LavaPack.loadBundle([[5775,{"./core.js":5774,"./helpers.js":5776},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});
/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017-2021 Joachim Wester
 * MIT license
 */
var n=e("./helpers.js"),o=e("./core.js"),i=new WeakMap,s=function(e){this.observers=new Map,this.obj=e},a=function(e,t){this.callback=e,this.observer=t};function c(e,t){void 0===t&&(t=!1);var r=i.get(e.object);u(r.value,e.object,e.patches,"",t),e.patches.length&&o.applyPatch(r.value,e.patches);var n=e.patches;return n.length>0&&(e.patches=[],e.callback&&e.callback(n)),n}function u(e,t,r,o,i){if(t!==e){"function"==typeof t.toJSON&&(t=t.toJSON());for(var s=n._objectKeys(t),a=n._objectKeys(e),c=!1,f=a.length-1;f>=0;f--){var l=e[h=a[f]];if(!n.hasOwnProperty(t,h)||t[h]===undefined&&l!==undefined&&!1===Array.isArray(t))Array.isArray(e)===Array.isArray(t)?(i&&r.push({op:"test",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(l)}),r.push({op:"remove",path:o+"/"+n.escapePathComponent(h)}),c=!0):(i&&r.push({op:"test",path:o,value:e}),r.push({op:"replace",path:o,value:t}),!0);else{var d=t[h];"object"==typeof l&&null!=l&&"object"==typeof d&&null!=d&&Array.isArray(l)===Array.isArray(d)?u(l,d,r,o+"/"+n.escapePathComponent(h),i):l!==d&&(i&&r.push({op:"test",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(l)}),r.push({op:"replace",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(d)}))}}if(c||s.length!=a.length)for(f=0;f<s.length;f++){var h=s[f];n.hasOwnProperty(e,h)||t[h]===undefined||r.push({op:"add",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(t[h])})}}}r.unobserve=function(e,t){t.unobserve()},r.observe=function(e,t){var r,o=function(e){return i.get(e)}(e);if(o){var u=function(e,t){return e.observers.get(t)}(o,t);r=u&&u.observer}else o=new s(e),i.set(e,o);if(r)return r;if(r={},o.value=n._deepClone(e),t){r.callback=t,r.next=null;var f=function(){c(r)},l=function(){clearTimeout(r.next),r.next=setTimeout(f)};"undefined"!=typeof window&&(window.addEventListener("mouseup",l),window.addEventListener("keyup",l),window.addEventListener("mousedown",l),window.addEventListener("keydown",l),window.addEventListener("change",l))}return r.patches=[],r.object=e,r.unobserve=function(){c(r),clearTimeout(r.next),function(e,t){e.observers.delete(t.callback)}(o,r),"undefined"!=typeof window&&(window.removeEventListener("mouseup",l),window.removeEventListener("keyup",l),window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l),window.removeEventListener("change",l))},o.observers.set(t,new a(t,r)),r},r.generate=c,r.compare=function(e,t,r){void 0===r&&(r=!1);var n=[];return u(e,t,n,"",r),n}}}},{package:"fast-json-patch",file:"node_modules/fast-json-patch/commonjs/duplex.js"}],[5776,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){
/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017-2022 Joachim Wester
 * MIT licensed
 */
var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var i=Object.prototype.hasOwnProperty;function s(e,t){return i.call(e,t)}function a(e){if(Array.isArray(e)){for(var t=new Array(e.length),r=0;r<t.length;r++)t[r]=""+r;return t}if(Object.keys)return Object.keys(e);var n=[];for(var o in e)s(e,o)&&n.push(o);return n}function c(e){return-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function u(e,t){var r;for(var n in e)if(s(e,n)){if(e[n]===t)return c(n)+"/";if("object"==typeof e[n]&&""!=(r=u(e[n],t)))return c(n)+"/"+r}return""}function f(e,t){var r=[e];for(var n in t){var o="object"==typeof t[n]?JSON.stringify(t[n],null,2):t[n];void 0!==o&&r.push(n+": "+o)}return r.join("\n")}Object.defineProperty(r,"hasOwnProperty",{value:s}),r._objectKeys=a,r._deepClone=function(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}},r.isInteger=function(e){for(var t,r=0,n=e.length;r<n;){if(!((t=e.charCodeAt(r))>=48&&t<=57))return!1;r++}return!0},r.escapePathComponent=c,r.unescapePathComponent=function(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")},r._getPathRecursive=u,r.getPath=function(e,t){if(e===t)return"/";var r=u(e,t);if(""===r)throw new Error("Object not found in root");return"/"+r},r.hasUndefined=function e(t){if(t===undefined)return!0;if(t)if(Array.isArray(t)){for(var r=0,n=t.length;r<n;r++)if(e(t[r]))return!0}else if("object"==typeof t)for(var o=a(t),i=o.length,s=0;s<i;s++)if(e(t[o[s]]))return!0;return!1};var l=function(e){function t(t,r,n,o,i){var s=this.constructor,a=e.call(this,f(t,{name:r,index:n,operation:o,tree:i}))||this;return a.name=r,a.index=n,a.operation=o,a.tree=i,Object.setPrototypeOf(a,s.prototype),a.message=f(t,{name:r,index:n,operation:o,tree:i}),a}return o(t,e),t}(Error);r.PatchError=l}}},{package:"fast-json-patch",file:"node_modules/fast-json-patch/commonjs/helpers.js"}],[5777,{"./commonjs/core.js":5774,"./commonjs/duplex.js":5775,"./commonjs/helpers.js":5776},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=e("./commonjs/core.js");Object.assign(r,n);var o=e("./commonjs/duplex.js");Object.assign(r,o);var i=e("./commonjs/helpers.js");r.JsonPatchError=i.PatchError,r.deepClone=i._deepClone,r.escapePathComponent=i.escapePathComponent,r.unescapePathComponent=i.unescapePathComponent}}},{package:"fast-json-patch",file:"node_modules/fast-json-patch/index.js"}],[578,{"@metamask/utils":4277,lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){(0,n.hasProperty)(e,"AppStateController")&&(0,n.isObject)(e.AppStateController)&&delete e.AppStateController.enableEIP1559V2NoticeDismissed;(0,n.hasProperty)(e,"NftController")&&(0,n.isObject)(e.NftController)&&(delete e.NftController.collectibles,delete e.NftController.collectibleContracts);(0,n.hasProperty)(e,"PreferencesController")&&(0,n.isObject)(e.PreferencesController)&&(0,n.hasProperty)(e.PreferencesController,"preferences")&&(0,n.isObject)(e.PreferencesController.preferences)&&(delete e.PreferencesController.preferences.transactionSecurityCheckEnabled,delete e.PreferencesController.preferences.useRequestQueue)}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=148}}},{package:"$root$",file:"app/scripts/migrations/148.ts"}],[5782,{"@firebase/app":921},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/app");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[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 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.
 */
(0,n.registerVersion)("firebase","11.2.0","app")}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/app/dist/esm/index.esm.js"}],[5783,{"@firebase/messaging":925},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/messaging");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))})}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/messaging/dist/esm/index.esm.js"}],[5784,{"@firebase/messaging/sw":926},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/messaging/sw");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))})}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/messaging/sw/dist/esm/index.esm.js"}],[579,{"@metamask/controller-utils":1810,"@metamask/utils":4277,lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,i.cloneDeep)(e);t.meta.version=s;try{t.data=function(e){const t=(0,i.cloneDeep)(e);if(!(0,o.hasProperty)(t,"NetworkController"))throw new Error("newState.NetworkController must be present");if(!(0,o.isObject)(t.NetworkController))throw new Error("state.NetworkController must be an object, but is: "+typeof t.NetworkController);if(!(0,o.hasProperty)(t.NetworkController,"networkConfigurationsByChainId"))throw new Error("state.NetworkController.networkConfigurationsByChainId must be present");if(!(0,o.isObject)(t.NetworkController.networkConfigurationsByChainId))throw new Error("state.NetworkController.networkConfigurationsByChainId must be an object, but is: "+typeof t.NetworkController.networkConfigurationsByChainId);const{networkConfigurationsByChainId:r}=t.NetworkController;for(const[e,t]of Object.entries(r)){const i=(0,n.toHex)(e);if(!(0,o.isObject)(t))throw new Error(`state.NetworkController.networkConfigurationsByChainId has a network configuration under '${e}' that must be an object but is: ${typeof t}`);if("string"!=typeof t.chainId)throw new Error(`state.NetworkController.networkConfigurationsByChainId has a network configuration under '${e}' with a chainId that must be a string but is: ${typeof t.chainId}`);t.chainId=i,i!==e&&(delete r[e],r[i]=t)}return t}(t.data)}catch(e){global.sentry?.captureException?.(new Error(`Migration #${s}: ${(0,o.getErrorMessage)(e)}`))}return t},r.version=void 0;var n=e("@metamask/controller-utils"),o=e("@metamask/utils"),i=e("lodash");const s=r.version=149}}},{package:"$root$",file:"app/scripts/migrations/149.ts"}],[58,{"../../../shared/constants/onboarding":7713,"../../../shared/lib/assets-unify-state/remote-feature-flag":7749,"../../../shared/lib/wallet-funds-obtained-metric":7889,"@metamask/notification-services-controller/notification-services":3333,loglevel:6360},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.WalletFundsObtainedMonitor=void 0;var n,o=e("@metamask/notification-services-controller/notification-services"),i=(n=e("loglevel"))&&n.__esModule?n:{default:n},s=e("../../../shared/lib/wallet-funds-obtained-metric"),a=e("../../../shared/constants/onboarding"),c=e("../../../shared/lib/assets-unify-state/remote-feature-flag");function u(e,t,r){f(e,t),t.set(e,r)}function f(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function l(e,t){return e.get(h(e,t))}function d(e,t,r){return e.set(h(e,t),r),r}function h(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var p=new WeakMap,m=new WeakMap,g=new WeakMap,b=new WeakSet;function y(){try{const e=l(p,this).call("RemoteFeatureFlagController:getState"),t=e?.remoteFeatureFlags?.assetsUnifyState;if(!(0,c.isAssetsUnifyStateFeatureEnabled)(t,c.ASSETS_UNIFY_STATE_VERSION_1)){const e=l(p,this).call("TokenBalancesController:getState"),t=l(p,this).call("MultichainBalancesController:getState");return(0,s.hasNonZeroTokenBalance)(e.tokenBalances)||(0,s.hasNonZeroMultichainBalance)(t.balances)}const r=l(p,this).call("AssetsController:getState");return Object.values(r.assetsBalance).some(e=>Object.values(e).some(e=>e.amount&&"0"!==e.amount))}catch(e){return i.default.error("Error checking for existing funds: ",e),!1}}function w(){return e=>{const t=e.filter(e=>e.type===o.TRIGGER_TYPES.ERC20_RECEIVED||e.type===o.TRIGGER_TYPES.ETH_RECEIVED);if(t.length<1)return;const r=t.at(-1);if(!r)return;const{payload:{chain_id:n}}=r,i=r.type===o.TRIGGER_TYPES.ERC20_RECEIVED?r.payload.data.token.usd:r.payload.data.amount.usd;n&&i&&(l(p,this).call("MetaMetricsController:trackEvent",(0,s.getWalletFundsObtainedEventProperties)({chainId:n,amountUsd:i})),l(p,this).call("AppStateController:setCanTrackWalletFundsObtained",!1),l(g,this)&&(l(p,this).unsubscribe("NotificationServicesController:notificationsListUpdated",l(g,this)),d(g,this,null)))}}r.WalletFundsObtainedMonitor=class{constructor({messenger:e}){!function(e,t){f(e,t),t.add(e)}(this,b),u(this,p,void 0),u(this,m,!1),u(this,g,null),d(p,this,e)}setupMonitoring(){if(l(m,this))return;const e=l(p,this).call("OnboardingController:getState"),{firstTimeFlowType:t}=e;if(t!==a.FirstTimeFlowType.create&&t!==a.FirstTimeFlowType.socialCreate)return void l(p,this).call("AppStateController:setCanTrackWalletFundsObtained",!1);l(p,this).call("NotificationServicesController:getState").isNotificationServicesEnabled?h(b,this,y).call(this)?l(p,this).call("AppStateController:setCanTrackWalletFundsObtained",!1):(d(g,this,h(b,this,w).call(this)),l(p,this).subscribe("NotificationServicesController:notificationsListUpdated",l(g,this)),d(m,this,!0)):l(p,this).call("AppStateController:setCanTrackWalletFundsObtained",!1)}}}}},{package:"$root$",file:"app/scripts/lib/WalletFundsObtainedMonitor.ts"}],[580,{lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=o,function(e){const t=e?.PreferencesController,r=t?.preferences;delete r?.petnamesEnabled}(t.data),t},r.version=void 0;var n=e("lodash");const o=r.version=150}}},{package:"$root$",file:"app/scripts/migrations/150.ts"}],[581,{lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=o,function(e){const t=e?.PreferencesController;delete t?.incomingTransactionsPreferences}(t.data),t},r.version=void 0;var n=e("lodash");const o=r.version=151}}},{package:"$root$",file:"app/scripts/migrations/151.ts"}],[5815,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){let n;return n=(null==r?void 0:r.registry)?r.registry.endsWith("/")?r.registry:`${r.registry}/`:"https://registry.npmjs.org/",`${n}${e}/-/${function(e){if("@"!==e[0])return e;return e.split("/")[1]}(e)}-${function(e){const t=e.indexOf("+");return-1===t?e:e.substring(0,t)}(t)}.tgz`}}}},{package:"@metamask/snaps-controllers>get-npm-tarball-url",file:"node_modules/get-npm-tarball-url/lib/index.js"}],[582,{"@metamask/utils":4277,lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.TESTNETS=void 0,r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){(0,n.hasProperty)(e,"MultichainNetworkController")&&(0,n.isObject)(e.MultichainNetworkController)&&(0,n.isObject)(e.MultichainNetworkController.multichainNetworkConfigurationsByChainId)&&(e.MultichainNetworkController.multichainNetworkConfigurationsByChainId={...e.MultichainNetworkController.multichainNetworkConfigurationsByChainId,...s})}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=152.1,s=r.TESTNETS={"bip122:000000000933ea01ad0ee984209779ba":{chainId:"bip122:000000000933ea01ad0ee984209779ba",name:"Bitcoin Testnet",nativeCurrency:"bip122:000000000933ea01ad0ee984209779ba/slip44:0",isEvm:!1},"bip122:00000008819873e925422c1ff0f99f7c":{chainId:"bip122:00000008819873e925422c1ff0f99f7c",name:"Bitcoin Mutinynet",nativeCurrency:"bip122:00000008819873e925422c1ff0f99f7c/slip44:0",isEvm:!1},"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":{chainId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",nativeCurrency:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z/slip44:501",isEvm:!1},"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1":{chainId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",nativeCurrency:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1/slip44:501",isEvm:!1}}}}},{package:"$root$",file:"app/scripts/migrations/152.1.ts"}],[5829,{"@ethereumjs/rlp":5831,"@metamask/eth-sig-util":2542,"aes-js":5287,bech32:5392,"bignumber.js":5847,"bn.js":5399,bs58check:5849,buffer:5450,cbor:5473,"cbor-bigdecimal":5850,"crc-32":5534,elliptic:5638,"hash.js/lib/hash/ripemd.js":6025,"lodash/inRange.js":6332,"lodash/isEmpty.js":6338,"lodash/isInteger.js":6341,ox:5937,secp256k1:5938,uuid:7313,viem:7503,zod:5941},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(r){(function(){function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o,i=Object.create,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,l=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of c(t))f.call(e,o)||o===r||s(e,o,{get:()=>t[o],enumerable:!(n=a(t,o))||n.enumerable});return e},d=(e,t,r)=>(r=null!=e?i(u(e)):{},l(!t&&e&&e.__esModule?r:s(r,"default",{value:e,enumerable:!0}),e)),h={};((e,t)=>{for(var r in t)s(e,r,{get:t[r],enumerable:!0})})(h,{BTC_LEGACY_XPUB_PATH:()=>te,BTC_SEGWIT_ZPUB_PATH:()=>ne,BTC_WRAPPED_SEGWIT_YPUB_PATH:()=>re,Calldata:()=>O,Client:()=>Un,Constants:()=>R,Utils:()=>dt,addAddressTags:()=>eo,connect:()=>bo,fetchActiveWallets:()=>mo,fetchAddress:()=>Ln,fetchAddressTags:()=>to,fetchAddresses:()=>Dn,fetchAddressesByDerivationPath:()=>Yn,fetchBip44ChangeAddresses:()=>Zn,fetchBtcLegacyAddresses:()=>zn,fetchBtcLegacyChangeAddresses:()=>Hn,fetchBtcSegwitAddresses:()=>Fn,fetchBtcSegwitChangeAddresses:()=>qn,fetchBtcWrappedSegwitAddresses:()=>Gn,fetchBtcWrappedSegwitChangeAddresses:()=>$n,fetchBtcXpub:()=>Jn,fetchBtcYpub:()=>Xn,fetchBtcZpub:()=>Qn,fetchLedgerLegacyAddresses:()=>Kn,fetchLedgerLiveAddresses:()=>Wn,fetchSolanaAddresses:()=>Vn,getClient:()=>fe,pair:()=>yo,parseDerivationPath:()=>me,removeAddressTags:()=>ro,setup:()=>go,sign:()=>so,signAuthorization:()=>co,signAuthorizationList:()=>uo,signBtcLegacyTx:()=>fo,signBtcSegwitTx:()=>lo,signBtcWrappedSegwitTx:()=>ho,signMessage:()=>ao,signSolanaTx:()=>po}),t.exports=(o=h,l(s({},"__esModule",{value:!0}),o));var p=e("ox"),m=e("viem");function g(e){return`0x${r.from(p.Hash.keccak256(r.from(e))).toString("hex").slice(0,8)}`}function b(e){if("string"!=typeof e||10!==e.length&&8!==e.length)throw new Error("`sig` must be a hex string with 4 bytes of data.");return 8===e.length&&(e=`0x${e}`),e}function y(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];let o=k[n[1]];if(n[2]&&(o=`${o}${8*n[2]}`),n[3].length>0&&n[3].forEach(e=>{o=0===n[3][e]?`${o}[]`:`${o}[${n[3][e]}]`}),n[4]){const e=y(n[4]);o=`${o}(${e.join(",")})`}t.push(o)}return t}function w(e){if(I(e))return P(e);if(e.indexOf(",")>-1)return e.slice(0,e.indexOf(","));if(e.indexOf(")")>-1)return e.slice(0,e.indexOf(")"));throw new Error(_)}function E(e){if(!I(e))return[v(e)];const t={szBytes:0,typeIdx:k.indexOf("tuple"),arraySzs:[]};let r=P(e,!1);const n=e.slice(r.length);t.arraySzs=S(n),r=r.slice(1);let o=[];for(;r.length>0;){const e=w(r);r=r.slice(e.length+1),o=o.concat(E(e))}if(!o.length)throw new Error(_);return[t,o]}function v(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r=!1;if(k.forEach((n,o)=>{if(e.indexOf(n)>-1&&!r){t.typeIdx=o,t.arraySzs=S(e);const i=t.arraySzs.length>0?e.indexOf("["):e.length,s=e.slice(n.length,i);if(parseInt(s)&&(t.szBytes=parseInt(s)/8,t.szBytes>32))throw new Error(_);r=!0}}),!r)throw new Error(_);return t}function x(e,t="",r=[],n=!1){if(!n){const n=e.name||"";r.push(n),t+=n}return e.inputs&&(t+="(",e.inputs.forEach(e=>{const n=function(e){if(!e.type)throw new Error("No type in input");const t=[e.name],{typeIdx:r,szBytes:n,arraySzs:o}=function(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r;k.forEach((n,o)=>{e.indexOf(n)>-1&&!r&&(r=n,t.typeIdx=o)}),t.arraySzs=S(e);const n=t.arraySzs.length>0?e.indexOf("["):e.length;if(["uint","int","bytes"].indexOf(r)>-1){const o=parseInt(e.slice(r.length,n))||0;if(o>256)throw new Error("Invalid param size");t.szBytes=o/8}else t.szBytes=0;return t}(e.type);return t.push(r),t.push(n),t.push(o),t}(e);if(e.type.indexOf("tuple")>-1&&e.components){const r=x({inputs:e.components},t,[],!0);t=r.canonicalName,t+=`${e.type.slice(5)},`,n.push(r.def)}else t+=e.type,t+=",";r.push(n)}),","===t[t.length-1]&&(t=t.slice(0,t.length-1)),t+=")"),{def:r,canonicalName:t}}function B(e,t=""){const r=[];let n=0;return e.forEach((e,o)=>{Array.isArray(e)?r[r.length-1].push(B(e,`${o}-`)):r.push([`#${t}${o+1-n}`,e.typeIdx,e.szBytes,e.arraySzs]),e.typeIdx===k.indexOf("tuple")&&(n+=1)}),r}function S(e){if("string"!=typeof e)throw new Error("Invalid type");const t=[];let r=e;for(;r.length>0;){const e=r.indexOf("[");if(e<0)return t;const n=r.slice(e),o=n.indexOf("]");if(o<0)throw new Error("Bad param type");const i=n.slice(1,o);0===i.length?t.push(0):t.push(parseInt(i)),r=n.slice(o+1)}return t}function P(e,t=!0){let r=0,n=!1;for(let o=0;o<e.length;o++){"("===e[o]?(r+=1,n=!0):")"===e[o]&&(r-=1);let i=","===e[o+1]||")"===e[o+1]||o===e.length-1;if(t||"["!==e[o+1]||(i=!0),!r&&n&&i)return e.slice(0,o+1)}throw new Error(_)}function I(e){return"("===e[0]}function T(e){return"bytes"===k[e[1]]}function A(e){return T(e)&&0===e[3].length}function j(e){return T(e)&&1===e[3].length&&0===e[3][0]}var _="Could not parse canonical function name.",k=[null,"address","bool","uint","int","bytes","string","tuple","nestedDef"],O={EVM:{type:1,parsers:{parseSolidityJSONABI:function(e,t){e=b(e);const r=t.filter(e=>"function"===e.type).find(t=>g(x(t).canonicalName)===e);if(r){return{def:x(r).def}}throw new Error("Unable to find matching function in ABI")},parseCanonicalName:function(e,t){if((e=b(e))!==g(t))throw new Error("Name does not match provided sig.");const r=[],n=t.indexOf("(");if(n<0)throw new Error(_);r.push(t.slice(0,n)),t=t.slice(n+1);let o=[];for(;t.length>1;){const e=w(t);o=o.concat(E(e)),t=t.slice(e.length+1)}const i=B(o);return r.concat(i)}},processors:{getNestedCalldata:function(e,t){const n=[],o=e.slice(1),i=y(o),s="0x"+t.slice(4).toString("hex"),a=i.map(e=>e.startsWith("tuple(")?e.replace("tuple",""):e),c=(0,m.parseAbiParameters)(a.join(","));function u(e){return(e.length-4)%32==0}return(0,m.decodeAbiParameters)(c,s).forEach((e,t)=>{if(T(o[t])){let i=!0;if(j(o[t]))Array.isArray(e)?e.forEach(e=>{if("string"!=typeof e||!e.startsWith("0x"))return void(i=!1);u(r.from(e.slice(2),"hex"))||(i=!1)}):i=!1;else if(A(o[t]))if("string"==typeof e&&e.startsWith("0x")){const t=e,n=r.from(t.slice(2),"hex");i=u(n)}else i=!1;else i=!1;n.push(i?e:null)}else n.push(null)}),n},replaceNestedDefs:function(e,t){for(let r=0;r<t.length;r++){const n=j(e[1+r]),o=A(e[1+r]);if(null!==t[r]&&(n||o)){e[1+r][1]=k.indexOf("nestedDef");const o=n?t[r]:[t[r]];e[1+r]=e[1+r].concat([o])}}return e}}}},N={aesIv:[109,121,115,101,99,114,101,116,112,97,115,115,119,111,114,100],addrStrLen:129,pairingStatus:{notPaired:0,paired:1},responseMsg:{0:"",128:"Invalid Request",129:"Unsupported Version",130:"Device Busy",131:"Timeout waiting for user",132:"Request declined by user",133:"Pairing failed",134:"Pairing is currently disabled",135:"Automated signing is currently disabled",136:"Device Error",137:"Device Timeout",138:"Active wallet does not match request",139:"Device Locked",140:"Feature Disabled",141:"Record already exists on device",142:"Request failed - needs resync"},msgSizes:{header:8,checksum:4,secure:{payload:{request:{connect:66,encrypted:1733},response:{connect:215,encrypted:3457}},data:{request:{connect:65,encrypted:{encryptedData:1728,0:99,1:54,3:1680,4:0,7:9,8:1391,9:405,12:1025,13:506}},response:{encrypted:{encryptedData:1728,0:0,1:1290,3:1090,4:142,7:1395,8:0,9:0,12:1608,13:1646}}}}}},R={GET_ADDR_FLAGS:{SECP256K1_PUB:3,ED25519_PUB:4,BLS12_381_G1_PUB:5,SECP256K1_XPUB:6},SIGNING:{HASHES:{NONE:0,KECCAK256:1,SHA256:2},CURVES:{SECP256K1:0,ED25519:1,BLS12_381_G2:2},ENCODINGS:{NONE:1,SOLANA:2,EVM:4,ETH_DEPOSIT:5,EIP7702_AUTH:6,EIP7702_AUTH_LIST:7},BLS_DST:{BLS_DST_NUL:1,BLS_DST_POP:2}},ENC_DATA:{SCHEMAS:{BLS_KEYSTORE_EIP2335_PBKDF_V4:0}},ETH_CONSENSUS_SPEC:{NETWORKS:{MAINNET_GENESIS:{networkName:"mainnet",forkVersion:r.alloc(4),validatorsRoot:r.alloc(32)}},DOMAINS:{DEPOSIT:r.from("03000000","hex"),VOLUNTARY_EXIT:r.from("04000000","hex")}}},C={ETH:"ETH",BTC:"BTC",ETH_MSG:"ETH_MSG"},U=2147483648,D={PURPOSES:{ETH:U+44,BTC_LEGACY:U+44,BTC_WRAPPED_SEGWIT:U+49,BTC_SEGWIT:U+84},COINS:{ETH:U+60,BTC:U,BTC_TESTNET:U+1}},L={address:1,bool:2,uint8:3,uint16:4,uint24:5,uint32:6,uint40:7,uint48:8,uint56:9,uint64:10,uint72:11,uint80:12,uint88:13,uint96:14,uint104:15,uint112:16,uint120:17,uint128:18,uint136:19,uint144:20,uint152:21,uint160:22,uint168:23,uint176:24,uint184:25,uint192:26,uint200:27,uint208:28,uint216:29,uint224:30,uint232:31,uint240:32,uint248:33,uint256:34,int8:35,int16:36,int24:37,int32:38,int40:39,int48:40,int56:41,int64:42,int72:43,int80:44,int88:45,int96:46,int104:47,int112:48,int120:49,int128:50,int136:51,int144:52,int152:53,int160:54,int168:55,int176:56,int184:57,int192:58,int200:59,int208:60,int216:61,int224:62,int232:63,int240:64,int248:65,int256:66,uint:67,bytes1:69,bytes2:70,bytes3:71,bytes4:72,bytes5:73,bytes6:74,bytes7:75,bytes8:76,bytes9:77,bytes10:78,bytes11:79,bytes12:80,bytes13:81,bytes14:82,bytes15:83,bytes16:84,bytes17:85,bytes18:86,bytes19:87,bytes20:88,bytes21:89,bytes22:90,bytes23:91,bytes24:92,bytes25:93,bytes26:94,bytes27:95,bytes28:96,bytes29:97,bytes30:98,bytes31:99,bytes32:100,bytes:101,string:102},M={SIGN_PERSONAL:{str:"signPersonal",enumIdx:0},TYPED_DATA:{str:"typedData",enumIdx:1,rawDataMaxLen:1629,typeCodes:L}};var z,F,G,H=/^[\x00-\x7F]+$/,q=10,$={1:{name:"ethereum",baseUrl:"https://api.etherscan.io",apiRoute:"api?module=contract&action=getabi"},137:{name:"polygon",baseUrl:"https://api.polygonscan.com",apiRoute:"api?module=contract&action=getabi"},56:{name:"binance",baseUrl:"https://api.bscscan.com",apiRoute:"api?module=contract&action=getabi"},42220:{name:"celo",baseUrl:"https://api.celoscan.io",apiRoute:"api?module=contract&action=getabi"},43114:{name:"avalanche",baseUrl:"https://api.snowtrace.io",apiRoute:"api?module=contract&action=getabi"}},V=r.alloc(32),W={internal:{uid:V,external:!1,name:r.alloc(0),capabilities:0},external:{uid:V,external:!0,name:r.alloc(0),capabilities:0}},K=[U+44,U+60,U,0,0],Z=[U+44,U+0,U,0,0],Y=[U+44,U+0,U,0,0],J=[U+84,U,U,0,0],X=[U+84,U,U,1,0],Q=[U+49,U,U,0,0],ee=[U+49,U,U,0,0],te="44'/0'/0'",re="49'/0'/0'",ne="84'/0'/0'",oe=[U+44,U+501,U,U],ie=[U+49,U+60,U,0,0],se=[U+49,U+60,U,0],ae=()=>G,ce=e=>{G=e},ue=async e=>{const t=await F();if(!t)throw new Error("Client not initialized");return ae()||ce(Promise.resolve()),ce(ae().then(async()=>await e(t).catch(e=>{throw ce(Promise.resolve()),e}).then(e=>(z(t.getStateData()),e)))),ae()},fe=async()=>{const e=F?await F():void 0;if(!e)throw new Error("Client not initialized");return e},le=e=>async t=>{if(!t)return;const n=(e=>r.from(e).toString("base64"))(t);await e(n)},de=e=>async()=>{const t=await e();if(!t)return;const n=(e=>r.from(e,"base64").toString())(t);if(!n)return;const o=new Un({stateData:n});if(!o)throw new Error("Client not initialized");return o},he=(e,t=0,r=4)=>{const n=[...e];return t>0&&(n[r]=e[r]+t),n},pe=e=>"string"!=typeof e&&"types"in e&&"domain"in e&&"primaryType"in e&&"message"in e;function me(e){if(!e)return[];return ge(e.split("/").filter(Boolean))}function ge(e){return e.map(e=>{const t=e.toLowerCase();if("x"===t)return 0;if("x'"===t)return U;if(e.endsWith("'"))return parseInt(e.slice(0,-1))+U;const r=parseInt(e);if(isNaN(r))throw new Error(`Invalid part in derivation path: ${e}`);return r})}var be,ye=e("@ethereumjs/rlp"),we=d(e("aes-js"),1),Ee=d(e("bignumber.js"),1),ve=e("bn.js"),xe=e("buffer"),Be=d(e("crc-32"),1),Se=d(e("elliptic"),1),Pe=e("ox"),Ie=d(e("lodash/inRange.js"),1),Te=d(e("lodash/isInteger.js"),1),Ae=d(e("secp256k1"),1),je=e("viem"),_e=d(e("lodash/isEmpty.js"),1),ke=e=>{if("number"!=typeof e||!tt(e))throw new Error("Must be an integer between 0 and 15 inclusive");return e},Oe=e=>{if(!e)throw new Error("The number of addresses is required.");if(e>q)throw new Error("You may only request 10 addresses at once.");return e},Ne=e=>{if(!e)throw new Error("Start path is required");if(e.length<1||e.length>5)throw new Error("Path must include between 1 and 5 indices");return e},Re=e=>{if("ECONNABORTED"===e.code&&"ETIME"===e.errno)throw new Error("Timeout waiting for device. Please ensure it is connected to the internet and try again in a minute.");throw new Error(`Failed to make request to device:\n${e.message}`)},Ce=e=>{if(!e||null===e)throw new Error("No active wallet.");return e},Ue=e=>({appName:(e=>{if(!e)throw new Error("Name is required.");if(e.length<5||e.length>24)throw new Error("Invalid length for name provided. Must be 5-24 characters.");return e})(e.getAppName()),ephemeralPub:De(e.ephemeralPub),sharedSecret:Le(e.sharedSecret),url:(e=>{if(!e)throw new Error("URL does not exist. Please reconnect.");try{new URL(e)}catch(e){throw console.error("Invalid URL format:",e),new Error("Invalid URL provided. Please use a valid URL.")}return e})(e.url),fwConstants:(e=>{if(!e)throw new Error("Firmware constants do not exist. Please reconnect.");return e})(e.getFwConstants()),fwVersion:(e=>{if(!e)throw new Error("Firmware version does not exist. Please reconnect.");if("number"!=typeof e.fix||"number"!=typeof e.minor||"number"!=typeof e.major)throw new Error("Firmware version improperly formatted. Please reconnect.");return e})(e.getFwVersion()),key:Me(e.key)}),De=e=>{if(!e)throw new Error("`ephemeralPub` (ephemeral public key) is required. Please reconnect.");return e},Le=e=>{if(!e)throw new Error("Shared secret required. Please reconnect.");return e},Me=e=>{if(!e)throw new Error("Key is required. Please reconnect.");return e},ze=Se.default.ec,{ecdsaRecover:Fe}=Ae.default,{COINS:Ge,PURPOSES:He}=D,qe=function(e){return Be.default.buf(e)>>>0},$e=function(e,t){const r=[],n=Math.ceil(e.length/t);let o=0;for(let i=0;i<n;i++)r.push(e.slice(o,o+t)),o+=t;return r};var Ve=function(e,t=!0){try{if(null===e||("number"==typeof e&&0===e||"bigint"==typeof e&&0n===e)&&!0===t)return xe.Buffer.alloc(0);const r="number"==typeof e||"bigint"==typeof e||"string"==typeof e&&function(e){const t=new Ee.default(e).toFixed().split(".").join(""),r=new String(e);return t.slice(0,8)===r.slice(0,8)}(e);let n;if(r){const t="bigint"==typeof e?e.toString(10):e;n=new Ee.default(t).toString(16)}else if("string"==typeof e&&"0x"===e.slice(0,2))n=e.slice(2);else{if(xe.Buffer.isBuffer(e))return e;n=e.toString()}return n.length%2>0&&(n=`0${n}`),"00"!==n||r?xe.Buffer.from(n,"hex"):xe.Buffer.alloc(0)}catch(t){throw new Error(`Cannot convert ${e.toString()} to hex buffer (${t.message})`)}},We=function(e,t){const r=xe.Buffer.alloc(t);return e.length<t?(e.copy(r,t-e.length),r):e.slice(-t)},Ke=function(e,t){const r=xe.Buffer.from(N.aesIv),n=new we.default.ModeOfOperation.cbc(t,r);return xe.Buffer.from(n.decrypt(e))},Ze=function(e){if(48!==e[0]||2!==e[2])throw new Error("Failed to decode DER signature");let t=3;const r=e[t];t++;const n=e.slice(t,t+r);if(t+=r,2!==e[t])throw new Error("Failed to decode DER signature");t++;const o=e[t];t++;return{r:n,s:e.slice(t,t+o)}},Ye=function(e){return void 0===be&&(be=new ze("p256")),be.keyFromPrivate(e,"hex")},Je=function(e){void 0===be&&(be=new ze("p256"));const t=xe.Buffer.isBuffer(e)?e.toString("hex"):e;return be.keyFromPublic(t,"hex")},Xe=function(e,t){const r=xe.Buffer.alloc(24);let n=0;if(t&&e.length>5)throw new Error("Signer path must be <=5 indices.");if(!t&&5!==e.length)throw new Error("Your Lattice firmware only supports 5-index derivation paths. Please upgrade.");r.writeUInt32LE(e.length,n),n+=4;for(let t=0;t<5;t++)t<e.length?r.writeUInt32LE(e[t],n):r.writeUInt32LE(0,n),n+=4;return r},Qe=function(e,t){return Object.keys(t).some(r=>t[r]===e)},et=function(e){const t=xe.Buffer.alloc(e);for(let r=0;r<e;r++)t[r]=Math.round(255*Math.random());return t},tt=e=>(0,Te.default)(e)&&(0,Ie.default)(e,0,16);function rt(e,t){let r;if(e.length>1&&console.warn("WARNING: There are multiple results. Using the first one."),e.sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).find(e=>{try{return r=O.EVM.parsers.parseCanonicalName(t,e.text_signature),!!r}catch(e){return console.error("Failed to parse canonical name:",e),!1}}),r)return r;throw new Error("Could not find definition for selector")}async function nt(e,t){try{if(globalThis.caches&&globalThis.Request){const r=await caches.open("gp-calldata"),n=new Request(e,t),o=await r.match(n);if(o)return o;{const e=await fetch(n,t),o=e.clone(),i=await e.json();return e.ok&&((e=>{try{const t=JSON.parse(e.result);return!(0,_e.default)(t)}catch(e){return console.error("Invalid block explorer response:",e),!1}})(i)||(e=>{try{return!(0,_e.default)(e.results)}catch(e){return console.error("Invalid 4byte response:",e),!1}})(i))?(await r.put(n,o),r.match(n)):e}}return fetch(e,t)}catch(e){throw console.error(e),e}}async function ot(e){const t=`https://www.4byte.directory/api/v1/signatures/?hex_signature=0x${e}`;return await fetch(t).then(e=>e.json()).then(e=>{if(e&&e.results)return e.results;throw new Error("No results found")}).catch(e=>{throw new Error(`Fetching data from 4byte failed: ${e.message}`)})}function it(e){return xe.Buffer.from(ye.RLP.encode(e))}async function st(e,t){const r=O.EVM.processors.getNestedCalldata(e,t),n=await async function(e){const t=[];for await(const r of e)if(null!==r)if(Array.isArray(r)){const e=[];let n=!0;for await(const t of r)try{const r=t.slice(2,10),n=rt(await ot(r),r);e.push(n)}catch(t){console.error("Failed to fetch nested 4byte data:",t),n=!1,e.push(null)}n?t.push(e):t.push(null)}else try{const e=r.slice(2,10),n=rt(await ot(e),e);t.push(n)}catch(e){console.error("Failed to fetch nested definition:",e),t.push(null)}else t.push(null);return t}(r);for await(const[e]of n.entries())if(Array.isArray(n[e])&&"string"!=typeof n[e][0])for await(const[t]of n[e].entries())null!==n[e][t]&&(n[e][t]=await st(n[e][t],xe.Buffer.from(r[e][t].slice(2),"hex")));else null!==n[e]&&(n[e]=await st(n[e],xe.Buffer.from(r[e].slice(2),"hex")));return O.EVM.processors.replaceNestedDefs(e,n)}async function at(e,t,r,n=!0){try{if(!e||e.length<2)throw new Error("Data is either undefined or less than two bytes");const o="string"==typeof e&&"0x"===e.slice(0,2)?xe.Buffer.from(e.slice(2),"hex"):xe.Buffer.from(e,"hex");if(0===o.length)return{def:null,abi:null};if(o.length<4)throw new Error("Data must contain at least 4 bytes of data to define the selector");const i=xe.Buffer.from(o.slice(0,4)).toString("hex"),s=Number(r),a=$[s],c=a||await async function(e){try{const t=await fetch("https://gridplus.github.io/chains/chains.json").then(e=>e.json());return t?t[e]:void 0}catch(e){console.warn("Fetching external networks failed.\n",e)}}(s);try{if(c){const e=await async function(e,t){const r=function({supportedChain:e,address:t}){return`${e.baseUrl}/${e.apiRoute}&address=${t}`}({address:e,supportedChain:t});return nt(r).then(e=>e.json()).then(e=>{if(!e||!e.result)throw new Error("Server response was malformed");try{return JSON.parse(e.result)}catch{throw new Error(`Invalid JSON in response: ${e.result.substring(0,50)}`)}}).catch(e=>{throw console.log(e),new Error("Fetching data from external network failed")})}(t,c);let r=O.EVM.parsers.parseSolidityJSONABI(i,e).def;return n&&(r=await st(r,o)),{abi:e,def:it(r)}}throw new Error(`Chain (id: ${s}) is not supported`)}catch(e){console.warn(e.message,"\n","Falling back to 4byte")}const u=await ot(i);let f=rt(u,i);return n&&(f=await st(f,o)),{abi:u,def:it(f)}}catch(e){console.warn(`Fetching calldata failed: ${e.message}`)}return{def:null,abi:null}}var ct=(e,t,r)=>{const n="string"==typeof e?xe.Buffer.from(e):e,o="string"==typeof t?xe.Buffer.from(t):t,i="string"==typeof r?xe.Buffer.from(r):r,s=xe.Buffer.concat([n,o,i]);return xe.Buffer.from(Pe.Hash.sha256(s))},ut=function(e,t){let r,n,o,i=!1;if(!xe.Buffer.isBuffer(e)&&"string"!=typeof e)throw new Error("Unsupported transaction format. Expected Buffer or hex string.");{const t=xe.Buffer.isBuffer(e)?`0x${e.toString("hex")}`:e,s=xe.Buffer.isBuffer(e)?e:xe.Buffer.from(e.slice(2),"hex");n=xe.Buffer.from(Pe.Hash.keccak256(s));try{const e=(0,je.parseTransaction)(t);if(o=e.type,void 0!==e.chainId&&null!==e.chainId&&(r=e.chainId.toString(),"legacy"===o&&(i=!0)),"legacy"===o&&!i){const e=ye.RLP.decode(s);if(e.length>=9){const t=e[6];t&&t.length>0&&(r=new ve.BN(t).toString(),i=!0)}}}catch(t){console.error("Failed to parse transaction, trying legacy format:",t);try{const t=xe.Buffer.isBuffer(e)?e:xe.Buffer.from(e.slice(2),"hex"),n=ye.RLP.decode(t);if(o="legacy",n.length>=9){const e=n[6];e&&e.length>0&&(r=new ve.BN(e).toString(),i=!0)}}catch{throw new Error("Could not recover V. Bad transaction data.")}}}const s=xe.Buffer.isBuffer(t.sig.r)?t.sig.r:xe.Buffer.from(t.sig.r.slice(2),"hex"),a=xe.Buffer.isBuffer(t.sig.s)?t.sig.s:xe.Buffer.from(t.sig.s.slice(2),"hex"),c=new Uint8Array(xe.Buffer.concat([s,a])),u=t.pubkey;if(!u)throw new Error("Response did not include a public key.");let f;if(xe.Buffer.isBuffer(u))f=xe.Buffer.from(u);else if(u instanceof Uint8Array)f=xe.Buffer.from(u);else if("string"==typeof u){const e=u.startsWith("0x")?u.slice(2):u;f=xe.Buffer.from(e,"hex")}else f=xe.Buffer.from(u);64===f.length&&(f=xe.Buffer.concat([xe.Buffer.from([4]),f]));const l=33===f.length&&(2===f[0]||3===f[0]),d=65===f.length&&4===f[0];if(!l&&!d)throw new Error("Unsupported public key format returned by device.");const h=xe.Buffer.from(Fe(c,0,n,l)),p=xe.Buffer.from(Fe(c,1,n,l)),m=f.toString("hex"),g=h.toString("hex"),b=p.toString("hex");let y;if(m===g)y=0;else{if(m!==b)throw new Error("Failed to recover V parameter. Bad signature or transaction data.");y=1}const w=ft(y,{chainId:r,useEIP155:i,type:o});return xe.Buffer.isBuffer(w)?0===w.length?new ve.BN(0):new ve.BN(w.toString("hex"),16):w},ft=function(e,t={}){const{chainId:r,useEIP155:n,type:o}=t;return 1===o||2===o||4===o||"eip2930"===o||"eip1559"===o||"eip7702"===o?Ve(e,!0):n&&r?new ve.BN(r).muln(2).addn(35).addn(e):new ve.BN(e).addn(27)},lt=function(e,t,r){if("object"==typeof e&&e&&"messageHash"in e)return lt(e.messageHash,e.signature,e.publicKey);if(t&&t.sig&&t.pubkey&&!r)return lt(e,t.sig,t.pubkey);if(!t||!r)throw new Error("Response with sig and pubkey required for legacy format");if(!t.r||!t.s)throw new Error("Response with sig and pubkey required for legacy format");let n=e;if("object"==typeof e&&e&&"function"==typeof e.getMessageToSign){const t=e._type;if(null!=t)n=e.getMessageToSign(!0);else{const t=ye.RLP.encode(e.getMessageToSign(!1));n=xe.Buffer.from(Pe.Hash.keccak256(t))}}else xe.Buffer.isBuffer(e)&&32!==e.length&&(n=xe.Buffer.from(Pe.Hash.keccak256(e)));const o=e=>{if(!e)throw new Error("Invalid data");if(xe.Buffer.isBuffer(e))return e;if(e instanceof Uint8Array)return xe.Buffer.from(e);if("string"==typeof e)return xe.Buffer.from(e.replace(/^0x/i,""),"hex");throw new Error("Invalid data type")},i=o(n),s=o(t.r),a=o(t.s),c=o(r),u=32===i.length?i:xe.Buffer.from(Pe.Hash.keccak256(i)),f=new Uint8Array(xe.Buffer.concat([s,a])),l=new Uint8Array(u),d=33===c.length;for(let e=0;e<=1;e++)try{const t=Fe(f,e,l,d);if(xe.Buffer.from(t).equals(c))return e}catch{continue}throw new Error("Failed to recover Y parity. Bad signature or transaction data.")},dt={fetchCalldataDecoder:at,generateAppSecret:ct,getV:ut,getYParity:lt,convertRecoveryToV:ft},ht=e("ox"),pt=e("bech32"),mt=d(e("bs58check"),1),gt=e("ox"),bt=e("hash.js/lib/hash/ripemd.js"),yt=r.from("01","hex"),{PURPOSES:wt,COINS:Et}=D,vt=0,xt=169,Bt=118,St=135,Pt=136,It=172,Tt=208,At=240;function jt(e,t){return r.concat([e,t])}function _t(e){const t=r.alloc(4);return t.writeUInt32LE(e,0),t}function kt(e){let t;return e<253?(t=r.alloc(1),t.writeUInt8(e,0)):e<=65535?(t=r.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967295?(t=r.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=r.alloc(9),t.writeUInt8(255,0),t.writeUInt32LE(e>>>0,1),t.writeUInt32LE(e/4294967296|0,5)),t}function Ot(e,t,n){"number"==typeof e&&(e=e.toString(16));const o=r.alloc(8),i=e.length%2==0?e.toString(16):`0${e.toString(16)}`;return r.from(i,"hex").reverse().copy(o,0),o.copy(t,n),o}function Nt(e){let t,n;try{t=mt.default.decode(e)[0],n=r.from(mt.default.decode(e).slice(1))}catch(o){console.error("Failed to decode base58 address, trying bech32:",o);try{const o=pt.bech32.decode(e);if("bc"===o.prefix)t=Tt;else{if("tb"!==o.prefix)throw new Error("Unsupported prefix: must be bc or tb.");t=At}if(0!==o.words[0])throw new Error(`Unsupported segwit version: must be 0, got ${o.words[0]}`);if(33!==o.words.length){const t=53===o.words.length;throw new Error(`Unsupported address${t?" (P2WSH not supported)":""}: ${e}`)}n=r.from(pt.bech32.fromWords(o.words.slice(1)))}catch(t){throw new Error(`Unable to decode address: ${e}: ${t.message}`)}}return{versionByte:t,pkh:n}}function Rt(e){if(e.length<2)throw new Error("Path must be >1 index");const t=e[0],r=e[1];if(t===wt.BTC_SEGWIT&&r===Et.BTC)return Tt;if(t===wt.BTC_SEGWIT&&r===Et.BTC_TESTNET)return At;if(t===wt.BTC_WRAPPED_SEGWIT&&r===Et.BTC)return 5;if(t===wt.BTC_WRAPPED_SEGWIT&&r===Et.BTC_TESTNET)return 196;if(t===wt.BTC_LEGACY&&r===Et.BTC)return 0;if(t===wt.BTC_LEGACY&&r===Et.BTC_TESTNET)return 111;throw new Error("Invalid Bitcoin path provided. Cannot determine address format.")}function Ct(e){switch(e.signerPath[0]){case wt.BTC_LEGACY:return 1;case wt.BTC_WRAPPED_SEGWIT:return 3;case wt.BTC_SEGWIT:return 4;default:throw new Error(`Unsupported path purpose (${e.signerPath[0]}): cannot determine BTC script type.`)}}var Ut={buildBitcoinTxRequest:function(e){const{prevOuts:t,recipient:n,value:o,changePath:i,fee:s}=e;if(!i)throw new Error("No changePath provided.");if(5!==i.length)throw new Error("Please provide a full change path.");const a=r.alloc(59+69*t.length);let c=0;const u=Rt(i);a.writeUInt8(u,0),c++,a.writeUInt32LE(i.length,c),c+=4;for(let e=0;e<i.length;e++)a.writeUInt32LE(i[e],c),c+=4;a.writeUInt32LE(s,c),c+=4;const f=Nt(n);a.writeUInt8(f.versionByte,c),c++,f.pkh.copy(a,c),c+=f.pkh.length,Ot(o,a,c),c+=8,a.writeUInt8(t.length,c),c++;let l=0;return t.forEach(e=>{if(!e.signerPath||5!==e.signerPath.length)throw new Error("Full recipient path not specified ");a.writeUInt32LE(e.signerPath.length,c),c+=4;for(let t=0;t<e.signerPath.length;t++)a.writeUInt32LE(e.signerPath[t],c),c+=4;a.writeUInt32LE(e.index,c),c+=4,Ot(e.value,a,c),c+=8,l+=e.value;const t=Ct(e);a.writeUInt8(t,c),c++,r.isBuffer(e.txHash)||(e.txHash=r.from(e.txHash,"hex")),e.txHash.copy(a,c),c+=e.txHash.length}),{payload:a,schema:0,origData:e,changeData:{value:l-(o+s)}}},serializeTx:function(e){const{inputs:t,outputs:n,lockTime:o=0}=e;let i=r.alloc(4),s=0;const a=function(e){let t=!1;return e.forEach(e=>{e.signerPath[0]!==wt.BTC_SEGWIT&&e.signerPath[0]!==wt.BTC_WRAPPED_SEGWIT||(t=!0)}),t}(t);i.writeUInt32LE(2,s),s+=4,a&&(i=jt(i,r.from("00","hex")),i=jt(i,r.from("01","hex")));const c=kt(t.length);i=jt(i,c),s+=c.length,t.forEach(e=>{i=jt(i,e.hash.reverse()),s+=e.hash.length;const t=_t(e.index);i=jt(i,t),s+=t.length;const n=Ct(e);if(3===n){const t=function(e){const t=r.alloc(22),n=r.from(gt.Hash.sha256(e)),o=r.from((0,bt.ripemd160)().update(n).digest("hex"),"hex");return t.writeUInt8(vt,0),t.writeUInt8(o.length,1),o.copy(t,2),t}(e.pubkey),n=kt(t.length),o=r.concat([n,t]),a=kt(o.length);i=jt(i,a),s+=a.length,i=jt(i,o),s+=o.length}else if(1===n){const t=function(e,t){const n=kt((e=r.concat([e,yt])).length),o=kt(t.length),i=r.concat([n,e,o,t]),s=kt(i.length);return r.concat([s,i])}(e.sig,e.pubkey);i=jt(i,t),s+=t.length}else if(4===n){const e=r.from("00","hex");i=jt(i,e),s+=1}const o=_t(4294967295);i=jt(i,o),s+=o.length});const u=kt(n.length);if(i=jt(i,u),s+=u.length,n.forEach(e=>{const t=function(e){const t=r.alloc(8);return Ot(e,t,0),t}(e.value);i=jt(i,t),s+=t.length;const n=function(e){const t=Nt(e);switch(t.versionByte){case Tt:case At:return function(e){const t=r.alloc(2+e.length);return t.writeUInt8(vt,0),t.writeUInt8(e.length,1),e.copy(t,2),t}(t.pkh);case 5:case 196:return function(e){const t=r.alloc(3+e.length);let n=0;return t.writeUInt8(xt,n),n++,t.writeUInt8(e.length,n),n++,e.copy(t,n),n+=e.length,t.writeUInt8(St,n),n++,t}(t.pkh);case 0:case 111:return function(e){const t=r.alloc(5+e.length);let n=0;return t.writeUInt8(Bt,n),n++,t.writeUInt8(xt,n),n++,t.writeUInt8(e.length,n),n++,e.copy(t,n),n+=e.length,t.writeUInt8(Pt,n),n++,t.writeUInt8(It,n),n++,t}(t.pkh);default:throw new Error(`Unknown version byte: ${t.versionByte}. Cannot build BTC transaction.`)}}(e.recipient),o=kt(n.length);i=jt(i,o),s+=o.length,i=jt(i,n),s+=n.length}),a){const e=[],n=[];for(let r=0;r<t.length;r++)e.push(t[r].sig),n.push(t[r].pubkey);const o=function(e,t){let n=r.alloc(0);const o=r.alloc(1);o.writeUInt8(2,0);for(let i=0;i<e.length;i++){const s=r.concat([e[i],yt]),a=kt(s.length),c=t[i],u=kt(c.length);n=r.concat([n,o,a,s,u,c])}return n}(e,n);i=jt(i,o),s+=o.length}return r.concat([i,_t(o)]).toString("hex")},getBitcoinAddress:function(e,t){let n=null,o=null;if(t===Tt?(n="bc",o=0):t===At&&(n="tb",o=0),null!==n&&null!==o){const t=pt.bech32.toWords(e);return t.unshift(o),pt.bech32.encode(n,t)}return mt.default.encode(r.concat([r.from([t]),e]))},getAddressFormat:Rt},Dt=d(e("bignumber.js"),1),Lt=e("@metamask/eth-sig-util"),Mt=e("ox"),zt=e("@ethereumjs/rlp"),Ft=d(e("secp256k1"),1),Gt=d(e("cbor"),1),Ht=d(e("cbor-bigdecimal"),1),qt=e("viem"),$t=0,Vt=1,Wt=2,Kt=4,Zt=5,Yt=e("ox"),Jt=e("@ethereumjs/rlp"),Xt=e("viem"),Qt=function(e){const{signerPath:t,curveType:n,hashType:o,encodingType:i=null,decoder:s=null,omitPubkey:a=!1,fwConstants:c,blsDst:u=R.SIGNING.BLS_DST.BLS_DST_NUL}=e,{extraDataFrameSz:f,extraDataMaxFrames:l,prehashAllowed:d,genericSigning:h,varAddrPathSzAllowed:p}=c,{curveTypes:m,encodingTypes:g,hashTypes:b,baseDataSz:y,baseReqSz:w,calldataDecoding:E}=h,v=rr(e.payload,i,g),{encoding:x}=v;let{payloadBuf:B}=v;const S=B;let P=B.length;const I=y+l*f;if(!P)throw new Error("Payload could not be handled.");if(!(h&&f&&l&&d))throw new Error("Unsupported. Please update your Lattice firmware.");if(!Qe(n,m))throw new Error("Unsupported curve type.");if(!Qe(o,b))throw new Error("Unsupported hash type.");const T=s&&E&&s.length<=E.maxSz,A=T&&B.length+s.length<=I;if(T&&A){const e=r.alloc(8+s.length);e.writeUInt32LE(E.reserved,0),e.writeUInt32LE(s.length,4),r.from(s).copy(e,8),B=r.concat([B,e])}if(n===m.ED25519){if(o!==b.NONE)throw new Error("Signing on ed25519 requires unhashed message");t.forEach(e=>{if(e<U)throw new Error("Signing on ed25519 requires all signer path indices be hardened.")})}else if(n===m.BLS12_381_G2){const e=r.alloc(4);e.writeUInt32LE(u),B=r.concat([e,B]),P+=e.length}const j=r.alloc(w);let _=0;j.writeUInt32LE(x,_),_+=4,j.writeUInt8(o,_),_+=1,j.writeUInt8(n,_),_+=1;const k=Xe(t,p);k.copy(j,_),_+=k.length,j.writeUInt8(a?1:0,_),_+=1;const O=[];let N=null,C=!1;if(B.length>y)if(d&&B.length>I){j.writeUInt16LE(B.length,_),_+=2,C=!0;const e=B.slice(0,P);if(o===b.NONE)throw new Error("Message too large to send and could not be prehashed (hashType=NONE).");if(o===b.KECCAK256)N=r.from(Yt.Hash.keccak256(e));else{if(o!==b.SHA256)throw new Error("Unsupported hash type.");N=r.from(Yt.Hash.sha256(e))}}else{$e(B.slice(y),f).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),O.push(r.concat([t,e]))})}C||(j.writeUInt16LE(P,_),_+=2);return(N||B).copy(j,_),{payload:j,extraDataPayloads:O,schema:5,curveType:n,encodingType:i,hashType:o,omitPubkey:a,origPayloadBuf:S}};function er(e,t){if(t&&32===t.length&&t.some(e=>0!==e))return t;if(e.hashType===R.SIGNING.HASHES.SHA256)return r.from(Yt.Hash.sha256(e.origPayloadBuf));if(e.hashType===R.SIGNING.HASHES.KECCAK256)return r.from(Yt.Hash.keccak256(e.origPayloadBuf));throw new Error("Unsupported hash type for message hash computation.")}function tr(e,t,r){if(t.encodingType===R.SIGNING.ENCODINGS.EVM)try{const n=`0x${t.origPayloadBuf.toString("hex")}`,o=(0,Xt.parseTransaction)(n),i={chainId:o.chainId,to:o.to??void 0,value:o.value??0n,data:o.data??"0x",nonce:o.nonce??0n,gas:o.gas??o.gasLimit??0n};void 0!==o.maxFeePerGas&&(i.maxFeePerGas=o.maxFeePerGas),void 0!==o.maxPriorityFeePerGas&&(i.maxPriorityFeePerGas=o.maxPriorityFeePerGas),void 0!==o.gasPrice&&(i.gasPrice=o.gasPrice),void 0!==o.accessList&&(i.accessList=o.accessList),void 0!==o.authorizationList&&(i.authorizationList=o.authorizationList),void 0!==o.type&&null!==o.type&&(i.type=o.type);const s="legacy"===o.type||void 0===o.type?{v:e,r:r.sig.r,s:r.sig.s}:{yParity:Number(e),r:r.sig.r,s:r.sig.s};r.viemTx=(0,Xt.serializeTransaction)(i,s)}catch(e){console.debug("Failed to build viemTx from response",e)}}var rr=function(e,t,n){if(t||(t=R.SIGNING.ENCODINGS.NONE),!Qe(t,n))throw new Error("Encoding not supported by Lattice firmware. You may want to update.");let o;if(!e)throw new Error("No payload included");return o="string"==typeof e&&"0x"===e.slice(0,2)?r.from(e.slice(2),"hex"):r.from(e),{payloadBuf:o,encoding:t}},nr=e("zod"),or=e("viem"),ir=nr.z.union([nr.z.string().regex(/^(0x[0-9a-fA-F]+|[0-9]+)$/,"Invalid number format"),nr.z.number(),nr.z.bigint()]).transform((e,t)=>{try{const r="string"==typeof e&&(0,or.isHex)(e)?(0,or.hexToBigInt)(e):BigInt(e);return r<0n?(t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Value must be non-negative"}),nr.z.NEVER):r}catch{return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Invalid numeric value"}),nr.z.NEVER}}),sr=ir.refine(e=>e>=0n,{message:"Gas values must be non-negative"}),ar=nr.z.union([nr.z.string(),nr.z.number()]).transform(e=>"string"==typeof e&&(0,or.isHex)(e)?Number((0,or.hexToBigInt)(e)):Number(e)).refine(e=>Number.isInteger(e)&&e>0,{message:"Chain ID must be a positive integer"}),cr=nr.z.string().refine(or.isAddress,"Invalid address").transform(e=>(0,or.getAddress)(e)),ur=nr.z.string().refine(or.isHex,"Data must be a valid hex string").default("0x"),fr=nr.z.union([nr.z.string().regex(/^(0x[0-9a-fA-F]+|[0-9]+)$/,"Invalid nonce format"),nr.z.number().int().nonnegative(),nr.z.bigint()]).transform((e,t)=>{try{const r="string"==typeof e?(0,or.isHex)(e)?(0,or.hexToBigInt)(e):BigInt(e):"number"==typeof e?BigInt(e):e;if(r<0n)return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Nonce must be non-negative"}),nr.z.NEVER;return r>BigInt(Number.MAX_SAFE_INTEGER)?(t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Nonce exceeds JavaScript safe integer range"}),nr.z.NEVER):Number(r)}catch{return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Invalid nonce value"}),nr.z.NEVER}}),lr=nr.z.object({address:cr,storageKeys:nr.z.array(nr.z.string().refine(or.isHex,"Storage key must be a hex string"))}),dr=nr.z.object({chainId:nr.z.number().int().positive(),address:cr,nonce:nr.z.number().int().nonnegative(),yParity:nr.z.number().optional().default(0),r:nr.z.string().refine(or.isHex).optional(),s:nr.z.string().refine(or.isHex).optional()}),hr=nr.z.object({to:cr.optional(),value:ir.optional(),data:ur,nonce:fr.optional(),gas:sr.optional(),gasLimit:sr.optional(),chainId:ar.optional().default(1),accessList:nr.z.array(lr).optional()}),pr=hr.extend({type:nr.z.union([nr.z.literal("legacy"),nr.z.literal($t)]).optional(),gasPrice:sr}),mr=hr.extend({type:nr.z.union([nr.z.literal("eip2930"),nr.z.literal(Vt)]),gasPrice:sr}),gr=hr.extend({type:nr.z.union([nr.z.literal("eip1559"),nr.z.literal(Wt)]),maxFeePerGas:sr,maxPriorityFeePerGas:sr}),br=hr.extend({type:nr.z.union([nr.z.literal("eip7702"),nr.z.literal(Kt),nr.z.literal(Zt)]),maxFeePerGas:sr,maxPriorityFeePerGas:sr,authorizationList:nr.z.array(dr).min(1)}),yr=nr.z.any().refine(e=>{try{return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t),!0}catch{return!1}},{message:"Circular reference detected in transaction object"}).transform(e=>(e.gasLimit&&(e.gas=e.gasLimit),null!==e.data&&void 0!==e.data&&""!==e.data||(e.data="0x"),e.authorization&&(e.authorizationList=[e.authorization]),e)).transform(e=>{const t=!!e.authorizationList,r=!!e.maxFeePerGas||!!e.maxPriorityFeePerGas,n=!!e.accessList,o=!!e.gasPrice;let i="legacy",s=pr;if("eip7702"===e.type||4===e.type||5===e.type||t?(i="eip7702",s=br):"eip1559"===e.type||2===e.type||r?(i="eip1559",s=gr):("eip2930"===e.type||1===e.type||n)&&(i="eip2930",s=mr),"legacy"===i&&!o)throw new Error("Legacy transactions require a `gasPrice` field.");const a=s.parse(e);return a.type=i,"legacy"===i&&void 0===a.gas&&(a.gas=21000n),"legacy"!==i&&"eip2930"!==i&&delete a.gasPrice,"eip1559"!==i&&"eip7702"!==i&&(delete a.maxFeePerGas,delete a.maxPriorityFeePerGas),delete a.gasLimit,"eip7702"!==i&&delete a.authorizationList,a}),{ecdsaRecover:wr}=Ft.default;(0,Ht.default)(Gt.default);function Er(e){if(null==e)return e;if("string"==typeof e){const t=e.trim();if(/^0x[0-9a-fA-F]+$/.test(t))try{const e=BigInt(t);return e<=BigInt(Number.MAX_SAFE_INTEGER)&&e>=BigInt(Number.MIN_SAFE_INTEGER)?Number(e):e.toString(10)}catch{return t}return t}if("bigint"==typeof e){const t=Number(e);return Number.isSafeInteger(t)?t:e.toString(10)}if(Dt.default.isBigNumber(e)){const t=Number(e.toString(10));return Number.isSafeInteger(t)?t:e.toString(10)}if(e&&"object"==typeof e&&"function"==typeof e.toString&&e.constructor&&"BN"===e.constructor.name&&"function"==typeof e.toArray){const t=e.toString(10),r=Number(t);return Number.isSafeInteger(r)?r:t}if(r.isBuffer(e)||e instanceof Uint8Array)return`0x${r.from(e).toString("hex")}`;if(Array.isArray(e))return e.map(e=>Er(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=Er(n);return t}return e}function vr(e){return void 0===e?e:Br?Br(e):xr(e)}function xr(e){if(null===e||"object"!=typeof e)return e;if(r.isBuffer(e))return r.from(e);if(e instanceof Uint8Array)return new Uint8Array(e);if(Array.isArray(e))return e.map(e=>xr(e));if(Dt.default.isBigNumber(e))return new Dt.default(e);if(e&&"object"==typeof e&&"BN"===e.constructor?.name&&"function"==typeof e.clone)return e.clone();if(e instanceof Date)return new Date(e.getTime());const t={};for(const[r,n]of Object.entries(e))t[r]=xr(n);return t}var Br="undefined"!=typeof globalThis&&"function"==typeof globalThis.structuredClone?globalThis.structuredClone:null;function Sr(e){let t=e[0];for(;e.length>0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e}function Pr(e,t,n,o={}){try{const i=new Uint8Array(e),s=r.isBuffer(n)?n:Ve(n,!1);if(20!==s.length)throw new Error("Invalid signer address provided.");let a=0;const c=We(t.r,32);t.r=c;const u=We(t.s,32);t.s=u;const f=new Uint8Array(r.concat([c,u]));let l=wr(f,a,i,!1).slice(1);const d=s.toString("hex"),h=[];let p=Ir(l);if(h.push(p),p===d)return t.v=Tr(a,o),t;if(a=1,l=wr(f,a,i,!1).slice(1),p=Ir(l),h.push(p),p===d)return t.v=Tr(a,o),t;throw new Error(`Invalid Ethereum signature returned. expected=${d}, recovered=${h.join(",")}`)}catch(e){if(e instanceof Error)throw e;throw new Error(String(e))}}function Ir(e){return r.from(Mt.Hash.keccak256(e)).slice(-20).toString("hex")}function Tr(e,t={}){const n=ft(e,t);return r.isBuffer(n)?n:Ve(`0x${n.toString(16)}`)}var Ar={mainnet:1,roptsten:3,rinkeby:4,kovan:42,goerli:5};function jr(e){let t,n;if(t=!0===_r(e)?Ve(e):Ve(`0x${new Dt.default(e).toString(16)}`),t.length>8)throw new Error("ChainID provided is too large.");return t.length<=2||4===t.length||8===t.length?t:(3===t.length?(n=r.alloc(4),n.writeUInt32BE(e)):t.length<=8&&(n=r.alloc(8),t.copy(n,8-t.length)),n)}function _r(e){if("string"!=typeof e)return!1;if("0x"!==e.slice(0,2))return!1;try{return!1===new Dt.default(e,16).isNaN()}catch(e){return console.error("Invalid chain ID hex string:",e),!1}}function kr(e,t){const{ethMaxMsgSz:n,extraDataFrameSz:o,extraDataMaxFrames:i}=t.fwConstants,s=n,a=o>0&&i>0,c=[];if(e.length>s){const t=s+i*o;if(!a)throw new Error(`Your message is ${e.length} bytes, but can only be a maximum of ${s}`);if(a&&e.length>t)throw new Error(`Your message is ${e.length} bytes, but can only be a maximum of ${t}`);$e(e.slice(s),o).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),c.push(r.concat([t,e]))})}return c}function Or(e,t,r,n=!1){return r[t].forEach(t=>{const o=t.type.indexOf("[")>-1,i=o?t.type.slice(0,t.type.indexOf("[")):t.type,s=Object.keys(r).indexOf(i)>-1;if(s&&Array.isArray(e))for(let o=0;o<e.length;o++)e[o][t.name]=Or(e[o][t.name],i,r,n);else if(s)e[t.name]=Or(e[t.name],i,r,n);else if(Array.isArray(e))for(let r=0;r<e.length;r++)if(o)for(let o=0;o<e[r][t.name].length;o++)e[r][t.name][o]=Nr(e[r][t.name][o],i,n);else e[r][t.name]=Nr(e[r][t.name],i,n);else if(o)for(let r=0;r<e[t.name].length;r++)e[t.name][r]=Nr(e[t.name][r],i,n);else e[t.name]=Nr(e[t.name],i,n)}),e}function Nr(e,t,n=!1){if("bytes"===t)e=Ve(e),n&&(e=`0x${e.toString("hex")}`);else if("bytes"===t.slice(0,5)){const o=parseInt(t.slice(5));if(0===(e=Ve(e)).length&&(e=r.alloc(o)),e.length!==o)throw new Error(`Expected ${t} type, but got ${e.length} bytes`);n&&(e=`0x${e.toString("hex")}`)}else if("address"===t){if(0===(e=Ve(e)).length&&(e=r.alloc(20)),20!==e.length)throw new Error(`Address type must be 20 bytes, but got ${e.length} bytes`);n&&(e=`0x${e.toString("hex")}`)}else if(M.TYPED_DATA.typeCodes[t]&&-1===t.indexOf("uint")&&t.indexOf("int")>-1)if(n){e=new Dt.default(e).toFixed()}else e=new Dt.default(e);else if(M.TYPED_DATA.typeCodes[t]&&(t.indexOf("uint")>-1||t.indexOf("int")>-1)){let t=Ve(e);0===t.length&&(t=r.from("00","hex")),e=n?`0x${t.toString("hex")}`:new Dt.default(t.toString("hex"),16)}else"bool"===t&&(e=!0===e?1:0);return e}function Rr(e){return r.from(`Ethereum Signed Message:\n${e.toString()}`,"utf-8")}function Cr(e,t){return t?r.concat([r.from([t]),r.from(zt.RLP.encode(e))]):r.from(zt.RLP.encode(e))}var Ur=e=>{const t=yr.parse(e);return{...t,to:t.to,data:t.data,gas:t.gas,value:t.value,nonce:t.nonce,chainId:t.chainId,gasPrice:"gasPrice"in t?t.gasPrice:void 0,maxFeePerGas:"maxFeePerGas"in t?t.maxFeePerGas:void 0,maxPriorityFeePerGas:"maxPriorityFeePerGas"in t?t.maxPriorityFeePerGas:void 0,accessList:"accessList"in t?t.accessList:void 0,authorizationList:"authorizationList"in t?t.authorizationList:void 0}},Dr=function(e){const t=Ur(e),n=(0,qt.serializeTransaction)(t);return r.from(n.slice(2),"hex")},Lr=function(e){if(!e.payload||!e.protocol||!e.signerPath)throw new Error("You must provide `payload`, `signerPath`, and `protocol` arguments in the messsage request");if(e.signerPath.length>5||e.signerPath.length<2)throw new Error("Please provide a signer path with 2-5 indices");const t={schema:3,payload:null,input:e,msg:null};switch(e.protocol){case"signPersonal":return function(e,t){const n=t.fwConstants.ethMaxMsgSz,o=t.fwConstants.varAddrPathSzAllowed,i=24+n+4;let s=0;e.payload=r.alloc(i),e.payload.writeUInt8(M.SIGN_PERSONAL,0),s+=1;const a=Xe(t.signerPath,o);a.copy(e.payload,s),s+=a.length;let c=t.payload,u=!1;if("string"==typeof t.payload)if("0x"===t.payload.slice(0,2))c=Ve(t.payload),u=!1===H.test(r.from(t.payload.slice(2),"hex").toString());else{if(!1===function(e,t=!1){if("string"!=typeof e)return!1;const r=t?[32,10]:[];for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(r.indexOf(n)<0&&(n<32||n>127))return!1}return!0}(t.payload))throw new Error("Currently, the Lattice can only display ASCII strings.");c=r.from(t.payload)}else if("boolean"==typeof t.displayHex)u=t.displayHex;else{if(!t.payload.toString)throw new Error("Unsupported input data type");u=!1===H.test(t.payload.toString())}const f=t.fwConstants;let l=n+f.extraDataMaxFrames*f.extraDataFrameSz;f.personalSignHeaderSz&&(l-=f.personalSignHeaderSz);if(f.ethMsgPreHashAllowed&&c.length>l){e.payload.writeUInt8(u,s),s+=1,e.payload.writeUInt16LE(c.length,s),s+=2;const t=r.from(Mt.Hash.keccak256(r.concat([Rr(c.length),c])));t.copy(e.payload,s),e.prehash=t}else{const r=kr(c,t);e.extraDataPayloads=r,e.msg=c,e.payload.writeUInt8(u,s),s+=1,e.payload.writeUInt16LE(c.length,s),s+=2,c.copy(e.payload,s)}return e}(t,e);case"eip712":if(!e.fwConstants.eip712Supported)throw new Error("EIP712 is not supported by your Lattice firmware version. Please upgrade.");return function(e,t){const{ethMaxMsgSz:n,varAddrPathSzAllowed:o,eip712MaxTypeParams:i}=t.fwConstants,{TYPED_DATA:s}=M,a=24+n+4;let c=0;e.payload=r.alloc(a),e.payload.writeUInt8(s.enumIdx,0),c+=1;const u=Xe(t.signerPath,o);u.copy(e.payload,c),c+=u.length;const f=vr(t.payload);if(!f.primaryType||!f.types[f.primaryType])throw new Error("primaryType must be specified and the type must be included.");if(!f.message||!f.domain)throw new Error("message and domain must be specified.");if(0>Object.keys(f.types).indexOf("EIP712Domain"))throw new Error("EIP712Domain type must be defined.");const l=vr(f);l.message=Or(vr(f.message),vr(f.primaryType),vr(f.types),!0),l.domain=Or(vr(f.domain),"EIP712Domain",vr(f.types),!0),e.validationPayload=l,f.domain=Or(f.domain,"EIP712Domain",f.types,!1),f.message=Or(f.message,f.primaryType,f.types,!1);const d=r.from(Gt.default.encode(f)),h=t.fwConstants,p=n+h.extraDataMaxFrames*h.extraDataFrameSz;let m=d.length>p;if(Object.keys(f.types).forEach(e=>{f.types[e].length>i&&(m=!0)}),h.ethMsgPreHashAllowed&&m){e.payload.writeUInt16LE(d.length,c),c+=2;const t=Lt.TypedDataUtils.eip712Hash(e.validationPayload,Lt.SignTypedDataVersion.V4);r.from(t).copy(e.payload,c),e.prehash=t}else{const r=kr(d,t);e.extraDataPayloads=r,e.payload.writeUInt16LE(d.length,c),c+=2,d.copy(e.payload,c),c+=d.length,e.payload=e.payload.slice(0,c)}return e}(t,e);default:throw new Error("Unsupported protocol")}},Mr=function(e,t){const{signer:n,sig:o}=e,{input:i,msg:s,prehash:a=null}=t;if("signPersonal"===i.protocol){return Pr(a||r.from(Mt.Hash.keccak256(r.concat([Rr(s.length),s]))),o,n,{chainId:1,useEIP155:!1})}if("eip712"===i.protocol){const e=t.validationPayload||t.input.payload,r=t.validationPayload?vr(t.validationPayload):Er(e),s=Lt.TypedDataUtils.eip712Hash(r,Lt.SignTypedDataVersion.V4),c=a||s;let u=i.payload.domain?.chainId||r.domain?.chainId;return"string"==typeof u?u=u.startsWith("0x")?parseInt(u,16):parseInt(u,10):"bigint"==typeof u&&(u=Number(u)),Pr(c,o,n,{chainId:u,useEIP155:!1})}throw new Error("Unsupported protocol")},zr=function(e){try{let{chainId:t=1}=e;const{signerPath:n,eip155:o=null,fwConstants:i,type:s=null}=e,{contractDeployKey:a,extraDataFrameSz:c,extraDataMaxFrames:u,prehashAllowed:f}=i,l=c>0&&u>0,d=i.ethMaxDataSz,h=i.varAddrPathSzAllowed;if("number"!=typeof t&&!1===_r(t)&&(t=Ar[t]),!t)throw new Error("Unsupported chain ID or name");if(!n)throw new Error("`signerPath` not provided");if(null===e.to&&!a)throw new Error("Contract deployment not supported. Please update your Lattice firmware.");const p=null===e.to&&a,m=i.allowedEthTxTypes&&i.allowedEthTxTypes.indexOf(2)>-1,g=i.allowedEthTxTypes&&i.allowedEthTxTypes.indexOf(1)>-1,b=m&&(2===s||"eip1559"===s),y=g&&(1===s||"eip2930"===s);if(null!==s&&!b&&!y)throw new Error("Unsupported Ethereum transaction type");let w=function(e){switch(e){case 3:case 4:return!1;default:return!0}}(t);null!==o&&"boolean"==typeof o?w=o:(b||y)&&(w=!1),e.value||(e.value=0);const E=[],v=Ve(t),x=Ve(e.nonce);let B;const S=Ve(e.gasLimit);let P,I;p?(P=r.alloc(0),I=Ve(a)):(P=Ve(e.to),I=Ve(e.to));const T=Ve(e.value),A=Ve(e.data);let j,_;if((b||y)&&E.push(v),E.push(x),b){if(!e.maxPriorityFeePerGas)throw new Error("EIP1559 transactions must include `maxPriorityFeePerGas`");j=Ve(e.maxPriorityFeePerGas),E.push(j),_=Ve(e.maxFeePerGas),E.push(_),B=_}else B=Ve(e.gasPrice),E.push(B);E.push(S),E.push(P),E.push(T),E.push(A);let k=!1;if(b||y){const t=[];Array.isArray(e.accessList)&&e.accessList.forEach(e=>{const r=[];e.storageKeys.forEach(e=>{r.push(Ve(e))}),t.push([Ve(e.address),r]),k=!0}),E.push(t)}else!0===w&&(E.push(v),E.push(Ve(null)),E.push(Ve(null)));const O=122,N=r.alloc(d+O);let R,C=0;N.writeUInt8(Number(w),C),C++;let U=0;if(!0===function(e){const t=jr(e);return 1!==t.length||255===t.readUInt8(0)}(t)){if(R=jr(t),U=R.length,U>8)throw new Error("ChainID provided is too large.");N.writeUInt8(255,C),C++}else{if(R=Ve(t),1!==R.length)throw new Error("Error parsing chainID");R.copy(N,C),C+=R.length}const D=Xe(n,h);if(D.copy(N,C),C+=D.length,x.length>4)throw new Error("Nonce too large");if(x.copy(N,C+(4-x.length)),C+=4,B.length>8)throw new Error("Gas price too large");if(B.copy(N,C+(8-B.length)),C+=8,S.length>4)throw new Error("Gas limit too large");if(S.copy(N,C+(4-S.length)),C+=4,20!==I.length)throw new Error("Invalid `to` address");if(I.copy(N,C),C+=20,T.length>32)throw new Error("Value too large");T.copy(N,C+(32-T.length)),C+=32;let L=!1;if(i.allowedEthTxTypes)if(k&&(L=!0),N.writeUInt8(L?1:0,C),C+=1,b){if(N.writeUInt8(2,C),C+=1,j.length>8)throw new Error("maxPriorityFeePerGasBytes too large");j.copy(N,C+(8-j.length)),C+=8}else y?(N.writeUInt8(1,C),C+=1,C+=8):C+=9;const M=[];let z=null;const F=A.length||0,G=U>0?U+1:0,H=r.alloc(F+G);if(G>0&&(H.writeUInt8(U,0),R.copy(H,1)),A.copy(H,G),F>d){const e=F+G,t=d+u*c;if(f&&e>t)z=r.from(Mt.Hash.keccak256(Cr(E,s)));else{if(!l||l&&e>t)throw new Error(`Data field too large (got ${A.length}; must be <=${t-G} bytes)`);$e(H.slice(d),c).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),M.push(r.concat([t,e]))})}}else L&&(z=r.from(Mt.Hash.keccak256(Cr(E,s))));return N.writeUInt16BE(A.length,C),C+=2,U>0&&(N.writeUInt8(U,C),C++,R.copy(N,C),C+=U),z?(z.copy(N,C),C+=d):(A.slice(0,d).copy(N,C),C+=d),{rawTx:E,type:s,payload:N.slice(0,C),extraDataPayloads:M,schema:1,chainId:t,useEIP155:w,signerPath:n}}catch(e){return{err:e.message}}},Fr=function(e,t,n){const o=Pr(r.from(Mt.Hash.keccak256(Cr(e.rawTx,e.type))),t,n,e),i=e.useEIP155?e.rawTx.slice(0,-3):e.rawTx;i.push(o.v),i.push(Sr(o.r)),i.push(Sr(o.s));const s=r.from(zt.RLP.encode(i)),a=e.type?r.concat([r.from([e.type]),s]):s;return e.type===Kt||e.type===Zt?a.toString("hex"):{rawTx:a.toString("hex"),sigWithV:o}},Gr=function(e){return Mt.Hash.keccak256(r.from(e,"hex"))},Hr=Dr,qr=class extends Error{constructor(e,t){const r=(({responseCode:e,errorMessage:t})=>{const r=[];return e&&r.push(`${N.responseMsg[e]}`),t&&(r.push("Error Message: "),r.push(t)),r.join("\n")})({responseCode:e,errorMessage:t});super(r),this.responseCode=e,this.errorMessage=t,this.name="LatticeResponseError",this.responseCode=e,this.errorMessage=t}},$r=(e,t=!1)=>{const n=e.getPublic().encode("hex",!1),o=r.from(n,"hex");if(!0===t){const e=o.slice(1,33).reverse(),t=o.slice(33,65).reverse();return r.concat([o[0],e,t])}return o},Vr=function(e){let t="m";return e.forEach(e=>{t+=e>=U?`/${e-U}'`:`/${e}`}),t},Wr=async({url:e,payload:t,timeout:r=6e4})=>async function(e,t){const{timeout:r=8e3}=t,n=new AbortController,o=setTimeout(()=>n.abort(),r),i=await fetch(e,{...t,signal:n.signal});return clearTimeout(o),i}(e,{method:"POST",body:JSON.stringify({data:t}),headers:{"Content-Type":"application/json"},timeout:r}).catch(Re).then(e=>e.json()).then(e=>{if(!e||!e.message)throw new Error("Invalid response");if(200!==e.status)throw new Error(`Error code ${e.status}: ${e.message}`);const{data:t,errorMessage:r,responseCode:n}=function(e){const t={errorMessage:null,data:null},r=xe.Buffer.from(e,"hex");let n=0;const o=r.readUInt8(n);if(n++,1!==o)return t.errorMessage="Incorrect protocol version. Please update your SDK",t;const i=r.readUInt8(n);if(n++,0!==i)return t.errorMessage="Incorrect response from Lattice1",t;r.readUInt32BE(n),n+=4;const s=r.readUInt16BE(n);n+=2;const a=r.slice(n,n+s);n+=s;const c=a.readUInt8(0);if(0!==c){const e=N.responseMsg[c];return t.errorMessage=`[Lattice] ${e||"Unknown Error"}`,t.responseCode=c,t}return t.data=a.slice(1,a.length),r.readUInt32BE(n)!==qe(r.slice(0,r.length-4))?(t.errorMessage="Invalid checksum from device response",t.data=null,t):t}(e.message);if(r||n)throw new qr(n,r);return t});var Kr=(e,t)=>(r,n)=>Zr({fn:r,params:{...n,client:e},retries:t,client:e}),Zr=async({fn:e,params:t,retries:r,client:n})=>e({...t}).catch(async o=>{if(o instanceof qr){const s=o.errorMessage,a=o.responseCode;if((s||a)&&r){if((e=>130===e||137===e)(a))await(i=3e3,new Promise(e=>setTimeout(e,i)));else if((e=>138===e)(a)&&!n.skipRetryOnWrongWallet)await n.fetchActiveWallet();else{if(!(e=>142===e)(a))throw o;await n.connect(n.deviceId)}return Zr({fn:e,params:t,retries:r-1,client:n})}}var i;throw o}),{msgSizes:Yr}=N,{secure:Jr}=Yr;async function Xr({url:e,pubkey:t}){const n=function(e){const t=r.alloc(Jr.data.request.connect);return e.pubkey.copy(t,0),t}({pubkey:t}),o=en(et(4),1,n),i=await Wr({url:e,payload:o});if(i.length!==Jr.payload.response.connect-1)throw new Error("Wrong Lattice response message size.");return i}async function Qr({data:e,requestType:t,sharedSecret:n,ephemeralPub:o,url:i}){const s=et(4),a=function({data:e,requestType:t,ephemeralPub:n,sharedSecret:o}){if(e.length>Jr.data.request.encrypted.encryptedData)throw new Error("Encrypted request data too large");De(n);const i=Jr.data.request.encrypted[t];if(e.length!==i)throw new Error(`Invalid request datasize (wanted ${i}, got ${e.length})`);const s=r.alloc(1+i);s[0]=t,e.copy(s,1);const a=qe(s),c=r.alloc(Jr.data.request.encrypted.encryptedData);s.copy(c,0),c.writeUInt32LE(a,s.length);const u=function(e,t){const r=xe.Buffer.from(N.aesIv),n=new we.default.ModeOfOperation.cbc(t,r),o=e.length%16==0?e:we.default.padding.pkcs7.pad(e);return xe.Buffer.from(n.encrypt(o))}(c,o),f=(e=>{const t=r.from(ht.Hash.sha256(e));return parseInt(t.slice(0,4).toString("hex"),16)})(o),l=r.alloc(Jr.payload.request.encrypted-1);return l.writeUInt32LE(f),u.copy(l,4),l}({data:e,requestType:t,ephemeralPub:o,sharedSecret:n}),c=en(s,2,a),u=await Wr({url:i,payload:c});if(u.length!==Jr.payload.response.encrypted-1)throw new Error("Wrong Lattice response message size.");return function({encPayloadData:e,requestType:t,sharedSecret:r}){const n=Ke(e,r),o=65,i=o+Jr.data.response.encrypted[t],s={ephemeralPub:n.slice(0,o),data:n.slice(o,i),checksum:n.readUInt32BE(i)},a=qe(n.slice(0,i));if(s.checksum!==a)throw new Error("Checksum mismatch in decrypted Lattice data");const c=Jr.data.response.encrypted[t];if(s.data.length!==c)throw new Error("Incorrect response data returned from Lattice");const u=Je(s.ephemeralPub);return{decryptedData:s.data,newEphemeralPub:u}}({encPayloadData:u.slice(0,Jr.data.response.encrypted.encryptedData),requestType:t,sharedSecret:n})}function en(e,t,n){if(4!==e.length)throw new Error("msgId must be four bytes");if(1!==t&&2!==t)throw new Error("Invalid Lattice secure request type");const o=1===t&&n.length===Jr.payload.request.connect-1,i=2===t&&n.length===Jr.payload.request.encrypted-1;let s,a=Yr.header+Yr.checksum;const c={requestType:t,data:n};if(o)s=Jr.payload.request.connect;else{if(!i)throw new Error("Invalid Lattice secure request payload size");s=Jr.payload.request.encrypted}a+=s;const u={header:{version:1,type:2,id:e,len:s},payload:c},f=r.alloc(a);let l=0;if(f.writeUInt8(u.header.version,l),l+=1,f.writeUInt8(u.header.type,l),l+=1,u.header.id.copy(f,l),l+=u.header.id.length,f.writeUInt16BE(u.header.len,l),l+=2,f.writeUInt8(u.payload.requestType,l),l+=1,u.payload.data.copy(f,l),l+=u.payload.data.length,f.writeUInt32BE(qe(f.slice(0,l)),l),l+=4,l!==a)throw new Error("Failed to build request message");return f}async function tn({client:e,records:t,type:r,caseSensitive:n}){const{url:o,sharedSecret:i,ephemeralPub:s,fwConstants:a}=Ue(e);rn({records:t,fwConstants:a});const c=nn({records:t,type:r,caseSensitive:n,fwConstants:a}),{decryptedData:u,newEphemeralPub:f}=await Qr({data:c,requestType:8,sharedSecret:i,ephemeralPub:s,url:o});return e.mutate({ephemeralPub:f}),u}var rn=({records:e,fwConstants:t})=>{((e,t)=>{if(!t||!t.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if("object"!=typeof e||Object.keys(e).length<1)throw new Error("One or more key-value mapping must be provided in `records` param.");if(Object.keys(e).length>t.kvActionMaxNum)throw new Error(`Too many keys provided. Please only provide up to ${t.kvActionMaxNum}.`)})(e,t)},nn=({records:e,type:t,caseSensitive:n,fwConstants:o})=>{const i=r.alloc(1+139*o.kvActionMaxNum);i.writeUInt8(Object.keys(e).length,0);let s=1;return Object.entries(e).forEach(([e,a])=>{const{key:c,val:u}=(({key:e,val:t},r)=>{if("string"!=typeof e||String(e).length>r.kvKeyMaxStrSz)throw new Error(`Key ${e} too large. Must be <=${r.kvKeyMaxStrSz} characters.`);if("string"!=typeof t||String(t).length>r.kvValMaxStrSz)throw new Error(`Value ${t} too large. Must be <=${r.kvValMaxStrSz} characters.`);if(0===String(e).length||0===String(t).length)throw new Error("Keys and values must be >0 characters.");if(!H.test(e)||!H.test(t))throw new Error("Unicode characters are not supported.");return{key:e,val:t}})({key:e,val:a},o);i.writeUInt32LE(0,s),s+=4,i.writeUInt32LE(t,s),s+=4,i.writeUInt8(n?1:0,s),s+=1,i.writeUInt8(String(c).length+1,s),s+=1,r.from(String(c)).copy(i,s),s+=o.kvKeyMaxStrSz+1,i.writeUInt8(String(u).length+1,s),s+=1,r.from(String(u)).copy(i,s),s+=o.kvValMaxStrSz+1}),i};async function on({client:e,id:t}){const{deviceId:r,key:n,baseUrl:o}=sn({deviceId:t,key:e.key,baseUrl:e.baseUrl}),i=`${o}/${r}`,s=await Xr({url:i,pubkey:e.publicKey}),{isPaired:a,fwVersion:c,activeWallets:u,ephemeralPub:f}=await an(s,n);return e.mutate({deviceId:r,ephemeralPub:f,url:i,isPaired:a,fwVersion:c,activeWallets:u}),a&&!(e=>((e,t)=>{const{major:r,minor:n,fix:o}=e,{major:i,minor:s,fix:a}=t;return r>i||r>=i&&n>s||r>=i&&n>=s&&o>=a})(e,{major:0,minor:14,fix:1}))(e.getFwVersion())&&await e.fetchActiveWallet(),a}var sn=({deviceId:e,key:t,baseUrl:r})=>{const n=(e=>{if(!e)throw new Error("No device ID has been stored. Please connect with your device ID first.");return e})(e),o=Me(t),i=(e=>{if(!e)throw new Error("Base URL is required.");try{new URL(e)}catch(e){throw console.error("Invalid Base URL format:",e),new Error("Invalid Base URL provided. Please use a valid URL.")}return e})(r);return{deviceId:n,key:o,baseUrl:i}},an=(e,t)=>{let n=0;const o=e.readUInt8(n)===N.pairingStatus.paired;n++;const i=e.slice(n,n+65).toString("hex");n+=65;const s=Je(i),a=e.slice(n,n+4);if(n+=4,o){const i=e.slice(n,n+160);n+=160;const c=((e,t)=>r.from(e.derive(t.getPublic()).toArray("be",32)))(t,s),u=Ke(i,c);if(0!==u[u.length-2]||0!==u[u.length-1])throw new Error("Failed to connect to Lattice.");const f=(e=>{let t=0;const r={internal:{uid:void 0,capabilities:void 0,name:void 0,external:!1},external:{uid:void 0,capabilities:void 0,name:void 0,external:!0}};return r.internal.uid=e.slice(t,t+32),t+=71,r.external.uid=e.slice(t,t+32),r})(u);return{isPaired:o,fwVersion:a,activeWallets:f,ephemeralPub:s}}return{isPaired:o,fwVersion:a,activeWallets:void 0,ephemeralPub:s}},cn=e("uuid"),{ENC_DATA:un}=R,fn="Unknown encrypted data export type requested. Exiting.",ln={CIPHERTEXT:32,SALT:32,CHECKSUM:32,IV:16,PUBKEY:48};async function dn({client:e,schema:t,params:r}){const{url:n,sharedSecret:o,ephemeralPub:i,fwVersion:s}=Ue(e),a=Ce(e.getActiveWallet());hn({params:r});const c=pn({schema:t,params:r,fwVersion:s,activeWallet:a}),{decryptedData:u,newEphemeralPub:f}=await Qr({data:c,requestType:12,sharedSecret:o,ephemeralPub:i,url:n});return e.mutate({ephemeralPub:f}),mn({data:u,schema:t,params:r})}var hn=({params:e})=>{Ne(e.path)},pn=({schema:e,params:t,fwVersion:n,activeWallet:o})=>{if(n.major<1&&n.minor<17)throw new Error("Firmware version >=v0.17.0 is required for encrypted data export.");if(e!==un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4)throw new Error(fn);t.walletUID=o.uid;const i=r.alloc(1025);let s=0;if(i.writeUInt8(e,s),s+=1,e===un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4){t.walletUID.copy(i,s),s+=t.walletUID.length,i.writeUInt8(t.path.length,s),s+=1;for(let e=0;e<5;e++)e<=t.path.length&&i.writeUInt32LE(t.path[e],s),s+=4;return t.c&&i.writeUInt32LE(t.c,s),s+=4,i}throw new Error(fn)},mn=({data:e,schema:t,params:r})=>{let n=0;if(t===un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4){const t={},{CIPHERTEXT:o,SALT:i,CHECKSUM:s,IV:a,PUBKEY:c}=ln,u=4+o+i+s+a+c,f=e.readUInt32LE(n);if(n+=4,f!==u)throw new Error("Invalid data returned from Lattice. Expected EIP2335 data.");return t.iterations=e.readUInt32LE(n),n+=4,t.cipherText=e.slice(n,n+o),n+=o,t.salt=e.slice(n,n+i),n+=i,t.checksum=e.slice(n,n+s),n+=s,t.iv=e.slice(n,n+a),n+=a,t.pubkey=e.slice(n,n+c),n+=c,gn(t,r.path)}throw new Error(fn)},gn=(e,t)=>{try{const{iterations:n,salt:o,checksum:i,iv:s,cipherText:a,pubkey:c}=e;return r.from(JSON.stringify({version:4,uuid:(0,cn.v4)(),path:Vr(t),pubkey:c.toString("hex"),crypto:{kdf:{function:"pbkdf2",params:{dklen:32,c:n,prf:"hmac-sha256",salt:o.toString("hex")},message:""},checksum:{function:"sha256",params:{},message:i.toString("hex")},cipher:{function:"aes-128-ctr",params:{iv:s.toString("hex")},message:a.toString("hex")}}}))}catch(e){throw Error(`Failed to format EIP2335 return data: ${e.toString()}`)}};async function bn({client:e}){const{url:t,sharedSecret:n,ephemeralPub:o}=Ue(e),{decryptedData:i,newEphemeralPub:s}=await Qr({data:r.alloc(0),requestType:4,sharedSecret:n,ephemeralPub:o,url:t}),a=(e=>{if(!e||e?.internal?.uid?.equals(V)&&e?.external?.uid?.equals(V))throw new Error("No active wallet.");return e})(yn(i));return e.mutate({ephemeralPub:s,activeWallets:a}),a}var yn=e=>{const t={internal:{uid:V,external:!1,name:r.alloc(0),capabilities:0},external:{uid:V,external:!0,name:r.alloc(0),capabilities:0}};let n=0;return t.internal.uid=e.slice(n,n+32),t.internal.capabilities=e.readUInt32BE(n+32),t.internal.name=e.slice(n+36,n+71),n+=71,t.external.uid=e.slice(n,n+32),t.external.capabilities=e.readUInt32BE(n+32),t.external.name=e.slice(n+36,n+71),t};async function wn({client:e,startPath:t,n:r,flag:n,iterIdx:o}){const{url:i,sharedSecret:s,ephemeralPub:a,fwConstants:c}=Ue(e),u=Ce(e.getActiveWallet()),{startPath:f,n:l,flag:d}=En({startPath:t,n:r,flag:n}),h=vn({startPath:f,n:l,flag:d,fwConstants:c,wallet:u,iterIdx:o}),{decryptedData:p,newEphemeralPub:m}=await Qr({data:h,requestType:1,sharedSecret:s,ephemeralPub:a,url:i});return e.mutate({ephemeralPub:m}),xn(p,d)}var En=({startPath:e,n:t,flag:r})=>({startPath:Ne(e),n:Oe(t),flag:ke(r)}),vn=({startPath:e,n:t,flag:n,fwConstants:o,wallet:i,iterIdx:s})=>{if(!((o.getAddressFlags||[]).indexOf(n)>-1&&(4===n||3===n||5===n))&&!(6===n)&&!function(e,t){const r=[He.ETH,He.BTC_LEGACY,He.BTC_WRAPPED_SEGWIT,He.BTC_SEGWIT],n=[Ge.ETH,Ge.BTC,Ge.BTC_TESTNET];return!((e[1]===Ge.BTC||e[1]===Ge.BTC_TESTNET)&&e[0]!==He.BTC_WRAPPED_SEGWIT&&!t.allowBtcLegacyAndSegwitAddrs)&&r.indexOf(e[0])>=0&&(n.indexOf(e[1])>=0||[60,61,966,700,9006,9e3,1007,553,178,137,37310,108,40,889,1987,820,6060,1620,1313114,76,246529,246785,1001,227,916,464,2221,344,73799,246].indexOf(e[1]-U)>0)}(e,o))throw new Error("Derivation path or flag is not supported. Try updating Lattice firmware.");if(e.length<2||e.length>5)throw new Error("Derivation path must include 2-5 indices.");if(s<0||s>5)throw new Error("Iteration index must be between 0 and 5.");if(s>e.length)throw new Error("Iteration index cannot be greater than path depth.");const a=r.alloc(54);let c=0;i.uid.copy(a,c),c+=32;const u=(15&s)<<4|15&e.length;a.writeUInt8(u,c),c+=1;for(let t=0;t<5;t++){const r=t<e.length?e[t]:0;a.writeUInt32BE(r,c),c+=4}const f=15&t,l=(15&n)<<4;return a.writeUInt8(f|l,c),a},xn=(e,t)=>{let r=0;const n=4===t?113:65,o=[],i=3===t||4===t||5===t;i&&(r+=1);const s=N.msgSizes.secure.data.response.encrypted[1];for(;r<s;)if(i){const i=e.slice(r,r+n),s=i.every(e=>0===e);s||4!==t?s||5!==t?s||o.push(i):o.push(i.slice(0,48)):o.push(i.slice(0,32)),r+=n}else{const t=e.slice(r,r+N.addrStrLen);r+=N.addrStrLen;const n=t.indexOf(0);if(n>0){const e=t.slice(0,n).toString().replace(/[\x00-\x1F\x7F-\x9F]/g,"");o.push(e)}}return o};async function Bn({client:e,type:t,n:r,start:n}){const{url:o,sharedSecret:i,ephemeralPub:s,fwConstants:a}=Ue(e),{type:c,n:u,start:f}=Sn({type:t,n:r,start:n,fwConstants:a}),l=Pn({type:c,n:u,start:f}),{decryptedData:d,newEphemeralPub:h}=await Qr({data:l,requestType:7,sharedSecret:i,ephemeralPub:s,url:o});return e.mutate({ephemeralPub:h}),In(d,a)}var Sn=({fwConstants:e,n:t,type:r,start:n})=>{if(!e.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if(!t||t<1)throw new Error("You must request at least one record.");if(t>e.kvActionMaxNum)throw new Error(`You may only request up to ${e.kvActionMaxNum} records at once.`);if(0!==r&&!r)throw new Error("You must specify a type.");if(0!==n&&!n)throw new Error("You must specify a type.");return{fwConstants:e,n:t,type:r,start:n}},Pn=({type:e,n:t,start:n})=>{const o=r.alloc(9);return o.writeUInt32LE(e,0),o.writeUInt8(t,4),o.writeUInt32LE(n,5),o},In=(e,t)=>{let r=0;const n=e.readUInt32BE(r);r+=4;const o=parseInt(e.slice(r,r+1).toString("hex"),16);if(r+=1,o>t.kvActionMaxNum)throw new Error("Too many records fetched. Firmware error.");const i=[];for(let n=0;n<o;n++){const n={};n.id=e.readUInt32BE(r),r+=4,n.type=e.readUInt32BE(r),r+=4,n.caseSensitive=1===parseInt(e.slice(r,r+1).toString("hex"),16),r+=1;const o=parseInt(e.slice(r,r+1).toString("hex"),16);r+=1,n.key=e.slice(r,r+o-1).toString(),r+=t.kvKeyMaxStrSz+1;const s=parseInt(e.slice(r,r+1).toString("hex"),16);r+=1,n.val=e.slice(r,r+s-1).toString(),r+=t.kvValMaxStrSz+1,i.push(n)}return{records:i,total:n,fetched:o}};async function Tn({client:e,pairingSecret:t}){const{url:r,sharedSecret:n,ephemeralPub:o,appName:i,key:s}=Ue(e),a=An({pairingSecret:t,key:s,appName:i}),{newEphemeralPub:c}=await Qr({data:a,requestType:0,sharedSecret:n,ephemeralPub:o,url:r});return e.mutate({ephemeralPub:c,isPaired:!0}),await e.fetchActiveWallet(),e.hasActiveWallet()}var An=({key:e,pairingSecret:t,appName:n})=>{const o=$r(e),i=r.alloc(25);t.length>0&&i.write(n);const s=ct(o,i,r.from(t)),a=function(e){const t=xe.Buffer.alloc(74);return xe.Buffer.from(e.toDER()).copy(t),t}(e.sign(s));return r.concat([i,a])};async function jn({client:e,type:t,ids:r}){const{url:n,sharedSecret:o,ephemeralPub:i,fwConstants:s}=Ue(e),{type:a,ids:c}=_n({fwConstants:s,type:t,ids:r}),u=kn({type:a,ids:c,fwConstants:s}),{decryptedData:f,newEphemeralPub:l}=await Qr({data:u,requestType:9,sharedSecret:o,ephemeralPub:i,url:n});return e.mutate({ephemeralPub:l}),f}var _n=({fwConstants:e,type:t,ids:r})=>{if(!e.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if(!Array.isArray(r)||r.length<1)throw new Error("You must include one or more `ids` to removed.");if(r.length>e.kvRemoveMaxNum)throw new Error(`Only up to ${e.kvRemoveMaxNum} records may be removed at once.`);if(0!==t&&!t)throw new Error("You must specify a type.");return{type:t,ids:r}},kn=({fwConstants:e,type:t,ids:n})=>{const o=r.alloc(5+4*e.kvRemoveMaxNum);o.writeUInt32LE(t,0),o.writeUInt8(n.length,4);for(let e=0;e<n.length;e++){const t=parseInt(n[e]);o.writeUInt32LE(t,5+4*e)}return o},On=e("ox");async function Nn({client:e,data:t,currency:r,cachedData:n,nextCode:o}){try{const{url:i,sharedSecret:s,ephemeralPub:a,fwConstants:c}=Ue(e),u=Ce(e.getActiveWallet()),{requestData:f,isGeneric:l}=(({data:e,currency:t,fwConstants:r})=>{if("ETH"===t&&(e=>e.genericSigning&&e.genericSigning.encodingTypes&&e.genericSigning.encodingTypes.EVM)(r)){let t;console.log("Using the legacy ETH signing path. This will soon be deprecated. Please switch to general signing request.");try{t=Hr(e)}catch(e){throw console.error("Failed to convert legacy Ethereum transaction:",e),new Error("Could not convert legacy request. Please switch to a general signing request. See gridplus-sdk docs for more information.")}return e={fwConstants:r,encodingType:R.SIGNING.ENCODINGS.EVM,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,signerPath:e.signerPath,payload:t},{requestData:Qt({...e,fwConstants:r}),isGeneric:!0}}return"ETH"===t?{requestData:zr({...e,fwConstants:r}),isGeneric:!1}:"ETH_MSG"===t?{requestData:Lr({...e,fwConstants:r}),isGeneric:!1}:"BTC"===t?{requestData:Ut.buildBitcoinTxRequest({...e,fwConstants:r}),isGeneric:!1}:{requestData:Qt({...e,fwConstants:r}),isGeneric:!0}})({data:t,currency:r,fwConstants:c}),{payload:d,hasExtraPayloads:h}=Rn({fwConstants:c,wallet:u,requestData:f,cachedData:n,nextCode:o}),{decryptedData:p,newEphemeralPub:m}=await Qr({data:d,requestType:3,sharedSecret:s,ephemeralPub:a,url:i});if(e.mutate({ephemeralPub:m}),h)return e.sign({data:t,currency:r,cachedData:f,nextCode:p.slice(0,8)});return Cn({data:p,request:f,isGeneric:l,currency:r})}catch(e){throw console.error("Error signing transaction:",{message:e.message,payload:JSON.stringify({data:t,currency:r},(e,t)=>"bigint"==typeof t?t.toString():t)}),e}}var Rn=({fwConstants:e,wallet:t,requestData:n,cachedData:o,nextCode:i})=>{let s,a,c=0;const u=n;if(o&&i){const e=o,t=e.extraDataPayloads.shift();if(!t)throw new Error("No cached extra payload available for multipart sign request.");u.extraDataPayloads&&(u.extraDataPayloads=e.extraDataPayloads),s=r.concat([i,t]),a=4,c=Number((e.extraDataPayloads?.length??0)>0)}else s=u.payload,a=u.schema,c=Number((u.extraDataPayloads?.length??0)>0);const f=r.alloc(2+e.reqMaxDataSz);let l=0;return f.writeUInt8(c,l),l+=1,f.writeUInt8(a,l),l+=1,t.uid?.copy(f,l),l+=t.uid?.length??0,s.copy(f,l),{payload:f,hasExtraPayloads:c}},Cn=({data:e,request:t,isGeneric:n,currency:o})=>{let i=0;if(o===C.BTC){const n=t,o=20,s=760,a=Ut.getAddressFormat(n.origData.changePath),c=e.slice(i,i+o);i+=o;const u=Ut.getBitcoinAddress(c,a),f=33,l=[],d=[];let h=0;for(;i<e.length&&48===e[i];){const t=i,r=i+2+e[i+1];d.push(e.slice(t,r)),i+=74;const n=h*f+s,o=(h+1)*f+s;l.push(e.slice(n,o)),h+=1}const p={inputs:[],outputs:[]};p.outputs.push({value:n.origData.value,recipient:n.origData.recipient}),n.changeData?.value&&n.changeData.value>0&&p.outputs.push({value:n.changeData.value,recipient:u});for(let e=0;e<d.length;e++)p.inputs.push({hash:n.origData.prevOuts[e].txHash,index:n.origData.prevOuts[e].index,sig:d[e],pubkey:l[e],signerPath:n.origData.prevOuts[e].signerPath});const m=Ut.serializeTx(p),g=m,b=r.from(On.Hash.sha256(r.from(g,"hex")));return{tx:m,txHash:`0x${r.from(On.Hash.sha256(b)).toString("hex")}`,changeRecipient:u,sigs:d}}if(o!==C.ETH||n){if(o===C.ETH_MSG){const r=Ze(e.slice(i,i+2+e[i+1]));i+=74;const n=e.slice(i,i+20),o=Mr({signer:n,sig:r},t);return{sig:{v:BigInt(`0x${o.v.toString("hex")}`),r:`0x${o.r.toString("hex")}`,s:`0x${o.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}return function(e,t,n){const o={pubkey:null,sig:null};let i;if(n.curveType===R.SIGNING.CURVES.SECP256K1){if(n.omitPubkey)t+=65;else{const n=e.readUInt8(t);if(t+=1,2===n||3===n)o.pubkey=r.alloc(33),o.pubkey.writeUInt8(n,0),e.slice(t,t+32).copy(o.pubkey,1);else{if(4!==n)throw new Error("Bad compression byte in signing response.");o.pubkey=r.alloc(65),o.pubkey.writeUInt8(n,0),e.slice(t).copy(o.pubkey,1)}t+=64}const s=2+e[t+1],a=e.slice(t,t+s),c=Ze(a),u=We(c.r,32),f=We(c.s,32);if(o.sig={r:`0x${u.toString("hex")}`,s:`0x${f.toString("hex")}`},t+=s,e.length>=t+32&&(i=r.from(e.slice(t,t+32)),t+=32),n.encodingType===R.SIGNING.ENCODINGS.EVM){const e=ut(n.origPayloadBuf,o);o.sig.v=BigInt(e.toString()),tr(o.sig.v,n,o)}else if(n.hashType===R.SIGNING.HASHES.KECCAK256&&n.encodingType!==R.SIGNING.ENCODINGS.EVM){let e=!1;try{let t=n.origPayloadBuf;t[0]<=127&&(t=t.slice(1));const r=Jt.RLP.decode(t);e=Array.isArray(r)&&r.length>=6}catch{e=!1}if(e)try{const e=ut(n.origPayloadBuf,o);o.sig.v=BigInt(e.toString()),tr(o.sig.v,n,o)}catch(e){console.error("Failed to get V from transaction, using fallback:",e);const t=er(n,i),r=lt({messageHash:t,signature:o.sig,publicKey:o.pubkey});o.sig.v=BigInt(27+r)}else{const e=er(n,i),t=lt({messageHash:e,signature:o.sig,publicKey:o.pubkey});o.sig.v=BigInt(27+t)}}}else if(n.curveType===R.SIGNING.CURVES.ED25519)n.omitPubkey||(o.pubkey=r.alloc(32),e.slice(t,t+32).copy(o.pubkey)),t+=32,o.sig={r:`0x${e.slice(t,t+32).toString("hex")}`,s:`0x${e.slice(t+32,t+64).toString("hex")}`},t+=64;else{if(n.curveType!==R.SIGNING.CURVES.BLS12_381_G2)throw new Error("Unsupported curve.");n.omitPubkey||(o.pubkey=r.alloc(48),e.slice(t,t+48).copy(o.pubkey)),t+=48,o.sig=r.alloc(96),e.slice(t,t+96).copy(o.sig),t+=96}return o}(e,i,t)}{const r=Ze(e.slice(i,i+2+e[i+1]));i+=74;const n=e.slice(i,i+20),o=Fr(t,r,n);if("string"==typeof o)return{tx:`0x${o}`,txHash:`0x${Gr(o)}`,sig:{v:0n,r:"0x",s:"0x"},signer:`0x${n.toString("hex")}`};return{tx:`0x${o.rawTx}`,txHash:`0x${Gr(o.rawTx)}`,sig:{v:BigInt(`0x${o.sigWithV.v.toString("hex")}`),r:`0x${o.sigWithV.r.toString("hex")}`,s:`0x${o.sigWithV.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}},Un=class{constructor({baseUrl:e,name:t,privKey:r,stateData:o,timeout:i,retryCount:s,skipRetryOnWrongWallet:a,deviceId:c,setStoredClient:u}){n(this,"isPaired",void 0),n(this,"timeout",void 0),n(this,"baseUrl",void 0),n(this,"url",void 0),n(this,"name",void 0),n(this,"key",void 0),n(this,"privKey",void 0),n(this,"retryCount",void 0),n(this,"fwVersion",void 0),n(this,"skipRetryOnWrongWallet",void 0),n(this,"_ephemeralPub",void 0),n(this,"deviceId",void 0),n(this,"activeWallets",void 0),n(this,"retryWrapper",void 0),n(this,"setStoredClient",void 0),this.name=t||"Unknown",this.baseUrl=e||"https://signing.gridpl.us",this.deviceId=c,this.isPaired=!1,this.activeWallets=W,this.timeout=i||6e4,this.retryCount=s||3,this.skipRetryOnWrongWallet=a||!1,this.privKey=r||et(32),this.key=Ye(this.privKey),this.retryWrapper=Kr(this,this.retryCount),this.setStoredClient=u?le(u):void 0,o&&this.unpackAndApplyStateData(o)}get publicKey(){return $r(this.key)}getAppName(){return this.name}getDeviceId(){return this.deviceId}get sharedSecret(){return r.from(this.key.derive(this.ephemeralPub.getPublic()).toArray("be",32))}get ephemeralPub(){return this._ephemeralPub}set ephemeralPub(e){De(e),this._ephemeralPub=e}async connect(e){return this.retryWrapper(on,{id:e})}async pair(e){return this.retryWrapper(Tn,{pairingSecret:e})}async getAddresses({startPath:e,n:t=1,flag:r=0,iterIdx:n=0}){return this.retryWrapper(wn,{startPath:e,n:t,flag:r,iterIdx:n})}async sign({data:e,currency:t,cachedData:r,nextCode:n}){return this.retryWrapper(Nn,{data:e,currency:t,cachedData:r,nextCode:n})}async fetchActiveWallet(){return this.retryWrapper(bn)}async addKvRecords({type:e=0,records:t,caseSensitive:r=!1}){return this.retryWrapper(tn,{type:e,records:t,caseSensitive:r})}async getKvRecords({type:e=0,n:t=1,start:r=0}){return this.retryWrapper(Bn,{type:e,n:t,start:r})}async removeKvRecords({type:e=0,ids:t=[]}){return this.retryWrapper(jn,{type:e,ids:t})}async fetchEncryptedData(e){return this.retryWrapper(dn,e)}getActiveWallet(){return this.activeWallets.external.uid&&!V.equals(this.activeWallets.external.uid)?this.activeWallets.external:this.activeWallets.internal.uid&&!V.equals(this.activeWallets.internal.uid)?this.activeWallets.internal:void 0}hasActiveWallet(){return!!this.getActiveWallet()}resetActiveWallets(){this.activeWallets=W}getStateData(){return this.packStateData()}getFwConstants(){return function(e){const t={extraDataFrameSz:0,extraDataMaxFrames:0,genericSigning:{}};function r(e,t){return e[2]>t[0]||e[2]===t[0]&&e[1]>t[1]||e[2]===t[0]&&e[1]===t[1]&&e[0]>t[2]||e[2]===t[0]&&e[1]===t[1]&&e[0]===t[2]}const n=0===e.length;return!n&&r(e,[0,10,4])||!n&&r(e,[0,10,0])?(t.reqMaxDataSz=1678,t.ethMaxGasPrice=2e13,t.addrFlagsAllowed=!0):(t.reqMaxDataSz=1152,t.ethMaxGasPrice=5e11,t.addrFlagsAllowed=!1),t.ethMaxDataSz=t.reqMaxDataSz-128,t.ethMaxMsgSz=t.ethMaxDataSz,t.eip712MaxTypeParams=18,!n&&r(e,[0,10,4])&&(t.extraDataFrameSz=1500,t.extraDataMaxFrames=1),!n&&r(e,[0,10,5])&&(t.varAddrPathSzAllowed=!0,t.eip712Supported=!0),!n&&r(e,[0,10,8])&&(t.prehashAllowed=!0),!n&&r(e,[0,10,10])&&(t.ethMsgPreHashAllowed=!0),!n&&r(e,[0,11,0])&&(t.allowedEthTxTypes=[1,2],t.ethMaxDataSz-=10,t.ethMaxMsgSz=t.ethMaxDataSz),!n&&r(e,[0,11,2])&&(t.personalSignHeaderSz=72),!n&&r(e,[0,12,0])&&(t.kvActionsAllowed=!0,t.kvKeyMaxStrSz=63,t.kvValMaxStrSz=63,t.kvActionMaxNum=10,t.kvRemoveMaxNum=100),!n&&r(e,[0,13,0])&&(t.allowBtcLegacyAndSegwitAddrs=!0,t.contractDeployKey="0x08002e0fec8e6acf00835f43c9764f7364fa3f42"),!n&&r(e,[0,14,0])&&(t.abiCategorySz=32,t.abiMaxRmv=200,t.genericSigning.baseReqSz=1552,t.genericSigning.baseDataSz=1519,t.genericSigning.hashTypes=R.SIGNING.HASHES,t.genericSigning.curveTypes=R.SIGNING.CURVES,t.genericSigning.encodingTypes={NONE:R.SIGNING.ENCODINGS.NONE,SOLANA:R.SIGNING.ENCODINGS.SOLANA},t.getAddressFlags=[R.GET_ADDR_FLAGS.ED25519_PUB,R.GET_ADDR_FLAGS.SECP256K1_PUB],t.eip712MaxTypeParams=36),!n&&r(e,[0,15,0])&&(t.genericSigning.encodingTypes.EVM=R.SIGNING.ENCODINGS.EVM,t.ethMaxDataSz=1519,t.maxDecoderBufSz=1600,t.genericSigning.calldataDecoding={reserved:2895728,maxSz:1024}),!n&&r(e,[0,17,0])&&(t.getAddressFlags.push(R.GET_ADDR_FLAGS.BLS12_381_G1_PUB),t.genericSigning.encodingTypes.ETH_DEPOSIT=R.SIGNING.ENCODINGS.ETH_DEPOSIT),!n&&r(e,[0,18,0])&&(t.genericSigning.encodingTypes={...t.genericSigning.encodingTypes,EIP7702_AUTH:R.SIGNING.ENCODINGS.EIP7702_AUTH,EIP7702_AUTH_LIST:R.SIGNING.ENCODINGS.EIP7702_AUTH_LIST}),t}(this.fwVersion??r.alloc(0))}getFwVersion(){return this.fwVersion&&this.fwVersion.length>=3?{fix:this.fwVersion[0],minor:this.fwVersion[1],major:this.fwVersion[2]}:{fix:0,minor:0,major:0}}mutate({deviceId:e,ephemeralPub:t,url:r,isPaired:n,fwVersion:o,activeWallets:i}){void 0!==e&&(this.deviceId=e),void 0!==t&&(this.ephemeralPub=t),void 0!==r&&(this.url=r),void 0!==n&&(this.isPaired=n),void 0!==o&&(this.fwVersion=o),void 0!==i&&(this.activeWallets=i),this.setStoredClient&&this.setStoredClient(this.getStateData())}packStateData(){try{const e={activeWallets:{internal:{uid:this.activeWallets.internal.uid?.toString("hex"),name:this.activeWallets.internal.name?.toString(),capabilities:this.activeWallets.internal.capabilities},external:{uid:this.activeWallets.external.uid?.toString("hex"),name:this.activeWallets.external.name?.toString(),capabilities:this.activeWallets.external.capabilities}},ephemeralPub:this.ephemeralPub?.getPublic()?.encode("hex",!1),fwVersion:this.fwVersion?.toString("hex"),deviceId:this.deviceId,name:this.name,baseUrl:this.baseUrl,privKey:this.privKey.toString("hex"),retryCount:this.retryCount,timeout:this.timeout};return JSON.stringify(e)}catch(e){return console.warn("Could not pack state data:",e),null}}unpackAndApplyStateData(e){try{const t=JSON.parse(e),n={uid:r.from(t.activeWallets.internal.uid,"hex"),name:t.activeWallets.internal.name?r.from(t.activeWallets.internal.name):null,capabilities:t.activeWallets.internal.capabilities,external:!1},o={uid:r.from(t.activeWallets.external.uid,"hex"),name:t.activeWallets.external.name?r.from(t.activeWallets.external.name):null,capabilities:t.activeWallets.external.capabilities,external:!0},i=r.from(t.ephemeralPub,"hex"),s=r.from(t.fwVersion,"hex"),a=r.from(t.privKey,"hex");this.activeWallets.internal=n,this.activeWallets.external=o,this.ephemeralPub=Je(i),this.fwVersion=s,this.deviceId=t.deviceId,this.name=t.name,this.baseUrl=t.baseUrl,this.url=`${this.baseUrl}/${this.deviceId}`,this.privKey=a,this.key=Ye(this.privKey),this.retryCount=t.retryCount,this.timeout=t.timeout,this.retryWrapper=Kr(this,this.retryCount)}catch(e){console.warn("Could not apply state data:",e)}}},Dn=async e=>{let t=[],r=0;const n=e?.n||q;for(;r<n;){const o=Math.min(q,n-r),i=he(K,r);await ue(n=>n.getAddresses({startPath:i,...e,n:o}).then(e=>{e.length>0&&(t=[...t,...e],r+=e.length)}))}return t},Ln=async(e=0)=>Dn({startPath:"number"==typeof e?he(K,e):e,n:1}).then(e=>e[0]);function Mn(e){return async({n:t,startPathIndex:r}={n:q,startPathIndex:0})=>Dn({startPath:he(e,r),n:t})}var zn=Mn(Z),Fn=Mn(J),Gn=Mn(Q),Hn=Mn(Y),qn=Mn(X),$n=Mn(ee),Vn=async({n:e,startPathIndex:t}={n:q,startPathIndex:0})=>Dn({startPath:he(oe,t,2),n:e,flag:4}),Wn=async({n:e,startPathIndex:t}={n:q,startPathIndex:0})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>e.getAddresses({startPath:he(ie,t+n,2),n:1}).then(e=>e.map(e=>`${e}`))));return Promise.all(r)},Kn=async({n:e,startPathIndex:t}={n:q,startPathIndex:0})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>e.getAddresses({startPath:he(se,t+n,3),n:1}).then(e=>e.map(e=>`${e}`))));return Promise.all(r)},Zn=async({n:e=10,startPathIndex:t=0}={})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>{const r=[44+U,501+U,t+n+U,0+U];return e.getAddresses({startPath:r,n:1,flag:4}).then(e=>e.map(e=>`${e}`))}));return Promise.all(r)};async function Yn(e,{n:t=1,startPathIndex:r=0,flag:n}={}){const o=e.split("/").filter(Boolean),i=ge(o),s=function(e){if(e.length>=2&&e[1]===501+U)return R.GET_ADDR_FLAGS.ED25519_PUB}(i),a=o.findIndex(e=>e.toLowerCase().includes("x"));if(-1===a)return ue(e=>e.getAddresses({startPath:i,flag:n||s,n:t}));const c=[];for(let e=0;e<t;e++){const t=[...i];t[a]=t[a]+r+e;const o=await ue(e=>e.getAddresses({startPath:t,flag:n||s,n:1}));c.push(...o)}return c}async function Jn(){return(await Yn(te,{flag:6}))[0]}async function Xn(){return(await Yn(re,{flag:6}))[0]}async function Qn(){return(await Yn(ne,{flag:6}))[0]}var eo=async e=>{const t=e.reduce((e,t)=>{const r=Object.keys(t)[0];return e[r]=t[r],e},{});return ue(e=>e.addKvRecords({records:t}))},to=async({n:e=10,start:t=0}={})=>{const r=[];let n=e,o=t;for(;n>0;)await ue(e=>e.getKvRecords({start:o,n:n>q?q:n}).then(async e=>{r.push(...e.records),o=e.fetched+o,n=e.total-o}));return r},ro=async e=>{const t=e.map(e=>`${e.id}`);return ue(e=>e.removeKvRecords({ids:t}))},no=e("@ethereumjs/rlp"),oo=e("ox"),io=e("viem");var so=async(e,t)=>{const n="string"==typeof(o=e)||o instanceof Uint8Array||r.isBuffer(o);var o;const i=n?function(e){if("string"==typeof e)return e.startsWith("0x")?e:`0x${e}`;return r.from(e)}(e):(0,io.serializeTransaction)(e);let s,a=R.SIGNING.ENCODINGS.EVM;if(!n&&"eip7702"===e.type){const t=e;a=t.authorizationList&&t.authorizationList.length>0?R.SIGNING.ENCODINGS.EIP7702_AUTH_LIST:R.SIGNING.ENCODINGS.EIP7702_AUTH}!n&&"data"in e&&"to"in e&&"chainId"in e&&(s=await async function({data:e,to:t,chainId:r}){try{const n=await fe();Ue(n);const o=n.getFwVersion(),i=o.major>0||o.minor>=16,{def:s}=await at(e,t,r,i);return s}catch(e){return void console.warn("Failed to fetch ABI:",e)}}({data:e.data,to:e.to,chainId:e.chainId}));const c={signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,encodingType:a,payload:i,decoder:s};return ue(e=>e.sign({data:c,...t}))};function ao(e,t){const r={data:{signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,protocol:pe(e)?"eip712":"signPersonal",payload:e},currency:t?.currency??C.ETH_MSG,...t??{}};return ue(e=>e.sign(r))}var co=async(e,t)=>{const n=r.from([5]),o="address"in e?e.address:e.contractAddress,i=r.concat([n,r.from(no.RLP.encode([e.chainId,o,e.nonce]))]),s={signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,encodingType:R.SIGNING.ENCODINGS.EIP7702_AUTH,payload:i},a=await ue(e=>e.sign({data:s,...t}));if(a.sig&&a.pubkey){const t=r.from(oo.Hash.keccak256(i)),n=lt(t,a.sig,a.pubkey),s=r.isBuffer(a.sig.r)?`0x${a.sig.r.toString("hex")}`:a.sig.r,c=r.isBuffer(a.sig.s)?`0x${a.sig.s.toString("hex")}`:a.sig.s;return{address:o,chainId:e.chainId,nonce:e.nonce,yParity:n,r:s,s:c}}throw new Error("Failed to get signature from device")},uo=async e=>{const t=(0,io.serializeTransaction)(e),r={signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,encodingType:R.SIGNING.ENCODINGS.EIP7702_AUTH_LIST,payload:t};return await ue(e=>e.sign({data:r}))},fo=async e=>{const t={data:{signerPath:Z,...e},currency:C.BTC};return ue(e=>e.sign(t))},lo=async e=>{const t={data:{signerPath:J,...e},currency:C.BTC};return ue(e=>e.sign(t))},ho=async e=>{const t={data:{signerPath:Q,...e},currency:C.BTC};return ue(e=>e.sign(t))},po=async(e,t)=>{const r={data:{signerPath:oe,curveType:R.SIGNING.CURVES.ED25519,hashType:R.SIGNING.HASHES.NONE,encodingType:R.SIGNING.ENCODINGS.SOLANA,payload:e,...t}};return ue(e=>e.sign(r))},mo=async()=>ue(e=>e.fetchActiveWallet()),go=async e=>{if(!e.getStoredClient)throw new Error("Client data getter required");var t;if(t=de(e.getStoredClient),F=t,!e.setStoredClient)throw new Error("Client data setter required");if((e=>{z=e})(le(e.setStoredClient)),"deviceId"in e&&"password"in e&&"name"in e){const t=e.appSecret||dt.generateAppSecret(e.deviceId,e.password,e.name),r=new Un({deviceId:e.deviceId,privKey:t,name:e.name,baseUrl:e.baseUrl});return r.connect(e.deviceId).then(async e=>(await z(r.getStateData()),e))}{const e=await F();if(!e)throw new Error("Client not initialized");const t=e.getDeviceId();return!e.ephemeralPub&&t?bo(t):(await z(e.getStateData()),Promise.resolve(!0))}},bo=async e=>ue(t=>t.connect(e)),yo=async e=>ue(t=>t.pair(e))}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"eth-lattice-keyring>gridplus-sdk",file:"node_modules/gridplus-sdk/dist/index.cjs"}],[583,{lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=o,function(e){const t=e?.PreferencesController,r=t?.preferences;delete r?.disabledUpgradeAccountsByChain,delete r?.accountUpgradeDisabledChains}(t.data),t},r.version=void 0;var n=e("lodash");const o=r.version=152.2}}},{package:"$root$",file:"app/scripts/migrations/152.2.ts"}],[5830,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.EthereumJSError=r.DEFAULT_ERROR_CODE=void 0,r.EthereumJSErrorWithoutCode=function(e,t){return new n({code:r.DEFAULT_ERROR_CODE},e,t)},r.DEFAULT_ERROR_CODE="ETHEREUMJS_DEFAULT_ERROR_CODE";class n extends Error{constructor(e,t,r){super(t??e.code),this.type=e,r!==undefined&&(this.stack=r)}getMetadata(){return this.type}toObject(){return{type:this.getMetadata(),message:this.message??"",stack:this.stack??"",className:this.constructor.name}}}r.EthereumJSError=n}}},{package:"eth-lattice-keyring>gridplus-sdk>@ethereumjs/rlp",file:"node_modules/gridplus-sdk/node_modules/@ethereumjs/rlp/dist/cjs/errors.js"}],[5831,{"./errors.js":5830},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=Object.create?function(e,t,r,n){n===undefined&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]},o=function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.RLP=r.utils=void 0,r.hexToBytes=p,r.encode=E,r.decode=v;const i=e("./errors.js");function s(e){if(0===e[0])throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: extra zeros");return function(e){const t=Number.parseInt(e,16);if(Number.isNaN(t))throw(0,i.EthereumJSErrorWithoutCode)("Invalid byte sequence");return t}(l(e))}function a(e,t){if(e<56)return Uint8Array.from([e+t]);const r=b(e),n=b(t+55+r.length/2);return Uint8Array.from(p(n+r))}function c(e,t,r){if(r>e.length)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function u(e){let t,r,n,o,a;const f=[],l=e[0];if(l<=127)return{data:e.slice(0,1),remainder:e.subarray(1)};if(l<=183){if(t=l-127,n=128===l?Uint8Array.from([]):c(e,1,t),2===t&&n[0]<128)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:n,remainder:e.subarray(t)}}if(l<=191){if(r=l-182,e.length-1<r)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: not enough bytes for string length");if(t=s(c(e,1,r)),t<=55)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: expected string length to be greater than 55");return n=c(e,r,t+r),{data:n,remainder:e.subarray(t+r)}}if(l<=247){for(t=l-191,o=c(e,1,t);o.length;)a=u(o),f.push(a.data),o=a.remainder;return{data:f,remainder:e.subarray(t)}}{if(r=l-246,t=s(c(e,1,r)),t<56)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: encoded list too short");const n=r+t;if(n>e.length)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: total length is larger than the data");for(o=c(e,r,n);o.length;)a=u(o),f.push(a.data),o=a.remainder;return{data:f,remainder:e.subarray(n)}}}o(e("./errors.js"),r);const f=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function l(e){let t="";for(let r=0;r<e.length;r++)t+=f[e[r]];return t}const d={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function h(e){return e>=d._0&&e<=d._9?e-d._0:e>=d._A&&e<=d._F?e-(d._A-10):e>=d._a&&e<=d._f?e-(d._a-10):void 0}function p(e){if("0x"===e.slice(0,2)&&(e=e.slice(0,2)),"string"!=typeof e)throw(0,i.EthereumJSErrorWithoutCode)("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw(0,i.EthereumJSErrorWithoutCode)("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=h(e.charCodeAt(o)),s=h(e.charCodeAt(o+1));if(r===undefined||s===undefined){const t=e[o]+e[o+1];throw(0,i.EthereumJSErrorWithoutCode)('hex string expected, got non-hex character "'+t+'" at index '+o)}n[t]=16*r+s}return n}function m(...e){if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}function g(e){return(new TextEncoder).encode(e)}function b(e){if(e<0)throw(0,i.EthereumJSErrorWithoutCode)("Invalid integer as argument, must be unsigned!");const t=e.toString(16);return t.length%2?`0${t}`:t}function y(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function w(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return y(e)?p((t="string"!=typeof(r=e)?r:y(r)?r.slice(2):r).length%2?`0${t}`:t):g(e);var t,r;if("number"==typeof e||"bigint"==typeof e)return e?p(b(e)):Uint8Array.from([]);if(null===e||e===undefined)return Uint8Array.from([]);throw(0,i.EthereumJSErrorWithoutCode)("toBytes: received unsupported type "+typeof e)}function E(e){if(Array.isArray(e)){const t=[];let r=0;for(let n=0;n<e.length;n++){const o=E(e[n]);t.push(o),r+=o.length}return m(a(r,192),...t)}const t=w(e);return 1===t.length&&t[0]<128?t:m(a(t.length,128),t)}function v(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=u(w(e));if(t)return{data:r.data,remainder:r.remainder.slice()};if(0!==r.remainder.length)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: remainder must be zero");return r.data}r.utils={bytesToHex:l,concatBytes:m,hexToBytes:p,utf8ToBytes:g},r.RLP={encode:E,decode:v}}}},{package:"eth-lattice-keyring>gridplus-sdk>@ethereumjs/rlp",file:"node_modules/gridplus-sdk/node_modules/@ethereumjs/rlp/dist/cjs/index.js"}],[5832,{"./abstract/weierstrass.js":5841,"@noble/hashes/hmac":4506,"@noble/hashes/utils":4515},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getHash=s,r.createCurve=function(e,t){const r=t=>(0,i.weierstrass)({...e,...s(t)});return{...r(t),create:r}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/hmac"),o=e("@noble/hashes/utils"),i=e("./abstract/weierstrass.js");function s(e){return{hash:e,hmac:(t,...r)=>(0,n.hmac)(e,t,(0,o.concatBytes)(...r)),randomBytes:o.randomBytes}}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/_shortw_utils.js"}],[5833,{"./hash-to-curve.js":5836,"./modular.js":5837,"./utils.js":5840,"./weierstrass.js":5841},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bls=function(e){const{Fp:t,Fr:r,Fp2:l,Fp6:d,Fp12:h}=e.fields,p=e.params.xNegative,m=e.params.twistType,g=(0,s.weierstrassPoints)({n:r.ORDER,...e.G1}),b=Object.assign(g,(0,n.createHasher)(g.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),y=(0,s.weierstrassPoints)({n:r.ORDER,...e.G2}),w=Object.assign(y,(0,n.createHasher)(y.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults}));let E;if("multiplicative"===m)E=(e,t,r,n,o,i)=>h.mul014(n,e,l.mul(t,o),l.mul(r,i));else{if("divisive"!==m)throw new Error("bls: unknown twist type");E=(e,t,r,n,o,i)=>h.mul034(n,l.mul(r,i),l.mul(t,o),e)}const v=l.div(l.ONE,l.mul(l.ONE,u));function x(e,t,r,n){const o=l.sqr(r),i=l.sqr(n),s=l.mulByB(l.mul(i,f)),a=l.mul(s,f),c=l.sub(l.sub(l.sqr(l.add(r,n)),i),o),u=l.sub(s,o),d=l.mul(l.sqr(t),f),h=l.neg(c);return e.push([u,d,h]),{Rx:t=l.mul(l.mul(l.mul(l.sub(o,a),t),r),v),Ry:r=l.sub(l.sqr(l.mul(l.add(o,a),v)),l.mul(l.sqr(s),f)),Rz:n=l.mul(o,c)}}function B(e,t,r,n,o,i){const s=l.sub(r,l.mul(i,n)),a=l.sub(t,l.mul(o,n)),c=l.sub(l.mul(s,o),l.mul(a,i)),f=l.neg(s),d=a;e.push([c,f,d]);const h=l.sqr(a),p=l.mul(h,a),m=l.mul(h,t),g=l.add(l.sub(p,l.mul(m,u)),l.mul(l.sqr(s),n));return{Rx:t=l.mul(a,g),Ry:r=l.sub(l.mul(l.sub(m,g),s),l.mul(p,r)),Rz:n=l.mul(n,p)}}const S=function(e){const t=[];for(;e>c;e>>=c)(e&c)===a?t.unshift(0):(e&f)===f?(t.unshift(-1),e+=c):t.unshift(1);return t}(e.params.ateLoopSize),P=(0,i.memoized)(t=>{const r=t,{x:n,y:o}=r.toAffine(),i=n,s=o,a=l.neg(o);let c=i,u=s,f=l.ONE;const d=[];for(const e of S){const t=[];({Rx:c,Ry:u,Rz:f}=x(t,c,u,f)),e&&({Rx:c,Ry:u,Rz:f}=B(t,c,u,f,i,-1===e?a:s)),d.push(t)}if(e.postPrecompute){const t=d[d.length-1];e.postPrecompute(c,u,f,i,s,B.bind(null,t))}return d});function I(e,t=!1){let r=h.ONE;if(e.length){const t=e[0][0].length;for(let n=0;n<t;n++){r=h.sqr(r);for(const[t,o,i]of e)for(const[e,s,a]of t[n])r=E(e,s,a,r,o,i)}}return p&&(r=h.conjugate(r)),t?h.finalExponentiate(r):r}function T(e,t=!0){const r=[];b.ProjectivePoint.normalizeZ(e.map(({g1:e})=>e)),w.ProjectivePoint.normalizeZ(e.map(({g2:e})=>e));for(const{g1:t,g2:n}of e){if(t.equals(b.ProjectivePoint.ZERO)||n.equals(w.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");t.assertValidity(),n.assertValidity();const e=t.toAffine();r.push([P(n),e.x,e.y])}return I(r,t)}const A={randomPrivateKey:()=>{const t=(0,o.getMinHashLength)(r.ORDER);return(0,o.mapHashToField)(e.randomBytes(t),r.ORDER)},calcPairingPrecomputes:P},{ShortSignature:j}=e.G1,{Signature:_}=e.G2;function k(e){return e instanceof b.ProjectivePoint?e:b.ProjectivePoint.fromHex(e)}function O(e,t){return e instanceof b.ProjectivePoint?e:b.hashToCurve((0,i.ensureBytes)("point",e),t)}function N(e){return e instanceof w.ProjectivePoint?e:_.fromHex(e)}function R(e,t){return e instanceof w.ProjectivePoint?e:w.hashToCurve((0,i.ensureBytes)("point",e),t)}function C(e){if(!Array.isArray(e)||0===e.length)throw new Error("expected non-empty array")}return b.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:function(e){return b.ProjectivePoint.fromPrivateKey(e).toRawBytes(!0)},getPublicKeyForShortSignatures:function(e){return w.ProjectivePoint.fromPrivateKey(e).toRawBytes(!0)},sign:function(e,t,r){const n=R(e,r);n.assertValidity();const o=n.multiply(b.normPrivateKeyToScalar(t));return e instanceof w.ProjectivePoint?o:_.toRawBytes(o)},signShortSignature:function(e,t,r){const n=O(e,r);n.assertValidity();const o=n.multiply(b.normPrivateKeyToScalar(t));return e instanceof b.ProjectivePoint?o:j.toRawBytes(o)},verify:function(e,t,r,n){const o=k(r),i=R(t,n),s=b.ProjectivePoint.BASE,a=N(e),c=T([{g1:o.negate(),g2:i},{g1:s,g2:a}]);return h.eql(c,h.ONE)},verifyBatch:function(e,t,r,n){if(C(t),r.length!==t.length)throw new Error("amount of public keys and messages should be equal");const o=N(e),i=t.map(e=>R(e,n)),s=r.map(k),a=new Map;for(let e=0;e<s.length;e++){const t=s[e],r=i[e];let n=a.get(r);n===undefined&&(n=[],a.set(r,n)),n.push(t)}const c=[];try{for(const[e,t]of a){const r=t.reduce((e,t)=>e.add(t));c.push({g1:r,g2:e})}return c.push({g1:b.ProjectivePoint.BASE.negate(),g2:o}),h.eql(T(c),h.ONE)}catch{return!1}},verifyShortSignature:function(e,t,r,n){const o=N(r),i=O(t,n),s=w.ProjectivePoint.BASE,a=k(e),c=T([{g1:i,g2:o},{g1:a,g2:s.negate()}]);return h.eql(c,h.ONE)},aggregatePublicKeys:function(e){C(e);const t=e.map(k).reduce((e,t)=>e.add(t),b.ProjectivePoint.ZERO);if(e[0]instanceof b.ProjectivePoint)return t.assertValidity(),t;return t.toRawBytes(!0)},aggregateSignatures:function(e){C(e);const t=e.map(N).reduce((e,t)=>e.add(t),w.ProjectivePoint.ZERO);if(e[0]instanceof w.ProjectivePoint)return t.assertValidity(),t;return _.toRawBytes(t)},aggregateShortSignatures:function(e){C(e);const t=e.map(k).reduce((e,t)=>e.add(t),b.ProjectivePoint.ZERO);if(e[0]instanceof b.ProjectivePoint)return t.assertValidity(),t;return j.toRawBytes(t)},millerLoopBatch:I,pairing:function(e,t,r=!0){return T([{g1:e,g2:t}],r)},pairingBatch:T,G1:b,G2:w,Signature:_,ShortSignature:j,fields:{Fr:r,Fp:t,Fp2:l,Fp6:d,Fp12:h},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:A}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./hash-to-curve.js"),o=e("./modular.js"),i=e("./utils.js"),s=e("./weierstrass.js"),a=BigInt(0),c=BigInt(1),u=BigInt(2),f=BigInt(3)}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/bls.js"}],[5834,{"./modular.js":5837,"./utils.js":5840},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.wNAF=function(e,t){return{constTimeNegate:a,hasPrecomputes:e=>1!==m(e),unsafeLadder(t,r,n=e.ZERO){let o=t;for(;r>i;)r&s&&(n=n.add(o)),o=o.double(),r>>=s;return n},precomputeWindow(e,r){const{windows:n,windowSize:o}=u(r,t),i=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,i.push(a);for(let e=1;e<o;e++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(r,n,o){let i=e.ZERO,s=e.BASE;const c=u(r,t);for(let e=0;e<c.windows;e++){const{nextN:t,offset:r,isZero:u,isNeg:l,isNegF:d,offsetF:h}=f(o,e,c);o=t,u?s=s.add(a(d,n[h])):i=i.add(a(l,n[r]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,s=e.ZERO){const a=u(r,t);for(let e=0;e<a.windows&&o!==i;e++){const{nextN:t,offset:r,isZero:i,isNeg:c}=f(o,e,a);if(o=t,!i){const e=n[r];s=s.add(c?e.negate():e)}}return s},getPrecomputes(e,t,r){let n=h.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&h.set(t,r(n))),n},wNAFCached(e,t,r){const n=m(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)},wNAFCachedUnsafe(e,t,r,n){const o=m(e);return 1===o?this.unsafeLadder(e,t,n):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),t,n)},setWindowSize(e,r){c(r,t),p.set(e,r),h.delete(e)}}},r.pippenger=function(e,t,r,n){l(r,e),d(n,t);const i=r.length,s=n.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,c=(0,o.bitLen)(BigInt(i));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const f=(0,o.bitMask)(u),h=new Array(Number(f)+1).fill(a),p=Math.floor((t.BITS-1)/u)*u;let m=a;for(let e=p;e>=0;e-=u){h.fill(a);for(let t=0;t<s;t++){const o=n[t],i=Number(o>>BigInt(e)&f);h[i]=h[i].add(r[t])}let t=a;for(let e=h.length-1,r=a;e>0;e--)r=r.add(h[e]),t=t.add(r);if(m=m.add(t),0!==e)for(let e=0;e<u;e++)m=m.double()}return m},r.precomputeMSMUnsafe=function(e,t,r,n){c(n,t.BITS),l(r,e);const i=e.ZERO,s=2**n-1,a=Math.ceil(t.BITS/n),u=(0,o.bitMask)(n),f=r.map(e=>{const t=[];for(let r=0,n=e;r<s;r++)t.push(n),n=n.add(e);return t});return e=>{if(d(e,t),e.length>r.length)throw new Error("array of scalars must be smaller than array of points");let o=i;for(let t=0;t<a;t++){if(o!==i)for(let e=0;e<n;e++)o=o.double();const r=BigInt(a*n-(t+1)*n);for(let t=0;t<e.length;t++){const n=e[t],i=Number(n>>r&u);i&&(o=o.add(f[t][i-1]))}}return o}},r.validateBasic=function(e){return(0,n.validateField)(e.Fp),(0,o.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1);function a(e,t){const r=t.negate();return e?r:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function u(e,t){c(e,t);const r=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:(0,o.bitMask)(e),maxNumber:r,shiftBy:BigInt(e)}}function f(e,t,r){const{windowSize:n,mask:o,maxNumber:i,shiftBy:a}=r;let c=Number(e&o),u=e>>a;c>n&&(c-=i,u+=s);const f=t*n;return{nextN:u,offset:f+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:f}}function l(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function d(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const h=new WeakMap,p=new WeakMap;function m(e){return p.get(e)||1}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/curve.js"}],[5835,{"./curve.js":5834,"./modular.js":5837,"./utils.js":5840},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.twistedEdwards=function(e){const t=function(e){const t=(0,n.validateBasic)(e);return(0,i.validateObject)(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:l,prehash:d,hash:h,randomBytes:p,nByteLength:m,h:g}=t,b=c<<BigInt(8*m)-a,y=r.create,w=(0,o.Field)(t.n,t.nBitLength);if(!function(e,n){const o=r.sqr(e),i=r.sqr(n),s=r.add(r.mul(t.a,o),i),a=r.add(r.ONE,r.mul(t.d,r.mul(o,i)));return r.eql(s,a)}(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const E=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:s}}}),v=t.adjustScalarBytes||(e=>e),x=t.domain||((e,t,r)=>{if((0,i.abool)("phflag",r),t.length||r)throw new Error("Contexts/pre-hash are not supported");return e});function B(e,t,r=!1){const n=r?a:s;(0,i.aInRange)("coordinate "+e,t,n,b)}function S(e){if(!(e instanceof T))throw new Error("ExtendedPoint expected")}const P=(0,i.memoized)((e,t)=>{const{ex:n,ey:o,ez:i}=e,c=e.is0();null==t&&(t=c?u:r.inv(i));const f=y(n*t),l=y(o*t),d=y(i*t);if(c)return{x:s,y:a};if(d!==a)throw new Error("invZ was invalid");return{x:f,y:l}}),I=(0,i.memoized)(e=>{const{a:r,d:n}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:o,ey:i,ez:s,et:a}=e,c=y(o*o),u=y(i*i),f=y(s*s),l=y(f*f),d=y(c*r);if(y(f*y(d+u))!==y(l+y(n*y(c*u))))throw new Error("bad point: equation left != right (1)");if(y(o*i)!==y(s*a))throw new Error("bad point: equation left != right (2)");return!0});class T{constructor(e,t,r,n){B("x",e),B("y",t),B("z",r,!0),B("t",n),this.ex=e,this.ey=t,this.ez=r,this.et=n,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof T)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};return B("x",t),B("y",r),new T(t,r,a,y(t*r))}static normalizeZ(e){const t=(0,o.FpInvertBatch)(r,e.map(e=>e.ez));return e.map((e,r)=>e.toAffine(t[r])).map(T.fromAffine)}static msm(e,t){return(0,n.pippenger)(T,w,e,t)}_setWindowSize(e){_.setWindowSize(this,e)}assertValidity(){I(this)}equals(e){S(e);const{ex:t,ey:r,ez:n}=this,{ex:o,ey:i,ez:s}=e,a=y(t*s),c=y(o*n),u=y(r*s),f=y(i*n);return a===c&&u===f}is0(){return this.equals(T.ZERO)}negate(){return new T(y(-this.ex),this.ey,this.ez,y(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:o}=this,i=y(r*r),s=y(n*n),a=y(c*y(o*o)),u=y(e*i),f=r+n,l=y(y(f*f)-i-s),d=u+s,h=d-a,p=u-s,m=y(l*h),g=y(d*p),b=y(l*p),w=y(h*d);return new T(m,g,w,b)}add(e){S(e);const{a:r,d:n}=t,{ex:o,ey:i,ez:s,et:a}=this,{ex:c,ey:u,ez:f,et:l}=e,d=y(o*c),h=y(i*u),p=y(a*n*l),m=y(s*f),g=y((o+i)*(c+u)-d-h),b=m-p,w=m+p,E=y(h-r*d),v=y(g*b),x=y(w*E),B=y(g*E),P=y(b*w);return new T(v,x,P,B)}subtract(e){return this.add(e.negate())}wNAF(e){return _.wNAFCached(this,e,T.normalizeZ)}multiply(e){const t=e;(0,i.aInRange)("scalar",t,a,l);const{p:r,f:n}=this.wNAF(t);return T.normalizeZ([r,n])[0]}multiplyUnsafe(e,t=T.ZERO){const r=e;return(0,i.aInRange)("scalar",r,s,l),r===s?j:this.is0()||r===a?this:_.wNAFCachedUnsafe(this,r,T.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(g).is0()}isTorsionFree(){return _.unsafeLadder(this,l).is0()}toAffine(e){return P(this,e)}clearCofactor(){const{h:e}=t;return e===a?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:o,a:c}=t,u=r.BYTES;e=(0,i.ensureBytes)("pointHex",e,u),(0,i.abool)("zip215",n);const f=e.slice(),l=e[u-1];f[u-1]=-129&l;const d=(0,i.bytesToNumberLE)(f),h=n?b:r.ORDER;(0,i.aInRange)("pointHex.y",d,s,h);const p=y(d*d),m=y(p-a),g=y(o*p-c);let{isValid:w,value:v}=E(m,g);if(!w)throw new Error("Point.fromHex: invalid y coordinate");const x=(v&a)===a,B=!!(128&l);if(!n&&v===s&&B)throw new Error("Point.fromHex: x=0 and x_0=1");return B!==x&&(v=y(-v)),T.fromAffine({x:v,y:d})}static fromPrivateKey(e){const{scalar:t}=N(e);return A.multiply(t)}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=(0,i.numberToBytesLE)(t,r.BYTES);return n[n.length-1]|=e&a?128:0,n}toHex(){return(0,i.bytesToHex)(this.toRawBytes())}}T.BASE=new T(t.Gx,t.Gy,a,y(t.Gx*t.Gy)),T.ZERO=new T(s,a,a,s);const{BASE:A,ZERO:j}=T,_=(0,n.wNAF)(T,8*m);function k(e){return(0,o.mod)(e,l)}function O(e){return k((0,i.bytesToNumberLE)(e))}function N(e){const t=r.BYTES;e=(0,i.ensureBytes)("private key",e,t);const n=(0,i.ensureBytes)("hashed private key",h(e),2*t),o=v(n.slice(0,t));return{head:o,prefix:n.slice(t,2*t),scalar:O(o)}}function R(e){const{head:t,prefix:r,scalar:n}=N(e),o=A.multiply(n),i=o.toRawBytes();return{head:t,prefix:r,scalar:n,point:o,pointBytes:i}}function C(e=Uint8Array.of(),...t){const r=(0,i.concatBytes)(...t);return O(h(x(r,(0,i.ensureBytes)("context",e),!!d)))}const U=f;A._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return R(e).pointBytes},sign:function(e,t,n={}){e=(0,i.ensureBytes)("message",e),d&&(e=d(e));const{prefix:o,scalar:a,pointBytes:c}=R(t),u=C(n.context,o,e),f=A.multiply(u).toRawBytes(),h=k(u+C(n.context,f,c,e)*a);(0,i.aInRange)("signature.s",h,s,l);const p=(0,i.concatBytes)(f,(0,i.numberToBytesLE)(h,r.BYTES));return(0,i.ensureBytes)("result",p,2*r.BYTES)},verify:function(e,t,n,o=U){const{context:s,zip215:a}=o,c=r.BYTES;e=(0,i.ensureBytes)("signature",e,2*c),t=(0,i.ensureBytes)("message",t),n=(0,i.ensureBytes)("publicKey",n,c),a!==undefined&&(0,i.abool)("zip215",a),d&&(t=d(t));const u=(0,i.bytesToNumberLE)(e.slice(c,2*c));let f,l,h;try{f=T.fromHex(n,a),l=T.fromHex(e.slice(0,c),a),h=A.multiplyUnsafe(u)}catch(e){return!1}if(!a&&f.isSmallOrder())return!1;const p=C(s,l.toRawBytes(),f.toRawBytes(),t);return l.add(f.multiplyUnsafe(p)).subtract(h).clearCofactor().equals(T.ZERO)},ExtendedPoint:T,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>p(r.BYTES),precompute:(e=8,t=T.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./curve.js"),o=e("./modular.js"),i=e("./utils.js"),s=BigInt(0),a=BigInt(1),c=BigInt(2),u=BigInt(8),f={zip215:!0}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/edwards.js"}],[5836,{"./modular.js":5837,"./utils.js":5840},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.expand_message_xmd=u,r.expand_message_xof=f,r.hash_to_field=l,r.isogenyMap=function(e,t){const r=t.map(e=>Array.from(e).reverse());return(t,o)=>{const[i,s,a,c]=r.map(r=>r.reduce((r,n)=>e.add(e.mul(r,t),n))),[u,f]=(0,n.FpInvertBatch)(e,[s,c],!0);return t=e.mul(i,u),o=e.mul(o,e.mul(a,f)),{x:t,y:o}}},r.createHasher=function(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");function n(r){return e.fromAffine(t(r))}function o(t){const r=t.clearCofactor();return r.equals(e.ZERO)?e.ZERO:(r.assertValidity(),r)}return{defaults:r,hashToCurve(e,t){const i=l(e,2,{...r,DST:r.DST,...t}),s=n(i[0]),a=n(i[1]);return o(s.add(a))},encodeToCurve:(e,t)=>o(n(l(e,1,{...r,DST:r.encodeDST,...t})[0])),mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return o(n(e))}}};const n=e("./modular.js"),o=e("./utils.js"),i=o.bytesToNumberBE;function s(e,t){if(c(e),c(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function a(e,t){const r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e,t,r,n){(0,o.abytes)(e),(0,o.abytes)(t),c(r),t.length>255&&(t=n((0,o.concatBytes)((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:u}=n,f=Math.ceil(r/i);if(r>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,o.concatBytes)(t,s(t.length,1)),d=s(0,u),h=s(r,2),p=new Array(f),m=n((0,o.concatBytes)(d,e,h,s(0,1),l));p[0]=n((0,o.concatBytes)(m,s(1,1),l));for(let e=1;e<=f;e++){const t=[a(m,p[e-1]),s(e+1,1),l];p[e]=n((0,o.concatBytes)(...t))}return(0,o.concatBytes)(...p).slice(0,r)}function f(e,t,r,n,i){if((0,o.abytes)(e),(0,o.abytes)(t),c(r),t.length>255){const e=Math.ceil(2*n/8);t=i.create({dkLen:e}).update((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(s(r,2)).update(t).update(s(t.length,1)).digest()}function l(e,t,r){(0,o.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:a,m:l,hash:d,expand:h,DST:p}=r;(0,o.abytes)(e),c(t);const m="string"==typeof p?(0,o.utf8ToBytes)(p):p,g=s.toString(2).length,b=Math.ceil((g+a)/8),y=t*l*b;let w;if("xmd"===h)w=u(e,m,y,d);else if("xof"===h)w=f(e,m,y,a,d);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');w=e}const E=new Array(t);for(let e=0;e<t;e++){const t=new Array(l);for(let r=0;r<l;r++){const o=b*(r+e*l),a=w.subarray(o,o+b);t[r]=(0,n.mod)(i(a),s)}E[e]=t}return E}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/hash-to-curve.js"}],[5837,{"./utils.js":5840,"@noble/hashes/utils":4515},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.isNegativeLE=void 0,r.mod=d,r.pow=function(e,t,r){return w(B(r),e,t)},r.pow2=function(e,t,r){let n=e;for(;t-- >i;)n*=n,n%=r;return n},r.invert=h,r.tonelliShanks=g,r.FpSqrt=b,r.validateField=function(e){const t=y.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,o.validateObject)(e,t)},r.FpPow=w,r.FpInvertBatch=E,r.FpDiv=function(e,t,r){return e.mul(t,"bigint"==typeof r?h(r,e.ORDER):e.inv(r))},r.FpLegendre=v,r.FpIsSquare=function(e,t){return 1===v(e,t)},r.nLength=x,r.Field=B,r.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)},r.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r},r.hashToPrivateScalar=function(e,t,r=!1){const n=(e=(0,o.ensureBytes)("privateHash",e)).length,i=x(t).nByteLength+8;if(i<24||n<i||n>1024)throw new Error("hashToPrivateScalar: expected "+i+"-1024 bytes of input, got "+n);return d(r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e),t-s)+s},r.getFieldBytesLength=S,r.getMinHashLength=P,r.mapHashToField=function(e,t,r=!1){const n=e.length,i=S(t),a=P(t);if(n<16||n<a||n>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+n);const c=d(r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e),t-s)+s;return r?(0,o.numberToBytesLE)(c,i):(0,o.numberToBytesBE)(c,i)};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/utils"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1),a=BigInt(2),c=BigInt(3),u=BigInt(4),f=BigInt(5),l=BigInt(8);function d(e,t){const r=e%t;return r>=i?r:t+r}function h(e,t){if(e===i)throw new Error("invert: expected non-zero number");if(t<=i)throw new Error("invert: expected positive modulus, got "+t);let r=d(e,t),n=t,o=i,a=s,c=s,u=i;for(;r!==i;){const e=n/r,t=n%r,i=o-c*e,s=a-u*e;n=r,r=t,o=c,a=u,c=i,u=s}if(n!==s)throw new Error("invert: does not exist");return d(o,t)}function p(e,t){const r=(e.ORDER+s)/u,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function m(e,t){const r=(e.ORDER-f)/l,n=e.mul(t,a),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,a),o),c=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}function g(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-s,r=0;for(;t%a===i;)t/=a,r++;let n=a;const o=B(e);for(;1===v(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return p;let c=o.pow(n,t);const u=(t+s)/a;return function(e,n){if(e.is0(n))return n;if(1!==v(e,n))throw new Error("Cannot find square root");let o=r,i=e.mul(e.ONE,c),a=e.pow(n,t),f=e.pow(n,u);for(;!e.eql(a,e.ONE);){if(e.is0(a))return e.ZERO;let t=1,r=e.sqr(a);for(;!e.eql(r,e.ONE);)if(t++,r=e.sqr(r),t===o)throw new Error("Cannot find square root");const n=s<<BigInt(o-t-1),c=e.pow(i,n);o=t,i=e.sqr(c),a=e.mul(a,i),f=e.mul(f,c)}return f}}function b(e){return e%u===c?p:e%l===f?m:g(e)}r.isNegativeLE=(e,t)=>(d(e,t)&s)===s;const y=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function w(e,t,r){if(r<i)throw new Error("invalid exponent, negatives unsupported");if(r===i)return e.ONE;if(r===s)return t;let n=e.ONE,o=t;for(;r>i;)r&s&&(n=e.mul(n,o)),o=e.sqr(o),r>>=s;return n}function E(e,t,r=!1){const n=new Array(t.length).fill(r?e.ZERO:undefined),o=t.reduce((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r)),e.ONE),i=e.inv(o);return t.reduceRight((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r)),i),n}function v(e,t){const r=(e.ORDER-s)/a,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),c=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!c)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function x(e,t){t!==undefined&&(0,n.anumber)(t);const r=t!==undefined?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function B(e,t,r=!1,n={}){if(e<=i)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:a,nByteLength:c}=x(e,t);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const f=Object.freeze({ORDER:e,isLE:r,BITS:a,BYTES:c,MASK:(0,o.bitMask)(a),ZERO:i,ONE:s,create:t=>d(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return i<=t&&t<e},is0:e=>e===i,isOdd:e=>(e&s)===s,neg:t=>d(-t,e),eql:(e,t)=>e===t,sqr:t=>d(t*t,e),add:(t,r)=>d(t+r,e),sub:(t,r)=>d(t-r,e),mul:(t,r)=>d(t*r,e),pow:(e,t)=>w(f,e,t),div:(t,r)=>d(t*h(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>h(t,e),sqrt:n.sqrt||(t=>(u||(u=b(e)),u(f,t))),toBytes:e=>r?(0,o.numberToBytesLE)(e,c):(0,o.numberToBytesBE)(e,c),fromBytes:e=>{if(e.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+e.length);return r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e)},invertBatch:e=>E(f,e),cmov:(e,t,r)=>r?t:e});return Object.freeze(f)}function S(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function P(e){const t=S(e);return t+Math.ceil(t/2)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/modular.js"}],[5838,{"./modular.js":5837,"./utils.js":5840},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.montgomery=function(e){const t=(d=e,(0,o.validateObject)(d,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...d})),{P:r,type:c,adjustScalarBytes:u,powPminus2:f}=t,l="x25519"===c;var d;if(!l&&"x448"!==c)throw new Error("invalid type");const h=l?255:448,p=l?32:56,m=l?BigInt(9):BigInt(5),g=l?BigInt(121665):BigInt(39081),b=l?a**BigInt(254):a**BigInt(447),y=l?BigInt(8)*a**BigInt(251)-s:BigInt(4)*a**BigInt(445)-s,w=b+y+s,E=e=>(0,n.mod)(e,r),v=x(m);function x(e){return(0,o.numberToBytesLE)(E(e),p)}function B(e,t){const n=function(e,t){(0,o.aInRange)("u",e,i,r),(0,o.aInRange)("scalar",t,b,w);const n=t,a=e;let c=s,u=i,l=e,d=s,p=i;for(let e=BigInt(h-1);e>=i;e--){const t=n>>e&s;p^=t,({x_2:c,x_3:l}=P(p,c,l)),({x_2:u,x_3:d}=P(p,u,d)),p=t;const r=c+u,o=E(r*r),i=c-u,f=E(i*i),h=o-f,m=l+d,b=E((l-d)*r),y=E(m*i),w=b+y,v=b-y;l=E(w*w),d=E(a*E(v*v)),c=E(o*f),u=E(h*(o+E(g*h)))}({x_2:c,x_3:l}=P(p,c,l)),({x_2:u,x_3:d}=P(p,u,d));const m=f(u);return E(c*m)}(function(e){const t=(0,o.ensureBytes)("u coordinate",e,p);return l&&(t[31]&=127),E((0,o.bytesToNumberLE)(t))}(t),function(e){return(0,o.bytesToNumberLE)(u((0,o.ensureBytes)("scalar",e,p)))}(e));if(n===i)throw new Error("invalid private or public key received");return x(n)}function S(e){return B(e,v)}function P(e,t,r){const n=E(e*(t-r));return{x_2:t=E(t-n),x_3:r=E(r+n)}}return{scalarMult:B,scalarMultBase:S,getSharedSecret:(e,t)=>B(e,t),getPublicKey:e=>S(e),utils:{randomPrivateKey:()=>t.randomBytes(p)},GuBytes:v.slice()}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1),a=BigInt(2)}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/montgomery.js"}],[5839,{"./modular.js":5837,"./utils.js":5840},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.psiFrobenius=function(e,t,r){const n=t.pow(r,(e.ORDER-s)/c),o=t.pow(r,(e.ORDER-s)/a);function i(e,r){return[t.mul(t.frobeniusMap(e,1),n),t.mul(t.frobeniusMap(r,1),o)]}const u=t.pow(r,(e.ORDER**a-s)/c),f=t.pow(r,(e.ORDER**a-s)/a);if(!t.eql(f,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function l(e,r){return[t.mul(e,u),t.neg(r)]}const d=e=>(t,r)=>{const n=r.toAffine(),o=e(n.x,n.y);return t.fromAffine({x:o[0],y:o[1]})},h=d(i),p=d(l);return{psi:i,psi2:l,G2psi:h,G2psi2:p,PSI_X:n,PSI_Y:o,PSI2_X:u,PSI2_Y:f}},r.tower12=function(e){const{ORDER:t}=e,r=n.Field(t),c=r.create(e.NONRESIDUE||BigInt(-1)),f=r.div(r.ONE,a),l=u(r,c,r.ORDER,2)[0],d=({c0:e,c1:t},{c0:n,c1:o})=>({c0:r.add(e,n),c1:r.add(t,o)}),h=({c0:e,c1:t},{c0:n,c1:o})=>({c0:r.sub(e,n),c1:r.sub(t,o)}),p=({c0:e,c1:t},n)=>{if("bigint"==typeof n)return{c0:r.mul(e,n),c1:r.mul(t,n)};const{c0:o,c1:i}=n;let s=r.mul(e,o),a=r.mul(t,i);return{c0:r.sub(s,a),c1:r.sub(r.mul(r.add(e,t),r.add(o,i)),r.add(s,a))}},m=({c0:e,c1:t})=>{const n=r.add(e,t),o=r.sub(e,t),i=r.add(e,e);return{c0:r.mul(n,o),c1:r.mul(i,t)}},g=e=>{if(2!==e.length)throw new Error("invalid tuple");const t=e.map(e=>r.create(e));return{c0:t[0],c1:t[1]}},b=t*t,y=g(e.FP2_NONRESIDUE),w={ORDER:b,isLE:r.isLE,NONRESIDUE:y,BITS:(0,o.bitLen)(b),BYTES:Math.ceil((0,o.bitLen)(b)/8),MASK:(0,o.bitMask)((0,o.bitLen)(b)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:e=>e,isValid:({c0:e,c1:t})=>"bigint"==typeof e&&"bigint"==typeof t,is0:({c0:e,c1:t})=>r.is0(e)&&r.is0(t),eql:({c0:e,c1:t},{c0:n,c1:o})=>r.eql(e,n)&&r.eql(t,o),neg:({c0:e,c1:t})=>({c0:r.neg(e),c1:r.neg(t)}),pow:(e,t)=>n.FpPow(w,e,t),invertBatch:e=>n.FpInvertBatch(w,e),add:d,sub:h,mul:p,sqr:m,addN:d,subN:h,mulN:p,sqrN:m,div:(e,t)=>w.mul(e,"bigint"==typeof t?r.inv(r.create(t)):w.inv(t)),inv:({c0:e,c1:t})=>{const n=r.inv(r.create(e*e+t*t));return{c0:r.mul(n,r.create(e)),c1:r.mul(n,r.create(-t))}},sqrt:t=>{if(e.Fp2sqrt)return e.Fp2sqrt(t);const{c0:o,c1:i}=t;if(r.is0(i))return 1===n.FpLegendre(r,o)?w.create({c0:r.sqrt(o),c1:r.ZERO}):w.create({c0:r.ZERO,c1:r.sqrt(r.div(o,c))});const s=r.sqrt(r.sub(r.sqr(o),r.mul(r.sqr(i),c)));let a=r.mul(r.add(s,o),f);-1===n.FpLegendre(r,a)&&(a=r.sub(a,s));const u=r.sqrt(a),l=w.create({c0:u,c1:r.div(r.mul(i,f),u)});if(!w.eql(w.sqr(l),t))throw new Error("Cannot find square root");const d=l,h=w.neg(d),{re:p,im:m}=w.reim(d),{re:g,im:b}=w.reim(h);return m>b||m===b&&p>g?d:h},isOdd:e=>{const{re:t,im:r}=w.reim(e);return BigInt(t%a||t===i&&r%a)==s},fromBytes(e){if(e.length!==w.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:r.fromBytes(e.subarray(0,r.BYTES)),c1:r.fromBytes(e.subarray(r.BYTES))}},toBytes:({c0:e,c1:t})=>(0,o.concatBytes)(r.toBytes(e),r.toBytes(t)),cmov:({c0:e,c1:t},{c0:n,c1:o},i)=>({c0:r.cmov(e,n,i),c1:r.cmov(t,o,i)}),reim:({c0:e,c1:t})=>({re:e,im:t}),mulByNonresidue:({c0:e,c1:t})=>w.mul({c0:e,c1:t},y),mulByB:e.Fp2mulByB,fromBigTuple:g,frobeniusMap:({c0:e,c1:t},n)=>({c0:e,c1:r.mul(t,l[n%2])})},E=({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i})=>({c0:w.add(e,n),c1:w.add(t,o),c2:w.add(r,i)}),v=({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i})=>({c0:w.sub(e,n),c1:w.sub(t,o),c2:w.sub(r,i)}),x=({c0:e,c1:t,c2:r},n)=>{if("bigint"==typeof n)return{c0:w.mul(e,n),c1:w.mul(t,n),c2:w.mul(r,n)};const{c0:o,c1:i,c2:s}=n,a=w.mul(e,o),c=w.mul(t,i),u=w.mul(r,s);return{c0:w.add(a,w.mulByNonresidue(w.sub(w.mul(w.add(t,r),w.add(i,s)),w.add(c,u)))),c1:w.add(w.sub(w.mul(w.add(e,t),w.add(o,i)),w.add(a,c)),w.mulByNonresidue(u)),c2:w.sub(w.add(c,w.mul(w.add(e,r),w.add(o,s))),w.add(a,u))}},B=({c0:e,c1:t,c2:r})=>{let n=w.sqr(e),o=w.mul(w.mul(e,t),a),i=w.mul(w.mul(t,r),a),s=w.sqr(r);return{c0:w.add(w.mulByNonresidue(i),n),c1:w.add(w.mulByNonresidue(s),o),c2:w.sub(w.sub(w.add(w.add(o,w.sqr(w.add(w.sub(e,t),r))),i),n),s)}},[S,P]=u(w,y,r.ORDER,6,2,3),I={ORDER:w.ORDER,isLE:w.isLE,BITS:3*w.BITS,BYTES:3*w.BYTES,MASK:(0,o.bitMask)(3*w.BITS),ZERO:{c0:w.ZERO,c1:w.ZERO,c2:w.ZERO},ONE:{c0:w.ONE,c1:w.ZERO,c2:w.ZERO},create:e=>e,isValid:({c0:e,c1:t,c2:r})=>w.isValid(e)&&w.isValid(t)&&w.isValid(r),is0:({c0:e,c1:t,c2:r})=>w.is0(e)&&w.is0(t)&&w.is0(r),neg:({c0:e,c1:t,c2:r})=>({c0:w.neg(e),c1:w.neg(t),c2:w.neg(r)}),eql:({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i})=>w.eql(e,n)&&w.eql(t,o)&&w.eql(r,i),sqrt:o.notImplemented,div:(e,t)=>I.mul(e,"bigint"==typeof t?r.inv(r.create(t)):I.inv(t)),pow:(e,t)=>n.FpPow(I,e,t),invertBatch:e=>n.FpInvertBatch(I,e),add:E,sub:v,mul:x,sqr:B,addN:E,subN:v,mulN:x,sqrN:B,inv:({c0:e,c1:t,c2:r})=>{let n=w.sub(w.sqr(e),w.mulByNonresidue(w.mul(r,t))),o=w.sub(w.mulByNonresidue(w.sqr(r)),w.mul(e,t)),i=w.sub(w.sqr(t),w.mul(e,r)),s=w.inv(w.add(w.mulByNonresidue(w.add(w.mul(r,o),w.mul(t,i))),w.mul(e,n)));return{c0:w.mul(s,n),c1:w.mul(s,o),c2:w.mul(s,i)}},fromBytes:e=>{if(e.length!==I.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:w.fromBytes(e.subarray(0,w.BYTES)),c1:w.fromBytes(e.subarray(w.BYTES,2*w.BYTES)),c2:w.fromBytes(e.subarray(2*w.BYTES))}},toBytes:({c0:e,c1:t,c2:r})=>(0,o.concatBytes)(w.toBytes(e),w.toBytes(t),w.toBytes(r)),cmov:({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i},s)=>({c0:w.cmov(e,n,s),c1:w.cmov(t,o,s),c2:w.cmov(r,i,s)}),fromBigSix:e=>{if(!Array.isArray(e)||6!==e.length)throw new Error("invalid Fp6 usage");return{c0:w.fromBigTuple(e.slice(0,2)),c1:w.fromBigTuple(e.slice(2,4)),c2:w.fromBigTuple(e.slice(4,6))}},frobeniusMap:({c0:e,c1:t,c2:r},n)=>({c0:w.frobeniusMap(e,n),c1:w.mul(w.frobeniusMap(t,n),S[n%6]),c2:w.mul(w.frobeniusMap(r,n),P[n%6])}),mulByFp2:({c0:e,c1:t,c2:r},n)=>({c0:w.mul(e,n),c1:w.mul(t,n),c2:w.mul(r,n)}),mulByNonresidue:({c0:e,c1:t,c2:r})=>({c0:w.mulByNonresidue(r),c1:e,c2:t}),mul1:({c0:e,c1:t,c2:r},n)=>({c0:w.mulByNonresidue(w.mul(r,n)),c1:w.mul(e,n),c2:w.mul(t,n)}),mul01({c0:e,c1:t,c2:r},n,o){let i=w.mul(e,n),s=w.mul(t,o);return{c0:w.add(w.mulByNonresidue(w.sub(w.mul(w.add(t,r),o),s)),i),c1:w.sub(w.sub(w.mul(w.add(n,o),w.add(e,t)),i),s),c2:w.add(w.sub(w.mul(w.add(e,r),n),i),s)}}},T=u(w,y,r.ORDER,12,1,6)[0],A=({c0:e,c1:t},{c0:r,c1:n})=>({c0:I.add(e,r),c1:I.add(t,n)}),j=({c0:e,c1:t},{c0:r,c1:n})=>({c0:I.sub(e,r),c1:I.sub(t,n)}),_=({c0:e,c1:t},r)=>{if("bigint"==typeof r)return{c0:I.mul(e,r),c1:I.mul(t,r)};let{c0:n,c1:o}=r,i=I.mul(e,n),s=I.mul(t,o);return{c0:I.add(i,I.mulByNonresidue(s)),c1:I.sub(I.mul(I.add(e,t),I.add(n,o)),I.add(i,s))}},k=({c0:e,c1:t})=>{let r=I.mul(e,t);return{c0:I.sub(I.sub(I.mul(I.add(I.mulByNonresidue(t),e),I.add(e,t)),r),I.mulByNonresidue(r)),c1:I.add(r,r)}};const O={ORDER:w.ORDER,isLE:I.isLE,BITS:2*I.BITS,BYTES:2*I.BYTES,MASK:(0,o.bitMask)(2*I.BITS),ZERO:{c0:I.ZERO,c1:I.ZERO},ONE:{c0:I.ONE,c1:I.ZERO},create:e=>e,isValid:({c0:e,c1:t})=>I.isValid(e)&&I.isValid(t),is0:({c0:e,c1:t})=>I.is0(e)&&I.is0(t),neg:({c0:e,c1:t})=>({c0:I.neg(e),c1:I.neg(t)}),eql:({c0:e,c1:t},{c0:r,c1:n})=>I.eql(e,r)&&I.eql(t,n),sqrt:o.notImplemented,inv:({c0:e,c1:t})=>{let r=I.inv(I.sub(I.sqr(e),I.mulByNonresidue(I.sqr(t))));return{c0:I.mul(e,r),c1:I.neg(I.mul(t,r))}},div:(e,t)=>O.mul(e,"bigint"==typeof t?r.inv(r.create(t)):O.inv(t)),pow:(e,t)=>n.FpPow(O,e,t),invertBatch:e=>n.FpInvertBatch(O,e),add:A,sub:j,mul:_,sqr:k,addN:A,subN:j,mulN:_,sqrN:k,fromBytes:e=>{if(e.length!==O.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:I.fromBytes(e.subarray(0,I.BYTES)),c1:I.fromBytes(e.subarray(I.BYTES))}},toBytes:({c0:e,c1:t})=>(0,o.concatBytes)(I.toBytes(e),I.toBytes(t)),cmov:({c0:e,c1:t},{c0:r,c1:n},o)=>({c0:I.cmov(e,r,o),c1:I.cmov(t,n,o)}),fromBigTwelve:e=>({c0:I.fromBigSix(e.slice(0,6)),c1:I.fromBigSix(e.slice(6,12))}),frobeniusMap(e,t){const{c0:r,c1:n,c2:o}=I.frobeniusMap(e.c1,t),i=T[t%12];return{c0:I.frobeniusMap(e.c0,t),c1:I.create({c0:w.mul(r,i),c1:w.mul(n,i),c2:w.mul(o,i)})}},mulByFp2:({c0:e,c1:t},r)=>({c0:I.mulByFp2(e,r),c1:I.mulByFp2(t,r)}),conjugate:({c0:e,c1:t})=>({c0:e,c1:I.neg(t)}),mul014:({c0:e,c1:t},r,n,o)=>{let i=I.mul01(e,r,n),s=I.mul1(t,o);return{c0:I.add(I.mulByNonresidue(s),i),c1:I.sub(I.sub(I.mul01(I.add(t,e),r,w.add(n,o)),i),s)}},mul034:({c0:e,c1:t},r,n,o)=>{const i=I.create({c0:w.mul(e.c0,r),c1:w.mul(e.c1,r),c2:w.mul(e.c2,r)}),s=I.mul01(t,n,o),a=I.mul01(I.add(e,t),w.add(r,n),o);return{c0:I.add(I.mulByNonresidue(s),i),c1:I.sub(a,I.add(i,s))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:w,Fp6:I,Fp4Square:function(e,t){const r=w.sqr(e),n=w.sqr(t);return{first:w.add(w.mulByNonresidue(n),r),second:w.sub(w.sub(w.sqr(w.add(e,t)),r),n)}},Fp12:O}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1),a=BigInt(2),c=BigInt(3);function u(e,t,r,n,o=1,i){const a=BigInt(i===undefined?n:i),c=r**BigInt(n),u=[];for(let i=0;i<o;i++){const o=BigInt(i+1),f=[];for(let i=0,u=s;i<n;i++){const n=(o*u-o)/a%c;f.push(e.pow(t,n)),u*=r}u.push(f)}return u}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/tower.js"}],[584,{"@metamask/utils":4277,lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=i,function(e){if(!(0,o.hasProperty)(e,"PermissionController"))return e;if(!(0,o.isObject)(e.PermissionController))return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.PermissionController is ${typeof e.PermissionController}`)),e;const{subjects:t}=e.PermissionController;if(!(0,o.isObject)(t))return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.PermissionController.subjects is ${typeof t}`)),e;for(const e of Object.values(t)){if(!(0,o.isObject)(e)||!(0,o.hasProperty)(e,"permissions")||!(0,o.isObject)(e.permissions))continue;const{permissions:t}=e,r=t[a];if(!(0,o.isObject)(r)||!Array.isArray(r.caveats))continue;const n=r.caveats.find(e=>e.type===s);n&&(0,o.isObject)(n.value)&&!(0,o.hasProperty)(n.value,"sessionProperties")&&(n.value.sessionProperties={})}}(t.data),t},r.version=void 0;var n=e("lodash"),o=e("@metamask/utils");const i=r.version=152,s="authorizedScopes",a="endowment:caip25"}}},{package:"$root$",file:"app/scripts/migrations/152.ts"}],[5840,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
Object.defineProperty(r,"__esModule",{value:!0}),r.notImplemented=r.bitMask=void 0,r.isBytes=i,r.abytes=s,r.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},r.numberToHexUnpadded=a,r.hexToNumber=c,r.bytesToHex=l,r.hexToBytes=p,r.bytesToNumberBE=function(e){return c(l(e))},r.bytesToNumberLE=function(e){return s(e),c(l(Uint8Array.from(e).reverse()))},r.numberToBytesBE=m,r.numberToBytesLE=function(e,t){return m(e,t).reverse()},r.numberToVarBytesBE=function(e){return p(a(e))},r.ensureBytes=function(e,t,r){let n;if("string"==typeof t)try{n=p(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!i(t))throw new Error(e+" must be hex string or Uint8Array");n=Uint8Array.from(t)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n},r.concatBytes=g,r.equalBytes=function(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r},r.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},r.inRange=y,r.aInRange=function(e,t,r,n){if(!y(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)},r.bitLen=function(e){let t;for(t=0;e>n;e>>=o,t+=1);return t},r.bitGet=function(e,t){return e>>BigInt(t)&o},r.bitSet=function(e,t,r){return e|(r?o:n)<<BigInt(t)},r.createHmacDrbg=function(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=w(e),o=w(e),i=0;const s=()=>{n.fill(1),o.fill(0),i=0},a=(...e)=>r(o,n,...e),c=(e=w(0))=>{o=a(E([0]),e),n=a(),0!==e.length&&(o=a(E([1]),e),n=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e<t;){n=a();const t=n.slice();r.push(t),e+=n.length}return g(...r)};return(e,t)=>{s(),c(e);let r=undefined;for(;!(r=t(u()));)c();return s(),r}},r.validateObject=function(e,t,r={}){const n=(t,r,n)=>{const o=v[r];if("function"!=typeof o)throw new Error("invalid validator function");const i=e[t];if(!(n&&i===undefined||o(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+r+", got "+i)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e},r.memoized=function(e){const t=new WeakMap;return(r,...n)=>{const o=t.get(r);if(o!==undefined)return o;const i=e(r,...n);return t.set(r,i),i}};const n=BigInt(0),o=BigInt(1);function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function s(e){if(!i(e))throw new Error("Uint8Array expected")}function a(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?n:BigInt("0x"+e)}const u="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,f=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function l(e){if(s(e),u)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=f[e[r]];return t}const d={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=d._0&&e<=d._9?e-d._0:e>=d.A&&e<=d.F?e-(d.A-10):e>=d.a&&e<=d.f?e-(d.a-10):void 0}function p(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(u)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=h(e.charCodeAt(o)),i=h(e.charCodeAt(o+1));if(r===undefined||i===undefined){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}n[t]=16*r+i}return n}function m(e,t){return p(e.toString(16).padStart(2*t,"0"))}function g(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}const b=e=>"bigint"==typeof e&&n<=e;function y(e,t,r){return b(e)&&b(t)&&b(r)&&t<=e&&e<r}r.bitMask=e=>(o<<BigInt(e))-o;const w=e=>new Uint8Array(e),E=e=>Uint8Array.from(e);const v={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||i(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};r.notImplemented=()=>{throw new Error("not implemented")}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/utils.js"}],[5841,{"./curve.js":5834,"./modular.js":5837,"./utils.js":5840},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.DER=r.DERErr=void 0,r.weierstrassPoints=p,r.weierstrass=function(e){const t=function(e){const t=(0,n.validateBasic)(e);return(0,i.validateObject)(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:a,n:l,nByteLength:d,nBitLength:h}=t,m=a.BYTES+1,g=2*a.BYTES+1;function b(e){return(0,o.mod)(e,l)}function y(e){return(0,o.invert)(e,l)}const{ProjectivePoint:w,normPrivateKeyToScalar:E,weierstrassEquation:v,isWithinCurveOrder:x}=p({...t,toBytes(e,t,r){const n=t.toAffine(),o=a.toBytes(n.x),s=i.concatBytes;return(0,i.abool)("isCompressed",r),r?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,a.toBytes(n.y))},fromBytes(e){const t=e.length,r=e[0],n=e.subarray(1);if(t!==m||2!==r&&3!==r){if(t===g&&4===r){return{x:a.fromBytes(n.subarray(0,a.BYTES)),y:a.fromBytes(n.subarray(a.BYTES,2*a.BYTES))}}throw new Error("invalid Point, expected length of "+m+", or uncompressed "+g+", got "+t)}{const e=(0,i.bytesToNumberBE)(n);if(!(0,i.inRange)(e,f,a.ORDER))throw new Error("Point is not on curve");const t=v(e);let o;try{o=a.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((o&f)===f)&&(o=a.neg(o)),{x:e,y:o}}}});function B(e){return e>l>>f}const S=(e,t,r)=>(0,i.bytesToNumberBE)(e.slice(t,r));class P{constructor(e,t,r){(0,i.aInRange)("r",e,f,l),(0,i.aInRange)("s",t,f,l),this.r=e,this.s=t,null!=r&&(this.recovery=r),Object.freeze(this)}static fromCompact(e){const t=d;return e=(0,i.ensureBytes)("compactSignature",e,2*t),new P(S(e,0,t),S(e,t,2*t))}static fromDER(e){const{r:t,s:n}=r.DER.toSig((0,i.ensureBytes)("DER",e));return new P(t,n)}assertValidity(){}addRecoveryBit(e){return new P(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:n,recovery:o}=this,s=j((0,i.ensureBytes)("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const u=2===o||3===o?r+t.n:r;if(u>=a.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&o?"03":"02",l=w.fromHex(f+c(u,a.BYTES)),d=y(u),h=b(-s*d),p=b(n*d),m=w.BASE.multiplyAndAddUnsafe(l,h,p);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return B(this.s)}normalizeS(){return this.hasHighS()?new P(this.r,b(-this.s),this.recovery):this}toDERRawBytes(){return(0,i.hexToBytes)(this.toDERHex())}toDERHex(){return r.DER.hexFromSig(this)}toCompactRawBytes(){return(0,i.hexToBytes)(this.toCompactHex())}toCompactHex(){const e=d;return c(this.r,e)+c(this.s,e)}}const I={isValidPrivateKey(e){try{return E(e),!0}catch(e){return!1}},normPrivateKeyToScalar:E,randomPrivateKey:()=>{const e=(0,o.getMinHashLength)(t.n);return(0,o.mapHashToField)(t.randomBytes(e),t.n)},precompute:(e=8,t=w.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function T(e){if("bigint"==typeof e)return!1;if(e instanceof w)return!0;const r=(0,i.ensureBytes)("key",e).length,n=a.BYTES,o=n+1,s=2*n+1;return t.allowedPrivateKeyLengths||d===o?undefined:r===o||r===s}const A=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,i.bytesToNumberBE)(e),r=8*e.length-h;return r>0?t>>BigInt(r):t},j=t.bits2int_modN||function(e){return b(A(e))},_=(0,i.bitMask)(h);function k(e){return(0,i.aInRange)("num < 2^"+h,e,u,_),(0,i.numberToBytesBE)(e,d)}function O(e,r,n=N){if(["recovered","canonical"].some(e=>e in n))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:c}=t;let{lowS:l,prehash:d,extraEntropy:h}=n;null==l&&(l=!0),e=(0,i.ensureBytes)("msgHash",e),s(n),d&&(e=(0,i.ensureBytes)("prehashed msgHash",o(e)));const p=j(e),m=E(r),g=[k(m),k(p)];if(null!=h&&!1!==h){const e=!0===h?c(a.BYTES):h;g.push((0,i.ensureBytes)("extraEntropy",e))}const v=(0,i.concatBytes)(...g),S=p;return{seed:v,k2sig:function(e){const t=A(e);if(!x(t))return;const r=y(t),n=w.BASE.multiply(t).toAffine(),o=b(n.x);if(o===u)return;const i=b(r*b(S+o*m));if(i===u)return;let s=(n.x===o?0:2)|Number(n.y&f),a=i;return l&&B(i)&&(a=function(e){return B(e)?b(-e):e}(i),s^=1),new P(o,a,s)}}}const N={lowS:t.lowS,prehash:!1},R={lowS:t.lowS,prehash:!1};return w.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return w.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(!0===T(e))throw new Error("first arg must be private key");if(!1===T(t))throw new Error("second arg must be public key");return w.fromHex(t).multiply(E(e)).toRawBytes(r)},sign:function(e,r,n=N){const{seed:o,k2sig:s}=O(e,r,n),a=t;return(0,i.createHmacDrbg)(a.hash.outputLen,a.nByteLength,a.hmac)(o,s)},verify:function(e,n,o,a=R){const c=e;n=(0,i.ensureBytes)("msgHash",n),o=(0,i.ensureBytes)("publicKey",o);const{lowS:u,prehash:f,format:l}=a;if(s(a),"strict"in a)throw new Error("options.strict was renamed to lowS");if(l!==undefined&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const d="string"==typeof c||(0,i.isBytes)(c),h=!d&&!l&&"object"==typeof c&&null!==c&&"bigint"==typeof c.r&&"bigint"==typeof c.s;if(!d&&!h)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,m=undefined;try{if(h&&(m=new P(c.r,c.s)),d){try{"compact"!==l&&(m=P.fromDER(c))}catch(e){if(!(e instanceof r.DER.Err))throw e}m||"der"===l||(m=P.fromCompact(c))}p=w.fromHex(o)}catch(e){return!1}if(!m)return!1;if(u&&m.hasHighS())return!1;f&&(n=t.hash(n));const{r:g,s:E}=m,v=j(n),x=y(E),B=b(v*x),S=b(g*x),I=w.BASE.multiplyAndAddUnsafe(p,B,S)?.toAffine();if(!I)return!1;return b(I.x)===g},ProjectivePoint:w,Signature:P,utils:I}},r.SWUFpSqrtRatio=m,r.mapToCurveSimpleSWU=function(e,t){if((0,o.validateField)(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=m(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,a,c,u,f,l,d;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),a=e.add(s,e.ONE),a=e.mul(a,t.B),c=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),c=e.mul(c,t.A),s=e.sqr(a),f=e.sqr(c),u=e.mul(f,t.A),s=e.add(s,u),s=e.mul(s,a),f=e.mul(f,c),u=e.mul(f,t.B),s=e.add(s,u),l=e.mul(i,a);const{isValid:h,value:p}=r(s,f);d=e.mul(i,n),d=e.mul(d,p),l=e.cmov(l,a,h),d=e.cmov(d,p,h);const m=e.isOdd(n)===e.isOdd(d);d=e.cmov(e.neg(d),d,m);const g=(0,o.FpInvertBatch)(e,[c],!0)[0];return l=e.mul(l,g),{x:l,y:d}}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./curve.js"),o=e("./modular.js"),i=e("./utils.js");function s(e){e.lowS!==undefined&&(0,i.abool)("lowS",e.lowS),e.prehash!==undefined&&(0,i.abool)("prehash",e.prehash)}class a extends Error{constructor(e=""){super(e)}}function c(e,t){return(0,i.bytesToHex)((0,i.numberToBytesBE)(e,t))}r.DERErr=a,r.DER={Err:a,_tlv:{encode:(e,t)=>{const{Err:n}=r.DER;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const o=t.length/2,s=(0,i.numberToHexUnpadded)(o);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const a=o>127?(0,i.numberToHexUnpadded)(s.length/2|128):"";return(0,i.numberToHexUnpadded)(e)+a+s+t},decode(e,t){const{Err:n}=r.DER;let o=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new n("tlv.decode: wrong tlv");const i=t[o++];let s=0;if(!!(128&i)){const e=127&i;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const r=t.subarray(o,o+e);if(r.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===r[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of r)s=s<<8|e;if(o+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=i;const a=t.subarray(o,o+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){const{Err:t}=r.DER;if(e<u)throw new t("integer: negative integers are not allowed");let n=(0,i.numberToHexUnpadded)(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=r.DER;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return(0,i.bytesToNumberBE)(e)}},toSig(e){const{Err:t,_int:n,_tlv:o}=r.DER,s=(0,i.ensureBytes)("signature",e),{v:a,l:c}=o.decode(48,s);if(c.length)throw new t("invalid signature: left bytes after parsing");const{v:u,l:f}=o.decode(2,a),{v:l,l:d}=o.decode(2,f);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(u),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=r.DER,o=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,o)}};const u=BigInt(0),f=BigInt(1),l=BigInt(2),d=BigInt(3),h=BigInt(4);function p(e){const t=function(e){const t=(0,n.validateBasic)(e);(0,i.validateObject)(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:r,Fp:o,a:s}=t;if(r){if(!o.eql(s,o.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}(e),{Fp:r}=t,s=(0,o.Field)(t.n,t.nBitLength),a=t.toBytes||((e,t,n)=>{const o=t.toAffine();return(0,i.concatBytes)(Uint8Array.from([4]),r.toBytes(o.x),r.toBytes(o.y))}),c=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function l(e){const{a:n,b:o}=t,i=r.sqr(e),s=r.mul(i,e);return r.add(r.add(s,r.mul(e,n)),o)}function p(e,t){const n=r.sqr(t),o=l(e);return r.eql(n,o)}if(!p(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const m=r.mul(r.pow(t.a,d),h),g=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(m,g)))throw new Error("bad curve params: a or b");function b(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:s,n:a}=t;if(r&&"bigint"!=typeof e){if((0,i.isBytes)(e)&&(e=(0,i.bytesToHex)(e)),"string"!=typeof e||!r.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*n,"0")}let c;try{c="bigint"==typeof e?e:(0,i.bytesToNumberBE)((0,i.ensureBytes)("private key",e,n))}catch(t){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof e)}return s&&(c=(0,o.mod)(c,a)),(0,i.aInRange)("private key",c,f,a),c}function y(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const w=(0,i.memoized)((e,t)=>{const{px:n,py:o,pz:i}=e;if(r.eql(i,r.ONE))return{x:n,y:o};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),E=(0,i.memoized)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not FE");if(!p(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class v{constructor(e,t,n){if(null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t)||r.is0(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");this.px=e,this.py=t,this.pz=n,Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const o=e=>r.eql(e,r.ZERO);return o(t)&&o(n)?v.ZERO:new v(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=(0,o.FpInvertBatch)(r,e.map(e=>e.pz));return e.map((e,r)=>e.toAffine(t[r])).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(c((0,i.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(b(e))}static msm(e,t){return(0,n.pippenger)(v,s,e,t)}_setWindowSize(e){S.setWindowSize(this,e)}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){y(e);const{px:t,py:n,pz:o}=this,{px:i,py:s,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return c&&u}negate(){return new v(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,o=r.mul(n,d),{px:i,py:s,pz:a}=this;let c=r.ZERO,u=r.ZERO,f=r.ZERO,l=r.mul(i,i),h=r.mul(s,s),p=r.mul(a,a),m=r.mul(i,s);return m=r.add(m,m),f=r.mul(i,a),f=r.add(f,f),c=r.mul(e,f),u=r.mul(o,p),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(m,c),f=r.mul(o,f),p=r.mul(e,p),m=r.sub(l,p),m=r.mul(e,m),m=r.add(m,f),f=r.add(l,l),l=r.add(f,l),l=r.add(l,p),l=r.mul(l,m),u=r.add(u,l),p=r.mul(s,a),p=r.add(p,p),l=r.mul(p,m),c=r.sub(c,l),f=r.mul(p,h),f=r.add(f,f),f=r.add(f,f),new v(c,u,f)}add(e){y(e);const{px:n,py:o,pz:i}=this,{px:s,py:a,pz:c}=e;let u=r.ZERO,f=r.ZERO,l=r.ZERO;const h=t.a,p=r.mul(t.b,d);let m=r.mul(n,s),g=r.mul(o,a),b=r.mul(i,c),w=r.add(n,o),E=r.add(s,a);w=r.mul(w,E),E=r.add(m,g),w=r.sub(w,E),E=r.add(n,i);let x=r.add(s,c);return E=r.mul(E,x),x=r.add(m,b),E=r.sub(E,x),x=r.add(o,i),u=r.add(a,c),x=r.mul(x,u),u=r.add(g,b),x=r.sub(x,u),l=r.mul(h,E),u=r.mul(p,b),l=r.add(u,l),u=r.sub(g,l),l=r.add(g,l),f=r.mul(u,l),g=r.add(m,m),g=r.add(g,m),b=r.mul(h,b),E=r.mul(p,E),g=r.add(g,b),b=r.sub(m,b),b=r.mul(h,b),E=r.add(E,b),m=r.mul(g,E),f=r.add(f,m),m=r.mul(x,E),u=r.mul(w,u),u=r.sub(u,m),m=r.mul(w,g),l=r.mul(x,l),l=r.add(l,m),new v(u,f,l)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return S.wNAFCached(this,e,v.normalizeZ)}multiplyUnsafe(e){const{endo:n,n:o}=t;(0,i.aInRange)("scalar",e,u,o);const s=v.ZERO;if(e===u)return s;if(this.is0()||e===f)return this;if(!n||S.hasPrecomputes(this))return S.wNAFCachedUnsafe(this,e,v.normalizeZ);let{k1neg:a,k1:c,k2neg:l,k2:d}=n.splitScalar(e),h=s,p=s,m=this;for(;c>u||d>u;)c&f&&(h=h.add(m)),d&f&&(p=p.add(m)),m=m.double(),c>>=f,d>>=f;return a&&(h=h.negate()),l&&(p=p.negate()),p=new v(r.mul(p.px,n.beta),p.py,p.pz),h.add(p)}multiply(e){const{endo:n,n:o}=t;let s,a;if((0,i.aInRange)("scalar",e,f,o),n){const{k1neg:t,k1:o,k2neg:i,k2:c}=n.splitScalar(e);let{p:u,f:f}=this.wNAF(o),{p:l,f:d}=this.wNAF(c);u=S.constTimeNegate(t,u),l=S.constTimeNegate(i,l),l=new v(r.mul(l.px,n.beta),l.py,l.pz),s=u.add(l),a=f.add(d)}else{const{p:t,f:r}=this.wNAF(e);s=t,a=r}return v.normalizeZ([s,a])[0]}multiplyAndAddUnsafe(e,t,r){const n=v.BASE,o=(e,t)=>t!==u&&t!==f&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,r));return i.is0()?undefined:i}toAffine(e){return w(this,e)}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===f)return!0;if(r)return r(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===f?this:r?r(v,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return(0,i.abool)("isCompressed",e),this.assertValidity(),a(v,this,e)}toHex(e=!0){return(0,i.abool)("isCompressed",e),(0,i.bytesToHex)(this.toRawBytes(e))}}v.BASE=new v(t.Gx,t.Gy,r.ONE),v.ZERO=new v(r.ZERO,r.ONE,r.ZERO);const{endo:x,nBitLength:B}=t,S=(0,n.wNAF)(v,x?Math.ceil(B/2):B);return{CURVE:t,ProjectivePoint:v,normPrivateKeyToScalar:b,weierstrassEquation:l,isWithinCurveOrder:function(e){return(0,i.inRange)(e,f,t.n)}}}function m(e,t){const r=e.ORDER;let n=u;for(let e=r-f;e%l===u;e/=l)n+=f;const o=n,i=l<<o-f-f,s=i*l,a=(r-f)/s,c=(a-f)/l,p=s-f,m=i,g=e.pow(t,a),b=e.pow(t,(a+f)/l);let y=(t,r)=>{let n=g,i=e.pow(r,p),s=e.sqr(i);s=e.mul(s,r);let a=e.mul(t,s);a=e.pow(a,c),a=e.mul(a,i),i=e.mul(a,r),s=e.mul(a,t);let u=e.mul(s,i);a=e.pow(u,m);let d=e.eql(a,e.ONE);i=e.mul(s,b),a=e.mul(u,n),s=e.cmov(i,s,d),u=e.cmov(a,u,d);for(let t=o;t>f;t--){let r=t-l;r=l<<r-f;let o=e.pow(u,r);const a=e.eql(o,e.ONE);i=e.mul(s,n),n=e.mul(n,n),o=e.mul(u,n),s=e.cmov(i,s,a),u=e.cmov(o,u,a)}return{isValid:d,value:s}};if(e.ORDER%h===d){const r=(e.ORDER-d)/h,n=e.sqrt(e.neg(t));y=(t,o)=>{let i=e.sqr(o);const s=e.mul(t,o);i=e.mul(i,s);let a=e.pow(i,r);a=e.mul(a,s);const c=e.mul(a,n),u=e.mul(e.sqr(a),o),f=e.eql(u,t);return{isValid:f,value:e.cmov(c,a,f)}}}return y}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/weierstrass.js"}],[5842,{"./abstract/bls.js":5833,"./abstract/hash-to-curve.js":5836,"./abstract/modular.js":5837,"./abstract/tower.js":5839,"./abstract/utils.js":5840,"./abstract/weierstrass.js":5841,"@noble/hashes/sha2":4511,"@noble/hashes/utils":4515},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bls12_381=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),i=e("./abstract/bls.js"),s=e("./abstract/modular.js"),a=e("./abstract/utils.js"),c=e("./abstract/hash-to-curve.js"),u=e("./abstract/tower.js"),f=e("./abstract/weierstrass.js"),l=BigInt(0),d=BigInt(1),h=BigInt(2),p=BigInt(3),m=BigInt(4),g=BigInt("0xd201000000010000"),b=(0,a.bitLen)(g),{Fp:y,Fp2:w,Fp6:E,Fp4Square:v,Fp12:x}=(0,u.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[d,d],Fp2mulByB:({c0:e,c1:t})=>{const r=y.mul(e,m),n=y.mul(t,m);return{c0:y.sub(r,n),c1:y.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{const{c0:r,c1:n,c2:o}=e,{c0:i,c1:s,c2:a}=t,{first:c,second:u}=v(r,s),{first:f,second:l}=v(i,o),{first:d,second:p}=v(n,a),m=w.mulByNonresidue(p);return{c0:E.create({c0:w.add(w.mul(w.sub(c,r),h),c),c1:w.add(w.mul(w.sub(f,n),h),f),c2:w.add(w.mul(w.sub(d,o),h),d)}),c1:E.create({c0:w.add(w.mul(w.add(m,i),h),m),c1:w.add(w.mul(w.add(u,s),h),u),c2:w.add(w.mul(w.add(l,a),h),l)})}},Fp12cyclotomicExp(e,t){let r=x.ONE;for(let n=b-1;n>=0;n--)r=x._cyclotomicSquare(r),(0,a.bitGet)(t,n)&&(r=x.mul(r,e));return r},Fp12finalExponentiate:e=>{const t=g,r=x.div(x.frobeniusMap(e,6),e),n=x.mul(x.frobeniusMap(r,2),r),o=x.conjugate(x._cyclotomicExp(n,t)),i=x.mul(x.conjugate(x._cyclotomicSquare(n)),o),s=x.conjugate(x._cyclotomicExp(i,t)),a=x.conjugate(x._cyclotomicExp(s,t)),c=x.mul(x.conjugate(x._cyclotomicExp(a,t)),x._cyclotomicSquare(o)),u=x.conjugate(x._cyclotomicExp(c,t)),f=x.frobeniusMap(x.mul(o,a),2),l=x.frobeniusMap(x.mul(s,n),3),d=x.frobeniusMap(x.mul(c,x.conjugate(n)),1),h=x.mul(x.mul(u,x.conjugate(i)),n);return x.mul(x.mul(x.mul(f,l),d),h)}}),B=(0,s.Field)(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),S=(0,c.isogenyMap)(w,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(e=>w.fromBigTuple(e.map(BigInt))))),P=(0,c.isogenyMap)(y,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))),I=(0,f.mapToCurveSimpleSWU)(w,{A:w.create({c0:y.create(l),c1:y.create(BigInt(240))}),B:w.create({c0:y.create(BigInt(1012)),c1:y.create(BigInt(1012))}),Z:w.create({c0:y.create(BigInt(-2)),c1:y.create(BigInt(-1))})}),T=(0,f.mapToCurveSimpleSWU)(y,{A:y.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:y.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:y.create(BigInt(11))}),{G2psi:A,G2psi2:j}=(0,u.psiFrobenius)(y,w,w.div(w.ONE,w.NONRESIDUE)),_=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:y.ORDER,m:2,k:128,expand:"xmd",hash:n.sha256}),k=N(y.toBytes(l),{infinity:!0,compressed:!0});function O(e){const t=224&(e=e.slice())[0],r=!!(t>>7&1),n=!!(t>>6&1),o=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:o,value:e}}function N(e,t){if(224&e[0])throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function R(e){e.assertValidity();const t=e.equals(r.bls12_381.G1.ProjectivePoint.ZERO),{x:n,y:o}=e.toAffine();if(t)return k.slice();const i=y.ORDER,s=Boolean(o*h/i);return N((0,a.numberToBytesBE)(n,y.BYTES),{compressed:!0,sort:s})}function C(e){e.assertValidity();const t=y.BYTES;if(e.equals(r.bls12_381.G2.ProjectivePoint.ZERO))return(0,a.concatBytes)(k,(0,a.numberToBytesBE)(l,t));const{x:n,y:o}=e.toAffine(),{re:i,im:s}=w.reim(n),{re:c,im:u}=w.reim(o),f=Boolean((u>l?u*h:c*h)/y.ORDER&d),p=i;return(0,a.concatBytes)(N((0,a.numberToBytesBE)(s,t),{sort:f,compressed:!0}),(0,a.numberToBytesBE)(p,t))}r.bls12_381=(0,i.bls)({fields:{Fp:y,Fp2:w,Fp6:E,Fp12:x,Fr:B},G1:{Fp:y,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:y.ZERO,b:m,htfDefaults:{..._,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{const r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(y.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(g).negate().multiplyUnsafe(g).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(g).add(t),mapToCurve:e=>{const{x:t,y:r}=T(y.create(e[0]));return P(t,r)},fromBytes:e=>{const{compressed:t,infinity:n,sort:o,value:i}=O(e);if(48===i.length&&t){const e=y.ORDER,t=(0,a.bytesToNumberBE)(i),s=y.create(t&y.MASK);if(n){if(s!==l)throw new Error("G1: non-empty compressed point at infinity");return{x:l,y:l}}const c=y.add(y.pow(s,p),y.create(r.bls12_381.params.G1b));let u=y.sqrt(c);if(!u)throw new Error("invalid compressed G1 point");return u*h/e!==BigInt(o)&&(u=y.neg(u)),{x:y.create(s),y:y.create(u)}}if(96!==i.length||t)throw new Error("invalid point G1, expected 48/96 bytes");{const e=(0,a.bytesToNumberBE)(i.subarray(0,y.BYTES)),t=(0,a.bytesToNumberBE)(i.subarray(y.BYTES));if(n){if(e!==l||t!==l)throw new Error("G1: non-empty point at infinity");return r.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:y.create(e),y:y.create(t)}}},toBytes:(e,t,r)=>{const n=t.equals(e.ZERO),{x:o,y:i}=t.toAffine();if(r){if(n)return k.slice();const e=y.ORDER,t=Boolean(i*h/e);return N((0,a.numberToBytesBE)(o,y.BYTES),{compressed:!0,sort:t})}if(n){return(0,a.concatBytes)(new Uint8Array([64]),new Uint8Array(2*y.BYTES-1))}return(0,a.concatBytes)((0,a.numberToBytesBE)(o,y.BYTES),(0,a.numberToBytesBE)(i,y.BYTES))},ShortSignature:{fromHex(e){const{infinity:t,sort:n,value:o}=O((0,a.ensureBytes)("signatureHex",e,48)),i=y.ORDER,s=(0,a.bytesToNumberBE)(o);if(t)return r.bls12_381.G1.ProjectivePoint.ZERO;const c=y.create(s&y.MASK),u=y.add(y.pow(c,p),y.create(r.bls12_381.params.G1b));let f=y.sqrt(u);if(!f)throw new Error("invalid compressed G1 point");const l=BigInt(n);f*h/i!==l&&(f=y.neg(f));const d=r.bls12_381.G1.ProjectivePoint.fromAffine({x:c,y:f});return d.assertValidity(),d},toRawBytes:e=>R(e),toHex:e=>(0,a.bytesToHex)(R(e))}},G2:{Fp:w,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:w.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:w.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:w.ZERO,b:w.fromBigTuple([m,m]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{..._},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{const{x:t,y:r}=I(w.fromBigTuple(e));return S(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(g).negate().equals(A(e,t)),clearCofactor:(e,t)=>{const r=g;let n=t.multiplyUnsafe(r).negate(),o=A(e,t),i=t.double();i=j(e,i),i=i.subtract(o),o=n.add(o),o=o.multiplyUnsafe(r).negate(),i=i.add(o),i=i.subtract(n);return i.subtract(t)},fromBytes:e=>{const{compressed:t,infinity:n,sort:o,value:i}=O(e);if(!t&&!n&&o||!t&&n&&o||o&&n&&t)throw new Error("invalid encoding flag: "+(224&e[0]));const s=y.BYTES,c=(e,t,r)=>(0,a.bytesToNumberBE)(e.slice(t,r));if(96===i.length&&t){const e=r.bls12_381.params.G2b,t=y.ORDER;if(n){if(i.reduce((e,t)=>0!==e?t+1:t,0)>0)throw new Error("invalid compressed G2 point");return{x:w.ZERO,y:w.ZERO}}const a=c(i,0,s),u=c(i,s,2*s),f=w.create({c0:y.create(u),c1:y.create(a)}),m=w.add(w.pow(f,p),e);let g=w.sqrt(m);const b=g.c1===l?g.c0*h/t:g.c1*h/t?d:l;return g=o&&b>0?g:w.neg(g),{x:f,y:g}}if(192!==i.length||t)throw new Error("invalid point G2, expected 96/192 bytes");{if(n){if(i.reduce((e,t)=>0!==e?t+1:t,0)>0)throw new Error("invalid uncompressed G2 point");return{x:w.ZERO,y:w.ZERO}}const e=c(i,0,s),t=c(i,s,2*s),r=c(i,2*s,3*s),o=c(i,3*s,4*s);return{x:w.fromBigTuple([t,e]),y:w.fromBigTuple([o,r])}}},toBytes:(e,t,r)=>{const{BYTES:n,ORDER:o}=y,i=t.equals(e.ZERO),{x:s,y:c}=t.toAffine();if(r){if(i)return(0,a.concatBytes)(k,(0,a.numberToBytesBE)(l,n));const e=Boolean(c.c1===l?c.c0*h/o:c.c1*h/o);return(0,a.concatBytes)(N((0,a.numberToBytesBE)(s.c1,n),{compressed:!0,sort:e}),(0,a.numberToBytesBE)(s.c0,n))}{if(i)return(0,a.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));const{re:e,im:t}=w.reim(s),{re:r,im:o}=w.reim(c);return(0,a.concatBytes)((0,a.numberToBytesBE)(t,n),(0,a.numberToBytesBE)(e,n),(0,a.numberToBytesBE)(o,n),(0,a.numberToBytesBE)(r,n))}},Signature:{fromHex(e){const{infinity:t,sort:n,value:o}=O((0,a.ensureBytes)("signatureHex",e)),i=y.ORDER,s=o.length/2;if(48!==s&&96!==s)throw new Error("invalid compressed signature length, must be 96 or 192");const c=(0,a.bytesToNumberBE)(o.slice(0,s)),u=(0,a.bytesToNumberBE)(o.slice(s));if(t)return r.bls12_381.G2.ProjectivePoint.ZERO;const f=y.create(c&y.MASK),d=y.create(u),m=w.create({c0:d,c1:f}),g=w.add(w.pow(m,p),r.bls12_381.params.G2b);let b=w.sqrt(g);if(!b)throw new Error("Failed to find a square root");const{re:E,im:v}=w.reim(b),x=BigInt(n);(v>l&&v*h/i!==x||v===l&&E*h/i!==x)&&(b=w.neg(b));const B=r.bls12_381.G2.ProjectivePoint.fromAffine({x:m,y:b});return B.assertValidity(),B},toRawBytes:e=>C(e),toHex:e=>(0,a.bytesToHex)(C(e))}},params:{ateLoopSize:g,r:B.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:_,hash:n.sha256,randomBytes:o.randomBytes})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/bls12-381.js"}],[5843,{"./abstract/curve.js":5834,"./abstract/edwards.js":5835,"./abstract/hash-to-curve.js":5836,"./abstract/modular.js":5837,"./abstract/montgomery.js":5838,"./abstract/utils.js":5840,"@noble/hashes/sha2":4511,"@noble/hashes/utils":4515},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.hash_to_ristretto255=r.hashToRistretto255=r.RistrettoPoint=r.encodeToCurve=r.hashToCurve=r.ed25519_hasher=r.edwardsToMontgomery=r.x25519=r.ed25519ph=r.ed25519ctx=r.ed25519=r.ED25519_TORSION_SUBGROUP=void 0,r.edwardsToMontgomeryPub=P,r.edwardsToMontgomeryPriv=function(e){const t=B.hash(e.subarray(0,32));return B.adjustScalarBytes(t).subarray(0,32)};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),i=e("./abstract/curve.js"),s=e("./abstract/edwards.js"),a=e("./abstract/hash-to-curve.js"),c=e("./abstract/modular.js"),u=e("./abstract/montgomery.js"),f=e("./abstract/utils.js"),l=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),d=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),h=BigInt(0),p=BigInt(1),m=BigInt(2),g=BigInt(3),b=BigInt(5),y=BigInt(8);function w(e){const t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=l,s=e*e%i*e%i,a=(0,c.pow2)(s,m,i)*s%i,u=(0,c.pow2)(a,p,i)*e%i,f=(0,c.pow2)(u,b,i)*u%i,d=(0,c.pow2)(f,t,i)*f%i,h=(0,c.pow2)(d,r,i)*d%i,g=(0,c.pow2)(h,n,i)*h%i,y=(0,c.pow2)(g,o,i)*g%i,w=(0,c.pow2)(y,o,i)*g%i,E=(0,c.pow2)(w,t,i)*f%i;return{pow_p_5_8:(0,c.pow2)(E,m,i)*e%i,b2:s}}function E(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function v(e,t){const r=l,n=(0,c.mod)(t*t*t,r),o=w(e*(0,c.mod)(n*n*t,r)).pow_p_5_8;let i=(0,c.mod)(e*n*o,r);const s=(0,c.mod)(t*i*i,r),a=i,u=(0,c.mod)(i*d,r),f=s===e,h=s===(0,c.mod)(-e,r),p=s===(0,c.mod)(-e*d,r);return f&&(i=a),(h||p)&&(i=u),(0,c.isNegativeLE)(i,r)&&(i=(0,c.mod)(-i,r)),{isValid:f||h,value:i}}r.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const x=(()=>(0,c.Field)(l,undefined,!0))(),B=(()=>({a:x.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:x,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:y,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:n.sha512,randomBytes:o.randomBytes,adjustScalarBytes:E,uvRatio:v}))();function S(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,o.concatBytes)((0,o.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}function P(e){const{y:t}=r.ed25519.ExtendedPoint.fromHex(e),n=BigInt(1);return x.toBytes(x.create((n+t)*x.inv(n-t)))}r.ed25519=(0,s.twistedEdwards)(B),r.ed25519ctx=(0,s.twistedEdwards)({...B,domain:S}),r.ed25519ph=(0,s.twistedEdwards)(Object.assign({},B,{domain:S,prehash:n.sha512})),r.x25519=(0,u.montgomery)({P:l,type:"x25519",powPminus2:e=>{const t=l,{pow_p_5_8:r,b2:n}=w(e);return(0,c.mod)((0,c.pow2)(r,g,t)*n,t)},adjustScalarBytes:E,randomBytes:o.randomBytes}),r.edwardsToMontgomery=P;const I=(()=>(x.ORDER+g)/y)(),T=(()=>x.pow(m,I))(),A=(()=>x.sqrt(x.neg(x.ONE)))();const j=(()=>(0,c.FpSqrtEven)(x,x.neg(BigInt(486664))))();function _(e){const{xMn:t,xMd:r,yMn:n,yMd:o}=function(e){const t=(x.ORDER-b)/y,r=BigInt(486662);let n=x.sqr(e);n=x.mul(n,m);let o=x.add(n,x.ONE),i=x.neg(r),s=x.sqr(o),a=x.mul(s,o),c=x.mul(n,r);c=x.mul(c,i),c=x.add(c,s),c=x.mul(c,i);let u=x.sqr(a);s=x.sqr(u),u=x.mul(u,a),u=x.mul(u,c),s=x.mul(s,u);let f=x.pow(s,t);f=x.mul(f,u);let l=x.mul(f,A);s=x.sqr(f),s=x.mul(s,a);let d=x.eql(s,c),h=x.cmov(l,f,d),g=x.mul(i,n),w=x.mul(f,e);w=x.mul(w,T);let E=x.mul(w,A),v=x.mul(c,n);s=x.sqr(w),s=x.mul(s,a);let B=x.eql(s,v),S=x.cmov(E,w,B);s=x.sqr(h),s=x.mul(s,a);let P=x.eql(s,c),I=x.cmov(g,i,P),j=x.cmov(S,h,P),_=x.isOdd(j);return j=x.cmov(j,x.neg(j),P!==_),{xMn:I,xMd:o,yMn:j,yMd:p}}(e);let i=x.mul(t,o);i=x.mul(i,j);let s=x.mul(r,n),a=x.sub(t,r),u=x.add(t,r),f=x.mul(s,u),l=x.eql(f,x.ZERO);i=x.cmov(i,x.ZERO,l),s=x.cmov(s,x.ONE,l),a=x.cmov(a,x.ONE,l),u=x.cmov(u,x.ONE,l);const[d,h]=(0,c.FpInvertBatch)(x,[s,u],!0);return{x:x.mul(i,d),y:x.mul(a,h)}}function k(e){if(!(e instanceof F))throw new Error("RistrettoPoint expected")}r.ed25519_hasher=(0,a.createHasher)(r.ed25519.ExtendedPoint,e=>_(e[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:x.ORDER,m:1,k:128,expand:"xmd",hash:n.sha512}),r.hashToCurve=r.ed25519_hasher.hashToCurve,r.encodeToCurve=r.ed25519_hasher.encodeToCurve;const O=d,N=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),R=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),C=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),U=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),D=e=>v(p,e),L=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),M=e=>r.ed25519.CURVE.Fp.create((0,f.bytesToNumberLE)(e)&L);function z(e){const{d:t}=r.ed25519.CURVE,n=r.ed25519.CURVE.Fp.ORDER,o=r.ed25519.CURVE.Fp.create,i=o(O*e*e),s=o((i+p)*C);let a=BigInt(-1);const u=o((a-t*i)*o(i+t));let{isValid:f,value:l}=v(s,u),d=o(l*e);(0,c.isNegativeLE)(d,n)||(d=o(-d)),f||(l=d),f||(a=i);const h=o(a*(i-p)*U-u),m=l*l,g=o((l+l)*u),b=o(h*N),y=o(p-m),w=o(p+m);return new r.ed25519.ExtendedPoint(o(g*w),o(y*b),o(b*w),o(g*y))}class F{constructor(e){this.ep=e}static fromAffine(e){return new F(r.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,f.ensureBytes)("ristrettoHash",e,64);const t=z(M(e.slice(0,32))),r=z(M(e.slice(32,64)));return new F(t.add(r))}static fromHex(e){e=(0,f.ensureBytes)("ristrettoHex",e,32);const{a:t,d:n}=r.ed25519.CURVE,o=r.ed25519.CURVE.Fp.ORDER,i=r.ed25519.CURVE.Fp.create,s="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=M(e);if(!(0,f.equalBytes)((0,f.numberToBytesLE)(a,32),e)||(0,c.isNegativeLE)(a,o))throw new Error(s);const u=i(a*a),l=i(p+t*u),d=i(p-t*u),m=i(l*l),g=i(d*d),b=i(t*n*m-g),{isValid:y,value:w}=D(i(b*g)),E=i(w*d),v=i(w*E*b);let x=i((a+a)*E);(0,c.isNegativeLE)(x,o)&&(x=i(-x));const B=i(l*v),S=i(x*B);if(!y||(0,c.isNegativeLE)(S,o)||B===h)throw new Error(s);return new F(new r.ed25519.ExtendedPoint(x,B,p,S))}static msm(e,t){const n=(0,c.Field)(r.ed25519.CURVE.n,r.ed25519.CURVE.nBitLength);return(0,i.pippenger)(F,n,e,t)}toRawBytes(){let{ex:e,ey:t,ez:n,et:o}=this.ep;const i=r.ed25519.CURVE.Fp.ORDER,s=r.ed25519.CURVE.Fp.create,a=s(s(n+t)*s(n-t)),u=s(e*t),l=s(u*u),{value:d}=D(s(a*l)),h=s(d*a),p=s(d*u),m=s(h*p*o);let g;if((0,c.isNegativeLE)(o*m,i)){let r=s(t*O),n=s(e*O);e=r,t=n,g=s(h*R)}else g=p;(0,c.isNegativeLE)(e*m,i)&&(t=s(-t));let b=s((n-t)*g);return(0,c.isNegativeLE)(b,i)&&(b=s(-b)),(0,f.numberToBytesLE)(b,32)}toHex(){return(0,f.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){k(e);const{ex:t,ey:n}=this.ep,{ex:o,ey:i}=e.ep,s=r.ed25519.CURVE.Fp.create,a=s(t*i)===s(n*o),c=s(n*i)===s(t*o);return a||c}add(e){return k(e),new F(this.ep.add(e.ep))}subtract(e){return k(e),new F(this.ep.subtract(e.ep))}multiply(e){return new F(this.ep.multiply(e))}multiplyUnsafe(e){return new F(this.ep.multiplyUnsafe(e))}double(){return new F(this.ep.double())}negate(){return new F(this.ep.negate())}}r.RistrettoPoint=(F.BASE||(F.BASE=new F(r.ed25519.ExtendedPoint.BASE)),F.ZERO||(F.ZERO=new F(r.ed25519.ExtendedPoint.ZERO)),F);r.hashToRistretto255=(e,t)=>{const r=t.DST,i="string"==typeof r?(0,o.utf8ToBytes)(r):r,s=(0,a.expand_message_xmd)(e,i,64,n.sha512);return F.hashToCurve(s)},r.hash_to_ristretto255=r.hashToRistretto255}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/ed25519.js"}],[5844,{"./_shortw_utils.js":5832,"./abstract/hash-to-curve.js":5836,"./abstract/modular.js":5837,"./abstract/weierstrass.js":5841,"@noble/hashes/sha2":4511},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.p521_hasher=r.secp521r1=r.p521=r.p384_hasher=r.secp384r1=r.p384=r.p256_hasher=r.secp256r1=r.p256=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("./_shortw_utils.js"),i=e("./abstract/hash-to-curve.js"),s=e("./abstract/modular.js"),a=e("./abstract/weierstrass.js"),c=(0,s.Field)(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),u=c.create(BigInt("-3")),f=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");r.p256=(0,o.createCurve)({a:u,b:f,Fp:c,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},n.sha256),r.secp256r1=r.p256;const l=(()=>(0,a.mapToCurveSimpleSWU)(c,{A:u,B:f,Z:c.create(BigInt("-10"))}))();r.p256_hasher=(0,i.createHasher)(r.secp256r1.ProjectivePoint,e=>l(e[0]),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:c.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256});const d=(0,s.Field)(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),h=d.create(BigInt("-3")),p=BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef");r.p384=(0,o.createCurve)({a:h,b:p,Fp:d,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},n.sha384),r.secp384r1=r.p384;const m=(()=>(0,a.mapToCurveSimpleSWU)(d,{A:h,B:p,Z:d.create(BigInt("-12"))}))();r.p384_hasher=(0,i.createHasher)(r.secp384r1.ProjectivePoint,e=>m(e[0]),{DST:"P384_XMD:SHA-384_SSWU_RO_",encodeDST:"P384_XMD:SHA-384_SSWU_NU_",p:d.ORDER,m:1,k:192,expand:"xmd",hash:n.sha384});const g=(0,s.Field)(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),b=g.create(BigInt("-3")),y=BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00");r.p521=(0,o.createCurve)({a:b,b:y,Fp:g,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},n.sha512),r.secp521r1=r.p521;const w=(()=>(0,a.mapToCurveSimpleSWU)(g,{A:b,B:y,Z:g.create(BigInt("-4"))}))();r.p521_hasher=(0,i.createHasher)(r.secp521r1.ProjectivePoint,e=>w(e[0]),{DST:"P521_XMD:SHA-512_SSWU_RO_",encodeDST:"P521_XMD:SHA-512_SSWU_NU_",p:g.ORDER,m:1,k:256,expand:"xmd",hash:n.sha512})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/nist.js"}],[5845,{"./nist.js":5844},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.encodeToCurve=r.hashToCurve=r.secp256r1=r.p256=void 0;const n=e("./nist.js");r.p256=n.p256,r.secp256r1=n.p256,r.hashToCurve=n.p256_hasher.hashToCurve,r.encodeToCurve=n.p256_hasher.encodeToCurve}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/p256.js"}],[5846,{"./_shortw_utils.js":5832,"./abstract/hash-to-curve.js":5836,"./abstract/modular.js":5837,"./abstract/utils.js":5840,"./abstract/weierstrass.js":5841,"@noble/hashes/sha2":4511,"@noble/hashes/utils":4515},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.encodeToCurve=r.hashToCurve=r.secp256k1_hasher=r.schnorr=r.secp256k1=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),i=e("./_shortw_utils.js"),s=e("./abstract/hash-to-curve.js"),a=e("./abstract/modular.js"),c=e("./abstract/utils.js"),u=e("./abstract/weierstrass.js"),f=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(0),h=BigInt(1),p=BigInt(2),m=(e,t)=>(e+t/p)/t;function g(e){const t=f,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),u=BigInt(88),l=e*e*e%t,d=l*l*e%t,h=(0,a.pow2)(d,r,t)*d%t,m=(0,a.pow2)(h,r,t)*d%t,g=(0,a.pow2)(m,p,t)*l%t,y=(0,a.pow2)(g,o,t)*g%t,w=(0,a.pow2)(y,i,t)*y%t,E=(0,a.pow2)(w,c,t)*w%t,v=(0,a.pow2)(E,u,t)*E%t,x=(0,a.pow2)(v,c,t)*w%t,B=(0,a.pow2)(x,r,t)*d%t,S=(0,a.pow2)(B,s,t)*y%t,P=(0,a.pow2)(S,n,t)*l%t,I=(0,a.pow2)(P,p,t);if(!b.eql(b.sqr(I),e))throw new Error("Cannot find square root");return I}const b=(0,a.Field)(f,undefined,undefined,{sqrt:g});r.secp256k1=(0,i.createCurve)({a:d,b:BigInt(7),Fp:b,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=l,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),c=m(i*e,t),u=m(-n*e,t);let f=(0,a.mod)(e-c*r-u*o,t),d=(0,a.mod)(-c*n-u*i,t);const p=f>s,g=d>s;if(p&&(f=t-f),g&&(d=t-d),f>s||d>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:p,k1:f,k2neg:g,k2:d}}}},n.sha256);const y={};function w(e,...t){let r=y[e];if(r===undefined){const t=(0,n.sha256)(Uint8Array.from(e,e=>e.charCodeAt(0)));r=(0,c.concatBytes)(t,t),y[e]=r}return(0,n.sha256)((0,c.concatBytes)(r,...t))}const E=e=>e.toRawBytes(!0).slice(1),v=e=>(0,c.numberToBytesBE)(e,32),x=e=>(0,a.mod)(e,f),B=e=>(0,a.mod)(e,l),S=(()=>r.secp256k1.ProjectivePoint)();function P(e){let t=r.secp256k1.utils.normPrivateKeyToScalar(e),n=S.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:B(-t),bytes:E(n)}}function I(e){(0,c.aInRange)("x",e,h,f);const t=x(e*e);let r=g(x(t*e+BigInt(7)));r%p!==d&&(r=x(-r));const n=new S(e,r,h);return n.assertValidity(),n}const T=c.bytesToNumberBE;function A(...e){return B(T(w("BIP0340/challenge",...e)))}function j(e){return P(e).bytes}function _(e,t,r=(0,o.randomBytes)(32)){const n=(0,c.ensureBytes)("message",e),{bytes:i,scalar:s}=P(t),a=(0,c.ensureBytes)("auxRand",r,32),u=v(s^T(w("BIP0340/aux",a))),f=w("BIP0340/nonce",u,i,n),l=B(T(f));if(l===d)throw new Error("sign failed: k is zero");const{bytes:h,scalar:p}=P(l),m=A(h,i,n),g=new Uint8Array(64);if(g.set(h,0),g.set(v(B(p+m*s)),32),!k(g,n,i))throw new Error("sign: Invalid signature produced");return g}function k(e,t,r){const n=(0,c.ensureBytes)("signature",e,64),o=(0,c.ensureBytes)("message",t),i=(0,c.ensureBytes)("publicKey",r,32);try{const e=I(T(i)),t=T(n.subarray(0,32));if(!(0,c.inRange)(t,h,f))return!1;const r=T(n.subarray(32,64));if(!(0,c.inRange)(r,h,l))return!1;const d=A(v(t),E(e),o),p=(s=e,a=r,u=B(-d),S.BASE.multiplyAndAddUnsafe(s,a,u));return!(!p||!p.hasEvenY()||p.toAffine().x!==t)}catch(e){return!1}var s,a,u}r.schnorr={getPublicKey:j,sign:_,verify:k,utils:{randomPrivateKey:r.secp256k1.utils.randomPrivateKey,lift_x:I,pointToBytes:E,numberToBytesBE:c.numberToBytesBE,bytesToNumberBE:c.bytesToNumberBE,taggedHash:w,mod:a.mod}};const O=(()=>(0,s.isogenyMap)(b,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))))(),N=(()=>(0,u.mapToCurveSimpleSWU)(b,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:b.create(BigInt("-11"))}))();r.secp256k1_hasher=(0,s.createHasher)(r.secp256k1.ProjectivePoint,e=>{const{x:t,y:r}=N(b.create(e[0]));return O(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:b.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}),r.hashToCurve=r.secp256k1_hasher.hashToCurve,r.encodeToCurve=r.secp256k1_hasher.encodeToCurve}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/secp256k1.js"}],[5847,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){!function(e){var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,i=Math.floor,s="[BigNumber Error] ",a=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,f=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,h=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function m(e){for(var t,r,n=1,o=e.length,i=e[0]+"";n<o;){for(t=e[n++]+"",r=u-t.length;r--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function g(e,t){var r,n,o=e.c,i=t.c,s=e.s,a=t.s,c=e.e,u=t.e;if(!s||!a)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=c==u,!o||!i)return n?0:!o^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=o.length)<(u=i.length)?c:u,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^r?1:-1;return c==u?0:c>u^r?1:-1}function b(e,t,r,n){if(e<t||e>r||e!==i(e))throw Error(s+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function y(e){var t=e.c.length-1;return p(e.e/u)==t&&e.c[t]%2!=0}function w(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function E(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}r=function e(t){var r,v,x,B,S,P,I,T,A,j,_=q.prototype={constructor:q,toString:null,valueOf:null},k=new q(1),O=20,N=4,R=-7,C=21,U=-1e7,D=1e7,L=!1,M=1,z=0,F={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},G="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function q(e,t){var r,o,s,c,l,d,h,p,m=this;if(!(m instanceof q))return new q(e,t);if(null==t){if(e&&!0===e._isBigNumber)return m.s=e.s,void(!e.c||e.e>D?m.c=m.e=null:e.e<U?m.c=[m.e=0]:(m.e=e.e,m.c=e.c.slice()));if((d="number"==typeof e)&&0*e==0){if(m.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,l=e;l>=10;l/=10,c++);return void(c>D?m.c=m.e=null:(m.e=c,m.c=[e]))}p=String(e)}else{if(!n.test(p=String(e)))return x(m,p,d);m.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(c<0&&(c=l),c+=+p.slice(l+1),p=p.substring(0,l)):c<0&&(c=p.length)}else{if(b(t,2,G.length,"Base"),10==t&&H)return K(m=new q(e),O+m.e+1,N);if(p=String(e),d="number"==typeof e){if(0*e!=0)return x(m,p,d,t);if(m.s=1/e<0?(p=p.slice(1),-1):1,q.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(a+e)}else m.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=G.slice(0,t),c=l=0,h=p.length;l<h;l++)if(r.indexOf(o=p.charAt(l))<0){if("."==o){if(l>c){c=h;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,c=0;continue}return x(m,String(e),d,t)}d=!1,(c=(p=v(p,t,10,m.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(l=0;48===p.charCodeAt(l);l++);for(h=p.length;48===p.charCodeAt(--h););if(p=p.slice(l,++h)){if(h-=l,d&&q.DEBUG&&h>15&&(e>f||e!==i(e)))throw Error(a+m.s*e);if((c=c-l-1)>D)m.c=m.e=null;else if(c<U)m.c=[m.e=0];else{if(m.e=c,m.c=[],l=(c+1)%u,c<0&&(l+=u),l<h){for(l&&m.c.push(+p.slice(0,l)),h-=u;l<h;)m.c.push(+p.slice(l,l+=u));l=u-(p=p.slice(l)).length}else l-=h;for(;l--;p+="0");m.c.push(+p)}}else m.c=[m.e=0]}function $(e,t,r,n){var o,i,s,a,c;if(null==r?r=N:b(r,0,8),!e.c)return e.toString();if(o=e.c[0],s=e.e,null==t)c=m(e.c),c=1==n||2==n&&(s<=R||s>=C)?w(c,s):E(c,s,"0");else if(i=(e=K(new q(e),t,r)).e,a=(c=m(e.c)).length,1==n||2==n&&(t<=i||i<=R)){for(;a<t;c+="0",a++);c=w(c,i)}else if(t-=s+(2===n&&i>s),c=E(c,i,"0"),i+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=i-a)>0)for(i+1==a&&(c+=".");t--;c+="0");return e.s<0&&o?"-"+c:c}function V(e,t){for(var r,n,o=1,i=new q(e[0]);o<e.length;o++)(!(n=new q(e[o])).s||(r=g(i,n))===t||0===r&&i.s===t)&&(i=n);return i}function W(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];o>=10;o/=10,n++);return(r=n+r*u-1)>D?e.c=e.e=null:r<U?e.c=[e.e=0]:(e.e=r,e.c=t),e}function K(e,t,r,n){var s,a,f,d,h,p,m,g=e.c,b=l;if(g){e:{for(s=1,d=g[0];d>=10;d/=10,s++);if((a=t-s)<0)a+=u,f=t,h=g[p=0],m=i(h/b[s-f-1]%10);else if((p=o((a+1)/u))>=g.length){if(!n)break e;for(;g.length<=p;g.push(0));h=m=0,s=1,f=(a%=u)-u+1}else{for(h=d=g[p],s=1;d>=10;d/=10,s++);m=(f=(a%=u)-u+s)<0?0:i(h/b[s-f-1]%10)}if(n=n||t<0||null!=g[p+1]||(f<0?h:h%b[s-f-1]),n=r<4?(m||n)&&(0==r||r==(e.s<0?3:2)):m>5||5==m&&(4==r||n||6==r&&(a>0?f>0?h/b[s-f]:0:g[p-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(t-=e.e+1,g[0]=b[(u-t%u)%u],e.e=-t||0):g[0]=e.e=0,e;if(0==a?(g.length=p,d=1,p--):(g.length=p+1,d=b[u-a],g[p]=f>0?i(h/b[s-f]%b[f])*d:0),n)for(;;){if(0==p){for(a=1,f=g[0];f>=10;f/=10,a++);for(f=g[0]+=d,d=1;f>=10;f/=10,d++);a!=d&&(e.e++,g[0]==c&&(g[0]=1));break}if(g[p]+=d,g[p]!=c)break;g[p--]=0,d=1}for(a=g.length;0===g[--a];g.pop());}e.e>D?e.c=e.e=null:e.e<U&&(e.c=[e.e=0])}return e}function Z(e){var t,r=e.e;return null===r?e.toString():(t=m(e.c),t=r<=R||r>=C?w(t,r):E(t,r,"0"),e.s<0?"-"+t:t)}return q.clone=e,q.ROUND_UP=0,q.ROUND_DOWN=1,q.ROUND_CEIL=2,q.ROUND_FLOOR=3,q.ROUND_HALF_UP=4,q.ROUND_HALF_DOWN=5,q.ROUND_HALF_EVEN=6,q.ROUND_HALF_CEIL=7,q.ROUND_HALF_FLOOR=8,q.EUCLID=9,q.config=q.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(s+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(b(r=e[t],0,h,t),O=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(b(r=e[t],0,8,t),N=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(b(r[0],-h,0,t),b(r[1],0,h,t),R=r[0],C=r[1]):(b(r,-h,h,t),R=-(C=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)b(r[0],-h,-1,t),b(r[1],1,h,t),U=r[0],D=r[1];else{if(b(r,-h,h,t),!r)throw Error(s+t+" cannot be zero: "+r);U=-(D=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(s+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!r,Error(s+"crypto unavailable");L=r}else L=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(b(r=e[t],0,9,t),M=r),e.hasOwnProperty(t="POW_PRECISION")&&(b(r=e[t],0,h,t),z=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(s+t+" not an object: "+r);F=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(s+t+" invalid: "+r);H="0123456789"==r.slice(0,10),G=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:N,EXPONENTIAL_AT:[R,C],RANGE:[U,D],CRYPTO:L,MODULO_MODE:M,POW_PRECISION:z,FORMAT:F,ALPHABET:G}},q.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!q.DEBUG)return!0;var t,r,n=e.c,o=e.e,a=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===a||-1===a)&&o>=-h&&o<=h&&o===i(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((t=(o+1)%u)<1&&(t+=u),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=c||r!==i(r))break e;if(0!==r)return!0}}}else if(null===n&&null===o&&(null===a||1===a||-1===a))return!0;throw Error(s+"Invalid BigNumber: "+e)},q.maximum=q.max=function(){return V(arguments,-1)},q.minimum=q.min=function(){return V(arguments,1)},q.random=(B=9007199254740992,S=Math.random()*B&2097151?function(){return i(Math.random()*B)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,a,c,f=0,d=[],p=new q(k);if(null==e?e=O:b(e,0,h),a=o(e/u),L)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));f<a;)(c=131072*t[f]+(t[f+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(d.push(c%1e14),f+=2);f=a/2}else{if(!crypto.randomBytes)throw L=!1,Error(s+"crypto unavailable");for(t=crypto.randomBytes(a*=7);f<a;)(c=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(d.push(c%1e14),f+=7);f=a/7}if(!L)for(;f<a;)(c=S())<9e15&&(d[f++]=c%1e14);for(a=d[--f],e%=u,a&&e&&(c=l[u-e],d[f]=i(a/c)*c);0===d[f];d.pop(),f--);if(f<0)d=[n=0];else{for(n=-1;0===d[0];d.splice(0,1),n-=u);for(f=1,c=d[0];c>=10;c/=10,f++);f<u&&(n-=u-f)}return p.e=n,p.c=d,p}),q.sum=function(){for(var e=1,t=arguments,r=new q(t[0]);e<t.length;)r=r.plus(t[e++]);return r},v=function(){var e="0123456789";function t(e,t,r,n){for(var o,i,s=[0],a=0,c=e.length;a<c;){for(i=s.length;i--;s[i]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),o=0;o<s.length;o++)s[o]>r-1&&(null==s[o+1]&&(s[o+1]=0),s[o+1]+=s[o]/r|0,s[o]%=r)}return s.reverse()}return function(n,o,i,s,a){var c,u,f,l,d,h,p,g,b=n.indexOf("."),y=O,w=N;for(b>=0&&(l=z,z=0,n=n.replace(".",""),h=(g=new q(o)).pow(n.length-b),z=l,g.c=t(E(m(h.c),h.e,"0"),10,i,e),g.e=g.c.length),f=l=(p=t(n,o,i,a?(c=G,e):(c=e,G))).length;0==p[--l];p.pop());if(!p[0])return c.charAt(0);if(b<0?--f:(h.c=p,h.e=f,h.s=s,p=(h=r(h,g,y,w,i)).c,d=h.r,f=h.e),b=p[u=f+y+1],l=i/2,d=d||u<0||null!=p[u+1],d=w<4?(null!=b||d)&&(0==w||w==(h.s<0?3:2)):b>l||b==l&&(4==w||d||6==w&&1&p[u-1]||w==(h.s<0?8:7)),u<1||!p[0])n=d?E(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(p.length=u,d)for(--i;++p[--u]>i;)p[u]=0,u||(++f,p=[1].concat(p));for(l=p.length;!p[--l];);for(b=0,n="";b<=l;n+=c.charAt(p[b++]));n=E(n,f,c.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,o,i,s,a=0,c=e.length,u=t%d,f=t/d|0;for(e=e.slice();c--;)a=((o=u*(i=e[c]%d)+(n=f*i+(s=e[c]/d|0)*u)%d*d+a)/r|0)+(n/d|0)+f*s,e[c]=o%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var o,i;if(r!=n)i=r>n?1:-1;else for(o=i=0;o<r;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function r(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,o,s,a,f){var l,d,h,m,g,b,y,w,E,v,x,B,S,P,I,T,A,j=n.s==o.s?1:-1,_=n.c,k=o.c;if(!(_&&_[0]&&k&&k[0]))return new q(n.s&&o.s&&(_?!k||_[0]!=k[0]:k)?_&&0==_[0]||!k?0*j:j/0:NaN);for(E=(w=new q(j)).c=[],j=s+(d=n.e-o.e)+1,f||(f=c,d=p(n.e/u)-p(o.e/u),j=j/u|0),h=0;k[h]==(_[h]||0);h++);if(k[h]>(_[h]||0)&&d--,j<0)E.push(1),m=!0;else{for(P=_.length,T=k.length,h=0,j+=2,(g=i(f/(k[0]+1)))>1&&(k=e(k,g,f),_=e(_,g,f),T=k.length,P=_.length),S=T,x=(v=_.slice(0,T)).length;x<T;v[x++]=0);A=k.slice(),A=[0].concat(A),I=k[0],k[1]>=f/2&&I++;do{if(g=0,(l=t(k,v,T,x))<0){if(B=v[0],T!=x&&(B=B*f+(v[1]||0)),(g=i(B/I))>1)for(g>=f&&(g=f-1),y=(b=e(k,g,f)).length,x=v.length;1==t(b,v,y,x);)g--,r(b,T<y?A:k,y,f),y=b.length,l=1;else 0==g&&(l=g=1),y=(b=k.slice()).length;if(y<x&&(b=[0].concat(b)),r(v,b,x,f),x=v.length,-1==l)for(;t(k,v,T,x)<1;)g++,r(v,T<x?A:k,x,f),x=v.length}else 0===l&&(g++,v=[0]);E[h++]=g,v[0]?v[x++]=_[S]||0:(v=[_[S]],x=1)}while((S++<P||null!=v[0])&&j--);m=null!=v[0],E[0]||E.splice(0,1)}if(f==c){for(h=1,j=E[0];j>=10;j/=10,h++);K(w,s+(w.e=h+d*u-1)+1,a,m)}else w.e=d,w.r=+m;return w}}(),P=/^(-?)0([xbo])(?=\w[\w.]*$)/i,I=/^([^.]+)\.$/,T=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,j=/^\s*\+(?=[\w.])|^\s+|\s+$/g,x=function(e,t,r,n){var o,i=r?t:t.replace(j,"");if(A.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(P,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,i=i.replace(I,"$1").replace(T,"0.$1")),t!=i))return new q(i,o);if(q.DEBUG)throw Error(s+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},_.absoluteValue=_.abs=function(){var e=new q(this);return e.s<0&&(e.s=1),e},_.comparedTo=function(e,t){return g(this,new q(e,t))},_.decimalPlaces=_.dp=function(e,t){var r,n,o,i=this;if(null!=e)return b(e,0,h),null==t?t=N:b(t,0,8),K(new q(i),e+i.e+1,t);if(!(r=i.c))return null;if(n=((o=r.length-1)-p(this.e/u))*u,o=r[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(e,t){return r(this,new q(e,t),O,N)},_.dividedToIntegerBy=_.idiv=function(e,t){return r(this,new q(e,t),0,1)},_.exponentiatedBy=_.pow=function(e,t){var r,n,a,c,f,l,d,h,p=this;if((e=new q(e)).c&&!e.isInteger())throw Error(s+"Exponent not an integer: "+Z(e));if(null!=t&&(t=new q(t)),f=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return h=new q(Math.pow(+Z(p),f?e.s*(2-y(e)):+Z(e))),t?h.mod(t):h;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new q(NaN);(n=!l&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||f&&p.c[1]>=24e7:p.c[0]<8e13||f&&p.c[0]<=9999975e7)))return c=p.s<0&&y(e)?-0:0,p.e>-1&&(c=1/c),new q(l?1/c:c);z&&(c=o(z/u+2))}for(f?(r=new q(.5),l&&(e.s=1),d=y(e)):d=(a=Math.abs(+Z(e)))%2,h=new q(k);;){if(d){if(!(h=h.times(p)).c)break;c?h.c.length>c&&(h.c.length=c):n&&(h=h.mod(t))}if(a){if(0===(a=i(a/2)))break;d=a%2}else if(K(e=e.times(r),e.e+1,1),e.e>14)d=y(e);else{if(0===(a=+Z(e)))break;d=a%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):n&&(p=p.mod(t))}return n?h:(l&&(h=k.div(h)),t?h.mod(t):c?K(h,z,N,undefined):h)},_.integerValue=function(e){var t=new q(this);return null==e?e=N:b(e,0,8),K(t,t.e+1,e)},_.isEqualTo=_.eq=function(e,t){return 0===g(this,new q(e,t))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(e,t){return g(this,new q(e,t))>0},_.isGreaterThanOrEqualTo=_.gte=function(e,t){return 1===(t=g(this,new q(e,t)))||0===t},_.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},_.isLessThan=_.lt=function(e,t){return g(this,new q(e,t))<0},_.isLessThanOrEqualTo=_.lte=function(e,t){return-1===(t=g(this,new q(e,t)))||0===t},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(e,t){var r,n,o,i,s=this,a=s.s;if(t=(e=new q(e,t)).s,!a||!t)return new q(NaN);if(a!=t)return e.s=-t,s.plus(e);var f=s.e/u,l=e.e/u,d=s.c,h=e.c;if(!f||!l){if(!d||!h)return d?(e.s=-t,e):new q(h?s:NaN);if(!d[0]||!h[0])return h[0]?(e.s=-t,e):new q(d[0]?s:3==N?-0:0)}if(f=p(f),l=p(l),d=d.slice(),a=f-l){for((i=a<0)?(a=-a,o=d):(l=f,o=h),o.reverse(),t=a;t--;o.push(0));o.reverse()}else for(n=(i=(a=d.length)<(t=h.length))?a:t,a=t=0;t<n;t++)if(d[t]!=h[t]){i=d[t]<h[t];break}if(i&&(o=d,d=h,h=o,e.s=-e.s),(t=(n=h.length)-(r=d.length))>0)for(;t--;d[r++]=0);for(t=c-1;n>a;){if(d[--n]<h[n]){for(r=n;r&&!d[--r];d[r]=t);--d[r],d[n]+=c}d[n]-=h[n]}for(;0==d[0];d.splice(0,1),--l);return d[0]?W(e,d,l):(e.s=3==N?-1:1,e.c=[e.e=0],e)},_.modulo=_.mod=function(e,t){var n,o,i=this;return e=new q(e,t),!i.c||!e.s||e.c&&!e.c[0]?new q(NaN):!e.c||i.c&&!i.c[0]?new q(i):(9==M?(o=e.s,e.s=1,n=r(i,e,0,3),e.s=o,n.s*=o):n=r(i,e,0,M),(e=i.minus(n.times(e))).c[0]||1!=M||(e.s=i.s),e)},_.multipliedBy=_.times=function(e,t){var r,n,o,i,s,a,f,l,h,m,g,b,y,w,E,v=this,x=v.c,B=(e=new q(e,t)).c;if(!(x&&B&&x[0]&&B[0]))return!v.s||!e.s||x&&!x[0]&&!B||B&&!B[0]&&!x?e.c=e.e=e.s=null:(e.s*=v.s,x&&B?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(v.e/u)+p(e.e/u),e.s*=v.s,(f=x.length)<(m=B.length)&&(y=x,x=B,B=y,o=f,f=m,m=o),o=f+m,y=[];o--;y.push(0));for(w=c,E=d,o=m;--o>=0;){for(r=0,g=B[o]%E,b=B[o]/E|0,i=o+(s=f);i>o;)r=((l=g*(l=x[--s]%E)+(a=b*l+(h=x[s]/E|0)*g)%E*E+y[i]+r)/w|0)+(a/E|0)+b*h,y[i--]=l%w;y[i]=r}return r?++n:y.splice(0,1),W(e,y,n)},_.negated=function(){var e=new q(this);return e.s=-e.s||null,e},_.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new q(e,t)).s,!o||!t)return new q(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/u,s=e.e/u,a=n.c,f=e.c;if(!i||!s){if(!a||!f)return new q(o/0);if(!a[0]||!f[0])return f[0]?e:new q(a[0]?n:0*o)}if(i=p(i),s=p(s),a=a.slice(),o=i-s){for(o>0?(s=i,r=f):(o=-o,r=a),r.reverse();o--;r.push(0));r.reverse()}for((o=a.length)-(t=f.length)<0&&(r=f,f=a,a=r,t=o),o=0;t;)o=(a[--t]=a[t]+f[t]+o)/c|0,a[t]=c===a[t]?0:a[t]%c;return o&&(a=[o].concat(a),++s),W(e,a,s)},_.precision=_.sd=function(e,t){var r,n,o,i=this;if(null!=e&&e!==!!e)return b(e,1,h),null==t?t=N:b(t,0,8),K(new q(i),e,t);if(!(r=i.c))return null;if(n=(o=r.length-1)*u+1,o=r[o]){for(;o%10==0;o/=10,n--);for(o=r[0];o>=10;o/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},_.shiftedBy=function(e){return b(e,-9007199254740991,f),this.times("1e"+e)},_.squareRoot=_.sqrt=function(){var e,t,n,o,i,s=this,a=s.c,c=s.s,u=s.e,f=O+4,l=new q("0.5");if(1!==c||!a||!a[0])return new q(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(c=Math.sqrt(+Z(s)))||c==1/0?(((t=m(a)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=p((u+1)/2)-(u<0||u%2),n=new q(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new q(c+""),n.c[0])for((c=(u=n.e)+f)<3&&(c=0);;)if(i=n,n=l.times(i.plus(r(s,i,f,1))),m(i.c).slice(0,c)===(t=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(K(n,n.e+O+2,1),e=!n.times(n).eq(s));break}if(!o&&(K(i,i.e+O+2,0),i.times(i).eq(s))){n=i;break}f+=4,c+=4,o=1}return K(n,n.e+O+1,N,e)},_.toExponential=function(e,t){return null!=e&&(b(e,0,h),e++),$(this,e,t,1)},_.toFixed=function(e,t){return null!=e&&(b(e,0,h),e=e+this.e+1),$(this,e,t)},_.toFormat=function(e,t,r){var n,o=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=F;else if("object"!=typeof r)throw Error(s+"Argument not an object: "+r);if(n=o.toFixed(e,t),o.c){var i,a=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,f=r.groupSeparator||"",l=a[0],d=a[1],h=o.s<0,p=h?l.slice(1):l,m=p.length;if(u&&(i=c,c=u,u=i,m-=i),c>0&&m>0){for(i=m%c||c,l=p.substr(0,i);i<m;i+=c)l+=f+p.substr(i,c);u>0&&(l+=f+p.slice(i)),h&&(l="-"+l)}n=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(e){var t,n,o,i,a,c,f,d,h,p,g,b,y=this,w=y.c;if(null!=e&&(!(f=new q(e)).isInteger()&&(f.c||1!==f.s)||f.lt(k)))throw Error(s+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+Z(f));if(!w)return new q(y);for(t=new q(k),h=n=new q(k),o=d=new q(k),b=m(w),a=t.e=b.length-y.e-1,t.c[0]=l[(c=a%u)<0?u+c:c],e=!e||f.comparedTo(t)>0?a>0?t:h:f,c=D,D=1/0,f=new q(b),d.c[0]=0;p=r(f,t,0,1),1!=(i=n.plus(p.times(o))).comparedTo(e);)n=o,o=i,h=d.plus(p.times(i=h)),d=i,t=f.minus(p.times(i=t)),f=i;return i=r(e.minus(n),o,0,1),d=d.plus(i.times(h)),n=n.plus(i.times(o)),d.s=h.s=y.s,g=r(h,o,a*=2,N).minus(y).abs().comparedTo(r(d,n,a,N).minus(y).abs())<1?[h,o]:[d,n],D=c,g},_.toNumber=function(){return+Z(this)},_.toPrecision=function(e,t){return null!=e&&b(e,1,h),$(this,e,t,2)},_.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=o<=R||o>=C?w(m(r.c),o):E(m(r.c),o,"0"):10===e&&H?t=E(m((r=K(new q(r),O+o+1,N)).c),r.e,"0"):(b(e,2,G.length,"Base"),t=v(E(m(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},_.valueOf=_.toJSON=function(){return Z(this)},_._isBigNumber=!0,null!=t&&q.set(t),q}(),r.default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):void 0!==t&&t.exports?t.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(void 0)}}},{package:"eth-lattice-keyring>gridplus-sdk>bignumber.js",file:"node_modules/gridplus-sdk/node_modules/bignumber.js/bignumber.js"}],[5848,{bs58:5454},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),o=e(r);if(!(n[0]^o[0]|n[1]^o[1]|n[2]^o[2]|n[3]^o[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),n=e(r),i=r.length+4,s=new Uint8Array(i);return s.set(r,0),s.set(n.subarray(0,4),r.length),o.default.encode(s)},decode:function(e){var r=t(o.default.decode(e));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=o.default.decodeUnsafe(e);if(null!=r)return t(r)}}};var o=n(e("bs58"))}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/base.cjs"}],[5849,{"./base.cjs":5848,"@noble/hashes/sha256":4512},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var o=e("@noble/hashes/sha256"),i=n(e("./base.cjs"));r.default=(0,i.default)(function(e){return(0,o.sha256)((0,o.sha256)(e))})}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/index.cjs"}],[585,{"@metamask/utils":4277,lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=i,t.data=function(e){if(!(0,o.hasProperty)(e,"TokensController"))return console.warn("newState.TokensController is not present"),e;const t=e.TokensController;if(!(0,o.isObject)(t))return global.sentry?.captureException?.(new Error(`Migration ${i}: TokensController is type '${typeof t}', expected object.`)),e;if(!(0,o.hasProperty)(e,"TokenListController"))return console.warn("newState.TokenListController is not present"),e;const r=e.TokenListController;if(!(0,o.isObject)(r))return global.sentry?.captureException?.(new Error(`Migration ${i}: TokenListController is type '${typeof r}', expected object.`)),e;(0,o.hasProperty)(t,"tokens")&&delete t.tokens;(0,o.hasProperty)(t,"detectedTokens")&&delete t.detectedTokens;(0,o.hasProperty)(t,"ignoredTokens")&&delete t.ignoredTokens;(0,o.hasProperty)(r,"tokenList")&&delete r.tokenList;return e}(t.data),t},r.version=void 0;var n=e("lodash"),o=e("@metamask/utils");const i=r.version=153}}},{package:"$root$",file:"app/scripts/migrations/153.ts"}],[5850,{"bignumber.js":5847},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n,o;n=void 0,o=e=>{return t={68:(e,t,r)=>{const{BigNumber:n}=r(905);let o=null;const i=new n("0x20000000000000"),s=new n(2);function a(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushJSBigint(BigInt(t.toFixed()));if(!e._pushTag(4)||!e._pushInt(2,4))return!1;const r=t.decimalPlaces(),n=t.shiftedBy(r);return!!e._pushIntNum(-r)&&(n.abs().isLessThan(i)?e._pushIntNum(n.toNumber()):e._pushJSBigint(BigInt(n.toFixed())))}function c(e){return new n(e[1]).shiftedBy(e[0])}function u(e){return s.pow(e[0]).times(e[1])}function f(e){return o=e,o.Encoder.SEMANTIC_TYPES[n.name]=a,o.Tagged.TAGS[4]=c,o.Tagged.TAGS[5]=u,o}f.BigNumber=n,e.exports=f},905:t=>{t.exports=e}},r={},function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n](i,i.exports,e),i.exports}(68);var t,r},"object"==typeof r&&"object"==typeof t?t.exports=o(e("bignumber.js")):"function"==typeof define&&define.amd?define([],o):"object"==typeof r?r.cborBigDecimal=o(e("bignumber.js")):n.cborBigDecimal=o(n.BigNumber)}}},{package:"eth-lattice-keyring>gridplus-sdk>cbor-bigdecimal",file:"node_modules/gridplus-sdk/node_modules/cbor-bigdecimal/dist/cbor-bigdecimal.js"}],[5851,{"./internal/abi.js":5919,abitype:5264},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.format=function(e){return n.formatAbi(e)},r.from=function(e){return o.isSignatures(e)?n.parseAbi(e):e};const n=e("abitype"),o=e("./internal/abi.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Abi.js"}],[5852,{"./AbiItem.js":5856,"./AbiParameters.js":5857,"./Hex.js":5883,abitype:5264},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return[a(t),r]}return e})(),{bytecode:n}=r;if(0===t.inputs?.length)return undefined;const o=r.data.replace(n,"0x");return i.decode(t.inputs,o)},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return[a(t),r]}return e})(),{bytecode:n,args:o}=r;return s.concat(n,t.inputs?.length&&o?.length?i.encode(t.inputs,o):"0x")},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e){return o.from(e)},r.fromAbi=a;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Hex.js");function a(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new o.NotFoundError({name:"constructor"});return t}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiConstructor.js"}],[5853,{"./AbiItem.js":5856,"./AbiParameters.js":5857,"./Hex.js":5883,abitype:5264},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.solidityPanicSelector=r.solidityPanic=r.solidityErrorSelector=r.solidityError=r.panicReasons=void 0,r.decode=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[c(t,r),n,o]}return e})();if(s.size(r)<4)throw new o.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const a=i.decode(t.inputs,s.slice(r,4),n);if(a&&1===Object.keys(a).length)return Array.isArray(a)?a[0]:Object.values(a)[0];return a},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,...n]=e;return[c(t,r),n]}const[t,...r]=e;return[t,r]})(),n=u(t),o=r.length>0?i.encode(t.inputs,r[0]):undefined;return o?s.concat(n,o):n},r.format=function(e){return n.formatAbiItem(e)},r.from=a,r.fromAbi=c,r.getSelector=u;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Hex.js");function a(e,t={}){return o.from(e,t)}function c(e,t,n){if("Error"===t)return r.solidityError;if("Panic"===t)return r.solidityPanic;if(s.validate(t,{strict:!1})){const e=s.slice(t,0,4);if(e===r.solidityErrorSelector)return r.solidityError;if(e===r.solidityPanicSelector)return r.solidityPanic}const i=o.fromAbi(e,t,n);if("error"!==i.type)throw new o.NotFoundError({name:t,type:"error"});return i}function u(e){return o.getSelector(e)}r.panicReasons={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},r.solidityError=a({inputs:[{name:"message",type:"string"}],name:"Error",type:"error"}),r.solidityErrorSelector="0x08c379a0",r.solidityPanic=a({inputs:[{name:"reason",type:"uint8"}],name:"Panic",type:"error"}),r.solidityPanicSelector="0x4e487b71"}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiError.js"}],[5854,{"./AbiItem.js":5856,"./AbiParameters.js":5857,"./Address.js":5860,"./Bytes.js":5872,"./Errors.js":5878,"./Hash.js":5881,"./Hex.js":5883,"./internal/cursor.js":5924,"./internal/errors.js":5927,abitype:5264},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.FilterTypeNotSupportedError=r.SelectorTopicMismatchError=r.TopicsMismatchError=r.DataMismatchError=r.InputNotFoundError=r.ArgsMismatchError=void 0,r.assertArgs=function(e,t,r){if(!t||!r)throw new g({abiEvent:e,expected:t,given:r});function n(e,t,r){return"address"===e.type?s.isEqual(t,r):"string"===e.type?u.keccak256(a.fromString(t))===r:"bytes"===e.type?u.keccak256(t)===r:t===r}if(Array.isArray(t)&&Array.isArray(r))for(const[o,i]of r.entries()){if(null===i||i===undefined)continue;const s=e.inputs[o];if(!s)throw new b({abiEvent:e,name:`${o}`});const a=Array.isArray(i)?i:[i];let c=!1;for(const e of a)n(s,e,t[o])&&(c=!0);if(!c)throw new g({abiEvent:e,expected:t,given:r})}if("object"==typeof t&&!Array.isArray(t)&&"object"==typeof r&&!Array.isArray(r))for(const[o,i]of Object.entries(r)){if(null===i||i===undefined)continue;const s=e.inputs.find(e=>e.name===o);if(!s)throw new b({abiEvent:e,name:o});const a=Array.isArray(i)?i:[i];let c=!1;for(const e of a)n(s,e,t[o])&&(c=!0);if(!c)throw new g({abiEvent:e,expected:t,given:r})}},r.decode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[p(t,r),n]}return e})(),{data:n,topics:o}=r,[s,...a]=o,c=m(t);if(s!==c)throw new E({abiEvent:t,actual:s,expected:c});const{inputs:u}=t,d=u?.every(e=>!("name"in e&&e.name));let h=d?[]:{};const g=u.filter(e=>"indexed"in e&&e.indexed);for(let e=0;e<g.length;e++){const r=g[e],n=a[e];if(!n)throw new w({abiEvent:t,param:r});h[d?e:r.name||e]=(()=>{if("string"===r.type||"bytes"===r.type||"tuple"===r.type||r.type.match(/^(.*)\[(\d+)?\]$/))return n;return(i.decode([r],n)||[])[0]})()}const b=u.filter(e=>!("indexed"in e&&e.indexed));if(b.length>0){if(!n||"0x"===n)throw new y({abiEvent:t,data:"0x",parameters:b,size:0});try{const e=i.decode(b,n);if(e)if(d)h=[...h,...e];else for(let t=0;t<b.length;t++){const r=u.indexOf(b[t]);h[b[t].name||r]=e[t]}}catch(e){if(e instanceof i.DataSizeTooSmallError||e instanceof l.PositionOutOfBoundsError)throw new y({abiEvent:t,data:n,parameters:b,size:f.size(n)});throw e}}return Object.values(h).length>0?h:undefined},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[p(t,r),n]}const[t,r]=e;return[t,r]})();let n=[];if(r&&t.inputs){const e=t.inputs.filter(e=>"indexed"in e&&e.indexed),o=Array.isArray(r)?r:Object.values(r).length>0?e?.map((e,t)=>r[e.name??t])??[]:[];if(o.length>0){const t=(e,t)=>{if("string"===e.type)return u.keccak256(f.fromString(t));if("bytes"===e.type)return u.keccak256(t);if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new v(e.type);return i.encode([e],[t])};n=e?.map((e,r)=>Array.isArray(o[r])?o[r].map((n,i)=>t(e,o[r][i])):void 0!==o[r]&&null!==o[r]?t(e,o[r]):null)??[]}}return{topics:[t.hash?t.hash:m(t),...n]}},r.format=h,r.from=function(e,t={}){return o.from(e,t)},r.fromAbi=p,r.getSelector=m;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Address.js"),a=e("./Bytes.js"),c=e("./Errors.js"),u=e("./Hash.js"),f=e("./Hex.js"),l=e("./internal/cursor.js"),d=e("./internal/errors.js");function h(e){return n.formatAbiItem(e)}function p(e,t,r){const n=o.fromAbi(e,t,r);if("event"!==n.type)throw new o.NotFoundError({name:t,type:"event"});return n}function m(e){return o.getSignatureHash(e)}class g extends c.BaseError{constructor({abiEvent:e,expected:t,given:r}){super("Given arguments do not match the expected arguments.",{metaMessages:[`Event: ${h(e)}`,"Expected Arguments: "+(t?"":"None"),t?(0,d.prettyPrint)(t):undefined,"Given Arguments: "+(r?"":"None"),r?(0,d.prettyPrint)(r):undefined]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.ArgsMismatchError"})}}r.ArgsMismatchError=g;class b extends c.BaseError{constructor({abiEvent:e,name:t}){super(`Parameter "${t}" not found on \`${h(e)}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.InputNotFoundError"})}}r.InputNotFoundError=b;class y extends c.BaseError{constructor({abiEvent:e,data:t,parameters:r,size:n}){super([`Data size of ${n} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Non-indexed Parameters: (${i.format(r)})`,`Data:   ${t} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.DataMismatchError"}),Object.defineProperty(this,"abiEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parameters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiEvent=e,this.data=t,this.parameters=r,this.size=n}}r.DataMismatchError=y;class w extends c.BaseError{constructor({abiEvent:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} for "${h(e)}".`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.TopicsMismatchError"}),Object.defineProperty(this,"abiEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiEvent=e}}r.TopicsMismatchError=w;class E extends c.BaseError{constructor({abiEvent:e,actual:t,expected:r}){super(`topics[0]="${t}" does not match the expected topics[0]="${r}".`,{metaMessages:[`Event: ${h(e)}`,`Selector: ${r}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.SelectorTopicMismatchError"})}}r.SelectorTopicMismatchError=E;class v extends c.BaseError{constructor(e){super(`Filter type "${e}" is not supported.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.FilterTypeNotSupportedError"})}}r.FilterTypeNotSupportedError=v}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiEvent.js"}],[5855,{"./AbiItem.js":5856,"./AbiParameters.js":5857,"./Hex.js":5883,abitype:5264},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decodeData=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[a(t,r),n]}return e})(),{overloads:n}=t;if(s.size(r)<4)throw new o.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const c=n?a([t,...n],r):t;return s.size(r)<=4?undefined:i.decode(c.inputs,s.slice(r,4))},r.decodeResult=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[a(t,r),n,o]}return e})(),o=i.decode(t.outputs,r,n);if(o&&0===Object.keys(o).length)return undefined;if(o&&1===Object.keys(o).length)return Array.isArray(o)?o[0]:Object.values(o)[0];return o},r.encodeData=function(...e){const[t,r=[]]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[a(t,r,{args:n}),n]}const[t,r]=e;return[t,r]})(),{overloads:n}=t,o=n?a([t,...n],t.name,{args:r}):t,u=c(o),f=r.length>0?i.encode(o.inputs,r):undefined;return f?s.concat(u,f):u},r.encodeResult=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[a(t,r),n,o]}return e})(),{as:o="Array"}=n,s=1===t.outputs.length?[r]:Array.isArray(r)?r:"Object"===o?Object.values(r):[r];return i.encode(t.outputs,s)},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e,t={}){return o.from(e,t)},r.fromAbi=a,r.getSelector=c;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Hex.js");function a(e,t,r){const n=o.fromAbi(e,t,r);if("function"!==n.type)throw new o.NotFoundError({name:t,type:"function"});return n}function c(e){return o.getSelector(e)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiFunction.js"}],[5856,{"./Errors.js":5878,"./Hash.js":5881,"./Hex.js":5883,"./internal/abiItem.js":5920,abitype:5264},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidSelectorSizeError=r.NotFoundError=r.AmbiguityError=void 0,r.format=function(e){return n.formatAbiItem(e)},r.from=function(e,t={}){const{prepare:r=!0}=t,o=Array.isArray(e)||"string"==typeof e?n.parseAbiItem(e):e;return{...o,...r?{hash:l(o)}:{}}},r.fromAbi=c,r.getSelector=u,r.getSignature=f,r.getSignatureHash=l;const n=e("abitype"),o=e("./Errors.js"),i=e("./Hash.js"),s=e("./Hex.js"),a=e("./internal/abiItem.js");function c(e,t,r){const{args:n=[],prepare:o=!0}=r??{},i=s.validate(t,{strict:!1}),c=e.filter(e=>i?"function"===e.type||"error"===e.type?u(e)===s.slice(t,0,4):"event"===e.type&&l(e)===t:"name"in e&&e.name===t);if(0===c.length)throw new h({name:t});if(1===c.length)return{...c[0],...o?{hash:l(c[0])}:{}};let f;for(const e of c){if(!("inputs"in e))continue;if(!n||0===n.length){if(!e.inputs||0===e.inputs.length)return{...e,...o?{hash:l(e)}:{}};continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==n.length)continue;if(n.every((t,r)=>{const n="inputs"in e&&e.inputs[r];return!!n&&a.isArgOfType(t,n)})){if(f&&"inputs"in f&&f.inputs){const t=a.getAmbiguousTypes(e.inputs,f.inputs,n);if(t)throw new d({abiItem:e,type:t[0]},{abiItem:f,type:t[1]})}f=e}}const p=(()=>{if(f)return f;const[e,...t]=c;return{...e,overloads:t}})();if(!p)throw new h({name:t});return{...p,...o?{hash:l(p)}:{}}}function u(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})();return s.slice(l(t),0,4)}function f(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})(),r="string"==typeof t?t:n.formatAbiItem(t);return a.normalizeSignature(r)}function l(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:i.keccak256(s.fromString(f(t)))}class d extends o.BaseError{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${a.normalizeSignature(n.formatAbiItem(e.abiItem))}\`, and`,`\`${t.type}\` in \`${a.normalizeSignature(n.formatAbiItem(t.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}r.AmbiguityError=d;class h extends o.BaseError{constructor({name:e,data:t,type:r="item"}){super(`ABI ${r}${e?` with name "${e}"`:t?` with data "${t}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}r.NotFoundError=h;class p extends o.BaseError{constructor({data:e}){super(`Selector size is invalid. Expected 4 bytes. Received ${s.size(e)} bytes ("${e}").`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.InvalidSelectorSizeError"})}}r.InvalidSelectorSizeError=p}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiItem.js"}],[5857,{"./Address.js":5860,"./Bytes.js":5872,"./Errors.js":5878,"./Hex.js":5883,"./Solidity.js":5901,"./internal/abiParameters.js":5921,"./internal/cursor.js":5924,abitype:5264},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidTypeError=r.InvalidArrayError=r.LengthMismatchError=r.BytesSizeMismatchError=r.ArrayLengthMismatchError=r.ZeroDataError=r.DataSizeTooSmallError=void 0,r.decode=function(e,t,r={}){const{as:n="Array",checksumAddress:o=!1}=r,s="string"==typeof t?i.fromHex(t):t,f=u.create(s);if(0===i.size(s)&&e.length>0)throw new h;if(i.size(s)&&i.size(s)<32)throw new d({data:"string"==typeof t?t:a.fromBytes(t),parameters:e,size:i.size(s)});let l=0;const p="Array"===n?[]:{};for(let t=0;t<e.length;++t){const r=e[t];f.setPosition(l);const[i,s]=c.decodeParameter(f,r,{checksumAddress:o,staticPosition:0});l+=s,"Array"===n?p.push(i):p[r.name??t]=i}return p},r.encode=function(e,t,r){const{checksumAddress:n=!1}=r??{};if(e.length!==t.length)throw new g({expectedLength:e.length,givenLength:t.length});const o=c.prepareParameters({checksumAddress:n,parameters:e,values:t}),i=c.encode(o);return 0===i.length?"0x":i},r.encodePacked=l,r.format=function(e){return n.formatAbiParameters(e)},r.from=function(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?n.parseAbiParameters(e):e};const n=e("abitype"),o=e("./Address.js"),i=e("./Bytes.js"),s=e("./Errors.js"),a=e("./Hex.js"),c=e("./internal/abiParameters.js"),u=e("./internal/cursor.js"),f=e("./Solidity.js");function l(e,t){if(e.length!==t.length)throw new g({expectedLength:e.length,givenLength:t.length});const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n];r.push(l.encode(o,i))}return a.concat(...r)}!function(e){e.encode=function e(t,r,n=!1){if("address"===t){const e=r;return o.assert(e),a.padLeft(e.toLowerCase(),n?32:0)}if("string"===t)return a.fromString(r);if("bytes"===t)return r;if("bool"===t)return a.padLeft(a.fromBoolean(r),n?32:1);const i=t.match(f.integerRegex);if(i){const[e,t,o="256"]=i,s=Number.parseInt(o,10)/8;return a.fromNumber(r,{size:n?32:s,signed:"int"===t})}const s=t.match(f.bytesRegex);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(r.length-2)/2)throw new m({expectedSize:Number.parseInt(t,10),value:r});return a.padRight(r,n?32:0)}const c=t.match(f.arrayRegex);if(c&&Array.isArray(r)){const[t,n]=c,o=[];for(let t=0;t<r.length;t++)o.push(e(n,r[t],!0));return 0===o.length?"0x":a.concat(...o)}throw new y(t)}}(l||(r.encodePacked=l={}));class d extends s.BaseError{constructor({data:e,parameters:t,size:r}){super(`Data size of ${r} bytes is too small for given parameters.`,{metaMessages:[`Params: (${n.formatAbiParameters(t)})`,`Data:   ${e} (${r} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}r.DataSizeTooSmallError=d;class h extends s.BaseError{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}r.ZeroDataError=h;class p extends s.BaseError{constructor({expectedLength:e,givenLength:t,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}r.ArrayLengthMismatchError=p;class m extends s.BaseError{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${a.size(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}r.BytesSizeMismatchError=m;class g extends s.BaseError{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}r.LengthMismatchError=g;class b extends s.BaseError{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}r.InvalidArrayError=b;class y extends s.BaseError{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}r.InvalidTypeError=y}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiParameters.js"}],[5858,{"./Address.js":5860,"./Errors.js":5878,"./Hash.js":5881,"./Hex.js":5883},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidStorageKeySizeError=void 0,r.fromTupleList=function(e){const t=[];for(let r=0;r<e.length;r++){const[o,a]=e[r];o&&n.assert(o,{strict:!1}),t.push({address:o,storageKeys:a.map(e=>i.validate(e)?e:s.trimLeft(e))})}return t},r.toTupleList=function(e){if(!e||0===e.length)return[];const t=[];for(const{address:r,storageKeys:o}of e){for(let e=0;e<o.length;e++)if(32!==s.size(o[e]))throw new a({storageKey:o[e]});r&&n.assert(r,{strict:!1}),t.push([r,o])}return t};const n=e("./Address.js"),o=e("./Errors.js"),i=e("./Hash.js"),s=e("./Hex.js");class a extends o.BaseError{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${s.size(e)} bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AccessList.InvalidStorageKeySizeError"})}}r.InvalidStorageKeySizeError=a}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AccessList.js"}],[5859,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AccountProof.js"}],[586,{lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=o,function(e){delete e?.QueuedRequestController}(t.data),t},r.version=void 0;var n=e("lodash");const o=r.version=154}}},{package:"$root$",file:"app/scripts/migrations/154.ts"}],[5860,{"./Bytes.js":5872,"./Caches.js":5873,"./Errors.js":5878,"./Hash.js":5881,"./PublicKey.js":5892},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidChecksumError=r.InvalidInputError=r.InvalidAddressError=void 0,r.assert=u,r.checksum=f,r.from=l,r.fromPublicKey=function(e,t={}){return l(`0x${s.keccak256(`0x${a.toHex(e).slice(4)}`).substring(26)}`,t)},r.isEqual=function(e,t){return u(e,{strict:!1}),u(t,{strict:!1}),e.toLowerCase()===t.toLowerCase()},r.validate=function(e,t={}){const{strict:r=!0}=t??{};try{return u(e,{strict:r}),!0}catch{return!1}};const n=e("./Bytes.js"),o=e("./Caches.js"),i=e("./Errors.js"),s=e("./Hash.js"),a=e("./PublicKey.js"),c=/^0x[a-fA-F0-9]{40}$/;function u(e,t={}){const{strict:r=!0}=t;if(!c.test(e))throw new d({address:e,cause:new h});if(r){if(e.toLowerCase()===e)return;if(f(e)!==e)throw new d({address:e,cause:new p})}}function f(e){if(o.checksum.has(e))return o.checksum.get(e);u(e,{strict:!1});const t=e.substring(2).toLowerCase(),r=s.keccak256(n.fromString(t),{as:"Bytes"}),i=t.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&r[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());const a=`0x${i.join("")}`;return o.checksum.set(e,a),a}function l(e,t={}){const{checksum:r=!1}=t;return u(e),r?f(e):e}class d extends i.BaseError{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}r.InvalidAddressError=d;class h extends i.BaseError{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}r.InvalidInputError=h;class p extends i.BaseError{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}r.InvalidChecksumError=p}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Address.js"}],[5861,{"./Bytes.js":5872,"./Hex.js":5883},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ivLength=void 0,r.decrypt=async function(e,t,i={}){const{as:s=("string"==typeof e?"Hex":"Bytes")}=i,a=n.from(e),c=a.slice(0,r.ivLength),u=a.slice(r.ivLength),f=await globalThis.crypto.subtle.decrypt({name:"AES-GCM",iv:c},t,n.from(u)),l=new Uint8Array(f);return"Bytes"===s?l:o.from(l)},r.encrypt=async function(e,t,i={}){const{as:s=("string"==typeof e?"Hex":"Bytes")}=i,a=n.random(r.ivLength),c=await globalThis.crypto.subtle.encrypt({name:"AES-GCM",iv:a},t,n.from(e)),u=n.concat(a,new Uint8Array(c));return"Bytes"===s?u:o.from(u)},r.getKey=async function(e){const{iterations:t=9e5,password:r,salt:o=i(32)}=e,s=await globalThis.crypto.subtle.importKey("raw",n.fromString(r),{name:"PBKDF2"},!1,["deriveBits","deriveKey"]);return await globalThis.crypto.subtle.deriveKey({name:"PBKDF2",salt:o,iterations:t,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])},r.randomSalt=i;const n=e("./Bytes.js"),o=e("./Hex.js");function i(e=32){return n.random(e)}r.ivLength=16}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AesGcm.js"}],[5862,{"./Hash.js":5881,"./Hex.js":5883,"./Rlp.js":5893,"./Signature.js":5899},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.from=a,r.fromRpc=c,r.fromRpcList=function(e){return e.map(c)},r.fromTuple=u,r.fromTupleList=function(e){const t=[];for(const r of e)t.push(u(r));return t},r.getSignPayload=function(e){return f(e,{presign:!0})},r.hash=f,r.toRpc=l,r.toRpcList=function(e){return e.map(l)},r.toTuple=d,r.toTupleList=function(e){if(!e||0===e.length)return[];const t=[];for(const r of e)t.push(d(r));return t};const n=e("./Hash.js"),o=e("./Hex.js"),i=e("./Rlp.js"),s=e("./Signature.js");function a(e,t={}){return"string"==typeof e.chainId?c(e):{...e,...t.signature}}function c(e){const{address:t,chainId:r,nonce:n}=e,o=s.extract(e);return{address:t,chainId:Number(r),nonce:BigInt(n),...o}}function u(e){const[t,r,n,o,i,c]=e;let u={address:r,chainId:"0x"===t?0:Number(t),nonce:"0x"===n?0n:BigInt(n)};return o&&i&&c&&(u={...u,...s.fromTuple([o,i,c])}),a(u)}function f(e,t={}){const{presign:r}=t;return n.keccak256(o.concat("0x05",i.fromHex(d(r?{address:e.address,chainId:e.chainId,nonce:e.nonce}:e))))}function l(e){const{address:t,chainId:r,nonce:n,...i}=e;return{address:t,chainId:o.fromNumber(r),nonce:o.fromNumber(n),...s.toRpc(i)}}function d(e){const{address:t,chainId:r,nonce:n}=e,i=s.extract(e);return[r?o.fromNumber(r):"0x",t,n?o.fromNumber(n):"0x",...i?s.toTuple(i):[]]}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Authorization.js"}],[5863,{"./Bytes.js":5872,"./Hex.js":5883,"./internal/base58.js":5922},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromBytes=function(e){return i.from(e)},r.fromHex=function(e){return i.from(e)},r.fromString=function(e){return i.from(n.fromString(e))},r.toBytes=function(e){return n.fromHex(s(e))},r.toHex=s,r.toString=function(e){return o.toString(s(e))};const n=e("./Bytes.js"),o=e("./Hex.js"),i=e("./internal/base58.js");function s(e){let t=BigInt(0),r=0,n=!0;for(let o=0;o<e.length;o++){const s=e[o];if(n&&"1"===s?r++:n=!1,"bigint"!=typeof i.alphabetToInteger[s])throw new Error("invalid base58 character: "+s);t*=58n,t+=i.alphabetToInteger[s]}return r?`0x${"0".repeat(2*r)}${t.toString(16)}`:`0x${t.toString(16)}`}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Base58.js"}],[5864,{"./Bytes.js":5872,"./Hex.js":5883},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromBytes=u,r.fromHex=function(e,t={}){return u(n.fromHex(e),t)},r.fromString=function(e,t={}){return u(n.fromString(e),t)},r.toBytes=f,r.toHex=function(e){return o.fromBytes(f(e))},r.toString=function(e){return n.toString(f(e))};const n=e("./Bytes.js"),o=e("./Hex.js"),i=new TextEncoder,s=new TextDecoder,a=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)])),c={...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t])),["=".charCodeAt(0)]:0,["-".charCodeAt(0)]:62,["_".charCodeAt(0)]:63};function u(e,t={}){const{pad:r=!0,url:n=!1}=t,o=new Uint8Array(4*Math.ceil(e.length/3));for(let t=0,r=0;r<e.length;t+=4,r+=3){const n=(e[r]<<16)+(e[r+1]<<8)+(0|e[r+2]);o[t]=a[n>>18],o[t+1]=a[n>>12&63],o[t+2]=a[n>>6&63],o[t+3]=a[63&n]}const i=e.length%3,c=4*Math.floor(e.length/3)+(i&&i+1);let u=s.decode(new Uint8Array(o.buffer,0,c));return r&&1===i&&(u+="=="),r&&2===i&&(u+="="),n&&(u=u.replaceAll("+","-").replaceAll("/","_")),u}function f(e){const t=e.replace(/=+$/,""),r=t.length,n=new Uint8Array(r+3);i.encodeInto(t+"===",n);for(let e=0,r=0;e<t.length;e+=4,r+=3){const t=(c[n[e]]<<18)+(c[n[e+1]]<<12)+(c[n[e+2]]<<6)+c[n[e+3]];n[r]=t>>16,n[r+1]=t>>8&255,n[r+2]=255&t}const o=3*(r>>2)+(r%4&&r%4-1);return new Uint8Array(n.buffer,0,o)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Base64.js"}],[5865,{"./Bytes.js":5872,"@noble/hashes/blake3":4503},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.create=function(){return{root:{type:"empty"}}},r.insert=function(e,t,r){const n=o.slice(t,0,31),s=o.slice(t,31)[0];if("empty"===e.root.type)return e.root=a(n),void(e.root.values[s]=r);e.root=function e(t,r,n,s,u){let f=t;if("empty"===f.type)return f=a(r),f.values[n]=s,f;const l=c(r);if("stem"===f.type)return o.isEqual(f.stem,r)?(f.values[n]=s,f):i(f,l,c(f.stem),n,s,u);if("internal"===f.type)return 0===l[u]?f.left=e(f.left,r,n,s,u+1):f.right=e(f.right,r,n,s,u+1),f;return{type:"empty"}}(e.root,n,s,r,0)},r.merkelize=function(e){return function e(t){if("empty"===t.type)return new Uint8Array(32).fill(0);if("internal"===t.type){const r=e(t.left),n=e(t.right);return u(o.concat(r,n))}let r=t.values.map(u);for(;r.length>1;){const e=[];for(let t=0;t<r.length;t+=2)e.push(u(o.concat(r[t],r[t+1])));r=e}return u(o.concat(t.stem,new Uint8Array(1).fill(0),r[0]))}(e.root)};const n=e("@noble/hashes/blake3"),o=e("./Bytes.js");function i(e,t,r,n,o,c){if(t[c]===r[c]){const a=s();return 0===t[c]?a.left=i(e,t,r,n,o,c+1):a.right=i(e,t,r,n,o,c+1),a}const u=s(),f=t[c],l=function(e){const t=new Uint8Array(e.length/8);for(let r=0;r<e.length;r+=8){let n=0;for(let t=0;t<8;t++)n|=e[r+t]<<7-t;t[r/8]=n}return t}(t);return 0===f?(u.left=a(l),u.left.values[n]=o,u.right=e):(u.right=a(l),u.right.values[n]=o,u.left=e),u}function s(){return{left:{type:"empty"},right:{type:"empty"},type:"internal"}}function a(e){return{stem:e,values:Array.from({length:256},()=>undefined),type:"stem"}}function c(e){const t=[];for(const r of e)for(let e=0;e<8;e++)t.push(r>>7-e&1);return t}function u(e){return e&&e.some(e=>0!==e)?(0,n.blake3)(e):new Uint8Array(32).fill(0)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BinaryStateTree.js"}],[5866,{"./Bytes.js":5872,"./Errors.js":5878,"./Hash.js":5881,"./Hex.js":5883,"./Kzg.js":5886,"./internal/cursor.js":5924},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidVersionedHashVersionError=r.InvalidVersionedHashSizeError=r.EmptyBlobVersionedHashesError=r.EmptyBlobError=r.BlobSizeTooLargeError=r.maxBytesPerTransaction=r.bytesPerBlob=r.fieldElementsPerBlob=r.bytesPerFieldElement=void 0,r.commitmentsToVersionedHashes=u,r.commitmentToVersionedHash=f,r.from=function(e,t={}){const o=t.as??("string"==typeof e?"Hex":"Bytes"),i="string"==typeof e?n.fromHex(e):e,c=n.size(i);if(!c)throw new m;if(c>r.maxBytesPerTransaction)throw new p({maxSize:r.maxBytesPerTransaction,size:c});const u=[];let f=!0,l=0;for(;f;){const e=a.create(new Uint8Array(r.bytesPerBlob));let t=0;for(;t<r.fieldElementsPerBlob;){const n=i.slice(l,l+(r.bytesPerFieldElement-1));if(e.pushByte(0),e.pushBytes(n),n.length<31){e.pushByte(128),f=!1;break}t++,l+=31}u.push(e)}return"Bytes"===o?u.map(e=>e.bytes):u.map(e=>s.fromBytes(e.bytes))},r.sidecarsToVersionedHashes=function(e,t={}){const{version:r}=t,n=t.as??("string"==typeof e[0].blob?"Hex":"Bytes"),o=[];for(const{commitment:t}of e)o.push(f(t,{as:n,version:r}));return o},r.to=l,r.toHex=function(e){return l(e,"Hex")},r.toBytes=function(e){return l(e,"Bytes")},r.toCommitments=d,r.toProofs=h,r.toSidecars=function(e,t){const{kzg:r}=t,n=t.commitments??d(e,{kzg:r}),o=t.proofs??h(e,{commitments:n,kzg:r}),i=[];for(let t=0;t<e.length;t++)i.push({blob:e[t],commitment:n[t],proof:o[t]});return i},r.toVersionedHashes=function(e,t){return u(d(e,t),t)};const n=e("./Bytes.js"),o=e("./Errors.js"),i=e("./Hash.js"),s=e("./Hex.js"),a=e("./internal/cursor.js"),c=e("./Kzg.js");function u(e,t={}){const{version:r}=t,n=t.as??("string"==typeof e[0]?"Hex":"Bytes"),o=[];for(const t of e)o.push(f(t,{as:n,version:r}));return o}function f(e,t={}){const{version:r=1}=t,n=t.as??("string"==typeof e?"Hex":"Bytes"),o=i.sha256(e,{as:"Bytes"});return o.set([r],0),"Bytes"===n?o:s.fromBytes(o)}function l(e,t){const r=t??("string"==typeof e[0]?"Hex":"Bytes"),o="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,i=o.reduce((e,t)=>e+t.length,0),c=a.create(new Uint8Array(i));let u=!0;for(const e of o){const t=a.create(e);for(;u&&t.position<e.length;){t.incrementPosition(1);let r=31;e.length-t.position<31&&(r=e.length-t.position);for(const e in Array.from({length:r})){const e=t.readByte();if(128===e&&!t.inspectBytes(t.remaining).includes(128)){u=!1;break}c.pushByte(e)}}}const f=c.bytes.slice(0,c.position);return"Hex"===r?s.fromBytes(f):f}function d(e,t){const{kzg:r}=t,o=t.as??("string"==typeof e[0]?"Hex":"Bytes"),i="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,a=[];for(const e of i)a.push(Uint8Array.from(r.blobToKzgCommitment(e)));return"Bytes"===o?a:a.map(e=>s.fromBytes(e))}function h(e,t){const{kzg:r}=t,o=t.as??("string"==typeof e[0]?"Hex":"Bytes"),i="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,a="string"==typeof t.commitments[0]?t.commitments.map(e=>n.fromHex(e)):t.commitments,c=[];for(let e=0;e<i.length;e++){const t=i[e],n=a[e];c.push(Uint8Array.from(r.computeBlobKzgProof(t,n)))}return"Bytes"===o?c:c.map(e=>s.fromBytes(e))}r.bytesPerFieldElement=32,r.fieldElementsPerBlob=4096,r.bytesPerBlob=r.bytesPerFieldElement*r.fieldElementsPerBlob,r.maxBytesPerTransaction=6*r.bytesPerBlob-1-1*r.fieldElementsPerBlob*6;class p extends o.BaseError{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.BlobSizeTooLargeError"})}}r.BlobSizeTooLargeError=p;class m extends o.BaseError{constructor(){super("Blob data must not be empty."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.EmptyBlobError"})}}r.EmptyBlobError=m;class g extends o.BaseError{constructor(){super("Blob versioned hashes must not be empty."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.EmptyBlobVersionedHashesError"})}}r.EmptyBlobVersionedHashesError=g;class b extends o.BaseError{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.InvalidVersionedHashSizeError"})}}r.InvalidVersionedHashSizeError=b;class y extends o.BaseError{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${c.versionedHashVersion}`,`Received: ${t}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.InvalidVersionedHashVersionError"})}}r.InvalidVersionedHashVersionError=y}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Blobs.js"}],[5867,{"./Hex.js":5883,"./Transaction.js":5903,"./Withdrawal.js":5917},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.toRpc=function(e,t={}){const r=e.transactions.map(e=>"string"==typeof e?e:o.toRpc(e));return{baseFeePerGas:"bigint"==typeof e.baseFeePerGas?n.fromNumber(e.baseFeePerGas):undefined,blobGasUsed:"bigint"==typeof e.blobGasUsed?n.fromNumber(e.blobGasUsed):undefined,excessBlobGas:"bigint"==typeof e.excessBlobGas?n.fromNumber(e.excessBlobGas):undefined,extraData:e.extraData,difficulty:"bigint"==typeof e.difficulty?n.fromNumber(e.difficulty):undefined,gasLimit:n.fromNumber(e.gasLimit),gasUsed:n.fromNumber(e.gasUsed),hash:e.hash,logsBloom:e.logsBloom,miner:e.miner,mixHash:e.mixHash,nonce:e.nonce,number:"bigint"==typeof e.number?n.fromNumber(e.number):null,parentBeaconBlockRoot:e.parentBeaconBlockRoot,parentHash:e.parentHash,receiptsRoot:e.receiptsRoot,sealFields:e.sealFields,sha3Uncles:e.sha3Uncles,size:n.fromNumber(e.size),stateRoot:e.stateRoot,timestamp:n.fromNumber(e.timestamp),totalDifficulty:"bigint"==typeof e.totalDifficulty?n.fromNumber(e.totalDifficulty):undefined,transactions:r,transactionsRoot:e.transactionsRoot,uncles:e.uncles,withdrawals:e.withdrawals?.map(i.toRpc),withdrawalsRoot:e.withdrawalsRoot}},r.fromRpc=function(e,t={}){if(!e)return null;const r=e.transactions.map(e=>"string"==typeof e?e:o.fromRpc(e));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):undefined,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):undefined,difficulty:e.difficulty?BigInt(e.difficulty):undefined,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):undefined,gasLimit:BigInt(e.gasLimit??0n),gasUsed:BigInt(e.gasUsed??0n),number:e.number?BigInt(e.number):null,size:BigInt(e.size??0n),stateRoot:e.stateRoot,timestamp:BigInt(e.timestamp??0n),totalDifficulty:BigInt(e.totalDifficulty??0n),transactions:r,withdrawals:e.withdrawals?.map(i.fromRpc)}};const n=e("./Hex.js"),o=e("./Transaction.js"),i=e("./Withdrawal.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Block.js"}],[5868,{"./Hex.js":5883,"./Withdrawal.js":5917},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromRpc=function(e){return{...e.baseFeePerGas&&{baseFeePerGas:BigInt(e.baseFeePerGas)},...e.blobBaseFee&&{blobBaseFee:BigInt(e.blobBaseFee)},...e.feeRecipient&&{feeRecipient:e.feeRecipient},...e.gasLimit&&{gasLimit:BigInt(e.gasLimit)},...e.number&&{number:BigInt(e.number)},...e.prevRandao&&{prevRandao:BigInt(e.prevRandao)},...e.time&&{time:BigInt(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(o.fromRpc)}}},r.toRpc=function(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:n.fromNumber(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:n.fromNumber(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:n.fromNumber(e.gasLimit)},..."bigint"==typeof e.number&&{number:n.fromNumber(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:n.fromNumber(e.prevRandao)},..."bigint"==typeof e.time&&{time:n.fromNumber(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(o.toRpc)}}};const n=e("./Hex.js"),o=e("./Withdrawal.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BlockOverrides.js"}],[5869,{"./Bytes.js":5872,"./Hash.js":5881,"./Hex.js":5883},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.contains=function(e,t){const r=n.fromHex(e),i=o.keccak256(t,{as:"Bytes"});for(const e of[0,2,4]){const t=i[e+1]+(i[e]<<8)&2047;if(!(r[255-Math.floor(t/8)]&1<<t%8))return!1}return!0},r.validate=function(e){return i.validate(e)&&256===i.size(e)};const n=e("./Bytes.js"),o=e("./Hash.js"),i=e("./Hex.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Bloom.js"}],[587,{"@metamask/utils":4277,lodash:6352},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=i,t.data=function(e){if(!(0,o.hasProperty)(e,"BridgeStatusController"))return e;const t=e.BridgeStatusController;if(!(0,o.isObject)(t))return global.sentry?.captureException?.(new Error(`Migration ${i}: BridgeStatusController is type '${typeof t}', expected object.`)),e;(0,o.hasProperty)(t,"bridgeStatusState")&&(0,o.isObject)(t.bridgeStatusState)&&(e.BridgeStatusController={...t.bridgeStatusState},delete t.bridgeStatusState);return e}(t.data),t},r.version=void 0;var n=e("lodash"),o=e("@metamask/utils");const i=r.version=155}}},{package:"$root$",file:"app/scripts/migrations/155.ts"}],[5870,{"./Bytes.js":5872,"./Hex.js":5883,"@noble/curves/bls12-381":5842},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.noble=void 0,r.aggregate=function(e){const t="bigint"==typeof e[0]?.x?n.bls12_381.G1:n.bls12_381.G2,r=e.reduce((e,r)=>e.add(new t.ProjectivePoint(r.x,r.y,r.z)),t.ProjectivePoint.ZERO);return{x:r.px,y:r.py,z:r.pz}},r.createKeyPair=function(e={}){const{as:t="Hex",size:r="short-key:long-sig"}=e,n=a({as:t}),o=s({privateKey:n,size:r});return{privateKey:n,publicKey:o}},r.getPublicKey=s,r.randomPrivateKey=a,r.sign=function(e){const{payload:t,privateKey:r,suite:i,size:s="short-key:long-sig"}=e,a=("short-key:long-sig"===s?n.bls12_381.G2:n.bls12_381.G1).hashToCurve(o.from(t),i?{DST:o.fromString(i)}:undefined),c="short-key:long-sig"===s?n.bls12_381.G1:n.bls12_381.G2,u=a.multiply(c.normPrivateKeyToScalar(r.slice(2)));return{x:u.px,y:u.py,z:u.pz}},r.verify=function(e){const{payload:t,suite:r}=e,i=e.publicKey,s=e.signature,a="bigint"==typeof s.x,c=(a?n.bls12_381.G1:n.bls12_381.G2).hashToCurve(o.from(t),r?{DST:o.fromString(r)}:undefined);return n.bls12_381.fields.Fp12.eql(a?n.bls12_381.pairingBatch([{g1:c,g2:new n.bls12_381.G2.ProjectivePoint(i.x,i.y,i.z)},{g1:new n.bls12_381.G1.ProjectivePoint(s.x,s.y,s.z),g2:n.bls12_381.G2.ProjectivePoint.BASE.negate()}]):n.bls12_381.pairingBatch([{g1:new n.bls12_381.G1.ProjectivePoint(i.x,i.y,i.z).negate(),g2:c},{g1:n.bls12_381.G1.ProjectivePoint.BASE,g2:new n.bls12_381.G2.ProjectivePoint(s.x,s.y,s.z)}]),n.bls12_381.fields.Fp12.ONE)};const n=e("@noble/curves/bls12-381"),o=e("./Bytes.js"),i=e("./Hex.js");function s(e){const{privateKey:t,size:r="short-key:long-sig"}=e,o="short-key:long-sig"===r?n.bls12_381.G1:n.bls12_381.G2,{px:s,py:a,pz:c}=o.ProjectivePoint.fromPrivateKey(i.from(t).slice(2));return{x:s,y:a,z:c}}function a(e={}){const{as:t="Hex"}=e,r=n.bls12_381.utils.randomPrivateKey();return"Hex"===t?i.fromBytes(r):r}r.noble=n.bls12_381}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Bls.js"}],[5871,{"./Hex.js":5883,"@noble/curves/bls12-381":5842},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.toBytes=i,r.toHex=function(e){return o.fromBytes(i(e))},r.fromBytes=s,r.fromHex=function(e,t){return s(o.toBytes(e))};const n=e("@noble/curves/bls12-381"),o=e("./Hex.js");function i(e){return new("bigint"==typeof e.z?n.bls12_381.G1:n.bls12_381.G2).ProjectivePoint(e.x,e.y,e.z).toRawBytes()}function s(e){const t=(48===e.length?n.bls12_381.G1:n.bls12_381.G2).ProjectivePoint.fromHex(e);return{x:t.px,y:t.py,z:t.pz}}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BlsPoint.js"}]],[],{});