@mx-cartographer/experiences 9.7.138 → 9.7.140
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 +9 -0
- package/dist/insights/components/shared/ChartDrawerTemplate/TipSection.es.js +19 -19
- package/dist/insights/components/shared/ChartDrawerTemplate/TipSection.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.es.js +18 -18
- package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/quiz.es.js +37 -31
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/quiz.es.js.map +1 -1
- package/dist/insights-v2/blocks/slotReaders.d.ts +1 -1
- package/dist/insights-v2/blocks/slotReaders.es.js.map +1 -1
- package/dist/insights-v2/components/CompactInsightCard.es.js +57 -55
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +71 -70
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [9.7.140] - 11-12-2026
|
|
2
|
+
|
|
3
|
+
- **FIXED** - The micro card draws its status icon instead of an empty tile when its row logo is unusable, and its unanswered icon when the reviewed one is; the merchant quiz keeps only a row's checked fields and the Not Interested dialog only a text account name, so malformed data cannot break either (WEC-2259)
|
|
4
|
+
|
|
5
|
+
## [9.7.139] - 11-11-2026
|
|
6
|
+
|
|
7
|
+
- **FIXED** - Bill Amount Not Standard: the embedded card is 98px, matching Figma, instead of 109px; its chart is a fixed 75x54 (was 85x54, `TinyBarChart`'s default width); the Full/Embedded/Mini chart color and the drilldown tip's close/dismiss icon color (`text.primary`, now `TipSection`'s shared default for the dismiss icon only — the action/chevron icon is unchanged, pending its own Figma confirmation) (WEC-2291)
|
|
8
|
+
- **CHANGED** - Storybook: the Bill Amount Not Standard notification reads "Your bill from **{merchant}** increased/decreased by **{x}%**." (was the full card description), matching mrs_content's new `notification:` copy (WEC-2291)
|
|
9
|
+
|
|
1
10
|
## [9.7.138] - 11-11-2026
|
|
2
11
|
|
|
3
12
|
- **FIXED** - Set Up / Switch Direct Deposit complete tile: the wash is Figma's `linear-gradient(257deg, rgba(255, 224, 153, 0.2) 1.86%, rgba(173, 248, 44, 0.2) 101.54%)` (`DIRECT_DEPOSIT_COMPLETE_GRADIENT`); the warm-lime accent other blocks use is unchanged (WEC-2289)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Icon as
|
|
3
|
-
import { jsx as r, jsxs as
|
|
4
|
-
import
|
|
5
|
-
var
|
|
1
|
+
import l from "@mui/material/Stack";
|
|
2
|
+
import { Icon as n, P as f } from "@mxenabled/mxui";
|
|
3
|
+
import { jsx as r, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
import x from "@mui/material/IconButton";
|
|
5
|
+
var h = {
|
|
6
6
|
color: "info",
|
|
7
7
|
name: "lightbulb",
|
|
8
8
|
size: 24
|
|
9
|
-
},
|
|
10
|
-
const
|
|
11
|
-
return /* @__PURE__ */
|
|
9
|
+
}, I = ({ message: m, tipAriaLabel: c, onDismiss: o, onAction: t, sx: s, icon: e = h }) => {
|
|
10
|
+
const i = t || o, p = t ? "chevron_right" : "close";
|
|
11
|
+
return /* @__PURE__ */ a(l, {
|
|
12
12
|
sx: {
|
|
13
13
|
backgroundColor: "primary.lighter",
|
|
14
14
|
borderRadius: "8px",
|
|
@@ -20,14 +20,14 @@ var x = {
|
|
|
20
20
|
justifyContent: "space-between",
|
|
21
21
|
flexDirection: "row",
|
|
22
22
|
gap: 8,
|
|
23
|
-
...
|
|
23
|
+
...s
|
|
24
24
|
},
|
|
25
|
-
children: [/* @__PURE__ */
|
|
25
|
+
children: [/* @__PURE__ */ a(l, {
|
|
26
26
|
sx: {
|
|
27
27
|
flexDirection: "row",
|
|
28
28
|
gap: 4
|
|
29
29
|
},
|
|
30
|
-
children: [/* @__PURE__ */ r(
|
|
30
|
+
children: [/* @__PURE__ */ r(n, {
|
|
31
31
|
color: e.color,
|
|
32
32
|
fill: !0,
|
|
33
33
|
name: e.name,
|
|
@@ -37,19 +37,19 @@ var x = {
|
|
|
37
37
|
fontWeight: 400,
|
|
38
38
|
noWrap: !1,
|
|
39
39
|
variant: "subtitle2",
|
|
40
|
-
children:
|
|
40
|
+
children: m
|
|
41
41
|
})]
|
|
42
|
-
}),
|
|
43
|
-
"aria-label":
|
|
44
|
-
onClick:
|
|
42
|
+
}), i && /* @__PURE__ */ r(x, {
|
|
43
|
+
"aria-label": c,
|
|
44
|
+
onClick: i,
|
|
45
45
|
size: "small",
|
|
46
46
|
sx: {
|
|
47
47
|
minHeight: 0,
|
|
48
48
|
minWidth: 0,
|
|
49
|
-
p: 0
|
|
49
|
+
p: 0,
|
|
50
|
+
...o && { "& .MuiSvgIcon-root": { color: "text.primary" } }
|
|
50
51
|
},
|
|
51
|
-
children: /* @__PURE__ */ r(
|
|
52
|
-
color: "primary",
|
|
52
|
+
children: /* @__PURE__ */ r(n, {
|
|
53
53
|
fill: !0,
|
|
54
54
|
name: p,
|
|
55
55
|
size: 20
|
|
@@ -58,7 +58,7 @@ var x = {
|
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
60
|
export {
|
|
61
|
-
|
|
61
|
+
I as TipSection
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
//# sourceMappingURL=TipSection.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TipSection.es.js","names":[],"sources":["../../../../../src/insights/components/shared/ChartDrawerTemplate/TipSection.tsx"],"sourcesContent":["import { Icon, P } from '@mxenabled/mxui'\n\nimport IconButton from '@mui/material/IconButton'\nimport Stack from '@mui/material/Stack'\nimport { type SxProps } from '@mui/material/styles'\n\nexport interface TipSectionIcon {\n color: 'info' | 'primary'\n name: string\n size: number\n}\n\nconst DEFAULT_TIP_ICON: TipSectionIcon = { color: 'info', name: 'lightbulb', size: 24 }\n\nexport interface TipSectionProps {\n message: React.ReactNode\n tipAriaLabel?: string\n onDismiss?: () => void\n onAction?: () => void\n sx?: SxProps\n icon?: TipSectionIcon\n}\n\nexport const TipSection = ({\n message,\n tipAriaLabel,\n onDismiss,\n onAction,\n sx,\n icon = DEFAULT_TIP_ICON,\n}: TipSectionProps) => {\n // Priority: action > dismiss > nothing\n const buttonHandler = onAction || onDismiss\n const iconName = onAction ? 'chevron_right' : 'close'\n\n return (\n <Stack\n sx={{\n backgroundColor: 'primary.lighter',\n borderRadius: '8px',\n mb: 24,\n mt: 12,\n p: 12,\n mx: 24,\n alignItems: 'flex-start',\n justifyContent: 'space-between',\n flexDirection: 'row',\n gap: 8,\n ...sx,\n }}\n >\n <Stack sx={{ flexDirection: 'row', gap: 4 }}>\n <Icon color={icon.color} fill={true} name={icon.name} size={icon.size} />\n <P color=\"primary.dark\" fontWeight={400} noWrap={false} variant=\"subtitle2\">\n {message}\n </P>\n </Stack>\n\n {buttonHandler && (\n <IconButton\n aria-label={tipAriaLabel}\n onClick={buttonHandler}\n size=\"small\"\n sx={{
|
|
1
|
+
{"version":3,"file":"TipSection.es.js","names":[],"sources":["../../../../../src/insights/components/shared/ChartDrawerTemplate/TipSection.tsx"],"sourcesContent":["import { Icon, P } from '@mxenabled/mxui'\n\nimport IconButton from '@mui/material/IconButton'\nimport Stack from '@mui/material/Stack'\nimport { type SxProps } from '@mui/material/styles'\n\nexport interface TipSectionIcon {\n color: 'info' | 'primary'\n name: string\n size: number\n}\n\nconst DEFAULT_TIP_ICON: TipSectionIcon = { color: 'info', name: 'lightbulb', size: 24 }\n\nexport interface TipSectionProps {\n message: React.ReactNode\n tipAriaLabel?: string\n onDismiss?: () => void\n onAction?: () => void\n sx?: SxProps\n icon?: TipSectionIcon\n}\n\nexport const TipSection = ({\n message,\n tipAriaLabel,\n onDismiss,\n onAction,\n sx,\n icon = DEFAULT_TIP_ICON,\n}: TipSectionProps) => {\n // Priority: action > dismiss > nothing\n const buttonHandler = onAction || onDismiss\n const iconName = onAction ? 'chevron_right' : 'close'\n\n return (\n <Stack\n sx={{\n backgroundColor: 'primary.lighter',\n borderRadius: '8px',\n mb: 24,\n mt: 12,\n p: 12,\n mx: 24,\n alignItems: 'flex-start',\n justifyContent: 'space-between',\n flexDirection: 'row',\n gap: 8,\n ...sx,\n }}\n >\n <Stack sx={{ flexDirection: 'row', gap: 4 }}>\n <Icon color={icon.color} fill={true} name={icon.name} size={icon.size} />\n <P color=\"primary.dark\" fontWeight={400} noWrap={false} variant=\"subtitle2\">\n {message}\n </P>\n </Stack>\n\n {buttonHandler && (\n <IconButton\n aria-label={tipAriaLabel}\n onClick={buttonHandler}\n size=\"small\"\n sx={{\n minHeight: 0,\n minWidth: 0,\n p: 0,\n ...(onDismiss && { '& .MuiSvgIcon-root': { color: 'text.primary' } }),\n }}\n >\n <Icon fill={true} name={iconName} size={20} />\n </IconButton>\n )}\n </Stack>\n )\n}\n"],"mappings":";;;;AAYA,IAAM,IAAmC;AAAA,EAAE,OAAO;AAAA,EAAQ,MAAM;AAAA,EAAa,MAAM;AAAG,GAWzE,IAAA,CAAc,EACzB,SAAA,GACA,cAAA,GACA,WAAA,GACA,UAAA,GACA,IAAA,GACA,MAAA,IAAO,EAAA,MACc;AAErB,QAAM,IAAgB,KAAY,GAC5B,IAAW,IAAW,kBAAkB;AAE9C,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,IAAI;AAAA,MACF,iBAAiB;AAAA,MACjB,cAAc;AAAA,MACd,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,KAAK;AAAA,MACL,GAAG;AAAA,IACL;AAAA,IAbF,UAAA,CAeE,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAA1C,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAO,EAAK;AAAA,QAAO,MAAM;AAAA,QAAM,MAAM,EAAK;AAAA,QAAM,MAAM,EAAK;AAAA,MAAO,CAAA,GACxE,gBAAA,EAAC,GAAD;AAAA,QAAG,OAAM;AAAA,QAAe,YAAY;AAAA,QAAK,QAAQ;AAAA,QAAO,SAAQ;AAAA,QAC7D,UAAA;AAAA,MACA,CAAA,CACE;AAAA,IAEN,CAAA,GAAA,KACC,gBAAA,EAAC,GAAD;AAAA,MACE,cAAY;AAAA,MACZ,SAAS;AAAA,MACT,MAAK;AAAA,MACL,IAAI;AAAA,QACF,WAAW;AAAA,QACX,UAAU;AAAA,QACV,GAAG;AAAA,QACH,GAAI,KAAa,EAAE,sBAAsB,EAAE,OAAO,eAAe,EAAE;AAAA,MACrE;AAAA,MAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,QAAM,MAAM;AAAA,QAAM,MAAM;AAAA,QAAU,MAAM;AAAA,MAAK,CAAA;AAAA,IACnC,CAAA,CAET;AAAA;AAEX"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { buildDynamicCopy as f } from "../../core/utils/Localization.es.js";
|
|
2
2
|
import { useGlobalCopyStore as _, useInsightsV2Store as g } from "../../common/context/hooks.es.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ANALYTICS_EVENTS_CONFIG as
|
|
6
|
-
import { useAnalyticsEvent as
|
|
3
|
+
import { useBeatActions as y } from "../beatActions.es.js";
|
|
4
|
+
import { asText as h, slotOrFlat as S } from "../blocks/slotReaders.es.js";
|
|
5
|
+
import { ANALYTICS_EVENTS_CONFIG as A } from "../analytics/analyticsEventsConfig.es.js";
|
|
6
|
+
import { useAnalyticsEvent as x } from "../analytics/useAnalyticsEvent.es.js";
|
|
7
7
|
import k from "../components/FeedbackModal.es.js";
|
|
8
|
-
import { useRef as
|
|
9
|
-
import { observer as
|
|
10
|
-
import { jsx as
|
|
11
|
-
import
|
|
12
|
-
var
|
|
13
|
-
const { closeActionDrawer:
|
|
8
|
+
import { useRef as F } from "react";
|
|
9
|
+
import { observer as T } from "mobx-react-lite";
|
|
10
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
11
|
+
import C from "@mui/material/Box";
|
|
12
|
+
var R = T(function({ beat: n }) {
|
|
13
|
+
const { closeActionDrawer: c } = g(), { onDismissInsight: o, onFeedbackTextFocus: m, onSubmitFeedback: l } = y(), u = _(), p = x(), s = F(!1), t = n.insights_payload, e = u.insights_feed?.feedback_modal;
|
|
14
14
|
if (!t || !e) return null;
|
|
15
|
-
const a =
|
|
15
|
+
const a = h(S(t.instance_slot, "account_name")) ?? "", d = {
|
|
16
16
|
title: e.title,
|
|
17
|
-
description: f(e.description, a ? /* @__PURE__ */
|
|
17
|
+
description: f(e.description, a ? /* @__PURE__ */ r(C, {
|
|
18
18
|
component: "span",
|
|
19
19
|
sx: { fontWeight: 600 },
|
|
20
20
|
children: a
|
|
@@ -29,16 +29,16 @@ var V = F(function({ beat: c }) {
|
|
|
29
29
|
tryAgainText: e.try_again,
|
|
30
30
|
toastCloseAriaLabel: e.toast_close_aria
|
|
31
31
|
};
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
copy:
|
|
32
|
+
return /* @__PURE__ */ r(k, {
|
|
33
|
+
copy: d,
|
|
34
34
|
isOpen: !0,
|
|
35
|
-
onClose: () =>
|
|
35
|
+
onClose: () => c(),
|
|
36
36
|
onSubmit: async (i, b) => {
|
|
37
37
|
s.current || (s.current = !0, o?.({
|
|
38
38
|
beatGuid: t.guid,
|
|
39
39
|
type: "always"
|
|
40
|
-
}),
|
|
41
|
-
...
|
|
40
|
+
}), p({
|
|
41
|
+
...A.BEAT_DISMISSED,
|
|
42
42
|
value: i
|
|
43
43
|
})), await l?.({
|
|
44
44
|
beatGuid: t.guid,
|
|
@@ -52,7 +52,7 @@ var V = F(function({ beat: c }) {
|
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
export {
|
|
55
|
-
|
|
55
|
+
R as FeedbackModalActionBlock
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
//# sourceMappingURL=FeedbackModalActionBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedbackModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/FeedbackModalActionBlock.tsx"],"sourcesContent":["import { useRef, type ReactNode } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\n\nimport { useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport {
|
|
1
|
+
{"version":3,"file":"FeedbackModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/FeedbackModalActionBlock.tsx"],"sourcesContent":["import { useRef, type ReactNode } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\n\nimport { useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport { buildDynamicCopy } from '../../core/utils/Localization'\nimport FeedbackModal, { type FeedbackModalContent } from '../components/FeedbackModal'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../analytics'\nimport { useBeatActions } from '../beatActions'\nimport { asText, slotOrFlat } from '../blocks/slotReaders'\nimport type { ActionBlockProps } from '../mappings/blocks'\n\n/**\n * `feedback_modal_block` — a CTA drilldown registered like any other drawer\n * block; its content is a MODAL (the dialog portals over the drawer).\n *\n * Flow: the CTA (e.g. Set Up Direct Deposit's \"Not Interested\") opens the\n * \"Can you tell us why?\" survey (Figma `1941:192803`). Submit dismisses the insight\n * (`onDismissInsight`), then forwards the selection via `onSubmitFeedback` (source\n * `hide`). A host that can dismiss shows its own confirmation; otherwise the dialog\n * swaps for the success snackbar (Figma `1941:167636`). Closing ends the drawer session.\n *\n * Copy comes from `insights_feed.feedback_modal` in GlobalCopy; the\n * description interpolates the beat's account name (`_1{account_name}`).\n */\nexport const FeedbackModalActionBlock = observer(function FeedbackModalActionBlock({\n beat,\n}: ActionBlockProps) {\n const { closeActionDrawer } = useInsightsV2Store()\n const { onDismissInsight, onFeedbackTextFocus, onSubmitFeedback } = useBeatActions()\n const copyStore = useGlobalCopyStore()\n const fireAnalyticsEvent = useAnalyticsEvent()\n // So a retry does not dismiss twice.\n const hasDismissed = useRef(false)\n\n const insights_payload = beat.insights_payload\n const modalCopy = copyStore.insights_feed?.feedback_modal\n\n if (!insights_payload || !modalCopy) return null\n\n const accountName = asText(slotOrFlat(insights_payload.instance_slot, 'account_name')) ?? ''\n\n const copy: FeedbackModalContent = {\n title: modalCopy.title,\n // Figma 1941:192803: the account name is semibold within the regular sentence.\n description: buildDynamicCopy(\n modalCopy.description,\n accountName ? (\n <Box component=\"span\" sx={{ fontWeight: 600 }}>\n {accountName}\n </Box>\n ) : (\n ''\n ),\n ) as ReactNode,\n options: Object.values(modalCopy.options ?? {}),\n submitText: modalCopy.submit,\n cancelText: modalCopy.no_thanks,\n closeAriaLabel: modalCopy.close_aria,\n characterLimitLabel: modalCopy.character_limit,\n successMessage: modalCopy.success_message,\n errorMessage: modalCopy.error_message,\n tryAgainText: modalCopy.try_again,\n toastCloseAriaLabel: modalCopy.toast_close_aria,\n }\n\n // As legacy: dismiss first (once), then send the survey. A failed send keeps the beat dismissed and\n // Try Again re-sends only the feedback. Awaited so a rejection drives the error snackbar.\n const handleSubmit = async (option: string, detail?: string) => {\n if (!hasDismissed.current) {\n hasDismissed.current = true\n onDismissInsight?.({ beatGuid: insights_payload.guid, type: 'always' })\n // The reason is the event's value, as legacy.\n fireAnalyticsEvent({ ...ANALYTICS_EVENTS_CONFIG.BEAT_DISMISSED, value: option })\n }\n\n await onSubmitFeedback?.({\n beatGuid: insights_payload.guid,\n source: 'not_interested',\n option,\n detail,\n })\n }\n\n return (\n <FeedbackModal\n copy={copy}\n isOpen={true}\n onClose={() => closeActionDrawer()}\n onSubmit={handleSubmit}\n onTextInputFocus={onFeedbackTextFocus}\n // A host that dismisses shows its own confirmation; the micro widget keeps the snackbar.\n showSuccessMessage={!onDismissInsight}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;AA2BA,IAAa,IAA2B,EAAS,SAAkC,EACjF,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,EAAE,kBAAA,GAAkB,qBAAA,GAAqB,kBAAA,EAAA,IAAqB,EAAe,GAC7E,IAAY,EAAmB,GAC/B,IAAqB,EAAkB,GAEvC,IAAe,EAAO,EAAK,GAE3B,IAAmB,EAAK,kBACxB,IAAY,EAAU,eAAe;AAE3C,MAAI,CAAC,KAAoB,CAAC,EAAW,QAAO;AAE5C,QAAM,IAAc,EAAO,EAAW,EAAiB,eAAe,cAAc,CAAC,KAAK,IAEpF,IAA6B;AAAA,IACjC,OAAO,EAAU;AAAA,IAEjB,aAAa,EACX,EAAU,aACV,IACE,gBAAA,EAAC,GAAD;AAAA,MAAK,WAAU;AAAA,MAAO,IAAI,EAAE,YAAY,IAAI;AAAA,MACzC,UAAA;AAAA,IACE,CAAA,IAEL,EAEJ;AAAA,IACA,SAAS,OAAO,OAAO,EAAU,WAAW,CAAC,CAAC;AAAA,IAC9C,YAAY,EAAU;AAAA,IACtB,YAAY,EAAU;AAAA,IACtB,gBAAgB,EAAU;AAAA,IAC1B,qBAAqB,EAAU;AAAA,IAC/B,gBAAgB,EAAU;AAAA,IAC1B,cAAc,EAAU;AAAA,IACxB,cAAc,EAAU;AAAA,IACxB,qBAAqB,EAAU;AAAA,EACjC;AAoBA,SACE,gBAAA,EAAC,GAAD;AAAA,IACQ,MAAA;AAAA,IACN,QAAQ;AAAA,IACR,SAAA,MAAe,EAAkB;AAAA,IACjC,UArBiB,OAAO,GAAgB,MAAoB;AAC9D,MAAK,EAAa,YAChB,EAAa,UAAU,IACvB,IAAmB;AAAA,QAAE,UAAU,EAAiB;AAAA,QAAM,MAAM;AAAA,MAAS,CAAC,GAEtE,EAAmB;AAAA,QAAE,GAAG,EAAwB;AAAA,QAAgB,OAAO;AAAA,MAAO,CAAC,IAGjF,MAAM,IAAmB;AAAA,QACvB,UAAU,EAAiB;AAAA,QAC3B,QAAQ;AAAA,QACR,QAAA;AAAA,QACA,QAAA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAQI,kBAAkB;AAAA,IAElB,oBAAoB,CAAC;AAAA,EACtB,CAAA;AAEL,CAAC"}
|
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
import { CategoryGuids as
|
|
2
|
-
import { slot as
|
|
3
|
-
import { buildDataSeries as
|
|
4
|
-
import { asNumber as s, asText as
|
|
5
|
-
var
|
|
1
|
+
import { CategoryGuids as u } from "../../../../core/constants/Category.es.js";
|
|
2
|
+
import { slot as l } from "../../../../core/types/Insights.es.js";
|
|
3
|
+
import { buildDataSeries as g } from "../../ChartBlocks/BarchartBlock/utils.es.js";
|
|
4
|
+
import { asLogoRef as d, asNonEmptyText as i, asNumber as s, asText as c } from "../../slotReaders.es.js";
|
|
5
|
+
var E = {
|
|
6
6
|
PICK: "quiz_pick",
|
|
7
7
|
CHECKED: "quiz_checked",
|
|
8
8
|
REVEALED: "quiz_revealed"
|
|
9
|
-
},
|
|
10
|
-
const { label: r, count:
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
const
|
|
9
|
+
}, T = { RESULTS: "results" }, n = (o) => {
|
|
10
|
+
const { label: r, count: a } = o ?? {};
|
|
11
|
+
return c(r) !== void 0 && s(a) !== void 0;
|
|
12
|
+
}, _ = (o, r) => o.filter((a) => r.guid ? a.merchant_guid === r.guid : !a.merchant_guid && a.description === r.label), m = (o, r = []) => {
|
|
13
|
+
const a = _(r, o)[0], e = o.logo?.fallback_guid || o.category_guid || a?.top_level_category_guid || a?.category_guid || u.UNCATEGORIZED, t = o.logo?.guid || o.guid;
|
|
14
14
|
return {
|
|
15
15
|
...o.logo,
|
|
16
16
|
alt: o.logo?.alt ?? o.label,
|
|
17
|
-
fallback_guid:
|
|
18
|
-
guid:
|
|
17
|
+
fallback_guid: e,
|
|
18
|
+
guid: t || e
|
|
19
19
|
};
|
|
20
|
-
},
|
|
21
|
-
const r =
|
|
22
|
-
return (Array.isArray(r) ? r :
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
}, p = (o) => o.guid || o.label, C = (o) => {
|
|
21
|
+
const r = l(o, "data_series");
|
|
22
|
+
return (Array.isArray(r) ? r : g(r)).filter(n).map((a) => ({
|
|
23
|
+
label: a.label,
|
|
24
|
+
count: a.count,
|
|
25
|
+
guid: i(a.guid) ?? null,
|
|
26
|
+
category_guid: i(a.category_guid),
|
|
27
|
+
logo: d(a.logo)
|
|
28
28
|
}));
|
|
29
|
-
}, k = (o
|
|
30
|
-
const
|
|
31
|
-
return
|
|
29
|
+
}, k = (o) => {
|
|
30
|
+
const r = [...o].sort((a, e) => e.count - a.count || a.label.localeCompare(e.label));
|
|
31
|
+
return r.map((a) => ({
|
|
32
|
+
...a,
|
|
33
|
+
rank: r.findIndex(({ count: e }) => e === a.count) + 1
|
|
34
|
+
}));
|
|
35
|
+
}, z = (o, r) => {
|
|
36
|
+
const a = Math.max(...o.map(({ count: e }) => e));
|
|
37
|
+
return o.some((e) => p(e) === r && e.count === a);
|
|
32
38
|
};
|
|
33
39
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
E as QUIZ_CONTEXT,
|
|
41
|
+
T as QUIZ_VARIANTS,
|
|
42
|
+
z as isTopMerchant,
|
|
43
|
+
p as merchantKey,
|
|
44
|
+
_ as merchantTransactions,
|
|
45
|
+
m as quizMerchantLogo,
|
|
46
|
+
k as rankQuizMerchants,
|
|
47
|
+
C as readQuizMerchants
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
//# sourceMappingURL=quiz.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quiz.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/QuizBlock/quiz.ts"],"sourcesContent":["import {\n slot,\n type DataSeries,\n type InstanceSlotData,\n type LogoRef,\n type Transaction,\n} from '../../../../core'\nimport { CategoryGuids } from '../../../../core/constants/Category'\nimport { buildDataSeries } from '../../ChartBlocks/BarchartBlock/utils'\nimport { asNumber, asText } from '../../slotReaders'\n\n/** One merchant in the month, a row of the backend's `data_series`. */\nexport interface QuizMerchant {\n /** `null` for spending with no merchant; the drawer then matches transactions by `label`. */\n guid?: string | null\n label: string\n count: number\n /** The merchant's category: its logo's fallback, and the logo itself when it has no guid. */\n category_guid?: string | null\n logo?: LogoRef\n}\n\nexport interface RankedQuizMerchant extends QuizMerchant {\n rank: number\n}\n\n/** What a results row hands its drawer through `actionDrawer.context`. */\nexport interface QuizDrawerContext {\n quiz_merchant?: RankedQuizMerchant\n}\n\n/** The beat-context keys the block and the quiz CTA steps share. */\nexport const QUIZ_CONTEXT = {\n PICK: 'quiz_pick',\n CHECKED: 'quiz_checked',\n REVEALED: 'quiz_revealed',\n} as const\n\nexport const QUIZ_VARIANTS = { RESULTS: 'results' } as const\n\nconst isMerchant = (row: unknown): row is QuizMerchant => {\n const { label, count } = (row ?? {}) as Record<string, unknown>\n return asText(label) !== undefined && asNumber(count) !== undefined\n}\n\n/** The merchant's transactions: by merchant guid, or by description when it has none. */\nexport const merchantTransactions = (transactions: Transaction[], merchant: QuizMerchant) =>\n transactions.filter((transaction) =>\n merchant.guid\n ? transaction.merchant_guid === merchant.guid\n : !transaction.merchant_guid && transaction.description === merchant.label,\n )\n\n/** The merchant logo over its category fallback, or the category icon when it has no merchant guid. */\nexport const quizMerchantLogo = (\n merchant: QuizMerchant,\n transactions: Transaction[] = [],\n): LogoRef => {\n const transaction = merchantTransactions(transactions, merchant)[0]\n const category =\n merchant.logo?.fallback_guid ||\n merchant.category_guid ||\n transaction?.top_level_category_guid ||\n transaction?.category_guid ||\n CategoryGuids.UNCATEGORIZED\n const guid = merchant.logo?.guid || merchant.guid\n\n return {\n ...merchant.logo,\n alt: merchant.logo?.alt ?? merchant.label,\n fallback_guid: category,\n guid: guid || category,\n }\n}\n\n/** A merchant's id in the quiz: its guid, else its label. */\nexport const merchantKey = (merchant: QuizMerchant) => merchant.guid || merchant.label\n\n/** `data_series` rows: tupac's columnar `{ names, data }`, or an array of row objects. */\nexport const readQuizMerchants = (data: InstanceSlotData | undefined): QuizMerchant[] => {\n const series = slot<unknown[] | DataSeries>(data, 'data_series')\n const rows = Array.isArray(series) ? series : buildDataSeries(series)\n return rows.filter(isMerchant)\n}\n\n/** Most transactions first, ties by name; tied counts share a rank (1, 1, 3). */\nexport const rankQuizMerchants = (merchants: QuizMerchant[]): RankedQuizMerchant[] => {\n const sorted = [...merchants].sort((a, b) => b.count - a.count || a.label.localeCompare(b.label))\n return sorted.map((merchant) => ({\n ...merchant,\n rank: sorted.findIndex(({ count }) => count === merchant.count) + 1,\n }))\n}\n\n/** Any merchant tied for the most transactions is a right answer. */\nexport const isTopMerchant = (merchants: QuizMerchant[], key: string) => {\n const top = Math.max(...merchants.map(({ count }) => count))\n return merchants.some((merchant) => merchantKey(merchant) === key && merchant.count === top)\n}\n"],"mappings":";;;;AAgCA,IAAa,IAAe;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AACZ,GAEa,IAAgB,EAAE,SAAS,UAAU,GAE5C,IAAA,CAAc,MAAsC;AACxD,QAAM,EAAE,OAAA,GAAO,OAAA,EAAA,IAAW,KAAO,CAAC;AAClC,SAAO,EAAO,CAAK,MAAM,UAAa,EAAS,CAAK,MAAM;AAC5D,GAGa,IAAA,CAAwB,GAA6B,MAChE,EAAa,OAAA,CAAQ,MACnB,EAAS,OACL,EAAY,kBAAkB,EAAS,OACvC,CAAC,EAAY,iBAAiB,EAAY,gBAAgB,EAAS,KACzE,GAGW,IAAA,CACX,GACA,IAA8B,CAAC,MACnB;AACZ,QAAM,IAAc,EAAqB,GAAc,CAAQ,EAAE,CAAA,GAC3D,IACJ,EAAS,MAAM,iBACf,EAAS,iBACT,GAAa,2BACb,GAAa,iBACb,EAAc,eACV,IAAO,EAAS,MAAM,QAAQ,EAAS;AAE7C,SAAO;AAAA,IACL,GAAG,EAAS;AAAA,IACZ,KAAK,EAAS,MAAM,OAAO,EAAS;AAAA,IACpC,eAAe;AAAA,IACf,MAAM,KAAQ;AAAA,EAChB;AACF,GAGa,IAAA,CAAe,MAA2B,EAAS,QAAQ,EAAS,OAGpE,IAAA,CAAqB,MAAuD;AACvF,QAAM,IAAS,EAA6B,GAAM,aAAa;AAE/D,UADa,MAAM,QAAQ,CAAM,IAAI,IAAS,EAAgB,CAAM,GACxD,OAAO,CAAU;
|
|
1
|
+
{"version":3,"file":"quiz.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/QuizBlock/quiz.ts"],"sourcesContent":["import {\n slot,\n type DataSeries,\n type InstanceSlotData,\n type LogoRef,\n type Transaction,\n} from '../../../../core'\nimport { CategoryGuids } from '../../../../core/constants/Category'\nimport { buildDataSeries } from '../../ChartBlocks/BarchartBlock/utils'\nimport { asLogoRef, asNonEmptyText, asNumber, asText } from '../../slotReaders'\n\n/** One merchant in the month, a row of the backend's `data_series`. */\nexport interface QuizMerchant {\n /** `null` for spending with no merchant; the drawer then matches transactions by `label`. */\n guid?: string | null\n label: string\n count: number\n /** The merchant's category: its logo's fallback, and the logo itself when it has no guid. */\n category_guid?: string | null\n logo?: LogoRef\n}\n\nexport interface RankedQuizMerchant extends QuizMerchant {\n rank: number\n}\n\n/** What a results row hands its drawer through `actionDrawer.context`. */\nexport interface QuizDrawerContext {\n quiz_merchant?: RankedQuizMerchant\n}\n\n/** The beat-context keys the block and the quiz CTA steps share. */\nexport const QUIZ_CONTEXT = {\n PICK: 'quiz_pick',\n CHECKED: 'quiz_checked',\n REVEALED: 'quiz_revealed',\n} as const\n\nexport const QUIZ_VARIANTS = { RESULTS: 'results' } as const\n\nconst isMerchant = (row: unknown): row is QuizMerchant => {\n const { label, count } = (row ?? {}) as Record<string, unknown>\n return asText(label) !== undefined && asNumber(count) !== undefined\n}\n\n/** The merchant's transactions: by merchant guid, or by description when it has none. */\nexport const merchantTransactions = (transactions: Transaction[], merchant: QuizMerchant) =>\n transactions.filter((transaction) =>\n merchant.guid\n ? transaction.merchant_guid === merchant.guid\n : !transaction.merchant_guid && transaction.description === merchant.label,\n )\n\n/** The merchant logo over its category fallback, or the category icon when it has no merchant guid. */\nexport const quizMerchantLogo = (\n merchant: QuizMerchant,\n transactions: Transaction[] = [],\n): LogoRef => {\n const transaction = merchantTransactions(transactions, merchant)[0]\n const category =\n merchant.logo?.fallback_guid ||\n merchant.category_guid ||\n transaction?.top_level_category_guid ||\n transaction?.category_guid ||\n CategoryGuids.UNCATEGORIZED\n const guid = merchant.logo?.guid || merchant.guid\n\n return {\n ...merchant.logo,\n alt: merchant.logo?.alt ?? merchant.label,\n fallback_guid: category,\n guid: guid || category,\n }\n}\n\n/** A merchant's id in the quiz: its guid, else its label. */\nexport const merchantKey = (merchant: QuizMerchant) => merchant.guid || merchant.label\n\n/** `data_series` rows: tupac's columnar `{ names, data }`, or an array of row objects. */\nexport const readQuizMerchants = (data: InstanceSlotData | undefined): QuizMerchant[] => {\n const series = slot<unknown[] | DataSeries>(data, 'data_series')\n const rows = Array.isArray(series) ? series : buildDataSeries(series)\n return rows.filter(isMerchant).map((row) => ({\n label: row.label,\n count: row.count,\n guid: asNonEmptyText(row.guid) ?? null,\n category_guid: asNonEmptyText(row.category_guid),\n logo: asLogoRef(row.logo),\n }))\n}\n\n/** Most transactions first, ties by name; tied counts share a rank (1, 1, 3). */\nexport const rankQuizMerchants = (merchants: QuizMerchant[]): RankedQuizMerchant[] => {\n const sorted = [...merchants].sort((a, b) => b.count - a.count || a.label.localeCompare(b.label))\n return sorted.map((merchant) => ({\n ...merchant,\n rank: sorted.findIndex(({ count }) => count === merchant.count) + 1,\n }))\n}\n\n/** Any merchant tied for the most transactions is a right answer. */\nexport const isTopMerchant = (merchants: QuizMerchant[], key: string) => {\n const top = Math.max(...merchants.map(({ count }) => count))\n return merchants.some((merchant) => merchantKey(merchant) === key && merchant.count === top)\n}\n"],"mappings":";;;;AAgCA,IAAa,IAAe;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AACZ,GAEa,IAAgB,EAAE,SAAS,UAAU,GAE5C,IAAA,CAAc,MAAsC;AACxD,QAAM,EAAE,OAAA,GAAO,OAAA,EAAA,IAAW,KAAO,CAAC;AAClC,SAAO,EAAO,CAAK,MAAM,UAAa,EAAS,CAAK,MAAM;AAC5D,GAGa,IAAA,CAAwB,GAA6B,MAChE,EAAa,OAAA,CAAQ,MACnB,EAAS,OACL,EAAY,kBAAkB,EAAS,OACvC,CAAC,EAAY,iBAAiB,EAAY,gBAAgB,EAAS,KACzE,GAGW,IAAA,CACX,GACA,IAA8B,CAAC,MACnB;AACZ,QAAM,IAAc,EAAqB,GAAc,CAAQ,EAAE,CAAA,GAC3D,IACJ,EAAS,MAAM,iBACf,EAAS,iBACT,GAAa,2BACb,GAAa,iBACb,EAAc,eACV,IAAO,EAAS,MAAM,QAAQ,EAAS;AAE7C,SAAO;AAAA,IACL,GAAG,EAAS;AAAA,IACZ,KAAK,EAAS,MAAM,OAAO,EAAS;AAAA,IACpC,eAAe;AAAA,IACf,MAAM,KAAQ;AAAA,EAChB;AACF,GAGa,IAAA,CAAe,MAA2B,EAAS,QAAQ,EAAS,OAGpE,IAAA,CAAqB,MAAuD;AACvF,QAAM,IAAS,EAA6B,GAAM,aAAa;AAE/D,UADa,MAAM,QAAQ,CAAM,IAAI,IAAS,EAAgB,CAAM,GACxD,OAAO,CAAU,EAAE,IAAA,CAAK,OAAS;AAAA,IAC3C,OAAO,EAAI;AAAA,IACX,OAAO,EAAI;AAAA,IACX,MAAM,EAAe,EAAI,IAAI,KAAK;AAAA,IAClC,eAAe,EAAe,EAAI,aAAa;AAAA,IAC/C,MAAM,EAAU,EAAI,IAAI;AAAA,EAC1B,EAAE;AACJ,GAGa,IAAA,CAAqB,MAAoD;AACpF,QAAM,IAAS,CAAC,GAAG,CAAS,EAAE,KAAA,CAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC;AAChG,SAAO,EAAO,IAAA,CAAK,OAAc;AAAA,IAC/B,GAAG;AAAA,IACH,MAAM,EAAO,UAAA,CAAW,EAAE,OAAA,EAAA,MAAY,MAAU,EAAS,KAAK,IAAI;AAAA,EACpE,EAAE;AACJ,GAGa,IAAA,CAAiB,GAA2B,MAAgB;AACvE,QAAM,IAAM,KAAK,IAAI,GAAG,EAAU,IAAA,CAAK,EAAE,OAAA,EAAA,MAAY,CAAK,CAAC;AAC3D,SAAO,EAAU,KAAA,CAAM,MAAa,EAAY,CAAQ,MAAM,KAAO,EAAS,UAAU,CAAG;AAC7F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InstanceSlot, LogoRef } from '../../core';
|
|
1
|
+
import { InstanceSlot, LogoRef } from '../../core/types/Insights';
|
|
2
2
|
/** A field V1 payloads carry flat on the slot, beside `data`. */
|
|
3
3
|
export type FlatSlotKey = Exclude<keyof InstanceSlot, 'data' | 'block' | 'variant'>;
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slotReaders.es.js","names":[],"sources":["../../../src/insights-v2/blocks/slotReaders.ts"],"sourcesContent":["import { slot, type InstanceSlot, type LogoRef } from '../../core'\n\n// Readers for untrusted payload values, in instance slots and drilldown_data: each returns the value\n// when it has the right shape, else undefined, so the caller drops it rather than drawing a guess.\n\n/** A field V1 payloads carry flat on the slot, beside `data`. */\nexport type FlatSlotKey = Exclude<keyof InstanceSlot, 'data' | 'block' | 'variant'>\n\n/**\n * `data` first, then the flat field V1 payloads carry beside it. Any non-null `data` value wins,\n * even one of the wrong kind (`data` is the truth; the caller's guard then drops it). For blocks\n * that still accept V1; a V2-only block reads `slot()` so a stale flat field never shows.\n */\nexport const slotOrFlat = (instanceSlot: InstanceSlot, key: FlatSlotKey): unknown =>\n slot(instanceSlot.data, key) ?? instanceSlot[key]\n\n/** A finite number, else undefined (so a card never shows a made-up value). */\nexport const asNumber = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\n/** Any string, empty included, else undefined. */\nexport const asText = (value: unknown): string | undefined =>\n typeof value === 'string' ? value : undefined\n\n/** A string with more than whitespace, else undefined: a blank guid or label is no value. */\nexport const asNonEmptyText = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\n/** Guids, else undefined: an empty list or a blank guid names nothing to fetch or draw. */\nexport const asGuidList = (value: unknown): string[] | undefined =>\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => asNonEmptyText(item) !== undefined)\n ? (value as string[])\n : undefined\n\n/** A logo ref naming a `guid` or an `icon`, keeping only its fields of the right kind, else undefined. */\nexport const asLogoRef = (value: unknown): LogoRef | undefined => {\n if (typeof value !== 'object' || value === null) return undefined\n const { alt, color, fallback_guid, guid, icon } = value as Record<string, unknown>\n const ref = {\n alt: asText(alt),\n color: asText(color),\n fallback_guid: asNonEmptyText(fallback_guid),\n guid: asNonEmptyText(guid),\n icon: asNonEmptyText(icon),\n }\n return ref.guid || ref.icon ? ref : undefined\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"slotReaders.es.js","names":[],"sources":["../../../src/insights-v2/blocks/slotReaders.ts"],"sourcesContent":["// Leaf import: the micro card uses this file, and the `core` barrel pulls every store into it.\nimport { slot, type InstanceSlot, type LogoRef } from '../../core/types/Insights'\n\n// Readers for untrusted payload values, in instance slots and drilldown_data: each returns the value\n// when it has the right shape, else undefined, so the caller drops it rather than drawing a guess.\n\n/** A field V1 payloads carry flat on the slot, beside `data`. */\nexport type FlatSlotKey = Exclude<keyof InstanceSlot, 'data' | 'block' | 'variant'>\n\n/**\n * `data` first, then the flat field V1 payloads carry beside it. Any non-null `data` value wins,\n * even one of the wrong kind (`data` is the truth; the caller's guard then drops it). For blocks\n * that still accept V1; a V2-only block reads `slot()` so a stale flat field never shows.\n */\nexport const slotOrFlat = (instanceSlot: InstanceSlot, key: FlatSlotKey): unknown =>\n slot(instanceSlot.data, key) ?? instanceSlot[key]\n\n/** A finite number, else undefined (so a card never shows a made-up value). */\nexport const asNumber = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\n/** Any string, empty included, else undefined. */\nexport const asText = (value: unknown): string | undefined =>\n typeof value === 'string' ? value : undefined\n\n/** A string with more than whitespace, else undefined: a blank guid or label is no value. */\nexport const asNonEmptyText = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\n/** Guids, else undefined: an empty list or a blank guid names nothing to fetch or draw. */\nexport const asGuidList = (value: unknown): string[] | undefined =>\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => asNonEmptyText(item) !== undefined)\n ? (value as string[])\n : undefined\n\n/** A logo ref naming a `guid` or an `icon`, keeping only its fields of the right kind, else undefined. */\nexport const asLogoRef = (value: unknown): LogoRef | undefined => {\n if (typeof value !== 'object' || value === null) return undefined\n const { alt, color, fallback_guid, guid, icon } = value as Record<string, unknown>\n const ref = {\n alt: asText(alt),\n color: asText(color),\n fallback_guid: asNonEmptyText(fallback_guid),\n guid: asNonEmptyText(guid),\n icon: asNonEmptyText(icon),\n }\n return ref.guid || ref.icon ? ref : undefined\n}\n"],"mappings":";AAcA,IAAa,IAAA,CAAc,GAA4B,MACrD,EAAK,EAAa,MAAM,CAAG,KAAK,EAAa,CAAA,GAGlC,IAAA,CAAY,MACvB,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,IAAI,IAAQ,QAGnD,IAAA,CAAU,MACrB,OAAO,KAAU,WAAW,IAAQ,QAGzB,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,KAAK,IAAQ,QAGhD,IAAA,CAAc,MACzB,MAAM,QAAQ,CAAK,KACnB,EAAM,SAAS,KACf,EAAM,MAAA,CAAO,MAAS,EAAe,CAAI,MAAM,MAAS,IACnD,IACD,QAGO,IAAA,CAAa,MAAwC;AAChE,MAAI,OAAO,KAAU,YAAY,MAAU,KAAM;AACjD,QAAM,EAAE,KAAA,GAAK,OAAA,GAAO,eAAA,GAAe,MAAA,GAAM,MAAA,EAAA,IAAS,GAC5C,IAAM;AAAA,IACV,KAAK,EAAO,CAAG;AAAA,IACf,OAAO,EAAO,CAAK;AAAA,IACnB,eAAe,EAAe,CAAa;AAAA,IAC3C,MAAM,EAAe,CAAI;AAAA,IACzB,MAAM,EAAe,CAAI;AAAA,EAC3B;AACA,SAAO,EAAI,QAAQ,EAAI,OAAO,IAAM;AACtC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { useGlobalStore as V, useInsightsV2Store as G } from "../../common/context/hooks.es.js";
|
|
2
|
-
import { slot as
|
|
3
|
-
import { getCategoryColor as
|
|
4
|
-
import { TinyBarChart as
|
|
5
|
-
import { BAR_ARIA_LABEL as
|
|
6
|
-
import { ThemedSVGImage as
|
|
7
|
-
import { asLogoRef as
|
|
8
|
-
import { postCtaMessage as
|
|
2
|
+
import { slot as b } from "../../core/types/Insights.es.js";
|
|
3
|
+
import { getCategoryColor as H } from "../../core/utils/CategoryUtil.es.js";
|
|
4
|
+
import { TinyBarChart as W } from "../../common/components/TinyBarChart.es.js";
|
|
5
|
+
import { BAR_ARIA_LABEL as N, buildChartData as P, buildDataSeries as K } from "../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
6
|
+
import { ThemedSVGImage as j } from "./chartblocks/ThemedSVGImage.es.js";
|
|
7
|
+
import { asLogoRef as M } from "../blocks/slotReaders.es.js";
|
|
8
|
+
import { postCtaMessage as F } from "../ctaActions/runCtaAction.es.js";
|
|
9
9
|
import p from "./LogoFromGuid.es.js";
|
|
10
10
|
import { createVariantBlock as Z } from "../blocks/createVariantBlock.es.js";
|
|
11
11
|
import { ActionBlockLayer as X } from "../actionBlocks/ActionBlockLayer.es.js";
|
|
12
|
-
import
|
|
12
|
+
import v from "./BadgedTile.es.js";
|
|
13
13
|
import { InsightOptionsMenu as $ } from "./InsightOptionsMenu.es.js";
|
|
14
14
|
import { ReactComponent as q } from "./shared/images/FeeDetected.es.js";
|
|
15
|
-
import
|
|
15
|
+
import D from "./StatusBadge.es.js";
|
|
16
16
|
import x from "@mui/material/Stack";
|
|
17
17
|
import { P as J, Text as C } from "@mxenabled/mxui";
|
|
18
18
|
import Q from "@mui/material/Button";
|
|
19
|
-
import { Icon as
|
|
19
|
+
import { Icon as y } from "@mxenabled/mx-icons";
|
|
20
20
|
import { Fragment as U, jsx as t, jsxs as d } from "react/jsx-runtime";
|
|
21
21
|
import e from "@mui/material/Box";
|
|
22
22
|
import Y from "@mui/material/Card";
|
|
@@ -25,7 +25,7 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
25
25
|
position: "absolute",
|
|
26
26
|
top: "50%",
|
|
27
27
|
transform: "translate(-50%, -50%)"
|
|
28
|
-
}, k = ({ logo: r }) => r ? /* @__PURE__ */ t(p, {
|
|
28
|
+
}, et = 54, ot = 75, k = ({ logo: r }) => r ? /* @__PURE__ */ t(p, {
|
|
29
29
|
logo: r,
|
|
30
30
|
size: c
|
|
31
31
|
}) : /* @__PURE__ */ t(e, {
|
|
@@ -38,22 +38,22 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
38
38
|
justifyContent: "center",
|
|
39
39
|
width: c
|
|
40
40
|
},
|
|
41
|
-
children: /* @__PURE__ */ t(
|
|
41
|
+
children: /* @__PURE__ */ t(y, {
|
|
42
42
|
color: "primary",
|
|
43
43
|
fill: !0,
|
|
44
44
|
name: "lightbulb",
|
|
45
45
|
size: 24
|
|
46
46
|
})
|
|
47
|
-
}), w = ({ logo: r }) => /* @__PURE__ */ t(
|
|
47
|
+
}), w = ({ logo: r }) => /* @__PURE__ */ t(v, {
|
|
48
48
|
center: /* @__PURE__ */ t(k, { logo: r }),
|
|
49
49
|
size: c,
|
|
50
50
|
sx: { flexShrink: 0 }
|
|
51
|
-
}),
|
|
51
|
+
}), at = ({ logo: r }) => /* @__PURE__ */ t(v, {
|
|
52
52
|
center: /* @__PURE__ */ t(k, { logo: r }),
|
|
53
53
|
size: c,
|
|
54
54
|
sx: { flexShrink: 0 },
|
|
55
|
-
topRight: /* @__PURE__ */ t(
|
|
56
|
-
}),
|
|
55
|
+
topRight: /* @__PURE__ */ t(D, { tone: "warning" })
|
|
56
|
+
}), nt = 24, st = ({ logo: r }) => /* @__PURE__ */ t(v, {
|
|
57
57
|
bottomLeft: r ? /* @__PURE__ */ t(e, {
|
|
58
58
|
"aria-hidden": !0,
|
|
59
59
|
sx: {
|
|
@@ -68,21 +68,21 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
68
68
|
...r,
|
|
69
69
|
alt: void 0
|
|
70
70
|
},
|
|
71
|
-
size:
|
|
71
|
+
size: nt
|
|
72
72
|
})
|
|
73
73
|
}) : void 0,
|
|
74
74
|
center: /* @__PURE__ */ t(k, { logo: r }),
|
|
75
75
|
size: c,
|
|
76
76
|
sx: { flexShrink: 0 },
|
|
77
|
-
topRight: /* @__PURE__ */ t(
|
|
78
|
-
}),
|
|
77
|
+
topRight: /* @__PURE__ */ t(D, { tone: "error" })
|
|
78
|
+
}), lt = () => /* @__PURE__ */ t(j, {
|
|
79
79
|
divProps: { style: {
|
|
80
80
|
flexShrink: 0,
|
|
81
81
|
lineHeight: 0,
|
|
82
82
|
width: "max-content"
|
|
83
83
|
} },
|
|
84
84
|
image: q
|
|
85
|
-
}),
|
|
85
|
+
}), _ = 24, dt = () => /* @__PURE__ */ t(e, {
|
|
86
86
|
"aria-hidden": !0,
|
|
87
87
|
"data-testid": "linked-logos-badge",
|
|
88
88
|
sx: {
|
|
@@ -97,12 +97,12 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
97
97
|
p: 2,
|
|
98
98
|
zIndex: 1
|
|
99
99
|
},
|
|
100
|
-
children: /* @__PURE__ */ t(
|
|
100
|
+
children: /* @__PURE__ */ t(y, {
|
|
101
101
|
name: "link",
|
|
102
102
|
size: 16,
|
|
103
103
|
sx: { color: "primary.contrastText" }
|
|
104
104
|
})
|
|
105
|
-
}),
|
|
105
|
+
}), ct = () => /* @__PURE__ */ t(e, {
|
|
106
106
|
"aria-hidden": !0,
|
|
107
107
|
"data-testid": "linked-logos-badge",
|
|
108
108
|
sx: {
|
|
@@ -111,22 +111,22 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
111
111
|
bgcolor: "primary.contrastText",
|
|
112
112
|
borderRadius: "50%",
|
|
113
113
|
display: "flex",
|
|
114
|
-
height:
|
|
114
|
+
height: _,
|
|
115
115
|
justifyContent: "center",
|
|
116
116
|
overflow: "hidden",
|
|
117
|
-
width:
|
|
117
|
+
width: _,
|
|
118
118
|
zIndex: 1
|
|
119
119
|
},
|
|
120
|
-
children: /* @__PURE__ */ t(
|
|
120
|
+
children: /* @__PURE__ */ t(y, {
|
|
121
121
|
name: "swap_vertical_circle",
|
|
122
|
-
size:
|
|
122
|
+
size: _ * 1.2,
|
|
123
123
|
sx: {
|
|
124
124
|
color: "primary.main",
|
|
125
125
|
flexShrink: 0,
|
|
126
126
|
transform: "rotate(-90deg)"
|
|
127
127
|
}
|
|
128
128
|
})
|
|
129
|
-
}),
|
|
129
|
+
}), pt = ({ data: r, template: o }) => {
|
|
130
130
|
const { from_logo: l, to_logo: a } = r ?? {}, i = o === "SwitchDirectDeposit";
|
|
131
131
|
return /* @__PURE__ */ d(e, {
|
|
132
132
|
sx: {
|
|
@@ -188,33 +188,35 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
188
188
|
size: I
|
|
189
189
|
})
|
|
190
190
|
}),
|
|
191
|
-
i ? /* @__PURE__ */ t(
|
|
191
|
+
i ? /* @__PURE__ */ t(ct, {}) : /* @__PURE__ */ t(dt, {})
|
|
192
192
|
]
|
|
193
193
|
});
|
|
194
|
-
},
|
|
195
|
-
const o =
|
|
194
|
+
}, gt = ({ data: r }) => {
|
|
195
|
+
const o = K(b(r, "series"));
|
|
196
196
|
if (!o.length) return null;
|
|
197
|
-
const l =
|
|
197
|
+
const l = b(r, "category_guid"), a = P(o, N).slice(-3);
|
|
198
198
|
return /* @__PURE__ */ t(e, {
|
|
199
199
|
"data-testid": "compact-insight-card-bar-chart",
|
|
200
200
|
sx: { flexShrink: 0 },
|
|
201
|
-
children: /* @__PURE__ */ t(
|
|
202
|
-
color: (i) => l ?
|
|
203
|
-
data: a
|
|
201
|
+
children: /* @__PURE__ */ t(W, {
|
|
202
|
+
color: (i) => l ? H(l, i) : i.palette.primary.main,
|
|
203
|
+
data: a,
|
|
204
|
+
height: et,
|
|
205
|
+
width: ot
|
|
204
206
|
})
|
|
205
207
|
});
|
|
206
|
-
},
|
|
208
|
+
}, mt = Z({
|
|
207
209
|
variants: {
|
|
208
|
-
category_color:
|
|
209
|
-
linked_logos:
|
|
210
|
+
category_color: gt,
|
|
211
|
+
linked_logos: pt,
|
|
210
212
|
minimal: w,
|
|
211
|
-
stacked_logos:
|
|
212
|
-
with_illustration:
|
|
213
|
-
with_warning_badge:
|
|
213
|
+
stacked_logos: st,
|
|
214
|
+
with_illustration: lt,
|
|
215
|
+
with_warning_badge: at
|
|
214
216
|
},
|
|
215
217
|
fallback: w,
|
|
216
218
|
name: "InsightVisual"
|
|
217
|
-
}),
|
|
219
|
+
}), ht = {
|
|
218
220
|
BillAmountNotStandard: {
|
|
219
221
|
key: "in_description_cta",
|
|
220
222
|
trigger: "inDescriptionCta"
|
|
@@ -228,22 +230,22 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
228
230
|
trigger: "inDescriptionCta"
|
|
229
231
|
},
|
|
230
232
|
SwitchDirectDeposit: { key: "in_description_cta" }
|
|
231
|
-
},
|
|
232
|
-
const
|
|
233
|
+
}, ft = (r) => r.stopPropagation(), Wt = ({ beat: r, isCtaDisabled: o = !1, onCtaClick: l, onTap: a, payload: i }) => {
|
|
234
|
+
const S = V(), { openActionDrawer: E } = G(), { description: B, instance_slot: m, primary_cta: h, title: R } = i, n = ht[i.template ?? ""], f = n ? i[n.key] : h, u = i.in_description_cta?.post_message_metadata, L = !n || !!n.trigger || !!r && !!u, A = M(b(m.data, "logo")), T = (s) => {
|
|
233
235
|
if (s.stopPropagation(), !(o || !f)) {
|
|
234
236
|
if (n) {
|
|
235
|
-
if (r && n.trigger)
|
|
237
|
+
if (r && n.trigger) E({
|
|
236
238
|
guid: r.guid,
|
|
237
239
|
trigger: n.trigger
|
|
238
240
|
});
|
|
239
241
|
else if (r && u) {
|
|
240
|
-
const { action:
|
|
241
|
-
|
|
242
|
+
const { action: z, ...O } = u;
|
|
243
|
+
F({
|
|
242
244
|
beat: r,
|
|
243
|
-
stores:
|
|
245
|
+
stores: S
|
|
244
246
|
}, {
|
|
245
|
-
action:
|
|
246
|
-
payload:
|
|
247
|
+
action: z,
|
|
248
|
+
payload: O
|
|
247
249
|
});
|
|
248
250
|
}
|
|
249
251
|
return;
|
|
@@ -281,9 +283,9 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
281
283
|
children: [/* @__PURE__ */ t(C, {
|
|
282
284
|
bold: !0,
|
|
283
285
|
variant: "body1",
|
|
284
|
-
children:
|
|
286
|
+
children: R ?? ""
|
|
285
287
|
}), /* @__PURE__ */ t(e, {
|
|
286
|
-
onClick:
|
|
288
|
+
onClick: ft,
|
|
287
289
|
sx: { display: "flex" },
|
|
288
290
|
children: /* @__PURE__ */ t($, {})
|
|
289
291
|
})]
|
|
@@ -314,9 +316,9 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
314
316
|
WebkitLineClamp: tt
|
|
315
317
|
},
|
|
316
318
|
variant: "subtitle2"
|
|
317
|
-
}), f?.label &&
|
|
319
|
+
}), f?.label && L && /* @__PURE__ */ t(Q, {
|
|
318
320
|
"aria-disabled": o,
|
|
319
|
-
onClick:
|
|
321
|
+
onClick: T,
|
|
320
322
|
size: "small",
|
|
321
323
|
sx: {
|
|
322
324
|
alignSelf: "flex-start",
|
|
@@ -335,7 +337,7 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
335
337
|
children: f.label
|
|
336
338
|
})
|
|
337
339
|
})]
|
|
338
|
-
}), /* @__PURE__ */ t(
|
|
340
|
+
}), /* @__PURE__ */ t(mt, {
|
|
339
341
|
data: m.data,
|
|
340
342
|
logo: A,
|
|
341
343
|
template: i.template,
|
|
@@ -345,7 +347,7 @@ var tt = 2, c = 44, I = 36, rt = 75, it = 74, g = {
|
|
|
345
347
|
}), r && /* @__PURE__ */ t(X, { beat: r })] });
|
|
346
348
|
};
|
|
347
349
|
export {
|
|
348
|
-
|
|
350
|
+
Wt as default
|
|
349
351
|
};
|
|
350
352
|
|
|
351
353
|
//# sourceMappingURL=CompactInsightCard.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { useGlobalStore, useInsightsV2Store } from '../../common'\nimport { TinyBarChart } from '../../common/components/TinyBarChart'\nimport { slot } from '../../core'\nimport type {\n Beat,\n DataSeries,\n InsightsPayload,\n InstanceSlotData,\n LogoRef,\n PrimaryCTA,\n} from '../../core'\nimport type { ActionDrawerTrigger } from '../../core/stores'\nimport type { AccountSwitchBlockV2Data } from '../../core/types/InsightsInstanceSlotData'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport {\n BAR_ARIA_LABEL,\n buildChartData,\n buildDataSeries,\n} from '../blocks/ChartBlocks/BarchartBlock/utils'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport { postCtaMessage } from '../ctaActions'\nimport { asLogoRef } from '../blocks/slotReaders'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\nconst DESCRIPTION_MAX_LINES = 2\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n /** The slot's whole `data`, for a visual drawn from more than the logo (`category_color`, `linked_logos`). */\n data?: InstanceSlotData\n /** The envelope's template, for a beat's own badge on `linked_logos`. */\n template?: string\n}\n\n// Figma 1943:219189: 36px logos at opposite corners of a 75×74 box, the badge and rings centred.\nconst LINKED_LOGO_SIZE = 36\nconst LINKED_BOX_WIDTH = 75\nconst LINKED_BOX_HEIGHT = 74\n\nconst CENTRED = {\n left: '50%',\n position: 'absolute',\n top: '50%',\n transform: 'translate(-50%, -50%)',\n} as const\n\n/** Figma 222:33404 (Embedded | Bill Amount Not Standard) shows the latest three bars. */\nconst BAR_CHART_BAR_COUNT = 3\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\nconst STACKED_LOGO_SIZE = 24\n\n/** ditto `stacked_logos`: the row logo twice, plus an error badge. The copy is `aria-hidden`, so the logo is named once. */\nconst StackedLogosVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n bottomLeft={\n logo ? (\n <Box\n aria-hidden={true}\n sx={{\n borderRadius: '6px',\n display: 'flex',\n outline: '2px solid',\n outlineColor: 'background.paper',\n overflow: 'hidden',\n }}\n >\n <LogoFromGuid logo={{ ...logo, alt: undefined }} size={STACKED_LOGO_SIZE} />\n </Box>\n ) : undefined\n }\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"error\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\nconst SWAP_BADGE_SIZE = 24\n\nconst LinkBadge = () => (\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-badge\"\n sx={{\n ...CENTRED,\n alignItems: 'center',\n bgcolor: 'primary.main',\n border: '2px solid',\n borderColor: 'primary.contrastText',\n borderRadius: '12px',\n display: 'flex',\n justifyContent: 'center',\n p: 2,\n zIndex: 1,\n }}\n >\n <Icon name=\"link\" size={16} sx={{ color: 'primary.contrastText' }} />\n </Box>\n)\n\n/**\n * Switch Direct Deposit (Figma 1941:167601): the outlined `swap_vertical_circle`, turned horizontal,\n * over a contrast disc: a primary ring and arrows on white. Drawn 1.2× so its circle fills 24px.\n */\nconst SwapBadge = () => (\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-badge\"\n sx={{\n ...CENTRED,\n alignItems: 'center',\n bgcolor: 'primary.contrastText',\n borderRadius: '50%',\n display: 'flex',\n height: SWAP_BADGE_SIZE,\n justifyContent: 'center',\n overflow: 'hidden',\n width: SWAP_BADGE_SIZE,\n zIndex: 1,\n }}\n >\n <Icon\n name=\"swap_vertical_circle\"\n size={SWAP_BADGE_SIZE * 1.2}\n sx={{ color: 'primary.main', flexShrink: 0, transform: 'rotate(-90deg)' }}\n />\n </Box>\n)\n\n/**\n * ditto `linked_logos` (Figma 1943:219189, Embedded | Discovered Accounts): the two institutions at\n * opposite corners of a 75×74 box — `from_logo` top-left, `to_logo` bottom-right — meeting on the\n * diagonal, with a badge over two rings at the centre (Switch Direct Deposit: the swap badge on an\n * outlined inner ring). The rings and badge are decorative (`aria-hidden`); each logo's accessible\n * name is its `alt`.\n */\nconst LinkedLogosVisual = ({ data, template }: InsightVisualProps) => {\n const { from_logo, to_logo } = (data ?? {}) as AccountSwitchBlockV2Data\n const isSwap = template === 'SwitchDirectDeposit'\n\n return (\n <Box\n sx={{\n flexShrink: 0,\n height: LINKED_BOX_HEIGHT,\n position: 'relative',\n width: LINKED_BOX_WIDTH,\n }}\n >\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{\n ...CENTRED,\n borderRadius: '50%',\n height: 36,\n width: 36,\n ...(isSwap\n ? { border: '2px solid', borderColor: 'primary.light' }\n : { bgcolor: 'primary.light' }),\n }}\n />\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{\n ...CENTRED,\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '50%',\n height: 48,\n width: 48,\n }}\n />\n <Box sx={{ borderRadius: '4px', left: 0, overflow: 'hidden', position: 'absolute', top: 0 }}>\n <LogoFromGuid logo={from_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n <Box\n sx={{ borderRadius: '4px', bottom: 0, overflow: 'hidden', position: 'absolute', right: 0 }}\n >\n <LogoFromGuid logo={to_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n {isSwap ? <SwapBadge /> : <LinkBadge />}\n </Box>\n )\n}\n\n/**\n * ditto `category_color`: a tiny bar chart of the latest bars in place of the logo tile, tinted by\n * the slot's category, the newest bar solid (Figma 222:33404). Draws nothing without a series.\n */\nconst BarChartVisual = ({ data }: InsightVisualProps) => {\n const series = buildDataSeries(slot<DataSeries>(data, 'series'))\n if (!series.length) return null\n\n const categoryGuid = slot<string>(data, 'category_guid')\n const bars = buildChartData(series, BAR_ARIA_LABEL).slice(-BAR_CHART_BAR_COUNT)\n\n return (\n <Box data-testid=\"compact-insight-card-bar-chart\" sx={{ flexShrink: 0 }}>\n <TinyBarChart\n color={(theme) =>\n categoryGuid ? getCategoryColor(categoryGuid, theme) : theme.palette.primary.main\n }\n data={bars}\n />\n </Box>\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n category_color: BarChartVisual,\n linked_logos: LinkedLogosVisual,\n minimal: PlainVisual,\n stacked_logos: StackedLogosVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\n/**\n * Beats whose embedded CTA the card reads from its own envelope key and opens in this card's\n * `ActionBlockLayer`, as a bar click does on the full card. The trigger names that key, so the layer\n * resolves the same CTA. Without a trigger the link posts its host message instead (Switch Direct\n * Deposit's op_1: Atomic runs only in pulse). Every other beat keeps `primary_cta` and hands it to\n * the host's `onCtaClick` (e.g. `contact_support_block`). A new beat adds its template here.\n */\nconst BEAT_CTA_CONFIG: Record<\n string,\n { key: 'primary_cta' | 'in_description_cta'; trigger?: ActionDrawerTrigger }\n> = {\n BillAmountNotStandard: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n ConnectDiscoveredAccountsV2: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n DuplicatePaymentV2: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n SwitchDirectDeposit: { key: 'in_description_cta' },\n}\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /** The envelope's beat; when given, the card mounts its `ActionBlockLayer` for CTA drawers. */\n beat?: Beat\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n beat,\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const stores = useGlobalStore()\n const { openActionDrawer } = useInsightsV2Store()\n const { description, instance_slot, primary_cta, title } = payload\n const beatCta = BEAT_CTA_CONFIG[payload.template ?? '']\n const cta = beatCta ? payload[beatCta.key] : primary_cta\n const message = payload.in_description_cta?.post_message_metadata\n // A link that posts needs its beat and message; without them it draws nothing.\n const canAct = !beatCta || !!beatCta.trigger || (!!beat && !!message)\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = asLogoRef(slot(instance_slot.data, 'logo'))\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !cta) return\n\n if (beatCta) {\n if (beat && beatCta.trigger) openActionDrawer({ guid: beat.guid, trigger: beatCta.trigger })\n else if (beat && message) {\n const { action, ...extras } = message\n postCtaMessage({ beat, stores }, { action, payload: extras })\n }\n return\n }\n if (primary_cta) onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <>\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 16, pl: 8 }}>\n <Stack sx={{ alignSelf: 'stretch', flex: 1, gap: 8, minWidth: 0, pt: 2 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n sx={{\n display: '-webkit-box',\n fontWeight: 'fontWeightRegular',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: DESCRIPTION_MAX_LINES,\n }}\n variant=\"subtitle2\"\n />\n {cta?.label && canAct && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // The label lines up with the description (the column pads 8; the tap target keeps\n // its padding). `my: 0` drops the theme's -12px text-button margin.\n ml: -8,\n my: 0,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n <Text bold={true} variant=\"body2\">\n {cta.label}\n </Text>\n </Button>\n )}\n </Stack>\n\n <InsightVisual\n data={instance_slot.data}\n logo={rowLogo}\n template={payload.template}\n variant={instance_slot.variant}\n />\n </Stack>\n </Card>\n {/* Outside the Card: the drawer is a portal, and its clicks would otherwise bubble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AAM;AAAA,UAAG,KAAK;AAAA,UAAG,UAAU;AAAA,UAAG,IAAI;AAAA,QAAE;AAAA,QAAvE,UAAA,CAIE,gBAAA,EAAC,GAAD;AAAA,UACE,yBAAyB,EAAE,QAAQ,EAAY,UAAU;AAAA,UACzD,eAAY;AAAA,UACZ,IAAI;AAAA,YACF,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,iBAAiB;AAAA,YACjB,iBAAiB;AAAA,UACnB;AAAA,UACA,SAAQ;AAAA,QACT,CAAA,GACA,GAAK,SAAS,KACb,gBAAA,EAAC,GAAD;AAAA,UACE,iBAAe;AAAA,UACf,SAAS;AAAA,UACT,MAAK;AAAA,UACL,IAAI;AAAA,YACF,WAAW;AAAA,YAGX,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,GAAI,KAAiB;AAAA,cACnB,OAAO;AAAA,cACP,QAAQ;AAAA,YACV;AAAA,UACF;AAAA,UACA,SAAQ;AAAA,UAER,UAAA,gBAAA,EAAC,GAAD;AAAA,YAAM,MAAM;AAAA,YAAM,SAAQ;AAAA,YACvB,UAAA,EAAI;AAAA,UACD,CAAA;AAAA,QACA,CAAA,CAEL;AAAA,MAEP,CAAA,GAAA,gBAAA,EAAC,IAAD;AAAA,QACE,MAAM,EAAc;AAAA,QACpB,MAAM;AAAA,QACN,UAAU,EAAQ;AAAA,QAClB,SAAS,EAAc;AAAA,MACxB,CAAA,CACI;AAAA,IACH,CAAA,CAAA;AAAA,EAEL,CAAA,GAAA,KAAQ,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA,CACxC,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { useGlobalStore, useInsightsV2Store } from '../../common'\nimport { TinyBarChart } from '../../common/components/TinyBarChart'\nimport { slot } from '../../core'\nimport type {\n Beat,\n DataSeries,\n InsightsPayload,\n InstanceSlotData,\n LogoRef,\n PrimaryCTA,\n} from '../../core'\nimport type { ActionDrawerTrigger } from '../../core/stores'\nimport type { AccountSwitchBlockV2Data } from '../../core/types/InsightsInstanceSlotData'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport {\n BAR_ARIA_LABEL,\n buildChartData,\n buildDataSeries,\n} from '../blocks/ChartBlocks/BarchartBlock/utils'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport { postCtaMessage } from '../ctaActions'\nimport { asLogoRef } from '../blocks/slotReaders'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\nconst DESCRIPTION_MAX_LINES = 2\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n /** The slot's whole `data`, for a visual drawn from more than the logo (`category_color`, `linked_logos`). */\n data?: InstanceSlotData\n /** The envelope's template, for a beat's own badge on `linked_logos`. */\n template?: string\n}\n\n// Figma 1943:219189: 36px logos at opposite corners of a 75×74 box, the badge and rings centred.\nconst LINKED_LOGO_SIZE = 36\nconst LINKED_BOX_WIDTH = 75\nconst LINKED_BOX_HEIGHT = 74\n\nconst CENTRED = {\n left: '50%',\n position: 'absolute',\n top: '50%',\n transform: 'translate(-50%, -50%)',\n} as const\n\n/** Figma 222:33404 (Embedded | Bill Amount Not Standard) shows the latest three bars. */\nconst BAR_CHART_BAR_COUNT = 3\n\nconst EMBEDDED_BAR_CHART_HEIGHT = 54\nconst EMBEDDED_BAR_CHART_WIDTH = 75\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\nconst STACKED_LOGO_SIZE = 24\n\n/** ditto `stacked_logos`: the row logo twice, plus an error badge. The copy is `aria-hidden`, so the logo is named once. */\nconst StackedLogosVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n bottomLeft={\n logo ? (\n <Box\n aria-hidden={true}\n sx={{\n borderRadius: '6px',\n display: 'flex',\n outline: '2px solid',\n outlineColor: 'background.paper',\n overflow: 'hidden',\n }}\n >\n <LogoFromGuid logo={{ ...logo, alt: undefined }} size={STACKED_LOGO_SIZE} />\n </Box>\n ) : undefined\n }\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"error\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\nconst SWAP_BADGE_SIZE = 24\n\nconst LinkBadge = () => (\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-badge\"\n sx={{\n ...CENTRED,\n alignItems: 'center',\n bgcolor: 'primary.main',\n border: '2px solid',\n borderColor: 'primary.contrastText',\n borderRadius: '12px',\n display: 'flex',\n justifyContent: 'center',\n p: 2,\n zIndex: 1,\n }}\n >\n <Icon name=\"link\" size={16} sx={{ color: 'primary.contrastText' }} />\n </Box>\n)\n\n/**\n * Switch Direct Deposit (Figma 1941:167601): the outlined `swap_vertical_circle`, turned horizontal,\n * over a contrast disc: a primary ring and arrows on white. Drawn 1.2× so its circle fills 24px.\n */\nconst SwapBadge = () => (\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-badge\"\n sx={{\n ...CENTRED,\n alignItems: 'center',\n bgcolor: 'primary.contrastText',\n borderRadius: '50%',\n display: 'flex',\n height: SWAP_BADGE_SIZE,\n justifyContent: 'center',\n overflow: 'hidden',\n width: SWAP_BADGE_SIZE,\n zIndex: 1,\n }}\n >\n <Icon\n name=\"swap_vertical_circle\"\n size={SWAP_BADGE_SIZE * 1.2}\n sx={{ color: 'primary.main', flexShrink: 0, transform: 'rotate(-90deg)' }}\n />\n </Box>\n)\n\n/**\n * ditto `linked_logos` (Figma 1943:219189, Embedded | Discovered Accounts): the two institutions at\n * opposite corners of a 75×74 box — `from_logo` top-left, `to_logo` bottom-right — meeting on the\n * diagonal, with a badge over two rings at the centre (Switch Direct Deposit: the swap badge on an\n * outlined inner ring). The rings and badge are decorative (`aria-hidden`); each logo's accessible\n * name is its `alt`.\n */\nconst LinkedLogosVisual = ({ data, template }: InsightVisualProps) => {\n const { from_logo, to_logo } = (data ?? {}) as AccountSwitchBlockV2Data\n const isSwap = template === 'SwitchDirectDeposit'\n\n return (\n <Box\n sx={{\n flexShrink: 0,\n height: LINKED_BOX_HEIGHT,\n position: 'relative',\n width: LINKED_BOX_WIDTH,\n }}\n >\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{\n ...CENTRED,\n borderRadius: '50%',\n height: 36,\n width: 36,\n ...(isSwap\n ? { border: '2px solid', borderColor: 'primary.light' }\n : { bgcolor: 'primary.light' }),\n }}\n />\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{\n ...CENTRED,\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '50%',\n height: 48,\n width: 48,\n }}\n />\n <Box sx={{ borderRadius: '4px', left: 0, overflow: 'hidden', position: 'absolute', top: 0 }}>\n <LogoFromGuid logo={from_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n <Box\n sx={{ borderRadius: '4px', bottom: 0, overflow: 'hidden', position: 'absolute', right: 0 }}\n >\n <LogoFromGuid logo={to_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n {isSwap ? <SwapBadge /> : <LinkBadge />}\n </Box>\n )\n}\n\n/**\n * ditto `category_color`: a tiny bar chart of the latest bars in place of the logo tile, tinted by\n * the slot's category, the newest bar solid (Figma 222:33404). Draws nothing without a series.\n */\nconst BarChartVisual = ({ data }: InsightVisualProps) => {\n const series = buildDataSeries(slot<DataSeries>(data, 'series'))\n if (!series.length) return null\n\n const categoryGuid = slot<string>(data, 'category_guid')\n const bars = buildChartData(series, BAR_ARIA_LABEL).slice(-BAR_CHART_BAR_COUNT)\n\n return (\n <Box data-testid=\"compact-insight-card-bar-chart\" sx={{ flexShrink: 0 }}>\n <TinyBarChart\n color={(theme) =>\n categoryGuid ? getCategoryColor(categoryGuid, theme) : theme.palette.primary.main\n }\n data={bars}\n height={EMBEDDED_BAR_CHART_HEIGHT}\n width={EMBEDDED_BAR_CHART_WIDTH}\n />\n </Box>\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n category_color: BarChartVisual,\n linked_logos: LinkedLogosVisual,\n minimal: PlainVisual,\n stacked_logos: StackedLogosVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\n/**\n * Beats whose embedded CTA the card reads from its own envelope key and opens in this card's\n * `ActionBlockLayer`, as a bar click does on the full card. The trigger names that key, so the layer\n * resolves the same CTA. Without a trigger the link posts its host message instead (Switch Direct\n * Deposit's op_1: Atomic runs only in pulse). Every other beat keeps `primary_cta` and hands it to\n * the host's `onCtaClick` (e.g. `contact_support_block`). A new beat adds its template here.\n */\nconst BEAT_CTA_CONFIG: Record<\n string,\n { key: 'primary_cta' | 'in_description_cta'; trigger?: ActionDrawerTrigger }\n> = {\n BillAmountNotStandard: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n ConnectDiscoveredAccountsV2: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n DuplicatePaymentV2: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n SwitchDirectDeposit: { key: 'in_description_cta' },\n}\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /** The envelope's beat; when given, the card mounts its `ActionBlockLayer` for CTA drawers. */\n beat?: Beat\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n beat,\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const stores = useGlobalStore()\n const { openActionDrawer } = useInsightsV2Store()\n const { description, instance_slot, primary_cta, title } = payload\n const beatCta = BEAT_CTA_CONFIG[payload.template ?? '']\n const cta = beatCta ? payload[beatCta.key] : primary_cta\n const message = payload.in_description_cta?.post_message_metadata\n // A link that posts needs its beat and message; without them it draws nothing.\n const canAct = !beatCta || !!beatCta.trigger || (!!beat && !!message)\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = asLogoRef(slot(instance_slot.data, 'logo'))\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !cta) return\n\n if (beatCta) {\n if (beat && beatCta.trigger) openActionDrawer({ guid: beat.guid, trigger: beatCta.trigger })\n else if (beat && message) {\n const { action, ...extras } = message\n postCtaMessage({ beat, stores }, { action, payload: extras })\n }\n return\n }\n if (primary_cta) onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <>\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 16, pl: 8 }}>\n <Stack sx={{ alignSelf: 'stretch', flex: 1, gap: 8, minWidth: 0, pt: 2 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n sx={{\n display: '-webkit-box',\n fontWeight: 'fontWeightRegular',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: DESCRIPTION_MAX_LINES,\n }}\n variant=\"subtitle2\"\n />\n {cta?.label && canAct && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // The label lines up with the description (the column pads 8; the tap target keeps\n // its padding). `my: 0` drops the theme's -12px text-button margin.\n ml: -8,\n my: 0,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n <Text bold={true} variant=\"body2\">\n {cta.label}\n </Text>\n </Button>\n )}\n </Stack>\n\n <InsightVisual\n data={instance_slot.data}\n logo={rowLogo}\n template={payload.template}\n variant={instance_slot.variant}\n />\n </Stack>\n </Card>\n {/* Outside the Card: the drawer is a portal, and its clicks would otherwise bubble to `onTap`. */}\n {beat && <ActionBlockLayer beat={beat} />}\n </>\n )\n}\n\nexport default CompactInsightCard\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,KAAwB,GAGxB,IAAY,IAYZ,IAAmB,IACnB,KAAmB,IACnB,KAAoB,IAEpB,IAAU;AAAA,EACd,MAAM;AAAA,EACN,UAAU;AAAA,EACV,KAAK;AAAA,EACL,WAAW;AACb,GAKM,KAA4B,IAC5B,KAA2B,IAG3B,IAAA,CAAkB,EAAE,MAAA,EAAA,MACxB,IACE,gBAAA,EAAC,GAAD;AAAA,EAAoB,MAAA;AAAA,EAAM,MAAM;AAAY,CAAA,IAE5C,gBAAA,EAAC,GAAD;AAAA,EACE,eAAY;AAAA,EACZ,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAU,MAAM;AAAA,IAAM,MAAK;AAAA,IAAY,MAAM;AAAA,EAAK,CAAA;AAC3D,CAAA,GAIH,IAAA,CAAe,EAAE,MAAA,EAAA,MACrB,gBAAA,EAA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A,EAAI;AAAA,UACD,CAAA;AAAA,QACA,CAAA,CAEL;AAAA,MAEP,CAAA,GAAA,gBAAA,EAAC,IAAD;AAAA,QACE,MAAM,EAAc;AAAA,QACpB,MAAM;AAAA,QACN,UAAU,EAAQ;AAAA,QAClB,SAAS,EAAc;AAAA,MACxB,CAAA,CACI;AAAA,IACH,CAAA,CAAA;AAAA,EAEL,CAAA,GAAA,KAAQ,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA,CACxC,EAAA,CAAA;AAEN"}
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import { GlobalDataContext as
|
|
2
|
-
import { slot as
|
|
3
|
-
import { resolveInsightRender as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { GlobalDataContext as Z } from "../../common/context/GlobalDataProvider.es.js";
|
|
2
|
+
import { slot as k } from "../../core/types/Insights.es.js";
|
|
3
|
+
import { resolveInsightRender as b } from "../../insights-v2/resolveInsightRender.es.js";
|
|
4
|
+
import { asLogoRef as S } from "../../insights-v2/blocks/slotReaders.es.js";
|
|
5
|
+
import { hasDrawerBlock as ii } from "../../insights-v2/mappings/hasDrawerBlock.es.js";
|
|
6
|
+
import ti, { isLogoGuid as ei } from "../../insights-v2/components/LogoFromGuid.es.js";
|
|
7
|
+
import { statusIconAccentColor as oi, statusIconName as x, statusIconPalette as ri } from "../../insights-v2/components/statusIcon.es.js";
|
|
8
|
+
import { ON_CLICK_EVENT as L, ON_VIEW_EVENT as ni, ON_VIEW_FIRST_TIME_EVENT as si } from "../constants/Analytics.es.js";
|
|
9
|
+
import q from "../beaticons/BeatMaterialIcon.es.js";
|
|
10
|
+
import { BeatIcon as ci } from "../beaticons/BeatIcon.es.js";
|
|
11
|
+
import { useCopyStore as mi, useEvent as li, useInsightsMicroWidgetStore as ai } from "../context/hooks.es.js";
|
|
12
|
+
import { microCardMinWidth as pi } from "../utils/cardWidth.es.js";
|
|
13
|
+
import D from "../MicroCardTemplate.es.js";
|
|
14
|
+
import di from "./InlineActionBlock.es.js";
|
|
15
|
+
import { MicroCtaStatusGate as _i } from "./MicroCtaStatus.es.js";
|
|
16
|
+
import ui from "../../insights-v2/components/InsightErrorCard.es.js";
|
|
17
|
+
import gi, { useEffect as j, useState as fi } from "react";
|
|
18
|
+
import { Fragment as hi, jsx as e, jsxs as Ii } from "react/jsx-runtime";
|
|
19
|
+
import { alpha as z, useTheme as Ci } from "@mui/material/styles";
|
|
20
|
+
import yi from "@mui/material/Box";
|
|
21
|
+
import { useInView as vi } from "react-intersection-observer";
|
|
22
|
+
var zi = ({ ariaLabel: g, beat: i, elevation: N, inDescriptionCtaBehavior: H = "external", index: s, isActiveCard: f, onCardClick: c, posthog: o, widthOverrides: h, variant: R, showIcon: T, heightOverrides: I }) => {
|
|
23
|
+
const { ref: C, inView: m } = vi({ threshold: 1 }), y = Ci(), { cardsCopy: K } = mi(), { onEvent: l } = li(), { updateBeat: $, updateOffer: J } = ai(), a = "is_insights_v2" in i && i.is_insights_v2, p = a ? { metadata: { is_insights_v2: !0 } } : void 0;
|
|
24
|
+
j(() => {
|
|
25
|
+
m && (i.has_been_displayed ? l(ni(i.template), p) : (i.guid.startsWith("OFR") ? J({
|
|
25
26
|
...i,
|
|
26
27
|
has_been_displayed: !0
|
|
27
|
-
}) :
|
|
28
|
+
}) : $({
|
|
28
29
|
...i,
|
|
29
30
|
has_been_displayed: !0
|
|
30
|
-
}),
|
|
31
|
-
}, [
|
|
32
|
-
if (
|
|
31
|
+
}), l(si(i.template), p)));
|
|
32
|
+
}, [m]), j(() => {
|
|
33
|
+
if (m && i) if (i.template === "MarketingOffer") {
|
|
33
34
|
const t = i;
|
|
34
|
-
|
|
35
|
+
o?.capture("viewed_messaging_insight", {
|
|
35
36
|
template: i.template,
|
|
36
37
|
campaign_guid: t.campaign_guid,
|
|
37
38
|
campaign_name: t.pulse_campaign_name,
|
|
38
39
|
offer_guid: t.guid,
|
|
39
40
|
user_guid: t.user_guid
|
|
40
41
|
});
|
|
41
|
-
} else
|
|
42
|
+
} else o?.capture("viewed_insight", {
|
|
42
43
|
beat_guid: i.guid,
|
|
43
44
|
template: i.template,
|
|
44
45
|
position: s,
|
|
@@ -47,26 +48,26 @@ var Gi = ({ ariaLabel: g, beat: i, elevation: k, inDescriptionCtaBehavior: L = "
|
|
|
47
48
|
}, [
|
|
48
49
|
i,
|
|
49
50
|
s,
|
|
50
|
-
|
|
51
|
+
m
|
|
51
52
|
]);
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
53
|
+
const V = b(i), r = V === "v2" ? i.insights_payload : void 0, Q = gi.useContext(Z) !== null, B = H === "internal" && Q && ii(r?.in_description_cta?.block), [M, U] = fi(0), d = () => {
|
|
54
|
+
if (B ? U((t) => t + 1) : c && c(i), l(L(i.template), p), i.template === "MarketingOffer") {
|
|
54
55
|
const t = i;
|
|
55
|
-
|
|
56
|
+
o?.capture("clicked_messaging_insight", {
|
|
56
57
|
template: i.template,
|
|
57
58
|
campaign_guid: t.campaign_guid,
|
|
58
59
|
campaign_name: t.pulse_campaign_name,
|
|
59
60
|
offer_guid: t.guid,
|
|
60
61
|
user_guid: t.user_guid
|
|
61
62
|
});
|
|
62
|
-
} else
|
|
63
|
+
} else o?.capture("clicked_insight", {
|
|
63
64
|
beat_guid: i.guid,
|
|
64
65
|
template: i.template,
|
|
65
66
|
position: s,
|
|
66
67
|
...a && { is_insights_v2: !0 }
|
|
67
68
|
});
|
|
68
69
|
};
|
|
69
|
-
return
|
|
70
|
+
return V === "error" ? /* @__PURE__ */ e(yi, {
|
|
70
71
|
"aria-hidden": !f,
|
|
71
72
|
"aria-label": g,
|
|
72
73
|
"aria-roledescription": "slide",
|
|
@@ -74,74 +75,74 @@ var Gi = ({ ariaLabel: g, beat: i, elevation: k, inDescriptionCtaBehavior: L = "
|
|
|
74
75
|
role: "group",
|
|
75
76
|
sx: {
|
|
76
77
|
height: I ? "100%" : 120,
|
|
77
|
-
minWidth:
|
|
78
|
+
minWidth: pi(h),
|
|
78
79
|
my: 1
|
|
79
80
|
},
|
|
80
|
-
children: /* @__PURE__ */ e(
|
|
81
|
-
}) :
|
|
81
|
+
children: /* @__PURE__ */ e(ui, { beat: i })
|
|
82
|
+
}) : r ? /* @__PURE__ */ e(_i, {
|
|
82
83
|
beat: i,
|
|
83
|
-
posthog:
|
|
84
|
+
posthog: o,
|
|
84
85
|
children: ({ presentation: n }) => {
|
|
85
|
-
const
|
|
86
|
-
c && c(i),
|
|
86
|
+
const w = n?.kind === "status" ? n : void 0, { data: v } = r.instance_slot, _ = S(k(v, "logo")), P = [w ? k(v, "reviewed_icon") : void 0, k(v, "icon")].map(S).find((Y) => x(Y?.guid)), E = x(_?.guid), W = E ? _?.color || "primary.main" : P?.color, A = E ?? x(P?.guid), F = ri(W), u = oi(y.palette, W), X = n ? w?.action?.label : r.primary_cta?.label || r.in_description_cta?.label || void 0, G = () => {
|
|
87
|
+
c && c(i), l(L(i.template), p), o?.capture("clicked_insight", {
|
|
87
88
|
beat_guid: i.guid,
|
|
88
89
|
template: i.template,
|
|
89
90
|
position: s,
|
|
90
91
|
...a && { is_insights_v2: !0 }
|
|
91
92
|
});
|
|
92
|
-
},
|
|
93
|
+
}, O = /* @__PURE__ */ e(D, {
|
|
93
94
|
"aria-roledescription": "slide",
|
|
94
95
|
ariaLabel: g,
|
|
95
|
-
description:
|
|
96
|
-
elevation:
|
|
96
|
+
description: r.description.html_text,
|
|
97
|
+
elevation: N,
|
|
97
98
|
heightOverrides: I,
|
|
98
|
-
icon:
|
|
99
|
-
logo:
|
|
99
|
+
icon: T && (ei(_?.guid) && !E ? /* @__PURE__ */ e(ti, {
|
|
100
|
+
logo: _,
|
|
100
101
|
size: 32
|
|
101
|
-
}) :
|
|
102
|
-
bgColor:
|
|
103
|
-
iconColor: u ? "inherit" :
|
|
104
|
-
name:
|
|
102
|
+
}) : A ? /* @__PURE__ */ e(q, {
|
|
103
|
+
bgColor: z(u ?? y.palette[F].main, 0.15),
|
|
104
|
+
iconColor: u ? "inherit" : F,
|
|
105
|
+
name: A,
|
|
105
106
|
sx: u ? { color: u } : void 0
|
|
106
|
-
}) : /* @__PURE__ */ e(
|
|
107
|
-
bgColor:
|
|
107
|
+
}) : /* @__PURE__ */ e(q, {
|
|
108
|
+
bgColor: z(y.palette.primary.main, 0.15),
|
|
108
109
|
name: "lightbulb"
|
|
109
110
|
})),
|
|
110
111
|
isActiveCard: f,
|
|
111
112
|
isInsightsV2: !0,
|
|
112
|
-
onCardClick: n ?
|
|
113
|
-
onPrimaryAction: n ?
|
|
114
|
-
primaryActionText:
|
|
113
|
+
onCardClick: n ? G : d,
|
|
114
|
+
onPrimaryAction: n ? G : d,
|
|
115
|
+
primaryActionText: X,
|
|
115
116
|
ref: C,
|
|
116
|
-
title: n?.title ||
|
|
117
|
-
variant:
|
|
117
|
+
title: n?.title || r.title || "",
|
|
118
|
+
variant: R,
|
|
118
119
|
widthOverrides: h
|
|
119
120
|
});
|
|
120
|
-
return
|
|
121
|
+
return B ? /* @__PURE__ */ Ii(hi, { children: [O, M > 0 && /* @__PURE__ */ e(di, {
|
|
121
122
|
beat: i,
|
|
122
|
-
openRequest:
|
|
123
|
-
posthog:
|
|
124
|
-
})] }) :
|
|
123
|
+
openRequest: M,
|
|
124
|
+
posthog: o
|
|
125
|
+
})] }) : O;
|
|
125
126
|
}
|
|
126
|
-
}) : /* @__PURE__ */ e(
|
|
127
|
+
}) : /* @__PURE__ */ e(D, {
|
|
127
128
|
"aria-roledescription": "slide",
|
|
128
129
|
ariaLabel: g,
|
|
129
130
|
description: i?.html_micro_description && i?.html_micro_description.length > 0 ? i.html_micro_description : i.html_description || "",
|
|
130
|
-
elevation:
|
|
131
|
+
elevation: N,
|
|
131
132
|
heightOverrides: I,
|
|
132
|
-
icon:
|
|
133
|
+
icon: T && /* @__PURE__ */ e(ci, { beat: i }),
|
|
133
134
|
isActiveCard: f,
|
|
134
|
-
onCardClick:
|
|
135
|
-
onPrimaryAction:
|
|
136
|
-
primaryActionText: i.micro_call_to_action ||
|
|
135
|
+
onCardClick: d,
|
|
136
|
+
onPrimaryAction: d,
|
|
137
|
+
primaryActionText: i.micro_call_to_action || K?.micro_card_cta,
|
|
137
138
|
ref: C,
|
|
138
139
|
title: i.micro_title && i.micro_title.length > 0 ? i.micro_title : i.title,
|
|
139
|
-
variant:
|
|
140
|
+
variant: R,
|
|
140
141
|
widthOverrides: h
|
|
141
142
|
});
|
|
142
143
|
};
|
|
143
144
|
export {
|
|
144
|
-
|
|
145
|
+
zi as InsightCard
|
|
145
146
|
};
|
|
146
147
|
|
|
147
148
|
//# 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, useState } 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 { ICON_SIZE, VIEW_THRESHOLD } from '../constants/App'\nimport { microCardMinWidth } from '../utils/cardWidth'\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 import, not the `common` barrel, which would pull the shared layer into the micro bundle.\nimport { GlobalDataContext } from '../../common/context/GlobalDataProvider'\n// TODO: load this with `React.lazy` to keep the block registry and charts out of the micro bundle,\n// once it is verified in every host that embeds the micro widget.\nimport InlineActionBlock from './InlineActionBlock'\nimport MicroCtaStatusGate, { type MicroCtaStatus } from './MicroCtaStatus'\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 {\n statusIconAccentColor,\n statusIconName,\n statusIconPalette,\n} from '../../insights-v2/components/statusIcon'\nimport { hasDrawerBlock } from '../../insights-v2/mappings/hasDrawerBlock'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\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 inDescriptionCtaBehavior = 'external',\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 const isV2 = 'is_insights_v2' in beat && beat.is_insights_v2\n const eventProps = isV2 ? { metadata: { is_insights_v2: true } } : undefined\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), eventProps)\n } else {\n onEvent(ON_VIEW_EVENT(beat.template), eventProps)\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 ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\n }, [beat, index, inView])\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n // Only a V2 beat whose `in_description_cta` names a drawer block opens in place; everything else\n // keeps the host's behavior. Micro sends its one action as `in_description_cta`.\n // It also needs the host's `GlobalDataProvider`; without one the tap goes to the host instead.\n const hasGlobalData = React.useContext(GlobalDataContext) !== null\n const opensInline =\n inDescriptionCtaBehavior === 'internal' &&\n hasGlobalData &&\n hasDrawerBlock(v2Payload?.in_description_cta?.block)\n\n // *************** Click handlers ************************\n // Taps that opened the beat's own action block.\n const [inlineOpenRequest, setInlineOpenRequest] = useState(0)\n\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n // Internal opens the block here and skips the host's `onCardClick`; analytics are unchanged.\n if (opensInline) {\n setInlineOpenRequest((count) => count + 1)\n } else {\n onCardClick && onCardClick(beat)\n }\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\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 ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\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: microCardMinWidth(widthOverrides),\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 // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no row logo may name a status icon instead (account_block `minimal`: `ICO-error`),\n // drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n // The status tile takes the palette the slot names (Payday's on-track check is `success.main`),\n // falling back to error. `||` on the label: the copy may send the primary label as \"\".\n // Answered (mirrors the full card): reviewed title, icon and the Undo label. Display only: the card\n // and its label tap go to the host, which opens the insight with its block; nothing runs here.\n const renderCard = ({ presentation }: MicroCtaStatus) => {\n const answered = presentation?.kind === 'status' ? presentation : undefined\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(\n v2Payload.instance_slot.data,\n answered && slot<LogoRef>(v2Payload.instance_slot.data, 'reviewed_icon')\n ? 'reviewed_icon'\n : 'icon',\n )\n // An `ICO-` row logo is an icon, not an entity logo: it takes the same tinted tile (Figma Micro\n // Card) and wins over the status icon, as a row logo always has. The no-colour defaults differ\n // on purpose: a row icon with none is decorative (primary), a status icon with none is an error.\n const rowIconName = statusIconName(rowLogo?.guid)\n const tileColor = rowIconName ? rowLogo?.color || 'primary.main' : statusIcon?.color\n const tileName = rowIconName ?? statusIconName(statusIcon?.guid)\n const tilePalette = statusIconPalette(tileColor)\n // A non-status icon (`primary.main`, `chart.*`) tints the tile in its own colour.\n const tileAccent = statusIconAccentColor(theme.palette, tileColor)\n const actionLabel = presentation\n ? answered?.action?.label\n : v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n const handleHostClick = () => {\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n\n const card = (\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 && !rowIconName ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : tileName ? (\n <BeatMaterialIcon\n bgColor={alpha(tileAccent ?? theme.palette[tilePalette].main, 0.15)}\n iconColor={tileAccent ? 'inherit' : tilePalette}\n name={tileName}\n sx={tileAccent ? { color: tileAccent } : undefined}\n />\n ) : (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette.primary.main, 0.15)}\n name=\"lightbulb\"\n />\n ))\n }\n isActiveCard={isActiveCard}\n isInsightsV2={true}\n onCardClick={presentation ? handleHostClick : handleClick}\n onPrimaryAction={presentation ? handleHostClick : handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={presentation?.title || v2Payload.title || ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n\n if (!opensInline) return card\n\n return (\n <>\n {card}\n {/* Nothing renders until the first tap. */}\n {inlineOpenRequest > 0 && (\n <InlineActionBlock\n beat={beat as Beat}\n openRequest={inlineOpenRequest}\n posthog={posthog}\n />\n )}\n </>\n )\n }\n\n return (\n <MicroCtaStatusGate beat={beat as Beat} posthog={posthog}>\n {renderCard}\n </MicroCtaStatusGate>\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":";;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,0BAAA,IAA2B,YAC3B,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,GAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,GAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,GAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,GAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,GAA4B,GAE1D,IAAO,oBAAoB,KAAQ,EAAK,gBACxC,IAAa,IAAO,EAAE,UAAU,EAAE,gBAAgB,GAAK,EAAE,IAAI;AAGnE,EAAA,EAAA,MAAgB;AACd,IAAI,MACG,EAAK,qBAcR,EAAQ,GAAc,EAAK,QAAQ,GAAG,CAAU,KAb5C,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,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AAAA,IACjB,MAAM,KAAY,gBAAA,EAAC,IAAD,EAAgB,MAAA,EAAO,CAAA;AAAA,IAC3B,cAAA;AAAA,IACd,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB,EAAK,wBAAwB,GAAW;AAAA,IACtD,KAAA;AAAA,IACL,OAAO,EAAK,eAAe,EAAK,YAAY,SAAS,IAAI,EAAK,cAAc,EAAK;AAAA,IACxE,SAAA;AAAA,IACO,gBAAA;AAAA,EACjB,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect, useState } 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 { ICON_SIZE, VIEW_THRESHOLD } from '../constants/App'\nimport { microCardMinWidth } from '../utils/cardWidth'\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 MicroCardTemplate from '../MicroCardTemplate'\n// Leaf import, not the `common` barrel, which would pull the shared layer into the micro bundle.\nimport { GlobalDataContext } from '../../common/context/GlobalDataProvider'\n// TODO: load this with `React.lazy` to keep the block registry and charts out of the micro bundle,\n// once it is verified in every host that embeds the micro widget.\nimport InlineActionBlock from './InlineActionBlock'\nimport MicroCtaStatusGate, { type MicroCtaStatus } from './MicroCtaStatus'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport { asLogoRef } from '../../insights-v2/blocks/slotReaders'\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid, { isLogoGuid } from '../../insights-v2/components/LogoFromGuid'\nimport {\n statusIconAccentColor,\n statusIconName,\n statusIconPalette,\n} from '../../insights-v2/components/statusIcon'\nimport { hasDrawerBlock } from '../../insights-v2/mappings/hasDrawerBlock'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\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 inDescriptionCtaBehavior = 'external',\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 const isV2 = 'is_insights_v2' in beat && beat.is_insights_v2\n const eventProps = isV2 ? { metadata: { is_insights_v2: true } } : undefined\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), eventProps)\n } else {\n onEvent(ON_VIEW_EVENT(beat.template), eventProps)\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 ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\n }, [beat, index, inView])\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n // Only a V2 beat whose `in_description_cta` names a drawer block opens in place; everything else\n // keeps the host's behavior. Micro sends its one action as `in_description_cta`.\n // It also needs the host's `GlobalDataProvider`; without one the tap goes to the host instead.\n const hasGlobalData = React.useContext(GlobalDataContext) !== null\n const opensInline =\n inDescriptionCtaBehavior === 'internal' &&\n hasGlobalData &&\n hasDrawerBlock(v2Payload?.in_description_cta?.block)\n\n // *************** Click handlers ************************\n // Taps that opened the beat's own action block.\n const [inlineOpenRequest, setInlineOpenRequest] = useState(0)\n\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n // Internal opens the block here and skips the host's `onCardClick`; analytics are unchanged.\n if (opensInline) {\n setInlineOpenRequest((count) => count + 1)\n } else {\n onCardClick && onCardClick(beat)\n }\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\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 ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\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: microCardMinWidth(widthOverrides),\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 // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no usable row logo may name a status icon instead (account_block `minimal`:\n // `ICO-error`), drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n // The status tile takes the palette the slot names (Payday's on-track check is `success.main`),\n // falling back to error. `||` on the label: the copy may send the primary label as \"\".\n // Answered (mirrors the full card): reviewed title, icon and the Undo label. Display only: the card\n // and its label tap go to the host, which opens the insight with its block; nothing runs here.\n const renderCard = ({ presentation }: MicroCtaStatus) => {\n const answered = presentation?.kind === 'status' ? presentation : undefined\n const { data } = v2Payload.instance_slot\n const rowLogo = asLogoRef(slot(data, 'logo'))\n // The reviewed icon once answered, else the icon: whichever names a status icon first.\n const statusIcon = [answered ? slot(data, 'reviewed_icon') : undefined, slot(data, 'icon')]\n .map(asLogoRef)\n .find((ref) => statusIconName(ref?.guid))\n // An `ICO-` row logo is an icon, not an entity logo: it takes the same tinted tile (Figma Micro\n // Card) and wins over the status icon, as a row logo always has. The no-colour defaults differ\n // on purpose: a row icon with none is decorative (primary), a status icon with none is an error.\n const rowIconName = statusIconName(rowLogo?.guid)\n const tileColor = rowIconName ? rowLogo?.color || 'primary.main' : statusIcon?.color\n const tileName = rowIconName ?? statusIconName(statusIcon?.guid)\n const tilePalette = statusIconPalette(tileColor)\n // A non-status icon (`primary.main`, `chart.*`) tints the tile in its own colour.\n const tileAccent = statusIconAccentColor(theme.palette, tileColor)\n const actionLabel = presentation\n ? answered?.action?.label\n : v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n const handleHostClick = () => {\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n\n const card = (\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 (isLogoGuid(rowLogo?.guid) && !rowIconName ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : tileName ? (\n <BeatMaterialIcon\n bgColor={alpha(tileAccent ?? theme.palette[tilePalette].main, 0.15)}\n iconColor={tileAccent ? 'inherit' : tilePalette}\n name={tileName}\n sx={tileAccent ? { color: tileAccent } : undefined}\n />\n ) : (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette.primary.main, 0.15)}\n name=\"lightbulb\"\n />\n ))\n }\n isActiveCard={isActiveCard}\n isInsightsV2={true}\n onCardClick={presentation ? handleHostClick : handleClick}\n onPrimaryAction={presentation ? handleHostClick : handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={presentation?.title || v2Payload.title || ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n\n if (!opensInline) return card\n\n return (\n <>\n {card}\n {/* Nothing renders until the first tap. */}\n {inlineOpenRequest > 0 && (\n <InlineActionBlock\n beat={beat as Beat}\n openRequest={inlineOpenRequest}\n posthog={posthog}\n />\n )}\n </>\n )\n }\n\n return (\n <MicroCtaStatusGate beat={beat as Beat} posthog={posthog}>\n {renderCard}\n </MicroCtaStatusGate>\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":";;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,0BAAA,IAA2B,YAC3B,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,GAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,GAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,GAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,GAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,GAA4B,GAE1D,IAAO,oBAAoB,KAAQ,EAAK,gBACxC,IAAa,IAAO,EAAE,UAAU,EAAE,gBAAgB,GAAK,EAAE,IAAI;AAGnE,EAAA,EAAA,MAAgB;AACd,IAAI,MACG,EAAK,qBAcR,EAAQ,GAAc,EAAK,QAAQ,GAAG,CAAU,KAb5C,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,GAAyB,EAAK,QAAQ,GAAG,CAAU;AAAA,EAKjE,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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