react-panel-layout 0.3.0 → 0.4.1

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