@mx-cartographer/experiences 9.7.41 → 9.7.43

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 (43) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/core/types/InsightsInstanceSlotData.d.ts +9 -1
  3. package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
  4. package/dist/core/types/localization/InsightsFeedCopy.d.ts +3 -0
  5. package/dist/insights-v2/actionBlocks/ConnectWidgetActionBlock.es.js +20 -14
  6. package/dist/insights-v2/actionBlocks/ConnectWidgetActionBlock.es.js.map +1 -1
  7. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +3 -1
  8. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +85 -75
  9. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
  10. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +115 -93
  11. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  12. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +3 -1
  13. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +66 -44
  14. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  15. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +1 -1
  16. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +49 -44
  17. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  18. package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +4 -0
  19. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +4 -0
  20. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
  21. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.d.ts +1 -1
  22. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js +19 -19
  23. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js.map +1 -1
  24. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.d.ts +8 -1
  25. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js +47 -31
  26. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js.map +1 -1
  27. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.d.ts +1 -5
  28. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js +10 -6
  29. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js.map +1 -1
  30. package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.d.ts +5 -2
  31. package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js +21 -23
  32. package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js.map +1 -1
  33. package/dist/insights-v2/components/CompactInsightCard.es.js +148 -82
  34. package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
  35. package/dist/insights-v2/components/SubTabs.d.ts +22 -0
  36. package/dist/insights-v2/components/SubTabs.es.js +38 -0
  37. package/dist/insights-v2/components/SubTabs.es.js.map +1 -0
  38. package/dist/insights-v2/components/chartblocks/ChartLegend.es.js +14 -18
  39. package/dist/insights-v2/components/chartblocks/ChartLegend.es.js.map +1 -1
  40. package/dist/insights-v2/components/chartblocks/DoubleBarChart.d.ts +5 -3
  41. package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js +108 -104
  42. package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js.map +1 -1
  43. package/package.json +1 -1
