@burdenoff/microfe-healthybowl 2026.710.5 → 2026.710.6

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.
@@ -5,16 +5,16 @@ import { require_leaflet_src as r } from "../../node_modules/leaflet/dist/leafle
5
5
  import { geocodePlace as i } from "../utils/geocode.js";
6
6
  import { useToast as a } from "../hooks/useToast.js";
7
7
  import { ensureLeafletCss as ee } from "../utils/leaflet.js";
8
- import { extractPolygon as te, isValidPolygon as ne, polygonAreaInUnit as o, ringToPolygon as re } from "../utils/geo.js";
9
- import { useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
10
- import { useI18n as ie } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
11
- import { Check as ae, LocateFixed as oe, MapPin as se, MapPinned as ce, Pencil as le, Save as ue, Search as de, Trash2 as fe, Upload as pe, X as d } from "lucide-react";
12
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
13
- import { Button as h } from "@burdenoff/fe-libs/ui";
14
- import { gql as g } from "@apollo/client";
15
- import { useMutation as me } from "@apollo/client/react";
8
+ import { extractPolygon as o, isValidPolygon as te, polygonAreaInUnit as s, ringToPolygon as ne } from "../utils/geo.js";
9
+ import { useCallback as c, useEffect as l, useRef as u, useState as d } from "react";
10
+ import { useI18n as re } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
11
+ import { Check as ie, LocateFixed as ae, MapPin as f, MapPinned as oe, Pencil as se, Save as ce, Search as p, Trash2 as le, Upload as ue, X as de } from "lucide-react";
12
+ import { Fragment as fe, jsx as m, jsxs as h } from "react/jsx-runtime";
13
+ import { Button as g } from "@burdenoff/fe-libs/ui";
14
+ import { gql as _ } from "@apollo/client";
15
+ import { useMutation as pe } from "@apollo/client/react";
16
16
  //#region src/healthybowl/components/FieldMap.tsx
17
- var _ = /* @__PURE__ */ e(r(), 1), he = g`
17
+ var v = /* @__PURE__ */ e(r(), 1), me = _`
18
18
  mutation UpdateHealthyBowlFieldBoundary($input: UpdateHealthyBowlFieldInput!) {
19
19
  updateHealthyBowlField(input: $input) {
20
20
  id
@@ -23,22 +23,22 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
23
23
  location
24
24
  }
25
25
  }
26
- `, ge = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", _e = "Esri, Maxar, Earthstar Geographics", ve = "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", ye = "© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors", be = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", xe = {
26
+ `, he = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", ge = "Esri, Maxar, Earthstar Geographics", _e = "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", ve = "© OpenTopoMap (CC-BY-SA) · © OpenStreetMap contributors", ye = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", be = {
27
27
  color: "#16a34a",
28
28
  weight: 2,
29
29
  fillColor: "#16a34a",
30
30
  fillOpacity: .25
31
- }, Se = {
31
+ }, xe = {
32
32
  color: "#f59e0b",
33
33
  weight: 2,
34
34
  dashArray: "6 4",
35
35
  fillColor: "#f59e0b",
36
36
  fillOpacity: .15
37
- }, Ce = 16, we = 17, v = (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)), Te = (e) => {
37
+ }, Se = 16, Ce = 17, y = (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)), we = (e) => {
38
38
  let t = e.trim().match(/^(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)$/);
39
39
  if (!t) return null;
40
40
  let n = Number(t[1]), r = Number(t[2]);
41
- return v({
41
+ return y({
42
42
  lat: n,
43
43
  lng: r
44
44
  }) ? {
@@ -46,50 +46,52 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
46
46
  lng: r,
47
47
  label: `${n.toFixed(6)}, ${r.toFixed(6)}`
48
48
  } : null;
49
- }, y = ({ fieldId: e, unit: r, center: g, initialBoundary: y, onSaved: Ee }) => {
50
- let { t: b } = ie(), { workspaceId: De } = t(), { toasts: Oe, toast: x, dismiss: ke } = a(), Ae = l(null), S = l(null), C = l(null), w = l(null), T = l(null), E = l(null), D = l(null), O = l(null), k = l(g ?? null), A = l([]), j = l([]), M = l(null), N = l("view"), [P, je] = u("loading"), [F, I] = u("view"), [L, R] = u(!1), [z, B] = u(null), [Me, V] = u(0), [Ne, H] = u(!1), [Pe, U] = u(!1), [Fe, Ie] = u(!1), [Le, W] = u(!1), [G, Re] = u(""), [K, ze] = u(!1), [q, J] = u(null), Be = Ne || Pe, [Ve] = me(he);
51
- c(() => {
52
- k.current = g ?? null;
53
- }, [g]);
54
- let Y = s(() => {
55
- let e = C.current;
56
- T.current && e && e.removeLayer(T.current), T.current = null, A.current.forEach((t) => e?.removeLayer(t)), A.current = [], j.current = [], V(0);
57
- }, []), X = s((e, t) => {
58
- let n = C.current;
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);
51
+ l(() => {
52
+ j.current = _ ?? null;
53
+ }, [_]), l(() => {
54
+ De?.(B);
55
+ }, [B, De]);
56
+ let J = c(() => {
57
+ let e = T.current;
58
+ D.current && e && e.removeLayer(D.current), D.current = null, M.current.forEach((t) => e?.removeLayer(t)), M.current = [], N.current = [], Pe(0);
59
+ }, []), Y = c((e, t) => {
60
+ let n = T.current;
59
61
  if (!n) return;
60
- w.current && n.removeLayer(w.current);
61
- let i = _.default.geoJSON(e, { style: () => xe }).addTo(n);
62
- if (w.current = i, M.current = e, R(!0), B(o(e, r)), t) try {
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 {
63
65
  n.fitBounds(i.getBounds(), {
64
66
  padding: [24, 24],
65
67
  maxZoom: 18
66
68
  });
67
69
  } catch {}
68
- }, [r]), Z = s(() => {
69
- let e = C.current;
70
- w.current && e && e.removeLayer(w.current), w.current = null, M.current = null, R(!1), B(null);
71
- }, []), He = s(() => {
72
- let e = C.current;
73
- E.current && e && e.removeLayer(E.current), D.current && e && e.removeLayer(D.current), E.current = null, D.current = null;
74
- }, []), Ue = s(() => {
75
- let e = C.current;
76
- O.current && e && e.removeLayer(O.current), O.current = null, J(null), U(!1);
77
- }, []), Q = s((e) => {
78
- let t = C.current;
70
+ }, [r]), X = c(() => {
71
+ let e = T.current;
72
+ E.current && e && e.removeLayer(E.current), E.current = null, P.current = null, je(!1), Me(null);
73
+ }, []), Z = c(() => {
74
+ let e = T.current;
75
+ O.current && e && e.removeLayer(O.current), k.current && e && e.removeLayer(k.current), O.current = null, k.current = null;
76
+ }, []), We = c(() => {
77
+ let e = T.current;
78
+ A.current && e && e.removeLayer(A.current), A.current = null, q(null), H(!1);
79
+ }, []), Q = c((e) => {
80
+ let t = T.current;
79
81
  if (!t) return;
80
- O.current && t.removeLayer(O.current);
82
+ A.current && t.removeLayer(A.current);
81
83
  let n = [e.lat, e.lng], r = document.createElement("span");
82
- r.textContent = e.label, O.current = _.default.circleMarker(n, {
84
+ r.textContent = e.label, A.current = v.default.circleMarker(n, {
83
85
  radius: 8,
84
86
  color: "#ffffff",
85
87
  weight: 2,
86
88
  fillColor: "#16a34a",
87
89
  fillOpacity: 1
88
- }).addTo(t).bindPopup(r).openPopup(), t.flyTo(n, Math.max(t.getZoom(), we), { duration: .75 }), J(e), U(!0);
89
- }, []), We = s(() => {
90
- let e = C.current;
90
+ }).addTo(t).bindPopup(r).openPopup(), t.flyTo(n, Math.max(t.getZoom(), Ce), { duration: .75 }), q(e), H(!0);
91
+ }, []), Ge = c(() => {
92
+ let e = T.current;
91
93
  if (!e) return;
92
- let t = w.current;
94
+ let t = E.current;
93
95
  if (t) try {
94
96
  let n = t.getBounds();
95
97
  if (n.isValid()) {
@@ -100,58 +102,58 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
100
102
  return;
101
103
  }
102
104
  } catch {}
103
- let n = k.current;
104
- if (v(n)) {
105
- e.flyTo([n.lat, n.lng], Ce, { duration: .6 });
105
+ let n = j.current;
106
+ if (y(n)) {
107
+ e.flyTo([n.lat, n.lng], Se, { duration: .6 });
106
108
  return;
107
109
  }
108
- x({
110
+ S({
109
111
  title: b("healthybowl.fieldMap.toast.noFieldLocation.title", "No field location set"),
110
112
  description: b("healthybowl.fieldMap.toast.noFieldLocation.description", "Draw a boundary or save GPS coordinates for this field first."),
111
113
  variant: "warning"
112
114
  });
113
- }, [b, x]), Ge = s(() => {
114
- let e = C.current;
115
+ }, [b, S]), Ke = c(() => {
116
+ let e = T.current;
115
117
  if (e) {
116
118
  if (typeof navigator > "u" || !navigator.geolocation) {
117
- x({
119
+ S({
118
120
  title: b("healthybowl.fieldMap.toast.locationUnsupported.title", "Location unavailable"),
119
121
  description: b("healthybowl.fieldMap.toast.locationUnsupported.description", "This browser does not support device location."),
120
122
  variant: "warning"
121
123
  });
122
124
  return;
123
125
  }
124
- W(!0), navigator.geolocation.getCurrentPosition((t) => {
126
+ U(!0), navigator.geolocation.getCurrentPosition((t) => {
125
127
  let n = [t.coords.latitude, t.coords.longitude];
126
- He(), D.current = _.default.circle(n, {
128
+ Z(), k.current = v.default.circle(n, {
127
129
  radius: Math.max(10, t.coords.accuracy || 0),
128
130
  color: "#2563eb",
129
131
  fillColor: "#3b82f6",
130
132
  fillOpacity: .12,
131
133
  opacity: .45,
132
134
  weight: 1
133
- }).addTo(e), E.current = _.default.circleMarker(n, {
135
+ }).addTo(e), O.current = v.default.circleMarker(n, {
134
136
  radius: 7,
135
137
  color: "#ffffff",
136
138
  weight: 2,
137
139
  fillColor: "#2563eb",
138
140
  fillOpacity: 1
139
- }).addTo(e), e.flyTo(n, Math.max(e.getZoom(), we), { duration: .75 }), Q({
141
+ }).addTo(e), e.flyTo(n, Math.max(e.getZoom(), Ce), { duration: .75 }), Q({
140
142
  lat: t.coords.latitude,
141
143
  lng: t.coords.longitude,
142
144
  label: b("healthybowl.fieldMap.location.currentLabel", "My current location")
143
- }), W(!1), x({
145
+ }), U(!1), S({
144
146
  title: b("healthybowl.fieldMap.toast.locationReady.title", "Location ready"),
145
147
  description: b("healthybowl.fieldMap.toast.locationReady.description", "Save to store this as the field GPS location."),
146
148
  variant: "success"
147
149
  });
148
150
  }, (e) => {
149
151
  let t = e.code === e.PERMISSION_DENIED;
150
- x({
152
+ S({
151
153
  title: t ? b("healthybowl.fieldMap.toast.locationBlocked.title", "Location blocked") : b("healthybowl.fieldMap.toast.locationFailed.title", "Could not get location"),
152
154
  description: t ? b("healthybowl.fieldMap.toast.locationBlocked.description", "Allow location access in the browser, then try again.") : b("healthybowl.fieldMap.toast.locationFailed.description", "Make sure GPS is enabled and the page is open over HTTPS."),
153
155
  variant: "warning"
154
- }), W(!1);
156
+ }), U(!1);
155
157
  }, {
156
158
  enableHighAccuracy: !0,
157
159
  timeout: 12e3,
@@ -159,31 +161,31 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
159
161
  });
160
162
  }
161
163
  }, [
162
- He,
164
+ Z,
163
165
  Q,
164
166
  b,
165
- x
166
- ]), Ke = s(async (e) => {
167
+ S
168
+ ]), qe = c(async (e) => {
167
169
  e.preventDefault();
168
- let t = G.trim();
170
+ let t = W.trim();
169
171
  if (!t) {
170
- x({
172
+ S({
171
173
  title: b("healthybowl.fieldMap.toast.searchRequired.title", "Place required"),
172
174
  description: b("healthybowl.fieldMap.toast.searchRequired.description", "Enter a village, city, region, or coordinates."),
173
175
  variant: "warning"
174
176
  });
175
177
  return;
176
178
  }
177
- let n = Te(t);
179
+ let n = we(t);
178
180
  if (n) {
179
181
  Q(n);
180
182
  return;
181
183
  }
182
- ze(!0);
184
+ Ve(!0);
183
185
  try {
184
186
  let e = await i(t);
185
187
  if (!e) {
186
- x({
188
+ S({
187
189
  title: b("healthybowl.fieldMap.toast.searchNotFound.title", "Place not found"),
188
190
  description: b("healthybowl.fieldMap.toast.searchNotFound.description", "Try a more specific location, such as village, district, and state."),
189
191
  variant: "warning"
@@ -201,49 +203,49 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
201
203
  label: n
202
204
  });
203
205
  } catch (e) {
204
- x({
206
+ S({
205
207
  title: b("healthybowl.fieldMap.toast.searchFailed.title", "Search failed"),
206
208
  description: e instanceof Error ? e.message : String(e),
207
209
  variant: "error"
208
210
  });
209
211
  } finally {
210
- ze(!1);
212
+ Ve(!1);
211
213
  }
212
214
  }, [
213
- G,
215
+ W,
214
216
  Q,
215
217
  b,
216
- x
217
- ]), qe = s(() => {
218
- let e = C.current;
218
+ S
219
+ ]), Je = c(() => {
220
+ let e = T.current;
219
221
  if (!e) return;
220
- let t = j.current;
221
- T.current && e.removeLayer(T.current), t.length >= 2 ? T.current = _.default.polygon(t, Se).addTo(e) : T.current = null;
222
- }, []), $ = s(() => {
223
- if (j.current.length < 3) {
224
- x({
222
+ let t = N.current;
223
+ D.current && e.removeLayer(D.current), t.length >= 2 ? D.current = v.default.polygon(t, xe).addTo(e) : D.current = null;
224
+ }, []), $ = c(() => {
225
+ if (N.current.length < 3) {
226
+ S({
225
227
  title: b("healthybowl.fieldMap.toast.needPoints.title", "Need at least 3 points"),
226
228
  description: b("healthybowl.fieldMap.toast.needPoints.description", "Click on the map to add more boundary corners."),
227
229
  variant: "warning"
228
230
  });
229
231
  return;
230
232
  }
231
- let e = re(j.current.map((e) => ({
233
+ let e = ne(N.current.map((e) => ({
232
234
  lat: e.lat,
233
235
  lng: e.lng
234
236
  })));
235
- Y(), N.current = "view", I("view"), e && (X(e, !1), H(!0));
237
+ J(), F.current = "view", R("view"), e && (Y(e, !1), V(!0));
236
238
  }, [
239
+ J,
237
240
  Y,
238
- X,
239
241
  b,
240
- x
241
- ]), Je = s((e) => {
242
- if (N.current !== "draw") return;
243
- let t = C.current;
242
+ S
243
+ ]), Ye = c((e) => {
244
+ if (F.current !== "draw") return;
245
+ let t = T.current;
244
246
  if (!t) return;
245
- j.current.push(e.latlng);
246
- let n = j.current.length === 1, r = _.default.circleMarker(e.latlng, {
247
+ N.current.push(e.latlng);
248
+ let n = N.current.length === 1, r = v.default.circleMarker(e.latlng, {
247
249
  radius: n ? 7 : 5,
248
250
  color: "#fff",
249
251
  weight: 2,
@@ -251,57 +253,57 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
251
253
  fillOpacity: 1
252
254
  }).addTo(t);
253
255
  n && r.on("click", (e) => {
254
- _.default.DomEvent.stopPropagation(e), $();
255
- }), A.current.push(r), V(j.current.length), qe();
256
- }, [$, qe]), Ye = s(() => {
257
- Z(), Y(), N.current = "draw", I("draw"), H(!0);
258
- }, [Y, Z]), Xe = s(() => {
259
- Y(), N.current = "view", I("view");
260
- }, [Y]), Ze = s(() => {
261
- Y(), Z(), N.current = "view", I("view"), H(!0);
262
- }, [Y, Z]), Qe = s(async (e) => {
256
+ v.default.DomEvent.stopPropagation(e), $();
257
+ }), M.current.push(r), Pe(N.current.length), Je();
258
+ }, [$, Je]), Xe = c(() => {
259
+ X(), J(), F.current = "draw", R("draw"), V(!0);
260
+ }, [J, X]), Ze = c(() => {
261
+ J(), F.current = "view", R("view");
262
+ }, [J]), Qe = c(() => {
263
+ J(), X(), F.current = "view", R("view"), V(!0);
264
+ }, [J, X]), $e = c(async (e) => {
263
265
  try {
264
266
  let t = await e.text(), n = JSON.parse(t);
265
- if (!ne(n)) {
266
- x({
267
+ if (!te(n)) {
268
+ S({
267
269
  title: b("healthybowl.fieldMap.toast.importInvalid.title", "No polygon found"),
268
270
  description: b("healthybowl.fieldMap.toast.importInvalid.description", "The file must contain a GeoJSON Polygon (Feature, FeatureCollection or geometry)."),
269
271
  variant: "error"
270
272
  });
271
273
  return;
272
274
  }
273
- let r = te(n);
274
- Y(), N.current = "view", I("view"), X(r, !0), H(!0), x({
275
+ let r = o(n);
276
+ J(), F.current = "view", R("view"), Y(r, !0), V(!0), S({
275
277
  title: b("healthybowl.fieldMap.toast.imported.title", "Boundary imported"),
276
278
  description: b("healthybowl.fieldMap.toast.imported.description", "Review it on the map, then Save to persist."),
277
279
  variant: "success"
278
280
  });
279
281
  } catch {
280
- x({
282
+ S({
281
283
  title: b("healthybowl.fieldMap.toast.importFailed.title", "Could not read file"),
282
284
  description: b("healthybowl.fieldMap.toast.importFailed.description", "Make sure it is a valid GeoJSON (.json / .geojson) file."),
283
285
  variant: "error"
284
286
  });
285
287
  }
286
288
  }, [
289
+ J,
287
290
  Y,
288
- X,
289
291
  b,
290
- x
291
- ]), $e = s(async () => {
292
- Ie(!0);
292
+ S
293
+ ]), et = c(async () => {
294
+ Re(!0);
293
295
  try {
294
- let t = M.current, n = t ? o(t, r) : void 0, i = q ? {
295
- lat: q.lat,
296
- lng: q.lng
296
+ let t = P.current, n = t ? s(t, r) : void 0, i = K ? {
297
+ lat: K.lat,
298
+ lng: K.lng
297
299
  } : void 0;
298
- await Ve({ variables: { input: {
300
+ await Ue({ variables: { input: {
299
301
  id: e,
300
302
  boundary: t,
301
303
  ...n == null ? {} : { area: n },
302
304
  ...i ? { location: i } : {},
303
- context: { workspaceId: De }
304
- } } }), i && (k.current = i), H(!1), U(!1), J(null), Ee?.(), x({
305
+ context: { workspaceId: x }
306
+ } } }), i && (j.current = i), V(!1), H(!1), q(null), Ee?.(), S({
305
307
  title: b("healthybowl.fieldMap.toast.saved.title", "Map saved"),
306
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}}.", {
307
309
  area: String(n ?? ""),
@@ -310,246 +312,246 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
310
312
  variant: "success"
311
313
  });
312
314
  } catch (e) {
313
- x({
315
+ S({
314
316
  title: b("healthybowl.fieldMap.toast.saveFailed.title", "Save failed"),
315
317
  description: String(e),
316
318
  variant: "error"
317
319
  });
318
320
  } finally {
319
- Ie(!1);
321
+ Re(!1);
320
322
  }
321
323
  }, [
322
324
  e,
323
325
  Ee,
324
- q,
326
+ K,
325
327
  b,
326
- x,
328
+ S,
327
329
  r,
328
- Ve,
329
- De
330
+ Ue,
331
+ x
330
332
  ]);
331
- return c(() => {
332
- let e = S.current;
333
+ return l(() => {
334
+ let e = w.current;
333
335
  if (!e) return;
334
336
  ee();
335
- let t = _.default.tileLayer(ge, {
336
- attribution: _e,
337
+ let t = v.default.tileLayer(he, {
338
+ attribution: ge,
337
339
  maxZoom: 19
338
- }), n = _.default.tileLayer(ve, {
339
- attribution: ye,
340
+ }), n = v.default.tileLayer(_e, {
341
+ attribution: ve,
340
342
  maxZoom: 17
341
- }), r = _.default.tileLayer(ve, {
342
- attribution: ye,
343
+ }), r = v.default.tileLayer(_e, {
344
+ attribution: ve,
343
345
  maxZoom: 17,
344
346
  opacity: .6
345
- }), i = _.default.tileLayer(be, {
347
+ }), i = v.default.tileLayer(ye, {
346
348
  attribution: "© OpenStreetMap contributors",
347
349
  maxZoom: 19
348
- }), a = _.default.map(e, {
350
+ }), a = v.default.map(e, {
349
351
  center: [20, 0],
350
352
  zoom: 2,
351
353
  scrollWheelZoom: !0,
352
354
  layers: [t]
353
355
  });
354
- C.current = a, _.default.control.layers({ [b("healthybowl.fieldMap.layers.satellite", "Satellite (Esri)")]: t }, {
356
+ T.current = a, v.default.control.layers({ [b("healthybowl.fieldMap.layers.satellite", "Satellite (Esri)")]: t }, {
355
357
  [b("healthybowl.fieldMap.layers.terrain", "Terrain (OpenTopoMap)")]: n,
356
358
  [b("healthybowl.fieldMap.layers.soil", "Soil (placeholder)")]: r,
357
359
  [b("healthybowl.fieldMap.layers.streets", "Streets (OSM)")]: i
358
- }, { collapsed: !1 }).addTo(a), a.on("click", Je);
359
- let o = te(y);
360
- return o && ne(o) ? X(o, !0) : v(g) && a.setView([g.lat, g.lng], Ce), je("ready"), window.setTimeout(() => a.invalidateSize(), 80), () => {
361
- a.off("click", Je), a.remove(), C.current = null, w.current = null, T.current = null, E.current = null, D.current = null, O.current = null, A.current = [], j.current = [], M.current = null;
360
+ }, { collapsed: !1 }).addTo(a), a.on("click", Ye);
361
+ let s = o(Te);
362
+ return s && te(s) ? Y(s, !0) : y(_) && a.setView([_.lat, _.lng], Se), Ae("ready"), window.setTimeout(() => a.invalidateSize(), 80), () => {
363
+ a.off("click", Ye), a.remove(), T.current = null, E.current = null, D.current = null, O.current = null, k.current = null, A.current = null, M.current = [], N.current = [], P.current = null;
362
364
  };
363
- }, []), /* @__PURE__ */ m("div", {
365
+ }, []), /* @__PURE__ */ h("div", {
364
366
  className: "relative",
365
367
  children: [
366
- /* @__PURE__ */ m("div", {
368
+ /* @__PURE__ */ h("div", {
367
369
  className: "mb-3 flex flex-wrap items-center gap-2",
368
- children: [F === "view" ? /* @__PURE__ */ m(f, { children: [
369
- /* @__PURE__ */ m(h, {
370
+ children: [L === "view" ? /* @__PURE__ */ h(fe, { children: [
371
+ /* @__PURE__ */ h(g, {
370
372
  variant: "outline",
371
373
  size: "sm",
372
- onClick: Ye,
374
+ onClick: Xe,
373
375
  children: [
374
- /* @__PURE__ */ p(le, { className: "h-4 w-4" }),
376
+ /* @__PURE__ */ m(se, { className: "h-4 w-4" }),
375
377
  " ",
376
- L ? b("healthybowl.fieldMap.actions.redraw", "Redraw") : b("healthybowl.fieldMap.actions.draw", "Draw boundary")
378
+ z ? b("healthybowl.fieldMap.actions.redraw", "Redraw") : b("healthybowl.fieldMap.actions.draw", "Draw boundary")
377
379
  ]
378
380
  }),
379
- /* @__PURE__ */ m(h, {
381
+ /* @__PURE__ */ h(g, {
380
382
  variant: "outline",
381
383
  size: "sm",
382
- onClick: () => Ae.current?.click(),
384
+ onClick: () => C.current?.click(),
383
385
  children: [
384
- /* @__PURE__ */ p(pe, { className: "h-4 w-4" }),
386
+ /* @__PURE__ */ m(ue, { className: "h-4 w-4" }),
385
387
  " ",
386
388
  b("healthybowl.fieldMap.actions.import", "Import GeoJSON")
387
389
  ]
388
390
  }),
389
- /* @__PURE__ */ m(h, {
391
+ /* @__PURE__ */ h(g, {
390
392
  variant: "outline",
391
393
  size: "sm",
392
- onClick: We,
394
+ onClick: Ge,
393
395
  title: b("healthybowl.fieldMap.actions.focusField.title", "Fit map to this field"),
394
396
  "aria-label": b("healthybowl.fieldMap.actions.focusField.title", "Fit map to this field"),
395
397
  children: [
396
- /* @__PURE__ */ p(ce, { className: "h-4 w-4" }),
398
+ /* @__PURE__ */ m(oe, { className: "h-4 w-4" }),
397
399
  " ",
398
400
  b("healthybowl.fieldMap.actions.focusField", "Field")
399
401
  ]
400
402
  }),
401
- /* @__PURE__ */ m(h, {
403
+ /* @__PURE__ */ h(g, {
402
404
  variant: "outline",
403
405
  size: "sm",
404
- onClick: Ge,
405
- disabled: Le,
406
+ onClick: Ke,
407
+ disabled: ze,
406
408
  title: b("healthybowl.fieldMap.actions.locateMe.title", "Go to my current location"),
407
409
  "aria-label": b("healthybowl.fieldMap.actions.locateMe.title", "Go to my current location"),
408
410
  children: [
409
- /* @__PURE__ */ p(oe, { className: "h-4 w-4" }),
411
+ /* @__PURE__ */ m(ae, { className: "h-4 w-4" }),
410
412
  " ",
411
- Le ? b("healthybowl.fieldMap.actions.locating", "Locating...") : b("healthybowl.fieldMap.actions.locateMe", "My location")
413
+ ze ? b("healthybowl.fieldMap.actions.locating", "Locating...") : b("healthybowl.fieldMap.actions.locateMe", "My location")
412
414
  ]
413
415
  }),
414
- L && /* @__PURE__ */ m(h, {
416
+ z && /* @__PURE__ */ h(g, {
415
417
  variant: "outline",
416
418
  size: "sm",
417
- onClick: Ze,
419
+ onClick: Qe,
418
420
  children: [
419
- /* @__PURE__ */ p(fe, { className: "h-4 w-4" }),
421
+ /* @__PURE__ */ m(le, { className: "h-4 w-4" }),
420
422
  " ",
421
423
  b("healthybowl.fieldMap.actions.clear", "Clear")
422
424
  ]
423
425
  })
424
- ] }) : /* @__PURE__ */ m(f, { children: [
425
- /* @__PURE__ */ m(h, {
426
+ ] }) : /* @__PURE__ */ h(fe, { children: [
427
+ /* @__PURE__ */ h(g, {
426
428
  variant: "default",
427
429
  size: "sm",
428
430
  onClick: $,
429
431
  children: [
430
- /* @__PURE__ */ p(ae, { className: "h-4 w-4" }),
432
+ /* @__PURE__ */ m(ie, { className: "h-4 w-4" }),
431
433
  " ",
432
434
  b("healthybowl.fieldMap.actions.finish", "Finish")
433
435
  ]
434
436
  }),
435
- /* @__PURE__ */ m(h, {
437
+ /* @__PURE__ */ h(g, {
436
438
  variant: "outline",
437
439
  size: "sm",
438
- onClick: Xe,
440
+ onClick: Ze,
439
441
  children: [
440
- /* @__PURE__ */ p(d, { className: "h-4 w-4" }),
442
+ /* @__PURE__ */ m(de, { className: "h-4 w-4" }),
441
443
  " ",
442
444
  b("healthybowl.common.cancel", "Cancel")
443
445
  ]
444
446
  }),
445
- /* @__PURE__ */ p("span", {
447
+ /* @__PURE__ */ m("span", {
446
448
  className: "text-xs text-text-secondary",
447
- children: b("healthybowl.fieldMap.draftHint", "Click the map to add corners ({{count}} placed) — click the first point or Finish to close.", { count: String(Me) })
449
+ children: b("healthybowl.fieldMap.draftHint", "Click the map to add corners ({{count}} placed) — click the first point or Finish to close.", { count: String(Ne) })
448
450
  })
449
- ] }), /* @__PURE__ */ m("div", {
451
+ ] }), /* @__PURE__ */ h("div", {
450
452
  className: "ml-auto flex items-center gap-3",
451
- children: [z != null && /* @__PURE__ */ p("span", {
453
+ children: [B != null && /* @__PURE__ */ m("span", {
452
454
  className: "text-xs text-text-secondary",
453
455
  children: b("healthybowl.fieldMap.computedArea", "Area: {{area}} {{unit}}", {
454
- area: String(z),
456
+ area: String(B),
455
457
  unit: r
456
458
  })
457
- }), /* @__PURE__ */ m(h, {
459
+ }), /* @__PURE__ */ h(g, {
458
460
  variant: "default",
459
461
  size: "sm",
460
- onClick: $e,
461
- disabled: !Be || Fe || F === "draw",
462
+ onClick: et,
463
+ disabled: !He || Le || L === "draw",
462
464
  children: [
463
- /* @__PURE__ */ p(ue, { className: "h-4 w-4" }),
465
+ /* @__PURE__ */ m(ce, { className: "h-4 w-4" }),
464
466
  " ",
465
- Fe ? b("healthybowl.fieldMap.actions.saving", "Saving…") : b("healthybowl.fieldMap.actions.save", "Save")
467
+ Le ? b("healthybowl.fieldMap.actions.saving", "Saving…") : b("healthybowl.fieldMap.actions.save", "Save")
466
468
  ]
467
469
  })]
468
470
  })]
469
471
  }),
470
- F === "view" && /* @__PURE__ */ m("div", {
472
+ L === "view" && /* @__PURE__ */ h("div", {
471
473
  className: "mb-3 space-y-2",
472
- children: [/* @__PURE__ */ m("form", {
474
+ children: [/* @__PURE__ */ h("form", {
473
475
  className: "flex flex-col gap-2 sm:flex-row",
474
- onSubmit: Ke,
476
+ onSubmit: qe,
475
477
  children: [
476
- /* @__PURE__ */ m("div", {
478
+ /* @__PURE__ */ h("div", {
477
479
  className: "relative min-w-0 flex-1",
478
- children: [/* @__PURE__ */ p(de, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ p("input", {
480
+ children: [/* @__PURE__ */ m(p, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ m("input", {
479
481
  type: "search",
480
- value: G,
481
- onChange: (e) => Re(e.target.value),
482
- disabled: P !== "ready" || K,
482
+ value: W,
483
+ onChange: (e) => Be(e.target.value),
484
+ disabled: I !== "ready" || G,
483
485
  placeholder: b("healthybowl.fieldMap.search.placeholder", "Search village, city, region, or lat,lng..."),
484
486
  "aria-label": b("healthybowl.fieldMap.search.label", "Search field map by place or coordinates"),
485
487
  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)]"
486
488
  })]
487
489
  }),
488
- /* @__PURE__ */ m(h, {
490
+ /* @__PURE__ */ h(g, {
489
491
  type: "submit",
490
492
  variant: "outline",
491
493
  size: "sm",
492
- disabled: P !== "ready" || K,
494
+ disabled: I !== "ready" || G,
493
495
  children: [
494
- /* @__PURE__ */ p(de, { className: "h-4 w-4" }),
496
+ /* @__PURE__ */ m(p, { className: "h-4 w-4" }),
495
497
  " ",
496
- K ? b("healthybowl.fieldMap.search.searching", "Searching...") : b("healthybowl.fieldMap.search.action", "Search")
498
+ G ? b("healthybowl.fieldMap.search.searching", "Searching...") : b("healthybowl.fieldMap.search.action", "Search")
497
499
  ]
498
500
  }),
499
- q && /* @__PURE__ */ m(h, {
501
+ K && /* @__PURE__ */ h(g, {
500
502
  type: "button",
501
503
  variant: "outline",
502
504
  size: "sm",
503
- onClick: Ue,
505
+ onClick: We,
504
506
  children: [
505
- /* @__PURE__ */ p(d, { className: "h-4 w-4" }),
507
+ /* @__PURE__ */ m(de, { className: "h-4 w-4" }),
506
508
  " ",
507
509
  b("healthybowl.common.clear", "Clear")
508
510
  ]
509
511
  })
510
512
  ]
511
- }), q && /* @__PURE__ */ p("div", {
513
+ }), K && /* @__PURE__ */ m("div", {
512
514
  className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
513
- children: /* @__PURE__ */ m("span", {
515
+ children: /* @__PURE__ */ h("span", {
514
516
  className: "inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border-subtle bg-bg-sunken/70 px-2.5 py-1",
515
- children: [/* @__PURE__ */ p(se, { className: "h-3.5 w-3.5 shrink-0 text-success" }), /* @__PURE__ */ p("span", {
517
+ children: [/* @__PURE__ */ m(f, { className: "h-3.5 w-3.5 shrink-0 text-success" }), /* @__PURE__ */ m("span", {
516
518
  className: "truncate",
517
- children: b("healthybowl.fieldMap.search.pendingLocation", "Unsaved field GPS: {{place}}", { place: q.label })
519
+ children: b("healthybowl.fieldMap.search.pendingLocation", "Unsaved field GPS: {{place}}", { place: K.label })
518
520
  })]
519
521
  })
520
522
  })]
521
523
  }),
522
- /* @__PURE__ */ p("input", {
523
- ref: Ae,
524
+ /* @__PURE__ */ m("input", {
525
+ ref: C,
524
526
  type: "file",
525
527
  accept: ".json,.geojson,application/geo+json,application/json",
526
528
  className: "hidden",
527
529
  onChange: (e) => {
528
530
  let t = e.target.files?.[0];
529
- t && Qe(t), e.target.value = "";
531
+ t && $e(t), e.target.value = "";
530
532
  }
531
533
  }),
532
- /* @__PURE__ */ m("div", {
534
+ /* @__PURE__ */ h("div", {
533
535
  className: "relative",
534
536
  children: [
535
- /* @__PURE__ */ p("div", {
536
- ref: S,
537
+ /* @__PURE__ */ m("div", {
538
+ ref: w,
537
539
  className: "h-[60vh] max-h-[520px] w-full overflow-hidden rounded-md border border-border-subtle bg-bg-sunken"
538
540
  }),
539
- P === "loading" && /* @__PURE__ */ p("div", {
541
+ I === "loading" && /* @__PURE__ */ m("div", {
540
542
  className: "pointer-events-none absolute inset-0 flex items-center justify-center rounded-md bg-bg-surface/60 text-sm text-text-secondary",
541
543
  children: b("healthybowl.fieldMap.loading", "Loading map…")
542
544
  }),
543
- P === "error" && /* @__PURE__ */ p("div", {
545
+ I === "error" && /* @__PURE__ */ m("div", {
544
546
  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",
545
547
  children: b("healthybowl.fieldMap.error", "The map needs an internet connection and couldn’t load.")
546
548
  }),
547
- P === "ready" && !L && F === "view" && /* @__PURE__ */ p("div", {
549
+ I === "ready" && !z && L === "view" && /* @__PURE__ */ m("div", {
548
550
  className: "pointer-events-none absolute left-1/2 top-3 z-[400] -translate-x-1/2 rounded-full bg-bg-surface/90 px-3 py-1.5 text-xs text-text-secondary shadow-sm",
549
- children: /* @__PURE__ */ m("span", {
551
+ children: /* @__PURE__ */ h("span", {
550
552
  className: "inline-flex items-center gap-1.5",
551
553
  children: [
552
- /* @__PURE__ */ p(se, { className: "h-3.5 w-3.5" }),
554
+ /* @__PURE__ */ m(f, { className: "h-3.5 w-3.5" }),
553
555
  " ",
554
556
  b("healthybowl.fieldMap.empty", "No boundary set — draw or import one.")
555
557
  ]
@@ -557,11 +559,11 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
557
559
  })
558
560
  ]
559
561
  }),
560
- /* @__PURE__ */ p("p", {
562
+ /* @__PURE__ */ m("p", {
561
563
  className: "mt-2 text-xs text-text-secondary",
562
564
  children: b("healthybowl.fieldMap.attribution", "Imagery © Esri, Maxar, Earthstar Geographics · overlays © OpenTopoMap / OpenStreetMap")
563
565
  }),
564
- /* @__PURE__ */ p(n, {
566
+ /* @__PURE__ */ m(n, {
565
567
  toasts: Oe,
566
568
  onDismiss: ke
567
569
  })
@@ -569,6 +571,6 @@ var _ = /* @__PURE__ */ e(r(), 1), he = g`
569
571
  });
570
572
  };
571
573
  //#endregion
572
- export { y as FieldMap };
574
+ export { Te as FieldMap };
573
575
 
574
576
  //# sourceMappingURL=FieldMap.js.map