@mx-cartographer/experiences 9.7.74 → 9.7.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/core/types/Insights.d.ts +2 -7
  3. package/dist/core/types/Insights.es.js.map +1 -1
  4. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +37 -37
  5. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
  6. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +10 -0
  7. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +12 -7
  8. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
  9. package/dist/insights-v2/actionBlocks/SurveyModalActionBlock.es.js +28 -20
  10. package/dist/insights-v2/actionBlocks/SurveyModalActionBlock.es.js.map +1 -1
  11. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +11 -11
  12. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +3 -3
  13. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.d.ts +7 -14
  14. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js +11 -27
  15. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js.map +1 -1
  16. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +75 -68
  17. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
  18. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +4 -1
  19. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +2 -1
  20. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
  21. package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +4 -4
  22. package/dist/insights-v2/components/BaseLayout.es.js +40 -40
  23. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  24. package/dist/insights-v2/components/CtaStatus.d.ts +2 -2
  25. package/dist/insights-v2/components/CtaStatus.es.js +23 -14
  26. package/dist/insights-v2/components/CtaStatus.es.js.map +1 -1
  27. package/dist/insights-v2/components/FeedbackDialog.d.ts +3 -1
  28. package/dist/insights-v2/components/FeedbackDialog.es.js +28 -28
  29. package/dist/insights-v2/components/FeedbackDialog.es.js.map +1 -1
  30. package/dist/insights-v2/components/FeedbackModal.d.ts +3 -1
  31. package/dist/insights-v2/components/FeedbackModal.es.js +17 -16
  32. package/dist/insights-v2/components/FeedbackModal.es.js.map +1 -1
  33. package/dist/insights-v2/components/InsightTransactionRow.d.ts +3 -1
  34. package/dist/insights-v2/components/InsightTransactionRow.es.js +36 -19
  35. package/dist/insights-v2/components/InsightTransactionRow.es.js.map +1 -1
  36. package/dist/insights-v2/components/SavingsOpportunityCard.es.js +6 -4
  37. package/dist/insights-v2/components/SavingsOpportunityCard.es.js.map +1 -1
  38. package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.d.ts +4 -0
  39. package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.es.js +11 -0
  40. package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.es.js.map +1 -0
  41. package/dist/insights-v2/components/SurveyModal.d.ts +5 -1
  42. package/dist/insights-v2/components/SurveyModal.es.js +46 -38
  43. package/dist/insights-v2/components/SurveyModal.es.js.map +1 -1
  44. package/dist/insights-v2/ctaActions/ctaConfig.es.js +19 -11
  45. package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -1
  46. package/dist/insights-v2/ctaActions/index.d.ts +1 -1
  47. package/dist/insights-v2/ctaActions/runCtaAction.d.ts +5 -1
  48. package/dist/insights-v2/ctaActions/runCtaAction.es.js +4 -4
  49. package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -1
  50. package/dist/insights-v2/ctaActions/subscriptionAnswer.d.ts +4 -2
  51. package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js +136 -0
  52. package/dist/insights-v2/ctaActions/subscriptionAnswer.es.js.map +1 -0
  53. package/dist/insights-v2/ctaActions/types.d.ts +12 -0
  54. package/dist/insights-v2/ctaActions/useCtaAction.d.ts +4 -1
  55. package/dist/insights-v2/ctaActions/useCtaAction.es.js +33 -33
  56. package/dist/insights-v2/ctaActions/useCtaAction.es.js.map +1 -1
  57. package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -0
  58. package/dist/insights-v2/mappings/actionBlocksKey.es.js +1 -0
  59. package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
  60. package/dist/insights-v2/mappings/blocks.es.js +69 -64
  61. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  62. package/package.json +1 -1
  63. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/layout.d.ts +0 -18
  64. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/layout.es.js +0 -13
  65. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/layout.es.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [9.7.76] - 11-02-2026
2
+
3
+ - **ADDED** - Subscription Detected beat on Insights 2.0 (WEC-2147): `confirm_subscription_detected` registers the shared subscription status CTA. "Does this look right?" opens the survey, which saves the answer to the repeating transaction (Yes → `CONFIRMED`; a reason → `NEVER_SUBSCRIBED` / `CANCELLED` / `ONE_TIME_PURCHASE` / `WRONG_FREQUENCY`); the card then shows ✓ Confirmed or ✗ Incorrect with Undo. A CTA step can now bring its own survey reasons and submit (`surveyAnswer`); otherwise `survey_modal_block` sends beat feedback, and the last reason can drop its free-text field (`showDetailField`). The `info_wash` row captions the amount with the subscription's live frequency (e.g. YEARLY, from the shared `RECURRENCE_COPY` words; none while unknown) via `InsightTransactionRow` `amountCaption` and TransactionBlock `showFrequency`. Mini shows the "Does this look right?" link (its tap is the host's, as micro); a card whose action travels as `in_description_cta` now runs that step's `prepare`, so mini still loads the frequency. Fixtures, the `InsightsV2/Insights/SubscriptionDetectedV2` story and a contract test
4
+ - **CHANGED** - A CTA status's inline action (e.g. Subscription Detected's Undo) is disabled until its press settles (WEC-2147)
5
+ - **FIXED** - The survey dialog's rows match Figma: no padding under the title, a divider only between rows, filled icons and Figma spacing; the row's frequency caption sits 4px below the amount (WEC-2147)
6
+
7
+ ## [9.7.75] - 11-02-2026
8
+
9
+ - **CHANGED** - Savings Opportunity V2 card now renders from the backend contract (WEC-1866): `SavingsOpportunityBlock` is a plain component registered under `savings_amount_block` that reads its slots off `instance_slot.data` (`primary_text`, `amount`), matching what tupac and ditto emit — it was `savings_opportunity_block` reading flat `instance_slot` fields with six speculative safety-net variants, so the card would not have rendered. ditto declares one `save_amount` variant with identical visuals, so the `createVariantBlock` dispatch and `layout.ts` are removed (as with `SaveExtraBlock` / `NoSpendDaysBlock`); the dead `instance_slot.slot` type field is dropped; `BlockType` key renamed `SavingsAmountBlock`; mock fixture, stories and block tests collapsed to the single card. The block guards its unchecked `slot()` reads — a payload without a numeric amount / string caption renders nothing rather than a fabricated `$0.00` coupon. Still to do on this story: the make_transfer / open_savings CTA action blocks (net-new UI, need Figma)
10
+ - **ADDED** - Savings Opportunity V2's "Set Reminder" secondary CTA now opens the safety-net amount-input modal (WEC-1866). ditto names a dedicated `safety_net_block` on that CTA with no variant, so it is registered in `actionBlocks` to `AmountInputModalBlock` (modal presentation) alongside the shared `amount_input_modal_block`, and the block resolves its variant from the CTA that opened it (`resolveAmountInputVariant`): an explicit variant wins — so `amount_input_modal_block` keeps choosing `low_balance_threshold` / `safety_net`, and an unknown one still falls to the error dialog — otherwise `safety_net_block` selects the `safety_net` mode. The card fixture's secondary CTA points at the block; registry, layout-helper and block tests cover the new secondary-CTA path. The primary CTA ("Transfer Funds") stays a host post message with no block
11
+ - **FIXED** - Savings Opportunity V2 coupon tile (`SavingsOpportunityCard`) now matches the design (WEC-1866), per design QA against Figma `Insights-V2-Development` node `1276:45964`: (1) the "Save an extra" caption is 11px/**400** in Figma but MXUI's `caption` variant renders 700, so set `sx={{ fontWeight: 400 }}` (keeps `text.secondary` — Figma caption is black @0.6); (2) the right half of the coupon used a **12px** corner radius but Figma specifies **8px** (`radii [0,8,8,0]`), so `borderTopRightRadius` / `borderBottomRightRadius` are now `8px`; (3) the amount (`h1` = 31/700/40) now sets `color="text.primary"` explicitly to match Figma (black @0.87) instead of relying on the mxui `h1` default.
12
+
1
13
  ## [9.7.74] - 11-02-2026
2
14
 
3
15
  - **FIXED** - Bill Amount Not Standard drilldown and the shared Insights 2.0 drawer and bar chart now match Figma (WEC-2151)
@@ -265,7 +265,7 @@ export declare const BlockType: {
265
265
  readonly NoSpendDaysBlock: "no_spend_days_block";
266
266
  readonly RepeatingTransactionBlock: "repeating_transaction_block";
267
267
  readonly SaveExtraBlock: "save_extra_block";
268
- readonly SavingsOpportunityBlock: "savings_opportunity_block";
268
+ readonly SavingsAmountBlock: "savings_amount_block";
269
269
  readonly StepChartBlock: "step_chart_block";
270
270
  readonly SVGImageBlock: "svg_image_block";
271
271
  readonly UpcomingBillBlock: "upcoming_bill_block";
@@ -340,13 +340,8 @@ export interface InstanceSlot {
340
340
  merchant_name?: string;
341
341
  /** Due date of the projected bill in ISO form (e.g. `2025-10-30`). */
342
342
  due_date?: string;
343
- /** Caption shown above the amount, e.g. `Save an extra` or `Potential savings`. */
343
+ /** Caption/label line for the confetti tile (V1 fallback). */
344
344
  label?: string;
345
- /**
346
- * Whether to render the green gradient slot behind the coupon. Defaults to true. Backend sends
347
- * `false` when the coupon is embedded in a parent surface that supplies its own background.
348
- */
349
- slot?: boolean;
350
345
  /** Billing cadence word that trails the price, e.g. `month` or `year`. */
351
346
  cadence?: string;
352
347
  /** Secondary line beneath the amount on the standard card, e.g. "Remaining after expenses". */
