@element-editor/ui 0.0.0-stage → 0.2.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.
Files changed (244) hide show
  1. package/AGENTS.md +65 -0
  2. package/LICENSE +21 -0
  3. package/README.md +46 -2
  4. package/dist/BooleanOperations-BRO7NHUY.js +111 -0
  5. package/dist/BooleanOperations-C2uOHRu3.cjs +1 -0
  6. package/dist/DataTable-B-2VjBEz.cjs +2 -0
  7. package/dist/DataTable-CS-3dIqY.js +510 -0
  8. package/dist/DataTablePanel-58LwzXQR.cjs +1 -0
  9. package/dist/DataTablePanel-DDFUmMaM.js +208 -0
  10. package/dist/EditToolbarBtn-Ch9HCLHq.cjs +3 -0
  11. package/dist/EditToolbarBtn-SR4xHd8G.js +378 -0
  12. package/dist/FeatureEditModal-Cc8N6vei.cjs +1 -0
  13. package/dist/FeatureEditModal-Dr10p3nE.js +77 -0
  14. package/dist/FeatureList-Bo9w9nre.js +520 -0
  15. package/dist/FeatureList-VRYesXCq.cjs +1 -0
  16. package/dist/FeatureRowContextMenu-CtBqdC1j.cjs +1 -0
  17. package/dist/FeatureRowContextMenu-DCUIiDwc.js +130 -0
  18. package/dist/GeoJSONModal-BV9Tamf4.js +886 -0
  19. package/dist/GeoJSONModal-Dd-nBufy.cjs +9 -0
  20. package/dist/SchemaEditor-B4L17K1e.cjs +1 -0
  21. package/dist/SchemaEditor-ryoTgaLb.js +293 -0
  22. package/dist/SchemaModal-DvMbWskS.js +95 -0
  23. package/dist/SchemaModal-gAuDkd-L.cjs +1 -0
  24. package/dist/SettingsModal-BScVTjpn.js +237 -0
  25. package/dist/SettingsModal-CqaSFxxR.cjs +1 -0
  26. package/dist/ShortcutsModal-D1Y2bGT8.cjs +1 -0
  27. package/dist/ShortcutsModal-ozuS2Ysb.js +299 -0
  28. package/dist/components/ActiveDrawingToolbar.d.cts +1 -0
  29. package/dist/components/ActiveDrawingToolbar.d.ts +1 -0
  30. package/dist/components/BasemapPicker.d.cts +26 -0
  31. package/dist/components/BasemapPicker.d.ts +26 -0
  32. package/dist/components/BooleanOperations.d.cts +1 -0
  33. package/dist/components/BooleanOperations.d.ts +1 -0
  34. package/dist/components/BufferPanel.d.cts +1 -0
  35. package/dist/components/BufferPanel.d.ts +1 -0
  36. package/dist/components/DataTable.d.cts +9 -0
  37. package/dist/components/DataTable.d.ts +9 -0
  38. package/dist/components/DataTablePanel.d.cts +10 -0
  39. package/dist/components/DataTablePanel.d.ts +10 -0
  40. package/dist/components/EditingToolbar.d.cts +1 -0
  41. package/dist/components/EditingToolbar.d.ts +1 -0
  42. package/dist/components/ElementEditorErrorBoundary.d.cts +28 -0
  43. package/dist/components/ElementEditorErrorBoundary.d.ts +28 -0
  44. package/dist/components/ElementEditorUIProvider.d.cts +50 -0
  45. package/dist/components/ElementEditorUIProvider.d.ts +50 -0
  46. package/dist/components/FeatureMapContextMenu.d.cts +23 -0
  47. package/dist/components/FeatureMapContextMenu.d.ts +23 -0
  48. package/dist/components/FitBoundsButton.d.cts +6 -0
  49. package/dist/components/FitBoundsButton.d.ts +6 -0
  50. package/dist/components/FloatingToolbar.d.cts +3 -0
  51. package/dist/components/FloatingToolbar.d.ts +3 -0
  52. package/dist/components/LocateButton.d.cts +11 -0
  53. package/dist/components/LocateButton.d.ts +11 -0
  54. package/dist/components/ReadonlyBanner.d.cts +1 -0
  55. package/dist/components/ReadonlyBanner.d.ts +1 -0
  56. package/dist/components/ShortcutsModal.d.cts +1 -0
  57. package/dist/components/ShortcutsModal.d.ts +1 -0
  58. package/dist/components/SimplifyPanel.d.cts +1 -0
  59. package/dist/components/SimplifyPanel.d.ts +1 -0
  60. package/dist/components/SmoothPanel.d.cts +1 -0
  61. package/dist/components/SmoothPanel.d.ts +1 -0
  62. package/dist/components/UndoRedoToolbar.d.cts +20 -0
  63. package/dist/components/UndoRedoToolbar.d.ts +20 -0
  64. package/dist/components/VertexSelectionBar.d.cts +12 -0
  65. package/dist/components/VertexSelectionBar.d.ts +12 -0
  66. package/dist/components/ZoomIndicator.d.cts +15 -0
  67. package/dist/components/ZoomIndicator.d.ts +15 -0
  68. package/dist/components/dialogs/DynamicFieldRenderer.d.cts +11 -0
  69. package/dist/components/dialogs/DynamicFieldRenderer.d.ts +11 -0
  70. package/dist/components/dialogs/SettingsModal.d.cts +1 -0
  71. package/dist/components/dialogs/SettingsModal.d.ts +1 -0
  72. package/dist/components/lazyParts.d.cts +12 -0
  73. package/dist/components/lazyParts.d.ts +12 -0
  74. package/dist/components/sidebar/FeatureEditModal.d.cts +6 -0
  75. package/dist/components/sidebar/FeatureEditModal.d.ts +6 -0
  76. package/dist/components/sidebar/FeatureList.d.cts +4 -0
  77. package/dist/components/sidebar/FeatureList.d.ts +4 -0
  78. package/dist/components/sidebar/FeatureRow.d.cts +38 -0
  79. package/dist/components/sidebar/FeatureRow.d.ts +38 -0
  80. package/dist/components/sidebar/FeatureRowContextMenu.d.cts +12 -0
  81. package/dist/components/sidebar/FeatureRowContextMenu.d.ts +12 -0
  82. package/dist/components/sidebar/FeatureSidePanel.d.cts +8 -0
  83. package/dist/components/sidebar/FeatureSidePanel.d.ts +8 -0
  84. package/dist/components/sidebar/GeoJSONModal.d.cts +5 -0
  85. package/dist/components/sidebar/GeoJSONModal.d.ts +5 -0
  86. package/dist/components/sidebar/GroupRow.d.cts +21 -0
  87. package/dist/components/sidebar/GroupRow.d.ts +21 -0
  88. package/dist/components/sidebar/HideLayersToggle.d.cts +2 -0
  89. package/dist/components/sidebar/HideLayersToggle.d.ts +2 -0
  90. package/dist/components/sidebar/LayersPanel.d.cts +5 -0
  91. package/dist/components/sidebar/LayersPanel.d.ts +5 -0
  92. package/dist/components/sidebar/PartSubRow.d.cts +9 -0
  93. package/dist/components/sidebar/PartSubRow.d.ts +9 -0
  94. package/dist/components/sidebar/SchemaEditor.d.cts +4 -0
  95. package/dist/components/sidebar/SchemaEditor.d.ts +4 -0
  96. package/dist/components/sidebar/SchemaModal.d.cts +5 -0
  97. package/dist/components/sidebar/SchemaModal.d.ts +5 -0
  98. package/dist/components/sidebar/codeDock.d.cts +21 -0
  99. package/dist/components/sidebar/codeDock.d.ts +21 -0
  100. package/dist/components/ui/Button.d.cts +9 -0
  101. package/dist/components/ui/Button.d.ts +9 -0
  102. package/dist/components/ui/CloseButton.d.cts +6 -0
  103. package/dist/components/ui/CloseButton.d.ts +6 -0
  104. package/dist/components/ui/ContextMenu.d.cts +28 -0
  105. package/dist/components/ui/ContextMenu.d.ts +28 -0
  106. package/dist/components/ui/EditToolbarBtn.d.cts +13 -0
  107. package/dist/components/ui/EditToolbarBtn.d.ts +13 -0
  108. package/dist/components/ui/ElementToaster.d.cts +3 -0
  109. package/dist/components/ui/ElementToaster.d.ts +3 -0
  110. package/dist/components/ui/GeometryTypeIcon.d.cts +7 -0
  111. package/dist/components/ui/GeometryTypeIcon.d.ts +7 -0
  112. package/dist/components/ui/IconButton.d.cts +28 -0
  113. package/dist/components/ui/IconButton.d.ts +28 -0
  114. package/dist/components/ui/Input.d.cts +14 -0
  115. package/dist/components/ui/Input.d.ts +14 -0
  116. package/dist/components/ui/JsonCode.d.cts +4 -0
  117. package/dist/components/ui/JsonCode.d.ts +4 -0
  118. package/dist/components/ui/Kbd.d.cts +16 -0
  119. package/dist/components/ui/Kbd.d.ts +16 -0
  120. package/dist/components/ui/NoFeaturesEmptyState.d.cts +1 -0
  121. package/dist/components/ui/NoFeaturesEmptyState.d.ts +1 -0
  122. package/dist/components/ui/SearchDropdown.d.cts +28 -0
  123. package/dist/components/ui/SearchDropdown.d.ts +28 -0
  124. package/dist/components/ui/ToolButton.d.cts +19 -0
  125. package/dist/components/ui/ToolButton.d.ts +19 -0
  126. package/dist/components/ui/Tooltip.d.cts +12 -0
  127. package/dist/components/ui/Tooltip.d.ts +12 -0
  128. package/dist/components/ui/panelHeader.d.cts +2 -0
  129. package/dist/components/ui/panelHeader.d.ts +2 -0
  130. package/dist/components/ui/resizeEdge.d.cts +4 -0
  131. package/dist/components/ui/resizeEdge.d.ts +4 -0
  132. package/dist/contexts/ElementEditorConfigContext.d.cts +351 -0
  133. package/dist/contexts/ElementEditorConfigContext.d.ts +351 -0
  134. package/dist/contexts/EventContext.d.cts +69 -0
  135. package/dist/contexts/EventContext.d.ts +69 -0
  136. package/dist/contexts/MapControllerContext.d.cts +24 -0
  137. package/dist/contexts/MapControllerContext.d.ts +24 -0
  138. package/dist/contexts/ShortcutConfigContext.d.cts +16 -0
  139. package/dist/contexts/ShortcutConfigContext.d.ts +16 -0
  140. package/dist/contexts/ThemeContext.d.cts +12 -0
  141. package/dist/contexts/ThemeContext.d.ts +12 -0
  142. package/dist/element-editor-ui.cjs +1 -0
  143. package/dist/element-editor-ui.es.js +102 -0
  144. package/dist/geometryWorker-CCwg4tNC.cjs +1 -0
  145. package/dist/geometryWorker-DgQCFSmD.js +25 -0
  146. package/dist/hooks/dragShield.d.cts +7 -0
  147. package/dist/hooks/dragShield.d.ts +7 -0
  148. package/dist/hooks/themeInputs.d.cts +14 -0
  149. package/dist/hooks/themeInputs.d.ts +14 -0
  150. package/dist/hooks/useAccentPalette.d.cts +15 -0
  151. package/dist/hooks/useAccentPalette.d.ts +15 -0
  152. package/dist/hooks/useAccentStyle.d.cts +39 -0
  153. package/dist/hooks/useAccentStyle.d.ts +39 -0
  154. package/dist/hooks/useAdapterControls.d.cts +280 -0
  155. package/dist/hooks/useAdapterControls.d.ts +280 -0
  156. package/dist/hooks/useBalancedWrap.d.cts +8 -0
  157. package/dist/hooks/useBalancedWrap.d.ts +8 -0
  158. package/dist/hooks/useContextMenu.d.cts +11 -0
  159. package/dist/hooks/useContextMenu.d.ts +11 -0
  160. package/dist/hooks/useDataChangeSubscription.d.cts +9 -0
  161. package/dist/hooks/useDataChangeSubscription.d.ts +9 -0
  162. package/dist/hooks/useDragWindow.d.cts +9 -0
  163. package/dist/hooks/useDragWindow.d.ts +9 -0
  164. package/dist/hooks/useFocusTrap.d.cts +7 -0
  165. package/dist/hooks/useFocusTrap.d.ts +7 -0
  166. package/dist/hooks/useGeoJSONDrop.d.cts +40 -0
  167. package/dist/hooks/useGeoJSONDrop.d.ts +40 -0
  168. package/dist/hooks/useGeoJSONExport.d.cts +69 -0
  169. package/dist/hooks/useGeoJSONExport.d.ts +69 -0
  170. package/dist/hooks/useGeoJSONFileImport.d.cts +24 -0
  171. package/dist/hooks/useGeoJSONFileImport.d.ts +24 -0
  172. package/dist/hooks/useInlineRename.d.cts +26 -0
  173. package/dist/hooks/useInlineRename.d.ts +26 -0
  174. package/dist/hooks/useJumpToFeature.d.cts +3 -0
  175. package/dist/hooks/useJumpToFeature.d.ts +3 -0
  176. package/dist/hooks/useKeyboardShortcuts.d.cts +9 -0
  177. package/dist/hooks/useKeyboardShortcuts.d.ts +9 -0
  178. package/dist/hooks/useNominatim.d.cts +24 -0
  179. package/dist/hooks/useNominatim.d.ts +24 -0
  180. package/dist/hooks/usePanelOffset.d.cts +14 -0
  181. package/dist/hooks/usePanelOffset.d.ts +14 -0
  182. package/dist/hooks/useResizablePanel.d.cts +4 -0
  183. package/dist/hooks/useResizablePanel.d.ts +4 -0
  184. package/dist/hooks/useRootTokens.d.cts +27 -0
  185. package/dist/hooks/useRootTokens.d.ts +27 -0
  186. package/dist/hooks/useSearchState.d.cts +23 -0
  187. package/dist/hooks/useSearchState.d.ts +23 -0
  188. package/dist/hooks/useServiceAttribution.d.cts +13 -0
  189. package/dist/hooks/useServiceAttribution.d.ts +13 -0
  190. package/dist/hooks/useWindowEscape.d.cts +25 -0
  191. package/dist/hooks/useWindowEscape.d.ts +25 -0
  192. package/dist/hooks/useWindowFocus.d.cts +4 -0
  193. package/dist/hooks/useWindowFocus.d.ts +4 -0
  194. package/dist/hooks/useWorkerGeometryPreview.d.cts +22 -0
  195. package/dist/hooks/useWorkerGeometryPreview.d.ts +22 -0
  196. package/dist/index-CILw1Du5.js +3165 -0
  197. package/dist/index-DG4wEjGj.cjs +1 -0
  198. package/dist/index.d.cts +89 -0
  199. package/dist/index.d.ts +89 -0
  200. package/dist/internal.cjs +1 -0
  201. package/dist/internal.d.cts +16 -0
  202. package/dist/internal.d.ts +16 -0
  203. package/dist/internal.es.js +42 -0
  204. package/dist/primitives.cjs +1 -0
  205. package/dist/primitives.d.cts +19 -0
  206. package/dist/primitives.d.ts +19 -0
  207. package/dist/primitives.es.js +17 -0
  208. package/dist/store/StoreContext.d.cts +17 -0
  209. package/dist/store/StoreContext.d.ts +17 -0
  210. package/dist/types/events.d.cts +95 -0
  211. package/dist/types/events.d.ts +95 -0
  212. package/dist/useAccentStyle-CPo2XqAn.js +412 -0
  213. package/dist/useAccentStyle-hsGvyHZc.cjs +1 -0
  214. package/dist/useAdapterControls-BBObhzVX.cjs +1 -0
  215. package/dist/useAdapterControls-DVjkwRZ_.js +691 -0
  216. package/dist/useContextMenu-DJ2Cti85.js +10 -0
  217. package/dist/useContextMenu-DbxMvb1s.cjs +1 -0
  218. package/dist/useFocusTrap-BBjPCfDR.cjs +1 -0
  219. package/dist/useFocusTrap-CKxKT8De.js +25 -0
  220. package/dist/useJumpToFeature-Bdz2hqOC.js +16 -0
  221. package/dist/useJumpToFeature-LwjxGzfy.cjs +1 -0
  222. package/dist/useWindowFocus-DuQVjnHE.js +80 -0
  223. package/dist/useWindowFocus-EemgNOuz.cjs +1 -0
  224. package/dist/utils/booleanValue.d.cts +4 -0
  225. package/dist/utils/booleanValue.d.ts +4 -0
  226. package/dist/utils/clipboardError.d.cts +3 -0
  227. package/dist/utils/clipboardError.d.ts +3 -0
  228. package/dist/utils/download.d.cts +42 -0
  229. package/dist/utils/download.d.ts +42 -0
  230. package/dist/utils/geojsonDocument.d.cts +168 -0
  231. package/dist/utils/geojsonDocument.d.ts +168 -0
  232. package/dist/utils/geometryWorkerClient.d.cts +6 -0
  233. package/dist/utils/geometryWorkerClient.d.ts +6 -0
  234. package/dist/utils/layerOrder.d.cts +9 -0
  235. package/dist/utils/layerOrder.d.ts +9 -0
  236. package/dist/utils/lazyWithPreload.d.cts +24 -0
  237. package/dist/utils/lazyWithPreload.d.ts +24 -0
  238. package/dist/utils/lineSmooth.d.cts +7 -0
  239. package/dist/utils/lineSmooth.d.ts +7 -0
  240. package/dist/utils/platform.d.cts +2 -0
  241. package/dist/utils/platform.d.ts +2 -0
  242. package/dist/workers/geometryWorker.d.cts +1 -0
  243. package/dist/workers/geometryWorker.d.ts +1 -0
  244. package/package.json +133 -3
