@nika-js/onlymap 0.7.3 → 0.7.5

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