@@ -1,77 +1,98 @@
1
- import { useGlobalCopyStore as Z, useGlobalUiStore as tt, useInsightsV2Store as et } from "../../../common/context/hooks.es.js";
2
- import { formatCurrency as ot } from "../../../core/utils/NumberFormatting.es.js";
3
- import at from "../../../common/components/drawer/Drawer.es.js";
4
- import nt from "../../../common/components/Loader.es.js";
5
- import { BAR_ARIA_LABEL as rt } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
6
- import { BarChartV2 as it } from "../../components/chartblocks/BarchartV2.es.js";
7
- import { EmptyBarChart as st } from "../../components/chartblocks/EmptyBarChart.es.js";
8
- import { ANALYTICS_EVENTS_CONFIG as B } from "../../analytics/analyticsEventsConfig.es.js";
9
- import { useAnalyticsEvent as lt } from "../../analytics/useAnalyticsEvent.es.js";
10
- import { TransactionDrillDown as ct } from "./TransactionDrillDown.es.js";
11
- import { getDefaultSelection as mt, getDrillDownConfig as dt, getFlattenedDataSeries as pt, resolveDrillDownSubHeader as gt, toStoreFilter as ut } from "./utils.es.js";
12
- import { useTransactionHistory as ft } from "./useTransactionHistory.es.js";
13
- import { getDynamicCtaBasedOnTriggers as ht } from "../util.es.js";
14
- import { TransactionDetailsBlock as yt } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
15
- import { useLayoutEffect as Ct, useState as u } from "react";
16
- import { observer as bt } from "mobx-react-lite";
17
- import { Fragment as Tt, jsx as a, jsxs as _t } from "react/jsx-runtime";
18
- import { useTheme as St } from "@mui/material/styles";
19
- var Vt = bt(({ beat: o }) => {
20
- const f = St(), { instanceSlotData: e, beatTransactions: l, spendCategoryGuids: h, allAccountGuids: y, categoryName: x, displayedDateRange: p, transactionStore: E } = ft(o), { actionDrawer: C, setActionContext: b } = et(), { common: I, insights_feed: c } = Z(), { isCopyLoaded: F } = tt(), [G, T] = u(!1), [R, H] = u(!1), _ = lt(), { insights_payload: n } = o, w = ht(C, n?.primary_cta, n?.secondary_cta, n?.in_description_cta)?.variant, { top: r, filterMode: m, header: O, colors: j, filterStrategy: k, tipSection: S } = dt(w ?? ""), { dataSeries: d, chartData: i, comparisonBars: K } = pt({
1
+ import { useGlobalCopyStore as lt, useGlobalUiStore as ct, useInsightsV2Store as mt } from "../../../common/context/hooks.es.js";
2
+ import { formatCurrency as dt } from "../../../core/utils/NumberFormatting.es.js";
3
+ import ut from "../../../common/components/drawer/Drawer.es.js";
4
+ import gt from "../../../common/components/Loader.es.js";
5
+ import { BAR_ARIA_LABEL as pt } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
6
+ import { BarChartV2 as bt } from "../../components/chartblocks/BarchartV2.es.js";
7
+ import { EmptyBarChart as ft } from "../../components/chartblocks/EmptyBarChart.es.js";
8
+ import { ANALYTICS_EVENTS_CONFIG as k } from "../../analytics/analyticsEventsConfig.es.js";
9
+ import { useAnalyticsEvent as ht } from "../../analytics/useAnalyticsEvent.es.js";
10
+ import { DoubleBarChart as _t } from "../../components/chartblocks/DoubleBarChart.es.js";
11
+ import { toLegendItems as Ct } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
12
+ import { TransactionDrillDown as yt } from "./TransactionDrillDown.es.js";
13
+ import { getDefaultSelection as Tt, getDrillDownConfig as At, getFlattenedDataSeries as St, resolveDrillDownSubHeader as Bt, toStoreFilter as Dt } from "./utils.es.js";
14
+ import { useTransactionHistory as Lt } from "./useTransactionHistory.es.js";
15
+ import { getDynamicCtaBasedOnTriggers as vt } from "../util.es.js";
16
+ import { TransactionDetailsBlock as It } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
17
+ import { useLayoutEffect as xt, useState as p } from "react";
18
+ import { observer as Et } from "mobx-react-lite";
19
+ import { Fragment as Rt, jsx as n, jsxs as Ft } from "react/jsx-runtime";
20
+ import { useTheme as Gt } from "@mui/material/styles";
21
+ var oe = Et(({ beat: r }) => {
22
+ const y = Gt(), { instanceSlotData: e, beatTransactions: m, spendCategoryGuids: T, allAccountGuids: A, categoryName: N, displayedDateRange: b, transactionStore: K } = Lt(r), { actionDrawer: S, setActionContext: B } = mt(), { common: V, insights_feed: i } = lt(), { isCopyLoaded: M } = ct(), [P, D] = p(!1), [U, W] = p(!1), L = ht(), { insights_payload: l } = r, Y = vt(S, l?.primary_cta, l?.secondary_cta, l?.in_description_cta)?.variant, { top: a, filterMode: d, header: $, colors: q, filterStrategy: z, tipSection: v, subTabAriaLabels: J } = At(Y ?? ""), { dataSeries: f, chartData: u, comparisonBars: s } = St({
21
23
  data: e?.data_series,
22
- ariaLabel: rt,
23
- top: r,
24
- beatTransactions: l,
24
+ ariaLabel: a === "doubleBar" ? i?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" : pt,
25
+ top: a,
26
+ beatTransactions: m,
25
27
  payload: e
26
- }), { chartBarIndex: N, subTabIndex: V } = mt({
27
- chartTabCount: i.length,
28
- comparisonTabCount: K.length,
29
- actionDrawer: C,
30
- beatGuid: o.guid
31
- }), [s, D] = u(N), A = (t) => k({
32
- beat: o,
33
- beatTransactions: l,
34
- dataSeries: d,
28
+ }), c = a === "doubleBar", h = c ? s : u, { chartBarIndex: Q, subTabIndex: X } = Tt({
29
+ chartTabCount: u.length,
30
+ comparisonTabCount: s.length,
31
+ actionDrawer: S,
32
+ beatGuid: r.guid
33
+ }), [o, I] = p(Q), [_, x] = p(X), E = (t) => z({
34
+ beat: r,
35
+ beatTransactions: m,
36
+ dataSeries: f,
37
+ comparisonBars: s,
35
38
  selectedIndex: t,
36
- subIndex: V,
37
- isLastTab: t === d.length - 1,
39
+ subIndex: _,
40
+ isLastTab: t === h.length - 1,
38
41
  instanceSlotData: e,
39
- spendCategoryGuids: h,
40
- displayedDateRange: p
41
- }), M = l.map((t) => t.guid).join(","), P = h.join(","), U = y.join(","), W = r === "list" || d.length > 0, v = () => {
42
- m !== "store" || !W || E.setFilter(ut(A(s), {
43
- allAccountGuids: y,
44
- displayedDateRange: p
42
+ spendCategoryGuids: T,
43
+ displayedDateRange: b
44
+ }), Z = m.map((t) => t.guid).join(","), tt = T.join(","), et = A.join(","), ot = a === "list" || f.length > 0, R = () => {
45
+ d !== "store" || !ot || K.setFilter(Dt(E(o), {
46
+ allAccountGuids: A,
47
+ displayedDateRange: b
45
48
  }));
46
49
  };
47
- Ct(() => {
48
- v();
50
+ xt(() => {
51
+ R();
49
52
  }, [
50
- o.guid,
51
- s,
52
- m,
53
- d.length,
53
+ r.guid,
54
+ o,
55
+ _,
56
+ d,
57
+ f.length,
54
58
  e,
55
- p,
56
- P,
57
- U,
58
- M,
59
- r
59
+ b,
60
+ tt,
61
+ et,
62
+ Z,
63
+ a
60
64
  ]);
61
- const L = gt(n), g = O?.({
62
- title: n?.title,
63
- subHeader: L,
64
- categoryName: x,
65
- selectedDate: i[s]?.date ?? void 0
66
- }), Y = j(f, e?.category_guid);
67
- if (!F) return /* @__PURE__ */ a(nt, {});
68
- const $ = [c.general.monthly_amount, c.general.trend], [q, z] = e?.legends?.length ? e.legends.map((t) => t.label) : $, J = m === "local" ? (t) => A(t).custom ?? (() => !0) : void 0, Q = m === "local" ? l : void 0, X = r === "singleBar" || r === "upcomingBill" ? i.length ? /* @__PURE__ */ a(it, {
65
+ const F = Bt(l), C = $?.({
66
+ title: l?.title,
67
+ subHeader: F,
68
+ categoryName: N,
69
+ selectedDate: u[o]?.date ?? void 0
70
+ }), G = q(y, e?.category_guid);
71
+ if (!M) return /* @__PURE__ */ n(gt, {});
72
+ const [O, H] = e?.legends ?? [], at = d === "local" ? (t) => E(t).custom ?? (() => !0) : void 0, nt = d === "local" ? m : void 0, w = (t, g) => {
73
+ L(k.DRAWER_CHART_BAR_CLICKED), I(t), g !== void 0 && x(g);
74
+ }, rt = (t) => {
75
+ L(k.TAB_SELECTED), I(t);
76
+ }, j = c ? Ct([{
77
+ ...O,
78
+ value: s[o]?.main
79
+ }, {
80
+ ...H,
81
+ value: s[o]?.comparison
82
+ }]) : void 0, it = J?.(i) ?? [], st = c || a === "singleBar" || a === "upcomingBill" ? h.length ? c ? /* @__PURE__ */ n(_t, {
83
+ bars: s,
84
+ colors: G,
85
+ legendPosition: "top",
86
+ legends: j,
87
+ onBarClick: w,
88
+ selectedIndex: o
89
+ }) : /* @__PURE__ */ n(bt, {
69
90
  amounts: {
70
91
  average: e?.average_amount,
71
- formattedAverage: ot(e?.average_amount ?? 0, "0,0.00")
92
+ formattedAverage: dt(e?.average_amount ?? 0, "0,0.00")
72
93
  },
73
- color: Y[0] ?? f.palette.primary.main,
74
- data: i,
94
+ color: G[0] ?? y.palette.primary.main,
95
+ data: u,
75
96
  legendPosition: "top",
76
97
  heightOverride: 142,
77
98
  margin: {
@@ -80,44 +101,45 @@ var Vt = bt(({ beat: o }) => {
80
101
  left: 24,
81
102
  right: 24
82
103
  },
83
- monthlyAmountLabel: q,
84
- onBarClick: (t) => {
85
- _(B.DRAWER_CHART_BAR_CLICKED), D(t);
86
- },
87
- selectedTabIndex: s,
88
- trendAmountLabel: z
89
- }) : /* @__PURE__ */ a(st, {}) : null;
90
- return /* @__PURE__ */ _t(Tt, { children: [/* @__PURE__ */ a(ct, {
91
- baseTransactions: Q,
92
- heading: g?.heading,
93
- icon: g?.icon,
94
- onSelectionChange: (t) => {
95
- _(B.TAB_SELECTED), D(t);
96
- },
97
- selectedIndex: s,
98
- subHeadingText: g?.subHeadingText,
99
- tabs: i.map((t) => ({
100
- ariaLabel: t.ariaLabel,
101
- label: t.label
102
- })),
103
- top: X,
104
- ...S && { tipSection: !R && S(H, c, L?.text) },
105
- transactionFilter: J,
104
+ monthlyAmountLabel: O?.label ?? i.general.monthly_amount,
105
+ onBarClick: w,
106
+ selectedTabIndex: o,
107
+ trendAmountLabel: H?.label ?? i.general.trend
108
+ }) : /* @__PURE__ */ n(ft, {}) : null;
109
+ return /* @__PURE__ */ Ft(Rt, { children: [/* @__PURE__ */ n(yt, {
110
+ baseTransactions: nt,
111
+ heading: C?.heading,
112
+ icon: C?.icon,
113
+ onSelectionChange: rt,
114
+ selectedIndex: o,
115
+ subHeadingText: C?.subHeadingText,
116
+ tabs: h,
117
+ top: st,
118
+ ...c && { subTabs: {
119
+ tabs: (j ?? []).map((t, g) => ({
120
+ label: t.label,
121
+ ariaLabel: it[g]
122
+ })),
123
+ selectedIndex: _,
124
+ onChange: x
125
+ } },
126
+ ...v && { tipSection: !U && v(W, i, F?.text) },
127
+ transactionFilter: at,
106
128
  onEachRowClick: (t) => {
107
- b({ transaction_guid: t }), T(!0);
129
+ B({ transaction_guid: t }), D(!0);
108
130
  }
109
- }), /* @__PURE__ */ a(at, {
110
- ariaLabelClose: I.close_aria,
111
- isOpen: G,
131
+ }), /* @__PURE__ */ n(ut, {
132
+ ariaLabelClose: V.close_aria,
133
+ isOpen: P,
112
134
  onClose: () => {
113
- T(!1), b({ transaction_guid: void 0 }), v();
135
+ D(!1), B({ transaction_guid: void 0 }), R();
114
136
  },
115
- title: c.general.transaction_details_title,
116
- children: /* @__PURE__ */ a(yt, { beat: o })
137
+ title: i.general.transaction_details_title,
138
+ children: /* @__PURE__ */ n(It, { beat: r })
117
139
  })] });
118
140
  });
119
141
  export {
120
- Vt as TransactionHistoryBlock
142
+ oe as TransactionHistoryBlock
121
143
  };
122
144
 
123
145
  //# sourceMappingURL=TransactionHistoryBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionHistoryBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.tsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport type { Beat, DataSeries, Transaction } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { BarChartV2 } from '../../components/chartblocks/BarchartV2'\nimport { EmptyBarChart } from '../../components/chartblocks/EmptyBarChart'\nimport { BAR_ARIA_LABEL } from '../../blocks/ChartBlocks/BarchartBlock/utils'\n\nimport { TransactionDrillDown } from './TransactionDrillDown'\nimport { useTransactionHistory } from './useTransactionHistory'\nimport {\n getDefaultSelection,\n getDrillDownConfig,\n getFlattenedDataSeries,\n resolveDrillDownSubHeader,\n toStoreFilter,\n} from './utils'\nimport {\n Drawer,\n useInsightsV2Store,\n useGlobalCopyStore,\n useGlobalUiStore,\n Loader,\n} from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const TransactionHistoryBlock = observer(({ beat }: TransactionHistoryProp) => {\n const theme = useTheme()\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(beat)\n\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n\n const { isCopyLoaded } = useGlobalUiStore()\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const { insights_payload } = beat\n\n const dynamicCtaVariant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )?.variant\n\n const { top, filterMode, header, colors, filterStrategy, tipSection } = getDrillDownConfig(\n dynamicCtaVariant ?? '',\n )\n\n const { dataSeries, chartData, comparisonBars } = getFlattenedDataSeries({\n data: instanceSlotData?.data_series as DataSeries,\n ariaLabel: BAR_ARIA_LABEL,\n top,\n beatTransactions,\n payload: instanceSlotData,\n })\n\n const { chartBarIndex, subTabIndex } = getDefaultSelection({\n chartTabCount: chartData.length,\n comparisonTabCount: comparisonBars.length,\n actionDrawer,\n beatGuid: beat.guid,\n })\n\n const [selectedIndex, setSelectedIndex] = useState(chartBarIndex)\n\n const resolveFilter = (index: number) =>\n filterStrategy({\n beat,\n beatTransactions,\n dataSeries,\n selectedIndex: index,\n subIndex: subTabIndex,\n isLastTab: index === dataSeries.length - 1,\n instanceSlotData,\n spendCategoryGuids,\n displayedDateRange,\n })\n\n // Apply the current selection's filter. Store variants route through the store filter; local\n // (upcomingBill) variants filter beatTransactions directly and only backfill the cache when the\n // Stable primitive keys for the collections below: beatTransactions/spendCategoryGuids/\n // allAccountGuids are recomputed (new array identity) every render, so depending on them directly\n // re-fires the effect each render (REVIEW.md MEW-3732). Key on content instead.\n const beatTransactionGuidsKey = beatTransactions.map((transaction) => transaction.guid).join(',')\n const spendCategoryGuidsKey = spendCategoryGuids.join(',')\n const allAccountGuidsKey = allAccountGuids.join(',')\n\n // Re-applies the current selection's filter to the shared transactionStore. Called both by the\n // effect below (on selection change) and when the nested TransactionDetailsBlock drawer closes:\n // AddMerchantBudgetAction (opened from within that drawer) overwrites transactionStore.filter\n // with a merchant_guid-only filter while its own drawer is open, and never restores it — leaving\n // the row list stuck showing only that one merchant's transactions after backing all the way out.\n // Re-running this on close re-derives the filter fresh instead of relying on whatever the nested\n // drawers left behind.\n // A `list` drawer has no bars: it filters once from the beat alone.\n const canApplyFilter = top === 'list' || dataSeries.length > 0\n const applyCurrentSelectionFilter = () => {\n if (filterMode !== 'store' || !canApplyFilter) return\n transactionStore.setFilter(\n toStoreFilter(resolveFilter(selectedIndex), { allAccountGuids, displayedDateRange }),\n )\n }\n\n // store variants route the selection through the shared store filter; local (upcomingBill) variants\n // filter beatTransactions directly, so there's nothing to push to the store for them.\n useLayoutEffect(() => {\n applyCurrentSelectionFilter()\n }, [\n beat.guid,\n selectedIndex,\n filterMode,\n dataSeries.length,\n instanceSlotData,\n displayedDateRange,\n spendCategoryGuidsKey,\n allAccountGuidsKey,\n beatTransactionGuidsKey,\n top,\n ])\n\n const subHeader = resolveDrillDownSubHeader(insights_payload)\n\n const headerContent = header?.({\n title: insights_payload?.title,\n subHeader,\n categoryName,\n selectedDate: chartData[selectedIndex]?.date ?? undefined,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\n\n if (!isCopyLoaded) return <Loader />\n\n // TODO: Temporary fallback while the backend doesn't always send `legends` on every beat/variant.\n // Remove this once the backend guarantees `legends` on the payload.\n const legendFallbackLabels = [insightsCopy.general.monthly_amount, insightsCopy.general.trend]\n\n const [monthlyAmountLabel, trendAmountLabel] = instanceSlotData?.legends?.length\n ? instanceSlotData.legends.map((legend) => legend.label)\n : legendFallbackLabels\n\n const transactionFilter =\n filterMode === 'local'\n ? (index: number) => resolveFilter(index).custom ?? (() => true)\n : undefined\n\n const baseTransactions: Transaction[] | undefined =\n filterMode === 'local' ? beatTransactions : undefined\n\n const isBarTop = top === 'singleBar' || top === 'upcomingBill'\n const chartTop = !isBarTop ? null : chartData.length ? (\n <BarChartV2\n amounts={{\n average: instanceSlotData?.average_amount,\n formattedAverage: formatCurrency(instanceSlotData?.average_amount ?? 0, '0,0.00'),\n }}\n color={barColors[0] ?? theme.palette.primary.main}\n data={chartData}\n legendPosition=\"top\"\n heightOverride={142}\n margin={{\n bottom: 8,\n top: 24,\n left: 24,\n right: 24,\n }}\n monthlyAmountLabel={monthlyAmountLabel}\n onBarClick={(index) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.DRAWER_CHART_BAR_CLICKED)\n setSelectedIndex(index)\n }}\n selectedTabIndex={selectedIndex}\n trendAmountLabel={trendAmountLabel}\n />\n ) : (\n <EmptyBarChart />\n )\n\n return (\n <>\n <TransactionDrillDown\n baseTransactions={baseTransactions}\n heading={headerContent?.heading}\n icon={headerContent?.icon}\n onSelectionChange={(index) => {\n // MUI Tabs only fires onChange on real user selection, not on mount.\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.TAB_SELECTED)\n setSelectedIndex(index)\n }}\n selectedIndex={selectedIndex}\n subHeadingText={headerContent?.subHeadingText}\n tabs={chartData.map((bar) => ({\n ariaLabel: bar.ariaLabel,\n label: bar.label,\n }))}\n top={chartTop}\n {...(tipSection && {\n tipSection:\n !closeTipSection && tipSection(setCloseTipSection, insightsCopy, subHeader?.text),\n })}\n transactionFilter={transactionFilter}\n onEachRowClick={(guid) => {\n setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns — setActionContext merges, so an\n // explicit `{}` would be a no-op and leave transaction_guid stuck in the shared\n // context, and the outer drawer's own context (e.g. chartBarIndex) must survive.\n setActionContext({ transaction_guid: undefined })\n // Re-apply this block's own filter: a further-nested AddMerchantBudgetAction drawer may\n // have overwritten transactionStore.filter (merchant_guid-only) without restoring it.\n applyCurrentSelectionFilter()\n }}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,IAAa,KAA0B,GAAA,CAAU,EAAE,MAAA,EAAA,MAAmC;AACpF,QAAM,IAAQ,GAAS,GACjB,EACJ,kBAAA,GACA,kBAAA,GACA,oBAAA,GACA,iBAAA,GACA,cAAA,GACA,oBAAA,GACA,kBAAA,EAAA,IACE,GAAsB,CAAI,GAExB,EAAE,cAAA,GAAc,kBAAA,EAAA,IAAqB,GAAmB,GAExD,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAiB,EAAmB,GAEzE,EAAE,cAAA,EAAA,IAAiB,GAAiB,GAEpC,CAAC,GAA0B,CAAA,IAA+B,EAAS,EAAK,GAExE,CAAC,GAAiB,CAAA,IAAsB,EAAS,EAAK,GAEtD,IAAqB,GAAkB,GAEvC,EAAE,kBAAA,EAAA,IAAqB,GAEvB,IAAoB,GACxB,GACA,GAAkB,aAClB,GAAkB,eAClB,GAAkB,kBACpB,GAAG,SAEG,EAAE,KAAA,GAAK,YAAA,GAAY,QAAA,GAAQ,QAAA,GAAQ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,GAAe;AAAA,IACxB,MAAM,GAAe;AAAA,IACrB,mBAAA,CAAoB,MAAU;AAE5B,MAAA,EAAmB,EAAwB,YAAY,GACvD,EAAiB,CAAK;AAAA,IACxB;AAAA,IACe,eAAA;AAAA,IACf,gBAAgB,GAAe;AAAA,IAC/B,MAAM,EAAU,IAAA,CAAK,OAAS;AAAA,MAC5B,WAAW,EAAI;AAAA,MACf,OAAO,EAAI;AAAA,IACb,EAAE;AAAA,IACF,KAAK;AAAA,IACL,GAAK,KAAc,EACjB,YACE,CAAC,KAAmB,EAAW,GAAoB,GAAc,GAAW,IAAI,EACpF;AAAA,IACmB,mBAAA;AAAA,IACnB,gBAAA,CAAiB,MAAS;AACxB,MAAA,EAAiB,EAAE,kBAAkB,EAAK,CAAC,GAC3C,EAA4B,EAAI;AAAA,IAClC;AAAA,EACD,CAAA,GACD,gBAAA,EAAC,IAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAA,MAAe;AACb,MAAA,EAA4B,EAAK,GAIjC,EAAiB,EAAE,kBAAkB,OAAU,CAAC,GAGhD,EAA4B;AAAA,IAC9B;AAAA,IACA,OAAO,EAAa,QAAQ;AAAA,IAE5B,UAAA,gBAAA,EAAC,IAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,EAChC,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
1
+ {"version":3,"file":"TransactionHistoryBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.tsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport type { Beat, DataSeries, Transaction } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { BarChartV2 } from '../../components/chartblocks/BarchartV2'\nimport { DoubleBarChart } from '../../components/chartblocks/DoubleBarChart'\nimport { EmptyBarChart } from '../../components/chartblocks/EmptyBarChart'\nimport { BAR_ARIA_LABEL } from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport {\n COMPARISON_BAR_ARIA_LABEL,\n toLegendItems,\n} from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\n\nimport { TransactionDrillDown } from './TransactionDrillDown'\nimport { useTransactionHistory } from './useTransactionHistory'\nimport {\n getDefaultSelection,\n getDrillDownConfig,\n getFlattenedDataSeries,\n resolveDrillDownSubHeader,\n toStoreFilter,\n} from './utils'\nimport {\n Drawer,\n useInsightsV2Store,\n useGlobalCopyStore,\n useGlobalUiStore,\n Loader,\n} from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const TransactionHistoryBlock = observer(({ beat }: TransactionHistoryProp) => {\n const theme = useTheme()\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(beat)\n\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n\n const { isCopyLoaded } = useGlobalUiStore()\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const { insights_payload } = beat\n\n const dynamicCtaVariant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )?.variant\n\n const { top, filterMode, header, colors, filterStrategy, tipSection, subTabAriaLabels } =\n getDrillDownConfig(dynamicCtaVariant ?? '')\n\n // `getFlattenedDataSeries` runs ahead of the copy-loaded guard below, hence the literal fallback.\n const { dataSeries, chartData, comparisonBars } = getFlattenedDataSeries({\n data: instanceSlotData?.data_series as DataSeries,\n ariaLabel:\n top === 'doubleBar'\n ? (insightsCopy?.general?.in_month_you_had_a_category_of_amount ??\n COMPARISON_BAR_ARIA_LABEL)\n : BAR_ARIA_LABEL,\n top,\n beatTransactions,\n payload: instanceSlotData,\n })\n\n const isDoubleBar = top === 'doubleBar'\n // The drawer's columns (and tabs): the double bar's month pairs, or the single bar's bars.\n const bars = isDoubleBar ? comparisonBars : chartData\n\n const { chartBarIndex, subTabIndex } = getDefaultSelection({\n chartTabCount: chartData.length,\n comparisonTabCount: comparisonBars.length,\n actionDrawer,\n beatGuid: beat.guid,\n })\n\n const [selectedIndex, setSelectedIndex] = useState(chartBarIndex)\n // The double-bar drawer's series tab (0 = main, e.g. Spend; 1 = comparison, e.g. Income).\n const [subIndex, setSubIndex] = useState(subTabIndex)\n\n const resolveFilter = (index: number) =>\n filterStrategy({\n beat,\n beatTransactions,\n dataSeries,\n comparisonBars,\n selectedIndex: index,\n subIndex,\n isLastTab: index === bars.length - 1,\n instanceSlotData,\n spendCategoryGuids,\n displayedDateRange,\n })\n\n // Apply the current selection's filter. Store variants route through the store filter; local\n // (upcomingBill) variants filter beatTransactions directly and only backfill the cache when the\n // Stable primitive keys for the collections below: beatTransactions/spendCategoryGuids/\n // allAccountGuids are recomputed (new array identity) every render, so depending on them directly\n // re-fires the effect each render (REVIEW.md MEW-3732). Key on content instead.\n const beatTransactionGuidsKey = beatTransactions.map((transaction) => transaction.guid).join(',')\n const spendCategoryGuidsKey = spendCategoryGuids.join(',')\n const allAccountGuidsKey = allAccountGuids.join(',')\n\n // Re-applies the current selection's filter to the shared transactionStore. Called both by the\n // effect below (on selection change) and when the nested TransactionDetailsBlock drawer closes:\n // AddMerchantBudgetAction (opened from within that drawer) overwrites transactionStore.filter\n // with a merchant_guid-only filter while its own drawer is open, and never restores it — leaving\n // the row list stuck showing only that one merchant's transactions after backing all the way out.\n // Re-running this on close re-derives the filter fresh instead of relying on whatever the nested\n // drawers left behind.\n // A `list` drawer has no bars: it filters once from the beat alone.\n const canApplyFilter = top === 'list' || dataSeries.length > 0\n const applyCurrentSelectionFilter = () => {\n if (filterMode !== 'store' || !canApplyFilter) return\n transactionStore.setFilter(\n toStoreFilter(resolveFilter(selectedIndex), { allAccountGuids, displayedDateRange }),\n )\n }\n\n // store variants route the selection through the shared store filter; local (upcomingBill) variants\n // filter beatTransactions directly, so there's nothing to push to the store for them.\n useLayoutEffect(() => {\n applyCurrentSelectionFilter()\n }, [\n beat.guid,\n selectedIndex,\n subIndex,\n filterMode,\n dataSeries.length,\n instanceSlotData,\n displayedDateRange,\n spendCategoryGuidsKey,\n allAccountGuidsKey,\n beatTransactionGuidsKey,\n top,\n ])\n\n const subHeader = resolveDrillDownSubHeader(insights_payload)\n\n const headerContent = header?.({\n title: insights_payload?.title,\n subHeader,\n categoryName,\n selectedDate: chartData[selectedIndex]?.date ?? undefined,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\n\n if (!isCopyLoaded) return <Loader />\n\n // `legends` is the block's additional_data ([0] main, [1] second series), as BarchartBlock reads it.\n const [mainLegend, comparisonLegend] = instanceSlotData?.legends ?? []\n\n const transactionFilter =\n filterMode === 'local'\n ? (index: number) => resolveFilter(index).custom ?? (() => true)\n : undefined\n\n const baseTransactions: Transaction[] | undefined =\n filterMode === 'local' ? beatTransactions : undefined\n\n // A chart bar click selects its column (and, on the double bar, its series); a month tab change\n // selects the month. MUI Tabs only fires onChange on real user selection, not on mount. The\n // series (Spend / Income) tab fires its own analytics via the shared SubTabs component.\n const selectBar = (index: number, seriesIndex?: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.DRAWER_CHART_BAR_CLICKED)\n setSelectedIndex(index)\n if (seriesIndex !== undefined) setSubIndex(seriesIndex)\n }\n const selectMonth = (index: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.TAB_SELECTED)\n setSelectedIndex(index)\n }\n\n // Double bar: the Spend / Income labels come from copy (additional_data); the legend carries the\n // selected month's two totals, and its labels name the series tabs.\n const doubleBarLegends = isDoubleBar\n ? toLegendItems([\n { ...mainLegend, value: comparisonBars[selectedIndex]?.main },\n { ...comparisonLegend, value: comparisonBars[selectedIndex]?.comparison },\n ])\n : undefined\n\n // Legacy pulse named these tabs \"Spend transactions\" / \"Income transactions\" for screen readers.\n const seriesAriaLabels = subTabAriaLabels?.(insightsCopy) ?? []\n\n const renderChart = () => {\n if (!bars.length) return <EmptyBarChart />\n\n return isDoubleBar ? (\n <DoubleBarChart\n bars={comparisonBars}\n colors={barColors}\n legendPosition=\"top\"\n legends={doubleBarLegends}\n onBarClick={selectBar}\n selectedIndex={selectedIndex}\n />\n ) : (\n <BarChartV2\n amounts={{\n average: instanceSlotData?.average_amount,\n formattedAverage: formatCurrency(instanceSlotData?.average_amount ?? 0, '0,0.00'),\n }}\n color={barColors[0] ?? theme.palette.primary.main}\n data={chartData}\n legendPosition=\"top\"\n heightOverride={142}\n margin={{\n bottom: 8,\n top: 24,\n left: 24,\n right: 24,\n }}\n // TODO: Temporary fallback while the backend doesn't always send `legends` on every\n // beat/variant. Remove this once the backend guarantees `legends` on the payload.\n monthlyAmountLabel={mainLegend?.label ?? insightsCopy.general.monthly_amount}\n onBarClick={selectBar}\n selectedTabIndex={selectedIndex}\n trendAmountLabel={comparisonLegend?.label ?? insightsCopy.general.trend}\n />\n )\n }\n\n // `list` drawers (e.g. Low Account Balance) have no chart above their transaction list.\n const chartTop =\n isDoubleBar || top === 'singleBar' || top === 'upcomingBill' ? renderChart() : null\n\n return (\n <>\n <TransactionDrillDown\n baseTransactions={baseTransactions}\n heading={headerContent?.heading}\n icon={headerContent?.icon}\n onSelectionChange={selectMonth}\n selectedIndex={selectedIndex}\n subHeadingText={headerContent?.subHeadingText}\n tabs={bars}\n top={chartTop}\n {...(isDoubleBar && {\n subTabs: {\n tabs: (doubleBarLegends ?? []).map((legend, index) => ({\n label: legend.label,\n ariaLabel: seriesAriaLabels[index],\n })),\n selectedIndex: subIndex,\n onChange: setSubIndex,\n },\n })}\n {...(tipSection && {\n tipSection:\n !closeTipSection && tipSection(setCloseTipSection, insightsCopy, subHeader?.text),\n })}\n transactionFilter={transactionFilter}\n onEachRowClick={(guid) => {\n setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns — setActionContext merges, so an\n // explicit `{}` would be a no-op and leave transaction_guid stuck in the shared\n // context, and the outer drawer's own context (e.g. chartBarIndex) must survive.\n setActionContext({ transaction_guid: undefined })\n // Re-apply this block's own filter: a further-nested AddMerchantBudgetAction drawer may\n // have overwritten transactionStore.filter (merchant_guid-only) without restoring it.\n applyCurrentSelectionFilter()\n }}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,KAA0B,GAAA,CAAU,EAAE,MAAA,EAAA,MAAmC;AACpF,QAAM,IAAQ,GAAS,GACjB,EACJ,kBAAA,GACA,kBAAA,GACA,oBAAA,GACA,iBAAA,GACA,cAAA,GACA,oBAAA,GACA,kBAAA,EAAA,IACE,GAAsB,CAAI,GAExB,EAAE,cAAA,GAAc,kBAAA,EAAA,IAAqB,GAAmB,GAExD,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAiB,GAAmB,GAEzE,EAAE,cAAA,EAAA,IAAiB,GAAiB,GAEpC,CAAC,GAA0B,CAAA,IAA+B,EAAS,EAAK,GAExE,CAAC,GAAiB,CAAA,IAAsB,EAAS,EAAK,GAEtD,IAAqB,GAAkB,GAEvC,EAAE,kBAAA,EAAA,IAAqB,GAEvB,IAAoB,GACxB,GACA,GAAkB,aAClB,GAAkB,eAClB,GAAkB,kBACpB,GAAG,SAEG,E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,CAAC,GAC3C,EAA4B,EAAI;AAAA,IAClC;AAAA,EACD,CAAA,GACD,gBAAA,EAAC,IAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAA,MAAe;AACb,MAAA,EAA4B,EAAK,GAIjC,EAAiB,EAAE,kBAAkB,OAAU,CAAC,GAGhD,EAA4B;AAAA,IAC9B;AAAA,IACA,OAAO,EAAa,QAAQ;AAAA,IAE5B,UAAA,gBAAA,EAAC,IAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,EAChC,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { Theme } from '@mui/material/styles';
3
3
  import { Beat, InsightsFeedCopy, Subtitle, Transaction } from '../../../core';
4
4
  import { TransactionFilter } from '../../../core/stores/TransactionStore';
5
- import { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
5
+ import { DataSet, InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
6
6
  import { ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils';
7
7
  import { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection';
8
8
  export interface DrillDownHeader {
@@ -47,6 +47,7 @@ export interface FilterContext {
47
47
  beat: Beat;
48
48
  beatTransactions: Transaction[];
49
49
  dataSeries: ChartDataSeriesItem[];
50
+ comparisonBars: DataSet[];
50
51
  selectedIndex: number;
51
52
  subIndex: number;
52
53
  isLastTab: boolean;
@@ -66,6 +67,7 @@ export interface DrillDownVariantConfig {
66
67
  tipSection?: (setCloseTipSection: (flag: boolean) => void, copy: InsightsFeedCopy, merchantName?: string) => TipSectionProps;
67
68
  scope: 'store' | 'beat';
68
69
  filterMode: 'store' | 'local';
70
+ subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[];
69
71
  }
70
72
  export declare const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>>;
71
73
  export declare const FALLBACK: DrillDownVariantConfig;
@@ -1,12 +1,13 @@
1
- import { buildDynamicCopy as p } from "../../../core/utils/Localization.es.js";
2
- import { DATE_FORMATS_INTL as y, formatDate as N } from "../../../core/constants/DateFormats.es.js";
3
- import { fromUnixUTC as d } from "../../../core/utils/DateUtil.es.js";
4
- import { getCategoryColor as f } from "../../../core/utils/CategoryUtil.es.js";
5
- import { MerchantLogo as S } from "@mxenabled/mxui";
6
- import { Icon as O } from "@mxenabled/mx-icons";
1
+ import { buildDynamicCopy as N } from "../../../core/utils/Localization.es.js";
2
+ import { DATE_FORMATS_INTL as f, formatDate as S } from "../../../core/constants/DateFormats.es.js";
3
+ import { fromUnixUTC as u } from "../../../core/utils/DateUtil.es.js";
4
+ import { getCategoryColor as O } from "../../../core/utils/CategoryUtil.es.js";
5
+ import { getLayoutConfig as C } from "../../blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js";
6
+ import { MerchantLogo as T } from "@mxenabled/mxui";
7
+ import { Icon as A } from "@mxenabled/mx-icons";
7
8
  import { jsx as c } from "react/jsx-runtime";
8
- import { endOfMonth as A, startOfMonth as C } from "date-fns";
9
- var s = {
9
+ import { endOfMonth as p, isValid as h, parseISO as I, startOfMonth as y } from "date-fns";
10
+ var i = {
10
11
  TRANSACTION: "not_standard_amount",
11
12
  CATEGORY_SPEND: "category_spend",
12
13
  MONTHLY_SPEND: "monthly_spend_comparison",
@@ -19,10 +20,10 @@ var s = {
19
20
  NON_ESSENTIAL_CATEGORY: "non_essential_category_summary",
20
21
  DEPOSIT_SUMMARY: "monthly_deposit_summary",
21
22
  LOW_BALANCE: "low_balance"
22
- }, l = (e, t) => t && f(t, e) || e.palette.primary.main, _ = (e) => ({
23
- start: C(new Date(e ?? NaN)),
24
- end: A(new Date(e ?? NaN))
25
- }), m = (e) => e?.length ? { accounts: e } : {}, T = ({ beat: e }) => {
23
+ }, l = (e, t) => t && O(t, e) || e.palette.primary.main, _ = (e) => ({
24
+ start: y(new Date(e ?? NaN)),
25
+ end: p(new Date(e ?? NaN))
26
+ }), m = (e) => e?.length ? { accounts: e } : {}, L = ({ beat: e }) => {
26
27
  const { account_guid: t, from_date: o, to_date: r } = e.insights_payload?.drilldown_data ?? {};
27
28
  return typeof t != "string" || typeof o != "number" || typeof r != "number" || !Number.isFinite(o) || !Number.isFinite(r) || r <= o ? {
28
29
  accounts: [],
@@ -30,41 +31,54 @@ var s = {
30
31
  } : {
31
32
  accounts: [t],
32
33
  dateRange: {
33
- start: d(o),
34
- end: d(r - 1)
34
+ start: u(o),
35
+ end: u(r - 1)
35
36
  }
36
37
  };
37
38
  }, g = ({ beatTransactions: e, dataSeries: t, selectedIndex: o }) => {
38
- const r = t[o], a = r?.guid, n = e.find((i) => i.guid === a)?.has_been_split;
39
+ const r = t[o], a = r?.guid, s = e.find((n) => n.guid === a)?.has_been_split;
39
40
  return {
40
- custom: (i) => i.guid === a,
41
+ custom: (n) => n.guid === a,
41
42
  dateRange: _(r?.date),
42
- showSplits: !n
43
+ showSplits: !s
43
44
  };
44
- }, h = ({ dataSeries: e, selectedIndex: t, instanceSlotData: o }) => {
45
+ }, M = ({ dataSeries: e, selectedIndex: t, instanceSlotData: o }) => {
45
46
  const r = e[t], a = o.category_guid ?? r?.guid;
46
47
  return {
47
- custom: (n) => n.category_guid === a || n.top_level_category_guid === a,
48
+ custom: (s) => s.category_guid === a || s.top_level_category_guid === a,
48
49
  dateRange: _(r?.date)
49
50
  };
50
- }, I = ({ dataSeries: e, selectedIndex: t, spendCategoryGuids: o, instanceSlotData: r }) => {
51
+ }, E = ({ dataSeries: e, selectedIndex: t, spendCategoryGuids: o, instanceSlotData: r }) => {
51
52
  const a = e[t];
52
53
  return {
53
- custom: (n) => !!n.top_level_category_guid && o.includes(n.top_level_category_guid),
54
+ custom: (s) => !!s.top_level_category_guid && o.includes(s.top_level_category_guid),
54
55
  dateRange: _(a?.date),
55
56
  ...m(r.account_guids)
56
57
  };
57
- }, L = ({ beat: e, dataSeries: t, selectedIndex: o, isLastTab: r, instanceSlotData: a }) => {
58
- const n = t[o], { start: i, end: u } = _(n?.date);
58
+ }, D = ({ beat: e, dataSeries: t, selectedIndex: o, isLastTab: r, instanceSlotData: a }) => {
59
+ const s = t[o], { start: n, end: d } = _(s?.date);
59
60
  return {
60
61
  dateRange: {
61
- start: i,
62
- end: r && e.created_at ? new Date(e.created_at) : u
62
+ start: n,
63
+ end: r && e.created_at ? new Date(e.created_at) : d
63
64
  },
64
65
  ...m(a.account_guids)
65
66
  };
66
- }, P = {
67
- [s.TRANSACTION]: {
67
+ }, b = ({ beat: e, comparisonBars: t, selectedIndex: o, subIndex: r }) => {
68
+ const a = t[o], s = new Set(r === 1 ? a?.comparisonGuids : a?.mainGuids), n = I(a?.date ?? "");
69
+ return !s.size || !h(n) ? {
70
+ accounts: [],
71
+ custom: () => !1
72
+ } : {
73
+ custom: (d) => s.has(d.guid),
74
+ dateRange: {
75
+ start: y(n),
76
+ end: p(n)
77
+ },
78
+ ...m(e.account_guids)
79
+ };
80
+ }, x = {
81
+ [i.TRANSACTION]: {
68
82
  top: "singleBar",
69
83
  scope: "store",
70
84
  filterMode: "store",
@@ -75,7 +89,7 @@ var s = {
75
89
  return {
76
90
  heading: t,
77
91
  subHeadingText: o?.text || void 0,
78
- icon: /* @__PURE__ */ c(S, {
92
+ icon: /* @__PURE__ */ c(T, {
79
93
  alt: o?.text,
80
94
  categoryGuid: o?.logo?.category_guid || "",
81
95
  merchantGuid: o?.logo?.merchant_guid || "",
@@ -84,54 +98,62 @@ var s = {
84
98
  };
85
99
  },
86
100
  tipSection: (e, t, o = "") => ({
87
- message: p(t.general.tip_section_message, /* @__PURE__ */ c("strong", { children: t.general.tip_section_title }), /* @__PURE__ */ c("strong", { children: o })),
101
+ message: N(t.general.tip_section_message, /* @__PURE__ */ c("strong", { children: t.general.tip_section_title }), /* @__PURE__ */ c("strong", { children: o })),
88
102
  onDismiss: () => e(!0)
89
103
  })
90
104
  },
91
- [s.CATEGORY_SPEND]: {
105
+ [i.CATEGORY_SPEND]: {
92
106
  top: "singleBar",
93
- filterStrategy: h,
107
+ filterStrategy: M,
94
108
  scope: "store",
95
109
  filterMode: "store",
96
110
  colors: (e, t) => [l(e, t)],
97
111
  header: (e) => ({
98
112
  heading: e.categoryName,
99
- subHeadingText: e.selectedDate && N(e.selectedDate, y.MONTH_LONG) || "",
100
- icon: /* @__PURE__ */ c(O, {
113
+ subHeadingText: e.selectedDate && S(e.selectedDate, f.MONTH_LONG) || "",
114
+ icon: /* @__PURE__ */ c(A, {
101
115
  name: "calendar_month",
102
116
  size: 16
103
117
  })
104
118
  })
105
119
  },
106
- [s.MONTHLY_SPEND]: {
120
+ [i.MONTHLY_SPEND]: {
107
121
  top: "singleBar",
108
- filterStrategy: I,
122
+ filterStrategy: E,
109
123
  scope: "store",
110
124
  filterMode: "store",
111
125
  colors: (e) => [e.palette.chart.chart2 ?? e.palette.primary.main]
112
126
  },
113
- [s.ACCOUNT_BALANCE]: {
127
+ [i.ACCOUNT_BALANCE]: {
114
128
  top: "singleBar",
115
- filterStrategy: L,
129
+ filterStrategy: D,
116
130
  scope: "store",
117
131
  filterMode: "store",
118
132
  colors: (e) => [e.palette.success.main]
119
133
  },
120
- [s.UPCOMING_BILL]: {
134
+ [i.UPCOMING_BILL]: {
121
135
  top: "upcomingBill",
122
136
  filterStrategy: g,
123
137
  scope: "beat",
124
138
  filterMode: "local",
125
139
  colors: (e, t) => [l(e, t)]
126
140
  },
127
- [s.LOW_BALANCE]: {
141
+ [i.LOW_BALANCE]: {
128
142
  top: "list",
129
- filterStrategy: T,
143
+ filterStrategy: L,
130
144
  scope: "store",
131
145
  filterMode: "store",
132
146
  colors: (e) => [e.palette.primary.main]
147
+ },
148
+ [i.SPEND_TO_INCOME]: {
149
+ top: "doubleBar",
150
+ filterStrategy: b,
151
+ scope: "store",
152
+ filterMode: "store",
153
+ colors: (e) => C(e, "spend_to_income")?.color ?? [],
154
+ subTabAriaLabels: (e) => [e.general.spend_transactions, e.general.income_transactions]
133
155
  }
134
- }, w = {
156
+ }, F = {
135
157
  top: "singleBar",
136
158
  filterStrategy: g,
137
159
  scope: "store",
@@ -139,9 +161,9 @@ var s = {
139
161
  colors: (e, t) => [l(e, t)]
140
162
  };
141
163
  export {
142
- s as DRILLDOWN_VARIANTS,
143
- w as FALLBACK,
144
- P as layout
164
+ i as DRILLDOWN_VARIANTS,
165
+ F as FALLBACK,
166
+ x as layout
145
167
  };
146
168
 
147
169
  //# sourceMappingURL=layout.es.js.map