@mx-cartographer/experiences 9.7.128 → 9.7.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/core/types/localization/InsightsFeedCopy.d.ts +11 -15
  3. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.d.ts +5 -1
  4. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +78 -30
  5. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
  6. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListContent.d.ts +26 -13
  7. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListContent.es.js +107 -136
  8. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListContent.es.js.map +1 -1
  9. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.d.ts +21 -7
  10. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.es.js +34 -17
  11. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.es.js.map +1 -1
  12. package/dist/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.d.ts +3 -1
  13. package/dist/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.es.js +10 -8
  14. package/dist/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.es.js.map +1 -1
  15. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +46 -45
  16. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  17. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js +23 -22
  18. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js.map +1 -1
  19. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -25
  20. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
  21. package/dist/insights-v2/actionBlocks/HelpBlock/layout.d.ts +0 -1
  22. package/dist/insights-v2/actionBlocks/HelpBlock/layout.es.js +6 -6
  23. package/dist/insights-v2/actionBlocks/HelpBlock/layout.es.js.map +1 -1
  24. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js +8 -7
  25. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js.map +1 -1
  26. package/dist/insights-v2/actionBlocks/OverdraftBlock/layout.es.js +11 -13
  27. package/dist/insights-v2/actionBlocks/OverdraftBlock/layout.es.js.map +1 -1
  28. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.d.ts +10 -12
  29. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js +20 -19
  30. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js.map +1 -1
  31. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/index.d.ts +1 -1
  32. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.d.ts +3 -12
  33. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.es.js +8 -8
  34. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.es.js.map +1 -1
  35. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.d.ts +9 -0
  36. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js +27 -10
  37. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js.map +1 -1
  38. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.d.ts +1 -7
  39. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +49 -59
  40. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
  41. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashContent.es.js +29 -75
  42. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashContent.es.js.map +1 -1
  43. package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.d.ts +12 -0
  44. package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.es.js +18 -9
  45. package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.es.js.map +1 -1
  46. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +14 -13
  47. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  48. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +10 -9
  49. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
  50. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +0 -3
  51. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +30 -33
  52. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  53. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +31 -30
  54. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
  55. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +14 -14
  56. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +4 -4
  57. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +4 -4
  58. package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js +4 -4
  59. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js +11 -10
  60. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js.map +1 -1
  61. package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +5 -5
  62. package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +4 -4
  63. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/EmergencySavingsAccountPicker.es.js +1 -1
  64. package/dist/insights-v2/blocks/slotReaders.d.ts +5 -0
  65. package/dist/insights-v2/blocks/slotReaders.es.js +7 -5
  66. package/dist/insights-v2/blocks/slotReaders.es.js.map +1 -1
  67. package/dist/insights-v2/components/AmountBreakdownCard.es.js +9 -8
  68. package/dist/insights-v2/components/AmountBreakdownCard.es.js.map +1 -1
  69. package/dist/insights-v2/components/InsightListRow.d.ts +31 -0
  70. package/dist/insights-v2/components/InsightListRow.es.js +111 -0
  71. package/dist/insights-v2/components/InsightListRow.es.js.map +1 -0
  72. package/dist/insights-v2/components/SubTabs.d.ts +2 -1
  73. package/dist/insights-v2/components/SubTabs.es.js +10 -10
  74. package/dist/insights-v2/components/SubTabs.es.js.map +1 -1
  75. package/dist/insights-v2/index.es.js +12 -12
  76. package/dist/insights-v2/mappings/blocks.es.js +21 -21
  77. package/dist/recurringtransactions/components/RecurringTransactionDetails.d.ts +3 -1
  78. package/dist/recurringtransactions/components/RecurringTransactionDetails.es.js +169 -120
  79. package/dist/recurringtransactions/components/RecurringTransactionDetails.es.js.map +1 -1
  80. package/dist/recurringtransactions/components/RecurringTransactionList.d.ts +3 -1
  81. package/dist/recurringtransactions/components/RecurringTransactionList.es.js +151 -118
  82. package/dist/recurringtransactions/components/RecurringTransactionList.es.js.map +1 -1
  83. package/dist/transactions/components/shared/TransactionDetails.d.ts +1 -6
  84. package/dist/transactions/components/shared/TransactionDetails.es.js +149 -199
  85. package/dist/transactions/components/shared/TransactionDetails.es.js.map +1 -1
  86. package/dist/transactions/components/shared/transactiondetails/Description.d.ts +2 -0
  87. package/dist/transactions/components/shared/transactiondetails/Description.es.js +59 -50
  88. package/dist/transactions/components/shared/transactiondetails/Description.es.js.map +1 -1
  89. package/dist/transactions/components/shared/transactiondetails/TransactionHeaderParts.d.ts +10 -0
  90. package/dist/transactions/components/shared/transactiondetails/TransactionHeaderParts.es.js +68 -0
  91. package/dist/transactions/components/shared/transactiondetails/TransactionHeaderParts.es.js.map +1 -0
  92. package/package.json +1 -1
@@ -1,39 +1,56 @@
1
- import { formatSignedCurrency as r } from "../../../core/utils/NumberFormatting.es.js";
2
- import { resolveVariantConfig as u } from "../../blocks/resolveVariantConfig.es.js";
3
- import { finiteNumberOf as t } from "../TransactionHistoryBlock/utils.es.js";
4
- var s = (a) => a.balance ?? 0, _ = (a, e, l) => {
5
- const i = new Set(a.account_guids?.length ? a.account_guids : l.map(({ guid: n }) => n));
6
- return e.filter((n) => i.has(n.guid)).sort((n, o) => s(o) - s(n));
7
- }, b = (a) => a.reduce((e, l) => e + s(l), 0), f = (a) => a?.replace(/\D/g, "").slice(-4) ?? "", d = (a, e) => {
8
- const l = t(a?.available_funds), i = t(a?.planned_expenses), n = t(a?.total_remaining);
9
- if (!(l === void 0 || i === void 0 || n === void 0))
1
+ import { AccountType as u } from "../../../core/types/Account.es.js";
2
+ import m from "../../../common/utils/AccountDisplayName.es.js";
3
+ import { formatSignedCurrency as l } from "../../../core/utils/NumberFormatting.es.js";
4
+ import { getAccountStartingBalance as d } from "../../../core/utils/AccountUtils.es.js";
5
+ import { resolveVariantConfig as g } from "../../blocks/resolveVariantConfig.es.js";
6
+ import { asNumber as s } from "../../blocks/slotReaders.es.js";
7
+ var c = (a) => a.balance ?? 0, E = (a, e, i) => {
8
+ const o = new Set(a.account_guids?.length ? a.account_guids : i.map(({ guid: n }) => n));
9
+ return e.filter((n) => o.has(n.guid)).sort((n, t) => c(t) - c(n));
10
+ }, v = /* @__PURE__ */ new Set([u.CHECKING, u.CHECKING_LINE_OF_CREDIT]), I = (a) => v.has(a.account_type), _ = (a, e) => ({
11
+ balance: d(a, e),
12
+ guid: a.guid,
13
+ institutionGuid: a.institution_guid ?? "",
14
+ name: m(a)
15
+ }), N = (a, e, i, o) => {
16
+ const n = i.map((t) => _(t, o)).sort((t, r) => r.balance - t.balance);
17
+ return {
18
+ header: e,
19
+ key: a,
20
+ rows: n,
21
+ total: n.reduce((t, r) => t + r.balance, 0)
22
+ };
23
+ }, b = (a, e) => {
24
+ const i = s(a?.available_funds), o = s(a?.planned_expenses), n = s(a?.total_remaining);
25
+ if (!(i === void 0 || o === void 0 || n === void 0))
10
26
  return {
11
27
  heading: e.how_is_this_calculated,
12
28
  rows: [
13
29
  {
14
30
  key: "available_funds",
15
31
  label: e.available_funds,
16
- value: r(l)
32
+ value: l(i)
17
33
  },
18
34
  {
19
35
  key: "planned_expenses",
20
36
  label: e.planned_expenses,
21
- value: r(-i)
37
+ value: l(-o)
22
38
  },
23
39
  {
24
40
  bold: !0,
25
41
  key: "remaining",
26
42
  label: e.remaining,
27
- value: r(n)
43
+ value: l(n)
28
44
  }
29
45
  ]
30
46
  };
31
- }, m = { monthly_obligations: d }, p = (a, e) => u(m, a?.variant, "monthly_obligations", "AccountListBlock")(a?.drilldown_data, e);
47
+ }, p = { monthly_obligations: b }, k = (a, e) => g(p, a?.variant, "monthly_obligations", "AccountListBlock")(a?.drilldown_data, e);
32
48
  export {
33
- p as buildSummary,
34
- f as lastFour,
35
- _ as resolveBeatAccounts,
36
- b as sumBalances
49
+ k as buildSummary,
50
+ I as isCheckingAccount,
51
+ E as resolveBeatAccounts,
52
+ _ as toAccountRow,
53
+ N as toAccountSection
37
54
  };
38
55
 
