LavaPack.loadBundle([["/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/app/dist/esm/index.esm2017.js",{"@firebase/component":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/component/dist/esm/index.esm2017.js","@firebase/logger":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/logger/dist/index.cjs.js","@firebase/util":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/util/dist/index.esm2017.js",idb:"/home/runner/work/metamask-extension/metamask-extension/node_modules/idb/build/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"FirebaseError",{enumerable:!0,get:function(){return r.FirebaseError}}),s._DEFAULT_ENTRY_NAME=s.SDK_VERSION=void 0,s._addComponent=U,s._addOrOverwriteComponent=function(e,t){e.container.addOrOverwriteComponent(t)},s._apps=void 0,s._clearComponents=function(){H.clear()}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,s._components=void 0,s._getProvider=W,s._isFirebaseApp=$,s._isFirebaseServerApp=function(e){return e.settings!==undefined},s._registerComponent=q,s._removeServiceInstance=function(e,t,s=M){W(e,t).clearInstance(s)},s._serverApps=void 0,s.deleteApp=X,s.getApp=function(e=M){const t=B.get(e);if(!t&&e===M&&(0,r.getDefaultAppConfig)())return z();if(!t)throw K.create("no-app",{appName:e});return t},s.getApps=function(){return Array.from(B.values())},s.initializeApp=z,s.initializeServerApp=function(e,t){if((0,r.isBrowser)()&&!(0,r.isWebWorker)())throw K.create("invalid-server-app-environment");t.automaticDataCollectionEnabled===undefined&&(t.automaticDataCollectionEnabled=!1);let s;s=$(e)?e.options:e;const n=Object.assign(Object.assign({},t),s);n.releaseOnDeref!==undefined&&delete n.releaseOnDeref;if(t.releaseOnDeref!==undefined&&"undefined"==typeof FinalizationRegistry)throw K.create("finalization-registry-not-supported",{});const o=""+(c=JSON.stringify(n),[...c].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0)),i=G.get(o);var c;if(i)return i.incRefCount(t.releaseOnDeref),i;const l=new a.ComponentContainer(o);for(const e of H.values())l.addComponent(e);const d=new Q(s,t,o,l);return G.set(o,d),d},s.onLog=function(e,t){if(null!==e&&"function"!=typeof e)throw K.create("invalid-log-argument");(0,n.setUserLogHandler)(e,t)},s.registerVersion=J,s.setLogLevel=function(e){(0,n.setLogLevel)(e)}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */;var a=e("@firebase/component"),n=e("@firebase/logger"),r=e("@firebase/util"),o=e("idb");
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class i{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const c="@firebase/app",l="0.10.18",d=new n.Logger("@firebase/app"),m="@firebase/app-compat",u="@firebase/analytics-compat",h="@firebase/analytics",f="@firebase/app-check-compat",p="@firebase/app-check",g="@firebase/auth",k="@firebase/auth-compat",b="@firebase/database",w="@firebase/data-connect",_="@firebase/database-compat",T="@firebase/functions",E="@firebase/functions-compat",I="@firebase/installations",S="@firebase/installations-compat",x="@firebase/messaging",y="@firebase/messaging-compat",A="@firebase/performance",v="@firebase/performance-compat",P="@firebase/remote-config",C="@firebase/remote-config-compat",j="@firebase/storage",N="@firebase/storage-compat",D="@firebase/firestore",R="@firebase/vertexai",F="@firebase/firestore-compat",L="firebase",M=s._DEFAULT_ENTRY_NAME="[DEFAULT]",O={[c]:"fire-core",[m]:"fire-core-compat",[h]:"fire-analytics",[u]:"fire-analytics-compat",[p]:"fire-app-check",[f]:"fire-app-check-compat",[g]:"fire-auth",[k]:"fire-auth-compat",[b]:"fire-rtdb",[w]:"fire-data-connect",[_]:"fire-rtdb-compat",[T]:"fire-fn",[E]:"fire-fn-compat",[I]:"fire-iid",[S]:"fire-iid-compat",[x]:"fire-fcm",[y]:"fire-fcm-compat",[A]:"fire-perf",[v]:"fire-perf-compat",[P]:"fire-rc",[C]:"fire-rc-compat",[j]:"fire-gcs",[N]:"fire-gcs-compat",[D]:"fire-fst",[F]:"fire-fst-compat",[R]:"fire-vertex","fire-js":"fire-js",[L]:"fire-js-all"},B=s._apps=new Map,G=s._serverApps=new Map,H=s._components=new Map;function U(e,t){try{e.container.addComponent(t)}catch(s){d.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,s)}}function q(e){const t=e.name;if(H.has(t))return d.debug(`There were multiple attempts to register component ${t}.`),!1;H.set(t,e);for(const t of B.values())U(t,e);for(const t of G.values())U(t,e);return!0}function W(e,t){const s=e.container.getProvider("heartbeat").getImmediate({optional:!0});return s&&s.triggerHeartbeat(),e.container.getProvider(t)}function $(e){return e.options!==undefined}const V={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},K=new r.ErrorFactory("app","Firebase",V);
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class Y{constructor(e,t,s){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new a.Component("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw K.create("app-deleted",{appName:this._name})}}
/**
 * @license
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class Q extends Y{constructor(e,t,s,a){const n=t.automaticDataCollectionEnabled!==undefined&&t.automaticDataCollectionEnabled,r={name:s,automaticDataCollectionEnabled:n};if(e.apiKey!==undefined)super(e,r,a);else{super(e.options,r,a)}this._serverConfig=Object.assign({automaticDataCollectionEnabled:n},t),this._finalizationRegistry=null,"undefined"!=typeof FinalizationRegistry&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=undefined,t.releaseOnDeref=undefined,J(c,l,"serverapp")}toJSON(){return undefined}get refCount(){return this._refCount}incRefCount(e){this.isDeleted||(this._refCount++,e!==undefined&&null!==this._finalizationRegistry&&this._finalizationRegistry.register(e,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){X(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw K.create("server-app-deleted")}}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */s.SDK_VERSION="11.2.0";function z(e,t={}){let s=e;if("object"!=typeof t){t={name:t}}const n=Object.assign({name:M,automaticDataCollectionEnabled:!1},t),o=n.name;if("string"!=typeof o||!o)throw K.create("bad-app-name",{appName:String(o)});if(s||(s=(0,r.getDefaultAppConfig)()),!s)throw K.create("no-options");const i=B.get(o);if(i){if((0,r.deepEqual)(s,i.options)&&(0,r.deepEqual)(n,i.config))return i;throw K.create("duplicate-app",{appName:o})}const c=new a.ComponentContainer(o);for(const e of H.values())c.addComponent(e);const l=new Y(s,n,c);return B.set(o,l),l}async function X(e){let t=!1;const s=e.name;if(B.has(s))t=!0,B.delete(s);else if(G.has(s)){e.decRefCount()<=0&&(G.delete(s),t=!0)}t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function J(e,t,s){var n;let r=null!==(n=O[e])&&void 0!==n?n:e;s&&(r+=`-${s}`);const o=r.match(/\s|\//),i=t.match(/\s|\//);if(o||i){const e=[`Unable to register library "${r}" with version "${t}":`];return o&&e.push(`library name "${r}" contains illegal characters (whitespace or "/")`),o&&i&&e.push("and"),i&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void d.warn(e.join(" "))}q(new a.Component(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}const Z="firebase-heartbeat-store";let ee=null;function te(){return ee||(ee=(0,o.openDB)("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(Z)}catch(e){console.warn(e)}}}).catch(e=>{throw K.create("idb-open",{originalErrorMessage:e.message})})),ee}async function se(e,t){try{const s=(await te()).transaction(Z,"readwrite"),a=s.objectStore(Z);await a.put(t,ae(e)),await s.done}catch(e){if(e instanceof r.FirebaseError)d.warn(e.message);else{const t=K.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});d.warn(t.message)}}}function ae(e){return`${e.name}!${e.options.appId}`}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class ne{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new oe(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=re();if(null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)))return;if(this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(e=>e.date===a))return;return this._heartbeatsCache.heartbeats.push({date:a,agent:s}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(e=>{const t=new Date(e.date).valueOf();return Date.now()-t<=2592e6}),this._storage.overwrite(this._heartbeatsCache)}catch(e){d.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";const t=re(),{heartbeatsToSend:s,unsentEntries:a}=function(e,t=1024){const s=[];let a=e.slice();for(const n of e){const e=s.find(e=>e.agent===n.agent);if(e){if(e.dates.push(n.date),ie(s)>t){e.dates.pop();break}}else if(s.push({agent:n.agent,dates:[n.date]}),ie(s)>t){s.pop();break}a=a.slice(1)}return{heartbeatsToSend:s,unsentEntries:a}}(this._heartbeatsCache.heartbeats),n=(0,r.base64urlEncodeWithoutPadding)(JSON.stringify({version:2,heartbeats:s}));return this._heartbeatsCache.lastSentHeartbeatDate=t,a.length>0?(this._heartbeatsCache.heartbeats=a,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),n}catch(e){return d.warn(e),""}}}function re(){return(new Date).toISOString().substring(0,10)}class oe{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,r.isIndexedDBAvailable)()&&(0,r.validateIndexedDBOpenable)().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await te()).transaction(Z),s=await t.objectStore(Z).get(ae(e));return await t.done,s}catch(e){if(e instanceof r.FirebaseError)d.warn(e.message);else{const t=K.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});d.warn(t.message)}}}(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return se(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return se(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}}}function ie(e){return(0,r.base64urlEncodeWithoutPadding)(JSON.stringify({version:2,heartbeats:e})).length}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var ce;ce="",q(new a.Component("platform-logger",e=>new i(e),"PRIVATE")),q(new a.Component("heartbeat",e=>new ne(e),"PRIVATE")),J(c,l,ce),J(c,l,"esm2017"),J("fire-js","")}}},{package:"@metamask/notification-services-controller>firebase>@firebase/app",file:"node_modules/@firebase/app/dist/esm/index.esm2017.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/component/dist/esm/index.esm2017.js",{"@firebase/util":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/util/dist/index.esm2017.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.Provider=s.ComponentContainer=s.Component=void 0;var a=e("@firebase/util");
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
s.Component=class{constructor(e,t,s){this.name=e,this.instanceFactory=t,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}};const n="[DEFAULT]";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class r{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new a.Deferred;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&e.resolve(s)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const s=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),a=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(s)&&!this.shouldAutoInitialize()){if(a)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:s})}catch(e){if(a)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */(e))try{this.getOrInitializeService({instanceIdentifier:n})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:s});t.resolve(e)}catch(e){}}}}clearInstance(e=n){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=n){return this.instances.has(e)}getOptions(e=n){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const a=this.getOrInitializeService({instanceIdentifier:s,options:t});for(const[e,t]of this.instancesDeferred.entries()){s===this.normalizeInstanceIdentifier(e)&&t.resolve(a)}return a}onInit(e,t){var s;const a=this.normalizeInstanceIdentifier(t),n=null!==(s=this.onInitCallbacks.get(a))&&void 0!==s?s:new Set;n.add(e),this.onInitCallbacks.set(a,n);const r=this.instances.get(a);return r&&e(r,a),()=>{n.delete(e)}}invokeOnInitCallbacks(e,t){const s=this.onInitCallbacks.get(t);if(s)for(const a of s)try{a(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:(a=e,a===n?undefined:a),options:t}),this.instances.set(e,s),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch(e){}var a;return s||null}normalizeInstanceIdentifier(e=n){return this.component?this.component.multipleInstances?e:n:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}s.Provider=r;s.ComponentContainer=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new r(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}}}},{package:"@metamask/notification-services-controller>firebase>@firebase/app>@firebase/component",file:"node_modules/@firebase/component/dist/esm/index.esm2017.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/installations/dist/esm/index.esm2017.js",{"@firebase/app":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/app/dist/esm/index.esm2017.js","@firebase/component":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/component/dist/esm/index.esm2017.js","@firebase/util":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/util/dist/index.esm2017.js",idb:"/home/runner/work/metamask-extension/metamask-extension/node_modules/idb/build/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.deleteInstallations=
/**
 * @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.
 */
async function(e){const{appConfig:t}=e,s=await H(t,e=>e&&0===e.registrationStatus?undefined:e);if(s){if(1===s.registrationStatus)throw p.create("delete-pending-registration");if(2===s.registrationStatus){if(!navigator.onLine)throw p.create("app-offline");
/**
 * @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.
 */
await async function(e,t){const s=function(e,{fid:t}){return`${k(e)}/${t}`}(e,t),a=T(e,t),n={method:"DELETE",headers:a},r=await E(()=>fetch(s,n));if(!r.ok)throw await w("Delete Installation",r)}(t,s),await G(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.
 */,s.getId=z,s.getInstallations=
/**
 * @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.
 */
function(e=(0,a.getApp)()){return(0,a._getProvider)(e,"installations").getImmediate()}
/**
 * @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.
 */,s.getToken=X,s.onIdChange=function(e,t){const{appConfig:s}=e;return function(e,t){N();const s=A(e);let a=v.get(s);a||(a=new Set,v.set(s,a));a.add(t)}(s,t),()=>{!function(e,t){const s=A(e),a=v.get(s);if(!a)return;a.delete(t),0===a.size&&v.delete(s);D()}(s,t)}};var a=e("@firebase/app"),n=e("@firebase/component"),r=e("@firebase/util"),o=e("idb");const i="@firebase/installations",c="0.6.12",l=1e4,d=`w:${c}`,m="FIS_v2",u="https://firebaseinstallations.googleapis.com/v1",h=36e5,f={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."},p=new r.ErrorFactory("installations","Installations",f);function g(e){return e instanceof r.FirebaseError&&e.code.includes("request-failed")}
/**
 * @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.
 */function k({projectId:e}){return`${u}/projects/${e}/installations`}function b(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function w(e,t){const s=(await t.json()).error;return p.create("request-failed",{requestName:e,serverCode:s.code,serverMessage:s.message,serverStatus:s.status})}function _({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function T(e,{refreshToken:t}){const s=_(e);return s.append("Authorization",function(e){return`${m} ${e}`}
/**
 * @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.
 */(t)),s}async function E(e){const t=await e();return t.status>=500&&t.status<600?e():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.
 */
function I(e){return new Promise(t=>{setTimeout(t,e)})}
/**
 * @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.
 */
/**
 * @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.
 */
const S=/^[cdef][\w-]{21}$/,x="";function y(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function(e){const t=(s=e,btoa(String.fromCharCode(...s)).replace(/\+/g,"-").replace(/\//g,"_"));var s;return t.substr(0,22)}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */(e);return S.test(t)?t:x}catch(e){return x}}function A(e){return`${e.appName}!${e.appId}`}
/**
 * @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.
 */const v=new Map;function P(e,t){const s=A(e);C(s,t),function(e,t){const s=N();s&&s.postMessage({key:e,fid:t});D()}(s,t)}function C(e,t){const s=v.get(e);if(s)for(const e of s)e(t)}let j=null;function N(){return!j&&"BroadcastChannel"in self&&(j=new BroadcastChannel("[Firebase] FID Change"),j.onmessage=e=>{C(e.data.key,e.data.fid)}),j}function D(){0===v.size&&j&&(j.close(),j=null)}
/**
 * @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.
 */const R="firebase-installations-database",F=1,L="firebase-installations-store";let M=null;function O(){return M||(M=(0,o.openDB)(R,F,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(L)}})),M}async function B(e,t){const s=A(e),a=(await O()).transaction(L,"readwrite"),n=a.objectStore(L),r=await n.get(s);return await n.put(t,s),await a.done,r&&r.fid===t.fid||P(e,t.fid),t}async function G(e){const t=A(e),s=(await O()).transaction(L,"readwrite");await s.objectStore(L).delete(t),await s.done}async function H(e,t){const s=A(e),a=(await O()).transaction(L,"readwrite"),n=a.objectStore(L),r=await n.get(s),o=t(r);return o===undefined?await n.delete(s):await n.put(o,s),await a.done,!o||r&&r.fid===o.fid||P(e,o.fid),o}
/**
 * @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.
 */async function U(e){let t;const s=await H(e.appConfig,s=>{const a=function(e){const t=e||{fid:y(),registrationStatus:0};return $(t)}(s),n=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine){return{installationEntry:t,registrationPromise:Promise.reject(p.create("app-offline"))}}const s={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},a=async function(e,t){try{const s=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:s}){const a=k(e),n=_(e),r=t.getImmediate({optional:!0});if(r){const e=await r.getHeartbeatsHeader();e&&n.append("x-firebase-client",e)}const o={fid:s,authVersion:m,appId:e.appId,sdkVersion:d},i={method:"POST",headers:n,body:JSON.stringify(o)},c=await E(()=>fetch(a,i));if(c.ok){const e=await c.json();return{fid:e.fid||s,registrationStatus:2,refreshToken:e.refreshToken,authToken:b(e.authToken)}}throw await w("Create Installation",c)}(e,t);return B(e.appConfig,s)}catch(s){throw g(s)&&409===s.customData.serverCode?await G(e.appConfig):await B(e.appConfig,{fid:t.fid,registrationStatus:0}),s}}(e,s);return{installationEntry:s,registrationPromise:a}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:q(e)}:{installationEntry:t}}(e,a);return t=n.registrationPromise,n.installationEntry});return s.fid===x?{installationEntry:await t}:{installationEntry:s,registrationPromise:t}}async function q(e){let t=await W(e.appConfig);for(;1===t.registrationStatus;)await I(100),t=await W(e.appConfig);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:s}=await U(e);return s||t}return t}function W(e){return H(e,e=>{if(!e)throw p.create("installation-not-found");return $(e)})}function $(e){return 1===(t=e).registrationStatus&&t.registrationTime+l<Date.now()?{fid:e.fid,registrationStatus:0}:e;var 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.
 */}async function V({appConfig:e,heartbeatServiceProvider:t},s){const a=function(e,{fid:t}){return`${k(e)}/${t}/authTokens:generate`}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */(e,s),n=T(e,s),r=t.getImmediate({optional:!0});if(r){const e=await r.getHeartbeatsHeader();e&&n.append("x-firebase-client",e)}const o={installation:{sdkVersion:d,appId:e.appId}},i={method:"POST",headers:n,body:JSON.stringify(o)},c=await E(()=>fetch(a,i));if(c.ok){return b(await c.json())}throw await w("Generate Auth Token",c)}async function K(e,t=!1){let s;const a=await H(e.appConfig,a=>{if(!Q(a))throw p.create("not-registered");const n=a.authToken;if(!t&&function(e){return 2===e.requestStatus&&!function(e){const t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+h}(e)}(n))return a;if(1===n.requestStatus)return s=async function(e,t){let s=await Y(e.appConfig);for(;1===s.authToken.requestStatus;)await I(100),s=await Y(e.appConfig);const a=s.authToken;return 0===a.requestStatus?K(e,t):a}(e,t),a;{if(!navigator.onLine)throw p.create("app-offline");const t=function(e){const t={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},e),{authToken:t})}(a);return s=async function(e,t){try{const s=await V(e,t),a=Object.assign(Object.assign({},t),{authToken:s});return await B(e.appConfig,a),s}catch(s){if(!g(s)||401!==s.customData.serverCode&&404!==s.customData.serverCode){const s=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await B(e.appConfig,s)}else await G(e.appConfig);throw s}}(e,t),t}});return s?await s:a.authToken}function Y(e){return H(e,e=>{if(!Q(e))throw p.create("not-registered");const t=e.authToken;return 1===(s=t).requestStatus&&s.requestTime+l<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e;var s;
/**
 * @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.
 */})}function Q(e){return e!==undefined&&2===e.registrationStatus}async function z(e){const t=e,{installationEntry:s,registrationPromise:a}=await U(t);return a?a.catch(console.error):K(t).catch(console.error),s.fid}
/**
 * @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.
 */async function X(e,t=!1){const s=e;await async function(e){const{registrationPromise:t}=await U(e);t&&await t}(s);return(await K(s,t)).token}function J(e){return p.create("missing-app-config-values",{valueName:e})}
/**
 * @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.
 */const Z="installations",ee=e=>{const t=e.getProvider("app").getImmediate(),s=function(e){if(!e||!e.options)throw J("App Configuration");if(!e.name)throw J("App Name");const t=["projectId","apiKey","appId"];for(const s of t)if(!e.options[s])throw J(s);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:s,heartbeatServiceProvider:(0,a._getProvider)(t,"heartbeat"),_delete:()=>Promise.resolve()}},te=e=>{const t=e.getProvider("app").getImmediate(),s=(0,a._getProvider)(t,Z).getImmediate();return{getId:()=>z(s),getToken:e=>X(s,e)}};(0,a._registerComponent)(new n.Component(Z,ee,"PUBLIC")),(0,a._registerComponent)(new n.Component("installations-internal",te,"PRIVATE")),(0,a.registerVersion)(i,c),(0,a.registerVersion)(i,c,"esm2017")}}},{package:"@metamask/notification-services-controller>firebase>@firebase/installations",file:"node_modules/@firebase/installations/dist/esm/index.esm2017.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/logger/dist/index.cjs.js",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!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.
 */
const a=[];var n;s.LogLevel=void 0,(n=s.LogLevel||(s.LogLevel={}))[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT";const r={debug:s.LogLevel.DEBUG,verbose:s.LogLevel.VERBOSE,info:s.LogLevel.INFO,warn:s.LogLevel.WARN,error:s.LogLevel.ERROR,silent:s.LogLevel.SILENT},o=s.LogLevel.INFO,i={[s.LogLevel.DEBUG]:"log",[s.LogLevel.VERBOSE]:"log",[s.LogLevel.INFO]:"info",[s.LogLevel.WARN]:"warn",[s.LogLevel.ERROR]:"error"},c=(e,t,...s)=>{if(t<e.logLevel)return;const a=(new Date).toISOString(),n=i[t];if(!n)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[n](`[${a}]  ${e.name}:`,...s)};s.Logger=class{constructor(e){this.name=e,this._logLevel=o,this._logHandler=c,this._userLogHandler=null,a.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in s.LogLevel))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?r[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,s.LogLevel.DEBUG,...e),this._logHandler(this,s.LogLevel.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,s.LogLevel.VERBOSE,...e),this._logHandler(this,s.LogLevel.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,s.LogLevel.INFO,...e),this._logHandler(this,s.LogLevel.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,s.LogLevel.WARN,...e),this._logHandler(this,s.LogLevel.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,s.LogLevel.ERROR,...e),this._logHandler(this,s.LogLevel.ERROR,...e)}},s.setLogLevel=function(e){a.forEach(t=>{t.setLogLevel(e)})},s.setUserLogHandler=function(e,t){for(const n of a){let a=null;t&&t.level&&(a=r[t.level]),n.userLogHandler=null===e?null:(t,n,...r)=>{const o=r.map(e=>{if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(e){return null}}).filter(e=>e).join(" ");n>=(null!=a?a:t.logLevel)&&e({level:s.LogLevel[n].toLowerCase(),message:o,args:r,type:t.name})}}}}}},{package:"@metamask/notification-services-controller>firebase>@firebase/app>@firebase/logger",file:"node_modules/@firebase/logger/dist/index.cjs.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/messaging/dist/esm/index.esm2017.js",{"@firebase/app":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/app/dist/esm/index.esm2017.js","@firebase/component":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/component/dist/esm/index.esm2017.js","@firebase/installations":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/installations/dist/esm/index.esm2017.js","@firebase/util":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/util/dist/index.esm2017.js",idb:"/home/runner/work/metamask-extension/metamask-extension/node_modules/idb/build/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.deleteToken=function(e){
/**
 * @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.
 */
return async function(e){if(!navigator)throw P.create("only-available-in-window");e.swRegistration||await G(e);return async function(e){const t=await x(e.firebaseDependencies);t&&(await C(e.firebaseDependencies,t.token),await async function(e){const t=A(e),s=(await S()).transaction(E,"readwrite");await s.objectStore(E).delete(t),await s.done}(e.firebaseDependencies));const s=await e.swRegistration.pushManager.getSubscription();if(s)return s.unsubscribe();return!0}(e)}
/**
 * @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.
 */(e=(0,r.getModularInstance)(e))},s.getMessaging=
/**
 * @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=(0,o.getApp)()){return Y().then(e=>{if(!e)throw P.create("unsupported-browser")},e=>{throw P.create("indexed-db-unsupported")}),(0,o._getProvider)((0,r.getModularInstance)(e),"messaging").getImmediate()},s.getToken=async function(e,t){return H(e=(0,r.getModularInstance)(e),t)},s.isSupported=Y,s.onMessage=function(e,t){return function(e,t){if(!navigator)throw P.create("only-available-in-window");return e.onMessageHandler=t,()=>{e.onMessageHandler=null}}(e=(0,r.getModularInstance)(e),t)},e("@firebase/installations");var a=e("@firebase/component"),n=e("idb"),r=e("@firebase/util"),o=e("@firebase/app");
/**
 * @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.
 */
const i="/firebase-messaging-sw.js",c="/firebase-cloud-messaging-push-scope",l="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",d="https://fcmregistrations.googleapis.com/v1",m="google.c.a.c_id",u=1e4;var h,f;
/**
 * @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 p(e){const t=new Uint8Array(e);return btoa(String.fromCharCode(...t)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function g(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),s=atob(t),a=new Uint8Array(s.length);for(let e=0;e<s.length;++e)a[e]=s.charCodeAt(e);return a}
/**
 * @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.
 */!function(e){e[e.DATA_MESSAGE=1]="DATA_MESSAGE",e[e.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION"}(h||(h={})),function(e){e.PUSH_RECEIVED="push-received",e.NOTIFICATION_CLICKED="notification-clicked"}(f||(f={}));const k="fcm_token_details_db",b=5,w="fcm_token_object_Store";
/**
 * @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.
 */
const _="firebase-messaging-database",T=1,E="firebase-messaging-store";let I=null;function S(){return I||(I=(0,n.openDB)(_,T,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(E)}})),I}async function x(e){const t=A(e),s=await S(),a=await s.transaction(E).objectStore(E).get(t);if(a)return a;{const t=await async function(e){if("databases"in indexedDB){const e=(await indexedDB.databases()).map(e=>e.name);if(!e.includes(k))return null}let t=null;return(await(0,n.openDB)(k,b,{upgrade:async(s,a,n,r)=>{var o;if(a<2)return;if(!s.objectStoreNames.contains(w))return;const i=r.objectStore(w),c=await i.index("fcmSenderId").get(e);if(await i.clear(),c)if(2===a){const e=c;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:null!==(o=e.createTime)&&void 0!==o?o:Date.now(),subscriptionOptions:{auth:e.auth,p256dh:e.p256dh,endpoint:e.endpoint,swScope:e.swScope,vapidKey:"string"==typeof e.vapidKey?e.vapidKey:p(e.vapidKey)}}}else if(3===a){const e=c;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:p(e.auth),p256dh:p(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:p(e.vapidKey)}}}else if(4===a){const e=c;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:p(e.auth),p256dh:p(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:p(e.vapidKey)}}}}})).close(),await(0,n.deleteDB)(k),await(0,n.deleteDB)("fcm_vapid_details_db"),await(0,n.deleteDB)("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;const{subscriptionOptions:t}=e;return"number"==typeof e.createTime&&e.createTime>0&&"string"==typeof e.token&&e.token.length>0&&"string"==typeof t.auth&&t.auth.length>0&&"string"==typeof t.p256dh&&t.p256dh.length>0&&"string"==typeof t.endpoint&&t.endpoint.length>0&&"string"==typeof t.swScope&&t.swScope.length>0&&"string"==typeof t.vapidKey&&t.vapidKey.length>0}(t)?t:null}(e.appConfig.senderId);if(t)return await y(e,t),t}}async function y(e,t){const s=A(e),a=(await S()).transaction(E,"readwrite");return await a.objectStore(E).put(t,s),await a.done,t}function A({appConfig:e}){return e.appId}
/**
 * @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 v={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."},P=new r.ErrorFactory("messaging","Messaging",v);async function C(e,t){const s={method:"DELETE",headers:await N(e)};try{const a=await fetch(`${j(e.appConfig)}/${t}`,s),n=await a.json();if(n.error){const e=n.error.message;throw P.create("token-unsubscribe-failed",{errorInfo:e})}}catch(e){throw P.create("token-unsubscribe-failed",{errorInfo:null==e?void 0:e.toString()})}}function j({projectId:e}){return`${d}/projects/${e}/registrations`}async function N({appConfig:e,installations:t}){const s=await t.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e.apiKey,"x-goog-firebase-installations-auth":`FIS ${s}`})}function D({p256dh:e,auth:t,endpoint:s,vapidKey:a}){const n={web:{endpoint:s,auth:t,p256dh:e}};return a!==l&&(n.web.applicationPubKey=a),n}
/**
 * @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.
 */const R=6048e5;async function F(e){const t=await async function(e,t){const s=await e.pushManager.getSubscription();if(s)return s;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:g(t)})}(e.swRegistration,e.vapidKey),s={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:p(t.getKey("auth")),p256dh:p(t.getKey("p256dh"))},a=await x(e.firebaseDependencies);if(a){if(function(e,t){const s=t.vapidKey===e.vapidKey,a=t.endpoint===e.endpoint,n=t.auth===e.auth,r=t.p256dh===e.p256dh;return s&&a&&n&&r}
/**
 * @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.
 */(a.subscriptionOptions,s))return Date.now()>=a.createTime+R?async function(e,t){try{const s=await async function(e,t){const s=await N(e),a=D(t.subscriptionOptions),n={method:"PATCH",headers:s,body:JSON.stringify(a)};let r;try{const s=await fetch(`${j(e.appConfig)}/${t.token}`,n);r=await s.json()}catch(e){throw P.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw P.create("token-update-failed",{errorInfo:e})}if(!r.token)throw P.create("token-update-no-token");return r.token}(e.firebaseDependencies,t),a=Object.assign(Object.assign({},t),{token:s,createTime:Date.now()});return await y(e.firebaseDependencies,a),s}catch(e){throw e}}(e,{token:a.token,createTime:Date.now(),subscriptionOptions:s}):a.token;try{await C(e.firebaseDependencies,a.token)}catch(e){console.warn(e)}return L(e.firebaseDependencies,s)}return L(e.firebaseDependencies,s)}async function L(e,t){const s=
/**
 * @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.
 */await async function(e,t){const s=await N(e),a=D(t),n={method:"POST",headers:s,body:JSON.stringify(a)};let r;try{const t=await fetch(j(e.appConfig),n);r=await t.json()}catch(e){throw P.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw P.create("token-subscribe-failed",{errorInfo:e})}if(!r.token)throw P.create("token-subscribe-no-token");return r.token}(e,t),a={token:s,createTime:Date.now(),subscriptionOptions:t};return await y(e,a),a.token}function M(e){const t={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return function(e,t){if(!t.notification)return;e.notification={};const s=t.notification.title;s&&(e.notification.title=s);const a=t.notification.body;a&&(e.notification.body=a);const n=t.notification.image;n&&(e.notification.image=n);const r=t.notification.icon;r&&(e.notification.icon=r)}(t,e),function(e,t){if(!t.data)return;e.data=t.data}(t,e),function(e,t){var s,a,n,r,o;if(!t.fcmOptions&&!(null===(s=t.notification)||void 0===s?void 0:s.click_action))return;e.fcmOptions={};const i=null!==(n=null===(a=t.fcmOptions)||void 0===a?void 0:a.link)&&void 0!==n?n:null===(r=t.notification)||void 0===r?void 0:r.click_action;i&&(e.fcmOptions.link=i);const c=null===(o=t.fcmOptions)||void 0===o?void 0:o.analytics_label;c&&(e.fcmOptions.analyticsLabel=c)}
/**
 * @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.
 */(t,e),t}function O(e){return P.create("missing-app-config-values",{valueName:e})}
/**
 * @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.
 */
/**
 * @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.
 */
!function(e,t){const s=[];for(let a=0;a<e.length;a++)s.push(e.charAt(a)),a<t.length&&s.push(t.charAt(a));s.join("")}
/**
 * @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.
 */("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class B{constructor(e,t,s){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const a=function(e){if(!e||!e.options)throw O("App Configuration Object");if(!e.name)throw O("App Name");const t=["projectId","apiKey","appId","messagingSenderId"],{options:s}=e;for(const e of t)if(!s[e])throw O(e);return{appName:e.name,projectId:s.projectId,apiKey:s.apiKey,appId:s.appId,senderId:s.messagingSenderId}}(e);this.firebaseDependencies={app:e,appConfig:a,installations:t,analyticsProvider:s}}_delete(){return Promise.resolve()}}
/**
 * @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.
 */async function G(e){try{e.swRegistration=await navigator.serviceWorker.register(i,{scope:c}),e.swRegistration.update().catch(()=>{}),await async function(e){return new Promise((t,s)=>{const a=setTimeout(()=>s(new Error(`Service worker not registered after ${u} ms`)),u),n=e.installing||e.waiting;e.active?(clearTimeout(a),t()):n?n.onstatechange=e=>{var s;"activated"===(null===(s=e.target)||void 0===s?void 0:s.state)&&(n.onstatechange=null,clearTimeout(a),t())}:(clearTimeout(a),s(new Error("No incoming service worker found.")))})}
/**
 * @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.
 */(e.swRegistration)}catch(e){throw P.create("failed-service-worker-registration",{browserErrorMessage:null==e?void 0:e.message})}}
/**
 * @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.
 */
async function H(e,t){if(!navigator)throw P.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw P.create("permission-blocked");
/**
 * @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.
 */
return await async function(e,t){t?e.vapidKey=t:e.vapidKey||(e.vapidKey=l)}(e,null==t?void 0:t.vapidKey),await async function(e,t){if(t||e.swRegistration||await G(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw P.create("invalid-sw-registration");e.swRegistration=t}}(e,null==t?void 0:t.serviceWorkerRegistration),F(e)}
/**
 * @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.
 */async function U(e,t,s){const a=function(e){switch(e){case f.NOTIFICATION_CLICKED:return"notification_open";case f.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}
/**
 * @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.
 */(t);(await e.firebaseDependencies.analyticsProvider.get()).logEvent(a,{message_id:s[m],message_name:s["google.c.a.c_l"],message_time:s["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)})}async function q(e,t){const s=t.data;if(!s.isFirebaseMessaging)return;e.onMessageHandler&&s.messageType===f.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(M(s)):e.onMessageHandler.next(M(s)));const a=s.data;var n;"object"==typeof(n=a)&&n&&m in n&&"1"===a["google.c.a.e"]&&await U(e,s.messageType,a)}const W="@firebase/messaging",$="0.12.16",V=e=>{const t=new B(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",e=>q(t,e)),t},K=e=>{const t=e.getProvider("messaging").getImmediate();return{getToken:e=>H(t,e)}};
/**
 * @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.
 */
async function Y(){try{await(0,r.validateIndexedDBOpenable)()}catch(e){return!1}return"undefined"!=typeof window&&(0,r.isIndexedDBAvailable)()&&(0,r.areCookiesEnabled)()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}(0,o._registerComponent)(new a.Component("messaging",V,"PUBLIC")),(0,o._registerComponent)(new a.Component("messaging-internal",K,"PRIVATE")),(0,o.registerVersion)(W,$),(0,o.registerVersion)(W,$,"esm2017")}}},{package:"@metamask/notification-services-controller>firebase>@firebase/messaging",file:"node_modules/@firebase/messaging/dist/esm/index.esm2017.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/messaging/dist/index.sw.cjs",{"@firebase/app":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/app/dist/esm/index.esm2017.js","@firebase/component":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/component/dist/esm/index.esm2017.js","@firebase/installations":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/installations/dist/esm/index.esm2017.js","@firebase/util":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/util/dist/index.esm2017.js",idb:"/home/runner/work/metamask-extension/metamask-extension/node_modules/idb/build/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),e("@firebase/installations");var a=e("@firebase/component"),n=e("idb"),r=e("@firebase/util"),o=e("@firebase/app");
/**
 * @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.
 */
const i="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",c="FCM_MSG";var l,d;
/**
 * @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 m(e){const t=new Uint8Array(e);return btoa(String.fromCharCode(...t)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function u(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),s=atob(t),a=new Uint8Array(s.length);for(let e=0;e<s.length;++e)a[e]=s.charCodeAt(e);return a}
/**
 * @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.
 */!function(e){e[e.DATA_MESSAGE=1]="DATA_MESSAGE",e[e.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION"}(l||(l={})),function(e){e.PUSH_RECEIVED="push-received",e.NOTIFICATION_CLICKED="notification-clicked"}(d||(d={}));const h="fcm_token_details_db",f="fcm_token_object_Store";
/**
 * @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.
 */
const p="firebase-messaging-store";let g=null;function k(){return g||(g=n.openDB("firebase-messaging-database",1,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(p)}})),g}async function b(e){const t=_(e),s=await k(),a=await s.transaction(p).objectStore(p).get(t);if(a)return a;{const t=await async function(e){if("databases"in indexedDB){const e=(await indexedDB.databases()).map(e=>e.name);if(!e.includes(h))return null}let t=null;return(await n.openDB(h,5,{upgrade:async(s,a,n,r)=>{var o;if(a<2)return;if(!s.objectStoreNames.contains(f))return;const i=r.objectStore(f),c=await i.index("fcmSenderId").get(e);if(await i.clear(),c)if(2===a){const e=c;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:null!==(o=e.createTime)&&void 0!==o?o:Date.now(),subscriptionOptions:{auth:e.auth,p256dh:e.p256dh,endpoint:e.endpoint,swScope:e.swScope,vapidKey:"string"==typeof e.vapidKey?e.vapidKey:m(e.vapidKey)}}}else if(3===a){const e=c;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:m(e.auth),p256dh:m(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:m(e.vapidKey)}}}else if(4===a){const e=c;t={token:e.fcmToken,createTime:e.createTime,subscriptionOptions:{auth:m(e.auth),p256dh:m(e.p256dh),endpoint:e.endpoint,swScope:e.swScope,vapidKey:m(e.vapidKey)}}}}})).close(),await n.deleteDB(h),await n.deleteDB("fcm_vapid_details_db"),await n.deleteDB("undefined"),function(e){if(!e||!e.subscriptionOptions)return!1;const{subscriptionOptions:t}=e;return"number"==typeof e.createTime&&e.createTime>0&&"string"==typeof e.token&&e.token.length>0&&"string"==typeof t.auth&&t.auth.length>0&&"string"==typeof t.p256dh&&t.p256dh.length>0&&"string"==typeof t.endpoint&&t.endpoint.length>0&&"string"==typeof t.swScope&&t.swScope.length>0&&"string"==typeof t.vapidKey&&t.vapidKey.length>0}(t)?t:null}(e.appConfig.senderId);if(t)return await w(e,t),t}}async function w(e,t){const s=_(e),a=(await k()).transaction(p,"readwrite");return await a.objectStore(p).put(t,s),await a.done,t}function _({appConfig:e}){return e.appId}
/**
 * @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={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."},E=new r.ErrorFactory("messaging","Messaging",T);async function I(e,t){const s={method:"DELETE",headers:await x(e)};try{const a=await fetch(`${S(e.appConfig)}/${t}`,s),n=await a.json();if(n.error){const e=n.error.message;throw E.create("token-unsubscribe-failed",{errorInfo:e})}}catch(e){throw E.create("token-unsubscribe-failed",{errorInfo:null==e?void 0:e.toString()})}}function S({projectId:e}){return`https://fcmregistrations.googleapis.com/v1/projects/${e}/registrations`}async function x({appConfig:e,installations:t}){const s=await t.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e.apiKey,"x-goog-firebase-installations-auth":`FIS ${s}`})}function y({p256dh:e,auth:t,endpoint:s,vapidKey:a}){const n={web:{endpoint:s,auth:t,p256dh:e}};return a!==i&&(n.web.applicationPubKey=a),n}
/**
 * @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.
 */async function A(e){const t=await async function(e,t){const s=await e.pushManager.getSubscription();if(s)return s;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:u(t)})}(e.swRegistration,e.vapidKey),s={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:m(t.getKey("auth")),p256dh:m(t.getKey("p256dh"))},a=await b(e.firebaseDependencies);if(a){if(function(e,t){const s=t.vapidKey===e.vapidKey,a=t.endpoint===e.endpoint,n=t.auth===e.auth,r=t.p256dh===e.p256dh;return s&&a&&n&&r}
/**
 * @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.
 */(a.subscriptionOptions,s))return Date.now()>=a.createTime+6048e5?async function(e,t){try{const s=await async function(e,t){const s=await x(e),a=y(t.subscriptionOptions),n={method:"PATCH",headers:s,body:JSON.stringify(a)};let r;try{const s=await fetch(`${S(e.appConfig)}/${t.token}`,n);r=await s.json()}catch(e){throw E.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw E.create("token-update-failed",{errorInfo:e})}if(!r.token)throw E.create("token-update-no-token");return r.token}(e.firebaseDependencies,t),a=Object.assign(Object.assign({},t),{token:s,createTime:Date.now()});return await w(e.firebaseDependencies,a),s}catch(e){throw e}}(e,{token:a.token,createTime:Date.now(),subscriptionOptions:s}):a.token;try{await I(e.firebaseDependencies,a.token)}catch(e){console.warn(e)}return P(e.firebaseDependencies,s)}return P(e.firebaseDependencies,s)}async function v(e){const t=await b(e.firebaseDependencies);t&&(await I(e.firebaseDependencies,t.token),await async function(e){const t=_(e),s=(await k()).transaction(p,"readwrite");await s.objectStore(p).delete(t),await s.done}(e.firebaseDependencies));const s=await e.swRegistration.pushManager.getSubscription();return!s||s.unsubscribe()}async function P(e,t){const s=
/**
 * @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.
 */await async function(e,t){const s=await x(e),a=y(t),n={method:"POST",headers:s,body:JSON.stringify(a)};let r;try{const t=await fetch(S(e.appConfig),n);r=await t.json()}catch(e){throw E.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw E.create("token-subscribe-failed",{errorInfo:e})}if(!r.token)throw E.create("token-subscribe-no-token");return r.token}(e,t),a={token:s,createTime:Date.now(),subscriptionOptions:t};return await w(e,a),a.token}async function C(e,t){const s=function(e,t){var s,a;const n={};e.from&&(n.project_number=e.from);e.fcmMessageId&&(n.message_id=e.fcmMessageId);n.instance_id=t,e.notification?n.message_type=l.DISPLAY_NOTIFICATION.toString():n.message_type=l.DATA_MESSAGE.toString();n.sdk_platform=3..toString(),n.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),!e.collapse_key||(n.collapse_key=e.collapse_key);n.event=1..toString(),!(null===(s=e.fcmOptions)||void 0===s?void 0:s.analytics_label)||(n.analytics_label=null===(a=e.fcmOptions)||void 0===a?void 0:a.analytics_label);return n}(t,await e.firebaseDependencies.installations.getId());!function(e,t,s){const a={};a.event_time_ms=Math.floor(Date.now()).toString(),a.source_extension_json_proto3=JSON.stringify({messaging_client_event:t}),!s||(a.compliance_data=function(e){const t={privacy_context:{prequest:{origin_associated_product_id:e}}};return t}(s));e.logEvents.push(a)}(e,s,t.productId)}async function j(e,t){const s=function({data:e}){if(!e)return null;try{return e.json()}catch(e){return null}}(e);if(!s)return;t.deliveryMetricsExportedToBigQueryEnabled&&await C(t,s);const a=await D();if(function(e){return e.some(e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://"))}(a))return function(e,t){t.isFirebaseMessaging=!0,t.messageType=d.PUSH_RECEIVED;for(const s of e)s.postMessage(t)}(a,s);if(s.notification&&await function(e){var t;const{actions:s}=e,{maxActions:a}=Notification;s&&a&&s.length>a&&console.warn(`This browser only supports ${a} actions. The remaining actions will not be displayed.`);return self.registration.showNotification(null!==(t=e.title)&&void 0!==t?t:"",e)}(function(e){const t=Object.assign({},e.notification);return t.data={[c]:e},t}(s)),t&&t.onBackgroundMessageHandler){const e=function(e){const t={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return function(e,t){if(!t.notification)return;e.notification={};const s=t.notification.title;s&&(e.notification.title=s);const a=t.notification.body;a&&(e.notification.body=a);const n=t.notification.image;n&&(e.notification.image=n);const r=t.notification.icon;r&&(e.notification.icon=r)}(t,e),function(e,t){t.data&&(e.data=t.data)}(t,e),function(e,t){var s,a,n,r,o;if(!t.fcmOptions&&!(null===(s=t.notification)||void 0===s?void 0:s.click_action))return;e.fcmOptions={};const i=null!==(n=null===(a=t.fcmOptions)||void 0===a?void 0:a.link)&&void 0!==n?n:null===(r=t.notification)||void 0===r?void 0:r.click_action;i&&(e.fcmOptions.link=i);const c=null===(o=t.fcmOptions)||void 0===o?void 0:o.analytics_label;c&&(e.fcmOptions.analyticsLabel=c)}
/**
 * @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.
 */(t,e),t}(s);"function"==typeof t.onBackgroundMessageHandler?await t.onBackgroundMessageHandler(e):t.onBackgroundMessageHandler.next(e)}}async function N(e){var t,s;const a=null===(s=null===(t=e.notification)||void 0===t?void 0:t.data)||void 0===s?void 0:s[c];if(!a)return;if(e.action)return;e.stopImmediatePropagation(),e.notification.close();const n=function(e){var t,s,a;const n=null!==(s=null===(t=e.fcmOptions)||void 0===t?void 0:t.link)&&void 0!==s?s:null===(a=e.notification)||void 0===a?void 0:a.click_action;if(n)return n;return r=e.data,"object"==typeof r&&r&&"google.c.a.c_id"in r?self.location.origin:null;var r;
/**
 * @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.
 */}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */(a);if(!n)return;const r=new URL(n,self.location.href),o=new URL(self.location.origin);if(r.host!==o.host)return;let i=await async function(e){const t=await D();for(const s of t){const t=new URL(s.url,self.location.href);if(e.host===t.host)return s}return null}(r);var l;
/**
 * @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.
 */return i?i=await i.focus():(i=await self.clients.openWindow(n),await(l=3e3,new Promise(e=>{setTimeout(e,l)}))),i?(a.messageType=d.NOTIFICATION_CLICKED,a.isFirebaseMessaging=!0,i.postMessage(a)):void 0}function D(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function R(e){return E.create("missing-app-config-values",{valueName:e})}
/**
 * @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.
 */!function(e,t){const s=[];for(let a=0;a<e.length;a++)s.push(e.charAt(a)),a<t.length&&s.push(t.charAt(a));s.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.
 */("AzSCbw63g1R0nCw85jG8","Iaya3yLKwmgvh7cF0q4");class F{constructor(e,t,s){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const a=function(e){if(!e||!e.options)throw R("App Configuration Object");if(!e.name)throw R("App Name");const t=["projectId","apiKey","appId","messagingSenderId"],{options:s}=e;for(const e of t)if(!s[e])throw R(e);return{appName:e.name,projectId:s.projectId,apiKey:s.apiKey,appId:s.appId,senderId:s.messagingSenderId}}(e);this.firebaseDependencies={app:e,appConfig:a,installations:t,analyticsProvider:s}}_delete(){return Promise.resolve()}}
/**
 * @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.
 */const L=e=>{const t=new F(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",e=>{e.waitUntil(j(e,t))}),self.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(async function(e,t){var s,a;const{newSubscription:n}=e;if(!n)return void await v(t);const r=await b(t.firebaseDependencies);await v(t),t.vapidKey=null!==(a=null===(s=null==r?void 0:r.subscriptionOptions)||void 0===s?void 0:s.vapidKey)&&void 0!==a?a:i,await A(t)}(e,t))}),self.addEventListener("notificationclick",e=>{e.waitUntil(N(e))}),t};
/**
 * @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.
 */
async function M(){return r.isIndexedDBAvailable()&&await r.validateIndexedDBOpenable()&&"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}
/**
 * @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.
 */o._registerComponent(new a.Component("messaging-sw",L,"PUBLIC")),s.experimentalSetDeliveryMetricsExportedToBigQueryEnabled=function(e,t){
/**
 * @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.
 */
return function(e,t){e.deliveryMetricsExportedToBigQueryEnabled=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.
 */(e=r.getModularInstance(e),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.
 */,s.getMessaging=function(e=o.getApp()){return M().then(e=>{if(!e)throw E.create("unsupported-browser")},e=>{throw E.create("indexed-db-unsupported")}),o._getProvider(r.getModularInstance(e),"messaging-sw").getImmediate()},s.isSupported=M,s.onBackgroundMessage=function(e,t){return function(e,t){if(self.document!==undefined)throw E.create("only-available-in-sw");return e.onBackgroundMessageHandler=t,()=>{e.onBackgroundMessageHandler=null}}(e=r.getModularInstance(e),t)}}}},{package:"@metamask/notification-services-controller>firebase>@firebase/messaging",file:"node_modules/@firebase/messaging/dist/index.sw.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@firebase/util/dist/index.esm2017.js",{_process:"/home/runner/work/metamask-extension/metamask-extension/node_modules/process/browser.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){(function(e){(function(){Object.defineProperty(s,"__esModule",{value:!0}),s.Sha1=s.RANDOM_FACTOR=s.MAX_VALUE_MILLIS=s.FirebaseError=s.ErrorFactory=s.Deferred=s.DecodeBase64StringError=s.CONSTANTS=void 0,s.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.
 */,s.assertionError=s.assert=void 0,s.async=function(e,t){return(...s)=>{Promise.resolve(!0).then(()=>{e(...s)}).catch(e=>{t&&t(e)})}},s.base64urlEncodeWithoutPadding=s.base64Encode=s.base64Decode=s.base64=void 0,s.calculateBackoffMillis=function(e,t=P,s=C){const a=t*Math.pow(s,e),n=Math.round(N*a*(Math.random()-.5)*2);return Math.min(j,a+n)}
/**
 * @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.
 */,s.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.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 s=t||"demo-project",a=e.iat||0,n=e.sub||e.user_id;if(!n)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const r=Object.assign({iss:`https://securetoken.google.com/${s}`,aud:s,iat:a,exp:a+3600,auth_time:a,sub:n,user_id:n,firebase:{sign_in_provider:"custom",identities:{}}},e);return[l(JSON.stringify({alg:"none",type:"JWT"})),l(JSON.stringify(r)),""].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.
 */,s.createSubscribe=function(e,t){const s=new y(e,t);return s.subscribe.bind(s)},s.decode=void 0,s.deepCopy=function(e){return m(undefined,e)},s.deepEqual=function e(t,s){if(t===s)return!0;const a=Object.keys(t),n=Object.keys(s);for(const r of a){if(!n.includes(r))return!1;const a=t[r],o=s[r];if(x(a)&&x(o)){if(!e(a,o))return!1}else if(a!==o)return!1}for(const e of n)if(!a.includes(e))return!1;return!0},s.deepExtend=m,s.errorPrefix=v,s.extractQuerystring=function(e){const t=e.indexOf("?");if(!t)return"";const s=e.indexOf("#",t);return e.substring(t,s>0?s: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.
 */,s.getExperimentalSetting=s.getDefaults=s.getDefaultEmulatorHostnameAndPort=s.getDefaultEmulatorHost=s.getDefaultAppConfig=void 0,s.getGlobal=h,s.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},s.getUA=k,s.isAdmin=void 0,s.isBrowser=function(){return"undefined"!=typeof window||w()},s.isBrowserExtension=function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:undefined;return"object"==typeof e&&e.id!==undefined},s.isCloudflareWorker=function(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent},s.isElectron=function(){return k().indexOf("Electron/")>=0},s.isEmpty=function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},s.isIE=function(){const e=k();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0},s.isIndexedDBAvailable=function(){try{return"object"==typeof indexedDB}catch(e){return!1}},s.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(k())},s.isNode=b,s.isNodeSdk=function(){return!0===t.NODE_CLIENT||!0===t.NODE_ADMIN},s.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},s.isSafari=function(){return!b()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},s.isUWP=function(){return k().indexOf("MSAppHost/")>=0},s.isValidTimestamp=s.isValidFormat=void 0,s.isWebWorker=w,s.issuedAtTime=void 0,s.jsonEval=I,s.map=function(e,t,s){const a={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=t.call(s,e[n],n,e));return a},s.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 s=e%10;if(1===s)return"st";if(2===s)return"nd";if(3===s)return"rd";return"th"}(e)},s.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 s=new g;return setTimeout(()=>s.reject("timeout!"),t),e.then(s.resolve,s.reject),s.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.
 */,s.querystring=function(e){const t=[];for(const[s,a]of Object.entries(e))Array.isArray(a)?a.forEach(e=>{t.push(encodeURIComponent(s)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(s)+"="+encodeURIComponent(a));return t.length?"&"+t.join("&"):""},s.querystringDecode=function(e){const t={},s=e.replace(/^\?/,"").split("&");return s.forEach(e=>{if(e){const[s,a]=e.split("=");t[decodeURIComponent(s)]=decodeURIComponent(a)}}),t},s.safeGet=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:undefined},s.stringToByteArray=s.stringLength=void 0,s.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.
 */,s.validateArgCount=void 0,s.validateCallback=function(e,t,s,a){if(a&&!s)return;if("function"!=typeof s)throw new Error(v(e,t)+"must be a valid function.")},s.validateContextObject=function(e,t,s,a){if(a&&!s)return;if("object"!=typeof s||null===s)throw new Error(v(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.
 */,s.validateIndexedDBOpenable=function(){return new Promise((e,t)=>{try{let s=!0;const a="validate-browser-context-for-indexeddb-analytics-module",n=self.indexedDB.open(a);n.onsuccess=()=>{n.result.close(),s||self.indexedDB.deleteDatabase(a),e(!0)},n.onupgradeneeded=()=>{s=!1},n.onerror=()=>{var e;t((null===(e=n.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}})},s.validateNamespace=function(e,t,s){if(s&&!t)return;if("string"!=typeof t)throw new Error(v(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=s.CONSTANTS={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},a=function(e,t){if(!e)throw n(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.
 */s.assert=a;const n=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.
 */s.assertionError=n;const r=function(e){const t=[];let s=0;for(let a=0;a<e.length;a++){let n=e.charCodeAt(a);n<128?t[s++]=n:n<2048?(t[s++]=n>>6|192,t[s++]=63&n|128):55296==(64512&n)&&a+1<e.length&&56320==(64512&e.charCodeAt(a+1))?(n=65536+((1023&n)<<10)+(1023&e.charCodeAt(++a)),t[s++]=n>>18|240,t[s++]=n>>12&63|128,t[s++]=n>>6&63|128,t[s++]=63&n|128):(t[s++]=n>>12|224,t[s++]=n>>6&63|128,t[s++]=63&n|128)}return t},o=s.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 s=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,a=[];for(let t=0;t<e.length;t+=3){const n=e[t],r=t+1<e.length,o=r?e[t+1]:0,i=t+2<e.length,c=i?e[t+2]:0,l=n>>2,d=(3&n)<<4|o>>4;let m=(15&o)<<2|c>>6,u=63&c;i||(u=64,r||(m=64)),a.push(s[l],s[d],s[m],s[u])}return a.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(r(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let s=0,a=0;for(;s<e.length;){const n=e[s++];if(n<128)t[a++]=String.fromCharCode(n);else if(n>191&&n<224){const r=e[s++];t[a++]=String.fromCharCode((31&n)<<6|63&r)}else if(n>239&&n<365){const r=((7&n)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536;t[a++]=String.fromCharCode(55296+(r>>10)),t[a++]=String.fromCharCode(56320+(1023&r))}else{const r=e[s++],o=e[s++];t[a++]=String.fromCharCode((15&n)<<12|(63&r)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const s=t?this.charToByteMapWebSafe_:this.charToByteMap_,a=[];for(let t=0;t<e.length;){const n=s[e.charAt(t++)],r=t<e.length?s[e.charAt(t)]:0;++t;const o=t<e.length?s[e.charAt(t)]:64;++t;const c=t<e.length?s[e.charAt(t)]:64;if(++t,null==n||null==r||null==o||null==c)throw new i;const l=n<<2|r>>4;if(a.push(l),64!==o){const e=r<<4&240|o>>2;if(a.push(e),64!==c){const e=o<<6&192|c;a.push(e)}}}return a},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 i extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}s.DecodeBase64StringError=i;const c=function(e){const t=r(e);return o.encodeByteArray(t,!0)};s.base64Encode=c;const l=function(e){return c(e).replace(/\./g,"")};s.base64urlEncodeWithoutPadding=l;const d=function(e){try{return o.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 m(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 s in t)t.hasOwnProperty(s)&&u(s)&&(e[s]=m(e[s],t[s]));return e}function u(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 h(){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.
 */s.base64Decode=d;const f=()=>{try{return h().__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&&d(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}};s.getDefaults=f;const p=e=>{var t,s;return null===(s=null===(t=f())||void 0===t?void 0:t.emulatorHosts)||void 0===s?void 0:s[e]};s.getDefaultEmulatorHost=p;s.getDefaultEmulatorHostnameAndPort=e=>{const t=p(e);if(!t)return undefined;const s=t.lastIndexOf(":");if(s<=0||s+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const a=parseInt(t.substring(s+1),10);return"["===t[0]?[t.substring(1,s-1),a]:[t.substring(0,s),a]};s.getDefaultAppConfig=()=>{var e;return null===(e=f())||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.
 */
s.getExperimentalSetting=e=>{var t;return null===(t=f())||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,s)=>{t?this.reject(t):this.resolve(s),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,s))}}}
/**
 * @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 k(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function b(){var e;const t=null===(e=f())||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 w(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}s.Deferred=g;class _ extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name="FirebaseError",Object.setPrototypeOf(this,_.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,T.prototype.create)}}s.FirebaseError=_;class T{constructor(e,t,s){this.service=e,this.serviceName=t,this.errors=s}create(e,...t){const s=t[0]||{},a=`${this.service}/${e}`,n=this.errors[e],r=n?function(e,t){return e.replace(E,(e,s)=>{const a=t[s];return null!=a?String(a):`<${s}?>`})}(n,s):"Error",o=`${this.serviceName}: ${r} (${a}).`;return new _(a,o,s)}}s.ErrorFactory=T;const E=/\{\$([^}]+)}/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 I(e){return JSON.parse(e)}const S=function(e){let t={},s={},a={},n="";try{const r=e.split(".");t=I(d(r[0])||""),s=I(d(r[1])||""),n=r[2],a=s.d||{},delete s.d}catch(e){}return{header:t,claims:s,data:a,signature:n}};s.decode=S;s.isValidTimestamp=function(e){const t=S(e).claims,s=Math.floor((new Date).getTime()/1e3);let a=0,n=0;return"object"==typeof t&&(t.hasOwnProperty("nbf")?a=t.nbf:t.hasOwnProperty("iat")&&(a=t.iat),n=t.hasOwnProperty("exp")?t.exp:a+86400),!!s&&!!a&&!!n&&s>=a&&s<=n};s.issuedAtTime=function(e){const t=S(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null};s.isValidFormat=function(e){const t=S(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")};function x(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.
 */
s.isAdmin=function(e){const t=S(e).claims;return"object"==typeof t&&!0===t.admin};s.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 s=this.W_;if("string"==typeof e)for(let a=0;a<16;a++)s[a]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let a=0;a<16;a++)s[a]=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=s[e-3]^s[e-8]^s[e-14]^s[e-16];s[e]=4294967295&(t<<1|t>>>31)}let a,n,r=this.chain_[0],o=this.chain_[1],i=this.chain_[2],c=this.chain_[3],l=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(a=c^o&(i^c),n=1518500249):(a=o^i^c,n=1859775393):e<60?(a=o&i|c&(o|i),n=2400959708):(a=o^i^c,n=3395469782);const t=(r<<5|r>>>27)+a+l+n+s[e]&4294967295;l=c,c=i,i=4294967295&(o<<30|o>>>2),o=r,r=t}this.chain_[0]=this.chain_[0]+r&4294967295,this.chain_[1]=this.chain_[1]+o&4294967295,this.chain_[2]=this.chain_[2]+i&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 s=t-this.blockSize;let a=0;const n=this.buf_;let r=this.inbuf_;for(;a<t;){if(0===r)for(;a<=s;)this.compress_(e,a),a+=this.blockSize;if("string"==typeof e){for(;a<t;)if(n[r]=e.charCodeAt(a),++r,++a,r===this.blockSize){this.compress_(n),r=0;break}}else for(;a<t;)if(n[r]=e[a],++r,++a,r===this.blockSize){this.compress_(n),r=0;break}}this.inbuf_=r,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 s=0;for(let t=0;t<5;t++)for(let a=24;a>=0;a-=8)e[s]=this.chain_[t]>>a&255,++s;return e}};class y{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,s){let a;if(e===undefined&&t===undefined&&s===undefined)throw new Error("Missing Observer.");a=function(e,t){if("object"!=typeof e||null===e)return!1;for(const s of t)if(s in e&&"function"==typeof e[s])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:s},a.next===undefined&&(a.next=A),a.error===undefined&&(a.error=A),a.complete===undefined&&(a.complete=A);const n=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?a.error(this.finalError):a.complete()}catch(e){}}),this.observers.push(a),n}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 A(){}
/**
 * @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 v(e,t){return`${e} failed: ${t} argument `}s.validateArgCount=function(e,t,s,a){let n;if(a<t?n="at least "+t:a>s&&(n=0===s?"none":"no more than "+s),n){throw new Error(e+" failed: Was called with "+a+(1===a?" argument.":" arguments.")+" Expects "+n+".")}};s.stringToByteArray=function(e){const t=[];let s=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>=55296&&r<=56319){const t=r-55296;n++,a(n<e.length,"Surrogate pair missing trail surrogate.");r=65536+(t<<10)+(e.charCodeAt(n)-56320)}r<128?t[s++]=r:r<2048?(t[s++]=r>>6|192,t[s++]=63&r|128):r<65536?(t[s++]=r>>12|224,t[s++]=r>>6&63|128,t[s++]=63&r|128):(t[s++]=r>>18|240,t[s++]=r>>12&63|128,t[s++]=r>>6&63|128,t[s++]=63&r|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.
 */
s.stringLength=function(e){let t=0;for(let s=0;s<e.length;s++){const a=e.charCodeAt(s);a<128?t++:a<2048?t+=2:a>=55296&&a<=56319?(t+=4,s++):t+=3}return t};const P=1e3,C=2,j=s.MAX_VALUE_MILLIS=144e5,N=s.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"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-spec/json-pointer/lib/index.js",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0});class a{static parse(e){if(""===e)return new a([]);if(!e.startsWith("/"))throw new n(e);const[,...t]=e.split("/");return new a(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 r(e,t);e=e[t]}return e}}s.default=a;class n extends Error{constructor(e){super(`Invalid JSON Pointer: ${e}`),this.ptr=e}}s.InvalidPtrError=n;class r extends Error{constructor(e,t){super(`Error evaluating JSON Pointer: no attribute ${t} on ${e}`),this.instance=e,this.token=t}}s.EvalError=r}}},{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"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/dereferencer/build/dereferencer.js",{"@json-schema-tools/reference-resolver":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/index-web.js","@json-schema-tools/traverse":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/traverse/build/index.js","fast-safe-stringify":"/home/runner/work/metamask-extension/metamask-extension/node_modules/fast-safe-stringify/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,s=1,a=arguments.length;s<a;s++)for(var n in t=arguments[s])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},a.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,s,a){return new(s||(s=Promise))(function(n,r){function o(e){try{c(a.next(e))}catch(e){r(e)}}function i(e){try{c(a.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(o,i)}c((a=a.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var s,a,n,r,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(c){return function(i){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(o=0)),o;)try{if(s=1,a&&(n=2&i[0]?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,a=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){o.label=i[1];break}if(6===i[0]&&o.label<n[1]){o.label=n[1],n=i;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(i);break}n[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],a=0}finally{s=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.NonStringRefError=void 0;var i=o(e("@json-schema-tools/traverse")),c=o(e("@json-schema-tools/reference-resolver")),l=o(e("fast-safe-stringify")),d=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")};s.NonStringRefError=d;var m=function(e,t){if(e.$ref!==undefined&&Object.keys(e).length>1&&!0!==t&&!1!==t){var s=a(a({},t),e);return delete s.$ref,s}return t},u=function(){function e(e,t){var s;if(void 0===t&&(t={}),this.options=t,this.refCache={},s=!0===this.options.mutate||!0===e||!1===e?e:a({},e),this.options.recursive===undefined&&(this.options.recursive=!0),this.options.rootSchema===undefined&&(this.options.rootSchema=s),!0!==e&&!1!==e&&e.$id&&(this.options.rootSchema=s),this.options.refCache&&(this.refCache=this.options.refCache),this.options.protocolHandlerMap)for(var n=0,r=Object.keys(this.options.protocolHandlerMap);n<r.length;n++){var o=r[n];c.default.protocolHandlerMap[o]=this.options.protocolHandlerMap[o]}this.schema=s,this.refs=this.collectRefs()}return e.prototype.resolve=function(){return n(this,void 0,void 0,function(){return r(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 n(this,void 0,void 0,function(){var t,s,n,o,l,d,u,h,f,p,g,k=this;return r(this,function(r){switch(r.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 k.refCache[e]===undefined}),s=[],n=0,o=t,r.label=1;case 1:return n<o.length?(l=o[n],d=void 0,this.refCache[l]===undefined?[3,2]:(d=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 d=this.options.rootSchema,[3,5];case 3:return u=c.default.resolve(l,this.options.rootSchema),s.push(u),[4,u];case 4:d=r.sent(),r.label=5;case 5:return!0!==this.options.recursive||!0===d||!1===d||"#"===l?[3,9]:(h=a(a({},this.options),{refCache:this.refCache}),0===(f=new e(d,h)).refs.length?[3,7]:(p=f._resolve(),s.push(p),[4,p]));case 6:return g=r.sent(),this.refCache[l]=m(d,g),[3,8];case 7:this.refCache[l]=d,r.label=8;case 8:return[3,10];case 9:this.refCache[l]=d,r.label=10;case 10:return n++,[3,1];case 11:return this.schema.$ref!==undefined?this.schema=m(this.schema,this.refCache[this.schema.$ref]):(0,i.default)(this.schema,function(e){if(!0===e||!1===e)return e;if(e.$ref!==undefined){var t=k.refCache[e.$ref];return m(e,t)}return e},{mutable:!0}),[4,Promise.all(s)];case 12:return r.sent(),[2,this.schema]}})})},e.prototype.collectRefs=function(){var e=[];return(0,i.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 d(t);e.push(t.$ref)}return t}),e},e}();s.default=u}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer",file:"node_modules/@json-schema-tools/dereferencer/build/dereferencer.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/dereferencer/build/index.js",{"./dereferencer":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/dereferencer/build/dereferencer.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.NonStringRefError=void 0;var n=a(e("./dereferencer")),r=e("./dereferencer");Object.defineProperty(s,"NonStringRefError",{enumerable:!0,get:function(){return r.NonStringRefError}}),s.default=n.default}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer",file:"node_modules/@json-schema-tools/dereferencer/build/index.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/meta-schema/index.js",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.jsonSchema=void 0,s.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:[]}}},s.default=s.jsonSchema}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/meta-schema",file:"node_modules/@json-schema-tools/meta-schema/index.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/default-protocol-handler-map.js",{"./errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/errors.js","isomorphic-fetch":"/home/runner/work/metamask-extension/metamask-extension/node_modules/isomorphic-fetch/fetch-npm-browserify.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__awaiter||function(e,t,s,a){return new(s||(s=Promise))(function(n,r){function o(e){try{c(a.next(e))}catch(e){r(e)}}function i(e){try{c(a.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(o,i)}c((a=a.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var s,a,n,r,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(c){return function(i){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(o=0)),o;)try{if(s=1,a&&(n=2&i[0]?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,a=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){o.label=i[1];break}if(6===i[0]&&o.label<n[1]){o.label=n[1],n=i;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(i);break}n[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],a=0}finally{s=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});var o=e("./errors"),i=r(e("isomorphic-fetch")),c=function(e){return a(void 0,void 0,void 0,function(){var t,s;return n(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,(0,i.default)(e)];case 1:return t=a.sent(),[3,3];case 2:throw a.sent(),new o.InvalidRemoteURLError(e);case 3:return a.trys.push([3,5,,6]),[4,t.json()];case 4:return[2,a.sent()];case 5:throw s=a.sent(),new o.NonJsonRefError({$ref:e},s.message);case 6:return[2]}})})};s.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"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/errors.js",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.InvalidFileSystemPathError=s.InvalidRemoteURLError=s.NotResolvableError=s.NonJsonRefError=void 0;var a=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")};s.NonJsonRefError=a;var n=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")};s.NotResolvableError=n;var r=function(e){this.name="InvalidRemoteURLError",this.message=["InvalidRemoteURLError","The url was not resolvable: ".concat(e)].join("\n")};s.InvalidRemoteURLError=r;var o=function(e){this.name="InvalidFileSystemPathError",this.message=["InvalidFileSystemPathError","The path was not resolvable: ".concat(e)].join("\n")};s.InvalidFileSystemPathError=o}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/errors.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/index-web.js",{"./default-protocol-handler-map":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/default-protocol-handler-map.js","./reference-resolver":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/reference-resolver.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,s=1,a=arguments.length;s<a;s++)for(var n in t=arguments[s])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},a.apply(this,arguments)},n=this&&this.__awaiter||function(e,t,s,a){return new(s||(s=Promise))(function(n,r){function o(e){try{c(a.next(e))}catch(e){r(e)}}function i(e){try{c(a.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(o,i)}c((a=a.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var s,a,n,r,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(c){return function(i){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(o=0)),o;)try{if(s=1,a&&(n=2&i[0]?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,a=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){o.label=i[1];break}if(6===i[0]&&o.label<n[1]){o.label=n[1],n=i;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(i);break}n[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],a=0}finally{s=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});var i=o(e("./default-protocol-handler-map")),c=o(e("./reference-resolver")),l=a(a({},i.default),{file:function(){return n(void 0,void 0,void 0,function(){return r(this,function(e){return[2,undefined]})})}});s.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"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/reference-resolver.js",{"./errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/errors.js","./resolve-pointer":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/resolve-pointer.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__awaiter||function(e,t,s,a){return new(s||(s=Promise))(function(n,r){function o(e){try{c(a.next(e))}catch(e){r(e)}}function i(e){try{c(a.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(o,i)}c((a=a.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var s,a,n,r,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(c){return function(i){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(o=0)),o;)try{if(s=1,a&&(n=2&i[0]?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,a=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){o.label=i[1];break}if(6===i[0]&&o.label<n[1]){o.label=n[1],n=i;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(i);break}n[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],a=0}finally{s=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});var o=e("./errors"),i=r(e("./resolve-pointer")),c=function(){function e(e){this.protocolHandlerMap=e}return e.prototype.resolve=function(e){return a(this,arguments,void 0,function(e,t){var s,a,r,c,l,d,m,u,h,f;return void 0===t&&(t={}),n(this,function(n){switch(n.label){case 0:if("#"===e[0])return[2,Promise.resolve((0,i.default)(e,t))];(s=e.split("#")).length>1&&(a=s[s.length-1]),r=s[0],n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.protocolHandlerMap.file(r,t)];case 2:return c=n.sent(),[3,4];case 3:throw l=n.sent(),new o.NonJsonRefError({$ref:e},l.message);case 4:if(c!==undefined)return f=c,a&&(f=(0,i.default)(a,f)),[2,f];if(!1===e.includes("://"))throw new o.InvalidFileSystemPathError(e);d=0,m=Object.keys(this.protocolHandlerMap),n.label=5;case 5:return d<m.length?(u=m[d],r.startsWith(u)?[4,this.protocolHandlerMap[u](r,t)]:[3,7]):[3,8];case 6:if((h=n.sent())!==undefined)return f=h,a&&(f=(0,i.default)(a,f)),[2,f];n.label=7;case 7:return d++,[3,5];case 8:throw new o.NotResolvableError(e)}})})},e}();s.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"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/reference-resolver/build/resolve-pointer.js",{"@json-schema-spec/json-pointer":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-spec/json-pointer/lib/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.InvalidJsonPointerRefError=void 0;var n=a(e("@json-schema-spec/json-pointer")),r=function(e,t){this.name="InvalidJsonPointerRefError",this.message=["InvalidJsonPointerRefError","The provided RFC6901 JSON Pointer is invalid: ".concat(e),"","addition info: ",t].join("\n")};s.InvalidJsonPointerRefError=r,s.default=function(e,t){try{var s=e.replace("#","");return n.default.parse(s).shmeval(t)}catch(t){throw new r(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"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@json-schema-tools/traverse/build/index.js",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,s=1,a=arguments.length;s<a;s++)for(var n in t=arguments[s])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},a.apply(this,arguments)},n=this&&this.__spreadArray||function(e,t,s){if(s||2===arguments.length)for(var a,n=0,r=t.length;n<r;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(s,"__esModule",{value:!0}),s.defaultOptions=void 0,s.defaultOptions={skipFirstMutation:!1,mutable:!1,bfs:!1};var r=function(e){return e.map(function(e){return""===e?"$":".".concat(e)}).join("")},o=function(e,t){var s=t.find(function(t){return t===e});return s||!1},i=function(e,t){return void 0===t&&(t=1),e[e.length-t]};s.default=function e(t,c,l,d,m,u,h,f,p){void 0===l&&(l=s.defaultOptions),void 0===d&&(d=0),void 0===m&&(m=[]),void 0===u&&(u=[]),void 0===h&&(h=[]),void 0===f&&(f=[]),void 0===p&&(p=[]);var g=a(a({},s.defaultOptions),l);if(0===d&&(h=[""]),"boolean"==typeof t||t instanceof Boolean)return!0===g.skipFirstMutation&&0===d?t:c(t,!1,r(h),i(u));var k=t;!1===g.mutable&&(k=a({},t)),u.push(k),!0===g.bfs&&(!1!==g.skipFirstMutation&&0===d||(k=c(k,!1,r(h),i(u,2)))),m.push(t),f.push([t,k]);var b=function(t,s){var a=o(t,m);return a?(p.push(a),!0===g.skipFirstMutation&&a===m[0]?c(t,!0,r(s),i(u)):f.find(function(e){var t=e[0];return a===t})[1]):e(t,c,l,d+1,m,u,s,f,p)};if(t.anyOf)k.anyOf=t.anyOf.map(function(e,t){return b(e,n(n([],h,!0),["anyOf[".concat(t,"]")],!1))});else if(t.allOf)k.allOf=t.allOf.map(function(e,t){return b(e,n(n([],h,!0),["allOf[".concat(t,"]")],!1))});else if(t.oneOf)k.oneOf=t.oneOf.map(function(e,t){return b(e,n(n([],h,!0),["oneOf[".concat(t,"]")],!1))});else{if(t.items)if(t.items instanceof Array)k.items=t.items.map(function(e,t){return b(e,n(n([],h,!0),["items[".concat(t,"]")],!1))});else{var w=o(t.items,m);if(w)if(p.push(w),!0===g.skipFirstMutation&&w===m[0])k.items=c(t.items,!0,r(h),i(u));else{var _=f.find(function(e){var t=e[0];return w===t})[1];k.items=_}else k.items=e(t.items,c,l,d+1,m,u,n(n([],h,!0),["items"],!1),f,p)}if(t.additionalItems!==undefined&&(k.additionalItems=b(t.additionalItems,n(n([],h,!0),["additionalItems"],!1))),t.properties!==undefined){var T=t.properties,E={};Object.keys(t.properties).forEach(function(e){E[e]=b(T[e],n(n([],h,!0),["properties",e.toString()],!1))}),k.properties=E}if(t.patternProperties!==undefined){var I=t.patternProperties,S={};Object.keys(t.patternProperties).forEach(function(e){S[e]=b(I[e],n(n([],h,!0),["patternProperties",e.toString()],!1))}),k.patternProperties=S}t.additionalProperties!==undefined&&!0==!!t.additionalProperties&&(k.additionalProperties=b(t.additionalProperties,n(n([],h,!0),["additionalProperties"],!1)))}if(!0===g.skipFirstMutation&&0===d)return k;if(!0===g.bfs)return u.pop(),k;var x=-1!==p.indexOf(t);return u.pop(),c(k,x,r(h),i(u))}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer>@json-schema-tools/traverse",file:"node_modules/@json-schema-tools/traverse/build/index.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/address-book-controller/dist/AddressBookController.cjs",{"@metamask/base-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/base-controller/dist/index.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.AddressBookController=s.getDefaultAddressBookControllerState=s.controllerName=s.AddressType=void 0;const a=e("@metamask/base-controller"),n=e("@metamask/controller-utils");var r;!function(e){e.externallyOwnedAccounts="EXTERNALLY_OWNED_ACCOUNTS",e.contractAccounts="CONTRACT_ACCOUNTS",e.nonAccounts="NON_ACCOUNTS"}(r||(s.AddressType=r={})),s.controllerName="AddressBookController";const o=["list","set","delete","clear"],i={addressBook:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0}};s.getDefaultAddressBookControllerState=()=>({addressBook:{}});class c extends a.BaseController{constructor({messenger:e,state:t}){const a={...(0,s.getDefaultAddressBookControllerState)(),...t};super({messenger:e,metadata:i,name:s.controllerName,state:a}),this.messenger.registerMethodActionHandlers(this,o)}list(){const{addressBook:e}=this.state;return Object.keys(e).reduce((t,s)=>{const a=s;return[...t,...Object.values(e[a])]},[])}clear(){this.update(e=>{e.addressBook={}})}delete(e,t){if(t=(0,n.toChecksumHexAddress)(t),![e,t].every(e=>(0,n.isSafeDynamicKey)(e))||!(0,n.isValidHexAddress)(t)||!this.state.addressBook[e]?.[t])return!1;const s={...this.state.addressBook[e][t]};return this.update(s=>{const a=s.addressBook[e];a?.[t]&&(delete a[t],0===Object.keys(a).length&&delete s.addressBook[e])}),"*"!==String(e)&&this.messenger.publish("AddressBookController:contactDeleted",s),!0}set(e,t,s=(0,n.toHex)(1),a="",r){if(e=(0,n.toChecksumHexAddress)(e),!(0,n.isValidHexAddress)(e))return!1;const o={address:e,chainId:s,isEns:!1,memo:a,name:t,addressType:r,lastUpdatedAt:Date.now()},i=(0,n.normalizeEnsName)(t);return i&&(o.name=i,o.isEns=!0),this.update(t=>{t.addressBook={...this.state.addressBook,[s]:{...this.state.addressBook[s],[e]:o}}}),"*"!==String(s)&&this.messenger.publish("AddressBookController:contactUpdated",o),!0}}s.AddressBookController=c,s.default=c}}},{package:"@metamask/address-book-controller",file:"node_modules/@metamask/address-book-controller/dist/AddressBookController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/address-book-controller/dist/index.cjs",{"./AddressBookController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/address-book-controller/dist/AddressBookController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.AddressBookController=s.getDefaultAddressBookControllerState=void 0;var a=e("./AddressBookController.cjs");Object.defineProperty(s,"getDefaultAddressBookControllerState",{enumerable:!0,get:function(){return a.getDefaultAddressBookControllerState}}),Object.defineProperty(s,"AddressBookController",{enumerable:!0,get:function(){return a.AddressBookController}})}}},{package:"@metamask/address-book-controller",file:"node_modules/@metamask/address-book-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/announcement-controller/dist/AnnouncementController.cjs",{"@metamask/base-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/base-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.AnnouncementController=void 0;const o=e("@metamask/base-controller"),i={announcements:{}},c={announcements:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!0,usedInUi:!0}};class l extends o.BaseController{constructor({messenger:e,state:t,allAnnouncements:s}){const o={...i,...t};super({messenger:e,metadata:c,name:"AnnouncementController",state:o}),a.add(this),r(this,a,"m",n).call(this,s)}resetViewed(){this.update(({announcements:e})=>{for(const t of Object.values(e))t.isShown=!1})}updateViewed(e){this.update(({announcements:t})=>{for(const s of Object.keys(e).map(Number))t[s].isShown=e[s]})}}s.AnnouncementController=l,a=new WeakSet,n=function(e){this.update(t=>{Object.values(e).forEach(e=>{t.announcements[e.id]=t.announcements[e.id]??{...e,isShown:!1}})})}}}},{package:"@metamask/announcement-controller",file:"node_modules/@metamask/announcement-controller/dist/AnnouncementController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/announcement-controller/dist/index.cjs",{"./AnnouncementController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/announcement-controller/dist/AnnouncementController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.AnnouncementController=void 0;var a=e("./AnnouncementController.cjs");Object.defineProperty(s,"AnnouncementController",{enumerable:!0,get:function(){return a.AnnouncementController}})}}},{package:"@metamask/announcement-controller",file:"node_modules/@metamask/announcement-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs",{"./bridge-status-controller.intent.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.intent.cjs","./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/types.cjs","./utils/accounts.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs","./utils/authentication.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs","./utils/bridge-status.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.cjs","./utils/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge.cjs","./utils/history.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/history.cjs","./utils/intent-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs","./utils/keyring.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/keyring.cjs","./utils/metrics.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/metrics.cjs","./utils/network.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs","./utils/snaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/snaps.cjs","./utils/trace.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/trace.cjs","./utils/transaction.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/polling-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/polling-controller/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p,g,k,b,w,_,T,E,I=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},S=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.BridgeStatusController=void 0;const x=e("@metamask/bridge-controller"),y=e("@metamask/polling-controller"),A=e("@metamask/transaction-controller"),v=e("@metamask/utils"),P=e("./bridge-status-controller.intent.cjs"),C=e("./constants.cjs"),j=e("./types.cjs"),N=e("./utils/accounts.cjs"),D=e("./utils/authentication.cjs"),R=e("./utils/bridge.cjs"),F=e("./utils/bridge-status.cjs"),L=e("./utils/history.cjs"),M=e("./utils/intent-api.cjs"),O=e("./utils/keyring.cjs"),B=e("./utils/metrics.cjs"),G=e("./utils/network.cjs"),H=e("./utils/snaps.cjs"),U=e("./utils/trace.cjs"),q=e("./utils/transaction.cjs"),W={txHistory:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0}};class $ extends((0,y.StaticIntervalPollingController)()){constructor({messenger:e,state:t,clientId:s,fetchFn:y,addTransactionBatchFn:$,config:V,traceFn:K}){super({name:C.BRIDGE_STATUS_CONTROLLER_NAME,metadata:W,messenger:e,state:{...C.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE,...t}}),a.set(this,{}),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,({id:e,actionId:t})=>{let s=this.state.txHistory[e]?e:undefined;if(!s&&t&&this.state.txHistory[t]&&(s=t),s??(s=Object.keys(this.state.txHistory).find(t=>this.state.txHistory[t].approvalTxId===e)),!s)return;const a=s;this.update(e=>{e.txHistory[a].status.status=x.StatusTypes.FAILED})}),this.resetState=()=>{this.update(e=>{e.txHistory=C.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory})},this.wipeBridgeStatus=({address:e,ignoreNetwork:t})=>{if(t)this.update(e=>{e.txHistory=C.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory});else{const t=(0,G.getSelectedChainId)(this.messenger);S(this,w,"f").call(this,e,t)}},this.restartPollingForFailedAttempts=e=>{const{txMetaId:t,txHash:s}=e;if(!t&&!s)throw new Error("Either txMetaId or txHash must be provided");let n;if(t?this.state.txHistory[t]&&(n=t):s&&(n=Object.keys(this.state.txHistory).find(e=>this.state.txHistory[e].status.srcChain.txHash===s)),!n)throw new Error("No bridge transaction history found for "+(t?`txMetaId: ${t}`:`txHash: ${s}`));const r=this.state.txHistory[n],o=r.attempts?.counter??0;if(this.update(e=>{n&&(e.txHistory[n].attempts=undefined)}),(0,L.shouldPollHistoryItem)(r)){if(!S(this,a,"f")[n]&&(S(this,f,"f").call(this,n),!r.featureId)){const e=(0,N.getAccountByAddress)(this.messenger,r.account),t=(0,B.getRequestParamFromHistory)(r),s=(0,B.getRequestMetadataFromHistory)(r,e),{security_warnings:a,...i}=s;S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.PollingStatusUpdated,n,{...(0,B.getTradeDataFromHistory)(r),...(0,B.getPriceImpactFromQuote)(r.quote),...i,chain_id_source:t.chain_id_source,chain_id_destination:t.chain_id_destination,token_symbol_source:t.token_symbol_source,token_symbol_destination:t.token_symbol_destination,action_type:x.MetricsActionType.SWAPBRIDGE_V1,polling_status:x.PollingStatus.ManuallyRestarted,retry_attempts:o})}}},this.getBridgeHistoryItemByTxMetaId=e=>this.state.txHistory[e],m.set(this,()=>{const{txHistory:e}=this.state;Object.values(e).filter(e=>e.status.status===x.StatusTypes.PENDING||e.status.status===x.StatusTypes.UNKNOWN).filter(e=>Boolean(e.txMetaId)).filter(e=>!S(this,a,"f")[e.txMetaId]).filter(e=>(0,L.shouldPollHistoryItem)(e)).forEach(e=>{const t=e.txMetaId;(0,F.shouldSkipFetchDueToFetchFailures)(e.attempts)||S(this,f,"f").call(this,t)})}),u.set(this,(...e)=>{const{historyKey:t,txHistoryItem:s}=(0,L.getInitialHistoryItem)(...e);this.update(e=>{e.txHistory[t]=s})}),h.set(this,(e,t)=>{this.update(s=>{(0,L.rekeyHistoryItemInState)(s,e,t)})}),f.set(this,e=>{const t=S(this,a,"f")[e];t&&this.stopPollingByPollingToken(t);const s=this.state.txHistory[e];s&&(0,L.shouldPollHistoryItem)(s)&&(S(this,a,"f")[e]=this.startPolling({bridgeTxMetaId:e}))}),this.startPollingForBridgeTxStatus=e=>{const{bridgeTxMeta:t}=e;if(!t?.id)throw new Error("Cannot start polling: bridgeTxMeta.id is required for polling");S(this,u,"f").call(this,e),S(this,f,"f").call(this,t.id)},this._executePoll=async e=>{await S(this,g,"f").call(this,e)},p.set(this,e=>{const{attempts:t}=this.state.txHistory[e],s=t?{counter:t.counter+1,lastAttemptTime:Date.now()}:{counter:1,lastAttemptTime:Date.now()},n=S(this,a,"f")[e];if(s.counter>=C.MAX_ATTEMPTS&&n){this.stopPollingByPollingToken(n),delete S(this,a,"f")[e];const t=this.state.txHistory[e];if(t&&!t.featureId){const a=(0,N.getAccountByAddress)(this.messenger,t.account),n=(0,B.getRequestParamFromHistory)(t),r=(0,B.getRequestMetadataFromHistory)(t,a),{security_warnings:o,...i}=r;S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.PollingStatusUpdated,e,{...(0,B.getTradeDataFromHistory)(t),...(0,B.getPriceImpactFromQuote)(t.quote),...i,chain_id_source:n.chain_id_source,chain_id_destination:n.chain_id_destination,token_symbol_source:n.token_symbol_source,token_symbol_destination:n.token_symbol_destination,action_type:x.MetricsActionType.SWAPBRIDGE_V1,polling_status:x.PollingStatus.MaxPollingReached,retry_attempts:s.counter})}}this.update(t=>{t.txHistory[e].attempts=s})}),g.set(this,async({bridgeTxMetaId:e})=>{const{txHistory:t}=this.state,s=t[e];if(s&&!(0,F.shouldSkipFetchDueToFetchFailures)(s.attempts))try{let t,c=[];if(s.quote.intent){const a=await S(this,n,"f").getIntentTransactionStatus(e,s.quote.srcChainId,s.quote.intent.protocol,S(this,r,"f"),s.status.srcChain.txHash);if(null===a?.bridgeStatus||a?.bridgeStatus===undefined)return;t=a.bridgeStatus.status}else{const a=S(this,k,"f").call(this,e);if(!a)return;S(this,b,"f").call(this,e,a);const n=(0,F.getStatusRequestWithSrcTxHash)(s.quote,a),l=await(0,F.fetchBridgeTxStatus)(n,S(this,r,"f"),await(0,D.getJwt)(this.messenger),S(this,o,"f"),S(this,i,"f").customBridgeApiBaseUrl);t=l.status,c=l.validationFailures}if(c.length>0)throw S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.StatusValidationFailed,e,{failures:c,refresh_count:s.attempts?.counter??0}),new Error(`Bridge status validation failed: ${c.join(", ")}`);const l={...s,status:t,completionTime:t.status===x.StatusTypes.COMPLETE||t.status===x.StatusTypes.FAILED?Date.now():undefined,attempts:undefined};this.update(t=>{t.txHistory[e]=l}),s.quote.intent&&S(this,n,"f").syncTransactionFromIntentStatus(e,s);const d=S(this,a,"f")[e];if((t.status===x.StatusTypes.COMPLETE||t.status===x.StatusTypes.FAILED)&&d){if(this.stopPollingByPollingToken(d),delete S(this,a,"f")[e],s.featureId)return;t.status===x.StatusTypes.COMPLETE&&(S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Completed,e),this.messenger.publish("BridgeStatusController:destinationTransactionCompleted",s.quote.destAsset.assetId)),t.status===x.StatusTypes.FAILED&&S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Failed,e)}}catch(t){console.warn("Failed to fetch bridge tx status",t),S(this,p,"f").call(this,e)}}),k.set(this,e=>{const{txHistory:t}=this.state,s=t[e].status.srcChain.txHash;if(s)return s;const a=(0,q.getTransactionMetaById)(this.messenger,e);return a?.hash}),b.set(this,(e,t)=>{const{txHistory:s}=this.state;s[e].status.srcChain.txHash||this.update(s=>{s.txHistory[e].status.srcChain.txHash=t})}),w.set(this,(e,t)=>{const s=Object.keys(this.state.txHistory).filter(s=>{const a=this.state.txHistory[s],n=(0,v.numberToHex)(a.quote.srcChainId);return a.account===e&&n===t});s.forEach(e=>{S(this,a,"f")[e]&&this.stopPollingByPollingToken(S(this,a,"f")[e])}),this.update(e=>{e.txHistory=s.reduce((e,t)=>(delete e[t],e),e.txHistory)})}),_.set(this,async(e,t,s,a,n,r)=>{if(a&&(0,x.isEvmTxData)(a)){const o=async()=>{n&&await(0,q.submitEvmTransaction)({messenger:this.messenger,transactionType:A.TransactionType.bridgeApproval,trade:n});const e=await(0,q.submitEvmTransaction)({messenger:this.messenger,transactionType:t?A.TransactionType.bridgeApproval:A.TransactionType.swapApproval,trade:a,requireApproval:r});return await(0,q.handleApprovalDelay)(s),e};return await S(this,l,"f").call(this,(0,U.getApprovalTraceParams)(e,!1),o)}return undefined}),T.set(this,async e=>{const t=await(0,q.getAddTransactionBatchParams)({messenger:this.messenger,...e});return await(0,q.addTransactionBatch)(this.messenger,S(this,c,"f"),t)}),this.submitTx=async(e,t,s,a,n=x.MetaMetricsSwapsEventSource.MainView,o,i)=>{(0,R.stopPollingForQuotes)(this.messenger,t.featureId,a);const c=(0,N.getAccountByAddress)(this.messenger,e);if(!c)throw new Error("Failed to submit cross-chain swap transaction: undefined multichain account");const d=(0,x.isHardwareWallet)(c),m=(0,B.getPreConfirmationPropertiesFromQuote)(t,s,d,n,o,i);let p,g,k=!1;const b=Date.now(),w=(0,x.isCrossChain)(t.quote.srcChainId,t.quote.destChainId),I=(0,x.isTronChainId)(t.quote.srcChainId);try{if(!t.featureId&&S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Submitted,undefined,m),(0,x.isNonEvmChainId)(t.quote.srcChainId)){if(t.approval&&(0,x.isTronTrade)(t.approval)){const e=await S(this,l,"f").call(this,(0,U.getApprovalTraceParams)(t,!1),async()=>t.approval&&(0,x.isTronTrade)(t.approval)?await(0,H.handleNonEvmTx)(this.messenger,t.approval,t,c):undefined);g=e?.id,await(0,q.handleApprovalDelay)(t.quote.srcChainId)}p=await S(this,l,"f").call(this,(0,U.getTraceParams)(t,!1),async()=>{if(!(0,x.isTronTrade)(t.trade)&&!(0,x.isBitcoinTrade)(t.trade)&&"string"!=typeof t.trade)throw new Error("Failed to submit cross-chain swap transaction: trade is not a non-EVM transaction");return await(0,H.handleNonEvmTx)(this.messenger,t.trade,t,c)})}else{const e=S(this,r,"f")===j.BridgeClientId.MOBILE&&d;p=await S(this,l,"f").call(this,(0,U.getTraceParams)(t,s),async()=>{if(!(0,x.isEvmTxData)(t.trade))throw new Error("Failed to submit cross-chain swap transaction: trade is not an EVM transaction");const a=(0,x.formatChainIdToHex)(t.quote.srcChainId);if(k=await(0,q.checkIsDelegatedAccount)(this.messenger,t.trade.from,[a]),s||t.quote.gasIncluded7702||k){const{tradeMeta:s,approvalMeta:a}=await S(this,T,"f").call(this,{isBridgeTx:w,resetApproval:t.resetApproval,approval:t.approval&&(0,x.isEvmTxData)(t.approval)?t.approval:undefined,trade:t.trade,quoteResponse:t,requireApproval:e,isDelegatedAccount:k});return g=a?.id,s}const r=await S(this,_,"f").call(this,t,w,t.quote.srcChainId,t.approval&&(0,x.isEvmTxData)(t.approval)?t.approval:undefined,t.resetApproval,e);g=r?.id,e&&r?(await(0,q.handleMobileHardwareWalletDelay)(e),await(0,q.waitForTxConfirmation)(this.messenger,r.id)):await(0,q.handleMobileHardwareWalletDelay)(e);const l=(0,q.generateActionId)().toString();S(this,u,"f").call(this,{accountAddress:c.address,quoteResponse:t,slippagePercentage:0,isStxEnabled:s,startTime:b,approvalTxId:g,location:n,abTests:o,activeAbTests:i,actionId:l});const d=await(0,q.submitEvmTransaction)({messenger:this.messenger,transactionType:w?A.TransactionType.bridge:A.TransactionType.swap,trade:t.trade,requireApproval:e,txFee:t.quote.gasIncluded?t.quote.feeData.txFee:undefined,actionId:l});return S(this,h,"f").call(this,l,d),d})}}catch(e){throw!t.featureId&&S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Failed,undefined,{error_message:e?.message,...m}),e}try{!((0,x.isNonEvmChainId)(t.quote.srcChainId)||s||t.quote.gasIncluded7702||k)||S(this,u,"f").call(this,{accountAddress:c.address,bridgeTxMeta:p,quoteResponse:t,slippagePercentage:0,isStxEnabled:s,startTime:b,approvalTxId:g,location:n,abTests:o,activeAbTests:i}),(0,x.isNonEvmChainId)(t.quote.srcChainId)&&(S(this,f,"f").call(this,p.id),w||I||S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Completed,p.id))}catch{}return p},this.submitIntent=async e=>{const{quoteResponse:t,accountAddress:s,location:a,abTests:n,activeAbTests:c}=e;(0,R.stopPollingForQuotes)(this.messenger);const l=Date.now(),d=(0,N.getAccountByAddress)(this.messenger,s),m=Boolean(d)&&(0,x.isHardwareWallet)(d),h=(0,B.getPreConfirmationPropertiesFromQuote)(t,!1,m,a,n,c);try{const e=(0,M.getIntentFromQuote)(t),d=(0,x.isCrossChain)(t.quote.srcChainId,t.quote.destChainId),h=m&&S(this,r,"f")===j.BridgeClientId.MOBILE,p=await S(this,_,"f").call(this,t,d,t.quote.srcChainId,t.approval,t.resetApproval,h),g=p?.id;g&&await(0,q.waitForTxConfirmation)(this.messenger,g);const{srcChainId:k,requestId:b}=t.quote,w={srcChainId:k,quoteId:b,signature:await(0,O.signTypedMessage)({messenger:this.messenger,accountAddress:s,typedData:e.typedData}),order:e.order,userAddress:s,aggregatorId:e.protocol},{id:T,status:E}=await(0,M.postSubmitOrder)({params:w,clientId:S(this,r,"f"),jwt:await(0,D.getJwt)(this.messenger),fetchFn:S(this,o,"f"),bridgeApiBaseUrl:S(this,i,"f").customBridgeApiBaseUrl}),I=d?A.TransactionType.bridge:A.TransactionType.swap,y=(0,G.getNetworkClientIdByChainId)(this.messenger,k),v={chainId:(0,x.formatChainIdToHex)(k),from:s,to:e.settlementContract??"0x9008D19f58AAbd9eD0D60971565AA8510560ab41",data:`0x${T.slice(-8)}`,value:"0x0",gas:"0x5208",gasPrice:"0x3b9aca00"},P={...await(0,q.addSyntheticTransaction)(this.messenger,v,{requireApproval:!1,networkClientId:y,type:I}),status:(0,M.mapIntentOrderStatusToTransactionStatus)(E),isIntentTx:!0,orderUid:T};try{const e=T,r={...P,id:e,originalTransactionId:P.id};S(this,u,"f").call(this,{accountAddress:s,bridgeTxMeta:r,quoteResponse:t,slippagePercentage:0,isStxEnabled:!1,approvalTxId:g,startTime:l,location:a,abTests:n,activeAbTests:c}),S(this,f,"f").call(this,e)}catch(e){console.error("📝 [submitIntent] Failed to add to bridge history",e)}return P}catch(e){throw S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Failed,undefined,{error_message:e?.message,...h}),e}},E.set(this,(e,t,s)=>{const a=t?this.state.txHistory?.[t]?.abTests:undefined,n=t?this.state.txHistory?.[t]?.activeAbTests:undefined,r=s?.ab_tests??a,o=s?.active_ab_tests??n,i={action_type:x.MetricsActionType.SWAPBRIDGE_V1,location:s?.location??(t?this.state.txHistory?.[t]?.location:undefined)??x.MetaMetricsSwapsEventSource.MainView,...s??{},...r&&Object.keys(r).length>0&&{ab_tests:r},...o&&o.length>0&&{active_ab_tests:o}};if(!t)return void(0,R.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:i});const c=this.state.txHistory[t];if(!c)return void(0,R.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:i});const{featureId:l,approvalTxId:d,quote:m}=c,u=(0,B.getRequestParamFromHistory)(c);if(e===x.UnifiedSwapBridgeEventName.StatusValidationFailed)return void(0,R.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:{...i,chain_id_source:u.chain_id_source,chain_id_destination:u.chain_id_destination,token_address_source:u.token_address_source,token_address_destination:u.token_address_destination,refresh_count:c.attempts?.counter??0}});if(l)return;const h=(0,N.getAccountByAddress)(this.messenger,c.account),f=(0,q.getTransactions)(this.messenger),p=f.find(e=>e.id===t),g=f.find(e=>e.id===d),k={...i,...u,...(0,B.getRequestMetadataFromHistory)(c,h),...(0,B.getTradeDataFromHistory)(c),...(0,B.getTxStatusesFromHistory)(c),...(0,B.getFinalizedTxProperties)(c,p,g),...(0,B.getPriceImpactFromQuote)(m)};(0,R.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:k})}),I(this,r,s,"f"),I(this,o,y,"f"),I(this,c,$,"f"),I(this,i,{customBridgeApiBaseUrl:V?.customBridgeApiBaseUrl??C.BRIDGE_PROD_API_BASE_URL},"f"),I(this,l,K??((e,t)=>t?.()),"f"),I(this,n,new P.IntentManager({messenger:this.messenger,customBridgeApiBaseUrl:S(this,i,"f").customBridgeApiBaseUrl,fetchFn:S(this,o,"f")}),"f"),this.messenger.registerActionHandler(`${C.BRIDGE_STATUS_CONTROLLER_NAME}:startPollingForBridgeTxStatus`,this.startPollingForBridgeTxStatus.bind(this)),this.messenger.registerActionHandler(`${C.BRIDGE_STATUS_CONTROLLER_NAME}:wipeBridgeStatus`,this.wipeBridgeStatus.bind(this)),this.messenger.registerActionHandler(`${C.BRIDGE_STATUS_CONTROLLER_NAME}:resetState`,this.resetState.bind(this)),this.messenger.registerActionHandler(`${C.BRIDGE_STATUS_CONTROLLER_NAME}:submitTx`,this.submitTx.bind(this)),this.messenger.registerActionHandler(`${C.BRIDGE_STATUS_CONTROLLER_NAME}:submitIntent`,this.submitIntent.bind(this)),this.messenger.registerActionHandler(`${C.BRIDGE_STATUS_CONTROLLER_NAME}:restartPollingForFailedAttempts`,this.restartPollingForFailedAttempts.bind(this)),this.messenger.registerActionHandler(`${C.BRIDGE_STATUS_CONTROLLER_NAME}:getBridgeHistoryItemByTxMetaId`,this.getBridgeHistoryItemByTxMetaId.bind(this)),this.setIntervalLength(C.REFRESH_INTERVAL_MS),this.messenger.subscribe("TransactionController:transactionFailed",({transactionMeta:e})=>{const{type:t,status:s,id:a,actionId:n}=e;if(t&&[A.TransactionType.bridge,A.TransactionType.swap,A.TransactionType.bridgeApproval,A.TransactionType.swapApproval].includes(t)&&[A.TransactionStatus.failed,A.TransactionStatus.dropped,A.TransactionStatus.rejected].includes(s)&&(S(this,d,"f").call(this,e),s!==A.TransactionStatus.rejected)){let t;this.state.txHistory[a]?t=a:n&&this.state.txHistory[n]&&(t=n),S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Failed,t??a,(0,B.getEVMTxPropertiesFromTransactionMeta)(e))}}),this.messenger.subscribe("TransactionController:transactionConfirmed",e=>{const{type:t,id:s,chainId:a}=e;t===A.TransactionType.swap&&S(this,E,"f").call(this,x.UnifiedSwapBridgeEventName.Completed,s),t!==A.TransactionType.bridge||(0,x.isNonEvmChainId)(a)||S(this,f,"f").call(this,s)}),S(this,m,"f").call(this)}}s.BridgeStatusController=$,a=new WeakMap,n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,h=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakMap,k=new WeakMap,b=new WeakMap,w=new WeakMap,_=new WeakMap,T=new WeakMap,E=new WeakMap}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.intent.cjs",{"./utils/authentication.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs","./utils/intent-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs","./utils/transaction.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs","./utils/validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},c=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.IntentManager=void 0;const l=e("@metamask/bridge-controller"),d=e("./utils/authentication.cjs"),m=e("./utils/intent-api.cjs"),u=e("./utils/transaction.cjs");e("./utils/validators.cjs");s.IntentManager=class{constructor({messenger:e,customBridgeApiBaseUrl:t,fetchFn:s}){a.add(this),n.set(this,void 0),r.set(this,new Map),this.getIntentTransactionStatus=async(e,t,s,n,r)=>{try{const i=await this.intentApi.getOrderStatus(e,s,t,n);return c(this,a,"m",o).call(this,e,i,t,r)}catch(e){if(e instanceof Error)throw new Error(`[Intent polling] Failed to get intent order status from API: ${e.message}`);return undefined}},this.syncTransactionFromIntentStatus=(e,t)=>{const s=t.originalTransactionId??t.txMetaId;if(!s)return;const a=c(this,r,"f").get(e);if(a)try{const t=(0,u.getTransactionMetaById)(c(this,n,"f"),s);if(!t)return void console.warn("[Intent polling] Skipping update, transaction not found",{originalTxId:s,bridgeHistoryKey:e});const{bridgeStatus:o,orderStatus:i}=a,d=o?.txHash,m=o?.status.status===l.StatusTypes.COMPLETE,h=o?.status.status===l.StatusTypes.COMPLETE||o?.status.status===l.StatusTypes.FAILED,f=t.txReceipt,p=d?{txReceipt:{...f,transactionHash:d,status:m?"0x1":"0x0"}}:{};(0,u.updateTransaction)(c(this,n,"f"),t,{status:o?.transactionStatus,...d?{hash:d}:{},...p},`BridgeStatusController - Intent order status updated: ${i}`),h&&c(this,r,"f").delete(e)}catch(t){console.error("[Intent polling] Failed to update transaction status",{originalTxId:s,bridgeHistoryKey:e,error:t})}},i(this,n,e,"f"),this.intentApi=new m.IntentApiImpl(t,s,async()=>await(0,d.getJwt)(e))}},n=new WeakMap,r=new WeakMap,a=new WeakSet,o=function(e,t,s,a){const n=(0,m.translateIntentOrderToBridgeStatus)(t,s,a),o={orderStatus:t.status,bridgeStatus:n};return c(this,r,"f").set(e,o),o}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.intent.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a;Object.defineProperty(s,"__esModule",{value:!0}),s.TraceName=s.APPROVAL_DELAY_MS=s.BRIDGE_PROD_API_BASE_URL=s.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE=s.BRIDGE_STATUS_CONTROLLER_NAME=s.MAX_ATTEMPTS=s.REFRESH_INTERVAL_MS=void 0,s.REFRESH_INTERVAL_MS=1e4,s.MAX_ATTEMPTS=7,s.BRIDGE_STATUS_CONTROLLER_NAME="BridgeStatusController",s.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE={txHistory:{}},s.BRIDGE_PROD_API_BASE_URL="https://bridge.api.cx.metamask.io",s.APPROVAL_DELAY_MS=5e3,function(e){e.BridgeTransactionApprovalCompleted="Bridge Transaction Approval Completed",e.BridgeTransactionCompleted="Bridge Transaction Completed",e.SwapTransactionApprovalCompleted="Swap Transaction Approval Completed",e.SwapTransactionCompleted="Swap Transaction Completed"}(a||(s.TraceName=a={}))}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/constants.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/index.cjs",{"./bridge-status-controller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs","./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/types.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.BridgeStatusController=s.BridgeStatusAction=s.BridgeId=s.MAX_ATTEMPTS=s.BRIDGE_STATUS_CONTROLLER_NAME=s.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE=s.REFRESH_INTERVAL_MS=void 0;var a=e("./constants.cjs");Object.defineProperty(s,"REFRESH_INTERVAL_MS",{enumerable:!0,get:function(){return a.REFRESH_INTERVAL_MS}}),Object.defineProperty(s,"DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE",{enumerable:!0,get:function(){return a.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE}}),Object.defineProperty(s,"BRIDGE_STATUS_CONTROLLER_NAME",{enumerable:!0,get:function(){return a.BRIDGE_STATUS_CONTROLLER_NAME}}),Object.defineProperty(s,"MAX_ATTEMPTS",{enumerable:!0,get:function(){return a.MAX_ATTEMPTS}});var n=e("./types.cjs");Object.defineProperty(s,"BridgeId",{enumerable:!0,get:function(){return n.BridgeId}}),Object.defineProperty(s,"BridgeStatusAction",{enumerable:!0,get:function(){return n.BridgeStatusAction}});var r=e("./bridge-status-controller.cjs");Object.defineProperty(s,"BridgeStatusController",{enumerable:!0,get:function(){return r.BridgeStatusController}})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/types.cjs",{"./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.BridgeStatusAction=s.BridgeId=s.BridgeClientId=void 0;e("./constants.cjs");var a,n,r;!function(e){e.EXTENSION="extension",e.MOBILE="mobile"}(a||(s.BridgeClientId=a={})),function(e){e.HOP="hop",e.CELER="celer",e.CELERCIRCLE="celercircle",e.CONNEXT="connext",e.POLYGON="polygon",e.AVALANCHE="avalanche",e.MULTICHAIN="multichain",e.AXELAR="axelar",e.ACROSS="across",e.STARGATE="stargate",e.RELAY="relay",e.MAYAN="mayan"}(n||(s.BridgeId=n={})),function(e){e.StartPollingForBridgeTxStatus="StartPollingForBridgeTxStatus",e.WipeBridgeStatus="WipeBridgeStatus",e.GetState="GetState",e.ResetState="ResetState",e.SubmitTx="SubmitTx",e.SubmitIntent="SubmitIntent",e.RestartPollingForFailedAttempts="RestartPollingForFailedAttempts",e.GetBridgeHistoryItemByTxMetaId="GetBridgeHistoryItemByTxMetaId"}(r||(s.BridgeStatusAction=r={}))}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/types.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getAccountByAddress=void 0;s.getAccountByAddress=(e,t)=>e.call("AccountsController:getAccountByAddress",t)}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getJwt=void 0;s.getJwt=async e=>{try{return await e.call("AuthenticationController:getBearerToken")}catch(e){return console.error("Error getting JWT token for bridge-api request",e),undefined}}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/superstruct":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/superstruct/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getStatusRequestParams=s.shouldSkipFetchDueToFetchFailures=s.getStatusRequestWithSrcTxHash=s.fetchBridgeTxStatus=s.getStatusRequestDto=s.getBridgeStatusUrl=void 0;const a=e("@metamask/bridge-controller"),n=e("@metamask/superstruct"),r=e("./validators.cjs"),o=e("../constants.cjs");s.getBridgeStatusUrl=e=>`${e}/getTxStatus`;s.getStatusRequestDto=e=>{const{quote:t,...s}=e;return{...Object.fromEntries(Object.entries(s).map(([e,t])=>[e,t.toString()])),...t?.requestId?{requestId:t.requestId}:{}}};s.fetchBridgeTxStatus=async(e,t,o,i,c)=>{const l=(0,s.getStatusRequestDto)(e),d=new URLSearchParams(l),m=`${(0,s.getBridgeStatusUrl)(c)}?${d.toString()}`,u=await i(m,{headers:(0,a.getClientHeaders)({clientId:t,jwt:o})}),h=[];try{(0,r.validateBridgeStatusResponse)(u)}catch(t){t instanceof n.StructError&&t.failures().forEach(({path:t})=>{const s=u?.bridge??(e.bridge||e.bridgeId)??"unknown",a=t?.join(".")||"unknown";h.push([s,a].join("|"))})}return{status:u,validationFailures:h}};s.getStatusRequestWithSrcTxHash=(e,t)=>{const{bridgeId:s,bridges:a,srcChainId:n,destChainId:r,refuel:o}=e;return{bridgeId:s,srcTxHash:t,bridge:a[0],srcChainId:n,destChainId:r,quote:e,refuel:Boolean(o)}};s.shouldSkipFetchDueToFetchFailures=e=>{if(e){const t=o.REFRESH_INTERVAL_MS*Math.pow(2,e.counter-1);if(Date.now()-e.lastAttemptTime<t)return!0}return!1};s.getStatusRequestParams=e=>({bridgeId:e.quote.bridgeId,bridge:e.quote.bridges[0],srcChainId:e.quote.srcChainId,destChainId:e.quote.destChainId,quote:e.quote,refuel:Boolean(e.quote.refuel)})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.trackMetricsEvent=s.stopPollingForQuotes=void 0;const a=e("@metamask/bridge-controller");s.stopPollingForQuotes=(e,t,s)=>{e.call("BridgeController:stopPollingForQuotes",a.AbortReason.TransactionSubmitted,t?undefined:s)};s.trackMetricsEvent=({messenger:e,eventName:t,properties:s})=>{e.call("BridgeController:trackUnifiedSwapBridgeEvent",t,s)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/bridge.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/gas.cjs",{"bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.calcActualGasUsed=void 0;const a=e("bignumber.js"),n=(e,t)=>e&&t?new a.BigNumber(e,16).times(new a.BigNumber(t,16)):null;s.calcActualGasUsed=({pricingData:e},t,s)=>{const r=e?.quotedGasInUsd&&e?.quotedGasAmount?new a.BigNumber(e?.quotedGasInUsd).div(e.quotedGasAmount):null,o=n(t?.gasUsed,t?.effectiveGasPrice)?.plus(n(s?.gasUsed,s?.effectiveGasPrice)??0),i=o?.div(new a.BigNumber(10).pow(18)).toString(10);return o&&i?{amount:o.toString(10),usd:r?.multipliedBy(i).toString(10)??null}:null}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/gas.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/history.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.shouldPollHistoryItem=s.getInitialHistoryItem=s.getHistoryKey=s.rekeyHistoryItemInState=void 0;const a=e("@metamask/bridge-controller");function n(e,t,s){const a=e??t??s;if(!a)throw new Error("Cannot add tx to history: either actionId, bridgeTxMeta.id, or syntheticTransactionId must be provided");return a}s.rekeyHistoryItemInState=(e,t,s)=>{const a=e.txHistory[t];return!!a&&(e.txHistory[s.id]={...a,txMetaId:s.id,originalTransactionId:a.originalTransactionId??s.id,status:{...a.status,srcChain:{...a.status.srcChain,txHash:s.hash??a.status.srcChain?.txHash}}},delete e.txHistory[t],!0)},s.getHistoryKey=n;s.getInitialHistoryItem=e=>{const{bridgeTxMeta:t,quoteResponse:s,startTime:r,slippagePercentage:o,initialDestAssetBalance:i,targetContractAddress:c,approvalTxId:l,isStxEnabled:d,location:m,abTests:u,activeAbTests:h,accountAddress:f,originalTransactionId:p,actionId:g}=e;return{historyKey:n(g,t?.id,p),txHistoryItem:{txMetaId:t?.id,actionId:g,originalTransactionId:p??t?.id,batchId:t?.batchId,quote:s.quote,startTime:r,estimatedProcessingTimeInSeconds:s.estimatedProcessingTimeInSeconds,slippagePercentage:o,pricingData:{amountSent:s.sentAmount?.amount??"0",amountSentInUsd:s.sentAmount?.usd??undefined,quotedGasInUsd:s.gasFee?.effective?.usd??undefined,quotedReturnInUsd:s.toTokenAmount?.usd??undefined,quotedGasAmount:s.gasFee?.effective?.amount??undefined},initialDestAssetBalance:i,targetContractAddress:c,account:f,status:{status:a.StatusTypes.PENDING,srcChain:{chainId:s.quote.srcChainId,txHash:t?.hash}},hasApprovalTx:Boolean(s.approval),approvalTxId:l,isStxEnabled:Boolean(d),featureId:s.featureId,location:m,...u&&{abTests:u},...h&&{activeAbTests:h}}}};s.shouldPollHistoryItem=e=>{const t=Boolean(e?.quote?.intent);return[(0,a.isCrossChain)(e.quote.srcChainId,e.quote.destChainId),t,(0,a.isTronChainId)(e.quote.srcChainId)].some(Boolean)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/history.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs",{"./validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},i=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.postSubmitOrder=s.getIntentFromQuote=s.mapIntentOrderStatusToTransactionStatus=s.translateIntentOrderToBridgeStatus=s.IntentApiImpl=void 0;const c=e("@metamask/bridge-controller"),l=e("@metamask/transaction-controller"),d=e("./validators.cjs");s.IntentApiImpl=class{constructor(e,t,s){a.set(this,void 0),n.set(this,void 0),r.set(this,void 0),o(this,a,e,"f"),o(this,n,t,"f"),o(this,r,s,"f")}async getOrderStatus(e,t,s,o){const l=`${i(this,a,"f")}/getOrderStatus?orderId=${e}&aggregatorId=${encodeURIComponent(t)}&srcChainId=${s}`;try{const e=await i(this,r,"f").call(this),t=await i(this,n,"f").call(this,l,{method:"GET",headers:(0,c.getClientHeaders)({clientId:o,jwt:e})});if(!(0,d.validateIntentStatusResponse)(t))throw new Error("Invalid getOrderStatus response");return t}catch(e){if(e instanceof Error)throw new Error(`Failed to get order status: ${e.message}`);throw new Error("Failed to get order status")}}},a=new WeakMap,n=new WeakMap,r=new WeakMap;function m(e){switch(e){case d.IntentOrderStatus.PENDING:case d.IntentOrderStatus.SUBMITTED:return l.TransactionStatus.submitted;case d.IntentOrderStatus.CONFIRMED:case d.IntentOrderStatus.COMPLETED:return l.TransactionStatus.confirmed;case d.IntentOrderStatus.FAILED:case d.IntentOrderStatus.EXPIRED:case d.IntentOrderStatus.CANCELLED:return l.TransactionStatus.failed;default:return l.TransactionStatus.submitted}}s.translateIntentOrderToBridgeStatus=(e,t,s)=>{let a;switch(e.status){case d.IntentOrderStatus.CONFIRMED:case d.IntentOrderStatus.COMPLETED:a=c.StatusTypes.COMPLETE;break;case d.IntentOrderStatus.FAILED:case d.IntentOrderStatus.EXPIRED:case d.IntentOrderStatus.CANCELLED:a=c.StatusTypes.FAILED;break;case d.IntentOrderStatus.PENDING:a=c.StatusTypes.PENDING;break;case d.IntentOrderStatus.SUBMITTED:a=c.StatusTypes.SUBMITTED;break;default:a=c.StatusTypes.UNKNOWN}const n=e.txHash??s;return{status:{status:a,srcChain:{chainId:t,txHash:n}},txHash:n,transactionStatus:m(e.status)}},s.mapIntentOrderStatusToTransactionStatus=m,s.getIntentFromQuote=function(e){const{intent:t}=e.quote;if(!t)throw new Error("submitIntent: missing intent data");return t};s.postSubmitOrder=async({params:e,clientId:t,jwt:s,fetchFn:a,bridgeApiBaseUrl:n})=>{const r=`${n}/submitOrder`;try{const n=await a(r,{method:"POST",headers:{"Content-Type":"application/json",...(0,c.getClientHeaders)({clientId:t,jwt:s})},body:JSON.stringify(e)});if(!(0,d.validateIntentStatusResponse)(n))throw new Error("Invalid submitOrder response");return n}catch(e){if(e instanceof Error)throw new Error(`Failed to submit intent: ${e.message}`);throw new Error("Failed to submit intent")}}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/keyring.cjs",{"@metamask/keyring-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.signTypedMessage=void 0;const a=e("@metamask/keyring-controller");s.signTypedMessage=async({messenger:e,accountAddress:t,typedData:s})=>await e.call("KeyringController:signTypedMessage",{from:t,data:s},a.SignTypedDataVersion.V4)}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/keyring.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/metrics.cjs",{"./gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/gas.cjs","./swap-received-amount.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/swap-received-amount.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getEVMTxPropertiesFromTransactionMeta=s.getRequestMetadataFromHistory=s.getTradeDataFromHistory=s.getPreConfirmationPropertiesFromQuote=s.getPriceImpactFromQuote=s.getTradeDataFromQuote=s.getRequestParamFromHistory=s.getFinalizedTxProperties=s.getTxStatusesFromHistory=void 0;const a=e("@metamask/bridge-controller"),n=e("@metamask/transaction-controller"),r=e("bignumber.js"),o=e("./gas.cjs"),i=e("./swap-received-amount.cjs");s.getTxStatusesFromHistory=({status:e,hasApprovalTx:t,approvalTxId:s,quote:n})=>{const r=e.srcChain.txHash?a.StatusTypes.COMPLETE:a.StatusTypes.PENDING,o=e.destChain?.txHash?e.status:a.StatusTypes.PENDING,i=(0,a.formatChainIdToHex)(n.srcChainId),c=(0,a.isEthUsdt)(i,n.srcAsset.address),l=e.srcChain.txHash?a.StatusTypes.COMPLETE:undefined,d=e.srcChain.txHash?a.StatusTypes.COMPLETE:a.StatusTypes.PENDING;return{allowance_reset_transaction:c?l:undefined,approval_transaction:t||s?d:undefined,source_transaction:r,destination_transaction:e.status===a.StatusTypes.FAILED?a.StatusTypes.FAILED:o}};s.getFinalizedTxProperties=(e,t,s)=>{const a=s?.submittedTime??t?.submittedTime??e.startTime,c=t?.type===n.TransactionType.swap?t?.time:e.completionTime,l=(0,o.calcActualGasUsed)(e,t?.txReceipt,s?.txReceipt),d=t?.type===n.TransactionType.swap?(0,i.getActualSwapReceivedAmount)(e,l,t):(0,i.getActualBridgeReceivedAmount)(e),m=e.pricingData?.quotedGasAmount&&l?.amount?new r.BigNumber(e.pricingData.quotedGasAmount).multipliedBy(new r.BigNumber(10).pow(18)).div(l.amount).toNumber():0,u=e.pricingData?.quotedReturnInUsd&&d?.usd?new r.BigNumber(e.pricingData.quotedReturnInUsd).div(d.usd).toNumber():0;return{actual_time_minutes:c&&a?(c-a)/6e4:0,usd_actual_return:Number(d?.usd??0),usd_actual_gas:l?.usd??0,quote_vs_execution_ratio:u,quoted_vs_used_gas_ratio:m}};s.getRequestParamFromHistory=e=>({chain_id_source:(0,a.formatChainIdToCaip)(e.quote.srcChainId),token_symbol_source:e.quote.srcAsset.symbol,token_address_source:e.quote.srcAsset.assetId,chain_id_destination:(0,a.formatChainIdToCaip)(e.quote.destChainId),token_symbol_destination:e.quote.destAsset.symbol,token_address_destination:e.quote.destAsset.assetId});s.getTradeDataFromQuote=e=>({usd_quoted_gas:Number(e.gasFee?.effective?.usd??0),gas_included:e.quote.gasIncluded??!1,gas_included_7702:e.quote.gasIncluded7702??!1,provider:(0,a.formatProviderLabel)(e.quote),quoted_time_minutes:Number(e.estimatedProcessingTimeInSeconds/60),usd_quoted_return:Number(e.adjustedReturn?.usd??0)});s.getPriceImpactFromQuote=e=>({price_impact:Number(e.priceData?.priceImpact??"0")});s.getPreConfirmationPropertiesFromQuote=(e,t,n,r=a.MetaMetricsSwapsEventSource.MainView,o,i)=>{const{quote:c}=e;return{...(0,s.getPriceImpactFromQuote)(c),...(0,s.getTradeDataFromQuote)(e),chain_id_source:(0,a.formatChainIdToCaip)(c.srcChainId),token_symbol_source:c.srcAsset.symbol,chain_id_destination:(0,a.formatChainIdToCaip)(c.destChainId),token_symbol_destination:c.destAsset.symbol,is_hardware_wallet:n,swap_type:(0,a.getSwapType)(e.quote.srcChainId,e.quote.destChainId),usd_amount_source:Number(e.sentAmount?.usd??0),stx_enabled:t,action_type:a.MetricsActionType.SWAPBRIDGE_V1,custom_slippage:!1,location:r,...o&&Object.keys(o).length>0&&{ab_tests:o},...i&&i.length>0&&{active_ab_tests:i}}};s.getTradeDataFromHistory=e=>({usd_quoted_gas:Number(e.pricingData?.quotedGasInUsd??0),gas_included:e.quote.gasIncluded??!1,gas_included_7702:e.quote.gasIncluded7702??!1,provider:(0,a.formatProviderLabel)(e.quote),quoted_time_minutes:Number(e.estimatedProcessingTimeInSeconds/60),usd_quoted_return:Number(e.pricingData?.quotedReturnInUsd??0)});s.getRequestMetadataFromHistory=(e,t)=>{const{quote:s,slippagePercentage:n,isStxEnabled:r}=e;return{slippage_limit:n,custom_slippage:(0,a.isCustomSlippage)(n),usd_amount_source:Number(e.pricingData?.amountSentInUsd??0),swap_type:(0,a.getSwapType)(s.srcChainId,s.destChainId),is_hardware_wallet:(0,a.isHardwareWallet)(t),stx_enabled:r??!1,security_warnings:[]}};s.getEVMTxPropertiesFromTransactionMeta=e=>({source_transaction:[n.TransactionStatus.failed,n.TransactionStatus.dropped,n.TransactionStatus.rejected].includes(e.status)?a.StatusTypes.FAILED:a.StatusTypes.COMPLETE,error_message:e.error?.message??"",chain_id_source:(0,a.formatChainIdToCaip)(e.chainId),chain_id_destination:(0,a.formatChainIdToCaip)(e.chainId),token_symbol_source:e.sourceTokenSymbol??"",token_symbol_destination:e.destinationTokenSymbol??"",usd_amount_source:0,stx_enabled:!1,token_address_source:(0,a.formatAddressToAssetId)(e.sourceTokenAddress??"",e.chainId)??"",token_address_destination:(0,a.formatAddressToAssetId)(e.destinationTokenAddress??"",e.chainId)??"",custom_slippage:!1,is_hardware_wallet:!1,swap_type:e.type&&[n.TransactionType.swap,n.TransactionType.swapApproval].includes(e.type)?a.MetricsSwapType.SINGLE:a.MetricsSwapType.CROSSCHAIN,security_warnings:[],price_impact:0,usd_quoted_gas:0,gas_included:!1,gas_included_7702:!1,quoted_time_minutes:0,usd_quoted_return:0,provider:"",actual_time_minutes:0,quote_vs_execution_ratio:0,quoted_vs_used_gas_ratio:0,usd_actual_return:0,usd_actual_gas:0,action_type:a.MetricsActionType.SWAPBRIDGE_V1})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/metrics.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getNetworkClientIdByChainId=s.getSelectedChainId=void 0;const a=e("@metamask/bridge-controller");s.getSelectedChainId=e=>{const{selectedNetworkClientId:t}=e.call("NetworkController:getState");return e.call("NetworkController:getNetworkClientById",t).configuration.chainId};s.getNetworkClientIdByChainId=(e,t)=>{const s=(0,a.formatChainIdToHex)(t);return e.call("NetworkController:findNetworkClientIdByChainId",s)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/snaps.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/snaps-controllers":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/snaps-controllers/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs",uuid:"/home/runner/work/metamask-extension/metamask-extension/node_modules/uuid/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.handleNonEvmTx=s.handleNonEvmTxResponse=s.getTxMetaFields=s.getClientRequest=s.createClientTransactionRequest=void 0;const a=e("@metamask/bridge-controller"),n=(e("@metamask/snaps-controllers"),e("@metamask/transaction-controller")),r=e("uuid");s.createClientTransactionRequest=(e,t,s,a,n)=>({snapId:e,origin:"metamask",handler:"onClientRequest",request:{id:(0,r.v4)(),jsonrpc:"2.0",method:"signAndSendTransaction",params:{transaction:t,scope:s,accountId:a,...n&&{options:n}}}});s.getClientRequest=(e,t,n,r)=>{const o=(0,a.formatChainIdToCaip)(t),i=(0,a.extractTradeData)(e),c=(0,a.isTronTrade)(e)?{visible:e.visible,type:e.raw_data?.contract?.[0]?.type}:undefined;return(0,s.createClientTransactionRequest)(r,i,o,n,c)};s.getTxMetaFields=(e,t)=>{let s;try{s=(0,a.formatChainIdToHex)(e.quote.destChainId)}catch{s=n.CHAIN_IDS.MAINNET}return{destinationChainId:s,sourceTokenAmount:e.quote.srcTokenAmount,sourceTokenSymbol:e.quote.srcAsset.symbol,sourceTokenDecimals:e.quote.srcAsset.decimals,sourceTokenAddress:e.quote.srcAsset.address,destinationTokenAmount:e.quote.destTokenAmount,destinationTokenSymbol:e.quote.destAsset.symbol,destinationTokenDecimals:e.quote.destAsset.decimals,destinationTokenAddress:e.quote.destAsset.address,approvalTxId:t,swapTokenValue:e.sentAmount.amount}};s.handleNonEvmTxResponse=(e,t,o,i)=>{const c=i.address,l=i.metadata.snap?.id;let d;"string"==typeof e?d=e:e&&"object"==typeof e&&("transactionId"in e&&e.transactionId?d=e.transactionId:"result"in e&&e.result&&"object"==typeof e.result?d=e.result.signature||e.result.txid||e.result.hash||e.result.txHash:"signature"in e&&e.signature&&"string"==typeof e.signature&&(d=e.signature));const m=(0,a.isCrossChain)(o.quote.srcChainId,o.quote.destChainId);let u;try{u=(0,a.formatChainIdToHex)(o.quote.srcChainId)}catch{u="0x1"}const h=(0,a.extractTradeData)(t);return{...(0,s.getTxMetaFields)(o),time:Date.now(),id:d??(0,r.v4)(),chainId:u,networkClientId:l??"mainnet",txParams:{from:c,data:h},type:m?n.TransactionType.bridge:n.TransactionType.swap,status:n.TransactionStatus.submitted,hash:d,origin:l,isSolana:!0,isBridgeTx:m}};s.handleNonEvmTx=async(e,t,a,n)=>{if(!n.metadata?.snap?.id)throw new Error("Failed to submit cross-chain swap transaction: undefined snap id");const r=(0,s.getClientRequest)(t,a.quote.srcChainId,n.id,n.metadata?.snap?.id),o=await e.call("SnapController:handleRequest",r);return(0,s.handleNonEvmTxResponse)(o,t,a,n)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/snaps.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/swap-received-amount.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getActualBridgeReceivedAmount=s.getActualSwapReceivedAmount=void 0;const a=e("@metamask/bridge-controller"),n=e("bignumber.js");s.getActualSwapReceivedAmount=(e,t,s)=>{const{pricingData:r}=e,o=e.quote.destTokenAmount;if(!s?.txReceipt)return null;const i=(0,a.isNativeAddress)(e.quote.destAsset.address)?((e,t,s)=>{const{preTxBalance:a,postTxBalance:r}=s;return a&&r&&a!==r?t&&r&&a?new n.BigNumber(r,16).minus(a,16).minus(t.amount).div(10**e.quote.destAsset.decimals):null:new n.BigNumber(e.quote.destTokenAmount).div(new n.BigNumber(10).pow(e.quote.destAsset.decimals)).toString(10)})(e,t,s):((e,t)=>{const{txReceipt:s}=t;if(!s?.logs||"0x0"===s.status)return null;const{account:a,quote:r}=e,o=s.logs.find(e=>{const t=e.topics?.[0]?.startsWith("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),s=e.address?.toLowerCase()===r.destAsset.address?.toLowerCase(),n=e.topics?.[2]&&(e.topics[2]===a||e.topics[2].match(a?.slice(2)));return t&&s&&n});return o?.data?new n.BigNumber(o.data,16).div(new n.BigNumber(10).pow(r.destAsset.decimals)):null})(e,s),c=r?.quotedReturnInUsd&&o?new n.BigNumber(r.quotedReturnInUsd).div(o).multipliedBy(10**e.quote.destAsset.decimals):null;return{amount:i,usd:i&&c?c.multipliedBy(i):null}};s.getActualBridgeReceivedAmount=e=>{const{quote:t,pricingData:s,status:a}=e,r=s?.quotedReturnInUsd?new n.BigNumber(s.quotedReturnInUsd).div(t.destTokenAmount):null,o=a.destChain?.amount;return o&&r?{amount:o,usd:r.multipliedBy(o).toString(10)}:null}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/swap-received-amount.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/trace.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getApprovalTraceParams=s.getTraceParams=void 0;const a=e("@metamask/bridge-controller"),n=e("../constants.cjs");s.getTraceParams=(e,t)=>({name:(0,a.isCrossChain)(e.quote.srcChainId,e.quote.destChainId)?n.TraceName.BridgeTransactionCompleted:n.TraceName.SwapTransactionCompleted,data:{srcChainId:(0,a.formatChainIdToCaip)(e.quote.srcChainId),stxEnabled:t}});s.getApprovalTraceParams=(e,t)=>({name:(0,a.isCrossChain)(e.quote.srcChainId,e.quote.destChainId)?n.TraceName.BridgeTransactionApprovalCompleted:n.TraceName.SwapTransactionApprovalCompleted,data:{srcChainId:(0,a.formatChainIdToCaip)(e.quote.srcChainId),stxEnabled:t}})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/trace.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./accounts.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs","./network.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.submitEvmTransaction=s.addTransactionBatch=s.findAndUpdateTransactionsInBatch=s.getAddTransactionBatchParams=s.toBatchTxParams=s.waitForTxConfirmation=s.handleMobileHardwareWalletDelay=s.handleApprovalDelay=s.addSyntheticTransaction=s.generateActionId=s.addTransaction=s.checkIsDelegatedAccount=s.updateTransaction=s.getTransactionMetaByHash=s.getTransactionMetaById=s.getTransactions=s.calculateGasFees=s.getTxGasEstimates=s.getGasFeeEstimates=void 0;const a=e("@metamask/bridge-controller"),n=e("@metamask/controller-utils"),r=e("@metamask/transaction-controller"),o=e("@metamask/utils"),i=e("bignumber.js"),c=e("./accounts.cjs"),l=e("./network.cjs"),d=e("../constants.cjs");s.getGasFeeEstimates=async(e,t)=>{const{estimates:s}=await e.call("TransactionController:estimateGasFee",t);return a.BRIDGE_PREFERRED_GAS_ESTIMATE in s&&"object"==typeof s[a.BRIDGE_PREFERRED_GAS_ESTIMATE]&&"maxFeePerGas"in s[a.BRIDGE_PREFERRED_GAS_ESTIMATE]&&"maxPriorityFeePerGas"in s[a.BRIDGE_PREFERRED_GAS_ESTIMATE]?s[a.BRIDGE_PREFERRED_GAS_ESTIMATE]:{}};s.getTxGasEstimates=async(e,t)=>{const{gasFeeEstimates:a}=e.call("GasFeeController:getState"),n="estimatedBaseFee"in a?a.estimatedBaseFee:"0",{maxFeePerGas:r,maxPriorityFeePerGas:o}=await(0,s.getGasFeeEstimates)(e,t);return{baseAndPriorityFeePerGas:o?new i.BigNumber(n,10).times(10**9).plus(o,16):undefined,maxFeePerGas:r,maxPriorityFeePerGas:o}};s.calculateGasFees=async(e,t,{chainId:a,gasLimit:r,...o},i,c,l)=>{if(e)return{};if(l)return{...l,gas:r?.toString()};const d={...o,gas:r?.toString(),data:o.data,to:o.to,value:o.value},{maxFeePerGas:m,maxPriorityFeePerGas:u}=await(0,s.getTxGasEstimates)(t,{transactionParams:d,networkClientId:i,chainId:c});return{maxFeePerGas:m,maxPriorityFeePerGas:u,gas:(0,n.toHex)(d.gas??0)}};s.getTransactions=e=>e.call("TransactionController:getState").transactions??[];s.getTransactionMetaById=(e,t)=>(0,s.getTransactions)(e).find(e=>e.id===t);s.getTransactionMetaByHash=(e,t)=>(0,s.getTransactions)(e).find(e=>e.hash===t);s.updateTransaction=(e,t,s,a)=>e.call("TransactionController:updateTransaction",{...t,...s},a);s.checkIsDelegatedAccount=async(e,t,s)=>{try{return(await e.call("TransactionController:isAtomicBatchSupported",{address:t,chainIds:s})).some(e=>e.isSupported&&e.delegationAddress)}catch{return!1}};s.addTransaction=async(e,...t)=>{const{result:a}=await e.call("TransactionController:addTransaction",...t);return await(async(e,t)=>{const a=await t,n=(0,s.getTransactionMetaByHash)(e,a);if(!n)throw new Error("Failed to submit cross-chain swap tx: txMeta for txHash was not found");return n})(e,a)};s.generateActionId=()=>(Date.now()+Math.random()).toString();s.addSyntheticTransaction=async(e,...t)=>{const{transactionMeta:a}=await e.call("TransactionController:addTransaction",t[0],{origin:"metamask",actionId:(0,s.generateActionId)(),isStateOnly:!0,...t[1]});return a};s.handleApprovalDelay=async e=>{if([a.ChainId.LINEA,a.ChainId.BASE].includes(e)){(0,o.createProjectLogger)("bridge")("Delaying submitting bridge tx to make Linea and Base confirmation more likely");const e=new Promise(e=>setTimeout(e,d.APPROVAL_DELAY_MS));await e}};s.handleMobileHardwareWalletDelay=async e=>{if(e){const e=new Promise(e=>setTimeout(e,1e3));await e}};s.waitForTxConfirmation=async(e,t,{timeoutMs:a=3e5,pollMs:n=3e3}={})=>{const o=Date.now();for(;;){const i=(0,s.getTransactionMetaById)(e,t);if(i){if(i.status===r.TransactionStatus.confirmed)return i;if(i.status===r.TransactionStatus.failed||i.status===r.TransactionStatus.dropped||i.status===r.TransactionStatus.rejected)throw new Error("Approval transaction did not confirm")}if(Date.now()-o>a)throw new Error("Timed out waiting for approval confirmation");await new Promise(e=>setTimeout(e,n))}};s.toBatchTxParams=(e,{chainId:t,gasLimit:s,...a},{maxFeePerGas:r,maxPriorityFeePerGas:o,gas:i})=>{const c={...a,data:a.data,to:a.to,value:a.value};return e?c:{...c,gas:(0,n.toHex)(i??0),maxFeePerGas:(0,n.toHex)(r??0),maxPriorityFeePerGas:(0,n.toHex)(o??0)}};s.getAddTransactionBatchParams=async({messenger:e,isBridgeTx:t,approval:n,resetApproval:o,trade:i,quoteResponse:{quote:{feeData:{txFee:d},gasIncluded:m,gasIncluded7702:u,gasSponsored:h},sentAmount:f,toTokenAmount:p},requireApproval:g=!1,isDelegatedAccount:k=!1})=>{const b=m||u;if(!(0,c.getAccountByAddress)(e,i.from))throw new Error("Failed to submit cross-chain swap batch transaction: unknown account in trade data");const w=(0,a.formatChainIdToHex)(i.chainId),_=(0,l.getNetworkClientIdByChainId)(e,w),T=!0===u;let E=!T&&!k;m&&!u&&(E=!0);const I=[];if(o){const a=await(0,s.calculateGasFees)(T,e,o,_,w,b?d:undefined);I.push({type:t?r.TransactionType.bridgeApproval:r.TransactionType.swapApproval,params:(0,s.toBatchTxParams)(T,o,a)})}if(n){const a=await(0,s.calculateGasFees)(T,e,n,_,w,b?d:undefined);I.push({type:t?r.TransactionType.bridgeApproval:r.TransactionType.swapApproval,params:(0,s.toBatchTxParams)(T,n,a)})}const S=await(0,s.calculateGasFees)(T,e,i,_,w,b?d:undefined);I.push({type:t?r.TransactionType.bridge:r.TransactionType.swap,params:(0,s.toBatchTxParams)(T,i,S),assetsFiatValues:{sending:f?.valueInCurrency?.toString(),receiving:p?.valueInCurrency?.toString()}});return{disable7702:E,isGasFeeIncluded:Boolean(u),isGasFeeSponsored:Boolean(h),networkClientId:_,requireApproval:g,origin:"metamask",from:i.from,transactions:I}};s.findAndUpdateTransactionsInBatch=({messenger:e,batchId:t,txDataByType:a})=>{const n=(0,s.getTransactions)(e),o={approvalMeta:undefined,tradeMeta:undefined};return Object.entries(a).forEach(([a,i])=>{if(i===undefined)return;const c=n.find(e=>{if(e.batchId!==t)return!1;if(Array.isArray(e.txParams.authorizationList)&&e.txParams.authorizationList.length>0||Boolean(e.delegationAddress)){if((a===r.TransactionType.swap||a===r.TransactionType.bridge)&&e.type===r.TransactionType.batch)return!0;if((a===r.TransactionType.swapApproval||a===r.TransactionType.bridgeApproval)&&e.txParams.data===i)return!0}return e.txParams.data===i});if(c){const t={...c,type:a};(0,s.updateTransaction)(e,c,{type:a},`Update tx type to ${a}`);const n=[r.TransactionType.bridgeApproval,r.TransactionType.swapApproval];o[n.includes(a)?"approvalMeta":"tradeMeta"]=t}}),o};s.addTransactionBatch=async(e,t,...a)=>{const n={[r.TransactionType.bridgeApproval]:a[0].transactions.find(({type:e})=>e===r.TransactionType.bridgeApproval)?.params.data,[r.TransactionType.swapApproval]:a[0].transactions.find(({type:e})=>e===r.TransactionType.swapApproval)?.params.data,[r.TransactionType.bridge]:a[0].transactions.find(({type:e})=>e===r.TransactionType.bridge)?.params.data,[r.TransactionType.swap]:a[0].transactions.find(({type:e})=>e===r.TransactionType.swap)?.params.data},{batchId:o}=await t(...a),{approvalMeta:i,tradeMeta:c}=(0,s.findAndUpdateTransactionsInBatch)({messenger:e,batchId:o,txDataByType:n});if(!c)throw new Error("Failed to update cross-chain swap transaction batch: tradeMeta not found");return{approvalMeta:i,tradeMeta:c}};const m=async(e,t,a,r,o)=>{const{gas:i}=t;if(o)return{maxFeePerGas:(0,n.toHex)(o.maxFeePerGas),maxPriorityFeePerGas:(0,n.toHex)(o.maxPriorityFeePerGas),gas:i?(0,n.toHex)(i):undefined};const{maxFeePerGas:c,maxPriorityFeePerGas:l}=await(0,s.getTxGasEstimates)(e,{transactionParams:t,chainId:r,networkClientId:a});return{maxFeePerGas:c,maxPriorityFeePerGas:l,gas:i?(0,n.toHex)(i):undefined}};s.submitEvmTransaction=async({messenger:e,trade:t,transactionType:n,requireApproval:r=!1,txFee:o,actionId:i=(0,s.generateActionId)()})=>{if(!(0,c.getAccountByAddress)(e,t.from))throw new Error("Failed to submit cross-chain swap transaction: unknown account in trade data");const d=(0,a.formatChainIdToHex)(t.chainId),u=(0,l.getNetworkClientIdByChainId)(e,d),h={actionId:i,networkClientId:u,requireApproval:r,type:n,origin:"metamask"},{gasLimit:f,...p}=t,g={...p,chainId:d,...f&&0!==f&&{gasLimit:f.toString(),gas:f.toString()}},k={...g,...await m(e,g,u,d,o)};return await(0,s.addTransaction)(e,k,h)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/superstruct":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/superstruct/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.validateIntentStatusResponse=s.IntentOrderStatus=s.validateBridgeStatusResponse=s.StatusResponseSchema=void 0;const a=e("@metamask/bridge-controller"),n=e("@metamask/superstruct"),r=(0,n.number)(),o=(0,n.type)({}),i=(0,n.type)({chainId:r,txHash:(0,n.optional)((0,n.string)()),amount:(0,n.optional)((0,n.string)()),token:(0,n.optional)((0,n.union)([o,a.BridgeAssetSchema]))}),c=(0,n.type)({chainId:r,txHash:(0,n.optional)((0,n.string)()),amount:(0,n.optional)((0,n.string)()),token:(0,n.optional)((0,n.union)([o,a.BridgeAssetSchema]))}),l=(0,n.type)({});s.StatusResponseSchema=(0,n.type)({status:(0,n.enums)(Object.values(a.StatusTypes)),srcChain:i,destChain:(0,n.optional)(c),bridge:(0,n.optional)((0,n.string)()),isExpectedToken:(0,n.optional)((0,n.boolean)()),isUnrecognizedRouterAddress:(0,n.optional)((0,n.boolean)()),refuel:(0,n.optional)(l)});var d;s.validateBridgeStatusResponse=e=>((0,n.assert)(e,s.StatusResponseSchema),!0),function(e){e.PENDING="pending",e.SUBMITTED="submitted",e.CONFIRMED="confirmed",e.COMPLETED="completed",e.FAILED="failed",e.CANCELLED="cancelled",e.EXPIRED="expired"}(d||(s.IntentOrderStatus=d={}));const m=(0,n.type)({id:(0,n.string)(),status:(0,n.enums)(Object.values(d)),txHash:(0,n.optional)((0,n.string)()),metadata:(0,n.type)({txHashes:(0,n.optional)((0,n.union)([(0,n.array)((0,n.string)()),(0,n.string)()]))})});s.validateIntentStatusResponse=e=>(0,n.is)(e,m)}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/bridge-controller.cjs",{"./constants/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs","./constants/chains.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs","./constants/swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/swaps.cjs","./constants/traces.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/traces.cjs","./selectors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/selectors.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs","./utils/assets.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/assets.cjs","./utils/balance.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/balance.cjs","./utils/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","./utils/caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","./utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/feature-flags.cjs","./utils/fetch.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/fetch.cjs","./utils/metrics/constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/constants.cjs","./utils/metrics/properties.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/properties.cjs","./utils/quote-fees.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote-fees.cjs","./utils/quote.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote.cjs","./utils/snaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/snaps.cjs","@ethersproject/bignumber":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/bignumber/lib/index.js","@ethersproject/contracts":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/contracts/lib/index.js","@ethersproject/providers":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/providers/lib/index.js","@metamask/metamask-eth-abis":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/metamask-eth-abis/dist/index.js","@metamask/polling-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/polling-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p,g,k,b,w,_,T,E,I,S,x,y,A,v,P,C,j=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},N=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.BridgeController=void 0;const D=e("@ethersproject/bignumber"),R=e("@ethersproject/contracts"),F=e("@ethersproject/providers"),L=e("@metamask/metamask-eth-abis"),M=e("@metamask/polling-controller"),O=e("./constants/bridge.cjs"),B=e("./constants/chains.cjs"),G=e("./constants/swaps.cjs"),H=e("./constants/traces.cjs"),U=e("./selectors.cjs"),q=e("./types.cjs"),W=e("./utils/assets.cjs"),$=e("./utils/balance.cjs"),V=e("./utils/bridge.cjs"),K=e("./utils/caip-formatters.cjs"),Y=e("./utils/feature-flags.cjs"),Q=e("./utils/fetch.cjs"),z=e("./utils/metrics/constants.cjs"),X=e("./utils/metrics/properties.cjs"),J=e("./utils/quote.cjs"),Z=e("./utils/quote-fees.cjs"),ee=e("./utils/snaps.cjs"),te={quoteRequest:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},quotes:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},quotesInitialLoadTime:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},quotesLastFetched:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},quotesLoadingStatus:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},quoteFetchError:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},quotesRefreshCount:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},assetExchangeRates:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},minimumBalanceForRentExemptionInLamports:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0},tokenWarnings:{includeInStateLogs:!0,persist:!1,includeInDebugSnapshot:!1,usedInUi:!0}};class se extends((0,M.StaticIntervalPollingController)()){constructor({messenger:e,state:t,clientId:s,clientVersion:M,getLayer1GasFee:se,fetchFn:ae,config:ne,trackMetaMetricsFn:re,traceFn:oe,getUseAssetsControllerForRates:ie}){super({name:O.BRIDGE_CONTROLLER_NAME,metadata:te,messenger:e,state:{...(0,V.getDefaultBridgeControllerState)(),...t}}),a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,z.MetaMetricsSwapsEventSource.MainView),i.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,void 0),u.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this._executePoll=async e=>{await N(this,_,"f").call(this,e)},this.updateBridgeQuoteRequestParams=async(e,t)=>{N(this,P,"f").call(this,e),this.resetState(z.AbortReason.QuoteRequestUpdated);const s={...O.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,...e};if(this.update(e=>{e.quoteRequest=s}),(0,J.isValidQuoteRequest)(s)){j(this,r,Date.now(),"f");const n=(0,V.isNonEvmChainId)(s.srcChainId),o=n?undefined:N(this,a,"m",S).call(this,(0,K.formatChainIdToHex)(s.srcChainId))?.configuration;let i,c=Boolean(e.resetApproval);n?i=e.insufficientBal:o?.rpcUrl?.includes("tenderly")?i=!0:(this.update(e=>{e.quotesLoadingStatus=q.RequestStatus.LOADING}),c=await N(this,w,"f").call(this,s),i=e.insufficientBal??await N(this,b,"f").call(this,s)),this.setChainIntervalLength(),this.startPolling({updatedQuoteRequest:{...s,insufficientBal:i,resetApproval:c},context:t})}},this.fetchQuotes=async(e,t=null,s=null)=>{const n=(0,Y.getBridgeFeatureFlags)(this.messenger),r=await N(this,x,"f").call(this),o=s?n.quoteRequestOverrides?.[s]:undefined,m=await N(this,w,"f").call(this,e),{quotes:u,validationFailures:f}=await(0,Q.fetchBridgeQuotes)(o?{...e,...o,resetApproval:m}:{...e,resetApproval:m},t,N(this,i,"f"),r,N(this,d,"f"),N(this,h,"f").customBridgeApiBaseUrl??O.BRIDGE_PROD_API_BASE_URL,s,N(this,c,"f"));N(this,p,"f").call(this,f);const g=await(0,Z.appendFeesToQuotes)(u,this.messenger,N(this,l,"f"),N(this,a,"m",I).call(this,e.walletAddress));return(0,J.sortQuotes)(g,s)},p.set(this,e=>{0!==e.length&&this.trackUnifiedSwapBridgeEvent(z.UnifiedSwapBridgeEventName.QuotesValidationFailed,{failures:e,location:N(this,o,"f")})}),g.set(this,()=>N(this,f,"f").call(this)?{...this.messenger.call("AssetsController:getExchangeRatesForBridge"),historicalPrices:{},...this.state}:{...this.messenger.call("MultichainAssetsRatesController:getState"),...this.messenger.call("CurrencyRateController:getState"),...this.messenger.call("TokenRatesController:getState"),...this.state}),k.set(this,async({srcChainId:e,srcTokenAddress:t,destChainId:s,destTokenAddress:a})=>{const r=new Set([]),o=N(this,g,"f").call(this);t&&e&&!(0,U.selectIsAssetExchangeRateInState)(o,e,t)&&(0,W.getAssetIdsForToken)(t,e).forEach(e=>r.add(e)),a&&s&&!(0,U.selectIsAssetExchangeRateInState)(o,s,a)&&(0,W.getAssetIdsForToken)(a,s).forEach(e=>r.add(e));const l=N(this,f,"f").call(this)?this.messenger.call("AssetsController:getExchangeRatesForBridge").currentCurrency:this.messenger.call("CurrencyRateController:getState").currentCurrency;if(0===r.size)return;const m=await(0,Q.fetchAssetPrices)({assetIds:r,currencies:new Set([l]),clientId:N(this,i,"f"),clientVersion:N(this,c,"f"),fetchFn:N(this,d,"f"),signal:N(this,n,"f")?.signal}),u=(0,W.toExchangeRates)(l,m);this.update(e=>{e.assetExchangeRates={...e.assetExchangeRates,...u}})}),b.set(this,async e=>{try{const t=(0,K.formatChainIdToHex)(e.srcChainId),s=N(this,a,"m",S).call(this,t)?.provider,n=(0,K.formatAddressToCaipReference)(e.srcTokenAddress);return!(s&&n&&e.srcTokenAmount&&t&&await(0,$.hasSufficientBalance)(s,e.walletAddress,n,e.srcTokenAmount,t))}catch(e){return console.warn("Failed to set insufficientBal",e),!0}}),w.set(this,async e=>{if((0,V.isNonEvmChainId)(e.srcChainId))return!1;try{const t=(0,K.formatAddressToCaipReference)(e.srcTokenAddress);if((0,V.isEthUsdt)(e.srcChainId,t)){const s=D.BigNumber.from(await N(this,C,"f").call(this,e.walletAddress,t,e.destChainId));return s.lt(e.srcTokenAmount)&&s.gt(0)}return!1}catch(e){return console.warn("Failed to set resetApproval",e),!0}}),this.stopPollingForQuotes=(e,t)=>{this.stopAllPolling(),this.state.quotesLoadingStatus===q.RequestStatus.LOADING&&t&&this.trackUnifiedSwapBridgeEvent(z.UnifiedSwapBridgeEventName.QuotesReceived,t),N(this,n,"f")?.abort(e)},this.setLocation=e=>{j(this,o,e,"f")},this.resetState=(e=z.AbortReason.ResetState)=>{this.stopPollingForQuotes(e),this.update(e=>{e.quoteRequest=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,e.quotesInitialLoadTime=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotesInitialLoadTime,e.quotes=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotes,e.quotesLastFetched=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLastFetched,e.quotesLoadingStatus=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLoadingStatus,e.quoteFetchError=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError,e.quotesRefreshCount=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount,e.assetExchangeRates=O.DEFAULT_BRIDGE_CONTROLLER_STATE.assetExchangeRates,e.minimumBalanceForRentExemptionInLamports=O.DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports,e.tokenWarnings=O.DEFAULT_BRIDGE_CONTROLLER_STATE.tokenWarnings})},this.setChainIntervalLength=()=>{const{state:e}=this,{srcChainId:t}=e.quoteRequest,s=(0,Y.getBridgeFeatureFlags)(this.messenger),a=t?s.chains[(0,K.formatChainIdToCaip)(t)]?.refreshRate:undefined,n=s.refreshRate;this.setIntervalLength(a??n)},_.set(this,async({updatedQuoteRequest:e,context:t})=>{N(this,n,"f")?.abort(z.AbortReason.NewQuoteRequest),j(this,n,new AbortController,"f"),N(this,k,"f").call(this,e).catch(e=>console.warn("Failed to fetch asset exchange rates",e)),this.trackUnifiedSwapBridgeEvent(z.UnifiedSwapBridgeEventName.QuotesRequested,t);const{sse:s,maxRefreshCount:o}=(0,Y.getBridgeFeatureFlags)(this.messenger),i=s?.enabled&&(0,Y.hasMinimumRequiredVersion)(N(this,c,"f"),s.minimumVersion);this.update(t=>{t.quoteRequest=e,t.quoteFetchError=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError,t.tokenWarnings=O.DEFAULT_BRIDGE_CONTROLLER_STATE.tokenWarnings,t.quotesLastFetched=Date.now(),t.quotesLoadingStatus=q.RequestStatus.LOADING});const l=await N(this,x,"f").call(this);try{await N(this,u,"f").call(this,{name:(0,V.isCrossChain)(e.srcChainId,e.destChainId)?H.TraceName.BridgeQuotesFetched:H.TraceName.SwapQuotesFetched,data:{srcChainId:(0,K.formatChainIdToCaip)(e.srcChainId),destChainId:(0,K.formatChainIdToCaip)(e.destChainId)}},async()=>{const t=N(this,a,"m",I).call(this,e.walletAddress);if(N(this,E,"f").call(this,e.srcChainId,t?.metadata?.snap?.id),i)return void await N(this,T,"f").call(this,e,l,t);const s=await this.fetchQuotes(e,N(this,n,"f")?.signal);this.update(e=>{e.quotesRefreshCount===O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount&&N(this,r,"f")&&(e.quotesInitialLoadTime=Date.now()-N(this,r,"f")),e.quotes=s,e.quotesLoadingStatus=q.RequestStatus.FETCHED})})}catch(e){if(this.update(e=>{e.quotes=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotes}),e.toString().includes("AbortError")||e.toString().includes("FetchRequestCanceledException")||[z.AbortReason.ResetState,z.AbortReason.NewQuoteRequest,z.AbortReason.QuoteRequestUpdated,z.AbortReason.TransactionSubmitted].includes(e))return;this.update(t=>{let s;try{s=e?.message??e.toString()}catch{}finally{t.quoteFetchError=s??"Unknown error"}t.quotesLoadingStatus=q.RequestStatus.ERROR}),this.trackUnifiedSwapBridgeEvent(z.UnifiedSwapBridgeEventName.QuotesError,t),console.log(`Failed to ${i?"stream":"fetch"} bridge quotes`,e)}this.update(e=>{e.quotesRefreshCount+=1}),(e.insufficientBal||!e.insufficientBal&&this.state.quotesRefreshCount>=o)&&this.stopAllPolling()}),T.set(this,async(e,t,s)=>{let a=0;const o=new Set;await(0,Q.fetchBridgeQuoteStream)(N(this,d,"f"),e,N(this,n,"f")?.signal,N(this,i,"f"),t,N(this,h,"f").customBridgeApiBaseUrl??O.BRIDGE_PROD_API_BASE_URL,{onQuoteValidationFailure:N(this,p,"f"),onValidQuoteReceived:async e=>{const t=(async()=>{const t=await(0,Z.appendFeesToQuotes)([e],this.messenger,N(this,l,"f"),s);t.length>0&&(a+=1),this.update(e=>{1===a&&(e.quotes=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotes,!e.quotesInitialLoadTime&&N(this,r,"f")&&(e.quotesInitialLoadTime=Date.now()-N(this,r,"f"))),e.quotes=[...e.quotes,...t]})})();o.add(t),t.catch(e=>{console.error("Error appending fees to quote",e)}).finally(()=>{o.delete(t)}),await t},onTokenWarning:e=>{this.update(t=>{t.tokenWarnings.some(t=>t.feature_id===e.feature_id)||(t.tokenWarnings=[...t.tokenWarnings,e])})},onClose:async()=>{await Promise.allSettled(Array.from(o)),this.update(e=>{0===a&&(e.quotes=O.DEFAULT_BRIDGE_CONTROLLER_STATE.quotes),e.quotesLoadingStatus=q.RequestStatus.FETCHED})}},N(this,c,"f"))}),E.set(this,async(e,t)=>{if(!(0,V.isSolanaChainId)(e)||!t)return;const s=await(0,ee.getMinimumBalanceForRentExemptionInLamports)(t,this.messenger);this.update(e=>{e.minimumBalanceForRentExemptionInLamports=s})}),x.set(this,async()=>{try{return await this.messenger.call("AuthenticationController:getBearerToken")}catch(e){return console.error("Error getting JWT token for bridge-api request",e),undefined}}),y.set(this,()=>({slippage_limit:this.state.quoteRequest.slippage,swap_type:(0,X.getSwapTypeFromQuote)(this.state.quoteRequest),custom_slippage:(0,X.isCustomSlippage)(this.state.quoteRequest.slippage)})),A.set(this,()=>({quotes_count:this.state.quotes.length,quotes_list:this.state.quotes.map(({quote:e})=>(0,X.formatProviderLabel)(e)),initial_load_time_all_quotes:this.state.quotesInitialLoadTime??0,has_gas_included_quote:this.state.quotes.some(({quote:e})=>e.gasIncluded)})),v.set(this,(e,t)=>{const s=t,n={...t,location:s?.location??N(this,o,"f"),action_type:z.MetricsActionType.SWAPBRIDGE_V1};switch(e){case z.UnifiedSwapBridgeEventName.ButtonClicked:case z.UnifiedSwapBridgeEventName.PageViewed:return{...(0,X.getRequestParams)(this.state.quoteRequest),...n};case z.UnifiedSwapBridgeEventName.QuotesValidationFailed:return{...(0,X.getRequestParams)(this.state.quoteRequest),refresh_count:this.state.quotesRefreshCount,...n};case z.UnifiedSwapBridgeEventName.QuotesReceived:return{...(0,X.getRequestParams)(this.state.quoteRequest),...N(this,y,"f").call(this),...N(this,A,"f").call(this),is_hardware_wallet:(0,X.isHardwareWallet)(N(this,a,"m",I).call(this)),refresh_count:this.state.quotesRefreshCount,...n};case z.UnifiedSwapBridgeEventName.QuotesRequested:return{...(0,X.getRequestParams)(this.state.quoteRequest),...N(this,y,"f").call(this),is_hardware_wallet:(0,X.isHardwareWallet)(N(this,a,"m",I).call(this)),has_sufficient_funds:!this.state.quoteRequest.insufficientBal,...n};case z.UnifiedSwapBridgeEventName.QuotesError:return{...(0,X.getRequestParams)(this.state.quoteRequest),...N(this,y,"f").call(this),is_hardware_wallet:(0,X.isHardwareWallet)(N(this,a,"m",I).call(this)),error_message:this.state.quoteFetchError,has_sufficient_funds:!this.state.quoteRequest.insufficientBal,...n};case z.UnifiedSwapBridgeEventName.AllQuotesOpened:case z.UnifiedSwapBridgeEventName.AllQuotesSorted:case z.UnifiedSwapBridgeEventName.QuoteSelected:return{...(0,X.getRequestParams)(this.state.quoteRequest),...N(this,y,"f").call(this),...N(this,A,"f").call(this),is_hardware_wallet:(0,X.isHardwareWallet)(N(this,a,"m",I).call(this)),...n};case z.UnifiedSwapBridgeEventName.Failed:return{...n,...(0,X.getRequestParams)(this.state.quoteRequest),...N(this,y,"f").call(this),...N(this,A,"f").call(this),...t};case z.UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:case z.UnifiedSwapBridgeEventName.AssetPickerOpened:return n;case z.UnifiedSwapBridgeEventName.Submitted:case z.UnifiedSwapBridgeEventName.Completed:return t;case z.UnifiedSwapBridgeEventName.InputChanged:default:return n}}),P.set(this,e=>{Object.entries(e).forEach(([t,s])=>{const a=X.toInputChangedPropertyKey[t],n=X.toInputChangedPropertyValue[t]?.(e);a&&n!==undefined&&s!==this.state.quoteRequest[t]&&this.trackUnifiedSwapBridgeEvent(z.UnifiedSwapBridgeEventName.InputChanged,{input:a,input_value:n,location:N(this,o,"f")})})}),this.trackUnifiedSwapBridgeEvent=(e,t)=>{try{const s=N(this,v,"f").call(this,e,t);N(this,m,"f").call(this,e,s)}catch(t){console.error(`Error tracking cross-chain swaps MetaMetrics event ${e}`,t)}},C.set(this,async(e,t,s)=>{const n=N(this,a,"m",S).call(this,B.CHAIN_IDS.MAINNET),r=n?.provider;if(!r)throw new Error("No provider found");const o=new F.Web3Provider(r),i=new R.Contract(t,L.abiERC20,o),c=(0,V.isCrossChain)(B.CHAIN_IDS.MAINNET,s)?O.METABRIDGE_ETHEREUM_ADDRESS:G.SWAPS_CONTRACT_ADDRESSES[B.CHAIN_IDS.MAINNET];return(await i.allowance(e,c)).toString()}),this.setIntervalLength(O.REFRESH_INTERVAL_MS),j(this,n,new AbortController,"f"),j(this,l,se,"f"),j(this,i,s,"f"),j(this,c,M,"f"),j(this,d,ae,"f"),j(this,m,re,"f"),j(this,h,ne??{},"f"),j(this,u,oe??((e,t)=>t?.()),"f"),j(this,f,ie??(()=>!1),"f"),this.messenger.registerActionHandler(`${O.BRIDGE_CONTROLLER_NAME}:setChainIntervalLength`,this.setChainIntervalLength.bind(this)),this.messenger.registerActionHandler(`${O.BRIDGE_CONTROLLER_NAME}:updateBridgeQuoteRequestParams`,this.updateBridgeQuoteRequestParams.bind(this)),this.messenger.registerActionHandler(`${O.BRIDGE_CONTROLLER_NAME}:resetState`,this.resetState.bind(this)),this.messenger.registerActionHandler(`${O.BRIDGE_CONTROLLER_NAME}:trackUnifiedSwapBridgeEvent`,this.trackUnifiedSwapBridgeEvent.bind(this)),this.messenger.registerActionHandler(`${O.BRIDGE_CONTROLLER_NAME}:stopPollingForQuotes`,this.stopPollingForQuotes.bind(this)),this.messenger.registerActionHandler(`${O.BRIDGE_CONTROLLER_NAME}:fetchQuotes`,this.fetchQuotes.bind(this))}}s.BridgeController=se,n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,h=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakMap,k=new WeakMap,b=new WeakMap,w=new WeakMap,_=new WeakMap,T=new WeakMap,E=new WeakMap,x=new WeakMap,y=new WeakMap,A=new WeakMap,v=new WeakMap,P=new WeakMap,C=new WeakMap,a=new WeakSet,I=function(e){const t=e??this.state.quoteRequest.walletAddress;if(!t)throw new Error("Account address is required");return this.messenger.call("AccountsController:getAccountByAddress",t)},S=function(e){const t=this.messenger.call("NetworkController:findNetworkClientIdByChainId",e);if(!t)throw new Error(`No network client found for chainId: ${e}`);return this.messenger.call("NetworkController:getNetworkClientById",t)}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/bridge-controller.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs",{"./chains.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs","@ethersproject/constants":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/constants/lib/index.js","@metamask/keyring-api":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-api/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.METABRIDGE_CHAIN_TO_ADDRESS_MAP=s.DEFAULT_BRIDGE_CONTROLLER_STATE=s.DEFAULT_FEATURE_FLAG_CONFIG=s.DEFAULT_CHAIN_RANKING=s.BRIDGE_CONTROLLER_NAME=s.DEFAULT_MAX_REFRESH_COUNT=s.REFRESH_INTERVAL_MS=s.BRIDGE_MM_FEE_RATE=s.BRIDGE_PREFERRED_GAS_ESTIMATE=s.BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE=s.BRIDGE_QUOTE_MAX_ETA_SECONDS=s.METABRIDGE_ETHEREUM_ADDRESS=s.ETH_USDT_ADDRESS=s.BridgeClientId=s.BRIDGE_PROD_API_BASE_URL=s.BRIDGE_DEV_API_BASE_URL=s.ALLOWED_BRIDGE_CHAIN_IDS=void 0;const a=e("@ethersproject/constants"),n=e("@metamask/keyring-api"),r=e("./chains.cjs");var o;s.ALLOWED_BRIDGE_CHAIN_IDS=[r.CHAIN_IDS.MAINNET,r.CHAIN_IDS.BSC,r.CHAIN_IDS.POLYGON,r.CHAIN_IDS.ZKSYNC_ERA,r.CHAIN_IDS.AVALANCHE,r.CHAIN_IDS.OPTIMISM,r.CHAIN_IDS.ARBITRUM,r.CHAIN_IDS.LINEA_MAINNET,r.CHAIN_IDS.BASE,r.CHAIN_IDS.SEI,r.CHAIN_IDS.MONAD,r.CHAIN_IDS.HYPEREVM,r.CHAIN_IDS.MEGAETH,n.SolScope.Mainnet,n.BtcScope.Mainnet,n.TrxScope.Mainnet],s.BRIDGE_DEV_API_BASE_URL="https://bridge.dev-api.cx.metamask.io",s.BRIDGE_PROD_API_BASE_URL="https://bridge.api.cx.metamask.io",function(e){e.EXTENSION="extension",e.MOBILE="mobile"}(o||(s.BridgeClientId=o={})),s.ETH_USDT_ADDRESS="0xdac17f958d2ee523a2206206994597c13d831ec7",s.METABRIDGE_ETHEREUM_ADDRESS="0x0439e60F02a8900a951603950d8D4527f400C3f1",s.BRIDGE_QUOTE_MAX_ETA_SECONDS=3600,s.BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE=.5,s.BRIDGE_PREFERRED_GAS_ESTIMATE="medium",s.BRIDGE_MM_FEE_RATE=.875,s.REFRESH_INTERVAL_MS=3e4,s.DEFAULT_MAX_REFRESH_COUNT=5,s.BRIDGE_CONTROLLER_NAME="BridgeController",s.DEFAULT_CHAIN_RANKING=[{chainId:"eip155:1",name:"Ethereum"},{chainId:"eip155:56",name:"BNB"},{chainId:"bip122:000000000019d6689c085ae165831e93",name:"BTC"},{chainId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana"},{chainId:"tron:728126428",name:"Tron"},{chainId:"eip155:8453",name:"Base"},{chainId:"eip155:42161",name:"Arbitrum"},{chainId:"eip155:59144",name:"Linea"},{chainId:"eip155:137",name:"Polygon"},{chainId:"eip155:43114",name:"Avalanche"},{chainId:"eip155:10",name:"Optimism"},{chainId:"eip155:143",name:"Monad"},{chainId:"eip155:1329",name:"Sei"},{chainId:"eip155:999",name:"HyperEVM"},{chainId:"eip155:4326",name:"MegaETH"},{chainId:"eip155:324",name:"zkSync"}],s.DEFAULT_FEATURE_FLAG_CONFIG={minimumVersion:"0.0.0",refreshRate:s.REFRESH_INTERVAL_MS,maxRefreshCount:s.DEFAULT_MAX_REFRESH_COUNT,support:!1,chains:{},chainRanking:[...s.DEFAULT_CHAIN_RANKING]},s.DEFAULT_BRIDGE_CONTROLLER_STATE={quoteRequest:{srcTokenAddress:a.AddressZero},quotesInitialLoadTime:null,quotes:[],quotesLastFetched:null,quotesLoadingStatus:null,quoteFetchError:null,quotesRefreshCount:0,assetExchangeRates:{},minimumBalanceForRentExemptionInLamports:"0",tokenWarnings:[]},s.METABRIDGE_CHAIN_TO_ADDRESS_MAP={[r.CHAIN_IDS.MAINNET]:s.METABRIDGE_ETHEREUM_ADDRESS}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.NETWORK_TO_NAME_MAP=s.MEGAETH_DISPLAY_NAME=s.HYPEREVM_DISPLAY_NAME=s.MONAD_DISPLAY_NAME=s.SEI_DISPLAY_NAME=s.MODE_DISPLAY_NAME=s.MODE_SEPOLIA_DISPLAY_NAME=s.SONEIUM_DISPLAY_NAME=s.INK_DISPLAY_NAME=s.INK_SEPOLIA_DISPLAY_NAME=s.LISK_SEPOLIA_DISPLAY_NAME=s.LISK_DISPLAY_NAME=s.METACHAIN_ONE_DISPLAY_NAME=s.BERACHAIN_DISPLAY_NAME=s.OP_BNB_DISPLAY_NAME=s.SCROLL_SEPOLIA_DISPLAY_NAME=s.SCROLL_DISPLAY_NAME=s.MOONRIVER_DISPLAY_NAME=s.MOONBEAM_DISPLAY_NAME=s.POLYGON_ZKEVM_DISPLAY_NAME=s.CRONOS_DISPLAY_NAME=s.AURORA_DISPLAY_NAME=s.BASE_DISPLAY_NAME=s.ZK_SYNC_ERA_DISPLAY_NAME=s.GNOSIS_DISPLAY_NAME=s.CELO_DISPLAY_NAME=s.PALM_DISPLAY_NAME=s.HARMONY_DISPLAY_NAME=s.FANTOM_DISPLAY_NAME=s.OPTIMISM_DISPLAY_NAME=s.BNB_DISPLAY_NAME=s.ARBITRUM_DISPLAY_NAME=s.AVALANCHE_DISPLAY_NAME=s.POLYGON_DISPLAY_NAME=s.BSC_DISPLAY_NAME=s.LOCALHOST_DISPLAY_NAME=s.LINEA_MAINNET_DISPLAY_NAME=s.LINEA_SEPOLIA_DISPLAY_NAME=s.LINEA_GOERLI_DISPLAY_NAME=s.SEPOLIA_DISPLAY_NAME=s.GOERLI_DISPLAY_NAME=s.MAINNET_DISPLAY_NAME=s.NETWORK_TYPES=s.CHAIN_IDS=void 0,s.CHAIN_IDS={MAINNET:"0x1",GOERLI:"0x5",LOCALHOST:"0x539",BSC:"0x38",BSC_TESTNET:"0x61",OPTIMISM:"0xa",OPTIMISM_TESTNET:"0xaa37dc",OPTIMISM_GOERLI:"0x1a4",BASE:"0x2105",BASE_TESTNET:"0x14a33",OPBNB:"0xcc",OPBNB_TESTNET:"0x15eb",POLYGON:"0x89",POLYGON_TESTNET:"0x13881",AVALANCHE:"0xa86a",AVALANCHE_TESTNET:"0xa869",FANTOM:"0xfa",FANTOM_TESTNET:"0xfa2",CELO:"0xa4ec",ARBITRUM:"0xa4b1",HARMONY:"0x63564c40",PALM:"0x2a15c308d",SEPOLIA:"0xaa36a7",HOLESKY:"0x4268",LINEA_GOERLI:"0xe704",LINEA_SEPOLIA:"0xe705",AMOY:"0x13882",BASE_SEPOLIA:"0x14a34",BLAST_SEPOLIA:"0xa0c71fd",OPTIMISM_SEPOLIA:"0xaa37dc",PALM_TESTNET:"0x2a15c3083",CELO_TESTNET:"0xaef3",ZK_SYNC_ERA_TESTNET:"0x12c",MANTA_SEPOLIA:"0x138b",UNICHAIN_SEPOLIA:"0x515",LINEA_MAINNET:"0xe708",AURORA:"0x4e454152",MOONBEAM:"0x504",MOONBEAM_TESTNET:"0x507",MOONRIVER:"0x505",CRONOS:"0x19",GNOSIS:"0x64",ZKSYNC_ERA:"0x144",TEST_ETH:"0x539",ARBITRUM_GOERLI:"0x66eed",BLAST:"0x13e31",FILECOIN:"0x13a",POLYGON_ZKEVM:"0x44d",SCROLL:"0x82750",SCROLL_SEPOLIA:"0x8274f",WETHIO:"0x4e",CHZ:"0x15b38",NUMBERS:"0x290b",SEI:"0x531",APE_TESTNET:"0x8157",APE_MAINNET:"0x8173",BERACHAIN:"0x138d5",METACHAIN_ONE:"0x1b6e6",ARBITRUM_SEPOLIA:"0x66eee",NEAR:"0x18d",NEAR_TESTNET:"0x18e",B3:"0x208d",B3_TESTNET:"0x7c9",GRAVITY_ALPHA_MAINNET:"0x659",GRAVITY_ALPHA_TESTNET_SEPOLIA:"0x34c1",LISK:"0x46f",LISK_SEPOLIA:"0x106a",INK_SEPOLIA:"0xba5eD",INK:"0xdef1",MODE_SEPOLIA:"0x397",MODE:"0x868b",MONAD:"0x8f",HYPEREVM:"0x3e7",MEGAETH:"0x10e6"},s.NETWORK_TYPES={GOERLI:"goerli",LOCALHOST:"localhost",MAINNET:"mainnet",SEPOLIA:"sepolia",LINEA_GOERLI:"linea-goerli",LINEA_SEPOLIA:"linea-sepolia",LINEA_MAINNET:"linea-mainnet"},s.MAINNET_DISPLAY_NAME="Ethereum Mainnet",s.GOERLI_DISPLAY_NAME="Goerli",s.SEPOLIA_DISPLAY_NAME="Sepolia",s.LINEA_GOERLI_DISPLAY_NAME="Linea Goerli",s.LINEA_SEPOLIA_DISPLAY_NAME="Linea Sepolia",s.LINEA_MAINNET_DISPLAY_NAME="Linea Mainnet",s.LOCALHOST_DISPLAY_NAME="Localhost 8545",s.BSC_DISPLAY_NAME="Binance Smart Chain",s.POLYGON_DISPLAY_NAME="Polygon",s.AVALANCHE_DISPLAY_NAME="Avalanche Network C-Chain",s.ARBITRUM_DISPLAY_NAME="Arbitrum One",s.BNB_DISPLAY_NAME="BNB Chain",s.OPTIMISM_DISPLAY_NAME="OP Mainnet",s.FANTOM_DISPLAY_NAME="Fantom Opera",s.HARMONY_DISPLAY_NAME="Harmony Mainnet Shard 0",s.PALM_DISPLAY_NAME="Palm",s.CELO_DISPLAY_NAME="Celo Mainnet",s.GNOSIS_DISPLAY_NAME="Gnosis",s.ZK_SYNC_ERA_DISPLAY_NAME="zkSync Era Mainnet",s.BASE_DISPLAY_NAME="Base Mainnet",s.AURORA_DISPLAY_NAME="Aurora Mainnet",s.CRONOS_DISPLAY_NAME="Cronos",s.POLYGON_ZKEVM_DISPLAY_NAME="Polygon zkEVM",s.MOONBEAM_DISPLAY_NAME="Moonbeam",s.MOONRIVER_DISPLAY_NAME="Moonriver",s.SCROLL_DISPLAY_NAME="Scroll",s.SCROLL_SEPOLIA_DISPLAY_NAME="Scroll Sepolia",s.OP_BNB_DISPLAY_NAME="opBNB",s.BERACHAIN_DISPLAY_NAME="Berachain Artio",s.METACHAIN_ONE_DISPLAY_NAME="Metachain One Mainnet",s.LISK_DISPLAY_NAME="Lisk",s.LISK_SEPOLIA_DISPLAY_NAME="Lisk Sepolia",s.INK_SEPOLIA_DISPLAY_NAME="Ink Sepolia",s.INK_DISPLAY_NAME="Ink Mainnet",s.SONEIUM_DISPLAY_NAME="Soneium Mainnet",s.MODE_SEPOLIA_DISPLAY_NAME="Mode Sepolia",s.MODE_DISPLAY_NAME="Mode Mainnet",s.SEI_DISPLAY_NAME="Sei Network",s.MONAD_DISPLAY_NAME="Monad",s.HYPEREVM_DISPLAY_NAME="HyperEVM",s.MEGAETH_DISPLAY_NAME="MegaETH",s.NETWORK_TO_NAME_MAP={[s.NETWORK_TYPES.GOERLI]:s.GOERLI_DISPLAY_NAME,[s.NETWORK_TYPES.MAINNET]:s.MAINNET_DISPLAY_NAME,[s.NETWORK_TYPES.LINEA_GOERLI]:s.LINEA_GOERLI_DISPLAY_NAME,[s.NETWORK_TYPES.LINEA_SEPOLIA]:s.LINEA_SEPOLIA_DISPLAY_NAME,[s.NETWORK_TYPES.LINEA_MAINNET]:s.LINEA_MAINNET_DISPLAY_NAME,[s.NETWORK_TYPES.LOCALHOST]:s.LOCALHOST_DISPLAY_NAME,[s.NETWORK_TYPES.SEPOLIA]:s.SEPOLIA_DISPLAY_NAME,[s.CHAIN_IDS.ARBITRUM]:s.ARBITRUM_DISPLAY_NAME,[s.CHAIN_IDS.AVALANCHE]:s.AVALANCHE_DISPLAY_NAME,[s.CHAIN_IDS.BSC]:s.BSC_DISPLAY_NAME,[s.CHAIN_IDS.BASE]:s.BASE_DISPLAY_NAME,[s.CHAIN_IDS.GOERLI]:s.GOERLI_DISPLAY_NAME,[s.CHAIN_IDS.MAINNET]:s.MAINNET_DISPLAY_NAME,[s.CHAIN_IDS.LINEA_GOERLI]:s.LINEA_GOERLI_DISPLAY_NAME,[s.CHAIN_IDS.LINEA_MAINNET]:s.LINEA_MAINNET_DISPLAY_NAME,[s.CHAIN_IDS.LINEA_SEPOLIA]:s.LINEA_SEPOLIA_DISPLAY_NAME,[s.CHAIN_IDS.LOCALHOST]:s.LOCALHOST_DISPLAY_NAME,[s.CHAIN_IDS.OPTIMISM]:s.OPTIMISM_DISPLAY_NAME,[s.CHAIN_IDS.POLYGON]:s.POLYGON_DISPLAY_NAME,[s.CHAIN_IDS.SCROLL]:s.SCROLL_DISPLAY_NAME,[s.CHAIN_IDS.SCROLL_SEPOLIA]:s.SCROLL_SEPOLIA_DISPLAY_NAME,[s.CHAIN_IDS.SEPOLIA]:s.SEPOLIA_DISPLAY_NAME,[s.CHAIN_IDS.OPBNB]:s.OP_BNB_DISPLAY_NAME,[s.CHAIN_IDS.ZKSYNC_ERA]:s.ZK_SYNC_ERA_DISPLAY_NAME,[s.CHAIN_IDS.BERACHAIN]:s.BERACHAIN_DISPLAY_NAME,[s.CHAIN_IDS.METACHAIN_ONE]:s.METACHAIN_ONE_DISPLAY_NAME,[s.CHAIN_IDS.LISK]:s.LISK_DISPLAY_NAME,[s.CHAIN_IDS.LISK_SEPOLIA]:s.LISK_SEPOLIA_DISPLAY_NAME,[s.CHAIN_IDS.SEI]:s.SEI_DISPLAY_NAME,[s.CHAIN_IDS.MONAD]:s.MONAD_DISPLAY_NAME,[s.CHAIN_IDS.HYPEREVM]:s.HYPEREVM_DISPLAY_NAME,[s.CHAIN_IDS.MEGAETH]:s.MEGAETH_DISPLAY_NAME}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/swaps.cjs",{"./chains.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.ALLOWED_CONTRACT_ADDRESSES=s.SWAPS_WRAPPED_TOKENS_ADDRESSES=s.SWAPS_CONTRACT_ADDRESSES=s.SWAPS_API_V2_BASE_URL=void 0;const a=e("./chains.cjs");s.SWAPS_API_V2_BASE_URL="https://swap.api.cx.metamask.io";const n="0x881d40237659c251811cec9c364ef91dc08d300c";s.SWAPS_CONTRACT_ADDRESSES={[a.CHAIN_IDS.MAINNET]:n,[a.CHAIN_IDS.LOCALHOST]:n,[a.CHAIN_IDS.BSC]:"0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31",[a.CHAIN_IDS.POLYGON]:"0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31",[a.CHAIN_IDS.AVALANCHE]:"0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31",[a.CHAIN_IDS.ARBITRUM]:"0x9dda6ef3d919c9bc8885d5560999a3640431e8e6",[a.CHAIN_IDS.OPTIMISM]:"0x9dda6ef3d919c9bc8885d5560999a3640431e8e6",[a.CHAIN_IDS.ZKSYNC_ERA]:"0xf504c1fe13d14df615e66dcd0abf39e60c697f34",[a.CHAIN_IDS.LINEA_MAINNET]:"0x9dda6ef3d919c9bc8885d5560999a3640431e8e6",[a.CHAIN_IDS.BASE]:"0x9dda6ef3d919c9bc8885d5560999a3640431e8e6",[a.CHAIN_IDS.SEI]:"0x962287c9d5B8a682389E61edAE90ec882325d08b"};const r="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";s.SWAPS_WRAPPED_TOKENS_ADDRESSES={[a.CHAIN_IDS.MAINNET]:r,[a.CHAIN_IDS.LOCALHOST]:r,[a.CHAIN_IDS.BSC]:"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",[a.CHAIN_IDS.POLYGON]:"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",[a.CHAIN_IDS.AVALANCHE]:"0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",[a.CHAIN_IDS.ARBITRUM]:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",[a.CHAIN_IDS.OPTIMISM]:"0x4200000000000000000000000000000000000006",[a.CHAIN_IDS.ZKSYNC_ERA]:"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",[a.CHAIN_IDS.LINEA_MAINNET]:"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",[a.CHAIN_IDS.BASE]:"0x4200000000000000000000000000000000000006",[a.CHAIN_IDS.SEI]:"0xe30fedd158a2e3b13e9badaeabafc5516e95e8c7"},s.ALLOWED_CONTRACT_ADDRESSES={[a.CHAIN_IDS.MAINNET]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.MAINNET],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.MAINNET]],[a.CHAIN_IDS.LOCALHOST]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.LOCALHOST],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.LOCALHOST]],[a.CHAIN_IDS.BSC]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.BSC],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.BSC]],[a.CHAIN_IDS.POLYGON]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.POLYGON],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.POLYGON]],[a.CHAIN_IDS.AVALANCHE]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.AVALANCHE],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.AVALANCHE]],[a.CHAIN_IDS.ARBITRUM]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.ARBITRUM],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.ARBITRUM]],[a.CHAIN_IDS.OPTIMISM]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.OPTIMISM],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.OPTIMISM]],[a.CHAIN_IDS.ZKSYNC_ERA]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.ZKSYNC_ERA],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.ZKSYNC_ERA]],[a.CHAIN_IDS.LINEA_MAINNET]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.LINEA_MAINNET],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.LINEA_MAINNET]],[a.CHAIN_IDS.BASE]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.BASE],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.BASE]],[a.CHAIN_IDS.SEI]:[s.SWAPS_CONTRACT_ADDRESSES[a.CHAIN_IDS.SEI],s.SWAPS_WRAPPED_TOKENS_ADDRESSES[a.CHAIN_IDS.SEI]]}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/swaps.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/tokens.cjs",{"./chains.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs","@metamask/keyring-api":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-api/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.SYMBOL_TO_SLIP44_MAP=s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP=s.DEFAULT_TOKEN_ADDRESS=void 0;const a=e("@metamask/keyring-api"),n=e("./chains.cjs");s.DEFAULT_TOKEN_ADDRESS="0x0000000000000000000000000000000000000000";const r="AVAX",o="BNB",i="ETH",c="POL",l="TESTETH",d="SOL",m="SEI",u="BTC",h="TRX",f="MON",p="HYPE",g={symbol:i,name:"Ether",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},k={symbol:o,name:"Binance Coin",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},b={symbol:c,name:"Polygon",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},w={symbol:r,name:"Avalanche",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},_={symbol:l,name:"Test Ether",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},T={symbol:i,name:"Ether",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},E={symbol:i,name:"Ether",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},I={...g},S={...g},x={...g},y={...g},A={...g},v={symbol:d,name:"Solana",address:s.DEFAULT_TOKEN_ADDRESS,decimals:9,iconUrl:""},P={symbol:u,name:"Bitcoin",address:s.DEFAULT_TOKEN_ADDRESS,decimals:8,iconUrl:""},C={symbol:m,name:"Sei",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},j={symbol:h,name:"Tron",address:s.DEFAULT_TOKEN_ADDRESS,decimals:6,iconUrl:""},N={symbol:f,name:"Mon",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},D={symbol:p,name:"Hyperliquid",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18,iconUrl:""},R={...g};s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP={[n.CHAIN_IDS.MAINNET]:g,[n.CHAIN_IDS.LOCALHOST]:_,[n.CHAIN_IDS.BSC]:k,[n.CHAIN_IDS.POLYGON]:b,[n.CHAIN_IDS.GOERLI]:T,[n.CHAIN_IDS.SEPOLIA]:E,[n.CHAIN_IDS.AVALANCHE]:w,[n.CHAIN_IDS.OPTIMISM]:S,[n.CHAIN_IDS.ARBITRUM]:I,[n.CHAIN_IDS.ZKSYNC_ERA]:x,[n.CHAIN_IDS.LINEA_MAINNET]:y,[n.CHAIN_IDS.BASE]:A,[n.CHAIN_IDS.SEI]:C,[n.CHAIN_IDS.MONAD]:N,[n.CHAIN_IDS.HYPEREVM]:D,[n.CHAIN_IDS.MEGAETH]:R,[a.SolScope.Mainnet]:v,[a.SolScope.Devnet]:v,[a.BtcScope.Mainnet]:P,[a.TrxScope.Mainnet]:j},s.SYMBOL_TO_SLIP44_MAP={SOL:"slip44:501",BTC:"slip44:0",ETH:"slip44:60",POL:"slip44:966",BNB:"slip44:714",AVAX:"slip44:9005",TESTETH:"slip44:60",SEI:"slip44:19000118",TRX:"slip44:195",MON:"slip44:268435779",HYPE:"slip44:2457"}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/tokens.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/traces.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a;Object.defineProperty(s,"__esModule",{value:!0}),s.TraceName=void 0,function(e){e.BridgeQuotesFetched="Bridge Quotes Fetched",e.SwapQuotesFetched="Swap Quotes Fetched"}(a||(s.TraceName=a={}))}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/traces.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs",{"./bridge-controller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/bridge-controller.cjs","./constants/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs","./constants/swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/swaps.cjs","./constants/tokens.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/tokens.cjs","./selectors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/selectors.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs","./utils/balance.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/balance.cjs","./utils/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","./utils/caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","./utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/feature-flags.cjs","./utils/fetch.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/fetch.cjs","./utils/metrics/constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/constants.cjs","./utils/metrics/properties.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/properties.cjs","./utils/quote.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote.cjs","./utils/slippage.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/slippage.cjs","./utils/swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/swaps.cjs","./utils/trade-utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/trade-utils.cjs","./utils/validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/validators.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.isTronChainId=s.isBitcoinChainId=s.isSolanaChainId=s.isNativeAddress=s.isEthUsdt=s.MetricsSwapType=s.MetricsActionType=s.ALLOWED_CONTRACT_ADDRESSES=s.SWAPS_WRAPPED_TOKENS_ADDRESSES=s.SWAPS_CONTRACT_ADDRESSES=s.SWAPS_API_V2_BASE_URL=s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP=s.BRIDGE_PROD_API_BASE_URL=s.BRIDGE_DEV_API_BASE_URL=s.METABRIDGE_CHAIN_TO_ADDRESS_MAP=s.DEFAULT_BRIDGE_CONTROLLER_STATE=s.DEFAULT_MAX_REFRESH_COUNT=s.REFRESH_INTERVAL_MS=s.BRIDGE_MM_FEE_RATE=s.BRIDGE_PREFERRED_GAS_ESTIMATE=s.BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE=s.BRIDGE_QUOTE_MAX_ETA_SECONDS=s.BRIDGE_CONTROLLER_NAME=s.BridgeClientId=s.ALLOWED_BRIDGE_CHAIN_IDS=s.TokenFeatureType=s.FeatureId=s.BridgeAssetSchema=s.ActionTypes=s.FeeType=s.BridgeBackgroundAction=s.BridgeUserAction=s.RequestStatus=s.ChainId=s.SortOrder=s.AssetType=s.StatusTypes=s.AbortReason=s.getQuotesReceivedProperties=s.isCustomSlippage=s.isHardwareWallet=s.getSwapType=s.getRequestParams=s.formatProviderLabel=s.PollingStatus=s.MetaMetricsSwapsEventSource=s.InputAmountPreset=s.UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY=s.UnifiedSwapBridgeEventName=s.BridgeController=void 0,s.fetchTokens=s.getSwapsContractAddress=s.isValidSwapsContractAddress=s.BRIDGE_DEFAULT_SLIPPAGE=s.getBridgeFeatureFlags=s.DEFAULT_FEATURE_FLAG_CONFIG=s.selectTokenWarnings=s.selectMinimumBalanceForRentExemptionInSOL=s.selectBridgeFeatureFlags=s.selectIsQuoteExpired=s.selectExchangeRateByChainIdAndAddress=s.selectDefaultSlippagePercentage=s.selectBridgeQuotes=s.isEvmTxData=s.isTronTrade=s.isBitcoinTrade=s.extractTradeData=s.formatAddressToAssetId=s.formatAddressToCaipReference=s.formatChainIdToHex=s.formatChainIdToCaip=s.getClientHeaders=s.fetchBridgeTokens=s.calcLatestSrcBalance=s.calcSlippagePercentage=s.formatEtaInMinutes=s.isValidQuoteRequest=s.isCrossChain=s.getDefaultBridgeControllerState=s.getNativeAssetForChainId=s.isNonEvmChainId=void 0;var a=e("./bridge-controller.cjs");Object.defineProperty(s,"BridgeController",{enumerable:!0,get:function(){return a.BridgeController}});var n=e("./utils/metrics/constants.cjs");Object.defineProperty(s,"UnifiedSwapBridgeEventName",{enumerable:!0,get:function(){return n.UnifiedSwapBridgeEventName}}),Object.defineProperty(s,"UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY",{enumerable:!0,get:function(){return n.UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY}}),Object.defineProperty(s,"InputAmountPreset",{enumerable:!0,get:function(){return n.InputAmountPreset}}),Object.defineProperty(s,"MetaMetricsSwapsEventSource",{enumerable:!0,get:function(){return n.MetaMetricsSwapsEventSource}}),Object.defineProperty(s,"PollingStatus",{enumerable:!0,get:function(){return n.PollingStatus}});var r=e("./utils/metrics/properties.cjs");Object.defineProperty(s,"formatProviderLabel",{enumerable:!0,get:function(){return r.formatProviderLabel}}),Object.defineProperty(s,"getRequestParams",{enumerable:!0,get:function(){return r.getRequestParams}}),Object.defineProperty(s,"getSwapType",{enumerable:!0,get:function(){return r.getSwapType}}),Object.defineProperty(s,"isHardwareWallet",{enumerable:!0,get:function(){return r.isHardwareWallet}}),Object.defineProperty(s,"isCustomSlippage",{enumerable:!0,get:function(){return r.isCustomSlippage}}),Object.defineProperty(s,"getQuotesReceivedProperties",{enumerable:!0,get:function(){return r.getQuotesReceivedProperties}});var o=e("./utils/metrics/constants.cjs");Object.defineProperty(s,"AbortReason",{enumerable:!0,get:function(){return o.AbortReason}});var i=e("./types.cjs");Object.defineProperty(s,"StatusTypes",{enumerable:!0,get:function(){return i.StatusTypes}});var c=e("./types.cjs");Object.defineProperty(s,"AssetType",{enumerable:!0,get:function(){return c.AssetType}}),Object.defineProperty(s,"SortOrder",{enumerable:!0,get:function(){return c.SortOrder}}),Object.defineProperty(s,"ChainId",{enumerable:!0,get:function(){return c.ChainId}}),Object.defineProperty(s,"RequestStatus",{enumerable:!0,get:function(){return c.RequestStatus}}),Object.defineProperty(s,"BridgeUserAction",{enumerable:!0,get:function(){return c.BridgeUserAction}}),Object.defineProperty(s,"BridgeBackgroundAction",{enumerable:!0,get:function(){return c.BridgeBackgroundAction}});var l=e("./utils/validators.cjs");Object.defineProperty(s,"FeeType",{enumerable:!0,get:function(){return l.FeeType}}),Object.defineProperty(s,"ActionTypes",{enumerable:!0,get:function(){return l.ActionTypes}}),Object.defineProperty(s,"BridgeAssetSchema",{enumerable:!0,get:function(){return l.BridgeAssetSchema}}),Object.defineProperty(s,"FeatureId",{enumerable:!0,get:function(){return l.FeatureId}}),Object.defineProperty(s,"TokenFeatureType",{enumerable:!0,get:function(){return l.TokenFeatureType}});var d=e("./constants/bridge.cjs");Object.defineProperty(s,"ALLOWED_BRIDGE_CHAIN_IDS",{enumerable:!0,get:function(){return d.ALLOWED_BRIDGE_CHAIN_IDS}}),Object.defineProperty(s,"BridgeClientId",{enumerable:!0,get:function(){return d.BridgeClientId}}),Object.defineProperty(s,"BRIDGE_CONTROLLER_NAME",{enumerable:!0,get:function(){return d.BRIDGE_CONTROLLER_NAME}}),Object.defineProperty(s,"BRIDGE_QUOTE_MAX_ETA_SECONDS",{enumerable:!0,get:function(){return d.BRIDGE_QUOTE_MAX_ETA_SECONDS}}),Object.defineProperty(s,"BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE",{enumerable:!0,get:function(){return d.BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE}}),Object.defineProperty(s,"BRIDGE_PREFERRED_GAS_ESTIMATE",{enumerable:!0,get:function(){return d.BRIDGE_PREFERRED_GAS_ESTIMATE}}),Object.defineProperty(s,"BRIDGE_MM_FEE_RATE",{enumerable:!0,get:function(){return d.BRIDGE_MM_FEE_RATE}}),Object.defineProperty(s,"REFRESH_INTERVAL_MS",{enumerable:!0,get:function(){return d.REFRESH_INTERVAL_MS}}),Object.defineProperty(s,"DEFAULT_MAX_REFRESH_COUNT",{enumerable:!0,get:function(){return d.DEFAULT_MAX_REFRESH_COUNT}}),Object.defineProperty(s,"DEFAULT_BRIDGE_CONTROLLER_STATE",{enumerable:!0,get:function(){return d.DEFAULT_BRIDGE_CONTROLLER_STATE}}),Object.defineProperty(s,"METABRIDGE_CHAIN_TO_ADDRESS_MAP",{enumerable:!0,get:function(){return d.METABRIDGE_CHAIN_TO_ADDRESS_MAP}}),Object.defineProperty(s,"BRIDGE_DEV_API_BASE_URL",{enumerable:!0,get:function(){return d.BRIDGE_DEV_API_BASE_URL}}),Object.defineProperty(s,"BRIDGE_PROD_API_BASE_URL",{enumerable:!0,get:function(){return d.BRIDGE_PROD_API_BASE_URL}});var m=e("./constants/tokens.cjs");Object.defineProperty(s,"SWAPS_CHAINID_DEFAULT_TOKEN_MAP",{enumerable:!0,get:function(){return m.SWAPS_CHAINID_DEFAULT_TOKEN_MAP}});var u=e("./constants/swaps.cjs");Object.defineProperty(s,"SWAPS_API_V2_BASE_URL",{enumerable:!0,get:function(){return u.SWAPS_API_V2_BASE_URL}}),Object.defineProperty(s,"SWAPS_CONTRACT_ADDRESSES",{enumerable:!0,get:function(){return u.SWAPS_CONTRACT_ADDRESSES}}),Object.defineProperty(s,"SWAPS_WRAPPED_TOKENS_ADDRESSES",{enumerable:!0,get:function(){return u.SWAPS_WRAPPED_TOKENS_ADDRESSES}}),Object.defineProperty(s,"ALLOWED_CONTRACT_ADDRESSES",{enumerable:!0,get:function(){return u.ALLOWED_CONTRACT_ADDRESSES}});var h=e("./utils/metrics/constants.cjs");Object.defineProperty(s,"MetricsActionType",{enumerable:!0,get:function(){return h.MetricsActionType}}),Object.defineProperty(s,"MetricsSwapType",{enumerable:!0,get:function(){return h.MetricsSwapType}});var f=e("./utils/bridge.cjs");Object.defineProperty(s,"isEthUsdt",{enumerable:!0,get:function(){return f.isEthUsdt}}),Object.defineProperty(s,"isNativeAddress",{enumerable:!0,get:function(){return f.isNativeAddress}}),Object.defineProperty(s,"isSolanaChainId",{enumerable:!0,get:function(){return f.isSolanaChainId}}),Object.defineProperty(s,"isBitcoinChainId",{enumerable:!0,get:function(){return f.isBitcoinChainId}}),Object.defineProperty(s,"isTronChainId",{enumerable:!0,get:function(){return f.isTronChainId}}),Object.defineProperty(s,"isNonEvmChainId",{enumerable:!0,get:function(){return f.isNonEvmChainId}}),Object.defineProperty(s,"getNativeAssetForChainId",{enumerable:!0,get:function(){return f.getNativeAssetForChainId}}),Object.defineProperty(s,"getDefaultBridgeControllerState",{enumerable:!0,get:function(){return f.getDefaultBridgeControllerState}}),Object.defineProperty(s,"isCrossChain",{enumerable:!0,get:function(){return f.isCrossChain}});var p=e("./utils/quote.cjs");Object.defineProperty(s,"isValidQuoteRequest",{enumerable:!0,get:function(){return p.isValidQuoteRequest}}),Object.defineProperty(s,"formatEtaInMinutes",{enumerable:!0,get:function(){return p.formatEtaInMinutes}}),Object.defineProperty(s,"calcSlippagePercentage",{enumerable:!0,get:function(){return p.calcSlippagePercentage}});var g=e("./utils/balance.cjs");Object.defineProperty(s,"calcLatestSrcBalance",{enumerable:!0,get:function(){return g.calcLatestSrcBalance}});var k=e("./utils/fetch.cjs");Object.defineProperty(s,"fetchBridgeTokens",{enumerable:!0,get:function(){return k.fetchBridgeTokens}}),Object.defineProperty(s,"getClientHeaders",{enumerable:!0,get:function(){return k.getClientHeaders}});var b=e("./utils/caip-formatters.cjs");Object.defineProperty(s,"formatChainIdToCaip",{enumerable:!0,get:function(){return b.formatChainIdToCaip}}),Object.defineProperty(s,"formatChainIdToHex",{enumerable:!0,get:function(){return b.formatChainIdToHex}}),Object.defineProperty(s,"formatAddressToCaipReference",{enumerable:!0,get:function(){return b.formatAddressToCaipReference}}),Object.defineProperty(s,"formatAddressToAssetId",{enumerable:!0,get:function(){return b.formatAddressToAssetId}});var w=e("./utils/trade-utils.cjs");Object.defineProperty(s,"extractTradeData",{enumerable:!0,get:function(){return w.extractTradeData}}),Object.defineProperty(s,"isBitcoinTrade",{enumerable:!0,get:function(){return w.isBitcoinTrade}}),Object.defineProperty(s,"isTronTrade",{enumerable:!0,get:function(){return w.isTronTrade}}),Object.defineProperty(s,"isEvmTxData",{enumerable:!0,get:function(){return w.isEvmTxData}});var _=e("./selectors.cjs");Object.defineProperty(s,"selectBridgeQuotes",{enumerable:!0,get:function(){return _.selectBridgeQuotes}}),Object.defineProperty(s,"selectDefaultSlippagePercentage",{enumerable:!0,get:function(){return _.selectDefaultSlippagePercentage}}),Object.defineProperty(s,"selectExchangeRateByChainIdAndAddress",{enumerable:!0,get:function(){return _.selectExchangeRateByChainIdAndAddress}}),Object.defineProperty(s,"selectIsQuoteExpired",{enumerable:!0,get:function(){return _.selectIsQuoteExpired}}),Object.defineProperty(s,"selectBridgeFeatureFlags",{enumerable:!0,get:function(){return _.selectBridgeFeatureFlags}}),Object.defineProperty(s,"selectMinimumBalanceForRentExemptionInSOL",{enumerable:!0,get:function(){return _.selectMinimumBalanceForRentExemptionInSOL}}),Object.defineProperty(s,"selectTokenWarnings",{enumerable:!0,get:function(){return _.selectTokenWarnings}});var T=e("./constants/bridge.cjs");Object.defineProperty(s,"DEFAULT_FEATURE_FLAG_CONFIG",{enumerable:!0,get:function(){return T.DEFAULT_FEATURE_FLAG_CONFIG}});var E=e("./utils/feature-flags.cjs");Object.defineProperty(s,"getBridgeFeatureFlags",{enumerable:!0,get:function(){return E.getBridgeFeatureFlags}});var I=e("./utils/slippage.cjs");Object.defineProperty(s,"BRIDGE_DEFAULT_SLIPPAGE",{enumerable:!0,get:function(){return I.BRIDGE_DEFAULT_SLIPPAGE}});var S=e("./utils/swaps.cjs");Object.defineProperty(s,"isValidSwapsContractAddress",{enumerable:!0,get:function(){return S.isValidSwapsContractAddress}}),Object.defineProperty(s,"getSwapsContractAddress",{enumerable:!0,get:function(){return S.getSwapsContractAddress}}),Object.defineProperty(s,"fetchTokens",{enumerable:!0,get:function(){return S.fetchTokens}})}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/selectors.cjs",{"./constants/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs","./utils/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","./utils/caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","./utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/feature-flags.cjs","./utils/quote.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote.cjs","./utils/slippage.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/slippage.cjs","@ethersproject/constants":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/constants/lib/index.js","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js",reselect:"/home/runner/work/metamask-extension/metamask-extension/node_modules/reselect/dist/cjs/reselect.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.selectDefaultSlippagePercentage=s.selectTokenWarnings=s.selectMinimumBalanceForRentExemptionInSOL=s.selectBridgeQuotes=s.selectIsQuoteExpired=s.selectIsAssetExchangeRateInState=s.selectExchangeRateByChainIdAndAddress=s.selectBridgeFeatureFlags=void 0;const a=e("@ethersproject/constants"),n=e("@metamask/utils"),r=e("bignumber.js"),o=e("lodash"),i=e("reselect"),c=e("./constants/bridge.cjs"),l=e("./types.cjs"),d=e("./utils/bridge.cjs"),m=e("./utils/caip-formatters.cjs"),u=e("./utils/feature-flags.cjs"),h=e("./utils/quote.cjs"),f=e("./utils/slippage.cjs"),p=i.createStructuredSelector.withTypes(),g=i.createSelector.withTypes(),k=i.createSelector.withTypes();s.selectBridgeFeatureFlags=k([e=>e.remoteFeatureFlags.bridgeConfig],e=>(0,u.processFeatureFlags)(e));const b=(e,t,s)=>{if(!t)return{};const a=(0,m.formatAddressToCaipReference)(s??""),o=(0,m.formatAddressToAssetId)(a,t);if(!o)return{};const{assetExchangeRates:i,currencyRates:c,marketData:l,conversionRates:u}=e,h=i?.[o.toLowerCase()]??i?.[o];if(h?.exchangeRate&&h?.usdExchangeRate)return h;if((0,d.isNonEvmChainId)(t)){const e=u,t=e?.[o],s=t?.rate;if(s){const e=Object.values(c??{}).find(e=>e?.conversionRate!==undefined&&null!==e?.conversionRate&&e?.usdConversionRate!==undefined&&null!==e?.usdConversionRate),t=e?.conversionRate!==undefined&&null!==e?.conversionRate&&e?.usdConversionRate!==undefined&&null!==e?.usdConversionRate?new r.BigNumber(e.usdConversionRate).div(e.conversionRate):undefined;return{exchangeRate:s,usdExchangeRate:t?new r.BigNumber(s).times(t).toString():undefined}}return{}}if((0,d.isNativeAddress)(a)){const{symbol:e}=(0,d.getNativeAssetForChainId)(t),s=c?.[e];return s?{exchangeRate:s.conversionRate?.toString(),usdExchangeRate:s.usdConversionRate?.toString()}:{}}if(!(0,d.isNonEvmChainId)(t)){const e=(l??{})[(0,m.formatChainIdToHex)(t)],s=(0,n.isStrictHexString)(a)?e?.[a]:null,o=s?.currency,i=o!==undefined&&null!==o?c?.[o]:undefined,d=s?.price??0;if(s&&i)return{exchangeRate:new r.BigNumber(d).multipliedBy(i.conversionRate??0).toString(),usdExchangeRate:new r.BigNumber(d).multipliedBy(i.usdConversionRate??0).toString()}}return{}};s.selectExchangeRateByChainIdAndAddress=(e,t,s)=>b(e,t,s);s.selectIsAssetExchangeRateInState=(...e)=>Boolean(b(...e)?.exchangeRate)&&Boolean(b(...e)?.usdExchangeRate);const w=g([e=>e.gasFeeEstimatesByChainId,e=>e.quotes?.[0]?.quote.srcChainId],(e,t)=>{if(!t)return null;if((0,d.isNonEvmChainId)(t))return null;const s=e?.[(0,m.formatChainIdToHex)(t)]?.gasFeeEstimates;return s?{estimatedBaseFeeInDecGwei:s.estimatedBaseFee,feePerGasInDecGwei:s[c.BRIDGE_PREFERRED_GAS_ESTIMATE]?.suggestedMaxFeePerGas,maxFeePerGasInDecGwei:s.high?.suggestedMaxFeePerGas}:null}),_=g([({quotes:e})=>e,w,g([e=>e,({quoteRequest:{srcChainId:e}})=>e,({quoteRequest:{srcTokenAddress:e}})=>e],s.selectExchangeRateByChainIdAndAddress),g([e=>e,({quoteRequest:{destChainId:e}})=>e,({quoteRequest:{destTokenAddress:e}})=>e],s.selectExchangeRateByChainIdAndAddress),g([e=>e,({quoteRequest:{srcChainId:e}})=>e],(e,t)=>(0,s.selectExchangeRateByChainIdAndAddress)(e,t,a.AddressZero))],(e,t,s,a,n)=>e.map(e=>{const r=(0,h.calcSentAmount)(e.quote,s),o=(0,h.calcToAmount)(e.quote.destTokenAmount,e.quote.destAsset,a),i=(0,h.calcToAmount)(e.quote.minDestTokenAmount,e.quote.destAsset,a),c=(0,h.calcIncludedTxFees)(e.quote,s,a);let l,m,u,f;(0,d.isEvmQuoteResponse)(e)?(u=(0,h.calcRelayerFee)(e,n),f=(0,h.calcEstimatedAndMaxTotalGasFee)({bridgeQuote:e,...t,...n}),l=(0,h.calcTotalEstimatedNetworkFee)(f,u),m=(0,h.calcTotalMaxNetworkFee)(f,u)):(l=(0,h.calcNonEvmTotalNetworkFee)(e,n),f={effective:l,total:l,max:l},m=l);const p=(0,h.calcAdjustedReturn)(o,l,e.quote),g=(0,h.calcCost)(p,r);return{...e,sentAmount:r,toTokenAmount:o,minToTokenAmount:i,swapRate:(0,h.calcSwapRate)(r.amount,o.amount),totalNetworkFee:l,totalMaxNetworkFee:m,gasFee:f,adjustedReturn:p,cost:g,includedTxFees:c}})),T=g([_,(e,{sortOrder:t})=>t],(e,t)=>t===l.SortOrder.ETA_ASC?(0,o.orderBy)(e,e=>e.estimatedProcessingTimeInSeconds,"asc"):e.every(e=>e.cost.valueInCurrency)?(0,o.orderBy)(e,({cost:e})=>Number(e.valueInCurrency),"asc"):e.every(e=>e.quote.priceData?.priceImpact)?(0,o.orderBy)(e,({quote:e})=>Number(e.priceData?.priceImpact),"asc"):(0,o.orderBy)(e,({quote:e})=>Number(e.destTokenAmount),"desc")),E=g([T],e=>e.length>0?e[0]:null),I=g([E,T,(e,{selectedQuote:t})=>t],(e,t,s)=>t.find(e=>e.quote.requestId===s?.quote.requestId)??e),S=g([s.selectBridgeFeatureFlags,e=>e.quoteRequest.insufficientBal,e=>e.quotesRefreshCount],(e,t,s)=>!t&&e.maxRefreshCount>s),x=g([s.selectBridgeFeatureFlags,e=>e.quoteRequest.srcChainId],(e,t)=>(t?e.chains[(0,m.formatChainIdToCaip)(t)]?.refreshRate:e.refreshRate)??e.refreshRate);s.selectIsQuoteExpired=g([S,({quotesLastFetched:e})=>e,x,(e,t,s)=>s],(e,t,s,a)=>Boolean(!e&&t&&a-t>s)),s.selectBridgeQuotes=p({sortedQuotes:T,recommendedQuote:E,activeQuote:I,quotesLastFetchedMs:e=>e.quotesLastFetched,isLoading:e=>e.quotesLoadingStatus===l.RequestStatus.LOADING,quoteFetchError:e=>e.quoteFetchError,quotesRefreshCount:e=>e.quotesRefreshCount,quotesInitialLoadTimeMs:e=>e.quotesInitialLoadTime,isQuoteGoingToRefresh:S});s.selectMinimumBalanceForRentExemptionInSOL=e=>new r.BigNumber(e.minimumBalanceForRentExemptionInLamports??0).div(10**9).toString();s.selectTokenWarnings=e=>e.tokenWarnings,s.selectDefaultSlippagePercentage=g([e=>(0,s.selectBridgeFeatureFlags)(e).chains,(e,t)=>t.srcTokenAddress,(e,t)=>t.destTokenAddress,(e,t)=>t.srcChainId?(0,m.formatChainIdToCaip)(t.srcChainId):undefined,(e,t)=>t.destChainId?(0,m.formatChainIdToCaip)(t.destChainId):undefined],(e,t,s,a,n)=>(0,f.getDefaultSlippagePercentage)({srcTokenAddress:t,destTokenAddress:s,srcChainId:a,destChainId:n},a?e[a]?.stablecoins:undefined,n?e[n]?.stablecoins:undefined))}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/selectors.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l;Object.defineProperty(s,"__esModule",{value:!0}),s.BridgeBackgroundAction=s.BridgeUserAction=s.RequestStatus=s.ChainId=s.StatusTypes=s.SortOrder=s.AssetType=void 0,function(e){e.native="NATIVE",e.token="TOKEN",e.NFT="NFT",e.unknown="UNKNOWN"}(a||(s.AssetType=a={})),function(e){e.COST_ASC="cost_ascending",e.ETA_ASC="time_descending"}(n||(s.SortOrder=n={})),function(e){e.SUBMITTED="SUBMITTED",e.UNKNOWN="UNKNOWN",e.FAILED="FAILED",e.PENDING="PENDING",e.COMPLETE="COMPLETE"}(r||(s.StatusTypes=r={})),function(e){e[e.ETH=1]="ETH",e[e.OPTIMISM=10]="OPTIMISM",e[e.BSC=56]="BSC",e[e.POLYGON=137]="POLYGON",e[e.ZKSYNC=324]="ZKSYNC",e[e.BASE=8453]="BASE",e[e.ARBITRUM=42161]="ARBITRUM",e[e.AVALANCHE=43114]="AVALANCHE",e[e.LINEA=59144]="LINEA",e[e.SOLANA=0x416edef1601be]="SOLANA",e[e.BTC=20000000000001]="BTC",e[e.TRON=728126428]="TRON",e[e.SEI=1329]="SEI",e[e.MONAD=143]="MONAD",e[e.HYPEREVM=999]="HYPEREVM",e[e.MEGAETH=4326]="MEGAETH"}(o||(s.ChainId=o={})),function(e){e[e.LOADING=0]="LOADING",e[e.FETCHED=1]="FETCHED",e[e.ERROR=2]="ERROR"}(i||(s.RequestStatus=i={})),function(e){e.SELECT_DEST_NETWORK="selectDestNetwork",e.UPDATE_QUOTE_PARAMS="updateBridgeQuoteRequestParams"}(c||(s.BridgeUserAction=c={})),function(e){e.SET_CHAIN_INTERVAL_LENGTH="setChainIntervalLength",e.RESET_STATE="resetState",e.TRACK_METAMETRICS_EVENT="trackUnifiedSwapBridgeEvent",e.STOP_POLLING_FOR_QUOTES="stopPollingForQuotes",e.FETCH_QUOTES="fetchQuotes"}(l||(s.BridgeBackgroundAction=l={}))}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/assets.cjs",{"./bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","./caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.toExchangeRates=s.getAssetIdsForToken=void 0;const a=e("./bridge.cjs"),n=e("./caip-formatters.cjs");s.getAssetIdsForToken=(e,t)=>{const s=[],r=(0,n.formatAddressToAssetId)(e,t);return r&&(s.push(r),(0,a.getNativeAssetForChainId)(t)?.assetId&&s.push((0,a.getNativeAssetForChainId)(t).assetId)),s};s.toExchangeRates=(e,t)=>Object.entries(t).reduce((t,[s,a])=>(a&&(t[s]={exchangeRate:a[e],usdExchangeRate:a.usd}),t),{})}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/assets.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/balance.cjs",{"./bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","@ethersproject/address":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/address/lib/index.js","@ethersproject/contracts":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/contracts/lib/index.js","@ethersproject/providers":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/providers/lib/index.js","@metamask/metamask-eth-abis":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/metamask-eth-abis/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.hasSufficientBalance=s.calcLatestSrcBalance=s.fetchTokenBalance=void 0;const a=e("@ethersproject/address"),n=e("@ethersproject/contracts"),r=e("@ethersproject/providers"),o=e("@metamask/metamask-eth-abis"),i=e("./bridge.cjs");s.fetchTokenBalance=async(e,t,s)=>{const a=new r.Web3Provider(s),i=new n.Contract(e,o.abiERC20,a),c="function"==typeof i?.balanceOf?i.balanceOf(t):Promise.resolve(undefined);return await c};s.calcLatestSrcBalance=async(e,t,n,o)=>{if(n&&o){if((0,i.isNativeAddress)(n)){const s=new r.Web3Provider(e);return await s.getBalance((0,a.getAddress)(t))}return await(0,s.fetchTokenBalance)(n,t,e)}return undefined};s.hasSufficientBalance=async(e,t,a,n,r)=>{const o=await(0,s.calcLatestSrcBalance)(e,t,a,r);return!!o&&o.gte(n)}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/balance.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs",{"../constants/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs","../constants/chains.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs","../constants/swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/swaps.cjs","../constants/tokens.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/tokens.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs","./caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","@ethersproject/constants":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/constants/lib/index.js","@ethersproject/contracts":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/contracts/lib/index.js","@metamask/keyring-api":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-api/dist/index.cjs","@metamask/metamask-eth-abis":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/metamask-eth-abis/dist/index.js","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.isEvmQuoteResponse=s.isNonEvmChainId=s.isTronChainId=s.isBitcoinChainId=s.isSolanaChainId=s.isNativeAddress=s.isSwapsDefaultTokenSymbol=s.isSwapsDefaultTokenAddress=s.sumHexes=s.isEthUsdt=s.getEthUsdtResetData=s.getNativeAssetForChainId=s.getDefaultBridgeControllerState=s.isCrossChain=void 0;const a=e("@ethersproject/constants"),n=e("@ethersproject/contracts"),r=e("@metamask/keyring-api"),o=e("@metamask/metamask-eth-abis"),i=e("@metamask/utils"),c=e("./caip-formatters.cjs"),l=e("../constants/bridge.cjs"),d=e("../constants/chains.cjs"),m=e("../constants/swaps.cjs"),u=e("../constants/tokens.cjs"),h=e("../types.cjs");s.isCrossChain=(e,t)=>{try{return!!t&&(0,c.formatChainIdToCaip)(e)!==(0,c.formatChainIdToCaip)(t)}catch{return!1}};s.getDefaultBridgeControllerState=()=>l.DEFAULT_BRIDGE_CONTROLLER_STATE;const f=(e,t)=>`${(0,c.formatChainIdToCaip)(e)}/${u.SYMBOL_TO_SLIP44_MAP[t]}`;s.getNativeAssetForChainId=e=>{const t=(0,c.formatChainIdToCaip)(e),s=u.SWAPS_CHAINID_DEFAULT_TOKEN_MAP[(0,c.formatChainIdToCaip)(e)]??u.SWAPS_CHAINID_DEFAULT_TOKEN_MAP[(0,c.formatChainIdToHex)(e)];if(!s)throw new Error(`No XChain Swaps native asset found for chainId: ${e}`);return{...s,chainId:(0,c.formatChainIdToDec)(e),assetId:f(t,s.symbol)}};s.getEthUsdtResetData=e=>{const t=(0,s.isCrossChain)(d.CHAIN_IDS.MAINNET,e)?l.METABRIDGE_ETHEREUM_ADDRESS:m.SWAPS_CONTRACT_ADDRESSES[d.CHAIN_IDS.MAINNET];return new n.Contract(l.ETH_USDT_ADDRESS,o.abiERC20).interface.encodeFunctionData("approve",[t,"0"])};s.isEthUsdt=(e,t)=>(0,c.formatChainIdToDec)(e)===h.ChainId.ETH&&t.toLowerCase()===l.ETH_USDT_ADDRESS.toLowerCase();s.sumHexes=(...e)=>{if(0===e.length)return"0x0";return`0x${e.reduce((e,t)=>e+BigInt(t),BigInt(0)).toString(16)}`};s.isSwapsDefaultTokenAddress=(e,t)=>!(!e||!t)&&e===(0,s.getNativeAssetForChainId)(t)?.address;s.isSwapsDefaultTokenSymbol=(e,t)=>!(!e||!t)&&e===(0,s.getNativeAssetForChainId)(t)?.symbol;s.isNativeAddress=e=>e===a.AddressZero||""===e||!e||!(0,i.isStrictHexString)(e)&&Object.values(u.SYMBOL_TO_SLIP44_MAP).some(t=>e.includes(t)||t.endsWith(e));s.isSolanaChainId=e=>(0,i.isCaipChainId)(e)?e===r.SolScope.Mainnet.toString():e.toString()===h.ChainId.SOLANA.toString();s.isBitcoinChainId=e=>(0,i.isCaipChainId)(e)?e===r.BtcScope.Mainnet.toString():e.toString()===h.ChainId.BTC.toString();s.isTronChainId=e=>(0,i.isCaipChainId)(e)?e===r.TrxScope.Mainnet.toString():e.toString()===h.ChainId.TRON.toString();s.isNonEvmChainId=e=>(0,s.isSolanaChainId)(e)||(0,s.isBitcoinChainId)(e)||(0,s.isTronChainId)(e);s.isEvmQuoteResponse=e=>!(0,s.isNonEvmChainId)(e.quote.srcChainId)}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs","./bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","@ethersproject/address":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/address/lib/index.js","@ethersproject/constants":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/constants/lib/index.js","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/keyring-api":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-api/dist/index.cjs","@metamask/multichain-network-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/multichain-network-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.formatAddressToAssetId=s.formatAddressToCaipReference=s.formatChainIdToHex=s.formatChainIdToDec=s.formatChainIdToCaip=void 0;const a=e("@ethersproject/address"),n=e("@ethersproject/constants"),r=e("@metamask/controller-utils"),o=e("@metamask/keyring-api"),i=e("@metamask/multichain-network-controller"),c=e("@metamask/utils"),l=e("./bridge.cjs"),d=e("../types.cjs");s.formatChainIdToCaip=e=>(0,c.isCaipChainId)(e)?e:(0,c.isStrictHexString)(e)?(0,i.toEvmCaipChainId)(e):(0,l.isSolanaChainId)(e)?o.SolScope.Mainnet:(0,l.isBitcoinChainId)(e)?o.BtcScope.Mainnet:(0,l.isTronChainId)(e)?o.TrxScope.Mainnet:(0,i.toEvmCaipChainId)((0,c.numberToHex)(Number(e)));s.formatChainIdToDec=e=>(0,c.isStrictHexString)(e)?(0,r.convertHexToDecimal)(e):e===o.SolScope.Mainnet?d.ChainId.SOLANA:e===o.BtcScope.Mainnet?d.ChainId.BTC:e===o.TrxScope.Mainnet?d.ChainId.TRON:(0,c.isCaipChainId)(e)?Number(e.split(":").at(-1)):"string"==typeof e?parseInt(e,10):e;s.formatChainIdToHex=e=>{if((0,c.isStrictHexString)(e))return e;if("number"==typeof e||parseInt(e,10))return(0,c.numberToHex)(Number(e));if((0,c.isCaipChainId)(e)){const{reference:t}=(0,c.parseCaipChainId)(e);if((0,c.isCaipReference)(t)&&!isNaN(Number(t)))return(0,c.numberToHex)(Number(t))}throw new Error(`Invalid cross-chain swaps chainId: ${e}`)};s.formatAddressToCaipReference=e=>{if((0,c.isStrictHexString)(e))return(0,a.getAddress)(e);if((0,l.isNativeAddress)(e))return n.AddressZero;const t=e.split(":").at(-1);if(!t)throw new Error("Invalid address");return t};s.formatAddressToAssetId=(e,t)=>{if((0,c.isCaipAssetType)(e))return e;if(!t)return undefined;const a=(0,s.formatChainIdToCaip)(t);if((0,l.isNativeAddress)(e))return(0,l.getNativeAssetForChainId)(a).assetId;if(a===o.SolScope.Mainnet)return c.CaipAssetTypeStruct.create(`${a}/token:${e}`);if(a===o.TrxScope.Mainnet)return c.CaipAssetTypeStruct.create(`${a}/trc20:${e}`);if(!(0,c.isStrictHexString)(e))return undefined;const n=(0,r.toChecksumHexAddress)(e);return c.CaipAssetTypeStruct.create(`${a}/erc20:${n}`)}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/feature-flags.cjs",{"../constants/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs","./caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","./validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/validators.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.hasMinimumRequiredVersion=s.getBridgeFeatureFlags=s.processFeatureFlags=s.formatFeatureFlags=void 0;const a=e("./caip-formatters.cjs"),n=e("./validators.cjs"),r=e("../constants/bridge.cjs");s.formatFeatureFlags=e=>{return{...e,chains:(t=e.chains,Object.entries(t).reduce((e,[t,s])=>({...e,[(0,a.formatChainIdToCaip)(t)]:s}),{}))};var t};s.processFeatureFlags=e=>{if((0,n.validateFeatureFlagsResponse)(e)){const t=(0,s.formatFeatureFlags)(e);return t.chainRanking&&0!==t.chainRanking.length?t:{...t,chainRanking:[...r.DEFAULT_CHAIN_RANKING]}}return r.DEFAULT_FEATURE_FLAG_CONFIG},s.getBridgeFeatureFlags=function(e){const t=e.call("RemoteFeatureFlagController:getState"),a=t?.remoteFeatureFlags?.bridgeConfigV2,n=t?.remoteFeatureFlags?.bridgeConfig;return(0,s.processFeatureFlags)(a||n)};s.hasMinimumRequiredVersion=(e,t)=>{const[s,a,n]=e.split(".").map(Number),[r,o,i]=t.split(".").map(Number);return s>r||(s===r&&a>o||s===r&&a===o&&n>=i)}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/feature-flags.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/fetch-server-events.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.fetchServerEvents=void 0;s.fetchServerEvents=async(e,{onMessage:t,onError:s,onClose:a,fetchFn:n,...r})=>{let o;try{const s=await n(e,r);if(!s.ok||!s.body)throw new Error(`${s.status}`);o=s.body.getReader();const i=new TextDecoder("utf-8");let c="";for(;;){const{done:e,value:s}=await o.read();if(e)break;c+=i.decode(s,{stream:!0});const a=c.split("\n\n");c=a.pop()||"";for(const e of a){const s=e.split("\n");let a;const n=[];for(const e of s)e.startsWith("event:")?a=e.slice(6).trim():e.startsWith("data:")&&n.push(e.slice(5).trim());if("error"===a)throw new Error(`Bridge-api error: ${n.join("\n")}`);if(n.length>0){const e=JSON.parse(n.join("\n"));await t(e,a)}}}await(a?.())}catch(e){s?.(e)}finally{try{await(o?.cancel())}catch(e){console.error("Error cleaning up stream reader",e)}}}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/fetch-server-events.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/fetch.cjs",{"./bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","./caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","./fetch-server-events.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/fetch-server-events.cjs","./trade-utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/trade-utils.cjs","./validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/validators.cjs","@metamask/superstruct":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/superstruct/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.fetchBridgeQuoteStream=s.fetchAssetPrices=s.fetchBridgeQuotes=s.fetchBridgeTokens=s.getClientHeaders=void 0;const a=e("@metamask/superstruct"),n=e("./bridge.cjs"),r=e("./caip-formatters.cjs"),o=e("./fetch-server-events.cjs"),i=e("./trade-utils.cjs"),c=e("./validators.cjs");s.getClientHeaders=({clientId:e,clientVersion:t,jwt:s})=>({"X-Client-Id":e,...s?{Authorization:`Bearer ${s}`}:{},...t?{"Client-Version":t}:{}}),s.fetchBridgeTokens=async function(e,t,a,n,o,i){const l=`${o}/getTokens?chainId=${(0,r.formatChainIdToDec)(e)}`,d=await n(l,{headers:(0,s.getClientHeaders)({clientId:t,clientVersion:i,jwt:a})}),m={};return d.forEach(e=>{(0,c.validateSwapsTokenObject)(e)&&(m[e.address]=e)}),m};const l=e=>{const t=e.destWalletAddress??e.walletAddress,s={walletAddress:(0,r.formatAddressToCaipReference)(e.walletAddress),destWalletAddress:(0,r.formatAddressToCaipReference)(t),srcChainId:(0,r.formatChainIdToDec)(e.srcChainId),destChainId:(0,r.formatChainIdToDec)(e.destChainId),srcTokenAddress:(0,r.formatAddressToCaipReference)(e.srcTokenAddress),destTokenAddress:(0,r.formatAddressToCaipReference)(e.destTokenAddress),srcTokenAmount:e.srcTokenAmount,insufficientBal:Boolean(e.insufficientBal),resetApproval:Boolean(e.resetApproval),gasIncluded:Boolean(e.gasIncluded),gasIncluded7702:Boolean(e.gasIncluded7702)};e.slippage!==undefined&&(s.slippage=e.slippage),e.fee!==undefined&&(s.fee=e.fee),e.aggIds&&e.aggIds.length>0&&(s.aggIds=e.aggIds),e.bridgeIds&&e.bridgeIds.length>0&&(s.bridgeIds=e.bridgeIds);const a=new URLSearchParams;return Object.entries(s).forEach(([e,t])=>{a.append(e,t.toString())}),a};s.fetchBridgeQuotes=async function(e,t,r,o,d,m,u,h){const f=`${m}/getQuote?${l(e)}`,p=await d(f,{headers:(0,s.getClientHeaders)({clientId:r,clientVersion:h,jwt:o}),signal:t}),g=new Set([]),k=p.filter(e=>{try{return(0,c.validateQuoteResponse)(e)}catch(t){return t instanceof a.StructError&&t.failures().forEach(({branch:t,path:s})=>{const a=t?.[0]?.quote?.bridgeId??t?.[0]?.quote?.bridges?.[0]??e?.quote?.bridgeId??e?.quote?.bridges?.[0]??"unknown",n=s?.join(".")||"unknown";g.add([a,n].join("|"))}),!1}}).map(t=>({...t,featureId:u??undefined,resetApproval:e.resetApproval&&t.approval&&(0,i.isEvmTxData)(t.approval)?{...t.approval,data:(0,n.getEthUsdtResetData)(e.destChainId)}:undefined})),b=Array.from(g);return g.size>0&&console.warn("Quote validation failed",b),{quotes:k,validationFailures:b}};s.fetchAssetPrices=async e=>{const{currencies:t,...a}=e,n=await Promise.allSettled(Array.from(t).map(async e=>await(async e=>{const{currency:t,assetIds:a,clientId:n,clientVersion:r,fetchFn:o,signal:i}=e,c=Array.from(a).filter(Boolean);if(0===c.length)return{};const l=`https://price.api.cx.metamask.io/v3/spot-prices?${new URLSearchParams({assetIds:c.filter(Boolean).join(","),vsCurrency:t})}`,d=await o(l,{headers:(0,s.getClientHeaders)({clientId:n,clientVersion:r}),signal:i});return d&&"object"==typeof d?Object.entries(d).reduce((e,[s,a])=>a?(e[s]||(e[s]={}),a[t]&&(e[s][t]=a[t].toString()),e):e,{}):{}})({...a,currency:e}))).then(e=>e.reduce((e,t)=>("fulfilled"===t.status&&Object.entries(t.value).forEach(([t,s])=>{e[t]||(e[t]={}),Object.entries(s).forEach(([s,a])=>{e[t][s]=a})}),e),{}));return n},s.fetchBridgeQuoteStream=async function(e,t,r,d,m,u,h,f){const p=l(t),g=`${u}/getQuoteStream?${p}`;await(0,o.fetchServerEvents)(g,{headers:{...(0,s.getClientHeaders)({clientId:d,clientVersion:f,jwt:m}),"Content-Type":"text/event-stream"},signal:r,onMessage:async(e,s)=>{switch(s){case"quote":return await(async e=>{const s=new Set([]);try{if((0,c.validateQuoteResponse)(e))return await h.onValidQuoteReceived({...e,resetApproval:t.resetApproval&&e.approval&&(0,i.isEvmTxData)(e.approval)?{...e.approval,data:(0,n.getEthUsdtResetData)(t.destChainId)}:undefined})}catch(t){t instanceof a.StructError&&t.failures().forEach(({branch:t,path:a})=>{const n=t?.[0]?.quote?.bridgeId??t?.[0]?.quote?.bridges?.[0]??e?.quote?.bridgeId??(e?.quote?.bridges?.[0]||"unknown"),r=a?.join(".")||"unknown";s.add([n,r].join("|"))});const n=Array.from(s);if(s.size>0)return console.warn("Quote validation failed",n),h.onQuoteValidationFailure(n);throw t}return undefined})(e);case"token_warning":return(e=>{try{(0,c.validateTokenFeature)(e)&&h.onTokenWarning(e)}catch(e){console.warn("Token warning validation failed",e)}})(e);default:return undefined}},onError:e=>{throw e},onClose:async()=>{await h.onClose()},fetchFn:e})}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/fetch.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/constants.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l;Object.defineProperty(s,"__esModule",{value:!0}),s.MetricsSwapType=s.MetricsActionType=s.InputAmountPreset=s.MetaMetricsSwapsEventSource=s.AbortReason=s.PollingStatus=s.UnifiedSwapBridgeEventName=s.UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY=void 0,s.UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY="Unified SwapBridge",function(e){e.ButtonClicked="Unified SwapBridge Button Clicked",e.PageViewed="Unified SwapBridge Page Viewed",e.InputChanged="Unified SwapBridge Input Changed",e.InputSourceDestinationSwitched="Unified SwapBridge Source Destination Switched",e.QuotesRequested="Unified SwapBridge Quotes Requested",e.QuotesReceived="Unified SwapBridge Quotes Received",e.QuotesError="Unified SwapBridge Quotes Error",e.Submitted="Unified SwapBridge Submitted",e.Completed="Unified SwapBridge Completed",e.Failed="Unified SwapBridge Failed",e.AllQuotesOpened="Unified SwapBridge All Quotes Opened",e.AllQuotesSorted="Unified SwapBridge All Quotes Sorted",e.QuoteSelected="Unified SwapBridge Quote Selected",e.AssetDetailTooltipClicked="Unified SwapBridge Asset Detail Tooltip Clicked",e.QuotesValidationFailed="Unified SwapBridge Quotes Failed Validation",e.StatusValidationFailed="Unified SwapBridge Status Failed Validation",e.AssetPickerOpened="Unified SwapBridge Asset Picker Opened",e.PollingStatusUpdated="Unified SwapBridge Polling Status Updated"}(a||(s.UnifiedSwapBridgeEventName=a={})),function(e){e.MaxPollingReached="max_polling_reached",e.ManuallyRestarted="manually_restarted"}(n||(s.PollingStatus=n={})),function(e){e.NewQuoteRequest="New Quote Request",e.QuoteRequestUpdated="Quote Request Updated",e.ResetState="Reset controller state",e.TransactionSubmitted="Transaction submitted"}(r||(s.AbortReason=r={})),function(e){e.MainView="Main View",e.TokenView="Token View",e.TrendingExplore="Trending Explore",e.Rewards="Rewards"}(o||(s.MetaMetricsSwapsEventSource=o={})),function(e){e.PERCENT_25="25%",e.PERCENT_50="50%",e.PERCENT_75="75%",e.PERCENT_90="90%",e.MAX="MAX"}(i||(s.InputAmountPreset=i={})),function(e){e.CROSSCHAIN_V1="crosschain-v1",e.SWAPBRIDGE_V1="swapbridge-v1"}(c||(s.MetricsActionType=c={})),function(e){e.SINGLE="single_chain",e.CROSSCHAIN="crosschain"}(l||(s.MetricsSwapType=l={}))}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/constants.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/properties.cjs",{"../../constants/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs","../../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/types.cjs","../bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","../caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/constants.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getQuotesReceivedProperties=s.isCustomSlippage=s.isHardwareWallet=s.getRequestParams=s.formatProviderLabel=s.getSwapTypeFromQuote=s.getSwapType=s.toInputChangedPropertyValue=s.toInputChangedPropertyKey=void 0;const a=e("./constants.cjs"),n=e("../../constants/bridge.cjs"),r=e("../../types.cjs"),o=e("../bridge.cjs"),i=e("../caip-formatters.cjs");s.toInputChangedPropertyKey={srcTokenAddress:"token_source",destTokenAddress:"token_destination",srcChainId:"chain_source",destChainId:"chain_destination",slippage:"slippage"},s.toInputChangedPropertyValue={srcTokenAddress:({srcTokenAddress:e,srcChainId:t})=>t?(0,i.formatAddressToAssetId)(e??"",t):undefined,destTokenAddress:({destTokenAddress:e,destChainId:t})=>t?(0,i.formatAddressToAssetId)(e??"",t):undefined,srcChainId:({srcChainId:e})=>e?(0,i.formatChainIdToCaip)(e):undefined,destChainId:({destChainId:e})=>e?(0,i.formatChainIdToCaip)(e):undefined,slippage:({slippage:e})=>e?Number(e):e};s.getSwapType=(e,t)=>e&&!(0,o.isCrossChain)(e,t??e)?a.MetricsSwapType.SINGLE:a.MetricsSwapType.CROSSCHAIN;s.getSwapTypeFromQuote=e=>(0,s.getSwapType)(e.srcChainId,e.destChainId);s.formatProviderLabel=({bridgeId:e,bridges:t})=>`${e}_${t[0]}`;s.getRequestParams=({srcChainId:e,destChainId:t,srcTokenAddress:s,destTokenAddress:a})=>{const n=(0,i.formatChainIdToCaip)(e??r.ChainId.ETH);return{chain_id_source:n,chain_id_destination:t?(0,i.formatChainIdToCaip)(t):null,token_address_source:s?(0,i.formatAddressToAssetId)(s,n)??(0,o.getNativeAssetForChainId)(n)?.assetId??null:(0,o.getNativeAssetForChainId)(n)?.assetId??null,token_address_destination:a?(0,i.formatAddressToAssetId)(a,t??n)??null:null}};s.isHardwareWallet=e=>e?.metadata?.keyring.type?.includes("Hardware")??!1;s.isCustomSlippage=e=>e!==n.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;s.getQuotesReceivedProperties=(e,t=[],a=!0,n,r)=>{const o=e?(0,s.formatProviderLabel)(e.quote):"_";return{can_submit:a,gas_included:Boolean(e?.quote?.gasIncluded),gas_included_7702:Boolean(e?.quote?.gasIncluded7702),quoted_time_minutes:e?.estimatedProcessingTimeInSeconds?e.estimatedProcessingTimeInSeconds/60:0,usd_quoted_gas:Number(e?.gasFee?.effective?.usd??0),usd_quoted_return:Number(e?.toTokenAmount?.usd??0),usd_balance_source:r??0,best_quote_provider:n?(0,s.formatProviderLabel)(n.quote):o,provider:o,warnings:t,price_impact:Number(e?.quote.priceData?.priceImpact??0)}}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/metrics/properties.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote-fees.cjs",{"../constants/chains.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs","./bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","./caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs","./snaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/snaps.cjs","./trade-utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/trade-utils.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.appendFeesToQuotes=void 0;const a=e("@metamask/utils"),n=e("./bridge.cjs"),r=e("./caip-formatters.cjs"),o=e("./snaps.cjs"),i=e("./trade-utils.cjs"),c=e("../constants/chains.cjs");s.appendFeesToQuotes=async(e,t,s,l)=>{const d=await(async(e,t)=>{if(e.some(({quote:e})=>{const t=(0,r.formatChainIdToCaip)(e.srcChainId);return![c.CHAIN_IDS.OPTIMISM,c.CHAIN_IDS.BASE].map(r.formatChainIdToCaip).includes(t)}))return undefined;const s=Promise.allSettled(e.map(async e=>{const{quote:s,trade:r,approval:o}=e,i=(0,a.numberToHex)(s.srcChainId),c=e=>({from:e.from,to:e.to,value:e.value,data:e.data,gasLimit:e.gasLimit?.toString()}),l=o?await t({transactionParams:c(o),chainId:i}):"0x0",d=await t({transactionParams:c(r),chainId:i});return l===undefined||d===undefined?undefined:{...e,l1GasFeesInHexWei:(0,n.sumHexes)(l,d)}}));return(await s).reduce((e,t)=>("fulfilled"===t.status&&t.value?e.push(t.value):"rejected"===t.status&&console.error("Error calculating L1 gas fees for quote",t.reason),e),[])})(e,s),m=await(async(e,t,s)=>{if(e.some(({quote:{srcChainId:e}})=>!(0,n.isNonEvmChainId)(e)))return undefined;const a=Promise.allSettled(e.map(async e=>{const{trade:a,quote:n}=e;if(!s?.metadata?.snap?.id||!a)return e;try{const c=(0,r.formatChainIdToCaip)(n.srcChainId),l=(0,i.extractTradeData)(a),d=(0,i.isTronTrade)(a)?{visible:a.visible,type:a.raw_data?.contract?.[0]?.type,feeLimit:a.raw_data?.fee_limit}:undefined,m=await t.call("SnapController:handleRequest",(0,o.computeFeeRequest)(s?.metadata?.snap?.id,l,s?.id,c,d)),u=m?.find(e=>"base"===e.type)||m?.find(e=>"priority"===e.type)||m?.[0],h=u?.asset?.amount||"0";return{...e,nonEvmFeesInNative:h}}catch(t){return console.error(`Failed to compute non-EVM fees for quote ${n.requestId}:`,t),{...e,nonEvmFeesInNative:undefined}}}));return(await a).reduce((e,t)=>("fulfilled"===t.status&&t.value&&e.push(t.value),e),[])})(e,t,l);return d??m??e}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote-fees.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote.cjs",{"./bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs","./validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/validators.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.sortQuotes=s.formatEtaInMinutes=s.calcSlippagePercentage=s.calcCost=s.calcSwapRate=s.calcAdjustedReturn=s.calcIncludedTxFees=s.calcTotalMaxNetworkFee=s.calcTotalEstimatedNetworkFee=s.calcEstimatedAndMaxTotalGasFee=s.calcRelayerFee=s.calcSentAmount=s.calcToAmount=s.calcNonEvmTotalNetworkFee=s.getQuoteIdentifier=s.isValidQuoteRequest=void 0;const a=e("@metamask/controller-utils"),n=e("bignumber.js"),r=e("./bridge.cjs"),o=e("./validators.cjs");s.isValidQuoteRequest=(e,t=!0)=>{const s=["srcTokenAddress","destTokenAddress","srcChainId","destChainId","walletAddress"];if(t&&s.push("srcTokenAmount"),e.destChainId&&e.srcChainId&&e.destChainId!==e.srcChainId&&((0,r.isNonEvmChainId)(e.destChainId)||(0,r.isNonEvmChainId)(e.srcChainId))&&(s.push("destWalletAddress"),!e.destWalletAddress))return!1;const a=[];return e.slippage!==undefined&&a.push("slippage"),s.every(t=>t in e&&"string"==typeof e[t]&&e[t]!==undefined&&""!==e[t]&&null!==e[t])&&a.every(t=>t in e&&"number"==typeof e[t]&&e[t]!==undefined&&!isNaN(Number(e[t]))&&null!==e[t])&&(!t||Boolean((e.srcTokenAmount??"").match(/^[1-9]\d*$/u)))};s.getQuoteIdentifier=e=>`${e.bridgeId}-${e.bridges[0]}-${e.steps.length}`;const i=(e,t)=>{const s=new n.BigNumber(10).pow(t??0);return new n.BigNumber(e).div(s)};s.calcNonEvmTotalNetworkFee=(e,{exchangeRate:t,usdExchangeRate:s})=>{const{nonEvmFeesInNative:a}=e,r=new n.BigNumber(a??"0");return{amount:r.toString(),valueInCurrency:t?r.times(t).toString():null,usd:s?r.times(s).toString():null}};s.calcToAmount=(e,t,{exchangeRate:s,usdExchangeRate:a})=>{const n=i(e,t.decimals);return{amount:n.toString(),valueInCurrency:s?n.times(s).toString():null,usd:a?n.times(a).toString():null}};s.calcSentAmount=({srcTokenAmount:e,srcAsset:t,feeData:s},{exchangeRate:a,usdExchangeRate:r})=>{const o=Object.values(s).filter(e=>e&&e.amount&&e.asset?.assetId===t.assetId).reduce((e,{amount:t})=>e.plus(t),new n.BigNumber(e)),c=i(o,t.decimals);return{amount:c.toString(),valueInCurrency:a?c.times(a).toString():null,usd:r?c.times(r).toString():null}};s.calcRelayerFee=(e,{exchangeRate:t,usdExchangeRate:o})=>{const{quote:c,trade:l}=e,d=new n.BigNumber((0,a.convertHexToDecimal)(l.value||"0x0"));let m=i(d,18);if((0,r.isNativeAddress)(c.srcAsset.address)){const e=(0,s.calcSentAmount)(c,{exchangeRate:t,usdExchangeRate:o}).amount;m=m.minus(e)}return{amount:m,valueInCurrency:t?m.times(t):null,usd:o?m.times(o):null}};const c=({approvalGasLimit:e,resetApprovalGasLimit:t,tradeGasLimit:s,l1GasFeesInHexWei:r,feePerGasInDecGwei:o,nativeToDisplayCurrencyExchangeRate:i,nativeToUsdExchangeRate:c})=>{const l=new n.BigNumber(s?.toString()??"0").plus(e?.toString()??"0").plus(t?.toString()??"0"),d=(0,a.weiHexToGweiDec)((0,a.toHex)(r??"0")),m=l.times(o??"0").plus(d).times(new n.BigNumber(10).pow(-9)),u=i?m.times(i.toString()):null,h=c?m.times(c.toString()):null;return{amount:m.toString(),valueInCurrency:u?.toString()??null,usd:h?.toString()??null}};s.calcEstimatedAndMaxTotalGasFee=({bridgeQuote:{approval:e,trade:t,l1GasFeesInHexWei:s,resetApproval:a},feePerGasInDecGwei:n,maxFeePerGasInDecGwei:r,exchangeRate:o,usdExchangeRate:i})=>{const{amount:l,valueInCurrency:d,usd:m}=c({approvalGasLimit:e?.effectiveGas??e?.gasLimit,resetApprovalGasLimit:a?.effectiveGas??a?.gasLimit,tradeGasLimit:t?.effectiveGas??t?.gasLimit,l1GasFeesInHexWei:s,feePerGasInDecGwei:n,nativeToDisplayCurrencyExchangeRate:o,nativeToUsdExchangeRate:i}),{amount:u,valueInCurrency:h,usd:f}=c({approvalGasLimit:e?.gasLimit,resetApprovalGasLimit:a?.gasLimit,tradeGasLimit:t?.gasLimit,l1GasFeesInHexWei:s,feePerGasInDecGwei:n,nativeToDisplayCurrencyExchangeRate:o,nativeToUsdExchangeRate:i}),{amount:p,valueInCurrency:g,usd:k}=c({approvalGasLimit:e?.gasLimit,resetApprovalGasLimit:a?.gasLimit,tradeGasLimit:t?.gasLimit,l1GasFeesInHexWei:s,feePerGasInDecGwei:r,nativeToDisplayCurrencyExchangeRate:o,nativeToUsdExchangeRate:i});return{effective:{amount:l,valueInCurrency:d,usd:m},total:{amount:u,valueInCurrency:h,usd:f},max:{amount:p,valueInCurrency:g,usd:k}}};s.calcTotalEstimatedNetworkFee=({total:e},t)=>({amount:new n.BigNumber(e?.amount??"0").plus(t.amount).toString(),valueInCurrency:e?.valueInCurrency?new n.BigNumber(e.valueInCurrency).plus(t.valueInCurrency??"0").toString():null,usd:e?.usd?new n.BigNumber(e.usd).plus(t.usd??"0").toString():null});s.calcTotalMaxNetworkFee=(e,t)=>({amount:new n.BigNumber(e.max.amount).plus(t.amount).toString(),valueInCurrency:e.max.valueInCurrency?new n.BigNumber(e.max.valueInCurrency).plus(t.valueInCurrency??"0").toString():null,usd:e.max.usd?new n.BigNumber(e.max.usd).plus(t.usd??"0").toString():null});s.calcIncludedTxFees=({gasIncluded:e,gasIncluded7702:t,srcAsset:s,feeData:{txFee:a}},n,r)=>{if(!a||!e&&!t)return null;const{exchangeRate:o,usdExchangeRate:c}=a.asset.assetId===s.assetId?n:r,l=i(a.amount,a.asset.decimals);return{amount:l.toString(),valueInCurrency:o?l.times(o).toString():null,usd:c?l.times(c).toString():null}};s.calcAdjustedReturn=(e,t,{feeData:{txFee:s},destAsset:{assetId:a}})=>s?.asset?.assetId===a?{valueInCurrency:e.valueInCurrency,usd:e.usd}:{valueInCurrency:e.valueInCurrency&&t.valueInCurrency?new n.BigNumber(e.valueInCurrency).minus(t.valueInCurrency).toString():null,usd:e.usd&&t.usd?new n.BigNumber(e.usd).minus(t.usd).toString():null};s.calcSwapRate=(e,t)=>new n.BigNumber(t).div(e).toString();s.calcCost=(e,t)=>({valueInCurrency:e.valueInCurrency&&t.valueInCurrency?new n.BigNumber(t.valueInCurrency).minus(e.valueInCurrency).toString():null,usd:e.usd&&t.usd?new n.BigNumber(t.usd).minus(e.usd).toString():null});s.calcSlippagePercentage=(e,t)=>{const a=(0,s.calcCost)(e,t);return a.valueInCurrency&&t.valueInCurrency?new n.BigNumber(a.valueInCurrency).div(t.valueInCurrency).times(100).abs().toString():a.usd&&t.usd?new n.BigNumber(a.usd).div(t.usd).times(100).abs().toString():null};s.formatEtaInMinutes=e=>e<60?"< 1":(e/60).toFixed();s.sortQuotes=(e,t)=>t===o.FeatureId.PERPS?e.sort((e,t)=>e.estimatedProcessingTimeInSeconds-t.estimatedProcessingTimeInSeconds):e}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/quote.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/slippage.cjs",{"./bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/bridge.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getDefaultSlippagePercentage=s.BRIDGE_DEFAULT_SLIPPAGE=void 0;const a=e("./bridge.cjs");s.BRIDGE_DEFAULT_SLIPPAGE=.5;const n=undefined;s.getDefaultSlippagePercentage=({srcTokenAddress:e,destTokenAddress:t,srcChainId:r,destChainId:o},i,c)=>!r||(0,a.isCrossChain)(r,o)?s.BRIDGE_DEFAULT_SLIPPAGE:(0,a.isSolanaChainId)(r)?n:e&&t&&i?.map(e=>e.toLowerCase()).includes(e.toLowerCase())&&(c??i)?.map(e=>e.toLowerCase()).includes(t.toLowerCase())?.5:2}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/slippage.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/snaps.cjs",{"../constants/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/bridge.cjs","@metamask/keyring-api":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-api/dist/index.cjs",uuid:"/home/runner/work/metamask-extension/metamask-extension/node_modules/uuid/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.computeFeeRequest=s.getMinimumBalanceForRentExemptionInLamports=s.getMinimumBalanceForRentExemptionRequest=void 0;const a=e("@metamask/keyring-api"),n=e("uuid"),r=e("../constants/bridge.cjs");s.getMinimumBalanceForRentExemptionRequest=e=>({snapId:e,origin:"metamask",handler:"onProtocolRequest",request:{method:" ",jsonrpc:"2.0",params:{scope:a.SolScope.Mainnet,request:{id:(0,n.v4)(),jsonrpc:"2.0",method:"getMinimumBalanceForRentExemption",params:[0,{commitment:"confirmed"}]}}}});s.getMinimumBalanceForRentExemptionInLamports=async(e,t)=>String(await t.call("SnapController:handleRequest",(0,s.getMinimumBalanceForRentExemptionRequest)(e)).catch(e=>(console.error("Error setting minimum balance for rent exemption",e),r.DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports)));s.computeFeeRequest=(e,t,s,a,r)=>({snapId:e,origin:"metamask",handler:"onClientRequest",request:{id:(0,n.v4)(),jsonrpc:"2.0",method:"computeFee",params:{transaction:t,accountId:s,scope:a,...r&&{options:r}}}})}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/snaps.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/swaps.cjs",{"../constants/chains.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/chains.cjs","../constants/swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/swaps.cjs","../constants/tokens.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/constants/tokens.cjs","./caip-formatters.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/caip-formatters.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.fetchTokens=s.DEV_BASE_URL=s.API_BASE_URL=s.getSwapsContractAddress=s.isValidSwapsContractAddress=void 0;const a=e("./caip-formatters.cjs"),n=e("../constants/chains.cjs"),r=e("../constants/swaps.cjs"),o=e("../constants/tokens.cjs");function i(e){return e?{"X-Client-Id":e}:undefined}s.isValidSwapsContractAddress=function(e,t){return!(!t||!r.ALLOWED_CONTRACT_ADDRESSES[e])&&r.ALLOWED_CONTRACT_ADDRESSES[e].some(e=>t.toLowerCase()===e.toLowerCase())},s.getSwapsContractAddress=function(e){return r.SWAPS_CONTRACT_ADDRESSES[e]},s.API_BASE_URL="https://swap.api.cx.metamask.io",s.DEV_BASE_URL="https://swap.dev-api.cx.metamask.io",s.fetchTokens=async function(e,t,r){const[c,l]=e===n.CHAIN_IDS.LOCALHOST?[n.CHAIN_IDS.MAINNET,s.DEV_BASE_URL]:[e,s.API_BASE_URL],d=`${l}/networks/${(0,a.formatChainIdToDec)(c)}/tokens`,m=(await t(d,{headers:i(r)})).filter(e=>e.address!==o.DEFAULT_TOKEN_ADDRESS),u=o.SWAPS_CHAINID_DEFAULT_TOKEN_MAP[e];return m.push(u),m}}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/swaps.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/trade-utils.cjs",{buffer:"/home/runner/work/metamask-extension/metamask-extension/node_modules/browserify/node_modules/buffer/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){(function(e){(function(){Object.defineProperty(s,"__esModule",{value:!0}),s.extractTradeData=s.isTronTrade=s.isBitcoinTrade=s.isEvmTxData=void 0;s.isEvmTxData=e=>"object"==typeof e&&null!==e&&"data"in e&&"chainId"in e&&"to"in e;s.isBitcoinTrade=e=>"object"==typeof e&&null!==e&&"unsignedPsbtBase64"in e;s.isTronTrade=e=>"object"==typeof e&&null!==e&&"raw_data_hex"in e;s.extractTradeData=t=>(0,s.isBitcoinTrade)(t)?t.unsignedPsbtBase64:(0,s.isTronTrade)(t)?e.from(t.raw_data_hex,"hex").toString("base64"):"string"==typeof t?t:(0,s.isEvmTxData)(t)?t.data:""}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/trade-utils.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/validators.cjs",{"@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/superstruct":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/superstruct/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.validateTokenFeature=s.TokenFeatureSchema=s.TokenFeatureType=s.validateQuoteResponse=s.QuoteResponseSchema=s.TronTradeDataSchema=s.BitcoinTradeDataSchema=s.TxDataSchema=s.QuoteSchema=s.IntentSchema=s.IntentOrderSchema=s.StepSchema=s.ProtocolSchema=s.FeeDataSchema=s.validateSwapsTokenObject=s.validateFeatureFlagsResponse=s.PlatformConfigSchema=s.PriceImpactThresholdSchema=s.ChainConfigurationSchema=s.ChainRankingSchema=s.ChainRankingItemSchema=s.BridgeAssetSchema=s.truthyString=s.ActionTypes=s.FeatureId=s.FeeType=void 0;const a=e("@metamask/controller-utils"),n=e("@metamask/superstruct"),r=e("@metamask/utils");var o,i,c;!function(e){e.METABRIDGE="metabridge",e.REFUEL="refuel",e.TX_FEE="txFee"}(o||(s.FeeType=o={})),function(e){e.PERPS="perps"}(i||(s.FeatureId=i={})),function(e){e.BRIDGE="bridge",e.SWAP="swap",e.REFUEL="refuel"}(c||(s.ActionTypes=c={}));const l=(0,n.define)("HexAddress",e=>(0,a.isValidHexAddress)(e,{allowNonPrefixed:!1})),d=(0,n.define)("HexString",e=>(0,r.isStrictHexString)(e)),m=(0,n.define)("VersionString",e=>"string"==typeof e&&/^(\d+\.*){2}\d+$/u.test(e)&&3===e.split(".").length);s.truthyString=e=>Boolean(e?.length);const u=(0,n.pattern)((0,n.string)(),/^\d+$/u),h=(0,n.number)();s.BridgeAssetSchema=(0,n.type)({chainId:h,address:(0,n.string)(),assetId:r.CaipAssetTypeStruct,symbol:(0,n.string)(),name:(0,n.string)(),decimals:(0,n.number)(),icon:(0,n.optional)((0,n.nullable)((0,n.string)())),iconUrl:(0,n.optional)((0,n.nullable)((0,n.string)()))});const f=(0,n.type)({standard:(0,n.record)((0,n.string)(),(0,n.string)()),other:(0,n.record)((0,n.string)(),(0,n.string)())});s.ChainRankingItemSchema=(0,n.type)({chainId:r.CaipChainIdStruct,name:(0,n.string)()}),s.ChainRankingSchema=(0,n.optional)((0,n.array)(s.ChainRankingItemSchema)),s.ChainConfigurationSchema=(0,n.type)({isActiveSrc:(0,n.boolean)(),isActiveDest:(0,n.boolean)(),refreshRate:(0,n.optional)((0,n.number)()),topAssets:(0,n.optional)((0,n.array)((0,n.string)())),stablecoins:(0,n.optional)((0,n.array)((0,n.string)())),isUnifiedUIEnabled:(0,n.optional)((0,n.boolean)()),isSingleSwapBridgeButtonEnabled:(0,n.optional)((0,n.boolean)()),isGaslessSwapEnabled:(0,n.optional)((0,n.boolean)()),noFeeAssets:(0,n.optional)((0,n.array)((0,n.string)())),defaultPairs:(0,n.optional)(f)}),s.PriceImpactThresholdSchema=(0,n.type)({gasless:(0,n.number)(),normal:(0,n.number)(),warning:(0,n.optional)((0,n.number)()),error:(0,n.optional)((0,n.number)())});const p=(0,n.type)({aggIds:(0,n.optional)((0,n.array)((0,n.string)())),bridgeIds:(0,n.optional)((0,n.array)((0,n.string)())),fee:(0,n.optional)((0,n.number)())}),g=(0,n.enums)(Object.values(i));s.PlatformConfigSchema=(0,n.type)({priceImpactThreshold:(0,n.optional)(s.PriceImpactThresholdSchema),quoteRequestOverrides:(0,n.optional)((0,n.record)(g,(0,n.optional)(p))),minimumVersion:(0,n.string)(),refreshRate:(0,n.number)(),maxRefreshCount:(0,n.number)(),support:(0,n.boolean)(),chains:(0,n.record)((0,n.string)(),s.ChainConfigurationSchema),bip44DefaultPairs:(0,n.optional)((0,n.record)((0,n.string)(),(0,n.optional)(f))),sse:(0,n.optional)((0,n.type)({enabled:(0,n.boolean)(),minimumVersion:m})),chainRanking:s.ChainRankingSchema});s.validateFeatureFlagsResponse=e=>(0,n.is)(e,s.PlatformConfigSchema);s.validateSwapsTokenObject=e=>(0,n.is)(e,s.BridgeAssetSchema),s.FeeDataSchema=(0,n.type)({amount:u,asset:s.BridgeAssetSchema}),s.ProtocolSchema=(0,n.type)({name:(0,n.string)(),displayName:(0,n.optional)((0,n.string)()),icon:(0,n.optional)((0,n.string)())}),s.StepSchema=(0,n.type)({action:(0,n.enums)(Object.values(c)),srcChainId:h,destChainId:(0,n.optional)(h),srcAsset:s.BridgeAssetSchema,destAsset:s.BridgeAssetSchema,srcAmount:(0,n.string)(),destAmount:(0,n.string)(),protocol:s.ProtocolSchema});const k=s.StepSchema,b=(0,n.union)([u,(0,n.number)()]),w=(0,n.string)();s.IntentOrderSchema=(0,n.type)({sellToken:l,buyToken:l,receiver:(0,n.optional)(l),validTo:b,appData:(0,n.string)(),appDataHash:d,feeAmount:u,kind:(0,n.enums)(["sell","buy"]),partiallyFillable:(0,n.boolean)(),sellAmount:(0,n.optional)(u),buyAmount:(0,n.optional)(u),from:(0,n.optional)(l)}),s.IntentSchema=(0,n.type)({protocol:w,order:s.IntentOrderSchema,settlementContract:(0,n.optional)(l),typedData:(0,n.type)({types:(0,n.record)((0,n.string)(),(0,n.array)((0,n.type)({name:(0,n.string)(),type:(0,n.string)()}))),primaryType:(0,n.string)(),domain:(0,n.record)((0,n.string)(),(0,n.any)()),message:(0,n.record)((0,n.string)(),(0,n.any)())})}),s.QuoteSchema=(0,n.type)({requestId:(0,n.string)(),srcChainId:h,srcAsset:s.BridgeAssetSchema,srcTokenAmount:(0,n.string)(),destChainId:h,destAsset:s.BridgeAssetSchema,destTokenAmount:(0,n.string)(),minDestTokenAmount:(0,n.string)(),feeData:(0,n.type)({[o.METABRIDGE]:s.FeeDataSchema,[o.TX_FEE]:(0,n.optional)((0,n.intersection)([s.FeeDataSchema,(0,n.type)({maxFeePerGas:(0,n.string)(),maxPriorityFeePerGas:(0,n.string)()})]))}),gasIncluded:(0,n.optional)((0,n.boolean)()),gasIncluded7702:(0,n.optional)((0,n.boolean)()),bridgeId:(0,n.string)(),bridges:(0,n.array)((0,n.string)()),steps:(0,n.array)(s.StepSchema),refuel:(0,n.optional)(k),priceData:(0,n.optional)((0,n.type)({totalFromAmountUsd:(0,n.optional)((0,n.string)()),totalToAmountUsd:(0,n.optional)((0,n.string)()),priceImpact:(0,n.optional)((0,n.string)()),totalFeeAmountUsd:(0,n.optional)((0,n.string)())})),intent:(0,n.optional)(s.IntentSchema),gasSponsored:(0,n.optional)((0,n.boolean)())}),s.TxDataSchema=(0,n.type)({chainId:(0,n.number)(),to:l,from:l,value:d,data:d,gasLimit:(0,n.nullable)((0,n.number)()),effectiveGas:(0,n.optional)((0,n.number)())}),s.BitcoinTradeDataSchema=(0,n.type)({unsignedPsbtBase64:(0,n.string)(),inputsToSign:(0,n.nullable)((0,n.array)((0,n.type)({})))}),s.TronTradeDataSchema=(0,n.type)({raw_data_hex:(0,n.string)(),visible:(0,n.optional)((0,n.boolean)()),raw_data:(0,n.optional)((0,n.nullable)((0,n.type)({contract:(0,n.optional)((0,n.array)((0,n.type)({type:(0,n.optional)((0,n.string)())}))),fee_limit:(0,n.optional)((0,n.number)())})))}),s.QuoteResponseSchema=(0,n.type)({quote:s.QuoteSchema,estimatedProcessingTimeInSeconds:(0,n.number)(),approval:(0,n.optional)((0,n.union)([s.TxDataSchema,s.TronTradeDataSchema])),trade:(0,n.union)([s.TxDataSchema,s.BitcoinTradeDataSchema,s.TronTradeDataSchema,(0,n.string)()])});var _;s.validateQuoteResponse=e=>((0,n.assert)(e,s.QuoteResponseSchema),!0),function(e){e.MALICIOUS="Malicious",e.WARNING="Warning",e.INFO="Info",e.BENIGN="Benign"}(_||(s.TokenFeatureType=_={})),s.TokenFeatureSchema=(0,n.type)({feature_id:(0,n.string)(),type:(0,n.enums)(Object.values(_)),description:(0,n.string)()});s.validateTokenFeature=e=>((0,n.assert)(e,s.TokenFeatureSchema),!0)}}},{package:"@metamask/bridge-status-controller>@metamask/bridge-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/bridge-controller/dist/utils/validators.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/TransactionController.cjs",{"./gas-flows/DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","./gas-flows/LineaGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.cjs","./gas-flows/OptimismLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs","./gas-flows/RandomisedEstimationsGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs","./gas-flows/ScrollLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs","./gas-flows/TestGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/TestGasFeeFlow.cjs","./helpers/AccountsApiRemoteTransactionSource.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs","./helpers/GasFeePoller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs","./helpers/IncomingTransactionHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.cjs","./helpers/MethodDataHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/MethodDataHelper.cjs","./helpers/MultichainTrackingHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.cjs","./helpers/PendingTransactionTracker.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.cjs","./helpers/ResimulateHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/ResimulateHelper.cjs","./hooks/ExtraTransactionsPublishHook.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/ExtraTransactionsPublishHook.cjs","./logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils/balance-changes.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/balance-changes.cjs","./utils/batch.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs","./utils/eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./utils/external-transactions.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.cjs","./utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","./utils/first-time-interaction.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/first-time-interaction.cjs","./utils/gas-fee-tokens.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fee-tokens.cjs","./utils/gas-fees.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs","./utils/gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs","./utils/gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas.cjs","./utils/layer1-gas-fee-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/layer1-gas-fee-flow.cjs","./utils/nonce.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/nonce.cjs","./utils/prepare.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs","./utils/retry.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/retry.cjs","./utils/swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/swaps.cjs","./utils/transaction-type.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs","./utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","./utils/validation.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/validation.cjs","@metamask/base-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/base-controller/dist/index.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/eth-query":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eth-query/index.js","@metamask/network-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/network-controller/dist/index.cjs","@metamask/nonce-tracker":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/nonce-tracker/dist/index.js","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs",events:"/home/runner/work/metamask-extension/metamask-extension/node_modules/events/events.js",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js",uuid:"/home/runner/work/metamask-extension/metamask-extension/node_modules/uuid/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p,g,k,b,w,_,T,E,I,S,x,y,A,v,P,C,j,N,D,R,F,L,M,O,B,G,H,U,q,W,$,V,K,Y,Q,z,X,J,Z,ee,te,se,ae,ne,re,oe,ie,ce,le,de,me,ue,he,fe,pe,ge,ke,be,we,_e,Te,Ee,Ie,Se,xe,ye,Ae,ve,Pe,Ce,je,Ne,De,Re,Fe,Le,Me,Oe,Be,Ge,He,Ue,qe,We,$e,Ve,Ke,Ye,Qe,ze,Xe,Je,Ze=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},et=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},tt=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.TransactionController=s.ApprovalState=s.SPEED_UP_RATE=s.CANCEL_RATE=void 0;const st=e("@metamask/base-controller"),at=e("@metamask/controller-utils"),nt=tt(e("@metamask/eth-query")),rt=e("@metamask/network-controller"),ot=e("@metamask/nonce-tracker"),it=e("@metamask/rpc-errors"),ct=e("@metamask/utils"),lt=e("events"),dt=e("lodash"),mt=e("uuid"),ut=e("./gas-flows/DefaultGasFeeFlow.cjs"),ht=e("./gas-flows/LineaGasFeeFlow.cjs"),ft=e("./gas-flows/OptimismLayer1GasFeeFlow.cjs"),pt=e("./gas-flows/RandomisedEstimationsGasFeeFlow.cjs"),gt=e("./gas-flows/ScrollLayer1GasFeeFlow.cjs"),kt=e("./gas-flows/TestGasFeeFlow.cjs"),bt=e("./helpers/AccountsApiRemoteTransactionSource.cjs"),wt=e("./helpers/GasFeePoller.cjs"),_t=e("./helpers/IncomingTransactionHelper.cjs"),Tt=e("./helpers/MethodDataHelper.cjs"),Et=e("./helpers/MultichainTrackingHelper.cjs"),It=e("./helpers/PendingTransactionTracker.cjs"),St=e("./helpers/ResimulateHelper.cjs"),xt=e("./hooks/ExtraTransactionsPublishHook.cjs"),yt=e("./logger.cjs"),At=e("./types.cjs"),vt=e("./utils/balance-changes.cjs"),Pt=e("./utils/batch.cjs"),Ct=e("./utils/eip7702.cjs"),jt=e("./utils/external-transactions.cjs"),Nt=e("./utils/feature-flags.cjs"),Dt=e("./utils/first-time-interaction.cjs"),Rt=e("./utils/gas.cjs"),Ft=e("./utils/gas-fee-tokens.cjs"),Lt=e("./utils/gas-fees.cjs"),Mt=e("./utils/gas-flow.cjs"),Ot=e("./utils/layer1-gas-fee-flow.cjs"),Bt=e("./utils/nonce.cjs"),Gt=e("./utils/prepare.cjs"),Ht=e("./utils/retry.cjs"),Ut=e("./utils/swaps.cjs"),qt=e("./utils/transaction-type.cjs"),Wt=e("./utils/utils.cjs"),$t=e("./utils/validation.cjs"),Vt={transactions:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},transactionBatches:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},methodData:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},lastFetchedBlockNumbers:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!1},submitHistory:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!1}};s.CANCEL_RATE=1.1,s.SPEED_UP_RATE=1.1;const Kt="TransactionController";var Yt;!function(e){e.Approved="approved",e.NotApproved="not-approved",e.SkippedViaBeforePublishHook="skipped-via-before-publish-hook"}(Yt||(s.ApprovalState=Yt={}));const Qt=["abortTransactionSigning","addTransaction","addTransactionBatch","approveTransactionsWithSameNonce","clearUnapprovedTransactions","confirmExternalTransaction","emulateNewTransaction","emulateTransactionUpdate","estimateGas","estimateGasBatch","estimateGasBuffered","estimateGasFee","getGasFeeTokens","getLayer1GasFee","getNonceLock","getTransactions","handleMethodData","isAtomicBatchSupported","setTransactionActive","speedUpTransaction","startIncomingTransactionPolling","stopIncomingTransactionPolling","stopTransaction","updateAtomicBatchData","updateCustodialTransaction","updateEditableParams","updateIncomingTransactions","updateTransaction"];class zt extends st.BaseController{constructor(e){const{disableSwaps:t,getCurrentAccountEIP1559Compatibility:s,getCurrentNetworkEIP1559Compatibility:q,getExternalPendingTransactions:W,getGasFeeEstimates:$,getNetworkClientRegistry:V,getNetworkState:Y,getPermittedAccounts:Q,getSavedGasFees:z,getSimulationConfig:X,hooks:J,incomingTransactions:ee={},isAutomaticGasFeeUpdateEnabled:te,isEIP7702GasFeeTokensEnabled:se,isFirstTimeInteractionEnabled:ae,isSimulationEnabled:ne,messenger:re,pendingTransactions:oe={},publicKeyEIP7702:ie,securityProviderRequest:ce,sign:le,state:me,testGasFeeFlows:ue,trace:he}=e;super({name:Kt,metadata:Vt,messenger:re,state:{methodData:{},transactions:[],transactionBatches:[],lastFetchedBlockNumbers:{},submitHistory:[],...me}}),a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,new Set),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,void 0),u.set(this,void 0),h.set(this,void 0),f.set(this,void 0),p.set(this,void 0),g.set(this,void 0),k.set(this,void 0),b.set(this,void 0),w.set(this,void 0),_.set(this,void 0),T.set(this,void 0),E.set(this,void 0),I.set(this,new lt.EventEmitter),S.set(this,void 0),x.set(this,void 0),y.set(this,void 0),A.set(this,void 0),v.set(this,void 0),P.set(this,void 0),C.set(this,void 0),j.set(this,void 0),N.set(this,void 0),D.set(this,void 0),R.set(this,void 0),F.set(this,void 0),L.set(this,void 0),M.set(this,void 0),O.set(this,void 0),B.set(this,new Map),G.set(this,new Set),H.set(this,void 0),U.set(this,void 0),ye.set(this,()=>{et(this,N,"f").checkForPendingTransactionAndStartPolling()}),this.messenger=re,Ze(this,n,J?.afterAdd??(()=>Promise.resolve({})),"f"),Ze(this,r,J?.afterSign??(()=>!0),"f"),Ze(this,o,J?.afterSimulate??(()=>Promise.resolve({})),"f"),Ze(this,c,J?.beforeCheckPendingTransaction??(()=>Promise.resolve(!0)),"f"),Ze(this,l,J?.beforePublish??(()=>Promise.resolve(!0)),"f"),Ze(this,d,J?.beforeSign??(()=>Promise.resolve({})),"f"),Ze(this,u,J?.getAdditionalSignArguments??(()=>[]),"f"),Ze(this,h,s??(()=>Promise.resolve(!0)),"f"),Ze(this,f,q,"f"),Ze(this,p,W??(()=>[]),"f"),Ze(this,g,$??(()=>Promise.resolve({})),"f"),Ze(this,k,Y,"f"),Ze(this,b,Q,"f"),Ze(this,w,z??(e=>undefined),"f"),Ze(this,_,X??(()=>Promise.resolve({})),"f"),Ze(this,E,ee,"f"),Ze(this,S,te??(e=>!1),"f"),Ze(this,x,se??(()=>Promise.resolve(!1)),"f"),Ze(this,y,ae??(()=>!0),"f"),Ze(this,A,ne??(()=>!0),"f"),Ze(this,v,t??!1,"f"),Ze(this,P,J?.isTimeoutEnabled??(()=>!0),"f"),Ze(this,D,oe,"f"),Ze(this,R,ie,"f"),Ze(this,F,J?.publish??(()=>Promise.resolve({transactionHash:undefined})),"f"),Ze(this,L,J?.publishBatch,"f"),Ze(this,M,ce,"f"),Ze(this,O,le,"f"),Ze(this,H,!0===ue,"f"),Ze(this,U,he??((e,t)=>t?.()),"f");const fe=e=>this.messenger.call("NetworkController:findNetworkClientIdByChainId",e);Ze(this,N,new Et.MultichainTrackingHelper({findNetworkClientIdByChainId:fe,getNetworkClientById:e=>this.messenger.call("NetworkController:getNetworkClientById",e),getNetworkClientRegistry:V,removePendingTransactionTrackerListeners:et(this,a,"m",Pe).bind(this),createNonceTracker:et(this,a,"m",Se).bind(this),createPendingTransactionTracker:et(this,a,"m",xe).bind(this),onNetworkStateChange:e=>{this.messenger.subscribe("NetworkController:stateChange",e)}}),"f"),et(this,N,"f").initialize(),Ze(this,m,et(this,a,"m",Re).call(this),"f"),Ze(this,C,et(this,a,"m",Fe).call(this),"f");const pe=new wt.GasFeePoller({findNetworkClientIdByChainId:fe,gasFeeFlows:et(this,m,"f"),getGasFeeControllerEstimates:et(this,g,"f"),getProvider:e=>et(this,a,"m",de).call(this,{networkClientId:e}),getTransactions:()=>this.state.transactions,getTransactionBatches:()=>this.state.transactionBatches,layer1GasFeeFlows:et(this,C,"f"),messenger:this.messenger,onStateChange:e=>{this.messenger.subscribe("TransactionController:stateChange",e)}});pe.hub.on("transaction-updated",et(this,a,"m",Oe).bind(this)),pe.hub.on("transaction-batch-updated",et(this,a,"m",Be).bind(this)),Ze(this,j,new Tt.MethodDataHelper({getProvider:e=>et(this,a,"m",de).call(this,{networkClientId:e}),getState:()=>this.state.methodData}),"f"),et(this,j,"f").hub.on("update",({fourBytePrefix:e,methodData:t})=>{this.update(s=>{s.methodData[e]=t})}),Ze(this,T,new _t.IncomingTransactionHelper({client:et(this,E,"f").client,getCurrentAccount:()=>et(this,a,"m",He).call(this),getLocalTransactions:()=>this.state.transactions,includeTokenTransfers:et(this,E,"f").includeTokenTransfers,isEnabled:et(this,E,"f").isEnabled,messenger:this.messenger,remoteTransactionSource:new bt.AccountsApiRemoteTransactionSource,trimTransactions:et(this,a,"m",Z).bind(this),updateTransactions:et(this,E,"f").updateTransactions}),"f"),et(this,a,"m",ve).call(this,et(this,T,"f")),this.messenger.subscribe("TransactionController:stateChange",et(this,ye,"f")),new St.ResimulateHelper({simulateTransaction:et(this,a,"m",Me).bind(this),onTransactionsUpdate:e=>{this.messenger.subscribe("TransactionController:stateChange",e,e=>e.transactions)},getTransactions:()=>this.state.transactions}),et(this,a,"m",K).call(this),et(this,ye,"f").call(this),et(this,a,"m",$e).call(this)}destroy(){et(this,a,"m",Ae).call(this)}async handleMethodData(e,t){return et(this,j,"f").lookup(e,t)}async addTransactionBatch(e){const{blockTracker:t}=this.messenger.call("NetworkController:getNetworkClientById",e.networkClientId);return await(0,Pt.addTransactionBatch)({addTransaction:this.addTransaction.bind(this),estimateGas:this.estimateGas.bind(this),getChainId:et(this,a,"m",ie).bind(this),getEthQuery:e=>et(this,a,"m",le).call(this,{networkClientId:e}),getGasFeeEstimates:et(this,g,"f"),getInternalAccounts:et(this,a,"m",Ue).bind(this),getSimulationConfig:et(this,_,"f").bind(this),getPendingTransactionTracker:e=>et(this,a,"m",xe).call(this,{provider:et(this,a,"m",de).call(this,{networkClientId:e}),blockTracker:t,chainId:et(this,a,"m",ie).call(this,e),networkClientId:e}),getTransaction:e=>et(this,a,"m",ne).call(this,e),isSimulationEnabled:et(this,A,"f"),messenger:this.messenger,publishBatchHook:et(this,L,"f"),publicKeyEIP7702:et(this,R,"f"),publishTransaction:(e,t)=>et(this,a,"m",X).call(this,e,t),request:e,signTransaction:et(this,a,"m",we).bind(this),update:this.update.bind(this),updateTransaction:et(this,a,"m",Le).bind(this)})}async isAtomicBatchSupported(e){return(0,Pt.isAtomicBatchSupported)({...e,getEthQuery:e=>et(this,a,"m",le).call(this,{chainId:e}),messenger:this.messenger,publicKeyEIP7702:et(this,R,"f")})}async addTransaction(e,t){(0,yt.projectLogger)("Adding transaction",e,t);const{actionId:s,assetsFiatValues:r,batchId:o,deviceConfirmedOn:i,disableGasBuffer:c,gasFeeToken:l,isGasFeeIncluded:d,isGasFeeSponsored:m,isStateOnly:u,method:h,nestedTransactions:f,networkClientId:p,origin:g,publishHook:k,requestId:w,requiredAssets:_,requireApproval:T,securityAlertResponse:E,skipInitialGasEstimate:I,swaps:S={},traceContext:x,type:A}=t;if(e=(0,Wt.normalizeTransactionParams)(e),!et(this,N,"f").has(p))throw new Error(`Network client not found - ${p}`);const P=et(this,a,"m",ie).call(this,p),C=et(this,a,"m",le).call(this,{networkClientId:p}),j=g===undefined?undefined:await(et(this,b,"f")?.call(this,g)),D=et(this,a,"m",Ue).call(this);await(0,$t.validateTransactionOrigin)({data:e.data,from:e.from,internalAccounts:D,origin:g,permittedAddresses:j,txParams:e,type:A});const R=(0,Ct.getDelegationAddress)(e.from,C).catch(()=>undefined),F=await et(this,a,"m",be).call(this,p);(0,$t.validateTxParams)(e,F,P),e.type||(0,Wt.setEnvelopeType)(e,F);if(o?.length&&this.state.transactions.some(e=>e.batchId?.toLowerCase()===o?.toLowerCase())&&g&&g!==at.ORIGIN_METAMASK)throw new it.JsonRpcError($t.ErrorCode.DuplicateBundleId,"Batch ID already exists");const L=et(this,a,"m",ue).call(this,e,g),O=A??(await(0,qt.determineTransactionType)(e,C)).type;let B={actionId:s,assetsFiatValues:r,batchId:o,chainId:P,dappSuggestedGasFees:L,deviceConfirmedOn:i,disableGasBuffer:c,id:(0,mt.v1)(),isGasFeeTokenIgnoredIfBalance:Boolean(l),isGasFeeIncluded:d,isGasFeeSponsored:m,isFirstTimeInteraction:undefined,isStateOnly:u,nestedTransactions:f,networkClientId:p,origin:g,requestId:w,requiredAssets:_,securityAlertResponse:E,selectedGasFeeToken:l,status:At.TransactionStatus.unapproved,time:Date.now(),txParams:e,type:O,userEditedGasLimit:!1,verifiedOnBlockchain:!1};const{updateTransaction:G}=await et(this,n,"f").call(this,{transactionMeta:B});if(G&&((0,yt.projectLogger)("Updating transaction using afterAdd hook"),B.txParamsOriginal=(0,dt.cloneDeep)(B.txParams),G(B)),I){const e=(0,dt.cloneDeep)(B);et(this,a,"m",V).call(this,e).then(()=>(et(this,a,"m",Le).call(this,{transactionId:e.id,skipResimulateCheck:!0,skipValidation:!0},t=>{t.txParams.gas=e.txParams.gas,t.txParams.gasPrice=e.txParams.gasPrice,t.txParams.maxFeePerGas=e.txParams.maxFeePerGas,t.txParams.maxPriorityFeePerGas=e.txParams.maxPriorityFeePerGas}),undefined)).catch(dt.noop)}else await et(this,U,"f").call(this,{name:"Estimate Gas Properties",parentContext:x},e=>et(this,a,"m",V).call(this,B,{traceContext:e}));if(h&&et(this,M,"f")){const e=await et(this,M,"f").call(this,B,h);B.securityProviderResponse=e}return B=(0,Ut.updateSwapsTransaction)(B,O,S,{isSwapsDisabled:et(this,v,"f"),cancelTransaction:et(this,a,"m",J).bind(this),messenger:this.messenger}),et(this,a,"m",$).call(this,B),R.then(e=>(et(this,a,"m",Le).call(this,{transactionId:B.id,skipResimulateCheck:!0,skipValidation:!0},t=>{t.delegationAddress=e}),undefined)).catch(dt.noop),!1===T||u?(0,yt.projectLogger)("Skipping simulation & first interaction update as approval not required"):(et(this,a,"m",Me).call(this,B,{traceContext:x}).catch(e=>{throw(0,yt.projectLogger)("Error while updating simulation data",e),e}),(0,Dt.updateFirstTimeInteraction)({existingTransactions:this.state.transactions,getTransaction:e=>et(this,a,"m",ae).call(this,e),isFirstTimeInteractionEnabled:et(this,y,"f"),trace:et(this,U,"f"),traceContext:x,transactionMeta:B,updateTransaction:et(this,a,"m",Le).bind(this)}).catch(e=>{(0,yt.projectLogger)("Error while updating first interaction properties",e)})),this.messenger.publish(`${Kt}:unapprovedTransactionAdded`,B),{result:et(this,a,"m",Q).call(this,B,{actionId:s,publishHook:k,requireApproval:T,traceContext:x}),transactionMeta:B}}startIncomingTransactionPolling(){et(this,T,"f").start()}stopIncomingTransactionPolling(){et(this,T,"f").stop()}async updateIncomingTransactions({tags:e}={}){await et(this,T,"f").update({tags:e})}async stopTransaction(e,t,{estimatedBaseFee:n,actionId:r}={}){await et(this,a,"m",q).call(this,{actionId:r,estimatedBaseFee:n,gasValues:t,label:"cancel",rate:s.CANCEL_RATE,transactionId:e,transactionType:At.TransactionType.cancel,prepareTransactionParams:e=>{delete e.data,e.to=e.from,e.value="0x0"},afterSubmit:e=>{this.messenger.publish(`${Kt}:transactionFinished`,e),et(this,I,"f").emit(`${e.id}:finished`,e)}})}async speedUpTransaction(e,t,{actionId:n,estimatedBaseFee:r}={}){await et(this,a,"m",q).call(this,{actionId:n,estimatedBaseFee:r,gasValues:t,label:"speed up",rate:s.SPEED_UP_RATE,transactionId:e,transactionType:At.TransactionType.retry,afterSubmit:e=>{this.messenger.publish(`${Kt}:speedupTransactionAdded`,e)}})}async estimateGas(e,t,{ignoreDelegationSignatures:s}={}){const n=et(this,a,"m",le).call(this,{networkClientId:t}),{estimatedGas:r,simulationFails:o}=await(0,Rt.estimateGas)({chainId:et(this,a,"m",ie).call(this,t),ethQuery:n,ignoreDelegationSignatures:s,isSimulationEnabled:et(this,A,"f").call(this),getSimulationConfig:et(this,_,"f"),messenger:this.messenger,txParams:e});return{gas:r,simulationFails:o}}async estimateGasBatch({chainId:e,from:t,transactions:s}){const n=et(this,a,"m",le).call(this,{chainId:e});return(0,Rt.estimateGasBatch)({chainId:e,ethQuery:n,from:t,getSimulationConfig:et(this,_,"f"),isAtomicBatchSupported:this.isAtomicBatchSupported.bind(this),messenger:this.messenger,transactions:s})}async estimateGasBuffered(e,t,s){const n=et(this,a,"m",le).call(this,{networkClientId:s}),{blockGasLimit:r,estimatedGas:o,simulationFails:i}=await(0,Rt.estimateGas)({chainId:et(this,a,"m",ie).call(this,s),ethQuery:n,isSimulationEnabled:et(this,A,"f").call(this),getSimulationConfig:et(this,_,"f"),messenger:this.messenger,txParams:e});return{gas:(0,Rt.addGasBuffer)(o,r,t),simulationFails:i}}updateTransaction(e,t){const{id:s}=e;et(this,a,"m",Le).call(this,{transactionId:s},()=>({...e})),(0,yt.projectLogger)("Transaction updated",{transactionId:s,note:t})}updateSecurityAlertResponse(e,t){if(!t)throw new Error("updateSecurityAlertResponse: securityAlertResponse should not be null");const s=et(this,a,"m",ae).call(this,e);if(!s)throw new Error("Cannot update security alert response as no transaction metadata found");const n={...s,securityAlertResponse:t};this.updateTransaction(n,`${Kt}:updatesecurityAlertResponse - securityAlertResponse updated`)}wipeTransactions({address:e,chainId:t}={}){if(!t&&!e)return void this.update(e=>{e.transactions=[]});const s=this.state.transactions.filter(({chainId:s,txParams:a,type:n})=>{if(!(!t||t===s))return!0;return!(!e||a.from?.toLowerCase()===e.toLowerCase()||n===At.TransactionType.incoming&&a.to?.toLowerCase()===e.toLowerCase())});this.update(e=>{e.transactions=et(this,a,"m",Z).call(this,s)})}updateTransactionSendFlowHistory(e,t,s){return et(this,a,"m",ne).call(this,e)}async confirmExternalTransaction(e,t,s){const n=et(this,a,"m",he).call(this,e);try{const e=n.id,r={...n,status:At.TransactionStatus.confirmed,txReceipt:t};s&&(r.baseFeePerGas=s),et(this,a,"m",fe).call(this,e),this.updateTransaction(r,`${Kt}:confirmExternalTransaction - Add external transaction`),et(this,a,"m",_e).call(this,r),et(this,a,"m",Ie).call(this,r).catch(e=>{throw(0,yt.projectLogger)("Error while updating post balance",e),e}),this.messenger.publish(`${Kt}:transactionConfirmed`,r)}catch(e){console.error("Failed to confirm external transaction",e)}}updateTransactionGasFees(e,{defaultGasEstimates:t,estimateUsed:s,estimateSuggested:n,gas:r,gasLimit:o,gasPrice:i,maxPriorityFeePerGas:c,maxFeePerGas:l,originalGasEstimate:d,userEditedGasLimit:m,userFeeLevel:u}){const h=et(this,a,"m",ae).call(this,e);if(!h)throw new Error("Cannot update transaction as no transaction metadata found");(0,Wt.validateIfTransactionUnapprovedOrSubmitted)(h,"updateTransactionGasFees");const f=(0,dt.cloneDeep)(h),p=h.gasFeeEstimates,g=et(this,S,"f").call(this,h),k=u,b=Object.values(At.GasFeeEstimateLevel).includes(k),w=p&&g&&b;w&&(0,wt.updateTransactionGasEstimates)({txMeta:f,userFeeLevel:k});const _={gas:r,gasLimit:o};w?Object.assign(_,{gasPrice:f.txParams.gasPrice,maxPriorityFeePerGas:f.txParams.maxPriorityFeePerGas,maxFeePerGas:f.txParams.maxFeePerGas}):Object.assign(_,{gasPrice:i,maxPriorityFeePerGas:c,maxFeePerGas:l});const T={txParams:(0,dt.pickBy)(_),defaultGasEstimates:t,estimateUsed:s,estimateSuggested:n,originalGasEstimate:d,userEditedGasLimit:m,userFeeLevel:k},E=(0,dt.pickBy)(T);return et(this,a,"m",Le).call(this,{transactionId:e,skipResimulateCheck:!0},e=>{const{txParams:t,...s}=E;Object.assign(e,s),t&&Object.assign(e.txParams,t)}),et(this,a,"m",ae).call(this,e)}updatePreviousGasParams(e,{gasLimit:t,maxFeePerGas:s,maxPriorityFeePerGas:n}){const r=et(this,a,"m",ae).call(this,e);if(!r)throw new Error("Cannot update transaction as no transaction metadata found");(0,Wt.validateIfTransactionUnapprovedOrSubmitted)(r,"updatePreviousGasParams");const o={previousGas:{gasLimit:t,maxFeePerGas:s,maxPriorityFeePerGas:n}};o.previousGas=(0,dt.pickBy)(o.previousGas);const i=(0,dt.merge)({},r,o);return this.updateTransaction(i,`${Kt}:updatePreviousGasParams - Previous gas values updated`),et(this,a,"m",ae).call(this,e)}async getNonceLock(e,t){return et(this,N,"f").getNonceLock(e,t)}async updateEditableParams(e,{containerTypes:t,data:s,from:n,gas:r,gasPrice:o,maxFeePerGas:i,maxPriorityFeePerGas:c,to:l,updateType:d,value:m}){const u=et(this,a,"m",ae).call(this,e);if(!u)throw new Error("Cannot update editable params as no transaction metadata found");(0,Wt.validateIfTransactionUnapproved)(u,"updateEditableParams");const h={txParams:{data:s,from:n,to:l,value:m,gas:r,gasPrice:o,maxFeePerGas:i,maxPriorityFeePerGas:c}};h.txParams=(0,dt.pickBy)(h.txParams);const f=(0,dt.merge)({},u,h),{networkClientId:p}=u,g=et(this,a,"m",de).call(this,{networkClientId:p}),k=new nt.default(g);if(!1!==d){const{type:e}=await(0,qt.determineTransactionType)(f.txParams,k);f.type=e}return t&&(f.containerTypes=t),await(0,Ot.updateTransactionLayer1GasFee)({layer1GasFeeFlows:et(this,C,"f"),messenger:this.messenger,provider:g,transactionMeta:f}),this.updateTransaction(f,`Update Editable Params for ${e}`),et(this,a,"m",ae).call(this,e)}setTransactionActive(e,t){if(!et(this,a,"m",ae).call(this,e))throw new Error(`Transaction with id ${e} not found`);et(this,a,"m",Le).call(this,{transactionId:e,skipValidation:!0,skipResimulateCheck:!0},e=>{e.isActive=t})}async approveTransactionsWithSameNonce(e=[],{hasNonce:t}={}){if((0,yt.projectLogger)("Approving transactions with same nonce",{transactions:e}),0===e.length)return"";const s=e[0],{chainId:n}=s,r=et(this,a,"m",ce).call(this,{chainId:n}),o=(0,Gt.prepareTransaction)(n,s),c=(0,Gt.serializeTransaction)(o);if(et(this,i,"f").has(c))return"";let l,d;et(this,i,"f").add(c);try{const n=s.from;d=!0!==t?await this.getNonceLock(n,r):undefined;const o=d?(0,ct.add0x)(d.nextNonce.toString(16)):s.nonce;d&&(0,yt.projectLogger)("Using nonce from nonce tracker",o,d.nonceDetails),l=await Promise.all(e.map(e=>(e.nonce=o,et(this,a,"m",W).call(this,e.chainId,e))))}catch(e){throw(0,yt.projectLogger)("Error while signing transactions with same nonce",e),e}finally{d?.releaseLock(),et(this,i,"f").delete(c)}return l}updateCustodialTransaction(e){const{transactionId:t,errorMessage:s,hash:n,status:r,gasLimit:o,gasPrice:i,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:d,type:m}=e,u=et(this,a,"m",ae).call(this,t);if(!u)throw new Error("Cannot update custodial transaction as no transaction metadata found");if(r&&![At.TransactionStatus.submitted,At.TransactionStatus.signed,At.TransactionStatus.failed].includes(r))throw new Error(`Cannot update custodial transaction with status: ${r}`);const h=(0,dt.merge)({},u,(0,dt.pickBy)({hash:n,status:r}));return h.status===At.TransactionStatus.submitted&&(h.submittedTime=(new Date).getTime()),h.status===At.TransactionStatus.failed&&(h.error=(0,Wt.normalizeTxError)(new Error(s))),h.txParams=(0,dt.merge)({},h.txParams,(0,dt.pickBy)({gasLimit:o,gasPrice:i,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:d,type:m})),m===At.TransactionEnvelopeType.legacy&&(delete h.txParams.maxFeePerGas,delete h.txParams.maxPriorityFeePerGas),this.updateTransaction(h,`${Kt}:updateCustodialTransaction - Custodial transaction updated`),r&&[At.TransactionStatus.submitted,At.TransactionStatus.failed].includes(r)&&(this.messenger.publish(`${Kt}:transactionFinished`,h),et(this,I,"f").emit(`${h.id}:finished`,h)),h}getTransactions({initialList:e,limit:t,searchCriteria:s={}}={}){const a=(0,dt.mapValues)(s,e=>"function"==typeof e?e:t=>t===e),n=e??this.state.transactions,r=(0,dt.sortBy)((0,dt.pickBy)(n,e=>{for(const[t,s]of Object.entries(a))if(t in e.txParams){if(!1===s(e.txParams[t]))return!1}else if(!1===s(e[t]))return!1;return!0}),"time");if(t!==undefined){const e=new Set,s=[];for(let a=r.length-1;a>-1;a--){const n=r[a],{nonce:o}=n.txParams;if(!e.has(o)){if(!(e.size<t))continue;e.add(o)}s.unshift(n)}return s}return r}async estimateGasFee({transactionParams:e,chainId:t,networkClientId:s}){const{id:a,provider:n}=et(this,N,"f").getNetworkClient({chainId:t,networkClientId:s}),r={txParams:e,chainId:t,networkClientId:a},o=(0,Mt.getGasFeeFlow)(r,et(this,m,"f"),this.messenger),i=new nt.default(n),c=await et(this,g,"f").call(this,{networkClientId:a});return o.getGasFees({ethQuery:i,gasFeeControllerData:c,messenger:this.messenger,transactionMeta:r})}async getLayer1GasFee({transactionParams:e,chainId:t,networkClientId:s}){const n=et(this,a,"m",de).call(this,{chainId:t,networkClientId:s});return await(0,Ot.getTransactionLayer1GasFee)({layer1GasFeeFlows:et(this,C,"f"),messenger:this.messenger,provider:n,transactionMeta:{txParams:e,chainId:t}})}clearUnapprovedTransactions(){const e=this.state.transactions.filter(({status:e})=>e!==At.TransactionStatus.unapproved);this.update(t=>{t.transactions=et(this,a,"m",Z).call(this,e)})}abortTransactionSigning(e){if(!et(this,a,"m",ae).call(this,e))throw new Error("Cannot abort signing as no transaction metadata found");const t=et(this,B,"f").get(e);if(!t)throw new Error("Cannot abort signing as transaction is not waiting for signing");t(),et(this,B,"f").delete(e)}async updateAtomicBatchData({transactionId:e,transactionIndex:t,transactionData:s}){(0,yt.projectLogger)("Updating atomic batch data",{transactionId:e,transactionIndex:t,transactionData:s});const n=et(this,a,"m",Le).call(this,{transactionId:e},e=>{const{nestedTransactions:a,txParams:n}=e,r=n.from,o=a?.[t];if(!o)throw new Error(`Nested transaction not found with index - ${t}`);o.data=s;const i=(0,Ct.generateEIP7702BatchTransaction)(r,a);e.txParams.data=i.data}),r=(0,dt.cloneDeep)({...n,txParams:{...n.txParams,gas:undefined}});return await et(this,a,"m",We).call(this,r),et(this,a,"m",Le).call(this,{transactionId:e},e=>{e.txParams.gas=r.txParams.gas,e.simulationFails=r.simulationFails,e.gasLimitNoBuffer=r.gasLimitNoBuffer}),n.txParams.data}updateBatchTransactions({transactionId:e,batchTransactions:t}){(0,yt.projectLogger)("Updating batch transactions",{transactionId:e,batchTransactions:t}),et(this,a,"m",Le).call(this,{transactionId:e},e=>{e.batchTransactions=t})}updateSelectedGasFeeToken(e,t){et(this,a,"m",Le).call(this,{transactionId:e},e=>{const s=e.gasFeeTokens?.some(e=>e.tokenAddress.toLowerCase()===t?.toLowerCase());if(t&&!s)throw new Error(`No matching gas fee token found with address - ${t}`);e.selectedGasFeeToken=t})}updateRequiredTransactionIds({transactionId:e,requiredTransactionIds:t,append:s}){et(this,a,"m",Le).call(this,{transactionId:e},e=>{const{requiredTransactionIds:a}=e;e.requiredTransactionIds=[...a&&!1!==s?a:[],...t]})}emulateNewTransaction(e){const t=this.state.transactions.find(t=>t.id===e);t&&(t.type===At.TransactionType.swap?this.messenger.publish("TransactionController:transactionNewSwap",{transactionMeta:t}):t.type===At.TransactionType.swapApproval&&this.messenger.publish("TransactionController:transactionNewSwapApproval",{transactionMeta:t}))}emulateTransactionUpdate(e){const t={...e,txParams:{...e.txParams,from:this.messenger.call("AccountsController:getSelectedAccount").address}};this.state.transactions.some(e=>e.id===t.id)||this.update(e=>{e.transactions.push(t)}),this.updateTransaction(t,"Generated from user operation"),this.messenger.publish("TransactionController:transactionStatusUpdated",{transactionMeta:t})}async getGasFeeTokens(e){const{chainId:t,data:s,from:n,to:r,value:o}=e,i=et(this,a,"m",le).call(this,{chainId:t}),c={chainId:t,delegationAddress:await(0,Ct.getDelegationAddress)(n,i),isExternalSign:!0,txParams:{data:s,from:n,to:r,value:o}};return(await et(this,a,"m",Je).call(this,c)).gasFeeTokens}}s.TransactionController=zt,n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,h=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakMap,k=new WeakMap,b=new WeakMap,w=new WeakMap,_=new WeakMap,T=new WeakMap,E=new WeakMap,I=new WeakMap,S=new WeakMap,x=new WeakMap,y=new WeakMap,A=new WeakMap,v=new WeakMap,P=new WeakMap,C=new WeakMap,j=new WeakMap,N=new WeakMap,D=new WeakMap,R=new WeakMap,F=new WeakMap,L=new WeakMap,M=new WeakMap,O=new WeakMap,B=new WeakMap,G=new WeakMap,H=new WeakMap,U=new WeakMap,ye=new WeakMap,a=new WeakSet,q=async function({actionId:e,afterSubmit:t,estimatedBaseFee:s,gasValues:n,label:r,prepareTransactionParams:o,rate:i,transactionId:c,transactionType:l}){n&&(n=(0,Wt.normalizeGasFeeValues)(n),(0,Wt.validateGasValues)(n)),(0,yt.projectLogger)(`Creating ${r} transaction`,c,n);const d=et(this,a,"m",ae).call(this,c);if(!d)return;if(!et(this,O,"f"))throw new Error("No sign method defined.");const m=(0,Ht.getTransactionParamsWithIncreasedGasFee)(d.txParams,i,n);o?.(m);const u=(0,Gt.prepareTransaction)(d.chainId,m),h=await et(this,O,"f").call(this,u,d.txParams.from),f=et(this,a,"m",ke).call(this,d,h),p=(0,Gt.serializeTransaction)(h),g=m.maxFeePerGas??m.gasPrice,k=m.maxFeePerGas?f.txParams.maxFeePerGas:f.txParams.gasPrice;(0,yt.projectLogger)(`Submitting ${r} transaction`,{oldFee:k,newFee:g,txParams:m});const{networkClientId:b}=d,w=et(this,a,"m",le).call(this,{networkClientId:b}),_={...f,actionId:e,estimatedBaseFee:s,id:(0,mt.v1)(),originalGasEstimate:d.txParams.gas,originalType:d.type,rawTx:p,time:Date.now(),txParams:m,type:l},T=await et(this,a,"m",Ne).call(this,w,{..._,origin:r});_.hash=T,et(this,a,"m",$).call(this,_),this.messenger.publish(`${Kt}:transactionApproved`,{transactionMeta:_,actionId:e}),this.messenger.publish(`${Kt}:transactionSubmitted`,{transactionMeta:_,actionId:e}),t?.(_)},W=async function(e,t){if(!et(this,O,"f"))throw new Error("No sign method defined.");const s=(0,Wt.normalizeTransactionParams)(t),a=(0,Wt.isEIP1559Transaction)(s)?At.TransactionEnvelopeType.feeMarket:At.TransactionEnvelopeType.legacy,n={...s,type:a,gasLimit:s.gas,chainId:e},{from:r}=n,o=(0,Gt.prepareTransaction)(e,n),i=await et(this,O,"f").call(this,o,r);return(0,Gt.serializeTransaction)(i)},$=function(e){(0,$t.validateTxParams)(e.txParams),this.update(t=>{t.transactions=et(this,a,"m",Z).call(this,[...t.transactions,e])})},V=async function(e,{traceContext:t}={}){const s=e.txParams.type!==At.TransactionEnvelopeType.legacy&&await et(this,a,"m",be).call(this,e.networkClientId),{networkClientId:n}=e,r=et(this,a,"m",le).call(this,{networkClientId:n}),o=et(this,a,"m",de).call(this,{networkClientId:n});await et(this,U,"f").call(this,{name:"Update Gas",parentContext:t},async()=>{await et(this,a,"m",We).call(this,e)}),await et(this,U,"f").call(this,{name:"Update Gas Fees",parentContext:t},async()=>await(0,Lt.updateGasFees)({eip1559:s,ethQuery:r,gasFeeFlows:et(this,m,"f"),getGasFeeEstimates:et(this,g,"f"),getSavedGasFees:et(this,w,"f").bind(this),messenger:this.messenger,txMeta:e})),await et(this,U,"f").call(this,{name:"Update Layer 1 Gas Fees",parentContext:t},async()=>await(0,Ot.updateTransactionLayer1GasFee)({layer1GasFeeFlows:et(this,C,"f"),messenger:this.messenger,provider:o,transactionMeta:e}))},K=function(){this.clearUnapprovedTransactions(),et(this,a,"m",Y).call(this)},Y=function(){const e=this.state.transactions.filter(e=>[At.TransactionStatus.approved,At.TransactionStatus.signed].includes(e.status));for(const t of e){const e=t.requiredTransactionIds??[],s=e.length>0&&e.every(e=>{const t=et(this,a,"m",ae).call(this,e);return t?.status===At.TransactionStatus.confirmed})?"Transaction incomplete at startup with all required transactions confirmed":"Transaction incomplete at startup";et(this,a,"m",Qe).call(this,t,new Error(s));for(const t of e){const e=et(this,a,"m",ae).call(this,t);e&&!et(this,a,"m",ee).call(this,e.status)&&et(this,a,"m",Qe).call(this,e,new Error("Parent transaction incomplete at startup"))}}},Q=async function(e,{actionId:t,publishHook:s,requireApproval:n,shouldShowRequest:r=!0,traceContext:o}){const{id:i,isStateOnly:c}=e;if(c)return et(this,a,"m",Le).call(this,{transactionId:i,skipValidation:!0},e=>{e.status=At.TransactionStatus.submitted,e.submittedTime=(new Date).getTime()}),"";let l;const{meta:d,isCompleted:m}=et(this,a,"m",oe).call(this,i),u=m?Promise.resolve(d):et(this,a,"m",ge).call(this,i);if(d&&!m)try{if(!1!==n){const t=await et(this,U,"f").call(this,{name:"Await Approval",parentContext:o},t=>et(this,a,"m",se).call(this,e,{shouldShowRequest:r,traceContext:t}));l=t.resultCallbacks;const s=t.value,n=s?.txMeta;n&&((0,yt.projectLogger)("Updating transaction with approval data",{customNonce:n.customNonceValue,params:n.txParams}),this.updateTransaction(n,"TransactionController#processApproval - Updated with approval data"))}const{isCompleted:c}=et(this,a,"m",oe).call(this,i);if(!c){const e=await et(this,a,"m",z).call(this,i,o,s);e===Yt.SkippedViaBeforePublishHook&&l&&l.success();const n=et(this,a,"m",ae).call(this,i);e===Yt.Approved&&this.messenger.publish(`${Kt}:transactionApproved`,{transactionMeta:n,actionId:t})}}catch(e){const s=e,{isCompleted:n}=et(this,a,"m",oe).call(this,i);n||(et(this,a,"m",Ke).call(this,s)?et(this,a,"m",Ye).call(this,i,t,s):et(this,a,"m",Qe).call(this,d,s,t))}finally{et(this,G,"f").delete(i)}const h=await u;switch(h?.status){case At.TransactionStatus.failed:{const e=h.error;throw l?.error(e),it.rpcErrors.internal(e.message)}case At.TransactionStatus.submitted:return l?.success(),h.hash;default:{const e=it.rpcErrors.internal(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(h??i)}`);throw l?.error(e),e}}},z=async function(e,t,s){let n,r,o=et(this,a,"m",ne).call(this,e);(0,yt.projectLogger)("Approving transaction",o);try{if(!et(this,O,"f"))return et(this,a,"m",Qe).call(this,o,new Error("No sign method defined.")),Yt.NotApproved;if(!o.chainId)return et(this,a,"m",Qe).call(this,o,new Error("No chainId defined.")),Yt.NotApproved;if(et(this,i,"f").has(e))return(0,yt.projectLogger)("Skipping approval as signing in progress",e),Yt.NotApproved;et(this,i,"f").add(e),n=()=>et(this,i,"f").delete(e);const{networkClientId:c}=o,d=et(this,a,"m",le).call(this,{networkClientId:c}),[m,u]=await(0,Bt.getNextNonce)(o,e=>et(this,N,"f").getNonceLock(e,o.networkClientId));r=u,o=et(this,a,"m",Le).call(this,{transactionId:e},e=>{const{chainId:t,txParams:s}=e,{gas:a,type:n}=s;e.status=At.TransactionStatus.approved,e.txParams.chainId=t,e.txParams.gasLimit=a,e.txParams.nonce=m,!n&&(0,Wt.isEIP1559Transaction)(s)&&(e.txParams.type=At.TransactionEnvelopeType.feeMarket)}),et(this,a,"m",_e).call(this,o);const h=await et(this,U,"f").call(this,{name:"Sign",parentContext:t},()=>et(this,a,"m",we).call(this,o));if(o=et(this,a,"m",ne).call(this,e),!await et(this,l,"f").call(this,o))return(0,yt.projectLogger)("Skipping publishing transaction based on hook"),this.messenger.publish(`${Kt}:transactionPublishingSkipped`,o),Yt.SkippedViaBeforePublishHook;if(!h&&!o.isExternalSign)return Yt.NotApproved;let f;const p=o.type===At.TransactionType.swap;p&&((0,yt.projectLogger)("Determining pre-transaction balance"),f=await(0,at.query)(d,"getBalance",[o.txParams.from])),(0,yt.projectLogger)("Publishing transaction",o.txParams),r?.(),r=undefined;let g=et(this,a,"m",Xe).bind(this,{ethQuery:d,publishHookOverride:s,traceContext:t});if(o.batchTransactions?.length){(0,yt.projectLogger)("Found batch transactions",o.batchTransactions);g=new xt.ExtraTransactionsPublishHook({addTransactionBatch:this.addTransactionBatch.bind(this),getTransaction:et(this,a,"m",ne).bind(this),originalPublishHook:g}).getHook()}const{transactionHash:k}=await g(o,h??"0x");return o=et(this,a,"m",Le).call(this,{transactionId:e},e=>{e.hash=k,e.status=At.TransactionStatus.submitted,e.submittedTime=(new Date).getTime(),p&&(e.preTxBalance=f,(0,yt.projectLogger)("Updated pre-transaction balance",f))}),this.messenger.publish(`${Kt}:transactionSubmitted`,{transactionMeta:o}),this.messenger.publish(`${Kt}:transactionFinished`,o),et(this,I,"f").emit(`${e}:finished`,o),et(this,a,"m",_e).call(this,o),Yt.Approved}catch(e){return et(this,a,"m",Qe).call(this,o,e),Yt.NotApproved}finally{n?.(),r?.()}},X=async function(e,t,{skipSubmitHistory:s}={}){try{const n=await(0,at.query)(e,"sendRawTransaction",[t.rawTx]);return!0!==s&&et(this,a,"m",qe).call(this,t,n),n}catch(e){const t=e,s=t?.data?.message??t?.message??String(e);throw new Error(s)}},J=function(e,t,s){const n=et(this,a,"m",ae).call(this,e);if(!n)return;et(this,a,"m",Ve).call(this,e);const r={...n,status:At.TransactionStatus.rejected,error:(0,Wt.normalizeTxError)(s??it.providerErrors.userRejectedRequest())};this.messenger.publish(`${Kt}:transactionFinished`,r),et(this,I,"f").emit(`${n.id}:finished`,r),this.messenger.publish(`${Kt}:transactionRejected`,{transactionMeta:r,actionId:t}),et(this,a,"m",_e).call(this,r)},Z=function(e){const t=new Set,s=(0,Nt.getTransactionHistoryLimit)(this.messenger),n=[...e].sort((e,t)=>e.time>t.time?-1:1).filter(e=>{const{chainId:n,status:r,txParams:o,time:i}=e;if(o){const e=`${String(o.nonce)}-${(0,at.convertHexToDecimal)(n)}-${new Date(i).toDateString()}`;if(t.has(e))return!0;if(t.size<s||!et(this,a,"m",ee).call(this,r))return t.add(e),!0}return!1});return n.reverse(),n},ee=function(e){return e===At.TransactionStatus.rejected||e===At.TransactionStatus.confirmed||e===At.TransactionStatus.failed||e===At.TransactionStatus.dropped},te=function(e){return[At.TransactionStatus.confirmed,At.TransactionStatus.failed,At.TransactionStatus.rejected,At.TransactionStatus.submitted].includes(e)},se=async function(e,{shouldShowRequest:t,traceContext:s}){const n=et(this,a,"m",re).call(this,e),{origin:r}=e,o=at.ApprovalType.Transaction,i={txId:e.id};return await et(this,U,"f").call(this,{name:"Notification Display",id:n,parentContext:s}),await this.messenger.call("ApprovalController:addRequest",{id:n,origin:r??at.ORIGIN_METAMASK,type:o,requestData:i,expectsResult:!0},t)},ae=function(e){const{transactions:t}=this.state;return t.find(({id:t})=>t===e)},ne=function(e,t="TransactionController"){const s=et(this,a,"m",ae).call(this,e);if(!s)throw new Error(`${t}: No transaction found with id ${e}`);return s},re=function(e){return String(e.id)},oe=function(e){const t=et(this,a,"m",ae).call(this,e);if(!t)return{meta:undefined,isCompleted:!1};return{meta:t,isCompleted:et(this,a,"m",te).call(this,t.status)}},ie=function(e){return et(this,N,"f").getNetworkClient({networkClientId:e}).configuration.chainId},ce=function({chainId:e,networkClientId:t}){return t||et(this,N,"f").getNetworkClient({chainId:e}).id},le=function({chainId:e,networkClientId:t}){return new nt.default(et(this,a,"m",de).call(this,{chainId:e,networkClientId:t}))},de=function({chainId:e,networkClientId:t}){return et(this,N,"f").getNetworkClient({chainId:e,networkClientId:t}).provider},me=function(e){if(!e.length)return;const t=[];for(const s of e){const{chainId:e}=s;try{const n=et(this,a,"m",ce).call(this,{chainId:e});t.push({...s,networkClientId:n})}catch(t){(0,yt.projectLogger)("Failed to get network client ID for incoming transaction",{chainId:e,error:t})}}this.update(e=>{const{transactions:s}=e;e.transactions=et(this,a,"m",Z).call(this,[...t,...s]),(0,yt.projectLogger)("Added incoming transactions to state",t.length,t)}),this.messenger.publish(`${Kt}:incomingTransactionsReceived`,t)},ue=function(e,t){if(!t||t===at.ORIGIN_METAMASK)return undefined;const{gasPrice:s,maxFeePerGas:a,maxPriorityFeePerGas:n,gas:r}=e;if(s===undefined&&a===undefined&&n===undefined&&r===undefined)return undefined;const o={};return s!==undefined?o.gasPrice=s:a===undefined&&n===undefined||(o.maxFeePerGas=a,o.maxPriorityFeePerGas=n),r!==undefined&&(o.gas=r),o},he=function(e){const{chainId:t}=e,{transactions:s}=this.state,n=e?.txParams?.from,r=s.filter(e=>e.txParams.from===n&&e.chainId===t),o=r.filter(e=>e.status===At.TransactionStatus.confirmed),i=r.filter(e=>e.status===At.TransactionStatus.submitted);return(0,jt.validateConfirmedExternalTransaction)(e,o,i),this.update(t=>{t.transactions=et(this,a,"m",Z).call(this,[...t.transactions,e])}),e},fe=function(e){const t=et(this,a,"m",ae).call(this,e);if(!t)return;const s=t.txParams?.nonce,n=t.txParams?.from,{chainId:r}=t,o=this.state.transactions.filter(t=>t.id!==e&&t.txParams.from===n&&s&&t.txParams.nonce===s&&t.chainId===r&&t.type!==At.TransactionType.incoming&&t.isTransfer===undefined),i=o.map(e=>e.id);if(0!==o.length){this.update(e=>{for(const s of e.transactions)i.includes(s.id)&&(s.replacedBy=t?.hash,s.replacedById=t?.id)});for(const e of this.state.transactions)i.includes(e.id)&&e.status!==At.TransactionStatus.failed&&et(this,a,"m",pe).call(this,e)}},pe=function(e){const t={...e,status:At.TransactionStatus.dropped};this.messenger.publish(`${Kt}:transactionDropped`,{transactionMeta:t}),this.updateTransaction(t,"TransactionController#setTransactionStatusDropped - Transaction dropped"),et(this,a,"m",_e).call(this,t)},ge=async function(e){return new Promise(t=>{et(this,I,"f").once(`${e}:finished`,e=>{t(e)})})},ke=function(e,t){const s=(0,dt.cloneDeep)(e);for(const e of["r","s","v"]){const a=t[e];a!==undefined&&null!==a&&(s[e]=(0,ct.add0x)(a.toString(16)))}return s},be=async function(e){const t=await et(this,f,"f").call(this,e),s=await et(this,h,"f").call(this);return t&&s},we=async function(e){let t=e;const{id:s}=t;(0,yt.projectLogger)("Calling before sign hook",t);const{updateTransaction:n}=await et(this,d,"f").call(this,{transactionMeta:t})??{};n&&(et(this,a,"m",Le).call(this,{transactionId:s,skipResimulateCheck:!0},n),(0,yt.projectLogger)("Updated transaction after before sign hook")),t=et(this,a,"m",ne).call(this,s);const{networkClientId:o}=t,c=et(this,a,"m",le).call(this,{networkClientId:o});await(0,Ft.checkGasFeeTokenBeforePublish)({ethQuery:c,fetchGasFeeTokens:async e=>(await et(this,a,"m",Je).call(this,e)).gasFeeTokens,transaction:t,updateTransaction:(e,t)=>et(this,a,"m",Le).call(this,{transactionId:e},t)}),t=et(this,a,"m",ne).call(this,s);const{chainId:l,isExternalSign:m,txParams:h}=t;if(m)return(0,yt.projectLogger)("Skipping sign as signed externally"),undefined;const{authorizationList:f,from:p}=h,g=await(0,Ct.signAuthorizationList)({authorizationList:f,messenger:this.messenger,transactionMeta:t});g&&et(this,a,"m",Le).call(this,{transactionId:s},e=>{e.txParams.authorizationList=g}),t=et(this,a,"m",ne).call(this,s);const k=et(this,a,"m",ne).call(this,s),{txParams:b}=k,w=(0,Gt.prepareTransaction)(l,b);et(this,i,"f").add(s),(0,yt.projectLogger)("Signing transaction",b);const _=await new Promise((e,t)=>{et(this,O,"f")?.call(this,w,p,...et(this,u,"f").call(this,k)).then(e,t),et(this,B,"f").set(s,()=>t(new Error("Signing aborted by user")))});if(et(this,B,"f").delete(s),!_)return(0,yt.projectLogger)("Skipping signed status as no signed transaction"),undefined;const T=(0,dt.cloneDeep)(k);if(!et(this,r,"f").call(this,T,_))return this.updateTransaction(T,"TransactionController#signTransaction - Update after sign"),(0,yt.projectLogger)("Skipping signed status based on hook"),undefined;const E={...et(this,a,"m",ke).call(this,T,_),status:At.TransactionStatus.signed,txParams:b};this.updateTransaction(E,"TransactionController#approveTransaction - Transaction signed"),et(this,a,"m",_e).call(this,E);const I=(0,Gt.serializeTransaction)(_),S=(0,dt.merge)({},E,{rawTx:I});return this.updateTransaction(S,"TransactionController#approveTransaction - RawTransaction added"),I},_e=function(e){this.messenger.publish(`${Kt}:transactionStatusUpdated`,{transactionMeta:e})},Te=function(e,t,s){return(0,Bt.getAndFormatTransactionsForNonceTracker)(s,t,e,this.state.transactions)},Ee=function(e){(0,yt.projectLogger)("Processing confirmed transaction",e.id),et(this,a,"m",fe).call(this,e.id),this.messenger.publish(`${Kt}:transactionConfirmed`,e),et(this,a,"m",_e).call(this,e),et(this,a,"m",Ie).call(this,e).catch(e=>{throw(0,yt.projectLogger)("Error while updating post balance",e),e})},Ie=async function(e){try{const{networkClientId:t,type:s}=e;if(s!==At.TransactionType.swap)return;const n=et(this,a,"m",le).call(this,{networkClientId:t}),{updatedTransactionMeta:r,approvalTransactionMeta:o}=await(0,Ut.updatePostTransactionBalance)(e,{ethQuery:n,getTransaction:et(this,a,"m",ae).bind(this),updateTransaction:this.updateTransaction.bind(this)});this.messenger.publish(`${Kt}:postTransactionBalanceUpdated`,{transactionMeta:r,approvalTransactionMeta:o})}catch(e){(0,yt.projectLogger)("Error while updating post transaction balance",e)}},Se=function({provider:e,blockTracker:t,chainId:s}){return new ot.NonceTracker({provider:e,blockTracker:t,getPendingTransactions:et(this,a,"m",je).bind(this,s),getConfirmedTransactions:et(this,a,"m",Te).bind(this,[At.TransactionStatus.confirmed],s)})},xe=function({provider:e,blockTracker:t,chainId:s,networkClientId:n}){const r=new nt.default(e),o=new It.PendingTransactionTracker({blockTracker:t,getChainId:()=>s,getEthQuery:()=>r,getGlobalLock:()=>et(this,N,"f").acquireNonceLockForChainIdKey({chainId:s}),getNetworkClientId:()=>n,getTransactions:()=>this.state.transactions,hooks:{beforeCheckPendingTransaction:et(this,c,"f").bind(this)},isResubmitEnabled:et(this,D,"f").isResubmitEnabled,isTimeoutEnabled:et(this,P,"f"),messenger:this.messenger,publishTransaction:(e,t)=>et(this,a,"m",X).call(this,e,t,{skipSubmitHistory:!0})});return et(this,a,"m",Ce).call(this,o),o},Ae=function(){et(this,N,"f").stopAllTracking()},ve=function(e){e.hub.on("transactions",et(this,a,"m",me).bind(this))},Pe=function(e){e.hub.removeAllListeners("transaction-confirmed"),e.hub.removeAllListeners("transaction-dropped"),e.hub.removeAllListeners("transaction-failed"),e.hub.removeAllListeners("transaction-updated")},Ce=function(e){e.hub.on("transaction-confirmed",et(this,a,"m",Ee).bind(this)),e.hub.on("transaction-dropped",et(this,a,"m",pe).bind(this)),e.hub.on("transaction-failed",et(this,a,"m",Qe).bind(this)),e.hub.on("transaction-updated",this.updateTransaction.bind(this))},je=function(e,t){return[...et(this,a,"m",Te).call(this,[At.TransactionStatus.approved,At.TransactionStatus.signed,At.TransactionStatus.submitted],t,e),...et(this,p,"f").call(this,t,e)]},Ne=async function(e,t){try{return await et(this,a,"m",X).call(this,e,t)}catch(e){if(et(this,a,"m",De).call(this,e))throw new Error("Previous transaction is already confirmed");throw e}},De=function(e){return Boolean(e?.message?.includes("nonce too low"))||Boolean(e?.data?.message?.includes("nonce too low"))},Re=function(){return et(this,H,"f")?[new kt.TestGasFeeFlow]:[new pt.RandomisedEstimationsGasFeeFlow,new ht.LineaGasFeeFlow,new ut.DefaultGasFeeFlow]},Fe=function(){return[new ft.OptimismLayer1GasFeeFlow,new gt.ScrollLayer1GasFeeFlow]},Le=function({transactionId:e,skipValidation:t,skipResimulateCheck:s},n){let r;this.update(a=>{const o=a.transactions.findIndex(({id:t})=>t===e);if(-1===o)throw new Error(`Cannot update transaction as ID not found - ${e}`);let i=a.transactions[o];const c=(0,dt.cloneDeep)(i);i=n(i)??i,!0!==t&&(i.txParams=(0,Wt.normalizeTransactionParams)(i.txParams),(0,$t.validateTxParams)(i.txParams)),!s&&et(this,A,"f").call(this)&&(r=(0,St.shouldResimulate)(c,i)),a.transactions[o]=i});const o=et(this,a,"m",ae).call(this,e);return r?.resimulate&&et(this,a,"m",Me).call(this,o,{blockTime:r.blockTime}).catch(e=>{throw(0,yt.projectLogger)("Error during re-simulation",e),e}),o},Me=async function(e,{blockTime:t,traceContext:s}={}){const{chainId:n,id:r,nestedTransactions:o,networkClientId:i,simulationData:c,txParams:l}=e;let d,m={error:{code:At.SimulationErrorCode.Disabled,message:"Simulation disabled"},tokenBalanceChanges:[]},u=[],h=!1;const f=et(this,G,"f").has(r);if(et(this,A,"f").call(this)&&!f){const r=await et(this,U,"f").call(this,{name:"Simulate",parentContext:s},()=>(0,vt.getBalanceChanges)({blockTime:t,chainId:n,ethQuery:et(this,a,"m",le).call(this,{networkClientId:i}),getSimulationConfig:(t,s)=>et(this,_,"f").call(this,t,{txMeta:e,...s}),nestedTransactions:o,txParams:l}));m=r.simulationData,d=r.gasUsed,t&&c&&(0,St.hasSimulationDataChanged)(c,m)&&(m={...m,isUpdatedAfterSecurityCheck:!0});const f=await et(this,a,"m",Je).call(this,e);u=f?.gasFeeTokens??[],h=f?.isGasFeeSponsored??!1}if(!et(this,a,"m",ae).call(this,r))return void(0,yt.projectLogger)("Cannot update simulation data as transaction not found",r,m);const p=et(this,a,"m",Le).call(this,{transactionId:r,skipResimulateCheck:Boolean(t)},e=>{e.gasFeeTokens=u,e.isGasFeeSponsored=h,e.gasUsed=d,f||(e.simulationData=m)});(0,yt.projectLogger)("Updated simulation data",r,p),await et(this,a,"m",ze).call(this,p)},Oe=function({transactionId:e,gasFeeEstimates:t,gasFeeEstimatesLoaded:s,layer1GasFee:n}){et(this,a,"m",Le).call(this,{transactionId:e},e=>{(0,wt.updateTransactionGasProperties)({txMeta:e,gasFeeEstimates:t,gasFeeEstimatesLoaded:s,isTxParamsGasFeeUpdatesEnabled:et(this,S,"f"),layer1GasFee:n})})},Be=function({transactionBatchId:e,gasFeeEstimates:t}){et(this,a,"m",Ge).call(this,e,e=>({...e,gasFeeEstimates:t}))},Ge=function(e,t){this.update(s=>{const a=s.transactionBatches.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Cannot update batch, ID not found - ${e}`);const n=s.transactionBatches[a],r=t(n);s.transactionBatches[a]=r??n})},He=function(){return this.messenger.call("AccountsController:getSelectedAccount")},Ue=function(){const e=this.messenger.call("AccountsController:getState");return Object.values(e.internalAccounts?.accounts??{}).filter(e=>"eip155:eoa"===e.type).map(e=>e.address)},qe=function(e,t){const{chainId:s,networkClientId:a,origin:n,rawTx:r,txParams:o}=e,{networkConfigurationsByChainId:i}=et(this,k,"f").call(this),c=i[s],l=c?.rpcEndpoints.find(e=>e.networkClientId===a),d=l?.url,m={chainId:s,hash:t,networkType:l?.name??a,networkUrl:d,origin:n,rawTransaction:r,time:Date.now(),transaction:o};(0,yt.projectLogger)("Updating submit history",m);const u=(0,Nt.getSubmitHistoryLimit)(this.messenger);this.update(e=>{const{submitHistory:t}=e;t.length>=u&&t.pop(),t.unshift(m)})},We=async function(e){const{chainId:t,networkClientId:s}=e,n=et(this,N,"f").getNetworkClient({networkClientId:s}).configuration.type===rt.NetworkClientType.Custom,r=et(this,a,"m",le).call(this,{networkClientId:s});await(0,Rt.updateGas)({chainId:t,ethQuery:r,isCustomNetwork:n,isSimulationEnabled:et(this,A,"f").call(this),getSimulationConfig:et(this,_,"f"),messenger:this.messenger,txMeta:e})},$e=function(){this.messenger.registerMethodActionHandlers(this,Qt)},Ve=function(e){this.update(t=>{const s=t.transactions.filter(({id:t})=>t!==e);t.transactions=et(this,a,"m",Z).call(this,s)})},Ke=function(e){return[it.errorCodes.provider.userRejectedRequest,$t.ErrorCode.RejectedUpgrade].includes(e.code)},Ye=function(e,t,s){if(et(this,a,"m",J).call(this,e,t,s),s.code===it.errorCodes.provider.userRejectedRequest)throw it.providerErrors.userRejectedRequest({message:"MetaMask Tx Signature: User denied transaction signature.",data:s?.data});throw s},Qe=function(e,t,s){let n;try{n=et(this,a,"m",Le).call(this,{transactionId:e.id,skipValidation:!0},e=>{e.status=At.TransactionStatus.failed,e.error=(0,Wt.normalizeTxError)(t)})}catch(s){(0,yt.projectLogger)("Failed to mark transaction as failed",s),n={...e,status:At.TransactionStatus.failed,error:(0,Wt.normalizeTxError)(t)}}this.messenger.publish(`${Kt}:transactionFailed`,{actionId:s,error:t.message,transactionMeta:n}),et(this,a,"m",_e).call(this,n),this.messenger.publish(`${Kt}:transactionFinished`,n),et(this,I,"f").emit(`${e.id}:finished`,n)},ze=async function(e){(0,yt.projectLogger)("Calling afterSimulate hook",e);const{id:t}=e,s=await et(this,o,"f").call(this,{transactionMeta:e}),{skipSimulation:n,updateTransaction:r}=s??{};if(n?et(this,G,"f").add(t):!1===n&&et(this,G,"f").delete(t),!r)return;const i=et(this,a,"m",Le).call(this,{transactionId:t,skipResimulateCheck:!0},e=>{e.txParamsOriginal=(0,dt.cloneDeep)(e.txParams),r(e)});(0,yt.projectLogger)("Updated transaction with afterSimulate data",i)},Xe=async function({ethQuery:e,publishHookOverride:t,traceContext:s},n,r){let o;return await et(this,U,"f").call(this,{name:"Publish",parentContext:s},async()=>{const s=t??et(this,F,"f");({transactionHash:o}=await s(n,r)),o??(o=await et(this,a,"m",X).call(this,e,{...n,rawTx:r}))}),(0,yt.projectLogger)("Publish successful",o),{transactionHash:o}},Je=async function(e){const{chainId:t}=e;return await(0,Ft.getGasFeeTokens)({chainId:t,getSimulationConfig:et(this,_,"f"),isEIP7702GasFeeTokensEnabled:et(this,x,"f"),messenger:this.messenger,publicKeyEIP7702:et(this,R,"f"),transactionMeta:e})}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/TransactionController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs",{"../errors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/errors.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getAccountTransactions=s.getAccountAddressRelationship=void 0;const a=e("@metamask/controller-utils"),n=e("@metamask/utils"),r=e("../errors.cjs"),o=e("../logger.cjs"),i="https://accounts.api.cx.metamask.io",c=`${i}/v1/accounts/`,l="x-metamask-clientproduct",d="metamask-transaction-controller",m=[1,10,56,137,8453,42161,59144,534352,1329,143,999],u=(0,n.createModuleLogger)(o.projectLogger,"accounts-api");s.getAccountAddressRelationship=async function(e){const{chainId:t,from:s,to:n}=e;if(!m.includes(t))throw u("Unsupported chain ID for account relationship API",t),new r.FirstTimeInteractionError("Unsupported chain ID");const o=`${i}/v1/networks/${t}/accounts/${s}/relationships/${n}`;u("Getting account address relationship",{request:e,url:o});const c={[l]:d},h=await(0,a.successfulFetch)(o,{headers:c});if(204===h.status)return{count:0};const f=await h.json();if(u("Retrieved account address relationship",f),f.error){const{code:e,message:t}=f.error;throw new r.FirstTimeInteractionError(t,e)}return f},s.getAccountTransactions=async function(e){const{address:t,chainIds:s,cursor:n,endTimestamp:r,sortDirection:o,startTimestamp:i,tags:m}=e;let h=`${c}${t}/transactions`;const f=[];if(s){const e=s.join(",");f.push(`networks=${e}`)}i&&f.push(`startTimestamp=${i}`),r&&f.push(`endTimestamp=${r}`),n&&f.push(`cursor=${n}`),o&&f.push(`sortDirection=${o}`),f.length&&(h+=`?${f.join("&")}`),u("Getting account transactions",{request:e,url:h});const p=[d,...m??[]].join("__"),g={[l]:p},k=await(0,a.successfulFetch)(h,{headers:g}),b=await k.json();return u("Retrieved account transactions",b),b}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","../errors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/errors.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.simulateTransactions=void 0;const a=e("@metamask/controller-utils"),n=e("@metamask/utils"),r=e("lodash"),o=e("../constants.cjs"),i=e("../errors.cjs"),c=e("../logger.cjs"),l=(0,n.createModuleLogger)(c.projectLogger,"simulation-api"),d="networks";let m=0;function u(e){return"https://tx-sentinel-{0}.api.cx.metamask.io/".replace("{0}",e)}s.simulateTransactions=async function(e,t){let s=await async function(e){const t=await async function(){const e=`${u("ethereum-mainnet")}${d}`,t=await fetch(e);return t.json()}(),s=(0,a.convertHexToDecimal)(e),n=t[s];if(!n?.confirmations)throw l("Chain is not supported",e),new i.SimulationChainNotSupportedError(e);return u(n.network)}(e);const{newUrl:n,authorization:c}=await t.getSimulationConfig(s)||{};n&&(s=n);const h=m;m+=1;const f=function(e){const t=(0,r.cloneDeep)(e);for(const e of t.transactions){const s=e.to?.toLowerCase();o.DELEGATION_MANAGER_ADDRESSES.includes(s)&&(t.overrides=t.overrides??{},t.overrides[s]={code:o.CODE_DELEGATION_MANAGER_NO_SIGNATURE_ERRORS})}return t}(t);l("Sending request",s,t);const p={"Content-Type":"application/json"};c&&(p.Authorization=c);const g=await fetch(s,{method:"POST",headers:p,body:JSON.stringify({id:String(h),jsonrpc:"2.0",method:"infura_simulateTransactions",params:[f]})}),k=await g.json();if(l("Received response",k),k.error){const{code:e,message:t}=k.error;throw new i.SimulationError(t,e)}return k?.result}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.CODE_DELEGATION_MANAGER_NO_SIGNATURE_ERRORS=s.DELEGATION_MANAGER_ADDRESSES=s.ABI_IERC7821=s.ABI_SIMULATION_ERC721_LEGACY=s.ABI_SIMULATION_ERC20_WRAPPED=s.CHAIN_IDS=void 0,s.CHAIN_IDS={MAINNET:"0x1",GOERLI:"0x5",BASE:"0x2105",BASE_TESTNET:"0x14a33",BSC:"0x38",BSC_TESTNET:"0x61",HYPEREVM:"0x3e7",OPTIMISM:"0xa",OPTIMISM_TESTNET:"0x1a4",OPBNB:"0xcc",OPBNB_TESTNET:"0x15eb",OPTIMISM_SEPOLIA:"0xaa37dc",POLYGON:"0x89",POLYGON_TESTNET:"0x13881",AVALANCHE:"0xa86a",AVALANCHE_TESTNET:"0xa869",FANTOM:"0xfa",FANTOM_TESTNET:"0xfa2",SEPOLIA:"0xaa36a7",LINEA_GOERLI:"0xe704",LINEA_SEPOLIA:"0xe705",LINEA_MAINNET:"0xe708",MOONBEAM:"0x504",MOONBEAM_TESTNET:"0x507",MOONRIVER:"0x505",MONAD:"0x8f",GNOSIS:"0x64",ARBITRUM:"0xa4b1",ZKSYNC_ERA:"0x144",ZORA:"0x76adf1",SCROLL:"0x82750",SCROLL_SEPOLIA:"0x8274f",MEGAETH_TESTNET:"0x18c6",SEI:"0x531"},s.ABI_SIMULATION_ERC20_WRAPPED=[{anonymous:!1,inputs:[{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"wad",type:"uint256"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!1,name:"wad",type:"uint256"}],name:"Withdrawal",type:"event"}],s.ABI_SIMULATION_ERC721_LEGACY=[{anonymous:!1,inputs:[{indexed:!1,name:"_from",type:"address"},{indexed:!1,name:"_to",type:"address"},{indexed:!1,name:"_tokenId",type:"uint256"}],name:"Transfer",type:"event"}],s.ABI_IERC7821=[{type:"function",name:"execute",inputs:[{name:"mode",type:"bytes32",internalType:"ModeCode"},{name:"executionData",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"supportsExecutionMode",inputs:[{name:"mode",type:"bytes32",internalType:"ModeCode"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"}],s.DELEGATION_MANAGER_ADDRESSES=["0xdb9b1e94b5b69df7e401ddbede43491141047db3"],s.CODE_DELEGATION_MANAGER_NO_SIGNATURE_ERRORS=" "}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/errors.cjs",{"./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.SimulationRevertedError=s.SimulationInvalidResponseError=s.SimulationChainNotSupportedError=s.FirstTimeInteractionError=s.SimulationError=void 0;const a=e("./types.cjs");class n extends Error{constructor(e,t){super(e??"Simulation failed"),this.code=t}}s.SimulationError=n;class r extends Error{constructor(e,t){super(e??"Error checking first time interaction"),this.code=t}}s.FirstTimeInteractionError=r;s.SimulationChainNotSupportedError=class extends n{constructor(e){super(`Chain is not supported: ${e}`,a.SimulationErrorCode.ChainNotSupported)}};s.SimulationInvalidResponseError=class extends n{constructor(){super("Invalid response from simulation API",a.SimulationErrorCode.InvalidResponse)}};s.SimulationRevertedError=class extends n{constructor(){super("Transaction was reverted",a.SimulationErrorCode.Reverted)}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/errors.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/gas-fees.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs","@metamask/gas-fee-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/gas-fee-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.DefaultGasFeeFlow=void 0;const d=e("@metamask/gas-fee-controller"),m=e("@metamask/utils"),u=e("../logger.cjs"),h=e("../types.cjs"),f=e("../utils/gas-fees.cjs"),p=(0,m.createModuleLogger)(u.projectLogger,"default-gas-fee-flow");s.DefaultGasFeeFlow=class{constructor(){a.add(this)}matchesTransaction(){return!0}async getGasFees(e){const{gasFeeControllerData:t}=e,{gasEstimateType:s,gasFeeEstimates:i}=t;let c;switch(s){case d.GAS_ESTIMATE_TYPES.FEE_MARKET:p("Using fee market estimates",i),c=l(this,a,"m",n).call(this,i);break;case d.GAS_ESTIMATE_TYPES.LEGACY:p("Using legacy estimates",i),c=l(this,a,"m",r).call(this,i);break;case d.GAS_ESTIMATE_TYPES.ETH_GASPRICE:p("Using eth_gasPrice estimates",i),c=l(this,a,"m",o).call(this,i);break;default:throw new Error(`Unsupported gas estimate type: ${s}`)}return{estimates:c}}},a=new WeakSet,n=function(e){const t=Object.values(h.GasFeeEstimateLevel).reduce((t,s)=>({...t,[s]:l(this,a,"m",i).call(this,e,s)}),{});return{type:h.GasFeeEstimateType.FeeMarket,...t}},r=function(e){const t=Object.values(h.GasFeeEstimateLevel).reduce((t,s)=>({...t,[s]:l(this,a,"m",c).call(this,e,s)}),{});return{type:h.GasFeeEstimateType.Legacy,...t}},o=function(e){return{type:h.GasFeeEstimateType.GasPrice,gasPrice:(0,f.gweiDecimalToWeiHex)(e.gasPrice)}},i=function(e,t){return{maxFeePerGas:(0,f.gweiDecimalToWeiHex)(e[t].suggestedMaxFeePerGas),maxPriorityFeePerGas:(0,f.gweiDecimalToWeiHex)(e[t].suggestedMaxPriorityFeePerGas)}},c=function(e,t){return(0,f.gweiDecimalToWeiHex)(e[t])}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.LineaGasFeeFlow=void 0;const d=e("@metamask/controller-utils"),m=e("@metamask/utils"),u=e("./DefaultGasFeeFlow.cjs"),h=e("../logger.cjs"),f=e("../types.cjs"),p=(0,m.createModuleLogger)(h.projectLogger,"linea-gas-fee-flow"),g=[d.ChainId["linea-mainnet"],d.ChainId["linea-goerli"],d.ChainId["linea-sepolia"]],k={low:1,medium:1.35,high:1.7},b={low:1,medium:1.05,high:1.1};s.LineaGasFeeFlow=class{constructor(){a.add(this)}matchesTransaction({transactionMeta:e}){return g.includes(e.chainId)}async getGasFees(e){try{return await l(this,a,"m",n).call(this,e)}catch(t){return p("Using default flow as fallback due to error",t),(new u.DefaultGasFeeFlow).getGasFees(e)}}},a=new WeakSet,n=async function(e){const{ethQuery:t,transactionMeta:s}=e,n=await l(this,a,"m",r).call(this,s,t);p("Received Linea response",n);const m=l(this,a,"m",o).call(this,n.baseFeePerGas,k);p("Generated base fees",l(this,a,"m",c).call(this,m));const u=l(this,a,"m",o).call(this,n.priorityFeePerGas,b);p("Generated priority fees",l(this,a,"m",c).call(this,u));const h=l(this,a,"m",i).call(this,m,u);p("Generated max fees",l(this,a,"m",c).call(this,h));return{estimates:Object.values(f.GasFeeEstimateLevel).reduce((e,t)=>({...e,[t]:{maxFeePerGas:(0,d.toHex)(h[t]),maxPriorityFeePerGas:(0,d.toHex)(u[t])}}),{type:f.GasFeeEstimateType.FeeMarket})}},r=function(e,t){return(0,d.query)(t,"linea_estimateGas",[{from:e.txParams.from,to:e.txParams.to,value:e.txParams.value,input:e.txParams.data}])},o=function(e,t){const s=(0,d.hexToBN)(e);return{low:s.muln(t.low),medium:s.muln(t.medium),high:s.muln(t.high)}},i=function(e,t){return{low:e.low.add(t.low),medium:e.medium.add(t.medium),high:e.high.add(t.high)}},c=function(e){return Object.values(f.GasFeeEstimateLevel).map(t=>e[t].toString(10))}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","./OracleLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/OracleLayer1GasFeeFlow.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.OptimismLayer1GasFeeFlow=void 0;const o=e("@metamask/controller-utils"),i=e("@metamask/utils"),c=e("./OracleLayer1GasFeeFlow.cjs"),l=e("../constants.cjs"),d=[l.CHAIN_IDS.OPTIMISM,l.CHAIN_IDS.OPTIMISM_TESTNET,l.CHAIN_IDS.BASE,l.CHAIN_IDS.BASE_TESTNET,l.CHAIN_IDS.OPBNB,l.CHAIN_IDS.OPBNB_TESTNET,l.CHAIN_IDS.ZORA];class m extends c.OracleLayer1GasFeeFlow{constructor(){super(...arguments),a.add(this)}async matchesTransaction({transactionMeta:e}){const t=(0,i.hexToNumber)(e.chainId),s=await r(this,a,"m",n).call(this);return!!s?.has(t)||d.includes(e.chainId)}}s.OptimismLayer1GasFeeFlow=m,a=new WeakSet,n=async function(){try{const e=await(0,o.handleFetch)("https://gas.api.cx.metamask.io/v1/supportedNetworks");return new Set(e?.partialSupport?.optimism??[])}catch{return null}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/OracleLayer1GasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../utils/prepare.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs","../utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","@ethersproject/contracts":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/contracts/lib/index.js","@ethersproject/providers":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/providers/lib/index.js","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bn.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/bn.js/lib/bn.js",buffer:"/home/runner/work/metamask-extension/metamask-extension/node_modules/browserify/node_modules/buffer/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){(function(t){(function(){var a,n,r,o,i,c,l=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.OracleLayer1GasFeeFlow=void 0;const m=e("@ethersproject/contracts"),u=e("@ethersproject/providers"),h=e("@metamask/utils"),f=d(e("bn.js")),p=e("../logger.cjs"),g=e("../utils/prepare.cjs"),k=e("../utils/utils.cjs"),b=(0,h.createModuleLogger)(p.projectLogger,"oracle-layer1-gas-fee-flow"),w=new f.default(0),_=[{inputs:[{internalType:"bytes",name:"_data",type:"bytes"}],name:"getL1Fee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_gasUsed",type:"uint256"}],name:"getOperatorFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}];s.OracleLayer1GasFeeFlow=class{constructor(){a.add(this)}getOracleAddressForChain(e){return"0x420000000000000000000000000000000000000F"}shouldSignTransaction(){return!1}async getLayer1Fee(e){try{const{provider:t,transactionMeta:s}=e,o=l(this,a,"m",c).call(this,t,s.chainId),i=await l(this,a,"m",n).call(this,o,s),d=await l(this,a,"m",r).call(this,o,s);return{layer1Fee:(0,h.add0x)((0,k.padHexToEvenLength)(i.add(d).toString(16)))}}catch(e){throw b("Failed to get oracle layer 1 gas fee",e),new Error("Failed to get oracle layer 1 gas fee")}}},a=new WeakSet,n=async function(e,t){const s=l(this,a,"m",o).call(this,t,this.shouldSignTransaction()).serialize(),n=await e.getL1Fee(s);if(n===undefined)throw new Error("No value returned from oracle contract");return(0,k.toBN)(n)},r=async function(e,t){const{gasUsed:s}=t;if(!s)return w;try{const t=await e.getOperatorFee(s);return t===undefined?w:(0,k.toBN)(t)}catch(e){return b("Failed to get operator layer 1 gas fee",e),w}},o=function(e,s){const n=l(this,a,"m",i).call(this,e),{chainId:r}=e;let o=(0,g.prepareTransaction)(r,n);if(s){const e=t.from("abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789","hex"),s=Uint8Array.from(e);o=o.sign(s)}return o},i=function(e){return{...e.txParams,gasLimit:e.txParams.gas}},c=function(e,t){return new m.Contract(this.getOracleAddressForChain(t),_,new u.Web3Provider(e))}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/OracleLayer1GasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","../utils/gas-fees.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs","./DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","@metamask/gas-fee-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/gas-fee-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.randomiseDecimalGWEIAndConvertToHex=s.RandomisedEstimationsGasFeeFlow=void 0;const l=e("@metamask/gas-fee-controller"),d=e("@metamask/utils"),m=e("./DefaultGasFeeFlow.cjs"),u=e("../logger.cjs"),h=e("../types.cjs"),f=e("../utils/feature-flags.cjs"),p=e("../utils/gas-fees.cjs"),g=(0,d.createModuleLogger)(u.projectLogger,"randomised-estimation-gas-fee-flow");function k(e,t,s){const a=(0,p.gweiDecimalToWeiDecimal)(e),n=a.length,r=Math.min(t,n-s);if(0===Number(a)||r<=0)return`0x${Number(a).toString(16)}`;const o=n-r,i=a.slice(0,o),c=a.slice(-r),l=function(e,t){const s=10**e;return t+Math.floor(Math.random()*(s-t))}(r,Number(c)),m=`0x${(BigInt(i+"0".repeat(r))+BigInt(l)).toString(16)}`;return(0,d.add0x)(m)}s.RandomisedEstimationsGasFeeFlow=class{constructor(){a.add(this)}matchesTransaction({transactionMeta:e,messenger:t}){const{chainId:s}=e;return(0,f.getGasFeeRandomisation)(t).randomisedGasFeeDigits[s]!==undefined}async getGasFees(e){try{return await c(this,a,"m",r).call(this,e)}catch(t){return g("Using default flow as fallback due to error",t),await c(this,a,"m",n).call(this,e)}}},a=new WeakSet,n=async function(e){return(new m.DefaultGasFeeFlow).getGasFees(e)},r=async function(e){const{messenger:t,gasFeeControllerData:s,transactionMeta:r}=e,{gasEstimateType:i,gasFeeEstimates:d}=s,m=(0,f.getGasFeeRandomisation)(t),u=m.randomisedGasFeeDigits[r.chainId],h=m.preservedNumberOfDigits??2;if(i===l.GAS_ESTIMATE_TYPES.FEE_MARKET){g("Randomising fee market estimates",d);const e=c(this,a,"m",o).call(this,d,u,h);return g("Added randomised fee market estimates",e),{estimates:e}}return await c(this,a,"m",n).call(this,e)},o=function(e,t,s){const n=Object.values(h.GasFeeEstimateLevel).reduce((n,r)=>({...n,[r]:c(this,a,"m",i).call(this,e,r,t,s)}),{});return{type:h.GasFeeEstimateType.FeeMarket,...n}},i=function(e,t,s,a){return{maxFeePerGas:(0,p.gweiDecimalToWeiHex)(e[t].suggestedMaxFeePerGas),maxPriorityFeePerGas:k(e[t].suggestedMaxPriorityFeePerGas,s,a)}},s.randomiseDecimalGWEIAndConvertToHex=k}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","./OracleLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/OracleLayer1GasFeeFlow.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.ScrollLayer1GasFeeFlow=void 0;const a=e("./OracleLayer1GasFeeFlow.cjs"),n=e("../constants.cjs"),r=[n.CHAIN_IDS.SCROLL,n.CHAIN_IDS.SCROLL_SEPOLIA];class o extends a.OracleLayer1GasFeeFlow{getOracleAddressForChain(e){return"0x5300000000000000000000000000000000000002"}shouldSignTransaction(){return!0}async matchesTransaction({transactionMeta:e}){return r.includes(e.chainId)}}s.ScrollLayer1GasFeeFlow=o}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/TestGasFeeFlow.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},i=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s};Object.defineProperty(s,"__esModule",{value:!0}),s.TestGasFeeFlow=void 0;const c=e("@metamask/controller-utils"),l=e("../types.cjs"),d=1e15;s.TestGasFeeFlow=class{constructor(){a.add(this),n.set(this,1)}matchesTransaction(){return!0}async getGasFees(e){const{transactionMeta:t}=e,{txParams:s}=t,{gas:c}=s;if(!c)throw new Error("Cannot estimate fee without gas value");const m=parseInt(c,16),u=.5*d,h=(o(this,n,"f")+1)*d,f=o(this,n,"f")*d,p=h-u,g=f-u,k=h+u,b=f+u;return i(this,n,o(this,n,"f")+1,"f"),{estimates:{type:l.GasFeeEstimateType.FeeMarket,low:{maxFeePerGas:o(this,a,"m",r).call(this,p,m),maxPriorityFeePerGas:o(this,a,"m",r).call(this,g,m)},medium:{maxFeePerGas:o(this,a,"m",r).call(this,h,m),maxPriorityFeePerGas:o(this,a,"m",r).call(this,f,m)},high:{maxFeePerGas:o(this,a,"m",r).call(this,k,m),maxPriorityFeePerGas:o(this,a,"m",r).call(this,b,m)}}}}},n=new WeakMap,a=new WeakSet,r=function(e,t){const s=Math.ceil(e/t);return(0,c.toHex)(s)}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/TestGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs",{"../api/accounts-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs","../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","../index.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","bn.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/bn.js/lib/bn.js",uuid:"/home/runner/work/metamask-extension/metamask-extension/node_modules/uuid/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.AccountsApiRemoteTransactionSource=s.SUPPORTED_CHAIN_IDS=void 0;const l=e("@metamask/controller-utils"),d=c(e("bn.js")),m=e("uuid"),u=e("../index.cjs"),h=e("../api/accounts-api.cjs"),f=e("../constants.cjs"),p=e("../logger.cjs"),g=e("../types.cjs");s.SUPPORTED_CHAIN_IDS=[f.CHAIN_IDS.MAINNET,f.CHAIN_IDS.POLYGON,f.CHAIN_IDS.BSC,f.CHAIN_IDS.LINEA_MAINNET,f.CHAIN_IDS.BASE,f.CHAIN_IDS.OPTIMISM,f.CHAIN_IDS.ARBITRUM,f.CHAIN_IDS.SCROLL,f.CHAIN_IDS.SEI,f.CHAIN_IDS.MONAD,f.CHAIN_IDS.HYPEREVM];const k=(0,p.createModuleLogger)(p.incomingTransactionsLogger,"accounts-api-source");s.AccountsApiRemoteTransactionSource=class{constructor(){a.add(this)}getSupportedChains(){return s.SUPPORTED_CHAIN_IDS}async fetchTransactions(e){const{address:t,chainIds:c}=e,l=await i(this,a,"m",n).call(this,e,c??s.SUPPORTED_CHAIN_IDS);k("Fetched transactions",l.length,l);const d=await Promise.all(l.map(e=>i(this,a,"m",o).call(this,t,e)));k("Normalized transactions",d);const m=i(this,a,"m",r).call(this,e,d);return k("Filtered transactions",m.length,m),m}},a=new WeakSet,n=async function(e,t){const{address:s,tags:a}=e,n=[];try{const e=await(0,h.getAccountTransactions)({address:s,chainIds:t,sortDirection:"DESC",tags:a});e?.data&&n.push(...e.data)}catch(e){k("Error while fetching transactions",e)}return n},r=function(e,t){const{address:s,includeTokenTransfers:a,updateTransactions:n}=e;let r=t;return n||(r=r.filter(e=>e.txParams.to===s)),a||(r=r.filter(e=>!e.isTransfer)),r},o=async function(e,t){const s=String(t.blockNumber),a=`0x${t.chainId.toString(16)}`,{hash:n}=t,r=new Date(t.timestamp).getTime(),o=(0,m.v1)({msecs:r}),{from:i}=t,c=(0,l.BNToHex)(new d.default(t.gas)),h=(0,l.BNToHex)(new d.default(t.gasPrice)),f=(0,l.BNToHex)(new d.default(t.gasUsed)),p=(0,l.BNToHex)(new d.default(t.nonce)),k=t.methodId,b=g.TransactionType.incoming,w=t.isError?g.TransactionStatus.failed:g.TransactionStatus.confirmed,_=t.valueTransfers.find(t=>(t.to.toLowerCase()===e.toLowerCase()||t.from.toLowerCase()===e.toLowerCase())&&t.contractAddress),T=_?.to.toLowerCase()===e.toLowerCase()&&i.toLowerCase()!==e.toLowerCase(),E=i.toLowerCase()===e.toLowerCase(),I=_?.amount,S=_?.contractAddress,x=_?.decimal,y=_?.symbol,A=(0,l.BNToHex)(new d.default(T?_?.amount??t.value:t.value)),v=T?e:t.to,P={blockNumber:s,chainId:a,error:w===g.TransactionStatus.failed?new Error("Transaction failed"):undefined,hash:n,id:o,isTransfer:T,networkClientId:"",status:w,time:r,toSmartContract:!1,transferInformation:_?{amount:I,contractAddress:S,decimals:x,symbol:y}:undefined,txParams:{chainId:a,data:k,from:i,gas:c,gasPrice:h,gasUsed:f,nonce:p,to:v,value:A},type:b,verifiedOnBlockchain:!1};return E&&(P.type=(await(0,u.determineTransactionType)(P.txParams)).type),P}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs",{"../gas-flows/DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs","../utils/layer1-gas-fee-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/layer1-gas-fee-flow.cjs","@metamask/eth-query":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eth-query/index.js","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs",events:"/home/runner/work/metamask-extension/metamask-extension/node_modules/events/events.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p,g,k,b,w,_,T,E,I,S,x,y=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},A=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},v=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.updateTransactionGasEstimates=s.updateTransactionGasProperties=s.GasFeePoller=void 0;const P=v(e("@metamask/eth-query")),C=e("@metamask/utils"),j=v(e("events")),N=e("../gas-flows/DefaultGasFeeFlow.cjs"),D=e("../logger.cjs"),R=e("../types.cjs"),F=e("../utils/gas-flow.cjs"),L=e("../utils/layer1-gas-fee-flow.cjs"),M=(0,C.createModuleLogger)(D.projectLogger,"gas-fee-poller");function O(e,t,s,a){const{type:n}=t;if(a){if(n===R.GasFeeEstimateType.FeeMarket){const a=t;e.maxFeePerGas=a[s]?.maxFeePerGas,e.maxPriorityFeePerGas=a[s]?.maxPriorityFeePerGas}if(n===R.GasFeeEstimateType.GasPrice){const s=t;e.maxFeePerGas=s.gasPrice,e.maxPriorityFeePerGas=s.gasPrice}if(n===R.GasFeeEstimateType.Legacy){const a=t[s];e.maxFeePerGas=a,e.maxPriorityFeePerGas=a}delete e.gasPrice}else{if(n===R.GasFeeEstimateType.FeeMarket){const a=t;e.gasPrice=a[s]?.maxFeePerGas}if(n===R.GasFeeEstimateType.GasPrice){const s=t;e.gasPrice=s.gasPrice}if(n===R.GasFeeEstimateType.Legacy){const a=t;e.gasPrice=a[s]}delete e.maxFeePerGas,delete e.maxPriorityFeePerGas}}s.GasFeePoller=class{constructor({findNetworkClientIdByChainId:e,gasFeeFlows:t,getGasFeeControllerEstimates:s,getProvider:g,getTransactions:k,getTransactionBatches:b,layer1GasFeeFlows:w,messenger:_,onStateChange:T}){a.add(this),this.hub=new j.default,n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,void 0),u.set(this,void 0),h.set(this,!1),y(this,n,e,"f"),y(this,r,t,"f"),y(this,d,w,"f"),y(this,o,s,"f"),y(this,i,g,"f"),y(this,c,k,"f"),y(this,l,b,"f"),y(this,m,_,"f"),T(()=>{const e=A(this,a,"m",I).call(this),t=A(this,a,"m",S).call(this);e.length||t.length?A(this,a,"m",f).call(this):A(this,a,"m",p).call(this)})}},n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,h=new WeakMap,a=new WeakSet,f=function(){A(this,h,"f")||(A(this,a,"m",g).call(this),y(this,h,!0,"f"),M("Started polling"))},p=function(){A(this,h,"f")&&(clearTimeout(A(this,u,"f")),y(this,u,undefined,"f"),y(this,h,!1,"f"),M("Stopped polling"))},g=async function e(){await A(this,a,"m",k).call(this),await A(this,a,"m",b).call(this),y(this,u,setTimeout(()=>A(this,a,"m",e).call(this),1e4),"f")},k=async function(){const e=A(this,a,"m",I).call(this);if(!e.length)return;M("Found unapproved transactions",e.length);const t=await A(this,a,"m",x).call(this,e);M("Retrieved gas fee controller data",t),await Promise.all(e.flatMap(e=>{const{chainId:s}=e,n=t.get(s);return A(this,a,"m",w).call(this,e,n)}))},b=async function(){const e=A(this,a,"m",S).call(this);if(!e.length)return;M("Found unapproved transaction batches",e.length);const t=await A(this,a,"m",x).call(this,e);M("Retrieved gas fee controller data",t),await Promise.all(e.flatMap(e=>{const{chainId:s}=e,n=t.get(s);return A(this,a,"m",_).call(this,e,n)}))},w=async function(e,t){const{id:s}=e,[n,r]=await Promise.all([A(this,a,"m",T).call(this,e,t),A(this,a,"m",E).call(this,e)]);(n||r)&&this.hub.emit("transaction-updated",{transactionId:s,gasFeeEstimates:n?.gasFeeEstimates,gasFeeEstimatesLoaded:n?.gasFeeEstimatesLoaded,layer1GasFee:r})},_=async function(e,t){const{id:s}=e,a=new P.default(A(this,i,"f").call(this,e.networkClientId)),n=new N.DefaultGasFeeFlow,r={ethQuery:a,gasFeeControllerData:t,messenger:A(this,m,"f"),transactionMeta:{...e,txParams:{...e.transactions?.[0],from:e.from,gas:e.gas},time:Date.now()}};let o;try{o=(await n.getGasFees(r)).estimates}catch(t){M("Failed to get gas fees for batch",e.id,t)}o&&this.hub.emit("transaction-batch-updated",{transactionBatchId:s,gasFeeEstimates:o,gasFeeEstimatesLoaded:!0})},T=async function(e,t){const{networkClientId:s}=e,a=new P.default(A(this,i,"f").call(this,s)),n=(0,F.getGasFeeFlow)(e,A(this,r,"f"),A(this,m,"f"));n&&M("Found gas fee flow",n.constructor.name,e.id);const o={ethQuery:a,gasFeeControllerData:t,messenger:A(this,m,"f"),transactionMeta:e};let c;if(n)try{c=(await n.getGasFees(o)).estimates}catch(t){M("Failed to get suggested gas fees",e.id,t)}return!c&&e.gasFeeEstimatesLoaded?undefined:(M("Updated gas fee estimates",{gasFeeEstimates:c,transaction:e.id}),{gasFeeEstimates:c,gasFeeEstimatesLoaded:!0})},E=async function(e){const{networkClientId:t}=e,s=A(this,i,"f").call(this,t),a=await(0,L.getTransactionLayer1GasFee)({layer1GasFeeFlows:A(this,d,"f"),messenger:A(this,m,"f"),provider:s,transactionMeta:e});return a&&M("Updated layer 1 gas fee",a,e.id),a},I=function(){return A(this,c,"f").call(this).filter(e=>e.status===R.TransactionStatus.unapproved)},S=function(){return A(this,l,"f").call(this).filter(e=>e.status===R.TransactionStatus.unapproved)},x=async function(e){const t=new Map;for(const s of e){const{chainId:e,networkClientId:a}=s;if(t.has(e))continue;const r=a??A(this,n,"f").call(this,e);t.set(e,r)}M("Extracted network client IDs by chain ID",t);const s=Array.from(t.entries()).map(async([e,t])=>[e,await A(this,o,"f").call(this,{networkClientId:t})]);return new Map(await Promise.all(s))},s.updateTransactionGasProperties=function({gasFeeEstimates:e,gasFeeEstimatesLoaded:t,isTxParamsGasFeeUpdatesEnabled:s,layer1GasFee:a,txMeta:n}){const r=n.userFeeLevel,o=Object.values(R.GasFeeEstimateLevel).includes(r);if(s(n)&&o&&e){const t=n.txParams.type!==R.TransactionEnvelopeType.legacy;O(n.txParams,e,r,t)}e&&(n.gasFeeEstimates=e),t!==undefined&&(n.gasFeeEstimatesLoaded=t),a&&(n.layer1GasFee=a)},s.updateTransactionGasEstimates=function({txMeta:e,userFeeLevel:t}){const{txParams:s,gasFeeEstimates:a}=e;if(!a)return;O(s,a,t,e.txParams.type!==R.TransactionEnvelopeType.legacy)}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","../utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","./AccountsApiRemoteTransactionSource.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs",events:"/home/runner/work/metamask-extension/metamask-extension/node_modules/events/events.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p,g,k,b,w,_,T,E,I,S,x,y,A,v,P,C,j,N,D,R,F=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},L=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},M=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.IncomingTransactionHelper=s.WebSocketState=void 0;const O=M(e("events")),B=e("./AccountsApiRemoteTransactionSource.cjs"),G=e("../logger.cjs"),H=e("../utils/feature-flags.cjs"),U=e("../utils/utils.cjs");var q;!function(e){e.CONNECTED="connected",e.DISCONNECTED="disconnected"}(q||(s.WebSocketState=q={}));s.IncomingTransactionHelper=class{constructor({client:e,getCurrentAccount:t,getLocalTransactions:s,includeTokenTransfers:I,isEnabled:x,messenger:y,remoteTransactionSource:P,trimTransactions:C,updateTransactions:j}){a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,void 0),u.set(this,void 0),h.set(this,void 0),f.set(this,void 0),p.set(this,!1),g.set(this,void 0),k.set(this,void 0),b.set(this,[...B.SUPPORTED_CHAIN_IDS]),w.set(this,e=>{L(this,a,"m",S).call(this,e)}),_.set(this,e=>{L(this,a,"m",A).call(this,e)}),T.set(this,()=>{L(this,a,"m",v).call(this)}),E.set(this,({chainIds:e,status:t})=>{L(this,a,"m",R).call(this,e,t)}),this.hub=new O.default,F(this,n,e,"f"),F(this,r,t,"f"),F(this,o,s,"f"),F(this,i,I,"f"),F(this,c,x??(()=>!0),"f"),F(this,l,!1,"f"),F(this,d,!1,"f"),F(this,m,y,"f"),F(this,u,P,"f"),F(this,f,C,"f"),F(this,g,j,"f"),F(this,k,(0,H.isIncomingTransactionsUseBackendWebSocketServiceEnabled)(y),"f"),L(this,k,"f")&&(L(this,m,"f").subscribe("BackendWebSocketService:connectionStateChanged",L(this,w,"f")),L(this,m,"f").subscribe("AccountActivityService:statusChanged",L(this,E,"f")))}start(){L(this,k,"f")||L(this,a,"m",I).call(this,!0)}stop(){L(this,h,"f")&&clearTimeout(L(this,h,"f")),L(this,l,"f")&&(F(this,l,!1,"f"),(0,G.incomingTransactionsLogger)("Stopped polling"))}async update({chainIds:e,isInterval:t,tags:s}={}){const n=L(this,a,"m",D).call(this,s,t);if((0,G.incomingTransactionsLogger)("Checking for incoming transactions",{isInterval:Boolean(t),tags:n}),!L(this,a,"m",j).call(this))return;const c=L(this,r,"f").call(this),l=L(this,i,"f")??!0,d=L(this,g,"f")??!1;let m=[];try{m=await L(this,u,"f").fetchTransactions({address:c.address,chainIds:e,includeTokenTransfers:l,tags:n,updateTransactions:d})}catch(e){return void(0,G.incomingTransactionsLogger)("Error while fetching remote transactions",e)}if(!m.length)return;L(this,a,"m",C).call(this,m),(0,G.incomingTransactionsLogger)("Found potential transactions",m.length,m);const h=L(this,o,"f").call(this),p=m.filter(e=>!h.some(t=>t.hash?.toLowerCase()===e.hash?.toLowerCase()&&t.txParams.from?.toLowerCase()===e.txParams.from?.toLowerCase()&&t.type===e.type));if(!p.length)return void(0,G.incomingTransactionsLogger)("All transactions are already known");(0,G.incomingTransactionsLogger)("Found unique transactions",p.length,p);const k=L(this,f,"f").call(this,[...p,...h]),b=p.map(e=>e.id),w=k.filter(e=>b.includes(e.id));w.length?((0,G.incomingTransactionsLogger)("Adding new transactions",w.length,w),this.hub.emit("transactions",w)):(0,G.incomingTransactionsLogger)("All unique transactions truncated due to limit")}},n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,h=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakMap,k=new WeakMap,b=new WeakMap,w=new WeakMap,_=new WeakMap,T=new WeakMap,E=new WeakMap,a=new WeakSet,I=function(e=!1){if(L(this,l,"f"))return;if(!L(this,a,"m",j).call(this))return;const t=L(this,a,"m",N).call(this);(0,G.incomingTransactionsLogger)("Started polling",{interval:t}),F(this,l,!0,"f"),L(this,d,"f")||L(this,a,"m",P).call(this).catch(t=>{(0,G.incomingTransactionsLogger)(e?"Initial polling failed":"Polling failed",t)})},S=function(e){e.state===q.CONNECTED?((0,G.incomingTransactionsLogger)("WebSocket connected, starting enhanced mode"),L(this,a,"m",x).call(this)):e.state===q.DISCONNECTED&&((0,G.incomingTransactionsLogger)("WebSocket disconnected, stopping enhanced mode"),L(this,a,"m",y).call(this))},x=function(){L(this,a,"m",j).call(this)&&(L(this,p,"f")||((0,G.incomingTransactionsLogger)("Started transaction history retrieval (event-driven)"),F(this,p,!0,"f"),this.update().catch(e=>{(0,G.incomingTransactionsLogger)("Initial update in transaction history retrieval failed",e)}),L(this,m,"f").subscribe("AccountActivityService:transactionUpdated",L(this,_,"f")),L(this,m,"f").subscribe("AccountsController:selectedAccountChange",L(this,T,"f"))))},y=function(){L(this,p,"f")&&((0,G.incomingTransactionsLogger)("Stopped transaction history retrieval"),F(this,p,!1,"f"),L(this,m,"f").unsubscribe("AccountActivityService:transactionUpdated",L(this,_,"f")),L(this,m,"f").unsubscribe("AccountsController:selectedAccountChange",L(this,T,"f")))},A=function(e){(0,G.incomingTransactionsLogger)("Received relevant transaction update, triggering update",{txId:e.id,chain:e.chain}),this.update().catch(e=>{(0,G.incomingTransactionsLogger)("Update after transaction event failed",e)})},v=function(){(0,G.incomingTransactionsLogger)("Selected account changed, triggering update"),this.update().catch(e=>{(0,G.incomingTransactionsLogger)("Update after account change failed",e)})},P=async function e(){F(this,d,!0,"f");try{const e=L(this,k,"f")?L(this,b,"f"):undefined;await this.update({chainIds:e,isInterval:!0})}catch(e){console.error("Error while checking incoming transactions",e)}F(this,d,!1,"f"),L(this,l,"f")&&(L(this,h,"f")&&clearTimeout(L(this,h,"f")),F(this,h,setTimeout(()=>L(this,a,"m",e).call(this),L(this,a,"m",N).call(this)),"f"))},C=function(e){e.sort((e,t)=>e.time<t.time?-1:1)},j=function(){return L(this,c,"f").call(this)},N=function(){return(0,H.getIncomingTransactionsPollingInterval)(L(this,m,"f"))},D=function(e,t){const s=[];return L(this,n,"f")&&s.push(L(this,n,"f")),e?.length?s.push(...e):t&&s.push("automatic-polling"),s?.length?s:undefined},R=function(e,t){if(!L(this,k,"f"))return;let s=!1;for(const a of e){const e=(0,U.caip2ToHex)(a);if(e&&B.SUPPORTED_CHAIN_IDS.includes(e))if("up"===t){const t=L(this,b,"f").indexOf(e);-1!==t&&(L(this,b,"f").splice(t,1),s=!0,(0,G.incomingTransactionsLogger)("Supported network came up, removed from polling list",{chainId:e}))}else"down"!==t||L(this,b,"f").includes(e)||(L(this,b,"f").push(e),s=!0,(0,G.incomingTransactionsLogger)("Supported network went down, added to polling list",{chainId:e}));else(0,G.incomingTransactionsLogger)("Chain ID not recognized or not supported",{caip2ChainId:a,hexChainId:e})}s?0===L(this,b,"f").length?((0,G.incomingTransactionsLogger)("Stopping fallback polling - all networks up"),this.stop()):((0,G.incomingTransactionsLogger)("Starting fallback polling - some networks need polling",{chainsToPoll:L(this,b,"f")}),L(this,a,"m",I).call(this)):(0,G.incomingTransactionsLogger)("No changes to polling list",{chainsToPoll:L(this,b,"f")})}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/MethodDataHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","async-mutex":"/home/runner/work/metamask-extension/metamask-extension/node_modules/async-mutex/lib/index.js","eth-method-registry":"/home/runner/work/metamask-extension/metamask-extension/node_modules/eth-method-registry/dist/index.js",events:"/home/runner/work/metamask-extension/metamask-extension/node_modules/events/events.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},d=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.MethodDataHelper=void 0;const u=e("@metamask/utils"),h=e("async-mutex"),f=e("eth-method-registry"),p=m(e("events")),g=e("../logger.cjs"),k=(0,u.createModuleLogger)(g.projectLogger,"method-data");s.MethodDataHelper=class{constructor({getProvider:e,getState:t}){a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,new h.Mutex),this.hub=new p.default,l(this,n,e,"f"),l(this,r,t,"f"),l(this,o,new Map,"f")}async lookup(e,t){k("lookup",e,t);const s=await d(this,i,"f").acquire();try{const s=d(this,r,"f").call(this)[e];if(s)return k("Cached",s),s;let i=d(this,o,"f").get(t);if(!i){const e=d(this,n,"f").call(this,t);i=new f.MethodRegistry({provider:e}),d(this,o,"f").set(t,i),k("Created registry",t)}const l=await d(this,a,"m",c).call(this,e,i);return k("Result",l),this.hub.emit("update",{fourBytePrefix:e,methodData:l}),l}finally{s()}}},n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,a=new WeakSet,c=async function(e,t){const s=await t.lookup(e);if(!s)return k("No method found",e),{registryMethod:"",parsedRegistryMethod:{name:undefined,args:undefined}};k("Parsing",s);return{registryMethod:s,parsedRegistryMethod:t.parse(s)}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/MethodDataHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","async-mutex":"/home/runner/work/metamask-extension/metamask-extension/node_modules/async-mutex/lib/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},g=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.MultichainTrackingHelper=void 0;const k=e("async-mutex"),b=e("../logger.cjs"),w=(0,b.createModuleLogger)(b.projectLogger,"multichain-tracking");s.MultichainTrackingHelper=class{constructor({findNetworkClientIdByChainId:e,getNetworkClientById:t,getNetworkClientRegistry:s,removePendingTransactionTrackerListeners:k,createNonceTracker:b,createPendingTransactionTracker:_,onNetworkStateChange:T}){a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,new Map),m.set(this,new Map),this.checkForPendingTransactionAndStartPolling=()=>{for(const[,e]of g(this,m,"f"))e.pendingTransactionTracker.startIfPendingTransactions()},u.set(this,e=>{const t=Object.keys(e),s=Array.from(g(this,m,"f").keys()),n=s.filter(e=>!t.includes(e));n.forEach(e=>{g(this,a,"m",h).call(this,e)});const r=t.filter(e=>!s.includes(e));r.forEach(e=>{g(this,a,"m",f).call(this,e)}),r.length&&w("Added trackers",r),n.length&&w("Removed trackers",n)}),p(this,n,e,"f"),p(this,r,t,"f"),p(this,o,s,"f"),p(this,i,k,"f"),p(this,c,b,"f"),p(this,l,_,"f"),T((e,t)=>{const s=g(this,o,"f").call(this);t.forEach(({op:e,path:t})=>{if("remove"===e&&"networkConfigurations"===t[0]){const e=t[1];delete s[e]}}),g(this,u,"f").call(this,s)})}initialize(){const e=g(this,o,"f").call(this);g(this,u,"f").call(this,e),w("Initialized")}has(e){return g(this,m,"f").has(e)}async acquireNonceLockForChainIdKey({chainId:e,key:t="global"}){let s=g(this,d,"f").get(e);s||(s=new Map,g(this,d,"f").set(e,s));let a=s.get(t);return a||(a=new k.Mutex,s.set(t,a)),await a.acquire()}async getNonceLock(e,t){const s=g(this,r,"f").call(this,t),a=await this.acquireNonceLockForChainIdKey({chainId:s.configuration.chainId,key:e}),n=g(this,m,"f").get(t)?.nonceTracker;if(!n)throw new Error(`Missing nonce tracker for network client ID - ${t}`);try{const t=await n.getNonceLock(e),s=()=>{t.releaseLock(),a?.()};return{...t,releaseLock:s}}catch(e){throw a?.(),e}}stopAllTracking(){for(const[e]of g(this,m,"f"))g(this,a,"m",h).call(this,e)}getNetworkClient({chainId:e,networkClientId:t}){if(!t&&!e)throw new Error("Cannot locate network client without networkClientId or chainId");let s,a=t;try{t&&(s=g(this,r,"f").call(this,t))}catch(s){if(w("No network client found with ID",t),!e)throw s}return!s&&e&&(a=g(this,n,"f").call(this,e),s=g(this,r,"f").call(this,a)),{...s,id:a}}},n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,a=new WeakSet,h=function(e){const t=g(this,m,"f").get(e);t&&(t.pendingTransactionTracker.stop(),g(this,i,"f").call(this,t.pendingTransactionTracker),g(this,m,"f").delete(e))},f=function(e){if(g(this,m,"f").get(e))return;const{provider:t,blockTracker:s,configuration:{chainId:a}}=g(this,r,"f").call(this,e),n=g(this,c,"f").call(this,{provider:t,blockTracker:s,chainId:a}),o=g(this,l,"f").call(this,{provider:t,blockTracker:s,chainId:a,networkClientId:e});g(this,m,"f").set(e,{nonceTracker:n,pendingTransactionTracker:o})}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","./TransactionPoller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/TransactionPoller.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs",events:"/home/runner/work/metamask-extension/metamask-extension/node_modules/events/events.js",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p,g,k,b,w,_,T,E,I,S,x,y,A,v,P,C,j,N,D,R,F,L,M,O,B,G,H,U,q,W,$=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},V=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)},K=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.PendingTransactionTracker=void 0;const Y=e("@metamask/controller-utils"),Q=K(e("events")),z=e("lodash"),X=e("./TransactionPoller.cjs"),J=e("../logger.cjs"),Z=e("../types.cjs"),ee=e("../utils/feature-flags.cjs"),te=["replacement transaction underpriced","known transaction","gas price too low to replace","transaction with the same hash was already imported","gateway timeout","nonce too low"],se=(0,J.createModuleLogger)(J.projectLogger,"pending-transactions");s.PendingTransactionTracker=class{constructor({blockTracker:e,getChainId:t,getEthQuery:s,getGlobalLock:I,getNetworkClientId:S,getTransactions:x,isTimeoutEnabled:y,hooks:A,isResubmitEnabled:v,messenger:P,publishTransaction:C}){a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,void 0),u.set(this,void 0),h.set(this,void 0),f.set(this,void 0),p.set(this,void 0),g.set(this,void 0),k.set(this,void 0),b.set(this,void 0),w.set(this,void 0),_.set(this,void 0),this.startIfPendingTransactions=()=>{const e=V(this,a,"m",R).call(this);e.length?V(this,a,"m",T).call(this,e):this.stop()},this.hub=new Q.default,$(this,r,new Map,"f"),$(this,i,t,"f"),$(this,c,s,"f"),$(this,l,I,"f"),$(this,d,S,"f"),$(this,m,x,"f"),$(this,u,v??(()=>!0),"f"),$(this,h,new Map,"f"),$(this,f,V(this,a,"m",E).bind(this),"f"),$(this,g,P,"f"),$(this,k,C,"f"),$(this,b,!1,"f"),$(this,_,undefined,"f"),$(this,w,new X.TransactionPoller({blockTracker:e,chainId:t(),messenger:P}),"f"),$(this,n,A?.beforeCheckPendingTransaction??(()=>Promise.resolve(!0)),"f"),$(this,o,y,"f"),$(this,p,(0,J.createModuleLogger)(se,`${t()}:${S()}`),"f")}addTransactionToPoll(e){V(this,a,"m",T).call(this,[e]),$(this,_,e,"f")}async forceCheckTransaction(e){const t=await V(this,l,"f").call(this);try{await V(this,a,"m",P).call(this,e)}catch(e){V(this,p,"f").call(this,"Failed to check transaction",e)}finally{t()}}stop(){V(this,b,"f")&&(V(this,w,"f").stop(),$(this,b,!1,"f"),V(this,p,"f").call(this,"Stopped polling"))}},n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,h=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakMap,k=new WeakMap,b=new WeakMap,w=new WeakMap,_=new WeakMap,a=new WeakSet,T=function(e){V(this,w,"f").setPendingTransactions(e),V(this,b,"f")||(V(this,w,"f").start(V(this,f,"f")),$(this,b,!0,"f"),V(this,p,"f").call(this,"Started polling"))},E=async function(e){const t=await V(this,l,"f").call(this);try{await V(this,a,"m",I).call(this)}catch(e){V(this,p,"f").call(this,"Failed to check transactions",e)}finally{t()}try{await V(this,a,"m",S).call(this,e)}catch(e){V(this,p,"f").call(this,"Failed to resubmit transactions",e)}},I=async function(){V(this,p,"f").call(this,"Checking transactions");const e=[...V(this,a,"m",R).call(this),...V(this,_,"f")?[V(this,_,"f")]:[]];e.length?(V(this,p,"f").call(this,"Found pending transactions to check",{count:e.length,ids:e.map(e=>e.id)}),await Promise.all(e.map(e=>V(this,a,"m",P).call(this,e)))):V(this,p,"f").call(this,"No pending transactions to check")},S=async function(e){if(!V(this,u,"f").call(this)||!V(this,b,"f"))return;V(this,p,"f").call(this,"Resubmitting transactions");const t=V(this,a,"m",R).call(this);if(t.length){V(this,p,"f").call(this,"Found pending transactions to resubmit",{count:t.length,ids:t.map(e=>e.id)});for(const s of t)try{await V(this,a,"m",y).call(this,s,e)}catch(e){const t=e.value?.message?.toLowerCase()??e.message?.toLowerCase()??String(e);if(V(this,a,"m",x).call(this,t)){V(this,p,"f").call(this,"Ignoring known transaction error",t);continue}V(this,a,"m",F).call(this,s,e.message,"There was an error when resubmitting this transaction.")}}else V(this,p,"f").call(this,"No pending transactions to resubmit")},x=function(e){return te.some(t=>e.includes(t))},y=async function(e,t){if(!V(this,a,"m",A).call(this,e,t))return;if(!await V(this,n,"f").call(this,e))return;const s=V(this,c,"f").call(this,e.networkClientId);await V(this,k,"f").call(this,s,e);const r=(e.retryCount??0)+1;V(this,a,"m",O).call(this,(0,z.merge)({},e,{retryCount:r}),"PendingTransactionTracker:transaction-retry - Retry count increased")},A=function(e,t){const s=(0,z.cloneDeep)(e);s.firstRetryBlockNumber||(s.firstRetryBlockNumber=t,V(this,a,"m",O).call(this,s,"PendingTransactionTracker:#isResubmitDue - First retry block number set"));const{firstRetryBlockNumber:n}=s,r=Number.parseInt(t,16)-Number.parseInt(n,16),o=e.retryCount??0;return r>=Math.min(50,Math.pow(2,o))},v=function(e){const{hash:t,id:s}=e;V(this,_,"f")?.id===s&&$(this,_,undefined,"f"),t&&V(this,h,"f").delete(t)},P=async function(e){const{hash:t,id:s,isIntentComplete:r,txParams:{from:o}}=e;if(r)await V(this,a,"m",C).call(this,e);else{if(!t&&await V(this,n,"f").call(this,e)){const t=new Error("We had an error while submitting this transaction, please try again.");return t.name="NoTxHashError",void V(this,a,"m",L).call(this,e,t)}if(V(this,a,"m",D).call(this,e))return V(this,p,"f").call(this,"Nonce already taken",s),void V(this,a,"m",M).call(this,e);try{const s=await V(this,a,"m",B).call(this,t),n="0x1"===s?.status;if("0x0"===s?.status)return V(this,p,"f").call(this,"Transaction receipt has failed status"),void V(this,a,"m",L).call(this,e,new Error("Transaction failed on-chain"));const{blockNumber:r,blockHash:i}=s??{};if(n&&r&&i)return void await V(this,a,"m",C).call(this,e,{...s,blockNumber:r,blockHash:i});V(this,p,"f").call(this,"No receipt status",{hash:t,receipt:s});const c=await V(this,a,"m",U).call(this,o),l=parseInt(c,16);if(!s&&await V(this,a,"m",j).call(this,e,l))return;await V(this,a,"m",N).call(this,e,l)&&V(this,a,"m",M).call(this,e)}catch(t){V(this,p,"f").call(this,"Failed to check transaction",s,t),V(this,a,"m",F).call(this,e,t.message,"There was a problem loading this transaction.")}}},C=async function(e,t){const{id:s}=e,{blockHash:n}=t??{};V(this,p,"f").call(this,"Transaction confirmed",s);const r=V(this,_,"f")?.id===s;if(V(this,a,"m",v).call(this,e),r)return void this.hub.emit("transaction-confirmed",e);const o=(0,z.cloneDeep)(e);if(t&&n){const{baseFeePerGas:e,timestamp:s}=await V(this,a,"m",H).call(this,n,!1);o.baseFeePerGas=e,o.blockTimestamp=s,o.txParams={...o.txParams,gasUsed:t.gasUsed},o.txReceipt=t,o.verifiedOnBlockchain=!0}o.status=Z.TransactionStatus.confirmed,V(this,a,"m",O).call(this,o,"PendingTransactionTracker:#onTransactionConfirmed - Transaction confirmed"),this.hub.emit("transaction-confirmed",o)},j=async function(e,t){const{chainId:s,hash:n,id:r,submittedTime:i,txParams:{nonce:c}}=e;if(!n||!c)return!1;if(!V(this,o,"f").call(this,e))return V(this,p,"f").call(this,"Timeout disabled for transaction",e),!1;const l=(0,ee.getTimeoutAttempts)(s,V(this,g,"f"));if(l===undefined||0===l)return V(this,p,"f").call(this,"Timeout disabled due to threshold",{chainId:s,threshold:l}),!1;const d=parseInt(c,16);if(d>t)return V(this,p,"f").call(this,"Skipping timeout as queued transaction",{transactionNonce:d,nextNonce:t}),!1;try{if(null!==await V(this,a,"m",G).call(this,n)){const e=Date.now();return V(this,p,"f").call(this,"Transaction found on network, recording timestamp",r),V(this,h,"f").set(n,e),!1}const t=V(this,h,"f").get(n)??i;if(t===undefined)return V(this,p,"f").call(this,"Transaction not yet seen on network and has no submitted time, skipping timeout check",r),!1;const{blockTime:o}=(0,ee.getAcceleratedPollingParams)(s,V(this,g,"f")),c=Date.now()-t,d=o*l;return V(this,p,"f").call(this,"Checking timeout duration",{transactionId:r,durationSinceLastSeen:c,timeoutDuration:d,threshold:l,blockTime:o}),c<d?!1:(V(this,p,"f").call(this,"Hit timeout duration threshold",r),V(this,h,"f").delete(n),V(this,a,"m",L).call(this,e,new Error("Transaction not found on network after timeout")),!0)}catch(e){return V(this,p,"f").call(this,"Failed to check transaction by hash",r,e),!1}},N=async function(e,t){const{hash:s,id:a,txParams:{nonce:n}}=e;if(!n||!s)return!1;if(parseInt(n,16)>=t)return!1;let o=V(this,r,"f").get(s);return o===undefined&&(o=0,V(this,r,"f").set(s,o)),o<3?(V(this,p,"f").call(this,"Incrementing dropped block count",{id:a,droppedBlockCount:o}),V(this,r,"f").set(s,o+1),!1):(V(this,p,"f").call(this,"Hit dropped block count",a),V(this,r,"f").delete(s),!0)},D=function(e){const{id:t,txParams:s}=e;return V(this,a,"m",q).call(this).some(e=>e.id!==t&&e.txParams.from===s.from&&e.status===Z.TransactionStatus.confirmed&&e.txParams.nonce&&e.txParams.nonce===s.nonce&&e.type!==Z.TransactionType.incoming&&e.isTransfer===undefined)},R=function(){return V(this,a,"m",W).call(this).filter(e=>e.status===Z.TransactionStatus.submitted&&!e.verifiedOnBlockchain&&!e.isUserOperation&&!e.isStateOnly)},F=function(e,t,s){V(this,a,"m",O).call(this,{...e,warning:{error:t,message:s}},"PendingTransactionTracker:#warnTransaction - Warning added")},L=function(e,t){V(this,p,"f").call(this,"Transaction failed",e.id,t),V(this,a,"m",v).call(this,e),this.hub.emit("transaction-failed",e,t)},M=function(e){V(this,p,"f").call(this,"Transaction dropped",e.id),V(this,a,"m",v).call(this,e),this.hub.emit("transaction-dropped",e)},O=function(e,t){this.hub.emit("transaction-updated",e,t)},B=async function(e){return await(0,Y.query)(V(this,c,"f").call(this),"getTransactionReceipt",[e])},G=async function(e){return await(0,Y.query)(V(this,c,"f").call(this),"getTransactionByHash",[e])},H=async function(e,t){return await(0,Y.query)(V(this,c,"f").call(this),"getBlockByHash",[e,t])},U=async function(e){return await(0,Y.query)(V(this,c,"f").call(this),"getTransactionCount",[e])},q=function(){const e=V(this,i,"f").call(this);return V(this,m,"f").call(this).filter(t=>t.chainId===e)},W=function(){const e=V(this,d,"f").call(this);return V(this,m,"f").call(this).filter(t=>t.networkClientId===e)}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/ResimulateHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bn.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/bn.js/lib/bn.js",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},h=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.hasSimulationDataChanged=s.shouldResimulate=s.ResimulateHelper=s.RESIMULATE_INTERVAL_MS=s.BLOCK_TIME_ADDITIONAL_SECONDS=s.VALUE_COMPARISON_PERCENT_THRESHOLD=s.BLOCKAID_RESULT_TYPE_MALICIOUS=s.RESIMULATE_PARAMS=void 0;const f=e("@metamask/utils"),p=e("bn.js"),g=e("lodash"),k=e("../logger.cjs"),b=e("../types.cjs"),w=e("../utils/utils.cjs"),_=(0,k.createModuleLogger)(k.projectLogger,"resimulate-helper");s.RESIMULATE_PARAMS=["to","value","data"],s.BLOCKAID_RESULT_TYPE_MALICIOUS="Malicious",s.VALUE_COMPARISON_PERCENT_THRESHOLD=5,s.BLOCK_TIME_ADDITIONAL_SECONDS=60,s.RESIMULATE_INTERVAL_MS=3e3;function T(e,t){return!E(e?.difference??"0x0",t?.difference??"0x0",!1===e?.isDecrease,!1===t?.isDecrease)}function E(e,t,a,n){let r=new p.BN((0,f.remove0x)(e),"hex"),o=new p.BN((0,f.remove0x)(t),"hex");return a&&(r=r.neg()),n&&(o=o.neg()),(0,w.getPercentageChange)(r,o)<=s.VALUE_COMPARISON_PERCENT_THRESHOLD}s.ResimulateHelper=class{constructor({getTransactions:e,simulateTransaction:t,onTransactionsUpdate:s}){a.add(this),n.set(this,new Map),r.set(this,void 0),o.set(this,void 0),u(this,r,e,"f"),u(this,o,t,"f"),s(h(this,a,"m",i).bind(this))}},n=new WeakMap,r=new WeakMap,o=new WeakMap,a=new WeakSet,i=function(){const e=h(this,r,"f").call(this).filter(e=>e.status===b.TransactionStatus.unapproved),t=new Set(e.map(e=>e.id));new Set([...t,...h(this,n,"f").keys()]).forEach(t=>{const s=e.find(e=>e.id===t);s?.isActive?h(this,a,"m",c).call(this,s):h(this,a,"m",d).call(this,t)})},c=function(e){const{id:t}=e;if(h(this,n,"f").has(t))return;const r=()=>{h(this,o,"f").call(this,e).catch(e=>{_("Error during transaction resimulation",e)}).finally(()=>{h(this,n,"f").has(t)&&h(this,a,"m",l).call(this,t,r)})};h(this,a,"m",l).call(this,t,r),_(`Started resimulating transaction ${t} every ${s.RESIMULATE_INTERVAL_MS} milliseconds`)},l=function(e,t){const a=setTimeout(t,s.RESIMULATE_INTERVAL_MS);h(this,n,"f").set(e,a)},d=function(e){h(this,n,"f").has(e)&&(h(this,a,"m",m).call(this,e),_(`Stopped resimulating transaction ${e} every ${s.RESIMULATE_INTERVAL_MS} milliseconds`))},m=function(e){const t=h(this,n,"f").get(e);t&&(clearTimeout(t),h(this,n,"f").delete(e))},s.shouldResimulate=function(e,t){const{id:a}=t,n=function(e,t){const{id:a,txParams:n}=t,{txParams:r}=e;if(!r||(0,g.isEqual)(r,n))return!1;const o=Object.keys(n).filter(e=>n[e]!==r[e]);return _("Transaction parameters updated",{transactionId:a,updatedProperties:o,originalParams:r,newParams:n}),s.RESIMULATE_PARAMS.some(e=>o.includes(e))}(e,t),r=function(e,t){const{securityAlertResponse:a}=e,{id:n,securityAlertResponse:r}=t;if((0,g.isEqual)(a,r))return!1;return _("Security alert updated",{transactionId:n,originalSecurityAlertResponse:a,newSecurityAlertResponse:r}),r?.result_type===s.BLOCKAID_RESULT_TYPE_MALICIOUS}(e,t),o=function(e,t){const{simulationData:s}=e,{simulationData:a,txParams:n}=t;if(!a||(0,g.isEqual)(s,a))return!1;return!E(n?.value??"0x0",a?.nativeBalanceChange?.difference??"0x0",!1,!1===a?.nativeBalanceChange?.isDecrease)}(e,t),i=n||r||o;let c;if(r||o){c=Math.floor(Date.now()/1e3)+s.BLOCK_TIME_ADDITIONAL_SECONDS}return i&&_("Transaction should be resimulated",{transactionId:a,blockTime:c,parametersUpdated:n,securityAlert:r,valueAndNativeBalanceMismatch:o}),{blockTime:c,resimulate:i}},s.hasSimulationDataChanged=function(e,t){if((0,g.isEqual)(e,t))return!1;if(T(e?.nativeBalanceChange,t?.nativeBalanceChange))return _("Simulation data native balance changed"),!0;if(e.tokenBalanceChanges.length!==t.tokenBalanceChanges.length)return!0;for(const s of e.tokenBalanceChanges){const e=t.tokenBalanceChanges.find(({address:e,id:t})=>e===s.address&&t===s.id);if(!e)return _("Missing new token balance",{address:s.address,id:s.id}),!0;if(T(s,e))return _("Simulation data token balance changed",{originalTokenBalanceChange:s,newTokenBalanceChange:e}),!0}return!1}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/ResimulateHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/TransactionPoller.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f,p,g,k,b,w,_=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},T=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.TransactionPoller=void 0;const E=e("@metamask/utils"),I=e("lodash"),S=e("../logger.cjs"),x=e("../utils/feature-flags.cjs"),y=(0,E.createModuleLogger)(S.projectLogger,"transaction-poller");var A;!function(e){e.Accelerated="Accelerated",e.BlockTracker="BlockTracker",e.Websocket="Websocket"}(A||(A={}));s.TransactionPoller=class{constructor({blockTracker:e,chainId:t,messenger:s}){a.add(this),n.set(this,0),r.set(this,void 0),o.set(this,void 0),i.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),m.set(this,!1),u.set(this,void 0),k.set(this,e=>{if(!T(this,m,"f"))return;if("confirmed"!==e.status&&"dropped"!==e.status&&"failed"!==e.status)return;const t=T(this,d,"f")?.some(t=>t.hash?.toLowerCase()===e.id.toLowerCase());t&&T(this,a,"m",f).call(this,A.Websocket).catch(()=>{})}),_(this,r,e,"f"),_(this,o,t,"f"),_(this,i,s,"f")}start(e){T(this,m,"f")||(_(this,l,e,"f"),_(this,m,!0,"f"),T(this,a,"m",b).call(this),T(this,a,"m",h).call(this),y("Started"))}stop(){T(this,m,"f")&&(_(this,m,!1,"f"),_(this,l,undefined,"f"),_(this,n,0,"f"),_(this,d,undefined,"f"),T(this,a,"m",p).call(this),T(this,a,"m",g).call(this),T(this,a,"m",w).call(this),y("Stopped"))}setPendingTransactions(e){const t=(T(this,d,"f")??[]).map(e=>e.id);_(this,d,e,"f");const s=e.map(e=>e.id),r=!(0,I.isEqual)(t,s);T(this,m,"f")&&r&&(y("Detected new pending transactions",s),_(this,n,0,"f"),T(this,c,"f")&&(T(this,a,"m",g).call(this),T(this,a,"m",h).call(this)))}},n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,k=new WeakMap,a=new WeakSet,h=function e(){if(!T(this,m,"f"))return;const{countMax:t,intervalMs:s}=(0,x.getAcceleratedPollingParams)(T(this,o,"f"),T(this,i,"f"));if(T(this,n,"f")>=t)return _(this,c,e=>T(this,a,"m",f).call(this,A.BlockTracker,e),"f"),T(this,r,"f").on("latest",T(this,c,"f")),void y("Added block tracker listener");T(this,a,"m",p).call(this),_(this,u,setTimeout(async()=>{await T(this,a,"m",f).call(this,A.Accelerated),T(this,a,"m",e).call(this)},s),"f")},f=async function(e,t){switch(e){case A.Websocket:y("AccountActivityService:transactionUpdated received");break;case A.Accelerated:y("Accelerated interval",T(this,n,"f")+1);break;case A.BlockTracker:y("Block tracker interval",t)}const s=t??await T(this,r,"f").getLatestBlock();await(T(this,l,"f")?.call(this,s)),e===A.Accelerated&&T(this,m,"f")&&_(this,n,T(this,n,"f")+1,"f")},p=function(){T(this,u,"f")&&(clearTimeout(T(this,u,"f")),_(this,u,undefined,"f"))},g=function(){T(this,c,"f")&&(T(this,r,"f").removeListener("latest",T(this,c,"f")),_(this,c,undefined,"f"))},b=function(){T(this,i,"f").subscribe("AccountActivityService:transactionUpdated",T(this,k,"f"))},w=function(){T(this,i,"f").unsubscribe("AccountActivityService:transactionUpdated",T(this,k,"f"))}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/TransactionPoller.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/CollectPublishHook.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},l=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.CollectPublishHook=void 0;const d=e("@metamask/utils"),m=e("lodash"),u=e("../logger.cjs"),h=(0,d.createModuleLogger)(u.projectLogger,"collect-publish-hook");s.CollectPublishHook=class{constructor(e){a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),c(this,o,(0,d.createDeferredPromise)(),"f"),c(this,n,[],"f"),c(this,r,e,"f")}getHook(){return l(this,a,"m",i).bind(this)}ready(){return l(this,o,"f").promise}success(e){if(h("Success",{transactionHashes:e}),e.length!==l(this,r,"f"))throw new Error("Transaction hash count mismatch");for(let t=0;t<l(this,n,"f").length;t++){const s=l(this,n,"f")[t],a=e[t];s.promise.resolve({transactionHash:a})}}error(e){h("Error",{error:e});for(const t of l(this,n,"f"))t.promise.reject(e)}},n=new WeakMap,r=new WeakMap,o=new WeakMap,a=new WeakSet,i=function(e,t){const s=e.txParams.nonce??"0x0",a=parseInt(s,16);h("Processing transaction",{nonce:a,signedTx:t,transactionMeta:e});const i=(0,d.createDeferredPromise)();if(l(this,n,"f").push({nonce:a,promise:i,signedTransaction:t}),c(this,n,(0,m.sortBy)(l(this,n,"f"),e=>e.nonce),"f"),l(this,n,"f").length===l(this,r,"f")){h("All transactions signed");const e=l(this,n,"f").map(e=>e.signedTransaction);l(this,o,"f").resolve({signedTransactions:e})}return i.promise}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/CollectPublishHook.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/ExtraTransactionsPublishHook.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},l=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.ExtraTransactionsPublishHook=void 0;const d=e("@metamask/utils"),m=e("../logger.cjs"),u=(0,d.createModuleLogger)(m.projectLogger,"extra-transactions-publish-hook");s.ExtraTransactionsPublishHook=class{constructor({addTransactionBatch:e,getTransaction:t,originalPublishHook:s}){a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),c(this,n,e,"f"),c(this,r,t,"f"),c(this,o,s,"f")}getHook(){return l(this,a,"m",i).bind(this)}},n=new WeakMap,r=new WeakMap,o=new WeakMap,a=new WeakSet,i=async function(e,t){u("Publishing transaction as batch",{transactionMeta:e,signedTx:t});const{batchTransactions:s,batchTransactionsOptions:a,id:i,networkClientId:c,txParams:m}=e,h=m.from,f=m.to,p=m.data,g=m.value,k=m.gas,b=m.maxFeePerGas,w=m.maxPriorityFeePerGas,_=t,T=(0,d.createDeferredPromise)(),E={existingTransaction:{id:i,onPublish:({newSignature:e,transactionHash:t})=>{if(e){const t=l(this,r,"f").call(this,i);return u("Calling original publish hook with new signature",{latestTransactionMeta:t,newSignature:e}),void l(this,o,"f").call(this,t,e).then(T.resolve).catch(T.reject)}T.resolve({transactionHash:t})},signedTransaction:_},params:{data:p,gas:k,maxFeePerGas:b,maxPriorityFeePerGas:w,to:f,value:g}},I=(s??[]).map(e=>{const{isAfter:t,type:s,...a}=e;return{isAfter:t,params:a,type:s}}),S=[...I.filter(e=>!1===e.isAfter).map(({isAfter:e,...t})=>({...t})),E,...I.filter(e=>e.isAfter===undefined||e.isAfter).map(({isAfter:e,...t})=>({...t}))];u("Adding transaction batch",{from:h,networkClientId:c,transactions:S});const x=a??{disable7702:!0,disableHook:!1,disableSequential:!0};return await l(this,n,"f").call(this,{from:h,networkClientId:c,requireApproval:!1,transactions:S,...x}),T.promise}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/ExtraTransactionsPublishHook.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/SequentialPublishBatchHook.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u,h,f=this&&this.__classPrivateFieldSet||function(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s},p=this&&this.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(s,"__esModule",{value:!0}),s.SequentialPublishBatchHook=void 0;const g=e("@metamask/rpc-errors"),k=e("@metamask/utils"),b=e("../logger.cjs"),w=(0,k.createModuleLogger)(b.projectLogger,"sequential-publish-batch-hook");s.SequentialPublishBatchHook=class{constructor({publishTransaction:e,getTransaction:t,getPendingTransactionTracker:s,getEthQuery:l}){a.add(this),n.set(this,void 0),r.set(this,void 0),o.set(this,void 0),i.set(this,void 0),c.set(this,{}),f(this,n,e,"f"),f(this,r,t,"f"),f(this,o,l,"f"),f(this,i,s,"f")}getHook(){return p(this,a,"m",l).bind(this)}},n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,c=new WeakMap,a=new WeakSet,l=async function({from:e,networkClientId:t,transactions:s}){w("Starting sequential publish batch hook",{from:e,networkClientId:t});const c=p(this,i,"f").call(this,t),l=[];for(const e of s)try{const s=p(this,r,"f").call(this,String(e.id)),i=await p(this,n,"f").call(this,p(this,o,"f").call(this,t),s);w("Transaction published",{transactionHash:i});const m={...s,hash:i},u=p(this,a,"m",d).call(this,c,m.id,m.hash);c.addTransactionToPoll(m),await u,l.push({transactionHash:i})}catch(t){throw w("Batch transaction failed",{transaction:e,error:t}),c.stop(),g.rpcErrors.internal("Failed to publish batch transaction")}return w("Sequential publish batch hook completed",{results:l}),c.stop(),{results:l}},d=async function(e,t,s){return new Promise((n,r)=>{const o=p(this,a,"m",m).bind(this,t,s,n,e),i=p(this,a,"m",u).bind(this,t,s,r,e);p(this,c,"f")[t]={onConfirmed:o,onFailedOrDropped:i},e.hub.on("transaction-confirmed",o),e.hub.on("transaction-failed",i),e.hub.on("transaction-dropped",i)})},m=function(e,t,s,n,r){r.id===e&&(w("Transaction confirmed",{transactionHash:t}),p(this,a,"m",h).call(this,n,e),s(r))},u=function(e,t,s,n,r,o){r.id===e&&(w("Transaction failed or dropped",{transactionHash:t,error:o}),p(this,a,"m",h).call(this,n,e),s(new Error(`Transaction ${t} failed or dropped.`)))},h=function(e,t){const s=p(this,c,"f")[t];e.hub.off("transaction-confirmed",s.onConfirmed),e.hub.off("transaction-failed",s.onFailedOrDropped),e.hub.off("transaction-dropped",s.onFailedOrDropped),delete p(this,c,"f")[t]}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/SequentialPublishBatchHook.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs",{"./TransactionController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/TransactionController.cjs","./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","./helpers/AccountsApiRemoteTransactionSource.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils/gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs","./utils/prepare.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs","./utils/transaction-type.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs","./utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.HARDFORK=s.INCOMING_TRANSACTIONS_SUPPORTED_CHAIN_IDS=s.CHAIN_IDS=s.normalizeTransactionParams=s.isEIP1559Transaction=s.mergeGasFeeEstimates=s.determineTransactionType=s.WalletDevice=s.UserFeeLevel=s.TransactionType=s.TransactionStatus=s.TransactionEnvelopeType=s.TransactionContainerType=s.SimulationTokenStandard=s.SimulationErrorCode=s.GasFeeEstimateType=s.GasFeeEstimateLevel=s.TransactionController=s.SPEED_UP_RATE=s.CANCEL_RATE=void 0;var a=e("./TransactionController.cjs");Object.defineProperty(s,"CANCEL_RATE",{enumerable:!0,get:function(){return a.CANCEL_RATE}}),Object.defineProperty(s,"SPEED_UP_RATE",{enumerable:!0,get:function(){return a.SPEED_UP_RATE}}),Object.defineProperty(s,"TransactionController",{enumerable:!0,get:function(){return a.TransactionController}});var n=e("./types.cjs");Object.defineProperty(s,"GasFeeEstimateLevel",{enumerable:!0,get:function(){return n.GasFeeEstimateLevel}}),Object.defineProperty(s,"GasFeeEstimateType",{enumerable:!0,get:function(){return n.GasFeeEstimateType}}),Object.defineProperty(s,"SimulationErrorCode",{enumerable:!0,get:function(){return n.SimulationErrorCode}}),Object.defineProperty(s,"SimulationTokenStandard",{enumerable:!0,get:function(){return n.SimulationTokenStandard}}),Object.defineProperty(s,"TransactionContainerType",{enumerable:!0,get:function(){return n.TransactionContainerType}}),Object.defineProperty(s,"TransactionEnvelopeType",{enumerable:!0,get:function(){return n.TransactionEnvelopeType}}),Object.defineProperty(s,"TransactionStatus",{enumerable:!0,get:function(){return n.TransactionStatus}}),Object.defineProperty(s,"TransactionType",{enumerable:!0,get:function(){return n.TransactionType}}),Object.defineProperty(s,"UserFeeLevel",{enumerable:!0,get:function(){return n.UserFeeLevel}}),Object.defineProperty(s,"WalletDevice",{enumerable:!0,get:function(){return n.WalletDevice}});var r=e("./utils/transaction-type.cjs");Object.defineProperty(s,"determineTransactionType",{enumerable:!0,get:function(){return r.determineTransactionType}});var o=e("./utils/gas-flow.cjs");Object.defineProperty(s,"mergeGasFeeEstimates",{enumerable:!0,get:function(){return o.mergeGasFeeEstimates}});var i=e("./utils/utils.cjs");Object.defineProperty(s,"isEIP1559Transaction",{enumerable:!0,get:function(){return i.isEIP1559Transaction}}),Object.defineProperty(s,"normalizeTransactionParams",{enumerable:!0,get:function(){return i.normalizeTransactionParams}});var c=e("./constants.cjs");Object.defineProperty(s,"CHAIN_IDS",{enumerable:!0,get:function(){return c.CHAIN_IDS}});var l=e("./helpers/AccountsApiRemoteTransactionSource.cjs");Object.defineProperty(s,"INCOMING_TRANSACTIONS_SUPPORTED_CHAIN_IDS",{enumerable:!0,get:function(){return l.SUPPORTED_CHAIN_IDS}});var d=e("./utils/prepare.cjs");Object.defineProperty(s,"HARDFORK",{enumerable:!0,get:function(){return d.HARDFORK}})}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs",{"@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.createModuleLogger=s.incomingTransactionsLogger=s.projectLogger=void 0;const a=e("@metamask/utils");Object.defineProperty(s,"createModuleLogger",{enumerable:!0,get:function(){return a.createModuleLogger}}),s.projectLogger=(0,a.createProjectLogger)("transaction-controller"),s.incomingTransactionsLogger=(0,a.createModuleLogger)(s.projectLogger,"incoming-transactions")}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a,n,r,o,i,c,l,d,m,u;Object.defineProperty(s,"__esModule",{value:!0}),s.SimulationErrorCode=s.SimulationTokenStandard=s.GasFeeEstimateType=s.GasFeeEstimateLevel=s.UserFeeLevel=s.TransactionEnvelopeType=s.TransactionContainerType=s.TransactionType=s.WalletDevice=s.TransactionStatus=void 0,function(e){e.unapproved="unapproved",e.approved="approved",e.signed="signed",e.submitted="submitted",e.confirmed="confirmed",e.failed="failed",e.dropped="dropped",e.rejected="rejected",e.cancelled="cancelled"}(a||(s.TransactionStatus=a={})),function(e){e.MM_MOBILE="metamask_mobile",e.MM_EXTENSION="metamask_extension",e.OTHER="other_device"}(n||(s.WalletDevice=n={})),function(e){e.batch="batch",e.bridge="bridge",e.bridgeApproval="bridgeApproval",e.cancel="cancel",e.contractInteraction="contractInteraction",e.deployContract="contractDeployment",e.ethDecrypt="eth_decrypt",e.ethGetEncryptionPublicKey="eth_getEncryptionPublicKey",e.gasPayment="gas_payment",e.incoming="incoming",e.lendingDeposit="lendingDeposit",e.lendingWithdraw="lendingWithdraw",e.moneyAccountDeposit="moneyAccountDeposit",e.moneyAccountWithdraw="moneyAccountWithdraw",e.musdClaim="musdClaim",e.musdConversion="musdConversion",e.perpsAcrossDeposit="perpsAcrossDeposit",e.perpsDeposit="perpsDeposit",e.perpsDepositAndOrder="perpsDepositAndOrder",e.perpsRelayDeposit="perpsRelayDeposit",e.perpsWithdraw="perpsWithdraw",e.personalSign="personal_sign",e.predictAcrossDeposit="predictAcrossDeposit",e.predictBuy="predictBuy",e.predictClaim="predictClaim",e.predictDeposit="predictDeposit",e.predictDepositAndOrder="predictDepositAndOrder",e.predictSell="predictSell",e.predictWithdraw="predictWithdraw",e.predictRelayDeposit="predictRelayDeposit",e.relayDeposit="relayDeposit",e.retry="retry",e.revokeDelegation="revokeDelegation",e.simpleSend="simpleSend",e.signTypedData="eth_signTypedData",e.smart="smart",e.stakingClaim="stakingClaim",e.stakingDeposit="stakingDeposit",e.stakingUnstake="stakingUnstake",e.swap="swap",e.swapAndSend="swapAndSend",e.swapApproval="swapApproval",e.tokenMethodApprove="approve",e.tokenMethodSafeTransferFrom="safetransferfrom",e.tokenMethodTransfer="transfer",e.tokenMethodTransferFrom="transferfrom",e.tokenMethodSetApprovalForAll="setapprovalforall",e.tokenMethodIncreaseAllowance="increaseAllowance",e.shieldSubscriptionApprove="shieldSubscriptionApprove"}(r||(s.TransactionType=r={})),function(e){e.EnforcedSimulations="enforcedSimulations"}(o||(s.TransactionContainerType=o={})),function(e){e.legacy="0x0",e.accessList="0x1",e.feeMarket="0x2",e.setCode="0x4"}(i||(s.TransactionEnvelopeType=i={})),function(e){e.CUSTOM="custom",e.DAPP_SUGGESTED="dappSuggested",e.MEDIUM="medium"}(c||(s.UserFeeLevel=c={})),function(e){e.Low="low",e.Medium="medium",e.High="high"}(l||(s.GasFeeEstimateLevel=l={})),function(e){e.FeeMarket="fee-market",e.Legacy="legacy",e.GasPrice="eth_gasPrice"}(d||(s.GasFeeEstimateType=d={})),function(e){e.erc20="erc20",e.erc721="erc721",e.erc1155="erc1155"}(m||(s.SimulationTokenStandard=m={})),function(e){e.ChainNotSupported="chain-not-supported",e.Disabled="disabled",e.InvalidResponse="invalid-response",e.Reverted="reverted"}(u||(s.SimulationErrorCode=u={}))}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/balance-changes.cjs",{"../api/simulation-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs","../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","../errors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/errors.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./balance.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/balance.cjs","@ethersproject/abi":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/abi/lib/index.js","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/metamask-eth-abis":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/metamask-eth-abis/dist/index.js","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bn.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/bn.js/lib/bn.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.getBalanceChanges=s.SupportedToken=void 0;const n=e("@ethersproject/abi"),r=e("@metamask/controller-utils"),o=e("@metamask/metamask-eth-abis"),i=e("@metamask/utils"),c=a(e("bn.js")),l=e("./balance.cjs"),d=e("../api/simulation-api.cjs"),m=e("../constants.cjs"),u=e("../errors.cjs"),h=e("../logger.cjs"),f=e("../types.cjs");var p;!function(e){e.ERC20="erc20",e.ERC721="erc721",e.ERC1155="erc1155",e.ERC20_WRAPPED="erc20Wrapped",e.ERC721_LEGACY="erc721Legacy"}(p||(s.SupportedToken=p={}));const g=(0,i.createModuleLogger)(h.projectLogger,"balance-changes"),k=["Transfer","TransferSingle","TransferBatch","Deposit","Withdrawal"],b={[p.ERC20]:{abi:o.abiERC20,standard:f.SimulationTokenStandard.erc20},[p.ERC721]:{abi:o.abiERC721,standard:f.SimulationTokenStandard.erc721},[p.ERC1155]:{abi:o.abiERC1155,standard:f.SimulationTokenStandard.erc1155},[p.ERC20_WRAPPED]:{abi:m.ABI_SIMULATION_ERC20_WRAPPED,standard:f.SimulationTokenStandard.erc20},[p.ERC721_LEGACY]:{abi:m.ABI_SIMULATION_ERC721_LEGACY,standard:f.SimulationTokenStandard.erc721}},w=["execution reverted","insufficient funds for gas"];function _(e){if(Array.isArray(e))return e.map(_);let t=e;return t=t.toHexString?.()??t,t=t.toLowerCase?.()??t,t}function T(e){return"Transfer"===e.name&&e.tokenStandard===f.SimulationTokenStandard.erc721&&0===parseInt(e.args.from,16)}function E(e){return e.tokenStandard===f.SimulationTokenStandard.erc721?[e.args.tokenId]:e.tokenStandard===f.SimulationTokenStandard.erc1155&&"TransferSingle"===e.name?[e.args.id]:e.tokenStandard===f.SimulationTokenStandard.erc1155&&"TransferBatch"===e.name?e.args.ids:[undefined]}function I(e){switch(e){case f.SimulationTokenStandard.erc721:return new n.Interface(o.abiERC721);case f.SimulationTokenStandard.erc1155:return new n.Interface(o.abiERC1155);default:return new n.Interface(o.abiERC20)}}function S(e,t,s){const a=I(t.standard);try{if(t.standard===f.SimulationTokenStandard.erc721){const t=a.decodeFunctionResult("ownerOf",s.return);return t[0].toLowerCase()===e.toLowerCase()?"0x1":"0x0"}const n=a.decodeFunctionResult("balanceOf",s.return);return(0,r.toHex)(n[0])}catch(e){throw g("Failed to decode balance transaction",e,{token:t,response:s}),new u.SimulationError(`Failed to decode balance transaction for token ${t.address}: ${String(e)}`)}}function x(e,t,s){const a=I(e);switch(e){case f.SimulationTokenStandard.erc721:return a.encodeFunctionData("ownerOf",[s]);case f.SimulationTokenStandard.erc1155:return a.encodeFunctionData("balanceOf",[t,s]);default:return a.encodeFunctionData("balanceOf",[t])}}function y(e){return[...e.logs??[],...(e.calls??[]).map(e=>y(e)).flat()]}function A(e){if(!e)return[];return[...e.error?[e.error]:[],...(e.calls??[]).flatMap(e=>A(e))]}function v(e,t,s=0){const a=(0,r.hexToBN)(t).add(new c.default(s)),n=(0,r.hexToBN)(e),o=a.sub(n),i=o.isNeg(),l=(0,r.toHex)(o.abs());return o.isZero()?(g("Balance change is zero"),undefined):{previousBalance:e,newBalance:(0,r.toHex)(a),difference:l,isDecrease:i}}async function P({request:e,params:t,before:s=[],after:a=[]}){const{blockTime:n,chainId:o,ethQuery:i,getSimulationConfig:m,txParams:u}=e,{authorizationList:h}=u,f=u.from,p=h?.map(e=>({address:e.address,from:f})),k=[...s,{authorizationList:p,data:u.data,from:u.from,gas:u.gas,maxFeePerGas:u.maxFeePerGas??u.gasPrice,maxPriorityFeePerGas:u.maxPriorityFeePerGas??u.gasPrice,to:u.to,value:u.value},...a],b=function(e){const{txParams:t}=e,s=(0,r.hexToBN)(t.gas??"0x0"),a=(0,r.hexToBN)(t.maxFeePerGas??t.gasPrice??"0x0"),n=(0,r.hexToBN)(t.value??"0x0"),o=(e.nestedTransactions??[]).map(e=>(0,r.hexToBN)(e.value??"0x0")).reduce((e,t)=>e.add(t),new c.default(0));return s.mul(a).add(n).add(o)}(e),w=(0,r.toHex)(b);g("Required balance",w);const{balanceRaw:_}=await(0,l.getNativeBalance)(f,i),T=(0,r.toHex)(_),E=(0,r.hexToBN)(T);g("Current balance",T);const I=E.lt(b);return await(0,d.simulateTransactions)(o,{...t,getSimulationConfig:m,transactions:k,withGas:!0,withDefaultBlockOverrides:!0,...n&&{blockOverrides:{...t?.blockOverrides,time:(0,r.toHex)(n)}},...I&&{overrides:{...t?.overrides,[f]:{...t?.overrides?.[f],balance:w}}}})}s.getBalanceChanges=async function(e){let t;g("Request",e);try{const s=await P({request:e,params:{withCallTrace:!0,withLogs:!0}}),a=s.transactions?.[0];t=A(a?.callTrace);const r=a?.error;if(r)throw new u.SimulationError(r);const o=function(e,t){const s=t.transactions[0];if(!s)return undefined;const{txParams:a}=e,n=a.from,{stateDiff:r}=s,o=r?.pre?.[n]?.balance,i=r?.post?.[n]?.balance;if(!o||!i)return undefined;return v(o,i,s.gasCost)}(e,s),i=function(e){const t=y(e.transactions[0]?.callTrace??{});g("Extracted logs",t);const s=function(){const e=Object.values(p);return new Map(e.map(e=>{const{abi:t}=b[e];return[e,new n.Interface(t)]}))}();return t.map(e=>{const t=function(e,t){const s=Object.values(p);for(const a of s)try{const s=t.get(a),{abi:n,standard:r}=b[a];return{...s.parseLog(e),abi:n,standard:r}}catch{continue}return undefined}(e,s);if(!t)return g("Failed to parse log",e),undefined;const a=t.abi.find(e=>e.name===t.name)?.inputs;if(!a)return g("Failed to find inputs for event",t),undefined;if(!k.includes(t.name))return g("Ignoring unsupported event",t.name,t),undefined;g("Normalizing event args",t.name,t);const n=function(e,t){return e.reduce((e,s,a)=>{const n=t[a].name.replace("_",""),r=_(s);return e[n]=r,e},{})}(t.args,a);return{contractAddress:e.address,tokenStandard:t.standard,name:t.name,args:n,abi:t.abi}}).filter(e=>e!==undefined)}(s);g("Parsed events",i);const c=await async function(e,t){const{txParams:s}=e,a=s.from,n=function(e,t){const s=new Set,a=new Map,n=new Map,r=e.txParams.from,o=t.filter(e=>[e.args.from,e.args.to].includes(r));g("Filtered user events",o);for(const e of o){const t=E(e);g("Extracted token IDs",t);for(const o of t){const t={address:e.contractAddress,standard:e.tokenStandard,id:o},i=JSON.stringify(t);if(s.has(i)){g("Ignoring additional event with same contract and token ID",t);continue}s.add(i);const c=x(e.tokenStandard,r,o),l={from:r,to:e.contractAddress,data:c};T(e)||a.set(t,l),n.set(t,l)}}return{before:a,after:n}}(e,t);g("Generated balance transactions",[...n.after.values()]);const r=n.before.size+n.after.size+1;if(1===r)return[];const o=await P({request:e,before:[...n.before.values()],after:[...n.after.values()]});if(g("Balance simulation response",o),o.transactions.length!==r)throw new u.SimulationInvalidResponseError;let i=0;return[...n.after.keys()].map((e,t)=>{const s=v(!n.before.get(e)?"0x0":S(a,e,o.transactions[i++]),S(a,e,o.transactions[t+n.before.size+1]));return s?{...e,...s}:undefined}).filter(e=>e!==undefined)}(e,i),l=a?.gasUsed;return{simulationData:{callTraceErrors:t,nativeBalanceChange:o,tokenBalanceChanges:c},gasUsed:l}}catch(s){g("Failed to get balance changes",s,e);let a=s;w.some(e=>a.message?.includes(e))&&(a=new u.SimulationRevertedError);const{code:n,message:r}=a;return{simulationData:{callTraceErrors:t,tokenBalanceChanges:[],error:{code:n,message:r}},gasUsed:undefined}}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/balance-changes.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/balance.cjs",{"@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.isNativeBalanceSufficientForGas=s.getNativeBalance=void 0;const a=e("@metamask/controller-utils"),n=e("bignumber.js");async function r(e,t){const s=await(0,a.query)(t,"getBalance",[e,"latest"]),r=new n.BigNumber(s).toString(10);return{balanceHuman:new n.BigNumber(r).shiftedBy(-18).toString(10),balanceRaw:r}}s.getNativeBalance=r,s.isNativeBalanceSufficientForGas=async function(e,t){const s=e.txParams.from,a=new n.BigNumber(e.txParams.gas??"0x0").multipliedBy(e.txParams.maxFeePerGas??e.txParams.gasPrice??"0x0"),{balanceRaw:o}=await r(s,t);return a.isLessThanOrEqualTo(o)}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/balance.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs",{"../gas-flows/DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","../helpers/GasFeePoller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs","../hooks/CollectPublishHook.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/CollectPublishHook.cjs","../hooks/SequentialPublishBatchHook.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/hooks/SequentialPublishBatchHook.cjs","../index.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/index.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","./gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas.cjs","./validation.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/validation.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs",uuid:"/home/runner/work/metamask-extension/metamask-extension/node_modules/uuid/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.isAtomicBatchSupported=s.addTransactionBatch=s.ERROR_MESSAGE_NO_UPGRADE_CONTRACT=void 0;const a=e("@metamask/controller-utils"),n=e("@metamask/rpc-errors"),r=e("@metamask/utils"),o=e("uuid"),i=e("./eip7702.cjs"),c=e("./feature-flags.cjs"),l=e("./gas.cjs"),d=e("./validation.cjs"),m=e("../index.cjs"),u=e("../gas-flows/DefaultGasFeeFlow.cjs"),h=e("../helpers/GasFeePoller.cjs"),f=e("../hooks/CollectPublishHook.cjs"),p=e("../hooks/SequentialPublishBatchHook.cjs"),g=e("../logger.cjs"),k=e("../types.cjs"),b=(0,r.createModuleLogger)(g.projectLogger,"batch");function w(){const e=(0,o.v4)(),t=new Uint8Array((0,o.parse)(e));return(0,r.bytesToHex)(t)}async function _(e,t,s,n,r,o){const{assetsFiatValues:i,existingTransaction:c,params:l,type:d}=t,{addTransaction:u,getTransaction:f,request:p,updateTransaction:g}=n,{from:k,networkClientId:w,origin:_}=p;if(c){const{id:t,onPublish:r}=c;let i=f(t);const d=i.txParams.nonce;let{signedTransaction:m}=c;const u=d?parseInt(d,16):undefined,h=o>0&&u!==undefined?u+o:undefined;if(g({transactionId:t},t=>{t.batchId=e,h&&(t.txParams.nonce=(0,a.toHex)(h))}),h){const e=await T({transactionId:t,request:n});m=e.newSignature,i=e.transactionMeta}return s(i,m).then(r).catch(()=>{}),b("Processed existing transaction with hook",{id:t,params:l}),{id:t,params:l}}const E={...r,txParams:{...l,from:k,gas:r?.gas??l.gas}};r&&(0,h.updateTransactionGasEstimates)({txMeta:E,userFeeLevel:m.GasFeeEstimateLevel.Medium});const{transactionMeta:I}=await u(E.txParams,{assetsFiatValues:i,batchId:e,disableGasBuffer:!0,networkClientId:w,origin:_,publishHook:s,requireApproval:!1,type:d}),{id:S,txParams:x}=I,y={data:x.data,gas:x.gas,maxFeePerGas:x.maxFeePerGas,maxPriorityFeePerGas:x.maxPriorityFeePerGas,to:x.to,value:x.value};return b("Processed new transaction with hook",{id:S,params:y,type:d}),{id:S,params:y,type:d}}async function T({request:e,transactionId:t}){const{getTransaction:s,signTransaction:a}=e,n=s(t);b("Re-signing existing transaction",{transactionId:t,txParams:n.txParams});const r=await a(n);if(!r)throw new Error("Failed to re-sign transaction");const o=s(t);return b("New signature",r),{newSignature:r,transactionMeta:o}}s.ERROR_MESSAGE_NO_UPGRADE_CONTRACT="Upgrade contract address not found",s.addTransactionBatch=async function(e){const{getInternalAccounts:t,messenger:r,request:o}=e,h=(0,c.getBatchSizeLimit)(r);if((0,d.validateBatchRequest)({internalAccounts:t(),request:o,sizeLimit:h}),b("Adding",o),!o.disable7702)try{return await async function(e){const{addTransaction:t,getChainId:a,messenger:r,publicKeyEIP7702:o,request:l}=e,{batchId:d,disableUpgrade:u,from:h,gasFeeToken:f,gasLimit7702:p,networkClientId:g,origin:_,overwriteUpgrade:E,requestId:I,requiredAssets:S,requireApproval:x,securityAlertId:y,skipInitialGasEstimate:A,transactions:v,validateSecurity:P}=l,C=a(g),j=e.getEthQuery(g),N=(0,i.doesChainSupportEIP7702)(C,r);if(!N)throw b("Chain does not support EIP-7702",C),n.rpcErrors.internal("Chain does not support EIP-7702");if(!o)throw n.rpcErrors.internal(i.ERROR_MESSGE_PUBLIC_KEY);let D=!1;if(!u){const{delegationAddress:e,isSupported:t}=await(0,i.isAccountUpgradedToEIP7702)(h,C,o,r,j);if(b("Account",{delegationAddress:e,isSupported:t}),!t&&e&&!E)throw b("Account upgraded to unsupported contract",h,e),n.rpcErrors.internal("Account upgraded to unsupported contract");D=!t,D&&e&&b("Overwriting authorization as already upgraded",{current:e})}const R=await Promise.all(v.map(e=>async function(e,t,s){const{from:a}=e,{params:n,type:r}=t;if(r)return{...n,type:r};const{type:o}=await(0,m.determineTransactionType)({from:a,...n},s);return{...n,type:o}}(l,e,j))),F={...(0,i.generateEIP7702BatchTransaction)(h,R),from:h,gas:p,maxFeePerGas:R[0]?.maxFeePerGas,maxPriorityFeePerGas:R[0]?.maxPriorityFeePerGas};if(D){const e=(0,c.getEIP7702UpgradeContractAddress)(C,r,o);if(!e)throw n.rpcErrors.internal(s.ERROR_MESSAGE_NO_UPGRADE_CONTRACT);F.type=k.TransactionEnvelopeType.setCode,F.authorizationList=[{address:e}]}if(P){const e={method:"eth_sendTransaction",params:[{...F,authorizationList:undefined,type:k.TransactionEnvelopeType.feeMarket}],delegationMock:F.authorizationList?.[0]?.address,origin:_};b("Security request",e),P(e,C).catch(e=>{b("Security validation failed",e)})}b("Adding batch transaction",F,g);const L=d??w(),M=y?{securityAlertId:y}:undefined,O=v.find(e=>e.existingTransaction)?.existingTransaction;if(O)return await async function({batchId:e,existingTransaction:t,nestedTransactions:s,request:a,txParams:n}){const{getTransaction:r,estimateGas:o,updateTransaction:i}=a,c=r(t.id);if(!c)throw new Error("Existing transaction not found");b("Converting existing transaction to 7702",{batchId:e,txParams:n});const{networkClientId:l}=c,d=await o(n,l);b("Estimated gas for converted EIP-7702 transaction",d),i({transactionId:c.id},t=>{var a;t.batchId=e,t.nestedTransactions=s,t.txParams=n,t.txParams.gas=d.gas,t.txParams.gasLimit=d.gas,t.txParams.maxFeePerGas=c.txParams.maxFeePerGas,t.txParams.maxPriorityFeePerGas=c.txParams.maxPriorityFeePerGas,t.txParams.nonce=c.txParams.nonce,(a=t.txParams).type??(a.type=k.TransactionEnvelopeType.feeMarket)});const{newSignature:m}=await T({request:a,transactionId:c.id});t.onPublish?.({transactionHash:undefined,newSignature:m}),b("Transaction updated to EIP-7702",{batchId:e,txParams:n,newSignature:m})}({batchId:L,existingTransaction:O,nestedTransactions:R,request:e,txParams:F}),{batchId:L};const{result:B}=await t(F,{batchId:L,gasFeeToken:f,isGasFeeIncluded:l.isGasFeeIncluded,isGasFeeSponsored:l.isGasFeeSponsored,nestedTransactions:R,networkClientId:g,origin:_,requestId:I,requireApproval:x,requiredAssets:S,securityAlertResponse:M,skipInitialGasEstimate:A,type:k.TransactionType.batch}),G=await B;return b("Batch transaction added",{batchId:L,transactionHash:G}),{batchId:L}}(e)}catch(e){if(!(e instanceof n.JsonRpcError&&"Chain does not support EIP-7702"===e.message))throw e}return await async function(e){const{messenger:t,publishBatchHook:s,request:r,update:o}=e,{batchId:i,from:c,networkClientId:d,origin:h,requireApproval:g,transactions:k}=r;let T,E=!1;b("Adding transaction batch using hook",r);const I=new p.SequentialPublishBatchHook({publishTransaction:e.publishTransaction,getTransaction:e.getTransaction,getEthQuery:e.getEthQuery,getPendingTransactionTracker:e.getPendingTransactionTracker});let{disable7702:S,disableSequential:x}=r;const{disableHook:y,useHook:A}=r;A&&(S=!0,x=!0);let v,P=null;!y&&s?P=s:x||(P=I.getHook(),E=!0);if(!P)throw b("No supported batch methods found",{disable7702:S,disableHook:y,disableSequential:x}),n.rpcErrors.internal("Can't process batch");const C=i??w(),j=k.map(e=>({...e,origin:h})),N=j.length,D=new f.CollectPublishHook(N);try{g&&(v=await async function({batchId:e,request:t}){const{messenger:s,request:a,isSimulationEnabled:n,getChainId:r,getEthQuery:o,getGasFeeEstimates:i,getSimulationConfig:c,update:d}=t,{from:h,origin:f,networkClientId:p,transactions:g}=a,k=o(p);if(!n())throw new Error("Cannot create transaction batch as simulation not supported");b("Preparing approval data for batch");const w=r(p),{totalGasLimit:_}=await(0,l.simulateGasBatch)({chainId:w,from:h,getSimulationConfig:c,transactions:g}),T=(x={chainId:w,from:h,gas:_,id:e,networkClientId:p,origin:f,transactions:g},{...x,status:m.TransactionStatus.unapproved}),E=new u.DefaultGasFeeFlow,I=await i({networkClientId:p}),S=await E.getGasFees({ethQuery:k,gasFeeControllerData:I,messenger:s,transactionMeta:{...T,txParams:{from:h,gas:_},time:Date.now()}});var x;return T.gasFeeEstimates=S.estimates,b("Saving transaction batch metadata",T),function(e,t){t(t=>{t.transactionBatches=[...t.transactionBatches,e]})}(T,d),T}({batchId:C,request:e}),T=(await async function(e,t){const s=String(e.id),{origin:n}=e,r=a.ApprovalType.TransactionBatch,o={txBatchId:s};return b("Requesting approval for transaction batch",s),await t.call("ApprovalController:addRequest",{id:s,origin:n??a.ORIGIN_METAMASK,requestData:o,expectsResult:!0,type:r},!0)}(v,t)).resultCallbacks);const s=D.getHook(),n=[];let r=0;for(const t of j){const a=await _(C,t,s,e,v,r);n.push(a),r+=1}const{signedTransactions:o}=await D.ready(),i={from:c,networkClientId:d,transactions:n.map((e,t)=>({...e,signedTx:o[t]}))};b("Calling publish batch hook",i);let h=await P(i);if(b("Publish batch hook result",h),!h&&!E&&!x){b("Fallback to sequential publish batch hook due to empty results");const e=I.getHook();h=await e(i)}if(!h?.results?.length)throw new Error("Publish batch hook did not return a result");const f=h.results.map(({transactionHash:e})=>e);return D.success(f),T?.success(),b("Completed batch transaction with hook",f),{batchId:C}}catch(e){throw b("Publish batch hook failed",e),D.error(e),T?.error(e),e}finally{b("Cleaning up publish batch hook",C),function(e,t){e(e=>{e.transactionBatches=e.transactionBatches.filter(e=>e.id!==t)})}(o,C)}}(e)},s.isAtomicBatchSupported=async function(e){const{address:t,chainIds:s,getEthQuery:a,messenger:r,publicKeyEIP7702:o}=e;if(!o)throw n.rpcErrors.internal(i.ERROR_MESSGE_PUBLIC_KEY);const l=(0,c.getEIP7702SupportedChains)(r).filter(e=>!s||s.includes(e)),d=(await Promise.all(l.map(async e=>{try{const s=a(e),{isSupported:n,delegationAddress:l}=await(0,i.isAccountUpgradedToEIP7702)(t,e,o,r,s);return{chainId:e,delegationAddress:l,isSupported:n,upgradeContractAddress:(0,c.getEIP7702UpgradeContractAddress)(e,r,o)}}catch(t){return b("Error checking atomic batch support",e,t),undefined}}))).filter(e=>Boolean(e));return b("Atomic batch supported results",d),d}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","@ethersproject/abi":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/abi/lib/index.js","@ethersproject/contracts":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/contracts/lib/index.js","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.signAuthorizationList=s.generateEIP7702BatchTransaction=s.isAccountUpgradedToEIP7702=s.getDelegationAddress=s.doesChainSupportEIP7702=s.ERROR_MESSGE_PUBLIC_KEY=s.CALLS_SIGNATURE=s.BATCH_FUNCTION_NAME=s.DELEGATION_PREFIX=void 0;const a=e("@ethersproject/abi"),n=e("@ethersproject/contracts"),r=e("@metamask/controller-utils"),o=e("@metamask/utils"),i=e("./feature-flags.cjs"),c=e("../constants.cjs"),l=e("../logger.cjs");s.DELEGATION_PREFIX="0xef0100",s.BATCH_FUNCTION_NAME="execute",s.CALLS_SIGNATURE="(address,uint256,bytes)[]",s.ERROR_MESSGE_PUBLIC_KEY="EIP-7702 public key not specified";const d=(0,o.createModuleLogger)(l.projectLogger,"eip-7702");async function m(e,t){const a=await(0,r.query)(t,"eth_getCode",[e]),n=(0,o.add0x)(a?.toLowerCase?.()??"");return 48===a?.length&&n.startsWith(s.DELEGATION_PREFIX)?(0,o.add0x)(n.slice(s.DELEGATION_PREFIX.length)):undefined}async function u(e,t,s,a){const n=function(e,t,s){const{chainId:a,nonce:n}=e,{txParams:o,chainId:i}=t,{nonce:c}=o,l=a??i;let m=n;m??(m=(0,r.toHex)(parseInt(c,16)+1+s));const u={...e,chainId:l,nonce:m};return d("Prepared authorization",u),u}(e,t,a),{txParams:i}=t,{from:c}=i,{address:l,chainId:m,nonce:u}=n,h=parseInt(m,16),f=parseInt(u,16),p=await s.call("KeyringController:signEip7702Authorization",{chainId:h,contractAddress:l,from:c,nonce:f}),g=p.slice(0,66),k=(0,o.add0x)(p.slice(66,130)),b=parseInt(p.slice(130,132),16),w={address:l,chainId:m,nonce:u,r:g,s:k,yParity:(0,r.toHex)(b-27==0?0:1)};return d("Signed authorization",w),w}s.doesChainSupportEIP7702=function(e,t){return(0,i.getEIP7702SupportedChains)(t).some(t=>t.toLowerCase()===e.toLowerCase())},s.getDelegationAddress=m,s.isAccountUpgradedToEIP7702=async function(e,t,s,a,n){const r=(0,i.getEIP7702ContractAddresses)(t,a,s),o=await m(e,n),c=Boolean(o&&r.some(e=>e.toLowerCase()===o.toLowerCase()));return{delegationAddress:o,isSupported:c}},s.generateEIP7702BatchTransaction=function(e,t){const r=n.Contract.getInterface(c.ABI_IERC7821),o=t.map(e=>{const{data:t,to:s,value:a}=e;return[s??"0x0000000000000000000000000000000000000000",a??"0x0",t??"0x"]}),i="0x01".padEnd(66,"0"),l=a.defaultAbiCoder.encode([s.CALLS_SIGNATURE],[o]),m=r.encodeFunctionData(s.BATCH_FUNCTION_NAME,[i,l]);return d("Transaction data",m),{data:m,to:e}},s.signAuthorizationList=async function({authorizationList:e,messenger:t,transactionMeta:s}){if(!e)return undefined;const a=[];let n=0;for(const r of e){const e=await u(r,s,t,n);a.push(e),n+=1}return a}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.validateConfirmedExternalTransaction=void 0;const a=e("@metamask/rpc-errors"),n=e("../types.cjs");s.validateConfirmedExternalTransaction=function(e,t,s){if(!e?.txParams)throw a.rpcErrors.invalidParams('"transactionMeta" or "transactionMeta.txParams" is missing');if(e.status!==n.TransactionStatus.confirmed)throw a.rpcErrors.invalidParams('External transaction status should be "confirmed"');const r=e.txParams.nonce;if(s&&s.length>0){if(s.find(e=>e.txParams?.nonce===r))throw a.rpcErrors.invalidParams("External transaction nonce should not be in pending txs")}if(t&&t.length>0){if(t.find(e=>e.txParams?.nonce===r))throw a.rpcErrors.invalidParams("External transaction nonce should not be in confirmed txs")}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","./signature.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/signature.cjs","./utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.isIncomingTransactionsUseBackendWebSocketServiceEnabled=s.getTimeoutAttempts=s.getIncomingTransactionsPollingInterval=s.getGasEstimateBuffer=s.getGasEstimateFallback=s.getGasFeeRandomisation=s.getAcceleratedPollingParams=s.getTransactionHistoryLimit=s.getSubmitHistoryLimit=s.getBatchSizeLimit=s.getEIP7702UpgradeContractAddress=s.getEIP7702ContractAddresses=s.getEIP7702SupportedChains=s.FeatureFlag=void 0;const a=e("@metamask/utils"),n=e("./signature.cjs"),r=e("./utils.cjs"),o=e("../logger.cjs");var i;!function(e){e.EIP7702="confirmations_eip_7702",e.GasBuffer="confirmations_gas_buffer",e.IncomingTransactions="confirmations_incoming_transactions",e.Transactions="confirmations_transactions"}(i||(s.FeatureFlag=i={}));const c=(0,a.createModuleLogger)(o.projectLogger,"feature-flags");function l(e,t,s){const a=d(t);return(a?.[i.EIP7702]?.contracts?.[e.toLowerCase()]??[]).filter(t=>(0,n.isValidSignature)([t.address,(0,r.padHexToEvenLength)(e)],t.signature,s)).map(e=>e.address)}function d(e){const t=e.call("RemoteFeatureFlagController:getState").remoteFeatureFlags;return c("Retrieved feature flags",t),t}s.getEIP7702SupportedChains=function(e){const t=d(e);return t?.[i.EIP7702]?.supportedChains??[]},s.getEIP7702ContractAddresses=l,s.getEIP7702UpgradeContractAddress=function(e,t,s){return l(e,t,s)?.[0]},s.getBatchSizeLimit=function(e){const t=d(e);return t?.[i.Transactions]?.batchSizeLimit??10},s.getSubmitHistoryLimit=function(e){const t=d(e);return t?.[i.Transactions]?.submitHistoryLimit??100},s.getTransactionHistoryLimit=function(e){const t=d(e);return t?.[i.Transactions]?.transactionHistoryLimit??40},s.getAcceleratedPollingParams=function(e,t){const s=d(t),a=s?.[i.Transactions]?.acceleratedPolling,n=a?.perChainConfig?.[e]?.countMax??a?.defaultCountMax??10,r=a?.perChainConfig?.[e]?.intervalMs??a?.defaultIntervalMs??3e3;return{blockTime:a?.perChainConfig?.[e]?.blockTime??12e3,countMax:n,intervalMs:r}},s.getGasFeeRandomisation=function(e){const t=d(e),s=t?.[i.Transactions]?.gasFeeRandomisation??{};return{randomisedGasFeeDigits:s.randomisedGasFeeDigits??{},preservedNumberOfDigits:s.preservedNumberOfDigits}},s.getGasEstimateFallback=function(e,t){const s=d(t),a=s?.[i.Transactions]?.gasEstimateFallback,n=a?.perChainConfig?.[e],r=n?.percentage??a?.default?.percentage??35;return{fixed:n?.fixed??a?.default?.fixed,percentage:r}},s.getGasEstimateBuffer=function({chainId:e,isCustomRPC:t,isUpgradeWithDataToSelf:s,messenger:a}){const n=d(a),r=n?.[i.GasBuffer],o=r?.perChainConfig?.[e],c=t?undefined:o?.included,l=t?undefined:r?.included;return(s?o?.eip7702:undefined)??c??o?.base??l??r?.default??1},s.getIncomingTransactionsPollingInterval=function(e){const t=d(e);return t?.[i.IncomingTransactions]?.pollingIntervalMs??24e4},s.getTimeoutAttempts=function(e,t){const s=d(t),a=s?.[i.Transactions]?.timeoutAttempts;return a?.perChainConfig?.[e]??a?.default},s.isIncomingTransactionsUseBackendWebSocketServiceEnabled=function(e){const t=d(e);return t?.[i.IncomingTransactions]?.useBackendWebSocketService??!1}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/first-time-interaction.cjs",{"../api/accounts-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./transaction-type.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs","./validation.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/validation.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.updateFirstTimeInteraction=void 0;const a=e("@metamask/utils"),n=e("./transaction-type.cjs"),r=e("./validation.cjs"),o=e("../api/accounts-api.cjs"),i=e("../logger.cjs"),c=e("../types.cjs"),l=[c.TransactionType.tokenMethodTransfer,c.TransactionType.tokenMethodTransferFrom];function d(e){const{data:t,to:s}=e?.txParams??{};if(t&&l.includes(e?.type)){const e=(0,n.decodeTransactionData)(t);return e?.args?._to??e?.args?.to??s}return s}s.updateFirstTimeInteraction=async function({existingTransactions:e,getTransaction:t,isFirstTimeInteractionEnabled:s,trace:n,traceContext:c,transactionMeta:l,updateTransaction:m}){if(!s())return;const{chainId:u,id:h,txParams:{from:f}}=l,p=d(l),g={chainId:(0,a.hexToNumber)(u),to:p,from:f};(0,r.validateParamTo)(p);const k=p?.toLowerCase();if(!e.find(e=>e.id!==h&&e.chainId===u&&e.txParams?.from?.toLowerCase()===f?.toLowerCase()&&d(e)?.toLowerCase()===k))try{const{count:e}=await n({name:"Account Address Relationship",parentContext:c},()=>(0,o.getAccountAddressRelationship)(g)),s=e===undefined?undefined:0===e;if(!t(h))return void(0,i.projectLogger)("Cannot update first time interaction as transaction not found",h);m({transactionId:h,note:"TransactionController#updateFirstInteraction - Update first time interaction"},e=>{e.isFirstTimeInteraction=s}),(0,i.projectLogger)("Updated first time interaction",h,{isFirstTimeInteraction:s})}catch(e){(0,i.projectLogger)("Error fetching account address relationship, skipping first time interaction update",e)}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/first-time-interaction.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fee-tokens.cjs",{"../api/simulation-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","./balance.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/balance.cjs","./batch.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.checkGasFeeTokenBeforePublish=s.getGasFeeTokens=void 0;const a=e("@metamask/rpc-errors"),n=e("@metamask/utils"),r=e("./balance.cjs"),o=e("./batch.cjs"),i=e("./eip7702.cjs"),c=e("./feature-flags.cjs"),l=e("../api/simulation-api.cjs"),d=e("../logger.cjs"),m=(0,n.createModuleLogger)(d.projectLogger,"gas-fee-tokens");s.getGasFeeTokens=async function({chainId:e,isEIP7702GasFeeTokensEnabled:t,messenger:s,publicKeyEIP7702:n,transactionMeta:r,getSimulationConfig:d}){const{delegationAddress:u,txParams:h}=r,{authorizationList:f}=h,p=h.data,g=h.from,k=h.to,b=h.value;m("Request",{chainId:e,txParams:h});const w=await t(r)&&(0,i.doesChainSupportEIP7702)(e,s);let _=f?.map(e=>({address:e.address,from:g}));!w||u||_||(_=function({chainId:e,from:t,messenger:s,publicKeyEIP7702:n}){if(!n)throw a.rpcErrors.internal(i.ERROR_MESSGE_PUBLIC_KEY);const r=(0,c.getEIP7702UpgradeContractAddress)(e,s,n);if(!r)throw a.rpcErrors.internal(o.ERROR_MESSAGE_NO_UPGRADE_CONTRACT);return[{address:r,from:t}]}({chainId:e,from:g,messenger:s,publicKeyEIP7702:n}));try{const t=await(0,l.simulateTransactions)(e,{getSimulationConfig:d,transactions:[{authorizationList:_,data:p,from:g,to:k,value:b}],suggestFees:{withTransfer:!0,withFeeTransfer:!0,with7702:w}});m("Response",t);const s=function(e){const t=e.transactions?.[0]?.fees?.[0],s=e.sponsorship?.isSponsored??!1;return{gasFeeTokens:(t?.tokenFees??[]).map(e=>({amount:e.balanceNeededToken,balance:e.currentBalanceToken,decimals:e.token.decimals,fee:e.serviceFee,gas:t.gas,gasTransfer:e.transferEstimate,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas,rateWei:e.rateWei,recipient:e.feeRecipient,symbol:e.token.symbol,tokenAddress:e.token.address})),isGasFeeSponsored:s}}(t);return m("Gas fee tokens",s),s}catch(e){return m("Failed to gas fee tokens",e),{gasFeeTokens:[],isGasFeeSponsored:!1}}},s.checkGasFeeTokenBeforePublish=async function({ethQuery:e,fetchGasFeeTokens:t,transaction:s,updateTransaction:a}){const{isGasFeeTokenIgnoredIfBalance:n,selectedGasFeeToken:o}=s;if(!o||!n)return;if(m("Checking gas fee token before publish",{selectedGasFeeToken:o}),await(0,r.isNativeBalanceSufficientForGas)(s,e))return m("Ignoring gas fee token before publish due to sufficient native balance"),void a(s.id,e=>{e.isExternalSign=!1,e.selectedGasFeeToken=undefined});const i=await t({...s,isExternalSign:!0});if(a(s.id,e=>{e.gasFeeTokens=i,e.isExternalSign=!0,e.txParams.nonce=undefined}),m("Updated gas fee tokens before publish",i),!i?.some(e=>e.tokenAddress.toLowerCase()===o.toLowerCase()))throw new Error("Gas fee token not found and insufficient native balance");m("Publishing with selected gas fee token",{selectedGasFeeToken:o})}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fee-tokens.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs","./swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/swaps.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.gweiDecimalToWeiDecimal=s.gweiDecimalToWeiHex=s.updateGasFees=void 0;const a=e("@metamask/controller-utils"),n=e("@metamask/utils"),r=e("./gas-flow.cjs"),o=e("./swaps.cjs"),i=e("../logger.cjs"),c=e("../types.cjs"),l=(0,n.createModuleLogger)(i.projectLogger,"gas-fees");function d(e){return(0,a.toHex)((0,a.gweiDecToWEIBN)(e))}s.updateGasFees=async function(e){const{txMeta:t}=e,s={...t.txParams},i=o.SWAP_TRANSACTION_TYPES.includes(t.type)?undefined:e.getSavedGasFees(t.chainId),m=await async function(e){const{eip1559:t,ethQuery:s,gasFeeFlows:o,getGasFeeEstimates:i,messenger:d,txMeta:m}=e,{networkClientId:u}=m;if(!t&&m.txParams.gasPrice||t&&m.txParams.maxFeePerGas&&m.txParams.maxPriorityFeePerGas)return{};const h=(0,r.getGasFeeFlow)(m,o,d);try{const e=await i({networkClientId:u}),t=await h.getGasFees({ethQuery:s,gasFeeControllerData:e,messenger:d,transactionMeta:m}),a=t.estimates?.type;switch(a){case c.GasFeeEstimateType.FeeMarket:return t.estimates.medium;case c.GasFeeEstimateType.Legacy:return{gasPrice:t.estimates.medium};case c.GasFeeEstimateType.GasPrice:return{gasPrice:t.estimates.gasPrice};default:throw new Error(`Unsupported gas fee estimate type returned from flow: ${a}`)}}catch(e){l("Failed to get suggested gas fees",e)}const f=await(0,a.query)(s,"gasPrice");return{gasPrice:f?(0,n.add0x)(f.toString(16)):undefined}}(e);l("Suggested gas fees",m);const u={...e,initialParams:s,savedGasFees:i,suggestedGasFees:m};t.txParams.maxFeePerGas=function(e){const{savedGasFees:t,eip1559:s,initialParams:a,suggestedGasFees:n}=e;if(!s)return undefined;if(t){const e=d(t.maxBaseFee);return l("Using maxFeePerGas from savedGasFees",e),e}if(a.maxFeePerGas)return l("Using maxFeePerGas from request",a.maxFeePerGas),a.maxFeePerGas;if(a.gasPrice&&!a.maxPriorityFeePerGas)return l("Setting maxFeePerGas to gasPrice from request",a.gasPrice),a.gasPrice;if(n.maxFeePerGas)return l("Using suggested maxFeePerGas",n.maxFeePerGas),n.maxFeePerGas;if(n.gasPrice)return l("Setting maxFeePerGas to suggested gasPrice",n.gasPrice),n.gasPrice;return l("maxFeePerGas not set"),undefined}(u),t.txParams.maxPriorityFeePerGas=function(e){const{eip1559:t,initialParams:s,savedGasFees:a,suggestedGasFees:n,txMeta:r}=e;if(!t)return undefined;if(a){const e=d(a.priorityFee);return l("Using maxPriorityFeePerGas from savedGasFees.priorityFee",e),e}if(s.maxPriorityFeePerGas)return l("Using maxPriorityFeePerGas from request",s.maxPriorityFeePerGas),s.maxPriorityFeePerGas;if(s.gasPrice&&!s.maxFeePerGas)return l("Setting maxPriorityFeePerGas to gasPrice from request",s.gasPrice),s.gasPrice;if(n.maxPriorityFeePerGas)return l("Using suggested maxPriorityFeePerGas",n.maxPriorityFeePerGas),n.maxPriorityFeePerGas;if(r.txParams.maxFeePerGas)return l("Setting maxPriorityFeePerGas to maxFeePerGas",r.txParams.maxFeePerGas),r.txParams.maxFeePerGas;return l("maxPriorityFeePerGas not set"),undefined}(u),t.txParams.gasPrice=function(e){const{eip1559:t,initialParams:s,suggestedGasFees:a}=e;if(t)return undefined;if(s.gasPrice)return l("Using gasPrice from request",s.gasPrice),s.gasPrice;if(a.maxFeePerGas)return l("Using suggested maxFeePerGas",a.maxFeePerGas),a.maxFeePerGas;if(a.gasPrice)return l("Using suggested gasPrice",a.gasPrice),a.gasPrice;return l("gasPrice not set"),undefined}(u),t.userFeeLevel=function(e){const{initialParams:t,savedGasFees:s,suggestedGasFees:n,txMeta:r}=e;if(s)return c.UserFeeLevel.CUSTOM;if(!t.maxFeePerGas&&!t.maxPriorityFeePerGas&&t.gasPrice)return r.origin===a.ORIGIN_METAMASK?c.UserFeeLevel.CUSTOM:c.UserFeeLevel.DAPP_SUGGESTED;if(!t.maxFeePerGas&&!t.maxPriorityFeePerGas&&n.maxFeePerGas&&n.maxPriorityFeePerGas)return c.UserFeeLevel.MEDIUM;if(!t.maxFeePerGas&&!t.maxPriorityFeePerGas&&n.gasPrice)return c.UserFeeLevel.MEDIUM;if(r.origin===a.ORIGIN_METAMASK)return c.UserFeeLevel.MEDIUM;return c.UserFeeLevel.DAPP_SUGGESTED}(u),l("Updated gas fee properties",{maxFeePerGas:t.txParams.maxFeePerGas,maxPriorityFeePerGas:t.txParams.maxPriorityFeePerGas,gasPrice:t.txParams.gasPrice}),(t.txParams.maxFeePerGas||t.txParams.maxPriorityFeePerGas)&&delete t.txParams.gasPrice,t.txParams.gasPrice&&(delete t.txParams.maxFeePerGas,delete t.txParams.maxPriorityFeePerGas),function(e){e.defaultGasEstimates??(e.defaultGasEstimates={}),e.defaultGasEstimates.maxFeePerGas=e.txParams.maxFeePerGas,e.defaultGasEstimates.maxPriorityFeePerGas=e.txParams.maxPriorityFeePerGas,e.defaultGasEstimates.gasPrice=e.txParams.gasPrice,e.defaultGasEstimates.estimateType=e.userFeeLevel}(t)},s.gweiDecimalToWeiHex=d,s.gweiDecimalToWeiDecimal=function(e){return(1e9*Number(e)).toString().split(".")[0]}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.mergeGasFeeEstimates=s.getGasFeeFlow=void 0;const a=e("@metamask/controller-utils"),n=e("../types.cjs");function r(e,t){return(0,a.weiHexToGweiDec)(e[t])}s.getGasFeeFlow=function(e,t,s){return t.find(t=>t.matchesTransaction({transactionMeta:e,messenger:s}))},s.mergeGasFeeEstimates=function({gasFeeControllerEstimates:e,transactionGasFeeEstimates:t}){const s=t.type;return s===n.GasFeeEstimateType.FeeMarket?Object.values(n.GasFeeEstimateLevel).reduce((s,n)=>{return{...s,[n]:(r=e?.[n],o=t[n],{...r,suggestedMaxFeePerGas:(0,a.weiHexToGweiDec)(o.maxFeePerGas),suggestedMaxPriorityFeePerGas:(0,a.weiHexToGweiDec)(o.maxPriorityFeePerGas)})};var r,o},{...e}):s===n.GasFeeEstimateType.Legacy?Object.values(n.GasFeeEstimateLevel).reduce((e,s)=>({...e,[s]:r(t,s)}),{}):s===n.GasFeeEstimateType.GasPrice?{gasPrice:(o=t,(0,a.weiHexToGweiDec)(o.gasPrice))}:e;var o}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas.cjs",{"../api/simulation-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.simulateGasBatch=s.addGasBuffer=s.estimateGasBatch=s.estimateGas=s.updateGas=s.DUMMY_AUTHORIZATION_SIGNATURE=s.INTRINSIC_GAS=s.MAX_GAS_BLOCK_PERCENT=s.DEFAULT_GAS_MULTIPLIER=s.FIXED_GAS=s.log=void 0;const a=e("@metamask/controller-utils"),n=e("@metamask/utils"),r=e("bignumber.js"),o=e("./eip7702.cjs"),i=e("./feature-flags.cjs"),c=e("../api/simulation-api.cjs"),l=e("../logger.cjs"),d=e("../types.cjs");async function m({chainId:e,ethQuery:t,ignoreDelegationSignatures:r,isSimulationEnabled:o,getSimulationConfig:c,messenger:l,txParams:m}){const u={...m},{authorizationList:h,data:g,from:k,value:b,to:w}=u;if(r&&!o)throw new Error("Gas estimation with ignored delegation signatures is not supported as simulation disabled");const{gasLimit:_,number:T}=await async function(e){return await(0,a.query)(e,"getBlockByNumber",["latest",!1])}(t),E=(0,a.hexToBN)(_),{percentage:I,fixed:S}=(0,i.getGasEstimateFallback)(e,l),x=S?(0,a.toHex)(S):(0,a.BNToHex)((0,a.fractionBN)(E,I,100));(0,s.log)("Estimation fallback values",x),u.data=g?(0,n.add0x)(g):g,u.value=b??"0x0",u.authorizationList=function(e,t){return e?.map(e=>({...e,chainId:e.chainId??t,nonce:e.nonce??"0x1",r:e.r??s.DUMMY_AUTHORIZATION_SIGNATURE,s:e.s??s.DUMMY_AUTHORIZATION_SIGNATURE,yParity:e.yParity??"0x1"}))}(u.authorizationList,e),delete u.gasPrice,delete u.maxFeePerGas,delete u.maxPriorityFeePerGas;let y,A=x;const v=m.type===d.TransactionEnvelopeType.setCode&&Boolean(h?.length)&&Boolean(g)&&"0x"!==g&&k?.toLowerCase()===w?.toLowerCase();try{A=o&&v?await async function(e,t,n,r){const o=await(0,a.query)(t,"estimateGas",[{...e,data:"0x"}]);(0,s.log)("Upgrade only gas",o);const i=e.authorizationList?.[0].address;let c;try{c=await f({chainId:n,delegationAddress:i,getSimulationConfig:r,transaction:e})}catch(e){(0,s.log)("Error while simulating data portion of upgrade",e)}if(c===undefined){try{c=await p(t,{...e,authorizationList:undefined,type:undefined},i)}catch(e){throw(0,s.log)("Error while estimating data portion of upgrade",e),e}(0,s.log)("Success estimating data portion of upgrade",c)}(0,s.log)("Execute gas",c);const l=(0,a.BNToHex)((0,a.hexToBN)(o).add((0,a.hexToBN)(c)).subn(s.INTRINSIC_GAS));return(0,s.log)("Total type 4 gas",l),l}(u,t,e,c):r&&o?await f({chainId:e,getSimulationConfig:c,transaction:u}):await p(t,u)}catch(e){y={reason:e.message,errorKey:e.errorKey,debug:{blockNumber:T,blockGasLimit:_}},(0,s.log)("Estimation failed",{...y,fallback:x})}return{blockGasLimit:_,estimatedGas:A,isUpgradeWithDataToSelf:v,simulationFails:y}}function u(e,t,r){const o=(0,a.hexToBN)(e),i=(0,a.fractionBN)((0,a.hexToBN)(t),s.MAX_GAS_BLOCK_PERCENT,100),c=(0,a.fractionBN)(o,100*r,100);if(o.gt(i)){const t=(0,n.add0x)(e);return(0,s.log)("Using estimated value",t),t}if(c.lt(i)){const e=(0,n.add0x)((0,a.BNToHex)(c));return(0,s.log)("Using padded estimate",e,r),e}const l=(0,n.add0x)((0,a.BNToHex)(i));return(0,s.log)("Using 90% of block gas limit",l),l}async function h({chainId:e,from:t,getSimulationConfig:n,transactions:r}){try{const s=await(0,c.simulateTransactions)(e,{getSimulationConfig:n,transactions:r.map(e=>({...e.params,from:t}))});if(s?.transactions?.length!==r.length)throw new Error("Simulation response does not match transaction count");return s.transactions.reduce((e,t)=>{const s=t?.gasLimit;if(!s)throw new Error("No simulated gas returned for one of the transactions");return e.gasLimits.push(s),e.totalGasLimit=(0,a.BNToHex)((0,a.hexToBN)(e.totalGasLimit).add((0,a.hexToBN)(s))),e},{totalGasLimit:"0x0",gasLimits:[]})}catch(e){throw(0,s.log)("Error while simulating gas batch",e),new Error("Cannot estimate transaction batch total gas as simulation failed")}}async function f({chainId:e,delegationAddress:t,getSimulationConfig:s,transaction:a}){const r=await(0,c.simulateTransactions)(e,{getSimulationConfig:s,transactions:[{to:a.to,from:a.from,data:a.data,value:a.value}],overrides:{[a.from]:{code:t&&o.DELEGATION_PREFIX+(0,n.remove0x)(t)}}}),i=r?.transactions?.[0].gasLimit;if(!i)throw new Error("No simulated gas returned");return i}function p(e,t,s){const{from:r}=t,i=[t];return s&&(i.push("latest"),i.push({[r]:{code:o.DELEGATION_PREFIX+(0,n.remove0x)(s)}})),(0,a.query)(e,"estimateGas",i)}s.log=(0,n.createModuleLogger)(l.projectLogger,"gas"),s.FIXED_GAS="0x5208",s.DEFAULT_GAS_MULTIPLIER=1.5,s.MAX_GAS_BLOCK_PERCENT=90,s.INTRINSIC_GAS=21e3,s.DUMMY_AUTHORIZATION_SIGNATURE="0x1111111111111111111111111111111111111111111111111111111111111111",s.updateGas=async function(e){const{txMeta:t}=e,n={...t.txParams},[r,o,c]=await async function(e){const{chainId:t,isCustomNetwork:n,isSimulationEnabled:r,getSimulationConfig:o,messenger:c,txMeta:l}=e,{disableGasBuffer:h}=l;if(l.txParams.gas)return(0,s.log)("Using value from request",l.txParams.gas),[l.txParams.gas,undefined,l.txParams.gas];if(await async function({ethQuery:e,txMeta:t,isCustomNetwork:s}){const{txParams:{to:n,data:r,type:o}}=t;if(s||!n||r||o===d.TransactionEnvelopeType.setCode)return!1;const i=await async function(e,t){return await(0,a.query)(e,"getCode",[t])}(e,n);return!i||"0x"===i}(e))return(0,s.log)("Using fixed value",s.FIXED_GAS),[s.FIXED_GAS,undefined,s.FIXED_GAS];const{blockGasLimit:f,estimatedGas:p,isUpgradeWithDataToSelf:g,simulationFails:k}=await m({chainId:t,ethQuery:e.ethQuery,isSimulationEnabled:r,getSimulationConfig:o,messenger:c,txParams:l.txParams});(0,s.log)("Original estimated gas",p),k&&(0,s.log)("Using original fallback estimate as simulation failed");h&&(0,s.log)("Gas buffer disabled");if(k||h)return[p,k,p];const b=(0,i.getGasEstimateBuffer)({chainId:t,isCustomRPC:n,isUpgradeWithDataToSelf:g,messenger:c});(0,s.log)("Buffer",b);const w=u(p,f,b);return(0,s.log)("Buffered gas",w),[w,k,p]}(e);t.txParams.gas=r,t.simulationFails=o,t.gasLimitNoBuffer=c,n.gas||(t.originalGasEstimate=t.txParams.gas),t.defaultGasEstimates??(t.defaultGasEstimates={}),t.defaultGasEstimates.gas=t.txParams.gas},s.estimateGas=m,s.estimateGasBatch=async function({chainId:e,ethQuery:t,from:a,getSimulationConfig:n,isAtomicBatchSupported:i,messenger:c,transactions:l}){const u=(await i({address:a,chainIds:[e]})).find(t=>t.chainId===e),f=Boolean(u&&!u.isSupported);if(f&&!u?.upgradeContractAddress)throw new Error("Upgrade contract address not found");if(u){const i=f?[{address:u.upgradeContractAddress}]:undefined,h=f?d.TransactionEnvelopeType.setCode:undefined,p={...(0,o.generateEIP7702BatchTransaction)(a,l),authorizationList:i,from:a,type:h},{estimatedGas:g}=await m({chainId:e,ethQuery:t,isSimulationEnabled:!0,getSimulationConfig:n,messenger:c,txParams:p}),k=new r.BigNumber(g).toNumber();return(0,s.log)("Estimated EIP-7702 gas limit",k),{totalGasLimit:k,gasLimits:[k]}}if(l.every(e=>e.gas!==undefined)){const e=l.map(e=>new r.BigNumber(e.gas).toNumber()),t=e.reduce((e,t)=>e+t,0);return(0,s.log)("Using batch parameter gas limits",{gasLimits:e,total:t}),{totalGasLimit:t,gasLimits:e}}const{gasLimits:p}=await h({chainId:e,from:a,getSimulationConfig:n,transactions:l.map(e=>({params:e}))}),g=l.map((e,t)=>e.gas?new r.BigNumber(e.gas).toNumber():new r.BigNumber(p[t]).toNumber()),k=g.reduce((e,t)=>e+t,0);return(0,s.log)("Simulated batch gas limits",{totalGasLimit:k,gasLimits:g}),{totalGasLimit:k,gasLimits:g}},s.addGasBuffer=u,s.simulateGasBatch=h}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/gas.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/layer1-gas-fee-flow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getTransactionLayer1GasFee=s.updateTransactionLayer1GasFee=void 0;const a=e("@metamask/utils"),n=e("../logger.cjs"),r=(0,a.createModuleLogger)(n.projectLogger,"layer-1-gas-fee-flow");async function o({layer1GasFeeFlows:e,messenger:t,provider:s,transactionMeta:a}){const n=await async function(e,t,s){for(const a of t)if(await a.matchesTransaction({transactionMeta:e,messenger:s}))return a;return undefined}(a,e,t);if(!n)return undefined;r("Found layer 1 gas fee flow",n.constructor.name,a.id);try{const{layer1Fee:e}=await n.getLayer1Fee({provider:s,transactionMeta:a});return e}catch(e){return r("Failed to get layer 1 gas fee",a.id,e),undefined}}s.updateTransactionLayer1GasFee=async function(e){const t=await o(e);if(!t)return;const{transactionMeta:s}=e;s.layer1GasFee=t,r("Updated layer 1 gas fee",t,s.id)},s.getTransactionLayer1GasFee=o}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/layer1-gas-fee-flow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/nonce.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getAndFormatTransactionsForNonceTracker=s.getNextNonce=void 0;const a=e("@metamask/controller-utils"),n=e("../logger.cjs"),r=(0,n.createModuleLogger)(n.projectLogger,"nonce");s.getNextNonce=async function(e,t){const{customNonceValue:s,isExternalSign:n,txParams:{from:o,nonce:i}}=e;if(n)return r("Skipping nonce as signed externally"),[undefined,undefined];const c=s?(0,a.toHex)(s):undefined;if(c)return r("Using custom nonce",c),[c,undefined];if(i)return r("Using existing nonce",i),[i,undefined];const l=await t(o),d=(0,a.toHex)(l.nextNonce),m=l.releaseLock.bind(l);return r("Using nonce from nonce tracker",d,l.nonceDetails),[d,m]},s.getAndFormatTransactionsForNonceTracker=function(e,t,s,a){return a.filter(({chainId:a,isTransfer:n,isUserOperation:r,status:o,txParams:{from:i,nonce:c}})=>!n&&!r&&a===e&&s.includes(o)&&i.toLowerCase()===t.toLowerCase()&&c).flatMap(({status:e,txParams:{authorizationList:t,from:s,gas:a,value:n,nonce:r}})=>[r,...(t??[]).map(e=>e.nonce).filter(e=>e!==undefined)].map(t=>({status:e,history:[{}],txParams:{from:s??"",gas:a??"",value:n??"",nonce:t??""}})))}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/nonce.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs",{"@ethereumjs/common":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethereumjs/common/dist/cjs/index.js","@ethereumjs/tx":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethereumjs/tx/dist/cjs/index.js","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.serializeTransaction=s.prepareTransaction=s.HARDFORK=void 0;const a=e("@ethereumjs/common"),n=e("@ethereumjs/tx"),r=e("@metamask/utils"),o=e("lodash");function i(e){const t={chainId:parseInt(e,16),defaultHardfork:s.HARDFORK};return a.Common.custom(t,{eips:[7702]})}function c(e){return e?"0x0"===e?"0x":e.replace?.(/^0x(00)+/u,"0x")??e:e}s.HARDFORK=a.Hardfork.Prague,s.prepareTransaction=function(e,t){const s=function(e){const t=(0,o.cloneDeep)(e);return function(e){if(!e)return;for(const t of e)t.nonce=c(t.nonce),t.r=c(t.r),t.s=c(t.s),t.yParity=c(t.yParity)}(t.authorizationList),t}(t);return n.TransactionFactory.fromTxData(s,{freeze:!1,common:i(e)})},s.serializeTransaction=function(e){return(0,r.bytesToHex)(e.serialize())}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/retry.cjs",{"@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getTransactionParamsWithIncreasedGasFee=void 0;const a=e("@metamask/controller-utils"),n=e("@metamask/utils");function r(e,t){const s=(0,a.convertHexToDecimal)(e),r=parseInt(""+s*t,10);return(0,n.add0x)(r.toString(16))}s.getTransactionParamsWithIncreasedGasFee=function(e,t,s){const a=function(e,t,s){if(s&&"gasPrice"in s)return s.gasPrice;const a=e.gasPrice;if(!a||"0x0"===a)return undefined;return r(a,t)}(e,t,s),n=function(e,t,s){if(s&&"maxFeePerGas"in s&&"maxPriorityFeePerGas"in s)return s;const a=e.maxFeePerGas,n=e.maxPriorityFeePerGas;if(!a||!n||"0x0"===a||"0x0"===n)return undefined;const o=r(a,t),i=r(n,t);return{maxFeePerGas:o,maxPriorityFeePerGas:i}}(e,t,s);if(n){const t={...e,...n};return delete t.gasPrice,t}if(a){const t={...e,gasPrice:a};return delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,t}throw new Error("Cannot increase gas fee as no current values and no new values were provided")}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/retry.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/signature.cjs",{"@ethersproject/wallet":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/wallet/lib/index.js","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.isValidSignature=void 0;const a=e("@ethersproject/wallet"),n=e("@metamask/utils");s.isValidSignature=function(e,t,s){try{const r=(0,n.add0x)(e.map(n.remove0x).join("")),o=(0,n.hexToBytes)(r);return(0,a.verifyMessage)(o,t).toLowerCase()===s.toLowerCase()}catch{return!1}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/signature.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/swaps.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/constants.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs",lodash:"/home/runner/work/metamask-extension/metamask-extension/node_modules/lodash/lodash.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.updatePostTransactionBalance=s.updateSwapsTransaction=s.SWAP_TRANSACTION_TYPES=s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP=s.DEFAULT_TOKEN_ADDRESS=s.UPDATE_POST_TX_BALANCE_ATTEMPTS=s.UPDATE_POST_TX_BALANCE_TIMEOUT=void 0;const a=e("@metamask/controller-utils"),n=e("lodash"),r=e("./utils.cjs"),o=e("../constants.cjs"),i=e("../logger.cjs"),c=e("../types.cjs"),l=(0,i.createModuleLogger)(i.projectLogger,"swaps");s.UPDATE_POST_TX_BALANCE_TIMEOUT=5e3,s.UPDATE_POST_TX_BALANCE_ATTEMPTS=6;const d="0x539";s.DEFAULT_TOKEN_ADDRESS="0x0000000000000000000000000000000000000000";const m={name:"Ether",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},u={name:"Binance Coin",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},h={name:"Matic",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},f={name:"Avalanche",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},p={name:"Test Ether",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},g={name:"Ether",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},k={...m},b={...m},w={...m},_={name:"Sei",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},T={name:"Mon",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},E={name:"Hyperliquid",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18};function I(e,t){return!(!e||!t)&&e===s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP[t]?.address}function S(e){return new Promise(t=>setTimeout(t,e))}s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP={[o.CHAIN_IDS.MAINNET]:m,[d]:p,[o.CHAIN_IDS.BSC]:u,[o.CHAIN_IDS.POLYGON]:h,[o.CHAIN_IDS.GOERLI]:g,[o.CHAIN_IDS.AVALANCHE]:f,[o.CHAIN_IDS.OPTIMISM]:b,[o.CHAIN_IDS.ARBITRUM]:k,[o.CHAIN_IDS.ZKSYNC_ERA]:w,[o.CHAIN_IDS.SEI]:_,[o.CHAIN_IDS.MONAD]:T,[o.CHAIN_IDS.HYPEREVM]:E},s.SWAP_TRANSACTION_TYPES=[c.TransactionType.swap,c.TransactionType.swapAndSend,c.TransactionType.swapApproval],s.updateSwapsTransaction=function(e,t,a,{isSwapsDisabled:o,cancelTransaction:i,messenger:l}){if(o||!s.SWAP_TRANSACTION_TYPES.includes(t))return e;if(t===c.TransactionType.swap&&!1===a?.hasApproveTx&&e.simulationFails)throw i(e.id),new Error("Simulation failed");const d=a?.meta;if(!d)return e;let m=e;return t===c.TransactionType.swapApproval&&(m=function(e,{type:t,sourceTokenSymbol:s}){(0,r.validateIfTransactionUnapproved)(e,"updateSwapApprovalTransaction");let a={type:t,sourceTokenSymbol:s};return a=(0,n.pickBy)({type:t,sourceTokenSymbol:s}),(0,n.merge)({},e,a)}(e,d),l.publish("TransactionController:transactionNewSwapApproval",{transactionMeta:m})),t===c.TransactionType.swapAndSend&&(m=function(e,{approvalTxId:t,destinationTokenAddress:s,destinationTokenAmount:a,destinationTokenDecimals:o,destinationTokenSymbol:i,estimatedBaseFee:c,sourceTokenAddress:l,sourceTokenAmount:d,sourceTokenDecimals:m,sourceTokenSymbol:u,swapAndSendRecipient:h,swapMetaData:f,swapTokenValue:p,type:g}){(0,r.validateIfTransactionUnapproved)(e,"updateSwapTransaction");let k={approvalTxId:t,destinationTokenAddress:s,destinationTokenAmount:a,destinationTokenDecimals:o,destinationTokenSymbol:i,estimatedBaseFee:c,sourceTokenAddress:l,sourceTokenAmount:d,sourceTokenDecimals:m,sourceTokenSymbol:u,swapAndSendRecipient:h,swapMetaData:f,swapTokenValue:p,type:g};return k=(0,n.pickBy)(k),(0,n.merge)({},e,k)}(e,d),l.publish("TransactionController:transactionNewSwapAndSend",{transactionMeta:m})),t===c.TransactionType.swap&&(m=function(e,{sourceTokenSymbol:t,destinationTokenSymbol:s,type:a,destinationTokenDecimals:o,destinationTokenAddress:i,swapMetaData:c,swapTokenValue:l,estimatedBaseFee:d,approvalTxId:m}){(0,r.validateIfTransactionUnapproved)(e,"updateSwapTransaction");let u={sourceTokenSymbol:t,destinationTokenSymbol:s,type:a,destinationTokenDecimals:o,destinationTokenAddress:i,swapMetaData:c,swapTokenValue:l,estimatedBaseFee:d,approvalTxId:m};return u=(0,n.pickBy)(u),(0,n.merge)({},e,u)}(e,d),l.publish("TransactionController:transactionNewSwap",{transactionMeta:m})),m},s.updatePostTransactionBalance=async function(e,{ethQuery:t,getTransaction:n,updateTransaction:r}){l("Updating post transaction balance",e.id);const o=e.id;let i,c;for(let r=0;r<s.UPDATE_POST_TX_BALANCE_ATTEMPTS;r++){l("Querying balance",{attempt:r});const d=await(0,a.query)(t,"getBalance",[e.txParams.from]);i={...n(o)??{}},c=i.approvalTxId?n(i.approvalTxId):undefined,i.postTxBalance=d.toString(16);const m=I(e.destinationTokenAddress,e.chainId);if(!m||e.preTxBalance!==i.postTxBalance){l("Finishing post balance update",{isDefaultTokenAddress:m,preTxBalance:e.preTxBalance,postTxBalance:i.postTxBalance});break}l("Waiting for balance to update",{delay:s.UPDATE_POST_TX_BALANCE_TIMEOUT}),await S(s.UPDATE_POST_TX_BALANCE_TIMEOUT)}return r(i,"TransactionController#updatePostTransactionBalance - Add post transaction balance"),l("Completed post balance update",i?.postTxBalance),{updatedTransactionMeta:i,approvalTransactionMeta:c}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/swaps.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","@ethersproject/abi":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/abi/lib/index.js","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/metamask-eth-abis":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/metamask-eth-abis/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.decodeTransactionData=s.determineTransactionType=s.ESTIMATE_GAS_ERROR=void 0;const a=e("@ethersproject/abi"),n=e("@metamask/controller-utils"),r=e("@metamask/metamask-eth-abis"),o=e("./eip7702.cjs"),i=e("../types.cjs");s.ESTIMATE_GAS_ERROR="eth_estimateGas rpc method error";const c=new a.Interface(r.abiERC20),l=new a.Interface(r.abiERC721),d=new a.Interface(r.abiERC1155),m=new a.Interface(r.abiFiatTokenV2);function u(e,t){if(!e||e.length<10)return undefined;const s=e.substring(0,10).toLowerCase();for(const a of[c,l,d,m])try{return t?.getMethodName?a.getFunction(s)?.name:a.parseTransaction({data:e})}catch{}return undefined}s.determineTransactionType=async function(e,t){const{data:s,to:a}=e;if(s&&!a)return{type:i.TransactionType.deployContract,getCodeResponse:undefined};let r,c=Boolean(s?.length);if(t){const e=await async function(e,t){let s;try{s=await(0,n.query)(e,"getCode",[t])}catch(e){s=null}const a=!!s&&("0x"!==s&&"0x0"!==s&&!s.startsWith(o.DELEGATION_PREFIX));return{contractCode:s,isContractAddress:a}}(t,a);r=e.contractCode,c=e.isContractAddress}if(!c)return{type:i.TransactionType.simpleSend,getCodeResponse:r};const l=0!==Number(e.value??"0"),d={type:i.TransactionType.contractInteraction,getCodeResponse:r};if(!s||l)return d;const m=function(e){return u(e,{getMethodName:!0})}(s);if(!m)return d;const h=[i.TransactionType.tokenMethodApprove,i.TransactionType.tokenMethodSetApprovalForAll,i.TransactionType.tokenMethodTransfer,i.TransactionType.tokenMethodTransferFrom,i.TransactionType.tokenMethodSafeTransferFrom,i.TransactionType.tokenMethodIncreaseAllowance].find(e=>e.toLowerCase()===m.toLowerCase());return h?{type:h,getCodeResponse:r}:d},s.decodeTransactionData=u}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bn.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/bn.js/lib/bn.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.caip2ToHex=s.setEnvelopeType=s.getPercentageChange=s.toBN=s.bnFromHex=s.padHexToEvenLength=s.normalizeGasFeeValues=s.normalizeTxError=s.validateIfTransactionUnapprovedOrSubmitted=s.validateIfTransactionUnapproved=s.validateGasValues=s.isEIP1559Transaction=s.normalizeTransactionParams=s.ESTIMATE_GAS_ERROR=void 0;const n=e("@metamask/controller-utils"),r=e("@metamask/utils"),o=a(e("bn.js")),i=e("../types.cjs");s.ESTIMATE_GAS_ERROR="eth_estimateGas rpc method error";const c={accessList:e=>e,authorizationList:e=>e,data:e=>(0,r.add0x)(d(e)),from:e=>(0,r.add0x)(e).toLowerCase(),gas:e=>(0,r.add0x)(e),gasLimit:e=>(0,r.add0x)(e),gasPrice:e=>(0,r.add0x)(e),nonce:e=>(0,r.add0x)(e),to:e=>(0,r.add0x)(e).toLowerCase(),value:e=>(0,r.add0x)(e),maxFeePerGas:e=>(0,r.add0x)(e),maxPriorityFeePerGas:e=>(0,r.add0x)(e),estimatedBaseFee:e=>(0,r.add0x)(e),type:e=>(0,r.add0x)(e)};s.normalizeTransactionParams=function(e){const t={from:""};for(const s of(0,r.getKnownPropertyNames)(c))e[s]&&(t[s]=c[s](e[s]));return t.value??(t.value="0x0"),t.gasLimit&&!t.gas&&(t.gas=t.gasLimit),t},s.isEIP1559Transaction=function(e){const t=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);return t(e,"maxFeePerGas")&&t(e,"maxPriorityFeePerGas")};function l(e){try{return JSON.parse(JSON.stringify(e)),!0}catch{return!1}}function d(e){const t=e.toLowerCase().startsWith("0x")?e.slice(0,2):"",s=t?e.slice(2):e;return t+(s.length%2==0?s:`0${s}`)}function m(e){const t=e,s=t.startsWith("0x")||t.startsWith("0X")?t.slice(2):t;return 0===s.length?new o.default(0):new o.default(s,16)}s.validateGasValues=e=>{Object.keys(e).forEach(t=>{const s=e[t];if("string"!=typeof s||!(0,r.isStrictHexString)(s))throw new TypeError(`expected hex string for ${t} but received: ${s}`)})},s.validateIfTransactionUnapproved=function(e,t){if(e?.status!==i.TransactionStatus.unapproved)throw new Error(`TransactionsController: Can only call ${t} on an unapproved transaction.\n      Current tx status: ${e?.status}`)},s.validateIfTransactionUnapprovedOrSubmitted=function(e,t){const s=[i.TransactionStatus.unapproved,i.TransactionStatus.submitted];if(!e||!s.includes(e.status))throw new Error(`TransactionsController: Can only call ${t} on an unapproved or submitted transaction.\n      Current tx status: ${e?.status}`)},s.normalizeTxError=function(e){return{name:e.name,message:e.message,stack:e.stack,code:e.code,rpc:l(e.value)?e.value:undefined}},s.normalizeGasFeeValues=function(e){const t=e=>"string"==typeof e?(0,r.add0x)(e):e;return"gasPrice"in e?{gasPrice:t(e.gasPrice)}:{maxFeePerGas:t(e.maxFeePerGas),maxPriorityFeePerGas:t(e.maxPriorityFeePerGas)}},s.padHexToEvenLength=d,s.bnFromHex=m,s.toBN=function(e){if(e instanceof o.default)return e;if("function"==typeof o.default.isBN&&o.default.isBN(e))return e;if(null!==e&&"object"==typeof e&&"function"==typeof e.toHexString)return m(e.toHexString());if(null!==e&&"object"==typeof e&&"string"==typeof e._hex)return m(e._hex);if("string"==typeof e)return m(e);if("bigint"==typeof e)return new o.default(e.toString());if("number"==typeof e)return new o.default(e);throw new Error("Unexpected value returned from oracle contract")},s.getPercentageChange=function(e,t){const s=new o.default(10).pow(new o.default(18)),a=e.mul(s),n=t.mul(s),r=n.sub(a);return r.isZero()?0:a.isZero()&&!n.isZero()?100:r.muln(100).div(a).abs().toNumber()},s.setEnvelopeType=function(e,t){e.accessList?e.type=i.TransactionEnvelopeType.accessList:e.authorizationList?e.type=i.TransactionEnvelopeType.setCode:e.type=t?i.TransactionEnvelopeType.feeMarket:i.TransactionEnvelopeType.legacy},s.caip2ToHex=function(e){if(!(0,r.isCaipChainId)(e))return undefined;try{const{reference:t}=(0,r.parseCaipChainId)(e);return(0,n.toHex)(t)}catch{return undefined}}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/validation.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","@ethersproject/abi":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@ethersproject/abi/lib/index.js","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/dist/index.cjs","@metamask/metamask-eth-abis":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/metamask-eth-abis/dist/index.js","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.validateBatchRequest=s.validateParamTo=s.validateTxParams=s.validateTransactionOrigin=s.ErrorCode=void 0;const a=e("@ethersproject/abi"),n=e("@metamask/controller-utils"),r=e("@metamask/metamask-eth-abis"),o=e("@metamask/rpc-errors"),i=e("@metamask/utils"),c=e("./utils.cjs"),l=e("../types.cjs");var d;!function(e){e[e.DuplicateBundleId=5720]="DuplicateBundleId",e[e.BundleTooLarge=5740]="BundleTooLarge",e[e.RejectedUpgrade=5750]="RejectedUpgrade"}(d||(s.ErrorCode=d={}));const m=[l.TransactionEnvelopeType.feeMarket,l.TransactionEnvelopeType.setCode];function u(e,t){const s=e.type;switch(t){case"authorizationList":if(s&&s!==l.TransactionEnvelopeType.setCode)throw o.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${s}" but including authorizationList requires type: "${l.TransactionEnvelopeType.setCode}"`);break;case"maxFeePerGas":case"maxPriorityFeePerGas":if(s&&!m.includes(s))throw o.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${s}" but including maxFeePerGas and maxPriorityFeePerGas requires type: "${m.join(", ")}"`);break;default:if(s&&m.includes(s))throw o.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${s}" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas`)}}function h(e,t,s){if(void 0!==e[s])throw o.rpcErrors.invalidParams(`Invalid transaction params: specified ${t} but also included ${s}, these cannot be mixed`)}function f(e,t){const s=e[t];if("string"!=typeof s||!(0,i.isStrictHexString)(s))throw o.rpcErrors.invalidParams(`Invalid transaction params: ${String(t)} is not a valid hexadecimal string. got: (${String(s)})`)}function p(e){f(e,"address"),function(e,t,s){const a=(0,i.remove0x)(e).length/2;if(a!==t)throw o.rpcErrors.invalidParams(`Invalid transaction params: ${s} must be ${t} bytes. got: ${a} bytes`)}(e.address,20,"address");for(const t of["chainId","nonce","r","s"])e[t]&&f(e,t);const{yParity:t}=e;if(t&&!["0x0","0x1"].includes(t))throw o.rpcErrors.invalidParams(`Invalid transaction params: yParity must be '0x0' or '0x1'. got: ${t}`)}s.validateTransactionOrigin=async function({data:e,from:t,internalAccounts:s,origin:a,permittedAddresses:r,txParams:i,type:c}){if(!a||a===n.ORIGIN_METAMASK)return;const{authorizationList:d,to:m,type:u}=i;if(r&&!r.includes(t))throw o.providerErrors.unauthorized({data:{origin:a}});if(c===l.TransactionType.batch)return;if(d||u===l.TransactionEnvelopeType.setCode)throw o.rpcErrors.invalidParams("External EIP-7702 transactions are not supported");if(Boolean(e&&"0x"!==e)&&s?.some(e=>e.toLowerCase()===m?.toLowerCase()))throw o.rpcErrors.invalidParams("External transactions to internal accounts cannot include data")},s.validateTxParams=function(e,t=!0,s){!function(e){if(e&&!Object.values(l.TransactionEnvelopeType).includes(e))throw o.rpcErrors.invalidParams(`Invalid transaction envelope type: "${e}". Must be one of: ${Object.values(l.TransactionEnvelopeType).join(", ")}`)}(e.type),function(e,t){if((0,c.isEIP1559Transaction)(e)&&!t)throw o.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559")}(e,t),function(e){if(!e||"string"!=typeof e)throw o.rpcErrors.invalidParams(`Invalid "from" address ${e}: not a string.`);if(!(0,n.isValidHexAddress)(e))throw o.rpcErrors.invalidParams('Invalid "from" address.')}(e.from),function(e){if("0x"===e.to||e.to===undefined){if(!e.data)throw o.rpcErrors.invalidParams('Invalid "to" address.');delete e.to}else if(e.to!==undefined&&!(0,n.isValidHexAddress)(e.to))throw o.rpcErrors.invalidParams('Invalid "to" address.')}(e),function(e){if(e!==undefined){if(e.includes("-"))throw o.rpcErrors.invalidParams(`Invalid transaction value "${e}": not a positive number.`);if(e.includes("."))throw o.rpcErrors.invalidParams(`Invalid transaction value "${e}": number must be in wei.`);const t=parseInt(e,10);if(!(Number.isFinite(t)&&!Number.isNaN(t)&&!isNaN(Number(e))&&Number.isSafeInteger(t)))throw o.rpcErrors.invalidParams(`Invalid transaction value ${e}: number must be a valid number.`)}}(e.value),function(e){if(e){const t=new a.Interface(r.abiERC20);try{t.parseTransaction({data:e})}catch(e){if(e.message.match(/BUFFER_OVERRUN/u))throw o.rpcErrors.invalidParams("Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.")}}}(e.data),function(e,t){if(e&&t&&e.toLowerCase?.()!==t.toLowerCase())throw o.rpcErrors.invalidParams(`Invalid transaction params: chainId must match the network client, got: ${e}, expected: ${t}`)}(e.chainId,s),function(e){e.gasPrice&&(u(e,"gasPrice"),h(e,"gasPrice","maxFeePerGas"),h(e,"gasPrice","maxPriorityFeePerGas"),f(e,"gasPrice"));e.maxFeePerGas&&(u(e,"maxFeePerGas"),h(e,"maxFeePerGas","gasPrice"),f(e,"maxFeePerGas"));e.maxPriorityFeePerGas&&(u(e,"maxPriorityFeePerGas"),h(e,"maxPriorityFeePerGas","gasPrice"),f(e,"maxPriorityFeePerGas"));e.gasLimit&&f(e,"gasLimit");e.gas&&f(e,"gas")}(e),function(e){const{authorizationList:t}=e;if(!t)return;if(u(e,"authorizationList"),!Array.isArray(t))throw o.rpcErrors.invalidParams("Invalid transaction params: authorizationList must be an array");for(const e of t)p(e)}(e)},s.validateParamTo=function(e){if(!e||"string"!=typeof e)throw o.rpcErrors.invalidParams('Invalid "to" address')},s.validateBatchRequest=function({internalAccounts:e,request:t,sizeLimit:s}){const{origin:a}=t,r=a&&a!==n.ORIGIN_METAMASK,i=e.map(e=>e.toLowerCase());if(r&&t.transactions.some(e=>{const t=e.params.to?.toLowerCase(),s=e.params.data,a=i.includes(t),n=Boolean(s&&"0x"!==s);return a&&n}))throw o.rpcErrors.invalidParams("External calls to internal accounts cannot include data");if(r&&t.transactions.length>s)throw new o.JsonRpcError(d.BundleTooLarge,`Batch size cannot exceed ${s}. got: ${t.transactions.length}`)}}}},{package:"@metamask/bridge-status-controller>@metamask/transaction-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/transaction-controller/dist/utils/validation.cjs"}]],[],{});