@mx-cartographer/experiences 8.2.0-alpha.bb0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{Account-BTOmbrEK.mjs → Account-BaJmiJAG.mjs} +2 -2
  3. package/dist/{Account-DC2d-cjn.mjs → Account-BxHMlV9R.mjs} +1 -1
  4. package/dist/{AccountDetailsHeader-IDZ6GTT0.mjs → AccountDetailsHeader-CfdnKyJK.mjs} +17 -17
  5. package/dist/{AccountFields-BRAl-Hro.mjs → AccountFields-CAy0x_4i.mjs} +6 -6
  6. package/dist/{AccountListItem-B8koowMf.mjs → AccountListItem-BYyeeCf6.mjs} +5 -5
  7. package/dist/{AccountUtils-Bc-SndzX.mjs → AccountUtils-T5_Odvos.mjs} +1 -1
  8. package/dist/{Analytics-vgPYa2Zt.mjs → Analytics-CkYXKvco.mjs} +1 -1
  9. package/dist/{BudgetUtil-CGchXaek.mjs → BudgetUtil-Bg2AQJpQ.mjs} +3 -3
  10. package/dist/{CategorySelectorDrawer-nHEBR24E.mjs → CategorySelectorDrawer-Cu1ohxeM.mjs} +1 -1
  11. package/dist/{CurrencyDialog-C7r7JqVu.mjs → CurrencyDialog-d4dL7vA5.mjs} +1 -1
  12. package/dist/{CurrencyInput-BUd8mAcE.mjs → CurrencyInput-B59ugxPN.mjs} +2 -2
  13. package/dist/{CurrencyText-Dd3NxFYY.mjs → CurrencyText-CCbE6MmF.mjs} +1 -1
  14. package/dist/{DateFormats-BSktnUw6.mjs → DateFormats-HudZ3Bjs.mjs} +1 -1
  15. package/dist/{DateUtil-Bdm-ZxFw.mjs → DateUtil-Bhq59ZVg.mjs} +1 -1
  16. package/dist/{DebtUtils-DPn1cXKG.mjs → DebtUtils-DD3186U-.mjs} +1 -1
  17. package/dist/{EmbeddedCard-CAY_HJjE.mjs → EmbeddedCard-BNl3quCs.mjs} +4 -4
  18. package/dist/{ExportCsvAction-DzeJOb_g.mjs → ExportCsvAction-hDprC41l.mjs} +2 -2
  19. package/dist/GlobalCopyApi-wcnDUzMV.mjs +128 -0
  20. package/dist/{GoalsUtil-B-Z6fq_t.mjs → GoalsUtil-C9EnLWvC.mjs} +3 -3
  21. package/dist/{Help-HoxJgoVt.mjs → Help-BSQm9o29.mjs} +1 -1
  22. package/dist/{LineChart-DNynWPGz.mjs → LineChart-CejWS_rh.mjs} +1 -1
  23. package/dist/Localization-DnoVyBNK.mjs +38 -0
  24. package/dist/{ManageIncome-C_FjST7B.mjs → ManageIncome-DwylSiWs.mjs} +41 -41
  25. package/dist/{NetWorthUtils-CyVz9bUn.mjs → NetWorthUtils-DilGN1nW.mjs} +2 -2
  26. package/dist/{NotificationSettings-B8pH9TOv.mjs → NotificationSettings-CCg-Tml2.mjs} +6 -6
  27. package/dist/{NumberFormatting-Dnk0YyfZ.mjs → NumberFormatting--XMeeBfr.mjs} +2 -1
  28. package/dist/{OriginalBalanceAction-BEBuqeS1.mjs → OriginalBalanceAction-CvDx0K6k.mjs} +2 -2
  29. package/dist/{RecurringSettings-eQb1AS5x.mjs → RecurringSettings-CPXLW6AR.mjs} +2 -2
  30. package/dist/{RecurringTransactionsUtil-DbMNqEu_.mjs → RecurringTransactionsUtil-B3rLEx_g.mjs} +6 -6
  31. package/dist/{SpendingData-CktOElG1.mjs → SpendingData-PKlh8caU.mjs} +1 -1
  32. package/dist/{SpendingLegend-CM5L_1Ka.mjs → SpendingLegend-BmkEr9Nh.mjs} +56 -56
  33. package/dist/{TransactionDetails-BP-sFltN.mjs → TransactionDetails-CbBSxdOi.mjs} +9 -9
  34. package/dist/{TransactionUtils-CvJW9wDu.mjs → TransactionUtils-BphBJBbU.mjs} +8 -8
  35. package/dist/UserStore-CRpKQjpP.mjs +3002 -0
  36. package/dist/{ViewMoreMicroCard-DWOpU5L8.mjs → ViewMoreMicroCard-K69RRs_b.mjs} +3 -3
  37. package/dist/{WidgetContainer-CAgbD0ZS.mjs → WidgetContainer-DalWyz5A.mjs} +1 -1
  38. package/dist/accounts/index.es.js +25 -25
  39. package/dist/budgets/index.es.js +11 -11
  40. package/dist/cashflow/index.es.js +12 -12
  41. package/dist/categories/index.es.js +1 -1
  42. package/dist/common/context/hooks.d.ts +1 -1
  43. package/dist/common/index.d.ts +3 -0
  44. package/dist/common/index.es.js +148 -136
  45. package/dist/core/index.es.js +104 -3061
  46. package/dist/core/utils/Localization.d.ts +1 -0
  47. package/dist/debts/index.es.js +9 -9
  48. package/dist/finstrong/index.es.js +13 -13
  49. package/dist/goals/index.es.js +8 -8
  50. package/dist/help/index.es.js +2 -2
  51. package/dist/insights/index.es.js +5 -5
  52. package/dist/investments/index.es.js +3 -3
  53. package/dist/microinsights/index.es.js +1 -1
  54. package/dist/networth/index.es.js +7 -7
  55. package/dist/notifications/index.es.js +2 -2
  56. package/dist/recurringtransactions/index.es.js +37 -37
  57. package/dist/settings/index.es.js +6 -6
  58. package/dist/spending/index.es.js +139 -139
  59. package/dist/transactions/index.es.js +12 -12
  60. package/dist/trends/index.es.js +12 -12
  61. package/package.json +1 -1
  62. package/dist/AnalyticsApi-DwgSyZ6m.mjs +0 -102
  63. package/dist/GlobalCopyApi-C75qVBk6.mjs +0 -30
  64. package/dist/Localization-Li21_krp.mjs +0 -37
