react-panel-layout 0.4.2 → 0.5.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.
Files changed (76) hide show
  1. package/dist/FloatingPanelFrame-6W5OexYe.js +98 -0
  2. package/dist/FloatingPanelFrame-6W5OexYe.js.map +1 -0
  3. package/dist/FloatingPanelFrame-D9Cp2al1.cjs +2 -0
  4. package/dist/FloatingPanelFrame-D9Cp2al1.cjs.map +1 -0
  5. package/dist/GridLayout-BzrIDrC9.js +1465 -0
  6. package/dist/GridLayout-BzrIDrC9.js.map +1 -0
  7. package/dist/GridLayout-ZrOhoLLB.cjs +2 -0
  8. package/dist/GridLayout-ZrOhoLLB.cjs.map +1 -0
  9. package/dist/PanelSystemContext.d.ts +9 -0
  10. package/dist/components/grid/GridLayerList.d.ts +3 -0
  11. package/dist/components/grid/GridLayout.d.ts +5 -0
  12. package/dist/components/paneling/FloatingPanelFrame.d.ts +4 -0
  13. package/dist/components/window/FloatingWindow.d.ts +15 -0
  14. package/dist/config/panelRouter.d.ts +2 -2
  15. package/dist/config.cjs +1 -1
  16. package/dist/config.cjs.map +1 -1
  17. package/dist/config.js +1 -1
  18. package/dist/config.js.map +1 -1
  19. package/dist/constants/styles.d.ts +3 -1
  20. package/dist/floating.cjs +1 -1
  21. package/dist/floating.js +1 -1
  22. package/dist/hooks/ContentCacheContext.d.ts +59 -0
  23. package/dist/hooks/useContainerScroll.d.ts +23 -0
  24. package/dist/hooks/useContentCache.d.ts +67 -0
  25. package/dist/hooks/useDocumentScroll.d.ts +13 -0
  26. package/dist/hooks/useScrollContainer.d.ts +21 -0
  27. package/dist/index.cjs +2 -2
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +4 -1
  30. package/dist/index.js +950 -878
  31. package/dist/index.js.map +1 -1
  32. package/dist/modules/grid/GridLayoutContext.d.ts +5 -0
  33. package/dist/modules/grid/resizeHandles.d.ts +14 -0
  34. package/dist/modules/grid/trackUtils.d.ts +29 -0
  35. package/dist/modules/grid/useGridTracks.d.ts +6 -15
  36. package/dist/modules/grid/useLayerInteractions.d.ts +2 -1
  37. package/dist/modules/window/useFloatingState.d.ts +9 -0
  38. package/dist/pivot.cjs +1 -1
  39. package/dist/pivot.js +1 -1
  40. package/dist/sticky-header/StickyHeader.d.ts +53 -0
  41. package/dist/sticky-header/index.d.ts +7 -0
  42. package/dist/sticky-header/types.d.ts +50 -0
  43. package/dist/sticky-header.cjs +2 -0
  44. package/dist/sticky-header.cjs.map +1 -0
  45. package/dist/sticky-header.js +198 -0
  46. package/dist/sticky-header.js.map +1 -0
  47. package/dist/styles-CA2_zLZt.js +52 -0
  48. package/dist/{styles-DcG3aIFx.cjs.map → styles-CA2_zLZt.js.map} +1 -1
  49. package/dist/styles-PsqGOEJP.cjs +2 -0
  50. package/dist/styles-PsqGOEJP.cjs.map +1 -0
  51. package/dist/types.d.ts +79 -4
  52. package/dist/useIsomorphicLayoutEffect-DGRNF4Lf.cjs +2 -0
  53. package/dist/useIsomorphicLayoutEffect-DGRNF4Lf.cjs.map +1 -0
  54. package/dist/useIsomorphicLayoutEffect-DhmEnmZ_.js +6 -0
  55. package/dist/useIsomorphicLayoutEffect-DhmEnmZ_.js.map +1 -0
  56. package/dist/usePivot-BS-DGfwd.cjs +2 -0
  57. package/dist/usePivot-BS-DGfwd.cjs.map +1 -0
  58. package/dist/usePivot-BvOGxLQQ.js +124 -0
  59. package/dist/usePivot-BvOGxLQQ.js.map +1 -0
  60. package/dist/utils/css.d.ts +19 -0
  61. package/package.json +6 -1
  62. package/dist/FloatingPanelFrame-SOrLGjZd.js +0 -67
  63. package/dist/FloatingPanelFrame-SOrLGjZd.js.map +0 -1
  64. package/dist/FloatingPanelFrame-XtBcHANI.cjs +0 -2
  65. package/dist/FloatingPanelFrame-XtBcHANI.cjs.map +0 -1
  66. package/dist/GridLayout-CLvW8jID.js +0 -1352
  67. package/dist/GridLayout-CLvW8jID.js.map +0 -1
  68. package/dist/GridLayout-qufTyOQM.cjs +0 -2
  69. package/dist/GridLayout-qufTyOQM.cjs.map +0 -1
  70. package/dist/styles-DcG3aIFx.cjs +0 -2
  71. package/dist/styles-w0ZixggV.js +0 -51
  72. package/dist/styles-w0ZixggV.js.map +0 -1
  73. package/dist/usePivot-C8q0pMgW.cjs +0 -2
  74. package/dist/usePivot-C8q0pMgW.cjs.map +0 -1
  75. package/dist/usePivot-z9gumDf-.js +0 -97
  76. package/dist/usePivot-z9gumDf-.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,24 +1,25 @@
1
- import { u as Dt, a as At, b as kt, c as J, d as Mt, e as M, t as _t, R as ot, G as st } from "./GridLayout-CLvW8jID.js";
2
- import { D as Rr, f as Pr, r as Dr, g as Ar } from "./GridLayout-CLvW8jID.js";
1
+ import { u as kt, a as Mt, b as _t, c as J, d as Ot, e as M, t as Bt, R as ot, G as st } from "./GridLayout-BzrIDrC9.js";
2
+ import { D as _n, f as On, F as Bn, r as Ln, g as Hn } from "./GridLayout-BzrIDrC9.js";
3
3
  import { jsx as m, jsxs as H, Fragment as et } from "react/jsx-runtime";
