@mx-cartographer/experiences 6.26.1-alpha.mega1 → 6.26.1

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 (92) hide show
  1. package/CHANGELOG.md +9 -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/help/components/content/section/index.d.ts +15 -15
  7. package/dist/index.d.ts +22 -0
  8. package/dist/index.es.js +29896 -0
  9. package/dist/index.es.js.map +1 -0
  10. package/dist/trends/components/CategoriesList.d.ts +5 -5
  11. package/dist/trends/components/CategoriesListItem.d.ts +4 -7
  12. package/dist/trends/components/CategoryDetailChart.d.ts +1 -5
  13. package/dist/trends/stores/TrendsStore.d.ts +16 -11
  14. package/package.json +3 -91
  15. package/dist/AccountStore-DkL93tXL.mjs +0 -317
  16. package/dist/AccountStore-DkL93tXL.mjs.map +0 -1
  17. package/dist/BudgetUtil-CVqAdv-j.mjs +0 -187
  18. package/dist/BudgetUtil-CVqAdv-j.mjs.map +0 -1
  19. package/dist/CashflowStore-gPEEBiXo.mjs +0 -53
  20. package/dist/CashflowStore-gPEEBiXo.mjs.map +0 -1
  21. package/dist/CategoryStore-m7oieLzP.mjs +0 -260
  22. package/dist/CategoryStore-m7oieLzP.mjs.map +0 -1
  23. package/dist/ConnectMiniWidget-CQWafYtQ.mjs +0 -22966
  24. package/dist/ConnectMiniWidget-CQWafYtQ.mjs.map +0 -1
  25. package/dist/DebtsStore-cUhIgJx6.mjs +0 -145
  26. package/dist/DebtsStore-cUhIgJx6.mjs.map +0 -1
  27. package/dist/Donut-CGNFni9y.mjs +0 -58
  28. package/dist/Donut-CGNFni9y.mjs.map +0 -1
  29. package/dist/FinstrongStore-BDG7l0nI.mjs +0 -183
  30. package/dist/FinstrongStore-BDG7l0nI.mjs.map +0 -1
  31. package/dist/GoalStore-o2waGeyf.mjs +0 -293
  32. package/dist/GoalStore-o2waGeyf.mjs.map +0 -1
  33. package/dist/Loader-CwdK8lfx.mjs +0 -147
  34. package/dist/Loader-CwdK8lfx.mjs.map +0 -1
  35. package/dist/MerchantStore-Cck9IGIH.mjs +0 -125
  36. package/dist/MerchantStore-Cck9IGIH.mjs.map +0 -1
  37. package/dist/NetWorthStore-D5eUfGQt.mjs +0 -66
  38. package/dist/NetWorthStore-D5eUfGQt.mjs.map +0 -1
  39. package/dist/NotificationStore-DCxw8W7u.mjs +0 -141
  40. package/dist/NotificationStore-DCxw8W7u.mjs.map +0 -1
  41. package/dist/RecurringTransactionsStore-Bijrgllq.mjs +0 -337
  42. package/dist/RecurringTransactionsStore-Bijrgllq.mjs.map +0 -1
  43. package/dist/SettingsStore-BhOYgUOa.mjs +0 -352
  44. package/dist/SettingsStore-BhOYgUOa.mjs.map +0 -1
  45. package/dist/TransactionApi-Dnbyi1JL.mjs +0 -175
  46. package/dist/TransactionApi-Dnbyi1JL.mjs.map +0 -1
  47. package/dist/TransactionStore-CiEtt5XJ.mjs +0 -417
  48. package/dist/TransactionStore-CiEtt5XJ.mjs.map +0 -1
  49. package/dist/TrendsStore-Idq3QfoA.mjs +0 -131
  50. package/dist/TrendsStore-Idq3QfoA.mjs.map +0 -1
  51. package/dist/accounts/index.es.js +0 -18
  52. package/dist/accounts/index.es.js.map +0 -1
  53. package/dist/analytics/index.es.js +0 -170
  54. package/dist/analytics/index.es.js.map +0 -1
  55. package/dist/budgets/index.es.js +0 -1116
  56. package/dist/budgets/index.es.js.map +0 -1
  57. package/dist/cashflow/index.es.js +0 -118
  58. package/dist/cashflow/index.es.js.map +0 -1
  59. package/dist/categories/index.es.js +0 -10
  60. package/dist/categories/index.es.js.map +0 -1
  61. package/dist/common/index.es.js +0 -1549
  62. package/dist/common/index.es.js.map +0 -1
  63. package/dist/dashboard/index.es.js +0 -257
  64. package/dist/dashboard/index.es.js.map +0 -1
  65. package/dist/debts/index.es.js +0 -9
  66. package/dist/debts/index.es.js.map +0 -1
  67. package/dist/finstrong/index.es.js +0 -11
  68. package/dist/finstrong/index.es.js.map +0 -1
  69. package/dist/goals/index.es.js +0 -9
  70. package/dist/goals/index.es.js.map +0 -1
  71. package/dist/help/index.es.js +0 -6
  72. package/dist/help/index.es.js.map +0 -1
  73. package/dist/investments/index.es.js +0 -1694
  74. package/dist/investments/index.es.js.map +0 -1
  75. package/dist/merchants/index.es.js +0 -7
  76. package/dist/merchants/index.es.js.map +0 -1
  77. package/dist/microinsights/index.es.js +0 -21
  78. package/dist/microinsights/index.es.js.map +0 -1
  79. package/dist/networth/index.es.js +0 -11
  80. package/dist/networth/index.es.js.map +0 -1
  81. package/dist/notifications/index.es.js +0 -116
  82. package/dist/notifications/index.es.js.map +0 -1
  83. package/dist/recurringtransactions/index.es.js +0 -14
  84. package/dist/recurringtransactions/index.es.js.map +0 -1
  85. package/dist/settings/index.es.js +0 -112
  86. package/dist/settings/index.es.js.map +0 -1
  87. package/dist/spending/index.es.js +0 -632
  88. package/dist/spending/index.es.js.map +0 -1
  89. package/dist/transactions/index.es.js +0 -19
  90. package/dist/transactions/index.es.js.map +0 -1
  91. package/dist/trends/index.es.js +0 -10
  92. package/dist/trends/index.es.js.map +0 -1
