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,a){Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"FirebaseError",{enumerable:!0,get:function(){return i.FirebaseError}}),a._DEFAULT_ENTRY_NAME=a.SDK_VERSION=void 0,a._addComponent=U,a._addOrOverwriteComponent=function(e,t){e.container.addOrOverwriteComponent(t)},a._apps=void 0,a._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.
 */,a._components=void 0,a._getProvider=W,a._isFirebaseApp=$,a._isFirebaseServerApp=function(e){return e.settings!==undefined},a._registerComponent=q,a._removeServiceInstance=function(e,t,a=L){W(e,t).clearInstance(a)},a._serverApps=void 0,a.deleteApp=Q,a.getApp=function(e=L){const t=B.get(e);if(!t&&e===L&&(0,i.getDefaultAppConfig)())return Y();if(!t)throw V.create("no-app",{appName:e});return t},a.getApps=function(){return Array.from(B.values())},a.initializeApp=Y,a.initializeServerApp=function(e,t){if((0,i.isBrowser)()&&!(0,i.isWebWorker)())throw V.create("invalid-server-app-environment");t.automaticDataCollectionEnabled===undefined&&(t.automaticDataCollectionEnabled=!1);let a;a=$(e)?e.options:e;const s=Object.assign(Object.assign({},t),a);s.releaseOnDeref!==undefined&&delete s.releaseOnDeref;if(t.releaseOnDeref!==undefined&&"undefined"==typeof FinalizationRegistry)throw V.create("finalization-registry-not-supported",{});const r=""+(c=JSON.stringify(s),[...c].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0)),o=R.get(r);var c;if(o)return o.incRefCount(t.releaseOnDeref),o;const l=new n.ComponentContainer(r);for(const e of H.values())l.addComponent(e);const d=new J(a,t,r,l);return R.set(r,d),d},a.onLog=function(e,t){if(null!==e&&"function"!=typeof e)throw V.create("invalid-log-argument");(0,s.setUserLogHandler)(e,t)},a.registerVersion=X,a.setLogLevel=function(e){(0,s.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 n=e("@firebase/component"),s=e("@firebase/logger"),i=e("@firebase/util"),r=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 s.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",w="@firebase/database",b="@firebase/data-connect",y="@firebase/database-compat",T="@firebase/functions",x="@firebase/functions-compat",_="@firebase/installations",v="@firebase/installations-compat",E="@firebase/messaging",S="@firebase/messaging-compat",I="@firebase/performance",P="@firebase/performance-compat",C="@firebase/remote-config",j="@firebase/remote-config-compat",A="@firebase/storage",F="@firebase/storage-compat",D="@firebase/firestore",M="@firebase/vertexai",O="@firebase/firestore-compat",N="firebase",L=a._DEFAULT_ENTRY_NAME="[DEFAULT]",G={[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",[w]:"fire-rtdb",[b]:"fire-data-connect",[y]:"fire-rtdb-compat",[T]:"fire-fn",[x]:"fire-fn-compat",[_]:"fire-iid",[v]:"fire-iid-compat",[E]:"fire-fcm",[S]:"fire-fcm-compat",[I]:"fire-perf",[P]:"fire-perf-compat",[C]:"fire-rc",[j]:"fire-rc-compat",[A]:"fire-gcs",[F]:"fire-gcs-compat",[D]:"fire-fst",[O]:"fire-fst-compat",[M]:"fire-vertex","fire-js":"fire-js",[N]:"fire-js-all"},B=a._apps=new Map,R=a._serverApps=new Map,H=a._components=new Map;function U(e,t){try{e.container.addComponent(t)}catch(a){d.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,a)}}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 a=e.container.getProvider("heartbeat").getImmediate({optional:!0});return a&&a.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 i.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,a){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=a,this.container.addComponent(new n.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 J extends z{constructor(e,t,a,n){const s=t.automaticDataCollectionEnabled!==undefined&&t.automaticDataCollectionEnabled,i={name:a,automaticDataCollectionEnabled:s};if(e.apiKey!==undefined)super(e,i,n);else{super(e.options,i,n)}this._serverConfig=Object.assign({automaticDataCollectionEnabled:s},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(){Q(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.
 */a.SDK_VERSION="11.2.0";function Y(e,t={}){let a=e;if("object"!=typeof t){t={name:t}}const s=Object.assign({name:L,automaticDataCollectionEnabled:!1},t),r=s.name;if("string"!=typeof r||!r)throw V.create("bad-app-name",{appName:String(r)});if(a||(a=(0,i.getDefaultAppConfig)()),!a)throw V.create("no-options");const o=B.get(r);if(o){if((0,i.deepEqual)(a,o.options)&&(0,i.deepEqual)(s,o.config))return o;throw V.create("duplicate-app",{appName:r})}const c=new n.ComponentContainer(r);for(const e of H.values())c.addComponent(e);const l=new z(a,s,c);return B.set(r,l),l}async function Q(e){let t=!1;const a=e.name;if(B.has(a))t=!0,B.delete(a);else if(R.has(a)){e.decRefCount()<=0&&(R.delete(a),t=!0)}t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function X(e,t,a){var s;let i=null!==(s=G[e])&&void 0!==s?s:e;a&&(i+=`-${a}`);const r=i.match(/\s|\//),o=t.match(/\s|\//);if(r||o){const e=[`Unable to register library "${i}" with version "${t}":`];return r&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),r&&o&&e.push("and"),o&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void d.warn(e.join(" "))}q(new n.Component(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}const Z="firebase-heartbeat-store";let ee=null;function te(){return ee||(ee=(0,r.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 ae(e,t){try{const a=(await te()).transaction(Z,"readwrite"),n=a.objectStore(Z);await n.put(t,ne(e)),await a.done}catch(e){if(e instanceof i.FirebaseError)d.warn(e.message);else{const t=V.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});d.warn(t.message)}}}function ne(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 se{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new re(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{const a=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),n=ie();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===n||this._heartbeatsCache.heartbeats.some(e=>e.date===n))return;return this._heartbeatsCache.heartbeats.push({date:n,agent:a}),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=ie(),{heartbeatsToSend:a,unsentEntries:n}=function(e,t=1024){const a=[];let n=e.slice();for(const s of e){const e=a.find(e=>e.agent===s.agent);if(e){if(e.dates.push(s.date),oe(a)>t){e.dates.pop();break}}else if(a.push({agent:s.agent,dates:[s.date]}),oe(a)>t){a.pop();break}n=n.slice(1)}return{heartbeatsToSend:a,unsentEntries:n}}(this._heartbeatsCache.heartbeats),s=(0,i.base64urlEncodeWithoutPadding)(JSON.stringify({version:2,heartbeats:a}));return this._heartbeatsCache.lastSentHeartbeatDate=t,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(e){return d.warn(e),""}}}function ie(){return(new Date).toISOString().substring(0,10)}class re{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,i.isIndexedDBAvailable)()&&(0,i.validateIndexedDBOpenable)().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await te()).transaction(Z),a=await t.objectStore(Z).get(ne(e));return await t.done,a}catch(e){if(e instanceof i.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 a=await this.read();return ae(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:a.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const a=await this.read();return ae(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:a.lastSentHeartbeatDate,heartbeats:[...a.heartbeats,...e.heartbeats]})}}}function oe(e){return(0,i.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 n.Component("platform-logger",e=>new o(e),"PRIVATE")),q(new n.Component("heartbeat",e=>new se(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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.Provider=a.ComponentContainer=a.Component=void 0;var n=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.
 */
a.Component=class{constructor(e,t,a){this.name=e,this.instanceFactory=t,this.type=a,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 s="[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 i{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 n.Deferred;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const a=this.getOrInitializeService({instanceIdentifier:t});a&&e.resolve(a)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const a=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),n=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(a)&&!this.shouldAutoInitialize()){if(n)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:a})}catch(e){if(n)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:s})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const a=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:a});t.resolve(e)}catch(e){}}}}clearInstance(e=s){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=s){return this.instances.has(e)}getOptions(e=s){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,a=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(a))throw Error(`${this.name}(${a}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const n=this.getOrInitializeService({instanceIdentifier:a,options:t});for(const[e,t]of this.instancesDeferred.entries()){a===this.normalizeInstanceIdentifier(e)&&t.resolve(n)}return n}onInit(e,t){var a;const n=this.normalizeInstanceIdentifier(t),s=null!==(a=this.onInitCallbacks.get(n))&&void 0!==a?a:new Set;s.add(e),this.onInitCallbacks.set(n,s);const i=this.instances.get(n);return i&&e(i,n),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const a=this.onInitCallbacks.get(t);if(a)for(const n of a)try{n(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let a=this.instances.get(e);if(!a&&this.component&&(a=this.component.instanceFactory(this.container,{instanceIdentifier:(n=e,n===s?undefined:n),options:t}),this.instances.set(e,a),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(a,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,a)}catch(e){}var n;return a||null}normalizeInstanceIdentifier(e=s){return this.component?this.component.multipleInstances?e:s:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}a.Provider=i;a.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 i(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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.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,a=await H(t,e=>e&&0===e.registrationStatus?undefined:e);if(a){if(1===a.registrationStatus)throw p.create("delete-pending-registration");if(2===a.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 a=function(e,{fid:t}){return`${k(e)}/${t}`}(e,t),n=T(e,t),s={method:"DELETE",headers:n},i=await x(()=>fetch(a,s));if(!i.ok)throw await b("Delete Installation",i)}(t,a),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.
 */,a.getId=Y,a.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,n.getApp)()){return(0,n._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.
 */,a.getToken=Q,a.onIdChange=function(e,t){const{appConfig:a}=e;return function(e,t){F();const a=I(e);let n=P.get(a);n||(n=new Set,P.set(a,n));n.add(t)}(a,t),()=>{!function(e,t){const a=I(e),n=P.get(a);if(!n)return;n.delete(t),0===n.size&&P.delete(a);D()}(a,t)}};var n=e("@firebase/app"),s=e("@firebase/component"),i=e("@firebase/util"),r=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 i.ErrorFactory("installations","Installations",f);function g(e){return e instanceof i.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 w(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function b(e,t){const a=(await t.json()).error;return p.create("request-failed",{requestName:e,serverCode:a.code,serverMessage:a.message,serverStatus:a.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 a=y(e);return a.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)),a}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 S(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function(e){const t=(a=e,btoa(String.fromCharCode(...a)).replace(/\+/g,"-").replace(/\//g,"_"));var a;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 I(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 P=new Map;function C(e,t){const a=I(e);j(a,t),function(e,t){const a=F();a&&a.postMessage({key:e,fid:t});D()}(a,t)}function j(e,t){const a=P.get(e);if(a)for(const e of a)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 D(){0===P.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",O=1,N="firebase-installations-store";let L=null;function G(){return L||(L=(0,r.openDB)(M,O,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(N)}})),L}async function B(e,t){const a=I(e),n=(await G()).transaction(N,"readwrite"),s=n.objectStore(N),i=await s.get(a);return await s.put(t,a),await n.done,i&&i.fid===t.fid||C(e,t.fid),t}async function R(e){const t=I(e),a=(await G()).transaction(N,"readwrite");await a.objectStore(N).delete(t),await a.done}async function H(e,t){const a=I(e),n=(await G()).transaction(N,"readwrite"),s=n.objectStore(N),i=await s.get(a),r=t(i);return r===undefined?await s.delete(a):await s.put(r,a),await n.done,!r||i&&i.fid===r.fid||C(e,r.fid),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.
 */async function U(e){let t;const a=await H(e.appConfig,a=>{const n=function(e){const t=e||{fid:S(),registrationStatus:0};return $(t)}(a),s=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine){return{installationEntry:t,registrationPromise:Promise.reject(p.create("app-offline"))}}const a={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},n=async function(e,t){try{const a=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:a}){const n=k(e),s=y(e),i=t.getImmediate({optional:!0});if(i){const e=await i.getHeartbeatsHeader();e&&s.append("x-firebase-client",e)}const r={fid:a,authVersion:m,appId:e.appId,sdkVersion:d},o={method:"POST",headers:s,body:JSON.stringify(r)},c=await x(()=>fetch(n,o));if(c.ok){const e=await c.json();return{fid:e.fid||a,registrationStatus:2,refreshToken:e.refreshToken,authToken:w(e.authToken)}}throw await b("Create Installation",c)}(e,t);return B(e.appConfig,a)}catch(a){throw g(a)&&409===a.customData.serverCode?await R(e.appConfig):await B(e.appConfig,{fid:t.fid,registrationStatus:0}),a}}(e,a);return{installationEntry:a,registrationPromise:n}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:q(e)}:{installationEntry:t}}(e,n);return t=s.registrationPromise,s.installationEntry});return a.fid===E?{installationEntry:await t}:{installationEntry:a,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:a}=await U(e);return a||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},a){const n=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,a),s=T(e,a),i=t.getImmediate({optional:!0});if(i){const e=await i.getHeartbeatsHeader();e&&s.append("x-firebase-client",e)}const r={installation:{sdkVersion:d,appId:e.appId}},o={method:"POST",headers:s,body:JSON.stringify(r)},c=await x(()=>fetch(n,o));if(c.ok){return w(await c.json())}throw await b("Generate Auth Token",c)}async function V(e,t=!1){let a;const n=await H(e.appConfig,n=>{if(!J(n))throw p.create("not-registered");const s=n.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)}(s))return n;if(1===s.requestStatus)return a=async function(e,t){let a=await z(e.appConfig);for(;1===a.authToken.requestStatus;)await _(100),a=await z(e.appConfig);const n=a.authToken;return 0===n.requestStatus?V(e,t):n}(e,t),n;{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})}(n);return a=async function(e,t){try{const a=await K(e,t),n=Object.assign(Object.assign({},t),{authToken:a});return await B(e.appConfig,n),a}catch(a){if(!g(a)||401!==a.customData.serverCode&&404!==a.customData.serverCode){const a=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await B(e.appConfig,a)}else await R(e.appConfig);throw a}}(e,t),t}});return a?await a:n.authToken}function z(e){return H(e,e=>{if(!J(e))throw p.create("not-registered");const t=e.authToken;return 1===(a=t).requestStatus&&a.requestTime+l<Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e;var 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 J(e){return e!==undefined&&2===e.registrationStatus}async function Y(e){const t=e,{installationEntry:a,registrationPromise:n}=await U(t);return n?n.catch(console.error):V(t).catch(console.error),a.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 Q(e,t=!1){const a=e;await async function(e){const{registrationPromise:t}=await U(e);t&&await t}(a);return(await V(a,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(),a=function(e){if(!e||!e.options)throw X("App Configuration");if(!e.name)throw X("App Name");const t=["projectId","apiKey","appId"];for(const a of t)if(!e.options[a])throw X(a);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:a,heartbeatServiceProvider:(0,n._getProvider)(t,"heartbeat"),_delete:()=>Promise.resolve()}},te=e=>{const t=e.getProvider("app").getImmediate(),a=(0,n._getProvider)(t,Z).getImmediate();return{getId:()=>Y(a),getToken:e=>Q(a,e)}};(0,n._registerComponent)(new s.Component(Z,ee,"PUBLIC")),(0,n._registerComponent)(new s.Component("installations-internal",te,"PRIVATE")),(0,n.registerVersion)(o,c),(0,n.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,a){Object.defineProperty(a,"__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 n=[];var s;a.LogLevel=void 0,(s=a.LogLevel||(a.LogLevel={}))[s.DEBUG=0]="DEBUG",s[s.VERBOSE=1]="VERBOSE",s[s.INFO=2]="INFO",s[s.WARN=3]="WARN",s[s.ERROR=4]="ERROR",s[s.SILENT=5]="SILENT";const i={debug:a.LogLevel.DEBUG,verbose:a.LogLevel.VERBOSE,info:a.LogLevel.INFO,warn:a.LogLevel.WARN,error:a.LogLevel.ERROR,silent:a.LogLevel.SILENT},r=a.LogLevel.INFO,o={[a.LogLevel.DEBUG]:"log",[a.LogLevel.VERBOSE]:"log",[a.LogLevel.INFO]:"info",[a.LogLevel.WARN]:"warn",[a.LogLevel.ERROR]:"error"},c=(e,t,...a)=>{if(t<e.logLevel)return;const n=(new Date).toISOString(),s=o[t];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[s](`[${n}]  ${e.name}:`,...a)};a.Logger=class{constructor(e){this.name=e,this._logLevel=r,this._logHandler=c,this._userLogHandler=null,n.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in a.LogLevel))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?i[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,a.LogLevel.DEBUG,...e),this._logHandler(this,a.LogLevel.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,a.LogLevel.VERBOSE,...e),this._logHandler(this,a.LogLevel.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,a.LogLevel.INFO,...e),this._logHandler(this,a.LogLevel.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,a.LogLevel.WARN,...e),this._logHandler(this,a.LogLevel.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,a.LogLevel.ERROR,...e),this._logHandler(this,a.LogLevel.ERROR,...e)}},a.setLogLevel=function(e){n.forEach(t=>{t.setLogLevel(e)})},a.setUserLogHandler=function(e,t){for(const s of n){let n=null;t&&t.level&&(n=i[t.level]),s.userLogHandler=null===e?null:(t,s,...i)=>{const r=i.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(" ");s>=(null!=n?n:t.logLevel)&&e({level:a.LogLevel[s].toLowerCase(),message:r,args:i,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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.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=I(e),a=(await v()).transaction(x,"readwrite");await a.objectStore(x).delete(t),await a.done}(e.firebaseDependencies));const a=await e.swRegistration.pushManager.getSubscription();if(a)return a.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,i.getModularInstance)(e))},a.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,r.getApp)()){return z().then(e=>{if(!e)throw C.create("unsupported-browser")},e=>{throw C.create("indexed-db-unsupported")}),(0,r._getProvider)((0,i.getModularInstance)(e),"messaging").getImmediate()},a.getToken=async function(e,t){return H(e=(0,i.getModularInstance)(e),t)},a.isSupported=z,a.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,i.getModularInstance)(e),t)},e("@firebase/installations");var n=e("@firebase/component"),s=e("idb"),i=e("@firebase/util"),r=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,"/"),a=atob(t),n=new Uint8Array(a.length);for(let e=0;e<a.length;++e)n[e]=a.charCodeAt(e);return 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.
 */!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",w=5,b="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,s.openDB)(y,T,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(x)}})),_}async function E(e){const t=I(e),a=await v(),n=await a.transaction(x).objectStore(x).get(t);if(n)return n;{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,s.openDB)(k,w,{upgrade:async(a,n,s,i)=>{var r;if(n<2)return;if(!a.objectStoreNames.contains(b))return;const o=i.objectStore(b),c=await o.index("fcmSenderId").get(e);if(await o.clear(),c)if(2===n){const e=c;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:null!==(r=e.createTime)&&void 0!==r?r: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===n){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===n){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,s.deleteDB)(k),await(0,s.deleteDB)("fcm_vapid_details_db"),await(0,s.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 S(e,t),t}}async function S(e,t){const a=I(e),n=(await v()).transaction(x,"readwrite");return await n.objectStore(x).put(t,a),await n.done,t}function I({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 P={"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 i.ErrorFactory("messaging","Messaging",P);async function j(e,t){const a={method:"DELETE",headers:await F(e)};try{const n=await fetch(`${A(e.appConfig)}/${t}`,a),s=await n.json();if(s.error){const e=s.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 a=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 ${a}`})}function D({p256dh:e,auth:t,endpoint:a,vapidKey:n}){const s={web:{endpoint:a,auth:t,p256dh:e}};return n!==l&&(s.web.applicationPubKey=n),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.
 */const M=6048e5;async function O(e){const t=await async function(e,t){const a=await e.pushManager.getSubscription();if(a)return a;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:g(t)})}(e.swRegistration,e.vapidKey),a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:p(t.getKey("auth")),p256dh:p(t.getKey("p256dh"))},n=await E(e.firebaseDependencies);if(n){if(function(e,t){const a=t.vapidKey===e.vapidKey,n=t.endpoint===e.endpoint,s=t.auth===e.auth,i=t.p256dh===e.p256dh;return a&&n&&s&&i}
/**
 * @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.
 */(n.subscriptionOptions,a))return Date.now()>=n.createTime+M?async function(e,t){try{const a=await async function(e,t){const a=await F(e),n=D(t.subscriptionOptions),s={method:"PATCH",headers:a,body:JSON.stringify(n)};let i;try{const a=await fetch(`${A(e.appConfig)}/${t.token}`,s);i=await a.json()}catch(e){throw C.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(i.error){const e=i.error.message;throw C.create("token-update-failed",{errorInfo:e})}if(!i.token)throw C.create("token-update-no-token");return i.token}(e.firebaseDependencies,t),n=Object.assign(Object.assign({},t),{token:a,createTime:Date.now()});return await S(e.firebaseDependencies,n),a}catch(e){throw e}}(e,{token:n.token,createTime:Date.now(),subscriptionOptions:a}):n.token;try{await j(e.firebaseDependencies,n.token)}catch(e){console.warn(e)}return N(e.firebaseDependencies,a)}return N(e.firebaseDependencies,a)}async function N(e,t){const 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.
 */await async function(e,t){const a=await F(e),n=D(t),s={method:"POST",headers:a,body:JSON.stringify(n)};let i;try{const t=await fetch(A(e.appConfig),s);i=await t.json()}catch(e){throw C.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(i.error){const e=i.error.message;throw C.create("token-subscribe-failed",{errorInfo:e})}if(!i.token)throw C.create("token-subscribe-no-token");return i.token}(e,t),n={token:a,createTime:Date.now(),subscriptionOptions:t};return await S(e,n),n.token}function L(e){const t={from:e.from,collapseKey:e.collapse_key,messageId:e.fcmMessageId};return function(e,t){if(!t.notification)return;e.notification={};const a=t.notification.title;a&&(e.notification.title=a);const n=t.notification.body;n&&(e.notification.body=n);const s=t.notification.image;s&&(e.notification.image=s);const i=t.notification.icon;i&&(e.notification.icon=i)}(t,e),function(e,t){if(!t.data)return;e.data=t.data}(t,e),function(e,t){var a,n,s,i,r;if(!t.fcmOptions&&!(null===(a=t.notification)||void 0===a?void 0:a.click_action))return;e.fcmOptions={};const o=null!==(s=null===(n=t.fcmOptions)||void 0===n?void 0:n.link)&&void 0!==s?s:null===(i=t.notification)||void 0===i?void 0:i.click_action;o&&(e.fcmOptions.link=o);const c=null===(r=t.fcmOptions)||void 0===r?void 0:r.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 G(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 a=[];for(let n=0;n<e.length;n++)a.push(e.charAt(n)),n<t.length&&a.push(t.charAt(n));a.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,a){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const n=function(e){if(!e||!e.options)throw G("App Configuration Object");if(!e.name)throw G("App Name");const t=["projectId","apiKey","appId","messagingSenderId"],{options:a}=e;for(const e of t)if(!a[e])throw G(e);return{appName:e.name,projectId:a.projectId,apiKey:a.apiKey,appId:a.appId,senderId:a.messagingSenderId}}(e);this.firebaseDependencies={app:e,appConfig:n,installations:t,analyticsProvider:a}}_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,a)=>{const n=setTimeout(()=>a(new Error(`Service worker not registered after ${u} ms`)),u),s=e.installing||e.waiting;e.active?(clearTimeout(n),t()):s?s.onstatechange=e=>{var a;"activated"===(null===(a=e.target)||void 0===a?void 0:a.state)&&(s.onstatechange=null,clearTimeout(n),t())}:(clearTimeout(n),a(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),O(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,a){const n=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(n,{message_id:a[m],message_name:a["google.c.a.c_l"],message_time:a["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)})}async function q(e,t){const a=t.data;if(!a.isFirebaseMessaging)return;e.onMessageHandler&&a.messageType===f.PUSH_RECEIVED&&("function"==typeof e.onMessageHandler?e.onMessageHandler(L(a)):e.onMessageHandler.next(L(a)));const n=a.data;var s;"object"==typeof(s=n)&&s&&m in s&&"1"===n["google.c.a.e"]&&await U(e,a.messageType,n)}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,i.validateIndexedDBOpenable)()}catch(e){return!1}return"undefined"!=typeof window&&(0,i.isIndexedDBAvailable)()&&(0,i.areCookiesEnabled)()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}(0,r._registerComponent)(new n.Component("messaging",K,"PUBLIC")),(0,r._registerComponent)(new n.Component("messaging-internal",V,"PRIVATE")),(0,r.registerVersion)(W,$),(0,r.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,a){Object.defineProperty(a,"__esModule",{value:!0}),e("@firebase/installations");var n=e("@firebase/component"),s=e("idb"),i=e("@firebase/util"),r=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,"/"),a=atob(t),n=new Uint8Array(a.length);for(let e=0;e<a.length;++e)n[e]=a.charCodeAt(e);return 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.
 */!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=s.openDB("firebase-messaging-database",1,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(p)}})),g}async function w(e){const t=y(e),a=await k(),n=await a.transaction(p).objectStore(p).get(t);if(n)return n;{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 s.openDB(h,5,{upgrade:async(a,n,s,i)=>{var r;if(n<2)return;if(!a.objectStoreNames.contains(f))return;const o=i.objectStore(f),c=await o.index("fcmSenderId").get(e);if(await o.clear(),c)if(2===n){const e=c;if(!e.auth||!e.p256dh||!e.endpoint)return;t={token:e.fcmToken,createTime:null!==(r=e.createTime)&&void 0!==r?r: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===n){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===n){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 s.deleteDB(h),await s.deleteDB("fcm_vapid_details_db"),await s.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 b(e,t),t}}async function b(e,t){const a=y(e),n=(await k()).transaction(p,"readwrite");return await n.objectStore(p).put(t,a),await n.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 i.ErrorFactory("messaging","Messaging",T);async function _(e,t){const a={method:"DELETE",headers:await E(e)};try{const n=await fetch(`${v(e.appConfig)}/${t}`,a),s=await n.json();if(s.error){const e=s.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 a=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 ${a}`})}function S({p256dh:e,auth:t,endpoint:a,vapidKey:n}){const s={web:{endpoint:a,auth:t,p256dh:e}};return n!==o&&(s.web.applicationPubKey=n),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.
 */async function I(e){const t=await async function(e,t){const a=await e.pushManager.getSubscription();if(a)return a;return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:u(t)})}(e.swRegistration,e.vapidKey),a={vapidKey:e.vapidKey,swScope:e.swRegistration.scope,endpoint:t.endpoint,auth:m(t.getKey("auth")),p256dh:m(t.getKey("p256dh"))},n=await w(e.firebaseDependencies);if(n){if(function(e,t){const a=t.vapidKey===e.vapidKey,n=t.endpoint===e.endpoint,s=t.auth===e.auth,i=t.p256dh===e.p256dh;return a&&n&&s&&i}
/**
 * @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.
 */(n.subscriptionOptions,a))return Date.now()>=n.createTime+6048e5?async function(e,t){try{const a=await async function(e,t){const a=await E(e),n=S(t.subscriptionOptions),s={method:"PATCH",headers:a,body:JSON.stringify(n)};let i;try{const a=await fetch(`${v(e.appConfig)}/${t.token}`,s);i=await a.json()}catch(e){throw x.create("token-update-failed",{errorInfo:null==e?void 0:e.toString()})}if(i.error){const e=i.error.message;throw x.create("token-update-failed",{errorInfo:e})}if(!i.token)throw x.create("token-update-no-token");return i.token}(e.firebaseDependencies,t),n=Object.assign(Object.assign({},t),{token:a,createTime:Date.now()});return await b(e.firebaseDependencies,n),a}catch(e){throw e}}(e,{token:n.token,createTime:Date.now(),subscriptionOptions:a}):n.token;try{await _(e.firebaseDependencies,n.token)}catch(e){console.warn(e)}return C(e.firebaseDependencies,a)}return C(e.firebaseDependencies,a)}async function P(e){const t=await w(e.firebaseDependencies);t&&(await _(e.firebaseDependencies,t.token),await async function(e){const t=y(e),a=(await k()).transaction(p,"readwrite");await a.objectStore(p).delete(t),await a.done}(e.firebaseDependencies));const a=await e.swRegistration.pushManager.getSubscription();return!a||a.unsubscribe()}async function C(e,t){const 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.
 */await async function(e,t){const a=await E(e),n=S(t),s={method:"POST",headers:a,body:JSON.stringify(n)};let i;try{const t=await fetch(v(e.appConfig),s);i=await t.json()}catch(e){throw x.create("token-subscribe-failed",{errorInfo:null==e?void 0:e.toString()})}if(i.error){const e=i.error.message;throw x.create("token-subscribe-failed",{errorInfo:e})}if(!i.token)throw x.create("token-subscribe-no-token");return i.token}(e,t),n={token:a,createTime:Date.now(),subscriptionOptions:t};return await b(e,n),n.token}async function j(e,t){const a=function(e,t){var a,n;const s={};e.from&&(s.project_number=e.from);e.fcmMessageId&&(s.message_id=e.fcmMessageId);s.instance_id=t,e.notification?s.message_type=l.DISPLAY_NOTIFICATION.toString():s.message_type=l.DATA_MESSAGE.toString();s.sdk_platform=3..toString(),s.package_name=self.origin.replace(/(^\w+:|^)\/\//,""),!e.collapse_key||(s.collapse_key=e.collapse_key);s.event=1..toString(),!(null===(a=e.fcmOptions)||void 0===a?void 0:a.analytics_label)||(s.analytics_label=null===(n=e.fcmOptions)||void 0===n?void 0:n.analytics_label);return s}(t,await e.firebaseDependencies.installations.getId());!function(e,t,a){const n={};n.event_time_ms=Math.floor(Date.now()).toString(),n.source_extension_json_proto3=JSON.stringify({messaging_client_event:t}),!a||(n.compliance_data=function(e){const t={privacy_context:{prequest:{origin_associated_product_id:e}}};return t}(a));e.logEvents.push(n)}(e,a,t.productId)}async function A(e,t){const a=function({data:e}){if(!e)return null;try{return e.json()}catch(e){return null}}(e);if(!a)return;t.deliveryMetricsExportedToBigQueryEnabled&&await j(t,a);const n=await D();if(function(e){return e.some(e=>"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://"))}(n))return function(e,t){t.isFirebaseMessaging=!0,t.messageType=d.PUSH_RECEIVED;for(const a of e)a.postMessage(t)}(n,a);if(a.notification&&await function(e){var t;const{actions:a}=e,{maxActions:n}=Notification;a&&n&&a.length>n&&console.warn(`This browser only supports ${n} 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}(a)),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 a=t.notification.title;a&&(e.notification.title=a);const n=t.notification.body;n&&(e.notification.body=n);const s=t.notification.image;s&&(e.notification.image=s);const i=t.notification.icon;i&&(e.notification.icon=i)}(t,e),function(e,t){t.data&&(e.data=t.data)}(t,e),function(e,t){var a,n,s,i,r;if(!t.fcmOptions&&!(null===(a=t.notification)||void 0===a?void 0:a.click_action))return;e.fcmOptions={};const o=null!==(s=null===(n=t.fcmOptions)||void 0===n?void 0:n.link)&&void 0!==s?s:null===(i=t.notification)||void 0===i?void 0:i.click_action;o&&(e.fcmOptions.link=o);const c=null===(r=t.fcmOptions)||void 0===r?void 0:r.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}(a);"function"==typeof t.onBackgroundMessageHandler?await t.onBackgroundMessageHandler(e):t.onBackgroundMessageHandler.next(e)}}async function F(e){var t,a;const n=null===(a=null===(t=e.notification)||void 0===t?void 0:t.data)||void 0===a?void 0:a[c];if(!n)return;if(e.action)return;e.stopImmediatePropagation(),e.notification.close();const s=function(e){var t,a,n;const s=null!==(a=null===(t=e.fcmOptions)||void 0===t?void 0:t.link)&&void 0!==a?a:null===(n=e.notification)||void 0===n?void 0:n.click_action;if(s)return s;return i=e.data,"object"==typeof i&&i&&"google.c.a.c_id"in i?self.location.origin:null;var 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.
 */}
/**
 * @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.
 */(n);if(!s)return;const i=new URL(s,self.location.href),r=new URL(self.location.origin);if(i.host!==r.host)return;let o=await async function(e){const t=await D();for(const a of t){const t=new URL(a.url,self.location.href);if(e.host===t.host)return a}return null}(i);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(s),await(l=3e3,new Promise(e=>{setTimeout(e,l)}))),o?(n.messageType=d.NOTIFICATION_CLICKED,n.isFirebaseMessaging=!0,o.postMessage(n)):void 0}function D(){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 a=[];for(let n=0;n<e.length;n++)a.push(e.charAt(n)),n<t.length&&a.push(t.charAt(n));a.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 O{constructor(e,t,a){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const n=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:a}=e;for(const e of t)if(!a[e])throw M(e);return{appName:e.name,projectId:a.projectId,apiKey:a.apiKey,appId:a.appId,senderId:a.messagingSenderId}}(e);this.firebaseDependencies={app:e,appConfig:n,installations:t,analyticsProvider:a}}_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 O(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 a,n;const{newSubscription:s}=e;if(!s)return void await P(t);const i=await w(t.firebaseDependencies);await P(t),t.vapidKey=null!==(n=null===(a=null==i?void 0:i.subscriptionOptions)||void 0===a?void 0:a.vapidKey)&&void 0!==n?n:o,await I(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 L(){return i.isIndexedDBAvailable()&&await i.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.
 */r._registerComponent(new n.Component("messaging-sw",N,"PUBLIC")),a.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=i.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.
 */,a.getMessaging=function(e=r.getApp()){return L().then(e=>{if(!e)throw x.create("unsupported-browser")},e=>{throw x.create("indexed-db-unsupported")}),r._getProvider(i.getModularInstance(e),"messaging-sw").getImmediate()},a.isSupported=L,a.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=i.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,a){(function(e){(function(){Object.defineProperty(a,"__esModule",{value:!0}),a.Sha1=a.RANDOM_FACTOR=a.MAX_VALUE_MILLIS=a.FirebaseError=a.ErrorFactory=a.Deferred=a.DecodeBase64StringError=a.CONSTANTS=void 0,a.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.
 */,a.assertionError=a.assert=void 0,a.async=function(e,t){return(...a)=>{Promise.resolve(!0).then(()=>{e(...a)}).catch(e=>{t&&t(e)})}},a.base64urlEncodeWithoutPadding=a.base64Encode=a.base64Decode=a.base64=void 0,a.calculateBackoffMillis=function(e,t=C,a=j){const n=t*Math.pow(a,e),s=Math.round(F*n*(Math.random()-.5)*2);return Math.min(A,n+s)}
/**
 * @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.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.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 a=t||"demo-project",n=e.iat||0,s=e.sub||e.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const i=Object.assign({iss:`https://securetoken.google.com/${a}`,aud:a,iat:n,exp:n+3600,auth_time:n,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},e);return[l(JSON.stringify({alg:"none",type:"JWT"})),l(JSON.stringify(i)),""].join(".")}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,a.createSubscribe=function(e,t){const a=new S(e,t);return a.subscribe.bind(a)},a.decode=void 0,a.deepCopy=function(e){return m(undefined,e)},a.deepEqual=function e(t,a){if(t===a)return!0;const n=Object.keys(t),s=Object.keys(a);for(const i of n){if(!s.includes(i))return!1;const n=t[i],r=a[i];if(E(n)&&E(r)){if(!e(n,r))return!1}else if(n!==r)return!1}for(const e of s)if(!n.includes(e))return!1;return!0},a.deepExtend=m,a.errorPrefix=P,a.extractQuerystring=function(e){const t=e.indexOf("?");if(!t)return"";const a=e.indexOf("#",t);return e.substring(t,a>0?a: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.
 */,a.getExperimentalSetting=a.getDefaults=a.getDefaultEmulatorHostnameAndPort=a.getDefaultEmulatorHost=a.getDefaultAppConfig=void 0,a.getGlobal=h,a.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},a.getUA=k,a.isAdmin=void 0,a.isBrowser=function(){return"undefined"!=typeof window||b()},a.isBrowserExtension=function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:undefined;return"object"==typeof e&&e.id!==undefined},a.isCloudflareWorker=function(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent},a.isElectron=function(){return k().indexOf("Electron/")>=0},a.isEmpty=function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},a.isIE=function(){const e=k();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0},a.isIndexedDBAvailable=function(){try{return"object"==typeof indexedDB}catch(e){return!1}},a.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(k())},a.isNode=w,a.isNodeSdk=function(){return!0===t.NODE_CLIENT||!0===t.NODE_ADMIN},a.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},a.isSafari=function(){return!w()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},a.isUWP=function(){return k().indexOf("MSAppHost/")>=0},a.isValidTimestamp=a.isValidFormat=void 0,a.isWebWorker=b,a.issuedAtTime=void 0,a.jsonEval=_,a.map=function(e,t,a){const n={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=t.call(a,e[s],s,e));return n},a.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 a=e%10;if(1===a)return"st";if(2===a)return"nd";if(3===a)return"rd";return"th"}(e)},a.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 a=new g;return setTimeout(()=>a.reject("timeout!"),t),e.then(a.resolve,a.reject),a.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.
 */,a.querystring=function(e){const t=[];for(const[a,n]of Object.entries(e))Array.isArray(n)?n.forEach(e=>{t.push(encodeURIComponent(a)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(a)+"="+encodeURIComponent(n));return t.length?"&"+t.join("&"):""},a.querystringDecode=function(e){const t={},a=e.replace(/^\?/,"").split("&");return a.forEach(e=>{if(e){const[a,n]=e.split("=");t[decodeURIComponent(a)]=decodeURIComponent(n)}}),t},a.safeGet=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:undefined},a.stringToByteArray=a.stringLength=void 0,a.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.
 */,a.validateArgCount=void 0,a.validateCallback=function(e,t,a,n){if(n&&!a)return;if("function"!=typeof a)throw new Error(P(e,t)+"must be a valid function.")},a.validateContextObject=function(e,t,a,n){if(n&&!a)return;if("object"!=typeof a||null===a)throw new Error(P(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.
 */,a.validateIndexedDBOpenable=function(){return new Promise((e,t)=>{try{let a=!0;const n="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(n);s.onsuccess=()=>{s.result.close(),a||self.indexedDB.deleteDatabase(n),e(!0)},s.onupgradeneeded=()=>{a=!1},s.onerror=()=>{var e;t((null===(e=s.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}})},a.validateNamespace=function(e,t,a){if(a&&!t)return;if("string"!=typeof t)throw new Error(P(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=a.CONSTANTS={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},n=function(e,t){if(!e)throw s(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.
 */a.assert=n;const s=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.
 */a.assertionError=s;const i=function(e){const t=[];let a=0;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);s<128?t[a++]=s:s<2048?(t[a++]=s>>6|192,t[a++]=63&s|128):55296==(64512&s)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++n)),t[a++]=s>>18|240,t[a++]=s>>12&63|128,t[a++]=s>>6&63|128,t[a++]=63&s|128):(t[a++]=s>>12|224,t[a++]=s>>6&63|128,t[a++]=63&s|128)}return t},r=a.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 a=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let t=0;t<e.length;t+=3){const s=e[t],i=t+1<e.length,r=i?e[t+1]:0,o=t+2<e.length,c=o?e[t+2]:0,l=s>>2,d=(3&s)<<4|r>>4;let m=(15&r)<<2|c>>6,u=63&c;o||(u=64,i||(m=64)),n.push(a[l],a[d],a[m],a[u])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(i(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let a=0,n=0;for(;a<e.length;){const s=e[a++];if(s<128)t[n++]=String.fromCharCode(s);else if(s>191&&s<224){const i=e[a++];t[n++]=String.fromCharCode((31&s)<<6|63&i)}else if(s>239&&s<365){const i=((7&s)<<18|(63&e[a++])<<12|(63&e[a++])<<6|63&e[a++])-65536;t[n++]=String.fromCharCode(55296+(i>>10)),t[n++]=String.fromCharCode(56320+(1023&i))}else{const i=e[a++],r=e[a++];t[n++]=String.fromCharCode((15&s)<<12|(63&i)<<6|63&r)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const a=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let t=0;t<e.length;){const s=a[e.charAt(t++)],i=t<e.length?a[e.charAt(t)]:0;++t;const r=t<e.length?a[e.charAt(t)]:64;++t;const c=t<e.length?a[e.charAt(t)]:64;if(++t,null==s||null==i||null==r||null==c)throw new o;const l=s<<2|i>>4;if(n.push(l),64!==r){const e=i<<4&240|r>>2;if(n.push(e),64!==c){const e=r<<6&192|c;n.push(e)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class o extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}a.DecodeBase64StringError=o;const c=function(e){const t=i(e);return r.encodeByteArray(t,!0)};a.base64Encode=c;const l=function(e){return c(e).replace(/\./g,"")};a.base64urlEncodeWithoutPadding=l;const d=function(e){try{return r.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 a in t)t.hasOwnProperty(a)&&u(a)&&(e[a]=m(e[a],t[a]));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.
 */a.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}`)}};a.getDefaults=f;const p=e=>{var t,a;return null===(a=null===(t=f())||void 0===t?void 0:t.emulatorHosts)||void 0===a?void 0:a[e]};a.getDefaultEmulatorHost=p;a.getDefaultEmulatorHostnameAndPort=e=>{const t=p(e);if(!t)return undefined;const a=t.lastIndexOf(":");if(a<=0||a+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const n=parseInt(t.substring(a+1),10);return"["===t[0]?[t.substring(1,a-1),n]:[t.substring(0,a),n]};a.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.
 */
a.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,a)=>{t?this.reject(t):this.resolve(a),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,a))}}}
/**
 * @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 w(){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 b(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}a.Deferred=g;class y extends Error{constructor(e,t,a){super(t),this.code=e,this.customData=a,this.name="FirebaseError",Object.setPrototypeOf(this,y.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,T.prototype.create)}}a.FirebaseError=y;class T{constructor(e,t,a){this.service=e,this.serviceName=t,this.errors=a}create(e,...t){const a=t[0]||{},n=`${this.service}/${e}`,s=this.errors[e],i=s?function(e,t){return e.replace(x,(e,a)=>{const n=t[a];return null!=n?String(n):`<${a}?>`})}(s,a):"Error",r=`${this.serviceName}: ${i} (${n}).`;return new y(n,r,a)}}a.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={},a={},n={},s="";try{const i=e.split(".");t=_(d(i[0])||""),a=_(d(i[1])||""),s=i[2],n=a.d||{},delete a.d}catch(e){}return{header:t,claims:a,data:n,signature:s}};a.decode=v;a.isValidTimestamp=function(e){const t=v(e).claims,a=Math.floor((new Date).getTime()/1e3);let n=0,s=0;return"object"==typeof t&&(t.hasOwnProperty("nbf")?n=t.nbf:t.hasOwnProperty("iat")&&(n=t.iat),s=t.hasOwnProperty("exp")?t.exp:n+86400),!!a&&!!n&&!!s&&a>=n&&a<=s};a.issuedAtTime=function(e){const t=v(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null};a.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.
 */
a.isAdmin=function(e){const t=v(e).claims;return"object"==typeof t&&!0===t.admin};a.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 a=this.W_;if("string"==typeof e)for(let n=0;n<16;n++)a[n]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let n=0;n<16;n++)a[n]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let e=16;e<80;e++){const t=a[e-3]^a[e-8]^a[e-14]^a[e-16];a[e]=4294967295&(t<<1|t>>>31)}let n,s,i=this.chain_[0],r=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?(n=c^r&(o^c),s=1518500249):(n=r^o^c,s=1859775393):e<60?(n=r&o|c&(r|o),s=2400959708):(n=r^o^c,s=3395469782);const t=(i<<5|i>>>27)+n+l+s+a[e]&4294967295;l=c,c=o,o=4294967295&(r<<30|r>>>2),r=i,i=t}this.chain_[0]=this.chain_[0]+i&4294967295,this.chain_[1]=this.chain_[1]+r&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 a=t-this.blockSize;let n=0;const s=this.buf_;let i=this.inbuf_;for(;n<t;){if(0===i)for(;n<=a;)this.compress_(e,n),n+=this.blockSize;if("string"==typeof e){for(;n<t;)if(s[i]=e.charCodeAt(n),++i,++n,i===this.blockSize){this.compress_(s),i=0;break}}else for(;n<t;)if(s[i]=e[n],++i,++n,i===this.blockSize){this.compress_(s),i=0;break}}this.inbuf_=i,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&t,t/=256;this.compress_(this.buf_);let a=0;for(let t=0;t<5;t++)for(let n=24;n>=0;n-=8)e[a]=this.chain_[t]>>n&255,++a;return e}};class S{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,a){let n;if(e===undefined&&t===undefined&&a===undefined)throw new Error("Missing Observer.");n=function(e,t){if("object"!=typeof e||null===e)return!1;for(const a of t)if(a in e&&"function"==typeof e[a])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:a},n.next===undefined&&(n.next=I),n.error===undefined&&(n.error=I),n.complete===undefined&&(n.complete=I);const s=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?n.error(this.finalError):n.complete()}catch(e){}}),this.observers.push(n),s}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 I(){}
/**
 * @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,t){return`${e} failed: ${t} argument `}a.validateArgCount=function(e,t,a,n){let s;if(n<t?s="at least "+t:n>a&&(s=0===a?"none":"no more than "+a),s){throw new Error(e+" failed: Was called with "+n+(1===n?" argument.":" arguments.")+" Expects "+s+".")}};a.stringToByteArray=function(e){const t=[];let a=0;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);if(i>=55296&&i<=56319){const t=i-55296;s++,n(s<e.length,"Surrogate pair missing trail surrogate.");i=65536+(t<<10)+(e.charCodeAt(s)-56320)}i<128?t[a++]=i:i<2048?(t[a++]=i>>6|192,t[a++]=63&i|128):i<65536?(t[a++]=i>>12|224,t[a++]=i>>6&63|128,t[a++]=63&i|128):(t[a++]=i>>18|240,t[a++]=i>>12&63|128,t[a++]=i>>6&63|128,t[a++]=63&i|128)}return t};
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
a.stringLength=function(e){let t=0;for(let a=0;a<e.length;a++){const n=e.charCodeAt(a);n<128?t++:n<2048?t+=2:n>=55296&&n<=56319?(t+=4,a++):t+=3}return t};const C=1e3,j=2,A=a.MAX_VALUE_MILLIS=144e5,F=a.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,a){Object.defineProperty(a,"__esModule",{value:!0});class n{static parse(e){if(""===e)return new n([]);if(!e.startsWith("/"))throw new s(e);const[,...t]=e.split("/");return new n(t.map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~")))}constructor(e){this.tokens=e}toString(){if(0===this.tokens.length)return"";return`/${this.tokens.map(e=>e.replace(/~/g,"~0").replace(/\//g,"~1")).join("/")}`}shmeval(e){for(const t of this.tokens){if(!e.hasOwnProperty(t))throw new i(e,t);e=e[t]}return e}}a.default=n;class s extends Error{constructor(e){super(`Invalid JSON Pointer: ${e}`),this.ptr=e}}a.InvalidPtrError=s;class i extends Error{constructor(e,t){super(`Error evaluating JSON Pointer: no attribute ${t} on ${e}`),this.instance=e,this.token=t}}a.EvalError=i}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver>@json-schema-spec/json-pointer",file:"node_modules/@json-schema-spec/json-pointer/lib/index.js"}],["/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,a){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var s in t=arguments[a])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},n.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,a,n){return new(a||(a=Promise))(function(s,i){function r(e){try{c(n.next(e))}catch(e){i(e)}}function o(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof a?t:new a(function(e){e(t)})).then(r,o)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var a,n,s,i,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(c){return function(o){if(a)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(r=0)),r;)try{if(a=1,n&&(s=2&o[0]?n.return:o[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,o[1])).done)return s;switch(n=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,n=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){r.label=o[1];break}if(6===o[0]&&r.label<s[1]){r.label=s[1],s=o;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(o);break}s[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],n=0}finally{a=s=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(a,"__esModule",{value:!0}),a.NonStringRefError=void 0;var o=r(e("@json-schema-tools/traverse")),c=r(e("@json-schema-tools/reference-resolver")),l=r(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")};a.NonStringRefError=d;var m=function(e,t){if(e.$ref!==undefined&&Object.keys(e).length>1&&!0!==t&&!1!==t){var a=n(n({},t),e);return delete a.$ref,a}return t},u=function(){function e(e,t){var a;if(void 0===t&&(t={}),this.options=t,this.refCache={},a=!0===this.options.mutate||!0===e||!1===e?e:n({},e),this.options.recursive===undefined&&(this.options.recursive=!0),this.options.rootSchema===undefined&&(this.options.rootSchema=a),!0!==e&&!1!==e&&e.$id&&(this.options.rootSchema=a),this.options.refCache&&(this.refCache=this.options.refCache),this.options.protocolHandlerMap)for(var s=0,i=Object.keys(this.options.protocolHandlerMap);s<i.length;s++){var r=i[s];c.default.protocolHandlerMap[r]=this.options.protocolHandlerMap[r]}this.schema=a,this.refs=this.collectRefs()}return e.prototype.resolve=function(){return s(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._resolve()];case 1:return e.sent(),delete this.schema.definitions,delete this.schema.components,[2,this.schema]}})})},e.prototype._resolve=function(){return s(this,void 0,void 0,function(){var t,a,s,r,l,d,u,h,f,p,g,k=this;return i(this,function(i){switch(i.label){case 0:if(!0===this.schema||!1===this.schema)return[2,Promise.resolve(this.schema)];if(0===this.refs.length)return[2,Promise.resolve(this.schema)];t=this.refs.filter(function(e){return k.refCache[e]===undefined}),a=[],s=0,r=t,i.label=1;case 1:return s<r.length?(l=r[s],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),a.push(u),[4,u];case 4:d=i.sent(),i.label=5;case 5:return!0!==this.options.recursive||!0===d||!1===d||"#"===l?[3,9]:(h=n(n({},this.options),{refCache:this.refCache}),0===(f=new e(d,h)).refs.length?[3,7]:(p=f._resolve(),a.push(p),[4,p]));case 6:return g=i.sent(),this.refCache[l]=m(d,g),[3,8];case 7:this.refCache[l]=d,i.label=8;case 8:return[3,10];case 9:this.refCache[l]=d,i.label=10;case 10:return s++,[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(a)];case 12:return i.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}();a.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,a){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.NonStringRefError=void 0;var s=n(e("./dereferencer")),i=e("./dereferencer");Object.defineProperty(a,"NonStringRefError",{enumerable:!0,get:function(){return i.NonStringRefError}}),a.default=s.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.jsonSchema=void 0,a.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:[]}}},a.default=a.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,a){var n=this&&this.__awaiter||function(e,t,a,n){return new(a||(a=Promise))(function(s,i){function r(e){try{c(n.next(e))}catch(e){i(e)}}function o(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof a?t:new a(function(e){e(t)})).then(r,o)}c((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var a,n,s,i,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(c){return function(o){if(a)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(r=0)),r;)try{if(a=1,n&&(s=2&o[0]?n.return:o[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,o[1])).done)return s;switch(n=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,n=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){r.label=o[1];break}if(6===o[0]&&r.label<s[1]){r.label=s[1],s=o;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(o);break}s[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],n=0}finally{a=s=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(a,"__esModule",{value:!0});var r=e("./errors"),o=i(e("isomorphic-fetch")),c=function(e){return n(void 0,void 0,void 0,function(){var t,a;return s(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,(0,o.default)(e)];case 1:return t=n.sent(),[3,3];case 2:throw n.sent(),new r.InvalidRemoteURLError(e);case 3:return n.trys.push([3,5,,6]),[4,t.json()];case 4:return[2,n.sent()];case 5:throw a=n.sent(),new r.NonJsonRefError({$ref:e},a.message);case 6:return[2]}})})};a.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.InvalidFileSystemPathError=a.InvalidRemoteURLError=a.NotResolvableError=a.NonJsonRefError=void 0;var n=function(e,t){this.name="NonJsonRefError",this.message=["NonJsonRefError","The resolved value at the reference: ".concat(e.$ref," was not JSON.parse 'able"),"The non-json content in question: ".concat(t)].join("\n")};a.NonJsonRefError=n;var s=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")};a.NotResolvableError=s;var i=function(e){this.name="InvalidRemoteURLError",this.message=["InvalidRemoteURLError","The url was not resolvable: ".concat(e)].join("\n")};a.InvalidRemoteURLError=i;var r=function(e){this.name="InvalidFileSystemPathError",this.message=["InvalidFileSystemPathError","The path was not resolvable: ".concat(e)].join("\n")};a.InvalidFileSystemPathError=r}}},{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,a){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var s in t=arguments[a])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},n.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,a,n){return new(a||(a=Promise))(function(s,i){function r(e){try{c(n.next(e))}catch(e){i(e)}}function o(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof a?t:new a(function(e){e(t)})).then(r,o)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var a,n,s,i,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(c){return function(o){if(a)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(r=0)),r;)try{if(a=1,n&&(s=2&o[0]?n.return:o[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,o[1])).done)return s;switch(n=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,n=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){r.label=o[1];break}if(6===o[0]&&r.label<s[1]){r.label=s[1],s=o;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(o);break}s[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],n=0}finally{a=s=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(a,"__esModule",{value:!0});var o=r(e("./default-protocol-handler-map")),c=r(e("./reference-resolver")),l=n(n({},o.default),{file:function(){return s(void 0,void 0,void 0,function(){return i(this,function(e){return[2,undefined]})})}});a.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,a){var n=this&&this.__awaiter||function(e,t,a,n){return new(a||(a=Promise))(function(s,i){function r(e){try{c(n.next(e))}catch(e){i(e)}}function o(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof a?t:new a(function(e){e(t)})).then(r,o)}c((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var a,n,s,i,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(c){return function(o){if(a)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(r=0)),r;)try{if(a=1,n&&(s=2&o[0]?n.return:o[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,o[1])).done)return s;switch(n=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,n=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){r.label=o[1];break}if(6===o[0]&&r.label<s[1]){r.label=s[1],s=o;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(o);break}s[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],n=0}finally{a=s=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(a,"__esModule",{value:!0});var r=e("./errors"),o=i(e("./resolve-pointer")),c=function(){function e(e){this.protocolHandlerMap=e}return e.prototype.resolve=function(e){return n(this,arguments,void 0,function(e,t){var a,n,i,c,l,d,m,u,h,f;return void 0===t&&(t={}),s(this,function(s){switch(s.label){case 0:if("#"===e[0])return[2,Promise.resolve((0,o.default)(e,t))];(a=e.split("#")).length>1&&(n=a[a.length-1]),i=a[0],s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.protocolHandlerMap.file(i,t)];case 2:return c=s.sent(),[3,4];case 3:throw l=s.sent(),new r.NonJsonRefError({$ref:e},l.message);case 4:if(c!==undefined)return f=c,n&&(f=(0,o.default)(n,f)),[2,f];if(!1===e.includes("://"))throw new r.InvalidFileSystemPathError(e);d=0,m=Object.keys(this.protocolHandlerMap),s.label=5;case 5:return d<m.length?(u=m[d],i.startsWith(u)?[4,this.protocolHandlerMap[u](i,t)]:[3,7]):[3,8];case 6:if((h=s.sent())!==undefined)return f=h,n&&(f=(0,o.default)(n,f)),[2,f];s.label=7;case 7:return d++,[3,5];case 8:throw new r.NotResolvableError(e)}})})},e}();a.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,a){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.InvalidJsonPointerRefError=void 0;var s=n(e("@json-schema-spec/json-pointer")),i=function(e,t){this.name="InvalidJsonPointerRefError",this.message=["InvalidJsonPointerRefError","The provided RFC6901 JSON Pointer is invalid: ".concat(e),"","addition info: ",t].join("\n")};a.InvalidJsonPointerRefError=i,a.default=function(e,t){try{var a=e.replace("#","");return s.default.parse(a).shmeval(t)}catch(t){throw new i(e,t.message)}}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/resolve-pointer.js"}],["/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,a){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var s in t=arguments[a])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},n.apply(this,arguments)},s=this&&this.__spreadArray||function(e,t,a){if(a||2===arguments.length)for(var n,s=0,i=t.length;s<i;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(a,"__esModule",{value:!0}),a.defaultOptions=void 0,a.defaultOptions={skipFirstMutation:!1,mutable:!1,bfs:!1};var i=function(e){return e.map(function(e){return""===e?"$":".".concat(e)}).join("")},r=function(e,t){var a=t.find(function(t){return t===e});return a||!1},o=function(e,t){return void 0===t&&(t=1),e[e.length-t]};a.default=function e(t,c,l,d,m,u,h,f,p){void 0===l&&(l=a.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=n(n({},a.defaultOptions),l);if(0===d&&(h=[""]),"boolean"==typeof t||t instanceof Boolean)return!0===g.skipFirstMutation&&0===d?t:c(t,!1,i(h),o(u));var k=t;!1===g.mutable&&(k=n({},t)),u.push(k),!0===g.bfs&&(!1!==g.skipFirstMutation&&0===d||(k=c(k,!1,i(h),o(u,2)))),m.push(t),f.push([t,k]);var w=function(t,a){var n=r(t,m);return n?(p.push(n),!0===g.skipFirstMutation&&n===m[0]?c(t,!0,i(a),o(u)):f.find(function(e){var t=e[0];return n===t})[1]):e(t,c,l,d+1,m,u,a,f,p)};if(t.anyOf)k.anyOf=t.anyOf.map(function(e,t){return w(e,s(s([],h,!0),["anyOf[".concat(t,"]")],!1))});else if(t.allOf)k.allOf=t.allOf.map(function(e,t){return w(e,s(s([],h,!0),["allOf[".concat(t,"]")],!1))});else if(t.oneOf)k.oneOf=t.oneOf.map(function(e,t){return w(e,s(s([],h,!0),["oneOf[".concat(t,"]")],!1))});else{if(t.items)if(t.items instanceof Array)k.items=t.items.map(function(e,t){return w(e,s(s([],h,!0),["items[".concat(t,"]")],!1))});else{var b=r(t.items,m);if(b)if(p.push(b),!0===g.skipFirstMutation&&b===m[0])k.items=c(t.items,!0,i(h),o(u));else{var y=f.find(function(e){var t=e[0];return b===t})[1];k.items=y}else k.items=e(t.items,c,l,d+1,m,u,s(s([],h,!0),["items"],!1),f,p)}if(t.additionalItems!==undefined&&(k.additionalItems=w(t.additionalItems,s(s([],h,!0),["additionalItems"],!1))),t.properties!==undefined){var T=t.properties,x={};Object.keys(t.properties).forEach(function(e){x[e]=w(T[e],s(s([],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]=w(_[e],s(s([],h,!0),["patternProperties",e.toString()],!1))}),k.patternProperties=v}t.additionalProperties!==undefined&&!0==!!t.additionalProperties&&(k.additionalProperties=w(t.additionalProperties,s(s([],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,i(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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.AddressBookController=a.getDefaultAddressBookControllerState=a.controllerName=a.AddressType=void 0;const n=e("@metamask/base-controller"),s=e("@metamask/controller-utils");var i;!function(e){e.externallyOwnedAccounts="EXTERNALLY_OWNED_ACCOUNTS",e.contractAccounts="CONTRACT_ACCOUNTS",e.nonAccounts="NON_ACCOUNTS"}(i||(a.AddressType=i={})),a.controllerName="AddressBookController";const r=["list","set","delete","clear"],o={addressBook:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0}};a.getDefaultAddressBookControllerState=()=>({addressBook:{}});class c extends n.BaseController{constructor({messenger:e,state:t}){const n={...(0,a.getDefaultAddressBookControllerState)(),...t};super({messenger:e,metadata:o,name:a.controllerName,state:n}),this.messenger.registerMethodActionHandlers(this,r)}list(){const{addressBook:e}=this.state;return Object.keys(e).reduce((t,a)=>{const n=a;return[...t,...Object.values(e[n])]},[])}clear(){this.update(e=>{e.addressBook={}})}delete(e,t){if(t=(0,s.toChecksumHexAddress)(t),![e,t].every(e=>(0,s.isSafeDynamicKey)(e))||!(0,s.isValidHexAddress)(t)||!this.state.addressBook[e]?.[t])return!1;const a={...this.state.addressBook[e][t]};return this.update(a=>{const n=a.addressBook[e];n?.[t]&&(delete n[t],0===Object.keys(n).length&&delete a.addressBook[e])}),"*"!==String(e)&&this.messenger.publish("AddressBookController:contactDeleted",a),!0}set(e,t,a=(0,s.toHex)(1),n="",i){if(e=(0,s.toChecksumHexAddress)(e),!(0,s.isValidHexAddress)(e))return!1;const r={address:e,chainId:a,isEns:!1,memo:n,name:t,addressType:i,lastUpdatedAt:Date.now()},o=(0,s.normalizeEnsName)(t);return o&&(r.name=o,r.isEns=!0),this.update(t=>{t.addressBook={...this.state.addressBook,[a]:{...this.state.addressBook[a],[e]:r}}}),"*"!==String(a)&&this.messenger.publish("AddressBookController:contactUpdated",r),!0}}a.AddressBookController=c,a.default=c}}},{package:"@metamask/address-book-controller",file:"node_modules/@metamask/address-book-controller/dist/AddressBookController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/address-book-controller/dist/index.cjs",{"./AddressBookController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/address-book-controller/dist/AddressBookController.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.AddressBookController=a.getDefaultAddressBookControllerState=void 0;var n=e("./AddressBookController.cjs");Object.defineProperty(a,"getDefaultAddressBookControllerState",{enumerable:!0,get:function(){return n.getDefaultAddressBookControllerState}}),Object.defineProperty(a,"AddressBookController",{enumerable:!0,get:function(){return n.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,a){var n,s,i=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.AnnouncementController=void 0;const r=e("@metamask/base-controller"),o={announcements:{}},c={announcements:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!0,usedInUi:!0}};class l extends r.BaseController{constructor({messenger:e,state:t,allAnnouncements:a}){const r={...o,...t};super({messenger:e,metadata:c,name:"AnnouncementController",state:r}),n.add(this),i(this,n,"m",s).call(this,a)}resetViewed(){this.update(({announcements:e})=>{for(const t of Object.values(e))t.isShown=!1})}updateViewed(e){this.update(({announcements:t})=>{for(const a of Object.keys(e).map(Number))t[a].isShown=e[a]})}}a.AnnouncementController=l,n=new WeakSet,s=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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.AnnouncementController=void 0;var n=e("./AnnouncementController.cjs");Object.defineProperty(a,"AnnouncementController",{enumerable:!0,get:function(){return n.AnnouncementController}})}}},{package:"@metamask/announcement-controller",file:"node_modules/@metamask/announcement-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs",{"./bridge-status-controller.intent.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.intent.cjs","./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/types.cjs","./utils/accounts.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs","./utils/authentication.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs","./utils/bridge-status.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.cjs","./utils/bridge.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge.cjs","./utils/history.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/history.cjs","./utils/intent-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs","./utils/keyring.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/keyring.cjs","./utils/metrics.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/metrics.cjs","./utils/network.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs","./utils/snaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/snaps.cjs","./utils/trace.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/trace.cjs","./utils/transaction.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/polling-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/polling-controller/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/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,a){var n,s,i,r,o,c,l,d,m,u,h,f,p,g,k,w,b,y,T,x,_=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},v=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.BridgeStatusController=void 0;const E=e("@metamask/bridge-controller"),S=e("@metamask/polling-controller"),I=e("@metamask/transaction-controller"),P=e("@metamask/utils"),C=e("./bridge-status-controller.intent.cjs"),j=e("./constants.cjs"),A=e("./types.cjs"),F=e("./utils/accounts.cjs"),D=e("./utils/authentication.cjs"),M=e("./utils/bridge.cjs"),O=e("./utils/bridge-status.cjs"),N=e("./utils/history.cjs"),L=e("./utils/intent-api.cjs"),G=e("./utils/keyring.cjs"),B=e("./utils/metrics.cjs"),R=e("./utils/network.cjs"),H=e("./utils/snaps.cjs"),U=e("./utils/trace.cjs"),q=e("./utils/transaction.cjs"),W={txHistory:{includeInStateLogs:!0,persist:!0,includeInDebugSnapshot:!1,usedInUi:!0}};class $ extends((0,S.StaticIntervalPollingController)()){constructor({messenger:e,state:t,clientId:a,fetchFn:S,addTransactionBatchFn:$,config:K,traceFn:V}){super({name:j.BRIDGE_STATUS_CONTROLLER_NAME,metadata:W,messenger:e,state:{...j.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE,...t}}),n.set(this,{}),s.set(this,void 0),i.set(this,void 0),r.set(this,void 0),o.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,({id:e,actionId:t})=>{let a=this.state.txHistory[e]?e:undefined;if(!a&&t&&this.state.txHistory[t]&&(a=t),a??(a=Object.keys(this.state.txHistory).find(t=>this.state.txHistory[t].approvalTxId===e)),!a)return;const n=a;this.update(e=>{e.txHistory[n].status.status=E.StatusTypes.FAILED})}),this.resetState=()=>{this.update(e=>{e.txHistory=j.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory})},this.wipeBridgeStatus=({address:e,ignoreNetwork:t})=>{if(t)this.update(e=>{e.txHistory=j.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory});else{const t=(0,R.getSelectedChainId)(this.messenger);v(this,b,"f").call(this,e,t)}},this.restartPollingForFailedAttempts=e=>{const{txMetaId:t,txHash:a}=e;if(!t&&!a)throw new Error("Either txMetaId or txHash must be provided");let s;if(t?this.state.txHistory[t]&&(s=t):a&&(s=Object.keys(this.state.txHistory).find(e=>this.state.txHistory[e].status.srcChain.txHash===a)),!s)throw new Error("No bridge transaction history found for "+(t?`txMetaId: ${t}`:`txHash: ${a}`));const i=this.state.txHistory[s],r=i.attempts?.counter??0;if(this.update(e=>{s&&(e.txHistory[s].attempts=undefined)}),(0,N.shouldPollHistoryItem)(i)){if(!v(this,n,"f")[s]&&(v(this,f,"f").call(this,s),!i.featureId)){const e=(0,F.getAccountByAddress)(this.messenger,i.account),t=(0,B.getRequestParamFromHistory)(i),a=(0,B.getRequestMetadataFromHistory)(i,e),{security_warnings:n,...o}=a;v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.PollingStatusUpdated,s,{...(0,B.getTradeDataFromHistory)(i),...(0,B.getPriceImpactFromQuote)(i.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:E.MetricsActionType.SWAPBRIDGE_V1,polling_status:E.PollingStatus.ManuallyRestarted,retry_attempts:r})}}},this.getBridgeHistoryItemByTxMetaId=e=>this.state.txHistory[e],m.set(this,()=>{const{txHistory:e}=this.state;Object.values(e).filter(e=>e.status.status===E.StatusTypes.PENDING||e.status.status===E.StatusTypes.UNKNOWN).filter(e=>Boolean(e.txMetaId)).filter(e=>!v(this,n,"f")[e.txMetaId]).filter(e=>(0,N.shouldPollHistoryItem)(e)).forEach(e=>{const t=e.txMetaId;(0,O.shouldSkipFetchDueToFetchFailures)(e.attempts)||v(this,f,"f").call(this,t)})}),u.set(this,(...e)=>{const{historyKey:t,txHistoryItem:a}=(0,N.getInitialHistoryItem)(...e);this.update(e=>{e.txHistory[t]=a})}),h.set(this,(e,t)=>{this.update(a=>{(0,N.rekeyHistoryItemInState)(a,e,t)})}),f.set(this,e=>{const t=v(this,n,"f")[e];t&&this.stopPollingByPollingToken(t);const a=this.state.txHistory[e];a&&(0,N.shouldPollHistoryItem)(a)&&(v(this,n,"f")[e]=this.startPolling({bridgeTxMetaId:e}))}),this.startPollingForBridgeTxStatus=e=>{const{bridgeTxMeta:t}=e;if(!t?.id)throw new Error("Cannot start polling: bridgeTxMeta.id is required for polling");v(this,u,"f").call(this,e),v(this,f,"f").call(this,t.id)},this._executePoll=async e=>{await v(this,g,"f").call(this,e)},p.set(this,e=>{const{attempts:t}=this.state.txHistory[e],a=t?{counter:t.counter+1,lastAttemptTime:Date.now()}:{counter:1,lastAttemptTime:Date.now()},s=v(this,n,"f")[e];if(a.counter>=j.MAX_ATTEMPTS&&s){this.stopPollingByPollingToken(s),delete v(this,n,"f")[e];const t=this.state.txHistory[e];if(t&&!t.featureId){const n=(0,F.getAccountByAddress)(this.messenger,t.account),s=(0,B.getRequestParamFromHistory)(t),i=(0,B.getRequestMetadataFromHistory)(t,n),{security_warnings:r,...o}=i;v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.PollingStatusUpdated,e,{...(0,B.getTradeDataFromHistory)(t),...(0,B.getPriceImpactFromQuote)(t.quote),...o,chain_id_source:s.chain_id_source,chain_id_destination:s.chain_id_destination,token_symbol_source:s.token_symbol_source,token_symbol_destination:s.token_symbol_destination,action_type:E.MetricsActionType.SWAPBRIDGE_V1,polling_status:E.PollingStatus.MaxPollingReached,retry_attempts:a.counter})}}this.update(t=>{t.txHistory[e].attempts=a})}),g.set(this,async({bridgeTxMetaId:e})=>{const{txHistory:t}=this.state,a=t[e];if(a&&!(0,O.shouldSkipFetchDueToFetchFailures)(a.attempts))try{let t,c=[];if(a.quote.intent){const n=await v(this,s,"f").getIntentTransactionStatus(e,a.quote.srcChainId,a.quote.intent.protocol,v(this,i,"f"),a.status.srcChain.txHash);if(null===n?.bridgeStatus||n?.bridgeStatus===undefined)return;t=n.bridgeStatus.status}else{const n=v(this,k,"f").call(this,e);if(!n)return;v(this,w,"f").call(this,e,n);const s=(0,O.getStatusRequestWithSrcTxHash)(a.quote,n),l=await(0,O.fetchBridgeTxStatus)(s,v(this,i,"f"),await(0,D.getJwt)(this.messenger),v(this,r,"f"),v(this,o,"f").customBridgeApiBaseUrl);t=l.status,c=l.validationFailures}if(c.length>0)throw v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.StatusValidationFailed,e,{failures:c,refresh_count:a.attempts?.counter??0}),new Error(`Bridge status validation failed: ${c.join(", ")}`);const l={...a,status:t,completionTime:t.status===E.StatusTypes.COMPLETE||t.status===E.StatusTypes.FAILED?Date.now():undefined,attempts:undefined};this.update(t=>{t.txHistory[e]=l}),a.quote.intent&&v(this,s,"f").syncTransactionFromIntentStatus(e,a);const d=v(this,n,"f")[e];if((t.status===E.StatusTypes.COMPLETE||t.status===E.StatusTypes.FAILED)&&d){if(this.stopPollingByPollingToken(d),delete v(this,n,"f")[e],a.featureId)return;t.status===E.StatusTypes.COMPLETE&&(v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Completed,e),this.messenger.publish("BridgeStatusController:destinationTransactionCompleted",a.quote.destAsset.assetId)),t.status===E.StatusTypes.FAILED&&v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Failed,e)}}catch(t){console.warn("Failed to fetch bridge tx status",t),v(this,p,"f").call(this,e)}}),k.set(this,e=>{const{txHistory:t}=this.state,a=t[e].status.srcChain.txHash;if(a)return a;const n=(0,q.getTransactionMetaById)(this.messenger,e);return n?.hash}),w.set(this,(e,t)=>{const{txHistory:a}=this.state;a[e].status.srcChain.txHash||this.update(a=>{a.txHistory[e].status.srcChain.txHash=t})}),b.set(this,(e,t)=>{const a=Object.keys(this.state.txHistory).filter(a=>{const n=this.state.txHistory[a],s=(0,P.numberToHex)(n.quote.srcChainId);return n.account===e&&s===t});a.forEach(e=>{v(this,n,"f")[e]&&this.stopPollingByPollingToken(v(this,n,"f")[e])}),this.update(e=>{e.txHistory=a.reduce((e,t)=>(delete e[t],e),e.txHistory)})}),y.set(this,async(e,t,a,n,s,i)=>{if(n&&(0,E.isEvmTxData)(n)){const r=async()=>{s&&await(0,q.submitEvmTransaction)({messenger:this.messenger,transactionType:I.TransactionType.bridgeApproval,trade:s});const e=await(0,q.submitEvmTransaction)({messenger:this.messenger,transactionType:t?I.TransactionType.bridgeApproval:I.TransactionType.swapApproval,trade:n,requireApproval:i});return await(0,q.handleApprovalDelay)(a),e};return await v(this,l,"f").call(this,(0,U.getApprovalTraceParams)(e,!1),r)}return undefined}),T.set(this,async e=>{const t=await(0,q.getAddTransactionBatchParams)({messenger:this.messenger,...e});return await(0,q.addTransactionBatch)(this.messenger,v(this,c,"f"),t)}),this.submitTx=async(e,t,a,n,s=E.MetaMetricsSwapsEventSource.MainView,r,o)=>{(0,M.stopPollingForQuotes)(this.messenger,t.featureId,n);const c=(0,F.getAccountByAddress)(this.messenger,e);if(!c)throw new Error("Failed to submit cross-chain swap transaction: undefined multichain account");const d=(0,E.isHardwareWallet)(c),m=(0,B.getPreConfirmationPropertiesFromQuote)(t,a,d,s,r,o);let p,g,k=!1;const w=Date.now(),b=(0,E.isCrossChain)(t.quote.srcChainId,t.quote.destChainId),_=(0,E.isTronChainId)(t.quote.srcChainId);try{if(!t.featureId&&v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Submitted,undefined,m),(0,E.isNonEvmChainId)(t.quote.srcChainId)){if(t.approval&&(0,E.isTronTrade)(t.approval)){const e=await v(this,l,"f").call(this,(0,U.getApprovalTraceParams)(t,!1),async()=>t.approval&&(0,E.isTronTrade)(t.approval)?await(0,H.handleNonEvmTx)(this.messenger,t.approval,t,c):undefined);g=e?.id,await(0,q.handleApprovalDelay)(t.quote.srcChainId)}p=await v(this,l,"f").call(this,(0,U.getTraceParams)(t,!1),async()=>{if(!(0,E.isTronTrade)(t.trade)&&!(0,E.isBitcoinTrade)(t.trade)&&"string"!=typeof t.trade)throw new Error("Failed to submit cross-chain swap transaction: trade is not a non-EVM transaction");return await(0,H.handleNonEvmTx)(this.messenger,t.trade,t,c)})}else{const e=v(this,i,"f")===A.BridgeClientId.MOBILE&&d;p=await v(this,l,"f").call(this,(0,U.getTraceParams)(t,a),async()=>{if(!(0,E.isEvmTxData)(t.trade))throw new Error("Failed to submit cross-chain swap transaction: trade is not an EVM transaction");const n=(0,E.formatChainIdToHex)(t.quote.srcChainId);if(k=await(0,q.checkIsDelegatedAccount)(this.messenger,t.trade.from,[n]),a||t.quote.gasIncluded7702||k){const{tradeMeta:a,approvalMeta:n}=await v(this,T,"f").call(this,{isBridgeTx:b,resetApproval:t.resetApproval,approval:t.approval&&(0,E.isEvmTxData)(t.approval)?t.approval:undefined,trade:t.trade,quoteResponse:t,requireApproval:e,isDelegatedAccount:k});return g=n?.id,a}const i=await v(this,y,"f").call(this,t,b,t.quote.srcChainId,t.approval&&(0,E.isEvmTxData)(t.approval)?t.approval:undefined,t.resetApproval,e);g=i?.id,e&&i?(await(0,q.handleMobileHardwareWalletDelay)(e),await(0,q.waitForTxConfirmation)(this.messenger,i.id)):await(0,q.handleMobileHardwareWalletDelay)(e);const l=(0,q.generateActionId)().toString();v(this,u,"f").call(this,{accountAddress:c.address,quoteResponse:t,slippagePercentage:0,isStxEnabled:a,startTime:w,approvalTxId:g,location:s,abTests:r,activeAbTests:o,actionId:l});const d=await(0,q.submitEvmTransaction)({messenger:this.messenger,transactionType:b?I.TransactionType.bridge:I.TransactionType.swap,trade:t.trade,requireApproval:e,txFee:t.quote.gasIncluded?t.quote.feeData.txFee:undefined,actionId:l});return v(this,h,"f").call(this,l,d),d})}}catch(e){throw!t.featureId&&v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Failed,undefined,{error_message:e?.message,...m}),e}try{!((0,E.isNonEvmChainId)(t.quote.srcChainId)||a||t.quote.gasIncluded7702||k)||v(this,u,"f").call(this,{accountAddress:c.address,bridgeTxMeta:p,quoteResponse:t,slippagePercentage:0,isStxEnabled:a,startTime:w,approvalTxId:g,location:s,abTests:r,activeAbTests:o}),(0,E.isNonEvmChainId)(t.quote.srcChainId)&&(v(this,f,"f").call(this,p.id),b||_||v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Completed,p.id))}catch{}return p},this.submitIntent=async e=>{const{quoteResponse:t,accountAddress:a,location:n,abTests:s,activeAbTests:c}=e;(0,M.stopPollingForQuotes)(this.messenger);const l=Date.now(),d=(0,F.getAccountByAddress)(this.messenger,a),m=Boolean(d)&&(0,E.isHardwareWallet)(d),h=(0,B.getPreConfirmationPropertiesFromQuote)(t,!1,m,n,s,c);try{const e=(0,L.getIntentFromQuote)(t),d=(0,E.isCrossChain)(t.quote.srcChainId,t.quote.destChainId),h=m&&v(this,i,"f")===A.BridgeClientId.MOBILE,p=await v(this,y,"f").call(this,t,d,t.quote.srcChainId,t.approval,t.resetApproval,h),g=p?.id;g&&await(0,q.waitForTxConfirmation)(this.messenger,g);const{srcChainId:k,requestId:w}=t.quote,b={srcChainId:k,quoteId:w,signature:await(0,G.signTypedMessage)({messenger:this.messenger,accountAddress:a,typedData:e.typedData}),order:e.order,userAddress:a,aggregatorId:e.protocol},{id:T,status:x}=await(0,L.postSubmitOrder)({params:b,clientId:v(this,i,"f"),jwt:await(0,D.getJwt)(this.messenger),fetchFn:v(this,r,"f"),bridgeApiBaseUrl:v(this,o,"f").customBridgeApiBaseUrl}),_=d?I.TransactionType.bridge:I.TransactionType.swap,S=(0,R.getNetworkClientIdByChainId)(this.messenger,k),P={chainId:(0,E.formatChainIdToHex)(k),from:a,to:e.settlementContract??"0x9008D19f58AAbd9eD0D60971565AA8510560ab41",data:`0x${T.slice(-8)}`,value:"0x0",gas:"0x5208",gasPrice:"0x3b9aca00"},C={...await(0,q.addSyntheticTransaction)(this.messenger,P,{requireApproval:!1,networkClientId:S,type:_}),status:(0,L.mapIntentOrderStatusToTransactionStatus)(x),isIntentTx:!0,orderUid:T};try{const e=T,i={...C,id:e,originalTransactionId:C.id};v(this,u,"f").call(this,{accountAddress:a,bridgeTxMeta:i,quoteResponse:t,slippagePercentage:0,isStxEnabled:!1,approvalTxId:g,startTime:l,location:n,abTests:s,activeAbTests:c}),v(this,f,"f").call(this,e)}catch(e){console.error("📝 [submitIntent] Failed to add to bridge history",e)}return C}catch(e){throw v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Failed,undefined,{error_message:e?.message,...h}),e}},x.set(this,(e,t,a)=>{const n=t?this.state.txHistory?.[t]?.abTests:undefined,s=t?this.state.txHistory?.[t]?.activeAbTests:undefined,i=a?.ab_tests??n,r=a?.active_ab_tests??s,o={action_type:E.MetricsActionType.SWAPBRIDGE_V1,location:a?.location??(t?this.state.txHistory?.[t]?.location:undefined)??E.MetaMetricsSwapsEventSource.MainView,...a??{},...i&&Object.keys(i).length>0&&{ab_tests:i},...r&&r.length>0&&{active_ab_tests:r}};if(!t)return void(0,M.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:o});const c=this.state.txHistory[t];if(!c)return void(0,M.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:o});const{featureId:l,approvalTxId:d,quote:m}=c,u=(0,B.getRequestParamFromHistory)(c);if(e===E.UnifiedSwapBridgeEventName.StatusValidationFailed)return void(0,M.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:{...o,chain_id_source:u.chain_id_source,chain_id_destination:u.chain_id_destination,token_address_source:u.token_address_source,token_address_destination:u.token_address_destination,refresh_count:c.attempts?.counter??0}});if(l)return;const h=(0,F.getAccountByAddress)(this.messenger,c.account),f=(0,q.getTransactions)(this.messenger),p=f.find(e=>e.id===t),g=f.find(e=>e.id===d),k={...o,...u,...(0,B.getRequestMetadataFromHistory)(c,h),...(0,B.getTradeDataFromHistory)(c),...(0,B.getTxStatusesFromHistory)(c),...(0,B.getFinalizedTxProperties)(c,p,g),...(0,B.getPriceImpactFromQuote)(m)};(0,M.trackMetricsEvent)({messenger:this.messenger,eventName:e,properties:k})}),_(this,i,a,"f"),_(this,r,S,"f"),_(this,c,$,"f"),_(this,o,{customBridgeApiBaseUrl:K?.customBridgeApiBaseUrl??j.BRIDGE_PROD_API_BASE_URL},"f"),_(this,l,V??((e,t)=>t?.()),"f"),_(this,s,new C.IntentManager({messenger:this.messenger,customBridgeApiBaseUrl:v(this,o,"f").customBridgeApiBaseUrl,fetchFn:v(this,r,"f")}),"f"),this.messenger.registerActionHandler(`${j.BRIDGE_STATUS_CONTROLLER_NAME}:startPollingForBridgeTxStatus`,this.startPollingForBridgeTxStatus.bind(this)),this.messenger.registerActionHandler(`${j.BRIDGE_STATUS_CONTROLLER_NAME}:wipeBridgeStatus`,this.wipeBridgeStatus.bind(this)),this.messenger.registerActionHandler(`${j.BRIDGE_STATUS_CONTROLLER_NAME}:resetState`,this.resetState.bind(this)),this.messenger.registerActionHandler(`${j.BRIDGE_STATUS_CONTROLLER_NAME}:submitTx`,this.submitTx.bind(this)),this.messenger.registerActionHandler(`${j.BRIDGE_STATUS_CONTROLLER_NAME}:submitIntent`,this.submitIntent.bind(this)),this.messenger.registerActionHandler(`${j.BRIDGE_STATUS_CONTROLLER_NAME}:restartPollingForFailedAttempts`,this.restartPollingForFailedAttempts.bind(this)),this.messenger.registerActionHandler(`${j.BRIDGE_STATUS_CONTROLLER_NAME}:getBridgeHistoryItemByTxMetaId`,this.getBridgeHistoryItemByTxMetaId.bind(this)),this.setIntervalLength(j.REFRESH_INTERVAL_MS),this.messenger.subscribe("TransactionController:transactionFailed",({transactionMeta:e})=>{const{type:t,status:a,id:n,actionId:s}=e;if(t&&[I.TransactionType.bridge,I.TransactionType.swap,I.TransactionType.bridgeApproval,I.TransactionType.swapApproval].includes(t)&&[I.TransactionStatus.failed,I.TransactionStatus.dropped,I.TransactionStatus.rejected].includes(a)&&(v(this,d,"f").call(this,e),a!==I.TransactionStatus.rejected)){let t;this.state.txHistory[n]?t=n:s&&this.state.txHistory[s]&&(t=s),v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Failed,t??n,(0,B.getEVMTxPropertiesFromTransactionMeta)(e))}}),this.messenger.subscribe("TransactionController:transactionConfirmed",e=>{const{type:t,id:a,chainId:n}=e;t===I.TransactionType.swap&&v(this,x,"f").call(this,E.UnifiedSwapBridgeEventName.Completed,a),t!==I.TransactionType.bridge||(0,E.isNonEvmChainId)(n)||v(this,f,"f").call(this,a)}),v(this,m,"f").call(this)}}a.BridgeStatusController=$,n=new WeakMap,s=new WeakMap,i=new WeakMap,r=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,w=new WeakMap,b=new WeakMap,y=new WeakMap,T=new WeakMap,x=new WeakMap}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.intent.cjs",{"./utils/authentication.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs","./utils/intent-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs","./utils/transaction.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs","./utils/validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){var n,s,i,r,o=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},c=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.IntentManager=void 0;const l=e("@metamask/bridge-controller"),d=e("./utils/authentication.cjs"),m=e("./utils/intent-api.cjs"),u=e("./utils/transaction.cjs");e("./utils/validators.cjs");a.IntentManager=class{constructor({messenger:e,customBridgeApiBaseUrl:t,fetchFn:a}){n.add(this),s.set(this,void 0),i.set(this,new Map),this.getIntentTransactionStatus=async(e,t,a,s,i)=>{try{const o=await this.intentApi.getOrderStatus(e,a,t,s);return c(this,n,"m",r).call(this,e,o,t,i)}catch(e){if(e instanceof Error)throw new Error(`[Intent polling] Failed to get intent order status from API: ${e.message}`);return undefined}},this.syncTransactionFromIntentStatus=(e,t)=>{const a=t.originalTransactionId??t.txMetaId;if(!a)return;const n=c(this,i,"f").get(e);if(n)try{const t=(0,u.getTransactionMetaById)(c(this,s,"f"),a);if(!t)return void console.warn("[Intent polling] Skipping update, transaction not found",{originalTxId:a,bridgeHistoryKey:e});const{bridgeStatus:r,orderStatus:o}=n,d=r?.txHash,m=r?.status.status===l.StatusTypes.COMPLETE,h=r?.status.status===l.StatusTypes.COMPLETE||r?.status.status===l.StatusTypes.FAILED,f=t.txReceipt,p=d?{txReceipt:{...f,transactionHash:d,status:m?"0x1":"0x0"}}:{};(0,u.updateTransaction)(c(this,s,"f"),t,{status:r?.transactionStatus,...d?{hash:d}:{},...p},`BridgeStatusController - Intent order status updated: ${o}`),h&&c(this,i,"f").delete(e)}catch(t){console.error("[Intent polling] Failed to update transaction status",{originalTxId:a,bridgeHistoryKey:e,error:t})}},o(this,s,e,"f"),this.intentApi=new m.IntentApiImpl(t,a,async()=>await(0,d.getJwt)(e))}},s=new WeakMap,i=new WeakMap,n=new WeakSet,r=function(e,t,a,n){const s=(0,m.translateIntentOrderToBridgeStatus)(t,a,n),r={orderStatus:t.status,bridgeStatus:s};return c(this,i,"f").set(e,r),r}}}},{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,a){var n;Object.defineProperty(a,"__esModule",{value:!0}),a.TraceName=a.APPROVAL_DELAY_MS=a.BRIDGE_PROD_API_BASE_URL=a.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE=a.BRIDGE_STATUS_CONTROLLER_NAME=a.MAX_ATTEMPTS=a.REFRESH_INTERVAL_MS=void 0,a.REFRESH_INTERVAL_MS=1e4,a.MAX_ATTEMPTS=7,a.BRIDGE_STATUS_CONTROLLER_NAME="BridgeStatusController",a.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE={txHistory:{}},a.BRIDGE_PROD_API_BASE_URL="https://bridge.api.cx.metamask.io",a.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"}(n||(a.TraceName=n={}))}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/constants.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/index.cjs",{"./bridge-status-controller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/bridge-status-controller.cjs","./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/types.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.BridgeStatusController=a.BridgeStatusAction=a.BridgeId=a.MAX_ATTEMPTS=a.BRIDGE_STATUS_CONTROLLER_NAME=a.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE=a.REFRESH_INTERVAL_MS=void 0;var n=e("./constants.cjs");Object.defineProperty(a,"REFRESH_INTERVAL_MS",{enumerable:!0,get:function(){return n.REFRESH_INTERVAL_MS}}),Object.defineProperty(a,"DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE",{enumerable:!0,get:function(){return n.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE}}),Object.defineProperty(a,"BRIDGE_STATUS_CONTROLLER_NAME",{enumerable:!0,get:function(){return n.BRIDGE_STATUS_CONTROLLER_NAME}}),Object.defineProperty(a,"MAX_ATTEMPTS",{enumerable:!0,get:function(){return n.MAX_ATTEMPTS}});var s=e("./types.cjs");Object.defineProperty(a,"BridgeId",{enumerable:!0,get:function(){return s.BridgeId}}),Object.defineProperty(a,"BridgeStatusAction",{enumerable:!0,get:function(){return s.BridgeStatusAction}});var i=e("./bridge-status-controller.cjs");Object.defineProperty(a,"BridgeStatusController",{enumerable:!0,get:function(){return i.BridgeStatusController}})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/types.cjs",{"./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.BridgeStatusAction=a.BridgeId=a.BridgeClientId=void 0;e("./constants.cjs");var n,s,i;!function(e){e.EXTENSION="extension",e.MOBILE="mobile"}(n||(a.BridgeClientId=n={})),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"}(s||(a.BridgeId=s={})),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"}(i||(a.BridgeStatusAction=i={}))}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/types.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getAccountByAddress=void 0;a.getAccountByAddress=(e,t)=>e.call("AccountsController:getAccountByAddress",t)}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getJwt=void 0;a.getJwt=async e=>{try{return await e.call("AuthenticationController:getBearerToken")}catch(e){return console.error("Error getting JWT token for bridge-api request",e),undefined}}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/authentication.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getStatusRequestParams=a.shouldSkipFetchDueToFetchFailures=a.getStatusRequestWithSrcTxHash=a.fetchBridgeTxStatus=a.getStatusRequestDto=a.getBridgeStatusUrl=void 0;const n=e("@metamask/bridge-controller"),s=e("@metamask/superstruct"),i=e("./validators.cjs"),r=e("../constants.cjs");a.getBridgeStatusUrl=e=>`${e}/getTxStatus`;a.getStatusRequestDto=e=>{const{quote:t,...a}=e;return{...Object.fromEntries(Object.entries(a).map(([e,t])=>[e,t.toString()])),...t?.requestId?{requestId:t.requestId}:{}}};a.fetchBridgeTxStatus=async(e,t,r,o,c)=>{const l=(0,a.getStatusRequestDto)(e),d=new URLSearchParams(l),m=`${(0,a.getBridgeStatusUrl)(c)}?${d.toString()}`,u=await o(m,{headers:(0,n.getClientHeaders)({clientId:t,jwt:r})}),h=[];try{(0,i.validateBridgeStatusResponse)(u)}catch(t){t instanceof s.StructError&&t.failures().forEach(({path:t})=>{const a=u?.bridge??(e.bridge||e.bridgeId)??"unknown",n=t?.join(".")||"unknown";h.push([a,n].join("|"))})}return{status:u,validationFailures:h}};a.getStatusRequestWithSrcTxHash=(e,t)=>{const{bridgeId:a,bridges:n,srcChainId:s,destChainId:i,refuel:r}=e;return{bridgeId:a,srcTxHash:t,bridge:n[0],srcChainId:s,destChainId:i,quote:e,refuel:Boolean(r)}};a.shouldSkipFetchDueToFetchFailures=e=>{if(e){const t=r.REFRESH_INTERVAL_MS*Math.pow(2,e.counter-1);if(Date.now()-e.lastAttemptTime<t)return!0}return!1};a.getStatusRequestParams=e=>({bridgeId:e.quote.bridgeId,bridge:e.quote.bridges[0],srcChainId:e.quote.srcChainId,destChainId:e.quote.destChainId,quote:e.quote,refuel:Boolean(e.quote.refuel)})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/bridge.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.trackMetricsEvent=a.stopPollingForQuotes=void 0;const n=e("@metamask/bridge-controller");a.stopPollingForQuotes=(e,t,a)=>{e.call("BridgeController:stopPollingForQuotes",n.AbortReason.TransactionSubmitted,t?undefined:a)};a.trackMetricsEvent=({messenger:e,eventName:t,properties:a})=>{e.call("BridgeController:trackUnifiedSwapBridgeEvent",t,a)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/bridge.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/gas.cjs",{"bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.calcActualGasUsed=void 0;const n=e("bignumber.js"),s=(e,t)=>e&&t?new n.BigNumber(e,16).times(new n.BigNumber(t,16)):null;a.calcActualGasUsed=({pricingData:e},t,a)=>{const i=e?.quotedGasInUsd&&e?.quotedGasAmount?new n.BigNumber(e?.quotedGasInUsd).div(e.quotedGasAmount):null,r=s(t?.gasUsed,t?.effectiveGasPrice)?.plus(s(a?.gasUsed,a?.effectiveGasPrice)??0),o=r?.div(new n.BigNumber(10).pow(18)).toString(10);return r&&o?{amount:r.toString(10),usd:i?.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/history.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.shouldPollHistoryItem=a.getInitialHistoryItem=a.getHistoryKey=a.rekeyHistoryItemInState=void 0;const n=e("@metamask/bridge-controller");function s(e,t,a){const n=e??t??a;if(!n)throw new Error("Cannot add tx to history: either actionId, bridgeTxMeta.id, or syntheticTransactionId must be provided");return n}a.rekeyHistoryItemInState=(e,t,a)=>{const n=e.txHistory[t];return!!n&&(e.txHistory[a.id]={...n,txMetaId:a.id,originalTransactionId:n.originalTransactionId??a.id,status:{...n.status,srcChain:{...n.status.srcChain,txHash:a.hash??n.status.srcChain?.txHash}}},delete e.txHistory[t],!0)},a.getHistoryKey=s;a.getInitialHistoryItem=e=>{const{bridgeTxMeta:t,quoteResponse:a,startTime:i,slippagePercentage:r,initialDestAssetBalance:o,targetContractAddress:c,approvalTxId:l,isStxEnabled:d,location:m,abTests:u,activeAbTests:h,accountAddress:f,originalTransactionId:p,actionId:g}=e;return{historyKey:s(g,t?.id,p),txHistoryItem:{txMetaId:t?.id,actionId:g,originalTransactionId:p??t?.id,batchId:t?.batchId,quote:a.quote,startTime:i,estimatedProcessingTimeInSeconds:a.estimatedProcessingTimeInSeconds,slippagePercentage:r,pricingData:{amountSent:a.sentAmount?.amount??"0",amountSentInUsd:a.sentAmount?.usd??undefined,quotedGasInUsd:a.gasFee?.effective?.usd??undefined,quotedReturnInUsd:a.toTokenAmount?.usd??undefined,quotedGasAmount:a.gasFee?.effective?.amount??undefined},initialDestAssetBalance:o,targetContractAddress:c,account:f,status:{status:n.StatusTypes.PENDING,srcChain:{chainId:a.quote.srcChainId,txHash:t?.hash}},hasApprovalTx:Boolean(a.approval),approvalTxId:l,isStxEnabled:Boolean(d),featureId:a.featureId,location:m,...u&&{abTests:u},...h&&{activeAbTests:h}}}};a.shouldPollHistoryItem=e=>{const t=Boolean(e?.quote?.intent);return[(0,n.isCrossChain)(e.quote.srcChainId,e.quote.destChainId),t,(0,n.isTronChainId)(e.quote.srcChainId)].some(Boolean)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/history.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs",{"./validators.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/transaction-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){var n,s,i,r=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},o=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.postSubmitOrder=a.getIntentFromQuote=a.mapIntentOrderStatusToTransactionStatus=a.translateIntentOrderToBridgeStatus=a.IntentApiImpl=void 0;const c=e("@metamask/bridge-controller"),l=e("@metamask/transaction-controller"),d=e("./validators.cjs");a.IntentApiImpl=class{constructor(e,t,a){n.set(this,void 0),s.set(this,void 0),i.set(this,void 0),r(this,n,e,"f"),r(this,s,t,"f"),r(this,i,a,"f")}async getOrderStatus(e,t,a,r){const l=`${o(this,n,"f")}/getOrderStatus?orderId=${e}&aggregatorId=${encodeURIComponent(t)}&srcChainId=${a}`;try{const e=await o(this,i,"f").call(this),t=await o(this,s,"f").call(this,l,{method:"GET",headers:(0,c.getClientHeaders)({clientId:r,jwt:e})});if(!(0,d.validateIntentStatusResponse)(t))throw new Error("Invalid getOrderStatus response");return t}catch(e){if(e instanceof Error)throw new Error(`Failed to get order status: ${e.message}`);throw new Error("Failed to get order status")}}},n=new WeakMap,s=new WeakMap,i=new WeakMap;function m(e){switch(e){case d.IntentOrderStatus.PENDING:case d.IntentOrderStatus.SUBMITTED:return l.TransactionStatus.submitted;case d.IntentOrderStatus.CONFIRMED:case d.IntentOrderStatus.COMPLETED:return l.TransactionStatus.confirmed;case d.IntentOrderStatus.FAILED:case d.IntentOrderStatus.EXPIRED:case d.IntentOrderStatus.CANCELLED:return l.TransactionStatus.failed;default:return l.TransactionStatus.submitted}}a.translateIntentOrderToBridgeStatus=(e,t,a)=>{let n;switch(e.status){case d.IntentOrderStatus.CONFIRMED:case d.IntentOrderStatus.COMPLETED:n=c.StatusTypes.COMPLETE;break;case d.IntentOrderStatus.FAILED:case d.IntentOrderStatus.EXPIRED:case d.IntentOrderStatus.CANCELLED:n=c.StatusTypes.FAILED;break;case d.IntentOrderStatus.PENDING:n=c.StatusTypes.PENDING;break;case d.IntentOrderStatus.SUBMITTED:n=c.StatusTypes.SUBMITTED;break;default:n=c.StatusTypes.UNKNOWN}const s=e.txHash??a;return{status:{status:n,srcChain:{chainId:t,txHash:s}},txHash:s,transactionStatus:m(e.status)}},a.mapIntentOrderStatusToTransactionStatus=m,a.getIntentFromQuote=function(e){const{intent:t}=e.quote;if(!t)throw new Error("submitIntent: missing intent data");return t};a.postSubmitOrder=async({params:e,clientId:t,jwt:a,fetchFn:n,bridgeApiBaseUrl:s})=>{const i=`${s}/submitOrder`;try{const s=await n(i,{method:"POST",headers:{"Content-Type":"application/json",...(0,c.getClientHeaders)({clientId:t,jwt:a})},body:JSON.stringify(e)});if(!(0,d.validateIntentStatusResponse)(s))throw new Error("Invalid submitOrder response");return s}catch(e){if(e instanceof Error)throw new Error(`Failed to submit intent: ${e.message}`);throw new Error("Failed to submit intent")}}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/intent-api.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/keyring.cjs",{"@metamask/keyring-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/keyring-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.signTypedMessage=void 0;const n=e("@metamask/keyring-controller");a.signTypedMessage=async({messenger:e,accountAddress:t,typedData:a})=>await e.call("KeyringController:signTypedMessage",{from:t,data:a},n.SignTypedDataVersion.V4)}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/keyring.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/metrics.cjs",{"./gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/gas.cjs","./swap-received-amount.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/swap-received-amount.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getEVMTxPropertiesFromTransactionMeta=a.getRequestMetadataFromHistory=a.getTradeDataFromHistory=a.getPreConfirmationPropertiesFromQuote=a.getPriceImpactFromQuote=a.getTradeDataFromQuote=a.getRequestParamFromHistory=a.getFinalizedTxProperties=a.getTxStatusesFromHistory=void 0;const n=e("@metamask/bridge-controller"),s=e("@metamask/transaction-controller"),i=e("bignumber.js"),r=e("./gas.cjs"),o=e("./swap-received-amount.cjs");a.getTxStatusesFromHistory=({status:e,hasApprovalTx:t,approvalTxId:a,quote:s})=>{const i=e.srcChain.txHash?n.StatusTypes.COMPLETE:n.StatusTypes.PENDING,r=e.destChain?.txHash?e.status:n.StatusTypes.PENDING,o=(0,n.formatChainIdToHex)(s.srcChainId),c=(0,n.isEthUsdt)(o,s.srcAsset.address),l=e.srcChain.txHash?n.StatusTypes.COMPLETE:undefined,d=e.srcChain.txHash?n.StatusTypes.COMPLETE:n.StatusTypes.PENDING;return{allowance_reset_transaction:c?l:undefined,approval_transaction:t||a?d:undefined,source_transaction:i,destination_transaction:e.status===n.StatusTypes.FAILED?n.StatusTypes.FAILED:r}};a.getFinalizedTxProperties=(e,t,a)=>{const n=a?.submittedTime??t?.submittedTime??e.startTime,c=t?.type===s.TransactionType.swap?t?.time:e.completionTime,l=(0,r.calcActualGasUsed)(e,t?.txReceipt,a?.txReceipt),d=t?.type===s.TransactionType.swap?(0,o.getActualSwapReceivedAmount)(e,l,t):(0,o.getActualBridgeReceivedAmount)(e),m=e.pricingData?.quotedGasAmount&&l?.amount?new i.BigNumber(e.pricingData.quotedGasAmount).multipliedBy(new i.BigNumber(10).pow(18)).div(l.amount).toNumber():0,u=e.pricingData?.quotedReturnInUsd&&d?.usd?new i.BigNumber(e.pricingData.quotedReturnInUsd).div(d.usd).toNumber():0;return{actual_time_minutes:c&&n?(c-n)/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}};a.getRequestParamFromHistory=e=>({chain_id_source:(0,n.formatChainIdToCaip)(e.quote.srcChainId),token_symbol_source:e.quote.srcAsset.symbol,token_address_source:e.quote.srcAsset.assetId,chain_id_destination:(0,n.formatChainIdToCaip)(e.quote.destChainId),token_symbol_destination:e.quote.destAsset.symbol,token_address_destination:e.quote.destAsset.assetId});a.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,n.formatProviderLabel)(e.quote),quoted_time_minutes:Number(e.estimatedProcessingTimeInSeconds/60),usd_quoted_return:Number(e.adjustedReturn?.usd??0)});a.getPriceImpactFromQuote=e=>({price_impact:Number(e.priceData?.priceImpact??"0")});a.getPreConfirmationPropertiesFromQuote=(e,t,s,i=n.MetaMetricsSwapsEventSource.MainView,r,o)=>{const{quote:c}=e;return{...(0,a.getPriceImpactFromQuote)(c),...(0,a.getTradeDataFromQuote)(e),chain_id_source:(0,n.formatChainIdToCaip)(c.srcChainId),token_symbol_source:c.srcAsset.symbol,chain_id_destination:(0,n.formatChainIdToCaip)(c.destChainId),token_symbol_destination:c.destAsset.symbol,is_hardware_wallet:s,swap_type:(0,n.getSwapType)(e.quote.srcChainId,e.quote.destChainId),usd_amount_source:Number(e.sentAmount?.usd??0),stx_enabled:t,action_type:n.MetricsActionType.SWAPBRIDGE_V1,custom_slippage:!1,location:i,...r&&Object.keys(r).length>0&&{ab_tests:r},...o&&o.length>0&&{active_ab_tests:o}}};a.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,n.formatProviderLabel)(e.quote),quoted_time_minutes:Number(e.estimatedProcessingTimeInSeconds/60),usd_quoted_return:Number(e.pricingData?.quotedReturnInUsd??0)});a.getRequestMetadataFromHistory=(e,t)=>{const{quote:a,slippagePercentage:s,isStxEnabled:i}=e;return{slippage_limit:s,custom_slippage:(0,n.isCustomSlippage)(s),usd_amount_source:Number(e.pricingData?.amountSentInUsd??0),swap_type:(0,n.getSwapType)(a.srcChainId,a.destChainId),is_hardware_wallet:(0,n.isHardwareWallet)(t),stx_enabled:i??!1,security_warnings:[]}};a.getEVMTxPropertiesFromTransactionMeta=e=>({source_transaction:[s.TransactionStatus.failed,s.TransactionStatus.dropped,s.TransactionStatus.rejected].includes(e.status)?n.StatusTypes.FAILED:n.StatusTypes.COMPLETE,error_message:e.error?.message??"",chain_id_source:(0,n.formatChainIdToCaip)(e.chainId),chain_id_destination:(0,n.formatChainIdToCaip)(e.chainId),token_symbol_source:e.sourceTokenSymbol??"",token_symbol_destination:e.destinationTokenSymbol??"",usd_amount_source:0,stx_enabled:!1,token_address_source:(0,n.formatAddressToAssetId)(e.sourceTokenAddress??"",e.chainId)??"",token_address_destination:(0,n.formatAddressToAssetId)(e.destinationTokenAddress??"",e.chainId)??"",custom_slippage:!1,is_hardware_wallet:!1,swap_type:e.type&&[s.TransactionType.swap,s.TransactionType.swapApproval].includes(e.type)?n.MetricsSwapType.SINGLE:n.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:n.MetricsActionType.SWAPBRIDGE_V1})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/metrics.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getNetworkClientIdByChainId=a.getSelectedChainId=void 0;const n=e("@metamask/bridge-controller");a.getSelectedChainId=e=>{const{selectedNetworkClientId:t}=e.call("NetworkController:getState");return e.call("NetworkController:getNetworkClientById",t).configuration.chainId};a.getNetworkClientIdByChainId=(e,t)=>{const a=(0,n.formatChainIdToHex)(t);return e.call("NetworkController:findNetworkClientIdByChainId",a)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/snaps.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs","@metamask/snaps-controllers":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/snaps-controllers/dist/index.cjs","@metamask/transaction-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/transaction-controller/dist/index.cjs",uuid:"/home/runner/work/metamask-extension/metamask-extension/node_modules/uuid/dist/index.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.handleNonEvmTx=a.handleNonEvmTxResponse=a.getTxMetaFields=a.getClientRequest=a.createClientTransactionRequest=void 0;const n=e("@metamask/bridge-controller"),s=(e("@metamask/snaps-controllers"),e("@metamask/transaction-controller")),i=e("uuid");a.createClientTransactionRequest=(e,t,a,n,s)=>({snapId:e,origin:"metamask",handler:"onClientRequest",request:{id:(0,i.v4)(),jsonrpc:"2.0",method:"signAndSendTransaction",params:{transaction:t,scope:a,accountId:n,...s&&{options:s}}}});a.getClientRequest=(e,t,s,i)=>{const r=(0,n.formatChainIdToCaip)(t),o=(0,n.extractTradeData)(e),c=(0,n.isTronTrade)(e)?{visible:e.visible,type:e.raw_data?.contract?.[0]?.type}:undefined;return(0,a.createClientTransactionRequest)(i,o,r,s,c)};a.getTxMetaFields=(e,t)=>{let a;try{a=(0,n.formatChainIdToHex)(e.quote.destChainId)}catch{a=s.CHAIN_IDS.MAINNET}return{destinationChainId:a,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}};a.handleNonEvmTxResponse=(e,t,r,o)=>{const c=o.address,l=o.metadata.snap?.id;let d;"string"==typeof e?d=e:e&&"object"==typeof e&&("transactionId"in e&&e.transactionId?d=e.transactionId:"result"in e&&e.result&&"object"==typeof e.result?d=e.result.signature||e.result.txid||e.result.hash||e.result.txHash:"signature"in e&&e.signature&&"string"==typeof e.signature&&(d=e.signature));const m=(0,n.isCrossChain)(r.quote.srcChainId,r.quote.destChainId);let u;try{u=(0,n.formatChainIdToHex)(r.quote.srcChainId)}catch{u="0x1"}const h=(0,n.extractTradeData)(t);return{...(0,a.getTxMetaFields)(r),time:Date.now(),id:d??(0,i.v4)(),chainId:u,networkClientId:l??"mainnet",txParams:{from:c,data:h},type:m?s.TransactionType.bridge:s.TransactionType.swap,status:s.TransactionStatus.submitted,hash:d,origin:l,isSolana:!0,isBridgeTx:m}};a.handleNonEvmTx=async(e,t,n,s)=>{if(!s.metadata?.snap?.id)throw new Error("Failed to submit cross-chain swap transaction: undefined snap id");const i=(0,a.getClientRequest)(t,n.quote.srcChainId,s.id,s.metadata?.snap?.id),r=await e.call("SnapController:handleRequest",i);return(0,a.handleNonEvmTxResponse)(r,t,n,s)}}}},{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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getActualBridgeReceivedAmount=a.getActualSwapReceivedAmount=void 0;const n=e("@metamask/bridge-controller"),s=e("bignumber.js");a.getActualSwapReceivedAmount=(e,t,a)=>{const{pricingData:i}=e,r=e.quote.destTokenAmount;if(!a?.txReceipt)return null;const o=(0,n.isNativeAddress)(e.quote.destAsset.address)?((e,t,a)=>{const{preTxBalance:n,postTxBalance:i}=a;return n&&i&&n!==i?t&&i&&n?new s.BigNumber(i,16).minus(n,16).minus(t.amount).div(10**e.quote.destAsset.decimals):null:new s.BigNumber(e.quote.destTokenAmount).div(new s.BigNumber(10).pow(e.quote.destAsset.decimals)).toString(10)})(e,t,a):((e,t)=>{const{txReceipt:a}=t;if(!a?.logs||"0x0"===a.status)return null;const{account:n,quote:i}=e,r=a.logs.find(e=>{const t=e.topics?.[0]?.startsWith("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),a=e.address?.toLowerCase()===i.destAsset.address?.toLowerCase(),s=e.topics?.[2]&&(e.topics[2]===n||e.topics[2].match(n?.slice(2)));return t&&a&&s});return r?.data?new s.BigNumber(r.data,16).div(new s.BigNumber(10).pow(i.destAsset.decimals)):null})(e,a),c=i?.quotedReturnInUsd&&r?new s.BigNumber(i.quotedReturnInUsd).div(r).multipliedBy(10**e.quote.destAsset.decimals):null;return{amount:o,usd:o&&c?c.multipliedBy(o):null}};a.getActualBridgeReceivedAmount=e=>{const{quote:t,pricingData:a,status:n}=e,i=a?.quotedReturnInUsd?new s.BigNumber(a.quotedReturnInUsd).div(t.destTokenAmount):null,r=n.destChain?.amount;return r&&i?{amount:r,usd:i.multipliedBy(r).toString(10)}:null}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/swap-received-amount.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/trace.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-controller/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getApprovalTraceParams=a.getTraceParams=void 0;const n=e("@metamask/bridge-controller"),s=e("../constants.cjs");a.getTraceParams=(e,t)=>({name:(0,n.isCrossChain)(e.quote.srcChainId,e.quote.destChainId)?s.TraceName.BridgeTransactionCompleted:s.TraceName.SwapTransactionCompleted,data:{srcChainId:(0,n.formatChainIdToCaip)(e.quote.srcChainId),stxEnabled:t}});a.getApprovalTraceParams=(e,t)=>({name:(0,n.isCrossChain)(e.quote.srcChainId,e.quote.destChainId)?s.TraceName.BridgeTransactionApprovalCompleted:s.TraceName.SwapTransactionApprovalCompleted,data:{srcChainId:(0,n.formatChainIdToCaip)(e.quote.srcChainId),stxEnabled:t}})}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/trace.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/constants.cjs","./accounts.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/accounts.cjs","./network.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/network.cjs","@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-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/transaction-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs","bignumber.js":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.submitEvmTransaction=a.addTransactionBatch=a.findAndUpdateTransactionsInBatch=a.getAddTransactionBatchParams=a.toBatchTxParams=a.waitForTxConfirmation=a.handleMobileHardwareWalletDelay=a.handleApprovalDelay=a.addSyntheticTransaction=a.generateActionId=a.addTransaction=a.checkIsDelegatedAccount=a.updateTransaction=a.getTransactionMetaByHash=a.getTransactionMetaById=a.getTransactions=a.calculateGasFees=a.getTxGasEstimates=a.getGasFeeEstimates=void 0;const n=e("@metamask/bridge-controller"),s=e("@metamask/controller-utils"),i=e("@metamask/transaction-controller"),r=e("@metamask/utils"),o=e("bignumber.js"),c=e("./accounts.cjs"),l=e("./network.cjs"),d=e("../constants.cjs");a.getGasFeeEstimates=async(e,t)=>{const{estimates:a}=await e.call("TransactionController:estimateGasFee",t);return n.BRIDGE_PREFERRED_GAS_ESTIMATE in a&&"object"==typeof a[n.BRIDGE_PREFERRED_GAS_ESTIMATE]&&"maxFeePerGas"in a[n.BRIDGE_PREFERRED_GAS_ESTIMATE]&&"maxPriorityFeePerGas"in a[n.BRIDGE_PREFERRED_GAS_ESTIMATE]?a[n.BRIDGE_PREFERRED_GAS_ESTIMATE]:{}};a.getTxGasEstimates=async(e,t)=>{const{gasFeeEstimates:n}=e.call("GasFeeController:getState"),s="estimatedBaseFee"in n?n.estimatedBaseFee:"0",{maxFeePerGas:i,maxPriorityFeePerGas:r}=await(0,a.getGasFeeEstimates)(e,t);return{baseAndPriorityFeePerGas:r?new o.BigNumber(s,10).times(10**9).plus(r,16):undefined,maxFeePerGas:i,maxPriorityFeePerGas:r}};a.calculateGasFees=async(e,t,{chainId:n,gasLimit:i,...r},o,c,l)=>{if(e)return{};if(l)return{...l,gas:i?.toString()};const d={...r,gas:i?.toString(),data:r.data,to:r.to,value:r.value},{maxFeePerGas:m,maxPriorityFeePerGas:u}=await(0,a.getTxGasEstimates)(t,{transactionParams:d,networkClientId:o,chainId:c});return{maxFeePerGas:m,maxPriorityFeePerGas:u,gas:(0,s.toHex)(d.gas??0)}};a.getTransactions=e=>e.call("TransactionController:getState").transactions??[];a.getTransactionMetaById=(e,t)=>(0,a.getTransactions)(e).find(e=>e.id===t);a.getTransactionMetaByHash=(e,t)=>(0,a.getTransactions)(e).find(e=>e.hash===t);a.updateTransaction=(e,t,a,n)=>e.call("TransactionController:updateTransaction",{...t,...a},n);a.checkIsDelegatedAccount=async(e,t,a)=>{try{return(await e.call("TransactionController:isAtomicBatchSupported",{address:t,chainIds:a})).some(e=>e.isSupported&&e.delegationAddress)}catch{return!1}};a.addTransaction=async(e,...t)=>{const{result:n}=await e.call("TransactionController:addTransaction",...t);return await(async(e,t)=>{const n=await t,s=(0,a.getTransactionMetaByHash)(e,n);if(!s)throw new Error("Failed to submit cross-chain swap tx: txMeta for txHash was not found");return s})(e,n)};a.generateActionId=()=>(Date.now()+Math.random()).toString();a.addSyntheticTransaction=async(e,...t)=>{const{transactionMeta:n}=await e.call("TransactionController:addTransaction",t[0],{origin:"metamask",actionId:(0,a.generateActionId)(),isStateOnly:!0,...t[1]});return n};a.handleApprovalDelay=async e=>{if([n.ChainId.LINEA,n.ChainId.BASE].includes(e)){(0,r.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}};a.handleMobileHardwareWalletDelay=async e=>{if(e){const e=new Promise(e=>setTimeout(e,1e3));await e}};a.waitForTxConfirmation=async(e,t,{timeoutMs:n=3e5,pollMs:s=3e3}={})=>{const r=Date.now();for(;;){const o=(0,a.getTransactionMetaById)(e,t);if(o){if(o.status===i.TransactionStatus.confirmed)return o;if(o.status===i.TransactionStatus.failed||o.status===i.TransactionStatus.dropped||o.status===i.TransactionStatus.rejected)throw new Error("Approval transaction did not confirm")}if(Date.now()-r>n)throw new Error("Timed out waiting for approval confirmation");await new Promise(e=>setTimeout(e,s))}};a.toBatchTxParams=(e,{chainId:t,gasLimit:a,...n},{maxFeePerGas:i,maxPriorityFeePerGas:r,gas:o})=>{const c={...n,data:n.data,to:n.to,value:n.value};return e?c:{...c,gas:(0,s.toHex)(o??0),maxFeePerGas:(0,s.toHex)(i??0),maxPriorityFeePerGas:(0,s.toHex)(r??0)}};a.getAddTransactionBatchParams=async({messenger:e,isBridgeTx:t,approval:s,resetApproval:r,trade:o,quoteResponse:{quote:{feeData:{txFee:d},gasIncluded:m,gasIncluded7702:u,gasSponsored:h},sentAmount:f,toTokenAmount:p},requireApproval:g=!1,isDelegatedAccount:k=!1})=>{const w=m||u;if(!(0,c.getAccountByAddress)(e,o.from))throw new Error("Failed to submit cross-chain swap batch transaction: unknown account in trade data");const b=(0,n.formatChainIdToHex)(o.chainId),y=(0,l.getNetworkClientIdByChainId)(e,b),T=!0===u;let x=!T&&!k;m&&!u&&(x=!0);const _=[];if(r){const n=await(0,a.calculateGasFees)(T,e,r,y,b,w?d:undefined);_.push({type:t?i.TransactionType.bridgeApproval:i.TransactionType.swapApproval,params:(0,a.toBatchTxParams)(T,r,n)})}if(s){const n=await(0,a.calculateGasFees)(T,e,s,y,b,w?d:undefined);_.push({type:t?i.TransactionType.bridgeApproval:i.TransactionType.swapApproval,params:(0,a.toBatchTxParams)(T,s,n)})}const v=await(0,a.calculateGasFees)(T,e,o,y,b,w?d:undefined);_.push({type:t?i.TransactionType.bridge:i.TransactionType.swap,params:(0,a.toBatchTxParams)(T,o,v),assetsFiatValues:{sending:f?.valueInCurrency?.toString(),receiving:p?.valueInCurrency?.toString()}});return{disable7702:x,isGasFeeIncluded:Boolean(u),isGasFeeSponsored:Boolean(h),networkClientId:y,requireApproval:g,origin:"metamask",from:o.from,transactions:_}};a.findAndUpdateTransactionsInBatch=({messenger:e,batchId:t,txDataByType:n})=>{const s=(0,a.getTransactions)(e),r={approvalMeta:undefined,tradeMeta:undefined};return Object.entries(n).forEach(([n,o])=>{if(o===undefined)return;const c=s.find(e=>{if(e.batchId!==t)return!1;if(Array.isArray(e.txParams.authorizationList)&&e.txParams.authorizationList.length>0||Boolean(e.delegationAddress)){if((n===i.TransactionType.swap||n===i.TransactionType.bridge)&&e.type===i.TransactionType.batch)return!0;if((n===i.TransactionType.swapApproval||n===i.TransactionType.bridgeApproval)&&e.txParams.data===o)return!0}return e.txParams.data===o});if(c){const t={...c,type:n};(0,a.updateTransaction)(e,c,{type:n},`Update tx type to ${n}`);const s=[i.TransactionType.bridgeApproval,i.TransactionType.swapApproval];r[s.includes(n)?"approvalMeta":"tradeMeta"]=t}}),r};a.addTransactionBatch=async(e,t,...n)=>{const s={[i.TransactionType.bridgeApproval]:n[0].transactions.find(({type:e})=>e===i.TransactionType.bridgeApproval)?.params.data,[i.TransactionType.swapApproval]:n[0].transactions.find(({type:e})=>e===i.TransactionType.swapApproval)?.params.data,[i.TransactionType.bridge]:n[0].transactions.find(({type:e})=>e===i.TransactionType.bridge)?.params.data,[i.TransactionType.swap]:n[0].transactions.find(({type:e})=>e===i.TransactionType.swap)?.params.data},{batchId:r}=await t(...n),{approvalMeta:o,tradeMeta:c}=(0,a.findAndUpdateTransactionsInBatch)({messenger:e,batchId:r,txDataByType:s});if(!c)throw new Error("Failed to update cross-chain swap transaction batch: tradeMeta not found");return{approvalMeta:o,tradeMeta:c}};const m=async(e,t,n,i,r)=>{const{gas:o}=t;if(r)return{maxFeePerGas:(0,s.toHex)(r.maxFeePerGas),maxPriorityFeePerGas:(0,s.toHex)(r.maxPriorityFeePerGas),gas:o?(0,s.toHex)(o):undefined};const{maxFeePerGas:c,maxPriorityFeePerGas:l}=await(0,a.getTxGasEstimates)(e,{transactionParams:t,chainId:i,networkClientId:n});return{maxFeePerGas:c,maxPriorityFeePerGas:l,gas:o?(0,s.toHex)(o):undefined}};a.submitEvmTransaction=async({messenger:e,trade:t,transactionType:s,requireApproval:i=!1,txFee:r,actionId:o=(0,a.generateActionId)()})=>{if(!(0,c.getAccountByAddress)(e,t.from))throw new Error("Failed to submit cross-chain swap transaction: unknown account in trade data");const d=(0,n.formatChainIdToHex)(t.chainId),u=(0,l.getNetworkClientIdByChainId)(e,d),h={actionId:o,networkClientId:u,requireApproval:i,type:s,origin:"metamask"},{gasLimit:f,...p}=t,g={...p,chainId:d,...f&&0!==f&&{gasLimit:f.toString(),gas:f.toString()}},k={...g,...await m(e,g,u,d,r)};return await(0,a.addTransaction)(e,k,h)}}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/transaction.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs",{"@metamask/bridge-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.validateIntentStatusResponse=a.IntentOrderStatus=a.validateBridgeStatusResponse=a.StatusResponseSchema=void 0;const n=e("@metamask/bridge-controller"),s=e("@metamask/superstruct"),i=(0,s.number)(),r=(0,s.type)({}),o=(0,s.type)({chainId:i,txHash:(0,s.optional)((0,s.string)()),amount:(0,s.optional)((0,s.string)()),token:(0,s.optional)((0,s.union)([r,n.BridgeAssetSchema]))}),c=(0,s.type)({chainId:i,txHash:(0,s.optional)((0,s.string)()),amount:(0,s.optional)((0,s.string)()),token:(0,s.optional)((0,s.union)([r,n.BridgeAssetSchema]))}),l=(0,s.type)({});a.StatusResponseSchema=(0,s.type)({status:(0,s.enums)(Object.values(n.StatusTypes)),srcChain:o,destChain:(0,s.optional)(c),bridge:(0,s.optional)((0,s.string)()),isExpectedToken:(0,s.optional)((0,s.boolean)()),isUnrecognizedRouterAddress:(0,s.optional)((0,s.boolean)()),refuel:(0,s.optional)(l)});var d;a.validateBridgeStatusResponse=e=>((0,s.assert)(e,a.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||(a.IntentOrderStatus=d={}));const m=(0,s.type)({id:(0,s.string)(),status:(0,s.enums)(Object.values(d)),txHash:(0,s.optional)((0,s.string)()),metadata:(0,s.type)({txHashes:(0,s.optional)((0,s.union)([(0,s.array)((0,s.string)()),(0,s.string)()]))})});a.validateIntentStatusResponse=e=>(0,s.is)(e,m)}}},{package:"@metamask/bridge-status-controller",file:"node_modules/@metamask/bridge-status-controller/dist/utils/validators.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/bridge-status-controller/node_modules/bignumber.js/bignumber.js",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){!function(e){var a,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,i=Math.floor,r="[BigNumber Error] ",o=r+"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,a,n=1,s=e.length,i=e[0]+"";n<s;){for(t=e[n++]+"",a=l-t.length;a--;t="0"+t);i+=t}for(s=i.length;48===i.charCodeAt(--s););return i.slice(0,s+1||1)}function g(e,t){var a,n,s=e.c,i=t.c,r=e.s,o=t.s,c=e.e,l=t.e;if(!r||!o)return null;if(a=s&&!s[0],n=i&&!i[0],a||n)return a?n?0:-o:r;if(r!=o)return r;if(a=r<0,n=c==l,!s||!i)return n?0:!s^a?1:-1;if(!n)return c>l^a?1:-1;for(o=(c=s.length)<(l=i.length)?c:l,r=0;r<o;r++)if(s[r]!=i[r])return s[r]>i[r]^a?1:-1;return c==l?0:c>l^a?1:-1}function k(e,t,a,n){if(e<t||e>a||e!==i(e))throw Error(r+(n||"Argument")+("number"==typeof e?e<t||e>a?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function w(e){var t=e.c.length-1;return f(e.e/l)==t&&e.c[t]%2!=0}function b(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function y(e,t,a){var n,s;if(t<0){for(s=a+".";++t;s+=a);e=s+e}else if(++t>(n=e.length)){for(s=a,t-=n;--t;s+=a);e+=s}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}a=function e(t){var a,T,x,_,v,E,S,I,P,C,j=W.prototype={constructor:W,toString:null,valueOf:null},A=new W(1),F=20,D=4,M=-7,O=21,N=-1e7,L=1e7,G=!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 a,s,r,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>L?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>L?p.c=p.e=null:(p.e=c,p.c=[e]))}f=String(e)}else{if(!n.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,D);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(a=U.slice(0,t),c=m=0,h=f.length;m<h;m++)if(a.indexOf(s=f.charAt(m))<0){if("."==s){if(m>c){c=h;continue}}else if(!r&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){r=!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!==i(e)))throw Error(o+p.s*e);if((c=c-m-1)>L)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,a,n){var s,i,r,o,c;if(null==a?a=D:k(a,0,8),!e.c)return e.toString();if(s=e.c[0],r=e.e,null==t)c=p(e.c),c=1==n||2==n&&(r<=M||r>=O)?b(c,r):y(c,r,"0");else if(i=(e=z(new W(e),t,a)).e,o=(c=p(e.c)).length,1==n||2==n&&(t<=i||i<=M)){for(;o<t;c+="0",o++);c=b(c,i)}else if(t-=r+(2===n&&i>r),c=y(c,i,"0"),i+1>o){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=i-o)>0)for(i+1==o&&(c+=".");t--;c+="0");return e.s<0&&s?"-"+c:c}function K(e,t){for(var a,n,s=1,i=new W(e[0]);s<e.length;s++)(!(n=new W(e[s])).s||(a=g(i,n))===t||0===a&&i.s===t)&&(i=n);return i}function V(e,t,a){for(var n=1,s=t.length;!t[--s];t.pop());for(s=t[0];s>=10;s/=10,n++);return(a=n+a*l-1)>L?e.c=e.e=null:a<N?e.c=[e.e=0]:(e.e=a,e.c=t),e}function z(e,t,a,n){var r,o,d,u,h,f,p,g=e.c,k=m;if(g){e:{for(r=1,u=g[0];u>=10;u/=10,r++);if((o=t-r)<0)o+=l,d=t,h=g[f=0],p=i(h/k[r-d-1]%10);else if((f=s((o+1)/l))>=g.length){if(!n)break e;for(;g.length<=f;g.push(0));h=p=0,r=1,d=(o%=l)-l+1}else{for(h=u=g[f],r=1;u>=10;u/=10,r++);p=(d=(o%=l)-l+r)<0?0:i(h/k[r-d-1]%10)}if(n=n||t<0||null!=g[f+1]||(d<0?h:h%k[r-d-1]),n=a<4?(p||n)&&(0==a||a==(e.s<0?3:2)):p>5||5==p&&(4==a||n||6==a&&(o>0?d>0?h/k[r-d]:0:g[f-1])%10&1||a==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(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?i(h/k[r-d]%k[d])*u:0),n)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>L?e.c=e.e=null:e.e<N&&(e.c=[e.e=0])}return e}function J(e){var t,a=e.e;return null===a?e.toString():(t=p(e.c),t=a<=M||a>=O?b(t,a):y(t,a,"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,a;if(null!=e){if("object"!=typeof e)throw Error(r+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(k(a=e[t],0,h,t),F=a),e.hasOwnProperty(t="ROUNDING_MODE")&&(k(a=e[t],0,8,t),D=a),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((a=e[t])&&a.pop?(k(a[0],-h,0,t),k(a[1],0,h,t),M=a[0],O=a[1]):(k(a,-h,h,t),M=-(O=a<0?-a:a))),e.hasOwnProperty(t="RANGE"))if((a=e[t])&&a.pop)k(a[0],-h,-1,t),k(a[1],1,h,t),N=a[0],L=a[1];else{if(k(a,-h,h,t),!a)throw Error(r+t+" cannot be zero: "+a);N=-(L=a<0?-a:a)}if(e.hasOwnProperty(t="CRYPTO")){if((a=e[t])!==!!a)throw Error(r+t+" not true or false: "+a);if(a){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw G=!a,Error(r+"crypto unavailable");G=a}else G=a}if(e.hasOwnProperty(t="MODULO_MODE")&&(k(a=e[t],0,9,t),B=a),e.hasOwnProperty(t="POW_PRECISION")&&(k(a=e[t],0,h,t),R=a),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(a=e[t]))throw Error(r+t+" not an object: "+a);H=a}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(a=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(a))throw Error(r+t+" invalid: "+a);q="0123456789"==a.slice(0,10),U=a}}return{DECIMAL_PLACES:F,ROUNDING_MODE:D,EXPONENTIAL_AT:[M,O],RANGE:[N,L],CRYPTO:G,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,a,n=e.c,s=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&s>=-h&&s<=h&&s===i(s)){if(0===n[0]){if(0===s&&1===n.length)return!0;break e}if((t=(s+1)%l)<1&&(t+=l),String(n[0]).length==t){for(t=0;t<n.length;t++)if((a=n[t])<0||a>=c||a!==i(a))break e;if(0!==a)return!0}}}else if(null===n&&null===s&&(null===o||1===o||-1===o))return!0;throw Error(r+"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 i(Math.random()*_)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,a,n,o,c,d=0,u=[],f=new W(A);if(null==e?e=F:k(e,0,h),o=s(e/l),G)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));d<o;)(c=131072*t[d]+(t[d+1]>>>11))>=9e15?(a=crypto.getRandomValues(new Uint32Array(2)),t[d]=a[0],t[d+1]=a[1]):(u.push(c%1e14),d+=2);d=o/2}else{if(!crypto.randomBytes)throw G=!1,Error(r+"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(!G)for(;d<o;)(c=v())<9e15&&(u[d++]=c%1e14);for(o=u[--d],e%=l,o&&e&&(c=m[l-e],u[d]=i(o/c)*c);0===u[d];u.pop(),d--);if(d<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=l);for(d=1,c=u[0];c>=10;c/=10,d++);d<l&&(n-=l-d)}return f.e=n,f.c=u,f}),W.sum=function(){for(var e=1,t=arguments,a=new W(t[0]);e<t.length;)a=a.plus(t[e++]);return a},T=function(){var e="0123456789";function t(e,t,a,n){for(var s,i,r=[0],o=0,c=e.length;o<c;){for(i=r.length;i--;r[i]*=t);for(r[0]+=n.indexOf(e.charAt(o++)),s=0;s<r.length;s++)r[s]>a-1&&(null==r[s+1]&&(r[s+1]=0),r[s+1]+=r[s]/a|0,r[s]%=a)}return r.reverse()}return function(n,s,i,r,o){var c,l,d,m,u,h,f,g,k=n.indexOf("."),w=F,b=D;for(k>=0&&(m=R,R=0,n=n.replace(".",""),h=(g=new W(s)).pow(n.length-k),R=m,g.c=t(y(p(h.c),h.e,"0"),10,i,e),g.e=g.c.length),d=m=(f=t(n,s,i,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=r,f=(h=a(h,g,w,b,i)).c,u=h.r,d=h.e),k=f[l=d+w+1],m=i/2,u=u||l<0||null!=f[l+1],u=b<4?(null!=k||u)&&(0==b||b==(h.s<0?3:2)):k>m||k==m&&(4==b||u||6==b&&1&f[l-1]||b==(h.s<0?8:7)),l<1||!f[0])n=u?y(c.charAt(1),-w,c.charAt(0)):c.charAt(0);else{if(f.length=l,u)for(--i;++f[--l]>i;)f[l]=0,l||(++d,f=[1].concat(f));for(m=f.length;!f[--m];);for(k=0,n="";k<=m;n+=c.charAt(f[k++]));n=y(n,d,c.charAt(0))}return n}}(),a=function(){function e(e,t,a){var n,s,i,r,o=0,c=e.length,l=t%u,d=t/u|0;for(e=e.slice();c--;)o=((s=l*(i=e[c]%u)+(n=d*i+(r=e[c]/u|0)*l)%u*u+o)/a|0)+(n/u|0)+d*r,e[c]=s%a;return o&&(e=[o].concat(e)),e}function t(e,t,a,n){var s,i;if(a!=n)i=a>n?1:-1;else for(s=i=0;s<a;s++)if(e[s]!=t[s]){i=e[s]>t[s]?1:-1;break}return i}function a(e,t,a,n){for(var s=0;a--;)e[a]-=s,s=e[a]<t[a]?1:0,e[a]=s*n+e[a]-t[a];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,s,r,o,d){var m,u,h,p,g,k,w,b,y,T,x,_,v,E,S,I,P,C=n.s==s.s?1:-1,j=n.c,A=s.c;if(!(j&&j[0]&&A&&A[0]))return new W(n.s&&s.s&&(j?!A||j[0]!=A[0]:A)?j&&0==j[0]||!A?0*C:C/0:NaN);for(y=(b=new W(C)).c=[],C=r+(u=n.e-s.e)+1,d||(d=c,u=f(n.e/l)-f(s.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,I=A.length,h=0,C+=2,(g=i(d/(A[0]+1)))>1&&(A=e(A,g,d),j=e(j,g,d),I=A.length,E=j.length),v=I,x=(T=j.slice(0,I)).length;x<I;T[x++]=0);P=A.slice(),P=[0].concat(P),S=A[0],A[1]>=d/2&&S++;do{if(g=0,(m=t(A,T,I,x))<0){if(_=T[0],I!=x&&(_=_*d+(T[1]||0)),(g=i(_/S))>1)for(g>=d&&(g=d-1),w=(k=e(A,g,d)).length,x=T.length;1==t(k,T,w,x);)g--,a(k,I<w?P:A,w,d),w=k.length,m=1;else 0==g&&(m=g=1),w=(k=A.slice()).length;if(w<x&&(k=[0].concat(k)),a(T,k,x,d),x=T.length,-1==m)for(;t(A,T,I,x)<1;)g++,a(T,I<x?P: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(b,r+(b.e=h+u*l-1)+1,o,p)}else b.e=u,b.r=+p;return b}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,S=/^([^.]+)\.$/,I=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,C=/^\s*\+(?=[\w.])|^\s+|\s+$/g,x=function(e,t,a,n){var s,i=a?t:t.replace(C,"");if(P.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!a&&(i=i.replace(E,function(e,t,a){return s="x"==(a=a.toLowerCase())?16:"b"==a?2:8,n&&n!=s?e:t}),n&&(s=n,i=i.replace(S,"$1").replace(I,"0.$1")),t!=i))return new W(i,s);if(W.DEBUG)throw Error(r+"Not a"+(n?" base "+n:"")+" 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 a,n,s,i=this;if(null!=e)return k(e,0,h),null==t?t=D:k(t,0,8),z(new W(i),e+i.e+1,t);if(!(a=i.c))return null;if(n=((s=a.length-1)-f(this.e/l))*l,s=a[s])for(;s%10==0;s/=10,n--);return n<0&&(n=0),n},j.dividedBy=j.div=function(e,t){return a(this,new W(e,t),F,D)},j.dividedToIntegerBy=j.idiv=function(e,t){return a(this,new W(e,t),0,1)},j.exponentiatedBy=j.pow=function(e,t){var a,n,o,c,d,m,u,h,f=this;if((e=new W(e)).c&&!e.isInteger())throw Error(r+"Exponent not an integer: "+J(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(+J(f),d?e.s*(2-w(e)):+J(e))),t?h.mod(t):h;if(m=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new W(NaN);(n=!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&&w(e)?-0:0,f.e>-1&&(c=1/c),new W(m?1/c:c);R&&(c=s(R/l+2))}for(d?(a=new W(.5),m&&(e.s=1),u=w(e)):u=(o=Math.abs(+J(e)))%2,h=new W(A);;){if(u){if(!(h=h.times(f)).c)break;c?h.c.length>c&&(h.c.length=c):n&&(h=h.mod(t))}if(o){if(0===(o=i(o/2)))break;u=o%2}else if(z(e=e.times(a),e.e+1,1),e.e>14)u=w(e);else{if(0===(o=+J(e)))break;u=o%2}f=f.times(f),c?f.c&&f.c.length>c&&(f.c.length=c):n&&(f=f.mod(t))}return n?h:(m&&(h=A.div(h)),t?h.mod(t):c?z(h,R,D,undefined):h)},j.integerValue=function(e){var t=new W(this);return null==e?e=D: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 a,n,s,i,r=this,o=r.s;if(t=(e=new W(e,t)).s,!o||!t)return new W(NaN);if(o!=t)return e.s=-t,r.plus(e);var d=r.e/l,m=e.e/l,u=r.c,h=e.c;if(!d||!m){if(!u||!h)return u?(e.s=-t,e):new W(h?r:NaN);if(!u[0]||!h[0])return h[0]?(e.s=-t,e):new W(u[0]?r:3==D?-0:0)}if(d=f(d),m=f(m),u=u.slice(),o=d-m){for((i=o<0)?(o=-o,s=u):(m=d,s=h),s.reverse(),t=o;t--;s.push(0));s.reverse()}else for(n=(i=(o=u.length)<(t=h.length))?o:t,o=t=0;t<n;t++)if(u[t]!=h[t]){i=u[t]<h[t];break}if(i&&(s=u,u=h,h=s,e.s=-e.s),(t=(n=h.length)-(a=u.length))>0)for(;t--;u[a++]=0);for(t=c-1;n>o;){if(u[--n]<h[n]){for(a=n;a&&!u[--a];u[a]=t);--u[a],u[n]+=c}u[n]-=h[n]}for(;0==u[0];u.splice(0,1),--m);return u[0]?V(e,u,m):(e.s=3==D?-1:1,e.c=[e.e=0],e)},j.modulo=j.mod=function(e,t){var n,s,i=this;return e=new W(e,t),!i.c||!e.s||e.c&&!e.c[0]?new W(NaN):!e.c||i.c&&!i.c[0]?new W(i):(9==B?(s=e.s,e.s=1,n=a(i,e,0,3),e.s=s,n.s*=s):n=a(i,e,0,B),(e=i.minus(n.times(e))).c[0]||1!=B||(e.s=i.s),e)},j.multipliedBy=j.times=function(e,t){var a,n,s,i,r,o,d,m,h,p,g,k,w,b,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(n=f(T.e/l)+f(e.e/l),e.s*=T.s,(d=x.length)<(p=_.length)&&(w=x,x=_,_=w,s=d,d=p,p=s),s=d+p,w=[];s--;w.push(0));for(b=c,y=u,s=p;--s>=0;){for(a=0,g=_[s]%y,k=_[s]/y|0,i=s+(r=d);i>s;)a=((m=g*(m=x[--r]%y)+(o=k*m+(h=x[r]/y|0)*g)%y*y+w[i]+a)/b|0)+(o/y|0)+k*h,w[i--]=m%b;w[i]=a}return a?++n:w.splice(0,1),V(e,w,n)},j.negated=function(){var e=new W(this);return e.s=-e.s||null,e},j.plus=function(e,t){var a,n=this,s=n.s;if(t=(e=new W(e,t)).s,!s||!t)return new W(NaN);if(s!=t)return e.s=-t,n.minus(e);var i=n.e/l,r=e.e/l,o=n.c,d=e.c;if(!i||!r){if(!o||!d)return new W(s/0);if(!o[0]||!d[0])return d[0]?e:new W(o[0]?n:0*s)}if(i=f(i),r=f(r),o=o.slice(),s=i-r){for(s>0?(r=i,a=d):(s=-s,a=o),a.reverse();s--;a.push(0));a.reverse()}for((s=o.length)-(t=d.length)<0&&(a=d,d=o,o=a,t=s),s=0;t;)s=(o[--t]=o[t]+d[t]+s)/c|0,o[t]=c===o[t]?0:o[t]%c;return s&&(o=[s].concat(o),++r),V(e,o,r)},j.precision=j.sd=function(e,t){var a,n,s,i=this;if(null!=e&&e!==!!e)return k(e,1,h),null==t?t=D:k(t,0,8),z(new W(i),e,t);if(!(a=i.c))return null;if(n=(s=a.length-1)*l+1,s=a[s]){for(;s%10==0;s/=10,n--);for(s=a[0];s>=10;s/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},j.shiftedBy=function(e){return k(e,-9007199254740991,d),this.times("1e"+e)},j.squareRoot=j.sqrt=function(){var e,t,n,s,i,r=this,o=r.c,c=r.s,l=r.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?r:1/0);if(0==(c=Math.sqrt(+J(r)))||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),n=new W(t=c==1/0?"5e"+l:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+l)):n=new W(c+""),n.c[0])for((c=(l=n.e)+d)<3&&(c=0);;)if(i=n,n=m.times(i.plus(a(r,i,d,1))),p(i.c).slice(0,c)===(t=p(n.c)).slice(0,c)){if(n.e<l&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(s||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(n,n.e+F+2,1),e=!n.times(n).eq(r));break}if(!s&&(z(i,i.e+F+2,0),i.times(i).eq(r))){n=i;break}d+=4,c+=4,s=1}return z(n,n.e+F+1,D,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,a){var n,s=this;if(null==a)null!=e&&t&&"object"==typeof t?(a=t,t=null):e&&"object"==typeof e?(a=e,e=t=null):a=H;else if("object"!=typeof a)throw Error(r+"Argument not an object: "+a);if(n=s.toFixed(e,t),s.c){var i,o=n.split("."),c=+a.groupSize,l=+a.secondaryGroupSize,d=a.groupSeparator||"",m=o[0],u=o[1],h=s.s<0,f=h?m.slice(1):m,p=f.length;if(l&&(i=c,c=l,l=i,p-=i),c>0&&p>0){for(i=p%c||c,m=f.substr(0,i);i<p;i+=c)m+=d+f.substr(i,c);l>0&&(m+=d+f.slice(i)),h&&(m="-"+m)}n=u?m+(a.decimalSeparator||"")+((l=+a.fractionGroupSize)?u.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(a.fractionGroupSeparator||"")):u):m}return(a.prefix||"")+n+(a.suffix||"")},j.toFraction=function(e){var t,n,s,i,o,c,d,u,h,f,g,k,w=this,b=w.c;if(null!=e&&(!(d=new W(e)).isInteger()&&(d.c||1!==d.s)||d.lt(A)))throw Error(r+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+J(d));if(!b)return new W(w);for(t=new W(A),h=n=new W(A),s=u=new W(A),k=p(b),o=t.e=k.length-w.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=L,L=1/0,d=new W(k),u.c[0]=0;f=a(d,t,0,1),1!=(i=n.plus(f.times(s))).comparedTo(e);)n=s,s=i,h=u.plus(f.times(i=h)),u=i,t=d.minus(f.times(i=t)),d=i;return i=a(e.minus(n),s,0,1),u=u.plus(i.times(h)),n=n.plus(i.times(s)),u.s=h.s=w.s,g=a(h,s,o*=2,D).minus(w).abs().comparedTo(a(u,n,o,D).minus(w).abs())<1?[h,s]:[u,n],L=c,g},j.toNumber=function(){return+J(this)},j.toPrecision=function(e,t){return null!=e&&k(e,1,h),$(this,e,t,2)},j.toString=function(e){var t,a=this,n=a.s,s=a.e;return null===s?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=s<=M||s>=O?b(p(a.c),s):y(p(a.c),s,"0"):10===e&&q?t=y(p((a=z(new W(a),F+s+1,D)).c),a.e,"0"):(k(e,2,U.length,"Base"),t=T(y(p(a.c),s,"0"),10,e,n,!0)),n<0&&a.c[0]&&(t="-"+t)),t},j.valueOf=j.toJSON=function(){return J(this)},j._isBigNumber=!0,null!=t&&W.set(t),W}(),a.default=a.BigNumber=a,"function"==typeof define&&define.amd?define(function(){return a}):void 0!==t&&t.exports?t.exports=a:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=a)}(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,a){(function(t){(function(){Object.defineProperty(a,"__esModule",{value:!0}),a.isVaultUpdated=a.updateVaultWithDetail=a.updateVault=a.generateSalt=a.serializeBufferForStorage=a.serializeBufferFromStorage=a.keyFromPassword=a.exportKey=a.importKey=a.decryptWithKey=a.decryptWithDetail=a.decrypt=a.encryptWithKey=a.encryptWithDetail=a.encrypt=void 0;const n=e("@metamask/utils"),s="jwk",i="AES-GCM",r="utf-8",o={algorithm:"PBKDF2",params:{iterations:1e4}},c={algorithm:"PBKDF2",params:{iterations:9e5}};async function l(e,t,a,n=g(),s=c){const i=a||await p(e,n,!1,s),r=await m(i,t);return r.salt=n,JSON.stringify(r)}async function d(e,t,a=g(),n=c){const s=await p(e,a,!0,n),i=await f(s);return{vault:await l(e,t,s,a),exportedKeyString:i}}async function m(e,a){const n=JSON.stringify(a),s=t.from(n,r),o=globalThis.crypto.getRandomValues(new Uint8Array(16)),c=b(e),l=await globalThis.crypto.subtle.encrypt({name:i,iv:o},c,s),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,a){const n=JSON.parse(t),{salt:s,keyMetadata:i}=n,r=b(a||await p(e,s,!1,i));return await h(r,n)}async function h(e,a){const n=t.from(a.data,"base64"),s=t.from(a.iv,"base64"),o=b(e);let c;try{const e=await crypto.subtle.decrypt({name:i,iv:s},o,n),a=new Uint8Array(e),l=t.from(a).toString(r);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(s,e.key),derivationOptions:e.derivationOptions}):JSON.stringify(await globalThis.crypto.subtle.exportKey(s,e))}async function p(e,a,n=!1,s=o){const c=t.from(e,r),l=t.from(a,"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:s.params.iterations,hash:"SHA-256"},d,{name:i,length:256},n,["encrypt","decrypt"]);return s?{key:m,derivationOptions:s}: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,n.isPlainObject)(e)&&(0,n.hasProperty)(e,"key")&&(0,n.hasProperty)(e,"derivationOptions")&&e.key instanceof CryptoKey&&w(e.derivationOptions)}function w(e){return(0,n.isPlainObject)(e)&&(0,n.hasProperty)(e,"algorithm")&&(0,n.hasProperty)(e,"params")}function b(e){return k(e)?e.key:e}function y(e,t=c){const{keyMetadata:a}=JSON.parse(e);return w(a)&&a.algorithm===t.algorithm&&a.params.iterations===t.params.iterations}a.encrypt=l,a.encryptWithDetail=d,a.encryptWithKey=m,a.decrypt=u,a.decryptWithDetail=async function(e,t){const a=JSON.parse(t),{salt:n,keyMetadata:s}=a,i=await p(e,n,!0,s);return{exportedKeyString:await f(i),vault:await u(e,t,i),salt:n}},a.decryptWithKey=h,a.importKey=async function(e){const t=JSON.parse(e);return a=t,(0,n.isPlainObject)(a)&&(0,n.hasProperty)(a,"key")&&(0,n.hasProperty)(a,"derivationOptions")&&w(a.derivationOptions)?{key:await globalThis.crypto.subtle.importKey(s,t.key,i,!0,["encrypt","decrypt"]),derivationOptions:t.derivationOptions}:await globalThis.crypto.subtle.importKey(s,t,i,!0,["encrypt","decrypt"]);var a},a.exportKey=f,a.keyFromPassword=p,a.serializeBufferFromStorage=function(e){const t="0x"===e.slice(0,2)?e.slice(2):e,a=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2){const n=t.substr(e,2);a[e/2]=parseInt(n,16)}return a},a.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},a.generateSalt=g,a.updateVault=async function(e,t,a=c){return y(e,a)?e:l(t,await u(t,e),undefined,undefined,a)},a.updateVaultWithDetail=async function(e,t,a=c){return y(e.vault,a)?e:d(t,await u(t,e.vault),undefined,a)},a.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/connectivity-controller/dist/ConnectivityController.cjs",{"./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/connectivity-controller/dist/types.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.ConnectivityController=a.getDefaultConnectivityControllerState=a.controllerName=void 0;const n=e("@metamask/base-controller"),s=e("./types.cjs");a.controllerName="ConnectivityController";const i={connectivityStatus:{persist:!1,includeInDebugSnapshot:!0,includeInStateLogs:!0,usedInUi:!0}};function r(){return{connectivityStatus:s.CONNECTIVITY_STATUSES.Online}}a.getDefaultConnectivityControllerState=r;class o extends n.BaseController{constructor({messenger:e,connectivityAdapter:t}){const n=t.getStatus();super({messenger:e,metadata:i,name:a.controllerName,state:{...r(),connectivityStatus:n}}),t.onConnectivityChange(e=>{this.update(t=>{t.connectivityStatus=e})})}}a.ConnectivityController=o}}},{package:"@metamask/connectivity-controller",file:"node_modules/@metamask/connectivity-controller/dist/ConnectivityController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/connectivity-controller/dist/index.cjs",{"./ConnectivityController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/connectivity-controller/dist/ConnectivityController.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/connectivity-controller/dist/types.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getDefaultConnectivityControllerState=a.ConnectivityController=a.CONNECTIVITY_STATUSES=void 0;var n=e("./types.cjs");Object.defineProperty(a,"CONNECTIVITY_STATUSES",{enumerable:!0,get:function(){return n.CONNECTIVITY_STATUSES}});var s=e("./ConnectivityController.cjs");Object.defineProperty(a,"ConnectivityController",{enumerable:!0,get:function(){return s.ConnectivityController}}),Object.defineProperty(a,"getDefaultConnectivityControllerState",{enumerable:!0,get:function(){return s.getDefaultConnectivityControllerState}})}}},{package:"@metamask/connectivity-controller",file:"node_modules/@metamask/connectivity-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/connectivity-controller/dist/types.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.CONNECTIVITY_STATUSES=void 0,a.CONNECTIVITY_STATUSES={Online:"online",Offline:"offline"}}}},{package:"@metamask/connectivity-controller",file:"node_modules/@metamask/connectivity-controller/dist/types.cjs"}],["/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,a){var n,s,i=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},r=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.DelegationController=a.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");a.controllerName="DelegationController";const u={delegations:{includeInStateLogs:!1,persist:!0,includeInDebugSnapshot:!1,usedInUi:!1}};class h extends o.BaseController{constructor({messenger:e,state:t,hashDelegation:r,getDelegationEnvironment:o}){super({messenger:e,metadata:u,name:a.controllerName,state:{delegations:{},...t}}),n.set(this,void 0),s.set(this,void 0),i(this,n,r,"f"),i(this,s,o,"f")}async signDelegation(e){const{delegation:t,chainId:a}=e,{DelegationManager:n}=r(this,s,"f").call(this,a),i=(0,m.createTypedMessageParams)({chainId:(0,l.hexToNumber)(a),from:t.delegator,delegation:{...t,signature:"0x"},verifyingContract:n});return await this.messenger.call("KeyringController:signTypedMessage",i,c.SignTypedDataVersion.V4)}store(e){const{entry:t}=e,a=r(this,n,"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[a]=t})}list(e){const t=this.messenger.call("AccountsController:getSelectedAccount").address;let a=Object.values(this.state.delegations);e?.from&&(a=a.filter(t=>(0,m.isHexEqual)(t.delegation.delegator,e.from))),(!e?.from||e?.from&&!(0,m.isHexEqual)(e.from,t))&&(a=a.filter(e=>(0,m.isHexEqual)(e.delegation.delegate,t)));const n=e?.chainId;n&&(a=a.filter(e=>(0,m.isHexEqual)(e.chainId,n)));const s=e?.tags;return s&&s.length>0&&(a=a.filter(e=>s.every(t=>e.tags.includes(t)))),a}retrieve(e){return this.state.delegations[e]??null}chain(e){const t=[],a=this.retrieve(e);if(!a)return null;t.push(a);for(let e=a.delegation.authority;e!==d.ROOT_AUTHORITY;){const a=this.retrieve(e);if(!a)throw new Error("Invalid delegation chain");t.push(a),e=a.delegation.authority}return t}delete(e){if(!this.retrieve(e))return 0;const t=Object.entries(this.state.delegations),a=[e],n=[];for(;a.length>0;){const e=a.pop();t.filter(([t,a])=>a.delegation.authority===e).forEach(([e])=>{a.push(e)}),n.push(e)}return this.update(e=>{n.forEach(t=>{delete e.delegations[t]})}),n.length}}a.DelegationController=h,n=new WeakMap,s=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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.SIGNABLE_DELEGATION_TYPED_DATA=a.ROOT_AUTHORITY=void 0,a.ROOT_AUTHORITY="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";a.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.DelegationController=void 0;var n=e("./DelegationController.cjs");Object.defineProperty(a,"DelegationController",{enumerable:!0,get:function(){return n.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.createTypedMessageParams=a.toDelegationStruct=a.isHexEqual=void 0;const n=e("@metamask/utils"),s=e("./constants.cjs");a.isHexEqual=function(e,t){return e.toLowerCase()===t.toLowerCase()};a.toDelegationStruct=e=>{const t=e.caveats.map(e=>({enforcer:(0,n.getChecksumAddress)(e.enforcer),terms:e.terms,args:e.args})),a="0x"===e.salt?0n:BigInt(e.salt);return{delegate:(0,n.getChecksumAddress)(e.delegate),delegator:(0,n.getChecksumAddress)(e.delegator),authority:e.authority,caveats:t,salt:a,signature:e.signature}},a.createTypedMessageParams=function(e){const{chainId:t,from:n,delegation:i,verifyingContract:r}=e;return{data:{types:s.SIGNABLE_DELEGATION_TYPED_DATA,primaryType:"Delegation",domain:{chainId:t,name:"DelegationManager",version:"1",verifyingContract:r},message:(0,a.toDelegationStruct)(i)},from:n}}}}},{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,a){Object.defineProperty(a,"__esModule",{value:!0});var n={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"},s={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"},i={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"},r={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":{[r.optimism]:i,[r.polygon]:i,[r.base]:i,[r.arbitrum]:i,[r.linea]:i,[r.sepolia]:{...i,HybridDeleGatorImpl:"0x5989F5D13DF8fc818EdA65e417AED90459fD67F7"},[r.lineaSepolia]:{...i,HybridDeleGatorImpl:"0x5989F5D13DF8fc818EdA65e417AED90459fD67F7"}},"1.1.0":{[r.arbitrum]:s,[r.base]:s,[r.linea]:s,[r.optimism]:s,[r.polygon]:s,[r.sepolia]:s,[r.lineaSepolia]:s,[r.baseSepolia]:{...s,SimpleFactory:"0xE8eA1DE8D6AfE400B7C8C1A81B7C29B7876b4d02"}},"1.3.0":{[r.mainnet]:n,[r.polygon]:n,[r.bsc]:n,[r.optimism]:n,[r.arbitrum]:n,[r.ink]:n,[r.linea]:n,[r.base]:n,[r.gnosis]:n,[r.berachain]:n,[r.unichain]:n,[r.arbitrumNova]:n,[r.sei]:n,[r.sonic]:n,[r.monad]:n,[r.bscTestnet]:n,[r.citreaTestnet]:n,[r.megaEthTestnet]:n,[r.chiado]:n,[r.lineaSepolia]:n,[r.berachainBepolia]:n,[r.baseSepolia]:n,[r.arbitrumSepolia]:n,[r.sepolia]:n,[r.optimismSepolia]:n,[r.unichainSepolia]:n,[r.polygonAmoy]:n,[r.inkSepolia]:n,[r.monadTestnet]:n,[r.seiTestnet]:n,[r.sonicTestnet]:n,[r.hoodiTestnet]:n}};a.CHAIN_ID=r,a.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.GetCallsStatusCode=a.EIP7682ErrorCode=a.EIP5792ErrorCode=a.SupportedCapabilities=a.MessageType=a.KEYRING_TYPES_SUPPORTING_7702=a.VERSION=void 0;const n=e("@metamask/keyring-controller");var s,i,r,o,c;a.VERSION="2.0.0",a.KEYRING_TYPES_SUPPORTING_7702=[n.KeyringTypes.hd,n.KeyringTypes.simple],function(e){e.SendTransaction="eth_sendTransaction"}(s||(a.MessageType=s={})),function(e){e.AuxiliaryFunds="auxiliaryFunds"}(i||(a.SupportedCapabilities=i={})),function(e){e[e.UnsupportedNonOptionalCapability=5700]="UnsupportedNonOptionalCapability",e[e.UnsupportedChainId=5710]="UnsupportedChainId",e[e.UnknownBundleId=5730]="UnknownBundleId",e[e.RejectedUpgrade=5750]="RejectedUpgrade"}(r||(a.EIP5792ErrorCode=r={})),function(e){e[e.UnsupportedAsset=5771]="UnsupportedAsset",e[e.UnsupportedChain=5772]="UnsupportedChain",e[e.MalformedRequiredAssets=5773]="MalformedRequiredAssets"}(o||(a.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||(a.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getCallsStatus=void 0;const n=e("@metamask/rpc-errors"),s=e("@metamask/transaction-controller"),i=e("../constants.cjs");a.getCallsStatus=function(e,t){const a=e.call("TransactionController:getState").transactions.filter(e=>e.batchId===t);if(!a?.length)throw new n.JsonRpcError(i.EIP5792ErrorCode.UnknownBundleId,"No matching bundle found");const r=a[0],{chainId:o,txReceipt:c}=r,l=function(e){const{hash:t,status:a}=e;if(a===s.TransactionStatus.confirmed)return i.GetCallsStatusCode.CONFIRMED;if(a===s.TransactionStatus.failed)return t?i.GetCallsStatusCode.REVERTED:i.GetCallsStatusCode.FAILED_OFFCHAIN;if(a===s.TransactionStatus.dropped)return i.GetCallsStatusCode.REVERTED;return i.GetCallsStatusCode.PENDING}(r),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:i.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getCapabilities=void 0;const n=e("../constants.cjs"),s=e("../utils.cjs");a.getCapabilities=async function(e,t,a,i){const{getDismissSmartAccountSuggestionEnabled:r,getIsSmartTransaction:o,isAtomicBatchSupported:c,isRelaySupported:l,getSendBundleSupportedChains:d,isAuxiliaryFundsSupported:m}=e;let u=i?.map(e=>e.toLowerCase());if(!u?.length){const e=t.call("NetworkController:getState").networkConfigurationsByChainId;u=Object.keys(e)}const h=await c({address:a,chainIds:u}),f=await async function(e,t,a,n,s,i){const r=i.call("PreferencesController:getState").useTransactionSimulations,o=await Promise.all(t.map(({chainId:e})=>e).map(e=>n(e))),c=await s(e),l=t.map((e,t)=>({...e,relaySupportedForChain:o[t]}));return e.reduce((e,t)=>{const n=l.find(({chainId:e})=>e===t)??{},{isSupported:s=!1,relaySupportedForChain:i}=n,o=a(t),d=c[t]??!1;return r&&(o&&d||s&&i)&&(e[t]={alternateGasFees:{supported:!0}}),e},{})}(u,h,o,l,d,t);return u.reduce((e,i)=>{const o=h.find(({chainId:e})=>e===i)??{},{delegationAddress:c,isSupported:l,upgradeContractAddress:d}=o,u=r();let f=!1;try{const e=(0,s.getAccountKeyringType)(a,t);f=n.KEYRING_TYPES_SUPPORTING_7702.includes(e)}catch{}if(!l&&!(!u&&d&&!c&&f))return e;const p=l?"supported":"ready",g=i;return e[g]===undefined&&(e[g]={}),e[g].atomic={status:p},f&&m(i)&&(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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.processSendCalls=void 0;const n=e("@metamask/rpc-errors"),s=e("@metamask/transaction-controller"),i=e("@metamask/utils"),r=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 n.rpcErrors.invalidInput(`Version not supported: Got ${t}, expected ${c.VERSION}`)}function m(e,t){const{chainId:a}=e;if(a&&a.toLowerCase()!==t.toLowerCase())throw n.rpcErrors.invalidParams(`Chain ID must match the dApp selected network: Got ${a}, expected ${t}`)}function u(e,t,a){const{calls:s,capabilities:i,chainId:r}=e,o=[...Object.keys(i??{}).filter(e=>e!==c.SupportedCapabilities.AuxiliaryFunds.toString()&&!0!==i?.[e].optional),...s.flatMap(e=>Object.keys(e.capabilities??{}).filter(t=>t!==c.SupportedCapabilities.AuxiliaryFunds.toString()&&!0!==e.capabilities?.[t].optional))];if(o?.length)throw new n.JsonRpcError(c.EIP5792ErrorCode.UnsupportedNonOptionalCapability,`Unsupported non-optional capabilities: ${o.join(", ")}`);i?.auxiliaryFunds&&h({auxiliaryFunds:i.auxiliaryFunds,chainId:r,keyringType:t,isAuxiliaryFundsSupported:a});for(const e of s)e.capabilities?.auxiliaryFunds&&h({auxiliaryFunds:e.capabilities.auxiliaryFunds,chainId:r,keyringType:t,isAuxiliaryFundsSupported:a})}function h({auxiliaryFunds:e,chainId:t,keyringType:a,isAuxiliaryFundsSupported:s}){if(e.optional)return;if(!c.KEYRING_TYPES_SUPPORTING_7702.includes(a))throw new n.JsonRpcError(c.EIP5792ErrorCode.UnsupportedNonOptionalCapability,`Unsupported non-optional capability: ${c.SupportedCapabilities.AuxiliaryFunds}`);if(!s(t))throw new n.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 n.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 a=(0,r.groupBy)(t,e=>`${e.address.toLowerCase()}-${e.standard}`);return Object.values(a).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,i.add0x)(t.toString(16))}})}a.processSendCalls=async function(e,t,a,r){const{addTransactionBatch:h,addTransaction:p,getDismissSmartAccountSuggestionEnabled:g,isAtomicBatchSupported:k,validateSecurity:w,getPermittedAccountsForOrigin:b,isAuxiliaryFundsSupported:y}=e,{calls:T,from:x}=a,{networkClientId:_,origin:v}=r,E=T.map(e=>({params:e})),{chainId:S}=t.call("NetworkController:getNetworkClientById",_).configuration,[I]=await b(),P=x??I;if(!P)throw n.providerErrors.unauthorized();const C=(0,o.v4)(),j=w.bind(null,C),A=r.id?String(r.id):"";let F;return F=1===Object.keys(E).length?await async function({addTransaction:e,chainId:t,from:a,messenger:n,networkClientId:r,origin:h,requestId:p,securityAlertId:g,sendCalls:k,transactions:w,validateSecurity:b,isAuxiliaryFundsSupported:y}){const T=(0,l.getAccountKeyringType)(a,n);!function(e,t,a,n){d(e),u(e,a,n),m(e,t)}(k,t,T,y);const x={from:a,...w[0].params,type:s.TransactionEnvelopeType.feeMarket},_={method:c.MessageType.SendTransaction,params:[x],origin:h};b(_,t);const v=f(k),E=function(){const e=(0,o.v4)(),t=new Uint8Array((0,o.parse)(e));return(0,i.bytesToHex)(t)}();return await e(x,{batchId:E,networkClientId:r,origin:h,requestId:p,requiredAssets:v,securityAlertResponse:{securityAlertId:g}}),E}({addTransaction:p,chainId:S,from:P,messenger:t,networkClientId:_,origin:v,requestId:A,securityAlertId:C,sendCalls:a,transactions:E,validateSecurity:j,isAuxiliaryFundsSupported:y}):await async function({addTransactionBatch:e,isAtomicBatchSupported:t,chainId:a,from:s,getDismissSmartAccountSuggestionEnabled:i,networkClientId:r,messenger:o,origin:h,requestId:p,sendCalls:g,securityAlertId:k,transactions:w,validateSecurity:b,isAuxiliaryFundsSupported:y}){const T=await t({address:s,chainIds:[a]}),x=T?.[0],_=(0,l.getAccountKeyringType)(s,o),v=i();!function(e,t,a,s,i,r){d(e),function(e,t,a){if(m(e,t),!a)throw new n.JsonRpcError(c.EIP5792ErrorCode.UnsupportedChainId,`EIP-7702 not supported on chain: ${t}`)}(e,t,s),u(e,i,r),function(e,t,a){if(t?.delegationAddress)return;if(e)throw new n.JsonRpcError(c.EIP5792ErrorCode.RejectedUpgrade,"EIP-7702 upgrade disabled by the user");if(!c.KEYRING_TYPES_SUPPORTING_7702.includes(a))throw new n.JsonRpcError(c.EIP5792ErrorCode.RejectedUpgrade,"EIP-7702 upgrade not supported on account")}(a,s,i)}(g,a,v,x,_,y);const E=f(g),S=await e({from:s,networkClientId:r,origin:h,requestId:p,requiredAssets:E,securityAlertId:k,transactions:w,validateSecurity:b});return S.batchId}({addTransactionBatch:h,isAtomicBatchSupported:k,chainId:S,from:P,getDismissSmartAccountSuggestionEnabled:g,messenger:t,networkClientId:_,origin:v,requestId:A,sendCalls:a,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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.walletGetCapabilities=a.walletGetCallsStatus=a.walletSendCalls=a.getCapabilities=a.getCallsStatus=a.processSendCalls=void 0;var n=e("./hooks/processSendCalls.cjs");Object.defineProperty(a,"processSendCalls",{enumerable:!0,get:function(){return n.processSendCalls}});var s=e("./hooks/getCallsStatus.cjs");Object.defineProperty(a,"getCallsStatus",{enumerable:!0,get:function(){return s.getCallsStatus}});var i=e("./hooks/getCapabilities.cjs");Object.defineProperty(a,"getCapabilities",{enumerable:!0,get:function(){return i.getCapabilities}});var r=e("./methods/wallet_sendCalls.cjs");Object.defineProperty(a,"walletSendCalls",{enumerable:!0,get:function(){return r.walletSendCalls}});var o=e("./methods/wallet_getCallsStatus.cjs");Object.defineProperty(a,"walletGetCallsStatus",{enumerable:!0,get:function(){return o.walletGetCallsStatus}});var c=e("./methods/wallet_getCapabilities.cjs");Object.defineProperty(a,"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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.walletGetCallsStatus=void 0;const n=e("@metamask/rpc-errors"),s=e("../types.cjs"),i=e("../utils.cjs");a.walletGetCallsStatus=async function(e,t,{getCallsStatus:a}){if(!a)throw n.rpcErrors.methodNotSupported();(0,i.validateParams)(e.params,s.GetCallsStatusStruct);const r=e.params[0];t.result=await a(r,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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.walletGetCapabilities=void 0;const n=e("@metamask/rpc-errors"),s=e("../types.cjs"),i=e("../utils.cjs");a.walletGetCapabilities=async function(e,t,{getPermittedAccountsForOrigin:a,getCapabilities:r}){if(!r)throw n.rpcErrors.methodNotSupported();(0,i.validateParams)(e.params,s.GetCapabilitiesStruct);const o=e.params[0],c=e.params[1];await(0,i.validateAndNormalizeKeyholder)(o,{getPermittedAccountsForOrigin:a});const l=await r(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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.walletSendCalls=void 0;const n=e("@metamask/rpc-errors"),s=e("../types.cjs"),i=e("../utils.cjs");a.walletSendCalls=async function(e,t,{getPermittedAccountsForOrigin:a,processSendCalls:r}){if(!r)throw n.rpcErrors.methodNotSupported();(0,i.validateParams)(e.params,s.SendCallsStruct);const o=e.params[0],c=o.from?await(0,i.validateAndNormalizeKeyholder)(o.from,{getPermittedAccountsForOrigin:a}):undefined,l={...o,from:c};t.result=await r(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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.SendCallsStruct=a.CapabilitiesStruct=a.GetCapabilitiesStruct=a.GetCallsStatusStruct=void 0;const n=e("@metamask/superstruct"),s=e("@metamask/utils");a.GetCallsStatusStruct=(0,n.tuple)([s.StrictHexStruct]),a.GetCapabilitiesStruct=(0,n.tuple)([s.HexChecksumAddressStruct,(0,n.optional)((0,n.array)(s.StrictHexStruct))]);const i=(0,n.type)({address:(0,n.nonempty)(s.HexChecksumAddressStruct),amount:(0,n.nonempty)(s.StrictHexStruct),standard:(0,n.nonempty)((0,n.string)())});a.CapabilitiesStruct=(0,n.record)((0,n.string)(),(0,n.type)({optional:(0,n.optional)((0,n.boolean)()),requiredAssets:(0,n.optional)((0,n.array)(i))})),a.SendCallsStruct=(0,n.tuple)([(0,n.object)({version:(0,n.nonempty)((0,n.string)()),id:(0,n.optional)(s.StrictHexStruct),from:(0,n.optional)(s.HexChecksumAddressStruct),chainId:s.StrictHexStruct,atomicRequired:(0,n.boolean)(),calls:(0,n.array)((0,n.object)({to:(0,n.optional)(s.HexChecksumAddressStruct),data:(0,n.optional)(s.StrictHexStruct),value:(0,n.optional)(s.StrictHexStruct),capabilities:(0,n.optional)(a.CapabilitiesStruct)})),capabilities:(0,n.optional)(a.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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.resemblesAddress=a.validateParams=a.validateAndNormalizeKeyholder=a.getAccountKeyringType=void 0;const n=e("@metamask/rpc-errors"),s=e("@metamask/superstruct"),i=e("./constants.cjs");function r(e){return 42===e.length}a.getAccountKeyringType=function(e,t){const{accounts:a}=t.call("AccountsController:getState").internalAccounts,s=Object.values(a).find(t=>t.address.toLowerCase()===e.toLowerCase()),r=s?.metadata?.keyring?.type;if(!r)throw new n.JsonRpcError(i.EIP5792ErrorCode.RejectedUpgrade,"EIP-7702 upgrade not supported as account type is unknown");return r},a.validateAndNormalizeKeyholder=async function(e,{getPermittedAccountsForOrigin:t}){if("string"==typeof e&&e.length>0&&r(e)){const a=(await t()).map(e=>e.toLowerCase()),s=e.toLowerCase();if(a.includes(s))return s;throw n.providerErrors.unauthorized()}throw n.rpcErrors.invalidParams({message:"Invalid parameters: must provide an Ethereum address."})},a.validateParams=function(e,t){const[a]=(0,s.validate)(e,t);if(a)throw n.rpcErrors.invalidParams(function(e,t){return`${t}\n\n${e.failures().map(e=>`${e.path.join(" > ")}${e.path.length?" - ":""}${e.message}`).join("\n")}`}(a,"Invalid params"))},a.resemblesAddress=r}}},{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/transaction-controller/dist/TransactionController.cjs",{"./gas-flows/DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","./gas-flows/LineaGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.cjs","./gas-flows/OptimismLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs","./gas-flows/RandomisedEstimationsGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs","./gas-flows/ScrollLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs","./gas-flows/TestGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/TestGasFeeFlow.cjs","./helpers/AccountsApiRemoteTransactionSource.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs","./helpers/GasFeePoller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs","./helpers/IncomingTransactionHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.cjs","./helpers/MethodDataHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/MethodDataHelper.cjs","./helpers/MultichainTrackingHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.cjs","./helpers/PendingTransactionTracker.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.cjs","./helpers/ResimulateHelper.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/ResimulateHelper.cjs","./hooks/ExtraTransactionsPublishHook.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/ExtraTransactionsPublishHook.cjs","./logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils/balance-changes.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/balance-changes.cjs","./utils/batch.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs","./utils/eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./utils/external-transactions.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.cjs","./utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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/eip-5792-middleware/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/eip-5792-middleware/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/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs","./utils/gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs","./utils/gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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/eip-5792-middleware/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/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/nonce.cjs","./utils/prepare.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs","./utils/retry.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/retry.cjs","./utils/swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/swaps.cjs","./utils/transaction-type.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs","./utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","./utils/validation.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u,h,f,p,g,k,w,b,y,T,x,_,v,E,S,I,P,C,j,A,F,D,M,O,N,L,G,B,R,H,U,q,W,$,K,V,z,J,Y,Q,X,Z,ee,te,ae,ne,se,ie,re,oe,ce,le,de,me,ue,he,fe,pe,ge,ke,we,be,ye,Te,xe,_e,ve,Ee,Se,Ie,Pe,Ce,je,Ae,Fe,De,Me,Oe,Ne,Le,Ge,Be,Re,He,Ue,qe,We,$e,Ke,Ve,ze,Je,Ye,Qe,Xe,Ze,et,tt=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},at=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},nt=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.TransactionController=a.ApprovalState=a.SPEED_UP_RATE=a.CANCEL_RATE=void 0;const st=e("@metamask/base-controller"),it=e("@metamask/controller-utils"),rt=nt(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"),wt=e("./gas-flows/ScrollLayer1GasFeeFlow.cjs"),bt=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"),St=e("./helpers/ResimulateHelper.cjs"),It=e("./hooks/ExtraTransactionsPublishHook.cjs"),Pt=e("./logger.cjs"),Ct=e("./types.cjs"),jt=e("./utils/balance-changes.cjs"),At=e("./utils/batch.cjs"),Ft=e("./utils/eip7702.cjs"),Dt=e("./utils/external-transactions.cjs"),Mt=e("./utils/feature-flags.cjs"),Ot=e("./utils/first-time-interaction.cjs"),Nt=e("./utils/gas.cjs"),Lt=e("./utils/gas-fee-tokens.cjs"),Gt=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}};a.CANCEL_RATE=1.1,a.SPEED_UP_RATE=1.1;const Jt="TransactionController";var Yt;!function(e){e.Approved="approved",e.NotApproved="not-approved",e.SkippedViaBeforePublishHook="skipped-via-before-publish-hook"}(Yt||(a.ApprovalState=Yt={}));class Qt extends st.BaseController{constructor(e){const{disableSwaps:t,getCurrentAccountEIP1559Compatibility:a,getCurrentNetworkEIP1559Compatibility:q,getExternalPendingTransactions:W,getGasFeeEstimates:$,getNetworkClientRegistry:K,getNetworkState:z,getPermittedAccounts:J,getSavedGasFees:Y,getSimulationConfig:Q,hooks:X,incomingTransactions:ee={},isAutomaticGasFeeUpdateEnabled:te,isEIP7702GasFeeTokensEnabled:ae,isFirstTimeInteractionEnabled:ne,isSimulationEnabled:se,messenger:ie,pendingTransactions:re={},publicKeyEIP7702:oe,securityProviderRequest:ce,sign:le,state:me,testGasFeeFlows:ue,trace:he}=e;super({name:Jt,metadata:zt,messenger:ie,state:{methodData:{},transactions:[],transactionBatches:[],lastFetchedBlockNumbers:{},submitHistory:[],...me}}),n.add(this),s.set(this,void 0),i.set(this,void 0),r.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),w.set(this,void 0),b.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),S.set(this,void 0),I.set(this,void 0),P.set(this,void 0),C.set(this,void 0),j.set(this,void 0),A.set(this,void 0),F.set(this,void 0),D.set(this,void 0),M.set(this,void 0),O.set(this,void 0),N.set(this,void 0),L.set(this,void 0),G.set(this,void 0),B.set(this,new Map),R.set(this,new Set),H.set(this,void 0),U.set(this,void 0),Ie.set(this,()=>{at(this,F,"f").checkForPendingTransactionAndStartPolling()}),this.messenger=ie,tt(this,s,X?.afterAdd??(()=>Promise.resolve({})),"f"),tt(this,i,X?.afterSign??(()=>!0),"f"),tt(this,r,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,a??(()=>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,w,J,"f"),tt(this,b,Y??(e=>undefined),"f"),tt(this,y,Q??(()=>Promise.resolve({})),"f"),tt(this,x,ee,"f"),tt(this,v,te??(e=>!1),"f"),tt(this,E,ae??(()=>Promise.resolve(!1)),"f"),tt(this,S,ne??(()=>!0),"f"),tt(this,I,se??(()=>!0),"f"),tt(this,P,t??!1,"f"),tt(this,C,X?.isTimeoutEnabled??(()=>!0),"f"),tt(this,D,re,"f"),tt(this,M,oe,"f"),tt(this,O,X?.publish??(()=>Promise.resolve({transactionHash:undefined})),"f"),tt(this,N,X?.publishBatch,"f"),tt(this,L,ce,"f"),tt(this,G,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:at(this,n,"m",je).bind(this),createNonceTracker:at(this,n,"m",Ee).bind(this),createPendingTransactionTracker:at(this,n,"m",Se).bind(this),onNetworkStateChange:e=>{this.messenger.subscribe("NetworkController:stateChange",e)}}),"f"),at(this,F,"f").initialize(),tt(this,m,at(this,n,"m",Oe).call(this),"f"),tt(this,j,at(this,n,"m",Ne).call(this),"f");const pe=new Tt.GasFeePoller({findNetworkClientIdByChainId:fe,gasFeeFlows:at(this,m,"f"),getGasFeeControllerEstimates:at(this,g,"f"),getProvider:e=>at(this,n,"m",de).call(this,{networkClientId:e}),getTransactions:()=>this.state.transactions,getTransactionBatches:()=>this.state.transactionBatches,layer1GasFeeFlows:at(this,j,"f"),messenger:this.messenger,onStateChange:e=>{this.messenger.subscribe("TransactionController:stateChange",e)}});pe.hub.on("transaction-updated",at(this,n,"m",Be).bind(this)),pe.hub.on("transaction-batch-updated",at(this,n,"m",Re).bind(this)),tt(this,A,new _t.MethodDataHelper({getProvider:e=>at(this,n,"m",de).call(this,{networkClientId:e}),getState:()=>this.state.methodData}),"f"),at(this,A,"f").hub.on("update",({fourBytePrefix:e,methodData:t})=>{this.update(a=>{a.methodData[e]=t})}),tt(this,T,new xt.IncomingTransactionHelper({client:at(this,x,"f").client,getCurrentAccount:()=>at(this,n,"m",Ue).call(this),getLocalTransactions:()=>this.state.transactions,includeTokenTransfers:at(this,x,"f").includeTokenTransfers,isEnabled:at(this,x,"f").isEnabled,messenger:this.messenger,remoteTransactionSource:new yt.AccountsApiRemoteTransactionSource,trimTransactions:at(this,n,"m",Z).bind(this),updateTransactions:at(this,x,"f").updateTransactions}),"f"),at(this,n,"m",Ce).call(this,at(this,T,"f")),this.messenger.subscribe("TransactionController:stateChange",at(this,Ie,"f")),new St.ResimulateHelper({simulateTransaction:at(this,n,"m",Ge).bind(this),onTransactionsUpdate:e=>{this.messenger.subscribe("TransactionController:stateChange",e,e=>e.transactions)},getTransactions:()=>this.state.transactions}),at(this,n,"m",V).call(this),at(this,Ie,"f").call(this),at(this,n,"m",Ke).call(this)}destroy(){at(this,n,"m",Pe).call(this)}async handleMethodData(e,t){return at(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:at(this,n,"m",oe).bind(this),getEthQuery:e=>at(this,n,"m",le).call(this,{networkClientId:e}),getGasFeeEstimates:at(this,g,"f"),getInternalAccounts:at(this,n,"m",qe).bind(this),getSimulationConfig:at(this,y,"f").bind(this),getPendingTransactionTracker:e=>at(this,n,"m",Se).call(this,{provider:at(this,n,"m",de).call(this,{networkClientId:e}),blockTracker:t,chainId:at(this,n,"m",oe).call(this,e),networkClientId:e}),getTransaction:e=>at(this,n,"m",se).call(this,e),isSimulationEnabled:at(this,I,"f"),messenger:this.messenger,publishBatchHook:at(this,N,"f"),publicKeyEIP7702:at(this,M,"f"),publishTransaction:(e,t)=>at(this,n,"m",Q).call(this,e,t),request:e,signTransaction:at(this,n,"m",ye).bind(this),update:this.update.bind(this),updateTransaction:at(this,n,"m",Le).bind(this)})}async isAtomicBatchSupported(e){return(0,At.isAtomicBatchSupported)({...e,getEthQuery:e=>at(this,n,"m",le).call(this,{chainId:e}),messenger:this.messenger,publicKeyEIP7702:at(this,M,"f")})}async addTransaction(e,t){(0,Pt.projectLogger)("Adding transaction",e,t);const{actionId:a,assetsFiatValues:i,batchId:r,deviceConfirmedOn:o,disableGasBuffer:c,gasFeeToken:l,isGasFeeIncluded:d,isGasFeeSponsored:m,isStateOnly:u,method:h,nestedTransactions:f,networkClientId:p,origin:g,publishHook:k,requestId:b,requiredAssets:y,requireApproval:T,securityAlertResponse:x,skipInitialGasEstimate:_,swaps:v={},traceContext:E,type:I}=t;if(e=(0,Kt.normalizeTransactionParams)(e),!at(this,F,"f").has(p))throw new Error(`Network client not found - ${p}`);const C=at(this,n,"m",oe).call(this,p),j=at(this,n,"m",le).call(this,{networkClientId:p}),A=g===undefined?undefined:await(at(this,w,"f")?.call(this,g)),D=at(this,n,"m",qe).call(this);await(0,Vt.validateTransactionOrigin)({data:e.data,from:e.from,internalAccounts:D,origin:g,permittedAddresses:A,txParams:e,type:I});const M=(0,Ft.getDelegationAddress)(e.from,j).catch(()=>undefined),O=await at(this,n,"m",be).call(this,p);(0,Vt.validateTxParams)(e,O,C),e.type||(0,Kt.setEnvelopeType)(e,O);if(r?.length&&this.state.transactions.some(e=>e.batchId?.toLowerCase()===r?.toLowerCase())&&g&&g!==it.ORIGIN_METAMASK)throw new lt.JsonRpcError(Vt.ErrorCode.DuplicateBundleId,"Batch ID already exists");const N=at(this,n,"m",ue).call(this,e,g),G=I??(await(0,$t.determineTransactionType)(e,j)).type,B=at(this,n,"m",ge).call(this,a);let R=B?(0,ut.cloneDeep)(B):{actionId:a,assetsFiatValues:i,batchId:r,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:b,requiredAssets:y,securityAlertResponse:x,selectedGasFeeToken:l,status:Ct.TransactionStatus.unapproved,time:Date.now(),txParams:e,type:G,userEditedGasLimit:!1,verifiedOnBlockchain:!1};const{updateTransaction:H}=await at(this,s,"f").call(this,{transactionMeta:R});if(H&&((0,Pt.projectLogger)("Updating transaction using afterAdd hook"),R.txParamsOriginal=(0,ut.cloneDeep)(R.txParams),H(R)),_){const e=(0,ut.cloneDeep)(R);at(this,n,"m",K).call(this,e).then(()=>(at(this,n,"m",Le).call(this,{transactionId:e.id,skipResimulateCheck:!0,skipValidation:!0},t=>{t.txParams.gas=e.txParams.gas,t.txParams.gasPrice=e.txParams.gasPrice,t.txParams.maxFeePerGas=e.txParams.maxFeePerGas,t.txParams.maxPriorityFeePerGas=e.txParams.maxPriorityFeePerGas}),undefined)).catch(ut.noop)}else await at(this,U,"f").call(this,{name:"Estimate Gas Properties",parentContext:E},e=>at(this,n,"m",K).call(this,R,{traceContext:e}));if(!B){if(h&&at(this,L,"f")){const e=await at(this,L,"f").call(this,R,h);R.securityProviderResponse=e}R=(0,Wt.updateSwapsTransaction)(R,G,v,{isSwapsDisabled:at(this,P,"f"),cancelTransaction:at(this,n,"m",X).bind(this),messenger:this.messenger}),at(this,n,"m",$).call(this,R),M.then(e=>(at(this,n,"m",Le).call(this,{transactionId:R.id,skipResimulateCheck:!0,skipValidation:!0},t=>{t.delegationAddress=e}),undefined)).catch(ut.noop),!1===T||u?(0,Pt.projectLogger)("Skipping simulation & first interaction update as approval not required"):(at(this,n,"m",Ge).call(this,R,{traceContext:E}).catch(e=>{throw(0,Pt.projectLogger)("Error while updating simulation data",e),e}),(0,Ot.updateFirstTimeInteraction)({existingTransactions:this.state.transactions,getTransaction:e=>at(this,n,"m",ne).call(this,e),isFirstTimeInteractionEnabled:at(this,S,"f"),trace:at(this,U,"f"),traceContext:E,transactionMeta:R,updateTransaction:at(this,n,"m",Le).bind(this)}).catch(e=>{(0,Pt.projectLogger)("Error while updating first interaction properties",e)})),this.messenger.publish(`${Jt}:unapprovedTransactionAdded`,R)}return{result:at(this,n,"m",J).call(this,R,{actionId:a,isExisting:Boolean(B),publishHook:k,requireApproval:T,traceContext:E}),transactionMeta:R}}startIncomingTransactionPolling(){at(this,T,"f").start()}stopIncomingTransactionPolling(){at(this,T,"f").stop()}async updateIncomingTransactions({tags:e}={}){await at(this,T,"f").update({tags:e})}async stopTransaction(e,t,{estimatedBaseFee:s,actionId:i}={}){await at(this,n,"m",q).call(this,{actionId:i,estimatedBaseFee:s,gasValues:t,label:"cancel",rate:a.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(`${Jt}:transactionFinished`,e),at(this,_,"f").emit(`${e.id}:finished`,e)}})}async speedUpTransaction(e,t,{actionId:s,estimatedBaseFee:i}={}){await at(this,n,"m",q).call(this,{actionId:s,estimatedBaseFee:i,gasValues:t,label:"speed up",rate:a.SPEED_UP_RATE,transactionId:e,transactionType:Ct.TransactionType.retry,afterSubmit:e=>{this.messenger.publish(`${Jt}:speedupTransactionAdded`,e)}})}async estimateGas(e,t,{ignoreDelegationSignatures:a}={}){const s=at(this,n,"m",le).call(this,{networkClientId:t}),{estimatedGas:i,simulationFails:r}=await(0,Nt.estimateGas)({chainId:at(this,n,"m",oe).call(this,t),ethQuery:s,ignoreDelegationSignatures:a,isSimulationEnabled:at(this,I,"f").call(this),getSimulationConfig:at(this,y,"f"),messenger:this.messenger,txParams:e});return{gas:i,simulationFails:r}}async estimateGasBatch({chainId:e,from:t,transactions:a}){const s=at(this,n,"m",le).call(this,{chainId:e});return(0,Nt.estimateGasBatch)({chainId:e,ethQuery:s,from:t,getSimulationConfig:at(this,y,"f"),isAtomicBatchSupported:this.isAtomicBatchSupported.bind(this),messenger:this.messenger,transactions:a})}async estimateGasBuffered(e,t,a){const s=at(this,n,"m",le).call(this,{networkClientId:a}),{blockGasLimit:i,estimatedGas:r,simulationFails:o}=await(0,Nt.estimateGas)({chainId:at(this,n,"m",oe).call(this,a),ethQuery:s,isSimulationEnabled:at(this,I,"f").call(this),getSimulationConfig:at(this,y,"f"),messenger:this.messenger,txParams:e});return{gas:(0,Nt.addGasBuffer)(r,i,t),simulationFails:o}}updateTransaction(e,t){const{id:a}=e;at(this,n,"m",Le).call(this,{transactionId:a},()=>({...e})),(0,Pt.projectLogger)("Transaction updated",{transactionId:a,note:t})}updateSecurityAlertResponse(e,t){if(!t)throw new Error("updateSecurityAlertResponse: securityAlertResponse should not be null");const a=at(this,n,"m",ne).call(this,e);if(!a)throw new Error("Cannot update security alert response as no transaction metadata found");const s={...a,securityAlertResponse:t};this.updateTransaction(s,`${Jt}:updatesecurityAlertResponse - securityAlertResponse updated`)}wipeTransactions({address:e,chainId:t}={}){if(!t&&!e)return void this.update(e=>{e.transactions=[]});const a=this.state.transactions.filter(({chainId:a,txParams:n,type:s})=>{if(!(!t||t===a))return!0;return!(!e||n.from?.toLowerCase()===e.toLowerCase()||s===Ct.TransactionType.incoming&&n.to?.toLowerCase()===e.toLowerCase())});this.update(e=>{e.transactions=at(this,n,"m",Z).call(this,a)})}updateTransactionSendFlowHistory(e,t,a){return at(this,n,"m",se).call(this,e)}async confirmExternalTransaction(e,t,a){const s=at(this,n,"m",he).call(this,e);try{const e=s.id,i={...s,status:Ct.TransactionStatus.confirmed,txReceipt:t};a&&(i.baseFeePerGas=a),at(this,n,"m",fe).call(this,e),this.updateTransaction(i,`${Jt}:confirmExternalTransaction - Add external transaction`),at(this,n,"m",Te).call(this,i),at(this,n,"m",ve).call(this,i).catch(e=>{throw(0,Pt.projectLogger)("Error while updating post balance",e),e}),this.messenger.publish(`${Jt}:transactionConfirmed`,i)}catch(e){console.error("Failed to confirm external transaction",e)}}updateTransactionGasFees(e,{defaultGasEstimates:t,estimateUsed:a,estimateSuggested:s,gas:i,gasLimit:r,gasPrice:o,maxPriorityFeePerGas:c,maxFeePerGas:l,originalGasEstimate:d,userEditedGasLimit:m,userFeeLevel:u}){const h=at(this,n,"m",ne).call(this,e);if(!h)throw new Error("Cannot update transaction as no transaction metadata found");(0,Kt.validateIfTransactionUnapprovedOrSubmitted)(h,"updateTransactionGasFees");const f=(0,ut.cloneDeep)(h),p=h.gasFeeEstimates,g=at(this,v,"f").call(this,h),k=u,w=Object.values(Ct.GasFeeEstimateLevel).includes(k),b=p&&g&&w;b&&(0,Tt.updateTransactionGasEstimates)({txMeta:f,userFeeLevel:k});const y={gas:i,gasLimit:r};b?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:a,estimateSuggested:s,originalGasEstimate:d,userEditedGasLimit:m,userFeeLevel:k},x=(0,ut.pickBy)(T);return at(this,n,"m",Le).call(this,{transactionId:e,skipResimulateCheck:!0},e=>{const{txParams:t,...a}=x;Object.assign(e,a),t&&Object.assign(e.txParams,t)}),at(this,n,"m",ne).call(this,e)}updatePreviousGasParams(e,{gasLimit:t,maxFeePerGas:a,maxPriorityFeePerGas:s}){const i=at(this,n,"m",ne).call(this,e);if(!i)throw new Error("Cannot update transaction as no transaction metadata found");(0,Kt.validateIfTransactionUnapprovedOrSubmitted)(i,"updatePreviousGasParams");const r={previousGas:{gasLimit:t,maxFeePerGas:a,maxPriorityFeePerGas:s}};r.previousGas=(0,ut.pickBy)(r.previousGas);const o=(0,ut.merge)({},i,r);return this.updateTransaction(o,`${Jt}:updatePreviousGasParams - Previous gas values updated`),at(this,n,"m",ne).call(this,e)}async getNonceLock(e,t){return at(this,F,"f").getNonceLock(e,t)}async updateEditableParams(e,{containerTypes:t,data:a,from:s,gas:i,gasPrice:r,maxFeePerGas:o,maxPriorityFeePerGas:c,to:l,updateType:d,value:m}){const u=at(this,n,"m",ne).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:a,from:s,to:l,value:m,gas:i,gasPrice:r,maxFeePerGas:o,maxPriorityFeePerGas:c}};h.txParams=(0,ut.pickBy)(h.txParams);const f=(0,ut.merge)({},u,h),{networkClientId:p}=u,g=at(this,n,"m",de).call(this,{networkClientId:p}),k=new rt.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:at(this,j,"f"),messenger:this.messenger,provider:g,transactionMeta:f}),this.updateTransaction(f,`Update Editable Params for ${e}`),at(this,n,"m",ne).call(this,e)}setTransactionActive(e,t){if(!at(this,n,"m",ne).call(this,e))throw new Error(`Transaction with id ${e} not found`);at(this,n,"m",Le).call(this,{transactionId:e,skipValidation:!0,skipResimulateCheck:!0},e=>{e.isActive=t})}async approveTransactionsWithSameNonce(e=[],{hasNonce:t}={}){if((0,Pt.projectLogger)("Approving transactions with same nonce",{transactions:e}),0===e.length)return"";const a=e[0],{chainId:s}=a,i=at(this,n,"m",ce).call(this,{chainId:s}),r=(0,Ut.prepareTransaction)(s,a),c=(0,Ut.serializeTransaction)(r);if(at(this,o,"f").has(c))return"";let l,d;at(this,o,"f").add(c);try{const s=a.from;d=!0!==t?await this.getNonceLock(s,i):undefined;const r=d?(0,dt.add0x)(d.nextNonce.toString(16)):a.nonce;d&&(0,Pt.projectLogger)("Using nonce from nonce tracker",r,d.nonceDetails),l=await Promise.all(e.map(e=>(e.nonce=r,at(this,n,"m",W).call(this,e.chainId,e))))}catch(e){throw(0,Pt.projectLogger)("Error while signing transactions with same nonce",e),e}finally{d?.releaseLock(),at(this,o,"f").delete(c)}return l}updateCustodialTransaction(e){const{transactionId:t,errorMessage:a,hash:s,status:i,gasLimit:r,gasPrice:o,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:d,type:m}=e,u=at(this,n,"m",ne).call(this,t);if(!u)throw new Error("Cannot update custodial transaction as no transaction metadata found");if(i&&![Ct.TransactionStatus.submitted,Ct.TransactionStatus.signed,Ct.TransactionStatus.failed].includes(i))throw new Error(`Cannot update custodial transaction with status: ${i}`);const h=(0,ut.merge)({},u,(0,ut.pickBy)({hash:s,status:i}));return h.status===Ct.TransactionStatus.submitted&&(h.submittedTime=(new Date).getTime()),h.status===Ct.TransactionStatus.failed&&(h.error=(0,Kt.normalizeTxError)(new Error(a))),h.txParams=(0,ut.merge)({},h.txParams,(0,ut.pickBy)({gasLimit:r,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,`${Jt}:updateCustodialTransaction - Custodial transaction updated`),i&&[Ct.TransactionStatus.submitted,Ct.TransactionStatus.failed].includes(i)&&(this.messenger.publish(`${Jt}:transactionFinished`,h),at(this,_,"f").emit(`${h.id}:finished`,h)),h}getTransactions({initialList:e,limit:t,searchCriteria:a={}}={}){const n=(0,ut.mapValues)(a,e=>"function"==typeof e?e:t=>t===e),s=e??this.state.transactions,i=(0,ut.sortBy)((0,ut.pickBy)(s,e=>{for(const[t,a]of Object.entries(n))if(t in e.txParams){if(!1===a(e.txParams[t]))return!1}else if(!1===a(e[t]))return!1;return!0}),"time");if(t!==undefined){const e=new Set,a=[];for(let n=i.length-1;n>-1;n--){const s=i[n],{nonce:r}=s.txParams;if(!e.has(r)){if(!(e.size<t))continue;e.add(r)}a.unshift(s)}return a}return i}async estimateGasFee({transactionParams:e,chainId:t,networkClientId:a}){const{id:n,provider:s}=at(this,F,"f").getNetworkClient({chainId:t,networkClientId:a}),i={txParams:e,chainId:t,networkClientId:n},r=(0,Bt.getGasFeeFlow)(i,at(this,m,"f"),this.messenger),o=new rt.default(s),c=await at(this,g,"f").call(this,{networkClientId:n});return r.getGasFees({ethQuery:o,gasFeeControllerData:c,messenger:this.messenger,transactionMeta:i})}async getLayer1GasFee({transactionParams:e,chainId:t,networkClientId:a}){const s=at(this,n,"m",de).call(this,{chainId:t,networkClientId:a});return await(0,Rt.getTransactionLayer1GasFee)({layer1GasFeeFlows:at(this,j,"f"),messenger:this.messenger,provider:s,transactionMeta:{txParams:e,chainId:t}})}clearUnapprovedTransactions(){const e=this.state.transactions.filter(({status:e})=>e!==Ct.TransactionStatus.unapproved);this.update(t=>{t.transactions=at(this,n,"m",Z).call(this,e)})}abortTransactionSigning(e){if(!at(this,n,"m",ne).call(this,e))throw new Error("Cannot abort signing as no transaction metadata found");const t=at(this,B,"f").get(e);if(!t)throw new Error("Cannot abort signing as transaction is not waiting for signing");t(),at(this,B,"f").delete(e)}async updateAtomicBatchData({transactionId:e,transactionIndex:t,transactionData:a}){(0,Pt.projectLogger)("Updating atomic batch data",{transactionId:e,transactionIndex:t,transactionData:a});const s=at(this,n,"m",Le).call(this,{transactionId:e},e=>{const{nestedTransactions:n,txParams:s}=e,i=s.from,r=n?.[t];if(!r)throw new Error(`Nested transaction not found with index - ${t}`);r.data=a;const o=(0,Ft.generateEIP7702BatchTransaction)(i,n);e.txParams.data=o.data}),i=(0,ut.cloneDeep)({...s,txParams:{...s.txParams,gas:undefined}});return await at(this,n,"m",$e).call(this,i),at(this,n,"m",Le).call(this,{transactionId:e},e=>{e.txParams.gas=i.txParams.gas,e.simulationFails=i.simulationFails,e.gasLimitNoBuffer=i.gasLimitNoBuffer}),s.txParams.data}updateBatchTransactions({transactionId:e,batchTransactions:t}){(0,Pt.projectLogger)("Updating batch transactions",{transactionId:e,batchTransactions:t}),at(this,n,"m",Le).call(this,{transactionId:e},e=>{e.batchTransactions=t})}updateSelectedGasFeeToken(e,t){at(this,n,"m",Le).call(this,{transactionId:e},e=>{const a=e.gasFeeTokens?.some(e=>e.tokenAddress.toLowerCase()===t?.toLowerCase());if(t&&!a)throw new Error(`No matching gas fee token found with address - ${t}`);e.selectedGasFeeToken=t})}updateRequiredTransactionIds({transactionId:e,requiredTransactionIds:t,append:a}){at(this,n,"m",Le).call(this,{transactionId:e},e=>{const{requiredTransactionIds:n}=e;e.requiredTransactionIds=[...n&&!1!==a?n:[],...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})}}a.TransactionController=Qt,s=new WeakMap,i=new WeakMap,r=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,w=new WeakMap,b=new WeakMap,y=new WeakMap,T=new WeakMap,x=new WeakMap,_=new WeakMap,v=new WeakMap,E=new WeakMap,S=new WeakMap,I=new WeakMap,P=new WeakMap,C=new WeakMap,j=new WeakMap,A=new WeakMap,F=new WeakMap,D=new WeakMap,M=new WeakMap,O=new WeakMap,N=new WeakMap,L=new WeakMap,G=new WeakMap,B=new WeakMap,R=new WeakMap,H=new WeakMap,U=new WeakMap,Ie=new WeakMap,n=new WeakSet,q=async function({actionId:e,afterSubmit:t,estimatedBaseFee:a,gasValues:s,label:i,prepareTransactionParams:r,rate:o,transactionId:c,transactionType:l}){if(at(this,n,"m",ge).call(this,e))return;s&&(s=(0,Kt.normalizeGasFeeValues)(s),(0,Kt.validateGasValues)(s)),(0,Pt.projectLogger)(`Creating ${i} transaction`,c,s);const d=at(this,n,"m",ne).call(this,c);if(!d)return;if(!at(this,G,"f"))throw new Error("No sign method defined.");const m=(0,qt.getTransactionParamsWithIncreasedGasFee)(d.txParams,o,s);r?.(m);const u=(0,Ut.prepareTransaction)(d.chainId,m),h=await at(this,G,"f").call(this,u,d.txParams.from),f=at(this,n,"m",we).call(this,d,h),p=(0,Ut.serializeTransaction)(h),g=m.maxFeePerGas??m.gasPrice,k=m.maxFeePerGas?f.txParams.maxFeePerGas:f.txParams.gasPrice;(0,Pt.projectLogger)(`Submitting ${i} transaction`,{oldFee:k,newFee:g,txParams:m});const{networkClientId:w}=d,b=at(this,n,"m",le).call(this,{networkClientId:w}),y={...f,actionId:e,estimatedBaseFee:a,id:(0,ht.v1)(),originalGasEstimate:d.txParams.gas,originalType:d.type,rawTx:p,time:Date.now(),txParams:m,type:l},T=await at(this,n,"m",De).call(this,b,{...y,origin:i});y.hash=T,at(this,n,"m",$).call(this,y),this.messenger.publish(`${Jt}:transactionApproved`,{transactionMeta:y,actionId:e}),this.messenger.publish(`${Jt}:transactionSubmitted`,{transactionMeta:y,actionId:e}),t?.(y)},W=async function(e,t){if(!at(this,G,"f"))throw new Error("No sign method defined.");const a=(0,Kt.normalizeTransactionParams)(t),n=(0,Kt.isEIP1559Transaction)(a)?Ct.TransactionEnvelopeType.feeMarket:Ct.TransactionEnvelopeType.legacy,s={...a,type:n,gasLimit:a.gas,chainId:e},{from:i}=s,r=(0,Ut.prepareTransaction)(e,s),o=await at(this,G,"f").call(this,r,i);return(0,Ut.serializeTransaction)(o)},$=function(e){(0,Vt.validateTxParams)(e.txParams),this.update(t=>{t.transactions=at(this,n,"m",Z).call(this,[...t.transactions,e])})},K=async function(e,{traceContext:t}={}){const a=e.txParams.type!==Ct.TransactionEnvelopeType.legacy&&await at(this,n,"m",be).call(this,e.networkClientId),{networkClientId:s}=e,i=at(this,n,"m",le).call(this,{networkClientId:s}),r=at(this,n,"m",de).call(this,{networkClientId:s});await at(this,U,"f").call(this,{name:"Update Gas",parentContext:t},async()=>{await at(this,n,"m",$e).call(this,e)}),await at(this,U,"f").call(this,{name:"Update Gas Fees",parentContext:t},async()=>await(0,Gt.updateGasFees)({eip1559:a,ethQuery:i,gasFeeFlows:at(this,m,"f"),getGasFeeEstimates:at(this,g,"f"),getSavedGasFees:at(this,b,"f").bind(this),messenger:this.messenger,txMeta:e})),await at(this,U,"f").call(this,{name:"Update Layer 1 Gas Fees",parentContext:t},async()=>await(0,Rt.updateTransactionLayer1GasFee)({layer1GasFeeFlows:at(this,j,"f"),messenger:this.messenger,provider:r,transactionMeta:e}))},V=function(){this.clearUnapprovedTransactions(),at(this,n,"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){const e=t.requiredTransactionIds??[],a=e.length>0&&e.every(e=>{const t=at(this,n,"m",ne).call(this,e);return t?.status===Ct.TransactionStatus.confirmed})?"Transaction incomplete at startup with all required transactions confirmed":"Transaction incomplete at startup";at(this,n,"m",Ye).call(this,t,new Error(a));for(const t of e){const e=at(this,n,"m",ne).call(this,t);e&&!at(this,n,"m",ee).call(this,e.status)&&at(this,n,"m",Ye).call(this,e,new Error("Parent transaction incomplete at startup"))}}},J=async function(e,{actionId:t,isExisting:a=!1,publishHook:s,requireApproval:i,shouldShowRequest:r=!0,traceContext:o}){const{id:c,isStateOnly:l}=e;if(l)return at(this,n,"m",Le).call(this,{transactionId:c,skipValidation:!0},e=>{e.status=Ct.TransactionStatus.submitted,e.submittedTime=(new Date).getTime()}),"";let d;const{meta:m,isCompleted:u}=at(this,n,"m",re).call(this,c),h=u?Promise.resolve(m):at(this,n,"m",ke).call(this,c);if(m&&!a&&!u)try{if(!1!==i){const t=await at(this,U,"f").call(this,{name:"Await Approval",parentContext:o},t=>at(this,n,"m",ae).call(this,e,{shouldShowRequest:r,traceContext:t}));d=t.resultCallbacks;const a=t.value,s=a?.txMeta;s&&((0,Pt.projectLogger)("Updating transaction with approval data",{customNonce:s.customNonceValue,params:s.txParams}),this.updateTransaction(s,"TransactionController#processApproval - Updated with approval data"))}const{isCompleted:a}=at(this,n,"m",re).call(this,c);if(!a){const e=await at(this,n,"m",Y).call(this,c,o,s);e===Yt.SkippedViaBeforePublishHook&&d&&d.success();const a=at(this,n,"m",ne).call(this,c);e===Yt.Approved&&this.messenger.publish(`${Jt}:transactionApproved`,{transactionMeta:a,actionId:t})}}catch(e){const a=e,{isCompleted:s}=at(this,n,"m",re).call(this,c);s||(at(this,n,"m",ze).call(this,a)?at(this,n,"m",Je).call(this,c,t,a):at(this,n,"m",Ye).call(this,m,a,t))}finally{at(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}}},Y=async function(e,t,a){let s,i,r=at(this,n,"m",se).call(this,e);(0,Pt.projectLogger)("Approving transaction",r);try{if(!at(this,G,"f"))return at(this,n,"m",Ye).call(this,r,new Error("No sign method defined.")),Yt.NotApproved;if(!r.chainId)return at(this,n,"m",Ye).call(this,r,new Error("No chainId defined.")),Yt.NotApproved;if(at(this,o,"f").has(e))return(0,Pt.projectLogger)("Skipping approval as signing in progress",e),Yt.NotApproved;at(this,o,"f").add(e),s=()=>at(this,o,"f").delete(e);const{networkClientId:c}=r,d=at(this,n,"m",le).call(this,{networkClientId:c}),[m,u]=await(0,Ht.getNextNonce)(r,e=>at(this,F,"f").getNonceLock(e,r.networkClientId));i=u,r=at(this,n,"m",Le).call(this,{transactionId:e},e=>{const{chainId:t,txParams:a}=e,{gas:n,type:s}=a;e.status=Ct.TransactionStatus.approved,e.txParams.chainId=t,e.txParams.gasLimit=n,e.txParams.nonce=m,!s&&(0,Kt.isEIP1559Transaction)(a)&&(e.txParams.type=Ct.TransactionEnvelopeType.feeMarket)}),at(this,n,"m",Te).call(this,r);const h=await at(this,U,"f").call(this,{name:"Sign",parentContext:t},()=>at(this,n,"m",ye).call(this,r));if(r=at(this,n,"m",se).call(this,e),!await at(this,l,"f").call(this,r))return(0,Pt.projectLogger)("Skipping publishing transaction based on hook"),this.messenger.publish(`${Jt}:transactionPublishingSkipped`,r),Yt.SkippedViaBeforePublishHook;if(!h&&!r.isExternalSign)return Yt.NotApproved;let f;const p=r.type===Ct.TransactionType.swap;p&&((0,Pt.projectLogger)("Determining pre-transaction balance"),f=await(0,it.query)(d,"getBalance",[r.txParams.from])),(0,Pt.projectLogger)("Publishing transaction",r.txParams),i?.(),i=undefined;let g=at(this,n,"m",Xe).bind(this,{ethQuery:d,publishHookOverride:a,traceContext:t});if(r.batchTransactions?.length){(0,Pt.projectLogger)("Found batch transactions",r.batchTransactions);g=new It.ExtraTransactionsPublishHook({addTransactionBatch:this.addTransactionBatch.bind(this),getTransaction:at(this,n,"m",se).bind(this),originalPublishHook:g}).getHook()}const{transactionHash:k}=await g(r,h??"0x");return r=at(this,n,"m",Le).call(this,{transactionId:e},e=>{e.hash=k,e.status=Ct.TransactionStatus.submitted,e.submittedTime=(new Date).getTime(),p&&(e.preTxBalance=f,(0,Pt.projectLogger)("Updated pre-transaction balance",f))}),this.messenger.publish(`${Jt}:transactionSubmitted`,{transactionMeta:r}),this.messenger.publish(`${Jt}:transactionFinished`,r),at(this,_,"f").emit(`${e}:finished`,r),at(this,n,"m",Te).call(this,r),Yt.Approved}catch(e){return at(this,n,"m",Ye).call(this,r,e),Yt.NotApproved}finally{s?.(),i?.()}},Q=async function(e,t,{skipSubmitHistory:a}={}){try{const s=await(0,it.query)(e,"sendRawTransaction",[t.rawTx]);return!0!==a&&at(this,n,"m",We).call(this,t,s),s}catch(e){const t=e,a=t?.data?.message??t?.message??String(e);throw new Error(a)}},X=function(e,t,a){const s=at(this,n,"m",ne).call(this,e);if(!s)return;at(this,n,"m",Ve).call(this,e);const i={...s,status:Ct.TransactionStatus.rejected,error:(0,Kt.normalizeTxError)(a??lt.providerErrors.userRejectedRequest())};this.messenger.publish(`${Jt}:transactionFinished`,i),at(this,_,"f").emit(`${s.id}:finished`,i),this.messenger.publish(`${Jt}:transactionRejected`,{transactionMeta:i,actionId:t}),at(this,n,"m",Te).call(this,i)},Z=function(e){const t=new Set,a=(0,Mt.getTransactionHistoryLimit)(this.messenger),s=[...e].sort((e,t)=>e.time>t.time?-1:1).filter(e=>{const{chainId:s,status:i,txParams:r,time:o}=e;if(r){const e=`${String(r.nonce)}-${(0,it.convertHexToDecimal)(s)}-${new Date(o).toDateString()}`;if(t.has(e))return!0;if(t.size<a||!at(this,n,"m",ee).call(this,i))return t.add(e),!0}return!1});return s.reverse(),s},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)},ae=async function(e,{shouldShowRequest:t,traceContext:a}){const s=at(this,n,"m",ie).call(this,e),{origin:i}=e,r=it.ApprovalType.Transaction,o={txId:e.id};return await at(this,U,"f").call(this,{name:"Notification Display",id:s,parentContext:a}),await this.messenger.call("ApprovalController:addRequest",{id:s,origin:i??it.ORIGIN_METAMASK,type:r,requestData:o,expectsResult:!0},t)},ne=function(e){const{transactions:t}=this.state;return t.find(({id:t})=>t===e)},se=function(e,t="TransactionController"){const a=at(this,n,"m",ne).call(this,e);if(!a)throw new Error(`${t}: No transaction found with id ${e}`);return a},ie=function(e){return String(e.id)},re=function(e){const t=at(this,n,"m",ne).call(this,e);if(!t)return{meta:undefined,isCompleted:!1};return{meta:t,isCompleted:at(this,n,"m",te).call(this,t.status)}},oe=function(e){return at(this,F,"f").getNetworkClient({networkClientId:e}).configuration.chainId},ce=function({chainId:e,networkClientId:t}){return t||at(this,F,"f").getNetworkClient({chainId:e}).id},le=function({chainId:e,networkClientId:t}){return new rt.default(at(this,n,"m",de).call(this,{chainId:e,networkClientId:t}))},de=function({chainId:e,networkClientId:t}){return at(this,F,"f").getNetworkClient({chainId:e,networkClientId:t}).provider},me=function(e){if(!e.length)return;const t=[];for(const a of e){const{chainId:e}=a;try{const s=at(this,n,"m",ce).call(this,{chainId:e});t.push({...a,networkClientId:s})}catch(t){(0,Pt.projectLogger)("Failed to get network client ID for incoming transaction",{chainId:e,error:t})}}this.update(e=>{const{transactions:a}=e;e.transactions=at(this,n,"m",Z).call(this,[...t,...a]),(0,Pt.projectLogger)("Added incoming transactions to state",t.length,t)}),this.messenger.publish(`${Jt}:incomingTransactionsReceived`,t)},ue=function(e,t){if(!t||t===it.ORIGIN_METAMASK)return undefined;const{gasPrice:a,maxFeePerGas:n,maxPriorityFeePerGas:s,gas:i}=e;if(a===undefined&&n===undefined&&s===undefined&&i===undefined)return undefined;const r={};return a!==undefined?r.gasPrice=a:n===undefined&&s===undefined||(r.maxFeePerGas=n,r.maxPriorityFeePerGas=s),i!==undefined&&(r.gas=i),r},he=function(e){const{chainId:t}=e,{transactions:a}=this.state,s=e?.txParams?.from,i=a.filter(e=>e.txParams.from===s&&e.chainId===t),r=i.filter(e=>e.status===Ct.TransactionStatus.confirmed),o=i.filter(e=>e.status===Ct.TransactionStatus.submitted);return(0,Dt.validateConfirmedExternalTransaction)(e,r,o),this.update(t=>{t.transactions=at(this,n,"m",Z).call(this,[...t.transactions,e])}),e},fe=function(e){const t=at(this,n,"m",ne).call(this,e);if(!t)return;const a=t.txParams?.nonce,s=t.txParams?.from,{chainId:i}=t,r=this.state.transactions.filter(t=>t.id!==e&&t.txParams.from===s&&a&&t.txParams.nonce===a&&t.chainId===i&&t.type!==Ct.TransactionType.incoming&&t.isTransfer===undefined),o=r.map(e=>e.id);if(0!==r.length){this.update(e=>{for(const a of e.transactions)o.includes(a.id)&&(a.replacedBy=t?.hash,a.replacedById=t?.id)});for(const e of this.state.transactions)o.includes(e.id)&&e.status!==Ct.TransactionStatus.failed&&at(this,n,"m",pe).call(this,e)}},pe=function(e){const t={...e,status:Ct.TransactionStatus.dropped};this.messenger.publish(`${Jt}:transactionDropped`,{transactionMeta:t}),this.updateTransaction(t,"TransactionController#setTransactionStatusDropped - Transaction dropped"),at(this,n,"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=>{at(this,_,"f").once(`${e}:finished`,e=>{t(e)})})},we=function(e,t){const a=(0,ut.cloneDeep)(e);for(const e of["r","s","v"]){const n=t[e];n!==undefined&&null!==n&&(a[e]=(0,dt.add0x)(n.toString(16)))}return a},be=async function(e){const t=await at(this,f,"f").call(this,e),a=await at(this,h,"f").call(this);return t&&a},ye=async function(e){let t=e;const{id:a}=t;(0,Pt.projectLogger)("Calling before sign hook",t);const{updateTransaction:s}=await at(this,d,"f").call(this,{transactionMeta:t})??{};s&&(at(this,n,"m",Le).call(this,{transactionId:a,skipResimulateCheck:!0},s),(0,Pt.projectLogger)("Updated transaction after before sign hook")),t=at(this,n,"m",se).call(this,a);const{networkClientId:r}=t,c=at(this,n,"m",le).call(this,{networkClientId:r});await(0,Lt.checkGasFeeTokenBeforePublish)({ethQuery:c,fetchGasFeeTokens:async e=>(await at(this,n,"m",Ze).call(this,e)).gasFeeTokens,transaction:t,updateTransaction:(e,t)=>at(this,n,"m",Le).call(this,{transactionId:e},t)}),t=at(this,n,"m",se).call(this,a);const{chainId:l,isExternalSign:m,txParams:h}=t;if(m)return(0,Pt.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&&at(this,n,"m",Le).call(this,{transactionId:a},e=>{e.txParams.authorizationList=g}),t=at(this,n,"m",se).call(this,a);const k=at(this,n,"m",se).call(this,a),{txParams:w}=k,b=(0,Ut.prepareTransaction)(l,w);at(this,o,"f").add(a),(0,Pt.projectLogger)("Signing transaction",w);const y=await new Promise((e,t)=>{at(this,G,"f")?.call(this,b,p,...at(this,u,"f").call(this,k)).then(e,t),at(this,B,"f").set(a,()=>t(new Error("Signing aborted by user")))});if(at(this,B,"f").delete(a),!y)return(0,Pt.projectLogger)("Skipping signed status as no signed transaction"),undefined;const T=(0,ut.cloneDeep)(k);if(!at(this,i,"f").call(this,T,y))return this.updateTransaction(T,"TransactionController#signTransaction - Update after sign"),(0,Pt.projectLogger)("Skipping signed status based on hook"),undefined;const x={...at(this,n,"m",we).call(this,T,y),status:Ct.TransactionStatus.signed,txParams:w};this.updateTransaction(x,"TransactionController#approveTransaction - Transaction signed"),at(this,n,"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(`${Jt}:transactionStatusUpdated`,{transactionMeta:e})},xe=function(e,t,a){return(0,Ht.getAndFormatTransactionsForNonceTracker)(a,t,e,this.state.transactions)},_e=function(e){(0,Pt.projectLogger)("Processing confirmed transaction",e.id),at(this,n,"m",fe).call(this,e.id),this.messenger.publish(`${Jt}:transactionConfirmed`,e),at(this,n,"m",Te).call(this,e),at(this,n,"m",ve).call(this,e).catch(e=>{throw(0,Pt.projectLogger)("Error while updating post balance",e),e})},ve=async function(e){try{const{networkClientId:t,type:a}=e;if(a!==Ct.TransactionType.swap)return;const s=at(this,n,"m",le).call(this,{networkClientId:t}),{updatedTransactionMeta:i,approvalTransactionMeta:r}=await(0,Wt.updatePostTransactionBalance)(e,{ethQuery:s,getTransaction:at(this,n,"m",ne).bind(this),updateTransaction:this.updateTransaction.bind(this)});this.messenger.publish(`${Jt}:postTransactionBalanceUpdated`,{transactionMeta:i,approvalTransactionMeta:r})}catch(e){(0,Pt.projectLogger)("Error while updating post transaction balance",e)}},Ee=function({provider:e,blockTracker:t,chainId:a}){return new ct.NonceTracker({provider:e,blockTracker:t,getPendingTransactions:at(this,n,"m",Fe).bind(this,a),getConfirmedTransactions:at(this,n,"m",xe).bind(this,[Ct.TransactionStatus.confirmed],a)})},Se=function({provider:e,blockTracker:t,chainId:a,networkClientId:s}){const i=new rt.default(e),r=new Et.PendingTransactionTracker({blockTracker:t,getChainId:()=>a,getEthQuery:()=>i,getGlobalLock:()=>at(this,F,"f").acquireNonceLockForChainIdKey({chainId:a}),getNetworkClientId:()=>s,getTransactions:()=>this.state.transactions,hooks:{beforeCheckPendingTransaction:at(this,c,"f").bind(this)},isResubmitEnabled:at(this,D,"f").isResubmitEnabled,isTimeoutEnabled:at(this,C,"f"),messenger:this.messenger,publishTransaction:(e,t)=>at(this,n,"m",Q).call(this,e,t,{skipSubmitHistory:!0})});return at(this,n,"m",Ae).call(this,r),r},Pe=function(){at(this,F,"f").stopAllTracking()},Ce=function(e){e.hub.on("transactions",at(this,n,"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",at(this,n,"m",_e).bind(this)),e.hub.on("transaction-dropped",at(this,n,"m",pe).bind(this)),e.hub.on("transaction-failed",at(this,n,"m",Ye).bind(this)),e.hub.on("transaction-updated",this.updateTransaction.bind(this))},Fe=function(e,t){return[...at(this,n,"m",xe).call(this,[Ct.TransactionStatus.approved,Ct.TransactionStatus.signed,Ct.TransactionStatus.submitted],t,e),...at(this,p,"f").call(this,t,e)]},De=async function(e,t){try{return await at(this,n,"m",Q).call(this,e,t)}catch(e){if(at(this,n,"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"))},Oe=function(){return at(this,H,"f")?[new bt.TestGasFeeFlow]:[new kt.RandomisedEstimationsGasFeeFlow,new pt.LineaGasFeeFlow,new ft.DefaultGasFeeFlow]},Ne=function(){return[new gt.OptimismLayer1GasFeeFlow,new wt.ScrollLayer1GasFeeFlow]},Le=function({transactionId:e,skipValidation:t,skipResimulateCheck:a},s){let i;this.update(n=>{const r=n.transactions.findIndex(({id:t})=>t===e);if(-1===r)throw new Error(`Cannot update transaction as ID not found - ${e}`);let o=n.transactions[r];const c=(0,ut.cloneDeep)(o);o=s(o)??o,!0!==t&&(o.txParams=(0,Kt.normalizeTransactionParams)(o.txParams),(0,Vt.validateTxParams)(o.txParams)),!a&&at(this,I,"f").call(this)&&(i=(0,St.shouldResimulate)(c,o)),n.transactions[r]=o});const r=at(this,n,"m",ne).call(this,e);return i?.resimulate&&at(this,n,"m",Ge).call(this,r,{blockTime:i.blockTime}).catch(e=>{throw(0,Pt.projectLogger)("Error during re-simulation",e),e}),r},Ge=async function(e,{blockTime:t,traceContext:a}={}){const{chainId:s,id:i,nestedTransactions:r,networkClientId:o,simulationData:c,txParams:l}=e;let d,m={error:{code:Ct.SimulationErrorCode.Disabled,message:"Simulation disabled"},tokenBalanceChanges:[]},u=[],h=!1;const f=at(this,R,"f").has(i);if(at(this,I,"f").call(this)&&!f){const i=await at(this,U,"f").call(this,{name:"Simulate",parentContext:a},()=>(0,jt.getBalanceChanges)({blockTime:t,chainId:s,ethQuery:at(this,n,"m",le).call(this,{networkClientId:o}),getSimulationConfig:(t,a)=>at(this,y,"f").call(this,t,{txMeta:e,...a}),nestedTransactions:r,txParams:l}));m=i.simulationData,d=i.gasUsed,t&&c&&(0,St.hasSimulationDataChanged)(c,m)&&(m={...m,isUpdatedAfterSecurityCheck:!0});const f=await at(this,n,"m",Ze).call(this,e);u=f?.gasFeeTokens??[],h=f?.isGasFeeSponsored??!1}if(!at(this,n,"m",ne).call(this,i))return void(0,Pt.projectLogger)("Cannot update simulation data as transaction not found",i,m);const p=at(this,n,"m",Le).call(this,{transactionId:i,skipResimulateCheck:Boolean(t)},e=>{e.gasFeeTokens=u,e.isGasFeeSponsored=h,e.gasUsed=d,f||(e.simulationData=m)});(0,Pt.projectLogger)("Updated simulation data",i,p),await at(this,n,"m",Qe).call(this,p)},Be=function({transactionId:e,gasFeeEstimates:t,gasFeeEstimatesLoaded:a,layer1GasFee:s}){at(this,n,"m",Le).call(this,{transactionId:e},e=>{(0,Tt.updateTransactionGasProperties)({txMeta:e,gasFeeEstimates:t,gasFeeEstimatesLoaded:a,isTxParamsGasFeeUpdatesEnabled:at(this,v,"f"),layer1GasFee:s})})},Re=function({transactionBatchId:e,gasFeeEstimates:t}){at(this,n,"m",He).call(this,e,e=>({...e,gasFeeEstimates:t}))},He=function(e,t){this.update(a=>{const n=a.transactionBatches.findIndex(t=>t.id===e);if(-1===n)throw new Error(`Cannot update batch, ID not found - ${e}`);const s=a.transactionBatches[n],i=t(s);a.transactionBatches[n]=i??s})},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:a,networkClientId:n,origin:s,rawTx:i,txParams:r}=e,{networkConfigurationsByChainId:o}=at(this,k,"f").call(this),c=o[a],l=c?.rpcEndpoints.find(e=>e.networkClientId===n),d=l?.url,m={chainId:a,hash:t,networkType:l?.name??n,networkUrl:d,origin:s,rawTransaction:i,time:Date.now(),transaction:r};(0,Pt.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:a}=e,s=at(this,F,"f").getNetworkClient({networkClientId:a}).configuration.type===ot.NetworkClientType.Custom,i=at(this,n,"m",le).call(this,{networkClientId:a});await(0,Nt.updateGas)({chainId:t,ethQuery:i,isCustomNetwork:s,isSimulationEnabled:at(this,I,"f").call(this),getSimulationConfig:at(this,y,"f"),messenger:this.messenger,txMeta:e})},Ke=function(){this.messenger.registerActionHandler(`${Jt}:addTransaction`,this.addTransaction.bind(this)),this.messenger.registerActionHandler(`${Jt}:addTransactionBatch`,this.addTransactionBatch.bind(this)),this.messenger.registerActionHandler(`${Jt}:confirmExternalTransaction`,this.confirmExternalTransaction.bind(this)),this.messenger.registerActionHandler(`${Jt}:emulateNewTransaction`,this.emulateNewTransaction.bind(this)),this.messenger.registerActionHandler(`${Jt}:emulateTransactionUpdate`,this.emulateTransactionUpdate.bind(this)),this.messenger.registerActionHandler(`${Jt}:estimateGas`,this.estimateGas.bind(this)),this.messenger.registerActionHandler(`${Jt}:estimateGasBatch`,this.estimateGasBatch.bind(this)),this.messenger.registerActionHandler(`${Jt}:getGasFeeTokens`,at(this,n,"m",et).bind(this)),this.messenger.registerActionHandler(`${Jt}:getNonceLock`,this.getNonceLock.bind(this)),this.messenger.registerActionHandler(`${Jt}:getTransactions`,this.getTransactions.bind(this)),this.messenger.registerActionHandler(`${Jt}:updateCustodialTransaction`,this.updateCustodialTransaction.bind(this)),this.messenger.registerActionHandler(`${Jt}:updateTransaction`,this.updateTransaction.bind(this))},Ve=function(e){this.update(t=>{const a=t.transactions.filter(({id:t})=>t!==e);t.transactions=at(this,n,"m",Z).call(this,a)})},ze=function(e){return[lt.errorCodes.provider.userRejectedRequest,Vt.ErrorCode.RejectedUpgrade].includes(e.code)},Je=function(e,t,a){if(at(this,n,"m",X).call(this,e,t,a),a.code===lt.errorCodes.provider.userRejectedRequest)throw lt.providerErrors.userRejectedRequest({message:"MetaMask Tx Signature: User denied transaction signature.",data:a?.data});throw a},Ye=function(e,t,a){let s;try{s=at(this,n,"m",Le).call(this,{transactionId:e.id,skipValidation:!0},e=>{e.status=Ct.TransactionStatus.failed,e.error=(0,Kt.normalizeTxError)(t)})}catch(a){(0,Pt.projectLogger)("Failed to mark transaction as failed",a),s={...e,status:Ct.TransactionStatus.failed,error:(0,Kt.normalizeTxError)(t)}}this.messenger.publish(`${Jt}:transactionFailed`,{actionId:a,error:t.message,transactionMeta:s}),at(this,n,"m",Te).call(this,s),this.messenger.publish(`${Jt}:transactionFinished`,s),at(this,_,"f").emit(`${e.id}:finished`,s)},Qe=async function(e){(0,Pt.projectLogger)("Calling afterSimulate hook",e);const{id:t}=e,a=await at(this,r,"f").call(this,{transactionMeta:e}),{skipSimulation:s,updateTransaction:i}=a??{};if(s?at(this,R,"f").add(t):!1===s&&at(this,R,"f").delete(t),!i)return;const o=at(this,n,"m",Le).call(this,{transactionId:t,skipResimulateCheck:!0},e=>{e.txParamsOriginal=(0,ut.cloneDeep)(e.txParams),i(e)});(0,Pt.projectLogger)("Updated transaction with afterSimulate data",o)},Xe=async function({ethQuery:e,publishHookOverride:t,traceContext:a},s,i){let r;return await at(this,U,"f").call(this,{name:"Publish",parentContext:a},async()=>{const a=t??at(this,O,"f");({transactionHash:r}=await a(s,i)),r??(r=await at(this,n,"m",Q).call(this,e,{...s,rawTx:i}))}),(0,Pt.projectLogger)("Publish successful",r),{transactionHash:r}},Ze=async function(e){const{chainId:t}=e;return await(0,Lt.getGasFeeTokens)({chainId:t,getSimulationConfig:at(this,y,"f"),isEIP7702GasFeeTokensEnabled:at(this,E,"f"),messenger:this.messenger,publicKeyEIP7702:at(this,M,"f"),transactionMeta:e})},et=async function(e){const{chainId:t,data:a,from:s,to:i,value:r}=e,o=at(this,n,"m",le).call(this,{chainId:t}),c={chainId:t,delegationAddress:await(0,Ft.getDelegationAddress)(s,o),isExternalSign:!0,txParams:{data:a,from:s,to:i,value:r}};return(await at(this,n,"m",Ze).call(this,c)).gasFeeTokens}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/TransactionController.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs",{"../errors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/errors.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getAccountTransactions=a.getAccountAddressRelationship=void 0;const n=e("@metamask/controller-utils"),s=e("@metamask/utils"),i=e("../errors.cjs"),r=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,s.createModuleLogger)(r.projectLogger,"accounts-api");a.getAccountAddressRelationship=async function(e){const{chainId:t,from:a,to:s}=e;if(!m.includes(t))throw u("Unsupported chain ID for account relationship API",t),new i.FirstTimeInteractionError("Unsupported chain ID");const r=`${o}/v1/networks/${t}/accounts/${a}/relationships/${s}`;u("Getting account address relationship",{request:e,url:r});const c={[l]:d},h=await(0,n.successfulFetch)(r,{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 i.FirstTimeInteractionError(t,e)}return f},a.getAccountTransactions=async function(e){const{address:t,chainIds:a,cursor:s,endTimestamp:i,sortDirection:r,startTimestamp:o,tags:m}=e;let h=`${c}${t}/transactions`;const f=[];if(a){const e=a.join(",");f.push(`networks=${e}`)}o&&f.push(`startTimestamp=${o}`),i&&f.push(`endTimestamp=${i}`),s&&f.push(`cursor=${s}`),r&&f.push(`sortDirection=${r}`),f.length&&(h+=`?${f.join("&")}`),u("Getting account transactions",{request:e,url:h});const p=[d,...m??[]].join("__"),g={[l]:p},k=await(0,n.successfulFetch)(h,{headers:g}),w=await k.json();return u("Retrieved account transactions",w),w}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","../errors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/errors.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.simulateTransactions=void 0;const n=e("@metamask/controller-utils"),s=e("@metamask/utils"),i=e("lodash"),r=e("../constants.cjs"),o=e("../errors.cjs"),c=e("../logger.cjs"),l=(0,s.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)}a.simulateTransactions=async function(e,t){let a=await async function(e){const t=await async function(){const e=`${u("ethereum-mainnet")}${d}`,t=await fetch(e);return t.json()}(),a=(0,n.convertHexToDecimal)(e),s=t[a];if(!s?.confirmations)throw l("Chain is not supported",e),new o.SimulationChainNotSupportedError(e);return u(s.network)}(e);const{newUrl:s,authorization:c}=await t.getSimulationConfig(a)||{};s&&(a=s);const h=m;m+=1;const f=function(e){const t=(0,i.cloneDeep)(e);for(const e of t.transactions){const a=e.to?.toLowerCase();r.DELEGATION_MANAGER_ADDRESSES.includes(a)&&(t.overrides=t.overrides??{},t.overrides[a]={code:r.CODE_DELEGATION_MANAGER_NO_SIGNATURE_ERRORS})}return t}(t);l("Sending request",a,t);const p={"Content-Type":"application/json"};c&&(p.Authorization=c);const g=await fetch(a,{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/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.CODE_DELEGATION_MANAGER_NO_SIGNATURE_ERRORS=a.DELEGATION_MANAGER_ADDRESSES=a.ABI_IERC7821=a.ABI_SIMULATION_ERC721_LEGACY=a.ABI_SIMULATION_ERC20_WRAPPED=a.CHAIN_IDS=void 0,a.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"},a.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"}],a.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"}],a.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"}],a.DELEGATION_MANAGER_ADDRESSES=["0xdb9b1e94b5b69df7e401ddbede43491141047db3"],a.CODE_DELEGATION_MANAGER_NO_SIGNATURE_ERRORS=" "}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/errors.cjs",{"./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.SimulationRevertedError=a.SimulationInvalidResponseError=a.SimulationChainNotSupportedError=a.FirstTimeInteractionError=a.SimulationError=void 0;const n=e("./types.cjs");class s extends Error{constructor(e,t){super(e??"Simulation failed"),this.code=t}}a.SimulationError=s;class i extends Error{constructor(e,t){super(e??"Error checking first time interaction"),this.code=t}}a.FirstTimeInteractionError=i;a.SimulationChainNotSupportedError=class extends s{constructor(e){super(`Chain is not supported: ${e}`,n.SimulationErrorCode.ChainNotSupported)}};a.SimulationInvalidResponseError=class extends s{constructor(){super("Invalid response from simulation API",n.SimulationErrorCode.InvalidResponse)}};a.SimulationRevertedError=class extends s{constructor(){super("Transaction was reverted",n.SimulationErrorCode.Reverted)}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/errors.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/gas-fees.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs","@metamask/gas-fee-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/gas-fee-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){var n,s,i,r,o,c,l=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.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");a.DefaultGasFeeFlow=class{constructor(){n.add(this)}matchesTransaction(){return!0}async getGasFees(e){const{gasFeeControllerData:t}=e,{gasEstimateType:a,gasFeeEstimates:o}=t;let c;switch(a){case d.GAS_ESTIMATE_TYPES.FEE_MARKET:p("Using fee market estimates",o),c=l(this,n,"m",s).call(this,o);break;case d.GAS_ESTIMATE_TYPES.LEGACY:p("Using legacy estimates",o),c=l(this,n,"m",i).call(this,o);break;case d.GAS_ESTIMATE_TYPES.ETH_GASPRICE:p("Using eth_gasPrice estimates",o),c=l(this,n,"m",r).call(this,o);break;default:throw new Error(`Unsupported gas estimate type: ${a}`)}return{estimates:c}}},n=new WeakSet,s=function(e){const t=Object.values(h.GasFeeEstimateLevel).reduce((t,a)=>({...t,[a]:l(this,n,"m",o).call(this,e,a)}),{});return{type:h.GasFeeEstimateType.FeeMarket,...t}},i=function(e){const t=Object.values(h.GasFeeEstimateLevel).reduce((t,a)=>({...t,[a]:l(this,n,"m",c).call(this,e,a)}),{});return{type:h.GasFeeEstimateType.Legacy,...t}},r=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/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.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},w={low:1,medium:1.05,high:1.1};a.LineaGasFeeFlow=class{constructor(){n.add(this)}matchesTransaction({transactionMeta:e}){return g.includes(e.chainId)}async getGasFees(e){try{return await l(this,n,"m",s).call(this,e)}catch(t){return p("Using default flow as fallback due to error",t),(new u.DefaultGasFeeFlow).getGasFees(e)}}},n=new WeakSet,s=async function(e){const{ethQuery:t,transactionMeta:a}=e,s=await l(this,n,"m",i).call(this,a,t);p("Received Linea response",s);const m=l(this,n,"m",r).call(this,s.baseFeePerGas,k);p("Generated base fees",l(this,n,"m",c).call(this,m));const u=l(this,n,"m",r).call(this,s.priorityFeePerGas,w);p("Generated priority fees",l(this,n,"m",c).call(this,u));const h=l(this,n,"m",o).call(this,m,u);p("Generated max fees",l(this,n,"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})}},i=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}])},r=function(e,t){const a=(0,d.hexToBN)(e);return{low:a.muln(t.low),medium:a.muln(t.medium),high:a.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/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","./OracleLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.OptimismLayer1GasFeeFlow=void 0;const r=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),n.add(this)}async matchesTransaction({transactionMeta:e}){const t=(0,o.hexToNumber)(e.chainId),a=await i(this,n,"m",s).call(this);return!!a?.has(t)||d.includes(e.chainId)}}a.OptimismLayer1GasFeeFlow=m,n=new WeakSet,s=async function(){try{const e=await(0,r.handleFetch)("https://gas.api.cx.metamask.io/v1/supportedNetworks");return new Set(e?.partialSupport?.optimism??[])}catch{return null}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/OracleLayer1GasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../utils/prepare.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs","../utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){(function(t){(function(){var n,s,i,r,o,c,l=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.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"),w=(0,h.createModuleLogger)(p.projectLogger,"oracle-layer1-gas-fee-flow"),b=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"}];a.OracleLayer1GasFeeFlow=class{constructor(){n.add(this)}getOracleAddressForChain(e){return"0x420000000000000000000000000000000000000F"}shouldSignTransaction(){return!1}async getLayer1Fee(e){try{const{provider:t,transactionMeta:a}=e,r=l(this,n,"m",c).call(this,t,a.chainId),o=await l(this,n,"m",s).call(this,r,a),d=await l(this,n,"m",i).call(this,r,a);return{layer1Fee:(0,h.add0x)((0,k.padHexToEvenLength)(o.add(d).toString(16)))}}catch(e){throw w("Failed to get oracle layer 1 gas fee",e),new Error("Failed to get oracle layer 1 gas fee")}}},n=new WeakSet,s=async function(e,t){const a=l(this,n,"m",r).call(this,t,this.shouldSignTransaction()).serialize(),s=await e.getL1Fee(a);if(s===undefined)throw new Error("No value returned from oracle contract");return(0,k.toBN)(s)},i=async function(e,t){const{gasUsed:a}=t;if(!a)return b;try{const t=await e.getOperatorFee(a);return t===undefined?b:(0,k.toBN)(t)}catch(e){return w("Failed to get operator layer 1 gas fee",e),b}},r=function(e,a){const s=l(this,n,"m",o).call(this,e),{chainId:i}=e;let r=(0,g.prepareTransaction)(i,s);if(a){const e=t.from("abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789","hex"),a=Uint8Array.from(e);r=r.sign(a)}return r},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/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/OracleLayer1GasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","../utils/gas-fees.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs","./DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","@metamask/gas-fee-controller":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/gas-fee-controller/dist/index.cjs","@metamask/utils":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/utils/dist/index.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){var n,s,i,r,o,c=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.randomiseDecimalGWEIAndConvertToHex=a.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,a){const n=(0,p.gweiDecimalToWeiDecimal)(e),s=n.length,i=Math.min(t,s-a);if(0===Number(n)||i<=0)return`0x${Number(n).toString(16)}`;const r=s-i,o=n.slice(0,r),c=n.slice(-i),l=function(e,t){const a=10**e;return t+Math.floor(Math.random()*(a-t))}(i,Number(c)),m=`0x${(BigInt(o+"0".repeat(i))+BigInt(l)).toString(16)}`;return(0,d.add0x)(m)}a.RandomisedEstimationsGasFeeFlow=class{constructor(){n.add(this)}matchesTransaction({transactionMeta:e,messenger:t}){const{chainId:a}=e;return(0,f.getGasFeeRandomisation)(t).randomisedGasFeeDigits[a]!==undefined}async getGasFees(e){try{return await c(this,n,"m",i).call(this,e)}catch(t){return g("Using default flow as fallback due to error",t),await c(this,n,"m",s).call(this,e)}}},n=new WeakSet,s=async function(e){return(new m.DefaultGasFeeFlow).getGasFees(e)},i=async function(e){const{messenger:t,gasFeeControllerData:a,transactionMeta:i}=e,{gasEstimateType:o,gasFeeEstimates:d}=a,m=(0,f.getGasFeeRandomisation)(t),u=m.randomisedGasFeeDigits[i.chainId],h=m.preservedNumberOfDigits??2;if(o===l.GAS_ESTIMATE_TYPES.FEE_MARKET){g("Randomising fee market estimates",d);const e=c(this,n,"m",r).call(this,d,u,h);return g("Added randomised fee market estimates",e),{estimates:e}}return await c(this,n,"m",s).call(this,e)},r=function(e,t,a){const s=Object.values(h.GasFeeEstimateLevel).reduce((s,i)=>({...s,[i]:c(this,n,"m",o).call(this,e,i,t,a)}),{});return{type:h.GasFeeEstimateType.FeeMarket,...s}},o=function(e,t,a,n){return{maxFeePerGas:(0,p.gweiDecimalToWeiHex)(e[t].suggestedMaxFeePerGas),maxPriorityFeePerGas:k(e[t].suggestedMaxPriorityFeePerGas,a,n)}},a.randomiseDecimalGWEIAndConvertToHex=k}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","./OracleLayer1GasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.ScrollLayer1GasFeeFlow=void 0;const n=e("./OracleLayer1GasFeeFlow.cjs"),s=e("../constants.cjs"),i=[s.CHAIN_IDS.SCROLL,s.CHAIN_IDS.SCROLL_SEPOLIA];class r extends n.OracleLayer1GasFeeFlow{getOracleAddressForChain(e){return"0x5300000000000000000000000000000000000002"}shouldSignTransaction(){return!0}async matchesTransaction({transactionMeta:e}){return i.includes(e.chainId)}}a.ScrollLayer1GasFeeFlow=r}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/TestGasFeeFlow.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a};Object.defineProperty(a,"__esModule",{value:!0}),a.TestGasFeeFlow=void 0;const c=e("@metamask/controller-utils"),l=e("../types.cjs"),d=1e15;a.TestGasFeeFlow=class{constructor(){n.add(this),s.set(this,1)}matchesTransaction(){return!0}async getGasFees(e){const{transactionMeta:t}=e,{txParams:a}=t,{gas:c}=a;if(!c)throw new Error("Cannot estimate fee without gas value");const m=parseInt(c,16),u=.5*d,h=(r(this,s,"f")+1)*d,f=r(this,s,"f")*d,p=h-u,g=f-u,k=h+u,w=f+u;return o(this,s,r(this,s,"f")+1,"f"),{estimates:{type:l.GasFeeEstimateType.FeeMarket,low:{maxFeePerGas:r(this,n,"m",i).call(this,p,m),maxPriorityFeePerGas:r(this,n,"m",i).call(this,g,m)},medium:{maxFeePerGas:r(this,n,"m",i).call(this,h,m),maxPriorityFeePerGas:r(this,n,"m",i).call(this,f,m)},high:{maxFeePerGas:r(this,n,"m",i).call(this,k,m),maxPriorityFeePerGas:r(this,n,"m",i).call(this,w,m)}}}}},s=new WeakMap,n=new WeakSet,i=function(e,t){const a=Math.ceil(e/t);return(0,c.toHex)(a)}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/TestGasFeeFlow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs",{"../api/accounts-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs","../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","../index.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/index.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.AccountsApiRemoteTransactionSource=a.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");a.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");a.AccountsApiRemoteTransactionSource=class{constructor(){n.add(this)}getSupportedChains(){return a.SUPPORTED_CHAIN_IDS}async fetchTransactions(e){const{address:t,chainIds:c}=e,l=await o(this,n,"m",s).call(this,e,c??a.SUPPORTED_CHAIN_IDS);k("Fetched transactions",l.length,l);const d=await Promise.all(l.map(e=>o(this,n,"m",r).call(this,t,e)));k("Normalized transactions",d);const m=o(this,n,"m",i).call(this,e,d);return k("Filtered transactions",m.length,m),m}},n=new WeakSet,s=async function(e,t){const{address:a,tags:n}=e,s=[];try{const e=await(0,h.getAccountTransactions)({address:a,chainIds:t,sortDirection:"DESC",tags:n});e?.data&&s.push(...e.data)}catch(e){k("Error while fetching transactions",e)}return s},i=function(e,t){const{address:a,includeTokenTransfers:n,updateTransactions:s}=e;let i=t;return s||(i=i.filter(e=>e.txParams.to===a)),n||(i=i.filter(e=>!e.isTransfer)),i},r=async function(e,t){const a=String(t.blockNumber),n=`0x${t.chainId.toString(16)}`,{hash:s}=t,i=new Date(t.timestamp).getTime(),r=(0,m.v1)({msecs:i}),{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,w=g.TransactionType.incoming,b=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,S=y?.symbol,I=(0,l.BNToHex)(new d.default(T?y?.amount??t.value:t.value)),P=T?e:t.to,C={blockNumber:a,chainId:n,error:b===g.TransactionStatus.failed?new Error("Transaction failed"):undefined,hash:s,id:r,isTransfer:T,networkClientId:"",status:b,time:i,toSmartContract:!1,transferInformation:y?{amount:_,contractAddress:v,decimals:E,symbol:S}:undefined,txParams:{chainId:n,data:k,from:o,gas:c,gasPrice:h,gasUsed:f,nonce:p,to:P,value:I},type:w,verifiedOnBlockchain:!1};return x&&(C.type=(await(0,u.determineTransactionType)(C.txParams)).type),C}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs",{"../gas-flows/DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u,h,f,p,g,k,w,b,y,T,x,_,v,E,S=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},I=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.updateTransactionGasEstimates=a.updateTransactionGasProperties=a.GasFeePoller=void 0;const C=P(e("@metamask/eth-query")),j=e("@metamask/utils"),A=P(e("events")),F=e("../gas-flows/DefaultGasFeeFlow.cjs"),D=e("../logger.cjs"),M=e("../types.cjs"),O=e("../utils/gas-flow.cjs"),N=e("../utils/layer1-gas-fee-flow.cjs"),L=(0,j.createModuleLogger)(D.projectLogger,"gas-fee-poller");function G(e,t,a,n){const{type:s}=t;if(n){if(s===M.GasFeeEstimateType.FeeMarket){const n=t;e.maxFeePerGas=n[a]?.maxFeePerGas,e.maxPriorityFeePerGas=n[a]?.maxPriorityFeePerGas}if(s===M.GasFeeEstimateType.GasPrice){const a=t;e.maxFeePerGas=a.gasPrice,e.maxPriorityFeePerGas=a.gasPrice}if(s===M.GasFeeEstimateType.Legacy){const n=t[a];e.maxFeePerGas=n,e.maxPriorityFeePerGas=n}delete e.gasPrice}else{if(s===M.GasFeeEstimateType.FeeMarket){const n=t;e.gasPrice=n[a]?.maxFeePerGas}if(s===M.GasFeeEstimateType.GasPrice){const a=t;e.gasPrice=a.gasPrice}if(s===M.GasFeeEstimateType.Legacy){const n=t;e.gasPrice=n[a]}delete e.maxFeePerGas,delete e.maxPriorityFeePerGas}}a.GasFeePoller=class{constructor({findNetworkClientIdByChainId:e,gasFeeFlows:t,getGasFeeControllerEstimates:a,getProvider:g,getTransactions:k,getTransactionBatches:w,layer1GasFeeFlows:b,messenger:y,onStateChange:T}){n.add(this),this.hub=new A.default,s.set(this,void 0),i.set(this,void 0),r.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),S(this,s,e,"f"),S(this,i,t,"f"),S(this,d,b,"f"),S(this,r,a,"f"),S(this,o,g,"f"),S(this,c,k,"f"),S(this,l,w,"f"),S(this,m,y,"f"),T(()=>{const e=I(this,n,"m",_).call(this),t=I(this,n,"m",v).call(this);e.length||t.length?I(this,n,"m",f).call(this):I(this,n,"m",p).call(this)})}},s=new WeakMap,i=new WeakMap,r=new WeakMap,o=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,h=new WeakMap,n=new WeakSet,f=function(){I(this,h,"f")||(I(this,n,"m",g).call(this),S(this,h,!0,"f"),L("Started polling"))},p=function(){I(this,h,"f")&&(clearTimeout(I(this,u,"f")),S(this,u,undefined,"f"),S(this,h,!1,"f"),L("Stopped polling"))},g=async function e(){await I(this,n,"m",k).call(this),await I(this,n,"m",w).call(this),S(this,u,setTimeout(()=>I(this,n,"m",e).call(this),1e4),"f")},k=async function(){const e=I(this,n,"m",_).call(this);if(!e.length)return;L("Found unapproved transactions",e.length);const t=await I(this,n,"m",E).call(this,e);L("Retrieved gas fee controller data",t),await Promise.all(e.flatMap(e=>{const{chainId:a}=e,s=t.get(a);return I(this,n,"m",b).call(this,e,s)}))},w=async function(){const e=I(this,n,"m",v).call(this);if(!e.length)return;L("Found unapproved transaction batches",e.length);const t=await I(this,n,"m",E).call(this,e);L("Retrieved gas fee controller data",t),await Promise.all(e.flatMap(e=>{const{chainId:a}=e,s=t.get(a);return I(this,n,"m",y).call(this,e,s)}))},b=async function(e,t){const{id:a}=e,[s,i]=await Promise.all([I(this,n,"m",T).call(this,e,t),I(this,n,"m",x).call(this,e)]);(s||i)&&this.hub.emit("transaction-updated",{transactionId:a,gasFeeEstimates:s?.gasFeeEstimates,gasFeeEstimatesLoaded:s?.gasFeeEstimatesLoaded,layer1GasFee:i})},y=async function(e,t){const{id:a}=e,n=new C.default(I(this,o,"f").call(this,e.networkClientId)),s=new F.DefaultGasFeeFlow,i={ethQuery:n,gasFeeControllerData:t,messenger:I(this,m,"f"),transactionMeta:{...e,txParams:{...e.transactions?.[0],from:e.from,gas:e.gas},time:Date.now()}};let r;try{r=(await s.getGasFees(i)).estimates}catch(t){L("Failed to get gas fees for batch",e.id,t)}r&&this.hub.emit("transaction-batch-updated",{transactionBatchId:a,gasFeeEstimates:r,gasFeeEstimatesLoaded:!0})},T=async function(e,t){const{networkClientId:a}=e,n=new C.default(I(this,o,"f").call(this,a)),s=(0,O.getGasFeeFlow)(e,I(this,i,"f"),I(this,m,"f"));s&&L("Found gas fee flow",s.constructor.name,e.id);const r={ethQuery:n,gasFeeControllerData:t,messenger:I(this,m,"f"),transactionMeta:e};let c;if(s)try{c=(await s.getGasFees(r)).estimates}catch(t){L("Failed to get suggested gas fees",e.id,t)}return!c&&e.gasFeeEstimatesLoaded?undefined:(L("Updated gas fee estimates",{gasFeeEstimates:c,transaction:e.id}),{gasFeeEstimates:c,gasFeeEstimatesLoaded:!0})},x=async function(e){const{networkClientId:t}=e,a=I(this,o,"f").call(this,t),n=await(0,N.getTransactionLayer1GasFee)({layer1GasFeeFlows:I(this,d,"f"),messenger:I(this,m,"f"),provider:a,transactionMeta:e});return n&&L("Updated layer 1 gas fee",n,e.id),n},_=function(){return I(this,c,"f").call(this).filter(e=>e.status===M.TransactionStatus.unapproved)},v=function(){return I(this,l,"f").call(this).filter(e=>e.status===M.TransactionStatus.unapproved)},E=async function(e){const t=new Map;for(const a of e){const{chainId:e,networkClientId:n}=a;if(t.has(e))continue;const i=n??I(this,s,"f").call(this,e);t.set(e,i)}L("Extracted network client IDs by chain ID",t);const a=Array.from(t.entries()).map(async([e,t])=>[e,await I(this,r,"f").call(this,{networkClientId:t})]);return new Map(await Promise.all(a))},a.updateTransactionGasProperties=function({gasFeeEstimates:e,gasFeeEstimatesLoaded:t,isTxParamsGasFeeUpdatesEnabled:a,layer1GasFee:n,txMeta:s}){const i=s.userFeeLevel,r=Object.values(M.GasFeeEstimateLevel).includes(i);if(a(s)&&r&&e){const t=s.txParams.type!==M.TransactionEnvelopeType.legacy;G(s.txParams,e,i,t)}e&&(s.gasFeeEstimates=e),t!==undefined&&(s.gasFeeEstimatesLoaded=t),n&&(s.layer1GasFee=n)},a.updateTransactionGasEstimates=function({txMeta:e,userFeeLevel:t}){const{txParams:a,gasFeeEstimates:n}=e;if(!n)return;G(a,n,t,e.txParams.type!==M.TransactionEnvelopeType.legacy)}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","../utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs","./AccountsApiRemoteTransactionSource.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u,h,f,p,g,k,w,b,y,T,x,_,v,E,S,I,P,C,j,A,F,D,M=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},O=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},N=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.IncomingTransactionHelper=a.WebSocketState=void 0;const L=N(e("events")),G=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||(a.WebSocketState=U={}));a.IncomingTransactionHelper=class{constructor({client:e,getCurrentAccount:t,getLocalTransactions:a,includeTokenTransfers:x,isEnabled:v,messenger:E,remoteTransactionSource:P,trimTransactions:C,updateTransactions:j}){n.add(this),s.set(this,void 0),i.set(this,void 0),r.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,[...G.SUPPORTED_CHAIN_IDS]),w.set(this,e=>{O(this,n,"m",_).call(this,e)}),b.set(this,e=>{O(this,n,"m",S).call(this,e)}),y.set(this,()=>{O(this,n,"m",I).call(this)}),T.set(this,({chainIds:e,status:t})=>{O(this,n,"m",D).call(this,e,t)}),this.hub=new L.default,M(this,s,e,"f"),M(this,i,t,"f"),M(this,r,a,"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,P,"f"),M(this,f,C,"f"),M(this,p,j,"f"),M(this,g,(0,R.isIncomingTransactionsUseBackendWebSocketServiceEnabled)(E),"f"),O(this,g,"f")&&(O(this,m,"f").subscribe("BackendWebSocketService:connectionStateChanged",O(this,w,"f")),O(this,m,"f").subscribe("AccountActivityService:statusChanged",O(this,T,"f")))}start(){O(this,g,"f")||O(this,n,"m",x).call(this,!0)}stop(){O(this,h,"f")&&clearTimeout(O(this,h,"f")),O(this,l,"f")&&(M(this,l,!1,"f"),(0,B.incomingTransactionsLogger)("Stopped polling"))}async update({chainIds:e,isInterval:t,tags:a}={}){const s=O(this,n,"m",F).call(this,a,t);if((0,B.incomingTransactionsLogger)("Checking for incoming transactions",{isInterval:Boolean(t),tags:s}),!O(this,n,"m",j).call(this))return;const c=O(this,i,"f").call(this),l=O(this,o,"f")??!0,d=O(this,p,"f")??!1;let m=[];try{m=await O(this,u,"f").fetchTransactions({address:c.address,chainIds:e,includeTokenTransfers:l,tags:s,updateTransactions:d})}catch(e){return void(0,B.incomingTransactionsLogger)("Error while fetching remote transactions",e)}if(!m.length)return;O(this,n,"m",C).call(this,m),(0,B.incomingTransactionsLogger)("Found potential transactions",m.length,m);const h=O(this,r,"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=O(this,f,"f").call(this,[...g,...h]),w=g.map(e=>e.id),b=k.filter(e=>w.includes(e.id));b.length?((0,B.incomingTransactionsLogger)("Adding new transactions",b.length,b),this.hub.emit("transactions",b)):(0,B.incomingTransactionsLogger)("All unique transactions truncated due to limit")}},s=new WeakMap,i=new WeakMap,r=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,w=new WeakMap,b=new WeakMap,y=new WeakMap,T=new WeakMap,n=new WeakSet,x=function(e=!1){if(O(this,l,"f"))return;if(!O(this,n,"m",j).call(this))return;const t=O(this,n,"m",A).call(this);(0,B.incomingTransactionsLogger)("Started polling",{interval:t}),M(this,l,!0,"f"),O(this,d,"f")||O(this,n,"m",P).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"),O(this,n,"m",v).call(this)):e.state===U.DISCONNECTED&&((0,B.incomingTransactionsLogger)("WebSocket disconnected, stopping enhanced mode"),O(this,n,"m",E).call(this))},v=function(){O(this,n,"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)}),O(this,m,"f").subscribe("AccountActivityService:transactionUpdated",O(this,b,"f")),O(this,m,"f").subscribe("AccountsController:selectedAccountChange",O(this,y,"f")))},E=function(){(0,B.incomingTransactionsLogger)("Stopped transaction history retrieval"),O(this,m,"f").unsubscribe("AccountActivityService:transactionUpdated",O(this,b,"f")),O(this,m,"f").unsubscribe("AccountsController:selectedAccountChange",O(this,y,"f"))},S=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)})},I=function(){(0,B.incomingTransactionsLogger)("Selected account changed, triggering update"),this.update().catch(e=>{(0,B.incomingTransactionsLogger)("Update after account change failed",e)})},P=async function e(){M(this,d,!0,"f");try{const e=O(this,g,"f")?O(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"),O(this,l,"f")&&(O(this,h,"f")&&clearTimeout(O(this,h,"f")),M(this,h,setTimeout(()=>O(this,n,"m",e).call(this),O(this,n,"m",A).call(this)),"f"))},C=function(e){e.sort((e,t)=>e.time<t.time?-1:1)},j=function(){return O(this,c,"f").call(this)},A=function(){return(0,R.getIncomingTransactionsPollingInterval)(O(this,m,"f"))},F=function(e,t){const a=[];return O(this,s,"f")&&a.push(O(this,s,"f")),e?.length?a.push(...e):t&&a.push("automatic-polling"),a?.length?a:undefined},D=function(e,t){if(!O(this,g,"f"))return;let a=!1;for(const n of e){const e=(0,H.caip2ToHex)(n);if(e&&G.SUPPORTED_CHAIN_IDS.includes(e))if("up"===t){const t=O(this,k,"f").indexOf(e);-1!==t&&(O(this,k,"f").splice(t,1),a=!0,(0,B.incomingTransactionsLogger)("Supported network came up, removed from polling list",{chainId:e}))}else"down"!==t||O(this,k,"f").includes(e)||(O(this,k,"f").push(e),a=!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:n,hexChainId:e})}a?0===O(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:O(this,k,"f")}),O(this,n,"m",x).call(this)):(0,B.incomingTransactionsLogger)("No changes to polling list",{chainsToPoll:O(this,k,"f")})}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/MethodDataHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},d=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.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");a.MethodDataHelper=class{constructor({getProvider:e,getState:t}){n.add(this),s.set(this,void 0),i.set(this,void 0),r.set(this,void 0),o.set(this,new h.Mutex),this.hub=new p.default,l(this,s,e,"f"),l(this,i,t,"f"),l(this,r,new Map,"f")}async lookup(e,t){k("lookup",e,t);const a=await d(this,o,"f").acquire();try{const a=d(this,i,"f").call(this)[e];if(a)return k("Cached",a),a;let o=d(this,r,"f").get(t);if(!o){const e=d(this,s,"f").call(this,t);o=new f.MethodRegistry({provider:e}),d(this,r,"f").set(t,o),k("Created registry",t)}const l=await d(this,n,"m",c).call(this,e,o);return k("Result",l),this.hub.emit("update",{fourBytePrefix:e,methodData:l}),l}finally{a()}}},s=new WeakMap,i=new WeakMap,r=new WeakMap,o=new WeakMap,n=new WeakSet,c=async function(e,t){const a=await t.lookup(e);if(!a)return k("No method found",e),{registryMethod:"",parsedRegistryMethod:{name:undefined,args:undefined}};k("Parsing",a);return{registryMethod:a,parsedRegistryMethod:t.parse(a)}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/MethodDataHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u,h,f,p=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},g=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.MultichainTrackingHelper=void 0;const k=e("async-mutex"),w=e("../logger.cjs"),b=(0,w.createModuleLogger)(w.projectLogger,"multichain-tracking");a.MultichainTrackingHelper=class{constructor({findNetworkClientIdByChainId:e,getNetworkClientById:t,getNetworkClientRegistry:a,removePendingTransactionTrackerListeners:k,createNonceTracker:w,createPendingTransactionTracker:y,onNetworkStateChange:T}){n.add(this),s.set(this,void 0),i.set(this,void 0),r.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),a=Array.from(g(this,m,"f").keys()),s=a.filter(e=>!t.includes(e));s.forEach(e=>{g(this,n,"m",h).call(this,e)});const i=t.filter(e=>!a.includes(e));i.forEach(e=>{g(this,n,"m",f).call(this,e)}),i.length&&b("Added trackers",i),s.length&&b("Removed trackers",s)}),p(this,s,e,"f"),p(this,i,t,"f"),p(this,r,a,"f"),p(this,o,k,"f"),p(this,c,w,"f"),p(this,l,y,"f"),T((e,t)=>{const a=g(this,r,"f").call(this);t.forEach(({op:e,path:t})=>{if("remove"===e&&"networkConfigurations"===t[0]){const e=t[1];delete a[e]}}),g(this,u,"f").call(this,a)})}initialize(){const e=g(this,r,"f").call(this);g(this,u,"f").call(this,e),b("Initialized")}has(e){return g(this,m,"f").has(e)}async acquireNonceLockForChainIdKey({chainId:e,key:t="global"}){let a=g(this,d,"f").get(e);a||(a=new Map,g(this,d,"f").set(e,a));let n=a.get(t);return n||(n=new k.Mutex,a.set(t,n)),await n.acquire()}async getNonceLock(e,t){const a=g(this,i,"f").call(this,t),n=await this.acquireNonceLockForChainIdKey({chainId:a.configuration.chainId,key:e}),s=g(this,m,"f").get(t)?.nonceTracker;if(!s)throw new Error(`Missing nonce tracker for network client ID - ${t}`);try{const t=await s.getNonceLock(e),a=()=>{t.releaseLock(),n?.()};return{...t,releaseLock:a}}catch(e){throw n?.(),e}}stopAllTracking(){for(const[e]of g(this,m,"f"))g(this,n,"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 a,n=t;try{t&&(a=g(this,i,"f").call(this,t))}catch(a){if(b("No network client found with ID",t),!e)throw a}return!a&&e&&(n=g(this,s,"f").call(this,e),a=g(this,i,"f").call(this,n)),{...a,id:n}}},s=new WeakMap,i=new WeakMap,r=new WeakMap,o=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,n=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:a,configuration:{chainId:n}}=g(this,i,"f").call(this,e),s=g(this,c,"f").call(this,{provider:t,blockTracker:a,chainId:n}),r=g(this,l,"f").call(this,{provider:t,blockTracker:a,chainId:n,networkClientId:e});g(this,m,"f").set(e,{nonceTracker:s,pendingTransactionTracker:r})}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","./TransactionPoller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u,h,f,p,g,k,w,b,y,T,x,_,v,E,S,I,P,C,j,A,F,D,M,O,N,L,G,B,R,H,U,q,W,$=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},K=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},V=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.PendingTransactionTracker=void 0;const z=e("@metamask/controller-utils"),J=V(e("events")),Y=e("lodash"),Q=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"],ae=(0,X.createModuleLogger)(X.projectLogger,"pending-transactions");a.PendingTransactionTracker=class{constructor({blockTracker:e,getChainId:t,getEthQuery:a,getGlobalLock:_,getNetworkClientId:v,getTransactions:E,isTimeoutEnabled:S,hooks:I,isResubmitEnabled:P,messenger:C,publishTransaction:j}){n.add(this),s.set(this,void 0),i.set(this,void 0),r.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),w.set(this,void 0),b.set(this,void 0),y.set(this,void 0),this.startIfPendingTransactions=()=>{const e=K(this,n,"m",M).call(this);e.length?K(this,n,"m",T).call(this,e):this.stop()},this.hub=new J.default,$(this,i,new Map,"f"),$(this,o,t,"f"),$(this,c,a,"f"),$(this,l,_,"f"),$(this,d,v,"f"),$(this,m,E,"f"),$(this,u,P??(()=>!0),"f"),$(this,h,new Map,"f"),$(this,f,K(this,n,"m",x).bind(this),"f"),$(this,g,C,"f"),$(this,k,j,"f"),$(this,w,!1,"f"),$(this,y,undefined,"f"),$(this,b,new Q.TransactionPoller({blockTracker:e,chainId:t(),messenger:C}),"f"),$(this,s,I?.beforeCheckPendingTransaction??(()=>Promise.resolve(!0)),"f"),$(this,r,S,"f"),$(this,p,(0,X.createModuleLogger)(ae,`${t()}:${v()}`),"f")}addTransactionToPoll(e){K(this,n,"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,n,"m",C).call(this,e)}catch(e){K(this,p,"f").call(this,"Failed to check transaction",e)}finally{t()}}stop(){K(this,w,"f")&&(K(this,b,"f").stop(),$(this,w,!1,"f"),K(this,p,"f").call(this,"Stopped polling"))}},s=new WeakMap,i=new WeakMap,r=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,w=new WeakMap,b=new WeakMap,y=new WeakMap,n=new WeakSet,T=function(e){K(this,b,"f").setPendingTransactions(e),K(this,w,"f")||(K(this,b,"f").start(K(this,f,"f")),$(this,w,!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,n,"m",_).call(this)}catch(e){K(this,p,"f").call(this,"Failed to check transactions",e)}finally{t()}try{await K(this,n,"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,n,"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,n,"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,w,"f"))return;K(this,p,"f").call(this,"Resubmitting transactions");const t=K(this,n,"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 a of t)try{await K(this,n,"m",S).call(this,a,e)}catch(e){const t=e.value?.message?.toLowerCase()??e.message?.toLowerCase()??String(e);if(K(this,n,"m",E).call(this,t)){K(this,p,"f").call(this,"Ignoring known transaction error",t);continue}K(this,n,"m",O).call(this,a,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))},S=async function(e,t){if(!K(this,n,"m",I).call(this,e,t))return;if(!await K(this,s,"f").call(this,e))return;const a=K(this,c,"f").call(this,e.networkClientId);await K(this,k,"f").call(this,a,e);const i=(e.retryCount??0)+1;K(this,n,"m",G).call(this,(0,Y.merge)({},e,{retryCount:i}),"PendingTransactionTracker:transaction-retry - Retry count increased")},I=function(e,t){const a=(0,Y.cloneDeep)(e);a.firstRetryBlockNumber||(a.firstRetryBlockNumber=t,K(this,n,"m",G).call(this,a,"PendingTransactionTracker:#isResubmitDue - First retry block number set"));const{firstRetryBlockNumber:s}=a,i=Number.parseInt(t,16)-Number.parseInt(s,16),r=e.retryCount??0;return i>=Math.min(50,Math.pow(2,r))},P=function(e){const{hash:t,id:a}=e;K(this,y,"f")?.id===a&&$(this,y,undefined,"f"),t&&K(this,h,"f").delete(t)},C=async function(e){const{hash:t,id:a,isIntentComplete:i,txParams:{from:r}}=e;if(i)await K(this,n,"m",j).call(this,e);else{if(!t&&await K(this,s,"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,n,"m",N).call(this,e,t)}if(K(this,n,"m",D).call(this,e))return K(this,p,"f").call(this,"Nonce already taken",a),void K(this,n,"m",L).call(this,e);try{const a=await K(this,n,"m",B).call(this,t),s="0x1"===a?.status;if("0x0"===a?.status)return K(this,p,"f").call(this,"Transaction receipt has failed status"),void K(this,n,"m",N).call(this,e,new Error("Transaction failed on-chain"));const{blockNumber:i,blockHash:o}=a??{};if(s&&i&&o)return void await K(this,n,"m",j).call(this,e,{...a,blockNumber:i,blockHash:o});K(this,p,"f").call(this,"No receipt status",{hash:t,receipt:a});const c=await K(this,n,"m",U).call(this,r),l=parseInt(c,16);if(!a&&await K(this,n,"m",A).call(this,e,l))return;await K(this,n,"m",F).call(this,e,l)&&K(this,n,"m",L).call(this,e)}catch(t){K(this,p,"f").call(this,"Failed to check transaction",a,t),K(this,n,"m",O).call(this,e,t.message,"There was a problem loading this transaction.")}}},j=async function(e,t){const{id:a}=e,{blockHash:s}=t??{};K(this,p,"f").call(this,"Transaction confirmed",a);const i=K(this,y,"f")?.id===a;if(K(this,n,"m",P).call(this,e),i)return void this.hub.emit("transaction-confirmed",e);const r=(0,Y.cloneDeep)(e);if(t&&s){const{baseFeePerGas:e,timestamp:a}=await K(this,n,"m",H).call(this,s,!1);r.baseFeePerGas=e,r.blockTimestamp=a,r.txParams={...r.txParams,gasUsed:t.gasUsed},r.txReceipt=t,r.verifiedOnBlockchain=!0}r.status=Z.TransactionStatus.confirmed,K(this,n,"m",G).call(this,r,"PendingTransactionTracker:#onTransactionConfirmed - Transaction confirmed"),this.hub.emit("transaction-confirmed",r)},A=async function(e,t){const{chainId:a,hash:s,id:i,submittedTime:o,txParams:{nonce:c}}=e;if(!s||!c)return!1;if(!K(this,r,"f").call(this,e))return K(this,p,"f").call(this,"Timeout disabled for transaction",e),!1;const l=(0,ee.getTimeoutAttempts)(a,K(this,g,"f"));if(l===undefined||0===l)return K(this,p,"f").call(this,"Timeout disabled due to threshold",{chainId:a,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,n,"m",R).call(this,s)){const e=Date.now();return K(this,p,"f").call(this,"Transaction found on network, recording timestamp",i),K(this,h,"f").set(s,e),!1}const t=K(this,h,"f").get(s)??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",i),!1;const{blockTime:r}=(0,ee.getAcceleratedPollingParams)(a,K(this,g,"f")),c=Date.now()-t,d=r*l;return K(this,p,"f").call(this,"Checking timeout duration",{transactionId:i,durationSinceLastSeen:c,timeoutDuration:d,threshold:l,blockTime:r}),c<d?!1:(K(this,p,"f").call(this,"Hit timeout duration threshold",i),K(this,h,"f").delete(s),K(this,n,"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",i,e),!1}},F=async function(e,t){const{hash:a,id:n,txParams:{nonce:s}}=e;if(!s||!a)return!1;if(parseInt(s,16)>=t)return!1;let r=K(this,i,"f").get(a);return r===undefined&&(r=0,K(this,i,"f").set(a,r)),r<3?(K(this,p,"f").call(this,"Incrementing dropped block count",{id:n,droppedBlockCount:r}),K(this,i,"f").set(a,r+1),!1):(K(this,p,"f").call(this,"Hit dropped block count",n),K(this,i,"f").delete(a),!0)},D=function(e){const{id:t,txParams:a}=e;return K(this,n,"m",q).call(this).some(e=>e.id!==t&&e.txParams.from===a.from&&e.status===Z.TransactionStatus.confirmed&&e.txParams.nonce&&e.txParams.nonce===a.nonce&&e.type!==Z.TransactionType.incoming&&e.isTransfer===undefined)},M=function(){return K(this,n,"m",W).call(this).filter(e=>e.status===Z.TransactionStatus.submitted&&!e.verifiedOnBlockchain&&!e.isUserOperation&&!e.isStateOnly)},O=function(e,t,a){K(this,n,"m",G).call(this,{...e,warning:{error:t,message:a}},"PendingTransactionTracker:#warnTransaction - Warning added")},N=function(e,t){K(this,p,"f").call(this,"Transaction failed",e.id,t),K(this,n,"m",P).call(this,e),this.hub.emit("transaction-failed",e,t)},L=function(e){K(this,p,"f").call(this,"Transaction dropped",e.id),K(this,n,"m",P).call(this,e),this.hub.emit("transaction-dropped",e)},G=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/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/ResimulateHelper.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","../utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},h=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.hasSimulationDataChanged=a.shouldResimulate=a.ResimulateHelper=a.RESIMULATE_INTERVAL_MS=a.BLOCK_TIME_ADDITIONAL_SECONDS=a.VALUE_COMPARISON_PERCENT_THRESHOLD=a.BLOCKAID_RESULT_TYPE_MALICIOUS=a.RESIMULATE_PARAMS=void 0;const f=e("@metamask/utils"),p=e("bn.js"),g=e("lodash"),k=e("../logger.cjs"),w=e("../types.cjs"),b=e("../utils/utils.cjs"),y=(0,k.createModuleLogger)(k.projectLogger,"resimulate-helper");a.RESIMULATE_PARAMS=["to","value","data"],a.BLOCKAID_RESULT_TYPE_MALICIOUS="Malicious",a.VALUE_COMPARISON_PERCENT_THRESHOLD=5,a.BLOCK_TIME_ADDITIONAL_SECONDS=60,a.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,n,s){let i=new p.BN((0,f.remove0x)(e),"hex"),r=new p.BN((0,f.remove0x)(t),"hex");return n&&(i=i.neg()),s&&(r=r.neg()),(0,b.getPercentageChange)(i,r)<=a.VALUE_COMPARISON_PERCENT_THRESHOLD}a.ResimulateHelper=class{constructor({getTransactions:e,simulateTransaction:t,onTransactionsUpdate:a}){n.add(this),s.set(this,new Map),i.set(this,void 0),r.set(this,void 0),u(this,i,e,"f"),u(this,r,t,"f"),a(h(this,n,"m",o).bind(this))}},s=new WeakMap,i=new WeakMap,r=new WeakMap,n=new WeakSet,o=function(){const e=h(this,i,"f").call(this).filter(e=>e.status===w.TransactionStatus.unapproved),t=new Set(e.map(e=>e.id));new Set([...t,...h(this,s,"f").keys()]).forEach(t=>{const a=e.find(e=>e.id===t);a?.isActive?h(this,n,"m",c).call(this,a):h(this,n,"m",d).call(this,t)})},c=function(e){const{id:t}=e;if(h(this,s,"f").has(t))return;const i=()=>{h(this,r,"f").call(this,e).catch(e=>{y("Error during transaction resimulation",e)}).finally(()=>{h(this,s,"f").has(t)&&h(this,n,"m",l).call(this,t,i)})};h(this,n,"m",l).call(this,t,i),y(`Started resimulating transaction ${t} every ${a.RESIMULATE_INTERVAL_MS} milliseconds`)},l=function(e,t){const n=setTimeout(t,a.RESIMULATE_INTERVAL_MS);h(this,s,"f").set(e,n)},d=function(e){h(this,s,"f").has(e)&&(h(this,n,"m",m).call(this,e),y(`Stopped resimulating transaction ${e} every ${a.RESIMULATE_INTERVAL_MS} milliseconds`))},m=function(e){const t=h(this,s,"f").get(e);t&&(clearTimeout(t),h(this,s,"f").delete(e))},a.shouldResimulate=function(e,t){const{id:n}=t,s=function(e,t){const{id:n,txParams:s}=t,{txParams:i}=e;if(!i||(0,g.isEqual)(i,s))return!1;const r=Object.keys(s).filter(e=>s[e]!==i[e]);return y("Transaction parameters updated",{transactionId:n,updatedProperties:r,originalParams:i,newParams:s}),a.RESIMULATE_PARAMS.some(e=>r.includes(e))}(e,t),i=function(e,t){const{securityAlertResponse:n}=e,{id:s,securityAlertResponse:i}=t;if((0,g.isEqual)(n,i))return!1;return y("Security alert updated",{transactionId:s,originalSecurityAlertResponse:n,newSecurityAlertResponse:i}),i?.result_type===a.BLOCKAID_RESULT_TYPE_MALICIOUS}(e,t),r=function(e,t){const{simulationData:a}=e,{simulationData:n,txParams:s}=t;if(!n||(0,g.isEqual)(a,n))return!1;return!x(s?.value??"0x0",n?.nativeBalanceChange?.difference??"0x0",!1,!1===n?.nativeBalanceChange?.isDecrease)}(e,t),o=s||i||r;let c;if(i||r){c=Math.floor(Date.now()/1e3)+a.BLOCK_TIME_ADDITIONAL_SECONDS}return o&&y("Transaction should be resimulated",{transactionId:n,blockTime:c,parametersUpdated:s,securityAlert:i,valueAndNativeBalanceMismatch:r}),{blockTime:c,resimulate:o}},a.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 a of e.tokenBalanceChanges){const e=t.tokenBalanceChanges.find(({address:e,id:t})=>e===a.address&&t===a.id);if(!e)return y("Missing new token balance",{address:a.address,id:a.id}),!0;if(T(a,e))return y("Simulation data token balance changed",{originalTokenBalanceChange:a,newTokenBalanceChange:e}),!0}return!1}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/ResimulateHelper.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/TransactionPoller.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../utils/feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u,h,f,p,g,k,w,b,y=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},T=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.TransactionPoller=void 0;const x=e("@metamask/utils"),_=e("lodash"),v=e("../logger.cjs"),E=e("../utils/feature-flags.cjs"),S=(0,x.createModuleLogger)(v.projectLogger,"transaction-poller");var I;!function(e){e.Accelerated="Accelerated",e.BlockTracker="BlockTracker",e.Websocket="Websocket"}(I||(I={}));a.TransactionPoller=class{constructor({blockTracker:e,chainId:t,messenger:a}){n.add(this),s.set(this,0),i.set(this,void 0),r.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,n,"m",f).call(this,I.Websocket).catch(()=>{})}),y(this,i,e,"f"),y(this,r,t,"f"),y(this,o,a,"f")}start(e){T(this,m,"f")||(y(this,l,e,"f"),y(this,m,!0,"f"),T(this,n,"m",w).call(this),T(this,n,"m",h).call(this),S("Started"))}stop(){T(this,m,"f")&&(y(this,m,!1,"f"),y(this,l,undefined,"f"),y(this,s,0,"f"),y(this,d,undefined,"f"),T(this,n,"m",p).call(this),T(this,n,"m",g).call(this),T(this,n,"m",b).call(this),S("Stopped"))}setPendingTransactions(e){const t=(T(this,d,"f")??[]).map(e=>e.id);y(this,d,e,"f");const a=e.map(e=>e.id),i=!(0,_.isEqual)(t,a);T(this,m,"f")&&i&&(S("Detected new pending transactions",a),y(this,s,0,"f"),T(this,c,"f")&&(T(this,n,"m",g).call(this),T(this,n,"m",h).call(this)))}},s=new WeakMap,i=new WeakMap,r=new WeakMap,o=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,m=new WeakMap,u=new WeakMap,k=new WeakMap,n=new WeakSet,h=function e(){if(!T(this,m,"f"))return;const{countMax:t,intervalMs:a}=(0,E.getAcceleratedPollingParams)(T(this,r,"f"),T(this,o,"f"));if(T(this,s,"f")>=t)return y(this,c,e=>T(this,n,"m",f).call(this,I.BlockTracker,e),"f"),T(this,i,"f").on("latest",T(this,c,"f")),void S("Added block tracker listener");T(this,n,"m",p).call(this),y(this,u,setTimeout(async()=>{await T(this,n,"m",f).call(this,I.Accelerated),T(this,n,"m",e).call(this)},a),"f")},f=async function(e,t){switch(e){case I.Websocket:S("AccountActivityService:transactionUpdated received");break;case I.Accelerated:S("Accelerated interval",T(this,s,"f")+1);break;case I.BlockTracker:S("Block tracker interval",t)}const a=t??await T(this,i,"f").getLatestBlock();await(T(this,l,"f")?.call(this,a)),e===I.Accelerated&&T(this,m,"f")&&y(this,s,T(this,s,"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,i,"f").removeListener("latest",T(this,c,"f")),y(this,c,undefined,"f"))},w=function(){T(this,o,"f").subscribe("AccountActivityService:transactionUpdated",T(this,k,"f"))},b=function(){T(this,o,"f").unsubscribe("AccountActivityService:transactionUpdated",T(this,k,"f"))}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/TransactionPoller.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/CollectPublishHook.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},l=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.CollectPublishHook=void 0;const d=e("@metamask/utils"),m=e("lodash"),u=e("../logger.cjs"),h=(0,d.createModuleLogger)(u.projectLogger,"collect-publish-hook");a.CollectPublishHook=class{constructor(e){n.add(this),s.set(this,void 0),i.set(this,void 0),r.set(this,void 0),c(this,r,(0,d.createDeferredPromise)(),"f"),c(this,s,[],"f"),c(this,i,e,"f")}getHook(){return l(this,n,"m",o).bind(this)}ready(){return l(this,r,"f").promise}success(e){if(h("Success",{transactionHashes:e}),e.length!==l(this,i,"f"))throw new Error("Transaction hash count mismatch");for(let t=0;t<l(this,s,"f").length;t++){const a=l(this,s,"f")[t],n=e[t];a.promise.resolve({transactionHash:n})}}error(e){h("Error",{error:e});for(const t of l(this,s,"f"))t.promise.reject(e)}},s=new WeakMap,i=new WeakMap,r=new WeakMap,n=new WeakSet,o=function(e,t){const a=e.txParams.nonce??"0x0",n=parseInt(a,16);h("Processing transaction",{nonce:n,signedTx:t,transactionMeta:e});const o=(0,d.createDeferredPromise)();if(l(this,s,"f").push({nonce:n,promise:o,signedTransaction:t}),c(this,s,(0,m.sortBy)(l(this,s,"f"),e=>e.nonce),"f"),l(this,s,"f").length===l(this,i,"f")){h("All transactions signed");const e=l(this,s,"f").map(e=>e.signedTransaction);l(this,r,"f").resolve({signedTransactions:e})}return o.promise}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/CollectPublishHook.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/ExtraTransactionsPublishHook.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},l=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.ExtraTransactionsPublishHook=void 0;const d=e("@metamask/utils"),m=e("../logger.cjs"),u=(0,d.createModuleLogger)(m.projectLogger,"extra-transactions-publish-hook");a.ExtraTransactionsPublishHook=class{constructor({addTransactionBatch:e,getTransaction:t,originalPublishHook:a}){n.add(this),s.set(this,void 0),i.set(this,void 0),r.set(this,void 0),c(this,s,e,"f"),c(this,i,t,"f"),c(this,r,a,"f")}getHook(){return l(this,n,"m",o).bind(this)}},s=new WeakMap,i=new WeakMap,r=new WeakMap,n=new WeakSet,o=async function(e,t){u("Publishing transaction as batch",{transactionMeta:e,signedTx:t});const{batchTransactions:a,batchTransactionsOptions:n,id:o,networkClientId:c,txParams:m}=e,h=m.from,f=m.to,p=m.data,g=m.value,k=m.gas,w=m.maxFeePerGas,b=m.maxPriorityFeePerGas,y=t,T=(0,d.createDeferredPromise)(),x={existingTransaction:{id:o,onPublish:({newSignature:e,transactionHash:t})=>{if(e){const t=l(this,i,"f").call(this,o);return u("Calling original publish hook with new signature",{latestTransactionMeta:t,newSignature:e}),void l(this,r,"f").call(this,t,e).then(T.resolve).catch(T.reject)}T.resolve({transactionHash:t})},signedTransaction:y},params:{data:p,gas:k,maxFeePerGas:w,maxPriorityFeePerGas:b,to:f,value:g}},_=(a??[]).map(e=>{const{isAfter:t,type:a,...n}=e;return{isAfter:t,params:n,type:a}}),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=n??{disable7702:!0,disableHook:!1,disableSequential:!0};return await l(this,s,"f").call(this,{from:h,networkClientId:c,requireApproval:!1,transactions:v,...E}),T.promise}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/ExtraTransactionsPublishHook.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/SequentialPublishBatchHook.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n,s,i,r,o,c,l,d,m,u,h,f=this&&this.__classPrivateFieldSet||function(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a},p=this&&this.__classPrivateFieldGet||function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};Object.defineProperty(a,"__esModule",{value:!0}),a.SequentialPublishBatchHook=void 0;const g=e("@metamask/rpc-errors"),k=e("@metamask/utils"),w=e("../logger.cjs"),b=(0,k.createModuleLogger)(w.projectLogger,"sequential-publish-batch-hook");a.SequentialPublishBatchHook=class{constructor({publishTransaction:e,getTransaction:t,getPendingTransactionTracker:a,getEthQuery:l}){n.add(this),s.set(this,void 0),i.set(this,void 0),r.set(this,void 0),o.set(this,void 0),c.set(this,{}),f(this,s,e,"f"),f(this,i,t,"f"),f(this,r,l,"f"),f(this,o,a,"f")}getHook(){return p(this,n,"m",l).bind(this)}},s=new WeakMap,i=new WeakMap,r=new WeakMap,o=new WeakMap,c=new WeakMap,n=new WeakSet,l=async function({from:e,networkClientId:t,transactions:a}){b("Starting sequential publish batch hook",{from:e,networkClientId:t});const c=p(this,o,"f").call(this,t),l=[];for(const e of a)try{const a=p(this,i,"f").call(this,String(e.id)),o=await p(this,s,"f").call(this,p(this,r,"f").call(this,t),a);b("Transaction published",{transactionHash:o});const m={...a,hash:o},u=p(this,n,"m",d).call(this,c,m.id,m.hash);c.addTransactionToPoll(m),await u,l.push({transactionHash:o})}catch(t){throw b("Batch transaction failed",{transaction:e,error:t}),c.stop(),g.rpcErrors.internal("Failed to publish batch transaction")}return b("Sequential publish batch hook completed",{results:l}),c.stop(),{results:l}},d=async function(e,t,a){return new Promise((s,i)=>{const r=p(this,n,"m",m).bind(this,t,a,s,e),o=p(this,n,"m",u).bind(this,t,a,i,e);p(this,c,"f")[t]={onConfirmed:r,onFailedOrDropped:o},e.hub.on("transaction-confirmed",r),e.hub.on("transaction-failed",o),e.hub.on("transaction-dropped",o)})},m=function(e,t,a,s,i){i.id===e&&(b("Transaction confirmed",{transactionHash:t}),p(this,n,"m",h).call(this,s,e),a(i))},u=function(e,t,a,s,i,r){i.id===e&&(b("Transaction failed or dropped",{transactionHash:t,error:r}),p(this,n,"m",h).call(this,s,e),a(new Error(`Transaction ${t} failed or dropped.`)))},h=function(e,t){const a=p(this,c,"f")[t];e.hub.off("transaction-confirmed",a.onConfirmed),e.hub.off("transaction-failed",a.onFailedOrDropped),e.hub.off("transaction-dropped",a.onFailedOrDropped),delete p(this,c,"f")[t]}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/SequentialPublishBatchHook.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/index.cjs",{"./TransactionController.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/TransactionController.cjs","./constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","./helpers/AccountsApiRemoteTransactionSource.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/AccountsApiRemoteTransactionSource.cjs","./types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils/gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs","./utils/prepare.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs","./utils/transaction-type.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs","./utils/utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.HARDFORK=a.INCOMING_TRANSACTIONS_SUPPORTED_CHAIN_IDS=a.CHAIN_IDS=a.normalizeTransactionParams=a.isEIP1559Transaction=a.mergeGasFeeEstimates=a.determineTransactionType=a.WalletDevice=a.UserFeeLevel=a.TransactionType=a.TransactionStatus=a.TransactionEnvelopeType=a.TransactionContainerType=a.SimulationTokenStandard=a.SimulationErrorCode=a.GasFeeEstimateType=a.GasFeeEstimateLevel=a.TransactionController=a.SPEED_UP_RATE=a.CANCEL_RATE=void 0;var n=e("./TransactionController.cjs");Object.defineProperty(a,"CANCEL_RATE",{enumerable:!0,get:function(){return n.CANCEL_RATE}}),Object.defineProperty(a,"SPEED_UP_RATE",{enumerable:!0,get:function(){return n.SPEED_UP_RATE}}),Object.defineProperty(a,"TransactionController",{enumerable:!0,get:function(){return n.TransactionController}});var s=e("./types.cjs");Object.defineProperty(a,"GasFeeEstimateLevel",{enumerable:!0,get:function(){return s.GasFeeEstimateLevel}}),Object.defineProperty(a,"GasFeeEstimateType",{enumerable:!0,get:function(){return s.GasFeeEstimateType}}),Object.defineProperty(a,"SimulationErrorCode",{enumerable:!0,get:function(){return s.SimulationErrorCode}}),Object.defineProperty(a,"SimulationTokenStandard",{enumerable:!0,get:function(){return s.SimulationTokenStandard}}),Object.defineProperty(a,"TransactionContainerType",{enumerable:!0,get:function(){return s.TransactionContainerType}}),Object.defineProperty(a,"TransactionEnvelopeType",{enumerable:!0,get:function(){return s.TransactionEnvelopeType}}),Object.defineProperty(a,"TransactionStatus",{enumerable:!0,get:function(){return s.TransactionStatus}}),Object.defineProperty(a,"TransactionType",{enumerable:!0,get:function(){return s.TransactionType}}),Object.defineProperty(a,"UserFeeLevel",{enumerable:!0,get:function(){return s.UserFeeLevel}}),Object.defineProperty(a,"WalletDevice",{enumerable:!0,get:function(){return s.WalletDevice}});var i=e("./utils/transaction-type.cjs");Object.defineProperty(a,"determineTransactionType",{enumerable:!0,get:function(){return i.determineTransactionType}});var r=e("./utils/gas-flow.cjs");Object.defineProperty(a,"mergeGasFeeEstimates",{enumerable:!0,get:function(){return r.mergeGasFeeEstimates}});var o=e("./utils/utils.cjs");Object.defineProperty(a,"isEIP1559Transaction",{enumerable:!0,get:function(){return o.isEIP1559Transaction}}),Object.defineProperty(a,"normalizeTransactionParams",{enumerable:!0,get:function(){return o.normalizeTransactionParams}});var c=e("./constants.cjs");Object.defineProperty(a,"CHAIN_IDS",{enumerable:!0,get:function(){return c.CHAIN_IDS}});var l=e("./helpers/AccountsApiRemoteTransactionSource.cjs");Object.defineProperty(a,"INCOMING_TRANSACTIONS_SUPPORTED_CHAIN_IDS",{enumerable:!0,get:function(){return l.SUPPORTED_CHAIN_IDS}});var d=e("./utils/prepare.cjs");Object.defineProperty(a,"HARDFORK",{enumerable:!0,get:function(){return d.HARDFORK}})}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/index.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.createModuleLogger=a.incomingTransactionsLogger=a.projectLogger=void 0;const n=e("@metamask/utils");Object.defineProperty(a,"createModuleLogger",{enumerable:!0,get:function(){return n.createModuleLogger}}),a.projectLogger=(0,n.createProjectLogger)("transaction-controller"),a.incomingTransactionsLogger=(0,n.createModuleLogger)(a.projectLogger,"incoming-transactions")}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs",{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){var n,s,i,r,o,c,l,d,m,u;Object.defineProperty(a,"__esModule",{value:!0}),a.SimulationErrorCode=a.SimulationTokenStandard=a.GasFeeEstimateType=a.GasFeeEstimateLevel=a.UserFeeLevel=a.TransactionEnvelopeType=a.TransactionContainerType=a.TransactionType=a.WalletDevice=a.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"}(n||(a.TransactionStatus=n={})),function(e){e.MM_MOBILE="metamask_mobile",e.MM_EXTENSION="metamask_extension",e.OTHER="other_device"}(s||(a.WalletDevice=s={})),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.perpsAcrossDeposit="perpsAcrossDeposit",e.perpsDeposit="perpsDeposit",e.perpsDepositAndOrder="perpsDepositAndOrder",e.perpsRelayDeposit="perpsRelayDeposit",e.personalSign="personal_sign",e.predictAcrossDeposit="predictAcrossDeposit",e.predictBuy="predictBuy",e.predictClaim="predictClaim",e.predictDeposit="predictDeposit",e.predictDepositAndOrder="predictDepositAndOrder",e.predictSell="predictSell",e.predictWithdraw="predictWithdraw",e.predictRelayDeposit="predictRelayDeposit",e.relayDeposit="relayDeposit",e.retry="retry",e.revokeDelegation="revokeDelegation",e.simpleSend="simpleSend",e.signTypedData="eth_signTypedData",e.smart="smart",e.stakingClaim="stakingClaim",e.stakingDeposit="stakingDeposit",e.stakingUnstake="stakingUnstake",e.swap="swap",e.swapAndSend="swapAndSend",e.swapApproval="swapApproval",e.tokenMethodApprove="approve",e.tokenMethodSafeTransferFrom="safetransferfrom",e.tokenMethodTransfer="transfer",e.tokenMethodTransferFrom="transferfrom",e.tokenMethodSetApprovalForAll="setapprovalforall",e.tokenMethodIncreaseAllowance="increaseAllowance",e.shieldSubscriptionApprove="shieldSubscriptionApprove"}(i||(a.TransactionType=i={})),function(e){e.EnforcedSimulations="enforcedSimulations"}(r||(a.TransactionContainerType=r={})),function(e){e.legacy="0x0",e.accessList="0x1",e.feeMarket="0x2",e.setCode="0x4"}(o||(a.TransactionEnvelopeType=o={})),function(e){e.CUSTOM="custom",e.DAPP_SUGGESTED="dappSuggested",e.MEDIUM="medium"}(c||(a.UserFeeLevel=c={})),function(e){e.Low="low",e.Medium="medium",e.High="high"}(l||(a.GasFeeEstimateLevel=l={})),function(e){e.FeeMarket="fee-market",e.Legacy="legacy",e.GasPrice="eth_gasPrice"}(d||(a.GasFeeEstimateType=d={})),function(e){e.erc20="erc20",e.erc721="erc721",e.erc1155="erc1155"}(m||(a.SimulationTokenStandard=m={})),function(e){e.ChainNotSupported="chain-not-supported",e.Disabled="disabled",e.InvalidResponse="invalid-response",e.Reverted="reverted"}(u||(a.SimulationErrorCode=u={}))}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/balance-changes.cjs",{"../api/simulation-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs","../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","../errors.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/errors.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./balance.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.getBalanceChanges=a.SupportedToken=void 0;const s=e("@ethersproject/abi"),i=e("@metamask/controller-utils"),r=e("@metamask/metamask-eth-abis"),o=e("@metamask/utils"),c=n(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||(a.SupportedToken=p={}));const g=(0,o.createModuleLogger)(h.projectLogger,"balance-changes"),k=["Transfer","TransferSingle","TransferBatch","Deposit","Withdrawal"],w={[p.ERC20]:{abi:r.abiERC20,standard:f.SimulationTokenStandard.erc20},[p.ERC721]:{abi:r.abiERC721,standard:f.SimulationTokenStandard.erc721},[p.ERC1155]:{abi:r.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}},b=["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 s.Interface(r.abiERC721);case f.SimulationTokenStandard.erc1155:return new s.Interface(r.abiERC1155);default:return new s.Interface(r.abiERC20)}}function v(e,t,a){const n=_(t.standard);try{if(t.standard===f.SimulationTokenStandard.erc721){const t=n.decodeFunctionResult("ownerOf",a.return);return t[0].toLowerCase()===e.toLowerCase()?"0x1":"0x0"}const s=n.decodeFunctionResult("balanceOf",a.return);return(0,i.toHex)(s[0])}catch(e){throw g("Failed to decode balance transaction",e,{token:t,response:a}),new u.SimulationError(`Failed to decode balance transaction for token ${t.address}: ${String(e)}`)}}function E(e,t,a){const n=_(e);switch(e){case f.SimulationTokenStandard.erc721:return n.encodeFunctionData("ownerOf",[a]);case f.SimulationTokenStandard.erc1155:return n.encodeFunctionData("balanceOf",[t,a]);default:return n.encodeFunctionData("balanceOf",[t])}}function S(e){return[...e.logs??[],...(e.calls??[]).map(e=>S(e)).flat()]}function I(e){if(!e)return[];return[...e.error?[e.error]:[],...(e.calls??[]).flatMap(e=>I(e))]}function P(e,t,a=0){const n=(0,i.hexToBN)(t).add(new c.default(a)),s=(0,i.hexToBN)(e),r=n.sub(s),o=r.isNeg(),l=(0,i.toHex)(r.abs());return r.isZero()?(g("Balance change is zero"),undefined):{previousBalance:e,newBalance:(0,i.toHex)(n),difference:l,isDecrease:o}}async function C({request:e,params:t,before:a=[],after:n=[]}){const{blockTime:s,chainId:r,ethQuery:o,getSimulationConfig:m,txParams:u}=e,{authorizationList:h}=u,f=u.from,p=h?.map(e=>({address:e.address,from:f})),k=[...a,{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},...n],w=function(e){const{txParams:t}=e,a=(0,i.hexToBN)(t.gas??"0x0"),n=(0,i.hexToBN)(t.maxFeePerGas??t.gasPrice??"0x0"),s=(0,i.hexToBN)(t.value??"0x0"),r=(e.nestedTransactions??[]).map(e=>(0,i.hexToBN)(e.value??"0x0")).reduce((e,t)=>e.add(t),new c.default(0));return a.mul(n).add(s).add(r)}(e),b=(0,i.toHex)(w);g("Required balance",b);const{balanceRaw:y}=await(0,l.getNativeBalance)(f,o),T=(0,i.toHex)(y),x=(0,i.hexToBN)(T);g("Current balance",T);const _=x.lt(w);return await(0,d.simulateTransactions)(r,{...t,getSimulationConfig:m,transactions:k,withGas:!0,withDefaultBlockOverrides:!0,...s&&{blockOverrides:{...t?.blockOverrides,time:(0,i.toHex)(s)}},..._&&{overrides:{...t?.overrides,[f]:{...t?.overrides?.[f],balance:b}}}})}a.getBalanceChanges=async function(e){let t;g("Request",e);try{const a=await C({request:e,params:{withCallTrace:!0,withLogs:!0}}),n=a.transactions?.[0];t=I(n?.callTrace);const i=n?.error;if(i)throw new u.SimulationError(i);const r=function(e,t){const a=t.transactions[0];if(!a)return undefined;const{txParams:n}=e,s=n.from,{stateDiff:i}=a,r=i?.pre?.[s]?.balance,o=i?.post?.[s]?.balance;if(!r||!o)return undefined;return P(r,o,a.gasCost)}(e,a),o=function(e){const t=S(e.transactions[0]?.callTrace??{});g("Extracted logs",t);const a=function(){const e=Object.values(p);return new Map(e.map(e=>{const{abi:t}=w[e];return[e,new s.Interface(t)]}))}();return t.map(e=>{const t=function(e,t){const a=Object.values(p);for(const n of a)try{const a=t.get(n),{abi:s,standard:i}=w[n];return{...a.parseLog(e),abi:s,standard:i}}catch{continue}return undefined}(e,a);if(!t)return g("Failed to parse log",e),undefined;const n=t.abi.find(e=>e.name===t.name)?.inputs;if(!n)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 s=function(e,t){return e.reduce((e,a,n)=>{const s=t[n].name.replace("_",""),i=y(a);return e[s]=i,e},{})}(t.args,n);return{contractAddress:e.address,tokenStandard:t.standard,name:t.name,args:s,abi:t.abi}}).filter(e=>e!==undefined)}(a);g("Parsed events",o);const c=await async function(e,t){const{txParams:a}=e,n=a.from,s=function(e,t){const a=new Set,n=new Map,s=new Map,i=e.txParams.from,r=t.filter(e=>[e.args.from,e.args.to].includes(i));g("Filtered user events",r);for(const e of r){const t=x(e);g("Extracted token IDs",t);for(const r of t){const t={address:e.contractAddress,standard:e.tokenStandard,id:r},o=JSON.stringify(t);if(a.has(o)){g("Ignoring additional event with same contract and token ID",t);continue}a.add(o);const c=E(e.tokenStandard,i,r),l={from:i,to:e.contractAddress,data:c};T(e)||n.set(t,l),s.set(t,l)}}return{before:n,after:s}}(e,t);g("Generated balance transactions",[...s.after.values()]);const i=s.before.size+s.after.size+1;if(1===i)return[];const r=await C({request:e,before:[...s.before.values()],after:[...s.after.values()]});if(g("Balance simulation response",r),r.transactions.length!==i)throw new u.SimulationInvalidResponseError;let o=0;return[...s.after.keys()].map((e,t)=>{const a=P(!s.before.get(e)?"0x0":v(n,e,r.transactions[o++]),v(n,e,r.transactions[t+s.before.size+1]));return a?{...e,...a}:undefined}).filter(e=>e!==undefined)}(e,o),l=n?.gasUsed;return{simulationData:{callTraceErrors:t,nativeBalanceChange:r,tokenBalanceChanges:c},gasUsed:l}}catch(a){g("Failed to get balance changes",a,e);let n=a;b.some(e=>n.message?.includes(e))&&(n=new u.SimulationRevertedError);const{code:s,message:i}=n;return{simulationData:{callTraceErrors:t,tokenBalanceChanges:[],error:{code:s,message:i}},gasUsed:undefined}}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/balance-changes.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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/eip-5792-middleware/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.isNativeBalanceSufficientForGas=a.getNativeBalance=void 0;const n=e("@metamask/controller-utils"),s=e("bignumber.js");async function i(e,t){const a=await(0,n.query)(t,"getBalance",[e,"latest"]),i=new s.BigNumber(a).toString(10);return{balanceHuman:new s.BigNumber(i).shiftedBy(-18).toString(10),balanceRaw:i}}a.getNativeBalance=i,a.isNativeBalanceSufficientForGas=async function(e,t){const a=e.txParams.from,n=new s.BigNumber(e.txParams.gas??"0x0").multipliedBy(e.txParams.maxFeePerGas??e.txParams.gasPrice??"0x0"),{balanceRaw:r}=await i(a,t);return n.isLessThanOrEqualTo(r)}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/balance.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs",{"../gas-flows/DefaultGasFeeFlow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.cjs","../helpers/GasFeePoller.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.cjs","../hooks/CollectPublishHook.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/CollectPublishHook.cjs","../hooks/SequentialPublishBatchHook.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/hooks/SequentialPublishBatchHook.cjs","../index.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/index.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs","./gas.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas.cjs","./validation.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.isAtomicBatchSupported=a.addTransactionBatch=a.ERROR_MESSAGE_NO_UPGRADE_CONTRACT=void 0;const n=e("@metamask/controller-utils"),s=e("@metamask/rpc-errors"),i=e("@metamask/utils"),r=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"),w=(0,i.createModuleLogger)(g.projectLogger,"batch");function b(){const e=(0,r.v4)(),t=new Uint8Array((0,r.parse)(e));return(0,i.bytesToHex)(t)}async function y(e,t,a,s,i,r){const{assetsFiatValues:o,existingTransaction:c,params:l,type:d}=t,{addTransaction:u,getTransaction:f,request:p,updateTransaction:g}=s,{from:k,networkClientId:b,origin:y}=p;if(c){const{id:t,onPublish:i}=c;let o=f(t);const d=o.txParams.nonce;let{signedTransaction:m}=c;const u=d?parseInt(d,16):undefined,h=r>0&&u!==undefined?u+r:undefined;if(g({transactionId:t},t=>{t.batchId=e,h&&(t.txParams.nonce=(0,n.toHex)(h))}),h){const e=await T({transactionId:t,request:s});m=e.newSignature,o=e.transactionMeta}return a(o,m).then(i).catch(()=>{}),w("Processed existing transaction with hook",{id:t,params:l}),{id:t,params:l}}const x={...i,txParams:{...l,from:k,gas:i?.gas??l.gas}};i&&(0,h.updateTransactionGasEstimates)({txMeta:x,userFeeLevel:m.GasFeeEstimateLevel.Medium});const{transactionMeta:_}=await u(x.txParams,{assetsFiatValues:o,batchId:e,disableGasBuffer:!0,networkClientId:b,origin:y,publishHook:a,requireApproval:!1,type:d}),{id:v,txParams:E}=_,S={data:E.data,gas:E.gas,maxFeePerGas:E.maxFeePerGas,maxPriorityFeePerGas:E.maxPriorityFeePerGas,to:E.to,value:E.value};return w("Processed new transaction with hook",{id:v,params:S,type:d}),{id:v,params:S,type:d}}async function T({request:e,transactionId:t}){const{getTransaction:a,signTransaction:n}=e,s=a(t);w("Re-signing existing transaction",{transactionId:t,txParams:s.txParams});const i=await n(s);if(!i)throw new Error("Failed to re-sign transaction");const r=a(t);return w("New signature",i),{newSignature:i,transactionMeta:r}}a.ERROR_MESSAGE_NO_UPGRADE_CONTRACT="Upgrade contract address not found",a.addTransactionBatch=async function(e){const{getInternalAccounts:t,messenger:i,request:r}=e,h=(0,c.getBatchSizeLimit)(i);if((0,d.validateBatchRequest)({internalAccounts:t(),request:r,sizeLimit:h}),w("Adding",r),!r.disable7702)try{return await async function(e){const{addTransaction:t,getChainId:n,messenger:i,publicKeyEIP7702:r,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:S,skipInitialGasEstimate:I,transactions:P,validateSecurity:C}=l,j=n(g),A=e.getEthQuery(g),F=(0,o.doesChainSupportEIP7702)(j,i);if(!F)throw w("Chain does not support EIP-7702",j),s.rpcErrors.internal("Chain does not support EIP-7702");if(!r)throw s.rpcErrors.internal(o.ERROR_MESSGE_PUBLIC_KEY);let D=!1;if(!u){const{delegationAddress:e,isSupported:t}=await(0,o.isAccountUpgradedToEIP7702)(h,j,r,i,A);if(w("Account",{delegationAddress:e,isSupported:t}),!t&&e&&!x)throw w("Account upgraded to unsupported contract",h,e),s.rpcErrors.internal("Account upgraded to unsupported contract");D=!t,D&&e&&w("Overwriting authorization as already upgraded",{current:e})}const M=await Promise.all(P.map(e=>async function(e,t,a){const{from:n}=e,{params:s,type:i}=t;if(i)return{...s,type:i};const{type:r}=await(0,m.determineTransactionType)({from:n,...s},a);return{...s,type:r}}(l,e,A))),O={...(0,o.generateEIP7702BatchTransaction)(h,M),from:h,gas:p,maxFeePerGas:M[0]?.maxFeePerGas,maxPriorityFeePerGas:M[0]?.maxPriorityFeePerGas};if(D){const e=(0,c.getEIP7702UpgradeContractAddress)(j,i,r);if(!e)throw s.rpcErrors.internal(a.ERROR_MESSAGE_NO_UPGRADE_CONTRACT);O.type=k.TransactionEnvelopeType.setCode,O.authorizationList=[{address:e}]}if(C){const e={method:"eth_sendTransaction",params:[{...O,authorizationList:undefined,type:k.TransactionEnvelopeType.feeMarket}],delegationMock:O.authorizationList?.[0]?.address,origin:y};w("Security request",e),C(e,j).catch(e=>{w("Security validation failed",e)})}w("Adding batch transaction",O,g);const N=d??b(),L=S?{securityAlertId:S}:undefined,G=P.find(e=>e.existingTransaction)?.existingTransaction;if(G)return await async function({batchId:e,existingTransaction:t,nestedTransactions:a,request:n,txParams:s}){const{getTransaction:i,estimateGas:r,updateTransaction:o}=n,c=i(t.id);if(!c)throw new Error("Existing transaction not found");w("Converting existing transaction to 7702",{batchId:e,txParams:s});const{networkClientId:l}=c,d=await r(s,l);w("Estimated gas for converted EIP-7702 transaction",d),o({transactionId:c.id},t=>{var n;t.batchId=e,t.nestedTransactions=a,t.txParams=s,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,(n=t.txParams).type??(n.type=k.TransactionEnvelopeType.feeMarket)});const{newSignature:m}=await T({request:n,transactionId:c.id});t.onPublish?.({transactionHash:undefined,newSignature:m}),w("Transaction updated to EIP-7702",{batchId:e,txParams:s,newSignature:m})}({batchId:N,existingTransaction:G,nestedTransactions:M,request:e,txParams:O}),{batchId:N};const{result:B}=await t(O,{batchId:N,gasFeeToken:f,isGasFeeIncluded:l.isGasFeeIncluded,isGasFeeSponsored:l.isGasFeeSponsored,nestedTransactions:M,networkClientId:g,origin:y,requestId:_,requireApproval:E,requiredAssets:v,securityAlertResponse:L,skipInitialGasEstimate:I,type:k.TransactionType.batch}),R=await B;return w("Batch transaction added",{batchId:N,transactionHash:R}),{batchId:N}}(e)}catch(e){if(!(e instanceof s.JsonRpcError&&"Chain does not support EIP-7702"===e.message))throw e}return await async function(e){const{messenger:t,publishBatchHook:a,request:i,update:r}=e,{batchId:o,from:c,networkClientId:d,origin:h,requireApproval:g,transactions:k}=i;let T,x=!1;w("Adding transaction batch using hook",i);const _=new p.SequentialPublishBatchHook({publishTransaction:e.publishTransaction,getTransaction:e.getTransaction,getEthQuery:e.getEthQuery,getPendingTransactionTracker:e.getPendingTransactionTracker});let{disable7702:v,disableSequential:E}=i;const{disableHook:S,useHook:I}=i;I&&(v=!0,E=!0);let P,C=null;!S&&a?C=a:E||(C=_.getHook(),x=!0);if(!C)throw w("No supported batch methods found",{disable7702:v,disableHook:S,disableSequential:E}),s.rpcErrors.internal("Can't process batch");const j=o??b(),A=k.map(e=>({...e,origin:h})),F=A.length,D=new f.CollectPublishHook(F);try{g&&(P=await async function({batchId:e,request:t}){const{messenger:a,request:n,isSimulationEnabled:s,getChainId:i,getEthQuery:r,getGasFeeEstimates:o,getSimulationConfig:c,update:d}=t,{from:h,origin:f,networkClientId:p,transactions:g}=n,k=r(p);if(!s())throw new Error("Cannot create transaction batch as simulation not supported");w("Preparing approval data for batch");const b=i(p),{totalGasLimit:y}=await(0,l.simulateGasBatch)({chainId:b,from:h,getSimulationConfig:c,transactions:g}),T=(E={chainId:b,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:a,transactionMeta:{...T,txParams:{from:h,gas:y},time:Date.now()}});var E;return T.gasFeeEstimates=v.estimates,w("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 a=String(e.id),{origin:s}=e,i=n.ApprovalType.TransactionBatch,r={txBatchId:a};return w("Requesting approval for transaction batch",a),await t.call("ApprovalController:addRequest",{id:a,origin:s??n.ORIGIN_METAMASK,requestData:r,expectsResult:!0,type:i},!0)}(P,t)).resultCallbacks);const a=D.getHook(),s=[];let i=0;for(const t of A){const n=await y(j,t,a,e,P,i);s.push(n),i+=1}const{signedTransactions:r}=await D.ready(),o={from:c,networkClientId:d,transactions:s.map((e,t)=>({...e,signedTx:r[t]}))};w("Calling publish batch hook",o);let h=await C(o);if(w("Publish batch hook result",h),!h&&!x&&!E){w("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 D.success(f),T?.success(),w("Completed batch transaction with hook",f),{batchId:j}}catch(e){throw w("Publish batch hook failed",e),D.error(e),T?.error(e),e}finally{w("Cleaning up publish batch hook",j),function(e,t){e(e=>{e.transactionBatches=e.transactionBatches.filter(e=>e.id!==t)})}(r,j)}}(e)},a.isAtomicBatchSupported=async function(e){const{address:t,chainIds:a,getEthQuery:n,messenger:i,publicKeyEIP7702:r}=e;if(!r)throw s.rpcErrors.internal(o.ERROR_MESSGE_PUBLIC_KEY);const l=(0,c.getEIP7702SupportedChains)(i).filter(e=>!a||a.includes(e)),d=(await Promise.all(l.map(async e=>{try{const a=n(e),{isSupported:s,delegationAddress:l}=await(0,o.isAccountUpgradedToEIP7702)(t,e,r,i,a);return{chainId:e,delegationAddress:l,isSupported:s,upgradeContractAddress:(0,c.getEIP7702UpgradeContractAddress)(e,i,r)}}catch(t){return w("Error checking atomic batch support",e,t),undefined}}))).filter(e=>Boolean(e));return w("Atomic batch supported results",d),d}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.signAuthorizationList=a.generateEIP7702BatchTransaction=a.isAccountUpgradedToEIP7702=a.getDelegationAddress=a.doesChainSupportEIP7702=a.ERROR_MESSGE_PUBLIC_KEY=a.CALLS_SIGNATURE=a.BATCH_FUNCTION_NAME=a.DELEGATION_PREFIX=void 0;const n=e("@ethersproject/abi"),s=e("@ethersproject/contracts"),i=e("@metamask/controller-utils"),r=e("@metamask/utils"),o=e("./feature-flags.cjs"),c=e("../constants.cjs"),l=e("../logger.cjs");a.DELEGATION_PREFIX="0xef0100",a.BATCH_FUNCTION_NAME="execute",a.CALLS_SIGNATURE="(address,uint256,bytes)[]",a.ERROR_MESSGE_PUBLIC_KEY="EIP-7702 public key not specified";const d=(0,r.createModuleLogger)(l.projectLogger,"eip-7702");async function m(e,t){const n=await(0,i.query)(t,"eth_getCode",[e]),s=(0,r.add0x)(n?.toLowerCase?.()??"");return 48===n?.length&&s.startsWith(a.DELEGATION_PREFIX)?(0,r.add0x)(s.slice(a.DELEGATION_PREFIX.length)):undefined}async function u(e,t,a,n){const s=function(e,t,a){const{chainId:n,nonce:s}=e,{txParams:r,chainId:o}=t,{nonce:c}=r,l=n??o;let m=s;m??(m=(0,i.toHex)(parseInt(c,16)+1+a));const u={...e,chainId:l,nonce:m};return d("Prepared authorization",u),u}(e,t,n),{txParams:o}=t,{from:c}=o,{address:l,chainId:m,nonce:u}=s,h=parseInt(m,16),f=parseInt(u,16),p=await a.call("KeyringController:signEip7702Authorization",{chainId:h,contractAddress:l,from:c,nonce:f}),g=p.slice(0,66),k=(0,r.add0x)(p.slice(66,130)),w=parseInt(p.slice(130,132),16),b={address:l,chainId:m,nonce:u,r:g,s:k,yParity:(0,i.toHex)(w-27==0?0:1)};return d("Signed authorization",b),b}a.doesChainSupportEIP7702=function(e,t){return(0,o.getEIP7702SupportedChains)(t).some(t=>t.toLowerCase()===e.toLowerCase())},a.getDelegationAddress=m,a.isAccountUpgradedToEIP7702=async function(e,t,a,n,s){const i=(0,o.getEIP7702ContractAddresses)(t,n,a),r=await m(e,s),c=Boolean(r&&i.some(e=>e.toLowerCase()===r.toLowerCase()));return{delegationAddress:r,isSupported:c}},a.generateEIP7702BatchTransaction=function(e,t){const i=s.Contract.getInterface(c.ABI_IERC7821),r=t.map(e=>{const{data:t,to:a,value:n}=e;return[a??"0x0000000000000000000000000000000000000000",n??"0x0",t??"0x"]}),o="0x01".padEnd(66,"0"),l=n.defaultAbiCoder.encode([a.CALLS_SIGNATURE],[r]),m=i.encodeFunctionData(a.BATCH_FUNCTION_NAME,[o,l]);return d("Transaction data",m),{data:m,to:e}},a.signAuthorizationList=async function({authorizationList:e,messenger:t,transactionMeta:a}){if(!e)return undefined;const n=[];let s=0;for(const i of e){const e=await u(i,a,t,s);n.push(e),s+=1}return n}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.validateConfirmedExternalTransaction=void 0;const n=e("@metamask/rpc-errors"),s=e("../types.cjs");a.validateConfirmedExternalTransaction=function(e,t,a){if(!e?.txParams)throw n.rpcErrors.invalidParams('"transactionMeta" or "transactionMeta.txParams" is missing');if(e.status!==s.TransactionStatus.confirmed)throw n.rpcErrors.invalidParams('External transaction status should be "confirmed"');const i=e.txParams.nonce;if(a&&a.length>0){if(a.find(e=>e.txParams?.nonce===i))throw n.rpcErrors.invalidParams("External transaction nonce should not be in pending txs")}if(t&&t.length>0){if(t.find(e=>e.txParams?.nonce===i))throw n.rpcErrors.invalidParams("External transaction nonce should not be in confirmed txs")}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","./signature.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/signature.cjs","./utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.isIncomingTransactionsUseBackendWebSocketServiceEnabled=a.getTimeoutAttempts=a.getIncomingTransactionsPollingInterval=a.getGasEstimateBuffer=a.getGasEstimateFallback=a.getGasFeeRandomisation=a.getAcceleratedPollingParams=a.getTransactionHistoryLimit=a.getSubmitHistoryLimit=a.getBatchSizeLimit=a.getEIP7702UpgradeContractAddress=a.getEIP7702ContractAddresses=a.getEIP7702SupportedChains=a.FeatureFlag=void 0;const n=e("@metamask/utils"),s=e("./signature.cjs"),i=e("./utils.cjs"),r=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||(a.FeatureFlag=o={}));const c=(0,n.createModuleLogger)(r.projectLogger,"feature-flags");function l(e,t,a){const n=d(t);return(n?.[o.EIP7702]?.contracts?.[e.toLowerCase()]??[]).filter(t=>(0,s.isValidSignature)([t.address,(0,i.padHexToEvenLength)(e)],t.signature,a)).map(e=>e.address)}function d(e){const t=e.call("RemoteFeatureFlagController:getState").remoteFeatureFlags;return c("Retrieved feature flags",t),t}a.getEIP7702SupportedChains=function(e){const t=d(e);return t?.[o.EIP7702]?.supportedChains??[]},a.getEIP7702ContractAddresses=l,a.getEIP7702UpgradeContractAddress=function(e,t,a){return l(e,t,a)?.[0]},a.getBatchSizeLimit=function(e){const t=d(e);return t?.[o.Transactions]?.batchSizeLimit??10},a.getSubmitHistoryLimit=function(e){const t=d(e);return t?.[o.Transactions]?.submitHistoryLimit??100},a.getTransactionHistoryLimit=function(e){const t=d(e);return t?.[o.Transactions]?.transactionHistoryLimit??40},a.getAcceleratedPollingParams=function(e,t){const a=d(t),n=a?.[o.Transactions]?.acceleratedPolling,s=n?.perChainConfig?.[e]?.countMax??n?.defaultCountMax??10,i=n?.perChainConfig?.[e]?.intervalMs??n?.defaultIntervalMs??3e3;return{blockTime:n?.perChainConfig?.[e]?.blockTime??12e3,countMax:s,intervalMs:i}},a.getGasFeeRandomisation=function(e){const t=d(e),a=t?.[o.Transactions]?.gasFeeRandomisation??{};return{randomisedGasFeeDigits:a.randomisedGasFeeDigits??{},preservedNumberOfDigits:a.preservedNumberOfDigits}},a.getGasEstimateFallback=function(e,t){const a=d(t),n=a?.[o.Transactions]?.gasEstimateFallback,s=n?.perChainConfig?.[e],i=s?.percentage??n?.default?.percentage??35;return{fixed:s?.fixed??n?.default?.fixed,percentage:i}},a.getGasEstimateBuffer=function({chainId:e,isCustomRPC:t,isUpgradeWithDataToSelf:a,messenger:n}){const s=d(n),i=s?.[o.GasBuffer],r=i?.perChainConfig?.[e],c=t?undefined:r?.included,l=t?undefined:i?.included;return(a?r?.eip7702:undefined)??c??r?.base??l??i?.default??1},a.getIncomingTransactionsPollingInterval=function(e){const t=d(e);return t?.[o.IncomingTransactions]?.pollingIntervalMs??24e4},a.getTimeoutAttempts=function(e,t){const a=d(t),n=a?.[o.Transactions]?.timeoutAttempts;return n?.perChainConfig?.[e]??n?.default},a.isIncomingTransactionsUseBackendWebSocketServiceEnabled=function(e){const t=d(e);return t?.[o.IncomingTransactions]?.useBackendWebSocketService??!1}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/feature-flags.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/accounts-api.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./transaction-type.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs","./validation.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.updateFirstTimeInteraction=void 0;const n=e("@metamask/utils"),s=e("./transaction-type.cjs"),i=e("./validation.cjs"),r=e("../api/accounts-api.cjs"),o=e("../logger.cjs"),c=e("../types.cjs"),l=[c.TransactionType.tokenMethodTransfer,c.TransactionType.tokenMethodTransferFrom];function d(e){const{data:t,to:a}=e?.txParams??{};if(t&&l.includes(e?.type)){const e=(0,s.decodeTransactionData)(t);return e?.args?._to??e?.args?.to??a}return a}a.updateFirstTimeInteraction=async function({existingTransactions:e,getTransaction:t,isFirstTimeInteractionEnabled:a,trace:s,traceContext:c,transactionMeta:l,updateTransaction:m}){if(!a())return;const{chainId:u,id:h,txParams:{from:f}}=l,p=d(l),g={chainId:(0,n.hexToNumber)(u),to:p,from:f};(0,i.validateParamTo)(p);const k=p?.toLowerCase();if(!e.find(e=>e.id!==h&&e.chainId===u&&e.txParams?.from?.toLowerCase()===f?.toLowerCase()&&d(e)?.toLowerCase()===k))try{const{count:e}=await s({name:"Account Address Relationship",parentContext:c},()=>(0,r.getAccountAddressRelationship)(g)),a=e===undefined?undefined:0===e;if(!t(h))return void(0,o.projectLogger)("Cannot update first time interaction as transaction not found",h);m({transactionId:h,note:"TransactionController#updateFirstInteraction - Update first time interaction"},e=>{e.isFirstTimeInteraction=a}),(0,o.projectLogger)("Updated first time interaction",h,{isFirstTimeInteraction:a})}catch(e){(0,o.projectLogger)("Error fetching account address relationship, skipping first time interaction update",e)}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/first-time-interaction.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","./balance.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/balance.cjs","./batch.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/batch.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.checkGasFeeTokenBeforePublish=a.getGasFeeTokens=void 0;const n=e("@metamask/rpc-errors"),s=e("@metamask/utils"),i=e("./balance.cjs"),r=e("./batch.cjs"),o=e("./eip7702.cjs"),c=e("./feature-flags.cjs"),l=e("../api/simulation-api.cjs"),d=e("../logger.cjs"),m=(0,s.createModuleLogger)(d.projectLogger,"gas-fee-tokens");a.getGasFeeTokens=async function({chainId:e,isEIP7702GasFeeTokensEnabled:t,messenger:a,publicKeyEIP7702:s,transactionMeta:i,getSimulationConfig:d}){const{delegationAddress:u,txParams:h}=i,{authorizationList:f}=h,p=h.data,g=h.from,k=h.to,w=h.value;m("Request",{chainId:e,txParams:h});const b=await t(i)&&(0,o.doesChainSupportEIP7702)(e,a);let y=f?.map(e=>({address:e.address,from:g}));!b||u||y||(y=function({chainId:e,from:t,messenger:a,publicKeyEIP7702:s}){if(!s)throw n.rpcErrors.internal(o.ERROR_MESSGE_PUBLIC_KEY);const i=(0,c.getEIP7702UpgradeContractAddress)(e,a,s);if(!i)throw n.rpcErrors.internal(r.ERROR_MESSAGE_NO_UPGRADE_CONTRACT);return[{address:i,from:t}]}({chainId:e,from:g,messenger:a,publicKeyEIP7702:s}));try{const t=await(0,l.simulateTransactions)(e,{getSimulationConfig:d,transactions:[{authorizationList:y,data:p,from:g,to:k,value:w}],suggestFees:{withTransfer:!0,withFeeTransfer:!0,with7702:b}});m("Response",t);const a=function(e){const t=e.transactions?.[0]?.fees?.[0],a=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:a}}(t);return m("Gas fee tokens",a),a}catch(e){return m("Failed to gas fee tokens",e),{gasFeeTokens:[],isGasFeeSponsored:!1}}},a.checkGasFeeTokenBeforePublish=async function({ethQuery:e,fetchGasFeeTokens:t,transaction:a,updateTransaction:n}){const{isGasFeeTokenIgnoredIfBalance:s,selectedGasFeeToken:r}=a;if(!r||!s)return;if(m("Checking gas fee token before publish",{selectedGasFeeToken:r}),await(0,i.isNativeBalanceSufficientForGas)(a,e))return m("Ignoring gas fee token before publish due to sufficient native balance"),void n(a.id,e=>{e.isExternalSign=!1,e.selectedGasFeeToken=undefined});const o=await t({...a,isExternalSign:!0});if(n(a.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()===r.toLowerCase()))throw new Error("Gas fee token not found and insufficient native balance");m("Publishing with selected gas fee token",{selectedGasFeeToken:r})}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-fee-tokens.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./gas-flow.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs","./swaps.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.gweiDecimalToWeiDecimal=a.gweiDecimalToWeiHex=a.updateGasFees=void 0;const n=e("@metamask/controller-utils"),s=e("@metamask/utils"),i=e("./gas-flow.cjs"),r=e("./swaps.cjs"),o=e("../logger.cjs"),c=e("../types.cjs"),l=(0,s.createModuleLogger)(o.projectLogger,"gas-fees");function d(e){return(0,n.toHex)((0,n.gweiDecToWEIBN)(e))}a.updateGasFees=async function(e){const{txMeta:t}=e,a={...t.txParams},o=r.SWAP_TRANSACTION_TYPES.includes(t.type)?undefined:e.getSavedGasFees(t.chainId),m=await async function(e){const{eip1559:t,ethQuery:a,gasFeeFlows:r,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,i.getGasFeeFlow)(m,r,d);try{const e=await o({networkClientId:u}),t=await h.getGasFees({ethQuery:a,gasFeeControllerData:e,messenger:d,transactionMeta:m}),n=t.estimates?.type;switch(n){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: ${n}`)}}catch(e){l("Failed to get suggested gas fees",e)}const f=await(0,n.query)(a,"gasPrice");return{gasPrice:f?(0,s.add0x)(f.toString(16)):undefined}}(e);l("Suggested gas fees",m);const u={...e,initialParams:a,savedGasFees:o,suggestedGasFees:m};t.txParams.maxFeePerGas=function(e){const{savedGasFees:t,eip1559:a,initialParams:n,suggestedGasFees:s}=e;if(!a)return undefined;if(t){const e=d(t.maxBaseFee);return l("Using maxFeePerGas from savedGasFees",e),e}if(n.maxFeePerGas)return l("Using maxFeePerGas from request",n.maxFeePerGas),n.maxFeePerGas;if(n.gasPrice&&!n.maxPriorityFeePerGas)return l("Setting maxFeePerGas to gasPrice from request",n.gasPrice),n.gasPrice;if(s.maxFeePerGas)return l("Using suggested maxFeePerGas",s.maxFeePerGas),s.maxFeePerGas;if(s.gasPrice)return l("Setting maxFeePerGas to suggested gasPrice",s.gasPrice),s.gasPrice;return l("maxFeePerGas not set"),undefined}(u),t.txParams.maxPriorityFeePerGas=function(e){const{eip1559:t,initialParams:a,savedGasFees:n,suggestedGasFees:s,txMeta:i}=e;if(!t)return undefined;if(n){const e=d(n.priorityFee);return l("Using maxPriorityFeePerGas from savedGasFees.priorityFee",e),e}if(a.maxPriorityFeePerGas)return l("Using maxPriorityFeePerGas from request",a.maxPriorityFeePerGas),a.maxPriorityFeePerGas;if(a.gasPrice&&!a.maxFeePerGas)return l("Setting maxPriorityFeePerGas to gasPrice from request",a.gasPrice),a.gasPrice;if(s.maxPriorityFeePerGas)return l("Using suggested maxPriorityFeePerGas",s.maxPriorityFeePerGas),s.maxPriorityFeePerGas;if(i.txParams.maxFeePerGas)return l("Setting maxPriorityFeePerGas to maxFeePerGas",i.txParams.maxFeePerGas),i.txParams.maxFeePerGas;return l("maxPriorityFeePerGas not set"),undefined}(u),t.txParams.gasPrice=function(e){const{eip1559:t,initialParams:a,suggestedGasFees:n}=e;if(t)return undefined;if(a.gasPrice)return l("Using gasPrice from request",a.gasPrice),a.gasPrice;if(n.maxFeePerGas)return l("Using suggested maxFeePerGas",n.maxFeePerGas),n.maxFeePerGas;if(n.gasPrice)return l("Using suggested gasPrice",n.gasPrice),n.gasPrice;return l("gasPrice not set"),undefined}(u),t.userFeeLevel=function(e){const{initialParams:t,savedGasFees:a,suggestedGasFees:s,txMeta:i}=e;if(a)return c.UserFeeLevel.CUSTOM;if(!t.maxFeePerGas&&!t.maxPriorityFeePerGas&&t.gasPrice)return i.origin===n.ORIGIN_METAMASK?c.UserFeeLevel.CUSTOM:c.UserFeeLevel.DAPP_SUGGESTED;if(!t.maxFeePerGas&&!t.maxPriorityFeePerGas&&s.maxFeePerGas&&s.maxPriorityFeePerGas)return c.UserFeeLevel.MEDIUM;if(!t.maxFeePerGas&&!t.maxPriorityFeePerGas&&s.gasPrice)return c.UserFeeLevel.MEDIUM;if(i.origin===n.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)},a.gweiDecimalToWeiHex=d,a.gweiDecimalToWeiDecimal=function(e){return(1e9*Number(e)).toString().split(".")[0]}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.mergeGasFeeEstimates=a.getGasFeeFlow=void 0;const n=e("@metamask/controller-utils"),s=e("../types.cjs");function i(e,t){return(0,n.weiHexToGweiDec)(e[t])}a.getGasFeeFlow=function(e,t,a){return t.find(t=>t.matchesTransaction({transactionMeta:e,messenger:a}))},a.mergeGasFeeEstimates=function({gasFeeControllerEstimates:e,transactionGasFeeEstimates:t}){const a=t.type;return a===s.GasFeeEstimateType.FeeMarket?Object.values(s.GasFeeEstimateLevel).reduce((a,s)=>{return{...a,[s]:(i=e?.[s],r=t[s],{...i,suggestedMaxFeePerGas:(0,n.weiHexToGweiDec)(r.maxFeePerGas),suggestedMaxPriorityFeePerGas:(0,n.weiHexToGweiDec)(r.maxPriorityFeePerGas)})};var i,r},{...e}):a===s.GasFeeEstimateType.Legacy?Object.values(s.GasFeeEstimateLevel).reduce((e,a)=>({...e,[a]:i(t,a)}),{}):a===s.GasFeeEstimateType.GasPrice?{gasPrice:(r=t,(0,n.weiHexToGweiDec)(r.gasPrice))}:e;var r}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas.cjs",{"../api/simulation-api.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/api/simulation-api.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/eip7702.cjs","./feature-flags.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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/eip-5792-middleware/node_modules/bignumber.js/bignumber.js"},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.simulateGasBatch=a.addGasBuffer=a.estimateGasBatch=a.estimateGas=a.updateGas=a.DUMMY_AUTHORIZATION_SIGNATURE=a.INTRINSIC_GAS=a.MAX_GAS_BLOCK_PERCENT=a.DEFAULT_GAS_MULTIPLIER=a.FIXED_GAS=a.log=void 0;const n=e("@metamask/controller-utils"),s=e("@metamask/utils"),i=e("bignumber.js"),r=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:i,isSimulationEnabled:r,getSimulationConfig:c,messenger:l,txParams:m}){const u={...m},{authorizationList:h,data:g,from:k,value:w,to:b}=u;if(i&&!r)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,n.query)(e,"getBlockByNumber",["latest",!1])}(t),x=(0,n.hexToBN)(y),{percentage:_,fixed:v}=(0,o.getGasEstimateFallback)(e,l),E=v?(0,n.toHex)(v):(0,n.BNToHex)((0,n.fractionBN)(x,_,100));(0,a.log)("Estimation fallback values",E),u.data=g?(0,s.add0x)(g):g,u.value=w??"0x0",u.authorizationList=function(e,t){return e?.map(e=>({...e,chainId:e.chainId??t,nonce:e.nonce??"0x1",r:e.r??a.DUMMY_AUTHORIZATION_SIGNATURE,s:e.s??a.DUMMY_AUTHORIZATION_SIGNATURE,yParity:e.yParity??"0x1"}))}(u.authorizationList,e),delete u.gasPrice,delete u.maxFeePerGas,delete u.maxPriorityFeePerGas;let S,I=E;const P=m.type===d.TransactionEnvelopeType.setCode&&Boolean(h?.length)&&Boolean(g)&&"0x"!==g&&k?.toLowerCase()===b?.toLowerCase();try{I=r&&P?await async function(e,t,s,i){const r=await(0,n.query)(t,"estimateGas",[{...e,data:"0x"}]);(0,a.log)("Upgrade only gas",r);const o=e.authorizationList?.[0].address;let c;try{c=await f({chainId:s,delegationAddress:o,getSimulationConfig:i,transaction:e})}catch(e){(0,a.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,a.log)("Error while estimating data portion of upgrade",e),e}(0,a.log)("Success estimating data portion of upgrade",c)}(0,a.log)("Execute gas",c);const l=(0,n.BNToHex)((0,n.hexToBN)(r).add((0,n.hexToBN)(c)).subn(a.INTRINSIC_GAS));return(0,a.log)("Total type 4 gas",l),l}(u,t,e,c):i&&r?await f({chainId:e,getSimulationConfig:c,transaction:u}):await p(t,u)}catch(e){S={reason:e.message,errorKey:e.errorKey,debug:{blockNumber:T,blockGasLimit:y}},(0,a.log)("Estimation failed",{...S,fallback:E})}return{blockGasLimit:y,estimatedGas:I,isUpgradeWithDataToSelf:P,simulationFails:S}}function u(e,t,i){const r=(0,n.hexToBN)(e),o=(0,n.fractionBN)((0,n.hexToBN)(t),a.MAX_GAS_BLOCK_PERCENT,100),c=(0,n.fractionBN)(r,100*i,100);if(r.gt(o)){const t=(0,s.add0x)(e);return(0,a.log)("Using estimated value",t),t}if(c.lt(o)){const e=(0,s.add0x)((0,n.BNToHex)(c));return(0,a.log)("Using padded estimate",e,i),e}const l=(0,s.add0x)((0,n.BNToHex)(o));return(0,a.log)("Using 90% of block gas limit",l),l}async function h({chainId:e,from:t,getSimulationConfig:s,transactions:i}){try{const a=await(0,c.simulateTransactions)(e,{getSimulationConfig:s,transactions:i.map(e=>({...e.params,from:t}))});if(a?.transactions?.length!==i.length)throw new Error("Simulation response does not match transaction count");return a.transactions.reduce((e,t)=>{const a=t?.gasLimit;if(!a)throw new Error("No simulated gas returned for one of the transactions");return e.gasLimits.push(a),e.totalGasLimit=(0,n.BNToHex)((0,n.hexToBN)(e.totalGasLimit).add((0,n.hexToBN)(a))),e},{totalGasLimit:"0x0",gasLimits:[]})}catch(e){throw(0,a.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:a,transaction:n}){const i=await(0,c.simulateTransactions)(e,{getSimulationConfig:a,transactions:[{to:n.to,from:n.from,data:n.data,value:n.value}],overrides:{[n.from]:{code:t&&r.DELEGATION_PREFIX+(0,s.remove0x)(t)}}}),o=i?.transactions?.[0].gasLimit;if(!o)throw new Error("No simulated gas returned");return o}function p(e,t,a){const{from:i}=t,o=[t];return a&&(o.push("latest"),o.push({[i]:{code:r.DELEGATION_PREFIX+(0,s.remove0x)(a)}})),(0,n.query)(e,"estimateGas",o)}a.log=(0,s.createModuleLogger)(l.projectLogger,"gas"),a.FIXED_GAS="0x5208",a.DEFAULT_GAS_MULTIPLIER=1.5,a.MAX_GAS_BLOCK_PERCENT=90,a.INTRINSIC_GAS=21e3,a.DUMMY_AUTHORIZATION_SIGNATURE="0x1111111111111111111111111111111111111111111111111111111111111111",a.updateGas=async function(e){const{txMeta:t}=e,s={...t.txParams},[i,r,c]=await async function(e){const{chainId:t,isCustomNetwork:s,isSimulationEnabled:i,getSimulationConfig:r,messenger:c,txMeta:l}=e,{disableGasBuffer:h}=l;if(l.txParams.gas)return(0,a.log)("Using value from request",l.txParams.gas),[l.txParams.gas,undefined,l.txParams.gas];if(await async function({ethQuery:e,txMeta:t,isCustomNetwork:a}){const{txParams:{to:s,data:i,type:r}}=t;if(a||!s||i||r===d.TransactionEnvelopeType.setCode)return!1;const o=await async function(e,t){return await(0,n.query)(e,"getCode",[t])}(e,s);return!o||"0x"===o}(e))return(0,a.log)("Using fixed value",a.FIXED_GAS),[a.FIXED_GAS,undefined,a.FIXED_GAS];const{blockGasLimit:f,estimatedGas:p,isUpgradeWithDataToSelf:g,simulationFails:k}=await m({chainId:t,ethQuery:e.ethQuery,isSimulationEnabled:i,getSimulationConfig:r,messenger:c,txParams:l.txParams});(0,a.log)("Original estimated gas",p),k&&(0,a.log)("Using original fallback estimate as simulation failed");h&&(0,a.log)("Gas buffer disabled");if(k||h)return[p,k,p];const w=(0,o.getGasEstimateBuffer)({chainId:t,isCustomRPC:s,isUpgradeWithDataToSelf:g,messenger:c});(0,a.log)("Buffer",w);const b=u(p,f,w);return(0,a.log)("Buffered gas",b),[b,k,p]}(e);t.txParams.gas=i,t.simulationFails=r,t.gasLimitNoBuffer=c,s.gas||(t.originalGasEstimate=t.txParams.gas),t.defaultGasEstimates??(t.defaultGasEstimates={}),t.defaultGasEstimates.gas=t.txParams.gas},a.estimateGas=m,a.estimateGasBatch=async function({chainId:e,ethQuery:t,from:n,getSimulationConfig:s,isAtomicBatchSupported:o,messenger:c,transactions:l}){const u=(await o({address:n,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,r.generateEIP7702BatchTransaction)(n,l),authorizationList:o,from:n,type:h},{estimatedGas:g}=await m({chainId:e,ethQuery:t,isSimulationEnabled:!0,getSimulationConfig:s,messenger:c,txParams:p}),k=new i.BigNumber(g).toNumber();return(0,a.log)("Estimated EIP-7702 gas limit",k),{totalGasLimit:k,gasLimits:[k]}}if(l.every(e=>e.gas!==undefined)){const e=l.map(e=>new i.BigNumber(e.gas).toNumber()),t=e.reduce((e,t)=>e+t,0);return(0,a.log)("Using batch parameter gas limits",{gasLimits:e,total:t}),{totalGasLimit:t,gasLimits:e}}const{gasLimits:p}=await h({chainId:e,from:n,getSimulationConfig:s,transactions:l.map(e=>({params:e}))}),g=l.map((e,t)=>e.gas?new i.BigNumber(e.gas).toNumber():new i.BigNumber(p[t]).toNumber()),k=g.reduce((e,t)=>e+t,0);return(0,a.log)("Simulated batch gas limits",{totalGasLimit:k,gasLimits:g}),{totalGasLimit:k,gasLimits:g}},a.addGasBuffer=u,a.simulateGasBatch=h}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/gas.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/layer1-gas-fee-flow.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getTransactionLayer1GasFee=a.updateTransactionLayer1GasFee=void 0;const n=e("@metamask/utils"),s=e("../logger.cjs"),i=(0,n.createModuleLogger)(s.projectLogger,"layer-1-gas-fee-flow");async function r({layer1GasFeeFlows:e,messenger:t,provider:a,transactionMeta:n}){const s=await async function(e,t,a){for(const n of t)if(await n.matchesTransaction({transactionMeta:e,messenger:a}))return n;return undefined}(n,e,t);if(!s)return undefined;i("Found layer 1 gas fee flow",s.constructor.name,n.id);try{const{layer1Fee:e}=await s.getLayer1Fee({provider:a,transactionMeta:n});return e}catch(e){return i("Failed to get layer 1 gas fee",n.id,e),undefined}}a.updateTransactionLayer1GasFee=async function(e){const t=await r(e);if(!t)return;const{transactionMeta:a}=e;a.layer1GasFee=t,i("Updated layer 1 gas fee",t,a.id)},a.getTransactionLayer1GasFee=r}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/layer1-gas-fee-flow.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/nonce.cjs",{"../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getAndFormatTransactionsForNonceTracker=a.getNextNonce=void 0;const n=e("@metamask/controller-utils"),s=e("../logger.cjs"),i=(0,s.createModuleLogger)(s.projectLogger,"nonce");a.getNextNonce=async function(e,t){const{customNonceValue:a,isExternalSign:s,txParams:{from:r,nonce:o}}=e;if(s)return i("Skipping nonce as signed externally"),[undefined,undefined];const c=a?(0,n.toHex)(a):undefined;if(c)return i("Using custom nonce",c),[c,undefined];if(o)return i("Using existing nonce",o),[o,undefined];const l=await t(r),d=(0,n.toHex)(l.nextNonce),m=l.releaseLock.bind(l);return i("Using nonce from nonce tracker",d,l.nonceDetails),[d,m]},a.getAndFormatTransactionsForNonceTracker=function(e,t,a,n){return n.filter(({chainId:n,isTransfer:s,isUserOperation:i,status:r,txParams:{from:o,nonce:c}})=>!s&&!i&&n===e&&a.includes(r)&&o.toLowerCase()===t.toLowerCase()&&c).flatMap(({status:e,txParams:{authorizationList:t,from:a,gas:n,value:s,nonce:i}})=>[i,...(t??[]).map(e=>e.nonce).filter(e=>e!==undefined)].map(t=>({status:e,history:[{}],txParams:{from:a??"",gas:n??"",value:s??"",nonce:t??""}})))}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/nonce.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.serializeTransaction=a.prepareTransaction=a.HARDFORK=void 0;const n=e("@ethereumjs/common"),s=e("@ethereumjs/tx"),i=e("@metamask/utils"),r=e("lodash");function o(e){const t={chainId:parseInt(e,16),defaultHardfork:a.HARDFORK};return n.Common.custom(t,{eips:[7702]})}function c(e){return e?"0x0"===e?"0x":e.replace?.(/^0x(00)+/u,"0x")??e:e}a.HARDFORK=n.Hardfork.Prague,a.prepareTransaction=function(e,t){const a=function(e){const t=(0,r.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 s.TransactionFactory.fromTxData(a,{freeze:!1,common:o(e)})},a.serializeTransaction=function(e){return(0,i.bytesToHex)(e.serialize())}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/prepare.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.getTransactionParamsWithIncreasedGasFee=void 0;const n=e("@metamask/controller-utils"),s=e("@metamask/utils");function i(e,t){const a=(0,n.convertHexToDecimal)(e),i=parseInt(""+a*t,10);return(0,s.add0x)(i.toString(16))}a.getTransactionParamsWithIncreasedGasFee=function(e,t,a){const n=function(e,t,a){if(a&&"gasPrice"in a)return a.gasPrice;const n=e.gasPrice;if(!n||"0x0"===n)return undefined;return i(n,t)}(e,t,a),s=function(e,t,a){if(a&&"maxFeePerGas"in a&&"maxPriorityFeePerGas"in a)return a;const n=e.maxFeePerGas,s=e.maxPriorityFeePerGas;if(!n||!s||"0x0"===n||"0x0"===s)return undefined;const r=i(n,t),o=i(s,t);return{maxFeePerGas:r,maxPriorityFeePerGas:o}}(e,t,a);if(s){const t={...e,...s};return delete t.gasPrice,t}if(n){const t={...e,gasPrice:n};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/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/retry.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.isValidSignature=void 0;const n=e("@ethersproject/wallet"),s=e("@metamask/utils");a.isValidSignature=function(e,t,a){try{const i=(0,s.add0x)(e.map(s.remove0x).join("")),r=(0,s.hexToBytes)(i);return(0,n.verifyMessage)(r,t).toLowerCase()===a.toLowerCase()}catch{return!1}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/signature.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/swaps.cjs",{"../constants.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/constants.cjs","../logger.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/logger.cjs","../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.updatePostTransactionBalance=a.updateSwapsTransaction=a.SWAP_TRANSACTION_TYPES=a.SWAPS_CHAINID_DEFAULT_TOKEN_MAP=a.DEFAULT_TOKEN_ADDRESS=a.UPDATE_POST_TX_BALANCE_ATTEMPTS=a.UPDATE_POST_TX_BALANCE_TIMEOUT=void 0;const n=e("@metamask/controller-utils"),s=e("lodash"),i=e("./utils.cjs"),r=e("../constants.cjs"),o=e("../logger.cjs"),c=e("../types.cjs"),l=(0,o.createModuleLogger)(o.projectLogger,"swaps");a.UPDATE_POST_TX_BALANCE_TIMEOUT=5e3,a.UPDATE_POST_TX_BALANCE_ATTEMPTS=6;const d="0x539";a.DEFAULT_TOKEN_ADDRESS="0x0000000000000000000000000000000000000000";const m={name:"Ether",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},u={name:"Binance Coin",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},h={name:"Matic",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},f={name:"Avalanche",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},p={name:"Test Ether",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},g={name:"Ether",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},k={...m},w={...m},b={...m},y={name:"Sei",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},T={name:"Mon",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18},x={name:"Hyperliquid",address:a.DEFAULT_TOKEN_ADDRESS,decimals:18};function _(e,t){return!(!e||!t)&&e===a.SWAPS_CHAINID_DEFAULT_TOKEN_MAP[t]?.address}function v(e){return new Promise(t=>setTimeout(t,e))}a.SWAPS_CHAINID_DEFAULT_TOKEN_MAP={[r.CHAIN_IDS.MAINNET]:m,[d]:p,[r.CHAIN_IDS.BSC]:u,[r.CHAIN_IDS.POLYGON]:h,[r.CHAIN_IDS.GOERLI]:g,[r.CHAIN_IDS.AVALANCHE]:f,[r.CHAIN_IDS.OPTIMISM]:w,[r.CHAIN_IDS.ARBITRUM]:k,[r.CHAIN_IDS.ZKSYNC_ERA]:b,[r.CHAIN_IDS.SEI]:y,[r.CHAIN_IDS.MONAD]:T,[r.CHAIN_IDS.HYPEREVM]:x},a.SWAP_TRANSACTION_TYPES=[c.TransactionType.swap,c.TransactionType.swapAndSend,c.TransactionType.swapApproval],a.updateSwapsTransaction=function(e,t,n,{isSwapsDisabled:r,cancelTransaction:o,messenger:l}){if(r||!a.SWAP_TRANSACTION_TYPES.includes(t))return e;if(t===c.TransactionType.swap&&!1===n?.hasApproveTx&&e.simulationFails)throw o(e.id),new Error("Simulation failed");const d=n?.meta;if(!d)return e;let m=e;return t===c.TransactionType.swapApproval&&(m=function(e,{type:t,sourceTokenSymbol:a}){(0,i.validateIfTransactionUnapproved)(e,"updateSwapApprovalTransaction");let n={type:t,sourceTokenSymbol:a};return n=(0,s.pickBy)({type:t,sourceTokenSymbol:a}),(0,s.merge)({},e,n)}(e,d),l.publish("TransactionController:transactionNewSwapApproval",{transactionMeta:m})),t===c.TransactionType.swapAndSend&&(m=function(e,{approvalTxId:t,destinationTokenAddress:a,destinationTokenAmount:n,destinationTokenDecimals:r,destinationTokenSymbol:o,estimatedBaseFee:c,sourceTokenAddress:l,sourceTokenAmount:d,sourceTokenDecimals:m,sourceTokenSymbol:u,swapAndSendRecipient:h,swapMetaData:f,swapTokenValue:p,type:g}){(0,i.validateIfTransactionUnapproved)(e,"updateSwapTransaction");let k={approvalTxId:t,destinationTokenAddress:a,destinationTokenAmount:n,destinationTokenDecimals:r,destinationTokenSymbol:o,estimatedBaseFee:c,sourceTokenAddress:l,sourceTokenAmount:d,sourceTokenDecimals:m,sourceTokenSymbol:u,swapAndSendRecipient:h,swapMetaData:f,swapTokenValue:p,type:g};return k=(0,s.pickBy)(k),(0,s.merge)({},e,k)}(e,d),l.publish("TransactionController:transactionNewSwapAndSend",{transactionMeta:m})),t===c.TransactionType.swap&&(m=function(e,{sourceTokenSymbol:t,destinationTokenSymbol:a,type:n,destinationTokenDecimals:r,destinationTokenAddress:o,swapMetaData:c,swapTokenValue:l,estimatedBaseFee:d,approvalTxId:m}){(0,i.validateIfTransactionUnapproved)(e,"updateSwapTransaction");let u={sourceTokenSymbol:t,destinationTokenSymbol:a,type:n,destinationTokenDecimals:r,destinationTokenAddress:o,swapMetaData:c,swapTokenValue:l,estimatedBaseFee:d,approvalTxId:m};return u=(0,s.pickBy)(u),(0,s.merge)({},e,u)}(e,d),l.publish("TransactionController:transactionNewSwap",{transactionMeta:m})),m},a.updatePostTransactionBalance=async function(e,{ethQuery:t,getTransaction:s,updateTransaction:i}){l("Updating post transaction balance",e.id);const r=e.id;let o,c;for(let i=0;i<a.UPDATE_POST_TX_BALANCE_ATTEMPTS;i++){l("Querying balance",{attempt:i});const d=await(0,n.query)(t,"getBalance",[e.txParams.from]);o={...s(r)??{}},c=o.approvalTxId?s(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:a.UPDATE_POST_TX_BALANCE_TIMEOUT}),await v(a.UPDATE_POST_TX_BALANCE_TIMEOUT)}return i(o,"TransactionController#updatePostTransactionBalance - Add post transaction balance"),l("Completed post balance update",o?.postTxBalance),{updatedTransactionMeta:o,approvalTransactionMeta:c}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/swaps.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./eip7702.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.decodeTransactionData=a.determineTransactionType=a.ESTIMATE_GAS_ERROR=void 0;const n=e("@ethersproject/abi"),s=e("@metamask/controller-utils"),i=e("@metamask/metamask-eth-abis"),r=e("./eip7702.cjs"),o=e("../types.cjs");a.ESTIMATE_GAS_ERROR="eth_estimateGas rpc method error";const c=new n.Interface(i.abiERC20),l=new n.Interface(i.abiERC721),d=new n.Interface(i.abiERC1155),m=new n.Interface(i.abiFiatTokenV2);function u(e,t){if(!e||e.length<10)return undefined;const a=e.substring(0,10).toLowerCase();for(const n of[c,l,d,m])try{return t?.getMethodName?n.getFunction(a)?.name:n.parseTransaction({data:e})}catch{}return undefined}a.determineTransactionType=async function(e,t){const{data:a,to:n}=e;if(a&&!n)return{type:o.TransactionType.deployContract,getCodeResponse:undefined};let i,c=Boolean(a?.length);if(t){const e=await async function(e,t){let a;try{a=await(0,s.query)(e,"getCode",[t])}catch(e){a=null}const n=!!a&&("0x"!==a&&"0x0"!==a&&!a.startsWith(r.DELEGATION_PREFIX));return{contractCode:a,isContractAddress:n}}(t,n);i=e.contractCode,c=e.isContractAddress}if(!c)return{type:o.TransactionType.simpleSend,getCodeResponse:i};const l=0!==Number(e.value??"0"),d={type:o.TransactionType.contractInteraction,getCodeResponse:i};if(!a||l)return d;const m=function(e){return u(e,{getMethodName:!0})}(a);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:i}:d},a.decodeTransactionData=u}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0}),a.caip2ToHex=a.setEnvelopeType=a.getPercentageChange=a.toBN=a.bnFromHex=a.padHexToEvenLength=a.normalizeGasFeeValues=a.normalizeTxError=a.validateIfTransactionUnapprovedOrSubmitted=a.validateIfTransactionUnapproved=a.validateGasValues=a.isEIP1559Transaction=a.normalizeTransactionParams=a.ESTIMATE_GAS_ERROR=void 0;const s=e("@metamask/controller-utils"),i=e("@metamask/utils"),r=n(e("bn.js")),o=e("../types.cjs");a.ESTIMATE_GAS_ERROR="eth_estimateGas rpc method error";const c={accessList:e=>e,authorizationList:e=>e,data:e=>(0,i.add0x)(d(e)),from:e=>(0,i.add0x)(e).toLowerCase(),gas:e=>(0,i.add0x)(e),gasLimit:e=>(0,i.add0x)(e),gasPrice:e=>(0,i.add0x)(e),nonce:e=>(0,i.add0x)(e),to:e=>(0,i.add0x)(e).toLowerCase(),value:e=>(0,i.add0x)(e),maxFeePerGas:e=>(0,i.add0x)(e),maxPriorityFeePerGas:e=>(0,i.add0x)(e),estimatedBaseFee:e=>(0,i.add0x)(e),type:e=>(0,i.add0x)(e)};a.normalizeTransactionParams=function(e){const t={from:""};for(const a of(0,i.getKnownPropertyNames)(c))e[a]&&(t[a]=c[a](e[a]));return t.value??(t.value="0x0"),t.gasLimit&&!t.gas&&(t.gas=t.gasLimit),t},a.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):"",a=t?e.slice(2):e;return t+(a.length%2==0?a:`0${a}`)}function m(e){const t=e,a=t.startsWith("0x")||t.startsWith("0X")?t.slice(2):t;return 0===a.length?new r.default(0):new r.default(a,16)}a.validateGasValues=e=>{Object.keys(e).forEach(t=>{const a=e[t];if("string"!=typeof a||!(0,i.isStrictHexString)(a))throw new TypeError(`expected hex string for ${t} but received: ${a}`)})},a.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}`)},a.validateIfTransactionUnapprovedOrSubmitted=function(e,t){const a=[o.TransactionStatus.unapproved,o.TransactionStatus.submitted];if(!e||!a.includes(e.status))throw new Error(`TransactionsController: Can only call ${t} on an unapproved or submitted transaction.\n      Current tx status: ${e?.status}`)},a.normalizeTxError=function(e){return{name:e.name,message:e.message,stack:e.stack,code:e.code,rpc:l(e.value)?e.value:undefined}},a.normalizeGasFeeValues=function(e){const t=e=>"string"==typeof e?(0,i.add0x)(e):e;return"gasPrice"in e?{gasPrice:t(e.gasPrice)}:{maxFeePerGas:t(e.maxFeePerGas),maxPriorityFeePerGas:t(e.maxPriorityFeePerGas)}},a.padHexToEvenLength=d,a.bnFromHex=m,a.toBN=function(e){if(e instanceof r.default)return e;if("function"==typeof r.default.isBN&&r.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 r.default(e.toString());if("number"==typeof e)return new r.default(e);throw new Error("Unexpected value returned from oracle contract")},a.getPercentageChange=function(e,t){const a=new r.default(10).pow(new r.default(18)),n=e.mul(a),s=t.mul(a),i=s.sub(n);return i.isZero()?0:n.isZero()&&!s.isZero()?100:i.muln(100).div(n).abs().toNumber()},a.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},a.caip2ToHex=function(e){if(!(0,i.isCaipChainId)(e))return undefined;try{const{reference:t}=(0,i.parseCaipChainId)(e);return(0,s.toHex)(t)}catch{return undefined}}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/utils.cjs"}],["/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/validation.cjs",{"../types.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/types.cjs","./utils.cjs":"/home/runner/work/metamask-extension/metamask-extension/node_modules/@metamask/eip-5792-middleware/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,a){Object.defineProperty(a,"__esModule",{value:!0}),a.validateBatchRequest=a.validateParamTo=a.validateTxParams=a.validateTransactionOrigin=a.ErrorCode=void 0;const n=e("@ethersproject/abi"),s=e("@metamask/controller-utils"),i=e("@metamask/metamask-eth-abis"),r=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||(a.ErrorCode=d={}));const m=[l.TransactionEnvelopeType.feeMarket,l.TransactionEnvelopeType.setCode];function u(e,t){const a=e.type;switch(t){case"authorizationList":if(a&&a!==l.TransactionEnvelopeType.setCode)throw r.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${a}" but including authorizationList requires type: "${l.TransactionEnvelopeType.setCode}"`);break;case"maxFeePerGas":case"maxPriorityFeePerGas":if(a&&!m.includes(a))throw r.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${a}" but including maxFeePerGas and maxPriorityFeePerGas requires type: "${m.join(", ")}"`);break;default:if(a&&m.includes(a))throw r.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${a}" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas`)}}function h(e,t,a){if(void 0!==e[a])throw r.rpcErrors.invalidParams(`Invalid transaction params: specified ${t} but also included ${a}, these cannot be mixed`)}function f(e,t){const a=e[t];if("string"!=typeof a||!(0,o.isStrictHexString)(a))throw r.rpcErrors.invalidParams(`Invalid transaction params: ${String(t)} is not a valid hexadecimal string. got: (${String(a)})`)}function p(e){f(e,"address"),function(e,t,a){const n=(0,o.remove0x)(e).length/2;if(n!==t)throw r.rpcErrors.invalidParams(`Invalid transaction params: ${a} must be ${t} bytes. got: ${n} 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 r.rpcErrors.invalidParams(`Invalid transaction params: yParity must be '0x0' or '0x1'. got: ${t}`)}a.validateTransactionOrigin=async function({data:e,from:t,internalAccounts:a,origin:n,permittedAddresses:i,txParams:o,type:c}){if(!n||n===s.ORIGIN_METAMASK)return;const{authorizationList:d,to:m,type:u}=o;if(i&&!i.includes(t))throw r.providerErrors.unauthorized({data:{origin:n}});if(c===l.TransactionType.batch)return;if(d||u===l.TransactionEnvelopeType.setCode)throw r.rpcErrors.invalidParams("External EIP-7702 transactions are not supported");if(Boolean(e&&"0x"!==e)&&a?.some(e=>e.toLowerCase()===m?.toLowerCase()))throw r.rpcErrors.invalidParams("External transactions to internal accounts cannot include data")},a.validateTxParams=function(e,t=!0,a){!function(e){if(e&&!Object.values(l.TransactionEnvelopeType).includes(e))throw r.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 r.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 r.rpcErrors.invalidParams(`Invalid "from" address ${e}: not a string.`);if(!(0,s.isValidHexAddress)(e))throw r.rpcErrors.invalidParams('Invalid "from" address.')}(e.from),function(e){if("0x"===e.to||e.to===undefined){if(!e.data)throw r.rpcErrors.invalidParams('Invalid "to" address.');delete e.to}else if(e.to!==undefined&&!(0,s.isValidHexAddress)(e.to))throw r.rpcErrors.invalidParams('Invalid "to" address.')}(e),function(e){if(e!==undefined){if(e.includes("-"))throw r.rpcErrors.invalidParams(`Invalid transaction value "${e}": not a positive number.`);if(e.includes("."))throw r.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 r.rpcErrors.invalidParams(`Invalid transaction value ${e}: number must be a valid number.`)}}(e.value),function(e){if(e){const t=new n.Interface(i.abiERC20);try{t.parseTransaction({data:e})}catch(e){if(e.message.match(/BUFFER_OVERRUN/u))throw r.rpcErrors.invalidParams("Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.")}}}(e.data),function(e,t){if(e&&t&&e.toLowerCase?.()!==t.toLowerCase())throw r.rpcErrors.invalidParams(`Invalid transaction params: chainId must match the network client, got: ${e}, expected: ${t}`)}(e.chainId,a),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 r.rpcErrors.invalidParams("Invalid transaction params: authorizationList must be an array");for(const e of t)p(e)}(e)},a.validateParamTo=function(e){if(!e||"string"!=typeof e)throw r.rpcErrors.invalidParams('Invalid "to" address')},a.validateBatchRequest=function({internalAccounts:e,request:t,sizeLimit:a}){const{origin:n}=t,i=n&&n!==s.ORIGIN_METAMASK,o=e.map(e=>e.toLowerCase());if(i&&t.transactions.some(e=>{const t=e.params.to?.toLowerCase(),a=e.params.data,n=o.includes(t),s=Boolean(a&&"0x"!==a);return n&&s}))throw r.rpcErrors.invalidParams("External calls to internal accounts cannot include data");if(i&&t.transactions.length>a)throw new r.JsonRpcError(d.BundleTooLarge,`Batch size cannot exceed ${a}. got: ${t.transactions.length}`)}}}},{package:"@metamask/eip-5792-middleware>@metamask/transaction-controller",file:"node_modules/@metamask/eip-5792-middleware/node_modules/@metamask/transaction-controller/dist/utils/validation.cjs"}]],[],{});