react-panel-layout 0.4.1 → 0.4.2

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 (52) hide show
  1. package/README.md +291 -0
  2. package/dist/FloatingPanelFrame-SOrLGjZd.js +67 -0
  3. package/dist/FloatingPanelFrame-SOrLGjZd.js.map +1 -0
  4. package/dist/FloatingPanelFrame-XtBcHANI.cjs +2 -0
  5. package/dist/FloatingPanelFrame-XtBcHANI.cjs.map +1 -0
  6. package/dist/{GridLayout-DZCV1X-3.js → GridLayout-CLvW8jID.js} +516 -502
  7. package/dist/GridLayout-CLvW8jID.js.map +1 -0
  8. package/dist/GridLayout-qufTyOQM.cjs +2 -0
  9. package/dist/GridLayout-qufTyOQM.cjs.map +1 -0
  10. package/dist/components/pivot/PivotLayer.d.ts +14 -0
  11. package/dist/config/PanelContentDeclaration.d.ts +20 -0
  12. package/dist/config/panelRouter.d.ts +3 -1
  13. package/dist/config.cjs +1 -1
  14. package/dist/config.cjs.map +1 -1
  15. package/dist/config.js +125 -76
  16. package/dist/config.js.map +1 -1
  17. package/dist/constants/styles.d.ts +8 -0
  18. package/dist/floating.cjs +1 -1
  19. package/dist/floating.js +1 -1
  20. package/dist/index.cjs +2 -2
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.js +573 -500
  23. package/dist/index.js.map +1 -1
  24. package/dist/modules/panels/rendering/ContentRegistry.d.ts +50 -0
  25. package/dist/modules/panels/rendering/RenderContext.d.ts +1 -0
  26. package/dist/modules/panels/state/types.d.ts +2 -2
  27. package/dist/modules/pivot/PivotContent.d.ts +29 -0
  28. package/dist/modules/pivot/index.d.ts +5 -0
  29. package/dist/modules/pivot/types.d.ts +62 -0
  30. package/dist/modules/pivot/usePivot.d.ts +28 -0
  31. package/dist/pivot/index.d.ts +8 -0
  32. package/dist/pivot.cjs +2 -0
  33. package/dist/pivot.cjs.map +1 -0
  34. package/dist/pivot.js +5 -0
  35. package/dist/pivot.js.map +1 -0
  36. package/dist/styles-DcG3aIFx.cjs +2 -0
  37. package/dist/styles-DcG3aIFx.cjs.map +1 -0
  38. package/dist/styles-w0ZixggV.js +51 -0
  39. package/dist/styles-w0ZixggV.js.map +1 -0
  40. package/dist/types.d.ts +27 -0
  41. package/dist/usePivot-C8q0pMgW.cjs +2 -0
  42. package/dist/usePivot-C8q0pMgW.cjs.map +1 -0
  43. package/dist/usePivot-z9gumDf-.js +97 -0
  44. package/dist/usePivot-z9gumDf-.js.map +1 -0
  45. package/package.json +6 -1
  46. package/dist/FloatingPanelFrame-BeP9z8EI.js +0 -98
  47. package/dist/FloatingPanelFrame-BeP9z8EI.js.map +0 -1
  48. package/dist/FloatingPanelFrame-Cu50Y9xg.cjs +0 -2
  49. package/dist/FloatingPanelFrame-Cu50Y9xg.cjs.map +0 -1
  50. package/dist/GridLayout-CwuQEP7k.cjs +0 -2
  51. package/dist/GridLayout-CwuQEP7k.cjs.map +0 -1
  52. package/dist/GridLayout-DZCV1X-3.js.map +0 -1
@@ -1,8 +1,10 @@
1
- import { jsxs as $, Fragment as G, jsx as m } from "react/jsx-runtime";
1
+ import { jsxs as G, Fragment as N, jsx as h } from "react/jsx-runtime";
2
2
  import * as i from "react";
