@mx-cartographer/experiences 9.7.130 → 9.7.132

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 (99) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/core/utils/NumberFormatting.d.ts +6 -0
  3. package/dist/core/utils/NumberFormatting.es.js +20 -16
  4. package/dist/core/utils/NumberFormatting.es.js.map +1 -1
  5. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +38 -38
  6. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
  7. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +17 -17
  8. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -1
  9. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +2 -0
  10. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +13 -12
  11. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
  12. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +38 -38
  13. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
  14. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js +14 -14
  15. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js.map +1 -1
  16. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -26
  17. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
  18. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js +22 -22
  19. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js.map +1 -1
  20. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js +78 -108
  21. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js.map +1 -1
  22. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.d.ts +14 -0
  23. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js +59 -13
  24. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js.map +1 -1
  25. package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js +18 -18
  26. package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js.map +1 -1
  27. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +22 -21
  28. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -1
  29. package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +57 -56
  30. package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -1
  31. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +50 -50
  32. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  33. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +2 -1
  34. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +52 -51
  35. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  36. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +17 -17
  37. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
  38. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +20 -20
  39. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
  40. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +25 -25
  41. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
  42. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +17 -16
  43. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
  44. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js +34 -34
  45. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js.map +1 -1
  46. package/dist/insights-v2/blocks/ChartBlocks/DoubleProgressBarBlock/ProgressBar.es.js +7 -7
  47. package/dist/insights-v2/blocks/ChartBlocks/DoubleProgressBarBlock/ProgressBar.es.js.map +1 -1
  48. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js +13 -13
  49. package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js.map +1 -1
  50. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +39 -39
  51. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
  52. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +6 -6
  53. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
  54. package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +20 -20
  55. package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js.map +1 -1
  56. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +44 -44
  57. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js.map +1 -1
  58. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +14 -14
  59. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
  60. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js +22 -28
  61. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js.map +1 -1
  62. package/dist/insights-v2/blocks/ComponentBlocks/GasPurchaseBlock/GasPurchaseBlock.es.js +8 -8
  63. package/dist/insights-v2/blocks/ComponentBlocks/GasPurchaseBlock/GasPurchaseBlock.es.js.map +1 -1
  64. package/dist/insights-v2/blocks/ComponentBlocks/GoalsBlock/GoalsBlock.es.js +25 -25
  65. package/dist/insights-v2/blocks/ComponentBlocks/GoalsBlock/GoalsBlock.es.js.map +1 -1
  66. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +39 -46
  67. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
  68. package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js +18 -18
  69. package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js.map +1 -1
  70. package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js +19 -19
  71. package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js.map +1 -1
  72. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js +9 -9
  73. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js.map +1 -1
  74. package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +12 -12
  75. package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js.map +1 -1
  76. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +58 -57
  77. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
  78. package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +18 -18
  79. package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js.map +1 -1
  80. package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +10 -10
  81. package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js.map +1 -1
  82. package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js +13 -13
  83. package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js.map +1 -1
  84. package/dist/insights-v2/blocks/slotReaders.d.ts +3 -1
  85. package/dist/insights-v2/blocks/slotReaders.es.js +17 -6
  86. package/dist/insights-v2/blocks/slotReaders.es.js.map +1 -1
  87. package/dist/insights-v2/components/CompactInsightCard.es.js +44 -43
  88. package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
  89. package/dist/insights-v2/components/SaveAnExtraCard.es.js +6 -6
  90. package/dist/insights-v2/components/SaveAnExtraCard.es.js.map +1 -1
  91. package/dist/insights-v2/components/WithdrawalCard.es.js +20 -20
  92. package/dist/insights-v2/components/WithdrawalCard.es.js.map +1 -1
  93. package/dist/insights-v2/components/celebrationGradients.d.ts +15 -1
  94. package/dist/insights-v2/components/celebrationGradients.es.js +16 -7
  95. package/dist/insights-v2/components/celebrationGradients.es.js.map +1 -1
  96. package/dist/insights-v2/components/shared/elevation.d.ts +2 -0
  97. package/dist/insights-v2/components/shared/elevation.es.js +3 -2
  98. package/dist/insights-v2/components/shared/elevation.es.js.map +1 -1
  99. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [9.7.132] - 11-11-2026
2
+
3
+ - **FIXED** - The step chart's milestones and the emergency savings drawer's goal label use a thousands separator ($1,000), as the goal box beside them does, and a bar's screen-reader amount matches its visible one; every Insights V2 amount uses one of two named currency formats (WEC-2259)
4
+ - **FIXED** - An Insights V2 card whose data logo is unusable (a blank, null or malformed guid, or on a bill card an icon or non-logo guid) shows its merchant or institution logo instead of an empty tile or the receipt icon (WEC-2259)
5
+
6
+ ## [9.7.131] - 11-11-2026
7
+
8
+ - **CHANGED** - Insights V2 code follows its own patterns: the Make Transfer drawer's per-variant settings live in its layout, and a stray shadow, a wash and two tile gradients move into the shared elevation and gradient files; no visual or behaviour change (WEC-2259)
9
+
1
10
  ## [9.7.130] - 11-10-2026
2
11
 
3
12
  - **CHANGED** - Insights V2 drops a blank (whitespace-only) payload text value or guid as it already drops an empty one, in the drawers, the Create Budget dialog and the budget analytics event; payload values are read through one shared set of readers (WEC-2259)
@@ -2,6 +2,12 @@ import { RoundingFunction } from 'numeral';
2
2
  import { CurrencyCodes } from '../constants/Numbers';
3
3
  export declare const generateEqualIntervals: (minValue: number, maxValue: number, tickCount: number) => number[];
4
4
  export declare const roundedAverage: (values: number[]) => number;
5
+ /** The shared currency formats: with cents, and whole dollars. */
6
+ export declare const CURRENCY_FORMAT: {
7
+ readonly cents: "0,0.00";
8
+ readonly whole: "0,0";
9
+ };
10
+ export type CurrencyFormat = (typeof CURRENCY_FORMAT)[keyof typeof CURRENCY_FORMAT];
5
11
  export declare const formatCurrency: (amount: number | undefined, formatting: string, roundingFunction?: RoundingFunction) => string;
6
12
  export declare const getCurrencyCodes: () => CurrencyCodes;
7
13
  export declare const isValidNumber: (value: any) => boolean;
@@ -1,35 +1,39 @@
1
1
  import { getLocale as a } from "./Localization.es.js";
2
2
  import { CurrencyCodes as s } from "../constants/Numbers.es.js";
3
3
  import c from "numeral";
