@mx-cartographer/experiences 9.7.28 → 9.7.30

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 (49) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/core/api/UserApi.es.js +8 -8
  3. package/dist/core/api/UserApi.es.js.map +1 -1
  4. package/dist/core/stores/GlobalStore.d.ts +4 -2
  5. package/dist/core/stores/GlobalStore.es.js +34 -34
  6. package/dist/core/stores/GlobalStore.es.js.map +1 -1
  7. package/dist/core/types/localization/InsightsFeedCopy.d.ts +25 -0
  8. package/dist/core/types/localization/index.d.ts +1 -1
  9. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.d.ts +11 -0
  10. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +132 -0
  11. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -0
  12. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.d.ts +12 -0
  13. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +124 -0
  14. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -0
  15. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/index.d.ts +1 -0
  16. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/layout.d.ts +26 -0
  17. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/layout.es.js +64 -0
  18. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/layout.es.js.map +1 -0
  19. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/payoff.d.ts +8 -0
  20. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/payoff.es.js +26 -0
  21. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/payoff.es.js.map +1 -0
  22. package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +12 -0
  23. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +12 -0
  24. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
  25. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/EmergencySavingsAccountPicker.d.ts +15 -0
  26. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/EmergencySavingsAccountPicker.es.js +30 -0
  27. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/EmergencySavingsAccountPicker.es.js.map +1 -0
  28. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.d.ts +1 -1
  29. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +32 -11
  30. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js.map +1 -1
  31. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.d.ts +10 -7
  32. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.es.js +17 -10
  33. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.es.js.map +1 -1
  34. package/dist/insights-v2/components/CtaStatus.d.ts +19 -0
  35. package/dist/insights-v2/components/CtaStatus.es.js +67 -0
  36. package/dist/insights-v2/components/CtaStatus.es.js.map +1 -0
  37. package/dist/insights-v2/ctaActions/ctaConfig.es.js +21 -6
  38. package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -1
  39. package/dist/insights-v2/ctaActions/ctaPostMessages.es.js +7 -7
  40. package/dist/insights-v2/ctaActions/ctaPostMessages.es.js.map +1 -1
  41. package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -1
  42. package/dist/insights-v2/ctaActions/types.d.ts +1 -1
  43. package/dist/insights-v2/index.es.js +30 -30
  44. package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -0
  45. package/dist/insights-v2/mappings/actionBlocksKey.es.js +2 -1
  46. package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
  47. package/dist/insights-v2/mappings/blocks.es.js +65 -59
  48. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  49. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## [9.7.30] - 10-22-2026
