@mx-cartographer/experiences 6.26.33-alpha.mm0 → 7.0.0-alpha.mega1

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 (104) hide show
  1. package/CHANGELOG.md +2 -3
  2. package/dist/Account-DY6nxO7y.mjs +30 -0
  3. package/dist/AccountDetailsContent-DvPs81kL.mjs +677 -0
  4. package/dist/AccountDetailsHeader-W2U7ZVm_.mjs +119 -0
  5. package/dist/AccountFields-DAVcbZy5.mjs +135 -0
  6. package/dist/AccountListItem-DFlbdcmT.mjs +90 -0
  7. package/dist/AccountStore-CU7qV3vg.mjs +230 -0
  8. package/dist/Accounts-BLlrQA5m.mjs +9 -0
  9. package/dist/BeatApi-DLu87ijw.mjs +21 -0
  10. package/dist/BeatStore-By4aGoRM.mjs +81 -0
  11. package/dist/BudgetUtil-Ci1TN0J5.mjs +101 -0
  12. package/dist/CashflowStore-D9Dpuz7X.mjs +91 -0
  13. package/dist/Category-5S6uwuXz.mjs +301 -0
  14. package/dist/CategorySelectorDrawer-rHyHHYuh.mjs +397 -0
  15. package/dist/CategoryStore-B5EW6I1d.mjs +183 -0
  16. package/dist/CategoryUtil-DRyruNgi.mjs +78 -0
  17. package/dist/ConnectDrawer-D9cR5phc.mjs +508 -0
  18. package/dist/ConnectionsDrawer-BzGqljSp.mjs +52 -0
  19. package/dist/CurrencyInput-D74cemI2.mjs +83 -0
  20. package/dist/CurrencyText-YUhH2caW.mjs +20 -0
  21. package/dist/DateUtil-BcuH7ErC.mjs +48 -0
  22. package/dist/DebtsStore-S0l9kr0r.mjs +60 -0
  23. package/dist/Dialog-CWW597AF.mjs +123 -0
  24. package/dist/Donut-1UMNcG67.mjs +57 -0
  25. package/dist/Drawer-kEE73B87.mjs +113 -0
  26. package/dist/EmptyState-Dcb-o2tl.mjs +55 -0
  27. package/dist/Fetch-CkFKy79O.mjs +116 -0
  28. package/dist/FinstrongStore-mkALvztw.mjs +101 -0
  29. package/dist/GoalStore-DioeeL-s.mjs +263 -0
  30. package/dist/HeaderCell-DjuifqHJ.mjs +6 -0
  31. package/dist/Help-DhcC-C05.mjs +320 -0
  32. package/dist/Help-DpYRO8oA.mjs +3181 -0
  33. package/dist/IconBacking-B9oC6uL2.mjs +39 -0
  34. package/dist/InvestmentUtil-jOyOgzIB.mjs +134 -0
  35. package/dist/LineChart-CcyX38kK.mjs +499 -0
  36. package/dist/ListItemAction-BabpYivr.mjs +69 -0
  37. package/dist/Loader-Dp1P2gNw.mjs +14 -0
  38. package/dist/Localization-2MODESHW.mjs +30 -0
  39. package/dist/ManageIncome-ndMuhJMG.mjs +535 -0
  40. package/dist/MerchantStore-DVH-QOf0.mjs +37 -0
  41. package/dist/MicroWidgetContainer-CsvHLYKX.mjs +45 -0
  42. package/dist/MiniWidgetContainer-BoOp-A05.mjs +39 -0
  43. package/dist/NetWorthStore-PD-RUe09.mjs +150 -0
  44. package/dist/Notification-AMGWM1Al.mjs +78 -0
  45. package/dist/NotificationSettings-VhHuMAFU.mjs +667 -0
  46. package/dist/NotificationStore-DHtSGySy.mjs +67 -0
  47. package/dist/NumberFormatting-CtWHhyBX.mjs +40 -0
  48. package/dist/OriginalBalanceAction-D39mx6uE.mjs +115 -0
  49. package/dist/RecurringSettings-D_HnMYZP.mjs +57 -0
  50. package/dist/RecurringTransactionsStore-BKLD3OWo.mjs +263 -0
  51. package/dist/RepeatingTransaction-BPWfaB3f.mjs +282 -0
  52. package/dist/SearchBox-B2_zLv8-.mjs +42 -0
  53. package/dist/SettingsStore-CE7jDVFL.mjs +265 -0
  54. package/dist/SingleSegmentDonut-BgbLgwHi.mjs +69 -0
  55. package/dist/SpendingData-BkrxzHdr.mjs +55 -0
  56. package/dist/StatusBar-BK_uYHAB.mjs +30 -0
  57. package/dist/TabContentContainer-j01JYR_7.mjs +21 -0
  58. package/dist/Transaction-CA0FW2Ij.mjs +312 -0
  59. package/dist/TransactionApi-DbbcjI2L.mjs +86 -0
  60. package/dist/TransactionDetails-WBHFmbxL.mjs +1283 -0
  61. package/dist/TransactionStore-CeLdmVnC.mjs +669 -0
  62. package/dist/TrendsStore-BHJUapXF.mjs +487 -0
  63. package/dist/ViewMoreMicroCard-CAPFNz-J.mjs +1959 -0
  64. package/dist/WidgetContainer-DWCusxYI.mjs +556 -0
  65. package/dist/accounts/index.es.js +752 -0
  66. package/dist/analytics/index.es.js +171 -0
  67. package/dist/budgets/index.es.js +1075 -0
  68. package/dist/cashflow/index.es.js +1098 -0
  69. package/dist/categories/index.es.js +9 -0
  70. package/dist/common/components/WidgetContainer.d.ts +1 -1
  71. package/dist/common/components/charts/LineChart.d.ts +0 -1
  72. package/dist/common/constants/Analytics.d.ts +10 -20
  73. package/dist/common/context/hooks.d.ts +13 -13
  74. package/dist/common/index.es.js +1451 -0
  75. package/dist/dashboard/index.es.js +181 -0
  76. package/dist/debts/index.es.js +1460 -0
  77. package/dist/exportTransactionsToCSV-CmwsKl2D.mjs +47 -0
  78. package/dist/finstrong/index.es.js +1455 -0
  79. package/dist/goals/index.es.js +1209 -0
  80. package/dist/help/components/content/section/index.d.ts +15 -15
  81. package/dist/help/index.es.js +14 -0
  82. package/dist/hooks-30y_BLwc.mjs +71 -0
  83. package/dist/index.d.ts +0 -22
  84. package/dist/insights/index.d.ts +1 -0
  85. package/dist/insights/index.es.js +4 -0
  86. package/dist/investments/index.es.js +1638 -0
  87. package/dist/merchants/index.es.js +79 -0
  88. package/dist/microinsights/components/carouselheader/CarouselHeader.d.ts +0 -1
  89. package/dist/microinsights/components/microBeatCarousel/MicroBeatCarousel.d.ts +0 -1
  90. package/dist/microinsights/index.es.js +16 -0
  91. package/dist/networth/index.es.js +576 -0
  92. package/dist/notifications/index.es.js +192 -0
  93. package/dist/recurringtransactions/index.es.js +879 -0
  94. package/dist/settings/index.es.js +879 -0
  95. package/dist/spending/index.es.js +570 -0
  96. package/dist/transactions/index.es.js +587 -0
  97. package/dist/trends/index.es.js +1086 -0
  98. package/dist/useCombineEvents-DaDBSR_1.mjs +92 -0
  99. package/dist/useDimensions-27p2evRx.mjs +36 -0
  100. package/dist/useScreenSize-B6JyS_Lj.mjs +36 -0
  101. package/package.json +155 -3
  102. package/dist/index.es.js +0 -30564
  103. package/dist/index.es.js.map +0 -1
  104. package/dist/trends/constants/TrendsWidget.d.ts +0 -3
