@mx-cartographer/experiences 9.7.202 → 9.7.204

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 (41) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/core/stores/AnalyticsStore.es.js +9 -8
  3. package/dist/core/stores/AnalyticsStore.es.js.map +1 -1
  4. package/dist/core/stores/InsightsV2Store.d.ts +4 -0
  5. package/dist/core/stores/InsightsV2Store.es.js +10 -8
  6. package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
  7. package/dist/core/types/Insights.d.ts +1 -0
  8. package/dist/core/types/Insights.es.js.map +1 -1
  9. package/dist/core/utils/PostHog.d.ts +2 -0
  10. package/dist/core/utils/PostHog.es.js +6 -0
  11. package/dist/core/utils/PostHog.es.js.map +1 -0
  12. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +28 -28
  13. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
  14. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +4 -4
  15. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +14 -14
  16. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  17. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.d.ts +5 -5
  18. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +26 -26
  19. package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js.map +1 -1
  20. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.d.ts +14 -0
  21. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.es.js +324 -0
  22. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/FeedbackBlock.es.js.map +1 -0
  23. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/index.d.ts +1 -0
  24. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.d.ts +29 -0
  25. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.es.js +25 -0
  26. package/dist/insights-v2/blocks/ComponentBlocks/FeedbackBlock/survey.es.js.map +1 -0
  27. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +34 -34
  28. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
  29. package/dist/insights-v2/blocks/ComponentBlocks/index.d.ts +1 -0
  30. package/dist/insights-v2/components/BaseLayout.es.js +137 -135
  31. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  32. package/dist/insights-v2/components/Header.d.ts +5 -1
  33. package/dist/insights-v2/components/Header.es.js +15 -15
  34. package/dist/insights-v2/components/Header.es.js.map +1 -1
  35. package/dist/insights-v2/components/MerchantHighlightCard.d.ts +2 -2
  36. package/dist/insights-v2/components/MerchantHighlightCard.es.js +5 -5
  37. package/dist/insights-v2/components/MerchantHighlightCard.es.js.map +1 -1
  38. package/dist/insights-v2/index.es.js +51 -49
  39. package/dist/insights-v2/mappings/blocks.es.js +96 -94
  40. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  41. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [9.7.204] - 11-24-2026
2
+
3
+ - **FIXED** - Debt Payment Reminder, P2P and Category Budget beats match Figma design QA (WEC-2440)
4
+
5
+ ## [9.7.203] - 11-23-2026
6
+
7
+ - **ADDED** - User Feedback survey block (WELL-224)
8
+ - **ADDED** - BaseLayout beatContext keys card_title and keep_after_dismiss, exported as BEAT_CARD_TITLE_KEY and BEAT_KEEP_AFTER_DISMISS_KEY, plus BlockType.FeedbackBlock (WELL-224)
9
+
1
10
  ## [9.7.202] - 11-23-2026
2
11
 
3
12
  - **ADDED** - Deposit 529 account block variant (WELL-221)