4
- var v = (r, e, t) => {
5
- const n = [], i = (e - r) / (t - 1);
4
+ var w = (r, e, t) => {
5
+ const n = [], l = (e - r) / (t - 1);
6
6
  for (let o = 0; o < t; o++) {
7
- const l = r + o * i;
8
- n.push(l);
7
+ const i = r + o * l;
8
+ n.push(i);
9
9
  }
10
10
  return n[t - 1] = e, n.map(Math.round);
11
- }, y = (r) => r.length ? Math.round(r.reduce((e, t) => e + t, 0) / r.length) : 0, d = (r, e, t) => a() === "fr-ca" ? c(r).format(`${e} $`, t) : c(r).format(`$${e}`, t), $ = () => a() === "fr-ca" ? s.CAD : s.USD, m = (r) => r != null && r !== "" && isFinite(r), f = {
11
+ }, y = (r) => r.length ? Math.round(r.reduce((e, t) => e + t, 0) / r.length) : 0, d = {
12
+ cents: "0,0.00",
13
+ whole: "0,0"
14
+ }, m = (r, e, t) => a() === "fr-ca" ? c(r).format(`${e} $`, t) : c(r).format(`$${e}`, t), C = () => a() === "fr-ca" ? s.CAD : s.USD, f = (r) => r != null && r !== "" && isFinite(r), u = {
12
15
  style: "percent",
13
16
  minimumFractionDigits: 2,
14
17
  maximumFractionDigits: 2
15
- }, w = (r, e = f) => m(r) ? new Intl.NumberFormat(a(), e).format(Number(r)) : r, u = (r) => new Intl.PluralRules(a(), r), C = (r, e = { type: "ordinal" }, t = {
18
+ }, $ = (r, e = u) => f(r) ? new Intl.NumberFormat(a(), e).format(Number(r)) : r, h = (r) => new Intl.PluralRules(a(), r), M = (r, e = { type: "ordinal" }, t = {
16
19
  one: "st",
17
20
  two: "nd",
18
21
  few: "rd",
19
22
  other: "th"
20
- }) => `${r}${t[u(e).select(r)]}`, D = (r) => {
21
- const e = Math.round(Math.abs(r) * 100), t = d(e / 100, "0,0.00");
23
+ }) => `${r}${t[h(e).select(r)]}`, R = (r) => {
24
+ const e = Math.round(Math.abs(r) * 100), t = m(e / 100, d.cents);
22
25
  return r < 0 && e > 0 ? `-${t}` : t;
23
26
  };
24
27
  export {
25
- d as formatCurrency,
26
- C as formatOrdinal,
27
- w as formatPercentage,
28
- D as formatSignedCurrency,
29
- v as generateEqualIntervals,
30
- $ as getCurrencyCodes,
31
- u as getPluralRules,
32
- m as isValidNumber,
28
+ d as CURRENCY_FORMAT,
29
+ m as formatCurrency,
30
+ M as formatOrdinal,
31
+ $ as formatPercentage,
32
+ R as formatSignedCurrency,
33
+ w as generateEqualIntervals,
34
+ C as getCurrencyCodes,
35
+ h as getPluralRules,
36
+ f as isValidNumber,
33
37
  y as roundedAverage
34
38
  };
35
39
 
@@ -1 +1 @@
1
- {"version":3,"file":"NumberFormatting.es.js","names":[],"sources":["../../../src/core/utils/NumberFormatting.ts"],"sourcesContent":["import numeral from 'numeral'\nimport type { RoundingFunction } from 'numeral'\n\nimport { CurrencyCodes } from '../constants/Numbers'\nimport { getLocale } from './Localization'\n\nexport const generateEqualIntervals = (\n minValue: number,\n maxValue: number,\n tickCount: number,\n): number[] => {\n const ticks: number[] = []\n const range = maxValue - minValue\n const step = range / (tickCount - 1) // The space between each tick\n\n for (let i = 0; i < tickCount; i++) {\n const tickValue = minValue + i * step\n ticks.push(tickValue)\n }\n\n ticks[tickCount - 1] = maxValue\n\n return ticks.map(Math.round)\n}\n\nexport const roundedAverage = (values: number[]) =>\n values.length ? Math.round(values.reduce((sum, value) => sum + value, 0) / values.length) : 0\n\n// enhances numeral's localization functionality by puting the $ in the correct place\nexport const formatCurrency = (\n amount: number | undefined,\n formatting: string,\n roundingFunction?: RoundingFunction,\n) => {\n switch (getLocale()) {\n case 'fr-ca': {\n return numeral(amount).format(`${formatting} $`, roundingFunction)\n }\n default: {\n return numeral(amount).format(`$${formatting}`, roundingFunction)\n }\n }\n}\n\nexport const getCurrencyCodes = () => {\n switch (getLocale()) {\n case 'fr-ca':\n return CurrencyCodes.CAD\n default:\n return CurrencyCodes.USD\n }\n}\n\n// will return `true` if value is a string number, like '99', which matches Serenity logic\nexport const isValidNumber = (value: any) =>\n value !== undefined && value !== null && value !== '' && isFinite(value)\n\nconst defaultPercentStyle = {\n style: 'percent',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n} as Intl.NumberFormatOptions\n\nexport const formatPercentage = (\n amount: number | string | undefined,\n options: Intl.NumberFormatOptions = defaultPercentStyle,\n) =>\n isValidNumber(amount)\n ? new Intl.NumberFormat(getLocale(), options).format(Number(amount))\n : amount\n\nexport const getPluralRules = (options: Intl.PluralRulesOptions) =>\n new Intl.PluralRules(getLocale(), options)\n\nexport const formatOrdinal = (\n number: number,\n options: Intl.PluralRulesOptions = { type: 'ordinal' },\n copy = {\n one: 'st',\n two: 'nd',\n few: 'rd',\n other: 'th',\n } as const,\n) => {\n const rule = getPluralRules(options).select(number)\n\n return `${number}${copy[rule as keyof typeof copy]}`\n}\n\n/**\n * `-$220.00`, not `$-220.00`: the sign goes before the currency symbol. Rounded to cents first so a\n * sub-cent negative (or `-0`) reads `$0.00`, never `-$0.00`.\n */\nexport const formatSignedCurrency = (amount: number): string => {\n const cents = Math.round(Math.abs(amount) * 100)\n const formatted = formatCurrency(cents / 100, '0,0.00')\n\n return amount < 0 && cents > 0 ? `-${formatted}` : formatted\n}\n"],"mappings":";;;AAMA,IAAa,IAAA,CACX,GACA,GACA,MACa;AACb,QAAM,IAAkB,CAAC,GAEnB,KADQ,IAAW,MACH,IAAY;AAElC,WAAS,IAAI,GAAG,IAAI,GAAW,KAAK;AAClC,UAAM,IAAY,IAAW,IAAI;AACjC,IAAA,EAAM,KAAK,CAAS;AAAA,EACtB;AAEA,SAAA,EAAM,IAAY,CAAA,IAAK,GAEhB,EAAM,IAAI,KAAK,KAAK;AAC7B,GAEa,IAAA,CAAkB,MAC7B,EAAO,SAAS,KAAK,MAAM,EAAO,OAAA,CAAQ,GAAK,MAAU,IAAM,GAAO,CAAC,IAAI,EAAO,MAAM,IAAI,GAGjF,IAAA,CACX,GACA,GACA,MAEQ,EAAU,MACX,UACI,EAAQ,CAAM,EAAE,OAAO,GAAG,CAAA,MAAgB,CAAgB,IAG1D,EAAQ,CAAM,EAAE,OAAO,IAAI,CAAA,IAAc,CAAgB,GAKzD,IAAA,MACH,EAAU,MACX,UACI,EAAc,MAEd,EAAc,KAKd,IAAA,CAAiB,MACL,KAAU,QAAQ,MAAU,MAAM,SAAS,CAAK,GAEnE,IAAsB;AAAA,EAC1B,OAAO;AAAA,EACP,uBAAuB;AAAA,EACvB,uBAAuB;AACzB,GAEa,IAAA,CACX,GACA,IAAoC,MAEpC,EAAc,CAAM,IAChB,IAAI,KAAK,aAAa,EAAU,GAAG,CAAO,EAAE,OAAO,OAAO,CAAM,CAAC,IACjE,GAEO,IAAA,CAAkB,MAC7B,IAAI,KAAK,YAAY,EAAU,GAAG,CAAO,GAE9B,IAAA,CACX,GACA,IAAmC,EAAE,MAAM,UAAU,GACrD,IAAO;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,OAAO;AACT,MAIO,GAAG,CAAA,GAAS,EAFN,EAAe,CAAO,EAAE,OAAO,CAEpB,CAAA,CAAA,IAOb,IAAA,CAAwB,MAA2B;AAC9D,QAAM,IAAQ,KAAK,MAAM,KAAK,IAAI,CAAM,IAAI,GAAG,GACzC,IAAY,EAAe,IAAQ,KAAK,QAAQ;AAEtD,SAAO,IAAS,KAAK,IAAQ,IAAI,IAAI,CAAA,KAAc;AACrD"}
1
+ {"version":3,"file":"NumberFormatting.es.js","names":[],"sources":["../../../src/core/utils/NumberFormatting.ts"],"sourcesContent":["import numeral from 'numeral'\nimport type { RoundingFunction } from 'numeral'\n\nimport { CurrencyCodes } from '../constants/Numbers'\nimport { getLocale } from './Localization'\n\nexport const generateEqualIntervals = (\n minValue: number,\n maxValue: number,\n tickCount: number,\n): number[] => {\n const ticks: number[] = []\n const range = maxValue - minValue\n const step = range / (tickCount - 1) // The space between each tick\n\n for (let i = 0; i < tickCount; i++) {\n const tickValue = minValue + i * step\n ticks.push(tickValue)\n }\n\n ticks[tickCount - 1] = maxValue\n\n return ticks.map(Math.round)\n}\n\nexport const roundedAverage = (values: number[]) =>\n values.length ? Math.round(values.reduce((sum, value) => sum + value, 0) / values.length) : 0\n\n/** The shared currency formats: with cents, and whole dollars. */\nexport const CURRENCY_FORMAT = { cents: '0,0.00', whole: '0,0' } as const\nexport type CurrencyFormat = (typeof CURRENCY_FORMAT)[keyof typeof CURRENCY_FORMAT]\n\n// enhances numeral's localization functionality by puting the $ in the correct place\nexport const formatCurrency = (\n amount: number | undefined,\n formatting: string,\n roundingFunction?: RoundingFunction,\n) => {\n switch (getLocale()) {\n case 'fr-ca': {\n return numeral(amount).format(`${formatting} $`, roundingFunction)\n }\n default: {\n return numeral(amount).format(`$${formatting}`, roundingFunction)\n }\n }\n}\n\nexport const getCurrencyCodes = () => {\n switch (getLocale()) {\n case 'fr-ca':\n return CurrencyCodes.CAD\n default:\n return CurrencyCodes.USD\n }\n}\n\n// will return `true` if value is a string number, like '99', which matches Serenity logic\nexport const isValidNumber = (value: any) =>\n value !== undefined && value !== null && value !== '' && isFinite(value)\n\nconst defaultPercentStyle = {\n style: 'percent',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n} as Intl.NumberFormatOptions\n\nexport const formatPercentage = (\n amount: number | string | undefined,\n options: Intl.NumberFormatOptions = defaultPercentStyle,\n) =>\n isValidNumber(amount)\n ? new Intl.NumberFormat(getLocale(), options).format(Number(amount))\n : amount\n\nexport const getPluralRules = (options: Intl.PluralRulesOptions) =>\n new Intl.PluralRules(getLocale(), options)\n\nexport const formatOrdinal = (\n number: number,\n options: Intl.PluralRulesOptions = { type: 'ordinal' },\n copy = {\n one: 'st',\n two: 'nd',\n few: 'rd',\n other: 'th',\n } as const,\n) => {\n const rule = getPluralRules(options).select(number)\n\n return `${number}${copy[rule as keyof typeof copy]}`\n}\n\n/**\n * `-$220.00`, not `$-220.00`: the sign goes before the currency symbol. Rounded to cents first so a\n * sub-cent negative (or `-0`) reads `$0.00`, never `-$0.00`.\n */\nexport const formatSignedCurrency = (amount: number): string => {\n const cents = Math.round(Math.abs(amount) * 100)\n const formatted = formatCurrency(cents / 100, CURRENCY_FORMAT.cents)\n\n return amount < 0 && cents > 0 ? `-${formatted}` : formatted\n}\n"],"mappings":";;;AAMA,IAAa,IAAA,CACX,GACA,GACA,MACa;AACb,QAAM,IAAkB,CAAC,GAEnB,KADQ,IAAW,MACH,IAAY;AAElC,WAAS,IAAI,GAAG,IAAI,GA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AAS,KAAK,IAAQ,IAAI,IAAI,CAAA,KAAc;AACrD"}
@@ -9,34 +9,34 @@ import { useCtaHandler as Z } from "../../ctaActions/useCtaAction.es.js";
9
9
  import { useAnalyticsEvent as oo } from "../../analytics/useAnalyticsEvent.es.js";
10
10
  import { getDynamicCtaBasedOnTriggers as eo } from "../util.es.js";
11
11
  import { CreateBudgetDialog as to } from "./CreateBudgetDialog.es.js";
12
- import { AMOUNT_INPUT_VARIANTS as io, findLowBalanceProfile as no, isAmountInputVariant as x, isWholeAmount as ro, resolveAmountInputVariant as ao, toInputValue as so } from "./layout.es.js";
12
+ import { AMOUNT_INPUT_VARIANTS as io, CREATE_BUDGET_VARIANT as no, findLowBalanceProfile as ro, isAmountInputVariant as x, isWholeAmount as ao, resolveAmountInputVariant as so, toInputValue as co } from "./layout.es.js";
13
13
  import a from "react";
14
- import { observer as k } from "mobx-react-lite";
15
- import V from "@mui/material/Stack";
16
- import { H3 as co, InstitutionLogo as lo, Text as w } from "@mxenabled/mxui";
17
- import { Icon as uo } from "@mxenabled/mx-icons";
14
+ import { observer as V } from "mobx-react-lite";
15
+ import k from "@mui/material/Stack";
16
+ import { H3 as lo, InstitutionLogo as uo, Text as w } from "@mxenabled/mxui";
17
+ import { Icon as mo } from "@mxenabled/mx-icons";
18
18
  import { jsx as o, jsxs as O } from "react/jsx-runtime";
19
- import mo from "@mui/material/Dialog";
20
- import po from "@mui/material/IconButton";
21
- var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
19
+ import po from "@mui/material/Dialog";
20
+ import _o from "@mui/material/IconButton";
21
+ var E = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
22
22
  const l = a.useId();
23
- return /* @__PURE__ */ o(mo, {
23
+ return /* @__PURE__ */ o(po, {
24
24
  "aria-labelledby": n ? l : void 0,
25
25
  maxWidth: "xs",
26
26
  onClose: e,
27
27
  open: !0,
28
- children: /* @__PURE__ */ O(V, {
28
+ children: /* @__PURE__ */ O(k, {
29
29
  sx: {
30
30
  gap: 12,
31
31
  p: 24,
32
32
  position: "relative"
33
33
  },
34
34
  children: [
35
- n && /* @__PURE__ */ o(co, {
35
+ n && /* @__PURE__ */ o(lo, {
36
36
  id: l,
37
37
  children: n
38
38
  }),
39
- /* @__PURE__ */ o(po, {
39
+ /* @__PURE__ */ o(_o, {
40
40
  "aria-label": i || "Close",
41
41
  onClick: e,
42
42
  sx: {
@@ -44,7 +44,7 @@ var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
44
44
  right: 8,
45
45
  top: 18
46
46
  },
47
- children: /* @__PURE__ */ o(uo, {
47
+ children: /* @__PURE__ */ o(mo, {
48
48
  name: "close",
49
49
  sx: { color: "action.active" }
50
50
  })
@@ -53,79 +53,79 @@ var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
53
53
  ]
54
54
  })
55
55
  });
56
- }, ko = k(function({ beat: i }) {
57
- const { common: n } = H(), { actionDrawer: e, closeActionDrawer: l } = P(), s = q(), { primary_cta: u, secondary_cta: p, in_description_cta: _ } = i.insights_payload ?? {}, [m] = a.useState(() => ao(eo(e, u, p, _))), r = m === "create_budget";
56
+ }, ko = V(function({ beat: i }) {
57
+ const { common: n } = H(), { actionDrawer: e, closeActionDrawer: l } = P(), s = q(), { primary_cta: u, secondary_cta: p, in_description_cta: _ } = i.insights_payload ?? {}, [m] = a.useState(() => so(eo(e, u, p, _))), r = m === no;
58
58
  return a.useEffect(() => {
59
59
  r && !s.categoriesLoaded && s.loadCategories();
60
- }, [s, r]), r ? s.categoriesLoaded ? /* @__PURE__ */ o(to, { beat: i }) : /* @__PURE__ */ o(v, {
60
+ }, [s, r]), r ? s.categoriesLoaded ? /* @__PURE__ */ o(to, { beat: i }) : /* @__PURE__ */ o(E, {
61
61
  closeAriaLabel: n?.close_aria,
62
62
  onClose: l,
63
63
  children: /* @__PURE__ */ o(B, {})
64
- }) : /* @__PURE__ */ o(_o, {
64
+ }) : /* @__PURE__ */ o(fo, {
65
65
  beat: i,
66
66
  variant: m
67
67
  });
68
- }), _o = k(function({ beat: i, variant: n }) {
69
- const { common: e, insights_feed: l } = H(), { closeActionDrawer: s } = P(), u = J(), { userInsightProfile: p } = K(), _ = Z(i, X()), m = oo(), r = l?.amount_input_modal, t = n === io.LOW_BALANCE_THRESHOLD, S = t ? no(u.notificationProfiles, i.primary_account_guid) : void 0, E = t ? S?.threshold : p?.savings_opportunity_minimum_checking_account_balance, [G, R] = a.useState(t), f = a.useRef(!0);
68
+ }), fo = V(function({ beat: i, variant: n }) {
69
+ const { common: e, insights_feed: l } = H(), { closeActionDrawer: s } = P(), u = J(), { userInsightProfile: p } = K(), _ = Z(i, X()), m = oo(), r = l?.amount_input_modal, t = n === io.LOW_BALANCE_THRESHOLD, I = t ? ro(u.notificationProfiles, i.primary_account_guid) : void 0, T = t ? I?.threshold : p?.savings_opportunity_minimum_checking_account_balance, [R, G] = a.useState(t), f = a.useRef(!0);
70
70
  a.useEffect(() => (f.current = !0, () => {
71
71
  f.current = !1;
72
72
  }), []), a.useEffect(() => {
73
73
  t && u.loadNotificationProfiles().finally(() => {
74
- f.current && R(!1);
74
+ f.current && G(!1);
75
75
  });
76
76
  }, [t, u]);
77
- const [F, M] = a.useState(null), [T, C] = a.useState(!1), [U, I] = a.useState(!1), g = F ?? so(E);
78
- if (G) return /* @__PURE__ */ o(v, {
77
+ const [F, M] = a.useState(null), [v, C] = a.useState(!1), [U, S] = a.useState(!1), g = F ?? co(T);
78
+ if (R) return /* @__PURE__ */ o(E, {
79
79
  closeAriaLabel: e?.close_aria,
80
80
  onClose: s,
81
81
  children: /* @__PURE__ */ o(B, {})
82
82
  });
83
83
  const c = x(n) ? r?.[n] : void 0, D = !!c?.title && !!c.description && !!c.input_label && !!r?.whole_number_error && !!r.save_error && !!e?.save_button && (!t || !!e.cancel_button) && !!e.close_aria;
84
- if (!r || !c || !D || !(t ? S : p))
85
- return console.warn(`amount_input_modal_block: ${r ? x(n) ? D ? t ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ o(v, {
84
+ if (!r || !c || !D || !(t ? I : p))
85
+ return console.warn(`amount_input_modal_block: ${r ? x(n) ? D ? t ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ o(E, {
86
86
  closeAriaLabel: e?.close_aria,
87
87
  heading: e?.error_heading,
88
88
  onClose: s,
89
89
  children: /* @__PURE__ */ o(w, { children: e?.error_message })
90
90
  });
91
- const b = () => {
91
+ const L = () => {
92
92
  m(t ? d.EDIT_INSIGHT_THRESHOLD_CANCELED : d.EDIT_SAFETY_NET_CANCEL), s();
93
- }, L = !t && !!E, N = i.primary_account ? z(i.primary_account) : "", A = ro(g), $ = g !== "" && !A, W = async () => {
94
- if (!A || T) return;
93
+ }, b = !t && !!T, N = i.primary_account ? z(i.primary_account) : "", A = ao(g), $ = g !== "" && !A, W = async () => {
94
+ if (!A || v) return;
95
95
  const h = Number(g);
96
- C(!0), I(!1);
96
+ C(!0), S(!1);
97
97
  const Y = t ? await _("updateNotificationProfileThreshold", {
98
- profileGuid: S?.guid,
98
+ profileGuid: I?.guid,
99
99
  threshold: h
100
100
  }, { analytics: d.EDIT_INSIGHT_THRESHOLD_SAVE }) : await _("updateUserInsightProfile", { fields: { savings_opportunity_minimum_checking_account_balance: h } }, { analytics: d.EDIT_SAFETY_NET_SAVE });
101
- f.current && (C(!1), Y ? s() : I(!0));
101
+ f.current && (C(!1), Y ? s() : S(!0));
102
102
  };
103
103
  return /* @__PURE__ */ o(Q, {
104
104
  closeAriaLabel: e.close_aria,
105
- content: j(L && c.description_edit || c.description, /* @__PURE__ */ o("strong", { children: N }, "account")),
105
+ content: j(b && c.description_edit || c.description, /* @__PURE__ */ o("strong", { children: N }, "account")),
106
106
  errorText: $ ? r.whole_number_error : U ? r.save_error : void 0,
107
107
  handleInputChange: (h) => {
108
- M(h), I(!1);
108
+ M(h), S(!1);
109
109
  },
110
110
  handleInputClick: t ? () => m(d.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED) : void 0,
111
- handleModalClose: b,
111
+ handleModalClose: L,
112
112
  handlePrimaryAction: () => {
113
113
  W();
114
114
  },
115
- handleSecondaryAction: b,
115
+ handleSecondaryAction: L,
116
116
  inputLabel: c.input_label,
117
117
  inputValue: g,
118
118
  isOpen: !0,
119
- isPrimaryDisabled: T || !A,
119
+ isPrimaryDisabled: v || !A,
120
120
  primaryText: e.save_button,
121
121
  secondaryText: t ? e.cancel_button : void 0,
122
- subtitle: t && i.primary_account ? /* @__PURE__ */ O(V, {
122
+ subtitle: t && i.primary_account ? /* @__PURE__ */ O(k, {
123
123
  sx: {
124
124
  alignItems: "center",
125
125
  flexDirection: "row",
126
126
  gap: 8
127
127
  },
128
- children: [/* @__PURE__ */ o(lo, {
128
+ children: [/* @__PURE__ */ o(uo, {
129
129
  alt: "",
130
130
  institutionGuid: i.primary_account.institution_guid ?? "",
131
131
  size: 16
@@ -136,7 +136,7 @@ var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
136
136
  children: N
137
137
  })]
138
138
  }) : void 0,
139
- title: L && c.title_edit || c.title
139
+ title: b && c.title_edit || c.title
140
140
  });
141
141
  });
142
142
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() =>\n resolveAmountInputVariant(\n getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta),\n ),\n )\n const isCreateBudget = variant === 'create_budget'\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,QAAI,UAAU;AAAA,MAAW;AAAA,MAAlD,UAAA;AAAA,QACG,KAAW,gBAAA,EAAC,IAAD;AAAA,UAAI,IAAI;AAAA,UAAY,UAAA;AAAA,QAAY,CAAA;AAAA,QAC5C,gBAAA,EAAC,IAAD;AAAA,UACE,cAAY,KAAkB;AAAA,UAC9B,SAAS;AAAA,UACT,IAAI;AAAA,YAAE,UAAU;AAAA,YAAY,OAAO;AAAA,YAAG,KAAK;AAAA,UAAG;AAAA,UAE9C,UAAA,gBAAA,EAAC,IAAD;AAAA,YAAM,MAAK;AAAA,YAAQ,IAAI,EAAE,OAAO,gBAAgB;AAAA,UAAI,CAAA;AAAA,QAC1C,CAAA;AAAA,QACX;AAAA,MACI;AAAA;EACE,CAAA;AAEf,GAGa,KAAwB,EAA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AW;AAAA;AAAA,IAC3C,uBAAuB;AAAA,IACvB,YAAY,EAAY;AAAA,IACxB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,mBAAmB,KAAY,CAAC;AAAA,IAChC,aAAa,EAAW;AAAA,IACxB,eAAe,IAAe,EAAW,gBAAgB;AAAA,IACzD,UACE,KAAgB,EAAK,kBACnB,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
1
+ {"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() =>\n resolveAmountInputVariant(\n getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta),\n ),\n )\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,QAAI,UAAU;AAAA,MAAW;AAAA,MAAlD,UAAA;AAAA,QACG,KAAW,gBAAA,EAAC,IAAD;AAAA,UAAI,IAAI;AAAA,UAAY,UAAA;AAAA,QAAY,CAAA;AAAA,QAC5C,gBAAA,EAAC,IAAD;AAAA,UACE,cAAY,KAAkB;AAAA,UAC9B,SAAS;AAAA,UACT,IAAI;AAAA,YAAE,UAAU;AAAA,YAAY,OAAO;AAAA,YAAG,KAAK;AAAA,UAAG;AAAA,UAE9C,UAAA,gBAAA,EAAC,IAAD;AAAA,YAAM,MAAK;AAAA,YAAQ,IAAI,EAAE,OAAO,gBAAgB;AAAA,UAAI,CAAA;AAAA,QAC1C,CAAA;AAAA,QACX;AAAA,MACI;AAAA;EACE,CAAA;AAEf,GAGa,KAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,QAAQ,EAAA,IAAe,EAAmB,GAC5C,EAAE,cAAA,GAAc,mBAAA,EAAA,IAAsB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AAAA,IAChC,aAAa,EAAW;AAAA,IACxB,eAAe,IAAe,EAAW,gBAAgB;AAAA,IACzD,UACE,KAAgB,EAAK,kBACnB,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
@@ -1,22 +1,22 @@
1
1
  import { buildDynamicCopy as C } from "../../../core/utils/Localization.es.js";
2
- import { useCategoryStore as N, useGlobalCopyStore as k, useInsightsV2Store as F } from "../../../common/context/hooks.es.js";
3
- import { slot as P } from "../../../core/types/Insights.es.js";
4
- import { formatCurrency as T } from "../../../core/utils/NumberFormatting.es.js";
5
- import { getLocalizedCategoryName as j } from "../../../core/utils/CategoryUtil.es.js";
6
- import w from "../../../common/components/CurrencyDialog.es.js";
7
- import { useBeatActions as G } from "../../beatActions.es.js";
8
- import { isPositiveAmount as H, resolveBudgetFacts as M } from "../BudgetDetailsBlock/layout.es.js";
9
- import { useCtaHandler as O } from "../../ctaActions/useCtaAction.es.js";
10
- import R from "../../components/shared/StatusSnackbar.es.js";
2
+ import { useCategoryStore as F, useGlobalCopyStore as I, useInsightsV2Store as L } from "../../../common/context/hooks.es.js";
3
+ import { slot as T } from "../../../core/types/Insights.es.js";
4
+ import { CURRENCY_FORMAT as k, formatCurrency as w } from "../../../core/utils/NumberFormatting.es.js";
5
+ import { getLocalizedCategoryName as M } from "../../../core/utils/CategoryUtil.es.js";
6
+ import O from "../../../common/components/CurrencyDialog.es.js";
7
+ import { useBeatActions as P } from "../../beatActions.es.js";
8
+ import { isPositiveAmount as j, resolveBudgetFacts as E } from "../BudgetDetailsBlock/layout.es.js";
9
+ import { useCtaHandler as G } from "../../ctaActions/useCtaAction.es.js";
10
+ import H from "../../components/shared/StatusSnackbar.es.js";
11
11
  import e from "react";
12
12
  import { observer as V } from "mobx-react-lite";
13
13
  import { jsx as l, jsxs as z } from "react/jsx-runtime";
14
- var re = V(function({ beat: n }) {
15
- const { budgets: t, categories: b, common: r, insights_feed: h } = k(), S = N(), { closeActionDrawer: s } = F(), v = O(n, G()), A = n.insights_payload, { categoryGuid: m = "" } = M(n), x = P(A?.instance_slot?.data, "average_amount") ?? 0, d = S.categories.find(({ guid: o }) => o === m), g = d ? j(d, b) : "", [c, B] = e.useState(""), [D, p] = e.useState(!0), [I, f] = e.useState(!1), [a, i] = e.useState(null), u = e.useRef(!0);
14
+ var ae = V(function({ beat: n }) {
15
+ const { budgets: t, categories: b, common: r, insights_feed: h } = I(), S = F(), { closeActionDrawer: s } = L(), v = G(n, P()), A = n.insights_payload, { categoryGuid: m = "" } = E(n), x = T(A?.instance_slot?.data, "average_amount") ?? 0, d = S.categories.find(({ guid: o }) => o === m), g = d ? M(d, b) : "", [c, B] = e.useState(""), [D, p] = e.useState(!0), [N, f] = e.useState(!1), [a, i] = e.useState(null), u = e.useRef(!0);
16
16
  e.useEffect(() => (u.current = !0, () => {
17
17
  u.current = !1;
18
18
  }), []);
19
- const y = (o) => C(o, g), _ = H(c) && !I, L = async () => {
19
+ const y = (o) => C(o, g), _ = j(c) && !N, R = async () => {
20
20
  if (!_) return;
21
21
  f(!0);
22
22
  const o = await v("createBudget", {
@@ -25,13 +25,13 @@ var re = V(function({ beat: n }) {
25
25
  }, { onSuccess: ["refreshBeat"] });
26
26
  u.current && (f(!1), p(!1), i(o ? "created" : "failed"));
27
27
  };
28
- return /* @__PURE__ */ z(e.Fragment, { children: [/* @__PURE__ */ l(w, {
28
+ return /* @__PURE__ */ z(e.Fragment, { children: [/* @__PURE__ */ l(O, {
29
29
  closeAriaLabel: r.close_aria,
30
- content: C(t.create_budget_content, /* @__PURE__ */ l("strong", { children: g }, "category"), T(x, "0,0")),
30
+ content: C(t.create_budget_content, /* @__PURE__ */ l("strong", { children: g }, "category"), w(x, k.whole)),
31
31
  handleInputChange: B,
32
32
  handleModalClose: s,
33
33
  handlePrimaryAction: () => {
34
- L();
34
+ R();
35
35
  },
36
36
  handleSecondaryAction: s,
37
37
  inputLabel: r.amount_text,
@@ -41,7 +41,7 @@ var re = V(function({ beat: n }) {
41
41
  primaryText: t.dialog_primary_button_text,
42
42
  secondaryText: r.cancel_button,
43
43
  title: t.dialog_create_budget_title
44
- }), /* @__PURE__ */ l(R, {
44
+ }), /* @__PURE__ */ l(H, {
45
45
  actionText: a === "failed" ? h?.general?.try_again : void 0,
46
46
  closeAriaLabel: r.close_aria,
47
47
  message: y(a === "created" ? t.alert_budget_created : t.alert_merchant_budget_not_created),
@@ -56,7 +56,7 @@ var re = V(function({ beat: n }) {
56
56
  })] });
57
57
  });
58
58
  export {
59
- re as CreateBudgetDialog
59
+ ae as CreateBudgetDialog
60
60
  };
61
61
 
62
62
  //# sourceMappingURL=CreateBudgetDialog.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CreateBudgetDialog.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n buildDynamicCopy,\n formatCurrency,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n} from '../../../common'\nimport { slot } from '../../../core/types/Insights'\nimport { getLocalizedCategoryName } from '../../../core/utils/CategoryUtil'\nimport StatusSnackbar from '../../components/shared/StatusSnackbar'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { isPositiveAmount, resolveBudgetFacts } from '../BudgetDetailsBlock/layout'\n\ntype Notice = 'created' | 'failed'\n\n/** The \"Create a Budget\" dialog (mounted once categories load): creates the budget, refreshes the beat, shows the result. */\nexport const CreateBudgetDialog = observer(function CreateBudgetDialog({ beat }: ActionBlockProps) {\n const {\n budgets: budgetsCopy,\n categories: categoriesCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n } = useGlobalCopyStore()\n const categoryStore = useCategoryStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const runHandler = useCtaHandler(beat, useBeatActions())\n\n const payload = beat.insights_payload\n const { categoryGuid = '' } = resolveBudgetFacts(beat)\n const averageAmount = slot<number>(payload?.instance_slot?.data, 'average_amount') ?? 0\n const category = categoryStore.categories.find(({ guid }) => guid === categoryGuid)\n const categoryName = category ? getLocalizedCategoryName(category, categoriesCopy) : ''\n\n const [amount, setAmount] = React.useState('')\n const [isOpen, setIsOpen] = React.useState(true)\n const [isSaving, setIsSaving] = React.useState(false)\n const [notice, setNotice] = React.useState<Notice | null>(null)\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n const named = (copy: string) => buildDynamicCopy(copy, categoryName) as string\n\n const canCreate = isPositiveAmount(amount) && !isSaving\n\n const handleCreate = async () => {\n if (!canCreate) return\n\n setIsSaving(true)\n const ok = await runHandler(\n 'createBudget',\n { categoryGuid, amount: Number(amount) },\n { onSuccess: ['refreshBeat'] },\n )\n if (!isMounted.current) return\n\n setIsSaving(false)\n setIsOpen(false)\n setNotice(ok ? 'created' : 'failed')\n }\n\n return (\n <React.Fragment>\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n content={\n buildDynamicCopy(\n budgetsCopy.create_budget_content,\n <strong key=\"category\">{categoryName}</strong>,\n formatCurrency(averageAmount, '0,0'),\n ) as React.ReactNode\n }\n handleInputChange={setAmount}\n handleModalClose={closeActionDrawer}\n handlePrimaryAction={() => void handleCreate()}\n handleSecondaryAction={closeActionDrawer}\n inputLabel={commonCopy.amount_text}\n inputValue={amount}\n isOpen={isOpen}\n isPrimaryDisabled={!canCreate}\n primaryText={budgetsCopy.dialog_primary_button_text}\n secondaryText={commonCopy.cancel_button}\n title={budgetsCopy.dialog_create_budget_title}\n />\n <StatusSnackbar\n actionText={notice === 'failed' ? insightsFeedCopy?.general?.try_again : undefined}\n closeAriaLabel={commonCopy.close_aria}\n message={\n notice === 'created'\n ? named(budgetsCopy.alert_budget_created)\n : named(budgetsCopy.alert_merchant_budget_not_created)\n }\n onActionClick={() => {\n setNotice(null)\n setIsOpen(true)\n }}\n onClose={() => {\n setNotice(null)\n closeActionDrawer()\n }}\n open={Boolean(notice)}\n severity={notice === 'created' ? 'success' : 'error'}\n />\n </React.Fragment>\n )\n})\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,KAAqB,EAAS,SAA4B,EAAE,MAAA,EAAA,GAA0B;AACjG,QAAM,EACJ,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,eAAe,EAAA,IACb,EAAmB,GACjB,IAAgB,EAAiB,GACjC,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,IAAa,EAAc,GAAM,EAAe,CAAC,GAEjD,IAAU,EAAK,kBACf,EAAE,cAAA,IAAe,GAAA,IAAO,EAAmB,CAAI,GAC/C,IAAgB,EAAa,GAAS,eAAe,MAAM,gBAAgB,KAAK,GAChF,IAAW,EAAc,WAAW,KAAA,CAAM,EAAE,MAAA,EAAA,MAAW,MAAS,CAAY,GAC5E,IAAe,IAAW,EAAyB,GAAU,CAAc,IAAI,IAE/E,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAS,EAAE,GACvC,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAS,EAAI,GACzC,CAAC,GAAU,CAAA,IAAe,EAAM,SAAS,EAAK,GAC9C,CAAC,GAAQ,CAAA,IAAa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5C,eAAA,MAAqB;AACnB,MAAA,EAAU,IAAI,GACd,EAAU,EAAI;AAAA,IAChB;AAAA,IACA,SAAA,MAAe;AACb,MAAA,EAAU,IAAI,GACd,EAAkB;AAAA,IACpB;AAAA,IACA,MAAM,EAAQ;AAAA,IACd,UAAU,MAAW,YAAY,YAAY;AAAA,EAC9C,CAAA,CACa,EAAA,CAAA;AAEpB,CAAC"}
1
+ {"version":3,"file":"CreateBudgetDialog.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n} from '../../../common'\nimport { slot } from '../../../core/types/Insights'\nimport { getLocalizedCategoryName } from '../../../core/utils/CategoryUtil'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport StatusSnackbar from '../../components/shared/StatusSnackbar'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { isPositiveAmount, resolveBudgetFacts } from '../BudgetDetailsBlock/layout'\n\ntype Notice = 'created' | 'failed'\n\n/** The \"Create a Budget\" dialog (mounted once categories load): creates the budget, refreshes the beat, shows the result. */\nexport const CreateBudgetDialog = observer(function CreateBudgetDialog({ beat }: ActionBlockProps) {\n const {\n budgets: budgetsCopy,\n categories: categoriesCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n } = useGlobalCopyStore()\n const categoryStore = useCategoryStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const runHandler = useCtaHandler(beat, useBeatActions())\n\n const payload = beat.insights_payload\n const { categoryGuid = '' } = resolveBudgetFacts(beat)\n const averageAmount = slot<number>(payload?.instance_slot?.data, 'average_amount') ?? 0\n const category = categoryStore.categories.find(({ guid }) => guid === categoryGuid)\n const categoryName = category ? getLocalizedCategoryName(category, categoriesCopy) : ''\n\n const [amount, setAmount] = React.useState('')\n const [isOpen, setIsOpen] = React.useState(true)\n const [isSaving, setIsSaving] = React.useState(false)\n const [notice, setNotice] = React.useState<Notice | null>(null)\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n const named = (copy: string) => buildDynamicCopy(copy, categoryName) as string\n\n const canCreate = isPositiveAmount(amount) && !isSaving\n\n const handleCreate = async () => {\n if (!canCreate) return\n\n setIsSaving(true)\n const ok = await runHandler(\n 'createBudget',\n { categoryGuid, amount: Number(amount) },\n { onSuccess: ['refreshBeat'] },\n )\n if (!isMounted.current) return\n\n setIsSaving(false)\n setIsOpen(false)\n setNotice(ok ? 'created' : 'failed')\n }\n\n return (\n <React.Fragment>\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n content={\n buildDynamicCopy(\n budgetsCopy.create_budget_content,\n <strong key=\"category\">{categoryName}</strong>,\n formatCurrency(averageAmount, CURRENCY_FORMAT.whole),\n ) as React.ReactNode\n }\n handleInputChange={setAmount}\n handleModalClose={closeActionDrawer}\n handlePrimaryAction={() => void handleCreate()}\n handleSecondaryAction={closeActionDrawer}\n inputLabel={commonCopy.amount_text}\n inputValue={amount}\n isOpen={isOpen}\n isPrimaryDisabled={!canCreate}\n primaryText={budgetsCopy.dialog_primary_button_text}\n secondaryText={commonCopy.cancel_button}\n title={budgetsCopy.dialog_create_budget_title}\n />\n <StatusSnackbar\n actionText={notice === 'failed' ? insightsFeedCopy?.general?.try_again : undefined}\n closeAriaLabel={commonCopy.close_aria}\n message={\n notice === 'created'\n ? named(budgetsCopy.alert_budget_created)\n : named(budgetsCopy.alert_merchant_budget_not_created)\n }\n onActionClick={() => {\n setNotice(null)\n setIsOpen(true)\n }}\n onClose={() => {\n setNotice(null)\n closeActionDrawer()\n }}\n open={Boolean(notice)}\n severity={notice === 'created' ? 'success' : 'error'}\n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AAQ;AAAA,EACrC;AAEA,SACE,gBAAA,EAAC,EAAM,UAAP,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,SACE,EACE,EAAY,uBACZ,gBAAA,EAAC,UAAD,EAAA,UAAwB,EAAqB,GAAjC,UAAiC,GAC7C,EAAe,GAAe,EAAgB,KAAK,CACrD;AAAA,IAEF,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,qBAAA,MAAA;AAA2B,MAAK,EAAa;AAAA;AAAA,IAC7C,uBAAuB;AAAA,IACvB,YAAY,EAAW;AAAA,IACvB,YAAY;AAAA,IACJ,QAAA;AAAA,IACR,mBAAmB,CAAC;AAAA,IACpB,aAAa,EAAY;AAAA,IACzB,eAAe,EAAW;AAAA,IAC1B,OAAO,EAAY;AAAA,EACpB,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,YAAY,MAAW,WAAW,GAAkB,SAAS,YAAY;AAAA,IACzE,gBAAgB,EAAW;AAAA,IAC3B,SAEM,EADJ,MAAW,YACD,EAAY,uBACZ,EAAY,iCADoB;AAAA,IAG5C,eAAA,MAAqB;AACnB,MAAA,EAAU,IAAI,GACd,EAAU,EAAI;AAAA,IAChB;AAAA,IACA,SAAA,MAAe;AACb,MAAA,EAAU,IAAI,GACd,EAAkB;AAAA,IACpB;AAAA,IACA,MAAM,EAAQ;AAAA,IACd,UAAU,MAAW,YAAY,YAAY;AAAA,EAC9C,CAAA,CACa,EAAA,CAAA;AAEpB,CAAC"}
@@ -4,6 +4,8 @@ export declare const AMOUNT_INPUT_VARIANTS: {
4
4
  readonly LOW_BALANCE_THRESHOLD: "low_balance_threshold";
5
5
  readonly SAFETY_NET: "safety_net";
6
6
  };
7
+ /** Opens the Create Budget dialog instead of an amount setting (Category Spending). */
8
+ export declare const CREATE_BUDGET_VARIANT = "create_budget";
7
9
  export type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS];
8
10
  export declare const isAmountInputVariant: (variant?: string | null) => variant is AmountInputVariant;
9
11
  /**
@@ -1,19 +1,20 @@
1
- import { AccountNotificationTypes as i } from "../../../core/types/Notification.es.js";
2
- import { actionBlocksKey as a } from "../../mappings/actionBlocksKey.es.js";
3
- var o = {
1
+ import { AccountNotificationTypes as a } from "../../../core/types/Notification.es.js";
2
+ import { actionBlocksKey as o } from "../../mappings/actionBlocksKey.es.js";
3
+ var e = {
4
4
  LOW_BALANCE_THRESHOLD: "low_balance_threshold",
5
5
  SAFETY_NET: "safety_net"
6
- }, T = (t) => Object.values(o).includes(t ?? ""), u = (t) => {
6
+ }, T = "create_budget", u = (t) => Object.values(e).includes(t ?? ""), N = (t) => {
7
7
  if (t?.variant) return t.variant;
8
- if (t?.block === a.SAFETY_NET_ACTION_BLOCK) return o.SAFETY_NET;
9
- }, e = 1e9, N = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= e, c = (t) => t ? String(Math.round(t)) : "", l = (t, n) => n ? t.find((r) => r.entity_guid === n && r.notification_type === i.AccountBalanceLow) : void 0;
8
+ if (t?.block === o.SAFETY_NET_ACTION_BLOCK) return e.SAFETY_NET;
9
+ }, i = 1e9, c = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= i, v = (t) => t ? String(Math.round(t)) : "", E = (t, r) => r ? t.find((n) => n.entity_guid === r && n.notification_type === a.AccountBalanceLow) : void 0;
10
10
  export {
11
- o as AMOUNT_INPUT_VARIANTS,
12
- l as findLowBalanceProfile,
13
- T as isAmountInputVariant,
14
- N as isWholeAmount,
15
- u as resolveAmountInputVariant,
16
- c as toInputValue
11
+ e as AMOUNT_INPUT_VARIANTS,
12
+ T as CREATE_BUDGET_VARIANT,
13
+ E as findLowBalanceProfile,
14
+ u as isAmountInputVariant,
15
+ c as isWholeAmount,
16
+ N as resolveAmountInputVariant,
17
+ v as toInputValue
17
18
  };
18
19
 
19
20
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;AAKA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAIa,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBACjC,QAAO,EAAsB;AAEjC,GAGM,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\n/** Opens the Create Budget dialog instead of an amount setting (Category Spending). */\nexport const CREATE_BUDGET_VARIANT = 'create_budget'\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;AAKA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAGa,IAAwB,iBAIxB,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBACjC,QAAO,EAAsB;AAEjC,GAGM,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}