{
  "version": 3,
  "sources": ["../../src/methods/account/getLatestNonce.ts"],
  "sourcesContent": ["import { accountNonceSelector } from '../../store/selectors/accountSelectors';\nimport { transactionsSliceSelector } from '../../store/selectors/transactionsSelector';\nimport { getState } from '../../store/store';\nimport { AccountType } from '../../types/account.types';\n\nexport function getLatestNonce(apiAccount: AccountType | null) {\n  const state = getState();\n  const transactionsSessions = transactionsSliceSelector(state);\n  const currentAccountNonce = accountNonceSelector(state);\n\n  // Get the max transactions nonce\n  let lastTransactionNonce = Object.keys(transactionsSessions)\n    .map(Number) // Convert keys to numbers (timestamps)\n    .reduce((maxNonce, timestamp) => {\n      const transactions = transactionsSessions[timestamp]?.transactions || [];\n      return Math.max(maxNonce, ...transactions.map((tx) => tx.nonce), 0);\n    }, 0);\n\n  if (lastTransactionNonce > 0) {\n    lastTransactionNonce += 1; // Increment only if there's at least one pending transaction\n  }\n\n  if (apiAccount == null) {\n    const currentStoreNonce = Math.max(\n      lastTransactionNonce,\n      currentAccountNonce\n    );\n    return currentStoreNonce;\n  }\n\n  const currentNonce = Math.max(\n    lastTransactionNonce,\n    apiAccount.nonce,\n    currentAccountNonce\n  );\n\n  return currentNonce;\n}\n"],
  "mappings": "sHAKO,SAASA,EAAeC,EAAgC,CAC7D,IAAMC,EAAQC,EAAS,EACjBC,EAAuBC,EAA0BH,CAAK,EACtDI,EAAsBC,EAAqBL,CAAK,EAGlDM,EAAuB,OAAO,KAAKJ,CAAoB,EACxD,IAAI,MAAM,EACV,OAAO,CAACK,EAAUC,IAAc,CAC/B,IAAMC,EAAeP,EAAqBM,CAAS,GAAG,cAAgB,CAAC,EACvE,OAAO,KAAK,IAAID,EAAU,GAAGE,EAAa,IAAKC,GAAOA,EAAG,KAAK,EAAG,CAAC,CACpE,EAAG,CAAC,EAMN,OAJIJ,EAAuB,IACzBA,GAAwB,GAGtBP,GAAc,KACU,KAAK,IAC7BO,EACAF,CACF,EAImB,KAAK,IACxBE,EACAP,EAAW,MACXK,CACF,CAGF",
  "names": ["getLatestNonce", "apiAccount", "state", "getState", "transactionsSessions", "transactionsSliceSelector", "currentAccountNonce", "accountNonceSelector", "lastTransactionNonce", "maxNonce", "timestamp", "transactions", "tx"]
}
