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