2
+
3
+ - **ADDED** - `payoff_calculator_block` action block: the credit card payoff calculator drawer behind Monthly Credit Card Interest Summary's "Learn how to save", ported from pulse. Prefills the beat account's balance, interest rate and minimum payment, validates the inputs and compares the payoff at that payment, $10 more and $20 more, with a failure state. Copy under the new `insights_feed.payoff_calculator` namespace; fixture, stories, tests and `docs/action-blocks/payoff-calculator-block.md` (MEW2-3357)
4
+
5
+ ## [9.7.29] - 10-22-2026
6
+
7
+ - **ADDED** - Designate Emergency Savings Account on Insights 2.0. `ctaConfig` gains the two backend-named actions: `select_savings_account` ("Save") designates the account picked in the card through `updateUserInsightProfile`, stays disabled until a pick is made, refreshes the beat and fires `EMERGENCY_SAVINGS_ACCT_SAVED`; `open_savings_account` ("Open a Savings Account") fires `EMERGENCY_SAVINGS_ACCT_CREATED` while `ctaPostMessages.DesignateEmergencySavingsAccount` sends `beat/cta` op_1 — now keyed on the CTA's `action_key` (`open_savings_account`) instead of re-deriving pulse's data rule (no designation, no savings accounts), so it holds on every widget. The analytics catalogue gains `EMERGENCY_SAVINGS_ACCT_SELECTED` / `_SAVED` / `_CREATED` with pulse's strings (WEC-1859)
8
+ - **ADDED** - `CtaStatus`, a shared component for an "after the press" status bar (label, tone, filled icon, optional inline action such as Undo; `role="status"`, only the inline action is a button). Designate Emergency Savings Account's saved state draws its "Account Saved!" (`instance_slot.data.saved_label`) with it in the card body, under the illustration, per the updated Figma Saved state (WEC-1859)
9
+ - **ADDED** - `svg_image_block` layout variants `savings_account_picker` (the emergency-savings illustration with the account picker: options from `accountStore.savingsAccounts`, labels and pre-selection from `instance_slot.data`, the pick written to the beat context with the Selected event and no API call) and `savings_account_saved` (the illustration with the slot's `saved_label` as a `CtaStatus` under it, no picker; full card only, nothing when the label is missing) — the card the sampled beat refreshes into after Save, whose empty `primary_cta.label` renders no button (WEC-1859)
10
+ - **CHANGED** - `svg_image_block`'s emergency-savings variant is keyed `savings`, the name ditto sends (was `Savings`, which never matched). An unknown variant now renders nothing instead of throwing (WEC-1859)
11
+ - **FIXED** - `UserApi.updateUserInsightProfile` sends the profile fields flat, as pulse does. firefly's `PUT user_insight_profile` reads each field at the top level of the body and drops nils, so the `{ user_insight_profile: ... }` body it sent reached firefly empty and the upsert saved nothing: Designate Emergency Savings Account's "Save" and the safety-net save in `AmountInputModalBlock` silently kept the old profile. The MSW handler takes the flat body too (WEC-1859)
12
+ - **ADDED** - `GlobalStore.loadData` accepts `userInsightProfile` and seeds `UserStore.setUserInsightProfile`, so the host (pulse) hands in the profile it loads; experiences never fetches it. `select_savings_account` PUTs this seeded profile (WEC-1859)
13
+
1
14
  ## [9.7.28] - 10-21-2026
2
15
 
3
16
  - **ADDED** - `goals_block` component block (`status` variant) for the Monthly Emergency Fund Review beat. Renders the new `GoalProgressCard` (progress line with an optional status pill, progress bar and icon-tile fact rows) from `instance_slot.data`, with row copy from the new `insights_feed.goals_block` namespace. Mock payloads, fixtures, stories and tests (WEC-1302)
@@ -1,17 +1,17 @@
1
1
  import { ApiEndpoints as s } from "../constants/ApiEndpoints.es.js";
2
2
  import { Fetch as r } from "../utils/Fetch.es.js";
3
- var h = class {
3
+ var i = class {
4
4
  fetchInstance;
5
- constructor(e, t, n) {
6
- this.fetchInstance = new r(e, t, void 0, n);
5
+ constructor(t, e, n) {
6
+ this.fetchInstance = new r(t, e, void 0, n);
7
7
  }
8
- getUserFeatures = async () => this.fetchInstance.get(s.USER_FEATURES).then((e) => e.user_features);
9
- updateUser = async (e) => this.fetchInstance.put(s.USER, e).then((t) => t.user);
10
- updateUserProfile = async (e) => this.fetchInstance.put(`${s.USER_PROFILES}/${e.guid}`, e).then((t) => t.user_profile);
11
- updateUserInsightProfile = async (e) => this.fetchInstance.put(s.USER_INSIGHT_PROFILE, { user_insight_profile: e }).then((t) => t.user_insight_profile);
8
+ getUserFeatures = async () => this.fetchInstance.get(s.USER_FEATURES).then((t) => t.user_features);
9
+ updateUser = async (t) => this.fetchInstance.put(s.USER, t).then((e) => e.user);
10
+ updateUserProfile = async (t) => this.fetchInstance.put(`${s.USER_PROFILES}/${t.guid}`, t).then((e) => e.user_profile);
11
+ updateUserInsightProfile = async (t) => this.fetchInstance.put(s.USER_INSIGHT_PROFILE, t).then((e) => e.user_insight_profile);
12
12
  };
13
13
  export {
14
- h as UserApi
14
+ i as UserApi
15
15
  };
16
16
 
17
17
  //# sourceMappingURL=UserApi.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserApi.es.js","names":[],"sources":["../../../src/core/api/UserApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport type { GlobalErrorHandler, User, UserInsightProfile, UserProfile } from '..'\n\nexport class UserApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n getUserFeatures = async () => {\n return this.fetchInstance.get(ApiEndpoints.USER_FEATURES).then((data) => data.user_features)\n }\n\n updateUser = async (user: User) => {\n return this.fetchInstance.put(ApiEndpoints.USER, user).then((data) => data.user)\n }\n\n updateUserProfile = async (userProfile: UserProfile) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.USER_PROFILES}/${userProfile.guid}`, userProfile)\n .then((data) => data.user_profile)\n }\n\n // The endpoint is singular per user, so no guid in the path (mirrors pulse FireflyAPI).\n updateUserInsightProfile = async (\n profile: Partial<UserInsightProfile>,\n ): Promise<UserInsightProfile> => {\n return this.fetchInstance\n .put(ApiEndpoints.USER_INSIGHT_PROFILE, { user_insight_profile: profile })\n .then((data) => data.user_insight_profile)\n }\n}\n"],"mappings":";;AAIA,IAAa,IAAb,MAAqB;AAAA,EACnB;AAAA,EAEA,YAAY,GAAkB,GAAe,GAA8B;AACzE,SAAK,gBAAgB,IAAI,EAAM,GAAU,GAAO,QAAW,CAAO;AAAA,EACpE;AAAA,EAEA,kBAAkB,YACT,KAAK,cAAc,IAAI,EAAa,aAAa,EAAE,KAAA,CAAM,MAAS,EAAK,aAAa;AAAA,EAG7F,aAAa,OAAO,MACX,KAAK,cAAc,IAAI,EAAa,MAAM,CAAI,EAAE,KAAA,CAAM,MAAS,EAAK,IAAI;AAAA,EAGjF,oBAAoB,OAAO,MAClB,KAAK,cACT,IAAI,GAAG,EAAa,aAAA,IAAiB,EAAY,IAAA,IAAQ,CAAW,EACpE,KAAA,CAAM,MAAS,EAAK,YAAY;AAAA,EAIrC,2BAA2B,OACzB,MAEO,KAAK,cACT,IAAI,EAAa,sBAAsB,EAAE,sBAAsB,EAAQ,CAAC,EACxE,KAAA,CAAM,MAAS,EAAK,oBAAoB;AAE/C"}
1
+ {"version":3,"file":"UserApi.es.js","names":[],"sources":["../../../src/core/api/UserApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport type { GlobalErrorHandler, User, UserInsightProfile, UserProfile } from '..'\n\nexport class UserApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n getUserFeatures = async () => {\n return this.fetchInstance.get(ApiEndpoints.USER_FEATURES).then((data) => data.user_features)\n }\n\n updateUser = async (user: User) => {\n return this.fetchInstance.put(ApiEndpoints.USER, user).then((data) => data.user)\n }\n\n updateUserProfile = async (userProfile: UserProfile) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.USER_PROFILES}/${userProfile.guid}`, userProfile)\n .then((data) => data.user_profile)\n }\n\n // The endpoint is singular per user, so no guid in the path (mirrors pulse FireflyAPI).\n updateUserInsightProfile = async (\n profile: Partial<UserInsightProfile>,\n ): Promise<UserInsightProfile> => {\n return (\n this.fetchInstance\n // Flat, as pulse sends it: firefly reads each field at the top level of the body and drops\n // nils, so a wrapped body would reach it empty and the upsert would write nothing.\n .put(ApiEndpoints.USER_INSIGHT_PROFILE, profile)\n .then((data) => data.user_insight_profile)\n )\n }\n}\n"],"mappings":";;AAIA,IAAa,IAAb,MAAqB;AAAA,EACnB;AAAA,EAEA,YAAY,GAAkB,GAAe,GAA8B;AACzE,SAAK,gBAAgB,IAAI,EAAM,GAAU,GAAO,QAAW,CAAO;AAAA,EACpE;AAAA,EAEA,kBAAkB,YACT,KAAK,cAAc,IAAI,EAAa,aAAa,EAAE,KAAA,CAAM,MAAS,EAAK,aAAa;AAAA,EAG7F,aAAa,OAAO,MACX,KAAK,cAAc,IAAI,EAAa,MAAM,CAAI,EAAE,KAAA,CAAM,MAAS,EAAK,IAAI;AAAA,EAGjF,oBAAoB,OAAO,MAClB,KAAK,cACT,IAAI,GAAG,EAAa,aAAA,IAAiB,EAAY,IAAA,IAAQ,CAAW,EACpE,KAAA,CAAM,MAAS,EAAK,YAAY;AAAA,EAIrC,2BAA2B,OACzB,MAGE,KAAK,cAGF,IAAI,EAAa,sBAAsB,CAAO,EAC9C,KAAA,CAAM,MAAS,EAAK,oBAAoB;AAGjD"}
@@ -1,5 +1,5 @@
1
1
  import { AccountStore, AgreementStore, AnalyticsStore, AppDataStore, BeatStore, BudgetsStore, CashflowStore, CategoryStore, ConnectStore, DebtsStore, FinstrongStore, GlobalCopyStore, GlobalUiStore, GoalStore, HelpStore, HoldingStore, InsightsV2Store, MerchantStore, NetWorthStore, NotificationStore, RecurringTransactionsStore, SettingsStore, TransactionStore, TrendsStore, UserStore } from '../stores';
2
- import { Account, Category, Institution, Member, AppConfig, AppData, Beat, GlobalCaptureException, GlobalErrorHandler, MerchantBudget, Tag, Tagging, Transaction, TransactionRule, UserFeature } from '../types';
2
+ import { Account, Category, Institution, Member, AppConfig, AppData, Beat, GlobalCaptureException, GlobalErrorHandler, MerchantBudget, Tag, Tagging, Transaction, TransactionRule, UserFeature, UserInsightProfile } from '../types';
3
3
  interface LoadDataProps {
4
4
  accounts?: Account[];
5
5
  appData?: AppData;
@@ -13,6 +13,8 @@ interface LoadDataProps {
13
13
  transactionRules?: TransactionRule[];
14
14
  transactions?: Transaction[];
15
15
  userFeatures?: UserFeature[];
16
+ /** Loaded by the host (pulse); experiences never fetches it. Read and PUT by insight CTAs. */
17
+ userInsightProfile?: UserInsightProfile;
16
18
  }
17
19
  type OnStoreUpdate = (update: ObservedUpdate) => void;
18
20
  export type ObservedUpdate = {
@@ -61,6 +63,6 @@ export declare class GlobalStore {
61
63
  captureException: (error: unknown, context?: Record<string, string>) => void;
62
64
  emitUpdate: (change: ObservedUpdate) => void;
63
65
  loadConfigData: () => Promise<void>;
64
- loadData: ({ accounts, appData, associatedBeats, categories, institutions, transactionRules, transactions, userFeatures, merchantBudgets, }?: LoadDataProps) => Promise<void>;
66
+ loadData: ({ accounts, appData, associatedBeats, categories, institutions, transactionRules, transactions, userFeatures, merchantBudgets, userInsightProfile, }?: LoadDataProps) => Promise<void>;
65
67
  }
66
68
  export {};
@@ -1,32 +1,32 @@
1
- import { AccountStore as p } from "./AccountStore.es.js";
2
- import { AgreementStore as m } from "./AgreementStore.es.js";
3
- import { AppDataStore as c } from "./AppDataStore.es.js";
4
- import { AnalyticsStore as f } from "./AnalyticsStore.es.js";
5
- import { BeatStore as l } from "./BeatStore.es.js";
6
- import { BudgetsStore as g } from "./BudgetsStore.es.js";
7
- import { CashflowStore as w } from "./CashflowStore.es.js";
8
- import { CategoryStore as d } from "./CategoryStore.es.js";
9
- import { ConnectStore as u } from "./ConnectStore.es.js";
10
- import { DebtsStore as b } from "./DebtsStore.es.js";
11
- import { FinstrongStore as y } from "./FinstrongStore.es.js";
12
- import { DefaultAppConfig as h } from "../constants/DefaultConfig.es.js";
13
- import { GlobalUiStore as C } from "./GlobalUiStore.es.js";
14
- import { GlobalCopyStore as U } from "./GlobalCopyStore.es.js";
15
- import { GoalStore as A } from "./GoalStore.es.js";
16
- import { HelpStore as D } from "./HelpStore.es.js";
17
- import { HoldingStore as T } from "./HoldingStore.es.js";
18
- import { InsightsV2Store as E } from "./InsightsV2Store.es.js";
19
- import { MerchantStore as x } from "./MerchantStore.es.js";
20
- import { NetWorthStore as k } from "./NetWorthStore.es.js";
21
- import { NotificationStore as G } from "./NotificationStore.es.js";
22
- import { RecurringTransactionsStore as I } from "./RecurringTransactionsStore.es.js";
23
- import { SettingsStore as M } from "./SettingsStore.es.js";
24
- import { TransactionStore as V } from "./TransactionStore.es.js";
25
- import { TrendsStore as W } from "./TrendsStore.es.js";
26
- import { UserStore as v } from "./UserStore.es.js";
27
- import { autorun as z, makeAutoObservable as B } from "mobx";
28
- var pt = class {
29
- appConfig = h;
1
+ import { AccountStore as m } from "./AccountStore.es.js";
2
+ import { AgreementStore as c } from "./AgreementStore.es.js";
3
+ import { AppDataStore as f } from "./AppDataStore.es.js";
4
+ import { AnalyticsStore as l } from "./AnalyticsStore.es.js";
5
+ import { BeatStore as g } from "./BeatStore.es.js";
6
+ import { BudgetsStore as w } from "./BudgetsStore.es.js";
7
+ import { CashflowStore as d } from "./CashflowStore.es.js";
8
+ import { CategoryStore as u } from "./CategoryStore.es.js";
9
+ import { ConnectStore as b } from "./ConnectStore.es.js";
10
+ import { DebtsStore as y } from "./DebtsStore.es.js";
11
+ import { FinstrongStore as C } from "./FinstrongStore.es.js";
12
+ import { DefaultAppConfig as p } from "../constants/DefaultConfig.es.js";
13
+ import { GlobalUiStore as U } from "./GlobalUiStore.es.js";
14
+ import { GlobalCopyStore as A } from "./GlobalCopyStore.es.js";
15
+ import { GoalStore as D } from "./GoalStore.es.js";
16
+ import { HelpStore as T } from "./HelpStore.es.js";
17
+ import { HoldingStore as E } from "./HoldingStore.es.js";
18
+ import { InsightsV2Store as x } from "./InsightsV2Store.es.js";
19
+ import { MerchantStore as k } from "./MerchantStore.es.js";
20
+ import { NetWorthStore as G } from "./NetWorthStore.es.js";
21
+ import { NotificationStore as I } from "./NotificationStore.es.js";
22
+ import { RecurringTransactionsStore as M } from "./RecurringTransactionsStore.es.js";
23
+ import { SettingsStore as V } from "./SettingsStore.es.js";
24
+ import { TransactionStore as W } from "./TransactionStore.es.js";
25
+ import { TrendsStore as v } from "./TrendsStore.es.js";
26
+ import { UserStore as z } from "./UserStore.es.js";
27
+ import { autorun as B, makeAutoObservable as H } from "mobx";
28
+ var mt = class {
29
+ appConfig = p;
30
30
  endpoint = "/";
31
31
  sessionToken = "";
32
32
  onCaptureException;
@@ -57,8 +57,8 @@ var pt = class {
57
57
  userStore;
58
58
  globalUiStore;
59
59
  insightsV2Store;
60
- constructor(t = h, o = "/", e, r, i) {
61
- this.appConfig = t, this.endpoint = o, this.sessionToken = t.options.session_token ?? "", this.onCaptureException = i, this.onError = e, this.onStoreUpdate = r, this.accountStore = new p(this), this.agreementStore = new m(this), this.appDataStore = new c(this), this.analyticsStore = new f(this), this.beatStore = new l(this), this.budgetsStore = new g(this), this.cashflowStore = new w(this), this.categoryStore = new d(this), this.connectStore = new u(this), this.copyStore = new U(this), this.debtsStore = new b(this), this.finstrongStore = new y(this), this.goalStore = new A(this), this.helpStore = new D(this), this.holdingStore = new T(this), this.merchantStore = new x(this), this.netWorthStore = new k(this), this.notificationStore = new G(this), this.recurringTransactionsStore = new I(this), this.settingsStore = new M(this), this.transactionStore = new V(this), this.trendsStore = new W(this), this.userStore = new v(this), this.globalUiStore = new C(this), this.insightsV2Store = new E(this), B(this), z(() => {
60
+ constructor(t = p, o = "/", e, r, i) {
61
+ this.appConfig = t, this.endpoint = o, this.sessionToken = t.options.session_token ?? "", this.onCaptureException = i, this.onError = e, this.onStoreUpdate = r, this.accountStore = new m(this), this.agreementStore = new c(this), this.appDataStore = new f(this), this.analyticsStore = new l(this), this.beatStore = new g(this), this.budgetsStore = new w(this), this.cashflowStore = new d(this), this.categoryStore = new u(this), this.connectStore = new b(this), this.copyStore = new A(this), this.debtsStore = new y(this), this.finstrongStore = new C(this), this.goalStore = new D(this), this.helpStore = new T(this), this.holdingStore = new E(this), this.merchantStore = new k(this), this.netWorthStore = new G(this), this.notificationStore = new I(this), this.recurringTransactionsStore = new M(this), this.settingsStore = new V(this), this.transactionStore = new W(this), this.trendsStore = new v(this), this.userStore = new z(this), this.globalUiStore = new U(this), this.insightsV2Store = new x(this), H(this), B(() => {
62
62
  const { transactions: s } = this.transactionStore;
63
63
  this.emitUpdate({ transactions: s });
64
64
  });
@@ -84,12 +84,12 @@ var pt = class {
84
84
  this.userStore.loadUserFeatures()
85
85
  ]);
86
86
  };
87
- loadData = async ({ accounts: t, appData: o, associatedBeats: e, categories: r, institutions: i, transactionRules: s, transactions: a, userFeatures: n, merchantBudgets: S } = {}) => {
88
- (!o || !n) && await this.loadConfigData(), o && this.appDataStore.setAppData(o), n && this.userStore.setUserFeatures(n), t && (await this.accountStore.loadMembers(), i && this.accountStore.setInstitutions(i), this.accountStore.setAccounts(t)), e && this.transactionStore.setAssociatedBeats(e), r && this.categoryStore.setCategories(r), a && this.transactionStore.setTransactions(a), s && this.transactionStore.setTransactionRules(s), S && this.budgetsStore.setMerchantBudgets(S);
87
+ loadData = async ({ accounts: t, appData: o, associatedBeats: e, categories: r, institutions: i, transactionRules: s, transactions: a, userFeatures: n, merchantBudgets: S, userInsightProfile: h } = {}) => {
88
+ (!o || !n) && await this.loadConfigData(), o && this.appDataStore.setAppData(o), n && this.userStore.setUserFeatures(n), t && (await this.accountStore.loadMembers(), i && this.accountStore.setInstitutions(i), this.accountStore.setAccounts(t)), e && this.transactionStore.setAssociatedBeats(e), r && this.categoryStore.setCategories(r), a && this.transactionStore.setTransactions(a), s && this.transactionStore.setTransactionRules(s), S && this.budgetsStore.setMerchantBudgets(S), h && this.userStore.setUserInsightProfile(h);
89
89
  };
90
90
  };
91
91
  export {
92
- pt as GlobalStore
92
+ mt as GlobalStore
93
93
  };
94
94
 
95
95
  //# sourceMappingURL=GlobalStore.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalStore.es.js","names":[],"sources":["../../../src/core/stores/GlobalStore.ts"],"sourcesContent":["import { autorun, makeAutoObservable } from 'mobx'\n\nimport { DefaultAppConfig } from '../constants/DefaultConfig'\n\nimport {\n AccountStore,\n AgreementStore,\n AnalyticsStore,\n AppDataStore,\n BeatStore,\n BudgetsStore,\n CashflowStore,\n CategoryStore,\n ConnectStore,\n DebtsStore,\n FinstrongStore,\n GlobalCopyStore,\n GlobalUiStore,\n GoalStore,\n HelpStore,\n HoldingStore,\n InsightsV2Store,\n MerchantStore,\n NetWorthStore,\n NotificationStore,\n RecurringTransactionsStore,\n SettingsStore,\n TransactionStore,\n TrendsStore,\n UserStore,\n} from '../stores'\n\nimport type {\n Account,\n Category,\n Institution,\n Member,\n AppConfig,\n AppData,\n Beat,\n GlobalCaptureException,\n GlobalErrorHandler,\n MerchantBudget,\n Tag,\n Tagging,\n Transaction,\n TransactionRule,\n UserFeature,\n} from '../types'\n\ninterface LoadDataProps {\n accounts?: Account[]\n appData?: AppData\n associatedBeats?: Beat[]\n categories?: Category[]\n institutions?: Institution[]\n members?: Member[]\n merchantBudgets?: MerchantBudget[]\n taggings?: Tagging[]\n tags?: Tag[]\n transactionRules?: TransactionRule[]\n transactions?: Transaction[]\n userFeatures?: UserFeature[]\n}\n\ntype OnStoreUpdate = (update: ObservedUpdate) => void\nexport type ObservedUpdate = {\n transactions?: Transaction[]\n /**\n * Guid of a beat whose data went stale because of an action taken inside experiences\n * (e.g. an insight CTA that mutated data). Hosts refetch that beat's sampled data.\n * Emitted only from explicit actions, never from the transactions autorun.\n */\n staleBeatGuid?: string\n}\nexport class GlobalStore {\n // Global properties\n appConfig: AppConfig = DefaultAppConfig\n endpoint: string = '/'\n sessionToken: string = ''\n onCaptureException?: GlobalCaptureException\n onError?: GlobalErrorHandler\n onStoreUpdate?: OnStoreUpdate\n\n // Data Stores\n accountStore: AccountStore\n agreementStore: AgreementStore\n appDataStore: AppDataStore\n analyticsStore: AnalyticsStore\n beatStore: BeatStore\n budgetsStore: BudgetsStore\n cashflowStore: CashflowStore\n categoryStore: CategoryStore\n connectStore: ConnectStore\n copyStore: GlobalCopyStore\n debtsStore: DebtsStore\n finstrongStore: FinstrongStore\n goalStore: GoalStore\n helpStore: HelpStore\n holdingStore: HoldingStore\n merchantStore: MerchantStore\n netWorthStore: NetWorthStore\n notificationStore: NotificationStore\n recurringTransactionsStore: RecurringTransactionsStore\n settingsStore: SettingsStore\n transactionStore: TransactionStore\n trendsStore: TrendsStore\n userStore: UserStore\n\n // UI Stores\n globalUiStore: GlobalUiStore\n insightsV2Store: InsightsV2Store\n\n constructor(\n appConfig: AppConfig = DefaultAppConfig,\n endpoint: string = '/',\n onError?: GlobalErrorHandler,\n onStoreUpdate?: OnStoreUpdate,\n onCaptureException?: GlobalCaptureException,\n ) {\n this.appConfig = appConfig\n this.endpoint = endpoint\n this.sessionToken = appConfig.options.session_token ?? ''\n this.onCaptureException = onCaptureException\n this.onError = onError\n this.onStoreUpdate = onStoreUpdate\n\n this.accountStore = new AccountStore(this)\n this.agreementStore = new AgreementStore(this)\n this.appDataStore = new AppDataStore(this)\n this.analyticsStore = new AnalyticsStore(this)\n this.beatStore = new BeatStore(this)\n this.budgetsStore = new BudgetsStore(this)\n this.cashflowStore = new CashflowStore(this)\n this.categoryStore = new CategoryStore(this)\n this.connectStore = new ConnectStore(this)\n this.copyStore = new GlobalCopyStore(this)\n this.debtsStore = new DebtsStore(this)\n this.finstrongStore = new FinstrongStore(this)\n this.goalStore = new GoalStore(this)\n this.helpStore = new HelpStore(this)\n this.holdingStore = new HoldingStore(this)\n this.merchantStore = new MerchantStore(this)\n this.netWorthStore = new NetWorthStore(this)\n this.notificationStore = new NotificationStore(this)\n this.recurringTransactionsStore = new RecurringTransactionsStore(this)\n this.settingsStore = new SettingsStore(this)\n this.transactionStore = new TransactionStore(this)\n this.trendsStore = new TrendsStore(this)\n this.userStore = new UserStore(this)\n\n this.globalUiStore = new GlobalUiStore(this)\n this.insightsV2Store = new InsightsV2Store(this)\n\n makeAutoObservable(this)\n\n // detects a change based on an observed value\n autorun(() => {\n // destructure or assign new variables to observe changes to them\n // in this case we are observing changes to `transactions`\n const { transactions } = this.transactionStore\n this.emitUpdate({\n transactions,\n })\n })\n }\n\n get isInitialized() {\n return this.globalUiStore.isInitialized\n }\n\n captureException = (error: unknown, context?: Record<string, string>) => {\n if (this.onCaptureException) {\n this.onCaptureException(error, context)\n return\n }\n console.error('Unreported error:', error, context)\n }\n\n // emits change triggered in the autorun\n emitUpdate = (change: ObservedUpdate) => {\n this.onStoreUpdate?.(change)\n }\n\n loadConfigData = async () => {\n await Promise.all([\n // Load copy, config and user data\n this.copyStore.loadCopy(),\n this.appDataStore.loadAppData(),\n this.accountStore.refreshMembers(),\n this.userStore.loadUserFeatures(),\n ])\n }\n\n loadData = async ({\n accounts,\n appData,\n associatedBeats,\n categories,\n institutions,\n transactionRules,\n transactions,\n userFeatures,\n merchantBudgets,\n }: LoadDataProps = {}) => {\n if (!appData || !userFeatures) {\n await this.loadConfigData()\n }\n\n // Keep for backwards compatibility for Insights\n if (appData) {\n this.appDataStore.setAppData(appData)\n }\n\n if (userFeatures) {\n this.userStore.setUserFeatures(userFeatures)\n }\n\n if (accounts) {\n await this.accountStore.loadMembers()\n if (institutions) {\n this.accountStore.setInstitutions(institutions)\n }\n this.accountStore.setAccounts(accounts)\n }\n\n if (associatedBeats) {\n this.transactionStore.setAssociatedBeats(associatedBeats)\n }\n\n if (categories) {\n this.categoryStore.setCategories(categories)\n }\n\n if (transactions) {\n this.transactionStore.setTransactions(transactions)\n }\n\n if (transactionRules) {\n this.transactionStore.setTransactionRules(transactionRules)\n }\n\n if (merchantBudgets) {\n this.budgetsStore.setMerchantBudgets(merchantBudgets)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,IAAa,KAAb,MAAyB;AAAA,EAEvB,YAAuB;AAAA,EACvB,WAAmB;AAAA,EACnB,eAAuB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EAC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B,CAAe,GAGtD,KACF,KAAK,cAAc,cAAc,CAAU,GAGzC,KACF,KAAK,iBAAiB,gBAAgB,CAAY,GAGhD,KACF,KAAK,iBAAiB,oBAAoB,CAAgB,GAGxD,KACF,KAAK,aAAa,mBAAmB,CAAe;AAAA,EAExD;AACF"}
1
+ {"version":3,"file":"GlobalStore.es.js","names":[],"sources":["../../../src/core/stores/GlobalStore.ts"],"sourcesContent":["import { autorun, makeAutoObservable } from 'mobx'\n\nimport { DefaultAppConfig } from '../constants/DefaultConfig'\n\nimport {\n AccountStore,\n AgreementStore,\n AnalyticsStore,\n AppDataStore,\n BeatStore,\n BudgetsStore,\n CashflowStore,\n CategoryStore,\n ConnectStore,\n DebtsStore,\n FinstrongStore,\n GlobalCopyStore,\n GlobalUiStore,\n GoalStore,\n HelpStore,\n HoldingStore,\n InsightsV2Store,\n MerchantStore,\n NetWorthStore,\n NotificationStore,\n RecurringTransactionsStore,\n SettingsStore,\n TransactionStore,\n TrendsStore,\n UserStore,\n} from '../stores'\n\nimport type {\n Account,\n Category,\n Institution,\n Member,\n AppConfig,\n AppData,\n Beat,\n GlobalCaptureException,\n GlobalErrorHandler,\n MerchantBudget,\n Tag,\n Tagging,\n Transaction,\n TransactionRule,\n UserFeature,\n UserInsightProfile,\n} from '../types'\n\ninterface LoadDataProps {\n accounts?: Account[]\n appData?: AppData\n associatedBeats?: Beat[]\n categories?: Category[]\n institutions?: Institution[]\n members?: Member[]\n merchantBudgets?: MerchantBudget[]\n taggings?: Tagging[]\n tags?: Tag[]\n transactionRules?: TransactionRule[]\n transactions?: Transaction[]\n userFeatures?: UserFeature[]\n /** Loaded by the host (pulse); experiences never fetches it. Read and PUT by insight CTAs. */\n userInsightProfile?: UserInsightProfile\n}\n\ntype OnStoreUpdate = (update: ObservedUpdate) => void\nexport type ObservedUpdate = {\n transactions?: Transaction[]\n /**\n * Guid of a beat whose data went stale because of an action taken inside experiences\n * (e.g. an insight CTA that mutated data). Hosts refetch that beat's sampled data.\n * Emitted only from explicit actions, never from the transactions autorun.\n */\n staleBeatGuid?: string\n}\nexport class GlobalStore {\n // Global properties\n appConfig: AppConfig = DefaultAppConfig\n endpoint: string = '/'\n sessionToken: string = ''\n onCaptureException?: GlobalCaptureException\n onError?: GlobalErrorHandler\n onStoreUpdate?: OnStoreUpdate\n\n // Data Stores\n accountStore: AccountStore\n agreementStore: AgreementStore\n appDataStore: AppDataStore\n analyticsStore: AnalyticsStore\n beatStore: BeatStore\n budgetsStore: BudgetsStore\n cashflowStore: CashflowStore\n categoryStore: CategoryStore\n connectStore: ConnectStore\n copyStore: GlobalCopyStore\n debtsStore: DebtsStore\n finstrongStore: FinstrongStore\n goalStore: GoalStore\n helpStore: HelpStore\n holdingStore: HoldingStore\n merchantStore: MerchantStore\n netWorthStore: NetWorthStore\n notificationStore: NotificationStore\n recurringTransactionsStore: RecurringTransactionsStore\n settingsStore: SettingsStore\n transactionStore: TransactionStore\n trendsStore: TrendsStore\n userStore: UserStore\n\n // UI Stores\n globalUiStore: GlobalUiStore\n insightsV2Store: InsightsV2Store\n\n constructor(\n appConfig: AppConfig = DefaultAppConfig,\n endpoint: string = '/',\n onError?: GlobalErrorHandler,\n onStoreUpdate?: OnStoreUpdate,\n onCaptureException?: GlobalCaptureException,\n ) {\n this.appConfig = appConfig\n this.endpoint = endpoint\n this.sessionToken = appConfig.options.session_token ?? ''\n this.onCaptureException = onCaptureException\n this.onError = onError\n this.onStoreUpdate = onStoreUpdate\n\n this.accountStore = new AccountStore(this)\n this.agreementStore = new AgreementStore(this)\n this.appDataStore = new AppDataStore(this)\n this.analyticsStore = new AnalyticsStore(this)\n this.beatStore = new BeatStore(this)\n this.budgetsStore = new BudgetsStore(this)\n this.cashflowStore = new CashflowStore(this)\n this.categoryStore = new CategoryStore(this)\n this.connectStore = new ConnectStore(this)\n this.copyStore = new GlobalCopyStore(this)\n this.debtsStore = new DebtsStore(this)\n this.finstrongStore = new FinstrongStore(this)\n this.goalStore = new GoalStore(this)\n this.helpStore = new HelpStore(this)\n this.holdingStore = new HoldingStore(this)\n this.merchantStore = new MerchantStore(this)\n this.netWorthStore = new NetWorthStore(this)\n this.notificationStore = new NotificationStore(this)\n this.recurringTransactionsStore = new RecurringTransactionsStore(this)\n this.settingsStore = new SettingsStore(this)\n this.transactionStore = new TransactionStore(this)\n this.trendsStore = new TrendsStore(this)\n this.userStore = new UserStore(this)\n\n this.globalUiStore = new GlobalUiStore(this)\n this.insightsV2Store = new InsightsV2Store(this)\n\n makeAutoObservable(this)\n\n // detects a change based on an observed value\n autorun(() => {\n // destructure or assign new variables to observe changes to them\n // in this case we are observing changes to `transactions`\n const { transactions } = this.transactionStore\n this.emitUpdate({\n transactions,\n })\n })\n }\n\n get isInitialized() {\n return this.globalUiStore.isInitialized\n }\n\n captureException = (error: unknown, context?: Record<string, string>) => {\n if (this.onCaptureException) {\n this.onCaptureException(error, context)\n return\n }\n console.error('Unreported error:', error, context)\n }\n\n // emits change triggered in the autorun\n emitUpdate = (change: ObservedUpdate) => {\n this.onStoreUpdate?.(change)\n }\n\n loadConfigData = async () => {\n await Promise.all([\n // Load copy, config and user data\n this.copyStore.loadCopy(),\n this.appDataStore.loadAppData(),\n this.accountStore.refreshMembers(),\n this.userStore.loadUserFeatures(),\n ])\n }\n\n loadData = async ({\n accounts,\n appData,\n associatedBeats,\n categories,\n institutions,\n transactionRules,\n transactions,\n userFeatures,\n merchantBudgets,\n userInsightProfile,\n }: LoadDataProps = {}) => {\n if (!appData || !userFeatures) {\n await this.loadConfigData()\n }\n\n // Keep for backwards compatibility for Insights\n if (appData) {\n this.appDataStore.setAppData(appData)\n }\n\n if (userFeatures) {\n this.userStore.setUserFeatures(userFeatures)\n }\n\n if (accounts) {\n await this.accountStore.loadMembers()\n if (institutions) {\n this.accountStore.setInstitutions(institutions)\n }\n this.accountStore.setAccounts(accounts)\n }\n\n if (associatedBeats) {\n this.transactionStore.setAssociatedBeats(associatedBeats)\n }\n\n if (categories) {\n this.categoryStore.setCategories(categories)\n }\n\n if (transactions) {\n this.transactionStore.setTransactions(transactions)\n }\n\n if (transactionRules) {\n this.transactionStore.setTransactionRules(transactionRules)\n }\n\n if (merchantBudgets) {\n this.budgetsStore.setMerchantBudgets(merchantBudgets)\n }\n\n if (userInsightProfile) {\n this.userStore.setUserInsightProfile(userInsightProfile)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,IAAa,KAAb,MAAyB;AAAA,EAEvB,YAAuB;AAAA,EACvB,WAAmB;AAAA,EACnB,eAAuB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EAEA,YACE,IAAuB,GACvB,IAAmB,KACnB,GACA,GACA,GACA;AACA,SAAK,YAAY,GACjB,KAAK,WAAW,GAChB,KAAK,eAAe,EAAU,QAAQ,iBAAiB,IACvD,KAAK,qBAAqB,GAC1B,KAAK,UAAU,GACf,KAAK,gBAAgB,GAErB,KAAK,eAAe,IAAI,EAAa,IAAI,GACzC,KAAK,iBAAiB,IAAI,EAAe,IAAI,GAC7C,KAAK,eAAe,IAAI,EAAa,IAAI,GACzC,KAAK,iBAAiB,IAAI,EAAe,IAAI,GAC7C,KAAK,YAAY,IAAI,EAAU,IAAI,GACnC,KAAK,eAAe,IAAI,EAAa,IAAI,GACzC,KAAK,gBAAgB,IAAI,EAAc,IAAI,GAC3C,KAAK,gBAAgB,IAAI,EAAc,IAAI,GAC3C,KAAK,eAAe,IAAI,EAAa,IAAI,GACzC,KAAK,YAAY,IAAI,EAAgB,IAAI,GACzC,KAAK,aAAa,I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AAW,OAAO,EAChB,UAAA,GACA,SAAA,GACA,iBAAA,GACA,YAAA,GACA,cAAA,GACA,kBAAA,GACA,cAAA,GACA,cAAA,GACA,iBAAA,GACA,oBAAA,EAAA,IACiB,CAAC,MAAM;AACxB,KAAI,CAAC,KAAW,CAAC,MACf,MAAM,KAAK,eAAe,GAIxB,KACF,KAAK,aAAa,WAAW,CAAO,GAGlC,KACF,KAAK,UAAU,gBAAgB,CAAY,GAGzC,MACF,MAAM,KAAK,aAAa,YAAY,GAChC,KACF,KAAK,aAAa,gBAAgB,CAAY,GAEhD,KAAK,aAAa,YAAY,CAAQ,IAGpC,KACF,KAAK,iBAAiB,mBAAmB,CAAe,GAGtD,KACF,KAAK,cAAc,cAAc,CAAU,GAGzC,KACF,KAAK,iBAAiB,gBAAgB,CAAY,GAGhD,KACF,KAAK,iBAAiB,oBAAoB,CAAgB,GAGxD,KACF,KAAK,aAAa,mBAAmB,CAAe,GAGlD,KACF,KAAK,UAAU,sBAAsB,CAAkB;AAAA,EAE3D;AACF"}
@@ -265,6 +265,29 @@ export interface GoalsBlockCopy {
265
265
  total_saved_label: string;
266
266
  complete_label: string;
267
267
  }
268
+ /** The credit card payoff calculator drawer (`payoff_calculator_block`). */
269
+ export interface PayoffCalculatorCopy {
270
+ /** Drawer title, e.g. "Credit card payoff calculator". */
271
+ title: string;
272
+ description: string;
273
+ credit_card_balance: string;
274
+ interest_rate: string;
275
+ monthly_payment: string;
276
+ calculate: string;
277
+ your_results: string;
278
+ time_to_payoff: string;
279
+ total_interest_paid: string;
280
+ /** Time to payoff, `_1{number}` months: singular and plural. */
281
+ month: string;
282
+ months: string;
283
+ calculation_failed: string;
284
+ calculation_failed_description: string;
285
+ /** Validation messages; `_1{value}` is the field label and `_2{amount}` the bound. */
286
+ value_is_required: string;
287
+ value_must_be_a_number: string;
288
+ value_must_be_greater_than_or_equal_to: string;
289
+ value_must_be_less_than_or_equal_to: string;
290
+ }
268
291
  export interface InsightsFeedCopy {
269
292
  general: GeneralInsightsFeedCopy;
270
293
  settings_menu: SettingsMenuCopy;
@@ -290,5 +313,7 @@ export interface InsightsFeedCopy {
290
313
  debts_block?: DebtsBlockCopy;
291
314
  /** Optional until the localized-content service ships the namespace. */
292
315
  goals_block?: GoalsBlockCopy;
316
+ /** Optional until the localized-content service ships the namespace. */
317
+ payoff_calculator?: PayoffCalculatorCopy;
293
318
  }
294
319
  export {};
@@ -13,7 +13,7 @@ export type { DebtsCopy } from './DebtsCopy';
13
13
  export type { FinstrongCopy } from './FinstrongCopy';
14
14
  export type { GoalsCopy } from './GoalsCopy';
15
15
  export type { HelpCopy, HelpByCategoryList } from './HelpCopy';
16
- export type { AmountInputModalCopy, AmountInputModalVariantCopy, InsightsFeedCopy, MakeTransferCopy, RemainingCashCopy, OverflowMenuCopy, DismissInsightCopy, DismissInsightOptionCopy, HiddenConfirmationCopy, HideFeedbackCopy, FeedbackCopy, FeedbackBarCopy, } from './InsightsFeedCopy';
16
+ export type { AmountInputModalCopy, AmountInputModalVariantCopy, InsightsFeedCopy, MakeTransferCopy, PayoffCalculatorCopy, RemainingCashCopy, OverflowMenuCopy, DismissInsightCopy, DismissInsightOptionCopy, HiddenConfirmationCopy, HideFeedbackCopy, FeedbackCopy, FeedbackBarCopy, } from './InsightsFeedCopy';
17
17
  export type { InvestmentsCopy } from './InvestmentsCopy';
18
18
  export type { MicroInsightsCopy } from './MicroInsightsCopy';
19
19
  export type { NetWorthCopy } from './NetWorthCopy';
@@ -0,0 +1,11 @@
1
+ import { ActionBlockProps } from '../../mappings/blocks';
2
+ /** Loads accounts once per open when the host did not attach the beat's primary account. */
3
+ export declare const usePayoffCalculatorPrepare: ({ beat }: ActionBlockProps) => void;
4
+ /**
5
+ * Monthly Credit Card Interest Summary's "Learn how to save" drawer: the credit card payoff
6
+ * calculator. The beat's account prefills the balance, interest rate and minimum payment; the
7
+ * user edits them and compares the payoff at that payment, $10 more and $20 more.
8
+ */
9
+ export declare const PayoffCalculatorBlock: (({ beat, }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
10
+ displayName: string;
11
+ };
@@ -0,0 +1,132 @@
1
+ import I from "../../../common/utils/AccountDisplayName.es.js";
2
+ import { useAccountStore as g, useGlobalCopyStore as S } from "../../../common/context/hooks.es.js";
3
+ import A from "../../../common/components/Loader.es.js";
4
+ import { isPayoffPossible as w } from "./payoff.es.js";
5
+ import { buildPayoffRows as F, initialPayoffInputs as R, parsePayoffInputs as k, resolvePrimaryAccount as D, validatePayoffInputs as L } from "./layout.es.js";
6
+ import { CalculationFailed as $, PayoffResults as j } from "./PayoffResults.es.js";
7
+ import l from "react";
8
+ import { observer as B } from "mobx-react-lite";
9
+ import c from "@mui/material/Stack";
10
+ import { InstitutionLogo as E, Text as h, TextField as T } from "@mxenabled/mxui";
11
+ import G from "@mui/material/Button";
12
+ import { jsx as o, jsxs as d } from "react/jsx-runtime";
13
+ import N from "@mui/material/InputAdornment";
14
+ var tt = ({ beat: i }) => {
15
+ const { accountsLoaded: t, loadAccounts: s } = g();
16
+ l.useEffect(() => {
17
+ !i.primary_account && !t && s();
18
+ }, []);
19
+ }, O = ({ account: i, copy: t }) => {
20
+ const s = l.useId(), [a, f] = l.useState(() => R(i)), [u, m] = l.useState({}), [p, v] = l.useState({ status: "idle" }), b = i ? I(i) : "", _ = (e) => (n) => f((r) => ({
21
+ ...r,
22
+ [e]: n.target.value
23
+ })), C = (e) => {
24
+ e.preventDefault();
25
+ const n = L(a, t);
26
+ if (m(n), Object.keys(n).length > 0) return;
27
+ const { balance: r, interestRate: x, monthlyPayment: P } = k(a);
28
+ v(w(x, r, P) ? {
29
+ status: "calculated",
30
+ rows: F(x, r, P)
31
+ } : { status: "failed" });
32
+ }, y = (e, n, r) => /* @__PURE__ */ o(T, {
33
+ error: !!u[e],
34
+ fullWidth: !0,
35
+ helperText: u[e],
36
+ id: `${s}-${e}`,
37
+ label: n,
38
+ onChange: _(e),
39
+ slotProps: {
40
+ htmlInput: { inputMode: "decimal" },
41
+ input: { [r.position === "start" ? "startAdornment" : "endAdornment"]: /* @__PURE__ */ o(N, {
42
+ "aria-hidden": "true",
43
+ position: r.position,
44
+ children: r.symbol
45
+ }) }
46
+ },
47
+ value: a[e]
48
+ });
49
+ return /* @__PURE__ */ d(c, {
50
+ component: "form",
51
+ noValidate: !0,
52
+ onSubmit: C,
53
+ sx: { p: 16 },
54
+ children: [
55
+ b && /* @__PURE__ */ d(c, {
56
+ sx: {
57
+ alignItems: "center",
58
+ flexDirection: "row",
59
+ gap: 8
60
+ },
61
+ children: [/* @__PURE__ */ o(E, {
62
+ alt: "",
63
+ institutionGuid: i?.institution_guid ?? "",
64
+ size: 24
65
+ }), /* @__PURE__ */ o(h, {
66
+ component: "p",
67
+ variant: "body2",
68
+ children: b
69
+ })]
70
+ }),
71
+ /* @__PURE__ */ o(h, {
72
+ color: "text.secondary",
73
+ component: "p",
74
+ sx: { mt: 16 },
75
+ variant: "body2",
76
+ children: t.description
77
+ }),
78
+ /* @__PURE__ */ d(c, {
79
+ sx: {
80
+ gap: 24,
81
+ pb: 24,
82
+ pt: 32
83
+ },
84
+ children: [y("balance", t.credit_card_balance, {
85
+ position: "start",
86
+ symbol: "$"
87
+ }), /* @__PURE__ */ d(c, {
88
+ sx: {
89
+ flexDirection: "row",
90
+ gap: 16
91
+ },
92
+ children: [y("interestRate", t.interest_rate, {
93
+ position: "end",
94
+ symbol: "%"
95
+ }), y("monthlyPayment", t.monthly_payment, {
96
+ position: "start",
97
+ symbol: "$"
98
+ })]
99
+ })]
100
+ }),
101
+ /* @__PURE__ */ o(G, {
102
+ fullWidth: !0,
103
+ sx: {
104
+ mb: 24,
105
+ mt: 8
106
+ },
107
+ type: "submit",
108
+ variant: "contained",
109
+ children: t.calculate
110
+ }),
111
+ p.status === "failed" ? /* @__PURE__ */ o($, { copy: t }) : /* @__PURE__ */ o(j, {
112
+ copy: t,
113
+ rows: p.status === "calculated" ? p.rows : void 0
114
+ })
115
+ ]
116
+ });
117
+ }, ot = B(function({ beat: t }) {
118
+ const { common: s, insights_feed: a } = S(), { accounts: f, accountsLoaded: u } = g(), m = a?.payoff_calculator;
119
+ return m ? !t.primary_account && !u ? /* @__PURE__ */ o(A, {}) : /* @__PURE__ */ o(O, {
120
+ account: D(t, f),
121
+ copy: m
122
+ }, t.guid) : /* @__PURE__ */ o(c, {
123
+ sx: { p: 24 },
124
+ children: /* @__PURE__ */ o(h, { children: s?.error_message })
125
+ });
126
+ });
127
+ export {
128
+ ot as PayoffCalculatorBlock,
129
+ tt as usePayoffCalculatorPrepare
130
+ };
131
+
132
+ //# sourceMappingURL=PayoffCalculatorBlock.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PayoffCalculatorBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Button from '@mui/material/Button'\nimport InputAdornment from '@mui/material/InputAdornment'\nimport Stack from '@mui/material/Stack'\n\nimport { InstitutionLogo, Text, TextField } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { Loader, useAccountStore, useGlobalCopyStore } from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport type { Account, PayoffCalculatorCopy } from '../../../core'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport {\n buildPayoffRows,\n initialPayoffInputs,\n parsePayoffInputs,\n resolvePrimaryAccount,\n validatePayoffInputs,\n type PayoffErrors,\n type PayoffField,\n type PayoffInputs,\n type PayoffRow,\n} from './layout'\nimport { isPayoffPossible } from './payoff'\nimport { CalculationFailed, PayoffResults } from './PayoffResults'\n\n/** Loads accounts once per open when the host did not attach the beat's primary account. */\nexport const usePayoffCalculatorPrepare = ({ beat }: ActionBlockProps) => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n React.useEffect(() => {\n if (!beat.primary_account && !accountsLoaded) void loadAccounts()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\ntype Outcome =\n | { status: 'idle' }\n | { status: 'calculated'; rows: PayoffRow[] }\n | { status: 'failed' }\n\ninterface PayoffCalculatorFormProps {\n account?: Account\n copy: PayoffCalculatorCopy\n}\n\nconst PayoffCalculatorForm = ({ account, copy }: PayoffCalculatorFormProps) => {\n const id = React.useId()\n const [inputs, setInputs] = React.useState<PayoffInputs>(() => initialPayoffInputs(account))\n const [errors, setErrors] = React.useState<PayoffErrors>({})\n const [outcome, setOutcome] = React.useState<Outcome>({ status: 'idle' })\n\n const accountName = account ? getAccountDisplayName(account) : ''\n\n const setField = (field: PayoffField) => (event: React.ChangeEvent<HTMLInputElement>) =>\n setInputs((previous) => ({ ...previous, [field]: event.target.value }))\n\n const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n\n const nextErrors = validatePayoffInputs(inputs, copy)\n\n setErrors(nextErrors)\n if (Object.keys(nextErrors).length > 0) return\n\n const { balance, interestRate, monthlyPayment } = parsePayoffInputs(inputs)\n\n setOutcome(\n isPayoffPossible(interestRate, balance, monthlyPayment)\n ? { status: 'calculated', rows: buildPayoffRows(interestRate, balance, monthlyPayment) }\n : { status: 'failed' },\n )\n }\n\n const field = (\n name: PayoffField,\n label: string,\n adornment: { position: 'start' | 'end'; symbol: string },\n ) => (\n <TextField\n error={!!errors[name]}\n fullWidth={true}\n helperText={errors[name]}\n id={`${id}-${name}`}\n label={label}\n onChange={setField(name)}\n slotProps={{\n htmlInput: { inputMode: 'decimal' },\n input: {\n [adornment.position === 'start' ? 'startAdornment' : 'endAdornment']: (\n <InputAdornment aria-hidden=\"true\" position={adornment.position}>\n {adornment.symbol}\n </InputAdornment>\n ),\n },\n }}\n value={inputs[name]}\n />\n )\n\n return (\n <Stack component=\"form\" noValidate={true} onSubmit={handleSubmit} sx={{ p: 16 }}>\n {accountName && (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <InstitutionLogo alt=\"\" institutionGuid={account?.institution_guid ?? ''} size={24} />\n <Text component=\"p\" variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n )}\n <Text color=\"text.secondary\" component=\"p\" sx={{ mt: 16 }} variant=\"body2\">\n {copy.description}\n </Text>\n <Stack sx={{ gap: 24, pb: 24, pt: 32 }}>\n {field('balance', copy.credit_card_balance, { position: 'start', symbol: '$' })}\n <Stack sx={{ flexDirection: 'row', gap: 16 }}>\n {field('interestRate', copy.interest_rate, { position: 'end', symbol: '%' })}\n {field('monthlyPayment', copy.monthly_payment, { position: 'start', symbol: '$' })}\n </Stack>\n </Stack>\n <Button fullWidth={true} sx={{ mb: 24, mt: 8 }} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n {outcome.status === 'failed' ? (\n <CalculationFailed copy={copy} />\n ) : (\n <PayoffResults\n copy={copy}\n rows={outcome.status === 'calculated' ? outcome.rows : undefined}\n />\n )}\n </Stack>\n )\n}\n\n/**\n * Monthly Credit Card Interest Summary's \"Learn how to save\" drawer: the credit card payoff\n * calculator. The beat's account prefills the balance, interest rate and minimum payment; the\n * user edits them and compares the payoff at that payment, $10 more and $20 more.\n */\nexport const PayoffCalculatorBlock = observer(function PayoffCalculatorBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { accounts, accountsLoaded } = useAccountStore()\n const copy = insightsFeedCopy?.payoff_calculator\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n if (!beat.primary_account && !accountsLoaded) return <Loader />\n\n return (\n <PayoffCalculatorForm\n account={resolvePrimaryAccount(beat, accounts)}\n copy={copy}\n key={beat.guid}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;AA6BA,IAAa,KAAA,CAA8B,EAAE,MAAA,EAAA,MAA6B;AACxE,QAAM,EAAE,gBAAA,GAAgB,cAAA,EAAA,IAAiB,EAAgB;AAEzD,EAAA,EAAM,U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ResultsProps {
4
+ copy: PayoffCalculatorCopy;
5
+ /** Undefined until the user has calculated: the rows then show placeholders. */
6
+ rows?: PayoffRow[];
7
+ }
8
+ export declare const PayoffResults: ({ copy, rows }: PayoffResultsProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const CalculationFailed: ({ copy }: {
10
+ copy: PayoffCalculatorCopy;
11
+ }) => import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,124 @@
1
+ import { buildPluralCopy as h } from "../../../core/utils/Localization.es.js";
2
+ import { formatCurrency as s } from "../../../core/utils/NumberFormatting.es.js";
3
+ import { PAYMENT_INCREMENTS as x } from "./layout.es.js";
4
+ import m from "@mui/material/Stack";
5
+ import { Text as t } from "@mxenabled/mxui";
6
+ import { Icon as v } from "@mxenabled/mx-icons";
7
+ import { Fragment as y, jsx as r, jsxs as n } from "react/jsx-runtime";
8
+ import g from "@mui/material/Box";
9
+ var C = "0px 6px 12px rgba(106, 115, 129, 0.16), 0px 3px 8px rgba(87, 102, 117, 0.06)", p = ({ label: o, tone: a, value: e }) => /* @__PURE__ */ n(m, {
10
+ sx: {
11
+ flexDirection: "row",
12
+ justifyContent: "space-between"
13
+ },
14
+ children: [/* @__PURE__ */ r(t, {
15
+ color: "text.secondary",
16
+ component: "span",
17
+ variant: "caption",
18
+ children: o
19
+ }), /* @__PURE__ */ r(t, {
20
+ bold: !0,
21
+ color: a,
22
+ component: "span",
23
+ sx: { transition: "color 0.5s" },
24
+ variant: "body1",
25
+ children: e
26
+ })]
27
+ }), E = ({ copy: o, rows: a }) => {
28
+ const e = !!a, i = e ? "text.primary" : "text.secondary", u = a ?? x.map(() => {
29
+ });
30
+ return /* @__PURE__ */ n(g, {
31
+ sx: {
32
+ bgcolor: e ? "background.paper" : "background.default",
33
+ borderRadius: "4px",
34
+ boxShadow: e ? C : "none",
35
+ transition: "background-color 0.5s, box-shadow 0.5s"
36
+ },
37
+ children: [/* @__PURE__ */ r(t, {
38
+ bold: !0,
39
+ color: i,
40
+ component: "h3",
41
+ sx: {
42
+ borderBottom: 1,
43
+ borderColor: "divider",
44
+ p: 16
45
+ },
46
+ variant: "h3",
47
+ children: o.your_results
48
+ }), u.map((l, b) => {
49
+ const c = x[b], d = l?.result.paymentCount ?? 0, f = d >= 1 ? h(o.month, o.months, d, String(d)) : "-";
50
+ return /* @__PURE__ */ n(m, {
51
+ sx: {
52
+ borderBottom: b === u.length - 1 ? 0 : 1,
53
+ borderColor: "divider",
54
+ gap: 16,
55
+ px: 16,
56
+ py: 24
57
+ },
58
+ children: [
59
+ /* @__PURE__ */ r(p, {
60
+ label: /* @__PURE__ */ n(y, { children: [o.monthly_payment, c > 0 && /* @__PURE__ */ r(t, {
61
+ bold: !0,
62
+ color: "success.main",
63
+ component: "span",
64
+ variant: "caption",
65
+ children: ` +${s(c, "0,0.00")}`
66
+ })] }),
67
+ tone: i,
68
+ value: s(l?.monthlyPayment ?? 0, "0,0.00")
69
+ }),
70
+ /* @__PURE__ */ r(p, {
71
+ label: o.time_to_payoff,
72
+ tone: i,
73
+ value: f
74
+ }),
75
+ /* @__PURE__ */ r(p, {
76
+ label: o.total_interest_paid,
77
+ tone: i,
78
+ value: s(l?.result.totalInterestPaid ?? 0, "0,0.00")
79
+ })
80
+ ]
81
+ }, c);
82
+ })]
83
+ });
84
+ }, j = ({ copy: o }) => /* @__PURE__ */ n(m, {
85
+ role: "alert",
86
+ sx: {
87
+ alignItems: "center",
88
+ bgcolor: "background.default",
89
+ borderRadius: "4px",
90
+ px: 32,
91
+ py: 40,
92
+ textAlign: "center"
93
+ },
94
+ children: [
95
+ /* @__PURE__ */ r(v, {
96
+ "aria-hidden": "true",
97
+ fill: !0,
98
+ name: "error",
99
+ size: 24,
100
+ sx: { color: "primary.main" }
101
+ }),
102
+ /* @__PURE__ */ r(t, {
103
+ bold: !0,
104
+ component: "p",
105
+ sx: {
106
+ pb: 8,
107
+ pt: 16
108
+ },
109
+ variant: "body1",
110
+ children: o.calculation_failed
111
+ }),
112
+ /* @__PURE__ */ r(t, {
113
+ component: "p",
114
+ variant: "body2",
115
+ children: o.calculation_failed_description
116
+ })
117
+ ]
118
+ });
119
+ export {
120
+ j as CalculationFailed,
121
+ E as PayoffResults
122
+ };
123
+
124
+ //# sourceMappingURL=PayoffResults.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PayoffResults.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildPluralCopy } from '../../../common'\nimport type { PayoffCalculatorCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\n\nimport { PAYMENT_INCREMENTS, type PayoffRow } from './layout'\n\nconst CALCULATED_SHADOW =\n '0px 6px 12px rgba(106, 115, 129, 0.16), 0px 3px 8px rgba(87, 102, 117, 0.06)'\n\ninterface ResultLineProps {\n label: React.ReactNode\n tone: 'text.primary' | 'text.secondary'\n value: string\n}\n\nconst ResultLine = ({ label, tone, value }: ResultLineProps) => (\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" component=\"span\" variant=\"caption\">\n {label}\n </Text>\n <Text\n bold={true}\n color={tone}\n component=\"span\"\n sx={{ transition: 'color 0.5s' }}\n variant=\"body1\"\n >\n {value}\n </Text>\n </Stack>\n)\n\ninterface PayoffResultsProps {\n copy: PayoffCalculatorCopy\n /** Undefined until the user has calculated: the rows then show placeholders. */\n rows?: PayoffRow[]\n}\n\nexport const PayoffResults = ({ copy, rows }: PayoffResultsProps) => {\n const isCalculated = !!rows\n const tone = isCalculated ? 'text.primary' : 'text.secondary'\n const shown: Array<PayoffRow | undefined> = rows ?? PAYMENT_INCREMENTS.map(() => undefined)\n\n return (\n <Box\n sx={{\n bgcolor: isCalculated ? 'background.paper' : 'background.default',\n borderRadius: '4px',\n boxShadow: isCalculated ? CALCULATED_SHADOW : 'none',\n transition: 'background-color 0.5s, box-shadow 0.5s',\n }}\n >\n <Text\n bold={true}\n color={tone}\n component=\"h3\"\n sx={{ borderBottom: 1, borderColor: 'divider', p: 16 }}\n variant=\"h3\"\n >\n {copy.your_results}\n </Text>\n {shown.map((row, index) => {\n const increment = PAYMENT_INCREMENTS[index]\n const paymentCount = row?.result.paymentCount ?? 0\n const timeToPayoff =\n paymentCount >= 1\n ? (buildPluralCopy(\n copy.month,\n copy.months,\n paymentCount,\n String(paymentCount),\n ) as string)\n : '-'\n\n return (\n <Stack\n key={increment}\n sx={{\n borderBottom: index === shown.length - 1 ? 0 : 1,\n borderColor: 'divider',\n gap: 16,\n px: 16,\n py: 24,\n }}\n >\n <ResultLine\n label={\n <>\n {copy.monthly_payment}\n {increment > 0 && (\n <Text bold={true} color=\"success.main\" component=\"span\" variant=\"caption\">\n {` +${formatCurrency(increment, '0,0.00')}`}\n </Text>\n )}\n </>\n }\n tone={tone}\n value={formatCurrency(row?.monthlyPayment ?? 0, '0,0.00')}\n />\n <ResultLine label={copy.time_to_payoff} tone={tone} value={timeToPayoff} />\n <ResultLine\n label={copy.total_interest_paid}\n tone={tone}\n value={formatCurrency(row?.result.totalInterestPaid ?? 0, '0,0.00')}\n />\n </Stack>\n )\n })}\n </Box>\n )\n}\n\nexport const CalculationFailed = ({ copy }: { copy: PayoffCalculatorCopy }) => (\n <Stack\n role=\"alert\"\n sx={{\n alignItems: 'center',\n bgcolor: 'background.default',\n borderRadius: '4px',\n px: 32,\n py: 40,\n textAlign: 'center',\n }}\n >\n <Icon aria-hidden=\"true\" fill={true} name=\"error\" size={24} sx={{ color: 'primary.main' }} />\n <Text bold={true} component=\"p\" sx={{ pb: 8, pt: 16 }} variant=\"body1\">\n {copy.calculation_failed}\n </Text>\n <Text component=\"p\" variant=\"body2\">\n {copy.calculation_failed_description}\n </Text>\n </Stack>\n)\n"],"mappings":";;;;;;;;AAYA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AAO,eAAe;AAAA,IAAI,CAAA;AAAA,IAC5F,gBAAA,EAAC,GAAD;AAAA,MAAM,MAAM;AAAA,MAAM,WAAU;AAAA,MAAI,IAAI;AAAA,QAAE,IAAI;AAAA,QAAG,IAAI;AAAA,MAAG;AAAA,MAAG,SAAQ;AAAA,MAC5D,UAAA,EAAK;AAAA,IACF,CAAA;AAAA,IACN,gBAAA,EAAC,GAAD;AAAA,MAAM,WAAU;AAAA,MAAI,SAAQ;AAAA,MACzB,UAAA,EAAK;AAAA,IACF,CAAA;AAAA,EACD"}
@@ -0,0 +1 @@
1
+ export { PayoffCalculatorBlock, usePayoffCalculatorPrepare } from './PayoffCalculatorBlock';
@@ -0,0 +1,26 @@
1
+ import { Account, Beat, PayoffCalculatorCopy } from '../../../core';
2
+ import { PayoffResult } from './payoff';
3
+ /** The three monthly payments the results compare: the entered one and two small increases. */
4
+ export declare const PAYMENT_INCREMENTS: readonly [0, 10, 20];
5
+ export type PayoffField = 'balance' | 'interestRate' | 'monthlyPayment';
6
+ export type PayoffInputs = Record<PayoffField, string>;
7
+ export type PayoffErrors = Partial<Record<PayoffField, string>>;
8
+ export declare const PAYOFF_FIELDS: readonly PayoffField[];
9
+ export declare const validatePayoffInputs: (inputs: PayoffInputs, copy: PayoffCalculatorCopy) => PayoffErrors;
10
+ export interface PayoffRow {
11
+ /** How much more than the entered payment this row pays each month. */
12
+ increment: number;
13
+ monthlyPayment: number;
14
+ result: PayoffResult;
15
+ }
16
+ export declare const buildPayoffRows: (annualRatePercent: number, balance: number, payment: number) => PayoffRow[];
17
+ export declare const parsePayoffInputs: (inputs: PayoffInputs) => {
18
+ balance: number;
19
+ interestRate: number;
20
+ monthlyPayment: number;
21
+ };
22
+ /** Manual accounts carry their rate as `interest_rate`; aggregated ones as APR, else APY. */
23
+ export declare const interestRateOf: (account: Account) => number | undefined;
24
+ export declare const initialPayoffInputs: (account?: Account) => PayoffInputs;
25
+ /** The beat's primary account: from the beat when the host attached it, else the loaded accounts. */
26
+ export declare const resolvePrimaryAccount: (beat: Beat, accounts: Account[]) => Account | undefined;