@burdenoff/microfe-healthybowl 2026.605.6 → 2026.605.7
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.
|
@@ -3,16 +3,14 @@ import { PageLayout as t } from "../../components/PageLayout.js";
|
|
|
3
3
|
import { StatCard as n } from "../../components/StatCard.js";
|
|
4
4
|
import { StatusBadge as r } from "../../components/StatusBadge.js";
|
|
5
5
|
import { EmptyState as i } from "../../components/EmptyState.js";
|
|
6
|
-
import { Modal as a } from "../../components/Modal.js";
|
|
7
6
|
import "../../components/index.js";
|
|
8
|
-
import { useHealthyBowlData as
|
|
9
|
-
import { useEffect as
|
|
10
|
-
import { AlertCircle as
|
|
11
|
-
import { useNavigate as
|
|
12
|
-
import {
|
|
13
|
-
import { getProfileScopedKey as T } from "@burdenoff/fe-libs/shared/utils";
|
|
7
|
+
import { useHealthyBowlData as a } from "../../hooks/useHealthyBowlData.js";
|
|
8
|
+
import { useEffect as o, useState as s } from "react";
|
|
9
|
+
import { AlertCircle as c, AlertTriangle as l, Calendar as u, Cloud as d, MapPin as f } from "lucide-react";
|
|
10
|
+
import { useNavigate as p } from "react-router-dom";
|
|
11
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
14
12
|
//#region src/healthybowl/pages/weather/WeatherAlertsPage.tsx
|
|
15
|
-
var
|
|
13
|
+
var g = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ? "warning" : "info", _ = (e) => {
|
|
16
14
|
switch (e) {
|
|
17
15
|
case "extreme": return "border-l-red-600";
|
|
18
16
|
case "severe": return "border-l-red-500";
|
|
@@ -20,346 +18,116 @@ var E = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
|
|
|
20
18
|
case "minor": return "border-l-sky-500";
|
|
21
19
|
default: return "border-l-border";
|
|
22
20
|
}
|
|
23
|
-
},
|
|
21
|
+
}, v = (e) => {
|
|
24
22
|
switch (e) {
|
|
25
23
|
case "high": return "error";
|
|
26
24
|
case "medium": return "warning";
|
|
27
25
|
case "low": return "success";
|
|
28
26
|
default: return "muted";
|
|
29
27
|
}
|
|
30
|
-
},
|
|
31
|
-
let { weatherData:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (e) return JSON.parse(e).emailNotif ?? !0;
|
|
35
|
-
} catch {}
|
|
36
|
-
return !0;
|
|
37
|
-
}), [z, B] = c(() => {
|
|
38
|
-
try {
|
|
39
|
-
let e = localStorage.getItem(T(O));
|
|
40
|
-
if (e) return JSON.parse(e).smsNotif ?? !1;
|
|
41
|
-
} catch {}
|
|
42
|
-
return !1;
|
|
43
|
-
}), [V, H] = c(() => {
|
|
44
|
-
try {
|
|
45
|
-
let e = localStorage.getItem(T(O));
|
|
46
|
-
if (e) return JSON.parse(e).pushNotif ?? !0;
|
|
47
|
-
} catch {}
|
|
48
|
-
return !0;
|
|
49
|
-
}), [U, W] = c({
|
|
50
|
-
severe: !0,
|
|
51
|
-
warning: !0,
|
|
52
|
-
advisory: !0,
|
|
53
|
-
info: !1
|
|
54
|
-
}), [G, K] = c(2);
|
|
55
|
-
s(() => {
|
|
56
|
-
try {
|
|
57
|
-
localStorage.setItem(T(O), JSON.stringify({
|
|
58
|
-
emailNotif: L,
|
|
59
|
-
smsNotif: z,
|
|
60
|
-
pushNotif: V
|
|
61
|
-
}));
|
|
62
|
-
} catch {}
|
|
63
|
-
}, [
|
|
64
|
-
L,
|
|
65
|
-
z,
|
|
66
|
-
V
|
|
67
|
-
]), s(() => {
|
|
68
|
-
M((k?.alerts ?? []).map((e) => ({
|
|
28
|
+
}, y = () => {
|
|
29
|
+
let { weatherData: y } = a(), b = p(), [x, S] = s([]), [C, w] = s("all");
|
|
30
|
+
o(() => {
|
|
31
|
+
S((y?.alerts ?? []).map((e) => ({
|
|
69
32
|
...e,
|
|
70
|
-
isSubscribed: e.severity === "extreme" || e.severity === "severe",
|
|
71
33
|
impactLevel: e.severity === "extreme" || e.severity === "severe" ? "high" : e.severity === "moderate" ? "medium" : "low"
|
|
72
34
|
})));
|
|
73
|
-
}, [
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
...t,
|
|
77
|
-
isSubscribed: !t.isSubscribed
|
|
78
|
-
} : t));
|
|
79
|
-
}, $ = j.filter((e) => N === "subscribed" ? e.isSubscribed : N === "active" ? new Date(e.endTime) > q : !0);
|
|
80
|
-
return /* @__PURE__ */ w(t, {
|
|
35
|
+
}, [y?.alerts]);
|
|
36
|
+
let T = /* @__PURE__ */ new Date(), E = x.filter((e) => new Date(e.endTime) > T).length, D = x.filter((e) => e.impactLevel === "high").length, O = x.length, k = x.filter((e) => C === "active" ? new Date(e.endTime) > T : !0);
|
|
37
|
+
return /* @__PURE__ */ h(t, {
|
|
81
38
|
title: "Weather Alerts",
|
|
82
39
|
description: "Stay informed about weather conditions affecting your crops",
|
|
83
|
-
actions: /* @__PURE__ */ w("button", {
|
|
84
|
-
onClick: () => I(!0),
|
|
85
|
-
className: "inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",
|
|
86
|
-
children: [/* @__PURE__ */ C(y, { className: "h-4 w-4" }), " Alert Settings"]
|
|
87
|
-
}),
|
|
88
40
|
children: [
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
className: "grid grid-cols-1 gap-4 sm:grid-cols-
|
|
41
|
+
/* @__PURE__ */ h("div", {
|
|
42
|
+
className: "grid grid-cols-1 gap-4 sm:grid-cols-3",
|
|
91
43
|
children: [
|
|
92
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ m(n, {
|
|
93
45
|
label: "Active Alerts",
|
|
94
|
-
value:
|
|
95
|
-
icon: /* @__PURE__ */
|
|
46
|
+
value: E,
|
|
47
|
+
icon: /* @__PURE__ */ m(l, { className: "h-4 w-4" })
|
|
96
48
|
}),
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
label: "Subscribed",
|
|
99
|
-
value: Y,
|
|
100
|
-
icon: /* @__PURE__ */ C(d, { className: "h-4 w-4" })
|
|
101
|
-
}),
|
|
102
|
-
/* @__PURE__ */ C(n, {
|
|
49
|
+
/* @__PURE__ */ m(n, {
|
|
103
50
|
label: "High Impact",
|
|
104
|
-
value:
|
|
105
|
-
icon: /* @__PURE__ */
|
|
51
|
+
value: D,
|
|
52
|
+
icon: /* @__PURE__ */ m(c, { className: "h-4 w-4" })
|
|
106
53
|
}),
|
|
107
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ m(n, {
|
|
108
55
|
label: "All Alerts",
|
|
109
|
-
value:
|
|
110
|
-
icon: /* @__PURE__ */
|
|
56
|
+
value: O,
|
|
57
|
+
icon: /* @__PURE__ */ m(d, { className: "h-4 w-4" })
|
|
111
58
|
})
|
|
112
59
|
]
|
|
113
60
|
}),
|
|
114
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ m("div", {
|
|
115
62
|
className: "flex gap-1 border-b border-border",
|
|
116
|
-
children: [
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
{
|
|
126
|
-
key: "subscribed",
|
|
127
|
-
label: `Subscribed (${Y})`
|
|
128
|
-
}
|
|
129
|
-
].map(({ key: e, label: t }) => /* @__PURE__ */ C("button", {
|
|
130
|
-
onClick: () => P(e),
|
|
131
|
-
className: `border-b-2 px-3 pb-2 text-sm font-medium transition-colors ${N === e ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground"}`,
|
|
63
|
+
children: [{
|
|
64
|
+
key: "all",
|
|
65
|
+
label: `All Alerts (${O})`
|
|
66
|
+
}, {
|
|
67
|
+
key: "active",
|
|
68
|
+
label: `Active Now (${E})`
|
|
69
|
+
}].map(({ key: e, label: t }) => /* @__PURE__ */ m("button", {
|
|
70
|
+
onClick: () => w(e),
|
|
71
|
+
className: `border-b-2 px-3 pb-2 text-sm font-medium transition-colors ${C === e ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground"}`,
|
|
132
72
|
children: t
|
|
133
73
|
}, e))
|
|
134
74
|
}),
|
|
135
|
-
|
|
136
|
-
icon: /* @__PURE__ */
|
|
75
|
+
k.length === 0 ? /* @__PURE__ */ m(i, {
|
|
76
|
+
icon: /* @__PURE__ */ m(d, { className: "h-12 w-12" }),
|
|
137
77
|
title: "No Alerts",
|
|
138
|
-
description:
|
|
139
|
-
}) : /* @__PURE__ */
|
|
78
|
+
description: "No weather alerts matching the selected filter."
|
|
79
|
+
}) : /* @__PURE__ */ m("div", {
|
|
140
80
|
className: "space-y-4",
|
|
141
|
-
children:
|
|
142
|
-
className: `rounded-lg border border-border border-l-4 bg-card p-5 ${
|
|
143
|
-
children: /* @__PURE__ */
|
|
144
|
-
className: "flex
|
|
145
|
-
children: [/* @__PURE__ */ w("div", {
|
|
146
|
-
className: "flex
|
|
147
|
-
children: [/* @__PURE__ */ C(u, { className: "mt-0.5 h-5 w-5 shrink-0 text-amber-500" }), /* @__PURE__ */ w("div", {
|
|
148
|
-
className: "flex-1 space-y-2",
|
|
149
|
-
children: [
|
|
150
|
-
/* @__PURE__ */ w("div", {
|
|
151
|
-
className: "flex flex-wrap items-center gap-2",
|
|
152
|
-
children: [
|
|
153
|
-
/* @__PURE__ */ C("h3", {
|
|
154
|
-
className: "text-sm font-semibold text-foreground",
|
|
155
|
-
children: t.title
|
|
156
|
-
}),
|
|
157
|
-
/* @__PURE__ */ C(r, {
|
|
158
|
-
label: t.severity,
|
|
159
|
-
variant: E(t.severity)
|
|
160
|
-
}),
|
|
161
|
-
/* @__PURE__ */ C(r, {
|
|
162
|
-
label: `${(t.impactLevel ?? "").toUpperCase()} IMPACT`,
|
|
163
|
-
variant: ee(t.impactLevel)
|
|
164
|
-
})
|
|
165
|
-
]
|
|
166
|
-
}),
|
|
167
|
-
/* @__PURE__ */ C("p", {
|
|
168
|
-
className: "text-sm text-muted-foreground",
|
|
169
|
-
children: t.description
|
|
170
|
-
}),
|
|
171
|
-
/* @__PURE__ */ w("div", {
|
|
172
|
-
className: "flex flex-wrap gap-4 text-xs text-muted-foreground",
|
|
173
|
-
children: [/* @__PURE__ */ w("span", {
|
|
174
|
-
className: "flex items-center gap-1",
|
|
175
|
-
children: [/* @__PURE__ */ C(_, { className: "h-3.5 w-3.5" }), (t.affectedAreas ?? []).join(", ")]
|
|
176
|
-
}), /* @__PURE__ */ w("span", {
|
|
177
|
-
className: "flex items-center gap-1",
|
|
178
|
-
children: [
|
|
179
|
-
/* @__PURE__ */ C(p, { className: "h-3.5 w-3.5" }),
|
|
180
|
-
e(t.startTime),
|
|
181
|
-
" - ",
|
|
182
|
-
e(t.endTime)
|
|
183
|
-
]
|
|
184
|
-
})]
|
|
185
|
-
})
|
|
186
|
-
]
|
|
187
|
-
})]
|
|
188
|
-
}), /* @__PURE__ */ C("button", {
|
|
189
|
-
onClick: () => Q(t.id),
|
|
190
|
-
className: `inline-flex shrink-0 items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm font-medium transition-colors ${t.isSubscribed ? "border-primary/30 text-primary hover:bg-primary/5" : "border-border text-muted-foreground hover:bg-muted/50 hover:text-foreground"}`,
|
|
191
|
-
children: t.isSubscribed ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(d, { className: "h-3.5 w-3.5" }), " Subscribed"] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(f, { className: "h-3.5 w-3.5" }), " Subscribe"] })
|
|
192
|
-
})]
|
|
193
|
-
})
|
|
194
|
-
}, t.id))
|
|
195
|
-
}),
|
|
196
|
-
/* @__PURE__ */ C(a, {
|
|
197
|
-
open: F,
|
|
198
|
-
onClose: () => I(!1),
|
|
199
|
-
title: "Alert Settings",
|
|
200
|
-
description: "Configure how and when you receive weather alerts for your farm.",
|
|
201
|
-
size: "lg",
|
|
202
|
-
footer: /* @__PURE__ */ w("div", {
|
|
203
|
-
className: "flex justify-end gap-3",
|
|
204
|
-
children: [/* @__PURE__ */ C("button", {
|
|
205
|
-
onClick: () => I(!1),
|
|
206
|
-
className: "rounded-md border border-border px-4 py-2 text-sm text-foreground hover:bg-muted/50",
|
|
207
|
-
children: "Cancel"
|
|
208
|
-
}), /* @__PURE__ */ C("button", {
|
|
209
|
-
onClick: () => I(!1),
|
|
210
|
-
className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",
|
|
211
|
-
children: "Save Settings"
|
|
212
|
-
})]
|
|
213
|
-
}),
|
|
214
|
-
children: /* @__PURE__ */ w("div", {
|
|
215
|
-
className: "space-y-6",
|
|
216
|
-
children: [
|
|
217
|
-
/* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("h4", {
|
|
218
|
-
className: "text-sm font-semibold text-foreground",
|
|
219
|
-
children: "Notification Methods"
|
|
220
|
-
}), /* @__PURE__ */ w("div", {
|
|
221
|
-
className: "mt-3 space-y-3",
|
|
222
|
-
children: [
|
|
223
|
-
/* @__PURE__ */ w("div", {
|
|
224
|
-
className: "flex items-center justify-between rounded-lg border border-border p-4",
|
|
225
|
-
children: [/* @__PURE__ */ w("div", {
|
|
226
|
-
className: "flex items-center gap-3",
|
|
227
|
-
children: [/* @__PURE__ */ C(g, { className: "h-5 w-5 text-sky-600" }), /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
|
|
228
|
-
className: "text-sm font-medium text-foreground",
|
|
229
|
-
children: "Email Notifications"
|
|
230
|
-
}), /* @__PURE__ */ C("p", {
|
|
231
|
-
className: "text-xs text-muted-foreground",
|
|
232
|
-
children: "Receive alerts via email"
|
|
233
|
-
})] })]
|
|
234
|
-
}), /* @__PURE__ */ C("input", {
|
|
235
|
-
type: "checkbox",
|
|
236
|
-
checked: L,
|
|
237
|
-
onChange: (e) => R(e.target.checked),
|
|
238
|
-
className: "h-4 w-4 rounded border-border"
|
|
239
|
-
})]
|
|
240
|
-
}),
|
|
241
|
-
/* @__PURE__ */ w("div", {
|
|
242
|
-
className: "flex items-center justify-between rounded-lg border border-border p-4",
|
|
243
|
-
children: [/* @__PURE__ */ w("div", {
|
|
244
|
-
className: "flex items-center gap-3",
|
|
245
|
-
children: [/* @__PURE__ */ C(v, { className: "h-5 w-5 text-emerald-600" }), /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
|
|
246
|
-
className: "text-sm font-medium text-foreground",
|
|
247
|
-
children: "SMS Notifications"
|
|
248
|
-
}), /* @__PURE__ */ C("p", {
|
|
249
|
-
className: "text-xs text-muted-foreground",
|
|
250
|
-
children: "Receive alerts via SMS"
|
|
251
|
-
})] })]
|
|
252
|
-
}), /* @__PURE__ */ C("input", {
|
|
253
|
-
type: "checkbox",
|
|
254
|
-
checked: z,
|
|
255
|
-
onChange: (e) => B(e.target.checked),
|
|
256
|
-
className: "h-4 w-4 rounded border-border"
|
|
257
|
-
})]
|
|
258
|
-
}),
|
|
259
|
-
/* @__PURE__ */ w("div", {
|
|
260
|
-
className: "flex items-center justify-between rounded-lg border border-border p-4",
|
|
261
|
-
children: [/* @__PURE__ */ w("div", {
|
|
262
|
-
className: "flex items-center gap-3",
|
|
263
|
-
children: [/* @__PURE__ */ C(b, { className: "h-5 w-5 text-purple-600" }), /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
|
|
264
|
-
className: "text-sm font-medium text-foreground",
|
|
265
|
-
children: "Push Notifications"
|
|
266
|
-
}), /* @__PURE__ */ C("p", {
|
|
267
|
-
className: "text-xs text-muted-foreground",
|
|
268
|
-
children: "Receive alerts on your device"
|
|
269
|
-
})] })]
|
|
270
|
-
}), /* @__PURE__ */ C("input", {
|
|
271
|
-
type: "checkbox",
|
|
272
|
-
checked: V,
|
|
273
|
-
onChange: (e) => H(e.target.checked),
|
|
274
|
-
className: "h-4 w-4 rounded border-border"
|
|
275
|
-
})]
|
|
276
|
-
})
|
|
277
|
-
]
|
|
278
|
-
})] }),
|
|
279
|
-
/* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("h4", {
|
|
280
|
-
className: "text-sm font-semibold text-foreground",
|
|
281
|
-
children: "Alert Types"
|
|
282
|
-
}), /* @__PURE__ */ C("div", {
|
|
283
|
-
className: "mt-3 grid grid-cols-1 gap-3 md:grid-cols-2",
|
|
81
|
+
children: k.map((t) => /* @__PURE__ */ m("div", {
|
|
82
|
+
className: `rounded-lg border border-border border-l-4 bg-card p-5 ${_(t.severity)}`,
|
|
83
|
+
children: /* @__PURE__ */ h("div", {
|
|
84
|
+
className: "flex items-start gap-3",
|
|
85
|
+
children: [/* @__PURE__ */ m(l, { className: "mt-0.5 h-5 w-5 shrink-0 text-amber-500" }), /* @__PURE__ */ h("div", {
|
|
86
|
+
className: "flex-1 space-y-2",
|
|
284
87
|
children: [
|
|
285
|
-
{
|
|
286
|
-
|
|
287
|
-
label: "Severe Alerts",
|
|
288
|
-
desc: "Critical weather events"
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
key: "warning",
|
|
292
|
-
label: "Warning Alerts",
|
|
293
|
-
desc: "Important weather conditions"
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
key: "advisory",
|
|
297
|
-
label: "Advisory Alerts",
|
|
298
|
-
desc: "Helpful weather information"
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
key: "info",
|
|
302
|
-
label: "Info Alerts",
|
|
303
|
-
desc: "General information"
|
|
304
|
-
}
|
|
305
|
-
].map(({ key: e, label: t, desc: n }) => /* @__PURE__ */ w("div", {
|
|
306
|
-
className: "flex items-center justify-between rounded-lg border border-border p-4",
|
|
307
|
-
children: [/* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
|
|
308
|
-
className: "text-sm font-medium text-foreground",
|
|
309
|
-
children: t
|
|
310
|
-
}), /* @__PURE__ */ C("p", {
|
|
311
|
-
className: "text-xs text-muted-foreground",
|
|
312
|
-
children: n
|
|
313
|
-
})] }), /* @__PURE__ */ C("input", {
|
|
314
|
-
type: "checkbox",
|
|
315
|
-
checked: U[e],
|
|
316
|
-
onChange: (t) => W((n) => ({
|
|
317
|
-
...n,
|
|
318
|
-
[e]: t.target.checked
|
|
319
|
-
})),
|
|
320
|
-
className: "h-4 w-4 rounded border-border"
|
|
321
|
-
})]
|
|
322
|
-
}, e))
|
|
323
|
-
})] }),
|
|
324
|
-
/* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("h4", {
|
|
325
|
-
className: "text-sm font-semibold text-foreground",
|
|
326
|
-
children: "Timing Preferences"
|
|
327
|
-
}), /* @__PURE__ */ w("div", {
|
|
328
|
-
className: "mt-3 rounded-lg border border-border p-4",
|
|
329
|
-
children: [
|
|
330
|
-
/* @__PURE__ */ C("label", {
|
|
331
|
-
className: "text-sm font-medium text-foreground",
|
|
332
|
-
children: "Advance Notice"
|
|
333
|
-
}),
|
|
334
|
-
/* @__PURE__ */ C("p", {
|
|
335
|
-
className: "mb-3 text-xs text-muted-foreground",
|
|
336
|
-
children: "How many hours ahead should we notify you?"
|
|
337
|
-
}),
|
|
338
|
-
/* @__PURE__ */ w("div", {
|
|
339
|
-
className: "flex items-center gap-3",
|
|
88
|
+
/* @__PURE__ */ h("div", {
|
|
89
|
+
className: "flex flex-wrap items-center gap-2",
|
|
340
90
|
children: [
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
className: "w-20 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
91
|
+
/* @__PURE__ */ m("h3", {
|
|
92
|
+
className: "text-sm font-semibold text-foreground",
|
|
93
|
+
children: t.title
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ m(r, {
|
|
96
|
+
label: t.severity,
|
|
97
|
+
variant: g(t.severity)
|
|
349
98
|
}),
|
|
350
|
-
/* @__PURE__ */
|
|
351
|
-
|
|
352
|
-
|
|
99
|
+
/* @__PURE__ */ m(r, {
|
|
100
|
+
label: `${(t.impactLevel ?? "").toUpperCase()} IMPACT`,
|
|
101
|
+
variant: v(t.impactLevel)
|
|
353
102
|
})
|
|
354
103
|
]
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ m("p", {
|
|
106
|
+
className: "text-sm text-muted-foreground",
|
|
107
|
+
children: t.description
|
|
108
|
+
}),
|
|
109
|
+
/* @__PURE__ */ h("div", {
|
|
110
|
+
className: "flex flex-wrap gap-4 text-xs text-muted-foreground",
|
|
111
|
+
children: [/* @__PURE__ */ h("span", {
|
|
112
|
+
className: "flex items-center gap-1",
|
|
113
|
+
children: [/* @__PURE__ */ m(f, { className: "h-3.5 w-3.5" }), (t.affectedAreas ?? []).join(", ")]
|
|
114
|
+
}), /* @__PURE__ */ h("span", {
|
|
115
|
+
className: "flex items-center gap-1",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ m(u, { className: "h-3.5 w-3.5" }),
|
|
118
|
+
e(t.startTime),
|
|
119
|
+
" - ",
|
|
120
|
+
e(t.endTime)
|
|
121
|
+
]
|
|
122
|
+
})]
|
|
355
123
|
})
|
|
356
124
|
]
|
|
357
|
-
})]
|
|
358
|
-
|
|
359
|
-
})
|
|
125
|
+
})]
|
|
126
|
+
})
|
|
127
|
+
}, t.id))
|
|
360
128
|
}),
|
|
361
|
-
/* @__PURE__ */
|
|
362
|
-
onClick: () =>
|
|
129
|
+
/* @__PURE__ */ m("div", { children: /* @__PURE__ */ m("button", {
|
|
130
|
+
onClick: () => b(".."),
|
|
363
131
|
className: "inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",
|
|
364
132
|
children: "← Back to Weather Dashboard"
|
|
365
133
|
}) })
|
|
@@ -367,6 +135,6 @@ var E = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
|
|
|
367
135
|
});
|
|
368
136
|
};
|
|
369
137
|
//#endregion
|
|
370
|
-
export {
|
|
138
|
+
export { y as WeatherAlertsPage };
|
|
371
139
|
|
|
372
140
|
//# sourceMappingURL=WeatherAlertsPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WeatherAlertsPage.js","names":[],"sources":["../../../../src/healthybowl/pages/weather/WeatherAlertsPage.tsx"],"sourcesContent":["import { useEffect, useState, type FC } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport {\n AlertTriangle,\n Bell,\n BellOff,\n Cloud,\n AlertCircle,\n MapPin,\n Calendar,\n Settings,\n Mail,\n MessageSquare,\n Smartphone,\n Clock,\n} from 'lucide-react';\nimport { PageLayout, StatCard, StatusBadge, EmptyState, Modal } from '../../components';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { formatDate } from '../../utils/helpers';\nimport { getProfileScopedKey } from '@burdenoff/fe-libs/shared/utils';\nimport type { WeatherAlert } from '../../types';\n\ninterface AlertWithMeta extends WeatherAlert {\n isSubscribed: boolean;\n impactLevel: 'high' | 'medium' | 'low';\n}\n\nconst severityVariant = (s: string) =>\n s === 'extreme' || s === 'severe' ? ('error' as const) : s === 'moderate' ? ('warning' as const) : ('info' as const);\n\nconst severityBorder = (s: string) => {\n switch (s) {\n case 'extreme':\n return 'border-l-red-600';\n case 'severe':\n return 'border-l-red-500';\n case 'moderate':\n return 'border-l-amber-500';\n case 'minor':\n return 'border-l-sky-500';\n default:\n return 'border-l-border';\n }\n};\n\nconst impactLabel = (level: string) => {\n switch (level) {\n case 'high':\n return 'error' as const;\n case 'medium':\n return 'warning' as const;\n case 'low':\n return 'success' as const;\n default:\n return 'muted' as const;\n }\n};\n\nconst WEATHER_PREFS_KEY = 'weather-alert-prefs';\n\nexport const WeatherAlertsPage: FC = () => {\n const { weatherData } = useHealthyBowlData();\n\n const navigate = useNavigate();\n const [alerts, setAlerts] = useState<AlertWithMeta[]>([]);\n const [filter, setFilter] = useState<'all' | 'active' | 'subscribed'>('all');\n const [showSettings, setShowSettings] = useState(false);\n\n // Notification settings state — initialize from localStorage\n const [emailNotif, setEmailNotif] = useState(() => {\n try {\n const stored = localStorage.getItem(getProfileScopedKey(WEATHER_PREFS_KEY));\n if (stored) {\n const parsed = JSON.parse(stored) as Record<string, boolean>;\n return parsed.emailNotif ?? true;\n }\n } catch {\n /* SSR safety */\n }\n return true;\n });\n const [smsNotif, setSmsNotif] = useState(() => {\n try {\n const stored = localStorage.getItem(getProfileScopedKey(WEATHER_PREFS_KEY));\n if (stored) {\n const parsed = JSON.parse(stored) as Record<string, boolean>;\n return parsed.smsNotif ?? false;\n }\n } catch {\n /* SSR safety */\n }\n return false;\n });\n const [pushNotif, setPushNotif] = useState(() => {\n try {\n const stored = localStorage.getItem(getProfileScopedKey(WEATHER_PREFS_KEY));\n if (stored) {\n const parsed = JSON.parse(stored) as Record<string, boolean>;\n return parsed.pushNotif ?? true;\n }\n } catch {\n /* SSR safety */\n }\n return true;\n });\n const [alertTypes, setAlertTypes] = useState({\n severe: true,\n warning: true,\n advisory: true,\n info: false,\n });\n const [advanceHours, setAdvanceHours] = useState(2);\n\n // Persist notification preferences to localStorage\n useEffect(() => {\n try {\n localStorage.setItem(getProfileScopedKey(WEATHER_PREFS_KEY), JSON.stringify({ emailNotif, smsNotif, pushNotif }));\n } catch {\n /* SSR safety */\n }\n }, [emailNotif, smsNotif, pushNotif]);\n\n useEffect(() => {\n setAlerts(\n (weatherData?.alerts ?? []).map((alert) => ({\n ...alert,\n isSubscribed: alert.severity === 'extreme' || alert.severity === 'severe',\n impactLevel:\n alert.severity === 'extreme' || alert.severity === 'severe'\n ? 'high'\n : alert.severity === 'moderate'\n ? 'medium'\n : 'low',\n }))\n );\n }, [weatherData?.alerts]);\n\n const now = new Date();\n const activeCount = alerts.filter((a) => new Date(a.endTime) > now).length;\n const subscribedCount = alerts.filter((a) => a.isSubscribed).length;\n const highImpactCount = alerts.filter((a) => a.impactLevel === 'high').length;\n const totalCount = alerts.length;\n\n const toggleSubscription = (alertId: string) => {\n setAlerts((prev) => prev.map((a) => (a.id === alertId ? { ...a, isSubscribed: !a.isSubscribed } : a)));\n };\n\n const filteredAlerts = alerts.filter((alert) => {\n if (filter === 'subscribed') return alert.isSubscribed;\n if (filter === 'active') return new Date(alert.endTime) > now;\n return true;\n });\n\n return (\n <PageLayout\n title=\"Weather Alerts\"\n description=\"Stay informed about weather conditions affecting your crops\"\n actions={\n <button\n onClick={() => setShowSettings(true)}\n className=\"inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90\"\n >\n <Settings className=\"h-4 w-4\" /> Alert Settings\n </button>\n }\n >\n {/* Stats */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard label=\"Active Alerts\" value={activeCount} icon={<AlertTriangle className=\"h-4 w-4\" />} />\n <StatCard label=\"Subscribed\" value={subscribedCount} icon={<Bell className=\"h-4 w-4\" />} />\n <StatCard label=\"High Impact\" value={highImpactCount} icon={<AlertCircle className=\"h-4 w-4\" />} />\n <StatCard label=\"All Alerts\" value={totalCount} icon={<Cloud className=\"h-4 w-4\" />} />\n </div>\n\n {/* Filter Tabs */}\n <div className=\"flex gap-1 border-b border-border\">\n {(\n [\n { key: 'all', label: `All Alerts (${totalCount})` },\n { key: 'active', label: `Active Now (${activeCount})` },\n { key: 'subscribed', label: `Subscribed (${subscribedCount})` },\n ] as const\n ).map(({ key, label }) => (\n <button\n key={key}\n onClick={() => setFilter(key)}\n className={`border-b-2 px-3 pb-2 text-sm font-medium transition-colors ${\n filter === key\n ? 'border-primary text-primary'\n : 'border-transparent text-muted-foreground hover:text-foreground'\n }`}\n >\n {label}\n </button>\n ))}\n </div>\n\n {/* Alert Cards */}\n {filteredAlerts.length === 0 ? (\n <EmptyState\n icon={<Cloud className=\"h-12 w-12\" />}\n title=\"No Alerts\"\n description={\n filter === 'subscribed'\n ? 'Subscribe to alerts to see them here'\n : 'No weather alerts matching the selected filter.'\n }\n />\n ) : (\n <div className=\"space-y-4\">\n {filteredAlerts.map((alert) => (\n <div\n key={alert.id}\n className={`rounded-lg border border-border border-l-4 bg-card p-5 ${severityBorder(alert.severity)}`}\n >\n <div className=\"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between\">\n <div className=\"flex items-start gap-3\">\n <AlertTriangle className=\"mt-0.5 h-5 w-5 shrink-0 text-amber-500\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-semibold text-foreground\">{alert.title}</h3>\n <StatusBadge label={alert.severity} variant={severityVariant(alert.severity)} />\n <StatusBadge\n label={`${(alert.impactLevel ?? '').toUpperCase()} IMPACT`}\n variant={impactLabel(alert.impactLevel)}\n />\n </div>\n <p className=\"text-sm text-muted-foreground\">{alert.description}</p>\n <div className=\"flex flex-wrap gap-4 text-xs text-muted-foreground\">\n <span className=\"flex items-center gap-1\">\n <MapPin className=\"h-3.5 w-3.5\" />\n {(alert.affectedAreas ?? []).join(', ')}\n </span>\n <span className=\"flex items-center gap-1\">\n <Calendar className=\"h-3.5 w-3.5\" />\n {formatDate(alert.startTime)} - {formatDate(alert.endTime)}\n </span>\n </div>\n </div>\n </div>\n\n <button\n onClick={() => toggleSubscription(alert.id)}\n className={`inline-flex shrink-0 items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm font-medium transition-colors ${\n alert.isSubscribed\n ? 'border-primary/30 text-primary hover:bg-primary/5'\n : 'border-border text-muted-foreground hover:bg-muted/50 hover:text-foreground'\n }`}\n >\n {alert.isSubscribed ? (\n <>\n <Bell className=\"h-3.5 w-3.5\" /> Subscribed\n </>\n ) : (\n <>\n <BellOff className=\"h-3.5 w-3.5\" /> Subscribe\n </>\n )}\n </button>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Notification Settings Modal */}\n <Modal\n open={showSettings}\n onClose={() => setShowSettings(false)}\n title=\"Alert Settings\"\n description=\"Configure how and when you receive weather alerts for your farm.\"\n size=\"lg\"\n footer={\n <div className=\"flex justify-end gap-3\">\n <button\n onClick={() => setShowSettings(false)}\n className=\"rounded-md border border-border px-4 py-2 text-sm text-foreground hover:bg-muted/50\"\n >\n Cancel\n </button>\n <button\n onClick={() => setShowSettings(false)}\n className=\"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90\"\n >\n Save Settings\n </button>\n </div>\n }\n >\n <div className=\"space-y-6\">\n {/* Notification Methods */}\n <div>\n <h4 className=\"text-sm font-semibold text-foreground\">Notification Methods</h4>\n <div className=\"mt-3 space-y-3\">\n {/* Email */}\n <div className=\"flex items-center justify-between rounded-lg border border-border p-4\">\n <div className=\"flex items-center gap-3\">\n <Mail className=\"h-5 w-5 text-sky-600\" />\n <div>\n <p className=\"text-sm font-medium text-foreground\">Email Notifications</p>\n <p className=\"text-xs text-muted-foreground\">Receive alerts via email</p>\n </div>\n </div>\n <input\n type=\"checkbox\"\n checked={emailNotif}\n onChange={(e) => setEmailNotif(e.target.checked)}\n className=\"h-4 w-4 rounded border-border\"\n />\n </div>\n {/* SMS */}\n <div className=\"flex items-center justify-between rounded-lg border border-border p-4\">\n <div className=\"flex items-center gap-3\">\n <MessageSquare className=\"h-5 w-5 text-emerald-600\" />\n <div>\n <p className=\"text-sm font-medium text-foreground\">SMS Notifications</p>\n <p className=\"text-xs text-muted-foreground\">Receive alerts via SMS</p>\n </div>\n </div>\n <input\n type=\"checkbox\"\n checked={smsNotif}\n onChange={(e) => setSmsNotif(e.target.checked)}\n className=\"h-4 w-4 rounded border-border\"\n />\n </div>\n {/* Push */}\n <div className=\"flex items-center justify-between rounded-lg border border-border p-4\">\n <div className=\"flex items-center gap-3\">\n <Smartphone className=\"h-5 w-5 text-purple-600\" />\n <div>\n <p className=\"text-sm font-medium text-foreground\">Push Notifications</p>\n <p className=\"text-xs text-muted-foreground\">Receive alerts on your device</p>\n </div>\n </div>\n <input\n type=\"checkbox\"\n checked={pushNotif}\n onChange={(e) => setPushNotif(e.target.checked)}\n className=\"h-4 w-4 rounded border-border\"\n />\n </div>\n </div>\n </div>\n\n {/* Alert Types */}\n <div>\n <h4 className=\"text-sm font-semibold text-foreground\">Alert Types</h4>\n <div className=\"mt-3 grid grid-cols-1 gap-3 md:grid-cols-2\">\n {[\n { key: 'severe' as const, label: 'Severe Alerts', desc: 'Critical weather events' },\n { key: 'warning' as const, label: 'Warning Alerts', desc: 'Important weather conditions' },\n { key: 'advisory' as const, label: 'Advisory Alerts', desc: 'Helpful weather information' },\n { key: 'info' as const, label: 'Info Alerts', desc: 'General information' },\n ].map(({ key, label, desc }) => (\n <div key={key} className=\"flex items-center justify-between rounded-lg border border-border p-4\">\n <div>\n <p className=\"text-sm font-medium text-foreground\">{label}</p>\n <p className=\"text-xs text-muted-foreground\">{desc}</p>\n </div>\n <input\n type=\"checkbox\"\n checked={alertTypes[key]}\n onChange={(e) => setAlertTypes((prev) => ({ ...prev, [key]: e.target.checked }))}\n className=\"h-4 w-4 rounded border-border\"\n />\n </div>\n ))}\n </div>\n </div>\n\n {/* Timing Preferences */}\n <div>\n <h4 className=\"text-sm font-semibold text-foreground\">Timing Preferences</h4>\n <div className=\"mt-3 rounded-lg border border-border p-4\">\n <label className=\"text-sm font-medium text-foreground\">Advance Notice</label>\n <p className=\"mb-3 text-xs text-muted-foreground\">How many hours ahead should we notify you?</p>\n <div className=\"flex items-center gap-3\">\n <Clock className=\"h-4 w-4 text-muted-foreground\" />\n <input\n type=\"number\"\n min={0}\n max={48}\n value={advanceHours}\n onChange={(e) => setAdvanceHours(parseInt(e.target.value) || 0)}\n className=\"w-20 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring\"\n />\n <span className=\"text-sm text-muted-foreground\">hours</span>\n </div>\n </div>\n </div>\n </div>\n </Modal>\n\n {/* Back nav */}\n <div>\n <button\n onClick={() => navigate('..')}\n className=\"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground\"\n >\n ← Back to Weather Dashboard\n </button>\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;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,CAAA;MACF;;IACA,CAAA;GAGR,kBAAC,OAAD,EAAA,UACE,kBAAC,UAAD;IACE,eAAe,EAAS,KAAK;IAC7B,WAAU;cACX;IAEQ,CAAA,EACL,CAAA;GACK"}
|
|
1
|
+
{"version":3,"file":"WeatherAlertsPage.js","names":[],"sources":["../../../../src/healthybowl/pages/weather/WeatherAlertsPage.tsx"],"sourcesContent":["import { useEffect, useState, type FC } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { AlertTriangle, Cloud, AlertCircle, MapPin, Calendar } from 'lucide-react';\nimport { PageLayout, StatCard, StatusBadge, EmptyState } from '../../components';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { formatDate } from '../../utils/helpers';\nimport type { WeatherAlert } from '../../types';\n\ninterface AlertWithMeta extends WeatherAlert {\n impactLevel: 'high' | 'medium' | 'low';\n}\n\nconst severityVariant = (s: string) =>\n s === 'extreme' || s === 'severe' ? ('error' as const) : s === 'moderate' ? ('warning' as const) : ('info' as const);\n\nconst severityBorder = (s: string) => {\n switch (s) {\n case 'extreme':\n return 'border-l-red-600';\n case 'severe':\n return 'border-l-red-500';\n case 'moderate':\n return 'border-l-amber-500';\n case 'minor':\n return 'border-l-sky-500';\n default:\n return 'border-l-border';\n }\n};\n\nconst impactLabel = (level: string) => {\n switch (level) {\n case 'high':\n return 'error' as const;\n case 'medium':\n return 'warning' as const;\n case 'low':\n return 'success' as const;\n default:\n return 'muted' as const;\n }\n};\n\n// NOTE: per-alert subscriptions + delivery settings (email/SMS/push) are intentionally\n// NOT here — alert delivery requires the notification/channel platform modules, which are\n// deferred. This page is an honest read-only view of the real weather alerts; the\n// subscription/delivery UI is added when those modules are wired (no faking it meanwhile).\nexport const WeatherAlertsPage: FC = () => {\n const { weatherData } = useHealthyBowlData();\n\n const navigate = useNavigate();\n const [alerts, setAlerts] = useState<AlertWithMeta[]>([]);\n const [filter, setFilter] = useState<'all' | 'active'>('all');\n\n useEffect(() => {\n setAlerts(\n (weatherData?.alerts ?? []).map((alert) => ({\n ...alert,\n impactLevel:\n alert.severity === 'extreme' || alert.severity === 'severe'\n ? 'high'\n : alert.severity === 'moderate'\n ? 'medium'\n : 'low',\n }))\n );\n }, [weatherData?.alerts]);\n\n const now = new Date();\n const activeCount = alerts.filter((a) => new Date(a.endTime) > now).length;\n const highImpactCount = alerts.filter((a) => a.impactLevel === 'high').length;\n const totalCount = alerts.length;\n\n const filteredAlerts = alerts.filter((alert) => (filter === 'active' ? new Date(alert.endTime) > now : true));\n\n return (\n <PageLayout title=\"Weather Alerts\" description=\"Stay informed about weather conditions affecting your crops\">\n {/* Stats */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <StatCard label=\"Active Alerts\" value={activeCount} icon={<AlertTriangle className=\"h-4 w-4\" />} />\n <StatCard label=\"High Impact\" value={highImpactCount} icon={<AlertCircle className=\"h-4 w-4\" />} />\n <StatCard label=\"All Alerts\" value={totalCount} icon={<Cloud className=\"h-4 w-4\" />} />\n </div>\n\n {/* Filter Tabs */}\n <div className=\"flex gap-1 border-b border-border\">\n {(\n [\n { key: 'all', label: `All Alerts (${totalCount})` },\n { key: 'active', label: `Active Now (${activeCount})` },\n ] as const\n ).map(({ key, label }) => (\n <button\n key={key}\n onClick={() => setFilter(key)}\n className={`border-b-2 px-3 pb-2 text-sm font-medium transition-colors ${\n filter === key\n ? 'border-primary text-primary'\n : 'border-transparent text-muted-foreground hover:text-foreground'\n }`}\n >\n {label}\n </button>\n ))}\n </div>\n\n {/* Alert Cards */}\n {filteredAlerts.length === 0 ? (\n <EmptyState\n icon={<Cloud className=\"h-12 w-12\" />}\n title=\"No Alerts\"\n description=\"No weather alerts matching the selected filter.\"\n />\n ) : (\n <div className=\"space-y-4\">\n {filteredAlerts.map((alert) => (\n <div\n key={alert.id}\n className={`rounded-lg border border-border border-l-4 bg-card p-5 ${severityBorder(alert.severity)}`}\n >\n <div className=\"flex items-start gap-3\">\n <AlertTriangle className=\"mt-0.5 h-5 w-5 shrink-0 text-amber-500\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-semibold text-foreground\">{alert.title}</h3>\n <StatusBadge label={alert.severity} variant={severityVariant(alert.severity)} />\n <StatusBadge\n label={`${(alert.impactLevel ?? '').toUpperCase()} IMPACT`}\n variant={impactLabel(alert.impactLevel)}\n />\n </div>\n <p className=\"text-sm text-muted-foreground\">{alert.description}</p>\n <div className=\"flex flex-wrap gap-4 text-xs text-muted-foreground\">\n <span className=\"flex items-center gap-1\">\n <MapPin className=\"h-3.5 w-3.5\" />\n {(alert.affectedAreas ?? []).join(', ')}\n </span>\n <span className=\"flex items-center gap-1\">\n <Calendar className=\"h-3.5 w-3.5\" />\n {formatDate(alert.startTime)} - {formatDate(alert.endTime)}\n </span>\n </div>\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Back nav */}\n <div>\n <button\n onClick={() => navigate('..')}\n className=\"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground\"\n >\n ← Back to Weather Dashboard\n </button>\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,KAAmB,MACvB,MAAM,aAAa,MAAM,WAAY,UAAoB,MAAM,aAAc,YAAuB,QAEhG,KAAkB,MAAc;AACpC,SAAQ,GAAR;EACE,KAAK,UACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,QACE,QAAO;;GAIP,KAAe,MAAkB;AACrC,SAAQ,GAAR;EACE,KAAK,OACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,QACE,QAAO;;GAQA,UAA8B;CACzC,IAAM,EAAE,mBAAgB,GAAoB,EAEtC,IAAW,GAAa,EACxB,CAAC,GAAQ,KAAa,EAA0B,EAAE,CAAC,EACnD,CAAC,GAAQ,KAAa,EAA2B,MAAM;AAE7D,SAAgB;AACd,K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