@@ -1 +1 @@
1
- {"version":3,"file":"Insights.es.js","names":[],"sources":["../../../src/core/types/Insights.ts"],"sourcesContent":["// ============ Core InsightsV2 Types ============\n\nimport { InsightsInstanceSlotData } from './InsightsInstanceSlotData'\n\nexport interface ThemedSVGImageProps {\n divProps?: React.HTMLAttributes<HTMLDivElement>\n image: React.ComponentType<React.SVGProps<SVGSVGElement>>\n isMini?: boolean\n}\n\n/**\n * Emitted by a block when the user drills into a specific datum (e.g. clicks a\n * chart bar). Named fields rather than positional args so blocks with differing\n * shapes can extend this without the call sites transposing values.\n */\nexport interface DrilldownPayload {\n chartBarIndex: number\n tabIndex?: number\n transaction_guid?: string\n block?: string\n}\n\n/**\n * Which envelope a beat was fetched with. `embedded` (the transaction-row pill + details-drawer\n * card) and `notification` are V2 additions; a surface asks for one with `widget_type=` on the fetch.\n */\nexport type WidgetType = 'full' | 'mini' | 'micro' | 'embedded' | 'notification'\n\n/**\n * V2: the transaction-row tag, its own small section of the `embedded` envelope (the same grammar\n * as `description` / `footer`, with room for a tone or an icon later). Omitted for an insight that\n * tags no transaction row. It deliberately is *not* `short_title`, which stays a per-variant\n * attribute with a second consumer (the bank-holiday sub-header).\n */\nexport interface Pill {\n text: string\n}\n\n/**\n * V2: facts a drilldown shows that the card does not. On the payload: what every CTA of the card\n * shares (e.g. the account number for the Transaction Details drawer, or the guid list a list drawer\n * shows, `transaction_guids`). On a CTA: the figures that CTA's own drilldown renders (the Transaction\n * List summary header's `amount`, `start_date` / `end_date` and `count`, see `readSummary`). Scalars\n * or string lists, omitted when the insight has none. Never carries copy or user actions (memo,\n * tags, hide, flag come from the transaction store). Values come from the server, so a reader still\n * checks each value's runtime shape.\n */\nexport type DrilldownData = Record<string, string | number | boolean | null | string[]>\n\nexport interface InsightsPayload {\n widget_type: WidgetType\n instance_slot: InstanceSlot\n /**\n * V1 only. The v2 contract carries everything a block needs on `instance_slot.data`,\n * and omits this key entirely (see the LargeTransactionV2 payload). Blocks that still require it\n * get it as a required field through `BlockProps`, which re-declares it.\n */\n instance_slot_data?: InsightsInstanceSlotData\n description: Description\n primary_cta?: PrimaryCTA\n secondary_cta?: SecondaryCTA\n title?: string\n sub_title?: Subtitle\n /**\n * V2 rename of `sub_title`: a flat string, with the logo promoted to the payload-level `logo`\n * field below. `sub_title` wins when both are present.\n */\n subtitle?: string\n /** V2: header logo paired with the flat `subtitle`: an entity guid or a status icon (`LogoRef`). */\n logo?: LogoRef\n /** V2: which design branch the backend picked (e.g. `no_merchant`). */\n variant?: string\n /** V2, `embedded` envelope only: the transaction-row pill. */\n pill?: Pill\n /**\n * V2: drilldown-only facts, e.g. `{ account_number: 'XXXXXXXX043' }`, or the guid list a list\n * drawer shows (`{ transaction_guids: [...] }`).\n */\n drilldown_data?: DrilldownData\n footer?: Footer\n /**\n * V2: the link inside the description: on the full card a drawer of its own (Low Account\n * Balance's \"Transactions ›\"); on mini and micro the card's action, sent instead of `primary_cta`.\n * Absent when the beat has no link.\n */\n in_description_cta?: InDescriptionCTA\n guid: string\n user_guid: string\n client_guid?: string\n /** Template name, e.g. `LargeTransactionV2`. */\n template?: string\n revision?: number\n /** Unix seconds. */\n created_at?: number\n /** Unix seconds. */\n updated_at?: number\n /** Unix seconds. */\n active_at?: number\n displayed_at?: number | null\n dismissed_at: number | null\n cta_clicked_at?: number | null\n has_been_displayed?: boolean\n is_dismissed: boolean\n is_deleted?: boolean\n is_hidden_by_system?: boolean\n is_obsolete?: boolean\n is_refreshable?: boolean\n is_sampled?: boolean\n is_zero_state?: boolean\n status?: string | null\n /**\n * V2 (LargeTransactionV2 onward): the entities the beat is about, carried on the payload so\n * action blocks do not have to reach back out to the beat envelope.\n */\n primary_account_guid?: string | null\n primary_transaction_guid?: string | null\n primary_category_guid?: string | null\n primary_merchant_guid?: string | null\n /**\n * V2: the repeating transaction a subscription beat is about (Upcoming Subscription, Subscription\n * Price Increase). Read by `recurring_transaction_block`, see\n * `actionBlocks/RecurringTransactionBlock/subscriptionBeats.ts`.\n */\n primary_repeating_transaction_guid?: string | null\n}\n\nexport interface Legends {\n label: string\n value: number\n additional_value?: number\n additional_value_type?: string\n value_type?: string\n}\n\nexport interface Logo {\n category_guid?: string\n category_name?: string\n institution_guid?: string\n institution_name?: string\n logo_color?: string\n /** Draw the `logo_name` icon filled (V2 `ICO-` logos). */\n logo_fill?: boolean\n logo_name?: string\n merchant_guid?: string\n merchant_name?: string\n}\n\nexport interface Subtitle {\n logo?: Logo\n text: string\n}\n\n/**\n * A V2 logo, shared by the header (`InsightsPayload.logo`) and every instance-slot row. It takes\n * one of two shapes:\n *\n * - **Entity**: `guid`, whose prefix (`INS-` / `MCH-` / `CAT-`) picks the logo component, plus an\n * optional `fallback_guid` for when that component's asset cannot load. Today that is the\n * category behind an `MCH-` guid, which `MerchantLogo` shows as a tile when the merchant image\n * is missing.\n * - **Status icon**: `icon` (an mx-icons name, e.g. `warning`) and `color` (a theme palette path,\n * e.g. `error.main`), for subheaders that show a state rather than an entity (V1's\n * `logo_name` / `logo_color`).\n *\n * `alt` is the accessible name for either shape. A logo sends one shape; if it sends both, `icon`\n * wins, as `logo_name` does in V1's `SubHeader`.\n */\nexport interface LogoRef {\n alt?: string\n color?: string\n fallback_guid?: string\n guid?: string\n icon?: string\n}\n\nexport interface CategoryLogo {\n category_guid: string\n category_name: string\n}\n\nexport interface MerchantLogo {\n merchant_guid: string\n merchant_name: string\n}\n\nexport interface InstitutionLogo {\n institution_guid: string\n institution_name: string\n}\n\nexport interface Description {\n text: string\n html_text: string\n}\n\n/**\n * Post message a CTA press sends to the host, resolved by the backend for the beat's current\n * state. Absent/null = the backend has not described one: the frontend uses the template's\n * interim `ctaPostMessages` entry if there is one, else sends no message. `payload` carries only\n * beat-specific extras; the frontend always adds `beat_guid`, `beat_template`, `user_guid` and\n * `action_string`.\n */\nexport interface CtaPostMessageMetadata {\n /** Post message event; defaults to `beat/cta`. */\n event?: string | null\n /** Operation the host should perform, e.g. `op_1`, `op_2`, `op_3`. Defaults to `op_1`. */\n action?: string | null\n /** Beat-specific fields merged into the message metadata (account ids, amounts, ...). */\n payload?: Record<string, unknown> | null\n}\n\nexport interface PrimaryCTA {\n label: string\n block: string\n variant?: string | null\n /**\n * What pressing the CTA does beyond opening its block, named by the backend (ditto\n * `primary_cta_action`, passed through by tupac). Looked up in `insights-v2/ctaActions`;\n * null / absent / unknown means the CTA only opens its block or posts its message.\n */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface SecondaryCTA {\n label: string\n /**\n * Drawer block to open. `null` when the CTA opens nothing (ditto `secondary_cta_block: null`,\n * e.g. Fee Detected's \"Contact Support\"): the press posts its message to the host instead.\n */\n block: string | null\n variant?: string | null\n /** See `PrimaryCTA.action_key` (ditto `secondary_cta_action`). */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\n/**\n * The description link: its label, the action block it opens and, like a CTA's, the variant that\n * tells that block what to show (ditto's `in_description_cta_variant`, e.g. `low_balance`). On mini\n * and micro it words the card's action; `block` is empty when that action opens no drawer.\n */\nexport interface InDescriptionCTA {\n label: string\n block?: string\n variant?: string | null\n action_key?: string | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface Footer {\n /** V1: a pre-formatted date string. */\n date?: string\n /**\n * The account label, on both V1 and V2. The backend resolves the plurality: one account sends\n * its name (e.g. `Epic Bank`), several send a localized count (e.g. `2 Accounts`), none sends\n * `null` (tupac's `footer_account_label` returns nil for a beat with no accounts, as Payday Cash\n * Left Over Status does). There is deliberately no separate `accounts` key.\n */\n account?: string | null\n /**\n * V2 (LargeTransactionV2 onward): unix seconds, formatted by `Footer` for display.\n * Replaces `date`; `date` wins when a beat somehow sends both.\n */\n timestamp?: number\n}\n\n// ============ Instance Slot Types ============\n// Values are the snake_case block names the backend sends on a beat's instance slot; the PascalCase\n// keys stay as friendly references (e.g. BlockType.BarChartBlock === 'bar_chart_block').\nexport const BlockType = {\n AccountBlock: 'account_block',\n AccountSwitchBlock: 'account_switch_block',\n BarChartBlock: 'bar_chart_block',\n BudgetBlock: 'budget_block',\n DirectDepositBlock: 'direct_deposit_block',\n ImageBlock: 'image_block',\n MerchantBlock: 'merchant_block',\n TransactionBlock: 'transaction_block',\n DonutChartBlock: 'donut_chart_block',\n DoubleBarChartBlock: 'double_bar_chart_block',\n DoubleProgressBarBlock: 'double_progress_bar_block',\n DebtsBlock: 'debts_block',\n GoalsBlock: 'goals_block',\n NoSpendDaysBlock: 'no_spend_days_block',\n RepeatingTransactionBlock: 'repeating_transaction_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsOpportunityBlock: 'savings_opportunity_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WithdrawalBlock: 'withdrawal_block',\n} as const\n\nexport type BlockType = (typeof BlockType)[keyof typeof BlockType]\n\n/**\n * A pre-localized row on a V2 instance slot. The backend resolves the copy and formatting; the\n * logo is a `LogoRef` (an entity guid or a status icon, see `logoFromRef`).\n */\nexport interface InstanceSlotRow {\n amount?: number\n logo?: LogoRef\n primary_text?: string\n secondary_text?: string\n}\n\n/**\n * V2: the slots a block's variant filled, keyed by slot name; ditto owns the names and omits any\n * slot it has no value for (`lib/ditto/blocks/<block>.yml`). Read with `slot()`, which names the\n * kind the caller expects.\n */\nexport interface InstanceSlotData {\n [slot: string]: unknown\n}\n\n/**\n * Reads one slot off a block's `data`; undefined when ditto did not fill it.\n *\n * The caller names the kind, because the slot's kind lives in the block's ditto schema and not\n * here — a block fills slots with whatever its card needs, so no fixed list of kinds would hold\n * (`account_switch_block` alone carries a boolean and `budget_block` a nested object).\n */\nexport const slot = <T = unknown>(\n data: InstanceSlotData | undefined,\n name: string,\n): T | undefined => data?.[name] as T | undefined\n\n/**\n * V2: which block renders this beat's content, and what it renders.\n *\n * `block` is optional: a beat whose template has no ditto config arrives as an empty `{}` and the\n * card renders its copy and CTAs alone, so a reader cannot assume a block is named. One interface\n * with `block` optional rather than a union with `Record<string, never>`, which TypeScript absorbs\n * — that union left `block` reading as required and typed a promise it did not keep.\n *\n * `variant` is optional for the same reason — the empty `{}` carries neither. Every ditto beat\n * file that names a block also names a variant, so a *filled* slot always has one; ditto drops a\n * nil variant rather than sending null, which is why the type is `string | null | undefined`.\n */\nexport interface InstanceSlot {\n block?: BlockType\n variant?: string | null\n /** The slots this block's variant declares in ditto. */\n data?: InstanceSlotData\n // Direct Deposit block (Set Up Direct Deposit, Switch Direct Deposit, Missing\n // Interest Rate): account facts carried flat on the slot, beside `data`.\n /** Primary line on the hero card, e.g. \"Epic Bank Checking, *1234\". */\n account_name?: string\n /** Secondary line beneath the name, e.g. \"Checking Account\" / \"Credit Card\". */\n account_type?: string\n /** Status pill label, e.g. \"Direct Deposit Not Set Up\" / \"Interest Rate: 19.99% APR\". */\n status_text?: string\n institution_guid?: string\n institution_name?: string\n // Shared across multiple V2 component blocks:\n // `amount` — UpcomingBillBlock (projected bill), SavingsOpportunityBlock (coupon),\n // UpcomingSubscriptionBlock (price per cadence).\n // `merchant_guid` / `merchant_name` — UpcomingBillBlock (bill row logo + name),\n // UpcomingSubscriptionBlock (hero logo + name).\n /** Dollar amount (unformatted); the block formats it as currency. */\n amount?: number\n // Withdrawal block (Emergency Fund Withdrawal): one row flat on the slot - `amount` above is the\n // withdrawal, shown with its date line \"{amount_label} {withdrawal_date}\" over the balance row.\n /** Pre-localized lead-in for the date line, e.g. \"Withdrawn on\". */\n amount_label?: string\n /** The withdrawal's calendar day, `YYYY-MM-DD` (e.g. `2026-10-20`); the card formats it. */\n withdrawal_date?: string\n /** Account balance after the withdrawal (unformatted); the card formats it as currency. */\n balance?: number\n /** Pre-localized label for the balance row, e.g. \"Balance\". */\n balance_label?: string\n /** Merchant guid used to render the inline / hero logo via `LogoFromGuid` (`MCH-...`). */\n merchant_guid?: string\n /** Merchant display name — shown as logo alt text and as the merchant/hero label. */\n merchant_name?: string\n // Upcoming Bill block (Projected Bill Payment): the block derives the Sun→Sat week strip\n // around `due_date` at render time.\n /** Due date of the projected bill in ISO form (e.g. `2025-10-30`). */\n due_date?: string\n // Savings Opportunity block (Save An Extra, Potential Savings, Embedded): purely data-driven\n // coupon card. Backend sends the caption and the amount, plus `slot` to toggle the green\n // gradient background when the card is embedded in a parent surface that supplies its own.\n /** Caption shown above the amount, e.g. `Save an extra` or `Potential savings`. */\n label?: string\n /**\n * Whether to render the green gradient slot behind the coupon. Defaults to true. Backend sends\n * `false` when the coupon is embedded in a parent surface that supplies its own background.\n */\n slot?: boolean\n // Upcoming Subscription block: billing cadence for the price pill (`${amount} / ${cadence}`).\n /** Billing cadence word that trails the price, e.g. `month` or `year`. */\n cadence?: string\n // Account block (status on/off-track, deposit, payoff variants): card content carried flat on\n // the slot (the V2 contract drops `instance_slot_data`). `amount`, `label`, `merchant_guid`,\n // `merchant_name`, `institution_guid`, `institution_name` are shared fields declared above.\n /** Secondary line beneath the amount on the standard card, e.g. \"Remaining after expenses\". */\n sub_text?: string\n /** Header bar text (standard card) or the colored category strip label (deposit cards). */\n header_text?: string\n /** Generic-tile icon name used when no merchant/institution logo is available. */\n icon_name?: string\n /** Category guid used to render the deposit-card logo fallback. */\n category_guid?: string\n // Debts block: `amount` is the current balance; the shared account/institution fields above.\n /** Projected payoff date in ISO form (e.g. `2027-03-01`); the block formats it as month + year. */\n payoff_date?: string\n /** Monthly payment toward the debt (unformatted); the block formats it as currency. */\n monthly_payment?: number\n /** Annual interest rate as a percentage (e.g. `19.99`); the block formats it as a percent. */\n interest_rate?: number\n start_date?: string\n no_spend_days?: string[]\n}\n"],"mappings":"AAyUA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
1
+ {"version":3,"file":"Insights.es.js","names":[],"sources":["../../../src/core/types/Insights.ts"],"sourcesContent":["// ============ Core InsightsV2 Types ============\n\nimport { InsightsInstanceSlotData } from './InsightsInstanceSlotData'\n\nexport interface ThemedSVGImageProps {\n divProps?: React.HTMLAttributes<HTMLDivElement>\n image: React.ComponentType<React.SVGProps<SVGSVGElement>>\n isMini?: boolean\n}\n\n/**\n * Emitted by a block when the user drills into a specific datum (e.g. clicks a\n * chart bar). Named fields rather than positional args so blocks with differing\n * shapes can extend this without the call sites transposing values.\n */\nexport interface DrilldownPayload {\n chartBarIndex: number\n tabIndex?: number\n transaction_guid?: string\n block?: string\n}\n\n/**\n * Which envelope a beat was fetched with. `embedded` (the transaction-row pill + details-drawer\n * card) and `notification` are V2 additions; a surface asks for one with `widget_type=` on the fetch.\n */\nexport type WidgetType = 'full' | 'mini' | 'micro' | 'embedded' | 'notification'\n\n/**\n * V2: the transaction-row tag, its own small section of the `embedded` envelope (the same grammar\n * as `description` / `footer`, with room for a tone or an icon later). Omitted for an insight that\n * tags no transaction row. It deliberately is *not* `short_title`, which stays a per-variant\n * attribute with a second consumer (the bank-holiday sub-header).\n */\nexport interface Pill {\n text: string\n}\n\n/**\n * V2: facts a drilldown shows that the card does not. On the payload: what every CTA of the card\n * shares (e.g. the account number for the Transaction Details drawer, or the guid list a list drawer\n * shows, `transaction_guids`). On a CTA: the figures that CTA's own drilldown renders (the Transaction\n * List summary header's `amount`, `start_date` / `end_date` and `count`, see `readSummary`). Scalars\n * or string lists, omitted when the insight has none. Never carries copy or user actions (memo,\n * tags, hide, flag come from the transaction store). Values come from the server, so a reader still\n * checks each value's runtime shape.\n */\nexport type DrilldownData = Record<string, string | number | boolean | null | string[]>\n\nexport interface InsightsPayload {\n widget_type: WidgetType\n instance_slot: InstanceSlot\n /**\n * V1 only. The v2 contract carries everything a block needs on `instance_slot.data`,\n * and omits this key entirely (see the LargeTransactionV2 payload). Blocks that still require it\n * get it as a required field through `BlockProps`, which re-declares it.\n */\n instance_slot_data?: InsightsInstanceSlotData\n description: Description\n primary_cta?: PrimaryCTA\n secondary_cta?: SecondaryCTA\n title?: string\n sub_title?: Subtitle\n /**\n * V2 rename of `sub_title`: a flat string, with the logo promoted to the payload-level `logo`\n * field below. `sub_title` wins when both are present.\n */\n subtitle?: string\n /** V2: header logo paired with the flat `subtitle`: an entity guid or a status icon (`LogoRef`). */\n logo?: LogoRef\n /** V2: which design branch the backend picked (e.g. `no_merchant`). */\n variant?: string\n /** V2, `embedded` envelope only: the transaction-row pill. */\n pill?: Pill\n /**\n * V2: drilldown-only facts, e.g. `{ account_number: 'XXXXXXXX043' }`, or the guid list a list\n * drawer shows (`{ transaction_guids: [...] }`).\n */\n drilldown_data?: DrilldownData\n footer?: Footer\n /**\n * V2: the link inside the description: on the full card a drawer of its own (Low Account\n * Balance's \"Transactions ›\"); on mini and micro the card's action, sent instead of `primary_cta`.\n * Absent when the beat has no link.\n */\n in_description_cta?: InDescriptionCTA\n guid: string\n user_guid: string\n client_guid?: string\n /** Template name, e.g. `LargeTransactionV2`. */\n template?: string\n revision?: number\n /** Unix seconds. */\n created_at?: number\n /** Unix seconds. */\n updated_at?: number\n /** Unix seconds. */\n active_at?: number\n displayed_at?: number | null\n dismissed_at: number | null\n cta_clicked_at?: number | null\n has_been_displayed?: boolean\n is_dismissed: boolean\n is_deleted?: boolean\n is_hidden_by_system?: boolean\n is_obsolete?: boolean\n is_refreshable?: boolean\n is_sampled?: boolean\n is_zero_state?: boolean\n status?: string | null\n /**\n * V2 (LargeTransactionV2 onward): the entities the beat is about, carried on the payload so\n * action blocks do not have to reach back out to the beat envelope.\n */\n primary_account_guid?: string | null\n primary_transaction_guid?: string | null\n primary_category_guid?: string | null\n primary_merchant_guid?: string | null\n /**\n * V2: the repeating transaction a subscription beat is about (Upcoming Subscription, Subscription\n * Price Increase). Read by `recurring_transaction_block`, see\n * `actionBlocks/RecurringTransactionBlock/subscriptionBeats.ts`.\n */\n primary_repeating_transaction_guid?: string | null\n}\n\nexport interface Legends {\n label: string\n value: number\n additional_value?: number\n additional_value_type?: string\n value_type?: string\n}\n\nexport interface Logo {\n category_guid?: string\n category_name?: string\n institution_guid?: string\n institution_name?: string\n logo_color?: string\n /** Draw the `logo_name` icon filled (V2 `ICO-` logos). */\n logo_fill?: boolean\n logo_name?: string\n merchant_guid?: string\n merchant_name?: string\n}\n\nexport interface Subtitle {\n logo?: Logo\n text: string\n}\n\n/**\n * A V2 logo, shared by the header (`InsightsPayload.logo`) and every instance-slot row. It takes\n * one of two shapes:\n *\n * - **Entity**: `guid`, whose prefix (`INS-` / `MCH-` / `CAT-`) picks the logo component, plus an\n * optional `fallback_guid` for when that component's asset cannot load. Today that is the\n * category behind an `MCH-` guid, which `MerchantLogo` shows as a tile when the merchant image\n * is missing.\n * - **Status icon**: `icon` (an mx-icons name, e.g. `warning`) and `color` (a theme palette path,\n * e.g. `error.main`), for subheaders that show a state rather than an entity (V1's\n * `logo_name` / `logo_color`).\n *\n * `alt` is the accessible name for either shape. A logo sends one shape; if it sends both, `icon`\n * wins, as `logo_name` does in V1's `SubHeader`.\n */\nexport interface LogoRef {\n alt?: string\n color?: string\n fallback_guid?: string\n guid?: string\n icon?: string\n}\n\nexport interface CategoryLogo {\n category_guid: string\n category_name: string\n}\n\nexport interface MerchantLogo {\n merchant_guid: string\n merchant_name: string\n}\n\nexport interface InstitutionLogo {\n institution_guid: string\n institution_name: string\n}\n\nexport interface Description {\n text: string\n html_text: string\n}\n\n/**\n * Post message a CTA press sends to the host, resolved by the backend for the beat's current\n * state. Absent/null = the backend has not described one: the frontend uses the template's\n * interim `ctaPostMessages` entry if there is one, else sends no message. `payload` carries only\n * beat-specific extras; the frontend always adds `beat_guid`, `beat_template`, `user_guid` and\n * `action_string`.\n */\nexport interface CtaPostMessageMetadata {\n /** Post message event; defaults to `beat/cta`. */\n event?: string | null\n /** Operation the host should perform, e.g. `op_1`, `op_2`, `op_3`. Defaults to `op_1`. */\n action?: string | null\n /** Beat-specific fields merged into the message metadata (account ids, amounts, ...). */\n payload?: Record<string, unknown> | null\n}\n\nexport interface PrimaryCTA {\n label: string\n block: string\n variant?: string | null\n /**\n * What pressing the CTA does beyond opening its block, named by the backend (ditto\n * `primary_cta_action`, passed through by tupac). Looked up in `insights-v2/ctaActions`;\n * null / absent / unknown means the CTA only opens its block or posts its message.\n */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface SecondaryCTA {\n label: string\n /**\n * Drawer block to open. `null` when the CTA opens nothing (ditto `secondary_cta_block: null`,\n * e.g. Fee Detected's \"Contact Support\"): the press posts its message to the host instead.\n */\n block: string | null\n variant?: string | null\n /** See `PrimaryCTA.action_key` (ditto `secondary_cta_action`). */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\n/**\n * The description link: its label, the action block it opens and, like a CTA's, the variant that\n * tells that block what to show (ditto's `in_description_cta_variant`, e.g. `low_balance`). On mini\n * and micro it words the card's action; `block` is empty when that action opens no drawer.\n */\nexport interface InDescriptionCTA {\n label: string\n block?: string\n variant?: string | null\n action_key?: string | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface Footer {\n /** V1: a pre-formatted date string. */\n date?: string\n /**\n * The account label, on both V1 and V2. The backend resolves the plurality: one account sends\n * its name (e.g. `Epic Bank`), several send a localized count (e.g. `2 Accounts`), none sends\n * `null` (tupac's `footer_account_label` returns nil for a beat with no accounts, as Payday Cash\n * Left Over Status does). There is deliberately no separate `accounts` key.\n */\n account?: string | null\n /**\n * V2 (LargeTransactionV2 onward): unix seconds, formatted by `Footer` for display.\n * Replaces `date`; `date` wins when a beat somehow sends both.\n */\n timestamp?: number\n}\n\n// ============ Instance Slot Types ============\n// Values are the snake_case block names the backend sends on a beat's instance slot; the PascalCase\n// keys stay as friendly references (e.g. BlockType.BarChartBlock === 'bar_chart_block').\nexport const BlockType = {\n AccountBlock: 'account_block',\n AccountSwitchBlock: 'account_switch_block',\n BarChartBlock: 'bar_chart_block',\n BudgetBlock: 'budget_block',\n DirectDepositBlock: 'direct_deposit_block',\n ImageBlock: 'image_block',\n MerchantBlock: 'merchant_block',\n TransactionBlock: 'transaction_block',\n DonutChartBlock: 'donut_chart_block',\n DoubleBarChartBlock: 'double_bar_chart_block',\n DoubleProgressBarBlock: 'double_progress_bar_block',\n DebtsBlock: 'debts_block',\n GoalsBlock: 'goals_block',\n NoSpendDaysBlock: 'no_spend_days_block',\n RepeatingTransactionBlock: 'repeating_transaction_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsAmountBlock: 'savings_amount_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WithdrawalBlock: 'withdrawal_block',\n} as const\n\nexport type BlockType = (typeof BlockType)[keyof typeof BlockType]\n\n/**\n * A pre-localized row on a V2 instance slot. The backend resolves the copy and formatting; the\n * logo is a `LogoRef` (an entity guid or a status icon, see `logoFromRef`).\n */\nexport interface InstanceSlotRow {\n amount?: number\n logo?: LogoRef\n primary_text?: string\n secondary_text?: string\n}\n\n/**\n * V2: the slots a block's variant filled, keyed by slot name; ditto owns the names and omits any\n * slot it has no value for (`lib/ditto/blocks/<block>.yml`). Read with `slot()`, which names the\n * kind the caller expects.\n */\nexport interface InstanceSlotData {\n [slot: string]: unknown\n}\n\n/**\n * Reads one slot off a block's `data`; undefined when ditto did not fill it.\n *\n * The caller names the kind, because the slot's kind lives in the block's ditto schema and not\n * here — a block fills slots with whatever its card needs, so no fixed list of kinds would hold\n * (`account_switch_block` alone carries a boolean and `budget_block` a nested object).\n */\nexport const slot = <T = unknown>(\n data: InstanceSlotData | undefined,\n name: string,\n): T | undefined => data?.[name] as T | undefined\n\n/**\n * V2: which block renders this beat's content, and what it renders.\n *\n * `block` is optional: a beat whose template has no ditto config arrives as an empty `{}` and the\n * card renders its copy and CTAs alone, so a reader cannot assume a block is named. One interface\n * with `block` optional rather than a union with `Record<string, never>`, which TypeScript absorbs\n * — that union left `block` reading as required and typed a promise it did not keep.\n *\n * `variant` is optional for the same reason — the empty `{}` carries neither. Every ditto beat\n * file that names a block also names a variant, so a *filled* slot always has one; ditto drops a\n * nil variant rather than sending null, which is why the type is `string | null | undefined`.\n */\nexport interface InstanceSlot {\n block?: BlockType\n variant?: string | null\n /** The slots this block's variant declares in ditto. */\n data?: InstanceSlotData\n // Direct Deposit block (Set Up Direct Deposit, Switch Direct Deposit, Missing\n // Interest Rate): account facts carried flat on the slot, beside `data`.\n /** Primary line on the hero card, e.g. \"Epic Bank Checking, *1234\". */\n account_name?: string\n /** Secondary line beneath the name, e.g. \"Checking Account\" / \"Credit Card\". */\n account_type?: string\n /** Status pill label, e.g. \"Direct Deposit Not Set Up\" / \"Interest Rate: 19.99% APR\". */\n status_text?: string\n institution_guid?: string\n institution_name?: string\n // Shared across multiple V2 component blocks:\n // `amount` — UpcomingBillBlock (projected bill), UpcomingSubscriptionBlock (price per cadence).\n // (SavingsOpportunityBlock now reads `amount` off `instance_slot.data`, not this flat field.)\n // `merchant_guid` / `merchant_name` — UpcomingBillBlock (bill row logo + name),\n // UpcomingSubscriptionBlock (hero logo + name).\n /** Dollar amount (unformatted); the block formats it as currency. */\n amount?: number\n // Withdrawal block (Emergency Fund Withdrawal): one row flat on the slot - `amount` above is the\n // withdrawal, shown with its date line \"{amount_label} {withdrawal_date}\" over the balance row.\n /** Pre-localized lead-in for the date line, e.g. \"Withdrawn on\". */\n amount_label?: string\n /** The withdrawal's calendar day, `YYYY-MM-DD` (e.g. `2026-10-20`); the card formats it. */\n withdrawal_date?: string\n /** Account balance after the withdrawal (unformatted); the card formats it as currency. */\n balance?: number\n /** Pre-localized label for the balance row, e.g. \"Balance\". */\n balance_label?: string\n /** Merchant guid used to render the inline / hero logo via `LogoFromGuid` (`MCH-...`). */\n merchant_guid?: string\n /** Merchant display name — shown as logo alt text and as the merchant/hero label. */\n merchant_name?: string\n // Upcoming Bill block (Projected Bill Payment): the block derives the Sun→Sat week strip\n // around `due_date` at render time.\n /** Due date of the projected bill in ISO form (e.g. `2025-10-30`). */\n due_date?: string\n // Account block (confetti tile): V1 flat fallback for the label line when `instance_slot.data` is\n // absent — `AccountBlock` reads `data.sub_text` first, then this. (The Savings Opportunity coupon\n // now reads `primary_text`/`amount` off `data`, so it no longer reads this flat field.)\n /** Caption/label line for the confetti tile (V1 fallback). */\n label?: string\n // Upcoming Subscription block: billing cadence for the price pill (`${amount} / ${cadence}`).\n /** Billing cadence word that trails the price, e.g. `month` or `year`. */\n cadence?: string\n // Account block (status on/off-track, deposit, payoff variants): card content carried flat on\n // the slot (the V2 contract drops `instance_slot_data`). `amount`, `label`, `merchant_guid`,\n // `merchant_name`, `institution_guid`, `institution_name` are shared fields declared above.\n /** Secondary line beneath the amount on the standard card, e.g. \"Remaining after expenses\". */\n sub_text?: string\n /** Header bar text (standard card) or the colored category strip label (deposit cards). */\n header_text?: string\n /** Generic-tile icon name used when no merchant/institution logo is available. */\n icon_name?: string\n /** Category guid used to render the deposit-card logo fallback. */\n category_guid?: string\n // Debts block: `amount` is the current balance; the shared account/institution fields above.\n /** Projected payoff date in ISO form (e.g. `2027-03-01`); the block formats it as month + year. */\n payoff_date?: string\n /** Monthly payment toward the debt (unformatted); the block formats it as currency. */\n monthly_payment?: number\n /** Annual interest rate as a percentage (e.g. `19.99`); the block formats it as a percent. */\n interest_rate?: number\n start_date?: string\n no_spend_days?: string[]\n}\n"],"mappings":"AAyUA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
@@ -1,25 +1,25 @@
1
- import { buildDynamicCopy as j } from "../../../core/utils/Localization.es.js";
2
- import z from "../../../common/utils/AccountDisplayName.es.js";
3
- import { useGlobalCopyStore as q, useInsightsV2Store as J, useSettingsStore as K, useUserStore as Q } from "../../../common/context/hooks.es.js";
4
- import X from "../../../common/components/Loader.es.js";
5
- import Z from "../../../common/components/CurrencyDialog.es.js";
6
- import { useBeatActions as oo } from "../../beatActions.es.js";
1
+ import { buildDynamicCopy as z } from "../../../core/utils/Localization.es.js";
2
+ import q from "../../../common/utils/AccountDisplayName.es.js";
3
+ import { useGlobalCopyStore as J, useInsightsV2Store as K, useSettingsStore as Q, useUserStore as X } from "../../../common/context/hooks.es.js";
4
+ import Z from "../../../common/components/Loader.es.js";
5
+ import oo from "../../../common/components/CurrencyDialog.es.js";
6
+ import { useBeatActions as to } from "../../beatActions.es.js";
7
7
  import { ANALYTICS_EVENTS_CONFIG as c } from "../../analytics/analyticsEventsConfig.es.js";
8
- import { useCtaHandler as to } from "../../ctaActions/useCtaAction.es.js";
9
- import { useAnalyticsEvent as eo } from "../../analytics/useAnalyticsEvent.es.js";
10
- import { getDynamicCtaBasedOnTriggers as io } from "../util.es.js";
11
- import { AMOUNT_INPUT_VARIANTS as no, findLowBalanceProfile as ro, isAmountInputVariant as x, isWholeAmount as ao, toInputValue as so } from "./layout.es.js";
8
+ import { useCtaHandler as eo } from "../../ctaActions/useCtaAction.es.js";
9
+ import { useAnalyticsEvent as io } from "../../analytics/useAnalyticsEvent.es.js";
10
+ import { getDynamicCtaBasedOnTriggers as no } from "../util.es.js";
11
+ import { AMOUNT_INPUT_VARIANTS as ro, findLowBalanceProfile as ao, isAmountInputVariant as x, isWholeAmount as so, resolveAmountInputVariant as co, toInputValue as lo } from "./layout.es.js";
12
12
  import r from "react";
13
- import { observer as co } from "mobx-react-lite";
13
+ import { observer as uo } from "mobx-react-lite";
14
14
  import P from "@mui/material/Stack";
15
- import { H3 as lo, InstitutionLogo as uo, Text as H } from "@mxenabled/mxui";
16
- import { Icon as mo } from "@mxenabled/mx-icons";
15
+ import { H3 as mo, InstitutionLogo as po, Text as H } from "@mxenabled/mxui";
16
+ import { Icon as _o } from "@mxenabled/mx-icons";
17
17
  import { jsx as e, jsxs as k } from "react/jsx-runtime";
18
- import po from "@mui/material/Dialog";
19
- import _o from "@mui/material/IconButton";
18
+ import fo from "@mui/material/Dialog";
19
+ import ho from "@mui/material/IconButton";
20
20
  var w = ({ children: I, closeAriaLabel: i, heading: o, onClose: l }) => {
21
21
  const u = r.useId();
22
- return /* @__PURE__ */ e(po, {
22
+ return /* @__PURE__ */ e(fo, {
23
23
  "aria-labelledby": o ? u : void 0,
24
24
  maxWidth: "xs",
25
25
  onClose: l,
@@ -31,11 +31,11 @@ var w = ({ children: I, closeAriaLabel: i, heading: o, onClose: l }) => {
31
31
  position: "relative"
32
32
  },
33
33
  children: [
34
- o && /* @__PURE__ */ e(lo, {
34
+ o && /* @__PURE__ */ e(mo, {
35
35
  id: u,
36
36
  children: o
37
37
  }),
38
- /* @__PURE__ */ e(_o, {
38
+ /* @__PURE__ */ e(ho, {
39
39
  "aria-label": i || "Close",
40
40
  onClick: l,
41
41
  sx: {
@@ -43,7 +43,7 @@ var w = ({ children: I, closeAriaLabel: i, heading: o, onClose: l }) => {
43
43
  right: 8,
44
44
  top: 18
45
45
  },
46
- children: /* @__PURE__ */ e(mo, {
46
+ children: /* @__PURE__ */ e(_o, {
47
47
  name: "close",
48
48
  sx: { color: "action.active" }
49
49
  })
@@ -52,20 +52,20 @@ var w = ({ children: I, closeAriaLabel: i, heading: o, onClose: l }) => {
52
52
  ]
53
53
  })
54
54
  });
55
- }, ko = co(function({ beat: i }) {
56
- const { common: o, insights_feed: l } = q(), { actionDrawer: u, closeActionDrawer: m } = J(), f = K(), { userInsightProfile: v } = Q(), S = to(i, oo()), T = eo(), { primary_cta: B, secondary_cta: O, in_description_cta: V } = i.insights_payload ?? {}, s = io(u, B, O, V)?.variant, a = l?.amount_input_modal, t = s === no.LOW_BALANCE_THRESHOLD, h = t ? ro(f.notificationProfiles, i.primary_account_guid) : void 0, E = t ? h?.threshold : v?.savings_opportunity_minimum_checking_account_balance, [G, R] = r.useState(t), d = r.useRef(!0);
55
+ }, Bo = uo(function({ beat: i }) {
56
+ const { common: o, insights_feed: l } = J(), { actionDrawer: u, closeActionDrawer: m } = K(), f = Q(), { userInsightProfile: v } = X(), S = eo(i, to()), T = io(), { primary_cta: V, secondary_cta: B, in_description_cta: O } = i.insights_payload ?? {}, G = no(u, V, B, O), s = co(G), a = l?.amount_input_modal, t = s === ro.LOW_BALANCE_THRESHOLD, h = t ? ao(f.notificationProfiles, i.primary_account_guid) : void 0, A = t ? h?.threshold : v?.savings_opportunity_minimum_checking_account_balance, [R, F] = r.useState(t), d = r.useRef(!0);
57
57
  r.useEffect(() => (d.current = !0, () => {
58
58
  d.current = !1;
59
59
  }), []), r.useEffect(() => {
60
60
  t && f.loadNotificationProfiles().finally(() => {
61
- d.current && R(!1);
61
+ d.current && F(!1);
62
62
  });
63
63
  }, [t, f]);
64
- const [F, M] = r.useState(null), [A, C] = r.useState(!1), [U, y] = r.useState(!1), p = F ?? so(E);
65
- if (G) return /* @__PURE__ */ e(w, {
64
+ const [M, U] = r.useState(null), [E, C] = r.useState(!1), [$, y] = r.useState(!1), p = M ?? lo(A);
65
+ if (R) return /* @__PURE__ */ e(w, {
66
66
  closeAriaLabel: o?.close_aria,
67
67
  onClose: m,
68
- children: /* @__PURE__ */ e(X, {})
68
+ children: /* @__PURE__ */ e(Z, {})
69
69
  });
70
70
  const n = x(s) ? a?.[s] : void 0, b = !!n?.title && !!n.description && !!n.input_label && !!a?.whole_number_error && !!a.save_error && !!o?.save_button && (!t || !!o.cancel_button) && !!o.close_aria;
71
71
  if (!a || !n || !b || !(t ? h : v))
@@ -77,33 +77,33 @@ var w = ({ children: I, closeAriaLabel: i, heading: o, onClose: l }) => {
77
77
  });
78
78
  const D = () => {
79
79
  T(t ? c.EDIT_INSIGHT_THRESHOLD_CANCELED : c.EDIT_SAFETY_NET_CANCEL), m();
80
- }, L = !t && !!E, N = i.primary_account ? z(i.primary_account) : "", g = ao(p), $ = p !== "" && !g, W = async () => {
81
- if (!g || A) return;
80
+ }, L = !t && !!A, N = i.primary_account ? q(i.primary_account) : "", g = so(p), W = p !== "" && !g, Y = async () => {
81
+ if (!g || E) return;
82
82
  const _ = Number(p);
83
83
  C(!0), y(!1);
84
- const Y = t ? await S("updateNotificationProfileThreshold", {
84
+ const j = t ? await S("updateNotificationProfileThreshold", {
85
85
  profileGuid: h?.guid,
86
86
  threshold: _
87
87
  }, { analytics: c.EDIT_INSIGHT_THRESHOLD_SAVE }) : await S("updateUserInsightProfile", { fields: { savings_opportunity_minimum_checking_account_balance: _ } }, { analytics: c.EDIT_SAFETY_NET_SAVE });
88
- d.current && (C(!1), Y ? m() : y(!0));
88
+ d.current && (C(!1), j ? m() : y(!0));
89
89
  };
90
- return /* @__PURE__ */ e(Z, {
90
+ return /* @__PURE__ */ e(oo, {
91
91
  closeAriaLabel: o.close_aria,
92
- content: j(L && n.description_edit || n.description, /* @__PURE__ */ e("strong", { children: N }, "account")),
93
- errorText: $ ? a.whole_number_error : U ? a.save_error : void 0,
92
+ content: z(L && n.description_edit || n.description, /* @__PURE__ */ e("strong", { children: N }, "account")),
93
+ errorText: W ? a.whole_number_error : $ ? a.save_error : void 0,
94
94
  handleInputChange: (_) => {
95
- M(_), y(!1);
95
+ U(_), y(!1);
96
96
  },
97
97
  handleInputClick: t ? () => T(c.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED) : void 0,
98
98
  handleModalClose: D,
99
99
  handlePrimaryAction: () => {
100
- W();
100
+ Y();
101
101
  },
102
102
  handleSecondaryAction: D,
103
103
  inputLabel: n.input_label,
104
104
  inputValue: p,
105
105
  isOpen: !0,
106
- isPrimaryDisabled: A || !g,
106
+ isPrimaryDisabled: E || !g,
107
107
  primaryText: o.save_button,
108
108
  secondaryText: t ? o.cancel_button : void 0,
109
109
  subtitle: t && i.primary_account ? /* @__PURE__ */ k(P, {
@@ -112,7 +112,7 @@ var w = ({ children: I, closeAriaLabel: i, heading: o, onClose: l }) => {
112
112
  flexDirection: "row",
113
113
  gap: 8
114
114
  },
115
- children: [/* @__PURE__ */ e(uo, {
115
+ children: [/* @__PURE__ */ e(po, {
116
116
  alt: "",
117
117
  institutionGuid: i.primary_account.institution_guid ?? "",
118
118
  size: 16
@@ -127,7 +127,7 @@ var w = ({ children: I, closeAriaLabel: i, heading: o, onClose: l }) => {
127
127
  });
128
128
  });
129
129
  export {
130
- ko as AmountInputModalBlock
130
+ Bo as AmountInputModalBlock
131
131
  };
132
132
 
133
133
  //# sourceMappingURL=AmountInputModalBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport {\n AMOUNT_INPUT_VARIANTS,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n toInputValue,\n} from './layout'\n\n/**\n * The dialog frame for the states that have no form: loading, and a non-retriable problem. Named by\n * its heading and closable by button, Esc and backdrop, like the form dialog.\n */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/**\n * `amount_input_modal_block`: one whole-dollar setting edited in a dialog (Figma 441:24913 and\n * 5402:34137). The CTA's variant picks what is edited:\n * - `low_balance_threshold`: the `threshold` on the beat account's low-balance alert profile;\n * - `safety_net`: `savings_opportunity_minimum_checking_account_balance` on the insight profile.\n *\n * Registered with `presentation: 'modal'`, so no drawer opens behind it; closing the dialog ends\n * the action-drawer session. `observer` is required: the starting values are read from stores.\n */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n const variant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )?.variant\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounted only while open (modal presentation), so mounting is the open: profiles are reloaded\n // here on each open, so the threshold prefills as saved now. `SettingsStore` swallows a failed\n // request, which leaves no profile for the account: the missing-profile error below covers it.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AA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BAAgB;AAAA,IACzD,UACE,KAAgB,EAAK,kBACnB,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
1
+ {"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport {\n AMOUNT_INPUT_VARIANTS,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/**\n * The dialog frame for the states that have no form: loading, and a non-retriable problem. Named by\n * its heading and closable by button, Esc and backdrop, like the form dialog.\n */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/**\n * `amount_input_modal_block`: one whole-dollar setting edited in a dialog (Figma 441:24913 and\n * 5402:34137). The CTA's variant picks what is edited:\n * - `low_balance_threshold`: the `threshold` on the beat account's low-balance alert profile;\n * - `safety_net`: `savings_opportunity_minimum_checking_account_balance` on the insight profile.\n *\n * Registered with `presentation: 'modal'`, so no drawer opens behind it; closing the dialog ends\n * the action-drawer session. `observer` is required: the starting values are read from stores.\n */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n const variant = resolveAmountInputVariant(cta)\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounted only while open (modal presentation), so mounting is the open: profiles are reloaded\n // here on each open, so the threshold prefills as saved now. `SettingsStore` swallows a failed\n // request, which leaves no profile for the account: the missing-profile error below covers it.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAA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,IACvB,YAAY,EAAY;AAAA,IACxB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,mBAAmB,KAAY,CAAC;AAAA,IAChC,aAAa,EAAW;AAAA,IACxB,eAAe,IAAe,EAAW,gBAAgB;AAAA,IACzD,UACE,KAAgB,EAAK,kBACnB,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
@@ -6,6 +6,16 @@ export declare const AMOUNT_INPUT_VARIANTS: {
6
6
  };
7
7
  export type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS];
8
8
  export declare const isAmountInputVariant: (variant?: string | null) => variant is AmountInputVariant;
9
+ /**
10
+ * The variant the modal edits, from the CTA that opened it. ditto drives the shared
11
+ * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net
12
+ * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An
13
+ * explicit variant always wins (so an unknown one still falls to the block's "unknown variant" path).
14
+ */
15
+ export declare const resolveAmountInputVariant: (cta?: {
16
+ block?: string | null;
17
+ variant?: string | null;
18
+ }) => string | undefined;
9
19
  /** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */
10
20
  export declare const isWholeAmount: (value: string) => boolean;
11
21
  /** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */
@@ -1,13 +1,18 @@
1
- import { AccountNotificationTypes as o } from "../../../core/types/Notification.es.js";
2
- var a = {
1
+ import { AccountNotificationTypes as i } from "../../../core/types/Notification.es.js";
2
+ import { actionBlocksKey as a } from "../../mappings/actionBlocksKey.es.js";
3
+ var o = {
3
4
  LOW_BALANCE_THRESHOLD: "low_balance_threshold",
4
5
  SAFETY_NET: "safety_net"
5
- }, A = (t) => Object.values(a).includes(t ?? ""), i = 1e9, _ = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= i, c = (t) => t ? String(Math.round(t)) : "", N = (t, n) => n ? t.find((e) => e.entity_guid === n && e.notification_type === o.AccountBalanceLow) : void 0;
6
+ }, T = (t) => Object.values(o).includes(t ?? ""), u = (t) => {
7
+ if (t?.variant) return t.variant;
8
+ if (t?.block === a.SAFETY_NET_ACTION_BLOCK) return o.SAFETY_NET;
9
+ }, e = 1e9, N = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= e, c = (t) => t ? String(Math.round(t)) : "", l = (t, n) => n ? t.find((r) => r.entity_guid === n && r.notification_type === i.AccountBalanceLow) : void 0;
6
10
  export {
7
- a as AMOUNT_INPUT_VARIANTS,
8
- N as findLowBalanceProfile,
9
- A as isAmountInputVariant,
10
- _ as isWholeAmount,
11
+ o as AMOUNT_INPUT_VARIANTS,
12
+ l as findLowBalanceProfile,
13
+ T as isAmountInputVariant,
14
+ N as isWholeAmount,
15
+ u as resolveAmountInputVariant,
11
16
  c as toInputValue
12
17
  };
13
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";AAIA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAIa,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAG/D,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK) return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;AAKA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAIa,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBAAyB,QAAO,EAAsB;AAE3F,GAGM,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
@@ -1,12 +1,18 @@
1
- import { useGlobalCopyStore as c, useInsightsV2Store as u } from "../../common/context/hooks.es.js";
2
- import { useBeatActions as m } from "../beatActions.es.js";
3
- import b from "../components/SurveyModal.es.js";
4
- import { observer as p } from "mobx-react-lite";
5
- import { jsx as _ } from "react/jsx-runtime";
6
- var A = p(function({ beat: t }) {
7
- const { closeActionDrawer: s } = u(), { onSubmitFeedback: r } = m(), a = c(), o = t.insights_payload, e = a.insights_feed?.survey_modal;
1
+ import { useGlobalCopyStore as _, useGlobalStore as y, useInsightsV2Store as v } from "../../common/context/hooks.es.js";
2
+ import { useBeatActions as d } from "../beatActions.es.js";
3
+ import { resolveStep as g } from "../ctaActions/runCtaAction.es.js";
4
+ import S from "../components/SurveyModal.es.js";
5
+ import { getDynamicCtaBasedOnTriggers as f } from "./util.es.js";
6
+ import { observer as h } from "mobx-react-lite";
7
+ import { jsx as A } from "react/jsx-runtime";
8
+ var B = h(function({ beat: t }) {
9
+ const { actionDrawer: i, closeActionDrawer: n } = v(), r = d(), c = _(), l = y(), o = t.insights_payload, e = c.insights_feed?.survey_modal;
8
10
  if (!o || !e) return null;
9
- const i = {
11
+ const a = f(i, o.primary_cta, o.secondary_cta, o.in_description_cta), s = a && g({ cta: a }).surveyAnswer?.({
12
+ beat: t,
13
+ stores: l,
14
+ hostActions: r
15
+ }, e), u = {
10
16
  title: e.title,
11
17
  options: [{
12
18
  overline: e.yes_overline,
@@ -20,28 +26,30 @@ var A = p(function({ beat: t }) {
20
26
  submitText: e.submit,
21
27
  closeAriaLabel: e.close_aria,
22
28
  reasonsTitle: e.reasons_title,
23
- reasonOptions: Object.values(e.reason_options ?? {}),
29
+ reasonOptions: s?.reasonOptions ?? Object.values(e.reason_options ?? {}),
24
30
  backText: e.back,
25
31
  characterLimitLabel: e.character_limit,
26
32
  successMessage: e.success_message,
27
33
  errorMessage: e.error_message,
28
34
  tryAgainText: e.try_again,
29
35
  toastCloseAriaLabel: e.toast_close_aria
30
- };
31
- return /* @__PURE__ */ _(b, {
32
- copy: i,
36
+ }, m = s?.onSubmit ?? ((p, b) => r.onSubmitFeedback?.({
37
+ beatGuid: o.guid,
38
+ source: "cta",
39
+ option: p,
40
+ detail: b
41
+ }));
42
+ return /* @__PURE__ */ A(S, {
43
+ copy: u,
33
44
  isOpen: !0,
34
- onClose: () => s(),
35
- onSubmit: (n, l) => r?.({
36
- beatGuid: o.guid,
37
- source: "cta",
38
- option: n,
39
- detail: l
40
- })
45
+ onClose: () => n(),
46
+ onReasonsOpen: s?.onReasonsOpen,
47
+ onSubmit: m,
48
+ showDetailField: s?.showDetailField
41
49
  });
42
50
  });
43
51
  export {
44
- A as SurveyModalActionBlock
52
+ B as SurveyModalActionBlock
45
53
  };
46
54
 
47
55
  //# sourceMappingURL=SurveyModalActionBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SurveyModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SurveyModalActionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport SurveyModal, { type SurveyModalContent } from '../components/SurveyModal'\nimport { useBeatActions } from '../beatActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\n\n/**\n * `survey_modal_block` — the \"Does this look right?\" confirmation survey\n * (Figma `1941:212640`). Registered like any other drawer block; its content\n * is a MODAL (the dialog portals over the drawer).\n *\n * The survey has no action buttons — its rows act: the positive row submits\n * to the host via `beatActions.onSubmitFeedback` (source `cta`) and shows the\n * status snackbar; the negative row opens the FeedbackModal reasons dialog.\n * The session ends when the flow does (snackbar dismissed or dialogs closed).\n *\n * Copy comes from `insights_feed.survey_modal` in GlobalCopy.\n */\nexport const SurveyModalActionBlock = observer(function SurveyModalActionBlock({\n beat,\n}: ActionBlockProps) {\n const { closeActionDrawer } = useInsightsV2Store()\n const { onSubmitFeedback } = useBeatActions()\n const copyStore = useGlobalCopyStore()\n\n const insights_payload = beat.insights_payload\n const surveyCopy = copyStore.insights_feed?.survey_modal\n\n if (!insights_payload || !surveyCopy) return null\n\n const copy: SurveyModalContent = {\n title: surveyCopy.title,\n options: [\n { overline: surveyCopy.yes_overline, label: surveyCopy.yes_label, tone: 'positive' },\n { overline: surveyCopy.no_overline, label: surveyCopy.no_label, tone: 'negative' },\n ],\n submitText: surveyCopy.submit,\n\n closeAriaLabel: surveyCopy.close_aria,\n reasonsTitle: surveyCopy.reasons_title,\n reasonOptions: Object.values(surveyCopy.reason_options ?? {}),\n backText: surveyCopy.back,\n characterLimitLabel: surveyCopy.character_limit,\n successMessage: surveyCopy.success_message,\n errorMessage: surveyCopy.error_message,\n tryAgainText: surveyCopy.try_again,\n toastCloseAriaLabel: surveyCopy.toast_close_aria,\n }\n\n // Returned (not just fired): a host promise rejection drives the modal's\n // error snackbar + Try Again retry. The session closes when the flow ends\n // (snackbar dismissed), not on submit.\n\n //TODO: Need to update the onSubmit functionality as per pulse. This function is mis-matching with the current approach of switchdirectdeposit and setupdirectdeposit\n const handleSubmit = (option: string, detail?: string) =>\n onSubmitFeedback?.({\n beatGuid: insights_payload.guid,\n source: 'cta',\n option,\n detail,\n })\n\n return (\n <SurveyModal\n copy={copy}\n isOpen={true}\n onClose={() => closeActionDrawer()}\n onSubmit={handleSubmit}\n />\n )\n})\n"],"mappings":";;;;;AAmBA,IAAa,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,EAAE,kBAAA,EAAA,IAAqB,EAAe,GACtC,IAAY,EAAmB,GAE/B,IAAmB,EAAK,kBACxB,IAAa,EAAU,eAAe;AAE5C,MAAI,CAAC,KAAoB,CAAC,EAAY,QAAO;AAE7C,QAAM,IAA2B;AAAA,IAC/B,OAAO,EAAW;AAAA,IAClB,SAAS,CACP;AAAA,MAAE,UAAU,EAAW;AAAA,MAAc,OAAO,EAAW;AAAA,MAAW,MAAM;AAAA,IAAW,GACnF;AAAA,MAAE,UAAU,EAAW;AAAA,MAAa,OAAO,EAAW;AAAA,MAAU,MAAM;AAAA,IAAW,CACnF;AAAA,IACA,YAAY,EAAW;AAAA,IAEvB,gBAAgB,EAAW;AAAA,IAC3B,cAAc,EAAW;AAAA,IACzB,eAAe,OAAO,OAAO,EAAW,kBAAkB,CAAC,CAAC;AAAA,IAC5D,UAAU,EAAW;AAAA,IACrB,qBAAqB,EAAW;AAAA,IAChC,gBAAgB,EAAW;AAAA,IAC3B,cAAc,EAAW;AAAA,IACzB,cAAc,EAAW;AAAA,IACzB,qBAAqB,EAAW;AAAA,EAClC;AAeA,SACE,gBAAA,EAAC,GAAD;AAAA,IACQ,MAAA;AAAA,IACN,QAAQ;AAAA,IACR,SAAA,MAAe,EAAkB;AAAA,IACjC,UAbE,CAAgB,GAAgB,MACpC,IAAmB;AAAA,MACjB,UAAU,EAAiB;AAAA,MAC3B,QAAQ;AAAA,MACR,QAAA;AAAA,MACA,QAAA;AAAA,IACF,CAAC;AAAA,EAQA,CAAA;AAEL,CAAC"}
1
+ {"version":3,"file":"SurveyModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/SurveyModalActionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport SurveyModal, { type SurveyModalContent } from '../components/SurveyModal'\nimport { useBeatActions } from '../beatActions'\nimport { resolveStep } from '../ctaActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\n/**\n * `survey_modal_block` — the \"Does this look right?\" confirmation survey\n * (Figma `1941:212640`). Registered like any other drawer block; its content\n * is a MODAL (the dialog portals over the drawer).\n *\n * The survey has no action buttons — its rows act: the positive row submits\n * to the host via `beatActions.onSubmitFeedback` (source `cta`) and shows the\n * status snackbar; the negative row opens the FeedbackModal reasons dialog.\n * The session ends when the flow does (snackbar dismissed or dialogs closed).\n *\n * Copy comes from `insights_feed.survey_modal` in GlobalCopy.\n */\nexport const SurveyModalActionBlock = observer(function SurveyModalActionBlock({\n beat,\n}: ActionBlockProps) {\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const beatActions = useBeatActions()\n const copyStore = useGlobalCopyStore()\n const stores = useGlobalStore()\n\n const insights_payload = beat.insights_payload\n const surveyCopy = copyStore.insights_feed?.survey_modal\n\n if (!insights_payload || !surveyCopy) return null\n\n // The step of the CTA that opened the drawer.\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload.primary_cta,\n insights_payload.secondary_cta,\n insights_payload.in_description_cta,\n )\n const survey =\n cta &&\n resolveStep({ cta }).surveyAnswer?.({ beat, stores, hostActions: beatActions }, surveyCopy)\n\n const copy: SurveyModalContent = {\n title: surveyCopy.title,\n options: [\n { overline: surveyCopy.yes_overline, label: surveyCopy.yes_label, tone: 'positive' },\n { overline: surveyCopy.no_overline, label: surveyCopy.no_label, tone: 'negative' },\n ],\n submitText: surveyCopy.submit,\n\n closeAriaLabel: surveyCopy.close_aria,\n reasonsTitle: surveyCopy.reasons_title,\n reasonOptions: survey?.reasonOptions ?? Object.values(surveyCopy.reason_options ?? {}),\n backText: surveyCopy.back,\n characterLimitLabel: surveyCopy.character_limit,\n successMessage: surveyCopy.success_message,\n errorMessage: surveyCopy.error_message,\n tryAgainText: surveyCopy.try_again,\n toastCloseAriaLabel: surveyCopy.toast_close_aria,\n }\n\n // Returned (not just fired): a host promise rejection drives the modal's\n // error snackbar + Try Again retry. The session closes when the flow ends\n // (snackbar dismissed), not on submit.\n\n //TODO: Need to update the onSubmit functionality as per pulse. This function is mis-matching with the current approach of switchdirectdeposit and setupdirectdeposit\n const handleSubmit =\n survey?.onSubmit ??\n ((option: string, detail?: string) =>\n beatActions.onSubmitFeedback?.({\n beatGuid: insights_payload.guid,\n source: 'cta',\n option,\n detail,\n }))\n\n return (\n <SurveyModal\n copy={copy}\n isOpen={true}\n onClose={() => closeActionDrawer()}\n onReasonsOpen={survey?.onReasonsOpen}\n onSubmit={handleSubmit}\n showDetailField={survey?.showDetailField}\n />\n )\n})\n"],"mappings":";;;;;;;AAqBA,IAAa,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,cAAA,GAAc,mBAAA,EAAA,IAAsB,EAAmB,GACzD,IAAc,EAAe,GAC7B,IAAY,EAAmB,GAC/B,IAAS,EAAe,GAExB,IAAmB,EAAK,kBACxB,IAAa,EAAU,eAAe;AAE5C,MAAI,CAAC,KAAoB,CAAC,EAAY,QAAO;AAG7C,QAAM,IAAM,EACV,GACA,EAAiB,aACjB,EAAiB,eACjB,EAAiB,kBACnB,GACM,IACJ,KACA,EAAY,EAAE,KAAA,EAAI,CAAC,EAAE,eAAe;AAAA,IAAE,MAAA;AAAA,IAAM,QAAA;AAAA,IAAQ,aAAa;AAAA,EAAY,GAAG,CAAU,GAEtF,IAA2B;AAAA,IAC/B,OAAO,EAAW;AAAA,IAClB,SAAS,CACP;AAAA,MAAE,UAAU,EAAW;AAAA,MAAc,OAAO,EAAW;AAAA,MAAW,MAAM;AAAA,IAAW,GACnF;AAAA,MAAE,UAAU,EAAW;AAAA,MAAa,OAAO,EAAW;AAAA,MAAU,MAAM;AAAA,IAAW,CACnF;AAAA,IACA,YAAY,EAAW;AAAA,IAEvB,gBAAgB,EAAW;AAAA,IAC3B,cAAc,EAAW;AAAA,IACzB,eAAe,GAAQ,iBAAiB,OAAO,OAAO,EAAW,kBAAkB,CAAC,CAAC;AAAA,IACrF,UAAU,EAAW;AAAA,IACrB,qBAAqB,EAAW;AAAA,IAChC,gBAAgB,EAAW;AAAA,IAC3B,cAAc,EAAW;AAAA,IACzB,cAAc,EAAW;AAAA,IACzB,qBAAqB,EAAW;AAAA,EAClC,GAOM,IACJ,GAAQ,aAAA,CACN,GAAgB,MAChB,EAAY,mBAAmB;AAAA,IAC7B,UAAU,EAAiB;AAAA,IAC3B,QAAQ;AAAA,IACR,QAAA;AAAA,IACA,QAAA;AAAA,EACF,CAAC;AAEL,SACE,gBAAA,EAAC,GAAD;AAAA,IACQ,MAAA;AAAA,IACN,QAAQ;AAAA,IACR,SAAA,MAAe,EAAkB;AAAA,IACjC,eAAe,GAAQ;AAAA,IACvB,UAAU;AAAA,IACV,iBAAiB,GAAQ;AAAA,EAC1B,CAAA;AAEL,CAAC"}
@@ -9,25 +9,25 @@ import { ANALYTICS_EVENTS_CONFIG as P } from "../../analytics/analyticsEventsCon
9
9
  import { useAnalyticsEvent as It } from "../../analytics/useAnalyticsEvent.es.js";
10
10
  import { DoubleBarChart as xt } from "../../components/chartblocks/DoubleBarChart.es.js";
11
11
  import { toLegendItems as Et } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
12
- import { TransactionDrillDown as Rt } from "./TransactionDrillDown.es.js";
13
- import { getDefaultSelection as Ot, getDrillDownConfig as jt, getFlattenedDataSeries as Ft, resolveDrillDownSubHeader as Gt, splitProjectedTransaction as Ht, toStoreFilter as wt } from "./utils.es.js";
14
- import { useTransactionHistory as kt } from "./useTransactionHistory.es.js";
15
- import { getDynamicCtaBasedOnTriggers as Nt } from "../util.es.js";
12
+ import { getDynamicCtaBasedOnTriggers as Rt } from "../util.es.js";
13
+ import { TransactionDrillDown as Ot } from "./TransactionDrillDown.es.js";
14
+ import { getDefaultSelection as jt, getDrillDownConfig as Ft, getFlattenedDataSeries as Gt, resolveDrillDownSubHeader as Ht, splitProjectedTransaction as wt, toStoreFilter as kt } from "./utils.es.js";
15
+ import { useTransactionHistory as Nt } from "./useTransactionHistory.es.js";
16
16
  import { TransactionDetailsBlock as Kt } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
17
17
  import { useLayoutEffect as Mt, useState as m } from "react";
18
18
  import { observer as Pt } from "mobx-react-lite";
19
19
  import { Fragment as Vt, jsx as r, jsxs as zt } from "react/jsx-runtime";
20
20
  import { useTheme as Ut } from "@mui/material/styles";
21
21
  var pe = Pt(({ beat: s }) => {
22
- const D = Ut(), { actionDrawer: B, setActionContext: S } = yt(), { insights_payload: c } = s, V = Nt(B, c?.primary_cta, c?.secondary_cta, c?.in_description_cta)?.variant, { top: e, filterMode: u, header: z, colors: U, filterStrategy: W, tipSection: L, subTabAriaLabels: Y, slotData: $, beatTransactions: q, hideListHeader: J } = jt(V ?? ""), { instanceSlotData: a, beatTransactions: g, spendCategoryGuids: v, allAccountGuids: I, categoryName: Q, displayedDateRange: f, transactionStore: X } = kt(s, {
22
+ const D = Ut(), { actionDrawer: B, setActionContext: S } = yt(), { insights_payload: c } = s, V = Rt(B, c?.primary_cta, c?.secondary_cta, c?.in_description_cta)?.variant, { top: e, filterMode: u, header: z, colors: U, filterStrategy: W, tipSection: L, subTabAriaLabels: Y, slotData: $, beatTransactions: q, hideListHeader: J } = Ft(V ?? ""), { instanceSlotData: a, beatTransactions: g, spendCategoryGuids: v, allAccountGuids: I, categoryName: Q, displayedDateRange: f, transactionStore: X } = Nt(s, {
23
23
  slotData: $,
24
24
  beatTransactions: q
25
- }), { common: Z, insights_feed: n } = Tt(), { isCopyLoaded: tt } = Ct(), [et, x] = m(!1), [ot, at] = m(!1), E = It(), { dataSeries: p, chartData: b, comparisonBars: i } = Ft({
25
+ }), { common: Z, insights_feed: n } = Tt(), { isCopyLoaded: tt } = Ct(), [et, x] = m(!1), [ot, at] = m(!1), E = It(), { dataSeries: p, chartData: b, comparisonBars: i } = Gt({
26
26
  data: a?.data_series,
27
27
  ariaLabel: e === "doubleBar" ? n?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" : St,
28
28
  top: e,
29
29
  beatTransactions: g
30
- }), d = e === "doubleBar", nt = e === "tabsOnly", l = d ? i : b, { chartBarIndex: R, subTabIndex: rt } = Ot({
30
+ }), d = e === "doubleBar", nt = e === "tabsOnly", l = d ? i : b, { chartBarIndex: R, subTabIndex: rt } = jt({
31
31
  chartTabCount: b.length,
32
32
  comparisonTabCount: i.length,
33
33
  actionDrawer: B,
@@ -46,7 +46,7 @@ var pe = Pt(({ beat: s }) => {
46
46
  spendCategoryGuids: v,
47
47
  displayedDateRange: f
48
48
  }), lt = g.map((t) => t.guid).join(","), ct = v.join(","), dt = I.join(","), mt = e === "list" || e === "tabsOnly" || e === "monthTabs" || p.length > 0, j = () => {
49
- u !== "store" || !mt || X.setFilter(wt(C(o), {
49
+ u !== "store" || !mt || X.setFilter(kt(C(o), {
50
50
  allAccountGuids: I,
51
51
  displayedDateRange: f
52
52
  }));
@@ -66,14 +66,14 @@ var pe = Pt(({ beat: s }) => {
66
66
  lt,
67
67
  e
68
68
  ]);
69
- const F = Gt(c), y = z?.({
69
+ const F = Ht(c), y = z?.({
70
70
  title: c?.title,
71
71
  subHeader: F,
72
72
  categoryName: Q,
73
73
  selectedDate: b[o]?.date ?? void 0
74
74
  }), G = U(D, a?.category_guid);
75
75
  if (!tt) return /* @__PURE__ */ r(Bt, {});
76
- const [H, w] = a?.legends ?? [], ut = u === "local" ? (t) => C(t).custom ?? (() => !0) : void 0, { transactions: gt, projectedTransaction: A } = Ht(g), pt = u === "local" ? gt : void 0, k = n.general.projected_amount, bt = A && k && C(o).custom?.(A) ? {
76
+ const [H, w] = a?.legends ?? [], ut = u === "local" ? (t) => C(t).custom ?? (() => !0) : void 0, { transactions: gt, projectedTransaction: A } = wt(g), pt = u === "local" ? gt : void 0, k = n.general.projected_amount, bt = A && k && C(o).custom?.(A) ? {
77
77
  heading: k,
78
78
  transaction: A
79
79
  } : void 0, N = (t, h) => {
@@ -116,7 +116,7 @@ var pe = Pt(({ beat: s }) => {
116
116
  selectedTabIndex: o,
117
117
  trendAmountLabel: w?.label ?? n.general.trend
118
118
  }) : /* @__PURE__ */ r(vt, {}) : null;
119
- return /* @__PURE__ */ zt(Vt, { children: [/* @__PURE__ */ r(Rt, {
119
+ return /* @__PURE__ */ zt(Vt, { children: [/* @__PURE__ */ r(Ot, {
120
120
  baseTransactions: pt,
121
121
  hideListHeader: J,
122
122
  projectedRow: bt,