@burdenoff/microfe-healthybowl 2026.714.6 → 2026.714.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WeatherAlertHistoryPage.js","names":[],"sources":["../../../../src/healthybowl/pages/weather/WeatherAlertHistoryPage.tsx"],"sourcesContent":["/**\n * Weather Alert History — timeline feed of fired weather early-warnings\n * (roadmap #20 · BOFF-2892, Historical Weather & Early Warning).\n *\n * An honest, read-side feed of every weather alert that has fired for this farm:\n * frost / storm / heat / disease warnings raised when a rule crossed its\n * threshold. Each row shows the severity band (RED / AMBER / GREY), the alert\n * type, the advisory, the delivery channels + when it was sent, and its\n * lifecycle status (delivered / handled / snoozed). Farmers can mark an alert as\n * handled or snooze it for a day. Everything is live from the weather-intelligence\n * GraphQL API via {@link useWeatherIntelligence} — no fabricated events; a farm\n * whose rules have never fired shows an honest empty state.\n * @module healthybowl\n */\nimport { useCallback, useState, type FC } from 'react';\nimport { Snowflake, CloudRain, Sun, Bug, Cloud, AlertTriangle, Check, Clock, Send, BellRing } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, StatusBadge, EmptyState, ErrorState, PageLoader } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useWeatherIntelligence, type WeatherAlertEvent } from '../../hooks/useWeatherIntelligence';\nimport { getRelativeTime } from '../../utils/helpers';\n\n// ── Filter tabs ────────────────────────────────────────────────────────────────\nconst FILTERS = ['ALL', 'FROST', 'STORM', 'HEAT'] as const;\ntype Filter = (typeof FILTERS)[number];\n\n// ── Severity tile styling (data-viz/severity palette exception) ──────────────────\nconst severityTileClass = (severity: string): string => {\n switch (severity) {\n case 'RED':\n return 'bg-red-600 text-white';\n case 'AMBER':\n return 'bg-amber-500 text-white';\n case 'GREY':\n default:\n return 'bg-slate-500 text-white';\n }\n};\n\nconst alertTypeIcon = (alertType: string, className: string) => {\n switch (alertType) {\n case 'FROST':\n return <Snowflake className={className} />;\n case 'STORM':\n return <CloudRain className={className} />;\n case 'HEAT':\n return <Sun className={className} />;\n case 'DISEASE':\n return <Bug className={className} />;\n default:\n return <Cloud className={className} />;\n }\n};\n\n// Humanise a delivery-channel key (e.g. \"in_app\" → \"In-app\", \"sms\" → \"SMS\").\nconst channelLabel = (channel: string): string => {\n const key = channel.toLowerCase();\n if (key === 'in_app' || key === 'inapp' || key === 'in-app') return 'In-app';\n if (key === 'sms') return 'SMS';\n if (key === 'email') return 'Email';\n if (key === 'webhook') return 'Webhook';\n if (key === 'push') return 'Push';\n return channel.charAt(0).toUpperCase() + channel.slice(1);\n};\n\nexport const WeatherAlertHistoryPage: FC = () => {\n const { t } = useI18n();\n const { toasts, toast, dismiss } = useToast();\n const { alertEvents, loadingEvents, errorEvents, refetchEvents, loadEvents, markHandled, snooze } =\n useWeatherIntelligence();\n\n const [filter, setFilter] = useState<Filter>('ALL');\n // `null` → show the eager, unfiltered `alertEvents`; otherwise a filtered result set.\n const [filtered, setFiltered] = useState<WeatherAlertEvent[] | null>(null);\n const [switching, setSwitching] = useState(false);\n const [busyId, setBusyId] = useState<string | null>(null);\n\n const events = filter === 'ALL' ? alertEvents : (filtered ?? []);\n\n const selectFilter = useCallback(\n async (next: Filter) => {\n setFilter(next);\n if (next === 'ALL') {\n setFiltered(null);\n return;\n }\n setSwitching(true);\n try {\n const result = await loadEvents({ alertType: next });\n setFiltered(result);\n } catch (err) {\n toast({\n title: t('healthybowl.weather.alertHistory.toast.loadError.title', 'Could not load alerts'),\n description: err instanceof Error ? err.message : undefined,\n variant: 'error',\n });\n setFiltered([]);\n } finally {\n setSwitching(false);\n }\n },\n [loadEvents, t, toast]\n );\n\n // After a mutation, keep the currently-shown list in sync. On the ALL tab the\n // hook's own refetch updates `alertEvents`; on a filtered tab we re-run the\n // filtered query so the row's new status is reflected.\n const reloadFilteredIfNeeded = useCallback(async () => {\n if (filter === 'ALL') return;\n const result = await loadEvents({ alertType: filter });\n setFiltered(result);\n }, [filter, loadEvents]);\n\n const handleMarkHandled = useCallback(\n async (event: WeatherAlertEvent) => {\n setBusyId(event.id);\n try {\n await markHandled(event.id);\n await reloadFilteredIfNeeded();\n toast({\n title: t('healthybowl.weather.alertHistory.toast.handled.title', 'Alert marked as handled'),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.weather.alertHistory.toast.error.title', 'Could not update alert'),\n description: err instanceof Error ? err.message : undefined,\n variant: 'error',\n });\n } finally {\n setBusyId(null);\n }\n },\n [markHandled, reloadFilteredIfNeeded, t, toast]\n );\n\n const handleSnooze = useCallback(\n async (event: WeatherAlertEvent) => {\n const tomorrowISO = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString();\n setBusyId(event.id);\n try {\n await snooze(event.id, tomorrowISO);\n await reloadFilteredIfNeeded();\n toast({\n title: t('healthybowl.weather.alertHistory.toast.snoozed.title', 'Alert snoozed for 1 day'),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.weather.alertHistory.toast.error.title', 'Could not update alert'),\n description: err instanceof Error ? err.message : undefined,\n variant: 'error',\n });\n } finally {\n setBusyId(null);\n }\n },\n [snooze, reloadFilteredIfNeeded, t, toast]\n );\n\n const statusBadge = (status: string) => {\n switch (status) {\n case 'handled':\n return (\n <StatusBadge label={t('healthybowl.weather.alertHistory.status.handled', 'Handled ✓')} variant=\"success\" />\n );\n case 'snoozed':\n return (\n <StatusBadge label={t('healthybowl.weather.alertHistory.status.snoozed', 'Snoozed')} variant=\"warning\" />\n );\n case 'delivered':\n default:\n return (\n <StatusBadge label={t('healthybowl.weather.alertHistory.status.delivered', 'Delivered')} variant=\"muted\" />\n );\n }\n };\n\n const filterLabel = (key: Filter): string => {\n switch (key) {\n case 'ALL':\n return t('healthybowl.weather.alertHistory.filter.all', 'All');\n case 'FROST':\n return t('healthybowl.weather.alertHistory.filter.frost', 'Frost');\n case 'STORM':\n return t('healthybowl.weather.alertHistory.filter.storm', 'Storm');\n case 'HEAT':\n return t('healthybowl.weather.alertHistory.filter.heat', 'Heat');\n default:\n return key;\n }\n };\n\n const isInitialLoading = loadingEvents && alertEvents.length === 0;\n const hasError = errorEvents && alertEvents.length === 0;\n\n return (\n <PageLayout\n title={t('healthybowl.weather.alertHistory.title', 'Alert History')}\n description={t('healthybowl.weather.alertHistory.description', 'Weather early-warnings triggered for this farm')}\n purpose=\"Every weather early-warning that has fired for your farm — frost, storm, heat and disease alerts — in one timeline. See what was sent, through which channels and when, then mark an alert as handled or snooze it for a day once you've acted.\"\n >\n {isInitialLoading ? (\n <PageLoader />\n ) : hasError ? (\n <ErrorState onRetry={() => void refetchEvents()} />\n ) : (\n <div className=\"space-y-6\">\n {/* Filter tabs */}\n <div className=\"flex flex-wrap items-center gap-1 border-b border-border-subtle\">\n {FILTERS.map((key) => {\n const active = filter === key;\n return (\n <button\n key={key}\n type=\"button\"\n onClick={() => void selectFilter(key)}\n className={`border-b-2 px-3 pb-2 text-sm font-medium transition-colors ${\n active\n ? 'border-primary text-primary'\n : 'border-transparent text-text-secondary hover:text-text-primary'\n }`}\n >\n {filterLabel(key)}\n </button>\n );\n })}\n </div>\n\n {switching ? (\n <PageLoader />\n ) : events.length === 0 ? (\n <EmptyState\n icon={<BellRing className=\"h-6 w-6 text-text-secondary\" />}\n title={t('healthybowl.weather.alertHistory.empty.title', 'No weather alerts yet')}\n description={t(\n 'healthybowl.weather.alertHistory.empty.description',\n 'Alerts appear here the moment one of your early-warning rules crosses its threshold — frost tonight, a storm tomorrow or a heat spike. Nothing has fired for this filter yet.'\n )}\n />\n ) : (\n /* Vertical timeline feed */\n <ol className=\"relative space-y-4 sm:pl-6\">\n {/* rail */}\n <span aria-hidden className=\"absolute left-2 top-2 bottom-2 hidden w-px bg-border-subtle sm:block\" />\n {events.map((event) => {\n const isBusy = busyId === event.id;\n const isHandled = event.status === 'handled';\n return (\n <li key={event.id} className=\"relative\">\n {/* rail dot */}\n <span\n aria-hidden\n className=\"absolute -left-[1.375rem] top-6 hidden h-2.5 w-2.5 rounded-full border-2 border-bg-canvas bg-border-subtle sm:block\"\n />\n <div className=\"flex overflow-hidden rounded-xl border border-border-subtle bg-bg-surface\">\n {/* Severity tile */}\n <div\n className={`flex w-20 shrink-0 flex-col items-center justify-center gap-1 py-4 ${severityTileClass(\n event.severity\n )}`}\n >\n {alertTypeIcon(event.alertType, 'h-6 w-6')}\n <span className=\"text-xs font-semibold tracking-wide\">{event.severity}</span>\n </div>\n\n {/* Body */}\n <div className=\"min-w-0 flex-1 p-4\">\n <div className=\"flex flex-wrap items-start justify-between gap-2\">\n <h3 className=\"flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <span className=\"text-text-secondary\">{alertTypeIcon(event.alertType, 'h-4 w-4')}</span>\n {event.title}\n </h3>\n {statusBadge(event.status)}\n </div>\n\n {event.advisory && <p className=\"mt-1 text-sm text-text-secondary\">{event.advisory}</p>}\n\n {/* Metric readout (only when the backend supplied one) */}\n {event.observedValue != null && event.threshold != null && (\n <p className=\"mt-1 flex items-center gap-1 text-xs text-text-secondary\">\n <AlertTriangle className=\"h-3.5 w-3.5 text-warning\" />\n {t(\n 'healthybowl.weather.alertHistory.metric',\n '{{metric}} {{observed}}{{unit}} · threshold {{threshold}}{{unit}}',\n {\n metric: event.metric,\n observed: event.observedValue,\n threshold: event.threshold,\n unit: event.unit ?? '',\n }\n )}\n </p>\n )}\n\n {/* Delivery line */}\n <p className=\"mt-2 flex flex-wrap items-center gap-1 text-xs text-text-secondary\">\n <Send className=\"h-3.5 w-3.5\" />\n {event.channels.length > 0\n ? t('healthybowl.weather.alertHistory.sentVia', 'Sent via {{channels}} · {{when}}', {\n channels: event.channels.map(channelLabel).join(' + '),\n when: getRelativeTime(event.triggeredAt),\n })\n : t('healthybowl.weather.alertHistory.triggered', 'Triggered {{when}}', {\n when: getRelativeTime(event.triggeredAt),\n })}\n {event.status === 'snoozed' && event.snoozedUntil && (\n <span className=\"inline-flex items-center gap-1 text-warning\">\n · <Clock className=\"h-3.5 w-3.5\" />\n {t('healthybowl.weather.alertHistory.snoozedUntil', 'snoozed until {{when}}', {\n when: getRelativeTime(event.snoozedUntil),\n })}\n </span>\n )}\n </p>\n\n {/* Rule attribution */}\n {event.ruleName && (\n <p className=\"mt-1 text-[11px] text-text-secondary\">\n {t('healthybowl.weather.alertHistory.rule', 'Rule: {{name}}', { name: event.ruleName })}\n </p>\n )}\n\n {/* Row actions */}\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n {!isHandled && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void handleMarkHandled(event)}\n disabled={isBusy}\n >\n <Check className=\"h-3.5 w-3.5\" />\n {t('healthybowl.weather.alertHistory.actions.markHandled', 'Mark as handled')}\n </Button>\n )}\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => void handleSnooze(event)}\n disabled={isBusy}\n className=\"text-text-secondary hover:text-text-primary\"\n >\n <Clock className=\"h-3.5 w-3.5\" />\n {t('healthybowl.weather.alertHistory.actions.snooze', 'Snooze 1 day')}\n </Button>\n </div>\n </div>\n </div>\n </li>\n );\n })}\n </ol>\n )}\n\n {/* Background refresh hint */}\n {loadingEvents && alertEvents.length > 0 && filter === 'ALL' && (\n <p className=\"text-center text-[11px] text-text-secondary\">\n {t('healthybowl.weather.alertHistory.refreshing', 'Refreshing…')}\n </p>\n )}\n </div>\n )}\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,IAAM,IAAU;CAAC;CAAO;CAAS;CAAS;CAAO,EAI3C,KAAqB,MAA6B;AACtD,SAAQ,GAAR;EACE,KAAK,MACH,QAAO;EACT,KAAK,QACH,QAAO;EAET,QACE,QAAO;;GAIP,KAAiB,GAAmB,MAAsB;AAC9D,SAAQ,GAAR;EACE,K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AAO,WAAU,eAAgB,CAAA;cAClC,EAAE,iDAAiD,0BAA0B,EAC5E,MAAM,EAAgB,EAAM,aAAa,EAC1C,CAAC;cACG;;YAEP;;UAGH,EAAM,YACL,kBAAC,KAAD;WAAG,WAAU;qBACV,EAAE,yCAAyC,kBAAkB,EAAE,MAAM,EAAM,UAAU,CAAC;WACrF,CAAA;UAIN,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACG,CAAC,KACA,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,KAAK,EAAkB,EAAM;YAC5C,UAAU;sBAJZ,CAME,kBAAC,GAAD,EAAO,WAAU,eAAgB,CAAA,EAChC,EAAE,wDAAwD,kBAAkB,CACtE;eAEX,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,KAAK,EAAa,EAAM;YACvC,UAAU;YACV,WAAU;sBALZ,CAOE,kBAAC,GAAD,EAAO,WAAU,eAAgB,CAAA,EAChC,EAAE,mDAAmD,eAAe,CAC9D;cACL;;UACF;WACF;UACH;SApGI,EAAM,GAoGV;OAEP,CACC;;IAIN,KAAiB,EAAY,SAAS,KAAK,MAAW,SACrD,kBAAC,KAAD;KAAG,WAAU;eACV,EAAE,+CAA+C,cAAc;KAC9D,CAAA;IAEF;MAGR,kBAAC,GAAD;GAAwB;GAAQ,WAAW;GAAW,CAAA,CAC3C"}
@@ -0,0 +1,387 @@
1
+ import { cn as e, formatDate as t } from "../../utils/helpers.js";
2
+ import { PageLayout as n } from "../../components/PageLayout.js";
3
+ import { EmptyState as r } from "../../components/EmptyState.js";
4
+ import { ErrorState as i } from "../../components/ErrorState.js";
5
+ import { ChartCard as a } from "../../components/ChartCard.js";
6
+ import { ToastContainer as o } from "../../components/Toast.js";
7
+ import { PageLoader as s } from "../../components/PageLoader.js";
8
+ import { useToast as c } from "../../hooks/useToast.js";
9
+ import "../../components/index.js";
10
+ import { Legend as l } from "../../../node_modules/recharts/es6/component/Legend.js";
11
+ import { Tooltip as u } from "../../../node_modules/recharts/es6/component/Tooltip.js";
12
+ import { ResponsiveContainer as d } from "../../../node_modules/recharts/es6/component/ResponsiveContainer.js";
13
+ import { Bar as f } from "../../../node_modules/recharts/es6/cartesian/Bar.js";
14
+ import { CartesianGrid as p } from "../../../node_modules/recharts/es6/cartesian/CartesianGrid.js";
15
+ import { Line as m } from "../../../node_modules/recharts/es6/cartesian/Line.js";
16
+ import { Area as h } from "../../../node_modules/recharts/es6/cartesian/Area.js";
17
+ import { XAxis as g } from "../../../node_modules/recharts/es6/cartesian/XAxis.js";
18
+ import { YAxis as _ } from "../../../node_modules/recharts/es6/cartesian/YAxis.js";
19
+ import { ComposedChart as v } from "../../../node_modules/recharts/es6/chart/ComposedChart.js";
20
+ import { useWeatherIntelligence as y } from "../../hooks/useWeatherIntelligence.js";
21
+ import { useMemo as b } from "react";
22
+ import { useI18n as x } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
23
+ import { AlertTriangle as S, ArrowDown as C, ArrowUp as w, CalendarClock as T, CloudRain as E, Minus as D, Printer as O, RefreshCw as k, Snowflake as A, Thermometer as j } from "lucide-react";
24
+ import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
25
+ import { Button as F } from "@burdenoff/fe-libs/ui";
26
+ //#region src/healthybowl/pages/weather/WeatherAnomalyReportPage.tsx
27
+ var I = {
28
+ backgroundColor: "var(--color-card)",
29
+ border: "1px solid var(--color-border)",
30
+ borderRadius: "8px"
31
+ }, L = (e) => e > 0 ? "up" : e < 0 ? "down" : "flat", R = (e, t, n) => e >= n ? "text-red-600" : e >= t ? "text-amber-600" : "text-emerald-600", z = (e) => {
32
+ let t = (e ?? "").toUpperCase();
33
+ return t === "RED" || t === "HIGH" ? {
34
+ label: "High",
35
+ className: "bg-red-100 text-red-700 dark:bg-red-950/40 dark:text-red-300"
36
+ } : t === "AMBER" || t === "MODERATE" || t === "MEDIUM" ? {
37
+ label: "Moderate",
38
+ className: "bg-amber-100 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300"
39
+ } : {
40
+ label: "Low",
41
+ className: "bg-bg-sunken text-text-secondary"
42
+ };
43
+ }, B = ({ icon: t, label: n, headline: r, emphasis: i, detail: a, direction: o, colorClass: s }) => /* @__PURE__ */ P("div", {
44
+ className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
45
+ children: [
46
+ /* @__PURE__ */ P("div", {
47
+ className: "flex items-center justify-between",
48
+ children: [/* @__PURE__ */ N("span", {
49
+ className: "text-sm font-medium text-text-secondary",
50
+ children: n
51
+ }), /* @__PURE__ */ N("span", {
52
+ className: "flex size-8 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary",
53
+ children: /* @__PURE__ */ N(t, { className: "size-4" })
54
+ })]
55
+ }),
56
+ /* @__PURE__ */ P("div", {
57
+ className: e("mt-2 flex items-baseline gap-1.5", s),
58
+ children: [
59
+ o === "up" && /* @__PURE__ */ N(w, { className: "size-5 shrink-0" }),
60
+ o === "down" && /* @__PURE__ */ N(C, { className: "size-5 shrink-0" }),
61
+ o === "flat" && /* @__PURE__ */ N(D, { className: "size-5 shrink-0" }),
62
+ /* @__PURE__ */ N("span", {
63
+ className: "text-3xl font-semibold tabular-nums",
64
+ children: r
65
+ }),
66
+ /* @__PURE__ */ N("span", {
67
+ className: "text-sm font-medium uppercase",
68
+ children: i
69
+ })
70
+ ]
71
+ }),
72
+ /* @__PURE__ */ N("p", {
73
+ className: "mt-1 text-xs text-text-secondary",
74
+ children: a
75
+ })
76
+ ]
77
+ }), V = () => {
78
+ let { t: C } = x(), { toasts: w, toast: D, dismiss: V } = c(), { anomaly: W, loadingAnomaly: G, errorAnomaly: K, refetchAnomaly: q, syncHistory: J } = y(), Y = b(() => (W?.monthlyRainfall ?? []).map((e) => ({
79
+ month: e.monthName,
80
+ current: e.currentValue,
81
+ baselineAvg: e.baselineAvg,
82
+ band: [e.baselineMin, e.baselineMax]
83
+ })), [W?.monthlyRainfall]), X = b(() => (W?.monthlyTemperature ?? []).map((e) => ({
84
+ month: e.monthName,
85
+ current: e.currentValue,
86
+ baselineAvg: e.baselineAvg,
87
+ band: [e.baselineMin, e.baselineMax]
88
+ })), [W?.monthlyTemperature]), Z = async () => {
89
+ try {
90
+ await J(), D({
91
+ title: C("healthybowl.weather.anomaly.toast.synced.title", "History synced"),
92
+ description: C("healthybowl.weather.anomaly.toast.synced.description", "The seasonal anomaly report has been recalculated from the latest archive."),
93
+ variant: "success"
94
+ });
95
+ } catch (e) {
96
+ D({
97
+ title: C("healthybowl.common.error", "Something went wrong"),
98
+ description: e instanceof Error ? e.message : void 0,
99
+ variant: "error"
100
+ });
101
+ }
102
+ }, Q = W ? C("healthybowl.weather.anomaly.subtitle", "This season vs {{years}}-year baseline ({{start}}–{{end}})", {
103
+ years: W.baselineYears,
104
+ start: W.startYear,
105
+ end: W.endYear - 1
106
+ }) : C("healthybowl.weather.anomaly.subtitleFallback", "This season vs the multi-year climate baseline");
107
+ return /* @__PURE__ */ P(n, {
108
+ title: C("healthybowl.weather.anomaly.title", "Seasonal Anomaly Report"),
109
+ description: Q,
110
+ purpose: "How this season is tracking against your farm's own multi-year climate baseline — is it wetter or drier than normal, warmer or cooler, and is frost arriving earlier than usual. Use it to spot when the weather is deviating from what your crops are used to, so you can adjust irrigation, protect against early frost, and understand an unusual yield.",
111
+ actions: /* @__PURE__ */ P(F, {
112
+ variant: "outline",
113
+ size: "sm",
114
+ onClick: () => window.print(),
115
+ className: "text-text-secondary hover:text-text-primary",
116
+ children: [
117
+ /* @__PURE__ */ N(O, { className: "h-4 w-4" }),
118
+ " ",
119
+ C("healthybowl.weather.anomaly.actions.print", "Print")
120
+ ]
121
+ }),
122
+ children: [G && !W ? /* @__PURE__ */ N(s, {}) : K && !W ? /* @__PURE__ */ N(i, { onRetry: q }) : !W || !W.synced ? /* @__PURE__ */ N(r, {
123
+ illustration: "empty-data",
124
+ title: C("healthybowl.weather.anomaly.empty.title", "No baseline yet"),
125
+ description: C("healthybowl.weather.anomaly.empty.description", "Sync your farm-site weather history to build a multi-year climate baseline. Once synced, this report compares the current season against it."),
126
+ action: /* @__PURE__ */ P(F, {
127
+ onClick: Z,
128
+ children: [
129
+ /* @__PURE__ */ N(k, { className: "h-4 w-4" }),
130
+ " ",
131
+ C("healthybowl.weather.anomaly.empty.sync", "Sync history")
132
+ ]
133
+ })
134
+ }) : /* @__PURE__ */ P(M, { children: [
135
+ /* @__PURE__ */ P("div", {
136
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
137
+ children: [
138
+ /* @__PURE__ */ N(B, {
139
+ icon: E,
140
+ label: C("healthybowl.weather.anomaly.stats.rainfall.label", "Rainfall this month"),
141
+ headline: `${Math.abs(Math.round(W.rainfallDeviationPct))}%`,
142
+ emphasis: W.rainfallDeviationPct < 0 ? C("healthybowl.weather.anomaly.stats.rainfall.below", "below normal") : C("healthybowl.weather.anomaly.stats.rainfall.above", "above normal"),
143
+ detail: C("healthybowl.weather.anomaly.stats.rainfall.detail", "{{now}}mm vs {{avg}}mm avg", {
144
+ now: Math.round(W.rainfallThisMonthMm),
145
+ avg: Math.round(W.rainfallBaselineMm)
146
+ }),
147
+ direction: L(W.rainfallDeviationPct),
148
+ colorClass: R(Math.abs(W.rainfallDeviationPct), 15, 30)
149
+ }),
150
+ /* @__PURE__ */ N(B, {
151
+ icon: j,
152
+ label: C("healthybowl.weather.anomaly.stats.temp.label", "Avg temperature"),
153
+ headline: `${W.avgTempDeltaC > 0 ? "+" : ""}${W.avgTempDeltaC.toFixed(1)}°C`,
154
+ emphasis: W.avgTempDeltaC > 0 ? C("healthybowl.weather.anomaly.stats.temp.above", "above") : W.avgTempDeltaC < 0 ? C("healthybowl.weather.anomaly.stats.temp.below", "below") : C("healthybowl.weather.anomaly.stats.temp.normal", "normal"),
155
+ detail: C("healthybowl.weather.anomaly.stats.temp.detail", "vs baseline average"),
156
+ direction: L(W.avgTempDeltaC),
157
+ colorClass: R(Math.abs(W.avgTempDeltaC), 1, 2)
158
+ }),
159
+ /* @__PURE__ */ N(B, {
160
+ icon: A,
161
+ label: C("healthybowl.weather.anomaly.stats.frost.label", "Frost days"),
162
+ headline: `${W.frostDaysDelta > 0 ? "+" : ""}${W.frostDaysDelta}`,
163
+ emphasis: C("healthybowl.weather.anomaly.stats.frost.emphasis", "vs average"),
164
+ detail: C("healthybowl.weather.anomaly.stats.frost.detail", "{{now}} this season vs {{avg}} baseline", {
165
+ now: W.frostDaysThisSeason,
166
+ avg: W.frostDaysBaseline
167
+ }),
168
+ direction: L(W.frostDaysDelta),
169
+ colorClass: R(Math.abs(W.frostDaysDelta), 2, 4)
170
+ }),
171
+ /* @__PURE__ */ N(B, {
172
+ icon: T,
173
+ label: C("healthybowl.weather.anomaly.stats.firstFrost.label", "First-frost date"),
174
+ headline: W.firstFrostDate ? `${Math.abs(W.firstFrostDeltaDays)}` : C("healthybowl.weather.anomaly.stats.firstFrost.none", "—"),
175
+ emphasis: W.firstFrostDate ? W.firstFrostDeltaDays < 0 ? C("healthybowl.weather.anomaly.stats.firstFrost.early", "days early") : W.firstFrostDeltaDays > 0 ? C("healthybowl.weather.anomaly.stats.firstFrost.late", "days late") : C("healthybowl.weather.anomaly.stats.firstFrost.onTime", "on time") : C("healthybowl.weather.anomaly.stats.firstFrost.pending", "not yet"),
176
+ detail: W.firstFrostDate ? C("healthybowl.weather.anomaly.stats.firstFrost.detail", "{{now}} vs {{avg}}", {
177
+ now: t(W.firstFrostDate),
178
+ avg: W.baselineFirstFrostDate ? t(W.baselineFirstFrostDate) : "—"
179
+ }) : C("healthybowl.weather.anomaly.stats.firstFrost.detailPending", "No frost recorded yet this season"),
180
+ direction: W.firstFrostDate ? L(W.firstFrostDeltaDays) : "flat",
181
+ colorClass: W.firstFrostDate ? R(Math.abs(W.firstFrostDeltaDays), 5, 10) : "text-text-secondary"
182
+ })
183
+ ]
184
+ }),
185
+ /* @__PURE__ */ P("div", {
186
+ className: "grid grid-cols-1 gap-4 lg:grid-cols-2",
187
+ children: [/* @__PURE__ */ N(a, {
188
+ title: C("healthybowl.weather.anomaly.charts.rainfall.title", "Monthly rainfall"),
189
+ description: C("healthybowl.weather.anomaly.charts.rainfall.description", "This season (bars) vs the baseline min–max band"),
190
+ children: Y.length === 0 ? /* @__PURE__ */ N(U, { label: C("healthybowl.weather.anomaly.charts.noData", "No monthly data yet") }) : /* @__PURE__ */ N(d, {
191
+ width: "100%",
192
+ height: 280,
193
+ children: /* @__PURE__ */ P(v, {
194
+ data: Y,
195
+ margin: {
196
+ top: 8,
197
+ right: 16,
198
+ left: 0,
199
+ bottom: 4
200
+ },
201
+ children: [
202
+ /* @__PURE__ */ N(p, {
203
+ strokeDasharray: "3 3",
204
+ className: "stroke-border"
205
+ }),
206
+ /* @__PURE__ */ N(g, {
207
+ dataKey: "month",
208
+ className: "text-xs",
209
+ tick: { fill: "currentColor" }
210
+ }),
211
+ /* @__PURE__ */ N(_, {
212
+ className: "text-xs",
213
+ tick: { fill: "currentColor" },
214
+ tickFormatter: (e) => `${e}`
215
+ }),
216
+ /* @__PURE__ */ N(u, {
217
+ contentStyle: I,
218
+ labelStyle: { color: "var(--color-foreground)" },
219
+ formatter: H
220
+ }),
221
+ /* @__PURE__ */ N(l, {}),
222
+ /* @__PURE__ */ N(h, {
223
+ type: "monotone",
224
+ dataKey: "band",
225
+ name: C("healthybowl.weather.anomaly.charts.baselineBand", "Baseline range"),
226
+ stroke: "var(--color-border)",
227
+ strokeDasharray: "6 4",
228
+ fill: "var(--color-muted)",
229
+ fillOpacity: .35,
230
+ connectNulls: !0,
231
+ activeDot: !1
232
+ }),
233
+ /* @__PURE__ */ N(f, {
234
+ dataKey: "current",
235
+ name: C("healthybowl.weather.anomaly.charts.thisSeason", "This season"),
236
+ fill: "var(--color-success)",
237
+ radius: [
238
+ 3,
239
+ 3,
240
+ 0,
241
+ 0
242
+ ],
243
+ barSize: 18
244
+ }),
245
+ /* @__PURE__ */ N(m, {
246
+ type: "monotone",
247
+ dataKey: "baselineAvg",
248
+ name: C("healthybowl.weather.anomaly.charts.baselineAvg", "Baseline avg"),
249
+ stroke: "var(--color-text-secondary)",
250
+ strokeWidth: 1.5,
251
+ strokeDasharray: "4 3",
252
+ dot: !1
253
+ })
254
+ ]
255
+ })
256
+ })
257
+ }), /* @__PURE__ */ N(a, {
258
+ title: C("healthybowl.weather.anomaly.charts.temp.title", "Monthly temperature"),
259
+ description: C("healthybowl.weather.anomaly.charts.temp.description", "This season vs the baseline min–max band"),
260
+ children: X.length === 0 ? /* @__PURE__ */ N(U, { label: C("healthybowl.weather.anomaly.charts.noData", "No monthly data yet") }) : /* @__PURE__ */ N(d, {
261
+ width: "100%",
262
+ height: 280,
263
+ children: /* @__PURE__ */ P(v, {
264
+ data: X,
265
+ margin: {
266
+ top: 8,
267
+ right: 16,
268
+ left: 0,
269
+ bottom: 4
270
+ },
271
+ children: [
272
+ /* @__PURE__ */ N(p, {
273
+ strokeDasharray: "3 3",
274
+ className: "stroke-border"
275
+ }),
276
+ /* @__PURE__ */ N(g, {
277
+ dataKey: "month",
278
+ className: "text-xs",
279
+ tick: { fill: "currentColor" }
280
+ }),
281
+ /* @__PURE__ */ N(_, {
282
+ className: "text-xs",
283
+ tick: { fill: "currentColor" },
284
+ tickFormatter: (e) => `${e}°`
285
+ }),
286
+ /* @__PURE__ */ N(u, {
287
+ contentStyle: I,
288
+ labelStyle: { color: "var(--color-foreground)" },
289
+ formatter: H
290
+ }),
291
+ /* @__PURE__ */ N(l, {}),
292
+ /* @__PURE__ */ N(h, {
293
+ type: "monotone",
294
+ dataKey: "band",
295
+ name: C("healthybowl.weather.anomaly.charts.baselineBand", "Baseline range"),
296
+ stroke: "none",
297
+ fill: "var(--color-success)",
298
+ fillOpacity: .18,
299
+ connectNulls: !0,
300
+ activeDot: !1
301
+ }),
302
+ /* @__PURE__ */ N(m, {
303
+ type: "monotone",
304
+ dataKey: "baselineAvg",
305
+ name: C("healthybowl.weather.anomaly.charts.baselineAvg", "Baseline avg"),
306
+ stroke: "var(--color-text-secondary)",
307
+ strokeWidth: 1.5,
308
+ strokeDasharray: "4 3",
309
+ dot: !1
310
+ }),
311
+ /* @__PURE__ */ N(m, {
312
+ type: "monotone",
313
+ dataKey: "current",
314
+ name: C("healthybowl.weather.anomaly.charts.thisSeason", "This season"),
315
+ stroke: "var(--color-success)",
316
+ strokeWidth: 2,
317
+ dot: { r: 2 }
318
+ })
319
+ ]
320
+ })
321
+ })
322
+ })]
323
+ }),
324
+ /* @__PURE__ */ N(a, {
325
+ title: C("healthybowl.weather.anomaly.callouts.title", "Anomaly callouts"),
326
+ description: C("healthybowl.weather.anomaly.callouts.description", "Notable deviations detected against your baseline"),
327
+ children: W.callouts.length === 0 ? /* @__PURE__ */ N("p", {
328
+ className: "py-6 text-center text-sm text-text-secondary",
329
+ children: C("healthybowl.weather.anomaly.callouts.none", "No anomalies flagged — this season is tracking normally.")
330
+ }) : /* @__PURE__ */ N("ul", {
331
+ className: "divide-y divide-border-subtle",
332
+ children: W.callouts.map((n) => {
333
+ let r = z(n.severity);
334
+ return /* @__PURE__ */ P("li", {
335
+ className: "flex items-center justify-between gap-4 py-3",
336
+ children: [/* @__PURE__ */ P("div", {
337
+ className: "flex min-w-0 items-center gap-3",
338
+ children: [/* @__PURE__ */ N(S, { className: "h-4 w-4 shrink-0 text-warning" }), /* @__PURE__ */ P("div", {
339
+ className: "min-w-0",
340
+ children: [/* @__PURE__ */ N("p", {
341
+ className: "truncate text-sm font-medium text-text-primary",
342
+ children: n.title
343
+ }), n.metric ? /* @__PURE__ */ N("p", {
344
+ className: "text-xs capitalize text-text-secondary",
345
+ children: n.metric.replace(/_/g, " ")
346
+ }) : null]
347
+ })]
348
+ }), /* @__PURE__ */ P("div", {
349
+ className: "flex shrink-0 items-center gap-4",
350
+ children: [/* @__PURE__ */ N("span", {
351
+ className: "hidden text-xs text-text-secondary sm:inline",
352
+ children: t(n.date)
353
+ }), /* @__PURE__ */ N("span", {
354
+ className: e("rounded-full px-2.5 py-0.5 text-xs font-medium", r.className),
355
+ children: r.label
356
+ })]
357
+ })]
358
+ }, n.id);
359
+ })
360
+ })
361
+ }),
362
+ /* @__PURE__ */ N("p", {
363
+ className: "text-xs text-text-secondary",
364
+ children: C("healthybowl.weather.anomaly.source", "Data source: {{source}} · generated {{when}}", {
365
+ source: W.source,
366
+ when: t(W.generatedAt)
367
+ })
368
+ })
369
+ ] }), /* @__PURE__ */ N(o, {
370
+ toasts: w,
371
+ onDismiss: V
372
+ })]
373
+ });
374
+ };
375
+ function H(e) {
376
+ return Array.isArray(e) ? `${Math.round(e[0])} – ${Math.round(e[1])}` : `${Math.round(e)}`;
377
+ }
378
+ function U({ label: e }) {
379
+ return /* @__PURE__ */ N("div", {
380
+ className: "flex h-[280px] items-center justify-center text-sm text-text-secondary",
381
+ children: e
382
+ });
383
+ }
384
+ //#endregion
385
+ export { V as WeatherAnomalyReportPage };
386
+
387
+ //# sourceMappingURL=WeatherAnomalyReportPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WeatherAnomalyReportPage.js","names":[],"sources":["../../../../src/healthybowl/pages/weather/WeatherAnomalyReportPage.tsx"],"sourcesContent":["/**\n * Seasonal Anomaly Report (BOFF-2892 · roadmap 20 · Historical Weather & Early\n * Warning). Compares the current season against the multi-year climate baseline\n * for the farm site: headline deviation cards (rainfall, temperature, frost days,\n * first-frost date), a monthly rainfall bar chart with the baseline min/max band,\n * a monthly temperature line chart against the baseline band, and the narrative\n * anomaly callouts. Every value is live from `getHealthyBowlWeatherAnomalyReport`\n * — no fabricated numbers; an un-synced farm shows an honest empty state.\n */\nimport { useMemo, type FC } from 'react';\nimport {\n ComposedChart,\n Bar,\n Line,\n Area,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n Legend,\n ResponsiveContainer,\n} from 'recharts';\nimport {\n CloudRain,\n Thermometer,\n Snowflake,\n CalendarClock,\n ArrowUp,\n ArrowDown,\n Minus,\n AlertTriangle,\n Printer,\n RefreshCw,\n type LucideIcon,\n} from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, ChartCard, EmptyState, ErrorState, PageLoader } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport {\n useWeatherIntelligence,\n type WeatherAnomalyMonthPoint,\n type WeatherAnomalyCallout,\n} from '../../hooks/useWeatherIntelligence';\nimport { cn, formatDate } from '../../utils/helpers';\n\nconst tooltipStyle = {\n backgroundColor: 'var(--color-card)',\n border: '1px solid var(--color-border)',\n borderRadius: '8px',\n} as const;\n\n/** Direction glyph for a signed deviation. */\ntype Direction = 'up' | 'down' | 'flat';\n\nconst directionOf = (value: number): Direction => (value > 0 ? 'up' : value < 0 ? 'down' : 'flat');\n\n/**\n * Severity → text-colour class keyed on the *magnitude* of a deviation. Small\n * deviations read as normal (emerald), moderate as amber, large as red. Data-viz\n * palette classes are the accepted exception to the semantic-token rule.\n */\nconst magnitudeColor = (magnitude: number, warn: number, danger: number): string =>\n magnitude >= danger ? 'text-red-600' : magnitude >= warn ? 'text-amber-600' : 'text-emerald-600';\n\n/** Callout severity badge classes (RED | AMBER | GREY, tolerant of high/moderate/low). */\nconst calloutSeverity = (severity: string): { label: string; className: string } => {\n const key = (severity ?? '').toUpperCase();\n if (key === 'RED' || key === 'HIGH') {\n return { label: 'High', className: 'bg-red-100 text-red-700 dark:bg-red-950/40 dark:text-red-300' };\n }\n if (key === 'AMBER' || key === 'MODERATE' || key === 'MEDIUM') {\n return { label: 'Moderate', className: 'bg-amber-100 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300' };\n }\n return { label: 'Low', className: 'bg-bg-sunken text-text-secondary' };\n};\n\ninterface DeviationCardProps {\n icon: LucideIcon;\n label: string;\n /** Big headline value, e.g. \"40%\" or \"1.8°C\". */\n headline: string;\n /** Emphasis word, e.g. \"BELOW normal\". */\n emphasis: string;\n /** Sub-line, e.g. \"84mm vs 140mm avg\". */\n detail: string;\n direction: Direction;\n colorClass: string;\n}\n\nconst DeviationCard: FC<DeviationCardProps> = ({\n icon: Icon,\n label,\n headline,\n emphasis,\n detail,\n direction,\n colorClass,\n}) => (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-medium text-text-secondary\">{label}</span>\n <span className=\"flex size-8 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n <Icon className=\"size-4\" />\n </span>\n </div>\n <div className={cn('mt-2 flex items-baseline gap-1.5', colorClass)}>\n {direction === 'up' && <ArrowUp className=\"size-5 shrink-0\" />}\n {direction === 'down' && <ArrowDown className=\"size-5 shrink-0\" />}\n {direction === 'flat' && <Minus className=\"size-5 shrink-0\" />}\n <span className=\"text-3xl font-semibold tabular-nums\">{headline}</span>\n <span className=\"text-sm font-medium uppercase\">{emphasis}</span>\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">{detail}</p>\n </div>\n);\n\nexport const WeatherAnomalyReportPage: FC = () => {\n const { t } = useI18n();\n const { toasts, toast, dismiss } = useToast();\n const { anomaly, loadingAnomaly, errorAnomaly, refetchAnomaly, syncHistory } = useWeatherIntelligence();\n\n // Row shapes for the composed charts: bundle the baseline min/max into a tuple so\n // recharts renders a range Area (the shaded baseline band) behind the current series.\n const rainfallRows = useMemo(\n () =>\n (anomaly?.monthlyRainfall ?? []).map((p: WeatherAnomalyMonthPoint) => ({\n month: p.monthName,\n current: p.currentValue,\n baselineAvg: p.baselineAvg,\n band: [p.baselineMin, p.baselineMax] as [number, number],\n })),\n [anomaly?.monthlyRainfall]\n );\n const temperatureRows = useMemo(\n () =>\n (anomaly?.monthlyTemperature ?? []).map((p: WeatherAnomalyMonthPoint) => ({\n month: p.monthName,\n current: p.currentValue,\n baselineAvg: p.baselineAvg,\n band: [p.baselineMin, p.baselineMax] as [number, number],\n })),\n [anomaly?.monthlyTemperature]\n );\n\n const handleSync = async () => {\n try {\n await syncHistory();\n toast({\n title: t('healthybowl.weather.anomaly.toast.synced.title', 'History synced'),\n description: t(\n 'healthybowl.weather.anomaly.toast.synced.description',\n 'The seasonal anomaly report has been recalculated from the latest archive.'\n ),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.common.error', 'Something went wrong'),\n description: err instanceof Error ? err.message : undefined,\n variant: 'error',\n });\n }\n };\n\n const subtitle = anomaly\n ? t('healthybowl.weather.anomaly.subtitle', 'This season vs {{years}}-year baseline ({{start}}–{{end}})', {\n years: anomaly.baselineYears,\n start: anomaly.startYear,\n end: anomaly.endYear - 1,\n })\n : t('healthybowl.weather.anomaly.subtitleFallback', 'This season vs the multi-year climate baseline');\n\n return (\n <PageLayout\n title={t('healthybowl.weather.anomaly.title', 'Seasonal Anomaly Report')}\n description={subtitle}\n purpose=\"How this season is tracking against your farm's own multi-year climate baseline — is it wetter or drier than normal, warmer or cooler, and is frost arriving earlier than usual. Use it to spot when the weather is deviating from what your crops are used to, so you can adjust irrigation, protect against early frost, and understand an unusual yield.\"\n actions={\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => window.print()}\n className=\"text-text-secondary hover:text-text-primary\"\n >\n <Printer className=\"h-4 w-4\" /> {t('healthybowl.weather.anomaly.actions.print', 'Print')}\n </Button>\n }\n >\n {loadingAnomaly && !anomaly ? (\n <PageLoader />\n ) : errorAnomaly && !anomaly ? (\n <ErrorState onRetry={refetchAnomaly} />\n ) : !anomaly || !anomaly.synced ? (\n <EmptyState\n illustration=\"empty-data\"\n title={t('healthybowl.weather.anomaly.empty.title', 'No baseline yet')}\n description={t(\n 'healthybowl.weather.anomaly.empty.description',\n 'Sync your farm-site weather history to build a multi-year climate baseline. Once synced, this report compares the current season against it.'\n )}\n action={\n <Button onClick={handleSync}>\n <RefreshCw className=\"h-4 w-4\" /> {t('healthybowl.weather.anomaly.empty.sync', 'Sync history')}\n </Button>\n }\n />\n ) : (\n <>\n {/* Deviation stat cards */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <DeviationCard\n icon={CloudRain}\n label={t('healthybowl.weather.anomaly.stats.rainfall.label', 'Rainfall this month')}\n headline={`${Math.abs(Math.round(anomaly.rainfallDeviationPct))}%`}\n emphasis={\n anomaly.rainfallDeviationPct < 0\n ? t('healthybowl.weather.anomaly.stats.rainfall.below', 'below normal')\n : t('healthybowl.weather.anomaly.stats.rainfall.above', 'above normal')\n }\n detail={t('healthybowl.weather.anomaly.stats.rainfall.detail', '{{now}}mm vs {{avg}}mm avg', {\n now: Math.round(anomaly.rainfallThisMonthMm),\n avg: Math.round(anomaly.rainfallBaselineMm),\n })}\n direction={directionOf(anomaly.rainfallDeviationPct)}\n colorClass={magnitudeColor(Math.abs(anomaly.rainfallDeviationPct), 15, 30)}\n />\n <DeviationCard\n icon={Thermometer}\n label={t('healthybowl.weather.anomaly.stats.temp.label', 'Avg temperature')}\n headline={`${anomaly.avgTempDeltaC > 0 ? '+' : ''}${anomaly.avgTempDeltaC.toFixed(1)}°C`}\n emphasis={\n anomaly.avgTempDeltaC > 0\n ? t('healthybowl.weather.anomaly.stats.temp.above', 'above')\n : anomaly.avgTempDeltaC < 0\n ? t('healthybowl.weather.anomaly.stats.temp.below', 'below')\n : t('healthybowl.weather.anomaly.stats.temp.normal', 'normal')\n }\n detail={t('healthybowl.weather.anomaly.stats.temp.detail', 'vs baseline average')}\n direction={directionOf(anomaly.avgTempDeltaC)}\n colorClass={magnitudeColor(Math.abs(anomaly.avgTempDeltaC), 1, 2)}\n />\n <DeviationCard\n icon={Snowflake}\n label={t('healthybowl.weather.anomaly.stats.frost.label', 'Frost days')}\n headline={`${anomaly.frostDaysDelta > 0 ? '+' : ''}${anomaly.frostDaysDelta}`}\n emphasis={t('healthybowl.weather.anomaly.stats.frost.emphasis', 'vs average')}\n detail={t('healthybowl.weather.anomaly.stats.frost.detail', '{{now}} this season vs {{avg}} baseline', {\n now: anomaly.frostDaysThisSeason,\n avg: anomaly.frostDaysBaseline,\n })}\n direction={directionOf(anomaly.frostDaysDelta)}\n colorClass={magnitudeColor(Math.abs(anomaly.frostDaysDelta), 2, 4)}\n />\n <DeviationCard\n icon={CalendarClock}\n label={t('healthybowl.weather.anomaly.stats.firstFrost.label', 'First-frost date')}\n headline={\n anomaly.firstFrostDate\n ? `${Math.abs(anomaly.firstFrostDeltaDays)}`\n : t('healthybowl.weather.anomaly.stats.firstFrost.none', '—')\n }\n emphasis={\n !anomaly.firstFrostDate\n ? t('healthybowl.weather.anomaly.stats.firstFrost.pending', 'not yet')\n : anomaly.firstFrostDeltaDays < 0\n ? t('healthybowl.weather.anomaly.stats.firstFrost.early', 'days early')\n : anomaly.firstFrostDeltaDays > 0\n ? t('healthybowl.weather.anomaly.stats.firstFrost.late', 'days late')\n : t('healthybowl.weather.anomaly.stats.firstFrost.onTime', 'on time')\n }\n detail={\n anomaly.firstFrostDate\n ? t('healthybowl.weather.anomaly.stats.firstFrost.detail', '{{now}} vs {{avg}}', {\n now: formatDate(anomaly.firstFrostDate),\n avg: anomaly.baselineFirstFrostDate ? formatDate(anomaly.baselineFirstFrostDate) : '—',\n })\n : t('healthybowl.weather.anomaly.stats.firstFrost.detailPending', 'No frost recorded yet this season')\n }\n direction={anomaly.firstFrostDate ? directionOf(anomaly.firstFrostDeltaDays) : 'flat'}\n colorClass={\n !anomaly.firstFrostDate\n ? 'text-text-secondary'\n : magnitudeColor(Math.abs(anomaly.firstFrostDeltaDays), 5, 10)\n }\n />\n </div>\n\n {/* Charts */}\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-2\">\n <ChartCard\n title={t('healthybowl.weather.anomaly.charts.rainfall.title', 'Monthly rainfall')}\n description={t(\n 'healthybowl.weather.anomaly.charts.rainfall.description',\n 'This season (bars) vs the baseline min–max band'\n )}\n >\n {rainfallRows.length === 0 ? (\n <NoSeries label={t('healthybowl.weather.anomaly.charts.noData', 'No monthly data yet')} />\n ) : (\n <ResponsiveContainer width=\"100%\" height={280}>\n <ComposedChart data={rainfallRows} margin={{ top: 8, right: 16, left: 0, bottom: 4 }}>\n <CartesianGrid strokeDasharray=\"3 3\" className=\"stroke-border\" />\n <XAxis dataKey=\"month\" className=\"text-xs\" tick={{ fill: 'currentColor' }} />\n <YAxis className=\"text-xs\" tick={{ fill: 'currentColor' }} tickFormatter={(v: number) => `${v}`} />\n <Tooltip\n contentStyle={tooltipStyle}\n labelStyle={{ color: 'var(--color-foreground)' }}\n formatter={formatChartValue}\n />\n <Legend />\n <Area\n type=\"monotone\"\n dataKey=\"band\"\n name={t('healthybowl.weather.anomaly.charts.baselineBand', 'Baseline range')}\n stroke=\"var(--color-border)\"\n strokeDasharray=\"6 4\"\n fill=\"var(--color-muted)\"\n fillOpacity={0.35}\n connectNulls\n activeDot={false}\n />\n <Bar\n dataKey=\"current\"\n name={t('healthybowl.weather.anomaly.charts.thisSeason', 'This season')}\n fill=\"var(--color-success)\"\n radius={[3, 3, 0, 0]}\n barSize={18}\n />\n <Line\n type=\"monotone\"\n dataKey=\"baselineAvg\"\n name={t('healthybowl.weather.anomaly.charts.baselineAvg', 'Baseline avg')}\n stroke=\"var(--color-text-secondary)\"\n strokeWidth={1.5}\n strokeDasharray=\"4 3\"\n dot={false}\n />\n </ComposedChart>\n </ResponsiveContainer>\n )}\n </ChartCard>\n\n <ChartCard\n title={t('healthybowl.weather.anomaly.charts.temp.title', 'Monthly temperature')}\n description={t(\n 'healthybowl.weather.anomaly.charts.temp.description',\n 'This season vs the baseline min–max band'\n )}\n >\n {temperatureRows.length === 0 ? (\n <NoSeries label={t('healthybowl.weather.anomaly.charts.noData', 'No monthly data yet')} />\n ) : (\n <ResponsiveContainer width=\"100%\" height={280}>\n <ComposedChart data={temperatureRows} margin={{ top: 8, right: 16, left: 0, bottom: 4 }}>\n <CartesianGrid strokeDasharray=\"3 3\" className=\"stroke-border\" />\n <XAxis dataKey=\"month\" className=\"text-xs\" tick={{ fill: 'currentColor' }} />\n <YAxis className=\"text-xs\" tick={{ fill: 'currentColor' }} tickFormatter={(v: number) => `${v}°`} />\n <Tooltip\n contentStyle={tooltipStyle}\n labelStyle={{ color: 'var(--color-foreground)' }}\n formatter={formatChartValue}\n />\n <Legend />\n <Area\n type=\"monotone\"\n dataKey=\"band\"\n name={t('healthybowl.weather.anomaly.charts.baselineBand', 'Baseline range')}\n stroke=\"none\"\n fill=\"var(--color-success)\"\n fillOpacity={0.18}\n connectNulls\n activeDot={false}\n />\n <Line\n type=\"monotone\"\n dataKey=\"baselineAvg\"\n name={t('healthybowl.weather.anomaly.charts.baselineAvg', 'Baseline avg')}\n stroke=\"var(--color-text-secondary)\"\n strokeWidth={1.5}\n strokeDasharray=\"4 3\"\n dot={false}\n />\n <Line\n type=\"monotone\"\n dataKey=\"current\"\n name={t('healthybowl.weather.anomaly.charts.thisSeason', 'This season')}\n stroke=\"var(--color-success)\"\n strokeWidth={2}\n dot={{ r: 2 }}\n />\n </ComposedChart>\n </ResponsiveContainer>\n )}\n </ChartCard>\n </div>\n\n {/* Anomaly callouts */}\n <ChartCard\n title={t('healthybowl.weather.anomaly.callouts.title', 'Anomaly callouts')}\n description={t(\n 'healthybowl.weather.anomaly.callouts.description',\n 'Notable deviations detected against your baseline'\n )}\n >\n {anomaly.callouts.length === 0 ? (\n <p className=\"py-6 text-center text-sm text-text-secondary\">\n {t(\n 'healthybowl.weather.anomaly.callouts.none',\n 'No anomalies flagged — this season is tracking normally.'\n )}\n </p>\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {anomaly.callouts.map((c: WeatherAnomalyCallout) => {\n const sev = calloutSeverity(c.severity);\n return (\n <li key={c.id} className=\"flex items-center justify-between gap-4 py-3\">\n <div className=\"flex min-w-0 items-center gap-3\">\n <AlertTriangle className=\"h-4 w-4 shrink-0 text-warning\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{c.title}</p>\n {c.metric ? (\n <p className=\"text-xs capitalize text-text-secondary\">{c.metric.replace(/_/g, ' ')}</p>\n ) : null}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-4\">\n <span className=\"hidden text-xs text-text-secondary sm:inline\">{formatDate(c.date)}</span>\n <span className={cn('rounded-full px-2.5 py-0.5 text-xs font-medium', sev.className)}>\n {sev.label}\n </span>\n </div>\n </li>\n );\n })}\n </ul>\n )}\n </ChartCard>\n\n {/* Source caption */}\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.weather.anomaly.source', 'Data source: {{source}} · generated {{when}}', {\n source: anomaly.source,\n when: formatDate(anomaly.generatedAt),\n })}\n </p>\n </>\n )}\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n\n/** Recharts tooltip/value formatter tolerant of the [min, max] band tuple. */\nfunction formatChartValue(value: number | [number, number]): string {\n if (Array.isArray(value)) {\n return `${Math.round(value[0])} – ${Math.round(value[1])}`;\n }\n return `${Math.round(value)}`;\n}\n\nfunction NoSeries({ label }: { label: string }) {\n return <div className=\"flex h-[280px] items-center justify-center text-sm text-text-secondary\">{label}</div>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAM,IAAe;CACnB,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACf,EAKK,KAAe,MAA8B,IAAQ,IAAI,OAAO,IAAQ,IAAI,SAAS,QAOrF,KAAkB,GAAmB,GAAc,MACvD,KAAa,IAAS,iBAAiB,KAAa,IAAO,mBAAmB,oBAG1E,KAAmB,MAA2D;CAClF,IAAM,KAAO,KAAY,IAAI,aAAa;AAO1C,QANI,MAAQ,SAAS,MAAQ,SACpB;EAAE,OAAO;EAAQ,WAAW;EAAgE,GAEjG,MAAQ,WAAW,MAAQ,cAAc,MAAQ,WAC5C;EAAE,OAAO;EAAY,WAAW;EAAwE,GAE1G;EAAE,OAAO;EAAO,WAAW;EAAoC;GAgBlE,KAAyC,EAC7C,MAAM,GACN,UACA,aACA,aACA,WACA,cACA,oBAEA,kBAAC,OAAD;CAAK,WAAU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