@mx-cartographer/experiences 9.7.116 → 9.7.118

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 (72) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/common/components/drawer/Drawer.d.ts +3 -0
  3. package/dist/common/components/drawer/Drawer.es.js +30 -29
  4. package/dist/common/components/drawer/Drawer.es.js.map +1 -1
  5. package/dist/common/components/drawer/Header.d.ts +3 -0
  6. package/dist/common/components/drawer/Header.es.js +51 -45
  7. package/dist/common/components/drawer/Header.es.js.map +1 -1
  8. package/dist/core/stores/InsightsV2Store.d.ts +10 -0
  9. package/dist/core/stores/InsightsV2Store.es.js +15 -7
  10. package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
  11. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +44 -33
  12. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +1 -9
  14. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +96 -83
  15. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
  16. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.d.ts +5 -0
  17. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +62 -0
  18. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -0
  19. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
  20. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +212 -145
  21. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
  22. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.d.ts +3 -1
  23. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +36 -36
  24. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
  25. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +32 -2
  26. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +68 -22
  27. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  28. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.d.ts +3 -0
  29. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js +34 -0
  30. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js.map +1 -0
  31. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +81 -78
  32. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  33. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +11 -8
  34. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +116 -91
  35. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  36. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +3 -3
  37. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +2 -0
  38. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  39. package/dist/insights-v2/actionBlocks/util.d.ts +2 -11
  40. package/dist/insights-v2/actionBlocks/util.es.js +16 -6
  41. package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
  42. package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +16 -0
  43. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +19 -2
  44. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
  45. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +8 -8
  46. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
  47. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +1 -1
  48. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +28 -27
  49. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
  50. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.d.ts +1 -7
  51. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +8 -10
  52. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
  53. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.d.ts +13 -17
  54. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js +16 -11
  55. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js.map +1 -1
  56. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.d.ts +6 -2
  57. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js +7 -6
  58. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js.map +1 -1
  59. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +14 -14
  60. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js +4 -4
  61. package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js +1 -1
  62. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +4 -4
  63. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +4 -4
  64. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +4 -4
  65. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +10 -10
  66. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +4 -4
  67. package/dist/insights-v2/components/BaseLayout.es.js +137 -118
  68. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  69. package/dist/insights-v2/mappings/blocks.d.ts +1 -0
  70. package/dist/insights-v2/mappings/blocks.es.js +131 -121
  71. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  72. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills plus the\n // projected bill its `beatTransactions` resolver appends).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per month of paid bills plus the projected bill,\n // each named by its month (buildChartData's default MONTH_SHORT) as the design labels it. A\n // projected bill sharing the latest paid month keeps its own day label.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab lists only its Projected amount row.\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * Splits a drawer's transactions into the real ones and the synthesized projected bill, which a\n * `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other\n * variant has no projected bill, so its transactions pass through untouched.\n */\nexport const splitProjectedTransaction = (\n transactions: Transaction[],\n): { transactions: Transaction[]; projectedTransaction?: Transaction } => {\n const last = transactions[transactions.length - 1]\n if (last?.guid !== PROJECTED_BILL_GUID) return { transactions }\n\n return { transactions: transactions.slice(0, -1), projectedTransaction: last }\n}\n\n/**\n * UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid\n * bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and\n * de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps\n * the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),\n * no bars. Bars are named by month; when two share a month, every bar is named by its day so no two\n * tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const { transactions: paidBills, projectedTransaction } = splitProjectedTransaction(transactions)\n if (!projectedTransaction || !paidBills.length) return []\n\n const sorted = [...paidBills].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const bars = [...history, toUpcomingBillBar(projectedTransaction)]\n\n const months = bars.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return bars\n\n return bars.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\n/**\n * The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under\n * \"Projected amount\": the latest paid bill's merchant and category with the due date and projected\n * amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the\n * inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.\n */\nexport const buildProjectedBillTransaction = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): Transaction | undefined => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) return undefined\n\n const latestBill = transactions.reduce((latest, t) => (t.date > latest.date ? t : latest))\n\n return {\n ...latestBill,\n guid: PROJECTED_BILL_GUID,\n amount: payload.amount,\n date: utcDayToUnix(payload.date),\n has_been_split: false,\n is_hidden: false,\n is_flagged: false,\n parent_guid: null,\n }\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block\n const key = `${variant}_drawer_title` as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n comparisonTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n // A double-bar drawer's tabs are its comparison columns; every other drawer's are its chart bars.\n const tabCount = comparisonTabCount || chartTabCount\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(Math.max(context?.chartBarIndex ?? 0, 0), Math.max(0, tabCount - 1))\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, tabCount - 1), subTabIndex }\n}\n\n/**\n * The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a\n * variant's tip names.\n */\nexport type DrillDownSlotData = InsightsInstanceSlotData &\n Pick<BarChartBlockData, 'average_amount'> & { merchant_name?: string }\n\n// A YYYY-MM-DD day as the epoch seconds of its UTC midnight: the day a transaction row is dated on\n// (fromUnixUTCToDayOfWeekAndDate), so a synthesized row agrees with the bars in every zone.\nexport const utcDayToUnix = (day: string): number => Date.parse(`${day}T00:00:00Z`) / 1000\n\n// Narrowing for drilldown_data's untyped values: each returns the value when it has the right shape,\n// else undefined, so a reader drops a missing or mistyped fact.\nexport const finiteNumberOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nexport const nonEmptyStringOf = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\nexport const guidListOf = (value: unknown): string[] | undefined =>\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => typeof item === 'string' && item !== '')\n ? (value as string[])\n : undefined\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/** Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload. */\nexport type SlotDataResolver = (payload: Partial<InsightsPayload> | undefined) => DrillDownSlotData\n\n/**\n * Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and\n * its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.\n */\nexport type BeatTransactionsResolver = (\n transactions: Transaction[],\n slotData: DrillDownSlotData,\n) => Transaction[]\n\n/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;;;AAyCA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAwB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,EAAA,MACmD;AAInD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,CAAgB;AAI3D,WAAO;AAAA,MAAE,YAAA;AAAA,MAAY,WAHH,EAAe,GAAY,CAAS,EAAE,IAAA,CAAK,GAAK,MAChE,EAAW,CAAA,EAAO,QAAQ;AAAA,QAAE,GAAG;AAAA,QAAK,OAAO,EAAW,CAAA,EAAO;AAAA,MAAM,IAAI,CAEpD;AAAA,MAAW,gBAAgB,CAAC;AAAA,IAAE;AAAA,EACrD;AAIA,MAAI,MAAQ,WACV,QAAO;AAAA,IACL,YAAY,EAAgB,CAAI,EAAE,OAAA,CAAQ,MAAQ,EAAI,eAAe;AAAA,IACrE,WAAW,CAAC;AAAA,IACZ,gBAAgB,CAAC;AAAA,EACnB;AAIF,MAAI,MAAQ,OACV,QAAO;AAAA,IAAE,YAAY,CAAC;AAAA,IAAG,WAAW,CAAC;AAAA,IAAG,gBAAgB,CAAC;AAAA,EAAE;AAM7D,QAAM,IAAa,CAAC,GAAG,EAAgB,CAAI,CAAC,EAAE,KAAA,CAAM,GAAG,MACjD,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D;AAED,UAAQ,GAAR;AAAA,IAEE,KAAK;AACH,aAAO;AAAA,QAAE,YAAA;AAAA,QAAY,WAAW,CAAC;AAAA,QAAG,gBAAgB,EAAsB,GAAM,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I,GAAG,IAAW,CAAC,CACnE;AAAA,IAAS,aAAA;AAAA,EAAY,IAGxC;AAAA,IAAE,eAAe,KAAK,IAAI,GAAG,IAAW,CAAC;AAAA,IAAG,aAAA;AAAA,EAAY;AACjE,GAWa,IAAA,CAAgB,MAAwB,KAAK,MAAM,GAAG,CAAA,YAAe,IAAI,KAIzE,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,IAAI,IAAQ,QAEnD,IAAA,CAAoB,MAC/B,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,KAAK,IAAQ,QAEhD,IAAA,CAAc,MACzB,MAAM,QAAQ,CAAK,KACnB,EAAM,SAAS,KACf,EAAM,MAAA,CAAO,MAAS,OAAO,KAAS,YAAY,MAAS,EAAE,IACxD,IACD,QAGO,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,sBAAsB,KAAK,CAAK,KAAK,EAAQ,EAAS,CAAK,CAAC,IACrF,IACA,QAeO,IAAA,CAAuB,EAClC,QAAA,GACA,eAAA,GACA,gBAAA,GACA,iBAAA,EAAA,MAC0C;AAC1C,QAAM,IAAmB,EAAgB,CAAM,EAC5C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
