@mx-cartographer/experiences 6.26.1-alpha.mega1 → 6.26.2-ram1-alpha-finstrong-financial-strength-section

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 (97) hide show
  1. package/CHANGELOG.md +13 -5
  2. package/dist/categories/util/CategoryUtil.d.ts +2 -3
  3. package/dist/common/context/hooks.d.ts +13 -13
  4. package/dist/common/types/Category.d.ts +8 -2
  5. package/dist/common/types/index.d.ts +1 -1
  6. package/dist/common/types/localization/FinstrongCopy.d.ts +10 -0
  7. package/dist/finstrong/FinancialStrengthCard.d.ts +3 -0
  8. package/dist/finstrong/components/ConnectMoreAccountsCard.d.ts +5 -1
  9. package/dist/finstrong/stores/FinstrongStore.d.ts +2 -2
  10. package/dist/finstrong/util/finstrongUtils.d.ts +1 -1
  11. package/dist/help/components/content/section/index.d.ts +15 -15
  12. package/dist/index.d.ts +22 -0
  13. package/dist/index.es.js +29963 -0
  14. package/dist/index.es.js.map +1 -0
  15. package/dist/trends/components/CategoriesList.d.ts +5 -5
  16. package/dist/trends/components/CategoriesListItem.d.ts +4 -7
  17. package/dist/trends/components/CategoryDetailChart.d.ts +1 -5
  18. package/dist/trends/stores/TrendsStore.d.ts +16 -11
  19. package/package.json +3 -91
  20. package/dist/AccountStore-DkL93tXL.mjs +0 -317
  21. package/dist/AccountStore-DkL93tXL.mjs.map +0 -1
  22. package/dist/BudgetUtil-CVqAdv-j.mjs +0 -187
  23. package/dist/BudgetUtil-CVqAdv-j.mjs.map +0 -1
  24. package/dist/CashflowStore-gPEEBiXo.mjs +0 -53
  25. package/dist/CashflowStore-gPEEBiXo.mjs.map +0 -1
  26. package/dist/CategoryStore-m7oieLzP.mjs +0 -260
  27. package/dist/CategoryStore-m7oieLzP.mjs.map +0 -1
  28. package/dist/ConnectMiniWidget-CQWafYtQ.mjs +0 -22966
  29. package/dist/ConnectMiniWidget-CQWafYtQ.mjs.map +0 -1
  30. package/dist/DebtsStore-cUhIgJx6.mjs +0 -145
  31. package/dist/DebtsStore-cUhIgJx6.mjs.map +0 -1
  32. package/dist/Donut-CGNFni9y.mjs +0 -58
  33. package/dist/Donut-CGNFni9y.mjs.map +0 -1
  34. package/dist/FinstrongStore-BDG7l0nI.mjs +0 -183
  35. package/dist/FinstrongStore-BDG7l0nI.mjs.map +0 -1
  36. package/dist/GoalStore-o2waGeyf.mjs +0 -293
  37. package/dist/GoalStore-o2waGeyf.mjs.map +0 -1
  38. package/dist/Loader-CwdK8lfx.mjs +0 -147
  39. package/dist/Loader-CwdK8lfx.mjs.map +0 -1
  40. package/dist/MerchantStore-Cck9IGIH.mjs +0 -125
  41. package/dist/MerchantStore-Cck9IGIH.mjs.map +0 -1
  42. package/dist/NetWorthStore-D5eUfGQt.mjs +0 -66
  43. package/dist/NetWorthStore-D5eUfGQt.mjs.map +0 -1
  44. package/dist/NotificationStore-DCxw8W7u.mjs +0 -141
  45. package/dist/NotificationStore-DCxw8W7u.mjs.map +0 -1
  46. package/dist/RecurringTransactionsStore-Bijrgllq.mjs +0 -337
  47. package/dist/RecurringTransactionsStore-Bijrgllq.mjs.map +0 -1
  48. package/dist/SettingsStore-BhOYgUOa.mjs +0 -352
  49. package/dist/SettingsStore-BhOYgUOa.mjs.map +0 -1
  50. package/dist/TransactionApi-Dnbyi1JL.mjs +0 -175
  51. package/dist/TransactionApi-Dnbyi1JL.mjs.map +0 -1
  52. package/dist/TransactionStore-CiEtt5XJ.mjs +0 -417
  53. package/dist/TransactionStore-CiEtt5XJ.mjs.map +0 -1
  54. package/dist/TrendsStore-Idq3QfoA.mjs +0 -131
  55. package/dist/TrendsStore-Idq3QfoA.mjs.map +0 -1
  56. package/dist/accounts/index.es.js +0 -18
  57. package/dist/accounts/index.es.js.map +0 -1
  58. package/dist/analytics/index.es.js +0 -170
  59. package/dist/analytics/index.es.js.map +0 -1
  60. package/dist/budgets/index.es.js +0 -1116
  61. package/dist/budgets/index.es.js.map +0 -1
  62. package/dist/cashflow/index.es.js +0 -118
  63. package/dist/cashflow/index.es.js.map +0 -1
  64. package/dist/categories/index.es.js +0 -10
  65. package/dist/categories/index.es.js.map +0 -1
  66. package/dist/common/index.es.js +0 -1549
  67. package/dist/common/index.es.js.map +0 -1
  68. package/dist/dashboard/index.es.js +0 -257
  69. package/dist/dashboard/index.es.js.map +0 -1
  70. package/dist/debts/index.es.js +0 -9
  71. package/dist/debts/index.es.js.map +0 -1
  72. package/dist/finstrong/index.es.js +0 -11
  73. package/dist/finstrong/index.es.js.map +0 -1
  74. package/dist/goals/index.es.js +0 -9
  75. package/dist/goals/index.es.js.map +0 -1
  76. package/dist/help/index.es.js +0 -6
  77. package/dist/help/index.es.js.map +0 -1
  78. package/dist/investments/index.es.js +0 -1694
  79. package/dist/investments/index.es.js.map +0 -1
  80. package/dist/merchants/index.es.js +0 -7
  81. package/dist/merchants/index.es.js.map +0 -1
  82. package/dist/microinsights/index.es.js +0 -21
  83. package/dist/microinsights/index.es.js.map +0 -1
  84. package/dist/networth/index.es.js +0 -11
  85. package/dist/networth/index.es.js.map +0 -1
  86. package/dist/notifications/index.es.js +0 -116
  87. package/dist/notifications/index.es.js.map +0 -1
  88. package/dist/recurringtransactions/index.es.js +0 -14
  89. package/dist/recurringtransactions/index.es.js.map +0 -1
  90. package/dist/settings/index.es.js +0 -112
  91. package/dist/settings/index.es.js.map +0 -1
  92. package/dist/spending/index.es.js +0 -632
  93. package/dist/spending/index.es.js.map +0 -1
  94. package/dist/transactions/index.es.js +0 -19
  95. package/dist/transactions/index.es.js.map +0 -1
  96. package/dist/trends/index.es.js +0 -10
  97. package/dist/trends/index.es.js.map +0 -1
