LavaPack.loadBundle([[649,{"../../../shared/constants/network":8409,"../../../shared/lib/sentry":8586,"@metamask/network-controller":2846,"@metamask/utils":3915,lodash:7067,uuid:8012},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.HYPEREVM_CHAIN_ID=void 0,r.migrate=async function(e,t){e.meta.version=u;const r=(0,o.cloneDeep)(e),d=new Set;try{!function(e,t){const r=function(e){if(!(0,i.hasProperty)(e,"NetworkController"))return(0,a.captureException)(new Error(`Migration ${u}: Invalid NetworkController state: missing NetworkController`)),undefined;const t=e.NetworkController;if(!function(e){if(!(0,i.isObject)(e))return(0,a.captureException)(new Error(`Migration ${u}: Invalid NetworkController state: NetworkController state is not an object: '${typeof e}'`)),!1;if(!(0,i.hasProperty)(e,"networkConfigurationsByChainId"))return(0,a.captureException)(new Error(`Migration ${u}: Invalid NetworkController state: missing networkConfigurationsByChainId property`)),!1;if(!function(e){return(0,i.isObject)(e)&&Object.entries(e).every(([e])=>"string"==typeof e&&(0,i.isHexString)(e))}(e.networkConfigurationsByChainId))return(0,a.captureException)(new Error(`Migration ${u}: Invalid NetworkController state: networkConfigurationsByChainId is not a valid Record<Hex, unknown>`)),!1;if(!(0,i.hasProperty)(e,"selectedNetworkClientId"))return(0,a.captureException)(new Error(`Migration ${u}: Invalid NetworkController state: missing selectedNetworkClientId property`)),!1;if("string"!=typeof e.selectedNetworkClientId)return(0,a.captureException)(new Error(`Migration ${u}: Invalid NetworkController state: selectedNetworkClientId is not a string: '${typeof e.selectedNetworkClientId}'`)),!1;return!0}(t))return undefined;return t}(e);if(r===undefined)return e;const{networkConfigurationsByChainId:o}=r;if((0,i.hasProperty)(o,f)){const r=o[f];if(d=r,!((0,i.isObject)(d)&&(0,i.hasProperty)(d,"chainId")&&"string"==typeof d.chainId&&(0,i.isHexString)(d.chainId)&&(0,i.hasProperty)(d,"rpcEndpoints")&&Array.isArray(d.rpcEndpoints)&&d.rpcEndpoints.every(l)&&(0,i.hasProperty)(d,"name")&&"string"==typeof d.name&&(0,i.hasProperty)(d,"nativeCurrency")&&"string"==typeof d.nativeCurrency&&(0,i.hasProperty)(d,"blockExplorerUrls")&&Array.isArray(d.blockExplorerUrls)&&d.blockExplorerUrls.every(e=>"string"==typeof e)&&(0,i.hasProperty)(d,"defaultRpcEndpointIndex")&&"number"==typeof d.defaultRpcEndpointIndex&&(!(0,i.hasProperty)(d,"defaultBlockExplorerUrlIndex")||(0,i.hasProperty)(d,"defaultBlockExplorerUrlIndex")&&"number"==typeof d.defaultBlockExplorerUrlIndex)))return console.warn(`Migration ${u}: Invalid HyperEVM network configuration, skip the migration`),e;!function(e){if(c.infuraProjectId){const t=`https://hyperevm-mainnet.infura.io/v3/${c.infuraProjectId}`;e.rpcEndpoints.find(e=>e.url===t)||(e.rpcEndpoints.push({failoverUrls:[],networkClientId:(0,s.v4)(),type:"custom",url:t}),e.defaultRpcEndpointIndex=e.rpcEndpoints.length-1)}else(0,a.captureException)(new Error(`Migration ${u}: Infura project ID is not set, skip the HyperEVM RPC part of the migration`));e.rpcEndpoints=e.rpcEndpoints.map(e=>{if(!l(e))return e;if(e.failoverUrls&&Array.isArray(e.failoverUrls)&&e.failoverUrls.length>0)return e;if(!function(e){if(e.type===n.RpcEndpointType.Infura)return!0;const t=/^https:\/\/(.+?)\.infura\.io\/v3\//u,r=e.url.match(t);if(!r)return!1;if(c.infuraProjectId){const t=`https://${r[1]}.infura.io/v3/${c.infuraProjectId}`;return e.url.startsWith(t)}return!0}(e))return e;const t="https://frequent-weathered-arrow.hype-mainnet.quiknode.pro/25c2fcfbd6e500742074432ee9e419a7435f7a24/evm";return t?{...e,failoverUrls:[t]}:e})}(r),t.add("NetworkController")}var d}(r.data,d),e.data=r.data,d.forEach(e=>t.add(e))}catch(e){console.error(e);const t=new Error(`Migration #${u}: ${(0,i.getErrorMessage)(e)}`);(0,a.captureException)(t)}},r.version=void 0;var n=e("@metamask/network-controller"),i=e("@metamask/utils"),o=e("lodash"),s=e("uuid"),a=e("../../../shared/lib/sentry"),c=e("../../../shared/constants/network");const u=r.version=197,f=r.HYPEREVM_CHAIN_ID="0x3e7";function l(e){return(0,i.isObject)(e)&&(0,i.hasProperty)(e,"url")&&"string"==typeof e.url&&(!(0,i.hasProperty)(e,"failoverUrls")||(0,i.hasProperty)(e,"failoverUrls")&&Array.isArray(e.failoverUrls)&&e.failoverUrls.every(e=>"string"==typeof e))}}}},{package:"$root$",file:"app/scripts/migrations/197.ts"}],[6494,{"@firebase/app":971},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"}],[6495,{"@firebase/messaging":975},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"}],[6496,{"@firebase/messaging/sw":976},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"}],[65,{"../../../shared/constants/defi-referrals":8393,"../../../shared/constants/time":8429,"@metamask/json-rpc-engine":2573,loglevel:7077},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ReferralTriggerType=void 0,r.createDefiReferralMiddleware=function(e){return(0,i.createAsyncMiddleware)(async(t,r,n)=>{if(await n(),!function(e){return Boolean(e.origin)&&Boolean(e.tabId)}(t))return;const i=(0,a.getPartnerByOrigin)(t.origin);if(!i)return;const s=`${t.origin}:${t.tabId}`;if(f(t.method)||l(t.method)){let n=!1;if(Array.isArray(r.result)&&r.result.length>0)if(f(t.method)){n=r.result.some(e=>"eth_accounts"===e?.parentCapability)}else n=r.result.every(e=>"string"==typeof e);return void(n&&(h(i.connectionFlow)?(p??(p=function(){const e=new Map,t=setInterval(()=>{const r=Date.now()-c;for(const[t,n]of e.entries())n<=r&&e.delete(t);0===e.size&&(clearInterval(t),e.clear(),p=null)},c);return e}()),p).set(s,Date.now()):e(i,t.tabId,u.NewConnection).catch(e=>{o.default.error(`Failed to handle ${i.name} referral after permissions grant: `,e)})))}h(i.connectionFlow)&&d(t.method)&&"string"==typeof r.result&&p?.has(s)&&(p.delete(s),e(i,t.tabId,u.NewConnection).catch(e=>{o.default.error(`Failed to handle ${i.name} referral after signature grant: `,e)}))})};var n,i=e("@metamask/json-rpc-engine"),o=(n=e("loglevel"))&&n.__esModule?n:{default:n},s=e("../../../shared/constants/time"),a=e("../../../shared/constants/defi-referrals");const c=10*s.SECOND;let u=r.ReferralTriggerType=function(e){return e.NewConnection="new_connection",e.OnNavigateConnectedTab="on_navigate_connected_tab",e.PermittedAccountAdded="permitted_account_added",e}({});const f=e=>"wallet_requestPermissions"===e,l=e=>"eth_requestAccounts"===e,d=e=>"eth_signTypedData_v4"===e,h=e=>"permissions_then_signature"===e;let p=null}}},{package:"$root$",file:"app/scripts/lib/createDefiReferralMiddleware.ts"}],[650,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=198;r.migrate=async(e,t)=>{e.meta.version=i,function(e,t){if(!(0,n.hasProperty)(e,"PreferencesController")||!(0,n.isObject)(e.PreferencesController))return;for(const r of o)(0,n.hasProperty)(e.PreferencesController,r)&&(delete e.PreferencesController[r],t.add("PreferencesController"))}(e.data,t)};const o=["identities","lostIdentities","selectedAddress"]}}},{package:"$root$",file:"app/scripts/migrations/198.ts"}],[651,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=199;r.migrate=async(e,t)=>{e.meta.version=i,function(e,t){if(!(0,n.hasProperty)(e,"PreferencesController")||!(0,n.isObject)(e.PreferencesController))return;if(!(0,n.hasProperty)(e.PreferencesController,"preferences")||!(0,n.isObject)(e.PreferencesController.preferences))return;(0,n.hasProperty)(e.PreferencesController.preferences,"petnamesEnabled")&&(delete e.PreferencesController.preferences.petnamesEnabled,t.add("PreferencesController"))}(e.data,t)}}}},{package:"$root$",file:"app/scripts/migrations/199.ts"}],[652,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=200;r.migrate=async(e,t)=>{e.meta.version=i,function(e,t){if(!(0,n.hasProperty)(e,"PreferencesController")||!(0,n.isObject)(e.PreferencesController))return;if(!(0,n.hasProperty)(e.PreferencesController,"preferences")||!(0,n.isObject)(e.PreferencesController.preferences))return;(0,n.hasProperty)(e.PreferencesController.preferences,"showDefaultAddress")&&!1===e.PreferencesController.preferences.showDefaultAddress&&(e.PreferencesController.preferences.showDefaultAddress=!0,t.add("PreferencesController"))}(e.data,t)}}}},{package:"$root$",file:"app/scripts/migrations/200.ts"}],[6527,{},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"}],[653,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=201;r.migrate=async(e,t)=>{e.meta.version=i,function(e,t){if(!(0,n.hasProperty)(e,"SnapsRegistry")||!(0,n.isObject)(e.SnapsRegistry))return;const{SnapsRegistry:r}=e;e.SnapRegistryController=r,delete e.SnapsRegistry,t.add("SnapRegistryController"),t.add("SnapsRegistry")}(e.data,t)}}}},{package:"$root$",file:"app/scripts/migrations/201.ts"}],[654,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=202;r.migrate=async(e,t)=>{e.meta.version=i,(0,n.hasProperty)(e.data,"PreferencesController")&&(0,n.isObject)(e.data.PreferencesController)&&(0,n.hasProperty)(e.data.PreferencesController,"useBlockie")&&(delete e.data.PreferencesController.useBlockie,t.add("PreferencesController"))}}}},{package:"$root$",file:"app/scripts/migrations/202.ts"}],[6541,{"@ethereumjs/rlp":6543,"@metamask/eth-sig-util":2352,"aes-js":6001,bech32:6105,"bignumber.js":6559,"bn.js":6112,bs58check:6561,buffer:6163,cbor:6186,"cbor-bigdecimal":6562,"crc-32":6247,elliptic:6350,"hash.js/lib/hash/ripemd.js":6737,"lodash/inRange.js":7047,"lodash/isEmpty.js":7053,"lodash/isInteger.js":7056,ox:6649,secp256k1:6650,uuid:8012,viem:8200,zod:6653},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 i,o=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 i of c(t))f.call(e,i)||i===r||s(e,i,{get:()=>t[i],enumerable:!(n=a(t,i))||n.enumerable});return e},d=(e,t,r)=>(r=null!=e?o(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:()=>N,Client:()=>Un,Constants:()=>R,Utils:()=>dt,addAddressTags:()=>ei,connect:()=>gi,fetchActiveWallets:()=>pi,fetchAddress:()=>Ln,fetchAddressTags:()=>ti,fetchAddresses:()=>Dn,fetchAddressesByDerivationPath:()=>Yn,fetchBip44ChangeAddresses:()=>Zn,fetchBtcLegacyAddresses:()=>zn,fetchBtcLegacyChangeAddresses:()=>Hn,fetchBtcSegwitAddresses:()=>Gn,fetchBtcSegwitChangeAddresses:()=>qn,fetchBtcWrappedSegwitAddresses:()=>Fn,fetchBtcWrappedSegwitChangeAddresses:()=>$n,fetchBtcXpub:()=>Jn,fetchBtcYpub:()=>Xn,fetchBtcZpub:()=>Qn,fetchLedgerLegacyAddresses:()=>Kn,fetchLedgerLiveAddresses:()=>Wn,fetchSolanaAddresses:()=>Vn,getClient:()=>fe,pair:()=>bi,parseDerivationPath:()=>me,removeAddressTags:()=>ri,setup:()=>mi,sign:()=>si,signAuthorization:()=>ci,signAuthorizationList:()=>ui,signBtcLegacyTx:()=>fi,signBtcSegwitTx:()=>li,signBtcWrappedSegwitTx:()=>di,signMessage:()=>ai,signSolanaTx:()=>hi}),t.exports=(i=h,l(s({},"__esModule",{value:!0}),i));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 i=k[n[1]];if(n[2]&&(i=`${i}${8*n[2]}`),n[3].length>0&&n[3].forEach(e=>{i=0===n[3][e]?`${i}[]`:`${i}[${n[3][e]}]`}),n[4]){const e=y(n[4]);i=`${i}(${e.join(",")})`}t.push(i)}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(j)}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 i=[];for(;r.length>0;){const e=w(r);r=r.slice(e.length+1),i=i.concat(E(e))}if(!i.length)throw new Error(j);return[t,i]}function v(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r=!1;if(k.forEach((n,i)=>{if(e.indexOf(n)>-1&&!r){t.typeIdx=i,t.arraySzs=S(e);const o=t.arraySzs.length>0?e.indexOf("["):e.length,s=e.slice(n.length,o);if(parseInt(s)&&(t.szBytes=parseInt(s)/8,t.szBytes>32))throw new Error(j);r=!0}}),!r)throw new Error(j);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:i}=function(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r;k.forEach((n,i)=>{e.indexOf(n)>-1&&!r&&(r=n,t.typeIdx=i)}),t.arraySzs=S(e);const n=t.arraySzs.length>0?e.indexOf("["):e.length;if(["uint","int","bytes"].indexOf(r)>-1){const i=parseInt(e.slice(r.length,n))||0;if(i>256)throw new Error("Invalid param size");t.szBytes=i/8}else t.szBytes=0;return t}(e.type);return t.push(r),t.push(n),t.push(i),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,i)=>{Array.isArray(e)?r[r.length-1].push(B(e,`${i}-`)):r.push([`#${t}${i+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),i=n.indexOf("]");if(i<0)throw new Error("Bad param type");const o=n.slice(1,i);0===o.length?t.push(0):t.push(parseInt(o)),r=n.slice(i+1)}return t}function P(e,t=!0){let r=0,n=!1;for(let i=0;i<e.length;i++){"("===e[i]?(r+=1,n=!0):")"===e[i]&&(r-=1);let o=","===e[i+1]||")"===e[i+1]||i===e.length-1;if(t||"["!==e[i+1]||(o=!0),!r&&n&&o)return e.slice(0,i+1)}throw new Error(j)}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 _(e){return T(e)&&1===e[3].length&&0===e[3][0]}var j="Could not parse canonical function name.",k=[null,"address","bool","uint","int","bytes","string","tuple","nestedDef"],N={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(j);r.push(t.slice(0,n)),t=t.slice(n+1);let i=[];for(;t.length>1;){const e=w(t);i=i.concat(E(e)),t=t.slice(e.length+1)}const o=B(i);return r.concat(o)}},processors:{getNestedCalldata:function(e,t){const n=[],i=e.slice(1),o=y(i),s="0x"+t.slice(4).toString("hex"),a=o.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(i[t])){let o=!0;if(_(i[t]))Array.isArray(e)?e.forEach(e=>{if("string"!=typeof e||!e.startsWith("0x"))return void(o=!1);u(r.from(e.slice(2),"hex"))||(o=!1)}):o=!1;else if(A(i[t]))if("string"==typeof e&&e.startsWith("0x")){const t=e,n=r.from(t.slice(2),"hex");o=u(n)}else o=!1;else o=!1;n.push(o?e:null)}else n.push(null)}),n},replaceNestedDefs:function(e,t){for(let r=0;r<t.length;r++){const n=_(e[1+r]),i=A(e[1+r]);if(null!==t[r]&&(n||i)){e[1+r][1]=k.indexOf("nestedDef");const i=n?t[r]:[t[r]];e[1+r]=e[1+r].concat([i])}}return e}}}},O={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,G,F,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'",ie=[U+44,U+501,U,U],oe=[U+49,U+60,U,0,0],se=[U+49,U+60,U,0],ae=()=>F,ce=e=>{F=e},ue=async e=>{const t=await G();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=G?await G():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 i=new Un({stateData:n});if(!i)throw new Error("Client not initialized");return i},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),_e=e("viem"),je=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},Ne=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},Oe=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:Ge}=Ae.default,{COINS:Fe,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 i=0;for(let o=0;o<n;o++)r.push(e.slice(i,i+t)),i+=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(O.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 i=e[t];t++;return{r:n,s:e.slice(t,t+i)}},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=N.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),i=await r.match(n);if(i)return i;{const e=await fetch(n,t),i=e.clone(),o=await e.json();return e.ok&&((e=>{try{const t=JSON.parse(e.result);return!(0,je.default)(t)}catch(e){return console.error("Invalid block explorer response:",e),!1}})(o)||(e=>{try{return!(0,je.default)(e.results)}catch(e){return console.error("Invalid 4byte response:",e),!1}})(o))?(await r.put(n,i),r.match(n)):e}}return fetch(e,t)}catch(e){throw console.error(e),e}}async function it(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 ot(e){return xe.Buffer.from(ye.RLP.encode(e))}async function st(e,t){const r=N.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 it(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 it(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 N.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 i="string"==typeof e&&"0x"===e.slice(0,2)?xe.Buffer.from(e.slice(2),"hex"):xe.Buffer.from(e,"hex");if(0===i.length)return{def:null,abi:null};if(i.length<4)throw new Error("Data must contain at least 4 bytes of data to define the selector");const o=xe.Buffer.from(i.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=N.EVM.parsers.parseSolidityJSONABI(o,e).def;return n&&(r=await st(r,i)),{abi:e,def:ot(r)}}throw new Error(`Chain (id: ${s}) is not supported`)}catch(e){console.warn(e.message,"\n","Falling back to 4byte")}const u=await it(o);let f=rt(u,o);return n&&(f=await st(f,i)),{abi:u,def:ot(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,i="string"==typeof t?xe.Buffer.from(t):t,o="string"==typeof r?xe.Buffer.from(r):r,s=xe.Buffer.concat([n,i,o]);return xe.Buffer.from(Pe.Hash.sha256(s))},ut=function(e,t){let r,n,i,o=!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,_e.parseTransaction)(t);if(i=e.type,void 0!==e.chainId&&null!==e.chainId&&(r=e.chainId.toString(),"legacy"===i&&(o=!0)),"legacy"===i&&!o){const e=ye.RLP.decode(s);if(e.length>=9){const t=e[6];t&&t.length>0&&(r=new ve.BN(t).toString(),o=!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(i="legacy",n.length>=9){const e=n[6];e&&e.length>0&&(r=new ve.BN(e).toString(),o=!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(Ge(c,0,n,l)),p=xe.Buffer.from(Ge(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:o,type:i});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:i}=t;return 1===i||2===i||4===i||"eip2930"===i||"eip1559"===i||"eip7702"===i?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 i=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")},o=i(n),s=i(t.r),a=i(t.s),c=i(r),u=32===o.length?o:xe.Buffer.from(Pe.Hash.keccak256(o)),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=Ge(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 _t(e,t){return r.concat([e,t])}function jt(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 Nt(e,t,n){"number"==typeof e&&(e=e.toString(16));const i=r.alloc(8),o=e.length%2==0?e.toString(16):`0${e.toString(16)}`;return r.from(o,"hex").reverse().copy(i,0),i.copy(t,n),i}function Ot(e){let t,n;try{t=mt.default.decode(e)[0],n=r.from(mt.default.decode(e).slice(1))}catch(i){console.error("Failed to decode base58 address, trying bech32:",i);try{const i=pt.bech32.decode(e);if("bc"===i.prefix)t=Tt;else{if("tb"!==i.prefix)throw new Error("Unsupported prefix: must be bc or tb.");t=At}if(0!==i.words[0])throw new Error(`Unsupported segwit version: must be 0, got ${i.words[0]}`);if(33!==i.words.length){const t=53===i.words.length;throw new Error(`Unsupported address${t?" (P2WSH not supported)":""}: ${e}`)}n=r.from(pt.bech32.fromWords(i.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:i,changePath:o,fee:s}=e;if(!o)throw new Error("No changePath provided.");if(5!==o.length)throw new Error("Please provide a full change path.");const a=r.alloc(59+69*t.length);let c=0;const u=Rt(o);a.writeUInt8(u,0),c++,a.writeUInt32LE(o.length,c),c+=4;for(let e=0;e<o.length;e++)a.writeUInt32LE(o[e],c),c+=4;a.writeUInt32LE(s,c),c+=4;const f=Ot(n);a.writeUInt8(f.versionByte,c),c++,f.pkh.copy(a,c),c+=f.pkh.length,Nt(i,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,Nt(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-(i+s)}}},serializeTx:function(e){const{inputs:t,outputs:n,lockTime:i=0}=e;let o=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);o.writeUInt32LE(2,s),s+=4,a&&(o=_t(o,r.from("00","hex")),o=_t(o,r.from("01","hex")));const c=kt(t.length);o=_t(o,c),s+=c.length,t.forEach(e=>{o=_t(o,e.hash.reverse()),s+=e.hash.length;const t=jt(e.index);o=_t(o,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)),i=r.from((0,bt.ripemd160)().update(n).digest("hex"),"hex");return t.writeUInt8(vt,0),t.writeUInt8(i.length,1),i.copy(t,2),t}(e.pubkey),n=kt(t.length),i=r.concat([n,t]),a=kt(i.length);o=_t(o,a),s+=a.length,o=_t(o,i),s+=i.length}else if(1===n){const t=function(e,t){const n=kt((e=r.concat([e,yt])).length),i=kt(t.length),o=r.concat([n,e,i,t]),s=kt(o.length);return r.concat([s,o])}(e.sig,e.pubkey);o=_t(o,t),s+=t.length}else if(4===n){const e=r.from("00","hex");o=_t(o,e),s+=1}const i=jt(4294967295);o=_t(o,i),s+=i.length});const u=kt(n.length);if(o=_t(o,u),s+=u.length,n.forEach(e=>{const t=function(e){const t=r.alloc(8);return Nt(e,t,0),t}(e.value);o=_t(o,t),s+=t.length;const n=function(e){const t=Ot(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),i=kt(n.length);o=_t(o,i),s+=i.length,o=_t(o,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 i=function(e,t){let n=r.alloc(0);const i=r.alloc(1);i.writeUInt8(2,0);for(let o=0;o<e.length;o++){const s=r.concat([e[o],yt]),a=kt(s.length),c=t[o],u=kt(c.length);n=r.concat([n,i,a,s,u,c])}return n}(e,n);o=_t(o,i),s+=i.length}return r.concat([o,jt(i)]).toString("hex")},getBitcoinAddress:function(e,t){let n=null,i=null;if(t===Tt?(n="bc",i=0):t===At&&(n="tb",i=0),null!==n&&null!==i){const t=pt.bech32.toWords(e);return t.unshift(i),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"),Gt=d(e("secp256k1"),1),Ft=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:i,encodingType:o=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,o,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(i,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(i!==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 _=r.alloc(w);let j=0;_.writeUInt32LE(x,j),j+=4,_.writeUInt8(i,j),j+=1,_.writeUInt8(n,j),j+=1;const k=Xe(t,p);k.copy(_,j),j+=k.length,_.writeUInt8(a?1:0,j),j+=1;const N=[];let O=null,C=!1;if(B.length>y)if(d&&B.length>I){_.writeUInt16LE(B.length,j),j+=2,C=!0;const e=B.slice(0,P);if(i===b.NONE)throw new Error("Message too large to send and could not be prehashed (hashType=NONE).");if(i===b.KECCAK256)O=r.from(Yt.Hash.keccak256(e));else{if(i!==b.SHA256)throw new Error("Unsupported hash type.");O=r.from(Yt.Hash.sha256(e))}}else{$e(B.slice(y),f).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),N.push(r.concat([t,e]))})}C||(_.writeUInt16LE(P,j),j+=2);return(O||B).copy(_,j),{payload:_,extraDataPayloads:N,schema:5,curveType:n,encodingType:o,hashType:i,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")}`,i=(0,Xt.parseTransaction)(n),o={chainId:i.chainId,to:i.to??void 0,value:i.value??0n,data:i.data??"0x",nonce:i.nonce??0n,gas:i.gas??i.gasLimit??0n};void 0!==i.maxFeePerGas&&(o.maxFeePerGas=i.maxFeePerGas),void 0!==i.maxPriorityFeePerGas&&(o.maxPriorityFeePerGas=i.maxPriorityFeePerGas),void 0!==i.gasPrice&&(o.gasPrice=i.gasPrice),void 0!==i.accessList&&(o.accessList=i.accessList),void 0!==i.authorizationList&&(o.authorizationList=i.authorizationList),void 0!==i.type&&null!==i.type&&(o.type=i.type);const s="legacy"===i.type||void 0===i.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)(o,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 i;if(!e)throw new Error("No payload included");return i="string"==typeof e&&"0x"===e.slice(0,2)?r.from(e.slice(2),"hex"):r.from(e),{payloadBuf:i,encoding:t}},nr=e("zod"),ir=e("viem"),or=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,ir.isHex)(e)?(0,ir.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=or.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,ir.isHex)(e)?Number((0,ir.hexToBigInt)(e)):Number(e)).refine(e=>Number.isInteger(e)&&e>0,{message:"Chain ID must be a positive integer"}),cr=nr.z.string().refine(ir.isAddress,"Invalid address").transform(e=>(0,ir.getAddress)(e)),ur=nr.z.string().refine(ir.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,ir.isHex)(e)?(0,ir.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(ir.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(ir.isHex).optional(),s:nr.z.string().refine(ir.isHex).optional()}),hr=nr.z.object({to:cr.optional(),value:or.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,i=!!e.gasPrice;let o="legacy",s=pr;if("eip7702"===e.type||4===e.type||5===e.type||t?(o="eip7702",s=br):"eip1559"===e.type||2===e.type||r?(o="eip1559",s=gr):("eip2930"===e.type||1===e.type||n)&&(o="eip2930",s=mr),"legacy"===o&&!i)throw new Error("Legacy transactions require a `gasPrice` field.");const a=s.parse(e);return a.type=o,"legacy"===o&&void 0===a.gas&&(a.gas=21000n),"legacy"!==o&&"eip2930"!==o&&delete a.gasPrice,"eip1559"!==o&&"eip7702"!==o&&(delete a.maxFeePerGas,delete a.maxPriorityFeePerGas),delete a.gasLimit,"eip7702"!==o&&delete a.authorizationList,a}),{ecdsaRecover:wr}=Gt.default;(0,Ht.default)(Ft.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,i={}){try{const o=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,o,!1).slice(1);const d=s.toString("hex"),h=[];let p=Ir(l);if(h.push(p),p===d)return t.v=Tr(a,i),t;if(a=1,l=wr(f,a,o,!1).slice(1),p=Ir(l),h.push(p),p===d)return t.v=Tr(a,i),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 _r(e){let t,n;if(t=!0===jr(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 jr(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:i,extraDataMaxFrames:o}=t.fwConstants,s=n,a=i>0&&o>0,c=[];if(e.length>s){const t=s+o*i;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),i).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),c.push(r.concat([t,e]))})}return c}function Nr(e,t,r,n=!1){return r[t].forEach(t=>{const i=t.type.indexOf("[")>-1,o=i?t.type.slice(0,t.type.indexOf("[")):t.type,s=Object.keys(r).indexOf(o)>-1;if(s&&Array.isArray(e))for(let i=0;i<e.length;i++)e[i][t.name]=Nr(e[i][t.name],o,r,n);else if(s)e[t.name]=Nr(e[t.name],o,r,n);else if(Array.isArray(e))for(let r=0;r<e.length;r++)if(i)for(let i=0;i<e[r][t.name].length;i++)e[r][t.name][i]=Or(e[r][t.name][i],o,n);else e[r][t.name]=Or(e[r][t.name],o,n);else if(i)for(let r=0;r<e[t.name].length;r++)e[t.name][r]=Or(e[t.name][r],o,n);else e[t.name]=Or(e[t.name],o,n)}),e}function Or(e,t,n=!1){if("bytes"===t)e=Ve(e),n&&(e=`0x${e.toString("hex")}`);else if("bytes"===t.slice(0,5)){const i=parseInt(t.slice(5));if(0===(e=Ve(e)).length&&(e=r.alloc(i)),e.length!==i)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,i=t.fwConstants.varAddrPathSzAllowed,o=24+n+4;let s=0;e.payload=r.alloc(o),e.payload.writeUInt8(M.SIGN_PERSONAL,0),s+=1;const a=Xe(t.signerPath,i);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:i,eip712MaxTypeParams:o}=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,i);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=Nr(vr(f.message),vr(f.primaryType),vr(f.types),!0),l.domain=Nr(vr(f.domain),"EIP712Domain",vr(f.types),!0),e.validationPayload=l,f.domain=Nr(f.domain,"EIP712Domain",f.types,!1),f.message=Nr(f.message,f.primaryType,f.types,!1);const d=r.from(Ft.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>o&&(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:i}=e,{input:o,msg:s,prehash:a=null}=t;if("signPersonal"===o.protocol){return Pr(a||r.from(Mt.Hash.keccak256(r.concat([Rr(s.length),s]))),i,n,{chainId:1,useEIP155:!1})}if("eip712"===o.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=o.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,i,n,{chainId:u,useEIP155:!1})}throw new Error("Unsupported protocol")},zr=function(e){try{let{chainId:t=1}=e;const{signerPath:n,eip155:i=null,fwConstants:o,type:s=null}=e,{contractDeployKey:a,extraDataFrameSz:c,extraDataMaxFrames:u,prehashAllowed:f}=o,l=c>0&&u>0,d=o.ethMaxDataSz,h=o.varAddrPathSzAllowed;if("number"!=typeof t&&!1===jr(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=o.allowedEthTxTypes&&o.allowedEthTxTypes.indexOf(2)>-1,g=o.allowedEthTxTypes&&o.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!==i&&"boolean"==typeof i?w=i:(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`");_=Ve(e.maxPriorityFeePerGas),E.push(_),j=Ve(e.maxFeePerGas),E.push(j),B=j}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 N=122,O=r.alloc(d+N);let R,C=0;O.writeUInt8(Number(w),C),C++;let U=0;if(!0===function(e){const t=_r(e);return 1!==t.length||255===t.readUInt8(0)}(t)){if(R=_r(t),U=R.length,U>8)throw new Error("ChainID provided is too large.");O.writeUInt8(255,C),C++}else{if(R=Ve(t),1!==R.length)throw new Error("Error parsing chainID");R.copy(O,C),C+=R.length}const D=Xe(n,h);if(D.copy(O,C),C+=D.length,x.length>4)throw new Error("Nonce too large");if(x.copy(O,C+(4-x.length)),C+=4,B.length>8)throw new Error("Gas price too large");if(B.copy(O,C+(8-B.length)),C+=8,S.length>4)throw new Error("Gas limit too large");if(S.copy(O,C+(4-S.length)),C+=4,20!==I.length)throw new Error("Invalid `to` address");if(I.copy(O,C),C+=20,T.length>32)throw new Error("Value too large");T.copy(O,C+(32-T.length)),C+=32;let L=!1;if(o.allowedEthTxTypes)if(k&&(L=!0),O.writeUInt8(L?1:0,C),C+=1,b){if(O.writeUInt8(2,C),C+=1,_.length>8)throw new Error("maxPriorityFeePerGasBytes too large");_.copy(O,C+(8-_.length)),C+=8}else y?(O.writeUInt8(1,C),C+=1,C+=8):C+=9;const M=[];let z=null;const G=A.length||0,F=U>0?U+1:0,H=r.alloc(G+F);if(F>0&&(H.writeUInt8(U,0),R.copy(H,1)),A.copy(H,F),G>d){const e=G+F,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-F} 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 O.writeUInt16BE(A.length,C),C+=2,U>0&&(O.writeUInt8(U,C),C++,R.copy(O,C),C+=U),z?(z.copy(O,C),C+=d):(A.slice(0,d).copy(O,C),C+=d),{rawTx:E,type:s,payload:O.slice(0,C),extraDataPayloads:M,schema:1,chainId:t,useEIP155:w,signerPath:n}}catch(e){return{err:e.message}}},Gr=function(e,t,n){const i=Pr(r.from(Mt.Hash.keccak256(Cr(e.rawTx,e.type))),t,n,e),o=e.useEIP155?e.rawTx.slice(0,-3):e.rawTx;o.push(i.v),o.push(Sr(i.r)),o.push(Sr(i.s));const s=r.from(zt.RLP.encode(o)),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:i}},Fr=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(`${O.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),i=r.from(n,"hex");if(!0===t){const e=i.slice(1,33).reverse(),t=i.slice(33,65).reverse();return r.concat([i[0],e,t])}return i},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,i=setTimeout(()=>n.abort(),r),o=await fetch(e,{...t,signal:n.signal});return clearTimeout(i),o}(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 i=r.readUInt8(n);if(n++,1!==i)return t.errorMessage="Incorrect protocol version. Please update your SDK",t;const o=r.readUInt8(n);if(n++,0!==o)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=O.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 i=>{if(i instanceof qr){const s=i.errorMessage,a=i.responseCode;if((s||a)&&r){if((e=>130===e||137===e)(a))await(o=3e3,new Promise(e=>setTimeout(e,o)));else if((e=>138===e)(a)&&!n.skipRetryOnWrongWallet)await n.fetchActiveWallet();else{if(!(e=>142===e)(a))throw i;await n.connect(n.deviceId)}return Zr({fn:e,params:t,retries:r-1,client:n})}}var o;throw i}),{msgSizes:Yr}=O,{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}),i=en(et(4),1,n),o=await Wr({url:e,payload:i});if(o.length!==Jr.payload.response.connect-1)throw new Error("Wrong Lattice response message size.");return o}async function Qr({data:e,requestType:t,sharedSecret:n,ephemeralPub:i,url:o}){const s=et(4),a=function({data:e,requestType:t,ephemeralPub:n,sharedSecret:i}){if(e.length>Jr.data.request.encrypted.encryptedData)throw new Error("Encrypted request data too large");De(n);const o=Jr.data.request.encrypted[t];if(e.length!==o)throw new Error(`Invalid request datasize (wanted ${o}, got ${e.length})`);const s=r.alloc(1+o);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(O.aesIv),n=new we.default.ModeOfOperation.cbc(t,r),i=e.length%16==0?e:we.default.padding.pkcs7.pad(e);return xe.Buffer.from(n.encrypt(i))}(c,i),f=(e=>{const t=r.from(ht.Hash.sha256(e));return parseInt(t.slice(0,4).toString("hex"),16)})(i),l=r.alloc(Jr.payload.request.encrypted-1);return l.writeUInt32LE(f),u.copy(l,4),l}({data:e,requestType:t,ephemeralPub:i,sharedSecret:n}),c=en(s,2,a),u=await Wr({url:o,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),i=65,o=i+Jr.data.response.encrypted[t],s={ephemeralPub:n.slice(0,i),data:n.slice(i,o),checksum:n.readUInt32BE(o)},a=qe(n.slice(0,o));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 i=1===t&&n.length===Jr.payload.request.connect-1,o=2===t&&n.length===Jr.payload.request.encrypted-1;let s,a=Yr.header+Yr.checksum;const c={requestType:t,data:n};if(i)s=Jr.payload.request.connect;else{if(!o)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:i,sharedSecret:o,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:o,ephemeralPub:s,url:i});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:i})=>{const o=r.alloc(1+139*i.kvActionMaxNum);o.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},i);o.writeUInt32LE(0,s),s+=4,o.writeUInt32LE(t,s),s+=4,o.writeUInt8(n?1:0,s),s+=1,o.writeUInt8(String(c).length+1,s),s+=1,r.from(String(c)).copy(o,s),s+=i.kvKeyMaxStrSz+1,o.writeUInt8(String(u).length+1,s),s+=1,r.from(String(u)).copy(o,s),s+=i.kvValMaxStrSz+1}),o};async function on({client:e,id:t}){const{deviceId:r,key:n,baseUrl:i}=sn({deviceId:t,key:e.key,baseUrl:e.baseUrl}),o=`${i}/${r}`,s=await Xr({url:o,pubkey:e.publicKey}),{isPaired:a,fwVersion:c,activeWallets:u,ephemeralPub:f}=await an(s,n);return e.mutate({deviceId:r,ephemeralPub:f,url:o,isPaired:a,fwVersion:c,activeWallets:u}),a&&!(e=>((e,t)=>{const{major:r,minor:n,fix:i}=e,{major:o,minor:s,fix:a}=t;return r>o||r>=o&&n>s||r>=o&&n>=s&&i>=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),i=Me(t),o=(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:i,baseUrl:o}},an=(e,t)=>{let n=0;const i=e.readUInt8(n)===O.pairingStatus.paired;n++;const o=e.slice(n,n+65).toString("hex");n+=65;const s=Je(o),a=e.slice(n,n+4);if(n+=4,i){const o=e.slice(n,n+160);n+=160;const c=((e,t)=>r.from(e.derive(t.getPublic()).toArray("be",32)))(t,s),u=Ke(o,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:i,fwVersion:a,activeWallets:f,ephemeralPub:s}}return{isPaired:i,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:i,ephemeralPub:o,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:i,ephemeralPub:o,url:n});return e.mutate({ephemeralPub:f}),mn({data:u,schema:t,params:r})}var hn=({params:e})=>{Oe(e.path)},pn=({schema:e,params:t,fwVersion:n,activeWallet:i})=>{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=i.uid;const o=r.alloc(1025);let s=0;if(o.writeUInt8(e,s),s+=1,e===un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4){t.walletUID.copy(o,s),s+=t.walletUID.length,o.writeUInt8(t.path.length,s),s+=1;for(let e=0;e<5;e++)e<=t.path.length&&o.writeUInt32LE(t.path[e],s),s+=4;return t.c&&o.writeUInt32LE(t.c,s),s+=4,o}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:i,SALT:o,CHECKSUM:s,IV:a,PUBKEY:c}=ln,u=4+i+o+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+i),n+=i,t.salt=e.slice(n,n+o),n+=o,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:i,checksum:o,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:i.toString("hex")},message:""},checksum:{function:"sha256",params:{},message:o.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:i}=Ue(e),{decryptedData:o,newEphemeralPub:s}=await Qr({data:r.alloc(0),requestType:4,sharedSecret:n,ephemeralPub:i,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(o));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:i}){const{url:o,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:i}),{decryptedData:p,newEphemeralPub:m}=await Qr({data:h,requestType:1,sharedSecret:s,ephemeralPub:a,url:o});return e.mutate({ephemeralPub:m}),xn(p,d)}var En=({startPath:e,n:t,flag:r})=>({startPath:Oe(e),n:Ne(t),flag:ke(r)}),vn=({startPath:e,n:t,flag:n,fwConstants:i,wallet:o,iterIdx:s})=>{if(!((i.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=[Fe.ETH,Fe.BTC,Fe.BTC_TESTNET];return!((e[1]===Fe.BTC||e[1]===Fe.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,i))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;o.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,i=[],o=3===t||4===t||5===t;o&&(r+=1);const s=O.msgSizes.secure.data.response.encrypted[1];for(;r<s;)if(o){const o=e.slice(r,r+n),s=o.every(e=>0===e);s||4!==t?s||5!==t?s||i.push(o):i.push(o.slice(0,48)):i.push(o.slice(0,32)),r+=n}else{const t=e.slice(r,r+O.addrStrLen);r+=O.addrStrLen;const n=t.indexOf(0);if(n>0){const e=t.slice(0,n).toString().replace(/[\x00-\x1F\x7F-\x9F]/g,"");i.push(e)}}return i};async function Bn({client:e,type:t,n:r,start:n}){const{url:i,sharedSecret:o,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:o,ephemeralPub:s,url:i});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 i=r.alloc(9);return i.writeUInt32LE(e,0),i.writeUInt8(t,4),i.writeUInt32LE(n,5),i},In=(e,t)=>{let r=0;const n=e.readUInt32BE(r);r+=4;const i=parseInt(e.slice(r,r+1).toString("hex"),16);if(r+=1,i>t.kvActionMaxNum)throw new Error("Too many records fetched. Firmware error.");const o=[];for(let n=0;n<i;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 i=parseInt(e.slice(r,r+1).toString("hex"),16);r+=1,n.key=e.slice(r,r+i-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,o.push(n)}return{records:o,total:n,fetched:i}};async function Tn({client:e,pairingSecret:t}){const{url:r,sharedSecret:n,ephemeralPub:i,appName:o,key:s}=Ue(e),a=An({pairingSecret:t,key:s,appName:o}),{newEphemeralPub:c}=await Qr({data:a,requestType:0,sharedSecret:n,ephemeralPub:i,url:r});return e.mutate({ephemeralPub:c,isPaired:!0}),await e.fetchActiveWallet(),e.hasActiveWallet()}var An=({key:e,pairingSecret:t,appName:n})=>{const i=$r(e),o=r.alloc(25);t.length>0&&o.write(n);const s=ct(i,o,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([o,a])};async function _n({client:e,type:t,ids:r}){const{url:n,sharedSecret:i,ephemeralPub:o,fwConstants:s}=Ue(e),{type:a,ids:c}=jn({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:i,ephemeralPub:o,url:n});return e.mutate({ephemeralPub:l}),f}var jn=({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 i=r.alloc(5+4*e.kvRemoveMaxNum);i.writeUInt32LE(t,0),i.writeUInt8(n.length,4);for(let e=0;e<n.length;e++){const t=parseInt(n[e]);i.writeUInt32LE(t,5+4*e)}return i},Nn=e("ox");async function On({client:e,data:t,currency:r,cachedData:n,nextCode:i}){try{const{url:o,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:i}),{decryptedData:p,newEphemeralPub:m}=await Qr({data:d,requestType:3,sharedSecret:s,ephemeralPub:a,url:o});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:i,nextCode:o})=>{let s,a,c=0;const u=n;if(i&&o){const e=i,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([o,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:i})=>{let o=0;if(i===C.BTC){const n=t,i=20,s=760,a=Ut.getAddressFormat(n.origData.changePath),c=e.slice(o,o+i);o+=i;const u=Ut.getBitcoinAddress(c,a),f=33,l=[],d=[];let h=0;for(;o<e.length&&48===e[o];){const t=o,r=o+2+e[o+1];d.push(e.slice(t,r)),o+=74;const n=h*f+s,i=(h+1)*f+s;l.push(e.slice(n,i)),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(Nn.Hash.sha256(r.from(g,"hex")));return{tx:m,txHash:`0x${r.from(Nn.Hash.sha256(b)).toString("hex")}`,changeRecipient:u,sigs:d}}if(i!==C.ETH||n){if(i===C.ETH_MSG){const r=Ze(e.slice(o,o+2+e[o+1]));o+=74;const n=e.slice(o,o+20),i=Mr({signer:n,sig:r},t);return{sig:{v:BigInt(`0x${i.v.toString("hex")}`),r:`0x${i.r.toString("hex")}`,s:`0x${i.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}return function(e,t,n){const i={pubkey:null,sig:null};let o;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)i.pubkey=r.alloc(33),i.pubkey.writeUInt8(n,0),e.slice(t,t+32).copy(i.pubkey,1);else{if(4!==n)throw new Error("Bad compression byte in signing response.");i.pubkey=r.alloc(65),i.pubkey.writeUInt8(n,0),e.slice(t).copy(i.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(i.sig={r:`0x${u.toString("hex")}`,s:`0x${f.toString("hex")}`},t+=s,e.length>=t+32&&(o=r.from(e.slice(t,t+32)),t+=32),n.encodingType===R.SIGNING.ENCODINGS.EVM){const e=ut(n.origPayloadBuf,i);i.sig.v=BigInt(e.toString()),tr(i.sig.v,n,i)}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,i);i.sig.v=BigInt(e.toString()),tr(i.sig.v,n,i)}catch(e){console.error("Failed to get V from transaction, using fallback:",e);const t=er(n,o),r=lt({messageHash:t,signature:i.sig,publicKey:i.pubkey});i.sig.v=BigInt(27+r)}else{const e=er(n,o),t=lt({messageHash:e,signature:i.sig,publicKey:i.pubkey});i.sig.v=BigInt(27+t)}}}else if(n.curveType===R.SIGNING.CURVES.ED25519)n.omitPubkey||(i.pubkey=r.alloc(32),e.slice(t,t+32).copy(i.pubkey)),t+=32,i.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||(i.pubkey=r.alloc(48),e.slice(t,t+48).copy(i.pubkey)),t+=48,i.sig=r.alloc(96),e.slice(t,t+96).copy(i.sig),t+=96}return i}(e,o,t)}{const r=Ze(e.slice(o,o+2+e[o+1]));o+=74;const n=e.slice(o,o+20),i=Gr(t,r,n);if("string"==typeof i)return{tx:`0x${i}`,txHash:`0x${Fr(i)}`,sig:{v:0n,r:"0x",s:"0x"},signer:`0x${n.toString("hex")}`};return{tx:`0x${i.rawTx}`,txHash:`0x${Fr(i.rawTx)}`,sig:{v:BigInt(`0x${i.sigWithV.v.toString("hex")}`),r:`0x${i.sigWithV.r.toString("hex")}`,s:`0x${i.sigWithV.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}},Un=class{constructor({baseUrl:e,name:t,privKey:r,stateData:i,timeout:o,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=o||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,i&&this.unpackAndApplyStateData(i)}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(On,{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(_n,{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:i,activeWallets:o}){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!==i&&(this.fwVersion=i),void 0!==o&&(this.activeWallets=o),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},i={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},o=r.from(t.ephemeralPub,"hex"),s=r.from(t.fwVersion,"hex"),a=r.from(t.privKey,"hex");this.activeWallets.internal=n,this.activeWallets.external=i,this.ephemeralPub=Je(o),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 i=Math.min(q,n-r),o=he(K,r);await ue(n=>n.getAddresses({startPath:o,...e,n:i}).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),Gn=Mn(J),Fn=Mn(Q),Hn=Mn(Y),qn=Mn(X),$n=Mn(ee),Vn=async({n:e,startPathIndex:t}={n:q,startPathIndex:0})=>Dn({startPath:he(ie,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(oe,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 i=e.split("/").filter(Boolean),o=ge(i),s=function(e){if(e.length>=2&&e[1]===501+U)return R.GET_ADDR_FLAGS.ED25519_PUB}(o),a=i.findIndex(e=>e.toLowerCase().includes("x"));if(-1===a)return ue(e=>e.getAddresses({startPath:o,flag:n||s,n:t}));const c=[];for(let e=0;e<t;e++){const t=[...o];t[a]=t[a]+r+e;const i=await ue(e=>e.getAddresses({startPath:t,flag:n||s,n:1}));c.push(...i)}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 ei=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}))},ti=async({n:e=10,start:t=0}={})=>{const r=[];let n=e,i=t;for(;n>0;)await ue(e=>e.getKvRecords({start:i,n:n>q?q:n}).then(async e=>{r.push(...e.records),i=e.fetched+i,n=e.total-i}));return r},ri=async e=>{const t=e.map(e=>`${e.id}`);return ue(e=>e.removeKvRecords({ids:t}))},ni=e("@ethereumjs/rlp"),ii=e("ox"),oi=e("viem");var si=async(e,t)=>{const n="string"==typeof(i=e)||i instanceof Uint8Array||r.isBuffer(i);var i;const o=n?function(e){if("string"==typeof e)return e.startsWith("0x")?e:`0x${e}`;return r.from(e)}(e):(0,oi.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 i=n.getFwVersion(),o=i.major>0||i.minor>=16,{def:s}=await at(e,t,r,o);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:o,decoder:s};return ue(e=>e.sign({data:c,...t}))};function ai(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 ci=async(e,t)=>{const n=r.from([5]),i="address"in e?e.address:e.contractAddress,o=r.concat([n,r.from(ni.RLP.encode([e.chainId,i,e.nonce]))]),s={signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,encodingType:R.SIGNING.ENCODINGS.EIP7702_AUTH,payload:o},a=await ue(e=>e.sign({data:s,...t}));if(a.sig&&a.pubkey){const t=r.from(ii.Hash.keccak256(o)),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:i,chainId:e.chainId,nonce:e.nonce,yParity:n,r:s,s:c}}throw new Error("Failed to get signature from device")},ui=async e=>{const t=(0,oi.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}))},fi=async e=>{const t={data:{signerPath:Z,...e},currency:C.BTC};return ue(e=>e.sign(t))},li=async e=>{const t={data:{signerPath:J,...e},currency:C.BTC};return ue(e=>e.sign(t))},di=async e=>{const t={data:{signerPath:Q,...e},currency:C.BTC};return ue(e=>e.sign(t))},hi=async(e,t)=>{const r={data:{signerPath:ie,curveType:R.SIGNING.CURVES.ED25519,hashType:R.SIGNING.HASHES.NONE,encodingType:R.SIGNING.ENCODINGS.SOLANA,payload:e,...t}};return ue(e=>e.sign(r))},pi=async()=>ue(e=>e.fetchActiveWallet()),mi=async e=>{if(!e.getStoredClient)throw new Error("Client data getter required");var t;if(t=de(e.getStoredClient),G=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 G();if(!e)throw new Error("Client not initialized");const t=e.getDeviceId();return!e.ephemeralPub&&t?gi(t):(await z(e.getStateData()),Promise.resolve(!0))}},gi=async e=>ue(t=>t.connect(e)),bi=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"}],[6542,{},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"}],[6543,{"./errors.js":6542},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 i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]},i=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 o=e("./errors.js");function s(e){if(0===e[0])throw(0,o.EthereumJSErrorWithoutCode)("invalid RLP: extra zeros");return function(e){const t=Number.parseInt(e,16);if(Number.isNaN(t))throw(0,o.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,o.EthereumJSErrorWithoutCode)("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function u(e){let t,r,n,i,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,o.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,o.EthereumJSErrorWithoutCode)("invalid RLP: not enough bytes for string length");if(t=s(c(e,1,r)),t<=55)throw(0,o.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,i=c(e,1,t);i.length;)a=u(i),f.push(a.data),i=a.remainder;return{data:f,remainder:e.subarray(t)}}{if(r=l-246,t=s(c(e,1,r)),t<56)throw(0,o.EthereumJSErrorWithoutCode)("invalid RLP: encoded list too short");const n=r+t;if(n>e.length)throw(0,o.EthereumJSErrorWithoutCode)("invalid RLP: total length is larger than the data");for(i=c(e,r,n);i.length;)a=u(i),f.push(a.data),i=a.remainder;return{data:f,remainder:e.subarray(n)}}}i(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,o.EthereumJSErrorWithoutCode)("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw(0,o.EthereumJSErrorWithoutCode)("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=h(e.charCodeAt(i)),s=h(e.charCodeAt(i+1));if(r===undefined||s===undefined){const t=e[i]+e[i+1];throw(0,o.EthereumJSErrorWithoutCode)('hex string expected, got non-hex character "'+t+'" at index '+i)}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 i=e[t];r.set(i,n),n+=i.length}return r}function g(e){return(new TextEncoder).encode(e)}function b(e){if(e<0)throw(0,o.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,o.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 i=E(e[n]);t.push(i),r+=i.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,o.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"}],[6544,{"./abstract/weierstrass.js":6553,"@noble/hashes/hmac":5180,"@noble/hashes/utils":5189},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,o.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"),i=e("@noble/hashes/utils"),o=e("./abstract/weierstrass.js");function s(e){return{hash:e,hmac:(t,...r)=>(0,n.hmac)(e,t,(0,i.concatBytes)(...r)),randomBytes:i.randomBytes}}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/_shortw_utils.js"}],[6545,{"./hash-to-curve.js":6548,"./modular.js":6549,"./utils.js":6552,"./weierstrass.js":6553},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,i,o)=>h.mul014(n,e,l.mul(t,i),l.mul(r,o));else{if("divisive"!==m)throw new Error("bls: unknown twist type");E=(e,t,r,n,i,o)=>h.mul034(n,l.mul(r,o),l.mul(t,i),e)}const v=l.div(l.ONE,l.mul(l.ONE,u));function x(e,t,r,n){const i=l.sqr(r),o=l.sqr(n),s=l.mulByB(l.mul(o,f)),a=l.mul(s,f),c=l.sub(l.sub(l.sqr(l.add(r,n)),o),i),u=l.sub(s,i),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(i,a),t),r),v),Ry:r=l.sub(l.sqr(l.mul(l.add(i,a),v)),l.mul(l.sqr(s),f)),Rz:n=l.mul(i,c)}}function B(e,t,r,n,i,o){const s=l.sub(r,l.mul(o,n)),a=l.sub(t,l.mul(i,n)),c=l.sub(l.mul(s,i),l.mul(a,o)),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,o.memoized)(t=>{const r=t,{x:n,y:i}=r.toAffine(),o=n,s=i,a=l.neg(i);let c=o,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,o,-1===e?a:s)),d.push(t)}if(e.postPrecompute){const t=d[d.length-1];e.postPrecompute(c,u,f,o,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,i,o]of e)for(const[e,s,a]of t[n])r=E(e,s,a,r,i,o)}}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,i.getMinHashLength)(r.ORDER);return(0,i.mapHashToField)(e.randomBytes(t),r.ORDER)},calcPairingPrecomputes:P},{ShortSignature:_}=e.G1,{Signature:j}=e.G2;function k(e){return e instanceof b.ProjectivePoint?e:b.ProjectivePoint.fromHex(e)}function N(e,t){return e instanceof b.ProjectivePoint?e:b.hashToCurve((0,o.ensureBytes)("point",e),t)}function O(e){return e instanceof w.ProjectivePoint?e:j.fromHex(e)}function R(e,t){return e instanceof w.ProjectivePoint?e:w.hashToCurve((0,o.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 i=n.multiply(b.normPrivateKeyToScalar(t));return e instanceof w.ProjectivePoint?i:j.toRawBytes(i)},signShortSignature:function(e,t,r){const n=N(e,r);n.assertValidity();const i=n.multiply(b.normPrivateKeyToScalar(t));return e instanceof b.ProjectivePoint?i:_.toRawBytes(i)},verify:function(e,t,r,n){const i=k(r),o=R(t,n),s=b.ProjectivePoint.BASE,a=O(e),c=T([{g1:i.negate(),g2:o},{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 i=O(e),o=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=o[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:i}),h.eql(T(c),h.ONE)}catch{return!1}},verifyShortSignature:function(e,t,r,n){const i=O(r),o=N(t,n),s=w.ProjectivePoint.BASE,a=k(e),c=T([{g1:o,g2:i},{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(O).reduce((e,t)=>e.add(t),w.ProjectivePoint.ZERO);if(e[0]instanceof w.ProjectivePoint)return t.assertValidity(),t;return j.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 _.toRawBytes(t)},millerLoopBatch:I,pairing:function(e,t,r=!0){return T([{g1:e,g2:t}],r)},pairingBatch:T,G1:b,G2:w,Signature:j,ShortSignature:_,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"),i=e("./modular.js"),o=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"}],[6546,{"./modular.js":6549,"./utils.js":6552},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 i=t;for(;r>o;)r&s&&(n=n.add(i)),i=i.double(),r>>=s;return n},precomputeWindow(e,r){const{windows:n,windowSize:i}=u(r,t),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<i;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(r,n,i){let o=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(i,e,c);i=t,u?s=s.add(a(d,n[h])):o=o.add(a(l,n[r]))}return{p:o,f:s}},wNAFUnsafe(r,n,i,s=e.ZERO){const a=u(r,t);for(let e=0;e<a.windows&&i!==o;e++){const{nextN:t,offset:r,isZero:o,isNeg:c}=f(i,e,a);if(i=t,!o){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 i=m(e);return 1===i?this.unsafeLadder(e,t,n):this.wNAFUnsafe(i,this.getPrecomputes(i,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 o=r.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,c=(0,i.bitLen)(BigInt(o));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const f=(0,i.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 i=n[t],o=Number(i>>BigInt(e)&f);h[o]=h[o].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 o=e.ZERO,s=2**n-1,a=Math.ceil(t.BITS/n),u=(0,i.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 i=o;for(let t=0;t<a;t++){if(i!==o)for(let e=0;e<n;e++)i=i.double();const r=BigInt(a*n-(t+1)*n);for(let t=0;t<e.length;t++){const n=e[t],o=Number(n>>r&u);o&&(i=i.add(f[t][o-1]))}}return i}},r.validateBasic=function(e){return(0,n.validateField)(e.Fp),(0,i.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"),i=e("./utils.js"),o=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,i.bitMask)(e),maxNumber:r,shiftBy:BigInt(e)}}function f(e,t,r){const{windowSize:n,mask:i,maxNumber:o,shiftBy:a}=r;let c=Number(e&i),u=e>>a;c>n&&(c-=o,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"}],[6547,{"./curve.js":6546,"./modular.js":6549,"./utils.js":6552},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,o.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,i.Field)(t.n,t.nBitLength);if(!function(e,n){const i=r.sqr(e),o=r.sqr(n),s=r.add(r.mul(t.a,i),o),a=r.add(r.ONE,r.mul(t.d,r.mul(i,o)));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,o.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,o.aInRange)("coordinate "+e,t,n,b)}function S(e){if(!(e instanceof T))throw new Error("ExtendedPoint expected")}const P=(0,o.memoized)((e,t)=>{const{ex:n,ey:i,ez:o}=e,c=e.is0();null==t&&(t=c?u:r.inv(o));const f=y(n*t),l=y(i*t),d=y(o*t);if(c)return{x:s,y:a};if(d!==a)throw new Error("invZ was invalid");return{x:f,y:l}}),I=(0,o.memoized)(e=>{const{a:r,d:n}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=e,c=y(i*i),u=y(o*o),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(i*o)!==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,i.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){j.setWindowSize(this,e)}assertValidity(){I(this)}equals(e){S(e);const{ex:t,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=e,a=y(t*s),c=y(i*n),u=y(r*s),f=y(o*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:i}=this,o=y(r*r),s=y(n*n),a=y(c*y(i*i)),u=y(e*o),f=r+n,l=y(y(f*f)-o-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:i,ey:o,ez:s,et:a}=this,{ex:c,ey:u,ez:f,et:l}=e,d=y(i*c),h=y(o*u),p=y(a*n*l),m=y(s*f),g=y((i+o)*(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 j.wNAFCached(this,e,T.normalizeZ)}multiply(e){const t=e;(0,o.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,o.aInRange)("scalar",r,s,l),r===s?_:this.is0()||r===a?this:j.wNAFCachedUnsafe(this,r,T.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(g).is0()}isTorsionFree(){return j.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:i,a:c}=t,u=r.BYTES;e=(0,o.ensureBytes)("pointHex",e,u),(0,o.abool)("zip215",n);const f=e.slice(),l=e[u-1];f[u-1]=-129&l;const d=(0,o.bytesToNumberLE)(f),h=n?b:r.ORDER;(0,o.aInRange)("pointHex.y",d,s,h);const p=y(d*d),m=y(p-a),g=y(i*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}=O(e);return A.multiply(t)}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=(0,o.numberToBytesLE)(t,r.BYTES);return n[n.length-1]|=e&a?128:0,n}toHex(){return(0,o.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:_}=T,j=(0,n.wNAF)(T,8*m);function k(e){return(0,i.mod)(e,l)}function N(e){return k((0,o.bytesToNumberLE)(e))}function O(e){const t=r.BYTES;e=(0,o.ensureBytes)("private key",e,t);const n=(0,o.ensureBytes)("hashed private key",h(e),2*t),i=v(n.slice(0,t));return{head:i,prefix:n.slice(t,2*t),scalar:N(i)}}function R(e){const{head:t,prefix:r,scalar:n}=O(e),i=A.multiply(n),o=i.toRawBytes();return{head:t,prefix:r,scalar:n,point:i,pointBytes:o}}function C(e=Uint8Array.of(),...t){const r=(0,o.concatBytes)(...t);return N(h(x(r,(0,o.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,o.ensureBytes)("message",e),d&&(e=d(e));const{prefix:i,scalar:a,pointBytes:c}=R(t),u=C(n.context,i,e),f=A.multiply(u).toRawBytes(),h=k(u+C(n.context,f,c,e)*a);(0,o.aInRange)("signature.s",h,s,l);const p=(0,o.concatBytes)(f,(0,o.numberToBytesLE)(h,r.BYTES));return(0,o.ensureBytes)("result",p,2*r.BYTES)},verify:function(e,t,n,i=U){const{context:s,zip215:a}=i,c=r.BYTES;e=(0,o.ensureBytes)("signature",e,2*c),t=(0,o.ensureBytes)("message",t),n=(0,o.ensureBytes)("publicKey",n,c),a!==undefined&&(0,o.abool)("zip215",a),d&&(t=d(t));const u=(0,o.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"),i=e("./modular.js"),o=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"}],[6548,{"./modular.js":6549,"./utils.js":6552},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,i)=>{const[o,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(o,u),i=e.mul(i,e.mul(a,f)),{x:t,y:i}}},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 i(t){const r=t.clearCofactor();return r.equals(e.ZERO)?e.ZERO:(r.assertValidity(),r)}return{defaults:r,hashToCurve(e,t){const o=l(e,2,{...r,DST:r.DST,...t}),s=n(o[0]),a=n(o[1]);return i(s.add(a))},encodeToCurve:(e,t)=>i(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 i(n(e))}}};const n=e("./modular.js"),i=e("./utils.js"),o=i.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,i.abytes)(e),(0,i.abytes)(t),c(r),t.length>255&&(t=n((0,i.concatBytes)((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:o,blockLen:u}=n,f=Math.ceil(r/o);if(r>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,i.concatBytes)(t,s(t.length,1)),d=s(0,u),h=s(r,2),p=new Array(f),m=n((0,i.concatBytes)(d,e,h,s(0,1),l));p[0]=n((0,i.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,i.concatBytes)(...t))}return(0,i.concatBytes)(...p).slice(0,r)}function f(e,t,r,n,o){if((0,i.abytes)(e),(0,i.abytes)(t),c(r),t.length>255){const e=Math.ceil(2*n/8);t=o.create({dkLen:e}).update((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:r}).update(e).update(s(r,2)).update(t).update(s(t.length,1)).digest()}function l(e,t,r){(0,i.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,i.abytes)(e),c(t);const m="string"==typeof p?(0,i.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 i=b*(r+e*l),a=w.subarray(i,i+b);t[r]=(0,n.mod)(o(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"}],[6549,{"./utils.js":6552,"@noble/hashes/utils":5189},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-- >o;)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,i.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,i.ensureBytes)("privateHash",e)).length,o=x(t).nByteLength+8;if(o<24||n<o||n>1024)throw new Error("hashToPrivateScalar: expected "+o+"-1024 bytes of input, got "+n);return d(r?(0,i.bytesToNumberLE)(e):(0,i.bytesToNumberBE)(e),t-s)+s},r.getFieldBytesLength=S,r.getMinHashLength=P,r.mapHashToField=function(e,t,r=!1){const n=e.length,o=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,i.bytesToNumberLE)(e):(0,i.bytesToNumberBE)(e),t-s)+s;return r?(0,i.numberToBytesLE)(c,o):(0,i.numberToBytesBE)(c,o)};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/utils"),i=e("./utils.js"),o=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>=o?r:t+r}function h(e,t){if(e===o)throw new Error("invert: expected non-zero number");if(t<=o)throw new Error("invert: expected positive modulus, got "+t);let r=d(e,t),n=t,i=o,a=s,c=s,u=o;for(;r!==o;){const e=n/r,t=n%r,o=i-c*e,s=a-u*e;n=r,r=t,i=c,a=u,c=o,u=s}if(n!==s)throw new Error("invert: does not exist");return d(i,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),i=e.pow(n,r),o=e.mul(t,i),s=e.mul(e.mul(o,a),i),c=e.mul(o,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===o;)t/=a,r++;let n=a;const i=B(e);for(;1===v(i,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return p;let c=i.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 i=r,o=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===i)throw new Error("Cannot find square root");const n=s<<BigInt(i-t-1),c=e.pow(o,n);i=t,o=e.sqr(c),a=e.mul(a,o),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<o)throw new Error("invalid exponent, negatives unsupported");if(r===o)return e.ONE;if(r===s)return t;let n=e.ONE,i=t;for(;r>o;)r&s&&(n=e.mul(n,i)),i=e.sqr(i),r>>=s;return n}function E(e,t,r=!1){const n=new Array(t.length).fill(r?e.ZERO:undefined),i=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),o=e.inv(i);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),o),n}function v(e,t){const r=(e.ORDER-s)/a,n=e.pow(t,r),i=e.eql(n,e.ONE),o=e.eql(n,e.ZERO),c=e.eql(n,e.neg(e.ONE));if(!i&&!o&&!c)throw new Error("invalid Legendre symbol result");return i?1:o?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<=o)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,i.bitMask)(a),ZERO:o,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 o<=t&&t<e},is0:e=>e===o,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,i.numberToBytesLE)(e,c):(0,i.numberToBytesBE)(e,c),fromBytes:e=>{if(e.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+e.length);return r?(0,i.bytesToNumberLE)(e):(0,i.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"}],[655,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=203;r.migrate=async(e,t)=>{if(e.meta.version=i,!(0,n.hasProperty)(e.data,"PreferencesController")||!(0,n.isObject)(e.data.PreferencesController))return;const{PreferencesController:r}=e.data;(0,n.hasProperty)(r,"currentLocale")&&"es"===r.currentLocale&&(r.currentLocale="es_419",t.add("PreferencesController"))}}}},{package:"$root$",file:"app/scripts/migrations/203.ts"}],[6550,{"./modular.js":6549,"./utils.js":6552},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,i.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,i.numberToBytesLE)(E(e),p)}function B(e,t){const n=function(e,t){(0,i.aInRange)("u",e,o,r),(0,i.aInRange)("scalar",t,b,w);const n=t,a=e;let c=s,u=o,l=e,d=s,p=o;for(let e=BigInt(h-1);e>=o;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,i=E(r*r),o=c-u,f=E(o*o),h=i-f,m=l+d,b=E((l-d)*r),y=E(m*o),w=b+y,v=b-y;l=E(w*w),d=E(a*E(v*v)),c=E(i*f),u=E(h*(i+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,i.ensureBytes)("u coordinate",e,p);return l&&(t[31]&=127),E((0,i.bytesToNumberLE)(t))}(t),function(e){return(0,i.bytesToNumberLE)(u((0,i.ensureBytes)("scalar",e,p)))}(e));if(n===o)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"),i=e("./utils.js"),o=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"}],[6551,{"./modular.js":6549,"./utils.js":6552},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),i=t.pow(r,(e.ORDER-s)/a);function o(e,r){return[t.mul(t.frobeniusMap(e,1),n),t.mul(t.frobeniusMap(r,1),i)]}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(),i=e(n.x,n.y);return t.fromAffine({x:i[0],y:i[1]})},h=d(o),p=d(l);return{psi:o,psi2:l,G2psi:h,G2psi2:p,PSI_X:n,PSI_Y:i,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:i})=>({c0:r.add(e,n),c1:r.add(t,i)}),h=({c0:e,c1:t},{c0:n,c1:i})=>({c0:r.sub(e,n),c1:r.sub(t,i)}),p=({c0:e,c1:t},n)=>{if("bigint"==typeof n)return{c0:r.mul(e,n),c1:r.mul(t,n)};const{c0:i,c1:o}=n;let s=r.mul(e,i),a=r.mul(t,o);return{c0:r.sub(s,a),c1:r.sub(r.mul(r.add(e,t),r.add(i,o)),r.add(s,a))}},m=({c0:e,c1:t})=>{const n=r.add(e,t),i=r.sub(e,t),o=r.add(e,e);return{c0:r.mul(n,i),c1:r.mul(o,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,i.bitLen)(b),BYTES:Math.ceil((0,i.bitLen)(b)/8),MASK:(0,i.bitMask)((0,i.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:i})=>r.eql(e,n)&&r.eql(t,i),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:i,c1:o}=t;if(r.is0(o))return 1===n.FpLegendre(r,i)?w.create({c0:r.sqrt(i),c1:r.ZERO}):w.create({c0:r.ZERO,c1:r.sqrt(r.div(i,c))});const s=r.sqrt(r.sub(r.sqr(i),r.mul(r.sqr(o),c)));let a=r.mul(r.add(s,i),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(o,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===o&&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,i.concatBytes)(r.toBytes(e),r.toBytes(t)),cmov:({c0:e,c1:t},{c0:n,c1:i},o)=>({c0:r.cmov(e,n,o),c1:r.cmov(t,i,o)}),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:i,c2:o})=>({c0:w.add(e,n),c1:w.add(t,i),c2:w.add(r,o)}),v=({c0:e,c1:t,c2:r},{c0:n,c1:i,c2:o})=>({c0:w.sub(e,n),c1:w.sub(t,i),c2:w.sub(r,o)}),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:i,c1:o,c2:s}=n,a=w.mul(e,i),c=w.mul(t,o),u=w.mul(r,s);return{c0:w.add(a,w.mulByNonresidue(w.sub(w.mul(w.add(t,r),w.add(o,s)),w.add(c,u)))),c1:w.add(w.sub(w.mul(w.add(e,t),w.add(i,o)),w.add(a,c)),w.mulByNonresidue(u)),c2:w.sub(w.add(c,w.mul(w.add(e,r),w.add(i,s))),w.add(a,u))}},B=({c0:e,c1:t,c2:r})=>{let n=w.sqr(e),i=w.mul(w.mul(e,t),a),o=w.mul(w.mul(t,r),a),s=w.sqr(r);return{c0:w.add(w.mulByNonresidue(o),n),c1:w.add(w.mulByNonresidue(s),i),c2:w.sub(w.sub(w.add(w.add(i,w.sqr(w.add(w.sub(e,t),r))),o),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,i.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:i,c2:o})=>w.eql(e,n)&&w.eql(t,i)&&w.eql(r,o),sqrt:i.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))),i=w.sub(w.mulByNonresidue(w.sqr(r)),w.mul(e,t)),o=w.sub(w.sqr(t),w.mul(e,r)),s=w.inv(w.add(w.mulByNonresidue(w.add(w.mul(r,i),w.mul(t,o))),w.mul(e,n)));return{c0:w.mul(s,n),c1:w.mul(s,i),c2:w.mul(s,o)}},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,i.concatBytes)(w.toBytes(e),w.toBytes(t),w.toBytes(r)),cmov:({c0:e,c1:t,c2:r},{c0:n,c1:i,c2:o},s)=>({c0:w.cmov(e,n,s),c1:w.cmov(t,i,s),c2:w.cmov(r,o,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,i){let o=w.mul(e,n),s=w.mul(t,i);return{c0:w.add(w.mulByNonresidue(w.sub(w.mul(w.add(t,r),i),s)),o),c1:w.sub(w.sub(w.mul(w.add(n,i),w.add(e,t)),o),s),c2:w.add(w.sub(w.mul(w.add(e,r),n),o),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)}),_=({c0:e,c1:t},{c0:r,c1:n})=>({c0:I.sub(e,r),c1:I.sub(t,n)}),j=({c0:e,c1:t},r)=>{if("bigint"==typeof r)return{c0:I.mul(e,r),c1:I.mul(t,r)};let{c0:n,c1:i}=r,o=I.mul(e,n),s=I.mul(t,i);return{c0:I.add(o,I.mulByNonresidue(s)),c1:I.sub(I.mul(I.add(e,t),I.add(n,i)),I.add(o,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 N={ORDER:w.ORDER,isLE:I.isLE,BITS:2*I.BITS,BYTES:2*I.BYTES,MASK:(0,i.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:i.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)=>N.mul(e,"bigint"==typeof t?r.inv(r.create(t)):N.inv(t)),pow:(e,t)=>n.FpPow(N,e,t),invertBatch:e=>n.FpInvertBatch(N,e),add:A,sub:_,mul:j,sqr:k,addN:A,subN:_,mulN:j,sqrN:k,fromBytes:e=>{if(e.length!==N.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,i.concatBytes)(I.toBytes(e),I.toBytes(t)),cmov:({c0:e,c1:t},{c0:r,c1:n},i)=>({c0:I.cmov(e,r,i),c1:I.cmov(t,n,i)}),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:i}=I.frobeniusMap(e.c1,t),o=T[t%12];return{c0:I.frobeniusMap(e.c0,t),c1:I.create({c0:w.mul(r,o),c1:w.mul(n,o),c2:w.mul(i,o)})}},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,i)=>{let o=I.mul01(e,r,n),s=I.mul1(t,i);return{c0:I.add(I.mulByNonresidue(s),o),c1:I.sub(I.sub(I.mul01(I.add(t,e),r,w.add(n,i)),o),s)}},mul034:({c0:e,c1:t},r,n,i)=>{const o=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,i),a=I.mul01(I.add(e,t),w.add(r,n),i);return{c0:I.add(I.mulByNonresidue(s),o),c1:I.sub(a,I.add(o,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:N}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),i=e("./utils.js"),o=BigInt(0),s=BigInt(1),a=BigInt(2),c=BigInt(3);function u(e,t,r,n,i=1,o){const a=BigInt(o===undefined?n:o),c=r**BigInt(n),u=[];for(let o=0;o<i;o++){const i=BigInt(o+1),f=[];for(let o=0,u=s;o<n;o++){const n=(i*u-i)/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"}],[6552,{},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=o,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(!o(t))throw new Error(e+" must be hex string or Uint8Array");n=Uint8Array.from(t)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(e+" of length "+r+" expected, got "+i);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>>=i,t+=1);return t},r.bitGet=function(e,t){return e>>BigInt(t)&i},r.bitSet=function(e,t,r){return e|(r?i: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),i=w(e),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...e)=>r(i,n,...e),c=(e=w(0))=>{i=a(E([0]),e),n=a(),0!==e.length&&(i=a(E([1]),e),n=a())},u=()=>{if(o++>=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 i=v[r];if("function"!=typeof i)throw new Error("invalid validator function");const o=e[t];if(!(n&&o===undefined||i(o,e)))throw new Error("param "+String(t)+" is invalid. Expected "+r+", got "+o)};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 i=t.get(r);if(i!==undefined)return i;const o=e(r,...n);return t.set(r,o),o}};const n=BigInt(0),i=BigInt(1);function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function s(e){if(!o(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,i=0;t<r;t++,i+=2){const r=h(e.charCodeAt(i)),o=h(e.charCodeAt(i+1));if(r===undefined||o===undefined){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}n[t]=16*r+o}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 i=e[t];r.set(i,n),n+=i.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=>(i<<BigInt(e))-i;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||o(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"}],[6553,{"./curve.js":6546,"./modular.js":6549,"./utils.js":6552},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,o.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,i.mod)(e,l)}function y(e){return(0,i.invert)(e,l)}const{ProjectivePoint:w,normPrivateKeyToScalar:E,weierstrassEquation:v,isWithinCurveOrder:x}=p({...t,toBytes(e,t,r){const n=t.toAffine(),i=a.toBytes(n.x),s=o.concatBytes;return(0,o.abool)("isCompressed",r),r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,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,o.bytesToNumberBE)(n);if(!(0,o.inRange)(e,f,a.ORDER))throw new Error("Point is not on curve");const t=v(e);let i;try{i=a.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((i&f)===f)&&(i=a.neg(i)),{x:e,y:i}}}});function B(e){return e>l>>f}const S=(e,t,r)=>(0,o.bytesToNumberBE)(e.slice(t,r));class P{constructor(e,t,r){(0,o.aInRange)("r",e,f,l),(0,o.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,o.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,o.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:i}=this,s=_((0,o.ensureBytes)("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?r+t.n:r;if(u>=a.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&i?"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,o.hexToBytes)(this.toDERHex())}toDERHex(){return r.DER.hexFromSig(this)}toCompactRawBytes(){return(0,o.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,i.getMinHashLength)(t.n);return(0,i.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,o.ensureBytes)("key",e).length,n=a.BYTES,i=n+1,s=2*n+1;return t.allowedPrivateKeyLengths||d===i?undefined:r===i||r===s}const A=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,o.bytesToNumberBE)(e),r=8*e.length-h;return r>0?t>>BigInt(r):t},_=t.bits2int_modN||function(e){return b(A(e))},j=(0,o.bitMask)(h);function k(e){return(0,o.aInRange)("num < 2^"+h,e,u,j),(0,o.numberToBytesBE)(e,d)}function N(e,r,n=O){if(["recovered","canonical"].some(e=>e in n))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:c}=t;let{lowS:l,prehash:d,extraEntropy:h}=n;null==l&&(l=!0),e=(0,o.ensureBytes)("msgHash",e),s(n),d&&(e=(0,o.ensureBytes)("prehashed msgHash",i(e)));const p=_(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,o.ensureBytes)("extraEntropy",e))}const v=(0,o.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(),i=b(n.x);if(i===u)return;const o=b(r*b(S+i*m));if(o===u)return;let s=(n.x===i?0:2)|Number(n.y&f),a=o;return l&&B(o)&&(a=function(e){return B(e)?b(-e):e}(o),s^=1),new P(i,a,s)}}}const O={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=O){const{seed:i,k2sig:s}=N(e,r,n),a=t;return(0,o.createHmacDrbg)(a.hash.outputLen,a.nByteLength,a.hmac)(i,s)},verify:function(e,n,i,a=R){const c=e;n=(0,o.ensureBytes)("msgHash",n),i=(0,o.ensureBytes)("publicKey",i);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,o.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(i)}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=_(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,i.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 o,s,a,c,u,f,l,d;o=e.sqr(n),o=e.mul(o,t.Z),s=e.sqr(o),s=e.add(s,o),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(o,a);const{isValid:h,value:p}=r(s,f);d=e.mul(o,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,i.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"),i=e("./modular.js"),o=e("./utils.js");function s(e){e.lowS!==undefined&&(0,o.abool)("lowS",e.lowS),e.prehash!==undefined&&(0,o.abool)("prehash",e.prehash)}class a extends Error{constructor(e=""){super(e)}}function c(e,t){return(0,o.bytesToHex)((0,o.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 i=t.length/2,s=(0,o.numberToHexUnpadded)(i);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const a=i>127?(0,o.numberToHexUnpadded)(s.length/2|128):"";return(0,o.numberToHexUnpadded)(e)+a+s+t},decode(e,t){const{Err:n}=r.DER;let i=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[i++];let s=0;if(!!(128&o)){const e=127&o;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(i,i+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(i+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=o;const a=t.subarray(i,i+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){const{Err:t}=r.DER;if(e<u)throw new t("integer: negative integers are not allowed");let n=(0,o.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,o.bytesToNumberBE)(e)}},toSig(e){const{Err:t,_int:n,_tlv:i}=r.DER,s=(0,o.ensureBytes)("signature",e),{v:a,l:c}=i.decode(48,s);if(c.length)throw new t("invalid signature: left bytes after parsing");const{v:u,l:f}=i.decode(2,a),{v:l,l:d}=i.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,i=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,i)}};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,o.validateObject)(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:r,Fp:i,a:s}=t;if(r){if(!i.eql(s,i.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,i.Field)(t.n,t.nBitLength),a=t.toBytes||((e,t,n)=>{const i=t.toAffine();return(0,o.concatBytes)(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.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:i}=t,o=r.sqr(e),s=r.mul(o,e);return r.add(r.add(s,r.mul(e,n)),i)}function p(e,t){const n=r.sqr(t),i=l(e);return r.eql(n,i)}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,o.isBytes)(e)&&(e=(0,o.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,o.bytesToNumberBE)((0,o.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,i.mod)(c,a)),(0,o.aInRange)("private key",c,f,a),c}function y(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const w=(0,o.memoized)((e,t)=>{const{px:n,py:i,pz:o}=e;if(r.eql(o,r.ONE))return{x:n,y:i};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(o));const a=r.mul(n,t),c=r.mul(i,t),u=r.mul(o,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,o.memoized)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not FE");if(!p(n,i))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 i=e=>r.eql(e,r.ZERO);return i(t)&&i(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,i.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,o.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:i}=this,{px:o,py:s,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(o,i)),u=r.eql(r.mul(n,a),r.mul(s,i));return c&&u}negate(){return new v(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,i=r.mul(n,d),{px:o,py:s,pz:a}=this;let c=r.ZERO,u=r.ZERO,f=r.ZERO,l=r.mul(o,o),h=r.mul(s,s),p=r.mul(a,a),m=r.mul(o,s);return m=r.add(m,m),f=r.mul(o,a),f=r.add(f,f),c=r.mul(e,f),u=r.mul(i,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(i,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:i,pz:o}=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(i,a),b=r.mul(o,c),w=r.add(n,i),E=r.add(s,a);w=r.mul(w,E),E=r.add(m,g),w=r.sub(w,E),E=r.add(n,o);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(i,o),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:i}=t;(0,o.aInRange)("scalar",e,u,i);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:i}=t;let s,a;if((0,o.aInRange)("scalar",e,f,i),n){const{k1neg:t,k1:i,k2neg:o,k2:c}=n.splitScalar(e);let{p:u,f:f}=this.wNAF(i),{p:l,f:d}=this.wNAF(c);u=S.constTimeNegate(t,u),l=S.constTimeNegate(o,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,i=(e,t)=>t!==u&&t!==f&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,r));return o.is0()?undefined:o}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,o.abool)("isCompressed",e),this.assertValidity(),a(v,this,e)}toHex(e=!0){return(0,o.abool)("isCompressed",e),(0,o.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,o.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 i=n,o=l<<i-f-f,s=o*l,a=(r-f)/s,c=(a-f)/l,p=s-f,m=o,g=e.pow(t,a),b=e.pow(t,(a+f)/l);let y=(t,r)=>{let n=g,o=e.pow(r,p),s=e.sqr(o);s=e.mul(s,r);let a=e.mul(t,s);a=e.pow(a,c),a=e.mul(a,o),o=e.mul(a,r),s=e.mul(a,t);let u=e.mul(s,o);a=e.pow(u,m);let d=e.eql(a,e.ONE);o=e.mul(s,b),a=e.mul(u,n),s=e.cmov(o,s,d),u=e.cmov(a,u,d);for(let t=i;t>f;t--){let r=t-l;r=l<<r-f;let i=e.pow(u,r);const a=e.eql(i,e.ONE);o=e.mul(s,n),n=e.mul(n,n),i=e.mul(u,n),s=e.cmov(o,s,a),u=e.cmov(i,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,i)=>{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,r);a=e.mul(a,s);const c=e.mul(a,n),u=e.mul(e.sqr(a),i),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"}],[6554,{"./abstract/bls.js":6545,"./abstract/hash-to-curve.js":6548,"./abstract/modular.js":6549,"./abstract/tower.js":6551,"./abstract/utils.js":6552,"./abstract/weierstrass.js":6553,"@noble/hashes/sha2":5185,"@noble/hashes/utils":5189},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"),i=e("@noble/hashes/utils"),o=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:i}=e,{c0:o,c1:s,c2:a}=t,{first:c,second:u}=v(r,s),{first:f,second:l}=v(o,i),{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,i),h),d)}),c1:E.create({c0:w.add(w.mul(w.add(m,o),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),i=x.conjugate(x._cyclotomicExp(n,t)),o=x.mul(x.conjugate(x._cyclotomicSquare(n)),i),s=x.conjugate(x._cyclotomicExp(o,t)),a=x.conjugate(x._cyclotomicExp(s,t)),c=x.mul(x.conjugate(x._cyclotomicExp(a,t)),x._cyclotomicSquare(i)),u=x.conjugate(x._cyclotomicExp(c,t)),f=x.frobeniusMap(x.mul(i,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(o)),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:_}=(0,u.psiFrobenius)(y,w,w.div(w.ONE,w.NONRESIDUE)),j=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=O(y.toBytes(l),{infinity:!0,compressed:!0});function N(e){const t=224&(e=e.slice())[0],r=!!(t>>7&1),n=!!(t>>6&1),i=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:i,value:e}}function O(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:i}=e.toAffine();if(t)return k.slice();const o=y.ORDER,s=Boolean(i*h/o);return O((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:i}=e.toAffine(),{re:o,im:s}=w.reim(n),{re:c,im:u}=w.reim(i),f=Boolean((u>l?u*h:c*h)/y.ORDER&d),p=o;return(0,a.concatBytes)(O((0,a.numberToBytesBE)(s,t),{sort:f,compressed:!0}),(0,a.numberToBytesBE)(p,t))}r.bls12_381=(0,o.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:{...j,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:i,value:o}=N(e);if(48===o.length&&t){const e=y.ORDER,t=(0,a.bytesToNumberBE)(o),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(i)&&(u=y.neg(u)),{x:y.create(s),y:y.create(u)}}if(96!==o.length||t)throw new Error("invalid point G1, expected 48/96 bytes");{const e=(0,a.bytesToNumberBE)(o.subarray(0,y.BYTES)),t=(0,a.bytesToNumberBE)(o.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:i,y:o}=t.toAffine();if(r){if(n)return k.slice();const e=y.ORDER,t=Boolean(o*h/e);return O((0,a.numberToBytesBE)(i,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)(i,y.BYTES),(0,a.numberToBytesBE)(o,y.BYTES))},ShortSignature:{fromHex(e){const{infinity:t,sort:n,value:i}=N((0,a.ensureBytes)("signatureHex",e,48)),o=y.ORDER,s=(0,a.bytesToNumberBE)(i);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/o!==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:{...j},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(),i=A(e,t),o=t.double();o=_(e,o),o=o.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),o=o.add(i),o=o.subtract(n);return o.subtract(t)},fromBytes:e=>{const{compressed:t,infinity:n,sort:i,value:o}=N(e);if(!t&&!n&&i||!t&&n&&i||i&&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===o.length&&t){const e=r.bls12_381.params.G2b,t=y.ORDER;if(n){if(o.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(o,0,s),u=c(o,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=i&&b>0?g:w.neg(g),{x:f,y:g}}if(192!==o.length||t)throw new Error("invalid point G2, expected 96/192 bytes");{if(n){if(o.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(o,0,s),t=c(o,s,2*s),r=c(o,2*s,3*s),i=c(o,3*s,4*s);return{x:w.fromBigTuple([t,e]),y:w.fromBigTuple([i,r])}}},toBytes:(e,t,r)=>{const{BYTES:n,ORDER:i}=y,o=t.equals(e.ZERO),{x:s,y:c}=t.toAffine();if(r){if(o)return(0,a.concatBytes)(k,(0,a.numberToBytesBE)(l,n));const e=Boolean(c.c1===l?c.c0*h/i:c.c1*h/i);return(0,a.concatBytes)(O((0,a.numberToBytesBE)(s.c1,n),{compressed:!0,sort:e}),(0,a.numberToBytesBE)(s.c0,n))}{if(o)return(0,a.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));const{re:e,im:t}=w.reim(s),{re:r,im:i}=w.reim(c);return(0,a.concatBytes)((0,a.numberToBytesBE)(t,n),(0,a.numberToBytesBE)(e,n),(0,a.numberToBytesBE)(i,n),(0,a.numberToBytesBE)(r,n))}},Signature:{fromHex(e){const{infinity:t,sort:n,value:i}=N((0,a.ensureBytes)("signatureHex",e)),o=y.ORDER,s=i.length/2;if(48!==s&&96!==s)throw new Error("invalid compressed signature length, must be 96 or 192");const c=(0,a.bytesToNumberBE)(i.slice(0,s)),u=(0,a.bytesToNumberBE)(i.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/o!==x||v===l&&E*h/o!==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:j,hash:n.sha256,randomBytes:i.randomBytes})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/bls12-381.js"}],[6555,{"./abstract/curve.js":6546,"./abstract/edwards.js":6547,"./abstract/hash-to-curve.js":6548,"./abstract/modular.js":6549,"./abstract/montgomery.js":6550,"./abstract/utils.js":6552,"@noble/hashes/sha2":5185,"@noble/hashes/utils":5189},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"),i=e("@noble/hashes/utils"),o=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),i=BigInt(80),o=l,s=e*e%o*e%o,a=(0,c.pow2)(s,m,o)*s%o,u=(0,c.pow2)(a,p,o)*e%o,f=(0,c.pow2)(u,b,o)*u%o,d=(0,c.pow2)(f,t,o)*f%o,h=(0,c.pow2)(d,r,o)*d%o,g=(0,c.pow2)(h,n,o)*h%o,y=(0,c.pow2)(g,i,o)*g%o,w=(0,c.pow2)(y,i,o)*g%o,E=(0,c.pow2)(w,t,o)*f%o;return{pow_p_5_8:(0,c.pow2)(E,m,o)*e%o,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),i=w(e*(0,c.mod)(n*n*t,r)).pow_p_5_8;let o=(0,c.mod)(e*n*i,r);const s=(0,c.mod)(t*o*o,r),a=o,u=(0,c.mod)(o*d,r),f=s===e,h=s===(0,c.mod)(-e,r),p=s===(0,c.mod)(-e*d,r);return f&&(o=a),(h||p)&&(o=u),(0,c.isNegativeLE)(o,r)&&(o=(0,c.mod)(-o,r)),{isValid:f||h,value:o}}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:i.randomBytes,adjustScalarBytes:E,uvRatio:v}))();function S(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,i.concatBytes)((0,i.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:i.randomBytes}),r.edwardsToMontgomery=P;const I=(()=>(x.ORDER+g)/y)(),T=(()=>x.pow(m,I))(),A=(()=>x.sqrt(x.neg(x.ONE)))();const _=(()=>(0,c.FpSqrtEven)(x,x.neg(BigInt(486664))))();function j(e){const{xMn:t,xMd:r,yMn:n,yMd:i}=function(e){const t=(x.ORDER-b)/y,r=BigInt(486662);let n=x.sqr(e);n=x.mul(n,m);let i=x.add(n,x.ONE),o=x.neg(r),s=x.sqr(i),a=x.mul(s,i),c=x.mul(n,r);c=x.mul(c,o),c=x.add(c,s),c=x.mul(c,o);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(o,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,o,P),_=x.cmov(S,h,P),j=x.isOdd(_);return _=x.cmov(_,x.neg(_),P!==j),{xMn:I,xMd:i,yMn:_,yMd:p}}(e);let o=x.mul(t,i);o=x.mul(o,_);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);o=x.cmov(o,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(o,d),y:x.mul(a,h)}}function k(e){if(!(e instanceof G))throw new Error("RistrettoPoint expected")}r.ed25519_hasher=(0,a.createHasher)(r.ed25519.ExtendedPoint,e=>j(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 N=d,O=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,i=r.ed25519.CURVE.Fp.create,o=i(N*e*e),s=i((o+p)*C);let a=BigInt(-1);const u=i((a-t*o)*i(o+t));let{isValid:f,value:l}=v(s,u),d=i(l*e);(0,c.isNegativeLE)(d,n)||(d=i(-d)),f||(l=d),f||(a=o);const h=i(a*(o-p)*U-u),m=l*l,g=i((l+l)*u),b=i(h*O),y=i(p-m),w=i(p+m);return new r.ed25519.ExtendedPoint(i(g*w),i(y*b),i(b*w),i(g*y))}class G{constructor(e){this.ep=e}static fromAffine(e){return new G(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 G(t.add(r))}static fromHex(e){e=(0,f.ensureBytes)("ristrettoHex",e,32);const{a:t,d:n}=r.ed25519.CURVE,i=r.ed25519.CURVE.Fp.ORDER,o=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,i))throw new Error(s);const u=o(a*a),l=o(p+t*u),d=o(p-t*u),m=o(l*l),g=o(d*d),b=o(t*n*m-g),{isValid:y,value:w}=D(o(b*g)),E=o(w*d),v=o(w*E*b);let x=o((a+a)*E);(0,c.isNegativeLE)(x,i)&&(x=o(-x));const B=o(l*v),S=o(x*B);if(!y||(0,c.isNegativeLE)(S,i)||B===h)throw new Error(s);return new G(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,o.pippenger)(G,n,e,t)}toRawBytes(){let{ex:e,ey:t,ez:n,et:i}=this.ep;const o=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*i);let g;if((0,c.isNegativeLE)(i*m,o)){let r=s(t*N),n=s(e*N);e=r,t=n,g=s(h*R)}else g=p;(0,c.isNegativeLE)(e*m,o)&&(t=s(-t));let b=s((n-t)*g);return(0,c.isNegativeLE)(b,o)&&(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:i,ey:o}=e.ep,s=r.ed25519.CURVE.Fp.create,a=s(t*o)===s(n*i),c=s(n*o)===s(t*i);return a||c}add(e){return k(e),new G(this.ep.add(e.ep))}subtract(e){return k(e),new G(this.ep.subtract(e.ep))}multiply(e){return new G(this.ep.multiply(e))}multiplyUnsafe(e){return new G(this.ep.multiplyUnsafe(e))}double(){return new G(this.ep.double())}negate(){return new G(this.ep.negate())}}r.RistrettoPoint=(G.BASE||(G.BASE=new G(r.ed25519.ExtendedPoint.BASE)),G.ZERO||(G.ZERO=new G(r.ed25519.ExtendedPoint.ZERO)),G);r.hashToRistretto255=(e,t)=>{const r=t.DST,o="string"==typeof r?(0,i.utf8ToBytes)(r):r,s=(0,a.expand_message_xmd)(e,o,64,n.sha512);return G.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"}],[6556,{"./_shortw_utils.js":6544,"./abstract/hash-to-curve.js":6548,"./abstract/modular.js":6549,"./abstract/weierstrass.js":6553,"@noble/hashes/sha2":5185},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"),i=e("./_shortw_utils.js"),o=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,i.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,o.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,i.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,o.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,i.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,o.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"}],[6557,{"./nist.js":6556},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"}],[6558,{"./_shortw_utils.js":6544,"./abstract/hash-to-curve.js":6548,"./abstract/modular.js":6549,"./abstract/utils.js":6552,"./abstract/weierstrass.js":6553,"@noble/hashes/sha2":5185,"@noble/hashes/utils":5189},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"),i=e("@noble/hashes/utils"),o=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),i=BigInt(11),o=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,i,t)*g%t,w=(0,a.pow2)(y,o,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,o.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"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),c=m(o*e,t),u=m(-n*e,t);let f=(0,a.mod)(e-c*r-u*i,t),d=(0,a.mod)(-c*n-u*o,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 _(e){return P(e).bytes}function j(e,t,r=(0,i.randomBytes)(32)){const n=(0,c.ensureBytes)("message",e),{bytes:o,scalar:s}=P(t),a=(0,c.ensureBytes)("auxRand",r,32),u=v(s^T(w("BIP0340/aux",a))),f=w("BIP0340/nonce",u,o,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,o,n),g=new Uint8Array(64);if(g.set(h,0),g.set(v(B(p+m*s)),32),!k(g,n,o))throw new Error("sign: Invalid signature produced");return g}function k(e,t,r){const n=(0,c.ensureBytes)("signature",e,64),i=(0,c.ensureBytes)("message",t),o=(0,c.ensureBytes)("publicKey",r,32);try{const e=I(T(o)),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),i),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:_,sign:j,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 N=(()=>(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)))))(),O=(()=>(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}=O(b.create(e[0]));return N(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"}],[6559,{},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,i=Math.ceil,o=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,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=u-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function g(e,t){var r,n,i=e.c,o=t.c,s=e.s,a=t.s,c=e.e,u=t.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=c==u,!i||!o)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=o.length)?c:u,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[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!==o(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,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}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),N=20,O=4,R=-7,C=21,U=-1e7,D=1e7,L=!1,M=1,z=0,G={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},F="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function q(e,t){var r,i,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,F.length,"Base"),10==t&&H)return K(m=new q(e),N+m.e+1,O);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=F.slice(0,t),c=l=0,h=p.length;l<h;l++)if(r.indexOf(i=p.charAt(l))<0){if("."==i){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!==o(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 i,o,s,a,c;if(null==r?r=O:b(r,0,8),!e.c)return e.toString();if(i=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(o=(e=K(new q(e),t,r)).e,a=(c=m(e.c)).length,1==n||2==n&&(t<=o||o<=R)){for(;a<t;c+="0",a++);c=w(c,o)}else if(t-=s+(2===n&&o>s),c=E(c,o,"0"),o+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=o-a)>0)for(o+1==a&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function V(e,t){for(var r,n,i=1,o=new q(e[0]);i<e.length;i++)(!(n=new q(e[i])).s||(r=g(o,n))===t||0===r&&o.s===t)&&(o=n);return o}function W(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=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=o(h/b[s-f-1]%10);else if((p=i((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:o(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?o(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),N=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(b(r=e[t],0,8,t),O=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);G=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),F=r}}return{DECIMAL_PLACES:N,ROUNDING_MODE:O,EXPONENTIAL_AT:[R,C],RANGE:[U,D],CRYPTO:L,MODULO_MODE:M,POW_PRECISION:z,FORMAT:G,ALPHABET:F}},q.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!q.DEBUG)return!0;var t,r,n=e.c,i=e.e,a=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===a||-1===a)&&i>=-h&&i<=h&&i===o(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+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!==o(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(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 o(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=N:b(e,0,h),a=i(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]=o(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 i,o,s=[0],a=0,c=e.length;a<c;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var c,u,f,l,d,h,p,g,b=n.indexOf("."),y=N,w=O;for(b>=0&&(l=z,z=0,n=n.replace(".",""),h=(g=new q(i)).pow(n.length-b),z=l,g.c=t(E(m(h.c),h.e,"0"),10,o,e),g.e=g.c.length),f=l=(p=t(n,i,o,a?(c=F,e):(c=e,F))).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,o)).c,d=h.r,f=h.e),b=p[u=f+y+1],l=o/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(--o;++p[--u]>o;)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,i,o,s,a=0,c=e.length,u=t%d,f=t/d|0;for(e=e.slice();c--;)a=((i=u*(o=e[c]%d)+(n=f*o+(s=e[c]/d|0)*u)%d*d+a)/r|0)+(n/d|0)+f*s,e[c]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,s,a,f){var l,d,h,m,g,b,y,w,E,v,x,B,S,P,I,T,A,_=n.s==i.s?1:-1,j=n.c,k=i.c;if(!(j&&j[0]&&k&&k[0]))return new q(n.s&&i.s&&(j?!k||j[0]!=k[0]:k)?j&&0==j[0]||!k?0*_:_/0:NaN);for(E=(w=new q(_)).c=[],_=s+(d=n.e-i.e)+1,f||(f=c,d=p(n.e/u)-p(i.e/u),_=_/u|0),h=0;k[h]==(j[h]||0);h++);if(k[h]>(j[h]||0)&&d--,_<0)E.push(1),m=!0;else{for(P=j.length,T=k.length,h=0,_+=2,(g=o(f/(k[0]+1)))>1&&(k=e(k,g,f),j=e(j,g,f),T=k.length,P=j.length),S=T,x=(v=j.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=o(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++]=j[S]||0:(v=[j[S]],x=1)}while((S++<P||null!=v[0])&&_--);m=null!=v[0],E[0]||E.splice(0,1)}if(f==c){for(h=1,_=E[0];_>=10;_/=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)$/,_=/^\s*\+(?=[\w.])|^\s+|\s+$/g,x=function(e,t,r,n){var i,o=r?t:t.replace(_,"");if(A.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(P,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(I,"$1").replace(T,"0.$1")),t!=o))return new q(o,i);if(q.DEBUG)throw Error(s+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},j.absoluteValue=j.abs=function(){var e=new q(this);return e.s<0&&(e.s=1),e},j.comparedTo=function(e,t){return g(this,new q(e,t))},j.decimalPlaces=j.dp=function(e,t){var r,n,i,o=this;if(null!=e)return b(e,0,h),null==t?t=O:b(t,0,8),K(new q(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-p(this.e/u))*u,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},j.dividedBy=j.div=function(e,t){return r(this,new q(e,t),N,O)},j.dividedToIntegerBy=j.idiv=function(e,t){return r(this,new q(e,t),0,1)},j.exponentiatedBy=j.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=i(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=o(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,O,undefined):h)},j.integerValue=function(e){var t=new q(this);return null==e?e=O:b(e,0,8),K(t,t.e+1,e)},j.isEqualTo=j.eq=function(e,t){return 0===g(this,new q(e,t))},j.isFinite=function(){return!!this.c},j.isGreaterThan=j.gt=function(e,t){return g(this,new q(e,t))>0},j.isGreaterThanOrEqualTo=j.gte=function(e,t){return 1===(t=g(this,new q(e,t)))||0===t},j.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},j.isLessThan=j.lt=function(e,t){return g(this,new q(e,t))<0},j.isLessThanOrEqualTo=j.lte=function(e,t){return-1===(t=g(this,new q(e,t)))||0===t},j.isNaN=function(){return!this.s},j.isNegative=function(){return this.s<0},j.isPositive=function(){return this.s>0},j.isZero=function(){return!!this.c&&0==this.c[0]},j.minus=function(e,t){var r,n,i,o,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==O?-0:0)}if(f=p(f),l=p(l),d=d.slice(),a=f-l){for((o=a<0)?(a=-a,i=d):(l=f,i=h),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(n=(o=(a=d.length)<(t=h.length))?a:t,a=t=0;t<n;t++)if(d[t]!=h[t]){o=d[t]<h[t];break}if(o&&(i=d,d=h,h=i,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==O?-1:1,e.c=[e.e=0],e)},j.modulo=j.mod=function(e,t){var n,i,o=this;return e=new q(e,t),!o.c||!e.s||e.c&&!e.c[0]?new q(NaN):!e.c||o.c&&!o.c[0]?new q(o):(9==M?(i=e.s,e.s=1,n=r(o,e,0,3),e.s=i,n.s*=i):n=r(o,e,0,M),(e=o.minus(n.times(e))).c[0]||1!=M||(e.s=o.s),e)},j.multipliedBy=j.times=function(e,t){var r,n,i,o,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,i=f,f=m,m=i),i=f+m,y=[];i--;y.push(0));for(w=c,E=d,i=m;--i>=0;){for(r=0,g=B[i]%E,b=B[i]/E|0,o=i+(s=f);o>i;)r=((l=g*(l=x[--s]%E)+(a=b*l+(h=x[s]/E|0)*g)%E*E+y[o]+r)/w|0)+(a/E|0)+b*h,y[o--]=l%w;y[o]=r}return r?++n:y.splice(0,1),W(e,y,n)},j.negated=function(){var e=new q(this);return e.s=-e.s||null,e},j.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new q(e,t)).s,!i||!t)return new q(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/u,s=e.e/u,a=n.c,f=e.c;if(!o||!s){if(!a||!f)return new q(i/0);if(!a[0]||!f[0])return f[0]?e:new q(a[0]?n:0*i)}if(o=p(o),s=p(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=f):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(t=f.length)<0&&(r=f,f=a,a=r,t=i),i=0;t;)i=(a[--t]=a[t]+f[t]+i)/c|0,a[t]=c===a[t]?0:a[t]%c;return i&&(a=[i].concat(a),++s),W(e,a,s)},j.precision=j.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return b(e,1,h),null==t?t=O:b(t,0,8),K(new q(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*u+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},j.shiftedBy=function(e){return b(e,-9007199254740991,f),this.times("1e"+e)},j.squareRoot=j.sqrt=function(){var e,t,n,i,o,s=this,a=s.c,c=s.s,u=s.e,f=N+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(o=n,n=l.times(o.plus(r(s,o,f,1))),m(o.c).slice(0,c)===(t=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(K(n,n.e+N+2,1),e=!n.times(n).eq(s));break}if(!i&&(K(o,o.e+N+2,0),o.times(o).eq(s))){n=o;break}f+=4,c+=4,i=1}return K(n,n.e+N+1,O,e)},j.toExponential=function(e,t){return null!=e&&(b(e,0,h),e++),$(this,e,t,1)},j.toFixed=function(e,t){return null!=e&&(b(e,0,h),e=e+this.e+1),$(this,e,t)},j.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=G;else if("object"!=typeof r)throw Error(s+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var o,a=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,f=r.groupSeparator||"",l=a[0],d=a[1],h=i.s<0,p=h?l.slice(1):l,m=p.length;if(u&&(o=c,c=u,u=o,m-=o),c>0&&m>0){for(o=m%c||c,l=p.substr(0,o);o<m;o+=c)l+=f+p.substr(o,c);u>0&&(l+=f+p.slice(o)),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||"")},j.toFraction=function(e){var t,n,i,o,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),i=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!=(o=n.plus(p.times(i))).comparedTo(e);)n=i,i=o,h=d.plus(p.times(o=h)),d=o,t=f.minus(p.times(o=t)),f=o;return o=r(e.minus(n),i,0,1),d=d.plus(o.times(h)),n=n.plus(o.times(i)),d.s=h.s=y.s,g=r(h,i,a*=2,O).minus(y).abs().comparedTo(r(d,n,a,O).minus(y).abs())<1?[h,i]:[d,n],D=c,g},j.toNumber=function(){return+Z(this)},j.toPrecision=function(e,t){return null!=e&&b(e,1,h),$(this,e,t,2)},j.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=i<=R||i>=C?w(m(r.c),i):E(m(r.c),i,"0"):10===e&&H?t=E(m((r=K(new q(r),N+i+1,O)).c),r.e,"0"):(b(e,2,F.length,"Base"),t=v(E(m(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},j.valueOf=j.toJSON=function(){return Z(this)},j._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"}],[656,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=204;r.migrate=async(e,t)=>{if(e.meta.version=i,!(0,n.hasProperty)(e.data,"PreferencesController")||!(0,n.isObject)(e.data.PreferencesController))return;const{PreferencesController:r}=e.data;if(!(0,n.hasProperty)(r,"preferences")||!(0,n.isObject)(r.preferences))return;const{preferences:o}=r;!0!==o.showExtensionInFullSizeView&&!0!==o.useSidePanelAsDefault&&(o.useSidePanelAsDefault=!0,r.showSidePanelMigrationToast=!0,t.add("PreferencesController"))}}}},{package:"$root$",file:"app/scripts/migrations/204.ts"}],[6560,{bs58:6167},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),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),n=e(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(n.subarray(0,4),r.length),i.default.encode(s)},decode:function(e){var r=t(i.default.decode(e));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=i.default.decodeUnsafe(e);if(null!=r)return t(r)}}};var i=n(e("bs58"))}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/base.cjs"}],[6561,{"./base.cjs":6560,"@noble/hashes/sha256":5186},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 i=e("@noble/hashes/sha256"),o=n(e("./base.cjs"));r.default=(0,o.default)(function(e){return(0,i.sha256)((0,i.sha256)(e))})}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/index.cjs"}],[6562,{"bignumber.js":6559},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n,i;n=void 0,i=e=>{return t={68:(e,t,r)=>{const{BigNumber:n}=r(905);let i=null;const o=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(o)?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 i=e,i.Encoder.SEMANTIC_TYPES[n.name]=a,i.Tagged.TAGS[4]=c,i.Tagged.TAGS[5]=u,i}f.BigNumber=n,e.exports=f},905:t=>{t.exports=e}},r={},function e(n){var i=r[n];if(void 0!==i)return i.exports;var o=r[n]={exports:{}};return t[n](o,o.exports,e),o.exports}(68);var t,r},"object"==typeof r&&"object"==typeof t?t.exports=i(e("bignumber.js")):"function"==typeof define&&define.amd?define([],i):"object"==typeof r?r.cborBigDecimal=i(e("bignumber.js")):n.cborBigDecimal=i(n.BigNumber)}}},{package:"eth-lattice-keyring>gridplus-sdk>cbor-bigdecimal",file:"node_modules/gridplus-sdk/node_modules/cbor-bigdecimal/dist/cbor-bigdecimal.js"}],[6563,{"./internal/abi.js":6631,abitype:5978},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 i.isSignatures(e)?n.parseAbi(e):e};const n=e("abitype"),i=e("./internal/abi.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Abi.js"}],[6564,{"./AbiItem.js":6568,"./AbiParameters.js":6569,"./Hex.js":6595,abitype:5978},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 i=r.data.replace(n,"0x");return o.decode(t.inputs,i)},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:i}=r;return s.concat(n,t.inputs?.length&&i?.length?o.encode(t.inputs,i):"0x")},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e){return i.from(e)},r.fromAbi=a;const n=e("abitype"),i=e("./AbiItem.js"),o=e("./AbiParameters.js"),s=e("./Hex.js");function a(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new i.NotFoundError({name:"constructor"});return t}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiConstructor.js"}],[6565,{"./AbiItem.js":6568,"./AbiParameters.js":6569,"./Hex.js":6595,abitype:5978},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,i]=e;return[c(t,r),n,i]}return e})();if(s.size(r)<4)throw new i.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const a=o.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),i=r.length>0?o.encode(t.inputs,r[0]):undefined;return i?s.concat(n,i):n},r.format=function(e){return n.formatAbiItem(e)},r.from=a,r.fromAbi=c,r.getSelector=u;const n=e("abitype"),i=e("./AbiItem.js"),o=e("./AbiParameters.js"),s=e("./Hex.js");function a(e,t={}){return i.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 o=i.fromAbi(e,t,n);if("error"!==o.type)throw new i.NotFoundError({name:t,type:"error"});return o}function u(e){return i.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"}],[6566,{"./AbiItem.js":6568,"./AbiParameters.js":6569,"./Address.js":6572,"./Bytes.js":6584,"./Errors.js":6590,"./Hash.js":6593,"./Hex.js":6595,"./internal/cursor.js":6636,"./internal/errors.js":6639,abitype:5978},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[i,o]of r.entries()){if(null===o||o===undefined)continue;const s=e.inputs[i];if(!s)throw new b({abiEvent:e,name:`${i}`});const a=Array.isArray(o)?o:[o];let c=!1;for(const e of a)n(s,e,t[i])&&(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[i,o]of Object.entries(r)){if(null===o||o===undefined)continue;const s=e.inputs.find(e=>e.name===i);if(!s)throw new b({abiEvent:e,name:i});const a=Array.isArray(o)?o:[o];let c=!1;for(const e of a)n(s,e,t[i])&&(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:i}=r,[s,...a]=i,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(o.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=o.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 o.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),i=Array.isArray(r)?r:Object.values(r).length>0?e?.map((e,t)=>r[e.name??t])??[]:[];if(i.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 o.encode([e],[t])};n=e?.map((e,r)=>Array.isArray(i[r])?i[r].map((n,o)=>t(e,i[r][o])):void 0!==i[r]&&null!==i[r]?t(e,i[r]):null)??[]}}return{topics:[t.hash?t.hash:m(t),...n]}},r.format=h,r.from=function(e,t={}){return i.from(e,t)},r.fromAbi=p,r.getSelector=m;const n=e("abitype"),i=e("./AbiItem.js"),o=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=i.fromAbi(e,t,r);if("event"!==n.type)throw new i.NotFoundError({name:t,type:"event"});return n}function m(e){return i.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: (${o.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"}],[6567,{"./AbiItem.js":6568,"./AbiParameters.js":6569,"./Hex.js":6595,abitype:5978},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 i.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const c=n?a([t,...n],r):t;return s.size(r)<=4?undefined:o.decode(c.inputs,s.slice(r,4))},r.decodeResult=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,i]=e;return[a(t,r),n,i]}return e})(),i=o.decode(t.outputs,r,n);if(i&&0===Object.keys(i).length)return undefined;if(i&&1===Object.keys(i).length)return Array.isArray(i)?i[0]:Object.values(i)[0];return i},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,i=n?a([t,...n],t.name,{args:r}):t,u=c(i),f=r.length>0?o.encode(i.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,i]=e;return[a(t,r),n,i]}return e})(),{as:i="Array"}=n,s=1===t.outputs.length?[r]:Array.isArray(r)?r:"Object"===i?Object.values(r):[r];return o.encode(t.outputs,s)},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e,t={}){return i.from(e,t)},r.fromAbi=a,r.getSelector=c;const n=e("abitype"),i=e("./AbiItem.js"),o=e("./AbiParameters.js"),s=e("./Hex.js");function a(e,t,r){const n=i.fromAbi(e,t,r);if("function"!==n.type)throw new i.NotFoundError({name:t,type:"function"});return n}function c(e){return i.getSelector(e)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiFunction.js"}],[6568,{"./Errors.js":6590,"./Hash.js":6593,"./Hex.js":6595,"./internal/abiItem.js":6632,abitype:5978},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,i=Array.isArray(e)||"string"==typeof e?n.parseAbiItem(e):e;return{...i,...r?{hash:l(i)}:{}}},r.fromAbi=c,r.getSelector=u,r.getSignature=f,r.getSignatureHash=l;const n=e("abitype"),i=e("./Errors.js"),o=e("./Hash.js"),s=e("./Hex.js"),a=e("./internal/abiItem.js");function c(e,t,r){const{args:n=[],prepare:i=!0}=r??{},o=s.validate(t,{strict:!1}),c=e.filter(e=>o?"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],...i?{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,...i?{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,...i?{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:o.keccak256(s.fromString(f(t)))}class d extends i.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 i.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 i.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"}],[6569,{"./Address.js":6572,"./Bytes.js":6584,"./Errors.js":6590,"./Hex.js":6595,"./Solidity.js":6613,"./internal/abiParameters.js":6633,"./internal/cursor.js":6636,abitype:5978},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:i=!1}=r,s="string"==typeof t?o.fromHex(t):t,f=u.create(s);if(0===o.size(s)&&e.length>0)throw new h;if(o.size(s)&&o.size(s)<32)throw new d({data:"string"==typeof t?t:a.fromBytes(t),parameters:e,size:o.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[o,s]=c.decodeParameter(f,r,{checksumAddress:i,staticPosition:0});l+=s,"Array"===n?p.push(o):p[r.name??t]=o}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 i=c.prepareParameters({checksumAddress:n,parameters:e,values:t}),o=c.encode(i);return 0===o.length?"0x":o},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"),i=e("./Address.js"),o=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 i=e[n],o=t[n];r.push(l.encode(i,o))}return a.concat(...r)}!function(e){e.encode=function e(t,r,n=!1){if("address"===t){const e=r;return i.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 o=t.match(f.integerRegex);if(o){const[e,t,i="256"]=o,s=Number.parseInt(i,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,i=[];for(let t=0;t<r.length;t++)i.push(e(n,r[t],!0));return 0===i.length?"0x":a.concat(...i)}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"}],[657,{"@metamask/utils":3915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const i=r.version=205;r.migrate=async(e,t)=>{if(e.meta.version=i,!(0,n.hasProperty)(e.data,"GatorPermissionsController")||!(0,n.isObject)(e.data.GatorPermissionsController))return;const{GatorPermissionsController:r}=e.data,o=r;((0,n.hasProperty)(o,"grantedPermissions")||(0,n.hasProperty)(o,"gatorPermissionsMapSerialized")||(0,n.hasProperty)(o,"isGatorPermissionsEnabled")||(0,n.hasProperty)(o,"gatorPermissionsProviderSnapId"))&&(delete o.gatorPermissionsMapSerialized,delete o.isGatorPermissionsEnabled,delete o.gatorPermissionsProviderSnapId,Array.isArray(o.grantedPermissions)&&o.grantedPermissions.forEach(e=>{(0,n.isObject)(e)&&((0,n.hasProperty)(e,"status")||(e.status=(0,n.hasProperty)(e,"revocationMetadata")?"Revoked":"Active"))}),t.add("GatorPermissionsController"))}}}},{package:"$root$",file:"app/scripts/migrations/205.ts"}],[6570,{"./Address.js":6572,"./Errors.js":6590,"./Hash.js":6593,"./Hex.js":6595},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[i,a]=e[r];i&&n.assert(i,{strict:!1}),t.push({address:i,storageKeys:a.map(e=>o.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:i}of e){for(let e=0;e<i.length;e++)if(32!==s.size(i[e]))throw new a({storageKey:i[e]});r&&n.assert(r,{strict:!1}),t.push([r,i])}return t};const n=e("./Address.js"),i=e("./Errors.js"),o=e("./Hash.js"),s=e("./Hex.js");class a extends i.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"}],[6571,{},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"}],[6572,{"./Bytes.js":6584,"./Caches.js":6585,"./Errors.js":6590,"./Hash.js":6593,"./PublicKey.js":6604},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"),i=e("./Caches.js"),o=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(i.checksum.has(e))return i.checksum.get(e);u(e,{strict:!1});const t=e.substring(2).toLowerCase(),r=s.keccak256(n.fromString(t),{as:"Bytes"}),o=t.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&o[e]&&(o[e]=o[e].toUpperCase()),(15&r[e>>1])>=8&&o[e+1]&&(o[e+1]=o[e+1].toUpperCase());const a=`0x${o.join("")}`;return i.checksum.set(e,a),a}function l(e,t={}){const{checksum:r=!1}=t;return u(e),r?f(e):e}class d extends o.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 o.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 o.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"}],[6573,{"./Bytes.js":6584,"./Hex.js":6595},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,o={}){const{as:s=("string"==typeof e?"Hex":"Bytes")}=o,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:i.from(l)},r.encrypt=async function(e,t,o={}){const{as:s=("string"==typeof e?"Hex":"Bytes")}=o,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:i.from(u)},r.getKey=async function(e){const{iterations:t=9e5,password:r,salt:i=o(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:i,iterations:t,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])},r.randomSalt=o;const n=e("./Bytes.js"),i=e("./Hex.js");function o(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"}],[6574,{"./Hash.js":6593,"./Hex.js":6595,"./Rlp.js":6605,"./Signature.js":6611},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"),i=e("./Hex.js"),o=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,i=s.extract(e);return{address:t,chainId:Number(r),nonce:BigInt(n),...i}}function u(e){const[t,r,n,i,o,c]=e;let u={address:r,chainId:"0x"===t?0:Number(t),nonce:"0x"===n?0n:BigInt(n)};return i&&o&&c&&(u={...u,...s.fromTuple([i,o,c])}),a(u)}function f(e,t={}){const{presign:r}=t;return n.keccak256(i.concat("0x05",o.fromHex(d(r?{address:e.address,chainId:e.chainId,nonce:e.nonce}:e))))}function l(e){const{address:t,chainId:r,nonce:n,...o}=e;return{address:t,chainId:i.fromNumber(r),nonce:i.fromNumber(n),...s.toRpc(o)}}function d(e){const{address:t,chainId:r,nonce:n}=e,o=s.extract(e);return[r?i.fromNumber(r):"0x",t,n?i.fromNumber(n):"0x",...o?s.toTuple(o):[]]}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Authorization.js"}],[6575,{"./Bytes.js":6584,"./Hex.js":6595,"./internal/base58.js":6634},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 o.from(e)},r.fromHex=function(e){return o.from(e)},r.fromString=function(e){return o.from(n.fromString(e))},r.toBytes=function(e){return n.fromHex(s(e))},r.toHex=s,r.toString=function(e){return i.toString(s(e))};const n=e("./Bytes.js"),i=e("./Hex.js"),o=e("./internal/base58.js");function s(e){let t=BigInt(0),r=0,n=!0;for(let i=0;i<e.length;i++){const s=e[i];if(n&&"1"===s?r++:n=!1,"bigint"!=typeof o.alphabetToInteger[s])throw new Error("invalid base58 character: "+s);t*=58n,t+=o.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"}],[6576,{"./Bytes.js":6584,"./Hex.js":6595},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 i.fromBytes(f(e))},r.toString=function(e){return n.toString(f(e))};const n=e("./Bytes.js"),i=e("./Hex.js"),o=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,i=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]);i[t]=a[n>>18],i[t+1]=a[n>>12&63],i[t+2]=a[n>>6&63],i[t+3]=a[63&n]}const o=e.length%3,c=4*Math.floor(e.length/3)+(o&&o+1);let u=s.decode(new Uint8Array(i.buffer,0,c));return r&&1===o&&(u+="=="),r&&2===o&&(u+="="),n&&(u=u.replaceAll("+","-").replaceAll("/","_")),u}function f(e){const t=e.replace(/=+$/,""),r=t.length,n=new Uint8Array(r+3);o.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 i=3*(r>>2)+(r%4&&r%4-1);return new Uint8Array(n.buffer,0,i)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Base64.js"}],[6577,{"./Bytes.js":6584,"@noble/hashes/blake3":5177},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=i.slice(t,0,31),s=i.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 i.isEqual(f.stem,r)?(f.values[n]=s,f):o(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(i.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(i.concat(r[t],r[t+1])));r=e}return u(i.concat(t.stem,new Uint8Array(1).fill(0),r[0]))}(e.root)};const n=e("@noble/hashes/blake3"),i=e("./Bytes.js");function o(e,t,r,n,i,c){if(t[c]===r[c]){const a=s();return 0===t[c]?a.left=o(e,t,r,n,i,c+1):a.right=o(e,t,r,n,i,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]=i,u.right=e):(u.right=a(l),u.right.values[n]=i,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"}],[6578,{"./Bytes.js":6584,"./Errors.js":6590,"./Hash.js":6593,"./Hex.js":6595,"./Kzg.js":6598,"./internal/cursor.js":6636},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 i=t.as??("string"==typeof e?"Hex":"Bytes"),o="string"==typeof e?n.fromHex(e):e,c=n.size(o);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=o.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"===i?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"),i=[];for(const{commitment:t}of e)i.push(f(t,{as:n,version:r}));return i},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}),i=t.proofs??h(e,{commitments:n,kzg:r}),o=[];for(let t=0;t<e.length;t++)o.push({blob:e[t],commitment:n[t],proof:i[t]});return o},r.toVersionedHashes=function(e,t){return u(d(e,t),t)};const n=e("./Bytes.js"),i=e("./Errors.js"),o=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"),i=[];for(const t of e)i.push(f(t,{as:n,version:r}));return i}function f(e,t={}){const{version:r=1}=t,n=t.as??("string"==typeof e?"Hex":"Bytes"),i=o.sha256(e,{as:"Bytes"});return i.set([r],0),"Bytes"===n?i:s.fromBytes(i)}function l(e,t){const r=t??("string"==typeof e[0]?"Hex":"Bytes"),i="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,o=i.reduce((e,t)=>e+t.length,0),c=a.create(new Uint8Array(o));let u=!0;for(const e of i){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,i=t.as??("string"==typeof e[0]?"Hex":"Bytes"),o="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,a=[];for(const e of o)a.push(Uint8Array.from(r.blobToKzgCommitment(e)));return"Bytes"===i?a:a.map(e=>s.fromBytes(e))}function h(e,t){const{kzg:r}=t,i=t.as??("string"==typeof e[0]?"Hex":"Bytes"),o="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<o.length;e++){const t=o[e],n=a[e];c.push(Uint8Array.from(r.computeBlobKzgProof(t,n)))}return"Bytes"===i?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 i.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 i.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 i.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 i.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 i.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"}],[6579,{"./Hex.js":6595,"./Transaction.js":6615,"./Withdrawal.js":6629},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:i.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(o.toRpc),withdrawalsRoot:e.withdrawalsRoot}},r.fromRpc=function(e,t={}){if(!e)return null;const r=e.transactions.map(e=>"string"==typeof e?e:i.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(o.fromRpc)}};const n=e("./Hex.js"),i=e("./Transaction.js"),o=e("./Withdrawal.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Block.js"}],[658,{"@metamask/utils":3915,"ethereumjs-util":6428},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils"),i=e("ethereumjs-util");const o=r.version=206,s=["0x1079","0xa5bf"],a=(0,i.zeroAddress)();r.migrate=async(e,t)=>{if(e.meta.version=o,!(0,n.hasProperty)(e.data,"TokenBalancesController")||!(0,n.isObject)(e.data.TokenBalancesController))return;const{TokenBalancesController:r}=e.data;if(!(0,n.hasProperty)(r,"tokenBalances")||!(0,n.isObject)(r.tokenBalances))return;const{tokenBalances:i}=r;let c=!1;Object.values(i).forEach(e=>{(0,n.isObject)(e)&&s.forEach(t=>{t in e&&(0,n.isObject)(e[t])&&e[t][a]&&"0x0"!==e[t][a]&&(e[t][a]="0x0",c=!0)})}),c&&t.add("TokenBalancesController")}}}},{package:"$root$",file:"app/scripts/migrations/206.ts"}],[6580,{"./Hex.js":6595,"./Withdrawal.js":6629},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(i.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(i.toRpc)}}};const n=e("./Hex.js"),i=e("./Withdrawal.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BlockOverrides.js"}],[6581,{"./Bytes.js":6584,"./Hash.js":6593,"./Hex.js":6595},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),o=i.keccak256(t,{as:"Bytes"});for(const e of[0,2,4]){const t=o[e+1]+(o[e]<<8)&2047;if(!(r[255-Math.floor(t/8)]&1<<t%8))return!1}return!0},r.validate=function(e){return o.validate(e)&&256===o.size(e)};const n=e("./Bytes.js"),i=e("./Hash.js"),o=e("./Hex.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Bloom.js"}],[6582,{"./Bytes.js":6584,"./Hex.js":6595,"@noble/curves/bls12-381":6554},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}),i=s({privateKey:n,size:r});return{privateKey:n,publicKey:i}},r.getPublicKey=s,r.randomPrivateKey=a,r.sign=function(e){const{payload:t,privateKey:r,suite:o,size:s="short-key:long-sig"}=e,a=("short-key:long-sig"===s?n.bls12_381.G2:n.bls12_381.G1).hashToCurve(i.from(t),o?{DST:i.fromString(o)}: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,o=e.publicKey,s=e.signature,a="bigint"==typeof s.x,c=(a?n.bls12_381.G1:n.bls12_381.G2).hashToCurve(i.from(t),r?{DST:i.fromString(r)}:undefined);return n.bls12_381.fields.Fp12.eql(a?n.bls12_381.pairingBatch([{g1:c,g2:new n.bls12_381.G2.ProjectivePoint(o.x,o.y,o.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(o.x,o.y,o.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"),i=e("./Bytes.js"),o=e("./Hex.js");function s(e){const{privateKey:t,size:r="short-key:long-sig"}=e,i="short-key:long-sig"===r?n.bls12_381.G1:n.bls12_381.G2,{px:s,py:a,pz:c}=i.ProjectivePoint.fromPrivateKey(o.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?o.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"}],[6583,{"./Hex.js":6595,"@noble/curves/bls12-381":6554},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.toBytes=o,r.toHex=function(e){return i.fromBytes(o(e))},r.fromBytes=s,r.fromHex=function(e,t){return s(i.toBytes(e))};const n=e("@noble/curves/bls12-381"),i=e("./Hex.js");function o(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"}]],[],{});