3
- import { C as xt, D as At, f as Ht, F as Nt, e as _t, g as $t, a as Gt, h as Ft, i as Ot, j as Wt, b as Bt, k as Yt, G as B, l as M, m as Xt, n as Vt, o as Ut, R as ct, p as jt, q as J } from "./FloatingPanelFrame-BeP9z8EI.js";
4
- import { createPortal as Zt } from "react-dom";
5
- const Kt = () => {
3
+ import { F as _t, e as $t, a as Gt, b as Ft } from "./FloatingPanelFrame-SOrLGjZd.js";
4
+ import { C as Ot, D as Wt, m as Bt, n as Yt, o as Xt, p as Vt, q as Ut, r as jt, G as B, s as D, t as Zt, u as Kt, v as qt, R as ct, w as Jt, x as J } from "./styles-w0ZixggV.js";
5
+ import { createPortal as Qt } from "react-dom";
6
+ import { u as te, a as Rt } from "./usePivot-z9gumDf-.js";
7
+ const ee = () => {
6
8
  const t = /* @__PURE__ */ new Map();
7
9
  return (e) => {
8
10
  if (!e)
@@ -10,24 +12,24 @@ const Kt = () => {
10
12
  const n = t.get(e);
11
13
  if (n !== void 0)
12
14
  return n;
13
- const o = t.size;
14
- return t.set(e, o), o;
15
+ const r = t.size;
16
+ return t.set(e, r), r;
15
17
  };
16
- }, qt = Kt(), Q = /* @__PURE__ */ new Map(), Jt = (t) => {
17
- const e = `ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${qt(t.root)}`;
18
+ }, ne = ee(), Q = /* @__PURE__ */ new Map(), re = (t) => {
19
+ const e = `ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${ne(t.root)}`;
18
20
  if (Q.has(e))
19
21
  return Q.get(e);
20
22
  const n = new class {
21
23
  #t = /* @__PURE__ */ new Map();
22
- #e = new IntersectionObserver((o) => {
23
- o.forEach((r) => {
24
- const s = this.#t.get(r.target);
25
- s && s(r);
24
+ #e = new IntersectionObserver((r) => {
25
+ r.forEach((o) => {
26
+ const s = this.#t.get(o.target);
27
+ s && s(o);
26
28
  });
27
29
  }, t);
28
- observe(o, r) {
29
- return this.#t.set(o, r), this.#e.observe(o), () => {
30
- this.#t.delete(o), this.#e.unobserve(o);
30
+ observe(r, o) {
31
+ return this.#t.set(r, o), this.#e.observe(r), () => {
32
+ this.#t.delete(r), this.#e.unobserve(r);
31
33
  };
32
34
  }
33
35
  }();
@@ -42,14 +44,14 @@ const Kt = () => {
42
44
  bottom: 0,
43
45
  left: 0
44
46
  });
45
- function Qt(t, { threshold: e = 0, rootMargin: n = "0px", root: o = null }) {
46
- const [r, s] = i.useState(null);
47
+ function oe(t, { threshold: e = 0, rootMargin: n = "0px", root: r = null }) {
48
+ const [o, s] = i.useState(null);
47
49
  return i.useEffect(() => {
48
50
  const c = t.current;
49
- return c ? Jt({
51
+ return c ? re({
50
52
  threshold: e,
51
53
  rootMargin: n,
52
- root: o
54
+ root: r
53
55
  }).observe(c, (a) => {
54
56
  s({
55
57
  isIntersecting: a.isIntersecting,
@@ -61,21 +63,21 @@ function Qt(t, { threshold: e = 0, rootMargin: n = "0px", root: o = null }) {
61
63
  time: a.time
62
64
  });
63
65
  }) : void 0;
64
- }, [t, e, n, o]), i.useMemo(() => ({
65
- isIntersecting: r?.isIntersecting ?? !1,
66
- boundingClientRect: r?.boundingClientRect ?? ut,
67
- intersectionRatio: r?.intersectionRatio ?? 0,
68
- intersectionRect: r?.intersectionRect ?? ut,
69
- rootBounds: r?.rootBounds ?? null,
70
- target: r?.target ?? t.current,
71
- time: r?.time ?? 0
72
- }), [r, t]);
66
+ }, [t, e, n, r]), i.useMemo(() => ({
67
+ isIntersecting: o?.isIntersecting ?? !1,
68
+ boundingClientRect: o?.boundingClientRect ?? ut,
69
+ intersectionRatio: o?.intersectionRatio ?? 0,
70
+ intersectionRect: o?.intersectionRect ?? ut,
71
+ rootBounds: o?.rootBounds ?? null,
72
+ target: o?.target ?? t.current,
73
+ time: o?.time ?? 0
74
+ }), [o, t]);
73
75
  }
74
76
  const lt = {
75
77
  position: "fixed",
76
78
  inset: 0,
77
- background: xt
78
- }, te = {
79
+ background: Ot
80
+ }, se = {
79
81
  willChange: "transform"
80
82
  }, dt = {
81
83
  left: {
@@ -102,41 +104,41 @@ const lt = {
102
104
  right: 0,
103
105
  transform: "translateY(100%)"
104
106
  }
105
- }, ee = (t, e, n) => t === "none" ? void 0 : `transform ${e ?? At} ${n ?? Ht}`, ne = (t, e) => t ? e : !1, re = {
107
+ }, ie = (t, e, n) => t === "none" ? void 0 : `transform ${e ?? Wt} ${n ?? Bt}`, ae = (t, e) => t ? e : !1, ce = {
106
108
  marginLeft: "auto",
107
109
  border: "none",
108
110
  background: "transparent",
109
111
  cursor: "pointer",
110
- fontSize: Yt
111
- }, oe = ({ header: t, dismissible: e, onClose: n }) => {
112
+ fontSize: jt
113
+ }, ue = ({ header: t, dismissible: e, onClose: n }) => {
112
114
  if (!t)
113
115
  return null;
114
- const o = t.showCloseButton ?? !0, r = ne(e, o);
115
- return /* @__PURE__ */ m(i.Activity, { mode: t ? "visible" : "hidden", children: /* @__PURE__ */ $(
116
+ const r = t.showCloseButton ?? !0, o = ae(e, r);
117
+ return /* @__PURE__ */ h(i.Activity, { mode: t ? "visible" : "hidden", children: /* @__PURE__ */ G(
116
118
  Gt,
117
119
  {
118
- style: { padding: `${Ot} ${Wt}`, gap: Ft },
120
+ style: { padding: `${Vt} ${Ut}`, gap: Xt },
119
121
  children: [
120
- /* @__PURE__ */ m(i.Activity, { mode: t ? "visible" : "hidden", children: /* @__PURE__ */ m(Bt, { children: t.title }) }),
121
- /* @__PURE__ */ m(i.Activity, { mode: r ? "visible" : "hidden", children: /* @__PURE__ */ m("button", { style: re, onClick: n, "aria-label": "Close drawer", type: "button", children: "×" }) })
122
+ /* @__PURE__ */ h(i.Activity, { mode: t ? "visible" : "hidden", children: /* @__PURE__ */ h(Ft, { children: t.title }) }),
123
+ /* @__PURE__ */ h(i.Activity, { mode: o ? "visible" : "hidden", children: /* @__PURE__ */ h("button", { style: ce, onClick: n, "aria-label": "Close drawer", type: "button", children: "×" }) })
122
124
  ]
123
125
  }
124
126
  ) });
125
- }, se = ({ header: t, dismissible: e, onClose: n, chrome: o, children: r }) => o ? /* @__PURE__ */ $(Nt, { style: { height: "100%", borderRadius: 0 }, children: [
126
- /* @__PURE__ */ m(oe, { header: t, dismissible: e, onClose: n }),
127
- /* @__PURE__ */ m(
128
- _t,
127
+ }, le = ({ header: t, dismissible: e, onClose: n, chrome: r, children: o }) => r ? /* @__PURE__ */ G(_t, { style: { height: "100%", borderRadius: 0 }, children: [
128
+ /* @__PURE__ */ h(ue, { header: t, dismissible: e, onClose: n }),
129
+ /* @__PURE__ */ h(
130
+ $t,
129
131
  {
130
- style: { padding: $t, flex: 1, display: "flex", flexDirection: "column" },
131
- children: r
132
+ style: { padding: Yt, flex: 1, display: "flex", flexDirection: "column" },
133
+ children: o
132
134
  }
133
135
  )
134
- ] }) : /* @__PURE__ */ m(G, { children: r }), ie = ({
136
+ ] }) : /* @__PURE__ */ h(N, { children: o }), de = ({
135
137
  id: t,
136
138
  config: e,
137
139
  isOpen: n,
138
- onClose: o,
139
- children: r,
140
+ onClose: r,
141
+ children: o,
140
142
  zIndex: s,
141
143
  width: c,
142
144
  height: u,
@@ -144,28 +146,28 @@ const lt = {
144
146
  }) => {
145
147
  const {
146
148
  dismissible: d = !0,
147
- header: p,
149
+ header: g,
148
150
  chrome: f = !0,
149
- inline: h = !1,
151
+ inline: m = !1,
150
152
  transitionMode: w = "css",
151
153
  transitionDuration: E,
152
154
  transitionEasing: z
153
- } = e, D = i.useCallback((y) => y ? y.left !== void 0 ? "left" : y.right !== void 0 ? "right" : y.top !== void 0 ? "top" : y.bottom !== void 0 ? "bottom" : "right" : "right", [])(a), F = {
155
+ } = e, L = i.useCallback((y) => y ? y.left !== void 0 ? "left" : y.right !== void 0 ? "right" : y.top !== void 0 ? "top" : y.bottom !== void 0 ? "bottom" : "right" : "right", [])(a), F = {
154
156
  left: "translateX(0)",
155
157
  right: "translateX(0)",
156
158
  top: "translateY(0)",
157
159
  bottom: "translateY(0)"
158
160
  }, T = i.useMemo(() => {
159
- const y = ee(w, E, z), I = {
160
- ...te,
161
- ...h ? { position: "absolute" } : { position: "fixed" },
162
- ...dt[D],
163
- transform: n ? F[D] : dt[D].transform,
161
+ const y = ie(w, E, z), I = {
162
+ ...se,
163
+ ...m ? { position: "absolute" } : { position: "fixed" },
164
+ ...dt[L],
165
+ transform: n ? F[L] : dt[L].transform,
164
166
  transition: y
165
167
  };
166
168
  return s !== void 0 && (I.zIndex = s), c !== void 0 && (I.width = typeof c == "number" ? `${c}px` : c), u !== void 0 && (I.height = typeof u == "number" ? `${u}px` : u), I;
167
- }, [u, h, n, D, E, z, w, c, s]), L = p?.title ?? e.ariaLabel ?? "Drawer", x = i.useMemo(() => {
168
- const y = h ? { ...lt, position: "absolute" } : lt, I = w === "none" ? void 0 : `opacity ${E ?? "220ms"} ease`;
169
+ }, [u, m, n, L, E, z, w, c, s]), M = g?.title ?? e.ariaLabel ?? "Drawer", k = i.useMemo(() => {
170
+ const y = m ? { ...lt, position: "absolute" } : lt, I = w === "none" ? void 0 : `opacity ${E ?? "220ms"} ease`;
169
171
  return {
170
172
  ...y,
171
173
  opacity: n ? 1 : 0,
@@ -173,139 +175,139 @@ const lt = {
173
175
  transition: I,
174
176
  zIndex: s !== void 0 ? s - 1 : void 0
175
177
  };
176
- }, [h, n, E, w, s]);
177
- return /* @__PURE__ */ $(G, { children: [
178
- /* @__PURE__ */ m("div", { style: x, onClick: d ? o : void 0 }),
179
- /* @__PURE__ */ m(
178
+ }, [m, n, E, w, s]);
179
+ return /* @__PURE__ */ G(N, { children: [
180
+ /* @__PURE__ */ h("div", { style: k, onClick: d ? r : void 0 }),
181
+ /* @__PURE__ */ h(
180
182
  "div",
181
183
  {
182
184
  "data-layer-id": t,
183
- "data-placement": D,
185
+ "data-placement": L,
184
186
  style: T,
185
187
  role: "dialog",
186
188
  "aria-modal": d ? !0 : void 0,
187
189
  "aria-hidden": n ? void 0 : !0,
188
- "aria-label": L,
189
- children: /* @__PURE__ */ m(se, { header: p, dismissible: d, onClose: o, chrome: f, children: r })
190
+ "aria-label": M,
191
+ children: /* @__PURE__ */ h(le, { header: g, dismissible: d, onClose: r, chrome: f, children: o })
190
192
  }
191
193
  )
192
194
  ] });
193
- }, ae = (t, e) => new Promise((n) => {
194
- let o = !1;
195
- const r = () => {
196
- o || (o = !0, t.removeEventListener("transitionend", s), n());
195
+ }, fe = (t, e) => new Promise((n) => {
196
+ let r = !1;
197
+ const o = () => {
198
+ r || (r = !0, t.removeEventListener("transitionend", s), n());
197
199
  }, s = (c) => {
198
- c.target === t && r();
200
+ c.target === t && o();
199
201
  };
200
- t.addEventListener("transitionend", s), setTimeout(r, e + 50);
201
- }), Rt = async (t, e, n, o) => {
202
+ t.addEventListener("transitionend", s), setTimeout(o, e + 50);
203
+ }), Pt = async (t, e, n, r) => {
202
204
  switch (e) {
203
205
  case "none":
204
206
  t();
205
207
  return;
206
208
  case "css":
207
- t(), n && await ae(n, o);
209
+ t(), n && await fe(n, r);
208
210
  return;
209
211
  }
210
- }, Dn = (t) => {
211
- const [e, n] = i.useState({}), o = i.useRef(t);
212
- o.current = t;
213
- const r = i.useCallback(
214
- async (a, d, p) => {
215
- const { mode: f = "none", element: h, duration: w = 300 } = p ?? {};
216
- await Rt(() => {
212
+ }, kn = (t) => {
213
+ const [e, n] = i.useState({}), r = i.useRef(t);
214
+ r.current = t;
215
+ const o = i.useCallback(
216
+ async (a, d, g) => {
217
+ const { mode: f = "none", element: m, duration: w = 300 } = g ?? {};
218
+ await Pt(() => {
217
219
  n((P) => P[a] === d ? P : { ...P, [a]: d });
218
- }, f, h?.current, w);
219
- const z = o.current;
220
+ }, f, m?.current, w);
221
+ const z = r.current;
220
222
  d ? z?.onOpen?.(a) : z?.onClose?.(a), z?.onTransitionEnd?.(a, d);
221
223
  },
222
224
  []
223
225
  ), s = i.useCallback((a) => e[a] ?? !1, [e]), c = i.useCallback(
224
- (a, d) => r(a, !0, d),
225
- [r]
226
+ (a, d) => o(a, !0, d),
227
+ [o]
226
228
  ), u = i.useCallback(
227
- (a, d) => r(a, !1, d),
228
- [r]
229
+ (a, d) => o(a, !1, d),
230
+ [o]
229
231
  );
230
232
  return { state: s, open: c, close: u };
231
- }, ce = (t) => {
233
+ }, pe = (t) => {
232
234
  if (!t)
233
235
  return 300;
234
236
  const e = t.match(/(\d+)/);
235
237
  return e ? parseInt(e[1], 10) : 300;
236
- }, ue = (t) => {
238
+ }, ge = (t) => {
237
239
  const [e, n] = i.useState(() => {
238
240
  const a = {};
239
241
  return t.forEach((d) => {
240
242
  d.drawer && (a[d.id] = d.drawer.defaultOpen ?? !1);
241
243
  }), a;
242
- }), o = i.useMemo(() => {
244
+ }), r = i.useMemo(() => {
243
245
  const a = /* @__PURE__ */ new Map();
244
246
  return t.forEach((d) => a.set(d.id, d)), a;
245
- }, [t]), r = i.useCallback(
246
- async (a, d, p) => {
247
- const f = o.get(a);
247
+ }, [t]), o = i.useCallback(
248
+ async (a, d, g) => {
249
+ const f = r.get(a);
248
250
  if (!f?.drawer)
249
251
  return;
250
- const h = p?.mode ?? f.drawer.transitionMode ?? "css", w = p?.duration ?? ce(f.drawer.transitionDuration), E = p?.element?.current;
251
- await Rt(() => {
252
+ const m = g?.mode ?? f.drawer.transitionMode ?? "css", w = g?.duration ?? pe(f.drawer.transitionDuration), E = g?.element?.current;
253
+ await Pt(() => {
252
254
  f.drawer?.open === void 0 && n((P) => P[a] === d ? P : { ...P, [a]: d }), f.drawer?.onStateChange?.(d);
253
- }, h, E, w);
255
+ }, m, E, w);
254
256
  },
255
- [o]
257
+ [r]
256
258
  ), s = i.useCallback(
257
259
  (a) => {
258
- const d = o.get(a);
260
+ const d = r.get(a);
259
261
  return d?.drawer?.open !== void 0 ? d.drawer.open : e[a] ?? !1;
260
262
  },
261
- [o, e]
263
+ [r, e]
262
264
  ), c = i.useCallback(
263
- (a, d) => r(a, !0, d),
264
- [r]
265
+ (a, d) => o(a, !0, d),
266
+ [o]
265
267
  ), u = i.useCallback(
266
- (a, d) => r(a, !1, d),
267
- [r]
268
+ (a, d) => o(a, !1, d),
269
+ [o]
268
270
  );
269
271
  return { state: s, open: c, close: u };
270
- }, le = ({ layers: t }) => {
271
- const e = ue(t), n = i.useMemo(() => t.filter((r) => r.drawer), [t]), o = i.useMemo(() => {
272
- const r = /* @__PURE__ */ new Map();
272
+ }, he = ({ layers: t }) => {
273
+ const e = ge(t), n = i.useMemo(() => t.filter((o) => o.drawer), [t]), r = i.useMemo(() => {
274
+ const o = /* @__PURE__ */ new Map();
273
275
  return n.forEach((s) => {
274
- r.set(s.id, () => e.close(s.id));
275
- }), r;
276
+ o.set(s.id, () => e.close(s.id));
277
+ }), o;
276
278
  }, [n, e.close]);
277
- return /* @__PURE__ */ m(G, { children: n.map((r) => {
278
- if (!r.drawer)
279
+ return /* @__PURE__ */ h(N, { children: n.map((o) => {
280
+ if (!o.drawer)
279
281
  return null;
280
- const s = e.state(r.id), c = o.get(r.id);
281
- return c ? /* @__PURE__ */ m(
282
- ie,
282
+ const s = e.state(o.id), c = r.get(o.id);
283
+ return c ? /* @__PURE__ */ h(
284
+ de,
283
285
  {
284
- id: r.id,
285
- config: r.drawer,
286
+ id: o.id,
287
+ config: o.drawer,
286
288
  isOpen: s,
287
289
  onClose: c,
288
- zIndex: r.zIndex,
289
- width: r.width,
290
- height: r.height,
291
- position: r.position,
292
- children: r.component
290
+ zIndex: o.zIndex,
291
+ width: o.width,
292
+ height: o.height,
293
+ position: o.position,
294
+ children: o.component
293
295
  },
294
- r.id
296
+ o.id
295
297
  ) : null;
296
298
  }) });
297
- }, Pt = i.createContext(null), de = ({ value: t, children: e }) => /* @__PURE__ */ m(Pt.Provider, { value: t, children: e }), fe = () => {
298
- const t = i.useContext(Pt);
299
+ }, yt = i.createContext(null), me = ({ value: t, children: e }) => /* @__PURE__ */ h(yt.Provider, { value: t, children: e }), Lt = () => {
300
+ const t = i.useContext(yt);
299
301
  if (!t)
300
302
  throw new Error("useGridLayoutContext must be used within a GridLayoutProvider.");
301
303
  return t;
302
- }, yt = i.createContext(null), pe = () => {
303
- const t = i.useContext(yt);
304
+ }, Mt = i.createContext(null), be = () => {
305
+ const t = i.useContext(Mt);
304
306
  if (!t)
305
307
  throw new Error("usePanelSystem must be used within a PanelSystemProvider.");
306
308
  return t;
307
- }, ge = ({ config: t, layers: e, style: n, children: o }) => {
308
- const r = i.useMemo(() => {
309
+ }, we = ({ config: t, layers: e, style: n, children: r }) => {
310
+ const o = i.useMemo(() => {
309
311
  const c = /* @__PURE__ */ new Map();
310
312
  return e.forEach((u) => {
311
313
  c.set(u.id, u);
@@ -316,16 +318,16 @@ const lt = {
316
318
  style: n,
317
319
  layers: {
318
320
  defs: e,
319
- layerById: r
321
+ layerById: o
320
322
  }
321
323
  }),
322
- [t, n, e, r]
324
+ [t, n, e, o]
323
325
  );
324
- return /* @__PURE__ */ m(yt.Provider, { value: s, children: o });
325
- }, Dt = i.createContext(null), Lt = ({ layerId: t, children: e }) => {
326
+ return /* @__PURE__ */ h(Mt.Provider, { value: s, children: r });
327
+ }, Dt = i.createContext(null), Tt = ({ layerId: t, children: e }) => {
326
328
  const n = i.useMemo(() => ({ layerId: t }), [t]);
327
- return /* @__PURE__ */ m(Dt.Provider, { value: n, children: e });
328
- }, Ln = () => {
329
+ return /* @__PURE__ */ h(Dt.Provider, { value: n, children: e });
330
+ }, An = () => {
329
331
  const t = i.useContext(Dt);
330
332
  if (!t)
331
333
  throw new Error("useLayerInstance must be used within a LayerInstanceProvider.");
@@ -334,43 +336,43 @@ const lt = {
334
336
  if (typeof t == "number" && Number.isFinite(t))
335
337
  return t;
336
338
  throw new Error(`Popup layer "${n}" requires a numeric "${e}" value.`);
337
- }, Mt = (t, e) => {
339
+ }, It = (t, e) => {
338
340
  if (!t)
339
341
  throw new Error(`Popup layer "${e}" must define position (left/top).`);
340
342
  return {
341
343
  left: ft(t.left, "left", e),
342
344
  top: ft(t.top, "top", e)
343
345
  };
344
- }, Y = (t) => `${Math.round(t)}`, N = (t) => {
346
+ }, Y = (t) => `${Math.round(t)}`, _ = (t) => {
345
347
  if (t !== void 0)
346
348
  return t ? "yes" : "no";
347
- }, he = (t, e, n, o, r) => {
348
- const s = {}, c = Mt(e, t);
349
- if (typeof n != "number" || typeof o != "number")
349
+ }, ve = (t, e, n, r, o) => {
350
+ const s = {}, c = It(e, t);
351
+ if (typeof n != "number" || typeof r != "number")
350
352
  throw new Error(`Popup layer "${t}" requires numeric width/height.`);
351
- s.width = Y(n), s.height = Y(o), s.left = Y(c.left), s.top = Y(c.top);
352
- const u = r?.features;
353
+ s.width = Y(n), s.height = Y(r), s.left = Y(c.left), s.top = Y(c.top);
354
+ const u = o?.features;
353
355
  if (u) {
354
- const a = N(u.toolbar), d = N(u.menubar), p = N(u.location), f = N(u.status), h = N(u.resizable), w = N(u.scrollbars);
355
- a !== void 0 && (s.toolbar = a), d !== void 0 && (s.menubar = d), p !== void 0 && (s.location = p), f !== void 0 && (s.status = f), h !== void 0 && (s.resizable = h), w !== void 0 && (s.scrollbars = w);
356
+ const a = _(u.toolbar), d = _(u.menubar), g = _(u.location), f = _(u.status), m = _(u.resizable), w = _(u.scrollbars);
357
+ a !== void 0 && (s.toolbar = a), d !== void 0 && (s.menubar = d), g !== void 0 && (s.location = g), f !== void 0 && (s.status = f), m !== void 0 && (s.resizable = m), w !== void 0 && (s.scrollbars = w);
356
358
  }
357
359
  return Object.entries(s).map(([a, d]) => `${a}=${d}`).join(",");
358
- }, pt = (t, e, n, o, r) => {
359
- const s = Mt(n, e);
360
- if (typeof o != "number" || typeof r != "number")
360
+ }, pt = (t, e, n, r, o) => {
361
+ const s = It(n, e);
362
+ if (typeof r != "number" || typeof o != "number")
361
363
  throw new Error(`Popup layer "${e}" requires numeric width/height.`);
362
- t.moveTo(Math.round(s.left), Math.round(s.top)), t.resizeTo(Math.round(o), Math.round(r));
363
- }, me = ({ layer: t }) => {
364
+ t.moveTo(Math.round(s.left), Math.round(s.top)), t.resizeTo(Math.round(r), Math.round(o));
365
+ }, Ee = ({ layer: t }) => {
364
366
  const e = t.floating;
365
367
  if (!e)
366
368
  throw new Error(`Layer "${t.id}" is missing floating configuration required for popup mode.`);
367
369
  if ((e.mode ?? "embedded") !== "popup")
368
370
  throw new Error(`PopupLayerPortal received layer "${t.id}" that is not configured for popup mode.`);
369
- const o = i.useRef(null), r = i.useRef(null), [s, c] = i.useState(!1);
371
+ const r = i.useRef(null), o = i.useRef(null), [s, c] = i.useState(!1);
370
372
  return i.useEffect(() => {
371
373
  if (typeof window > "u")
372
374
  return;
373
- const u = he(t.id, t.position, t.width, t.height, e.popup), a = e.popup?.name ?? t.id, d = be(
375
+ const u = ve(t.id, t.position, t.width, t.height, e.popup), a = e.popup?.name ?? t.id, d = Se(
374
376
  a,
375
377
  u,
376
378
  {
@@ -381,15 +383,15 @@ const lt = {
381
383
  );
382
384
  if (!d)
383
385
  throw new Error(`Failed to open popup window for layer "${t.id}".`);
384
- const p = d;
385
- r.current = p, e.popup?.focus !== !1 && p.focus(), p.document.title || (p.document.title = t.id), p.document.body.innerHTML = "";
386
- const f = p.document.createElement("div");
387
- f.dataset.layerId = t.id, p.document.body.appendChild(f), o.current = f, c(!0), pt(p, t.id, t.position, t.width, t.height);
388
- const h = () => {
389
- r.current = null, o.current = null, c(!1);
386
+ const g = d;
387
+ o.current = g, e.popup?.focus !== !1 && g.focus(), g.document.title || (g.document.title = t.id), g.document.body.innerHTML = "";
388
+ const f = g.document.createElement("div");
389
+ f.dataset.layerId = t.id, g.document.body.appendChild(f), r.current = f, c(!0), pt(g, t.id, t.position, t.width, t.height);
390
+ const m = () => {
391
+ o.current = null, r.current = null, c(!1);
390
392
  };
391
- return p.addEventListener("beforeunload", h), () => {
392
- p.removeEventListener("beforeunload", h), e.popup?.closeOnUnmount !== !1 && p.close(), r.current = null, o.current = null, c(!1);
393
+ return g.addEventListener("beforeunload", m), () => {
394
+ g.removeEventListener("beforeunload", m), e.popup?.closeOnUnmount !== !1 && g.close(), o.current = null, r.current = null, c(!1);
393
395
  };
394
396
  }, [
395
397
  e.popup?.closeOnUnmount,
@@ -403,27 +405,27 @@ const lt = {
403
405
  e.popup?.name,
404
406
  t.id
405
407
  ]), i.useEffect(() => {
406
- const u = r.current;
408
+ const u = o.current;
407
409
  u && pt(u, t.id, t.position, t.width, t.height);
408
- }, [t.position?.left, t.position?.top, t.height, t.width, t.id]), !s || !o.current ? null : Zt(/* @__PURE__ */ m(Lt, { layerId: t.id, children: t.component }), o.current);
409
- }, be = (t, e, n, o) => {
410
- const r = o?.createWindow;
411
- return r ? r({ name: t, features: e, bounds: n }) : window.open("", t, e);
412
- }, Tt = {
410
+ }, [t.position?.left, t.position?.top, t.height, t.width, t.id]), !s || !r.current ? null : Qt(/* @__PURE__ */ h(Tt, { layerId: t.id, children: t.component }), r.current);
411
+ }, Se = (t, e, n, r) => {
412
+ const o = r?.createWindow;
413
+ return o ? o({ name: t, features: e, bounds: n }) : window.open("", t, e);
414
+ }, xt = {
413
415
  position: "absolute",
414
416
  pointerEvents: "auto",
415
417
  boxSizing: "border-box",
416
418
  background: "transparent",
417
419
  border: "none"
418
- }, we = {
419
- ...Tt,
420
- width: M,
421
- height: M,
420
+ }, Ce = {
421
+ ...xt,
422
+ width: D,
423
+ height: D,
422
424
  zIndex: 2
423
- }, ve = {
424
- ...Tt,
425
+ }, ze = {
426
+ ...xt,
425
427
  zIndex: 1
426
- }, Ee = {
428
+ }, Re = {
427
429
  "top-left": {
428
430
  top: 0,
429
431
  left: 0,
@@ -448,40 +450,40 @@ const lt = {
448
450
  transform: "translate(50%, 50%)",
449
451
  cursor: "nwse-resize"
450
452
  }
451
- }, Se = {
453
+ }, Pe = {
452
454
  left: {
453
- top: M,
454
- bottom: M,
455
+ top: D,
456
+ bottom: D,
455
457
  left: 0,
456
458
  width: B,
457
459
  transform: "translateX(-50%)",
458
460
  cursor: "ew-resize"
459
461
  },
460
462
  right: {
461
- top: M,
462
- bottom: M,
463
+ top: D,
464
+ bottom: D,
463
465
  right: 0,
464
466
  width: B,
465
467
  transform: "translateX(50%)",
466
468
  cursor: "ew-resize"
467
469
  },
468
470
  top: {
469
- left: M,
470
- right: M,
471
+ left: D,
472
+ right: D,
471
473
  top: 0,
472
474
  height: B,
473
475
  transform: "translateY(-50%)",
474
476
  cursor: "ns-resize"
475
477
  },
476
478
  bottom: {
477
- left: M,
478
- right: M,
479
+ left: D,
480
+ right: D,
479
481
  bottom: 0,
480
482
  height: B,
481
483
  transform: "translateY(50%)",
482
484
  cursor: "ns-resize"
483
485
  }
484
- }, Ce = [
486
+ }, ye = [
485
487
  { key: "top-left", variant: "corner", horizontal: "left", vertical: "top" },
486
488
  { key: "top-right", variant: "corner", horizontal: "right", vertical: "top" },
487
489
  { key: "bottom-left", variant: "corner", horizontal: "left", vertical: "bottom" },
@@ -490,9 +492,9 @@ const lt = {
490
492
  { key: "right", variant: "edge", horizontal: "right" },
491
493
  { key: "top", variant: "edge", vertical: "top" },
492
494
  { key: "bottom", variant: "edge", vertical: "bottom" }
493
- ], ze = ({ layerId: t, onPointerDown: e }) => /* @__PURE__ */ m(G, { children: Ce.map((n) => {
494
- const o = n.variant === "corner" ? we : ve, r = n.variant === "corner" ? Ee[n.key] : Se[n.key], s = { ...o, ...r }, c = n.variant === "corner" ? { "data-resize-corner": n.key } : { "data-resize-edge": n.key };
495
- return /* @__PURE__ */ m(
495
+ ], Le = ({ layerId: t, onPointerDown: e }) => /* @__PURE__ */ h(N, { children: ye.map((n) => {
496
+ const r = n.variant === "corner" ? Ce : ze, o = n.variant === "corner" ? Re[n.key] : Pe[n.key], s = { ...r, ...o }, c = n.variant === "corner" ? { "data-resize-corner": n.key } : { "data-resize-edge": n.key };
497
+ return /* @__PURE__ */ h(
496
498
  "div",
497
499
  {
498
500
  role: "presentation",
@@ -504,140 +506,153 @@ const lt = {
504
506
  },
505
507
  n.key
506
508
  );
507
- }) }), Re = ({ layers: t }) => {
508
- const { handleLayerPointerDown: e, getLayerRenderState: n } = fe(), o = i.useCallback((r) => r.length === 0 ? null : r.map((s) => /* @__PURE__ */ m(ze, { layerId: s.layerId, onPointerDown: s.onPointerDown }, s.layerId)), []);
509
- return /* @__PURE__ */ m(G, { children: t.map((r) => {
510
- const s = r.floating?.mode ?? "embedded";
511
- if (r.floating && s === "popup")
512
- return /* @__PURE__ */ m(me, { layer: r }, r.id);
513
- const { style: c, isResizable: u, isResizing: a, onResizeHandlePointerDown: d } = n(r), p = {};
514
- r.gridArea && (p.gridArea = r.gridArea), r.gridRow && (p.gridRow = r.gridRow), r.gridColumn && (p.gridColumn = r.gridColumn);
515
- const h = u ? { ...c, ...p, position: "relative" } : { ...c, ...p }, E = o(u ? [
516
- {
517
- layerId: r.id,
518
- onPointerDown: d
519
- }
520
- ] : []);
521
- return /* @__PURE__ */ $(
522
- "div",
523
- {
524
- "data-layer-id": r.id,
525
- "data-draggable": !!r.floating?.draggable,
526
- "data-resizable": u,
527
- "data-resizing": a,
528
- style: h,
529
- onPointerDown: e,
530
- children: [
531
- /* @__PURE__ */ m(Lt, { layerId: r.id, children: r.component }),
532
- E
533
- ]
534
- },
535
- r.id
536
- );
509
+ }) }), Me = ({ pivot: t }) => {
510
+ const { Outlet: e } = te({
511
+ items: t.items,
512
+ activeId: t.activeId,
513
+ defaultActiveId: t.defaultActiveId,
514
+ onActiveChange: t.onActiveChange,
515
+ transitionMode: t.transitionMode
516
+ });
517
+ return /* @__PURE__ */ h(e, {});
518
+ }, kt = i.memo(({ layer: t }) => t.pivot ? /* @__PURE__ */ h(Me, { pivot: t.pivot }) : /* @__PURE__ */ h(N, { children: t.component }));
519
+ kt.displayName = "LayerContent";
520
+ const At = i.memo(({ layerId: t, isResizable: e, onPointerDown: n }) => e ? /* @__PURE__ */ h(Le, { layerId: t, onPointerDown: n }) : null);
521
+ At.displayName = "LayerResizeHandles";
522
+ const Ht = i.memo(({ layer: t, handleLayerPointerDown: e }) => {
523
+ const { getLayerRenderState: n } = Lt(), { style: r, isResizable: o, isResizing: s, onResizeHandlePointerDown: c } = n(t), u = i.useMemo(() => {
524
+ const d = {};
525
+ return t.gridArea && (d.gridArea = t.gridArea), t.gridRow && (d.gridRow = t.gridRow), t.gridColumn && (d.gridColumn = t.gridColumn), d;
526
+ }, [t.gridArea, t.gridRow, t.gridColumn]), a = i.useMemo(() => {
527
+ const d = { ...r, ...u };
528
+ return o ? { ...d, position: "relative" } : d;
529
+ }, [r, u, o]);
530
+ return /* @__PURE__ */ G(
531
+ "div",
532
+ {
533
+ "data-layer-id": t.id,
534
+ "data-draggable": !!t.floating?.draggable,
535
+ "data-resizable": o,
536
+ "data-resizing": s,
537
+ style: a,
538
+ onPointerDown: e,
539
+ children: [
540
+ /* @__PURE__ */ h(Tt, { layerId: t.id, children: /* @__PURE__ */ h(kt, { layer: t }) }),
541
+ /* @__PURE__ */ h(At, { layerId: t.id, isResizable: o, onPointerDown: c })
542
+ ]
543
+ }
544
+ );
545
+ });
546
+ Ht.displayName = "EmbeddedLayer";
547
+ const De = ({ layers: t }) => {
548
+ const { handleLayerPointerDown: e } = Lt();
549
+ return /* @__PURE__ */ h(N, { children: t.map((n) => {
550
+ const r = n.floating?.mode ?? "embedded";
551
+ return n.floating && r === "popup" ? /* @__PURE__ */ h(Ee, { layer: n }, n.id) : /* @__PURE__ */ h(Ht, { layer: n, handleLayerPointerDown: e }, n.id);
537
552
  }) });
538
553
  };
539
- function _(t) {
554
+ function $(t) {
540
555
  const e = i.useRef(t);
541
556
  return e.current = t, i.useCallback((...n) => {
542
- const o = e.current;
543
- if (o)
544
- return o(...n);
557
+ const r = e.current;
558
+ if (r)
559
+ return r(...n);
545
560
  }, []);
546
561
  }
547
562
  function tt(t, e) {
548
- const n = _(e.onMove), o = _(e.onUp), r = _(e.onCancel);
563
+ const n = $(e.onMove), r = $(e.onUp), o = $(e.onCancel);
549
564
  i.useEffect(() => {
550
565
  if (t)
551
- return e.onMove && document.addEventListener("pointermove", n, { passive: !1 }), e.onUp && document.addEventListener("pointerup", o), e.onCancel && document.addEventListener("pointercancel", r), () => {
552
- e.onMove && document.removeEventListener("pointermove", n), e.onUp && document.removeEventListener("pointerup", o), e.onCancel && document.removeEventListener("pointercancel", r);
566
+ return e.onMove && document.addEventListener("pointermove", n, { passive: !1 }), e.onUp && document.addEventListener("pointerup", r), e.onCancel && document.addEventListener("pointercancel", o), () => {
567
+ e.onMove && document.removeEventListener("pointermove", n), e.onUp && document.removeEventListener("pointerup", r), e.onCancel && document.removeEventListener("pointercancel", o);
553
568
  };
554
- }, [t, e.onMove, e.onUp, e.onCancel, n, o, r]);
569
+ }, [t, e.onMove, e.onUp, e.onCancel, n, r, o]);
555
570
  }
556
- function Pe(t, e, n) {
571
+ function Te(t, e, n) {
557
572
  i.useEffect(() => {
558
- const o = t.current;
559
- if (!(!e || !o || n === void 0))
560
- return o.setPointerCapture(n), () => {
561
- o.hasPointerCapture && o.hasPointerCapture(n) && o.releasePointerCapture(n);
573
+ const r = t.current;
574
+ if (!(!e || !r || n === void 0))
575
+ return r.setPointerCapture(n), () => {
576
+ r.hasPointerCapture && r.hasPointerCapture(n) && r.releasePointerCapture(n);
562
577
  };
563
578
  }, [t, e, n]);
564
579
  }
565
- function ye(t, e, n = ["pointerdown", "pointermove", "pointerup"]) {
580
+ function Ie(t, e, n = ["pointerdown", "pointermove", "pointerup"]) {
566
581
  i.useEffect(() => {
567
- const o = t.current;
568
- if (!e || !o)
582
+ const r = t.current;
583
+ if (!e || !r)
569
584
  return;
570
- const r = (s) => {
585
+ const o = (s) => {
571
586
  s.preventDefault();
572
587
  };
573
588
  return n.forEach((s) => {
574
- o.addEventListener(s, r, { passive: !1 });
589
+ r.addEventListener(s, o, { passive: !1 });
575
590
  }), () => {
576
591
  n.forEach((s) => {
577
- o.removeEventListener(s, r);
592
+ r.removeEventListener(s, o);
578
593
  });
579
594
  };
580
595
  }, [t, e, n]);
581
596
  }
582
- function De(t, e, n) {
583
- const { onMove: o, onUp: r, onCancel: s, pointerId: c, capturePointer: u = !0, preventDefaults: a = !0 } = n;
584
- tt(e, { onMove: o, onUp: r, onCancel: s }), Pe(t, e ? u : !1, c), ye(t, e ? a : !1);
597
+ function xe(t, e, n) {
598
+ const { onMove: r, onUp: o, onCancel: s, pointerId: c, capturePointer: u = !0, preventDefaults: a = !0 } = n;
599
+ tt(e, { onMove: r, onUp: o, onCancel: s }), Te(t, e ? u : !1, c), Ie(t, e ? a : !1);
585
600
  }
586
- const Le = (t) => {
587
- const e = i.useRef(null), n = i.useRef(null), o = i.useRef(0), [r, s] = i.useState(!1), c = _((f) => {
601
+ const ke = (t) => {
602
+ const e = i.useRef(null), n = i.useRef(null), r = i.useRef(0), [o, s] = i.useState(!1), c = $((f) => {
588
603
  t.onResize?.(f);
589
604
  }), u = i.useCallback(
590
605
  (f) => t.axis === "x" ? f.clientX : f.clientY,
591
606
  [t.axis]
592
607
  ), a = i.useCallback(
593
608
  (f) => {
594
- f.preventDefault(), e.current = f.currentTarget, n.current = f.pointerId, o.current = u(f), s(!0);
609
+ f.preventDefault(), e.current = f.currentTarget, n.current = f.pointerId, r.current = u(f), s(!0);
595
610
  },
596
611
  [u]
597
612
  ), d = i.useCallback(
598
613
  (f) => {
599
- const h = u(f), w = h - o.current;
600
- w !== 0 && (o.current = h, c(w));
614
+ const m = u(f), w = m - r.current;
615
+ w !== 0 && (r.current = m, c(w));
601
616
  },
602
617
  [u, c]
603
- ), p = i.useCallback(() => {
618
+ ), g = i.useCallback(() => {
604
619
  s(!1), n.current = null;
605
620
  }, []);
606
- return De(e, r, {
621
+ return xe(e, o, {
607
622
  onMove: d,
608
- onUp: p,
623
+ onUp: g,
609
624
  pointerId: n.current ?? void 0,
610
625
  capturePointer: !0,
611
626
  preventDefaults: !1
612
627
  }), {
613
628
  ref: e,
614
629
  onPointerDown: a,
615
- isDragging: r
630
+ isDragging: o
616
631
  };
617
- }, Me = ({
632
+ }, Ae = ({
618
633
  element: t,
619
634
  component: e
620
- }) => i.forwardRef(({ children: n, ...o }, r) => t ? i.cloneElement(
635
+ }) => i.forwardRef(({ children: n, ...r }, o) => t ? i.cloneElement(
621
636
  t,
622
- { ...o, ref: r },
637
+ { ...r, ref: o },
623
638
  n ?? t.props.children
624
- ) : e ? /* @__PURE__ */ m(e, { ...o, ref: r, children: n }) : /* @__PURE__ */ m("div", { ...o, ref: r, children: n }));
625
- function Te({
639
+ ) : e ? /* @__PURE__ */ h(e, { ...r, ref: o, children: n }) : /* @__PURE__ */ h("div", { ...r, ref: o, children: n }));
640
+ function He({
626
641
  element: t,
627
642
  component: e
628
643
  }) {
629
644
  return i.useMemo(
630
- () => Me({
645
+ () => Ae({
631
646
  element: t,
632
647
  component: e
633
648
  }),
634
649
  [e, t]
635
650
  );
636
651
  }
637
- const Ie = {
652
+ const Ne = {
638
653
  position: "absolute",
639
- zIndex: jt
640
- }, ke = {
654
+ zIndex: Jt
655
+ }, _e = {
641
656
  vertical: {
642
657
  width: ct,
643
658
  height: "100%",
@@ -650,31 +665,31 @@ const Ie = {
650
665
  left: 0,
651
666
  cursor: "row-resize"
652
667
  }
653
- }, xe = {
654
- idle: Ut,
655
- hovered: Vt,
656
- dragging: Xt
657
- }, Ae = ({
668
+ }, $e = {
669
+ idle: qt,
670
+ hovered: Kt,
671
+ dragging: Zt
672
+ }, Ge = ({
658
673
  direction: t,
659
674
  onResize: e,
660
675
  component: n,
661
- element: o,
662
- children: r
676
+ element: r,
677
+ children: o
663
678
  }) => {
664
- const s = t === "vertical" ? "x" : "y", { ref: c, isDragging: u, onPointerDown: a } = Le({ axis: s, onResize: e }), [d, p] = i.useState(!1), f = i.useCallback(() => {
665
- p(!0);
666
- }, []), h = i.useCallback(() => {
667
- p(!1);
668
- }, []), w = Te({
669
- element: o,
679
+ const s = t === "vertical" ? "x" : "y", { ref: c, isDragging: u, onPointerDown: a } = ke({ axis: s, onResize: e }), [d, g] = i.useState(!1), f = i.useCallback(() => {
680
+ g(!0);
681
+ }, []), m = i.useCallback(() => {
682
+ g(!1);
683
+ }, []), w = He({
684
+ element: r,
670
685
  component: n
671
686
  }), E = i.useMemo(() => u ? "dragging" : d ? "hovered" : "idle", [u, d]), z = i.useMemo(() => ({
672
- ...Ie,
673
- ...ke[t],
674
- backgroundColor: xe[E],
687
+ ...Ne,
688
+ ..._e[t],
689
+ backgroundColor: $e[E],
675
690
  touchAction: "none"
676
691
  }), [t, E]);
677
- return /* @__PURE__ */ m(
692
+ return /* @__PURE__ */ h(
678
693
  w,
679
694
  {
680
695
  ref: c,
@@ -687,8 +702,8 @@ const Ie = {
687
702
  "data-is-dragging": u ? "true" : void 0,
688
703
  onPointerDown: a,
689
704
  onPointerEnter: f,
690
- onPointerLeave: h,
691
- children: r
705
+ onPointerLeave: m,
706
+ children: o
692
707
  }
693
708
  );
694
709
  }, gt = {
@@ -698,24 +713,24 @@ const Ie = {
698
713
  direction: t,
699
714
  trackIndex: e,
700
715
  align: n,
701
- gap: o,
702
- span: r,
716
+ gap: r,
717
+ span: o,
703
718
  onResize: s
704
719
  }) => {
705
720
  const c = t === "col" ? "vertical" : "horizontal", u = i.useCallback(
706
- (p) => {
707
- const f = n === "start" ? -p : p;
721
+ (g) => {
722
+ const f = n === "start" ? -g : g;
708
723
  s(t, e, f);
709
724
  },
710
725
  [n, t, e, s]
711
726
  ), a = i.useMemo(() => t === "col" ? {
712
727
  gridColumn: `${e + 1} / ${e + 2}`,
713
- gridRow: `${r.start} / ${r.end}`
728
+ gridRow: `${o.start} / ${o.end}`
714
729
  } : {
715
730
  gridRow: `${e + 1} / ${e + 2}`,
716
- gridColumn: `${r.start} / ${r.end}`
717
- }, [t, e, r]), d = i.useMemo(() => {
718
- const f = Math.max(0, o) / 2 + J / 2;
731
+ gridColumn: `${o.start} / ${o.end}`
732
+ }, [t, e, o]), d = i.useMemo(() => {
733
+ const f = Math.max(0, r) / 2 + J / 2;
719
734
  return t === "col" ? {
720
735
  ...gt,
721
736
  width: J,
@@ -731,19 +746,19 @@ const Ie = {
731
746
  right: 0,
732
747
  ...n === "start" ? { top: -f } : { bottom: -f }
733
748
  };
734
- }, [n, t, o]);
735
- return /* @__PURE__ */ m("div", { "data-resizable": "true", style: { ...a, position: "relative", pointerEvents: "none" }, children: /* @__PURE__ */ m("div", { "data-direction": c, "data-align": n, "data-handle": "true", style: d, children: /* @__PURE__ */ m(Ae, { direction: c, onResize: u }) }) });
736
- }, He = (t) => {
749
+ }, [n, t, r]);
750
+ return /* @__PURE__ */ h("div", { "data-resizable": "true", style: { ...a, position: "relative", pointerEvents: "none" }, children: /* @__PURE__ */ h("div", { "data-direction": c, "data-align": n, "data-handle": "true", style: d, children: /* @__PURE__ */ h(Ge, { direction: c, onResize: u }) }) });
751
+ }, Fe = (t) => {
737
752
  const e = /* @__PURE__ */ new Map();
738
- t.forEach((o, r) => {
739
- o.forEach((s, c) => {
753
+ t.forEach((r, o) => {
754
+ r.forEach((s, c) => {
740
755
  if (!s || s === ".")
741
756
  return;
742
757
  const u = e.get(s);
743
758
  if (u) {
744
759
  const d = {
745
- rowStart: Math.min(u.rowStart, r),
746
- rowEnd: Math.max(u.rowEnd, r),
760
+ rowStart: Math.min(u.rowStart, o),
761
+ rowEnd: Math.max(u.rowEnd, o),
747
762
  colStart: Math.min(u.colStart, c),
748
763
  colEnd: Math.max(u.colEnd, c)
749
764
  };
@@ -751,8 +766,8 @@ const Ie = {
751
766
  return;
752
767
  }
753
768
  const a = {
754
- rowStart: r,
755
- rowEnd: r,
769
+ rowStart: o,
770
+ rowEnd: o,
756
771
  colStart: c,
757
772
  colEnd: c
758
773
  };
@@ -760,172 +775,172 @@ const Ie = {
760
775
  });
761
776
  });
762
777
  const n = /* @__PURE__ */ new Map();
763
- return e.forEach((o, r) => {
764
- const s = o.rowStart + 1, c = o.rowEnd + 2, u = o.colStart + 1, a = o.colEnd + 2, d = {
765
- gridArea: r,
778
+ return e.forEach((r, o) => {
779
+ const s = r.rowStart + 1, c = r.rowEnd + 2, u = r.colStart + 1, a = r.colEnd + 2, d = {
780
+ gridArea: o,
766
781
  gridRow: `${s} / ${c}`,
767
782
  gridColumn: `${u} / ${a}`
768
783
  };
769
- n.set(r, d);
784
+ n.set(o, d);
770
785
  }), n;
771
- }, Ne = (t, e) => {
786
+ }, Oe = (t, e) => {
772
787
  if ((t.positionMode ?? "grid") !== "grid")
773
788
  return t;
774
- const o = t.gridArea ?? t.id, r = e.get(o);
775
- if (!r)
789
+ const r = t.gridArea ?? t.id, o = e.get(r);
790
+ if (!o)
776
791
  return t;
777
792
  const s = !t.gridArea, c = !t.gridRow, u = !t.gridColumn;
778
793
  return !s && !c && !u ? t : {
779
794
  ...t,
780
- gridArea: s ? r.gridArea : t.gridArea,
781
- gridRow: c ? r.gridRow : t.gridRow,
782
- gridColumn: u ? r.gridColumn : t.gridColumn
795
+ gridArea: s ? o.gridArea : t.gridArea,
796
+ gridRow: c ? o.gridRow : t.gridRow,
797
+ gridColumn: u ? o.gridColumn : t.gridColumn
783
798
  };
784
- }, _e = (t, e) => {
785
- const n = i.useMemo(() => He(t.areas), [t.areas]), o = i.useMemo(() => e.map((u) => Ne(u, n)), [e, n]), r = i.useMemo(
786
- () => o.filter((u) => u.visible !== !1),
787
- [o]
788
- ), s = i.useMemo(
789
- () => r.filter((u) => !u.drawer),
799
+ }, We = (t, e) => {
800
+ const n = i.useMemo(() => Fe(t.areas), [t.areas]), r = i.useMemo(() => e.map((u) => Oe(u, n)), [e, n]), o = i.useMemo(
801
+ () => r.filter((u) => u.visible !== !1),
790
802
  [r]
803
+ ), s = i.useMemo(
804
+ () => o.filter((u) => !u.drawer),
805
+ [o]
791
806
  ), c = i.useMemo(() => {
792
807
  const u = /* @__PURE__ */ new Map();
793
- return o.forEach((a) => {
808
+ return r.forEach((a) => {
794
809
  u.set(a.id, a);
795
810
  }), u;
796
- }, [o]);
811
+ }, [r]);
797
812
  return {
798
- normalizedLayers: o,
799
- visibleLayers: r,
813
+ normalizedLayers: r,
814
+ visibleLayers: o,
800
815
  regularLayers: s,
801
816
  layerById: c
802
817
  };
803
- }, $e = typeof window < "u" && typeof window.document < "u", It = $e ? i.useLayoutEffect : i.useEffect, j = (t, e) => `${t}-${e}`, Ge = (t, e, n, o) => {
804
- const r = j(n, o), s = e[r];
818
+ }, j = (t, e) => `${t}-${e}`, Be = (t, e, n, r) => {
819
+ const o = j(n, r), s = e[o];
805
820
  return s !== void 0 ? `${s}px` : t.size;
806
- }, mt = (t, e, n) => t.map((o, r) => Ge(o, e, n, r)).join(" "), X = (t, e) => t.reduce((n, o, r) => (o.resizable && o.size.endsWith("px") && (n[j(e, r)] = parseInt(o.size, 10)), n), {}), Fe = (t, e, n) => {
807
- const o = e !== void 0 ? Math.max(t, e) : t;
808
- return n !== void 0 ? Math.min(o, n) : o;
809
- }, Oe = (t, e, n) => {
810
- const o = t + e;
811
- return Fe(o, n.minSize, n.maxSize);
812
- }, We = (t, e, n, o, r) => {
821
+ }, mt = (t, e, n) => t.map((r, o) => Be(r, e, n, o)).join(" "), X = (t, e) => t.reduce((n, r, o) => (r.resizable && r.size.endsWith("px") && (n[j(e, o)] = parseInt(r.size, 10)), n), {}), Ye = (t, e, n) => {
822
+ const r = e !== void 0 ? Math.max(t, e) : t;
823
+ return n !== void 0 ? Math.min(r, n) : r;
824
+ }, Xe = (t, e, n) => {
825
+ const r = t + e;
826
+ return Ye(r, n.minSize, n.maxSize);
827
+ }, Ve = (t, e, n, r, o) => {
813
828
  const s = j(t, e);
814
829
  return (c) => {
815
- const u = Oe(n, o, r);
830
+ const u = Xe(n, r, o);
816
831
  return { ...c, [s]: u };
817
832
  };
818
833
  }, bt = (t, e) => {
819
- const n = t.length, o = [];
834
+ const n = t.length, r = [];
820
835
  for (let c = 0; c < n; c++) {
821
836
  const u = t[c], a = u[e], d = u[e + 1];
822
- a !== d && o.push(c);
837
+ a !== d && r.push(c);
823
838
  }
824
- if (o.length === 0)
839
+ if (r.length === 0)
825
840
  return { start: 1, end: n + 1 };
826
- const r = Math.min(...o), s = Math.max(...o);
827
- return { start: r + 1, end: s + 2 };
841
+ const o = Math.min(...r), s = Math.max(...r);
842
+ return { start: o + 1, end: s + 2 };
828
843
  }, wt = (t, e) => {
829
- const n = t[e], o = t[e + 1], r = n?.length ?? 0, s = [];
830
- for (let a = 0; a < r; a++) {
831
- const d = n?.[a], p = o?.[a];
832
- d !== p && s.push(a);
844
+ const n = t[e], r = t[e + 1], o = n?.length ?? 0, s = [];
845
+ for (let a = 0; a < o; a++) {
846
+ const d = n?.[a], g = r?.[a];
847
+ d !== g && s.push(a);
833
848
  }
834
849
  if (s.length === 0)
835
- return { start: 1, end: r + 1 };
850
+ return { start: 1, end: o + 1 };
836
851
  const c = Math.min(...s), u = Math.max(...s);
837
852
  return { start: c + 1, end: u + 2 };
838
- }, Be = (t, e) => {
853
+ }, Ue = (t, e) => {
839
854
  if (t.length === 0)
840
855
  return [];
841
856
  const n = e.length;
842
857
  if (t.length === 1)
843
858
  return t[0]?.resizable ? [{ trackIndex: 0, align: "end", span: { start: 1, end: n + 1 } }] : [];
844
- const o = [];
859
+ const r = [];
845
860
  return Array.from({ length: t.length - 1 }, (s, c) => c).forEach((s) => {
846
861
  const c = t[s];
847
862
  if (t[s + 1]?.resizable) {
848
863
  const a = bt(e, s);
849
- o.push({ trackIndex: s + 1, align: "start", span: a });
864
+ r.push({ trackIndex: s + 1, align: "start", span: a });
850
865
  return;
851
866
  }
852
867
  if (c?.resizable) {
853
868
  const a = bt(e, s);
854
- o.push({ trackIndex: s, align: "end", span: a });
869
+ r.push({ trackIndex: s, align: "end", span: a });
855
870
  }
856
- }), o;
857
- }, Ye = (t, e) => {
871
+ }), r;
872
+ }, je = (t, e) => {
858
873
  if (t.length === 0)
859
874
  return [];
860
875
  const n = e[0]?.length ?? 0;
861
876
  if (t.length === 1)
862
877
  return t[0]?.resizable ? [{ trackIndex: 0, align: "end", span: { start: 1, end: n + 1 } }] : [];
863
- const o = [];
878
+ const r = [];
864
879
  return Array.from({ length: t.length - 1 }, (s, c) => c).forEach((s) => {
865
880
  const c = t[s];
866
881
  if (t[s + 1]?.resizable) {
867
882
  const a = wt(e, s);
868
- o.push({ trackIndex: s + 1, align: "start", span: a });
883
+ r.push({ trackIndex: s + 1, align: "start", span: a });
869
884
  return;
870
885
  }
871
886
  if (c?.resizable) {
872
887
  const a = wt(e, s);
873
- o.push({ trackIndex: s, align: "end", span: a });
888
+ r.push({ trackIndex: s, align: "end", span: a });
874
889
  }
875
- }), o;
876
- }, Xe = (t) => {
890
+ }), r;
891
+ }, Ze = (t) => {
877
892
  if (!t)
878
893
  return { rowGap: 0, columnGap: 0 };
879
- const e = t.split(/\s+/).map((o) => o.trim()).filter(Boolean), n = (o) => {
880
- const r = o.match(/^(-?\d+(?:\.\d+)?)px$/);
881
- return r ? Number.parseFloat(r[1]) : 0;
894
+ const e = t.split(/\s+/).map((r) => r.trim()).filter(Boolean), n = (r) => {
895
+ const o = r.match(/^(-?\d+(?:\.\d+)?)px$/);
896
+ return o ? Number.parseFloat(o[1]) : 0;
882
897
  };
883
898
  if (e.length === 1) {
884
- const o = n(e[0]);
885
- return { rowGap: o, columnGap: o };
899
+ const r = n(e[0]);
900
+ return { rowGap: r, columnGap: r };
886
901
  }
887
902
  return {
888
903
  rowGap: n(e[0]),
889
904
  columnGap: n(e[1])
890
905
  };
891
- }, Ve = (t) => t !== void 0 ? { gap: t } : {}, Ue = (t, e, n, o) => {
892
- const r = j(n, o), s = t[r];
906
+ }, Ke = (t) => t !== void 0 ? { gap: t } : {}, qe = (t, e, n, r) => {
907
+ const o = j(n, r), s = t[o];
893
908
  return s !== void 0 ? s : e.size.endsWith("px") ? Number.parseInt(e.size, 10) : 300;
894
- }, je = (t, e) => {
895
- const [n, o] = i.useState(() => ({
909
+ }, Je = (t, e) => {
910
+ const [n, r] = i.useState(() => ({
896
911
  ...X(t.columns, "col"),
897
912
  ...X(t.rows, "row")
898
913
  }));
899
- It(() => {
900
- const p = {
914
+ Rt(() => {
915
+ const g = {
901
916
  ...X(t.columns, "col"),
902
917
  ...X(t.rows, "row")
903
918
  };
904
- o((f) => {
905
- const h = /* @__PURE__ */ new Set([...Object.keys(f), ...Object.keys(p)]);
906
- return Array.from(h).some((E) => f[E] !== p[E]) ? p : f;
919
+ r((f) => {
920
+ const m = /* @__PURE__ */ new Set([...Object.keys(f), ...Object.keys(g)]);
921
+ return Array.from(m).some((E) => f[E] !== g[E]) ? g : f;
907
922
  });
908
923
  }, [t.columns, t.rows]);
909
- const r = i.useMemo(() => t.areas.map((p) => `"${p.join(" ")}"`).join(" "), [t.areas]), s = i.useMemo(() => Xe(t.gap), [t.gap]), c = i.useMemo(
910
- () => Be(t.columns, t.areas),
924
+ const o = i.useMemo(() => t.areas.map((g) => `"${g.join(" ")}"`).join(" "), [t.areas]), s = i.useMemo(() => Ze(t.gap), [t.gap]), c = i.useMemo(
925
+ () => Ue(t.columns, t.areas),
911
926
  [t.columns, t.areas]
912
927
  ), u = i.useMemo(
913
- () => Ye(t.rows, t.areas),
928
+ () => je(t.rows, t.areas),
914
929
  [t.rows, t.areas]
915
930
  ), a = i.useMemo(() => ({
916
931
  ...t.style,
917
932
  ...e,
918
- gridTemplateAreas: r,
933
+ gridTemplateAreas: o,
919
934
  gridTemplateRows: mt(t.rows, n, "row"),
920
935
  gridTemplateColumns: mt(t.columns, n, "col"),
921
- ...Ve(t.gap)
922
- }), [r, t.columns, t.gap, t.rows, t.style, e, n]), d = i.useCallback(
923
- (p, f, h) => {
924
- const E = (p === "row" ? t.rows : t.columns)[f];
936
+ ...Ke(t.gap)
937
+ }), [o, t.columns, t.gap, t.rows, t.style, e, n]), d = i.useCallback(
938
+ (g, f, m) => {
939
+ const E = (g === "row" ? t.rows : t.columns)[f];
925
940
  if (!E || !E.resizable)
926
941
  return;
927
- const z = Ue(n, E, p, f);
928
- o(We(p, f, z, h, E));
942
+ const z = qe(n, E, g, f);
943
+ r(Ve(g, f, z, m, E));
929
944
  },
930
945
  [t.columns, t.rows, n]
931
946
  );
@@ -936,38 +951,38 @@ const Ie = {
936
951
  gridStyle: a,
937
952
  handleResize: d
938
953
  };
939
- }, Ze = (t, e = Number.NEGATIVE_INFINITY, n = Number.POSITIVE_INFINITY) => Math.min(Math.max(t, e), n), Mn = (t, e) => typeof t != "number" || !Number.isFinite(t) ? e : t, Ke = (t) => t.positionMode ? t.positionMode : t.floating ? (t.floating.mode ?? "embedded") === "embedded" ? "absolute" : "relative" : "grid", qe = (t) => ({ position: t === "grid" ? "relative" : t }), Je = (t, e) => e !== "grid" ? {} : {
954
+ }, Qe = (t, e = Number.NEGATIVE_INFINITY, n = Number.POSITIVE_INFINITY) => Math.min(Math.max(t, e), n), Hn = (t, e) => typeof t != "number" || !Number.isFinite(t) ? e : t, tn = (t) => t.positionMode ? t.positionMode : t.floating ? (t.floating.mode ?? "embedded") === "embedded" ? "absolute" : "relative" : "grid", en = (t) => ({ position: t === "grid" ? "relative" : t }), nn = (t, e) => e !== "grid" ? {} : {
940
955
  gridArea: t.gridArea,
941
956
  gridRow: t.gridRow,
942
957
  gridColumn: t.gridColumn
943
- }, Qe = (t) => t ? {
958
+ }, rn = (t) => t ? {
944
959
  top: t.top,
945
960
  right: t.right,
946
961
  bottom: t.bottom,
947
962
  left: t.left
948
- } : {}, tn = (t) => t !== void 0 ? { zIndex: t } : {}, en = (t, e) => ({
963
+ } : {}, on = (t) => t !== void 0 ? { zIndex: t } : {}, sn = (t, e) => ({
949
964
  width: t,
950
965
  height: e
951
- }), nn = (t, e) => t.pointerEvents !== void 0 ? typeof t.pointerEvents == "boolean" ? { pointerEvents: t.pointerEvents ? "auto" : "none" } : { pointerEvents: t.pointerEvents } : e === "absolute" || e === "fixed" ? { pointerEvents: "auto" } : {}, rn = (t) => t.position, on = (t) => ({
966
+ }), an = (t, e) => t.pointerEvents !== void 0 ? typeof t.pointerEvents == "boolean" ? { pointerEvents: t.pointerEvents ? "auto" : "none" } : { pointerEvents: t.pointerEvents } : e === "absolute" || e === "fixed" ? { pointerEvents: "auto" } : {}, cn = (t) => t.position, un = (t) => ({
952
967
  width: t.width,
953
968
  height: t.height
954
- }), sn = (t) => t.zIndex, an = (t) => {
955
- const e = Ke(t), n = rn(t), o = on(t), r = sn(t);
969
+ }), ln = (t) => t.zIndex, dn = (t) => {
970
+ const e = tn(t), n = cn(t), r = un(t), o = ln(t);
956
971
  return {
957
972
  ...t.style,
958
- ...qe(e),
959
- ...Je(t, e),
960
- ...Qe(n),
961
- ...tn(r),
962
- ...en(o.width, o.height),
963
- ...nn(t, e)
973
+ ...en(e),
974
+ ...nn(t, e),
975
+ ...rn(n),
976
+ ...on(o),
977
+ ...sn(r.width, r.height),
978
+ ...an(t, e)
964
979
  };
965
- }, cn = (t) => {
980
+ }, fn = (t) => {
966
981
  const e = t.floating;
967
982
  return e ? e.mode ?? "embedded" : null;
968
- }, H = (t) => cn(t) !== "embedded" ? null : t.floating ?? null, vt = (t) => t instanceof HTMLElement ? ["INPUT", "TEXTAREA", "SELECT", "BUTTON"].includes(t.tagName) : !1, Et = (t, e, n) => {
969
- const o = e ?? Number.NEGATIVE_INFINITY, r = n ?? Number.POSITIVE_INFINITY;
970
- return Ze(t, o, r);
983
+ }, H = (t) => fn(t) !== "embedded" ? null : t.floating ?? null, vt = (t) => t instanceof HTMLElement ? ["INPUT", "TEXTAREA", "SELECT", "BUTTON"].includes(t.tagName) : !1, Et = (t, e, n) => {
984
+ const r = e ?? Number.NEGATIVE_INFINITY, o = n ?? Number.POSITIVE_INFINITY;
985
+ return Qe(t, r, o);
971
986
  }, St = (t, e, n) => {
972
987
  if (typeof t == "number" && Number.isFinite(t))
973
988
  return t;
@@ -984,10 +999,10 @@ const Ie = {
984
999
  left: St(n.left, "left", t.id),
985
1000
  top: St(n.top, "top", t.id)
986
1001
  };
987
- }, un = (t) => {
1002
+ }, pn = (t) => {
988
1003
  const e = H(t);
989
1004
  return e ? e.constraints ?? {} : {};
990
- }, ln = (t, e, n) => t ? t === "left" ? e - n : e + n : e, dn = (t, e, n) => t ? t === "top" ? e - n : e + n : e, fn = (t, e, n) => !t || t === "right" ? e : e + n, pn = (t, e, n) => !t || t === "bottom" ? e : e + n, et = (t, e) => t ? t.dataset.layerId === e ? t : et(t.parentElement, e) : null, nt = (t, e, n) => !t || n?.(t) ? null : e(t) ? t : nt(t.parentElement, e, n), gn = (t) => t instanceof HTMLElement ? nt(
1005
+ }, gn = (t, e, n) => t ? t === "left" ? e - n : e + n : e, hn = (t, e, n) => t ? t === "top" ? e - n : e + n : e, mn = (t, e, n) => !t || t === "right" ? e : e + n, bn = (t, e, n) => !t || t === "bottom" ? e : e + n, et = (t, e) => t ? t.dataset.layerId === e ? t : et(t.parentElement, e) : null, nt = (t, e, n) => !t || n?.(t) ? null : e(t) ? t : nt(t.parentElement, e, n), wn = (t) => t instanceof HTMLElement ? nt(
991
1006
  t,
992
1007
  (e) => e.dataset.dragHandle === "true",
993
1008
  (e) => e.dataset.dragIgnore === "true"
@@ -1000,53 +1015,53 @@ const Ie = {
1000
1015
  }, U = (t) => {
1001
1016
  if (!H(t))
1002
1017
  return null;
1003
- const n = bn(t);
1018
+ const n = Sn(t);
1004
1019
  if (!n)
1005
1020
  throw new Error(`Floating layer "${t.id}" must define width and height when resizable or draggable.`);
1006
1021
  return {
1007
1022
  width: n.width,
1008
1023
  height: n.height
1009
1024
  };
1010
- }, hn = (t, e, n) => {
1011
- const o = t.filter(V).reduce((f, h) => {
1012
- if (n === h.id) {
1013
- const E = e[h.id];
1025
+ }, vn = (t, e, n) => {
1026
+ const r = t.filter(V).reduce((f, m) => {
1027
+ if (n === m.id) {
1028
+ const E = e[m.id];
1014
1029
  if (E)
1015
- return f[h.id] = E, f;
1030
+ return f[m.id] = E, f;
1016
1031
  }
1017
- const w = U(h);
1018
- return w && (f[h.id] = w), f;
1019
- }, {}), r = Object.keys(e), s = Object.keys(o), c = r.length !== s.length, u = r.some((f) => !Object.prototype.hasOwnProperty.call(o, f)), a = c ? !0 : u, d = s.some((f) => {
1020
- const h = e[f], w = o[f];
1021
- return !h || !w ? !0 : h.width !== w.width || h.height !== w.height;
1032
+ const w = U(m);
1033
+ return w && (f[m.id] = w), f;
1034
+ }, {}), o = Object.keys(e), s = Object.keys(r), c = o.length !== s.length, u = o.some((f) => !Object.prototype.hasOwnProperty.call(r, f)), a = c ? !0 : u, d = s.some((f) => {
1035
+ const m = e[f], w = r[f];
1036
+ return !m || !w ? !0 : m.width !== w.width || m.height !== w.height;
1022
1037
  });
1023
1038
  return {
1024
- sizes: o,
1039
+ sizes: r,
1025
1040
  changed: a ? !0 : d
1026
1041
  };
1027
- }, mn = ({
1042
+ }, En = ({
1028
1043
  layers: t,
1029
1044
  layerById: e
1030
1045
  }) => {
1031
- const [n, o] = i.useState(null), [r, s] = i.useState(null), [c, u] = i.useState({}), [a, d] = i.useState({}), p = i.useRef(null), f = i.useRef(null), h = _((g, l) => {
1032
- e.get(g)?.floating?.onMove?.(l);
1033
- }), w = _((g, l) => {
1034
- e.get(g)?.floating?.onResize?.(l);
1046
+ const [n, r] = i.useState(null), [o, s] = i.useState(null), [c, u] = i.useState({}), [a, d] = i.useState({}), g = i.useRef(null), f = i.useRef(null), m = $((p, l) => {
1047
+ e.get(p)?.floating?.onMove?.(l);
1048
+ }), w = $((p, l) => {
1049
+ e.get(p)?.floating?.onResize?.(l);
1035
1050
  });
1036
- It(() => {
1037
- const { sizes: g, changed: l } = hn(t, a, r);
1038
- l && d(g);
1039
- }, [t, r]);
1051
+ Rt(() => {
1052
+ const { sizes: p, changed: l } = vn(t, a, o);
1053
+ l && d(p);
1054
+ }, [t, o]);
1040
1055
  const E = i.useCallback(
1041
- (g, l, b, v) => {
1042
- const S = Ct(l), R = c[g] ?? { x: 0, y: 0 }, C = {
1056
+ (p, l, b, v) => {
1057
+ const S = Ct(l), R = c[p] ?? { x: 0, y: 0 }, C = {
1043
1058
  pointerStartX: v.clientX,
1044
1059
  pointerStartY: v.clientY,
1045
1060
  initialTranslationX: R.x,
1046
1061
  initialTranslationY: R.y,
1047
1062
  baseLeft: S.left,
1048
1063
  baseTop: S.top,
1049
- layerId: g,
1064
+ layerId: p,
1050
1065
  pointerId: v.pointerId,
1051
1066
  target: b
1052
1067
  };
@@ -1055,12 +1070,12 @@ const Ie = {
1055
1070
  C.target.setPointerCapture(C.pointerId);
1056
1071
  } catch {
1057
1072
  }
1058
- p.current = C, o(g);
1073
+ g.current = C, r(p);
1059
1074
  },
1060
1075
  [c]
1061
1076
  ), z = i.useCallback(
1062
- (g) => {
1063
- const l = g.target, b = gn(l);
1077
+ (p) => {
1078
+ const l = p.target, b = wn(l);
1064
1079
  if (!b)
1065
1080
  return;
1066
1081
  const v = b.closest("[data-layer-id]")?.getAttribute("data-layer-id");
@@ -1070,40 +1085,40 @@ const Ie = {
1070
1085
  if (!S)
1071
1086
  return;
1072
1087
  const R = H(S);
1073
- if (!(!R || R.draggable !== !0) && !vt(g.target) && !zt(g.target) && b) {
1088
+ if (!(!R || R.draggable !== !0) && !vt(p.target) && !zt(p.target) && b) {
1074
1089
  const C = et(b, v);
1075
1090
  if (!C)
1076
1091
  return;
1077
- E(v, S, C, g);
1092
+ E(v, S, C, p);
1078
1093
  return;
1079
1094
  }
1080
1095
  },
1081
1096
  [E, e]
1082
1097
  ), P = i.useCallback(
1083
- (g, l) => {
1084
- const b = e.get(g), v = b ? H(b) : null;
1098
+ (p, l) => {
1099
+ const b = e.get(p), v = b ? H(b) : null;
1085
1100
  if (!b || !v || v.draggable !== !0 || vt(l.target) || zt(l.target))
1086
1101
  return;
1087
- const S = et(l.currentTarget, g);
1088
- S && E(g, b, S, l);
1102
+ const S = et(l.currentTarget, p);
1103
+ S && E(p, b, S, l);
1089
1104
  },
1090
1105
  [E, e]
1091
- ), D = i.useCallback(
1092
- (g, l, b) => {
1093
- const v = e.get(g);
1106
+ ), L = i.useCallback(
1107
+ (p, l, b) => {
1108
+ const v = e.get(p);
1094
1109
  if (!v || !V(v))
1095
1110
  return;
1096
- const S = a[g] ?? U(v);
1111
+ const S = a[p] ?? U(v);
1097
1112
  if (!S)
1098
1113
  return;
1099
- const R = Ct(v), C = un(v), k = c[g] ?? { x: 0, y: 0 };
1114
+ const R = Ct(v), C = pn(v), x = c[p] ?? { x: 0, y: 0 };
1100
1115
  if (b.stopPropagation(), b.preventDefault(), b.currentTarget.setPointerCapture)
1101
1116
  try {
1102
1117
  b.currentTarget.setPointerCapture(b.pointerId);
1103
1118
  } catch {
1104
1119
  }
1105
1120
  f.current = {
1106
- layerId: g,
1121
+ layerId: p,
1107
1122
  pointerId: b.pointerId,
1108
1123
  horizontalEdge: l.horizontal,
1109
1124
  verticalEdge: l.vertical,
@@ -1111,7 +1126,7 @@ const Ie = {
1111
1126
  startY: b.clientY,
1112
1127
  startWidth: S.width,
1113
1128
  startHeight: S.height,
1114
- startPosition: k,
1129
+ startPosition: x,
1115
1130
  baseLeft: R.left,
1116
1131
  baseTop: R.top,
1117
1132
  minWidth: C.minWidth,
@@ -1119,63 +1134,63 @@ const Ie = {
1119
1134
  minHeight: C.minHeight,
1120
1135
  maxHeight: C.maxHeight,
1121
1136
  target: b.currentTarget
1122
- }, s(g);
1137
+ }, s(p);
1123
1138
  },
1124
1139
  [e, c, a]
1125
1140
  ), F = i.useCallback(
1126
- (g) => {
1127
- const l = p.current;
1141
+ (p) => {
1142
+ const l = g.current;
1128
1143
  if (!l)
1129
1144
  return;
1130
- const b = g.clientX - l.pointerStartX, v = g.clientY - l.pointerStartY, S = {
1145
+ const b = p.clientX - l.pointerStartX, v = p.clientY - l.pointerStartY, S = {
1131
1146
  x: l.initialTranslationX + b,
1132
1147
  y: l.initialTranslationY + v
1133
1148
  };
1134
- u((R) => ({ ...R, [l.layerId]: S })), h(l.layerId, {
1149
+ u((R) => ({ ...R, [l.layerId]: S })), m(l.layerId, {
1135
1150
  left: l.baseLeft + S.x,
1136
1151
  top: l.baseTop + S.y
1137
1152
  });
1138
1153
  },
1139
- [h]
1154
+ [m]
1140
1155
  ), T = i.useCallback(
1141
- (g) => {
1156
+ (p) => {
1142
1157
  const l = f.current;
1143
- if (!l || l.pointerId !== g.pointerId || !e.get(l.layerId))
1158
+ if (!l || l.pointerId !== p.pointerId || !e.get(l.layerId))
1144
1159
  return;
1145
- const v = g.clientX - l.startX, S = g.clientY - l.startY, R = ln(l.horizontalEdge, l.startWidth, v), C = dn(l.verticalEdge, l.startHeight, S), k = Et(R, l.minWidth, l.maxWidth), A = Et(C, l.minHeight, l.maxHeight), O = l.startWidth - k, Z = l.startHeight - A, st = fn(
1160
+ const v = p.clientX - l.startX, S = p.clientY - l.startY, R = gn(l.horizontalEdge, l.startWidth, v), C = hn(l.verticalEdge, l.startHeight, S), x = Et(R, l.minWidth, l.maxWidth), A = Et(C, l.minHeight, l.maxHeight), O = l.startWidth - x, Z = l.startHeight - A, st = mn(
1146
1161
  l.horizontalEdge,
1147
1162
  l.startPosition.x,
1148
1163
  O
1149
- ), kt = pn(l.verticalEdge, l.startPosition.y, Z), K = a[l.layerId], it = { width: k, height: A };
1150
- (!K || K.width !== k || K.height !== A) && (d((q) => ({
1164
+ ), Nt = bn(l.verticalEdge, l.startPosition.y, Z), K = a[l.layerId], it = { width: x, height: A };
1165
+ (!K || K.width !== x || K.height !== A) && (d((q) => ({
1151
1166
  ...q,
1152
1167
  [l.layerId]: it
1153
1168
  })), w(l.layerId, it));
1154
- const at = c[l.layerId] ?? { x: 0, y: 0 }, W = { x: st, y: kt };
1169
+ const at = c[l.layerId] ?? { x: 0, y: 0 }, W = { x: st, y: Nt };
1155
1170
  (at.x !== W.x || at.y !== W.y) && (u((q) => ({
1156
1171
  ...q,
1157
1172
  [l.layerId]: W
1158
- })), h(l.layerId, {
1173
+ })), m(l.layerId, {
1159
1174
  left: l.baseLeft + W.x,
1160
1175
  top: l.baseTop + W.y
1161
1176
  }));
1162
1177
  },
1163
- [e, c, a, h, w]
1164
- ), L = i.useCallback((g) => {
1165
- const l = p.current;
1178
+ [e, c, a, m, w]
1179
+ ), M = i.useCallback((p) => {
1180
+ const l = g.current;
1166
1181
  if (l) {
1167
- if (l.pointerId === g.pointerId && l.target.releasePointerCapture)
1182
+ if (l.pointerId === p.pointerId && l.target.releasePointerCapture)
1168
1183
  try {
1169
1184
  l.target.releasePointerCapture(l.pointerId);
1170
1185
  } catch {
1171
1186
  }
1172
- p.current = null;
1187
+ g.current = null;
1173
1188
  }
1174
- o(null);
1175
- }, []), x = i.useCallback((g) => {
1189
+ r(null);
1190
+ }, []), k = i.useCallback((p) => {
1176
1191
  const l = f.current;
1177
1192
  if (l) {
1178
- if (l.pointerId === g.pointerId && l.target.releasePointerCapture)
1193
+ if (l.pointerId === p.pointerId && l.target.releasePointerCapture)
1179
1194
  try {
1180
1195
  l.target.releasePointerCapture(l.pointerId);
1181
1196
  } catch {
@@ -1186,19 +1201,19 @@ const Ie = {
1186
1201
  }, []);
1187
1202
  tt(n !== null, {
1188
1203
  onMove: F,
1189
- onUp: L,
1190
- onCancel: L
1191
- }), tt(r !== null, {
1204
+ onUp: M,
1205
+ onCancel: M
1206
+ }), tt(o !== null, {
1192
1207
  onMove: T,
1193
- onUp: x,
1194
- onCancel: x
1208
+ onUp: k,
1209
+ onCancel: k
1195
1210
  });
1196
1211
  const y = i.useCallback(
1197
- (g) => {
1198
- const l = an(g), b = H(g);
1212
+ (p) => {
1213
+ const l = dn(p), b = H(p);
1199
1214
  if (!b || b.draggable !== !0)
1200
1215
  return l;
1201
- const v = c[g.id], S = n === g.id, R = r === g.id, C = v ? { transform: `translate(${v.x}px, ${v.y}px)` } : {}, k = a[g.id], A = V(g) ? U(g) : null, O = k ?? A, Z = O ? { width: `${O.width}px`, height: `${O.height}px` } : {};
1216
+ const v = c[p.id], S = n === p.id, R = o === p.id, C = v ? { transform: `translate(${v.x}px, ${v.y}px)` } : {}, x = a[p.id], A = V(p) ? U(p) : null, O = x ?? A, Z = O ? { width: `${O.width}px`, height: `${O.height}px` } : {};
1202
1217
  return {
1203
1218
  ...l,
1204
1219
  ...Z,
@@ -1206,20 +1221,20 @@ const Ie = {
1206
1221
  ...S || R ? { cursor: "grabbing" } : {}
1207
1222
  };
1208
1223
  },
1209
- [n, c, a, r]
1224
+ [n, c, a, o]
1210
1225
  ), I = i.useCallback(
1211
- (g) => {
1212
- if (!V(g))
1226
+ (p) => {
1227
+ if (!V(p))
1213
1228
  return { isResizable: !1 };
1214
- const b = a[g.id], v = U(g);
1215
- return (b ?? v) !== null ? { isResizable: !0, onPointerDown: (k, A) => {
1216
- D(g.id, k, A);
1229
+ const b = a[p.id], v = U(p);
1230
+ return (b ?? v) !== null ? { isResizable: !0, onPointerDown: (x, A) => {
1231
+ L(p.id, x, A);
1217
1232
  } } : { isResizable: !1 };
1218
1233
  },
1219
- [D, a]
1234
+ [L, a]
1220
1235
  ), rt = i.useCallback(
1221
- (g) => {
1222
- const { isResizable: l, onPointerDown: b } = I(g), v = y(g), S = r === g.id;
1236
+ (p) => {
1237
+ const { isResizable: l, onPointerDown: b } = I(p), v = y(p), S = o === p.id;
1223
1238
  return {
1224
1239
  style: v,
1225
1240
  isResizable: l,
@@ -1229,15 +1244,15 @@ const Ie = {
1229
1244
  }
1230
1245
  };
1231
1246
  },
1232
- [y, I, r]
1247
+ [y, I, o]
1233
1248
  ), ot = i.useCallback(
1234
- (g) => ({
1249
+ (p) => ({
1235
1250
  "data-drag-handle": "true",
1236
1251
  role: "button",
1237
1252
  "aria-roledescription": "Drag handle",
1238
1253
  "aria-label": "Drag layer",
1239
1254
  onPointerDown: (l) => {
1240
- P(g, l);
1255
+ P(p, l);
1241
1256
  }
1242
1257
  }),
1243
1258
  [P]
@@ -1252,34 +1267,34 @@ const Ie = {
1252
1267
  [ot, rt, z]
1253
1268
  ),
1254
1269
  draggingLayerId: n,
1255
- resizingLayerId: r
1270
+ resizingLayerId: o
1256
1271
  };
1257
- }, bn = (t) => {
1272
+ }, Sn = (t) => {
1258
1273
  if (typeof t.width == "number" && typeof t.height == "number")
1259
1274
  return { width: t.width, height: t.height };
1260
- }, wn = {
1275
+ }, Cn = {
1261
1276
  display: "grid",
1262
1277
  width: "100%",
1263
1278
  height: "100%"
1264
- }, vn = {
1279
+ }, zn = {
1265
1280
  touchAction: "none",
1266
1281
  WebkitTouchCallout: "none",
1267
1282
  WebkitUserSelect: "none",
1268
1283
  userSelect: "none"
1269
- }, Tn = ({ config: t, layers: e, style: n }) => {
1270
- const o = i.useRef(null), { isIntersecting: r } = Qt(o, { threshold: 0 });
1271
- return /* @__PURE__ */ m(ge, { config: t, layers: e, style: n, children: /* @__PURE__ */ m(En, { gridRef: o, isIntersecting: r }) });
1272
- }, En = ({ gridRef: t, isIntersecting: e }) => {
1273
- const { config: n, style: o, layers: r } = pe(), { normalizedLayers: s, visibleLayers: c, regularLayers: u, layerById: a } = _e(n, r.defs), { columnHandles: d, rowHandles: p, gapSizes: f, gridStyle: h, handleResize: w } = je(n, o), { providerValue: E, draggingLayerId: z, resizingLayerId: P } = mn({
1284
+ }, Nn = ({ config: t, layers: e, style: n }) => {
1285
+ const r = i.useRef(null), { isIntersecting: o } = oe(r, { threshold: 0 });
1286
+ return /* @__PURE__ */ h(we, { config: t, layers: e, style: n, children: /* @__PURE__ */ h(Rn, { gridRef: r, isIntersecting: o }) });
1287
+ }, Rn = ({ gridRef: t, isIntersecting: e }) => {
1288
+ const { config: n, style: r, layers: o } = be(), { normalizedLayers: s, visibleLayers: c, regularLayers: u, layerById: a } = We(n, o.defs), { columnHandles: d, rowHandles: g, gapSizes: f, gridStyle: m, handleResize: w } = Je(n, r), { providerValue: E, draggingLayerId: z, resizingLayerId: P } = En({
1274
1289
  layers: s,
1275
1290
  layerById: a
1276
- }), D = z ? !0 : !!P, F = i.useMemo(() => ({
1277
- ...wn,
1278
- ...h,
1279
- ...D ? vn : {}
1280
- }), [h, D]);
1281
- return /* @__PURE__ */ $(G, { children: [
1282
- /* @__PURE__ */ $(
1291
+ }), L = z ? !0 : !!P, F = i.useMemo(() => ({
1292
+ ...Cn,
1293
+ ...m,
1294
+ ...L ? zn : {}
1295
+ }), [m, L]);
1296
+ return /* @__PURE__ */ G(N, { children: [
1297
+ /* @__PURE__ */ G(
1283
1298
  "div",
1284
1299
  {
1285
1300
  ref: t,
@@ -1288,51 +1303,50 @@ const Ie = {
1288
1303
  "data-resizing": !!P,
1289
1304
  "data-visible": e,
1290
1305
  children: [
1291
- /* @__PURE__ */ m(de, { value: E, children: /* @__PURE__ */ m(Re, { layers: u }) }),
1292
- d.map(({ trackIndex: T, align: L, span: x }) => /* @__PURE__ */ m(
1306
+ /* @__PURE__ */ h(me, { value: E, children: /* @__PURE__ */ h(De, { layers: u }) }),
1307
+ d.map(({ trackIndex: T, align: M, span: k }) => /* @__PURE__ */ h(
1293
1308
  ht,
1294
1309
  {
1295
1310
  direction: "col",
1296
1311
  trackIndex: T,
1297
- align: L,
1312
+ align: M,
1298
1313
  gap: f.columnGap,
1299
- span: x,
1314
+ span: k,
1300
1315
  onResize: w
1301
1316
  },
1302
- `col-${T}:${L}`
1317
+ `col-${T}:${M}`
1303
1318
  )),
1304
- p.map(({ trackIndex: T, align: L, span: x }) => /* @__PURE__ */ m(
1319
+ g.map(({ trackIndex: T, align: M, span: k }) => /* @__PURE__ */ h(
1305
1320
  ht,
1306
1321
  {
1307
1322
  direction: "row",
1308
1323
  trackIndex: T,
1309
- align: L,
1324
+ align: M,
1310
1325
  gap: f.rowGap,
1311
- span: x,
1326
+ span: k,
1312
1327
  onResize: w
1313
1328
  },
1314
- `row-${T}:${L}`
1329
+ `row-${T}:${M}`
1315
1330
  ))
1316
1331
  ]
1317
1332
  }
1318
1333
  ),
1319
- /* @__PURE__ */ m(le, { layers: c })
1334
+ /* @__PURE__ */ h(he, { layers: c })
1320
1335
  ] });
1321
1336
  };
1322
1337
  export {
1323
- ie as D,
1324
- Tn as G,
1325
- Ae as R,
1326
- Ln as a,
1327
- fe as b,
1328
- _ as c,
1329
- Te as d,
1330
- Ze as e,
1331
- It as f,
1332
- le as g,
1333
- Dn as h,
1334
- Rt as r,
1335
- Mn as t,
1336
- Le as u
1338
+ de as D,
1339
+ Nn as G,
1340
+ Ge as R,
1341
+ An as a,
1342
+ Lt as b,
1343
+ $ as c,
1344
+ He as d,
1345
+ Qe as e,
1346
+ he as f,
1347
+ kn as g,
1348
+ Pt as r,
1349
+ Hn as t,
1350
+ ke as u
1337
1351
  };
1338
- //# sourceMappingURL=GridLayout-DZCV1X-3.js.map
1352
+ //# sourceMappingURL=GridLayout-CLvW8jID.js.map