@@ -0,0 +1,3165 @@
1
+ var Tr = Object.defineProperty;
2
+ var Ar = (t, e, n) => e in t ? Tr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var Pt = (t, e, n) => Ar(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import Fr, { lazy as _t, useState as q, createElement as zr, useContext as tt, useCallback as J, createContext as Lr, useRef as B, useLayoutEffect as pe, useEffect as $, useMemo as ue, isValidElement as Rr, cloneElement as $r, memo as Gt, Suspense as Ut, useId as Kr } from "react";
5
+ import { e as oe, h as ae, g as Ae, b as Or, s as jt, u as S, f as U, l as Br, E as Wr, T as _r, m as Gr, M as Ur } from "./useAdapterControls-DVjkwRZ_.js";
6
+ import { jsx as r, jsxs as T, Fragment as le } from "react/jsx-runtime";
7
+ import { u as ce, f as jr, e as qr, w as Hr, E as Vr } from "./useAccentStyle-CPo2XqAn.js";
8
+ import { loadCustomBindings as Jr, syncShortcutCache as $e, getEffectiveKey as qt, findConflict as Xr, saveCustomBindings as Xe, getCurrentKey as Zr, isMultiGeometry as Yr, getPartCount as rt, sidebarTakesSpace as nt, NARROW_EDITOR_WIDTH as Dt, getPartGeometry as Qr, getPartLabel as en, BOUNDARIES_SCHEMA_ID as tn, featureLimitMessage as rn, canProcessShape as Fe, setGeometryRunner as nn, countShapeVertices as Ke, resolveUnitSystem as on, isLineGeometryType as sn, placeBox as ln } from "@element-editor/core/internal";
9
+ import { getGeometryBBox as ot, readStorage as Ht, writeStorage as an, getFixedShortcutDisplay as Vt, ElementEditorError as Be, formatLength as It, subscribeToDataChanges as cn, readAccentPalette as Mt, DEFAULT_MAX_IMPORT_BYTES as dn, parseGeoJSONText as un } from "@element-editor/core";
10
+ import { MapPinPlus as mn, SidebarSimple as Jt, ArrowLeft as fn, CopySimple as Xt, Trash as ze, CaretDown as pn, CaretRight as hn, Check as gn, Copy as yn, FolderPlus as bn, MapPin as Zt, Polygon as Yt, StackSimple as Ye, LineSegment as Qt, PencilSimple as vn, EyeClosed as Qe, Eye as st, Folder as xn, FolderOpen as wn, DotsThree as kn, Pencil as Sn, FolderMinus as Cn, Path as Nn, Circle as En, Rectangle as Pn, ScribbleLoop as Dn, HandTap as In, Ruler as Mn, MagnifyingGlass as Ze, X as Tt, Resize as er, Scissors as tr, Knife as rr, WaveSine as nr, SquareLogo as or, Shapes as sr, StackPlus as ir, LineSegments as Tn, DotOutline as An, Crosshair as Fn, ArrowArcRight as zn, ArrowArcLeft as Ln, ArrowsHorizontal as Rn, Hexagon as $n, CircleHalfTilt as Kn, CornersOut as On, NavigationArrow as Bn } from "@phosphor-icons/react";
11
+ import { useShallow as Wn } from "zustand/react/shallow";
12
+ import { i as _n, c as lr, I as At, T as Gn, f as be, a as Q, B as we, b as Ie, C as ar, S as Ft, d as me, g as zt, K as Oe, E as te, e as Ne, h as Un } from "./EditToolbarBtn-SR4xHd8G.js";
13
+ import { clsx as ne } from "clsx";
14
+ import { createPortal as cr } from "react-dom";
15
+ import { centroid as jn } from "@turf/centroid";
16
+ import { featureCollection as qn } from "@turf/helpers";
17
+ import { bbox as dr } from "@turf/bbox";
18
+ function fe(t) {
19
+ let e = null, n = null;
20
+ const s = () => e ?? (e = t().then((i) => (n = i.default, i))), o = _t(s);
21
+ function d(i) {
22
+ const [m] = q(() => n ?? o);
23
+ return zr(m, i);
24
+ }
25
+ return Object.assign(d, { preload: s });
26
+ }
27
+ const ur = [];
28
+ function it(...t) {
29
+ for (const e of t) ur.push(e.preload);
30
+ }
31
+ let Lt = !1;
32
+ function Ks() {
33
+ if (Lt || typeof window > "u") return;
34
+ Lt = !0;
35
+ const t = () => {
36
+ for (const n of ur) n().catch(() => {
37
+ });
38
+ }, e = window.requestIdleCallback;
39
+ e ? e(t, { timeout: 3e3 }) : setTimeout(t, 1500);
40
+ }
41
+ const lt = Lr(null);
42
+ function Hn({ children: t }) {
43
+ const e = ce(), [n, s] = q(() => {
44
+ const c = Jr(e);
45
+ return $e(c), c;
46
+ }), o = J((c) => qt(c, n), [n]), d = J((c, y) => {
47
+ const f = Xr(y, c, n);
48
+ if (f) return f;
49
+ const h = { ...n, [c]: y };
50
+ return s(h), Xe(h, e), $e(h), null;
51
+ }, [n, e]), i = J((c) => {
52
+ const y = { ...n };
53
+ delete y[c], s(y), Xe(y, e), $e(y);
54
+ }, [n, e]), m = J(() => {
55
+ s({}), Xe({}, e), $e({});
56
+ }, [e]);
57
+ return /* @__PURE__ */ r(lt.Provider, { value: { custom: n, getKey: o, setKey: d, resetKey: i, resetAll: m }, children: t });
58
+ }
59
+ function Vn() {
60
+ return tt(lt);
61
+ }
62
+ function Ee() {
63
+ const t = tt(lt);
64
+ if (!t) throw new Error("useShortcutConfig must be used inside ShortcutConfigProvider");
65
+ return t;
66
+ }
67
+ const mr = fe(() => import("./FeatureList-Bo9w9nre.js")), Jn = fe(() => import("./DataTable-CS-3dIqY.js")), Xn = fe(() => import("./SchemaEditor-ryoTgaLb.js"));
68
+ it(mr, Jn, Xn);
69
+ function Zn() {
70
+ return /* @__PURE__ */ T("div", { className: "flex flex-col items-center justify-center gap-3 h-full text-elm-text-muted", children: [
71
+ /* @__PURE__ */ r(mn, { size: 40, weight: "light" }),
72
+ /* @__PURE__ */ r("p", { className: "text-sm text-center text-balance leading-snug", children: "No features yet — add a point, line, or area" })
73
+ ] });
74
+ }
75
+ const Yn = () => typeof navigator < "u" && /Mac/.test(navigator.platform);
76
+ function Qn(t) {
77
+ const e = t == null ? void 0 : t.name;
78
+ return {
79
+ type: "error",
80
+ code: e === "NotAllowedError" ? "permission-denied" : e === "TypeError" ? "unsupported" : "unknown",
81
+ source: "clipboard",
82
+ message: "Could not copy to the clipboard",
83
+ cause: t,
84
+ quiet: !0
85
+ };
86
+ }
87
+ function eo(t, e) {
88
+ if (e.length === 0) return t.map((s) => s.id);
89
+ const n = [];
90
+ for (const s of e)
91
+ for (const o of t)
92
+ o.groupId === s.id && n.push(o.id);
93
+ for (const s of t)
94
+ s.groupId || n.push(s.id);
95
+ return n;
96
+ }
97
+ function Os(t, e) {
98
+ const n = [];
99
+ for (const s of e)
100
+ if (!s.collapsed)
101
+ for (const o of t) o.groupId === s.id && n.push(o.id);
102
+ for (const s of t) s.groupId || n.push(s.id);
103
+ return n;
104
+ }
105
+ const to = "data-elm-window", et = /* @__PURE__ */ new WeakMap();
106
+ function ro(t) {
107
+ const e = et.get(t);
108
+ if (!(e != null && e.size)) return !1;
109
+ let n = null;
110
+ for (const s of e) (!n || s.z() > n.z()) && (n = s);
111
+ return n == null || n.close(), !!n;
112
+ }
113
+ function Bs(t, e, n, s, { topWindow: o = !0 } = {}) {
114
+ const { uiStore: d } = oe(), i = B(n), m = B(s);
115
+ pe(() => {
116
+ i.current = n, m.current = s;
117
+ }), $(() => {
118
+ if (!e) return;
119
+ const c = document.activeElement, y = { z: () => m.current, close: () => i.current() };
120
+ let f = et.get(d);
121
+ f || et.set(d, f = /* @__PURE__ */ new Set()), o && f.add(y);
122
+ const h = t.current;
123
+ function u(x) {
124
+ x.key !== "Escape" || x.defaultPrevented || !(h != null && h.contains(x.target)) || (x.preventDefault(), i.current());
125
+ }
126
+ return document.addEventListener("keydown", u), () => {
127
+ f.delete(y), document.removeEventListener("keydown", u);
128
+ const x = document.activeElement;
129
+ (!x || x === document.body || ((h == null ? void 0 : h.contains(x)) ?? !1) || !x.isConnected) && (c != null && c.isConnected) && c !== document.body && c.focus({ preventScroll: !0 });
130
+ };
131
+ }, [e, t, d, o]);
132
+ }
133
+ function no() {
134
+ return new Promise((t) => {
135
+ const e = document.createElement("input");
136
+ e.type = "file", e.accept = ".geojson,.json,application/geo+json,application/json", e.style.display = "none", document.body.appendChild(e);
137
+ let n = !1;
138
+ const s = () => {
139
+ n || (n = !0, e.remove());
140
+ };
141
+ e.addEventListener("change", () => {
142
+ var d;
143
+ const o = ((d = e.files) == null ? void 0 : d[0]) ?? null;
144
+ s(), t(o);
145
+ }, { once: !0 }), e.addEventListener("cancel", () => {
146
+ s(), t(null);
147
+ }, { once: !0 }), e.click();
148
+ });
149
+ }
150
+ const Ce = /* @__PURE__ */ new Map();
151
+ function fr(t) {
152
+ if (t.closest("[data-elm-portal]")) return !0;
153
+ let e = t;
154
+ for (; e.parentElement && e.parentElement !== document.body; ) e = e.parentElement;
155
+ return e.parentElement === document.body && (e.hasAttribute("data-elm-theme") || e.hasAttribute("data-elm-portal"));
156
+ }
157
+ function oo(t, e) {
158
+ if (!e || t.composedPath().includes(e.root)) return !0;
159
+ const n = document.activeElement;
160
+ return !n || n === document.body || fr(n) ? e.pointerInside ?? Ce.size === 1 : !1;
161
+ }
162
+ function ke() {
163
+ const { uiStore: t } = oe();
164
+ return J((e) => oo(e, Ce.get(t)), [t]);
165
+ }
166
+ const so = 140;
167
+ function io(t, e) {
168
+ t.querySelectorAll(`[data-elm-shortcut="${e}"]`).forEach((n) => {
169
+ n.disabled || (n.setAttribute("data-pressed", ""), setTimeout(() => n.removeAttribute("data-pressed"), so));
170
+ });
171
+ }
172
+ const lo = ["point", "line", "polygon", "route", "circle", "rectangle", "freehand", "picker"];
173
+ function Ws(t) {
174
+ var x;
175
+ const { dataStore: e, uiStore: n } = oe(), s = ae(), { panTo: o, fitBounds: d, setZoom: i } = Ae(), m = Or(), c = ce(), y = ke(), f = (x = Vn()) == null ? void 0 : x.custom, h = B(f);
176
+ h.current = f;
177
+ const u = J((w) => h.current ? qt(w, h.current) : Zr(w), []);
178
+ $(() => {
179
+ if (!t) return;
180
+ const w = t.closest("[data-elm-theme]") ?? t, M = { root: w, pointerInside: null };
181
+ Ce.set(n, M);
182
+ const C = (l) => {
183
+ l.composedPath().includes(w) ? M.pointerInside = !0 : l.target instanceof Element && fr(l.target) || (M.pointerInside = !1);
184
+ };
185
+ return document.addEventListener("pointerdown", C, { capture: !0, passive: !0 }), () => {
186
+ Ce.get(n) === M && Ce.delete(n), document.removeEventListener("pointerdown", C, { capture: !0 });
187
+ };
188
+ }, [t, n]), $(() => {
189
+ if (!c.ui.keyboardShortcuts.enabled || !c.ui.keyboardShortcuts.mapZoom) return;
190
+ function w(M) {
191
+ if (!(M.metaKey || M.ctrlKey) || !y(M)) return;
192
+ const C = M.target, l = C == null ? void 0 : C.tagName;
193
+ if (l === "INPUT" || l === "TEXTAREA" || l === "SELECT" || C != null && C.isContentEditable) return;
194
+ const p = M.key === "+" || M.key === "=", a = M.key === "-" || M.key === "_";
195
+ if (!p && !a || !i) return;
196
+ M.preventDefault();
197
+ const E = e.getState().currentZoom;
198
+ i(E + (p ? 1 : -1));
199
+ }
200
+ return window.addEventListener("keydown", w, { capture: !0 }), () => window.removeEventListener("keydown", w, { capture: !0 });
201
+ }, [c.ui.keyboardShortcuts.enabled, c.ui.keyboardShortcuts.mapZoom, i, e]), $(() => {
202
+ const w = c.ui.keyboardShortcuts.enabled;
203
+ function M(l) {
204
+ var L;
205
+ if (!w && l.key !== "Enter" || !y(l)) return;
206
+ const p = e.getState(), a = n.getState(), E = a.readonly, g = (v) => {
207
+ var W;
208
+ return io(((W = Ce.get(n)) == null ? void 0 : W.root) ?? document, v);
209
+ }, N = l.target.tagName, P = l.target, z = l.composedPath(), K = z.some((v) => {
210
+ if (!(v instanceof Element)) return !1;
211
+ const W = v.getAttribute("role");
212
+ return W === "grid" || W === "treegrid";
213
+ }), b = N === "INPUT" || N === "TEXTAREA" || N === "SELECT" || P.isContentEditable || K, k = l.key.toLowerCase();
214
+ if (!b && !E && k === "z" && (l.metaKey || l.ctrlKey) && !l.shiftKey) {
215
+ l.preventDefault(), g("undo"), p.undoStack.length > 0 && (p.undo(), s({ type: "undo" }));
216
+ return;
217
+ }
218
+ if (!b && !E && k === "z" && (l.metaKey || l.ctrlKey) && l.shiftKey) {
219
+ l.preventDefault(), g("redo"), p.redoStack.length > 0 && (p.redo(), s({ type: "redo" }));
220
+ return;
221
+ }
222
+ if (!b && (l.metaKey || l.ctrlKey) && (l.key === "a" || l.key === "A")) {
223
+ l.preventDefault();
224
+ const v = new Set(p.groups.filter((H) => H.hidden).map((H) => H.id)), W = p.features.filter((H) => !H.hidden && !(H.groupId && v.has(H.groupId))).map((H) => H.id);
225
+ W.length > 0 && p.setSelection(W);
226
+ return;
227
+ }
228
+ if (!b && (l.metaKey || l.ctrlKey) && !l.shiftKey && (l.key === "j" || l.key === "J")) {
229
+ l.preventDefault();
230
+ const v = !a.autoExitAfterDraw;
231
+ a.setAutoExitAfterDraw(v), s({
232
+ type: "success",
233
+ message: v ? "Drawing tools will exit after each shape" : "Drawing tools will stay active after each shape",
234
+ description: v ? "You’ll go back to select mode. Press a tool key to draw again." : "Keep drawing more shapes in a row. Press the tool key again or Esc to exit."
235
+ });
236
+ return;
237
+ }
238
+ if (!b && !E && (l.metaKey || l.ctrlKey) && !l.shiftKey && (l.key === "o" || l.key === "O")) {
239
+ l.preventDefault(), no().then((v) => {
240
+ v && m(v);
241
+ });
242
+ return;
243
+ }
244
+ if (!b && (l.metaKey || l.ctrlKey) && !l.shiftKey && (l.key === "s" || l.key === "S")) {
245
+ l.preventDefault();
246
+ const v = p.exportGeoJSON(), W = JSON.parse(v);
247
+ if (!Array.isArray(W.features) || W.features.length === 0) {
248
+ s({ type: "warning", message: "Export failed", description: "No features to export — draw or import something first." });
249
+ return;
250
+ }
251
+ const H = W.features.length;
252
+ (async () => {
253
+ const F = await jt(v);
254
+ F && s({
255
+ type: "success",
256
+ message: `Exported ${F.name}`,
257
+ description: `${H === 1 ? "1 feature" : `${H} features`} · ${(F.bytes / 1024).toFixed(1)} KB`
258
+ });
259
+ })();
260
+ return;
261
+ }
262
+ if (!b && (l.metaKey || l.ctrlKey)) {
263
+ if (l.key === "c") {
264
+ if (p.selectedIds.length === 0) return;
265
+ p.copySelection().then((v) => s(v ? { type: "selection:copied" } : { type: "warning", message: "Copied for pasting in this editor only", description: "The browser did not allow writing to the system clipboard." }));
266
+ return;
267
+ }
268
+ if (l.key === "d") {
269
+ if (l.preventDefault(), E) return;
270
+ g("duplicate");
271
+ const v = p.selectedIds;
272
+ if (p.duplicateSelection())
273
+ if (v.length === 1) {
274
+ const W = e.getState().features.find((H) => H.id === v[0]);
275
+ s({ type: "feature:duplicated", featureId: v[0], label: String((W == null ? void 0 : W.properties.name) || "feature") });
276
+ } else
277
+ s({ type: "features:duplicated", count: v.length });
278
+ return;
279
+ }
280
+ if (l.key === "e" || l.key === "E") {
281
+ if (p.selectedIds.length !== 1) return;
282
+ l.preventDefault(), a.openEditDialog(p.selectedIds[0], { focusFirstField: !0 });
283
+ return;
284
+ }
285
+ if ((l.key === "g" || l.key === "G") && !E) {
286
+ if (l.shiftKey) {
287
+ if (p.selectedIds.length === 0 || !p.features.some((W) => p.selectedIds.includes(W.id) && W.groupId)) return;
288
+ l.preventDefault(), p.ungroupSelection();
289
+ } else {
290
+ if (p.selectedIds.length === 0) return;
291
+ l.preventDefault();
292
+ const v = p.groupSelection();
293
+ v && a.setAutoFocusGroupId(v);
294
+ }
295
+ return;
296
+ }
297
+ }
298
+ if (l.key === "Enter") {
299
+ if ((!b || l.metaKey || l.ctrlKey) && a.editingMode !== "none") {
300
+ if (a.editingMode === "slice-shape") {
301
+ l.preventDefault(), a.commitSliceShape();
302
+ return;
303
+ } else if (a.editingMode === "cut-hole") {
304
+ l.preventDefault(), a.commitCutHole();
305
+ return;
306
+ } else if (a.editingMode === "draw-line" && a.lineInProgress.length >= 2) {
307
+ l.preventDefault(), a.commitLine({});
308
+ return;
309
+ } else if (a.editingMode === "draw-polygon" && a.polygonInProgress.length >= 3) {
310
+ l.preventDefault(), a.commitPolygon({});
311
+ return;
312
+ } else if (a.editingMode === "draw-route" && a.routeWaypoints.length >= 2) {
313
+ l.preventDefault(), a.commitRoute();
314
+ return;
315
+ }
316
+ }
317
+ if (!w) return;
318
+ const W = a.editingMode === "none" || a.editingMode === "draw-rect" || a.editingMode === "draw-circle" || a.editingMode === "place-point" || a.editingMode === "draw-freehand" || a.editingMode === "pick-shape" || a.editingMode === "draw-line" && a.lineInProgress.length < 2 || a.editingMode === "draw-polygon" && a.polygonInProgress.length < 3 || a.editingMode === "draw-route" && a.routeWaypoints.length < 2;
319
+ if (a.dialogState.type === "closed") {
320
+ if (!b && !E && !((L = P.closest) != null && L.call(P, 'button, a[href], [role="button"]')) && !l.metaKey && !l.ctrlKey && !l.altKey && W) {
321
+ const H = p.selectedIds;
322
+ if (H.length === 1) {
323
+ const F = p.features.find((G) => G.id === H[0]), I = F == null ? void 0 : F.geometry.type;
324
+ if (I === "LineString" || I === "Polygon" || I === "MultiLineString" || I === "MultiPolygon" || I === "GeometryCollection") {
325
+ l.preventDefault();
326
+ const G = !a.vertexEditActive;
327
+ G && a.editingMode !== "none" && a.setEditingMode("none"), a.setVertexEditActive(G);
328
+ return;
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ const D = z.some((v) => v instanceof Element && v.hasAttribute("data-elm-search-open"));
335
+ if (l.key === "Tab" && !b && a.dialogState.type === "closed" && !D && !l.metaKey && !l.ctrlKey && !l.altKey) {
336
+ const v = p.features;
337
+ if (v.length === 0) return;
338
+ l.preventDefault();
339
+ const W = eo(v, p.groups), H = p.selectedIds.length === 1 ? p.selectedIds[0] : null, F = H ? W.indexOf(H) : -1;
340
+ let I;
341
+ l.shiftKey ? I = F <= 0 ? W.length - 1 : F - 1 : I = F >= W.length - 1 ? 0 : F + 1;
342
+ const _ = W[I];
343
+ p.selectFeature(_);
344
+ const G = v.find((V) => V.id === _);
345
+ if (G)
346
+ if (G.geometry.type === "Point") {
347
+ const [V, Y] = G.geometry.coordinates;
348
+ o == null || o([Y, V]);
349
+ } else
350
+ d == null || d(G.bbox || ot(G.geometry));
351
+ return;
352
+ }
353
+ if (!b && !l.metaKey && !l.ctrlKey && !l.altKey) {
354
+ const v = l.key.toLowerCase();
355
+ if (v === u("show-shortcuts")) {
356
+ l.preventDefault(), g("show-shortcuts"), a.shortcutsModalOpen ? a.closeShortcutsModal() : a.openShortcutsModal();
357
+ return;
358
+ }
359
+ if (c.ui.schemaEditor && !E && v === u("toggle-schema")) {
360
+ l.preventDefault(), g("toggle-schema"), a.toggleSchemaModal();
361
+ return;
362
+ }
363
+ if (c.ui.layerList && v === u("toggle-sidebar")) {
364
+ l.preventDefault(), g("toggle-sidebar"), a.setSidebarOpen(!a.sidebarOpen);
365
+ return;
366
+ }
367
+ }
368
+ if (!b && a.dialogState.type !== "new-point" && !l.metaKey && !l.ctrlKey && !l.altKey) {
369
+ const v = l.key.toLowerCase();
370
+ if (c.ui.dataTable && v === u("toggle-table")) {
371
+ l.preventDefault(), g("toggle-table"), a.toggleTable();
372
+ return;
373
+ }
374
+ if (c.ui.geojsonEditor && v === u("toggle-geojson")) {
375
+ l.preventDefault(), g("toggle-geojson"), a.toggleCodeModal();
376
+ return;
377
+ }
378
+ if (c.ui.zoomIndicator && v === u("set-zoom")) {
379
+ l.preventDefault(), g("set-zoom"), a.setZoomEditing(!0);
380
+ return;
381
+ }
382
+ if (v === u("measure")) {
383
+ g("measure"), a.setEditingMode(a.editingMode === "measure" ? "none" : "measure");
384
+ return;
385
+ }
386
+ if (E) return;
387
+ if (v === u("toggle-transform")) {
388
+ (p.selectedIds.length === 1 && p.selectedIds[0] || p.selectedIds.length > 0) && (g("toggle-transform"), a.setTransformActive(!a.transformActive), !a.transformActive && a.editingMode !== "none" && a.setEditingMode("none"));
389
+ return;
390
+ }
391
+ const W = a.isToolAvailable, H = (F) => {
392
+ a.editingMode !== F && !p.canAddFeatures(1) || (g(F === "pick-shape" ? "picker" : F), a.setEditingMode(a.editingMode === F ? "none" : F));
393
+ };
394
+ for (const F of lo) {
395
+ const I = jr[F];
396
+ if (W(F) && v === u(I === "pick-shape" ? "picker" : I)) {
397
+ H(I);
398
+ return;
399
+ }
400
+ }
401
+ if (v === u("cut-hole")) {
402
+ const F = p.features.find((I) => I.id === (p.selectedIds.length === 1 ? p.selectedIds[0] : null));
403
+ F && (F.geometry.type === "Polygon" || F.geometry.type === "MultiPolygon") && (g("cut-hole"), a.setEditingMode(a.editingMode === "cut-hole" ? "none" : "cut-hole"), a.setTransformActive(!1));
404
+ return;
405
+ }
406
+ if (v === u("slice-shape")) {
407
+ const F = p.features.find((I) => I.id === (p.selectedIds.length === 1 ? p.selectedIds[0] : null));
408
+ F && (F.geometry.type === "Polygon" || F.geometry.type === "MultiPolygon") && (g("slice-shape"), a.setEditingMode(a.editingMode === "slice-shape" ? "none" : "slice-shape"), a.setTransformActive(!1));
409
+ return;
410
+ }
411
+ if (v === u("break-apart")) {
412
+ const F = p.selectedIds.length === 1 ? p.selectedIds[0] : null, I = F ? p.features.find((_) => _.id === F) : null;
413
+ if (I && Yr(I.geometry)) {
414
+ g("break-apart");
415
+ const _ = rt(I.geometry);
416
+ p.breakMultiGeometry(F) && s({ type: "feature:broken", featureId: F, count: _, undo: () => e.getState().undo() });
417
+ }
418
+ return;
419
+ }
420
+ }
421
+ if (l.key !== "Delete" && l.key !== "Backspace" || E || a.dialogState.type === "new-point") return;
422
+ const R = p.selectedIds;
423
+ if (R.length === 0 || b || a.vertexEditActive) return;
424
+ const O = R.length, j = O === 1 ? p.features.find((v) => v.id === R[0]) : null, Z = O === 1 ? String((j == null ? void 0 : j.properties.name) || "Unnamed feature") : `${O} features`;
425
+ l.preventDefault(), l.stopImmediatePropagation(), g("delete-selected"), p.deleteSelection(), a.closeDialog(), s(O === 1 ? { type: "feature:deleted", featureId: R[0], label: Z, undo: () => e.getState().undo() } : { type: "features:deleted", count: O, undo: () => e.getState().undo() });
426
+ }
427
+ function C(l) {
428
+ var g;
429
+ if (!y(l)) return;
430
+ const p = l.target.tagName;
431
+ if (p === "INPUT" || p === "TEXTAREA" || p === "SELECT" || n.getState().readonly) return;
432
+ const a = (g = l.clipboardData) == null ? void 0 : g.getData("text");
433
+ if (a)
434
+ try {
435
+ const N = JSON.parse(a);
436
+ if (N.type === "FeatureCollection" || N.type === "Feature") {
437
+ const P = N.type === "FeatureCollection" ? N.features : [N];
438
+ e.setState({ clipboard: P }), e.getState().pasteSelection() && s({ type: "selection:pasted", count: P.length });
439
+ return;
440
+ }
441
+ } catch {
442
+ }
443
+ const E = e.getState().clipboard;
444
+ E && E.length > 0 && e.getState().pasteSelection() && s({ type: "selection:pasted", count: E.length });
445
+ }
446
+ return window.addEventListener("keydown", M), window.addEventListener("paste", C), () => {
447
+ window.removeEventListener("keydown", M), window.removeEventListener("paste", C);
448
+ };
449
+ }, [e, n, s, o, d, c, u, m]), $(() => {
450
+ function w(M) {
451
+ var a;
452
+ if (M.key !== "Escape" || !y(M)) return;
453
+ const C = M.target;
454
+ if (C && (C.tagName === "INPUT" || C.tagName === "TEXTAREA" || C.isContentEditable) || (a = C == null ? void 0 : C.closest) != null && a.call(C, `[${to}]`) || _n()) return;
455
+ const l = n.getState();
456
+ if (l.dialogState.type !== "closed") {
457
+ l.closeDialog(), M.stopPropagation();
458
+ return;
459
+ }
460
+ if (l.editingMode === "none") {
461
+ if (l.vertexEditActive) {
462
+ l.setVertexEditActive(!1), M.stopPropagation();
463
+ return;
464
+ }
465
+ if (l.transformActive) {
466
+ l.setTransformActive(!1), M.stopPropagation();
467
+ return;
468
+ }
469
+ if (e.getState().selectedIds.length > 0) {
470
+ e.getState().selectFeature(null), M.stopPropagation();
471
+ return;
472
+ }
473
+ ro(n) && M.stopPropagation();
474
+ }
475
+ }
476
+ return window.addEventListener("keydown", w, { capture: !0 }), () => window.removeEventListener("keydown", w, { capture: !0 });
477
+ }, []);
478
+ }
479
+ const ao = /* @__PURE__ */ new Set(["true", "yes", "y", "1", "on", "x", "✓"]), co = /* @__PURE__ */ new Set(["false", "no", "n", "0", "off", ""]);
480
+ function uo(t) {
481
+ const e = t.trim().toLowerCase();
482
+ return ao.has(e) ? !0 : co.has(e) ? !1 : null;
483
+ }
484
+ function mo(t) {
485
+ return typeof t == "boolean" ? t : typeof t == "number" ? t !== 0 : typeof t == "string" ? uo(t) === !0 : !1;
486
+ }
487
+ function fo({ fields: t, values: e, onChange: n, errors: s, autoFocusFirst: o, readonly: d }) {
488
+ return /* @__PURE__ */ r("div", { className: "space-y-3", children: t.map((i, m) => {
489
+ const c = e[i.key] ?? "", y = s == null ? void 0 : s[i.key], f = o && m === 0, h = /* @__PURE__ */ T("label", { className: "block text-xs font-medium text-(--elm-text-muted,var(--color-gray-600)) dark:text-(--elm-text-muted,var(--color-gray-400)) mb-1", children: [
490
+ i.label,
491
+ i.required && /* @__PURE__ */ r("span", { className: "text-rose-500 ml-0.5", children: "*" })
492
+ ] });
493
+ let u;
494
+ return i.type === "boolean" ? /* @__PURE__ */ T("div", { "data-field-key": i.key, className: "flex items-center justify-between py-1 border-b border-transparent", children: [
495
+ h,
496
+ /* @__PURE__ */ T("label", { className: "relative inline-flex items-center cursor-pointer", children: [
497
+ /* @__PURE__ */ r(
498
+ "input",
499
+ {
500
+ type: "checkbox",
501
+ checked: mo(c),
502
+ onChange: (x) => n(i.key, x.target.checked),
503
+ disabled: d,
504
+ className: "sr-only peer"
505
+ }
506
+ ),
507
+ /* @__PURE__ */ r("div", { className: "w-9 h-5 bg-(--elm-border-strong,var(--color-gray-200)) peer-focus-visible:ring-2 peer-focus-visible:ring-elm-focus-ring peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-elm-surface rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-(--elm-border-strong,var(--color-gray-300)) after:border after:rounded-full after:h-4 after:w-4 after:transition-transform peer-checked:bg-primary-500 opacity-90 hover:opacity-100 disabled:opacity-50" })
508
+ ] }),
509
+ y && /* @__PURE__ */ r("p", { className: "mt-1 text-xs text-rose-500 w-full basis-full", children: y })
510
+ ] }, i.key) : (i.type === "textarea" ? u = /* @__PURE__ */ r(
511
+ Gn,
512
+ {
513
+ rows: 3,
514
+ value: String(c),
515
+ onChange: (x) => n(i.key, x.target.value),
516
+ autoFocus: f,
517
+ error: !!y,
518
+ disabled: d
519
+ }
520
+ ) : i.type === "select" ? u = /* @__PURE__ */ T(
521
+ lr,
522
+ {
523
+ value: String(c),
524
+ onChange: (x) => n(i.key, x.target.value),
525
+ autoFocus: f,
526
+ error: !!y,
527
+ disabled: d,
528
+ children: [
529
+ /* @__PURE__ */ r("option", { value: "", children: "— select —" }),
530
+ (i.options ?? []).map((x) => /* @__PURE__ */ r("option", { value: x, children: x }, x))
531
+ ]
532
+ }
533
+ ) : i.type === "number" ? u = /* @__PURE__ */ r(
534
+ At,
535
+ {
536
+ type: "number",
537
+ value: String(c),
538
+ onChange: (x) => n(i.key, x.target.value),
539
+ autoFocus: f,
540
+ error: !!y,
541
+ disabled: d,
542
+ min: i.min,
543
+ max: i.max
544
+ }
545
+ ) : u = /* @__PURE__ */ r(
546
+ At,
547
+ {
548
+ type: i.type,
549
+ value: String(c),
550
+ onChange: (x) => n(i.key, x.target.value),
551
+ autoFocus: f,
552
+ error: !!y,
553
+ disabled: d
554
+ }
555
+ ), // `data-field-key` lets the parent panel focus the offending input
556
+ // by key after a failed save (see handleSave in FeatureSidePanel).
557
+ /* @__PURE__ */ T("div", { "data-field-key": i.key, children: [
558
+ h,
559
+ u,
560
+ y && /* @__PURE__ */ r("p", { className: "mt-1 text-xs text-rose-500", children: y })
561
+ ] }, i.key));
562
+ }) });
563
+ }
564
+ const Me = "items-center justify-center flex-shrink-0 p-[3px] rounded-elm-control text-elm-text-secondary hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) active:scale-[0.95] disabled:text-elm-text-disabled disabled:hover:bg-transparent disabled:active:scale-100 disabled:cursor-not-allowed transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-elm-focus-ring", po = "h-10 box-border flex items-center flex-shrink-0 border-b border-elm-border bg-elm-surface-sunken";
565
+ function pr() {
566
+ const t = S((o) => o.setSidebarOpen), e = S((o) => o.layout === "split"), n = ce(), { getKey: s } = Ee();
567
+ return e ? null : /* @__PURE__ */ r(
568
+ be,
569
+ {
570
+ content: "Hide layers",
571
+ shortcut: n.ui.keyboardShortcuts.enabled ? /* @__PURE__ */ r(Q, { children: s("toggle-sidebar").toUpperCase() }) : void 0,
572
+ side: "bottom",
573
+ children: /* @__PURE__ */ r(
574
+ "button",
575
+ {
576
+ "aria-label": "Collapse layers panel",
577
+ "data-elm-shortcut": "toggle-sidebar",
578
+ onClick: (o) => {
579
+ t(!1), o.currentTarget.blur();
580
+ },
581
+ className: `flex ${Me}`,
582
+ children: /* @__PURE__ */ r(Jt, { size: 16, mirrored: !0 })
583
+ }
584
+ )
585
+ }
586
+ );
587
+ }
588
+ const ho = /("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false)\b|\bnull\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g, go = "text-gray-800 dark:text-[#e06c75]", yo = "text-[#a11] dark:text-[#98c379]", bo = "text-[#164] dark:text-[#d19a66]", vo = "text-[#219] dark:text-[#d19a66]", xo = "text-[#164] dark:text-[#d19a66]";
589
+ function wo(t) {
590
+ const e = [];
591
+ let n = 0;
592
+ for (const s of t.matchAll(ho)) {
593
+ const o = s.index;
594
+ o > n && e.push(t.slice(n, o));
595
+ const [d, i, m, c] = s;
596
+ i !== void 0 ? (e.push(/* @__PURE__ */ r("span", { className: m ? go : yo, children: i }, o)), m && e.push(m)) : c !== void 0 ? e.push(/* @__PURE__ */ r("span", { className: vo, children: d }, o)) : e.push(/* @__PURE__ */ r("span", { className: d === "null" ? xo : bo, children: d }, o)), n = o + d.length;
597
+ }
598
+ return n < t.length && e.push(t.slice(n)), e;
599
+ }
600
+ function ko({ json: t, className: e }) {
601
+ const n = ue(() => wo(t), [t]);
602
+ return /* @__PURE__ */ r("pre", { className: e, children: n });
603
+ }
604
+ function Rt(t, e) {
605
+ if (t.required && (e == null || String(e).trim() === ""))
606
+ return `${t.label} is required`;
607
+ if (t.type === "number" && e !== void 0 && e !== null && String(e).trim() !== "") {
608
+ const n = Number(e);
609
+ if (!isNaN(n)) {
610
+ const s = t.min !== void 0, o = t.max !== void 0;
611
+ if (s && o && (n < t.min || n > t.max))
612
+ return `${t.label} must be between ${t.min} and ${t.max}`;
613
+ if (s && n < t.min) return `${t.label} must be ≥ ${t.min}`;
614
+ if (o && n > t.max) return `${t.label} must be ≤ ${t.max}`;
615
+ }
616
+ }
617
+ return null;
618
+ }
619
+ function hr(t, e) {
620
+ const n = S((i) => i.panelPrefs[t]), s = S((i) => i.setPanelPref), o = n !== null ? n : e;
621
+ return { open: o, toggle: () => s(t, !o) };
622
+ }
623
+ function So(t, e, n) {
624
+ if (t.type === "new-point") {
625
+ const s = {};
626
+ return e.fields.forEach((o) => {
627
+ s[o.key] = "";
628
+ }), t.prefill && Object.assign(s, t.prefill), s;
629
+ }
630
+ if (t.type === "edit") {
631
+ const s = n.find((o) => o.id === t.featureId);
632
+ if (s) return { ...s.properties };
633
+ }
634
+ return {};
635
+ }
636
+ function Co({ dialogState: t, collapsible: e = !1 }) {
637
+ const { dataStore: n } = oe(), s = ae(), o = S((I) => I.closeDialog), d = U((I) => I.selectFeature), i = U(Wn((I) => I.getVisibleSchemas())), m = U((I) => I.lastUsedSchemaId), c = S((I) => I.readonly), { uiStore: y } = oe(), f = ke(), h = U((I) => I.features), u = ue(
638
+ () => t.type === "edit" ? h.find((I) => I.id === t.featureId) ?? null : null,
639
+ [t, h]
640
+ ), x = U((I) => I.addFeature), w = U((I) => I.updateFeature), M = U((I) => I.deleteFeature), C = U((I) => I.duplicateFeature), l = U((I) => I.getDefaultSchema), p = U((I) => I.setLastUsedSchemaId), a = t.type === "new-point", E = l(), [g, N] = q(() => t.type === "edit" && (u != null && u.schemaId) ? u.schemaId : m && i.find((_) => _.id === m) ? m : E.id), P = i.find((I) => I.id === g) ?? E, [z, K] = q(
641
+ () => So(t, P, h)
642
+ ), [b, k] = q({}), D = u == null ? void 0 : u.properties, R = u == null ? void 0 : u.schemaId, [O, j] = q({ editProps: D, editSchemaId: R });
643
+ u && (O.editProps !== D || O.editSchemaId !== R) && (j({ editProps: D, editSchemaId: R }), K({ ...D }), R && N(R), k({}));
644
+ function Z(I) {
645
+ const _ = i.find((G) => G.id === I) ?? E;
646
+ if (a) {
647
+ const G = {};
648
+ _.fields.forEach((V) => {
649
+ G[V.key] = z[V.key] ?? "";
650
+ }), K(G);
651
+ }
652
+ N(I), p(I), k({});
653
+ }
654
+ $(() => {
655
+ if (c) return;
656
+ function I(_) {
657
+ if ((_.metaKey || _.ctrlKey) && _.key === "Enter" && f(_)) {
658
+ const G = y.getState();
659
+ if (G.lineInProgress.length > 0 || G.polygonInProgress.length > 0 || G.routeWaypoints.length > 0 || G.freehandPoints.length > 0 || G.circleCenter !== null || G.rectCorner !== null) return;
660
+ _.preventDefault(), L();
661
+ }
662
+ }
663
+ return window.addEventListener("keydown", I), () => window.removeEventListener("keydown", I);
664
+ });
665
+ function L() {
666
+ var G;
667
+ const I = {};
668
+ for (const V of P.fields) {
669
+ const Y = Rt(V, z[V.key]);
670
+ Y && (I[V.key] = Y);
671
+ }
672
+ if (Object.keys(I).length > 0) {
673
+ k(I);
674
+ const V = (G = P.fields.find((Y) => I[Y.key])) == null ? void 0 : G.key;
675
+ V && setTimeout(() => {
676
+ var ve;
677
+ const Y = document.querySelector(`[data-field-key="${CSS.escape(V)}"]`), re = Y == null ? void 0 : Y.querySelector("input, textarea, select");
678
+ re == null || re.focus(), re && "select" in re && ((ve = re.select) == null || ve.call(re));
679
+ }, 0);
680
+ return;
681
+ }
682
+ k({});
683
+ const _ = {};
684
+ for (const [V, Y] of Object.entries(z))
685
+ Y !== "" && (_[V] = Y);
686
+ a && t.type === "new-point" ? x({
687
+ type: "Feature",
688
+ id: crypto.randomUUID(),
689
+ schemaId: g,
690
+ geometry: { type: "Point", coordinates: t.coords },
691
+ properties: _
692
+ }) : u && w(u.id, { properties: _, schemaId: g }), o();
693
+ }
694
+ function v() {
695
+ if (!u) return;
696
+ const I = String(u.properties.name || "feature"), _ = u.id, G = C(_);
697
+ o(), G && s({ type: "feature:duplicated", featureId: _, label: I });
698
+ }
699
+ function W() {
700
+ if (!u) return;
701
+ const I = String(u.properties.name || "Unnamed feature"), _ = u.id;
702
+ M(_), o(), s({ type: "feature:deleted", featureId: _, label: I, undo: () => n.getState().undo() });
703
+ }
704
+ const H = a ? "New point" : u ? String(u.properties.name || "Edit feature") : "Edit feature", F = a ? "point" : (u == null ? void 0 : u.geometry.type) === "MultiPoint" ? "points" : (u == null ? void 0 : u.geometry.type) === "LineString" ? "line" : (u == null ? void 0 : u.geometry.type) === "MultiLineString" ? "lines" : (u == null ? void 0 : u.geometry.type) === "Polygon" ? "area" : (u == null ? void 0 : u.geometry.type) === "MultiPolygon" ? "areas" : (u == null ? void 0 : u.geometry.type) === "GeometryCollection" ? "mixed" : "point";
705
+ return /* @__PURE__ */ T("div", { className: "flex flex-col flex-1 min-h-0", children: [
706
+ /* @__PURE__ */ T("header", { className: "flex items-center gap-1 px-4 pt-4 pb-3 border-b border-elm-border flex-shrink-0 bg-elm-surface-sunken", children: [
707
+ e && /* @__PURE__ */ r(pr, {}),
708
+ /* @__PURE__ */ r(be, { content: "Back to layers", side: "bottom", children: /* @__PURE__ */ r("button", { type: "button", onClick: () => {
709
+ o(), d(null);
710
+ }, "aria-label": "Back to layers", className: `flex ${Me}`, children: /* @__PURE__ */ r(fn, { size: 16 }) }) }),
711
+ /* @__PURE__ */ T("div", { className: "flex-1 min-w-0 mx-1", children: [
712
+ /* @__PURE__ */ r("p", { className: "text-sm leading-5 font-semibold text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-100)) truncate", children: H }),
713
+ /* @__PURE__ */ r("p", { className: "text-xs leading-4 text-elm-text-subtle capitalize", children: F })
714
+ ] }),
715
+ u && /* @__PURE__ */ T(le, { children: [
716
+ !c && /* @__PURE__ */ r(
717
+ be,
718
+ {
719
+ content: "Duplicate",
720
+ shortcut: /* @__PURE__ */ T("span", { className: "flex items-center gap-0.5", children: [
721
+ /* @__PURE__ */ r(Q, { children: "⌘" }),
722
+ /* @__PURE__ */ r(Q, { children: "D" })
723
+ ] }),
724
+ side: "bottom",
725
+ children: /* @__PURE__ */ r("button", { type: "button", onClick: v, "aria-label": "Duplicate feature", className: `flex ${Me}`, children: /* @__PURE__ */ r(Xt, { size: 16 }) })
726
+ }
727
+ ),
728
+ !c && /* @__PURE__ */ r(be, { content: "Delete feature", side: "bottom", children: /* @__PURE__ */ r("button", { type: "button", onClick: W, "aria-label": "Delete feature", className: `flex ${Me}`, children: /* @__PURE__ */ r(ze, { size: 16 }) }) })
729
+ ] })
730
+ ] }),
731
+ /* @__PURE__ */ T("div", { className: "flex-1 overflow-y-auto min-h-0 px-4 pt-4", children: [
732
+ i.length > 1 && // mb-3 mirrors the inter-field spacing inside DynamicFieldRenderer
733
+ // (space-y-3) so Schema sits the same distance above Name as Name
734
+ // sits above Description, etc.
735
+ /* @__PURE__ */ T("div", { className: "mb-3", children: [
736
+ /* @__PURE__ */ r("label", { className: "block text-xs font-medium text-(--elm-text-muted,var(--color-gray-600)) dark:text-(--elm-text-muted,var(--color-gray-400)) mb-1", children: "Schema" }),
737
+ /* @__PURE__ */ r(
738
+ lr,
739
+ {
740
+ value: g,
741
+ onChange: (I) => Z(I.target.value),
742
+ disabled: c,
743
+ children: i.map((I) => {
744
+ var _;
745
+ return /* @__PURE__ */ T("option", { value: I.id, children: [
746
+ I.name,
747
+ I.id === ((_ = i[0]) == null ? void 0 : _.id) ? " (default)" : ""
748
+ ] }, I.id);
749
+ })
750
+ }
751
+ )
752
+ ] }),
753
+ /* @__PURE__ */ r(
754
+ fo,
755
+ {
756
+ fields: P.fields,
757
+ values: z,
758
+ onChange: (I, _) => {
759
+ K((V) => ({ ...V, [I]: _ }));
760
+ const G = P.fields.find((V) => V.key === I);
761
+ if (G) {
762
+ const V = Rt(G, _);
763
+ k((Y) => {
764
+ if (V) return { ...Y, [I]: V };
765
+ const re = { ...Y };
766
+ return delete re[I], re;
767
+ });
768
+ }
769
+ },
770
+ errors: b,
771
+ autoFocusFirst: !c && (a || t.type === "edit" && !!t.isNew || t.type === "edit" && !!t.focusFirstField),
772
+ readonly: c
773
+ }
774
+ ),
775
+ /* @__PURE__ */ r(Eo, { dialogState: t, editFeature: u ?? null, values: z, schemaId: g }),
776
+ /* @__PURE__ */ r(No, { dialogState: t, editFeature: u ?? null }),
777
+ /* @__PURE__ */ r("div", { className: "-mx-4 border-t border-elm-border" })
778
+ ] }),
779
+ !c && /* @__PURE__ */ r("div", { className: "px-4 py-3 border-t border-elm-border flex-shrink-0", children: /* @__PURE__ */ T(we, { variant: "primary", onClick: L, className: "w-full py-2 rounded-elm font-medium", children: [
780
+ "Save",
781
+ /* @__PURE__ */ r("span", { className: "ml-auto flex items-center gap-0.5", children: Yn() ? /* @__PURE__ */ T(le, { children: [
782
+ /* @__PURE__ */ r(Ie, { children: "⌘" }),
783
+ /* @__PURE__ */ r(Ie, { children: "↵" })
784
+ ] }) : /* @__PURE__ */ T(le, { children: [
785
+ /* @__PURE__ */ r(Ie, { children: "Ctrl" }),
786
+ /* @__PURE__ */ r(Ie, { children: "↵" })
787
+ ] }) })
788
+ ] }) })
789
+ ] });
790
+ }
791
+ function No({
792
+ dialogState: t,
793
+ editFeature: e
794
+ }) {
795
+ const n = ue(() => {
796
+ if (t.type === "new-point") {
797
+ const [i, m] = t.coords;
798
+ return [`${m.toFixed(6)}, ${i.toFixed(6)}`];
799
+ }
800
+ if (!e) return [];
801
+ if (e.geometry.type === "Point") {
802
+ const [i, m] = e.geometry.coordinates;
803
+ return [`${m.toFixed(6)}, ${i.toFixed(6)}`];
804
+ }
805
+ return e.geometry.type === "LineString" ? e.geometry.coordinates.map(([m, c], y) => `${y + 1}. ${c.toFixed(6)}, ${m.toFixed(6)}`) : e.geometry.type === "Polygon" ? e.geometry.coordinates[0].slice(0, -1).map(([m, c], y) => `${y + 1}. ${c.toFixed(6)}, ${m.toFixed(6)}`) : [];
806
+ }, [t, e]), s = n.length <= 5, { open: o, toggle: d } = hr("coordsOpen", s);
807
+ return n.length === 0 ? null : /* @__PURE__ */ r(gr, { label: "Coordinates", open: o, onToggle: d, children: /* @__PURE__ */ r("div", { className: "space-y-0.5", children: n.map((i, m) => /* @__PURE__ */ r("p", { className: "text-xs font-elm-mono text-elm-text-muted", children: i }, m)) }) });
808
+ }
809
+ function Eo({
810
+ dialogState: t,
811
+ editFeature: e,
812
+ values: n,
813
+ schemaId: s
814
+ }) {
815
+ const o = ue(() => {
816
+ if (t.type === "new-point") {
817
+ const x = {};
818
+ for (const [w, M] of Object.entries(n))
819
+ M !== "" && (x[w] = M);
820
+ return { type: "Feature", id: "(new)", schemaId: s, geometry: { type: "Point", coordinates: t.coords }, properties: x };
821
+ }
822
+ return e ?? null;
823
+ }, [t, e, n, s]), { open: d, toggle: i } = hr("sourceOpen", !1), [m, c] = q(!1), y = ae();
824
+ if (!o) return null;
825
+ const f = JSON.stringify(o, null, 2);
826
+ function h() {
827
+ Promise.resolve().then(() => navigator.clipboard.writeText(f)).then(() => {
828
+ c(!0), setTimeout(() => c(!1), 1500);
829
+ }, (x) => y(Qn(x)));
830
+ }
831
+ return /* @__PURE__ */ r(gr, { label: "Source", open: d, onToggle: i, action: /* @__PURE__ */ r(
832
+ "button",
833
+ {
834
+ type: "button",
835
+ onClick: (x) => {
836
+ x.stopPropagation(), h();
837
+ },
838
+ "aria-label": "Copy source",
839
+ className: `flex items-center justify-center w-6 h-6 rounded-elm-chip hover:bg-elm-surface-hover transition-colors ${m ? "text-emerald-500" : "text-elm-text-disabled hover:text-(--elm-text-secondary,var(--color-gray-500)) dark:hover:text-(--elm-text-secondary,var(--color-gray-300))"}`,
840
+ children: m ? /* @__PURE__ */ r(gn, { size: 16, weight: "bold" }) : /* @__PURE__ */ r(yn, { size: 16 })
841
+ }
842
+ ), children: /* @__PURE__ */ r(
843
+ ko,
844
+ {
845
+ json: f,
846
+ className: "text-[11px] font-elm-mono text-(--elm-text-secondary,var(--color-gray-800)) dark:text-(--elm-text-secondary,var(--color-gray-300)) bg-elm-surface-sunken border border-(--elm-border-subtle,var(--color-gray-100)) dark:border-(--elm-border-subtle,var(--color-gray-700)) rounded-elm-card p-2 overflow-x-auto whitespace-pre leading-relaxed"
847
+ }
848
+ ) });
849
+ }
850
+ function gr({
851
+ label: t,
852
+ open: e,
853
+ onToggle: n,
854
+ action: s,
855
+ children: o
856
+ }) {
857
+ return /* @__PURE__ */ T("div", { children: [
858
+ /* @__PURE__ */ r("div", { className: "-mx-4 border-t border-elm-border" }),
859
+ /* @__PURE__ */ T("div", { className: "flex items-center h-12", children: [
860
+ /* @__PURE__ */ T(
861
+ "button",
862
+ {
863
+ type: "button",
864
+ className: "flex items-center gap-1 text-xs font-medium text-elm-text-subtle hover:text-(--elm-text-secondary,var(--color-gray-600)) dark:hover:text-(--elm-text-secondary,var(--color-gray-300)) hover:bg-elm-surface-hover rounded-elm-control -ml-2 pl-2 transition-colors flex-1 text-left h-full",
865
+ onClick: n,
866
+ children: [
867
+ /* @__PURE__ */ r("span", { className: "text-elm-text-subtle flex-shrink-0", children: e ? /* @__PURE__ */ r(pn, { size: 12, weight: "bold" }) : /* @__PURE__ */ r(hn, { size: 12, weight: "bold" }) }),
868
+ t
869
+ ]
870
+ }
871
+ ),
872
+ s
873
+ ] }),
874
+ e && /* @__PURE__ */ r("div", { className: "pb-3", children: o })
875
+ ] });
876
+ }
877
+ const yr = "[data-elm-theme],[data-elm-theme] *{transition:none!important}";
878
+ function $t(t) {
879
+ const e = document.createElement("style");
880
+ e.textContent = yr, document.head.appendChild(e), t(), requestAnimationFrame(() => requestAnimationFrame(() => e.remove()));
881
+ }
882
+ function Po(t, e) {
883
+ e == null || e.setAttribute("data-dragging", "");
884
+ const n = document.createElement("div");
885
+ n.style.cssText = `position:fixed;inset:0;z-index:2147483647;cursor:${t}`, document.body.appendChild(n);
886
+ const s = document.createElement("style");
887
+ return s.textContent = yr, document.head.appendChild(s), document.body.style.userSelect = "none", () => {
888
+ e == null || e.removeAttribute("data-dragging"), n.remove(), s.remove(), document.body.style.userSelect = "";
889
+ };
890
+ }
891
+ function br(t, e, n, s) {
892
+ const o = ce(), [d, i] = q(() => {
893
+ const y = parseInt(Ht(t, o) ?? "", 10);
894
+ return isNaN(y) ? e : Math.max(n, Math.min(s, y));
895
+ }), m = B(d);
896
+ m.current = d;
897
+ const c = J((y) => {
898
+ if (y.button !== 0) return;
899
+ y.preventDefault();
900
+ const f = y.clientX, h = m.current, u = Po("col-resize", y.currentTarget);
901
+ function x(M) {
902
+ const C = Math.max(n, Math.min(s, h + (f - M.clientX)));
903
+ m.current = C, i(C);
904
+ }
905
+ function w() {
906
+ u(), an(t, String(m.current), o), window.removeEventListener("mousemove", x), window.removeEventListener("mouseup", w);
907
+ }
908
+ window.addEventListener("mousemove", x), window.addEventListener("mouseup", w);
909
+ }, [t, n, s, o]);
910
+ return { width: d, onHandleMouseDown: c };
911
+ }
912
+ function vr(t, e = !0) {
913
+ const { uiStore: n } = oe(), s = ce().ui.layerList, o = S(nt), d = S((f) => f.narrow), i = S((f) => f.sidebarWidth), m = S((f) => f.codeDockWidth), y = S((f) => f.tableFullscreen) || d ? 0 : (s && o ? i : 0) + m;
914
+ pe(() => {
915
+ var h;
916
+ if (!e) return;
917
+ const f = (h = t.current) == null ? void 0 : h.closest("[data-elm-theme]");
918
+ if (f)
919
+ return f.style.setProperty("--elm-panel-offset", `${y}px`), () => {
920
+ f.style.removeProperty("--elm-panel-offset");
921
+ };
922
+ }, [t, e, y]), pe(() => {
923
+ var x;
924
+ if (!e) return;
925
+ const f = (x = t.current) == null ? void 0 : x.closest("[data-elm-theme]");
926
+ if (!f) return;
927
+ const h = () => {
928
+ const w = f.clientWidth;
929
+ w > 0 && n.getState().narrow !== w < Dt && n.getState().setNarrow(w < Dt);
930
+ };
931
+ h();
932
+ const u = new ResizeObserver(h);
933
+ return u.observe(f), () => u.disconnect();
934
+ }, [t, e, n]);
935
+ }
936
+ const xr = "after:absolute after:transition-colors hover:after:bg-elm-focus-ring data-[dragging]:after:bg-elm-focus-ring", Do = `absolute left-0 top-0 h-full w-1 z-20 cursor-col-resize after:inset-y-0 after:left-0 after:w-0.5 ${xr}`, _s = `absolute top-0 left-0 right-0 h-1 z-10 cursor-row-resize after:inset-x-0 after:top-0 after:h-0.5 ${xr}`, Io = "p-1 rounded-elm-control flex items-center justify-center text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-elm-focus-ring active:scale-[0.95] disabled:cursor-not-allowed disabled:active:scale-100", Mo = "text-elm-text hover:bg-elm-control-hover disabled:hover:bg-transparent", To = "flex items-center justify-center w-6 h-6 rounded-elm-control transition-colors bg-transparent hover:bg-(--elm-control-hover,color-mix(in_oklab,var(--color-gray-200)_70%,transparent)) dark:hover:bg-(--elm-control-hover,var(--color-gray-800)) focus:outline-none focus-visible:ring-2 focus-visible:ring-elm-focus-ring disabled:cursor-not-allowed", Ao = "flex items-center justify-center w-12 h-12 backdrop-blur-md border border-elm-border/80 shadow-elm-control rounded-elm transition-colors active:scale-[0.95] focus:outline-none focus-visible:ring-2 focus-visible:ring-elm-focus-ring disabled:cursor-not-allowed disabled:active:scale-100", Fo = "bg-elm-surface/95 hover:bg-elm-surface-hover disabled:hover:bg-elm-surface/95", Kt = "disabled:text-elm-text-disabled", Ot = "text-primary-600 dark:text-primary-400", zo = "text-elm-text";
937
+ function Pe({
938
+ label: t,
939
+ tooltipContent: e,
940
+ shortcut: n,
941
+ shortcutId: s,
942
+ tooltipSide: o = "top",
943
+ onClick: d,
944
+ active: i,
945
+ expanded: m,
946
+ controls: c,
947
+ disabled: y,
948
+ size: f = "md",
949
+ children: h
950
+ }) {
951
+ const x = ce().ui.keyboardShortcuts.enabled ? n : void 0;
952
+ return /* @__PURE__ */ r(be, { content: e ?? t, shortcut: x, side: o, children: /* @__PURE__ */ r(
953
+ "button",
954
+ {
955
+ "aria-label": t,
956
+ "data-elm-shortcut": s,
957
+ "aria-pressed": m === void 0 ? i : void 0,
958
+ "aria-expanded": m,
959
+ "aria-controls": c,
960
+ onClick: (w) => {
961
+ d(), w.detail > 0 && w.currentTarget.blur();
962
+ },
963
+ disabled: y,
964
+ className: f === "group" ? `${Io} ${i ? Ot : Mo} ${Kt}` : `${f === "sm" ? To : `${Ao} ${Fo}`} ${i ? Ot : zo} ${Kt}`,
965
+ children: Rr(h) && typeof h.type != "string" ? $r(h, { ...i ? { weight: "fill" } : {}, ...f === "sm" ? { size: 16 } : {} }) : h
966
+ }
967
+ ) });
968
+ }
969
+ const Gs = Gt(function({ footer: e }) {
970
+ const { dataStore: n } = oe(), s = ae(), o = S((L) => L.sidebarOpen), d = S((L) => L.setSidebarOpen), i = S((L) => L.setSidebarWidth), m = S((L) => L.codeDockWidth), c = S((L) => L.readonly), y = S((L) => L.layout), { width: f, onHandleMouseDown: h } = br("elm_panel_width", 288, 200, 520), u = y === "split", x = B(null);
971
+ vr(x);
972
+ const w = S((L) => L.narrow) && !u, [M, C] = q(!1), l = B(!1);
973
+ $(() => {
974
+ const L = requestAnimationFrame(() => {
975
+ l.current = !0;
976
+ });
977
+ return () => cancelAnimationFrame(L);
978
+ }, []), pe(() => {
979
+ w && (l.current || C(!0), d(!1));
980
+ }, [w, d]), $(() => {
981
+ if (!M) return;
982
+ const L = requestAnimationFrame(() => C(!1));
983
+ return () => cancelAnimationFrame(L);
984
+ }, [M]);
985
+ const { getKey: p } = Ee(), a = /* @__PURE__ */ r(Q, { children: p("toggle-sidebar").toUpperCase() }), [E, g] = q(null), N = J((L) => g(L), []);
986
+ pe(() => {
987
+ i(f);
988
+ }, [f, i]);
989
+ const P = S((L) => L.dialogState), z = P.type !== "closed", K = U((L) => L.features), b = U((L) => L.selectedIds), k = U((L) => L.deleteSelection), D = U((L) => L.clearSelection), R = S((L) => L.autoFocusGroupId), O = S((L) => L.setAutoFocusGroupId);
990
+ $(() => {
991
+ R && O(null);
992
+ }, [R, O]);
993
+ function j() {
994
+ const L = crypto.randomUUID();
995
+ n.setState((v) => ({
996
+ groups: [...v.groups, { id: L, name: "New group", collapsed: !1 }],
997
+ lastModifiedAt: Date.now()
998
+ })), O(L);
999
+ }
1000
+ const Z = P.type === "edit" ? `edit-${P.featureId}` : P.type;
1001
+ return /* @__PURE__ */ r(le, { children: /* @__PURE__ */ T(
1002
+ "aside",
1003
+ {
1004
+ ref: x,
1005
+ "data-elm-layers-panel": "",
1006
+ className: u ? "h-full w-full" : w ? `absolute top-0 h-full z-[600] ${o ? "shadow-elm-raised" : ""}` : "absolute top-0 h-full z-10",
1007
+ style: u ? void 0 : w ? { width: `min(${f}px, 100% - 48px)`, right: o ? 0 : `calc(-1 * min(${f}px, 100% - 48px))`, transition: M ? "none" : "right 200ms ease" } : { width: f, right: o ? 0 : -f, transition: M ? "none" : "right 200ms ease" },
1008
+ children: [
1009
+ !u && !o && /* @__PURE__ */ r("div", { className: "absolute z-30", style: { left: -64 - m, top: 16 }, children: /* @__PURE__ */ r(Pe, { label: "Open layers panel", shortcutId: "toggle-sidebar", tooltipContent: "Show layers", shortcut: a, tooltipSide: "bottom", onClick: () => d(!0), children: /* @__PURE__ */ r(Jt, { size: 24 }) }) }),
1010
+ /* @__PURE__ */ T("div", { inert: !u && !o, className: `h-full flex flex-col overflow-hidden bg-elm-surface ${u ? "" : "border-l border-elm-border/80"}`, children: [
1011
+ !u && /* @__PURE__ */ r(
1012
+ "div",
1013
+ {
1014
+ onMouseDown: h,
1015
+ className: Do,
1016
+ title: "Drag to resize panel"
1017
+ }
1018
+ ),
1019
+ z && b.length < 2 ? /* @__PURE__ */ r(Co, { dialogState: P, collapsible: !0 }, Z) : /* @__PURE__ */ T(le, { children: [
1020
+ /* @__PURE__ */ r("header", { className: `${po} px-3`, children: /* @__PURE__ */ T("div", { className: "flex items-center justify-between h-6 w-full", children: [
1021
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-1.5", children: [
1022
+ /* @__PURE__ */ r(pr, {}),
1023
+ /* @__PURE__ */ r("span", { className: "text-xs font-medium text-elm-text-secondary", children: "Layers" })
1024
+ ] }),
1025
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-0.5", children: !c && /* @__PURE__ */ r(be, { content: "New group", side: "bottom", children: /* @__PURE__ */ r("button", { type: "button", onClick: j, disabled: K.length === 0, className: `flex ${Me}`, "aria-label": "New group", children: /* @__PURE__ */ r(bn, { size: 16 }) }) }) })
1026
+ ] }) }),
1027
+ /* @__PURE__ */ r("div", { ref: N, className: "flex-1 overflow-y-auto min-h-0", children: /* @__PURE__ */ r("div", { className: "px-3 py-3 flex flex-col gap-3 h-full", children: /* @__PURE__ */ r(Ut, { fallback: K.length === 0 ? /* @__PURE__ */ r("div", { className: "h-full", children: /* @__PURE__ */ r(Zn, {}) }) : null, children: /* @__PURE__ */ r(mr, { autoFocusGroupId: R, scrollElement: E }) }) }) }),
1028
+ b.length >= 2 && /* @__PURE__ */ T("div", { className: "flex items-center gap-2 px-3 py-2 bg-elm-surface-sunken border-t border-elm-border flex-shrink-0", children: [
1029
+ /* @__PURE__ */ T("span", { className: "text-xs text-elm-text-secondary font-medium flex-1", children: [
1030
+ b.length,
1031
+ " selected"
1032
+ ] }),
1033
+ /* @__PURE__ */ r(
1034
+ "button",
1035
+ {
1036
+ onClick: D,
1037
+ className: "text-xs text-elm-text-secondary px-2 py-1 rounded-elm-control hover:bg-(--elm-surface-hover,var(--color-gray-200)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) transition-colors",
1038
+ children: "Clear"
1039
+ }
1040
+ ),
1041
+ !c && /* @__PURE__ */ r(
1042
+ "button",
1043
+ {
1044
+ onClick: () => {
1045
+ const L = b.length;
1046
+ k(), s({ type: "features:deleted", count: L, undo: () => n.getState().undo() });
1047
+ },
1048
+ className: "text-xs text-elm-text-secondary px-2 py-1 rounded-elm-control hover:bg-(--elm-surface-hover,var(--color-gray-200)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) transition-colors",
1049
+ children: "Delete all"
1050
+ }
1051
+ )
1052
+ ] })
1053
+ ] }),
1054
+ e && /* @__PURE__ */ r("div", { className: "flex-shrink-0 border-t border-elm-border", children: e })
1055
+ ] })
1056
+ ]
1057
+ }
1058
+ ) });
1059
+ });
1060
+ function wr({ type: t, size: e = 20 }) {
1061
+ return t === "Point" || t === "MultiPoint" ? /* @__PURE__ */ r(Zt, { size: e }) : t === "Polygon" || t === "MultiPolygon" ? /* @__PURE__ */ r(Yt, { size: e, weight: "fill" }) : t === "GeometryCollection" ? /* @__PURE__ */ r(Ye, { size: e }) : /* @__PURE__ */ r(Qt, { size: e, weight: "bold" });
1062
+ }
1063
+ function Lo(t) {
1064
+ switch (t) {
1065
+ case "Point":
1066
+ return "Point";
1067
+ case "MultiPoint":
1068
+ return "Points";
1069
+ case "LineString":
1070
+ return "Line";
1071
+ case "MultiLineString":
1072
+ return "Lines";
1073
+ case "Polygon":
1074
+ return "Area";
1075
+ case "MultiPolygon":
1076
+ return "Areas";
1077
+ case "GeometryCollection":
1078
+ return "Mixed";
1079
+ default:
1080
+ return t;
1081
+ }
1082
+ }
1083
+ function kr({ initialLabel: t, onCommit: e, autoFocus: n, activate: s, onEnd: o, onTab: d, disabled: i }) {
1084
+ const [m, c] = q(() => !i && (!!n || !!s)), [y, f] = q(t), h = B(null);
1085
+ $(() => {
1086
+ s && !m && !i && (f(t), c(!0));
1087
+ }, [s]), $(() => {
1088
+ var l, p;
1089
+ m && ((l = h.current) == null || l.focus(), (p = h.current) == null || p.select());
1090
+ }, [m]);
1091
+ function u(l) {
1092
+ i || (f(l), c(!0));
1093
+ }
1094
+ function x() {
1095
+ const l = y.trim();
1096
+ l && l !== t && e(l), c(!1), o == null || o();
1097
+ }
1098
+ function w() {
1099
+ f(t), c(!1), o == null || o();
1100
+ }
1101
+ function M(l) {
1102
+ if (l.key === "Enter") {
1103
+ l.preventDefault(), l.nativeEvent.stopImmediatePropagation(), x();
1104
+ return;
1105
+ }
1106
+ if (l.key === "Escape") {
1107
+ l.nativeEvent.stopImmediatePropagation(), w();
1108
+ return;
1109
+ }
1110
+ if (l.key === "Tab" && d) {
1111
+ l.preventDefault(), l.nativeEvent.stopImmediatePropagation();
1112
+ const p = y.trim();
1113
+ p && p !== t && e(p), c(!1), d(l.shiftKey ? "prev" : "next");
1114
+ }
1115
+ }
1116
+ return { isRenaming: m, startRenaming: u, inputProps: {
1117
+ ref: h,
1118
+ value: y,
1119
+ onChange: (l) => f(l.target.value),
1120
+ onBlur: x,
1121
+ onKeyDown: M,
1122
+ onClick: (l) => l.stopPropagation()
1123
+ } };
1124
+ }
1125
+ function Ro(t) {
1126
+ const e = t.properties.name;
1127
+ return typeof e == "string" && e.trim() ? e : Lo(t.geometry.type);
1128
+ }
1129
+ const Us = Gt(function({
1130
+ feature: e,
1131
+ isSelected: n,
1132
+ onRowClick: s,
1133
+ onRowSelectOnly: o,
1134
+ onRowJump: d,
1135
+ onEdit: i,
1136
+ onToggleHidden: m,
1137
+ containerProps: c,
1138
+ dragHandleProps: y,
1139
+ isDragging: f,
1140
+ innerRef: h,
1141
+ isMultiSelected: u,
1142
+ onMultiSelectToggle: x,
1143
+ onRangeSelect: w,
1144
+ isContextMenuActive: M,
1145
+ dragCountBadge: C,
1146
+ isGhosted: l,
1147
+ onRename: p,
1148
+ renameActive: a,
1149
+ onRenameEnd: E,
1150
+ onRenameTab: g,
1151
+ joinTop: N,
1152
+ joinBottom: P
1153
+ }) {
1154
+ const z = B(null), K = Ro(e), b = S((F) => F.readonly), { isRenaming: k, startRenaming: D, inputProps: R } = kr({
1155
+ initialLabel: K,
1156
+ disabled: b,
1157
+ onCommit: (F) => p == null ? void 0 : p(e.id, F),
1158
+ activate: a,
1159
+ onEnd: E,
1160
+ onTab: g
1161
+ }), O = B(null);
1162
+ $(() => () => {
1163
+ O.current !== null && clearTimeout(O.current);
1164
+ }, []);
1165
+ const j = typeof e.properties.imageUrl == "string" && e.properties.imageUrl ? e.properties.imageUrl : null, [Z, L] = q(!1);
1166
+ $(() => {
1167
+ if (L(!1), !j) return;
1168
+ const F = new Image();
1169
+ let I = !1;
1170
+ return F.onload = () => {
1171
+ I || L(!0);
1172
+ }, F.onerror = () => {
1173
+ }, F.src = j, () => {
1174
+ I = !0, F.onload = null, F.onerror = null;
1175
+ };
1176
+ }, [j]);
1177
+ const v = j !== null && Z, { style: W, ...H } = c ?? {};
1178
+ return /* @__PURE__ */ r(
1179
+ "li",
1180
+ {
1181
+ ref: (F) => {
1182
+ z.current = F, h == null || h(F);
1183
+ },
1184
+ ...H,
1185
+ ...y,
1186
+ style: { listStyle: "none", opacity: l ? 0.4 : void 0, outline: "none", ...W },
1187
+ children: /* @__PURE__ */ T(
1188
+ "div",
1189
+ {
1190
+ "data-feature-id": e.id,
1191
+ className: ne(
1192
+ // Fixed h-9 (36 px): FeatureList's virtualiser computes row offsets from it.
1193
+ "group flex items-center gap-2 px-2 h-9 rounded-elm-control text-sm cursor-default",
1194
+ !f && N && "rounded-t-none",
1195
+ !f && P && "rounded-b-none",
1196
+ f ? "cursor-grabbing shadow-elm-control bg-elm-surface-raised" : u || n ? "bg-(--elm-row-selected) hover:bg-(--elm-row-selected-hover) text-primary-700 dark:text-primary-300" : e.hidden ? ne("text-elm-text-disabled", M ? "bg-(--elm-row-hover)" : "hover:bg-(--elm-row-hover)") : M ? "bg-(--elm-row-hover) text-elm-text-secondary" : "hover:bg-(--elm-row-hover) text-elm-text-secondary"
1197
+ ),
1198
+ onClick: (F) => {
1199
+ if (F.metaKey || F.ctrlKey) {
1200
+ F.stopPropagation(), x == null || x(e.id);
1201
+ return;
1202
+ }
1203
+ if (F.shiftKey) {
1204
+ F.stopPropagation(), w == null || w(e.id);
1205
+ return;
1206
+ }
1207
+ s(e.id);
1208
+ },
1209
+ children: [
1210
+ v ? /* @__PURE__ */ r(
1211
+ "img",
1212
+ {
1213
+ src: j,
1214
+ alt: "",
1215
+ className: "w-5 h-5 rounded-elm-chip object-cover flex-shrink-0 border border-(--elm-border,var(--color-gray-200))"
1216
+ }
1217
+ ) : /* @__PURE__ */ r("span", { className: ne(
1218
+ "flex-shrink-0",
1219
+ // Selected rows tint the icon to match their text color (primary).
1220
+ // Hidden rows mute it to the row's dimmed text. Otherwise stay neutral gray.
1221
+ n || u ? "text-primary-700 dark:text-primary-300" : e.hidden ? "text-elm-text-disabled" : "text-(--elm-text-subtle,var(--color-gray-400))"
1222
+ ), children: /* @__PURE__ */ r(wr, { type: e.geometry.type }) }),
1223
+ k ? /* @__PURE__ */ r(
1224
+ "input",
1225
+ {
1226
+ ...R,
1227
+ className: "flex-1 min-w-0 bg-elm-surface outline-none text-sm font-normal text-elm-text-secondary border border-primary-400 rounded-elm-control px-1.5 py-0.5 leading-snug"
1228
+ }
1229
+ ) : /* @__PURE__ */ r(
1230
+ "span",
1231
+ {
1232
+ className: "flex-1 min-w-0 font-normal truncate leading-snug border border-transparent rounded-elm-control px-1.5 py-0.5",
1233
+ onClick: (F) => {
1234
+ F.metaKey || F.ctrlKey || F.shiftKey || !o || !d || (F.stopPropagation(), o(e.id), O.current !== null && (clearTimeout(O.current), O.current = null), !(F.detail >= 2) && (O.current = window.setTimeout(() => {
1235
+ d(e.id), O.current = null;
1236
+ }, 300)));
1237
+ },
1238
+ onDoubleClick: (F) => {
1239
+ F.stopPropagation(), O.current !== null && (clearTimeout(O.current), O.current = null), D(K);
1240
+ },
1241
+ children: K
1242
+ }
1243
+ ),
1244
+ !k && C && C > 1 && /* @__PURE__ */ r("span", { className: "flex-shrink-0 bg-primary-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full min-w-[1.25rem] text-center leading-none", children: C }),
1245
+ !k && /* @__PURE__ */ T("div", { className: "flex items-center gap-0.5 flex-shrink-0", children: [
1246
+ /* @__PURE__ */ r(
1247
+ "button",
1248
+ {
1249
+ onClick: (F) => {
1250
+ F.stopPropagation(), i(e.id);
1251
+ },
1252
+ className: "text-elm-text hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) p-1 rounded-elm-control opacity-0 group-hover:opacity-100",
1253
+ "aria-label": "Edit",
1254
+ children: /* @__PURE__ */ r(vn, { size: 16 })
1255
+ }
1256
+ ),
1257
+ /* @__PURE__ */ r(
1258
+ "button",
1259
+ {
1260
+ onClick: (F) => {
1261
+ F.stopPropagation(), m(e.id);
1262
+ },
1263
+ className: ne(
1264
+ "text-elm-text hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) p-1 rounded-elm-control",
1265
+ e.hidden ? "" : "opacity-0 group-hover:opacity-100"
1266
+ ),
1267
+ "aria-label": "Toggle visibility",
1268
+ children: e.hidden ? /* @__PURE__ */ r(Qe, { size: 16 }) : /* @__PURE__ */ r(st, { size: 16 })
1269
+ }
1270
+ )
1271
+ ] })
1272
+ ]
1273
+ }
1274
+ )
1275
+ }
1276
+ );
1277
+ });
1278
+ function js({ group: t, featureCount: e, autoFocus: n, isSelected: s, onToggleCollapse: o, onToggleHidden: d, onRename: i, onDelete: m, onSelect: c, innerRef: y, dragHandleProps: f, containerProps: h, isDragging: u }) {
1279
+ const x = S((z) => z.readonly), { isRenaming: w, startRenaming: M, inputProps: C } = kr({
1280
+ initialLabel: t.name,
1281
+ disabled: x,
1282
+ onCommit: i,
1283
+ autoFocus: n
1284
+ }), [l, p] = q(null), a = B(null);
1285
+ function E(z) {
1286
+ z.stopPropagation();
1287
+ const K = a.current;
1288
+ if (K) {
1289
+ const b = K.getBoundingClientRect();
1290
+ p({ x: b.right, y: b.bottom + 4 });
1291
+ }
1292
+ }
1293
+ const g = B(null);
1294
+ $(() => () => {
1295
+ g.current !== null && clearTimeout(g.current);
1296
+ }, []);
1297
+ const N = {
1298
+ label: t.hidden ? "Show on map" : "Hide from map",
1299
+ icon: t.hidden ? /* @__PURE__ */ r(st, { size: 16 }) : /* @__PURE__ */ r(Qe, { size: 16 }),
1300
+ onClick: () => d()
1301
+ }, P = x ? [N] : [
1302
+ N,
1303
+ {
1304
+ label: "Rename",
1305
+ icon: /* @__PURE__ */ r(Sn, { size: 16 }),
1306
+ onClick: () => M(t.name)
1307
+ },
1308
+ { separator: !0 },
1309
+ {
1310
+ // Removes the group but keeps its features at the top level.
1311
+ label: "Ungroup",
1312
+ icon: /* @__PURE__ */ r(Cn, { size: 16 }),
1313
+ onClick: () => m("ungroup")
1314
+ },
1315
+ {
1316
+ label: "Delete group",
1317
+ icon: /* @__PURE__ */ r(ze, { size: 16 }),
1318
+ onClick: () => m("delete-features")
1319
+ }
1320
+ ];
1321
+ return /* @__PURE__ */ T(le, { children: [
1322
+ l && /* @__PURE__ */ r(
1323
+ ar,
1324
+ {
1325
+ x: l.x,
1326
+ y: l.y,
1327
+ onClose: () => p(null),
1328
+ items: P
1329
+ }
1330
+ ),
1331
+ /* @__PURE__ */ T(
1332
+ "div",
1333
+ {
1334
+ ref: y,
1335
+ ...h,
1336
+ ...f,
1337
+ className: ne(
1338
+ "group flex items-center gap-2 px-2 py-1.5 rounded-elm-control text-sm font-medium cursor-default",
1339
+ u ? "shadow-elm-control bg-elm-surface-raised" : s ? "bg-(--elm-row-selected) hover:bg-(--elm-row-selected-hover) text-primary-700 dark:text-primary-300" : t.hidden ? "text-elm-text-disabled hover:bg-(--elm-row-hover)" : "text-elm-text-secondary hover:bg-(--elm-row-hover)"
1340
+ ),
1341
+ style: { outline: "none", cursor: u ? "grabbing" : "default", ...h == null ? void 0 : h.style },
1342
+ onClick: () => {
1343
+ c && c();
1344
+ },
1345
+ onContextMenu: (z) => {
1346
+ z.preventDefault(), p({ x: z.clientX, y: z.clientY });
1347
+ },
1348
+ children: [
1349
+ /* @__PURE__ */ r(
1350
+ "span",
1351
+ {
1352
+ className: ne(
1353
+ "flex-shrink-0 cursor-pointer",
1354
+ t.hidden ? "text-elm-text-disabled" : "text-elm-text-muted"
1355
+ ),
1356
+ onClick: (z) => {
1357
+ z.stopPropagation(), o();
1358
+ },
1359
+ "aria-label": t.collapsed ? "Expand group" : "Collapse group",
1360
+ children: t.collapsed ? /* @__PURE__ */ r(xn, { size: 20, weight: "fill" }) : /* @__PURE__ */ r(wn, { size: 20, weight: "fill" })
1361
+ }
1362
+ ),
1363
+ w ? /* @__PURE__ */ r(
1364
+ "input",
1365
+ {
1366
+ ...C,
1367
+ className: "flex-1 min-w-0 bg-elm-surface outline-none text-sm font-medium text-elm-text-secondary border border-primary-400 rounded-elm-control px-1.5 py-0.5 leading-snug"
1368
+ }
1369
+ ) : /* @__PURE__ */ r(
1370
+ "span",
1371
+ {
1372
+ className: "flex-1 min-w-0 truncate cursor-default leading-snug border border-transparent rounded-elm-control px-1.5 py-0.5",
1373
+ onClick: (z) => {
1374
+ z.stopPropagation(), !(!c || z.metaKey || z.ctrlKey || z.shiftKey) && (g.current !== null && (clearTimeout(g.current), g.current = null), !(z.detail >= 2) && (g.current = window.setTimeout(() => {
1375
+ c(), g.current = null;
1376
+ }, 300)));
1377
+ },
1378
+ onDoubleClick: (z) => {
1379
+ z.stopPropagation(), g.current !== null && (clearTimeout(g.current), g.current = null), M(t.name);
1380
+ },
1381
+ children: t.name
1382
+ }
1383
+ ),
1384
+ !w && /* @__PURE__ */ T("div", { className: "ml-auto flex items-center gap-1 flex-shrink-0", children: [
1385
+ t.hidden && /* @__PURE__ */ r(
1386
+ "button",
1387
+ {
1388
+ onClick: (z) => {
1389
+ z.stopPropagation(), d();
1390
+ },
1391
+ className: "text-elm-text p-1 rounded-elm-control hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700))",
1392
+ "aria-label": "Show on map",
1393
+ children: /* @__PURE__ */ r(Qe, { size: 16 })
1394
+ }
1395
+ ),
1396
+ /* @__PURE__ */ r("div", { className: "opacity-0 group-hover:opacity-100", children: /* @__PURE__ */ r(be, { content: "More options", children: /* @__PURE__ */ r(
1397
+ "button",
1398
+ {
1399
+ ref: a,
1400
+ onClick: E,
1401
+ className: "text-elm-text p-1 rounded-elm-control hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700))",
1402
+ "aria-label": "More options",
1403
+ children: /* @__PURE__ */ r(kn, { size: 16, weight: "bold" })
1404
+ }
1405
+ ) }) }),
1406
+ /* @__PURE__ */ r("span", { className: ne(
1407
+ "font-normal w-7 text-right text-sm",
1408
+ t.hidden ? "text-elm-text-disabled" : "text-elm-text-subtle"
1409
+ ), children: e })
1410
+ ] })
1411
+ ]
1412
+ }
1413
+ )
1414
+ ] });
1415
+ }
1416
+ function qs({ geometry: t, partIndex: e, isSelected: n, onClick: s }) {
1417
+ const o = Qr(t, e), d = en(t, e);
1418
+ return (
1419
+ // ml-5 nests the sub-row under its parent feature visually.
1420
+ /* @__PURE__ */ r("li", { style: { listStyle: "none" }, className: "ml-5", children: /* @__PURE__ */ T(
1421
+ "div",
1422
+ {
1423
+ className: ne(
1424
+ // Fixed h-9, like FeatureRow: FeatureList computes the expanded row's height.
1425
+ "flex items-center gap-2 px-2 h-9 rounded-elm-control text-sm cursor-default",
1426
+ n ? "bg-(--elm-row-selected) hover:bg-(--elm-row-selected-hover) text-primary-700 dark:text-primary-300" : "text-elm-text-muted hover:bg-(--elm-row-hover)"
1427
+ ),
1428
+ onClick: (i) => {
1429
+ i.stopPropagation(), s();
1430
+ },
1431
+ children: [
1432
+ /* @__PURE__ */ r("span", { className: ne(
1433
+ "flex-shrink-0",
1434
+ n ? "text-primary-700 dark:text-primary-300" : "text-(--elm-text-subtle,var(--color-gray-400))"
1435
+ ), children: /* @__PURE__ */ r(wr, { type: o.type }) }),
1436
+ /* @__PURE__ */ r("span", { className: "flex-1 min-w-0 font-normal truncate leading-snug border border-transparent rounded-elm-control px-1.5 py-0.5", children: d })
1437
+ ]
1438
+ }
1439
+ ) })
1440
+ );
1441
+ }
1442
+ const $o = "elm_code_docked";
1443
+ function Ko() {
1444
+ const t = ce(), [e] = q(() => Ht($o, t) !== "0");
1445
+ return e;
1446
+ }
1447
+ function Oo(t) {
1448
+ const e = ce(), n = S((f) => f.layout), s = S(nt), o = S((f) => f.sidebarWidth), d = S((f) => f.tableFullscreen), i = S((f) => f.setCodeDockWidth), m = S((f) => f.narrow), c = br("elm_code_dock_width", 420, 280, 900);
1449
+ pe(() => {
1450
+ if (t)
1451
+ return $t(() => i(m ? 0 : c.width)), () => $t(() => i(0));
1452
+ }, [t, m, c.width, i]);
1453
+ const y = e.ui.layerList && s;
1454
+ return {
1455
+ ...c,
1456
+ className: `absolute top-0 ${m ? "z-[600] shadow-elm-raised" : "z-10"} flex flex-col bg-elm-surface border-l border-elm-border/80 overflow-hidden ${d ? "hidden" : ""}`,
1457
+ // Left of the layers panel, above split layout's bottom panel. Same
1458
+ // `right` transition as the panel and the data table: one mechanism
1459
+ // (layout) keeps them in lockstep; mixing it with a compositor
1460
+ // transform drifted and opened gaps.
1461
+ style: {
1462
+ right: y ? o : 0,
1463
+ bottom: n === "split" ? "33.33%" : 0,
1464
+ width: m ? `min(${c.width}px, 100%)` : c.width,
1465
+ transition: "right 200ms ease"
1466
+ }
1467
+ };
1468
+ }
1469
+ function Hs() {
1470
+ const t = Ko(), e = Oo(t), n = B(null);
1471
+ return vr(n, t), t ? /* @__PURE__ */ r("div", { ref: n, "aria-hidden": "true", className: e.className, style: e.style }) : null;
1472
+ }
1473
+ function Bo() {
1474
+ const [t, e] = q(""), [n, s] = q(!1), [o, d] = q(!1), [i, m] = q(-1), c = B(null), y = B(null), { results: f, loading: h, error: u, flush: x } = Br(t), w = B(!1), { flyTo: M, fitBounds: C } = Ae(), { dataStore: l } = oe(), p = ke();
1475
+ $(() => {
1476
+ s(t.trim().length >= 2), m(-1);
1477
+ }, [t, f]), $(() => {
1478
+ w.current = !1;
1479
+ }, [t]), $(() => {
1480
+ !w.current || h || (w.current = !1, f.length && P(0));
1481
+ }, [f, h]), $(() => {
1482
+ function b(k) {
1483
+ c.current && !c.current.contains(k.target) && s(!1);
1484
+ }
1485
+ return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
1486
+ }, []), $(() => {
1487
+ function b(k) {
1488
+ var D, R;
1489
+ if (p(k)) {
1490
+ if (k.key === "f" && (k.metaKey || k.ctrlKey) && !Sr(k)) {
1491
+ k.preventDefault(), (D = y.current) == null || D.focus();
1492
+ return;
1493
+ }
1494
+ k.key === "Escape" && (n || document.activeElement === y.current) && (k.stopPropagation(), e(""), s(!1), m(-1), (R = y.current) == null || R.blur());
1495
+ }
1496
+ }
1497
+ return window.addEventListener("keydown", b, { capture: !0 }), () => window.removeEventListener("keydown", b, { capture: !0 });
1498
+ }, [n, p]);
1499
+ function a(b) {
1500
+ M == null || M([parseFloat(b.lat), parseFloat(b.lon)], 15);
1501
+ }
1502
+ function E(b) {
1503
+ const k = parseFloat(b.lat), D = parseFloat(b.lon), R = l.getState().getDefaultSchema(), O = {};
1504
+ for (const Z of R.fields)
1505
+ O[Z.key] = Z.key === "name" ? b.display_name.split(",")[0].trim() : "";
1506
+ const j = {
1507
+ type: "Feature",
1508
+ id: crypto.randomUUID(),
1509
+ schemaId: R.id,
1510
+ geometry: { type: "Point", coordinates: [D, k] },
1511
+ properties: O
1512
+ };
1513
+ l.getState().addFeature(j), M == null || M([k, D], 15), N();
1514
+ }
1515
+ function g(b) {
1516
+ const k = b.geojson;
1517
+ if (!k || k.type === "Point") return;
1518
+ let D;
1519
+ k.type === "MultiPolygon" ? D = { type: "Polygon", coordinates: k.coordinates.reduce((Z, L) => L[0].length > Z[0].length ? L : Z) } : D = k;
1520
+ const R = {
1521
+ type: "Feature",
1522
+ id: crypto.randomUUID(),
1523
+ schemaId: tn,
1524
+ geometry: D,
1525
+ properties: { name: b.display_name.split(",")[0].trim() }
1526
+ };
1527
+ l.getState().addFeature(R), C == null || C(ot(D)), N();
1528
+ }
1529
+ function N() {
1530
+ e(""), s(!1), m(-1);
1531
+ }
1532
+ function P(b) {
1533
+ m(b), a(f[b]), requestAnimationFrame(() => {
1534
+ var k;
1535
+ return (k = y.current) == null ? void 0 : k.focus();
1536
+ });
1537
+ }
1538
+ function z(b) {
1539
+ if (b.key === "Enter") {
1540
+ if (t.trim().length < 2) return;
1541
+ if (b.preventDefault(), f.length && !h) {
1542
+ P(i >= 0 ? i : 0);
1543
+ return;
1544
+ }
1545
+ w.current = !0, s(!0), x();
1546
+ return;
1547
+ }
1548
+ f.length && (b.key === "ArrowDown" ? (b.preventDefault(), m((k) => (k + 1) % f.length)) : b.key === "ArrowUp" && (b.preventDefault(), m((k) => k <= 0 ? f.length - 1 : k - 1)));
1549
+ }
1550
+ const K = n && t.trim().length >= 2;
1551
+ return { query: t, setQuery: e, setOpen: s, showDropdown: K, containerRef: c, inputRef: y, focused: o, setFocused: d, results: f, loading: h, error: u, flyToResult: a, handleAdd: E, handleAddShape: g, clear: N, activeIndex: i, setActiveIndex: m, handleInputKeyDown: z };
1552
+ }
1553
+ function Sr(t) {
1554
+ var e, n;
1555
+ return ((n = (e = t.target) == null ? void 0 : e.closest) == null ? void 0 : n.call(e, ".cm-editor")) != null;
1556
+ }
1557
+ const Wo = 208, _o = {
1558
+ "top-left": { style: { top: 16, left: 16 }, className: "flex-col items-start" },
1559
+ "top-center": { style: { top: 16, left: 0, right: 0 }, className: "flex-col items-center" },
1560
+ "top-right": { style: { top: 16, right: 16 }, className: "flex-col items-end" },
1561
+ "left-center": { style: { left: 16, top: "50%", transform: "translateY(-50%)" }, className: "flex-col items-start" },
1562
+ "right-center": { style: { right: 16, top: "50%", transform: "translateY(-50%)" }, className: "flex-col items-end" },
1563
+ "bottom-left": { style: { bottom: 16, left: 16 }, className: "flex-col-reverse items-start" },
1564
+ "bottom-center": { style: { bottom: 16, left: 0, right: 0 }, className: "flex-col-reverse items-center" },
1565
+ "bottom-right": { style: { bottom: 16, right: 16 }, className: "flex-col-reverse items-end" }
1566
+ };
1567
+ function Vs({ embedded: t } = {}) {
1568
+ const e = U((A) => A.features.length), n = U((A) => A.maxFeatures), s = n != null && e >= n, o = ae(), d = ce(), { toolbar: i } = d, m = i.direction === "vertical", c = _o[i.position], y = S(nt), f = S((A) => A.sidebarWidth), h = S((A) => A.codeDockWidth), u = S((A) => A.layout), x = d.ui.layerList && y, w = i.position.startsWith("bottom"), M = i.position === "left-center" || i.position === "right-center", C = u === "split" && w, l = u === "split" && M, p = (() => {
1569
+ let A = c.style;
1570
+ const X = i.position.endsWith("-right") || i.position.startsWith("right");
1571
+ return x ? X && (A = { ...A, right: f + 16 + h }) : d.ui.layerList && u === "panel" && i.position === "top-right" ? A = { ...A, right: 72 + h } : X && h && (A = { ...A, right: 16 + h }), C ? A = { ...A, bottom: "calc(33.33% + 16px)" } : w && (A = { ...A, bottom: "calc(var(--elm-table-offset, 0px) + 16px)" }), l && (A = { ...A, top: "33.33%" }), A === c.style ? c : { ...c, style: A };
1572
+ })(), a = S((A) => A.editingMode), E = S((A) => A.enabledTools), g = S((A) => A.unavailableTools), N = S((A) => A.readonly), P = S((A) => A.setEditingMode);
1573
+ function z(A) {
1574
+ if (s && A !== "none") {
1575
+ o({ type: "error", code: "limit-reached", source: "editor", message: rn(n) });
1576
+ return;
1577
+ }
1578
+ P(A);
1579
+ }
1580
+ const { getKey: K } = Ee(), { query: b, setQuery: k, setOpen: D, showDropdown: R, containerRef: O, inputRef: j, focused: Z, setFocused: L, results: v, loading: W, error: H, flyToResult: F, handleAdd: I, handleAddShape: _, clear: G, activeIndex: V, setActiveIndex: Y, handleInputKeyDown: re } = Bo(), ve = B(null), De = B(null);
1581
+ $(() => {
1582
+ var de;
1583
+ if (t || !w) return;
1584
+ const A = (de = De.current) == null ? void 0 : de.closest("[data-elm-theme]");
1585
+ if (!A) return;
1586
+ const X = () => {
1587
+ var Se;
1588
+ const xe = ((Se = De.current) == null ? void 0 : Se.offsetHeight) ?? 0;
1589
+ A.style.setProperty("--elm-bottom-toolbar-offset", `${xe + 8}px`);
1590
+ };
1591
+ X();
1592
+ const ee = new ResizeObserver(X);
1593
+ return De.current && ee.observe(De.current), () => {
1594
+ ee.disconnect(), A.style.setProperty("--elm-bottom-toolbar-offset", "0px");
1595
+ };
1596
+ }, [t, w]);
1597
+ const [Le, he] = q(!1), ut = B(null), mt = B(null), [Er, ft] = q(!1), pt = B(null);
1598
+ pe(() => {
1599
+ var kt, St;
1600
+ const A = pt.current;
1601
+ if (m || !A) {
1602
+ ft(!1);
1603
+ return;
1604
+ }
1605
+ const X = ((kt = O.current) == null ? void 0 : kt.closest('[data-elm-edge="top"], [data-elm-edge="bottom"]')) ?? null, ee = X ?? ((St = O.current) == null ? void 0 : St.offsetParent);
1606
+ if (!ee) return;
1607
+ const de = (Re) => Re.flatMap((ye) => getComputedStyle(ye).display === "contents" ? de([...ye.children]) : [ye.offsetWidth]), xe = () => {
1608
+ const Re = de([...A.children]).filter((Je) => Je > 0), ye = getComputedStyle(A), Ir = parseFloat(ye.paddingLeft) + parseFloat(ye.paddingRight) + parseFloat(ye.borderLeftWidth) + parseFloat(ye.borderRightWidth);
1609
+ let Ct = Re.reduce((Je, Mr) => Je + Mr, 0) + 8 * Math.max(0, Re.length - 1) + Ir;
1610
+ const Nt = A.querySelector("[data-elm-search-toggle]");
1611
+ Nt && (Ct += Wo - Nt.offsetWidth);
1612
+ const Et = X ? X.clientWidth - (parseFloat(X.dataset.elmClearance ?? "") || 0) : ee.clientWidth - 32;
1613
+ ft(Et > 0 && Ct > Et + 0.5);
1614
+ };
1615
+ xe();
1616
+ const Se = new ResizeObserver(() => xe());
1617
+ return Se.observe(ee), Se.observe(A), () => Se.disconnect();
1618
+ }, [m, O]);
1619
+ const ge = m || Er, ht = B(ge);
1620
+ ht.current = ge, $(() => {
1621
+ ge || he(!1);
1622
+ }, [ge]);
1623
+ const gt = B(null), yt = ke();
1624
+ function bt() {
1625
+ const A = gt.current;
1626
+ A && (A.style.animation = "none", A.offsetWidth, A.style.animation = "press-pulse 200ms ease-out");
1627
+ }
1628
+ $(() => {
1629
+ function A(X) {
1630
+ X.key === "f" && (X.metaKey || X.ctrlKey) && yt(X) && !Sr(X) && (ht.current ? he(!0) : bt());
1631
+ }
1632
+ return window.addEventListener("keydown", A), () => window.removeEventListener("keydown", A);
1633
+ }, [yt]);
1634
+ const Pr = i.position.startsWith("right") || i.position.endsWith("-right") ? "left" : "right";
1635
+ $(() => {
1636
+ if (!Le) return;
1637
+ requestAnimationFrame(() => {
1638
+ var ee;
1639
+ return (ee = j.current) == null ? void 0 : ee.focus();
1640
+ });
1641
+ function A(ee) {
1642
+ var de, xe;
1643
+ !((de = ut.current) != null && de.contains(ee.target)) && !((xe = mt.current) != null && xe.contains(ee.target)) && he(!1);
1644
+ }
1645
+ function X(ee) {
1646
+ ee.key === "Escape" && he(!1);
1647
+ }
1648
+ return document.addEventListener("mousedown", A), document.addEventListener("keydown", X), () => {
1649
+ document.removeEventListener("mousedown", A), document.removeEventListener("keydown", X);
1650
+ };
1651
+ }, [Le, j]);
1652
+ const We = a === "place-point", _e = a === "draw-line", Ge = a === "draw-polygon", Ue = a === "draw-circle", je = a === "draw-rect", qe = a === "draw-route", He = a === "draw-freehand", Ve = a === "pick-shape", vt = a === "measure", se = (A) => (!E || E.includes(A)) && !g.includes(A), Dr = null;
1653
+ function xt(A) {
1654
+ var X;
1655
+ if (A.key === "Tab" && V >= 0) {
1656
+ A.preventDefault(), (X = ve.current) == null || X.focusAdd(V);
1657
+ return;
1658
+ }
1659
+ re(A);
1660
+ }
1661
+ function wt(A, X) {
1662
+ var de;
1663
+ const ee = ((X + A) % v.length + v.length) % v.length;
1664
+ Y(ee), (de = ve.current) == null || de.focusAdd(ee);
1665
+ }
1666
+ return /* @__PURE__ */ T(
1667
+ "div",
1668
+ {
1669
+ ref: O,
1670
+ "data-elm-search-open": R ? "true" : void 0,
1671
+ className: t ? "select-none" : ne("absolute z-[500] flex gap-2 pointer-events-none select-none", p.className),
1672
+ style: t ? void 0 : p.style,
1673
+ children: [
1674
+ /* @__PURE__ */ T("div", { ref: De, className: "relative w-fit max-w-full", children: [
1675
+ R && !ge && /* @__PURE__ */ r(
1676
+ Ft,
1677
+ {
1678
+ ref: ve,
1679
+ results: v,
1680
+ loading: W,
1681
+ error: H,
1682
+ onGo: F,
1683
+ onAdd: N ? void 0 : I,
1684
+ onAddShape: N ? void 0 : _,
1685
+ activeIndex: V,
1686
+ onHoverIndex: Y,
1687
+ onNavigate: wt,
1688
+ layout: "row",
1689
+ className: `absolute left-0 right-0 bg-elm-surface border border-elm-border rounded-elm shadow-elm z-50 overflow-hidden pointer-events-auto ${w ? "bottom-full mb-2" : "top-full mt-2"}`
1690
+ }
1691
+ ),
1692
+ /* @__PURE__ */ T("div", { ref: pt, className: ne(
1693
+ "flex gap-2 bg-elm-surface/95 backdrop-blur-md border border-(--elm-border,color-mix(in_oklab,var(--color-black)_10%,transparent)) dark:border-(--elm-border,color-mix(in_oklab,var(--color-white)_10%,transparent)) shadow-elm rounded-elm pointer-events-auto antialiased",
1694
+ m ? "flex-col items-center p-[7px]" : "flex-row flex-wrap justify-center items-center p-[7px]"
1695
+ ), children: [
1696
+ N ? null : /* @__PURE__ */ T(le, { children: [
1697
+ se("point") && /* @__PURE__ */ r(me, { active: We, disabled: !We && s, onClick: () => z(We ? "none" : "place-point"), label: "Point", shortcut: K("place-point").toUpperCase(), shortcutId: "place-point", children: /* @__PURE__ */ r(Zt, { size: 24 }) }),
1698
+ se("line") && /* @__PURE__ */ r(me, { active: _e, disabled: !_e && s, onClick: () => z(_e ? "none" : "draw-line"), label: "Line", shortcut: K("draw-line").toUpperCase(), shortcutId: "draw-line", children: /* @__PURE__ */ r(Qt, { size: 24 }) }),
1699
+ se("polygon") && /* @__PURE__ */ r(me, { active: Ge, disabled: !Ge && s, onClick: () => z(Ge ? "none" : "draw-polygon"), label: "Area", shortcut: K("draw-polygon").toUpperCase(), shortcutId: "draw-polygon", children: /* @__PURE__ */ r(Yt, { size: 24 }) }),
1700
+ se("route") && /* @__PURE__ */ r(me, { active: qe, disabled: !qe && s, onClick: () => z(qe ? "none" : "draw-route"), label: "Route", shortcut: K("draw-route").toUpperCase(), shortcutId: "draw-route", children: /* @__PURE__ */ r(Nn, { size: 24 }) }),
1701
+ se("circle") && /* @__PURE__ */ r(me, { active: Ue, disabled: !Ue && s, onClick: () => z(Ue ? "none" : "draw-circle"), label: "Circle", shortcut: K("draw-circle").toUpperCase(), shortcutId: "draw-circle", children: /* @__PURE__ */ r(En, { size: 24 }) }),
1702
+ se("rectangle") && /* @__PURE__ */ r(me, { active: je, disabled: !je && s, onClick: () => z(je ? "none" : "draw-rect"), label: "Rectangle", shortcut: K("draw-rect").toUpperCase(), shortcutId: "draw-rect", children: /* @__PURE__ */ r(Pn, { size: 24 }) }),
1703
+ se("freehand") && /* @__PURE__ */ r(me, { active: He, disabled: !He && s, onClick: () => z(He ? "none" : "draw-freehand"), label: "Freehand", shortcut: K("draw-freehand").toUpperCase(), shortcutId: "draw-freehand", children: /* @__PURE__ */ r(Dn, { size: 24 }) }),
1704
+ se("picker") && /* @__PURE__ */ r(me, { active: Ve, disabled: !Ve && s, onClick: () => z(Ve ? "none" : "pick-shape"), label: "Picker", shortcut: K("picker").toUpperCase(), shortcutId: "picker", children: /* @__PURE__ */ r(In, { size: 24 }) })
1705
+ ] }),
1706
+ se("measure") && /* @__PURE__ */ T(le, { children: [
1707
+ !N && /* @__PURE__ */ r(zt, { vertical: m }),
1708
+ /* @__PURE__ */ r(me, { active: vt, onClick: () => P(vt ? "none" : "measure"), label: "Measure", shortcut: K("measure").toUpperCase(), shortcutId: "measure", children: /* @__PURE__ */ r(Mn, { size: 24 }) }),
1709
+ ge && se("search") && /* @__PURE__ */ r(zt, { vertical: m })
1710
+ ] }),
1711
+ se("search") && !ge && /* @__PURE__ */ T("div", { className: "flex items-center gap-2 pl-2.5 pr-3 py-1.5 bg-(--elm-surface-sunken,var(--color-gray-100)) dark:bg-(--elm-surface-sunken,color-mix(in_oklab,var(--color-white)_7%,transparent)) hover:bg-(--elm-control-hover,color-mix(in_oklab,var(--color-gray-200)_70%,transparent)) dark:hover:bg-(--elm-control-hover,color-mix(in_oklab,var(--color-white)_10%,transparent)) rounded-elm-control transition-colors w-52 focus-within:ring-1 focus-within:ring-inset focus-within:ring-(--elm-border-strong,var(--color-gray-300)) dark:focus-within:ring-(--elm-border-strong,var(--color-gray-600))", children: [
1712
+ /* @__PURE__ */ T(
1713
+ "div",
1714
+ {
1715
+ ref: gt,
1716
+ className: "flex items-center gap-2 flex-1 min-w-0",
1717
+ children: [
1718
+ /* @__PURE__ */ r(Ze, { size: 14, className: "text-elm-text-subtle flex-shrink-0" }),
1719
+ /* @__PURE__ */ r(
1720
+ "input",
1721
+ {
1722
+ ref: j,
1723
+ type: "text",
1724
+ value: b,
1725
+ onChange: (A) => k(A.target.value),
1726
+ onFocus: () => {
1727
+ L(!0), bt(), b.trim().length >= 2 && D(!0);
1728
+ },
1729
+ onBlur: () => L(!1),
1730
+ onKeyDown: xt,
1731
+ placeholder: "Search places…",
1732
+ className: "bg-transparent text-sm text-elm-text-secondary placeholder-elm-text-muted outline-none w-full",
1733
+ autoComplete: "off"
1734
+ }
1735
+ ),
1736
+ W && /* @__PURE__ */ r("div", { className: "w-3 h-3 border-2 border-(--elm-border-strong,var(--color-gray-300)) border-t-primary-500 rounded-full animate-spin flex-shrink-0" }),
1737
+ !W && b && /* @__PURE__ */ r("button", { onClick: G, className: "p-1 -m-1 rounded-elm-chip text-elm-text hover:bg-(--elm-control-hover,var(--color-gray-200)) dark:hover:bg-(--elm-control-hover,color-mix(in_oklab,var(--color-white)_15%,transparent)) transition-colors flex-shrink-0", "aria-label": "Clear search", children: /* @__PURE__ */ r(Tt, { size: 12 }) })
1738
+ ]
1739
+ }
1740
+ ),
1741
+ !W && !b && // Sibling of the animated row — excluded from the press-pulse scale.
1742
+ // Still fades opacity+scale on focus so the hint animates out when
1743
+ // the user starts searching.
1744
+ /* @__PURE__ */ T(
1745
+ "span",
1746
+ {
1747
+ className: ne(
1748
+ "flex items-center gap-0.5 flex-shrink-0 transition-all duration-110 ease-out",
1749
+ Z ? "opacity-0 scale-75 pointer-events-none" : "opacity-100 scale-100"
1750
+ ),
1751
+ children: [
1752
+ /* @__PURE__ */ r(Oe, { children: "⌘" }),
1753
+ /* @__PURE__ */ r(Oe, { children: "F" })
1754
+ ]
1755
+ }
1756
+ )
1757
+ ] }),
1758
+ se("search") && ge && /* @__PURE__ */ T("div", { ref: mt, "data-elm-search-toggle": "", className: m ? "relative" : void 0, children: [
1759
+ /* @__PURE__ */ r(
1760
+ me,
1761
+ {
1762
+ active: Le,
1763
+ onClick: () => he((A) => !A),
1764
+ label: "Search places",
1765
+ shortcut: "⌘F",
1766
+ children: /* @__PURE__ */ r(Ze, { size: 24 })
1767
+ }
1768
+ ),
1769
+ Le && /* @__PURE__ */ T(
1770
+ "div",
1771
+ {
1772
+ ref: ut,
1773
+ className: ne(
1774
+ "absolute z-50 bg-elm-surface/97 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm pointer-events-auto antialiased flex flex-col",
1775
+ // Vertical: beside the column. Compact horizontal: under
1776
+ // (or above) the bar, as wide as it, like the inline dropdown.
1777
+ m ? Pr === "right" ? "top-0 w-80 left-full ml-2" : "top-0 w-80 right-full mr-2" : `left-0 right-0 min-w-0 ${w ? "bottom-full mb-2" : "top-full mt-2"}`
1778
+ ),
1779
+ children: [
1780
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-2 px-3 py-2", children: [
1781
+ /* @__PURE__ */ r(Ze, { size: 16, className: "text-elm-text-subtle flex-shrink-0" }),
1782
+ /* @__PURE__ */ r(
1783
+ "input",
1784
+ {
1785
+ ref: j,
1786
+ type: "text",
1787
+ value: b,
1788
+ onChange: (A) => k(A.target.value),
1789
+ onFocus: () => {
1790
+ L(!0), b.trim().length >= 2 && D(!0);
1791
+ },
1792
+ onBlur: () => L(!1),
1793
+ onKeyDown: xt,
1794
+ placeholder: "Search places…",
1795
+ className: "bg-transparent text-sm text-elm-text-secondary placeholder-elm-text-muted outline-none w-full",
1796
+ autoComplete: "off"
1797
+ }
1798
+ ),
1799
+ W && /* @__PURE__ */ r("div", { className: "w-3 h-3 border-2 border-(--elm-border-strong,var(--color-gray-300)) border-t-primary-500 rounded-full animate-spin flex-shrink-0" }),
1800
+ !W && b && /* @__PURE__ */ r("button", { onClick: G, className: "p-1 -m-1 rounded-elm-chip text-elm-text hover:bg-(--elm-control-hover,var(--color-gray-200)) dark:hover:bg-(--elm-control-hover,color-mix(in_oklab,var(--color-white)_15%,transparent)) transition-colors flex-shrink-0", "aria-label": "Clear search", children: /* @__PURE__ */ r(Tt, { size: 12 }) })
1801
+ ] }),
1802
+ R && /* @__PURE__ */ r(
1803
+ Ft,
1804
+ {
1805
+ ref: ve,
1806
+ results: v,
1807
+ loading: W,
1808
+ error: H,
1809
+ onGo: (A) => {
1810
+ F(A), he(!1);
1811
+ },
1812
+ onAdd: N ? void 0 : (A) => {
1813
+ I(A), he(!1);
1814
+ },
1815
+ onAddShape: N ? void 0 : (A) => {
1816
+ _(A), he(!1);
1817
+ },
1818
+ activeIndex: V,
1819
+ onHoverIndex: Y,
1820
+ onNavigate: wt,
1821
+ className: "border-t border-elm-border max-h-80 overflow-y-auto"
1822
+ }
1823
+ )
1824
+ ]
1825
+ }
1826
+ )
1827
+ ] })
1828
+ ] })
1829
+ ] }),
1830
+ !N && Dr
1831
+ ]
1832
+ }
1833
+ );
1834
+ }
1835
+ function Bt(t) {
1836
+ const e = [], n = (s) => {
1837
+ for (const o of Array.from(s.children)) {
1838
+ if (getComputedStyle(o).display === "contents") {
1839
+ n(o);
1840
+ continue;
1841
+ }
1842
+ const d = o.getBoundingClientRect();
1843
+ if (!d.width) continue;
1844
+ const i = d.top + d.height / 2;
1845
+ e.some((m) => Math.abs(m - i) < 8) || e.push(i);
1846
+ }
1847
+ };
1848
+ return n(t), e.length;
1849
+ }
1850
+ function Go(t, e) {
1851
+ pe(() => {
1852
+ const n = t.current;
1853
+ if (!n) return;
1854
+ const s = () => {
1855
+ n.style.maxWidth = "";
1856
+ const c = Bt(n);
1857
+ if (c < 2) return;
1858
+ let y = 0, f = n.offsetWidth;
1859
+ for (; f - y > 1; ) {
1860
+ const h = y + f >> 1;
1861
+ n.style.maxWidth = h + "px", Bt(n) > c || n.scrollWidth > n.clientWidth ? y = h : f = h;
1862
+ }
1863
+ n.style.maxWidth = f + "px";
1864
+ };
1865
+ s();
1866
+ const o = [];
1867
+ for (let c = n.parentElement; c && o.length < 8 && (o.push(c), !c.hasAttribute("data-elm-theme")); c = c.parentElement)
1868
+ ;
1869
+ const d = /* @__PURE__ */ new WeakMap(), i = () => {
1870
+ for (const c of o) d.set(c, c.clientWidth);
1871
+ };
1872
+ i();
1873
+ const m = new ResizeObserver((c) => {
1874
+ c.every((y) => d.get(y.target) === y.target.clientWidth) || (s(), i());
1875
+ });
1876
+ for (const c of o) m.observe(c);
1877
+ return () => {
1878
+ m.disconnect(), n.style.maxWidth = "";
1879
+ };
1880
+ }, [t, e]);
1881
+ }
1882
+ const Uo = _t(() => import("./BooleanOperations-BRO7NHUY.js"));
1883
+ function Js() {
1884
+ const { dataStore: t } = oe(), e = S((k) => k.readonly), n = S((k) => k.transformActive), s = S((k) => k.setTransformActive), o = S((k) => k.editingMode), d = S((k) => k.setEditingMode), i = U((k) => k.selectedIds), m = i.length === 1 ? i[0] : null, c = S((k) => k.closeDialog), { getKey: y } = Ee(), f = ae(), h = U((k) => {
1885
+ if (!m) return null;
1886
+ const D = k.features.find((R) => R.id === m);
1887
+ return (D == null ? void 0 : D.geometry.type) ?? null;
1888
+ }), u = B(null);
1889
+ if (Go(u, `${e}|${i.length}|${h}`), e) return null;
1890
+ const x = m !== null || i.length > 0, w = h === "Polygon" || h === "MultiPolygon", M = h === "MultiPoint" || h === "MultiPolygon" || h === "MultiLineString" || h === "GeometryCollection", C = i.length === 1 && h === "Point", l = x && !C, p = w, a = Fe(h), E = M, g = i.length >= 2, N = E || g;
1891
+ function P() {
1892
+ if (i.length !== 0 && t.getState().duplicateSelection())
1893
+ if (i.length === 1) {
1894
+ const k = t.getState().features.find((D) => D.id === i[0]);
1895
+ f({ type: "feature:duplicated", featureId: i[0], label: String((k == null ? void 0 : k.properties.name) || "feature") });
1896
+ } else
1897
+ f({ type: "features:duplicated", count: i.length });
1898
+ }
1899
+ function z() {
1900
+ if (!m || !M) return;
1901
+ const k = t.getState().features.find((R) => R.id === m);
1902
+ if (!k) return;
1903
+ const D = rt(k.geometry);
1904
+ t.getState().breakMultiGeometry(m) && f({ type: "feature:broken", featureId: m, count: D, undo: () => t.getState().undo() });
1905
+ }
1906
+ function K() {
1907
+ i.length < 2 || (t.getState().mergeFeatures(), f({ type: "success", message: `Merged ${i.length} features` }));
1908
+ }
1909
+ function b() {
1910
+ if (i.length === 0) return;
1911
+ const k = i.length, D = k === 1 ? t.getState().features.find((O) => O.id === i[0]) : null, R = k === 1 ? String((D == null ? void 0 : D.properties.name) || "Unnamed feature") : `${k} features`;
1912
+ t.getState().deleteSelection(), c(), f(k === 1 ? { type: "feature:deleted", featureId: i[0], label: R, undo: () => t.getState().undo() } : { type: "features:deleted", count: k, undo: () => t.getState().undo() });
1913
+ }
1914
+ return /* @__PURE__ */ T("div", { className: "flex flex-wrap items-center justify-center gap-3 max-w-full pointer-events-none", children: [
1915
+ x && /* @__PURE__ */ T("div", { ref: u, className: "flex flex-wrap items-center justify-center gap-2 max-w-full bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm px-2 py-2 pointer-events-auto antialiased", children: [
1916
+ l && /* @__PURE__ */ r(
1917
+ te,
1918
+ {
1919
+ label: "Transform",
1920
+ shortcut: /* @__PURE__ */ r(Q, { children: y("toggle-transform").toUpperCase() }),
1921
+ shortcutId: "toggle-transform",
1922
+ onClick: () => {
1923
+ s(!n), !n && o !== "none" && d("none");
1924
+ },
1925
+ active: n,
1926
+ children: /* @__PURE__ */ r(er, { size: 24 })
1927
+ }
1928
+ ),
1929
+ l && (a || N) && /* @__PURE__ */ r(Ne, {}),
1930
+ p && /* @__PURE__ */ T(le, { children: [
1931
+ /* @__PURE__ */ r(
1932
+ te,
1933
+ {
1934
+ label: "Cut hole",
1935
+ shortcut: /* @__PURE__ */ r(Q, { children: y("cut-hole").toUpperCase() }),
1936
+ shortcutId: "cut-hole",
1937
+ onClick: () => {
1938
+ d(o === "cut-hole" ? "none" : "cut-hole"), n && s(!1);
1939
+ },
1940
+ active: o === "cut-hole",
1941
+ children: /* @__PURE__ */ r(tr, { size: 24 })
1942
+ }
1943
+ ),
1944
+ /* @__PURE__ */ r(
1945
+ te,
1946
+ {
1947
+ label: "Slice shape",
1948
+ shortcut: /* @__PURE__ */ r(Q, { children: y("slice-shape").toUpperCase() }),
1949
+ shortcutId: "slice-shape",
1950
+ onClick: () => {
1951
+ d(o === "slice-shape" ? "none" : "slice-shape"), n && s(!1);
1952
+ },
1953
+ active: o === "slice-shape",
1954
+ children: /* @__PURE__ */ r(rr, { size: 24 })
1955
+ }
1956
+ )
1957
+ ] }),
1958
+ a && /* @__PURE__ */ T(le, { children: [
1959
+ /* @__PURE__ */ r(
1960
+ te,
1961
+ {
1962
+ label: "Simplify shape",
1963
+ onClick: () => {
1964
+ d(o === "simplify-shape" ? "none" : "simplify-shape"), n && s(!1);
1965
+ },
1966
+ active: o === "simplify-shape",
1967
+ children: /* @__PURE__ */ r("svg", { width: "24", height: "24", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: o === "simplify-shape" ? 1.5 : 1, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ r("polyline", { points: "2.5,8 5.25,3.5 8,8 10.75,12.5 13.5,8" }) })
1968
+ }
1969
+ ),
1970
+ /* @__PURE__ */ r(
1971
+ te,
1972
+ {
1973
+ label: "Smooth shape",
1974
+ onClick: () => {
1975
+ d(o === "smooth-shape" ? "none" : "smooth-shape"), n && s(!1);
1976
+ },
1977
+ active: o === "smooth-shape",
1978
+ children: /* @__PURE__ */ r(nr, { size: 24 })
1979
+ }
1980
+ ),
1981
+ /* @__PURE__ */ r(
1982
+ te,
1983
+ {
1984
+ label: "Buffer",
1985
+ onClick: () => {
1986
+ d(o === "buffer-shape" ? "none" : "buffer-shape"), n && s(!1);
1987
+ },
1988
+ active: o === "buffer-shape",
1989
+ children: /* @__PURE__ */ r(or, { size: 24 })
1990
+ }
1991
+ )
1992
+ ] }),
1993
+ a && N && /* @__PURE__ */ r(Ne, {}),
1994
+ E && /* @__PURE__ */ r(
1995
+ te,
1996
+ {
1997
+ label: "Break apart",
1998
+ shortcut: /* @__PURE__ */ r(Q, { children: y("break-apart").toUpperCase() }),
1999
+ shortcutId: "break-apart",
2000
+ onClick: z,
2001
+ children: /* @__PURE__ */ r(sr, { size: 24 })
2002
+ }
2003
+ ),
2004
+ g && /* @__PURE__ */ r(te, { label: "Merge", onClick: K, children: /* @__PURE__ */ r(ir, { size: 24 }) }),
2005
+ (l || a || N) && /* @__PURE__ */ r(Ne, {}),
2006
+ /* @__PURE__ */ r(
2007
+ te,
2008
+ {
2009
+ label: "Duplicate",
2010
+ shortcut: /* @__PURE__ */ T(le, { children: [
2011
+ /* @__PURE__ */ r(Q, { children: "⌘" }),
2012
+ /* @__PURE__ */ r(Q, { children: "D" })
2013
+ ] }),
2014
+ shortcutId: "duplicate",
2015
+ onClick: P,
2016
+ children: /* @__PURE__ */ r(Xt, { size: 24 })
2017
+ }
2018
+ ),
2019
+ /* @__PURE__ */ r(
2020
+ te,
2021
+ {
2022
+ label: "Delete",
2023
+ shortcut: /* @__PURE__ */ r(Q, { children: Vt("delete-selected") }),
2024
+ shortcutId: "delete-selected",
2025
+ onClick: b,
2026
+ children: /* @__PURE__ */ r(ze, { size: 24 })
2027
+ }
2028
+ )
2029
+ ] }),
2030
+ i.length >= 2 && /* @__PURE__ */ r(Ut, { fallback: null, children: /* @__PURE__ */ r(Uo, {}) })
2031
+ ] });
2032
+ }
2033
+ const jo = "calc(var(--elm-bottom-stack-offset, calc(var(--elm-table-offset, 0px) + var(--elm-bottom-toolbar-offset, 0px) + 16px)) + 58px)";
2034
+ function Xs({ mapContainer: t, count: e, onSimplify: n, onDelete: s }) {
2035
+ const o = t.parentElement;
2036
+ return o ? cr(
2037
+ /* @__PURE__ */ r(
2038
+ "div",
2039
+ {
2040
+ className: "absolute left-0 right-0 z-[400] flex justify-center pointer-events-none",
2041
+ style: { bottom: jo },
2042
+ onMouseDown: (d) => d.stopPropagation(),
2043
+ onContextMenu: (d) => d.stopPropagation(),
2044
+ children: /* @__PURE__ */ T("div", { className: "flex items-center gap-2 bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm px-2 py-2 pointer-events-auto antialiased", children: [
2045
+ /* @__PURE__ */ T("span", { className: "px-1 text-sm text-elm-text-muted tabular-nums", children: [
2046
+ e,
2047
+ " point",
2048
+ e !== 1 ? "s" : "",
2049
+ " selected"
2050
+ ] }),
2051
+ /* @__PURE__ */ r(Ne, {}),
2052
+ /* @__PURE__ */ T(te, { label: "Simplify selected points", onClick: n, disabled: e < 3, children: [
2053
+ /* @__PURE__ */ r(Tn, { size: 24 }),
2054
+ /* @__PURE__ */ r("span", { className: "px-1 font-medium", children: "Simplify" })
2055
+ ] }),
2056
+ /* @__PURE__ */ T(te, { label: "Delete selected points", onClick: s, children: [
2057
+ /* @__PURE__ */ r(ze, { size: 24 }),
2058
+ /* @__PURE__ */ r("span", { className: "px-1 font-medium", children: "Delete" })
2059
+ ] }),
2060
+ /* @__PURE__ */ r(Oe, { children: "Del" })
2061
+ ] })
2062
+ }
2063
+ ),
2064
+ o
2065
+ ) : null;
2066
+ }
2067
+ const qo = /* @__PURE__ */ r("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ r("polyline", { points: "2.5,8 5.25,3.5 8,8 10.75,12.5 13.5,8" }) }), Ho = [
2068
+ { mode: "cut-hole", label: "Cut hole", icon: /* @__PURE__ */ r(tr, { size: 16 }), shortcut: "cut-hole" },
2069
+ { mode: "slice-shape", label: "Slice shape", icon: /* @__PURE__ */ r(rr, { size: 16 }), shortcut: "slice-shape" }
2070
+ ], Vo = [
2071
+ { mode: "simplify-shape", label: "Simplify shape", icon: qo },
2072
+ { mode: "smooth-shape", label: "Smooth shape", icon: /* @__PURE__ */ r(nr, { size: 16 }) },
2073
+ { mode: "buffer-shape", label: "Buffer", icon: /* @__PURE__ */ r(or, { size: 16 }) }
2074
+ ];
2075
+ function Zs({ x: t, y: e, data: n, onClose: s }) {
2076
+ const { feature: o, requestPreciseCoords: d } = n, { dataStore: i } = oe(), m = S((P) => P.readonly), c = S((P) => P.transformActive), y = S((P) => P.setTransformActive), f = S((P) => P.editingMode), h = S((P) => P.setEditingMode), u = S((P) => P.closeDialog), x = U((P) => P.selectedIds), w = ae(), { getKey: M } = Ee();
2077
+ if (m) return null;
2078
+ const C = o.geometry.type, l = C === "Polygon" || C === "MultiPolygon", p = C === "MultiPoint" || C === "MultiPolygon" || C === "MultiLineString" || C === "GeometryCollection", a = x.length >= 2 && x.includes(o.id);
2079
+ function E(P) {
2080
+ h(f === P ? "none" : P), c && y(!1);
2081
+ }
2082
+ function g(P) {
2083
+ return /* @__PURE__ */ r(Q, { children: M(P).toUpperCase() });
2084
+ }
2085
+ const N = [];
2086
+ if (N.push({
2087
+ label: "Transform",
2088
+ icon: /* @__PURE__ */ r(er, { size: 16 }),
2089
+ shortcut: g("toggle-transform"),
2090
+ onClick: () => {
2091
+ y(!c), !c && f !== "none" && h("none");
2092
+ }
2093
+ }), Fe(C)) {
2094
+ N.push({ separator: !0 });
2095
+ for (const P of [...l ? Ho : [], ...Vo])
2096
+ N.push({
2097
+ label: P.label,
2098
+ icon: P.icon,
2099
+ shortcut: P.shortcut ? g(P.shortcut) : void 0,
2100
+ onClick: () => E(P.mode)
2101
+ });
2102
+ }
2103
+ return l && N.push({
2104
+ label: "Center point",
2105
+ icon: /* @__PURE__ */ r(An, { size: 16, weight: "fill" }),
2106
+ onClick: () => {
2107
+ var b;
2108
+ const P = jn(o), z = typeof ((b = o.properties) == null ? void 0 : b.name) == "string" && o.properties.name ? o.properties.name : null, K = {
2109
+ type: "Feature",
2110
+ id: crypto.randomUUID(),
2111
+ geometry: { type: "Point", coordinates: P.geometry.coordinates },
2112
+ properties: z ? { name: `${z} center` } : {},
2113
+ groupId: o.groupId
2114
+ };
2115
+ i.getState().addFeature(K);
2116
+ }
2117
+ }), (p || a) && (N.push({ separator: !0 }), p && N.push({
2118
+ label: "Break apart",
2119
+ icon: /* @__PURE__ */ r(sr, { size: 16 }),
2120
+ shortcut: g("break-apart"),
2121
+ onClick: () => {
2122
+ const P = rt(o.geometry);
2123
+ i.getState().breakMultiGeometry(o.id) && w({ type: "feature:broken", featureId: o.id, count: P, undo: () => i.getState().undo() });
2124
+ }
2125
+ }), a && N.push({
2126
+ label: `Merge ${x.length} features`,
2127
+ icon: /* @__PURE__ */ r(ir, { size: 16 }),
2128
+ onClick: () => {
2129
+ const P = x.length;
2130
+ i.getState().mergeFeatures(), w({ type: "success", message: `Merged ${P} features` });
2131
+ }
2132
+ })), d && (N.push({ separator: !0 }), N.push({
2133
+ label: "Precise coordinates…",
2134
+ icon: /* @__PURE__ */ r(Fn, { size: 16 }),
2135
+ onClick: d
2136
+ })), N.push({ separator: !0 }), N.push({
2137
+ label: a ? `Delete ${x.length} features` : "Delete",
2138
+ icon: /* @__PURE__ */ r(ze, { size: 16 }),
2139
+ shortcut: /* @__PURE__ */ r(Q, { children: Vt("delete-selected") }),
2140
+ onClick: () => {
2141
+ var K;
2142
+ const P = a ? x.length : 1, z = String(((K = o.properties) == null ? void 0 : K.name) || "feature");
2143
+ i.getState().deleteSelection(), u(), w(P === 1 ? { type: "feature:deleted", featureId: o.id, label: z, undo: () => i.getState().undo() } : { type: "features:deleted", count: P, undo: () => i.getState().undo() });
2144
+ }
2145
+ }), /* @__PURE__ */ r(ar, { x: t, y: e, items: N, onClose: s });
2146
+ }
2147
+ function Jo({ size: t, tooltipSide: e }) {
2148
+ const n = U((d) => d.undoStack.length > 0), s = U((d) => d.undo), o = ae();
2149
+ return /* @__PURE__ */ r(
2150
+ Pe,
2151
+ {
2152
+ label: "Undo",
2153
+ shortcutId: "undo",
2154
+ shortcut: /* @__PURE__ */ T("span", { className: "flex items-center gap-0.5", children: [
2155
+ /* @__PURE__ */ r(Q, { children: "⌘" }),
2156
+ /* @__PURE__ */ r(Q, { children: "Z" })
2157
+ ] }),
2158
+ onClick: () => {
2159
+ n && (s(), o({ type: "undo" }));
2160
+ },
2161
+ disabled: !n,
2162
+ size: t,
2163
+ tooltipSide: e,
2164
+ children: /* @__PURE__ */ r(Ln, { size: 24 })
2165
+ }
2166
+ );
2167
+ }
2168
+ function Xo({ size: t, tooltipSide: e }) {
2169
+ const n = U((d) => d.redoStack.length > 0), s = U((d) => d.redo), o = ae();
2170
+ return /* @__PURE__ */ r(
2171
+ Pe,
2172
+ {
2173
+ label: "Redo",
2174
+ shortcutId: "redo",
2175
+ shortcut: /* @__PURE__ */ T("span", { className: "flex items-center gap-0.5", children: [
2176
+ /* @__PURE__ */ r(Q, { children: "⌘" }),
2177
+ /* @__PURE__ */ r(Q, { children: "⇧" }),
2178
+ /* @__PURE__ */ r(Q, { children: "Z" })
2179
+ ] }),
2180
+ onClick: () => {
2181
+ n && (s(), o({ type: "redo" }));
2182
+ },
2183
+ disabled: !n,
2184
+ size: t,
2185
+ tooltipSide: e,
2186
+ children: /* @__PURE__ */ r(zn, { size: 24 })
2187
+ }
2188
+ );
2189
+ }
2190
+ function Zo({ direction: t = "horizontal", children: e }) {
2191
+ return /* @__PURE__ */ r("div", { "data-elm-group": "", className: `flex bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm pointer-events-auto antialiased items-center gap-1 px-2 py-1.5 ${t === "vertical" ? "flex-col" : "flex-row"}`, children: e });
2192
+ }
2193
+ function Ys({ direction: t = "vertical" }) {
2194
+ const e = t === "vertical" ? "right" : "top";
2195
+ return /* @__PURE__ */ T(Zo, { direction: t, children: [
2196
+ /* @__PURE__ */ r(Jo, { size: "group", tooltipSide: e }),
2197
+ /* @__PURE__ */ r(Xo, { size: "group", tooltipSide: e })
2198
+ ] });
2199
+ }
2200
+ const Wt = "h-8 px-3 rounded-elm-control text-sm flex items-center justify-center gap-1.5 active:scale-[0.95]";
2201
+ function Qs() {
2202
+ const { ui: t } = ce(), e = S((v) => v.editingMode), n = S((v) => v.lineInProgress), s = S((v) => v.polygonInProgress), o = S((v) => v.routeWaypoints), d = S((v) => v.routeLoading), i = S((v) => v.commitLine), m = S((v) => v.commitPolygon), c = S((v) => v.commitRoute), y = S((v) => v.commitSliceShape), f = S((v) => v.commitCutHole), h = S((v) => v.cancelDrawing), u = S((v) => v.circleCenter), x = S((v) => v.rectCorner), w = S((v) => v.freehandPoints), M = S((v) => v.freehandClosed), C = S((v) => v.setFreehandClosed), l = S((v) => v.measurePoints), p = S((v) => v.measureMode), a = S((v) => v.setMeasureMode), E = e === "draw-line" || e === "slice-shape", g = e === "draw-polygon" || e === "cut-hole", N = e === "draw-route", P = e === "draw-circle", z = e === "draw-rect", K = e === "draw-freehand", b = e === "place-point", k = e === "measure", D = e === "pick-shape";
2203
+ if (!(E || g || N || P || z || K || b) && !k && !D) return null;
2204
+ const O = n.length > 0 || s.length > 0 || !!u || !!x || o.length > 0 || w.length > 0 || l.length > 0;
2205
+ function j() {
2206
+ if (e === "slice-shape") {
2207
+ if (n.length < 2) return;
2208
+ y();
2209
+ } else if (e === "cut-hole") {
2210
+ if (s.length < 3) return;
2211
+ f();
2212
+ } else if (E) {
2213
+ if (n.length < 2) return;
2214
+ i({});
2215
+ } else if (g) {
2216
+ if (s.length < 3) return;
2217
+ m({});
2218
+ } else if (N) {
2219
+ if (o.length < 2) return;
2220
+ c();
2221
+ }
2222
+ }
2223
+ const Z = E ? n.length >= 2 : g ? s.length >= 3 : N ? o.length >= 2 && !d : !1, L = b ? "Click to place a point" : e === "draw-line" ? n.length === 0 ? "Click to place the first point" : "Click to add points · Double-click to finish · ⌫ undo last" : e === "draw-polygon" ? s.length === 0 ? "Click to place the first point" : s.length < 3 ? "Click to continue · ⌫ undo last" : "Click to add points · Double-click to close · ⌫ undo last" : N ? o.length === 0 ? "Click to place the first waypoint" : "Click to add waypoints · ⌫ undo last" : P ? "Click and drag to size" : z ? "Click and drag to size · Hold Shift for square" : K ? "Click and drag to draw" : e === "slice-shape" ? n.length === 0 ? "Draw a line across the shape to slice it" : "Click to add points · Double-click to cut · ⌫ undo last" : e === "cut-hole" ? s.length === 0 ? "Draw a shape inside to cut a hole" : s.length < 3 ? "Click to continue · ⌫ undo last" : "Click to add points · Double-click to cut · ⌫ undo last" : k ? l.length === 0 ? "Click to start measuring" : "Click to add points · Double-click to finish · ⌫ undo last" : D ? "Click anywhere to import a shape from the map" : null;
2224
+ return /* @__PURE__ */ T("div", { className: "flex flex-wrap items-center justify-center gap-2 max-w-full bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm px-2 py-2 pointer-events-auto", children: [
2225
+ k && /* @__PURE__ */ T(le, { children: [
2226
+ /* @__PURE__ */ r(
2227
+ te,
2228
+ {
2229
+ active: p === "distance",
2230
+ onClick: () => a("distance"),
2231
+ label: "Measure distance",
2232
+ children: /* @__PURE__ */ r(Rn, { size: 24 })
2233
+ }
2234
+ ),
2235
+ /* @__PURE__ */ r(
2236
+ te,
2237
+ {
2238
+ active: p === "area",
2239
+ onClick: () => a("area"),
2240
+ label: "Measure area",
2241
+ children: /* @__PURE__ */ r($n, { size: 24 })
2242
+ }
2243
+ )
2244
+ ] }),
2245
+ e === "draw-freehand" && /* @__PURE__ */ r(
2246
+ te,
2247
+ {
2248
+ active: M,
2249
+ onClick: () => C(!M),
2250
+ label: "Closed shape",
2251
+ children: /* @__PURE__ */ r(Kn, { size: 24, weight: M ? "fill" : "regular" })
2252
+ }
2253
+ ),
2254
+ (k || e === "draw-freehand") && /* @__PURE__ */ r(Ne, {}),
2255
+ t.hints && L && /* @__PURE__ */ r("span", { className: "text-sm text-elm-text-muted px-2", children: L }),
2256
+ t.hints && L && /* @__PURE__ */ r(Ne, {}),
2257
+ Z && /* @__PURE__ */ T(
2258
+ "button",
2259
+ {
2260
+ type: "button",
2261
+ onClick: j,
2262
+ className: `${Wt} shadow-sm bg-primary-500 text-white hover:bg-primary-600`,
2263
+ children: [
2264
+ N ? "Save route" : e === "slice-shape" ? "Slice" : e === "cut-hole" ? "Cut" : "Finish",
2265
+ /* @__PURE__ */ r(Ie, { children: "↵" })
2266
+ ]
2267
+ }
2268
+ ),
2269
+ /* @__PURE__ */ T(
2270
+ "button",
2271
+ {
2272
+ type: "button",
2273
+ onClick: h,
2274
+ className: `${Wt} text-(--elm-text-muted,var(--color-gray-600)) dark:text-(--elm-text-muted,var(--color-gray-400)) hover:bg-elm-control-hover`,
2275
+ children: [
2276
+ O ? "Cancel" : "Exit",
2277
+ /* @__PURE__ */ r(Oe, { children: "Esc" })
2278
+ ]
2279
+ }
2280
+ )
2281
+ ] });
2282
+ }
2283
+ function ei({ size: t, tooltipSide: e } = {}) {
2284
+ const { fitBounds: n } = Ae(), s = ae(), o = U((m) => m.features), d = U((m) => m.selectedIds);
2285
+ function i() {
2286
+ if (!n) return;
2287
+ let m = o;
2288
+ if (d.length > 0) {
2289
+ const c = new Set(d);
2290
+ m = o.filter((y) => c.has(y.id));
2291
+ }
2292
+ if (m.length === 0) {
2293
+ s({ type: "warning", message: "No features on the map to zoom to" });
2294
+ return;
2295
+ }
2296
+ try {
2297
+ if (m.length === 1) {
2298
+ const f = m[0];
2299
+ n(f.bbox || ot(f.geometry));
2300
+ return;
2301
+ }
2302
+ const c = qn(m), y = dr(c);
2303
+ n(y);
2304
+ } catch (c) {
2305
+ s({ type: "error", code: "geometry", source: "editor", message: "Failed to calculate map bounds", cause: c });
2306
+ }
2307
+ }
2308
+ return /* @__PURE__ */ r(
2309
+ Pe,
2310
+ {
2311
+ label: "Fit map to features",
2312
+ tooltipContent: d.length > 0 ? "Zoom to selection" : "Zoom to all features",
2313
+ onClick: i,
2314
+ size: t,
2315
+ tooltipSide: e,
2316
+ children: /* @__PURE__ */ r(On, { size: 24 })
2317
+ }
2318
+ );
2319
+ }
2320
+ const Yo = "flex items-center justify-center h-6 min-w-6 px-1.5 rounded-elm-control bg-transparent border border-transparent text-elm-text font-elm-mono text-xs tabular-nums select-none transition-colors focus-visible:ring-2 focus-visible:ring-elm-focus-ring", Qo = "flex items-center justify-center h-8 min-w-8 px-1 rounded-elm-control bg-transparent border border-transparent text-elm-text font-elm-mono text-sm tabular-nums select-none transition-colors", es = "flex items-center justify-center w-12 h-12 bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm-control rounded-elm text-elm-text font-elm-mono text-sm select-none transition-colors";
2321
+ function ti({ minZoom: t = 1, maxZoom: e = 22, fractional: n = !1, size: s = "md", tooltipSide: o = "top" }) {
2322
+ const d = U((E) => E.currentZoom), { flyTo: i, getCenter: m } = Ae(), c = ae(), y = !!i && !!m, f = S((E) => E.zoomEditing), h = S((E) => E.setZoomEditing), [u, x] = q(null), w = B(null), M = B(!1), { getKey: C } = Ee(), l = s === "sm" ? Yo : s === "group" ? Qo : es, p = s !== "md";
2323
+ $(() => {
2324
+ u !== null && (n ? Math.abs(d - u) < 0.05 : Math.round(d) === Math.round(u)) && x(null);
2325
+ }, [d, u, n]);
2326
+ function a() {
2327
+ var P;
2328
+ const E = (((P = w.current) == null ? void 0 : P.value) ?? "").trim();
2329
+ if (E === "") {
2330
+ h(!1);
2331
+ return;
2332
+ }
2333
+ const g = Number(E);
2334
+ if (!Number.isFinite(g)) {
2335
+ c({ type: "warning", message: `"${E}" is not a valid zoom level` });
2336
+ return;
2337
+ }
2338
+ if (g < t || g > e) {
2339
+ c({ type: "warning", message: `Zoom must be between ${t} and ${e}` });
2340
+ return;
2341
+ }
2342
+ if (!i || !m) {
2343
+ c({ type: "warning", message: "Map is not ready yet — try again in a moment" });
2344
+ return;
2345
+ }
2346
+ const N = m();
2347
+ x(g), i([N[1], N[0]], g), h(!1);
2348
+ }
2349
+ if (f) {
2350
+ const E = n ? (u ?? d).toFixed(1) : String(Math.round(u ?? d));
2351
+ return /* @__PURE__ */ r(
2352
+ "input",
2353
+ {
2354
+ ref: w,
2355
+ type: "text",
2356
+ inputMode: n ? "decimal" : "numeric",
2357
+ pattern: n ? "[0-9.]*" : "[0-9]*",
2358
+ autoFocus: !0,
2359
+ defaultValue: E,
2360
+ onFocus: (g) => {
2361
+ const N = g.currentTarget;
2362
+ M.current ? N.setSelectionRange(N.value.length, N.value.length) : N.select(), M.current = !1;
2363
+ },
2364
+ onKeyDown: (g) => {
2365
+ g.key === "Enter" ? (g.preventDefault(), a()) : g.key === "Escape" && (g.preventDefault(), h(!1));
2366
+ },
2367
+ onBlur: () => h(!1),
2368
+ "aria-label": "Zoom level",
2369
+ className: `${l.replace(" select-none", "")} text-center focus:outline-none focus:border-elm-focus-ring${p ? " w-10 !bg-elm-surface" : ""}`
2370
+ }
2371
+ );
2372
+ }
2373
+ return /* @__PURE__ */ r(
2374
+ be,
2375
+ {
2376
+ content: y ? "Set zoom level" : "Map zoom level",
2377
+ side: o,
2378
+ shortcut: y ? /* @__PURE__ */ r(Q, { children: C("set-zoom").toUpperCase() }) : void 0,
2379
+ children: /* @__PURE__ */ r(
2380
+ "button",
2381
+ {
2382
+ type: "button",
2383
+ "aria-label": y ? "Set map zoom level" : "Map zoom level",
2384
+ "data-elm-shortcut": "set-zoom",
2385
+ onClick: () => {
2386
+ y && (M.current = !0, h(!0));
2387
+ },
2388
+ disabled: !y,
2389
+ className: `${l} ${y ? `${p ? "hover:bg-(--elm-control-hover,color-mix(in_oklab,var(--color-gray-200)_70%,transparent)) dark:hover:bg-(--elm-control-hover,var(--color-gray-800))" : "hover:bg-elm-surface-hover"} focus:outline-none focus-visible:ring-2 focus-visible:ring-elm-focus-ring cursor-pointer` : "cursor-default"}`,
2390
+ children: n ? (u ?? d).toFixed(1) : Math.round(u ?? d)
2391
+ }
2392
+ )
2393
+ }
2394
+ );
2395
+ }
2396
+ function ri({ zoom: t = 15, size: e, tooltipSide: n }) {
2397
+ const { flyTo: s } = Ae(), o = ae(), [d, i] = q(!1);
2398
+ function m() {
2399
+ if (!navigator.geolocation) {
2400
+ o({ type: "error", code: "unsupported", source: "locate", message: "Geolocation is not supported by this browser" });
2401
+ return;
2402
+ }
2403
+ if (!s) {
2404
+ o({ type: "warning", message: "Map is not ready yet — try again in a moment" });
2405
+ return;
2406
+ }
2407
+ d || (i(!0), navigator.geolocation.getCurrentPosition(
2408
+ (c) => {
2409
+ i(!1), s([c.coords.latitude, c.coords.longitude], t);
2410
+ },
2411
+ (c) => {
2412
+ i(!1), o({
2413
+ type: "error",
2414
+ code: c.code === c.PERMISSION_DENIED ? "permission-denied" : c.code === c.TIMEOUT ? "timeout" : "unknown",
2415
+ source: "locate",
2416
+ cause: c,
2417
+ message: c.code === c.PERMISSION_DENIED ? "Location access denied" : "Could not determine your location"
2418
+ });
2419
+ },
2420
+ { timeout: 1e4 }
2421
+ ));
2422
+ }
2423
+ return (
2424
+ // Not `disabled` while locating: that fades the whole button (disabled
2425
+ // opacity). A repeat click is ignored in handleLocate instead.
2426
+ /* @__PURE__ */ r(Pe, { label: d ? "Locating…" : "Show my location", onClick: m, size: e, tooltipSide: n, children: d ? /* @__PURE__ */ r("div", { className: `${e === "sm" ? "w-3.5 h-3.5" : "w-5 h-5"} border-2 border-current/25 border-t-current rounded-full animate-spin`, "aria-hidden": !0 }) : /* @__PURE__ */ r(Bn, { size: 24 }) })
2427
+ );
2428
+ }
2429
+ function ni() {
2430
+ return S((e) => e.readonly) ? /* @__PURE__ */ T("div", { className: "flex items-center gap-2 px-4 py-2 bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm text-sm text-(--elm-text-secondary,var(--color-gray-600)) dark:text-(--elm-text-secondary,var(--color-gray-300)) pointer-events-auto antialiased select-none", children: [
2431
+ /* @__PURE__ */ r(st, { size: 20, weight: "duotone", className: "text-elm-text-muted" }),
2432
+ /* @__PURE__ */ r("span", { children: "View-only mode" })
2433
+ ] }) : null;
2434
+ }
2435
+ const ts = 3e4;
2436
+ let ie = null;
2437
+ const Te = /* @__PURE__ */ new Map();
2438
+ function at(t, e) {
2439
+ ie == null || ie.terminate(), ie = null;
2440
+ const n = [...Te.values()];
2441
+ Te.clear();
2442
+ for (const s of n)
2443
+ clearTimeout(s.timer), s.reject(new Be(e, "geometry", t));
2444
+ }
2445
+ async function rs() {
2446
+ if (ie) return ie;
2447
+ const { default: t } = await import("./geometryWorker-DgQCFSmD.js");
2448
+ return ie || (ie = new t(), ie.onmessage = (e) => {
2449
+ const { id: n, ok: s, result: o, error: d } = e.data, i = Te.get(n);
2450
+ if (i) {
2451
+ if (Te.delete(n), clearTimeout(i.timer), s && (o != null && o.geometry)) {
2452
+ i.resolve(o.geometry);
2453
+ return;
2454
+ }
2455
+ i.reject(new Be("geometry", "geometry", (d == null ? void 0 : d.message) || "Geometry operation failed"));
2456
+ }
2457
+ }, ie.onerror = () => at("Geometry worker failed", "geometry"), ie);
2458
+ }
2459
+ function Cr(t, { timeoutMs: e = ts } = {}) {
2460
+ return rs().then((n) => new Promise((s, o) => {
2461
+ const d = crypto.randomUUID(), i = setTimeout(() => {
2462
+ at(`Geometry operation timed out after ${e} ms`, "timeout");
2463
+ }, e);
2464
+ Te.set(d, { resolve: s, reject: o, timer: i });
2465
+ const m = { id: d, payload: t };
2466
+ n.postMessage(m);
2467
+ }));
2468
+ }
2469
+ typeof Worker < "u" && nn(Cr);
2470
+ function oi() {
2471
+ at("Geometry worker disposed", "unknown");
2472
+ }
2473
+ function ct(t, e) {
2474
+ var m;
2475
+ const n = (m = tt(Wr)) == null ? void 0 : m.emit, s = B(n);
2476
+ s.current = n;
2477
+ const o = B({
2478
+ seq: 0,
2479
+ epoch: 0,
2480
+ busy: !1,
2481
+ queued: null,
2482
+ owned: !1,
2483
+ onSettled: null,
2484
+ alive: !0
2485
+ }).current, d = J(() => {
2486
+ const c = o.onSettled;
2487
+ o.onSettled = null, c == null || c();
2488
+ }, [o]), i = J((c) => {
2489
+ const y = ++o.seq, f = o.epoch;
2490
+ o.busy = !0, Cr(c).then((h) => h, (h) => {
2491
+ var u;
2492
+ return o.alive && f === o.epoch && ((u = s.current) == null || u.call(s, {
2493
+ type: "error",
2494
+ code: h instanceof Be ? h.code : "geometry",
2495
+ source: "geometry",
2496
+ message: `The ${c.type} preview failed: ${h instanceof Error ? h.message : String(h)}`,
2497
+ cause: h,
2498
+ quiet: !0
2499
+ })), null;
2500
+ }).then((h) => {
2501
+ if (o.busy = !1, !o.alive || f !== o.epoch) {
2502
+ if (o.queued) {
2503
+ const w = o.queued;
2504
+ o.queued = null, i(w);
2505
+ }
2506
+ return;
2507
+ }
2508
+ const u = o.queued;
2509
+ o.queued = null;
2510
+ const x = y === o.seq;
2511
+ (x || u && u.geometry === c.geometry) && (o.owned = !0, e(h)), u ? i(u) : x && d();
2512
+ });
2513
+ }, [o, e, d]);
2514
+ return $(() => {
2515
+ if (!t) {
2516
+ o.epoch++, o.queued = null, o.onSettled = null, o.owned && (o.owned = !1, e(null));
2517
+ return;
2518
+ }
2519
+ if (o.busy) {
2520
+ o.queued = t, o.seq++;
2521
+ return;
2522
+ }
2523
+ i(t);
2524
+ }, [t, o, i, e]), $(() => (o.alive = !0, () => {
2525
+ o.alive = !1, o.queued = null, o.onSettled = null;
2526
+ }), [o]), J((c) => {
2527
+ !o.busy && !o.queued ? c() : o.onSettled = c;
2528
+ }, [o]);
2529
+ }
2530
+ const ns = 111320;
2531
+ function os(t, e) {
2532
+ const n = t * ns;
2533
+ if (n < 1)
2534
+ return `<1${It(1, e).unit}`;
2535
+ const s = It(n, e);
2536
+ return `~${s.value}${s.unit}`;
2537
+ }
2538
+ function si() {
2539
+ const t = S((g) => g.editingMode), e = S((g) => g.simplifyTolerance), n = S((g) => g.setSimplifyTolerance), s = S((g) => g.setGeometryPreview), o = S((g) => g.geometryPreview), d = S((g) => g.commitGeometryProcess), i = S((g) => g.cancelGeometryProcess), { units: m } = ce(), c = { unit: m.length, display: m.display, precision: m.precision }, { dataStore: y } = oe(), f = ke(), h = U((g) => g.selectedIds[0] ?? null), u = U((g) => {
2540
+ var N;
2541
+ return h ? ((N = g.features.find((P) => P.id === h)) == null ? void 0 : N.geometry) ?? null : null;
2542
+ }), x = U((g) => {
2543
+ var N;
2544
+ return h ? ((N = g.features.find((P) => P.id === h)) == null ? void 0 : N._drawType) ?? null : null;
2545
+ }), w = ue(() => {
2546
+ if (!u || t !== "simplify-shape") return 0;
2547
+ try {
2548
+ const g = dr({ type: "Feature", geometry: u, properties: {} }), N = Math.sqrt((g[2] - g[0]) ** 2 + (g[3] - g[1]) ** 2);
2549
+ return (e / 100) ** 2 * N * 0.3;
2550
+ } catch {
2551
+ return 0;
2552
+ }
2553
+ }, [e, u, t]), M = t === "simplify-shape", C = ue(() => !M || !u || !Fe(u.type) ? null : { type: "simplify", geometry: u, tolerance: w }, [M, u, w]), l = ct(C, s);
2554
+ $(() => () => {
2555
+ y.getState(), s(null);
2556
+ }, [s, y]);
2557
+ const p = u ? Ke(u) : 0, a = o ? Ke(o) : p, E = p - a;
2558
+ return $(() => {
2559
+ if (t !== "simplify-shape") return;
2560
+ function g(N) {
2561
+ f(N) && (N.key === "Enter" && o && E > 0 ? (N.preventDefault(), l(d)) : N.key === "Escape" && (N.preventDefault(), i()));
2562
+ }
2563
+ return window.addEventListener("keydown", g), () => window.removeEventListener("keydown", g);
2564
+ }, [t, o, E, d, i, l, f]), t !== "simplify-shape" ? null : /* @__PURE__ */ T("div", { className: "flex flex-wrap items-center justify-center gap-3 max-w-full bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm px-3 py-1.5 pointer-events-auto", children: [
2565
+ /* @__PURE__ */ r("span", { className: "text-sm font-medium text-elm-text-secondary shrink-0", children: "Simplify" }),
2566
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-2", children: [
2567
+ /* @__PURE__ */ r(
2568
+ "input",
2569
+ {
2570
+ type: "range",
2571
+ min: 0,
2572
+ max: 100,
2573
+ value: e,
2574
+ onChange: (g) => n(Number(g.target.value)),
2575
+ className: "w-32 accent-primary-600"
2576
+ }
2577
+ ),
2578
+ /* @__PURE__ */ r("span", { className: "text-sm text-elm-text-muted w-16 shrink-0", children: os(w, c) })
2579
+ ] }),
2580
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-1 text-sm text-elm-text-muted shrink-0", children: [
2581
+ /* @__PURE__ */ r("span", { className: "font-elm-mono", children: p }),
2582
+ /* @__PURE__ */ r("span", { children: "→" }),
2583
+ /* @__PURE__ */ r("span", { className: `font-elm-mono font-medium ${E > 0 ? "text-primary-600 dark:text-primary-400" : "text-(--elm-text-secondary,var(--color-gray-600)) dark:text-(--elm-text-secondary,var(--color-gray-300))"}`, children: a }),
2584
+ E > 0 && /* @__PURE__ */ T("span", { className: "text-xs text-primary-500", children: [
2585
+ "(−",
2586
+ E,
2587
+ ")"
2588
+ ] }),
2589
+ /* @__PURE__ */ r("span", { className: "ml-0.5", children: "points" })
2590
+ ] }),
2591
+ x && /* @__PURE__ */ r("span", { className: "text-xs text-amber-600 dark:text-amber-400 shrink-0", children: x === "route" ? "Turns this route into a plain line." : `Turns this ${x} into a plain shape.` }),
2592
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-1 shrink-0", children: [
2593
+ /* @__PURE__ */ r(we, { variant: "ghost", onClick: i, className: "rounded-elm-control h-8 px-3 text-sm", children: "Cancel" }),
2594
+ /* @__PURE__ */ r(we, { variant: "primary", onClick: () => l(d), disabled: !o || E === 0, className: "rounded-elm-control h-8 px-3 text-sm", children: "Apply" })
2595
+ ] })
2596
+ ] });
2597
+ }
2598
+ function ii() {
2599
+ const t = S((p) => p.editingMode), e = S((p) => p.smoothIterations), n = S((p) => p.setSmoothIterations), s = S((p) => p.setGeometryPreview), o = S((p) => p.geometryPreview), d = S((p) => p.commitGeometryProcess), i = S((p) => p.cancelGeometryProcess), { dataStore: m } = oe(), c = ke(), y = U((p) => p.selectedIds[0] ?? null), f = U((p) => {
2600
+ var a;
2601
+ return y ? ((a = p.features.find((E) => E.id === y)) == null ? void 0 : a.geometry) ?? null : null;
2602
+ }), h = U((p) => {
2603
+ var a;
2604
+ return y ? ((a = p.features.find((E) => E.id === y)) == null ? void 0 : a._drawType) ?? null : null;
2605
+ }), u = t === "smooth-shape", x = ue(() => !u || !f || !Fe(f.type) ? null : { type: "smooth", geometry: f, iterations: e }, [u, f, e]), w = ct(x, s);
2606
+ $(() => () => {
2607
+ m.getState(), s(null);
2608
+ }, [s, m]);
2609
+ const M = f ? Ke(f) : 0, C = o ? Ke(o) : M, l = C - M;
2610
+ return $(() => {
2611
+ if (t !== "smooth-shape") return;
2612
+ function p(a) {
2613
+ c(a) && (a.key === "Enter" && o ? (a.preventDefault(), w(d)) : a.key === "Escape" && (a.preventDefault(), i()));
2614
+ }
2615
+ return window.addEventListener("keydown", p), () => window.removeEventListener("keydown", p);
2616
+ }, [t, o, d, i, w, c]), t !== "smooth-shape" ? null : /* @__PURE__ */ T("div", { className: "flex flex-wrap items-center justify-center gap-3 max-w-full bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm px-3 py-1.5 pointer-events-auto", children: [
2617
+ /* @__PURE__ */ r("span", { className: "text-sm font-medium text-elm-text-secondary shrink-0", children: "Smooth" }),
2618
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-2", children: [
2619
+ /* @__PURE__ */ r(
2620
+ "input",
2621
+ {
2622
+ type: "range",
2623
+ min: 1,
2624
+ max: 5,
2625
+ step: 1,
2626
+ value: e,
2627
+ onChange: (p) => n(Number(p.target.value)),
2628
+ className: "w-24 accent-primary-600"
2629
+ }
2630
+ ),
2631
+ /* @__PURE__ */ T("span", { className: "text-sm text-elm-text-muted w-16 shrink-0", children: [
2632
+ e,
2633
+ " ",
2634
+ e === 1 ? "pass" : "passes"
2635
+ ] })
2636
+ ] }),
2637
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-1 text-sm text-elm-text-muted shrink-0", children: [
2638
+ /* @__PURE__ */ r("span", { className: "font-elm-mono", children: M }),
2639
+ /* @__PURE__ */ r("span", { children: "→" }),
2640
+ /* @__PURE__ */ r("span", { className: "font-elm-mono font-medium text-primary-600 dark:text-primary-400", children: C }),
2641
+ l > 0 && /* @__PURE__ */ T("span", { className: "text-xs text-primary-500", children: [
2642
+ "(+",
2643
+ l,
2644
+ ")"
2645
+ ] }),
2646
+ /* @__PURE__ */ r("span", { className: "ml-0.5", children: "points" })
2647
+ ] }),
2648
+ h && /* @__PURE__ */ r("span", { className: "text-xs text-amber-600 dark:text-amber-400 shrink-0", children: h === "route" ? "Turns this route into a plain line." : `Turns this ${h} into a plain shape.` }),
2649
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-1 shrink-0", children: [
2650
+ /* @__PURE__ */ r(we, { variant: "ghost", onClick: i, className: "rounded-elm-control h-8 px-3 text-sm", children: "Cancel" }),
2651
+ /* @__PURE__ */ r(we, { variant: "primary", onClick: () => w(d), disabled: !o, className: "rounded-elm-control h-8 px-3 text-sm", children: "Apply" })
2652
+ ] })
2653
+ ] });
2654
+ }
2655
+ const dt = 0.3048, ss = 5280, Nr = dt * ss;
2656
+ function is(t, e) {
2657
+ switch (e) {
2658
+ case "m":
2659
+ return t;
2660
+ case "km":
2661
+ return t * 1e3;
2662
+ case "ft":
2663
+ return t * dt;
2664
+ case "mi":
2665
+ return t * Nr;
2666
+ }
2667
+ }
2668
+ function ls(t, e) {
2669
+ switch (e) {
2670
+ case "m":
2671
+ return t;
2672
+ case "km":
2673
+ return t / 1e3;
2674
+ case "ft":
2675
+ return t / dt;
2676
+ case "mi":
2677
+ return t / Nr;
2678
+ }
2679
+ }
2680
+ function li() {
2681
+ const { dataStore: t } = oe(), e = ke(), n = S((D) => D.editingMode), s = S((D) => D.bufferDistance), o = S((D) => D.setBufferDistance), d = S((D) => D.bufferCreateNew), i = S((D) => D.setBufferCreateNew), m = S((D) => D.setGeometryPreview), c = S((D) => D.geometryPreview), y = S((D) => D.commitBufferProcess), f = S((D) => D.cancelBufferProcess), { units: h } = ce(), u = on(h.length), x = ue(
2682
+ () => u === "imperial" ? ["ft", "mi"] : ["m", "km"],
2683
+ [u]
2684
+ ), [w, M] = q(!1), C = w ? x[1] : x[0], [l, p] = q(null);
2685
+ $(() => {
2686
+ var O;
2687
+ if (n !== "buffer-shape") {
2688
+ p(null);
2689
+ return;
2690
+ }
2691
+ const D = t.getState().selectedIds[0] ?? null;
2692
+ if (!D) return;
2693
+ const R = ((O = t.getState().features.find((j) => j.id === D)) == null ? void 0 : O.geometry) ?? null;
2694
+ R && Fe(R.type) && p(R);
2695
+ }, [n, t]);
2696
+ const a = sn(l == null ? void 0 : l.type), E = ue(
2697
+ () => l && !(a && s <= 0) ? { type: "buffer", geometry: l, distance: s } : null,
2698
+ [l, s, a]
2699
+ ), g = ct(E, m);
2700
+ $(() => () => {
2701
+ m(null);
2702
+ }, [m]), $(() => {
2703
+ if (n !== "buffer-shape") return;
2704
+ function D(R) {
2705
+ e(R) && (R.key === "Enter" && c ? (R.preventDefault(), g(y)) : R.key === "Escape" && (R.preventDefault(), f()));
2706
+ }
2707
+ return window.addEventListener("keydown", D), () => window.removeEventListener("keydown", D);
2708
+ }, [n, c, y, f, g, e]);
2709
+ const N = C === "km" || C === "mi", P = ls(s, C), z = N ? Number(P.toFixed(2)) : Math.round(P), K = N ? 0.1 : 1;
2710
+ function b(D) {
2711
+ const R = parseFloat(D);
2712
+ isNaN(R) || o(Math.round(is(R, C)));
2713
+ }
2714
+ function k() {
2715
+ M((D) => !D);
2716
+ }
2717
+ return n !== "buffer-shape" ? null : /* @__PURE__ */ T("div", { className: "flex flex-wrap items-center justify-center gap-3 max-w-full bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm px-3 py-1.5 pointer-events-auto", children: [
2718
+ /* @__PURE__ */ r("span", { className: "text-sm font-medium text-elm-text-secondary shrink-0", children: "Buffer" }),
2719
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-1", children: [
2720
+ /* @__PURE__ */ r(
2721
+ "input",
2722
+ {
2723
+ type: "range",
2724
+ min: a ? 0 : -500,
2725
+ max: 2e3,
2726
+ step: 1,
2727
+ value: s,
2728
+ onChange: (D) => o(Number(D.target.value)),
2729
+ className: "w-28 accent-primary-600"
2730
+ }
2731
+ ),
2732
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-0.5", children: [
2733
+ /* @__PURE__ */ r(
2734
+ "input",
2735
+ {
2736
+ type: "number",
2737
+ value: z,
2738
+ step: K,
2739
+ onChange: (D) => b(D.target.value),
2740
+ className: "w-16 text-sm text-right bg-transparent border border-elm-border rounded-elm-control px-1.5 py-0.5 text-elm-text-secondary focus:outline-none focus:border-primary-500"
2741
+ }
2742
+ ),
2743
+ /* @__PURE__ */ r(
2744
+ "button",
2745
+ {
2746
+ onClick: k,
2747
+ className: "text-xs text-primary-600 dark:text-primary-400 hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) font-medium px-1.5 py-0.5 rounded-elm-control shrink-0 transition-colors",
2748
+ children: C
2749
+ }
2750
+ )
2751
+ ] })
2752
+ ] }),
2753
+ /* @__PURE__ */ T("label", { className: "flex items-center gap-1.5 cursor-pointer shrink-0 select-none", children: [
2754
+ /* @__PURE__ */ r("span", { className: "text-sm text-(--elm-text-muted,var(--color-gray-600)) dark:text-(--elm-text-muted,var(--color-gray-400))", children: "New shape" }),
2755
+ /* @__PURE__ */ r(
2756
+ "div",
2757
+ {
2758
+ role: "checkbox",
2759
+ "aria-checked": d,
2760
+ onClick: () => i(!d),
2761
+ className: `relative w-8 h-4 rounded-full transition-colors cursor-pointer ${d ? "bg-primary-500 dark:bg-primary-600" : "bg-elm-border"}`,
2762
+ children: /* @__PURE__ */ r(
2763
+ "span",
2764
+ {
2765
+ className: `absolute top-0.5 w-3 h-3 bg-white rounded-full shadow-sm transition-transform ${d ? "translate-x-4" : "translate-x-0.5"}`
2766
+ }
2767
+ )
2768
+ }
2769
+ )
2770
+ ] }),
2771
+ /* @__PURE__ */ T("div", { className: "flex items-center gap-1 shrink-0", children: [
2772
+ /* @__PURE__ */ r(we, { variant: "ghost", onClick: f, className: "rounded-elm-control h-8 px-3 text-sm", children: "Cancel" }),
2773
+ /* @__PURE__ */ r(we, { variant: "primary", onClick: () => g(y), disabled: !c, className: "rounded-elm-control h-8 px-3 text-sm", children: "Apply" })
2774
+ ] })
2775
+ ] });
2776
+ }
2777
+ const as = 8, cs = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -3, ArrowDown: 3 };
2778
+ function ai({ options: t, value: e, onChange: n, label: s = "Basemap", size: o, tooltipSide: d }) {
2779
+ const [i, m] = q(!1), [c, y] = q(null), [f, h] = q(!1), u = B(null), x = B(null), w = Kr(), M = qr(), C = c !== null;
2780
+ pe(() => {
2781
+ var K, b;
2782
+ const a = (b = (K = u.current) == null ? void 0 : K.querySelector("button")) == null ? void 0 : b.getBoundingClientRect(), E = x.current;
2783
+ if (!i || !a || !E) return;
2784
+ const { width: g, height: N } = E.getBoundingClientRect(), P = a.top + a.height / 2 > window.innerHeight / 2, z = a.left + a.width / 2 > window.innerWidth / 2;
2785
+ y(ln(z ? a.right : a.left, P ? a.top : a.bottom, g, N, {
2786
+ x: z ? "before" : "after",
2787
+ y: P ? "before" : "after",
2788
+ gapY: as
2789
+ }));
2790
+ }, [i, t.length]), $(() => {
2791
+ var E;
2792
+ if (!i || !C) return;
2793
+ const a = x.current;
2794
+ (E = (a == null ? void 0 : a.querySelector('[aria-pressed="true"]')) ?? (a == null ? void 0 : a.querySelector("button"))) == null || E.focus();
2795
+ }, [i, C]), $(() => {
2796
+ if (!i) return;
2797
+ const a = (E) => {
2798
+ var g, N, P;
2799
+ E.key === "Escape" && (E.stopImmediatePropagation(), E.preventDefault(), (g = x.current) != null && g.contains(document.activeElement) && ((P = (N = u.current) == null ? void 0 : N.querySelector("button")) == null || P.focus()), m(!1));
2800
+ };
2801
+ return window.addEventListener("keydown", a, { capture: !0 }), () => window.removeEventListener("keydown", a, { capture: !0 });
2802
+ }, [i]);
2803
+ const l = (a) => {
2804
+ const E = cs[a.key];
2805
+ if (!E) return;
2806
+ const g = Array.from(a.currentTarget.querySelectorAll("button")), N = g[g.indexOf(document.activeElement) + E];
2807
+ N && (a.preventDefault(), N.focus());
2808
+ };
2809
+ return /* @__PURE__ */ T("div", { ref: u, className: "contents", children: [
2810
+ /* @__PURE__ */ r(Pe, { label: s, onClick: () => {
2811
+ var a, E;
2812
+ y(null), h(((E = (a = u.current) == null ? void 0 : a.closest("[data-elm-theme]")) == null ? void 0 : E.getAttribute("data-elm-theme")) === "dark"), m((g) => !g);
2813
+ }, active: i, expanded: i, controls: i ? w : void 0, size: o, tooltipSide: d, children: /* @__PURE__ */ r(Ye, { size: 24 }) }),
2814
+ i && cr(
2815
+ /* @__PURE__ */ r("div", { "data-elm-portal": !0, "data-elm-theme": f ? "dark" : "light", style: M, [Un]: "", children: /* @__PURE__ */ r(
2816
+ "div",
2817
+ {
2818
+ ref: x,
2819
+ id: w,
2820
+ role: "group",
2821
+ "aria-label": s,
2822
+ className: "fixed z-[9999] w-80 max-h-[70vh] flex flex-col bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm antialiased",
2823
+ style: { left: (c == null ? void 0 : c.left) ?? 0, top: (c == null ? void 0 : c.top) ?? 0, visibility: c ? void 0 : "hidden" },
2824
+ children: /* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-2 p-2 overflow-y-auto", onKeyDown: l, children: t.map((a) => {
2825
+ const E = a.id === e;
2826
+ return /* @__PURE__ */ T(
2827
+ "button",
2828
+ {
2829
+ type: "button",
2830
+ "aria-pressed": E,
2831
+ "aria-label": a.label,
2832
+ onClick: () => n(a.id),
2833
+ className: `flex flex-col rounded-elm-card border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/60 ${E ? "border-primary-500 ring-2 ring-primary-400/40 bg-primary-50 hover:bg-primary-100 dark:bg-primary-950/40 dark:hover:bg-primary-950/60" : "border-elm-border hover:border-(--elm-border-strong,var(--color-gray-400)) dark:hover:border-(--elm-border-strong,var(--color-gray-500)) bg-elm-surface hover:bg-elm-surface-hover"}`,
2834
+ children: [
2835
+ Array.isArray(a.thumbnail) ? /* @__PURE__ */ r("div", { className: "w-full h-12 flex rounded-t-elm-card overflow-hidden", children: a.thumbnail.map((g) => /* @__PURE__ */ r("img", { src: g, alt: "", className: "w-1/2 h-full object-cover", loading: "lazy", draggable: !1 }, g)) }) : a.thumbnail ? /* @__PURE__ */ r("img", { src: a.thumbnail, alt: "", className: "w-full h-12 object-cover rounded-t-elm-card", loading: "lazy", draggable: !1 }) : /* @__PURE__ */ r("div", { className: "w-full h-12 rounded-t-elm-card bg-elm-surface-hover flex items-center justify-center text-elm-text-subtle", children: /* @__PURE__ */ r(Ye, { size: 20 }) }),
2836
+ /* @__PURE__ */ r("div", { className: `text-[11px] leading-4 tracking-tight text-center px-0.5 py-1 truncate font-medium ${E ? "text-primary-700 dark:text-primary-300" : "text-(--elm-text-secondary,var(--color-gray-700)) dark:text-(--elm-text-secondary,var(--color-gray-200))"}`, children: a.label })
2837
+ ]
2838
+ },
2839
+ a.id
2840
+ );
2841
+ }) })
2842
+ }
2843
+ ) }),
2844
+ document.body
2845
+ )
2846
+ ] });
2847
+ }
2848
+ function ci(t, e) {
2849
+ const n = B(e);
2850
+ n.current = e, $(() => cn(t, () => n.current), [t]);
2851
+ }
2852
+ const ds = (t, e) => Object.keys(t).every((n) => t[n] === e[n]);
2853
+ function di(t) {
2854
+ const [e, n] = q(() => Mt(t));
2855
+ return $(() => {
2856
+ const s = () => {
2857
+ const m = Mt(t);
2858
+ n((c) => ds(c, m) ? c : m);
2859
+ };
2860
+ let o = 0;
2861
+ const d = () => {
2862
+ o || (o = requestAnimationFrame(() => {
2863
+ o = 0, s();
2864
+ }));
2865
+ };
2866
+ s();
2867
+ const i = Hr((t == null ? void 0 : t.closest("[data-elm-theme]")) ?? null, d);
2868
+ return () => {
2869
+ i(), cancelAnimationFrame(o);
2870
+ };
2871
+ }, [t]), e;
2872
+ }
2873
+ const us = [
2874
+ ".geojson",
2875
+ ".json",
2876
+ "application/geo+json",
2877
+ "application/json"
2878
+ ];
2879
+ function ms(t, e) {
2880
+ const n = t.name.toLowerCase();
2881
+ for (const s of e) {
2882
+ const o = s.toLowerCase();
2883
+ if (o.startsWith(".")) {
2884
+ if (n.endsWith(o)) return !0;
2885
+ } else if (o.endsWith("/*")) {
2886
+ const d = o.slice(0, -1);
2887
+ if (t.type.toLowerCase().startsWith(d)) return !0;
2888
+ } else if (t.type.toLowerCase() === o)
2889
+ return !0;
2890
+ }
2891
+ return !1;
2892
+ }
2893
+ function ui(t) {
2894
+ const {
2895
+ onImport: e,
2896
+ onError: n,
2897
+ maxBytes: s = dn,
2898
+ accept: o = us,
2899
+ disabled: d = !1
2900
+ } = t, [i, m] = q(!1), [c, y] = q(!1), f = B(0), h = B(null), u = B(!0), x = B(e), w = B(n);
2901
+ $(() => {
2902
+ x.current = e;
2903
+ }, [e]), $(() => {
2904
+ w.current = n;
2905
+ }, [n]), $(() => (u.current = !0, () => {
2906
+ u.current = !1;
2907
+ }), []);
2908
+ const M = ue(() => o.join(","), [o]), C = J(async (b) => {
2909
+ var k, D, R, O;
2910
+ if (!ms(b, o)) {
2911
+ (k = w.current) == null || k.call(w, { kind: "wrong-type", file: b });
2912
+ return;
2913
+ }
2914
+ if (b.size > s) {
2915
+ (D = w.current) == null || D.call(w, { kind: "too-large", bytes: b.size, maxBytes: s });
2916
+ return;
2917
+ }
2918
+ y(!0);
2919
+ try {
2920
+ const j = await b.text();
2921
+ if (!u.current) return;
2922
+ const Z = un(j, { maxBytes: s });
2923
+ if (!u.current) return;
2924
+ if (!Z.ok) {
2925
+ (R = w.current) == null || R.call(w, Z.error);
2926
+ return;
2927
+ }
2928
+ x.current(Z.fc, b);
2929
+ } catch (j) {
2930
+ if (!u.current) return;
2931
+ (O = w.current) == null || O.call(w, {
2932
+ kind: "invalid-json",
2933
+ cause: j instanceof Error ? j : new Error(String(j))
2934
+ });
2935
+ } finally {
2936
+ u.current && y(!1);
2937
+ }
2938
+ }, [o, s]), l = J((b) => {
2939
+ var k, D;
2940
+ d || (D = (k = b.dataTransfer) == null ? void 0 : k.types) != null && D.includes("Files") && (b.preventDefault(), b.stopPropagation(), f.current += 1, m(!0));
2941
+ }, [d]), p = J((b) => {
2942
+ var k, D;
2943
+ d || (D = (k = b.dataTransfer) == null ? void 0 : k.types) != null && D.includes("Files") && (b.preventDefault(), b.stopPropagation(), b.dataTransfer.dropEffect = "copy");
2944
+ }, [d]), a = J((b) => {
2945
+ d || (b.preventDefault(), b.stopPropagation(), f.current = Math.max(0, f.current - 1), f.current === 0 && m(!1));
2946
+ }, [d]), E = J((b) => {
2947
+ var D, R;
2948
+ if (d) return;
2949
+ b.preventDefault(), b.stopPropagation(), f.current = 0, m(!1);
2950
+ const k = (R = (D = b.dataTransfer) == null ? void 0 : D.files) == null ? void 0 : R[0];
2951
+ k && C(k);
2952
+ }, [d, C]), g = J((b) => {
2953
+ var D;
2954
+ if (d) return;
2955
+ const k = (D = b.target.files) == null ? void 0 : D[0];
2956
+ b.target.value = "", k && C(k);
2957
+ }, [d, C]), N = J((b) => {
2958
+ h.current = b;
2959
+ }, []), P = J(() => {
2960
+ var b;
2961
+ d || (b = h.current) == null || b.click();
2962
+ }, [d]), z = J(() => ({
2963
+ onDragEnter: l,
2964
+ onDragOver: p,
2965
+ onDragLeave: a,
2966
+ onDrop: E
2967
+ }), [l, p, a, E]), K = J(() => ({
2968
+ type: "file",
2969
+ accept: M,
2970
+ style: { display: "none" },
2971
+ ref: N,
2972
+ onChange: g
2973
+ }), [M, N, g]);
2974
+ return { getRootProps: z, getInputProps: K, isDragActive: i, isProcessing: c, open: P };
2975
+ }
2976
+ const fs = "application/geo+json";
2977
+ function ps(t, e) {
2978
+ const n = typeof e == "function" ? e(t) : typeof e == "string" && e.length > 0 ? e : "features";
2979
+ return n.toLowerCase().endsWith(".geojson") ? n : `${n}.geojson`;
2980
+ }
2981
+ function mi(t) {
2982
+ const { getFeatureCollection: e, filename: n, indent: s = 2, disabled: o = !1 } = t, d = B(e), i = B(t.onExport), m = B(t.onError), c = B(n), y = B(s), f = B(o);
2983
+ $(() => {
2984
+ d.current = e;
2985
+ }, [e]), $(() => {
2986
+ i.current = t.onExport;
2987
+ }, [t.onExport]), $(() => {
2988
+ m.current = t.onError;
2989
+ }, [t.onError]), $(() => {
2990
+ c.current = n;
2991
+ }, [n]), $(() => {
2992
+ y.current = s;
2993
+ }, [s]), $(() => {
2994
+ f.current = o;
2995
+ }, [o]);
2996
+ const h = J(() => {
2997
+ var l;
2998
+ if (f.current) return null;
2999
+ const C = d.current();
3000
+ return !C || !Array.isArray(C.features) || C.features.length === 0 ? ((l = m.current) == null || l.call(m, { kind: "empty" }), null) : C;
3001
+ }, []), u = J((C) => {
3002
+ var l;
3003
+ try {
3004
+ return JSON.stringify(C, null, y.current);
3005
+ } catch (p) {
3006
+ return (l = m.current) == null || l.call(m, {
3007
+ kind: "serialization-error",
3008
+ cause: p instanceof Error ? p : new Error(String(p))
3009
+ }), null;
3010
+ }
3011
+ }, []), x = J(() => {
3012
+ const C = h();
3013
+ return C ? u(C) : null;
3014
+ }, [h, u]), w = J(() => {
3015
+ const C = x();
3016
+ return C === null ? null : new Blob([C], { type: fs });
3017
+ }, [x]);
3018
+ return { exportToFile: J(() => {
3019
+ const C = h();
3020
+ if (!C) return null;
3021
+ const l = u(C);
3022
+ if (l === null) return null;
3023
+ const p = ps(C, c.current);
3024
+ return jt(l, p).then((a) => {
3025
+ var E;
3026
+ a && ((E = i.current) == null || E.call(i, C, a));
3027
+ }), p;
3028
+ }, [h, u]), exportToString: x, exportToBlob: w };
3029
+ }
3030
+ class hs extends Fr.Component {
3031
+ constructor() {
3032
+ super(...arguments);
3033
+ Pt(this, "state", { hasError: !1, error: null });
3034
+ }
3035
+ static getDerivedStateFromError(n) {
3036
+ return { hasError: !0, error: n };
3037
+ }
3038
+ componentDidCatch(n) {
3039
+ var s, o;
3040
+ (o = (s = this.props).onError) == null || o.call(s, new Be("crash", "editor", `The editor crashed: ${(n == null ? void 0 : n.message) ?? String(n)}`, { cause: n }));
3041
+ }
3042
+ render() {
3043
+ var n;
3044
+ return this.state.hasError ? /* @__PURE__ */ T(
3045
+ "div",
3046
+ {
3047
+ style: {
3048
+ display: "flex",
3049
+ flexDirection: "column",
3050
+ alignItems: "center",
3051
+ justifyContent: "center",
3052
+ width: "100%",
3053
+ height: "100%",
3054
+ padding: 32,
3055
+ fontFamily: "var(--elm-font, system-ui, sans-serif)",
3056
+ // Design tokens when the integrator set them; the plain fallback look otherwise.
3057
+ background: "var(--elm-surface-sunken, #fafafa)",
3058
+ color: "var(--elm-text, #333)"
3059
+ },
3060
+ children: [
3061
+ /* @__PURE__ */ r("p", { style: { fontSize: 16, fontWeight: 600, marginBottom: 8 }, children: "Something went wrong" }),
3062
+ /* @__PURE__ */ r("p", { style: { fontSize: 13, color: "var(--elm-text-muted, #666)", marginBottom: 16, maxWidth: 420, textAlign: "center" }, children: ((n = this.state.error) == null ? void 0 : n.message) || "An unexpected error occurred in the map editor." }),
3063
+ /* @__PURE__ */ r(
3064
+ "button",
3065
+ {
3066
+ onClick: () => this.setState({ hasError: !1, error: null }),
3067
+ style: {
3068
+ padding: "8px 16px",
3069
+ fontSize: 13,
3070
+ borderRadius: 8,
3071
+ border: "1px solid var(--elm-border, #ddd)",
3072
+ background: "var(--elm-surface, white)",
3073
+ cursor: "pointer"
3074
+ },
3075
+ children: "Try again"
3076
+ }
3077
+ )
3078
+ ]
3079
+ }
3080
+ ) : this.props.children;
3081
+ }
3082
+ }
3083
+ function fi({ config: t, accentColor: e, featureColor: n, onEvent: s, onError: o, toaster: d = !0, children: i }) {
3084
+ const m = ue(
3085
+ () => e || n ? { ...t, ...e && { accentColor: e }, ...n && { featureColor: n } } : t,
3086
+ [t, e, n]
3087
+ );
3088
+ return /* @__PURE__ */ r(hs, { onError: o, children: /* @__PURE__ */ r(Vr, { config: m, children: /* @__PURE__ */ r(Hn, { children: /* @__PURE__ */ r(_r, { children: /* @__PURE__ */ r(Gr, { onEvent: s, onError: o, toaster: d, children: /* @__PURE__ */ r(Ur, { children: i }) }) }) }) }) });
3089
+ }
3090
+ const gs = fe(() => import("./GeoJSONModal-BV9Tamf4.js")), ys = fe(() => import("./SchemaModal-DvMbWskS.js")), bs = fe(() => import("./FeatureEditModal-Dr10p3nE.js")), vs = fe(() => import("./DataTablePanel-DDFUmMaM.js")), xs = fe(() => import("./SettingsModal-BScVTjpn.js")), ws = fe(
3091
+ () => import("./ShortcutsModal-ozuS2Ysb.js").then((t) => ({ default: t.ShortcutsModal }))
3092
+ );
3093
+ it(gs, ys, bs, vs, xs, ws);
3094
+ const ks = fe(() => import("./BooleanOperations-BRO7NHUY.js"));
3095
+ it(ks);
3096
+ export {
3097
+ ws as $,
3098
+ Qs as A,
3099
+ ai as B,
3100
+ $o as C,
3101
+ Jn as D,
3102
+ Js as E,
3103
+ Co as F,
3104
+ js as G,
3105
+ fi as H,
3106
+ bs as I,
3107
+ mr as J,
3108
+ Zs as K,
3109
+ ei as L,
3110
+ Vs as M,
3111
+ Zn as N,
3112
+ Hs as O,
3113
+ qs as P,
3114
+ gs as Q,
3115
+ Pe as R,
3116
+ Gs as S,
3117
+ ri as T,
3118
+ ni as U,
3119
+ Xo as V,
3120
+ to as W,
3121
+ Xn as X,
3122
+ ys as Y,
3123
+ xs as Z,
3124
+ Hn as _,
3125
+ Me as a,
3126
+ si as a0,
3127
+ ii as a1,
3128
+ Jo as a2,
3129
+ Ys as a3,
3130
+ Xs as a4,
3131
+ ti as a5,
3132
+ oi as a6,
3133
+ Ks as a7,
3134
+ di as a8,
3135
+ ci as a9,
3136
+ ui as aa,
3137
+ mi as ab,
3138
+ ke as ac,
3139
+ Ws as ad,
3140
+ Ee as b,
3141
+ Cr as c,
3142
+ eo as d,
3143
+ Us as e,
3144
+ mo as f,
3145
+ Os as g,
3146
+ uo as h,
3147
+ Yn as i,
3148
+ wr as j,
3149
+ Lo as k,
3150
+ Ro as l,
3151
+ Ko as m,
3152
+ Oo as n,
3153
+ vr as o,
3154
+ po as p,
3155
+ Do as q,
3156
+ _s as r,
3157
+ Po as s,
3158
+ Qn as t,
3159
+ Bs as u,
3160
+ ks as v,
3161
+ li as w,
3162
+ Zo as x,
3163
+ vs as y,
3164
+ hs as z
3165
+ };