@@ -0,0 +1,3002 @@
1
+ import { makeAutoObservable as d, runInAction as c, reaction as ut, autorun as St, observable as Tt } from "mobx";
2
+ import { d as At } from "./AccountUtils-T5_Odvos.mjs";
3
+ import { i as wt, f as bt, b as It, c as k } from "./BudgetUtil-Bg2AQJpQ.mjs";
4
+ import { A as h, f as M } from "./Account-BaJmiJAG.mjs";
5
+ import { F as g, B as v, G as H } from "./GlobalCopyApi-wcnDUzMV.mjs";
6
+ import { A as i } from "./ApiEndpoints-DXwIYNUV.mjs";
7
+ import Ct from "posthog-js";
8
+ import { endOfMonth as T } from "date-fns/endOfMonth";
9
+ import { startOfMonth as E } from "date-fns/startOfMonth";
10
+ import { startOfToday as y } from "date-fns/startOfToday";
11
+ import { C as w, b as Et } from "./Category-DEKZGLYe.mjs";
12
+ import { addDays as Dt } from "date-fns/addDays";
13
+ import { differenceInDays as Rt } from "date-fns/differenceInDays";
14
+ import { isBefore as F } from "date-fns/isBefore";
15
+ import { getUnixTime as m } from "date-fns/getUnixTime";
16
+ import { subMonths as $ } from "date-fns/subMonths";
17
+ import { c as Lt, d as vt, C as $t, h as Nt, i as Gt, s as Bt, j as xt, T as Mt, D as Ot } from "./TransactionUtils-BphBJBbU.mjs";
18
+ import { l as Pt, D as Ut } from "./DebtUtils-DD3186U-.mjs";
19
+ import { format as Ft } from "date-fns/format";
20
+ import { fromUnixTime as kt } from "date-fns/fromUnixTime";
21
+ import { f as P, D as U } from "./DateFormats-HudZ3Bjs.mjs";
22
+ import { T as S, c as W } from "./GoalsUtil-C9EnLWvC.mjs";
23
+ import { A as Ht, m as Wt, a as Vt, b as zt } from "./InvestmentUtil-BItV7uEs.mjs";
24
+ import { f as Kt, b as Qt, a as V, c as qt, d as Yt, e as jt, s as Xt } from "./NetWorthUtils-DilGN1nW.mjs";
25
+ import { f as Jt } from "./NotificationUtils-BRGFTePr.mjs";
26
+ import { isAfter as z } from "date-fns/isAfter";
27
+ import { isSameDay as K } from "date-fns/isSameDay";
28
+ import { isWithinInterval as gt } from "date-fns/isWithinInterval";
29
+ import { subDays as pt } from "date-fns/subDays";
30
+ import { e as O, f as Zt, a as f, b as Q } from "./RecurringTransactionsUtil-B3rLEx_g.mjs";
31
+ import { I as u, A as _, B as N } from "./Notification-DTNYSd8P.mjs";
32
+ import { endOfToday as q } from "date-fns/endOfToday";
33
+ import { formatISO as te } from "date-fns/formatISO";
34
+ import { addSeconds as ee } from "date-fns/addSeconds";
35
+ import { differenceInCalendarMonths as se } from "date-fns/differenceInCalendarMonths";
36
+ import { f as ae, b as ne } from "./TrendsUtil-D9z3kIj_.mjs";
37
+ import { addMonths as ie } from "date-fns/addMonths";
38
+ import { getMonth as L } from "date-fns/getMonth";
39
+ import { a as re } from "./Help-CkQTjORd.mjs";
40
+ class G {
41
+ fetchInstance;
42
+ constructor(t, e, s) {
43
+ this.fetchInstance = new g(t, e, void 0, s);
44
+ }
45
+ createAccount = async (t) => this.fetchInstance.post(i.ACCOUNTS, t).then((e) => e.account).catch((e) => e);
46
+ deleteAccount = async (t) => this.fetchInstance.delete(`${i.ACCOUNTS}/${t}`).catch((e) => e);
47
+ getAccounts = async () => this.fetchInstance.get(i.ACCOUNTS).then((t) => t.accounts).catch((t) => t);
48
+ getInstitutions = async () => this.fetchInstance.get(i.INSTITUTIONS).then((t) => t).catch((t) => t);
49
+ getMembers = async () => this.fetchInstance.get(i.MEMBERS).then((t) => t.members).catch((t) => t);
50
+ getMonthlyAccountBalances = async (t) => this.fetchInstance.get(`${i.ACCOUNTS}/${t}/monthly_account_balances`).then((e) => e.monthly_account_balances).catch((e) => e);
51
+ mergeAccounts = async (t) => this.fetchInstance.put(`${i.ACCOUNTS}/merge`, { accounts: t }).then((e) => e).catch((e) => e);
52
+ refreshAllMembers = async () => this.fetchInstance.get(`${i.MEMBERS}/refresh_all`).then((t) => t).catch((t) => t);
53
+ updateAccount = async (t) => this.fetchInstance.put(`${i.ACCOUNTS}/${t.guid}`, t).then((e) => e.account).catch((e) => e);
54
+ }
55
+ class Y {
56
+ fetchInstance;
57
+ constructor(t, e, s) {
58
+ this.fetchInstance = new g(t, e, void 0, s);
59
+ }
60
+ getAppData = async () => this.fetchInstance.get(i.APP_DATA).then((t) => t);
61
+ }
62
+ class j {
63
+ fetchInstance;
64
+ constructor(t) {
65
+ this.fetchInstance = new g(t, "", {
66
+ Accept: "application/json",
67
+ "Content-Type": "application/json"
68
+ });
69
+ }
70
+ getBanner = async (t) => {
71
+ try {
72
+ const e = `/banner/${t}/account_widget_banner`;
73
+ return this.fetchInstance?.get(e).then((s) => s.banner) ?? {};
74
+ } catch (e) {
75
+ return console.error("Error fetching banner:", e), null;
76
+ }
77
+ };
78
+ }
79
+ class X {
80
+ fetchInstance;
81
+ constructor(t, e, s) {
82
+ this.fetchInstance = new g(t, e, void 0, s);
83
+ }
84
+ addBudget = async (t, e, s = null) => this.fetchInstance.post(i.BUDGETS, {
85
+ amount: e,
86
+ category_guid: t.guid,
87
+ category_name: t.name,
88
+ parent_guid: s
89
+ }).then((a) => a.budget).catch((a) => {
90
+ throw a;
91
+ });
92
+ deleteBudget = async (t) => this.fetchInstance.delete(`${i.BUDGETS}/${t}`).then((e) => e).catch((e) => {
93
+ throw e;
94
+ });
95
+ getBudgets = async () => this.fetchInstance.get(i.BUDGETS).then((t) => t.budgets).catch((t) => t);
96
+ updateBudget = async (t) => this.fetchInstance.put(`${i.BUDGETS}/${t.guid}`, t).then((e) => e.budget).catch((e) => {
97
+ throw e;
98
+ });
99
+ addMerchantBudget = async (t, e) => this.fetchInstance.post(i.MERCHANT_BUDGETS, {
100
+ amount: e,
101
+ merchant_guid: t
102
+ }).then((s) => s.merchant_budget).catch((s) => {
103
+ throw s;
104
+ });
105
+ updateMerchantBudget = async (t, e) => this.fetchInstance.put(`${i.MERCHANT_BUDGETS}/${t}`, {
106
+ amount: e
107
+ }).then((s) => s.merchant_budget).catch((s) => {
108
+ throw s;
109
+ });
110
+ deleteMerchantBudget = async (t) => this.fetchInstance.delete(`${i.MERCHANT_BUDGETS}/${t}`).then((e) => e).catch((e) => {
111
+ throw e;
112
+ });
113
+ }
114
+ class J {
115
+ fetchInstance;
116
+ constructor(t, e, s) {
117
+ this.fetchInstance = new g(t, e, void 0, s);
118
+ }
119
+ addCategory = async (t) => this.fetchInstance.post(i.CATEGORIES, t).then((e) => e.category);
120
+ getCategories = async () => this.fetchInstance.get(i.CATEGORIES).then((t) => t.categories);
121
+ getDateRangeCategoryTotals = async (t, e, s) => s.length === 0 ? [] : this.fetchInstance.post(`${i.DATE_RANGE_CATEGORY_TOTALS}/from/${t}/to/${e}`, {
122
+ account_guid: s.map((a) => a.guid)
123
+ }).then((a) => a.date_range_category_totals);
124
+ getMonthlyCategoryTotals = async (t, e, s) => {
125
+ try {
126
+ const a = `${i.MONTHLY_CATEGORY_TOTALS}/from/${t}/to/${e}`;
127
+ if (s) {
128
+ const o = s.length === 0 ? [""] : s.map((l) => l.guid);
129
+ return (await this.fetchInstance.post(a, { account_guid: o })).monthly_category_totals;
130
+ } else
131
+ return (await this.fetchInstance.get(a)).monthly_category_totals;
132
+ } catch (a) {
133
+ throw console.error("Error fetching monthly category totals:", a), a;
134
+ }
135
+ };
136
+ removeCategory = async (t) => this.fetchInstance.delete(`${i.CATEGORIES}/${t}`);
137
+ updateCategory = async (t) => this.fetchInstance.put(`${i.CATEGORIES}/${t.guid}`, t).then((e) => e.category);
138
+ }
139
+ class Z {
140
+ fetchInstance;
141
+ constructor(t, e, s) {
142
+ this.fetchInstance = new g(t, e, void 0, s);
143
+ }
144
+ calculateHealthScore = async () => this.fetchInstance.post(`${i.HEALTH_SCORES}/calculate`).then((t) => t.health_score);
145
+ getAverageHealthScores = async () => this.fetchInstance.get(`${i.HEALTH_SCORES}/monthly_averages`).then((t) => t);
146
+ getDebtSpend = async () => this.fetchInstance.get(`${i.HEALTH_SCORES}/transactions/debt_spend`).then((t) => t);
147
+ getIncome = async () => this.fetchInstance.get(`${i.HEALTH_SCORES}/transactions/income`).then((t) => t);
148
+ getMonthlySummaries = async () => this.fetchInstance.get(`${i.HEALTH_SCORES}/monthly_summaries`).then((t) => t);
149
+ getHealthScoreChangeReports = async (t, e) => this.fetchInstance.get(`${i.HEALTH_SCORES}/change_report/from/${t}/to/${e}`).then((s) => s);
150
+ getPeerScore = async (t) => this.fetchInstance.get(`${i.HEALTH_SCORES}/average/${t}`).then((e) => e);
151
+ getSpendingFeeTransactions = async () => this.fetchInstance.get(`${i.HEALTH_SCORES}/transactions/spending_fee`).then((t) => t);
152
+ getStandardSpend = async () => this.fetchInstance.get(`${i.HEALTH_SCORES}/transactions/standard_spend`).then((t) => t);
153
+ }
154
+ class tt {
155
+ fetchInstance;
156
+ constructor(t, e, s) {
157
+ this.fetchInstance = new g(t, e, void 0, s);
158
+ }
159
+ addGoal = async (t) => this.fetchInstance.post(i.GOALS, t).then((e) => e.goal);
160
+ addRetirementGoal = async (t) => this.fetchInstance.post(i.RETIREMENT_GOALS, t).then((e) => e.retirement_goal);
161
+ addRetirementGoalAccount = async (t) => this.fetchInstance.post(i.RETIREMENT_GOAL_ACCOUNTS, t).then((e) => e.retirement_goal_account);
162
+ getGoalByGuid = async (t) => this.fetchInstance.get(`${i.GOALS}/${t}`).then((e) => e.goal);
163
+ getGoals = async () => this.fetchInstance.get(i.GOALS).then((t) => t.goals);
164
+ getMonthlyCashFlowProfile = async () => this.fetchInstance.get(i.MONTHLY_CASH_FLOW_PROFILE).then((t) => t.monthly_cash_flow_profile);
165
+ getRetirementGoals = async () => this.fetchInstance.get(i.RETIREMENT_GOALS).then((t) => t.retirement_goals);
166
+ getRetirementGoalAccounts = async () => this.fetchInstance.get(i.RETIREMENT_GOAL_ACCOUNTS).then((t) => t.retirement_goal_accounts);
167
+ removeGoal = async (t) => this.fetchInstance.delete(`${i.GOALS}/${t}`).then((e) => e);
168
+ removeRetirementGoal = async (t) => this.fetchInstance.delete(`${i.RETIREMENT_GOALS}/${t}`).then((e) => e);
169
+ removeRetirementGoalAccount = async (t) => this.fetchInstance.delete(`${i.RETIREMENT_GOAL_ACCOUNTS}/${t}`).then((e) => e);
170
+ reorderGoals = async (t) => this.fetchInstance.post(`${i.GOALS}/reposition`, { goals: t }).then((e) => e.goals);
171
+ updateGoal = async (t) => this.fetchInstance.put(`${i.GOALS}/${t.guid}`, t).then((e) => e.goal);
172
+ updateMonthlyCashFlowProfile = async (t) => this.fetchInstance.put(`${i.MONTHLY_CASH_FLOW_PROFILE}`, t).then((e) => e.monthly_cash_flow_profile);
173
+ updateRetirementGoal = async (t) => this.fetchInstance.put(`${i.RETIREMENT_GOALS}/${t.guid}`, t).then((e) => e.retirement_goal);
174
+ }
175
+ class et {
176
+ fetchInstance;
177
+ constructor(t, e, s) {
178
+ this.fetchInstance = new g(t, e, void 0, s);
179
+ }
180
+ createSupportTicket = async (t) => this.fetchInstance.post(i.SUPPORT_TICKETS, t).then((e) => e);
181
+ }
182
+ class st {
183
+ fetchInstance;
184
+ constructor(t, e, s) {
185
+ this.fetchInstance = new g(t, e, void 0, s);
186
+ }
187
+ getHoldings = async () => this.fetchInstance.get(i.HOLDINGS).then((t) => t.holdings);
188
+ updateHoldings = async (t) => this.fetchInstance.put(`${i.HOLDINGS}/${t.guid}`, t).then((e) => e.holding);
189
+ }
190
+ class at {
191
+ fetchInstance;
192
+ constructor(t, e, s) {
193
+ this.fetchInstance = new g(t, e, void 0, s);
194
+ }
195
+ getMerchants = async (t = [], e = [], s = 1, a = 25) => {
196
+ let o = i.MERCHANTS;
197
+ return o += `?page=${s}&per_page=${a}`, t.length && t.forEach((r) => o += `&fuzzy_name[]=${r}`), e.length && e.forEach((r) => o += `&guid[]=${r}`), this.fetchInstance.get(o).then((r) => r.merchants);
198
+ };
199
+ getMerchantByGuid = async (t) => this.fetchInstance.get(`${i.MERCHANTS}/${t}`).then((e) => e.merchant);
200
+ }
201
+ class nt {
202
+ fetchInstance;
203
+ constructor(t, e, s) {
204
+ this.fetchInstance = new g(t, e, void 0, s);
205
+ }
206
+ getNotifications = () => this.fetchInstance.get(i.NOTIFICATIONS).then(
207
+ (t) => t.notifications.map((e) => e.notification)
208
+ ).finally();
209
+ updateNotification = (t) => this.fetchInstance.put(`${i.NOTIFICATIONS}/${t.guid}`, {
210
+ guid: t.guid,
211
+ has_been_viewed: t.has_been_viewed
212
+ }).then((e) => e.notification).finally();
213
+ // Note: The notifications/mark_all_as_viewed endpoint is broken, but still returns 202.
214
+ // A bug ticket has been filed to fix it, but should not require any changes here.
215
+ markAllAsViewed = (t) => this.fetchInstance.put(`${i.NOTIFICATIONS}/mark_all_as_viewed`, { channel: t }).finally();
216
+ }
217
+ class it {
218
+ fetchInstance;
219
+ constructor(t, e, s) {
220
+ this.fetchInstance = new g(t, e, void 0, s);
221
+ }
222
+ addRepeatingTransaction = async (t) => this.fetchInstance.post(i.REPEATING_TRANSACTIONS, t).then((e) => e.repeating_transaction);
223
+ getRepeatingTransactions = async () => this.fetchInstance.get(i.REPEATING_TRANSACTIONS).then((t) => t.repeating_transactions);
224
+ updateRepeatingTransaction = async (t) => this.fetchInstance.put(
225
+ `${i.REPEATING_TRANSACTIONS}/${t.guid}`,
226
+ t
227
+ ).then((e) => e.repeating_transaction);
228
+ deleteRepeatingTransaction = async (t) => this.fetchInstance.delete(`${i.REPEATING_TRANSACTIONS}/${t}`).then((e) => e);
229
+ }
230
+ class rt {
231
+ fetchInstance;
232
+ constructor(t, e, s) {
233
+ this.fetchInstance = new g(t, e, void 0, s);
234
+ }
235
+ deleteDevice = async (t) => this.fetchInstance.delete(`${i.DEVICES}/${t}`).then((e) => e);
236
+ generateDeviceToken = async () => this.fetchInstance.get(`${i.USER}/mobile_token`).then((t) => t.mobile_token);
237
+ getDevices = async () => this.fetchInstance.get(i.DEVICES).then((t) => t.map((e) => e.device));
238
+ getNotificationProfiles = async () => this.fetchInstance.get(i.NOTIFICATION_PROFILES).then((t) => t.notification_profiles);
239
+ // verifications endpoints respond with HTTP status codes; they error otherwise
240
+ sendEmailVerification = async () => this.fetchInstance.post(i.EMAIL_VERIFICATIONS);
241
+ sendPhoneVerification = async () => this.fetchInstance.post(i.PHONE_VERIFICATIONS + "/deliver");
242
+ verifyPhoneToken = async (t) => this.fetchInstance.post(i.PHONE_VERIFICATIONS + "/verify", { sms_verification_token: t }).then((e) => ({ verified: e.verified }));
243
+ updateDevice = async (t) => this.fetchInstance.put(`${i.DEVICES}/${t.guid}`, t).then((e) => e.device);
244
+ updateNotificationProfile = async (t) => this.fetchInstance.put(`${i.NOTIFICATION_PROFILES}/${t.guid}`, t).then((e) => e.notification_profile);
245
+ updateUserCommunicationProfile = async (t) => this.fetchInstance.put(i.USER_COMMUNICATION_PROFILE, t).then((e) => e.user_communication_profile);
246
+ getInsightsNotificationProfiles = async () => this.fetchInstance.get(`${i.NOTIFICATION_PROFILES}/${i.INSIGHTS_NOTIFICATION_PROFILES}`).then((t) => t);
247
+ }
248
+ class B {
249
+ fetchInstance;
250
+ constructor(t, e, s) {
251
+ this.fetchInstance = new g(t, e, void 0, s);
252
+ }
253
+ addTag = async (t) => this.fetchInstance.post(i.TAGS, t).then((e) => e.tag).catch((e) => e);
254
+ addTagging = async (t) => this.fetchInstance.post(i.TAGGINGS, t).then((e) => e.tagging).catch((e) => e);
255
+ addTransaction = async (t) => this.fetchInstance.post(i.TRANSACTIONS, t).then((e) => e.transaction).catch((e) => e);
256
+ addTransactionRule = async (t) => this.fetchInstance.post(i.TRANSACTION_RULES, t).then((e) => e).catch((e) => e);
257
+ getTaggings = async () => this.fetchInstance.get(i.TAGGINGS).then((t) => t.map((e) => e.tagging));
258
+ getTags = async () => this.fetchInstance.get(i.TAGS).then((t) => t.map((e) => e.tag));
259
+ getTransactionRules = async () => this.fetchInstance.get(i.TRANSACTION_RULES).then((t) => t.transaction_rules);
260
+ getTransactionsByDateRange = async (t, e) => this.fetchInstance.get(`${i.TRANSACTIONS}/by_date/${t}/${e}`).then((s) => s.map((a) => a.transaction));
261
+ // DEPRECATED
262
+ getTransactionsByAccountsAndDateRange = async (t, e, s) => {
263
+ console.warn("DEPRECATED: getTransactionsByAccountsAndDateRange will be removed");
264
+ const a = t.reduce(
265
+ (o, r, l) => `${o}account_guids[]=${r}${l !== t.length - 1 ? "&" : ""}`,
266
+ ""
267
+ );
268
+ return this.fetchInstance.get(`${i.TRANSACTIONS}/by_date/${e}/${s}?${a}`).then((o) => o.map((r) => r.transaction));
269
+ };
270
+ // DEPRECATED
271
+ getTransactionsByGuids = async (t) => (console.warn("DEPRECATED: getTransactionsByGuids will be removed"), this.fetchInstance.post(`${i.TRANSACTIONS}/by_guids`, { guids: t.join("+") }).then((e) => e.map((s) => s.transaction)));
272
+ // DEPRECATED
273
+ getTransactionsByCategoryAndDate = async (t, e, s) => (console.warn("DEPRECATED: getTransactionsByCategoryAndDate will be removed"), this.fetchInstance.get(
274
+ `${i.TRANSACTIONS}/by_category_guid/${t}/by_date/${e}/${s}`
275
+ ).then((a) => a.map((o) => o.transaction)));
276
+ // DEPRECATED
277
+ getTransactionsByCategoryDateAndAccounts = async (t, e, s, a) => {
278
+ console.warn("DEPRECATED: getTransactionsByCategoryDateAndAccounts will be removed");
279
+ const o = a.reduce(
280
+ (r, l, p) => `${r}account_guids[]=${l}${p !== a.length - 1 ? "&" : ""}`,
281
+ ""
282
+ );
283
+ return this.fetchInstance.get(
284
+ `${i.TRANSACTIONS}/by_category_guid/${t}/by_date/${e}/${s}?${o}`
285
+ ).then((r) => r.map((l) => l.transaction));
286
+ };
287
+ // DEPRECATED
288
+ getTransactionsByCategoriesDateAndAccounts = async (t, e, s, a) => {
289
+ console.warn("DEPRECATED: getTransactionsByCategoriesDateAndAccounts will be removed");
290
+ const o = a.reduce(
291
+ (r, l, p) => `${r}account_guids[]=${l}${p !== a.length - 1 ? "&" : ""}`,
292
+ ""
293
+ );
294
+ return this.fetchInstance.get(
295
+ `${i.TRANSACTIONS}/by_category_guids/${t.join(
296
+ "+"
297
+ )}/by_date/${e}/${s}?${o}`
298
+ ).then((r) => r.map((l) => l.transaction));
299
+ };
300
+ /**
301
+ * DEPRECATED
302
+ * Get all transactions by the top level category, between begin date and end date, and optionally
303
+ * filtered by accounts
304
+ * @param categoryGuid The top level category guid
305
+ * @param beginDate the start date
306
+ * @param endDate the end date
307
+ * @param accountGuids an optional list of account guids
308
+ */
309
+ getTransactionsByTopLevelCategoryAndDate = async (t, e, s, a = []) => {
310
+ console.warn("DEPRECATED: getTransactionsByTopLevelCategoryAndDate will be removed");
311
+ let o = `${i.TRANSACTIONS}/by_top_level_category_guid/${t}/by_date/${e}/${s}`;
312
+ if (a.length > 0) {
313
+ const r = a.reduce(
314
+ (l, p, b) => `${l}account_guids[]=${p}${b !== a.length - 1 ? "&" : ""}`,
315
+ ""
316
+ );
317
+ o += `?${r}`;
318
+ }
319
+ return this.fetchInstance.get(o).then((r) => r.map((l) => l.transaction));
320
+ };
321
+ removeTag = async (t) => this.fetchInstance.delete(`${i.TAGS}/${t}`).then((e) => e).catch((e) => e);
322
+ removeTagging = async (t) => this.fetchInstance.delete(`${i.TAGGINGS}/${t}`).then((e) => e).catch((e) => e);
323
+ removeTransaction = async (t) => this.fetchInstance.delete(`${i.TRANSACTIONS}/${t}`).then((e) => e);
324
+ removeTransactionRule = async (t) => this.fetchInstance.delete(`${i.TRANSACTION_RULES}/${t}`).catch((e) => e);
325
+ removeTransactionSplit = async (t) => this.fetchInstance.delete(`${i.TRANSACTIONS}/${t}/unsplit`).then((e) => e).catch((e) => e);
326
+ updateTransactionRule = async (t) => this.fetchInstance.put(`${i.TRANSACTION_RULES}/${t.guid}`, t).then((e) => e).catch((e) => e);
327
+ updateTag = async (t) => this.fetchInstance.put(`${i.TAGS}/${t.guid}`, t).then((e) => e.tag).catch((e) => e);
328
+ updateTransaction = async (t) => this.fetchInstance.put(`${i.TRANSACTIONS}/${t.guid}`, t).then((e) => e.transaction).catch((e) => e);
329
+ }
330
+ class ot {
331
+ fetchInstance;
332
+ constructor(t, e, s) {
333
+ this.fetchInstance = new g(t, e, void 0, s);
334
+ }
335
+ getUserFeatures = async () => this.fetchInstance.get(i.USER_FEATURES).then((t) => t.user_features).catch((t) => t);
336
+ updateUser = async (t) => this.fetchInstance.put(i.USER, t).then((e) => e.user);
337
+ updateUserProfile = async (t) => this.fetchInstance.put(`${i.USER_PROFILES}/${t.guid}`, t).then((e) => e.user_profile);
338
+ }
339
+ class ct {
340
+ fetchInstance;
341
+ constructor(t, e) {
342
+ this.fetchInstance = new g(t, e);
343
+ }
344
+ requestWidgetUrl = async (t) => this.fetchInstance.post(i.WIDGET_URLS, t).then((e) => e.widget_url);
345
+ }
346
+ class oe {
347
+ globalStore;
348
+ api = new G("/", "");
349
+ accounts = [];
350
+ accountsLoaded = !1;
351
+ accountsLoading = !1;
352
+ institutions = [];
353
+ institutionsLoaded = !1;
354
+ institutionsLoading = !1;
355
+ members = [];
356
+ membersLoaded = !1;
357
+ membersLoading = !1;
358
+ uiStore;
359
+ constructor(t) {
360
+ this.globalStore = t, this.uiStore = new ce(), this.api = new G(t.endpoint, t.sessionToken, t.onError), d(this);
361
+ }
362
+ loadAccountData = async () => {
363
+ await Promise.all([this.loadAccounts(), this.loadMembers(), this.loadInstitutions()]);
364
+ };
365
+ get isAccountDataLoaded() {
366
+ return this.accountsLoaded && this.membersLoaded && this.institutionsLoaded;
367
+ }
368
+ get detailedAccounts() {
369
+ const t = this.globalStore.userStore.userFeatures, e = wt(t, "MD_EXCLUDE_EXTERNAL_ACCOUNTS"), s = this.globalStore.appConfig.config.display_only_external_accounts_in_accounts && this.globalStore.appConfig.options.subtype === "accounts";
370
+ return At(
371
+ this.accounts,
372
+ this.institutions,
373
+ this.members,
374
+ e,
375
+ s
376
+ );
377
+ }
378
+ get accountsByTypeMap() {
379
+ return this.detailedAccounts.reduce((t, e) => {
380
+ const s = e.account_type;
381
+ let a = t.get(s);
382
+ return a || (a = []), a.push(e), t.set(s, a), t;
383
+ }, /* @__PURE__ */ new Map());
384
+ }
385
+ get cashAccounts() {
386
+ return this.detailedAccounts.filter(
387
+ (t) => t.account_type === h.CASH || t.account_type === h.CHECKING || t.account_type === h.PREPAID || t.account_type === h.SAVINGS || t.account_type === h.CHECKING_LINE_OF_CREDIT
388
+ );
389
+ }
390
+ get cashBalance() {
391
+ return this.cashAccounts.reduce((t, e) => t + (e?.balance || 0), 0);
392
+ }
393
+ get checkingAccounts() {
394
+ return this.detailedAccounts.filter((t) => t.account_type === h.CHECKING);
395
+ }
396
+ get debtAccounts() {
397
+ return this.detailedAccounts.filter(
398
+ (t) => t.account_type === h.CREDIT_CARD || t.account_type === h.LOAN || t.account_type === h.MORTGAGE || t.account_type === h.LINE_OF_CREDIT || t.account_type === h.CHECKING_LINE_OF_CREDIT
399
+ );
400
+ }
401
+ get finstrongAccounts() {
402
+ const t = /* @__PURE__ */ new Set([
403
+ h.CHECKING,
404
+ h.SAVINGS,
405
+ h.CREDIT_CARD,
406
+ h.INVESTMENT
407
+ ]);
408
+ return this.detailedAccounts.filter((e) => t.has(e.account_type));
409
+ }
410
+ get investmentAccounts() {
411
+ return this.detailedAccounts.filter(
412
+ (t) => t.account_type === h.INVESTMENT
413
+ );
414
+ }
415
+ get manualAccounts() {
416
+ return this.detailedAccounts.filter((t) => t.is_manual);
417
+ }
418
+ get savingsAccounts() {
419
+ return this.detailedAccounts.filter((t) => t.account_type === h.SAVINGS);
420
+ }
421
+ get retirementAccounts() {
422
+ return this.detailedAccounts.filter(
423
+ (t) => t.account_type === h.INVESTMENT || t.account_type === h.SAVINGS || t.account_type === h.CHECKING || t.account_type === h.CASH || t.account_type === h.PROPERTY || t.account_type === h.INSURANCE && (t.account_subtype === M.WHOLE_LIFE || t.account_subtype === M.UNIVERSAL_LIFE || t.account_subtype === M.VARIABLE_UNIVERSAL_LIFE)
424
+ );
425
+ }
426
+ get visibleAccounts() {
427
+ return this.detailedAccounts.filter((t) => !t.is_hidden && !t.is_closed);
428
+ }
429
+ get visibleCashAccounts() {
430
+ return this.cashAccounts.filter((t) => !t.is_hidden);
431
+ }
432
+ get visibleCashBalance() {
433
+ return this.visibleCashAccounts.reduce((t, e) => t + (e?.balance || 0), 0);
434
+ }
435
+ get visibleCheckingAccounts() {
436
+ return this.checkingAccounts.filter((t) => !t.is_hidden);
437
+ }
438
+ get visibleDebtAccounts() {
439
+ return this.debtAccounts.filter((t) => !t.is_hidden);
440
+ }
441
+ get visibleFinstrongAccounts() {
442
+ return this.finstrongAccounts.filter(
443
+ (t) => !(t.is_closed || t.is_deleted || t.is_hidden)
444
+ );
445
+ }
446
+ get visibleRetirementAccounts() {
447
+ return this.retirementAccounts.filter((t) => !t.is_hidden);
448
+ }
449
+ get visibleInvestmentAccounts() {
450
+ return this.investmentAccounts.filter((t) => !t.is_hidden);
451
+ }
452
+ get visibleSavingsAccounts() {
453
+ return this.savingsAccounts.filter((t) => !t.is_hidden);
454
+ }
455
+ get savingsAndCheckingAccountsBalance() {
456
+ return this.savingsAndCheckingAccounts.reduce(
457
+ (e, s) => e + (s?.balance || 0),
458
+ 0
459
+ );
460
+ }
461
+ get savingsAndCheckingAccounts() {
462
+ return this.accounts.filter(
463
+ (e) => e.account_type === h.SAVINGS || e.account_type === h.CHECKING
464
+ );
465
+ }
466
+ setAccounts = (t) => {
467
+ this.accounts = t, this.accountsLoading = !1, this.accountsLoaded = !0;
468
+ };
469
+ setMembers = (t) => {
470
+ this.members = t, this.membersLoading = !1, this.membersLoaded = !0;
471
+ };
472
+ setInstitutions = (t) => {
473
+ this.institutions = t, this.institutionsLoading = !1, this.institutionsLoaded = !0;
474
+ };
475
+ addAccount = async (t) => {
476
+ try {
477
+ const e = await this.api.createAccount(t);
478
+ c(() => {
479
+ this.accounts = [...this.accounts, e];
480
+ });
481
+ } catch (e) {
482
+ console.error(`Error occurred while adding an account: ${e}`);
483
+ }
484
+ };
485
+ loadAccounts = async () => {
486
+ if (!this.accountsLoading) {
487
+ this.accountsLoading = !0;
488
+ try {
489
+ const t = await this.api.getAccounts();
490
+ this.setAccounts(t);
491
+ } catch (t) {
492
+ console.error(`Error occurred while loading accounts: ${t}`);
493
+ }
494
+ }
495
+ };
496
+ loadInstitutions = async () => {
497
+ if (!this.institutionsLoading) {
498
+ this.institutionsLoading = !0;
499
+ try {
500
+ const t = await this.api.getInstitutions();
501
+ this.setInstitutions(t);
502
+ } catch (t) {
503
+ console.error(`Error occurred while loading institutions: ${t}`);
504
+ }
505
+ }
506
+ };
507
+ loadMembers = async () => {
508
+ if (!this.membersLoading) {
509
+ this.membersLoading = !0;
510
+ try {
511
+ const t = await this.api.getMembers();
512
+ this.setMembers(t);
513
+ } catch (t) {
514
+ console.error(`Error occurred while loading members: ${t}`);
515
+ }
516
+ }
517
+ };
518
+ mergeAccounts = async (t) => {
519
+ try {
520
+ const e = await this.api.mergeAccounts(t), s = e[Object.keys(e)[0]];
521
+ c(() => {
522
+ const a = this.accounts.findIndex((r) => r.guid === t[1]);
523
+ this.accounts.splice(a, 1);
524
+ const o = this.accounts.findIndex((r) => r.guid === t[0]);
525
+ this.accounts.splice(o, 1, s);
526
+ });
527
+ } catch (e) {
528
+ console.error(`Error occurred while merging accounts: ${e}`);
529
+ }
530
+ };
531
+ /**
532
+ * DEPRECATED: Use loadAccountData instead
533
+ */
534
+ refreshAccounts = async () => {
535
+ await Promise.all([this.loadAccounts(), this.loadInstitutions(), this.loadMembers()]);
536
+ };
537
+ refreshMembers = async () => {
538
+ try {
539
+ await this.api.refreshAllMembers();
540
+ } catch (t) {
541
+ console.error(`Error occurredwhile refreshing members: ${t}`);
542
+ }
543
+ };
544
+ removeAccount = async (t) => {
545
+ try {
546
+ await this.api.deleteAccount(t);
547
+ const e = this.accounts.findIndex((s) => s.guid === t);
548
+ this.accounts.splice(e, 1);
549
+ } catch (e) {
550
+ console.error(`Error occurred while removing an account: ${e}`);
551
+ }
552
+ };
553
+ updateAccount = async (t) => {
554
+ try {
555
+ const e = await this.api.updateAccount(t), s = this.accounts.findIndex(
556
+ (a) => a.guid === e.guid
557
+ );
558
+ this.accounts.splice(s, 1, e);
559
+ } catch (e) {
560
+ console.error(`Error occurred while updating account: ${e}`);
561
+ }
562
+ };
563
+ updateAccountBalance = (t, e) => {
564
+ const s = this.accounts.find((a) => a.guid === t);
565
+ s && c(() => {
566
+ s.balance = (s.balance || 0) + e;
567
+ });
568
+ };
569
+ updateAccountFilter = async (t) => {
570
+ const e = [];
571
+ for (const [o, r] of t.entries()) {
572
+ const l = this.accounts.find((p) => p.guid === o);
573
+ l && l.is_excluded_from_accounts === r && (l.is_excluded_from_accounts = !r, e.push(this.api.updateAccount(l)));
574
+ }
575
+ const s = await Promise.all(e), a = [...this.accounts];
576
+ for (const o of s) {
577
+ const r = a.findIndex((l) => l.guid === o.guid);
578
+ r !== -1 && a.splice(r, 1, o);
579
+ }
580
+ this.setAccounts(a);
581
+ };
582
+ }
583
+ let ce = class {
584
+ selectedAccount = {};
585
+ selectedMember = {};
586
+ constructor() {
587
+ d(this);
588
+ }
589
+ setSelectedAccount = (t) => this.selectedAccount = t;
590
+ setSelectedMember = (t) => this.selectedMember = t;
591
+ };
592
+ class le {
593
+ globalStore;
594
+ api = new Y("/", "");
595
+ bannerApi = new j("/");
596
+ appData = {};
597
+ isAppDataLoaded = !1;
598
+ banner = {};
599
+ constructor(t) {
600
+ this.globalStore = t, this.api = new Y(t.endpoint, t.sessionToken, t.onError), d(this);
601
+ }
602
+ get appConfig() {
603
+ return this.globalStore.appConfig;
604
+ }
605
+ get clientCommunicationProfile() {
606
+ return this.appData.client_communication_profile;
607
+ }
608
+ get clientInsightProfile() {
609
+ return this.appData.client_insight_profile;
610
+ }
611
+ get user() {
612
+ return this.appData.user;
613
+ }
614
+ get userCommunicationProfile() {
615
+ return this.appData.user_communication_profile;
616
+ }
617
+ get userProfile() {
618
+ return this.appData.user_profile;
619
+ }
620
+ setAppData = (t) => {
621
+ this.appData = t, this.bannerApi = new j(t.address?.bullseye || "/"), this.isAppDataLoaded = !0;
622
+ };
623
+ loadAppData = async () => {
624
+ try {
625
+ const t = await this.api.getAppData();
626
+ this.setAppData(t);
627
+ } catch (t) {
628
+ console.error(`Error loading app data: ${t}`);
629
+ }
630
+ };
631
+ loadBanner = async () => {
632
+ try {
633
+ const t = this.user?.guid ?? null, e = t ? await this.bannerApi.getBanner(t) : {};
634
+ c(() => {
635
+ this.banner = e;
636
+ });
637
+ } catch (t) {
638
+ console.error(`Error loading banner: ${t}`);
639
+ }
640
+ };
641
+ setUser = (t) => this.appData.user = t;
642
+ setUserCommunicationProfile = (t) => this.appData.user_communication_profile = t;
643
+ setUserProfile = (t) => this.appData.user_profile = t;
644
+ }
645
+ class de {
646
+ globalStore;
647
+ survey = null;
648
+ currentQuestionIndex = 0;
649
+ question = null;
650
+ response = null;
651
+ responses = {};
652
+ constructor(t) {
653
+ this.globalStore = t, d(this);
654
+ }
655
+ get isLastQuestion() {
656
+ return this.currentQuestionIndex === this.surveyQuestions.length - 1;
657
+ }
658
+ get questionCount() {
659
+ return `${this.currentQuestionIndex + 1}/${this.surveyQuestions.length}`;
660
+ }
661
+ get responsePayload() {
662
+ return {
663
+ $survey_id: this.surveyId,
664
+ ...this.responses
665
+ };
666
+ }
667
+ // TODO hardcode elsewhere
668
+ get surveyId() {
669
+ return window.app?.postHogPublicKey === "phc_KclQGnOZEaYCttkpiVpuyOYeBlixGo6xNphYgWV4CXo" ? "0196caa6-9b37-0000-98a7-f04e8d56faf5" : "0196a6b0-ccde-0000-b980-0b84ea2fef4a";
670
+ }
671
+ get surveyQuestions() {
672
+ return this.survey ? this.survey.questions : [];
673
+ }
674
+ loadSurvey = (t = !1) => {
675
+ Ct.getActiveMatchingSurveys((e) => {
676
+ c(() => {
677
+ if (e.length > 0) {
678
+ const s = e.find((a) => a.id === this.surveyId);
679
+ s && (this.survey = s, this.currentQuestionIndex = 0, this.question = s.questions[0], this.response = null, this.responses = {});
680
+ }
681
+ });
682
+ }, t);
683
+ };
684
+ nextQuestion = () => {
685
+ this.currentQuestionIndex < this.surveyQuestions.length - 1 && (this.currentQuestionIndex += 1), this.response = null, this.question = this.surveyQuestions[this.currentQuestionIndex];
686
+ };
687
+ resetStore = () => {
688
+ this.survey = null, this.currentQuestionIndex = 0, this.question = null, this.response = null, this.responses = {};
689
+ };
690
+ setResponse = (t) => {
691
+ this.response = t, this.question && (this.responses[`$survey_response_${this.question.id}`] = t);
692
+ };
693
+ }
694
+ function he(n, t, e, s = "asc") {
695
+ const a = s === "desc" ? -1 : 1;
696
+ return [...n, ...t].sort((o, r) => o[e] < r[e] ? -1 * a : o[e] > r[e] ? 1 * a : 0);
697
+ }
698
+ const ue = (n) => ({
699
+ ...n,
700
+ //fields that are offer specific, adding here for visibility
701
+ image_url: n.image_url,
702
+ guid: n.guid,
703
+ created_at: n.created_at,
704
+ dismissed_at: n.dismissed_at,
705
+ active_at: n.campaign_activated_at,
706
+ displayed_at: n.has_been_viewed,
707
+ post_message_secondary: n.pulse_post_message_secondary,
708
+ //offer fields mapped to beat fields for functionality
709
+ title: n.pulse_title || n.campaign_name,
710
+ html_title: n.pulse_title || n.campaign_name,
711
+ short_title: n.pulse_title || n.campaign_name,
712
+ html_short_title: n.pulse_title || n.campaign_name,
713
+ micro_title: n.pulse_title || n.campaign_name,
714
+ html_micro_title: n.pulse_title || n.campaign_name,
715
+ supporting_action: n.pulse_call_to_action_text_secondary,
716
+ description: n.pulse_body,
717
+ html_description: n.pulse_body,
718
+ micro_description: n.pulse_body,
719
+ html_micro_description: n.pulse_body,
720
+ call_to_action: n.pulse_call_to_action_text,
721
+ html_micro_call_to_action: n.pulse_call_to_action_text,
722
+ micro_call_to_action: n.pulse_call_to_action_text,
723
+ is_dismissed: n.has_been_dismissed,
724
+ icon_type: 5,
725
+ template: "MarketingOffer",
726
+ //beat fields we null out
727
+ account_guids: [],
728
+ data_series: {},
729
+ has_been_displayed: !1,
730
+ is_obsolete: !1,
731
+ is_refreshable: !1,
732
+ is_sampled: !1,
733
+ merchant_guids: [],
734
+ payload: {},
735
+ pulse_campaign_name: n.campaign_name,
736
+ scheduled_payment_guids: [],
737
+ transaction_guids: [],
738
+ user_guid: "",
739
+ user_verification: 0
740
+ });
741
+ class ge {
742
+ globalStore;
743
+ api = new v("/", "");
744
+ beats = [];
745
+ isLoading = !1;
746
+ constructor(t) {
747
+ this.globalStore = t, this.api = new v(t.endpoint, t.sessionToken, t.onError), d(this);
748
+ }
749
+ loadBeats = async () => {
750
+ this.isLoading = !0;
751
+ const t = await this.api.getBeats(), s = (await this.api.getOffers()).map((a) => ue(a));
752
+ c(() => {
753
+ this.beats = he(t, s, "active_at", "desc"), this.isLoading = !1;
754
+ });
755
+ };
756
+ getFilteredBeats(t) {
757
+ const { categoryGuids: e, templates: s } = t;
758
+ let a = this.beats;
759
+ return e && (a = this.filterBeatsByCategory(a, e)), s && (a = this.filterBeatsByTemplate(a, s)), a;
760
+ }
761
+ // Return beats with any beat.category_guids that are in categoryGuids
762
+ filterBeatsByCategory(t, e) {
763
+ return t.filter((s) => s.category_guids?.some((a) => e.includes(a)));
764
+ }
765
+ // Return beats with a beat.template that is in templates
766
+ filterBeatsByTemplate(t, e) {
767
+ return t.filter((s) => e.some((a) => s.template === a));
768
+ }
769
+ }
770
+ class pe {
771
+ api = new X("/", "");
772
+ globalStore;
773
+ alert = "";
774
+ dateRange = { start: E(y()), end: T(y()) };
775
+ budgets = [];
776
+ selectedBudget;
777
+ selectedSubBudget;
778
+ isDataLoaded = !1;
779
+ theme = {};
780
+ merchantBudgets = [];
781
+ constructor(t) {
782
+ this.globalStore = t, this.api = new X(t.endpoint, t.sessionToken, t.onError), d(this);
783
+ }
784
+ loadBudgetData = async () => {
785
+ this.globalStore.recurringTransactionsStore.isDataLoaded || await this.globalStore.recurringTransactionsStore.loadRepeatingTransactionData(), await this.loadBudgets(), ut(
786
+ () => this.detailedBudgets,
787
+ (t) => {
788
+ if (t) {
789
+ const e = this.selectedBudget;
790
+ e && (this.selectedBudget = bt(t, e.guid));
791
+ const s = this.selectedSubBudget;
792
+ s && s.parent_guid && (this.selectedSubBudget = It(
793
+ t,
794
+ s.guid,
795
+ s.parent_guid
796
+ ));
797
+ }
798
+ }
799
+ );
800
+ };
801
+ get detailedBudgets() {
802
+ return k(
803
+ this.budgets.filter(
804
+ (t) => t.category_guid !== w.INCOME && t.category_guid !== w.TRANSFER && t.category_guid !== w.INVESTMENTS
805
+ ),
806
+ this.globalStore.categoryStore.detailedCategories,
807
+ this.globalStore.copyStore.copy.budgets,
808
+ this.theme
809
+ ).sort((t, e) => t.percentage > e.percentage ? -1 : t.percentage < e.percentage ? 1 : 0);
810
+ }
811
+ // TODO: Replace this with income from recurring transactions. Income budgets are deprecated.
812
+ get incomeBudget() {
813
+ return k(
814
+ this.budgets.filter((s) => !s.parent_guid),
815
+ this.globalStore.categoryStore.detailedCategories,
816
+ this.globalStore.copyStore.copy.budgets,
817
+ this.theme
818
+ ).reduce(
819
+ (s, a) => a.category_guid !== w.INCOME ? s : !s || a.percentage > s.percentage ? a : s,
820
+ void 0
821
+ )?.amount;
822
+ }
823
+ get unbudgetedCategories() {
824
+ return this.globalStore.categoryStore.spendCategories.filter(
825
+ (t) => !this.detailedBudgets.find((e) => e.category_guid === t.guid)
826
+ );
827
+ }
828
+ get totalBudgeted() {
829
+ return this.detailedBudgets.reduce((t, e) => t + e.amount, 0);
830
+ }
831
+ addBudget = async (t, e, s = null) => {
832
+ try {
833
+ const a = await this.api.addBudget(t, e, s);
834
+ c(() => {
835
+ this.budgets.push(a);
836
+ });
837
+ } catch (a) {
838
+ console.error(`Error adding budget: ${a}`);
839
+ }
840
+ };
841
+ deleteBudget = async (t) => {
842
+ try {
843
+ await this.api.deleteBudget(t), c(() => {
844
+ const e = this.budgets.findIndex((s) => s.guid === t);
845
+ e >= 0 && this.budgets.splice(e, 1);
846
+ });
847
+ } catch (e) {
848
+ console.error(`Error deleting budget: ${e}`);
849
+ }
850
+ };
851
+ loadBudgets = async () => {
852
+ try {
853
+ const t = await this.api.getBudgets();
854
+ this.setBudgets(t);
855
+ } catch (t) {
856
+ throw console.error(`Error occurred while loading budgets: ${t}`), t;
857
+ }
858
+ };
859
+ setAlert = (t) => this.alert = t;
860
+ setBudgets = (t) => {
861
+ this.budgets = t, this.isDataLoaded = !0;
862
+ };
863
+ setDateRange = (t) => this.dateRange = t;
864
+ setSelectedBudget = (t) => this.selectedBudget = t;
865
+ setSelectedSubBudget = (t) => this.selectedSubBudget = t;
866
+ setTheme = (t) => this.theme = t;
867
+ /**
868
+ * Recalculate budget by using the average amount from top-level categories
869
+ * @param categories Detailed categories
870
+ */
871
+ recalculateBudgets = async (t) => {
872
+ try {
873
+ for (const s of t) {
874
+ const a = this.budgets.find((o) => o.category_guid === s.guid);
875
+ a ? await this.api.updateBudget({
876
+ ...a,
877
+ amount: s.totalAverageAmount
878
+ }) : await this.api.addBudget(s, s.totalAverageAmount);
879
+ }
880
+ const e = this.budgets.filter(
881
+ (s) => !t.find((a) => a.guid === s.category_guid)
882
+ );
883
+ for (const s of e)
884
+ await this.api.deleteBudget(s.guid);
885
+ return await this.loadBudgets(), { data: this.budgets, isSuccess: !0 };
886
+ } catch (e) {
887
+ return console.error("error recalculating budgets", e), { data: [], isSuccess: !1 };
888
+ }
889
+ };
890
+ updateBudget = async (t) => {
891
+ try {
892
+ const e = await this.api.updateBudget(t);
893
+ c(() => {
894
+ const s = this.budgets.findIndex((a) => a.guid === t.guid);
895
+ s >= 0 && (this.budgets[s] = e);
896
+ });
897
+ } catch (e) {
898
+ console.error(`Error updating budget: ${e}`);
899
+ }
900
+ };
901
+ getMerchantBudgetByMerchantGuid = (t) => this.merchantBudgets.find(
902
+ (e) => e?.merchant_guid === t
903
+ );
904
+ setMerchantBudgets = (t) => {
905
+ this.merchantBudgets = t;
906
+ };
907
+ addMerchantBudget = async (t, e) => {
908
+ try {
909
+ const s = await this.api.addMerchantBudget(t, e);
910
+ return c(() => {
911
+ this.merchantBudgets.push(s);
912
+ }), { isSuccess: !0 };
913
+ } catch (s) {
914
+ return console.error(`Error adding merchant budget: ${s}`), { isSuccess: !1 };
915
+ }
916
+ };
917
+ updateMerchantBudget = async (t) => {
918
+ try {
919
+ const { guid: e, amount: s } = t, a = await this.api.updateMerchantBudget(e, s);
920
+ return c(() => {
921
+ const o = this.merchantBudgets.findIndex((r) => r.guid === t.guid);
922
+ o >= 0 && (this.merchantBudgets[o] = a);
923
+ }), { isSuccess: !0 };
924
+ } catch (e) {
925
+ return console.error(`Error updating merchant budget: ${e}`), { isSuccess: !1 };
926
+ }
927
+ };
928
+ deleteMerchantBudget = async (t) => {
929
+ try {
930
+ return await this.api.deleteMerchantBudget(t), c(() => {
931
+ this.merchantBudgets = this.merchantBudgets.filter((e) => e.guid !== t);
932
+ }), { isSuccess: !0 };
933
+ } catch (e) {
934
+ return console.error(`Error deleting merchant budget: ${e}`), { isSuccess: !1 };
935
+ }
936
+ };
937
+ }
938
+ class _e {
939
+ globalStore;
940
+ uiStore;
941
+ constructor(t) {
942
+ this.globalStore = t, this.uiStore = new fe(), d(this);
943
+ }
944
+ completeOnboarding = async () => {
945
+ const t = {
946
+ ...this.globalStore.userStore.userProfile,
947
+ has_completed_cash_flow_onboarding: !0
948
+ };
949
+ await this.globalStore.userStore.updateUserProfile(t);
950
+ };
951
+ }
952
+ let fe = class {
953
+ // Cashflow is hard-coded to display 30 days starting from today
954
+ dateRange = { start: y(), end: Dt(y(), 30) };
955
+ isDirty = !1;
956
+ nextIncome = void 0;
957
+ upcomingExpenses = [];
958
+ selectedCashAccounts = [];
959
+ constructor() {
960
+ d(this);
961
+ }
962
+ // Returns the number of days until the next income activity or 0 if there is no income activity
963
+ get daysUntilNextIncome() {
964
+ return this.nextIncome ? Math.abs(Rt(y(), this.nextIncome.expectedDate)) : 0;
965
+ }
966
+ // Returns the expenses (Activities) until the next income activity or the end of the month
967
+ // if there is no income activity
968
+ get expensesTilNextIncome() {
969
+ return this.upcomingExpenses.filter(
970
+ (t) => F(t.expectedDate, this.nextIncome?.expectedDate || T(/* @__PURE__ */ new Date()))
971
+ );
972
+ }
973
+ setNextIncome = (t) => {
974
+ this.nextIncome = t;
975
+ };
976
+ setUpcomingExpenses = (t) => {
977
+ this.upcomingExpenses = t;
978
+ };
979
+ setSelectedCashAccounts = (t) => this.selectedCashAccounts = t;
980
+ };
981
+ class ye {
982
+ globalStore;
983
+ uiStore;
984
+ api = new J("/", "");
985
+ categories = [];
986
+ categoriesLoaded = !1;
987
+ categoriesLoading = !1;
988
+ dateRangeCategoryTotals = [];
989
+ monthlyCategoryTotals = [];
990
+ dateRangeTotalsLoaded = !1;
991
+ dateRangeTotalsLoading = !1;
992
+ monthlyTotalsLoaded = !1;
993
+ monthlyTotalsLoading = !1;
994
+ constructor(t) {
995
+ this.globalStore = t, this.uiStore = new me(), this.api = new J(t.endpoint, t.sessionToken, t.onError), d(this);
996
+ }
997
+ get detailedCategories() {
998
+ return this.globalStore.isInitialized ? Lt(
999
+ this.categories,
1000
+ this.globalStore.copyStore.copy.categories,
1001
+ this.dateRangeCategoryTotals,
1002
+ this.monthlyCategoryTotals
1003
+ ) : [];
1004
+ }
1005
+ get detailedCategoriesWithTransactions() {
1006
+ return vt(
1007
+ this.detailedCategories,
1008
+ this.globalStore.transactionStore.sortedTransactions
1009
+ );
1010
+ }
1011
+ get incomeCategories() {
1012
+ return this.detailedCategories.filter((t) => t.is_income);
1013
+ }
1014
+ get spendCategories() {
1015
+ return this.detailedCategories.filter(
1016
+ (t) => !t.is_income && !t.isTransfer && t.guid !== w.INVESTMENTS
1017
+ );
1018
+ }
1019
+ get transferCategories() {
1020
+ return this.detailedCategories.filter((t) => t.isTransfer);
1021
+ }
1022
+ setCategories = (t) => {
1023
+ this.categories = t, this.categoriesLoading = !1, this.categoriesLoaded = !0;
1024
+ };
1025
+ setMonthlyCategoryTotals = (t) => {
1026
+ this.monthlyCategoryTotals = t, this.monthlyTotalsLoading = !1, this.monthlyTotalsLoaded = !0;
1027
+ };
1028
+ setDateRangeCategoryTotals = (t) => {
1029
+ this.dateRangeCategoryTotals = t, this.dateRangeTotalsLoading = !1, this.dateRangeTotalsLoaded = !0;
1030
+ };
1031
+ get trendsCategories() {
1032
+ return this.detailedCategories.filter((t) => t.totalAmount !== 0).filter((t) => t.guid !== w.INVESTMENTS && t.guid !== w.TRANSFER);
1033
+ }
1034
+ addCategory = async (t, e) => {
1035
+ const s = { name: t, parent_guid: e };
1036
+ try {
1037
+ await this.api.addCategory(s), await this.loadCategories();
1038
+ } catch (a) {
1039
+ console.error(`Error occurred while adding category: ${a}`);
1040
+ }
1041
+ };
1042
+ loadCategories = async () => {
1043
+ if (!this.categoriesLoading) {
1044
+ this.categoriesLoading = !0;
1045
+ try {
1046
+ const t = await this.api.getCategories();
1047
+ this.setCategories(t);
1048
+ } catch (t) {
1049
+ console.error(`Error occurred while getting categories: ${t}`);
1050
+ }
1051
+ }
1052
+ };
1053
+ loadDateRangeCategoryTotals = async (t, e, s) => {
1054
+ if (!this.dateRangeTotalsLoading) {
1055
+ this.dateRangeTotalsLoading = !0;
1056
+ try {
1057
+ const a = await this.api.getDateRangeCategoryTotals(
1058
+ m(e),
1059
+ m(s),
1060
+ t
1061
+ );
1062
+ this.setDateRangeCategoryTotals(a);
1063
+ } catch (a) {
1064
+ console.error(`Error occurred while getting date range category totals: ${a}`);
1065
+ }
1066
+ }
1067
+ };
1068
+ loadMonthlyCategoryTotals = async (t = this.globalStore.globalUiStore.selectedAccounts, e, s) => {
1069
+ if (this.monthlyTotalsLoading) return;
1070
+ this.monthlyTotalsLoading = !0;
1071
+ const a = m(E(e ?? $(/* @__PURE__ */ new Date(), 11))), o = m(T(s ?? /* @__PURE__ */ new Date()));
1072
+ try {
1073
+ const r = await this.api.getMonthlyCategoryTotals(a, o, t);
1074
+ this.setMonthlyCategoryTotals(r);
1075
+ } catch (r) {
1076
+ console.error(`Error occurred while getting monthly category totals: ${r}`);
1077
+ }
1078
+ };
1079
+ reloadCategoryTotals = async (t, e, s) => {
1080
+ const a = e ?? $(/* @__PURE__ */ new Date(), 11), o = s ?? T(/* @__PURE__ */ new Date());
1081
+ try {
1082
+ await Promise.all([
1083
+ this.loadMonthlyCategoryTotals(t, a, o),
1084
+ this.loadDateRangeCategoryTotals(t, a, o)
1085
+ ]);
1086
+ } catch (r) {
1087
+ console.error(`Error occurred while getting category totals: ${r}`);
1088
+ }
1089
+ };
1090
+ removeCategory = async (t) => {
1091
+ try {
1092
+ await this.api.removeCategory(t), await this.loadCategories();
1093
+ } catch (e) {
1094
+ console.error(`Error occurred while removing category: ${e}`);
1095
+ }
1096
+ };
1097
+ updateCategory = async (t) => {
1098
+ try {
1099
+ await this.api.updateCategory(t), await this.loadCategories();
1100
+ } catch (e) {
1101
+ console.error(`Error occurred while updating category: ${e}`);
1102
+ }
1103
+ };
1104
+ // TODO: Remove this after refactoring Trends components to use detailedCategories
1105
+ getCategoryName = (t) => this.categories.find((s) => s.guid === t)?.name ?? Et[t];
1106
+ }
1107
+ let me = class {
1108
+ expandedGuid = null;
1109
+ selectedGuid = null;
1110
+ searchValue = "";
1111
+ showSelected = !0;
1112
+ shouldDisableDrawerScroll = !1;
1113
+ unselectable = [];
1114
+ unselectableText = "";
1115
+ savedOnSelect;
1116
+ // todo
1117
+ constructor() {
1118
+ d(this);
1119
+ }
1120
+ setExpandedGuid = (t) => this.expandedGuid = t;
1121
+ setSelectedGuid = (t) => this.selectedGuid = t;
1122
+ setSearchValue = (t) => this.searchValue = t;
1123
+ setShouldDisableDrawerScroll = (t) => this.shouldDisableDrawerScroll = t;
1124
+ setShowSelected = (t) => this.showSelected = t;
1125
+ setUnselectable = (t) => this.unselectable = t;
1126
+ setUnselectableText = (t) => this.unselectableText = t;
1127
+ onSelect = (t) => this.savedOnSelect(t);
1128
+ setOnSelect = (t) => this.savedOnSelect = t;
1129
+ };
1130
+ class Se {
1131
+ globalStore;
1132
+ widgetApi = new ct("/", "");
1133
+ constructor(t) {
1134
+ this.globalStore = t, this.widgetApi = new ct(t.endpoint, t.sessionToken), d(this);
1135
+ }
1136
+ loadWidget = async ({ widget: t = "connect_widget", mode: e = "light", ...s }) => await this.widgetApi.requestWidgetUrl({
1137
+ widget_url: { widget_type: t, color_scheme: e, ...s }
1138
+ });
1139
+ }
1140
+ class Te {
1141
+ globalStore;
1142
+ uiStore;
1143
+ constructor(t) {
1144
+ this.globalStore = t, this.uiStore = new Ae(), d(this);
1145
+ }
1146
+ get debts() {
1147
+ const { visibleDebtAccounts: t } = this.globalStore.accountStore, { selectedAccountGuids: e } = this.globalStore.globalUiStore, { debtGoals: s } = this.globalStore.goalStore, a = e.length ? t.filter((o) => e.includes(o.guid)) : t;
1148
+ return Pt(a, s);
1149
+ }
1150
+ get totalMonthlyPayments() {
1151
+ return this.debts.map((e) => Number(e.monthly_payment)).filter((e) => !isNaN(e)).reduce((e, s) => e + s, 0);
1152
+ }
1153
+ }
1154
+ let Ae = class {
1155
+ isLoading = !1;
1156
+ selectedDebtChartData = {};
1157
+ selectedDebtPriority = Ut.LOWEST_BALANCE;
1158
+ constructor() {
1159
+ d(this);
1160
+ }
1161
+ get showError() {
1162
+ const { interest_rate: t, monthly_payment: e } = this.selectedDebtChartData;
1163
+ return t === void 0 || e === void 0;
1164
+ }
1165
+ get showCompleted() {
1166
+ return this.selectedDebtChartData.is_paid_off;
1167
+ }
1168
+ setIsLoading = (t) => this.isLoading = t;
1169
+ setSelectedDebtChartData = (t) => this.selectedDebtChartData = t;
1170
+ setSelectedDebtPriority = (t) => this.selectedDebtPriority = t;
1171
+ };
1172
+ const we = (n) => n.sort((t, e) => t.monthly_health_score_average.year !== e.monthly_health_score_average.year ? t.monthly_health_score_average.year - e.monthly_health_score_average.year : t.monthly_health_score_average.month - e.monthly_health_score_average.month).map((t) => ({
1173
+ x: P(
1174
+ new Date(0, t.monthly_health_score_average.month - 1, 1),
1175
+ U.MONTH_SHORT
1176
+ ),
1177
+ y: Math.round(t.monthly_health_score_average.average_health_score)
1178
+ })), be = (n) => n.map(({ transaction: e }) => ({
1179
+ ...e
1180
+ })).sort((e, s) => s.date - e.date);
1181
+ class Ie {
1182
+ api = new Z("/", "");
1183
+ augmentedChartData = [];
1184
+ averageHealthScores = [];
1185
+ monthlySummaries = [];
1186
+ incomeTransactions = [];
1187
+ debtSpendTransactions = [];
1188
+ spendingFeeTransactions = [];
1189
+ spendTransactions = [];
1190
+ globalStore;
1191
+ healthScore = {};
1192
+ healthScoreChange;
1193
+ healthScoreChangeReports = [];
1194
+ peerScore = null;
1195
+ isSpendingInitialized = !1;
1196
+ isIncomeInitialized = !1;
1197
+ constructor(t) {
1198
+ this.globalStore = t, this.api = new Z(t.endpoint, t.sessionToken, t.onError), d(this);
1199
+ }
1200
+ setSpendingInitialized = (t) => {
1201
+ this.isSpendingInitialized = t;
1202
+ };
1203
+ setIncomeInitialized = (t) => {
1204
+ this.isIncomeInitialized = t;
1205
+ };
1206
+ calculateHealthScore = async (t = !0) => {
1207
+ try {
1208
+ const e = await this.api.calculateHealthScore();
1209
+ let s = 0;
1210
+ t && await this.loadHealthScoreChangeReports();
1211
+ const a = e?.health_score || 0, o = this.healthScoreChangeReports.at(-1)?.older_health_score || 0;
1212
+ s = a - o, c(() => {
1213
+ this.healthScore = e, this.healthScoreChange = s;
1214
+ });
1215
+ } catch (e) {
1216
+ console.error("Error calculating health score:", e);
1217
+ }
1218
+ };
1219
+ loadAverageHealthScores = async () => {
1220
+ try {
1221
+ const t = await this.api.getAverageHealthScores();
1222
+ c(() => {
1223
+ this.averageHealthScores = t;
1224
+ });
1225
+ } catch (t) {
1226
+ console.error("Error loading average health scores:", t);
1227
+ }
1228
+ };
1229
+ loadMonthlySummaries = async () => {
1230
+ try {
1231
+ const t = await this.api.getMonthlySummaries();
1232
+ c(() => {
1233
+ this.monthlySummaries = t;
1234
+ });
1235
+ } catch (t) {
1236
+ console.error("Error loading monthly summaries:", t);
1237
+ }
1238
+ };
1239
+ loadDebtSpend = async () => {
1240
+ try {
1241
+ const t = await this.api.getDebtSpend();
1242
+ c(() => {
1243
+ this.debtSpendTransactions = t;
1244
+ });
1245
+ } catch (t) {
1246
+ console.error("Error loading debt spend:", t);
1247
+ }
1248
+ };
1249
+ loadIncome = async () => {
1250
+ this.setIncomeInitialized(!1);
1251
+ try {
1252
+ const t = await this.api.getIncome();
1253
+ c(() => {
1254
+ this.incomeTransactions = t, this.setIncomeInitialized(!0);
1255
+ });
1256
+ } catch (t) {
1257
+ console.error("Error loading income:", t);
1258
+ }
1259
+ };
1260
+ loadHealthScoreChangeReports = async () => {
1261
+ const t = m($(/* @__PURE__ */ new Date(), 2)), e = m(/* @__PURE__ */ new Date());
1262
+ try {
1263
+ const s = await this.api.getHealthScoreChangeReports(
1264
+ t,
1265
+ e
1266
+ );
1267
+ c(() => {
1268
+ this.healthScoreChangeReports = s;
1269
+ });
1270
+ } catch (s) {
1271
+ console.error("Error loading health score change reports:", s);
1272
+ }
1273
+ };
1274
+ loadPeerScore = async () => {
1275
+ const t = Ft(kt(this.globalStore.appDataStore.user.birthday), "yyyy");
1276
+ try {
1277
+ const e = await this.api.getPeerScore(t);
1278
+ c(() => {
1279
+ this.peerScore = e;
1280
+ });
1281
+ } catch (e) {
1282
+ console.error("Error loading peer score:", e);
1283
+ }
1284
+ };
1285
+ loadAugmentedChartData = async () => {
1286
+ try {
1287
+ const t = await this.api.getAverageHealthScores();
1288
+ c(() => {
1289
+ this.augmentedChartData = we(t);
1290
+ });
1291
+ } catch (t) {
1292
+ console.error(`Error occurred while getting augmented chart data: ${t}`);
1293
+ }
1294
+ };
1295
+ getSpendingFeeTransactions = async () => {
1296
+ try {
1297
+ const t = await this.api.getSpendingFeeTransactions(), e = be(t);
1298
+ c(() => {
1299
+ this.spendingFeeTransactions = e;
1300
+ });
1301
+ } catch (t) {
1302
+ console.error(`Error occurred while getting spending fee transactions: ${t}`);
1303
+ }
1304
+ };
1305
+ loadSpendTransactions = async () => {
1306
+ this.setSpendingInitialized(!1);
1307
+ try {
1308
+ const t = await this.api.getStandardSpend();
1309
+ c(() => {
1310
+ this.spendTransactions = [...t], this.setSpendingInitialized(!0);
1311
+ });
1312
+ } catch (t) {
1313
+ console.error("Error loading spend transactions:", t);
1314
+ }
1315
+ };
1316
+ get spendAndDebtTransactions() {
1317
+ return [...this.spendTransactions, ...this.debtSpendTransactions];
1318
+ }
1319
+ get allTransactions() {
1320
+ return {
1321
+ income: this.incomeTransactions,
1322
+ debtSpend: this.debtSpendTransactions,
1323
+ spendingFee: this.spendingFeeTransactions,
1324
+ spend: this.spendTransactions
1325
+ };
1326
+ }
1327
+ handleFinstrongWidgetPrimaryCtaClick = (t) => () => {
1328
+ };
1329
+ }
1330
+ const lt = {
1331
+ clientConfig: {},
1332
+ clientStyleProfile: {},
1333
+ config: {
1334
+ assets_prefix: "/assets",
1335
+ bundle: "widgetLoader",
1336
+ client_guid: "",
1337
+ dashboard_accounts_index: 6,
1338
+ dashboard_accounts_location: 0,
1339
+ dashboard_activity_index: 2,
1340
+ dashboard_activity_location: 0,
1341
+ dashboard_budgets_index: 5,
1342
+ dashboard_budgets_location: 1,
1343
+ dashboard_cash_flow_index: 0,
1344
+ dashboard_cash_flow_location: 0,
1345
+ dashboard_connect_index: 7,
1346
+ dashboard_connect_location: 1,
1347
+ dashboard_insights_index: 3,
1348
+ dashboard_insights_location: 1,
1349
+ dashboard_spending_index: 1,
1350
+ dashboard_spending_location: 1,
1351
+ dashboard_survey_index: 8,
1352
+ dashboard_survey_location: 1,
1353
+ dashboard_trends_index: 4,
1354
+ dashboard_trends_location: 0,
1355
+ display_account_number_in_accounts: !0,
1356
+ display_add_manual_transaction_in_transactions: !0,
1357
+ display_available_balance_in_accounts: !0,
1358
+ display_email_edit_field_in_settings: !0,
1359
+ display_mobile_devices_in_settings: !0,
1360
+ display_notification_settings_in_settings: !0,
1361
+ display_only_external_accounts_in_accounts: !1,
1362
+ display_password_options_in_settings: !0,
1363
+ display_sms_edit_field_in_settings: !0,
1364
+ display_terms_and_conditions: !0,
1365
+ display_user_profile_in_settings: !0,
1366
+ display_user_transaction_rules_in_settings: !0,
1367
+ display_widget_headings: !0,
1368
+ enable_add_account_in_zero_state: !0,
1369
+ enable_aggregation_prompts: !0,
1370
+ enable_external_accounts_in_goals_widget: !0,
1371
+ enable_funds_transfers_in_goals_widget: !1,
1372
+ enable_manual_accounts: !0,
1373
+ enable_mark_account_closed_for_held_accounts: !0,
1374
+ enable_mark_account_duplicate_for_held_accounts: !0,
1375
+ enable_renaming_home_accounts: !0,
1376
+ enable_support_requests: !1,
1377
+ language: "en-US",
1378
+ product_name: "Money Dashboard",
1379
+ session_token: "",
1380
+ show_account_nicknames_in_master: !1,
1381
+ show_accounts_widget_in_master: !0,
1382
+ show_budgets_widget_in_master: !0,
1383
+ show_carousel_card_border_in_pulse_micro_widget: !1,
1384
+ show_cash_flow_widget_in_master: !0,
1385
+ show_connections_widget_in_master: !0,
1386
+ show_debts_widget_in_master: !0,
1387
+ show_finstrong_widget_in_master: !0,
1388
+ show_full_experience_link_in_pulse_micro_widget: !1,
1389
+ show_full_experience_link_in_pulse_mini_widget: !1,
1390
+ show_goals_widget_in_master: !0,
1391
+ show_help_widget_in_master: !0,
1392
+ show_horizontal_padding_in_pulse_micro_widget: !0,
1393
+ show_icon_in_pulse_micro_widget: !0,
1394
+ show_insights_widget_in_master: !0,
1395
+ show_investments_widget_in_master: !1,
1396
+ show_mx_branding: !0,
1397
+ show_navigation_controls_in_pulse_micro_widget: !0,
1398
+ show_net_worth_widget_in_master: !0,
1399
+ show_notifications_widget_in_master: !0,
1400
+ show_recurring_transactions_widget_in_master: !0,
1401
+ show_settings_widget_in_master: !0,
1402
+ show_spending_plan_widget_in_master: !1,
1403
+ show_spending_widget_in_master: !0,
1404
+ show_transactions_widget_in_master: !0,
1405
+ show_trends_widget_in_master: !0,
1406
+ type: "money-dashboard",
1407
+ websocket: {
1408
+ hmac: "",
1409
+ token: "",
1410
+ url: ""
1411
+ },
1412
+ widgets_display_name: "Money Dashboard "
1413
+ },
1414
+ honeyBadgerPublicKey: "",
1415
+ options: {
1416
+ assets_prefix: "/assets",
1417
+ brokaw_auth: {
1418
+ token: "",
1419
+ hmac: "",
1420
+ url: ""
1421
+ },
1422
+ brokaw_websocket_url: "",
1423
+ bundle: "widgetLoader",
1424
+ custom_copy_namespace: "",
1425
+ language: "en-US",
1426
+ product_name: "Master Widget",
1427
+ session_token: "",
1428
+ subtype: "master",
1429
+ type: "money_dashboard"
1430
+ },
1431
+ postHogPublicKey: "phc_1fVYJICC69TpW4wagp9o2XqQ8E7X98cAmcR5psSpfkE",
1432
+ userFeatures: []
1433
+ };
1434
+ class Ns {
1435
+ // Global properties
1436
+ appConfig = lt;
1437
+ endpoint = "/";
1438
+ sessionToken = "";
1439
+ onError;
1440
+ onStoreUpdate;
1441
+ // Data Stores
1442
+ accountStore;
1443
+ appDataStore;
1444
+ analyticsStore;
1445
+ beatStore;
1446
+ budgetsStore;
1447
+ cashflowStore;
1448
+ categoryStore;
1449
+ connectStore;
1450
+ copyStore;
1451
+ debtsStore;
1452
+ finstrongStore;
1453
+ goalStore;
1454
+ helpStore;
1455
+ holdingStore;
1456
+ merchantStore;
1457
+ netWorthStore;
1458
+ notificationStore;
1459
+ recurringTransactionsStore;
1460
+ settingsStore;
1461
+ transactionStore;
1462
+ trendsStore;
1463
+ userStore;
1464
+ // UI Stores
1465
+ globalUiStore;
1466
+ constructor(t = lt, e = "/", s, a) {
1467
+ this.appConfig = t, this.endpoint = e, this.sessionToken = t.options.session_token ?? "", this.onError = s, this.onStoreUpdate = a, this.accountStore = new oe(this), this.appDataStore = new le(this), this.analyticsStore = new de(this), this.beatStore = new ge(this), this.budgetsStore = new pe(this), this.cashflowStore = new _e(this), this.categoryStore = new ye(this), this.connectStore = new Se(this), this.copyStore = new Ee(this), this.debtsStore = new Te(this), this.finstrongStore = new Ie(this), this.goalStore = new De(this), this.helpStore = new ve(this), this.holdingStore = new $e(this), this.merchantStore = new Ne(this), this.netWorthStore = new Ge(this), this.notificationStore = new Be(this), this.recurringTransactionsStore = new xe(this), this.settingsStore = new Pe(this), this.transactionStore = new Ue(this), this.trendsStore = new ke(this), this.userStore = new He(this), this.globalUiStore = new Ce(this), d(this), St(() => {
1468
+ const { transactions: o } = this.transactionStore;
1469
+ this.emitUpdate({
1470
+ transactions: o
1471
+ });
1472
+ });
1473
+ }
1474
+ get isInitialized() {
1475
+ return this.globalUiStore.isInitialized;
1476
+ }
1477
+ // emits change triggered in the autorun
1478
+ emitUpdate = (t) => {
1479
+ this.onStoreUpdate?.(t);
1480
+ };
1481
+ loadConfigData = async () => {
1482
+ await Promise.all([
1483
+ // Load copy, config and user data
1484
+ this.copyStore.loadCopy(),
1485
+ this.appDataStore.loadAppData(),
1486
+ this.accountStore.refreshMembers(),
1487
+ this.userStore.loadUserFeatures()
1488
+ ]);
1489
+ };
1490
+ loadData = async ({
1491
+ accounts: t,
1492
+ appData: e,
1493
+ associatedBeats: s,
1494
+ categories: a,
1495
+ institutions: o,
1496
+ transactionRules: r,
1497
+ transactions: l,
1498
+ userFeatures: p,
1499
+ merchantBudgets: b
1500
+ } = {}) => {
1501
+ (!e || !p) && await this.loadConfigData(), e && this.appDataStore.setAppData(e), p && this.userStore.setUserFeatures(p), t && (await this.accountStore.loadMembers(), o && this.accountStore.setInstitutions(o), this.accountStore.setAccounts(t)), s && this.transactionStore.setAssociatedBeats(s), a && this.categoryStore.setCategories(a), l && this.transactionStore.setTransactions(l), r && this.transactionStore.setTransactionRules(r), b && this.budgetsStore.setMerchantBudgets(b);
1502
+ };
1503
+ }
1504
+ class Ce {
1505
+ globalStore;
1506
+ accountFilterMap = /* @__PURE__ */ new Map();
1507
+ displayedDate = /* @__PURE__ */ new Date();
1508
+ displayedDateRange = {
1509
+ start: E(this.displayedDate),
1510
+ end: T(this.displayedDate)
1511
+ };
1512
+ constructor(t) {
1513
+ d(this), this.globalStore = t, ut(
1514
+ () => this.globalStore.accountStore.visibleAccounts,
1515
+ (e) => {
1516
+ this.populateAccountFilterMap(e);
1517
+ }
1518
+ );
1519
+ }
1520
+ get allSelectedAccounts() {
1521
+ return this.globalStore.accountStore.detailedAccounts.filter(
1522
+ (t) => !t.is_excluded_from_accounts
1523
+ );
1524
+ }
1525
+ get selectedAccounts() {
1526
+ return this.globalStore.accountStore.visibleAccounts.filter(
1527
+ (t) => !t.is_excluded_from_accounts
1528
+ );
1529
+ }
1530
+ get selectedAccountGuids() {
1531
+ return this.selectedAccounts.map((t) => t.guid);
1532
+ }
1533
+ get isCopyLoaded() {
1534
+ return this.globalStore.copyStore.isInitialized;
1535
+ }
1536
+ get isConfigLoaded() {
1537
+ return this.globalStore.appDataStore.isAppDataLoaded;
1538
+ }
1539
+ get areUserFeaturesLoaded() {
1540
+ return this.globalStore.userStore.userFeaturesLoaded;
1541
+ }
1542
+ get isInitialized() {
1543
+ return this.isCopyLoaded && this.isConfigLoaded && this.areUserFeaturesLoaded;
1544
+ }
1545
+ populateAccountFilterMap = (t) => {
1546
+ t && t.forEach((e) => {
1547
+ this.accountFilterMap.set(e.guid, !e.is_excluded_from_accounts);
1548
+ });
1549
+ };
1550
+ resetAccountFilterMap = () => {
1551
+ this.accountFilterMap.clear(), this.populateAccountFilterMap(this.globalStore.accountStore.visibleAccounts);
1552
+ };
1553
+ updateAccountFilterMap = (t, e) => {
1554
+ this.accountFilterMap.set(t, e);
1555
+ };
1556
+ setDisplayedDate = (t, e) => {
1557
+ this.displayedDate = e, this.displayedDateRange = {
1558
+ start: t,
1559
+ end: e
1560
+ };
1561
+ };
1562
+ get shouldDisableNextDate() {
1563
+ const t = L(this.displayedDate), e = L(ie(/* @__PURE__ */ new Date(), 1));
1564
+ return t === e;
1565
+ }
1566
+ get shouldDisablePrevDate() {
1567
+ const t = L(this.displayedDate), e = L(/* @__PURE__ */ new Date());
1568
+ return t === e;
1569
+ }
1570
+ }
1571
+ class Ee {
1572
+ globalStore;
1573
+ api = new H("/", "");
1574
+ copy = {};
1575
+ featureNamespace = "experiences";
1576
+ isInitialized = !1;
1577
+ constructor(t) {
1578
+ this.globalStore = t, this.api = new H(
1579
+ t.endpoint,
1580
+ t.sessionToken,
1581
+ t.onError
1582
+ ), d(this);
1583
+ }
1584
+ loadCopy = async () => {
1585
+ await this.getCopy(this.featureNamespace), c(() => {
1586
+ this.isInitialized = !0;
1587
+ });
1588
+ };
1589
+ getCopy = async (t, e = "") => {
1590
+ try {
1591
+ const s = await this.api.getGlobalCopy(t, e);
1592
+ c(() => {
1593
+ this.copy = s[t];
1594
+ });
1595
+ } catch (s) {
1596
+ console.error(`Error occurred while fetching ${this.featureNamespace} copy: ${s}`);
1597
+ }
1598
+ };
1599
+ }
1600
+ class De {
1601
+ globalStore;
1602
+ api = new tt("/", "");
1603
+ goals = [];
1604
+ goalsLoaded = !1;
1605
+ retirementGoals = [];
1606
+ retirementGoalsLoaded = !1;
1607
+ retirementGoalAccounts = [];
1608
+ retirementGoalAccountsLoaded = !1;
1609
+ monthlyCashFlowProfile = void 0;
1610
+ monthlyCashFlowProfileLoaded = !1;
1611
+ newRetirementGoalAccounts = [];
1612
+ alert = "";
1613
+ selectedGoal = void 0;
1614
+ constructor(t) {
1615
+ this.globalStore = t, this.api = new tt(t.endpoint, t.sessionToken, t.onError), d(this);
1616
+ }
1617
+ get allGoals() {
1618
+ if (!this.isAllGoalDataLoaded) return [];
1619
+ const t = this.globalStore.copyStore.copy.goals, e = this.globalStore.userStore.user.birthday;
1620
+ return [
1621
+ ...this.goals,
1622
+ ...this.retirementGoals.map((s) => ({
1623
+ ...s,
1624
+ amount: s.target_amount,
1625
+ name: t.retirement,
1626
+ track_type: S.RETIREMENT_TRACK,
1627
+ projected_to_complete_at: s.retirement_age && e ? W(s.retirement_age, e) : void 0
1628
+ }))
1629
+ ];
1630
+ }
1631
+ get orderedGoals() {
1632
+ return this.allGoals.slice().sort((t, e) => t.position - e.position);
1633
+ }
1634
+ get debtGoals() {
1635
+ return this.orderedGoals.filter((t) => t.track_type === S.DEBT_TRACK);
1636
+ }
1637
+ get retirmentGoals() {
1638
+ return this.orderedGoals.filter((t) => t.track_type === S.RETIREMENT_TRACK);
1639
+ }
1640
+ get savingGoals() {
1641
+ return this.orderedGoals.filter((t) => t.track_type === S.SAVINGS_TRACK);
1642
+ }
1643
+ get ongoingGoalsForMicroWidget() {
1644
+ const t = this.allGoals.filter(
1645
+ (s) => !s.is_complete && s.track_type !== S.EMERGENCY_FUND_TRACK && s.track_type !== null
1646
+ ), e = [
1647
+ S.SAVINGS_TRACK,
1648
+ S.DEBT_TRACK,
1649
+ S.RETIREMENT_TRACK
1650
+ ];
1651
+ return t.sort((s, a) => {
1652
+ const o = s.track_type ? e.indexOf(s.track_type) : -1, r = a.track_type ? e.indexOf(a.track_type) : -1;
1653
+ return o - r;
1654
+ }).slice(0, 3);
1655
+ }
1656
+ get isAllGoalDataLoaded() {
1657
+ return this.goalsLoaded && this.retirementGoalsLoaded && this.retirementGoalAccountsLoaded && this.monthlyCashFlowProfileLoaded;
1658
+ }
1659
+ setGoals = (t) => {
1660
+ this.goals = t, this.goalsLoaded = !0;
1661
+ };
1662
+ setRetirementGoals = (t) => {
1663
+ this.retirementGoals = t, this.retirementGoalsLoaded = !0;
1664
+ };
1665
+ setRetirementGoalAccounts = (t) => {
1666
+ this.retirementGoalAccounts = t, this.retirementGoalAccountsLoaded = !0;
1667
+ };
1668
+ setMonthlyCashFlowProfile = (t) => {
1669
+ this.monthlyCashFlowProfile = t, this.monthlyCashFlowProfileLoaded = !0;
1670
+ };
1671
+ loadGoalData = async () => {
1672
+ await Promise.all([
1673
+ this.loadGoals(),
1674
+ this.loadRetirementGoals(),
1675
+ this.loadRetirementGoalAccounts(),
1676
+ this.loadMonthlyCashFlowProfile()
1677
+ ]);
1678
+ };
1679
+ loadGoals = async () => {
1680
+ try {
1681
+ const t = await this.api.getGoals();
1682
+ this.setGoals(t);
1683
+ } catch (t) {
1684
+ console.error(`Error occured while getting goals: ${t}`);
1685
+ }
1686
+ };
1687
+ loadRetirementGoals = async () => {
1688
+ try {
1689
+ const t = await this.api.getRetirementGoals();
1690
+ this.setRetirementGoals(t);
1691
+ } catch (t) {
1692
+ console.error(`Error occurred while loading retirement goals: ${t}`);
1693
+ }
1694
+ };
1695
+ loadRetirementGoalAccounts = async () => {
1696
+ try {
1697
+ const t = await this.api.getRetirementGoalAccounts();
1698
+ this.setRetirementGoalAccounts(t);
1699
+ } catch (t) {
1700
+ console.error(`Error occurred while loading retirement goal accounts: ${t}`);
1701
+ }
1702
+ };
1703
+ loadMonthlyCashFlowProfile = async () => {
1704
+ try {
1705
+ const t = await this.api.getMonthlyCashFlowProfile();
1706
+ this.setMonthlyCashFlowProfile(t);
1707
+ } catch (t) {
1708
+ console.error(`Error occurred while loading monthly cash flow profile: ${t}`);
1709
+ }
1710
+ };
1711
+ addGoal = async (t) => {
1712
+ try {
1713
+ const e = await this.api.addGoal(t);
1714
+ this.setGoals([...this.goals, e]);
1715
+ } catch (e) {
1716
+ console.error(`Error occurred while adding goal: ${e}`);
1717
+ }
1718
+ };
1719
+ addRetirementGoal = async (t) => {
1720
+ const e = this.globalStore.copyStore.copy.goals;
1721
+ try {
1722
+ const s = await this.api.addRetirementGoal(t), a = [], o = this.globalStore.userStore.user.birthday;
1723
+ for (const r of this.newRetirementGoalAccounts) {
1724
+ const l = await this.api.addRetirementGoalAccount({
1725
+ ...r,
1726
+ retirement_goal_guid: s.guid
1727
+ });
1728
+ a.push(l);
1729
+ }
1730
+ this.setNewRetirementGoalAccounts([]), this.retirementGoals = [
1731
+ ...this.retirementGoals,
1732
+ {
1733
+ ...s,
1734
+ amount: s.target_amount,
1735
+ name: e.retirement,
1736
+ track_type: S.RETIREMENT_TRACK,
1737
+ projected_to_complete_at: s.retirement_age && o ? W(s.retirement_age, o) : void 0
1738
+ }
1739
+ ], this.setRetirementGoalAccounts([...this.retirementGoalAccounts, ...a]);
1740
+ } catch (s) {
1741
+ console.error(`Error occurred while adding retirement goal: ${s}`);
1742
+ }
1743
+ };
1744
+ addRetirementGoalAccount = async (t) => {
1745
+ try {
1746
+ const e = await this.api.addRetirementGoalAccount(t);
1747
+ c(() => {
1748
+ this.retirementGoalAccounts = [...this.retirementGoalAccounts, e];
1749
+ });
1750
+ } catch (e) {
1751
+ console.error(`Error occurred while adding retirement goal account: ${e}`);
1752
+ }
1753
+ };
1754
+ deleteGoal = async (t) => {
1755
+ try {
1756
+ await this.api.removeGoal(t);
1757
+ const e = this.goals.findIndex((s) => s.guid === t);
1758
+ e >= 0 && this.goals.splice(e, 1);
1759
+ } catch (e) {
1760
+ console.error(`Error occured while deleting goal: ${e}`);
1761
+ }
1762
+ };
1763
+ deleteRetirementGoal = async (t) => {
1764
+ try {
1765
+ const e = this.retirementGoalAccounts.filter(
1766
+ (a) => a.retirement_goal_guid === t.guid
1767
+ );
1768
+ for (const a of e)
1769
+ await this.deleteRetirementGoalAccount(a.guid);
1770
+ await this.api.removeRetirementGoal(t.guid);
1771
+ const s = this.retirementGoals.findIndex((a) => a.guid === t.guid);
1772
+ s >= 0 && this.retirementGoals.splice(s, 1);
1773
+ } catch (e) {
1774
+ console.error(`Error deleting retirement goal: ${e}`);
1775
+ }
1776
+ };
1777
+ deleteRetirementGoalAccount = async (t) => {
1778
+ try {
1779
+ await this.api.removeRetirementGoalAccount(t);
1780
+ const e = this.retirementGoalAccounts.findIndex((s) => s.guid === t);
1781
+ e >= 0 && this.retirementGoalAccounts.splice(e, 1);
1782
+ } catch (e) {
1783
+ console.error(`Error deleting retirement goal account: ${e}`);
1784
+ }
1785
+ };
1786
+ reorderGoals = async (t) => {
1787
+ try {
1788
+ const e = await this.api.reorderGoals(t);
1789
+ c(() => {
1790
+ for (const s of e) {
1791
+ const a = this.goals.findIndex((o) => o.guid === s.guid);
1792
+ a >= 0 && (this.goals[a].position = s.position);
1793
+ }
1794
+ });
1795
+ } catch (e) {
1796
+ console.error(`Error reordering goals: ${e}`);
1797
+ }
1798
+ };
1799
+ setAlert = (t) => this.alert = t;
1800
+ setNewRetirementGoalAccounts = (t) => {
1801
+ this.newRetirementGoalAccounts = t;
1802
+ };
1803
+ setSelectedGoal = (t) => this.selectedGoal = t;
1804
+ updateGoal = async (t) => {
1805
+ try {
1806
+ const e = await this.api.updateGoal(t);
1807
+ c(() => {
1808
+ const s = this.goals.findIndex((a) => a.guid === t.guid);
1809
+ s >= 0 && (this.goals[s] = e), this.selectedGoal?.guid === t.guid && this.setSelectedGoal(e);
1810
+ });
1811
+ } catch (e) {
1812
+ console.error(`Error occurred while updating goal: ${e}`);
1813
+ }
1814
+ };
1815
+ updateRetirementGoal = async (t) => {
1816
+ try {
1817
+ const e = await this.api.updateRetirementGoal({
1818
+ ...t,
1819
+ target_amount: t.amount
1820
+ });
1821
+ c(() => {
1822
+ const s = this.retirementGoals.findIndex((a) => a.guid === t.guid);
1823
+ s >= 0 && (this.retirementGoals[s] = e), this.selectedGoal?.guid === t.guid && this.setSelectedGoal(this.allGoals.find((a) => a.guid === t.guid));
1824
+ });
1825
+ } catch (e) {
1826
+ console.error(`Error occurred while updating goal: ${e}`);
1827
+ }
1828
+ };
1829
+ updateMonthlyCashFlowProfile = async (t) => {
1830
+ try {
1831
+ const e = await this.api.updateMonthlyCashFlowProfile(t);
1832
+ this.setMonthlyCashFlowProfile(e);
1833
+ } catch (e) {
1834
+ console.error(`Error occurred while updating monthly Cash Flow profile: ${e}`);
1835
+ }
1836
+ };
1837
+ }
1838
+ const Re = (n, t) => n.guid === "general" || n.guid === "insights" ? !0 : n.flags ? n.flags.every((e) => t[e]) : !1, Le = (n, t) => {
1839
+ const e = [];
1840
+ for (const s of re) {
1841
+ const a = t[s.guid];
1842
+ if (!a) continue;
1843
+ const o = {
1844
+ ...s,
1845
+ title: a.label,
1846
+ topics: s.topics.map(({ topicKey: r }, l) => ({
1847
+ topicKey: r,
1848
+ label: a.topics[l]
1849
+ }))
1850
+ };
1851
+ Re(o, n) && e.push(o);
1852
+ }
1853
+ return e;
1854
+ };
1855
+ class ve {
1856
+ alert = { message: "", severity: void 0 };
1857
+ api = new et("/", "");
1858
+ appConfig;
1859
+ globalStore;
1860
+ isLoading = !1;
1861
+ constructor(t) {
1862
+ this.globalStore = t, this.api = new et(t.endpoint, t.sessionToken, t.onError), d(this);
1863
+ }
1864
+ createSupportTicket = async (t) => {
1865
+ try {
1866
+ this.isLoading = !0, await this.api.createSupportTicket(t), this.setAlert(this.copy.request_support_submit_success_message, "success");
1867
+ } catch (e) {
1868
+ this.setAlert(this.copy.request_support_submit_failure_message, "error"), console.error("Error occurred while submitting:", e);
1869
+ } finally {
1870
+ this.isLoading = !1;
1871
+ }
1872
+ };
1873
+ setAlert = (t, e = void 0) => this.alert = { message: t, severity: e };
1874
+ get copy() {
1875
+ return this.globalStore.copyStore.copy.help;
1876
+ }
1877
+ get helpCategories() {
1878
+ const { client_communication_profile: t, client_profile: e } = this.globalStore.appDataStore.appData, {
1879
+ help: { category_list: s }
1880
+ } = this.globalStore.copyStore.copy;
1881
+ return Le(
1882
+ {
1883
+ ...t,
1884
+ ...e,
1885
+ ...this.globalStore.appConfig.config
1886
+ },
1887
+ s
1888
+ );
1889
+ }
1890
+ }
1891
+ class $e {
1892
+ analysisType = Ht.Stocks;
1893
+ api = new st("/", "");
1894
+ holdings = [];
1895
+ holdingsLoaded = !1;
1896
+ globalStore;
1897
+ showConnectionsWidget = !1;
1898
+ constructor(t) {
1899
+ this.globalStore = t, this.api = new st(t.endpoint, t.sessionToken, t.onError), d(this);
1900
+ }
1901
+ get analysisChartData() {
1902
+ return Wt(Vt(this.visibleHoldings), this.analysisType);
1903
+ }
1904
+ get analysisDetails() {
1905
+ return zt(this.visibleHoldings)[this.analysisType] || {};
1906
+ }
1907
+ get visibleHoldings() {
1908
+ return this.holdings.filter(
1909
+ (t) => this.globalStore.globalUiStore.selectedAccountGuids.includes(t.account_guid)
1910
+ );
1911
+ }
1912
+ setHoldings = (t) => {
1913
+ this.holdings = t, this.holdingsLoaded = !0;
1914
+ };
1915
+ setShowConnectionsWidget = (t) => {
1916
+ this.showConnectionsWidget = t;
1917
+ };
1918
+ loadHoldings = async () => {
1919
+ try {
1920
+ const t = await this.api.getHoldings();
1921
+ this.setHoldings(t);
1922
+ } catch (t) {
1923
+ console.error(`Error occured while getting holdings: ${t}`);
1924
+ }
1925
+ };
1926
+ setAnalysisType = (t) => {
1927
+ this.analysisType = t;
1928
+ };
1929
+ updateHoldings = async (t) => {
1930
+ this.holdingsLoaded = !1;
1931
+ try {
1932
+ const e = await this.api.updateHoldings(t), s = this.holdings.findIndex(({ guid: a }) => a === t.guid);
1933
+ if (s >= 0) {
1934
+ const a = [...this.holdings];
1935
+ a[s] = e, c(() => {
1936
+ this.holdings = a, this.holdingsLoaded = !0;
1937
+ });
1938
+ }
1939
+ } catch (e) {
1940
+ console.error(`Error occurred while updating holding: ${e}`);
1941
+ }
1942
+ };
1943
+ }
1944
+ class Ne {
1945
+ globalStore;
1946
+ api = new at("/", "");
1947
+ merchant = null;
1948
+ merchants = [];
1949
+ isLoading = !1;
1950
+ constructor(t) {
1951
+ this.globalStore = t, this.api = new at(t.endpoint, t.sessionToken, t.onError), d(this);
1952
+ }
1953
+ loadMerchants = async (t = "") => {
1954
+ this.isLoading = !0;
1955
+ const e = await this.api.getMerchants([t]);
1956
+ c(() => {
1957
+ this.merchants = e, this.isLoading = !1;
1958
+ });
1959
+ };
1960
+ loadMerchantByGuid = async (t) => {
1961
+ const e = await this.api.getMerchantByGuid(t);
1962
+ c(() => this.merchant = e);
1963
+ };
1964
+ }
1965
+ class Ge {
1966
+ globalStore;
1967
+ accountsApi = new G("/", "");
1968
+ monthlyAccountBalances = [];
1969
+ monthlyAccountBalancesLoaded = !1;
1970
+ hoveredIndex = -1;
1971
+ selectedIndex = -1;
1972
+ timeframe = 6;
1973
+ // default timeframe is 6 months
1974
+ constructor(t) {
1975
+ this.globalStore = t, this.accountsApi = new G(
1976
+ t.endpoint,
1977
+ t.sessionToken,
1978
+ t.onError
1979
+ ), d(this);
1980
+ }
1981
+ get isNetWorthDataLoaded() {
1982
+ return this.globalStore.accountStore.isAccountDataLoaded && this.monthlyAccountBalancesLoaded;
1983
+ }
1984
+ get netWorthAccounts() {
1985
+ return Kt(
1986
+ this.globalStore.globalUiStore.selectedAccounts,
1987
+ this.globalStore.accountStore.members
1988
+ );
1989
+ }
1990
+ get netWorthData() {
1991
+ return {
1992
+ accounts: this.netWorthAccounts,
1993
+ monthlyAccountBalances: this.monthlyAccountBalances
1994
+ };
1995
+ }
1996
+ get netWorthChartData() {
1997
+ return Qt(this.netWorthAccounts, this.monthlyAccountBalances, this.timeframe);
1998
+ }
1999
+ get selectedData() {
2000
+ if (!(!this.netWorthChartData || this.netWorthChartData.length === 0))
2001
+ return this.selectedIndex === -1 ? V(this.netWorthChartData) : this.netWorthChartData[this.selectedIndex];
2002
+ }
2003
+ get hoveredData() {
2004
+ return this.hoveredIndex >= 0 ? this.netWorthChartData[this.hoveredIndex] : void 0;
2005
+ }
2006
+ get gainsLosses() {
2007
+ return qt(this.selectedData);
2008
+ }
2009
+ get assetsLiabilities() {
2010
+ const { assets: t, liabilities: e, totalAssets: s, totalLiabilities: a } = Yt(
2011
+ this.netWorthData.accounts
2012
+ );
2013
+ return {
2014
+ netWorth: V(this.netWorthChartData),
2015
+ assets: t,
2016
+ liabilities: e,
2017
+ totalAssets: s,
2018
+ totalLiabilities: a
2019
+ };
2020
+ }
2021
+ loadNetWorthData = async () => {
2022
+ this.globalStore.accountStore.isAccountDataLoaded || await this.globalStore.accountStore.loadAccountData();
2023
+ const e = (await Promise.all(
2024
+ this.netWorthAccounts.map((s) => this.getMonthlyAccountBalances(s.guid))
2025
+ )).reduce(jt, []).sort(Xt);
2026
+ this.setMonthlyAccountBalances(e);
2027
+ };
2028
+ getMonthlyAccountBalances = async (t) => {
2029
+ try {
2030
+ return await this.accountsApi.getMonthlyAccountBalances(t);
2031
+ } catch (e) {
2032
+ return console.error(`Error occured while fetching monthly account balances: ${e}`), [];
2033
+ }
2034
+ };
2035
+ setHoveredIndex = (t) => this.hoveredIndex = t;
2036
+ setMonthlyAccountBalances = (t) => {
2037
+ this.monthlyAccountBalances = t, this.monthlyAccountBalancesLoaded = !0;
2038
+ };
2039
+ setSelectedIndex = (t) => this.selectedIndex = t;
2040
+ setTimeframe = (t) => this.timeframe = t;
2041
+ }
2042
+ class Be {
2043
+ globalStore;
2044
+ api = new nt("/", "");
2045
+ isLoading = !0;
2046
+ notifications = [];
2047
+ notificationsLoaded = !1;
2048
+ constructor(t) {
2049
+ this.globalStore = t, this.api = new nt(
2050
+ t.endpoint,
2051
+ t.sessionToken,
2052
+ t.onError
2053
+ ), d(this, { notifications: Tt });
2054
+ }
2055
+ // Used in Money Dashboard
2056
+ get newNotifications() {
2057
+ return this.recentNotifications.filter((t) => !t.has_been_viewed);
2058
+ }
2059
+ get recentNotifications() {
2060
+ return Jt(this.notifications);
2061
+ }
2062
+ setNotifications = (t) => {
2063
+ this.notifications = t, this.notificationsLoaded = !0;
2064
+ };
2065
+ loadNotifications = async () => {
2066
+ this.isLoading = !0;
2067
+ try {
2068
+ const t = await this.api.getNotifications();
2069
+ this.setNotifications(t);
2070
+ } catch (t) {
2071
+ console.error(`Error occurred while loading notifications: ${t}`);
2072
+ } finally {
2073
+ c(() => {
2074
+ this.isLoading = !1;
2075
+ });
2076
+ }
2077
+ };
2078
+ markAllAsViewed = async () => {
2079
+ await this.api.markAllAsViewed();
2080
+ };
2081
+ updateNotification = async (t) => {
2082
+ t.has_been_viewed = !0, await this.api.updateNotification(t);
2083
+ };
2084
+ }
2085
+ const dt = (n, t) => gt(t.expectedDate, n), A = (n, t) => n + t.amount;
2086
+ class xe {
2087
+ globalStore;
2088
+ api = new it("/", "");
2089
+ repeatingTransactions = [];
2090
+ isDataLoaded = !1;
2091
+ selectedDay;
2092
+ dateRange = { start: E(y()), end: T(y()) };
2093
+ constructor(t) {
2094
+ this.globalStore = t, this.api = new it(
2095
+ t.endpoint,
2096
+ t.sessionToken,
2097
+ t.onError
2098
+ ), d(this);
2099
+ }
2100
+ get detailedRepeatingTransactions() {
2101
+ return O(
2102
+ this.globalStore.accountStore.visibleAccounts,
2103
+ this.repeatingTransactions,
2104
+ this.globalStore.transactionStore.transactions
2105
+ );
2106
+ }
2107
+ /**
2108
+ * Returns all recurrences built from repeating transactions and filtered by accounts.
2109
+ */
2110
+ get recurrences() {
2111
+ const t = this.globalStore.accountStore.visibleAccounts;
2112
+ return Zt(this.detailedRepeatingTransactions, this.dateRange).filter((e) => t.some((s) => s.guid === e.accountGuid && !s.is_excluded_from_accounts)).filter((e) => gt(e.expectedDate, this.dateRange));
2113
+ }
2114
+ /**
2115
+ * Returns all recurrences that have occurred in the past, including those that are paid or missed
2116
+ */
2117
+ get pastRecurrences() {
2118
+ return this.recurrences.filter(
2119
+ (t) => t.status === f.Paid || t.status === f.Missed
2120
+ );
2121
+ }
2122
+ /**
2123
+ * Returns all recurrences that are expected to occur through the end of the month
2124
+ * or should have occurred in the last 3 days.
2125
+ */
2126
+ get upcomingRecurrences() {
2127
+ return this.recurrences.filter(
2128
+ (t) => z(t.expectedDate, pt(y(), 3)) && F(t.expectedDate, this.dateRange.end) && t.status === f.Upcoming
2129
+ );
2130
+ }
2131
+ /**
2132
+ * Returns all expense recurrences.
2133
+ */
2134
+ get expenses() {
2135
+ return this.recurrences.filter(
2136
+ (t) => t.type === Q.Expense
2137
+ );
2138
+ }
2139
+ /**
2140
+ * Returns the upcoming expense recurrences.
2141
+ */
2142
+ get upcomingExpenses() {
2143
+ return this.expenses.filter(
2144
+ (t) => t.status === f.Upcoming
2145
+ );
2146
+ }
2147
+ /**
2148
+ * Returns all income recurrences.
2149
+ */
2150
+ get income() {
2151
+ return this.recurrences.filter(
2152
+ (t) => t.type === Q.Income
2153
+ );
2154
+ }
2155
+ /**
2156
+ * Returns the upcoming income recurrences.
2157
+ */
2158
+ get upcomingIncome() {
2159
+ return this.income.filter(
2160
+ (t) => t.status === f.Upcoming
2161
+ );
2162
+ }
2163
+ get nextIncomeRecurrence() {
2164
+ return this.upcomingIncome.find((t) => z(t.expectedDate, y()));
2165
+ }
2166
+ /**
2167
+ * Returns the expense recurrences for the current month.
2168
+ */
2169
+ get currentMonthExpenses() {
2170
+ return this.expenses.filter(
2171
+ (t) => dt(this.dateRange, t)
2172
+ );
2173
+ }
2174
+ /**
2175
+ * Returns the income recurrences for the current month.
2176
+ */
2177
+ get currentMonthIncome() {
2178
+ return this.income.filter(
2179
+ (t) => dt(this.dateRange, t)
2180
+ );
2181
+ }
2182
+ /**
2183
+ * Calculates the total amount of all expenses for the current month.
2184
+ */
2185
+ get expenseTotal() {
2186
+ return this.currentMonthExpenses.reduce(A, 0);
2187
+ }
2188
+ /**
2189
+ * Calculates the total amount of all paid expenses for the current month.
2190
+ */
2191
+ get paidExpenseTotal() {
2192
+ return this.currentMonthExpenses.filter((t) => t.status === f.Paid).reduce(A, 0);
2193
+ }
2194
+ /**
2195
+ * Calculates the total amount of all missed expenses for the current month.
2196
+ */
2197
+ get missedExpenseTotal() {
2198
+ return this.currentMonthExpenses.filter((t) => t.status === f.Missed).reduce(A, 0);
2199
+ }
2200
+ /**
2201
+ * Calculates the total amount of all upcoming expenses for the current month.
2202
+ */
2203
+ get upcomingExpenseTotal() {
2204
+ return this.currentMonthExpenses.filter((t) => t.status === f.Upcoming).reduce(A, 0);
2205
+ }
2206
+ /**
2207
+ * Calculates the total amount of all income for the current month.
2208
+ */
2209
+ get incomeTotal() {
2210
+ return this.currentMonthIncome.reduce(A, 0);
2211
+ }
2212
+ /**
2213
+ * Calculates the total amount of all paid income for the current month.
2214
+ */
2215
+ get paidIncomeTotal() {
2216
+ return this.currentMonthIncome.filter((t) => t.status === f.Paid).reduce(A, 0);
2217
+ }
2218
+ /**
2219
+ * Calculates the total amount of all upcoming income for the current month.
2220
+ */
2221
+ get upcomingIncomeTotal() {
2222
+ return this.currentMonthIncome.filter((t) => t.status === f.Upcoming).reduce(A, 0);
2223
+ }
2224
+ /**
2225
+ * Get the recurrences for the currently selected day.
2226
+ */
2227
+ get selectedDayRecurrences() {
2228
+ return this.selectedDay && this.recurrences.filter(
2229
+ (t) => this.selectedDay && K(t.occurredOnDate || t.expectedDate, this.selectedDay)
2230
+ );
2231
+ }
2232
+ setRepeatingTransactions = (t) => {
2233
+ this.repeatingTransactions = t, this.isDataLoaded = !0;
2234
+ };
2235
+ /**
2236
+ * Set the date range for filtering recurrences.
2237
+ * @param dateRange - The date range to set.
2238
+ */
2239
+ setDateRange = (t) => this.dateRange = t;
2240
+ /**
2241
+ * Set the currently selected day.
2242
+ * @param day - The day to select.
2243
+ */
2244
+ setSelectedDay = (t) => {
2245
+ this.selectedDay = this.selectedDay && K(t, this.selectedDay) ? void 0 : t;
2246
+ };
2247
+ loadRepeatingTransactionData = async () => {
2248
+ await Promise.all([
2249
+ this.globalStore.accountStore.loadAccountData(),
2250
+ this.globalStore.categoryStore.loadCategories(),
2251
+ this.globalStore.transactionStore.loadTransactionData()
2252
+ ]), await this.loadRepeatingTransactions();
2253
+ };
2254
+ /**
2255
+ * Load repeating transactions and augment them with additional data.
2256
+ */
2257
+ loadRepeatingTransactions = async () => {
2258
+ try {
2259
+ const t = await this.api.getRepeatingTransactions();
2260
+ this.setRepeatingTransactions(t);
2261
+ } catch (t) {
2262
+ console.error(`Error occurred while getting repeating transactions: ${t}`);
2263
+ }
2264
+ };
2265
+ /**
2266
+ * Add a new repeating transaction and link it to the associated transaction.
2267
+ * @param repeatingTransaction - The repeating transaction to add.
2268
+ * @param transaction - The transaction associated with the repeating transaction.
2269
+ */
2270
+ addRepeatingTransaction = async (t, e) => {
2271
+ try {
2272
+ const s = await this.api.addRepeatingTransaction(t);
2273
+ await this.globalStore.transactionStore.updateTransaction({
2274
+ ...e,
2275
+ repeating_transaction_guid: s.guid
2276
+ }), c(() => {
2277
+ this.repeatingTransactions = [
2278
+ ...this.repeatingTransactions,
2279
+ ...O(
2280
+ this.globalStore.accountStore.visibleAccounts,
2281
+ [s],
2282
+ this.globalStore.transactionStore.transactions
2283
+ )
2284
+ ];
2285
+ });
2286
+ } catch (s) {
2287
+ console.error(`Error occurred while adding repeating transaction: ${s}`);
2288
+ }
2289
+ };
2290
+ /**
2291
+ * Delete a repeating transaction by its GUID.
2292
+ * @param guid - The GUID of the repeating transaction to delete.
2293
+ */
2294
+ deleteRepeatingTransaction = async (t) => {
2295
+ try {
2296
+ await this.api.deleteRepeatingTransaction(t), c(() => {
2297
+ this.repeatingTransactions = [
2298
+ ...this.repeatingTransactions.filter((e) => e.guid !== t)
2299
+ ];
2300
+ });
2301
+ } catch (e) {
2302
+ console.error(`Error occurred while deleting repeating transaction: ${e}`);
2303
+ }
2304
+ };
2305
+ /**
2306
+ * Update an existing repeating transaction.
2307
+ * @param transaction - The repeating transaction to update.
2308
+ */
2309
+ updateRepeatingTransaction = async (t) => {
2310
+ try {
2311
+ const e = await this.api.updateRepeatingTransaction(t), s = this.repeatingTransactions.findIndex(
2312
+ (a) => a.guid === e.guid
2313
+ );
2314
+ if (s < 0) return;
2315
+ c(() => {
2316
+ this.repeatingTransactions = [
2317
+ ...this.repeatingTransactions.slice(0, s),
2318
+ ...O(
2319
+ this.globalStore.accountStore.visibleAccounts,
2320
+ [e],
2321
+ this.globalStore.transactionStore.transactions
2322
+ ),
2323
+ ...this.repeatingTransactions.slice(s + 1)
2324
+ ];
2325
+ });
2326
+ } catch (e) {
2327
+ console.error(`Error occurred while updating repeating transaction: ${e}`);
2328
+ }
2329
+ };
2330
+ }
2331
+ const ht = "PARENT-ENTITY", Me = (n, t) => ({
2332
+ [N.BudgetExceeded]: t.notification_budget_exceeded,
2333
+ [N.BudgetOffTarget]: t.notification_budget_off_target,
2334
+ [_.DebtPaymentReminder]: t.notification_debt_payment_reminder,
2335
+ [_.AccountBalanceLow]: t.notification_low_balance,
2336
+ [_.AccountDepositLargePosted]: t.notification_large_deposit,
2337
+ [_.AccountDepositLarge]: t.notification_large_deposit,
2338
+ [_.TransactionExpenseLarge]: t.notification_large_expense,
2339
+ [_.TransactionFeeCharge]: t.notification_transaction_fee,
2340
+ [_.InternationalTransaction]: t.notification_transaction_is_international,
2341
+ [u.AccountBalanceLow]: t.account_balance_low,
2342
+ [u.BillAmountNotStandard]: t.bill_amount_not_standard,
2343
+ [u.CategorySpending]: t.category_spending,
2344
+ [u.CreditCardCloseToLimit]: t.credit_card_close_to_limit,
2345
+ [u.DebtPaymentReminder]: t.debt_payment_reminder,
2346
+ [u.DuplicatePayment]: t.duplicate_payment,
2347
+ [u.MonthlySpendComparison]: t.monthly_spend_comparison,
2348
+ [u.MonthlySpendToIncomeComparison]: t.monthly_spend_to_income_comparison,
2349
+ [u.MonthlySubscriptionAggregate]: t.monthly_subscription_aggregate,
2350
+ [u.MonthlyTopMerchantSpending]: t.monthly_top_merchant_spending,
2351
+ [u.SaveAnExtra100Dollars]: t.save_an_extra_100_dollars,
2352
+ [u.SavingsOpportunity]: t.savings_opportunity,
2353
+ [u.SetUpDirectDeposit]: t.set_up_direct_deposit,
2354
+ [u.SwitchDirectDeposit]: t.switch_direct_deposit,
2355
+ [u.UncategorizedTransactions]: t.uncategorized_transactions,
2356
+ [u.UnifiedDeposit]: t.unified_deposit,
2357
+ [u.UpcomingBill]: t.upcoming_bill,
2358
+ [u.WeekendSpendingSummary]: t.weekend_spending_summary,
2359
+ [u.WeeklyNewMerchants]: t.weekly_new_merchants,
2360
+ [u.DiscoveredAccounts]: t.discovered_account,
2361
+ [u.TransactionExpenseLarge]: t.large_transaction,
2362
+ [u.PromotionalCampaignMessages]: t.promotional_campaign_messages,
2363
+ [u.TransparentOverdraft]: t.transparent_overdraft
2364
+ })[n] || "", Oe = (n, t, e, s, a, o) => {
2365
+ const r = [], {
2366
+ email_notifications_enabled: l,
2367
+ sms_notifications_enabled: p,
2368
+ push_notifications_enabled: b
2369
+ } = t, {
2370
+ opted_out_of_email_notifications: _t,
2371
+ opted_out_of_sms_notifications: ft,
2372
+ opted_out_of_push_notifications: yt
2373
+ } = a;
2374
+ for (const I of s.filter((D) => D.entity_guid === ht)) {
2375
+ const D = Me(I.notification_type, e), mt = s.filter(
2376
+ (C) => C.entity_guid !== ht && C.notification_type === I.notification_type && n.some((x) => x.guid === C.entity_guid)
2377
+ ), R = [];
2378
+ l && !_t && I.email_channel && o.email && R.push(e.delivery_method_email_label), p && !ft && I.sms_channel && o.phone && R.push(e.delivery_method_sms_label), b && !yt && I.push_channel && R.push(e.delivery_method_push_label), r.push({
2379
+ ...I,
2380
+ children: mt.map((C) => ({
2381
+ ...C,
2382
+ account: n.find((x) => x.guid === C.entity_guid),
2383
+ label: D
2384
+ })),
2385
+ deliveryMethodsLabel: R.join(", "),
2386
+ label: D
2387
+ });
2388
+ }
2389
+ return r;
2390
+ };
2391
+ class Pe {
2392
+ globalStore;
2393
+ api = new rt("/", "");
2394
+ transactionApi = new B("/", "");
2395
+ alert = { message: "", severity: void 0 };
2396
+ devices = [];
2397
+ notificationProfiles = [];
2398
+ selectedRule = void 0;
2399
+ transactionRules = [];
2400
+ constructor(t) {
2401
+ this.globalStore = t, this.api = new rt(t.endpoint, t.sessionToken, t.onError), this.transactionApi = new B(
2402
+ t.endpoint,
2403
+ t.sessionToken,
2404
+ t.onError
2405
+ ), d(this);
2406
+ }
2407
+ get accountProfiles() {
2408
+ const t = this.globalStore.appDataStore.clientCommunicationProfile;
2409
+ return this.detailedNotificationProfiles.filter(
2410
+ (e) => e.notification_type === _.DebtPaymentReminder && t.debt_payment_reminder_notifications_enabled || e.notification_type === _.AccountBalanceLow && t.low_balance_notifications_enabled || e.notification_type === _.AccountDepositLarge && t.large_deposit_notifications_enabled || e.notification_type === _.TransactionExpenseLarge && t.large_expense_notifications_enabled || e.notification_type === _.TransactionFeeCharge && t.transaction_fee_notifications_enabled || e.notification_type === _.InternationalTransaction && t.transaction_is_international_notifications_enabled || e.notification_type === _.AccountDepositLargePosted && t.large_deposit_posted_notifications_enabled
2411
+ );
2412
+ }
2413
+ get budgetProfiles() {
2414
+ const t = this.globalStore.appDataStore.clientCommunicationProfile;
2415
+ return this.detailedNotificationProfiles.filter(
2416
+ (e) => e.notification_type === N.BudgetExceeded && t.budget_exceeded_notifications_enabled || e.notification_type === N.BudgetOffTarget && t.budget_off_target_notifications_enabled
2417
+ );
2418
+ }
2419
+ get insightsProfiles() {
2420
+ return this.detailedNotificationProfiles.filter(
2421
+ (t) => Object.values(u).includes(t.notification_type)
2422
+ );
2423
+ }
2424
+ get clientCommunicationProfile() {
2425
+ return this.globalStore.appDataStore.clientCommunicationProfile;
2426
+ }
2427
+ get copy() {
2428
+ return this.globalStore.copyStore.copy.settings;
2429
+ }
2430
+ get detailedNotificationProfiles() {
2431
+ return this.globalStore.isInitialized ? Oe(
2432
+ this.globalStore.accountStore.accounts,
2433
+ this.clientCommunicationProfile,
2434
+ this.copy,
2435
+ this.notificationProfiles,
2436
+ this.userCommunicationsProfile,
2437
+ this.globalStore.userStore.user
2438
+ ) : [];
2439
+ }
2440
+ get userCommunicationsProfile() {
2441
+ return this.globalStore.appDataStore.userCommunicationProfile;
2442
+ }
2443
+ deleteDevice = async (t) => {
2444
+ try {
2445
+ await this.api.deleteDevice(t);
2446
+ const e = this.devices.findIndex((s) => s.guid === t);
2447
+ return e >= 0 && c(() => {
2448
+ this.devices.splice(e, 1);
2449
+ }), { success: !0 };
2450
+ } catch {
2451
+ return console.error(`Error deleting device: ${t}`), { success: !1 };
2452
+ }
2453
+ };
2454
+ deleteTransactionRule = async () => {
2455
+ this.selectedRule && this.transactionApi.removeTransactionRule(this.selectedRule?.guid).then(() => {
2456
+ this.setAlert(this.copy.delete_rule_success, "success"), this.loadTransactionRules();
2457
+ }).catch(() => {
2458
+ this.setAlert(this.copy.delete_rule_error, "error");
2459
+ });
2460
+ };
2461
+ generateDeviceToken = async () => {
2462
+ try {
2463
+ return await this.api.generateDeviceToken();
2464
+ } catch (t) {
2465
+ console.error(`Error generating device token: ${t}`);
2466
+ }
2467
+ };
2468
+ loadDevices = async () => {
2469
+ try {
2470
+ const t = await this.api.getDevices();
2471
+ c(() => {
2472
+ this.devices = t;
2473
+ });
2474
+ } catch (t) {
2475
+ console.error(`Error loading devices: ${t}`);
2476
+ }
2477
+ };
2478
+ loadNotificationProfiles = async () => {
2479
+ try {
2480
+ const t = await this.api.getNotificationProfiles();
2481
+ c(() => {
2482
+ this.notificationProfiles = t;
2483
+ });
2484
+ } catch (t) {
2485
+ console.error(`Error loading notification profiles: ${t}`);
2486
+ }
2487
+ };
2488
+ loadTransactionRules = async () => {
2489
+ try {
2490
+ const t = await this.transactionApi.getTransactionRules();
2491
+ c(() => {
2492
+ this.transactionRules = t;
2493
+ });
2494
+ } catch (t) {
2495
+ console.error(`Error loading transaction rules: ${t}`);
2496
+ }
2497
+ };
2498
+ sendEmailVerification = async () => {
2499
+ try {
2500
+ await this.api.sendEmailVerification(), this.setAlert(this.copy.verification_sent_success, "success");
2501
+ } catch (t) {
2502
+ console.error(`Error sending email verification: ${t}`), this.setAlert(this.copy.verification_sent_error, "error");
2503
+ }
2504
+ };
2505
+ sendPhoneVerification = async () => {
2506
+ try {
2507
+ await this.api.sendPhoneVerification(), this.setAlert(this.copy.verification_sent_success, "success");
2508
+ } catch (t) {
2509
+ console.error(`Error sending phone verification: ${t}`), this.setAlert(this.copy.verification_sent_error, "error");
2510
+ }
2511
+ };
2512
+ setAlert = (t, e = void 0) => this.alert = { message: t, severity: e };
2513
+ setSelectedRule = (t) => {
2514
+ this.selectedRule = t;
2515
+ };
2516
+ updateDevice = async (t) => {
2517
+ try {
2518
+ const e = await this.api.updateDevice(t), s = this.devices.findIndex((a) => a.guid === t.guid);
2519
+ return s >= 0 && c(() => {
2520
+ this.devices[s] = e;
2521
+ }), { success: !0 };
2522
+ } catch (e) {
2523
+ return console.error(`Error updating device: ${e}`), { success: !1 };
2524
+ }
2525
+ };
2526
+ updateNotificationProfile = async (t) => {
2527
+ try {
2528
+ const e = await this.api.updateNotificationProfile(t), s = this.notificationProfiles.findIndex((a) => a.guid === t.guid);
2529
+ s >= 0 && c(() => {
2530
+ this.notificationProfiles[s] = e;
2531
+ });
2532
+ } catch (e) {
2533
+ console.error(`Error updating notification profile: ${e}`);
2534
+ }
2535
+ };
2536
+ updateRuleCategory = async (t) => {
2537
+ this.transactionApi.updateTransactionRule(t).then(() => {
2538
+ this.loadTransactionRules();
2539
+ });
2540
+ };
2541
+ updateRulePayee = async (t) => {
2542
+ this.transactionApi.updateTransactionRule(t).then(() => {
2543
+ this.setAlert(this.copy.edit_payee_success, "success"), this.loadTransactionRules();
2544
+ }).catch(() => {
2545
+ this.setAlert(this.copy.edit_payee_error, "error");
2546
+ });
2547
+ };
2548
+ updateUser = async (t) => {
2549
+ this.globalStore.userStore.updateUser(t).then(() => {
2550
+ this.setAlert(this.copy.information_updated_success, "success");
2551
+ }).catch(() => {
2552
+ this.setAlert(this.copy.information_updated_error, "error");
2553
+ });
2554
+ };
2555
+ updateUserCommunicationProfile = async (t) => {
2556
+ try {
2557
+ const e = await this.api.updateUserCommunicationProfile(t);
2558
+ this.globalStore.appDataStore.setUserCommunicationProfile(e);
2559
+ } catch (e) {
2560
+ console.error(`Error occurred while updating user communication profile: ${e}`);
2561
+ }
2562
+ };
2563
+ verifyPhoneToken = async (t) => {
2564
+ try {
2565
+ const { verified: e } = await this.api.verifyPhoneToken(t);
2566
+ if (!e)
2567
+ throw new Error();
2568
+ this.setAlert(this.copy.verified_phone_success, "success");
2569
+ } catch (e) {
2570
+ console.error(`Error verifying phone token: ${e}`), this.setAlert(this.copy.verified_phone_error, "error");
2571
+ }
2572
+ };
2573
+ }
2574
+ class Ue {
2575
+ globalStore;
2576
+ uiStore;
2577
+ api = new B("/", "");
2578
+ beatApi = new v("/", "");
2579
+ associatedBeats = [];
2580
+ associatedBeatsLoaded = !1;
2581
+ associatedBeatsLoading = !1;
2582
+ transactions = [];
2583
+ transactionsLoaded = !1;
2584
+ transactionsLoading = !1;
2585
+ taggings = [];
2586
+ taggingsLoaded = !1;
2587
+ taggingsLoading = !1;
2588
+ tags = [];
2589
+ tagsLoaded = !1;
2590
+ tagsLoading = !1;
2591
+ transactionRules = [];
2592
+ transactionRulesLoaded = !1;
2593
+ transactionRulesLoading = !1;
2594
+ cachedStartDate = pt(y(), 90);
2595
+ filter = {};
2596
+ isLoading = !0;
2597
+ alert = "";
2598
+ sortColumn = $t.DATE;
2599
+ sortDirection = Nt.DESC;
2600
+ constructor(t) {
2601
+ this.globalStore = t, this.uiStore = new Fe(), this.api = new B(
2602
+ t.endpoint,
2603
+ t.sessionToken,
2604
+ t.onError
2605
+ ), this.beatApi = new v(t.endpoint, t.sessionToken, t.onError), d(this);
2606
+ }
2607
+ loadTransactionData = async () => {
2608
+ this.globalStore.accountStore.isAccountDataLoaded || await this.globalStore.accountStore.loadAccountData(), this.globalStore.categoryStore.categoriesLoaded || await this.globalStore.categoryStore.loadCategories(), await Promise.all([
2609
+ this.loadAssociatedBeats(E(/* @__PURE__ */ new Date())),
2610
+ this.loadTags(),
2611
+ this.loadTaggings(),
2612
+ this.loadTransactionRules(),
2613
+ // By default loads 90 days of transactions
2614
+ this.loadTransactions(this.cachedStartDate)
2615
+ ]);
2616
+ };
2617
+ get isTransactionDataLoaded() {
2618
+ return this.associatedBeatsLoaded && this.tagsLoaded && this.taggingsLoaded && this.transactionRulesLoaded && this.transactionsLoaded;
2619
+ }
2620
+ get detailedTransactions() {
2621
+ return this.isTransactionDataLoaded ? Gt(
2622
+ this.transactions,
2623
+ this.globalStore.accountStore.visibleAccounts,
2624
+ this.globalStore.categoryStore.categories,
2625
+ this.taggings
2626
+ ) : [];
2627
+ }
2628
+ get sortedTransactions() {
2629
+ return Bt(
2630
+ this.filter,
2631
+ this.uiStore.expandedSplits,
2632
+ this.sortColumn,
2633
+ this.sortDirection,
2634
+ this.tags,
2635
+ this.detailedTransactions
2636
+ );
2637
+ }
2638
+ get sortedTransactionsWithSplits() {
2639
+ return xt(this.sortedTransactions, this.detailedTransactions);
2640
+ }
2641
+ setAssociatedBeats = (t) => {
2642
+ this.associatedBeats = t, this.associatedBeatsLoading = !1, this.associatedBeatsLoaded = !0;
2643
+ };
2644
+ setTaggings = (t) => {
2645
+ this.taggings = t, this.taggingsLoading = !1, this.taggingsLoaded = !0;
2646
+ };
2647
+ setTags = (t) => {
2648
+ this.tags = t, this.tagsLoading = !1, this.tagsLoaded = !0;
2649
+ };
2650
+ setTransactionRules = (t) => {
2651
+ this.transactionRules = t, this.transactionRulesLoading = !1, this.transactionRulesLoaded = !0;
2652
+ };
2653
+ setTransactions = (t) => {
2654
+ this.transactions = t, this.transactionsLoading = !1, this.transactionsLoaded = !0;
2655
+ };
2656
+ setAlert = (t) => {
2657
+ this.alert = t;
2658
+ };
2659
+ addTag = async (t) => {
2660
+ await this.api.addTag({ name: t }), await this.loadTags();
2661
+ };
2662
+ addTagging = async (t, e) => {
2663
+ await this.api.addTagging({
2664
+ tag_guid: t,
2665
+ transaction_guid: e
2666
+ });
2667
+ };
2668
+ addOrUpdateTransactionRule = async (t, e) => {
2669
+ const s = this.transactionRules.find(
2670
+ (a) => a.guid === e.user_transaction_rule_guid
2671
+ );
2672
+ s ? await this.api.updateTransactionRule({
2673
+ ...s,
2674
+ category_guid: t,
2675
+ description: e.description
2676
+ }) : await this.api.addTransactionRule({
2677
+ category_guid: t,
2678
+ description: e.description,
2679
+ match_description: e.description
2680
+ }), await this.loadTransactionRules();
2681
+ };
2682
+ addTransaction = async (t) => {
2683
+ const e = await this.api.addTransaction(t);
2684
+ if (e) {
2685
+ this.setTransactions([e, ...this.transactions]);
2686
+ const s = e.transaction_type === Mt.CREDIT ? e.amount : -e.amount;
2687
+ this.globalStore.accountStore.updateAccountBalance(e.account_guid, s);
2688
+ }
2689
+ };
2690
+ loadAssociatedBeats = async (t) => {
2691
+ if (this.associatedBeatsLoading) return;
2692
+ this.associatedBeatsLoading = !0;
2693
+ const e = t ? te(t, { representation: "date" }) : void 0;
2694
+ try {
2695
+ const s = await this.beatApi.getBeatsWithAssociatedTransaction(e);
2696
+ this.setAssociatedBeats(s);
2697
+ } catch (s) {
2698
+ console.error(`Error occurred while loading associated beats: ${s}`);
2699
+ }
2700
+ };
2701
+ loadTags = async () => {
2702
+ if (!this.tagsLoading) {
2703
+ this.tagsLoading = !0;
2704
+ try {
2705
+ const t = await this.api.getTags();
2706
+ this.setTags(t);
2707
+ } catch (t) {
2708
+ console.error(`Error occurred while loading tags: ${t}`);
2709
+ }
2710
+ }
2711
+ };
2712
+ loadTaggings = async () => {
2713
+ if (!this.taggingsLoading) {
2714
+ this.taggingsLoading = !0;
2715
+ try {
2716
+ const t = await this.api.getTaggings();
2717
+ this.setTaggings(t);
2718
+ } catch (t) {
2719
+ console.error(`Error occurred while loading taggings: ${t}`);
2720
+ }
2721
+ }
2722
+ };
2723
+ loadTransactionRules = async () => {
2724
+ if (this.transactionRulesLoading) return;
2725
+ this.transactionRulesLoading = !0;
2726
+ const t = await this.api.getTransactionRules();
2727
+ this.setTransactionRules(t);
2728
+ };
2729
+ loadTransactions = async (t = this.cachedStartDate) => {
2730
+ if (!this.transactionsLoading) {
2731
+ this.setIsLoading(!0), this.transactionsLoading = !0, this.transactions = [];
2732
+ try {
2733
+ const e = await this.api.getTransactionsByDateRange(
2734
+ m(t),
2735
+ m(q())
2736
+ );
2737
+ this.setTransactions(e);
2738
+ } catch (e) {
2739
+ console.error(`Error occurred while loading transactions: ${e}`);
2740
+ }
2741
+ this.setIsLoading(!1);
2742
+ }
2743
+ };
2744
+ modifyTransactionByAccountGuid = (t, e) => {
2745
+ this.transactions = this.transactions.map(
2746
+ (s) => s.account_guid === t ? { ...s, ...e } : s
2747
+ );
2748
+ };
2749
+ removeTag = async (t) => {
2750
+ await this.api.removeTag(t), await this.loadTags();
2751
+ };
2752
+ removeTagging = async (t) => {
2753
+ await this.api.removeTagging(t);
2754
+ };
2755
+ removeTransaction = async (t) => {
2756
+ await this.api.removeTransaction(t);
2757
+ const e = this.transactions.findIndex((s) => s.guid === t);
2758
+ if (e >= 0) {
2759
+ const s = [...this.transactions];
2760
+ s.splice(e, 1), this.setTransactions(s);
2761
+ }
2762
+ };
2763
+ setFilter = (t) => {
2764
+ this.filter = t, t.dateRange && F(t.dateRange.start, this.cachedStartDate) && this.loadTransactions(t.dateRange.start).then(() => {
2765
+ t.dateRange && (this.cachedStartDate = t.dateRange.start);
2766
+ });
2767
+ };
2768
+ setIsLoading = (t) => this.isLoading = t;
2769
+ splitTransaction = async (t, e) => {
2770
+ const s = await this.api.updateTransaction(t), a = [];
2771
+ for (let r = 0; r < e.length; r++) {
2772
+ const l = await this.api.addTransaction(e[r]);
2773
+ a.push(l);
2774
+ }
2775
+ const o = this.transactions.findIndex((r) => r.guid === t.guid);
2776
+ if (o >= 0) {
2777
+ const r = this.transactions.filter(
2778
+ (l) => l.guid !== t.guid && l.parent_guid !== t.guid
2779
+ );
2780
+ this.setTransactions([
2781
+ ...r.slice(0, o),
2782
+ s,
2783
+ ...a,
2784
+ ...r.slice(o)
2785
+ ]);
2786
+ }
2787
+ };
2788
+ unSplitTransaction = async (t) => {
2789
+ const e = this.transactions.filter((r) => r.parent_guid === t);
2790
+ await this.api.removeTransactionSplit(t);
2791
+ const s = [...this.transactions];
2792
+ e.forEach((r) => {
2793
+ const l = s.findIndex((p) => p.guid === r.guid);
2794
+ l >= 0 && s.splice(l, 1);
2795
+ });
2796
+ const a = s.findIndex((r) => r.guid === t), o = s[a];
2797
+ o.has_been_split = !1, a >= 0 && this.setTransactions([
2798
+ ...s.slice(0, a),
2799
+ o,
2800
+ ...s.slice(a + 1)
2801
+ ]);
2802
+ };
2803
+ updateTaggings = async (t, e) => {
2804
+ const s = this.taggings.filter((r) => r.transaction_guid === e), a = new Set(s.map((r) => r.tag_guid)), o = new Set(t);
2805
+ for (const r of t)
2806
+ a.has(r) || await this.addTagging(r, e);
2807
+ for (const r of s)
2808
+ o.has(r.tag_guid) || await this.removeTagging(r.guid);
2809
+ await this.loadTaggings();
2810
+ };
2811
+ updateTag = async (t) => {
2812
+ await this.api.updateTag(t), await this.loadTags();
2813
+ };
2814
+ updateTransaction = async (t) => {
2815
+ const e = await this.api.updateTransaction(t), s = this.transactions.findIndex((a) => a.guid === t.guid);
2816
+ s >= 0 && this.setTransactions([
2817
+ ...this.transactions.slice(0, s),
2818
+ e,
2819
+ ...this.transactions.slice(s + 1)
2820
+ ]);
2821
+ };
2822
+ // This is used for loading the transactions list on demand, on clicking the different transactions of the insightful beats.
2823
+ loadEmbeddedInstanceTransactions = async (t) => {
2824
+ try {
2825
+ const e = await this.api.getTransactionsByDateRange(
2826
+ m(t),
2827
+ m(q())
2828
+ );
2829
+ this.cachedStartDate = t, this.transactions = e;
2830
+ } catch (e) {
2831
+ console.error(`Error occurred while loading embedded instance transactions: ${e}`);
2832
+ }
2833
+ };
2834
+ }
2835
+ class Fe {
2836
+ beginDate = E(/* @__PURE__ */ new Date());
2837
+ endDate = T(/* @__PURE__ */ new Date());
2838
+ expandedSplits = [];
2839
+ height = 550;
2840
+ width = 1e3;
2841
+ shouldDisableDrawerScroll = !1;
2842
+ searchValue = "";
2843
+ selectedAccountGuids = [];
2844
+ manualTransaction = Ot;
2845
+ isAmountValid = !1;
2846
+ showInsights = !1;
2847
+ constructor() {
2848
+ d(this);
2849
+ }
2850
+ setDateRange = (t, e) => {
2851
+ this.beginDate = t, this.endDate = e;
2852
+ };
2853
+ setIsAmountValid = (t) => this.isAmountValid = t;
2854
+ setSearchValue = (t) => this.searchValue = t;
2855
+ setSelectedAccountGuids = (t) => this.selectedAccountGuids = t;
2856
+ setShouldDisableDrawerScroll = (t) => this.shouldDisableDrawerScroll = t;
2857
+ setShowInsights = (t) => {
2858
+ this.showInsights = t;
2859
+ };
2860
+ setSize = (t, e) => {
2861
+ this.height = t, this.width = e;
2862
+ };
2863
+ toggleSplit = (t) => {
2864
+ const e = [...this.expandedSplits], s = this.expandedSplits.findIndex((a) => a === t);
2865
+ s >= 0 ? e.splice(s, 1) : e.push(t), this.expandedSplits = e;
2866
+ };
2867
+ clearExpandedSplits = () => {
2868
+ this.expandedSplits.length !== 0 && (this.expandedSplits = []);
2869
+ };
2870
+ updateManualTransaction = (t) => {
2871
+ this.manualTransaction = t;
2872
+ };
2873
+ }
2874
+ class ke {
2875
+ globalStore;
2876
+ selectedCategoryData = null;
2877
+ selectedDateRange;
2878
+ visibleListLength = 5;
2879
+ constructor(t) {
2880
+ this.globalStore = t, this.selectedDateRange = {
2881
+ start: ee(T($(/* @__PURE__ */ new Date(), 6)), 1),
2882
+ end: T(/* @__PURE__ */ new Date())
2883
+ }, d(this);
2884
+ }
2885
+ setSelectedCategoryData = (t) => {
2886
+ this.selectedCategoryData = t;
2887
+ };
2888
+ setSelectedDateRange = (t) => {
2889
+ this.selectedDateRange = t;
2890
+ };
2891
+ setVisibleListLength = (t) => {
2892
+ this.visibleListLength = t;
2893
+ };
2894
+ get sortedDetailedCategoriesWithTransactions() {
2895
+ return ae(
2896
+ this.globalStore.categoryStore.detailedCategoriesWithTransactions
2897
+ );
2898
+ }
2899
+ get selectedDateRangeMonthCount() {
2900
+ return se(this.selectedDateRange.end, this.selectedDateRange.start) + 1;
2901
+ }
2902
+ get selectedDateRangeMonthRange() {
2903
+ const t = P(this.selectedDateRange.start, U.MONTH_LONG), e = P(this.selectedDateRange.end, U.MONTH_LONG);
2904
+ return `${t} - ${e}`;
2905
+ }
2906
+ get visibleCategories() {
2907
+ return this.sortedDetailedCategoriesWithTransactions.slice(0, this.visibleListLength);
2908
+ }
2909
+ get collapsedCategories() {
2910
+ return this.sortedDetailedCategoriesWithTransactions.slice(this.visibleListLength);
2911
+ }
2912
+ get categoryDetailsChartData() {
2913
+ return ne(
2914
+ this.selectedCategoryData,
2915
+ this.selectedDateRangeMonthCount
2916
+ );
2917
+ }
2918
+ }
2919
+ class He {
2920
+ globalStore;
2921
+ api = new ot("/", "");
2922
+ userFeatures = [];
2923
+ userFeaturesLoaded = !1;
2924
+ constructor(t) {
2925
+ this.globalStore = t, this.api = new ot(t.endpoint, t.sessionToken, t.onError), d(this);
2926
+ }
2927
+ get userProfile() {
2928
+ return this.globalStore.appDataStore.userProfile;
2929
+ }
2930
+ get user() {
2931
+ return this.globalStore.appDataStore.user;
2932
+ }
2933
+ setUserFeatures = (t) => {
2934
+ this.userFeatures = t, this.userFeaturesLoaded = !0;
2935
+ };
2936
+ loadUserFeatures = async () => {
2937
+ try {
2938
+ const t = await this.api.getUserFeatures();
2939
+ this.setUserFeatures(t);
2940
+ } catch (t) {
2941
+ console.error(`Error occurred while loading user features: ${t}`);
2942
+ }
2943
+ };
2944
+ updateUser = async (t) => {
2945
+ try {
2946
+ const e = await this.api.updateUser(t);
2947
+ this.globalStore.appDataStore.setUser(e);
2948
+ } catch (e) {
2949
+ console.error(`Error updating User: ${e}`);
2950
+ }
2951
+ };
2952
+ updateUserProfile = async (t) => {
2953
+ try {
2954
+ const e = await this.api.updateUserProfile(t);
2955
+ this.globalStore.appDataStore.setUserProfile(e);
2956
+ } catch (e) {
2957
+ console.error(`Error occurred while updating user profile: ${e}`);
2958
+ }
2959
+ };
2960
+ }
2961
+ export {
2962
+ G as A,
2963
+ j as B,
2964
+ _e as C,
2965
+ Te as D,
2966
+ Z as F,
2967
+ Ee as G,
2968
+ et as H,
2969
+ at as M,
2970
+ Ge as N,
2971
+ xe as R,
2972
+ rt as S,
2973
+ B as T,
2974
+ ot as U,
2975
+ ct as W,
2976
+ oe as a,
2977
+ de as b,
2978
+ Y as c,
2979
+ le as d,
2980
+ ge as e,
2981
+ X as f,
2982
+ pe as g,
2983
+ J as h,
2984
+ ye as i,
2985
+ Se as j,
2986
+ Ie as k,
2987
+ Ns as l,
2988
+ Ce as m,
2989
+ tt as n,
2990
+ De as o,
2991
+ ve as p,
2992
+ st as q,
2993
+ $e as r,
2994
+ Ne as s,
2995
+ nt as t,
2996
+ Be as u,
2997
+ it as v,
2998
+ Pe as w,
2999
+ Ue as x,
3000
+ ke as y,
3001
+ He as z
3002
+ };