@mx-cartographer/experiences 9.5.3 → 9.6.0
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.
- package/CHANGELOG.md +7 -0
- package/dist/common/components/CurrencyDialog.d.ts +10 -2
- package/dist/common/components/CurrencyDialog.es.js +56 -50
- package/dist/common/components/CurrencyDialog.es.js.map +1 -1
- package/dist/core/index.es.js +111 -109
- package/dist/core/types/Insights.d.ts +33 -16
- package/dist/core/types/Insights.es.js +6 -0
- package/dist/core/types/Insights.es.js.map +1 -0
- package/dist/core/types/index.d.ts +2 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +21 -0
- package/dist/core/types/localization/index.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +31 -25
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +13 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +128 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/index.d.ts +1 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +14 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +14 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.d.ts +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.d.ts +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.d.ts +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.d.ts +5 -2
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +36 -35
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/WithdrawalBlock/WithdrawalBlock.d.ts +2 -2
- package/dist/insights-v2/blocks/ComponentBlocks/WithdrawalBlock/WithdrawalBlock.es.js +6 -5
- package/dist/insights-v2/blocks/ComponentBlocks/WithdrawalBlock/WithdrawalBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.d.ts +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +22 -22
- package/dist/insights-v2/components/CompactInsightCard.d.ts +4 -4
- package/dist/insights-v2/components/CompactInsightCard.es.js +50 -46
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/runCtaAction.es.js +10 -10
- package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -1
- package/dist/insights-v2/index.es.js +17 -17
- package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js +2 -1
- package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.d.ts +2 -1
- package/dist/insights-v2/mappings/blocks.es.js +62 -62
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/insights-v2/mappings/hasDrawerBlock.d.ts +1 -0
- package/dist/insights-v2/mappings/hasDrawerBlock.es.js +13 -0
- package/dist/insights-v2/mappings/hasDrawerBlock.es.js.map +1 -0
- package/dist/insights-v2/resolveInsightRender.d.ts +8 -5
- package/dist/insights-v2/resolveInsightRender.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +32 -31
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { ContactSupportActionBlock as
|
|
2
|
-
import { actionBlocksKey as
|
|
3
|
-
import { BarchartBlock as
|
|
4
|
-
import { DoubleBarChartBlock as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { ContactSupportActionBlock as m } from "../actionBlocks/ContactSupportActionBlock.es.js";
|
|
2
|
+
import { actionBlocksKey as o } from "./actionBlocksKey.es.js";
|
|
3
|
+
import { BarchartBlock as l } from "../blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js";
|
|
4
|
+
import { DoubleBarChartBlock as n } from "../blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js";
|
|
5
|
+
import p from "../blocks/ChartBlocks/StepChartBlock/StepChartBlock.es.js";
|
|
6
|
+
import _ from "../blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js";
|
|
7
7
|
import s from "../blocks/ChartBlocks/DoubleProgressBarBlock/DoubleProgressBarBlock.es.js";
|
|
8
8
|
import k from "../blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js";
|
|
9
9
|
import C from "../blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js";
|
|
10
10
|
import B from "../blocks/ComponentBlocks/DirectDepositBlock/DirectDepositBlock.es.js";
|
|
11
11
|
import { BudgetBlock as T } from "../blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js";
|
|
12
|
-
import
|
|
13
|
-
import { TransactionBlock as
|
|
14
|
-
import
|
|
12
|
+
import A from "../blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js";
|
|
13
|
+
import { TransactionBlock as f } from "../blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js";
|
|
14
|
+
import u from "../blocks/ComponentBlocks/WithdrawalBlock/WithdrawalBlock.es.js";
|
|
15
15
|
import O from "../blocks/ImageBlocks/ImageBlock.es.js";
|
|
16
|
-
import { SVGImageBlock as
|
|
17
|
-
import { PlaceholderActionBlock as
|
|
18
|
-
import { getMakeTransferDrawerTitle as
|
|
19
|
-
import { MakeTransferActionBlockLayer as
|
|
20
|
-
import { getDrawerHeaderTitle as
|
|
21
|
-
import { TransactionDetailsBlock as
|
|
16
|
+
import { SVGImageBlock as N } from "../blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js";
|
|
17
|
+
import { PlaceholderActionBlock as b } from "../actionBlocks/PlaceholderActionBlock.es.js";
|
|
18
|
+
import { getMakeTransferDrawerTitle as I } from "../actionBlocks/MakeTransferActionBlock/layout.es.js";
|
|
19
|
+
import { MakeTransferActionBlockLayer as h } from "../actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js";
|
|
20
|
+
import { getDrawerHeaderTitle as g } from "../actionBlocks/TransactionHistoryBlock/utils.es.js";
|
|
21
|
+
import { TransactionDetailsBlock as d } from "../actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
22
22
|
import { useTransactionDetailsPrepare as a } from "../actionBlocks/TransactionDetailsBlock/useTransactionDetailsPrepare.es.js";
|
|
23
23
|
import { TransactionHistoryBlock as L } from "../actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js";
|
|
24
24
|
import { useRecurringTransactionPrepare as i } from "../actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
|
|
25
|
-
import { RecurringTransactionBlock as
|
|
25
|
+
import { RecurringTransactionBlock as P } from "../actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js";
|
|
26
26
|
import { TransactionListBlock as R } from "../actionBlocks/TransactionListBlock/TransactionListBlock.es.js";
|
|
27
|
-
import { RemainingCashBlock as
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return !!o && !D.has(o);
|
|
36
|
-
}, co = {
|
|
37
|
-
[r.PLACEHOLDER_ACTION_BLOCK]: {
|
|
38
|
-
Component: N,
|
|
39
|
-
usePrepare: e,
|
|
27
|
+
import { RemainingCashBlock as D } from "../actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js";
|
|
28
|
+
import { hasDrawerBlock as co } from "./hasDrawerBlock.es.js";
|
|
29
|
+
import { AmountInputModalBlock as S } from "../actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js";
|
|
30
|
+
var t = (e) => {
|
|
31
|
+
}, lo = {
|
|
32
|
+
[o.PLACEHOLDER_ACTION_BLOCK]: {
|
|
33
|
+
Component: b,
|
|
34
|
+
usePrepare: t,
|
|
40
35
|
title: () => "Action Block Layer Drilldown"
|
|
41
36
|
},
|
|
42
|
-
[
|
|
43
|
-
Component:
|
|
44
|
-
usePrepare:
|
|
45
|
-
title:
|
|
37
|
+
[o.MAKE_TRANSFER_ACTION_BLOCK]: {
|
|
38
|
+
Component: h,
|
|
39
|
+
usePrepare: t,
|
|
40
|
+
title: I
|
|
46
41
|
},
|
|
47
|
-
[
|
|
42
|
+
[o.TRANSCATION_HISTORY_ACTION_BLOCK]: {
|
|
48
43
|
Component: L,
|
|
49
|
-
usePrepare:
|
|
50
|
-
title:
|
|
44
|
+
usePrepare: t,
|
|
45
|
+
title: g
|
|
51
46
|
},
|
|
52
|
-
[
|
|
53
|
-
Component:
|
|
47
|
+
[o.TRANSACTION_DETAILS_ACTION_BLOCK]: {
|
|
48
|
+
Component: d,
|
|
54
49
|
usePrepare: a,
|
|
55
50
|
title: () => "Transaction Details"
|
|
56
51
|
},
|
|
57
|
-
[
|
|
58
|
-
Component:
|
|
52
|
+
[o.RECURRING_TRANSACTION_ACTION_BLOCK]: {
|
|
53
|
+
Component: P,
|
|
59
54
|
usePrepare: i,
|
|
60
|
-
title: (
|
|
55
|
+
title: (e, r) => r.recurring?.expense_details ?? ""
|
|
61
56
|
},
|
|
62
|
-
[
|
|
63
|
-
Component:
|
|
57
|
+
[o.REMAINING_CASH_ACTION_BLOCK]: {
|
|
58
|
+
Component: D,
|
|
64
59
|
usePrepare: i,
|
|
65
|
-
title: (
|
|
60
|
+
title: (e, r) => r.insights_feed?.remaining_cash?.title ?? ""
|
|
66
61
|
},
|
|
67
|
-
[
|
|
68
|
-
Component:
|
|
69
|
-
usePrepare:
|
|
70
|
-
title: (
|
|
62
|
+
[o.CONTACT_SUPPORT_ACTION_BLOCK]: {
|
|
63
|
+
Component: m,
|
|
64
|
+
usePrepare: t,
|
|
65
|
+
title: (e, r) => r.help?.request_support ?? ""
|
|
71
66
|
},
|
|
72
|
-
[
|
|
67
|
+
[o.TRANSACTION_LIST_ACTION_BLOCK]: {
|
|
73
68
|
Component: R,
|
|
74
69
|
usePrepare: a,
|
|
75
|
-
title: (
|
|
70
|
+
title: (e, r, c) => c?.insights_payload?.title ?? ""
|
|
71
|
+
},
|
|
72
|
+
[o.AMOUNT_INPUT_MODAL_ACTION_BLOCK]: {
|
|
73
|
+
Component: S,
|
|
74
|
+
presentation: "modal",
|
|
75
|
+
usePrepare: t
|
|
76
76
|
}
|
|
77
|
-
},
|
|
77
|
+
}, no = {
|
|
78
78
|
account_block: k,
|
|
79
79
|
account_switch_block: C,
|
|
80
80
|
direct_deposit_block: B,
|
|
81
|
-
bar_chart_block:
|
|
81
|
+
bar_chart_block: l,
|
|
82
82
|
budget_block: T,
|
|
83
|
-
donut_chart_block:
|
|
84
|
-
double_bar_chart_block:
|
|
83
|
+
donut_chart_block: _,
|
|
84
|
+
double_bar_chart_block: n,
|
|
85
85
|
double_progress_bar_block: s,
|
|
86
86
|
image_block: O,
|
|
87
|
-
save_extra_block:
|
|
88
|
-
step_chart_block:
|
|
89
|
-
svg_image_block:
|
|
90
|
-
withdrawal_block:
|
|
91
|
-
transaction_block:
|
|
87
|
+
save_extra_block: A,
|
|
88
|
+
step_chart_block: p,
|
|
89
|
+
svg_image_block: N,
|
|
90
|
+
withdrawal_block: u,
|
|
91
|
+
transaction_block: f
|
|
92
92
|
};
|
|
93
93
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
lo as actionBlocks,
|
|
95
|
+
no as blocks,
|
|
96
|
+
co as hasDrawerBlock
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
//# sourceMappingURL=blocks.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.es.js","names":[],"sources":["../../../src/insights-v2/mappings/blocks.ts"],"sourcesContent":["import {\n AccountBlock,\n AccountSwitchBlock,\n DirectDepositBlock,\n BarchartBlock,\n BudgetBlock,\n DonutChartBlock,\n DoubleBarChartBlock,\n DoubleProgressBarBlock,\n SaveExtraBlock,\n SVGImageBlock,\n WithdrawalBlock,\n TransactionBlock,\n} from '../blocks'\nimport StepChartBlock from '../blocks/ChartBlocks/StepChartBlock'\nimport ImageBlock from '../blocks/ImageBlocks/ImageBlock'\n\nimport type { Beat, GlobalCopy, InsightsPayload } from '../../core'\nimport { ContactSupportActionBlock } from '../actionBlocks/ContactSupportActionBlock'\nimport { PlaceholderActionBlock } from '../actionBlocks/PlaceholderActionBlock'\nimport { MakeTransferActionBlockLayer } from '../actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer'\nimport { getMakeTransferDrawerTitle } from '../actionBlocks/MakeTransferActionBlock/layout'\nimport { TransactionHistoryBlock } from '../actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock'\nimport { getDrawerHeaderTitle } from '../actionBlocks/TransactionHistoryBlock/utils'\nimport {\n TransactionDetailsBlock,\n useTransactionDetailsPrepare,\n} from '../actionBlocks/TransactionDetailsBlock'\nimport {\n RecurringTransactionBlock,\n useRecurringTransactionPrepare,\n} from '../actionBlocks/RecurringTransactionBlock'\nimport { TransactionListBlock } from '../actionBlocks/TransactionListBlock'\nimport { RemainingCashBlock } from '../actionBlocks/RemainingCashBlock'\n// Keys live in ./actionBlocksKey (imported directly by chart blocks/tests too) to avoid a\n// circular import between this module and the chart blocks — see that file for details.\nimport { actionBlocksKey } from './actionBlocksKey'\n\n// Drilldown indexes are not passed down: action blocks read them from\n// InsightsV2Store (useInsightsV2Store().actionDrawer).\nexport interface ActionBlockProps {\n beat: Beat\n}\n\nconst noop = (_: ActionBlockProps) => {}\n\n//
|
|
1
|
+
{"version":3,"file":"blocks.es.js","names":[],"sources":["../../../src/insights-v2/mappings/blocks.ts"],"sourcesContent":["import {\n AccountBlock,\n AccountSwitchBlock,\n DirectDepositBlock,\n BarchartBlock,\n BudgetBlock,\n DonutChartBlock,\n DoubleBarChartBlock,\n DoubleProgressBarBlock,\n SaveExtraBlock,\n SVGImageBlock,\n WithdrawalBlock,\n TransactionBlock,\n} from '../blocks'\nimport StepChartBlock from '../blocks/ChartBlocks/StepChartBlock'\nimport ImageBlock from '../blocks/ImageBlocks/ImageBlock'\n\nimport type { Beat, GlobalCopy, InsightsPayload } from '../../core'\nimport { ContactSupportActionBlock } from '../actionBlocks/ContactSupportActionBlock'\nimport { PlaceholderActionBlock } from '../actionBlocks/PlaceholderActionBlock'\nimport { MakeTransferActionBlockLayer } from '../actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer'\nimport { getMakeTransferDrawerTitle } from '../actionBlocks/MakeTransferActionBlock/layout'\nimport { TransactionHistoryBlock } from '../actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock'\nimport { getDrawerHeaderTitle } from '../actionBlocks/TransactionHistoryBlock/utils'\nimport {\n TransactionDetailsBlock,\n useTransactionDetailsPrepare,\n} from '../actionBlocks/TransactionDetailsBlock'\nimport {\n RecurringTransactionBlock,\n useRecurringTransactionPrepare,\n} from '../actionBlocks/RecurringTransactionBlock'\nimport { TransactionListBlock } from '../actionBlocks/TransactionListBlock'\nimport { RemainingCashBlock } from '../actionBlocks/RemainingCashBlock'\nimport { AmountInputModalBlock } from '../actionBlocks/AmountInputModalBlock'\n// Keys live in ./actionBlocksKey (imported directly by chart blocks/tests too) to avoid a\n// circular import between this module and the chart blocks — see that file for details.\nimport { actionBlocksKey } from './actionBlocksKey'\n\n// Drilldown indexes are not passed down: action blocks read them from\n// InsightsV2Store (useInsightsV2Store().actionDrawer).\nexport interface ActionBlockProps {\n beat: Beat\n}\n\nconst noop = (_: ActionBlockProps) => {}\n\n// Re-exported so existing `hasDrawerBlock` imports from this module keep working.\nexport { hasDrawerBlock } from './hasDrawerBlock'\n\nexport interface ActionBlockEntry {\n Component: React.ComponentType<ActionBlockProps>\n usePrepare: (props: ActionBlockProps) => void // required; default to noop in each entry\n // Resolves the drawer title from the clicked CTA's variant + copy, with the beat available\n // for blocks that title from beat fields (e.g. transaction-list reads insights_payload.title).\n // Falls back to the CTA label when the resolver returns an empty string / is absent.\n title?: (variant: string | null | undefined, copy: GlobalCopy, beat?: Beat) => string\n // 'modal' blocks render their own dialog, so the layer skips the Drawer (and its title) and mounts\n // the block only while it is open for this beat. Defaults to 'drawer'.\n presentation?: 'drawer' | 'modal'\n}\n\n// Registry of drawer drilldowns, keyed by the `block` name the backend sends\n// on a beat's CTA. To add one: create a component taking ActionBlockProps,\n// read the clicked indexes from useInsightsV2Store().actionDrawer, and\n// register it here. Add\n// `usePrepare` when the block needs to load data before rendering.\n\nexport const actionBlocks = {\n [actionBlocksKey.PLACEHOLDER_ACTION_BLOCK]: {\n Component: PlaceholderActionBlock,\n usePrepare: noop,\n title: () => 'Action Block Layer Drilldown',\n },\n [actionBlocksKey.MAKE_TRANSFER_ACTION_BLOCK]: {\n Component: MakeTransferActionBlockLayer,\n usePrepare: noop,\n title: getMakeTransferDrawerTitle,\n },\n [actionBlocksKey.TRANSCATION_HISTORY_ACTION_BLOCK]: {\n Component: TransactionHistoryBlock,\n usePrepare: noop,\n title: getDrawerHeaderTitle,\n },\n [actionBlocksKey.TRANSACTION_DETAILS_ACTION_BLOCK]: {\n Component: TransactionDetailsBlock,\n usePrepare: useTransactionDetailsPrepare,\n title: () => 'Transaction Details',\n },\n // Expense Details for one recurring subscription. Which subscription a beat names is resolved in\n // `RecurringTransactionBlock/subscriptionBeats.ts`, not through this registry.\n [actionBlocksKey.RECURRING_TRANSACTION_ACTION_BLOCK]: {\n Component: RecurringTransactionBlock,\n usePrepare: useRecurringTransactionPrepare,\n title: (_variant, copy) => copy.recurring?.expense_details ?? '',\n },\n // Remaining Cash for the Payday Cash Left Over Status beat. Store-driven: reuses the recurring\n // loader, which also loads accounts and categories, so CashflowStore's computeds are ready.\n [actionBlocksKey.REMAINING_CASH_ACTION_BLOCK]: {\n Component: RemainingCashBlock,\n usePrepare: useRecurringTransactionPrepare,\n title: (_variant, copy) => copy.insights_feed?.remaining_cash?.title ?? '',\n },\n // The block renders its own drawer (the help module's RequestSupport) on top of the action\n // drawer, so the action drawer's title is the CTA label.\n [actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK]: {\n Component: ContactSupportActionBlock,\n usePrepare: noop,\n title: (_variant, copy) => copy.help?.request_support ?? '',\n },\n [actionBlocksKey.TRANSACTION_LIST_ACTION_BLOCK]: {\n Component: TransactionListBlock,\n usePrepare: useTransactionDetailsPrepare,\n title: (_variant, _copy, beat) => beat?.insights_payload?.title ?? '',\n },\n // One whole-dollar setting in a dialog; the CTA variant picks which (low-balance threshold or\n // safety net). A modal: no drawer, so no drawer title.\n [actionBlocksKey.AMOUNT_INPUT_MODAL_ACTION_BLOCK]: {\n Component: AmountInputModalBlock,\n presentation: 'modal',\n // Loads inside the block: it mounts only while open, so mounting is the open-time load.\n usePrepare: noop,\n },\n} as Record<string, ActionBlockEntry>\n\nexport const blocks = {\n account_block: AccountBlock,\n account_switch_block: AccountSwitchBlock,\n direct_deposit_block: DirectDepositBlock,\n bar_chart_block: BarchartBlock,\n budget_block: BudgetBlock,\n donut_chart_block: DonutChartBlock,\n double_bar_chart_block: DoubleBarChartBlock,\n double_progress_bar_block: DoubleProgressBarBlock,\n image_block: ImageBlock,\n save_extra_block: SaveExtraBlock,\n step_chart_block: StepChartBlock,\n svg_image_block: SVGImageBlock,\n withdrawal_block: With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AkC;AAAA,IACjD,WAAW;AAAA,IACX,cAAc;AAAA,IAEd,YAAY;AAAA,EACd;AACF,GAEa,KAAS;AAAA,EACpB,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,mBAAmB;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasDrawerBlock: (block?: string | null) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasDrawerBlock.es.js","names":[],"sources":["../../../src/insights-v2/mappings/hasDrawerBlock.ts"],"sourcesContent":["// Kept out of `blocks.ts` for the same reason as `actionBlocksKey.ts`: `ctaActions` needs it, and\n// action blocks import `ctaActions` (for in-drawer saves), so importing it from the registry module\n// would close a cycle back into `blocks.ts` while it is still initialising.\n\n// A CTA opens a drawer only when it carries a real `block`. The backend may send\n// an empty/absent block (or the literal strings \"null\"/\"undefined\") for CTAs\n// that trigger something else (e.g. a postMessage) instead of a drilldown.\nconst NON_BLOCK_VALUES = new Set(['', 'null', 'undefined'])\nexport const hasDrawerBlock = (block?: string | null): boolean => {\n const normalized = block?.trim().toLowerCase()\n return !!normalized && !NON_BLOCK_VALUES.has(normalized)\n}\n"],"mappings":"AAOA,IAAM,IAAmB,oBAAI,IAAI;AAAA,EAAC;AAAA,EAAI;AAAA,EAAQ;AAAW,CAAC,GAC7C,IAAA,CAAkB,MAAmC;AAChE,QAAM,IAAa,GAAO,KAAK,EAAE,YAAY;AAC7C,SAAO,CAAC,CAAC,KAAc,CAAC,EAAiB,IAAI,CAAU;AACzD"}
|
|
@@ -21,10 +21,13 @@ export type InsightRender = 'legacy' | 'v2' | 'error';
|
|
|
21
21
|
* no block, no logo and no footer, and the failure would never surface. An absent flag (older firefly,
|
|
22
22
|
* cortex) renders the legacy path unchanged.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* `
|
|
28
|
-
*
|
|
24
|
+
* The gate checks only that `instance_slot` is an object and `description` is present. It does not
|
|
25
|
+
* look inside the slot: an empty `{}` is a valid envelope and resolves to `v2`, because a beat
|
|
26
|
+
* whose template has no ditto config names no block, and the card renders its copy and CTAs alone.
|
|
27
|
+
* So `block` is optional on `InstanceSlot` and a renderer must not dereference it unguarded.
|
|
28
|
+
*
|
|
29
|
+
* A payload missing `description` resolves to `error` instead: all three renderers — `BaseLayout`,
|
|
30
|
+
* `CompactInsightCard` and the micro `InsightCard` — paint `description.html_text` unguarded, so
|
|
31
|
+
* that one would throw.
|
|
29
32
|
*/
|
|
30
33
|
export declare const resolveInsightRender: (beat?: Beat | null) => InsightRender;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveInsightRender.es.js","names":[],"sources":["../../src/insights-v2/resolveInsightRender.ts"],"sourcesContent":["import type { Beat } from '../core'\n\n/**\n * Which renderer draws a beat:\n * - `legacy` — the per-template legacy component (feed, mini, micro) or the legacy caption / embedded\n * `switch` (transaction row, details drawer).\n * - `v2` — `BaseLayout` (full, mini) or `CompactInsightCard` (micro, embedded) from `insights_payload`.\n * - `error` — `InsightErrorCard`: the beat is flagged but its envelope is missing.\n */\nexport type InsightRender = 'legacy' | 'v2' | 'error'\n\n/**\n * The single gate every surface calls. Two facts decide: `beat.is_insights_v2` (written by firefly\n * when the insight's Insights 2.0 flag is on) and whether the envelope is present.\n *\n * | `is_insights_v2` | envelope | result |\n * | false / absent | any | `legacy` |\n * | true | non-empty | `v2` |\n * | true | empty | `error` |\n *\n * `error` is never downgraded to `legacy`: a flagged insight's legacy copy fields are filled from the\n * same V2 copy block, so a failed envelope would otherwise render a plausible legacy-looking card with\n * no block, no logo and no footer, and the failure would never surface. An absent flag (older firefly,\n * cortex) renders the legacy path unchanged.\n *\n *
|
|
1
|
+
{"version":3,"file":"resolveInsightRender.es.js","names":[],"sources":["../../src/insights-v2/resolveInsightRender.ts"],"sourcesContent":["import type { Beat } from '../core'\n\n/**\n * Which renderer draws a beat:\n * - `legacy` — the per-template legacy component (feed, mini, micro) or the legacy caption / embedded\n * `switch` (transaction row, details drawer).\n * - `v2` — `BaseLayout` (full, mini) or `CompactInsightCard` (micro, embedded) from `insights_payload`.\n * - `error` — `InsightErrorCard`: the beat is flagged but its envelope is missing.\n */\nexport type InsightRender = 'legacy' | 'v2' | 'error'\n\n/**\n * The single gate every surface calls. Two facts decide: `beat.is_insights_v2` (written by firefly\n * when the insight's Insights 2.0 flag is on) and whether the envelope is present.\n *\n * | `is_insights_v2` | envelope | result |\n * | false / absent | any | `legacy` |\n * | true | non-empty | `v2` |\n * | true | empty | `error` |\n *\n * `error` is never downgraded to `legacy`: a flagged insight's legacy copy fields are filled from the\n * same V2 copy block, so a failed envelope would otherwise render a plausible legacy-looking card with\n * no block, no logo and no footer, and the failure would never surface. An absent flag (older firefly,\n * cortex) renders the legacy path unchanged.\n *\n * The gate checks only that `instance_slot` is an object and `description` is present. It does not\n * look inside the slot: an empty `{}` is a valid envelope and resolves to `v2`, because a beat\n * whose template has no ditto config names no block, and the card renders its copy and CTAs alone.\n * So `block` is optional on `InstanceSlot` and a renderer must not dereference it unguarded.\n *\n * A payload missing `description` resolves to `error` instead: all three renderers — `BaseLayout`,\n * `CompactInsightCard` and the micro `InsightCard` — paint `description.html_text` unguarded, so\n * that one would throw.\n */\nexport const resolveInsightRender = (beat?: Beat | null): InsightRender => {\n if (!beat?.is_insights_v2) return 'legacy'\n\n const payload = beat.insights_payload\n\n return payload?.instance_slot && payload.description ? 'v2' : 'error'\n}\n"],"mappings":"AAkCA,IAAa,IAAA,CAAwB,MAAsC;AACzE,MAAI,CAAC,GAAM,eAAgB,QAAO;AAElC,QAAM,IAAU,EAAK;AAErB,SAAO,GAAS,iBAAiB,EAAQ,cAAc,OAAO;AAChE"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import x from "../../insights-v2/
|
|
3
|
-
import B from "../../insights-v2/components/
|
|
4
|
-
import
|
|
5
|
-
import S from "../
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
1
|
+
import { slot as k } from "../../core/types/Insights.es.js";
|
|
2
|
+
import { resolveInsightRender as x } from "../../insights-v2/resolveInsightRender.es.js";
|
|
3
|
+
import B from "../../insights-v2/components/LogoFromGuid.es.js";
|
|
4
|
+
import M from "../../insights-v2/components/InsightErrorCard.es.js";
|
|
5
|
+
import { ON_CLICK_EVENT as R, ON_VIEW_EVENT as W, ON_VIEW_FIRST_TIME_EVENT as S } from "../constants/Analytics.es.js";
|
|
6
|
+
import F from "../beaticons/BeatMaterialIcon.es.js";
|
|
7
|
+
import { BeatIcon as O } from "../beaticons/BeatIcon.es.js";
|
|
8
|
+
import { useCopyStore as P, useEvent as A, useInsightsMicroWidgetStore as j } from "../context/hooks.es.js";
|
|
8
9
|
import E from "../MicroCardTemplate.es.js";
|
|
9
10
|
import { useEffect as I } from "react";
|
|
10
11
|
import { jsx as r } from "react/jsx-runtime";
|
|
11
|
-
import { alpha as
|
|
12
|
-
import
|
|
13
|
-
import { useInView as
|
|
14
|
-
var
|
|
15
|
-
const { ref: _, inView: n } =
|
|
12
|
+
import { alpha as v, useTheme as w } from "@mui/material/styles";
|
|
13
|
+
import z from "@mui/material/Box";
|
|
14
|
+
import { useInView as G } from "react-intersection-observer";
|
|
15
|
+
var K = 32, ti = ({ ariaLabel: l, beat: i, elevation: g, index: c, isActiveCard: s, onCardClick: u, posthog: o, widthOverrides: m, variant: f, showIcon: h, heightOverrides: a }) => {
|
|
16
|
+
const { ref: _, inView: n } = G({ threshold: 1 }), C = w(), { cardsCopy: T } = P(), { onEvent: d } = A(), { updateBeat: N, updateOffer: V } = j();
|
|
16
17
|
I(() => {
|
|
17
|
-
n && (i.has_been_displayed ? d(
|
|
18
|
+
n && (i.has_been_displayed ? d(W(i.template)) : (i.guid.startsWith("OFR") ? V({
|
|
18
19
|
...i,
|
|
19
20
|
has_been_displayed: !0
|
|
20
21
|
}) : N({
|
|
21
22
|
...i,
|
|
22
23
|
has_been_displayed: !0
|
|
23
|
-
}), d(
|
|
24
|
+
}), d(S(i.template))));
|
|
24
25
|
}, [n]), I(() => {
|
|
25
26
|
if (n && i) if (i.template === "MarketingOffer") {
|
|
26
27
|
const e = i;
|
|
@@ -34,15 +35,15 @@ var G = 32, ei = ({ ariaLabel: l, beat: i, elevation: g, index: s, isActiveCard:
|
|
|
34
35
|
} else o?.capture("viewed_insight", {
|
|
35
36
|
beat_guid: i.guid,
|
|
36
37
|
template: i.template,
|
|
37
|
-
position:
|
|
38
|
+
position: c
|
|
38
39
|
});
|
|
39
40
|
}, [
|
|
40
41
|
i,
|
|
41
|
-
|
|
42
|
+
c,
|
|
42
43
|
n
|
|
43
44
|
]);
|
|
44
45
|
const p = () => {
|
|
45
|
-
if (u && u(i), d(
|
|
46
|
+
if (u && u(i), d(R(i.template)), i.template === "MarketingOffer") {
|
|
46
47
|
const e = i;
|
|
47
48
|
o?.capture("clicked_messaging_insight", {
|
|
48
49
|
template: i.template,
|
|
@@ -54,11 +55,11 @@ var G = 32, ei = ({ ariaLabel: l, beat: i, elevation: g, index: s, isActiveCard:
|
|
|
54
55
|
} else o?.capture("clicked_insight", {
|
|
55
56
|
beat_guid: i.guid,
|
|
56
57
|
template: i.template,
|
|
57
|
-
position:
|
|
58
|
+
position: c
|
|
58
59
|
});
|
|
59
|
-
}, y =
|
|
60
|
-
if (y === "error") return /* @__PURE__ */ r(
|
|
61
|
-
"aria-hidden": !
|
|
60
|
+
}, y = x(i), t = y === "v2" ? i.insights_payload : void 0;
|
|
61
|
+
if (y === "error") return /* @__PURE__ */ r(z, {
|
|
62
|
+
"aria-hidden": !s,
|
|
62
63
|
"aria-label": l,
|
|
63
64
|
"aria-roledescription": "slide",
|
|
64
65
|
ref: _,
|
|
@@ -68,24 +69,24 @@ var G = 32, ei = ({ ariaLabel: l, beat: i, elevation: g, index: s, isActiveCard:
|
|
|
68
69
|
minWidth: m ? `${m}px` : "100%",
|
|
69
70
|
my: 1
|
|
70
71
|
},
|
|
71
|
-
children: /* @__PURE__ */ r(
|
|
72
|
+
children: /* @__PURE__ */ r(M, { beat: i })
|
|
72
73
|
});
|
|
73
74
|
if (t) {
|
|
74
|
-
const e = t.instance_slot.
|
|
75
|
+
const e = k(t.instance_slot.data, "logo");
|
|
75
76
|
return /* @__PURE__ */ r(E, {
|
|
76
77
|
"aria-roledescription": "slide",
|
|
77
78
|
ariaLabel: l,
|
|
78
79
|
description: t.description.html_text,
|
|
79
80
|
elevation: g,
|
|
80
81
|
heightOverrides: a,
|
|
81
|
-
icon: h && (e ? /* @__PURE__ */ r(
|
|
82
|
+
icon: h && (e ? /* @__PURE__ */ r(B, {
|
|
82
83
|
logo: e,
|
|
83
|
-
size:
|
|
84
|
-
}) : /* @__PURE__ */ r(
|
|
85
|
-
bgColor:
|
|
84
|
+
size: K
|
|
85
|
+
}) : /* @__PURE__ */ r(F, {
|
|
86
|
+
bgColor: v(C.palette.primary.main, 0.15),
|
|
86
87
|
name: "lightbulb"
|
|
87
88
|
})),
|
|
88
|
-
isActiveCard:
|
|
89
|
+
isActiveCard: s,
|
|
89
90
|
onCardClick: p,
|
|
90
91
|
onPrimaryAction: p,
|
|
91
92
|
primaryActionText: t.primary_cta?.label,
|
|
@@ -101,8 +102,8 @@ var G = 32, ei = ({ ariaLabel: l, beat: i, elevation: g, index: s, isActiveCard:
|
|
|
101
102
|
description: i?.html_micro_description && i?.html_micro_description.length > 0 ? i.html_micro_description : i.html_description || "",
|
|
102
103
|
elevation: g,
|
|
103
104
|
heightOverrides: a,
|
|
104
|
-
icon: h && /* @__PURE__ */ r(
|
|
105
|
-
isActiveCard:
|
|
105
|
+
icon: h && /* @__PURE__ */ r(O, { beat: i }),
|
|
106
|
+
isActiveCard: s,
|
|
106
107
|
onCardClick: p,
|
|
107
108
|
onPrimaryAction: p,
|
|
108
109
|
primaryActionText: i.micro_call_to_action || T?.micro_card_cta,
|
|
@@ -113,7 +114,7 @@ var G = 32, ei = ({ ariaLabel: l, beat: i, elevation: g, index: s, isActiveCard:
|
|
|
113
114
|
});
|
|
114
115
|
};
|
|
115
116
|
export {
|
|
116
|
-
|
|
117
|
+
ti as InsightCard
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
//# sourceMappingURL=InsightCard.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { VIEW_THRESHOLD } from '../constants/App'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\n/** The legacy micro card's icon tile size (BeatMaterialIcon). */\nconst ICON_SIZE = 32\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n }, [beat, index, inView])\n\n // *************** Click handlers ************************\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template))\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: widthOverrides ? `${widthOverrides}px` : '100%',\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the
|
|
1
|
+
{"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { VIEW_THRESHOLD } from '../constants/App'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\n// Leaf imports, not the `core` barrel: that pulls GlobalStore and every feature store into the\n// micro bundle, and through `core/stores` it reintroduces a circular path this module avoids.\nimport { slot } from '../../core/types/Insights'\nimport type { LogoRef } from '../../core/types/Insights'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\n/** The legacy micro card's icon tile size (BeatMaterialIcon). */\nconst ICON_SIZE = 32\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n }, [beat, index, inView])\n\n // *************** Click handlers ************************\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template))\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: widthOverrides ? `${widthOverrides}px` : '100%',\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the slot's logo on the left (merchant, or the category without one), title, description, and the\n // primary CTA as a link. The logo falls back to the insight glyph when the slot carries none.\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={v2Payload.description.html_text}\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={\n showIcon &&\n (rowLogo ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : (\n <BeatMaterialIcon bgColor={alpha(theme.palette.primary.main, 0.15)} name=\"lightbulb\" />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={v2Payload.primary_cta?.label}\n ref={ref}\n title={v2Payload.title ?? ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n }\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={\n beat?.html_micro_description && beat?.html_micro_description.length > 0\n ? beat.html_micro_description\n : beat.html_description || ''\n }\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={showIcon && <BeatIcon beat={beat} />}\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={beat.micro_call_to_action || cardsCopy?.micro_card_cta}\n ref={ref}\n title={beat.micro_title && beat.micro_title.length > 0 ? beat.micro_title : beat.title}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,IAAM,IAAY,IAOL,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,OAAA,GACA,cAAA,GACA,aAAA,GACA,SAAA,GACA,gBAAA,GACA,SAAA,GACA,UAAA,GACA,iBAAA,EAAA,MACI;AACJ,QAAM,EAAE,KAAA,GAAK,QAAA,EAAA,IAAW,EAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,EAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,EAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,EAA4B;AAGhE,EAAA,EAAA,MAAgB;AACd,IAAI,MACG,EAAK,qBAcR,EAAQ,EAAc,EAAK,QAAQ,CAAC,KAbhC,EAAK,KAAK,WAAW,KAAK,IAC5B,EAAY;AAAA,MACV,GAAG;AAAA,MACH,oBAAoB;AAAA,IACtB,CAAC,IAED,EAAW;AAAA,MACT,GAAG;AAAA,MACH,oBAAoB;AAAA,IACtB,CAAC,GAEH,EAAQ,EAAyB,EAAK,QAAQ,CAAC;AAAA,EAKrD,GAAG,CAAC,CAAM,CAAC,GAEX,EAAA,MAAgB;AACd,QAAI,KAAU,EACZ,KAAI,EAAK,aAAa,kBAAkB;AACtC,YAAM,IAAY;AAClB,MAAA,GAAS,QAAQ,4BAA4B;AAAA,QAC3C,UAAU,EAAK;AAAA,QACf,eAAe,EAAU;AAAA,QACzB,eAAe,EAAU;AAAA,QACzB,YAAY,EAAU;AAAA,QACtB,WAAW,EAAU;AAAA,MACvB,CAAC;AAAA,IACH,MACE,CAAA,GAAS,QAAQ,kBAAkB;AAAA,MACjC,WAAW,EAAK;AAAA,MACh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