@nika-js/onlymap 0.4.3 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +44 -11
  2. package/bin/onlymapjs.mjs +160 -11
  3. package/dist/{LercDecode.es-peqB7bxk.js → LercDecode.es-B49qauXg.js} +1 -1
  4. package/dist/{basemap-BeKuGQJs.js → basemap-nJ_ODY7r.js} +168 -163
  5. package/dist/basemap.d.ts +3 -1
  6. package/dist/elements/om-map.d.ts +68 -0
  7. package/dist/{index-BPKvpqIk.js → index-CeOjfL2p.js} +2 -2
  8. package/dist/{index-DzyVbu_T.js → index-DSkgI4Oc.js} +12996 -12463
  9. package/dist/{index-BKU3HvOO.js → index-DjlGZov2.js} +1 -1
  10. package/dist/{index-DVnTYF5u.js → index-o_yRv2lD.js} +1 -1
  11. package/dist/{index-Dg8SKcgV.js → index-uDJbHjA9.js} +1 -1
  12. package/dist/index.d.ts +4 -2
  13. package/dist/layer-registry.d.ts +8 -0
  14. package/dist/layout-audit.d.ts +53 -0
  15. package/dist/{lerc-DEpGyngt.js → lerc-CaQOmDCP.js} +2 -2
  16. package/dist/onlymap.standalone.js +22201 -21663
  17. package/dist/onlymapjs.js +78 -63
  18. package/dist/programmatic.d.ts +7 -1
  19. package/dist/{raster-CX7Y4jtJ.js → raster-DMq8FgiV.js} +2 -2
  20. package/dist/react/context.d.ts +9 -1
  21. package/dist/react/om-map.d.ts +3 -1
  22. package/dist/react/om-widget.d.ts +3 -1
  23. package/dist/react.js +336 -204
  24. package/dist/runtime-core.d.ts +20 -1
  25. package/dist/testing.d.ts +6 -0
  26. package/dist/version.d.ts +1 -1
  27. package/dist/widget-layout.d.ts +36 -0
  28. package/docs/basemaps.md +1 -1
  29. package/docs/react.md +2 -1
  30. package/docs/testing.md +13 -1
  31. package/llms.txt +2 -2
  32. package/onlymapjs.html-data.json +18 -0
  33. package/package.json +2 -2
  34. package/skills/onlymapjs/SKILL.md +3 -2
  35. package/skills/onlymapjs/references/react.md +2 -2
  36. package/skills/onlymapjs/references/syntax.md +4 -4
  37. package/skills/onlymapjs/references/testing.md +16 -0