1
+ {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills plus the\n // projected bill its `beatTransactions` resolver appends).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per month of paid bills plus the projected bill,\n // each named by its month (buildChartData's default MONTH_SHORT) as the design labels it. A\n // projected bill sharing the latest paid month keeps its own day label.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab lists only its Projected amount row.\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * Splits a drawer's transactions into the real ones and the synthesized projected bill, which a\n * `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other\n * variant has no projected bill, so its transactions pass through untouched.\n */\nexport const splitProjectedTransaction = (\n transactions: Transaction[],\n): { transactions: Transaction[]; projectedTransaction?: Transaction } => {\n const last = transactions[transactions.length - 1]\n if (last?.guid !== PROJECTED_BILL_GUID) return { transactions }\n\n return { transactions: transactions.slice(0, -1), projectedTransaction: last }\n}\n\n/**\n * UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid\n * bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and\n * de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps\n * the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),\n * no bars. Bars are named by month; when two share a month, every bar is named by its day so no two\n * tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const { transactions: paidBills, projectedTransaction } = splitProjectedTransaction(transactions)\n if (!projectedTransaction || !paidBills.length) return []\n\n const sorted = [...paidBills].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const bars = [...history, toUpcomingBillBar(projectedTransaction)]\n\n const months = bars.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return bars\n\n return bars.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\n/**\n * The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under\n * \"Projected amount\": the latest paid bill's merchant and category with the due date and projected\n * amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the\n * inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.\n */\nexport const buildProjectedBillTransaction = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): Transaction | undefined => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) return undefined\n\n const latestBill = transactions.reduce((latest, t) => (t.date > latest.date ? t : latest))\n\n return {\n ...latestBill,\n guid: PROJECTED_BILL_GUID,\n amount: payload.amount,\n date: utcDayToUnix(payload.date),\n has_been_split: false,\n is_hidden: false,\n is_flagged: false,\n parent_guid: null,\n }\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block\n const key = `${variant}_drawer_title` as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n comparisonTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n // A double-bar drawer's tabs are its comparison columns; every other drawer's are its chart bars.\n const tabCount = comparisonTabCount || chartTabCount\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(Math.max(context?.chartBarIndex ?? 0, 0), Math.max(0, tabCount - 1))\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, tabCount - 1), subTabIndex }\n}\n\n/**\n * The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a\n * variant's tip names.\n */\nexport type DrillDownSlotData = InsightsInstanceSlotData &\n Pick<BarChartBlockData, 'average_amount'> & {\n merchant_name?: string\n // Monthly Deposit Summary: the deposits on the Income sub-tab, across every month.\n income_transaction_guids?: string[]\n // A drawer's own sub-tab names when the card's legend rows aren't the chart's (Income / Other Deposits).\n sub_tab_labels?: string[]\n }\n\n// A YYYY-MM-DD day as the epoch seconds of its UTC midnight: the day a transaction row is dated on\n// (fromUnixUTCToDayOfWeekAndDate), so a synthesized row agrees with the bars in every zone.\nexport const utcDayToUnix = (day: string): number => Date.parse(`${day}T00:00:00Z`) / 1000\n\n// Narrowing for drilldown_data's untyped values: each returns the value when it has the right shape,\n// else undefined, so a reader drops a missing or mistyped fact.\nexport const finiteNumberOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nexport const nonEmptyStringOf = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\nexport const guidListOf = (value: unknown): string[] | undefined =>\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => typeof item === 'string' && item !== '')\n ? (value as string[])\n : undefined\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/** Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload. */\nexport type SlotDataResolver = (payload: Partial<InsightsPayload> | undefined) => DrillDownSlotData\n\n/**\n * Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and\n * its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.\n */\nexport type BeatTransactionsResolver = (\n transactions: Transaction[],\n slotData: DrillDownSlotData,\n) => Transaction[]\n\n/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;;;AAyCA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAwB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,EAA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AAA,CAAoB,MAC/B,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,KAAK,IAAQ,QAEhD,IAAA,CAAc,MACzB,MAAM,QAAQ,CAAK,KACnB,EAAM,SAAS,KACf,EAAM,MAAA,CAAO,MAAS,OAAO,KAAS,YAAY,MAAS,EAAE,IACxD,IACD,QAGO,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,sBAAsB,KAAK,CAAK,KAAK,EAAQ,EAAS,CAAK,CAAC,IACrF,IACA,QAeO,IAAA,CAAuB,EAClC,QAAA,GACA,eAAA,GACA,gBAAA,GACA,iBAAA,EAAA,MAC0C;AAC1C,QAAM,IAAmB,EAAgB,CAAM,EAC5C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
@@ -1,14 +1,5 @@
1
1
  import { ActionDrawerState, InDescriptionCTA, PrimaryCTA, SecondaryCTA } from '../../core';
2
- /**
3
- * A chart-bar drilldown's context carries which block it targets (see BarchartBlock /
4
- * DoubleBarChartBlock), since either CTA could in principle open the same drawer. Match that
5
- * against `primary_cta.block`; anything else is assumed to be the secondary CTA's block.
6
- */
2
+ /** A CTA naming the bar's block wins; else that block with the card's CTA variant; else the secondary CTA. */
7
3
  export declare const getCtaForChartBarClick: (actionDrawer: ActionDrawerState, primary_cta: PrimaryCTA | undefined, secondary_cta: SecondaryCTA | undefined) => PrimaryCTA | SecondaryCTA | undefined;
8
- /**
9
- * Resolves which CTA (primary/secondary/in-description) drives the currently open drawer's
10
- * title/variant, based on what triggered it. Falls back to `primary_cta` whenever resolution comes
11
- * up empty (e.g. a `secondaryCta` trigger with no configured secondary CTA), so callers never have
12
- * to null-check.
13
- */
4
+ /** The CTA driving the open drawer, by trigger; falls back to `primary_cta`. */
14
5
  export declare const getDynamicCtaBasedOnTriggers: (actionDrawer: ActionDrawerState, primary_cta: PrimaryCTA | undefined, secondary_cta: SecondaryCTA | undefined, in_description_cta?: InDescriptionCTA) => PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined;
@@ -1,18 +1,28 @@
1
- var n = (t, r, e) => t.context?.block === r?.block ? r : e, u = (t, r, e, g) => {
1
+ import { layout as g } from "./TransactionHistoryBlock/layout.es.js";
2
+ var o = (t, r, n) => {
3
+ const e = t.context?.block;
4
+ if (e === r?.block) return r;
5
+ const l = r?.variant;
6
+ return e && e !== n?.block && l && Object.hasOwn(g, l) ? {
7
+ label: "",
8
+ block: e,
9
+ variant: l
10
+ } : n;
11
+ }, b = (t, r, n, e) => {
2
12
  if (t.trigger === "inDescriptionCta") {
3
- if (!t.cta) return g;
4
- const { drilldown_data: l } = g ?? {};
13
+ if (!t.cta) return e;
14
+ const { drilldown_data: l } = e ?? {};
5
15
  return {
6
16
  label: "",
7
17
  ...l && { drilldown_data: l },
8
18
  ...t.cta
9
19
  };
10
20
  }
11
- return t.trigger === "secondaryCta" ? e ?? r : t.trigger === "primaryCta" ? r : n(t, r, e) ?? r;
21
+ return t.trigger === "secondaryCta" ? n ?? r : t.trigger === "primaryCta" ? r : o(t, r, n) ?? r;
12
22
  };
13
23
  export {
14
- n as getCtaForChartBarClick,
15
- u as getDynamicCtaBasedOnTriggers
24
+ o as getCtaForChartBarClick,
25
+ b as getDynamicCtaBasedOnTriggers
16
26
  };
17
27
 
18
28
  //# sourceMappingURL=util.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/util.ts"],"sourcesContent":["import type {\n ActionDrawerState,\n DrilldownPayload,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../core'\n\n/**\n * A chart-bar drilldown's context carries which block it targets (see BarchartBlock /\n * DoubleBarChartBlock), since either CTA could in principle open the same drawer. Match that\n * against `primary_cta.block`; anything else is assumed to be the secondary CTA's block.\n */\nexport const getCtaForChartBarClick = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n): PrimaryCTA | SecondaryCTA | undefined => {\n const context = actionDrawer.context as DrilldownPayload | undefined\n const blockName = context?.block\n\n if (blockName === primary_cta?.block) {\n return primary_cta\n }\n return secondary_cta\n}\n\n/**\n * Resolves which CTA (primary/secondary/in-description) drives the currently open drawer's\n * title/variant, based on what triggered it. Falls back to `primary_cta` whenever resolution comes\n * up empty (e.g. a `secondaryCta` trigger with no configured secondary CTA), so callers never have\n * to null-check.\n */\nexport const getDynamicCtaBasedOnTriggers = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n in_description_cta?: InDescriptionCTA,\n): PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined => {\n // The opener may supply the block and variant, else the beat's link names them; the link's own\n // drilldown figures travel with either. Nothing to fall back to: only the link's own button fires\n // this trigger.\n if (actionDrawer.trigger === 'inDescriptionCta') {\n if (!actionDrawer.cta) return in_description_cta\n const { drilldown_data } = in_description_cta ?? {}\n return { label: '', ...(drilldown_data && { drilldown_data }), ...actionDrawer.cta }\n }\n if (actionDrawer.trigger === 'secondaryCta') {\n return secondary_cta ?? primary_cta\n }\n if (actionDrawer.trigger === 'primaryCta') {\n return primary_cta\n }\n return getCtaForChartBarClick(actionDrawer, primary_cta, secondary_cta) ?? primary_cta\n}\n"],"mappings":"AAaA,IAAa,IAAA,CACX,GACA,GACA,MAEgB,EAAa,SACF,UAET,GAAa,QACtB,IAEF,GASI,IAAA,CACX,GACA,GACA,GACA,MAC6D;AAI7D,MAAI,EAAa,YAAY,oBAAoB;AAC/C,QAAI,CAAC,EAAa,IAAK,QAAO;AAC9B,UAAM,EAAE,gBAAA,EAAA,IAAmB,KAAsB,CAAC;AAClD,WAAO;AAAA,MAAE,OAAO;AAAA,MAAI,GAAI,KAAkB,EAAE,gBAAA,EAAe;AAAA,MAAI,GAAG,EAAa;AAAA,IAAI;AAAA,EACrF;AACA,SAAI,EAAa,YAAY,iBACpB,KAAiB,IAEtB,EAAa,YAAY,eACpB,IAEF,EAAuB,GAAc,GAAa,CAAa,KAAK;AAC7E"}
1
+ {"version":3,"file":"util.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/util.ts"],"sourcesContent":["import type {\n ActionDrawerState,\n DrilldownPayload,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../core'\nimport { layout as drillDownLayout } from './TransactionHistoryBlock/layout'\n\n/** A CTA naming the bar's block wins; else that block with the card's CTA variant; else the secondary CTA. */\nexport const getCtaForChartBarClick = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n): PrimaryCTA | SecondaryCTA | undefined => {\n const context = actionDrawer.context as DrilldownPayload | undefined\n const blockName = context?.block\n\n if (blockName === primary_cta?.block) {\n return primary_cta\n }\n // Category Spending with a budget: no CTA names Spending History, so the bar opens it with the\n // primary CTA's variant when that is a Spending History view (`category_spend`).\n const variant = primary_cta?.variant\n if (\n blockName &&\n blockName !== secondary_cta?.block &&\n variant &&\n Object.hasOwn(drillDownLayout, variant)\n ) {\n return { label: '', block: blockName, variant }\n }\n return secondary_cta\n}\n\n/** The CTA driving the open drawer, by trigger; falls back to `primary_cta`. */\nexport const getDynamicCtaBasedOnTriggers = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n in_description_cta?: InDescriptionCTA,\n): PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined => {\n // The opener's block and variant, else the beat's link.\n if (actionDrawer.trigger === 'inDescriptionCta') {\n if (!actionDrawer.cta) return in_description_cta\n const { drilldown_data } = in_description_cta ?? {}\n return { label: '', ...(drilldown_data && { drilldown_data }), ...actionDrawer.cta }\n }\n if (actionDrawer.trigger === 'secondaryCta') {\n return secondary_cta ?? primary_cta\n }\n if (actionDrawer.trigger === 'primaryCta') {\n return primary_cta\n }\n return getCtaForChartBarClick(actionDrawer, primary_cta, secondary_cta) ?? primary_cta\n}\n"],"mappings":";AAUA,IAAa,IAAA,CACX,GACA,GACA,MAC0C;AAE1C,QAAM,IADU,EAAa,SACF;AAE3B,MAAI,MAAc,GAAa,MAC7B,QAAO;AAIT,QAAM,IAAU,GAAa;AAC7B,SACE,KACA,MAAc,GAAe,SAC7B,KACA,OAAO,OAAO,GAAiB,CAAO,IAE/B;AAAA,IAAE,OAAO;AAAA,IAAI,OAAO;AAAA,IAAW,SAAA;AAAA,EAAQ,IAEzC;AACT,GAGa,IAAA,CACX,GACA,GACA,GACA,MAC6D;AAE7D,MAAI,EAAa,YAAY,oBAAoB;AAC/C,QAAI,CAAC,EAAa,IAAK,QAAO;AAC9B,UAAM,EAAE,gBAAA,EAAA,IAAmB,KAAsB,CAAC;AAClD,WAAO;AAAA,MAAE,OAAO;AAAA,MAAI,GAAI,KAAkB,EAAE,gBAAA,EAAe;AAAA,MAAI,GAAG,EAAa;AAAA,IAAI;AAAA,EACrF;AACA,SAAI,EAAa,YAAY,iBACpB,KAAiB,IAEtB,EAAa,YAAY,eACpB,IAEF,EAAuB,GAAc,GAAa,CAAa,KAAK;AAC7E"}
@@ -12,6 +12,22 @@ export interface AnalyticsEventConfigEntry {
12
12
  };
13
13
  }
