@burdenoff/microfe-healthybowl 2026.710.7 → 2026.710.8

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.
@@ -1,8 +1,8 @@
1
1
  import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
2
- import { useHealthyBowl as t } from "../context/HealthyBowlContext.js";
3
- import { ToastContainer as n } from "./Toast.js";
4
- import { require_leaflet_src as r } from "../../node_modules/leaflet/dist/leaflet-src.js";
5
- import { geocodePlace as i } from "../utils/geocode.js";
2
+ import { geocodePlace as t } from "../utils/geocode.js";
3
+ import { useHealthyBowl as n } from "../context/HealthyBowlContext.js";
4
+ import { ToastContainer as r } from "./Toast.js";
5
+ import { require_leaflet_src as i } from "../../node_modules/leaflet/dist/leaflet-src.js";
6
6
  import { useToast as a } from "../hooks/useToast.js";
7
7
  import { ensureLeafletCss as ee } from "../utils/leaflet.js";
8
8
  import { extractPolygon as o, isValidPolygon as te, polygonAreaInUnit as s, ringToPolygon as ne } from "../utils/geo.js";
@@ -14,7 +14,7 @@ import { Button as g } from "@burdenoff/fe-libs/ui";
14
14
  import { gql as _ } from "@apollo/client";
15
15
  import { useMutation as pe } from "@apollo/client/react";
16
16
  //#region src/healthybowl/components/FieldMap.tsx