package/dist/react.js CHANGED
@@ -1,144 +1,259 @@
1
- var Z = Object.defineProperty;
2
- var ee = (t, e, n) => e in t ? Z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var B = (t, e, n) => ee(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { jsxs as te, jsx as w } from "react/jsx-runtime";
5
- import { createContext as re, useContext as ne, forwardRef as se, useRef as m, useState as V, useCallback as oe, useMemo as x, useLayoutEffect as ie, useEffect as E, useImperativeHandle as ae, useSyncExternalStore as J } from "react";
6
- import { MANAGED_SLOTS as ce, slotContainerStyle as le, MapController as ue, parseWidgetStyle as de, resolveSlot as fe, isStoreToken as ye } from "@nika-js/onlymap";
7
- import { createPortal as Y } from "react-dom";
8
- const Q = re(null);
9
- function z(t) {
10
- const e = ne(Q);
11
- if (!e) throw new Error(`[onlymapjs] ${t} must be rendered inside <OmMap>.`);
12
- return e;
1
+ var Ee = Object.defineProperty;
2
+ var Re = (e, t, s) => t in e ? Ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var ne = (e, t, s) => Re(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { jsxs as J, jsx as E } from "react/jsx-runtime";
5
+ import { createContext as xe, useContext as Fe, forwardRef as Ce, useRef as h, useState as L, useId as le, useCallback as oe, useMemo as P, useLayoutEffect as se, useEffect as x, useImperativeHandle as Pe, useSyncExternalStore as ce } from "react";
6
+ import { MANAGED_SLOTS as Te, slotContainerStyle as ke, FOLD_SIDES as A, MapController as Me, parseWidgetStyle as Le, foldToggleSlot as $e, foldToggleStyle as je, foldPanelStyle as De, foldDrawerStyle as _e, resolveFoldBreakpointPx as Ae, shouldFoldAtWidth as Ie, DEFAULT_FOLD_BREAKPOINT_PX as ze, resolveSlot as Ke, foldSideForSlot as He, isStoreToken as Ne } from "@nika-js/onlymap";
7
+ import { createPortal as de } from "react-dom";
8
+ const ue = xe(null);
9
+ function W(e) {
10
+ const t = Fe(ue);
11
+ if (!t) throw new Error(`[onlymapjs] ${e} must be rendered inside <OmMap>.`);
12
+ return t;
13
13
  }
14
- function W(t, e) {
15
- if (t === e) return !0;
16
- const n = Object.keys(t ?? {}), r = Object.keys(e ?? {});
17
- return n.length !== r.length ? !1 : n.every((l) => t[l] === e[l]);
14
+ function U(e, t) {
15
+ if (e === t) return !0;
16
+ const s = Object.keys(e ?? {}), o = Object.keys(t ?? {});
17
+ return s.length !== o.length ? !1 : s.every((i) => e[i] === t[i]);
18
18
  }
19
- function me(t, e) {
20
- const { props: n, updateTriggers: r, ...l } = t, { props: d, updateTriggers: c, ...o } = e;
21
- return W(l, o) && W(n, d) && W(r, c);
19
+ function We(e, t) {
20
+ const { props: s, updateTriggers: o, ...i } = e, { props: b, updateTriggers: m, ...a } = t;
21
+ return U(i, a) && U(s, b) && U(o, m);
22
22
  }
23
- class ge {
24
- constructor(e) {
25
- B(this, "descriptors", /* @__PURE__ */ new Map());
26
- this.controller = e;
23
+ class qe {
24
+ constructor(t) {
25
+ ne(this, "descriptors", /* @__PURE__ */ new Map());
26
+ this.controller = t;
27
27
  }
28
- upsert(e) {
29
- const n = this.descriptors.get(e.id);
30
- n && me(n, e) || (this.descriptors.set(e.id, e), this.controller.setLayers([...this.descriptors.values()]));
28
+ upsert(t) {
29
+ const s = this.descriptors.get(t.id);
30
+ s && We(s, t) || (this.descriptors.set(t.id, t), this.controller.setLayers([...this.descriptors.values()]));
31
31
  }
32
- remove(e) {
33
- this.descriptors.delete(e) && this.controller.setLayers([...this.descriptors.values()]);
32
+ remove(t) {
33
+ this.descriptors.delete(t) && this.controller.setLayers([...this.descriptors.values()]);
34
34
  }
35
35
  }
36
- const $ = ce, he = Object.fromEntries($.map((t) => [t, le(t)]));
37
- function be(t, e) {
38
- return Object.entries(e).some(([n, r]) => r !== void 0 && t[n] !== r);
36
+ const N = Te, Ve = Object.fromEntries(N.map((e) => [e, ke(e)])), ie = { display: "flex", pointerEvents: "none", order: 2147483647 }, Be = Object.fromEntries(A.map((e) => [e, null]));
37
+ function Ye(e) {
38
+ const t = e.querySelector(
39
+ 'button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])'
40
+ );
41
+ t ? t.focus() : (e.tabIndex = -1, e.focus());
42
+ }
43
+ function Ge(e, t) {
44
+ return Object.entries(t).some(([s, o]) => o !== void 0 && e[s] !== o);
39
45
  }
40
- const Ce = se(function(e, n) {
41
- const { center: r, zoom: l, pitch: d, bearing: c, basemap: o, basemapKey: a, attribution: f, headless: u, widgetStyle: v, widgetsHidden: L, className: h, style: b, children: g } = e, p = m(null), [s, R] = V(null), [S, T] = V(null), [O, k] = V(
42
- () => Object.fromEntries($.map((i) => [i, null]))
43
- ), j = oe((i) => {
44
- T((y) => y === i ? y : i);
45
- }, []), P = x(
46
+ const rt = Ce(function(t, s) {
47
+ const { center: o, zoom: i, pitch: b, bearing: m, basemap: a, basemapKey: l, attribution: g, headless: d, widgetStyle: w, widgetsHidden: v, widgetsFold: p = !0, className: y, style: S, children: $ } = t, R = h(null), C = h(null), [c, T] = L(null), [F, D] = L(null), [j, I] = L(
48
+ () => Object.fromEntries(N.map((r) => [r, null]))
49
+ ), [k, fe] = L(!1), [X, me] = L(Be), [ge, be] = L(
50
+ () => Object.fromEntries(A.map((r) => [r, 0]))
51
+ ), [ye, q] = L(null), Q = `om-react-fold-${le().replaceAll(":", "")}`, pe = h(new Map(A.map((r) => [r, /* @__PURE__ */ new Set()]))), Z = d ? JSON.stringify(d) : "", z = h({
52
+ badge: null,
53
+ attribution: null
54
+ }), he = oe((r) => {
55
+ D((n) => n === r ? n : r);
56
+ }, []), ve = P(
46
57
  () => Object.fromEntries(
47
- $.map((i) => [
48
- i,
49
- (y) => {
50
- k((M) => M[i] === y ? M : { ...M, [i]: y });
58
+ N.map((r) => [
59
+ r,
60
+ (n) => {
61
+ I((u) => u[r] === n ? u : { ...u, [r]: n });
51
62
  }
52
63
  ])
53
64
  ),
54
65
  []
55
- ), _ = m({ center: r, zoom: l, pitch: d, bearing: c });
56
- _.current = { center: r, zoom: l, pitch: d, bearing: c };
57
- const F = m(e.onReady);
58
- F.current = e.onReady;
59
- const C = m(e.onViewStateChange);
60
- C.current = e.onViewStateChange;
61
- const K = m(e.onRuntimeError);
62
- K.current = e.onRuntimeError;
63
- const A = m(o);
64
- A.current = o;
65
- const D = m(void 0), U = u ? JSON.stringify(u) : "";
66
- ie(() => {
67
- if (!p.current) return;
68
- const i = _.current;
69
- D.current = A.current;
70
- const y = new ue(p.current, {
71
- center: i.center,
72
- zoom: i.zoom,
73
- pitch: i.pitch,
74
- bearing: i.bearing,
75
- basemap: A.current,
76
- basemapKey: a,
77
- attribution: f,
78
- headless: u ? u === !0 ? {} : u : void 0,
79
- onRuntimeError: (I) => {
80
- var q;
81
- return (q = K.current) == null ? void 0 : q.call(K, I);
66
+ ), Se = P(
67
+ () => Object.fromEntries(
68
+ A.map((r) => [
69
+ r,
70
+ (n) => {
71
+ me((u) => u[r] === n ? u : { ...u, [r]: n });
72
+ }
73
+ ])
74
+ ),
75
+ []
76
+ ), ee = oe((r, n, u) => {
77
+ const f = pe.current.get(r), O = f.size;
78
+ u ? f.add(n) : f.delete(n), f.size !== O && be((_) => ({ ..._, [r]: f.size }));
79
+ }, []);
80
+ se(() => {
81
+ const r = R.current;
82
+ if (!r) return;
83
+ let n, u = ze;
84
+ const f = (_) => {
85
+ const G = getComputedStyle(r).getPropertyValue("--om-widget-fold-breakpoint").trim();
86
+ G !== n && (n = G, u = Ae(G, r)), fe((we) => p && Ie(_, u, we));
87
+ };
88
+ if (f(r.getBoundingClientRect().width || (d ? d === !0 ? 800 : d.width ?? 800 : 0)), typeof ResizeObserver > "u") return;
89
+ const O = new ResizeObserver(([_]) => f(_.contentRect.width));
90
+ return O.observe(r), () => O.disconnect();
91
+ }, [p, Z]), x(() => {
92
+ (!k || v) && q(null);
93
+ }, [k, v]);
94
+ const te = h({ center: o, zoom: i, pitch: b, bearing: m });
95
+ te.current = { center: o, zoom: i, pitch: b, bearing: m };
96
+ const K = h(t.onReady);
97
+ K.current = t.onReady;
98
+ const M = h(t.onViewStateChange);
99
+ M.current = t.onViewStateChange;
100
+ const H = h(t.onRuntimeError);
101
+ H.current = t.onRuntimeError;
102
+ const V = h(a);
103
+ V.current = a;
104
+ const B = h(void 0);
105
+ se(() => {
106
+ if (!C.current) return;
107
+ const r = te.current;
108
+ B.current = V.current;
109
+ const n = new Me(C.current, {
110
+ center: r.center,
111
+ zoom: r.zoom,
112
+ pitch: r.pitch,
113
+ bearing: r.bearing,
114
+ basemap: V.current,
115
+ basemapKey: l,
116
+ attribution: g,
117
+ headless: d ? d === !0 ? {} : d : void 0,
118
+ chromeHosts: {
119
+ badge: z.current.badge ?? void 0,
120
+ attribution: z.current.attribution ?? void 0
121
+ },
122
+ onRuntimeError: (f) => {
123
+ var O;
124
+ return (O = H.current) == null ? void 0 : O.call(H, f);
82
125
  }
83
126
  });
84
- R(y);
85
- let M = !0;
86
- return y.ready.then(() => {
87
- var I;
88
- M && ((I = F.current) == null || I.call(F));
127
+ T(n);
128
+ let u = !0;
129
+ return n.ready.then(() => {
130
+ var f;
131
+ u && ((f = K.current) == null || f.call(K));
89
132
  }), () => {
90
- M = !1, R(null), y.destroy();
133
+ u = !1, T(null), n.destroy();
91
134
  };
92
- }, [U]), E(() => {
93
- !s || D.current === o || (D.current = o, s.setBasemap(o ?? null));
94
- }, [s, o]), ae(n, () => s, [s]), E(() => {
95
- if (!s) return;
96
- const i = { longitude: r == null ? void 0 : r[0], latitude: r == null ? void 0 : r[1], zoom: l, pitch: d, bearing: c };
97
- be(s.getViewState(), i) && s.setView(i);
98
- }, [s, r == null ? void 0 : r[0], r == null ? void 0 : r[1], l, d, c]), E(() => {
99
- var i;
100
- if (s)
101
- return (i = C.current) == null || i.call(C, s.getViewState()), s.getStore("viewport").subscribe(() => {
102
- var y;
103
- return (y = C.current) == null ? void 0 : y.call(C, s.getViewState());
135
+ }, [Z]), x(() => {
136
+ !c || B.current === a || (B.current = a, c.setBasemap(a ?? null));
137
+ }, [c, a]), Pe(s, () => c, [c]), x(() => {
138
+ if (!c) return;
139
+ const r = { longitude: o == null ? void 0 : o[0], latitude: o == null ? void 0 : o[1], zoom: i, pitch: b, bearing: m };
140
+ Ge(c.getViewState(), r) && c.setView(r);
141
+ }, [c, o == null ? void 0 : o[0], o == null ? void 0 : o[1], i, b, m]), x(() => {
142
+ var r;
143
+ if (c)
144
+ return (r = M.current) == null || r.call(M, c.getViewState()), c.getStore("viewport").subscribe(() => {
145
+ var n;
146
+ return (n = M.current) == null ? void 0 : n.call(M, c.getViewState());
104
147
  });
105
- }, [s]);
106
- const X = x(
148
+ }, [c]);
149
+ const Oe = P(
107
150
  () => ({
108
151
  position: "absolute",
109
152
  inset: 0,
110
153
  zIndex: 20,
111
154
  pointerEvents: "none",
112
155
  opacity: "var(--om-widget-opacity, 1)",
113
- ...L ? { visibility: "hidden" } : void 0,
114
- ...v ? de(v).properties : void 0
156
+ ...w ? Le(w).properties : void 0
115
157
  }),
116
- [v, L]
117
- ), N = x(() => s ? new ge(s) : null, [s]), H = x(
118
- () => s && N && S ? { controller: s, layers: N, overlayPane: S, corners: O } : null,
119
- [s, N, S, O]
158
+ [w]
159
+ ), Y = P(() => c ? new qe(c) : null, [c]), re = P(
160
+ () => c && Y && F ? { controller: c, layers: Y, overlayPane: F, corners: j, widgetsHidden: !!v, widgetsFolded: k, foldPanels: X, registerFoldedWidget: ee } : null,
161
+ [c, Y, F, j, v, k, X, ee]
120
162
  );
121
- return /* @__PURE__ */ te("div", { className: h, style: { position: "relative", overflow: "hidden", ...b }, children: [
122
- /* @__PURE__ */ w("div", { ref: p, style: { position: "absolute", inset: 0 } }),
123
- /* @__PURE__ */ w(
163
+ return /* @__PURE__ */ J("div", { ref: R, className: y, style: { position: "relative", overflow: "hidden", ...S }, children: [
164
+ /* @__PURE__ */ E("div", { ref: C, style: { position: "absolute", inset: 0 } }),
165
+ /* @__PURE__ */ E(
124
166
  "div",
125
167
  {
126
- ref: j,
168
+ ref: he,
127
169
  style: { position: "absolute", top: 0, left: 0, zIndex: 10, pointerEvents: "none" }
128
170
  }
129
171
  ),
130
- /* @__PURE__ */ w("div", { "data-om-widget-layer": "", style: X, children: $.map((i) => /* @__PURE__ */ w(
172
+ /* @__PURE__ */ E("div", { "data-om-widget-layer": "", style: Oe, children: N.map((r) => /* @__PURE__ */ J(
131
173
  "div",
132
174
  {
133
- "data-om-widget-slot": i,
134
- ref: P[i],
135
- style: he[i]
175
+ "data-om-widget-slot": r,
176
+ ref: ve[r],
177
+ style: {
178
+ ...Ve[r],
179
+ ...k && r === "bottom-end" ? { bottom: "calc(var(--om-widget-inset-y, 12px) + 28px)" } : void 0
180
+ },
181
+ children: [
182
+ k && A.filter((n) => $e(n) === r && ge[n] > 0).map((n) => {
183
+ const u = ye === n;
184
+ return /* @__PURE__ */ J(
185
+ "div",
186
+ {
187
+ "data-om-fold-drawer": n,
188
+ style: { ..._e(n), display: v ? "none" : "flex" },
189
+ onKeyDown: (f) => {
190
+ var O;
191
+ f.key !== "Escape" || !u || (q(null), (O = f.currentTarget.querySelector("[data-om-fold-toggle]")) == null || O.focus(), f.preventDefault(), f.stopPropagation());
192
+ },
193
+ children: [
194
+ /* @__PURE__ */ E(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ "data-om-fold-toggle": n,
199
+ "aria-expanded": u,
200
+ "aria-controls": `${Q}-${n}`,
201
+ "aria-label": `${u ? "Close" : "Open"} ${n} map controls`,
202
+ style: je(),
203
+ onClick: () => {
204
+ q(u ? null : n), u || requestAnimationFrame(() => {
205
+ var O;
206
+ const f = (O = R.current) == null ? void 0 : O.querySelector(`[data-om-fold-panel="${n}"]`);
207
+ f && Ye(f);
208
+ });
209
+ },
210
+ children: "⋯"
211
+ }
212
+ ),
213
+ /* @__PURE__ */ E(
214
+ "div",
215
+ {
216
+ id: `${Q}-${n}`,
217
+ ref: Se[n],
218
+ "data-om-fold-panel": n,
219
+ role: "region",
220
+ "aria-label": `${n} map controls`,
221
+ hidden: !u,
222
+ style: { ...De(n), display: u ? "flex" : "none" }
223
+ }
224
+ )
225
+ ]
226
+ },
227
+ `fold-${n}`
228
+ );
229
+ }),
230
+ r === "bottom-start" && /* @__PURE__ */ E(
231
+ "div",
232
+ {
233
+ "data-om-mandated-chrome": "badge",
234
+ ref: (n) => {
235
+ z.current.badge = n;
236
+ },
237
+ style: ie
238
+ }
239
+ ),
240
+ r === "bottom-end" && /* @__PURE__ */ E(
241
+ "div",
242
+ {
243
+ "data-om-mandated-chrome": "attribution",
244
+ ref: (n) => {
245
+ z.current.attribution = n;
246
+ },
247
+ style: ie
248
+ }
249
+ )
250
+ ]
136
251
  },
137
- i
252
+ r
138
253
  )) }),
139
- H && /* @__PURE__ */ w(Q.Provider, { value: H, children: g })
254
+ re && /* @__PURE__ */ E(ue.Provider, { value: re, children: $ })
140
255
  ] });
141
- }), ve = /* @__PURE__ */ new Set([
256
+ }), Je = /* @__PURE__ */ new Set([
142
257
  "id",
143
258
  "type",
144
259
  "data",
@@ -158,61 +273,78 @@ const Ce = se(function(e, n) {
158
273
  "onClick",
159
274
  "onHover"
160
275
  ]);
161
- function xe(t) {
162
- const { controller: e, layers: n } = z("OmLayer"), { id: r } = t, l = {};
163
- for (const [a, f] of Object.entries(t))
164
- !ve.has(a) && f !== void 0 && (l[a] = f);
165
- const d = {
166
- id: r,
167
- type: t.type,
168
- data: t.data,
169
- label: t.label,
170
- color: t.color,
171
- filterField: t.filterField,
172
- filterRange: t.filterRange,
173
- filterSoftRange: t.filterSoftRange,
174
- filterCategoryField: t.filterCategoryField,
175
- filterCategories: t.filterCategories,
176
- source: t.source,
177
- key: t.streamKey,
178
- flush: t.flush,
179
- refresh: t.refresh,
180
- terrain: t.terrain,
181
- updateTriggers: t.updateTriggers,
182
- props: l
276
+ function nt(e) {
277
+ const { controller: t, layers: s } = W("OmLayer"), { id: o } = e, i = {};
278
+ for (const [l, g] of Object.entries(e))
279
+ !Je.has(l) && g !== void 0 && (i[l] = g);
280
+ const b = {
281
+ id: o,
282
+ type: e.type,
283
+ data: e.data,
284
+ label: e.label,
285
+ color: e.color,
286
+ filterField: e.filterField,
287
+ filterRange: e.filterRange,
288
+ filterSoftRange: e.filterSoftRange,
289
+ filterCategoryField: e.filterCategoryField,
290
+ filterCategories: e.filterCategories,
291
+ source: e.source,
292
+ key: e.streamKey,
293
+ flush: e.flush,
294
+ refresh: e.refresh,
295
+ terrain: e.terrain,
296
+ updateTriggers: e.updateTriggers,
297
+ props: i
183
298
  };
184
- E(() => {
185
- n.upsert(d);
186
- }), E(() => () => n.remove(r), [n, r]);
187
- const c = m(t.onClick);
188
- c.current = t.onClick;
189
- const o = m(t.onHover);
190
- return o.current = t.onHover, E(
191
- () => e.watchPicks((a) => {
192
- var f, u, v;
193
- if (a === null) {
194
- (f = o.current) == null || f.call(o, null);
299
+ x(() => {
300
+ s.upsert(b);
301
+ }), x(() => () => s.remove(o), [s, o]);
302
+ const m = h(e.onClick);
303
+ m.current = e.onClick;
304
+ const a = h(e.onHover);
305
+ return a.current = e.onHover, x(
306
+ () => t.watchPicks((l) => {
307
+ var g, d, w;
308
+ if (l === null) {
309
+ (g = a.current) == null || g.call(a, null);
195
310
  return;
196
311
  }
197
- a.layerId === r && (a.type === "click" ? (u = c.current) == null || u.call(c, a) : (v = o.current) == null || v.call(o, a));
312
+ l.layerId === o && (l.type === "click" ? (d = m.current) == null || d.call(m, l) : (w = a.current) == null || w.call(a, l));
198
313
  }),
199
- [e, r]
314
+ [t, o]
200
315
  ), null;
201
316
  }
202
- function Te({ position: t = "top-start", order: e, className: n, style: r, children: l }) {
203
- const { corners: d } = z("OmWidget"), c = fe(t) ?? "top-start";
204
- if (c === "manual")
205
- return /* @__PURE__ */ w("div", { className: n, style: { pointerEvents: "auto", ...r }, children: l });
206
- const o = d[c];
207
- return o ? Y(
208
- /* @__PURE__ */ w("div", { className: n, style: { pointerEvents: "auto", ...e !== void 0 ? { order: e } : void 0, ...r }, children: l }),
209
- o
317
+ function ot({ position: e = "top-start", order: t, fold: s, className: o, style: i, children: b }) {
318
+ const { corners: m, widgetsHidden: a, widgetsFolded: l, foldPanels: g, registerFoldedWidget: d } = W("OmWidget"), w = le(), v = Ke(e) ?? "top-start", p = l && v !== "manual" && s !== "never", y = v === "manual" ? null : He(v);
319
+ if (x(() => {
320
+ if (y)
321
+ return d(y, w, p), () => d(y, w, !1);
322
+ }, [y, w, p, d]), v === "manual")
323
+ return /* @__PURE__ */ E("div", { className: o, style: { pointerEvents: "auto", ...i }, children: b });
324
+ const S = p && y ? g[y] : m[v];
325
+ return S ? de(
326
+ /* @__PURE__ */ E(
327
+ "div",
328
+ {
329
+ "data-om-react-widget": "",
330
+ "data-om-fold-origin-slot": p ? v : void 0,
331
+ className: o,
332
+ style: {
333
+ ...t !== void 0 ? { order: t } : void 0,
334
+ ...i,
335
+ pointerEvents: a ? "none" : (i == null ? void 0 : i.pointerEvents) ?? "auto",
336
+ visibility: a ? "hidden" : i == null ? void 0 : i.visibility
337
+ },
338
+ children: b
339
+ }
340
+ ),
341
+ S
210
342
  ) : null;
211
343
  }
212
- function G(t, e) {
213
- return !e || (t == null ? void 0 : t.layerId) === e;
344
+ function ae(e, t) {
345
+ return !t || (e == null ? void 0 : e.layerId) === t;
214
346
  }
215
- const pe = {
347
+ const Ue = {
216
348
  "top-left": "translate(0, 0)",
217
349
  "top-center": "translate(-50%, 0)",
218
350
  "top-right": "translate(-100%, 0)",
@@ -223,52 +355,52 @@ const pe = {
223
355
  "bottom-center": "translate(-50%, -100%)",
224
356
  "bottom-right": "translate(-100%, -100%)"
225
357
  };
226
- function Me(t) {
227
- const { controller: e, overlayPane: n } = z("OmOverlay"), r = m(null), l = m(void 0), d = m(t);
228
- d.current = t;
229
- const c = x(() => {
230
- const h = e.getStore("selection");
231
- let b, g, p = null;
358
+ function st(e) {
359
+ const { controller: t, overlayPane: s } = W("OmOverlay"), o = h(null), i = h(void 0), b = h(e);
360
+ b.current = e;
361
+ const m = P(() => {
362
+ const p = t.getStore("selection");
363
+ let y, S, $ = null;
232
364
  return {
233
- subscribe: h.subscribe,
365
+ subscribe: p.subscribe,
234
366
  getSnapshot: () => {
235
- const s = h.getSnapshot(), { anchorFrom: R, layer: S } = d.current, T = `${R ?? ""}|${S ?? ""}`;
236
- return (s !== b || T !== g) && (b = s, g = T, R === "selection" && G(s, S) && (p = s)), p;
367
+ const R = p.getSnapshot(), { anchorFrom: C, layer: c } = b.current, T = `${C ?? ""}|${c ?? ""}`;
368
+ return (R !== y || T !== S) && (y = R, S = T, C === "selection" && ae(R, c) && ($ = R)), $;
237
369
  }
238
370
  };
239
- }, [e]), o = J(
240
- c.subscribe,
241
- c.getSnapshot,
242
- c.getSnapshot
371
+ }, [t]), a = ce(
372
+ m.subscribe,
373
+ m.getSnapshot,
374
+ m.getSnapshot
243
375
  );
244
- E(
245
- () => e.registerOverlay((h, b) => {
246
- const g = r.current;
247
- if (!g) return;
248
- const { anchor: p, anchorFrom: s, layer: R, visible: S = !0, anchorOffset: T } = d.current;
249
- let O;
250
- if (s === "selection" ? (G(b, R) && (l.current = (b == null ? void 0 : b.coordinate) ?? void 0), O = l.current) : O = p, !S || !O || !h) {
251
- g.style.visibility = "hidden";
376
+ x(
377
+ () => t.registerOverlay((p, y) => {
378
+ const S = o.current;
379
+ if (!S) return;
380
+ const { anchor: $, anchorFrom: R, layer: C, visible: c = !0, anchorOffset: T } = b.current;
381
+ let F;
382
+ if (R === "selection" ? (ae(y, C) && (i.current = (y == null ? void 0 : y.coordinate) ?? void 0), F = i.current) : F = $, !c || !F || !p) {
383
+ S.style.visibility = "hidden";
252
384
  return;
253
385
  }
254
- const [k, j, P] = h.project([O[0], O[1], 0]);
255
- if (!(k >= 0 && k <= h.width && j >= 0 && j <= h.height) || P !== void 0 && P < 0) {
256
- g.style.visibility = "hidden";
386
+ const [D, j, I] = p.project([F[0], F[1], 0]);
387
+ if (!(D >= 0 && D <= p.width && j >= 0 && j <= p.height) || I !== void 0 && I < 0) {
388
+ S.style.visibility = "hidden";
257
389
  return;
258
390
  }
259
- g.style.visibility = "visible", g.style.transform = `translate(${k}px, ${j}px) ${pe[T ?? "bottom-center"]}`;
391
+ S.style.visibility = "visible", S.style.transform = `translate(${D}px, ${j}px) ${Ue[T ?? "bottom-center"]}`;
260
392
  }),
261
- [e]
262
- ), E(() => {
263
- e.refreshOverlays();
393
+ [t]
394
+ ), x(() => {
395
+ t.refreshOverlays();
264
396
  });
265
- const { children: a, className: f, style: u, interactive: v = !0 } = t, L = typeof a == "function" ? a(o) : a;
266
- return Y(
267
- /* @__PURE__ */ w(
397
+ const { children: l, className: g, style: d, interactive: w = !0 } = e, v = typeof l == "function" ? l(a) : l;
398
+ return de(
399
+ /* @__PURE__ */ E(
268
400
  "div",
269
401
  {
270
- ref: r,
271
- className: f,
402
+ ref: o,
403
+ className: g,
272
404
  style: {
273
405
  position: "absolute",
274
406
  top: 0,
@@ -276,38 +408,38 @@ function Me(t) {
276
408
  visibility: "hidden",
277
409
  // hidden until the first flush positions it — never flashes at the origin
278
410
  willChange: "transform",
279
- pointerEvents: v ? "auto" : "none",
280
- ...u
411
+ pointerEvents: w ? "auto" : "none",
412
+ ...d
281
413
  },
282
- children: L
414
+ children: v
283
415
  }
284
416
  ),
285
- n
417
+ s
286
418
  );
287
419
  }
288
- function ke(t = []) {
289
- const { controller: e } = z("useOmMap"), n = t.join(" "), r = x(() => {
290
- const c = (n ? n.split(" ") : []).flatMap((a) => ye(a) ? [e.getStore(a)] : (console.warn(`[onlymapjs] useOmMap: "${a}" is not a watch token on the React front-end — expected viewport, selection, layers, or data:<layerId>.`), []));
291
- let o;
420
+ function it(e = []) {
421
+ const { controller: t } = W("useOmMap"), s = e.join(" "), o = P(() => {
422
+ const m = (s ? s.split(" ") : []).flatMap((l) => Ne(l) ? [t.getStore(l)] : (console.warn(`[onlymapjs] useOmMap: "${l}" is not a watch token on the React front-end — expected viewport, selection, layers, or data:<layerId>.`), []));
423
+ let a;
292
424
  return {
293
- subscribe: (a) => {
294
- const f = c.map((u) => u.subscribe(a));
425
+ subscribe: (l) => {
426
+ const g = m.map((d) => d.subscribe(l));
295
427
  return () => {
296
- for (const u of f) u();
428
+ for (const d of g) d();
297
429
  };
298
430
  },
299
431
  getSnapshot: () => {
300
- const a = c.map((f) => f.getSnapshot());
301
- return (!o || a.some((f, u) => f !== o[u])) && (o = a), o;
432
+ const l = m.map((g) => g.getSnapshot());
433
+ return (!a || l.some((g, d) => g !== a[d])) && (a = l), a;
302
434
  }
303
435
  };
304
- }, [e, n]), l = J(r.subscribe, r.getSnapshot, r.getSnapshot);
305
- return x(() => e.buildCtx(), [e, l]);
436
+ }, [t, s]), i = ce(o.subscribe, o.getSnapshot, o.getSnapshot);
437
+ return P(() => t.buildCtx(), [t, i]);
306
438
  }
307
439
  export {
308
- xe as OmLayer,
309
- Ce as OmMap,
310
- Me as OmOverlay,
311
- Te as OmWidget,
312
- ke as useOmMap
440
+ nt as OmLayer,
441
+ rt as OmMap,
442
+ st as OmOverlay,
443
+ ot as OmWidget,
444
+ it as useOmMap
313
445
  };