@nika-js/onlymap 0.4.2 → 0.4.4

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