@@ -1,187 +0,0 @@
1
- import "bowser";
2
- import "date-fns/getUnixTime";
3
- import "date-fns/intlFormat";
4
- import "react";
5
- import "react/jsx-runtime";
6
- import "@mui/material/Button";
7
- import "@mxenabled/mxui";
8
- import "@mui/material/Tooltip";
9
- import "@mui/material/Box";
10
- import "@mui/material/IconButton";
11
- import { aK as g, aL as c, aM as d } from "./ConnectMiniWidget-CQWafYtQ.mjs";
12
- import { u as _ } from "./Loader-CwdK8lfx.mjs";
13
- import "@mui/material/styles/useTheme";
14
- import "@mui/material/useMediaQuery";
15
- import "@mxenabled/cssinjs";
16
- import "date-fns/addDays";
17
- import "date-fns/addMonths";
18
- import "date-fns/eachDayOfInterval";
19
- import "date-fns/eachWeekOfInterval";
20
- import "date-fns/endOfMonth";
21
- import "date-fns/format";
22
- import "date-fns/isBefore";
23
- import "date-fns/isSameMonth";
24
- import "date-fns/startOfMonth";
25
- import "date-fns/startOfToday";
26
- import "date-fns/subMonths";
27
- import "@mui/material/Paper";
28
- import "@mxenabled/mx-icons";
29
- import "date-fns/isSameDay";
30
- import "date-fns/isWithinInterval";
31
- import "d3";
32
- import "@mui/material/styles";
33
- import "@mui/x-charts";
34
- import "@mui/material";
35
- import "@mui/x-charts/ChartsTooltip";
36
- import "@mui/material/Stack";
37
- import "date-fns/addYears";
38
- import "date-fns/differenceInCalendarDays";
39
- import "date-fns/endOfToday";
40
- import "date-fns/endOfYear";
41
- import "date-fns/startOfYear";
42
- import "date-fns/subDays";
43
- import "date-fns/subYears";
44
- import "@mui/material/ButtonGroup";
45
- import "@mui/material/Tab";
46
- import "@mui/material/Tabs";
47
- import "@mui/material/ToggleButton";
48
- import "@mui/material/ToggleButtonGroup";
49
- import "@mui/material/Dialog";
50
- import "@mui/material/DialogContent";
51
- import "@mui/material/Card";
52
- import "@mui/material/CardContent";
53
- import "@mui/material/CardHeader";
54
- import "uuid";
55
- import "numeral";
56
- import "@mui/material/CircularProgress";
57
- import "@mui/material/FormControlLabel";
58
- import "@mui/material/Radio";
59
- import "@mui/material/Avatar";
60
- import "@mui/material/ListItem";
61
- import "@mui/material/ListItemAvatar";
62
- import "@mui/material/ListItemButton";
63
- import "@mui/material/ListItemText";
64
- import "@mui/material/ListItemIcon";
65
- import "@mui/material/MenuItem";
66
- import "@mui/material/TextField";
67
- import "@mui/material/Switch";
68
- import "mobx";
69
- import "posthog-js";
70
- import "date-fns/differenceInDays";
71
- import "@mui/x-data-grid-pro";
72
- import "date-fns";
73
- import "@mui/material/Divider";
74
- import "@mui/material/List";
75
- import "date-fns/fromUnixTime";
76
- import "date-fns/formatISO";
77
- import "date-fns/isAfter";
78
- import "date-fns/addQuarters";
79
- import "date-fns/nextDay";
80
- import "date-fns/parseISO";
81
- import "date-fns/setDate";
82
- import "date-fns/subQuarters";
83
- import "date-fns/lastDayOfMonth";
84
- import "date-fns/setDayOfYear";
85
- import "date-fns/addWeeks";
86
- import "date-fns/getDay";
87
- import "date-fns/addSeconds";
88
- import "date-fns/differenceInCalendarMonths";
89
- import "date-fns/getMonth";
90
- const f = (o, r) => o.find((t) => t.guid === r), B = (o, r) => o.find((t) => t.guid === r), T = (o, r) => {
91
- const t = o.find((i) => i.subCategories.find((n) => n.guid === r));
92
- if (t)
93
- return t.subCategories.find((i) => i.guid === r);
94
- }, ir = (o, r) => {
95
- const t = [];
96
- for (const i of r) {
97
- const n = f(o, i.category_guid);
98
- if (!n) continue;
99
- const e = n.parent_guid ?? n.guid, a = f(o, e);
100
- if (!a) continue;
101
- const p = {
102
- amount: i.total,
103
- category: n,
104
- guid: n.guid,
105
- subCategoryTotals: []
106
- }, m = t.find((s) => s.guid === e);
107
- m ? (m.amount += i.total, m.subCategoryTotals.push(p)) : t.push({
108
- amount: i.total,
109
- category: a,
110
- guid: e,
111
- subCategoryTotals: [p]
112
- });
113
- }
114
- return t;
115
- }, er = (o, r) => {
116
- const t = o.find((i) => i.guid === r);
117
- return t ? t.guid === g.INCOME || t.parent_guid === g.INCOME : !1;
118
- }, l = (o, r) => !o && !r ? 0 : !o && r ? 101 : r / o * 100, y = (o, r) => {
119
- const t = {
120
- background: r.palette.success.main,
121
- description: o <= 100 ? r.palette.text.secondary : r.palette.error.main,
122
- text: r.palette.common.white,
123
- mercury: r.palette.success.lighter
124
- };
125
- return o > 100 ? (t.background = r.palette.error.main, t.mercury = r.palette.error.lighter) : o > 80 && (t.background = r.palette.warning.main, t.text = r.palette.grey[900], t.mercury = r.palette.warning.lighter), t;
126
- }, nr = () => {
127
- const { detailedBudgets: o } = _();
128
- return o.map((t) => {
129
- const i = t.transaction_total;
130
- return t.amount - i;
131
- }).reduce((t, i) => t + i, 0);
132
- }, ar = (o, r, t, i) => {
133
- const n = [];
134
- for (const e of o) {
135
- const a = B(r, e.category_guid);
136
- if (!a) continue;
137
- const p = a.totalAmount, m = l(e.amount, p), s = e.amount - p;
138
- n.push({
139
- ...e,
140
- budgetColors: y(m, i),
141
- category: a,
142
- description: c(
143
- s < 0 ? t.budget_remaining_over : t.budget_remaining_left,
144
- d(Math.abs(s), "0,0")
145
- ),
146
- percentage: m,
147
- subBudgets: [],
148
- transaction_total: p
149
- });
150
- }
151
- for (const e of o) {
152
- const a = T(r, e.category_guid);
153
- if (!a) continue;
154
- const p = a.currentAmount, m = n.find((C) => C.category_guid === a.parent_guid);
155
- if (!m) continue;
156
- const s = e.amount - p, u = l(e.amount, p);
157
- m && m.subBudgets.push({
158
- ...e,
159
- budgetColors: y(u, i),
160
- category: a,
161
- description: c(
162
- s < 0 ? t.budget_remaining_over : t.budget_remaining_left,
163
- d(Math.abs(s), "0,0")
164
- ),
165
- percentage: u,
166
- subBudgets: [],
167
- transaction_total: p
168
- });
169
- }
170
- return n;
171
- }, b = (o, r) => o.find((t) => t.guid === r), pr = (o, r, t) => {
172
- const i = b(o, t);
173
- if (i)
174
- return b(i.subBudgets, r);
175
- };
176
- export {
177
- pr as a,
178
- ar as b,
179
- B as c,
180
- T as d,
181
- ir as e,
182
- b as f,
183
- f as g,
184
- er as i,
185
- nr as u
186
- };
187
- //# sourceMappingURL=BudgetUtil-CVqAdv-j.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BudgetUtil-CVqAdv-j.mjs","sources":["../src/common/utils/Categories.ts","../src/budgets/utils/BudgetUtil.ts"],"sourcesContent":["import type { Category, CategoryTotal, DateRangeCategoryTotals, DetailedCategory } from '../types'\nimport { CategoryGuids } from '../constants'\n\nexport const getCategory = (\n categories: Category[],\n categoryGuid: string | undefined,\n): Category | undefined => {\n return categories.find((c) => c.guid === categoryGuid)\n}\n\nexport const getDetailedCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n return detailedCategories.find((dc) => dc.guid === guid)\n}\n\nexport const getDetailedSubCategory = (\n detailedCategories: DetailedCategory[],\n guid: string | undefined,\n): DetailedCategory | undefined => {\n const parent = detailedCategories.find((dc) => dc.subCategories.find((sc) => sc.guid === guid))\n if (!parent) return undefined\n\n return parent.subCategories.find((sc) => sc.guid === guid)\n}\n\nexport const getCategoryTotalsByParent = (\n categories: Category[],\n dateRangeTotals: DateRangeCategoryTotals[],\n): CategoryTotal[] => {\n const categoryTotals = [] as CategoryTotal[]\n\n // Iterate over the category data from BE and roll up all categories into parent categories\n // acc is the accumulated category totals of type CategoryTotal that is initialized as an empty []\n // curr is the current DateRangeCategoryTotal\n\n for (const dateRangeTotal of dateRangeTotals) {\n const category = getCategory(categories, dateRangeTotal.category_guid)\n if (!category) continue\n\n const parentGuid = category.parent_guid ?? category.guid\n const parentCategory = getCategory(categories, parentGuid)\n if (!parentCategory) continue\n\n const categoryTotal = {\n amount: dateRangeTotal.total,\n category,\n guid: category.guid,\n subCategoryTotals: [],\n }\n\n const parentCategoryTotal = categoryTotals.find((ct) => ct.guid === parentGuid)\n if (parentCategoryTotal) {\n parentCategoryTotal.amount += dateRangeTotal.total\n parentCategoryTotal.subCategoryTotals.push(categoryTotal)\n } else {\n categoryTotals.push({\n amount: dateRangeTotal.total,\n category: parentCategory,\n guid: parentGuid,\n subCategoryTotals: [categoryTotal],\n })\n }\n }\n\n return categoryTotals\n}\n\nexport const isIncome = (categories: Category[], guid: string) => {\n const category = categories.find((c) => c.guid === guid)\n if (!category) return false\n\n return category.guid === CategoryGuids.INCOME || category.parent_guid === CategoryGuids.INCOME\n}\n","import type { Theme } from '@mui/system'\n\nimport {\n type Budget,\n type BudgetColors,\n type BudgetsCopy,\n type DetailedCategory,\n type DetailedBudget,\n buildDynamicCopy,\n formatCurrency,\n getDetailedCategory,\n getDetailedSubCategory,\n useBudgetsStore,\n} from '../../common'\n\nexport const getBudgetPercentage = (budgetAmount: number, totalAmount: number) => {\n // No budget amount and nothing spent results in zero percent and green bubble\n if (!budgetAmount && !totalAmount) {\n return 0\n }\n\n // No budget amount and money spent results in 101 percent and red bubble\n if (!budgetAmount && totalAmount) {\n return 101\n }\n\n // Budget amount and money spent results in calculating percentage for color\n return (totalAmount / budgetAmount) * 100\n}\n\nexport const getBudgetColors = (percentage: number, theme: Theme) => {\n const budgetColors: BudgetColors = {\n background: theme.palette.success.main,\n description: percentage <= 100 ? theme.palette.text.secondary : theme.palette.error.main,\n text: theme.palette.common.white,\n mercury: theme.palette.success.lighter,\n }\n\n if (percentage > 100) {\n budgetColors.background = theme.palette.error.main\n budgetColors.mercury = theme.palette.error.lighter\n } else if (percentage > 80) {\n budgetColors.background = theme.palette.warning.main\n budgetColors.text = theme.palette.grey['900']\n budgetColors.mercury = theme.palette.warning.lighter\n }\n\n return budgetColors\n}\n\nexport const useGetBudgetDifference = () => {\n const { detailedBudgets: budgets } = useBudgetsStore()\n\n const differences = budgets.map((budget) => {\n const currentAmount = budget.transaction_total\n const totalAmount = budget.amount\n return totalAmount - currentAmount\n })\n\n return differences.reduce((total, difference) => total + difference, 0)\n}\n\nexport const augmentBudgets = (\n budgets: Budget[],\n categories: DetailedCategory[],\n copy: BudgetsCopy,\n theme: Theme,\n): DetailedBudget[] => {\n const detailedBudgets = [] as DetailedBudget[]\n\n // Top-level Categories\n for (const budget of budgets) {\n const category = getDetailedCategory(categories, budget.category_guid)\n if (!category) continue\n\n const spent = category.totalAmount\n\n const percentage = getBudgetPercentage(budget.amount, spent)\n const difference = budget.amount - spent\n\n detailedBudgets.push({\n ...budget,\n budgetColors: getBudgetColors(percentage, theme),\n category,\n description: buildDynamicCopy(\n difference < 0 ? copy.budget_remaining_over : copy.budget_remaining_left,\n formatCurrency(Math.abs(difference), '0,0'),\n ) as string,\n percentage,\n subBudgets: [],\n transaction_total: spent,\n })\n }\n\n // Sub categories\n for (const budget of budgets) {\n const category = getDetailedSubCategory(categories, budget.category_guid)\n if (!category) continue\n\n const spent = category.currentAmount\n\n const parentBudget = detailedBudgets.find((b) => b.category_guid === category.parent_guid)\n if (!parentBudget) continue\n\n const difference = budget.amount - spent\n const percentage = getBudgetPercentage(budget.amount, spent)\n\n if (parentBudget) {\n parentBudget.subBudgets.push({\n ...budget,\n budgetColors: getBudgetColors(percentage, theme),\n category,\n description: buildDynamicCopy(\n difference < 0 ? copy.budget_remaining_over : copy.budget_remaining_left,\n formatCurrency(Math.abs(difference), '0,0'),\n ) as string,\n percentage,\n subBudgets: [],\n transaction_total: spent,\n })\n }\n }\n\n return detailedBudgets\n}\n\nexport const findBudget = (budgets: DetailedBudget[], guid: string): DetailedBudget | undefined => {\n return budgets.find((budget) => budget.guid === guid)\n}\n\nexport const findSubBudget = (\n budgets: DetailedBudget[],\n guid: string,\n parentGuid: string,\n): DetailedBudget | undefined => {\n const parent = findBudget(budgets, parentGuid)\n if (!parent) return undefined\n\n return findBudget(parent.subBudgets, guid)\n}\n"],"names":["getCategory","categories","categoryGuid","c","getDetailedCategory","detailedCategories","guid","dc","getDetailedSubCategory","parent","sc","getCategoryTotalsByParent","dateRangeTotals","categoryTotals","dateRangeTotal","category","parentGuid","parentCategory","categoryTotal","parentCategoryTotal","ct","isIncome","CategoryGuids","getBudgetPercentage","budgetAmount","totalAmount","getBudgetColors","percentage","theme","budgetColors","useGetBudgetDifference","budgets","useBudgetsStore","budget","currentAmount","total","difference","augmentBudgets","copy","detailedBudgets","spent","buildDynamicCopy","formatCurrency","parentBudget","b","findBudget","findSubBudget"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGa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r } from "date-fns/addDays";
3
- import { differenceInDays as n } from "date-fns/differenceInDays";
4
- import { endOfMonth as i } from "date-fns/endOfMonth";
5
- import { isBefore as a } from "date-fns/isBefore";
6
- import { startOfToday as t } from "date-fns/startOfToday";
7
- class c {
8
- // Cashflow is hard-coded to display 30 days starting from today
9
- dateRange = { start: t(), end: r(t(), 30) };
10
- isDirty = !1;
11
- nextIncome = void 0;
12
- upcomingExpenses = [];
13
- selectedCashAccounts = [];
14
- constructor() {
15
- o(this);
16
- }
17
- // Returns the number of days until the next income activity or 0 if there is no income activity
18
- get daysUntilNextIncome() {
19
- return this.nextIncome ? Math.abs(n(t(), this.nextIncome.expectedDate)) : 0;
20
- }
21
- // Returns the expenses (Activities) until the next income activity or the end of the month
22
- // if there is no income activity
23
- get expensesTilNextIncome() {
24
- return this.upcomingExpenses.filter(
25
- (e) => a(e.expectedDate, this.nextIncome?.expectedDate || i(/* @__PURE__ */ new Date()))
26
- );
27
- }
28
- setNextIncome = (e) => {
29
- this.nextIncome = e;
30
- };
31
- setUpcomingExpenses = (e) => {
32
- this.upcomingExpenses = e;
33
- };
34
- setSelectedCashAccounts = (e) => this.selectedCashAccounts = e;
35
- }
36
- class f {
37
- globalStore;
38
- uiStore;
39
- constructor(e) {
40
- this.globalStore = e, this.uiStore = new c(), o(this);
41
- }
42
- completeOnboarding = async () => {
43
- const e = {
44
- ...this.globalStore.userStore.userProfile,
45
- has_completed_cash_flow_onboarding: !0
46
- };
47
- await this.globalStore.userStore.updateUserProfile(e);
48
- };
49
- }
50
- export {
51
- f as C
52
- };
53
- //# sourceMappingURL=CashflowStore-gPEEBiXo.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CashflowStore-gPEEBiXo.mjs","sources":["../src/cashflow/stores/UiStore.ts","../src/cashflow/stores/CashflowStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\nimport { addDays } from 'date-fns/addDays'\nimport { differenceInDays } from 'date-fns/differenceInDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { type Account, type Recurrence } from '../../common'\n\nexport class UiStore {\n // Cashflow is hard-coded to display 30 days starting from today\n dateRange = { start: startOfToday(), end: addDays(startOfToday(), 30) }\n isDirty = false\n\n nextIncome: Recurrence | undefined = undefined\n upcomingExpenses: Recurrence[] = []\n\n selectedCashAccounts: Account[] = []\n\n constructor() {\n makeAutoObservable(this)\n }\n\n // Returns the number of days until the next income activity or 0 if there is no income activity\n get daysUntilNextIncome() {\n return this.nextIncome\n ? Math.abs(differenceInDays(startOfToday(), this.nextIncome.expectedDate))\n : 0\n }\n\n // Returns the expenses (Activities) until the next income activity or the end of the month\n // if there is no income activity\n get expensesTilNextIncome() {\n return this.upcomingExpenses.filter((a) =>\n isBefore(a.expectedDate, this.nextIncome?.expectedDate || endOfMonth(new Date())),\n )\n }\n\n setNextIncome = (nextIncome: Recurrence) => {\n this.nextIncome = nextIncome\n }\n\n setUpcomingExpenses = (expenses: Recurrence[]) => {\n this.upcomingExpenses = expenses\n }\n\n setSelectedCashAccounts = (accounts: Account[]) => (this.selectedCashAccounts = accounts)\n}\n","import { makeAutoObservable } from 'mobx'\n\nimport { GlobalStore, type UserProfile } from '../../common'\n\nimport { UiStore } from './UiStore'\n\nexport class CashflowStore {\n globalStore: GlobalStore\n uiStore: UiStore\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n\n makeAutoObservable(this)\n }\n\n completeOnboarding = async () => {\n const updatedUserProfile = {\n ...this.globalStore.userStore.userProfile,\n has_completed_cash_flow_onboarding: true,\n } as UserProfile\n\n await this.globalStore.userStore.updateUserProfile(updatedUserProfile)\n }\n}\n"],"names":["UiStore","startOfToday","addDays","makeAutoObservable","differenceInDays","a","isBefore","endOfMonth","nextIncome","expenses","accounts","CashflowStore","globalStore","updatedUserProfile"],"mappings":";;;;;;AASO,MAAMA,EAAQ;AAAA;AAAA,EAEnB,YAAY,EAAE,OAAOC,KAAgB,KAAKC,EAAQD,EAAA,GAAgB,EAAE;EACpE,UAAU;AAAA,EAEV,aAAqC;AAAA,EACrC,mBAAiC,CAAA;AAAA,EAEjC,uBAAkC,CAAA;AAAA,EAElC,cAAc;AACZ,IAAAE,EAAmB,IAAI;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,sBAAsB;AACjB,WAAA,KAAK,aACR,KAAK,IAAIC,EAAiBH,EAAa,GAAG,KAAK,WAAW,YAAY,CAAC,IACvE;AAAA,EACN;AAAA;AAAA;AAAA,EAIA,IAAI,wBAAwB;AAC1B,WAAO,KAAK,iBAAiB;AAAA,MAAO,CAACI,MACnCC,EAASD,EAAE,cAAc,KAAK,YAAY,gBAAgBE,EAAW,oBAAI,KAAM,CAAA,CAAC;AAAA,IAAA;AAAA,EAEpF;AAAA,EAEA,gBAAgB,CAACC,MAA2B;AAC1C,SAAK,aAAaA;AAAA,EAAA;AAAA,EAGpB,sBAAsB,CAACC,MAA2B;AAChD,SAAK,mBAAmBA;AAAA,EAAA;AAAA,EAG1B,0BAA0B,CAACC,MAAyB,KAAK,uBAAuBA;AAClF;ACzCO,MAAMC,EAAc;AAAA,EACzB;AAAA,EACA;AAAA,EAEA,YAAYC,GAA0B;AACpC,SAAK,cAAcA,GACd,KAAA,UAAU,IAAIZ,KAEnBG,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,qBAAqB,YAAY;AAC/B,UAAMU,IAAqB;AAAA,MACzB,GAAG,KAAK,YAAY,UAAU;AAAA,MAC9B,oCAAoC;AAAA,IAAA;AAGtC,UAAM,KAAK,YAAY,UAAU,kBAAkBA,CAAkB;AAAA,EAAA;AAEzE;"}
@@ -1,260 +0,0 @@
1
- import { makeAutoObservable as d, runInAction as l } from "mobx";
2
- import { getUnixTime as a } from "date-fns/getUnixTime";
3
- import { subMonths as g } from "date-fns/subMonths";
4
- import { startOfMonth as m } from "date-fns/startOfMonth";
5
- import { endOfMonth as p } from "date-fns/endOfMonth";
6
- import "bowser";
7
- import "date-fns/intlFormat";
8
- import { ae as u, af as s, aX as C, aK as T, aY as f } from "./ConnectMiniWidget-CQWafYtQ.mjs";
9
- import "date-fns/addMonths";
10
- import "date-fns/addQuarters";
11
- import "date-fns/addWeeks";
12
- import "date-fns/addYears";
13
- import "date-fns/getDay";
14
- import "date-fns/isBefore";
15
- import "date-fns/nextDay";
16
- import "date-fns/setDate";
17
- import "date-fns/startOfToday";
18
- import "date-fns/fromUnixTime";
19
- import "react";
20
- import "numeral";
21
- import "@mui/material";
22
- import "react/jsx-runtime";
23
- import "@mui/material/Button";
24
- import "@mxenabled/mxui";
25
- import "@mui/material/Tooltip";
26
- import "@mui/material/Box";
27
- import "@mui/material/IconButton";
28
- import "./Loader-CwdK8lfx.mjs";
29
- import "@mui/material/styles/useTheme";
30
- import "@mui/material/useMediaQuery";
31
- import "@mxenabled/cssinjs";
32
- import "date-fns/addDays";
33
- import "date-fns/eachDayOfInterval";
34
- import "date-fns/eachWeekOfInterval";
35
- import "date-fns/format";
36
- import "date-fns/isSameMonth";
37
- import "@mui/material/Paper";
38
- import "@mxenabled/mx-icons";
39
- import "date-fns/isSameDay";
40
- import "date-fns/isWithinInterval";
41
- import "d3";
42
- import "@mui/material/styles";
43
- import "@mui/x-charts";
44
- import "@mui/x-charts/ChartsTooltip";
45
- import "@mui/material/Stack";
46
- import "date-fns/differenceInCalendarDays";
47
- import "date-fns/endOfToday";
48
- import "date-fns/endOfYear";
49
- import "date-fns/startOfYear";
50
- import "date-fns/subDays";
51
- import "date-fns/subYears";
52
- import "@mui/material/ButtonGroup";
53
- import "@mui/material/Tab";
54
- import "@mui/material/Tabs";
55
- import "@mui/material/ToggleButton";
56
- import "@mui/material/ToggleButtonGroup";
57
- import "@mui/material/Dialog";
58
- import "@mui/material/DialogContent";
59
- import "@mui/material/Card";
60
- import "@mui/material/CardContent";
61
- import "@mui/material/CardHeader";
62
- import "uuid";
63
- import "@mui/material/CircularProgress";
64
- import "@mui/material/FormControlLabel";
65
- import "@mui/material/Radio";
66
- import "@mui/material/Avatar";
67
- import "@mui/material/ListItem";
68
- import "@mui/material/ListItemAvatar";
69
- import "@mui/material/ListItemButton";
70
- import "@mui/material/ListItemText";
71
- import "@mui/material/ListItemIcon";
72
- import "@mui/material/MenuItem";
73
- import "@mui/material/TextField";
74
- import "@mui/material/Switch";
75
- import "posthog-js";
76
- import "date-fns/differenceInDays";
77
- import "@mui/x-data-grid-pro";
78
- import "date-fns";
79
- import "@mui/material/Divider";
80
- import "@mui/material/List";
81
- import "date-fns/formatISO";
82
- import "date-fns/isAfter";
83
- import "date-fns/parseISO";
84
- import "date-fns/subQuarters";
85
- import "date-fns/lastDayOfMonth";
86
- import "date-fns/setDayOfYear";
87
- import "date-fns/addSeconds";
88
- import "date-fns/differenceInCalendarMonths";
89
- import "date-fns/getMonth";
90
- class h {
91
- fetchInstance;
92
- constructor(t, e) {
93
- this.fetchInstance = new u(t, e);
94
- }
95
- addCategory = async (t) => this.fetchInstance.post(s.CATEGORIES, t).then((e) => e.category);
96
- getCategories = async () => this.fetchInstance.get(s.CATEGORIES).then((t) => t.categories);
97
- getDateRangeCategoryTotals = async (t, e, r) => r.length === 0 ? [] : this.fetchInstance.post(`${s.DATE_RANGE_CATEGORY_TOTALS}/from/${t}/to/${e}`, {
98
- account_guid: r.map((o) => o.guid)
99
- }).then((o) => o.date_range_category_totals);
100
- getMonthlyCategoryTotals = async (t, e, r) => {
101
- try {
102
- const o = `${s.MONTHLY_CATEGORY_TOTALS}/from/${t}/to/${e}`;
103
- if (r) {
104
- const i = r.length === 0 ? [""] : r.map((y) => y.guid);
105
- return (await this.fetchInstance.post(o, { account_guid: i })).monthly_category_totals;
106
- } else
107
- return (await this.fetchInstance.get(o)).monthly_category_totals;
108
- } catch (o) {
109
- throw console.error("Error fetching monthly category totals:", o), o;
110
- }
111
- };
112
- removeCategory = async (t) => this.fetchInstance.delete(`${s.CATEGORIES}/${t}`);
113
- updateCategory = async (t) => this.fetchInstance.put(`${s.CATEGORIES}/${t.guid}`, t).then((e) => e.category);
114
- }
115
- class w {
116
- expandedGuid = null;
117
- selectedGuid = null;
118
- searchValue = "";
119
- showSelected = !0;
120
- shouldDisableDrawerScroll = !1;
121
- unselectable = [];
122
- unselectableText = "";
123
- savedOnSelect;
124
- // todo
125
- constructor() {
126
- d(this);
127
- }
128
- setExpandedGuid = (t) => this.expandedGuid = t;
129
- setSelectedGuid = (t) => this.selectedGuid = t;
130
- setSearchValue = (t) => this.searchValue = t;
131
- setShouldDisableDrawerScroll = (t) => this.shouldDisableDrawerScroll = t;
132
- setShowSelected = (t) => this.showSelected = t;
133
- setUnselectable = (t) => this.unselectable = t;
134
- setUnselectableText = (t) => this.unselectableText = t;
135
- onSelect = (t) => this.savedOnSelect(t);
136
- setOnSelect = (t) => this.savedOnSelect = t;
137
- }
138
- class oe {
139
- globalStore;
140
- uiStore;
141
- api = new h("/", "");
142
- categories = [];
143
- dateRangeCategoryTotals = [];
144
- monthlyCategoryTotals = [];
145
- dataRangeTotalsLoaded = !1;
146
- isLoadingCategoryTotals = !1;
147
- monthlyTotalsLoaded = !1;
148
- constructor(t) {
149
- this.globalStore = t, this.uiStore = new w(), this.api = new h(t.endpoint, t.sessionToken), d(this);
150
- }
151
- get detailedCategories() {
152
- return C(
153
- this.categories,
154
- this.dateRangeCategoryTotals,
155
- this.monthlyCategoryTotals,
156
- this.globalStore.transactionStore.sortedTransactions
157
- );
158
- }
159
- get incomeCategories() {
160
- return this.detailedCategories.filter((t) => t.is_income);
161
- }
162
- get spendCategories() {
163
- return this.detailedCategories.filter(
164
- (t) => !t.is_income && !t.isTransfer && t.guid !== T.INVESTMENTS
165
- );
166
- }
167
- get transferCategories() {
168
- return this.detailedCategories.filter((t) => t.isTransfer);
169
- }
170
- addCategory = async (t, e) => {
171
- const r = { name: t, parent_guid: e };
172
- try {
173
- await this.api.addCategory(r), await this.loadCategories();
174
- } catch (o) {
175
- console.error(`Error occurred while adding category: ${o}`);
176
- }
177
- };
178
- loadCategories = async (t) => {
179
- try {
180
- const e = t || await this.api.getCategories(), { default_categories: r } = this.globalStore.copyStore.copy.categories;
181
- l(() => {
182
- this.categories = e.map((o) => ({
183
- ...o,
184
- name: r[o.guid] ? r[o.guid].replace(/&amp;/g, "&") : o.name
185
- }));
186
- });
187
- } catch (e) {
188
- console.error(`Error occurred while getting categories: ${e}`);
189
- }
190
- };
191
- loadDateRangeCategoryTotals = async (t, e, r) => {
192
- this.setIsLoadingCategoryTotals(!0);
193
- try {
194
- const o = await this.api.getDateRangeCategoryTotals(
195
- a(e),
196
- a(r),
197
- t
198
- );
199
- l(() => {
200
- this.dateRangeCategoryTotals = o, this.setIsLoadingCategoryTotals(!1), this.dataRangeTotalsLoaded = !0;
201
- });
202
- } catch (o) {
203
- this.setIsLoadingCategoryTotals(!1), console.error(`Error occurred while getting date range category totals: ${o}`);
204
- }
205
- };
206
- loadMonthlyCategoryTotals = async (t = this.globalStore.globalUiStore.selectedAccounts, e, r) => {
207
- const o = a(m(e ?? g(/* @__PURE__ */ new Date(), 11))), i = a(p(r ?? /* @__PURE__ */ new Date()));
208
- try {
209
- const n = await this.api.getMonthlyCategoryTotals(o, i, t);
210
- l(() => {
211
- this.monthlyCategoryTotals = n, this.monthlyTotalsLoaded = !0;
212
- });
213
- } catch (n) {
214
- console.error(`Error occurred while getting monthly category totals: ${n}`);
215
- }
216
- };
217
- reloadCategoryTotals = async (t, e, r) => {
218
- this.setIsLoadingCategoryTotals(!0);
219
- try {
220
- const o = await this.api.getDateRangeCategoryTotals(
221
- a(e),
222
- a(r),
223
- t
224
- ), i = await this.api.getMonthlyCategoryTotals(
225
- a(m(g(r, 11))),
226
- a(p(r)),
227
- t
228
- );
229
- l(() => {
230
- this.dateRangeCategoryTotals = o, this.monthlyCategoryTotals = i, this.dataRangeTotalsLoaded = !0, this.monthlyTotalsLoaded = !0, this.setIsLoadingCategoryTotals(!1);
231
- });
232
- } catch (o) {
233
- console.error(`Error occurred while getting category totals: ${o}`);
234
- }
235
- };
236
- removeCategory = async (t) => {
237
- try {
238
- await this.api.removeCategory(t), await this.loadCategories();
239
- } catch (e) {
240
- console.error(`Error occurred while removing category: ${e}`);
241
- }
242
- };
243
- setIsLoadingCategoryTotals = (t) => {
244
- this.isLoadingCategoryTotals = t;
245
- };
246
- updateCategory = async (t) => {
247
- try {
248
- await this.api.updateCategory(t), await this.loadCategories();
249
- } catch (e) {
250
- console.error(`Error occurred while updating category: ${e}`);
251
- }
252
- };
253
- // TODO: Remove this after refactoring Trends components to use detailedCategories
254
- getCategoryName = (t) => this.categories.find((r) => r.guid === t)?.name ?? f[t];
255
- }
256
- export {
257
- oe as C,
258
- h as a
259
- };
260
- //# sourceMappingURL=CategoryStore-m7oieLzP.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CategoryStore-m7oieLzP.mjs","sources":["../src/common/api/CategoryApi.ts","../src/categories/stores/UiStore.ts","../src/categories/stores/CategoryStore.ts"],"sourcesContent":["import Fetch from '../utils/Fetch'\n\nimport { ApiEndpoints } from '../constants/ApiEndpoints'\n\nimport type { Account } from '../types/Account'\nimport type { Category } from '../types/Category'\n\nexport class CategoryApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string) {\n this.fetchInstance = new Fetch(endpoint, token)\n }\n\n addCategory = async (category: Category) => {\n return this.fetchInstance.post(ApiEndpoints.CATEGORIES, category).then((data) => data.category)\n }\n\n getCategories = async () => {\n return this.fetchInstance.get(ApiEndpoints.CATEGORIES).then((data) => data.categories)\n }\n\n getDateRangeCategoryTotals = async (startDate: number, endDate: number, accounts: Account[]) => {\n // If no accounts are selected, return an empty array\n if (accounts.length === 0) return []\n return this.fetchInstance\n .post(`${ApiEndpoints.DATE_RANGE_CATEGORY_TOTALS}/from/${startDate}/to/${endDate}`, {\n account_guid: accounts.map((account) => account.guid),\n })\n .then((data) => data.date_range_category_totals)\n }\n\n getMonthlyCategoryTotals = async (startDate: number, endDate: number, accounts?: Account[]) => {\n try {\n const url = `${ApiEndpoints.MONTHLY_CATEGORY_TOTALS}/from/${startDate}/to/${endDate}`\n if (accounts) {\n const accountGuids = accounts.length === 0 ? [''] : accounts.map((account) => account.guid)\n const response = await this.fetchInstance.post(url, { account_guid: accountGuids })\n return response.monthly_category_totals\n } else {\n const response = await this.fetchInstance.get(url)\n return response.monthly_category_totals\n }\n } catch (error) {\n console.error('Error fetching monthly category totals:', error)\n throw error // Re-throw the error for the caller to handle\n }\n }\n removeCategory = async (guid: string) => {\n return this.fetchInstance.delete(`${ApiEndpoints.CATEGORIES}/${guid}`)\n }\n\n updateCategory = async (category: Category) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.CATEGORIES}/${category.guid}`, category)\n .then((data) => data.category)\n }\n}\n","import { makeAutoObservable } from 'mobx'\n\nexport class UiStore {\n expandedGuid: string | null = null\n selectedGuid: string | null = null\n searchValue = ''\n showSelected = true\n shouldDisableDrawerScroll = false\n unselectable: string[] = []\n unselectableText = ''\n\n savedOnSelect: any // todo\n\n constructor() {\n makeAutoObservable(this)\n }\n\n setExpandedGuid = (guid: string | null) => (this.expandedGuid = guid)\n\n setSelectedGuid = (guid: string | null) => (this.selectedGuid = guid)\n\n setSearchValue = (value: string) => (this.searchValue = value)\n\n setShouldDisableDrawerScroll = (shouldDisable: boolean) =>\n (this.shouldDisableDrawerScroll = shouldDisable)\n\n setShowSelected = (showSelected: boolean) => (this.showSelected = showSelected)\n\n setUnselectable = (unselectable: string[]) => (this.unselectable = unselectable)\n\n setUnselectableText = (text: string) => (this.unselectableText = text)\n\n onSelect = (guid: string) => this.savedOnSelect(guid)\n\n setOnSelect = (callback: any) => (this.savedOnSelect = callback)\n}\n","import { makeAutoObservable, runInAction } from 'mobx'\nimport { getUnixTime } from 'date-fns/getUnixTime'\nimport { subMonths } from 'date-fns/subMonths'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { endOfMonth } from 'date-fns/endOfMonth'\n\nimport { Account, CategoryApi, CategoryGuids, CategoryGuidToName } from '../../common'\n\nimport type {\n Category,\n DetailedCategory,\n DateRangeCategoryTotals,\n GlobalStore,\n MonthlyCategoryTotals,\n} from '../../common'\n\nimport { augmentCategories } from '../util/CategoryUtil'\nimport { UiStore } from './UiStore'\n\nexport class CategoryStore {\n globalStore: GlobalStore\n uiStore: UiStore\n api = new CategoryApi('/', '')\n\n categories: Category[] = []\n dateRangeCategoryTotals: DateRangeCategoryTotals[] = []\n monthlyCategoryTotals: MonthlyCategoryTotals[] = []\n\n dataRangeTotalsLoaded = false\n isLoadingCategoryTotals = false\n monthlyTotalsLoaded = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n this.api = new CategoryApi(globalStore.endpoint, globalStore.sessionToken)\n\n makeAutoObservable(this)\n }\n\n get detailedCategories(): DetailedCategory[] {\n return augmentCategories(\n this.categories,\n this.dateRangeCategoryTotals,\n this.monthlyCategoryTotals,\n this.globalStore.transactionStore.sortedTransactions,\n )\n }\n\n get incomeCategories(): DetailedCategory[] {\n return this.detailedCategories.filter((c) => c.is_income)\n }\n\n get spendCategories(): DetailedCategory[] {\n return this.detailedCategories.filter(\n (c) => !c.is_income && !c.isTransfer && c.guid !== CategoryGuids.INVESTMENTS,\n )\n }\n\n get transferCategories(): DetailedCategory[] {\n return this.detailedCategories.filter((c) => c.isTransfer)\n }\n\n addCategory = async (name: string, parentGuid: string) => {\n const category = { name, parent_guid: parentGuid } as Category\n\n try {\n await this.api.addCategory(category)\n await this.loadCategories()\n } catch (error) {\n console.error(`Error occurred while adding category: ${error}`)\n }\n }\n\n loadCategories = async (categoriesOverride?: Category[]) => {\n try {\n const categories = categoriesOverride || (await this.api.getCategories())\n const { default_categories } = this.globalStore.copyStore.copy.categories\n\n runInAction(() => {\n this.categories = categories.map((category: Category) => ({\n ...category,\n name: default_categories[category.guid]\n ? default_categories[category.guid].replace(/&amp;/g, '&')\n : category.name,\n }))\n })\n } catch (error) {\n console.error(`Error occurred while getting categories: ${error}`)\n }\n }\n\n loadDateRangeCategoryTotals = async (accounts: Account[], startDate: Date, endDate: Date) => {\n this.setIsLoadingCategoryTotals(true)\n try {\n const totals = await this.api.getDateRangeCategoryTotals(\n getUnixTime(startDate),\n getUnixTime(endDate),\n accounts,\n )\n runInAction(() => {\n this.dateRangeCategoryTotals = totals\n this.setIsLoadingCategoryTotals(false)\n this.dataRangeTotalsLoaded = true\n })\n } catch (error) {\n this.setIsLoadingCategoryTotals(false)\n console.error(`Error occurred while getting date range category totals: ${error}`)\n }\n }\n\n loadMonthlyCategoryTotals = async (\n accounts: Account[] = this.globalStore.globalUiStore.selectedAccounts,\n startDate?: Date,\n endDate?: Date,\n ) => {\n const start = getUnixTime(startOfMonth(startDate ?? subMonths(new Date(), 11)))\n const end = getUnixTime(endOfMonth(endDate ?? new Date()))\n\n try {\n const totals = await this.api.getMonthlyCategoryTotals(start, end, accounts)\n\n runInAction(() => {\n this.monthlyCategoryTotals = totals\n this.monthlyTotalsLoaded = true\n })\n } catch (error) {\n console.error(`Error occurred while getting monthly category totals: ${error}`)\n }\n }\n\n reloadCategoryTotals = async (accounts: Account[], startDate: Date, endDate: Date) => {\n this.setIsLoadingCategoryTotals(true)\n try {\n const dateRangeTotals = await this.api.getDateRangeCategoryTotals(\n getUnixTime(startDate),\n getUnixTime(endDate),\n accounts,\n )\n\n const monthlyTotals = await this.api.getMonthlyCategoryTotals(\n getUnixTime(startOfMonth(subMonths(endDate, 11))),\n getUnixTime(endOfMonth(endDate)),\n accounts,\n )\n\n runInAction(() => {\n this.dateRangeCategoryTotals = dateRangeTotals\n this.monthlyCategoryTotals = monthlyTotals\n this.dataRangeTotalsLoaded = true\n this.monthlyTotalsLoaded = true\n this.setIsLoadingCategoryTotals(false)\n })\n } catch (error) {\n console.error(`Error occurred while getting category totals: ${error}`)\n }\n }\n\n removeCategory = async (guid: string) => {\n try {\n await this.api.removeCategory(guid)\n await this.loadCategories()\n } catch (error) {\n console.error(`Error occurred while removing category: ${error}`)\n }\n }\n\n setIsLoadingCategoryTotals = (isLoading: boolean) => {\n this.isLoadingCategoryTotals = isLoading\n }\n\n updateCategory = async (category: Category) => {\n try {\n await this.api.updateCategory(category)\n await this.loadCategories()\n } catch (error) {\n console.error(`Error occurred while updating category: ${error}`)\n }\n }\n\n // TODO: Remove this after refactoring Trends components to use detailedCategories\n getCategoryName = (guid: string) => {\n const category = this.categories.find((c) => c.guid === guid)\n return category?.name ?? CategoryGuidToName[guid]\n }\n}\n"],"names":["CategoryApi","endpoint","token","Fetch","category","ApiEndpoints","data","startDate","endDate","accounts","account","url","accountGuids","error","guid","UiStore","makeAutoObservable","value","shouldDisable","showSelected","unselectable","text","callback","CategoryStore","globalStore","augmentCategories","c","CategoryGuids","name","parentGuid","categoriesOverride","categories","default_categories","runInAction","totals","getUnixTime","start","startOfMonth","subMonths","end","endOfMonth","dateRangeTotals","monthlyTotals","isLoading","CategoryGuidToName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,MAAMA,EAAY;AAAA,EACvB;AAAA,EAEA,YAAYC,GAAkBC,GAAe;AAC3C,SAAK,gBAAgB,IAAIC,EAAMF,GAAUC,CAAK;AAAA,EAChD;AAAA,EAEA,cAAc,OAAOE,MACZ,KAAK,cAAc,KAAKC,EAAa,YAAYD,CAAQ,EAAE,KAAK,CAACE,MAASA,EAAK,QAAQ;AAAA,EAGhG,gBAAgB,YACP,KAAK,cAAc,IAAID,EAAa,UAAU,EAAE,KAAK,CAACC,MAASA,EAAK,UAAU;AAAA,EAGvF,6BAA6B,OAAOC,GAAmBC,GAAiBC,MAElEA,EAAS,WAAW,IAAU,CAAA,IAC3B,KAAK,cACT,KAAK,GAAGJ,EAAa,0BAA0B,SAASE,CAAS,OAAOC,CAAO,IAAI;AAAA,IAClF,cAAcC,EAAS,IAAI,CAACC,MAAYA,EAAQ,IAAI;AA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