14
14
  export declare const ANALYTICS_EVENTS_CONFIG: {
15
+ readonly BUDGET_EDIT_SAVE: {
16
+ readonly category: "Budget Menu";
17
+ readonly action: (beat: Beat) => string;
18
+ };
19
+ readonly BUDGET_DELETE_START: {
20
+ readonly category: "Budget Menu";
21
+ readonly action: (beat: Beat) => string;
22
+ };
23
+ readonly BUDGET_DELETE_CANCEL: {
24
+ readonly category: "Budget Menu";
25
+ readonly action: (beat: Beat) => string;
26
+ };
27
+ readonly BUDGET_DELETE_END: {
28
+ readonly category: "Budget Menu";
29
+ readonly action: (beat: Beat) => string;
30
+ };
15
31
  readonly PRIMARY_ACTION_SELECTED: {
16
32
  readonly category: "Beat Interaction";
17
33
  readonly action: "Primary Action Selected";
@@ -1,4 +1,21 @@
1
- var t = (e) => e?.replace(/([A-Z]+)/g, " $1")?.replace(/^ /, "") ?? "", a = {
1
+ import { resolveBudgetFacts as c } from "../actionBlocks/BudgetDetailsBlock/layout.es.js";
2
+ var t = (e) => e?.replace(/([A-Z]+)/g, " $1")?.replace(/^ /, "") ?? "", a = (e) => (n) => `${c(n).categoryGuid ? "Category" : "Merchant"} Budget - ${e}`, r = {
3
+ BUDGET_EDIT_SAVE: {
4
+ category: "Budget Menu",
5
+ action: a("End - Save")
6
+ },
7
+ BUDGET_DELETE_START: {
8
+ category: "Budget Menu",
9
+ action: a("Start - Delete")
10
+ },
11
+ BUDGET_DELETE_CANCEL: {
12
+ category: "Budget Menu",
13
+ action: a("Cancel - Delete")
14
+ },
15
+ BUDGET_DELETE_END: {
16
+ category: "Budget Menu",
17
+ action: a("End - Delete")
18
+ },
2
19
  PRIMARY_ACTION_SELECTED: {
3
20
  category: "Beat Interaction",
4
21
  action: "Primary Action Selected"
@@ -100,7 +117,7 @@ var t = (e) => e?.replace(/([A-Z]+)/g, " $1")?.replace(/^ /, "") ?? "", a = {
100
117
  } }
101
118
  };
102
119
  export {
103
- a as ANALYTICS_EVENTS_CONFIG,
120
+ r as ANALYTICS_EVENTS_CONFIG,
104
121
  t as sentenceCaseTemplate
105
122
  };
106
123
 
@@ -1 +1 @@
1
- {"version":3,"file":"analyticsEventsConfig.es.js","names":[],"sources":["../../../src/insights-v2/analytics/analyticsEventsConfig.ts"],"sourcesContent":["import type { Beat } from '../../core'\n\n// PascalCase template to label, ported from Pulse.\nexport const sentenceCaseTemplate = (template?: string | null): string =>\n template?.replace(/([A-Z]+)/g, ' $1')?.replace(/^ /, '') ?? ''\n\n// Fixed or beat-computed value.\ntype Resolvable = string | ((beat: Beat) => string)\n\n// Source of truth for insights-v2 analytics events. Mirrors Pulse's strings.\n// Entry has a Firefly half (action/category) and/or a postHog half.\nexport interface AnalyticsEventConfigEntry {\n category?: Resolvable\n action?: Resolvable\n /** Detail stored with the Firefly event, e.g. a survey reason. */\n value?: Resolvable\n postHog?: {\n eventName: string\n properties?: (beat: Beat) => Record<string, unknown>\n }\n}\n\nexport const ANALYTICS_EVENTS_CONFIG = {\n // Primary/secondary CTA click, fired via sendCtaAnalytics.\n PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Primary Action Selected',\n },\n SECONDARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Secondary Action Selected',\n },\n // Fires once, gated on !beat.cta_clicked_at.\n FIRST_TIME_PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'First Time Primary Action Selected',\n },\n\n // \"Not Interested\" survey submitted; the call site sets the picked reason as `value`.\n BEAT_DISMISSED: {\n category: 'Beat Interaction',\n action: 'Beat Dismissed',\n },\n\n // Bar click on the card's inline chart.\n CHART_BAR_CLICKED: {\n category: 'Beat Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Bar click inside the drill-down drawer.\n DRAWER_CHART_BAR_CLICKED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Month/tab change inside the drill-down drawer.\n TAB_SELECTED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Month Tab Selected`,\n },\n // Series (e.g. Spend / Income) tab change inside the double-bar drawer.\n TYPE_FILTER_SELECTED: {\n category: 'Transactions Filter',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Transactions Filtered By Type`,\n },\n\n // LowAccountBalance threshold dialog.\n EDIT_INSIGHT_THRESHOLD_SAVE: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Save',\n },\n EDIT_INSIGHT_THRESHOLD_CANCELED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Canceled',\n },\n EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Input Selected',\n },\n\n // SavingsOpportunityV2 safety-net dialog.\n EDIT_SAFETY_NET_SAVE: {\n category: 'Safety Net',\n action: 'Edit Safety Net',\n },\n // Ported verbatim from Pulse (uses '=' not '-').\n EDIT_SAFETY_NET_CANCEL: {\n category: 'Safety Net',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} = Edit Safety Net - Cancel`,\n },\n\n // Designate Emergency Savings Account (picker pick, Save, Open a Savings Account). Pulse's strings.\n EMERGENCY_SAVINGS_ACCT_SELECTED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Selected',\n },\n EMERGENCY_SAVINGS_ACCT_SAVED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Saved',\n },\n EMERGENCY_SAVINGS_ACCT_CREATED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account - Savings Account Created',\n },\n\n // Subscription status CTA answers and Undo (pulse's Subscription Confirmation).\n SUBSCRIPTION_CONFIRMED: {\n category: 'Subscription Confirmation',\n action: 'User Marked as Correct',\n },\n SUBSCRIPTION_NOT_SUBSCRIBED: {\n category: 'Subscription Confirmation',\n action: 'User Marked as Incorrect',\n },\n SUBSCRIPTION_NEVER_SUBSCRIBED: {\n category: 'Subscription Confirmation',\n action: 'Have Never Subscribed',\n },\n SUBSCRIPTION_CANCELLED: {\n category: 'Subscription Confirmation',\n action: 'Subscription Has Been Canceled',\n },\n SUBSCRIPTION_ONE_TIME_PURCHASE: {\n category: 'Subscription Confirmation',\n action: 'One Time Purchase',\n },\n SUBSCRIPTION_WRONG_FREQUENCY: {\n category: 'Subscription Confirmation',\n action: 'Frequency Is Incorrect',\n },\n /** Fired with \" - Previous action: <answer>\" appended, as pulse did. */\n SUBSCRIPTION_UNDO: { category: 'Subscription Confirmation', action: 'User Clicked Undo Button' },\n\n // Connect drawer opened. PostHog-only.\n OPENED_CONNECT_DRAWER: {\n postHog: {\n eventName: 'opened_connect_drawer',\n properties: (beat) => ({ beat_guid: beat.guid, template: beat.template }),\n },\n },\n} as const satisfies Record<string, AnalyticsEventConfigEntry>\n"],"mappings":"AAGA,IAAa,IAAA,CAAwB,MACnC,GAAU,QAAQ,aAAa,KAAK,GAAG,QAAQ,MAAM,EAAE,KAAK,IAkBjD,IAA0B;AAAA,EAErC,yBAAyB;AAAA,IACvB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,2BAA2B;AAAA,IACzB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAEA,oCAAoC;AAAA,IAClC,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,gBAAgB;AAAA,IACd,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,mBAAmB;AAAA,IACjB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,0BAA0B;AAAA,IACxB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,cAAc;AAAA,IACZ,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,sBAAsB;AAAA,IACpB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAGA,6BAA6B;AAAA,IAC3B,UAAU;AAAA,IACV,QAAQ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analyticsEventsConfig.ts"],"sourcesContent":["import type { Beat } from '../../core'\nimport { resolveBudgetFacts } from '../actionBlocks/BudgetDetailsBlock/layout'\n\n// PascalCase template to label, ported from Pulse.\nexport const sentenceCaseTemplate = (template?: string | null): string =>\n template?.replace(/([A-Z]+)/g, ' $1')?.replace(/^ /, '') ?? ''\n\n// Fixed or beat-computed value.\ntype Resolvable = string | ((beat: Beat) => string)\n\n// Source of truth for insights-v2 analytics events. Mirrors Pulse's strings.\n// Entry has a Firefly half (action/category) and/or a postHog half.\nexport interface AnalyticsEventConfigEntry {\n category?: Resolvable\n action?: Resolvable\n /** Detail stored with the Firefly event, e.g. a survey reason. */\n value?: Resolvable\n postHog?: {\n eventName: string\n properties?: (beat: Beat) => Record<string, unknown>\n }\n}\n\n// Pulse's labels: \"Category Budget - …\" for a category budget, \"Merchant Budget - …\" for a merchant's.\nconst budgetMenuAction =\n (step: string) =>\n (beat: Beat): string =>\n `${resolveBudgetFacts(beat).categoryGuid ? 'Category' : 'Merchant'} Budget - ${step}`\n\nexport const ANALYTICS_EVENTS_CONFIG = {\n // Budget Details drawer events; End - Save carries the new amount as its value.\n BUDGET_EDIT_SAVE: { category: 'Budget Menu', action: budgetMenuAction('End - Save') },\n BUDGET_DELETE_START: { category: 'Budget Menu', action: budgetMenuAction('Start - Delete') },\n BUDGET_DELETE_CANCEL: { category: 'Budget Menu', action: budgetMenuAction('Cancel - Delete') },\n BUDGET_DELETE_END: { category: 'Budget Menu', action: budgetMenuAction('End - Delete') },\n\n // Primary/secondary CTA click, fired via sendCtaAnalytics.\n PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Primary Action Selected',\n },\n SECONDARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Secondary Action Selected',\n },\n // Fires once, gated on !beat.cta_clicked_at.\n FIRST_TIME_PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'First Time Primary Action Selected',\n },\n\n // \"Not Interested\" survey submitted; the call site sets the picked reason as `value`.\n BEAT_DISMISSED: {\n category: 'Beat Interaction',\n action: 'Beat Dismissed',\n },\n\n // Bar click on the card's inline chart.\n CHART_BAR_CLICKED: {\n category: 'Beat Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Bar click inside the drill-down drawer.\n DRAWER_CHART_BAR_CLICKED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Month/tab change inside the drill-down drawer.\n TAB_SELECTED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Month Tab Selected`,\n },\n // Series (e.g. Spend / Income) tab change inside the double-bar drawer.\n TYPE_FILTER_SELECTED: {\n category: 'Transactions Filter',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Transactions Filtered By Type`,\n },\n\n // LowAccountBalance threshold dialog.\n EDIT_INSIGHT_THRESHOLD_SAVE: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Save',\n },\n EDIT_INSIGHT_THRESHOLD_CANCELED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Canceled',\n },\n EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Input Selected',\n },\n\n // SavingsOpportunityV2 safety-net dialog.\n EDIT_SAFETY_NET_SAVE: {\n category: 'Safety Net',\n action: 'Edit Safety Net',\n },\n // Ported verbatim from Pulse (uses '=' not '-').\n EDIT_SAFETY_NET_CANCEL: {\n category: 'Safety Net',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} = Edit Safety Net - Cancel`,\n },\n\n // Designate Emergency Savings Account (picker pick, Save, Open a Savings Account). Pulse's strings.\n EMERGENCY_SAVINGS_ACCT_SELECTED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Selected',\n },\n EMERGENCY_SAVINGS_ACCT_SAVED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Saved',\n },\n EMERGENCY_SAVINGS_ACCT_CREATED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account - Savings Account Created',\n },\n\n // Subscription status CTA answers and Undo (pulse's Subscription Confirmation).\n SUBSCRIPTION_CONFIRMED: {\n category: 'Subscription Confirmation',\n action: 'User Marked as Correct',\n },\n SUBSCRIPTION_NOT_SUBSCRIBED: {\n category: 'Subscription Confirmation',\n action: 'User Marked as Incorrect',\n },\n SUBSCRIPTION_NEVER_SUBSCRIBED: {\n category: 'Subscription Confirmation',\n action: 'Have Never Subscribed',\n },\n SUBSCRIPTION_CANCELLED: {\n category: 'Subscription Confirmation',\n action: 'Subscription Has Been Canceled',\n },\n SUBSCRIPTION_ONE_TIME_PURCHASE: {\n category: 'Subscription Confirmation',\n action: 'One Time Purchase',\n },\n SUBSCRIPTION_WRONG_FREQUENCY: {\n category: 'Subscription Confirmation',\n action: 'Frequency Is Incorrect',\n },\n /** Fired with \" - Previous action: <answer>\" appended, as pulse did. */\n SUBSCRIPTION_UNDO: { category: 'Subscription Confirmation', action: 'User Clicked Undo Button' },\n\n // Connect drawer opened. PostHog-only.\n OPENED_CONNECT_DRAWER: {\n postHog: {\n eventName: 'opened_connect_drawer',\n properties: (beat) => ({ beat_guid: beat.guid, template: beat.template }),\n },\n },\n} as const satisfies Record<string, AnalyticsEventConfigEntry>\n"],"mappings":";AAIA,IAAa,IAAA,CAAwB,MACnC,GAAU,QAAQ,aAAa,KAAK,GAAG,QAAQ,MAAM,EAAE,KAAK,IAmBxD,IAAA,CACH,MAAA,CACA,MACC,GAAG,EAAmB,CAAI,EAAE,eAAe,aAAa,UAAA,aAAuB,CAAA,IAEtE,IAA0B;AAAA,EAErC,kBAAkB;AAAA,IAAE,UAAU;AAAA,IAAe,QAAQ,EAAiB,YAAY;AAAA,EAAE;AAAA,EACpF,qBAAqB;AAAA,IAAE,UAAU;AAAA,IAAe,QAAQ,EAAiB,gBAAgB;AAAA,EAAE;AAAA,EAC3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AQ,CAAA;AAAA,EACzD;AAAA,EAGA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,gCAAgC;AAAA,IAC9B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,wBAAwB;AAAA,IACtB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,6BAA6B;AAAA,IAC3B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,+BAA+B;AAAA,IAC7B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,wBAAwB;AAAA,IACtB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,gCAAgC;AAAA,IAC9B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAEA,mBAAmB;AAAA,IAAE,UAAU;AAAA,IAA6B,QAAQ;AAAA,EAA2B;AAAA,EAG/F,uBAAuB,EACrB,SAAS;AAAA,IACP,WAAW;AAAA,IACX,YAAA,CAAa,OAAU;AAAA,MAAE,WAAW,EAAK;AAAA,MAAM,UAAU,EAAK;AAAA,IAAS;AAAA,EACzE,EACF;AACF"}
@@ -11,12 +11,12 @@ import V from "react";
11
11
  import { observer as w } from "mobx-react-lite";
12
12
  import { jsx as r } from "react/jsx-runtime";
13
13
  import { useTheme as H } from "@mui/material/styles";
14
- var X = w(({ payload: a, beatGuid: n = "" }) => {
15
- const i = H(), { openActionDrawer: m } = I(), { isCopyLoaded: s } = B(), { instance_slot: o, widget_type: c } = a, { series: l, category_guid: h, average_amount: e = 0, additional_data: d = [] } = o.data ?? {}, [f, u] = d, t = E(O(l), v), [p] = V.useState(t.length - 1), { chartHeight: A, color: g, showMonthlyAmount: C, unselectedOpacity: _ } = S(o, h, i), b = D();
16
- return s ? t.length ? /* @__PURE__ */ r(R, {
14
+ var X = w(({ payload: n, beatGuid: i = "" }) => {
15
+ const m = H(), { openActionDrawer: s } = I(), { isCopyLoaded: c } = B(), { instance_slot: o, widget_type: e } = n, { series: l, category_guid: h, average_amount: a = 0, additional_data: d = [] } = o.data ?? {}, [f, u] = d, t = E(O(l), v), [p] = V.useState(t.length - 1), { chartHeight: A, color: g, showMonthlyAmount: C, unselectedOpacity: _ } = S(o, h, m, e), b = D();
16
+ return c ? t.length ? /* @__PURE__ */ r(R, {
17
17
  amounts: {
18
- average: e,
19
- formattedAverage: L(e, "0,0")
18
+ average: a,
19
+ formattedAverage: L(a, "0,0")
20
20
  },
21
21
  color: g,
22
22
  data: t,
@@ -29,9 +29,9 @@ var X = w(({ payload: a, beatGuid: n = "" }) => {
29
29
  top: 24
30
30
  },
31
31
  onBarClick: (y) => {
32
- if (c !== "full") return !1;
33
- b(x.CHART_BAR_CLICKED), m({
34
- guid: n,
32
+ if (e !== "full") return !1;
33
+ b(x.CHART_BAR_CLICKED), s({
34
+ guid: i,
35
35
  trigger: "chartBar",
36
36
  context: {
37
37
  chartBarIndex: y,
@@ -1 +1 @@
1
- {"version":3,"file":"BarchartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.tsx"],"sourcesContent":["import React from 'react'\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport { formatCurrency, Loader, useGlobalUiStore, useInsightsV2Store } from '../../../../common'\nimport type { DrilldownPayload, InsightsPayload } from '../../../../core'\nimport type { BarChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { BarChartV2 } from '../../../components/chartblocks/BarchartV2'\nimport { EmptyBarChart } from '../../../components/chartblocks/EmptyBarChart'\n\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../../analytics'\n\nimport { BAR_ARIA_LABEL, barChartVariant, buildChartData, buildDataSeries } from './utils'\nimport { actionBlocksKey } from '../../../mappings/actionBlocksKey'\n\ninterface BarchartBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nexport const BarchartBlock = observer(({ payload, beatGuid = '' }: BarchartBlockProps) => {\n const theme = useTheme()\n const { openActionDrawer } = useInsightsV2Store()\n const { isCopyLoaded } = useGlobalUiStore()\n const { instance_slot, widget_type } = payload\n const {\n series,\n category_guid,\n average_amount = 0,\n additional_data = [],\n } = (instance_slot.data ?? {}) as BarChartBlockData\n const [monthlyAmount, trend] = additional_data\n const chartData = buildChartData(buildDataSeries(series), BAR_ARIA_LABEL)\n const [selectedTabIndex] = React.useState(chartData.length - 1)\n const { chartHeight, color, showMonthlyAmount, unselectedOpacity } = barChartVariant(\n instance_slot,\n category_guid,\n theme,\n )\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n if (!isCopyLoaded) {\n return <Loader />\n }\n\n return chartData.length ? (\n <BarChartV2\n amounts={{\n average: average_amount,\n formattedAverage: formatCurrency(average_amount, '0,0'),\n }}\n color={color}\n data={chartData}\n heightOverride={chartHeight}\n monthlyAmountLabel={monthlyAmount?.label ?? ''}\n margin={{\n bottom: 8,\n left: 16,\n right: 16,\n // Room for the tallest bar's value label, drawn 8px above the bar and about 14px tall.\n top: 24,\n }}\n onBarClick={(index) => {\n if (widget_type !== 'full') return false\n\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.CHART_BAR_CLICKED)\n\n openActionDrawer({\n guid: beatGuid,\n trigger: 'chartBar',\n context: {\n chartBarIndex: index,\n block: actionBlocksKey.TRANSCATION_HISTORY_ACTION_BLOCK,\n } satisfies DrilldownPayload,\n })\n }}\n selectedTabIndex={selectedTabIndex}\n showMonthlyAmount={showMonthlyAmount}\n trendAmountLabel={trend?.label ?? ''}\n unselectedOpacity={unselectedOpacity}\n />\n ) : (\n <EmptyBarChart />\n )\n})\n"],"mappings":";;;;;;;;;;;;;AAqBA,IAAa,IAAgB,EAAA,CAAU,EAAE,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AAA,IAxCT,gBAAA,EAAC,GAAD,CAAS,CAAA;AA0CpB,CAAC"}
1
+ {"version":3,"file":"BarchartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.tsx"],"sourcesContent":["import React from 'react'\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport { formatCurrency, Loader, useGlobalUiStore, useInsightsV2Store } from '../../../../common'\nimport type { DrilldownPayload, InsightsPayload } from '../../../../core'\nimport type { BarChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { BarChartV2 } from '../../../components/chartblocks/BarchartV2'\nimport { EmptyBarChart } from '../../../components/chartblocks/EmptyBarChart'\n\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../../analytics'\n\nimport { BAR_ARIA_LABEL, barChartVariant, buildChartData, buildDataSeries } from './utils'\nimport { actionBlocksKey } from '../../../mappings/actionBlocksKey'\n\ninterface BarchartBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nexport const BarchartBlock = observer(({ payload, beatGuid = '' }: BarchartBlockProps) => {\n const theme = useTheme()\n const { openActionDrawer } = useInsightsV2Store()\n const { isCopyLoaded } = useGlobalUiStore()\n const { instance_slot, widget_type } = payload\n const {\n series,\n category_guid,\n average_amount = 0,\n additional_data = [],\n } = (instance_slot.data ?? {}) as BarChartBlockData\n const [monthlyAmount, trend] = additional_data\n const chartData = buildChartData(buildDataSeries(series), BAR_ARIA_LABEL)\n const [selectedTabIndex] = React.useState(chartData.length - 1)\n const { chartHeight, color, showMonthlyAmount, unselectedOpacity } = barChartVariant(\n instance_slot,\n category_guid,\n theme,\n widget_type,\n )\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n if (!isCopyLoaded) {\n return <Loader />\n }\n\n return chartData.length ? (\n <BarChartV2\n amounts={{\n average: average_amount,\n formattedAverage: formatCurrency(average_amount, '0,0'),\n }}\n color={color}\n data={chartData}\n heightOverride={chartHeight}\n monthlyAmountLabel={monthlyAmount?.label ?? ''}\n margin={{\n bottom: 8,\n left: 16,\n right: 16,\n // Room for the tallest bar's value label, drawn 8px above the bar and about 14px tall.\n top: 24,\n }}\n onBarClick={(index) => {\n if (widget_type !== 'full') return false\n\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.CHART_BAR_CLICKED)\n\n openActionDrawer({\n guid: beatGuid,\n trigger: 'chartBar',\n context: {\n chartBarIndex: index,\n block: actionBlocksKey.TRANSCATION_HISTORY_ACTION_BLOCK,\n } satisfies DrilldownPayload,\n })\n }}\n selectedTabIndex={selectedTabIndex}\n showMonthlyAmount={showMonthlyAmount}\n trendAmountLabel={trend?.label ?? ''}\n unselectedOpacity={unselectedOpacity}\n />\n ) : (\n <EmptyBarChart />\n )\n})\n"],"mappings":";;;;;;;;;;;;;AAqBA,IAAa,IAAgB,EAAA,CAAU,EAAE,SAAA,GAAS,UAAA,IAAW,GAAA,MAA6B;AACxF,QAAM,IAAQ,EAAS,GACjB,EAAE,kBAAA,EAAA,IAAqB,EAAmB,GAC1C,EAAE,cAAA,EAAA,IAAiB,EAAiB,GACpC,EAAE,eAAA,GAAe,aAAA,EAAA,IAAgB,GACjC,EACJ,QAAA,GACA,eAAA,GACA,gBAAA,IAAiB,GACjB,iBAAA,IAAkB,CAAC,EAAA,IAChB,EAAc,QAAQ,CAAC,GACtB,CAAC,GAAe,CAAA,IAAS,GACzB,IAAY,EAAe,EAAgB,CAAM,GAAG,CAAc,GAClE,CAAC,CAAA,IAAoB,EAAM,SAAS,EAAU,SAAS,CAAC,GACxD,EAAE,aAAA,GAAa,OAAA,GAAO,mBAAA,GAAmB,mBAAA,EAAA,IAAsB,EACnE,GACA,GACA,GACA,CACF,GACM,IAAqB,EAAkB;AAE7C,SAAK,IAIE,EAAU,SACf,gBAAA,EAAC,GAAD;AAAA,IACE,SAAS;AAAA,MACP,SAAS;AAAA,MACT,kBAAkB,EAAe,GAAgB,KAAK;AAAA,IACxD;AAAA,IACO,OAAA;AAAA,IACP,MAAM;AAAA,IACN,gBAAgB;AAAA,IAChB,oBAAoB,GAAe,SAAS;AAAA,IAC5C,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MAEP,KAAK;AAAA,IACP;AAAA,IACA,YAAA,CAAa,MAAU;AACrB,UAAI,MAAgB,OAAQ,QAAO;AAEnC,MAAA,EAAmB,EAAwB,iBAAiB,GAE5D,EAAiB;AAAA,QACf,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,UACP,eAAe;AAAA,UACf,OAAO,EAAgB;AAAA,QACzB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACkB,kBAAA;AAAA,IACC,mBAAA;AAAA,IACnB,kBAAkB,GAAO,SAAS;AAAA,IACf,mBAAA;AAAA,EACpB,CAAA,IAED,gBAAA,EAAC,GAAD,CAAgB,CAAA,IAxCT,gBAAA,EAAC,GAAD,CAAS,CAAA;AA0CpB,CAAC"}
@@ -32,4 +32,4 @@ export interface BarChartVariantLayout {
32
32
  showMonthlyAmount: boolean;
33
33
  unselectedOpacity?: number;
34
34
  }
35
- export declare const barChartVariant: (instanceSlot: InstanceSlot, categoryGuid: string | undefined, theme: Theme) => BarChartVariantLayout;
35
+ export declare const barChartVariant: (instanceSlot: InstanceSlot, categoryGuid: string | undefined, theme: Theme, widgetType?: string) => BarChartVariantLayout;
@@ -1,47 +1,48 @@
1
1
  import { buildDynamicCopy as u } from "../../../../core/utils/Localization.es.js";
2
- import { DATE_FORMATS_INTL as i, formatDate as c } from "../../../../core/constants/DateFormats.es.js";
3
- import { formatCurrency as m } from "../../../../core/utils/NumberFormatting.es.js";
4
- import { getCategoryColor as l } from "../../../../core/utils/CategoryUtil.es.js";
5
- import { getLayoutConfig as A } from "./layout.es.js";
6
- import { parseISO as p } from "date-fns/parseISO";
7
- var s = {
2
+ import { DATE_FORMATS_INTL as c, formatDate as l } from "../../../../core/constants/DateFormats.es.js";
3
+ import { formatCurrency as i } from "../../../../core/utils/NumberFormatting.es.js";
4
+ import { getCategoryColor as A } from "../../../../core/utils/CategoryUtil.es.js";
5
+ import { getLayoutConfig as p } from "./layout.es.js";
6
+ import { parseISO as s } from "date-fns/parseISO";
7
+ var _ = {
8
8
  CATEGORY_COLOR: "category_color",
9
9
  ACCOUNT_BALANCE: "account_balance",
10
10
  MONTHLY_SPEND_COMPARISON: "monthly_spend_comparison"
11
- }, h = "_1{month}: _2{amount}", T = (a) => a ? a.data ? a.data.map((n) => {
11
+ }, T = "_1{month}: _2{amount}", R = (a) => a ? a.data ? a.data.map((o) => {
12
12
  const e = {};
13
13
  return a.names?.map((t, r) => {
14
- e[t] = n[r];
14
+ e[t] = o[r];
15
15
  }), e;
16
- }) : [] : [], R = (a, n, e = i.MONTH_SHORT) => [...a].sort((t, r) => !t.date || !r.date ? 0 : new Date(t.date).getTime() - new Date(r.date).getTime()).map((t) => {
17
- const r = t.date ? c(p(t.date), e) : t.label ?? "", o = t.amount ?? 0;
16
+ }) : [] : [], L = (a, o, e = c.MONTH_SHORT) => [...a].sort((t, r) => !t.date || !r.date ? 0 : new Date(t.date).getTime() - new Date(r.date).getTime()).map((t) => {
17
+ const r = t.date ? l(s(t.date), e) : t.label ?? "", n = t.amount ?? 0;
18
18
  return {
19
- ariaLabel: u(n, r, m(o, "0.00")),
19
+ ariaLabel: u(o, r, i(n, "0.00")),
20
20
  date: t.date ?? null,
21
21
  label: r,
22
- value: o,
23
- formattedAmount: m(o, "0,0")
22
+ value: n,
23
+ formattedAmount: i(n, "0,0")
24
24
  };
25
- }), L = (a, n, e) => {
26
- const { variant: t } = a, r = A(e);
27
- if (t === s.CATEGORY_COLOR && n) return {
28
- color: l(n, e),
25
+ }), g = (a, o, e, t) => {
26
+ const { variant: r } = a, n = p(e);
27
+ if (r === _.CATEGORY_COLOR && o) return {
28
+ chartHeight: t === "mini" ? 94 : void 0,
29
+ color: A(o, e),
29
30
  showMonthlyAmount: !0
30
31
  };
31
- const o = r[t];
32
+ const m = n[r];
32
33
  return {
33
- chartHeight: o?.chartHeight,
34
- color: o?.color ?? e.palette.primary.main,
35
- showMonthlyAmount: o?.showMonthlyAmount ?? !0,
36
- unselectedOpacity: o?.unselectedOpacity
34
+ chartHeight: m?.chartHeight,
35
+ color: m?.color ?? e.palette.primary.main,
36
+ showMonthlyAmount: m?.showMonthlyAmount ?? !0,
37
+ unselectedOpacity: m?.unselectedOpacity
37
38
  };
38
39
  };
39
40
  export {
40
- h as BAR_ARIA_LABEL,
41
- s as BAR_CHART_VARIANTS,
42
- L as barChartVariant,
43
- R as buildChartData,
44
- T as buildDataSeries
41
+ T as BAR_ARIA_LABEL,
42
+ _ as BAR_CHART_VARIANTS,
43
+ g as barChartVariant,
44
+ L as buildChartData,
45
+ R as buildDataSeries
45
46
  };
46
47
 
47
48
  //# sourceMappingURL=utils.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\nimport { parseISO } from 'date-fns/parseISO'\n\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport type { DataSeries, InstanceSlot } from '../../../../core'\nimport { getLayoutConfig } from './layout'\n\nexport const BAR_CHART_VARIANTS = {\n CATEGORY_COLOR: 'category_color',\n ACCOUNT_BALANCE: 'account_balance',\n MONTHLY_SPEND_COMPARISON: 'monthly_spend_comparison',\n}\n\nexport interface ChartDataSeriesItem {\n date?: string\n amount?: number\n guid?: string\n label?: string\n aggregated_guids?: string[]\n localized_label?: string\n category_guid?: string\n}\n\n/** Per-bar aria label, built in the frontend: \"{month}: {amount}\" (buildDynamicCopy placeholders). */\nexport const BAR_ARIA_LABEL = '_1{month}: _2{amount}'\n\nexport const buildDataSeries = (data: DataSeries | undefined): ChartDataSeriesItem[] => {\n if (!data) {\n return []\n }\n\n if (data.data) {\n return data.data.map((d) => {\n const item: any = {}\n\n data.names?.map((name, index) => {\n item[name] = d[index]\n })\n return item\n })\n } else {\n return []\n }\n}\n\nexport const buildChartData = (\n dataSeries: ChartDataSeriesItem[],\n ariaLabel: string,\n dateFormat: Parameters<typeof formatDate>[1] = DATE_FORMATS_INTL.MONTH_SHORT,\n) => {\n const data = [...dataSeries]\n .sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n .map((total) => {\n const label = total.date ? formatDate(parseISO(total.date), dateFormat) : (total.label ?? '')\n const amount = total.amount ?? 0\n\n return {\n ariaLabel: buildDynamicCopy(ariaLabel, label, formatCurrency(amount, '0.00')) as string,\n date: total.date ?? null,\n label,\n value: amount,\n formattedAmount: formatCurrency(amount, '0,0'),\n }\n })\n\n return data\n}\n\n/** A bar chart variant's look: its layout entry, resolved with defaults. */\nexport interface BarChartVariantLayout {\n chartHeight?: number\n color: string\n showMonthlyAmount: boolean\n unselectedOpacity?: number\n}\n\nexport const barChartVariant = (\n instanceSlot: InstanceSlot,\n categoryGuid: string | undefined,\n theme: Theme,\n): BarChartVariantLayout => {\n const { variant } = instanceSlot\n const barChartLayout = getLayoutConfig(theme)\n if (variant === BAR_CHART_VARIANTS.CATEGORY_COLOR && categoryGuid) {\n return { color: getCategoryColor(categoryGuid, theme), showMonthlyAmount: true }\n }\n const layout: Partial<BarChartVariantLayout> | undefined =\n barChartLayout[variant as keyof typeof barChartLayout]\n return {\n chartHeight: layout?.chartHeight,\n color: layout?.color ?? theme.palette.primary.main,\n showMonthlyAmount: layout?.showMonthlyAmount ?? true,\n unselectedOpacity: layout?.unselectedOpacity,\n }\n}\n"],"mappings":";;;;;;AAWA,IAAa,IAAqB;AAAA,EAChC,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,0B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GAAQ;AAAA,EAC7B;AACF"}
1
+ {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\nimport { parseISO } from 'date-fns/parseISO'\n\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport type { DataSeries, InstanceSlot } from '../../../../core'\nimport { getLayoutConfig } from './layout'\n\nexport const BAR_CHART_VARIANTS = {\n CATEGORY_COLOR: 'category_color',\n ACCOUNT_BALANCE: 'account_balance',\n MONTHLY_SPEND_COMPARISON: 'monthly_spend_comparison',\n}\n\nexport interface ChartDataSeriesItem {\n date?: string\n amount?: number\n guid?: string\n label?: string\n aggregated_guids?: string[]\n localized_label?: string\n category_guid?: string\n}\n\n/** Per-bar aria label, built in the frontend: \"{month}: {amount}\" (buildDynamicCopy placeholders). */\nexport const BAR_ARIA_LABEL = '_1{month}: _2{amount}'\n\nexport const buildDataSeries = (data: DataSeries | undefined): ChartDataSeriesItem[] => {\n if (!data) {\n return []\n }\n\n if (data.data) {\n return data.data.map((d) => {\n const item: any = {}\n\n data.names?.map((name, index) => {\n item[name] = d[index]\n })\n return item\n })\n } else {\n return []\n }\n}\n\nexport const buildChartData = (\n dataSeries: ChartDataSeriesItem[],\n ariaLabel: string,\n dateFormat: Parameters<typeof formatDate>[1] = DATE_FORMATS_INTL.MONTH_SHORT,\n) => {\n const data = [...dataSeries]\n .sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n .map((total) => {\n const label = total.date ? formatDate(parseISO(total.date), dateFormat) : (total.label ?? '')\n const amount = total.amount ?? 0\n\n return {\n ariaLabel: buildDynamicCopy(ariaLabel, label, formatCurrency(amount, '0.00')) as string,\n date: total.date ?? null,\n label,\n value: amount,\n formattedAmount: formatCurrency(amount, '0,0'),\n }\n })\n\n return data\n}\n\n/** A bar chart variant's look: its layout entry, resolved with defaults. */\nexport interface BarChartVariantLayout {\n chartHeight?: number\n color: string\n showMonthlyAmount: boolean\n unselectedOpacity?: number\n}\n\nexport const barChartVariant = (\n instanceSlot: InstanceSlot,\n categoryGuid: string | undefined,\n theme: Theme,\n widgetType?: string,\n): BarChartVariantLayout => {\n const { variant } = instanceSlot\n const barChartLayout = getLayoutConfig(theme)\n if (variant === BAR_CHART_VARIANTS.CATEGORY_COLOR && categoryGuid) {\n // Figma (Mini | Category Spending): the chart and the legend share the full chart's 122px.\n const chartHeight = widgetType === 'mini' ? 94 : undefined\n return { chartHeight, color: getCategoryColor(categoryGuid, theme), showMonthlyAmount: true }\n }\n const layout: Partial<BarChartVariantLayout> | undefined =\n barChartLayout[variant as keyof typeof barChartLayout]\n return {\n chartHeight: layout?.chartHeight,\n color: layout?.color ?? theme.palette.primary.main,\n showMonthlyAmount: layout?.showMonthlyAmount ?? true,\n unselectedOpacity: layout?.unselectedOpacity,\n }\n}\n"],"mappings":";;;;;;AAWA,IAAa,IAAqB;AAAA,EAChC,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,0BAA0B;AAC5B,GAaa,IAAiB,yBAEjB,IAAA,CAAmB,MACzB,IAID,EAAK,OACA,EAAK,KAAK,IAAA,CAAK,MAAM;AAC1B,QAAM,IAAY,CAAC;AAEnB,SAAA,EAAK,OAAO,IAAA,CAAK,GAAM,MAAU;AAC/B,IAAA,EAAK,CAAA,IAAQ,EAAE,CAAA;AAAA,EACjB,CAAC,GACM;AACT,CAAC,IAEM,CAAC,IAbD,CAAC,GAiBC,IAAA,CACX,GACA,GACA,IAA+C,EAAkB,gBAEpD,CAAC,GAAG,CAAU,EACxB,KAAA,CAAM,GAAG,MACJ,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D,EACA,IAAA,CAAK,MAAU;AACd,QAAM,IAAQ,EAAM,OAAO,EAAW,EAAS,EAAM,IAAI,GAAG,CAAU,IAAK,EAAM,SAAS,IACpF,IAAS,EAAM,UAAU;AAE/B,SAAO;AAAA,IACL,WAAW,EAAiB,GAAW,GAAO,EAAe,GAAQ,MAAM,CAAC;AAAA,IAC5E,MAAM,EAAM,QAAQ;AAAA,IACpB,OAAA;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,EAAe,GAAQ,KAAK;AAAA,EAC/C;AACF,CAEK,GAWI,IAAA,CACX,GACA,GACA,GACA,MAC0B;AAC1B,QAAM,EAAE,SAAA,EAAA,IAAY,GACd,IAAiB,EAAgB,CAAK;AAC5C,MAAI,MAAY,EAAmB,kBAAkB,EAGnD,QAAO;AAAA,IAAE,aADW,MAAe,SAAS,KAAK;AAAA,IAC3B,OAAO,EAAiB,GAAc,CAAK;AAAA,IAAG,mBAAmB;AAAA,EAAK;AAE9F,QAAM,IACJ,EAAe,CAAA;AACjB,SAAO;AAAA,IACL,aAAa,GAAQ;AAAA,IACrB,OAAO,GAAQ,SAAS,EAAM,QAAQ,QAAQ;AAAA,IAC9C,mBAAmB,GAAQ,qBAAqB;AAAA,IAChD,mBAAmB,GAAQ;AAAA,EAC7B;AACF"}
@@ -1,11 +1,5 @@
1
1
  import { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData';
2
2
  import { BlockProps } from '../../types';
3
- /**
4
- * `donut_chart_block`: a donut with a centre total and a two-row legend.
5
- *
6
- * Reads `main` and `legends` from `instance_slot.data` (the Insights 2.0 envelope; ditto variant
7
- * `deposit_summary` for Monthly Deposit Summary), falling back to the V1 `instance_slot_data` for
8
- * payloads that still carry the facts there. The palette comes from `./layout.ts` by variant.
9
- */
3
+ /** `donut_chart_block`: a donut with a centre total and a two-row legend; V1 `instance_slot_data` is the fallback. */
10
4
  declare const DonutChartBlock: ({ payload }: BlockProps<Partial<DonutChartBlockData>>) => import("react/jsx-runtime").JSX.Element | null;
11
5
  export default DonutChartBlock;
@@ -1,23 +1,21 @@
1
1
  import { formatValueByType as e } from "../../../CommonUtils.es.js";
2
2
  import v from "./DonutChart.es.js";
3
3
  import { getDonutChartColors as y } from "./utils.es.js";
4
- import { Fragment as f, jsx as i, jsxs as b } from "react/jsx-runtime";
4
+ import { Fragment as b, jsx as u, jsxs as f } from "react/jsx-runtime";
5
5
  import { useTheme as h } from "@mui/material/styles";
6
- var j = ({ payload: s }) => {
7
- const c = h(), { instance_slot: l, instance_slot_data: r } = s, { variant: m } = l, n = l.data, t = n?.main ? n : r ?? {}, _ = Array.isArray(t.legends) ? t.legends : [], { main: o } = t;
6
+ var j = ({ payload: i }) => {
7
+ const s = h(), { instance_slot: l, instance_slot_data: r } = i, { variant: c } = l, n = l.data, t = n?.main ? n : r ?? {}, m = Array.isArray(t.legends) ? t.legends : [], { main: o } = t;
8
8
  if (!o) return null;
9
- const u = y(m, {
9
+ const _ = y(c, {
10
10
  ...t,
11
11
  category_guid: t.category_guid ?? r?.category_guid
12
- }, c);
13
- if (!u) return null;
14
- const d = _.map((a, p) => ({
12
+ }, s), d = m.map((a, p) => ({
15
13
  value: a.value,
16
- color: u[p],
14
+ color: _[p],
17
15
  label: a.label,
18
- labelValue: /* @__PURE__ */ b(f, { children: [/* @__PURE__ */ i("b", { children: e(a.value, a.value_type ?? "amount", "0,0.00") }), a.additional_value && a.additional_value_type ? ` (${e(a.additional_value, a.additional_value_type, "0,0.00")})` : null] })
16
+ labelValue: /* @__PURE__ */ f(b, { children: [/* @__PURE__ */ u("b", { children: e(a.value, a.value_type ?? "amount", "0,0.00") }), a.additional_value && a.additional_value_type ? ` (${e(a.additional_value, a.additional_value_type, "0,0.00")})` : null] })
19
17
  }));
20
- return /* @__PURE__ */ i(v, {
18
+ return /* @__PURE__ */ u(v, {
21
19
  centerLabel: o.label,
22
20
  centerValue: e(Number(o.value), o.value_type, "0,0"),
23
21
  data: d
@@ -1 +1 @@
1
- {"version":3,"file":"DonutChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport type { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { formatValueByType } from '../../../CommonUtils'\n\nimport type { BlockProps } from '../../types'\n\nimport DonutChartV2 from './DonutChart'\nimport { getDonutChartColors } from './utils'\n\n/**\n * `donut_chart_block`: a donut with a centre total and a two-row legend.\n *\n * Reads `main` and `legends` from `instance_slot.data` (the Insights 2.0 envelope; ditto variant\n * `deposit_summary` for Monthly Deposit Summary), falling back to the V1 `instance_slot_data` for\n * payloads that still carry the facts there. The palette comes from `./layout.ts` by variant.\n */\nconst DonutChartBlock = ({ payload }: BlockProps<Partial<DonutChartBlockData>>) => {\n const theme = useTheme()\n const { instance_slot, instance_slot_data } = payload\n const { variant } = instance_slot\n // V2 contract first (`instance_slot.data`), V1 `instance_slot_data` as the legacy alias.\n const slotData = instance_slot.data as Partial<DonutChartBlockData> | undefined\n const blockData: Partial<DonutChartBlockData> = slotData?.main\n ? slotData\n : (instance_slot_data ?? {})\n const legends = Array.isArray(blockData.legends) ? blockData.legends : []\n const { main } = blockData\n\n if (!main) return null\n\n const colors = getDonutChartColors(\n variant,\n { ...blockData, category_guid: blockData.category_guid ?? instance_slot_data?.category_guid },\n theme,\n )\n\n if (!colors) return null\n\n const data = legends.map((legend, index) => ({\n value: legend.value,\n color: colors[index],\n label: legend.label,\n labelValue: (\n <>\n <b>{formatValueByType(legend.value, legend.value_type ?? 'amount', '0,0.00')}</b>\n {legend.additional_value && legend.additional_value_type\n ? ` (${formatValueByType(legend.additional_value, legend.additional_value_type, '0,0.00')})`\n : null}\n </>\n ),\n }))\n\n return (\n <DonutChartV2\n centerLabel={main.label}\n centerValue={formatValueByType(Number(main.value), main.value_type, '0,0')}\n data={data}\n />\n )\n}\n\nexport default DonutChartBlock\n"],"mappings":";;;;;AAkBA,IAAM,IAAA,CAAmB,EAAE,SAAA,EAAA,MAAwD;AACjF,QAAM,IAAQ,EAAS,GACjB,EAAE,eAAA,GAAe,oBAAA,EAAA,IAAuB,GACxC,EAAE,SAAA,EAAA,IAAY,GAEd,IAAW,EAAc,MACzB,IAA0C,GAAU,OACtD,IACC,KAAsB,CAAC,GACtB,IAAU,MAAM,QAAQ,EAAU,OAAO,IAAI,EAAU,UAAU,CAAC,GAClE,EAAE,MAAA,EAAA,IAAS;AAEjB,MAAI,CAAC,EAAM,QAAO;AAElB,QAAM,IAAS,EACb,GACA;AAAA,IAAE,GAAG;AAAA,IAAW,eAAe,EAAU,iBAAiB,GAAoB;AAAA,EAAc,GAC5F,CACF;AAEA,MAAI,CAAC,EAAQ,QAAO;AAEpB,QAAM,IAAO,EAAQ,IAAA,CAAK,GAAQ,OAAW;AAAA,IAC3C,OAAO,EAAO;AAAA,IACd,OAAO,EAAO,CAAA;AAAA,IACd,OAAO,EAAO;AAAA,IACd,YACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,KAAD,EAAA,UAAI,EAAkB,EAAO,OAAO,EAAO,cAAc,UAAU,QAAQ,EAAK,CAAA,GAC/E,EAAO,oBAAoB,EAAO,wBAC/B,KAAK,EAAkB,EAAO,kBAAkB,EAAO,uBAAuB,QAAQ,CAAA,MACtF,IACJ,EAAA,CAAA;AAAA,EAEN,EAAE;AAEF,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,aAAa,EAAK;AAAA,IAClB,aAAa,EAAkB,OAAO,EAAK,KAAK,GAAG,EAAK,YAAY,KAAK;AAAA,IACnE,MAAA;AAAA,EACP,CAAA;AAEL"}
1
+ {"version":3,"file":"DonutChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport type { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { formatValueByType } from '../../../CommonUtils'\n\nimport type { BlockProps } from '../../types'\n\nimport DonutChartV2 from './DonutChart'\nimport { getDonutChartColors } from './utils'\n\n/** `donut_chart_block`: a donut with a centre total and a two-row legend; V1 `instance_slot_data` is the fallback. */\nconst DonutChartBlock = ({ payload }: BlockProps<Partial<DonutChartBlockData>>) => {\n const theme = useTheme()\n const { instance_slot, instance_slot_data } = payload\n const { variant } = instance_slot\n // V2 contract first (`instance_slot.data`), V1 `instance_slot_data` as the legacy alias.\n const slotData = instance_slot.data as Partial<DonutChartBlockData> | undefined\n const blockData: Partial<DonutChartBlockData> = slotData?.main\n ? slotData\n : (instance_slot_data ?? {})\n const legends = Array.isArray(blockData.legends) ? blockData.legends : []\n const { main } = blockData\n\n if (!main) return null\n\n const colors = getDonutChartColors(\n variant,\n { ...blockData, category_guid: blockData.category_guid ?? instance_slot_data?.category_guid },\n theme,\n )\n\n const data = legends.map((legend, index) => ({\n value: legend.value,\n color: colors[index],\n label: legend.label,\n labelValue: (\n <>\n <b>{formatValueByType(legend.value, legend.value_type ?? 'amount', '0,0.00')}</b>\n {legend.additional_value && legend.additional_value_type\n ? ` (${formatValueByType(legend.additional_value, legend.additional_value_type, '0,0.00')})`\n : null}\n </>\n ),\n }))\n\n return (\n <DonutChartV2\n centerLabel={main.label}\n centerValue={formatValueByType(Number(main.value), main.value_type, '0,0')}\n data={data}\n />\n )\n}\n\nexport default DonutChartBlock\n"],"mappings":";;;;;AAYA,IAAM,IAAA,CAAmB,EAAE,SAAA,EAAA,MAAwD;AACjF,QAAM,IAAQ,EAAS,GACjB,EAAE,eAAA,GAAe,oBAAA,EAAA,IAAuB,GACxC,EAAE,SAAA,EAAA,IAAY,GAEd,IAAW,EAAc,MACzB,IAA0C,GAAU,OACtD,IACC,KAAsB,CAAC,GACtB,IAAU,MAAM,QAAQ,EAAU,OAAO,IAAI,EAAU,UAAU,CAAC,GAClE,EAAE,MAAA,EAAA,IAAS;AAEjB,MAAI,CAAC,EAAM,QAAO;AAElB,QAAM,IAAS,EACb,GACA;AAAA,IAAE,GAAG;AAAA,IAAW,eAAe,EAAU,iBAAiB,GAAoB;AAAA,EAAc,GAC5F,CACF,GAEM,IAAO,EAAQ,IAAA,CAAK,GAAQ,OAAW;AAAA,IAC3C,OAAO,EAAO;AAAA,IACd,OAAO,EAAO,CAAA;AAAA,IACd,OAAO,EAAO;AAAA,IACd,YACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,KAAD,EAAA,UAAI,EAAkB,EAAO,OAAO,EAAO,cAAc,UAAU,QAAQ,EAAK,CAAA,GAC/E,EAAO,oBAAoB,EAAO,wBAC/B,KAAK,EAAkB,EAAO,kBAAkB,EAAO,uBAAuB,QAAQ,CAAA,MACtF,IACJ,EAAA,CAAA;AAAA,EAEN,EAAE;AAEF,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,aAAa,EAAK;AAAA,IAClB,aAAa,EAAkB,OAAO,EAAK,KAAK,GAAG,EAAK,YAAY,KAAK;AAAA,IACnE,MAAA;AAAA,EACP,CAAA;AAEL"}
@@ -1,19 +1,15 @@
1
1
  import { Theme } from '@mui/material/styles';
2
- export declare const getLayoutConfig: (theme: Theme) => {
3
- CostOfLivingToIncome: {
4
- secondaryColor: string;
5
- };
6
- MonthlyDepositSummaryV2: {
7
- colors: string[];
8
- };
9
- MonthlyNonEssentialCategorySummaryV2: {
10
- colors: (string | undefined)[];
11
- };
12
- CreditCardCloseToLimit: {
13
- colors: string[];
14
- };
15
- CreditUtilization: {
16
- dynamicPrimary: string;
17
- secondaryColor: string;
18
- };
2
+ /** Ditto's `donut_chart_block` variants; the template-name keys below are V1 aliases. */
3
+ export declare const donutChartVariant: {
4
+ readonly DepositSummary: "deposit_summary";
19
5
  };
6
+ export type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant];
7
+ export type DonutChartLayoutConfig = {
8
+ colors: [string, string];
9
+ } | {
10
+ secondaryColor: string;
11
+ } | {
12
+ dynamicPrimary: 'creditUtilization';
13
+ secondaryColor: string;
14
+ };
15
+ export declare const getLayoutConfig: (theme: Theme) => Record<string, DonutChartLayoutConfig>;
@@ -1,15 +1,20 @@
1
- var t = (o) => ({
2
- CostOfLivingToIncome: { secondaryColor: o.palette.divider },
3
- MonthlyDepositSummaryV2: { colors: [o.palette.success.main, o.palette.success.light] },
4
- MonthlyNonEssentialCategorySummaryV2: { colors: [o.palette.chartMono.chartMono3, o.palette.chartMono.chartMono5] },
5
- CreditCardCloseToLimit: { colors: [o.palette.warning.main, o.palette.divider] },
6
- CreditUtilization: {
7
- dynamicPrimary: "creditUtilization",
8
- secondaryColor: o.palette.divider
9
- }
10
- });
1
+ var a = { DepositSummary: "deposit_summary" }, r = (t) => {
2
+ const o = { colors: [t.palette.success.main, t.palette.success.light] };
3
+ return {
4
+ [a.DepositSummary]: o,
5
+ CostOfLivingToIncome: { secondaryColor: t.palette.divider },
6
+ MonthlyDepositSummaryV2: o,
7
+ MonthlyNonEssentialCategorySummaryV2: { colors: [t.palette.chartMono.chartMono3 ?? t.palette.text.primary, t.palette.chartMono.chartMono5 ?? t.palette.divider] },
8
+ CreditCardCloseToLimit: { colors: [t.palette.warning.main, t.palette.divider] },
9
+ CreditUtilization: {
10
+ dynamicPrimary: "creditUtilization",
11
+ secondaryColor: t.palette.divider
12
+ }
13
+ };
14
+ };
11
15
  export {
12
- t as getLayoutConfig
16
+ a as donutChartVariant,
17
+ r as getLayoutConfig
13
18
  };
14
19
 
15
20
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\nexport const getLayoutConfig = (theme: Theme) => {\n return {\n CostOfLivingToIncome: {\n secondaryColor: theme.palette.divider,\n },\n MonthlyDepositSummaryV2: {\n colors: [theme.palette.success.main, theme.palette.success.light],\n },\n MonthlyNonEssentialCategorySummaryV2: {\n colors: [theme.palette.chartMono.chartMono3, theme.palette.chartMono.chartMono5],\n },\n CreditCardCloseToLimit: {\n colors: [theme.palette.warning.main, theme.palette.divider],\n },\n CreditUtilization: {\n dynamicPrimary: 'creditUtilization',\n secondaryColor: theme.palette.divider,\n },\n }\n}\n"],"mappings":"AACA,IAAa,IAAA,CAAmB,OACvB;AAAA,EACL,sBAAsB,EACpB,gBAAgB,EAAM,QAAQ,QAChC;AAAA,EACA,yBAAyB,EACvB,QAAQ,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,QAAQ,KAAK,EAClE;AAAA,EACA,sCAAsC,EACpC,QAAQ,CAAC,EAAM,QAAQ,UAAU,YAAY,EAAM,QAAQ,UAAU,UAAU,EACjF;AAAA,EACA,wBAAwB,EACtB,QAAQ,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,OAAO,EAC5D;AAAA,EACA,mBAAmB;AAAA,IACjB,gBAAgB;AAAA,IAChB,gBAAgB,EAAM,QAAQ;AAAA,EAChC;AACF"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\n/** Ditto's `donut_chart_block` variants; the template-name keys below are V1 aliases. */\nexport const donutChartVariant = {\n DepositSummary: 'deposit_summary',\n} as const\n\nexport type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant]\n\nexport type DonutChartLayoutConfig =\n | { colors: [string, string] }\n | { secondaryColor: string }\n | { dynamicPrimary: 'creditUtilization'; secondaryColor: string }\n\nexport const getLayoutConfig = (theme: Theme): Record<string, DonutChartLayoutConfig> => {\n const depositSummary: DonutChartLayoutConfig = {\n colors: [theme.palette.success.main, theme.palette.success.light],\n }\n\n return {\n [donutChartVariant.DepositSummary]: depositSummary,\n\n // V1 aliases: the template name as the variant.\n CostOfLivingToIncome: {\n secondaryColor: theme.palette.divider,\n },\n MonthlyDepositSummaryV2: depositSummary,\n MonthlyNonEssentialCategorySummaryV2: {\n colors: [\n theme.palette.chartMono.chartMono3 ?? theme.palette.text.primary,\n theme.palette.chartMono.chartMono5 ?? theme.palette.divider,\n ],\n },\n CreditCardCloseToLimit: {\n colors: [theme.palette.warning.main, theme.palette.divider],\n },\n CreditUtilization: {\n dynamicPrimary: 'creditUtilization',\n secondaryColor: theme.palette.divider,\n },\n }\n}\n"],"mappings":"AAGA,IAAa,IAAoB,EAC/B,gBAAgB,kBAClB,GASa,IAAA,CAAmB,MAAyD;AACvF,QAAM,IAAyC,EAC7C,QAAQ,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,QAAQ,KAAK,EAClE;AAEA,SAAO;AAAA,IACJ,CAAA,EAAkB,cAAA,GAAiB;AAAA,IAGpC,sBAAsB,EACpB,gBAAgB,EAAM,QAAQ,QAChC;AAAA,IACA,yBAAyB;AAAA,IACzB,sCAAsC,EACpC,QAAQ,CACN,EAAM,QAAQ,UAAU,cAAc,EAAM,QAAQ,KAAK,SACzD,EAAM,QAAQ,UAAU,cAAc,EAAM,QAAQ,OACtD,EACF;AAAA,IACA,wBAAwB,EACtB,QAAQ,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,OAAO,EAC5D;AAAA,IACA,mBAAmB;AAAA,MACjB,gBAAgB;AAAA,MAChB,gBAAgB,EAAM,QAAQ;AAAA,IAChC;AAAA,EACF;AACF"}
@@ -1,3 +1,7 @@
1
1
  import { Theme } from '@mui/material/styles';
2
- import { InsightsInstanceSlotData } from '../../../../core/types/InsightsInstanceSlotData';
3
- export declare const getDonutChartColors: (variant: string | null | undefined, blockData: InsightsInstanceSlotData, theme: Theme) => [string, string] | null;
2
+ import { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData';
3
+ /** The facts the palette may read: the centre value (credit utilization) and the category. */
4
+ export type DonutColorData = Partial<DonutChartBlockData> & {
5
+ category_guid?: string;
6
+ };
7
+ export declare const getDonutChartColors: (variant: string | null | undefined, blockData: DonutColorData, theme: Theme) => [string, string];