39
56
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/layout.ts"],"sourcesContent":["import type { Account, Beat, DrilldownData } from '../../../core'\nimport type { AccountListCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport { formatSignedCurrency } from '../../../core/utils/NumberFormatting'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\nimport { finiteNumberOf } from '../TransactionHistoryBlock/utils'\n\nconst balanceOf = (account: Account) => account.balance ?? 0\n\n/** The beat's `account_guids` among visible accounts (or every cash account when it names none), largest first. */\nexport const resolveBeatAccounts = (\n beat: Beat,\n visibleAccounts: Account[],\n cashAccounts: Account[],\n): Account[] => {\n const guids = new Set<string>(\n beat.account_guids?.length ? beat.account_guids : cashAccounts.map(({ guid }) => guid),\n )\n\n return visibleAccounts\n .filter((account) => guids.has(account.guid))\n .sort((a, b) => balanceOf(b) - balanceOf(a))\n}\n\nexport const sumBalances = (accounts: Account[]): number =>\n accounts.reduce((total, account) => total + balanceOf(account), 0)\n\n/** The last four digits of an account number; empty when the account has none. */\nexport const lastFour = (accountNumber?: string): string =>\n accountNumber?.replace(/\\D/g, '').slice(-4) ?? ''\n\n/** A generic breakdown row: a label and its already-formatted display value. */\nexport interface SummaryRow {\n key: string\n label: string\n value: string\n /** The emphasised total row. */\n bold?: boolean\n}\n\n/** The \"How is this calculated?\" breakdown, built per insight so AccountListContent stays generic. */\nexport interface AccountListSummary {\n heading: string\n rows: SummaryRow[]\n}\n\ntype SummaryBuilder = (\n drilldown: DrilldownData | undefined,\n copy: AccountListCopy,\n) => AccountListSummary | undefined\n\n/** Monthly Obligations breakdown; undefined unless all three figures are finite, so the drawer falls back to the list. */\nconst buildMonthlyObligationsSummary: SummaryBuilder = (drilldown, copy) => {\n const availableFunds = finiteNumberOf(drilldown?.available_funds)\n const plannedExpenses = finiteNumberOf(drilldown?.planned_expenses)\n const totalRemaining = finiteNumberOf(drilldown?.total_remaining)\n\n if (\n availableFunds === undefined ||\n plannedExpenses === undefined ||\n totalRemaining === undefined\n ) {\n return undefined\n }\n\n return {\n heading: copy.how_is_this_calculated,\n rows: [\n {\n key: 'available_funds',\n label: copy.available_funds,\n value: formatSignedCurrency(availableFunds),\n },\n // Shown as a deduction (-$1,200.00), per Figma; the figure is stored positive.\n {\n key: 'planned_expenses',\n label: copy.planned_expenses,\n value: formatSignedCurrency(-plannedExpenses),\n },\n {\n bold: true,\n key: 'remaining',\n label: copy.remaining,\n value: formatSignedCurrency(totalRemaining),\n },\n ],\n }\n}\n\nconst SUMMARY_BUILDERS = {\n monthly_obligations: buildMonthlyObligationsSummary,\n} satisfies Record<string, SummaryBuilder>\n\n/**\n * Builds the drawer breakdown from whichever CTA opened it, keyed by the CTA's `variant` (ditto's\n * `*_cta_variant`). Unknown/absent variants fall back to Monthly Obligations and warn.\n */\nexport const buildSummary = (\n cta: { variant?: string | null; drilldown_data?: DrilldownData } | undefined,\n copy: AccountListCopy,\n): AccountListSummary | undefined =>\n resolveVariantConfig(\n SUMMARY_BUILDERS,\n cta?.variant,\n 'monthly_obligations',\n 'AccountListBlock',\n )(cta?.drilldown_data, copy)\n"],"mappings":";;;AAMA,IAAM,IAAA,CAAa,MAAqB,EAAQ,WAAW,GAG9C,IAAA,CACX,GACA,GACA,MACc;AACd,QAAM,IAAQ,IAAI,IAChB,EAAK,eAAe,SAAS,EAAK,gBAAgB,EAAa,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,CACvF;AAEA,SAAO,EACJ,OAAA,CAAQ,MAAY,EAAM,IAAI,EAAQ,IAAI,CAAC,EAC3C,KAAA,CAAM,GAAG,MAAM,EAAU,CAAC,IAAI,EAAU,CAAC,CAAC;AAC/C,GAEa,IAAA,CAAe,MAC1B,EAAS,OAAA,CAAQ,GAAO,MAAY,IAAQ,EAAU,CAAO,GAAG,CAAC,GAGtD,IAAA,CAAY,MACvB,GAAe,QAAQ,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,IAuB3C,IAAA,CAAkD,GAAW,MAAS;AAC1E,QAAM,IAAiB,EAAe,GAAW,eAAe,GAC1D,IAAkB,EAAe,GAAW,gBAAgB,GAC5D,IAAiB,EAAe,GAAW,eAAe;AAEhE,MACE,EAAA,MAAmB,UACnB,MAAoB,UACpB,MAAmB;AAKrB,WAAO;AAAA,MACL,SAAS,EAAK;AAAA,MACd,MAAM;AAAA,QACJ;AAAA,UACE,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAc;AAAA,QAC5C;AAAA,QAEA;AAAA,UACE,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAC,CAAe;AAAA,QAC9C;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAc;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACF,GAEM,IAAmB,EACvB,qBAAqB,EACvB,GAMa,IAAA,CACX,GACA,MAEA,EACE,GACA,GAAK,SACL,uBACA,kBACF,EAAE,GAAK,gBAAgB,CAAI"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/layout.ts"],"sourcesContent":["import getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { AccountType, type Account, type Beat, type DrilldownData } from '../../../core'\nimport type { AccountListCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport { formatSignedCurrency } from '../../../core/utils/NumberFormatting'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\nimport { asNumber } from '../../blocks/slotReaders'\n\nconst balanceOf = (account: Account) => account.balance ?? 0\n\n/** The beat's `account_guids` among visible accounts (or every cash account when it names none), largest first. */\nexport const resolveBeatAccounts = (\n beat: Beat,\n visibleAccounts: Account[],\n cashAccounts: Account[],\n): Account[] => {\n const guids = new Set<string>(\n beat.account_guids?.length ? beat.account_guids : cashAccounts.map(({ guid }) => guid),\n )\n\n return visibleAccounts\n .filter((account) => guids.has(account.guid))\n .sort((a, b) => balanceOf(b) - balanceOf(a))\n}\n\n/** Checking-family types; every other cash account goes under Savings (Figma has just the two). */\nconst CHECKING_TYPES: ReadonlySet<AccountType> = new Set([\n AccountType.CHECKING,\n AccountType.CHECKING_LINE_OF_CREDIT,\n])\n\nexport const isCheckingAccount = (account: Account): boolean =>\n CHECKING_TYPES.has(account.account_type)\n\nexport interface AccountListRow {\n guid: string\n name: string\n /** Empty when no institution is known: the default logo is shown. */\n institutionGuid: string\n balance: number\n}\n\n/** A group of accounts (Checking or Savings) with its own balance subtotal. */\nexport interface AccountSection {\n key: string\n header: string\n total: number\n /** Already ordered, largest balance first. */\n rows: AccountListRow[]\n}\n\n/** One account as a row, its balance by the host's available-vs-current rule (as RemainingCashBlock). */\nexport const toAccountRow = (account: Account, showAvailable: boolean): AccountListRow => ({\n balance: getAccountStartingBalance(account, showAvailable),\n guid: account.guid,\n institutionGuid: account.institution_guid ?? '',\n name: getAccountDisplayName(account),\n})\n\n/** Rows largest displayed balance first, with the section subtotal. */\nexport const toAccountSection = (\n key: string,\n header: string,\n accounts: Account[],\n showAvailable: boolean,\n): AccountSection => {\n const rows = accounts\n .map((account) => toAccountRow(account, showAvailable))\n .sort((a, b) => b.balance - a.balance)\n\n return { header, key, rows, total: rows.reduce((total, row) => total + row.balance, 0) }\n}\n\n/** A generic breakdown row: a label and its already-formatted display value. */\nexport interface SummaryRow {\n key: string\n label: string\n value: string\n /** The emphasised total row. */\n bold?: boolean\n}\n\n/** The \"How is this calculated?\" breakdown, built per insight so AccountListContent stays generic. */\nexport interface AccountListSummary {\n heading: string\n rows: SummaryRow[]\n}\n\ntype SummaryBuilder = (\n drilldown: DrilldownData | undefined,\n copy: AccountListCopy,\n) => AccountListSummary | undefined\n\n/** Monthly Obligations breakdown; undefined unless all three figures are finite, so the drawer falls back to the list. */\nconst buildMonthlyObligationsSummary: SummaryBuilder = (drilldown, copy) => {\n const availableFunds = asNumber(drilldown?.available_funds)\n const plannedExpenses = asNumber(drilldown?.planned_expenses)\n const totalRemaining = asNumber(drilldown?.total_remaining)\n\n if (\n availableFunds === undefined ||\n plannedExpenses === undefined ||\n totalRemaining === undefined\n ) {\n return undefined\n }\n\n return {\n heading: copy.how_is_this_calculated,\n rows: [\n {\n key: 'available_funds',\n label: copy.available_funds,\n value: formatSignedCurrency(availableFunds),\n },\n // Shown as a deduction (-$1,200.00), per Figma; the figure is stored positive.\n {\n key: 'planned_expenses',\n label: copy.planned_expenses,\n value: formatSignedCurrency(-plannedExpenses),\n },\n {\n bold: true,\n key: 'remaining',\n label: copy.remaining,\n value: formatSignedCurrency(totalRemaining),\n },\n ],\n }\n}\n\nconst SUMMARY_BUILDERS = {\n monthly_obligations: buildMonthlyObligationsSummary,\n} satisfies Record<string, SummaryBuilder>\n\n/** The drawer breakdown for the opening CTA's `variant`; unknown variants warn and fall back. */\nexport const buildSummary = (\n cta: { variant?: string | null; drilldown_data?: DrilldownData } | undefined,\n copy: AccountListCopy,\n): AccountListSummary | undefined =>\n resolveVariantConfig(\n SUMMARY_BUILDERS,\n cta?.variant,\n 'monthly_obligations',\n 'AccountListBlock',\n )(cta?.drilldown_data, copy)\n"],"mappings":";;;;;;AAQA,IAAM,IAAA,CAAa,MAAqB,EAAQ,WAAW,GAG9C,IAAA,CACX,GACA,GACA,MACc;AACd,QAAM,IAAQ,IAAI,IAChB,EAAK,eAAe,SAAS,EAAK,gBAAgB,EAAa,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,CACvF;AAEA,SAAO,EACJ,OAAA,CAAQ,MAAY,EAAM,IAAI,EAAQ,IAAI,CAAC,EAC3C,KAAA,CAAM,GAAG,MAAM,EAAU,CAAC,IAAI,EAAU,CAAC,CAAC;AAC/C,GAGM,IAA2C,oBAAI,IAAI,CACvD,EAAY,UACZ,EAAY,uBACd,CAAC,GAEY,IAAA,CAAqB,MAChC,EAAe,IAAI,EAAQ,YAAY,GAoB5B,IAAA,CAAgB,GAAkB,OAA4C;AAAA,EACzF,SAAS,EAA0B,GAAS,CAAa;AAAA,EACzD,MAAM,EAAQ;AAAA,EACd,iBAAiB,EAAQ,oBAAoB;AAAA,EAC7C,MAAM,EAAsB,CAAO;AACrC,IAGa,IAAA,CACX,GACA,GACA,GACA,MACmB;AACnB,QAAM,IAAO,EACV,IAAA,CAAK,MAAY,EAAa,GAAS,CAAa,CAAC,EACrD,KAAA,CAAM,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AAEvC,SAAO;AAAA,IAAE,QAAA;AAAA,IAAQ,KAAA;AAAA,IAAK,MAAA;AAAA,IAAM,OAAO,EAAK,OAAA,CAAQ,GAAO,MAAQ,IAAQ,EAAI,SAAS,CAAC;AAAA,EAAE;AACzF,GAuBM,IAAA,CAAkD,GAAW,MAAS;AAC1E,QAAM,IAAiB,EAAS,GAAW,eAAe,GACpD,IAAkB,EAAS,GAAW,gBAAgB,GACtD,IAAiB,EAAS,GAAW,eAAe;AAE1D,MACE,EAAA,MAAmB,UACnB,MAAoB,UACpB,MAAmB;AAKrB,WAAO;AAAA,MACL,SAAS,EAAK;AAAA,MACd,MAAM;AAAA,QACJ;AAAA,UACE,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAc;AAAA,QAC5C;AAAA,QAEA;AAAA,UACE,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAC,CAAe;AAAA,QAC9C;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAc;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACF,GAEM,IAAmB,EACvB,qBAAqB,EACvB,GAGa,IAAA,CACX,GACA,MAEA,EACE,GACA,GAAK,SACL,uBACA,kBACF,EAAE,GAAK,gBAAgB,CAAI"}
@@ -1 +1,3 @@
1
- export declare const useAccountListPrepare: () => void;
1
+ import { ActionBlockProps } from '../../mappings/blocks';
2
+ /** Loads the accounts, the recurring transactions behind the Recurring Expenses tab, and what a tapped account's Account Details needs. */
3
+ export declare const useAccountListPrepare: (props: ActionBlockProps) => void;
@@ -1,13 +1,15 @@
1
- import { useAccountStore as c } from "../../../common/context/hooks.es.js";
2
- import e from "react";
3
- var u = () => {
4
- const { accountsLoaded: o, loadAccounts: t } = c();
5
- e.useEffect(() => {
6
- o || t();
7
- }, [o, t]);
1
+ import { useAccountStore as t } from "../../../common/context/hooks.es.js";
2
+ import { useRecurringTransactionPrepare as c } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
3
+ import { useAccountDetailsPrepare as a } from "../AccountDetailsBlock/useAccountDetailsPrepare.es.js";
4
+ import s from "react";
5
+ var p = (e) => {
6
+ const { accountsLoaded: r, loadAccounts: o } = t();
7
+ s.useEffect(() => {
8
+ r || o();
9
+ }, [r, o]), c(e), a();
8
10
  };
9
11
  export {
10
- u as useAccountListPrepare
12
+ p as useAccountListPrepare
11
13
  };
12
14
 
13
15
  //# sourceMappingURL=useAccountListPrepare.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAccountListPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.ts"],"sourcesContent":["import React from 'react'\n\nimport { useAccountStore } from '../../../common'\n\nexport const useAccountListPrepare = () => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n React.useEffect(() => {\n if (!accountsLoaded) void loadAccounts()\n }, [accountsLoaded, loadAccounts])\n}\n"],"mappings":";;AAIA,IAAa,IAAA,MAA8B;AACzC,QAAM,EAAE,gBAAA,GAAgB,cAAA,EAAA,IAAiB,EAAgB;AAEzD,EAAA,EAAM,UAAA,MAAgB;AACpB,IAAK,KAAgB,EAAkB;AAAA,EACzC,GAAG,CAAC,GAAgB,CAAY,CAAC;AACnC"}
1
+ {"version":3,"file":"useAccountListPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.ts"],"sourcesContent":["import React from 'react'\n\nimport { useAccountStore } from '../../../common'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { useAccountDetailsPrepare } from '../AccountDetailsBlock'\nimport { useRecurringTransactionPrepare } from '../RecurringTransactionBlock'\n\n/** Loads the accounts, the recurring transactions behind the Recurring Expenses tab, and what a tapped account's Account Details needs. */\nexport const useAccountListPrepare = (props: ActionBlockProps) => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n React.useEffect(() => {\n if (!accountsLoaded) void loadAccounts()\n }, [accountsLoaded, loadAccounts])\n\n useRecurringTransactionPrepare(props)\n // Members and institutions for the nested Account Details (also loads accounts, once).\n useAccountDetailsPrepare()\n}\n"],"mappings":";;;;AAQA,IAAa,IAAA,CAAyB,MAA4B;AAChE,QAAM,EAAE,gBAAA,GAAgB,cAAA,EAAA,IAAiB,EAAgB;AAEzD,EAAA,EAAM,UAAA,MAAgB;AACpB,IAAK,KAAgB,EAAkB;AAAA,EACzC,GAAG,CAAC,GAAgB,CAAY,CAAC,GAEjC,EAA+B,CAAK,GAEpC,EAAyB;AAC3B"}
@@ -1,29 +1,30 @@
1
1
  import { BEAT_ACTIVE_AT_KEY as m } from "../../../core/stores/InsightsV2Store.es.js";
2
- import { resolveVariantConfig as g } from "../../blocks/resolveVariantConfig.es.js";
2
+ import { resolveVariantConfig as c } from "../../blocks/resolveVariantConfig.es.js";
3
+ import { asNonEmptyText as n, asNumber as u } from "../../blocks/slotReaders.es.js";
3
4
  import { endOfMonth as o } from "date-fns/endOfMonth";
4
- import { startOfMonth as c } from "date-fns/startOfMonth";
5
+ import { startOfMonth as s } from "date-fns/startOfMonth";
5
6
  import { differenceInCalendarDays as v } from "date-fns/differenceInCalendarDays";
6
7
  var l = {
7
8
  LOW: "success.light",
8
9
  MEDIUM: "warning.light",
9
10
  HIGH: "warning.main",
10
11
  OFF_TRACK: "error.main"
11
- }, T = "success.main", R = (t, e) => Math.ceil((e ? t / e : 0) * 100), b = (t) => {
12
- if (t > 100) return "OFF_TRACK";
13
- if (t >= 75) return "HIGH";
14
- if (t >= 50) return "MEDIUM";
15
- if (t >= 25) return "LOW";
16
- }, N = (t) => t ? l[t] : T, n = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, d = (t) => typeof t == "string" && t ? t : void 0, E = (t) => {
17
- const e = t.insights_payload, r = e?.instance_slot?.data ?? e?.instance_slot_data ?? {};
12
+ }, T = "success.main", N = (e, t) => Math.ceil((t ? e / t : 0) * 100), L = (e) => {
13
+ if (e > 100) return "OFF_TRACK";
14
+ if (e >= 75) return "HIGH";
15
+ if (e >= 50) return "MEDIUM";
16
+ if (e >= 25) return "LOW";
17
+ }, M = (e) => e ? l[e] : T, E = (e) => {
18
+ const t = e.insights_payload, r = t?.instance_slot?.data ?? t?.instance_slot_data ?? {};
18
19
  return {
19
- categoryGuid: d(r.category_guid) ?? e?.primary_category_guid ?? t.primary_category_guid ?? void 0,
20
- merchantGuid: d(r.merchant_guid) ?? e?.primary_merchant_guid ?? t.primary_merchant_guid ?? void 0,
21
- spent: n(r.spent_amount),
22
- budgeted: n(r.budgeted_amount)
20
+ categoryGuid: n(r.category_guid) ?? t?.primary_category_guid ?? e.primary_category_guid ?? void 0,
21
+ merchantGuid: n(r.merchant_guid) ?? t?.primary_merchant_guid ?? e.primary_merchant_guid ?? void 0,
22
+ spent: u(r.spent_amount),
23
+ budgeted: u(r.budgeted_amount)
23
24
  };
24
- }, i = (t, e) => {
25
- const { categoryGuid: r } = E(t);
26
- return (r ? e.categories?.default_categories?.[r] : void 0)?.replace(/&amp;/g, "&");
25
+ }, i = (e, t) => {
26
+ const { categoryGuid: r } = E(e);
27
+ return (r ? t.categories?.default_categories?.[r] : void 0)?.replace(/&amp;/g, "&");
27
28
  }, a = {
28
29
  CATEGORY_SPEND: "category_spend",
29
30
  CATEGORY_BUDGET: "category_budget",
@@ -32,52 +33,52 @@ var l = {
32
33
  default: i,
33
34
  [a.CATEGORY_SPEND]: i,
34
35
  [a.CATEGORY_BUDGET]: i
35
- }, L = (t, e, r) => g(f, t, "default", "BudgetDetailsBlock")(e, r), u = (t) => {
36
- if (t == null || t === "") return;
37
- const e = new Date(typeof t == "number" ? t * 1e3 : t);
38
- return Number.isNaN(e.getTime()) ? void 0 : e;
39
- }, y = (t) => t.active_at ?? t.insights_payload?.active_at, M = (t, e) => t.beatContext[e.guid]?.[m], s = (t, e, r = /* @__PURE__ */ new Date()) => u(e) ?? u(y(t)) ?? r, U = (t, e = /* @__PURE__ */ new Date(), r) => {
40
- const _ = s(t, r, e);
41
- if (!(o(_) < c(e)))
42
- return v(o(e), e) + 1;
43
- }, I = (t, e) => {
44
- const r = s(t, e);
36
+ }, U = (e, t, r) => c(f, e, "default", "BudgetDetailsBlock")(t, r), d = (e) => {
37
+ if (e == null || e === "") return;
38
+ const t = new Date(typeof e == "number" ? e * 1e3 : e);
39
+ return Number.isNaN(t.getTime()) ? void 0 : t;
40
+ }, A = (e) => e.active_at ?? e.insights_payload?.active_at, b = (e, t) => e.beatContext[t.guid]?.[m], g = (e, t, r = /* @__PURE__ */ new Date()) => d(t) ?? d(A(e)) ?? r, I = (e, t = /* @__PURE__ */ new Date(), r) => {
41
+ const _ = g(e, r, t);
42
+ if (!(o(_) < s(t)))
43
+ return v(o(t), t) + 1;
44
+ }, P = (e, t) => {
45
+ const r = g(e, t);
45
46
  return {
46
- start: c(r),
47
+ start: s(r),
47
48
  end: o(r)
48
49
  };
49
- }, A = (t) => (e) => e.category_guid === t || e.top_level_category_guid === t, h = (t) => (e) => e.merchant_guid === t, F = (t, e) => {
50
- const r = t.categoryGuid ? A(t.categoryGuid) : t.merchantGuid ? h(t.merchantGuid) : void 0;
50
+ }, h = (e) => (t) => t.category_guid === e || t.top_level_category_guid === e, y = (e) => (t) => t.merchant_guid === e, F = (e, t) => {
51
+ const r = e.categoryGuid ? h(e.categoryGuid) : e.merchantGuid ? y(e.merchantGuid) : void 0;
51
52
  return r && {
52
53
  custom: r,
53
- dateRange: e
54
+ dateRange: t
54
55
  };
55
56
  }, D = {
56
57
  default: { showPeriodLine: !0 },
57
58
  [a.CATEGORY_SPEND]: { showPeriodLine: !1 },
58
59
  [a.CATEGORY_BUDGET]: { showPeriodLine: !1 },
59
60
  [a.MERCHANT_BUDGET]: { showPeriodLine: !1 }
60
- }, P = (t) => g(D, t, "default", "BudgetDetailsBlock"), S = (t) => {
61
- const e = Number(t);
62
- return t.trim() !== "" && Number.isFinite(e) && e > 0;
61
+ }, S = (e) => c(D, e, "default", "BudgetDetailsBlock"), Y = (e) => {
62
+ const t = Number(e);
63
+ return e.trim() !== "" && Number.isFinite(t) && t > 0;
63
64
  };
64
65
  export {
65
66
  l as BUDGET_TIER_COLORS,
66
67
  T as DEFAULT_TIER_COLOR,
67
- u as activeAtDate,
68
- y as beatActiveAt,
69
- s as budgetMonthOf,
70
- I as budgetMonthRange,
68
+ d as activeAtDate,
69
+ A as beatActiveAt,
70
+ g as budgetMonthOf,
71
+ P as budgetMonthRange,
71
72
  F as budgetTransactionFilter,
72
- R as calculateBudgetPercent,
73
- b as calculateBudgetTier,
74
- U as daysLeftInBudgetMonth,
75
- S as isPositiveAmount,
76
- M as recordedActiveAtOf,
77
- P as resolveBudgetDetailsLayout,
73
+ N as calculateBudgetPercent,
74
+ L as calculateBudgetTier,
75
+ I as daysLeftInBudgetMonth,
76
+ Y as isPositiveAmount,
77
+ b as recordedActiveAtOf,
78
+ S as resolveBudgetDetailsLayout,
78
79
  E as resolveBudgetFacts,
79
- L as resolveBudgetSubject,
80
- N as tierColor
80
+ U as resolveBudgetSubject,
81
+ M as tierColor
81
82
  };
82
83
 
83
84
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/layout.ts"],"sourcesContent":["import { differenceInCalendarDays } from 'date-fns/differenceInCalendarDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\n\nimport type { Beat, GlobalCopy, Transaction } from '../../../core'\nimport { BEAT_ACTIVE_AT_KEY, type InsightsV2Store } from '../../../core/stores/InsightsV2Store'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\n\nexport type BudgetTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'OFF_TRACK'\n\nexport const BUDGET_TIER_COLORS: Record<BudgetTier, string> = {\n LOW: 'success.light',\n MEDIUM: 'warning.light',\n HIGH: 'warning.main',\n OFF_TRACK: 'error.main',\n}\n\nexport const DEFAULT_TIER_COLOR = 'success.main'\n\nexport const calculateBudgetPercent = (total: number, limit: number) =>\n Math.ceil((limit ? total / limit : 0) * 100)\n\nexport const calculateBudgetTier = (percent: number): BudgetTier | undefined => {\n if (percent > 100) return 'OFF_TRACK'\n if (percent >= 75) return 'HIGH'\n if (percent >= 50) return 'MEDIUM'\n if (percent >= 25) return 'LOW'\n\n return undefined\n}\n\nexport const tierColor = (tier: BudgetTier | undefined) =>\n tier ? BUDGET_TIER_COLORS[tier] : DEFAULT_TIER_COLOR\n\nexport interface BudgetFacts {\n categoryGuid?: string\n merchantGuid?: string\n spent?: number\n budgeted?: number\n}\n\nconst finiteNumber = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nconst nonEmptyString = (value: unknown) => (typeof value === 'string' && value ? value : undefined)\n\nexport const resolveBudgetFacts = (beat: Beat): BudgetFacts => {\n const payload = beat.insights_payload\n const data = (payload?.instance_slot?.data ?? payload?.instance_slot_data ?? {}) as Record<\n string,\n unknown\n >\n\n return {\n categoryGuid:\n nonEmptyString(data.category_guid) ??\n payload?.primary_category_guid ??\n beat.primary_category_guid ??\n undefined,\n merchantGuid:\n nonEmptyString(data.merchant_guid) ??\n payload?.primary_merchant_guid ??\n beat.primary_merchant_guid ??\n undefined,\n spent: finiteNumber(data.spent_amount),\n budgeted: finiteNumber(data.budgeted_amount),\n }\n}\n\ntype BudgetSubject = (beat: Beat, copy: GlobalCopy) => string | undefined\n\nconst categoryName: BudgetSubject = (beat, copy) => {\n const { categoryGuid } = resolveBudgetFacts(beat)\n const name = categoryGuid ? copy.categories?.default_categories?.[categoryGuid] : undefined\n\n return name?.replace(/&amp;/g, '&')\n}\n\n/** The CTA variants `budget_details_block` serves (ditto names one on each beat's CTA). */\nconst BUDGET_DETAILS_VARIANTS = {\n CATEGORY_SPEND: 'category_spend',\n CATEGORY_BUDGET: 'category_budget',\n MERCHANT_BUDGET: 'merchant_budget',\n} as const\n\n// The drawer's \"{subject} Budget\" title, keyed by the CTA variant; the card's subtitle never names it.\nconst BUDGET_SUBJECT: Record<string, BudgetSubject> = {\n default: categoryName,\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: categoryName,\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: categoryName,\n // merchant_budget: the merchant name, when Merchant Budget moves to Insights 2.0.\n}\n\nexport const resolveBudgetSubject = (\n variant: string | null | undefined,\n beat: Beat,\n copy: GlobalCopy,\n): string | undefined =>\n resolveVariantConfig(BUDGET_SUBJECT, variant, 'default', 'BudgetDetailsBlock')(beat, copy)\n\ntype ActiveAt = Beat['active_at'] | number | null | undefined\n\n/** A beat's `active_at` (epoch seconds or ISO) as a date; undefined when absent or invalid. */\nexport const activeAtDate = (raw: ActiveAt): Date | undefined => {\n if (raw == null || raw === '') return undefined\n const at = new Date(typeof raw === 'number' ? raw * 1000 : raw)\n\n return Number.isNaN(at.getTime()) ? undefined : at\n}\n\n/** The beat's own `active_at`: on the beat, else on its envelope. */\nexport const beatActiveAt = (beat: Beat): ActiveAt =>\n beat.active_at ?? beat.insights_payload?.active_at\n\n/** The `active_at` the card recorded on render; a sampled beat is re-read without it after a CTA. */\nexport const recordedActiveAtOf = (\n store: Pick<InsightsV2Store, 'beatContext'>,\n beat: Beat,\n): ActiveAt => store.beatContext[beat.guid]?.[BEAT_ACTIVE_AT_KEY] as ActiveAt\n\n/** The budget month's anchor: the recorded `active_at`, else the beat's, else now. */\nexport const budgetMonthOf = (beat: Beat, recordedActiveAt?: ActiveAt, now = new Date()) =>\n activeAtDate(recordedActiveAt) ?? activeAtDate(beatActiveAt(beat)) ?? now\n\nexport const daysLeftInBudgetMonth = (\n beat: Beat,\n now = new Date(),\n recordedActiveAt?: ActiveAt,\n) => {\n const activeAt = budgetMonthOf(beat, recordedActiveAt, now)\n if (endOfMonth(activeAt) < startOfMonth(now)) return undefined\n\n return differenceInCalendarDays(endOfMonth(now), now) + 1\n}\n\n/** The month a budget drawer shows (see budgetMonthOf). */\nexport const budgetMonthRange = (beat: Beat, recordedActiveAt?: ActiveAt) => {\n const month = budgetMonthOf(beat, recordedActiveAt)\n\n return { start: startOfMonth(month), end: endOfMonth(month) }\n}\n\nconst inCategory = (categoryGuid: string) => (transaction: Transaction) =>\n transaction.category_guid === categoryGuid || transaction.top_level_category_guid === categoryGuid\n\nconst atMerchant = (merchantGuid: string) => (transaction: Transaction) =>\n transaction.merchant_guid === merchantGuid\n\n/** The budget month and category (own or top-level) or merchant; none without either, so no rows. */\nexport const budgetTransactionFilter = (\n facts: BudgetFacts,\n dateRange: { start: Date; end: Date },\n): TransactionFilter | undefined => {\n const custom = facts.categoryGuid\n ? inCategory(facts.categoryGuid)\n : facts.merchantGuid\n ? atMerchant(facts.merchantGuid)\n : undefined\n\n return custom && { custom, dateRange }\n}\n\nexport interface BudgetDetailsLayout {\n /** The \"N days until the end of the month\" / previous-month notice under the summary. */\n showPeriodLine: boolean\n}\n\n// Figma's Budget Details for these three insights has no period line; any other caller keeps it.\nconst LAYOUT: Record<string, BudgetDetailsLayout> = {\n default: { showPeriodLine: true },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: { showPeriodLine: false },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: { showPeriodLine: false },\n [BUDGET_DETAILS_VARIANTS.MERCHANT_BUDGET]: { showPeriodLine: false },\n}\n\nexport const resolveBudgetDetailsLayout = (variant: string | null | undefined) =>\n resolveVariantConfig(LAYOUT, variant, 'default', 'BudgetDetailsBlock')\n\n/** A budget amount the dialogs accept: a finite number above zero. */\nexport const isPositiveAmount = (value: string): boolean => {\n const amount = Number(value)\n return value.trim() !== '' && Number.isFinite(amount) && amount > 0\n}\n"],"mappings":";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,EAAE,gBAAgB,GAAK;AAAA,EAC/B,CAAA,EAAwB,cAAA,GAAiB,EAAE,gBAAgB,GAAM;AAAA,EACjE,CAAA,EAAwB,eAAA,GAAkB,EAAE,gBAAgB,GAAM;AAAA,EAClE,CAAA,EAAwB,eAAA,GAAkB,EAAE,gBAAgB,GAAM;AACrE,GAEa,IAAA,CAA8B,MACzC,EAAqB,GAAQ,GAAS,WAAW,oBAAoB,GAG1D,IAAA,CAAoB,MAA2B;AAC1D,QAAM,IAAS,OAAO,CAAK;AAC3B,SAAO,EAAM,KAAK,MAAM,MAAM,OAAO,SAAS,CAAM,KAAK,IAAS;AACpE"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/layout.ts"],"sourcesContent":["import { differenceInCalendarDays } from 'date-fns/differenceInCalendarDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\n\nimport type { Beat, GlobalCopy, Transaction } from '../../../core'\nimport { BEAT_ACTIVE_AT_KEY, type InsightsV2Store } from '../../../core/stores/InsightsV2Store'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\n\nexport type BudgetTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'OFF_TRACK'\n\nexport const BUDGET_TIER_COLORS: Record<BudgetTier, string> = {\n LOW: 'success.light',\n MEDIUM: 'warning.light',\n HIGH: 'warning.main',\n OFF_TRACK: 'error.main',\n}\n\nexport const DEFAULT_TIER_COLOR = 'success.main'\n\nexport const calculateBudgetPercent = (total: number, limit: number) =>\n Math.ceil((limit ? total / limit : 0) * 100)\n\nexport const calculateBudgetTier = (percent: number): BudgetTier | undefined => {\n if (percent > 100) return 'OFF_TRACK'\n if (percent >= 75) return 'HIGH'\n if (percent >= 50) return 'MEDIUM'\n if (percent >= 25) return 'LOW'\n\n return undefined\n}\n\nexport const tierColor = (tier: BudgetTier | undefined) =>\n tier ? BUDGET_TIER_COLORS[tier] : DEFAULT_TIER_COLOR\n\nexport interface BudgetFacts {\n categoryGuid?: string\n merchantGuid?: string\n spent?: number\n budgeted?: number\n}\n\nexport const resolveBudgetFacts = (beat: Beat): BudgetFacts => {\n const payload = beat.insights_payload\n const data = (payload?.instance_slot?.data ?? payload?.instance_slot_data ?? {}) as Record<\n string,\n unknown\n >\n\n return {\n categoryGuid:\n asNonEmptyText(data.category_guid) ??\n payload?.primary_category_guid ??\n beat.primary_category_guid ??\n undefined,\n merchantGuid:\n asNonEmptyText(data.merchant_guid) ??\n payload?.primary_merchant_guid ??\n beat.primary_merchant_guid ??\n undefined,\n spent: asNumber(data.spent_amount),\n budgeted: asNumber(data.budgeted_amount),\n }\n}\n\ntype BudgetSubject = (beat: Beat, copy: GlobalCopy) => string | undefined\n\nconst categoryName: BudgetSubject = (beat, copy) => {\n const { categoryGuid } = resolveBudgetFacts(beat)\n const name = categoryGuid ? copy.categories?.default_categories?.[categoryGuid] : undefined\n\n return name?.replace(/&amp;/g, '&')\n}\n\n/** The CTA variants `budget_details_block` serves (ditto names one on each beat's CTA). */\nconst BUDGET_DETAILS_VARIANTS = {\n CATEGORY_SPEND: 'category_spend',\n CATEGORY_BUDGET: 'category_budget',\n MERCHANT_BUDGET: 'merchant_budget',\n} as const\n\n// The drawer's \"{subject} Budget\" title, keyed by the CTA variant; the card's subtitle never names it.\nconst BUDGET_SUBJECT: Record<string, BudgetSubject> = {\n default: categoryName,\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: categoryName,\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: categoryName,\n // merchant_budget: the merchant name, when Merchant Budget moves to Insights 2.0.\n}\n\nexport const resolveBudgetSubject = (\n variant: string | null | undefined,\n beat: Beat,\n copy: GlobalCopy,\n): string | undefined =>\n resolveVariantConfig(BUDGET_SUBJECT, variant, 'default', 'BudgetDetailsBlock')(beat, copy)\n\ntype ActiveAt = Beat['active_at'] | number | null | undefined\n\n/** A beat's `active_at` (epoch seconds or ISO) as a date; undefined when absent or invalid. */\nexport const activeAtDate = (raw: ActiveAt): Date | undefined => {\n if (raw == null || raw === '') return undefined\n const at = new Date(typeof raw === 'number' ? raw * 1000 : raw)\n\n return Number.isNaN(at.getTime()) ? undefined : at\n}\n\n/** The beat's own `active_at`: on the beat, else on its envelope. */\nexport const beatActiveAt = (beat: Beat): ActiveAt =>\n beat.active_at ?? beat.insights_payload?.active_at\n\n/** The `active_at` the card recorded on render; a sampled beat is re-read without it after a CTA. */\nexport const recordedActiveAtOf = (\n store: Pick<InsightsV2Store, 'beatContext'>,\n beat: Beat,\n): ActiveAt => store.beatContext[beat.guid]?.[BEAT_ACTIVE_AT_KEY] as ActiveAt\n\n/** The budget month's anchor: the recorded `active_at`, else the beat's, else now. */\nexport const budgetMonthOf = (beat: Beat, recordedActiveAt?: ActiveAt, now = new Date()) =>\n activeAtDate(recordedActiveAt) ?? activeAtDate(beatActiveAt(beat)) ?? now\n\nexport const daysLeftInBudgetMonth = (\n beat: Beat,\n now = new Date(),\n recordedActiveAt?: ActiveAt,\n) => {\n const activeAt = budgetMonthOf(beat, recordedActiveAt, now)\n if (endOfMonth(activeAt) < startOfMonth(now)) return undefined\n\n return differenceInCalendarDays(endOfMonth(now), now) + 1\n}\n\n/** The month a budget drawer shows (see budgetMonthOf). */\nexport const budgetMonthRange = (beat: Beat, recordedActiveAt?: ActiveAt) => {\n const month = budgetMonthOf(beat, recordedActiveAt)\n\n return { start: startOfMonth(month), end: endOfMonth(month) }\n}\n\nconst inCategory = (categoryGuid: string) => (transaction: Transaction) =>\n transaction.category_guid === categoryGuid || transaction.top_level_category_guid === categoryGuid\n\nconst atMerchant = (merchantGuid: string) => (transaction: Transaction) =>\n transaction.merchant_guid === merchantGuid\n\n/** The budget month and category (own or top-level) or merchant; none without either, so no rows. */\nexport const budgetTransactionFilter = (\n facts: BudgetFacts,\n dateRange: { start: Date; end: Date },\n): TransactionFilter | undefined => {\n const custom = facts.categoryGuid\n ? inCategory(facts.categoryGuid)\n : facts.merchantGuid\n ? atMerchant(facts.merchantGuid)\n : undefined\n\n return custom && { custom, dateRange }\n}\n\nexport interface BudgetDetailsLayout {\n /** The \"N days until the end of the month\" / previous-month notice under the summary. */\n showPeriodLine: boolean\n}\n\n// Figma's Budget Details for these three insights has no period line; any other caller keeps it.\nconst LAYOUT: Record<string, BudgetDetailsLayout> = {\n default: { showPeriodLine: true },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: { showPeriodLine: false },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: { showPeriodLine: false },\n [BUDGET_DETAILS_VARIANTS.MERCHANT_BUDGET]: { showPeriodLine: false },\n}\n\nexport const resolveBudgetDetailsLayout = (variant: string | null | undefined) =>\n resolveVariantConfig(LAYOUT, variant, 'default', 'BudgetDetailsBlock')\n\n/** A budget amount the dialogs accept: a finite number above zero. */\nexport const isPositiveAmount = (value: string): boolean => {\n const amount = Number(value)\n return value.trim() !== '' && Number.isFinite(amount) && amount > 0\n}\n"],"mappings":";;;;;;AAYA,IAAa,IAAiD;AAAA,EAC5D,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AACb,GAEa,IAAqB,gBAErB,IAAA,CAA0B,GAAe,MACpD,KAAK,MAAM,IAAQ,IAAQ,IAAQ,KAAK,GAAG,GAEhC,IAAA,CAAuB,MAA4C;AAC9E,MAAI,IAAU,IAAK,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAG5B,GAEa,IAAA,CAAa,MACxB,IAAO,EAAmB,CAAA,IAAQ,GASvB,IAAA,CAAsB,MAA4B;AAC7D,QAAM,IAAU,EAAK,kBACf,IAAQ,GAAS,eAAe,QAAQ,GAAS,sBAAsB,CAAC;AAK9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a,CAAG;AAE3C,WAAO,EAAyB,EAAW,CAAG,GAAG,CAAG,IAAI;AAC1D,GAGa,IAAA,CAAoB,GAAY,MAAgC;AAC3E,QAAM,IAAQ,EAAc,GAAM,CAAgB;AAElD,SAAO;AAAA,IAAE,OAAO,EAAa,CAAK;AAAA,IAAG,KAAK,EAAW,CAAK;AAAA,EAAE;AAC9D,GAEM,IAAA,CAAc,MAAA,CAA0B,MAC5C,EAAY,kBAAkB,KAAgB,EAAY,4BAA4B,GAElF,IAAA,CAAc,MAAA,CAA0B,MAC5C,EAAY,kBAAkB,GAGnB,IAAA,CACX,GACA,MACkC;AAClC,QAAM,IAAS,EAAM,eACjB,EAAW,EAAM,YAAY,IAC7B,EAAM,eACJ,EAAW,EAAM,YAAY,IAC7B;AAEN,SAAO,KAAU;AAAA,IAAE,QAAA;AAAA,IAAQ,WAAA;AAAA,EAAU;AACvC,GAQM,IAA8C;AAAA,EAClD,SAAS,EAAE,gBAAgB,GAAK;AAAA,EAC/B,CAAA,EAAwB,cAAA,GAAiB,EAAE,gBAAgB,GAAM;AAAA,EACjE,CAAA,EAAwB,eAAA,GAAkB,EAAE,gBAAgB,GAAM;AAAA,EAClE,CAAA,EAAwB,eAAA,GAAkB,EAAE,gBAAgB,GAAM;AACrE,GAEa,IAAA,CAA8B,MACzC,EAAqB,GAAQ,GAAS,WAAW,oBAAoB,GAG1D,IAAA,CAAoB,MAA2B;AAC1D,QAAM,IAAS,OAAO,CAAK;AAC3B,SAAO,EAAM,KAAK,MAAM,MAAM,OAAO,SAAS,CAAM,KAAK,IAAS;AACpE"}
@@ -1,3 +1,4 @@
1
+ import { asNumber as r } from "../../blocks/slotReaders.es.js";
1
2
  var l = {
2
3
  band: "needs_work",
3
4
  range: ">30%",
@@ -23,44 +24,44 @@ var l = {
23
24
  color: (t) => t.palette.warning.light
24
25
  },
25
26
  l
26
- ], c = (t) => Math.min(100, Math.max(0, Math.round(t))), s = (t) => g.find(({ maxPercent: a }) => c(t) <= a) ?? l, r = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, p = (t) => {
27
- const a = r(t?.accounts_balance_sum), n = r(t?.accounts_credit_limit_sum), e = r(t?.credit_utilization_percentage);
28
- if (!(a === void 0 || n === void 0 || e === void 0))
27
+ ], c = (t) => Math.min(100, Math.max(0, Math.round(t))), p = (t) => g.find(({ maxPercent: e }) => c(t) <= e) ?? l, b = (t) => {
28
+ const e = r(t?.accounts_balance_sum), n = r(t?.accounts_credit_limit_sum), a = r(t?.credit_utilization_percentage);
29
+ if (!(e === void 0 || n === void 0 || a === void 0))
29
30
  return {
30
- balance: a,
31
+ balance: e,
31
32
  limit: n,
32
- percentage: c(e)
33
+ percentage: c(a)
33
34
  };
34
- }, b = (t) => {
35
+ }, f = (t) => {
35
36
  if (!t || Array.isArray(t) || !t.names || !Array.isArray(t.data)) return [];
36
- const { names: a } = t;
37
+ const { names: e } = t;
37
38
  return t.data.flatMap((n) => {
38
- const e = Object.fromEntries(a.map((m, d) => [m, n[d]]));
39
- if (typeof e.guid != "string" || typeof e.label != "string") return [];
40
- const o = r(e.amount) ?? 0, i = r(e.total_amount);
41
- if (i === void 0 || i <= 0) return [{
42
- amount: o,
43
- guid: e.guid,
44
- label: e.label,
39
+ const a = Object.fromEntries(e.map((m, d) => [m, n[d]]));
40
+ if (typeof a.guid != "string" || typeof a.label != "string") return [];
41
+ const i = r(a.amount) ?? 0, o = r(a.total_amount);
42
+ if (o === void 0 || o <= 0) return [{
43
+ amount: i,
44
+ guid: a.guid,
45
+ label: a.label,
45
46
  limit: null,
46
47
  percentage: null
47
48
  }];
48
- const u = r(e.percentage) ?? o / i * 100;
49
+ const u = r(a.percentage) ?? i / o * 100;
49
50
  return [{
50
- amount: o,
51
- guid: e.guid,
52
- label: e.label,
53
- limit: i,
51
+ amount: i,
52
+ guid: a.guid,
53
+ label: a.label,
54
+ limit: o,
54
55
  percentage: c(u)
55
56
  }];
56
57
  });
57
58
  };
58
59
  export {
59
60
  g as UTILIZATION_BANDS,
60
- s as getUtilizationBand,
61
+ p as getUtilizationBand,
61
62
  c as normalizePercent,
62
- b as readCardRows,
63
- p as readSummary
63
+ f as readCardRows,
64
+ b as readSummary
64
65
  };
65
66
 
66
67
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport type { DataSeries } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\n\nexport type UtilizationBand = 'excellent' | 'good' | 'fair' | 'needs_work'\n\nexport interface UtilizationBandSpec {\n band: UtilizationBand\n range: string\n /** Highest whole percentage in the band. */\n maxPercent: number\n color: (theme: Theme) => string\n}\n\nconst NEEDS_WORK: UtilizationBandSpec = {\n band: 'needs_work',\n range: '>30%',\n maxPercent: Infinity,\n color: (theme) => theme.palette.error.light,\n}\n\n/** Ordered from best to worst, as the legend shows them. */\nexport const UTILIZATION_BANDS: UtilizationBandSpec[] = [\n {\n band: 'excellent',\n range: '0-10%',\n maxPercent: 10,\n color: (theme) => theme.palette.success.main,\n },\n { band: 'good', range: '11-20%', maxPercent: 20, color: (theme) => theme.palette.success.light },\n { band: 'fair', range: '21-30%', maxPercent: 30, color: (theme) => theme.palette.warning.light },\n NEEDS_WORK,\n]\n\n/** Whole percent within 0-100, the only form the drawer shows, bands or announces. */\nexport const normalizePercent = (percent: number): number =>\n Math.min(100, Math.max(0, Math.round(percent)))\n\nexport const getUtilizationBand = (percent: number): UtilizationBandSpec =>\n UTILIZATION_BANDS.find(({ maxPercent }) => normalizePercent(percent) <= maxPercent) ?? NEEDS_WORK\n\nexport interface CreditUtilizationSummary {\n balance: number\n limit: number\n percentage: number\n}\n\nexport interface CreditCardRow {\n guid: string\n label: string\n amount: number\n /** `null` when the institution did not share the card's limit. */\n limit: number | null\n percentage: number | null\n}\n\nconst toFiniteNumber = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nexport const readSummary = (\n data?: InsightsInstanceSlotData,\n): CreditUtilizationSummary | undefined => {\n const balance = toFiniteNumber(data?.accounts_balance_sum)\n const limit = toFiniteNumber(data?.accounts_credit_limit_sum)\n const percentage = toFiniteNumber(data?.credit_utilization_percentage)\n\n if (balance === undefined || limit === undefined || percentage === undefined) return undefined\n\n return { balance, limit, percentage: normalizePercent(percentage) }\n}\n\n/** One object per `data` row, keyed by `names` (pulse's `buildDataSeries`). */\nexport const readCardRows = (series?: DataSeries | unknown[]): CreditCardRow[] => {\n if (!series || Array.isArray(series) || !series.names || !Array.isArray(series.data)) return []\n\n const { names } = series\n\n return series.data.flatMap((values: unknown[]): CreditCardRow[] => {\n const row = Object.fromEntries(names.map((name, index) => [name, values[index]]))\n\n if (typeof row.guid !== 'string' || typeof row.label !== 'string') return []\n\n const amount = toFiniteNumber(row.amount) ?? 0\n const limit = toFiniteNumber(row.total_amount)\n\n if (limit === undefined || limit <= 0) {\n return [{ amount, guid: row.guid, label: row.label, limit: null, percentage: null }]\n }\n\n const percentage = toFiniteNumber(row.percentage) ?? (amount / limit) * 100\n\n return [\n { amount, guid: row.guid, label: row.label, limit, percentage: normalizePercent(percentage) },\n ]\n })\n}\n"],"mappings":"AAeA,IAAM,IAAkC;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,MAAM;AACxC,GAGa,IAA2C;AAAA,EACtD;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAC1C;AAAA,EACA;AAAA,IAAE,MAAM;AAAA,IAAQ,OAAO;AAAA,IAAU,YAAY;AAAA,IAAI,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAAM;AAAA,EAC/F;AAAA,IAA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AM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAO;AAAA,MAAM,YAAY;AAAA,IAAK,CAAC;AAGrF,UAAM,IAAa,EAAe,EAAI,UAAU,KAAM,IAAS,IAAS;AAExE,WAAO,CACL;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAA;AAAA,MAAO,YAAY,EAAiB,CAAU;AAAA,IAAE,CAC9F;AAAA,EACF,CAAC;AACH"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport type { DataSeries } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\nimport { asNumber } from '../../blocks/slotReaders'\n\nexport type UtilizationBand = 'excellent' | 'good' | 'fair' | 'needs_work'\n\nexport interface UtilizationBandSpec {\n band: UtilizationBand\n range: string\n /** Highest whole percentage in the band. */\n maxPercent: number\n color: (theme: Theme) => string\n}\n\nconst NEEDS_WORK: UtilizationBandSpec = {\n band: 'needs_work',\n range: '>30%',\n maxPercent: Infinity,\n color: (theme) => theme.palette.error.light,\n}\n\n/** Ordered from best to worst, as the legend shows them. */\nexport const UTILIZATION_BANDS: UtilizationBandSpec[] = [\n {\n band: 'excellent',\n range: '0-10%',\n maxPercent: 10,\n color: (theme) => theme.palette.success.main,\n },\n { band: 'good', range: '11-20%', maxPercent: 20, color: (theme) => theme.palette.success.light },\n { band: 'fair', range: '21-30%', maxPercent: 30, color: (theme) => theme.palette.warning.light },\n NEEDS_WORK,\n]\n\n/** Whole percent within 0-100, the only form the drawer shows, bands or announces. */\nexport const normalizePercent = (percent: number): number =>\n Math.min(100, Math.max(0, Math.round(percent)))\n\nexport const getUtilizationBand = (percent: number): UtilizationBandSpec =>\n UTILIZATION_BANDS.find(({ maxPercent }) => normalizePercent(percent) <= maxPercent) ?? NEEDS_WORK\n\nexport interface CreditUtilizationSummary {\n balance: number\n limit: number\n percentage: number\n}\n\nexport interface CreditCardRow {\n guid: string\n label: string\n amount: number\n /** `null` when the institution did not share the card's limit. */\n limit: number | null\n percentage: number | null\n}\n\nexport const readSummary = (\n data?: InsightsInstanceSlotData,\n): CreditUtilizationSummary | undefined => {\n const balance = asNumber(data?.accounts_balance_sum)\n const limit = asNumber(data?.accounts_credit_limit_sum)\n const percentage = asNumber(data?.credit_utilization_percentage)\n\n if (balance === undefined || limit === undefined || percentage === undefined) return undefined\n\n return { balance, limit, percentage: normalizePercent(percentage) }\n}\n\n/** One object per `data` row, keyed by `names` (pulse's `buildDataSeries`). */\nexport const readCardRows = (series?: DataSeries | unknown[]): CreditCardRow[] => {\n if (!series || Array.isArray(series) || !series.names || !Array.isArray(series.data)) return []\n\n const { names } = series\n\n return series.data.flatMap((values: unknown[]): CreditCardRow[] => {\n const row = Object.fromEntries(names.map((name, index) => [name, values[index]]))\n\n if (typeof row.guid !== 'string' || typeof row.label !== 'string') return []\n\n const amount = asNumber(row.amount) ?? 0\n const limit = asNumber(row.total_amount)\n\n if (limit === undefined || limit <= 0) {\n return [{ amount, guid: row.guid, label: row.label, limit: null, percentage: null }]\n }\n\n const percentage = asNumber(row.percentage) ?? (amount / limit) * 100\n\n return [\n { amount, guid: row.guid, label: row.label, limit, percentage: normalizePercent(percentage) },\n ]\n })\n}\n"],"mappings":";AAgBA,IAAM,IAAkC;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,MAAM;AACxC,GAGa,IAA2C;AAAA,EACtD;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAC1C;AAAA,EACA;AAAA,IAAE,MAAM;AAAA,IAAQ,OAAO;AAAA,IAAU,YAAY;AAAA,IAA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,MAAM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAO;AAAA,MAAM,YAAY;AAAA,IAAK,CAAC;AAGrF,UAAM,IAAa,EAAS,EAAI,UAAU,KAAM,IAAS,IAAS;AAElE,WAAO,CACL;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAA;AAAA,MAAO,YAAY,EAAiB,CAAU;AAAA,IAAE,CAC9F;AAAA,EACF,CAAC;AACH"}
@@ -1,14 +1,15 @@
1
- import { buildDynamicCopy as x } from "../../../core/utils/Localization.es.js";
2
- import { useGlobalCopyStore as v } from "../../../common/context/hooks.es.js";
3
- import { formatCurrency as c } from "../../../core/utils/NumberFormatting.es.js";
1
+ import { buildDynamicCopy as f } from "../../../core/utils/Localization.es.js";
2
+ import { useGlobalCopyStore as x } from "../../../common/context/hooks.es.js";
3
+ import { formatCurrency as s } from "../../../core/utils/NumberFormatting.es.js";
4
+ import { asNumber as v } from "../../blocks/slotReaders.es.js";
4
5
  import { variants as _ } from "../../blocks/ChartBlocks/StepChartBlock/index.es.js";
5
- import { stepForBalance as y } from "./layout.es.js";
6
- import { SavingsCalculator as h } from "./SavingsCalculator.es.js";
6
+ import { stepForBalance as h } from "./layout.es.js";
7
+ import { SavingsCalculator as y } from "./SavingsCalculator.es.js";
7
8
  import { observer as C } from "mobx-react-lite";
8
9
  import e from "@mui/material/Stack";
9
- import { Text as p } from "@mxenabled/mxui";
10
+ import { Text as c } from "@mxenabled/mxui";
10
11
  import { jsx as o, jsxs as n } from "react/jsx-runtime";
11
- var m = ({ label: i, value: a }) => /* @__PURE__ */ n(e, {
12
+ var p = ({ label: i, value: a }) => /* @__PURE__ */ n(e, {
12
13
  "aria-label": i,
13
14
  role: "group",
14
15
  sx: {
@@ -19,23 +20,23 @@ var m = ({ label: i, value: a }) => /* @__PURE__ */ n(e, {
19
20
  gap: 4,
20
21
  p: 12
21
22
  },
22
- children: [/* @__PURE__ */ o(p, {
23
+ children: [/* @__PURE__ */ o(c, {
23
24
  color: "text.secondary",
24
25
  variant: "caption",
25
26
  children: i
26
- }), /* @__PURE__ */ o(p, {
27
+ }), /* @__PURE__ */ o(c, {
27
28
  bold: !0,
28
29
  component: "p",
29
30
  variant: "h3",
30
31
  children: a
31
32
  })]
32
- }), A = C(function({ beat: a }) {
33
- const { common: d, insights_feed: g } = v(), r = g?.emergency_savings;
33
+ }), G = C(function({ beat: a }) {
34
+ const { common: m, insights_feed: d } = x(), r = d?.emergency_savings;
34
35
  if (!r) return /* @__PURE__ */ o(e, {
35
36
  sx: { p: 24 },
36
- children: /* @__PURE__ */ o(p, { children: d?.error_message })
37
+ children: /* @__PURE__ */ o(c, { children: m?.error_message })
37
38
  });
38
- const t = a.insights_payload?.drilldown_data?.savings_account_balance, l = typeof t == "number" && Number.isFinite(t) ? t : 0, { goal: s, index: u, labelKey: b } = y(l), { WithText: f } = _;
39
+ const t = v(a.insights_payload?.drilldown_data?.savings_account_balance) ?? 0, { goal: l, index: g, labelKey: u } = h(t), { WithText: b } = _;
39
40
  return /* @__PURE__ */ n(e, {
40
41
  sx: {
41
42
  bgcolor: "background.default",
@@ -49,32 +50,32 @@ var m = ({ label: i, value: a }) => /* @__PURE__ */ n(e, {
49
50
  gap: 16,
50
51
  p: 16
51
52
  },
52
- children: [/* @__PURE__ */ o(f, { slotData: {
53
- completed_steps: u,
54
- label_1: r[b].toUpperCase(),
55
- label_2: x(r.amount_in_savings, c(s, "0"))
53
+ children: [/* @__PURE__ */ o(b, { slotData: {
54
+ completed_steps: g,
55
+ label_1: r[u].toUpperCase(),
56
+ label_2: f(r.amount_in_savings, s(l, "0"))
56
57
  } }), /* @__PURE__ */ n(e, {
57
58
  sx: {
58
59
  flexDirection: "row",
59
60
  gap: 12
60
61
  },
61
- children: [/* @__PURE__ */ o(m, {
62
+ children: [/* @__PURE__ */ o(p, {
62
63
  label: r.total_savings_balance,
63
- value: c(l, "0,0.00")
64
- }), /* @__PURE__ */ o(m, {
64
+ value: s(t, "0,0.00")
65
+ }), /* @__PURE__ */ o(p, {
65
66
  label: r.savings_goal,
66
- value: c(s, "0,0")
67
+ value: s(l, "0,0")
67
68
  })]
68
69
  })]
69
- }), /* @__PURE__ */ o(h, {
70
- balance: l,
70
+ }), /* @__PURE__ */ o(y, {
71
+ balance: t,
71
72
  copy: r,
72
- goal: s
73
+ goal: l
73
74
  }, a.guid)]
74
75
  });
75
76
  });
76
77
  export {
77
- A as EmergencySavingsBlock
78
+ G as EmergencySavingsBlock
78
79
  };
79
80
 
80
81
  //# sourceMappingURL=EmergencySavingsBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmergencySavingsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { variants as stepChartVariants } from '../../blocks/ChartBlocks/StepChartBlock'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { SavingsCalculator } from './SavingsCalculator'\nimport { stepForBalance } from './layout'\n\nconst AmountBox = ({ label, value }: { label: string; value: string }) => (\n <Stack\n aria-label={label}\n role=\"group\"\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n flex: 1,\n gap: 4,\n p: 12,\n }}\n >\n <Text color=\"text.secondary\" variant=\"caption\">\n {label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h3\">\n {value}\n </Text>\n </Stack>\n)\n\nexport const EmergencySavingsBlock = observer(function EmergencySavingsBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const copy = insightsFeedCopy?.emergency_savings\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n const raw = beat.insights_payload?.drilldown_data?.savings_account_balance\n const balance = typeof raw === 'number' && Number.isFinite(raw) ? raw : 0\n const { goal, index, labelKey } = stepForBalance(balance)\n const { WithText: Stepper } = stepChartVariants\n\n return (\n <Stack sx={{ bgcolor: 'background.default', gap: 24, p: 24 }}>\n <Stack sx={{ bgcolor: 'background.paper', borderRadius: '8px', gap: 16, p: 16 }}>\n <Stepper\n slotData={{\n completed_steps: index,\n label_1: copy[labelKey].toUpperCase(),\n label_2: buildDynamicCopy(copy.amount_in_savings, formatCurrency(goal, '0')) as string,\n }}\n />\n <Stack sx={{ flexDirection: 'row', gap: 12 }}>\n <AmountBox label={copy.total_savings_balance} value={formatCurrency(balance, '0,0.00')} />\n <AmountBox label={copy.savings_goal} value={formatCurrency(goal, '0,0')} />\n </Stack>\n </Stack>\n <SavingsCalculator balance={balance} copy={copy} goal={goal} key={beat.guid} />\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;AAcA,IAAM,IAAA,CAAa,EAAE,OAAA,GAAO,OAAA,EAAA,MAC1B,gBAAA,EAAC,GAAD;AAAA,EACE,cAAY;AAAA,EACZ,MAAK;AAAA,EACL,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,MAAM;AAAA,IACN,KAAK;AAAA,IACL,GAAG;AAAA,EACL;AAAA,EAVF,UAAA,CAYE,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAiB,SAAQ;AAAA,IAClC,UAAA;AAAA,EACG,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,IAAM,MAAM;AAAA,IAAM,WAAU;AAAA,IAAI,SAAQ;AAAA,IACrC,UAAA;AAAA,EACG,CAAA,CACD;IAGI,IAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,QAAQ,GAAY,eAAe,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IACP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,MAA4B,SAAA;AAAA,MAAe,MAAA;AAAA,MAAY,MAAA;AAAA,IAAuB,GAAZ,EAAK,IAAO,CACzE;AAAA;AAEX,CAAC"}
1
+ {"version":3,"file":"EmergencySavingsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { variants as stepChartVariants } from '../../blocks/ChartBlocks/StepChartBlock'\nimport { asNumber } from '../../blocks/slotReaders'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { SavingsCalculator } from './SavingsCalculator'\nimport { stepForBalance } from './layout'\n\nconst AmountBox = ({ label, value }: { label: string; value: string }) => (\n <Stack\n aria-label={label}\n role=\"group\"\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n flex: 1,\n gap: 4,\n p: 12,\n }}\n >\n <Text color=\"text.secondary\" variant=\"caption\">\n {label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h3\">\n {value}\n </Text>\n </Stack>\n)\n\nexport const EmergencySavingsBlock = observer(function EmergencySavingsBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const copy = insightsFeedCopy?.emergency_savings\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n const balance = asNumber(beat.insights_payload?.drilldown_data?.savings_account_balance) ?? 0\n const { goal, index, labelKey } = stepForBalance(balance)\n const { WithText: Stepper } = stepChartVariants\n\n return (\n <Stack sx={{ bgcolor: 'background.default', gap: 24, p: 24 }}>\n <Stack sx={{ bgcolor: 'background.paper', borderRadius: '8px', gap: 16, p: 16 }}>\n <Stepper\n slotData={{\n completed_steps: index,\n label_1: copy[labelKey].toUpperCase(),\n label_2: buildDynamicCopy(copy.amount_in_savings, formatCurrency(goal, '0')) as string,\n }}\n />\n <Stack sx={{ flexDirection: 'row', gap: 12 }}>\n <AmountBox label={copy.total_savings_balance} value={formatCurrency(balance, '0,0.00')} />\n <AmountBox label={copy.savings_goal} value={formatCurrency(goal, '0,0')} />\n </Stack>\n </Stack>\n <SavingsCalculator balance={balance} copy={copy} goal={goal} key={beat.guid} />\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;AAeA,IAAM,IAAA,CAAa,EAAE,OAAA,GAAO,OAAA,EAAA,MAC1B,gBAAA,EAAC,GAAD;AAAA,EACE,cAAY;AAAA,EACZ,MAAK;AAAA,EACL,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,MAAM;AAAA,IACN,KAAK;AAAA,IACL,GAAG;AAAA,EACL;AAAA,EAVF,UAAA,CAYE,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAiB,SAAQ;AAAA,IAClC,UAAA;AAAA,EACG,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,IAAM,MAAM;AAAA,IAAM,WAAU;AAAA,IAAI,SAAQ;AAAA,IACrC,UAAA;AAAA,EACG,CAAA,CACD;IAGI,IAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAqB,EAAmB,GAC7E,IAAO,GAAkB;AAE/B,MAAI,CAAC,EACH,QACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,GAAG,GAAG;AAAA,IACjB,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAO,GAAY,cAAoB,CAAA;AAAA,EAClC,CAAA;AAIX,QAAM,IAAU,EAAS,EAAK,kBAAkB,gBAAgB,uBAAuB,KAAK,GACtF,EAAE,MAAA,GAAM,OAAA,GAAO,UAAA,EAAA,IAAa,EAAe,CAAO,GAClD,EAAE,UAAU,EAAA,IAAY;AAE9B,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,SAAS;AAAA,MAAsB,KAAK;AAAA,MAAI,GAAG;AAAA,IAAG;AAAA,IAA3D,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,SAAS;AAAA,QAAoB,cAAc;AAAA,QAAO,KAAK;AAAA,QAAI,GAAG;AAAA,MAAG;AAAA,MAA9E,UAAA,CACE,gBAAA,EAAC,GAAD,EACE,UAAU;AAAA,QACR,iBAAiB;AAAA,QACjB,SAAS,EAAK,CAAA,EAAU,YAAY;AAAA,QACpC,SAAS,EAAiB,EAAK,mBAAmB,EAAe,GAAM,GAAG,CAAC;AAAA,MAC7E,EACD,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,eAAe;AAAA,UAAO,KAAK;AAAA,QAAG;AAAA,QAA3C,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,UAAW,OAAO,EAAK;AAAA,UAAuB,OAAO,EAAe,GAAS,QAAQ;AAAA,QAAI,CAAA,GACzF,gBAAA,EAAC,GAAD;AAAA,UAAW,OAAO,EAAK;AAAA,UAAc,OAAO,EAAe,GAAM,KAAK;AAAA,QAAI,CAAA,CACrE;AAAA,MACF,CAAA,CAAA;AAAA,IACP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,MAA4B,SAAA;AAAA,MAAe,MAAA;AAAA,MAAY,MAAA;AAAA,IAAuB,GAAZ,EAAK,IAAO,CACzE;AAAA;AAEX,CAAC"}
@@ -3,7 +3,6 @@ export interface HelpContent {
3
3
  title: string;
4
4
  html: string;
5
5
  }
6
- export declare const toText: (value: unknown) => string | undefined;
7
6
  /**
8
7
  * A beat's "How was this calculated?" content: pre-localized `help_title` and `help_html` on the
9
8
  * payload's `drilldown_data`, shared by every CTA of the card. Absent either, there is nothing to
@@ -1,13 +1,13 @@
1
- var o = (t) => typeof t == "string" && t.trim() !== "" ? t : void 0, i = (t) => {
2
- const e = o(t?.help_title), r = o(t?.help_html);
3
- return e && r ? {
1
+ import { asNonEmptyText as p } from "../../blocks/slotReaders.es.js";
2
+ var l = (t) => {
3
+ const e = p(t?.help_title), o = p(t?.help_html);
4
+ return e && o ? {
4
5
  title: e,
5
- html: r
6
+ html: o
6
7
  } : void 0;
7
8
  };
8
9
  export {
9
- i as readHelp,
10
- o as toText
10
+ l as readHelp
11
11
  };
12
12
 
13
13
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/HelpBlock/layout.ts"],"sourcesContent":["import type { DrilldownData } from '../../../core'\n\nexport interface HelpContent {\n title: string\n html: string\n}\n\nexport const toText = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\n/**\n * A beat's \"How was this calculated?\" content: pre-localized `help_title` and `help_html` on the\n * payload's `drilldown_data`, shared by every CTA of the card. Absent either, there is nothing to\n * open.\n */\nexport const readHelp = (drilldown: DrilldownData | undefined): HelpContent | undefined => {\n const title = toText(drilldown?.help_title)\n const html = toText(drilldown?.help_html)\n return title && html ? { title, html } : undefined\n}\n"],"mappings":"AAOA,IAAa,IAAA,CAAU,MACrB,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,KAAK,IAAQ,QAOhD,IAAA,CAAY,MAAkE;AACzF,QAAM,IAAQ,EAAO,GAAW,UAAU,GACpC,IAAO,EAAO,GAAW,SAAS;AACxC,SAAO,KAAS,IAAO;AAAA,IAAE,OAAA;AAAA,IAAO,MAAA;AAAA,EAAK,IAAI;AAC3C"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/HelpBlock/layout.ts"],"sourcesContent":["import type { DrilldownData } from '../../../core'\nimport { asNonEmptyText } from '../../blocks/slotReaders'\n\nexport interface HelpContent {\n title: string\n html: string\n}\n\n/**\n * A beat's \"How was this calculated?\" content: pre-localized `help_title` and `help_html` on the\n * payload's `drilldown_data`, shared by every CTA of the card. Absent either, there is nothing to\n * open.\n */\nexport const readHelp = (drilldown: DrilldownData | undefined): HelpContent | undefined => {\n const title = asNonEmptyText(drilldown?.help_title)\n const html = asNonEmptyText(drilldown?.help_html)\n return title && html ? { title, html } : undefined\n}\n"],"mappings":";AAaA,IAAa,IAAA,CAAY,MAAkE;AACzF,QAAM,IAAQ,EAAe,GAAW,UAAU,GAC5C,IAAO,EAAe,GAAW,SAAS;AAChD,SAAO,KAAS,IAAO;AAAA,IAAE,OAAA;AAAA,IAAO,MAAA;AAAA,EAAK,IAAI;AAC3C"}