@@ -1,6 +1,7 @@
1
- import { makeAutoObservable as i, runInAction as r } from "mobx";
2
- import u from "posthog-js";
3
- var l = class {
1
+ import { isProductionPostHogKey as i } from "../utils/PostHog.es.js";
2
+ import { makeAutoObservable as r, runInAction as u } from "mobx";
3
+ import o from "posthog-js";
4
+ var c = class {
4
5
  globalStore;
5
6
  survey = null;
6
7
  currentQuestionIndex = 0;
@@ -8,7 +9,7 @@ var l = class {
8
9
  response = null;
9
10
  responses = {};
10
11
  constructor(s) {
11
- this.globalStore = s, i(this);
12
+ this.globalStore = s, r(this);
12
13
  }
13
14
  get isLastQuestion() {
14
15
  return this.currentQuestionIndex === this.surveyQuestions.length - 1;
@@ -23,14 +24,14 @@ var l = class {
23
24
  };
24
25
  }
25
26
  get surveyId() {
26
- return window.app?.postHogPublicKey === "phc_KclQGnOZEaYCttkpiVpuyOYeBlixGo6xNphYgWV4CXo" ? "0196caa6-9b37-0000-98a7-f04e8d56faf5" : "0196a6b0-ccde-0000-b980-0b84ea2fef4a";
27
+ return i(window.app?.postHogPublicKey) ? "0196caa6-9b37-0000-98a7-f04e8d56faf5" : "0196a6b0-ccde-0000-b980-0b84ea2fef4a";
27
28
  }
28
29
  get surveyQuestions() {
29
30
  return this.survey ? this.survey.questions : [];
30
31
  }
31
32
  loadSurvey = (s = !1) => {
32
- u.getActiveMatchingSurveys((t) => {
33
- r(() => {
33
+ o.getActiveMatchingSurveys((t) => {
34
+ u(() => {
34
35
  if (t.length > 0) {
35
36
  const e = t.find((n) => n.id === this.surveyId);
36
37
  e && (this.survey = e, this.currentQuestionIndex = 0, this.question = e.questions[0], this.response = null, this.responses = {});
@@ -49,7 +50,7 @@ var l = class {
49
50
  };
50
51
  };
51
52
  export {
52
- l as AnalyticsStore
53
+ c as AnalyticsStore
53
54
  };
54
55
 
55
56
  //# sourceMappingURL=AnalyticsStore.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsStore.es.js","names":[],"sources":["../../../src/core/stores/AnalyticsStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport posthog, { Survey, SurveyQuestion } from 'posthog-js'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class AnalyticsStore {\n globalStore: GlobalStore\n survey: Survey | null = null\n currentQuestionIndex: number = 0\n question: SurveyQuestion | null = null\n response: number | string | null = null\n responses: Record<string, number | string | null> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n makeAutoObservable(this)\n }\n\n get isLastQuestion() {\n return this.currentQuestionIndex === this.surveyQuestions.length - 1\n }\n\n get questionCount() {\n return `${this.currentQuestionIndex + 1}/${this.surveyQuestions.length}`\n }\n\n get responsePayload() {\n return {\n $survey_id: this.surveyId,\n ...this.responses,\n }\n }\n\n // TODO hardcode elsewhere\n get surveyId() {\n const posthogKey = window.app?.postHogPublicKey\n\n return posthogKey === 'phc_KclQGnOZEaYCttkpiVpuyOYeBlixGo6xNphYgWV4CXo'\n ? '0196caa6-9b37-0000-98a7-f04e8d56faf5'\n : '0196a6b0-ccde-0000-b980-0b84ea2fef4a'\n }\n\n get surveyQuestions() {\n return this.survey ? this.survey.questions : ([] as SurveyQuestion[])\n }\n\n loadSurvey = (forceReload: boolean = false) => {\n posthog.getActiveMatchingSurveys((surveys) => {\n runInAction(() => {\n if (surveys.length > 0) {\n const survey = surveys.find((s) => s.id === this.surveyId)\n if (survey) {\n this.survey = survey\n this.currentQuestionIndex = 0\n this.question = survey.questions[0]\n this.response = null\n this.responses = {}\n }\n }\n })\n }, forceReload)\n }\n\n nextQuestion = () => {\n if (this.currentQuestionIndex < this.surveyQuestions.length - 1) {\n this.currentQuestionIndex += 1\n }\n this.response = null\n this.question = this.surveyQuestions[this.currentQuestionIndex]\n }\n\n resetStore = () => {\n this.survey = null\n this.currentQuestionIndex = 0\n this.question = null\n this.response = null\n this.responses = {}\n }\n\n setResponse = (response: number | string | null) => {\n this.response = response\n if (this.question) {\n this.responses[`$survey_response_${this.question.id}`] = response\n }\n }\n}\n"],"mappings":";;AAKA,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AA,EAC5C;AAAA,EAEA,aAAA,MAAmB;AACjB,SAAK,SAAS,MACd,KAAK,uBAAuB,GAC5B,KAAK,WAAW,MAChB,KAAK,WAAW,MAChB,KAAK,YAAY,CAAC;AAAA,EACpB;AAAA,EAEA,cAAA,CAAe,MAAqC;AAClD,SAAK,WAAW,GACZ,KAAK,aACP,KAAK,UAAU,oBAAoB,KAAK,SAAS,EAAA,EAAA,IAAQ;AAAA,EAE7D;AACF"}
1
+ {"version":3,"file":"AnalyticsStore.es.js","names":[],"sources":["../../../src/core/stores/AnalyticsStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport posthog, { Survey, SurveyQuestion } from 'posthog-js'\n\nimport { isProductionPostHogKey } from '../utils/PostHog'\nimport { GlobalStore } from './GlobalStore'\n\nexport class AnalyticsStore {\n globalStore: GlobalStore\n survey: Survey | null = null\n currentQuestionIndex: number = 0\n question: SurveyQuestion | null = null\n response: number | string | null = null\n responses: Record<string, number | string | null> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n makeAutoObservable(this)\n }\n\n get isLastQuestion() {\n return this.currentQuestionIndex === this.surveyQuestions.length - 1\n }\n\n get questionCount() {\n return `${this.currentQuestionIndex + 1}/${this.surveyQuestions.length}`\n }\n\n get responsePayload() {\n return {\n $survey_id: this.surveyId,\n ...this.responses,\n }\n }\n\n // TODO hardcode elsewhere\n get surveyId() {\n return isProductionPostHogKey(window.app?.postHogPublicKey)\n ? '0196caa6-9b37-0000-98a7-f04e8d56faf5'\n : '0196a6b0-ccde-0000-b980-0b84ea2fef4a'\n }\n\n get surveyQuestions() {\n return this.survey ? this.survey.questions : ([] as SurveyQuestion[])\n }\n\n loadSurvey = (forceReload: boolean = false) => {\n posthog.getActiveMatchingSurveys((surveys) => {\n runInAction(() => {\n if (surveys.length > 0) {\n const survey = surveys.find((s) => s.id === this.surveyId)\n if (survey) {\n this.survey = survey\n this.currentQuestionIndex = 0\n this.question = survey.questions[0]\n this.response = null\n this.responses = {}\n }\n }\n })\n }, forceReload)\n }\n\n nextQuestion = () => {\n if (this.currentQuestionIndex < this.surveyQuestions.length - 1) {\n this.currentQuestionIndex += 1\n }\n this.response = null\n this.question = this.surveyQuestions[this.currentQuestionIndex]\n }\n\n resetStore = () => {\n this.survey = null\n this.currentQuestionIndex = 0\n this.question = null\n this.response = null\n this.responses = {}\n }\n\n setResponse = (response: number | string | null) => {\n this.response = response\n if (this.question) {\n this.responses[`$survey_response_${this.question.id}`] = response\n }\n }\n}\n"],"mappings":";;;AAMA,IAAa,IAAb,MAA4B;AAAA,EAC1B;AAAA,EACA,SAAwB;AAAA,EACxB,uBAA+B;AAAA,EAC/B,WAAkC;AAAA,EAClC,WAAmC;AAAA,EACnC,YAAoD,CAAC;AAAA,EAErD,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,iBAAiB;AACnB,WAAO,KAAK,yBAAyB,KAAK,gBAAgB,SAAS;AAAA,EACrE;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,GAAG,KAAK,uBAAuB,CAAA,IAAK,KAAK,gBAAgB,MAAA;AAAA,EAClE;AAAA,EAEA,IAAI,kBAAkB;AACpB,WAAO;AAAA,MACL,YAAY,KAAK;AAAA,MACjB,GAAG,KAAK;AAAA,IACV;AAAA,EACF;AAAA,EAGA,IAAI,WAAW;AACb,WAAO,EAAuB,OAAO,KAAK,gBAAgB,IACtD,yCACA;AAAA,EACN;AAAA,EAEA,IAAI,kBAAkB;AACpB,WAAO,KAAK,SAAS,KAAK,OAAO,YAAa,CAAC;AAAA,EACjD;AAAA,EAEA,aAAA,CAAc,IAAuB,OAAU;AAC7C,IAAA,EAAQ,yBAAA,CAA0B,MAAY;AAC5C,MAAA,EAAA,MAAkB;AAChB,YAAI,EAAQ,SAAS,GAAG;AACtB,gBAAM,IAAS,EAAQ,KAAA,CAAM,MAAM,EAAE,OAAO,KAAK,QAAQ;AACzD,UAAI,MACF,KAAK,SAAS,GACd,KAAK,uBAAuB,GAC5B,KAAK,WAAW,EAAO,UAAU,CAAA,GACjC,KAAK,WAAW,MAChB,KAAK,YAAY,CAAC;AAAA,QAEtB;AAAA,MACF,CAAC;AAAA,IACH,GAAG,CAAW;AAAA,EAChB;AAAA,EAEA,eAAA,MAAqB;AACnB,IAAI,KAAK,uBAAuB,KAAK,gBAAgB,SAAS,MAC5D,KAAK,wBAAwB,IAE/B,KAAK,WAAW,MAChB,KAAK,WAAW,KAAK,gBAAgB,KAAK,oBAAA;AAAA,EAC5C;AAAA,EAEA,aAAA,MAAmB;AACjB,SAAK,SAAS,MACd,KAAK,uBAAuB,GAC5B,KAAK,WAAW,MAChB,KAAK,WAAW,MAChB,KAAK,YAAY,CAAC;AAAA,EACpB;AAAA,EAEA,cAAA,CAAe,MAAqC;AAClD,SAAK,WAAW,GACZ,KAAK,aACP,KAAK,UAAU,oBAAoB,KAAK,SAAS,EAAA,EAAA,IAAQ;AAAA,EAE7D;AACF"}
@@ -41,6 +41,10 @@ type OpenActionDrawerArgs = {
41
41
  });
42
42
  /** beatContext key: the beat's active_at as its card last rendered it (a sampled refresh drops it). */
43
43
  export declare const BEAT_ACTIVE_AT_KEY = "active_at";
44
+ /** beatContext key: a title the card's block shows in place of the envelope's (a survey's question). */
45
+ export declare const BEAT_CARD_TITLE_KEY = "card_title";
46
+ /** beatContext key: keep drawing the card after its block dismissed the beat (until the feed refreshes). */
47
+ export declare const BEAT_KEEP_AFTER_DISMISS_KEY = "keep_after_dismiss";
44
48
  /** A message a block hands over when it closes its own drawer, shown after it unmounts. */
45
49
  export interface ActionNotice {
46
50
  message: string;
@@ -1,18 +1,18 @@
1
- import { makeAutoObservable as o } from "mobx";
2
- var r = {
1
+ import { makeAutoObservable as r } from "mobx";
2
+ var o = {
3
3
  isDrawerOpen: !1,
4
4
  trigger: "primaryCta",
5
5
  guid: "",
6
6
  context: void 0,
7
7
  cta: void 0
8
- }, n = "active_at", c = class {
8
+ }, c = "active_at", n = "card_title", D = "keep_after_dismiss", h = class {
9
9
  globalStore;
10
- actionDrawer = r;
10
+ actionDrawer = o;
11
11
  ctaStatus = {};
12
12
  actionNotice = {};
13
13
  beatContext = {};
14
14
  constructor(t) {
15
- this.globalStore = t, o(this);
15
+ this.globalStore = t, r(this);
16
16
  }
17
17
  setActionNotice = (t, e) => {
18
18
  this.actionNotice = {
@@ -68,9 +68,11 @@ var r = {
68
68
  };
69
69
  };
70
70
  export {
71
- n as BEAT_ACTIVE_AT_KEY,
72
- r as CLOSED_ACTION_DRAWER,
73
- c as InsightsV2Store
71
+ c as BEAT_ACTIVE_AT_KEY,
72
+ n as BEAT_CARD_TITLE_KEY,
73
+ D as BEAT_KEEP_AFTER_DISMISS_KEY,
74
+ o as CLOSED_ACTION_DRAWER,
75
+ h as InsightsV2Store
74
76
  };
75
77
 
76
78
  //# sourceMappingURL=InsightsV2Store.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { InDescriptionCTA } from '../types/Insights'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n /**\n * Block and variant an `inDescriptionCta` drawer runs; without it the beat's own\n * `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.\n */\n cta?: DrawerCta\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n cta: undefined,\n}\n\n/** What an `inDescriptionCta` opener picks: the block, its variant and step (`action_key`). */\nexport type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant' | 'action_key'>\n\n// Only the `inDescriptionCta` trigger accepts a `cta`.\ntype OpenActionDrawerArgs = {\n guid: string\n context?: unknown\n} & (\n | { trigger: 'inDescriptionCta'; cta?: DrawerCta }\n | { trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>; cta?: never }\n)\n\n/** beatContext key: the beat's active_at as its card last rendered it (a sampled refresh drops it). */\nexport const BEAT_ACTIVE_AT_KEY = 'active_at'\n\n/** A message a block hands over when it closes its own drawer, shown after it unmounts. */\nexport interface ActionNotice {\n message: string\n severity: 'success' | 'error'\n}\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /** The notice per beat guid that outlives its drawer session; ActionBlockLayer draws it. */\n actionNotice: Record<string, ActionNotice | undefined> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setActionNotice = (guid: string, notice: ActionNotice | undefined) => {\n this.actionNotice = { ...this.actionNotice, [guid]: notice }\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext. `cta` overrides the CTA an\n * `inDescriptionCta` drawer runs, for this session only.\n */\n openActionDrawer = ({ guid, trigger, context, cta }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context, cta }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger`, `context` and `cta` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";AAmCA,IAAa,IAA0C;AAAA,EACrD,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AACP,GAea,IAAqB,aAiBrB,IAAb,MAA6B;AAAA,EAC3B;AAAA,EAEA,eAAkC;AAAA,EAMlC,YAAuC,CAAC;AAAA,EAGxC,eAAyD,CAAC;AAAA,EAU1D,cAAuD,CAAC;AAAA,EAExD,YAAY,GAA0B;AACpC,SAAK,cAAc,GAEnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,kBAAA,CAAmB,GAAc,MAAqC;AACpE,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAe,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EAC7D;AAAA,EAEA,eAAA,CAAgB,GAAc,MAAsB;AAClD,SAAK,YAAY;AAAA,MAAE,GAAG,KAAK;AAAA,MAAY,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EACvD;AAAA,EAGA,iBAAA,CAAkB,GAAc,MAAoC;AAClE,SAAK,cAAc;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,CAAA,CAAA,GAAO;AAAA,QAAE,GAAG,KAAK,YAAY,CAAA;AAAA,QAAO,GAAG;AAAA,MAAO;AAAA,IAAE;AAAA,EAC7F;AAAA,EAYA,mBAAA,CAAoB,MAAqC;AACvD,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA,MACR,SAAS;AAAA,QACP,GAAI,KAAK,aAAa;AAAA,QACtB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAQA,mBAAA,CAAoB,EAAE,MAAA,GAAM,SAAA,GAAS,SAAA,GAAS,KAAA,EAAA,MAAgC;AAC5E,SAAK,eAAe;AAAA,MAAE,cAAc;AAAA,MAAM,SAAA;AAAA,MAAS,MAAA;AAAA,MAAM,SAAA;AAAA,MAAS,KAAA;AAAA,IAAI;AAAA,EACxE;AAAA,EAGA,gBAAA,CAAiB,GAAc,MAA2C;AACxE,SAAK,iBAAiB;AAAA,MAAE,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ,CAAC;AAAA,EACzC;AAAA,EAEA,oBAAA,MAA0B;AAIxB,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,cAAc;AAAA,MAAO,MAAM;AAAA,IAAG;AAAA,EAC5E;AACF"}
1
+ {"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { InDescriptionCTA } from '../types/Insights'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n /**\n * Block and variant an `inDescriptionCta` drawer runs; without it the beat's own\n * `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.\n */\n cta?: DrawerCta\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n cta: undefined,\n}\n\n/** What an `inDescriptionCta` opener picks: the block, its variant and step (`action_key`). */\nexport type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant' | 'action_key'>\n\n// Only the `inDescriptionCta` trigger accepts a `cta`.\ntype OpenActionDrawerArgs = {\n guid: string\n context?: unknown\n} & (\n | { trigger: 'inDescriptionCta'; cta?: DrawerCta }\n | { trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>; cta?: never }\n)\n\n/** beatContext key: the beat's active_at as its card last rendered it (a sampled refresh drops it). */\nexport const BEAT_ACTIVE_AT_KEY = 'active_at'\n/** beatContext key: a title the card's block shows in place of the envelope's (a survey's question). */\nexport const BEAT_CARD_TITLE_KEY = 'card_title'\n/** beatContext key: keep drawing the card after its block dismissed the beat (until the feed refreshes). */\nexport const BEAT_KEEP_AFTER_DISMISS_KEY = 'keep_after_dismiss'\n\n/** A message a block hands over when it closes its own drawer, shown after it unmounts. */\nexport interface ActionNotice {\n message: string\n severity: 'success' | 'error'\n}\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /** The notice per beat guid that outlives its drawer session; ActionBlockLayer draws it. */\n actionNotice: Record<string, ActionNotice | undefined> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setActionNotice = (guid: string, notice: ActionNotice | undefined) => {\n this.actionNotice = { ...this.actionNotice, [guid]: notice }\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext. `cta` overrides the CTA an\n * `inDescriptionCta` drawer runs, for this session only.\n */\n openActionDrawer = ({ guid, trigger, context, cta }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context, cta }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger`, `context` and `cta` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";AAmCA,IAAa,IAA0C;AAAA,EACrD,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AACP,GAea,IAAqB,aAErB,IAAsB,cAEtB,IAA8B,sBAiB9B,IAAb,MAA6B;AAAA,EAC3B;AAAA,EAEA,eAAkC;AAAA,EAMlC,YAAuC,CAAC;AAAA,EAGxC,eAAyD,CAAC;AAAA,EAU1D,cAAuD,CAAC;AAAA,EAExD,YAAY,GAA0B;AACpC,SAAK,cAAc,GAEnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,kBAAA,CAAmB,GAAc,MAAqC;AACpE,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAe,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EAC7D;AAAA,EAEA,eAAA,CAAgB,GAAc,MAAsB;AAClD,SAAK,YAAY;AAAA,MAAE,GAAG,KAAK;AAAA,MAAY,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EACvD;AAAA,EAGA,iBAAA,CAAkB,GAAc,MAAoC;AAClE,SAAK,cAAc;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,CAAA,CAAA,GAAO;AAAA,QAAE,GAAG,KAAK,YAAY,CAAA;AAAA,QAAO,GAAG;AAAA,MAAO;AAAA,IAAE;AAAA,EAC7F;AAAA,EAYA,mBAAA,CAAoB,MAAqC;AACvD,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA,MACR,SAAS;AAAA,QACP,GAAI,KAAK,aAAa;AAAA,QACtB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAQA,mBAAA,CAAoB,EAAE,MAAA,GAAM,SAAA,GAAS,SAAA,GAAS,KAAA,EAAA,MAAgC;AAC5E,SAAK,eAAe;AAAA,MAAE,cAAc;AAAA,MAAM,SAAA;AAAA,MAAS,MAAA;AAAA,MAAM,SAAA;AAAA,MAAS,KAAA;AAAA,IAAI;AAAA,EACxE;AAAA,EAGA,gBAAA,CAAiB,GAAc,MAA2C;AACxE,SAAK,iBAAiB;AAAA,MAAE,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ,CAAC;AAAA,EACzC;AAAA,EAEA,oBAAA,MAA0B;AAIxB,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,cAAc;AAAA,MAAO,MAAM;AAAA,IAAG;AAAA,EAC5E;AACF"}
@@ -274,6 +274,7 @@ export declare const BlockType: {
274
274
  readonly NoSpendDaysBlock: "no_spend_days_block";
275
275
  readonly QuarterlySummaryBlock: "quarterly_summary_block";
276
276
  readonly QuizBlock: "quiz_block";
277
+ readonly FeedbackBlock: "feedback_block";
277
278
  readonly RepeatingTransactionBlock: "repeating_transaction_block";
278
279
  readonly SaveExtraBlock: "save_extra_block";
279
280
  readonly SavingsAmountBlock: "savings_amount_block";
@@ -1 +1 @@
1
- {"version":3,"file":"Insights.es.js","names":[],"sources":["../../../src/core/types/Insights.ts"],"sourcesContent":["// ============ Core InsightsV2 Types ============\n\nimport type { DataSeries } from './Beat'\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/** A row in a drilldown list fact (e.g. the Subscriptions drawer's per-transaction schedule). */\nexport type DrilldownRow = Record<string, string | number | boolean | null>\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 * string lists, a `data_series` (the months a history drawer charts), or rows of scalars\n * (`transaction_frequencies`), omitted when the insight has none. Never carries copy or user actions\n * (memo, tags, hide, flag come from the transaction store). Values come from the server, so a reader\n * still checks each value's runtime shape.\n */\nexport type DrilldownData = Record<\n string,\n string | number | boolean | null | string[] | DataSeries | DrilldownRow[]\n>\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 /** tupac's flat host message for the link (`action` plus fields), e.g. Switch's op_1. */\n post_message_metadata?: ({ action?: string | null } & Record<string, unknown>) | 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 GasPurchaseBlock: 'gas_purchase_block',\n GoalsBlock: 'goals_block',\n NoSpendDaysBlock: 'no_spend_days_block',\n QuarterlySummaryBlock: 'quarterly_summary_block',\n QuizBlock: 'quiz_block',\n RepeatingTransactionBlock: 'repeating_transaction_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsAmountBlock: 'savings_amount_block',\n SavingsSummaryBlock: 'savings_summary_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WeeklySmallPurchasesBlock: 'weekly_small_purchases_block',\n WithdrawalBlock: 'withdrawal_block',\n FeeChargedBlock: 'fee_charged_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 start_date?: string\n no_spend_days?: string[]\n /** First day of the month a monthly summary covers, in ISO form (e.g. `2026-09-01`). */\n date?: string\n /** Number of gas station visits in the month. */\n total_fill_up_visits?: number\n /** Amount spent at gas stations in the month, unformatted. */\n total_spend?: number\n /** V1 name for `total_spend`, read when `total_spend` is absent. */\n total_debt_for_fill_up_visits_in_prev_month?: number\n /** Total available balance across the user's accounts, unformatted. */\n available_balance?: number\n /** Average monthly spend, unformatted. */\n avg_monthly_spend?: number\n /** How long the balance lasts, e.g. \"2 months, 11 days\". */\n time_period?: string\n /** One row per unique merchant in the period, in the order sent. */\n data_series?: InstanceSlotRow[]\n}\n"],"mappings":"AAyVA,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 type { DataSeries } from './Beat'\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/** A row in a drilldown list fact (e.g. the Subscriptions drawer's per-transaction schedule). */\nexport type DrilldownRow = Record<string, string | number | boolean | null>\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 * string lists, a `data_series` (the months a history drawer charts), or rows of scalars\n * (`transaction_frequencies`), omitted when the insight has none. Never carries copy or user actions\n * (memo, tags, hide, flag come from the transaction store). Values come from the server, so a reader\n * still checks each value's runtime shape.\n */\nexport type DrilldownData = Record<\n string,\n string | number | boolean | null | string[] | DataSeries | DrilldownRow[]\n>\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 /** tupac's flat host message for the link (`action` plus fields), e.g. Switch's op_1. */\n post_message_metadata?: ({ action?: string | null } & Record<string, unknown>) | 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 GasPurchaseBlock: 'gas_purchase_block',\n GoalsBlock: 'goals_block',\n NoSpendDaysBlock: 'no_spend_days_block',\n QuarterlySummaryBlock: 'quarterly_summary_block',\n QuizBlock: 'quiz_block',\n FeedbackBlock: 'feedback_block',\n RepeatingTransactionBlock: 'repeating_transaction_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsAmountBlock: 'savings_amount_block',\n SavingsSummaryBlock: 'savings_summary_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WeeklySmallPurchasesBlock: 'weekly_small_purchases_block',\n WithdrawalBlock: 'withdrawal_block',\n FeeChargedBlock: 'fee_charged_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 start_date?: string\n no_spend_days?: string[]\n /** First day of the month a monthly summary covers, in ISO form (e.g. `2026-09-01`). */\n date?: string\n /** Number of gas station visits in the month. */\n total_fill_up_visits?: number\n /** Amount spent at gas stations in the month, unformatted. */\n total_spend?: number\n /** V1 name for `total_spend`, read when `total_spend` is absent. */\n total_debt_for_fill_up_visits_in_prev_month?: number\n /** Total available balance across the user's accounts, unformatted. */\n available_balance?: number\n /** Average monthly spend, unformatted. */\n avg_monthly_spend?: number\n /** How long the balance lasts, e.g. \"2 months, 11 days\". */\n time_period?: string\n /** One row per unique merchant in the period, in the order sent. */\n data_series?: InstanceSlotRow[]\n}\n"],"mappings":"AA0VA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
@@ -0,0 +1,2 @@
1
+ /** Whether `postHogPublicKey` is production's, so a caller can pick that environment's survey id. */
2
+ export declare const isProductionPostHogKey: (postHogPublicKey?: string) => postHogPublicKey is "phc_KclQGnOZEaYCttkpiVpuyOYeBlixGo6xNphYgWV4CXo";
@@ -0,0 +1,6 @@
1
+ var O = "phc_KclQGnOZEaYCttkpiVpuyOYeBlixGo6xNphYgWV4CXo", p = (o) => o === O;
2
+ export {
3
+ p as isProductionPostHogKey
4
+ };
5
+
6
+ //# sourceMappingURL=PostHog.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostHog.es.js","names":[],"sources":["../../../src/core/utils/PostHog.ts"],"sourcesContent":["// The production PostHog project's public key; any other key is a non-production project.\nconst PRODUCTION_POSTHOG_KEY = 'phc_KclQGnOZEaYCttkpiVpuyOYeBlixGo6xNphYgWV4CXo'\n\n/** Whether `postHogPublicKey` is production's, so a caller can pick that environment's survey id. */\nexport const isProductionPostHogKey = (postHogPublicKey?: string) =>\n postHogPublicKey === PRODUCTION_POSTHOG_KEY\n"],"mappings":"AACA,IAAM,IAAyB,mDAGlB,IAAA,CAA0B,MACrC,MAAqB"}
@@ -1,75 +1,75 @@
1
- import { buildDynamicCopy as p, buildPluralCopy as g } from "../../../core/utils/Localization.es.js";
1
+ import { buildDynamicCopy as s, buildPluralCopy as g } from "../../../core/utils/Localization.es.js";
2
2
  import { CURRENCY_FORMAT as e, formatCurrency as t } from "../../../core/utils/NumberFormatting.es.js";
3
3
  import { calculateBudgetPercent as v, calculateBudgetTier as y, tierColor as C } from "./layout.es.js";
4
4
  import S from "../../components/ComponentBlocks/StatusIndicator.es.js";
5
- import i from "@mui/material/Stack";
6
- import { Text as o } from "@mxenabled/mxui";
7
- import { jsx as r, jsxs as n } from "react/jsx-runtime";
5
+ import l from "@mui/material/Stack";
6
+ import { P as B, Text as i } from "@mxenabled/mxui";
7
+ import { jsx as r, jsxs as o } from "react/jsx-runtime";
8
8
  import x from "@mui/material/Box";
9
- import B from "@mui/material/Alert";
10
- var E = ({ budgetsCopy: c, copy: d, daysLeft: m, icon: _, limit: a, showPeriodLine: h = !0, spent: l }) => {
11
- const s = v(l, a), f = y(s), b = C(f), u = m === void 0 ? /* @__PURE__ */ r(B, {
9
+ import D from "@mui/material/Alert";
10
+ var E = ({ budgetsCopy: c, copy: m, daysLeft: d, icon: _, limit: n, showPeriodLine: h = !0, spent: a }) => {
11
+ const p = v(a, n), f = y(p), b = C(f), u = d === void 0 ? /* @__PURE__ */ r(D, {
12
12
  severity: "info",
13
- children: d.previous_month_notice
14
- }) : /* @__PURE__ */ r(o, {
13
+ children: m.previous_month_notice
14
+ }) : /* @__PURE__ */ r(i, {
15
15
  color: "text.secondary",
16
16
  variant: "body2",
17
- children: g(d.days_left_until_end_of_month_one, d.days_left_until_end_of_month, m, String(m))
17
+ children: g(m.days_left_until_end_of_month_one, m.days_left_until_end_of_month, d, String(d))
18
18
  });
19
- return a <= 0 ? /* @__PURE__ */ n(i, {
19
+ return n <= 0 ? /* @__PURE__ */ o(l, {
20
20
  sx: { gap: 16 },
21
- children: [/* @__PURE__ */ n(i, {
21
+ children: [/* @__PURE__ */ o(l, {
22
22
  sx: {
23
23
  alignItems: "center",
24
24
  flexDirection: "row",
25
25
  gap: 12
26
26
  },
27
- children: [/* @__PURE__ */ r(x, { children: _ }), /* @__PURE__ */ n(i, { children: [/* @__PURE__ */ r(o, {
27
+ children: [/* @__PURE__ */ r(x, { children: _ }), /* @__PURE__ */ o(l, { children: [/* @__PURE__ */ r(i, {
28
28
  color: "text.secondary",
29
29
  variant: "body2",
30
30
  children: c.spent_label
31
- }), /* @__PURE__ */ r(o, {
31
+ }), /* @__PURE__ */ r(i, {
32
32
  bold: !0,
33
33
  component: "p",
34
34
  variant: "h2",
35
- children: t(l, e.cents)
35
+ children: t(a, e.cents)
36
36
  })] })]
37
37
  }), h && u]
38
- }) : /* @__PURE__ */ n(i, {
38
+ }) : /* @__PURE__ */ o(l, {
39
39
  sx: { gap: 16 },
40
40
  children: [/* @__PURE__ */ r(x, {
41
- "aria-label": p(d.total_out_of_limit_aria, t(l, e.cents), t(a, e.cents)),
41
+ "aria-label": s(m.total_out_of_limit_aria, t(a, e.cents), t(n, e.cents)),
42
42
  "data-tier": f ?? "none",
43
43
  role: "group",
44
44
  children: /* @__PURE__ */ r(S, {
45
- amount: /* @__PURE__ */ n(i, {
45
+ amount: /* @__PURE__ */ o(l, {
46
46
  sx: {
47
47
  alignItems: "baseline",
48
48
  flexDirection: "row",
49
49
  gap: 4
50
50
  },
51
- children: [/* @__PURE__ */ r(o, {
51
+ children: [/* @__PURE__ */ r(B, {
52
52
  bold: !0,
53
- component: "p",
53
+ color: "text.primary",
54
54
  variant: "h2",
55
- children: t(l, e.cents)
56
- }), /* @__PURE__ */ n(o, {
55
+ children: t(a, e.cents)
56
+ }), /* @__PURE__ */ o(i, {
57
57
  color: "text.secondary",
58
58
  variant: "body2",
59
- children: ["/ ", t(a, e.cents)]
59
+ children: ["/ ", t(n, e.cents)]
60
60
  })]
61
61
  }),
62
62
  completeColor: b,
63
63
  icon: _,
64
- label: /* @__PURE__ */ r(o, {
65
- color: "text.secondary",
64
+ label: /* @__PURE__ */ r(i, {
65
+ color: "text.primary",
66
66
  variant: "body2",
67
67
  children: c.spent_label
68
68
  }),
69
69
  labelVariant: "body2",
70
- leftLabel: p(c.percent_spent, String(s)),
71
- percentComplete: Math.min(100, s),
72
- rightLabel: p(c.balance_left, t(Math.max(0, a - l), e.cents)),
70
+ leftLabel: s(c.percent_spent, String(p)),
71
+ percentComplete: Math.min(100, p),
72
+ rightLabel: s(c.balance_left, t(Math.max(0, n - a), e.cents)),
73
73
  sx: { p: 0 }
74
74
  })
75
75
  }), h && u]
@@ -1 +1 @@
1
- {"version":3,"file":"BudgetSummary.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport type { BudgetsCopy } from '../../../core/types/localization'\nimport type { BudgetDetailsCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport StatusIndicator from '../../components/ComponentBlocks/StatusIndicator'\n\nimport { calculateBudgetPercent, calculateBudgetTier, tierColor } from './layout'\n\ninterface BudgetSummaryProps {\n budgetsCopy: BudgetsCopy\n copy: BudgetDetailsCopy\n daysLeft?: number\n icon: ReactNode\n limit: number\n /** The days-left / previous-month line under the bar (off for Figma's Budget Details insights). */\n showPeriodLine?: boolean\n spent: number\n}\n\nexport const BudgetSummary = ({\n budgetsCopy,\n copy,\n daysLeft,\n icon,\n limit,\n showPeriodLine = true,\n spent,\n}: BudgetSummaryProps) => {\n const percent = calculateBudgetPercent(spent, limit)\n const tier = calculateBudgetTier(percent)\n const color = tierColor(tier)\n const periodLine =\n daysLeft === undefined ? (\n <Alert severity=\"info\">{copy.previous_month_notice}</Alert>\n ) : (\n <Text color=\"text.secondary\" variant=\"body2\">\n {\n buildPluralCopy(\n copy.days_left_until_end_of_month_one,\n copy.days_left_until_end_of_month,\n daysLeft,\n String(daysLeft),\n ) as string\n }\n </Text>\n )\n\n if (limit <= 0) {\n return (\n <Stack sx={{ gap: 16 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <Box>{icon}</Box>\n <Stack>\n <Text color=\"text.secondary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(spent, CURRENCY_FORMAT.cents)}\n </Text>\n </Stack>\n </Stack>\n {showPeriodLine && periodLine}\n </Stack>\n )\n }\n\n return (\n <Stack sx={{ gap: 16 }}>\n <Box\n aria-label={\n buildDynamicCopy(\n copy.total_out_of_limit_aria,\n formatCurrency(spent, CURRENCY_FORMAT.cents),\n formatCurrency(limit, CURRENCY_FORMAT.cents),\n ) as string\n }\n data-tier={tier ?? 'none'}\n role=\"group\"\n >\n <StatusIndicator\n amount={\n <Stack sx={{ alignItems: 'baseline', flexDirection: 'row', gap: 4 }}>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(spent, CURRENCY_FORMAT.cents)}\n </Text>\n <Text color=\"text.secondary\" variant=\"body2\">\n / {formatCurrency(limit, CURRENCY_FORMAT.cents)}\n </Text>\n </Stack>\n }\n completeColor={color}\n icon={icon}\n label={\n <Text color=\"text.secondary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n }\n labelVariant=\"body2\"\n leftLabel={buildDynamicCopy(budgetsCopy.percent_spent, String(percent)) as string}\n percentComplete={Math.min(100, percent)}\n rightLabel={\n buildDynamicCopy(\n // Figma's \"$amount Left\"; $0.00 once over, as the Budgets drawer shows it.\n budgetsCopy.balance_left,\n formatCurrency(Math.max(0, limit - spent), CURRENCY_FORMAT.cents),\n ) as string\n }\n sx={{ p: 0 }}\n />\n </Box>\n {showPeriodLine && periodLine}\n </Stack>\n )\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAa,IAAA,CAAiB,EAC5B,aAAA,GACA,MAAA,GACA,UAAA,GACA,MAAA,GACA,OAAA,GACA,gBAAA,IAAiB,IACjB,OAAA,EAAA,MACwB;AACxB,QAAM,IAAU,EAAuB,GAAO,CAAK,GAC7C,IAAO,EAAoB,CAAO,GAClC,IAAQ,EAAU,CAAI,GACtB,IACJ,MAAa,SACX,gBAAA,EAAC,GAAD;AAAA,IAAO,UAAS;AAAA,IAAQ,UAAA,EAAK;AAAA,EAA6B,CAAA,IAE1D,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAiB,SAAQ;AAAA,IAEjC,UAAA,EACE,EAAK,kCACL,EAAK,8BACL,GACA,OAAO,CAAQ,CACjB;AAAA,EAEE,CAAA;AAGV,SAAI,KAAS,IAET,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,KAAK,GAAG;AAAA,IAArB,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAG;AAAA,MAAjE,UAAA,CACE,gBAAA,EAAC,GAAD,EAAA,UAAM,EAAU,CAAA,GAChB,gBAAA,EAAC,GAAD,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,SAAQ;AAAA,QAClC,UAAA,EAAY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Ae,KAAK,IAAI,GAAG,IAAQ,CAAK,GAAG,EAAgB,KAAK,CAClE;AAAA,QAEF,IAAI,EAAE,GAAG,EAAE;AAAA,MACZ,CAAA;AAAA,IACE,CAAA,GACJ,KAAkB,CACd;AAAA;AAEX"}
1
+ {"version":3,"file":"BudgetSummary.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport type { BudgetsCopy } from '../../../core/types/localization'\nimport type { BudgetDetailsCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport StatusIndicator from '../../components/ComponentBlocks/StatusIndicator'\n\nimport { calculateBudgetPercent, calculateBudgetTier, tierColor } from './layout'\n\ninterface BudgetSummaryProps {\n budgetsCopy: BudgetsCopy\n copy: BudgetDetailsCopy\n daysLeft?: number\n icon: ReactNode\n limit: number\n /** The days-left / previous-month line under the bar (off for Figma's Budget Details insights). */\n showPeriodLine?: boolean\n spent: number\n}\n\nexport const BudgetSummary = ({\n budgetsCopy,\n copy,\n daysLeft,\n icon,\n limit,\n showPeriodLine = true,\n spent,\n}: BudgetSummaryProps) => {\n const percent = calculateBudgetPercent(spent, limit)\n const tier = calculateBudgetTier(percent)\n const color = tierColor(tier)\n const periodLine =\n daysLeft === undefined ? (\n <Alert severity=\"info\">{copy.previous_month_notice}</Alert>\n ) : (\n <Text color=\"text.secondary\" variant=\"body2\">\n {\n buildPluralCopy(\n copy.days_left_until_end_of_month_one,\n copy.days_left_until_end_of_month,\n daysLeft,\n String(daysLeft),\n ) as string\n }\n </Text>\n )\n\n if (limit <= 0) {\n return (\n <Stack sx={{ gap: 16 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <Box>{icon}</Box>\n <Stack>\n <Text color=\"text.secondary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(spent, CURRENCY_FORMAT.cents)}\n </Text>\n </Stack>\n </Stack>\n {showPeriodLine && periodLine}\n </Stack>\n )\n }\n\n return (\n <Stack sx={{ gap: 16 }}>\n <Box\n aria-label={\n buildDynamicCopy(\n copy.total_out_of_limit_aria,\n formatCurrency(spent, CURRENCY_FORMAT.cents),\n formatCurrency(limit, CURRENCY_FORMAT.cents),\n ) as string\n }\n data-tier={tier ?? 'none'}\n role=\"group\"\n >\n <StatusIndicator\n amount={\n <Stack sx={{ alignItems: 'baseline', flexDirection: 'row', gap: 4 }}>\n <P bold={true} color=\"text.primary\" variant=\"h2\">\n {formatCurrency(spent, CURRENCY_FORMAT.cents)}\n </P>\n <Text color=\"text.secondary\" variant=\"body2\">\n / {formatCurrency(limit, CURRENCY_FORMAT.cents)}\n </Text>\n </Stack>\n }\n completeColor={color}\n icon={icon}\n label={\n <Text color=\"text.primary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n }\n labelVariant=\"body2\"\n leftLabel={buildDynamicCopy(budgetsCopy.percent_spent, String(percent)) as string}\n percentComplete={Math.min(100, percent)}\n rightLabel={\n buildDynamicCopy(\n // Figma's \"$amount Left\"; $0.00 once over, as the Budgets drawer shows it.\n budgetsCopy.balance_left,\n formatCurrency(Math.max(0, limit - spent), CURRENCY_FORMAT.cents),\n ) as string\n }\n sx={{ p: 0 }}\n />\n </Box>\n {showPeriodLine && periodLine}\n </Stack>\n )\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAa,IAAA,CAAiB,EAC5B,aAAA,GACA,MAAA,GACA,UAAA,GACA,MAAA,GACA,OAAA,GACA,gBAAA,IAAiB,IACjB,OAAA,EAAA,MACwB;AACxB,QAAM,IAAU,EAAuB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,QACE,gBAAA,EAAC,GAAD;AAAA,UAAO,IAAI;AAAA,YAAE,YAAY;AAAA,YAAY,eAAe;AAAA,YAAO,KAAK;AAAA,UAAE;AAAA,UAAlE,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,YAAG,MAAM;AAAA,YAAM,OAAM;AAAA,YAAe,SAAQ;AAAA,YACzC,UAAA,EAAe,GAAO,EAAgB,KAAK;AAAA,UAC3C,CAAA,GACH,gBAAA,EAAC,GAAD;AAAA,YAAM,OAAM;AAAA,YAAiB,SAAQ;AAAA,YAArC,UAAA,CAA6C,MACxC,EAAe,GAAO,EAAgB,KAAK,CAC1C;AAAA,UACD,CAAA,CAAA;AAAA;QAET,eAAe;AAAA,QACT,MAAA;AAAA,QACN,OACE,gBAAA,EAAC,GAAD;AAAA,UAAM,OAAM;AAAA,UAAe,SAAQ;AAAA,UAChC,UAAA,EAAY;AAAA,QACT,CAAA;AAAA,QAER,cAAa;AAAA,QACb,WAAW,EAAiB,EAAY,eAAe,OAAO,CAAO,CAAC;AAAA,QACtE,iBAAiB,KAAK,IAAI,KAAK,CAAO;AAAA,QACtC,YACE,EAEE,EAAY,cACZ,EAAe,KAAK,IAAI,GAAG,IAAQ,CAAK,GAAG,EAAgB,KAAK,CAClE;AAAA,QAEF,IAAI,EAAE,GAAG,EAAE;AAAA,MACZ,CAAA;AAAA,IACE,CAAA,GACJ,KAAkB,CACd;AAAA;AAEX"}
@@ -16,11 +16,11 @@ export interface BudgetFacts {
16
16
  export declare const resolveBudgetFacts: (beat: Beat) => BudgetFacts;
17
17
  type BudgetSubject = (beat: Beat, copy: GlobalCopy) => string | undefined;
18
18
  type ActiveAt = Beat['active_at'] | number | null | undefined;
19
- /** A beat's `active_at` (epoch seconds or ISO) as a date; undefined when absent or invalid. */
19
+ /** A beat's `active_at` (epoch seconds or ISO) as a date undefined when absent or invalid. */
20
20
  export declare const activeAtDate: (raw: ActiveAt) => Date | undefined;
21
21
  /** The beat's own `active_at`: on the beat, else on its envelope. */
22
22
  export declare const beatActiveAt: (beat: Beat) => ActiveAt;
23
- /** The `active_at` the card recorded on render; a sampled beat is re-read without it after a CTA. */
23
+ /** The `active_at` the card recorded on render a sampled beat is re-read without it after a CTA. */
24
24
  export declare const recordedActiveAtOf: (store: Pick<InsightsV2Store, "beatContext">, beat: Beat) => ActiveAt;
25
25
  /** The budget month's anchor: the recorded `active_at`, else the beat's, else now. */
26
26
  export declare const budgetMonthOf: (beat: Beat, recordedActiveAt?: ActiveAt, now?: Date) => Date;
@@ -30,7 +30,7 @@ export declare const budgetMonthRange: (beat: Beat, recordedActiveAt?: ActiveAt)
30
30
  start: Date;
31
31
  end: Date;
32
32
  };
33
- /** The budget month and category (own or top-level) or merchant; none without either, so no rows. */
33
+ /** The budget month and category (own or top-level) or merchant none without either, so no rows. */
34
34
  export declare const budgetTransactionFilter: (facts: BudgetFacts, dateRange: {
35
35
  start: Date;
36
36
  end: Date;
@@ -38,7 +38,7 @@ export declare const budgetTransactionFilter: (facts: BudgetFacts, dateRange: {
38
38
  export interface BudgetDetailsLayout {
39
39
  /** The "N days until the end of the month" / previous-month notice under the summary. */
40
40
  showPeriodLine: boolean;
41
- /** The subject of the drawer's "{subject} Budget" title; the card's subtitle never names it. */
41
+ /** The subject of the drawer's "{subject} Budget" title the card's subtitle never names it. */
42
42
  subject: BudgetSubject;
43
43
  }
44
44
  export declare const resolveBudgetDetailsLayout: (variant: string | null | undefined) => BudgetDetailsLayout;
@@ -2,12 +2,12 @@ import { buildDynamicCopy as _ } from "../../../core/utils/Localization.es.js";
2
2
  import { BEAT_ACTIVE_AT_KEY as m } from "../../../core/stores/InsightsV2Store.es.js";
3
3
  import { resolveVariantConfig as l } from "../../blocks/resolveVariantConfig.es.js";
4
4
  import { asNonEmptyText as u, asNumber as d } from "../../blocks/slotReaders.es.js";
5
- import { endOfMonth as n } from "date-fns/endOfMonth";
5
+ import { endOfMonth as o } from "date-fns/endOfMonth";
6
6
  import { startOfMonth as c } from "date-fns/startOfMonth";
7
7
  import { differenceInCalendarDays as v } from "date-fns/differenceInCalendarDays";
8
8
  var T = {
9
- LOW: "success.light",
10
- MEDIUM: "warning.light",
9
+ LOW: "success.main",
10
+ MEDIUM: "warning.main",
11
11
  HIGH: "warning.main",
12
12
  OFF_TRACK: "error.main"
13
13
  }, f = "success.main", M = (t, e) => Math.ceil((e ? t / e : 0) * 100), N = (t) => {
@@ -26,7 +26,7 @@ var T = {
26
26
  }, i = (t, e) => {
27
27
  const { categoryGuid: r } = y(t);
28
28
  return (r ? e.categories?.default_categories?.[r] : void 0)?.replace(/&amp;/g, "&");
29
- }, o = {
29
+ }, n = {
30
30
  CATEGORY_SPEND: "category_spend",
31
31
  CATEGORY_BUDGET: "category_budget",
32
32
  MERCHANT_BUDGET: "merchant_budget"
@@ -34,18 +34,18 @@ var T = {
34
34
  if (t == null || t === "") return;
35
35
  const e = new Date(typeof t == "number" ? t * 1e3 : t);
36
36
  return Number.isNaN(e.getTime()) ? void 0 : e;
37
- }, h = (t) => t.active_at ?? t.insights_payload?.active_at, U = (t, e) => t.beatContext[e.guid]?.[m], g = (t, e, r = /* @__PURE__ */ new Date()) => s(e) ?? s(h(t)) ?? r, F = (t, e = /* @__PURE__ */ new Date(), r) => {
37
+ }, E = (t) => t.active_at ?? t.insights_payload?.active_at, U = (t, e) => t.beatContext[e.guid]?.[m], g = (t, e, r = /* @__PURE__ */ new Date()) => s(e) ?? s(E(t)) ?? r, F = (t, e = /* @__PURE__ */ new Date(), r) => {
38
38
  const a = g(t, r, e);
39
- if (!(n(a) < c(e)))
40
- return v(n(e), e) + 1;
39
+ if (!(o(a) < c(e)))
40
+ return v(o(e), e) + 1;
41
41
  }, P = (t, e) => {
42
42
  const r = g(t, e);
43
43
  return {
44
44
  start: c(r),
45
- end: n(r)
45
+ end: o(r)
46
46
  };
47
- }, E = (t) => (e) => e.category_guid === t || e.top_level_category_guid === t, A = (t) => (e) => e.merchant_guid === t, j = (t, e) => {
48
- const r = t.categoryGuid ? E(t.categoryGuid) : t.merchantGuid ? A(t.merchantGuid) : void 0;
47
+ }, h = (t) => (e) => e.category_guid === t || e.top_level_category_guid === t, A = (t) => (e) => e.merchant_guid === t, j = (t, e) => {
48
+ const r = t.categoryGuid ? h(t.categoryGuid) : t.merchantGuid ? A(t.merchantGuid) : void 0;
49
49
  return r && {
50
50
  custom: r,
51
51
  dateRange: e
@@ -55,15 +55,15 @@ var T = {
55
55
  showPeriodLine: !0,
56
56
  subject: i
57
57
  },
58
- [o.CATEGORY_SPEND]: {
58
+ [n.CATEGORY_SPEND]: {
59
59
  showPeriodLine: !1,
60
60
  subject: i
61
61
  },
62
- [o.CATEGORY_BUDGET]: {
62
+ [n.CATEGORY_BUDGET]: {
63
63
  showPeriodLine: !1,
64
64
  subject: i
65
65
  },
66
- [o.MERCHANT_BUDGET]: {
66
+ [n.MERCHANT_BUDGET]: {
67
67
  showPeriodLine: !1,
68
68
  subject: i
69
69
  }
@@ -78,7 +78,7 @@ export {
78
78
  T as BUDGET_TIER_COLORS,
79
79
  f as DEFAULT_TIER_COLOR,
80
80
  s as activeAtDate,
81
- h as beatActiveAt,
81
+ E as beatActiveAt,
82
82
  g as budgetMonthOf,
83
83
  P as budgetMonthRange,
84
84
  j as budgetTransactionFilter,
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/layout.ts"],"sourcesContent":["import { differenceInCalendarDays } from 'date-fns/differenceInCalendarDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\n\nimport type { Beat, GlobalCopy, Transaction } from '../../../core'\nimport { BEAT_ACTIVE_AT_KEY, type InsightsV2Store } from '../../../core/stores/InsightsV2Store'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\n\nexport type BudgetTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'OFF_TRACK'\n\nexport const BUDGET_TIER_COLORS: Record<BudgetTier, string> = {\n LOW: 'success.light',\n MEDIUM: 'warning.light',\n HIGH: 'warning.main',\n OFF_TRACK: 'error.main',\n}\n\nexport const DEFAULT_TIER_COLOR = 'success.main'\n\nexport const calculateBudgetPercent = (total: number, limit: number) =>\n Math.ceil((limit ? total / limit : 0) * 100)\n\nexport const calculateBudgetTier = (percent: number): BudgetTier | undefined => {\n if (percent > 100) return 'OFF_TRACK'\n if (percent >= 75) return 'HIGH'\n if (percent >= 50) return 'MEDIUM'\n if (percent >= 25) return 'LOW'\n\n return undefined\n}\n\nexport const tierColor = (tier: BudgetTier | undefined) =>\n tier ? BUDGET_TIER_COLORS[tier] : DEFAULT_TIER_COLOR\n\nexport interface BudgetFacts {\n categoryGuid?: string\n merchantGuid?: string\n spent?: number\n budgeted?: number\n}\n\nexport const resolveBudgetFacts = (beat: Beat): BudgetFacts => {\n const payload = beat.insights_payload\n const data = (payload?.instance_slot?.data ?? payload?.instance_slot_data ?? {}) as Record<\n string,\n unknown\n >\n\n return {\n categoryGuid:\n asNonEmptyText(data.category_guid) ??\n payload?.primary_category_guid ??\n beat.primary_category_guid ??\n undefined,\n merchantGuid:\n asNonEmptyText(data.merchant_guid) ??\n payload?.primary_merchant_guid ??\n beat.primary_merchant_guid ??\n undefined,\n spent: asNumber(data.spent_amount),\n budgeted: asNumber(data.budgeted_amount),\n }\n}\n\ntype BudgetSubject = (beat: Beat, copy: GlobalCopy) => string | undefined\n\nconst categoryName: BudgetSubject = (beat, copy) => {\n const { categoryGuid } = resolveBudgetFacts(beat)\n const name = categoryGuid ? copy.categories?.default_categories?.[categoryGuid] : undefined\n\n return name?.replace(/&amp;/g, '&')\n}\n\n/** The CTA variants `budget_details_block` serves (ditto names one on each beat's CTA). */\nconst BUDGET_DETAILS_VARIANTS = {\n CATEGORY_SPEND: 'category_spend',\n CATEGORY_BUDGET: 'category_budget',\n MERCHANT_BUDGET: 'merchant_budget',\n} as const\n\ntype ActiveAt = Beat['active_at'] | number | null | undefined\n\n/** A beat's `active_at` (epoch seconds or ISO) as a date; undefined when absent or invalid. */\nexport const activeAtDate = (raw: ActiveAt): Date | undefined => {\n if (raw == null || raw === '') return undefined\n const at = new Date(typeof raw === 'number' ? raw * 1000 : raw)\n\n return Number.isNaN(at.getTime()) ? undefined : at\n}\n\n/** The beat's own `active_at`: on the beat, else on its envelope. */\nexport const beatActiveAt = (beat: Beat): ActiveAt =>\n beat.active_at ?? beat.insights_payload?.active_at\n\n/** The `active_at` the card recorded on render; a sampled beat is re-read without it after a CTA. */\nexport const recordedActiveAtOf = (\n store: Pick<InsightsV2Store, 'beatContext'>,\n beat: Beat,\n): ActiveAt => store.beatContext[beat.guid]?.[BEAT_ACTIVE_AT_KEY] as ActiveAt\n\n/** The budget month's anchor: the recorded `active_at`, else the beat's, else now. */\nexport const budgetMonthOf = (beat: Beat, recordedActiveAt?: ActiveAt, now = new Date()) =>\n activeAtDate(recordedActiveAt) ?? activeAtDate(beatActiveAt(beat)) ?? now\n\nexport const daysLeftInBudgetMonth = (\n beat: Beat,\n now = new Date(),\n recordedActiveAt?: ActiveAt,\n) => {\n const activeAt = budgetMonthOf(beat, recordedActiveAt, now)\n if (endOfMonth(activeAt) < startOfMonth(now)) return undefined\n\n return differenceInCalendarDays(endOfMonth(now), now) + 1\n}\n\n/** The month a budget drawer shows (see budgetMonthOf). */\nexport const budgetMonthRange = (beat: Beat, recordedActiveAt?: ActiveAt) => {\n const month = budgetMonthOf(beat, recordedActiveAt)\n\n return { start: startOfMonth(month), end: endOfMonth(month) }\n}\n\nconst inCategory = (categoryGuid: string) => (transaction: Transaction) =>\n transaction.category_guid === categoryGuid || transaction.top_level_category_guid === categoryGuid\n\nconst atMerchant = (merchantGuid: string) => (transaction: Transaction) =>\n transaction.merchant_guid === merchantGuid\n\n/** The budget month and category (own or top-level) or merchant; none without either, so no rows. */\nexport const budgetTransactionFilter = (\n facts: BudgetFacts,\n dateRange: { start: Date; end: Date },\n): TransactionFilter | undefined => {\n const custom = facts.categoryGuid\n ? inCategory(facts.categoryGuid)\n : facts.merchantGuid\n ? atMerchant(facts.merchantGuid)\n : undefined\n\n return custom && { custom, dateRange }\n}\n\nexport interface BudgetDetailsLayout {\n /** The \"N days until the end of the month\" / previous-month notice under the summary. */\n showPeriodLine: boolean\n /** The subject of the drawer's \"{subject} Budget\" title; the card's subtitle never names it. */\n subject: BudgetSubject\n}\n\n// Figma's Budget Details for these three insights has no period line; any other caller keeps it.\n// merchant_budget will name the merchant once Merchant Budget moves to Insights 2.0.\nconst LAYOUT: Record<string, BudgetDetailsLayout> = {\n default: { showPeriodLine: true, subject: categoryName },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: { showPeriodLine: false, subject: categoryName },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: { showPeriodLine: false, subject: categoryName },\n [BUDGET_DETAILS_VARIANTS.MERCHANT_BUDGET]: { showPeriodLine: false, subject: categoryName },\n}\n\nexport const resolveBudgetDetailsLayout = (variant: string | null | undefined) =>\n resolveVariantConfig(LAYOUT, variant, 'default', 'BudgetDetailsBlock')\n\n/** \"{subject} Budget\" when the variant names a subject, else the card's title. */\nexport const getBudgetDetailsDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const subject = beat && resolveBudgetDetailsLayout(variant).subject(beat, copy)\n if (subject && copy.budgets?.details_type_title) {\n return buildDynamicCopy(copy.budgets.details_type_title, subject) as string\n }\n\n return beat?.insights_payload?.title || copy.budgets?.details_title || ''\n}\n\n/** A budget amount the dialogs accept: a finite number above zero. */\nexport const isPositiveAmount = (value: string): boolean => {\n const amount = Number(value)\n return value.trim() !== '' && Number.isFinite(amount) && amount > 0\n}\n"],"mappings":";;;;;;;AAaA,IAAa,IAAiD;AAAA,EAC5D,KAAK;AAAA,EACL,QAAQ;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ACX,GACA,GACA,MACW;AACX,QAAM,IAAU,KAAQ,EAA2B,CAAO,EAAE,QAAQ,GAAM,CAAI;AAC9E,SAAI,KAAW,EAAK,SAAS,qBACpB,EAAiB,EAAK,QAAQ,oBAAoB,CAAO,IAG3D,GAAM,kBAAkB,SAAS,EAAK,SAAS,iBAAiB;AACzE,GAGa,IAAA,CAAoB,MAA2B;AAC1D,QAAM,IAAS,OAAO,CAAK;AAC3B,SAAO,EAAM,KAAK,MAAM,MAAM,OAAO,SAAS,CAAM,KAAK,IAAS;AACpE"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/layout.ts"],"sourcesContent":["import { differenceInCalendarDays } from 'date-fns/differenceInCalendarDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\n\nimport type { Beat, GlobalCopy, Transaction } from '../../../core'\nimport { BEAT_ACTIVE_AT_KEY, type InsightsV2Store } from '../../../core/stores/InsightsV2Store'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\n\nexport type BudgetTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'OFF_TRACK'\n\nexport const BUDGET_TIER_COLORS: Record<BudgetTier, string> = {\n LOW: 'success.main',\n MEDIUM: 'warning.main',\n HIGH: 'warning.main',\n OFF_TRACK: 'error.main',\n}\n\nexport const DEFAULT_TIER_COLOR = 'success.main'\n\nexport const calculateBudgetPercent = (total: number, limit: number) =>\n Math.ceil((limit ? total / limit : 0) * 100)\n\nexport const calculateBudgetTier = (percent: number): BudgetTier | undefined => {\n if (percent > 100) return 'OFF_TRACK'\n if (percent >= 75) return 'HIGH'\n if (percent >= 50) return 'MEDIUM'\n if (percent >= 25) return 'LOW'\n\n return undefined\n}\n\nexport const tierColor = (tier: BudgetTier | undefined) =>\n tier ? BUDGET_TIER_COLORS[tier] : DEFAULT_TIER_COLOR\n\nexport interface BudgetFacts {\n categoryGuid?: string\n merchantGuid?: string\n spent?: number\n budgeted?: number\n}\n\nexport const resolveBudgetFacts = (beat: Beat): BudgetFacts => {\n const payload = beat.insights_payload\n const data = (payload?.instance_slot?.data ?? payload?.instance_slot_data ?? {}) as Record<\n string,\n unknown\n >\n\n return {\n categoryGuid:\n asNonEmptyText(data.category_guid) ??\n payload?.primary_category_guid ??\n beat.primary_category_guid ??\n undefined,\n merchantGuid:\n asNonEmptyText(data.merchant_guid) ??\n payload?.primary_merchant_guid ??\n beat.primary_merchant_guid ??\n undefined,\n spent: asNumber(data.spent_amount),\n budgeted: asNumber(data.budgeted_amount),\n }\n}\n\ntype BudgetSubject = (beat: Beat, copy: GlobalCopy) => string | undefined\n\nconst categoryName: BudgetSubject = (beat, copy) => {\n const { categoryGuid } = resolveBudgetFacts(beat)\n const name = categoryGuid ? copy.categories?.default_categories?.[categoryGuid] : undefined\n\n return name?.replace(/&amp;/g, '&')\n}\n\n/** The CTA variants `budget_details_block` serves (ditto names one on each beat's CTA). */\nconst BUDGET_DETAILS_VARIANTS = {\n CATEGORY_SPEND: 'category_spend',\n CATEGORY_BUDGET: 'category_budget',\n MERCHANT_BUDGET: 'merchant_budget',\n} as const\n\ntype ActiveAt = Beat['active_at'] | number | null | undefined\n\n/** A beat's `active_at` (epoch seconds or ISO) as a date undefined when absent or invalid. */\nexport const activeAtDate = (raw: ActiveAt): Date | undefined => {\n if (raw == null || raw === '') return undefined\n const at = new Date(typeof raw === 'number' ? raw * 1000 : raw)\n\n return Number.isNaN(at.getTime()) ? undefined : at\n}\n\n/** The beat's own `active_at`: on the beat, else on its envelope. */\nexport const beatActiveAt = (beat: Beat): ActiveAt =>\n beat.active_at ?? beat.insights_payload?.active_at\n\n/** The `active_at` the card recorded on render a sampled beat is re-read without it after a CTA. */\nexport const recordedActiveAtOf = (\n store: Pick<InsightsV2Store, 'beatContext'>,\n beat: Beat,\n): ActiveAt => store.beatContext[beat.guid]?.[BEAT_ACTIVE_AT_KEY] as ActiveAt\n\n/** The budget month's anchor: the recorded `active_at`, else the beat's, else now. */\nexport const budgetMonthOf = (beat: Beat, recordedActiveAt?: ActiveAt, now = new Date()) =>\n activeAtDate(recordedActiveAt) ?? activeAtDate(beatActiveAt(beat)) ?? now\n\nexport const daysLeftInBudgetMonth = (\n beat: Beat,\n now = new Date(),\n recordedActiveAt?: ActiveAt,\n) => {\n const activeAt = budgetMonthOf(beat, recordedActiveAt, now)\n if (endOfMonth(activeAt) < startOfMonth(now)) return undefined\n\n return differenceInCalendarDays(endOfMonth(now), now) + 1\n}\n\n/** The month a budget drawer shows (see budgetMonthOf). */\nexport const budgetMonthRange = (beat: Beat, recordedActiveAt?: ActiveAt) => {\n const month = budgetMonthOf(beat, recordedActiveAt)\n\n return { start: startOfMonth(month), end: endOfMonth(month) }\n}\n\nconst inCategory = (categoryGuid: string) => (transaction: Transaction) =>\n transaction.category_guid === categoryGuid || transaction.top_level_category_guid === categoryGuid\n\nconst atMerchant = (merchantGuid: string) => (transaction: Transaction) =>\n transaction.merchant_guid === merchantGuid\n\n/** The budget month and category (own or top-level) or merchant none without either, so no rows. */\nexport const budgetTransactionFilter = (\n facts: BudgetFacts,\n dateRange: { start: Date; end: Date },\n): TransactionFilter | undefined => {\n const custom = facts.categoryGuid\n ? inCategory(facts.categoryGuid)\n : facts.merchantGuid\n ? atMerchant(facts.merchantGuid)\n : undefined\n\n return custom && { custom, dateRange }\n}\n\nexport interface BudgetDetailsLayout {\n /** The \"N days until the end of the month\" / previous-month notice under the summary. */\n showPeriodLine: boolean\n /** The subject of the drawer's \"{subject} Budget\" title the card's subtitle never names it. */\n subject: BudgetSubject\n}\n\n// Figma's Budget Details for these three insights has no period line any other caller keeps it.\n// merchant_budget will name the merchant once Merchant Budget moves to Insights 2.0.\nconst LAYOUT: Record<string, BudgetDetailsLayout> = {\n default: { showPeriodLine: true, subject: categoryName },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: {\n showPeriodLine: false,\n subject: categoryName,\n },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: {\n showPeriodLine: false,\n subject: categoryName,\n },\n [BUDGET_DETAILS_VARIANTS.MERCHANT_BUDGET]: {\n showPeriodLine: false,\n subject: categoryName,\n },\n}\n\nexport const resolveBudgetDetailsLayout = (variant: string | null | undefined) =>\n resolveVariantConfig(LAYOUT, variant, 'default', 'BudgetDetailsBlock')\n\n/** \"{subject} Budget\" when the variant names a subject, else the card's title. */\nexport const getBudgetDetailsDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const subject = beat && resolveBudgetDetailsLayout(variant).subject(beat, copy)\n if (subject && copy.budgets?.details_type_title) {\n return buildDynamicCopy(copy.budgets.details_type_title, subject) as string\n }\n\n return beat?.insights_payload?.title || copy.budgets?.details_title || ''\n}\n\n/** A budget amount the dialogs accept: a finite number above zero. */\nexport const isPositiveAmount = (value: string): boolean => {\n const amount = Number(value)\n return value.trim() !== '' && Number.isFinite(amount) && amount > 0\n}\n"],"mappings":";;;;;;;AAaA,IAAa,IAAiD;AAAA,EAC5D,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AACb,GAEa,IAAqB,gBAErB,IAAA,CAA0B,GAAe,MACpD,KAAK,MAAM,IAAQ,IAAQ,IAAQ,KAAK,GAAG,GAEhC,IAAA,CAAuB,MAA4C;AAC9E,MAAI,IAAU,IAAK,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAG5B,GAEa,IAAA,CAAa,MACxB,IAAO,EAAmB,CAAA,IAAQ,GASvB,IAAA,CAAsB,MAA4B;AAC7D,QAAM,IAAU,EAAK,kBACf,IAAQ,GAAS,eAAe,QAAQ,GAAS,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