react-resizable-panels 4.12.3 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
1
  "use client";
2
- import { jsx as ae } from "react/jsx-runtime";
3
- import { useState as Q, useCallback as re, useId as mt, useLayoutEffect as Ke, useEffect as me, useRef as O, createContext as gt, useImperativeHandle as Xe, useMemo as Se, useSyncExternalStore as qe, useContext as yt } from "react";
4
- function St(e, t) {
2
+ import { jsx as B, jsxs as zt } from "react/jsx-runtime";
3
+ import { useState as Z, useCallback as ce, useId as wt, useLayoutEffect as Ze, useEffect as Se, useRef as D, createContext as Pt, useContext as Lt, isValidElement as Ct, useImperativeHandle as Qe, useMemo as Pe, useSyncExternalStore as et } from "react";
4
+ function Rt(e, t) {
5
5
  const n = getComputedStyle(e), o = parseFloat(n.fontSize);
6
6
  return t * o;
7
7
  }
8
- function vt(e, t) {
8
+ function Mt(e, t) {
9
9
  const n = getComputedStyle(e.ownerDocument.documentElement), o = parseFloat(n.fontSize);
10
10
  return t * o;
11
11
  }
12
- function bt(e) {
12
+ function Et(e) {
13
13
  return e / 100 * window.innerHeight;
14
14
  }
15
- function zt(e) {
15
+ function It(e) {
16
16
  return e / 100 * window.innerWidth;
17
17
  }
18
- function xt(e) {
18
+ function kt(e) {
19
19
  switch (typeof e) {
20
20
  case "number":
21
21
  return [e, "px"];
@@ -31,46 +31,46 @@ function ie({
31
31
  styleProp: n
32
32
  }) {
33
33
  let o;
34
- const [i, s] = xt(n);
35
- switch (s) {
34
+ const [r, i] = kt(n);
35
+ switch (i) {
36
36
  case "%": {
37
- o = i / 100 * e;
37
+ o = r / 100 * e;
38
38
  break;
39
39
  }
40
40
  case "px": {
41
- o = i;
41
+ o = r;
42
42
  break;
43
43
  }
44
44
  case "rem": {
45
- o = vt(t, i);
45
+ o = Mt(t, r);
46
46
  break;
47
47
  }
48
48
  case "em": {
49
- o = St(t, i);
49
+ o = Rt(t, r);
50
50
  break;
51
51
  }
52
52
  case "vh": {
53
- o = bt(i);
53
+ o = Et(r);
54
54
  break;
55
55
  }
56
56
  case "vw": {
57
- o = zt(i);
57
+ o = It(r);
58
58
  break;
59
59
  }
60
60
  }
61
61
  return o;
62
62
  }
63
- function T(e) {
63
+ function A(e) {
64
64
  return parseFloat(e.toFixed(3));
65
65
  }
66
- function ne({
66
+ function ae({
67
67
  group: e
68
68
  }) {
69
69
  const { orientation: t, panels: n } = e;
70
- return n.reduce((o, i) => (o += t === "horizontal" ? i.element.offsetWidth : i.element.offsetHeight, o), 0);
70
+ return n.reduce((o, r) => (o += t === "horizontal" ? r.element.offsetWidth : r.element.offsetHeight, o), 0);
71
71
  }
72
- function ve(e) {
73
- const { panels: t } = e, n = ne({ group: e });
72
+ function Le(e) {
73
+ const { panels: t } = e, n = ae({ group: e });
74
74
  return n === 0 ? t.map((o) => ({
75
75
  groupResizeBehavior: o.panelConstraints.groupResizeBehavior,
76
76
  collapsedSize: 0,
@@ -81,226 +81,66 @@ function ve(e) {
81
81
  maxSize: 100,
82
82
  panelId: o.id
83
83
  })) : t.map((o) => {
84
- const { element: i, panelConstraints: s } = o;
85
- let u = 0;
86
- if (s.collapsedSize !== void 0) {
87
- const c = ie({
84
+ const { element: r, panelConstraints: i } = o;
85
+ let c = 0;
86
+ if (i.collapsedSize !== void 0) {
87
+ const f = ie({
88
88
  groupSize: n,
89
- panelElement: i,
90
- styleProp: s.collapsedSize
89
+ panelElement: r,
90
+ styleProp: i.collapsedSize
91
91
  });
92
- u = T(c / n * 100);
92
+ c = A(f / n * 100);
93
+ }
94
+ let l;
95
+ if (i.collapsedThreshold !== void 0) {
96
+ const f = ie({
97
+ groupSize: n,
98
+ panelElement: r,
99
+ styleProp: i.collapsedThreshold
100
+ });
101
+ l = A(f / n * 100);
93
102
  }
94
103
  let a;
95
- if (s.defaultSize !== void 0) {
96
- const c = ie({
104
+ if (i.defaultSize !== void 0) {
105
+ const f = ie({
97
106
  groupSize: n,
98
- panelElement: i,
99
- styleProp: s.defaultSize
107
+ panelElement: r,
108
+ styleProp: i.defaultSize
100
109
  });
101
- a = T(c / n * 100);
110
+ a = A(f / n * 100);
102
111
  }
103
- let r = 0;
104
- if (s.minSize !== void 0) {
105
- const c = ie({
112
+ let s = 0;
113
+ if (i.minSize !== void 0) {
114
+ const f = ie({
106
115
  groupSize: n,
107
- panelElement: i,
108
- styleProp: s.minSize
116
+ panelElement: r,
117
+ styleProp: i.minSize
109
118
  });
110
- r = T(c / n * 100);
119
+ s = A(f / n * 100);
111
120
  }
112
- let l = 100;
113
- if (s.maxSize !== void 0) {
114
- const c = ie({
121
+ let u = 100;
122
+ if (i.maxSize !== void 0) {
123
+ const f = ie({
115
124
  groupSize: n,
116
- panelElement: i,
117
- styleProp: s.maxSize
125
+ panelElement: r,
126
+ styleProp: i.maxSize
118
127
  });
119
- l = T(c / n * 100);
128
+ u = A(f / n * 100);
120
129
  }
121
130
  return {
122
- groupResizeBehavior: s.groupResizeBehavior,
123
- collapsedSize: u,
124
- collapsible: s.collapsible === !0,
131
+ groupResizeBehavior: i.groupResizeBehavior,
132
+ collapsedSize: c,
133
+ collapsedThreshold: l,
134
+ collapsible: i.collapsible === !0,
125
135
  defaultSize: a,
126
- disabled: s.disabled,
127
- minSize: r,
128
- maxSize: l,
136
+ disabled: i.disabled,
137
+ minSize: s,
138
+ maxSize: u,
129
139
  panelId: o.id
130
140
  };
131
141
  });
132
142
  }
133
- function C(e, t = "Assertion error") {
134
- if (!e)
135
- throw Error(t);
136
- }
137
- function be(e, t) {
138
- return Array.from(t).sort(
139
- e === "horizontal" ? Pt : wt
140
- );
141
- }
142
- function Pt(e, t) {
143
- const n = e.element.offsetLeft - t.element.offsetLeft;
144
- return n !== 0 ? n : e.element.offsetWidth - t.element.offsetWidth;
145
- }
146
- function wt(e, t) {
147
- const n = e.element.offsetTop - t.element.offsetTop;
148
- return n !== 0 ? n : e.element.offsetHeight - t.element.offsetHeight;
149
- }
150
- function Ye(e) {
151
- return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.ELEMENT_NODE;
152
- }
153
- function Je(e, t) {
154
- return {
155
- x: e.x >= t.left && e.x <= t.right ? 0 : Math.min(
156
- Math.abs(e.x - t.left),
157
- Math.abs(e.x - t.right)
158
- ),
159
- y: e.y >= t.top && e.y <= t.bottom ? 0 : Math.min(
160
- Math.abs(e.y - t.top),
161
- Math.abs(e.y - t.bottom)
162
- )
163
- };
164
- }
165
- function Lt({
166
- orientation: e,
167
- rects: t,
168
- targetRect: n
169
- }) {
170
- const o = {
171
- x: n.x + n.width / 2,
172
- y: n.y + n.height / 2
173
- };
174
- let i, s = Number.MAX_VALUE;
175
- for (const u of t) {
176
- const { x: a, y: r } = Je(o, u), l = e === "horizontal" ? a : r;
177
- l < s && (s = l, i = u);
178
- }
179
- return C(i, "No rect found"), i;
180
- }
181
- let fe;
182
- function Ct() {
183
- return fe === void 0 && (typeof matchMedia == "function" ? fe = !!matchMedia("(pointer:coarse)").matches : fe = !1), fe;
184
- }
185
- function Ze(e) {
186
- const { element: t, orientation: n, panels: o, separators: i } = e, s = be(
187
- n,
188
- Array.from(t.children).filter(Ye).map((z) => ({ element: z }))
189
- ).map(({ element: z }) => z), u = [];
190
- let a = !1, r = !1, l = -1, c = -1, m = 0, p, S = [];
191
- {
192
- let z = -1;
193
- for (const f of s)
194
- f.hasAttribute("data-panel") && (z++, f.hasAttribute("data-disabled") || (m++, l === -1 && (l = z), c = z));
195
- }
196
- if (m > 1) {
197
- let z = -1;
198
- for (const f of s)
199
- if (f.hasAttribute("data-panel")) {
200
- z++;
201
- const d = o.find(
202
- (h) => h.element === f
203
- );
204
- if (d) {
205
- if (p) {
206
- const h = p.element.getBoundingClientRect(), y = f.getBoundingClientRect();
207
- let b;
208
- if (r) {
209
- const v = n === "horizontal" ? new DOMRect(
210
- h.right,
211
- h.top,
212
- 0,
213
- h.height
214
- ) : new DOMRect(
215
- h.left,
216
- h.bottom,
217
- h.width,
218
- 0
219
- ), g = n === "horizontal" ? new DOMRect(y.left, y.top, 0, y.height) : new DOMRect(y.left, y.top, y.width, 0);
220
- switch (S.length) {
221
- case 0: {
222
- b = [
223
- v,
224
- g
225
- ];
226
- break;
227
- }
228
- case 1: {
229
- const w = S[0], E = Lt({
230
- orientation: n,
231
- rects: [h, y],
232
- targetRect: w.element.getBoundingClientRect()
233
- });
234
- b = [
235
- w,
236
- E === h ? g : v
237
- ];
238
- break;
239
- }
240
- default: {
241
- b = S;
242
- break;
243
- }
244
- }
245
- } else
246
- S.length ? b = S : b = [
247
- n === "horizontal" ? new DOMRect(
248
- h.right,
249
- y.top,
250
- y.left - h.right,
251
- y.height
252
- ) : new DOMRect(
253
- y.left,
254
- h.bottom,
255
- y.width,
256
- y.top - h.bottom
257
- )
258
- ];
259
- for (const v of b) {
260
- let g = "width" in v ? v : v.element.getBoundingClientRect();
261
- const w = Ct() ? e.resizeTargetMinimumSize.coarse : e.resizeTargetMinimumSize.fine;
262
- if (g.width < w) {
263
- const L = w - g.width;
264
- g = new DOMRect(
265
- g.x - L / 2,
266
- g.y,
267
- g.width + L,
268
- g.height
269
- );
270
- }
271
- if (g.height < w) {
272
- const L = w - g.height;
273
- g = new DOMRect(
274
- g.x,
275
- g.y - L / 2,
276
- g.width,
277
- g.height + L
278
- );
279
- }
280
- const E = z <= l || z > c;
281
- !a && !E && u.push({
282
- group: e,
283
- groupSize: ne({ group: e }),
284
- panels: [p, d],
285
- separator: "width" in v ? void 0 : v,
286
- rect: g
287
- }), a = !1;
288
- }
289
- }
290
- r = !1, p = d, S = [];
291
- }
292
- } else if (f.hasAttribute("data-separator")) {
293
- f.ariaDisabled !== null && (a = !0);
294
- const d = i.find(
295
- (h) => h.element === f
296
- );
297
- d ? S.push(d) : (p = void 0, S = []);
298
- } else
299
- r = !0;
300
- }
301
- return u;
302
- }
303
- class Qe {
143
+ class tt {
304
144
  #e = {};
305
145
  addListener(t, n) {
306
146
  const o = this.#e[t];
@@ -314,18 +154,18 @@ class Qe {
314
154
  if (o.length === 1)
315
155
  o[0].call(null, n);
316
156
  else {
317
- let i = !1, s = null;
318
- const u = Array.from(o);
319
- for (let a = 0; a < u.length; a++) {
320
- const r = u[a];
157
+ let r = !1, i = null;
158
+ const c = Array.from(o);
159
+ for (let l = 0; l < c.length; l++) {
160
+ const a = c[l];
321
161
  try {
322
- r.call(null, n);
323
- } catch (l) {
324
- s === null && (i = !0, s = l);
162
+ a.call(null, n);
163
+ } catch (s) {
164
+ i === null && (r = !0, i = s);
325
165
  }
326
166
  }
327
- if (i)
328
- throw s;
167
+ if (r)
168
+ throw i;
329
169
  }
330
170
  }
331
171
  removeAllListeners() {
@@ -334,106 +174,138 @@ class Qe {
334
174
  removeListener(t, n) {
335
175
  const o = this.#e[t];
336
176
  if (o !== void 0) {
337
- const i = o.indexOf(n);
338
- i >= 0 && o.splice(i, 1);
177
+ const r = o.indexOf(n);
178
+ r >= 0 && o.splice(r, 1);
339
179
  }
340
180
  }
341
181
  }
342
- let ee = {
182
+ let k = {
343
183
  cursorFlags: 0,
344
184
  state: "inactive"
345
185
  };
346
- const ze = new Qe();
347
- function W() {
348
- return ee;
186
+ const Re = new tt();
187
+ function X() {
188
+ return k;
349
189
  }
350
- function Rt(e) {
351
- return ze.addListener("change", e);
190
+ function nt(e) {
191
+ return Re.addListener("change", e);
352
192
  }
353
- function Et(e) {
354
- const t = ee, n = { ...ee };
355
- n.cursorFlags = e, ee = n, ze.emit("change", {
356
- prev: t,
357
- next: n
193
+ function Tt(e, t = [], n) {
194
+ const o = k, r = { ...k };
195
+ r.cursorFlags = e, r.state === "active" && (r.previews = t, n && (r.previewLayoutMap = n)), k = r, Re.emit("change", {
196
+ prev: o,
197
+ next: r
358
198
  });
359
199
  }
360
- function te(e) {
361
- const t = ee;
362
- ee = e, ze.emit("change", {
200
+ function U(e) {
201
+ const t = k;
202
+ k = e, Re.emit("change", {
363
203
  prev: t,
364
204
  next: e
365
205
  });
366
206
  }
367
- const Mt = (e) => e, ye = () => {
368
- }, et = 1, tt = 2, nt = 4, ot = 8, Ie = 3, ke = 12;
369
- let de;
370
- function De() {
371
- return de === void 0 && (de = !1, typeof window < "u" && (window.navigator.userAgent.includes("Chrome") || window.navigator.userAgent.includes("Firefox")) && (de = !0)), de;
207
+ function Ot(e) {
208
+ k.state !== "active" || !k.previews.some((t) => t.separator === e) || U({
209
+ ...k,
210
+ previews: k.previews.map(
211
+ (t) => t.separator === e ? { ...t } : t
212
+ )
213
+ });
372
214
  }
373
- function It({
215
+ function Dt(e) {
216
+ if (k.state === "inactive")
217
+ return !1;
218
+ const t = k.hitRegions.filter(
219
+ (o) => o.group !== e
220
+ ), n = k.state === "active" && k.previews.some((o) => o.group === e);
221
+ if (t.length === k.hitRegions.length && !n)
222
+ return !1;
223
+ if (t.length === 0)
224
+ U({ cursorFlags: 0, state: "inactive" });
225
+ else if (k.state === "active") {
226
+ const o = new Map(k.initialLayoutMap), r = new Map(k.previewLayoutMap);
227
+ o.delete(e), r.delete(e), U({
228
+ ...k,
229
+ cursorFlags: 0,
230
+ hitRegions: t,
231
+ initialLayoutMap: o,
232
+ previewLayoutMap: r,
233
+ previews: k.previews.filter((i) => i.group !== e)
234
+ });
235
+ } else
236
+ U({ ...k, hitRegions: t });
237
+ return !0;
238
+ }
239
+ const At = (e) => e, we = () => {
240
+ }, ot = 1, rt = 2, it = 4, st = 8, Ge = 3, Fe = 12;
241
+ let me;
242
+ function Ne() {
243
+ return me === void 0 && (me = !1, typeof window < "u" && (window.navigator.userAgent.includes("Chrome") || window.navigator.userAgent.includes("Firefox")) && (me = !0)), me;
244
+ }
245
+ function Gt({
374
246
  cursorFlags: e,
375
247
  groups: t,
376
248
  state: n
377
249
  }) {
378
- let o = 0, i = 0;
250
+ let o = 0, r = 0;
379
251
  switch (n) {
380
252
  case "active":
381
253
  case "hover":
382
- t.forEach((s) => {
383
- if (!s.mutableState.disableCursor)
384
- switch (s.orientation) {
254
+ t.forEach((i) => {
255
+ if (!i.mutableState.disableCursor)
256
+ switch (i.orientation) {
385
257
  case "horizontal": {
386
258
  o++;
387
259
  break;
388
260
  }
389
261
  case "vertical": {
390
- i++;
262
+ r++;
391
263
  break;
392
264
  }
393
265
  }
394
266
  });
395
267
  }
396
- if (!(o === 0 && i === 0)) {
268
+ if (!(o === 0 && r === 0)) {
397
269
  switch (n) {
398
270
  case "active": {
399
- if (e && De()) {
400
- const s = (e & et) !== 0, u = (e & tt) !== 0, a = (e & nt) !== 0, r = (e & ot) !== 0;
401
- if (s)
402
- return a ? "se-resize" : r ? "ne-resize" : "e-resize";
403
- if (u)
404
- return a ? "sw-resize" : r ? "nw-resize" : "w-resize";
405
- if (a)
271
+ if (e && Ne()) {
272
+ const i = (e & ot) !== 0, c = (e & rt) !== 0, l = (e & it) !== 0, a = (e & st) !== 0;
273
+ if (i)
274
+ return l ? "se-resize" : a ? "ne-resize" : "e-resize";
275
+ if (c)
276
+ return l ? "sw-resize" : a ? "nw-resize" : "w-resize";
277
+ if (l)
406
278
  return "s-resize";
407
- if (r)
279
+ if (a)
408
280
  return "n-resize";
409
281
  }
410
282
  break;
411
283
  }
412
284
  }
413
- return De() ? o > 0 && i > 0 ? "move" : o > 0 ? "ew-resize" : "ns-resize" : o > 0 && i > 0 ? "grab" : o > 0 ? "col-resize" : "row-resize";
285
+ return Ne() ? o > 0 && r > 0 ? "move" : o > 0 ? "ew-resize" : "ns-resize" : o > 0 && r > 0 ? "grab" : o > 0 ? "col-resize" : "row-resize";
414
286
  }
415
287
  }
416
- const Te = /* @__PURE__ */ new WeakMap();
417
- function xe(e) {
288
+ const _e = /* @__PURE__ */ new WeakMap();
289
+ function fe(e) {
418
290
  if (!e.defaultView || !e.adoptedStyleSheets)
419
291
  return;
420
- let { prevStyle: t, styleSheet: n } = Te.get(e) ?? {};
292
+ let { prevStyle: t, styleSheet: n } = _e.get(e) ?? {};
421
293
  n === void 0 && (n = new e.defaultView.CSSStyleSheet(), e.adoptedStyleSheets && (Object.isExtensible(e.adoptedStyleSheets) ? e.adoptedStyleSheets.push(n) : e.adoptedStyleSheets = [
422
294
  ...e.adoptedStyleSheets,
423
295
  n
424
296
  ]));
425
- const o = W();
297
+ const o = X();
426
298
  switch (o.state) {
427
299
  case "active":
428
300
  case "hover": {
429
- const i = It({
301
+ const r = Gt({
430
302
  cursorFlags: o.cursorFlags,
431
- groups: o.hitRegions.map((u) => u.group),
303
+ groups: o.hitRegions.map((c) => c.group),
432
304
  state: o.state
433
- }), s = `*, *:hover {cursor: ${i} !important; }`;
434
- if (t === s)
305
+ }), i = `*, *:hover {cursor: ${r} !important; }`;
306
+ if (t === i)
435
307
  return;
436
- t = s, i ? n.cssRules.length === 0 ? n.insertRule(s) : n.replaceSync(s) : n.cssRules.length === 1 && n.deleteRule(0);
308
+ t = i, r ? n.cssRules.length === 0 ? n.insertRule(i) : n.replaceSync(i) : n.cssRules.length === 1 && n.deleteRule(0);
437
309
  break;
438
310
  }
439
311
  case "inactive": {
@@ -441,600 +313,859 @@ function xe(e) {
441
313
  break;
442
314
  }
443
315
  }
444
- Te.set(e, {
316
+ _e.set(e, {
445
317
  prevStyle: t,
446
318
  styleSheet: n
447
319
  });
448
320
  }
449
- let F = /* @__PURE__ */ new Map();
450
- const it = new Qe();
451
- function kt(e) {
452
- F = new Map(F), F.delete(e);
321
+ function R(e, t = "Assertion error") {
322
+ if (!e)
323
+ throw Error(t);
324
+ }
325
+ function Ce(e, t) {
326
+ return Array.from(t).sort(
327
+ e === "horizontal" ? Ft : Nt
328
+ );
453
329
  }
454
- function Oe(e, t) {
455
- for (const [n] of F)
330
+ function Ft(e, t) {
331
+ const n = e.element.offsetLeft - t.element.offsetLeft;
332
+ return n !== 0 ? n : e.element.offsetWidth - t.element.offsetWidth;
333
+ }
334
+ function Nt(e, t) {
335
+ const n = e.element.offsetTop - t.element.offsetTop;
336
+ return n !== 0 ? n : e.element.offsetHeight - t.element.offsetHeight;
337
+ }
338
+ function at(e) {
339
+ return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.ELEMENT_NODE;
340
+ }
341
+ function lt(e, t) {
342
+ return {
343
+ x: e.x >= t.left && e.x <= t.right ? 0 : Math.min(
344
+ Math.abs(e.x - t.left),
345
+ Math.abs(e.x - t.right)
346
+ ),
347
+ y: e.y >= t.top && e.y <= t.bottom ? 0 : Math.min(
348
+ Math.abs(e.y - t.top),
349
+ Math.abs(e.y - t.bottom)
350
+ )
351
+ };
352
+ }
353
+ function _t({
354
+ orientation: e,
355
+ rects: t,
356
+ targetRect: n
357
+ }) {
358
+ const o = {
359
+ x: n.x + n.width / 2,
360
+ y: n.y + n.height / 2
361
+ };
362
+ let r, i = Number.MAX_VALUE;
363
+ for (const c of t) {
364
+ const { x: l, y: a } = lt(o, c), s = e === "horizontal" ? l : a;
365
+ s < i && (i = s, r = c);
366
+ }
367
+ return R(r, "No rect found"), r;
368
+ }
369
+ let ge;
370
+ function $t() {
371
+ return ge === void 0 && (typeof matchMedia == "function" ? ge = !!matchMedia("(pointer:coarse)").matches : ge = !1), ge;
372
+ }
373
+ function Me({
374
+ expandHitTargets: e = !0,
375
+ group: t,
376
+ includeDisabled: n = !1
377
+ }) {
378
+ const { element: o, orientation: r, panels: i, separators: c } = t, l = Ce(
379
+ r,
380
+ Array.from(o.children).filter(at).filter((h) => !h.hasAttribute("data-resize-preview")).map((h) => ({ element: h }))
381
+ ).map(({ element: h }) => h), a = [];
382
+ let s = !1, u = !1, f = -1, d = -1, v = 0, z, p = [];
383
+ {
384
+ let h = -1;
385
+ for (const g of l)
386
+ g.hasAttribute("data-panel") && (h++, g.hasAttribute("data-disabled") || (v++, f === -1 && (f = h), d = h));
387
+ }
388
+ if (n || v > 1) {
389
+ let h = -1;
390
+ for (const g of l)
391
+ if (g.hasAttribute("data-panel")) {
392
+ h++;
393
+ const y = i.find(
394
+ (m) => m.element === g
395
+ );
396
+ if (y) {
397
+ if (z) {
398
+ const m = z.element.getBoundingClientRect(), b = g.getBoundingClientRect();
399
+ let x;
400
+ if (u) {
401
+ const L = r === "horizontal" ? new DOMRect(
402
+ m.right,
403
+ m.top,
404
+ 0,
405
+ m.height
406
+ ) : new DOMRect(
407
+ m.left,
408
+ m.bottom,
409
+ m.width,
410
+ 0
411
+ ), w = r === "horizontal" ? new DOMRect(b.left, b.top, 0, b.height) : new DOMRect(b.left, b.top, b.width, 0);
412
+ switch (p.length) {
413
+ case 0: {
414
+ x = [
415
+ L,
416
+ w
417
+ ];
418
+ break;
419
+ }
420
+ case 1: {
421
+ const C = p[0], M = _t({
422
+ orientation: r,
423
+ rects: [m, b],
424
+ targetRect: C.element.getBoundingClientRect()
425
+ });
426
+ x = [
427
+ C,
428
+ M === m ? w : L
429
+ ];
430
+ break;
431
+ }
432
+ default: {
433
+ x = p;
434
+ break;
435
+ }
436
+ }
437
+ } else
438
+ p.length ? x = p : x = [
439
+ r === "horizontal" ? new DOMRect(
440
+ m.right,
441
+ b.top,
442
+ b.left - m.right,
443
+ b.height
444
+ ) : new DOMRect(
445
+ b.left,
446
+ m.bottom,
447
+ b.width,
448
+ b.top - m.bottom
449
+ )
450
+ ];
451
+ for (const L of x) {
452
+ let w = "width" in L ? L : L.element.getBoundingClientRect();
453
+ const C = e ? $t() ? t.resizeTargetMinimumSize.coarse : t.resizeTargetMinimumSize.fine : 0;
454
+ if (w.width < C) {
455
+ const T = C - w.width;
456
+ w = new DOMRect(
457
+ w.x - T / 2,
458
+ w.y,
459
+ w.width + T,
460
+ w.height
461
+ );
462
+ }
463
+ if (w.height < C) {
464
+ const T = C - w.height;
465
+ w = new DOMRect(
466
+ w.x,
467
+ w.y - T / 2,
468
+ w.width,
469
+ w.height + T
470
+ );
471
+ }
472
+ const M = h <= f || h > d;
473
+ (n || !s && !M) && a.push({
474
+ group: t,
475
+ groupSize: ae({ group: t }),
476
+ panels: [z, y],
477
+ separator: "width" in L ? void 0 : L,
478
+ rect: w
479
+ }), s = !1;
480
+ }
481
+ }
482
+ u = !1, z = y, p = [];
483
+ }
484
+ } else if (g.hasAttribute("data-separator")) {
485
+ g.ariaDisabled !== null && (s = !0);
486
+ const y = c.find(
487
+ (m) => m.element === g
488
+ );
489
+ y ? p.push(y) : (z = void 0, p = []);
490
+ } else
491
+ u = !0;
492
+ }
493
+ return a;
494
+ }
495
+ let V = /* @__PURE__ */ new Map();
496
+ const ct = new tt();
497
+ function jt(e) {
498
+ V = new Map(V), V.delete(e);
499
+ }
500
+ function ut(e, t) {
501
+ for (const [n] of V)
456
502
  if (n.id === e)
457
503
  return n;
458
504
  }
459
- function H(e, t) {
460
- for (const [n, o] of F)
505
+ function Q(e, t) {
506
+ for (const [n, o] of V)
461
507
  if (n.id === e)
462
508
  return o;
463
509
  if (t)
464
510
  throw Error(`Could not find data for Group with id ${e}`);
465
511
  }
466
- function V() {
467
- return F;
512
+ function ee() {
513
+ return V;
468
514
  }
469
- function Pe(e, t) {
470
- return it.addListener("groupChange", (n) => {
515
+ function Ee(e, t) {
516
+ return ct.addListener("groupChange", (n) => {
471
517
  n.group.id === e && t(n);
472
518
  });
473
519
  }
474
- function j(e, t, n) {
475
- const o = F.get(e);
476
- F = new Map(F), F.set(e, t), it.emit("groupChange", {
520
+ function K(e, t, n) {
521
+ const o = V.get(e);
522
+ V = new Map(V), V.set(e, t), ct.emit("groupChange", {
477
523
  group: e,
478
524
  isUserInteraction: n?.isUserInteraction === !0,
479
525
  prev: o,
480
526
  next: t
481
527
  });
482
528
  }
483
- function rt(e) {
484
- const t = W(), n = V();
485
- let o = !1;
486
- switch (t.state) {
529
+ function Ht(e, t) {
530
+ if (e.length !== t.length)
531
+ return !1;
532
+ for (let n = 0; n < e.length; n++)
533
+ if (e[n] != t[n])
534
+ return !1;
535
+ return !0;
536
+ }
537
+ function O(e, t, n = 0) {
538
+ return Math.abs(A(e) - A(t)) <= n;
539
+ }
540
+ function H(e, t) {
541
+ return O(e, t) ? 0 : e > t ? 1 : -1;
542
+ }
543
+ function se({
544
+ overrideDisabledPanels: e,
545
+ panelConstraints: t,
546
+ prevSize: n,
547
+ size: o
548
+ }) {
549
+ const {
550
+ collapsedSize: r = 0,
551
+ collapsedThreshold: i,
552
+ collapsible: c,
553
+ disabled: l,
554
+ maxSize: a = 100,
555
+ minSize: s = 0
556
+ } = t;
557
+ if (l && !e)
558
+ return n;
559
+ if (H(o, s) < 0)
560
+ if (c) {
561
+ const u = i ?? (s - r) / 2, f = H(n, r) <= 0, d = f ? r + u : s - u, v = H(o, d);
562
+ H(o, r) <= 0 || v < 0 || i !== void 0 && f && v === 0 ? o = r : o = s;
563
+ } else
564
+ o = s;
565
+ return o = Math.min(a, o), o = A(o), o;
566
+ }
567
+ function de({
568
+ delta: e,
569
+ initialLayout: t,
570
+ panelConstraints: n,
571
+ pivotIndices: o,
572
+ prevLayout: r,
573
+ trigger: i
574
+ }) {
575
+ if (O(e, 0))
576
+ return t;
577
+ const c = i === "imperative-api", l = Object.values(t), a = Object.values(r), s = [...l], [u, f] = o;
578
+ R(u != null, "Invalid first pivot index"), R(f != null, "Invalid second pivot index");
579
+ let d = 0;
580
+ switch (i) {
581
+ case "keyboard": {
582
+ {
583
+ const p = e < 0 ? f : u, h = n[p];
584
+ R(
585
+ h,
586
+ `Panel constraints not found for index ${p}`
587
+ );
588
+ const {
589
+ collapsedSize: g = 0,
590
+ collapsible: y,
591
+ minSize: m = 0
592
+ } = h;
593
+ if (y) {
594
+ const b = l[p];
595
+ if (R(
596
+ b != null,
597
+ `Previous layout not found for panel index ${p}`
598
+ ), O(b, g)) {
599
+ const x = m - b;
600
+ H(x, Math.abs(e)) > 0 && (e = e < 0 ? 0 - x : x);
601
+ }
602
+ }
603
+ }
604
+ {
605
+ const p = e < 0 ? u : f, h = n[p];
606
+ R(
607
+ h,
608
+ `No panel constraints found for index ${p}`
609
+ );
610
+ const {
611
+ collapsedSize: g = 0,
612
+ collapsible: y,
613
+ minSize: m = 0
614
+ } = h;
615
+ if (y) {
616
+ const b = l[p];
617
+ if (R(
618
+ b != null,
619
+ `Previous layout not found for panel index ${p}`
620
+ ), O(b, m)) {
621
+ const x = b - g;
622
+ H(x, Math.abs(e)) > 0 && (e = e < 0 ? 0 - x : x);
623
+ }
624
+ }
625
+ }
626
+ break;
627
+ }
628
+ default: {
629
+ const p = e < 0 ? f : u, h = n[p];
630
+ R(
631
+ h,
632
+ `Panel constraints not found for index ${p}`
633
+ );
634
+ const g = l[p], { collapsedSize: y, collapsedThreshold: m, collapsible: b, minSize: x } = h;
635
+ if (b && H(g, x) < 0) {
636
+ const L = x - y, w = m ?? L / 2, C = g + Math.abs(e);
637
+ if (H(C, x) < 0) {
638
+ const M = H(Math.abs(e), w), T = m === void 0 && e < 0;
639
+ M > 0 || M === 0 && T ? e = e < 0 ? -L : L : e = 0;
640
+ }
641
+ }
642
+ break;
643
+ }
644
+ }
645
+ {
646
+ const p = e < 0 ? 1 : -1;
647
+ let h = e < 0 ? f : u, g = 0;
648
+ for (; ; ) {
649
+ const m = l[h];
650
+ R(
651
+ m != null,
652
+ `Previous layout not found for panel index ${h}`
653
+ );
654
+ const x = se({
655
+ overrideDisabledPanels: c,
656
+ panelConstraints: n[h],
657
+ prevSize: m,
658
+ size: 100
659
+ }) - m;
660
+ if (g += x, h += p, h < 0 || h >= n.length)
661
+ break;
662
+ }
663
+ const y = Math.min(Math.abs(e), Math.abs(g));
664
+ e = e < 0 ? 0 - y : y;
665
+ }
666
+ {
667
+ let h = e < 0 ? u : f;
668
+ for (; h >= 0 && h < n.length; ) {
669
+ const g = Math.abs(e) - Math.abs(d), y = l[h];
670
+ R(
671
+ y != null,
672
+ `Previous layout not found for panel index ${h}`
673
+ );
674
+ const m = y - g, b = se({
675
+ overrideDisabledPanels: c,
676
+ panelConstraints: n[h],
677
+ prevSize: y,
678
+ size: m
679
+ });
680
+ if (!O(y, b) && (d += y - b, s[h] = b, d.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
681
+ numeric: !0
682
+ }) >= 0))
683
+ break;
684
+ e < 0 ? h-- : h++;
685
+ }
686
+ }
687
+ if (Ht(a, s))
688
+ return r;
689
+ {
690
+ const p = e < 0 ? f : u, h = l[p];
691
+ R(
692
+ h != null,
693
+ `Previous layout not found for panel index ${p}`
694
+ );
695
+ const g = h + d, y = se({
696
+ overrideDisabledPanels: c,
697
+ panelConstraints: n[p],
698
+ prevSize: h,
699
+ size: g
700
+ });
701
+ if (s[p] = y, !O(y, g)) {
702
+ let m = g - y, x = e < 0 ? f : u;
703
+ for (; x >= 0 && x < n.length; ) {
704
+ const L = s[x];
705
+ R(
706
+ L != null,
707
+ `Previous layout not found for panel index ${x}`
708
+ );
709
+ const w = L + m, C = se({
710
+ overrideDisabledPanels: c,
711
+ panelConstraints: n[x],
712
+ prevSize: L,
713
+ size: w
714
+ });
715
+ if (O(L, C) || (m -= C - L, s[x] = C), O(m, 0))
716
+ break;
717
+ e > 0 ? x-- : x++;
718
+ }
719
+ }
720
+ }
721
+ const v = Object.values(s).reduce(
722
+ (p, h) => h + p,
723
+ 0
724
+ );
725
+ if (!O(v, 100, 0.1))
726
+ return r;
727
+ const z = Object.keys(r);
728
+ return s.reduce((p, h, g) => (p[z[g]] = h, p), {});
729
+ }
730
+ function W(e, t) {
731
+ if (Object.keys(e).length !== Object.keys(t).length)
732
+ return !1;
733
+ for (const n in e)
734
+ if (t[n] === void 0 || H(e[n], t[n]) !== 0)
735
+ return !1;
736
+ return !0;
737
+ }
738
+ function Ie({
739
+ commit: e,
740
+ document: t,
741
+ event: n,
742
+ hitRegions: o,
743
+ initialLayoutMap: r,
744
+ mountedGroups: i,
745
+ pointerDownAtPoint: c,
746
+ prevCursorFlags: l
747
+ }) {
748
+ let a = 0;
749
+ const s = X();
750
+ let u = s.state === "active" ? s.previews : [];
751
+ const f = new Map(
752
+ s.state === "active" ? s.previewLayoutMap : void 0
753
+ );
754
+ o.forEach((v) => {
755
+ const { group: z, groupSize: p } = v, { orientation: h, panels: g } = z;
756
+ if (e && z.resizePreviewMode !== "separator")
757
+ return;
758
+ const { disableCursor: y } = z.mutableState;
759
+ let m = 0;
760
+ c ? h === "horizontal" ? m = (n.clientX - c.x) / p * 100 : m = (n.clientY - c.y) / p * 100 : h === "horizontal" ? m = n.clientX < 0 ? -100 : 100 : m = n.clientY < 0 ? -100 : 100;
761
+ const b = r.get(z), x = i.get(z);
762
+ if (!b || !x)
763
+ return;
764
+ const {
765
+ defaultLayoutDeferred: L,
766
+ derivedPanelConstraints: w,
767
+ groupSize: C,
768
+ layout: M,
769
+ separatorToPanels: T
770
+ } = x;
771
+ if (w && M && T) {
772
+ const G = z.resizePreviewMode === "separator" ? f.get(z) ?? M : M, E = de({
773
+ delta: m,
774
+ initialLayout: b,
775
+ panelConstraints: w,
776
+ pivotIndices: v.panels.map((N) => g.indexOf(N)),
777
+ prevLayout: G,
778
+ trigger: "mouse-or-touch"
779
+ });
780
+ if (z.resizePreviewMode === "separator" && !e && !W(E, G)) {
781
+ f.set(z, E);
782
+ let N = 0;
783
+ const _ = g.map((S) => (N += E[S.id] - b[S.id], N * (p / 100)));
784
+ u = u.map((S) => {
785
+ if (S.group !== z)
786
+ return S;
787
+ const P = _[S.panelIndex];
788
+ return P === S.offset ? S : { ...S, offset: P };
789
+ });
790
+ }
791
+ if (W(E, G) && m !== 0 && !y)
792
+ switch (h) {
793
+ case "horizontal": {
794
+ a |= m < 0 ? ot : rt;
795
+ break;
796
+ }
797
+ case "vertical": {
798
+ a |= m < 0 ? it : st;
799
+ break;
800
+ }
801
+ }
802
+ (z.resizePreviewMode !== "separator" || e) && !W(E, M) && K(v.group, {
803
+ defaultLayoutDeferred: L,
804
+ derivedPanelConstraints: w,
805
+ groupSize: C,
806
+ layout: E,
807
+ separatorToPanels: T
808
+ });
809
+ }
810
+ });
811
+ let d = 0;
812
+ n.movementX === 0 ? d |= l & Ge : d |= a & Ge, n.movementY === 0 ? d |= l & Fe : d |= a & Fe, Tt(d, u, f), fe(t);
813
+ }
814
+ function ft(e, t) {
815
+ const n = X(), o = ee();
816
+ let r = !1;
817
+ switch (n.state) {
487
818
  case "active":
488
- te({
819
+ Ie({
820
+ commit: !0,
821
+ document: e,
822
+ event: t,
823
+ hitRegions: n.hitRegions,
824
+ initialLayoutMap: n.initialLayoutMap,
825
+ mountedGroups: o,
826
+ pointerDownAtPoint: n.pointerDownAtPoint,
827
+ prevCursorFlags: n.cursorFlags
828
+ }), U({
489
829
  cursorFlags: 0,
490
830
  state: "inactive"
491
- }), t.hitRegions.length > 0 && (xe(e), o = !0, t.hitRegions.forEach((i) => {
492
- if (!n.has(i.group))
831
+ }), n.hitRegions.length > 0 && (fe(e), r = !0, n.hitRegions.forEach((i) => {
832
+ if (!o.has(i.group))
493
833
  return;
494
- const s = H(i.group.id, !0);
495
- j(i.group, s, {
834
+ const c = Q(i.group.id, !0);
835
+ K(i.group, c, {
496
836
  isUserInteraction: !0
497
837
  });
498
838
  }));
499
839
  }
500
- return o;
840
+ return r;
501
841
  }
502
- function Ge(e) {
503
- e.defaultPrevented || rt(e.currentTarget);
842
+ function $e(e) {
843
+ e.defaultPrevented || ft(e.currentTarget, e);
504
844
  }
505
- function Dt(e, t, n) {
506
- let o, i = {
845
+ function Vt(e, t, n) {
846
+ let o, r = {
507
847
  x: 1 / 0,
508
848
  y: 1 / 0
509
849
  };
510
- for (const s of t) {
511
- const u = Je(n, s.rect);
850
+ for (const i of t) {
851
+ const c = lt(n, i.rect);
512
852
  switch (e) {
513
853
  case "horizontal": {
514
- u.x <= i.x && (o = s, i = u);
854
+ c.x <= r.x && (o = i, r = c);
515
855
  break;
516
856
  }
517
857
  case "vertical": {
518
- u.y <= i.y && (o = s, i = u);
858
+ c.y <= r.y && (o = i, r = c);
519
859
  break;
520
860
  }
521
861
  }
522
862
  }
523
863
  return o ? {
524
- distance: i,
864
+ distance: r,
525
865
  hitRegion: o
526
866
  } : void 0;
527
867
  }
528
- function Tt(e) {
868
+ function Bt(e) {
529
869
  return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
530
870
  }
531
- function Ot(e, t) {
871
+ function Ut(e, t) {
532
872
  if (e === t) throw new Error("Cannot compare node with itself");
533
873
  const n = {
534
- a: Ne(e),
535
- b: Ne(t)
874
+ a: Ve(e),
875
+ b: Ve(t)
536
876
  };
537
877
  let o;
538
878
  for (; n.a.at(-1) === n.b.at(-1); )
539
879
  o = n.a.pop(), n.b.pop();
540
- C(
880
+ R(
541
881
  o,
542
882
  "Stacking order can only be calculated for elements with a common ancestor"
543
883
  );
544
- const i = {
545
- a: Fe(Ae(n.a)),
546
- b: Fe(Ae(n.b))
884
+ const r = {
885
+ a: He(je(n.a)),
886
+ b: He(je(n.b))
547
887
  };
548
- if (i.a === i.b) {
549
- const s = o.childNodes, u = {
888
+ if (r.a === r.b) {
889
+ const i = o.childNodes, c = {
550
890
  a: n.a.at(-1),
551
891
  b: n.b.at(-1)
552
892
  };
553
- let a = s.length;
554
- for (; a--; ) {
555
- const r = s[a];
556
- if (r === u.a) return 1;
557
- if (r === u.b) return -1;
893
+ let l = i.length;
894
+ for (; l--; ) {
895
+ const a = i[l];
896
+ if (a === c.a) return 1;
897
+ if (a === c.b) return -1;
558
898
  }
559
899
  }
560
- return Math.sign(i.a - i.b);
900
+ return Math.sign(r.a - r.b);
561
901
  }
562
- const Gt = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
563
- function At(e) {
564
- const t = getComputedStyle(st(e) ?? e).display;
902
+ const Wt = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
903
+ function Kt(e) {
904
+ const t = getComputedStyle(dt(e) ?? e).display;
565
905
  return t === "flex" || t === "inline-flex";
566
906
  }
567
- function Ft(e) {
907
+ function qt(e) {
568
908
  const t = getComputedStyle(e);
569
- return !!(t.position === "fixed" || t.zIndex !== "auto" && (t.position !== "static" || At(e)) || +t.opacity < 1 || "transform" in t && t.transform !== "none" || "webkitTransform" in t && t.webkitTransform !== "none" || "mixBlendMode" in t && t.mixBlendMode !== "normal" || "filter" in t && t.filter !== "none" || "webkitFilter" in t && t.webkitFilter !== "none" || "isolation" in t && t.isolation === "isolate" || Gt.test(t.willChange) || t.webkitOverflowScrolling === "touch");
909
+ return !!(t.position === "fixed" || t.zIndex !== "auto" && (t.position !== "static" || Kt(e)) || +t.opacity < 1 || "transform" in t && t.transform !== "none" || "webkitTransform" in t && t.webkitTransform !== "none" || "mixBlendMode" in t && t.mixBlendMode !== "normal" || "filter" in t && t.filter !== "none" || "webkitFilter" in t && t.webkitFilter !== "none" || "isolation" in t && t.isolation === "isolate" || Wt.test(t.willChange) || t.webkitOverflowScrolling === "touch");
570
910
  }
571
- function Ae(e) {
911
+ function je(e) {
572
912
  let t = e.length;
573
913
  for (; t--; ) {
574
914
  const n = e[t];
575
- if (C(n, "Missing node"), Ft(n)) return n;
915
+ if (R(n, "Missing node"), qt(n)) return n;
576
916
  }
577
917
  return null;
578
918
  }
579
- function Fe(e) {
919
+ function He(e) {
580
920
  return e && Number(getComputedStyle(e).zIndex) || 0;
581
921
  }
582
- function Ne(e) {
922
+ function Ve(e) {
583
923
  const t = [];
584
924
  for (; e; )
585
- t.push(e), e = st(e);
925
+ t.push(e), e = dt(e);
586
926
  return t;
587
927
  }
588
- function st(e) {
928
+ function dt(e) {
589
929
  const { parentNode: t } = e;
590
- return Tt(t) ? t.host : t;
930
+ return Bt(t) ? t.host : t;
591
931
  }
592
- function Nt(e, t) {
932
+ function Xt(e, t) {
593
933
  return e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y;
594
934
  }
595
- function _t({
935
+ function Yt({
596
936
  groupElement: e,
597
937
  hitRegion: t,
598
938
  pointerEventTarget: n
599
939
  }) {
600
- if (!Ye(n) || n.contains(e) || e.contains(n))
940
+ if (!at(n) || n.contains(e) || e.contains(n))
601
941
  return !0;
602
- if (Ot(n, e) > 0) {
942
+ if (Ut(n, e) > 0) {
603
943
  let o = n;
604
944
  for (; o; ) {
605
945
  if (o.contains(e))
606
946
  return !0;
607
- if (Nt(o.getBoundingClientRect(), t))
947
+ if (Xt(o.getBoundingClientRect(), t))
608
948
  return !1;
609
949
  o = o.parentElement;
610
950
  }
611
951
  }
612
952
  return !0;
613
953
  }
614
- function we(e, t) {
954
+ function ke(e, t) {
615
955
  const n = [];
616
- return t.forEach((o, i) => {
617
- if (i.disabled)
956
+ return t.forEach((o, r) => {
957
+ if (r.disabled)
618
958
  return;
619
- const s = Ze(i), u = Dt(i.orientation, s, {
959
+ const i = Me({ group: r }), c = Vt(r.orientation, i, {
620
960
  x: e.clientX,
621
961
  y: e.clientY
622
962
  });
623
- u && u.distance.x <= 0 && u.distance.y <= 0 && _t({
624
- groupElement: i.element,
625
- hitRegion: u.hitRegion.rect,
963
+ c && c.distance.x <= 0 && c.distance.y <= 0 && Yt({
964
+ groupElement: r.element,
965
+ hitRegion: c.hitRegion.rect,
626
966
  pointerEventTarget: e.target
627
- }) && n.push(u.hitRegion);
967
+ }) && n.push(c.hitRegion);
628
968
  }), n;
629
969
  }
630
- function $t(e, t) {
631
- if (e.length !== t.length)
632
- return !1;
633
- for (let n = 0; n < e.length; n++)
634
- if (e[n] != t[n])
635
- return !1;
636
- return !0;
637
- }
638
- function k(e, t, n = 0) {
639
- return Math.abs(T(e) - T(t)) <= n;
640
- }
641
- function A(e, t) {
642
- return k(e, t) ? 0 : e > t ? 1 : -1;
643
- }
644
- function Z({
645
- overrideDisabledPanels: e,
646
- panelConstraints: t,
647
- prevSize: n,
648
- size: o
649
- }) {
650
- const {
651
- collapsedSize: i = 0,
652
- collapsible: s,
653
- disabled: u,
654
- maxSize: a = 100,
655
- minSize: r = 0
656
- } = t;
657
- if (u && !e)
658
- return n;
659
- if (A(o, r) < 0)
660
- if (s) {
661
- const l = (i + r) / 2;
662
- A(o, l) < 0 ? o = i : o = r;
663
- } else
664
- o = r;
665
- return o = Math.min(a, o), o = T(o), o;
666
- }
667
- function le({
668
- delta: e,
669
- initialLayout: t,
670
- panelConstraints: n,
671
- pivotIndices: o,
672
- prevLayout: i,
673
- trigger: s
674
- }) {
675
- if (k(e, 0))
676
- return t;
677
- const u = s === "imperative-api", a = Object.values(t), r = Object.values(i), l = [...a], [c, m] = o;
678
- C(c != null, "Invalid first pivot index"), C(m != null, "Invalid second pivot index");
679
- let p = 0;
680
- switch (s) {
681
- case "keyboard": {
682
- {
683
- const f = e < 0 ? m : c, d = n[f];
684
- C(
685
- d,
686
- `Panel constraints not found for index ${f}`
687
- );
688
- const {
689
- collapsedSize: h = 0,
690
- collapsible: y,
691
- minSize: b = 0
692
- } = d;
693
- if (y) {
694
- const v = a[f];
695
- if (C(
696
- v != null,
697
- `Previous layout not found for panel index ${f}`
698
- ), k(v, h)) {
699
- const g = b - v;
700
- A(g, Math.abs(e)) > 0 && (e = e < 0 ? 0 - g : g);
701
- }
702
- }
703
- }
704
- {
705
- const f = e < 0 ? c : m, d = n[f];
706
- C(
707
- d,
708
- `No panel constraints found for index ${f}`
709
- );
710
- const {
711
- collapsedSize: h = 0,
712
- collapsible: y,
713
- minSize: b = 0
714
- } = d;
715
- if (y) {
716
- const v = a[f];
717
- if (C(
718
- v != null,
719
- `Previous layout not found for panel index ${f}`
720
- ), k(v, b)) {
721
- const g = v - h;
722
- A(g, Math.abs(e)) > 0 && (e = e < 0 ? 0 - g : g);
723
- }
724
- }
725
- }
726
- break;
727
- }
728
- default: {
729
- const f = e < 0 ? m : c, d = n[f];
730
- C(
731
- d,
732
- `Panel constraints not found for index ${f}`
733
- );
734
- const h = a[f], { collapsible: y, collapsedSize: b, minSize: v } = d;
735
- if (y && A(h, v) < 0)
736
- if (e > 0) {
737
- const g = v - b, w = g / 2, E = h + e;
738
- A(E, v) < 0 && (e = A(e, w) <= 0 ? 0 : g);
739
- } else {
740
- const g = v - b, w = 100 - g / 2, E = h - e;
741
- A(E, v) < 0 && (e = A(100 + e, w) > 0 ? 0 : -g);
742
- }
743
- break;
744
- }
745
- }
746
- {
747
- const f = e < 0 ? 1 : -1;
748
- let d = e < 0 ? m : c, h = 0;
749
- for (; ; ) {
750
- const b = a[d];
751
- C(
752
- b != null,
753
- `Previous layout not found for panel index ${d}`
754
- );
755
- const g = Z({
756
- overrideDisabledPanels: u,
757
- panelConstraints: n[d],
758
- prevSize: b,
759
- size: 100
760
- }) - b;
761
- if (h += g, d += f, d < 0 || d >= n.length)
762
- break;
763
- }
764
- const y = Math.min(Math.abs(e), Math.abs(h));
765
- e = e < 0 ? 0 - y : y;
766
- }
767
- {
768
- let d = e < 0 ? c : m;
769
- for (; d >= 0 && d < n.length; ) {
770
- const h = Math.abs(e) - Math.abs(p), y = a[d];
771
- C(
772
- y != null,
773
- `Previous layout not found for panel index ${d}`
774
- );
775
- const b = y - h, v = Z({
776
- overrideDisabledPanels: u,
777
- panelConstraints: n[d],
778
- prevSize: y,
779
- size: b
780
- });
781
- if (!k(y, v) && (p += y - v, l[d] = v, p.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
782
- numeric: !0
783
- }) >= 0))
784
- break;
785
- e < 0 ? d-- : d++;
786
- }
787
- }
788
- if ($t(r, l))
789
- return i;
790
- {
791
- const f = e < 0 ? m : c, d = a[f];
792
- C(
793
- d != null,
794
- `Previous layout not found for panel index ${f}`
795
- );
796
- const h = d + p, y = Z({
797
- overrideDisabledPanels: u,
798
- panelConstraints: n[f],
799
- prevSize: d,
800
- size: h
801
- });
802
- if (l[f] = y, !k(y, h)) {
803
- let b = h - y, g = e < 0 ? m : c;
804
- for (; g >= 0 && g < n.length; ) {
805
- const w = l[g];
806
- C(
807
- w != null,
808
- `Previous layout not found for panel index ${g}`
809
- );
810
- const E = w + b, L = Z({
811
- overrideDisabledPanels: u,
812
- panelConstraints: n[g],
813
- prevSize: w,
814
- size: E
815
- });
816
- if (k(w, L) || (b -= L - w, l[g] = L), k(b, 0))
817
- break;
818
- e > 0 ? g-- : g++;
819
- }
820
- }
821
- }
822
- const S = Object.values(l).reduce(
823
- (f, d) => d + f,
824
- 0
825
- );
826
- if (!k(S, 100, 0.1))
827
- return i;
828
- const z = Object.keys(i);
829
- return l.reduce((f, d, h) => (f[z[h]] = d, f), {});
830
- }
831
- function K(e, t) {
832
- if (Object.keys(e).length !== Object.keys(t).length)
833
- return !1;
834
- for (const n in e)
835
- if (t[n] === void 0 || A(e[n], t[n]) !== 0)
836
- return !1;
837
- return !0;
838
- }
839
- function X({
970
+ function ne({
840
971
  layout: e,
841
972
  panelConstraints: t
842
973
  }) {
843
- const n = Object.values(e), o = [...n], i = o.reduce(
844
- (a, r) => a + r,
974
+ const n = Object.values(e), o = [...n], r = o.reduce(
975
+ (l, a) => l + a,
845
976
  0
846
977
  );
847
978
  if (o.length !== t.length)
848
979
  throw Error(
849
- `Invalid ${t.length} panel layout: ${o.map((a) => `${a}%`).join(", ")}`
980
+ `Invalid ${t.length} panel layout: ${o.map((l) => `${l}%`).join(", ")}`
850
981
  );
851
- if (!k(i, 100) && o.length > 0)
852
- for (let a = 0; a < t.length; a++) {
853
- const r = o[a];
854
- C(r != null, `No layout data found for index ${a}`);
855
- const l = 100 / i * r;
856
- o[a] = l;
982
+ if (!O(r, 100) && o.length > 0)
983
+ for (let l = 0; l < t.length; l++) {
984
+ const a = o[l];
985
+ R(a != null, `No layout data found for index ${l}`);
986
+ const s = 100 / r * a;
987
+ o[l] = s;
857
988
  }
858
- let s = 0;
859
- for (let a = 0; a < t.length; a++) {
860
- const r = n[a];
861
- C(r != null, `No layout data found for index ${a}`);
862
- const l = o[a];
863
- C(l != null, `No layout data found for index ${a}`);
864
- const c = Z({
989
+ let i = 0;
990
+ for (let l = 0; l < t.length; l++) {
991
+ const a = n[l];
992
+ R(a != null, `No layout data found for index ${l}`);
993
+ const s = o[l];
994
+ R(s != null, `No layout data found for index ${l}`);
995
+ const u = se({
865
996
  overrideDisabledPanels: !0,
866
- panelConstraints: t[a],
867
- prevSize: r,
868
- size: l
997
+ panelConstraints: t[l],
998
+ prevSize: a,
999
+ size: s
869
1000
  });
870
- l != c && (s += l - c, o[a] = c);
1001
+ s != u && (i += s - u, o[l] = u);
871
1002
  }
872
- if (!k(s, 0))
873
- for (let a = 0; a < t.length; a++) {
874
- const r = o[a];
875
- C(r != null, `No layout data found for index ${a}`);
876
- const l = r + s, c = Z({
1003
+ if (!O(i, 0))
1004
+ for (let l = 0; l < t.length; l++) {
1005
+ const a = o[l];
1006
+ R(a != null, `No layout data found for index ${l}`);
1007
+ const s = a + i, u = se({
877
1008
  overrideDisabledPanels: !0,
878
- panelConstraints: t[a],
879
- prevSize: r,
880
- size: l
1009
+ panelConstraints: t[l],
1010
+ prevSize: a,
1011
+ size: s
881
1012
  });
882
- if (r !== c && (s -= c - r, o[a] = c, k(s, 0)))
1013
+ if (a !== u && (i -= u - a, o[l] = u, O(i, 0)))
883
1014
  break;
884
1015
  }
885
- const u = Object.keys(e);
886
- return o.reduce((a, r, l) => (a[u[l]] = r, a), {});
1016
+ const c = Object.keys(e);
1017
+ return o.reduce((l, a, s) => (l[c[s]] = a, l), {});
887
1018
  }
888
- function at({
1019
+ function pt({
889
1020
  groupId: e,
890
1021
  panelId: t
891
1022
  }) {
892
1023
  const n = () => {
893
- const r = V();
1024
+ const a = ee();
894
1025
  for (const [
895
- l,
1026
+ s,
896
1027
  {
897
- defaultLayoutDeferred: c,
898
- derivedPanelConstraints: m,
899
- layout: p,
900
- groupSize: S,
1028
+ defaultLayoutDeferred: u,
1029
+ derivedPanelConstraints: f,
1030
+ layout: d,
1031
+ groupSize: v,
901
1032
  separatorToPanels: z
902
1033
  }
903
- ] of r)
904
- if (l.id === e)
1034
+ ] of a)
1035
+ if (s.id === e)
905
1036
  return {
906
- defaultLayoutDeferred: c,
907
- derivedPanelConstraints: m,
908
- group: l,
909
- groupSize: S,
910
- layout: p,
1037
+ defaultLayoutDeferred: u,
1038
+ derivedPanelConstraints: f,
1039
+ group: s,
1040
+ groupSize: v,
1041
+ layout: d,
911
1042
  separatorToPanels: z
912
1043
  };
913
1044
  throw Error(`Group ${e} not found`);
914
1045
  }, o = () => {
915
- const r = n().derivedPanelConstraints.find(
916
- (l) => l.panelId === t
1046
+ const a = n().derivedPanelConstraints.find(
1047
+ (s) => s.panelId === t
917
1048
  );
918
- if (r !== void 0)
919
- return r;
1049
+ if (a !== void 0)
1050
+ return a;
920
1051
  throw Error(`Panel constraints not found for Panel ${t}`);
921
- }, i = () => {
922
- const r = n().group.panels.find((l) => l.id === t);
923
- if (r !== void 0)
924
- return r;
1052
+ }, r = () => {
1053
+ const a = n().group.panels.find((s) => s.id === t);
1054
+ if (a !== void 0)
1055
+ return a;
925
1056
  throw Error(`Layout not found for Panel ${t}`);
926
- }, s = () => {
927
- const r = n().layout[t];
928
- if (r !== void 0)
929
- return r;
1057
+ }, i = () => {
1058
+ const a = n().layout[t];
1059
+ if (a !== void 0)
1060
+ return a;
930
1061
  throw Error(`Layout not found for Panel ${t}`);
931
- }, u = ({
932
- nextSize: r,
933
- panels: l,
934
- prevLayout: c,
935
- derivedPanelConstraints: m
1062
+ }, c = ({
1063
+ nextSize: a,
1064
+ panels: s,
1065
+ prevLayout: u,
1066
+ derivedPanelConstraints: f
936
1067
  }) => {
937
- const p = s(), S = l.findIndex((h) => h.id === t), z = S === 0, f = S === l.length - 1;
938
- if (f && r < p && (z || l.slice(0, S).every((h, y) => {
939
- const b = m[y];
940
- return b?.collapsible && k(b.collapsedSize, c[b.panelId]);
1068
+ const d = i(), v = s.findIndex((g) => g.id === t), z = v === 0, p = v === s.length - 1;
1069
+ if (p && a < d && (z || s.slice(0, v).every((g, y) => {
1070
+ const m = f[y];
1071
+ return m?.collapsible && O(m.collapsedSize, u[m.panelId]);
941
1072
  }))) {
942
- const h = l.slice(0, S).reduce((y, b) => y + c[b.id], 0);
1073
+ const g = s.slice(0, v).reduce((y, m) => y + u[m.id], 0);
943
1074
  return {
944
- ...c,
945
- [t]: T(100 - h)
1075
+ ...u,
1076
+ [t]: A(100 - g)
946
1077
  };
947
1078
  }
948
- return le({
949
- delta: f ? p - r : r - p,
950
- initialLayout: c,
951
- panelConstraints: m,
952
- pivotIndices: f ? [S - 1, S] : [S, S + 1],
953
- prevLayout: c,
1079
+ return de({
1080
+ delta: p ? d - a : a - d,
1081
+ initialLayout: u,
1082
+ panelConstraints: f,
1083
+ pivotIndices: p ? [v - 1, v] : [v, v + 1],
1084
+ prevLayout: u,
954
1085
  trigger: "imperative-api"
955
1086
  });
956
- }, a = (r) => {
957
- const l = s();
958
- if (r === l)
1087
+ }, l = (a) => {
1088
+ const s = i();
1089
+ if (a === s)
959
1090
  return;
960
1091
  const {
961
- defaultLayoutDeferred: c,
962
- derivedPanelConstraints: m,
963
- group: p,
964
- groupSize: S,
1092
+ defaultLayoutDeferred: u,
1093
+ derivedPanelConstraints: f,
1094
+ group: d,
1095
+ groupSize: v,
965
1096
  layout: z,
966
- separatorToPanels: f
967
- } = n(), d = u({
968
- nextSize: r,
969
- panels: p.panels,
1097
+ separatorToPanels: p
1098
+ } = n(), h = c({
1099
+ nextSize: a,
1100
+ panels: d.panels,
970
1101
  prevLayout: z,
971
- derivedPanelConstraints: m
972
- }), h = X({
973
- layout: d,
974
- panelConstraints: m
975
- });
976
- K(z, h) || j(p, {
977
- defaultLayoutDeferred: c,
978
- derivedPanelConstraints: m,
979
- groupSize: S,
1102
+ derivedPanelConstraints: f
1103
+ }), g = ne({
980
1104
  layout: h,
981
- separatorToPanels: f
1105
+ panelConstraints: f
1106
+ });
1107
+ W(z, g) || K(d, {
1108
+ defaultLayoutDeferred: u,
1109
+ derivedPanelConstraints: f,
1110
+ groupSize: v,
1111
+ layout: g,
1112
+ separatorToPanels: p
982
1113
  });
983
1114
  };
984
1115
  return {
985
1116
  collapse: () => {
986
- const { collapsible: r, collapsedSize: l } = o(), { mutableValues: c } = i(), m = s();
987
- r && m !== l && (c.expandToSize = m, a(l));
1117
+ const { collapsible: a, collapsedSize: s } = o(), { mutableValues: u } = r(), f = i();
1118
+ a && f !== s && (u.expandToSize = f, l(s));
988
1119
  },
989
1120
  expand: () => {
990
- const { collapsible: r, collapsedSize: l, minSize: c } = o(), { mutableValues: m } = i(), p = s();
991
- if (r && p === l) {
992
- let S = m.expandToSize ?? c;
993
- S === 0 && (S = 1), a(S);
1121
+ const { collapsible: a, collapsedSize: s, minSize: u } = o(), { mutableValues: f } = r(), d = i();
1122
+ if (a && d === s) {
1123
+ let v = f.expandToSize ?? u;
1124
+ v === 0 && (v = 1), l(v);
994
1125
  }
995
1126
  },
996
1127
  getSize: () => {
997
- const { group: r } = n(), l = s(), { element: c } = i(), m = r.orientation === "horizontal" ? c.offsetWidth : c.offsetHeight;
1128
+ const { group: a } = n(), s = i(), { element: u } = r(), f = a.orientation === "horizontal" ? u.offsetWidth : u.offsetHeight;
998
1129
  return {
999
- asPercentage: l,
1000
- inPixels: m
1130
+ asPercentage: s,
1131
+ inPixels: f
1001
1132
  };
1002
1133
  },
1003
1134
  isCollapsed: () => {
1004
- const { collapsible: r, collapsedSize: l } = o(), c = s();
1005
- return r && k(l, c);
1135
+ const { collapsible: a, collapsedSize: s } = o(), u = i();
1136
+ return a && O(s, u);
1006
1137
  },
1007
- resize: (r) => {
1008
- const { group: l } = n(), { element: c } = i(), m = ne({ group: l }), p = ie({
1009
- groupSize: m,
1010
- panelElement: c,
1011
- styleProp: r
1012
- }), S = T(p / m * 100);
1013
- a(S);
1138
+ resize: (a) => {
1139
+ const { group: s } = n(), { element: u } = r(), f = ae({ group: s }), d = ie({
1140
+ groupSize: f,
1141
+ panelElement: u,
1142
+ styleProp: a
1143
+ }), v = A(d / f * 100);
1144
+ l(v);
1014
1145
  }
1015
1146
  };
1016
1147
  }
1017
- function _e(e) {
1148
+ function Be(e) {
1018
1149
  if (e.defaultPrevented)
1019
1150
  return;
1020
- const t = V();
1021
- we(e, t).forEach((o) => {
1151
+ const t = ee();
1152
+ ke(e, t).forEach((o) => {
1022
1153
  if (o.separator && !o.separator.disableDoubleClick) {
1023
- const i = o.panels.find(
1024
- (s) => s.panelConstraints.defaultSize !== void 0
1154
+ const r = o.panels.find(
1155
+ (i) => i.panelConstraints.defaultSize !== void 0
1025
1156
  );
1026
- if (i) {
1027
- const s = i.panelConstraints.defaultSize, u = at({
1157
+ if (r) {
1158
+ const i = r.panelConstraints.defaultSize, c = pt({
1028
1159
  groupId: o.group.id,
1029
- panelId: i.id
1160
+ panelId: r.id
1030
1161
  });
1031
- u && s !== void 0 && (u.resize(s), e.preventDefault());
1162
+ c && i !== void 0 && (c.resize(i), e.preventDefault());
1032
1163
  }
1033
1164
  }
1034
1165
  });
1035
1166
  }
1036
- function pe(e) {
1037
- const t = V();
1167
+ function ye(e) {
1168
+ const t = ee();
1038
1169
  for (const [n] of t)
1039
1170
  if (n.separators.some(
1040
1171
  (o) => o.element === e
@@ -1042,14 +1173,14 @@ function pe(e) {
1042
1173
  return n;
1043
1174
  throw Error("Could not find parent Group for separator element");
1044
1175
  }
1045
- function lt({
1176
+ function ht({
1046
1177
  groupId: e
1047
1178
  }) {
1048
1179
  const t = () => {
1049
- const n = V();
1050
- for (const [o, i] of n)
1180
+ const n = ee();
1181
+ for (const [o, r] of n)
1051
1182
  if (o.id === e)
1052
- return { group: o, ...i };
1183
+ return { group: o, ...r };
1053
1184
  throw Error(`Could not find Group with id "${e}"`);
1054
1185
  };
1055
1186
  return {
@@ -1060,50 +1191,50 @@ function lt({
1060
1191
  setLayout(n) {
1061
1192
  const {
1062
1193
  defaultLayoutDeferred: o,
1063
- derivedPanelConstraints: i,
1064
- group: s,
1065
- groupSize: u,
1066
- layout: a,
1067
- separatorToPanels: r
1068
- } = t(), l = X({
1194
+ derivedPanelConstraints: r,
1195
+ group: i,
1196
+ groupSize: c,
1197
+ layout: l,
1198
+ separatorToPanels: a
1199
+ } = t(), s = ne({
1069
1200
  layout: n,
1070
- panelConstraints: i
1201
+ panelConstraints: r
1071
1202
  });
1072
- return o ? a : (K(a, l) || j(s, {
1203
+ return o ? l : (W(l, s) || K(i, {
1073
1204
  defaultLayoutDeferred: o,
1074
- derivedPanelConstraints: i,
1075
- groupSize: u,
1076
- layout: l,
1077
- separatorToPanels: r
1078
- }), l);
1205
+ derivedPanelConstraints: r,
1206
+ groupSize: c,
1207
+ layout: s,
1208
+ separatorToPanels: a
1209
+ }), s);
1079
1210
  }
1080
1211
  };
1081
1212
  }
1082
- function B(e, t) {
1083
- const n = pe(e), o = H(n.id, !0), i = n.separators.find(
1084
- (m) => m.element === e
1213
+ function te(e, t) {
1214
+ const n = ye(e), o = Q(n.id, !0), r = n.separators.find(
1215
+ (f) => f.element === e
1085
1216
  );
1086
- C(i, "Matching separator not found");
1087
- const s = o.separatorToPanels.get(i);
1088
- C(s, "Matching panels not found");
1089
- const u = s.map((m) => n.panels.indexOf(m)), r = lt({ groupId: n.id }).getLayout(), l = le({
1217
+ R(r, "Matching separator not found");
1218
+ const i = o.separatorToPanels.get(r);
1219
+ R(i, "Matching panels not found");
1220
+ const c = i.map((f) => n.panels.indexOf(f)), a = ht({ groupId: n.id }).getLayout(), s = de({
1090
1221
  delta: t,
1091
- initialLayout: r,
1222
+ initialLayout: a,
1092
1223
  panelConstraints: o.derivedPanelConstraints,
1093
- pivotIndices: u,
1094
- prevLayout: r,
1224
+ pivotIndices: c,
1225
+ prevLayout: a,
1095
1226
  trigger: "keyboard"
1096
- }), c = X({
1097
- layout: l,
1227
+ }), u = ne({
1228
+ layout: s,
1098
1229
  panelConstraints: o.derivedPanelConstraints
1099
1230
  });
1100
- K(r, c) || j(
1231
+ W(a, u) || K(
1101
1232
  n,
1102
1233
  {
1103
1234
  defaultLayoutDeferred: o.defaultLayoutDeferred,
1104
1235
  derivedPanelConstraints: o.derivedPanelConstraints,
1105
1236
  groupSize: o.groupSize,
1106
- layout: c,
1237
+ layout: u,
1107
1238
  separatorToPanels: o.separatorToPanels
1108
1239
  },
1109
1240
  // Keyboard resizes (arrow keys, Home/End, Enter collapse/expand) originate
@@ -1113,155 +1244,137 @@ function B(e, t) {
1113
1244
  { isUserInteraction: !0 }
1114
1245
  );
1115
1246
  }
1116
- function $e(e) {
1247
+ function Ue(e) {
1117
1248
  if (e.defaultPrevented)
1118
1249
  return;
1119
- const t = e.currentTarget, n = pe(t);
1250
+ const t = e.currentTarget, n = ye(t);
1120
1251
  if (!n.disabled)
1121
1252
  switch (e.key) {
1122
1253
  case "ArrowDown": {
1123
- e.preventDefault(), n.orientation === "vertical" && B(t, 5);
1254
+ e.preventDefault(), n.orientation === "vertical" && te(t, 5);
1124
1255
  break;
1125
1256
  }
1126
1257
  case "ArrowLeft": {
1127
- e.preventDefault(), n.orientation === "horizontal" && B(t, -5);
1258
+ e.preventDefault(), n.orientation === "horizontal" && te(t, -5);
1128
1259
  break;
1129
1260
  }
1130
1261
  case "ArrowRight": {
1131
- e.preventDefault(), n.orientation === "horizontal" && B(t, 5);
1262
+ e.preventDefault(), n.orientation === "horizontal" && te(t, 5);
1132
1263
  break;
1133
1264
  }
1134
1265
  case "ArrowUp": {
1135
- e.preventDefault(), n.orientation === "vertical" && B(t, -5);
1266
+ e.preventDefault(), n.orientation === "vertical" && te(t, -5);
1136
1267
  break;
1137
1268
  }
1138
1269
  case "End": {
1139
- e.preventDefault(), B(t, 100);
1270
+ e.preventDefault(), te(t, 100);
1140
1271
  break;
1141
1272
  }
1142
1273
  case "Enter": {
1143
1274
  e.preventDefault();
1144
- const o = pe(t), i = H(o.id, !0), { derivedPanelConstraints: s, layout: u, separatorToPanels: a } = i, r = o.separators.find(
1145
- (p) => p.element === t
1275
+ const o = ye(t), r = Q(o.id, !0), { derivedPanelConstraints: i, layout: c, separatorToPanels: l } = r, a = o.separators.find(
1276
+ (d) => d.element === t
1146
1277
  );
1147
- C(r, "Matching separator not found");
1148
- const l = a.get(r);
1149
- C(l, "Matching panels not found");
1150
- const c = l[0], m = s.find(
1151
- (p) => p.panelId === c.id
1278
+ R(a, "Matching separator not found");
1279
+ const s = l.get(a);
1280
+ R(s, "Matching panels not found");
1281
+ const u = s[0], f = i.find(
1282
+ (d) => d.panelId === u.id
1152
1283
  );
1153
- if (C(m, "Panel metadata not found"), m.collapsible) {
1154
- const p = u[c.id], S = m.collapsedSize === p ? o.mutableState.expandedPanelSizes[c.id] ?? m.minSize : m.collapsedSize;
1155
- B(t, S - p);
1284
+ if (R(f, "Panel metadata not found"), f.collapsible) {
1285
+ const d = c[u.id], v = f.collapsedSize === d ? o.mutableState.expandedPanelSizes[u.id] ?? f.minSize : f.collapsedSize;
1286
+ te(t, v - d);
1156
1287
  }
1157
1288
  break;
1158
1289
  }
1159
1290
  case "F6": {
1160
1291
  e.preventDefault();
1161
- const i = pe(t).separators.map(
1162
- (r) => r.element
1163
- ), s = Array.from(i).findIndex(
1164
- (r) => r === e.currentTarget
1292
+ const r = ye(t).separators.map(
1293
+ (a) => a.element
1294
+ ), i = Array.from(r).findIndex(
1295
+ (a) => a === e.currentTarget
1165
1296
  );
1166
- C(s !== null, "Index not found");
1167
- const u = e.shiftKey ? s > 0 ? s - 1 : i.length - 1 : s + 1 < i.length ? s + 1 : 0;
1168
- i[u].focus({
1297
+ R(i !== null, "Index not found");
1298
+ const c = e.shiftKey ? i > 0 ? i - 1 : r.length - 1 : i + 1 < r.length ? i + 1 : 0;
1299
+ r[c].focus({
1169
1300
  preventScroll: !0
1170
1301
  });
1171
1302
  break;
1172
1303
  }
1173
1304
  case "Home": {
1174
- e.preventDefault(), B(t, -100);
1305
+ e.preventDefault(), te(t, -100);
1175
1306
  break;
1176
1307
  }
1177
1308
  }
1178
1309
  }
1179
- function je(e) {
1310
+ function Jt(e, t) {
1311
+ const { element: n, orientation: o, panels: r } = e, i = n.getBoundingClientRect(), c = o === "horizontal";
1312
+ return Me({
1313
+ expandHitTargets: !1,
1314
+ group: e,
1315
+ includeDisabled: !0
1316
+ }).map(
1317
+ ({ panels: a, rect: s, separator: u }, f) => {
1318
+ const d = r.indexOf(a[0]), v = c ? s.left + s.width / 2 : s.top + s.height / 2;
1319
+ return {
1320
+ active: t.some((p) => {
1321
+ if (p.group !== e || p.panels[0] !== a[0])
1322
+ return !1;
1323
+ if (u || p.separator)
1324
+ return p.separator === u;
1325
+ const h = c ? p.rect.left + p.rect.width / 2 : p.rect.top + p.rect.height / 2;
1326
+ return O(v, h);
1327
+ }),
1328
+ group: e,
1329
+ key: u ? `separator-${u.id}` : `panel-${a[0].id}-${f}`,
1330
+ offset: 0,
1331
+ panelIndex: d,
1332
+ rect: new DOMRect(
1333
+ (c && !u ? v : s.left) - i.left - n.clientLeft + n.scrollLeft,
1334
+ (!c && !u ? v : s.top) - i.top - n.clientTop + n.scrollTop,
1335
+ c && !u ? 0 : s.width,
1336
+ !c && !u ? 0 : s.height
1337
+ ),
1338
+ separator: u
1339
+ };
1340
+ }
1341
+ );
1342
+ }
1343
+ function We(e) {
1180
1344
  if (e.defaultPrevented)
1181
1345
  return;
1182
1346
  if (e.pointerType === "mouse" && e.button > 0)
1183
1347
  return;
1184
- const t = V(), n = we(e, t), o = /* @__PURE__ */ new Map();
1185
- let i = !1;
1186
- n.forEach((s) => {
1187
- s.separator && (i || (i = !0, s.separator.element.focus({
1348
+ const t = ee(), n = ke(e, t), o = /* @__PURE__ */ new Map();
1349
+ let r = !1;
1350
+ n.forEach((c) => {
1351
+ c.separator && (r || (r = !0, c.separator.element.focus({
1188
1352
  // @ts-expect-error https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#browser_compatibility
1189
1353
  focusVisible: !1,
1190
1354
  preventScroll: !0
1191
1355
  })));
1192
- const u = t.get(s.group);
1193
- u && o.set(s.group, u.layout);
1194
- }), te({
1356
+ const l = t.get(c.group);
1357
+ l && o.set(c.group, l.layout);
1358
+ });
1359
+ const i = Array.from(o.keys()).flatMap(
1360
+ (c) => c.resizePreviewMode === "separator" ? Jt(c, n) : []
1361
+ );
1362
+ U({
1195
1363
  cursorFlags: 0,
1196
1364
  hitRegions: n,
1197
1365
  initialLayoutMap: o,
1198
1366
  pointerDownAtPoint: { x: e.clientX, y: e.clientY },
1367
+ previewLayoutMap: new Map(o),
1368
+ previews: i,
1199
1369
  state: "active"
1200
1370
  }), n.length && e.preventDefault();
1201
1371
  }
1202
- function ut({
1203
- document: e,
1204
- event: t,
1205
- hitRegions: n,
1206
- initialLayoutMap: o,
1207
- mountedGroups: i,
1208
- pointerDownAtPoint: s,
1209
- prevCursorFlags: u
1210
- }) {
1211
- let a = 0;
1212
- n.forEach((l) => {
1213
- const { group: c, groupSize: m } = l, { orientation: p, panels: S } = c, { disableCursor: z } = c.mutableState;
1214
- let f = 0;
1215
- s ? p === "horizontal" ? f = (t.clientX - s.x) / m * 100 : f = (t.clientY - s.y) / m * 100 : p === "horizontal" ? f = t.clientX < 0 ? -100 : 100 : f = t.clientY < 0 ? -100 : 100;
1216
- const d = o.get(c), h = i.get(c);
1217
- if (!d || !h)
1218
- return;
1219
- const {
1220
- defaultLayoutDeferred: y,
1221
- derivedPanelConstraints: b,
1222
- groupSize: v,
1223
- layout: g,
1224
- separatorToPanels: w
1225
- } = h;
1226
- if (b && g && w) {
1227
- const E = le({
1228
- delta: f,
1229
- initialLayout: d,
1230
- panelConstraints: b,
1231
- pivotIndices: l.panels.map((L) => S.indexOf(L)),
1232
- prevLayout: g,
1233
- trigger: "mouse-or-touch"
1234
- });
1235
- if (K(E, g)) {
1236
- if (f !== 0 && !z)
1237
- switch (p) {
1238
- case "horizontal": {
1239
- a |= f < 0 ? et : tt;
1240
- break;
1241
- }
1242
- case "vertical": {
1243
- a |= f < 0 ? nt : ot;
1244
- break;
1245
- }
1246
- }
1247
- } else
1248
- j(l.group, {
1249
- defaultLayoutDeferred: y,
1250
- derivedPanelConstraints: b,
1251
- groupSize: v,
1252
- layout: E,
1253
- separatorToPanels: w
1254
- });
1255
- }
1256
- });
1257
- let r = 0;
1258
- t.movementX === 0 ? r |= u & Ie : r |= a & Ie, t.movementY === 0 ? r |= u & ke : r |= a & ke, Et(r), xe(e);
1259
- }
1260
- function He(e) {
1261
- const t = V(), n = W();
1372
+ function Ke(e) {
1373
+ const t = ee(), n = X();
1262
1374
  switch (n.state) {
1263
1375
  case "active":
1264
- ut({
1376
+ Ie({
1377
+ commit: !1,
1265
1378
  document: e.currentTarget,
1266
1379
  event: e,
1267
1380
  hitRegions: n.hitRegions,
@@ -1271,35 +1384,39 @@ function He(e) {
1271
1384
  });
1272
1385
  }
1273
1386
  }
1274
- function Ve(e) {
1387
+ function qe(e) {
1275
1388
  if (e.defaultPrevented)
1276
1389
  return;
1277
- const t = W(), n = V();
1390
+ const t = X(), n = ee();
1278
1391
  switch (t.state) {
1279
1392
  case "active": {
1280
1393
  if (
1281
1394
  // Skip this check for "pointerleave" events, else Firefox triggers a false positive (see #514)
1282
1395
  e.buttons === 0
1283
1396
  ) {
1284
- te({
1397
+ t.previewLayoutMap.forEach((o, r) => {
1398
+ const i = n.get(r);
1399
+ r.resizePreviewMode === "separator" && i && !W(o, i.layout) && K(r, { ...i, layout: o });
1400
+ }), U({
1285
1401
  cursorFlags: 0,
1286
1402
  state: "inactive"
1287
1403
  }), t.hitRegions.forEach((o) => {
1288
1404
  if (!n.has(o.group))
1289
1405
  return;
1290
- const i = H(o.group.id, !0);
1291
- j(o.group, i, {
1406
+ const r = Q(o.group.id, !0);
1407
+ K(o.group, r, {
1292
1408
  isUserInteraction: !0
1293
1409
  });
1294
- });
1410
+ }), fe(e.currentTarget);
1295
1411
  return;
1296
1412
  }
1297
1413
  for (const o of t.hitRegions)
1298
1414
  if (o.separator) {
1299
- const { element: i } = o.separator;
1300
- i.hasPointerCapture?.(e.pointerId) || i.setPointerCapture?.(e.pointerId);
1415
+ const { element: r } = o.separator;
1416
+ r.isConnected && !r.hasPointerCapture?.(e.pointerId) && r.setPointerCapture?.(e.pointerId);
1301
1417
  }
1302
- ut({
1418
+ Ie({
1419
+ commit: !1,
1303
1420
  document: e.currentTarget,
1304
1421
  event: e,
1305
1422
  hitRegions: t.hitRegions,
@@ -1311,67 +1428,70 @@ function Ve(e) {
1311
1428
  break;
1312
1429
  }
1313
1430
  default: {
1314
- const o = we(e, n);
1315
- o.length === 0 ? t.state !== "inactive" && te({
1431
+ const o = ke(e, n);
1432
+ o.length === 0 ? t.state !== "inactive" && U({
1316
1433
  cursorFlags: 0,
1317
1434
  state: "inactive"
1318
- }) : te({
1435
+ }) : U({
1319
1436
  cursorFlags: 0,
1320
1437
  hitRegions: o,
1321
1438
  state: "hover"
1322
- }), xe(e.currentTarget);
1439
+ }), fe(e.currentTarget);
1323
1440
  break;
1324
1441
  }
1325
1442
  }
1326
1443
  }
1327
- function Ue(e) {
1444
+ function Xe(e) {
1328
1445
  if (e.relatedTarget instanceof HTMLIFrameElement)
1329
- switch (W().state) {
1446
+ switch (X().state) {
1330
1447
  case "hover":
1331
- te({
1448
+ U({
1332
1449
  cursorFlags: 0,
1333
1450
  state: "inactive"
1334
1451
  });
1335
1452
  }
1336
1453
  }
1337
- function Be(e) {
1454
+ function Ye(e) {
1338
1455
  if (e.defaultPrevented)
1339
1456
  return;
1340
1457
  if (e.pointerType === "mouse" && e.button > 0)
1341
1458
  return;
1342
- rt(e.currentTarget) && e.preventDefault();
1459
+ ft(
1460
+ e.currentTarget,
1461
+ e
1462
+ ) && e.preventDefault();
1343
1463
  }
1344
- function We(e) {
1464
+ function Je(e) {
1345
1465
  let t = 0, n = 0;
1346
1466
  const o = {};
1347
- for (const s of e)
1348
- if (s.defaultSize !== void 0) {
1467
+ for (const i of e)
1468
+ if (i.defaultSize !== void 0) {
1349
1469
  t++;
1350
- const u = T(s.defaultSize);
1351
- n += u, o[s.panelId] = u;
1470
+ const c = A(i.defaultSize);
1471
+ n += c, o[i.panelId] = c;
1352
1472
  } else
1353
- o[s.panelId] = void 0;
1354
- const i = e.length - t;
1355
- if (i !== 0) {
1356
- const s = T((100 - n) / i);
1357
- for (const u of e)
1358
- u.defaultSize === void 0 && (o[u.panelId] = s);
1473
+ o[i.panelId] = void 0;
1474
+ const r = e.length - t;
1475
+ if (r !== 0) {
1476
+ const i = A((100 - n) / r);
1477
+ for (const c of e)
1478
+ c.defaultSize === void 0 && (o[c.panelId] = i);
1359
1479
  }
1360
1480
  return o;
1361
1481
  }
1362
- function jt(e, t, n) {
1482
+ function Zt(e, t, n) {
1363
1483
  if (!n[0])
1364
1484
  return;
1365
- const i = e.panels.find((l) => l.element === t);
1366
- if (!i || !i.onResize)
1485
+ const r = e.panels.find((s) => s.element === t);
1486
+ if (!r || !r.onResize)
1367
1487
  return;
1368
- const s = ne({ group: e }), u = e.orientation === "horizontal" ? i.element.offsetWidth : i.element.offsetHeight, a = i.mutableValues.prevSize, r = {
1369
- asPercentage: T(u / s * 100),
1370
- inPixels: u
1488
+ const i = ae({ group: e }), c = e.orientation === "horizontal" ? r.element.offsetWidth : r.element.offsetHeight, l = r.mutableValues.prevSize, a = {
1489
+ asPercentage: A(c / i * 100),
1490
+ inPixels: c
1371
1491
  };
1372
- i.mutableValues.prevSize = r, i.onResize(r, i.id, a);
1492
+ r.mutableValues.prevSize = a, r.onResize(a, r.id, l);
1373
1493
  }
1374
- function Ht(e, t) {
1494
+ function mt(e, t) {
1375
1495
  if (Object.keys(e).length !== Object.keys(t).length)
1376
1496
  return !1;
1377
1497
  for (const o in e)
@@ -1379,10 +1499,10 @@ function Ht(e, t) {
1379
1499
  return !1;
1380
1500
  return !0;
1381
1501
  }
1382
- function Vt(e, t) {
1383
- return e.length !== t.length ? !1 : e.every((n, o) => Ht(n, t[o]));
1502
+ function Qt(e, t) {
1503
+ return e.length !== t.length ? !1 : e.every((n, o) => mt(n, t[o]));
1384
1504
  }
1385
- function Ut({
1505
+ function en({
1386
1506
  group: e,
1387
1507
  nextGroupSize: t,
1388
1508
  prevGroupSize: n,
@@ -1390,172 +1510,172 @@ function Ut({
1390
1510
  }) {
1391
1511
  if (n <= 0 || t <= 0 || n === t)
1392
1512
  return o;
1393
- let i = 0, s = 0, u = !1;
1394
- const a = /* @__PURE__ */ new Map(), r = [];
1395
- for (const m of e.panels) {
1396
- const p = o[m.id] ?? 0;
1397
- switch (m.panelConstraints.groupResizeBehavior) {
1513
+ let r = 0, i = 0, c = !1;
1514
+ const l = /* @__PURE__ */ new Map(), a = [];
1515
+ for (const f of e.panels) {
1516
+ const d = o[f.id] ?? 0;
1517
+ switch (f.panelConstraints.groupResizeBehavior) {
1398
1518
  case "preserve-pixel-size": {
1399
- u = !0;
1400
- const S = p / 100 * n, z = T(
1401
- S / t * 100
1519
+ c = !0;
1520
+ const v = d / 100 * n, z = A(
1521
+ v / t * 100
1402
1522
  );
1403
- a.set(m.id, z), i += z;
1523
+ l.set(f.id, z), r += z;
1404
1524
  break;
1405
1525
  }
1406
1526
  case "preserve-relative-size":
1407
1527
  default: {
1408
- r.push(m.id), s += p;
1528
+ a.push(f.id), i += d;
1409
1529
  break;
1410
1530
  }
1411
1531
  }
1412
1532
  }
1413
- if (!u || r.length === 0)
1533
+ if (!c || a.length === 0)
1414
1534
  return o;
1415
- const l = 100 - i, c = { ...o };
1416
- if (a.forEach((m, p) => {
1417
- c[p] = m;
1418
- }), s > 0)
1419
- for (const m of r) {
1420
- const p = o[m] ?? 0;
1421
- c[m] = T(
1422
- p / s * l
1535
+ const s = 100 - r, u = { ...o };
1536
+ if (l.forEach((f, d) => {
1537
+ u[d] = f;
1538
+ }), i > 0)
1539
+ for (const f of a) {
1540
+ const d = o[f] ?? 0;
1541
+ u[f] = A(
1542
+ d / i * s
1423
1543
  );
1424
1544
  }
1425
1545
  else {
1426
- const m = T(
1427
- l / r.length
1546
+ const f = A(
1547
+ s / a.length
1428
1548
  );
1429
- for (const p of r)
1430
- c[p] = m;
1549
+ for (const d of a)
1550
+ u[d] = f;
1431
1551
  }
1432
- return c;
1552
+ return u;
1433
1553
  }
1434
- function Bt(e, t) {
1435
- const n = e.map((i) => i.id), o = Object.keys(t);
1554
+ function tn(e, t) {
1555
+ const n = e.map((r) => r.id), o = Object.keys(t);
1436
1556
  if (n.length !== o.length)
1437
1557
  return !1;
1438
- for (const i of n)
1439
- if (!o.includes(i))
1558
+ for (const r of n)
1559
+ if (!o.includes(r))
1440
1560
  return !1;
1441
1561
  return !0;
1442
1562
  }
1443
- const J = /* @__PURE__ */ new Map();
1444
- function Wt(e) {
1563
+ const re = /* @__PURE__ */ new Map();
1564
+ function nn(e) {
1445
1565
  let t = !0;
1446
- C(
1566
+ R(
1447
1567
  e.element.ownerDocument.defaultView,
1448
1568
  "Cannot register an unmounted Group"
1449
1569
  );
1450
- const n = e.element.ownerDocument.defaultView.ResizeObserver, o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = new n((f) => {
1451
- for (const d of f) {
1452
- const { borderBoxSize: h, target: y } = d;
1570
+ const n = e.element.ownerDocument.defaultView.ResizeObserver, o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = new n((p) => {
1571
+ for (const h of p) {
1572
+ const { borderBoxSize: g, target: y } = h;
1453
1573
  if (y === e.element) {
1454
1574
  if (t) {
1455
- const b = ne({ group: e });
1456
- if (b === 0)
1575
+ const m = ae({ group: e });
1576
+ if (m === 0)
1457
1577
  return;
1458
- const v = H(e.id);
1459
- if (!v)
1578
+ const b = Q(e.id);
1579
+ if (!b)
1460
1580
  return;
1461
- const g = ve(e), w = v.defaultLayoutDeferred ? We(g) : v.layout, E = Ut({
1581
+ const x = Le(e), L = b.defaultLayoutDeferred ? Je(x) : b.layout, w = en({
1462
1582
  group: e,
1463
- nextGroupSize: b,
1464
- prevGroupSize: v.groupSize,
1465
- prevLayout: w
1466
- }), L = X({
1467
- layout: E,
1468
- panelConstraints: g
1583
+ nextGroupSize: m,
1584
+ prevGroupSize: b.groupSize,
1585
+ prevLayout: L
1586
+ }), C = ne({
1587
+ layout: w,
1588
+ panelConstraints: x
1469
1589
  });
1470
- if (!v.defaultLayoutDeferred && K(v.layout, L) && Vt(
1471
- v.derivedPanelConstraints,
1472
- g
1473
- ) && v.groupSize === b)
1590
+ if (!b.defaultLayoutDeferred && W(b.layout, C) && Qt(
1591
+ b.derivedPanelConstraints,
1592
+ x
1593
+ ) && b.groupSize === m)
1474
1594
  continue;
1475
- j(e, {
1595
+ K(e, {
1476
1596
  defaultLayoutDeferred: !1,
1477
- derivedPanelConstraints: g,
1478
- groupSize: b,
1479
- layout: L,
1480
- separatorToPanels: v.separatorToPanels
1597
+ derivedPanelConstraints: x,
1598
+ groupSize: m,
1599
+ layout: C,
1600
+ separatorToPanels: b.separatorToPanels
1481
1601
  });
1482
1602
  }
1483
1603
  } else
1484
- jt(e, y, h);
1604
+ Zt(e, y, g);
1485
1605
  }
1486
1606
  });
1487
- s.observe(e.element), e.panels.forEach((f) => {
1488
- C(
1489
- !o.has(f.id),
1490
- `Panel ids must be unique; id "${f.id}" was used more than once`
1491
- ), o.add(f.id), f.onResize && s.observe(f.element);
1607
+ i.observe(e.element), e.panels.forEach((p) => {
1608
+ R(
1609
+ !o.has(p.id),
1610
+ `Panel ids must be unique; id "${p.id}" was used more than once`
1611
+ ), o.add(p.id), p.onResize && i.observe(p.element);
1492
1612
  });
1493
- const u = ne({ group: e }), a = ve(e), r = e.panels.map(({ id: f }) => f).join(",");
1494
- let l = e.mutableState.defaultLayout;
1495
- l && (Bt(e.panels, l) || (l = void 0));
1496
- const c = e.mutableState.layouts[r] ?? l ?? We(a), m = X({
1497
- layout: c,
1498
- panelConstraints: a
1499
- }), p = e.element.ownerDocument;
1500
- J.set(
1501
- p,
1502
- (J.get(p) ?? 0) + 1
1613
+ const c = ae({ group: e }), l = Le(e), a = e.panels.map(({ id: p }) => p).join(",");
1614
+ let s = e.mutableState.defaultLayout;
1615
+ s && (tn(e.panels, s) || (s = void 0));
1616
+ const u = e.mutableState.layouts[a] ?? s ?? Je(l), f = ne({
1617
+ layout: u,
1618
+ panelConstraints: l
1619
+ }), d = e.element.ownerDocument;
1620
+ re.set(
1621
+ d,
1622
+ (re.get(d) ?? 0) + 1
1503
1623
  );
1504
- const S = /* @__PURE__ */ new Map();
1505
- return Ze(e).forEach((f) => {
1506
- f.separator && S.set(f.separator, f.panels);
1507
- }), j(e, {
1508
- defaultLayoutDeferred: u === 0,
1509
- derivedPanelConstraints: a,
1510
- groupSize: u,
1511
- layout: m,
1512
- separatorToPanels: S
1513
- }), e.separators.forEach((f) => {
1514
- C(
1515
- !i.has(f.id),
1516
- `Separator ids must be unique; id "${f.id}" was used more than once`
1517
- ), i.add(f.id), f.element.addEventListener("keydown", $e);
1518
- }), J.get(p) === 1 && (p.addEventListener("contextmenu", Ge, !0), p.addEventListener("dblclick", _e, !0), p.addEventListener("pointerdown", je, !0), p.addEventListener("pointerleave", He), p.addEventListener("pointermove", Ve), p.addEventListener("pointerout", Ue), p.addEventListener("pointerup", Be, !0)), function() {
1519
- t = !1, J.set(
1520
- p,
1521
- Math.max(0, (J.get(p) ?? 0) - 1)
1522
- ), kt(e), e.separators.forEach((d) => {
1523
- d.element.removeEventListener("keydown", $e);
1524
- }), J.get(p) || (p.removeEventListener(
1624
+ const v = /* @__PURE__ */ new Map();
1625
+ return Me({ group: e }).forEach((p) => {
1626
+ p.separator && v.set(p.separator, p.panels);
1627
+ }), K(e, {
1628
+ defaultLayoutDeferred: c === 0,
1629
+ derivedPanelConstraints: l,
1630
+ groupSize: c,
1631
+ layout: f,
1632
+ separatorToPanels: v
1633
+ }), e.separators.forEach((p) => {
1634
+ R(
1635
+ !r.has(p.id),
1636
+ `Separator ids must be unique; id "${p.id}" was used more than once`
1637
+ ), r.add(p.id), p.element.addEventListener("keydown", Ue);
1638
+ }), re.get(d) === 1 && (d.addEventListener("contextmenu", $e, !0), d.addEventListener("dblclick", Be, !0), d.addEventListener("pointerdown", We, !0), d.addEventListener("pointerleave", Ke), d.addEventListener("pointermove", qe), d.addEventListener("pointerout", Xe), d.addEventListener("pointerup", Ye, !0)), function() {
1639
+ t = !1, re.set(
1640
+ d,
1641
+ Math.max(0, (re.get(d) ?? 0) - 1)
1642
+ ), jt(e), Dt(e) && fe(d), e.separators.forEach((h) => {
1643
+ h.element.removeEventListener("keydown", Ue);
1644
+ }), re.get(d) || (d.removeEventListener(
1525
1645
  "contextmenu",
1526
- Ge,
1646
+ $e,
1527
1647
  !0
1528
- ), p.removeEventListener(
1648
+ ), d.removeEventListener(
1529
1649
  "dblclick",
1530
- _e,
1650
+ Be,
1531
1651
  !0
1532
- ), p.removeEventListener(
1652
+ ), d.removeEventListener(
1533
1653
  "pointerdown",
1534
- je,
1654
+ We,
1535
1655
  !0
1536
- ), p.removeEventListener("pointerleave", He), p.removeEventListener("pointermove", Ve), p.removeEventListener("pointerout", Ue), p.removeEventListener("pointerup", Be, !0)), s.disconnect();
1656
+ ), d.removeEventListener("pointerleave", Ke), d.removeEventListener("pointermove", qe), d.removeEventListener("pointerout", Xe), d.removeEventListener("pointerup", Ye, !0)), i.disconnect();
1537
1657
  };
1538
1658
  }
1539
- function Kt() {
1540
- const [e, t] = Q({}), n = re(() => t({}), []);
1659
+ function on() {
1660
+ const [e, t] = Z({}), n = ce(() => t({}), []);
1541
1661
  return [e, n];
1542
1662
  }
1543
- function Le(e) {
1544
- const t = mt();
1663
+ function Te(e) {
1664
+ const t = wt();
1545
1665
  return `${e ?? t}`;
1546
1666
  }
1547
- const q = typeof window < "u" ? Ke : me;
1548
- function se(e) {
1549
- const t = O(e);
1550
- return q(() => {
1667
+ const j = typeof window < "u" ? Ze : Se;
1668
+ function ue(e) {
1669
+ const t = D(e);
1670
+ return j(() => {
1551
1671
  t.current = e;
1552
- }, [e]), re(
1672
+ }, [e]), ce(
1553
1673
  (...n) => t.current?.(...n),
1554
1674
  [t]
1555
1675
  );
1556
1676
  }
1557
- function Ce(...e) {
1558
- return se((t) => {
1677
+ function Oe(...e) {
1678
+ return ue((t) => {
1559
1679
  e.forEach((n) => {
1560
1680
  if (n)
1561
1681
  switch (typeof n) {
@@ -1571,268 +1691,427 @@ function Ce(...e) {
1571
1691
  });
1572
1692
  });
1573
1693
  }
1574
- function Re(e) {
1575
- const t = O({ ...e });
1576
- return q(() => {
1694
+ function De(e) {
1695
+ const t = D({ ...e });
1696
+ return j(() => {
1577
1697
  for (const n in e)
1578
1698
  t.current[n] = e[n];
1579
1699
  }, [e]), t.current;
1580
1700
  }
1581
- const ct = gt(null);
1582
- function Xt(e, t) {
1583
- const n = O({
1701
+ const gt = Pt(null);
1702
+ function rn({
1703
+ separator: e
1704
+ }) {
1705
+ const { element: t } = e, n = D(null);
1706
+ return j(() => {
1707
+ const o = t.cloneNode(!0), r = [t, ...t.querySelectorAll("*")], i = [o, ...o.querySelectorAll("*")], c = t.ownerDocument.defaultView;
1708
+ return r.forEach((l, a) => {
1709
+ const s = i[a];
1710
+ if (s instanceof c.HTMLElement || s instanceof c.SVGElement) {
1711
+ const u = c.getComputedStyle(l);
1712
+ for (let f = 0; f < u.length; f++) {
1713
+ const d = u.item(f);
1714
+ s.style.setProperty(
1715
+ d,
1716
+ u.getPropertyValue(d)
1717
+ );
1718
+ }
1719
+ }
1720
+ s.removeAttribute("data-testid"), s.removeAttribute("id");
1721
+ }), Object.assign(o.style, {
1722
+ boxSizing: "border-box",
1723
+ height: "100%",
1724
+ margin: "0",
1725
+ position: "static",
1726
+ transform: "none",
1727
+ width: "100%"
1728
+ }), n.current.appendChild(o), () => o.remove();
1729
+ }, [t]), /* @__PURE__ */ B(
1730
+ "div",
1731
+ {
1732
+ ref: n,
1733
+ style: {
1734
+ height: "100%",
1735
+ opacity: 0.65,
1736
+ pointerEvents: "none",
1737
+ width: "100%"
1738
+ }
1739
+ }
1740
+ );
1741
+ }
1742
+ function be() {
1743
+ const e = Lt(gt);
1744
+ return R(
1745
+ e,
1746
+ "Group Context not found; did you render a Panel or Separator outside of a Group?"
1747
+ ), e;
1748
+ }
1749
+ function yt(e) {
1750
+ const { registerOverlay: t } = be(), n = D(e);
1751
+ mt(n.current, e) || (n.current = e);
1752
+ const o = n.current;
1753
+ return j(
1754
+ () => t(o),
1755
+ [t, o]
1756
+ ), null;
1757
+ }
1758
+ yt.displayName = "SeparatorOverlay";
1759
+ function sn({
1760
+ active: e,
1761
+ orientation: t,
1762
+ style: n,
1763
+ ...o
1764
+ }) {
1765
+ let r;
1766
+ switch (t) {
1767
+ case "horizontal": {
1768
+ r = {
1769
+ height: "100%",
1770
+ minWidth: "1px"
1771
+ };
1772
+ break;
1773
+ }
1774
+ case "vertical": {
1775
+ r = {
1776
+ minHeight: "1px",
1777
+ width: "100%"
1778
+ };
1779
+ break;
1780
+ }
1781
+ }
1782
+ return /* @__PURE__ */ B(
1783
+ "div",
1784
+ {
1785
+ ...o,
1786
+ "data-separator-overlay": e ? "active" : "inactive",
1787
+ style: {
1788
+ ...r,
1789
+ ...n,
1790
+ flexShrink: 0,
1791
+ pointerEvents: "none"
1792
+ }
1793
+ }
1794
+ );
1795
+ }
1796
+ function an({
1797
+ overlay: e,
1798
+ preview: t
1799
+ }) {
1800
+ const { group: n, offset: o, rect: r, separator: i } = t, c = n.orientation === "horizontal";
1801
+ let l = i?.preview, a = e;
1802
+ return Ct(l) && l.type === yt && (a = l.props, l = void 0), l == null && (a ? l = /* @__PURE__ */ B(
1803
+ sn,
1804
+ {
1805
+ ...a,
1806
+ active: t.active,
1807
+ orientation: n.orientation
1808
+ }
1809
+ ) : i && (l = /* @__PURE__ */ B(rn, { separator: i }))), /* @__PURE__ */ B(
1810
+ "div",
1811
+ {
1812
+ "aria-hidden": "true",
1813
+ "data-resize-preview": !0,
1814
+ inert: !0,
1815
+ style: {
1816
+ height: r.height,
1817
+ left: r.left,
1818
+ pointerEvents: "none",
1819
+ position: "absolute",
1820
+ top: r.top,
1821
+ transform: c ? `translateX(${o}px)` : `translateY(${o}px)`,
1822
+ width: r.width
1823
+ },
1824
+ children: l
1825
+ }
1826
+ );
1827
+ }
1828
+ function ln(e, t) {
1829
+ const n = D({
1584
1830
  getLayout: () => ({}),
1585
- setLayout: Mt
1831
+ setLayout: At
1586
1832
  });
1587
- Xe(t, () => n.current, []), q(() => {
1833
+ Qe(t, () => n.current, []), j(() => {
1588
1834
  Object.assign(
1589
1835
  n.current,
1590
- lt({ groupId: e })
1836
+ ht({ groupId: e })
1591
1837
  );
1592
1838
  });
1593
1839
  }
1594
- function qt({
1840
+ function cn({
1841
+ groupId: e,
1842
+ resizePreviewMode: t
1843
+ }) {
1844
+ const [n, o] = Z([]), r = D(n);
1845
+ return j(() => {
1846
+ const i = (l) => {
1847
+ const a = ut(e), s = t === "separator" && l.state === "active" ? l.previews.filter(
1848
+ (f) => f.group === a && (f.active || !O(f.offset, 0))
1849
+ ) : [], u = r.current;
1850
+ u.length === s.length && s.every(
1851
+ (f, d) => f === u[d]
1852
+ ) || (r.current = s, o(s));
1853
+ };
1854
+ if (t !== "separator") {
1855
+ i(X());
1856
+ return;
1857
+ }
1858
+ const c = nt(
1859
+ ({ next: l }) => i(l)
1860
+ );
1861
+ return i(X()), c;
1862
+ }, [e, t]), n;
1863
+ }
1864
+ function un({
1595
1865
  children: e,
1596
1866
  className: t,
1597
1867
  defaultLayout: n,
1598
1868
  disableCursor: o,
1599
- disabled: i,
1600
- elementRef: s,
1601
- groupRef: u,
1602
- id: a,
1603
- onLayoutChange: r,
1604
- onLayoutChanged: l,
1605
- orientation: c = "horizontal",
1606
- resizeTargetMinimumSize: m = {
1869
+ disabled: r,
1870
+ elementRef: i,
1871
+ groupRef: c,
1872
+ id: l,
1873
+ onLayoutChange: a,
1874
+ onLayoutChanged: s,
1875
+ orientation: u = "horizontal",
1876
+ resizePreviewMode: f = "panel",
1877
+ resizeTargetMinimumSize: d = {
1607
1878
  coarse: 20,
1608
1879
  fine: 10
1609
1880
  },
1610
- style: p,
1611
- ...S
1881
+ style: v,
1882
+ ...z
1612
1883
  }) {
1613
- const z = O({
1884
+ const p = D({
1614
1885
  onLayoutChange: {},
1615
1886
  onLayoutChanged: {}
1616
- }), f = se((x) => {
1617
- K(z.current.onLayoutChange, x) || (z.current.onLayoutChange = x, r?.(x));
1618
- }), d = se(
1619
- (x, P) => {
1620
- K(z.current.onLayoutChanged, x) || (z.current.onLayoutChanged = x, l?.(x, { isUserInteraction: P }));
1887
+ }), h = ue((S) => {
1888
+ W(p.current.onLayoutChange, S) || (p.current.onLayoutChange = S, a?.(S));
1889
+ }), g = ue(
1890
+ (S, P) => {
1891
+ W(p.current.onLayoutChanged, S) || (p.current.onLayoutChanged = S, s?.(S, { isUserInteraction: P }));
1621
1892
  }
1622
- ), h = Le(a), y = O(null), [b, v] = Kt(), g = O({
1893
+ ), y = Te(l), [m, b] = Z(), x = cn({
1894
+ groupId: y,
1895
+ resizePreviewMode: f
1896
+ }), L = D(null), [w, C] = on(), M = D({
1623
1897
  lastExpandedPanelSizes: {},
1624
1898
  layouts: {},
1625
1899
  panels: [],
1626
- resizeTargetMinimumSize: m,
1900
+ resizeTargetMinimumSize: d,
1627
1901
  separators: []
1628
- }), w = Ce(y, s);
1629
- Xt(h, u);
1630
- const E = se(
1631
- (x, P) => {
1632
- const I = W(), R = Oe(x), M = H(x);
1633
- if (M) {
1634
- let D = !1;
1635
- switch (I.state) {
1636
- case "active": {
1637
- D = I.hitRegions.some(
1638
- (U) => U.group === R
1639
- );
1640
- break;
1641
- }
1642
- }
1902
+ }), T = Oe(L, i);
1903
+ ln(y, c);
1904
+ const G = ue(
1905
+ (S, P) => {
1906
+ const I = Q(S);
1907
+ if (I)
1643
1908
  return {
1644
- flexGrow: M.layout[P] ?? 1,
1645
- pointerEvents: D ? "none" : void 0
1909
+ flexGrow: I.layout[P] ?? 1
1646
1910
  };
1647
- }
1648
1911
  if (n?.[P])
1649
1912
  return {
1650
1913
  flexGrow: n?.[P]
1651
1914
  };
1652
1915
  }
1653
- ), L = Re({
1916
+ ), E = De({
1654
1917
  defaultLayout: n,
1655
1918
  disableCursor: o
1656
- }), G = Se(
1919
+ }), N = Pe(
1657
1920
  () => ({
1658
1921
  get disableCursor() {
1659
- return !!L.disableCursor;
1922
+ return !!E.disableCursor;
1660
1923
  },
1661
- getPanelStyles: E,
1662
- id: h,
1663
- orientation: c,
1664
- registerPanel: (x) => {
1665
- const P = g.current;
1666
- return P.panels = be(c, [
1924
+ getPanelStyles: G,
1925
+ id: y,
1926
+ orientation: u,
1927
+ registerPanel: (S) => {
1928
+ const P = M.current;
1929
+ return P.panels = Ce(u, [
1667
1930
  ...P.panels,
1668
- x
1669
- ]), v(), () => {
1931
+ S
1932
+ ]), C(), () => {
1670
1933
  P.panels = P.panels.filter(
1671
- (I) => I !== x
1672
- ), v();
1934
+ (I) => I !== S
1935
+ ), C();
1673
1936
  };
1674
1937
  },
1675
- registerSeparator: (x) => {
1676
- const P = g.current;
1677
- return P.separators = be(c, [
1938
+ registerOverlay: (S) => (b(S), () => {
1939
+ b(void 0);
1940
+ }),
1941
+ registerSeparator: (S) => {
1942
+ const P = M.current;
1943
+ return P.separators = Ce(u, [
1678
1944
  ...P.separators,
1679
- x
1680
- ]), v(), () => {
1945
+ S
1946
+ ]), C(), () => {
1681
1947
  P.separators = P.separators.filter(
1682
- (I) => I !== x
1683
- ), v();
1948
+ (I) => I !== S
1949
+ ), C();
1684
1950
  };
1685
1951
  },
1686
- updatePanelProps: (x, { disabled: P }) => {
1687
- const R = g.current.panels.find(
1688
- (U) => U.id === x
1952
+ updatePanelProps: (S, { disabled: P }) => {
1953
+ const F = M.current.panels.find(
1954
+ (oe) => oe.id === S
1689
1955
  );
1690
- R && (R.panelConstraints.disabled = P);
1691
- const M = Oe(h), D = H(h);
1692
- M && D && j(M, {
1693
- ...D,
1694
- derivedPanelConstraints: ve(M)
1956
+ F && (F.panelConstraints.disabled = P);
1957
+ const $ = ut(y), Y = Q(y);
1958
+ $ && Y && K($, {
1959
+ ...Y,
1960
+ derivedPanelConstraints: Le($)
1695
1961
  });
1696
1962
  },
1697
- updateSeparatorProps: (x, {
1963
+ updateSeparatorProps: (S, {
1698
1964
  disabled: P,
1699
1965
  disableDoubleClick: I
1700
1966
  }) => {
1701
- const M = g.current.separators.find(
1702
- (D) => D.id === x
1967
+ const $ = M.current.separators.find(
1968
+ (Y) => Y.id === S
1703
1969
  );
1704
- M && (M.disabled = P, M.disableDoubleClick = I);
1970
+ $ && ($.disabled = P, $.disableDoubleClick = I);
1705
1971
  }
1706
1972
  }),
1707
- [E, h, v, c, L]
1708
- ), N = O(null);
1709
- return q(() => {
1710
- const x = y.current;
1711
- if (x === null)
1973
+ [G, y, C, u, E]
1974
+ ), _ = D(null);
1975
+ return j(() => {
1976
+ const S = L.current;
1977
+ if (S === null)
1712
1978
  return;
1713
- const P = g.current;
1979
+ const P = M.current;
1714
1980
  let I;
1715
- if (L.defaultLayout !== void 0 && Object.keys(L.defaultLayout).length === P.panels.length) {
1981
+ if (E.defaultLayout !== void 0 && Object.keys(E.defaultLayout).length === P.panels.length) {
1716
1982
  I = {};
1717
- for (const _ of P.panels) {
1718
- const Y = L.defaultLayout[_.id];
1719
- Y !== void 0 && (I[_.id] = Y);
1983
+ for (const J of P.panels) {
1984
+ const pe = E.defaultLayout[J.id];
1985
+ pe !== void 0 && (I[J.id] = pe);
1720
1986
  }
1721
1987
  }
1722
- const R = {
1723
- disabled: !!i,
1724
- element: x,
1725
- id: h,
1988
+ const F = {
1989
+ disabled: !!r,
1990
+ element: S,
1991
+ id: y,
1726
1992
  mutableState: {
1727
1993
  defaultLayout: I,
1728
- disableCursor: !!L.disableCursor,
1729
- expandedPanelSizes: g.current.lastExpandedPanelSizes,
1730
- layouts: g.current.layouts
1994
+ disableCursor: !!E.disableCursor,
1995
+ expandedPanelSizes: M.current.lastExpandedPanelSizes,
1996
+ layouts: M.current.layouts
1731
1997
  },
1732
- orientation: c,
1998
+ orientation: u,
1733
1999
  panels: P.panels,
2000
+ resizePreviewMode: f,
1734
2001
  resizeTargetMinimumSize: P.resizeTargetMinimumSize,
1735
2002
  separators: P.separators
1736
2003
  };
1737
- N.current = R;
1738
- const M = Wt(R), { defaultLayoutDeferred: D, derivedPanelConstraints: U, layout: ue } = H(R.id, !0);
1739
- !D && U.length > 0 && (f(ue), d(ue, !1));
1740
- const oe = Pe(h, (_) => {
1741
- const { defaultLayoutDeferred: Y, derivedPanelConstraints: Me, layout: ce } = _.next;
1742
- if (Y || Me.length === 0)
2004
+ _.current = F;
2005
+ const $ = nn(F), { defaultLayoutDeferred: Y, derivedPanelConstraints: oe, layout: le } = Q(F.id, !0);
2006
+ !Y && oe.length > 0 && (h(le), g(le, !1));
2007
+ const xe = Ee(y, (J) => {
2008
+ const { defaultLayoutDeferred: pe, derivedPanelConstraints: Ae, layout: he } = J.next;
2009
+ if (pe || Ae.length === 0)
1743
2010
  return;
1744
- const ft = R.panels.map(({ id: $ }) => $).join(",");
1745
- R.mutableState.layouts[ft] = ce, Me.forEach(($) => {
1746
- if ($.collapsible) {
1747
- const { layout: ge } = _.prev ?? {};
1748
- if (ge) {
1749
- const pt = k(
1750
- $.collapsedSize,
1751
- ce[$.panelId]
1752
- ), ht = k(
1753
- $.collapsedSize,
1754
- ge[$.panelId]
2011
+ const vt = F.panels.map(({ id: q }) => q).join(",");
2012
+ F.mutableState.layouts[vt] = he, Ae.forEach((q) => {
2013
+ if (q.collapsible) {
2014
+ const { layout: ze } = J.prev ?? {};
2015
+ if (ze) {
2016
+ const bt = O(
2017
+ q.collapsedSize,
2018
+ he[q.panelId]
2019
+ ), xt = O(
2020
+ q.collapsedSize,
2021
+ ze[q.panelId]
1755
2022
  );
1756
- pt && !ht && (R.mutableState.expandedPanelSizes[$.panelId] = ge[$.panelId]);
2023
+ bt && !xt && (F.mutableState.expandedPanelSizes[q.panelId] = ze[q.panelId]);
1757
2024
  }
1758
2025
  }
1759
2026
  });
1760
- const dt = W().state !== "active";
1761
- f(ce), dt && d(ce, _.isUserInteraction);
2027
+ const St = X().state !== "active";
2028
+ h(he), St && g(he, J.isUserInteraction);
1762
2029
  });
1763
2030
  return () => {
1764
- N.current = null, M(), oe();
2031
+ _.current = null, $(), xe();
1765
2032
  };
1766
2033
  }, [
1767
- i,
2034
+ r,
2035
+ y,
2036
+ g,
1768
2037
  h,
1769
- d,
2038
+ u,
2039
+ w,
1770
2040
  f,
1771
- c,
1772
- b,
1773
- L
1774
- ]), me(() => {
1775
- const x = N.current;
1776
- x && (x.mutableState.defaultLayout = n, x.mutableState.disableCursor = !!o);
1777
- }), /* @__PURE__ */ ae(ct.Provider, { value: G, children: /* @__PURE__ */ ae(
2041
+ E
2042
+ ]), Se(() => {
2043
+ const S = _.current;
2044
+ S && (S.mutableState.defaultLayout = n, S.mutableState.disableCursor = !!o);
2045
+ }), /* @__PURE__ */ B(gt.Provider, { value: N, children: /* @__PURE__ */ zt(
1778
2046
  "div",
1779
2047
  {
1780
- ...S,
2048
+ ...z,
1781
2049
  className: t,
1782
2050
  "data-group": !0,
1783
- "data-testid": h,
1784
- id: h,
1785
- ref: w,
2051
+ "data-testid": y,
2052
+ id: y,
2053
+ ref: T,
1786
2054
  style: {
1787
2055
  height: "100%",
1788
2056
  width: "100%",
1789
2057
  overflow: "hidden",
1790
- ...p,
2058
+ position: f === "separator" ? "relative" : void 0,
2059
+ ...v,
1791
2060
  display: "flex",
1792
- flexDirection: c === "horizontal" ? "row" : "column",
2061
+ flexDirection: u === "horizontal" ? "row" : "column",
1793
2062
  flexWrap: "nowrap",
1794
2063
  // Inform the browser that the library is handling touch events for this element
1795
2064
  // but still allow users to scroll content within panels in the non-resizing direction
1796
2065
  // NOTE This is not an inherited style
1797
2066
  // See github.com/bvaughn/react-resizable-panels/issues/662
1798
- touchAction: c === "horizontal" ? "pan-y" : "pan-x"
2067
+ touchAction: u === "horizontal" ? "pan-y" : "pan-x"
1799
2068
  },
1800
- children: e
2069
+ children: [
2070
+ e,
2071
+ x.map((S) => /* @__PURE__ */ B(
2072
+ an,
2073
+ {
2074
+ overlay: m,
2075
+ preview: S
2076
+ },
2077
+ S.key
2078
+ ))
2079
+ ]
1801
2080
  }
1802
2081
  ) });
1803
2082
  }
1804
- qt.displayName = "Group";
1805
- function he(e, t) {
2083
+ un.displayName = "Group";
2084
+ function ve(e, t) {
1806
2085
  return `react-resizable-panels:${[e, ...t].join(":")}`;
1807
2086
  }
1808
- function Yt({
2087
+ function fn({
1809
2088
  id: e,
1810
2089
  panelIds: t,
1811
2090
  storage: n
1812
2091
  }) {
1813
- const o = he(e, []), i = n.getItem(o);
1814
- if (i)
2092
+ const o = ve(e, []), r = n.getItem(o);
2093
+ if (r)
1815
2094
  try {
1816
- const s = JSON.parse(i);
2095
+ const i = JSON.parse(r);
1817
2096
  if (t) {
1818
- const u = t.join(","), a = s[u];
1819
- if (a && Array.isArray(a.layout) && t.length === a.layout.length) {
1820
- const r = {};
1821
- for (let l = 0; l < t.length; l++)
1822
- r[t[l]] = a.layout[l];
1823
- return r;
2097
+ const c = t.join(","), l = i[c];
2098
+ if (l && Array.isArray(l.layout) && t.length === l.layout.length) {
2099
+ const a = {};
2100
+ for (let s = 0; s < t.length; s++)
2101
+ a[t[s]] = l.layout[s];
2102
+ return a;
1824
2103
  }
1825
2104
  } else {
1826
- const u = Object.keys(s);
1827
- if (u.length === 1) {
1828
- const a = s[u[0]];
1829
- if (a && Array.isArray(a.layout)) {
1830
- const r = u[0].split(",");
1831
- if (r.length === a.layout.length) {
1832
- const l = {};
1833
- for (let c = 0; c < r.length; c++)
1834
- l[r[c]] = a.layout[c];
1835
- return l;
2105
+ const c = Object.keys(i);
2106
+ if (c.length === 1) {
2107
+ const l = i[c[0]];
2108
+ if (l && Array.isArray(l.layout)) {
2109
+ const a = c[0].split(",");
2110
+ if (a.length === l.layout.length) {
2111
+ const s = {};
2112
+ for (let u = 0; u < a.length; u++)
2113
+ s[a[u]] = l.layout[u];
2114
+ return s;
1836
2115
  }
1837
2116
  }
1838
2117
  }
@@ -1840,224 +2119,220 @@ function Yt({
1840
2119
  } catch {
1841
2120
  }
1842
2121
  }
1843
- function an({
2122
+ function xn({
1844
2123
  debounceSaveMs: e = 100,
1845
2124
  onlySaveAfterUserInteractions: t,
1846
2125
  panelIds: n,
1847
2126
  storage: o = localStorage,
1848
- ...i
2127
+ ...r
1849
2128
  }) {
1850
- const s = n !== void 0, u = "id" in i ? i.id : i.groupId, a = he(u, n ?? []), r = qe(
1851
- Jt,
1852
- () => o.getItem(a),
1853
- () => o.getItem(a)
1854
- ), l = Se(() => {
1855
- if (r) {
1856
- const d = JSON.parse(r), h = Object.values(d);
1857
- if (Array.from(h).every((y) => typeof y == "number"))
1858
- return d;
2129
+ const i = n !== void 0, c = "id" in r ? r.id : r.groupId, l = ve(c, n ?? []), a = et(
2130
+ dn,
2131
+ () => o.getItem(l),
2132
+ () => o.getItem(l)
2133
+ ), s = Pe(() => {
2134
+ if (a) {
2135
+ const h = JSON.parse(a), g = Object.values(h);
2136
+ if (Array.from(g).every((y) => typeof y == "number"))
2137
+ return h;
1859
2138
  }
1860
- }, [r]), c = Se(() => {
1861
- if (!l)
1862
- return Yt({
1863
- id: u,
2139
+ }, [a]), u = Pe(() => {
2140
+ if (!s)
2141
+ return fn({
2142
+ id: c,
1864
2143
  panelIds: n,
1865
2144
  storage: o
1866
2145
  });
1867
- }, [l, u, n, o]), m = l ?? c, p = O(null), S = re(() => {
1868
- const d = p.current;
1869
- d && (p.current = null, clearTimeout(d));
2146
+ }, [s, c, n, o]), f = s ?? u, d = D(null), v = ce(() => {
2147
+ const h = d.current;
2148
+ h && (d.current = null, clearTimeout(h));
1870
2149
  }, []);
1871
- Ke(() => () => {
1872
- S();
1873
- }, [S]);
1874
- const z = re(
2150
+ Ze(() => () => {
2151
+ v();
2152
+ }, [v]);
2153
+ const z = ce(
1875
2154
  // The hook persists every layout commit -- including library-driven ones --
1876
2155
  // because it owns its own storage and the goal is to remember whatever
1877
2156
  // layout the user is currently looking at. Consumers that only want to
1878
2157
  // persist on user interaction should branch on `isUserInteraction` in
1879
2158
  // their own callback (see #716) rather than via this hook.
1880
- (d, h) => {
1881
- if (t && !h.isUserInteraction)
2159
+ (h, g) => {
2160
+ if (t && !g.isUserInteraction)
1882
2161
  return;
1883
- S();
2162
+ v();
1884
2163
  let y;
1885
- s ? y = he(u, Object.keys(d)) : y = he(u, []);
2164
+ i ? y = ve(c, Object.keys(h)) : y = ve(c, []);
1886
2165
  try {
1887
- o.setItem(y, JSON.stringify(d));
1888
- } catch (b) {
1889
- console.error(b);
2166
+ o.setItem(y, JSON.stringify(h));
2167
+ } catch (m) {
2168
+ console.error(m);
1890
2169
  }
1891
2170
  },
1892
2171
  [
1893
- S,
1894
- s,
1895
- u,
2172
+ v,
2173
+ i,
2174
+ c,
1896
2175
  t,
1897
2176
  o
1898
2177
  ]
1899
- ), f = re(
1900
- (d) => {
1901
- S(), e === 0 ? z(d, { isUserInteraction: !1 }) : p.current = setTimeout(() => {
1902
- z(d, { isUserInteraction: !1 });
2178
+ ), p = ce(
2179
+ (h) => {
2180
+ v(), e === 0 ? z(h, { isUserInteraction: !1 }) : d.current = setTimeout(() => {
2181
+ z(h, { isUserInteraction: !1 });
1903
2182
  }, e);
1904
2183
  },
1905
- [S, e, z]
2184
+ [v, e, z]
1906
2185
  );
1907
2186
  return {
1908
2187
  /**
1909
2188
  * Pass this value to `Group` as the `defaultLayout` prop.
1910
2189
  */
1911
- defaultLayout: m,
2190
+ defaultLayout: f,
1912
2191
  /**
1913
2192
  * Attach this callback on the `Group` as the `onLayoutChange` prop.
1914
2193
  *
1915
2194
  * @deprecated Use the {@link onLayoutChanged} prop instead.
1916
2195
  */
1917
- onLayoutChange: f,
2196
+ onLayoutChange: p,
1918
2197
  /**
1919
2198
  * Attach this callback on the `Group` as the `onLayoutChanged` prop.
1920
2199
  */
1921
2200
  onLayoutChanged: z
1922
2201
  };
1923
2202
  }
1924
- function Jt() {
2203
+ function dn() {
1925
2204
  return function() {
1926
2205
  };
1927
2206
  }
1928
- function ln() {
1929
- return Q(null);
2207
+ function zn() {
2208
+ return Z(null);
1930
2209
  }
1931
- function un() {
1932
- return O(null);
1933
- }
1934
- function Ee() {
1935
- const e = yt(ct);
1936
- return C(
1937
- e,
1938
- "Group Context not found; did you render a Panel or Separator outside of a Group?"
1939
- ), e;
2210
+ function wn() {
2211
+ return D(null);
1940
2212
  }
1941
- function Zt(e, t) {
1942
- const { id: n } = Ee(), o = O({
1943
- collapse: ye,
1944
- expand: ye,
2213
+ function pn(e, t) {
2214
+ const { id: n } = be(), o = D({
2215
+ collapse: we,
2216
+ expand: we,
1945
2217
  getSize: () => ({
1946
2218
  asPercentage: 0,
1947
2219
  inPixels: 0
1948
2220
  }),
1949
2221
  isCollapsed: () => !1,
1950
- resize: ye
2222
+ resize: we
1951
2223
  });
1952
- Xe(t, () => o.current, []), q(() => {
2224
+ Qe(t, () => o.current, []), j(() => {
1953
2225
  Object.assign(
1954
2226
  o.current,
1955
- at({ groupId: n, panelId: e })
2227
+ pt({ groupId: n, panelId: e })
1956
2228
  );
1957
2229
  });
1958
2230
  }
1959
- function Qt({
2231
+ function hn({
1960
2232
  children: e,
1961
2233
  className: t,
1962
2234
  collapsedSize: n = "0%",
1963
- collapsible: o = !1,
2235
+ collapsedThreshold: o,
2236
+ collapsible: r = !1,
1964
2237
  defaultSize: i,
1965
- disabled: s,
1966
- elementRef: u,
2238
+ disabled: c,
2239
+ elementRef: l,
1967
2240
  groupResizeBehavior: a = "preserve-relative-size",
1968
- id: r,
1969
- maxSize: l = "100%",
1970
- minSize: c = "0%",
1971
- onResize: m,
1972
- panelRef: p,
1973
- style: S,
1974
- ...z
2241
+ id: s,
2242
+ maxSize: u = "100%",
2243
+ minSize: f = "0%",
2244
+ onResize: d,
2245
+ panelRef: v,
2246
+ style: z,
2247
+ ...p
1975
2248
  }) {
1976
- const f = !!r, d = Le(r), h = Re({
1977
- disabled: s
1978
- }), y = O(null), b = Ce(y, u), {
1979
- getPanelStyles: v,
1980
- id: g,
2249
+ const h = !!s, g = Te(s), y = De({
2250
+ disabled: c
2251
+ }), m = D(null), b = Oe(m, l), {
2252
+ getPanelStyles: x,
2253
+ id: L,
1981
2254
  orientation: w,
1982
- registerPanel: E,
1983
- updatePanelProps: L
1984
- } = Ee(), G = m !== null, N = se(
1985
- (R, M, D) => {
1986
- m?.(R, r, D);
2255
+ registerPanel: C,
2256
+ updatePanelProps: M
2257
+ } = be(), T = d !== null, G = ue(
2258
+ (S, P, I) => {
2259
+ d?.(S, s, I);
1987
2260
  }
1988
2261
  );
1989
- q(() => {
1990
- const R = y.current;
1991
- if (R !== null) {
1992
- const M = {
1993
- element: R,
1994
- id: d,
1995
- idIsStable: f,
2262
+ j(() => {
2263
+ const S = m.current;
2264
+ if (S !== null) {
2265
+ const P = {
2266
+ element: S,
2267
+ id: g,
2268
+ idIsStable: h,
1996
2269
  mutableValues: {
1997
2270
  expandToSize: void 0,
1998
2271
  prevSize: void 0
1999
2272
  },
2000
- onResize: G ? N : void 0,
2273
+ onResize: T ? G : void 0,
2001
2274
  panelConstraints: {
2002
2275
  groupResizeBehavior: a,
2003
2276
  collapsedSize: n,
2004
- collapsible: o,
2277
+ collapsedThreshold: o,
2278
+ collapsible: r,
2005
2279
  defaultSize: i,
2006
- disabled: h.disabled,
2007
- maxSize: l,
2008
- minSize: c
2280
+ disabled: y.disabled,
2281
+ maxSize: u,
2282
+ minSize: f
2009
2283
  }
2010
2284
  };
2011
- return E(M);
2285
+ return C(P);
2012
2286
  }
2013
2287
  }, [
2014
2288
  a,
2015
2289
  n,
2016
2290
  o,
2291
+ r,
2017
2292
  i,
2018
- G,
2019
- d,
2293
+ T,
2294
+ g,
2295
+ h,
2296
+ u,
2020
2297
  f,
2021
- l,
2022
- c,
2023
- N,
2298
+ G,
2299
+ C,
2300
+ y
2301
+ ]), Se(() => {
2302
+ M(g, { disabled: c });
2303
+ }, [c, g, M]), pn(g, v);
2304
+ const E = () => {
2305
+ const S = x(L, g);
2306
+ if (S)
2307
+ return JSON.stringify(S);
2308
+ }, N = et(
2309
+ (S) => Ee(L, S),
2024
2310
  E,
2025
- h
2026
- ]), me(() => {
2027
- L(d, { disabled: s });
2028
- }, [s, d, L]), Zt(d, p);
2029
- const x = () => {
2030
- const R = v(g, d);
2031
- if (R)
2032
- return JSON.stringify(R);
2033
- }, P = qe(
2034
- (R) => Pe(g, R),
2035
- x,
2036
- x
2311
+ E
2037
2312
  );
2038
- let I;
2039
- return P ? I = JSON.parse(P) : i !== void 0 ? I = {
2313
+ let _;
2314
+ return N ? _ = JSON.parse(N) : i !== void 0 ? _ = {
2040
2315
  flexGrow: void 0,
2041
2316
  flexShrink: void 0,
2042
2317
  flexBasis: i
2043
- } : I = { flexGrow: 1 }, /* @__PURE__ */ ae(
2318
+ } : _ = { flexGrow: 1 }, /* @__PURE__ */ B(
2044
2319
  "div",
2045
2320
  {
2046
- ...z,
2047
- "data-disabled": s || void 0,
2321
+ ...p,
2322
+ "data-disabled": c || void 0,
2048
2323
  "data-panel": !0,
2049
- "data-testid": d,
2050
- id: d,
2324
+ "data-testid": g,
2325
+ id: g,
2051
2326
  ref: b,
2052
2327
  style: {
2053
- ...en,
2328
+ ...mn,
2054
2329
  display: "flex",
2055
2330
  flexBasis: 0,
2056
2331
  flexShrink: 1,
2057
2332
  overflow: "visible",
2058
- ...I
2333
+ ..._
2059
2334
  },
2060
- children: /* @__PURE__ */ ae(
2335
+ children: /* @__PURE__ */ B(
2061
2336
  "div",
2062
2337
  {
2063
2338
  className: t,
@@ -2066,7 +2341,7 @@ function Qt({
2066
2341
  maxWidth: "100%",
2067
2342
  flexGrow: 1,
2068
2343
  overflow: "auto",
2069
- ...S,
2344
+ ...z,
2070
2345
  // Inform the browser that the library is handling touch events for this element
2071
2346
  // but still allow users to scroll content within panels in the non-resizing direction
2072
2347
  // NOTE This is not an inherited style
@@ -2079,8 +2354,8 @@ function Qt({
2079
2354
  }
2080
2355
  );
2081
2356
  }
2082
- Qt.displayName = "Panel";
2083
- const en = {
2357
+ hn.displayName = "Panel";
2358
+ const mn = {
2084
2359
  minHeight: 0,
2085
2360
  maxHeight: "100%",
2086
2361
  height: "auto",
@@ -2092,39 +2367,39 @@ const en = {
2092
2367
  padding: 0,
2093
2368
  margin: 0
2094
2369
  };
2095
- function cn() {
2096
- return Q(null);
2370
+ function Pn() {
2371
+ return Z(null);
2097
2372
  }
2098
- function fn() {
2099
- return O(null);
2373
+ function Ln() {
2374
+ return D(null);
2100
2375
  }
2101
- function tn({
2376
+ function gn({
2102
2377
  layout: e,
2103
2378
  panelConstraints: t,
2104
2379
  panelId: n,
2105
2380
  panelIndex: o
2106
2381
  }) {
2107
- let i, s;
2108
- const u = e[n], a = t.find(
2109
- (r) => r.panelId === n
2382
+ let r, i;
2383
+ const c = e[n], l = t.find(
2384
+ (a) => a.panelId === n
2110
2385
  );
2111
- if (a) {
2112
- const r = a.maxSize, l = a.collapsible ? a.collapsedSize : a.minSize, c = [o, o + 1];
2113
- s = X({
2114
- layout: le({
2115
- delta: l - u,
2386
+ if (l) {
2387
+ const a = l.maxSize, s = l.collapsible ? l.collapsedSize : l.minSize, u = [o, o + 1];
2388
+ i = ne({
2389
+ layout: de({
2390
+ delta: s - c,
2116
2391
  initialLayout: e,
2117
2392
  panelConstraints: t,
2118
- pivotIndices: c,
2393
+ pivotIndices: u,
2119
2394
  prevLayout: e
2120
2395
  }),
2121
2396
  panelConstraints: t
2122
- })[n], i = X({
2123
- layout: le({
2124
- delta: r - u,
2397
+ })[n], r = ne({
2398
+ layout: de({
2399
+ delta: a - c,
2125
2400
  initialLayout: e,
2126
2401
  panelConstraints: t,
2127
- pivotIndices: c,
2402
+ pivotIndices: u,
2128
2403
  prevLayout: e
2129
2404
  }),
2130
2405
  panelConstraints: t
@@ -2132,108 +2407,132 @@ function tn({
2132
2407
  }
2133
2408
  return {
2134
2409
  valueControls: n,
2135
- valueMax: i,
2136
- valueMin: s,
2137
- valueNow: u
2410
+ valueMax: r,
2411
+ valueMin: i,
2412
+ valueNow: c
2138
2413
  };
2139
2414
  }
2140
- function nn({
2415
+ function yn({
2141
2416
  children: e,
2142
2417
  className: t,
2143
2418
  disabled: n,
2144
2419
  disableDoubleClick: o,
2145
- elementRef: i,
2146
- id: s,
2147
- style: u,
2420
+ elementRef: r,
2421
+ id: i,
2422
+ preview: c,
2423
+ style: l,
2148
2424
  ...a
2149
2425
  }) {
2150
- const r = Le(s), l = Re({
2426
+ const s = Te(i), u = De({
2151
2427
  disabled: n,
2152
- disableDoubleClick: o
2153
- }), [c, m] = Q({}), [p, S] = Q("inactive"), [z, f] = Q(!1), d = O(null), h = Ce(d, i), {
2154
- disableCursor: y,
2155
- id: b,
2156
- orientation: v,
2157
- registerSeparator: g,
2158
- updateSeparatorProps: w
2159
- } = Ee(), E = v === "horizontal" ? "vertical" : "horizontal";
2160
- q(() => {
2161
- const N = d.current;
2162
- if (N !== null) {
2163
- const x = {
2164
- disabled: l.disabled,
2165
- disableDoubleClick: l.disableDoubleClick,
2166
- element: N,
2167
- id: r
2168
- }, P = g(x), I = Rt(
2169
- (M) => {
2170
- S(
2171
- M.next.state !== "inactive" && M.next.hitRegions.some(
2172
- (D) => D.separator === x
2173
- ) ? M.next.state : "inactive"
2428
+ disableDoubleClick: o,
2429
+ children: e,
2430
+ className: t,
2431
+ preview: c,
2432
+ style: l
2433
+ }), [f, d] = Z({}), [v, z] = Z("inactive"), [p, h] = Z(!1), g = D(null), y = D(null), m = Oe(g, r), {
2434
+ disableCursor: b,
2435
+ id: x,
2436
+ orientation: L,
2437
+ registerSeparator: w,
2438
+ updateSeparatorProps: C
2439
+ } = be(), M = L === "horizontal" ? "vertical" : "horizontal";
2440
+ j(() => {
2441
+ const E = g.current;
2442
+ if (E !== null) {
2443
+ const N = {
2444
+ disabled: u.disabled,
2445
+ disableDoubleClick: u.disableDoubleClick,
2446
+ element: E,
2447
+ id: s,
2448
+ get children() {
2449
+ return u.children;
2450
+ },
2451
+ get className() {
2452
+ return u.className;
2453
+ },
2454
+ get preview() {
2455
+ return u.preview;
2456
+ },
2457
+ get style() {
2458
+ return u.style;
2459
+ }
2460
+ };
2461
+ y.current = N;
2462
+ const _ = w(N), S = nt(
2463
+ (I) => {
2464
+ z(
2465
+ I.next.state !== "inactive" && I.next.hitRegions.some(
2466
+ (F) => F.separator === N
2467
+ ) ? I.next.state : "inactive"
2174
2468
  );
2175
2469
  }
2176
- ), R = Pe(
2177
- b,
2178
- (M) => {
2179
- const { derivedPanelConstraints: D, layout: U, separatorToPanels: ue } = M.next, oe = ue.get(x);
2470
+ ), P = Ee(
2471
+ x,
2472
+ (I) => {
2473
+ const { derivedPanelConstraints: F, layout: $, separatorToPanels: Y } = I.next, oe = Y.get(N);
2180
2474
  if (oe) {
2181
- const _ = oe[0], Y = oe.indexOf(_);
2182
- m(
2183
- tn({
2184
- layout: U,
2185
- panelConstraints: D,
2186
- panelId: _.id,
2187
- panelIndex: Y
2475
+ const le = oe[0], xe = F.findIndex(
2476
+ (J) => J.panelId === le.id
2477
+ );
2478
+ d(
2479
+ gn({
2480
+ layout: $,
2481
+ panelConstraints: F,
2482
+ panelId: le.id,
2483
+ panelIndex: xe
2188
2484
  })
2189
2485
  );
2190
2486
  }
2191
2487
  }
2192
2488
  );
2193
2489
  return () => {
2194
- I(), R(), P();
2490
+ y.current = null, S(), P(), _();
2195
2491
  };
2196
2492
  }
2197
- }, [b, r, g, l]), me(() => {
2198
- w(r, { disabled: n, disableDoubleClick: o });
2199
- }, [n, o, r, w]);
2200
- let L;
2201
- n && !y && (L = "not-allowed");
2493
+ }, [x, s, w, u]), j(() => {
2494
+ const E = y.current;
2495
+ E && Ot(E);
2496
+ }, [c]), Se(() => {
2497
+ C(s, { disabled: n, disableDoubleClick: o });
2498
+ }, [n, o, s, C]);
2499
+ let T;
2500
+ n && !b && (T = "not-allowed");
2202
2501
  let G;
2203
2502
  if (n)
2204
2503
  G = "disabled";
2205
2504
  else
2206
- switch (p) {
2505
+ switch (v) {
2207
2506
  case "active": {
2208
2507
  G = "active";
2209
2508
  break;
2210
2509
  }
2211
2510
  default:
2212
- z ? G = "focus" : G = p;
2511
+ p ? G = "focus" : G = v;
2213
2512
  }
2214
- return /* @__PURE__ */ ae(
2513
+ return /* @__PURE__ */ B(
2215
2514
  "div",
2216
2515
  {
2217
2516
  ...a,
2218
- "aria-controls": c.valueControls,
2517
+ "aria-controls": f.valueControls,
2219
2518
  "aria-disabled": n || void 0,
2220
- "aria-orientation": E,
2221
- "aria-valuemax": c.valueMax,
2222
- "aria-valuemin": c.valueMin,
2223
- "aria-valuenow": c.valueNow,
2519
+ "aria-orientation": M,
2520
+ "aria-valuemax": f.valueMax,
2521
+ "aria-valuemin": f.valueMin,
2522
+ "aria-valuenow": f.valueNow,
2224
2523
  children: e,
2225
2524
  className: t,
2226
2525
  "data-separator": G,
2227
- "data-testid": r,
2228
- id: r,
2229
- onBlur: () => f(!1),
2230
- onFocus: () => f(!0),
2231
- ref: h,
2526
+ "data-testid": s,
2527
+ id: s,
2528
+ onBlur: () => h(!1),
2529
+ onFocus: () => h(!0),
2530
+ ref: m,
2232
2531
  role: "separator",
2233
2532
  style: {
2234
2533
  flexBasis: "auto",
2235
- cursor: L,
2236
- ...u,
2534
+ cursor: T,
2535
+ ...l,
2237
2536
  flexGrow: 0,
2238
2537
  flexShrink: 0,
2239
2538
  // Inform the browser that the library is handling touch events for this element
@@ -2244,16 +2543,17 @@ function nn({
2244
2543
  }
2245
2544
  );
2246
2545
  }
2247
- nn.displayName = "Separator";
2546
+ yn.displayName = "Separator";
2248
2547
  export {
2249
- qt as Group,
2250
- Qt as Panel,
2251
- nn as Separator,
2252
- Ct as isCoarsePointer,
2253
- an as useDefaultLayout,
2254
- ln as useGroupCallbackRef,
2255
- un as useGroupRef,
2256
- cn as usePanelCallbackRef,
2257
- fn as usePanelRef
2548
+ un as Group,
2549
+ hn as Panel,
2550
+ yn as Separator,
2551
+ yt as SeparatorOverlay,
2552
+ $t as isCoarsePointer,
2553
+ xn as useDefaultLayout,
2554
+ zn as useGroupCallbackRef,
2555
+ wn as useGroupRef,
2556
+ Pn as usePanelCallbackRef,
2557
+ Ln as usePanelRef
2258
2558
  };
2259
2559
  //# sourceMappingURL=react-resizable-panels.js.map