4
- import * as l from "react";
5
- import { t as Ot, u as Bt, v as Lt, H as Ht, y as Nt, z as $t, A as zt, B as Xt, E as Yt, I as Ft, T as jt, J as Kt, K as Vt, L as Ut, M as Wt, N as qt, O as Zt, S as Jt } from "./styles-w0ZixggV.js";
6
- import { Q as Mr } from "./styles-w0ZixggV.js";
7
- import { a as rt } from "./usePivot-z9gumDf-.js";
8
- import { createPortal as Qt } from "react-dom";
9
- const te = (t) => ({
10
- width: Ht,
4
+ import * as u from "react";
5
+ import { u as Lt, v as Ht, w as Nt, H as zt, z as $t, A as Ft, B as Xt, E as Yt, I as jt, J as Ut, T as Kt, K as Vt, L as Wt, M as qt, N as Zt, O as Jt, Q as Qt, S as te } from "./styles-CA2_zLZt.js";
6
+ import { U as zn } from "./styles-CA2_zLZt.js";
7
+ import { u as nt } from "./useIsomorphicLayoutEffect-DhmEnmZ_.js";
8
+ import { createPortal as ee } from "react-dom";
9
+ import { a as ne } from "./usePivot-BvOGxLQQ.js";
10
+ const re = (t) => ({
11
+ width: zt,
11
12
  cursor: "col-resize",
12
13
  position: "relative",
13
14
  userSelect: "none",
14
- backgroundColor: t === "drag" ? Ot : t === "hover" ? Bt : Lt
15
- }), Tr = ({ onResize: t, component: e, element: r }) => {
16
- const { ref: n, isDragging: o, onPointerDown: s } = Dt({
15
+ backgroundColor: t === "drag" ? Lt : t === "hover" ? Ht : Nt
16
+ }), En = ({ onResize: t, component: e, element: n }) => {
17
+ const { ref: r, isDragging: o, onPointerDown: s } = kt({
17
18
  axis: "x",
18
19
  onResize: t
19
- }), [a, i] = l.useState(!1), c = {
20
- ref: n,
21
- style: te(o ? "drag" : a ? "hover" : "idle"),
20
+ }), [a, i] = u.useState(!1), c = {
21
+ ref: r,
22
+ style: re(o ? "drag" : a ? "hover" : "idle"),
22
23
  role: "separator",
23
24
  "aria-orientation": "vertical",
24
25
  "data-dragging": o ? "true" : void 0,
@@ -26,78 +27,146 @@ const te = (t) => ({
26
27
  onPointerEnter: () => i(!0),
27
28
  onPointerLeave: () => i(!1)
28
29
  };
29
- return r ? l.cloneElement(r, c) : e ? /* @__PURE__ */ m(e, { ...c }) : /* @__PURE__ */ m("div", { ...c });
30
- }, xr = () => {
31
- const { layerId: t } = At(), { getLayerHandleProps: e } = kt();
32
- return l.useMemo(() => e(t), [e, t]);
33
- }, dt = l.createContext(null), ee = () => {
34
- const t = l.useContext(dt);
30
+ return n ? u.cloneElement(n, c) : e ? /* @__PURE__ */ m(e, { ...c }) : /* @__PURE__ */ m("div", { ...c });
31
+ }, Rn = () => {
32
+ const { layerId: t } = Mt(), { getLayerHandleProps: e } = _t();
33
+ return u.useMemo(() => e(t), [e, t]);
34
+ }, it = { left: 0, top: 0 }, at = { width: 400, height: 300 }, Pn = (t) => {
35
+ const [e, n] = u.useState(() => {
36
+ const l = {};
37
+ return t.forEach((p) => {
38
+ if (p.floating) {
39
+ const g = p.floating;
40
+ l[p.id] = {
41
+ position: g.defaultPosition ?? it,
42
+ size: g.defaultSize ?? at
43
+ };
44
+ }
45
+ }), l;
46
+ }), r = u.useMemo(() => {
47
+ const l = /* @__PURE__ */ new Map();
48
+ return t.forEach((p) => l.set(p.id, p)), l;
49
+ }, [t]), o = u.useCallback(
50
+ (l) => {
51
+ const p = r.get(l);
52
+ return p?.floating?.position !== void 0 ? p.floating.position : e[l]?.position ?? it;
53
+ },
54
+ [r, e]
55
+ ), s = u.useCallback(
56
+ (l) => {
57
+ const p = r.get(l);
58
+ return p?.floating?.size !== void 0 ? p.floating.size : e[l]?.size ?? at;
59
+ },
60
+ [r, e]
61
+ ), a = u.useCallback(
62
+ (l) => r.get(l)?.floating?.zIndex,
63
+ [r]
64
+ ), i = u.useCallback(
65
+ (l, p) => {
66
+ const g = r.get(l);
67
+ g?.floating && (g.floating.position === void 0 && n((v) => {
68
+ const b = v[l];
69
+ return b ? {
70
+ ...v,
71
+ [l]: { ...b, position: p }
72
+ } : v;
73
+ }), g.floating.onMove?.(p));
74
+ },
75
+ [r]
76
+ ), c = u.useCallback(
77
+ (l, p) => {
78
+ const g = r.get(l);
79
+ g?.floating && (g.floating.size === void 0 && n((v) => {
80
+ const b = v[l];
81
+ return b ? {
82
+ ...v,
83
+ [l]: { ...b, size: p }
84
+ } : v;
85
+ }), g.floating.onResize?.(p));
86
+ },
87
+ [r]
88
+ ), d = u.useCallback(
89
+ (l) => {
90
+ r.get(l)?.floating?.onClose?.();
91
+ },
92
+ [r]
93
+ );
94
+ return {
95
+ getPosition: o,
96
+ getSize: s,
97
+ getZIndex: a,
98
+ updatePosition: i,
99
+ updateSize: c,
100
+ close: d
101
+ };
102
+ }, ft = u.createContext(null), oe = () => {
103
+ const t = u.useContext(ft);
35
104
  if (!t)
36
105
  throw new Error("useKeybindings must be used within KeybindingsProvider");
37
106
  return t;
38
- }, re = (t) => {
107
+ }, se = (t) => {
39
108
  const e = [];
40
109
  t.metaKey && e.push("Mod"), t.ctrlKey && e.push("Ctrl"), t.altKey && e.push("Alt"), t.shiftKey && e.push("Shift");
41
- const r = t.key.length === 1 ? t.key.toUpperCase() : t.key;
42
- return e.push(r), e.join("-");
43
- }, ne = ({ children: t, configure: e }) => {
44
- const r = l.useRef({}), n = l.useCallback((a, i) => {
45
- r.current = { ...r.current, [a]: i };
46
- }, []), o = l.useCallback((a) => {
47
- const i = { ...r.current };
48
- delete i[a], r.current = i;
110
+ const n = t.key.length === 1 ? t.key.toUpperCase() : t.key;
111
+ return e.push(n), e.join("-");
112
+ }, ie = ({ children: t, configure: e }) => {
113
+ const n = u.useRef({}), r = u.useCallback((a, i) => {
114
+ n.current = { ...n.current, [a]: i };
115
+ }, []), o = u.useCallback((a) => {
116
+ const i = { ...n.current };
117
+ delete i[a], n.current = i;
49
118
  }, []);
50
- l.useEffect(() => {
119
+ u.useEffect(() => {
51
120
  const a = (i) => {
52
- const c = re(i), u = r.current[c];
53
- u && u(i);
121
+ const c = se(i), d = n.current[c];
122
+ d && d(i);
54
123
  };
55
124
  return window.addEventListener("keydown", a), () => {
56
125
  window.removeEventListener("keydown", a);
57
126
  };
58
127
  }, []);
59
- const s = l.useMemo(() => ({ register: n, unregister: o }), [n, o]);
60
- return l.useEffect(() => {
128
+ const s = u.useMemo(() => ({ register: r, unregister: o }), [r, o]);
129
+ return u.useEffect(() => {
61
130
  e && e(s);
62
- }, [s, e]), /* @__PURE__ */ m(dt.Provider, { value: s, children: t });
63
- }, oe = (t, e) => {
64
- t.register("Mod-\\", (r) => {
65
- r.preventDefault(), e.splitFocused("vertical");
66
- }), t.register("Mod-Shift-\\", (r) => {
67
- r.preventDefault(), e.splitFocused("horizontal");
131
+ }, [s, e]), /* @__PURE__ */ m(ft.Provider, { value: s, children: t });
132
+ }, ae = (t, e) => {
133
+ t.register("Mod-\\", (n) => {
134
+ n.preventDefault(), e.splitFocused("vertical");
135
+ }), t.register("Mod-Shift-\\", (n) => {
136
+ n.preventDefault(), e.splitFocused("horizontal");
68
137
  });
69
- for (const r of [1, 2, 3, 4, 5, 6, 7, 8, 9])
70
- t.register(`Mod-${String(r)}`, (n) => {
71
- n.preventDefault(), e.focusGroupIndex(r);
138
+ for (const n of [1, 2, 3, 4, 5, 6, 7, 8, 9])
139
+ t.register(`Mod-${String(n)}`, (r) => {
140
+ r.preventDefault(), e.focusGroupIndex(n);
72
141
  });
73
- t.register("Alt-ArrowRight", (r) => {
74
- r.preventDefault(), e.focusNextGroup();
75
- }), t.register("Alt-ArrowLeft", (r) => {
76
- r.preventDefault(), e.focusPrevGroup();
142
+ t.register("Alt-ArrowRight", (n) => {
143
+ n.preventDefault(), e.focusNextGroup();
144
+ }), t.register("Alt-ArrowLeft", (n) => {
145
+ n.preventDefault(), e.focusPrevGroup();
77
146
  });
78
- }, se = (t) => t.type === "group", pt = (t, e = { x: 0, y: 0, w: 100, h: 100 }) => {
79
- const r = /* @__PURE__ */ new Map(), n = (o, s) => {
80
- if (se(o)) {
81
- r.set(o.groupId, s);
147
+ }, ce = (t) => t.type === "group", gt = (t, e = { x: 0, y: 0, w: 100, h: 100 }) => {
148
+ const n = /* @__PURE__ */ new Map(), r = (o, s) => {
149
+ if (ce(o)) {
150
+ n.set(o.groupId, s);
82
151
  return;
83
152
  }
84
153
  if (o.direction === "vertical") {
85
- const c = s.w * o.ratio, u = s.w - c;
86
- n(o.a, { x: s.x, y: s.y, w: c, h: s.h }), n(o.b, { x: s.x + c, y: s.y, w: u, h: s.h });
154
+ const c = s.w * o.ratio, d = s.w - c;
155
+ r(o.a, { x: s.x, y: s.y, w: c, h: s.h }), r(o.b, { x: s.x + c, y: s.y, w: d, h: s.h });
87
156
  return;
88
157
  }
89
158
  const a = s.h * o.ratio, i = s.h - a;
90
- n(o.a, { x: s.x, y: s.y, w: s.w, h: a }), n(o.b, { x: s.x, y: s.y + a, w: s.w, h: i });
159
+ r(o.a, { x: s.x, y: s.y, w: s.w, h: a }), r(o.b, { x: s.x, y: s.y + a, w: s.w, h: i });
91
160
  };
92
- return n(t, e), r;
93
- }, ie = (t, e) => {
94
- const r = pt(t.tree), n = {
161
+ return r(t, e), n;
162
+ }, ue = (t, e) => {
163
+ const n = gt(t.tree), r = {
95
164
  areas: [["root"]],
96
165
  rows: [{ size: "1fr" }],
97
166
  columns: [{ size: "1fr" }],
98
167
  gap: "0px",
99
168
  style: { position: "relative" }
100
- }, o = Array.from(r.entries()).map(([s, a]) => {
169
+ }, o = Array.from(n.entries()).map(([s, a]) => {
101
170
  const i = {
102
171
  position: "absolute",
103
172
  left: `${a.x}%`,
@@ -115,167 +184,167 @@ const te = (t) => ({
115
184
  component: e(s)
116
185
  };
117
186
  });
118
- return { config: n, layers: o };
119
- }, ae = (t, e, r) => {
120
- const n = pt(t.tree), o = Array.from(new Set(Array.from(n.values()).flatMap((h) => [h.x, h.x + h.w]))).sort((h, w) => h - w), s = Array.from(new Set(Array.from(n.values()).flatMap((h) => [h.y, h.y + h.h]))).sort((h, w) => h - w), a = o.slice(1).map((h, w) => `${h - o[w]}fr`), i = s.slice(1).map((h, w) => `${h - s[w]}fr`), c = a.map((h) => ({ size: h, resizable: r })), u = i.map((h) => ({ size: h, resizable: r })), d = (h, w, I, T) => {
121
- for (const [b, v] of n.entries())
122
- if (h >= v.x && w <= v.x + v.w && I >= v.y && T <= v.y + v.h)
123
- return b;
187
+ return { config: r, layers: o };
188
+ }, le = (t, e, n) => {
189
+ const r = gt(t.tree), o = Array.from(new Set(Array.from(r.values()).flatMap((b) => [b.x, b.x + b.w]))).sort((b, I) => b - I), s = Array.from(new Set(Array.from(r.values()).flatMap((b) => [b.y, b.y + b.h]))).sort((b, I) => b - I), a = o.slice(1).map((b, I) => `${b - o[I]}fr`), i = s.slice(1).map((b, I) => `${b - s[I]}fr`), c = a.map((b) => ({ size: b, resizable: n })), d = i.map((b) => ({ size: b, resizable: n })), l = (b, I, w, T) => {
190
+ for (const [h, y] of r.entries())
191
+ if (b >= y.x && I <= y.x + y.w && w >= y.y && T <= y.y + y.h)
192
+ return h;
124
193
  return ".";
125
- }, f = [];
126
- for (let h = 0; h < s.length - 1; h += 1) {
127
- const w = [];
128
- for (let I = 0; I < o.length - 1; I += 1)
129
- w.push(d(o[I], o[I + 1], s[h], s[h + 1]));
130
- f.push(w);
194
+ }, p = [];
195
+ for (let b = 0; b < s.length - 1; b += 1) {
196
+ const I = [];
197
+ for (let w = 0; w < o.length - 1; w += 1)
198
+ I.push(l(o[w], o[w + 1], s[b], s[b + 1]));
199
+ p.push(I);
131
200
  }
132
201
  const g = {
133
- areas: f,
134
- rows: u,
202
+ areas: p,
203
+ rows: d,
135
204
  columns: c,
136
205
  gap: "0px"
137
- }, y = Array.from(n.keys()).map((h) => ({
138
- id: h,
139
- gridArea: h,
140
- component: e(h)
206
+ }, v = Array.from(r.keys()).map((b) => ({
207
+ id: b,
208
+ gridArea: b,
209
+ component: e(b)
141
210
  }));
142
- return { config: g, layers: y };
143
- }, ft = l.createContext(null), ce = () => {
144
- const t = l.useContext(ft);
211
+ return { config: g, layers: v };
212
+ }, bt = u.createContext(null), de = () => {
213
+ const t = u.useContext(bt);
145
214
  if (!t)
146
215
  throw new Error("usePanelRenderContext must be used within PanelRenderProvider");
147
216
  return t;
148
- }, ue = ({ value: t, children: e }) => /* @__PURE__ */ m(ft.Provider, { value: t, children: e }), bt = l.createContext(null), gt = () => {
149
- const t = l.useContext(bt);
217
+ }, pe = ({ value: t, children: e }) => /* @__PURE__ */ m(bt.Provider, { value: t, children: e }), ht = u.createContext(null), mt = () => {
218
+ const t = u.useContext(ht);
150
219
  if (!t)
151
220
  throw new Error("useDomRegistry must be used within DomRegistryProvider");
152
221
  return t;
153
- }, le = ({ children: t }) => {
154
- const e = l.useRef(/* @__PURE__ */ new Map()), r = l.useCallback((c) => {
155
- const u = e.current.get(c);
156
- if (u)
157
- return u;
158
- const d = { group: null, tabbar: null, content: null };
159
- return e.current.set(c, d), d;
160
- }, []), n = l.useCallback(
161
- (c, u) => {
162
- const d = r(c);
163
- if (d.group = u, u === null) {
164
- const f = e.current.get(c);
165
- (f ? f.tabbar === null && f.content === null : !1) && e.current.delete(c);
222
+ }, fe = ({ children: t }) => {
223
+ const e = u.useRef(/* @__PURE__ */ new Map()), n = u.useCallback((c) => {
224
+ const d = e.current.get(c);
225
+ if (d)
226
+ return d;
227
+ const l = { group: null, tabbar: null, content: null };
228
+ return e.current.set(c, l), l;
229
+ }, []), r = u.useCallback(
230
+ (c, d) => {
231
+ const l = n(c);
232
+ if (l.group = d, d === null) {
233
+ const p = e.current.get(c);
234
+ (p ? p.tabbar === null && p.content === null : !1) && e.current.delete(c);
166
235
  }
167
236
  },
168
- [r]
169
- ), o = l.useCallback(
170
- (c, u) => {
171
- const d = r(c);
172
- if (d.tabbar = u, u === null) {
173
- const f = e.current.get(c);
174
- (f ? f.group === null && f.content === null : !1) && e.current.delete(c);
237
+ [n]
238
+ ), o = u.useCallback(
239
+ (c, d) => {
240
+ const l = n(c);
241
+ if (l.tabbar = d, d === null) {
242
+ const p = e.current.get(c);
243
+ (p ? p.group === null && p.content === null : !1) && e.current.delete(c);
175
244
  }
176
245
  },
177
- [r]
178
- ), s = l.useCallback(
179
- (c, u) => {
180
- const d = r(c);
181
- if (d.content = u, u === null) {
182
- const f = e.current.get(c);
183
- (f ? f.group === null && f.tabbar === null : !1) && e.current.delete(c);
246
+ [n]
247
+ ), s = u.useCallback(
248
+ (c, d) => {
249
+ const l = n(c);
250
+ if (l.content = d, d === null) {
251
+ const p = e.current.get(c);
252
+ (p ? p.group === null && p.tabbar === null : !1) && e.current.delete(c);
184
253
  }
185
254
  },
186
- [r]
187
- ), a = l.useCallback(() => e.current, []), i = l.useMemo(() => ({ setGroupEl: n, setTabbarEl: o, setContentEl: s, getAll: a }), [n, o, s, a]);
188
- return /* @__PURE__ */ m(bt.Provider, { value: i, children: t });
189
- }, de = {
255
+ [n]
256
+ ), a = u.useCallback(() => e.current, []), i = u.useMemo(() => ({ setGroupEl: r, setTabbarEl: o, setContentEl: s, getAll: a }), [r, o, s, a]);
257
+ return /* @__PURE__ */ m(ht.Provider, { value: i, children: t });
258
+ }, ge = {
190
259
  display: "flex",
191
260
  flexDirection: "column",
192
261
  width: "100%",
193
262
  height: "100%"
194
- }, pe = {
263
+ }, be = {
195
264
  flex: "1 1 auto",
196
265
  minWidth: 0,
197
266
  minHeight: 0,
198
267
  position: "relative",
199
268
  overflow: "hidden"
200
269
  };
201
- function fe(t, e, r, n) {
202
- return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
270
+ function he(t, e, n, r) {
271
+ return t ? u.cloneElement(t, n, r) : e ? /* @__PURE__ */ m(e, { ...n, children: r }) : /* @__PURE__ */ m("div", { ...n, children: r });
203
272
  }
204
- function be(t, e, r, n) {
205
- return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
273
+ function me(t, e, n, r) {
274
+ return t ? u.cloneElement(t, n, r) : e ? /* @__PURE__ */ m(e, { ...n, children: r }) : /* @__PURE__ */ m("div", { ...n, children: r });
206
275
  }
207
- const ge = ({
276
+ const ve = ({
208
277
  group: t,
209
278
  tabbar: e,
210
- content: r,
211
- onContentPointerDown: n,
279
+ content: n,
280
+ onContentPointerDown: r,
212
281
  groupRef: o,
213
282
  contentRef: s,
214
283
  component: a,
215
284
  element: i,
216
285
  contentComponent: c,
217
- contentElement: u
286
+ contentElement: d
218
287
  }) => {
219
- const d = {
288
+ const l = {
220
289
  ref: o,
221
- style: de,
290
+ style: ge,
222
291
  "data-group-id": t.id
223
- }, g = fe(u, c, {
292
+ }, g = he(d, c, {
224
293
  ref: s,
225
- style: pe,
294
+ style: be,
226
295
  "data-dnd-zone": "content",
227
- onPointerDown: n
228
- }, r);
229
- return be(i, a, d, /* @__PURE__ */ H(et, { children: [
296
+ onPointerDown: r
297
+ }, n);
298
+ return me(i, a, l, /* @__PURE__ */ H(et, { children: [
230
299
  e,
231
300
  g
232
301
  ] }));
233
- }, ht = l.memo(ge, (t, e) => t.group.id !== e.group.id || t.group.activeTabId !== e.group.activeTabId || t.group.tabs.length !== e.group.tabs.length ? !1 : t.group.tabs === e.group.tabs);
234
- ht.displayName = "PanelGroupView";
235
- const K = (t, e, r) => {
236
- const n = t.left, o = t.top, s = t.width, a = t.height, i = e - n, c = r - o, u = s / 3, d = a / 3;
237
- return i > u && i < s - u && c > d && c < a - d ? "center" : i < c && i < s - i && c < a - c ? "left" : s - i < c && s - i < i && c < a - c ? "right" : c < i && c < a - c && i < s - i ? "top" : "bottom";
302
+ }, vt = u.memo(ve, (t, e) => t.group.id !== e.group.id || t.group.activeTabId !== e.group.activeTabId || t.group.tabs.length !== e.group.tabs.length ? !1 : t.group.tabs === e.group.tabs);
303
+ vt.displayName = "PanelGroupView";
304
+ const U = (t, e, n) => {
305
+ const r = t.left, o = t.top, s = t.width, a = t.height, i = e - r, c = n - o, d = s / 3, l = a / 3;
306
+ return i > d && i < s - d && c > l && c < a - l ? "center" : i < c && i < s - i && c < a - c ? "left" : s - i < c && s - i < i && c < a - c ? "right" : c < i && c < a - c && i < s - i ? "top" : "bottom";
238
307
  };
239
308
  function A(t, e) {
240
309
  if (!e) {
241
- const n = (() => ({ type: t }));
242
- return Object.defineProperty(n, "type", {
310
+ const r = (() => ({ type: t }));
311
+ return Object.defineProperty(r, "type", {
243
312
  value: t,
244
313
  writable: !1,
245
314
  enumerable: !0
246
- }), n;
315
+ }), r;
247
316
  }
248
- const r = ((...n) => {
249
- const o = e(...n);
317
+ const n = ((...r) => {
318
+ const o = e(...r);
250
319
  return typeof o > "u" ? { type: t } : { type: t, payload: o };
251
320
  });
252
- return Object.defineProperty(r, "type", {
321
+ return Object.defineProperty(n, "type", {
253
322
  value: t,
254
323
  writable: !1,
255
324
  enumerable: !0
256
- }), r;
325
+ }), n;
257
326
  }
258
- const he = (t, e) => {
259
- const r = {};
260
- return Object.keys(t).forEach((n) => {
261
- const o = t[n];
262
- r[n] = ((...s) => {
327
+ const Ie = (t, e) => {
328
+ const n = {};
329
+ return Object.keys(t).forEach((r) => {
330
+ const o = t[r];
331
+ n[r] = ((...s) => {
263
332
  const a = o(...s);
264
333
  return e(a), a;
265
334
  });
266
- }), r;
267
- }, mt = (t, e) => {
268
- const r = {};
269
- return Object.keys(e).forEach((n) => {
270
- const o = e[n];
335
+ }), n;
336
+ }, It = (t, e) => {
337
+ const n = {};
338
+ return Object.keys(e).forEach((r) => {
339
+ const o = e[r];
271
340
  if (!o)
272
341
  return;
273
- const s = t[n];
342
+ const s = t[r];
274
343
  if (!s)
275
- throw new Error(`Missing action creator for key "${String(n)}"`);
276
- r[s.type] = o;
277
- }), r;
278
- }, vt = { phase: { kind: "idle" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null }, D = {
344
+ throw new Error(`Missing action creator for key "${String(r)}"`);
345
+ n[s.type] = o;
346
+ }), n;
347
+ }, wt = { phase: { kind: "idle" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null }, D = {
279
348
  startContent: A(
280
349
  "START_CONTENT",
281
350
  (t) => t
@@ -291,7 +360,7 @@ const he = (t, e) => {
291
360
  (t) => t
292
361
  ),
293
362
  reset: A("RESET")
294
- }, me = mt(D, {
363
+ }, we = It(D, {
295
364
  startContent: (t, e) => ({
296
365
  phase: {
297
366
  kind: "content",
@@ -323,322 +392,322 @@ const he = (t, e) => {
323
392
  setSuggest: (t, e) => ({ ...t, suggest: e.payload }),
324
393
  setPointer: (t, e) => ({ ...t, pointer: e.payload }),
325
394
  setTabbarHover: (t, e) => ({ ...t, tabbarHover: e.payload }),
326
- reset: () => vt
327
- }), ve = (t, e) => {
328
- const r = me[e.type];
329
- return r ? r(t, e, void 0) : t;
330
- }, It = l.createContext(null), W = () => {
331
- const t = l.useContext(It);
395
+ reset: () => wt
396
+ }), ye = (t, e) => {
397
+ const n = we[e.type];
398
+ return n ? n(t, e, void 0) : t;
399
+ }, yt = u.createContext(null), W = () => {
400
+ const t = u.useContext(yt);
332
401
  if (!t)
333
402
  throw new Error("usePanelInteractions must be used within InteractionsProvider");
334
403
  return t;
335
- }, Ie = ({
404
+ }, Te = ({
336
405
  containerRef: t,
337
406
  dragThresholdPx: e,
338
- onCommitContentDrop: r,
339
- onCommitTabDrop: n,
407
+ onCommitContentDrop: n,
408
+ onCommitTabDrop: r,
340
409
  isContentZoneAllowed: o,
341
410
  children: s
342
411
  }) => {
343
- const [a, i] = l.useReducer(ve, vt), c = gt(), u = l.useCallback(() => {
344
- const I = Array.from(c.getAll().entries()), T = I.map(([p, x]) => ({ gid: p, el: x.content ?? x.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), b = I.map(([p, x]) => ({ gid: p, el: x.tabbar })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), v = I.map(([p, x]) => ({ gid: p, el: x.content ?? x.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() }));
345
- return { groups: T, tabbars: b, contents: v };
346
- }, [c]), d = J((I) => {
412
+ const [a, i] = u.useReducer(ye, wt), c = mt(), d = u.useCallback(() => {
413
+ const w = Array.from(c.getAll().entries()), T = w.map(([f, S]) => ({ gid: f, el: S.content ?? S.group })).filter((f) => !!f.el).map((f) => ({ ...f, rect: f.el.getBoundingClientRect() })), h = w.map(([f, S]) => ({ gid: f, el: S.tabbar })).filter((f) => !!f.el).map((f) => ({ ...f, rect: f.el.getBoundingClientRect() })), y = w.map(([f, S]) => ({ gid: f, el: S.content ?? S.group })).filter((f) => !!f.el).map((f) => ({ ...f, rect: f.el.getBoundingClientRect() }));
414
+ return { groups: T, tabbars: h, contents: y };
415
+ }, [c]), l = J((w) => {
347
416
  if (!t.current)
348
417
  return;
349
- const b = I.clientX, v = I.clientY, p = a.phase;
350
- if (p.kind === "idle")
418
+ const h = w.clientX, y = w.clientY, f = a.phase;
419
+ if (f.kind === "idle")
351
420
  return;
352
- const x = Math.abs(b - p.startX), E = Math.abs(v - p.startY);
353
- if (x < e && E < e) {
421
+ const S = Math.abs(h - f.startX), C = Math.abs(y - f.startY);
422
+ if (S < e && C < e) {
354
423
  a.phase.kind === "content" && i(D.setSuggest(null)), i(D.setPointer(null)), i(D.setTabbarHover(null));
355
424
  return;
356
425
  }
357
- if (i(D.setPointer({ x: b, y: v })), p.kind === "content") {
358
- const S = p.cache.groups.find(({ rect: G }) => b >= G.left && b <= G.right && v >= G.top && v <= G.bottom);
359
- if (!S) {
426
+ if (i(D.setPointer({ x: h, y })), f.kind === "content") {
427
+ const G = f.cache.groups.find(({ rect: x }) => h >= x.left && h <= x.right && y >= x.top && y <= x.bottom);
428
+ if (!G) {
360
429
  i(D.setSuggest(null));
361
430
  return;
362
431
  }
363
- const R = K(S.rect, b, v);
364
- if (o && !o({ targetGroupId: S.gid, zone: R })) {
432
+ const R = U(G.rect, h, y);
433
+ if (o && !o({ targetGroupId: G.gid, zone: R })) {
365
434
  i(D.setSuggest(null));
366
435
  return;
367
436
  }
368
- i(D.setSuggest({ rect: S.rect, zone: R }));
437
+ i(D.setSuggest({ rect: G.rect, zone: R }));
369
438
  return;
370
439
  }
371
- if (p.kind === "tab") {
372
- const S = p.cache.tabbars.find(({ rect: C }) => b >= C.left && b <= C.right && v >= C.top && v <= C.bottom);
373
- if (S) {
374
- const k = Array.from(S.el.querySelectorAll("[role='tab']")).map(($) => $.getBoundingClientRect()), P = k.map(($) => $.left + $.width / 2), O = P.findIndex(($) => b < $), B = O === -1 ? P.length : O, Pt = k.length === 0 ? S.rect.left + 8 : B === 0 ? k[0].left : B === k.length ? k[k.length - 1].right : (k[B - 1].right + k[B].left) / 2;
375
- i(D.setTabbarHover({ groupId: S.gid, index: B, rect: S.rect, insertX: Pt }));
440
+ if (f.kind === "tab") {
441
+ const G = f.cache.tabbars.find(({ rect: E }) => h >= E.left && h <= E.right && y >= E.top && y <= E.bottom);
442
+ if (G) {
443
+ const k = Array.from(G.el.querySelectorAll("[role='tab']")).map((z) => z.getBoundingClientRect()), P = k.map((z) => z.left + z.width / 2), O = P.findIndex((z) => h < z), B = O === -1 ? P.length : O, At = k.length === 0 ? G.rect.left + 8 : B === 0 ? k[0].left : B === k.length ? k[k.length - 1].right : (k[B - 1].right + k[B].left) / 2;
444
+ i(D.setTabbarHover({ groupId: G.gid, index: B, rect: G.rect, insertX: At }));
376
445
  } else
377
446
  i(D.setTabbarHover(null));
378
- const R = p.cache.contents.find(({ rect: C }) => b >= C.left && b <= C.right && v >= C.top && v <= C.bottom);
447
+ const R = f.cache.contents.find(({ rect: E }) => h >= E.left && h <= E.right && y >= E.top && y <= E.bottom);
379
448
  if (!R) {
380
449
  i(D.setSuggest(null));
381
450
  return;
382
451
  }
383
- const G = K(R.rect, b, v);
384
- if (o && !o({ targetGroupId: R.gid, zone: G })) {
452
+ const x = U(R.rect, h, y);
453
+ if (o && !o({ targetGroupId: R.gid, zone: x })) {
385
454
  i(D.setSuggest(null));
386
455
  return;
387
456
  }
388
- i(D.setSuggest({ rect: R.rect, zone: G }));
457
+ i(D.setSuggest({ rect: R.rect, zone: x }));
389
458
  }
390
- }), f = J((I) => {
391
- const T = t.current, b = a;
459
+ }), p = J((w) => {
460
+ const T = t.current, h = a;
392
461
  if (i(D.reset()), !T)
393
462
  return;
394
- const v = I.clientX, p = I.clientY;
395
- if (b.phase.kind === "idle")
463
+ const y = w.clientX, f = w.clientY;
464
+ if (h.phase.kind === "idle")
396
465
  return;
397
- const x = Math.abs(v - b.phase.startX), E = Math.abs(p - b.phase.startY);
398
- if (!(x < e && E < e)) {
399
- if (b.phase.kind === "content") {
400
- const S = b.phase.cache.groups.find(({ rect: C }) => v >= C.left && v <= C.right && p >= C.top && p <= C.bottom);
401
- if (!S)
466
+ const S = Math.abs(y - h.phase.startX), C = Math.abs(f - h.phase.startY);
467
+ if (!(S < e && C < e)) {
468
+ if (h.phase.kind === "content") {
469
+ const G = h.phase.cache.groups.find(({ rect: E }) => y >= E.left && y <= E.right && f >= E.top && f <= E.bottom);
470
+ if (!G)
402
471
  return;
403
- const R = S.gid ?? null;
472
+ const R = G.gid ?? null;
404
473
  if (!R)
405
474
  return;
406
- const G = K(S.rect, v, p);
407
- if (o && !o({ targetGroupId: R, zone: G }))
475
+ const x = U(G.rect, y, f);
476
+ if (o && !o({ targetGroupId: R, zone: x }))
408
477
  return;
409
- r({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: R, zone: G });
478
+ n({ fromGroupId: h.phase.fromGroupId, tabId: h.phase.tabId, targetGroupId: R, zone: x });
410
479
  return;
411
480
  }
412
- if (b.phase.kind === "tab") {
413
- const S = b.phase.cache.tabbars.find(({ rect: G }) => v >= G.left && v <= G.right && p >= G.top && p <= G.bottom);
414
- if (S) {
415
- const G = S.gid;
416
- if (!G)
481
+ if (h.phase.kind === "tab") {
482
+ const G = h.phase.cache.tabbars.find(({ rect: x }) => y >= x.left && y <= x.right && f >= x.top && f <= x.bottom);
483
+ if (G) {
484
+ const x = G.gid;
485
+ if (!x)
417
486
  return;
418
- const k = Array.from(S.el.querySelectorAll("[role='tab']")).map((B) => {
487
+ const k = Array.from(G.el.querySelectorAll("[role='tab']")).map((B) => {
419
488
  const Z = B.getBoundingClientRect();
420
489
  return Z.left + Z.width / 2;
421
- }), P = k.findIndex((B) => v < B), O = P === -1 ? k.length : P;
422
- n({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: G, targetIndex: O });
490
+ }), P = k.findIndex((B) => y < B), O = P === -1 ? k.length : P;
491
+ r({ fromGroupId: h.phase.fromGroupId, tabId: h.phase.tabId, targetGroupId: x, targetIndex: O });
423
492
  return;
424
493
  }
425
- const R = b.phase.cache.contents.find(({ rect: G }) => v >= G.left && v <= G.right && p >= G.top && p <= G.bottom);
494
+ const R = h.phase.cache.contents.find(({ rect: x }) => y >= x.left && y <= x.right && f >= x.top && f <= x.bottom);
426
495
  if (R) {
427
- const G = R.gid ?? null;
428
- if (!G)
496
+ const x = R.gid ?? null;
497
+ if (!x)
429
498
  return;
430
- const C = K(R.rect, v, p);
431
- if (o && !o({ targetGroupId: G, zone: C }))
499
+ const E = U(R.rect, y, f);
500
+ if (o && !o({ targetGroupId: x, zone: E }))
432
501
  return;
433
- r({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: G, zone: C });
502
+ n({ fromGroupId: h.phase.fromGroupId, tabId: h.phase.tabId, targetGroupId: x, zone: E });
434
503
  }
435
504
  }
436
505
  }
437
506
  }), g = J(() => {
438
507
  i(D.reset());
439
508
  });
440
- l.useEffect(() => {
509
+ u.useEffect(() => {
441
510
  if (a.phase.kind !== "idle")
442
- return window.addEventListener("pointermove", d), window.addEventListener("pointerup", f, { once: !0 }), window.addEventListener("pointercancel", g, { once: !0 }), () => {
443
- window.removeEventListener("pointermove", d), window.removeEventListener("pointerup", f), window.removeEventListener("pointercancel", g);
511
+ return window.addEventListener("pointermove", l), window.addEventListener("pointerup", p, { once: !0 }), window.addEventListener("pointercancel", g, { once: !0 }), () => {
512
+ window.removeEventListener("pointermove", l), window.removeEventListener("pointerup", p), window.removeEventListener("pointercancel", g);
444
513
  };
445
514
  }, [a.phase.kind]);
446
- const y = l.useCallback((I, T, b) => {
447
- if (b.button !== 0)
515
+ const v = u.useCallback((w, T, h) => {
516
+ if (h.button !== 0)
448
517
  return;
449
- b.currentTarget.setPointerCapture(b.pointerId);
450
- const v = u();
451
- i(D.startContent({ x: b.clientX, y: b.clientY, groupId: I, tabId: T, cache: v }));
452
- }, [u]), h = l.useCallback((I, T, b) => {
453
- if (b.button !== 0)
518
+ h.currentTarget.setPointerCapture(h.pointerId);
519
+ const y = d();
520
+ i(D.startContent({ x: h.clientX, y: h.clientY, groupId: w, tabId: T, cache: y }));
521
+ }, [d]), b = u.useCallback((w, T, h) => {
522
+ if (h.button !== 0)
454
523
  return;
455
- const v = b.currentTarget;
456
- v && v.setPointerCapture(b.pointerId);
457
- const p = u();
458
- i(D.startTab({ x: b.clientX, y: b.clientY, groupId: T, tabId: I, cache: p, element: v }));
459
- }, [u]), w = l.useMemo(() => ({
524
+ const y = h.currentTarget;
525
+ y && y.setPointerCapture(h.pointerId);
526
+ const f = d();
527
+ i(D.startTab({ x: h.clientX, y: h.clientY, groupId: T, tabId: w, cache: f, element: y }));
528
+ }, [d]), I = u.useMemo(() => ({
460
529
  suggest: a.suggest,
461
530
  isTabDragging: a.phase.kind === "tab",
462
531
  draggingTabId: a.phase.kind === "tab" ? a.phase.tabId : null,
463
532
  dragPointer: a.pointer,
464
533
  tabbarHover: a.tabbarHover,
465
534
  draggingTabElement: a.draggingTabElement,
466
- onStartContentDrag: y,
467
- onStartTabDrag: h
468
- }), [a.suggest, a.pointer, a.tabbarHover, a.phase, a.draggingTabElement, y, h]);
469
- return /* @__PURE__ */ m(It.Provider, { value: w, children: s });
470
- }, it = {
535
+ onStartContentDrag: v,
536
+ onStartTabDrag: b
537
+ }), [a.suggest, a.pointer, a.tabbarHover, a.phase, a.draggingTabElement, v, b]);
538
+ return /* @__PURE__ */ m(yt.Provider, { value: I, children: s });
539
+ }, ct = {
471
540
  display: "inline-flex",
472
541
  alignItems: "center",
473
542
  userSelect: "none"
474
- }, we = ({
543
+ }, Se = ({
475
544
  groupId: t,
476
545
  tab: e,
477
- active: r,
478
- dragging: n,
546
+ active: n,
547
+ dragging: r,
479
548
  onClickTab: o,
480
549
  onStartDrag: s,
481
550
  onCloseTab: a,
482
551
  tabComponent: i,
483
552
  tabElement: c,
484
- onDoubleClick: u
553
+ onDoubleClick: d
485
554
  }) => {
486
- const d = l.useEffectEvent(() => {
555
+ const l = u.useEffectEvent(() => {
487
556
  o(e.id);
488
- }), f = l.useEffectEvent((w) => {
489
- s && w.button === 0 && s(e.id, t, w);
557
+ }), p = u.useEffectEvent((I) => {
558
+ s && I.button === 0 && s(e.id, t, I);
490
559
  }), g = () => {
491
- const w = !!a;
492
- return /* @__PURE__ */ m(l.Activity, { mode: w ? "visible" : "hidden", children: /* @__PURE__ */ m(
560
+ const I = !!a;
561
+ return /* @__PURE__ */ m(u.Activity, { mode: I ? "visible" : "hidden", children: /* @__PURE__ */ m(
493
562
  "button",
494
563
  {
495
564
  type: "button",
496
565
  "aria-label": `Close tab ${e.title}`,
497
- onClick: (I) => {
498
- a && (I.stopPropagation(), a(t, e.id));
566
+ onClick: (w) => {
567
+ a && (w.stopPropagation(), a(t, e.id));
499
568
  },
500
569
  style: { marginLeft: 6 },
501
- tabIndex: w ? void 0 : -1,
502
- disabled: !w,
503
- "aria-hidden": w ? void 0 : !0,
570
+ tabIndex: I ? void 0 : -1,
571
+ disabled: !I,
572
+ "aria-hidden": I ? void 0 : !0,
504
573
  children: "×"
505
574
  }
506
575
  ) });
507
- }, y = {
576
+ }, v = {
508
577
  role: "tab",
509
- "aria-selected": r,
510
- tabIndex: r ? 0 : -1,
511
- style: it,
512
- onClick: d,
513
- onPointerDown: f,
514
- onDoubleClick: u,
578
+ "aria-selected": n,
579
+ tabIndex: n ? 0 : -1,
580
+ style: ct,
581
+ onClick: l,
582
+ onPointerDown: p,
583
+ onDoubleClick: d,
515
584
  "data-tab-id": e.id,
516
- "data-active": r ? "true" : "false",
517
- "data-dragging": n ? "true" : "false",
585
+ "data-active": n ? "true" : "false",
586
+ "data-dragging": r ? "true" : "false",
518
587
  children: /* @__PURE__ */ H(et, { children: [
519
588
  /* @__PURE__ */ m("span", { children: e.title }),
520
589
  g()
521
590
  ] })
522
- }, h = {
591
+ }, b = {
523
592
  type: "button",
524
593
  role: "tab",
525
- "aria-selected": r,
526
- tabIndex: r ? 0 : -1,
527
- style: it,
594
+ "aria-selected": n,
595
+ tabIndex: n ? 0 : -1,
596
+ style: ct,
528
597
  onClick: () => {
529
598
  o(e.id);
530
599
  },
531
- onPointerDown: (w) => {
532
- s && w.button === 0 && s(e.id, t, w);
600
+ onPointerDown: (I) => {
601
+ s && I.button === 0 && s(e.id, t, I);
533
602
  },
534
- onDoubleClick: u,
603
+ onDoubleClick: d,
535
604
  children: /* @__PURE__ */ m("span", { children: e.title })
536
605
  };
537
- return c ? c(h) : i ? /* @__PURE__ */ m(i, { ...h }) : /* @__PURE__ */ m("div", { ...y });
538
- }, ye = {
606
+ return c ? c(b) : i ? /* @__PURE__ */ m(i, { ...b }) : /* @__PURE__ */ m("div", { ...v });
607
+ }, xe = {
539
608
  display: "flex",
540
609
  alignItems: "center"
541
- }, Te = {
610
+ }, Ge = {
542
611
  flex: "1 1 auto",
543
612
  alignSelf: "stretch"
544
- }, xe = ({
613
+ }, Ce = ({
545
614
  group: t,
546
615
  onClickTab: e,
547
- onStartDrag: r,
548
- rootRef: n,
616
+ onStartDrag: n,
617
+ rootRef: r,
549
618
  component: o,
550
619
  element: s,
551
620
  tabComponent: a,
552
621
  tabElement: i,
553
622
  onAddTab: c,
554
- onCloseTab: u,
555
- doubleClickToAdd: d
623
+ onCloseTab: d,
624
+ doubleClickToAdd: l
556
625
  }) => {
557
- const { isTabDragging: f, draggingTabId: g } = W(), y = l.useRef(null), h = l.useCallback(
558
- (p) => {
559
- if (y.current = p, !!n) {
560
- if (typeof n == "function") {
561
- n(p);
626
+ const { isTabDragging: p, draggingTabId: g } = W(), v = u.useRef(null), b = u.useCallback(
627
+ (f) => {
628
+ if (v.current = f, !!r) {
629
+ if (typeof r == "function") {
630
+ r(f);
562
631
  return;
563
632
  }
564
633
  try {
565
- n.current = p;
634
+ r.current = f;
566
635
  } catch {
567
636
  }
568
637
  }
569
638
  },
570
- [n]
571
- ), w = l.useEffectEvent((p) => {
572
- const x = y.current ?? p.currentTarget;
573
- if (!x)
639
+ [r]
640
+ ), I = u.useEffectEvent((f) => {
641
+ const S = v.current ?? f.currentTarget;
642
+ if (!S)
574
643
  return;
575
- const E = Array.from(x.querySelectorAll('[role="tab"]'));
576
- if (E.length === 0)
644
+ const C = Array.from(S.querySelectorAll('[role="tab"]'));
645
+ if (C.length === 0)
577
646
  return;
578
- const S = (P) => {
579
- const O = Math.max(0, Math.min(P, E.length - 1)), B = E[O];
647
+ const G = (P) => {
648
+ const O = Math.max(0, Math.min(P, C.length - 1)), B = C[O];
580
649
  B && B.focus();
581
- }, R = document.activeElement, G = R ? E.indexOf(R) : E.findIndex((P) => P.getAttribute("data-tab-id") === t.activeTabId);
582
- if (p.key === "ArrowRight") {
583
- p.preventDefault();
584
- const P = G >= 0 ? G + 1 : 0;
585
- S(P >= E.length ? 0 : P);
650
+ }, R = document.activeElement, x = R ? C.indexOf(R) : C.findIndex((P) => P.getAttribute("data-tab-id") === t.activeTabId);
651
+ if (f.key === "ArrowRight") {
652
+ f.preventDefault();
653
+ const P = x >= 0 ? x + 1 : 0;
654
+ G(P >= C.length ? 0 : P);
586
655
  return;
587
656
  }
588
- if (p.key === "ArrowLeft") {
589
- p.preventDefault();
590
- const P = G >= 0 ? G - 1 : E.length - 1;
591
- S(P < 0 ? E.length - 1 : P);
657
+ if (f.key === "ArrowLeft") {
658
+ f.preventDefault();
659
+ const P = x >= 0 ? x - 1 : C.length - 1;
660
+ G(P < 0 ? C.length - 1 : P);
592
661
  return;
593
662
  }
594
- if (p.key === "Home") {
595
- p.preventDefault(), S(0);
663
+ if (f.key === "Home") {
664
+ f.preventDefault(), G(0);
596
665
  return;
597
666
  }
598
- if (p.key === "End") {
599
- p.preventDefault(), S(E.length - 1);
667
+ if (f.key === "End") {
668
+ f.preventDefault(), G(C.length - 1);
600
669
  return;
601
670
  }
602
- if (p.key === "Enter" || p.key === " ") {
603
- p.preventDefault();
604
- const O = (G >= 0 ? E[G] : null)?.getAttribute("data-tab-id") ?? null;
671
+ if (f.key === "Enter" || f.key === " ") {
672
+ f.preventDefault();
673
+ const O = (x >= 0 ? C[x] : null)?.getAttribute("data-tab-id") ?? null;
605
674
  O && e(O);
606
675
  return;
607
676
  }
608
- if (p.key === "Delete" || p.key === "Backspace") {
609
- if (u) {
610
- p.preventDefault();
611
- const O = (G >= 0 ? E[G] : null)?.getAttribute("data-tab-id") ?? null;
612
- O && u(t.id, O);
677
+ if (f.key === "Delete" || f.key === "Backspace") {
678
+ if (d) {
679
+ f.preventDefault();
680
+ const O = (x >= 0 ? C[x] : null)?.getAttribute("data-tab-id") ?? null;
681
+ O && d(t.id, O);
613
682
  }
614
683
  return;
615
684
  }
616
- const C = (p.ctrlKey ? 1 : 0) + (p.metaKey ? 1 : 0) > 0, k = typeof p.key == "string" ? p.key.toLowerCase() : "";
617
- if (C && k === "t") {
618
- c && (p.preventDefault(), c(t.id));
685
+ const E = (f.ctrlKey ? 1 : 0) + (f.metaKey ? 1 : 0) > 0, k = typeof f.key == "string" ? f.key.toLowerCase() : "";
686
+ if (E && k === "t") {
687
+ c && (f.preventDefault(), c(t.id));
619
688
  return;
620
689
  }
621
690
  });
622
- l.useEffect(() => {
623
- const p = y.current;
624
- if (!p)
691
+ u.useEffect(() => {
692
+ const f = v.current;
693
+ if (!f)
625
694
  return;
626
- const x = p.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);
627
- if (x === document.activeElement)
695
+ const S = f.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);
696
+ if (S === document.activeElement)
628
697
  return;
629
- !p.contains(document.activeElement) && x && x.focus();
698
+ !f.contains(document.activeElement) && S && S.focus();
630
699
  }, [t.activeTabId]);
631
- const I = {
632
- style: ye,
700
+ const w = {
701
+ style: xe,
633
702
  role: "tablist",
634
703
  "data-tabbar": "true",
635
704
  "data-group-id": t.id,
636
- "data-dragging": f ? "true" : "false",
637
- onKeyDown: w
638
- }, T = Mt({
705
+ "data-dragging": p ? "true" : "false",
706
+ onKeyDown: I
707
+ }, T = Ot({
639
708
  element: s,
640
709
  component: o
641
- }), b = () => c ? /* @__PURE__ */ m(
710
+ }), h = () => c ? /* @__PURE__ */ m(
642
711
  "button",
643
712
  {
644
713
  type: "button",
@@ -648,85 +717,85 @@ const he = (t, e) => {
648
717
  },
649
718
  children: "+"
650
719
  }
651
- ) : null, v = l.useCallback(() => {
652
- d && c && c(t.id);
653
- }, [d, c, t.id]);
654
- return /* @__PURE__ */ H(T, { ...I, ref: h, onDoubleClick: v, children: [
655
- t.tabs.map((p, x) => /* @__PURE__ */ m(
656
- we,
720
+ ) : null, y = u.useCallback(() => {
721
+ l && c && c(t.id);
722
+ }, [l, c, t.id]);
723
+ return /* @__PURE__ */ H(T, { ...w, ref: b, onDoubleClick: y, children: [
724
+ t.tabs.map((f, S) => /* @__PURE__ */ m(
725
+ Se,
657
726
  {
658
727
  groupId: t.id,
659
- tab: p,
660
- active: t.activeTabId === p.id,
661
- dragging: g === p.id,
728
+ tab: f,
729
+ active: t.activeTabId === f.id,
730
+ dragging: g === f.id,
662
731
  onClickTab: e,
663
- onStartDrag: r,
664
- onCloseTab: u,
732
+ onStartDrag: n,
733
+ onCloseTab: d,
665
734
  tabComponent: a,
666
735
  tabElement: i,
667
- onDoubleClick: (E) => E.stopPropagation()
736
+ onDoubleClick: (C) => C.stopPropagation()
668
737
  },
669
- `${t.id}:${p.id}:${x}`
738
+ `${t.id}:${f.id}:${S}`
670
739
  )),
671
- /* @__PURE__ */ m("span", { style: Te }),
672
- b()
740
+ /* @__PURE__ */ m("span", { style: Ge }),
741
+ h()
673
742
  ] });
674
- }, Ge = ({ id: t, TabBarComponent: e, PanelGroupComponent: r }) => {
675
- const { getGroup: n, getGroupContent: o, onClickTab: s, onAddTab: a, onCloseTab: i, onStartTabDrag: c, doubleClickToAdd: u, registerContentContainer: d } = ce(), { setGroupEl: f, setTabbarEl: g, setContentEl: y } = gt(), h = l.useCallback(
676
- (x) => {
677
- f(t, x);
743
+ }, Ee = ({ id: t, TabBarComponent: e, PanelGroupComponent: n }) => {
744
+ const { getGroup: r, getGroupContent: o, onClickTab: s, onAddTab: a, onCloseTab: i, onStartTabDrag: c, doubleClickToAdd: d, registerContentContainer: l } = de(), { setGroupEl: p, setTabbarEl: g, setContentEl: v } = mt(), b = u.useCallback(
745
+ (S) => {
746
+ p(t, S);
678
747
  },
679
- [t, f]
680
- ), w = l.useCallback(
681
- (x) => {
682
- y(t, x), d(t, x);
748
+ [t, p]
749
+ ), I = u.useCallback(
750
+ (S) => {
751
+ v(t, S), l(t, S);
683
752
  },
684
- [t, y, d]
685
- ), I = l.useCallback(
686
- (x) => {
687
- g(t, x);
753
+ [t, v, l]
754
+ ), w = u.useCallback(
755
+ (S) => {
756
+ g(t, S);
688
757
  },
689
758
  [t, g]
690
- ), T = n(t);
759
+ ), T = r(t);
691
760
  if (!T)
692
761
  return null;
693
- const b = o(t);
762
+ const h = o(t);
694
763
  return /* @__PURE__ */ m(
695
- r ?? ((x) => /* @__PURE__ */ m(ht, { ...x })),
764
+ n ?? ((S) => /* @__PURE__ */ m(vt, { ...S })),
696
765
  {
697
766
  group: T,
698
767
  tabbar: /* @__PURE__ */ m(
699
- e ?? xe,
768
+ e ?? Ce,
700
769
  {
701
- rootRef: I,
770
+ rootRef: w,
702
771
  group: T,
703
- onClickTab: (x) => s(t, x),
772
+ onClickTab: (S) => s(t, S),
704
773
  onAddTab: a,
705
774
  onCloseTab: i,
706
- onStartDrag: (x, E, S) => c(x, E, S),
707
- doubleClickToAdd: u
775
+ onStartDrag: (S, C, G) => c(S, C, G),
776
+ doubleClickToAdd: d
708
777
  }
709
778
  ),
710
- content: b,
711
- groupRef: h,
712
- contentRef: w
779
+ content: h,
780
+ groupRef: b,
781
+ contentRef: I
713
782
  }
714
783
  );
715
- }, Se = (t, e) => {
716
- const r = new Array(16);
717
- for (let n = 0; n < 4; n++)
784
+ }, Re = (t, e) => {
785
+ const n = new Array(16);
786
+ for (let r = 0; r < 4; r++)
718
787
  for (let o = 0; o < 4; o++)
719
- r[n * 4 + o] = t[0 + o] * e[n * 4 + 0] + t[4 + o] * e[n * 4 + 1] + t[8 + o] * e[n * 4 + 2] + t[12 + o] * e[n * 4 + 3];
720
- return r;
721
- }, V = (t) => {
788
+ n[r * 4 + o] = t[0 + o] * e[r * 4 + 0] + t[4 + o] * e[r * 4 + 1] + t[8 + o] * e[r * 4 + 2] + t[12 + o] * e[r * 4 + 3];
789
+ return n;
790
+ }, K = (t) => {
722
791
  if (t.length !== 16)
723
792
  throw new Error("Matrix must have exactly 16 values");
724
- const e = Object.freeze([...t]), r = (n) => {
725
- const o = Se(e, n);
726
- return V(o);
793
+ const e = Object.freeze([...t]), n = (r) => {
794
+ const o = Re(e, r);
795
+ return K(o);
727
796
  };
728
797
  return Object.freeze({
729
- translate: (n = 0, o = 0, s = 0) => r([
798
+ translate: (r = 0, o = 0, s = 0) => n([
730
799
  1,
731
800
  0,
732
801
  0,
@@ -739,12 +808,12 @@ const he = (t, e) => {
739
808
  0,
740
809
  1,
741
810
  0,
742
- n,
811
+ r,
743
812
  o,
744
813
  s,
745
814
  1
746
815
  ]),
747
- translate3d: (n, o, s) => r([
816
+ translate3d: (r, o, s) => n([
748
817
  1,
749
818
  0,
750
819
  0,
@@ -757,12 +826,12 @@ const he = (t, e) => {
757
826
  0,
758
827
  1,
759
828
  0,
760
- n,
829
+ r,
761
830
  o,
762
831
  s,
763
832
  1
764
833
  ]),
765
- translateX: (n) => r([
834
+ translateX: (r) => n([
766
835
  1,
767
836
  0,
768
837
  0,
@@ -775,12 +844,12 @@ const he = (t, e) => {
775
844
  0,
776
845
  1,
777
846
  0,
778
- n,
847
+ r,
779
848
  0,
780
849
  0,
781
850
  1
782
851
  ]),
783
- translateY: (n) => r([
852
+ translateY: (r) => n([
784
853
  1,
785
854
  0,
786
855
  0,
@@ -794,11 +863,11 @@ const he = (t, e) => {
794
863
  1,
795
864
  0,
796
865
  0,
797
- n,
866
+ r,
798
867
  0,
799
868
  1
800
869
  ]),
801
- translateZ: (n) => r([
870
+ translateZ: (r) => n([
802
871
  1,
803
872
  0,
804
873
  0,
@@ -813,11 +882,11 @@ const he = (t, e) => {
813
882
  0,
814
883
  0,
815
884
  0,
816
- n,
885
+ r,
817
886
  1
818
887
  ]),
819
- scale: (n = 1, o = 1, s = 1) => r([
820
- n,
888
+ scale: (r = 1, o = 1, s = 1) => n([
889
+ r,
821
890
  0,
822
891
  0,
823
892
  0,
@@ -834,8 +903,8 @@ const he = (t, e) => {
834
903
  0,
835
904
  1
836
905
  ]),
837
- scale3d: (n, o, s) => r([
838
- n,
906
+ scale3d: (r, o, s) => n([
907
+ r,
839
908
  0,
840
909
  0,
841
910
  0,
@@ -852,8 +921,8 @@ const he = (t, e) => {
852
921
  0,
853
922
  1
854
923
  ]),
855
- scaleX: (n) => r([
856
- n,
924
+ scaleX: (r) => n([
925
+ r,
857
926
  0,
858
927
  0,
859
928
  0,
@@ -870,13 +939,13 @@ const he = (t, e) => {
870
939
  0,
871
940
  1
872
941
  ]),
873
- scaleY: (n) => r([
942
+ scaleY: (r) => n([
874
943
  1,
875
944
  0,
876
945
  0,
877
946
  0,
878
947
  0,
879
- n,
948
+ r,
880
949
  0,
881
950
  0,
882
951
  0,
@@ -888,7 +957,7 @@ const he = (t, e) => {
888
957
  0,
889
958
  1
890
959
  ]),
891
- scaleZ: (n) => r([
960
+ scaleZ: (r) => n([
892
961
  1,
893
962
  0,
894
963
  0,
@@ -899,16 +968,16 @@ const he = (t, e) => {
899
968
  0,
900
969
  0,
901
970
  0,
902
- n,
971
+ r,
903
972
  0,
904
973
  0,
905
974
  0,
906
975
  0,
907
976
  1
908
977
  ]),
909
- rotateX: (n) => {
910
- const o = Math.cos(n), s = Math.sin(n);
911
- return r([
978
+ rotateX: (r) => {
979
+ const o = Math.cos(r), s = Math.sin(r);
980
+ return n([
912
981
  1,
913
982
  0,
914
983
  0,
@@ -927,9 +996,9 @@ const he = (t, e) => {
927
996
  1
928
997
  ]);
929
998
  },
930
- rotateY: (n) => {
931
- const o = Math.cos(n), s = Math.sin(n);
932
- return r([
999
+ rotateY: (r) => {
1000
+ const o = Math.cos(r), s = Math.sin(r);
1001
+ return n([
933
1002
  o,
934
1003
  0,
935
1004
  -s,
@@ -948,9 +1017,9 @@ const he = (t, e) => {
948
1017
  1
949
1018
  ]);
950
1019
  },
951
- rotateZ: (n) => {
952
- const o = Math.cos(n), s = Math.sin(n);
953
- return r([
1020
+ rotateZ: (r) => {
1021
+ const o = Math.cos(r), s = Math.sin(r);
1022
+ return n([
954
1023
  o,
955
1024
  s,
956
1025
  0,
@@ -969,24 +1038,24 @@ const he = (t, e) => {
969
1038
  1
970
1039
  ]);
971
1040
  },
972
- rotate: (n, o, s, a) => {
1041
+ rotate: (r, o, s, a) => {
973
1042
  const i = Math.sqrt(o * o + s * s + a * a);
974
1043
  if (i === 0)
975
- return V(e);
1044
+ return K(e);
976
1045
  o /= i, s /= i, a /= i;
977
- const c = Math.cos(n), u = Math.sin(n), d = 1 - c;
978
- return r([
979
- d * o * o + c,
980
- d * o * s + u * a,
981
- d * o * a - u * s,
1046
+ const c = Math.cos(r), d = Math.sin(r), l = 1 - c;
1047
+ return n([
1048
+ l * o * o + c,
1049
+ l * o * s + d * a,
1050
+ l * o * a - d * s,
982
1051
  0,
983
- d * o * s - u * a,
984
- d * s * s + c,
985
- d * s * a + u * o,
1052
+ l * o * s - d * a,
1053
+ l * s * s + c,
1054
+ l * s * a + d * o,
986
1055
  0,
987
- d * o * a + u * s,
988
- d * s * a - u * o,
989
- d * a * a + c,
1056
+ l * o * a + d * s,
1057
+ l * s * a - d * o,
1058
+ l * a * a + c,
990
1059
  0,
991
1060
  0,
992
1061
  0,
@@ -994,24 +1063,24 @@ const he = (t, e) => {
994
1063
  1
995
1064
  ]);
996
1065
  },
997
- rotate3d: (n, o, s, a) => {
998
- const i = Math.sqrt(n * n + o * o + s * s);
1066
+ rotate3d: (r, o, s, a) => {
1067
+ const i = Math.sqrt(r * r + o * o + s * s);
999
1068
  if (i === 0)
1000
- return V(e);
1001
- n /= i, o /= i, s /= i;
1002
- const c = Math.cos(a), u = Math.sin(a), d = 1 - c;
1003
- return r([
1004
- d * n * n + c,
1005
- d * n * o + u * s,
1006
- d * n * s - u * o,
1069
+ return K(e);
1070
+ r /= i, o /= i, s /= i;
1071
+ const c = Math.cos(a), d = Math.sin(a), l = 1 - c;
1072
+ return n([
1073
+ l * r * r + c,
1074
+ l * r * o + d * s,
1075
+ l * r * s - d * o,
1007
1076
  0,
1008
- d * n * o - u * s,
1009
- d * o * o + c,
1010
- d * o * s + u * n,
1077
+ l * r * o - d * s,
1078
+ l * o * o + c,
1079
+ l * o * s + d * r,
1011
1080
  0,
1012
- d * n * s + u * o,
1013
- d * o * s - u * n,
1014
- d * s * s + c,
1081
+ l * r * s + d * o,
1082
+ l * o * s - d * r,
1083
+ l * s * s + c,
1015
1084
  0,
1016
1085
  0,
1017
1086
  0,
@@ -1019,9 +1088,9 @@ const he = (t, e) => {
1019
1088
  1
1020
1089
  ]);
1021
1090
  },
1022
- skew: (n = 0, o = 0) => {
1023
- const s = Math.tan(n), a = Math.tan(o);
1024
- return r([
1091
+ skew: (r = 0, o = 0) => {
1092
+ const s = Math.tan(r), a = Math.tan(o);
1093
+ return n([
1025
1094
  1,
1026
1095
  a,
1027
1096
  0,
@@ -1040,9 +1109,9 @@ const he = (t, e) => {
1040
1109
  1
1041
1110
  ]);
1042
1111
  },
1043
- skewX: (n) => {
1044
- const o = Math.tan(n);
1045
- return r([
1112
+ skewX: (r) => {
1113
+ const o = Math.tan(r);
1114
+ return n([
1046
1115
  1,
1047
1116
  0,
1048
1117
  0,
@@ -1061,9 +1130,9 @@ const he = (t, e) => {
1061
1130
  1
1062
1131
  ]);
1063
1132
  },
1064
- skewY: (n) => {
1065
- const o = Math.tan(n);
1066
- return r([
1133
+ skewY: (r) => {
1134
+ const o = Math.tan(r);
1135
+ return n([
1067
1136
  1,
1068
1137
  o,
1069
1138
  0,
@@ -1082,10 +1151,10 @@ const he = (t, e) => {
1082
1151
  1
1083
1152
  ]);
1084
1153
  },
1085
- perspective: (n) => {
1086
- if (n === 0)
1154
+ perspective: (r) => {
1155
+ if (r === 0)
1087
1156
  throw new Error("Perspective distance cannot be zero");
1088
- return r([
1157
+ return n([
1089
1158
  1,
1090
1159
  0,
1091
1160
  0,
@@ -1097,7 +1166,7 @@ const he = (t, e) => {
1097
1166
  0,
1098
1167
  0,
1099
1168
  1,
1100
- -1 / n,
1169
+ -1 / r,
1101
1170
  0,
1102
1171
  0,
1103
1172
  0,
@@ -1114,7 +1183,7 @@ const he = (t, e) => {
1114
1183
  ].join(`
1115
1184
  `)
1116
1185
  });
1117
- }, Ee = () => V([
1186
+ }, Pe = () => K([
1118
1187
  1,
1119
1188
  0,
1120
1189
  0,
@@ -1131,142 +1200,142 @@ const he = (t, e) => {
1131
1200
  0,
1132
1201
  0,
1133
1202
  1
1134
- ]), Ce = {
1203
+ ]), De = {
1135
1204
  position: "fixed",
1136
1205
  inset: 0,
1137
1206
  pointerEvents: "none",
1138
- zIndex: Nt
1139
- }, Re = {
1207
+ zIndex: $t
1208
+ }, Ae = {
1140
1209
  position: "absolute",
1141
- border: `${Xt} dashed ${Yt}`,
1142
- background: zt,
1143
- borderRadius: $t,
1210
+ border: `${Yt} dashed ${jt}`,
1211
+ background: Xt,
1212
+ borderRadius: Ft,
1144
1213
  transformOrigin: "top left"
1145
- }, L = (t, e) => e <= 0 ? 0 : M(t / e, 0), Pe = (t, e, r) => {
1146
- const { width: n, height: o } = t, s = r / 2, a = n > 0 ? n : 1, i = o > 0 ? o : 1, c = {
1147
- translateX: r,
1148
- translateY: r,
1149
- scaleX: L(M(n - r * 2, 0), a),
1150
- scaleY: L(M(o - r * 2, 0), i)
1151
- }, u = {
1152
- translateX: r,
1153
- translateY: r,
1154
- scaleX: L(M(n / 2 - r * 1.5, 0), a),
1155
- scaleY: L(M(o - r * 2, 0), i)
1214
+ }, L = (t, e) => e <= 0 ? 0 : M(t / e, 0), ke = (t, e, n) => {
1215
+ const { width: r, height: o } = t, s = n / 2, a = r > 0 ? r : 1, i = o > 0 ? o : 1, c = {
1216
+ translateX: n,
1217
+ translateY: n,
1218
+ scaleX: L(M(r - n * 2, 0), a),
1219
+ scaleY: L(M(o - n * 2, 0), i)
1156
1220
  }, d = {
1157
- translateX: n / 2 + s,
1158
- translateY: r,
1159
- scaleX: L(M(n / 2 - r * 1.5, 0), a),
1160
- scaleY: L(M(o - r * 2, 0), i)
1161
- }, f = {
1162
- translateX: r,
1163
- translateY: r,
1164
- scaleX: L(M(n - r * 2, 0), a),
1165
- scaleY: L(M(o / 2 - r * 1.5, 0), i)
1221
+ translateX: n,
1222
+ translateY: n,
1223
+ scaleX: L(M(r / 2 - n * 1.5, 0), a),
1224
+ scaleY: L(M(o - n * 2, 0), i)
1225
+ }, l = {
1226
+ translateX: r / 2 + s,
1227
+ translateY: n,
1228
+ scaleX: L(M(r / 2 - n * 1.5, 0), a),
1229
+ scaleY: L(M(o - n * 2, 0), i)
1230
+ }, p = {
1231
+ translateX: n,
1232
+ translateY: n,
1233
+ scaleX: L(M(r - n * 2, 0), a),
1234
+ scaleY: L(M(o / 2 - n * 1.5, 0), i)
1166
1235
  }, g = {
1167
- translateX: r,
1236
+ translateX: n,
1168
1237
  translateY: o / 2 + s,
1169
- scaleX: L(M(n - r * 2, 0), a),
1170
- scaleY: L(M(o / 2 - r * 1.5, 0), i)
1171
- }, y = {
1238
+ scaleX: L(M(r - n * 2, 0), a),
1239
+ scaleY: L(M(o / 2 - n * 1.5, 0), i)
1240
+ }, v = {
1172
1241
  center: c,
1173
- left: u,
1174
- right: d,
1175
- top: f,
1242
+ left: d,
1243
+ right: l,
1244
+ top: p,
1176
1245
  bottom: g
1177
- }, { translateX: h, translateY: w, scaleX: I, scaleY: T } = y[e];
1178
- return Ee().translate(h, w, 0).scale(I, T, 1).toCSS();
1179
- }, De = (t, e) => {
1180
- const r = Ft;
1246
+ }, { translateX: b, translateY: I, scaleX: w, scaleY: T } = v[e];
1247
+ return Pe().translate(b, I, 0).scale(w, T, 1).toCSS();
1248
+ }, Me = (t, e) => {
1249
+ const n = Ut;
1181
1250
  return {
1182
- ...Re,
1251
+ ...Ae,
1183
1252
  left: t.left,
1184
1253
  top: t.top,
1185
1254
  width: t.width,
1186
1255
  height: t.height,
1187
- transform: Pe(t, e, r)
1256
+ transform: ke(t, e, n)
1188
1257
  };
1189
- }, Ae = ({ suggest: t }) => {
1258
+ }, _e = ({ suggest: t }) => {
1190
1259
  if (!t)
1191
1260
  return null;
1192
- const { rect: e, zone: r } = t, n = De(e, r);
1193
- return /* @__PURE__ */ m("div", { style: Ce, children: /* @__PURE__ */ m("div", { style: n }) });
1194
- }, ke = typeof window < "u" && typeof document < "u", Me = (t) => {
1195
- const [e, r] = l.useState(null), [n, o] = l.useState(null);
1196
- return rt(() => {
1197
- if (!ke || !t) {
1198
- r(null), o(null);
1261
+ const { rect: e, zone: n } = t, r = Me(e, n);
1262
+ return /* @__PURE__ */ m("div", { style: De, children: /* @__PURE__ */ m("div", { style: r }) });
1263
+ }, Oe = typeof window < "u" && typeof document < "u", Be = (t) => {
1264
+ const [e, n] = u.useState(null), [r, o] = u.useState(null);
1265
+ return nt(() => {
1266
+ if (!Oe || !t) {
1267
+ n(null), o(null);
1199
1268
  return;
1200
1269
  }
1201
1270
  const s = t.getBoundingClientRect();
1202
- r({ width: s.width, height: s.height }), o(t.outerHTML);
1203
- }, [t]), { html: n, size: e };
1204
- }, _e = {
1271
+ n({ width: s.width, height: s.height }), o(t.outerHTML);
1272
+ }, [t]), { html: r, size: e };
1273
+ }, Le = {
1205
1274
  position: "fixed",
1206
1275
  inset: 0,
1207
1276
  pointerEvents: "none",
1208
- zIndex: Zt
1209
- }, Oe = {
1277
+ zIndex: Qt
1278
+ }, He = {
1210
1279
  position: "absolute",
1211
- width: qt,
1212
- borderRadius: Wt,
1213
- background: Ut,
1214
- boxShadow: Vt
1215
- }, Be = () => {
1216
- const { isTabDragging: t, draggingTabId: e, dragPointer: r, tabbarHover: n, draggingTabElement: o } = W(), { html: s, size: a } = Me(o), i = r !== null && e !== null, c = l.useMemo(() => {
1217
- if (!(!i || !r))
1280
+ width: Jt,
1281
+ borderRadius: Zt,
1282
+ background: qt,
1283
+ boxShadow: Wt
1284
+ }, Ne = () => {
1285
+ const { isTabDragging: t, draggingTabId: e, dragPointer: n, tabbarHover: r, draggingTabElement: o } = W(), { html: s, size: a } = Be(o), i = n !== null && e !== null, c = u.useMemo(() => {
1286
+ if (!(!i || !n))
1218
1287
  return {
1219
1288
  position: "absolute",
1220
- left: r.x,
1221
- top: r.y,
1222
- transform: `translate(${jt}, ${Kt})`,
1289
+ left: n.x,
1290
+ top: n.y,
1291
+ transform: `translate(${Kt}, ${Vt})`,
1223
1292
  pointerEvents: "none"
1224
1293
  };
1225
- }, [i, r]), u = l.useMemo(() => {
1294
+ }, [i, n]), d = u.useMemo(() => {
1226
1295
  if (!(!c || !o))
1227
1296
  return a ? { ...c, width: a.width, height: a.height } : c;
1228
- }, [c, o, a]), d = l.useMemo(() => {
1229
- if (n)
1297
+ }, [c, o, a]), l = u.useMemo(() => {
1298
+ if (r)
1230
1299
  return {
1231
- ...Oe,
1232
- left: n.insertX,
1233
- top: n.rect.top + 4,
1234
- height: Math.max(0, n.rect.height - 8)
1300
+ ...He,
1301
+ left: r.insertX,
1302
+ top: r.rect.top + 4,
1303
+ height: Math.max(0, r.rect.height - 8)
1235
1304
  };
1236
- }, [n]);
1237
- return t ? /* @__PURE__ */ H("div", { style: _e, children: [
1238
- /* @__PURE__ */ m(l.Activity, { mode: u ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: u, children: /* @__PURE__ */ m(
1305
+ }, [r]);
1306
+ return t ? /* @__PURE__ */ H("div", { style: Le, children: [
1307
+ /* @__PURE__ */ m(u.Activity, { mode: d ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: d, children: /* @__PURE__ */ m(
1239
1308
  "div",
1240
1309
  {
1241
1310
  style: { width: "100%", height: "100%", pointerEvents: "none" },
1242
1311
  dangerouslySetInnerHTML: { __html: s ?? "" }
1243
1312
  }
1244
1313
  ) }) }),
1245
- /* @__PURE__ */ m(l.Activity, { mode: d ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: d }) })
1314
+ /* @__PURE__ */ m(u.Activity, { mode: l ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: l }) })
1246
1315
  ] }) : null;
1247
- }, _ = (t) => t.type === "group", F = (t, e = []) => {
1316
+ }, _ = (t) => t.type === "group", Y = (t, e = []) => {
1248
1317
  if (_(t))
1249
1318
  return [...e, t.groupId];
1250
- const r = F(t.a, e);
1251
- return F(t.b, r);
1252
- }, q = (t, e) => e.reduce((r, n) => _(r) ? r : r[n], t), j = (t, e, r) => {
1319
+ const n = Y(t.a, e);
1320
+ return Y(t.b, n);
1321
+ }, q = (t, e) => e.reduce((n, r) => _(n) ? n : n[r], t), j = (t, e, n) => {
1253
1322
  if (e.length === 0)
1254
- return r;
1255
- const [n, ...o] = e;
1256
- return _(t) ? t : n === "a" ? { ...t, a: j(t.a, o, r) } : { ...t, b: j(t.b, o, r) };
1257
- }, U = (t, e, r = []) => {
1323
+ return n;
1324
+ const [r, ...o] = e;
1325
+ return _(t) ? t : r === "a" ? { ...t, a: j(t.a, o, n) } : { ...t, b: j(t.b, o, n) };
1326
+ }, V = (t, e, n = []) => {
1258
1327
  if (_(t))
1259
1328
  return t.groupId === e ? { splitPath: null, side: null } : null;
1260
1329
  if (_(t.a) && t.a.groupId === e)
1261
- return { splitPath: r, side: "a" };
1330
+ return { splitPath: n, side: "a" };
1262
1331
  if (_(t.b) && t.b.groupId === e)
1263
- return { splitPath: r, side: "b" };
1264
- const n = U(t.a, e, [...r, "a"]);
1265
- return n || U(t.b, e, [...r, "b"]);
1266
- }, wt = (t, e, r, n) => {
1267
- const o = n(), s = U(t, e), a = {
1332
+ return { splitPath: n, side: "b" };
1333
+ const r = V(t.a, e, [...n, "a"]);
1334
+ return r || V(t.b, e, [...n, "b"]);
1335
+ }, Tt = (t, e, n, r) => {
1336
+ const o = r(), s = V(t, e), a = {
1268
1337
  type: "split",
1269
- direction: r,
1338
+ direction: n,
1270
1339
  ratio: 0.5,
1271
1340
  a: { type: "group", groupId: e },
1272
1341
  b: { type: "group", groupId: o }
@@ -1276,139 +1345,139 @@ const he = (t, e) => {
1276
1345
  const i = s.splitPath, c = q(t, i);
1277
1346
  if (_(c))
1278
1347
  return { tree: a, newGroupId: o };
1279
- const u = s.side === "a" ? { ...c, a } : { ...c, b: a };
1280
- return { tree: j(t, i, u), newGroupId: o };
1281
- }, Le = (t, e) => {
1282
- const r = U(t, e);
1283
- if (!r || r.splitPath === null)
1348
+ const d = s.side === "a" ? { ...c, a } : { ...c, b: a };
1349
+ return { tree: j(t, i, d), newGroupId: o };
1350
+ }, ze = (t, e) => {
1351
+ const n = V(t, e);
1352
+ if (!n || n.splitPath === null)
1284
1353
  return { tree: t, survivorGroupId: e };
1285
- const n = r.splitPath, o = q(t, n);
1354
+ const r = n.splitPath, o = q(t, r);
1286
1355
  if (_(o))
1287
1356
  return { tree: t, survivorGroupId: e };
1288
- const s = r.side === "a" ? o.b : o.a, a = j(t, n, s), i = _(s) ? s.groupId : F(s)[0] ?? null;
1357
+ const s = n.side === "a" ? o.b : o.a, a = j(t, r, s), i = _(s) ? s.groupId : Y(s)[0] ?? null;
1289
1358
  return { tree: a, survivorGroupId: i };
1290
- }, He = (t, e, r) => {
1291
- const n = q(t, e);
1292
- if (_(n))
1359
+ }, $e = (t, e, n) => {
1360
+ const r = q(t, e);
1361
+ if (_(r))
1293
1362
  return t;
1294
- const o = { ...n, ratio: M(r, 0.05, 0.95) };
1363
+ const o = { ...r, ratio: M(n, 0.05, 0.95) };
1295
1364
  return j(t, e, o);
1296
1365
  }, Q = (t) => {
1297
1366
  if (Object.keys(t.groups).filter((o) => t.groups[o].tabIds.length === 0).length === 0)
1298
1367
  return t;
1299
- const n = (o, s) => {
1368
+ const r = (o, s) => {
1300
1369
  const a = o.groups[s];
1301
1370
  if (!a || a.tabs.length > 0 || Object.keys(o.groups).length <= 1)
1302
1371
  return o;
1303
- const { tree: c, survivorGroupId: u } = Le(o.tree, s), { [s]: d, ...f } = o.groups, g = F(c), y = o.focusedGroupId === s ? u ?? g[0] ?? null : o.focusedGroupId;
1304
- return { ...o, tree: c, groups: f, groupOrder: g, focusedGroupId: y };
1372
+ const { tree: c, survivorGroupId: d } = ze(o.tree, s), { [s]: l, ...p } = o.groups, g = Y(c), v = o.focusedGroupId === s ? d ?? g[0] ?? null : o.focusedGroupId;
1373
+ return { ...o, tree: c, groups: p, groupOrder: g, focusedGroupId: v };
1305
1374
  };
1306
- return t.groupOrder.reduce((o, s) => n(o, s), t);
1307
- }, Ne = (t) => ({ id: t, tabIds: [], tabs: [], activeTabId: null }), at = (t, e, r, n) => {
1375
+ return t.groupOrder.reduce((o, s) => r(o, s), t);
1376
+ }, Fe = (t) => ({ id: t, tabIds: [], tabs: [], activeTabId: null }), ut = (t, e, n, r) => {
1308
1377
  const o = { ...t.groups }, s = o[e];
1309
1378
  if (!s)
1310
1379
  throw new Error(`Group ${e} does not exist.`);
1311
- const a = { ...t.panels, [r.id]: r }, i = [...s.tabIds, r.id], c = n ? r.id : s.activeTabId ?? r.id, u = i.map((f) => a[f]), d = { ...s, tabIds: i, tabs: u, activeTabId: c };
1312
- return o[e] = d, { ...t, panels: a, groups: o };
1313
- }, $e = (t, e, r) => {
1314
- const n = { ...t.groups }, o = n[e];
1380
+ const a = { ...t.panels, [n.id]: n }, i = [...s.tabIds, n.id], c = r ? n.id : s.activeTabId ?? n.id, d = i.map((p) => a[p]), l = { ...s, tabIds: i, tabs: d, activeTabId: c };
1381
+ return o[e] = l, { ...t, panels: a, groups: o };
1382
+ }, Xe = (t, e, n) => {
1383
+ const r = { ...t.groups }, o = r[e];
1315
1384
  if (!o)
1316
1385
  throw new Error(`Group ${e} does not exist.`);
1317
- const s = o.tabIds.filter((c) => c !== r), a = s.map((c) => t.panels[c]), i = o.activeTabId === r ? s[0] ?? null : o.activeTabId;
1318
- return n[e] = { ...o, tabIds: s, tabs: a, activeTabId: i }, { ...t, groups: n };
1319
- }, ct = (t, e, r, n, o) => {
1320
- const s = t.groups[e], a = t.groups[r];
1386
+ const s = o.tabIds.filter((c) => c !== n), a = s.map((c) => t.panels[c]), i = o.activeTabId === n ? s[0] ?? null : o.activeTabId;
1387
+ return r[e] = { ...o, tabIds: s, tabs: a, activeTabId: i }, { ...t, groups: r };
1388
+ }, lt = (t, e, n, r, o) => {
1389
+ const s = t.groups[e], a = t.groups[n];
1321
1390
  if (!s || !a)
1322
1391
  throw new Error("moveTab: source or target group is missing.");
1323
- const i = { ...t.groups }, c = s.tabIds.filter((f) => f !== n), u = [...a.tabIds.filter((f) => f !== n), n], d = s.activeTabId === n ? c[0] ?? null : s.activeTabId;
1324
- return i[e] = { ...s, tabIds: c, tabs: c.map((f) => t.panels[f]), activeTabId: d }, i[r] = { ...a, tabIds: u, tabs: u.map((f) => t.panels[f]), activeTabId: n }, { ...t, groups: i };
1325
- }, yt = (t, e, r) => {
1326
- const n = t.groups[e];
1327
- if (!n)
1392
+ const i = { ...t.groups }, c = s.tabIds.filter((p) => p !== r), d = [...a.tabIds.filter((p) => p !== r), r], l = s.activeTabId === r ? c[0] ?? null : s.activeTabId;
1393
+ return i[e] = { ...s, tabIds: c, tabs: c.map((p) => t.panels[p]), activeTabId: l }, i[n] = { ...a, tabIds: d, tabs: d.map((p) => t.panels[p]), activeTabId: r }, { ...t, groups: i };
1394
+ }, St = (t, e, n) => {
1395
+ const r = t.groups[e];
1396
+ if (!r)
1328
1397
  throw new Error(`setActiveTab: group ${e} not found.`);
1329
- if (!n.tabIds.some((s) => s === r))
1330
- throw new Error(`setActiveTab: tab ${r} not found in group ${e}.`);
1331
- const o = { ...t.groups, [e]: { ...n, activeTabId: r } };
1398
+ if (!r.tabIds.some((s) => s === n))
1399
+ throw new Error(`setActiveTab: tab ${n} not found in group ${e}.`);
1400
+ const o = { ...t.groups, [e]: { ...r, activeTabId: n } };
1332
1401
  return { ...t, groups: o, focusedGroupId: e };
1333
- }, ut = (t, e, r, n, o) => {
1402
+ }, dt = (t, e, n, r, o) => {
1334
1403
  const s = t.groups[e];
1335
1404
  if (!s)
1336
1405
  throw new Error(`addTabToGroupAtIndex: group ${e} not found.`);
1337
- const a = { ...t.panels, [r.id]: r }, i = s.tabIds.slice(), c = Math.max(0, Math.min(n, i.length));
1338
- i.splice(c, 0, r.id);
1339
- const u = i.map((g) => a[g]), d = o ? r.id : s.activeTabId ?? r.id, f = { ...t.groups, [e]: { ...s, tabIds: i, tabs: u, activeTabId: d } };
1340
- return { ...t, panels: a, groups: f };
1406
+ const a = { ...t.panels, [n.id]: n }, i = s.tabIds.slice(), c = Math.max(0, Math.min(r, i.length));
1407
+ i.splice(c, 0, n.id);
1408
+ const d = i.map((g) => a[g]), l = o ? n.id : s.activeTabId ?? n.id, p = { ...t.groups, [e]: { ...s, tabIds: i, tabs: d, activeTabId: l } };
1409
+ return { ...t, panels: a, groups: p };
1341
1410
  }, N = (t, e) => {
1342
1411
  if (!t.groups[e])
1343
1412
  throw new Error(`setFocusedGroup: group ${e} not found.`);
1344
1413
  return { ...t, focusedGroupId: e };
1345
- }, ze = (t, e) => {
1346
- const r = e - 1, n = t.groupOrder[r];
1347
- return n ? N(t, n) : t;
1348
- }, Xe = (t) => {
1349
- const e = t.groupOrder, r = t.focusedGroupId;
1350
- if (!r) {
1414
+ }, Ye = (t, e) => {
1415
+ const n = e - 1, r = t.groupOrder[n];
1416
+ return r ? N(t, r) : t;
1417
+ }, je = (t) => {
1418
+ const e = t.groupOrder, n = t.focusedGroupId;
1419
+ if (!n) {
1351
1420
  const s = e[0];
1352
1421
  return s ? N(t, s) : t;
1353
1422
  }
1354
- const n = e.indexOf(r), o = e[(n + 1) % e.length];
1423
+ const r = e.indexOf(n), o = e[(r + 1) % e.length];
1355
1424
  return N(t, o);
1356
- }, Ye = (t) => {
1357
- const e = t.groupOrder, r = t.focusedGroupId;
1358
- if (!r) {
1425
+ }, Ue = (t) => {
1426
+ const e = t.groupOrder, n = t.focusedGroupId;
1427
+ if (!n) {
1359
1428
  const s = e[e.length - 1];
1360
1429
  return s ? N(t, s) : t;
1361
1430
  }
1362
- const n = e.indexOf(r), o = e[(n - 1 + e.length) % e.length];
1431
+ const r = e.indexOf(n), o = e[(r - 1 + e.length) % e.length];
1363
1432
  return N(t, o);
1364
- }, Tt = (t, e, r, n) => {
1365
- const { tree: o, newGroupId: s } = wt(t.tree, e, r, n), a = { ...t.groups, [s]: Ne(s) }, i = F(o);
1433
+ }, xt = (t, e, n, r) => {
1434
+ const { tree: o, newGroupId: s } = Tt(t.tree, e, n, r), a = { ...t.groups, [s]: Fe(s) }, i = Y(o);
1366
1435
  return { ...t, tree: o, groups: a, groupOrder: i, focusedGroupId: s };
1367
- }, Gr = (t) => {
1368
- const r = { type: "group", groupId: "g_1" }, n = Object.fromEntries(t.map((i) => [i.id, i])), s = { g_1: { id: "g_1", tabIds: t.map((i) => i.id), tabs: t, activeTabId: t[0]?.id ?? null } };
1369
- return { tree: r, panels: n, groups: s, groupOrder: ["g_1"], focusedGroupId: "g_1" };
1370
- }, Fe = l.createContext(null), je = ({ value: t, children: e }) => /* @__PURE__ */ m(Fe.Provider, { value: t, children: e }), xt = l.createContext(null), Ke = () => {
1371
- const t = l.useContext(xt);
1436
+ }, Dn = (t) => {
1437
+ const n = { type: "group", groupId: "g_1" }, r = Object.fromEntries(t.map((i) => [i.id, i])), s = { g_1: { id: "g_1", tabIds: t.map((i) => i.id), tabs: t, activeTabId: t[0]?.id ?? null } };
1438
+ return { tree: n, panels: r, groups: s, groupOrder: ["g_1"], focusedGroupId: "g_1" };
1439
+ }, Ke = u.createContext(null), Ve = ({ value: t, children: e }) => /* @__PURE__ */ m(Ke.Provider, { value: t, children: e }), Gt = u.createContext(null), We = () => {
1440
+ const t = u.useContext(Gt);
1372
1441
  if (!t)
1373
1442
  throw new Error("useTree must be used within TreeProvider");
1374
1443
  return t;
1375
- }, Ve = ({ value: t, children: e }) => /* @__PURE__ */ m(xt.Provider, { value: t, children: e }), Ue = l.createContext(null), We = ({ value: t, children: e }) => /* @__PURE__ */ m(Ue.Provider, { value: t, children: e }), X = (t) => {
1376
- const e = _t(t, Number.POSITIVE_INFINITY);
1444
+ }, qe = ({ value: t, children: e }) => /* @__PURE__ */ m(Gt.Provider, { value: t, children: e }), Ze = u.createContext(null), Je = ({ value: t, children: e }) => /* @__PURE__ */ m(Ze.Provider, { value: t, children: e }), F = (t) => {
1445
+ const e = Bt(t, Number.POSITIVE_INFINITY);
1377
1446
  return M(e, 1);
1378
- }, qe = (t) => typeof t == "object" && t !== null, Ze = (t) => qe(t) ? "rows" in t ? !0 : "cols" in t : !1, Gt = (t) => {
1447
+ }, Qe = (t) => typeof t == "object" && t !== null, tn = (t) => Qe(t) ? "rows" in t ? !0 : "cols" in t : !1, Ct = (t) => {
1379
1448
  if (!t)
1380
1449
  return {
1381
1450
  rows: Number.POSITIVE_INFINITY,
1382
1451
  cols: Number.POSITIVE_INFINITY
1383
1452
  };
1384
1453
  if (typeof t == "number") {
1385
- const r = X(t);
1386
- return { rows: r, cols: r };
1454
+ const n = F(t);
1455
+ return { rows: n, cols: n };
1387
1456
  }
1388
- if (Ze(t))
1457
+ if (tn(t))
1389
1458
  return {
1390
- rows: X(t.rows),
1391
- cols: X(t.cols)
1459
+ rows: F(t.rows),
1460
+ cols: F(t.cols)
1392
1461
  };
1393
1462
  const e = t;
1394
1463
  return {
1395
- rows: X(e.maxHorizontal),
1396
- cols: X(e.maxVertical)
1464
+ rows: F(e.maxHorizontal),
1465
+ cols: F(e.maxVertical)
1397
1466
  };
1398
1467
  }, tt = (t) => {
1399
1468
  if (_(t))
1400
1469
  return { horizontal: 1, vertical: 1 };
1401
- const e = tt(t.a), r = tt(t.b);
1402
- return t.direction === "horizontal" ? { horizontal: e.horizontal + r.horizontal, vertical: Math.max(e.vertical, r.vertical) } : { horizontal: Math.max(e.horizontal, r.horizontal), vertical: e.vertical + r.vertical };
1403
- }, Je = (t, e, r) => {
1404
- const { tree: n } = wt(t, e, r, () => "__preview__");
1405
- return n;
1406
- }, nt = (t, e, r, n) => {
1407
- if (!Number.isFinite(n.rows) && !Number.isFinite(n.cols))
1470
+ const e = tt(t.a), n = tt(t.b);
1471
+ return t.direction === "horizontal" ? { horizontal: e.horizontal + n.horizontal, vertical: Math.max(e.vertical, n.vertical) } : { horizontal: Math.max(e.horizontal, n.horizontal), vertical: e.vertical + n.vertical };
1472
+ }, en = (t, e, n) => {
1473
+ const { tree: r } = Tt(t, e, n, () => "__preview__");
1474
+ return r;
1475
+ }, rt = (t, e, n, r) => {
1476
+ if (!Number.isFinite(r.rows) && !Number.isFinite(r.cols))
1408
1477
  return !0;
1409
- const o = Je(t, e, r), s = tt(o);
1410
- return !(s.horizontal > n.rows || s.vertical > n.cols);
1411
- }, St = {
1478
+ const o = en(t, e, n), s = tt(o);
1479
+ return !(s.horizontal > r.rows || s.vertical > r.cols);
1480
+ }, Et = {
1412
1481
  splitFocused: A("panelState/splitFocused", (t) => ({ direction: t })),
1413
1482
  focusGroupIndex: A("panelState/focusGroupIndex", (t) => ({ index1Based: t })),
1414
1483
  focusNextGroup: A("panelState/focusNextGroup"),
@@ -1432,137 +1501,137 @@ const he = (t, e) => {
1432
1501
  (t) => t
1433
1502
  ),
1434
1503
  adjustSplitRatio: A("panelState/adjustSplitRatio", (t) => t)
1435
- }, Qe = (t, e, r) => {
1436
- const n = t.groups[e.fromGroupId], o = t.groups[e.targetGroupId];
1437
- if (!n || !o || !n.tabs.find((f) => f.id === e.tabId))
1504
+ }, nn = (t, e, n) => {
1505
+ const r = t.groups[e.fromGroupId], o = t.groups[e.targetGroupId];
1506
+ if (!r || !o || !r.tabs.find((p) => p.id === e.tabId))
1438
1507
  return t;
1439
1508
  if (e.zone === "center" && e.fromGroupId === e.targetGroupId)
1440
- return yt(t, e.fromGroupId, e.tabId);
1509
+ return St(t, e.fromGroupId, e.tabId);
1441
1510
  if (e.zone === "center") {
1442
- const f = ct(t, e.fromGroupId, e.targetGroupId, e.tabId);
1443
- return N(f, e.targetGroupId);
1511
+ const p = lt(t, e.fromGroupId, e.targetGroupId, e.tabId);
1512
+ return N(p, e.targetGroupId);
1444
1513
  }
1445
1514
  const a = e.zone === "left" || e.zone === "right" ? "vertical" : "horizontal";
1446
- if (!nt(t.tree, e.targetGroupId, a, r.splitLimits))
1515
+ if (!rt(t.tree, e.targetGroupId, a, n.splitLimits))
1447
1516
  return t;
1448
- const i = r.createGroupId(), c = Tt(t, e.targetGroupId, a, () => i), u = e.zone === "left" || e.zone === "top" ? e.targetGroupId : i, d = ct(c, e.fromGroupId, u, e.tabId);
1449
- return N(d, u);
1450
- }, tr = (t, e) => {
1451
- const r = t.groups[e.fromGroupId], n = t.groups[e.targetGroupId];
1452
- if (!r || !n || !t.panels[e.tabId])
1517
+ const i = n.createGroupId(), c = xt(t, e.targetGroupId, a, () => i), d = e.zone === "left" || e.zone === "top" ? e.targetGroupId : i, l = lt(c, e.fromGroupId, d, e.tabId);
1518
+ return N(l, d);
1519
+ }, rn = (t, e) => {
1520
+ const n = t.groups[e.fromGroupId], r = t.groups[e.targetGroupId];
1521
+ if (!n || !r || !t.panels[e.tabId])
1453
1522
  return t;
1454
1523
  if (e.fromGroupId === e.targetGroupId) {
1455
- const g = r.tabIds.filter((T) => T !== e.tabId), y = Math.max(0, Math.min(e.targetIndex, g.length)), h = g.slice(0, y).concat([e.tabId], g.slice(y)), w = h.map((T) => t.panels[T]).filter(Boolean), I = { ...t.groups, [e.fromGroupId]: { ...r, tabIds: h, tabs: w } };
1456
- return { ...t, groups: I };
1524
+ const g = n.tabIds.filter((T) => T !== e.tabId), v = Math.max(0, Math.min(e.targetIndex, g.length)), b = g.slice(0, v).concat([e.tabId], g.slice(v)), I = b.map((T) => t.panels[T]).filter(Boolean), w = { ...t.groups, [e.fromGroupId]: { ...n, tabIds: b, tabs: I } };
1525
+ return { ...t, groups: w };
1457
1526
  }
1458
- const s = { ...t.groups }, a = r.tabIds.filter((g) => g !== e.tabId), i = a.map((g) => t.panels[g]);
1527
+ const s = { ...t.groups }, a = n.tabIds.filter((g) => g !== e.tabId), i = a.map((g) => t.panels[g]);
1459
1528
  s[e.fromGroupId] = {
1460
- ...r,
1529
+ ...n,
1461
1530
  tabIds: a,
1462
1531
  tabs: i,
1463
- activeTabId: r.activeTabId === e.tabId ? i[0]?.id ?? null : r.activeTabId
1532
+ activeTabId: n.activeTabId === e.tabId ? i[0]?.id ?? null : n.activeTabId
1464
1533
  };
1465
- const c = n.tabIds.filter((g) => g !== e.tabId), u = Math.max(0, Math.min(e.targetIndex, c.length)), d = c.slice(0, u).concat([e.tabId], c.slice(u)), f = d.map((g) => t.panels[g]).filter(Boolean);
1466
- return s[e.targetGroupId] = { ...n, tabIds: d, tabs: f, activeTabId: e.tabId }, { ...t, groups: s, focusedGroupId: e.targetGroupId };
1467
- }, er = mt(St, {
1468
- splitFocused: (t, e, r) => {
1469
- const n = t.focusedGroupId ?? t.groupOrder[0] ?? null;
1470
- return !n || !nt(t.tree, n, e.payload.direction, r.splitLimits) ? t : Tt(t, n, e.payload.direction, r.createGroupId);
1534
+ const c = r.tabIds.filter((g) => g !== e.tabId), d = Math.max(0, Math.min(e.targetIndex, c.length)), l = c.slice(0, d).concat([e.tabId], c.slice(d)), p = l.map((g) => t.panels[g]).filter(Boolean);
1535
+ return s[e.targetGroupId] = { ...r, tabIds: l, tabs: p, activeTabId: e.tabId }, { ...t, groups: s, focusedGroupId: e.targetGroupId };
1536
+ }, on = It(Et, {
1537
+ splitFocused: (t, e, n) => {
1538
+ const r = t.focusedGroupId ?? t.groupOrder[0] ?? null;
1539
+ return !r || !rt(t.tree, r, e.payload.direction, n.splitLimits) ? t : xt(t, r, e.payload.direction, n.createGroupId);
1471
1540
  },
1472
- focusGroupIndex: (t, e) => ze(t, e.payload.index1Based),
1473
- focusNextGroup: (t) => Xe(t),
1474
- focusPrevGroup: (t) => Ye(t),
1475
- setActiveTab: (t, e) => yt(t, e.payload.groupId, e.payload.tabId),
1541
+ focusGroupIndex: (t, e) => Ye(t, e.payload.index1Based),
1542
+ focusNextGroup: (t) => je(t),
1543
+ focusPrevGroup: (t) => Ue(t),
1544
+ setActiveTab: (t, e) => St(t, e.payload.groupId, e.payload.tabId),
1476
1545
  addTab: (t, e) => {
1477
- const { groupId: r, tab: n, index: o, makeActive: s } = e.payload;
1478
- return typeof o == "number" ? ut(t, r, n, o, s ?? !0) : at(t, r, n, s ?? !0);
1546
+ const { groupId: n, tab: r, index: o, makeActive: s } = e.payload;
1547
+ return typeof o == "number" ? dt(t, n, r, o, s ?? !0) : ut(t, n, r, s ?? !0);
1479
1548
  },
1480
- addNewTab: (t, e, r) => {
1481
- if (!r.createPanelId)
1549
+ addNewTab: (t, e, n) => {
1550
+ if (!n.createPanelId)
1482
1551
  throw new Error("addNewTab requires PanelSystemProvider.createPanelId");
1483
- const o = { id: r.createPanelId(), title: e.payload.title, render: () => e.payload.title }, { groupId: s, index: a, makeActive: i } = e.payload;
1484
- return typeof a == "number" ? ut(t, s, o, a, i ?? !0) : at(t, s, o, i ?? !0);
1552
+ const o = { id: n.createPanelId(), title: e.payload.title, render: () => e.payload.title }, { groupId: s, index: a, makeActive: i } = e.payload;
1553
+ return typeof a == "number" ? dt(t, s, o, a, i ?? !0) : ut(t, s, o, i ?? !0);
1485
1554
  },
1486
- removeTab: (t, e) => $e(t, e.payload.groupId, e.payload.tabId),
1487
- contentDrop: (t, e, r) => Qe(t, e.payload, r),
1488
- tabDrop: (t, e) => tr(t, e.payload),
1555
+ removeTab: (t, e) => Xe(t, e.payload.groupId, e.payload.tabId),
1556
+ contentDrop: (t, e, n) => nn(t, e.payload, n),
1557
+ tabDrop: (t, e) => rn(t, e.payload),
1489
1558
  adjustSplitRatio: (t, e) => {
1490
- const r = q(t.tree, e.payload.path);
1491
- if (_(r))
1559
+ const n = q(t.tree, e.payload.path);
1560
+ if (_(n))
1492
1561
  return t;
1493
- const n = He(t.tree, e.payload.path, r.ratio + e.payload.deltaRatio);
1494
- return { ...t, tree: n };
1562
+ const r = $e(t.tree, e.payload.path, n.ratio + e.payload.deltaRatio);
1563
+ return { ...t, tree: r };
1495
1564
  }
1496
- }), lt = (t, e, r) => {
1497
- const n = er[e.type];
1498
- if (!n)
1565
+ }), pt = (t, e, n) => {
1566
+ const r = on[e.type];
1567
+ if (!r)
1499
1568
  return t;
1500
- const o = n(t, e, r);
1569
+ const o = r(t, e, n);
1501
1570
  return Q(o);
1502
- }, Et = l.createContext(null), z = () => {
1503
- const t = l.useContext(Et);
1571
+ }, Rt = u.createContext(null), $ = () => {
1572
+ const t = u.useContext(Rt);
1504
1573
  if (!t)
1505
1574
  throw new Error("usePanelSystem must be used within PanelSystemProvider");
1506
1575
  return t;
1507
- }, rr = ({
1576
+ }, sn = ({
1508
1577
  initialState: t,
1509
1578
  createGroupId: e,
1510
- createPanelId: r,
1511
- state: n,
1579
+ createPanelId: n,
1580
+ state: r,
1512
1581
  onStateChange: o,
1513
1582
  splitLimits: s,
1514
1583
  children: a
1515
1584
  }) => {
1516
- const i = l.useMemo(() => Q(t), [t]), c = l.useMemo(() => Gt(s), [s]), u = l.useRef({ createGroupId: e, splitLimits: c, createPanelId: r });
1517
- u.current.createGroupId = e, u.current.splitLimits = c, u.current.createPanelId = r;
1518
- const [d, f] = l.useReducer(
1519
- (x, E) => lt(x, E, u.current),
1585
+ const i = u.useMemo(() => Q(t), [t]), c = u.useMemo(() => Ct(s), [s]), d = u.useRef({ createGroupId: e, splitLimits: c, createPanelId: n });
1586
+ d.current.createGroupId = e, d.current.splitLimits = c, d.current.createPanelId = n;
1587
+ const [l, p] = u.useReducer(
1588
+ (S, C) => pt(S, C, d.current),
1520
1589
  i
1521
- ), g = l.useMemo(
1522
- () => n ? Q(n) : d,
1523
- [n, d]
1524
- ), y = l.useRef(g);
1525
- y.current = g;
1526
- const h = n !== void 0, w = l.useCallback(
1527
- (x) => {
1528
- if (h) {
1529
- const E = lt(y.current, x, u.current);
1530
- o?.(E);
1590
+ ), g = u.useMemo(
1591
+ () => r ? Q(r) : l,
1592
+ [r, l]
1593
+ ), v = u.useRef(g);
1594
+ v.current = g;
1595
+ const b = r !== void 0, I = u.useCallback(
1596
+ (S) => {
1597
+ if (b) {
1598
+ const C = pt(v.current, S, d.current);
1599
+ o?.(C);
1531
1600
  return;
1532
1601
  }
1533
- f(x);
1602
+ p(S);
1534
1603
  },
1535
- [h, o, f]
1536
- ), I = l.useMemo(() => he(St, w), [w]), T = l.useMemo(
1604
+ [b, o, p]
1605
+ ), w = u.useMemo(() => Ie(Et, I), [I]), T = u.useMemo(
1537
1606
  () => ({
1538
- setActiveTab: I.setActiveTab,
1539
- tabDrop: I.tabDrop
1607
+ setActiveTab: w.setActiveTab,
1608
+ tabDrop: w.tabDrop
1540
1609
  }),
1541
- [I]
1542
- ), b = l.useMemo(
1610
+ [w]
1611
+ ), h = u.useMemo(
1543
1612
  () => ({
1544
- adjustSplitRatio: I.adjustSplitRatio
1613
+ adjustSplitRatio: w.adjustSplitRatio
1545
1614
  }),
1546
- [I]
1547
- ), v = l.useMemo(
1615
+ [w]
1616
+ ), y = u.useMemo(
1548
1617
  () => ({
1549
- focusGroupIndex: I.focusGroupIndex,
1550
- focusNextGroup: I.focusNextGroup,
1551
- focusPrevGroup: I.focusPrevGroup
1618
+ focusGroupIndex: w.focusGroupIndex,
1619
+ focusNextGroup: w.focusNextGroup,
1620
+ focusPrevGroup: w.focusPrevGroup
1552
1621
  }),
1553
- [I]
1554
- ), p = l.useMemo(
1622
+ [w]
1623
+ ), f = u.useMemo(
1555
1624
  () => ({
1556
1625
  state: g,
1557
- dispatch: w,
1558
- actions: I
1626
+ dispatch: I,
1627
+ actions: w
1559
1628
  }),
1560
- [g, w, I]
1629
+ [g, I, w]
1561
1630
  );
1562
- return /* @__PURE__ */ m(Et.Provider, { value: p, children: /* @__PURE__ */ m(je, { value: T, children: /* @__PURE__ */ m(Ve, { value: b, children: /* @__PURE__ */ m(We, { value: v, children: a }) }) }) });
1563
- }, nr = () => {
1564
- const { actions: t } = z();
1565
- return l.useMemo(
1631
+ return /* @__PURE__ */ m(Rt.Provider, { value: f, children: /* @__PURE__ */ m(Ve, { value: T, children: /* @__PURE__ */ m(qe, { value: h, children: /* @__PURE__ */ m(Je, { value: y, children: a }) }) }) });
1632
+ }, an = () => {
1633
+ const { actions: t } = $();
1634
+ return u.useMemo(
1566
1635
  () => ({
1567
1636
  splitFocused: (e) => {
1568
1637
  t.splitFocused(e);
@@ -1581,341 +1650,342 @@ const he = (t, e) => {
1581
1650
  }),
1582
1651
  [t]
1583
1652
  );
1584
- }, or = () => {
1585
- const { actions: t } = z(), e = l.useCallback(
1586
- ({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a }) => {
1587
- t.contentDrop({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a });
1653
+ }, cn = () => {
1654
+ const { actions: t } = $(), e = u.useCallback(
1655
+ ({ fromGroupId: r, tabId: o, targetGroupId: s, zone: a }) => {
1656
+ t.contentDrop({ fromGroupId: r, tabId: o, targetGroupId: s, zone: a });
1588
1657
  },
1589
1658
  [t]
1590
- ), r = l.useCallback(
1591
- ({ fromGroupId: n, tabId: o, targetGroupId: s, targetIndex: a }) => {
1592
- t.tabDrop({ fromGroupId: n, tabId: o, targetGroupId: s, targetIndex: a });
1659
+ ), n = u.useCallback(
1660
+ ({ fromGroupId: r, tabId: o, targetGroupId: s, targetIndex: a }) => {
1661
+ t.tabDrop({ fromGroupId: r, tabId: o, targetGroupId: s, targetIndex: a });
1593
1662
  },
1594
1663
  [t]
1595
1664
  );
1596
- return { onCommitContentDrop: e, onCommitTabDrop: r };
1597
- }, sr = () => {
1598
- const t = ee(), e = nr();
1599
- return l.useEffect(() => {
1600
- oe(t, e);
1665
+ return { onCommitContentDrop: e, onCommitTabDrop: n };
1666
+ }, un = () => {
1667
+ const t = oe(), e = an();
1668
+ return u.useEffect(() => {
1669
+ ae(t, e);
1601
1670
  }, [t, e]), null;
1602
- }, Ct = l.createContext(null), ir = () => {
1603
- const t = l.useContext(Ct);
1671
+ }, Pt = u.createContext(null), ln = () => {
1672
+ const t = u.useContext(Pt);
1604
1673
  if (!t)
1605
1674
  throw new Error("useContentRegistry must be used within ContentRegistryProvider");
1606
1675
  return t;
1607
- }, ar = (t) => {
1676
+ }, dn = (t) => {
1608
1677
  const e = document.createElement("div");
1609
1678
  return e.setAttribute("data-panel-wrapper", t), e.style.display = "contents", e;
1610
- }, cr = (t, e, r) => {
1611
- const [n] = l.useState(() => ar(t));
1612
- return rt(() => (n.style.display = r ? "contents" : "none", e && n.parentElement !== e && e.appendChild(n), () => {
1613
- n.parentElement?.removeChild(n);
1614
- }), [n, e, r]), n;
1615
- }, Rt = l.memo(
1616
- ({ panelId: t, content: e, placement: r, containerElement: n }) => {
1617
- const o = r?.isActive ?? !1, s = cr(t, n, o);
1618
- return Qt(
1619
- /* @__PURE__ */ m(l.Activity, { mode: o ? "visible" : "hidden", children: e }),
1679
+ }, pn = (t, e, n) => {
1680
+ const [r] = u.useState(() => dn(t));
1681
+ return nt(() => (r.style.display = n ? "contents" : "none", e && r.parentElement !== e && e.appendChild(r), () => {
1682
+ r.parentElement?.removeChild(r);
1683
+ }), [r, e, n]), r;
1684
+ }, Dt = u.memo(
1685
+ ({ panelId: t, content: e, placement: n, containerElement: r }) => {
1686
+ const o = n?.isActive ?? !1, s = pn(t, r, o);
1687
+ return ee(
1688
+ /* @__PURE__ */ m(u.Activity, { mode: o ? "visible" : "hidden", children: e }),
1620
1689
  s
1621
1690
  );
1622
1691
  }
1623
1692
  );
1624
- Rt.displayName = "PanelContentHost";
1625
- const ur = ({
1693
+ Dt.displayName = "PanelContentHost";
1694
+ const fn = ({
1626
1695
  children: t,
1627
1696
  panels: e,
1628
- placements: r
1697
+ placements: n
1629
1698
  }) => {
1630
- const [n, o] = l.useState(/* @__PURE__ */ new Map()), s = l.useRef(/* @__PURE__ */ new Map()), a = l.useCallback((d, f) => {
1631
- o((g) => {
1632
- const y = new Map(g);
1633
- return f ? y.set(d, f) : y.delete(d), y;
1699
+ const [r, o] = u.useState(/* @__PURE__ */ new Map()), s = u.useCallback((g, v) => {
1700
+ o((b) => {
1701
+ const I = new Map(b);
1702
+ return v ? I.set(g, v) : I.delete(g), I;
1634
1703
  });
1635
- }, []), i = l.useMemo(
1636
- () => ({ registerContentContainer: a }),
1637
- [a]
1638
- ), c = l.useCallback((d, f) => {
1639
- const g = s.current.get(d);
1640
- if (g)
1641
- return g;
1642
- const y = f.render(f.id);
1643
- return s.current.set(d, y), y;
1644
- }, []), u = Object.keys(e);
1645
- return /* @__PURE__ */ H(Ct.Provider, { value: i, children: [
1704
+ }, []), a = u.useMemo(
1705
+ () => ({ registerContentContainer: s }),
1706
+ [s]
1707
+ ), i = u.useRef(e);
1708
+ i.current = e;
1709
+ const c = u.useCallback((g) => {
1710
+ const v = i.current[g];
1711
+ return v ? v.render(v.id) : null;
1712
+ }, []), d = u.useMemo(() => Object.keys(e), [e]), { getCachedContent: l } = ne({
1713
+ resolveContent: c,
1714
+ validIds: d
1715
+ }), p = Object.keys(e);
1716
+ return /* @__PURE__ */ H(Pt.Provider, { value: a, children: [
1646
1717
  t,
1647
- u.map((d) => {
1648
- const f = e[d];
1649
- if (!f)
1718
+ p.map((g) => {
1719
+ if (!e[g])
1650
1720
  return null;
1651
- const g = r[d] ?? null, y = g ? n.get(g.groupId) ?? null : null, h = c(d, f);
1721
+ const b = n[g] ?? null, I = b ? r.get(b.groupId) ?? null : null, w = l(g);
1652
1722
  return /* @__PURE__ */ m(
1653
- Rt,
1723
+ Dt,
1654
1724
  {
1655
- panelId: d,
1656
- content: h,
1657
- placement: g,
1658
- containerElement: y
1725
+ panelId: g,
1726
+ content: w,
1727
+ placement: b,
1728
+ containerElement: I
1659
1729
  },
1660
- d
1730
+ g
1661
1731
  );
1662
1732
  })
1663
1733
  ] });
1664
- }, lr = ({
1734
+ }, gn = ({
1665
1735
  children: t,
1666
1736
  emptyContentComponent: e,
1667
- doubleClickToAdd: r
1737
+ doubleClickToAdd: n
1668
1738
  }) => {
1669
- const n = W(), { state: o, actions: s } = z(), { registerContentContainer: a } = ir(), i = l.useCallback(() => l.createElement("div", { style: { color: "#888", fontSize: 12, padding: 12 } }, "No tabs"), []), c = e ?? i, u = l.useCallback(
1739
+ const r = W(), { state: o, actions: s } = $(), { registerContentContainer: a } = ln(), i = u.useCallback(() => u.createElement("div", { style: { color: "#888", fontSize: 12, padding: 12 } }, "No tabs"), []), c = e ?? i, d = u.useCallback(
1670
1740
  (T) => {
1671
- const b = o.groups[T];
1672
- if (!b)
1741
+ const h = o.groups[T];
1742
+ if (!h)
1673
1743
  return null;
1674
- const v = b.tabIds.map((p) => o.panels[p]).filter(Boolean);
1675
- return { ...b, tabs: v };
1744
+ const y = h.tabIds.map((f) => o.panels[f]).filter(Boolean);
1745
+ return { ...h, tabs: y };
1676
1746
  },
1677
1747
  [o.groups, o.panels]
1678
- ), d = l.useCallback(
1748
+ ), l = u.useCallback(
1679
1749
  (T) => {
1680
- const b = o.groups[T];
1681
- return !b || b.tabIds.length === 0 ? /* @__PURE__ */ m(c, {}) : null;
1750
+ const h = o.groups[T];
1751
+ return !h || h.tabIds.length === 0 ? /* @__PURE__ */ m(c, {}) : null;
1682
1752
  },
1683
1753
  [o.groups, c]
1684
- ), f = l.useCallback((T, b) => {
1685
- s.setActiveTab(T, b);
1686
- }, [s]), g = l.useCallback((T) => {
1754
+ ), p = u.useCallback((T, h) => {
1755
+ s.setActiveTab(T, h);
1756
+ }, [s]), g = u.useCallback((T) => {
1687
1757
  s.addNewTab({ groupId: T, title: "New Tab", makeActive: !0 });
1688
- }, [s]), y = l.useCallback((T, b) => {
1689
- s.removeTab(T, b);
1690
- }, [s]), h = l.useCallback((T, b, v) => {
1691
- s.setActiveTab(b, T), n.onStartTabDrag(T, b, v);
1692
- }, [s, n]), w = l.useCallback((T, b) => {
1693
- const v = o.groups[T];
1694
- !v || !v.activeTabId || n.onStartContentDrag(T, v.activeTabId, b);
1695
- }, [o.groups, n]), I = l.useMemo(
1696
- () => ({ getGroup: u, getGroupContent: d, onClickTab: f, onAddTab: g, onCloseTab: y, onStartTabDrag: h, onStartContentDrag: w, doubleClickToAdd: r, registerContentContainer: a }),
1697
- [u, d, f, g, y, h, w, r, a]
1758
+ }, [s]), v = u.useCallback((T, h) => {
1759
+ s.removeTab(T, h);
1760
+ }, [s]), b = u.useCallback((T, h, y) => {
1761
+ s.setActiveTab(h, T), r.onStartTabDrag(T, h, y);
1762
+ }, [s, r]), I = u.useCallback((T, h) => {
1763
+ const y = o.groups[T];
1764
+ !y || !y.activeTabId || r.onStartContentDrag(T, y.activeTabId, h);
1765
+ }, [o.groups, r]), w = u.useMemo(
1766
+ () => ({ getGroup: d, getGroupContent: l, onClickTab: p, onAddTab: g, onCloseTab: v, onStartTabDrag: b, onStartContentDrag: I, doubleClickToAdd: n, registerContentContainer: a }),
1767
+ [d, l, p, g, v, b, I, n, a]
1698
1768
  );
1699
- return /* @__PURE__ */ m(ue, { value: I, children: t });
1700
- }, dr = ({
1769
+ return /* @__PURE__ */ m(pe, { value: w, children: t });
1770
+ }, bn = ({
1701
1771
  children: t,
1702
1772
  emptyContentComponent: e,
1703
- doubleClickToAdd: r
1773
+ doubleClickToAdd: n
1704
1774
  }) => {
1705
- const { state: n } = z(), o = l.useMemo(() => {
1775
+ const { state: r } = $(), o = u.useMemo(() => {
1706
1776
  const s = {};
1707
- for (const [a, i] of Object.entries(n.groups))
1777
+ for (const [a, i] of Object.entries(r.groups))
1708
1778
  for (const c of i.tabIds)
1709
1779
  s[c] = {
1710
1780
  groupId: a,
1711
1781
  isActive: c === i.activeTabId
1712
1782
  };
1713
1783
  return s;
1714
- }, [n.groups]);
1715
- return /* @__PURE__ */ m(ur, { panels: n.panels, placements: o, children: /* @__PURE__ */ m(lr, { emptyContentComponent: e, doubleClickToAdd: r, children: t }) });
1716
- }, Y = (t, e, r, n) => {
1784
+ }, [r.groups]);
1785
+ return /* @__PURE__ */ m(fn, { panels: r.panels, placements: o, children: /* @__PURE__ */ m(gn, { emptyContentComponent: e, doubleClickToAdd: n, children: t }) });
1786
+ }, X = (t, e, n, r) => {
1717
1787
  if (_(t))
1718
- return n;
1719
- const o = t.direction, s = o === "vertical" ? r.x + r.w * t.ratio : r.y + r.h * t.ratio;
1720
- if (n.push({ path: e, direction: o, parentRect: r, linePos: s }), o === "vertical") {
1721
- const c = r.w * t.ratio, u = r.w - c;
1722
- return Y(t.a, [...e, "a"], { x: r.x, y: r.y, w: c, h: r.h }, n), Y(t.b, [...e, "b"], { x: r.x + c, y: r.y, w: u, h: r.h }, n), n;
1788
+ return r;
1789
+ const o = t.direction, s = o === "vertical" ? n.x + n.w * t.ratio : n.y + n.h * t.ratio;
1790
+ if (r.push({ path: e, direction: o, parentRect: n, linePos: s }), o === "vertical") {
1791
+ const c = n.w * t.ratio, d = n.w - c;
1792
+ return X(t.a, [...e, "a"], { x: n.x, y: n.y, w: c, h: n.h }, r), X(t.b, [...e, "b"], { x: n.x + c, y: n.y, w: d, h: n.h }, r), r;
1723
1793
  }
1724
- const a = r.h * t.ratio, i = r.h - a;
1725
- return Y(t.a, [...e, "a"], { x: r.x, y: r.y, w: r.w, h: a }, n), Y(t.b, [...e, "b"], { x: r.x, y: r.y + a, w: r.w, h: i }, n), n;
1726
- }, pr = ({ containerRef: t }) => {
1727
- const { state: e } = z(), { adjustSplitRatio: r } = Ke(), n = l.useMemo(() => Y(e.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [e.tree]), [o, s] = l.useState(null);
1728
- if (rt(() => {
1794
+ const a = n.h * t.ratio, i = n.h - a;
1795
+ return X(t.a, [...e, "a"], { x: n.x, y: n.y, w: n.w, h: a }, r), X(t.b, [...e, "b"], { x: n.x, y: n.y + a, w: n.w, h: i }, r), r;
1796
+ }, hn = ({ containerRef: t }) => {
1797
+ const { state: e } = $(), { adjustSplitRatio: n } = We(), r = u.useMemo(() => X(e.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [e.tree]), [o, s] = u.useState(null);
1798
+ if (nt(() => {
1729
1799
  const i = t.current;
1730
1800
  if (!i)
1731
1801
  return;
1732
1802
  const c = () => {
1733
- const y = i.getBoundingClientRect();
1734
- s({ left: y.left, top: y.top, width: y.width, height: y.height });
1803
+ const v = i.getBoundingClientRect();
1804
+ s({ left: v.left, top: v.top, width: v.width, height: v.height });
1735
1805
  };
1736
1806
  c();
1737
- function u() {
1807
+ function d() {
1738
1808
  try {
1739
- const y = window.ResizeObserver;
1740
- return typeof y == "function" ? y : null;
1809
+ const v = window.ResizeObserver;
1810
+ return typeof v == "function" ? v : null;
1741
1811
  } catch {
1742
1812
  return null;
1743
1813
  }
1744
1814
  }
1745
- const d = u(), f = d ? new d(() => c()) : null;
1746
- f && f.observe(i);
1815
+ const l = d(), p = l ? new l(() => c()) : null;
1816
+ p && p.observe(i);
1747
1817
  const g = () => c();
1748
1818
  return window.addEventListener("scroll", g, !0), () => {
1749
- window.removeEventListener("scroll", g, !0), f && f.disconnect();
1819
+ window.removeEventListener("scroll", g, !0), p && p.disconnect();
1750
1820
  };
1751
1821
  }, [t, e.tree]), !o)
1752
1822
  return null;
1753
1823
  const a = (i, c) => {
1754
- const u = {
1824
+ const d = {
1755
1825
  left: o.left + o.width * i.parentRect.x / 100,
1756
1826
  top: o.top + o.height * i.parentRect.y / 100,
1757
1827
  width: o.width * i.parentRect.w / 100,
1758
1828
  height: o.height * i.parentRect.h / 100
1759
- }, d = Jt;
1829
+ }, l = te;
1760
1830
  if (i.direction === "vertical") {
1761
- const h = u.left + u.width * (i.linePos - i.parentRect.x) / i.parentRect.w, w = {
1831
+ const b = d.left + d.width * (i.linePos - i.parentRect.x) / i.parentRect.w, I = {
1762
1832
  position: "fixed",
1763
- left: `calc(${Math.round(h)}px - ${d} / 2)`,
1764
- top: Math.round(u.top),
1765
- width: d,
1766
- height: Math.round(u.height),
1833
+ left: `calc(${Math.round(b)}px - ${l} / 2)`,
1834
+ top: Math.round(d.top),
1835
+ width: l,
1836
+ height: Math.round(d.height),
1767
1837
  cursor: "col-resize",
1768
1838
  pointerEvents: "auto"
1769
1839
  };
1770
- return /* @__PURE__ */ m("div", { style: w, children: /* @__PURE__ */ m(ot, { direction: "vertical", onResize: (T) => {
1771
- const b = o.width * i.parentRect.w / 100, v = b === 0 ? 0 : T / b;
1772
- r({ path: i.path, deltaRatio: v });
1840
+ return /* @__PURE__ */ m("div", { style: I, children: /* @__PURE__ */ m(ot, { direction: "vertical", onResize: (T) => {
1841
+ const h = o.width * i.parentRect.w / 100, y = h === 0 ? 0 : T / h;
1842
+ n({ path: i.path, deltaRatio: y });
1773
1843
  } }) }, `split-${c}`);
1774
1844
  }
1775
- const f = u.top + u.height * (i.linePos - i.parentRect.y) / i.parentRect.h, g = {
1845
+ const p = d.top + d.height * (i.linePos - i.parentRect.y) / i.parentRect.h, g = {
1776
1846
  position: "fixed",
1777
- left: Math.round(u.left),
1778
- top: `calc(${Math.round(f)}px - ${d} / 2)`,
1779
- width: Math.round(u.width),
1780
- height: d,
1847
+ left: Math.round(d.left),
1848
+ top: `calc(${Math.round(p)}px - ${l} / 2)`,
1849
+ width: Math.round(d.width),
1850
+ height: l,
1781
1851
  cursor: "row-resize",
1782
1852
  pointerEvents: "auto"
1783
1853
  };
1784
- return /* @__PURE__ */ m("div", { style: g, children: /* @__PURE__ */ m(ot, { direction: "horizontal", onResize: (h) => {
1785
- const w = o.height * i.parentRect.h / 100, I = w === 0 ? 0 : h / w;
1786
- r({ path: i.path, deltaRatio: I });
1854
+ return /* @__PURE__ */ m("div", { style: g, children: /* @__PURE__ */ m(ot, { direction: "horizontal", onResize: (b) => {
1855
+ const I = o.height * i.parentRect.h / 100, w = I === 0 ? 0 : b / I;
1856
+ n({ path: i.path, deltaRatio: w });
1787
1857
  } }) }, `split-${c}`);
1788
1858
  };
1789
- return /* @__PURE__ */ m("div", { style: { position: "fixed", inset: 0, pointerEvents: "none" }, children: n.map((i, c) => a(i, c)) });
1790
- }, fr = {
1859
+ return /* @__PURE__ */ m("div", { style: { position: "fixed", inset: 0, pointerEvents: "none" }, children: r.map((i, c) => a(i, c)) });
1860
+ }, mn = {
1791
1861
  position: "relative",
1792
1862
  display: "flex",
1793
1863
  width: "100%",
1794
1864
  height: "100%"
1795
- }, br = ({
1865
+ }, vn = ({
1796
1866
  state: t,
1797
1867
  layoutMode: e,
1798
- gridTracksInteractive: r,
1799
- view: n,
1868
+ gridTracksInteractive: n,
1869
+ view: r,
1800
1870
  tabBarComponent: o,
1801
1871
  panelGroupComponent: s
1802
1872
  }) => {
1803
- const a = (c) => n ? /* @__PURE__ */ m(n, { groupId: c }) : /* @__PURE__ */ m(Ge, { id: c, TabBarComponent: o, PanelGroupComponent: s });
1873
+ const a = (c) => r ? /* @__PURE__ */ m(r, { groupId: c }) : /* @__PURE__ */ m(Ee, { id: c, TabBarComponent: o, PanelGroupComponent: s });
1804
1874
  if (e === "grid") {
1805
- const c = ae(t, a, !!r);
1875
+ const c = le(t, a, !!n);
1806
1876
  return /* @__PURE__ */ m(st, { config: c.config, layers: c.layers });
1807
1877
  }
1808
- const i = ie(t, a);
1878
+ const i = ue(t, a);
1809
1879
  return /* @__PURE__ */ m(st, { config: i.config, layers: i.layers });
1810
- }, gr = ({
1880
+ }, In = ({
1811
1881
  containerRef: t,
1812
1882
  layoutMode: e,
1813
- gridTracksInteractive: r,
1814
- dragThresholdPx: n,
1883
+ gridTracksInteractive: n,
1884
+ dragThresholdPx: r,
1815
1885
  view: o,
1816
1886
  style: s,
1817
1887
  className: a,
1818
1888
  tabBarComponent: i,
1819
1889
  panelGroupComponent: c,
1820
- splitLimits: u,
1821
- emptyContentComponent: d,
1822
- doubleClickToAdd: f
1890
+ splitLimits: d,
1891
+ emptyContentComponent: l,
1892
+ doubleClickToAdd: p
1823
1893
  }) => {
1824
- const { state: g } = z(), { onCommitContentDrop: y, onCommitTabDrop: h } = or(), w = l.useMemo(() => ({ ...fr, ...s }), [s]), I = l.useCallback(
1825
- ({ targetGroupId: T, zone: b }) => {
1826
- if (b === "center")
1894
+ const { state: g } = $(), { onCommitContentDrop: v, onCommitTabDrop: b } = cn(), I = u.useMemo(() => ({ ...mn, ...s }), [s]), w = u.useCallback(
1895
+ ({ targetGroupId: T, zone: h }) => {
1896
+ if (h === "center")
1827
1897
  return !0;
1828
- const v = b === "left" || b === "right" ? "vertical" : "horizontal";
1829
- return nt(g.tree, T, v, u);
1898
+ const y = h === "left" || h === "right" ? "vertical" : "horizontal";
1899
+ return rt(g.tree, T, y, d);
1830
1900
  },
1831
- [g.tree, u]
1901
+ [g.tree, d]
1832
1902
  );
1833
- return /* @__PURE__ */ m(le, { children: /* @__PURE__ */ H(
1834
- Ie,
1903
+ return /* @__PURE__ */ m(fe, { children: /* @__PURE__ */ H(
1904
+ Te,
1835
1905
  {
1836
1906
  containerRef: t,
1837
- dragThresholdPx: n,
1838
- onCommitContentDrop: y,
1839
- onCommitTabDrop: h,
1840
- isContentZoneAllowed: I,
1907
+ dragThresholdPx: r,
1908
+ onCommitContentDrop: v,
1909
+ onCommitTabDrop: b,
1910
+ isContentZoneAllowed: w,
1841
1911
  children: [
1842
- /* @__PURE__ */ m(dr, { emptyContentComponent: d, doubleClickToAdd: f, children: /* @__PURE__ */ m("div", { ref: t, className: a, style: w, children: /* @__PURE__ */ m(
1843
- br,
1912
+ /* @__PURE__ */ m(bn, { emptyContentComponent: l, doubleClickToAdd: p, children: /* @__PURE__ */ m("div", { ref: t, className: a, style: I, children: /* @__PURE__ */ m(
1913
+ vn,
1844
1914
  {
1845
1915
  state: g,
1846
1916
  layoutMode: e,
1847
- gridTracksInteractive: r,
1917
+ gridTracksInteractive: n,
1848
1918
  view: o,
1849
1919
  tabBarComponent: i,
1850
1920
  panelGroupComponent: c
1851
1921
  }
1852
1922
  ) }) }),
1853
- /* @__PURE__ */ m(pr, { containerRef: t }),
1854
- /* @__PURE__ */ m(hr, {})
1923
+ /* @__PURE__ */ m(hn, { containerRef: t }),
1924
+ /* @__PURE__ */ m(wn, {})
1855
1925
  ]
1856
1926
  }
1857
1927
  ) });
1858
- }, hr = () => {
1928
+ }, wn = () => {
1859
1929
  const t = W();
1860
1930
  return /* @__PURE__ */ H(et, { children: [
1861
- /* @__PURE__ */ m(Ae, { suggest: t.suggest }),
1862
- /* @__PURE__ */ m(Be, {})
1931
+ /* @__PURE__ */ m(_e, { suggest: t.suggest }),
1932
+ /* @__PURE__ */ m(Ne, {})
1863
1933
  ] });
1864
- }, Sr = ({
1934
+ }, An = ({
1865
1935
  initialState: t,
1866
1936
  createGroupId: e,
1867
- createPanelId: r,
1868
- layoutMode: n,
1937
+ createPanelId: n,
1938
+ layoutMode: r,
1869
1939
  gridTracksInteractive: o,
1870
1940
  dragThresholdPx: s,
1871
1941
  view: a,
1872
1942
  emptyContentComponent: i,
1873
1943
  state: c,
1874
- onStateChange: u,
1875
- className: d,
1876
- style: f,
1944
+ onStateChange: d,
1945
+ className: l,
1946
+ style: p,
1877
1947
  tabBarComponent: g,
1878
- panelGroupComponent: y,
1879
- splitLimits: h,
1880
- doubleClickToAdd: w
1948
+ panelGroupComponent: v,
1949
+ splitLimits: b,
1950
+ doubleClickToAdd: I
1881
1951
  }) => {
1882
1952
  if (!t)
1883
1953
  throw new Error("PanelSystem requires initialState.");
1884
1954
  if (!e)
1885
1955
  throw new Error("PanelSystem requires explicit createGroupId function.");
1886
- if (!n)
1956
+ if (!r)
1887
1957
  throw new Error("PanelSystem requires explicit layoutMode ('absolute' | 'grid').");
1888
- if (n === "grid" && o === void 0)
1958
+ if (r === "grid" && o === void 0)
1889
1959
  throw new Error("PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.");
1890
1960
  if (s === void 0)
1891
1961
  throw new Error("PanelSystem requires explicit 'dragThresholdPx' value.");
1892
- const I = l.useRef(null), T = l.useMemo(() => Gt(h), [h]);
1962
+ const w = u.useRef(null), T = u.useMemo(() => Ct(b), [b]);
1893
1963
  return /* @__PURE__ */ m(
1894
- rr,
1964
+ sn,
1895
1965
  {
1896
1966
  initialState: t,
1897
1967
  createGroupId: e,
1898
- createPanelId: r,
1968
+ createPanelId: n,
1899
1969
  state: c,
1900
- onStateChange: u,
1901
- splitLimits: h,
1902
- children: /* @__PURE__ */ H(ne, { children: [
1903
- /* @__PURE__ */ m(sr, {}),
1970
+ onStateChange: d,
1971
+ splitLimits: b,
1972
+ children: /* @__PURE__ */ H(ie, { children: [
1973
+ /* @__PURE__ */ m(un, {}),
1904
1974
  /* @__PURE__ */ m(
1905
- gr,
1975
+ In,
1906
1976
  {
1907
- containerRef: I,
1908
- layoutMode: n,
1977
+ containerRef: w,
1978
+ layoutMode: r,
1909
1979
  gridTracksInteractive: o,
1910
1980
  dragThresholdPx: s,
1911
1981
  view: a,
1912
- style: f,
1913
- className: d,
1982
+ style: p,
1983
+ className: l,
1914
1984
  tabBarComponent: g,
1915
- panelGroupComponent: y,
1985
+ panelGroupComponent: v,
1916
1986
  splitLimits: T,
1917
1987
  emptyContentComponent: i,
1918
- doubleClickToAdd: w
1988
+ doubleClickToAdd: I
1919
1989
  }
1920
1990
  )
1921
1991
  ] })
@@ -1923,16 +1993,18 @@ const ur = ({
1923
1993
  );
1924
1994
  };
1925
1995
  export {
1926
- Mr as CSS_VAR_PREFIX,
1927
- Rr as Drawer,
1928
- Pr as DrawerLayers,
1996
+ zn as CSS_VAR_PREFIX,
1997
+ _n as Drawer,
1998
+ On as DrawerLayers,
1999
+ Bn as FloatingWindow,
1929
2000
  st as GridLayout,
1930
- Tr as HorizontalDivider,
1931
- Sr as PanelSystem,
2001
+ En as HorizontalDivider,
2002
+ An as PanelSystem,
1932
2003
  ot as ResizeHandle,
1933
- Gr as buildInitialState,
1934
- Dr as runTransition,
1935
- xr as useLayerDragHandle,
1936
- Ar as useTransitionState
2004
+ Dn as buildInitialState,
2005
+ Ln as runTransition,
2006
+ Pn as useFloatingState,
2007
+ Rn as useLayerDragHandle,
2008
+ Hn as useTransitionState
1937
2009
  };
1938
2010
  //# sourceMappingURL=index.js.map