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