@@ -1,1116 +0,0 @@
1
- import { jsx as e, jsxs as d, Fragment as ke } from "react/jsx-runtime";
2
- import l from "react";
3
- import { observer as I } from "mobx-react-lite";
4
- import { endOfMonth as Me } from "date-fns/endOfMonth";
5
- import { startOfMonth as ye } from "date-fns/startOfMonth";
6
- import W from "@mui/material/Box";
7
- import _ from "@mui/material/Stack";
8
- import q from "@mui/material/styles/useTheme";
9
- import { Icon as $, Text as p, CategoryIcon as H, H1 as $e, H3 as fe } from "@mxenabled/mxui";
10
- import "bowser";
11
- import "date-fns/getUnixTime";
12
- import { be as se, av as le, bd as Ge, b9 as k, aM as T, aL as L, b8 as M, bf as Pe, bg as P, bh as ce, bi as Ce, j as Ne, i as je, a5 as Be, a7 as ze, a3 as Ue, W as Fe, aw as We } from "../ConnectMiniWidget-CQWafYtQ.mjs";
13
- import "date-fns/intlFormat";
14
- import "date-fns/addMonths";
15
- import "date-fns/addQuarters";
16
- import "date-fns/addWeeks";
17
- import "date-fns/addYears";
18
- import "date-fns/getDay";
19
- import "date-fns/isBefore";
20
- import "date-fns/nextDay";
21
- import "date-fns/setDate";
22
- import "date-fns/startOfToday";
23
- import "date-fns/fromUnixTime";
24
- import "@mui/material";
25
- import Se from "@mui/material/Button";
26
- import He from "@mui/material/Tooltip";
27
- import Xe from "@mui/material/IconButton";
28
- import { u as w, h as j, b as D, L as N, c as X, d as J, k as Ke, l as Q, M as Ve, i as ee, g as Ye, f as Ae } from "../Loader-CwdK8lfx.mjs";
29
- import "@mui/material/useMediaQuery";
30
- import "@mxenabled/cssinjs";
31
- import "date-fns/addDays";
32
- import "date-fns/eachDayOfInterval";
33
- import "date-fns/eachWeekOfInterval";
34
- import "date-fns/format";
35
- import "date-fns/isSameMonth";
36
- import "date-fns/subMonths";
37
- import "@mui/material/Paper";
38
- import "@mxenabled/mx-icons";
39
- import "date-fns/isSameDay";
40
- import "date-fns/isWithinInterval";
41
- import * as E from "d3";
42
- import "@mui/material/styles";
43
- import "@mui/x-charts";
44
- import "@mui/x-charts/ChartsTooltip";
45
- import "date-fns/differenceInCalendarDays";
46
- import "date-fns/endOfToday";
47
- import "date-fns/endOfYear";
48
- import "date-fns/startOfYear";
49
- import { subDays as Ze } from "date-fns/subDays";
50
- import "date-fns/subYears";
51
- import "@mui/material/ButtonGroup";
52
- import pe from "@mui/material/Tab";
53
- import qe from "@mui/material/Tabs";
54
- import "@mui/material/ToggleButton";
55
- import "@mui/material/ToggleButtonGroup";
56
- import "@mui/material/Dialog";
57
- import "@mui/material/DialogContent";
58
- import de from "@mui/material/Card";
59
- import ue from "@mui/material/CardContent";
60
- import xe from "@mui/material/CardHeader";
61
- import "uuid";
62
- import "@mui/material/FormControlLabel";
63
- import "@mui/material/Radio";
64
- import "@mui/material/Avatar";
65
- import K from "@mui/material/ListItem";
66
- import te from "@mui/material/ListItemAvatar";
67
- import V from "@mui/material/ListItemButton";
68
- import Y from "@mui/material/ListItemText";
69
- import "@mui/material/ListItemIcon";
70
- import "@mui/material/MenuItem";
71
- import "@mui/material/TextField";
72
- import "@mui/material/Switch";
73
- import "mobx";
74
- import "posthog-js";
75
- import { u as Je } from "../BudgetUtil-CVqAdv-j.mjs";
76
- import "date-fns/differenceInDays";
77
- import "@mui/x-data-grid-pro";
78
- import "date-fns";
79
- import oe from "@mui/material/Divider";
80
- import Z from "@mui/material/List";
81
- import "date-fns/formatISO";
82
- import { isAfter as Qe } from "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
- import "numeral";
91
- import "@mui/material/CircularProgress";
92
- import et from "@mui/material/ListItemSecondaryAction";
93
- import tt from "@mui/material/Alert";
94
- import ot from "@mui/material/Snackbar";
95
- const he = 5, nt = 100, rt = 25, at = (t) => {
96
- const n = (r) => {
97
- r.active || t.alphaTarget(0.3).restart(), r.subject.fx = r.subject.x, r.subject.fy = r.subject.y;
98
- }, i = (r) => {
99
- r.subject.fx = r.x, r.subject.fy = r.y;
100
- }, s = (r) => {
101
- r.active || t.alphaTarget(0), r.subject.fx = null, r.subject.fy = null;
102
- };
103
- return E.drag().on("start", n).on("drag", i).on("end", s);
104
- }, st = (t) => {
105
- let n = t.transaction_total / t.amount;
106
- n < 0 ? n = 0 : n > 1 && (n = 1);
107
- const i = n * 2 * Math.PI, s = E.interpolate(0, i), r = E.arc().cornerRadius(5).innerRadius(t.radius - he * 2).outerRadius(t.radius - he).startAngle(0).endAngle(0);
108
- return (o) => (r.endAngle(s(o)), r(t) || "");
109
- }, it = (t) => {
110
- E.selectAll(".bubble").call(at(t));
111
- }, ct = (t, n, i) => {
112
- t.alpha(1).restart().force(
113
- "x",
114
- E.forceX().x(i / 2).strength(0.01)
115
- ).force(
116
- "y",
117
- E.forceY().y(n / 2).strength(0.01)
118
- );
119
- }, lt = (t, n) => E.scaleLinear().domain([t, n]).range([rt, nt]), dt = (t) => {
120
- const n = t.reduce((o, a) => {
121
- const c = Math.max(a.transaction_total, a.amount);
122
- return c > o ? c : o;
123
- }, 0), i = t.reduce((o, a) => {
124
- const c = Math.max(a.transaction_total, a.amount);
125
- return c < o ? c : o;
126
- }, n), s = lt(i, n), r = t.map((o) => {
127
- const a = s(Math.max(o.transaction_total, o.amount)) || 25;
128
- return {
129
- ...o,
130
- radius: a
131
- };
132
- });
133
- return E.forceSimulation(r).velocityDecay(0.05).force("collide", E.forceCollide((o) => o.radius + 2).strength(0.5)).on("tick", () => {
134
- E.selectAll(".bubble").data(r).attr("transform", (o) => `translate(${o.x},${o.y})`);
135
- });
136
- }, be = 5, ut = 2e3;
137
- function mt({ bubble: t }) {
138
- const n = q(), {
139
- guid: i,
140
- budgetColors: { mercury: s },
141
- radius: r
142
- } = t, o = `mercury-${i}`;
143
- l.useEffect(() => {
144
- E.select(`.${o}`).selectAll(".status").remove(), E.select(`.${o}`).append("path").transition().duration(ut).delay(0).attr("class", "status").attr("style", `fill: ${s}; fill-opacity: 1;`).attrTween("d", () => st(t));
145
- }, [t]);
146
- const a = E.arc().innerRadius((c) => c - 2 * be).outerRadius((c) => c - be).startAngle(0).endAngle(2 * Math.PI);
147
- return /* @__PURE__ */ e("g", { className: o, children: /* @__PURE__ */ e(
148
- "path",
149
- {
150
- d: a(r) || "",
151
- style: { fill: n.palette.common.white, fillOpacity: 0.35 }
152
- }
153
- ) });
154
- }
155
- const G = 75, ie = 50;
156
- function gt({ bubble: t, isDraggable: n, onClick: i = () => {
157
- } }) {
158
- const [s, r] = l.useState(!1);
159
- if (!t) return;
160
- const {
161
- budgetColors: { background: o, text: a },
162
- category: { icon: c, name: y },
163
- guid: h,
164
- description: m,
165
- radius: g,
166
- x: f,
167
- y: b
168
- } = t;
169
- let u = -12, C = -12;
170
- g > G ? (u = -14, C = -45) : g > ie && (C = -32);
171
- const B = `${t.category.name}: ${m}`, A = {
172
- modifiers: [
173
- {
174
- name: "offset",
175
- options: { offset: [0, 15] }
176
- }
177
- ]
178
- };
179
- return /* @__PURE__ */ d(
180
- "g",
181
- {
182
- className: "bubble",
183
- id: `bubble-${h}`,
184
- onClick: () => i(t),
185
- onMouseEnter: () => r(!0),
186
- onMouseLeave: () => r(!1),
187
- style: { cursor: n ? "pointer" : "default" },
188
- textAnchor: "middle",
189
- x: f,
190
- y: b,
191
- children: [
192
- /* @__PURE__ */ e(
193
- He,
194
- {
195
- followCursor: !0,
196
- open: s,
197
- slotProps: { popper: A },
198
- title: B,
199
- children: /* @__PURE__ */ e("circle", { fill: o, id: `circle-${h}`, r: g })
200
- }
201
- ),
202
- /* @__PURE__ */ e("svg", { x: u, y: C, children: /* @__PURE__ */ e($, { name: c, size: g <= G ? 24 : 32, sx: { fill: a } }) }),
203
- g > G && /* @__PURE__ */ e(
204
- p,
205
- {
206
- bold: !0,
207
- component: "text",
208
- id: `budget-category-${h}`,
209
- sx: { fill: a },
210
- variant: "Small",
211
- y: 4,
212
- children: y
213
- }
214
- ),
215
- g > ie && /* @__PURE__ */ e(
216
- p,
217
- {
218
- bold: !0,
219
- component: "text",
220
- id: `budget-description-${h}-1`,
221
- sx: { fill: a },
222
- variant: "Body",
223
- y: g <= G ? 12 : 24,
224
- children: g <= G ? m.split(" ")[0] : m
225
- }
226
- ),
227
- g <= G && g > ie && /* @__PURE__ */ e(
228
- p,
229
- {
230
- component: "text",
231
- id: `budget-description-${h}-2`,
232
- sx: { fill: a },
233
- variant: "XSmall",
234
- y: 28,
235
- children: m.split(" ")[1]
236
- }
237
- ),
238
- /* @__PURE__ */ e(mt, { bubble: t })
239
- ]
240
- },
241
- h
242
- );
243
- }
244
- let F;
245
- const pt = ({
246
- height: t,
247
- width: n,
248
- isDraggable: i = !1,
249
- onClick: s = () => {
250
- }
251
- }) => {
252
- const { detailedBudgets: r } = w();
253
- return F = l.useMemo(() => dt(r), [r]), l.useEffect(() => {
254
- ct(F, t, n), i && it(F);
255
- }, [F, t, n]), /* @__PURE__ */ e("svg", { height: t, style: { overflow: "visible" }, width: Math.abs(n), children: F.nodes().map((o) => /* @__PURE__ */ e(gt, { bubble: o, isDraggable: i, onClick: s }, o.guid)) });
256
- }, ht = I(pt), bt = ({
257
- isMiniWidget: t = !1,
258
- onConnectAccountsClick: n,
259
- createBudgetOnClick: i
260
- }) => {
261
- const { recalculateBudgets: s } = w(), { spendCategories: r } = j(), { budgets: o } = D(), [a, c] = l.useState(!1), [y, h] = l.useState(!1), [m, g] = l.useState(!1), f = l.useMemo(() => [...r.filter((u) => u.totalAverageAmount > 0)], [r]), b = async () => {
262
- g(!0);
263
- const { data: u, isSuccess: C } = await s(f);
264
- g(!1), C ? (u.length === 0 && c(!0), h(!1)) : h(!0);
265
- };
266
- return m ? /* @__PURE__ */ e(N, {}) : y ? /* @__PURE__ */ e(
267
- se,
268
- {
269
- header: o.autogenerate_budgets_error_header,
270
- icon: "error",
271
- iconColor: "#4D4D4D",
272
- onClick: (u) => {
273
- u === "primary" ? b() : i();
274
- },
275
- primaryButton: o.autogenerate_budgets_error_primary_button,
276
- secondaryButton: o.zero_state_generate_budgets_secondary_button,
277
- subText: o.autogenerate_budgets_error_subheader,
278
- sx: {
279
- width: { sm: 468 },
280
- ".buttons-footer": {
281
- width: 208
282
- }
283
- }
284
- }
285
- ) : /* @__PURE__ */ e(ke, { children: a ? /* @__PURE__ */ e(
286
- se,
287
- {
288
- header: o.zero_state_generate_budgets_header,
289
- icon: "error",
290
- iconColor: "#4D4D4D",
291
- onClick: (u) => {
292
- u === "primary" ? n() : i();
293
- },
294
- primaryButton: o.zero_state_generate_budgets_primary_button,
295
- secondaryButton: o.zero_state_generate_budgets_secondary_button,
296
- subText: o.zero_state_generate_budgets_subheader,
297
- sx: {
298
- width: t ? "100%" : { sm: 500 },
299
- height: t ? "100%" : { sm: 468 },
300
- mt: 50,
301
- ".buttons-footer": {
302
- width: 208,
303
- height: 100
304
- },
305
- padding: t ? 5 : 0
306
- }
307
- }
308
- ) : /* @__PURE__ */ e(
309
- se,
310
- {
311
- header: o.create_budgets_title,
312
- icon: "bubble_chart",
313
- iconColor: "#1A1A1A",
314
- onClick: (u) => {
315
- u === "primary" ? b() : i();
316
- },
317
- primaryButton: o.empty_state_primary_button,
318
- secondaryButton: t ? void 0 : o.empty_state_secondary_button,
319
- subText: o.empty_state_subheader,
320
- sx: {
321
- width: t ? "100%" : { sm: 432 },
322
- height: t ? "100%" : { sm: 468 },
323
- mt: 50,
324
- ".buttons-footer": {
325
- width: 208,
326
- height: 100
327
- },
328
- padding: t ? 4 : 0
329
- }
330
- }
331
- ) });
332
- }, ve = I(
333
- ({
334
- createBudgetOnClick: t = () => {
335
- },
336
- height: n,
337
- isDraggable: i = !1,
338
- isMiniWidget: s = !1,
339
- shouldShowZeroState: r,
340
- unavailableWidth: o = 24
341
- }) => {
342
- const { onEvent: a } = X(), { setSelectedBudget: c } = w(), { isLoadingCategoryTotals: y } = j(), { isInitialized: h } = J(), { accounts: m } = D(), { availableWidth: g } = Ke(), { isMobile: f } = le(), [b, u] = l.useState(!1), C = l.useMemo(() => g - o, [g]), B = (x) => {
343
- c(x), a(k.BUDGETS_CLICK_BUDGET_CATEGORY, {
344
- budget_category: x.category.name,
345
- click_type: "bubble"
346
- });
347
- }, A = () => {
348
- u(!0), a(k.ACCOUNTS_CLICK_CONNECT);
349
- };
350
- return y ? /* @__PURE__ */ e(_, { alignItems: "center", height: n, justifyContent: "center", width: Math.abs(C), children: /* @__PURE__ */ e(N, {}) }) : /* @__PURE__ */ d(W, { ml: r || f ? 0 : 24, sx: { alignSelf: "center" }, children: [
351
- r || !h ? /* @__PURE__ */ e(
352
- bt,
353
- {
354
- createBudgetOnClick: t,
355
- isMiniWidget: s,
356
- onConnectAccountsClick: A
357
- }
358
- ) : /* @__PURE__ */ e(
359
- ht,
360
- {
361
- height: n,
362
- isDraggable: i,
363
- onClick: B,
364
- width: C
365
- }
366
- ),
367
- /* @__PURE__ */ e(
368
- Ge,
369
- {
370
- onClose: () => u(!1),
371
- showConnectionsWidget: b,
372
- title: m.manage_connections
373
- }
374
- )
375
- ] });
376
- }
377
- ), _t = I(() => {
378
- const { budgets: t } = D(), { totalBudgeted: n } = w(), { incomeTotal: i } = Q(), s = i - n;
379
- return /* @__PURE__ */ d(_, { direction: "row", justifyContent: "center", my: 16, spacing: 20, children: [
380
- /* @__PURE__ */ d(_, { alignItems: "center", children: [
381
- /* @__PURE__ */ e(p, { bold: !0, variant: "Body", children: T(i, "0,0") }),
382
- /* @__PURE__ */ e(p, { color: "secondary", variant: "Small", children: t.projected_income })
383
- ] }),
384
- /* @__PURE__ */ e(p, { bold: !0, justifyContent: "center", variant: "Body", children: "-" }),
385
- /* @__PURE__ */ d(_, { alignItems: "center", children: [
386
- /* @__PURE__ */ e(p, { bold: !0, variant: "Body", children: T(n, "0,0") }),
387
- /* @__PURE__ */ e(p, { color: "secondary", variant: "Small", children: t.budgeted })
388
- ] }),
389
- /* @__PURE__ */ e(p, { bold: !0, justifyContent: "center", variant: "Body", children: "=" }),
390
- /* @__PURE__ */ d(_, { alignItems: "center", children: [
391
- /* @__PURE__ */ e(p, { bold: !0, variant: "Body", children: T(s, "0,0") }),
392
- /* @__PURE__ */ e(p, { color: "secondary", variant: "Small", children: t.remaining })
393
- ] })
394
- ] });
395
- }), yt = I(
396
- ({ category: t }) => {
397
- const { budgets: n } = D(), { budgets: i } = w(), s = l.useMemo(() => {
398
- const r = i.find((c) => c.category_guid === t.guid), o = T(t.totalAverageAmount, "0,0"), a = r ? L(n.recalculate_previous_budget, T(r.amount, "0,0")) : n.recalculate_new_budget;
399
- return `${o} - ${a}`;
400
- }, [n, i]);
401
- return /* @__PURE__ */ d(l.Fragment, { children: [
402
- /* @__PURE__ */ e(K, { children: /* @__PURE__ */ d(V, { children: [
403
- /* @__PURE__ */ e(te, { children: /* @__PURE__ */ e(H, { categoryGuid: t.guid, variant: "filled" }) }),
404
- /* @__PURE__ */ e(Y, { primary: t.name, secondary: s })
405
- ] }) }),
406
- /* @__PURE__ */ e(oe, {})
407
- ] }, t.guid);
408
- }
409
- ), ft = ({ onRecalculateBudgets: t }) => {
410
- const { budgets: n, common: i } = D(), { spendCategories: s } = j(), { recalculateBudgets: r, setAlert: o } = w(), [a, c] = l.useState(!1), y = s.filter((m) => m.totalAverageAmount > 0), h = async () => {
411
- await r(y), c(!1), o(n.alert_recalculated_budgets), t?.();
412
- };
413
- return /* @__PURE__ */ d(l.Fragment, { children: [
414
- /* @__PURE__ */ e(Se, { onClick: () => c(!0), sx: { mt: 24, mx: 24 }, variant: "text", children: n.recalculate_button }),
415
- /* @__PURE__ */ e(p, { sx: { mx: 24, my: 16, textAlign: "center", whiteSpace: "wrap" }, variant: "Paragraph", children: n.recalculate_help }),
416
- /* @__PURE__ */ e(
417
- M,
418
- {
419
- ariaLabelClose: i.close_aria,
420
- isOpen: a,
421
- onClose: () => c(!1),
422
- onPrimaryAction: h,
423
- title: n.recalculate_title,
424
- children: /* @__PURE__ */ d(_, { children: [
425
- /* @__PURE__ */ d(_, { mx: 24, my: 16, children: [
426
- /* @__PURE__ */ e(p, { bold: !0, variant: "Body", children: n.recalculate_description_top }),
427
- /* @__PURE__ */ e(p, { variant: "ParagraphSmall", children: n.recalculate_description_bottom })
428
- ] }),
429
- /* @__PURE__ */ e(W, { bgcolor: "background.paper", children: /* @__PURE__ */ e(Z, { children: y.map((m) => /* @__PURE__ */ e(yt, { category: m }, m.guid)) }) })
430
- ] })
431
- }
432
- )
433
- ] });
434
- }, ne = ({
435
- amount: t,
436
- categoryName: n,
437
- onAmountChanged: i
438
- }) => {
439
- const { budgets: s } = D(), { totalBudgeted: r } = w(), { incomeTotal: o } = Q(), a = o - r;
440
- return /* @__PURE__ */ d(_, { gap: 16, children: [
441
- /* @__PURE__ */ d(_, { children: [
442
- /* @__PURE__ */ e(p, { children: L(
443
- s.add_description_top,
444
- T(a, "0,0")
445
- ) }),
446
- /* @__PURE__ */ e(p, { children: L(s.add_description_bottom, n) })
447
- ] }),
448
- /* @__PURE__ */ e(
449
- Pe,
450
- {
451
- amount: t,
452
- autoFocus: !0,
453
- label: s.add_label,
454
- minAmount: 0,
455
- setAmount: i,
456
- sx: { ".MuiTypography-Body": { p: 0 } }
457
- }
458
- )
459
- ] });
460
- }, Ct = I(({ category: t, onAddBudget: n }) => {
461
- const { budgets: i, common: s } = D(), [r, o] = l.useState(!1), [a, c] = l.useState(
462
- `${t.totalAmount === 0 ? "" : t.totalAmount}`
463
- );
464
- return /* @__PURE__ */ d(l.Fragment, { children: [
465
- /* @__PURE__ */ e(K, { children: /* @__PURE__ */ d(V, { onClick: () => o(!0), children: [
466
- /* @__PURE__ */ e(te, { children: /* @__PURE__ */ e(H, { categoryGuid: t.guid }) }),
467
- /* @__PURE__ */ e(
468
- Y,
469
- {
470
- primary: t.name,
471
- secondary: T(t.totalAmount, "0,0")
472
- }
473
- ),
474
- /* @__PURE__ */ e(et, { children: /* @__PURE__ */ e($, { name: "add", size: 20 }) })
475
- ] }) }, t.guid),
476
- /* @__PURE__ */ e(
477
- P,
478
- {
479
- copy: { close_aria: s.close_aria, title: i.add_title },
480
- disablePrimaryButton: Number(a) <= 0,
481
- isOpen: r,
482
- onClose: () => o(!1),
483
- onPrimaryAction: () => n(t, Number(a)),
484
- primaryText: i.add_save_button,
485
- children: /* @__PURE__ */ e(ne, { amount: a, categoryName: t.name, onAmountChanged: c })
486
- }
487
- )
488
- ] });
489
- }), Te = I(({ onRecalculateBudgets: t }) => {
490
- const { budgets: n } = D(), { addBudget: i, setAlert: s, unbudgetedCategories: r } = w(), o = async (a, c) => {
491
- await i(a, c), s(L(n.alert_budget_created, a.name));
492
- };
493
- return /* @__PURE__ */ d(_, { children: [
494
- /* @__PURE__ */ e(_t, {}),
495
- /* @__PURE__ */ e(W, { bgcolor: "background.paper", children: /* @__PURE__ */ e(Z, { children: r.map((a) => /* @__PURE__ */ e(
496
- Ct,
497
- {
498
- category: a,
499
- onAddBudget: o
500
- },
501
- a.guid
502
- )) }) }),
503
- /* @__PURE__ */ e(ft, { onRecalculateBudgets: t })
504
- ] });
505
- }), Bt = (t) => {
506
- const n = q(), { onEvent: i } = X(), { detailedBudgets: s, isDataLoaded: r, loadBudgetData: o, setTheme: a } = w(), { budgets: c, common: y } = D(), { isCopyLoaded: h, isInitialized: m, selectedAccounts: g } = J(), { reloadCategoryTotals: f } = j(), b = Je(), u = s.length === 0, [C, B] = l.useState(!1), A = () => {
507
- B(!0), i(k.BUDGETS_CLICK_ADD);
508
- }, x = () => {
509
- B(!1);
510
- };
511
- return l.useEffect(() => {
512
- a(n);
513
- }, [n]), l.useEffect(() => {
514
- m && !r && f(g, ye(/* @__PURE__ */ new Date()), Me(/* @__PURE__ */ new Date())).then(
515
- () => {
516
- o().finally();
517
- }
518
- );
519
- }, [m, g]), h ? /* @__PURE__ */ d(
520
- Ve,
521
- {
522
- primaryCtaLabel: u ? c.get_started_cta : c.details_cta,
523
- title: c.budgets_title,
524
- ...t,
525
- children: [
526
- r ? /* @__PURE__ */ d(_, { height: 450, mt: 32, children: [
527
- /* @__PURE__ */ e(
528
- ve,
529
- {
530
- createBudgetOnClick: A,
531
- height: 370,
532
- isMiniWidget: !0,
533
- shouldShowZeroState: u
534
- }
535
- ),
536
- !u && /* @__PURE__ */ d(W, { ml: 16, children: [
537
- /* @__PURE__ */ e(p, { bold: !0, color: b < 0 ? "error.main" : "success.main", children: T(Math.abs(b), "0,0") }),
538
- /* @__PURE__ */ e(p, { children: b < 0 ? c.overspent_in_budgets : c.left_in_budgets })
539
- ] })
540
- ] }) : /* @__PURE__ */ e(N, {}),
541
- /* @__PURE__ */ e(
542
- M,
543
- {
544
- ariaLabelClose: y.close_aria,
545
- isOpen: C,
546
- onClose: () => B(!1),
547
- title: c.add_new_title,
548
- children: /* @__PURE__ */ e(Te, { onRecalculateBudgets: x })
549
- }
550
- )
551
- ]
552
- }
553
- ) : /* @__PURE__ */ e(N, {});
554
- }, yn = I(Bt), we = ({ budget: t }) => {
555
- const {
556
- amount: n,
557
- budgetColors: { background: i },
558
- category: { name: s },
559
- category_guid: r,
560
- percentage: o,
561
- transaction_total: a
562
- } = t, c = [
563
- {
564
- color: i,
565
- percentage: `${o}%`
566
- }
567
- ];
568
- return /* @__PURE__ */ e(de, { sx: { mt: 24, mx: 24 }, children: /* @__PURE__ */ e(ue, { children: /* @__PURE__ */ d(_, { alignItems: "center", gap: 16, children: [
569
- /* @__PURE__ */ e(H, { categoryGuid: r, size: 56 }),
570
- /* @__PURE__ */ e($e, { children: `${T(a, "0,0")} / ${T(n, "0,0")}` }),
571
- /* @__PURE__ */ e(p, { bold: !0, variant: "XSmall", children: s }),
572
- /* @__PURE__ */ e(ce, { data: c, height: 10 })
573
- ] }) }) });
574
- }, St = I(() => {
575
- const { budgets: t } = D();
576
- return /* @__PURE__ */ d(_, { alignItems: "center", gap: 12, height: "auto", mb: 24, mt: 24, children: [
577
- /* @__PURE__ */ e($, { color: "secondary", name: "bubble_chart", sx: { fontSize: 32 } }),
578
- /* @__PURE__ */ e(p, { bold: !0, color: "secondary", variant: "Small", children: t.zero_state_no_sub_budgets }),
579
- /* @__PURE__ */ e(p, { color: "text.secondary", variant: "XSmall", children: t.zero_state_no_sub_budgets_description })
580
- ] });
581
- }), At = I(({ budget: t }) => {
582
- const {
583
- amount: n,
584
- budgetColors: { background: i },
585
- category: s,
586
- percentage: r,
587
- transaction_total: o
588
- } = t, { setSelectedSubBudget: a } = w();
589
- return /* @__PURE__ */ e(K, { children: /* @__PURE__ */ d(V, { onClick: () => a(t), children: [
590
- /* @__PURE__ */ e(te, { sx: { mb: -8, mr: 16 }, children: /* @__PURE__ */ e(Ce, { color: i, percent: r, size: 40, children: /* @__PURE__ */ e(H, { categoryGuid: s.parent_guid, variant: "basic" }) }) }),
591
- /* @__PURE__ */ e(
592
- Y,
593
- {
594
- primary: /* @__PURE__ */ e(_, { component: "span", direction: "row", justifyContent: "space-between", children: /* @__PURE__ */ e(p, { bold: !0, variant: "Body", children: t.category.name }) }),
595
- secondary: /* @__PURE__ */ e(_, { component: "span", direction: "row", justifyContent: "space-between", children: /* @__PURE__ */ e(p, { fontWeight: 400, variant: "Body", children: `
596
- ${T(o, "0,0")} /
597
- ${T(n, "0,0")}
598
- ` }) })
599
- }
600
- )
601
- ] }) });
602
- }), xt = I(({ category: t, parentBudget: n }) => {
603
- const { budgets: i, common: s } = D(), { setExpandedGuid: r, setOnSelect: o } = Ne(), { addBudget: a } = w(), [c, y] = l.useState(!1), [h, m] = l.useState(!1), [g, f] = l.useState(""), [b, u] = l.useState(void 0);
604
- l.useEffect(() => {
605
- o((A) => {
606
- const x = t.subCategories.find((v) => v.guid === A);
607
- x && (u(x), f(`${x.currentAmount === 0 ? "" : x.currentAmount}`), m(!0));
608
- });
609
- }, []);
610
- const C = () => {
611
- r(t.guid), y(!0);
612
- }, B = async () => {
613
- b && Number(g) > 0 && (await a(b, Number(g), n.guid), m(!1), y(!1), u(void 0));
614
- };
615
- return /* @__PURE__ */ d(W, { children: [
616
- /* @__PURE__ */ e(K, { disableGutters: !0, disablePadding: !0, sx: { bgcolor: "background.paper" }, children: /* @__PURE__ */ e(V, { onClick: C, children: /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ d(_, { alignItems: "center", direction: "row", justifyContent: "space-between", children: [
617
- /* @__PURE__ */ d(_, { alignItems: "center", direction: "row", gap: 8, children: [
618
- /* @__PURE__ */ e($, { fill: !0, name: "add_box", size: 24, sx: { color: "primary.light" } }),
619
- /* @__PURE__ */ e(p, { bold: !0, sx: { color: "primary.light" }, variant: "Body", children: i.add_sub_budget_button })
620
- ] }),
621
- /* @__PURE__ */ e($, { name: "chevron_right", size: 24, sx: { color: "primary.light" } })
622
- ] }) }) }) }),
623
- /* @__PURE__ */ e(oe, {}),
624
- /* @__PURE__ */ e(
625
- M,
626
- {
627
- ariaLabelClose: s.close_aria,
628
- isOpen: c,
629
- onClose: () => y(!1),
630
- title: i.add_sub_budget_title,
631
- children: /* @__PURE__ */ e(Z, { children: /* @__PURE__ */ e(je, { category: t, subCategories: t.subCategories }) })
632
- }
633
- ),
634
- /* @__PURE__ */ e(
635
- P,
636
- {
637
- copy: { close_aria: s.close_aria, title: i.add_title },
638
- disablePrimaryButton: Number(g) <= 0,
639
- isOpen: h,
640
- onClose: () => m(!1),
641
- onPrimaryAction: B,
642
- primaryText: i.add_save_button,
643
- children: /* @__PURE__ */ e(
644
- ne,
645
- {
646
- amount: g,
647
- categoryName: b?.name || "",
648
- onAmountChanged: f
649
- }
650
- )
651
- }
652
- )
653
- ] });
654
- }), vt = I(({ budget: t }) => {
655
- const { category: n, subBudgets: i } = t, { budgets: s, common: r } = D(), { deleteBudget: o, selectedSubBudget: a, setSelectedSubBudget: c, updateBudget: y } = w(), { filter: h, setFilter: m } = ee(), [g, f] = l.useState(!1), [b, u] = l.useState(!1), [C, B] = l.useState("");
656
- l.useEffect(() => {
657
- a && (B(`${a.amount}`), m({
658
- ...h,
659
- custom: (S) => S.category_guid === a.category_guid
660
- }));
661
- }, [a]);
662
- const A = async () => {
663
- a && await y({
664
- ...a,
665
- amount: Number(C)
666
- });
667
- }, x = async () => {
668
- a && await o(a.guid), u(!1), v();
669
- }, v = () => {
670
- m({
671
- ...h,
672
- custom: (S) => S.category_guid === t.category_guid || S.top_level_category_guid === t.category_guid
673
- }), c(void 0);
674
- };
675
- return /* @__PURE__ */ d(l.Fragment, { children: [
676
- /* @__PURE__ */ d(Z, { sx: { bgcolor: "background.paper" }, children: [
677
- i.length === 0 ? /* @__PURE__ */ e(St, {}) : i.map((S) => /* @__PURE__ */ d(l.Fragment, { children: [
678
- /* @__PURE__ */ e(At, { budget: S }),
679
- /* @__PURE__ */ e(oe, {})
680
- ] }, S.guid)),
681
- /* @__PURE__ */ e(xt, { category: n, parentBudget: t })
682
- ] }),
683
- /* @__PURE__ */ e(
684
- M,
685
- {
686
- ariaLabelClose: r.close_aria,
687
- isOpen: !!a,
688
- onClose: v,
689
- onPrimaryAction: () => f(!0),
690
- onSecondaryAction: () => u(!0),
691
- primaryText: s.details_edit_button,
692
- secondaryText: s.details_delete_button,
693
- title: s.details_title,
694
- children: a && /* @__PURE__ */ d(_, { gap: 24, children: [
695
- /* @__PURE__ */ e(we, { budget: a }),
696
- /* @__PURE__ */ e(Be, { height: "100%" })
697
- ] })
698
- }
699
- ),
700
- a && /* @__PURE__ */ d(l.Fragment, { children: [
701
- /* @__PURE__ */ e(
702
- P,
703
- {
704
- copy: { close_aria: r.close_aria, title: s.details_edit_title },
705
- disablePrimaryButton: Number(C) <= 0,
706
- isOpen: g,
707
- onClose: () => f(!1),
708
- onPrimaryAction: A,
709
- primaryText: s.edit_save_button,
710
- children: /* @__PURE__ */ e(
711
- ne,
712
- {
713
- amount: C,
714
- categoryName: a.category.name,
715
- onAmountChanged: B
716
- }
717
- )
718
- }
719
- ),
720
- /* @__PURE__ */ e(
721
- P,
722
- {
723
- copy: { close_aria: r.close_aria, title: s.delete_title },
724
- isOpen: b,
725
- onClose: () => u(!1),
726
- onPrimaryAction: x,
727
- primaryColor: "error",
728
- primaryText: "Delete",
729
- secondaryColor: "secondary",
730
- children: /* @__PURE__ */ e(p, { variant: "Paragraph", children: L(s.delete_description, a.category.name) })
731
- }
732
- )
733
- ] })
734
- ] });
735
- }), Tt = I(({ budget: t }) => {
736
- const { is_mobile_webview: n } = Ye(), { setAlert: i } = w(), { budgets: s, common: r, transactions: o } = D(), { isDesktop: a } = le(), {
737
- sortedTransactions: c,
738
- sortedTransactionsWithSplits: y,
739
- tags: h
740
- } = ee(), [m, g] = l.useState(0), [f, b] = l.useState(""), u = l.useMemo(
741
- () => c.find((x) => x.guid === f),
742
- [f, c]
743
- ), C = (x, v) => {
744
- g(v);
745
- }, B = () => {
746
- Ue(y, h), i(s.alert_csv_downloaded);
747
- }, A = c.length > 0 && !n && a;
748
- return /* @__PURE__ */ d(_, { gap: 24, children: [
749
- /* @__PURE__ */ e(we, { budget: t }),
750
- /* @__PURE__ */ d(_, { children: [
751
- /* @__PURE__ */ d(
752
- qe,
753
- {
754
- onChange: C,
755
- sx: { width: "100%" },
756
- textColor: "primary",
757
- value: m,
758
- variant: "fullWidth",
759
- children: [
760
- /* @__PURE__ */ e(pe, { label: s.details_transactions_tab }),
761
- /* @__PURE__ */ e(pe, { label: s.details_subbudgets_tab })
762
- ]
763
- }
764
- ),
765
- m === 0 && /* @__PURE__ */ d(_, { children: [
766
- A && /* @__PURE__ */ e(_, { direction: "row", justifyContent: "right", mb: -24, mr: 8, mt: 8, zIndex: 1, children: /* @__PURE__ */ e(
767
- Se,
768
- {
769
- onClick: B,
770
- startIcon: /* @__PURE__ */ e($, { name: "ios_share" }),
771
- variant: "text",
772
- children: o.export_csv_btn
773
- }
774
- ) }),
775
- /* @__PURE__ */ e(Be, { height: "100%", onClick: b })
776
- ] }),
777
- m === 1 && /* @__PURE__ */ e(vt, { budget: t }),
778
- /* @__PURE__ */ e(
779
- M,
780
- {
781
- ariaLabelClose: r.close_aria,
782
- isOpen: !!u,
783
- onClose: () => b(""),
784
- title: s.details_transaction_drawer,
785
- children: u && /* @__PURE__ */ e(ze, { transaction: u })
786
- }
787
- )
788
- ] })
789
- ] });
790
- }), wt = I(() => {
791
- const { selectedAccountGuids: t } = J(), { budgets: n, common: i } = D(), {
792
- dateRange: s,
793
- deleteBudget: r,
794
- selectedBudget: o,
795
- selectedSubBudget: a,
796
- setAlert: c,
797
- setSelectedBudget: y,
798
- updateBudget: h
799
- } = w(), { setFilter: m } = ee(), [g, f] = l.useState(!1), [b, u] = l.useState(!1), [C, B] = l.useState(!1), [A, x] = l.useState("");
800
- l.useEffect(() => {
801
- o && !a && (x(`${o.amount}`), f(!0), m({
802
- accounts: t,
803
- dateRange: s,
804
- custom: (R) => R.category_guid === o.category_guid || R.top_level_category_guid === o.category_guid
805
- }));
806
- }, [o]);
807
- const v = async () => {
808
- o && (await h({
809
- ...o,
810
- amount: Number(A),
811
- percentage: o.category.totalAmount / Number(A) * 100
812
- }), c(L(n.alert_budget_updated, o.category.name)));
813
- }, S = async () => {
814
- o && (await r(o.guid), c(L(n.alert_budget_deleted, o.category.name))), B(!1), O();
815
- }, O = () => {
816
- f(!1), setTimeout(() => {
817
- y(void 0);
818
- }, 250);
819
- };
820
- if (o)
821
- return /* @__PURE__ */ d(l.Fragment, { children: [
822
- /* @__PURE__ */ e(
823
- M,
824
- {
825
- ariaLabelClose: i.close_aria,
826
- isOpen: g,
827
- onClose: O,
828
- onPrimaryAction: () => u(!0),
829
- onSecondaryAction: () => B(!0),
830
- primaryText: n.details_edit_button,
831
- secondaryColor: "error",
832
- secondaryText: n.details_delete_button,
833
- title: n.details_title,
834
- children: /* @__PURE__ */ e(Tt, { budget: o })
835
- }
836
- ),
837
- /* @__PURE__ */ e(
838
- P,
839
- {
840
- copy: { close_aria: i.close_aria, title: n.details_edit_title },
841
- disablePrimaryButton: Number(A) <= 0,
842
- isOpen: b,
843
- onClose: () => u(!1),
844
- onPrimaryAction: v,
845
- primaryText: n.edit_save_button,
846
- children: /* @__PURE__ */ e(
847
- ne,
848
- {
849
- amount: A,
850
- categoryName: o.category.name,
851
- onAmountChanged: x
852
- }
853
- )
854
- }
855
- ),
856
- /* @__PURE__ */ e(
857
- P,
858
- {
859
- copy: { close_aria: i.close_aria, title: n.delete_title },
860
- isOpen: C,
861
- onClose: () => B(!1),
862
- onPrimaryAction: S,
863
- primaryColor: "error",
864
- primaryText: n.details_delete_button,
865
- secondaryColor: "secondary",
866
- children: /* @__PURE__ */ e(p, { variant: "Paragraph", children: L(n.delete_description, o.category.name) })
867
- }
868
- )
869
- ] });
870
- }), Dt = ({ budget: t, onClick: n }) => {
871
- const {
872
- amount: i,
873
- budgetColors: { background: s, description: r },
874
- category_guid: o,
875
- description: a,
876
- percentage: c,
877
- subBudgets: y,
878
- transaction_total: h
879
- } = t;
880
- return /* @__PURE__ */ e(K, { children: /* @__PURE__ */ d(V, { onClick: () => n?.(t), children: [
881
- /* @__PURE__ */ e(te, { sx: { mb: -8, mr: 16 }, children: /* @__PURE__ */ e(Ce, { color: s, percent: c, size: 40, children: /* @__PURE__ */ e(H, { categoryGuid: o, variant: "basic" }) }) }),
882
- /* @__PURE__ */ e(
883
- Y,
884
- {
885
- primary: /* @__PURE__ */ d(_, { component: "span", direction: "row", justifyContent: "space-between", children: [
886
- /* @__PURE__ */ e(p, { bold: !0, variant: "Body", children: t.category.name }),
887
- /* @__PURE__ */ e(p, { fontWeight: 400, variant: "Body", children: `
888
- ${T(h, "0,0")} /
889
- ${T(i, "0,0")}
890
- ` })
891
- ] }),
892
- secondary: /* @__PURE__ */ d(_, { component: "span", direction: "row", justifyContent: "space-between", children: [
893
- /* @__PURE__ */ e(p, { variant: "XSmall", children: `${y.length} Sub-budgets` }),
894
- /* @__PURE__ */ e(p, { bold: c > 100, color: r, variant: "XSmall", children: a })
895
- ] })
896
- }
897
- )
898
- ] }) });
899
- }, It = I(() => {
900
- const { onEvent: t } = X(), { budgets: n } = D(), { detailedBudgets: i, setSelectedBudget: s } = w(), r = (o) => {
901
- s(o), t(k.BUDGETS_CLICK_BUDGET_CATEGORY, {
902
- budget_category: o.category.name,
903
- click_type: "list"
904
- });
905
- };
906
- return /* @__PURE__ */ d(de, { elevation: 2, children: [
907
- /* @__PURE__ */ e(xe, { sx: { pb: 8, pl: 24 }, title: /* @__PURE__ */ e(fe, { children: n.budget_categories_title }) }),
908
- /* @__PURE__ */ e(ue, { sx: { p: 0, ":last-child": { p: 0 } }, children: /* @__PURE__ */ e(Z, { children: i.map((o) => /* @__PURE__ */ d(l.Fragment, { children: [
909
- /* @__PURE__ */ e(Dt, { budget: o, onClick: r }),
910
- /* @__PURE__ */ e(oe, {})
911
- ] }, o.guid)) }) })
912
- ] });
913
- }), Et = I(() => {
914
- const t = q(), { onEvent: n } = X(), { visibleAccounts: i } = Ae(), { budgets: s, common: r, recurring: o } = D(), { incomeCategories: a, spendCategories: c } = j(), { detailedBudgets: y, totalBudgeted: h } = w(), { incomeTotal: m } = Q(), { setFilter: g } = ee(), [f, b] = l.useState(!1), [u, C] = l.useMemo(() => {
915
- const v = c.reduce((z, re) => z + re.totalAmount, 0);
916
- let S = v / h;
917
- S > 1 && (S = 1);
918
- let O = t.palette.success.main;
919
- S > 0.8 && S < 1 ? O = t.palette.warning.main : S >= 1 && (O = t.palette.error.main);
920
- const R = [
921
- {
922
- color: O,
923
- percentage: `${S}`
924
- }
925
- ];
926
- return [v, R];
927
- }, [y, c]), [B, A] = l.useMemo(() => {
928
- const v = Math.abs(
929
- a.reduce((R, z) => R + z.totalAmount, 0)
930
- );
931
- let S = v / m;
932
- S > 1 && (S = 1);
933
- const O = [
934
- {
935
- color: t.palette.secondary.main,
936
- percentage: `${S}`
937
- }
938
- ];
939
- return [v, O];
940
- }, [a, m]), x = () => {
941
- g({
942
- accounts: i.map((v) => v.guid),
943
- dateRange: {
944
- start: Ze(/* @__PURE__ */ new Date(), 90),
945
- end: /* @__PURE__ */ new Date()
946
- }
947
- }), b(!0), n(k.BUDGETS_CLICK_EDIT_INCOME);
948
- };
949
- return /* @__PURE__ */ d(de, { elevation: 2, sx: { overflow: "visible" }, children: [
950
- /* @__PURE__ */ e(xe, { sx: { pb: 8, pl: 24 }, title: /* @__PURE__ */ e(fe, { children: s.overview_title }) }),
951
- /* @__PURE__ */ e(ue, { sx: { pt: 12, px: 24 }, children: /* @__PURE__ */ d(_, { gap: 24, children: [
952
- /* @__PURE__ */ d(_, { gap: 8, children: [
953
- /* @__PURE__ */ e(p, { bold: !0, sx: { mb: 8 }, variant: "Body", children: s.spending_title }),
954
- /* @__PURE__ */ e(ce, { data: C, height: 16 }),
955
- /* @__PURE__ */ e(p, { variant: "Small", children: L(
956
- s.spending_description,
957
- T(u, "0,0"),
958
- T(h, "0,0")
959
- ) })
960
- ] }),
961
- /* @__PURE__ */ d(_, { gap: 8, children: [
962
- /* @__PURE__ */ d(_, { alignItems: "center", direction: "row", gap: 4, mb: -4, children: [
963
- /* @__PURE__ */ e(p, { bold: !0, variant: "Body", children: s.income_title }),
964
- /* @__PURE__ */ e(
965
- Xe,
966
- {
967
- "aria-label": o.manage_income,
968
- onClick: x,
969
- sx: { p: 0 },
970
- children: /* @__PURE__ */ e($, { color: "primary", name: "edit" })
971
- }
972
- )
973
- ] }),
974
- /* @__PURE__ */ e(ce, { data: A, height: 16 }),
975
- /* @__PURE__ */ e(p, { variant: "Small", children: L(
976
- s.income_description,
977
- T(B, "0,0"),
978
- T(m, "0,0")
979
- ) })
980
- ] })
981
- ] }) }),
982
- /* @__PURE__ */ e(
983
- M,
984
- {
985
- ariaLabelClose: r.close_aria,
986
- isOpen: f,
987
- onClose: () => b(!1),
988
- title: o.manage_income,
989
- children: /* @__PURE__ */ d(_, { gap: 4, children: [
990
- /* @__PURE__ */ e(p, { bold: !0, sx: { mt: 12, mx: 24 }, variant: "Small", children: s.income_title }),
991
- /* @__PURE__ */ e(Fe, {})
992
- ] })
993
- }
994
- )
995
- ] });
996
- }), _e = 480, fn = I(({ onBackClick: t, sx: n }) => {
997
- const i = q(), { onEvent: s } = X(), { visibleAccounts: r } = Ae(), { budgets: o, common: a } = D(), { isCopyLoaded: c, isInitialized: y, selectedAccounts: h, setDisplayedDate: m, setSelectedAccounts: g } = J(), {
998
- alert: f,
999
- dateRange: b,
1000
- isDataLoaded: u,
1001
- loadBudgetData: C,
1002
- setDateRange: B,
1003
- setAlert: A,
1004
- setTheme: x,
1005
- detailedBudgets: v
1006
- } = w(), { loadRepeatingTransactions: S, setDateRange: O } = Q(), { reloadCategoryTotals: R } = j(), { isSmallTablet: z, isMobile: re, isSmallMobile: De } = le(), U = z || re || De, [Ie, ae] = l.useState(!1);
1007
- l.useEffect(() => {
1008
- x(i), g(r), m(b.start, b.end), s(k.BUDGETS_VIEW);
1009
- }, []), l.useEffect(() => {
1010
- g(r);
1011
- }, [r]), l.useEffect(() => {
1012
- y && (R(h, b.start, b.end).finally(), O(b), u || (S().finally(), C().finally()));
1013
- }, [y, h, b]);
1014
- const Ee = (ge) => {
1015
- B({ start: ge[0] || /* @__PURE__ */ new Date(), end: ge[1] || /* @__PURE__ */ new Date() });
1016
- }, Oe = () => {
1017
- s(k.BUDGETS_CLICK_FILTER);
1018
- }, me = () => {
1019
- ae(!0), s(k.BUDGETS_CLICK_ADD);
1020
- }, Le = () => {
1021
- ae(!1);
1022
- }, Re = Qe(b.end, ye(/* @__PURE__ */ new Date()));
1023
- return !c || !y || !u ? /* @__PURE__ */ e(N, {}) : /* @__PURE__ */ d(
1024
- We,
1025
- {
1026
- accountOptions: r,
1027
- actions: [
1028
- {
1029
- iconName: "add",
1030
- label: o.add_title,
1031
- onClick: me
1032
- }
1033
- ],
1034
- calendarActions: { onRangeChanged: Ee, shouldDisableNext: Re },
1035
- onAccountsFilterClick: Oe,
1036
- onBackClick: t,
1037
- sx: n,
1038
- title: o.budgets_title,
1039
- children: [
1040
- (!y || !u) && /* @__PURE__ */ e(N, {}),
1041
- y && u && /* @__PURE__ */ d(
1042
- _,
1043
- {
1044
- direction: U ? "column" : "row",
1045
- height: "100%",
1046
- sx: { justifyContent: "center" },
1047
- width: "100%",
1048
- children: [
1049
- /* @__PURE__ */ e(_, { height: U ? 450 : "calc(100dvh - 150px)", children: /* @__PURE__ */ e(
1050
- ve,
1051
- {
1052
- createBudgetOnClick: me,
1053
- height: U ? 450 : 800,
1054
- isDraggable: !0,
1055
- shouldShowZeroState: v.length === 0,
1056
- unavailableWidth: U ? 0 : _e
1057
- }
1058
- ) }),
1059
- v.length !== 0 && /* @__PURE__ */ d(
1060
- _,
1061
- {
1062
- gap: 24,
1063
- height: "100%",
1064
- sx: { mr: 24, mt: 48 },
1065
- width: U ? "100%" : _e,
1066
- children: [
1067
- /* @__PURE__ */ e(Et, {}),
1068
- /* @__PURE__ */ e(It, {})
1069
- ]
1070
- }
1071
- )
1072
- ]
1073
- }
1074
- ),
1075
- /* @__PURE__ */ e(wt, {}),
1076
- /* @__PURE__ */ e(
1077
- M,
1078
- {
1079
- ariaLabelClose: a.close_aria,
1080
- isOpen: Ie,
1081
- onClose: () => ae(!1),
1082
- title: o.add_new_title,
1083
- children: /* @__PURE__ */ e(Te, { onRecalculateBudgets: Le })
1084
- }
1085
- ),
1086
- /* @__PURE__ */ e(
1087
- ot,
1088
- {
1089
- anchorOrigin: { vertical: "bottom", horizontal: "right" },
1090
- autoHideDuration: 3500,
1091
- onClose: () => {
1092
- A("");
1093
- },
1094
- open: !!f,
1095
- children: /* @__PURE__ */ e(
1096
- tt,
1097
- {
1098
- onClose: () => {
1099
- A("");
1100
- },
1101
- severity: "success",
1102
- variant: "filled",
1103
- children: f
1104
- }
1105
- )
1106
- }
1107
- )
1108
- ]
1109
- }
1110
- );
1111
- });
1112
- export {
1113
- yn as BubbleBudgetsMiniWidget,
1114
- fn as BubbleBudgetsWidget
1115
- };
1116
- //# sourceMappingURL=index.es.js.map