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=O){W(e,t).clearInstance(s)},s._serverApps=void 0,s.deleteApp=J,s.getApp=function(e=O){const t=B.get(e);if(!t&&e===O&&(0,r.getDefaultAppConfig)())return Q();if(!t)throw V.create("no-app",{appName:e});return t},s.getApps=function(){return Array.from(B.values())},s.initializeApp=Q,s.initializeServerApp=function(e,t){if((0,r.isBrowser)()&&!(0,r.isWebWorker)())throw V.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 V.create("finalization-registry-not-supported",{});const i=""+(c=JSON.stringify(n),[...c].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0)),o=R.get(i);var c;if(o)return o.incRefCount(t.releaseOnDeref),o;const l=new a.ComponentContainer(i);for(const e of H.values())l.addComponent(e);const d=new Y(s,t,i,l);return R.set(i,d),d},s.onLog=function(e,t){if(null!==e&&"function"!=typeof e)throw V.create("invalid-log-argument");(0,n.setUserLogHandler)(e,t)},s.registerVersion=X,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"),i=e("idb");
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class o{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const 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",y="@firebase/database-compat",T="@firebase/functions",x="@firebase/functions-compat",_="@firebase/installations",v="@firebase/installations-compat",E="@firebase/messaging",I="@firebase/messaging-compat",P="@firebase/performance",S="@firebase/performance-compat",C="@firebase/remote-config",j="@firebase/remote-config-compat",A="@firebase/storage",F="@firebase/storage-compat",G="@firebase/firestore",M="@firebase/vertexai",D="@firebase/firestore-compat",N="firebase",O=s._DEFAULT_ENTRY_NAME="[DEFAULT]",L={[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",[y]:"fire-rtdb-compat",[T]:"fire-fn",[x]:"fire-fn-compat",[_]:"fire-iid",[v]:"fire-iid-compat",[E]:"fire-fcm",[I]:"fire-fcm-compat",[P]:"fire-perf",[S]:"fire-perf-compat",[C]:"fire-rc",[j]:"fire-rc-compat",[A]:"fire-gcs",[F]:"fire-gcs-compat",[G]:"fire-fst",[D]:"fire-fst-compat",[M]:"fire-vertex","fire-js":"fire-js",[N]:"fire-js-all"},B=s._apps=new Map,R=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 R.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 K={"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."},V=new r.ErrorFactory("app","Firebase",K);
/**
 * @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 z{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 V.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 Y extends z{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,X(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(){J(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw V.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 Q(e,t={}){let s=e;if("object"!=typeof t){t={name:t}}const n=Object.assign({name:O,automaticDataCollectionEnabled:!1},t),i=n.name;if("string"!=typeof i||!i)throw V.create("bad-app-name",{appName:String(i)});if(s||(s=(0,r.getDefaultAppConfig)()),!s)throw V.create("no-options");const o=B.get(i);if(o){if((0,r.deepEqual)(s,o.options)&&(0,r.deepEqual)(n,o.config))return o;throw V.create("duplicate-app",{appName:i})}const c=new a.ComponentContainer(i);for(const e of H.values())c.addComponent(e);const l=new z(s,n,c);return B.set(i,l),l}async function J(e){let t=!1;const s=e.name;if(B.has(s))t=!0,B.delete(s);else if(R.has(s)){e.decRefCount()<=0&&(R.delete(s),t=!0)}t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function X(e,t,s){var n;let r=null!==(n=L[e])&&void 0!==n?n:e;s&&(r+=`-${s}`);const i=r.match(/\s|\//),o=t.match(/\s|\//);if(i||o){const e=[`Unable to register library "${r}" with version "${t}":`];return i&&e.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&o&&e.push("and"),o&&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,i.openDB)("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(Z)}catch(e){console.warn(e)}}}).catch(e=>{throw V.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=V.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 ie(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),oe(s)>t){e.dates.pop();break}}else if(s.push({agent:n.agent,dates:[n.date]}),oe(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 ie{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=V.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 oe(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 o(e),"PRIVATE")),q(new a.Component("heartbeat",e=>new ne(e),"PRIVATE")),X(c,l,ce),X(c,l,"esm2017"),X("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 x(()=>fetch(s,n));if(!r.ok)throw await w("Delete Installation",r)}(t,s),await R(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=Q,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=J,s.onIdChange=function(e,t){const{appConfig:s}=e;return function(e,t){F();const s=P(e);let a=S.get(s);a||(a=new Set,S.set(s,a));a.add(t)}(s,t),()=>{!function(e,t){const s=P(e),a=S.get(s);if(!a)return;a.delete(t),0===a.size&&S.delete(s);G()}(s,t)}};var a=e("@firebase/app"),n=e("@firebase/component"),r=e("@firebase/util"),i=e("idb");const o="@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 y({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function T(e,{refreshToken:t}){const s=y(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 x(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 _(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 v=/^[cdef][\w-]{21}$/,E="";function I(){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 v.test(t)?t:E}catch(e){return E}}function P(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 S=new Map;function C(e,t){const s=P(e);j(s,t),function(e,t){const s=F();s&&s.postMessage({key:e,fid:t});G()}(s,t)}function j(e,t){const s=S.get(e);if(s)for(const e of s)e(t)}let A=null;function F(){return!A&&"BroadcastChannel"in self&&(A=new BroadcastChannel("[Firebase] FID Change"),A.onmessage=e=>{j(e.data.key,e.data.fid)}),A}function G(){0===S.size&&A&&(A.close(),A=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 M="firebase-installations-database",D=1,N="firebase-installations-store";let O=null;function L(){return O||(O=(0,i.openDB)(M,D,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(N)}})),O}async function B(e,t){const s=P(e),a=(await L()).transaction(N,"readwrite"),n=a.objectStore(N),r=await n.get(s);return await n.put(t,s),await a.done,r&&r.fid===t.fid||C(e,t.fid),t}async function R(e){const t=P(e),s=(await L()).transaction(N,"readwrite");await s.objectStore(N).delete(t),await s.done}async function H(e,t){const s=P(e),a=(await L()).transaction(N,"readwrite"),n=a.objectStore(N),r=await n.get(s),i=t(r);return i===undefined?await n.delete(s):await n.put(i,s),await a.done,!i||r&&r.fid===i.fid||C(e,i.fid),i}
/**
 * @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:I(),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=y(e),r=t.getImmediate({optional:!0});if(r){const e=await r.getHeartbeatsHeader();e&&n.append("x-firebase-client",e)}const i={fid:s,authVersion:m,appId:e.appId,sdkVersion:d},o={method:"POST",headers:n,body:JSON.stringify(i)},c=await x(()=>fetch(a,o));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 R(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===E?{installationEntry:await t}:{installationEntry:s,registrationPromise:t}}async function q(e){let t=await W(e.appConfig);for(;1===t.registrationStatus;)await _(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 K({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 i={installation:{sdkVersion:d,appId:e.appId}},o={method:"POST",headers:n,body:JSON.stringify(i)},c=await x(()=>fetch(a,o));if(c.ok){return b(await c.json())}throw await w("Generate Auth Token",c)}async function V(e,t=!1){let s;const a=await H(e.appConfig,a=>{if(!Y(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 z(e.appConfig);for(;1===s.authToken.requestStatus;)await _(100),s=await z(e.appConfig);const a=s.authToken;return 0===a.requestStatus?V(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 K(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 R(e.appConfig);throw s}}(e,t),t}});return s?await s:a.authToken}function z(e){return H(e,e=>{if(!Y(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 Y(e){return e!==undefined&&2===e.registrationStatus}async function Q(e){const t=e,{installationEntry:s,registrationPromise:a}=await U(t);return a?a.catch(console.error):V(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 J(e,t=!1){const s=e;await async function(e){const{registrationPromise:t}=await U(e);t&&await t}(s);return(await V(s,t)).token}function X(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 X("App Configuration");if(!e.name)throw X("App Name");const t=["projectId","apiKey","appId"];for(const s of t)if(!e.options[s])throw X(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:()=>Q(s),getToken:e=>J(s,e)}};(0,a._registerComponent)(new n.Component(Z,ee,"PUBLIC")),(0,a._registerComponent)(new n.Component("installations-internal",te,"PRIVATE")),(0,a.registerVersion)(o,c),(0,a.registerVersion)(o,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},i=s.LogLevel.INFO,o={[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=o[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=i,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 i=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:i,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 C.create("only-available-in-window");e.swRegistration||await R(e);return async function(e){const t=await E(e.firebaseDependencies);t&&(await j(e.firebaseDependencies,t.token),await async function(e){const t=P(e),s=(await v()).transaction(x,"readwrite");await s.objectStore(x).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,i.getApp)()){return z().then(e=>{if(!e)throw C.create("unsupported-browser")},e=>{throw C.create("indexed-db-unsupported")}),(0,i._getProvider)((0,r.getModularInstance)(e),"messaging").getImmediate()},s.getToken=async function(e,t){return H(e=(0,r.getModularInstance)(e),t)},s.isSupported=z,s.onMessage=function(e,t){return function(e,t){if(!navigator)throw C.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"),i=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 o="/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 y="firebase-messaging-database",T=1,x="firebase-messaging-store";let _=null;function v(){return _||(_=(0,n.openDB)(y,T,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(x)}})),_}async function E(e){const t=P(e),s=await v(),a=await s.transaction(x).objectStore(x).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 i;if(a<2)return;if(!s.objectStoreNames.contains(w))return;const o=r.objectStore(w),c=await o.index("fcmSenderId").get(e);if(await o.clear(),c)if(2===a){const e=c;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:null!==(i=e.createTime)&&void 0!==i?i: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 I(e,t),t}}async function I(e,t){const s=P(e),a=(await v()).transaction(x,"readwrite");return await a.objectStore(x).put(t,s),await a.done,t}function P({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 S={"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."},C=new r.ErrorFactory("messaging","Messaging",S);async function j(e,t){const s={method:"DELETE",headers:await F(e)};try{const a=await fetch(`${A(e.appConfig)}/${t}`,s),n=await a.json();if(n.error){const e=n.error.message;throw C.create("token-unsubscribe-failed",{errorInfo:e})}}catch(e){throw C.create("token-unsubscribe-failed",{errorInfo:null==e?void 0:e.toString()})}}function A({projectId:e}){return`${d}/projects/${e}/registrations`}async function F({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 G({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 M=6048e5;async function D(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 E(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+M?async function(e,t){try{const s=await async function(e,t){const s=await F(e),a=G(t.subscriptionOptions),n={method:"PATCH",headers:s,body:JSON.stringify(a)};let r;try{const s=await fetch(`${A(e.appConfig)}/${t.token}`,n);r=await s.json()}catch(e){throw C.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw C.create("token-update-failed",{errorInfo:e})}if(!r.token)throw C.create("token-update-no-token");return r.token}(e.firebaseDependencies,t),a=Object.assign(Object.assign({},t),{token:s,createTime:Date.now()});return await I(e.firebaseDependencies,a),s}catch(e){throw e}}(e,{token:a.token,createTime:Date.now(),subscriptionOptions:s}):a.token;try{await j(e.firebaseDependencies,a.token)}catch(e){console.warn(e)}return N(e.firebaseDependencies,s)}return N(e.firebaseDependencies,s)}async function N(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 F(e),a=G(t),n={method:"POST",headers:s,body:JSON.stringify(a)};let r;try{const t=await fetch(A(e.appConfig),n);r=await t.json()}catch(e){throw C.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw C.create("token-subscribe-failed",{errorInfo:e})}if(!r.token)throw C.create("token-subscribe-no-token");return r.token}(e,t),a={token:s,createTime:Date.now(),subscriptionOptions:t};return await I(e,a),a.token}function O(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,i;if(!t.fcmOptions&&!(null===(s=t.notification)||void 0===s?void 0:s.click_action))return;e.fcmOptions={};const o=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;o&&(e.fcmOptions.link=o);const c=null===(i=t.fcmOptions)||void 0===i?void 0:i.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 L(e){return C.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 L("App Configuration Object");if(!e.name)throw L("App Name");const t=["projectId","apiKey","appId","messagingSenderId"],{options:s}=e;for(const e of t)if(!s[e])throw L(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 R(e){try{e.swRegistration=await navigator.serviceWorker.register(o,{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 C.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 C.create("only-available-in-window");if("default"===Notification.permission&&await Notification.requestPermission(),"granted"!==Notification.permission)throw C.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 R(e),t||!e.swRegistration){if(!(t instanceof ServiceWorkerRegistration))throw C.create("invalid-sw-registration");e.swRegistration=t}}(e,null==t?void 0:t.serviceWorkerRegistration),D(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(O(s)):e.onMessageHandler.next(O(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",K=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},V=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 z(){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,i._registerComponent)(new a.Component("messaging",K,"PUBLIC")),(0,i._registerComponent)(new a.Component("messaging-internal",V,"PRIVATE")),(0,i.registerVersion)(W,$),(0,i.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"),i=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 o="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=y(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 i;if(a<2)return;if(!s.objectStoreNames.contains(f))return;const o=r.objectStore(f),c=await o.index("fcmSenderId").get(e);if(await o.clear(),c)if(2===a){const e=c;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:null!==(i=e.createTime)&&void 0!==i?i: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=y(e),a=(await k()).transaction(p,"readwrite");return await a.objectStore(p).put(t,s),await a.done,t}function y({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."},x=new r.ErrorFactory("messaging","Messaging",T);async function _(e,t){const s={method:"DELETE",headers:await E(e)};try{const a=await fetch(`${v(e.appConfig)}/${t}`,s),n=await a.json();if(n.error){const e=n.error.message;throw x.create("token-unsubscribe-failed",{errorInfo:e})}}catch(e){throw x.create("token-unsubscribe-failed",{errorInfo:null==e?void 0:e.toString()})}}function v({projectId:e}){return`https://fcmregistrations.googleapis.com/v1/projects/${e}/registrations`}async function E({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 I({p256dh:e,auth:t,endpoint:s,vapidKey:a}){const n={web:{endpoint:s,auth:t,p256dh:e}};return a!==o&&(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 P(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 E(e),a=I(t.subscriptionOptions),n={method:"PATCH",headers:s,body:JSON.stringify(a)};let r;try{const s=await fetch(`${v(e.appConfig)}/${t.token}`,n);r=await s.json()}catch(e){throw x.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw x.create("token-update-failed",{errorInfo:e})}if(!r.token)throw x.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 _(e.firebaseDependencies,a.token)}catch(e){console.warn(e)}return C(e.firebaseDependencies,s)}return C(e.firebaseDependencies,s)}async function S(e){const t=await b(e.firebaseDependencies);t&&(await _(e.firebaseDependencies,t.token),await async function(e){const t=y(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 C(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 E(e),a=I(t),n={method:"POST",headers:s,body:JSON.stringify(a)};let r;try{const t=await fetch(v(e.appConfig),n);r=await t.json()}catch(e){throw x.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(r.error){const e=r.error.message;throw x.create("token-subscribe-failed",{errorInfo:e})}if(!r.token)throw x.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 j(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 A(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 j(t,s);const a=await G();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,i;if(!t.fcmOptions&&!(null===(s=t.notification)||void 0===s?void 0:s.click_action))return;e.fcmOptions={};const o=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;o&&(e.fcmOptions.link=o);const c=null===(i=t.fcmOptions)||void 0===i?void 0:i.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 F(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),i=new URL(self.location.origin);if(r.host!==i.host)return;let o=await async function(e){const t=await G();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 o?o=await o.focus():(o=await self.clients.openWindow(n),await(l=3e3,new Promise(e=>{setTimeout(e,l)}))),o?(a.messageType=d.NOTIFICATION_CLICKED,a.isFirebaseMessaging=!0,o.postMessage(a)):void 0}function G(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function M(e){return x.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 D{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 M("App Configuration Object");if(!e.name)throw M("App Name");const t=["projectId","apiKey","appId","messagingSenderId"],{options:s}=e;for(const e of t)if(!s[e])throw M(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 N=e=>{const t=new D(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),e.getProvider("analytics-internal"));return self.addEventListener("push",e=>{e.waitUntil(A(e,t))}),self.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(async function(e,t){var s,a;const{newSubscription:n}=e;if(!n)return void await S(t);const r=await b(t.firebaseDependencies);await S(t),t.vapidKey=null!==(a=null===(s=null==r?void 0:r.subscriptionOptions)||void 0===s?void 0:s.vapidKey)&&void 0!==a?a:o,await P(t)}(e,t))}),self.addEventListener("notificationclick",e=>{e.waitUntil(F(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 O(){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.
 */i._registerComponent(new a.Component("messaging-sw",N,"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=i.getApp()){return O().then(e=>{if(!e)throw x.create("unsupported-browser")},e=>{throw x.create("indexed-db-unsupported")}),i._getProvider(r.getModularInstance(e),"messaging-sw").getImmediate()},s.isSupported=O,s.onBackgroundMessage=function(e,t){return function(e,t){if(self.document!==undefined)throw x.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=C,s=j){const a=t*Math.pow(s,e),n=Math.round(F*a*(Math.random()-.5)*2);return Math.min(A,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 I(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],i=s[r];if(E(a)&&E(i)){if(!e(a,i))return!1}else if(a!==i)return!1}for(const e of n)if(!a.includes(e))return!1;return!0},s.deepExtend=m,s.errorPrefix=S,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=_,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(S(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(S(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(S(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},i=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,i=r?e[t+1]:0,o=t+2<e.length,c=o?e[t+2]:0,l=n>>2,d=(3&n)<<4|i>>4;let m=(15&i)<<2|c>>6,u=63&c;o||(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++],i=e[s++];t[a++]=String.fromCharCode((15&n)<<12|(63&r)<<6|63&i)}}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 i=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==i||null==c)throw new o;const l=n<<2|r>>4;if(a.push(l),64!==i){const e=r<<4&240|i>>2;if(a.push(e),64!==c){const e=i<<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 o extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}s.DecodeBase64StringError=o;const c=function(e){const t=r(e);return i.encodeByteArray(t,!0)};s.base64Encode=c;const l=function(e){return c(e).replace(/\./g,"")};s.base64urlEncodeWithoutPadding=l;const d=function(e){try{return i.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 y extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name="FirebaseError",Object.setPrototypeOf(this,y.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,T.prototype.create)}}s.FirebaseError=y;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(x,(e,s)=>{const a=t[s];return null!=a?String(a):`<${s}?>`})}(n,s):"Error",i=`${this.serviceName}: ${r} (${a}).`;return new y(a,i,s)}}s.ErrorFactory=T;const x=/\{\$([^}]+)}/g;
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function _(e){return JSON.parse(e)}const v=function(e){let t={},s={},a={},n="";try{const r=e.split(".");t=_(d(r[0])||""),s=_(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=v;s.isValidTimestamp=function(e){const t=v(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=v(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null};s.isValidFormat=function(e){const t=v(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")};function E(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=v(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],i=this.chain_[1],o=this.chain_[2],c=this.chain_[3],l=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(a=c^i&(o^c),n=1518500249):(a=i^o^c,n=1859775393):e<60?(a=i&o|c&(i|o),n=2400959708):(a=i^o^c,n=3395469782);const t=(r<<5|r>>>27)+a+l+n+s[e]&4294967295;l=c,c=o,o=4294967295&(i<<30|i>>>2),i=r,r=t}this.chain_[0]=this.chain_[0]+r&4294967295,this.chain_[1]=this.chain_[1]+i&4294967295,this.chain_[2]=this.chain_[2]+o&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 I{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=P),a.error===undefined&&(a.error=P),a.complete===undefined&&(a.complete=P);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 P(){}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function S(e,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 C=1e3,j=2,A=s.MAX_VALUE_MILLIS=144e5,F=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 i(e){try{c(a.next(e))}catch(e){r(e)}}function o(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(i,o)}c((a=a.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var s,a,n,r,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function o(o){return function(c){return function(o){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,o[0]&&(i=0)),i;)try{if(s=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{s=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.NonStringRefError=void 0;var o=i(e("@json-schema-tools/traverse")),c=i(e("@json-schema-tools/reference-resolver")),l=i(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 i=r[n];c.default.protocolHandlerMap[i]=this.options.protocolHandlerMap[i]}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,i,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,i=t,r.label=1;case 1:return n<i.length?(l=i[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,o.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,o.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 i(e){try{c(a.next(e))}catch(e){r(e)}}function o(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(i,o)}c((a=a.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var s,a,n,r,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function o(o){return function(c){return function(o){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,o[0]&&(i=0)),i;)try{if(s=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{s=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});var i=e("./errors"),o=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,o.default)(e)];case 1:return t=a.sent(),[3,3];case 2:throw a.sent(),new i.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 i.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 i=function(e){this.name="InvalidFileSystemPathError",this.message=["InvalidFileSystemPathError","The path was not resolvable: ".concat(e)].join("\n")};s.InvalidFileSystemPathError=i}}},{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 i(e){try{c(a.next(e))}catch(e){r(e)}}function o(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(i,o)}c((a=a.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var s,a,n,r,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function o(o){return function(c){return function(o){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,o[0]&&(i=0)),i;)try{if(s=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{s=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});var o=i(e("./default-protocol-handler-map")),c=i(e("./reference-resolver")),l=a(a({},o.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 i(e){try{c(a.next(e))}catch(e){r(e)}}function o(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(i,o)}c((a=a.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var s,a,n,r,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function o(o){return function(c){return function(o){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,o[0]&&(i=0)),i;)try{if(s=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{s=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0});var i=e("./errors"),o=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,o.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 i.NonJsonRefError({$ref:e},l.message);case 4:if(c!==undefined)return f=c,a&&(f=(0,o.default)(a,f)),[2,f];if(!1===e.includes("://"))throw new i.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,o.default)(a,f)),[2,f];n.label=7;case 7:return d++,[3,5];case 8:throw new i.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("")},i=function(e,t){var s=t.find(function(t){return t===e});return s||!1},o=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),o(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),o(u,2)))),m.push(t),f.push([t,k]);var b=function(t,s){var a=i(t,m);return a?(p.push(a),!0===g.skipFirstMutation&&a===m[0]?c(t,!0,r(s),o(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=i(t.items,m);if(w)if(p.push(w),!0===g.skipFirstMutation&&w===m[0])k.items=c(t.items,!0,r(h),o(u));else{var y=f.find(function(e){var t=e[0];return w===t})[1];k.items=y}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,x={};Object.keys(t.properties).forEach(function(e){x[e]=b(T[e],n(n([],h,!0),["properties",e.toString()],!1))}),k.properties=x}if(t.patternProperties!==undefined){var _=t.patternProperties,v={};Object.keys(t.patternProperties).forEach(function(e){v[e]=b(_[e],n(n([],h,!0),["patternProperties",e.toString()],!1))}),k.patternProperties=v}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 E=-1!==p.indexOf(t);return u.pop(),c(k,E,r(h),o(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){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.AddressBookController=s.getDefaultAddressBookControllerState=s.controllerName=s.AddressType=void 0;const i=e("@metamask/base-controller"),o=e("@metamask/controller-utils");var c;!function(e){e.externallyOwnedAccounts="EXTERNALLY_OWNED_ACCOUNTS",e.contractAccounts="CONTRACT_ACCOUNTS",e.nonAccounts="NON_ACCOUNTS"}(c||(s.AddressType=c={})),s.controllerName="AddressBookController";const l={addressBook:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0}};s.getDefaultAddressBookControllerState=()=>({addressBook:{}});class d extends i.BaseController{constructor({messenger:e,state:t}){const i={...(0,s.getDefaultAddressBookControllerState)(),...t};super({messenger:e,metadata:l,name:s.controllerName,state:i}),a.add(this),r(this,a,"m",n).call(this)}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,o.toChecksumHexAddress)(t),!([e,t].every(e=>(0,o.isSafeDynamicKey)(e))&&(0,o.isValidHexAddress)(t)&&this.state.addressBook[e]&&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,o.toHex)(1),a="",n){if(e=(0,o.toChecksumHexAddress)(e),!(0,o.isValidHexAddress)(e))return!1;const r={address:e,chainId:s,isEns:!1,memo:a,name:t,addressType:n,lastUpdatedAt:Date.now()},i=(0,o.normalizeEnsName)(t);return i&&(r.name=i,r.isEns=!0),this.update(t=>{t.addressBook={...this.state.addressBook,[s]:{...this.state.addressBook[s],[e]:r}}}),"*"!==String(s)&&this.messenger.publish("AddressBookController:contactUpdated",r),!0}}s.AddressBookController=d,a=new WeakSet,n=function(){this.messenger.registerActionHandler(`${s.controllerName}:list`,this.list.bind(this)),this.messenger.registerActionHandler(`${s.controllerName}:set`,this.set.bind(this)),this.messenger.registerActionHandler(`${s.controllerName}:delete`,this.delete.bind(this))},s.default=d}}},{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 i=e("@metamask/base-controller"),o={announcements:{}},c={announcements:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!0,usedInUi:!0}};class l extends i.BaseController{constructor({messenger:e,state:t,allAnnouncements:s}){const i={...o,...t};super({messenger:e,metadata:c,name:"AnnouncementController",state:i}),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/bridge-status.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.cjs","./utils/gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/gas.cjs","./utils/intent-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs","./utils/metrics.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/metrics.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-controller/dist/index.cjs","@metamask/controller-utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/controller-utils/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,i,o,c,l,d,m,u,h,f,p,g,k,b,w,y,T,x,_,v,E,I,P,S,C,j,A,F,G,M,D,N=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},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)};Object.defineProperty(s,"__esModule",{value:!0}),s.BridgeStatusController=void 0;const L=e("@metamask/bridge-controller"),B=e("@metamask/controller-utils"),R=e("@metamask/polling-controller"),H=e("@metamask/transaction-controller"),U=e("@metamask/utils"),q=e("./bridge-status-controller.intent.cjs"),W=e("./constants.cjs"),$=e("./types.cjs"),K=e("./utils/bridge-status.cjs"),V=e("./utils/gas.cjs"),z=e("./utils/intent-api.cjs"),Y=e("./utils/metrics.cjs"),Q=e("./utils/transaction.cjs"),J={txHistory:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0}};class X extends((0,R.StaticIntervalPollingController)()){constructor({messenger:e,state:t,clientId:s,fetchFn:R,addTransactionFn:X,addTransactionBatchFn:Z,updateTransactionFn:ee,estimateGasFeeFn:te,config:se,traceFn:ae}){super({name:W.BRIDGE_STATUS_CONTROLLER_NAME,metadata:J,messenger:e,state:{...W.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE,...t}}),a.add(this),n.set(this,{}),r.set(this,void 0),i.set(this,void 0),o.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,({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=L.StatusTypes.FAILED})}),this.resetState=()=>{this.update(e=>{e.txHistory=W.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory})},this.wipeBridgeStatus=({address:e,ignoreNetwork:t})=>{if(t)this.update(e=>{e.txHistory=W.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory});else{const{selectedNetworkClientId:t}=this.messenger.call("NetworkController:getState"),s=this.messenger.call("NetworkController:getNetworkClientById",t).configuration.chainId;O(this,I,"f").call(this,e,s)}},this.restartPollingForFailedAttempts=e=>{const{txMetaId:t,txHash:s}=e;if(!t&&!s)throw new Error("Either txMetaId or txHash must be provided");let a;if(t?this.state.txHistory[t]&&(a=t):s&&(a=Object.keys(this.state.txHistory).find(e=>this.state.txHistory[e].status.srcChain.txHash===s)),!a)throw new Error("No bridge transaction history found for "+(t?`txMetaId: ${t}`:`txHash: ${s}`));const r=this.state.txHistory[a],i=r.attempts?.counter??0;if(this.update(e=>{a&&(e.txHistory[a].attempts=undefined)}),O(this,w,"f").call(this,r)){if(!O(this,n,"f")[a]&&(O(this,b,"f").call(this,a),!r.featureId)){const e=this.messenger.call("AccountsController:getAccountByAddress",r.account),t=(0,Y.getRequestParamFromHistory)(r),s=(0,Y.getRequestMetadataFromHistory)(r,e),{security_warnings:n,...o}=s;O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.PollingStatusUpdated,a,{...(0,Y.getTradeDataFromHistory)(r),...(0,Y.getPriceImpactFromQuote)(r.quote),...o,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:L.MetricsActionType.SWAPBRIDGE_V1,polling_status:L.PollingStatus.ManuallyRestarted,retry_attempts:i})}}},this.getBridgeHistoryItemByTxMetaId=e=>this.state.txHistory[e],p.set(this,()=>{const{txHistory:e}=this.state;Object.values(e).filter(e=>e.status.status===L.StatusTypes.PENDING||e.status.status===L.StatusTypes.UNKNOWN).filter(e=>Boolean(e.txMetaId)).filter(e=>!O(this,n,"f")[e.txMetaId]).filter(e=>O(this,w,"f").call(this,e)).forEach(e=>{const t=e.txMetaId;(0,K.shouldSkipFetchDueToFetchFailures)(e.attempts)||O(this,b,"f").call(this,t)})}),g.set(this,(e,t)=>{const{bridgeTxMeta:s,statusRequest:a,quoteResponse:n,startTime:r,slippagePercentage:i,initialDestAssetBalance:o,targetContractAddress:c,approvalTxId:l,isStxEnabled:d,location:m,accountAddress:u}=e,h=(0,Q.getHistoryKey)(t,s?.id),f={txMetaId:s?.id,actionId:t,originalTransactionId:s?.originalTransactionId||s?.id,batchId:s?.batchId,quote:n.quote,startTime:r,estimatedProcessingTimeInSeconds:n.estimatedProcessingTimeInSeconds,slippagePercentage:i,pricingData:{amountSent:n.sentAmount?.amount??"0",amountSentInUsd:n.sentAmount?.usd??undefined,quotedGasInUsd:n.gasFee?.effective?.usd??undefined,quotedReturnInUsd:n.toTokenAmount?.usd??undefined,quotedGasAmount:n.gasFee?.effective?.amount??undefined},initialDestAssetBalance:o,targetContractAddress:c,account:u,status:{status:L.StatusTypes.PENDING,srcChain:{chainId:a.srcChainId,txHash:a.srcTxHash}},hasApprovalTx:Boolean(n.approval),approvalTxId:l,isStxEnabled:d??!1,featureId:n.featureId,location:m};this.update(e=>{e.txHistory[h]=f})}),k.set(this,(e,t)=>{this.update(s=>{(0,Q.rekeyHistoryItemInState)(s,e,t)})}),b.set(this,e=>{const t=O(this,n,"f")[e];t&&this.stopPollingByPollingToken(t);const s=this.state.txHistory[e];s&&O(this,w,"f").call(this,s)&&(O(this,n,"f")[e]=this.startPolling({bridgeTxMetaId:e}))}),w.set(this,e=>{const t=Boolean(e?.quote?.intent);return[(0,L.isCrossChain)(e.quote.srcChainId,e.quote.destChainId),t,(0,L.isTronChainId)(e.quote.srcChainId)].some(Boolean)}),this.startPollingForBridgeTxStatus=e=>{const{bridgeTxMeta:t}=e;if(!t?.id)throw new Error("Cannot start polling: bridgeTxMeta.id is required for polling");O(this,g,"f").call(this,e),O(this,b,"f").call(this,t.id)},this._executePoll=async e=>{await O(this,x,"f").call(this,e)},T.set(this,e=>{const{attempts:t}=this.state.txHistory[e],s=t?{counter:t.counter+1,lastAttemptTime:Date.now()}:{counter:1,lastAttemptTime:Date.now()},a=O(this,n,"f")[e];if(s.counter>=W.MAX_ATTEMPTS&&a){this.stopPollingByPollingToken(a),delete O(this,n,"f")[e];const t=this.state.txHistory[e];if(t&&!t.featureId){const a=this.messenger.call("AccountsController:getAccountByAddress",t.account),n=(0,Y.getRequestParamFromHistory)(t),r=(0,Y.getRequestMetadataFromHistory)(t,a),{security_warnings:i,...o}=r;O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.PollingStatusUpdated,e,{...(0,Y.getTradeDataFromHistory)(t),...(0,Y.getPriceImpactFromQuote)(t.quote),...o,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:L.MetricsActionType.SWAPBRIDGE_V1,polling_status:L.PollingStatus.MaxPollingReached,retry_attempts:s.counter})}}this.update(t=>{t.txHistory[e].attempts=s})}),x.set(this,async({bridgeTxMetaId:e})=>{const{txHistory:t}=this.state,s=t[e];if(s&&!(0,K.shouldSkipFetchDueToFetchFailures)(s.attempts))try{let t,a,l=[],d=null;const m=Boolean(s.quote.intent);if(m){const{srcChainId:n}=s.quote,r=new z.IntentApiImpl(O(this,c,"f").customBridgeApiBaseUrl,O(this,o,"f")),l=await r.getOrderStatus(e,s.quote.intent?.protocol??"",n.toString(),O(this,i,"f"),await O(this,_,"f").call(this));a=l.status,d=(0,z.translateIntentOrderToBridgeStatus)(l,n,s.status.srcChain.txHash),t=d.status}else{const a=O(this,v,"f").call(this,e);if(!a)return;O(this,E,"f").call(this,e,a);const n=(0,K.getStatusRequestWithSrcTxHash)(s.quote,a),r=await(0,K.fetchBridgeTxStatus)(n,O(this,i,"f"),await O(this,_,"f").call(this),O(this,o,"f"),O(this,c,"f").customBridgeApiBaseUrl);t=r.status,l=r.validationFailures}if(l.length>0)throw O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.StatusValidationFailed,e,{failures:l,refresh_count:s.attempts?.counter??0}),new Error(`Bridge status validation failed: ${l.join(", ")}`);const u={...s,status:t,completionTime:t.status===L.StatusTypes.COMPLETE||t.status===L.StatusTypes.FAILED?Date.now():undefined,attempts:undefined};this.update(t=>{t.txHistory[e]=u}),m&&d&&a&&O(this,r,"f").syncTransactionFromIntentStatus(e,s,d,a);const h=O(this,n,"f")[e];if((t.status===L.StatusTypes.COMPLETE||t.status===L.StatusTypes.FAILED)&&h){if(this.stopPollingByPollingToken(h),delete O(this,n,"f")[e],s.featureId)return;t.status===L.StatusTypes.COMPLETE&&(O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Completed,e),this.messenger.publish("BridgeStatusController:destinationTransactionCompleted",s.quote.destAsset.assetId)),t.status===L.StatusTypes.FAILED&&O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Failed,e)}}catch(t){console.warn("Failed to fetch bridge tx status",t),O(this,T,"f").call(this,e)}}),_.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}}),v.set(this,e=>{const{txHistory:t}=this.state,s=t[e].status.srcChain.txHash;if(s)return s;const a=this.messenger.call("TransactionController:getState").transactions.find(t=>t.id===e);return a?.hash}),E.set(this,(e,t)=>{const{txHistory:s}=this.state;s[e].status.srcChain.txHash||this.update(s=>{s.txHistory[e].status.srcChain.txHash=t})}),I.set(this,(e,t)=>{const s=Object.keys(this.state.txHistory).filter(s=>{const a=this.state.txHistory[s],n=(0,U.numberToHex)(a.quote.srcChainId);return a.account===e&&n===t});s.forEach(e=>{O(this,n,"f")[e]&&this.stopPollingByPollingToken(O(this,n,"f")[e])}),this.update(e=>{e.txHistory=s.reduce((e,t)=>(delete e[t],e),e.txHistory)})}),P.set(this,async(e,t,s)=>{if(!s.metadata?.snap?.id)throw new Error("Failed to submit cross-chain swap transaction: undefined snap id");const a=(0,Q.getClientRequest)(e,t.quote.srcChainId,s),n=await this.messenger.call("SnapController:handleRequest",a),r={...t,trade:e};return(0,Q.handleNonEvmTxResponse)(n,r,s)}),S.set(this,async e=>{const t=await e,s=this.messenger.call("TransactionController:getState").transactions.find(e=>e.hash===t);if(!s)throw new Error("Failed to submit cross-chain swap tx: txMeta for txHash was not found");return s}),C.set(this,async(e,{timeoutMs:t=3e5,pollMs:s=3e3}={})=>await(0,Q.waitForTxConfirmation)(this.messenger,e,{timeoutMs:t,pollMs:s})),j.set(this,async(e,t,s,a,n)=>{if(s){const r=async()=>{await O(this,F,"f").call(this,a);const r=await O(this,A,"f").call(this,{transactionType:e?H.TransactionType.bridgeApproval:H.TransactionType.swapApproval,trade:s,requireApproval:n});return await(0,Q.handleApprovalDelay)(t),r};return await O(this,h,"f").call(this,{name:e?W.TraceName.BridgeTransactionApprovalCompleted:W.TraceName.SwapTransactionApprovalCompleted,data:{srcChainId:(0,L.formatChainIdToCaip)(t),stxEnabled:!1}},r)}return undefined}),A.set(this,async({transactionType:e,trade:t,requireApproval:s=!1,txFee:a,actionId:n})=>{const r=n??(0,Q.generateActionId)().toString();if(!this.messenger.call("AccountsController:getAccountByAddress",t.from))throw new Error("Failed to submit cross-chain swap transaction: unknown account in trade data");const i=(0,L.formatChainIdToHex)(t.chainId),o=this.messenger.call("NetworkController:findNetworkClientIdByChainId",i),c={actionId:r,networkClientId:o,requireApproval:s,type:e,origin:"metamask"},{gasLimit:d,...m}=t,u={...m,chainId:i,...d&&0!==d&&{gasLimit:d.toString(),gas:d.toString()}},h={...u,...await O(this,G,"f").call(this,u,o,i,a)},{result:f}=await O(this,l,"f").call(this,h,c);return await O(this,S,"f").call(this,f)}),F.set(this,async e=>{e&&await O(this,A,"f").call(this,{transactionType:H.TransactionType.bridgeApproval,trade:e})}),G.set(this,async(e,t,s,a)=>{const{gas:n}=e;if(a)return{maxFeePerGas:(0,B.toHex)(a.maxFeePerGas??0),maxPriorityFeePerGas:(0,B.toHex)(a.maxPriorityFeePerGas??0),gas:n?(0,B.toHex)(n):undefined};const{gasFeeEstimates:r}=this.messenger.call("GasFeeController:getState"),{estimates:i}=await O(this,u,"f").call(this,{transactionParams:e,chainId:s,networkClientId:t}),{maxFeePerGas:o,maxPriorityFeePerGas:c}=(0,V.getTxGasEstimates)({networkGasFeeEstimates:r,txGasFeeEstimates:i});return{maxFeePerGas:o,maxPriorityFeePerGas:c,gas:n?(0,B.toHex)(n):undefined}}),M.set(this,async e=>{const t=await(0,Q.getAddTransactionBatchParams)({messenger:this.messenger,estimateGasFeeFn:O(this,u,"f"),...e}),s={[H.TransactionType.bridgeApproval]:t.transactions.find(({type:e})=>e===H.TransactionType.bridgeApproval)?.params.data,[H.TransactionType.swapApproval]:t.transactions.find(({type:e})=>e===H.TransactionType.swapApproval)?.params.data,[H.TransactionType.bridge]:t.transactions.find(({type:e})=>e===H.TransactionType.bridge)?.params.data,[H.TransactionType.swap]:t.transactions.find(({type:e})=>e===H.TransactionType.swap)?.params.data},{batchId:a}=await O(this,d,"f").call(this,t),{approvalMeta:n,tradeMeta:r}=(0,Q.findAndUpdateTransactionsInBatch)({messenger:this.messenger,updateTransactionFn:O(this,m,"f"),batchId:a,txDataByType:s});if(!r)throw new Error("Failed to update cross-chain swap transaction batch: tradeMeta not found");return{approvalMeta:n,tradeMeta:r}}),this.submitTx=async(e,t,s,n,r=L.MetaMetricsSwapsEventSource.MainView)=>{this.messenger.call("BridgeController:stopPollingForQuotes",L.AbortReason.TransactionSubmitted,t.featureId?undefined:n);const o=O(this,a,"m",y).call(this,e);if(!o)throw new Error("Failed to submit cross-chain swap transaction: undefined multichain account");const c=(0,L.isHardwareWallet)(o),l=(0,Y.getPreConfirmationPropertiesFromQuote)(t,s,c,r);let d,m;!t.featureId&&O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Submitted,undefined,l);const u=Date.now(),f=(0,L.isCrossChain)(t.quote.srcChainId,t.quote.destChainId),p=(0,L.isTronChainId)(t.quote.srcChainId);if((0,L.isNonEvmChainId)(t.quote.srcChainId)){if(t.approval&&(0,L.isTronTrade)(t.approval)){const e=await O(this,h,"f").call(this,{name:f?W.TraceName.BridgeTransactionApprovalCompleted:W.TraceName.SwapTransactionApprovalCompleted,data:{srcChainId:(0,L.formatChainIdToCaip)(t.quote.srcChainId),stxEnabled:!1}},async()=>{try{return t.approval&&(0,L.isTronTrade)(t.approval)?await O(this,P,"f").call(this,t.approval,t,o):undefined}catch(e){throw!t.featureId&&O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Failed,undefined,{error_message:e?.message,...l}),e}});m=e?.id,await(0,Q.handleApprovalDelay)(t.quote.srcChainId)}d=await O(this,h,"f").call(this,{name:f?W.TraceName.BridgeTransactionCompleted:W.TraceName.SwapTransactionCompleted,data:{srcChainId:(0,L.formatChainIdToCaip)(t.quote.srcChainId),stxEnabled:!1}},async()=>{try{if(!(0,L.isTronTrade)(t.trade)&&!(0,L.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 O(this,P,"f").call(this,t.trade,t,o)}catch(e){throw!t.featureId&&O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Failed,d?.id,{error_message:e?.message,...l}),e}})}else{const e=O(this,i,"f")===$.BridgeClientId.MOBILE&&c;d=await O(this,h,"f").call(this,{name:f?W.TraceName.BridgeTransactionCompleted:W.TraceName.SwapTransactionCompleted,data:{srcChainId:(0,L.formatChainIdToCaip)(t.quote.srcChainId),stxEnabled:s}},async()=>{if(!(0,L.isEvmTxData)(t.trade))throw new Error("Failed to submit cross-chain swap transaction: trade is not an EVM transaction");if(s||t.quote.gasIncluded7702){const{tradeMeta:s,approvalMeta:a}=await O(this,M,"f").call(this,{isBridgeTx:f,resetApproval:t.resetApproval,approval:t.approval&&(0,L.isEvmTxData)(t.approval)?t.approval:undefined,trade:t.trade,quoteResponse:t,requireApproval:e});return m=a?.id,s}const a=await O(this,j,"f").call(this,f,t.quote.srcChainId,t.approval&&(0,L.isEvmTxData)(t.approval)?t.approval:undefined,t.resetApproval,e);m=a?.id,await(0,Q.handleMobileHardwareWalletDelay)(e);const n=(0,Q.generateActionId)().toString();O(this,g,"f").call(this,{accountAddress:o.address,statusRequest:{...(0,Q.getStatusRequestParams)(t),srcTxHash:""},quoteResponse:t,slippagePercentage:0,isStxEnabled:s,startTime:u,approvalTxId:m,location:r},n);const i=await O(this,A,"f").call(this,{transactionType:f?H.TransactionType.bridge:H.TransactionType.swap,trade:t.trade,requireApproval:e,txFee:t.quote.gasIncluded?t.quote.feeData.txFee:undefined,actionId:n});return O(this,k,"f").call(this,n,i),i})}try{!(0,L.isNonEvmChainId)(t.quote.srcChainId)&&!s&&!t.quote.gasIncluded7702||O(this,g,"f").call(this,{accountAddress:o.address,bridgeTxMeta:d,statusRequest:{...(0,Q.getStatusRequestParams)(t),srcTxHash:d.hash},quoteResponse:t,slippagePercentage:0,isStxEnabled:s,startTime:u,approvalTxId:m,location:r}),(0,L.isNonEvmChainId)(t.quote.srcChainId)&&(O(this,b,"f").call(this,d.id),f||p||O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Completed,d.id))}catch{}return d},this.submitIntent=async e=>{const{quoteResponse:t,signature:s,accountAddress:n,location:r}=e;this.messenger.call("BridgeController:stopPollingForQuotes",L.AbortReason.TransactionSubmitted);const d=O(this,a,"m",y).call(this,n),m=Boolean(d)&&(0,L.isHardwareWallet)(d),u=(0,Y.getPreConfirmationPropertiesFromQuote)(t,!1,m,r);try{const e=(0,Q.getIntentFromQuote)(t);let a;if(t.approval){const e=(0,L.isCrossChain)(t.quote.srcChainId,t.quote.destChainId),s=await O(this,j,"f").call(this,e,t.quote.srcChainId,t.approval&&(0,L.isEvmTxData)(t.approval)?t.approval:undefined,t.resetApproval,!1);a=s?.id,a&&await O(this,C,"f").call(this,a)}const{srcChainId:d,requestId:m}=t.quote,u={srcChainId:d.toString(),quoteId:m,signature:s,order:e.order,userAddress:n,aggregatorId:e.protocol},h=new z.IntentApiImpl(O(this,c,"f").customBridgeApiBaseUrl,O(this,o,"f")),f=await h.submitIntent(u,O(this,i,"f"),await O(this,_,"f").call(this)),p=f.id,k=(0,L.isCrossChain)(t.quote.srcChainId,t.quote.destChainId),w=k?H.TransactionType.bridge:H.TransactionType.swap,y=this.messenger.call("NetworkController:findNetworkClientIdByChainId",(0,L.formatChainIdToHex)(d)),T={chainId:(0,L.formatChainIdToHex)(d),from:n,to:e.settlementContract??"0x9008D19f58AAbd9eD0D60971565AA8510560ab41",data:`0x${p.slice(-8)}`,value:"0x0",gas:"0x5208",gasPrice:"0x3b9aca00"},{transactionMeta:x}=await O(this,l,"f").call(this,T,{origin:"metamask",actionId:(0,Q.generateActionId)(),requireApproval:!1,isStateOnly:!0,networkClientId:y,type:w}),v=x,E=(0,z.mapIntentOrderStatusToTransactionStatus)(f.status),I={...{...v,status:E},isIntentTx:!0,orderUid:p,intentType:k?"bridge":"swap"};try{const e=p,s={...I,id:e,originalTransactionId:I.id},i=Date.now();O(this,g,"f").call(this,{accountAddress:n,bridgeTxMeta:s,statusRequest:{...(0,Q.getStatusRequestParams)(t),srcTxHash:I.hash??""},quoteResponse:t,slippagePercentage:0,isStxEnabled:!1,approvalTxId:a,startTime:i,location:r}),O(this,b,"f").call(this,e)}catch(e){console.error("📝 [submitIntent] Failed to add to bridge history",e)}return I}catch(e){throw O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Failed,undefined,{error_message:e?.message,...u}),e}},D.set(this,(e,t,s)=>{const a={action_type:L.MetricsActionType.SWAPBRIDGE_V1,location:s?.location??(t?this.state.txHistory?.[t]?.location:undefined)??L.MetaMetricsSwapsEventSource.MainView,...s??{}};if(!t)return void this.messenger.call("BridgeController:trackUnifiedSwapBridgeEvent",e,a);const n=this.state.txHistory[t];if(!n)return void this.messenger.call("BridgeController:trackUnifiedSwapBridgeEvent",e,a);const r=(0,Y.getRequestParamFromHistory)(n);if(e===L.UnifiedSwapBridgeEventName.StatusValidationFailed)return void this.messenger.call("BridgeController:trackUnifiedSwapBridgeEvent",e,{...a,chain_id_source:r.chain_id_source,chain_id_destination:r.chain_id_destination,token_address_source:r.token_address_source,token_address_destination:r.token_address_destination,refresh_count:n.attempts?.counter??0});if(n.featureId)return;const i=this.messenger.call("AccountsController:getAccountByAddress",n.account),{transactions:o}=this.messenger.call("TransactionController:getState"),c=o?.find(e=>e.id===t),l=o?.find(e=>e.id===n.approvalTxId),d={...a,...r,...(0,Y.getRequestMetadataFromHistory)(n,i),...(0,Y.getTradeDataFromHistory)(n),...(0,Y.getTxStatusesFromHistory)(n),...(0,Y.getFinalizedTxProperties)(n,c,l),...(0,Y.getPriceImpactFromQuote)(n.quote)};this.messenger.call("BridgeController:trackUnifiedSwapBridgeEvent",e,d)}),N(this,i,s,"f"),N(this,o,R,"f"),N(this,l,X,"f"),N(this,d,Z,"f"),N(this,m,ee,"f"),N(this,u,te,"f"),N(this,c,{customBridgeApiBaseUrl:se?.customBridgeApiBaseUrl??W.BRIDGE_PROD_API_BASE_URL},"f"),N(this,h,ae??((e,t)=>t?.()),"f"),N(this,r,new q.IntentStatusManager({messenger:this.messenger,updateTransactionFn:O(this,m,"f")}),"f"),this.messenger.registerActionHandler(`${W.BRIDGE_STATUS_CONTROLLER_NAME}:startPollingForBridgeTxStatus`,this.startPollingForBridgeTxStatus.bind(this)),this.messenger.registerActionHandler(`${W.BRIDGE_STATUS_CONTROLLER_NAME}:wipeBridgeStatus`,this.wipeBridgeStatus.bind(this)),this.messenger.registerActionHandler(`${W.BRIDGE_STATUS_CONTROLLER_NAME}:resetState`,this.resetState.bind(this)),this.messenger.registerActionHandler(`${W.BRIDGE_STATUS_CONTROLLER_NAME}:submitTx`,this.submitTx.bind(this)),this.messenger.registerActionHandler(`${W.BRIDGE_STATUS_CONTROLLER_NAME}:submitIntent`,this.submitIntent.bind(this)),this.messenger.registerActionHandler(`${W.BRIDGE_STATUS_CONTROLLER_NAME}:restartPollingForFailedAttempts`,this.restartPollingForFailedAttempts.bind(this)),this.messenger.registerActionHandler(`${W.BRIDGE_STATUS_CONTROLLER_NAME}:getBridgeHistoryItemByTxMetaId`,this.getBridgeHistoryItemByTxMetaId.bind(this)),this.setIntervalLength(W.REFRESH_INTERVAL_MS),this.messenger.subscribe("TransactionController:transactionFailed",({transactionMeta:e})=>{const{type:t,status:s,id:a,actionId:n}=e;if(t&&[H.TransactionType.bridge,H.TransactionType.swap,H.TransactionType.bridgeApproval,H.TransactionType.swapApproval].includes(t)&&[H.TransactionStatus.failed,H.TransactionStatus.dropped,H.TransactionStatus.rejected].includes(s)&&(O(this,f,"f").call(this,e),s!==H.TransactionStatus.rejected)){let t;this.state.txHistory[a]?t=a:n&&this.state.txHistory[n]&&(t=n),O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Failed,t??a,(0,Y.getEVMTxPropertiesFromTransactionMeta)(e))}}),this.messenger.subscribe("TransactionController:transactionConfirmed",e=>{const{type:t,id:s,chainId:a}=e;t===H.TransactionType.swap&&O(this,D,"f").call(this,L.UnifiedSwapBridgeEventName.Completed,s),t!==H.TransactionType.bridge||(0,L.isNonEvmChainId)(a)||O(this,b,"f").call(this,s)}),O(this,p,"f").call(this)}}s.BridgeStatusController=X,n=new WeakMap,r=new WeakMap,i=new WeakMap,o=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,T=new WeakMap,x=new WeakMap,_=new WeakMap,v=new WeakMap,E=new WeakMap,I=new WeakMap,P=new WeakMap,S=new WeakMap,C=new WeakMap,j=new WeakMap,A=new WeakMap,F=new WeakMap,G=new WeakMap,M=new WeakMap,D=new WeakMap,a=new WeakSet,y=function(e){return this.messenger.call("AccountsController:getAccountByAddress",e)}}}},{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",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/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=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.IntentStatusManager=void 0;const o=e("@metamask/bridge-controller");s.IntentStatusManager=class{constructor({messenger:e,updateTransactionFn:t}){a.set(this,void 0),n.set(this,void 0),this.syncTransactionFromIntentStatus=(e,t,s,r)=>{const c=t.originalTransactionId??t.txMetaId;if(c)try{const{transactions:t}=i(this,a,"f").call("TransactionController:getState"),l=t.find(e=>e.id===c);if(!l)return void console.warn("📝 [Intent polling] Skipping update; transaction not found",{originalTxId:c,bridgeHistoryKey:e});const{txHash:d}=s,m=s.status.status===o.StatusTypes.COMPLETE,u=l.txReceipt,h=d?{txReceipt:{...u,transactionHash:d,status:m?"0x1":"0x0"}}:{},f={...l,status:s.transactionStatus,...d?{hash:d}:{},...h};i(this,n,"f").call(this,f,`BridgeStatusController - Intent order status updated: ${r}`)}catch(t){console.error("📝 [Intent polling] Failed to update transaction status",{originalTxId:c,bridgeHistoryKey:e,error:t})}},r(this,a,e,"f"),r(this,n,t,"f")}},a=new WeakMap,n=new WeakMap}}},{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","./utils/transaction.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.getTxMetaFields=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}});var i=e("./utils/transaction.cjs");Object.defineProperty(s,"getTxMetaFields",{enumerable:!0,get:function(){return i.getTxMetaFields}})}}},{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/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-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.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"),i=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,i,o,c)=>{const l=(0,s.getStatusRequestDto)(e),d=new URLSearchParams(l),m=`${(0,s.getBridgeStatusUrl)(c)}?${d.toString()}`,u=await o(m,{headers:(0,a.getClientHeaders)({clientId:t,jwt:i})}),h=[];try{(0,r.validateBridgeStatusResponse)(u)}catch(t){t instanceof n.StructError&&t.failures().forEach(({branch:t,path:s})=>{const a=t?.[0]?.quote?.bridgeId??t?.[0]?.quote?.bridges?.[0]??u?.bridge??(e.bridge||e.bridgeId)??"unknown",n=s?.join(".")||"unknown";h.push([a,n].join("|"))})}return{status:u,validationFailures:h}};s.getStatusRequestWithSrcTxHash=(e,t)=>{const{bridgeId:s,bridges:a,srcChainId:n,destChainId:r,refuel:i}=e;return{bridgeId:s,srcTxHash:t,bridge:a[0],srcChainId:n,destChainId:r,quote:e,refuel:Boolean(i)}};s.shouldSkipFetchDueToFetchFailures=e=>{if(e){const t=i.REFRESH_INTERVAL_MS*Math.pow(2,e.counter-1);if(Date.now()-e.lastAttemptTime<t)return!0}return!1}}}},{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/gas.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/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","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=s.calculateGasFees=s.getTxGasEstimates=void 0;const a=e("@metamask/bridge-controller"),n=e("@metamask/controller-utils"),r=e("bignumber.js");s.getTxGasEstimates=({txGasFeeEstimates:e,networkGasFeeEstimates:t})=>{const{estimatedBaseFee:s="0"}=t;return((e,t)=>{const{maxFeePerGas:s,maxPriorityFeePerGas:n}=e?.[a.BRIDGE_PREFERRED_GAS_ESTIMATE]??{};return{baseAndPriorityFeePerGas:n?new r.BigNumber(t,10).times(10**9).plus(n,16):undefined,maxFeePerGas:s,maxPriorityFeePerGas:n}})(e,s)};s.calculateGasFees=async(e,t,a,{chainId:r,gasLimit:i,...o},c,l,d)=>{if(!e)return{};if(d)return{...d,gas:i?.toString()};const m={...o,gas:i?.toString(),data:o.data,to:o.to,value:o.value},{gasFeeEstimates:u}=t.call("GasFeeController:getState"),{estimates:h}=await a({transactionParams:m,chainId:l,networkClientId:c}),{maxFeePerGas:f,maxPriorityFeePerGas:p}=(0,s.getTxGasEstimates)({networkGasFeeEstimates:u,txGasFeeEstimates:h});return{maxFeePerGas:f,maxPriorityFeePerGas:p,gas:(0,n.toHex)(m.gas??0)}};const i=(e,t)=>e&&t?new r.BigNumber(e,16).times(new r.BigNumber(t,16)):null;s.calcActualGasUsed=({pricingData:e},t,s)=>{const a=e?.quotedGasInUsd&&e?.quotedGasAmount?new r.BigNumber(e?.quotedGasInUsd).div(e.quotedGasAmount):null,n=i(t?.gasUsed,t?.effectiveGasPrice)?.plus(i(s?.gasUsed,s?.effectiveGasPrice)??0),o=n?.div(new r.BigNumber(10).pow(18)).toString(10);return n&&o?{amount:n.toString(10),usd:a?.multipliedBy(o).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/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-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=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.mapIntentOrderStatusToTransactionStatus=s.translateIntentOrderToBridgeStatus=s.IntentApiImpl=void 0;const o=e("@metamask/bridge-controller"),c=e("@metamask/transaction-controller"),l=e("./validators.cjs");s.IntentApiImpl=class{constructor(e,t){a.set(this,void 0),n.set(this,void 0),r(this,a,e,"f"),r(this,n,t,"f")}async submitIntent(e,t,s){const r=`${i(this,a,"f")}/submitOrder`;try{const a=await i(this,n,"f").call(this,r,{method:"POST",headers:{"Content-Type":"application/json",...(0,o.getClientHeaders)({clientId:t,jwt:s})},body:JSON.stringify(e)});if(!(0,l.validateIntentOrderResponse)(a))throw new Error("Invalid submitOrder response");return a}catch(e){if(e instanceof Error)throw new Error(`Failed to submit intent: ${e.message}`);throw new Error("Failed to submit intent")}}async getOrderStatus(e,t,s,r,c){const d=`${i(this,a,"f")}/getOrderStatus?orderId=${e}&aggregatorId=${encodeURIComponent(t)}&srcChainId=${s}`;try{const e=await i(this,n,"f").call(this,d,{method:"GET",headers:(0,o.getClientHeaders)({clientId:r,jwt:c})});if(!(0,l.validateIntentOrderResponse)(e))throw new Error("Invalid getOrderStatus response");return e}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;function d(e){switch(e){case l.IntentOrderStatus.PENDING:case l.IntentOrderStatus.SUBMITTED:return c.TransactionStatus.submitted;case l.IntentOrderStatus.CONFIRMED:case l.IntentOrderStatus.COMPLETED:return c.TransactionStatus.confirmed;case l.IntentOrderStatus.FAILED:case l.IntentOrderStatus.EXPIRED:case l.IntentOrderStatus.CANCELLED:return c.TransactionStatus.failed;default:return c.TransactionStatus.submitted}}s.translateIntentOrderToBridgeStatus=(e,t,s)=>{let a;switch(e.status){case l.IntentOrderStatus.CONFIRMED:case l.IntentOrderStatus.COMPLETED:a=o.StatusTypes.COMPLETE;break;case l.IntentOrderStatus.FAILED:case l.IntentOrderStatus.EXPIRED:case l.IntentOrderStatus.CANCELLED:a=o.StatusTypes.FAILED;break;case l.IntentOrderStatus.PENDING:a=o.StatusTypes.PENDING;break;case l.IntentOrderStatus.SUBMITTED:a=o.StatusTypes.SUBMITTED;break;default:a=o.StatusTypes.UNKNOWN}return{status:{status:a,srcChain:{chainId:t,txHash:e.txHash??s??""}},txHash:e.txHash,transactionStatus:d(e.status)}},s.mapIntentOrderStatusToTransactionStatus=d}}},{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/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-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"),i=e("./gas.cjs"),o=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,i=e.destChain?.txHash?e.status:a.StatusTypes.PENDING,o=(0,a.formatChainIdToHex)(n.srcChainId),c=(0,a.isEthUsdt)(o,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:i}};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,i.calcActualGasUsed)(e,t?.txReceipt,s?.txReceipt),d=t?.type===n.TransactionType.swap?(0,o.getActualSwapReceivedAmount)(e,l,t):(0,o.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)=>{const{quote:i}=e;return{...(0,s.getPriceImpactFromQuote)(i),...(0,s.getTradeDataFromQuote)(e),chain_id_source:(0,a.formatChainIdToCaip)(i.srcChainId),token_symbol_source:i.srcAsset.symbol,chain_id_destination:(0,a.formatChainIdToCaip)(i.destChainId),token_symbol_destination:i.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}};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/snaps.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.createClientTransactionRequest=void 0;const a=e("uuid");s.createClientTransactionRequest=(e,t,s,n,r)=>({snapId:e,origin:"metamask",handler:"onClientRequest",request:{id:(0,a.v4)(),jsonrpc:"2.0",method:"signAndSendTransaction",params:{transaction:t,scope:s,accountId:n,...r&&{options:r}}}})}}},{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-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,i=e.quote.destTokenAmount;if(!s?.txReceipt)return null;const o=(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,i=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 i?.data?new n.BigNumber(i.data,16).div(new n.BigNumber(10).pow(r.destAsset.decimals)):null})(e,s),c=r?.quotedReturnInUsd&&i?new n.BigNumber(r.quotedReturnInUsd).div(i).multipliedBy(10**e.quote.destAsset.decimals):null;return{amount:o,usd:o&&c?c.multipliedBy(o):null}};s.getActualBridgeReceivedAmount=e=>{const{quote:t,pricingData:s,status:a}=e,r=s?.quotedReturnInUsd?new n.BigNumber(s.quotedReturnInUsd).div(t.destTokenAmount):null,i=a.destChain?.amount;return i&&r?{amount:i,usd:r.multipliedBy(i).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/transaction.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/gas.cjs","./snaps.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-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",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.getIntentFromQuote=s.getHistoryKey=s.findAndUpdateTransactionsInBatch=s.getAddTransactionBatchParams=s.toBatchTxParams=s.rekeyHistoryItemInState=s.waitForTxConfirmation=s.getClientRequest=s.handleMobileHardwareWalletDelay=s.handleApprovalDelay=s.handleNonEvmTxResponse=s.getTxMetaFields=s.getStatusRequestParams=s.generateActionId=void 0;const a=e("@metamask/bridge-controller"),n=e("@metamask/controller-utils"),r=e("@metamask/transaction-controller"),i=e("@metamask/utils"),o=e("uuid"),c=e("./gas.cjs"),l=e("./snaps.cjs"),d=e("../constants.cjs");s.generateActionId=()=>(Date.now()+Math.random()).toString();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)});s.getTxMetaFields=(e,t)=>{let s;try{s=(0,a.formatChainIdToHex)(e.quote.destChainId)}catch{s="0x1"}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,n)=>{const i=n.address,c=n.metadata.snap?.id;let l;"string"==typeof e?l=e:e&&"object"==typeof e&&("transactionId"in e&&e.transactionId?l=e.transactionId:"result"in e&&e.result&&"object"==typeof e.result?l=e.result.signature||e.result.txid||e.result.hash||e.result.txHash:"signature"in e&&e.signature&&"string"==typeof e.signature&&(l=e.signature));const d=(0,a.isCrossChain)(t.quote.srcChainId,t.quote.destChainId);let m;try{m=(0,a.formatChainIdToHex)(t.quote.srcChainId)}catch{m="0x1"}const u=(0,a.extractTradeData)(t.trade);return{...(0,s.getTxMetaFields)(t),time:Date.now(),id:l??(0,o.v4)(),chainId:m,networkClientId:c??m,txParams:{from:i,data:u},type:d?r.TransactionType.bridge:r.TransactionType.swap,status:r.TransactionStatus.submitted,hash:l,origin:c,isSolana:!0,isBridgeTx:d}};s.handleApprovalDelay=async e=>{if([a.ChainId.LINEA,a.ChainId.BASE].includes(e)){(0,i.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.getClientRequest=(e,t,s)=>{const n=(0,a.formatChainIdToCaip)(t),r=(0,a.extractTradeData)(e),i=(0,a.isTronTrade)(e)?{visible:e.visible,type:e.raw_data?.contract?.[0]?.type}:undefined;return(0,l.createClientTransactionRequest)(s.metadata.snap?.id,r,n,s.id,i)};s.waitForTxConfirmation=async(e,t,{timeoutMs:s=3e5,pollMs:a=3e3}={})=>{const n=Date.now();for(;;){const{transactions:i}=e.call("TransactionController:getState"),o=i.find(e=>e.id===t);if(o){if(o.status===r.TransactionStatus.confirmed)return o;if(o.status===r.TransactionStatus.failed||o.status===r.TransactionStatus.dropped||o.status===r.TransactionStatus.rejected)throw new Error("Approval transaction did not confirm")}if(Date.now()-n>s)throw new Error("Timed out waiting for approval confirmation");await new Promise(e=>setTimeout(e,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.toBatchTxParams=(e,{chainId:t,gasLimit:s,...a},{maxFeePerGas:r,maxPriorityFeePerGas:i,gas:o})=>{const c={...a,data:a.data,to:a.to,value:a.value};return e?{...c,gas:(0,n.toHex)(o??0),maxFeePerGas:(0,n.toHex)(r??0),maxPriorityFeePerGas:(0,n.toHex)(i??0)}:c};s.getAddTransactionBatchParams=async({messenger:e,isBridgeTx:t,approval:n,resetApproval:i,trade:o,quoteResponse:{quote:{feeData:{txFee:l},gasIncluded:d,gasIncluded7702:m,gasSponsored:u},sentAmount:h,toTokenAmount:f},requireApproval:p=!1,estimateGasFeeFn:g})=>{const k=d||m;if(!e.call("AccountsController:getAccountByAddress",o.from))throw new Error("Failed to submit cross-chain swap batch transaction: unknown account in trade data");const b=(0,a.formatChainIdToHex)(o.chainId),w=e.call("NetworkController:findNetworkClientIdByChainId",b),y=!0!==m,T=[];if(i){const a=await(0,c.calculateGasFees)(y,e,g,i,w,b,k?l:undefined);T.push({type:t?r.TransactionType.bridgeApproval:r.TransactionType.swapApproval,params:(0,s.toBatchTxParams)(y,i,a)})}if(n){const a=await(0,c.calculateGasFees)(y,e,g,n,w,b,k?l:undefined);T.push({type:t?r.TransactionType.bridgeApproval:r.TransactionType.swapApproval,params:(0,s.toBatchTxParams)(y,n,a)})}const x=await(0,c.calculateGasFees)(y,e,g,o,w,b,k?l:undefined);T.push({type:t?r.TransactionType.bridge:r.TransactionType.swap,params:(0,s.toBatchTxParams)(y,o,x),assetsFiatValues:{sending:h?.valueInCurrency?.toString(),receiving:f?.valueInCurrency?.toString()}});return{disable7702:y,isGasFeeIncluded:Boolean(m),isGasFeeSponsored:Boolean(u),networkClientId:w,requireApproval:p,origin:"metamask",from:o.from,transactions:T}};s.findAndUpdateTransactionsInBatch=({messenger:e,updateTransactionFn:t,batchId:s,txDataByType:a})=>{const n=e.call("TransactionController:getState").transactions,i={approvalMeta:undefined,tradeMeta:undefined};return Object.entries(a).forEach(([e,a])=>{const o=n.find(t=>{if(t.batchId!==s)return!1;if(Array.isArray(t.txParams.authorizationList)&&t.txParams.authorizationList.length>0||Boolean(t.delegationAddress)){if(e===r.TransactionType.swap&&t.type===r.TransactionType.batch)return!0;if(e===r.TransactionType.swapApproval&&t.txParams.data===a)return!0}return t.txParams.data===a});if(o){const s={...o,type:e};t(s,`Update tx type to ${e}`),i[[r.TransactionType.bridgeApproval,r.TransactionType.swapApproval].includes(e)?"approvalMeta":"tradeMeta"]=s}}),i},s.getHistoryKey=function(e,t){const s=e??t;if(!s)throw new Error("Cannot add tx to history: either actionId or bridgeTxMeta.id must be provided");return s},s.getIntentFromQuote=function(e){const{intent:t}=e.quote;if(!t)throw new Error("submitIntent: missing intent data");return t}}}},{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-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.validateIntentOrderResponse=s.IntentOrderResponseSchema=s.IntentOrderStatus=s.validateBridgeStatusResponse=s.StatusResponseSchema=void 0;const a=e("@metamask/bridge-controller"),n=e("@metamask/superstruct"),r=(0,n.number)(),i=(0,n.type)({}),o=(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)([i,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)([i,a.BridgeAssetSchema]))}),l=(0,n.type)({});s.StatusResponseSchema=(0,n.type)({status:(0,n.enums)(Object.values(a.StatusTypes)),srcChain:o,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={})),s.IntentOrderResponseSchema=(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.validateIntentOrderResponse=e=>(0,n.is)(e,s.IntentOrderResponseSchema)}}},{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/gas-fee-controller/dist/GasFeeController.cjs",{"./determineGasFeeCalculations.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/determineGasFeeCalculations.cjs","./gas-util.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/gas-util.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/polling-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/polling-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){var a,n,r,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},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)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.GasFeeController=s.GAS_ESTIMATE_TYPES=s.LEGACY_GAS_PRICES_API_URL=void 0;const l=e("@metamask/controller-utils"),d=c(e("@metamask/eth-query")),m=e("@metamask/polling-controller"),u=e("uuid"),h=c(e("./determineGasFeeCalculations.cjs")),f=e("./gas-util.cjs");s.LEGACY_GAS_PRICES_API_URL="https://api.metaswap.codefi.network/gasPrices",s.GAS_ESTIMATE_TYPES={FEE_MARKET:"fee-market",LEGACY:"legacy",ETH_GASPRICE:"eth_gasPrice",NONE:"none"};const p={gasFeeEstimatesByChainId:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},gasFeeEstimates:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},estimatedGasFeeTimeBounds:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},gasEstimateType:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},nonRPCGasFeeApisDisabled:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!1}},g={gasFeeEstimatesByChainId:{},gasFeeEstimates:{},estimatedGasFeeTimeBounds:{},gasEstimateType:s.GAS_ESTIMATE_TYPES.NONE,nonRPCGasFeeApisDisabled:!1};class k extends((0,m.StaticIntervalPollingController)()){constructor({interval:e=15e3,messenger:t,state:c,getCurrentNetworkEIP1559Compatibility:l,getCurrentAccountEIP1559Compatibility:m,getChainId:u,getCurrentNetworkLegacyGasAPICompatibility:h,getProvider:f,onNetworkDidChange:k,legacyAPIEndpoint:b=s.LEGACY_GAS_PRICES_API_URL,EIP1559APIEndpoint:w,clientId:y}){if(super({name:"GasFeeController",metadata:p,messenger:t,state:{...g,...c}}),a.add(this),n.set(this,void 0),this.intervalDelay=e,this.setIntervalLength(e),this.pollTokens=new Set,this.getCurrentNetworkEIP1559Compatibility=l,this.getCurrentNetworkLegacyGasAPICompatibility=h,this.getCurrentAccountEIP1559Compatibility=m,i(this,n,f,"f"),this.EIP1559APIEndpoint=w,this.legacyAPIEndpoint=b,this.clientId=y,this.ethQuery=new d.default(o(this,n,"f").call(this)),k&&u)this.currentChainId=u(),k(async e=>{await o(this,a,"m",r).call(this,e)});else{const{selectedNetworkClientId:e}=this.messenger.call("NetworkController:getState");this.currentChainId=this.messenger.call("NetworkController:getNetworkClientById",e).configuration.chainId,this.messenger.subscribe("NetworkController:networkDidChange",async e=>{await o(this,a,"m",r).call(this,e)})}}async resetPolling(){if(0!==this.pollTokens.size){const e=Array.from(this.pollTokens);this.stopPolling(),await this.getGasFeeEstimatesAndStartPolling(e[0]),e.slice(1).forEach(e=>{this.pollTokens.add(e)})}}async fetchGasFeeEstimates(e){return await this._fetchGasFeeEstimateData(e)}async getGasFeeEstimatesAndStartPolling(e){const t=e||(0,u.v1)();return this.pollTokens.add(t),1===this.pollTokens.size&&(await this._fetchGasFeeEstimateData(),this._poll()),t}async _fetchGasFeeEstimateData(e={}){const{shouldUpdateState:t=!0,networkClientId:s}=e;let a,n,r,i;if(s!==undefined){const e=this.messenger.call("NetworkController:getNetworkClientById",s);r="0x38"===e.configuration.chainId,i=(0,l.convertHexToDecimal)(e.configuration.chainId);try{n=await this.messenger.call("NetworkController:getEIP1559Compatibility",s)||!1}catch{n=!1}a=new d.default(e.provider)}a??(a=this.ethQuery),r??(r=this.getCurrentNetworkLegacyGasAPICompatibility()),i??(i=(0,l.convertHexToDecimal)(this.currentChainId));try{n??(n=await this.getEIP1559Compatibility())}catch(e){console.error(e),n??(n=!1)}const o=await(0,h.default)({isEIP1559Compatible:n,isLegacyGasAPICompatible:r,fetchGasEstimates:f.fetchGasEstimates,fetchGasEstimatesUrl:this.EIP1559APIEndpoint.replace("<chain_id>",`${i}`),fetchLegacyGasPriceEstimates:f.fetchLegacyGasPriceEstimates,fetchLegacyGasPriceEstimatesUrl:this.legacyAPIEndpoint.replace("<chain_id>",`${i}`),fetchEthGasPriceEstimate:f.fetchEthGasPriceEstimate,calculateTimeEstimate:f.calculateTimeEstimate,clientId:this.clientId,ethQuery:a,nonRPCGasFeeApisDisabled:this.state.nonRPCGasFeeApisDisabled});if(t){const e=(0,l.toHex)(i);this.update(t=>{this.currentChainId===e&&(t.gasFeeEstimates=o.gasFeeEstimates,t.estimatedGasFeeTimeBounds=o.estimatedGasFeeTimeBounds,t.gasEstimateType=o.gasEstimateType),t.gasFeeEstimatesByChainId??(t.gasFeeEstimatesByChainId={}),t.gasFeeEstimatesByChainId[e]={gasFeeEstimates:o.gasFeeEstimates,estimatedGasFeeTimeBounds:o.estimatedGasFeeTimeBounds,gasEstimateType:o.gasEstimateType}})}return o}disconnectPoller(e){this.pollTokens.delete(e),0===this.pollTokens.size&&this.stopPolling()}stopPolling(){this.intervalId&&clearInterval(this.intervalId),this.pollTokens.clear(),this.resetState()}destroy(){super.destroy(),this.stopPolling()}_poll(){this.intervalId&&clearInterval(this.intervalId),this.intervalId=setInterval(async()=>{await(0,l.safelyExecute)(()=>this._fetchGasFeeEstimateData())},this.intervalDelay)}async _executePoll({networkClientId:e}){await this._fetchGasFeeEstimateData({networkClientId:e})}resetState(){this.update(()=>g)}async getEIP1559Compatibility(){const e=await this.getCurrentNetworkEIP1559Compatibility(),t=this.getCurrentAccountEIP1559Compatibility?.()??!0;return e&&t}getTimeEstimate(e,t){return this.state.gasFeeEstimates&&this.state.gasEstimateType===s.GAS_ESTIMATE_TYPES.FEE_MARKET?(0,f.calculateTimeEstimate)(e,t,this.state.gasFeeEstimates):{}}enableNonRPCGasFeeApis(){this.update(e=>{e.nonRPCGasFeeApisDisabled=!1})}disableNonRPCGasFeeApis(){this.update(e=>{e.nonRPCGasFeeApisDisabled=!0})}}s.GasFeeController=k,n=new WeakMap,a=new WeakSet,r=async function({selectedNetworkClientId:e}){const t=this.messenger.call("NetworkController:getNetworkClientById",e).configuration.chainId;t!==this.currentChainId&&(this.ethQuery=new d.default(o(this,n,"f").call(this)),await this.resetPolling(),this.currentChainId=t)},s.default=k}}},{package:"@metamask/bridge-status-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/GasFeeController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/determineGasFeeCalculations.cjs",{"./GasFeeController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/GasFeeController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0});const a=e("./GasFeeController.cjs");s.default=async function(e){try{return await async function(e){const{isEIP1559Compatible:t,isLegacyGasAPICompatible:s,nonRPCGasFeeApisDisabled:n}=e;try{if(t&&!n)return await async function(e){const{fetchGasEstimates:t,fetchGasEstimatesUrl:s,clientId:n,calculateTimeEstimate:r}=e,i=await t(s,n),{suggestedMaxPriorityFeePerGas:o,suggestedMaxFeePerGas:c}=i.medium,l=r(o,c,i);return{gasFeeEstimates:i,estimatedGasFeeTimeBounds:l,gasEstimateType:a.GAS_ESTIMATE_TYPES.FEE_MARKET}}(e);if(s&&!n)return await async function(e){const{fetchLegacyGasPriceEstimates:t,fetchLegacyGasPriceEstimatesUrl:s,clientId:n}=e;return{gasFeeEstimates:await t(s,n),estimatedGasFeeTimeBounds:{},gasEstimateType:a.GAS_ESTIMATE_TYPES.LEGACY}}(e);throw new Error("Main gas fee/price estimation failed. Use fallback")}catch{return await async function(e){const{ethQuery:t,fetchEthGasPriceEstimate:s}=e;return{gasFeeEstimates:await s(t),estimatedGasFeeTimeBounds:{},gasEstimateType:a.GAS_ESTIMATE_TYPES.ETH_GASPRICE}}(e)}}(e)}catch(e){if(e instanceof Error)throw new Error(`Gas fee/price estimation failed. Message: ${e.message}`);throw e}}}}},{package:"@metamask/bridge-status-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/determineGasFeeCalculations.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/gas-util.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"},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.calculateTimeEstimate=s.fetchEthGasPriceEstimate=s.fetchLegacyGasPriceEstimates=s.fetchGasEstimates=s.normalizeGWEIDecimalNumbers=void 0;const n=e("@metamask/controller-utils"),r=a(e("bn.js")),i=e=>({"X-Client-Id":e});function o(e){const t=(0,n.gweiDecToWEIBN)(e).toString(16);return(0,n.weiHexToGweiDec)(t)}s.normalizeGWEIDecimalNumbers=o,s.fetchGasEstimates=async function(e,t){const s=await(0,n.handleFetch)(e,t?{headers:i(t)}:undefined);return{low:{...s.low,suggestedMaxPriorityFeePerGas:o(s.low.suggestedMaxPriorityFeePerGas),suggestedMaxFeePerGas:o(s.low.suggestedMaxFeePerGas)},medium:{...s.medium,suggestedMaxPriorityFeePerGas:o(s.medium.suggestedMaxPriorityFeePerGas),suggestedMaxFeePerGas:o(s.medium.suggestedMaxFeePerGas)},high:{...s.high,suggestedMaxPriorityFeePerGas:o(s.high.suggestedMaxPriorityFeePerGas),suggestedMaxFeePerGas:o(s.high.suggestedMaxFeePerGas)},estimatedBaseFee:o(s.estimatedBaseFee),historicalBaseFeeRange:s.historicalBaseFeeRange,baseFeeTrend:s.baseFeeTrend,latestPriorityFeeRange:s.latestPriorityFeeRange,historicalPriorityFeeRange:s.historicalPriorityFeeRange,priorityFeeTrend:s.priorityFeeTrend,networkCongestion:s.networkCongestion}},s.fetchLegacyGasPriceEstimates=async function(e,t){const s=await(0,n.handleFetch)(e,{referrer:e,referrerPolicy:"no-referrer-when-downgrade",method:"GET",mode:"cors",headers:{"Content-Type":"application/json",...t&&i(t)}});return{low:s.SafeGasPrice,medium:s.ProposeGasPrice,high:s.FastGasPrice}},s.fetchEthGasPriceEstimate=async function(e){const t=await(0,n.query)(e,"gasPrice");return{gasPrice:(0,n.weiHexToGweiDec)(t).toString()}},s.calculateTimeEstimate=function(e,t,s){const{low:a,medium:i,high:o,estimatedBaseFee:c}=s,l=(0,n.gweiDecToWEIBN)(e),d=(0,n.gweiDecToWEIBN)(t),m=(0,n.gweiDecToWEIBN)(c),u=r.default.min(l,d.sub(m)),h=(0,n.gweiDecToWEIBN)(a.suggestedMaxPriorityFeePerGas),f=(0,n.gweiDecToWEIBN)(i.suggestedMaxPriorityFeePerGas),p=(0,n.gweiDecToWEIBN)(o.suggestedMaxPriorityFeePerGas);let g,k;return u.lt(h)?(g=null,k="unknown"):u.gte(h)&&u.lt(f)?(g=a.minWaitTimeEstimate,k=a.maxWaitTimeEstimate):u.gte(f)&&u.lt(p)?(g=i.minWaitTimeEstimate,k=i.maxWaitTimeEstimate):u.eq(p)?(g=o.minWaitTimeEstimate,k=o.maxWaitTimeEstimate):(g=0,k=o.maxWaitTimeEstimate),{lowerTimeBound:g,upperTimeBound:k}}}}},{package:"@metamask/bridge-status-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/gas-util.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/index.cjs",{"./GasFeeController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/GasFeeController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__createBinding||(Object.create?function(e,t,s,a){a===undefined&&(a=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,n)}:function(e,t,s,a){a===undefined&&(a=s),e[a]=t[s]}),n=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||a(t,e,s)};Object.defineProperty(s,"__esModule",{value:!0}),n(e("./GasFeeController.cjs"),s)}}},{package:"@metamask/bridge-status-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/bridge-status-controller/node_modules/@metamask/gas-fee-controller/dist/index.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,i,o,c,l,d,m,u,h,f,p,g,k,b,w,y,T,x,_,v,E,I,P,S,C,j,A,F,G,M,D,N,O,L,B,R,H,U,q,W,$,K,V,z,Y,Q,J,X,Z,ee,te,se,ae,ne,re,ie,oe,ce,le,de,me,ue,he,fe,pe,ge,ke,be,we,ye,Te,xe,_e,ve,Ee,Ie,Pe,Se,Ce,je,Ae,Fe,Ge,Me,De,Ne,Oe,Le,Be,Re,He,Ue,qe,We,$e,Ke,Ve,ze,Ye,Qe,Je,Xe,Ze,et,tt=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},st=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)},at=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 nt=e("@metamask/base-controller"),rt=e("@metamask/controller-utils"),it=at(e("@metamask/eth-query")),ot=e("@metamask/network-controller"),ct=e("@metamask/nonce-tracker"),lt=e("@metamask/rpc-errors"),dt=e("@metamask/utils"),mt=e("events"),ut=e("lodash"),ht=e("uuid"),ft=e("./gas-flows/DefaultGasFeeFlow.cjs"),pt=e("./gas-flows/LineaGasFeeFlow.cjs"),gt=e("./gas-flows/OptimismLayer1GasFeeFlow.cjs"),kt=e("./gas-flows/RandomisedEstimationsGasFeeFlow.cjs"),bt=e("./gas-flows/ScrollLayer1GasFeeFlow.cjs"),wt=e("./gas-flows/TestGasFeeFlow.cjs"),yt=e("./helpers/AccountsApiRemoteTransactionSource.cjs"),Tt=e("./helpers/GasFeePoller.cjs"),xt=e("./helpers/IncomingTransactionHelper.cjs"),_t=e("./helpers/MethodDataHelper.cjs"),vt=e("./helpers/MultichainTrackingHelper.cjs"),Et=e("./helpers/PendingTransactionTracker.cjs"),It=e("./helpers/ResimulateHelper.cjs"),Pt=e("./hooks/ExtraTransactionsPublishHook.cjs"),St=e("./logger.cjs"),Ct=e("./types.cjs"),jt=e("./utils/balance-changes.cjs"),At=e("./utils/batch.cjs"),Ft=e("./utils/eip7702.cjs"),Gt=e("./utils/external-transactions.cjs"),Mt=e("./utils/feature-flags.cjs"),Dt=e("./utils/first-time-interaction.cjs"),Nt=e("./utils/gas.cjs"),Ot=e("./utils/gas-fee-tokens.cjs"),Lt=e("./utils/gas-fees.cjs"),Bt=e("./utils/gas-flow.cjs"),Rt=e("./utils/layer1-gas-fee-flow.cjs"),Ht=e("./utils/nonce.cjs"),Ut=e("./utils/prepare.cjs"),qt=e("./utils/retry.cjs"),Wt=e("./utils/swaps.cjs"),$t=e("./utils/transaction-type.cjs"),Kt=e("./utils/utils.cjs"),Vt=e("./utils/validation.cjs"),zt={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 Yt="TransactionController";var Qt;!function(e){e.Approved="approved",e.NotApproved="not-approved",e.SkippedViaBeforePublishHook="skipped-via-before-publish-hook"}(Qt||(s.ApprovalState=Qt={}));class Jt extends nt.BaseController{constructor(e){const{disableSwaps:t,getCurrentAccountEIP1559Compatibility:s,getCurrentNetworkEIP1559Compatibility:q,getExternalPendingTransactions:W,getGasFeeEstimates:$,getNetworkClientRegistry:K,getNetworkState:z,getPermittedAccounts:Y,getSavedGasFees:Q,getSimulationConfig:J,hooks:X,incomingTransactions:ee={},isAutomaticGasFeeUpdateEnabled:te,isEIP7702GasFeeTokensEnabled:se,isFirstTimeInteractionEnabled:ae,isSimulationEnabled:ne,messenger:re,pendingTransactions:ie={},publicKeyEIP7702:oe,securityProviderRequest:ce,sign:le,state:me,testGasFeeFlows:ue,trace:he}=e;super({name:Yt,metadata:zt,messenger:re,state:{methodData:{},transactions:[],transactionBatches:[],lastFetchedBlockNumbers:{},submitHistory:[],...me}}),a.add(this),n.set(this,void 0),r.set(this,void 0),i.set(this,void 0),o.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),y.set(this,void 0),T.set(this,void 0),x.set(this,void 0),_.set(this,new mt.EventEmitter),v.set(this,void 0),E.set(this,void 0),I.set(this,void 0),P.set(this,void 0),S.set(this,void 0),C.set(this,void 0),j.set(this,void 0),A.set(this,void 0),F.set(this,void 0),G.set(this,void 0),M.set(this,void 0),D.set(this,void 0),N.set(this,void 0),O.set(this,void 0),L.set(this,void 0),B.set(this,new Map),R.set(this,new Set),H.set(this,void 0),U.set(this,void 0),Pe.set(this,()=>{st(this,F,"f").checkForPendingTransactionAndStartPolling()}),this.messenger=re,tt(this,n,X?.afterAdd??(()=>Promise.resolve({})),"f"),tt(this,r,X?.afterSign??(()=>!0),"f"),tt(this,i,X?.afterSimulate??(()=>Promise.resolve({})),"f"),tt(this,c,X?.beforeCheckPendingTransaction??(()=>Promise.resolve(!0)),"f"),tt(this,l,X?.beforePublish??(()=>Promise.resolve(!0)),"f"),tt(this,d,X?.beforeSign??(()=>Promise.resolve({})),"f"),tt(this,u,X?.getAdditionalSignArguments??(()=>[]),"f"),tt(this,h,s??(()=>Promise.resolve(!0)),"f"),tt(this,f,q,"f"),tt(this,p,W??(()=>[]),"f"),tt(this,g,$??(()=>Promise.resolve({})),"f"),tt(this,k,z,"f"),tt(this,b,Y,"f"),tt(this,w,Q??(e=>undefined),"f"),tt(this,y,J??(()=>Promise.resolve({})),"f"),tt(this,x,ee,"f"),tt(this,v,te??(e=>!1),"f"),tt(this,E,se??(()=>Promise.resolve(!1)),"f"),tt(this,I,ae??(()=>!0),"f"),tt(this,P,ne??(()=>!0),"f"),tt(this,S,t??!1,"f"),tt(this,C,X?.isTimeoutEnabled??(()=>!0),"f"),tt(this,G,ie,"f"),tt(this,M,oe,"f"),tt(this,D,X?.publish??(()=>Promise.resolve({transactionHash:undefined})),"f"),tt(this,N,X?.publishBatch,"f"),tt(this,O,ce,"f"),tt(this,L,le,"f"),tt(this,H,!0===ue,"f"),tt(this,U,he??((e,t)=>t?.()),"f");const fe=e=>this.messenger.call("NetworkController:findNetworkClientIdByChainId",e);tt(this,F,new vt.MultichainTrackingHelper({findNetworkClientIdByChainId:fe,getNetworkClientById:e=>this.messenger.call("NetworkController:getNetworkClientById",e),getNetworkClientRegistry:K,removePendingTransactionTrackerListeners:st(this,a,"m",je).bind(this),createNonceTracker:st(this,a,"m",Ee).bind(this),createPendingTransactionTracker:st(this,a,"m",Ie).bind(this),onNetworkStateChange:e=>{this.messenger.subscribe("NetworkController:stateChange",e)}}),"f"),st(this,F,"f").initialize(),tt(this,m,st(this,a,"m",De).call(this),"f"),tt(this,j,st(this,a,"m",Ne).call(this),"f");const pe=new Tt.GasFeePoller({findNetworkClientIdByChainId:fe,gasFeeFlows:st(this,m,"f"),getGasFeeControllerEstimates:st(this,g,"f"),getProvider:e=>st(this,a,"m",de).call(this,{networkClientId:e}),getTransactions:()=>this.state.transactions,getTransactionBatches:()=>this.state.transactionBatches,layer1GasFeeFlows:st(this,j,"f"),messenger:this.messenger,onStateChange:e=>{this.messenger.subscribe("TransactionController:stateChange",e)}});pe.hub.on("transaction-updated",st(this,a,"m",Be).bind(this)),pe.hub.on("transaction-batch-updated",st(this,a,"m",Re).bind(this)),tt(this,A,new _t.MethodDataHelper({getProvider:e=>st(this,a,"m",de).call(this,{networkClientId:e}),getState:()=>this.state.methodData}),"f"),st(this,A,"f").hub.on("update",({fourBytePrefix:e,methodData:t})=>{this.update(s=>{s.methodData[e]=t})}),tt(this,T,new xt.IncomingTransactionHelper({client:st(this,x,"f").client,getCurrentAccount:()=>st(this,a,"m",Ue).call(this),getLocalTransactions:()=>this.state.transactions,includeTokenTransfers:st(this,x,"f").includeTokenTransfers,isEnabled:st(this,x,"f").isEnabled,messenger:this.messenger,remoteTransactionSource:new yt.AccountsApiRemoteTransactionSource,trimTransactions:st(this,a,"m",Z).bind(this),updateTransactions:st(this,x,"f").updateTransactions}),"f"),st(this,a,"m",Ce).call(this,st(this,T,"f")),this.messenger.subscribe("TransactionController:stateChange",st(this,Pe,"f")),new It.ResimulateHelper({simulateTransaction:st(this,a,"m",Le).bind(this),onTransactionsUpdate:e=>{this.messenger.subscribe("TransactionController:stateChange",e,e=>e.transactions)},getTransactions:()=>this.state.transactions}),st(this,a,"m",V).call(this),st(this,Pe,"f").call(this),st(this,a,"m",Ke).call(this)}destroy(){st(this,a,"m",Se).call(this)}async handleMethodData(e,t){return st(this,A,"f").lookup(e,t)}async addTransactionBatch(e){const{blockTracker:t}=this.messenger.call("NetworkController:getNetworkClientById",e.networkClientId);return await(0,At.addTransactionBatch)({addTransaction:this.addTransaction.bind(this),estimateGas:this.estimateGas.bind(this),getChainId:st(this,a,"m",oe).bind(this),getEthQuery:e=>st(this,a,"m",le).call(this,{networkClientId:e}),getGasFeeEstimates:st(this,g,"f"),getInternalAccounts:st(this,a,"m",qe).bind(this),getSimulationConfig:st(this,y,"f").bind(this),getPendingTransactionTracker:e=>st(this,a,"m",Ie).call(this,{provider:st(this,a,"m",de).call(this,{networkClientId:e}),blockTracker:t,chainId:st(this,a,"m",oe).call(this,e),networkClientId:e}),getTransaction:e=>st(this,a,"m",ne).call(this,e),isSimulationEnabled:st(this,P,"f"),messenger:this.messenger,publishBatchHook:st(this,N,"f"),publicKeyEIP7702:st(this,M,"f"),publishTransaction:(e,t)=>st(this,a,"m",J).call(this,e,t),request:e,signTransaction:st(this,a,"m",ye).bind(this),update:this.update.bind(this),updateTransaction:st(this,a,"m",Oe).bind(this)})}async isAtomicBatchSupported(e){return(0,At.isAtomicBatchSupported)({...e,getEthQuery:e=>st(this,a,"m",le).call(this,{chainId:e}),messenger:this.messenger,publicKeyEIP7702:st(this,M,"f")})}async addTransaction(e,t){(0,St.projectLogger)("Adding transaction",e,t);const{actionId:s,assetsFiatValues:r,batchId:i,deviceConfirmedOn:o,disableGasBuffer:c,gasFeeToken:l,isGasFeeIncluded:d,isGasFeeSponsored:m,isStateOnly:u,method:h,nestedTransactions:f,networkClientId:p,origin:g,publishHook:k,requestId:w,requiredAssets:y,requireApproval:T,securityAlertResponse:x,skipInitialGasEstimate:_,swaps:v={},traceContext:E,type:P}=t;if(e=(0,Kt.normalizeTransactionParams)(e),!st(this,F,"f").has(p))throw new Error(`Network client not found - ${p}`);const C=st(this,a,"m",oe).call(this,p),j=st(this,a,"m",le).call(this,{networkClientId:p}),A=g===undefined?undefined:await(st(this,b,"f")?.call(this,g)),G=st(this,a,"m",qe).call(this);await(0,Vt.validateTransactionOrigin)({data:e.data,from:e.from,internalAccounts:G,origin:g,permittedAddresses:A,txParams:e,type:P});const M=(0,Ft.getDelegationAddress)(e.from,j).catch(()=>undefined),D=await st(this,a,"m",we).call(this,p);(0,Vt.validateTxParams)(e,D,C),e.type||(0,Kt.setEnvelopeType)(e,D);if(i?.length&&this.state.transactions.some(e=>e.batchId?.toLowerCase()===i?.toLowerCase())&&g&&g!==rt.ORIGIN_METAMASK)throw new lt.JsonRpcError(Vt.ErrorCode.DuplicateBundleId,"Batch ID already exists");const N=st(this,a,"m",ue).call(this,e,g),L=P??(await(0,$t.determineTransactionType)(e,j)).type,B=st(this,a,"m",ge).call(this,s);let R=B?(0,ut.cloneDeep)(B):{actionId:s,assetsFiatValues:r,batchId:i,chainId:C,dappSuggestedGasFees:N,deviceConfirmedOn:o,disableGasBuffer:c,id:(0,ht.v1)(),isGasFeeTokenIgnoredIfBalance:Boolean(l),isGasFeeIncluded:d,isGasFeeSponsored:m,isFirstTimeInteraction:undefined,isStateOnly:u,nestedTransactions:f,networkClientId:p,origin:g,requestId:w,requiredAssets:y,securityAlertResponse:x,selectedGasFeeToken:l,status:Ct.TransactionStatus.unapproved,time:Date.now(),txParams:e,type:L,userEditedGasLimit:!1,verifiedOnBlockchain:!1};const{updateTransaction:H}=await st(this,n,"f").call(this,{transactionMeta:R});if(H&&((0,St.projectLogger)("Updating transaction using afterAdd hook"),R.txParamsOriginal=(0,ut.cloneDeep)(R.txParams),H(R)),_){const e=(0,ut.cloneDeep)(R);st(this,a,"m",K).call(this,e).then(()=>(st(this,a,"m",Oe).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(ut.noop)}else await st(this,U,"f").call(this,{name:"Estimate Gas Properties",parentContext:E},e=>st(this,a,"m",K).call(this,R,{traceContext:e}));if(!B){if(h&&st(this,O,"f")){const e=await st(this,O,"f").call(this,R,h);R.securityProviderResponse=e}R=(0,Wt.updateSwapsTransaction)(R,L,v,{isSwapsDisabled:st(this,S,"f"),cancelTransaction:st(this,a,"m",X).bind(this),messenger:this.messenger}),st(this,a,"m",$).call(this,R),M.then(e=>(st(this,a,"m",Oe).call(this,{transactionId:R.id,skipResimulateCheck:!0,skipValidation:!0},t=>{t.delegationAddress=e}),undefined)).catch(ut.noop),!1===T||u?(0,St.projectLogger)("Skipping simulation & first interaction update as approval not required"):(st(this,a,"m",Le).call(this,R,{traceContext:E}).catch(e=>{throw(0,St.projectLogger)("Error while updating simulation data",e),e}),(0,Dt.updateFirstTimeInteraction)({existingTransactions:this.state.transactions,getTransaction:e=>st(this,a,"m",ae).call(this,e),isFirstTimeInteractionEnabled:st(this,I,"f"),trace:st(this,U,"f"),traceContext:E,transactionMeta:R,updateTransaction:st(this,a,"m",Oe).bind(this)}).catch(e=>{(0,St.projectLogger)("Error while updating first interaction properties",e)})),this.messenger.publish(`${Yt}:unapprovedTransactionAdded`,R)}return{result:st(this,a,"m",Y).call(this,R,{actionId:s,isExisting:Boolean(B),publishHook:k,requireApproval:T,traceContext:E}),transactionMeta:R}}startIncomingTransactionPolling(){st(this,T,"f").start()}stopIncomingTransactionPolling(){st(this,T,"f").stop()}async updateIncomingTransactions({tags:e}={}){await st(this,T,"f").update({tags:e})}async stopTransaction(e,t,{estimatedBaseFee:n,actionId:r}={}){await st(this,a,"m",q).call(this,{actionId:r,estimatedBaseFee:n,gasValues:t,label:"cancel",rate:s.CANCEL_RATE,transactionId:e,transactionType:Ct.TransactionType.cancel,prepareTransactionParams:e=>{delete e.data,e.to=e.from,e.value="0x0"},afterSubmit:e=>{this.messenger.publish(`${Yt}:transactionFinished`,e),st(this,_,"f").emit(`${e.id}:finished`,e)}})}async speedUpTransaction(e,t,{actionId:n,estimatedBaseFee:r}={}){await st(this,a,"m",q).call(this,{actionId:n,estimatedBaseFee:r,gasValues:t,label:"speed up",rate:s.SPEED_UP_RATE,transactionId:e,transactionType:Ct.TransactionType.retry,afterSubmit:e=>{this.messenger.publish(`${Yt}:speedupTransactionAdded`,e)}})}async estimateGas(e,t,{ignoreDelegationSignatures:s}={}){const n=st(this,a,"m",le).call(this,{networkClientId:t}),{estimatedGas:r,simulationFails:i}=await(0,Nt.estimateGas)({chainId:st(this,a,"m",oe).call(this,t),ethQuery:n,ignoreDelegationSignatures:s,isSimulationEnabled:st(this,P,"f").call(this),getSimulationConfig:st(this,y,"f"),messenger:this.messenger,txParams:e});return{gas:r,simulationFails:i}}async estimateGasBatch({chainId:e,from:t,transactions:s}){const n=st(this,a,"m",le).call(this,{chainId:e});return(0,Nt.estimateGasBatch)({chainId:e,ethQuery:n,from:t,getSimulationConfig:st(this,y,"f"),isAtomicBatchSupported:this.isAtomicBatchSupported.bind(this),messenger:this.messenger,transactions:s})}async estimateGasBuffered(e,t,s){const n=st(this,a,"m",le).call(this,{networkClientId:s}),{blockGasLimit:r,estimatedGas:i,simulationFails:o}=await(0,Nt.estimateGas)({chainId:st(this,a,"m",oe).call(this,s),ethQuery:n,isSimulationEnabled:st(this,P,"f").call(this),getSimulationConfig:st(this,y,"f"),messenger:this.messenger,txParams:e});return{gas:(0,Nt.addGasBuffer)(i,r,t),simulationFails:o}}updateTransaction(e,t){const{id:s}=e;st(this,a,"m",Oe).call(this,{transactionId:s},()=>({...e})),(0,St.projectLogger)("Transaction updated",{transactionId:s,note:t})}updateSecurityAlertResponse(e,t){if(!t)throw new Error("updateSecurityAlertResponse: securityAlertResponse should not be null");const s=st(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,`${Yt}: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===Ct.TransactionType.incoming&&a.to?.toLowerCase()===e.toLowerCase())});this.update(e=>{e.transactions=st(this,a,"m",Z).call(this,s)})}updateTransactionSendFlowHistory(e,t,s){return st(this,a,"m",ne).call(this,e)}async confirmExternalTransaction(e,t,s){const n=st(this,a,"m",he).call(this,e);try{const e=n.id,r={...n,status:Ct.TransactionStatus.confirmed,txReceipt:t};s&&(r.baseFeePerGas=s),st(this,a,"m",fe).call(this,e),this.updateTransaction(r,`${Yt}:confirmExternalTransaction - Add external transaction`),st(this,a,"m",Te).call(this,r),st(this,a,"m",ve).call(this,r).catch(e=>{throw(0,St.projectLogger)("Error while updating post balance",e),e}),this.messenger.publish(`${Yt}:transactionConfirmed`,r)}catch(e){console.error("Failed to confirm external transaction",e)}}updateTransactionGasFees(e,{defaultGasEstimates:t,estimateUsed:s,estimateSuggested:n,gas:r,gasLimit:i,gasPrice:o,maxPriorityFeePerGas:c,maxFeePerGas:l,originalGasEstimate:d,userEditedGasLimit:m,userFeeLevel:u}){const h=st(this,a,"m",ae).call(this,e);if(!h)throw new Error("Cannot update transaction as no transaction metadata found");(0,Kt.validateIfTransactionUnapproved)(h,"updateTransactionGasFees");const f=(0,ut.cloneDeep)(h),p=h.gasFeeEstimates,g=st(this,v,"f").call(this,h),k=u,b=Object.values(Ct.GasFeeEstimateLevel).includes(k),w=p&&g&&b;w&&(0,Tt.updateTransactionGasEstimates)({txMeta:f,userFeeLevel:k});const y={gas:r,gasLimit:i};w?Object.assign(y,{gasPrice:f.txParams.gasPrice,maxPriorityFeePerGas:f.txParams.maxPriorityFeePerGas,maxFeePerGas:f.txParams.maxFeePerGas}):Object.assign(y,{gasPrice:o,maxPriorityFeePerGas:c,maxFeePerGas:l});const T={txParams:(0,ut.pickBy)(y),defaultGasEstimates:t,estimateUsed:s,estimateSuggested:n,originalGasEstimate:d,userEditedGasLimit:m,userFeeLevel:k},x=(0,ut.pickBy)(T);return st(this,a,"m",Oe).call(this,{transactionId:e,skipResimulateCheck:!0},e=>{const{txParams:t,...s}=x;Object.assign(e,s),t&&Object.assign(e.txParams,t)}),st(this,a,"m",ae).call(this,e)}updatePreviousGasParams(e,{gasLimit:t,maxFeePerGas:s,maxPriorityFeePerGas:n}){const r=st(this,a,"m",ae).call(this,e);if(!r)throw new Error("Cannot update transaction as no transaction metadata found");(0,Kt.validateIfTransactionUnapproved)(r,"updatePreviousGasParams");const i={previousGas:{gasLimit:t,maxFeePerGas:s,maxPriorityFeePerGas:n}};i.previousGas=(0,ut.pickBy)(i.previousGas);const o=(0,ut.merge)({},r,i);return this.updateTransaction(o,`${Yt}:updatePreviousGasParams - Previous gas values updated`),st(this,a,"m",ae).call(this,e)}async getNonceLock(e,t){return st(this,F,"f").getNonceLock(e,t)}async updateEditableParams(e,{containerTypes:t,data:s,from:n,gas:r,gasPrice:i,maxFeePerGas:o,maxPriorityFeePerGas:c,to:l,updateType:d,value:m}){const u=st(this,a,"m",ae).call(this,e);if(!u)throw new Error("Cannot update editable params as no transaction metadata found");(0,Kt.validateIfTransactionUnapproved)(u,"updateEditableParams");const h={txParams:{data:s,from:n,to:l,value:m,gas:r,gasPrice:i,maxFeePerGas:o,maxPriorityFeePerGas:c}};h.txParams=(0,ut.pickBy)(h.txParams);const f=(0,ut.merge)({},u,h),{networkClientId:p}=u,g=st(this,a,"m",de).call(this,{networkClientId:p}),k=new it.default(g);if(!1!==d){const{type:e}=await(0,$t.determineTransactionType)(f.txParams,k);f.type=e}return t&&(f.containerTypes=t),await(0,Rt.updateTransactionLayer1GasFee)({layer1GasFeeFlows:st(this,j,"f"),messenger:this.messenger,provider:g,transactionMeta:f}),this.updateTransaction(f,`Update Editable Params for ${e}`),st(this,a,"m",ae).call(this,e)}setTransactionActive(e,t){if(!st(this,a,"m",ae).call(this,e))throw new Error(`Transaction with id ${e} not found`);st(this,a,"m",Oe).call(this,{transactionId:e,skipValidation:!0,skipResimulateCheck:!0},e=>{e.isActive=t})}async approveTransactionsWithSameNonce(e=[],{hasNonce:t}={}){if((0,St.projectLogger)("Approving transactions with same nonce",{transactions:e}),0===e.length)return"";const s=e[0],{chainId:n}=s,r=st(this,a,"m",ce).call(this,{chainId:n}),i=(0,Ut.prepareTransaction)(n,s),c=(0,Ut.serializeTransaction)(i);if(st(this,o,"f").has(c))return"";let l,d;st(this,o,"f").add(c);try{const n=s.from;d=!0!==t?await this.getNonceLock(n,r):undefined;const i=d?(0,dt.add0x)(d.nextNonce.toString(16)):s.nonce;d&&(0,St.projectLogger)("Using nonce from nonce tracker",i,d.nonceDetails),l=await Promise.all(e.map(e=>(e.nonce=i,st(this,a,"m",W).call(this,e.chainId,e))))}catch(e){throw(0,St.projectLogger)("Error while signing transactions with same nonce",e),e}finally{d?.releaseLock(),st(this,o,"f").delete(c)}return l}updateCustodialTransaction(e){const{transactionId:t,errorMessage:s,hash:n,status:r,gasLimit:i,gasPrice:o,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:d,type:m}=e,u=st(this,a,"m",ae).call(this,t);if(!u)throw new Error("Cannot update custodial transaction as no transaction metadata found");if(r&&![Ct.TransactionStatus.submitted,Ct.TransactionStatus.signed,Ct.TransactionStatus.failed].includes(r))throw new Error(`Cannot update custodial transaction with status: ${r}`);const h=(0,ut.merge)({},u,(0,ut.pickBy)({hash:n,status:r}));return h.status===Ct.TransactionStatus.submitted&&(h.submittedTime=(new Date).getTime()),h.status===Ct.TransactionStatus.failed&&(h.error=(0,Kt.normalizeTxError)(new Error(s))),h.txParams=(0,ut.merge)({},h.txParams,(0,ut.pickBy)({gasLimit:i,gasPrice:o,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:d,type:m})),m===Ct.TransactionEnvelopeType.legacy&&(delete h.txParams.maxFeePerGas,delete h.txParams.maxPriorityFeePerGas),this.updateTransaction(h,`${Yt}:updateCustodialTransaction - Custodial transaction updated`),r&&[Ct.TransactionStatus.submitted,Ct.TransactionStatus.failed].includes(r)&&(this.messenger.publish(`${Yt}:transactionFinished`,h),st(this,_,"f").emit(`${h.id}:finished`,h)),h}getTransactions({initialList:e,limit:t,searchCriteria:s={}}={}){const a=(0,ut.mapValues)(s,e=>"function"==typeof e?e:t=>t===e),n=e??this.state.transactions,r=(0,ut.sortBy)((0,ut.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:i}=n.txParams;if(!e.has(i)){if(!(e.size<t))continue;e.add(i)}s.unshift(n)}return s}return r}async estimateGasFee({transactionParams:e,chainId:t,networkClientId:s}){const{id:a,provider:n}=st(this,F,"f").getNetworkClient({chainId:t,networkClientId:s}),r={txParams:e,chainId:t,networkClientId:a},i=(0,Bt.getGasFeeFlow)(r,st(this,m,"f"),this.messenger),o=new it.default(n),c=await st(this,g,"f").call(this,{networkClientId:a});return i.getGasFees({ethQuery:o,gasFeeControllerData:c,messenger:this.messenger,transactionMeta:r})}async getLayer1GasFee({transactionParams:e,chainId:t,networkClientId:s}){const n=st(this,a,"m",de).call(this,{chainId:t,networkClientId:s});return await(0,Rt.getTransactionLayer1GasFee)({layer1GasFeeFlows:st(this,j,"f"),messenger:this.messenger,provider:n,transactionMeta:{txParams:e,chainId:t}})}clearUnapprovedTransactions(){const e=this.state.transactions.filter(({status:e})=>e!==Ct.TransactionStatus.unapproved);this.update(t=>{t.transactions=st(this,a,"m",Z).call(this,e)})}abortTransactionSigning(e){if(!st(this,a,"m",ae).call(this,e))throw new Error("Cannot abort signing as no transaction metadata found");const t=st(this,B,"f").get(e);if(!t)throw new Error("Cannot abort signing as transaction is not waiting for signing");t(),st(this,B,"f").delete(e)}async updateAtomicBatchData({transactionId:e,transactionIndex:t,transactionData:s}){(0,St.projectLogger)("Updating atomic batch data",{transactionId:e,transactionIndex:t,transactionData:s});const n=st(this,a,"m",Oe).call(this,{transactionId:e},e=>{const{nestedTransactions:a,txParams:n}=e,r=n.from,i=a?.[t];if(!i)throw new Error(`Nested transaction not found with index - ${t}`);i.data=s;const o=(0,Ft.generateEIP7702BatchTransaction)(r,a);e.txParams.data=o.data}),r=(0,ut.cloneDeep)({...n,txParams:{...n.txParams,gas:undefined}});return await st(this,a,"m",$e).call(this,r),st(this,a,"m",Oe).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,St.projectLogger)("Updating batch transactions",{transactionId:e,batchTransactions:t}),st(this,a,"m",Oe).call(this,{transactionId:e},e=>{e.batchTransactions=t})}updateSelectedGasFeeToken(e,t){st(this,a,"m",Oe).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}){st(this,a,"m",Oe).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===Ct.TransactionType.swap?this.messenger.publish("TransactionController:transactionNewSwap",{transactionMeta:t}):t.type===Ct.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})}}s.TransactionController=Jt,n=new WeakMap,r=new WeakMap,i=new WeakMap,o=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,y=new WeakMap,T=new WeakMap,x=new WeakMap,_=new WeakMap,v=new WeakMap,E=new WeakMap,I=new WeakMap,P=new WeakMap,S=new WeakMap,C=new WeakMap,j=new WeakMap,A=new WeakMap,F=new WeakMap,G=new WeakMap,M=new WeakMap,D=new WeakMap,N=new WeakMap,O=new WeakMap,L=new WeakMap,B=new WeakMap,R=new WeakMap,H=new WeakMap,U=new WeakMap,Pe=new WeakMap,a=new WeakSet,q=async function({actionId:e,afterSubmit:t,estimatedBaseFee:s,gasValues:n,label:r,prepareTransactionParams:i,rate:o,transactionId:c,transactionType:l}){if(st(this,a,"m",ge).call(this,e))return;n&&(n=(0,Kt.normalizeGasFeeValues)(n),(0,Kt.validateGasValues)(n)),(0,St.projectLogger)(`Creating ${r} transaction`,c,n);const d=st(this,a,"m",ae).call(this,c);if(!d)return;if(!st(this,L,"f"))throw new Error("No sign method defined.");const m=(0,qt.getTransactionParamsWithIncreasedGasFee)(d.txParams,o,n);i?.(m);const u=(0,Ut.prepareTransaction)(d.chainId,m),h=await st(this,L,"f").call(this,u,d.txParams.from),f=st(this,a,"m",be).call(this,d,h),p=(0,Ut.serializeTransaction)(h),g=m.maxFeePerGas??m.gasPrice,k=m.maxFeePerGas?f.txParams.maxFeePerGas:f.txParams.gasPrice;(0,St.projectLogger)(`Submitting ${r} transaction`,{oldFee:k,newFee:g,txParams:m});const{networkClientId:b}=d,w=st(this,a,"m",le).call(this,{networkClientId:b}),y={...f,actionId:e,estimatedBaseFee:s,id:(0,ht.v1)(),originalGasEstimate:d.txParams.gas,originalType:d.type,rawTx:p,time:Date.now(),txParams:m,type:l},T=await st(this,a,"m",Ge).call(this,w,{...y,origin:r});y.hash=T,st(this,a,"m",$).call(this,y),this.messenger.publish(`${Yt}:transactionApproved`,{transactionMeta:y,actionId:e}),this.messenger.publish(`${Yt}:transactionSubmitted`,{transactionMeta:y,actionId:e}),t?.(y)},W=async function(e,t){if(!st(this,L,"f"))throw new Error("No sign method defined.");const s=(0,Kt.normalizeTransactionParams)(t),a=(0,Kt.isEIP1559Transaction)(s)?Ct.TransactionEnvelopeType.feeMarket:Ct.TransactionEnvelopeType.legacy,n={...s,type:a,gasLimit:s.gas,chainId:e},{from:r}=n,i=(0,Ut.prepareTransaction)(e,n),o=await st(this,L,"f").call(this,i,r);return(0,Ut.serializeTransaction)(o)},$=function(e){(0,Vt.validateTxParams)(e.txParams),this.update(t=>{t.transactions=st(this,a,"m",Z).call(this,[...t.transactions,e])})},K=async function(e,{traceContext:t}={}){const s=e.txParams.type!==Ct.TransactionEnvelopeType.legacy&&await st(this,a,"m",we).call(this,e.networkClientId),{networkClientId:n}=e,r=st(this,a,"m",le).call(this,{networkClientId:n}),i=st(this,a,"m",de).call(this,{networkClientId:n});await st(this,U,"f").call(this,{name:"Update Gas",parentContext:t},async()=>{await st(this,a,"m",$e).call(this,e)}),await st(this,U,"f").call(this,{name:"Update Gas Fees",parentContext:t},async()=>await(0,Lt.updateGasFees)({eip1559:s,ethQuery:r,gasFeeFlows:st(this,m,"f"),getGasFeeEstimates:st(this,g,"f"),getSavedGasFees:st(this,w,"f").bind(this),messenger:this.messenger,txMeta:e})),await st(this,U,"f").call(this,{name:"Update Layer 1 Gas Fees",parentContext:t},async()=>await(0,Rt.updateTransactionLayer1GasFee)({layer1GasFeeFlows:st(this,j,"f"),messenger:this.messenger,provider:i,transactionMeta:e}))},V=function(){this.clearUnapprovedTransactions(),st(this,a,"m",z).call(this)},z=function(){const e=this.state.transactions.filter(e=>[Ct.TransactionStatus.approved,Ct.TransactionStatus.signed].includes(e.status));for(const t of e){st(this,a,"m",Qe).call(this,t,new Error("Transaction incomplete at startup"));const e=t.requiredTransactionIds??[];for(const t of e){const e=st(this,a,"m",ae).call(this,t);e&&!st(this,a,"m",ee).call(this,e.status)&&st(this,a,"m",Qe).call(this,e,new Error("Parent transaction incomplete at startup"))}}},Y=async function(e,{actionId:t,isExisting:s=!1,publishHook:n,requireApproval:r,shouldShowRequest:i=!0,traceContext:o}){const{id:c,isStateOnly:l}=e;if(l)return st(this,a,"m",Oe).call(this,{transactionId:c,skipValidation:!0},e=>{e.status=Ct.TransactionStatus.submitted,e.submittedTime=(new Date).getTime()}),"";let d;const{meta:m,isCompleted:u}=st(this,a,"m",ie).call(this,c),h=u?Promise.resolve(m):st(this,a,"m",ke).call(this,c);if(m&&!s&&!u)try{if(!1!==r){const t=await st(this,U,"f").call(this,{name:"Await Approval",parentContext:o},t=>st(this,a,"m",se).call(this,e,{shouldShowRequest:i,traceContext:t}));d=t.resultCallbacks;const s=t.value,n=s?.txMeta;n&&((0,St.projectLogger)("Updating transaction with approval data",{customNonce:n.customNonceValue,params:n.txParams}),this.updateTransaction(n,"TransactionController#processApproval - Updated with approval data"))}const{isCompleted:s}=st(this,a,"m",ie).call(this,c);if(!s){const e=await st(this,a,"m",Q).call(this,c,o,n);e===Qt.SkippedViaBeforePublishHook&&d&&d.success();const s=st(this,a,"m",ae).call(this,c);e===Qt.Approved&&this.messenger.publish(`${Yt}:transactionApproved`,{transactionMeta:s,actionId:t})}}catch(e){const s=e,{isCompleted:n}=st(this,a,"m",ie).call(this,c);n||(st(this,a,"m",ze).call(this,s)?st(this,a,"m",Ye).call(this,c,t,s):st(this,a,"m",Qe).call(this,m,s,t))}finally{st(this,R,"f").delete(c)}const f=await h;switch(f?.status){case Ct.TransactionStatus.failed:{const e=f.error;throw d?.error(e),lt.rpcErrors.internal(e.message)}case Ct.TransactionStatus.submitted:return d?.success(),f.hash;default:{const e=lt.rpcErrors.internal(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(f??c)}`);throw d?.error(e),e}}},Q=async function(e,t,s){let n,r,i=st(this,a,"m",ne).call(this,e);(0,St.projectLogger)("Approving transaction",i);try{if(!st(this,L,"f"))return st(this,a,"m",Qe).call(this,i,new Error("No sign method defined.")),Qt.NotApproved;if(!i.chainId)return st(this,a,"m",Qe).call(this,i,new Error("No chainId defined.")),Qt.NotApproved;if(st(this,o,"f").has(e))return(0,St.projectLogger)("Skipping approval as signing in progress",e),Qt.NotApproved;st(this,o,"f").add(e),n=()=>st(this,o,"f").delete(e);const{networkClientId:c}=i,d=st(this,a,"m",le).call(this,{networkClientId:c}),[m,u]=await(0,Ht.getNextNonce)(i,e=>st(this,F,"f").getNonceLock(e,i.networkClientId));r=u,i=st(this,a,"m",Oe).call(this,{transactionId:e},e=>{const{chainId:t,txParams:s}=e,{gas:a,type:n}=s;e.status=Ct.TransactionStatus.approved,e.txParams.chainId=t,e.txParams.gasLimit=a,e.txParams.nonce=m,!n&&(0,Kt.isEIP1559Transaction)(s)&&(e.txParams.type=Ct.TransactionEnvelopeType.feeMarket)}),st(this,a,"m",Te).call(this,i);const h=await st(this,U,"f").call(this,{name:"Sign",parentContext:t},()=>st(this,a,"m",ye).call(this,i));if(i=st(this,a,"m",ne).call(this,e),!await st(this,l,"f").call(this,i))return(0,St.projectLogger)("Skipping publishing transaction based on hook"),this.messenger.publish(`${Yt}:transactionPublishingSkipped`,i),Qt.SkippedViaBeforePublishHook;if(!h&&!i.isExternalSign)return Qt.NotApproved;let f;const p=i.type===Ct.TransactionType.swap;p&&((0,St.projectLogger)("Determining pre-transaction balance"),f=await(0,rt.query)(d,"getBalance",[i.txParams.from])),(0,St.projectLogger)("Publishing transaction",i.txParams),r?.(),r=undefined;let g=st(this,a,"m",Xe).bind(this,{ethQuery:d,publishHookOverride:s,traceContext:t});if(i.batchTransactions?.length){(0,St.projectLogger)("Found batch transactions",i.batchTransactions);g=new Pt.ExtraTransactionsPublishHook({addTransactionBatch:this.addTransactionBatch.bind(this),getTransaction:st(this,a,"m",ne).bind(this),originalPublishHook:g}).getHook()}const{transactionHash:k}=await g(i,h??"0x");return i=st(this,a,"m",Oe).call(this,{transactionId:e},e=>{e.hash=k,e.status=Ct.TransactionStatus.submitted,e.submittedTime=(new Date).getTime(),p&&(e.preTxBalance=f,(0,St.projectLogger)("Updated pre-transaction balance",f))}),this.messenger.publish(`${Yt}:transactionSubmitted`,{transactionMeta:i}),this.messenger.publish(`${Yt}:transactionFinished`,i),st(this,_,"f").emit(`${e}:finished`,i),st(this,a,"m",Te).call(this,i),Qt.Approved}catch(e){return st(this,a,"m",Qe).call(this,i,e),Qt.NotApproved}finally{n?.(),r?.()}},J=async function(e,t,{skipSubmitHistory:s}={}){try{const n=await(0,rt.query)(e,"sendRawTransaction",[t.rawTx]);return!0!==s&&st(this,a,"m",We).call(this,t,n),n}catch(e){const t=e,s=t?.data?.message??t?.message??String(e);throw new Error(s)}},X=function(e,t,s){const n=st(this,a,"m",ae).call(this,e);if(!n)return;st(this,a,"m",Ve).call(this,e);const r={...n,status:Ct.TransactionStatus.rejected,error:(0,Kt.normalizeTxError)(s??lt.providerErrors.userRejectedRequest())};this.messenger.publish(`${Yt}:transactionFinished`,r),st(this,_,"f").emit(`${n.id}:finished`,r),this.messenger.publish(`${Yt}:transactionRejected`,{transactionMeta:r,actionId:t}),st(this,a,"m",Te).call(this,r)},Z=function(e){const t=new Set,s=(0,Mt.getTransactionHistoryLimit)(this.messenger),n=[...e].sort((e,t)=>e.time>t.time?-1:1).filter(e=>{const{chainId:n,status:r,txParams:i,time:o}=e;if(i){const e=`${String(i.nonce)}-${(0,rt.convertHexToDecimal)(n)}-${new Date(o).toDateString()}`;if(t.has(e))return!0;if(t.size<s||!st(this,a,"m",ee).call(this,r))return t.add(e),!0}return!1});return n.reverse(),n},ee=function(e){return e===Ct.TransactionStatus.rejected||e===Ct.TransactionStatus.confirmed||e===Ct.TransactionStatus.failed||e===Ct.TransactionStatus.dropped},te=function(e){return[Ct.TransactionStatus.confirmed,Ct.TransactionStatus.failed,Ct.TransactionStatus.rejected,Ct.TransactionStatus.submitted].includes(e)},se=async function(e,{shouldShowRequest:t,traceContext:s}){const n=st(this,a,"m",re).call(this,e),{origin:r}=e,i=rt.ApprovalType.Transaction,o={txId:e.id};return await st(this,U,"f").call(this,{name:"Notification Display",id:n,parentContext:s}),await this.messenger.call("ApprovalController:addRequest",{id:n,origin:r??rt.ORIGIN_METAMASK,type:i,requestData:o,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=st(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)},ie=function(e){const t=st(this,a,"m",ae).call(this,e);if(!t)return{meta:undefined,isCompleted:!1};return{meta:t,isCompleted:st(this,a,"m",te).call(this,t.status)}},oe=function(e){return st(this,F,"f").getNetworkClient({networkClientId:e}).configuration.chainId},ce=function({chainId:e,networkClientId:t}){return t||st(this,F,"f").getNetworkClient({chainId:e}).id},le=function({chainId:e,networkClientId:t}){return new it.default(st(this,a,"m",de).call(this,{chainId:e,networkClientId:t}))},de=function({chainId:e,networkClientId:t}){return st(this,F,"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=st(this,a,"m",ce).call(this,{chainId:e});t.push({...s,networkClientId:n})}catch(t){(0,St.projectLogger)("Failed to get network client ID for incoming transaction",{chainId:e,error:t})}}this.update(e=>{const{transactions:s}=e;e.transactions=st(this,a,"m",Z).call(this,[...t,...s]),(0,St.projectLogger)("Added incoming transactions to state",t.length,t)}),this.messenger.publish(`${Yt}:incomingTransactionsReceived`,t)},ue=function(e,t){if(!t||t===rt.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 i={};return s!==undefined?i.gasPrice=s:a===undefined&&n===undefined||(i.maxFeePerGas=a,i.maxPriorityFeePerGas=n),r!==undefined&&(i.gas=r),i},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),i=r.filter(e=>e.status===Ct.TransactionStatus.confirmed),o=r.filter(e=>e.status===Ct.TransactionStatus.submitted);return(0,Gt.validateConfirmedExternalTransaction)(e,i,o),this.update(t=>{t.transactions=st(this,a,"m",Z).call(this,[...t.transactions,e])}),e},fe=function(e){const t=st(this,a,"m",ae).call(this,e);if(!t)return;const s=t.txParams?.nonce,n=t.txParams?.from,{chainId:r}=t,i=this.state.transactions.filter(t=>t.id!==e&&t.txParams.from===n&&s&&t.txParams.nonce===s&&t.chainId===r&&t.type!==Ct.TransactionType.incoming&&t.isTransfer===undefined),o=i.map(e=>e.id);if(0!==i.length){this.update(e=>{for(const s of e.transactions)o.includes(s.id)&&(s.replacedBy=t?.hash,s.replacedById=t?.id)});for(const e of this.state.transactions)o.includes(e.id)&&e.status!==Ct.TransactionStatus.failed&&st(this,a,"m",pe).call(this,e)}},pe=function(e){const t={...e,status:Ct.TransactionStatus.dropped};this.messenger.publish(`${Yt}:transactionDropped`,{transactionMeta:t}),this.updateTransaction(t,"TransactionController#setTransactionStatusDropped - Transaction dropped"),st(this,a,"m",Te).call(this,t)},ge=function(e){return this.state.transactions.find(t=>e&&t.actionId===e)},ke=async function(e){return new Promise(t=>{st(this,_,"f").once(`${e}:finished`,e=>{t(e)})})},be=function(e,t){const s=(0,ut.cloneDeep)(e);for(const e of["r","s","v"]){const a=t[e];a!==undefined&&null!==a&&(s[e]=(0,dt.add0x)(a.toString(16)))}return s},we=async function(e){const t=await st(this,f,"f").call(this,e),s=await st(this,h,"f").call(this);return t&&s},ye=async function(e){let t=e;const{id:s}=t;(0,St.projectLogger)("Calling before sign hook",t);const{updateTransaction:n}=await st(this,d,"f").call(this,{transactionMeta:t})??{};n&&(st(this,a,"m",Oe).call(this,{transactionId:s,skipResimulateCheck:!0},n),(0,St.projectLogger)("Updated transaction after before sign hook")),t=st(this,a,"m",ne).call(this,s);const{networkClientId:i}=t,c=st(this,a,"m",le).call(this,{networkClientId:i});await(0,Ot.checkGasFeeTokenBeforePublish)({ethQuery:c,fetchGasFeeTokens:async e=>(await st(this,a,"m",Ze).call(this,e)).gasFeeTokens,transaction:t,updateTransaction:(e,t)=>st(this,a,"m",Oe).call(this,{transactionId:e},t)}),t=st(this,a,"m",ne).call(this,s);const{chainId:l,isExternalSign:m,txParams:h}=t;if(m)return(0,St.projectLogger)("Skipping sign as signed externally"),undefined;const{authorizationList:f,from:p}=h,g=await(0,Ft.signAuthorizationList)({authorizationList:f,messenger:this.messenger,transactionMeta:t});g&&st(this,a,"m",Oe).call(this,{transactionId:s},e=>{e.txParams.authorizationList=g}),t=st(this,a,"m",ne).call(this,s);const k=st(this,a,"m",ne).call(this,s),{txParams:b}=k,w=(0,Ut.prepareTransaction)(l,b);st(this,o,"f").add(s),(0,St.projectLogger)("Signing transaction",b);const y=await new Promise((e,t)=>{st(this,L,"f")?.call(this,w,p,...st(this,u,"f").call(this,k)).then(e,t),st(this,B,"f").set(s,()=>t(new Error("Signing aborted by user")))});if(st(this,B,"f").delete(s),!y)return(0,St.projectLogger)("Skipping signed status as no signed transaction"),undefined;const T=(0,ut.cloneDeep)(k);if(!st(this,r,"f").call(this,T,y))return this.updateTransaction(T,"TransactionController#signTransaction - Update after sign"),(0,St.projectLogger)("Skipping signed status based on hook"),undefined;const x={...st(this,a,"m",be).call(this,T,y),status:Ct.TransactionStatus.signed,txParams:b};this.updateTransaction(x,"TransactionController#approveTransaction - Transaction signed"),st(this,a,"m",Te).call(this,x);const _=(0,Ut.serializeTransaction)(y),v=(0,ut.merge)({},x,{rawTx:_});return this.updateTransaction(v,"TransactionController#approveTransaction - RawTransaction added"),_},Te=function(e){this.messenger.publish(`${Yt}:transactionStatusUpdated`,{transactionMeta:e})},xe=function(e,t,s){return(0,Ht.getAndFormatTransactionsForNonceTracker)(s,t,e,this.state.transactions)},_e=function(e){(0,St.projectLogger)("Processing confirmed transaction",e.id),st(this,a,"m",fe).call(this,e.id),this.messenger.publish(`${Yt}:transactionConfirmed`,e),st(this,a,"m",Te).call(this,e),st(this,a,"m",ve).call(this,e).catch(e=>{throw(0,St.projectLogger)("Error while updating post balance",e),e})},ve=async function(e){try{const{networkClientId:t,type:s}=e;if(s!==Ct.TransactionType.swap)return;const n=st(this,a,"m",le).call(this,{networkClientId:t}),{updatedTransactionMeta:r,approvalTransactionMeta:i}=await(0,Wt.updatePostTransactionBalance)(e,{ethQuery:n,getTransaction:st(this,a,"m",ae).bind(this),updateTransaction:this.updateTransaction.bind(this)});this.messenger.publish(`${Yt}:postTransactionBalanceUpdated`,{transactionMeta:r,approvalTransactionMeta:i})}catch(e){(0,St.projectLogger)("Error while updating post transaction balance",e)}},Ee=function({provider:e,blockTracker:t,chainId:s}){return new ct.NonceTracker({provider:e,blockTracker:t,getPendingTransactions:st(this,a,"m",Fe).bind(this,s),getConfirmedTransactions:st(this,a,"m",xe).bind(this,[Ct.TransactionStatus.confirmed],s)})},Ie=function({provider:e,blockTracker:t,chainId:s,networkClientId:n}){const r=new it.default(e),i=new Et.PendingTransactionTracker({blockTracker:t,getChainId:()=>s,getEthQuery:()=>r,getGlobalLock:()=>st(this,F,"f").acquireNonceLockForChainIdKey({chainId:s}),getNetworkClientId:()=>n,getTransactions:()=>this.state.transactions,hooks:{beforeCheckPendingTransaction:st(this,c,"f").bind(this)},isResubmitEnabled:st(this,G,"f").isResubmitEnabled,isTimeoutEnabled:st(this,C,"f"),messenger:this.messenger,publishTransaction:(e,t)=>st(this,a,"m",J).call(this,e,t,{skipSubmitHistory:!0})});return st(this,a,"m",Ae).call(this,i),i},Se=function(){st(this,F,"f").stopAllTracking()},Ce=function(e){e.hub.on("transactions",st(this,a,"m",me).bind(this))},je=function(e){e.hub.removeAllListeners("transaction-confirmed"),e.hub.removeAllListeners("transaction-dropped"),e.hub.removeAllListeners("transaction-failed"),e.hub.removeAllListeners("transaction-updated")},Ae=function(e){e.hub.on("transaction-confirmed",st(this,a,"m",_e).bind(this)),e.hub.on("transaction-dropped",st(this,a,"m",pe).bind(this)),e.hub.on("transaction-failed",st(this,a,"m",Qe).bind(this)),e.hub.on("transaction-updated",this.updateTransaction.bind(this))},Fe=function(e,t){return[...st(this,a,"m",xe).call(this,[Ct.TransactionStatus.approved,Ct.TransactionStatus.signed,Ct.TransactionStatus.submitted],t,e),...st(this,p,"f").call(this,t,e)]},Ge=async function(e,t){try{return await st(this,a,"m",J).call(this,e,t)}catch(e){if(st(this,a,"m",Me).call(this,e))throw new Error("Previous transaction is already confirmed");throw e}},Me=function(e){return Boolean(e?.message?.includes("nonce too low"))||Boolean(e?.data?.message?.includes("nonce too low"))},De=function(){return st(this,H,"f")?[new wt.TestGasFeeFlow]:[new kt.RandomisedEstimationsGasFeeFlow,new pt.LineaGasFeeFlow,new ft.DefaultGasFeeFlow]},Ne=function(){return[new gt.OptimismLayer1GasFeeFlow,new bt.ScrollLayer1GasFeeFlow]},Oe=function({transactionId:e,skipValidation:t,skipResimulateCheck:s},n){let r;this.update(a=>{const i=a.transactions.findIndex(({id:t})=>t===e);if(-1===i)throw new Error(`Cannot update transaction as ID not found - ${e}`);let o=a.transactions[i];const c=(0,ut.cloneDeep)(o);o=n(o)??o,!0!==t&&(o.txParams=(0,Kt.normalizeTransactionParams)(o.txParams),(0,Vt.validateTxParams)(o.txParams)),!s&&st(this,P,"f").call(this)&&(r=(0,It.shouldResimulate)(c,o)),a.transactions[i]=o});const i=st(this,a,"m",ae).call(this,e);return r?.resimulate&&st(this,a,"m",Le).call(this,i,{blockTime:r.blockTime}).catch(e=>{throw(0,St.projectLogger)("Error during re-simulation",e),e}),i},Le=async function(e,{blockTime:t,traceContext:s}={}){const{chainId:n,id:r,nestedTransactions:i,networkClientId:o,simulationData:c,txParams:l}=e;let d,m={error:{code:Ct.SimulationErrorCode.Disabled,message:"Simulation disabled"},tokenBalanceChanges:[]},u=[],h=!1;const f=st(this,R,"f").has(r);if(st(this,P,"f").call(this)&&!f){const r=await st(this,U,"f").call(this,{name:"Simulate",parentContext:s},()=>(0,jt.getBalanceChanges)({blockTime:t,chainId:n,ethQuery:st(this,a,"m",le).call(this,{networkClientId:o}),getSimulationConfig:(t,s)=>st(this,y,"f").call(this,t,{txMeta:e,...s}),nestedTransactions:i,txParams:l}));m=r.simulationData,d=r.gasUsed,t&&c&&(0,It.hasSimulationDataChanged)(c,m)&&(m={...m,isUpdatedAfterSecurityCheck:!0});const f=await st(this,a,"m",Ze).call(this,e);u=f?.gasFeeTokens??[],h=f?.isGasFeeSponsored??!1}if(!st(this,a,"m",ae).call(this,r))return void(0,St.projectLogger)("Cannot update simulation data as transaction not found",r,m);const p=st(this,a,"m",Oe).call(this,{transactionId:r,skipResimulateCheck:Boolean(t)},e=>{e.gasFeeTokens=u,e.isGasFeeSponsored=h,e.gasUsed=d,f||(e.simulationData=m)});(0,St.projectLogger)("Updated simulation data",r,p),await st(this,a,"m",Je).call(this,p)},Be=function({transactionId:e,gasFeeEstimates:t,gasFeeEstimatesLoaded:s,layer1GasFee:n}){st(this,a,"m",Oe).call(this,{transactionId:e},e=>{(0,Tt.updateTransactionGasProperties)({txMeta:e,gasFeeEstimates:t,gasFeeEstimatesLoaded:s,isTxParamsGasFeeUpdatesEnabled:st(this,v,"f"),layer1GasFee:n})})},Re=function({transactionBatchId:e,gasFeeEstimates:t}){st(this,a,"m",He).call(this,e,e=>({...e,gasFeeEstimates:t}))},He=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})},Ue=function(){return this.messenger.call("AccountsController:getSelectedAccount")},qe=function(){const e=this.messenger.call("AccountsController:getState");return Object.values(e.internalAccounts?.accounts??{}).filter(e=>"eip155:eoa"===e.type).map(e=>e.address)},We=function(e,t){const{chainId:s,networkClientId:a,origin:n,rawTx:r,txParams:i}=e,{networkConfigurationsByChainId:o}=st(this,k,"f").call(this),c=o[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:i};(0,St.projectLogger)("Updating submit history",m);const u=(0,Mt.getSubmitHistoryLimit)(this.messenger);this.update(e=>{const{submitHistory:t}=e;t.length>=u&&t.pop(),t.unshift(m)})},$e=async function(e){const{chainId:t,networkClientId:s}=e,n=st(this,F,"f").getNetworkClient({networkClientId:s}).configuration.type===ot.NetworkClientType.Custom,r=st(this,a,"m",le).call(this,{networkClientId:s});await(0,Nt.updateGas)({chainId:t,ethQuery:r,isCustomNetwork:n,isSimulationEnabled:st(this,P,"f").call(this),getSimulationConfig:st(this,y,"f"),messenger:this.messenger,txMeta:e})},Ke=function(){this.messenger.registerActionHandler(`${Yt}:addTransaction`,this.addTransaction.bind(this)),this.messenger.registerActionHandler(`${Yt}:addTransactionBatch`,this.addTransactionBatch.bind(this)),this.messenger.registerActionHandler(`${Yt}:confirmExternalTransaction`,this.confirmExternalTransaction.bind(this)),this.messenger.registerActionHandler(`${Yt}:emulateNewTransaction`,this.emulateNewTransaction.bind(this)),this.messenger.registerActionHandler(`${Yt}:emulateTransactionUpdate`,this.emulateTransactionUpdate.bind(this)),this.messenger.registerActionHandler(`${Yt}:estimateGas`,this.estimateGas.bind(this)),this.messenger.registerActionHandler(`${Yt}:estimateGasBatch`,this.estimateGasBatch.bind(this)),this.messenger.registerActionHandler(`${Yt}:getGasFeeTokens`,st(this,a,"m",et).bind(this)),this.messenger.registerActionHandler(`${Yt}:getNonceLock`,this.getNonceLock.bind(this)),this.messenger.registerActionHandler(`${Yt}:getTransactions`,this.getTransactions.bind(this)),this.messenger.registerActionHandler(`${Yt}:updateCustodialTransaction`,this.updateCustodialTransaction.bind(this)),this.messenger.registerActionHandler(`${Yt}:updateTransaction`,this.updateTransaction.bind(this))},Ve=function(e){this.update(t=>{const s=t.transactions.filter(({id:t})=>t!==e);t.transactions=st(this,a,"m",Z).call(this,s)})},ze=function(e){return[lt.errorCodes.provider.userRejectedRequest,Vt.ErrorCode.RejectedUpgrade].includes(e.code)},Ye=function(e,t,s){if(st(this,a,"m",X).call(this,e,t,s),s.code===lt.errorCodes.provider.userRejectedRequest)throw lt.providerErrors.userRejectedRequest({message:"MetaMask Tx Signature: User denied transaction signature.",data:s?.data});throw s},Qe=function(e,t,s){let n;try{n=st(this,a,"m",Oe).call(this,{transactionId:e.id,skipValidation:!0},e=>{e.status=Ct.TransactionStatus.failed,e.error=(0,Kt.normalizeTxError)(t)})}catch(s){(0,St.projectLogger)("Failed to mark transaction as failed",s),n={...e,status:Ct.TransactionStatus.failed,error:(0,Kt.normalizeTxError)(t)}}this.messenger.publish(`${Yt}:transactionFailed`,{actionId:s,error:t.message,transactionMeta:n}),st(this,a,"m",Te).call(this,n),this.messenger.publish(`${Yt}:transactionFinished`,n),st(this,_,"f").emit(`${e.id}:finished`,n)},Je=async function(e){(0,St.projectLogger)("Calling afterSimulate hook",e);const{id:t}=e,s=await st(this,i,"f").call(this,{transactionMeta:e}),{skipSimulation:n,updateTransaction:r}=s??{};if(n?st(this,R,"f").add(t):!1===n&&st(this,R,"f").delete(t),!r)return;const o=st(this,a,"m",Oe).call(this,{transactionId:t,skipResimulateCheck:!0},e=>{e.txParamsOriginal=(0,ut.cloneDeep)(e.txParams),r(e)});(0,St.projectLogger)("Updated transaction with afterSimulate data",o)},Xe=async function({ethQuery:e,publishHookOverride:t,traceContext:s},n,r){let i;return await st(this,U,"f").call(this,{name:"Publish",parentContext:s},async()=>{const s=t??st(this,D,"f");({transactionHash:i}=await s(n,r)),i??(i=await st(this,a,"m",J).call(this,e,{...n,rawTx:r}))}),(0,St.projectLogger)("Publish successful",i),{transactionHash:i}},Ze=async function(e){const{chainId:t}=e;return await(0,Ot.getGasFeeTokens)({chainId:t,getSimulationConfig:st(this,y,"f"),isEIP7702GasFeeTokensEnabled:st(this,E,"f"),messenger:this.messenger,publicKeyEIP7702:st(this,M,"f"),transactionMeta:e})},et=async function(e){const{chainId:t,data:s,from:n,to:r,value:i}=e,o=st(this,a,"m",le).call(this,{chainId:t}),c={chainId:t,delegationAddress:await(0,Ft.getDelegationAddress)(n,o),isExternalSign:!0,txParams:{data:s,from:n,to:r,value:i}};return(await st(this,a,"m",Ze).call(this,c)).gasFeeTokens}}}},{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"),i=e("../logger.cjs"),o="https://accounts.api.cx.metamask.io",c=`${o}/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)(i.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 i=`${o}/v1/networks/${t}/accounts/${s}/relationships/${n}`;u("Getting account address relationship",{request:e,url:i});const c={[l]:d},h=await(0,a.successfulFetch)(i,{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:i,startTimestamp:o,tags:m}=e;let h=`${c}${t}/transactions`;const f=[];if(s){const e=s.join(",");f.push(`networks=${e}`)}o&&f.push(`startTimestamp=${o}`),r&&f.push(`endTimestamp=${r}`),n&&f.push(`cursor=${n}`),i&&f.push(`sortDirection=${i}`),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"),i=e("../constants.cjs"),o=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 o.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();i.DELEGATION_MANAGER_ADDRESSES.includes(s)&&(t.overrides=t.overrides??{},t.overrides[s]={code:i.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 o.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/bridge-status-controller/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,i,o,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:o}=t;let c;switch(s){case d.GAS_ESTIMATE_TYPES.FEE_MARKET:p("Using fee market estimates",o),c=l(this,a,"m",n).call(this,o);break;case d.GAS_ESTIMATE_TYPES.LEGACY:p("Using legacy estimates",o),c=l(this,a,"m",r).call(this,o);break;case d.GAS_ESTIMATE_TYPES.ETH_GASPRICE:p("Using eth_gasPrice estimates",o),c=l(this,a,"m",i).call(this,o);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",o).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}},i=function(e){return{type:h.GasFeeEstimateType.GasPrice,gasPrice:(0,f.gweiDecimalToWeiHex)(e.gasPrice)}},o=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,i,o,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",i).call(this,n.baseFeePerGas,k);p("Generated base fees",l(this,a,"m",c).call(this,m));const u=l(this,a,"m",i).call(this,n.priorityFeePerGas,b);p("Generated priority fees",l(this,a,"m",c).call(this,u));const h=l(this,a,"m",o).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}])},i=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)}},o=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 i=e("@metamask/controller-utils"),o=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,o.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,i.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,i,o,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),y=[{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,i=l(this,a,"m",c).call(this,t,s.chainId),o=await l(this,a,"m",n).call(this,i,s),d=await l(this,a,"m",r).call(this,i,s);return{layer1Fee:(0,h.add0x)((0,k.padHexToEvenLength)(o.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",i).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}},i=function(e,s){const n=l(this,a,"m",o).call(this,e),{chainId:r}=e;let i=(0,g.prepareTransaction)(r,n);if(s){const e=t.from("abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789","hex"),s=Uint8Array.from(e);i=i.sign(s)}return i},o=function(e){return{...e.txParams,gasLimit:e.txParams.gas}},c=function(e,t){return new m.Contract(this.getOracleAddressForChain(t),y,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/bridge-status-controller/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,i,o,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 i=n-r,o=a.slice(0,i),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(o+"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:o,gasFeeEstimates:d}=s,m=(0,f.getGasFeeRandomisation)(t),u=m.randomisedGasFeeDigits[r.chainId],h=m.preservedNumberOfDigits??2;if(o===l.GAS_ESTIMATE_TYPES.FEE_MARKET){g("Randomising fee market estimates",d);const e=c(this,a,"m",i).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)},i=function(e,t,s){const n=Object.values(h.GasFeeEstimateLevel).reduce((n,r)=>({...n,[r]:c(this,a,"m",o).call(this,e,r,t,s)}),{});return{type:h.GasFeeEstimateType.FeeMarket,...n}},o=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 i extends a.OracleLayer1GasFeeFlow{getOracleAddressForChain(e){return"0x5300000000000000000000000000000000000002"}shouldSignTransaction(){return!0}async matchesTransaction({transactionMeta:e}){return r.includes(e.chainId)}}s.ScrollLayer1GasFeeFlow=i}}},{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,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)},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};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=(i(this,n,"f")+1)*d,f=i(this,n,"f")*d,p=h-u,g=f-u,k=h+u,b=f+u;return o(this,n,i(this,n,"f")+1,"f"),{estimates:{type:l.GasFeeEstimateType.FeeMarket,low:{maxFeePerGas:i(this,a,"m",r).call(this,p,m),maxPriorityFeePerGas:i(this,a,"m",r).call(this,g,m)},medium:{maxFeePerGas:i(this,a,"m",r).call(this,h,m),maxPriorityFeePerGas:i(this,a,"m",r).call(this,f,m)},high:{maxFeePerGas:i(this,a,"m",r).call(this,k,m),maxPriorityFeePerGas:i(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,i,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)},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 o(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=>o(this,a,"m",i).call(this,t,e)));k("Normalized transactions",d);const m=o(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},i=async function(e,t){const s=String(t.blockNumber),a=`0x${t.chainId.toString(16)}`,{hash:n}=t,r=new Date(t.timestamp).getTime(),i=(0,m.v1)({msecs:r}),{from:o}=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,y=t.valueTransfers.find(t=>(t.to.toLowerCase()===e.toLowerCase()||t.from.toLowerCase()===e.toLowerCase())&&t.contractAddress),T=y?.to.toLowerCase()===e.toLowerCase()&&o.toLowerCase()!==e.toLowerCase(),x=o.toLowerCase()===e.toLowerCase(),_=y?.amount,v=y?.contractAddress,E=y?.decimal,I=y?.symbol,P=(0,l.BNToHex)(new d.default(T?y?.amount??t.value:t.value)),S=T?e:t.to,C={blockNumber:s,chainId:a,error:w===g.TransactionStatus.failed?new Error("Transaction failed"):undefined,hash:n,id:i,isTransfer:T,networkClientId:"",status:w,time:r,toSmartContract:!1,transferInformation:y?{amount:_,contractAddress:v,decimals:E,symbol:I}:undefined,txParams:{chainId:a,data:k,from:o,gas:c,gasPrice:h,gasUsed:f,nonce:p,to:S,value:P},type:b,verifiedOnBlockchain:!1};return x&&(C.type=(await(0,u.determineTransactionType)(C.txParams)).type),C}}}},{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,i,o,c,l,d,m,u,h,f,p,g,k,b,w,y,T,x,_,v,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},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)},S=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 C=S(e("@metamask/eth-query")),j=e("@metamask/utils"),A=S(e("events")),F=e("../gas-flows/DefaultGasFeeFlow.cjs"),G=e("../logger.cjs"),M=e("../types.cjs"),D=e("../utils/gas-flow.cjs"),N=e("../utils/layer1-gas-fee-flow.cjs"),O=(0,j.createModuleLogger)(G.projectLogger,"gas-fee-poller");function L(e,t,s,a){const{type:n}=t;if(a){if(n===M.GasFeeEstimateType.FeeMarket){const a=t;e.maxFeePerGas=a[s]?.maxFeePerGas,e.maxPriorityFeePerGas=a[s]?.maxPriorityFeePerGas}if(n===M.GasFeeEstimateType.GasPrice){const s=t;e.maxFeePerGas=s.gasPrice,e.maxPriorityFeePerGas=s.gasPrice}if(n===M.GasFeeEstimateType.Legacy){const a=t[s];e.maxFeePerGas=a,e.maxPriorityFeePerGas=a}delete e.gasPrice}else{if(n===M.GasFeeEstimateType.FeeMarket){const a=t;e.gasPrice=a[s]?.maxFeePerGas}if(n===M.GasFeeEstimateType.GasPrice){const s=t;e.gasPrice=s.gasPrice}if(n===M.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:y,onStateChange:T}){a.add(this),this.hub=new A.default,n.set(this,void 0),r.set(this,void 0),i.set(this,void 0),o.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),I(this,n,e,"f"),I(this,r,t,"f"),I(this,d,w,"f"),I(this,i,s,"f"),I(this,o,g,"f"),I(this,c,k,"f"),I(this,l,b,"f"),I(this,m,y,"f"),T(()=>{const e=P(this,a,"m",_).call(this),t=P(this,a,"m",v).call(this);e.length||t.length?P(this,a,"m",f).call(this):P(this,a,"m",p).call(this)})}},n=new WeakMap,r=new WeakMap,i=new WeakMap,o=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(){P(this,h,"f")||(P(this,a,"m",g).call(this),I(this,h,!0,"f"),O("Started polling"))},p=function(){P(this,h,"f")&&(clearTimeout(P(this,u,"f")),I(this,u,undefined,"f"),I(this,h,!1,"f"),O("Stopped polling"))},g=async function e(){await P(this,a,"m",k).call(this),await P(this,a,"m",b).call(this),I(this,u,setTimeout(()=>P(this,a,"m",e).call(this),1e4),"f")},k=async function(){const e=P(this,a,"m",_).call(this);if(!e.length)return;O("Found unapproved transactions",e.length);const t=await P(this,a,"m",E).call(this,e);O("Retrieved gas fee controller data",t),await Promise.all(e.flatMap(e=>{const{chainId:s}=e,n=t.get(s);return P(this,a,"m",w).call(this,e,n)}))},b=async function(){const e=P(this,a,"m",v).call(this);if(!e.length)return;O("Found unapproved transaction batches",e.length);const t=await P(this,a,"m",E).call(this,e);O("Retrieved gas fee controller data",t),await Promise.all(e.flatMap(e=>{const{chainId:s}=e,n=t.get(s);return P(this,a,"m",y).call(this,e,n)}))},w=async function(e,t){const{id:s}=e,[n,r]=await Promise.all([P(this,a,"m",T).call(this,e,t),P(this,a,"m",x).call(this,e)]);(n||r)&&this.hub.emit("transaction-updated",{transactionId:s,gasFeeEstimates:n?.gasFeeEstimates,gasFeeEstimatesLoaded:n?.gasFeeEstimatesLoaded,layer1GasFee:r})},y=async function(e,t){const{id:s}=e,a=new C.default(P(this,o,"f").call(this,e.networkClientId)),n=new F.DefaultGasFeeFlow,r={ethQuery:a,gasFeeControllerData:t,messenger:P(this,m,"f"),transactionMeta:{...e,txParams:{...e.transactions?.[0],from:e.from,gas:e.gas},time:Date.now()}};let i;try{i=(await n.getGasFees(r)).estimates}catch(t){O("Failed to get gas fees for batch",e.id,t)}i&&this.hub.emit("transaction-batch-updated",{transactionBatchId:s,gasFeeEstimates:i,gasFeeEstimatesLoaded:!0})},T=async function(e,t){const{networkClientId:s}=e,a=new C.default(P(this,o,"f").call(this,s)),n=(0,D.getGasFeeFlow)(e,P(this,r,"f"),P(this,m,"f"));n&&O("Found gas fee flow",n.constructor.name,e.id);const i={ethQuery:a,gasFeeControllerData:t,messenger:P(this,m,"f"),transactionMeta:e};let c;if(n)try{c=(await n.getGasFees(i)).estimates}catch(t){O("Failed to get suggested gas fees",e.id,t)}return!c&&e.gasFeeEstimatesLoaded?undefined:(O("Updated gas fee estimates",{gasFeeEstimates:c,transaction:e.id}),{gasFeeEstimates:c,gasFeeEstimatesLoaded:!0})},x=async function(e){const{networkClientId:t}=e,s=P(this,o,"f").call(this,t),a=await(0,N.getTransactionLayer1GasFee)({layer1GasFeeFlows:P(this,d,"f"),messenger:P(this,m,"f"),provider:s,transactionMeta:e});return a&&O("Updated layer 1 gas fee",a,e.id),a},_=function(){return P(this,c,"f").call(this).filter(e=>e.status===M.TransactionStatus.unapproved)},v=function(){return P(this,l,"f").call(this).filter(e=>e.status===M.TransactionStatus.unapproved)},E=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??P(this,n,"f").call(this,e);t.set(e,r)}O("Extracted network client IDs by chain ID",t);const s=Array.from(t.entries()).map(async([e,t])=>[e,await P(this,i,"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,i=Object.values(M.GasFeeEstimateLevel).includes(r);if(s(n)&&i&&e){const t=n.txParams.type!==M.TransactionEnvelopeType.legacy;L(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;L(s,a,t,e.txParams.type!==M.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,i,o,c,l,d,m,u,h,f,p,g,k,b,w,y,T,x,_,v,E,I,P,S,C,j,A,F,G,M=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)},N=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=N(e("events")),L=e("./AccountsApiRemoteTransactionSource.cjs"),B=e("../logger.cjs"),R=e("../utils/feature-flags.cjs"),H=e("../utils/utils.cjs");var U;!function(e){e.CONNECTED="connected",e.DISCONNECTED="disconnected"}(U||(s.WebSocketState=U={}));s.IncomingTransactionHelper=class{constructor({client:e,getCurrentAccount:t,getLocalTransactions:s,includeTokenTransfers:x,isEnabled:v,messenger:E,remoteTransactionSource:S,trimTransactions:C,updateTransactions:j}){a.add(this),n.set(this,void 0),r.set(this,void 0),i.set(this,void 0),o.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,[...L.SUPPORTED_CHAIN_IDS]),b.set(this,e=>{D(this,a,"m",_).call(this,e)}),w.set(this,e=>{D(this,a,"m",I).call(this,e)}),y.set(this,()=>{D(this,a,"m",P).call(this)}),T.set(this,({chainIds:e,status:t})=>{D(this,a,"m",G).call(this,e,t)}),this.hub=new O.default,M(this,n,e,"f"),M(this,r,t,"f"),M(this,i,s,"f"),M(this,o,x,"f"),M(this,c,v??(()=>!0),"f"),M(this,l,!1,"f"),M(this,d,!1,"f"),M(this,m,E,"f"),M(this,u,S,"f"),M(this,f,C,"f"),M(this,p,j,"f"),M(this,g,(0,R.isIncomingTransactionsUseBackendWebSocketServiceEnabled)(E),"f"),D(this,g,"f")&&(D(this,m,"f").subscribe("BackendWebSocketService:connectionStateChanged",D(this,b,"f")),D(this,m,"f").subscribe("AccountActivityService:statusChanged",D(this,T,"f")))}start(){D(this,g,"f")||D(this,a,"m",x).call(this,!0)}stop(){D(this,h,"f")&&clearTimeout(D(this,h,"f")),D(this,l,"f")&&(M(this,l,!1,"f"),(0,B.incomingTransactionsLogger)("Stopped polling"))}async update({chainIds:e,isInterval:t,tags:s}={}){const n=D(this,a,"m",F).call(this,s,t);if((0,B.incomingTransactionsLogger)("Checking for incoming transactions",{isInterval:Boolean(t),tags:n}),!D(this,a,"m",j).call(this))return;const c=D(this,r,"f").call(this),l=D(this,o,"f")??!0,d=D(this,p,"f")??!1;let m=[];try{m=await D(this,u,"f").fetchTransactions({address:c.address,chainIds:e,includeTokenTransfers:l,tags:n,updateTransactions:d})}catch(e){return void(0,B.incomingTransactionsLogger)("Error while fetching remote transactions",e)}if(!m.length)return;D(this,a,"m",C).call(this,m),(0,B.incomingTransactionsLogger)("Found potential transactions",m.length,m);const h=D(this,i,"f").call(this),g=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(!g.length)return void(0,B.incomingTransactionsLogger)("All transactions are already known");(0,B.incomingTransactionsLogger)("Found unique transactions",g.length,g);const k=D(this,f,"f").call(this,[...g,...h]),b=g.map(e=>e.id),w=k.filter(e=>b.includes(e.id));w.length?((0,B.incomingTransactionsLogger)("Adding new transactions",w.length,w),this.hub.emit("transactions",w)):(0,B.incomingTransactionsLogger)("All unique transactions truncated due to limit")}},n=new WeakMap,r=new WeakMap,i=new WeakMap,o=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,y=new WeakMap,T=new WeakMap,a=new WeakSet,x=function(e=!1){if(D(this,l,"f"))return;if(!D(this,a,"m",j).call(this))return;const t=D(this,a,"m",A).call(this);(0,B.incomingTransactionsLogger)("Started polling",{interval:t}),M(this,l,!0,"f"),D(this,d,"f")||D(this,a,"m",S).call(this).catch(t=>{(0,B.incomingTransactionsLogger)(e?"Initial polling failed":"Polling failed",t)})},_=function(e){e.state===U.CONNECTED?((0,B.incomingTransactionsLogger)("WebSocket connected, starting enhanced mode"),D(this,a,"m",v).call(this)):e.state===U.DISCONNECTED&&((0,B.incomingTransactionsLogger)("WebSocket disconnected, stopping enhanced mode"),D(this,a,"m",E).call(this))},v=function(){D(this,a,"m",j).call(this)&&((0,B.incomingTransactionsLogger)("Started transaction history retrieval (event-driven)"),this.update().catch(e=>{(0,B.incomingTransactionsLogger)("Initial update in transaction history retrieval failed",e)}),D(this,m,"f").subscribe("AccountActivityService:transactionUpdated",D(this,w,"f")),D(this,m,"f").subscribe("AccountsController:selectedAccountChange",D(this,y,"f")))},E=function(){(0,B.incomingTransactionsLogger)("Stopped transaction history retrieval"),D(this,m,"f").unsubscribe("AccountActivityService:transactionUpdated",D(this,w,"f")),D(this,m,"f").unsubscribe("AccountsController:selectedAccountChange",D(this,y,"f"))},I=function(e){(0,B.incomingTransactionsLogger)("Received relevant transaction update, triggering update",{txId:e.id,chain:e.chain}),this.update().catch(e=>{(0,B.incomingTransactionsLogger)("Update after transaction event failed",e)})},P=function(){(0,B.incomingTransactionsLogger)("Selected account changed, triggering update"),this.update().catch(e=>{(0,B.incomingTransactionsLogger)("Update after account change failed",e)})},S=async function e(){M(this,d,!0,"f");try{const e=D(this,g,"f")?D(this,k,"f"):undefined;await this.update({chainIds:e,isInterval:!0})}catch(e){console.error("Error while checking incoming transactions",e)}M(this,d,!1,"f"),D(this,l,"f")&&(D(this,h,"f")&&clearTimeout(D(this,h,"f")),M(this,h,setTimeout(()=>D(this,a,"m",e).call(this),D(this,a,"m",A).call(this)),"f"))},C=function(e){e.sort((e,t)=>e.time<t.time?-1:1)},j=function(){return D(this,c,"f").call(this)},A=function(){return(0,R.getIncomingTransactionsPollingInterval)(D(this,m,"f"))},F=function(e,t){const s=[];return D(this,n,"f")&&s.push(D(this,n,"f")),e?.length?s.push(...e):t&&s.push("automatic-polling"),s?.length?s:undefined},G=function(e,t){if(!D(this,g,"f"))return;let s=!1;for(const a of e){const e=(0,H.caip2ToHex)(a);if(e&&L.SUPPORTED_CHAIN_IDS.includes(e))if("up"===t){const t=D(this,k,"f").indexOf(e);-1!==t&&(D(this,k,"f").splice(t,1),s=!0,(0,B.incomingTransactionsLogger)("Supported network came up, removed from polling list",{chainId:e}))}else"down"!==t||D(this,k,"f").includes(e)||(D(this,k,"f").push(e),s=!0,(0,B.incomingTransactionsLogger)("Supported network went down, added to polling list",{chainId:e}));else(0,B.incomingTransactionsLogger)("Chain ID not recognized or not supported",{caip2ChainId:a,hexChainId:e})}s?0===D(this,k,"f").length?((0,B.incomingTransactionsLogger)("Stopping fallback polling - all networks up"),this.stop()):((0,B.incomingTransactionsLogger)("Starting fallback polling - some networks need polling",{chainsToPoll:D(this,k,"f")}),D(this,a,"m",x).call(this)):(0,B.incomingTransactionsLogger)("No changes to polling list",{chainsToPoll:D(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/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,i,o,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),i.set(this,void 0),o.set(this,new h.Mutex),this.hub=new p.default,l(this,n,e,"f"),l(this,r,t,"f"),l(this,i,new Map,"f")}async lookup(e,t){k("lookup",e,t);const s=await d(this,o,"f").acquire();try{const s=d(this,r,"f").call(this)[e];if(s)return k("Cached",s),s;let o=d(this,i,"f").get(t);if(!o){const e=d(this,n,"f").call(this,t);o=new f.MethodRegistry({provider:e}),d(this,i,"f").set(t,o),k("Created registry",t)}const l=await d(this,a,"m",c).call(this,e,o);return k("Result",l),this.hub.emit("update",{fourBytePrefix:e,methodData:l}),l}finally{s()}}},n=new WeakMap,r=new WeakMap,i=new WeakMap,o=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,i,o,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:y,onNetworkStateChange:T}){a.add(this),n.set(this,void 0),r.set(this,void 0),i.set(this,void 0),o.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,i,s,"f"),p(this,o,k,"f"),p(this,c,b,"f"),p(this,l,y,"f"),T((e,t)=>{const s=g(this,i,"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,i,"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,i=new WeakMap,o=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,o,"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}),i=g(this,l,"f").call(this,{provider:t,blockTracker:s,chainId:a,networkClientId:e});g(this,m,"f").set(e,{nonceTracker:n,pendingTransactionTracker:i})}}}},{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,i,o,c,l,d,m,u,h,f,p,g,k,b,w,y,T,x,_,v,E,I,P,S,C,j,A,F,G,M,D,N,O,L,B,R,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},K=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.PendingTransactionTracker=void 0;const z=e("@metamask/controller-utils"),Y=V(e("events")),Q=e("lodash"),J=e("./TransactionPoller.cjs"),X=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,X.createModuleLogger)(X.projectLogger,"pending-transactions");s.PendingTransactionTracker=class{constructor({blockTracker:e,getChainId:t,getEthQuery:s,getGlobalLock:_,getNetworkClientId:v,getTransactions:E,isTimeoutEnabled:I,hooks:P,isResubmitEnabled:S,messenger:C,publishTransaction:j}){a.add(this),n.set(this,void 0),r.set(this,void 0),i.set(this,void 0),o.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),y.set(this,void 0),this.startIfPendingTransactions=()=>{const e=K(this,a,"m",M).call(this);e.length?K(this,a,"m",T).call(this,e):this.stop()},this.hub=new Y.default,$(this,r,new Map,"f"),$(this,o,t,"f"),$(this,c,s,"f"),$(this,l,_,"f"),$(this,d,v,"f"),$(this,m,E,"f"),$(this,u,S??(()=>!0),"f"),$(this,h,new Map,"f"),$(this,f,K(this,a,"m",x).bind(this),"f"),$(this,g,C,"f"),$(this,k,j,"f"),$(this,b,!1,"f"),$(this,y,undefined,"f"),$(this,w,new J.TransactionPoller({blockTracker:e,chainId:t(),messenger:C}),"f"),$(this,n,P?.beforeCheckPendingTransaction??(()=>Promise.resolve(!0)),"f"),$(this,i,I,"f"),$(this,p,(0,X.createModuleLogger)(se,`${t()}:${v()}`),"f")}addTransactionToPoll(e){K(this,a,"m",T).call(this,[e]),$(this,y,e,"f")}async forceCheckTransaction(e){const t=await K(this,l,"f").call(this);try{await K(this,a,"m",C).call(this,e)}catch(e){K(this,p,"f").call(this,"Failed to check transaction",e)}finally{t()}}stop(){K(this,b,"f")&&(K(this,w,"f").stop(),$(this,b,!1,"f"),K(this,p,"f").call(this,"Stopped polling"))}},n=new WeakMap,r=new WeakMap,i=new WeakMap,o=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,y=new WeakMap,a=new WeakSet,T=function(e){K(this,w,"f").setPendingTransactions(e),K(this,b,"f")||(K(this,w,"f").start(K(this,f,"f")),$(this,b,!0,"f"),K(this,p,"f").call(this,"Started polling"))},x=async function(e){const t=await K(this,l,"f").call(this);try{await K(this,a,"m",_).call(this)}catch(e){K(this,p,"f").call(this,"Failed to check transactions",e)}finally{t()}try{await K(this,a,"m",v).call(this,e)}catch(e){K(this,p,"f").call(this,"Failed to resubmit transactions",e)}},_=async function(){K(this,p,"f").call(this,"Checking transactions");const e=[...K(this,a,"m",M).call(this),...K(this,y,"f")?[K(this,y,"f")]:[]];e.length?(K(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=>K(this,a,"m",C).call(this,e)))):K(this,p,"f").call(this,"No pending transactions to check")},v=async function(e){if(!K(this,u,"f").call(this)||!K(this,b,"f"))return;K(this,p,"f").call(this,"Resubmitting transactions");const t=K(this,a,"m",M).call(this);if(t.length){K(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 K(this,a,"m",I).call(this,s,e)}catch(e){const t=e.value?.message?.toLowerCase()??e.message?.toLowerCase()??String(e);if(K(this,a,"m",E).call(this,t)){K(this,p,"f").call(this,"Ignoring known transaction error",t);continue}K(this,a,"m",D).call(this,s,e.message,"There was an error when resubmitting this transaction.")}}else K(this,p,"f").call(this,"No pending transactions to resubmit")},E=function(e){return te.some(t=>e.includes(t))},I=async function(e,t){if(!K(this,a,"m",P).call(this,e,t))return;if(!await K(this,n,"f").call(this,e))return;const s=K(this,c,"f").call(this,e.networkClientId);await K(this,k,"f").call(this,s,e);const r=(e.retryCount??0)+1;K(this,a,"m",L).call(this,(0,Q.merge)({},e,{retryCount:r}),"PendingTransactionTracker:transaction-retry - Retry count increased")},P=function(e,t){const s=(0,Q.cloneDeep)(e);s.firstRetryBlockNumber||(s.firstRetryBlockNumber=t,K(this,a,"m",L).call(this,s,"PendingTransactionTracker:#isResubmitDue - First retry block number set"));const{firstRetryBlockNumber:n}=s,r=Number.parseInt(t,16)-Number.parseInt(n,16),i=e.retryCount??0;return r>=Math.min(50,Math.pow(2,i))},S=function(e){const{hash:t,id:s}=e;K(this,y,"f")?.id===s&&$(this,y,undefined,"f"),t&&K(this,h,"f").delete(t)},C=async function(e){const{hash:t,id:s,isIntentComplete:r,txParams:{from:i}}=e;if(r)await K(this,a,"m",j).call(this,e);else{if(!t&&await K(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 K(this,a,"m",N).call(this,e,t)}if(K(this,a,"m",G).call(this,e))return K(this,p,"f").call(this,"Nonce already taken",s),void K(this,a,"m",O).call(this,e);try{const s=await K(this,a,"m",B).call(this,t),n="0x1"===s?.status;if("0x0"===s?.status)return K(this,p,"f").call(this,"Transaction receipt has failed status"),void K(this,a,"m",N).call(this,e,new Error("Transaction failed on-chain"));const{blockNumber:r,blockHash:o}=s??{};if(n&&r&&o)return void await K(this,a,"m",j).call(this,e,{...s,blockNumber:r,blockHash:o});K(this,p,"f").call(this,"No receipt status",{hash:t,receipt:s});const c=await K(this,a,"m",U).call(this,i),l=parseInt(c,16);if(!s&&await K(this,a,"m",A).call(this,e,l))return;await K(this,a,"m",F).call(this,e,l)&&K(this,a,"m",O).call(this,e)}catch(t){K(this,p,"f").call(this,"Failed to check transaction",s,t),K(this,a,"m",D).call(this,e,t.message,"There was a problem loading this transaction.")}}},j=async function(e,t){const{id:s}=e,{blockHash:n}=t??{};K(this,p,"f").call(this,"Transaction confirmed",s);const r=K(this,y,"f")?.id===s;if(K(this,a,"m",S).call(this,e),r)return void this.hub.emit("transaction-confirmed",e);const i=(0,Q.cloneDeep)(e);if(t&&n){const{baseFeePerGas:e,timestamp:s}=await K(this,a,"m",H).call(this,n,!1);i.baseFeePerGas=e,i.blockTimestamp=s,i.txParams={...i.txParams,gasUsed:t.gasUsed},i.txReceipt=t,i.verifiedOnBlockchain=!0}i.status=Z.TransactionStatus.confirmed,K(this,a,"m",L).call(this,i,"PendingTransactionTracker:#onTransactionConfirmed - Transaction confirmed"),this.hub.emit("transaction-confirmed",i)},A=async function(e,t){const{chainId:s,hash:n,id:r,submittedTime:o,txParams:{nonce:c}}=e;if(!n||!c)return!1;if(!K(this,i,"f").call(this,e))return K(this,p,"f").call(this,"Timeout disabled for transaction",e),!1;const l=(0,ee.getTimeoutAttempts)(s,K(this,g,"f"));if(l===undefined||0===l)return K(this,p,"f").call(this,"Timeout disabled due to threshold",{chainId:s,threshold:l}),!1;const d=parseInt(c,16);if(d>t)return K(this,p,"f").call(this,"Skipping timeout as queued transaction",{transactionNonce:d,nextNonce:t}),!1;try{if(null!==await K(this,a,"m",R).call(this,n)){const e=Date.now();return K(this,p,"f").call(this,"Transaction found on network, recording timestamp",r),K(this,h,"f").set(n,e),!1}const t=K(this,h,"f").get(n)??o;if(t===undefined)return K(this,p,"f").call(this,"Transaction not yet seen on network and has no submitted time, skipping timeout check",r),!1;const{blockTime:i}=(0,ee.getAcceleratedPollingParams)(s,K(this,g,"f")),c=Date.now()-t,d=i*l;return K(this,p,"f").call(this,"Checking timeout duration",{transactionId:r,durationSinceLastSeen:c,timeoutDuration:d,threshold:l,blockTime:i}),c<d?!1:(K(this,p,"f").call(this,"Hit timeout duration threshold",r),K(this,h,"f").delete(n),K(this,a,"m",N).call(this,e,new Error("Transaction not found on network after timeout")),!0)}catch(e){return K(this,p,"f").call(this,"Failed to check transaction by hash",r,e),!1}},F=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 i=K(this,r,"f").get(s);return i===undefined&&(i=0,K(this,r,"f").set(s,i)),i<3?(K(this,p,"f").call(this,"Incrementing dropped block count",{id:a,droppedBlockCount:i}),K(this,r,"f").set(s,i+1),!1):(K(this,p,"f").call(this,"Hit dropped block count",a),K(this,r,"f").delete(s),!0)},G=function(e){const{id:t,txParams:s}=e;return K(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)},M=function(){return K(this,a,"m",W).call(this).filter(e=>e.status===Z.TransactionStatus.submitted&&!e.verifiedOnBlockchain&&!e.isUserOperation&&!e.isStateOnly)},D=function(e,t,s){K(this,a,"m",L).call(this,{...e,warning:{error:t,message:s}},"PendingTransactionTracker:#warnTransaction - Warning added")},N=function(e,t){K(this,p,"f").call(this,"Transaction failed",e.id,t),K(this,a,"m",S).call(this,e),this.hub.emit("transaction-failed",e,t)},O=function(e){K(this,p,"f").call(this,"Transaction dropped",e.id),K(this,a,"m",S).call(this,e),this.hub.emit("transaction-dropped",e)},L=function(e,t){this.hub.emit("transaction-updated",e,t)},B=async function(e){return await(0,z.query)(K(this,c,"f").call(this),"getTransactionReceipt",[e])},R=async function(e){return await(0,z.query)(K(this,c,"f").call(this),"getTransactionByHash",[e])},H=async function(e,t){return await(0,z.query)(K(this,c,"f").call(this),"getBlockByHash",[e,t])},U=async function(e){return await(0,z.query)(K(this,c,"f").call(this),"getTransactionCount",[e])},q=function(){const e=K(this,o,"f").call(this);return K(this,m,"f").call(this).filter(t=>t.chainId===e)},W=function(){const e=K(this,d,"f").call(this);return K(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,i,o,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"),y=(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!x(e?.difference??"0x0",t?.difference??"0x0",!1===e?.isDecrease,!1===t?.isDecrease)}function x(e,t,a,n){let r=new p.BN((0,f.remove0x)(e),"hex"),i=new p.BN((0,f.remove0x)(t),"hex");return a&&(r=r.neg()),n&&(i=i.neg()),(0,w.getPercentageChange)(r,i)<=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),i.set(this,void 0),u(this,r,e,"f"),u(this,i,t,"f"),s(h(this,a,"m",o).bind(this))}},n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakSet,o=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,i,"f").call(this,e).catch(e=>{y("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),y(`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),y(`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 i=Object.keys(n).filter(e=>n[e]!==r[e]);return y("Transaction parameters updated",{transactionId:a,updatedProperties:i,originalParams:r,newParams:n}),s.RESIMULATE_PARAMS.some(e=>i.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 y("Security alert updated",{transactionId:n,originalSecurityAlertResponse:a,newSecurityAlertResponse:r}),r?.result_type===s.BLOCKAID_RESULT_TYPE_MALICIOUS}(e,t),i=function(e,t){const{simulationData:s}=e,{simulationData:a,txParams:n}=t;if(!a||(0,g.isEqual)(s,a))return!1;return!x(n?.value??"0x0",a?.nativeBalanceChange?.difference??"0x0",!1,!1===a?.nativeBalanceChange?.isDecrease)}(e,t),o=n||r||i;let c;if(r||i){c=Math.floor(Date.now()/1e3)+s.BLOCK_TIME_ADDITIONAL_SECONDS}return o&&y("Transaction should be resimulated",{transactionId:a,blockTime:c,parametersUpdated:n,securityAlert:r,valueAndNativeBalanceMismatch:i}),{blockTime:c,resimulate:o}},s.hasSimulationDataChanged=function(e,t){if((0,g.isEqual)(e,t))return!1;if(T(e?.nativeBalanceChange,t?.nativeBalanceChange))return y("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 y("Missing new token balance",{address:s.address,id:s.id}),!0;if(T(s,e))return y("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,i,o,c,l,d,m,u,h,f,p,g,k,b,w,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},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 x=e("@metamask/utils"),_=e("lodash"),v=e("../logger.cjs"),E=e("../utils/feature-flags.cjs"),I=(0,x.createModuleLogger)(v.projectLogger,"transaction-poller");var P;!function(e){e.Accelerated="Accelerated",e.BlockTracker="BlockTracker",e.Websocket="Websocket"}(P||(P={}));s.TransactionPoller=class{constructor({blockTracker:e,chainId:t,messenger:s}){a.add(this),n.set(this,0),r.set(this,void 0),i.set(this,void 0),o.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,P.Websocket).catch(()=>{})}),y(this,r,e,"f"),y(this,i,t,"f"),y(this,o,s,"f")}start(e){T(this,m,"f")||(y(this,l,e,"f"),y(this,m,!0,"f"),T(this,a,"m",b).call(this),T(this,a,"m",h).call(this),I("Started"))}stop(){T(this,m,"f")&&(y(this,m,!1,"f"),y(this,l,undefined,"f"),y(this,n,0,"f"),y(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),I("Stopped"))}setPendingTransactions(e){const t=(T(this,d,"f")??[]).map(e=>e.id);y(this,d,e,"f");const s=e.map(e=>e.id),r=!(0,_.isEqual)(t,s);T(this,m,"f")&&r&&(I("Detected new pending transactions",s),y(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,i=new WeakMap,o=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,E.getAcceleratedPollingParams)(T(this,i,"f"),T(this,o,"f"));if(T(this,n,"f")>=t)return y(this,c,e=>T(this,a,"m",f).call(this,P.BlockTracker,e),"f"),T(this,r,"f").on("latest",T(this,c,"f")),void I("Added block tracker listener");T(this,a,"m",p).call(this),y(this,u,setTimeout(async()=>{await T(this,a,"m",f).call(this,P.Accelerated),T(this,a,"m",e).call(this)},s),"f")},f=async function(e,t){switch(e){case P.Websocket:I("AccountActivityService:transactionUpdated received");break;case P.Accelerated:I("Accelerated interval",T(this,n,"f")+1);break;case P.BlockTracker:I("Block tracker interval",t)}const s=t??await T(this,r,"f").getLatestBlock();await(T(this,l,"f")?.call(this,s)),e===P.Accelerated&&T(this,m,"f")&&y(this,n,T(this,n,"f")+1,"f")},p=function(){T(this,u,"f")&&(clearTimeout(T(this,u,"f")),y(this,u,undefined,"f"))},g=function(){T(this,c,"f")&&(T(this,r,"f").removeListener("latest",T(this,c,"f")),y(this,c,undefined,"f"))},b=function(){T(this,o,"f").subscribe("AccountActivityService:transactionUpdated",T(this,k,"f"))},w=function(){T(this,o,"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,i,o,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),i.set(this,void 0),c(this,i,(0,d.createDeferredPromise)(),"f"),c(this,n,[],"f"),c(this,r,e,"f")}getHook(){return l(this,a,"m",o).bind(this)}ready(){return l(this,i,"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,i=new WeakMap,a=new WeakSet,o=function(e,t){const s=e.txParams.nonce??"0x0",a=parseInt(s,16);h("Processing transaction",{nonce:a,signedTx:t,transactionMeta:e});const o=(0,d.createDeferredPromise)();if(l(this,n,"f").push({nonce:a,promise:o,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,i,"f").resolve({signedTransactions:e})}return o.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,i,o,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),i.set(this,void 0),c(this,n,e,"f"),c(this,r,t,"f"),c(this,i,s,"f")}getHook(){return l(this,a,"m",o).bind(this)}},n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakSet,o=async function(e,t){u("Publishing transaction as batch",{transactionMeta:e,signedTx:t});const{batchTransactions:s,batchTransactionsOptions:a,id:o,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,y=t,T=(0,d.createDeferredPromise)(),x={existingTransaction:{id:o,onPublish:({newSignature:e,transactionHash:t})=>{if(e){const t=l(this,r,"f").call(this,o);return u("Calling original publish hook with new signature",{latestTransactionMeta:t,newSignature:e}),void l(this,i,"f").call(this,t,e).then(T.resolve).catch(T.reject)}T.resolve({transactionHash:t})},signedTransaction:y},params:{data:p,gas:k,maxFeePerGas:b,maxPriorityFeePerGas:w,to:f,value:g}},_=(s??[]).map(e=>{const{isAfter:t,type:s,...a}=e;return{isAfter:t,params:a,type:s}}),v=[..._.filter(e=>!1===e.isAfter).map(({isAfter:e,...t})=>({...t})),x,..._.filter(e=>e.isAfter===undefined||e.isAfter).map(({isAfter:e,...t})=>({...t}))];u("Adding transaction batch",{from:h,networkClientId:c,transactions:v});const E=a??{disable7702:!0,disableHook:!1,disableSequential:!0};return await l(this,n,"f").call(this,{from:h,networkClientId:c,requireApproval:!1,transactions:v,...E}),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,i,o,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),i.set(this,void 0),o.set(this,void 0),c.set(this,{}),f(this,n,e,"f"),f(this,r,t,"f"),f(this,i,l,"f"),f(this,o,s,"f")}getHook(){return p(this,a,"m",l).bind(this)}},n=new WeakMap,r=new WeakMap,i=new WeakMap,o=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,o,"f").call(this,t),l=[];for(const e of s)try{const s=p(this,r,"f").call(this,String(e.id)),o=await p(this,n,"f").call(this,p(this,i,"f").call(this,t),s);w("Transaction published",{transactionHash:o});const m={...s,hash:o},u=p(this,a,"m",d).call(this,c,m.id,m.hash);c.addTransactionToPoll(m),await u,l.push({transactionHash:o})}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 i=p(this,a,"m",m).bind(this,t,s,n,e),o=p(this,a,"m",u).bind(this,t,s,r,e);p(this,c,"f")[t]={onConfirmed:i,onFailedOrDropped:o},e.hub.on("transaction-confirmed",i),e.hub.on("transaction-failed",o),e.hub.on("transaction-dropped",o)})},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,i){r.id===e&&(w("Transaction failed or dropped",{transactionHash:t,error:i}),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 i=e("./utils/gas-flow.cjs");Object.defineProperty(s,"mergeGasFeeEstimates",{enumerable:!0,get:function(){return i.mergeGasFeeEstimates}});var o=e("./utils/utils.cjs");Object.defineProperty(s,"isEIP1559Transaction",{enumerable:!0,get:function(){return o.isEIP1559Transaction}}),Object.defineProperty(s,"normalizeTransactionParams",{enumerable:!0,get:function(){return o.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,i,o,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.musdClaim="musdClaim",e.musdConversion="musdConversion",e.perpsDeposit="perpsDeposit",e.perpsDepositAndOrder="perpsDepositAndOrder",e.perpsRelayDeposit="perpsRelayDeposit",e.personalSign="personal_sign",e.predictBuy="predictBuy",e.predictClaim="predictClaim",e.predictDeposit="predictDeposit",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"}(i||(s.TransactionContainerType=i={})),function(e){e.legacy="0x0",e.accessList="0x1",e.feeMarket="0x2",e.setCode="0x4"}(o||(s.TransactionEnvelopeType=o={})),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"),i=e("@metamask/metamask-eth-abis"),o=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,o.createModuleLogger)(h.projectLogger,"balance-changes"),k=["Transfer","TransferSingle","TransferBatch","Deposit","Withdrawal"],b={[p.ERC20]:{abi:i.abiERC20,standard:f.SimulationTokenStandard.erc20},[p.ERC721]:{abi:i.abiERC721,standard:f.SimulationTokenStandard.erc721},[p.ERC1155]:{abi:i.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 y(e){if(Array.isArray(e))return e.map(y);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 x(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 _(e){switch(e){case f.SimulationTokenStandard.erc721:return new n.Interface(i.abiERC721);case f.SimulationTokenStandard.erc1155:return new n.Interface(i.abiERC1155);default:return new n.Interface(i.abiERC20)}}function v(e,t,s){const a=_(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 E(e,t,s){const a=_(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 I(e){return[...e.logs??[],...(e.calls??[]).map(e=>I(e)).flat()]}function P(e){if(!e)return[];return[...e.error?[e.error]:[],...(e.calls??[]).flatMap(e=>P(e))]}function S(e,t,s=0){const a=(0,r.hexToBN)(t).add(new c.default(s)),n=(0,r.hexToBN)(e),i=a.sub(n),o=i.isNeg(),l=(0,r.toHex)(i.abs());return i.isZero()?(g("Balance change is zero"),undefined):{previousBalance:e,newBalance:(0,r.toHex)(a),difference:l,isDecrease:o}}async function C({request:e,params:t,before:s=[],after:a=[]}){const{blockTime:n,chainId:i,ethQuery:o,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"),i=(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(i)}(e),w=(0,r.toHex)(b);g("Required balance",w);const{balanceRaw:y}=await(0,l.getNativeBalance)(f,o),T=(0,r.toHex)(y),x=(0,r.hexToBN)(T);g("Current balance",T);const _=x.lt(b);return await(0,d.simulateTransactions)(i,{...t,getSimulationConfig:m,transactions:k,withGas:!0,withDefaultBlockOverrides:!0,...n&&{blockOverrides:{...t?.blockOverrides,time:(0,r.toHex)(n)}},..._&&{overrides:{...t?.overrides,[f]:{...t?.overrides?.[f],balance:w}}}})}s.getBalanceChanges=async function(e){let t;g("Request",e);try{const s=await C({request:e,params:{withCallTrace:!0,withLogs:!0}}),a=s.transactions?.[0];t=P(a?.callTrace);const r=a?.error;if(r)throw new u.SimulationError(r);const i=function(e,t){const s=t.transactions[0];if(!s)return undefined;const{txParams:a}=e,n=a.from,{stateDiff:r}=s,i=r?.pre?.[n]?.balance,o=r?.post?.[n]?.balance;if(!i||!o)return undefined;return S(i,o,s.gasCost)}(e,s),o=function(e){const t=I(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=y(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",o);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,i=t.filter(e=>[e.args.from,e.args.to].includes(r));g("Filtered user events",i);for(const e of i){const t=x(e);g("Extracted token IDs",t);for(const i of t){const t={address:e.contractAddress,standard:e.tokenStandard,id:i},o=JSON.stringify(t);if(s.has(o)){g("Ignoring additional event with same contract and token ID",t);continue}s.add(o);const c=E(e.tokenStandard,r,i),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 i=await C({request:e,before:[...n.before.values()],after:[...n.after.values()]});if(g("Balance simulation response",i),i.transactions.length!==r)throw new u.SimulationInvalidResponseError;let o=0;return[...n.after.keys()].map((e,t)=>{const s=S(!n.before.get(e)?"0x0":v(a,e,i.transactions[o++]),v(a,e,i.transactions[t+n.before.size+1]));return s?{...e,...s}:undefined}).filter(e=>e!==undefined)}(e,o),l=a?.gasUsed;return{simulationData:{callTraceErrors:t,nativeBalanceChange:i,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:i}=await r(s,t);return a.isLessThanOrEqualTo(i)}}}},{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"),i=e("uuid"),o=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,i.v4)(),t=new Uint8Array((0,i.parse)(e));return(0,r.bytesToHex)(t)}async function y(e,t,s,n,r,i){const{assetsFiatValues:o,existingTransaction:c,params:l,type:d}=t,{addTransaction:u,getTransaction:f,request:p,updateTransaction:g}=n,{from:k,networkClientId:w,origin:y}=p;if(c){const{id:t,onPublish:r}=c;let o=f(t);const d=o.txParams.nonce;let{signedTransaction:m}=c;const u=d?parseInt(d,16):undefined,h=i>0&&u!==undefined?u+i: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,o=e.transactionMeta}return s(o,m).then(r).catch(()=>{}),b("Processed existing transaction with hook",{id:t,params:l}),{id:t,params:l}}const x={...r,txParams:{...l,from:k,gas:r?.gas??l.gas}};r&&(0,h.updateTransactionGasEstimates)({txMeta:x,userFeeLevel:m.GasFeeEstimateLevel.Medium});const{transactionMeta:_}=await u(x.txParams,{assetsFiatValues:o,batchId:e,disableGasBuffer:!0,networkClientId:w,origin:y,publishHook:s,requireApproval:!1,type:d}),{id:v,txParams:E}=_,I={data:E.data,gas:E.gas,maxFeePerGas:E.maxFeePerGas,maxPriorityFeePerGas:E.maxPriorityFeePerGas,to:E.to,value:E.value};return b("Processed new transaction with hook",{id:v,params:I,type:d}),{id:v,params:I,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 i=s(t);return b("New signature",r),{newSignature:r,transactionMeta:i}}s.ERROR_MESSAGE_NO_UPGRADE_CONTRACT="Upgrade contract address not found",s.addTransactionBatch=async function(e){const{getInternalAccounts:t,messenger:r,request:i}=e,h=(0,c.getBatchSizeLimit)(r);if((0,d.validateBatchRequest)({internalAccounts:t(),request:i,sizeLimit:h}),b("Adding",i),!i.disable7702)try{return await async function(e){const{addTransaction:t,getChainId:a,messenger:r,publicKeyEIP7702:i,request:l}=e,{batchId:d,disableUpgrade:u,from:h,gasFeeToken:f,gasLimit7702:p,networkClientId:g,origin:y,overwriteUpgrade:x,requestId:_,requiredAssets:v,requireApproval:E,securityAlertId:I,skipInitialGasEstimate:P,transactions:S,validateSecurity:C}=l,j=a(g),A=e.getEthQuery(g),F=(0,o.doesChainSupportEIP7702)(j,r);if(!F)throw b("Chain does not support EIP-7702",j),n.rpcErrors.internal("Chain does not support EIP-7702");if(!i)throw n.rpcErrors.internal(o.ERROR_MESSGE_PUBLIC_KEY);let G=!1;if(!u){const{delegationAddress:e,isSupported:t}=await(0,o.isAccountUpgradedToEIP7702)(h,j,i,r,A);if(b("Account",{delegationAddress:e,isSupported:t}),!t&&e&&!x)throw b("Account upgraded to unsupported contract",h,e),n.rpcErrors.internal("Account upgraded to unsupported contract");G=!t,G&&e&&b("Overwriting authorization as already upgraded",{current:e})}const M=await Promise.all(S.map(e=>async function(e,t,s){const{from:a}=e,{params:n,type:r}=t;if(r)return{...n,type:r};const{type:i}=await(0,m.determineTransactionType)({from:a,...n},s);return{...n,type:i}}(l,e,A))),D={...(0,o.generateEIP7702BatchTransaction)(h,M),from:h,gas:p,maxFeePerGas:M[0]?.maxFeePerGas,maxPriorityFeePerGas:M[0]?.maxPriorityFeePerGas};if(G){const e=(0,c.getEIP7702UpgradeContractAddress)(j,r,i);if(!e)throw n.rpcErrors.internal(s.ERROR_MESSAGE_NO_UPGRADE_CONTRACT);D.type=k.TransactionEnvelopeType.setCode,D.authorizationList=[{address:e}]}if(C){const e={method:"eth_sendTransaction",params:[{...D,authorizationList:undefined,type:k.TransactionEnvelopeType.feeMarket}],delegationMock:D.authorizationList?.[0]?.address,origin:y};b("Security request",e),C(e,j).catch(e=>{b("Security validation failed",e)})}b("Adding batch transaction",D,g);const N=d??w(),O=I?{securityAlertId:I}:undefined,L=S.find(e=>e.existingTransaction)?.existingTransaction;if(L)return await async function({batchId:e,existingTransaction:t,nestedTransactions:s,request:a,txParams:n}){const{getTransaction:r,estimateGas:i,updateTransaction:o}=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 i(n,l);b("Estimated gas for converted EIP-7702 transaction",d),o({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:N,existingTransaction:L,nestedTransactions:M,request:e,txParams:D}),{batchId:N};const{result:B}=await t(D,{batchId:N,gasFeeToken:f,isGasFeeIncluded:l.isGasFeeIncluded,isGasFeeSponsored:l.isGasFeeSponsored,nestedTransactions:M,networkClientId:g,origin:y,requestId:_,requireApproval:E,requiredAssets:v,securityAlertResponse:O,skipInitialGasEstimate:P,type:k.TransactionType.batch}),R=await B;return b("Batch transaction added",{batchId:N,transactionHash:R}),{batchId:N}}(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:i}=e,{batchId:o,from:c,networkClientId:d,origin:h,requireApproval:g,transactions:k}=r;let T,x=!1;b("Adding transaction batch using hook",r);const _=new p.SequentialPublishBatchHook({publishTransaction:e.publishTransaction,getTransaction:e.getTransaction,getEthQuery:e.getEthQuery,getPendingTransactionTracker:e.getPendingTransactionTracker});let{disable7702:v,disableSequential:E}=r;const{disableHook:I,useHook:P}=r;P&&(v=!0,E=!0);let S,C=null;!I&&s?C=s:E||(C=_.getHook(),x=!0);if(!C)throw b("No supported batch methods found",{disable7702:v,disableHook:I,disableSequential:E}),n.rpcErrors.internal("Can't process batch");const j=o??w(),A=k.map(e=>({...e,origin:h})),F=A.length,G=new f.CollectPublishHook(F);try{g&&(S=await async function({batchId:e,request:t}){const{messenger:s,request:a,isSimulationEnabled:n,getChainId:r,getEthQuery:i,getGasFeeEstimates:o,getSimulationConfig:c,update:d}=t,{from:h,origin:f,networkClientId:p,transactions:g}=a,k=i(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:y}=await(0,l.simulateGasBatch)({chainId:w,from:h,getSimulationConfig:c,transactions:g}),T=(E={chainId:w,from:h,gas:y,id:e,networkClientId:p,origin:f,transactions:g},{...E,status:m.TransactionStatus.unapproved}),x=new u.DefaultGasFeeFlow,_=await o({networkClientId:p}),v=await x.getGasFees({ethQuery:k,gasFeeControllerData:_,messenger:s,transactionMeta:{...T,txParams:{from:h,gas:y},time:Date.now()}});var E;return T.gasFeeEstimates=v.estimates,b("Saving transaction batch metadata",T),function(e,t){t(t=>{t.transactionBatches=[...t.transactionBatches,e]})}(T,d),T}({batchId:j,request:e}),T=(await async function(e,t){const s=String(e.id),{origin:n}=e,r=a.ApprovalType.TransactionBatch,i={txBatchId:s};return b("Requesting approval for transaction batch",s),await t.call("ApprovalController:addRequest",{id:s,origin:n??a.ORIGIN_METAMASK,requestData:i,expectsResult:!0,type:r},!0)}(S,t)).resultCallbacks);const s=G.getHook(),n=[];let r=0;for(const t of A){const a=await y(j,t,s,e,S,r);n.push(a),r+=1}const{signedTransactions:i}=await G.ready(),o={from:c,networkClientId:d,transactions:n.map((e,t)=>({...e,signedTx:i[t]}))};b("Calling publish batch hook",o);let h=await C(o);if(b("Publish batch hook result",h),!h&&!x&&!E){b("Fallback to sequential publish batch hook due to empty results");const e=_.getHook();h=await e(o)}if(!h?.results?.length)throw new Error("Publish batch hook did not return a result");const f=h.results.map(({transactionHash:e})=>e);return G.success(f),T?.success(),b("Completed batch transaction with hook",f),{batchId:j}}catch(e){throw b("Publish batch hook failed",e),G.error(e),T?.error(e),e}finally{b("Cleaning up publish batch hook",j),function(e,t){e(e=>{e.transactionBatches=e.transactionBatches.filter(e=>e.id!==t)})}(i,j)}}(e)},s.isAtomicBatchSupported=async function(e){const{address:t,chainIds:s,getEthQuery:a,messenger:r,publicKeyEIP7702:i}=e;if(!i)throw n.rpcErrors.internal(o.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,o.isAccountUpgradedToEIP7702)(t,e,i,r,s);return{chainId:e,delegationAddress:l,isSupported:n,upgradeContractAddress:(0,c.getEIP7702UpgradeContractAddress)(e,r,i)}}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"),i=e("@metamask/utils"),o=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,i.createModuleLogger)(l.projectLogger,"eip-7702");async function m(e,t){const a=await(0,r.query)(t,"eth_getCode",[e]),n=(0,i.add0x)(a?.toLowerCase?.()??"");return 48===a?.length&&n.startsWith(s.DELEGATION_PREFIX)?(0,i.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:i,chainId:o}=t,{nonce:c}=i,l=a??o;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:o}=t,{from:c}=o,{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,i.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,o.getEIP7702SupportedChains)(t).some(t=>t.toLowerCase()===e.toLowerCase())},s.getDelegationAddress=m,s.isAccountUpgradedToEIP7702=async function(e,t,s,a,n){const r=(0,o.getEIP7702ContractAddresses)(t,a,s),i=await m(e,n),c=Boolean(i&&r.some(e=>e.toLowerCase()===i.toLowerCase()));return{delegationAddress:i,isSupported:c}},s.generateEIP7702BatchTransaction=function(e,t){const r=n.Contract.getInterface(c.ABI_IERC7821),i=t.map(e=>{const{data:t,to:s,value:a}=e;return[s??"0x0000000000000000000000000000000000000000",a??"0x0",t??"0x"]}),o="0x01".padEnd(66,"0"),l=a.defaultAbiCoder.encode([s.CALLS_SIGNATURE],[i]),m=r.encodeFunctionData(s.BATCH_FUNCTION_NAME,[o,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"),i=e("../logger.cjs");var o;!function(e){e.EIP7702="confirmations_eip_7702",e.GasBuffer="confirmations_gas_buffer",e.IncomingTransactions="confirmations_incoming_transactions",e.Transactions="confirmations_transactions"}(o||(s.FeatureFlag=o={}));const c=(0,a.createModuleLogger)(i.projectLogger,"feature-flags");function l(e,t,s){const a=d(t);return(a?.[o.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?.[o.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?.[o.Transactions]?.batchSizeLimit??10},s.getSubmitHistoryLimit=function(e){const t=d(e);return t?.[o.Transactions]?.submitHistoryLimit??100},s.getTransactionHistoryLimit=function(e){const t=d(e);return t?.[o.Transactions]?.transactionHistoryLimit??40},s.getAcceleratedPollingParams=function(e,t){const s=d(t),a=s?.[o.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?.[o.Transactions]?.gasFeeRandomisation??{};return{randomisedGasFeeDigits:s.randomisedGasFeeDigits??{},preservedNumberOfDigits:s.preservedNumberOfDigits}},s.getGasEstimateFallback=function(e,t){const s=d(t),a=s?.[o.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?.[o.GasBuffer],i=r?.perChainConfig?.[e],c=t?undefined:i?.included,l=t?undefined:r?.included;return(s?i?.eip7702:undefined)??c??i?.base??l??r?.default??1},s.getIncomingTransactionsPollingInterval=function(e){const t=d(e);return t?.[o.IncomingTransactions]?.pollingIntervalMs??24e4},s.getTimeoutAttempts=function(e,t){const s=d(t),a=s?.[o.Transactions]?.timeoutAttempts;return a?.perChainConfig?.[e]??a?.default},s.isIncomingTransactionsUseBackendWebSocketServiceEnabled=function(e){const t=d(e);return t?.[o.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"),i=e("../api/accounts-api.cjs"),o=e("../logger.cjs"),c=e("../types.cjs");s.updateFirstTimeInteraction=async function({existingTransactions:e,getTransaction:t,isFirstTimeInteractionEnabled:s,trace:l,traceContext:d,transactionMeta:m,updateTransaction:u}){if(!s())return;const{chainId:h,id:f,txParams:{data:p,from:g,to:k},type:b}=m;let w;if(p&&[c.TransactionType.tokenMethodTransfer,c.TransactionType.tokenMethodTransferFrom].includes(b)){const e=(0,n.decodeTransactionData)(p);w=e?.args?._to??e?.args?.to}w??(w=k);const y={chainId:(0,a.hexToNumber)(h),to:w,from:g};if((0,r.validateParamTo)(w),!e.find(e=>e.chainId===h&&e.txParams.from.toLowerCase()===g.toLowerCase()&&e.txParams.to?.toLowerCase()===k?.toLowerCase()&&e.id!==f))try{const{count:e}=await l({name:"Account Address Relationship",parentContext:d},()=>(0,i.getAccountAddressRelationship)(y)),s=e===undefined?undefined:0===e;if(!t(f))return void(0,o.projectLogger)("Cannot update first time interaction as transaction not found",f);u({transactionId:f,note:"TransactionController#updateFirstInteraction - Update first time interaction"},e=>{e.isFirstTimeInteraction=s}),(0,o.projectLogger)("Updated first time interaction",f,{isFirstTimeInteraction:s})}catch(e){(0,o.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"),i=e("./batch.cjs"),o=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,o.doesChainSupportEIP7702)(e,s);let y=f?.map(e=>({address:e.address,from:g}));!w||u||y||(y=function({chainId:e,from:t,messenger:s,publicKeyEIP7702:n}){if(!n)throw a.rpcErrors.internal(o.ERROR_MESSGE_PUBLIC_KEY);const r=(0,c.getEIP7702UpgradeContractAddress)(e,s,n);if(!r)throw a.rpcErrors.internal(i.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:y,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:i}=s;if(!i||!n)return;if(m("Checking gas fee token before publish",{selectedGasFeeToken:i}),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 o=await t({...s,isExternalSign:!0});if(a(s.id,e=>{e.gasFeeTokens=o,e.isExternalSign=!0,e.txParams.nonce=undefined}),m("Updated gas fee tokens before publish",o),!o?.some(e=>e.tokenAddress.toLowerCase()===i.toLowerCase()))throw new Error("Gas fee token not found and insufficient native balance");m("Publishing with selected gas fee token",{selectedGasFeeToken:i})}}}},{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"),i=e("./swaps.cjs"),o=e("../logger.cjs"),c=e("../types.cjs"),l=(0,n.createModuleLogger)(o.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},o=i.SWAP_TRANSACTION_TYPES.includes(t.type)?undefined:e.getSavedGasFees(t.chainId),m=await async function(e){const{eip1559:t,ethQuery:s,gasFeeFlows:i,getGasFeeEstimates:o,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,i,d);try{const e=await o({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:o,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],i=t[n],{...r,suggestedMaxFeePerGas:(0,a.weiHexToGweiDec)(i.maxFeePerGas),suggestedMaxPriorityFeePerGas:(0,a.weiHexToGweiDec)(i.maxPriorityFeePerGas)})};var r,i},{...e}):s===n.GasFeeEstimateType.Legacy?Object.values(n.GasFeeEstimateLevel).reduce((e,s)=>({...e,[s]:r(t,s)}),{}):s===n.GasFeeEstimateType.GasPrice?{gasPrice:(i=t,(0,a.weiHexToGweiDec)(i.gasPrice))}:e;var i}}}},{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"),i=e("./eip7702.cjs"),o=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:i,getSimulationConfig:c,messenger:l,txParams:m}){const u={...m},{authorizationList:h,data:g,from:k,value:b,to:w}=u;if(r&&!i)throw new Error("Gas estimation with ignored delegation signatures is not supported as simulation disabled");const{gasLimit:y,number:T}=await async function(e){return await(0,a.query)(e,"getBlockByNumber",["latest",!1])}(t),x=(0,a.hexToBN)(y),{percentage:_,fixed:v}=(0,o.getGasEstimateFallback)(e,l),E=v?(0,a.toHex)(v):(0,a.BNToHex)((0,a.fractionBN)(x,_,100));(0,s.log)("Estimation fallback values",E),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 I,P=E;const S=m.type===d.TransactionEnvelopeType.setCode&&Boolean(h?.length)&&Boolean(g)&&"0x"!==g&&k?.toLowerCase()===w?.toLowerCase();try{P=i&&S?await async function(e,t,n,r){const i=await(0,a.query)(t,"estimateGas",[{...e,data:"0x"}]);(0,s.log)("Upgrade only gas",i);const o=e.authorizationList?.[0].address;let c;try{c=await f({chainId:n,delegationAddress:o,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},o)}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)(i).add((0,a.hexToBN)(c)).subn(s.INTRINSIC_GAS));return(0,s.log)("Total type 4 gas",l),l}(u,t,e,c):r&&i?await f({chainId:e,getSimulationConfig:c,transaction:u}):await p(t,u)}catch(e){I={reason:e.message,errorKey:e.errorKey,debug:{blockNumber:T,blockGasLimit:y}},(0,s.log)("Estimation failed",{...I,fallback:E})}return{blockGasLimit:y,estimatedGas:P,isUpgradeWithDataToSelf:S,simulationFails:I}}function u(e,t,r){const i=(0,a.hexToBN)(e),o=(0,a.fractionBN)((0,a.hexToBN)(t),s.MAX_GAS_BLOCK_PERCENT,100),c=(0,a.fractionBN)(i,100*r,100);if(i.gt(o)){const t=(0,n.add0x)(e);return(0,s.log)("Using estimated value",t),t}if(c.lt(o)){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)(o));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&&i.DELEGATION_PREFIX+(0,n.remove0x)(t)}}}),o=r?.transactions?.[0].gasLimit;if(!o)throw new Error("No simulated gas returned");return o}function p(e,t,s){const{from:r}=t,o=[t];return s&&(o.push("latest"),o.push({[r]:{code:i.DELEGATION_PREFIX+(0,n.remove0x)(s)}})),(0,a.query)(e,"estimateGas",o)}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,i,c]=await async function(e){const{chainId:t,isCustomNetwork:n,isSimulationEnabled:r,getSimulationConfig:i,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:i}}=t;if(s||!n||r||i===d.TransactionEnvelopeType.setCode)return!1;const o=await async function(e,t){return await(0,a.query)(e,"getCode",[t])}(e,n);return!o||"0x"===o}(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:i,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,o.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=i,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:o,messenger:c,transactions:l}){const u=(await o({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 o=f?[{address:u.upgradeContractAddress}]:undefined,h=f?d.TransactionEnvelopeType.setCode:undefined,p={...(0,i.generateEIP7702BatchTransaction)(a,l),authorizationList:o,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 i({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 i(e);if(!t)return;const{transactionMeta:s}=e;s.layer1GasFee=t,r("Updated layer 1 gas fee",t,s.id)},s.getTransactionLayer1GasFee=i}}},{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:i,nonce:o}}=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(o)return r("Using existing nonce",o),[o,undefined];const l=await t(i),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:i,txParams:{from:o,nonce:c}})=>!n&&!r&&a===e&&s.includes(i)&&o.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"),i=e("lodash");function o(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,i.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:o(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 i=r(a,t),o=r(n,t);return{maxFeePerGas:i,maxPriorityFeePerGas:o}}(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("")),i=(0,n.hexToBytes)(r);return(0,a.verifyMessage)(i,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"),i=e("../constants.cjs"),o=e("../logger.cjs"),c=e("../types.cjs"),l=(0,o.createModuleLogger)(o.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},y={name:"Sei",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},T={name:"Mon",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18},x={name:"Hyperliquid",address:s.DEFAULT_TOKEN_ADDRESS,decimals:18};function _(e,t){return!(!e||!t)&&e===s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP[t]?.address}function v(e){return new Promise(t=>setTimeout(t,e))}s.SWAPS_CHAINID_DEFAULT_TOKEN_MAP={[i.CHAIN_IDS.MAINNET]:m,[d]:p,[i.CHAIN_IDS.BSC]:u,[i.CHAIN_IDS.POLYGON]:h,[i.CHAIN_IDS.GOERLI]:g,[i.CHAIN_IDS.AVALANCHE]:f,[i.CHAIN_IDS.OPTIMISM]:b,[i.CHAIN_IDS.ARBITRUM]:k,[i.CHAIN_IDS.ZKSYNC_ERA]:w,[i.CHAIN_IDS.SEI]:y,[i.CHAIN_IDS.MONAD]:T,[i.CHAIN_IDS.HYPEREVM]:x},s.SWAP_TRANSACTION_TYPES=[c.TransactionType.swap,c.TransactionType.swapAndSend,c.TransactionType.swapApproval],s.updateSwapsTransaction=function(e,t,a,{isSwapsDisabled:i,cancelTransaction:o,messenger:l}){if(i||!s.SWAP_TRANSACTION_TYPES.includes(t))return e;if(t===c.TransactionType.swap&&!1===a?.hasApproveTx&&e.simulationFails)throw o(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:i,destinationTokenSymbol:o,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:i,destinationTokenSymbol:o,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:i,destinationTokenAddress:o,swapMetaData:c,swapTokenValue:l,estimatedBaseFee:d,approvalTxId:m}){(0,r.validateIfTransactionUnapproved)(e,"updateSwapTransaction");let u={sourceTokenSymbol:t,destinationTokenSymbol:s,type:a,destinationTokenDecimals:i,destinationTokenAddress:o,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 i=e.id;let o,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]);o={...n(i)??{}},c=o.approvalTxId?n(o.approvalTxId):undefined,o.postTxBalance=d.toString(16);const m=_(e.destinationTokenAddress,e.chainId);if(!m||e.preTxBalance!==o.postTxBalance){l("Finishing post balance update",{isDefaultTokenAddress:m,preTxBalance:e.preTxBalance,postTxBalance:o.postTxBalance});break}l("Waiting for balance to update",{delay:s.UPDATE_POST_TX_BALANCE_TIMEOUT}),await v(s.UPDATE_POST_TX_BALANCE_TIMEOUT)}return r(o,"TransactionController#updatePostTransactionBalance - Add post transaction balance"),l("Completed post balance update",o?.postTxBalance),{updatedTransactionMeta:o,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"),i=e("./eip7702.cjs"),o=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:o.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(i.DELEGATION_PREFIX));return{contractCode:s,isContractAddress:a}}(t,a);r=e.contractCode,c=e.isContractAddress}if(!c)return{type:o.TransactionType.simpleSend,getCodeResponse:r};const l=0!==Number(e.value??"0"),d={type:o.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=[o.TransactionType.tokenMethodApprove,o.TransactionType.tokenMethodSetApprovalForAll,o.TransactionType.tokenMethodTransfer,o.TransactionType.tokenMethodTransferFrom,o.TransactionType.tokenMethodSafeTransferFrom,o.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.validateIfTransactionUnapproved=s.validateGasValues=s.isEIP1559Transaction=s.normalizeTransactionParams=s.ESTIMATE_GAS_ERROR=void 0;const n=e("@metamask/controller-utils"),r=e("@metamask/utils"),i=a(e("bn.js")),o=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 i.default(0):new i.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!==o.TransactionStatus.unapproved)throw new Error(`TransactionsController: Can only call ${t} on an unapproved 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 i.default)return e;if("function"==typeof i.default.isBN&&i.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 i.default(e.toString());if("number"==typeof e)return new i.default(e);throw new Error("Unexpected value returned from oracle contract")},s.getPercentageChange=function(e,t){const s=new i.default(10).pow(new i.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=o.TransactionEnvelopeType.accessList:e.authorizationList?e.type=o.TransactionEnvelopeType.setCode:e.type=t?o.TransactionEnvelopeType.feeMarket:o.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"),i=e("@metamask/rpc-errors"),o=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 i.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 i.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 i.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 i.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,o.isStrictHexString)(s))throw i.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,o.remove0x)(e).length/2;if(a!==t)throw i.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 i.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:o,type:c}){if(!a||a===n.ORIGIN_METAMASK)return;const{authorizationList:d,to:m,type:u}=o;if(r&&!r.includes(t))throw i.providerErrors.unauthorized({data:{origin:a}});if(c===l.TransactionType.batch)return;if(d||u===l.TransactionEnvelopeType.setCode)throw i.rpcErrors.invalidParams("External EIP-7702 transactions are not supported");if(Boolean(e&&"0x"!==e)&&s?.some(e=>e.toLowerCase()===m?.toLowerCase()))throw i.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 i.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 i.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 i.rpcErrors.invalidParams(`Invalid "from" address ${e}: not a string.`);if(!(0,n.isValidHexAddress)(e))throw i.rpcErrors.invalidParams('Invalid "from" address.')}(e.from),function(e){if("0x"===e.to||e.to===undefined){if(!e.data)throw i.rpcErrors.invalidParams('Invalid "to" address.');delete e.to}else if(e.to!==undefined&&!(0,n.isValidHexAddress)(e.to))throw i.rpcErrors.invalidParams('Invalid "to" address.')}(e),function(e){if(e!==undefined){if(e.includes("-"))throw i.rpcErrors.invalidParams(`Invalid transaction value "${e}": not a positive number.`);if(e.includes("."))throw i.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 i.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 i.rpcErrors.invalidParams("Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.")}}}(e.data),function(e,t){if(e&&t&&e.toLowerCase?.()!==t.toLowerCase())throw i.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 i.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 i.rpcErrors.invalidParams('Invalid "to" address')},s.validateBatchRequest=function({internalAccounts:e,request:t,sizeLimit:s}){const{origin:a}=t,r=a&&a!==n.ORIGIN_METAMASK,o=e.map(e=>e.toLowerCase());if(r&&t.transactions.some(e=>{const t=e.params.to?.toLowerCase(),s=e.params.data,a=o.includes(t),n=Boolean(s&&"0x"!==s);return a&&n}))throw i.rpcErrors.invalidParams("External calls to internal accounts cannot include data");if(r&&t.transactions.length>s)throw new i.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"}],["/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){!function(e){var s,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,r=Math.floor,i="[BigNumber Error] ",o=i+"Number primitive has more than 15 significant digits: ",c=1e14,l=14,d=9007199254740991,m=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],u=1e7,h=1e9;function f(e){var t=0|e;return e>0||e===t?t:t-1}function p(e){for(var t,s,a=1,n=e.length,r=e[0]+"";a<n;){for(t=e[a++]+"",s=l-t.length;s--;t="0"+t);r+=t}for(n=r.length;48===r.charCodeAt(--n););return r.slice(0,n+1||1)}function g(e,t){var s,a,n=e.c,r=t.c,i=e.s,o=t.s,c=e.e,l=t.e;if(!i||!o)return null;if(s=n&&!n[0],a=r&&!r[0],s||a)return s?a?0:-o:i;if(i!=o)return i;if(s=i<0,a=c==l,!n||!r)return a?0:!n^s?1:-1;if(!a)return c>l^s?1:-1;for(o=(c=n.length)<(l=r.length)?c:l,i=0;i<o;i++)if(n[i]!=r[i])return n[i]>r[i]^s?1:-1;return c==l?0:c>l^s?1:-1}function k(e,t,s,a){if(e<t||e>s||e!==r(e))throw Error(i+(a||"Argument")+("number"==typeof e?e<t||e>s?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return f(e.e/l)==t&&e.c[t]%2!=0}function w(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function y(e,t,s){var a,n;if(t<0){for(n=s+".";++t;n+=s);e=n+e}else if(++t>(a=e.length)){for(n=s,t-=a;--t;n+=s);e+=n}else t<a&&(e=e.slice(0,t)+"."+e.slice(t));return e}s=function e(t){var s,T,x,_,v,E,I,P,S,C,j=W.prototype={constructor:W,toString:null,valueOf:null},A=new W(1),F=20,G=4,M=-7,D=21,N=-1e7,O=1e7,L=!1,B=1,R=0,H={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},U="0123456789abcdefghijklmnopqrstuvwxyz",q=!0;function W(e,t){var s,n,i,c,m,u,h,f,p=this;if(!(p instanceof W))return new W(e,t);if(null==t){if(e&&!0===e._isBigNumber)return p.s=e.s,void(!e.c||e.e>O?p.c=p.e=null:e.e<N?p.c=[p.e=0]:(p.e=e.e,p.c=e.c.slice()));if((u="number"==typeof e)&&0*e==0){if(p.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,m=e;m>=10;m/=10,c++);return void(c>O?p.c=p.e=null:(p.e=c,p.c=[e]))}f=String(e)}else{if(!a.test(f=String(e)))return x(p,f,u);p.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(c=f.indexOf("."))>-1&&(f=f.replace(".","")),(m=f.search(/e/i))>0?(c<0&&(c=m),c+=+f.slice(m+1),f=f.substring(0,m)):c<0&&(c=f.length)}else{if(k(t,2,U.length,"Base"),10==t&&q)return z(p=new W(e),F+p.e+1,G);if(f=String(e),u="number"==typeof e){if(0*e!=0)return x(p,f,u,t);if(p.s=1/e<0?(f=f.slice(1),-1):1,W.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(o+e)}else p.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(s=U.slice(0,t),c=m=0,h=f.length;m<h;m++)if(s.indexOf(n=f.charAt(m))<0){if("."==n){if(m>c){c=h;continue}}else if(!i&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){i=!0,m=-1,c=0;continue}return x(p,String(e),u,t)}u=!1,(c=(f=T(f,t,10,p.s)).indexOf("."))>-1?f=f.replace(".",""):c=f.length}for(m=0;48===f.charCodeAt(m);m++);for(h=f.length;48===f.charCodeAt(--h););if(f=f.slice(m,++h)){if(h-=m,u&&W.DEBUG&&h>15&&(e>d||e!==r(e)))throw Error(o+p.s*e);if((c=c-m-1)>O)p.c=p.e=null;else if(c<N)p.c=[p.e=0];else{if(p.e=c,p.c=[],m=(c+1)%l,c<0&&(m+=l),m<h){for(m&&p.c.push(+f.slice(0,m)),h-=l;m<h;)p.c.push(+f.slice(m,m+=l));m=l-(f=f.slice(m)).length}else m-=h;for(;m--;f+="0");p.c.push(+f)}}else p.c=[p.e=0]}function $(e,t,s,a){var n,r,i,o,c;if(null==s?s=G:k(s,0,8),!e.c)return e.toString();if(n=e.c[0],i=e.e,null==t)c=p(e.c),c=1==a||2==a&&(i<=M||i>=D)?w(c,i):y(c,i,"0");else if(r=(e=z(new W(e),t,s)).e,o=(c=p(e.c)).length,1==a||2==a&&(t<=r||r<=M)){for(;o<t;c+="0",o++);c=w(c,r)}else if(t-=i+(2===a&&r>i),c=y(c,r,"0"),r+1>o){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=r-o)>0)for(r+1==o&&(c+=".");t--;c+="0");return e.s<0&&n?"-"+c:c}function K(e,t){for(var s,a,n=1,r=new W(e[0]);n<e.length;n++)(!(a=new W(e[n])).s||(s=g(r,a))===t||0===s&&r.s===t)&&(r=a);return r}function V(e,t,s){for(var a=1,n=t.length;!t[--n];t.pop());for(n=t[0];n>=10;n/=10,a++);return(s=a+s*l-1)>O?e.c=e.e=null:s<N?e.c=[e.e=0]:(e.e=s,e.c=t),e}function z(e,t,s,a){var i,o,d,u,h,f,p,g=e.c,k=m;if(g){e:{for(i=1,u=g[0];u>=10;u/=10,i++);if((o=t-i)<0)o+=l,d=t,h=g[f=0],p=r(h/k[i-d-1]%10);else if((f=n((o+1)/l))>=g.length){if(!a)break e;for(;g.length<=f;g.push(0));h=p=0,i=1,d=(o%=l)-l+1}else{for(h=u=g[f],i=1;u>=10;u/=10,i++);p=(d=(o%=l)-l+i)<0?0:r(h/k[i-d-1]%10)}if(a=a||t<0||null!=g[f+1]||(d<0?h:h%k[i-d-1]),a=s<4?(p||a)&&(0==s||s==(e.s<0?3:2)):p>5||5==p&&(4==s||a||6==s&&(o>0?d>0?h/k[i-d]:0:g[f-1])%10&1||s==(e.s<0?8:7)),t<1||!g[0])return g.length=0,a?(t-=e.e+1,g[0]=k[(l-t%l)%l],e.e=-t||0):g[0]=e.e=0,e;if(0==o?(g.length=f,u=1,f--):(g.length=f+1,u=k[l-o],g[f]=d>0?r(h/k[i-d]%k[d])*u:0),a)for(;;){if(0==f){for(o=1,d=g[0];d>=10;d/=10,o++);for(d=g[0]+=u,u=1;d>=10;d/=10,u++);o!=u&&(e.e++,g[0]==c&&(g[0]=1));break}if(g[f]+=u,g[f]!=c)break;g[f--]=0,u=1}for(o=g.length;0===g[--o];g.pop());}e.e>O?e.c=e.e=null:e.e<N&&(e.c=[e.e=0])}return e}function Y(e){var t,s=e.e;return null===s?e.toString():(t=p(e.c),t=s<=M||s>=D?w(t,s):y(t,s,"0"),e.s<0?"-"+t:t)}return W.clone=e,W.ROUND_UP=0,W.ROUND_DOWN=1,W.ROUND_CEIL=2,W.ROUND_FLOOR=3,W.ROUND_HALF_UP=4,W.ROUND_HALF_DOWN=5,W.ROUND_HALF_EVEN=6,W.ROUND_HALF_CEIL=7,W.ROUND_HALF_FLOOR=8,W.EUCLID=9,W.config=W.set=function(e){var t,s;if(null!=e){if("object"!=typeof e)throw Error(i+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(k(s=e[t],0,h,t),F=s),e.hasOwnProperty(t="ROUNDING_MODE")&&(k(s=e[t],0,8,t),G=s),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((s=e[t])&&s.pop?(k(s[0],-h,0,t),k(s[1],0,h,t),M=s[0],D=s[1]):(k(s,-h,h,t),M=-(D=s<0?-s:s))),e.hasOwnProperty(t="RANGE"))if((s=e[t])&&s.pop)k(s[0],-h,-1,t),k(s[1],1,h,t),N=s[0],O=s[1];else{if(k(s,-h,h,t),!s)throw Error(i+t+" cannot be zero: "+s);N=-(O=s<0?-s:s)}if(e.hasOwnProperty(t="CRYPTO")){if((s=e[t])!==!!s)throw Error(i+t+" not true or false: "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!s,Error(i+"crypto unavailable");L=s}else L=s}if(e.hasOwnProperty(t="MODULO_MODE")&&(k(s=e[t],0,9,t),B=s),e.hasOwnProperty(t="POW_PRECISION")&&(k(s=e[t],0,h,t),R=s),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(s=e[t]))throw Error(i+t+" not an object: "+s);H=s}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(s=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(s))throw Error(i+t+" invalid: "+s);q="0123456789"==s.slice(0,10),U=s}}return{DECIMAL_PLACES:F,ROUNDING_MODE:G,EXPONENTIAL_AT:[M,D],RANGE:[N,O],CRYPTO:L,MODULO_MODE:B,POW_PRECISION:R,FORMAT:H,ALPHABET:U}},W.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!W.DEBUG)return!0;var t,s,a=e.c,n=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(a)){if((1===o||-1===o)&&n>=-h&&n<=h&&n===r(n)){if(0===a[0]){if(0===n&&1===a.length)return!0;break e}if((t=(n+1)%l)<1&&(t+=l),String(a[0]).length==t){for(t=0;t<a.length;t++)if((s=a[t])<0||s>=c||s!==r(s))break e;if(0!==s)return!0}}}else if(null===a&&null===n&&(null===o||1===o||-1===o))return!0;throw Error(i+"Invalid BigNumber: "+e)},W.maximum=W.max=function(){return K(arguments,-1)},W.minimum=W.min=function(){return K(arguments,1)},W.random=(_=9007199254740992,v=Math.random()*_&2097151?function(){return r(Math.random()*_)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,s,a,o,c,d=0,u=[],f=new W(A);if(null==e?e=F:k(e,0,h),o=n(e/l),L)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));d<o;)(c=131072*t[d]+(t[d+1]>>>11))>=9e15?(s=crypto.getRandomValues(new Uint32Array(2)),t[d]=s[0],t[d+1]=s[1]):(u.push(c%1e14),d+=2);d=o/2}else{if(!crypto.randomBytes)throw L=!1,Error(i+"crypto unavailable");for(t=crypto.randomBytes(o*=7);d<o;)(c=281474976710656*(31&t[d])+1099511627776*t[d+1]+4294967296*t[d+2]+16777216*t[d+3]+(t[d+4]<<16)+(t[d+5]<<8)+t[d+6])>=9e15?crypto.randomBytes(7).copy(t,d):(u.push(c%1e14),d+=7);d=o/7}if(!L)for(;d<o;)(c=v())<9e15&&(u[d++]=c%1e14);for(o=u[--d],e%=l,o&&e&&(c=m[l-e],u[d]=r(o/c)*c);0===u[d];u.pop(),d--);if(d<0)u=[a=0];else{for(a=-1;0===u[0];u.splice(0,1),a-=l);for(d=1,c=u[0];c>=10;c/=10,d++);d<l&&(a-=l-d)}return f.e=a,f.c=u,f}),W.sum=function(){for(var e=1,t=arguments,s=new W(t[0]);e<t.length;)s=s.plus(t[e++]);return s},T=function(){var e="0123456789";function t(e,t,s,a){for(var n,r,i=[0],o=0,c=e.length;o<c;){for(r=i.length;r--;i[r]*=t);for(i[0]+=a.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>s-1&&(null==i[n+1]&&(i[n+1]=0),i[n+1]+=i[n]/s|0,i[n]%=s)}return i.reverse()}return function(a,n,r,i,o){var c,l,d,m,u,h,f,g,k=a.indexOf("."),b=F,w=G;for(k>=0&&(m=R,R=0,a=a.replace(".",""),h=(g=new W(n)).pow(a.length-k),R=m,g.c=t(y(p(h.c),h.e,"0"),10,r,e),g.e=g.c.length),d=m=(f=t(a,n,r,o?(c=U,e):(c=e,U))).length;0==f[--m];f.pop());if(!f[0])return c.charAt(0);if(k<0?--d:(h.c=f,h.e=d,h.s=i,f=(h=s(h,g,b,w,r)).c,u=h.r,d=h.e),k=f[l=d+b+1],m=r/2,u=u||l<0||null!=f[l+1],u=w<4?(null!=k||u)&&(0==w||w==(h.s<0?3:2)):k>m||k==m&&(4==w||u||6==w&&1&f[l-1]||w==(h.s<0?8:7)),l<1||!f[0])a=u?y(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(f.length=l,u)for(--r;++f[--l]>r;)f[l]=0,l||(++d,f=[1].concat(f));for(m=f.length;!f[--m];);for(k=0,a="";k<=m;a+=c.charAt(f[k++]));a=y(a,d,c.charAt(0))}return a}}(),s=function(){function e(e,t,s){var a,n,r,i,o=0,c=e.length,l=t%u,d=t/u|0;for(e=e.slice();c--;)o=((n=l*(r=e[c]%u)+(a=d*r+(i=e[c]/u|0)*l)%u*u+o)/s|0)+(a/u|0)+d*i,e[c]=n%s;return o&&(e=[o].concat(e)),e}function t(e,t,s,a){var n,r;if(s!=a)r=s>a?1:-1;else for(n=r=0;n<s;n++)if(e[n]!=t[n]){r=e[n]>t[n]?1:-1;break}return r}function s(e,t,s,a){for(var n=0;s--;)e[s]-=n,n=e[s]<t[s]?1:0,e[s]=n*a+e[s]-t[s];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(a,n,i,o,d){var m,u,h,p,g,k,b,w,y,T,x,_,v,E,I,P,S,C=a.s==n.s?1:-1,j=a.c,A=n.c;if(!(j&&j[0]&&A&&A[0]))return new W(a.s&&n.s&&(j?!A||j[0]!=A[0]:A)?j&&0==j[0]||!A?0*C:C/0:NaN);for(y=(w=new W(C)).c=[],C=i+(u=a.e-n.e)+1,d||(d=c,u=f(a.e/l)-f(n.e/l),C=C/l|0),h=0;A[h]==(j[h]||0);h++);if(A[h]>(j[h]||0)&&u--,C<0)y.push(1),p=!0;else{for(E=j.length,P=A.length,h=0,C+=2,(g=r(d/(A[0]+1)))>1&&(A=e(A,g,d),j=e(j,g,d),P=A.length,E=j.length),v=P,x=(T=j.slice(0,P)).length;x<P;T[x++]=0);S=A.slice(),S=[0].concat(S),I=A[0],A[1]>=d/2&&I++;do{if(g=0,(m=t(A,T,P,x))<0){if(_=T[0],P!=x&&(_=_*d+(T[1]||0)),(g=r(_/I))>1)for(g>=d&&(g=d-1),b=(k=e(A,g,d)).length,x=T.length;1==t(k,T,b,x);)g--,s(k,P<b?S:A,b,d),b=k.length,m=1;else 0==g&&(m=g=1),b=(k=A.slice()).length;if(b<x&&(k=[0].concat(k)),s(T,k,x,d),x=T.length,-1==m)for(;t(A,T,P,x)<1;)g++,s(T,P<x?S:A,x,d),x=T.length}else 0===m&&(g++,T=[0]);y[h++]=g,T[0]?T[x++]=j[v]||0:(T=[j[v]],x=1)}while((v++<E||null!=T[0])&&C--);p=null!=T[0],y[0]||y.splice(0,1)}if(d==c){for(h=1,C=y[0];C>=10;C/=10,h++);z(w,i+(w.e=h+u*l-1)+1,o,p)}else w.e=u,w.r=+p;return w}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,I=/^([^.]+)\.$/,P=/^\.([^.]+)$/,S=/^-?(Infinity|NaN)$/,C=/^\s*\+(?=[\w.])|^\s+|\s+$/g,x=function(e,t,s,a){var n,r=s?t:t.replace(C,"");if(S.test(r))e.s=isNaN(r)?null:r<0?-1:1;else{if(!s&&(r=r.replace(E,function(e,t,s){return n="x"==(s=s.toLowerCase())?16:"b"==s?2:8,a&&a!=n?e:t}),a&&(n=a,r=r.replace(I,"$1").replace(P,"0.$1")),t!=r))return new W(r,n);if(W.DEBUG)throw Error(i+"Not a"+(a?" base "+a:"")+" number: "+t);e.s=null}e.c=e.e=null},j.absoluteValue=j.abs=function(){var e=new W(this);return e.s<0&&(e.s=1),e},j.comparedTo=function(e,t){return g(this,new W(e,t))},j.decimalPlaces=j.dp=function(e,t){var s,a,n,r=this;if(null!=e)return k(e,0,h),null==t?t=G:k(t,0,8),z(new W(r),e+r.e+1,t);if(!(s=r.c))return null;if(a=((n=s.length-1)-f(this.e/l))*l,n=s[n])for(;n%10==0;n/=10,a--);return a<0&&(a=0),a},j.dividedBy=j.div=function(e,t){return s(this,new W(e,t),F,G)},j.dividedToIntegerBy=j.idiv=function(e,t){return s(this,new W(e,t),0,1)},j.exponentiatedBy=j.pow=function(e,t){var s,a,o,c,d,m,u,h,f=this;if((e=new W(e)).c&&!e.isInteger())throw Error(i+"Exponent not an integer: "+Y(e));if(null!=t&&(t=new W(t)),d=e.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!e.c||!e.c[0])return h=new W(Math.pow(+Y(f),d?e.s*(2-b(e)):+Y(e))),t?h.mod(t):h;if(m=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new W(NaN);(a=!m&&f.isInteger()&&t.isInteger())&&(f=f.mod(t))}else{if(e.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||d&&f.c[1]>=24e7:f.c[0]<8e13||d&&f.c[0]<=9999975e7)))return c=f.s<0&&b(e)?-0:0,f.e>-1&&(c=1/c),new W(m?1/c:c);R&&(c=n(R/l+2))}for(d?(s=new W(.5),m&&(e.s=1),u=b(e)):u=(o=Math.abs(+Y(e)))%2,h=new W(A);;){if(u){if(!(h=h.times(f)).c)break;c?h.c.length>c&&(h.c.length=c):a&&(h=h.mod(t))}if(o){if(0===(o=r(o/2)))break;u=o%2}else if(z(e=e.times(s),e.e+1,1),e.e>14)u=b(e);else{if(0===(o=+Y(e)))break;u=o%2}f=f.times(f),c?f.c&&f.c.length>c&&(f.c.length=c):a&&(f=f.mod(t))}return a?h:(m&&(h=A.div(h)),t?h.mod(t):c?z(h,R,G,undefined):h)},j.integerValue=function(e){var t=new W(this);return null==e?e=G:k(e,0,8),z(t,t.e+1,e)},j.isEqualTo=j.eq=function(e,t){return 0===g(this,new W(e,t))},j.isFinite=function(){return!!this.c},j.isGreaterThan=j.gt=function(e,t){return g(this,new W(e,t))>0},j.isGreaterThanOrEqualTo=j.gte=function(e,t){return 1===(t=g(this,new W(e,t)))||0===t},j.isInteger=function(){return!!this.c&&f(this.e/l)>this.c.length-2},j.isLessThan=j.lt=function(e,t){return g(this,new W(e,t))<0},j.isLessThanOrEqualTo=j.lte=function(e,t){return-1===(t=g(this,new W(e,t)))||0===t},j.isNaN=function(){return!this.s},j.isNegative=function(){return this.s<0},j.isPositive=function(){return this.s>0},j.isZero=function(){return!!this.c&&0==this.c[0]},j.minus=function(e,t){var s,a,n,r,i=this,o=i.s;if(t=(e=new W(e,t)).s,!o||!t)return new W(NaN);if(o!=t)return e.s=-t,i.plus(e);var d=i.e/l,m=e.e/l,u=i.c,h=e.c;if(!d||!m){if(!u||!h)return u?(e.s=-t,e):new W(h?i:NaN);if(!u[0]||!h[0])return h[0]?(e.s=-t,e):new W(u[0]?i:3==G?-0:0)}if(d=f(d),m=f(m),u=u.slice(),o=d-m){for((r=o<0)?(o=-o,n=u):(m=d,n=h),n.reverse(),t=o;t--;n.push(0));n.reverse()}else for(a=(r=(o=u.length)<(t=h.length))?o:t,o=t=0;t<a;t++)if(u[t]!=h[t]){r=u[t]<h[t];break}if(r&&(n=u,u=h,h=n,e.s=-e.s),(t=(a=h.length)-(s=u.length))>0)for(;t--;u[s++]=0);for(t=c-1;a>o;){if(u[--a]<h[a]){for(s=a;s&&!u[--s];u[s]=t);--u[s],u[a]+=c}u[a]-=h[a]}for(;0==u[0];u.splice(0,1),--m);return u[0]?V(e,u,m):(e.s=3==G?-1:1,e.c=[e.e=0],e)},j.modulo=j.mod=function(e,t){var a,n,r=this;return e=new W(e,t),!r.c||!e.s||e.c&&!e.c[0]?new W(NaN):!e.c||r.c&&!r.c[0]?new W(r):(9==B?(n=e.s,e.s=1,a=s(r,e,0,3),e.s=n,a.s*=n):a=s(r,e,0,B),(e=r.minus(a.times(e))).c[0]||1!=B||(e.s=r.s),e)},j.multipliedBy=j.times=function(e,t){var s,a,n,r,i,o,d,m,h,p,g,k,b,w,y,T=this,x=T.c,_=(e=new W(e,t)).c;if(!(x&&_&&x[0]&&_[0]))return!T.s||!e.s||x&&!x[0]&&!_||_&&!_[0]&&!x?e.c=e.e=e.s=null:(e.s*=T.s,x&&_?(e.c=[0],e.e=0):e.c=e.e=null),e;for(a=f(T.e/l)+f(e.e/l),e.s*=T.s,(d=x.length)<(p=_.length)&&(b=x,x=_,_=b,n=d,d=p,p=n),n=d+p,b=[];n--;b.push(0));for(w=c,y=u,n=p;--n>=0;){for(s=0,g=_[n]%y,k=_[n]/y|0,r=n+(i=d);r>n;)s=((m=g*(m=x[--i]%y)+(o=k*m+(h=x[i]/y|0)*g)%y*y+b[r]+s)/w|0)+(o/y|0)+k*h,b[r--]=m%w;b[r]=s}return s?++a:b.splice(0,1),V(e,b,a)},j.negated=function(){var e=new W(this);return e.s=-e.s||null,e},j.plus=function(e,t){var s,a=this,n=a.s;if(t=(e=new W(e,t)).s,!n||!t)return new W(NaN);if(n!=t)return e.s=-t,a.minus(e);var r=a.e/l,i=e.e/l,o=a.c,d=e.c;if(!r||!i){if(!o||!d)return new W(n/0);if(!o[0]||!d[0])return d[0]?e:new W(o[0]?a:0*n)}if(r=f(r),i=f(i),o=o.slice(),n=r-i){for(n>0?(i=r,s=d):(n=-n,s=o),s.reverse();n--;s.push(0));s.reverse()}for((n=o.length)-(t=d.length)<0&&(s=d,d=o,o=s,t=n),n=0;t;)n=(o[--t]=o[t]+d[t]+n)/c|0,o[t]=c===o[t]?0:o[t]%c;return n&&(o=[n].concat(o),++i),V(e,o,i)},j.precision=j.sd=function(e,t){var s,a,n,r=this;if(null!=e&&e!==!!e)return k(e,1,h),null==t?t=G:k(t,0,8),z(new W(r),e,t);if(!(s=r.c))return null;if(a=(n=s.length-1)*l+1,n=s[n]){for(;n%10==0;n/=10,a--);for(n=s[0];n>=10;n/=10,a++);}return e&&r.e+1>a&&(a=r.e+1),a},j.shiftedBy=function(e){return k(e,-9007199254740991,d),this.times("1e"+e)},j.squareRoot=j.sqrt=function(){var e,t,a,n,r,i=this,o=i.c,c=i.s,l=i.e,d=F+4,m=new W("0.5");if(1!==c||!o||!o[0])return new W(!c||c<0&&(!o||o[0])?NaN:o?i:1/0);if(0==(c=Math.sqrt(+Y(i)))||c==1/0?(((t=p(o)).length+l)%2==0&&(t+="0"),c=Math.sqrt(+t),l=f((l+1)/2)-(l<0||l%2),a=new W(t=c==1/0?"5e"+l:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+l)):a=new W(c+""),a.c[0])for((c=(l=a.e)+d)<3&&(c=0);;)if(r=a,a=m.times(r.plus(s(i,r,d,1))),p(r.c).slice(0,c)===(t=p(a.c)).slice(0,c)){if(a.e<l&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(a,a.e+F+2,1),e=!a.times(a).eq(i));break}if(!n&&(z(r,r.e+F+2,0),r.times(r).eq(i))){a=r;break}d+=4,c+=4,n=1}return z(a,a.e+F+1,G,e)},j.toExponential=function(e,t){return null!=e&&(k(e,0,h),e++),$(this,e,t,1)},j.toFixed=function(e,t){return null!=e&&(k(e,0,h),e=e+this.e+1),$(this,e,t)},j.toFormat=function(e,t,s){var a,n=this;if(null==s)null!=e&&t&&"object"==typeof t?(s=t,t=null):e&&"object"==typeof e?(s=e,e=t=null):s=H;else if("object"!=typeof s)throw Error(i+"Argument not an object: "+s);if(a=n.toFixed(e,t),n.c){var r,o=a.split("."),c=+s.groupSize,l=+s.secondaryGroupSize,d=s.groupSeparator||"",m=o[0],u=o[1],h=n.s<0,f=h?m.slice(1):m,p=f.length;if(l&&(r=c,c=l,l=r,p-=r),c>0&&p>0){for(r=p%c||c,m=f.substr(0,r);r<p;r+=c)m+=d+f.substr(r,c);l>0&&(m+=d+f.slice(r)),h&&(m="-"+m)}a=u?m+(s.decimalSeparator||"")+((l=+s.fractionGroupSize)?u.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(s.fractionGroupSeparator||"")):u):m}return(s.prefix||"")+a+(s.suffix||"")},j.toFraction=function(e){var t,a,n,r,o,c,d,u,h,f,g,k,b=this,w=b.c;if(null!=e&&(!(d=new W(e)).isInteger()&&(d.c||1!==d.s)||d.lt(A)))throw Error(i+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+Y(d));if(!w)return new W(b);for(t=new W(A),h=a=new W(A),n=u=new W(A),k=p(w),o=t.e=k.length-b.e-1,t.c[0]=m[(c=o%l)<0?l+c:c],e=!e||d.comparedTo(t)>0?o>0?t:h:d,c=O,O=1/0,d=new W(k),u.c[0]=0;f=s(d,t,0,1),1!=(r=a.plus(f.times(n))).comparedTo(e);)a=n,n=r,h=u.plus(f.times(r=h)),u=r,t=d.minus(f.times(r=t)),d=r;return r=s(e.minus(a),n,0,1),u=u.plus(r.times(h)),a=a.plus(r.times(n)),u.s=h.s=b.s,g=s(h,n,o*=2,G).minus(b).abs().comparedTo(s(u,a,o,G).minus(b).abs())<1?[h,n]:[u,a],O=c,g},j.toNumber=function(){return+Y(this)},j.toPrecision=function(e,t){return null!=e&&k(e,1,h),$(this,e,t,2)},j.toString=function(e){var t,s=this,a=s.s,n=s.e;return null===n?a?(t="Infinity",a<0&&(t="-"+t)):t="NaN":(null==e?t=n<=M||n>=D?w(p(s.c),n):y(p(s.c),n,"0"):10===e&&q?t=y(p((s=z(new W(s),F+n+1,G)).c),s.e,"0"):(k(e,2,U.length,"Base"),t=T(y(p(s.c),n,"0"),10,e,a,!0)),a<0&&s.c[0]&&(t="-"+t)),t},j.valueOf=j.toJSON=function(){return Y(this)},j._isBigNumber=!0,null!=t&&W.set(t),W}(),s.default=s.BigNumber=s,"function"==typeof define&&define.amd?define(function(){return s}):void 0!==t&&t.exports?t.exports=s:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=s)}(this)}}},{package:"@metamask/bridge-status-controller>bignumber.js",file:"node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/browser-passworder/dist/index.js",{"@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.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(t){(function(){Object.defineProperty(s,"__esModule",{value:!0}),s.isVaultUpdated=s.updateVaultWithDetail=s.updateVault=s.generateSalt=s.serializeBufferForStorage=s.serializeBufferFromStorage=s.keyFromPassword=s.exportKey=s.importKey=s.decryptWithKey=s.decryptWithDetail=s.decrypt=s.encryptWithKey=s.encryptWithDetail=s.encrypt=void 0;const a=e("@metamask/utils"),n="jwk",r="AES-GCM",i="utf-8",o={algorithm:"PBKDF2",params:{iterations:1e4}},c={algorithm:"PBKDF2",params:{iterations:9e5}};async function l(e,t,s,a=g(),n=c){const r=s||await p(e,a,!1,n),i=await m(r,t);return i.salt=a,JSON.stringify(i)}async function d(e,t,s=g(),a=c){const n=await p(e,s,!0,a),r=await f(n);return{vault:await l(e,t,n,s),exportedKeyString:r}}async function m(e,s){const a=JSON.stringify(s),n=t.from(a,i),o=globalThis.crypto.getRandomValues(new Uint8Array(16)),c=w(e),l=await globalThis.crypto.subtle.encrypt({name:r,iv:o},c,n),d=new Uint8Array(l),m=t.from(o).toString("base64"),u={data:t.from(d).toString("base64"),iv:m};return k(e)&&(u.keyMetadata=e.derivationOptions),u}async function u(e,t,s){const a=JSON.parse(t),{salt:n,keyMetadata:r}=a,i=w(s||await p(e,n,!1,r));return await h(i,a)}async function h(e,s){const a=t.from(s.data,"base64"),n=t.from(s.iv,"base64"),o=w(e);let c;try{const e=await crypto.subtle.decrypt({name:r,iv:n},o,a),s=new Uint8Array(e),l=t.from(s).toString(i);c=JSON.parse(l)}catch(e){throw new Error("Incorrect password")}return c}async function f(e){return k(e)?JSON.stringify({key:await globalThis.crypto.subtle.exportKey(n,e.key),derivationOptions:e.derivationOptions}):JSON.stringify(await globalThis.crypto.subtle.exportKey(n,e))}async function p(e,s,a=!1,n=o){const c=t.from(e,i),l=t.from(s,"base64"),d=await globalThis.crypto.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveBits","deriveKey"]),m=await globalThis.crypto.subtle.deriveKey({name:"PBKDF2",salt:l,iterations:n.params.iterations,hash:"SHA-256"},d,{name:r,length:256},a,["encrypt","decrypt"]);return n?{key:m,derivationOptions:n}:m}function g(e=32){const t=new Uint8Array(e);globalThis.crypto.getRandomValues(t);return btoa(String.fromCharCode.apply(null,t))}function k(e){return(0,a.isPlainObject)(e)&&(0,a.hasProperty)(e,"key")&&(0,a.hasProperty)(e,"derivationOptions")&&e.key instanceof CryptoKey&&b(e.derivationOptions)}function b(e){return(0,a.isPlainObject)(e)&&(0,a.hasProperty)(e,"algorithm")&&(0,a.hasProperty)(e,"params")}function w(e){return k(e)?e.key:e}function y(e,t=c){const{keyMetadata:s}=JSON.parse(e);return b(s)&&s.algorithm===t.algorithm&&s.params.iterations===t.params.iterations}s.encrypt=l,s.encryptWithDetail=d,s.encryptWithKey=m,s.decrypt=u,s.decryptWithDetail=async function(e,t){const s=JSON.parse(t),{salt:a,keyMetadata:n}=s,r=await p(e,a,!0,n);return{exportedKeyString:await f(r),vault:await u(e,t,r),salt:a}},s.decryptWithKey=h,s.importKey=async function(e){const t=JSON.parse(e);return s=t,(0,a.isPlainObject)(s)&&(0,a.hasProperty)(s,"key")&&(0,a.hasProperty)(s,"derivationOptions")&&b(s.derivationOptions)?{key:await globalThis.crypto.subtle.importKey(n,t.key,r,!0,["encrypt","decrypt"]),derivationOptions:t.derivationOptions}:await globalThis.crypto.subtle.importKey(n,t,r,!0,["encrypt","decrypt"]);var s},s.exportKey=f,s.keyFromPassword=p,s.serializeBufferFromStorage=function(e){const t="0x"===e.slice(0,2)?e.slice(2):e,s=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2){const a=t.substr(e,2);s[e/2]=parseInt(a,16)}return s},s.serializeBufferForStorage=function(e){let t="0x";return e.forEach(e=>{t+=function(e){let t=e.toString(16);for(;t.length<2;)t=`0${t}`;return t}(e)}),t},s.generateSalt=g,s.updateVault=async function(e,t,s=c){return y(e,s)?e:l(t,await u(t,e),undefined,undefined,s)},s.updateVaultWithDetail=async function(e,t,s=c){return y(e.vault,s)?e:d(t,await u(t,e.vault),undefined,s)},s.isVaultUpdated=y}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/browser-passworder",file:"node_modules/@metamask/browser-passworder/dist/index.js"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-controller/dist/DelegationController.cjs",{"./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-controller/dist/constants.cjs","./utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-controller/dist/utils.cjs","@metamask/base-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/base-controller/dist/index.cjs","@metamask/keyring-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-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=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.DelegationController=s.controllerName=void 0;const o=e("@metamask/base-controller"),c=e("@metamask/keyring-controller"),l=e("@metamask/utils"),d=e("./constants.cjs"),m=e("./utils.cjs");s.controllerName="DelegationController";const u={delegations:{includeInStateLogs:!1,persist:!0,includeInDebugSnapshot:!1,usedInUi:!1}};class h extends o.BaseController{constructor({messenger:e,state:t,hashDelegation:i,getDelegationEnvironment:o}){super({messenger:e,metadata:u,name:s.controllerName,state:{delegations:{},...t}}),a.set(this,void 0),n.set(this,void 0),r(this,a,i,"f"),r(this,n,o,"f")}async signDelegation(e){const{delegation:t,chainId:s}=e,{DelegationManager:a}=i(this,n,"f").call(this,s),r=(0,m.createTypedMessageParams)({chainId:(0,l.hexToNumber)(s),from:t.delegator,delegation:{...t,signature:"0x"},verifyingContract:a});return await this.messenger.call("KeyringController:signTypedMessage",r,c.SignTypedDataVersion.V4)}store(e){const{entry:t}=e,s=i(this,a,"f").call(this,t.delegation);if(!(0,m.isHexEqual)(t.delegation.authority,d.ROOT_AUTHORITY)&&!this.state.delegations[t.delegation.authority])throw new Error("Invalid authority");this.update(e=>{e.delegations[s]=t})}list(e){const t=this.messenger.call("AccountsController:getSelectedAccount").address;let s=Object.values(this.state.delegations);e?.from&&(s=s.filter(t=>(0,m.isHexEqual)(t.delegation.delegator,e.from))),(!e?.from||e?.from&&!(0,m.isHexEqual)(e.from,t))&&(s=s.filter(e=>(0,m.isHexEqual)(e.delegation.delegate,t)));const a=e?.chainId;a&&(s=s.filter(e=>(0,m.isHexEqual)(e.chainId,a)));const n=e?.tags;return n&&n.length>0&&(s=s.filter(e=>n.every(t=>e.tags.includes(t)))),s}retrieve(e){return this.state.delegations[e]??null}chain(e){const t=[],s=this.retrieve(e);if(!s)return null;t.push(s);for(let e=s.delegation.authority;e!==d.ROOT_AUTHORITY;){const s=this.retrieve(e);if(!s)throw new Error("Invalid delegation chain");t.push(s),e=s.delegation.authority}return t}delete(e){if(!this.retrieve(e))return 0;const t=Object.entries(this.state.delegations),s=[e],a=[];for(;s.length>0;){const e=s.pop();t.filter(([t,s])=>s.delegation.authority===e).forEach(([e])=>{s.push(e)}),a.push(e)}return this.update(e=>{a.forEach(t=>{delete e.delegations[t]})}),a.length}}s.DelegationController=h,a=new WeakMap,n=new WeakMap}}},{package:"@metamask/delegation-controller",file:"node_modules/@metamask/delegation-controller/dist/DelegationController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-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.SIGNABLE_DELEGATION_TYPED_DATA=s.ROOT_AUTHORITY=void 0,s.ROOT_AUTHORITY="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";s.SIGNABLE_DELEGATION_TYPED_DATA={EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Caveat:[{name:"enforcer",type:"address"},{name:"terms",type:"bytes"}],Delegation:[{name:"delegate",type:"address"},{name:"delegator",type:"address"},{name:"authority",type:"bytes32"},{name:"caveats",type:"Caveat[]"},{name:"salt",type:"uint256"}]}}}},{package:"@metamask/delegation-controller",file:"node_modules/@metamask/delegation-controller/dist/constants.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-controller/dist/index.cjs",{"./DelegationController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-controller/dist/DelegationController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.DelegationController=void 0;var a=e("./DelegationController.cjs");Object.defineProperty(s,"DelegationController",{enumerable:!0,get:function(){return a.DelegationController}})}}},{package:"@metamask/delegation-controller",file:"node_modules/@metamask/delegation-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-controller/dist/utils.cjs",{"./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-controller/dist/constants.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.createTypedMessageParams=s.toDelegationStruct=s.isHexEqual=void 0;const a=e("@metamask/utils"),n=e("./constants.cjs");s.isHexEqual=function(e,t){return e.toLowerCase()===t.toLowerCase()};s.toDelegationStruct=e=>{const t=e.caveats.map(e=>({enforcer:(0,a.getChecksumAddress)(e.enforcer),terms:e.terms,args:e.args})),s="0x"===e.salt?0n:BigInt(e.salt);return{delegate:(0,a.getChecksumAddress)(e.delegate),delegator:(0,a.getChecksumAddress)(e.delegator),authority:e.authority,caveats:t,salt:s,signature:e.signature}},s.createTypedMessageParams=function(e){const{chainId:t,from:a,delegation:r,verifyingContract:i}=e;return{data:{types:n.SIGNABLE_DELEGATION_TYPED_DATA,primaryType:"Delegation",domain:{chainId:t,name:"DelegationManager",version:"1",verifyingContract:i},message:(0,s.toDelegationStruct)(r)},from:a}}}}},{package:"@metamask/delegation-controller",file:"node_modules/@metamask/delegation-controller/dist/utils.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/delegation-deployments/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});var a={DelegationManager:"0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3",EntryPoint:"0x0000000071727De22E5E9d8BAf0edAc6f37da032",SimpleFactory:"0x69Aa2f9fe1572F1B640E1bbc512f5c3a734fc77c",MultiSigDeleGatorImpl:"0x56a9EdB16a0105eb5a4C54f4C062e2868844f3A7",HybridDeleGatorImpl:"0x48dBe696A4D990079e039489bA2053B36E8FFEC4",EIP7702StatelessDeleGatorImpl:"0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B",AllowedCalldataEnforcer:"0xc2b0d624c1c4319760C96503BA27C347F3260f55",AllowedMethodsEnforcer:"0x2c21fD0Cb9DC8445CB3fb0DC5E7Bb0Aca01842B5",AllowedTargetsEnforcer:"0x7F20f61b1f09b08D970938F6fa563634d65c4EeB",BlockNumberEnforcer:"0x5d9818dF0AE3f66e9c3D0c5029DAF99d1823ca6c",DeployedEnforcer:"0x24ff2AA430D53a8CD6788018E902E098083dcCd2",ERC20BalanceChangeEnforcer:"0xcdF6aB796408598Cea671d79506d7D48E97a5437",ERC20TransferAmountEnforcer:"0xf100b0819427117EcF76Ed94B358B1A5b5C6D2Fc",ERC20PeriodTransferEnforcer:"0x474e3Ae7E169e940607cC624Da8A15Eb120139aB",ERC20StreamingEnforcer:"0x56c97aE02f233B29fa03502Ecc0457266d9be00e",ERC721BalanceChangeEnforcer:"0x8aFdf96eDBbe7e1eD3f5Cd89C7E084841e12A09e",ERC721TransferEnforcer:"0x3790e6B7233f779b09DA74C72b6e94813925b9aF",ERC1155BalanceChangeEnforcer:"0x63c322732695cAFbbD488Fc6937A0A7B66fC001A",ExactCalldataBatchEnforcer:"0x982FD5C86BBF425d7d1451f974192d4525113DfD",ExactCalldataEnforcer:"0x99F2e9bF15ce5eC84685604836F71aB835DBBdED",ExactExecutionBatchEnforcer:"0x1e141e455d08721Dd5BCDA1BaA6Ea5633Afd5017",ExactExecutionEnforcer:"0x146713078D39eCC1F5338309c28405ccf85Abfbb",IdEnforcer:"0xC8B5D93463c893401094cc70e66A206fb5987997",LimitedCallsEnforcer:"0x04658B29F6b82ed55274221a06Fc97D318E25416",NativeBalanceChangeEnforcer:"0xbD7B277507723490Cd50b12EaaFe87C616be6880",ArgsEqualityCheckEnforcer:"0x44B8C6ae3C304213c3e298495e12497Ed3E56E41",NativeTokenPaymentEnforcer:"0x4803a326ddED6dDBc60e659e5ed12d85c7582811",NativeTokenTransferAmountEnforcer:"0xF71af580b9c3078fbc2BBF16FbB8EEd82b330320",NativeTokenStreamingEnforcer:"0xD10b97905a320b13a0608f7E9cC506b56747df19",NativeTokenPeriodTransferEnforcer:"0x9BC0FAf4Aca5AE429F4c06aEEaC517520CB16BD9",NonceEnforcer:"0xDE4f2FAC4B3D87A1d9953Ca5FC09FCa7F366254f",OwnershipTransferEnforcer:"0x7EEf9734E7092032B5C56310Eb9BbD1f4A524681",RedeemerEnforcer:"0xE144b0b2618071B4E56f746313528a669c7E65c5",SpecificActionERC20TransferBatchEnforcer:"0x6649b61c873F6F9686A1E1ae9ee98aC380c7bA13",TimestampEnforcer:"0x1046bb45C8d673d4ea75321280DB34899413c069",ValueLteEnforcer:"0x92Bf12322527cAA612fd31a0e810472BBB106A8F",MultiTokenPeriodEnforcer:"0xFB2f1a9BD76d3701B730E5d69C3219D42D80eBb7"},n={DelegationManager:"0x56D56e07e3d6Ee5a24e30203A37a0a460f42D7A3",EntryPoint:"0x0000000071727De22E5E9d8BAf0edAc6f37da032",SimpleFactory:"0x6ff518884f21168c30c58CB21184D6AdBC18Ad90",MultiSigDeleGatorImpl:"0xd1f421EDbA5e3FA9efe3874827114b20C5BEC40C",HybridDeleGatorImpl:"0x941f3a016F8726d5643Ce62452d0D78492D42b42",AllowedCalldataEnforcer:"0xff71d60f3208469cBCE0859717B5198042DCB3F3",AllowedMethodsEnforcer:"0xe32C2561792e8446Abe73B9f557B881C13906186",AllowedTargetsEnforcer:"0x06aaE4c67EEA95277c46Bf79b1583d4a01772D22",BlockNumberEnforcer:"0x8E470D2Ae278457b42d2405E0B8Cd4BE21Ed9045",DeployedEnforcer:"0xf9088f013dBD9ebb7Cebd66fEB48253c6Ac5a820",ERC20BalanceGteEnforcer:"0xB7B6f32ec6343261D814e55Ed8C5925d91Cab861",ERC20TransferAmountEnforcer:"0x9A069b18032B31429A363AeCFb1B6A0564b44471",IdEnforcer:"0x91015c3b9D9523966eD2399885e5Df7A567f916c",LimitedCallsEnforcer:"0xe694bFfffEA3E85923b1210b37e6a0175e910863",NonceEnforcer:"0xE83BCFD8bBE672A96747e831050a91cf44F4F87A",TimestampEnforcer:"0x550FdD13eEBC1f22ea2a2480024BacBF0Ad7e5CE",ValueLteEnforcer:"0xBE32a6DB7471F63BB168C088c57Db01AfAe87967",NativeTokenTransferAmountEnforcer:"0x5eD3833d7B957A8DB8A461c3AF2d668Ec25382E0",NativeBalanceGteEnforcer:"0x376a98860E210DdEda3689fb39565592c563cB0A",ArgsEqualityCheckEnforcer:"0x7378dE585998d3E18Ce147867C335C25B3dB8Ee5",NativeTokenPaymentEnforcer:"0x87Fe18EbF99e42fcE8A03a25F1d20E119407f8e7",RedeemerEnforcer:"0x926672b130D1EF60A9d6b11D2048d121b30f40C1"},r={DelegationManager:"0xbe4138886cb096bdc1b930f2f0ca7892aa234d78",EntryPoint:"0x0000000071727De22E5E9d8BAf0edAc6f37da032",SimpleFactory:"0x6ff518884f21168c30c58CB21184D6AdBC18Ad90",MultiSigDeleGatorImpl:"0x11f555af5844d85bfcf5d61d2a22866527eb585a",HybridDeleGatorImpl:"0xd6edd1256deccb2b06bdecef92dc16bcf26e531b",AllowedCalldataEnforcer:"0x48db3835a873d64a4af2c09f014052407c003bd7",AllowedMethodsEnforcer:"0xfd731951bf1c52afccee3e6f14ab656475b76dd4",AllowedTargetsEnforcer:"0xbc8673c0afa52d86d991c06881e55b2966920564",BlockNumberEnforcer:"0xc15faffa0d879b9263c15a46ce31eacfa2e0e8ae",DeployedEnforcer:"0x5accb9559b56a6c1e3f90e342c85c42d93720d43",ERC20BalanceGteEnforcer:"0xb5d6b1ec6d868a3bae5b7f48178eaa2686a7a087",ERC20TransferAmountEnforcer:"0x92ac423b9c111962179a6242e1adb58d02c103be",IdEnforcer:"0x34152d9f3f8f74338d50703e780389e829b4abac",LimitedCallsEnforcer:"0x4b3adad4a328bee8ba17b86074d92fe7372180cd",NonceEnforcer:"0x2f32ff3fc3086d7f63f16fe8d0065390d460b40d",TimestampEnforcer:"0x78e05f779490c24bf3bfa135b4112e7003b321cd",ValueLteEnforcer:"0xfc20ede0a1132e839fbda9d7ed3904ff3c89540f"},i={arbitrum:42161,arbitrumNova:42170,base:8453,berachain:80094,bsc:56,gnosis:100,ink:57073,linea:59144,mainnet:1,monad:143,optimism:10,polygon:137,sei:1329,sonic:146,unichain:130,bscTestnet:97,arbitrumSepolia:421614,baseSepolia:84532,berachainBepolia:80069,chiado:10200,citreaTestnet:5115,hoodiTestnet:560048,inkSepolia:763373,lineaSepolia:59141,megaEthTestnet:6342,monadTestnet:10143,optimismSepolia:11155420,polygonAmoy:80002,seiTestnet:1328,sepolia:11155111,sonicTestnet:14601,unichainSepolia:1301,lineaGoerli:59140},o={"1.0.0":{[i.optimism]:r,[i.polygon]:r,[i.base]:r,[i.arbitrum]:r,[i.linea]:r,[i.sepolia]:{...r,HybridDeleGatorImpl:"0x5989F5D13DF8fc818EdA65e417AED90459fD67F7"},[i.lineaSepolia]:{...r,HybridDeleGatorImpl:"0x5989F5D13DF8fc818EdA65e417AED90459fD67F7"}},"1.1.0":{[i.arbitrum]:n,[i.base]:n,[i.linea]:n,[i.optimism]:n,[i.polygon]:n,[i.sepolia]:n,[i.lineaSepolia]:n,[i.baseSepolia]:{...n,SimpleFactory:"0xE8eA1DE8D6AfE400B7C8C1A81B7C29B7876b4d02"}},"1.3.0":{[i.mainnet]:a,[i.polygon]:a,[i.bsc]:a,[i.optimism]:a,[i.arbitrum]:a,[i.ink]:a,[i.linea]:a,[i.base]:a,[i.gnosis]:a,[i.berachain]:a,[i.unichain]:a,[i.arbitrumNova]:a,[i.sei]:a,[i.sonic]:a,[i.monad]:a,[i.bscTestnet]:a,[i.citreaTestnet]:a,[i.megaEthTestnet]:a,[i.chiado]:a,[i.lineaSepolia]:a,[i.berachainBepolia]:a,[i.baseSepolia]:a,[i.arbitrumSepolia]:a,[i.sepolia]:a,[i.optimismSepolia]:a,[i.unichainSepolia]:a,[i.polygonAmoy]:a,[i.inkSepolia]:a,[i.monadTestnet]:a,[i.seiTestnet]:a,[i.sonicTestnet]:a,[i.hoodiTestnet]:a}};s.CHAIN_ID=i,s.DELEGATOR_CONTRACTS=o}}},{package:"@metamask/delegation-deployments",file:"node_modules/@metamask/delegation-deployments/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/constants.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.GetCallsStatusCode=s.EIP7682ErrorCode=s.EIP5792ErrorCode=s.SupportedCapabilities=s.MessageType=s.KEYRING_TYPES_SUPPORTING_7702=s.VERSION=void 0;const a=e("@metamask/keyring-controller");var n,r,i,o,c;s.VERSION="2.0.0",s.KEYRING_TYPES_SUPPORTING_7702=[a.KeyringTypes.hd,a.KeyringTypes.simple],function(e){e.SendTransaction="eth_sendTransaction"}(n||(s.MessageType=n={})),function(e){e.AuxiliaryFunds="auxiliaryFunds"}(r||(s.SupportedCapabilities=r={})),function(e){e[e.UnsupportedNonOptionalCapability=5700]="UnsupportedNonOptionalCapability",e[e.UnsupportedChainId=5710]="UnsupportedChainId",e[e.UnknownBundleId=5730]="UnknownBundleId",e[e.RejectedUpgrade=5750]="RejectedUpgrade"}(i||(s.EIP5792ErrorCode=i={})),function(e){e[e.UnsupportedAsset=5771]="UnsupportedAsset",e[e.UnsupportedChain=5772]="UnsupportedChain",e[e.MalformedRequiredAssets=5773]="MalformedRequiredAssets"}(o||(s.EIP7682ErrorCode=o={})),function(e){e[e.PENDING=100]="PENDING",e[e.CONFIRMED=200]="CONFIRMED",e[e.FAILED_OFFCHAIN=400]="FAILED_OFFCHAIN",e[e.REVERTED=500]="REVERTED",e[e.REVERTED_PARTIAL=600]="REVERTED_PARTIAL"}(c||(s.GetCallsStatusCode=c={}))}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/constants.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/hooks/getCallsStatus.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/constants.cjs","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-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.getCallsStatus=void 0;const a=e("@metamask/rpc-errors"),n=e("@metamask/transaction-controller"),r=e("../constants.cjs");s.getCallsStatus=function(e,t){const s=e.call("TransactionController:getState").transactions.filter(e=>e.batchId===t);if(!s?.length)throw new a.JsonRpcError(r.EIP5792ErrorCode.UnknownBundleId,"No matching bundle found");const i=s[0],{chainId:o,txReceipt:c}=i,l=function(e){const{hash:t,status:s}=e;if(s===n.TransactionStatus.confirmed)return r.GetCallsStatusCode.CONFIRMED;if(s===n.TransactionStatus.failed)return t?r.GetCallsStatusCode.REVERTED:r.GetCallsStatusCode.FAILED_OFFCHAIN;if(s===n.TransactionStatus.dropped)return r.GetCallsStatusCode.REVERTED;return r.GetCallsStatusCode.PENDING}(i),d=c,m=d?.logs??[],u=d&&[{blockHash:d.blockHash,blockNumber:d.blockNumber,gasUsed:d.gasUsed,logs:m.map(e=>({address:e.address,data:e.data,topics:e.topics})),status:d.status,transactionHash:d.transactionHash}];return{version:r.VERSION,id:t,chainId:o,atomic:!0,status:l,receipts:u}}}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/hooks/getCallsStatus.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/hooks/getCapabilities.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/constants.cjs","../utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/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.getCapabilities=void 0;const a=e("../constants.cjs"),n=e("../utils.cjs");s.getCapabilities=async function(e,t,s,r){const{getDismissSmartAccountSuggestionEnabled:i,getIsSmartTransaction:o,isAtomicBatchSupported:c,isRelaySupported:l,getSendBundleSupportedChains:d,isAuxiliaryFundsSupported:m}=e;let u=r?.map(e=>e.toLowerCase());if(!u?.length){const e=t.call("NetworkController:getState").networkConfigurationsByChainId;u=Object.keys(e)}const h=await c({address:s,chainIds:u}),f=await async function(e,t,s,a,n,r){const i=r.call("PreferencesController:getState").useTransactionSimulations,o=await Promise.all(t.map(({chainId:e})=>e).map(e=>a(e))),c=await n(e),l=t.map((e,t)=>({...e,relaySupportedForChain:o[t]}));return e.reduce((e,t)=>{const a=l.find(({chainId:e})=>e===t)??{},{isSupported:n=!1,relaySupportedForChain:r}=a,o=s(t),d=c[t]??!1;return i&&(o&&d||n&&r)&&(e[t]={alternateGasFees:{supported:!0}}),e},{})}(u,h,o,l,d,t);return u.reduce((e,r)=>{const o=h.find(({chainId:e})=>e===r)??{},{delegationAddress:c,isSupported:l,upgradeContractAddress:d}=o,u=i();let f=!1;try{const e=(0,n.getAccountKeyringType)(s,t);f=a.KEYRING_TYPES_SUPPORTING_7702.includes(e)}catch{}if(!l&&!(!u&&d&&!c&&f))return e;const p=l?"supported":"ready",g=r;return e[g]===undefined&&(e[g]={}),e[g].atomic={status:p},f&&m(r)&&(e[g].auxiliaryFunds={supported:!0}),e},f)}}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/hooks/getCapabilities.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/hooks/processSendCalls.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/constants.cjs","../utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/utils.cjs","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/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",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.processSendCalls=void 0;const a=e("@metamask/rpc-errors"),n=e("@metamask/transaction-controller"),r=e("@metamask/utils"),i=e("lodash"),o=e("uuid"),c=e("../constants.cjs"),l=e("../utils.cjs");function d(e){const{version:t}=e;if(t!==c.VERSION)throw a.rpcErrors.invalidInput(`Version not supported: Got ${t}, expected ${c.VERSION}`)}function m(e,t){const{chainId:s}=e;if(s&&s.toLowerCase()!==t.toLowerCase())throw a.rpcErrors.invalidParams(`Chain ID must match the dApp selected network: Got ${s}, expected ${t}`)}function u(e,t,s){const{calls:n,capabilities:r,chainId:i}=e,o=[...Object.keys(r??{}).filter(e=>e!==c.SupportedCapabilities.AuxiliaryFunds.toString()&&!0!==r?.[e].optional),...n.flatMap(e=>Object.keys(e.capabilities??{}).filter(t=>t!==c.SupportedCapabilities.AuxiliaryFunds.toString()&&!0!==e.capabilities?.[t].optional))];if(o?.length)throw new a.JsonRpcError(c.EIP5792ErrorCode.UnsupportedNonOptionalCapability,`Unsupported non-optional capabilities: ${o.join(", ")}`);r?.auxiliaryFunds&&h({auxiliaryFunds:r.auxiliaryFunds,chainId:i,keyringType:t,isAuxiliaryFundsSupported:s});for(const e of n)e.capabilities?.auxiliaryFunds&&h({auxiliaryFunds:e.capabilities.auxiliaryFunds,chainId:i,keyringType:t,isAuxiliaryFundsSupported:s})}function h({auxiliaryFunds:e,chainId:t,keyringType:s,isAuxiliaryFundsSupported:n}){if(e.optional)return;if(!c.KEYRING_TYPES_SUPPORTING_7702.includes(s))throw new a.JsonRpcError(c.EIP5792ErrorCode.UnsupportedNonOptionalCapability,`Unsupported non-optional capability: ${c.SupportedCapabilities.AuxiliaryFunds}`);if(!n(t))throw new a.JsonRpcError(c.EIP7682ErrorCode.UnsupportedChain,`The wallet no longer supports auxiliary funds on the requested chain: ${t}`);if(e?.requiredAssets)for(const t of e.requiredAssets)if("erc20"!==t.standard)throw new a.JsonRpcError(c.EIP7682ErrorCode.UnsupportedAsset,`The requested asset ${t.address} is not available through the wallet’s auxiliary fund system: unsupported token standard ${t.standard}`)}function f(e){const t=[...e.capabilities?.auxiliaryFunds?.requiredAssets??[],...e.calls.flatMap(e=>e.capabilities?.auxiliaryFunds?.requiredAssets??[])];if(0===t.length)return undefined;const s=(0,i.groupBy)(t,e=>`${e.address.toLowerCase()}-${e.standard}`);return Object.values(s).map(e=>{if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+BigInt(t.amount),0n);return{...e[0],amount:(0,r.add0x)(t.toString(16))}})}s.processSendCalls=async function(e,t,s,i){const{addTransactionBatch:h,addTransaction:p,getDismissSmartAccountSuggestionEnabled:g,isAtomicBatchSupported:k,validateSecurity:b,getPermittedAccountsForOrigin:w,isAuxiliaryFundsSupported:y}=e,{calls:T,from:x}=s,{networkClientId:_,origin:v}=i,E=T.map(e=>({params:e})),{chainId:I}=t.call("NetworkController:getNetworkClientById",_).configuration,[P]=await w(),S=x??P;if(!S)throw a.providerErrors.unauthorized();const C=(0,o.v4)(),j=b.bind(null,C),A=i.id?String(i.id):"";let F;return F=1===Object.keys(E).length?await async function({addTransaction:e,chainId:t,from:s,messenger:a,networkClientId:i,origin:h,requestId:p,securityAlertId:g,sendCalls:k,transactions:b,validateSecurity:w,isAuxiliaryFundsSupported:y}){const T=(0,l.getAccountKeyringType)(s,a);!function(e,t,s,a){d(e),u(e,s,a),m(e,t)}(k,t,T,y);const x={from:s,...b[0].params,type:n.TransactionEnvelopeType.feeMarket},_={method:c.MessageType.SendTransaction,params:[x],origin:h};w(_,t);const v=f(k),E=function(){const e=(0,o.v4)(),t=new Uint8Array((0,o.parse)(e));return(0,r.bytesToHex)(t)}();return await e(x,{batchId:E,networkClientId:i,origin:h,requestId:p,requiredAssets:v,securityAlertResponse:{securityAlertId:g}}),E}({addTransaction:p,chainId:I,from:S,messenger:t,networkClientId:_,origin:v,requestId:A,securityAlertId:C,sendCalls:s,transactions:E,validateSecurity:j,isAuxiliaryFundsSupported:y}):await async function({addTransactionBatch:e,isAtomicBatchSupported:t,chainId:s,from:n,getDismissSmartAccountSuggestionEnabled:r,networkClientId:i,messenger:o,origin:h,requestId:p,sendCalls:g,securityAlertId:k,transactions:b,validateSecurity:w,isAuxiliaryFundsSupported:y}){const T=await t({address:n,chainIds:[s]}),x=T?.[0],_=(0,l.getAccountKeyringType)(n,o),v=r();!function(e,t,s,n,r,i){d(e),function(e,t,s){if(m(e,t),!s)throw new a.JsonRpcError(c.EIP5792ErrorCode.UnsupportedChainId,`EIP-7702 not supported on chain: ${t}`)}(e,t,n),u(e,r,i),function(e,t,s){if(t?.delegationAddress)return;if(e)throw new a.JsonRpcError(c.EIP5792ErrorCode.RejectedUpgrade,"EIP-7702 upgrade disabled by the user");if(!c.KEYRING_TYPES_SUPPORTING_7702.includes(s))throw new a.JsonRpcError(c.EIP5792ErrorCode.RejectedUpgrade,"EIP-7702 upgrade not supported on account")}(s,n,r)}(g,s,v,x,_,y);const E=f(g),I=await e({from:n,networkClientId:i,origin:h,requestId:p,requiredAssets:E,securityAlertId:k,transactions:b,validateSecurity:w});return I.batchId}({addTransactionBatch:h,isAtomicBatchSupported:k,chainId:I,from:S,getDismissSmartAccountSuggestionEnabled:g,messenger:t,networkClientId:_,origin:v,requestId:A,sendCalls:s,securityAlertId:C,transactions:E,validateSecurity:j,isAuxiliaryFundsSupported:y}),{id:F}}}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/hooks/processSendCalls.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/index.cjs",{"./hooks/getCallsStatus.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/hooks/getCallsStatus.cjs","./hooks/getCapabilities.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/hooks/getCapabilities.cjs","./hooks/processSendCalls.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/hooks/processSendCalls.cjs","./methods/wallet_getCallsStatus.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_getCallsStatus.cjs","./methods/wallet_getCapabilities.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_getCapabilities.cjs","./methods/wallet_sendCalls.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_sendCalls.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.walletGetCapabilities=s.walletGetCallsStatus=s.walletSendCalls=s.getCapabilities=s.getCallsStatus=s.processSendCalls=void 0;var a=e("./hooks/processSendCalls.cjs");Object.defineProperty(s,"processSendCalls",{enumerable:!0,get:function(){return a.processSendCalls}});var n=e("./hooks/getCallsStatus.cjs");Object.defineProperty(s,"getCallsStatus",{enumerable:!0,get:function(){return n.getCallsStatus}});var r=e("./hooks/getCapabilities.cjs");Object.defineProperty(s,"getCapabilities",{enumerable:!0,get:function(){return r.getCapabilities}});var i=e("./methods/wallet_sendCalls.cjs");Object.defineProperty(s,"walletSendCalls",{enumerable:!0,get:function(){return i.walletSendCalls}});var o=e("./methods/wallet_getCallsStatus.cjs");Object.defineProperty(s,"walletGetCallsStatus",{enumerable:!0,get:function(){return o.walletGetCallsStatus}});var c=e("./methods/wallet_getCapabilities.cjs");Object.defineProperty(s,"walletGetCapabilities",{enumerable:!0,get:function(){return c.walletGetCapabilities}})}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_getCallsStatus.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/types.cjs","../utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/utils.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.walletGetCallsStatus=void 0;const a=e("@metamask/rpc-errors"),n=e("../types.cjs"),r=e("../utils.cjs");s.walletGetCallsStatus=async function(e,t,{getCallsStatus:s}){if(!s)throw a.rpcErrors.methodNotSupported();(0,r.validateParams)(e.params,n.GetCallsStatusStruct);const i=e.params[0];t.result=await s(i,e)}}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_getCallsStatus.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_getCapabilities.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/types.cjs","../utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/utils.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.walletGetCapabilities=void 0;const a=e("@metamask/rpc-errors"),n=e("../types.cjs"),r=e("../utils.cjs");s.walletGetCapabilities=async function(e,t,{getPermittedAccountsForOrigin:s,getCapabilities:i}){if(!i)throw a.rpcErrors.methodNotSupported();(0,r.validateParams)(e.params,n.GetCapabilitiesStruct);const o=e.params[0],c=e.params[1];await(0,r.validateAndNormalizeKeyholder)(o,{getPermittedAccountsForOrigin:s});const l=await i(o,c,e);t.result=l}}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_getCapabilities.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_sendCalls.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/types.cjs","../utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/utils.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.walletSendCalls=void 0;const a=e("@metamask/rpc-errors"),n=e("../types.cjs"),r=e("../utils.cjs");s.walletSendCalls=async function(e,t,{getPermittedAccountsForOrigin:s,processSendCalls:i}){if(!i)throw a.rpcErrors.methodNotSupported();(0,r.validateParams)(e.params,n.SendCallsStruct);const o=e.params[0],c=o.from?await(0,r.validateAndNormalizeKeyholder)(o.from,{getPermittedAccountsForOrigin:s}):undefined,l={...o,from:c};t.result=await i(l,e)}}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/methods/wallet_sendCalls.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/types.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.SendCallsStruct=s.CapabilitiesStruct=s.GetCapabilitiesStruct=s.GetCallsStatusStruct=void 0;const a=e("@metamask/superstruct"),n=e("@metamask/utils");s.GetCallsStatusStruct=(0,a.tuple)([n.StrictHexStruct]),s.GetCapabilitiesStruct=(0,a.tuple)([n.HexChecksumAddressStruct,(0,a.optional)((0,a.array)(n.StrictHexStruct))]);const r=(0,a.type)({address:(0,a.nonempty)(n.HexChecksumAddressStruct),amount:(0,a.nonempty)(n.StrictHexStruct),standard:(0,a.nonempty)((0,a.string)())});s.CapabilitiesStruct=(0,a.record)((0,a.string)(),(0,a.type)({optional:(0,a.optional)((0,a.boolean)()),requiredAssets:(0,a.optional)((0,a.array)(r))})),s.SendCallsStruct=(0,a.tuple)([(0,a.object)({version:(0,a.nonempty)((0,a.string)()),id:(0,a.optional)(n.StrictHexStruct),from:(0,a.optional)(n.HexChecksumAddressStruct),chainId:n.StrictHexStruct,atomicRequired:(0,a.boolean)(),calls:(0,a.array)((0,a.object)({to:(0,a.optional)(n.HexChecksumAddressStruct),data:(0,a.optional)(n.StrictHexStruct),value:(0,a.optional)(n.StrictHexStruct),capabilities:(0,a.optional)(s.CapabilitiesStruct)})),capabilities:(0,a.optional)(s.CapabilitiesStruct)})])}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/types.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/utils.cjs",{"./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/dist/constants.cjs","@metamask/rpc-errors":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/rpc-errors/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.resemblesAddress=s.validateParams=s.validateAndNormalizeKeyholder=s.getAccountKeyringType=void 0;const a=e("@metamask/rpc-errors"),n=e("@metamask/superstruct"),r=e("./constants.cjs");function i(e){return 42===e.length}s.getAccountKeyringType=function(e,t){const{accounts:s}=t.call("AccountsController:getState").internalAccounts,n=Object.values(s).find(t=>t.address.toLowerCase()===e.toLowerCase()),i=n?.metadata?.keyring?.type;if(!i)throw new a.JsonRpcError(r.EIP5792ErrorCode.RejectedUpgrade,"EIP-7702 upgrade not supported as account type is unknown");return i},s.validateAndNormalizeKeyholder=async function(e,{getPermittedAccountsForOrigin:t}){if("string"==typeof e&&e.length>0&&i(e)){const s=(await t()).map(e=>e.toLowerCase()),n=e.toLowerCase();if(s.includes(n))return n;throw a.providerErrors.unauthorized()}throw a.rpcErrors.invalidParams({message:"Invalid parameters: must provide an Ethereum address."})},s.validateParams=function(e,t){const[s]=(0,n.validate)(e,t);if(s)throw a.rpcErrors.invalidParams(function(e,t){return`${t}\n\n${e.failures().map(e=>`${e.path.join(" > ")}${e.path.length?" - ":""}${e.message}`).join("\n")}`}(s,"Invalid params"))},s.resemblesAddress=i}}},{package:"@metamask/eip-5792-middleware",file:"node_modules/@metamask/eip-5792-middleware/dist/utils.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/GasFeeController.cjs",{"./determineGasFeeCalculations.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/determineGasFeeCalculations.cjs","./gas-util.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/gas-util.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/polling-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/polling-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){var a,n,r,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},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)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s,"__esModule",{value:!0}),s.GasFeeController=s.GAS_ESTIMATE_TYPES=s.LEGACY_GAS_PRICES_API_URL=void 0;const l=e("@metamask/controller-utils"),d=c(e("@metamask/eth-query")),m=e("@metamask/polling-controller"),u=e("uuid"),h=c(e("./determineGasFeeCalculations.cjs")),f=e("./gas-util.cjs");s.LEGACY_GAS_PRICES_API_URL="https://api.metaswap.codefi.network/gasPrices",s.GAS_ESTIMATE_TYPES={FEE_MARKET:"fee-market",LEGACY:"legacy",ETH_GASPRICE:"eth_gasPrice",NONE:"none"};const p={gasFeeEstimatesByChainId:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},gasFeeEstimates:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},estimatedGasFeeTimeBounds:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},gasEstimateType:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0},nonRPCGasFeeApisDisabled:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!1}},g={gasFeeEstimatesByChainId:{},gasFeeEstimates:{},estimatedGasFeeTimeBounds:{},gasEstimateType:s.GAS_ESTIMATE_TYPES.NONE,nonRPCGasFeeApisDisabled:!1};class k extends((0,m.StaticIntervalPollingController)()){constructor({interval:e=15e3,messenger:t,state:c,getCurrentNetworkEIP1559Compatibility:l,getCurrentAccountEIP1559Compatibility:m,getChainId:u,getCurrentNetworkLegacyGasAPICompatibility:h,getProvider:f,onNetworkDidChange:k,legacyAPIEndpoint:b=s.LEGACY_GAS_PRICES_API_URL,EIP1559APIEndpoint:w,clientId:y}){if(super({name:"GasFeeController",metadata:p,messenger:t,state:{...g,...c}}),a.add(this),n.set(this,void 0),this.intervalDelay=e,this.setIntervalLength(e),this.pollTokens=new Set,this.getCurrentNetworkEIP1559Compatibility=l,this.getCurrentNetworkLegacyGasAPICompatibility=h,this.getCurrentAccountEIP1559Compatibility=m,i(this,n,f,"f"),this.EIP1559APIEndpoint=w,this.legacyAPIEndpoint=b,this.clientId=y,this.ethQuery=new d.default(o(this,n,"f").call(this)),k&&u)this.currentChainId=u(),k(async e=>{await o(this,a,"m",r).call(this,e)});else{const{selectedNetworkClientId:e}=this.messenger.call("NetworkController:getState");this.currentChainId=this.messenger.call("NetworkController:getNetworkClientById",e).configuration.chainId,this.messenger.subscribe("NetworkController:networkDidChange",async e=>{await o(this,a,"m",r).call(this,e)})}}async resetPolling(){if(0!==this.pollTokens.size){const e=Array.from(this.pollTokens);this.stopPolling(),await this.getGasFeeEstimatesAndStartPolling(e[0]),e.slice(1).forEach(e=>{this.pollTokens.add(e)})}}async fetchGasFeeEstimates(e){return await this._fetchGasFeeEstimateData(e)}async getGasFeeEstimatesAndStartPolling(e){const t=e||(0,u.v1)();return this.pollTokens.add(t),1===this.pollTokens.size&&(await this._fetchGasFeeEstimateData(),this._poll()),t}async _fetchGasFeeEstimateData(e={}){const{shouldUpdateState:t=!0,networkClientId:s}=e;let a,n,r,i;if(s!==undefined){const e=this.messenger.call("NetworkController:getNetworkClientById",s);r="0x38"===e.configuration.chainId,i=(0,l.convertHexToDecimal)(e.configuration.chainId);try{n=await this.messenger.call("NetworkController:getEIP1559Compatibility",s)||!1}catch{n=!1}a=new d.default(e.provider)}a??(a=this.ethQuery),r??(r=this.getCurrentNetworkLegacyGasAPICompatibility()),i??(i=(0,l.convertHexToDecimal)(this.currentChainId));try{n??(n=await this.getEIP1559Compatibility())}catch(e){console.error(e),n??(n=!1)}const o=await(0,h.default)({isEIP1559Compatible:n,isLegacyGasAPICompatible:r,fetchGasEstimates:f.fetchGasEstimates,fetchGasEstimatesUrl:this.EIP1559APIEndpoint.replace("<chain_id>",`${i}`),fetchLegacyGasPriceEstimates:f.fetchLegacyGasPriceEstimates,fetchLegacyGasPriceEstimatesUrl:this.legacyAPIEndpoint.replace("<chain_id>",`${i}`),fetchEthGasPriceEstimate:f.fetchEthGasPriceEstimate,calculateTimeEstimate:f.calculateTimeEstimate,clientId:this.clientId,ethQuery:a,nonRPCGasFeeApisDisabled:this.state.nonRPCGasFeeApisDisabled});if(t){const e=(0,l.toHex)(i);this.update(t=>{this.currentChainId===e&&(t.gasFeeEstimates=o.gasFeeEstimates,t.estimatedGasFeeTimeBounds=o.estimatedGasFeeTimeBounds,t.gasEstimateType=o.gasEstimateType),t.gasFeeEstimatesByChainId??(t.gasFeeEstimatesByChainId={}),t.gasFeeEstimatesByChainId[e]={gasFeeEstimates:o.gasFeeEstimates,estimatedGasFeeTimeBounds:o.estimatedGasFeeTimeBounds,gasEstimateType:o.gasEstimateType}})}return o}disconnectPoller(e){this.pollTokens.delete(e),0===this.pollTokens.size&&this.stopPolling()}stopPolling(){this.intervalId&&clearInterval(this.intervalId),this.pollTokens.clear(),this.resetState()}destroy(){super.destroy(),this.stopPolling()}_poll(){this.intervalId&&clearInterval(this.intervalId),this.intervalId=setInterval(async()=>{await(0,l.safelyExecute)(()=>this._fetchGasFeeEstimateData())},this.intervalDelay)}async _executePoll({networkClientId:e}){await this._fetchGasFeeEstimateData({networkClientId:e})}resetState(){this.update(()=>g)}async getEIP1559Compatibility(){const e=await this.getCurrentNetworkEIP1559Compatibility(),t=this.getCurrentAccountEIP1559Compatibility?.()??!0;return e&&t}getTimeEstimate(e,t){return this.state.gasFeeEstimates&&this.state.gasEstimateType===s.GAS_ESTIMATE_TYPES.FEE_MARKET?(0,f.calculateTimeEstimate)(e,t,this.state.gasFeeEstimates):{}}enableNonRPCGasFeeApis(){this.update(e=>{e.nonRPCGasFeeApisDisabled=!1})}disableNonRPCGasFeeApis(){this.update(e=>{e.nonRPCGasFeeApisDisabled=!0})}}s.GasFeeController=k,n=new WeakMap,a=new WeakSet,r=async function({selectedNetworkClientId:e}){const t=this.messenger.call("NetworkController:getNetworkClientById",e).configuration.chainId;t!==this.currentChainId&&(this.ethQuery=new d.default(o(this,n,"f").call(this)),await this.resetPolling(),this.currentChainId=t)},s.default=k}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/GasFeeController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/determineGasFeeCalculations.cjs",{"./GasFeeController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/GasFeeController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){Object.defineProperty(s,"__esModule",{value:!0});const a=e("./GasFeeController.cjs");s.default=async function(e){try{return await async function(e){const{isEIP1559Compatible:t,isLegacyGasAPICompatible:s,nonRPCGasFeeApisDisabled:n}=e;try{if(t&&!n)return await async function(e){const{fetchGasEstimates:t,fetchGasEstimatesUrl:s,clientId:n,calculateTimeEstimate:r}=e,i=await t(s,n),{suggestedMaxPriorityFeePerGas:o,suggestedMaxFeePerGas:c}=i.medium,l=r(o,c,i);return{gasFeeEstimates:i,estimatedGasFeeTimeBounds:l,gasEstimateType:a.GAS_ESTIMATE_TYPES.FEE_MARKET}}(e);if(s&&!n)return await async function(e){const{fetchLegacyGasPriceEstimates:t,fetchLegacyGasPriceEstimatesUrl:s,clientId:n}=e;return{gasFeeEstimates:await t(s,n),estimatedGasFeeTimeBounds:{},gasEstimateType:a.GAS_ESTIMATE_TYPES.LEGACY}}(e);throw new Error("Main gas fee/price estimation failed. Use fallback")}catch{return await async function(e){const{ethQuery:t,fetchEthGasPriceEstimate:s}=e;return{gasFeeEstimates:await s(t),estimatedGasFeeTimeBounds:{},gasEstimateType:a.GAS_ESTIMATE_TYPES.ETH_GASPRICE}}(e)}}(e)}catch(e){if(e instanceof Error)throw new Error(`Gas fee/price estimation failed. Message: ${e.message}`);throw e}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/determineGasFeeCalculations.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/gas-util.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"},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.calculateTimeEstimate=s.fetchEthGasPriceEstimate=s.fetchLegacyGasPriceEstimates=s.fetchGasEstimates=s.normalizeGWEIDecimalNumbers=void 0;const n=e("@metamask/controller-utils"),r=a(e("bn.js")),i=e=>({"X-Client-Id":e});function o(e){const t=(0,n.gweiDecToWEIBN)(e).toString(16);return(0,n.weiHexToGweiDec)(t)}s.normalizeGWEIDecimalNumbers=o,s.fetchGasEstimates=async function(e,t){const s=await(0,n.handleFetch)(e,t?{headers:i(t)}:undefined);return{low:{...s.low,suggestedMaxPriorityFeePerGas:o(s.low.suggestedMaxPriorityFeePerGas),suggestedMaxFeePerGas:o(s.low.suggestedMaxFeePerGas)},medium:{...s.medium,suggestedMaxPriorityFeePerGas:o(s.medium.suggestedMaxPriorityFeePerGas),suggestedMaxFeePerGas:o(s.medium.suggestedMaxFeePerGas)},high:{...s.high,suggestedMaxPriorityFeePerGas:o(s.high.suggestedMaxPriorityFeePerGas),suggestedMaxFeePerGas:o(s.high.suggestedMaxFeePerGas)},estimatedBaseFee:o(s.estimatedBaseFee),historicalBaseFeeRange:s.historicalBaseFeeRange,baseFeeTrend:s.baseFeeTrend,latestPriorityFeeRange:s.latestPriorityFeeRange,historicalPriorityFeeRange:s.historicalPriorityFeeRange,priorityFeeTrend:s.priorityFeeTrend,networkCongestion:s.networkCongestion}},s.fetchLegacyGasPriceEstimates=async function(e,t){const s=await(0,n.handleFetch)(e,{referrer:e,referrerPolicy:"no-referrer-when-downgrade",method:"GET",mode:"cors",headers:{"Content-Type":"application/json",...t&&i(t)}});return{low:s.SafeGasPrice,medium:s.ProposeGasPrice,high:s.FastGasPrice}},s.fetchEthGasPriceEstimate=async function(e){const t=await(0,n.query)(e,"gasPrice");return{gasPrice:(0,n.weiHexToGweiDec)(t).toString()}},s.calculateTimeEstimate=function(e,t,s){const{low:a,medium:i,high:o,estimatedBaseFee:c}=s,l=(0,n.gweiDecToWEIBN)(e),d=(0,n.gweiDecToWEIBN)(t),m=(0,n.gweiDecToWEIBN)(c),u=r.default.min(l,d.sub(m)),h=(0,n.gweiDecToWEIBN)(a.suggestedMaxPriorityFeePerGas),f=(0,n.gweiDecToWEIBN)(i.suggestedMaxPriorityFeePerGas),p=(0,n.gweiDecToWEIBN)(o.suggestedMaxPriorityFeePerGas);let g,k;return u.lt(h)?(g=null,k="unknown"):u.gte(h)&&u.lt(f)?(g=a.minWaitTimeEstimate,k=a.maxWaitTimeEstimate):u.gte(f)&&u.lt(p)?(g=i.minWaitTimeEstimate,k=i.maxWaitTimeEstimate):u.eq(p)?(g=o.minWaitTimeEstimate,k=o.maxWaitTimeEstimate):(g=0,k=o.maxWaitTimeEstimate),{lowerTimeBound:g,upperTimeBound:k}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/gas-util.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/index.cjs",{"./GasFeeController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/GasFeeController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,s){var a=this&&this.__createBinding||(Object.create?function(e,t,s,a){a===undefined&&(a=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,n)}:function(e,t,s,a){a===undefined&&(a=s),e[a]=t[s]}),n=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||a(t,e,s)};Object.defineProperty(s,"__esModule",{value:!0}),n(e("./GasFeeController.cjs"),s)}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller>@metamask/gas-fee-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/gas-fee-controller/dist/index.cjs"}]],[],{});