@@ -0,0 +1,397 @@
1
+ import { jsx as t, jsxs as E } from "react/jsx-runtime";
2
+ import { observer as g } from "mobx-react-lite";
3
+ import C from "react";
4
+ import $ from "@mui/material/Stack";
5
+ import { G as K, k as y, u as b, g as D, a as U } from "./hooks-30y_BLwc.mjs";
6
+ import Y from "@mui/material/List";
7
+ import V from "@mui/material/Paper";
8
+ import v from "@mui/material/Divider";
9
+ import x from "@mui/material/ListItem";
10
+ import W from "@mui/material/ListItemAvatar";
11
+ import N from "@mui/material/ListItemButton";
12
+ import F from "@mui/material/ListItemIcon";
13
+ import G from "@mui/material/ListItemText";
14
+ import { CheckCircle as M, Edit as j, Delete as X, ExpandMore as z } from "@mxenabled/mx-icons";
15
+ import { Text as B, TextField as q, CategoryIcon as H } from "@mxenabled/mxui";
16
+ import J from "@mui/material/Collapse";
17
+ import Q from "@mui/material/DialogContent";
18
+ import { b as S } from "./Localization-2MODESHW.mjs";
19
+ import { a as Z } from "./Dialog-CWW597AF.mjs";
20
+ import ee from "@mui/material/Box";
21
+ import te from "@mui/material/Chip";
22
+ import I from "@mui/material/IconButton";
23
+ import { S as oe } from "./SearchBox-B2_zLv8-.mjs";
24
+ import { L as k } from "./Loader-Dp1P2gNw.mjs";
25
+ import { D as ae } from "./Drawer-kEE73B87.mjs";
26
+ const h = () => {
27
+ if (!C.useContext(K))
28
+ throw new Error("useCategoryUiStore() must be used within the GlobalDataContext");
29
+ return y().uiStore;
30
+ }, m = {
31
+ ON_CATEGORY_EXPANDED: "onCategoryExpanded",
32
+ ON_CATEGORY_COLLAPSED: "onCategoryCollapsed",
33
+ ON_CATEGORY_SELECTED: "onCategorySelected",
34
+ ON_SUBCATEGORY_ADD_CLICK: "onSubcategoryAddClick",
35
+ ON_SUBCATEGORY_ADD_CANCEL_CLICK: "onSubcategoryAddCancelClick",
36
+ ON_SUBCATEGORY_ADDED: "onSubcategoryAdded",
37
+ ON_SUBCATEGORY_EDIT_CLICK: "onSubcategoryEditClick",
38
+ ON_SUBCATEGORY_EDIT_CANCEL_CLICK: "onSubcategoryEditCancelClick",
39
+ ON_SUBCATEGORY_DELETE_CLICK: "onSubcategoryDeleteClick",
40
+ ON_SUBCATEGORY_DELETED: "onSubcategoryDeleted",
41
+ ON_SUBCATEGORY_SAVED: "onSubcategorySaved"
42
+ };
43
+ var L = /* @__PURE__ */ ((e) => (e.ADD = "add", e.EDIT = "edit", e.DELETE = "delete", e))(L || {});
44
+ const re = ({
45
+ categoryName: e = "",
46
+ onClose: o,
47
+ onSave: r,
48
+ isOpen: c,
49
+ type: s
50
+ }) => {
51
+ const [a, i] = C.useState(e), { categories: n } = b(), { setShouldDisableDrawerScroll: l } = h();
52
+ let u = "", d = [];
53
+ const _ = s === "delete";
54
+ switch (s) {
55
+ case "add":
56
+ u = n.add_subcategory_title;
57
+ break;
58
+ case "edit":
59
+ u = S(n.edit_subcategory_title, e);
60
+ break;
61
+ case "delete":
62
+ u = n.delete_subcategory_heading, d = S(
63
+ n.all_transactions_in_this_subcategory,
64
+ /* @__PURE__ */ t(B, { bold: !0, children: S(n.all_parent_category, e) })
65
+ );
66
+ break;
67
+ }
68
+ return /* @__PURE__ */ t(
69
+ Z,
70
+ {
71
+ copy: {
72
+ title: u
73
+ },
74
+ disablePrimaryButton: !a,
75
+ isOpen: c,
76
+ onClose: () => {
77
+ l(!1), o();
78
+ },
79
+ onPrimaryAction: () => {
80
+ l(!1), r(a);
81
+ },
82
+ children: /* @__PURE__ */ t(Q, { children: _ ? /* @__PURE__ */ t(B, { children: d }) : /* @__PURE__ */ t(
83
+ q,
84
+ {
85
+ "aria-label": s === "edit" ? n.edit_subcategory_aria : n.add_subcategory_aria,
86
+ name: "modify-subcategory",
87
+ onChange: (p) => i(p.target.value),
88
+ placeholder: n.input_placeholder,
89
+ sx: { width: "100%" },
90
+ value: a
91
+ }
92
+ ) })
93
+ }
94
+ );
95
+ }, R = g(re), ne = ({ parentCategory: e }) => {
96
+ const [o, r] = C.useState(!1), { addCategory: c } = y(), { categories: s } = b(), { onEvent: a } = D(), { setShouldDisableDrawerScroll: i } = h(), n = async (d) => {
97
+ await c(d.trim(), e.guid), a(m.ON_SUBCATEGORY_ADDED), r(!1);
98
+ }, l = async () => {
99
+ a(m.ON_SUBCATEGORY_ADD_CLICK), i(!0), r(!0);
100
+ }, u = () => {
101
+ r(!1), a(m.ON_SUBCATEGORY_ADD_CANCEL_CLICK);
102
+ };
103
+ return /* @__PURE__ */ E(x, { disableGutters: !0, disablePadding: !0, children: [
104
+ /* @__PURE__ */ t(N, { onClick: l, sx: { ml: 60 }, children: /* @__PURE__ */ t(
105
+ G,
106
+ {
107
+ primary: s.add_subcategory_button,
108
+ primaryTypographyProps: { color: "primary", fontWeight: "normal", variant: "Body" }
109
+ }
110
+ ) }),
111
+ o && /* @__PURE__ */ t(
112
+ R,
113
+ {
114
+ isOpen: o,
115
+ onClose: u,
116
+ onSave: n,
117
+ type: L.ADD
118
+ }
119
+ )
120
+ ] });
121
+ }, se = g(ne), ie = ({
122
+ setShowRename: e,
123
+ subCategory: o,
124
+ showRename: r
125
+ }) => {
126
+ const { updateCategory: c } = y(), { onEvent: s } = D(), a = async (n) => {
127
+ await c({ ...o, name: n }), s(m.ON_SUBCATEGORY_SAVED), e(!1);
128
+ }, i = () => {
129
+ e(!1), s(m.ON_SUBCATEGORY_EDIT_CANCEL_CLICK);
130
+ };
131
+ return /* @__PURE__ */ t(
132
+ R,
133
+ {
134
+ categoryName: o.name,
135
+ isOpen: r,
136
+ onClose: i,
137
+ onSave: a,
138
+ type: L.EDIT
139
+ }
140
+ );
141
+ }, ce = g(ie), le = ({
142
+ parentCategory: e,
143
+ showDelete: o,
144
+ setShowDelete: r,
145
+ subCategory: c
146
+ }) => {
147
+ const { onEvent: s } = D(), { removeCategory: a } = y(), i = () => {
148
+ r(!1), s(m.ON_SUBCATEGORY_DELETE_CLICK);
149
+ }, n = async () => {
150
+ s(m.ON_SUBCATEGORY_DELETED), await a(c.guid), r(!1);
151
+ };
152
+ return /* @__PURE__ */ t(
153
+ R,
154
+ {
155
+ categoryName: e.name,
156
+ isOpen: o,
157
+ onClose: i,
158
+ onSave: n,
159
+ type: L.DELETE
160
+ }
161
+ );
162
+ }, de = g(le), ue = ({ parentCategory: e, subCategory: o }) => {
163
+ const {
164
+ onSelect: r,
165
+ selectedGuid: c,
166
+ setSelectedGuid: s,
167
+ setShouldDisableDrawerScroll: a,
168
+ showSelected: i,
169
+ unselectable: n,
170
+ unselectableText: l
171
+ } = h(), { categories: u } = b(), { onEvent: d } = D(), [_, p] = C.useState(!1), [f, O] = C.useState(!1), T = !!o.revision, A = o.guid === c, w = !n.some((P) => P === o.guid);
172
+ return /* @__PURE__ */ E(
173
+ x,
174
+ {
175
+ className: "mx-cat-subcategory-row",
176
+ disableGutters: !0,
177
+ disablePadding: !0,
178
+ sx: { pl: 58 },
179
+ children: [
180
+ /* @__PURE__ */ E(
181
+ N,
182
+ {
183
+ "aria-pressed": A,
184
+ color: "secondary",
185
+ onClick: () => {
186
+ w && (s(o.guid), r(o.guid), d(m.ON_CATEGORY_SELECTED));
187
+ },
188
+ sx: { height: 44 },
189
+ children: [
190
+ /* @__PURE__ */ t(
191
+ G,
192
+ {
193
+ primary: o.name,
194
+ primaryTypographyProps: { fontWeight: "normal", variant: "Body" }
195
+ }
196
+ ),
197
+ i && A && /* @__PURE__ */ t(M, { fontSize: "small" }),
198
+ !w && /* @__PURE__ */ t(te, { label: l })
199
+ ]
200
+ }
201
+ ),
202
+ T && /* @__PURE__ */ E(ee, { className: "mx-cat-subcategory-edit-container", sx: { marginRight: 24 }, children: [
203
+ /* @__PURE__ */ t(
204
+ I,
205
+ {
206
+ "aria-label": S(u.edit_subcategory_aria, o.name),
207
+ onClick: () => {
208
+ p(!0), a(!0), d(m.ON_SUBCATEGORY_EDIT_CLICK);
209
+ },
210
+ children: /* @__PURE__ */ t(j, { color: "secondary" })
211
+ }
212
+ ),
213
+ /* @__PURE__ */ t(
214
+ I,
215
+ {
216
+ "aria-label": S(u.delete_subcategory_aria, o.name),
217
+ edge: "end",
218
+ onClick: () => {
219
+ O(!0), a(!0), d(m.ON_SUBCATEGORY_DELETE_CLICK);
220
+ },
221
+ children: /* @__PURE__ */ t(X, { color: "secondary" })
222
+ }
223
+ )
224
+ ] }),
225
+ f && /* @__PURE__ */ t(
226
+ de,
227
+ {
228
+ parentCategory: e,
229
+ setShowDelete: O,
230
+ showDelete: f,
231
+ subCategory: o
232
+ }
233
+ ),
234
+ _ && /* @__PURE__ */ t(
235
+ ce,
236
+ {
237
+ setShowRename: p,
238
+ showRename: _,
239
+ subCategory: o
240
+ }
241
+ )
242
+ ]
243
+ }
244
+ );
245
+ }, me = g(ue), Ce = ({ categories: e, parentCategory: o }) => {
246
+ const { expandedGuid: r, searchValue: c } = h(), s = o.guid === r, a = !!c;
247
+ return /* @__PURE__ */ t(
248
+ J,
249
+ {
250
+ in: s || a,
251
+ sx: { backgroundColor: "background.default" },
252
+ timeout: "auto",
253
+ unmountOnExit: !0,
254
+ children: /* @__PURE__ */ E(
255
+ Y,
256
+ {
257
+ "aria-labelledby": `category-${o.guid}`,
258
+ className: "mx-cat-subcategory-list",
259
+ id: `subcategories-${o.guid}`,
260
+ children: [
261
+ e.map((i) => /* @__PURE__ */ E(C.Fragment, { children: [
262
+ /* @__PURE__ */ t(me, { parentCategory: o, subCategory: i }),
263
+ /* @__PURE__ */ t(v, { sx: { ml: 58 } })
264
+ ] }, i.guid)),
265
+ !a && /* @__PURE__ */ t(se, { parentCategory: o })
266
+ ]
267
+ }
268
+ )
269
+ }
270
+ );
271
+ }, ge = g(Ce), _e = ({ category: e, subCategories: o }) => {
272
+ const { expandedGuid: r, searchValue: c, setExpandedGuid: s } = h(), { onEvent: a } = D(), i = e.guid === r, n = () => {
273
+ const l = e.guid !== r ? e.guid : null;
274
+ s(l), a(l ? m.ON_CATEGORY_EXPANDED : m.ON_CATEGORY_COLLAPSED);
275
+ };
276
+ return /* @__PURE__ */ E(C.Fragment, { children: [
277
+ /* @__PURE__ */ t(x, { disableGutters: !0, disablePadding: !0, children: /* @__PURE__ */ E(
278
+ N,
279
+ {
280
+ "aria-controls": `subcategories-${e.guid}`,
281
+ "aria-expanded": e.guid === r,
282
+ "aria-label": e.name,
283
+ id: `category-${e.guid}`,
284
+ onClick: n,
285
+ children: [
286
+ /* @__PURE__ */ t(W, { children: /* @__PURE__ */ t(H, { categoryGuid: e.guid }) }),
287
+ /* @__PURE__ */ t(
288
+ G,
289
+ {
290
+ primary: e.name,
291
+ primaryTypographyProps: { fontWeight: "normal", variant: "Body" }
292
+ }
293
+ ),
294
+ /* @__PURE__ */ t(F, { children: /* @__PURE__ */ t(
295
+ z,
296
+ {
297
+ sx: {
298
+ transition: "transform 0.3s ease-in-out",
299
+ transform: i || c ? "rotate(180deg)" : "rotate(0deg)"
300
+ }
301
+ }
302
+ ) })
303
+ ]
304
+ },
305
+ e.guid
306
+ ) }),
307
+ /* @__PURE__ */ t(v, { sx: { ml: 58 } }),
308
+ /* @__PURE__ */ t(ge, { categories: o, parentCategory: e })
309
+ ] });
310
+ }, Ee = g(_e), he = () => {
311
+ const { categories: e } = y(), { searchValue: o } = h(), { categories: r } = b(), s = ((a, i = "") => a.reduce((n, l) => {
312
+ if (l.parent_guid === null) {
313
+ const d = [
314
+ {
315
+ ...l,
316
+ name: S(r.all_parent_category, l.name),
317
+ parent_guid: l.guid
318
+ },
319
+ ...a
320
+ ].filter(
321
+ (_) => _.parent_guid === l.guid && _.name.toLowerCase().includes(i.toLowerCase())
322
+ );
323
+ if (l.name.toLowerCase().includes(i.toLowerCase()) || d.length > 0)
324
+ return [...n, { category: { ...l }, children: d }];
325
+ }
326
+ return n;
327
+ }, []))(e, o);
328
+ return /* @__PURE__ */ t(V, { className: "mx-cat-category-list", sx: { boxShadow: "none" }, children: /* @__PURE__ */ t(Y, { children: s.map((a) => /* @__PURE__ */ t(
329
+ Ee,
330
+ {
331
+ category: a.category,
332
+ subCategories: a.children
333
+ },
334
+ a.category.guid
335
+ )) }) });
336
+ }, pe = g(he), Se = ({
337
+ initialSelected: e,
338
+ onSelect: o = void 0,
339
+ showSelected: r = !0,
340
+ unselectable: c = [],
341
+ unselectableText: s = "Unselectable"
342
+ }) => {
343
+ const { categories: a, loadCategories: i } = y(), { common: n } = b(), { isCopyLoaded: l } = U(), {
344
+ searchValue: u,
345
+ setOnSelect: d,
346
+ setSearchValue: _,
347
+ setSelectedGuid: p,
348
+ setShowSelected: f,
349
+ setUnselectable: O,
350
+ setUnselectableText: T
351
+ } = h();
352
+ return C.useEffect(() => {
353
+ o && d(o);
354
+ }), C.useEffect(() => {
355
+ a.length || i();
356
+ }, []), C.useEffect(() => {
357
+ e && p(e), f(r), O(c), T(s);
358
+ }, [e, r, c, s]), l ? /* @__PURE__ */ E($, { className: "mx-cat-category-selector", sx: { width: "100%" }, children: [
359
+ /* @__PURE__ */ t(
360
+ oe,
361
+ {
362
+ ariaLabel: n.search_aria,
363
+ cancelAriaLabel: n.cancel_search_aria,
364
+ onChange: (A) => _(A),
365
+ placeholder: n.search_placeholder,
366
+ searchValue: u
367
+ }
368
+ ),
369
+ /* @__PURE__ */ t(pe, {})
370
+ ] }) : /* @__PURE__ */ t(k, {});
371
+ }, ye = g(Se), be = ({
372
+ id: e,
373
+ onClose: o,
374
+ title: r,
375
+ showDrawer: c,
376
+ ...s
377
+ }) => {
378
+ const { common: a } = b(), { isCopyLoaded: i } = U();
379
+ return i ? /* @__PURE__ */ t(
380
+ ae,
381
+ {
382
+ ariaLabelClose: a.close_aria,
383
+ className: "mx-cat-category-selector-drawer",
384
+ id: e,
385
+ isOpen: c,
386
+ onClose: o,
387
+ title: r,
388
+ children: /* @__PURE__ */ t(ye, { ...s })
389
+ }
390
+ ) : /* @__PURE__ */ t(k, {});
391
+ }, ze = g(be);
392
+ export {
393
+ ye as C,
394
+ ze as a,
395
+ Ee as b,
396
+ h as u
397
+ };
@@ -0,0 +1,183 @@
1
+ import { makeAutoObservable as u, runInAction as l } from "mobx";
2
+ import { getUnixTime as r } from "date-fns/getUnixTime";
3
+ import { subMonths as g } from "date-fns/subMonths";
4
+ import { startOfMonth as h } from "date-fns/startOfMonth";
5
+ import { endOfMonth as d } from "date-fns/endOfMonth";
6
+ import { a as T, g as m } from "./CategoryUtil-DRyruNgi.mjs";
7
+ import { F as p, A as i } from "./Fetch-CkFKy79O.mjs";
8
+ import { c as f, C as w } from "./Category-5S6uwuXz.mjs";
9
+ class y {
10
+ fetchInstance;
11
+ constructor(t, e) {
12
+ this.fetchInstance = new p(t, e);
13
+ }
14
+ addCategory = async (t) => this.fetchInstance.post(i.CATEGORIES, t).then((e) => e.category);
15
+ getCategories = async () => this.fetchInstance.get(i.CATEGORIES).then((t) => t.categories);
16
+ getDateRangeCategoryTotals = async (t, e, o) => o.length === 0 ? [] : this.fetchInstance.post(`${i.DATE_RANGE_CATEGORY_TOTALS}/from/${t}/to/${e}`, {
17
+ account_guid: o.map((a) => a.guid)
18
+ }).then((a) => a.date_range_category_totals);
19
+ getMonthlyCategoryTotals = async (t, e, o) => {
20
+ try {
21
+ const a = `${i.MONTHLY_CATEGORY_TOTALS}/from/${t}/to/${e}`;
22
+ if (o) {
23
+ const s = o.length === 0 ? [""] : o.map((C) => C.guid);
24
+ return (await this.fetchInstance.post(a, { account_guid: s })).monthly_category_totals;
25
+ } else
26
+ return (await this.fetchInstance.get(a)).monthly_category_totals;
27
+ } catch (a) {
28
+ throw console.error("Error fetching monthly category totals:", a), a;
29
+ }
30
+ };
31
+ removeCategory = async (t) => this.fetchInstance.delete(`${i.CATEGORIES}/${t}`);
32
+ updateCategory = async (t) => this.fetchInstance.put(`${i.CATEGORIES}/${t.guid}`, t).then((e) => e.category);
33
+ }
34
+ class S {
35
+ expandedGuid = null;
36
+ selectedGuid = null;
37
+ searchValue = "";
38
+ showSelected = !0;
39
+ shouldDisableDrawerScroll = !1;
40
+ unselectable = [];
41
+ unselectableText = "";
42
+ savedOnSelect;
43
+ // todo
44
+ constructor() {
45
+ u(this);
46
+ }
47
+ setExpandedGuid = (t) => this.expandedGuid = t;
48
+ setSelectedGuid = (t) => this.selectedGuid = t;
49
+ setSearchValue = (t) => this.searchValue = t;
50
+ setShouldDisableDrawerScroll = (t) => this.shouldDisableDrawerScroll = t;
51
+ setShowSelected = (t) => this.showSelected = t;
52
+ setUnselectable = (t) => this.unselectable = t;
53
+ setUnselectableText = (t) => this.unselectableText = t;
54
+ onSelect = (t) => this.savedOnSelect(t);
55
+ setOnSelect = (t) => this.savedOnSelect = t;
56
+ }
57
+ class G {
58
+ globalStore;
59
+ uiStore;
60
+ api = new y("/", "");
61
+ categories = [];
62
+ dateRangeCategoryTotals = [];
63
+ monthlyCategoryTotals = [];
64
+ dataRangeTotalsLoaded = !1;
65
+ isLoadingCategoryTotals = !1;
66
+ monthlyTotalsLoaded = !1;
67
+ constructor(t) {
68
+ this.globalStore = t, this.uiStore = new S(), this.api = new y(t.endpoint, t.sessionToken), u(this);
69
+ }
70
+ get detailedCategories() {
71
+ return T(
72
+ this.categories,
73
+ this.dateRangeCategoryTotals,
74
+ this.monthlyCategoryTotals
75
+ );
76
+ }
77
+ get detailedCategoriesWithTransactions() {
78
+ return m(
79
+ this.detailedCategories,
80
+ this.globalStore.transactionStore.sortedTransactions
81
+ );
82
+ }
83
+ get incomeCategories() {
84
+ return this.detailedCategories.filter((t) => t.is_income);
85
+ }
86
+ get spendCategories() {
87
+ return this.detailedCategories.filter(
88
+ (t) => !t.is_income && !t.isTransfer && t.guid !== f.INVESTMENTS
89
+ );
90
+ }
91
+ get transferCategories() {
92
+ return this.detailedCategories.filter((t) => t.isTransfer);
93
+ }
94
+ addCategory = async (t, e) => {
95
+ const o = { name: t, parent_guid: e };
96
+ try {
97
+ await this.api.addCategory(o), await this.loadCategories();
98
+ } catch (a) {
99
+ console.error(`Error occurred while adding category: ${a}`);
100
+ }
101
+ };
102
+ loadCategories = async (t) => {
103
+ try {
104
+ const e = t || await this.api.getCategories(), { default_categories: o } = this.globalStore.copyStore.copy.categories;
105
+ l(() => {
106
+ this.categories = e.map((a) => ({
107
+ ...a,
108
+ name: o[a.guid] ? o[a.guid].replace(/&/g, "&") : a.name
109
+ }));
110
+ });
111
+ } catch (e) {
112
+ console.error(`Error occurred while getting categories: ${e}`);
113
+ }
114
+ };
115
+ loadDateRangeCategoryTotals = async (t, e, o) => {
116
+ this.setIsLoadingCategoryTotals(!0);
117
+ try {
118
+ const a = await this.api.getDateRangeCategoryTotals(
119
+ r(e),
120
+ r(o),
121
+ t
122
+ );
123
+ l(() => {
124
+ this.dateRangeCategoryTotals = a, this.setIsLoadingCategoryTotals(!1), this.dataRangeTotalsLoaded = !0;
125
+ });
126
+ } catch (a) {
127
+ this.setIsLoadingCategoryTotals(!1), console.error(`Error occurred while getting date range category totals: ${a}`);
128
+ }
129
+ };
130
+ loadMonthlyCategoryTotals = async (t = this.globalStore.globalUiStore.selectedAccounts, e, o) => {
131
+ const a = r(h(e ?? g(/* @__PURE__ */ new Date(), 11))), s = r(d(o ?? /* @__PURE__ */ new Date()));
132
+ try {
133
+ const n = await this.api.getMonthlyCategoryTotals(a, s, t);
134
+ l(() => {
135
+ this.monthlyCategoryTotals = n, this.monthlyTotalsLoaded = !0;
136
+ });
137
+ } catch (n) {
138
+ console.error(`Error occurred while getting monthly category totals: ${n}`);
139
+ }
140
+ };
141
+ reloadCategoryTotals = async (t, e, o) => {
142
+ this.setIsLoadingCategoryTotals(!0);
143
+ try {
144
+ const a = await this.api.getDateRangeCategoryTotals(
145
+ r(e),
146
+ r(o),
147
+ t
148
+ ), s = await this.api.getMonthlyCategoryTotals(
149
+ r(h(g(o, 11))),
150
+ r(d(o)),
151
+ t
152
+ );
153
+ l(() => {
154
+ this.dateRangeCategoryTotals = a, this.monthlyCategoryTotals = s, this.dataRangeTotalsLoaded = !0, this.monthlyTotalsLoaded = !0, this.setIsLoadingCategoryTotals(!1);
155
+ });
156
+ } catch (a) {
157
+ console.error(`Error occurred while getting category totals: ${a}`);
158
+ }
159
+ };
160
+ removeCategory = async (t) => {
161
+ try {
162
+ await this.api.removeCategory(t), await this.loadCategories();
163
+ } catch (e) {
164
+ console.error(`Error occurred while removing category: ${e}`);
165
+ }
166
+ };
167
+ setIsLoadingCategoryTotals = (t) => {
168
+ this.isLoadingCategoryTotals = t;
169
+ };
170
+ updateCategory = async (t) => {
171
+ try {
172
+ await this.api.updateCategory(t), await this.loadCategories();
173
+ } catch (e) {
174
+ console.error(`Error occurred while updating category: ${e}`);
175
+ }
176
+ };
177
+ // TODO: Remove this after refactoring Trends components to use detailedCategories
178
+ getCategoryName = (t) => this.categories.find((o) => o.guid === t)?.name ?? w[t];
179
+ }
180
+ export {
181
+ G as C,
182
+ y as a
183
+ };
@@ -0,0 +1,78 @@
1
+ import { format as l } from "date-fns/format";
2
+ import { startOfMonth as h } from "date-fns/startOfMonth";
3
+ import { startOfToday as M } from "date-fns/startOfToday";
4
+ import { subMonths as T } from "date-fns/subMonths";
5
+ import { CategoryIconList as C } from "@mxenabled/mxui";
6
+ import { a as N, b as O, c as b } from "./Category-5S6uwuXz.mjs";
7
+ import { f as D, D as E } from "./Dialog-CWW597AF.mjs";
8
+ const R = 3, d = 12, Y = (n, r, t) => n.filter((e) => !e.parent_guid).map(
9
+ (e) => _(
10
+ e,
11
+ r,
12
+ t,
13
+ n.filter((o) => o.parent_guid === e.guid)
14
+ )
15
+ ), x = (n, r) => {
16
+ const t = C.find((e) => e.guid === n);
17
+ return t ? r.palette.categories[t.colorName] || "" : r.palette.categories.uncategorized || "";
18
+ }, _ = (n, r, t, e = []) => {
19
+ const o = n.guid, i = n.parent_guid || o, u = o === i, s = r.find((a) => a.category_guid === o)?.total || 0, c = f(
20
+ t.filter((a) => a.category_guid === o)
21
+ ), g = f(
22
+ t.filter(
23
+ (a) => a.category_guid === o || a.top_level_category_guid === o
24
+ )
25
+ ), m = e.map(
26
+ (a) => _(a, r, t)
27
+ ), p = m.reduce(
28
+ (a, A) => a + A.currentAmount,
29
+ s
30
+ );
31
+ return {
32
+ ...n,
33
+ currentAmount: s,
34
+ averageAmount: y(c),
35
+ color: N[i],
36
+ icon: O[i],
37
+ isTransfer: i === b.TRANSFER,
38
+ monthlyAmounts: c,
39
+ subCategories: m,
40
+ totalAmount: u ? p : 0,
41
+ totalAverageAmount: y(g),
42
+ totalMonthlyAmounts: u ? g : []
43
+ };
44
+ }, k = (n, r) => n.map((t) => {
45
+ const e = r.filter(
46
+ (o) => o.category_guid === t.guid || o.top_level_category_guid === t.guid
47
+ );
48
+ return {
49
+ ...t,
50
+ transactions: e
51
+ };
52
+ }), y = (n, r = R) => {
53
+ const t = r > history.length ? history.length : r;
54
+ return Math.ceil(
55
+ Math.max(
56
+ 0,
57
+ n.slice(-t).reduce((e, o) => e + o.amount, 0) / t
58
+ )
59
+ );
60
+ }, f = (n) => {
61
+ const r = [], t = M();
62
+ for (let e = 0; e <= d; e++) {
63
+ const o = h(T(t, d - e)), u = n.filter(
64
+ (s) => s.year_month === Number(l(o, "yyyyMM"))
65
+ ).reduce((s, c) => s + c.total, 0);
66
+ r.push({
67
+ amount: u,
68
+ isoDate: l(o, "yyyy-MM-dd"),
69
+ label: D(o, E.MONTH_YEAR)
70
+ });
71
+ }
72
+ return r;
73
+ };
74
+ export {
75
+ Y as a,
76
+ x as b,
77
+ k as g
78
+ };