17
- var v = /* @__PURE__ */ e(r(), 1), me = _`
17
+ var v = /* @__PURE__ */ e(i(), 1), me = _`
18
18
  mutation UpdateHealthyBowlFieldBoundary($input: UpdateHealthyBowlFieldInput!) {
19
19
  updateHealthyBowlField(input: $input) {
20
20
  id
@@ -46,8 +46,8 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
46
46
  lng: r,
47
47
  label: `${n.toFixed(6)}, ${r.toFixed(6)}`
48
48
  } : null;
49
- }, Te = ({ fieldId: e, unit: r, center: _, initialBoundary: Te, onSaved: Ee, onAreaChange: De }) => {
50
- let { t: b } = re(), { workspaceId: x } = t(), { toasts: Oe, toast: S, dismiss: ke } = a(), C = u(null), w = u(null), T = u(null), E = u(null), D = u(null), O = u(null), k = u(null), A = u(null), j = u(_ ?? null), M = u([]), N = u([]), P = u(null), F = u("view"), [I, Ae] = d("loading"), [L, R] = d("view"), [z, je] = d(!1), [B, Me] = d(null), [Ne, Pe] = d(0), [Fe, V] = d(!1), [Ie, H] = d(!1), [Le, Re] = d(!1), [ze, U] = d(!1), [W, Be] = d(""), [G, Ve] = d(!1), [K, q] = d(null), He = Fe || Ie, [Ue] = pe(me);
49
+ }, Te = ({ fieldId: e, unit: i, center: _, initialBoundary: Te, onSaved: Ee, onAreaChange: De }) => {
50
+ let { t: b } = re(), { workspaceId: x } = n(), { toasts: Oe, toast: S, dismiss: ke } = a(), C = u(null), w = u(null), T = u(null), E = u(null), D = u(null), O = u(null), k = u(null), A = u(null), j = u(_ ?? null), M = u([]), N = u([]), P = u(null), F = u("view"), [I, Ae] = d("loading"), [L, R] = d("view"), [z, je] = d(!1), [B, Me] = d(null), [Ne, Pe] = d(0), [Fe, V] = d(!1), [Ie, H] = d(!1), [Le, Re] = d(!1), [ze, U] = d(!1), [W, Be] = d(""), [G, Ve] = d(!1), [K, q] = d(null), He = Fe || Ie, [Ue] = pe(me);
51
51
  l(() => {
52
52
  j.current = _ ?? null;
53
53
  }, [_]), l(() => {
@@ -60,14 +60,14 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
60
60
  let n = T.current;
61
61
  if (!n) return;
62
62
  E.current && n.removeLayer(E.current);
63
- let i = v.default.geoJSON(e, { style: () => be }).addTo(n);
64
- if (E.current = i, P.current = e, je(!0), Me(s(e, r)), t) try {
65
- n.fitBounds(i.getBounds(), {
63
+ let r = v.default.geoJSON(e, { style: () => be }).addTo(n);
64
+ if (E.current = r, P.current = e, je(!0), Me(s(e, i)), t) try {
65
+ n.fitBounds(r.getBounds(), {
66
66
  padding: [24, 24],
67
67
  maxZoom: 18
68
68
  });
69
69
  } catch {}
70
- }, [r]), X = c(() => {
70
+ }, [i]), X = c(() => {
71
71
  let e = T.current;
72
72
  E.current && e && e.removeLayer(E.current), E.current = null, P.current = null, je(!1), Me(null);
73
73
  }, []), Z = c(() => {
@@ -167,8 +167,8 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
167
167
  S
168
168
  ]), qe = c(async (e) => {
169
169
  e.preventDefault();
170
- let t = W.trim();
171
- if (!t) {
170
+ let n = W.trim();
171
+ if (!n) {
172
172
  S({
173
173
  title: b("healthybowl.fieldMap.toast.searchRequired.title", "Place required"),
174
174
  description: b("healthybowl.fieldMap.toast.searchRequired.description", "Enter a village, city, region, or coordinates."),
@@ -176,14 +176,14 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
176
176
  });
177
177
  return;
178
178
  }
179
- let n = we(t);
180
- if (n) {
181
- Q(n);
179
+ let r = we(n);
180
+ if (r) {
181
+ Q(r);
182
182
  return;
183
183
  }
184
184
  Ve(!0);
185
185
  try {
186
- let e = await i(t);
186
+ let e = await t(n);
187
187
  if (!e) {
188
188
  S({
189
189
  title: b("healthybowl.fieldMap.toast.searchNotFound.title", "Place not found"),
@@ -192,15 +192,15 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
192
192
  });
193
193
  return;
194
194
  }
195
- let n = [
195
+ let r = [
196
196
  e.name,
197
197
  e.admin1,
198
198
  e.country
199
- ].filter(Boolean).join(", ") || t;
199
+ ].filter(Boolean).join(", ") || n;
200
200
  Q({
201
201
  lat: e.latitude,
202
202
  lng: e.longitude,
203
- label: n
203
+ label: r
204
204
  });
205
205
  } catch (e) {
206
206
  S({
@@ -293,7 +293,7 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
293
293
  ]), et = c(async () => {
294
294
  Re(!0);
295
295
  try {
296
- let t = P.current, n = t ? s(t, r) : void 0, i = K ? {
296
+ let t = P.current, n = t ? s(t, i) : void 0, r = K ? {
297
297
  lat: K.lat,
298
298
  lng: K.lng
299
299
  } : void 0;
@@ -301,13 +301,13 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
301
301
  id: e,
302
302
  boundary: t,
303
303
  ...n == null ? {} : { area: n },
304
- ...i ? { location: i } : {},
304
+ ...r ? { location: r } : {},
305
305
  context: { workspaceId: x }
306
- } } }), i && (j.current = i), V(!1), H(!1), q(null), Ee?.(), S({
306
+ } } }), r && (j.current = r), V(!1), H(!1), q(null), Ee?.(), S({
307
307
  title: b("healthybowl.fieldMap.toast.saved.title", "Map saved"),
308
- description: i ? b("healthybowl.fieldMap.toast.savedLocation.description", "Field GPS location updated.") : t ? b("healthybowl.fieldMap.toast.saved.description", "Field area updated to {{area}} {{unit}}.", {
308
+ description: r ? b("healthybowl.fieldMap.toast.savedLocation.description", "Field GPS location updated.") : t ? b("healthybowl.fieldMap.toast.saved.description", "Field area updated to {{area}} {{unit}}.", {
309
309
  area: String(n ?? ""),
310
- unit: r
310
+ unit: i
311
311
  }) : b("healthybowl.fieldMap.toast.savedCleared.description", "Boundary removed from this field."),
312
312
  variant: "success"
313
313
  });
@@ -326,7 +326,7 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
326
326
  K,
327
327
  b,
328
328
  S,
329
- r,
329
+ i,
330
330
  Ue,
331
331
  x
332
332
  ]);
@@ -454,7 +454,7 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
454
454
  className: "text-xs text-text-secondary",
455
455
  children: b("healthybowl.fieldMap.computedArea", "Area: {{area}} {{unit}}", {
456
456
  area: String(B),
457
- unit: r
457
+ unit: i
458
458
  })
459
459
  }), /* @__PURE__ */ h(g, {
460
460
  variant: "default",
@@ -563,7 +563,7 @@ var v = /* @__PURE__ */ e(r(), 1), me = _`
563
563
  className: "mt-2 text-xs text-text-secondary",
564
564
  children: b("healthybowl.fieldMap.attribution", "Imagery © Esri, Maxar, Earthstar Geographics · overlays © OpenTopoMap / OpenStreetMap")
565
565
  }),
566
- /* @__PURE__ */ m(n, {
566
+ /* @__PURE__ */ m(r, {
567
567
  toasts: Oe,
568
568
  onDismiss: ke
569
569
  })
@@ -1,7 +1,7 @@
1
1
  import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
2
- import { ToastContainer as t } from "./Toast.js";
3
- import { require_leaflet_src as n } from "../../node_modules/leaflet/dist/leaflet-src.js";
4
- import { geocodePlace as r } from "../utils/geocode.js";
2
+ import { geocodePlace as t } from "../utils/geocode.js";
3
+ import { ToastContainer as n } from "./Toast.js";
4
+ import { require_leaflet_src as r } from "../../node_modules/leaflet/dist/leaflet-src.js";
5
5
  import { useToast as i } from "../hooks/useToast.js";
6
6
  import { useCallback as a, useEffect as o, useRef as s, useState as c } from "react";
7
7
  import { useI18n as l } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
@@ -9,14 +9,14 @@ import { LocateFixed as u, MapPinned as d, Search as f, X as p } from "lucide-re
9
9
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
10
10
  import { Button as g } from "@burdenoff/fe-libs/ui";
11
11
  //#region src/healthybowl/components/WeatherMap.tsx
12
- var _ = /* @__PURE__ */ e(n(), 1), v = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css", y = "sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=", b = 7, x = 10, S = 10, C = (e) => !!(e && Number.isFinite(e.lat) && Number.isFinite(e.lng) && e.lat >= -90 && e.lat <= 90 && e.lng >= -180 && e.lng <= 180 && (e.lat !== 0 || e.lng !== 0));
13
- function w() {
12
+ var _ = /* @__PURE__ */ e(r(), 1), v = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css", y = "sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=", b = 7, x = 10, S = 10, C = (e) => !!(e && Number.isFinite(e.lat) && Number.isFinite(e.lng) && e.lat >= -90 && e.lat <= 90 && e.lng >= -180 && e.lng <= 180 && (e.lat !== 0 || e.lng !== 0));
13
+ function ee() {
14
14
  if (document.getElementById("leaflet-css")) return;
15
15
  let e = document.createElement("link");
16
16
  e.id = "leaflet-css", e.rel = "stylesheet", e.href = v, e.integrity = y, e.crossOrigin = "anonymous", document.head.appendChild(e);
17
17
  }
18
- var T = ({ location: e, center: n }) => {
19
- let { t: v } = l(), { toasts: y, toast: T, dismiss: ee } = i(), E = s(null), D = s(null), O = s(null), k = s(null), A = s(null), j = s(null), [M, N] = c("loading"), [P, F] = c(!1), [I, L] = c(!1), [R, z] = c(""), [B, V] = c(!1), [H, U] = c(null), [W, G] = c(null), K = v("healthybowl.weather.map.layers.streets", "Streets"), q = v("healthybowl.weather.map.layers.terrain", "Terrain"), J = v("healthybowl.weather.map.layers.radar", "Live radar"), Y = C(n) ? n : null, X = Y ? Y.lat : null, Z = Y ? Y.lng : null, Q = a(() => {
18
+ var w = ({ location: e, center: r }) => {
19
+ let { t: v } = l(), { toasts: y, toast: w, dismiss: T } = i(), E = s(null), D = s(null), O = s(null), k = s(null), A = s(null), j = s(null), [M, N] = c("loading"), [P, F] = c(!1), [I, L] = c(!1), [R, z] = c(""), [B, V] = c(!1), [H, U] = c(null), [W, G] = c(null), K = v("healthybowl.weather.map.layers.streets", "Streets"), q = v("healthybowl.weather.map.layers.terrain", "Terrain"), J = v("healthybowl.weather.map.layers.radar", "Live radar"), Y = C(r) ? r : null, X = Y ? Y.lat : null, Z = Y ? Y.lng : null, Q = a(() => {
20
20
  let e = D.current;
21
21
  k.current && e && e.removeLayer(k.current), A.current && e && e.removeLayer(A.current), k.current = null, A.current = null;
22
22
  }, []), $ = a(() => {
@@ -31,7 +31,7 @@ var T = ({ location: e, center: n }) => {
31
31
  let e = D.current;
32
32
  if (e) {
33
33
  if (typeof navigator > "u" || !navigator.geolocation) {
34
- T({
34
+ w({
35
35
  title: v("healthybowl.weather.map.toast.locationUnsupported.title", "Location unavailable"),
36
36
  description: v("healthybowl.weather.map.toast.locationUnsupported.description", "This browser does not support device location."),
37
37
  variant: "warning"
@@ -56,7 +56,7 @@ var T = ({ location: e, center: n }) => {
56
56
  }).addTo(e), e.flyTo(n, Math.max(e.getZoom(), x), { duration: .75 }), L(!1);
57
57
  }, (e) => {
58
58
  let t = e.code === e.PERMISSION_DENIED;
59
- T({
59
+ w({
60
60
  title: t ? v("healthybowl.weather.map.toast.locationBlocked.title", "Location blocked") : v("healthybowl.weather.map.toast.locationFailed.title", "Could not get location"),
61
61
  description: t ? v("healthybowl.weather.map.toast.locationBlocked.description", "Allow location access in the browser, then try again.") : v("healthybowl.weather.map.toast.locationFailed.description", "Make sure GPS is enabled and the page is open over HTTPS."),
62
62
  variant: "warning"
@@ -70,24 +70,24 @@ var T = ({ location: e, center: n }) => {
70
70
  }, [
71
71
  Q,
72
72
  v,
73
- T
73
+ w
74
74
  ]), ie = a(async (e) => {
75
75
  e.preventDefault();
76
- let t = D.current, n = R.trim();
77
- if (!n) {
78
- T({
76
+ let n = D.current, r = R.trim();
77
+ if (!r) {
78
+ w({
79
79
  title: v("healthybowl.weather.map.toast.searchRequired.title", "Place required"),
80
80
  description: v("healthybowl.weather.map.toast.searchRequired.description", "Enter a city, village, district, or region to view it on the map."),
81
81
  variant: "warning"
82
82
  });
83
83
  return;
84
84
  }
85
- if (t) {
85
+ if (n) {
86
86
  V(!0);
87
87
  try {
88
- let e = await r(n);
88
+ let e = await t(r);
89
89
  if (!e) {
90
- T({
90
+ w({
91
91
  title: v("healthybowl.weather.map.toast.searchNotFound.title", "Place not found"),
92
92
  description: v("healthybowl.weather.map.toast.searchNotFound.description", "Try a more specific location name, such as city and state."),
93
93
  variant: "warning"
@@ -98,7 +98,7 @@ var T = ({ location: e, center: n }) => {
98
98
  e.name,
99
99
  e.admin1,
100
100
  e.country
101
- ].filter(Boolean).join(", ") || n, a = [e.latitude, e.longitude];
101
+ ].filter(Boolean).join(", ") || r, a = [e.latitude, e.longitude];
102
102
  $();
103
103
  let o = document.createElement("span");
104
104
  o.textContent = i, j.current = _.default.circleMarker(a, {
@@ -107,9 +107,9 @@ var T = ({ location: e, center: n }) => {
107
107
  weight: 2,
108
108
  fillColor: "#0ea5e9",
109
109
  fillOpacity: 1
110
- }).addTo(t).bindPopup(o).openPopup(), t.flyTo(a, Math.max(t.getZoom(), S), { duration: .75 }), U(i);
110
+ }).addTo(n).bindPopup(o).openPopup(), n.flyTo(a, Math.max(n.getZoom(), S), { duration: .75 }), U(i);
111
111
  } catch (e) {
112
- T({
112
+ w({
113
113
  title: v("healthybowl.weather.map.toast.searchFailed.title", "Search failed"),
114
114
  description: e instanceof Error ? e.message : String(e),
115
115
  variant: "error"
@@ -122,21 +122,21 @@ var T = ({ location: e, center: n }) => {
122
122
  $,
123
123
  R,
124
124
  v,
125
- T
125
+ w
126
126
  ]);
127
127
  return o(() => {
128
- let t = E.current;
129
- if (!t) return;
130
- w();
131
- let n = new AbortController(), i, a = !1;
128
+ let n = E.current;
129
+ if (!n) return;
130
+ ee();
131
+ let r = new AbortController(), i, a = !1;
132
132
  return N("loading"), F(!1), G(null), U(null), O.current = null, (async () => {
133
133
  let o = X !== null && Z !== null ? {
134
134
  lat: X,
135
135
  lng: Z
136
- } : null, s = o ? null : await r(e, n.signal), c = o ? [o.lat, o.lng] : s ? [s.latitude, s.longitude] : null;
136
+ } : null, s = o ? null : await t(e, r.signal), c = o ? [o.lat, o.lng] : s ? [s.latitude, s.longitude] : null;
137
137
  if (a || !E.current) return;
138
138
  let l = c ?? [20, 0], u = c ? b : 2;
139
- O.current = c ? _.default.latLng(c[0], c[1]) : null, F(!!c), i = _.default.map(t, {
139
+ O.current = c ? _.default.latLng(c[0], c[1]) : null, F(!!c), i = _.default.map(n, {
140
140
  center: l,
141
141
  zoom: u,
142
142
  scrollWheelZoom: !0
@@ -163,21 +163,21 @@ var T = ({ location: e, center: n }) => {
163
163
  n.textContent = e || "Your farm", _.default.marker(l, { icon: t }).addTo(i).bindPopup(n);
164
164
  }
165
165
  try {
166
- let e = await (await fetch("https://api.rainviewer.com/public/weather-maps.json", { signal: n.signal })).json(), t = e.radar?.past ?? [], r = t[t.length - 1];
167
- if (!a && i && e.host && r?.path) {
168
- let t = _.default.tileLayer(`${e.host}${r.path}/256/{z}/{x}/{y}/4/1_1.png`, {
166
+ let e = await (await fetch("https://api.rainviewer.com/public/weather-maps.json", { signal: r.signal })).json(), t = e.radar?.past ?? [], n = t[t.length - 1];
167
+ if (!a && i && e.host && n?.path) {
168
+ let t = _.default.tileLayer(`${e.host}${n.path}/256/{z}/{x}/{y}/4/1_1.png`, {
169
169
  opacity: .55,
170
170
  maxZoom: 18,
171
171
  maxNativeZoom: 7
172
172
  }).addTo(i);
173
- p.addOverlay(t, J), typeof r.time == "number" && G(/* @__PURE__ */ new Date(r.time * 1e3));
173
+ p.addOverlay(t, J), typeof n.time == "number" && G(/* @__PURE__ */ new Date(n.time * 1e3));
174
174
  }
175
175
  } catch {}
176
176
  a || (N("ready"), window.setTimeout(() => i?.invalidateSize(), 80));
177
177
  })().catch(() => {
178
178
  a || N("error");
179
179
  }), () => {
180
- a = !0, n.abort(), Q(), $(), i?.remove(), D.current = null, O.current = null;
180
+ a = !0, r.abort(), Q(), $(), i?.remove(), D.current = null, O.current = null;
181
181
  };
182
182
  }, [
183
183
  X,
@@ -288,14 +288,14 @@ var T = ({ location: e, center: n }) => {
288
288
  })}` : ""
289
289
  ]
290
290
  }),
291
- /* @__PURE__ */ m(t, {
291
+ /* @__PURE__ */ m(n, {
292
292
  toasts: y,
293
- onDismiss: ee
293
+ onDismiss: T
294
294
  })
295
295
  ]
296
296
  });
297
297
  };
298
298
  //#endregion
299
- export { T as WeatherMap };
299
+ export { w as WeatherMap };
300
300
 
301
301
  //# sourceMappingURL=WeatherMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WeatherMap.js","names":[],"sources":["../../../src/healthybowl/components/WeatherMap.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type FC, type FormEvent } from 'react';\nimport L from 'leaflet';\nimport { LocateFixed, MapPinned, Search, X } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { geocodePlace } from '../utils/geocode';\nimport { useToast } from '../hooks/useToast';\nimport { ToastContainer } from './Toast';\n\ninterface WeatherMapProps {\n /** Resolved place name (from the weather data) used to center the map. */\n location: string;\n /** Backend-resolved farm/weather coordinates. Preferred over client-side geocoding. */\n center?: { lat: number; lng: number } | null;\n}\n\nconst LEAFLET_CSS = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css';\n// SRI for leaflet@1.9.4/dist/leaflet.css (immutable versioned URL) — guards against a CDN compromise.\nconst LEAFLET_CSS_SRI = 'sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=';\nconst FARM_WEATHER_ZOOM = 7;\nconst USER_LOCATION_ZOOM = 10;\nconst SEARCH_LOCATION_ZOOM = 10;\n\nconst isUsableCoordinate = (value?: { lat: number; lng: number } | null): value is { lat: number; lng: number } =>\n Boolean(\n value &&\n Number.isFinite(value.lat) &&\n Number.isFinite(value.lng) &&\n value.lat >= -90 &&\n value.lat <= 90 &&\n value.lng >= -180 &&\n value.lng <= 180 &&\n (value.lat !== 0 || value.lng !== 0)\n );\n\n/**\n * Inject Leaflet's stylesheet at runtime. The MFE library build doesn't deliver\n * a component's bundled CSS to the host shell (the host styles come from its own\n * Tailwind), so we load Leaflet's CSS from a CDN instead — consistent with the\n * map being an inherently online feature (tiles + radar).\n */\nfunction ensureLeafletCss(): void {\n if (document.getElementById('leaflet-css')) return;\n const link = document.createElement('link');\n link.id = 'leaflet-css';\n link.rel = 'stylesheet';\n link.href = LEAFLET_CSS;\n link.integrity = LEAFLET_CSS_SRI;\n link.crossOrigin = 'anonymous';\n document.head.appendChild(link);\n}\n\n/**\n * Interactive weather map: OpenStreetMap base + live precipitation radar overlay\n * (RainViewer, keyless), centered on backend-resolved farm coordinates when\n * available, then client-geocoded from the weather location as a fallback.\n */\nexport const WeatherMap: FC<WeatherMapProps> = ({ location, center }) => {\n const { t } = useI18n();\n const { toasts, toast, dismiss } = useToast();\n const containerRef = useRef<HTMLDivElement>(null);\n const mapRef = useRef<L.Map | null>(null);\n const farmCenterRef = useRef<L.LatLng | null>(null);\n const userLocationMarkerRef = useRef<L.CircleMarker | null>(null);\n const userAccuracyCircleRef = useRef<L.Circle | null>(null);\n const searchedPlaceMarkerRef = useRef<L.CircleMarker | null>(null);\n const [status, setStatus] = useState<'loading' | 'ready' | 'error'>('loading');\n const [hasFarmCenter, setHasFarmCenter] = useState(false);\n const [locating, setLocating] = useState(false);\n const [searchQuery, setSearchQuery] = useState('');\n const [searching, setSearching] = useState(false);\n const [searchedPlace, setSearchedPlace] = useState<string | null>(null);\n const [radarUpdatedAt, setRadarUpdatedAt] = useState<Date | null>(null);\n const streetsLayerLabel = t('healthybowl.weather.map.layers.streets', 'Streets');\n const terrainLayerLabel = t('healthybowl.weather.map.layers.terrain', 'Terrain');\n const radarLayerLabel = t('healthybowl.weather.map.layers.radar', 'Live radar');\n\n // Depend on the primitive coordinates, not the `center` object: the parent\n // re-renders on every weather/radar refresh and hands us a fresh {lat,lng}\n // object with identical values. Keying the map-creation effect on the object\n // reference re-created the whole Leaflet map on each refresh, snapping the view\n // back to the farm and wiping any place the user had searched for.\n const usableCenter = isUsableCoordinate(center) ? center : null;\n const centerLat = usableCenter ? usableCenter.lat : null;\n const centerLng = usableCenter ? usableCenter.lng : null;\n\n const clearUserLocation = useCallback(() => {\n const map = mapRef.current;\n if (userLocationMarkerRef.current && map) map.removeLayer(userLocationMarkerRef.current);\n if (userAccuracyCircleRef.current && map) map.removeLayer(userAccuracyCircleRef.current);\n userLocationMarkerRef.current = null;\n userAccuracyCircleRef.current = null;\n }, []);\n\n const removeSearchedPlaceMarker = useCallback(() => {\n const map = mapRef.current;\n if (searchedPlaceMarkerRef.current && map) map.removeLayer(searchedPlaceMarkerRef.current);\n searchedPlaceMarkerRef.current = null;\n }, []);\n\n const clearSearchedPlace = useCallback(() => {\n removeSearchedPlaceMarker();\n setSearchedPlace(null);\n }, [removeSearchedPlaceMarker]);\n\n const focusFarm = useCallback(() => {\n const map = mapRef.current;\n const farmCenter = farmCenterRef.current;\n if (!map || !farmCenter) return;\n map.flyTo(farmCenter, FARM_WEATHER_ZOOM, { duration: 0.6 });\n }, []);\n\n const handleLocateMe = useCallback(() => {\n const map = mapRef.current;\n if (!map) return;\n if (typeof navigator === 'undefined' || !navigator.geolocation) {\n toast({\n title: t('healthybowl.weather.map.toast.locationUnsupported.title', 'Location unavailable'),\n description: t(\n 'healthybowl.weather.map.toast.locationUnsupported.description',\n 'This browser does not support device location.'\n ),\n variant: 'warning',\n });\n return;\n }\n\n setLocating(true);\n navigator.geolocation.getCurrentPosition(\n (position) => {\n const latlng: L.LatLngExpression = [position.coords.latitude, position.coords.longitude];\n clearUserLocation();\n userAccuracyCircleRef.current = L.circle(latlng, {\n radius: Math.max(10, position.coords.accuracy || 0),\n color: '#2563eb',\n fillColor: '#3b82f6',\n fillOpacity: 0.12,\n opacity: 0.45,\n weight: 1,\n }).addTo(map);\n userLocationMarkerRef.current = L.circleMarker(latlng, {\n radius: 7,\n color: '#ffffff',\n weight: 2,\n fillColor: '#2563eb',\n fillOpacity: 1,\n }).addTo(map);\n map.flyTo(latlng, Math.max(map.getZoom(), USER_LOCATION_ZOOM), { duration: 0.75 });\n setLocating(false);\n },\n (error) => {\n const blocked = error.code === error.PERMISSION_DENIED;\n toast({\n title: blocked\n ? t('healthybowl.weather.map.toast.locationBlocked.title', 'Location blocked')\n : t('healthybowl.weather.map.toast.locationFailed.title', 'Could not get location'),\n description: blocked\n ? t(\n 'healthybowl.weather.map.toast.locationBlocked.description',\n 'Allow location access in the browser, then try again.'\n )\n : t(\n 'healthybowl.weather.map.toast.locationFailed.description',\n 'Make sure GPS is enabled and the page is open over HTTPS.'\n ),\n variant: 'warning',\n });\n setLocating(false);\n },\n { enableHighAccuracy: true, timeout: 12000, maximumAge: 60000 }\n );\n }, [clearUserLocation, t, toast]);\n\n const handleSearchPlace = useCallback(\n async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n const map = mapRef.current;\n const place = searchQuery.trim();\n if (!place) {\n toast({\n title: t('healthybowl.weather.map.toast.searchRequired.title', 'Place required'),\n description: t(\n 'healthybowl.weather.map.toast.searchRequired.description',\n 'Enter a city, village, district, or region to view it on the map.'\n ),\n variant: 'warning',\n });\n return;\n }\n if (!map) return;\n\n setSearching(true);\n try {\n const hit = await geocodePlace(place);\n if (!hit) {\n toast({\n title: t('healthybowl.weather.map.toast.searchNotFound.title', 'Place not found'),\n description: t(\n 'healthybowl.weather.map.toast.searchNotFound.description',\n 'Try a more specific location name, such as city and state.'\n ),\n variant: 'warning',\n });\n return;\n }\n\n const label = [hit.name, hit.admin1, hit.country].filter(Boolean).join(', ') || place;\n const latlng: L.LatLngExpression = [hit.latitude, hit.longitude];\n removeSearchedPlaceMarker();\n const popupEl = document.createElement('span');\n popupEl.textContent = label;\n searchedPlaceMarkerRef.current = L.circleMarker(latlng, {\n radius: 8,\n color: '#ffffff',\n weight: 2,\n fillColor: '#0ea5e9',\n fillOpacity: 1,\n })\n .addTo(map)\n .bindPopup(popupEl)\n .openPopup();\n map.flyTo(latlng, Math.max(map.getZoom(), SEARCH_LOCATION_ZOOM), { duration: 0.75 });\n setSearchedPlace(label);\n } catch (err) {\n toast({\n title: t('healthybowl.weather.map.toast.searchFailed.title', 'Search failed'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setSearching(false);\n }\n },\n [removeSearchedPlaceMarker, searchQuery, t, toast]\n );\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return undefined;\n ensureLeafletCss();\n const controller = new AbortController();\n let map: L.Map | undefined;\n let cancelled = false;\n setStatus('loading');\n setHasFarmCenter(false);\n setRadarUpdatedAt(null);\n setSearchedPlace(null);\n farmCenterRef.current = null;\n\n void (async () => {\n const backendCenter = centerLat !== null && centerLng !== null ? { lat: centerLat, lng: centerLng } : null;\n const hit = backendCenter ? null : await geocodePlace(location, controller.signal);\n const located: [number, number] | null = backendCenter\n ? [backendCenter.lat, backendCenter.lng]\n : hit\n ? [hit.latitude, hit.longitude]\n : null;\n if (cancelled || !containerRef.current) return;\n const mapCenter: L.LatLngExpression = located ?? [20, 0];\n // z7 keeps the RainViewer radar at its native resolution (it has no tiles past z7)\n // while still framing the farm and its surrounding weather system.\n const zoom = located ? FARM_WEATHER_ZOOM : 2;\n farmCenterRef.current = located ? L.latLng(located[0], located[1]) : null;\n setHasFarmCenter(Boolean(located));\n\n map = L.map(el, { center: mapCenter, zoom, scrollWheelZoom: true });\n mapRef.current = map;\n const streetsLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\n attribution: '© OpenStreetMap contributors',\n maxZoom: 18,\n });\n const terrainLayer = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {\n attribution: '© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors',\n maxZoom: 17,\n });\n streetsLayer.addTo(map);\n const layerControl = L.control\n .layers(\n {\n [streetsLayerLabel]: streetsLayer,\n [terrainLayerLabel]: terrainLayer,\n },\n undefined,\n { collapsed: false }\n )\n .addTo(map);\n L.control.scale({ imperial: false }).addTo(map);\n\n if (located) {\n const icon = L.divIcon({\n className: 'hb-weather-marker',\n html:\n '<div style=\"width:16px;height:16px;border-radius:50% 50% 50% 0;transform:rotate(-45deg);' +\n 'background:var(--color-action-primary-bg, #16a34a);border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.4)\"></div>',\n iconSize: [16, 16],\n iconAnchor: [8, 16],\n });\n // bindPopup treats a string as HTML; pass a text node so the place name\n // can never be interpreted as markup (defense-in-depth against a tainted value).\n const popupEl = document.createElement('span');\n popupEl.textContent = location || 'Your farm';\n L.marker(mapCenter, { icon }).addTo(map).bindPopup(popupEl);\n }\n\n // Live precipitation radar overlay (RainViewer — free, keyless).\n try {\n const res = await fetch('https://api.rainviewer.com/public/weather-maps.json', { signal: controller.signal });\n const data = (await res.json()) as {\n host?: string;\n radar?: { past?: Array<{ path?: string; time?: number }> };\n };\n const frames = data.radar?.past ?? [];\n const latest = frames[frames.length - 1];\n // The map may have been removed during the await — guard before touching it.\n if (!cancelled && map && data.host && latest?.path) {\n // RainViewer radar only has tiles up to z7; cap maxNativeZoom so Leaflet\n // upscales from z7 instead of requesting the \"Zoom Level Not Supported\" placeholder.\n const radarLayer = L.tileLayer(`${data.host}${latest.path}/256/{z}/{x}/{y}/4/1_1.png`, {\n opacity: 0.55,\n maxZoom: 18,\n maxNativeZoom: 7,\n }).addTo(map);\n layerControl.addOverlay(radarLayer, radarLayerLabel);\n if (typeof latest.time === 'number') setRadarUpdatedAt(new Date(latest.time * 1000));\n }\n } catch {\n /* radar overlay is best-effort */\n }\n\n if (!cancelled) {\n setStatus('ready');\n window.setTimeout(() => map?.invalidateSize(), 80);\n }\n })().catch(() => {\n if (!cancelled) setStatus('error');\n });\n\n return () => {\n cancelled = true;\n controller.abort();\n clearUserLocation();\n removeSearchedPlaceMarker();\n map?.remove();\n mapRef.current = null;\n farmCenterRef.current = null;\n };\n }, [\n centerLat,\n centerLng,\n clearUserLocation,\n location,\n radarLayerLabel,\n removeSearchedPlaceMarker,\n streetsLayerLabel,\n terrainLayerLabel,\n ]);\n\n return (\n <div className=\"relative\">\n <div className=\"mb-3 flex flex-wrap items-center gap-2\">\n <form onSubmit={handleSearchPlace} className=\"flex min-w-[min(100%,22rem)] flex-1 flex-wrap items-center gap-2\">\n <div className=\"relative min-w-[12rem] flex-1\">\n <Search className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary\" />\n <input\n type=\"search\"\n value={searchQuery}\n onChange={(event) => setSearchQuery(event.target.value)}\n disabled={status !== 'ready' || searching}\n placeholder={t('healthybowl.weather.map.search.placeholder', 'Search city or place...')}\n aria-label={t('healthybowl.weather.map.search.label', 'Search map by place')}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface py-2 pl-9 pr-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] disabled:cursor-not-allowed disabled:opacity-60\"\n />\n </div>\n <Button type=\"submit\" variant=\"outline\" size=\"sm\" disabled={status !== 'ready' || searching}>\n <Search className=\"h-4 w-4\" />{' '}\n {searching\n ? t('healthybowl.weather.map.search.searching', 'Searching...')\n : t('healthybowl.weather.map.search.action', 'Search')}\n </Button>\n {searchedPlace && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={clearSearchedPlace}\n aria-label={t('healthybowl.weather.map.search.clear', 'Clear searched place')}\n title={t('healthybowl.weather.map.search.clear', 'Clear searched place')}\n >\n <X className=\"h-4 w-4\" />\n </Button>\n )}\n </form>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={focusFarm}\n disabled={!hasFarmCenter || status === 'loading'}\n title={t('healthybowl.weather.map.actions.focusFarm.title', 'Focus the weather map on the farm')}\n aria-label={t('healthybowl.weather.map.actions.focusFarm.title', 'Focus the weather map on the farm')}\n >\n <MapPinned className=\"h-4 w-4\" /> {t('healthybowl.weather.map.actions.focusFarm', 'Farm')}\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleLocateMe}\n disabled={locating || status !== 'ready'}\n title={t('healthybowl.weather.map.actions.locateMe.title', 'Go to my current location')}\n aria-label={t('healthybowl.weather.map.actions.locateMe.title', 'Go to my current location')}\n >\n <LocateFixed className=\"h-4 w-4\" />{' '}\n {locating\n ? t('healthybowl.weather.map.actions.locating', 'Locating...')\n : t('healthybowl.weather.map.actions.locateMe', 'My location')}\n </Button>\n </div>\n <div\n ref={containerRef}\n className=\"h-[60vh] max-h-[460px] w-full overflow-hidden rounded-md border border-border-subtle bg-bg-sunken\"\n />\n {status === 'loading' && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center rounded-md bg-bg-surface/60 text-sm text-text-secondary\">\n Loading map…\n </div>\n )}\n {status === 'error' && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center rounded-md bg-bg-surface/80 px-4 text-center text-sm text-text-secondary\">\n Weather map needs an internet connection and couldn’t load.\n </div>\n )}\n {status === 'ready' && !hasFarmCenter && (\n <div className=\"pointer-events-none absolute left-1/2 top-16 z-[400] -translate-x-1/2 rounded-full bg-bg-surface/90 px-3 py-1.5 text-xs text-text-secondary shadow-sm\">\n {t('healthybowl.weather.map.noLocation', 'No farm coordinates available')}\n </div>\n )}\n <p className=\"mt-2 text-xs text-text-secondary\">\n Live precipitation radar via RainViewer · base map © OpenStreetMap\n {location ? ` · centered on ${location}` : ''}\n {searchedPlace ? ` · viewing ${searchedPlace}` : ''}\n {radarUpdatedAt\n ? ` · radar ${radarUpdatedAt.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`\n : ''}\n </p>\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;mCAgBM,IAAc,oDAEd,IAAkB,uDAClB,IAAoB,GACpB,IAAqB,IACrB,IAAuB,IAEvB,KAAsB,MAC1B,GACE,KACA,OAAO,SAAS,EAAM,IAAI,IAC1B,OAAO,SAAS,EAAM,IAAI,IAC1B,EAAM,OAAO,OACb,EAAM,OAAO,MACb,EAAM,OAAO,QACb,EAAM,OAAO,QACZ,EAAM,QAAQ,KAAK,EAAM,QAAQ;AAStC,SAAS,IAAyB;AAChC,KAAI,SAAS,eAAe,cAAc,CAAE;CAC5C,IAAM,IAAO,SAAS,cAAc,OAAO;AAM3C,CALA,EAAK,KAAK,eACV,EAAK,MAAM,cACX,EAAK,OAAO,GACZ,EAAK,YAAY,GACjB,EAAK,cAAc,aACnB,SAAS,KAAK,YAAY,EAAK;;AAQjC,IAAa,KAAmC,EAAE,aAAU,gBAAa;CACvE,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,WAAQ,UAAO,gBAAY,GAAU,EACvC,IAAe,EAAuB,KAAK,EAC3C,IAAS,EAAqB,KAAK,EACnC,IAAgB,EAAwB,KAAK,EAC7C,IAAwB,EAA8B,KAAK,EAC3D,IAAwB,EAAwB,KAAK,EAC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GAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAClD"}
1
+ {"version":3,"file":"WeatherMap.js","names":[],"sources":["../../../src/healthybowl/components/WeatherMap.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type FC, type FormEvent } from 'react';\nimport L from 'leaflet';\nimport { LocateFixed, MapPinned, Search, X } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { geocodePlace } from '../utils/geocode';\nimport { useToast } from '../hooks/useToast';\nimport { ToastContainer } from './Toast';\n\ninterface WeatherMapProps {\n /** Resolved place name (from the weather data) used to center the map. */\n location: string;\n /** Backend-resolved farm/weather coordinates. Preferred over client-side geocoding. */\n center?: { lat: number; lng: number } | null;\n}\n\nconst LEAFLET_CSS = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css';\n// SRI for leaflet@1.9.4/dist/leaflet.css (immutable versioned URL) — guards against a CDN compromise.\nconst LEAFLET_CSS_SRI = 'sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=';\nconst FARM_WEATHER_ZOOM = 7;\nconst USER_LOCATION_ZOOM = 10;\nconst SEARCH_LOCATION_ZOOM = 10;\n\nconst isUsableCoordinate = (value?: { lat: number; lng: number } | null): value is { lat: number; lng: number } =>\n Boolean(\n value &&\n Number.isFinite(value.lat) &&\n Number.isFinite(value.lng) &&\n value.lat >= -90 &&\n value.lat <= 90 &&\n value.lng >= -180 &&\n value.lng <= 180 &&\n (value.lat !== 0 || value.lng !== 0)\n );\n\n/**\n * Inject Leaflet's stylesheet at runtime. The MFE library build doesn't deliver\n * a component's bundled CSS to the host shell (the host styles come from its own\n * Tailwind), so we load Leaflet's CSS from a CDN instead — consistent with the\n * map being an inherently online feature (tiles + radar).\n */\nfunction ensureLeafletCss(): void {\n if (document.getElementById('leaflet-css')) return;\n const link = document.createElement('link');\n link.id = 'leaflet-css';\n link.rel = 'stylesheet';\n link.href = LEAFLET_CSS;\n link.integrity = LEAFLET_CSS_SRI;\n link.crossOrigin = 'anonymous';\n document.head.appendChild(link);\n}\n\n/**\n * Interactive weather map: OpenStreetMap base + live precipitation radar overlay\n * (RainViewer, keyless), centered on backend-resolved farm coordinates when\n * available, then client-geocoded from the weather location as a fallback.\n */\nexport const WeatherMap: FC<WeatherMapProps> = ({ location, center }) => {\n const { t } = useI18n();\n const { toasts, toast, dismiss } = useToast();\n const containerRef = useRef<HTMLDivElement>(null);\n const mapRef = useRef<L.Map | null>(null);\n const farmCenterRef = useRef<L.LatLng | null>(null);\n const userLocationMarkerRef = useRef<L.CircleMarker | null>(null);\n const userAccuracyCircleRef = useRef<L.Circle | null>(null);\n const searchedPlaceMarkerRef = useRef<L.CircleMarker | null>(null);\n const [status, setStatus] = useState<'loading' | 'ready' | 'error'>('loading');\n const [hasFarmCenter, setHasFarmCenter] = useState(false);\n const [locating, setLocating] = useState(false);\n const [searchQuery, setSearchQuery] = useState('');\n const [searching, setSearching] = useState(false);\n const [searchedPlace, setSearchedPlace] = useState<string | null>(null);\n const [radarUpdatedAt, setRadarUpdatedAt] = useState<Date | null>(null);\n const streetsLayerLabel = t('healthybowl.weather.map.layers.streets', 'Streets');\n const terrainLayerLabel = t('healthybowl.weather.map.layers.terrain', 'Terrain');\n const radarLayerLabel = t('healthybowl.weather.map.layers.radar', 'Live radar');\n\n // Depend on the primitive coordinates, not the `center` object: the parent\n // re-renders on every weather/radar refresh and hands us a fresh {lat,lng}\n // object with identical values. Keying the map-creation effect on the object\n // reference re-created the whole Leaflet map on each refresh, snapping the view\n // back to the farm and wiping any place the user had searched for.\n const usableCenter = isUsableCoordinate(center) ? center : null;\n const centerLat = usableCenter ? usableCenter.lat : null;\n const centerLng = usableCenter ? usableCenter.lng : null;\n\n const clearUserLocation = useCallback(() => {\n const map = mapRef.current;\n if (userLocationMarkerRef.current && map) map.removeLayer(userLocationMarkerRef.current);\n if (userAccuracyCircleRef.current && map) map.removeLayer(userAccuracyCircleRef.current);\n userLocationMarkerRef.current = null;\n userAccuracyCircleRef.current = null;\n }, []);\n\n const removeSearchedPlaceMarker = useCallback(() => {\n const map = mapRef.current;\n if (searchedPlaceMarkerRef.current && map) map.removeLayer(searchedPlaceMarkerRef.current);\n searchedPlaceMarkerRef.current = null;\n }, []);\n\n const clearSearchedPlace = useCallback(() => {\n removeSearchedPlaceMarker();\n setSearchedPlace(null);\n }, [removeSearchedPlaceMarker]);\n\n const focusFarm = useCallback(() => {\n const map = mapRef.current;\n const farmCenter = farmCenterRef.current;\n if (!map || !farmCenter) return;\n map.flyTo(farmCenter, FARM_WEATHER_ZOOM, { duration: 0.6 });\n }, []);\n\n const handleLocateMe = useCallback(() => {\n const map = mapRef.current;\n if (!map) return;\n if (typeof navigator === 'undefined' || !navigator.geolocation) {\n toast({\n title: t('healthybowl.weather.map.toast.locationUnsupported.title', 'Location unavailable'),\n description: t(\n 'healthybowl.weather.map.toast.locationUnsupported.description',\n 'This browser does not support device location.'\n ),\n variant: 'warning',\n });\n return;\n }\n\n setLocating(true);\n navigator.geolocation.getCurrentPosition(\n (position) => {\n const latlng: L.LatLngExpression = [position.coords.latitude, position.coords.longitude];\n clearUserLocation();\n userAccuracyCircleRef.current = L.circle(latlng, {\n radius: Math.max(10, position.coords.accuracy || 0),\n color: '#2563eb',\n fillColor: '#3b82f6',\n fillOpacity: 0.12,\n opacity: 0.45,\n weight: 1,\n }).addTo(map);\n userLocationMarkerRef.current = L.circleMarker(latlng, {\n radius: 7,\n color: '#ffffff',\n weight: 2,\n fillColor: '#2563eb',\n fillOpacity: 1,\n }).addTo(map);\n map.flyTo(latlng, Math.max(map.getZoom(), USER_LOCATION_ZOOM), { duration: 0.75 });\n setLocating(false);\n },\n (error) => {\n const blocked = error.code === error.PERMISSION_DENIED;\n toast({\n title: blocked\n ? t('healthybowl.weather.map.toast.locationBlocked.title', 'Location blocked')\n : t('healthybowl.weather.map.toast.locationFailed.title', 'Could not get location'),\n description: blocked\n ? t(\n 'healthybowl.weather.map.toast.locationBlocked.description',\n 'Allow location access in the browser, then try again.'\n )\n : t(\n 'healthybowl.weather.map.toast.locationFailed.description',\n 'Make sure GPS is enabled and the page is open over HTTPS.'\n ),\n variant: 'warning',\n });\n setLocating(false);\n },\n { enableHighAccuracy: true, timeout: 12000, maximumAge: 60000 }\n );\n }, [clearUserLocation, t, toast]);\n\n const handleSearchPlace = useCallback(\n async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n const map = mapRef.current;\n const place = searchQuery.trim();\n if (!place) {\n toast({\n title: t('healthybowl.weather.map.toast.searchRequired.title', 'Place required'),\n description: t(\n 'healthybowl.weather.map.toast.searchRequired.description',\n 'Enter a city, village, district, or region to view it on the map.'\n ),\n variant: 'warning',\n });\n return;\n }\n if (!map) return;\n\n setSearching(true);\n try {\n const hit = await geocodePlace(place);\n if (!hit) {\n toast({\n title: t('healthybowl.weather.map.toast.searchNotFound.title', 'Place not found'),\n description: t(\n 'healthybowl.weather.map.toast.searchNotFound.description',\n 'Try a more specific location name, such as city and state.'\n ),\n variant: 'warning',\n });\n return;\n }\n\n const label = [hit.name, hit.admin1, hit.country].filter(Boolean).join(', ') || place;\n const latlng: L.LatLngExpression = [hit.latitude, hit.longitude];\n removeSearchedPlaceMarker();\n const popupEl = document.createElement('span');\n popupEl.textContent = label;\n searchedPlaceMarkerRef.current = L.circleMarker(latlng, {\n radius: 8,\n color: '#ffffff',\n weight: 2,\n fillColor: '#0ea5e9',\n fillOpacity: 1,\n })\n .addTo(map)\n .bindPopup(popupEl)\n .openPopup();\n map.flyTo(latlng, Math.max(map.getZoom(), SEARCH_LOCATION_ZOOM), { duration: 0.75 });\n setSearchedPlace(label);\n } catch (err) {\n toast({\n title: t('healthybowl.weather.map.toast.searchFailed.title', 'Search failed'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setSearching(false);\n }\n },\n [removeSearchedPlaceMarker, searchQuery, t, toast]\n );\n\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return undefined;\n ensureLeafletCss();\n const controller = new AbortController();\n let map: L.Map | undefined;\n let cancelled = false;\n setStatus('loading');\n setHasFarmCenter(false);\n setRadarUpdatedAt(null);\n setSearchedPlace(null);\n farmCenterRef.current = null;\n\n void (async () => {\n const backendCenter = centerLat !== null && centerLng !== null ? { lat: centerLat, lng: centerLng } : null;\n const hit = backendCenter ? null : await geocodePlace(location, controller.signal);\n const located: [number, number] | null = backendCenter\n ? [backendCenter.lat, backendCenter.lng]\n : hit\n ? [hit.latitude, hit.longitude]\n : null;\n if (cancelled || !containerRef.current) return;\n const mapCenter: L.LatLngExpression = located ?? [20, 0];\n // z7 keeps the RainViewer radar at its native resolution (it has no tiles past z7)\n // while still framing the farm and its surrounding weather system.\n const zoom = located ? FARM_WEATHER_ZOOM : 2;\n farmCenterRef.current = located ? L.latLng(located[0], located[1]) : null;\n setHasFarmCenter(Boolean(located));\n\n map = L.map(el, { center: mapCenter, zoom, scrollWheelZoom: true });\n mapRef.current = map;\n const streetsLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\n attribution: '© OpenStreetMap contributors',\n maxZoom: 18,\n });\n const terrainLayer = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {\n attribution: '© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors',\n maxZoom: 17,\n });\n streetsLayer.addTo(map);\n const layerControl = L.control\n .layers(\n {\n [streetsLayerLabel]: streetsLayer,\n [terrainLayerLabel]: terrainLayer,\n },\n undefined,\n { collapsed: false }\n )\n .addTo(map);\n L.control.scale({ imperial: false }).addTo(map);\n\n if (located) {\n const icon = L.divIcon({\n className: 'hb-weather-marker',\n html:\n '<div style=\"width:16px;height:16px;border-radius:50% 50% 50% 0;transform:rotate(-45deg);' +\n 'background:var(--color-action-primary-bg, #16a34a);border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.4)\"></div>',\n iconSize: [16, 16],\n iconAnchor: [8, 16],\n });\n // bindPopup treats a string as HTML; pass a text node so the place name\n // can never be interpreted as markup (defense-in-depth against a tainted value).\n const popupEl = document.createElement('span');\n popupEl.textContent = location || 'Your farm';\n L.marker(mapCenter, { icon }).addTo(map).bindPopup(popupEl);\n }\n\n // Live precipitation radar overlay (RainViewer — free, keyless).\n try {\n const res = await fetch('https://api.rainviewer.com/public/weather-maps.json', { signal: controller.signal });\n const data = (await res.json()) as {\n host?: string;\n radar?: { past?: Array<{ path?: string; time?: number }> };\n };\n const frames = data.radar?.past ?? [];\n const latest = frames[frames.length - 1];\n // The map may have been removed during the await — guard before touching it.\n if (!cancelled && map && data.host && latest?.path) {\n // RainViewer radar only has tiles up to z7; cap maxNativeZoom so Leaflet\n // upscales from z7 instead of requesting the \"Zoom Level Not Supported\" placeholder.\n const radarLayer = L.tileLayer(`${data.host}${latest.path}/256/{z}/{x}/{y}/4/1_1.png`, {\n opacity: 0.55,\n maxZoom: 18,\n maxNativeZoom: 7,\n }).addTo(map);\n layerControl.addOverlay(radarLayer, radarLayerLabel);\n if (typeof latest.time === 'number') setRadarUpdatedAt(new Date(latest.time * 1000));\n }\n } catch {\n /* radar overlay is best-effort */\n }\n\n if (!cancelled) {\n setStatus('ready');\n window.setTimeout(() => map?.invalidateSize(), 80);\n }\n })().catch(() => {\n if (!cancelled) setStatus('error');\n });\n\n return () => {\n cancelled = true;\n controller.abort();\n clearUserLocation();\n removeSearchedPlaceMarker();\n map?.remove();\n mapRef.current = null;\n farmCenterRef.current = null;\n };\n }, [\n centerLat,\n centerLng,\n clearUserLocation,\n location,\n radarLayerLabel,\n removeSearchedPlaceMarker,\n streetsLayerLabel,\n terrainLayerLabel,\n ]);\n\n return (\n <div className=\"relative\">\n <div className=\"mb-3 flex flex-wrap items-center gap-2\">\n <form onSubmit={handleSearchPlace} className=\"flex min-w-[min(100%,22rem)] flex-1 flex-wrap items-center gap-2\">\n <div className=\"relative min-w-[12rem] flex-1\">\n <Search className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary\" />\n <input\n type=\"search\"\n value={searchQuery}\n onChange={(event) => setSearchQuery(event.target.value)}\n disabled={status !== 'ready' || searching}\n placeholder={t('healthybowl.weather.map.search.placeholder', 'Search city or place...')}\n aria-label={t('healthybowl.weather.map.search.label', 'Search map by place')}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface py-2 pl-9 pr-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] disabled:cursor-not-allowed disabled:opacity-60\"\n />\n </div>\n <Button type=\"submit\" variant=\"outline\" size=\"sm\" disabled={status !== 'ready' || searching}>\n <Search className=\"h-4 w-4\" />{' '}\n {searching\n ? t('healthybowl.weather.map.search.searching', 'Searching...')\n : t('healthybowl.weather.map.search.action', 'Search')}\n </Button>\n {searchedPlace && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={clearSearchedPlace}\n aria-label={t('healthybowl.weather.map.search.clear', 'Clear searched place')}\n title={t('healthybowl.weather.map.search.clear', 'Clear searched place')}\n >\n <X className=\"h-4 w-4\" />\n </Button>\n )}\n </form>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={focusFarm}\n disabled={!hasFarmCenter || status === 'loading'}\n title={t('healthybowl.weather.map.actions.focusFarm.title', 'Focus the weather map on the farm')}\n aria-label={t('healthybowl.weather.map.actions.focusFarm.title', 'Focus the weather map on the farm')}\n >\n <MapPinned className=\"h-4 w-4\" /> {t('healthybowl.weather.map.actions.focusFarm', 'Farm')}\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleLocateMe}\n disabled={locating || status !== 'ready'}\n title={t('healthybowl.weather.map.actions.locateMe.title', 'Go to my current location')}\n aria-label={t('healthybowl.weather.map.actions.locateMe.title', 'Go to my current location')}\n >\n <LocateFixed className=\"h-4 w-4\" />{' '}\n {locating\n ? t('healthybowl.weather.map.actions.locating', 'Locating...')\n : t('healthybowl.weather.map.actions.locateMe', 'My location')}\n </Button>\n </div>\n <div\n ref={containerRef}\n className=\"h-[60vh] max-h-[460px] w-full overflow-hidden rounded-md border border-border-subtle bg-bg-sunken\"\n />\n {status === 'loading' && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center rounded-md bg-bg-surface/60 text-sm text-text-secondary\">\n Loading map…\n </div>\n )}\n {status === 'error' && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center rounded-md bg-bg-surface/80 px-4 text-center text-sm text-text-secondary\">\n Weather map needs an internet connection and couldn’t load.\n </div>\n )}\n {status === 'ready' && !hasFarmCenter && (\n <div className=\"pointer-events-none absolute left-1/2 top-16 z-[400] -translate-x-1/2 rounded-full bg-bg-surface/90 px-3 py-1.5 text-xs text-text-secondary shadow-sm\">\n {t('healthybowl.weather.map.noLocation', 'No farm coordinates available')}\n </div>\n )}\n <p className=\"mt-2 text-xs text-text-secondary\">\n Live precipitation radar via RainViewer · base map © OpenStreetMap\n {location ? ` · centered on ${location}` : ''}\n {searchedPlace ? ` · viewing ${searchedPlace}` : ''}\n {radarUpdatedAt\n ? ` · radar ${radarUpdatedAt.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`\n : ''}\n </p>\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;mCAgBM,IAAc,oDAEd,IAAkB,uDAClB,IAAoB,GACpB,IAAqB,IACrB,IAAuB,IAEvB,KAAsB,MAC1B,GACE,KACA,OAAO,SAAS,EAAM,IAAI,IAC1B,OAAO,SAAS,EAAM,IAAI,IAC1B,EAAM,OAAO,OACb,EAAM,OAAO,MACb,EAAM,OAAO,QACb,EAAM,OAAO,QACZ,EAAM,QAAQ,KAAK,EAAM,QAAQ;AAStC,SAAS,KAAyB;AAChC,KAAI,SAAS,eAAe,cAAc,CAAE;CAC5C,IAAM,IAAO,SAAS,cAAc,OAAO;AAM3C,CALA,EAAK,KA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kBAAC,OAAD;IAAK,WAAU;cAAiJ;IAE1J,CAAA;GAEP,MAAW,WAAW,CAAC,KACtB,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAE,sCAAsC,gCAAgC;IACrE,CAAA;GAER,kBAAC,KAAD;IAAG,WAAU;cAAb;KAAgD;KAE7C,IAAW,kBAAkB,MAAa;KAC1C,IAAgB,cAAc,MAAkB;KAChD,IACG,YAAY,EAAe,mBAAmB,EAAE,EAAE;MAAE,MAAM;MAAW,QAAQ;MAAW,CAAC,KACzF;KACF;;GACJ,kBAAC,GAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAClD"}
@@ -1,28 +1,30 @@
1
- import { createContext as e, useContext as t } from "react";
2
- import { MemoryRouter as n } from "react-router-dom";
3
- import { jsx as r } from "react/jsx-runtime";
1
+ import { configureGeocoder as e } from "../utils/geocode.js";
2
+ import { createContext as t, useContext as n } from "react";
3
+ import { MemoryRouter as r } from "react-router-dom";
4
+ import { jsx as i } from "react/jsx-runtime";
4
5
  //#region src/healthybowl/context/HealthyBowlContext.tsx
5
- var i = e(null);
6
- function a() {
7
- let e = t(i);
6
+ var a = t(null);
7
+ function o() {
8
+ let e = n(a);
8
9
  if (!e) throw Error("useHealthyBowl must be used within a HealthyBowlProvider");
9
10
  return e;
10
11
  }
11
- var o = ({ children: e, basePath: t = "/", navigate: a = () => {}, currentUser: o, workspaceId: s = "", apiGatewayUrl: c = "", authToken: l = "" }) => {
12
- let u = {
13
- basePath: t,
14
- navigate: a,
15
- currentUser: o,
16
- workspaceId: s,
17
- apiGatewayUrl: c,
18
- authToken: l
19
- }, d = /* @__PURE__ */ r(i.Provider, {
20
- value: u,
21
- children: e
12
+ var s = ({ children: t, basePath: n = "/", navigate: o = () => {}, currentUser: s, workspaceId: c = "", apiGatewayUrl: l = "", authToken: u = "", googleMapsApiKey: d }) => {
13
+ e({ googleMapsApiKey: d });
14
+ let f = {
15
+ basePath: n,
16
+ navigate: o,
17
+ currentUser: s,
18
+ workspaceId: c,
19
+ apiGatewayUrl: l,
20
+ authToken: u
21
+ }, p = /* @__PURE__ */ i(a.Provider, {
22
+ value: f,
23
+ children: t
22
24
  });
23
- return t && t !== "/" ? d : /* @__PURE__ */ r(n, { children: d });
25
+ return n && n !== "/" ? p : /* @__PURE__ */ i(r, { children: p });
24
26
  };
25
27
  //#endregion
26
- export { o as HealthyBowlProvider, a as useHealthyBowl };
28
+ export { s as HealthyBowlProvider, o as useHealthyBowl };
27
29
 
28
30
  //# sourceMappingURL=HealthyBowlContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HealthyBowlContext.js","names":[],"sources":["../../../src/healthybowl/context/HealthyBowlContext.tsx"],"sourcesContent":["/**\n * HealthyBowl Context Provider\n * @module healthybowl\n */\n\nimport { createContext, useContext, type FC, type PropsWithChildren } from 'react';\nimport { MemoryRouter } from 'react-router-dom';\nimport type { HealthyBowlRootProps } from '../types';\n\ninterface HealthyBowlContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: HealthyBowlRootProps['currentUser'];\n workspaceId: string;\n apiGatewayUrl: string;\n authToken: string;\n}\n\nconst HealthyBowlContext = createContext<HealthyBowlContextValue | null>(null);\n\nexport function useHealthyBowl(): HealthyBowlContextValue {\n const context = useContext(HealthyBowlContext);\n if (!context) {\n throw new Error('useHealthyBowl must be used within a HealthyBowlProvider');\n }\n return context;\n}\n\nexport const HealthyBowlProvider: FC<PropsWithChildren<HealthyBowlRootProps>> = ({\n children,\n basePath = '/',\n navigate = () => {},\n currentUser,\n workspaceId = '',\n apiGatewayUrl = '',\n authToken = '',\n}) => {\n const contextValue: HealthyBowlContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n apiGatewayUrl,\n authToken,\n };\n\n const content = <HealthyBowlContext.Provider value={contextValue}>{children}</HealthyBowlContext.Provider>;\n\n // If basePath is provided, we're running inside the host shell (which has BrowserRouter)\n if (basePath && basePath !== '/') return content;\n\n // Standalone mode: wrap in MemoryRouter\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;AAkBA,IAAM,IAAqB,EAA8C,KAAK;AAE9E,SAAgB,IAA0C;CACxD,IAAM,IAAU,EAAW,EAAmB;AAC9C,KAAI,CAAC,EACH,OAAU,MAAM,2DAA2D;AAE7E,QAAO;;AAGT,IAAa,KAAoE,EAC/E,aACA,cAAW,KACX,oBAAiB,IACjB,gBACA,iBAAc,IACd,mBAAgB,IAChB,eAAY,SACR;CACJ,IAAM,IAAwC;EAC5C;EACA;EACA;EACA;EACA;EACA;EACD,EAEK,IAAU,kBAAC,EAAmB,UAApB;EAA6B,OAAO;EAAe;EAAuC,CAAA;AAM1G,QAHI,KAAY,MAAa,MAAY,IAGlC,kBAAC,GAAD,EAAA,UAAe,GAAuB,CAAA"}
1
+ {"version":3,"file":"HealthyBowlContext.js","names":[],"sources":["../../../src/healthybowl/context/HealthyBowlContext.tsx"],"sourcesContent":["/**\n * HealthyBowl Context Provider\n * @module healthybowl\n */\n\nimport { createContext, useContext, type FC, type PropsWithChildren } from 'react';\nimport { MemoryRouter } from 'react-router-dom';\nimport type { HealthyBowlRootProps } from '../types';\nimport { configureGeocoder } from '../utils/geocode';\n\ninterface HealthyBowlContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: HealthyBowlRootProps['currentUser'];\n workspaceId: string;\n apiGatewayUrl: string;\n authToken: string;\n}\n\nconst HealthyBowlContext = createContext<HealthyBowlContextValue | null>(null);\n\nexport function useHealthyBowl(): HealthyBowlContextValue {\n const context = useContext(HealthyBowlContext);\n if (!context) {\n throw new Error('useHealthyBowl must be used within a HealthyBowlProvider');\n }\n return context;\n}\n\nexport const HealthyBowlProvider: FC<PropsWithChildren<HealthyBowlRootProps>> = ({\n children,\n basePath = '/',\n navigate = () => {},\n currentUser,\n workspaceId = '',\n apiGatewayUrl = '',\n authToken = '',\n googleMapsApiKey,\n}) => {\n // Inject the host app's Google Maps key into the (non-React) geocoder. Done\n // synchronously in render (not useEffect) so it's set before child map effects\n // run — child effects fire before parent effects. Idempotent module assignment.\n configureGeocoder({ googleMapsApiKey });\n\n const contextValue: HealthyBowlContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n apiGatewayUrl,\n authToken,\n };\n\n const content = <HealthyBowlContext.Provider value={contextValue}>{children}</HealthyBowlContext.Provider>;\n\n // If basePath is provided, we're running inside the host shell (which has BrowserRouter)\n if (basePath && basePath !== '/') return content;\n\n // Standalone mode: wrap in MemoryRouter\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;AAmBA,IAAM,IAAqB,EAA8C,KAAK;AAE9E,SAAgB,IAA0C;CACxD,IAAM,IAAU,EAAW,EAAmB;AAC9C,KAAI,CAAC,EACH,OAAU,MAAM,2DAA2D;AAE7E,QAAO;;AAGT,IAAa,KAAoE,EAC/E,aACA,cAAW,KACX,oBAAiB,IACjB,gBACA,iBAAc,IACd,mBAAgB,IAChB,eAAY,IACZ,0BACI;AAIJ,GAAkB,EAAE,qBAAkB,CAAC;CAEvC,IAAM,IAAwC;EAC5C;EACA;EACA;EACA;EACA;EACA;EACD,EAEK,IAAU,kBAAC,EAAmB,UAApB;EAA6B,OAAO;EAAe;EAAuC,CAAA;AAM1G,QAHI,KAAY,MAAa,MAAY,IAGlC,kBAAC,GAAD,EAAA,UAAe,GAAuB,CAAA"}
@@ -1,12 +1,12 @@
1
- import { useBasePath as e } from "../../hooks/useBasePath.js";
2
- import { PageLayout as t } from "../../components/PageLayout.js";
3
- import { StatusBadge as n } from "../../components/StatusBadge.js";
4
- import { EmptyState as r } from "../../components/EmptyState.js";
5
- import { ErrorState as i } from "../../components/ErrorState.js";
6
- import { ToastContainer as a } from "../../components/Toast.js";
7
- import { PageLoader as ee } from "../../components/PageLoader.js";
8
- import { Modal as o } from "../../components/Modal.js";
9
- import { geocodePlace as s } from "../../utils/geocode.js";
1
+ import { geocodePlace as e } from "../../utils/geocode.js";
2
+ import { useBasePath as t } from "../../hooks/useBasePath.js";
3
+ import { PageLayout as n } from "../../components/PageLayout.js";
4
+ import { StatusBadge as r } from "../../components/StatusBadge.js";
5
+ import { EmptyState as i } from "../../components/EmptyState.js";
6
+ import { ErrorState as a } from "../../components/ErrorState.js";
7
+ import { ToastContainer as ee } from "../../components/Toast.js";
8
+ import { PageLoader as o } from "../../components/PageLoader.js";
9
+ import { Modal as s } from "../../components/Modal.js";
10
10
  import { useToast as c } from "../../hooks/useToast.js";
11
11
  import { WeatherMap as l } from "../../components/WeatherMap.js";
12
12
  import "../../components/index.js";
@@ -37,7 +37,7 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
37
37
  default: return w;
38
38
  }
39
39
  }, le = (e) => e <= 2 ? "low" : e <= 5 ? "moderate" : e <= 7 ? "high" : e <= 10 ? "veryHigh" : "extreme", M = () => {
40
- let { weatherData: y, farm: b, createFarm: x, updateFarm: w, loadings: M, errors: N, refetch: P } = te(), [F, I] = f(!1), [ue, L] = f(!1), [R, z] = f(""), [B, V] = f(!1), H = oe(), { buildPath: U } = e(), { t: W } = p(), G = u((e, t, n) => {
40
+ let { weatherData: y, farm: b, createFarm: x, updateFarm: w, loadings: M, errors: N, refetch: P } = te(), [F, I] = f(!1), [ue, L] = f(!1), [R, z] = f(""), [B, V] = f(!1), H = oe(), { buildPath: U } = t(), { t: W } = p(), G = u((e, t, n) => {
41
41
  let r = W(e), i = r === e ? t : r;
42
42
  return n ? Object.entries(n).reduce((e, [t, n]) => e.replace(`{{${t}}}`, String(n)), i) : i;
43
43
  }, [W]), { toasts: de, toast: K, dismiss: fe } = c(), q = y?.current ?? {
@@ -72,8 +72,8 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
72
72
  }, [G]), $ = u(() => {
73
73
  z(b.location ?? ""), L(!0);
74
74
  }, [b.location]), he = u(async () => {
75
- let e = R.trim();
76
- if (!e) {
75
+ let t = R.trim();
76
+ if (!t) {
77
77
  K({
78
78
  title: G("healthybowl.weather.overview.location.toast.required.title", "Location required"),
79
79
  description: G("healthybowl.weather.overview.location.toast.required.description", "Enter a town, city, or region to set your farm location."),
@@ -83,29 +83,29 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
83
83
  }
84
84
  V(!0);
85
85
  try {
86
- let t = await s(e), n = t ? {
87
- latitude: t.latitude,
88
- longitude: t.longitude
86
+ let n = await e(t), r = n ? {
87
+ latitude: n.latitude,
88
+ longitude: n.longitude
89
89
  } : {};
90
90
  b.id ? await w({
91
91
  id: b.id,
92
- location: e,
93
- ...n
92
+ location: t,
93
+ ...r
94
94
  }) : await x({
95
95
  name: G("healthybowl.weather.overview.location.defaultFarmName", "My Farm"),
96
- location: e,
96
+ location: t,
97
97
  owner: "",
98
98
  totalArea: 0,
99
99
  areaUnit: "acres",
100
100
  organicCertified: !1,
101
- ...n
101
+ ...r
102
102
  }), K({
103
103
  title: G("healthybowl.weather.overview.location.toast.saved.title", "Location set"),
104
- description: t ? G("healthybowl.weather.overview.location.toast.saved.resolved", "Weather will load for {{place}}.", { place: [
105
- t.name,
106
- t.admin1,
107
- t.country
108
- ].filter(Boolean).join(", ") || e }) : G("healthybowl.weather.overview.location.toast.saved.unresolved", "Saved \"{{place}}\". We could not resolve exact coordinates — the server will try to geocode it.", { place: e }),
104
+ description: n ? G("healthybowl.weather.overview.location.toast.saved.resolved", "Weather will load for {{place}}.", { place: [
105
+ n.name,
106
+ n.admin1,
107
+ n.country
108
+ ].filter(Boolean).join(", ") || t }) : G("healthybowl.weather.overview.location.toast.saved.unresolved", "Saved \"{{place}}\". We could not resolve exact coordinates — the server will try to geocode it.", { place: t }),
109
109
  variant: "success"
110
110
  }), L(!1), await P();
111
111
  } catch (e) {
@@ -227,7 +227,7 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
227
227
  Y,
228
228
  G
229
229
  ]);
230
- return /* @__PURE__ */ k(t, {
230
+ return /* @__PURE__ */ k(n, {
231
231
  title: G("healthybowl.weather.overview.title", "Weather Dashboard"),
232
232
  description: G("healthybowl.weather.overview.description", "Real-time weather data and forecasts for {{location}}", { location: X }),
233
233
  purpose: "Today's conditions and the days ahead for your farm in one view. Check the weather before you head out, and jump into the full forecast, history or alerts when you need to plan or react.",
@@ -260,7 +260,7 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
260
260
  children: [/* @__PURE__ */ O(C, { className: "h-4 w-4 text-text-secondary" }), G("healthybowl.weather.overview.actions.changeLocation", "Change location")]
261
261
  }) : void 0,
262
262
  children: [
263
- M.weather ? /* @__PURE__ */ O(ee, {}) : N.weather ? /* @__PURE__ */ O(i, { onRetry: P }) : me ? /* @__PURE__ */ O(r, {
263
+ M.weather ? /* @__PURE__ */ O(o, {}) : N.weather ? /* @__PURE__ */ O(a, { onRetry: P }) : me ? /* @__PURE__ */ O(i, {
264
264
  illustration: "empty-generic",
265
265
  title: G("healthybowl.weather.overview.emptyState.title", "No farm location set"),
266
266
  description: G("healthybowl.weather.overview.emptyState.description", "Weather forecasts need a location. Set your farm location to see real-time conditions, a 7-day forecast, and farming recommendations."),
@@ -328,7 +328,7 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
328
328
  children: [/* @__PURE__ */ O("h3", {
329
329
  className: "text-sm font-medium text-text-primary",
330
330
  children: e.title
331
- }), /* @__PURE__ */ O(n, {
331
+ }), /* @__PURE__ */ O(r, {
332
332
  label: e.severity,
333
333
  variant: se(e.severity)
334
334
  })]
@@ -630,7 +630,7 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
630
630
  })]
631
631
  })
632
632
  ] }),
633
- /* @__PURE__ */ O(o, {
633
+ /* @__PURE__ */ O(s, {
634
634
  open: F,
635
635
  onClose: () => I(!1),
636
636
  title: G("healthybowl.weather.overview.map.title", "Weather Map"),
@@ -641,7 +641,7 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
641
641
  center: pe
642
642
  })
643
643
  }),
644
- /* @__PURE__ */ O(o, {
644
+ /* @__PURE__ */ O(s, {
645
645
  open: ue,
646
646
  onClose: () => L(!1),
647
647
  title: G("healthybowl.weather.overview.location.modal.title", "Set farm location"),
@@ -676,7 +676,7 @@ var se = (e) => e === "extreme" || e === "severe" ? "error" : e === "moderate" ?
676
676
  })
677
677
  ] })
678
678
  }),
679
- /* @__PURE__ */ O(a, {
679
+ /* @__PURE__ */ O(ee, {
680
680
  toasts: de,
681
681
  onDismiss: fe
682
682
  })
@@ -1 +1 @@
1
- {"version":3,"file":"WeatherOverviewPage.js","names":[],"sources":["../../../../src/healthybowl/pages/weather/WeatherOverviewPage.tsx"],"sourcesContent":["import { useMemo, useCallback, useState, type FC } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Cloud,\n CloudRain,\n Sun,\n CloudLightning,\n Wind,\n Droplets,\n Eye,\n Gauge,\n AlertTriangle,\n TrendingUp,\n Calendar,\n Bell,\n MapPin,\n ChevronRight,\n ArrowUp,\n ArrowDown,\n Loader2,\n} from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, StatusBadge, ErrorState, PageLoader, Modal, WeatherMap, EmptyState } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { geocodePlace } from '../../utils/geocode';\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 getWeatherIcon = (condition: string) => {\n switch (condition.toLowerCase()) {\n case 'sunny':\n case 'clear':\n return Sun;\n case 'partly cloudy':\n return Cloud;\n case 'rain':\n return CloudRain;\n case 'thunderstorm':\n return CloudLightning;\n case 'cloudy':\n return Cloud;\n default:\n return Sun;\n }\n};\n\ntype UVLevel = 'low' | 'moderate' | 'high' | 'veryHigh' | 'extreme';\n\nconst getUVLevel = (uv: number): UVLevel => {\n if (uv <= 2) return 'low';\n if (uv <= 5) return 'moderate';\n if (uv <= 7) return 'high';\n if (uv <= 10) return 'veryHigh';\n return 'extreme';\n};\n\nexport const WeatherOverviewPage: FC = () => {\n const { weatherData, farm, createFarm, updateFarm, loadings, errors, refetch } = useHealthyBowlData();\n const [mapOpen, setMapOpen] = useState(false);\n const [locationOpen, setLocationOpen] = useState(false);\n const [locationInput, setLocationInput] = useState('');\n const [savingLocation, setSavingLocation] = useState(false);\n\n const navigate = useNavigate();\n // buildPath gives absolute MFE paths; bare navigate(buildPath('weather/forecast')) resolves\n // relative to /healthybowl/weather → /healthybowl/forecast (404).\n const { buildPath } = useBasePath();\n const { t: translate } = useI18n();\n const t = useCallback(\n (key: string, fallback: string, vars?: Record<string, string | number>): string => {\n const resolved = translate(key);\n const base = resolved === key ? fallback : resolved;\n if (!vars) return base;\n return Object.entries(vars).reduce(\n (str, [varKey, varValue]) => str.replace(`{{${varKey}}}`, String(varValue)),\n base\n );\n },\n [translate]\n );\n const { toasts, toast, dismiss } = useToast();\n const defaultCurrent = {\n temperature: 0,\n condition: 'N/A',\n feelsLike: 0,\n humidity: 0,\n windSpeed: 0,\n windDirection: '',\n uvIndex: 0,\n pressure: 0,\n visibility: 0,\n icon: '',\n };\n const current = weatherData?.current ?? defaultCurrent;\n const forecast = weatherData?.forecast ?? [];\n const alerts = weatherData?.alerts ?? [];\n const location = weatherData?.location ?? '';\n const weatherMapCenter =\n typeof weatherData?.latitude === 'number' && typeof weatherData?.longitude === 'number'\n ? { lat: weatherData.latitude, lng: weatherData.longitude }\n : null;\n\n // No resolved location AND no forecast points => the svc has nowhere to fetch\n // weather for. Render an honest empty-state with a CTA rather than the\n // all-zeros default that looks like real (but fake) data.\n const needsLocation = location === '' && forecast.length === 0;\n const todayForecast =\n forecast[0] ??\n ({\n high: current.temperature,\n low: current.temperature,\n precipitation: 0,\n humidity: current.humidity,\n windSpeed: current.windSpeed,\n } as const);\n\n const uvLabel = useCallback(\n (uv: number): string => {\n const level = getUVLevel(uv);\n const labels: Record<UVLevel, string> = {\n low: t('healthybowl.weather.overview.uv.low', 'Low'),\n moderate: t('healthybowl.weather.overview.uv.moderate', 'Moderate'),\n high: t('healthybowl.weather.overview.uv.high', 'High'),\n veryHigh: t('healthybowl.weather.overview.uv.veryHigh', 'Very High'),\n extreme: t('healthybowl.weather.overview.uv.extreme', 'Extreme'),\n };\n return labels[level];\n },\n [t]\n );\n\n const openLocationModal = useCallback(() => {\n setLocationInput(farm.location ?? '');\n setLocationOpen(true);\n }, [farm.location]);\n\n // Set the farm's weather location: geocode the free-text place client-side\n // (Open-Meteo, keyless), then persist via updateFarm (or createFarm when no\n // farm exists yet) with the resolved lat/lng so the svc can fetch weather for\n // the new place, and refetch the weather query.\n const handleSaveLocation = useCallback(async () => {\n const place = locationInput.trim();\n if (!place) {\n toast({\n title: t('healthybowl.weather.overview.location.toast.required.title', 'Location required'),\n description: t(\n 'healthybowl.weather.overview.location.toast.required.description',\n 'Enter a town, city, or region to set your farm location.'\n ),\n variant: 'warning',\n });\n return;\n }\n setSavingLocation(true);\n try {\n const hit = await geocodePlace(place);\n const coords = hit ? { latitude: hit.latitude, longitude: hit.longitude } : {};\n if (farm.id) {\n await updateFarm({ id: farm.id, location: place, ...coords });\n } else {\n // Minimal farm bootstrap so weather has a home; the profile page fills the rest.\n await createFarm({\n name: t('healthybowl.weather.overview.location.defaultFarmName', 'My Farm'),\n location: place,\n owner: '',\n totalArea: 0,\n areaUnit: 'acres',\n organicCertified: false,\n ...coords,\n });\n }\n toast({\n title: t('healthybowl.weather.overview.location.toast.saved.title', 'Location set'),\n description: hit\n ? t('healthybowl.weather.overview.location.toast.saved.resolved', 'Weather will load for {{place}}.', {\n place: [hit.name, hit.admin1, hit.country].filter(Boolean).join(', ') || place,\n })\n : t(\n 'healthybowl.weather.overview.location.toast.saved.unresolved',\n 'Saved \"{{place}}\". We could not resolve exact coordinates — the server will try to geocode it.',\n { place }\n ),\n variant: 'success',\n });\n setLocationOpen(false);\n await refetch();\n } catch (err) {\n toast({\n title: t('healthybowl.weather.overview.location.toast.failed.title', 'Could not set location'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setSavingLocation(false);\n }\n }, [locationInput, farm.id, updateFarm, createFarm, refetch, toast, t]);\n\n // Derive farming recommendations from actual weather conditions\n const farmingRecommendations = useMemo(() => {\n const recs: { id: string; title: string; description: string; icon: typeof TrendingUp; iconColor: string }[] = [];\n if (current.humidity >= 40 && current.humidity <= 70 && current.temperature >= 15 && current.temperature <= 30) {\n recs.push({\n id: 'goodIrrigation',\n title: t('healthybowl.weather.overview.recommendations.goodIrrigation.title', 'Good conditions for irrigation'),\n description: t(\n 'healthybowl.weather.overview.recommendations.goodIrrigation.description',\n 'Humidity at {{humidity}}% and {{temperature}}°C are optimal for watering crops',\n { humidity: current.humidity, temperature: current.temperature }\n ),\n icon: TrendingUp,\n iconColor: 'text-success',\n });\n } else if (current.humidity > 70) {\n recs.push({\n id: 'skipIrrigation',\n title: t('healthybowl.weather.overview.recommendations.skipIrrigation.title', 'Skip irrigation today'),\n description: t(\n 'healthybowl.weather.overview.recommendations.skipIrrigation.description',\n 'Humidity is high at {{humidity}}% — soil moisture is likely adequate',\n { humidity: current.humidity }\n ),\n icon: Droplets,\n iconColor: 'text-info',\n });\n } else {\n recs.push({\n id: 'increaseIrrigation',\n title: t('healthybowl.weather.overview.recommendations.increaseIrrigation.title', 'Increase irrigation'),\n description: t(\n 'healthybowl.weather.overview.recommendations.increaseIrrigation.description',\n 'Low humidity at {{humidity}}% — crops may need extra watering',\n { humidity: current.humidity }\n ),\n icon: AlertTriangle,\n iconColor: 'text-warning',\n });\n }\n const rainForecast = forecast.find((d) => d.precipitation > 50);\n if (rainForecast) {\n recs.push({\n id: 'heavyRain',\n title: t('healthybowl.weather.overview.recommendations.heavyRain.title', 'Prepare for heavy rain'),\n description: t(\n 'healthybowl.weather.overview.recommendations.heavyRain.description',\n '{{precipitation}}% precipitation expected on {{day}} — ensure proper drainage',\n {\n precipitation: rainForecast.precipitation,\n day: new Date(rainForecast.date).toLocaleDateString('en-US', { weekday: 'short' }),\n }\n ),\n icon: AlertTriangle,\n iconColor: 'text-warning',\n });\n }\n if (current.windSpeed > 20) {\n recs.push({\n id: 'windSensitive',\n title: t('healthybowl.weather.overview.recommendations.windSensitive.title', 'Monitor wind-sensitive crops'),\n description: t(\n 'healthybowl.weather.overview.recommendations.windSensitive.description',\n 'Wind at {{windSpeed}} km/h {{windDirection}} — check support structures for tall crops',\n { windSpeed: current.windSpeed, windDirection: current.windDirection }\n ),\n icon: Wind,\n iconColor: 'text-info',\n });\n }\n if (current.uvIndex >= 8) {\n recs.push({\n id: 'highUV',\n title: t('healthybowl.weather.overview.recommendations.highUV.title', 'High UV exposure'),\n description: t(\n 'healthybowl.weather.overview.recommendations.highUV.description',\n 'UV index at {{uvIndex}} ({{uvLabel}}) — consider shade protection for sensitive crops',\n { uvIndex: current.uvIndex, uvLabel: uvLabel(current.uvIndex) }\n ),\n icon: AlertTriangle,\n iconColor: 'text-status-error-text',\n });\n }\n if (recs.length === 0) {\n recs.push({\n id: 'stable',\n title: t('healthybowl.weather.overview.recommendations.stable.title', 'Conditions are stable'),\n description: t(\n 'healthybowl.weather.overview.recommendations.stable.description',\n 'No immediate weather concerns for farming operations'\n ),\n icon: TrendingUp,\n iconColor: 'text-success',\n });\n }\n return recs;\n }, [current, forecast, t, uvLabel]);\n\n // Derive weather impact metrics from forecast/alert data\n const weatherImpactMetrics = useMemo(() => {\n const levelLow = t('healthybowl.weather.overview.impact.levels.low', 'Low');\n const levelModerate = t('healthybowl.weather.overview.impact.levels.moderate', 'Moderate');\n const levelHigh = t('healthybowl.weather.overview.impact.levels.high', 'High');\n\n const tempScore =\n current.temperature >= 15 && current.temperature <= 30\n ? 90\n : current.temperature >= 10 && current.temperature <= 35\n ? 60\n : 30;\n const humidityScore = current.humidity >= 40 && current.humidity <= 70 ? 85 : 50;\n const growthPercent = Math.round((tempScore + humidityScore) / 2);\n const growthLevel =\n growthPercent >= 80\n ? t('healthybowl.weather.overview.impact.levels.excellent', 'Excellent')\n : growthPercent >= 60\n ? t('healthybowl.weather.overview.impact.levels.good', 'Good')\n : growthPercent >= 40\n ? levelModerate\n : t('healthybowl.weather.overview.impact.levels.poor', 'Poor');\n const growthColor = growthPercent >= 60 ? 'bg-success' : growthPercent >= 40 ? 'bg-warning' : 'bg-status-error-bg';\n\n const severeAlerts = alerts.filter((a) => a.severity === 'extreme' || a.severity === 'severe').length;\n const diseasePercent = Math.min(100, Math.round((current.humidity / 100) * 60 + severeAlerts * 15));\n const diseaseLevel = diseasePercent >= 70 ? levelHigh : diseasePercent >= 40 ? levelModerate : levelLow;\n const diseaseColor =\n diseasePercent >= 70 ? 'bg-status-error-bg' : diseasePercent >= 40 ? 'bg-warning' : 'bg-success';\n\n const windFactor = Math.min(100, Math.round((current.windSpeed / 50) * 100));\n const pestPercent = Math.min(100, Math.round(windFactor * 0.4 + (current.temperature > 25 ? 30 : 10)));\n const pestLevel = pestPercent >= 60 ? levelHigh : pestPercent >= 30 ? levelModerate : levelLow;\n const pestColor = pestPercent >= 60 ? 'bg-status-error-bg' : pestPercent >= 30 ? 'bg-warning' : 'bg-success';\n\n const avgPrecip = forecast.length > 0 ? forecast.reduce((s, d) => s + d.precipitation, 0) / forecast.length : 0;\n const irrigationPercent = Math.max(0, Math.min(100, Math.round(100 - avgPrecip - current.humidity * 0.5)));\n const irrigationLevel = irrigationPercent >= 60 ? levelHigh : irrigationPercent >= 30 ? levelModerate : levelLow;\n const irrigationColor =\n irrigationPercent >= 60 ? 'bg-status-error-bg' : irrigationPercent >= 30 ? 'bg-warning' : 'bg-info';\n\n return [\n {\n id: 'cropGrowth',\n label: t('healthybowl.weather.overview.impact.cropGrowth.label', 'Crop Growth Conditions'),\n level: growthLevel,\n percent: growthPercent,\n color: growthColor,\n },\n {\n id: 'diseaseRisk',\n label: t('healthybowl.weather.overview.impact.diseaseRisk.label', 'Disease Risk'),\n level: diseaseLevel,\n percent: diseasePercent,\n color: diseaseColor,\n },\n {\n id: 'pestActivity',\n label: t('healthybowl.weather.overview.impact.pestActivity.label', 'Pest Activity'),\n level: pestLevel,\n percent: pestPercent,\n color: pestColor,\n },\n {\n id: 'irrigationNeed',\n label: t('healthybowl.weather.overview.impact.irrigationNeed.label', 'Irrigation Need'),\n level: irrigationLevel,\n percent: irrigationPercent,\n color: irrigationColor,\n },\n ];\n }, [current, forecast, alerts, t]);\n\n return (\n <PageLayout\n title={t('healthybowl.weather.overview.title', 'Weather Dashboard')}\n description={t(\n 'healthybowl.weather.overview.description',\n 'Real-time weather data and forecasts for {{location}}',\n {\n location,\n }\n )}\n purpose=\"Today's conditions and the days ahead for your farm in one view. Check the weather before you head out, and jump into the full forecast, history or alerts when you need to plan or react.\"\n nextStepsKey=\"healthybowl-weather-overview\"\n nextStepsTitle=\"Plan around the weather\"\n nextSteps={[\n {\n id: 'forecast',\n label: 'See the full forecast',\n description: 'Plan field work around the 7-day outlook.',\n onClick: () => navigate(buildPath('weather/forecast')),\n },\n {\n id: 'alerts',\n label: 'Set up weather alerts',\n description: 'Get warned about frost, heat or heavy rain in time to act.',\n onClick: () => navigate(buildPath('weather/alerts')),\n },\n {\n id: 'history',\n label: 'Review weather history',\n description: 'Compare past seasons to plan planting and irrigation.',\n onClick: () => navigate(buildPath('weather/history')),\n },\n ]}\n actions={\n !needsLocation && !loadings.weather && !errors.weather ? (\n <Button variant=\"outline\" size=\"sm\" onClick={openLocationModal}>\n <MapPin className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.actions.changeLocation', 'Change location')}\n </Button>\n ) : undefined\n }\n >\n {loadings.weather ? (\n <PageLoader />\n ) : errors.weather ? (\n <ErrorState onRetry={refetch} />\n ) : needsLocation ? (\n <EmptyState\n illustration=\"empty-generic\"\n title={t('healthybowl.weather.overview.emptyState.title', 'No farm location set')}\n description={t(\n 'healthybowl.weather.overview.emptyState.description',\n 'Weather forecasts need a location. Set your farm location to see real-time conditions, a 7-day forecast, and farming recommendations.'\n )}\n action={\n <Button onClick={openLocationModal}>\n <MapPin className=\"h-4 w-4\" />\n {t('healthybowl.weather.overview.emptyState.action', 'Set your farm location')}\n </Button>\n }\n />\n ) : (\n <>\n {/* Quick Navigation */}\n <div className=\"grid grid-cols-2 gap-3 md:grid-cols-4\">\n <Button variant=\"outline\" onClick={() => navigate(buildPath('weather/forecast'))}>\n <Calendar className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.quickNav.extendedForecast', 'Extended Forecast')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate(buildPath('weather/alerts'))}>\n <Bell className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.quickNav.alertSettings', 'Alert Settings')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate(buildPath('weather/history'))}>\n <TrendingUp className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.quickNav.historicalData', 'Historical Data')}\n </Button>\n <Button variant=\"outline\" onClick={() => setMapOpen(true)}>\n <MapPin className=\"h-4 w-4 text-text-secondary\" />{' '}\n {t('healthybowl.weather.overview.quickNav.weatherMaps', 'Weather Maps')}\n </Button>\n </div>\n\n {/* Weather Alerts */}\n {alerts.length > 0 && (\n <div className=\"space-y-3\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.alerts.heading', 'Weather Alerts')}\n </h2>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('weather/alerts'))}\n className=\"gap-1 text-text-secondary hover:text-text-primary\"\n >\n {t('healthybowl.weather.overview.alerts.manage', 'Manage Alerts')}{' '}\n <ChevronRight className=\"h-3.5 w-3.5\" />\n </Button>\n </div>\n {alerts.map((alert) => (\n <div\n key={alert.id}\n className={`rounded-lg border border-border-subtle border-l-4 bg-bg-surface p-4 ${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-warning\" />\n <div className=\"flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-medium text-text-primary\">{alert.title}</h3>\n <StatusBadge label={alert.severity} variant={severityVariant(alert.severity)} />\n </div>\n <p className=\"mt-1 text-sm text-text-secondary\">{alert.description}</p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.alerts.affected', 'Affected: {{areas}}', {\n areas: (alert.affectedAreas ?? []).join(', '),\n })}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Current Weather + Today's Summary */}\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-3\">\n {/* Main Current Weather Card */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6 lg:col-span-2\">\n <div className=\"mb-4 flex items-center gap-2\">\n {(() => {\n const Icon = getWeatherIcon(current.condition);\n return <Icon className=\"h-8 w-8 text-text-secondary\" />;\n })()}\n <div>\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.current.title', 'Current Weather')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.current.lastUpdated', 'Last updated: {{time}}', {\n time: new Date().toLocaleString(),\n })}\n </p>\n </div>\n </div>\n <div className=\"grid grid-cols-2 gap-6 md:grid-cols-4\">\n {/* Temp */}\n <div className=\"text-center\">\n <div className=\"text-3xl font-bold text-text-primary\">{current.temperature}°C</div>\n <div className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.current.feelsLike', 'Feels like {{temp}}°C', {\n temp: current.feelsLike,\n })}\n </div>\n <div className=\"mt-1 text-sm font-medium text-text-primary\">{current.condition}</div>\n </div>\n {/* Humidity & Wind */}\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <Droplets className=\"h-4 w-4 text-info\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.humidity', 'Humidity: {{value}}%', {\n value: current.humidity,\n })}\n </span>\n </div>\n <div className=\"flex items-center gap-2\">\n <Wind className=\"h-4 w-4 text-text-secondary\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.wind', 'Wind: {{speed}} km/h {{direction}}', {\n speed: current.windSpeed,\n direction: current.windDirection,\n })}\n </span>\n </div>\n </div>\n {/* Pressure & Visibility */}\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <Gauge className=\"h-4 w-4 text-primary\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.pressure', 'Pressure: {{value}} hPa', {\n value: current.pressure,\n })}\n </span>\n </div>\n <div className=\"flex items-center gap-2\">\n <Eye className=\"h-4 w-4 text-success\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.visibility', 'Visibility: {{value}} km', {\n value: current.visibility,\n })}\n </span>\n </div>\n </div>\n {/* UV Index */}\n <div className=\"space-y-2\">\n <div className=\"text-sm\">\n <span className=\"text-text-secondary\">\n {t('healthybowl.weather.overview.current.uvIndex', 'UV Index: ')}\n </span>\n <span className=\"font-medium text-text-primary\">\n {current.uvIndex} ({uvLabel(current.uvIndex)})\n </span>\n </div>\n </div>\n </div>\n </div>\n\n {/* Today's Summary */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.summary.title', \"Today's Summary\")}\n </h3>\n <div className=\"mt-4 space-y-4\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.high', 'High')}\n </span>\n <div className=\"flex items-center gap-1\">\n <ArrowUp className=\"h-3.5 w-3.5 text-status-error-text\" />\n <span className=\"font-medium text-text-primary\">{todayForecast.high}°C</span>\n </div>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.low', 'Low')}\n </span>\n <div className=\"flex items-center gap-1\">\n <ArrowDown className=\"h-3.5 w-3.5 text-info\" />\n <span className=\"font-medium text-text-primary\">{todayForecast.low}°C</span>\n </div>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.precipitation', 'Precipitation')}\n </span>\n <span className=\"font-medium text-text-primary\">{todayForecast.precipitation}%</span>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.humidity', 'Humidity')}\n </span>\n <span className=\"font-medium text-text-primary\">{todayForecast.humidity}%</span>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.windSpeed', 'Wind Speed')}\n </span>\n <span className=\"font-medium text-text-primary\">{todayForecast.windSpeed} km/h</span>\n </div>\n </div>\n </div>\n </div>\n\n {/* 7-Day Forecast */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h3 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.forecast.title', '7-Day Forecast')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.forecast.subtitle', 'Click on any day for detailed forecast')}\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('weather/forecast'))}\n className=\"gap-1 text-text-secondary hover:text-text-primary\"\n >\n {t('healthybowl.weather.overview.forecast.viewExtended', 'View Extended Forecast')}{' '}\n <ChevronRight className=\"h-3.5 w-3.5\" />\n </Button>\n </div>\n <div className=\"space-y-2\">\n {forecast.slice(0, 7).map((day, index) => {\n const Icon = getWeatherIcon(day.condition);\n return (\n <div\n key={day.date}\n onClick={() => navigate(buildPath('weather/forecast'))}\n className=\"flex cursor-pointer items-center justify-between rounded-lg px-3 py-2.5 transition-colors hover:bg-bg-sunken/50\"\n >\n <div className=\"flex items-center gap-3 flex-1\">\n <span className=\"w-14 text-sm font-medium text-text-primary\">\n {index === 0\n ? t('healthybowl.weather.overview.forecast.today', 'Today')\n : new Date(day.date).toLocaleDateString('en-US', { weekday: 'short' })}\n </span>\n <Icon className=\"h-5 w-5 text-text-secondary\" />\n <span className=\"text-sm text-text-primary\">{day.condition}</span>\n </div>\n <div className=\"flex items-center gap-4 text-sm\">\n <div className=\"flex items-center gap-1\">\n <Droplets className=\"h-3 w-3 text-info\" />\n <span className=\"text-text-primary\">{day.precipitation}%</span>\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-text-primary\">{day.high}°</span>\n <span className=\"text-text-secondary\">{day.low}°</span>\n </div>\n </div>\n </div>\n );\n })}\n </div>\n </div>\n\n {/* Farming Recommendations + Weather Impact */}\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n {/* Farming Recommendations - derived from current weather data */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.recommendations.title', 'Farming Recommendations')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.weather.overview.recommendations.subtitle',\n 'AI-powered insights based on current conditions'\n )}\n </p>\n <div className=\"mt-4 space-y-3\">\n {farmingRecommendations.map((rec) => {\n const Icon = rec.icon;\n return (\n <div key={rec.id} className=\"flex items-start gap-3 rounded-lg bg-bg-sunken/50 p-3\">\n <Icon className={`mt-0.5 h-5 w-5 shrink-0 ${rec.iconColor}`} />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">{rec.title}</p>\n <p className=\"text-xs text-text-secondary\">{rec.description}</p>\n </div>\n </div>\n );\n })}\n </div>\n </div>\n\n {/* Weather Impact Analysis - derived from forecast/alert data */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.impact.title', 'Weather Impact Analysis')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.impact.subtitle', 'Impact on farming operations')}\n </p>\n <div className=\"mt-4 space-y-4\">\n {weatherImpactMetrics.map(({ id, label, level, percent, color }) => (\n <div key={id}>\n <div className=\"mb-1.5 flex items-center justify-between\">\n <span className=\"text-sm font-medium text-text-primary\">{label}</span>\n <span className=\"text-sm font-medium text-text-secondary\">{level}</span>\n </div>\n <div className=\"h-2 w-full rounded-full bg-bg-sunken\">\n <div className={`h-2 rounded-full transition-all ${color}`} style={{ width: `${percent}%` }} />\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n </>\n )}\n\n <Modal\n open={mapOpen}\n onClose={() => setMapOpen(false)}\n title={t('healthybowl.weather.overview.map.title', 'Weather Map')}\n description={\n location\n ? t('healthybowl.weather.overview.map.descriptionNear', 'Live precipitation radar near {{location}}', {\n location,\n })\n : t('healthybowl.weather.overview.map.description', 'Live precipitation radar')\n }\n size=\"xl\"\n >\n {mapOpen && <WeatherMap location={location} center={weatherMapCenter} />}\n </Modal>\n\n {/* Set / change farm weather location */}\n <Modal\n open={locationOpen}\n onClose={() => setLocationOpen(false)}\n title={t('healthybowl.weather.overview.location.modal.title', 'Set farm location')}\n description={t(\n 'healthybowl.weather.overview.location.modal.description',\n 'Enter your farm’s town, city, or region. We use it to fetch local weather and forecasts.'\n )}\n size=\"md\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setLocationOpen(false)}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSaveLocation} disabled={savingLocation}>\n {savingLocation && <Loader2 className=\"h-4 w-4 animate-spin\" />}\n {savingLocation\n ? t('healthybowl.weather.overview.location.modal.saving', 'Saving…')\n : t('healthybowl.weather.overview.location.modal.save', 'Save location')}\n </Button>\n </>\n }\n >\n <div>\n <label htmlFor=\"weather-location\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.weather.overview.location.field.label', 'Farm location')}\n </label>\n <input\n id=\"weather-location\"\n type=\"text\"\n value={locationInput}\n onChange={(e) => setLocationInput(e.target.value)}\n placeholder={t('healthybowl.weather.overview.location.field.placeholder', 'e.g., Pune, Maharashtra')}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.weather.overview.location.field.helper',\n 'We resolve coordinates automatically so the forecast reflects this exact place.'\n )}\n </p>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,MAAmB,MACvB,MAAM,aAAa,MAAM,WAAY,UAAoB,MAAM,aAAc,YAAuB,QAEhG,MAAkB,MAAc;AACpC,SAAQ,GAAR;EACE,KAAK,UACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,QACE,QAAO;;GAIP,KAAkB,MAAsB;AAC5C,SAAQ,EAAU,aAAa,EAA/B;EACE,KAAK;EACL,KAAK,QACH,QAAO;EACT,KAAK,gBACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,eACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,QACE,QAAO;;GAMP,MAAc,MACd,KAAM,IAAU,QAChB,KAAM,IAAU,aAChB,KAAM,IAAU,SAChB,KAAM,KAAW,aACd,WAGI,UAAgC;CAC3C,IAAM,EAA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AAS,WAAU,wBAAyB,CAAA,EAC9D,IACG,EAAE,sDAAsD,UAAU,GAClE,EAAE,oDAAoD,gBAAgB,CACnE;OACR,EAAA,CAAA;cAGL,kBAAC,OAAD,EAAA,UAAA;KACE,kBAAC,SAAD;MAAO,SAAQ;MAAmB,WAAU;gBACzC,EAAE,qDAAqD,gBAAgB;MAClE,CAAA;KACR,kBAAC,SAAD;MACE,IAAG;MACH,MAAK;MACL,OAAO;MACP,WAAW,MAAM,EAAiB,EAAE,OAAO,MAAM;MACjD,aAAa,EAAE,2DAA2D,0BAA0B;MACpG,WAAU;MACV,CAAA;KACF,kBAAC,KAAD;MAAG,WAAU;gBACV,EACC,sDACA,kFACD;MACC,CAAA;KACA,EAAA,CAAA;IACA,CAAA;GAER,kBAAC,GAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAC3C"}
1
+ {"version":3,"file":"WeatherOverviewPage.js","names":[],"sources":["../../../../src/healthybowl/pages/weather/WeatherOverviewPage.tsx"],"sourcesContent":["import { useMemo, useCallback, useState, type FC } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Cloud,\n CloudRain,\n Sun,\n CloudLightning,\n Wind,\n Droplets,\n Eye,\n Gauge,\n AlertTriangle,\n TrendingUp,\n Calendar,\n Bell,\n MapPin,\n ChevronRight,\n ArrowUp,\n ArrowDown,\n Loader2,\n} from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, StatusBadge, ErrorState, PageLoader, Modal, WeatherMap, EmptyState } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { geocodePlace } from '../../utils/geocode';\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 getWeatherIcon = (condition: string) => {\n switch (condition.toLowerCase()) {\n case 'sunny':\n case 'clear':\n return Sun;\n case 'partly cloudy':\n return Cloud;\n case 'rain':\n return CloudRain;\n case 'thunderstorm':\n return CloudLightning;\n case 'cloudy':\n return Cloud;\n default:\n return Sun;\n }\n};\n\ntype UVLevel = 'low' | 'moderate' | 'high' | 'veryHigh' | 'extreme';\n\nconst getUVLevel = (uv: number): UVLevel => {\n if (uv <= 2) return 'low';\n if (uv <= 5) return 'moderate';\n if (uv <= 7) return 'high';\n if (uv <= 10) return 'veryHigh';\n return 'extreme';\n};\n\nexport const WeatherOverviewPage: FC = () => {\n const { weatherData, farm, createFarm, updateFarm, loadings, errors, refetch } = useHealthyBowlData();\n const [mapOpen, setMapOpen] = useState(false);\n const [locationOpen, setLocationOpen] = useState(false);\n const [locationInput, setLocationInput] = useState('');\n const [savingLocation, setSavingLocation] = useState(false);\n\n const navigate = useNavigate();\n // buildPath gives absolute MFE paths; bare navigate(buildPath('weather/forecast')) resolves\n // relative to /healthybowl/weather → /healthybowl/forecast (404).\n const { buildPath } = useBasePath();\n const { t: translate } = useI18n();\n const t = useCallback(\n (key: string, fallback: string, vars?: Record<string, string | number>): string => {\n const resolved = translate(key);\n const base = resolved === key ? fallback : resolved;\n if (!vars) return base;\n return Object.entries(vars).reduce(\n (str, [varKey, varValue]) => str.replace(`{{${varKey}}}`, String(varValue)),\n base\n );\n },\n [translate]\n );\n const { toasts, toast, dismiss } = useToast();\n const defaultCurrent = {\n temperature: 0,\n condition: 'N/A',\n feelsLike: 0,\n humidity: 0,\n windSpeed: 0,\n windDirection: '',\n uvIndex: 0,\n pressure: 0,\n visibility: 0,\n icon: '',\n };\n const current = weatherData?.current ?? defaultCurrent;\n const forecast = weatherData?.forecast ?? [];\n const alerts = weatherData?.alerts ?? [];\n const location = weatherData?.location ?? '';\n const weatherMapCenter =\n typeof weatherData?.latitude === 'number' && typeof weatherData?.longitude === 'number'\n ? { lat: weatherData.latitude, lng: weatherData.longitude }\n : null;\n\n // No resolved location AND no forecast points => the svc has nowhere to fetch\n // weather for. Render an honest empty-state with a CTA rather than the\n // all-zeros default that looks like real (but fake) data.\n const needsLocation = location === '' && forecast.length === 0;\n const todayForecast =\n forecast[0] ??\n ({\n high: current.temperature,\n low: current.temperature,\n precipitation: 0,\n humidity: current.humidity,\n windSpeed: current.windSpeed,\n } as const);\n\n const uvLabel = useCallback(\n (uv: number): string => {\n const level = getUVLevel(uv);\n const labels: Record<UVLevel, string> = {\n low: t('healthybowl.weather.overview.uv.low', 'Low'),\n moderate: t('healthybowl.weather.overview.uv.moderate', 'Moderate'),\n high: t('healthybowl.weather.overview.uv.high', 'High'),\n veryHigh: t('healthybowl.weather.overview.uv.veryHigh', 'Very High'),\n extreme: t('healthybowl.weather.overview.uv.extreme', 'Extreme'),\n };\n return labels[level];\n },\n [t]\n );\n\n const openLocationModal = useCallback(() => {\n setLocationInput(farm.location ?? '');\n setLocationOpen(true);\n }, [farm.location]);\n\n // Set the farm's weather location: geocode the free-text place client-side\n // (Open-Meteo, keyless), then persist via updateFarm (or createFarm when no\n // farm exists yet) with the resolved lat/lng so the svc can fetch weather for\n // the new place, and refetch the weather query.\n const handleSaveLocation = useCallback(async () => {\n const place = locationInput.trim();\n if (!place) {\n toast({\n title: t('healthybowl.weather.overview.location.toast.required.title', 'Location required'),\n description: t(\n 'healthybowl.weather.overview.location.toast.required.description',\n 'Enter a town, city, or region to set your farm location.'\n ),\n variant: 'warning',\n });\n return;\n }\n setSavingLocation(true);\n try {\n const hit = await geocodePlace(place);\n const coords = hit ? { latitude: hit.latitude, longitude: hit.longitude } : {};\n if (farm.id) {\n await updateFarm({ id: farm.id, location: place, ...coords });\n } else {\n // Minimal farm bootstrap so weather has a home; the profile page fills the rest.\n await createFarm({\n name: t('healthybowl.weather.overview.location.defaultFarmName', 'My Farm'),\n location: place,\n owner: '',\n totalArea: 0,\n areaUnit: 'acres',\n organicCertified: false,\n ...coords,\n });\n }\n toast({\n title: t('healthybowl.weather.overview.location.toast.saved.title', 'Location set'),\n description: hit\n ? t('healthybowl.weather.overview.location.toast.saved.resolved', 'Weather will load for {{place}}.', {\n place: [hit.name, hit.admin1, hit.country].filter(Boolean).join(', ') || place,\n })\n : t(\n 'healthybowl.weather.overview.location.toast.saved.unresolved',\n 'Saved \"{{place}}\". We could not resolve exact coordinates — the server will try to geocode it.',\n { place }\n ),\n variant: 'success',\n });\n setLocationOpen(false);\n await refetch();\n } catch (err) {\n toast({\n title: t('healthybowl.weather.overview.location.toast.failed.title', 'Could not set location'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setSavingLocation(false);\n }\n }, [locationInput, farm.id, updateFarm, createFarm, refetch, toast, t]);\n\n // Derive farming recommendations from actual weather conditions\n const farmingRecommendations = useMemo(() => {\n const recs: { id: string; title: string; description: string; icon: typeof TrendingUp; iconColor: string }[] = [];\n if (current.humidity >= 40 && current.humidity <= 70 && current.temperature >= 15 && current.temperature <= 30) {\n recs.push({\n id: 'goodIrrigation',\n title: t('healthybowl.weather.overview.recommendations.goodIrrigation.title', 'Good conditions for irrigation'),\n description: t(\n 'healthybowl.weather.overview.recommendations.goodIrrigation.description',\n 'Humidity at {{humidity}}% and {{temperature}}°C are optimal for watering crops',\n { humidity: current.humidity, temperature: current.temperature }\n ),\n icon: TrendingUp,\n iconColor: 'text-success',\n });\n } else if (current.humidity > 70) {\n recs.push({\n id: 'skipIrrigation',\n title: t('healthybowl.weather.overview.recommendations.skipIrrigation.title', 'Skip irrigation today'),\n description: t(\n 'healthybowl.weather.overview.recommendations.skipIrrigation.description',\n 'Humidity is high at {{humidity}}% — soil moisture is likely adequate',\n { humidity: current.humidity }\n ),\n icon: Droplets,\n iconColor: 'text-info',\n });\n } else {\n recs.push({\n id: 'increaseIrrigation',\n title: t('healthybowl.weather.overview.recommendations.increaseIrrigation.title', 'Increase irrigation'),\n description: t(\n 'healthybowl.weather.overview.recommendations.increaseIrrigation.description',\n 'Low humidity at {{humidity}}% — crops may need extra watering',\n { humidity: current.humidity }\n ),\n icon: AlertTriangle,\n iconColor: 'text-warning',\n });\n }\n const rainForecast = forecast.find((d) => d.precipitation > 50);\n if (rainForecast) {\n recs.push({\n id: 'heavyRain',\n title: t('healthybowl.weather.overview.recommendations.heavyRain.title', 'Prepare for heavy rain'),\n description: t(\n 'healthybowl.weather.overview.recommendations.heavyRain.description',\n '{{precipitation}}% precipitation expected on {{day}} — ensure proper drainage',\n {\n precipitation: rainForecast.precipitation,\n day: new Date(rainForecast.date).toLocaleDateString('en-US', { weekday: 'short' }),\n }\n ),\n icon: AlertTriangle,\n iconColor: 'text-warning',\n });\n }\n if (current.windSpeed > 20) {\n recs.push({\n id: 'windSensitive',\n title: t('healthybowl.weather.overview.recommendations.windSensitive.title', 'Monitor wind-sensitive crops'),\n description: t(\n 'healthybowl.weather.overview.recommendations.windSensitive.description',\n 'Wind at {{windSpeed}} km/h {{windDirection}} — check support structures for tall crops',\n { windSpeed: current.windSpeed, windDirection: current.windDirection }\n ),\n icon: Wind,\n iconColor: 'text-info',\n });\n }\n if (current.uvIndex >= 8) {\n recs.push({\n id: 'highUV',\n title: t('healthybowl.weather.overview.recommendations.highUV.title', 'High UV exposure'),\n description: t(\n 'healthybowl.weather.overview.recommendations.highUV.description',\n 'UV index at {{uvIndex}} ({{uvLabel}}) — consider shade protection for sensitive crops',\n { uvIndex: current.uvIndex, uvLabel: uvLabel(current.uvIndex) }\n ),\n icon: AlertTriangle,\n iconColor: 'text-status-error-text',\n });\n }\n if (recs.length === 0) {\n recs.push({\n id: 'stable',\n title: t('healthybowl.weather.overview.recommendations.stable.title', 'Conditions are stable'),\n description: t(\n 'healthybowl.weather.overview.recommendations.stable.description',\n 'No immediate weather concerns for farming operations'\n ),\n icon: TrendingUp,\n iconColor: 'text-success',\n });\n }\n return recs;\n }, [current, forecast, t, uvLabel]);\n\n // Derive weather impact metrics from forecast/alert data\n const weatherImpactMetrics = useMemo(() => {\n const levelLow = t('healthybowl.weather.overview.impact.levels.low', 'Low');\n const levelModerate = t('healthybowl.weather.overview.impact.levels.moderate', 'Moderate');\n const levelHigh = t('healthybowl.weather.overview.impact.levels.high', 'High');\n\n const tempScore =\n current.temperature >= 15 && current.temperature <= 30\n ? 90\n : current.temperature >= 10 && current.temperature <= 35\n ? 60\n : 30;\n const humidityScore = current.humidity >= 40 && current.humidity <= 70 ? 85 : 50;\n const growthPercent = Math.round((tempScore + humidityScore) / 2);\n const growthLevel =\n growthPercent >= 80\n ? t('healthybowl.weather.overview.impact.levels.excellent', 'Excellent')\n : growthPercent >= 60\n ? t('healthybowl.weather.overview.impact.levels.good', 'Good')\n : growthPercent >= 40\n ? levelModerate\n : t('healthybowl.weather.overview.impact.levels.poor', 'Poor');\n const growthColor = growthPercent >= 60 ? 'bg-success' : growthPercent >= 40 ? 'bg-warning' : 'bg-status-error-bg';\n\n const severeAlerts = alerts.filter((a) => a.severity === 'extreme' || a.severity === 'severe').length;\n const diseasePercent = Math.min(100, Math.round((current.humidity / 100) * 60 + severeAlerts * 15));\n const diseaseLevel = diseasePercent >= 70 ? levelHigh : diseasePercent >= 40 ? levelModerate : levelLow;\n const diseaseColor =\n diseasePercent >= 70 ? 'bg-status-error-bg' : diseasePercent >= 40 ? 'bg-warning' : 'bg-success';\n\n const windFactor = Math.min(100, Math.round((current.windSpeed / 50) * 100));\n const pestPercent = Math.min(100, Math.round(windFactor * 0.4 + (current.temperature > 25 ? 30 : 10)));\n const pestLevel = pestPercent >= 60 ? levelHigh : pestPercent >= 30 ? levelModerate : levelLow;\n const pestColor = pestPercent >= 60 ? 'bg-status-error-bg' : pestPercent >= 30 ? 'bg-warning' : 'bg-success';\n\n const avgPrecip = forecast.length > 0 ? forecast.reduce((s, d) => s + d.precipitation, 0) / forecast.length : 0;\n const irrigationPercent = Math.max(0, Math.min(100, Math.round(100 - avgPrecip - current.humidity * 0.5)));\n const irrigationLevel = irrigationPercent >= 60 ? levelHigh : irrigationPercent >= 30 ? levelModerate : levelLow;\n const irrigationColor =\n irrigationPercent >= 60 ? 'bg-status-error-bg' : irrigationPercent >= 30 ? 'bg-warning' : 'bg-info';\n\n return [\n {\n id: 'cropGrowth',\n label: t('healthybowl.weather.overview.impact.cropGrowth.label', 'Crop Growth Conditions'),\n level: growthLevel,\n percent: growthPercent,\n color: growthColor,\n },\n {\n id: 'diseaseRisk',\n label: t('healthybowl.weather.overview.impact.diseaseRisk.label', 'Disease Risk'),\n level: diseaseLevel,\n percent: diseasePercent,\n color: diseaseColor,\n },\n {\n id: 'pestActivity',\n label: t('healthybowl.weather.overview.impact.pestActivity.label', 'Pest Activity'),\n level: pestLevel,\n percent: pestPercent,\n color: pestColor,\n },\n {\n id: 'irrigationNeed',\n label: t('healthybowl.weather.overview.impact.irrigationNeed.label', 'Irrigation Need'),\n level: irrigationLevel,\n percent: irrigationPercent,\n color: irrigationColor,\n },\n ];\n }, [current, forecast, alerts, t]);\n\n return (\n <PageLayout\n title={t('healthybowl.weather.overview.title', 'Weather Dashboard')}\n description={t(\n 'healthybowl.weather.overview.description',\n 'Real-time weather data and forecasts for {{location}}',\n {\n location,\n }\n )}\n purpose=\"Today's conditions and the days ahead for your farm in one view. Check the weather before you head out, and jump into the full forecast, history or alerts when you need to plan or react.\"\n nextStepsKey=\"healthybowl-weather-overview\"\n nextStepsTitle=\"Plan around the weather\"\n nextSteps={[\n {\n id: 'forecast',\n label: 'See the full forecast',\n description: 'Plan field work around the 7-day outlook.',\n onClick: () => navigate(buildPath('weather/forecast')),\n },\n {\n id: 'alerts',\n label: 'Set up weather alerts',\n description: 'Get warned about frost, heat or heavy rain in time to act.',\n onClick: () => navigate(buildPath('weather/alerts')),\n },\n {\n id: 'history',\n label: 'Review weather history',\n description: 'Compare past seasons to plan planting and irrigation.',\n onClick: () => navigate(buildPath('weather/history')),\n },\n ]}\n actions={\n !needsLocation && !loadings.weather && !errors.weather ? (\n <Button variant=\"outline\" size=\"sm\" onClick={openLocationModal}>\n <MapPin className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.actions.changeLocation', 'Change location')}\n </Button>\n ) : undefined\n }\n >\n {loadings.weather ? (\n <PageLoader />\n ) : errors.weather ? (\n <ErrorState onRetry={refetch} />\n ) : needsLocation ? (\n <EmptyState\n illustration=\"empty-generic\"\n title={t('healthybowl.weather.overview.emptyState.title', 'No farm location set')}\n description={t(\n 'healthybowl.weather.overview.emptyState.description',\n 'Weather forecasts need a location. Set your farm location to see real-time conditions, a 7-day forecast, and farming recommendations.'\n )}\n action={\n <Button onClick={openLocationModal}>\n <MapPin className=\"h-4 w-4\" />\n {t('healthybowl.weather.overview.emptyState.action', 'Set your farm location')}\n </Button>\n }\n />\n ) : (\n <>\n {/* Quick Navigation */}\n <div className=\"grid grid-cols-2 gap-3 md:grid-cols-4\">\n <Button variant=\"outline\" onClick={() => navigate(buildPath('weather/forecast'))}>\n <Calendar className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.quickNav.extendedForecast', 'Extended Forecast')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate(buildPath('weather/alerts'))}>\n <Bell className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.quickNav.alertSettings', 'Alert Settings')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate(buildPath('weather/history'))}>\n <TrendingUp className=\"h-4 w-4 text-text-secondary\" />\n {t('healthybowl.weather.overview.quickNav.historicalData', 'Historical Data')}\n </Button>\n <Button variant=\"outline\" onClick={() => setMapOpen(true)}>\n <MapPin className=\"h-4 w-4 text-text-secondary\" />{' '}\n {t('healthybowl.weather.overview.quickNav.weatherMaps', 'Weather Maps')}\n </Button>\n </div>\n\n {/* Weather Alerts */}\n {alerts.length > 0 && (\n <div className=\"space-y-3\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.alerts.heading', 'Weather Alerts')}\n </h2>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('weather/alerts'))}\n className=\"gap-1 text-text-secondary hover:text-text-primary\"\n >\n {t('healthybowl.weather.overview.alerts.manage', 'Manage Alerts')}{' '}\n <ChevronRight className=\"h-3.5 w-3.5\" />\n </Button>\n </div>\n {alerts.map((alert) => (\n <div\n key={alert.id}\n className={`rounded-lg border border-border-subtle border-l-4 bg-bg-surface p-4 ${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-warning\" />\n <div className=\"flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-medium text-text-primary\">{alert.title}</h3>\n <StatusBadge label={alert.severity} variant={severityVariant(alert.severity)} />\n </div>\n <p className=\"mt-1 text-sm text-text-secondary\">{alert.description}</p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.alerts.affected', 'Affected: {{areas}}', {\n areas: (alert.affectedAreas ?? []).join(', '),\n })}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Current Weather + Today's Summary */}\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-3\">\n {/* Main Current Weather Card */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6 lg:col-span-2\">\n <div className=\"mb-4 flex items-center gap-2\">\n {(() => {\n const Icon = getWeatherIcon(current.condition);\n return <Icon className=\"h-8 w-8 text-text-secondary\" />;\n })()}\n <div>\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.current.title', 'Current Weather')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.current.lastUpdated', 'Last updated: {{time}}', {\n time: new Date().toLocaleString(),\n })}\n </p>\n </div>\n </div>\n <div className=\"grid grid-cols-2 gap-6 md:grid-cols-4\">\n {/* Temp */}\n <div className=\"text-center\">\n <div className=\"text-3xl font-bold text-text-primary\">{current.temperature}°C</div>\n <div className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.current.feelsLike', 'Feels like {{temp}}°C', {\n temp: current.feelsLike,\n })}\n </div>\n <div className=\"mt-1 text-sm font-medium text-text-primary\">{current.condition}</div>\n </div>\n {/* Humidity & Wind */}\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <Droplets className=\"h-4 w-4 text-info\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.humidity', 'Humidity: {{value}}%', {\n value: current.humidity,\n })}\n </span>\n </div>\n <div className=\"flex items-center gap-2\">\n <Wind className=\"h-4 w-4 text-text-secondary\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.wind', 'Wind: {{speed}} km/h {{direction}}', {\n speed: current.windSpeed,\n direction: current.windDirection,\n })}\n </span>\n </div>\n </div>\n {/* Pressure & Visibility */}\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <Gauge className=\"h-4 w-4 text-primary\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.pressure', 'Pressure: {{value}} hPa', {\n value: current.pressure,\n })}\n </span>\n </div>\n <div className=\"flex items-center gap-2\">\n <Eye className=\"h-4 w-4 text-success\" />\n <span className=\"text-sm text-text-primary\">\n {t('healthybowl.weather.overview.current.visibility', 'Visibility: {{value}} km', {\n value: current.visibility,\n })}\n </span>\n </div>\n </div>\n {/* UV Index */}\n <div className=\"space-y-2\">\n <div className=\"text-sm\">\n <span className=\"text-text-secondary\">\n {t('healthybowl.weather.overview.current.uvIndex', 'UV Index: ')}\n </span>\n <span className=\"font-medium text-text-primary\">\n {current.uvIndex} ({uvLabel(current.uvIndex)})\n </span>\n </div>\n </div>\n </div>\n </div>\n\n {/* Today's Summary */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.summary.title', \"Today's Summary\")}\n </h3>\n <div className=\"mt-4 space-y-4\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.high', 'High')}\n </span>\n <div className=\"flex items-center gap-1\">\n <ArrowUp className=\"h-3.5 w-3.5 text-status-error-text\" />\n <span className=\"font-medium text-text-primary\">{todayForecast.high}°C</span>\n </div>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.low', 'Low')}\n </span>\n <div className=\"flex items-center gap-1\">\n <ArrowDown className=\"h-3.5 w-3.5 text-info\" />\n <span className=\"font-medium text-text-primary\">{todayForecast.low}°C</span>\n </div>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.precipitation', 'Precipitation')}\n </span>\n <span className=\"font-medium text-text-primary\">{todayForecast.precipitation}%</span>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.humidity', 'Humidity')}\n </span>\n <span className=\"font-medium text-text-primary\">{todayForecast.humidity}%</span>\n </div>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm text-text-secondary\">\n {t('healthybowl.weather.overview.summary.windSpeed', 'Wind Speed')}\n </span>\n <span className=\"font-medium text-text-primary\">{todayForecast.windSpeed} km/h</span>\n </div>\n </div>\n </div>\n </div>\n\n {/* 7-Day Forecast */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h3 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.forecast.title', '7-Day Forecast')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.forecast.subtitle', 'Click on any day for detailed forecast')}\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('weather/forecast'))}\n className=\"gap-1 text-text-secondary hover:text-text-primary\"\n >\n {t('healthybowl.weather.overview.forecast.viewExtended', 'View Extended Forecast')}{' '}\n <ChevronRight className=\"h-3.5 w-3.5\" />\n </Button>\n </div>\n <div className=\"space-y-2\">\n {forecast.slice(0, 7).map((day, index) => {\n const Icon = getWeatherIcon(day.condition);\n return (\n <div\n key={day.date}\n onClick={() => navigate(buildPath('weather/forecast'))}\n className=\"flex cursor-pointer items-center justify-between rounded-lg px-3 py-2.5 transition-colors hover:bg-bg-sunken/50\"\n >\n <div className=\"flex items-center gap-3 flex-1\">\n <span className=\"w-14 text-sm font-medium text-text-primary\">\n {index === 0\n ? t('healthybowl.weather.overview.forecast.today', 'Today')\n : new Date(day.date).toLocaleDateString('en-US', { weekday: 'short' })}\n </span>\n <Icon className=\"h-5 w-5 text-text-secondary\" />\n <span className=\"text-sm text-text-primary\">{day.condition}</span>\n </div>\n <div className=\"flex items-center gap-4 text-sm\">\n <div className=\"flex items-center gap-1\">\n <Droplets className=\"h-3 w-3 text-info\" />\n <span className=\"text-text-primary\">{day.precipitation}%</span>\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-text-primary\">{day.high}°</span>\n <span className=\"text-text-secondary\">{day.low}°</span>\n </div>\n </div>\n </div>\n );\n })}\n </div>\n </div>\n\n {/* Farming Recommendations + Weather Impact */}\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n {/* Farming Recommendations - derived from current weather data */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.recommendations.title', 'Farming Recommendations')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.weather.overview.recommendations.subtitle',\n 'AI-powered insights based on current conditions'\n )}\n </p>\n <div className=\"mt-4 space-y-3\">\n {farmingRecommendations.map((rec) => {\n const Icon = rec.icon;\n return (\n <div key={rec.id} className=\"flex items-start gap-3 rounded-lg bg-bg-sunken/50 p-3\">\n <Icon className={`mt-0.5 h-5 w-5 shrink-0 ${rec.iconColor}`} />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">{rec.title}</p>\n <p className=\"text-xs text-text-secondary\">{rec.description}</p>\n </div>\n </div>\n );\n })}\n </div>\n </div>\n\n {/* Weather Impact Analysis - derived from forecast/alert data */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.weather.overview.impact.title', 'Weather Impact Analysis')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.weather.overview.impact.subtitle', 'Impact on farming operations')}\n </p>\n <div className=\"mt-4 space-y-4\">\n {weatherImpactMetrics.map(({ id, label, level, percent, color }) => (\n <div key={id}>\n <div className=\"mb-1.5 flex items-center justify-between\">\n <span className=\"text-sm font-medium text-text-primary\">{label}</span>\n <span className=\"text-sm font-medium text-text-secondary\">{level}</span>\n </div>\n <div className=\"h-2 w-full rounded-full bg-bg-sunken\">\n <div className={`h-2 rounded-full transition-all ${color}`} style={{ width: `${percent}%` }} />\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n </>\n )}\n\n <Modal\n open={mapOpen}\n onClose={() => setMapOpen(false)}\n title={t('healthybowl.weather.overview.map.title', 'Weather Map')}\n description={\n location\n ? t('healthybowl.weather.overview.map.descriptionNear', 'Live precipitation radar near {{location}}', {\n location,\n })\n : t('healthybowl.weather.overview.map.description', 'Live precipitation radar')\n }\n size=\"xl\"\n >\n {mapOpen && <WeatherMap location={location} center={weatherMapCenter} />}\n </Modal>\n\n {/* Set / change farm weather location */}\n <Modal\n open={locationOpen}\n onClose={() => setLocationOpen(false)}\n title={t('healthybowl.weather.overview.location.modal.title', 'Set farm location')}\n description={t(\n 'healthybowl.weather.overview.location.modal.description',\n 'Enter your farm’s town, city, or region. We use it to fetch local weather and forecasts.'\n )}\n size=\"md\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setLocationOpen(false)}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSaveLocation} disabled={savingLocation}>\n {savingLocation && <Loader2 className=\"h-4 w-4 animate-spin\" />}\n {savingLocation\n ? t('healthybowl.weather.overview.location.modal.saving', 'Saving…')\n : t('healthybowl.weather.overview.location.modal.save', 'Save location')}\n </Button>\n </>\n }\n >\n <div>\n <label htmlFor=\"weather-location\" className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.weather.overview.location.field.label', 'Farm location')}\n </label>\n <input\n id=\"weather-location\"\n type=\"text\"\n value={locationInput}\n onChange={(e) => setLocationInput(e.target.value)}\n placeholder={t('healthybowl.weather.overview.location.field.placeholder', 'e.g., Pune, Maharashtra')}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.weather.overview.location.field.helper',\n 'We resolve coordinates automatically so the forecast reflects this exact place.'\n )}\n </p>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,MAAmB,MACvB,MAAM,aAAa,MAAM,WAAY,UAAoB,MAAM,aAAc,YAAuB,QAEhG,MAAkB,MAAc;AACpC,SAAQ,GAAR;EACE,KAAK,UACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,KAAK,WACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,QACE,QAAO;;GAIP,KAAkB,MAAsB;AAC5C,SAAQ,EAAU,aAAa,EAA/B;EACE,KAAK;EACL,KAAK,QACH,QAAO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D;IACD,MAAK;IACL,QACE,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;KAAQ,SAAQ;KAAU,eAAe,EAAgB,GAAM;eAC5D,EAAE,6BAA6B,SAAS;KAClC,CAAA,EACT,kBAAC,GAAD;KAAQ,SAAS;KAAoB,UAAU;eAA/C,CACG,KAAkB,kBAAC,IAAD,EAAS,WAAU,wBAAyB,CAAA,EAC9D,IACG,EAAE,sDAAsD,UAAU,GAClE,EAAE,oDAAoD,gBAAgB,CACnE;OACR,EAAA,CAAA;cAGL,kBAAC,OAAD,EAAA,UAAA;KACE,kBAAC,SAAD;MAAO,SAAQ;MAAmB,WAAU;gBACzC,EAAE,qDAAqD,gBAAgB;MAClE,CAAA;KACR,kBAAC,SAAD;MACE,IAAG;MACH,MAAK;MACL,OAAO;MACP,WAAW,MAAM,EAAiB,EAAE,OAAO,MAAM;MACjD,aAAa,EAAE,2DAA2D,0BAA0B;MACpG,WAAU;MACV,CAAA;KACF,kBAAC,KAAD;MAAG,WAAU;gBACV,EACC,sDACA,kFACD;MACC,CAAA;KACA,EAAA,CAAA;IACA,CAAA;GAER,kBAAC,IAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAC3C"}
@@ -1,8 +1,43 @@
1
1
  //#region src/healthybowl/utils/geocode.ts
2
- var e = (e) => {
2
+ var e, t = (t) => {
3
+ e = t.googleMapsApiKey || void 0;
4
+ }, n = () => {
5
+ if (e) return e;
6
+ if (typeof window < "u") {
7
+ let e = window.__HB_GOOGLE_MAPS_API_KEY__;
8
+ if (e) return e;
9
+ }
10
+ }, r = async (e, t) => {
11
+ let r = n();
12
+ if (!r) return null;
13
+ let i = await fetch("https://places.googleapis.com/v1/places:searchText", {
14
+ method: "POST",
15
+ headers: {
16
+ "Content-Type": "application/json",
17
+ "X-Goog-Api-Key": r,
18
+ "X-Goog-FieldMask": "places.displayName,places.formattedAddress,places.location,places.addressComponents"
19
+ },
20
+ body: JSON.stringify({
21
+ textQuery: e,
22
+ maxResultCount: 1
23
+ }),
24
+ ...t ? { signal: t } : {}
25
+ });
26
+ if (!i.ok) return null;
27
+ let a = (await i.json()).places?.[0], o = a?.location?.latitude, s = a?.location?.longitude;
28
+ if (typeof o != "number" || typeof s != "number") return null;
29
+ let c = (e) => a?.addressComponents?.find((t) => t.types?.includes(e))?.longText;
30
+ return {
31
+ latitude: o,
32
+ longitude: s,
33
+ name: a?.displayName?.text ?? a?.formattedAddress?.split(",")[0]?.trim(),
34
+ admin1: c("administrative_area_level_1"),
35
+ country: c("country")
36
+ };
37
+ }, i = (e) => {
3
38
  let t = /* @__PURE__ */ new Set();
4
39
  return [e, e.split(",")[0] ?? ""].map((e) => e.trim()).filter((e) => e.length > 0 && !t.has(e) && !!t.add(e));
5
- }, t = async (e, t) => {
40
+ }, a = async (e, t) => {
6
41
  let n = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(e)}&count=1`, t ? { signal: t } : void 0);
7
42
  if (!n.ok) return null;
8
43
  let r = (await n.json()).results?.[0];
@@ -13,7 +48,7 @@ var e = (e) => {
13
48
  admin1: r.admin1,
14
49
  country: r.country
15
50
  } : null;
16
- }, n = async (e, t) => {
51
+ }, o = async (e, t) => {
17
52
  let n = new URLSearchParams({
18
53
  format: "jsonv2",
19
54
  q: e,
@@ -34,19 +69,23 @@ var e = (e) => {
34
69
  country: s?.country
35
70
  };
36
71
  };
37
- async function r(r, i) {
38
- let a = e(r);
39
- for (let e of a) try {
40
- let n = await t(e, i);
72
+ async function s(e, t) {
73
+ let s = i(e);
74
+ if (n()) for (let e of s) try {
75
+ let n = await r(e, t);
41
76
  if (n) return n;
42
77
  } catch {}
43
- for (let e of a) try {
44
- let t = await n(e, i);
45
- if (t) return t;
78
+ for (let e of s) try {
79
+ let n = await a(e, t);
80
+ if (n) return n;
81
+ } catch {}
82
+ for (let e of s) try {
83
+ let n = await o(e, t);
84
+ if (n) return n;
46
85
  } catch {}
47
86
  return null;
48
87
  }
49
88
  //#endregion
50
- export { r as geocodePlace };
89
+ export { t as configureGeocoder, s as geocodePlace };
51
90
 
52
91
  //# sourceMappingURL=geocode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"geocode.js","names":[],"sources":["../../../src/healthybowl/utils/geocode.ts"],"sourcesContent":["/**\n * Client-side geocoding.\n *\n * When a Google Maps browser key is configured (`VITE_GOOGLE_MAPS_API_KEY`,\n * referrer-restricted to the app domains), Places API (New) Text Search is the\n * primary lookup — it gives Google-quality coverage of small villages, hamlets,\n * and pincodes worldwide. It's called directly from the browser, which sends the\n * `Referer` the restricted key requires (the Geocoding *web service* rejects\n * referrer-restricted keys, so we deliberately use Places API New instead).\n *\n * Keyless public providers remain as fallback (and are the only path when no key\n * is present, e.g. offline dev): Open-Meteo for cities/towns, then OpenStreetMap\n * Nominatim for smaller places.\n */\nexport interface GeoResult {\n latitude: number;\n longitude: number;\n /** The canonical place name the provider resolved (e.g. \"Pune\"). */\n name?: string;\n /** Admin region / country, when available (for disambiguation in the UI). */\n admin1?: string;\n country?: string;\n}\n\nconst GOOGLE_MAPS_API_KEY: string | undefined = import.meta.env.VITE_GOOGLE_MAPS_API_KEY;\n\nconst geocodeGoogle = async (query: string, signal?: AbortSignal): Promise<GeoResult | null> => {\n if (!GOOGLE_MAPS_API_KEY) return null;\n const res = await fetch('https://places.googleapis.com/v1/places:searchText', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Goog-Api-Key': GOOGLE_MAPS_API_KEY,\n 'X-Goog-FieldMask': 'places.displayName,places.formattedAddress,places.location,places.addressComponents',\n },\n body: JSON.stringify({ textQuery: query, maxResultCount: 1 }),\n ...(signal ? { signal } : {}),\n });\n if (!res.ok) return null;\n const data = (await res.json()) as {\n places?: Array<{\n displayName?: { text?: string };\n formattedAddress?: string;\n location?: { latitude?: number; longitude?: number };\n addressComponents?: Array<{ longText?: string; types?: string[] }>;\n }>;\n };\n const hit = data.places?.[0];\n const latitude = hit?.location?.latitude;\n const longitude = hit?.location?.longitude;\n if (typeof latitude !== 'number' || typeof longitude !== 'number') return null;\n const component = (type: string): string | undefined =>\n hit?.addressComponents?.find((c) => c.types?.includes(type))?.longText;\n return {\n latitude,\n longitude,\n name: hit?.displayName?.text ?? hit?.formattedAddress?.split(',')[0]?.trim(),\n admin1: component('administrative_area_level_1'),\n country: component('country'),\n };\n};\n\nconst buildCandidates = (name: string): string[] => {\n const seen = new Set<string>();\n return [name, name.split(',')[0] ?? '']\n .map((candidate) => candidate.trim())\n .filter((candidate) => candidate.length > 0 && !seen.has(candidate) && Boolean(seen.add(candidate)));\n};\n\nconst geocodeOpenMeteo = async (query: string, signal?: AbortSignal): Promise<GeoResult | null> => {\n const res = await fetch(\n `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(query)}&count=1`,\n signal ? { signal } : undefined\n );\n if (!res.ok) return null;\n const data = (await res.json()) as {\n results?: Array<{\n latitude?: number;\n longitude?: number;\n name?: string;\n admin1?: string;\n country?: string;\n }>;\n };\n const hit = data.results?.[0];\n if (hit && typeof hit.latitude === 'number' && typeof hit.longitude === 'number') {\n return {\n latitude: hit.latitude,\n longitude: hit.longitude,\n name: hit.name,\n admin1: hit.admin1,\n country: hit.country,\n };\n }\n return null;\n};\n\nconst geocodeNominatim = async (query: string, signal?: AbortSignal): Promise<GeoResult | null> => {\n const params = new URLSearchParams({\n format: 'jsonv2',\n q: query,\n limit: '1',\n addressdetails: '1',\n });\n const res = await fetch(\n `https://nominatim.openstreetmap.org/search?${params.toString()}`,\n signal ? { signal } : undefined\n );\n if (!res.ok) return null;\n const data = (await res.json()) as Array<{\n lat?: string;\n lon?: string;\n name?: string;\n display_name?: string;\n address?: {\n village?: string;\n town?: string;\n city?: string;\n suburb?: string;\n county?: string;\n state_district?: string;\n state?: string;\n postcode?: string;\n country?: string;\n };\n }>;\n const hit = data[0];\n if (!hit) return null;\n const latitude = Number(hit.lat);\n const longitude = Number(hit.lon);\n if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;\n\n const address = hit.address;\n const name =\n hit.name ||\n address?.village ||\n address?.town ||\n address?.city ||\n address?.suburb ||\n address?.postcode ||\n hit.display_name?.split(',')[0]?.trim();\n const admin1 = address?.state_district || address?.county || address?.state;\n\n return {\n latitude,\n longitude,\n name,\n admin1,\n country: address?.country,\n };\n};\n\n/**\n * Resolve the best-match coordinates for a free-text place name. Returns null\n * when nothing matches or the network is unavailable (offline VM, no egress).\n */\nexport async function geocodePlace(name: string, signal?: AbortSignal): Promise<GeoResult | null> {\n const candidates = buildCandidates(name);\n // Primary: Google Places (New) when a key is configured — best small-place coverage.\n if (GOOGLE_MAPS_API_KEY) {\n for (const q of candidates) {\n try {\n const hit = await geocodeGoogle(q, signal);\n if (hit) return hit;\n } catch {\n /* fall through to keyless providers */\n }\n }\n }\n for (const q of candidates) {\n try {\n const hit = await geocodeOpenMeteo(q, signal);\n if (hit) return hit;\n } catch {\n /* try the next candidate */\n }\n }\n for (const q of candidates) {\n try {\n const hit = await geocodeNominatim(q, signal);\n if (hit) return hit;\n } catch {\n /* try the next candidate */\n }\n }\n return null;\n}\n"],"mappings":";AA8DA,IAAM,KAAmB,MAA2B;CAClD,IAAM,oBAAO,IAAI,KAAa;AAC9B,QAAO,CAAC,GAAM,EAAK,MAAM,IAAI,CAAC,MAAM,GAAG,CACpC,KAAK,MAAc,EAAU,MAAM,CAAC,CACpC,QAAQ,MAAc,EAAU,SAAS,KAAK,CAAC,EAAK,IAAI,EAAU,IAAI,EAAQ,EAAK,IAAI,EAAU,CAAE;GAGlG,IAAmB,OAAO,GAAe,MAAoD;CACjG,IAAM,IAAM,MAAM,MAChB,uDAAuD,mBAAmB,EAAM,CAAC,WACjF,IAAS,EAAE,WAAQ,GAAG,KAAA,EACvB;AACD,KAAI,CAAC,EAAI,GAAI,QAAO;CAUpB,IAAM,KATQ,MAAM,EAAI,MAAM,EASb,UAAU;AAU3B,QATI,KAAO,OAAO,EAAI,YAAa,YAAY,OAAO,EAAI,aAAc,WAC/D;EACL,UAAU,EAAI;EACd,WAAW,EAAI;EACf,MAAM,EAAI;EACV,QAAQ,EAAI;EACZ,SAAS,EAAI;EACd,GAEI;GAGH,IAAmB,OAAO,GAAe,MAAoD;CACjG,IAAM,IAAS,IAAI,gBAAgB;EACjC,QAAQ;EACR,GAAG;EACH,OAAO;EACP,gBAAgB;EACjB,CAAC,EACI,IAAM,MAAM,MAChB,8CAA8C,EAAO,UAAU,IAC/D,IAAS,EAAE,WAAQ,GAAG,KAAA,EACvB;AACD,KAAI,CAAC,EAAI,GAAI,QAAO;CAkBpB,IAAM,KAjBQ,MAAM,EAAI,MAAM,EAiBb;AACjB,KAAI,CAAC,EAAK,QAAO;CACjB,IAAM,IAAW,OAAO,EAAI,IAAI,EAC1B,IAAY,OAAO,EAAI,IAAI;AACjC,KAAI,CAAC,OAAO,SAAS,EAAS,IAAI,CAAC,OAAO,SAAS,EAAU,CAAE,QAAO;CAEtE,IAAM,IAAU,EAAI;AAWpB,QAAO;EACL;EACA;EACA,MAZA,EAAI,QACJ,GAAS,WACT,GAAS,QACT,GAAS,QACT,GAAS,UACT,GAAS,YACT,EAAI,cAAc,MAAM,IAAI,CAAC,IAAI,MAAM;EAOvC,QANa,GAAS,kBAAkB,GAAS,UAAU,GAAS;EAOpE,SAAS,GAAS;EACnB;;AAOH,eAAsB,EAAa,GAAc,GAAiD;CAChG,IAAM,IAAa,EAAgB,EAAK;AAYxC,MAAK,IAAM,KAAK,EACd,KAAI;EACF,IAAM,IAAM,MAAM,EAAiB,GAAG,EAAO;AAC7C,MAAI,EAAK,QAAO;SACV;AAIV,MAAK,IAAM,KAAK,EACd,KAAI;EACF,IAAM,IAAM,MAAM,EAAiB,GAAG,EAAO;AAC7C,MAAI,EAAK,QAAO;SACV;AAIV,QAAO"}
1
+ {"version":3,"file":"geocode.js","names":[],"sources":["../../../src/healthybowl/utils/geocode.ts"],"sourcesContent":["/**\n * Client-side geocoding.\n *\n * When a Google Maps browser key is configured (injected at runtime by the host\n * app via `configureGeocoder`, referrer-restricted to the app domains), Places\n * API (New) Text Search is the\n * primary lookup — it gives Google-quality coverage of small villages, hamlets,\n * and pincodes worldwide. It's called directly from the browser, which sends the\n * `Referer` the restricted key requires (the Geocoding *web service* rejects\n * referrer-restricted keys, so we deliberately use Places API New instead).\n *\n * Keyless public providers remain as fallback (and are the only path when no key\n * is present, e.g. offline dev): Open-Meteo for cities/towns, then OpenStreetMap\n * Nominatim for smaller places.\n */\nexport interface GeoResult {\n latitude: number;\n longitude: number;\n /** The canonical place name the provider resolved (e.g. \"Pune\"). */\n name?: string;\n /** Admin region / country, when available (for disambiguation in the UI). */\n admin1?: string;\n country?: string;\n}\n\n// The key MUST be resolved at runtime, not baked at build. When this microfe is\n// published on its own CI (which has no VITE_GOOGLE_MAPS_API_KEY), a build-time\n// constant would inline to `undefined` and the whole Google path would be\n// tree-shaken out of the published bundle before the host app ever consumes it.\n// So the host app (whose build DOES have the key) injects it at runtime via\n// `configureGeocoder()` (called by HealthyBowlProvider). window + import.meta.env\n// are fallbacks for standalone/dev.\nlet runtimeGoogleMapsApiKey: string | undefined;\n\nexport const configureGeocoder = (opts: { googleMapsApiKey?: string }): void => {\n runtimeGoogleMapsApiKey = opts.googleMapsApiKey || undefined;\n};\n\nconst getGoogleMapsApiKey = (): string | undefined => {\n if (runtimeGoogleMapsApiKey) return runtimeGoogleMapsApiKey;\n if (typeof window !== 'undefined') {\n const fromWindow = (window as unknown as { __HB_GOOGLE_MAPS_API_KEY__?: string }).__HB_GOOGLE_MAPS_API_KEY__;\n if (fromWindow) return fromWindow;\n }\n return import.meta.env.VITE_GOOGLE_MAPS_API_KEY || undefined;\n};\n\nconst geocodeGoogle = async (query: string, signal?: AbortSignal): Promise<GeoResult | null> => {\n const apiKey = getGoogleMapsApiKey();\n if (!apiKey) return null;\n const res = await fetch('https://places.googleapis.com/v1/places:searchText', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Goog-Api-Key': apiKey,\n 'X-Goog-FieldMask': 'places.displayName,places.formattedAddress,places.location,places.addressComponents',\n },\n body: JSON.stringify({ textQuery: query, maxResultCount: 1 }),\n ...(signal ? { signal } : {}),\n });\n if (!res.ok) return null;\n const data = (await res.json()) as {\n places?: Array<{\n displayName?: { text?: string };\n formattedAddress?: string;\n location?: { latitude?: number; longitude?: number };\n addressComponents?: Array<{ longText?: string; types?: string[] }>;\n }>;\n };\n const hit = data.places?.[0];\n const latitude = hit?.location?.latitude;\n const longitude = hit?.location?.longitude;\n if (typeof latitude !== 'number' || typeof longitude !== 'number') return null;\n const component = (type: string): string | undefined =>\n hit?.addressComponents?.find((c) => c.types?.includes(type))?.longText;\n return {\n latitude,\n longitude,\n name: hit?.displayName?.text ?? hit?.formattedAddress?.split(',')[0]?.trim(),\n admin1: component('administrative_area_level_1'),\n country: component('country'),\n };\n};\n\nconst buildCandidates = (name: string): string[] => {\n const seen = new Set<string>();\n return [name, name.split(',')[0] ?? '']\n .map((candidate) => candidate.trim())\n .filter((candidate) => candidate.length > 0 && !seen.has(candidate) && Boolean(seen.add(candidate)));\n};\n\nconst geocodeOpenMeteo = async (query: string, signal?: AbortSignal): Promise<GeoResult | null> => {\n const res = await fetch(\n `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(query)}&count=1`,\n signal ? { signal } : undefined\n );\n if (!res.ok) return null;\n const data = (await res.json()) as {\n results?: Array<{\n latitude?: number;\n longitude?: number;\n name?: string;\n admin1?: string;\n country?: string;\n }>;\n };\n const hit = data.results?.[0];\n if (hit && typeof hit.latitude === 'number' && typeof hit.longitude === 'number') {\n return {\n latitude: hit.latitude,\n longitude: hit.longitude,\n name: hit.name,\n admin1: hit.admin1,\n country: hit.country,\n };\n }\n return null;\n};\n\nconst geocodeNominatim = async (query: string, signal?: AbortSignal): Promise<GeoResult | null> => {\n const params = new URLSearchParams({\n format: 'jsonv2',\n q: query,\n limit: '1',\n addressdetails: '1',\n });\n const res = await fetch(\n `https://nominatim.openstreetmap.org/search?${params.toString()}`,\n signal ? { signal } : undefined\n );\n if (!res.ok) return null;\n const data = (await res.json()) as Array<{\n lat?: string;\n lon?: string;\n name?: string;\n display_name?: string;\n address?: {\n village?: string;\n town?: string;\n city?: string;\n suburb?: string;\n county?: string;\n state_district?: string;\n state?: string;\n postcode?: string;\n country?: string;\n };\n }>;\n const hit = data[0];\n if (!hit) return null;\n const latitude = Number(hit.lat);\n const longitude = Number(hit.lon);\n if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;\n\n const address = hit.address;\n const name =\n hit.name ||\n address?.village ||\n address?.town ||\n address?.city ||\n address?.suburb ||\n address?.postcode ||\n hit.display_name?.split(',')[0]?.trim();\n const admin1 = address?.state_district || address?.county || address?.state;\n\n return {\n latitude,\n longitude,\n name,\n admin1,\n country: address?.country,\n };\n};\n\n/**\n * Resolve the best-match coordinates for a free-text place name. Returns null\n * when nothing matches or the network is unavailable (offline VM, no egress).\n */\nexport async function geocodePlace(name: string, signal?: AbortSignal): Promise<GeoResult | null> {\n const candidates = buildCandidates(name);\n // Primary: Google Places (New) when a key is configured — best small-place coverage.\n if (getGoogleMapsApiKey()) {\n for (const q of candidates) {\n try {\n const hit = await geocodeGoogle(q, signal);\n if (hit) return hit;\n } catch {\n /* fall through to keyless providers */\n }\n }\n }\n for (const q of candidates) {\n try {\n const hit = await geocodeOpenMeteo(q, signal);\n if (hit) return hit;\n } catch {\n /* try the next candidate */\n }\n }\n for (const q of candidates) {\n try {\n const hit = await geocodeNominatim(q, signal);\n if (hit) return hit;\n } catch {\n /* try the next candidate */\n }\n }\n return null;\n}\n"],"mappings":";AAgCA,IAAI,GAES,KAAqB,MAA8C;AAC9E,KAA0B,EAAK,oBAAoB,KAAA;GAG/C,UAAgD;AACpD,KAAI,EAAyB,QAAO;AACpC,KAAI,OAAO,SAAW,KAAa;EACjC,IAAM,IAAc,OAA8D;AAClF,MAAI,EAAY,QAAO;;GAKrB,IAAgB,OAAO,GAAe,MAAoD;CAC9F,IAAM,IAAS,GAAqB;AAC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@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.710.7",
3
+ "version": "2026.710.8",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [