@mintplayer/web-components 2.13.0 → 2.15.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.
Files changed (54) hide show
  1. package/README.md +15 -0
  2. package/badge/src/styles/badge.styles.d.ts +2 -0
  3. package/chunks/install-light-styles-DbCAGFOC.mjs +209 -0
  4. package/chunks/{mp-datatable-GmKqaN8y.mjs → mp-datatable-UJI8E73X.mjs} +484 -476
  5. package/chunks/{mp-splitter-LszuRDbR.mjs → mp-splitter-Ckn1kN4v.mjs} +33 -19
  6. package/chunks/{mp-treeview-tkWu28iF.mjs → mp-treeview-C8iltDbq.mjs} +61 -63
  7. package/datatable/index.mjs +2 -2
  8. package/datatable/src/components/mp-datatable.d.ts +9 -1
  9. package/datatable/src/index.d.ts +1 -1
  10. package/datatable/src/styles/datatable.light.styles.d.ts +2 -0
  11. package/datatable/src/styles/index.d.ts +1 -1
  12. package/dock/index.mjs +917 -921
  13. package/dock/src/components/mint-dock-manager.element.d.ts +16 -42
  14. package/dock/src/core/geometry.d.ts +36 -0
  15. package/dock/src/core/index.d.ts +6 -0
  16. package/dock/src/core/intersection-sizing.d.ts +83 -0
  17. package/dock/src/core/layout-tree.d.ts +105 -0
  18. package/dock/src/core/resize.d.ts +83 -0
  19. package/dock/src/core/sizes.d.ts +31 -0
  20. package/dock/src/core/types.d.ts +58 -0
  21. package/file-manager/index.mjs +31 -30
  22. package/file-manager/src/components/mp-file-manager.d.ts +2 -0
  23. package/light-dom/index.d.ts +1 -0
  24. package/light-dom/index.mjs +11 -0
  25. package/light-dom/src/index.d.ts +2 -0
  26. package/light-dom/src/install-light-styles.d.ts +25 -0
  27. package/light-dom/src/scoped-html.d.ts +26 -0
  28. package/navbar/index.mjs +71 -44
  29. package/navbar/src/components/mp-navbar.d.ts +17 -1
  30. package/package.json +5 -1
  31. package/query-builder/index.mjs +1472 -2651
  32. package/query-builder/src/index.d.ts +4 -0
  33. package/query-builder/src/mp-query-builder.element.d.ts +1 -1
  34. package/query-builder/src/mp-query-builder.light.styles.d.ts +2 -0
  35. package/query-builder/src/mp-query-condition.element.d.ts +1 -1
  36. package/query-builder/src/mp-query-condition.light.styles.d.ts +2 -0
  37. package/query-builder/src/mp-query-group.element.d.ts +1 -1
  38. package/query-builder/src/mp-query-group.light.styles.d.ts +2 -0
  39. package/query-builder/src/mp-query-subquery.element.d.ts +1 -1
  40. package/query-builder/src/mp-query-subquery.light.styles.d.ts +2 -0
  41. package/ribbon/index.mjs +7 -3
  42. package/ribbon/src/mp-quick-access-toolbar.element.d.ts +11 -0
  43. package/splitter/index.mjs +1 -1
  44. package/splitter/src/state/splitter-state.d.ts +9 -0
  45. package/tree-select/index.mjs +60 -58
  46. package/tree-select/src/components/mp-tree-select.d.ts +1 -1
  47. package/tree-select/src/index.d.ts +1 -1
  48. package/tree-select/src/styles/index.d.ts +1 -1
  49. package/tree-select/src/styles/tree-select.light.styles.d.ts +2 -0
  50. package/treeview/index.mjs +3 -3
  51. package/treeview/src/components/mp-treeview.d.ts +1 -1
  52. package/treeview/src/index.d.ts +1 -1
  53. package/treeview/src/styles/index.d.ts +1 -1
  54. package/treeview/src/styles/treeview.light.styles.d.ts +2 -0
package/dock/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { html as D, unsafeCSS as E, LitElement as A } from "lit";
1
+ import { html as U, unsafeCSS as Q, LitElement as tt } from "lit";
2
2
  import "../chunks/mp-tab-page-CaCzX1ym.mjs";
3
- import "../chunks/mp-splitter-LszuRDbR.mjs";
4
- import { L as M } from "../chunks/live-announcer-Bi0orG4n.mjs";
5
- import { F as C } from "../chunks/focus-restore-DxuP1Oe2.mjs";
6
- const I = D`<div class="dock-root">
3
+ import "../chunks/mp-splitter-Ckn1kN4v.mjs";
4
+ import { L as et } from "../chunks/live-announcer-Bi0orG4n.mjs";
5
+ import { F as it } from "../chunks/focus-restore-DxuP1Oe2.mjs";
6
+ const nt = U`<div class="dock-root">
7
7
  <div class="dock-docked"></div>
8
8
  <div class="dock-floating-layer"></div>
9
9
  <div class="dock-intersections-layer dock-intersection-layer"></div>
@@ -54,7 +54,7 @@ const I = D`<div class="dock-root">
54
54
  ↓
55
55
  </button>
56
56
  <div class="dock-drop-joystick__spacer"></div>
57
- </div>`, _ = E(`:host {
57
+ </div>`, ot = Q(`:host {
58
58
  display: block;
59
59
  position: relative;
60
60
  width: 100%;
@@ -288,19 +288,6 @@ const I = D`<div class="dock-root">
288
288
  outline-offset: 1px;
289
289
  }
290
290
 
291
- .dock-snap-marker {
292
- position: absolute;
293
- width: 6px;
294
- height: 6px;
295
- margin-left: -3px;
296
- margin-top: -3px;
297
- border-radius: 50%;
298
- background: var(--bs-primary);
299
- box-shadow: 0 0 0 2px var(--bs-primary-bg-subtle);
300
- pointer-events: none;
301
- z-index: 130;
302
- }
303
-
304
291
  .dock-stack {
305
292
  flex: 1 1 0;
306
293
  border: 1px solid var(--bs-border-color);
@@ -427,21 +414,312 @@ const I = D`<div class="dock-root">
427
414
  animation: none !important;
428
415
  }
429
416
  }`);
430
- class P extends A {
417
+ function R(s, t) {
418
+ if (t.width <= 0 || t.height <= 0) return s;
419
+ const e = Math.min(s.width, t.width), i = Math.min(s.height, t.height), n = Math.min(Math.max(s.left, 0), t.width - e), o = Math.min(Math.max(s.top, 0), t.height - i);
420
+ return { left: n, top: o, width: e, height: i };
421
+ }
422
+ function j(s, t, e) {
423
+ return t >= s.left && t <= s.right && e >= s.top && e <= s.bottom;
424
+ }
425
+ function H(s, t) {
426
+ return s && typeof s.zIndex == "number" && Number.isFinite(s.zIndex) ? s.zIndex : 10 + t;
427
+ }
428
+ function x(s, t) {
429
+ if (t <= 0)
430
+ return [];
431
+ if (!Array.isArray(s) || s.length !== t)
432
+ return Array.from({ length: t }, () => 1 / t);
433
+ const e = s.map((n) => Number.isFinite(n) ? Math.max(n, 0) : 0), i = e.reduce((n, o) => n + o, 0);
434
+ return i <= 0 ? Array.from({ length: t }, () => 1 / t) : e.map((n) => n / i);
435
+ }
436
+ function rt(s) {
437
+ s.sizes = x(s.sizes, s.children.length);
438
+ }
439
+ function st(s, t, e) {
440
+ const i = e - 1, n = x(s, i), o = 1 / e, r = 1 - o, d = [];
441
+ for (let a = 0; a < e; a += 1)
442
+ if (a === t)
443
+ d.push(o);
444
+ else {
445
+ const c = a < t ? a : a - 1;
446
+ d.push(n[c] * r);
447
+ }
448
+ return d;
449
+ }
450
+ function at(s, t) {
451
+ let e = [];
452
+ if (s)
453
+ try {
454
+ const l = JSON.parse(s);
455
+ Array.isArray(l) && (e = l);
456
+ } catch {
457
+ e = [];
458
+ }
459
+ if (e.length > 0) return e;
460
+ const i = (t ?? "").split("|");
461
+ if (i.length !== 2) return [];
462
+ const [n, o] = i, r = n.lastIndexOf(":"), d = o.lastIndexOf(":");
463
+ if (r <= 0 || d <= 0) return [];
464
+ const a = Number.parseInt(n.slice(r + 1), 10), c = Number.parseInt(o.slice(d + 1), 10);
465
+ return [
466
+ {
467
+ h: { pathStr: n.slice(0, r), index: a },
468
+ v: { pathStr: o.slice(0, d), index: c }
469
+ }
470
+ ];
471
+ }
472
+ function lt(s, t) {
473
+ const e = [...s], i = (e[t] ?? 0) + (e[t + 1] ?? 0);
474
+ if (i <= 0) return e;
475
+ e[t] = i / 2, e[t + 1] = i / 2;
476
+ const n = e.reduce((o, r) => o + r, 0);
477
+ return n > 0 ? e.map((o) => o / n) : e;
478
+ }
479
+ function ct(s, t, e) {
480
+ const i = { writes: [], remember: [], clearStored: !1 };
481
+ if (s.length === 0) return i;
482
+ const n = /* @__PURE__ */ new Set();
483
+ if (s.forEach((c) => {
484
+ n.add(c.h.pathStr), n.add(c.v.pathStr);
485
+ }), [...n].some((c) => t.has(c)))
486
+ return t.forEach((c, l) => {
487
+ const h = e(l);
488
+ h && i.writes.push({ pathStr: l, sizes: x(c, h.childCount) });
489
+ }), i.clearStored = !0, i;
490
+ const r = /* @__PURE__ */ new Map(), d = (c) => {
491
+ const l = e(c);
492
+ if (!l) return null;
493
+ const h = r.get(c);
494
+ return { childCount: l.childCount, sizes: h ?? l.sizes };
495
+ }, a = /* @__PURE__ */ new Set();
496
+ return s.forEach((c) => {
497
+ [c.h.pathStr, c.v.pathStr].forEach((l) => {
498
+ if (a.has(l)) return;
499
+ a.add(l);
500
+ const h = e(l);
501
+ h && Array.isArray(h.sizes) && i.remember.push({ pathStr: l, sizes: [...h.sizes] });
502
+ }), [c.h, c.v].forEach(({ pathStr: l, index: h }) => {
503
+ const u = d(l);
504
+ if (!u) return;
505
+ const f = x(u.sizes ?? [], u.childCount), p = lt(f, h);
506
+ r.set(l, p), i.writes.push({ pathStr: l, sizes: p });
507
+ });
508
+ }), i;
509
+ }
510
+ function M(s, t) {
511
+ if (!s)
512
+ return null;
513
+ let e = s;
514
+ if (t.length === 0)
515
+ return e;
516
+ for (const i of t) {
517
+ if (!e || e.kind !== "split")
518
+ return null;
519
+ e = e.children[i] ?? null;
520
+ }
521
+ return e;
522
+ }
523
+ function X(s, t) {
524
+ if (!s || s === t || s.kind !== "split")
525
+ return null;
526
+ const e = s.children.indexOf(t);
527
+ if (e !== -1)
528
+ return { parent: s, index: e };
529
+ for (let i = 0; i < s.children.length; i += 1) {
530
+ const n = X(s.children[i], t);
531
+ if (n)
532
+ return n;
533
+ }
534
+ return null;
535
+ }
536
+ function dt(s, t, e) {
537
+ if (!s || s === t)
538
+ return e;
539
+ const i = X(s, t);
540
+ return i && (i.parent.children[i.index] = e, rt(i.parent)), s;
541
+ }
542
+ function _(s, t, e, i) {
543
+ const n = i === "left" || i === "right" ? "horizontal" : "vertical", o = i === "left" || i === "top", r = X(s, t);
544
+ if (r && r.parent.direction === n) {
545
+ const a = o ? r.index : r.index + 1;
546
+ return r.parent.children.splice(a, 0, e), r.parent.sizes = st(
547
+ r.parent.sizes,
548
+ a,
549
+ r.parent.children.length
550
+ ), s ?? e;
551
+ }
552
+ return dt(s, t, {
553
+ kind: "split",
554
+ direction: n,
555
+ children: o ? [e, t] : [t, e],
556
+ sizes: [0.5, 0.5]
557
+ });
558
+ }
559
+ function N(s, t, e = []) {
560
+ if (s) {
561
+ if (s.kind === "stack") {
562
+ t(s, e);
563
+ return;
564
+ }
565
+ s.children.forEach((i, n) => N(i, t, [...e, n]));
566
+ }
567
+ }
568
+ function E(s) {
569
+ let t = null;
570
+ return N(s, (e) => {
571
+ t || e.panes.length === 0 || (e.activePane && e.panes.includes(e.activePane) ? t = e.activePane : t = e.panes[0]);
572
+ }), t;
573
+ }
574
+ function I(s) {
575
+ const t = [];
576
+ return N(s, (e) => {
577
+ e.panes.forEach((i) => t.push(i));
578
+ }), t;
579
+ }
580
+ function ht(s, t) {
581
+ return s.panes = s.panes.filter((e) => e !== t), s.panes.includes(s.activePane ?? "") || (s.panes.length > 0 ? s.activePane = s.panes[0] : delete s.activePane), s.panes.length === 0;
582
+ }
583
+ function $(s) {
584
+ if (!s) return null;
585
+ if (s.kind === "stack")
586
+ return s.panes.length === 0 ? null : ((!s.activePane || !s.panes.includes(s.activePane)) && (s.activePane = s.panes[0]), s);
587
+ const t = x(s.sizes, s.children.length), e = s.children.map((i, n) => ({ child: $(i), slot: t[n] })).filter((i) => i.child !== null).flatMap(({ child: i, slot: n }) => {
588
+ if (i.kind === "split" && i.direction === s.direction) {
589
+ const o = x(i.sizes, i.children.length);
590
+ return i.children.map((r, d) => ({
591
+ child: r,
592
+ slot: n * o[d]
593
+ }));
594
+ }
595
+ return [{ child: i, slot: n }];
596
+ });
597
+ return e.length === 0 ? null : e.length === 1 ? e[0].child : (s.children = e.map((i) => i.child), s.sizes = x(
598
+ e.map((i) => i.slot),
599
+ e.length
600
+ ), s);
601
+ }
602
+ function F(s) {
603
+ return s ? JSON.parse(JSON.stringify(s)) : null;
604
+ }
605
+ function J(s) {
606
+ return s ? s.kind === "stack" ? s.panes.length : s.children.reduce((t, e) => t + J(e), 0) : 0;
607
+ }
608
+ function A(s, t, e) {
609
+ const i = s.type === "docked" ? t : e[s.index]?.root ?? null;
610
+ if (!i)
611
+ return null;
612
+ const n = M(i, s.segments);
613
+ return n && n.kind === "split" ? n : null;
614
+ }
615
+ function ut(s) {
616
+ const t = s.bounds ?? { left: 0, top: 0, width: 320, height: 200 };
617
+ return {
618
+ id: s.id,
619
+ bounds: {
620
+ left: Number.isFinite(t.left) ? t.left : 0,
621
+ top: Number.isFinite(t.top) ? t.top : 0,
622
+ width: Number.isFinite(t.width) ? Math.max(t.width, 160) : 320,
623
+ height: Number.isFinite(t.height) ? Math.max(t.height, 120) : 200
624
+ },
625
+ zIndex: s.zIndex,
626
+ root: s.root ? F(s.root) : null,
627
+ activePane: s.activePane
628
+ };
629
+ }
630
+ const pt = 192, gt = 128;
631
+ function W(s, t) {
632
+ return t > 0 ? Math.min(s, t) : s;
633
+ }
634
+ function Z(s, t, e, i) {
635
+ const n = W(pt, i.width), o = W(gt, i.height);
636
+ let r = s.width, d = s.height, a = s.left, c = s.top;
637
+ return t.horizontal === "right" ? (r = Math.max(n, s.width + e.x), i.width > 0 && (r = Math.min(r, i.width - s.left))) : t.horizontal === "left" && (r = Math.max(n, s.width - e.x), r = Math.min(r, s.left + s.width), a = s.left + s.width - r), t.vertical === "bottom" ? (d = Math.max(o, s.height + e.y), i.height > 0 && (d = Math.min(d, i.height - s.top))) : t.vertical === "top" && (d = Math.max(o, s.height - e.y), d = Math.min(d, s.top + s.height), c = s.top + s.height - d), { left: a, top: c, width: r, height: d };
638
+ }
639
+ const C = [1 / 3, 1 / 2, 2 / 3];
640
+ function ft(s, t) {
641
+ if (t <= 0) return s;
642
+ const e = s / t;
643
+ let i = C[0], n = Math.abs(e - i);
644
+ for (let o = 1; o < C.length; o += 1) {
645
+ const r = Math.abs(e - C[o]);
646
+ r < n && (n = r, i = C[o]);
647
+ }
648
+ return i * t;
649
+ }
650
+ function q(s, t, e) {
651
+ let i = s, n = e + 1;
652
+ for (const o of t) {
653
+ const r = Math.abs(o - s);
654
+ r < n && (n = r, i = o);
655
+ }
656
+ return n <= e ? i : s;
657
+ }
658
+ function mt(s, t, e, i, n = !1) {
659
+ const o = s + t;
660
+ let r = Math.min(Math.max(s + e, i), o - i);
661
+ return n && (r = ft(r, o)), { before: r, after: o - r };
662
+ }
663
+ function yt(s, t, e, i = 12) {
664
+ for (let n = 0; n < s.length; n += 1) {
665
+ const r = (e !== null ? s[n] >= e : !1) ? s[n] + i : s[n];
666
+ if (t < r)
667
+ return n;
668
+ }
669
+ return s.length;
670
+ }
671
+ function w(s) {
672
+ if (s.type === "floating") {
673
+ const e = s.segments.length > 0 ? `/${s.segments.map((i) => i.toString()).join("/")}` : "";
674
+ return `f:${s.index}${e}`;
675
+ }
676
+ const t = s.segments.join("/");
677
+ return t.length > 0 ? `d:${t}` : "d:";
678
+ }
679
+ function S(s) {
680
+ if (s == null)
681
+ return null;
682
+ if (s.startsWith("f:")) {
683
+ const i = s.slice(2), [n, ...o] = i.split("/"), r = Number.parseInt(n, 10);
684
+ if (!Number.isFinite(r))
685
+ return null;
686
+ const d = o.filter((a) => a.length > 0).map((a) => Number.parseInt(a, 10)).filter((a) => Number.isFinite(a));
687
+ return { type: "floating", index: r, segments: d };
688
+ }
689
+ const t = s.startsWith("d:") ? s.slice(2) : s;
690
+ return t.length === 0 ? { type: "docked", segments: [] } : { type: "docked", segments: t.split("/").filter((i) => i.length > 0).map((i) => Number.parseInt(i, 10)).filter((i) => Number.isFinite(i)) };
691
+ }
692
+ function B(s, t) {
693
+ if (s.type !== t.type)
694
+ return !1;
695
+ if (s.type === "floating") {
696
+ const i = t;
697
+ return s.index !== i.index || s.segments.length !== i.segments.length ? !1 : s.segments.every((n, o) => n === i.segments[o]);
698
+ }
699
+ const e = t;
700
+ return s.segments.length !== e.segments.length ? !1 : s.segments.every((i, n) => i === e.segments[n]);
701
+ }
702
+ function T(s) {
703
+ return s.type === "floating" ? { type: "floating", index: s.index, segments: [...s.segments] } : { type: "docked", segments: [...s.segments] };
704
+ }
705
+ function bt(s, t) {
706
+ return s.type !== t.type || s.type === "floating" && t.index !== s.index || s.segments.length > t.segments.length ? !1 : s.segments.every((e, i) => e === t.segments[i]);
707
+ }
708
+ class L extends tt {
431
709
  constructor() {
432
- super(), this.liveAnnouncer = new M(this), this.paneMoveMode = null, this.paneMoveCandidateIndex = null, this.dropJoystickTarget = null, this.rootLayout = null, this.floatingLayouts = [], this.titles = {}, this.pendingTabDragMetrics = null, this.dragState = null, this.floatingDragState = null, this.floatingResizeState = null, this.intersectionRaf = null, this.rootResizeObserver = null, this.dockedMutationObserver = null, this.cornerResizeState = null, this.pointerTrackingActive = !1, this.dragPointerTrackingActive = !1, this.lastDragPointerPosition = null, this.cornerSnapXTargets = [], this.cornerSnapYTargets = [], this.showSnapMarkers = !1, this.debugLayoutIntegrity = !1, this.pendingDragEndTimeout = null, this.previousSplitSizes = /* @__PURE__ */ new Map(), this.layoutFocusRestore = new C(() => this.shadowRoot, {
710
+ super(), this.liveAnnouncer = new et(this), this.paneMoveMode = null, this.paneMoveCandidateIndex = null, this.dropJoystickTarget = null, this.rootLayout = null, this.floatingLayouts = [], this.titles = {}, this.pendingTabDragMetrics = null, this.dragState = null, this.floatingDragState = null, this.floatingResizeState = null, this.intersectionRaf = null, this.rootResizeObserver = null, this.dockedMutationObserver = null, this.cornerResizeState = null, this.pointerTrackingActive = !1, this.dragPointerTrackingActive = !1, this.lastDragPointerPosition = null, this.cornerSnapXTargets = [], this.cornerSnapYTargets = [], this.debugLayoutIntegrity = !1, this.pendingDragEndTimeout = null, this.previousSplitSizes = /* @__PURE__ */ new Map(), this.layoutFocusRestore = new it(() => this.shadowRoot, {
433
711
  selector: ".dock-intersection-handle[data-key], mp-tab-control, .dock-tab[data-tab-id]",
434
712
  keyOf: (t) => t.dataset.key ?? t.dataset.tabId ?? (t.id || null)
435
- }), this.instanceId = `mint-dock-${++P.instanceCounter}`, this.windowRef = typeof window < "u" ? window : null, this.onPointerMove = this.onPointerMove.bind(this), this.onPointerUp = this.onPointerUp.bind(this), this.onPointerCancel = this.onPointerCancel.bind(this), this.onDragPointerMove = this.onDragPointerMove.bind(this), this.onDragPointerUp = this.onDragPointerUp.bind(this), this.onDragPointerCancel = this.onDragPointerCancel.bind(this), this.onSplitterResize = this.onSplitterResize.bind(this);
713
+ }), this.instanceId = `mint-dock-${++L.instanceCounter}`, this.windowRef = typeof window < "u" ? window : null, this.onPointerMove = this.onPointerMove.bind(this), this.onPointerUp = this.onPointerUp.bind(this), this.onPointerCancel = this.onPointerCancel.bind(this), this.onDragPointerMove = this.onDragPointerMove.bind(this), this.onDragPointerUp = this.onDragPointerUp.bind(this), this.onDragPointerCancel = this.onDragPointerCancel.bind(this), this.onSplitterResize = this.onSplitterResize.bind(this);
436
714
  }
437
715
  static {
438
- this.styles = [_];
716
+ this.styles = [ot];
439
717
  }
440
718
  static {
441
719
  this.documentRef = typeof document < "u" ? document : null;
442
720
  }
443
721
  static configureDocument(t) {
444
- t && (P.documentRef = t);
722
+ t && (L.documentRef = t);
445
723
  }
446
724
  static get observedAttributes() {
447
725
  return [...super.observedAttributes ?? [], "layout", "debug-layout-integrity"];
@@ -461,36 +739,8 @@ class P extends A {
461
739
  static {
462
740
  this.PANE_MOVE_ZONE_ORDER = ["top", "right", "bottom", "left"];
463
741
  }
464
- renderSnapMarkersForCorner() {
465
- if (!this.showSnapMarkers) return;
466
- const t = this.shadowRoot?.querySelector(".dock-intersections-layer, .dock-intersection-layer");
467
- if (!t || (Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((r) => r.remove()), !this.cornerResizeState)) return;
468
- const e = this.rootEl.getBoundingClientRect();
469
- let i = null, o = null;
470
- const n = this.cornerResizeState;
471
- if (n.vs.length > 0) {
472
- const r = n.vs[0], l = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
473
- l && (i = l.left + l.width / 2 - e.left);
474
- }
475
- if (n.hs.length > 0) {
476
- const r = n.hs[0], l = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
477
- l && (o = l.top + l.height / 2 - e.top);
478
- }
479
- o != null && this.cornerSnapXTargets.forEach((r) => {
480
- const c = this.documentRef.createElement("div");
481
- c.className = "dock-snap-marker", c.style.left = `${r}px`, c.style.top = `${o}px`, t.appendChild(c);
482
- }), i != null && this.cornerSnapYTargets.forEach((r) => {
483
- const c = this.documentRef.createElement("div");
484
- c.className = "dock-snap-marker", c.style.left = `${i}px`, c.style.top = `${r}px`, t.appendChild(c);
485
- });
486
- }
487
- clearSnapMarkers() {
488
- if (!this.showSnapMarkers) return;
489
- const t = this.shadowRoot?.querySelector(".dock-intersections-layer, .dock-intersection-layer");
490
- t && Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((e) => e.remove());
491
- }
492
742
  render() {
493
- return D`${I}${this.liveAnnouncer.template()}`;
743
+ return U`${nt}${this.liveAnnouncer.template()}`;
494
744
  }
495
745
  firstUpdated() {
496
746
  const t = this.resolveDocument();
@@ -498,24 +748,24 @@ class P extends A {
498
748
  const e = this.shadowRoot, i = e.querySelector(".dock-root");
499
749
  if (!i)
500
750
  throw new Error("mint-dock-manager template is missing the root element.");
501
- const o = e.querySelector(".dock-docked");
502
- if (!o)
503
- throw new Error("mint-dock-manager template is missing the docked surface element.");
504
- const n = e.querySelector(".dock-floating-layer");
751
+ const n = e.querySelector(".dock-docked");
505
752
  if (!n)
753
+ throw new Error("mint-dock-manager template is missing the docked surface element.");
754
+ const o = e.querySelector(".dock-floating-layer");
755
+ if (!o)
506
756
  throw new Error("mint-dock-manager template is missing the floating layer element.");
507
757
  const r = e.querySelector(".dock-drop-indicator");
508
758
  if (!r)
509
759
  throw new Error("mint-dock-manager template is missing the drop indicator element.");
510
- const c = e.querySelector(".dock-drop-joystick");
511
- if (!c)
760
+ const d = e.querySelector(".dock-drop-joystick");
761
+ if (!d)
512
762
  throw new Error("mint-dock-manager template is missing the drop joystick element.");
513
- const l = Array.from(
514
- c.querySelectorAll(".dock-drop-joystick__button[data-zone]")
763
+ const a = Array.from(
764
+ d.querySelectorAll(".dock-drop-joystick__button[data-zone]")
515
765
  );
516
- if (l.length === 0)
766
+ if (a.length === 0)
517
767
  throw new Error("mint-dock-manager template is missing drop joystick buttons.");
518
- this.rootEl = i, this.dockedEl = o, this.floatingLayerEl = n, this.dropIndicator = r, this.dropJoystick = c, this.dropJoystickButtons = l, this.dockedEl.dataset.path = this.formatPath({ type: "docked", segments: [] }), i.addEventListener("keydown", (s) => this.onRootKeyDown(s), { capture: !0 }), i.addEventListener("focusout", (s) => this.onRootFocusOut(s)), this.renderLayout(), this.rootResizeObserver = new ResizeObserver(() => {
768
+ this.rootEl = i, this.dockedEl = n, this.floatingLayerEl = o, this.dropIndicator = r, this.dropJoystick = d, this.dropJoystickButtons = a, this.dockedEl.dataset.path = w({ type: "docked", segments: [] }), i.addEventListener("keydown", (c) => this.onRootKeyDown(c), { capture: !0 }), i.addEventListener("focusout", (c) => this.onRootFocusOut(c)), this.renderLayout(), this.rootResizeObserver = new ResizeObserver(() => {
519
769
  this.scheduleRenderIntersectionHandles(), this.updateFloatingPanePositions();
520
770
  }), this.rootResizeObserver.observe(this.rootEl), this.dockedMutationObserver = new MutationObserver(() => this.scheduleRenderIntersectionHandles()), this.dockedMutationObserver.observe(this.dockedEl, { childList: !0, subtree: !0 }), this.dockedEl.addEventListener("resizing", this.onSplitterResize), this.dockedEl.addEventListener("resize-end", this.onSplitterResize);
521
771
  }
@@ -527,11 +777,11 @@ class P extends A {
527
777
  this.stopDragPointerTracking(), t?.removeEventListener("pointermove", this.onPointerMove), t?.removeEventListener("pointerup", this.onPointerUp), t?.removeEventListener("pointercancel", this.onPointerCancel), this.pointerTrackingActive = !1, this.rootResizeObserver?.disconnect(), this.rootResizeObserver = null, this.dockedMutationObserver?.disconnect(), this.dockedMutationObserver = null, this.dockedEl?.removeEventListener("resizing", this.onSplitterResize), this.dockedEl?.removeEventListener("resize-end", this.onSplitterResize), this.intersectionRaf !== null && (this.windowRef?.clearTimeout(this.intersectionRaf), this.intersectionRaf = null), super.disconnectedCallback();
528
778
  }
529
779
  attributeChangedCallback(t, e, i) {
530
- super.attributeChangedCallback(t, e, i), t === "layout" ? this.layout = i ? this.parseLayout(i) : null : t === "debug-snap-markers" ? (this.showSnapMarkers = !(i === null || i === "false" || i === "0"), this.showSnapMarkers || this.clearSnapMarkers()) : t === "debug-layout-integrity" && (this.debugLayoutIntegrity = !(i === null || i === "false" || i === "0"));
780
+ super.attributeChangedCallback(t, e, i), t === "layout" ? this.layout = i ? this.parseLayout(i) : null : t === "debug-layout-integrity" && (this.debugLayoutIntegrity = !(i === null || i === "false" || i === "0"));
531
781
  }
532
782
  get layout() {
533
783
  return {
534
- root: this.cloneLayoutNode(this.rootLayout),
784
+ root: F(this.rootLayout),
535
785
  floating: this.cloneFloatingArray(this.floatingLayouts),
536
786
  titles: { ...this.titles }
537
787
  };
@@ -543,8 +793,8 @@ class P extends A {
543
793
  root: this.rootLayout,
544
794
  floating: this.floatingLayouts,
545
795
  titles: this.titles
546
- }), o = JSON.stringify(e);
547
- i !== o && (this.rootLayout = this.cloneLayoutNode(e.root), this.floatingLayouts = this.cloneFloatingArray(e.floating), this.titles = e.titles ? { ...e.titles } : {}, this.normalizeAllLayouts(), this.renderLayout());
796
+ }), n = JSON.stringify(e);
797
+ i !== n && (this.rootLayout = F(e.root), this.floatingLayouts = this.cloneFloatingArray(e.floating), this.titles = e.titles ? { ...e.titles } : {}, this.normalizeAllLayouts(), this.renderLayout());
548
798
  }
549
799
  /**
550
800
  * True while the user is actively interacting with the dock — pane drag,
@@ -562,10 +812,10 @@ class P extends A {
562
812
  return this.snapshot;
563
813
  }
564
814
  resolveDocument() {
565
- const t = P.documentRef, e = this.ownerDocument ?? null, o = t ?? e ?? (typeof document < "u" ? document : null);
566
- if (!o)
815
+ const t = L.documentRef, e = this.ownerDocument ?? null, n = t ?? e ?? (typeof document < "u" ? document : null);
816
+ if (!n)
567
817
  throw new Error("mint-dock-manager requires a Document to initialize.");
568
- return P.documentRef || (P.documentRef = o), o;
818
+ return L.documentRef || (L.documentRef = n), n;
569
819
  }
570
820
  resolveWindow(t) {
571
821
  return typeof window < "u" ? window : t.defaultView ?? null;
@@ -586,7 +836,7 @@ class P extends A {
586
836
  const e = t;
587
837
  return {
588
838
  root: e.root ?? null,
589
- floating: Array.isArray(e.floating) ? e.floating.map((i) => this.normalizeFloatingLayout(i)) : [],
839
+ floating: Array.isArray(e.floating) ? e.floating.map((i) => ut(i)) : [],
590
840
  titles: e.titles ? { ...e.titles } : {}
591
841
  };
592
842
  }
@@ -606,40 +856,40 @@ class P extends A {
606
856
  this.floatingLayerEl.innerHTML = "";
607
857
  const t = this.getHostSize();
608
858
  this.floatingLayouts.forEach((e, i) => {
609
- const o = this.documentRef.createElement("div");
610
- o.classList.add("dock-floating"), o.dataset.path = this.formatPath({
859
+ const n = this.documentRef.createElement("div");
860
+ n.classList.add("dock-floating"), n.dataset.path = w({
611
861
  type: "floating",
612
862
  index: i,
613
863
  segments: []
614
864
  });
615
- const n = this.getFloatingWindowTitle(e), r = `${this.instanceId}-floating-${i}-title`;
616
- o.setAttribute("role", "dialog"), o.setAttribute("aria-labelledby", r), o.setAttribute("aria-modal", "false");
617
- const { left: c, top: l, width: s, height: a } = this.clampBoundsToHost(e.bounds, t);
618
- o.style.left = `${c}px`, o.style.top = `${l}px`, o.style.width = `${s}px`, o.style.height = `${a}px`, o.style.minWidth = "0", o.style.minHeight = "0";
619
- const p = this.getFloatingPaneZIndex(i);
620
- o.style.zIndex = String(p);
621
- const h = this.documentRef.createElement("div");
622
- h.classList.add("dock-floating__chrome"), h.addEventListener(
865
+ const o = this.getFloatingWindowTitle(e), r = `${this.instanceId}-floating-${i}-title`;
866
+ n.setAttribute("role", "dialog"), n.setAttribute("aria-labelledby", r), n.setAttribute("aria-modal", "false");
867
+ const { left: d, top: a, width: c, height: l } = R(e.bounds, t);
868
+ n.style.left = `${d}px`, n.style.top = `${a}px`, n.style.width = `${c}px`, n.style.height = `${l}px`, n.style.minWidth = "0", n.style.minHeight = "0";
869
+ const h = H(this.floatingLayouts[i], i);
870
+ n.style.zIndex = String(h);
871
+ const u = this.documentRef.createElement("div");
872
+ u.classList.add("dock-floating__chrome"), u.addEventListener(
623
873
  "pointerdown",
624
- (u) => this.beginFloatingDrag(u, i, o, h)
874
+ (g) => this.beginFloatingDrag(g, i, n, u)
625
875
  );
626
- const d = this.documentRef.createElement("div");
627
- d.classList.add("dock-floating__title"), d.id = r, d.textContent = n, h.appendChild(d);
628
- const g = this.documentRef.createElement("button");
629
- if (g.type = "button", g.classList.add("dock-floating__close"), g.setAttribute("aria-label", `Close pane: ${n}`), g.textContent = "×", g.addEventListener("click", (u) => {
630
- u.stopPropagation(), this.closeFloatingPane(i);
631
- }), g.addEventListener("pointerdown", (u) => u.stopPropagation()), h.appendChild(g), o.appendChild(h), e.root) {
632
- const u = this.renderNode(e.root, [], i);
633
- u.classList.add("dock-floating__stack"), o.appendChild(u);
876
+ const f = this.documentRef.createElement("div");
877
+ f.classList.add("dock-floating__title"), f.id = r, f.textContent = o, u.appendChild(f);
878
+ const p = this.documentRef.createElement("button");
879
+ if (p.type = "button", p.classList.add("dock-floating__close"), p.setAttribute("aria-label", `Close pane: ${o}`), p.textContent = "×", p.addEventListener("click", (g) => {
880
+ g.stopPropagation(), this.closeFloatingPane(i);
881
+ }), p.addEventListener("pointerdown", (g) => g.stopPropagation()), u.appendChild(p), n.appendChild(u), e.root) {
882
+ const g = this.renderNode(e.root, [], i);
883
+ g.classList.add("dock-floating__stack"), n.appendChild(g);
634
884
  } else {
635
- const u = this.documentRef.createElement("div");
636
- u.classList.add("dock-stack"), u.dataset.path = this.formatPath({
885
+ const g = this.documentRef.createElement("div");
886
+ g.classList.add("dock-stack"), g.dataset.path = w({
637
887
  type: "floating",
638
888
  index: i,
639
889
  segments: []
640
890
  });
641
- const m = this.documentRef.createElement("div");
642
- m.classList.add("dock-stack__pane"), m.textContent = "No panes configured", u.appendChild(m), o.appendChild(u);
891
+ const y = this.documentRef.createElement("div");
892
+ y.classList.add("dock-stack__pane"), y.textContent = "No panes configured", g.appendChild(y), n.appendChild(g);
643
893
  }
644
894
  [
645
895
  {
@@ -674,23 +924,23 @@ class P extends A {
674
924
  classes: ["dock-floating__resizer", "dock-floating__resizer--left"],
675
925
  edges: { horizontal: "left", vertical: "none" }
676
926
  }
677
- ].forEach(({ classes: u, edges: m }) => {
678
- const y = this.documentRef.createElement("div");
679
- y.classList.add(...u), y.setAttribute("role", "separator");
680
- const b = m.horizontal === "none" && m.vertical !== "none", z = m.vertical === "none" && m.horizontal !== "none";
681
- b ? y.setAttribute("aria-orientation", "horizontal") : z && y.setAttribute("aria-orientation", "vertical");
682
- const S = [];
683
- m.vertical === "top" ? S.push("top") : m.vertical === "bottom" && S.push("bottom"), m.horizontal === "left" ? S.push("left") : m.horizontal === "right" && S.push("right"), y.setAttribute(
927
+ ].forEach(({ classes: g, edges: y }) => {
928
+ const b = this.documentRef.createElement("div");
929
+ b.classList.add(...g), b.setAttribute("role", "separator");
930
+ const k = y.horizontal === "none" && y.vertical !== "none", D = y.vertical === "none" && y.horizontal !== "none";
931
+ k ? b.setAttribute("aria-orientation", "horizontal") : D && b.setAttribute("aria-orientation", "vertical");
932
+ const P = [];
933
+ y.vertical === "top" ? P.push("top") : y.vertical === "bottom" && P.push("bottom"), y.horizontal === "left" ? P.push("left") : y.horizontal === "right" && P.push("right"), b.setAttribute(
684
934
  "aria-label",
685
- `Resize pane ${S.length === 2 ? "corner " : "edge "}${S.join("-")}`
686
- ), y.addEventListener(
935
+ `Resize pane ${P.length === 2 ? "corner " : "edge "}${P.join("-")}`
936
+ ), b.addEventListener(
687
937
  "pointerdown",
688
- (v) => this.beginFloatingResize(v, i, o, y, m)
689
- ), y.setAttribute("tabindex", "0"), y.setAttribute("aria-valuemin", "0"), y.setAttribute("aria-valuemax", "100"), this.syncFloatingResizerValue(y, i, m), y.addEventListener(
938
+ (z) => this.beginFloatingResize(z, i, n, b, y)
939
+ ), b.setAttribute("tabindex", "0"), b.setAttribute("aria-valuemin", "0"), b.setAttribute("aria-valuemax", "100"), this.syncFloatingResizerValue(b, i, y), b.addEventListener(
690
940
  "keydown",
691
- (v) => this.onFloatingResizeKeydown(v, i, o, y, m)
692
- ), o.appendChild(y);
693
- }), this.floatingLayerEl.appendChild(o);
941
+ (z) => this.onFloatingResizeKeydown(z, i, n, b, y)
942
+ ), n.appendChild(b);
943
+ }), this.floatingLayerEl.appendChild(n);
694
944
  });
695
945
  }
696
946
  onSplitterResize() {
@@ -708,45 +958,45 @@ class P extends A {
708
958
  if (!t) return;
709
959
  const e = this.rootEl.getBoundingClientRect();
710
960
  if (this.cornerResizeState) {
711
- const l = this.cornerResizeState, s = l.hs[0], a = l.vs[0], p = this.findSplitterByPath(s.path.segments), h = this.findSplitterByPath(a.path.segments), d = p ? this.getSplitterDividers(p)[s.index] : null, g = h ? this.getSplitterDividers(h)[a.index] : null;
712
- if (d && g) {
713
- const f = d.getBoundingClientRect(), u = g.getBoundingClientRect(), m = u.left + u.width / 2 - e.left, y = f.top + f.height / 2 - e.top;
714
- l.handle.style.left = `${m}px`, l.handle.style.top = `${y}px`, Array.from(t.querySelectorAll(".dock-intersection-handle")).forEach((b) => {
715
- b !== l.handle && b.remove();
961
+ const a = this.cornerResizeState, c = a.hs[0], l = a.vs[0], h = this.findSplitterByPath(c.path.segments), u = this.findSplitterByPath(l.path.segments), f = h ? this.getSplitterDividers(h)[c.index] : null, p = u ? this.getSplitterDividers(u)[l.index] : null;
962
+ if (f && p) {
963
+ const m = f.getBoundingClientRect(), g = p.getBoundingClientRect(), y = g.left + g.width / 2 - e.left, b = m.top + m.height / 2 - e.top;
964
+ a.handle.style.left = `${y}px`, a.handle.style.top = `${b}px`, Array.from(t.querySelectorAll(".dock-intersection-handle")).forEach((k) => {
965
+ k !== a.handle && k.remove();
716
966
  });
717
967
  }
718
968
  return;
719
969
  }
720
970
  t.replaceChildren();
721
- const i = [], o = [];
971
+ const i = [], n = [];
722
972
  Array.from(
723
973
  this.shadowRoot?.querySelectorAll(".dock-split") ?? []
724
- ).forEach((l) => {
725
- const s = l.dataset.direction, a = l.dataset.path ?? "", p = this.splitterLayerKey(l);
726
- this.getSplitterDividers(l).forEach((h, d) => {
727
- const g = { rect: h.getBoundingClientRect(), pathStr: a, index: d, layerKey: p };
728
- s === "horizontal" ? o.push(g) : s === "vertical" && i.push(g);
974
+ ).forEach((a) => {
975
+ const c = a.dataset.direction, l = a.dataset.path ?? "", h = this.splitterLayerKey(a);
976
+ this.getSplitterDividers(a).forEach((u, f) => {
977
+ const p = { rect: u.getBoundingClientRect(), pathStr: l, index: f, layerKey: h };
978
+ c === "horizontal" ? n.push(p) : c === "vertical" && i.push(p);
729
979
  });
730
980
  });
731
- const r = 24, c = /* @__PURE__ */ new Map();
732
- i.forEach((l) => {
733
- const s = l.rect.top + l.rect.height / 2;
734
- o.forEach((a) => {
735
- if (l.layerKey !== a.layerKey) return;
736
- const p = a.rect.left + a.rect.width / 2, h = p < l.rect.left ? l.rect.left - p : p > l.rect.right ? p - l.rect.right : 0, d = s < a.rect.top ? a.rect.top - s : s > a.rect.bottom ? s - a.rect.bottom : 0;
737
- if (h > r || d > r) return;
738
- const g = p - e.left, f = s - e.top, u = `${Math.round(g)}:${Math.round(f)}`, m = c.get(u) ?? { x: g, y: f, pairs: [] };
739
- m.pairs.push({ h: { pathStr: l.pathStr, index: l.index }, v: { pathStr: a.pathStr, index: a.index } }), c.set(u, m);
981
+ const r = 24, d = /* @__PURE__ */ new Map();
982
+ i.forEach((a) => {
983
+ const c = a.rect.top + a.rect.height / 2;
984
+ n.forEach((l) => {
985
+ if (a.layerKey !== l.layerKey) return;
986
+ const h = l.rect.left + l.rect.width / 2, u = h < a.rect.left ? a.rect.left - h : h > a.rect.right ? h - a.rect.right : 0, f = c < l.rect.top ? l.rect.top - c : c > l.rect.bottom ? c - l.rect.bottom : 0;
987
+ if (u > r || f > r) return;
988
+ const p = h - e.left, m = c - e.top, g = `${Math.round(p)}:${Math.round(m)}`, y = d.get(g) ?? { x: p, y: m, pairs: [] };
989
+ y.pairs.push({ h: { pathStr: a.pathStr, index: a.index }, v: { pathStr: l.pathStr, index: l.index } }), d.set(g, y);
740
990
  });
741
- }), c.forEach((l, s) => {
742
- const a = this.documentRef.createElement("div");
743
- a.classList.add("dock-intersection-handle", "glyph"), a.setAttribute("role", "separator"), a.setAttribute("aria-label", "Resize split intersection");
744
- const p = e.width > 0 ? Math.round(l.x / e.width * 100) : 0;
745
- a.setAttribute("aria-valuemin", "0"), a.setAttribute("aria-valuemax", "100"), a.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, p)))), a.setAttribute("tabindex", "0");
746
- const h = l.pairs[0], d = `${h.h.pathStr}:${h.h.index}|${h.v.pathStr}:${h.v.index}`;
747
- a.dataset.key = d, a.dataset.pairs = JSON.stringify(l.pairs), a.style.left = `${l.x}px`, a.style.top = `${l.y}px`;
748
- const g = { path: this.parsePath(h.h.pathStr), index: h.h.index, container: this.findSplitterByPath(this.parsePath(h.h.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() }, f = { path: this.parsePath(h.v.pathStr), index: h.v.index, container: this.findSplitterByPath(this.parsePath(h.v.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() };
749
- a.addEventListener("pointerdown", (u) => this.beginCornerResize(u, g, f, a)), a.addEventListener("dblclick", (u) => this.onIntersectionDoubleClick(u, a)), a.addEventListener("keydown", (u) => this.onIntersectionKeyDown(u, a)), t.appendChild(a);
991
+ }), d.forEach((a, c) => {
992
+ const l = this.documentRef.createElement("div");
993
+ l.classList.add("dock-intersection-handle", "glyph"), l.setAttribute("role", "separator"), l.setAttribute("aria-label", "Resize split intersection");
994
+ const h = e.width > 0 ? Math.round(a.x / e.width * 100) : 0;
995
+ l.setAttribute("aria-valuemin", "0"), l.setAttribute("aria-valuemax", "100"), l.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, h)))), l.setAttribute("tabindex", "0");
996
+ const u = a.pairs[0], f = `${u.h.pathStr}:${u.h.index}|${u.v.pathStr}:${u.v.index}`;
997
+ l.dataset.key = f, l.dataset.pairs = JSON.stringify(a.pairs), l.style.left = `${a.x}px`, l.style.top = `${a.y}px`;
998
+ const p = { path: S(u.h.pathStr), index: u.h.index, container: this.findSplitterByPath(S(u.h.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() }, m = { path: S(u.v.pathStr), index: u.v.index, container: this.findSplitterByPath(S(u.v.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() };
999
+ l.addEventListener("pointerdown", (g) => this.beginCornerResize(g, p, m, l)), l.addEventListener("dblclick", (g) => this.onIntersectionDoubleClick(g, l)), l.addEventListener("keydown", (g) => this.onIntersectionKeyDown(g, l)), t.appendChild(l);
750
1000
  });
751
1001
  }
752
1002
  /**
@@ -761,67 +1011,67 @@ class P extends A {
761
1011
  * pair drives — same precedence as the pointer drag path.
762
1012
  */
763
1013
  onIntersectionKeyDown(t, e) {
764
- const i = t.key === "ArrowLeft" || t.key === "ArrowRight", o = t.key === "ArrowUp" || t.key === "ArrowDown", n = t.key === "Home" || t.key === "End";
765
- if (!i && !o && !n) return;
1014
+ const i = t.key === "ArrowLeft" || t.key === "ArrowRight", n = t.key === "ArrowUp" || t.key === "ArrowDown", o = t.key === "Home" || t.key === "End";
1015
+ if (!i && !n && !o) return;
766
1016
  const r = e.dataset.pairs;
767
1017
  if (!r) return;
768
- let c;
1018
+ let d;
769
1019
  try {
770
- c = JSON.parse(r);
1020
+ d = JSON.parse(r);
771
1021
  } catch {
772
1022
  return;
773
1023
  }
774
- if (c.length === 0) return;
1024
+ if (d.length === 0) return;
775
1025
  t.preventDefault();
776
- const l = t.shiftKey, a = i || n ? c[0].v : c[0].h, p = this.parsePath(a.pathStr);
777
- this.findSplitterByPath(p?.segments ?? [])?.resizeDividerBy?.(a.index, t.key, l);
1026
+ const a = t.shiftKey, l = i || o ? d[0].v : d[0].h, h = S(l.pathStr);
1027
+ this.findSplitterByPath(h?.segments ?? [])?.resizeDividerBy?.(l.index, t.key, a);
778
1028
  }
779
- beginCornerResize(t, e, i, o) {
1029
+ beginCornerResize(t, e, i, n) {
780
1030
  t.preventDefault();
781
- const n = o.dataset.pairs, r = n ? JSON.parse(n) : [], c = [], l = [], s = (a, p, h) => {
782
- const d = this.parsePath(a);
783
- if (!d) return;
784
- const g = this.findSplitterByPath(d.segments);
785
- if (!g) return;
786
- const f = this.getSplitterPanels(g);
787
- if (f.length === 0) return;
788
- const u = h === "h" ? "height" : "width", m = f.map((b) => b.getBoundingClientRect()[u]), y = { path: d, index: p, container: g, initialSizes: m, before: m[p], after: m[p + 1] };
789
- h === "h" ? c.push(y) : l.push(y);
1031
+ const o = n.dataset.pairs, r = o ? JSON.parse(o) : [], d = [], a = [], c = (l, h, u) => {
1032
+ const f = S(l);
1033
+ if (!f) return;
1034
+ const p = this.findSplitterByPath(f.segments);
1035
+ if (!p) return;
1036
+ const m = this.getSplitterPanels(p);
1037
+ if (m.length === 0) return;
1038
+ const g = u === "h" ? "height" : "width", y = m.map((k) => k.getBoundingClientRect()[g]), b = { path: f, index: h, container: p, initialSizes: y, before: y[h], after: y[h + 1] };
1039
+ u === "h" ? d.push(b) : a.push(b);
790
1040
  };
791
- if (r.length > 0 ? r.forEach((a) => {
792
- s(a.h.pathStr, a.h.index, "h"), s(a.v.pathStr, a.v.index, "v");
793
- }) : e.path && i.path && (s(this.formatPath(e.path), e.index, "h"), s(this.formatPath(i.path), i.index, "v")), !(c.length === 0 && l.length === 0)) {
1041
+ if (r.length > 0 ? r.forEach((l) => {
1042
+ c(l.h.pathStr, l.h.index, "h"), c(l.v.pathStr, l.v.index, "v");
1043
+ }) : e.path && i.path && (c(w(e.path), e.index, "h"), c(w(i.path), i.index, "v")), !(d.length === 0 && a.length === 0)) {
794
1044
  try {
795
- o.setPointerCapture(t.pointerId), o.dataset.resizing = "true", o.classList.add("hovering");
1045
+ n.setPointerCapture(t.pointerId), n.dataset.resizing = "true", n.classList.add("hovering");
796
1046
  } catch {
797
1047
  }
798
1048
  this.cornerResizeState = {
799
1049
  pointerId: t.pointerId,
800
- handle: o,
801
- hs: c.map((a) => ({ path: this.clonePath(a.path), index: a.index, container: a.container, beforeSize: a.before, afterSize: a.after, initialSizes: a.initialSizes, startY: t.clientY })),
802
- vs: l.map((a) => ({ path: this.clonePath(a.path), index: a.index, container: a.container, beforeSize: a.before, afterSize: a.after, initialSizes: a.initialSizes, startX: t.clientX }))
803
- }, this.startPointerTracking(), o.dataset.key || (o.dataset.key = o.dataset.group ?? ""), this.renderSnapMarkersForCorner();
1050
+ handle: n,
1051
+ hs: d.map((l) => ({ path: T(l.path), index: l.index, container: l.container, beforeSize: l.before, afterSize: l.after, initialSizes: l.initialSizes, startY: t.clientY })),
1052
+ vs: a.map((l) => ({ path: T(l.path), index: l.index, container: l.container, beforeSize: l.before, afterSize: l.after, initialSizes: l.initialSizes, startX: t.clientX }))
1053
+ }, this.startPointerTracking(), n.dataset.key || (n.dataset.key = n.dataset.group ?? "");
804
1054
  try {
805
- const a = this.rootEl.getBoundingClientRect();
806
- let p = null, h = null;
807
- if (l.length > 0) {
808
- const u = l[0], y = this.getSplitterDividers(u.container)[u.index]?.getBoundingClientRect();
809
- y && (p = y.left + y.width / 2);
1055
+ const l = this.rootEl.getBoundingClientRect();
1056
+ let h = null, u = null;
1057
+ if (a.length > 0) {
1058
+ const g = a[0], b = this.getSplitterDividers(g.container)[g.index]?.getBoundingClientRect();
1059
+ b && (h = b.left + b.width / 2);
810
1060
  }
811
- if (c.length > 0) {
812
- const u = c[0], y = this.getSplitterDividers(u.container)[u.index]?.getBoundingClientRect();
813
- y && (h = y.top + y.height / 2);
1061
+ if (d.length > 0) {
1062
+ const g = d[0], b = this.getSplitterDividers(g.container)[g.index]?.getBoundingClientRect();
1063
+ b && (u = b.top + b.height / 2);
814
1064
  }
815
- const d = [], g = [];
1065
+ const f = [], p = [];
816
1066
  Array.from(
817
1067
  this.shadowRoot?.querySelectorAll(".dock-split") ?? []
818
- ).forEach((u) => {
819
- const m = u.dataset.direction ?? void 0;
820
- this.getSplitterDividers(u).forEach((y) => {
821
- const b = y.getBoundingClientRect();
822
- m === "horizontal" && h != null ? h >= b.top && h <= b.bottom && d.push(b.left + b.width / 2 - a.left) : m === "vertical" && p != null && p >= b.left && p <= b.right && g.push(b.top + b.height / 2 - a.top);
1068
+ ).forEach((g) => {
1069
+ const y = g.dataset.direction ?? void 0;
1070
+ this.getSplitterDividers(g).forEach((b) => {
1071
+ const k = b.getBoundingClientRect();
1072
+ y === "horizontal" && u != null ? u >= k.top && u <= k.bottom && f.push(k.left + k.width / 2 - l.left) : y === "vertical" && h != null && h >= k.left && h <= k.right && p.push(k.top + k.height / 2 - l.top);
823
1073
  });
824
- }), this.cornerSnapXTargets = d, this.cornerSnapYTargets = g;
1074
+ }), this.cornerSnapXTargets = f, this.cornerSnapYTargets = p;
825
1075
  } catch {
826
1076
  this.cornerSnapXTargets = [], this.cornerSnapYTargets = [];
827
1077
  }
@@ -830,43 +1080,29 @@ class P extends A {
830
1080
  handleCornerResizeMove(t) {
831
1081
  const e = this.cornerResizeState;
832
1082
  if (!e || e.pointerId !== t.pointerId) return;
833
- const i = (s, a, p) => {
834
- if (!p || a <= 0) return s;
835
- const h = [1 / 3, 1 / 2, 2 / 3], d = s / a;
836
- let g = h[0], f = Math.abs(d - g);
837
- for (let u = 1; u < h.length; u++) {
838
- const m = Math.abs(d - h[u]);
839
- m < f && (f = m, g = h[u]);
840
- }
841
- return g * a;
842
- }, o = 10, n = this.rootEl.getBoundingClientRect();
843
- let r = t.clientX, c = t.clientY;
844
- if (this.cornerSnapXTargets.length) {
845
- let s = r, a = o + 1;
846
- this.cornerSnapXTargets.forEach((p) => {
847
- const h = n.left + p, d = Math.abs(h - r);
848
- d < a && (a = d, s = h);
849
- }), a <= o && (r = s);
850
- }
851
- if (this.cornerSnapYTargets.length) {
852
- let s = c, a = o + 1;
853
- this.cornerSnapYTargets.forEach((p) => {
854
- const h = n.top + p, d = Math.abs(h - c);
855
- d < a && (a = d, s = h);
856
- }), a <= o && (c = s);
857
- }
858
- const l = (s, a) => {
859
- const p = this.resolveSplitNode(s.path);
860
- if (!p) return;
861
- const h = 48, d = s.beforeSize + s.afterSize;
862
- let g = Math.min(Math.max(s.beforeSize + a, h), d - h);
863
- g = i(g, d, t.shiftKey);
864
- const f = d - g, u = [...s.initialSizes];
865
- u[s.index] = g, u[s.index + 1] = f;
866
- const m = u.reduce((y, b) => y + b, 0);
867
- p.sizes = m > 0 ? u.map((y) => y / m) : [], s.container.setPanelSizes?.(u);
1083
+ const i = 10, n = this.rootEl.getBoundingClientRect(), o = q(
1084
+ t.clientX,
1085
+ this.cornerSnapXTargets.map((a) => n.left + a),
1086
+ i
1087
+ ), r = q(
1088
+ t.clientY,
1089
+ this.cornerSnapYTargets.map((a) => n.top + a),
1090
+ i
1091
+ ), d = (a, c) => {
1092
+ const l = A(a.path, this.rootLayout, this.floatingLayouts);
1093
+ if (!l) return;
1094
+ const h = 48, { before: u, after: f } = mt(
1095
+ a.beforeSize,
1096
+ a.afterSize,
1097
+ c,
1098
+ h,
1099
+ t.shiftKey
1100
+ ), p = [...a.initialSizes];
1101
+ p[a.index] = u, p[a.index + 1] = f;
1102
+ const m = p.reduce((g, y) => g + y, 0);
1103
+ l.sizes = m > 0 ? p.map((g) => g / m) : [], a.container.setPanelSizes?.(p);
868
1104
  };
869
- e.hs.forEach((s) => l(s, c - s.startY)), e.vs.forEach((s) => l(s, r - s.startX)), this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
1105
+ e.hs.forEach((a) => d(a, r - a.startY)), e.vs.forEach((a) => d(a, o - a.startX)), this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
870
1106
  }
871
1107
  endCornerResize(t) {
872
1108
  const e = this.cornerResizeState;
@@ -880,78 +1116,48 @@ class P extends A {
880
1116
  }
881
1117
  onIntersectionDoubleClick(t, e) {
882
1118
  t.preventDefault();
883
- const i = e.dataset.pairs, o = i ? JSON.parse(i) : [];
884
- if (!Array.isArray(o) || o.length === 0) {
885
- const a = (e.dataset.key ?? "").split("|");
886
- if (a.length === 2) {
887
- const [p, h] = a, d = p.lastIndexOf(":"), g = h.lastIndexOf(":");
888
- if (d > 0 && g > 0) {
889
- const f = p.slice(0, d), u = h.slice(0, g), m = Number.parseInt(p.slice(d + 1), 10), y = Number.parseInt(h.slice(g + 1), 10);
890
- o.push({ h: { pathStr: f, index: m }, v: { pathStr: u, index: y } });
891
- }
1119
+ const i = at(e.dataset.pairs, e.dataset.key);
1120
+ if (i.length === 0) return;
1121
+ const n = ct(
1122
+ i,
1123
+ this.previousSplitSizes,
1124
+ (o) => {
1125
+ const r = S(o), d = r ? A(r, this.rootLayout, this.floatingLayouts) : null;
1126
+ return d ? { sizes: d.sizes, childCount: d.children.length } : null;
892
1127
  }
893
- }
894
- if (o.length === 0) return;
895
- const n = /* @__PURE__ */ new Set();
896
- o.forEach((s) => {
897
- n.add(s.h.pathStr), n.add(s.v.pathStr);
898
- });
899
- let r = !1;
900
- n.forEach((s) => {
901
- this.previousSplitSizes.has(s) && (r = !0);
902
- });
903
- const c = (s, a) => {
904
- const p = this.findSplitterByPath(s.segments);
905
- if (!p) return;
906
- const d = (p.dataset.direction ?? "horizontal") === "horizontal" ? p.getBoundingClientRect().width : p.getBoundingClientRect().height;
907
- if (!Number.isFinite(d) || d <= 0) return;
908
- const g = a.reduce((u, m) => u + Math.max(m, 0), 0);
909
- if (g <= 0) return;
910
- const f = a.map((u) => Math.max(u, 0) / g * d);
911
- p.setPanelSizes?.(f);
912
- }, l = (s, a, p) => {
913
- const h = this.parsePath(s);
914
- if (!h) return;
915
- const d = this.resolveSplitNode(h);
916
- if (!d) return;
917
- const g = this.normalizeSizesArray(d.sizes ?? [], d.children.length), f = p([...g], a);
918
- d.sizes = f, c(h, f);
919
- };
920
- if (r)
921
- this.previousSplitSizes.forEach((s, a) => {
922
- const p = this.parsePath(a), h = p ? this.resolveSplitNode(p) : null;
923
- if (!h || !p) return;
924
- const d = this.normalizeSizesArray(s, h.children.length);
925
- h.sizes = d, c(p, d);
926
- }), this.previousSplitSizes.clear();
927
- else {
928
- const s = /* @__PURE__ */ new Set();
929
- o.forEach((a) => {
930
- [a.h.pathStr, a.v.pathStr].forEach((h) => {
931
- if (s.has(h)) return;
932
- const d = this.parsePath(h), g = d ? this.resolveSplitNode(d) : null;
933
- g && Array.isArray(g.sizes) && this.previousSplitSizes.set(h, [...g.sizes]), s.add(h);
934
- });
935
- const p = (h, d) => {
936
- const g = (h[d] ?? 0) + (h[d + 1] ?? 0);
937
- if (g <= 0) return h;
938
- h[d] = g / 2, h[d + 1] = g / 2;
939
- const f = h.reduce((u, m) => u + m, 0);
940
- return f > 0 ? h.map((u) => u / f) : h;
941
- };
942
- l(a.h.pathStr, a.h.index, p), l(a.v.pathStr, a.v.index, p);
943
- });
944
- }
945
- this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
1128
+ );
1129
+ n.remember.forEach(({ pathStr: o, sizes: r }) => this.previousSplitSizes.set(o, r)), n.writes.forEach(({ pathStr: o, sizes: r }) => {
1130
+ const d = S(o), a = d ? A(d, this.rootLayout, this.floatingLayouts) : null;
1131
+ !a || !d || (a.sizes = r, this.pushSizesToSplitter(d, r));
1132
+ }), n.clearStored && this.previousSplitSizes.clear(), this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
946
1133
  }
947
- beginFloatingDrag(t, e, i, o) {
948
- const n = this.floatingLayouts[e];
949
- if (!n)
1134
+ /**
1135
+ * Push normalized weights into the matching `<mp-splitter>` as pixel sizes.
1136
+ * The splitter's panel wrappers live in its shadow DOM, so direct flex
1137
+ * mutation is not an option.
1138
+ *
1139
+ * Returns without writing when the splitter has no measured size — which is
1140
+ * every case under jsdom, and is why the double-click logic above had to move
1141
+ * out of this method's shadow to become testable.
1142
+ */
1143
+ pushSizesToSplitter(t, e) {
1144
+ const i = this.findSplitterByPath(t.segments);
1145
+ if (!i) return;
1146
+ const o = (i.dataset.direction ?? "horizontal") === "horizontal" ? i.getBoundingClientRect().width : i.getBoundingClientRect().height;
1147
+ if (!Number.isFinite(o) || o <= 0) return;
1148
+ const r = e.reduce((a, c) => a + Math.max(c, 0), 0);
1149
+ if (r <= 0) return;
1150
+ const d = e.map((a) => Math.max(a, 0) / r * o);
1151
+ i.setPanelSizes?.(d);
1152
+ }
1153
+ beginFloatingDrag(t, e, i, n) {
1154
+ const o = this.floatingLayouts[e];
1155
+ if (!o)
950
1156
  return;
951
- t.preventDefault(), t.stopPropagation(), n.bounds = this.clampBoundsToHost(n.bounds, this.getHostSize());
952
- const { left: r, top: c } = n.bounds;
1157
+ t.preventDefault(), t.stopPropagation(), o.bounds = R(o.bounds, this.getHostSize());
1158
+ const { left: r, top: d } = o.bounds;
953
1159
  try {
954
- o.setPointerCapture(t.pointerId);
1160
+ n.setPointerCapture(t.pointerId);
955
1161
  } catch {
956
1162
  }
957
1163
  this.promoteFloatingPane(e, i), i.dataset.dragging = "true", this.floatingDragState = {
@@ -960,17 +1166,17 @@ class P extends A {
960
1166
  startX: t.clientX,
961
1167
  startY: t.clientY,
962
1168
  startLeft: r,
963
- startTop: c,
1169
+ startTop: d,
964
1170
  wrapper: i,
965
- handle: o
1171
+ handle: n
966
1172
  }, this.startPointerTracking();
967
1173
  }
968
1174
  /** The percent-of-host size of the dimension a handle drives (width for
969
1175
  * horizontal/corner handles, height for pure-vertical ones). */
970
1176
  syncFloatingResizerValue(t, e, i) {
971
- const o = this.floatingLayouts[e], n = this.getHostSize();
972
- if (!o || n.width <= 0 || n.height <= 0) return;
973
- const r = i.horizontal !== "none" ? o.bounds.width / n.width * 100 : o.bounds.height / n.height * 100;
1177
+ const n = this.floatingLayouts[e], o = this.getHostSize();
1178
+ if (!n || o.width <= 0 || o.height <= 0) return;
1179
+ const r = i.horizontal !== "none" ? n.bounds.width / o.width * 100 : n.bounds.height / o.height * 100;
974
1180
  t.setAttribute("aria-valuenow", String(Math.round(Math.min(100, Math.max(0, r)))));
975
1181
  }
976
1182
  /**
@@ -979,35 +1185,30 @@ class P extends A {
979
1185
  * ±10px per arrow, Shift for 1px. Off-axis arrows and modifier chords pass
980
1186
  * through untouched.
981
1187
  */
982
- onFloatingResizeKeydown(t, e, i, o, n) {
1188
+ onFloatingResizeKeydown(t, e, i, n, o) {
983
1189
  if (t.altKey || t.ctrlKey || t.metaKey) return;
984
- const r = t.key === "ArrowLeft" ? -1 : t.key === "ArrowRight" ? 1 : 0, c = t.key === "ArrowUp" ? -1 : t.key === "ArrowDown" ? 1 : 0;
985
- if (r === 0 && c === 0 || r !== 0 && n.horizontal === "none" || c !== 0 && n.vertical === "none") return;
986
- const l = this.floatingLayouts[e];
987
- if (!l) return;
1190
+ const r = t.key === "ArrowLeft" ? -1 : t.key === "ArrowRight" ? 1 : 0, d = t.key === "ArrowUp" ? -1 : t.key === "ArrowDown" ? 1 : 0;
1191
+ if (r === 0 && d === 0 || r !== 0 && o.horizontal === "none" || d !== 0 && o.vertical === "none") return;
1192
+ const a = this.floatingLayouts[e];
1193
+ if (!a) return;
988
1194
  t.preventDefault(), t.stopPropagation();
989
- const s = t.shiftKey ? 1 : 10, a = this.getHostSize(), p = a.width > 0 ? Math.min(192, a.width) : 192, h = a.height > 0 ? Math.min(128, a.height) : 128, d = { ...l.bounds };
990
- if (r !== 0) {
991
- const g = n.horizontal === "left" ? -r * s : r * s;
992
- let f = Math.max(p, d.width + g);
993
- n.horizontal === "left" ? (f = Math.min(f, d.left + d.width), d.left = d.left + d.width - f) : a.width > 0 && (f = Math.min(f, a.width - d.left)), d.width = f;
994
- }
995
- if (c !== 0) {
996
- const g = n.vertical === "top" ? -c * s : c * s;
997
- let f = Math.max(h, d.height + g);
998
- n.vertical === "top" ? (f = Math.min(f, d.top + d.height), d.top = d.top + d.height - f) : a.height > 0 && (f = Math.min(f, a.height - d.top)), d.height = f;
999
- }
1000
- l.bounds = d, i.style.left = `${d.left}px`, i.style.top = `${d.top}px`, i.style.width = `${d.width}px`, i.style.height = `${d.height}px`, this.syncFloatingResizerValue(o, e, n), this.dispatchLayoutChanged();
1195
+ const c = t.shiftKey ? 1 : 10, l = Z(
1196
+ a.bounds,
1197
+ o,
1198
+ { x: r * c, y: d * c },
1199
+ this.getHostSize()
1200
+ );
1201
+ this.applyFloatingBounds(i, e, l), this.syncFloatingResizerValue(n, e, o), this.dispatchLayoutChanged();
1001
1202
  }
1002
- beginFloatingResize(t, e, i, o, n) {
1203
+ beginFloatingResize(t, e, i, n, o) {
1003
1204
  const r = this.floatingLayouts[e];
1004
1205
  if (r) {
1005
1206
  t.preventDefault(), t.stopPropagation();
1006
1207
  try {
1007
- o.setPointerCapture(t.pointerId), o.dataset.resizing = "true";
1208
+ n.setPointerCapture(t.pointerId), n.dataset.resizing = "true";
1008
1209
  } catch {
1009
1210
  }
1010
- this.promoteFloatingPane(e, i), r.bounds = this.clampBoundsToHost(r.bounds, this.getHostSize()), this.floatingResizeState = {
1211
+ this.promoteFloatingPane(e, i), r.bounds = R(r.bounds, this.getHostSize()), this.floatingResizeState = {
1011
1212
  index: e,
1012
1213
  pointerId: t.pointerId,
1013
1214
  startX: t.clientX,
@@ -1017,8 +1218,8 @@ class P extends A {
1017
1218
  startLeft: r.bounds.left,
1018
1219
  startTop: r.bounds.top,
1019
1220
  wrapper: i,
1020
- handle: o,
1021
- edges: n
1221
+ handle: n,
1222
+ edges: o
1022
1223
  }, this.startPointerTracking();
1023
1224
  }
1024
1225
  }
@@ -1028,10 +1229,10 @@ class P extends A {
1028
1229
  return;
1029
1230
  const i = this.floatingLayouts[e.index];
1030
1231
  if (!i) return;
1031
- const o = t.clientX - e.startX, n = t.clientY - e.startY, r = this.clampBoundsToHost(
1232
+ const n = t.clientX - e.startX, o = t.clientY - e.startY, r = R(
1032
1233
  {
1033
- left: e.startLeft + o,
1034
- top: e.startTop + n,
1234
+ left: e.startLeft + n,
1235
+ top: e.startTop + o,
1035
1236
  width: i.bounds.width,
1036
1237
  height: i.bounds.height
1037
1238
  },
@@ -1060,24 +1261,41 @@ class P extends A {
1060
1261
  e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
1061
1262
  return;
1062
1263
  }
1063
- const o = this.parsePath(i.dataset.path);
1064
- if (!o || o.type === "floating" && o.index === e.index) {
1264
+ const n = S(i.dataset.path);
1265
+ if (!n || n.type === "floating" && n.index === e.index) {
1065
1266
  e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
1066
1267
  return;
1067
1268
  }
1068
1269
  this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null));
1069
- const n = this.computeDropZone(i, t, this.extractDropZoneFromEvent(t));
1070
- n ? e.dropTarget = { path: o, zone: n } : e.dropTarget && delete e.dropTarget, this.showDropIndicator(i, n);
1270
+ const o = this.computeDropZone(i, t, this.extractDropZoneFromEvent(t));
1271
+ o ? e.dropTarget = { path: n, zone: o } : e.dropTarget && delete e.dropTarget, this.showDropIndicator(i, o);
1071
1272
  }
1072
1273
  handleFloatingResizeMove(t) {
1073
1274
  const e = this.floatingResizeState;
1074
1275
  if (!e || t.pointerId !== e.pointerId)
1075
1276
  return;
1076
- const i = t.clientX - e.startX, o = t.clientY - e.startY, n = this.getHostSize(), r = n.width > 0 ? Math.min(192, n.width) : 192, c = n.height > 0 ? Math.min(128, n.height) : 128;
1077
- let l = e.startWidth, s = e.startHeight, a = e.startLeft, p = e.startTop;
1078
- e.edges.horizontal === "right" ? (l = Math.max(r, e.startWidth + i), n.width > 0 && (l = Math.min(l, n.width - e.startLeft))) : e.edges.horizontal === "left" && (l = Math.max(r, e.startWidth - i), l = Math.min(l, e.startLeft + e.startWidth), a = e.startLeft + e.startWidth - l), e.edges.vertical === "bottom" ? (s = Math.max(c, e.startHeight + o), n.height > 0 && (s = Math.min(s, n.height - e.startTop))) : e.edges.vertical === "top" && (s = Math.max(c, e.startHeight - o), s = Math.min(s, e.startTop + e.startHeight), p = e.startTop + e.startHeight - s), e.wrapper.style.width = `${l}px`, e.wrapper.style.height = `${s}px`, e.wrapper.style.left = `${a}px`, e.wrapper.style.top = `${p}px`;
1079
- const h = this.floatingLayouts[e.index];
1080
- h && (h.bounds = { left: a, top: p, width: l, height: s });
1277
+ const i = Z(
1278
+ {
1279
+ left: e.startLeft,
1280
+ top: e.startTop,
1281
+ width: e.startWidth,
1282
+ height: e.startHeight
1283
+ },
1284
+ e.edges,
1285
+ { x: t.clientX - e.startX, y: t.clientY - e.startY },
1286
+ this.getHostSize()
1287
+ );
1288
+ this.applyFloatingBounds(e.wrapper, e.index, i);
1289
+ }
1290
+ /**
1291
+ * Commit resolved bounds to both the DOM and the layout. Written directly
1292
+ * rather than through a re-render: a resize runs once per pointer move, and
1293
+ * tearing the wrapper down would drop the pointer capture mid-gesture.
1294
+ */
1295
+ applyFloatingBounds(t, e, i) {
1296
+ t.style.left = `${i.left}px`, t.style.top = `${i.top}px`, t.style.width = `${i.width}px`, t.style.height = `${i.height}px`;
1297
+ const n = this.floatingLayouts[e];
1298
+ n && (n.bounds = i);
1081
1299
  }
1082
1300
  endFloatingResize(t) {
1083
1301
  const e = this.floatingResizeState;
@@ -1089,21 +1307,12 @@ class P extends A {
1089
1307
  delete e.handle.dataset.resizing, this.syncFloatingResizerValue(e.handle, e.index, e.edges), this.floatingResizeState = null, this.dispatchLayoutChanged();
1090
1308
  }
1091
1309
  }
1092
- getFloatingPaneZIndex(t) {
1093
- const e = this.floatingLayouts[t];
1094
- return e && typeof e.zIndex == "number" && Number.isFinite(e.zIndex) ? e.zIndex : 10 + t;
1095
- }
1096
1310
  getHostSize() {
1097
1311
  return {
1098
1312
  width: this.rootEl.clientWidth,
1099
1313
  height: this.rootEl.clientHeight
1100
1314
  };
1101
1315
  }
1102
- clampBoundsToHost(t, e) {
1103
- if (e.width <= 0 || e.height <= 0) return t;
1104
- const i = Math.min(t.width, e.width), o = Math.min(t.height, e.height), n = Math.min(Math.max(t.left, 0), e.width - i), r = Math.min(Math.max(t.top, 0), e.height - o);
1105
- return { left: n, top: r, width: i, height: o };
1106
- }
1107
1316
  // Re-clamp existing floating-pane wrappers in place. Avoids the full
1108
1317
  // renderFloatingPanes() teardown (which would release pointer capture if
1109
1318
  // a user is mid-drag when the host resizes).
@@ -1111,26 +1320,26 @@ class P extends A {
1111
1320
  if (!this.floatingLayerEl) return;
1112
1321
  const t = this.getHostSize();
1113
1322
  this.floatingLayouts.forEach((e, i) => {
1114
- const o = this.floatingLayerEl.children[i];
1115
- if (!o) return;
1116
- const { left: n, top: r, width: c, height: l } = this.clampBoundsToHost(e.bounds, t);
1117
- o.style.left = `${n}px`, o.style.top = `${r}px`, o.style.width = `${c}px`, o.style.height = `${l}px`, o.style.minWidth = "0", o.style.minHeight = "0";
1323
+ const n = this.floatingLayerEl.children[i];
1324
+ if (!n) return;
1325
+ const { left: o, top: r, width: d, height: a } = R(e.bounds, t);
1326
+ n.style.left = `${o}px`, n.style.top = `${r}px`, n.style.width = `${d}px`, n.style.height = `${a}px`, n.style.minWidth = "0", n.style.minHeight = "0";
1118
1327
  });
1119
1328
  }
1120
1329
  promoteFloatingPane(t, e) {
1121
1330
  const i = this.floatingLayouts[t];
1122
1331
  if (!i)
1123
1332
  return;
1124
- const o = this.floatingLayouts.reduce((r, c, l) => {
1125
- if (!c)
1333
+ const n = this.floatingLayouts.reduce((r, d, a) => {
1334
+ if (!d)
1126
1335
  return r;
1127
- const s = l === t ? Number.NEGATIVE_INFINITY : this.getFloatingPaneZIndex(l);
1128
- return Math.max(r, s);
1129
- }, 0), n = Math.max(o + 2, 12);
1130
- i.zIndex = n, e.style.zIndex = String(n);
1336
+ const c = a === t ? Number.NEGATIVE_INFINITY : H(this.floatingLayouts[a], a);
1337
+ return Math.max(r, c);
1338
+ }, 0), o = Math.max(n + 2, 12);
1339
+ i.zIndex = o, e.style.zIndex = String(o);
1131
1340
  }
1132
1341
  getFloatingWrapper(t) {
1133
- const e = `.dock-floating[data-path="${this.formatPath({
1342
+ const e = `.dock-floating[data-path="${w({
1134
1343
  type: "floating",
1135
1344
  index: t,
1136
1345
  segments: []
@@ -1153,87 +1362,87 @@ class P extends A {
1153
1362
  const e = "Floating Pane";
1154
1363
  if (!t || !t.root)
1155
1364
  return e;
1156
- const i = t.activePane ?? this.findFirstPaneName(t.root);
1365
+ const i = t.activePane ?? E(t.root);
1157
1366
  return i ? this.titles[i] ?? i ?? e : e;
1158
1367
  }
1159
1368
  updateFloatingWindowTitle(t) {
1160
1369
  const e = this.floatingLayouts[t];
1161
1370
  if (!e)
1162
1371
  return;
1163
- const i = `.dock-floating[data-path="${this.formatPath({
1372
+ const i = `.dock-floating[data-path="${w({
1164
1373
  type: "floating",
1165
1374
  index: t,
1166
1375
  segments: []
1167
- })}"]`, o = this.floatingLayerEl.querySelector(i);
1168
- if (!o)
1376
+ })}"]`, n = this.floatingLayerEl.querySelector(i);
1377
+ if (!n)
1169
1378
  return;
1170
- const n = o.querySelector(".dock-floating__title");
1171
- n && (n.textContent = this.getFloatingWindowTitle(e));
1379
+ const o = n.querySelector(".dock-floating__title");
1380
+ o && (o.textContent = this.getFloatingWindowTitle(e));
1172
1381
  }
1173
1382
  renderSplit(t, e, i) {
1174
- const o = this.documentRef.createElement("mp-splitter");
1175
- o.classList.add("dock-split"), o.dataset.direction = t.direction, o.dataset.path = e.join("/"), o.setAttribute("orientation", t.direction);
1176
- const n = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
1177
- t.children.forEach((c, l) => {
1178
- o.appendChild(this.renderNode(c, [...e, l], i));
1383
+ const n = this.documentRef.createElement("mp-splitter");
1384
+ n.classList.add("dock-split"), n.dataset.direction = t.direction, n.dataset.path = e.join("/"), n.setAttribute("orientation", t.direction);
1385
+ const o = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
1386
+ t.children.forEach((d, a) => {
1387
+ n.appendChild(this.renderNode(d, [...e, a], i));
1179
1388
  });
1180
1389
  const r = Array.isArray(t.sizes) ? t.sizes : [];
1181
1390
  return r.length > 0 && requestAnimationFrame(() => {
1182
- const c = r.reduce((a, p) => a + Math.max(p, 0), 0);
1183
- if (c <= 0) return;
1184
- const l = t.direction === "horizontal" ? o.getBoundingClientRect().width : o.getBoundingClientRect().height;
1185
- if (!Number.isFinite(l) || l <= 0) return;
1186
- const s = r.map((a) => Math.max(a, 0) / c * l);
1187
- o.setPanelSizes?.(s), requestAnimationFrame(() => this.scheduleRenderIntersectionHandles());
1188
- }), o.addEventListener("resize-end", (c) => {
1189
- if (c.target !== o) return;
1190
- const l = c.detail;
1191
- if (!Array.isArray(l?.sizes) || l.sizes.length === 0) return;
1192
- const s = this.resolveSplitNode(n);
1193
- if (!s) return;
1194
- const a = (s.sizes ?? []).reduce(
1195
- (d, g) => d + Math.max(g, 0),
1391
+ const d = r.reduce((l, h) => l + Math.max(h, 0), 0);
1392
+ if (d <= 0) return;
1393
+ const a = t.direction === "horizontal" ? n.getBoundingClientRect().width : n.getBoundingClientRect().height;
1394
+ if (!Number.isFinite(a) || a <= 0) return;
1395
+ const c = r.map((l) => Math.max(l, 0) / d * a);
1396
+ n.setPanelSizes?.(c), requestAnimationFrame(() => this.scheduleRenderIntersectionHandles());
1397
+ }), n.addEventListener("resize-end", (d) => {
1398
+ if (d.target !== n) return;
1399
+ const a = d.detail;
1400
+ if (!Array.isArray(a?.sizes) || a.sizes.length === 0) return;
1401
+ const c = A(o, this.rootLayout, this.floatingLayouts);
1402
+ if (!c) return;
1403
+ const l = (c.sizes ?? []).reduce(
1404
+ (f, p) => f + Math.max(p, 0),
1196
1405
  0
1197
- ), p = l.sizes.reduce((d, g) => d + Math.max(g, 0), 0), h = a > 0 ? a : l.sizes.length;
1198
- p > 0 && (s.sizes = l.sizes.map(
1199
- (d) => Math.max(d, 0) / p * h
1406
+ ), h = a.sizes.reduce((f, p) => f + Math.max(p, 0), 0), u = l > 0 ? l : a.sizes.length;
1407
+ h > 0 && (c.sizes = a.sizes.map(
1408
+ (f) => Math.max(f, 0) / h * u
1200
1409
  ), this.dispatchLayoutChanged());
1201
- }), o;
1410
+ }), n;
1202
1411
  }
1203
1412
  renderStack(t, e, i) {
1204
- const o = this.documentRef.createElement("mp-tab-control");
1205
- o.classList.add("dock-stack"), o.setAttribute("select-first-tab", "false"), o.setAttribute("border", "top");
1206
- const n = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
1207
- o.dataset.path = this.formatPath(n);
1413
+ const n = this.documentRef.createElement("mp-tab-control");
1414
+ n.classList.add("dock-stack"), n.setAttribute("select-first-tab", "false"), n.setAttribute("border", "top");
1415
+ const o = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
1416
+ n.dataset.path = w(o);
1208
1417
  const r = Array.from(new Set(t.panes));
1209
1418
  if (r.length === 0) {
1210
- const a = this.documentRef.createElement("span");
1211
- a.setAttribute("slot", "__empty__-header"), a.textContent = "(empty)";
1212
- const p = this.documentRef.createElement("div");
1213
- return p.setAttribute("slot", "__empty__-content"), p.classList.add("dock-stack__pane"), p.textContent = "No panes configured", o.append(a, p), o.setAttribute("active-tab", "__empty__"), o;
1419
+ const l = this.documentRef.createElement("span");
1420
+ l.setAttribute("slot", "__empty__-header"), l.textContent = "(empty)";
1421
+ const h = this.documentRef.createElement("div");
1422
+ return h.setAttribute("slot", "__empty__-content"), h.classList.add("dock-stack__pane"), h.textContent = "No panes configured", n.append(l, h), n.setAttribute("active-tab", "__empty__"), n;
1214
1423
  }
1215
- const c = r.includes(t.activePane ?? "") ? t.activePane : r[0], l = e.length ? e.join("-") : "root", s = typeof i == "number" ? `f${i}-${l}` : l;
1216
- return r.forEach((a) => {
1217
- const p = a.replace(/[^a-zA-Z0-9_-]/g, "-"), h = p.length > 0 ? p : "pane", d = `${this.instanceId}-tab-${s}-${h}`, g = `${this.instanceId}-panel-${s}-${h}`, f = this.documentRef.createElement("span");
1218
- f.setAttribute("slot", `${d}-header`), f.classList.add("dock-tab"), f.dataset.pane = a, f.dataset.tabId = d, f.textContent = this.titles[a] ?? a, f.addEventListener("pointerdown", (y) => {
1219
- this.captureTabDragMetrics(y, o), this.armPaneDragGesture(y, this.clonePath(n), a, o), y.stopPropagation();
1424
+ const d = r.includes(t.activePane ?? "") ? t.activePane : r[0], a = e.length ? e.join("-") : "root", c = typeof i == "number" ? `f${i}-${a}` : a;
1425
+ return r.forEach((l) => {
1426
+ const h = l.replace(/[^a-zA-Z0-9_-]/g, "-"), u = h.length > 0 ? h : "pane", f = `${this.instanceId}-tab-${c}-${u}`, p = `${this.instanceId}-panel-${c}-${u}`, m = this.documentRef.createElement("span");
1427
+ m.setAttribute("slot", `${f}-header`), m.classList.add("dock-tab"), m.dataset.pane = l, m.dataset.tabId = f, m.textContent = this.titles[l] ?? l, m.addEventListener("pointerdown", (b) => {
1428
+ this.captureTabDragMetrics(b, n), this.armPaneDragGesture(b, T(o), l, n), b.stopPropagation();
1220
1429
  });
1221
- const u = this.documentRef.createElement("div");
1222
- u.setAttribute("slot", `${d}-content`), u.classList.add("dock-stack__pane"), u.dataset.pane = a, u.dataset.tabId = d, u.id = g;
1223
- const m = this.documentRef.createElement("slot");
1224
- m.name = a, u.appendChild(m), o.append(f, u), a === c && o.setAttribute("active-tab", d);
1225
- }), o.dataset.activePane = c, o.addEventListener("tab-activate", (a) => {
1226
- const p = a.detail, d = o.querySelector(
1227
- `:scope > [data-tab-id="${p.tabId}"]`
1430
+ const g = this.documentRef.createElement("div");
1431
+ g.setAttribute("slot", `${f}-content`), g.classList.add("dock-stack__pane"), g.dataset.pane = l, g.dataset.tabId = f, g.id = p;
1432
+ const y = this.documentRef.createElement("slot");
1433
+ y.name = l, g.appendChild(y), n.append(m, g), l === d && n.setAttribute("active-tab", f);
1434
+ }), n.dataset.activePane = d, n.addEventListener("tab-activate", (l) => {
1435
+ const h = l.detail, f = n.querySelector(
1436
+ `:scope > [data-tab-id="${h.tabId}"]`
1228
1437
  )?.dataset.pane;
1229
- d && (this.activatePane(o, d, this.clonePath(n)), this.dispatchEvent(
1438
+ f && (this.activatePane(n, f, T(o)), this.dispatchEvent(
1230
1439
  new CustomEvent("dock-pane-activated", {
1231
- detail: { pane: d },
1440
+ detail: { pane: f },
1232
1441
  bubbles: !0,
1233
1442
  composed: !0
1234
1443
  })
1235
1444
  ));
1236
- }), o;
1445
+ }), n;
1237
1446
  }
1238
1447
  /**
1239
1448
  * Returns the strip (`.tsc`) element inside an `<mp-tab-control>`'s shadow
@@ -1311,14 +1520,14 @@ class P extends A {
1311
1520
  this.pendingTabDragMetrics = null;
1312
1521
  return;
1313
1522
  }
1314
- const i = this.getBoundingClientRect(), o = e.getBoundingClientRect(), n = t.clientX - o.left, r = t.clientY - o.top, c = o.left - i.left, l = o.top - i.top, s = Number.isFinite(o.width) ? o.width : 0, a = Number.isFinite(o.height) ? o.height : 0;
1523
+ const i = this.getBoundingClientRect(), n = e.getBoundingClientRect(), o = t.clientX - n.left, r = t.clientY - n.top, d = n.left - i.left, a = n.top - i.top, c = Number.isFinite(n.width) ? n.width : 0, l = Number.isFinite(n.height) ? n.height : 0;
1315
1524
  this.pendingTabDragMetrics = {
1316
- pointerOffsetX: n,
1525
+ pointerOffsetX: o,
1317
1526
  pointerOffsetY: r,
1318
- left: c,
1319
- top: l,
1320
- width: s,
1321
- height: a,
1527
+ left: d,
1528
+ top: a,
1529
+ width: c,
1530
+ height: l,
1322
1531
  startClientX: t.clientX,
1323
1532
  startClientY: t.clientY
1324
1533
  };
@@ -1334,26 +1543,26 @@ class P extends A {
1334
1543
  * Once armed, both paths converge on {@link beginPaneDrag}. All listeners
1335
1544
  * self-clean on resolve so the gesture stays scoped to a single pointerdown.
1336
1545
  */
1337
- armPaneDragGesture(t, e, i, o) {
1546
+ armPaneDragGesture(t, e, i, n) {
1338
1547
  if (t.pointerType === "touch") {
1339
- this.armPaneDragGestureTouch(t, e, i, o);
1548
+ this.armPaneDragGestureTouch(t, e, i, n);
1340
1549
  return;
1341
1550
  }
1342
1551
  if (t.pointerType === "mouse" && t.button !== 0) return;
1343
- const n = this.windowRef;
1344
- if (!n) return;
1345
- const r = t.clientX, c = t.clientY, l = t.pointerId, s = 5;
1346
- let a = !1;
1347
- const p = () => {
1348
- a = !0, n.removeEventListener("pointermove", h, !0), n.removeEventListener("pointerup", d, !0), n.removeEventListener("pointercancel", d, !0);
1349
- }, h = (g) => {
1350
- if (a || g.pointerId !== l) return;
1351
- const f = g.clientX - r, u = g.clientY - c;
1352
- Math.hypot(f, u) < s || (p(), this.beginPaneDrag(g, e, i, o));
1353
- }, d = (g) => {
1354
- a || g.pointerId !== l || (p(), this.clearPendingTabDragMetrics());
1552
+ const o = this.windowRef;
1553
+ if (!o) return;
1554
+ const r = t.clientX, d = t.clientY, a = t.pointerId, c = 5;
1555
+ let l = !1;
1556
+ const h = () => {
1557
+ l = !0, o.removeEventListener("pointermove", u, !0), o.removeEventListener("pointerup", f, !0), o.removeEventListener("pointercancel", f, !0);
1558
+ }, u = (p) => {
1559
+ if (l || p.pointerId !== a) return;
1560
+ const m = p.clientX - r, g = p.clientY - d;
1561
+ Math.hypot(m, g) < c || (h(), this.beginPaneDrag(p, e, i, n));
1562
+ }, f = (p) => {
1563
+ l || p.pointerId !== a || (h(), this.clearPendingTabDragMetrics());
1355
1564
  };
1356
- n.addEventListener("pointermove", h, !0), n.addEventListener("pointerup", d, !0), n.addEventListener("pointercancel", d, !0);
1565
+ o.addEventListener("pointermove", u, !0), o.addEventListener("pointerup", f, !0), o.addEventListener("pointercancel", f, !0);
1357
1566
  }
1358
1567
  /**
1359
1568
  * Touch-specific gesture arming. With `.dock-tab` set to `touch-action:
@@ -1376,41 +1585,41 @@ class P extends A {
1376
1585
  * promote it, so first move after a long-press fires pointercancel and
1377
1586
  * strands the panel. JS-driven scroll is the only model that holds.
1378
1587
  */
1379
- armPaneDragGestureTouch(t, e, i, o) {
1380
- const n = this.windowRef;
1381
- if (!n) return;
1382
- const r = t.clientX, c = t.clientY, l = t.pointerId;
1383
- let s = r, a = c, p = r, h = !1, d = !1, g = !1;
1384
- const f = t.currentTarget instanceof HTMLElement ? t.currentTarget : t.target instanceof HTMLElement ? t.target.closest(".dock-tab") : null, u = o ? this.getStackStripEl(o)?.querySelector(
1588
+ armPaneDragGestureTouch(t, e, i, n) {
1589
+ const o = this.windowRef;
1590
+ if (!o) return;
1591
+ const r = t.clientX, d = t.clientY, a = t.pointerId;
1592
+ let c = r, l = d, h = r, u = !1, f = !1, p = !1;
1593
+ const m = t.currentTarget instanceof HTMLElement ? t.currentTarget : t.target instanceof HTMLElement ? t.target.closest(".dock-tab") : null, g = n ? this.getStackStripEl(n)?.querySelector(
1385
1594
  "ul.nav.nav-tabs"
1386
- ) ?? null : null, m = () => {
1387
- h || (h = !0, n.clearTimeout(S), n.clearTimeout(v), n.removeEventListener("pointermove", y, !0), n.removeEventListener("pointerup", b, !0), n.removeEventListener("pointercancel", z, !0), g && f && f.removeAttribute("data-pressing"));
1388
- }, y = (k) => {
1389
- if (h || k.pointerId !== l) return;
1390
- if (d) {
1391
- const T = k.clientX - p;
1392
- p = k.clientX, u && (u.scrollLeft -= T);
1595
+ ) ?? null : null, y = () => {
1596
+ u || (u = !0, o.clearTimeout(P), o.clearTimeout(z), o.removeEventListener("pointermove", b, !0), o.removeEventListener("pointerup", k, !0), o.removeEventListener("pointercancel", D, !0), p && m && m.removeAttribute("data-pressing"));
1597
+ }, b = (v) => {
1598
+ if (u || v.pointerId !== a) return;
1599
+ if (f) {
1600
+ const G = v.clientX - h;
1601
+ h = v.clientX, g && (g.scrollLeft -= G);
1393
1602
  return;
1394
1603
  }
1395
- s = k.clientX, a = k.clientY;
1396
- const w = k.clientX - r, L = k.clientY - c;
1397
- if (Math.hypot(w, L) <= P.TOUCH_LONG_PRESS_SLOP_PX)
1604
+ c = v.clientX, l = v.clientY;
1605
+ const O = v.clientX - r, Y = v.clientY - d;
1606
+ if (Math.hypot(O, Y) <= L.TOUCH_LONG_PRESS_SLOP_PX)
1398
1607
  return;
1399
- const R = !!u && u.scrollWidth > u.clientWidth;
1400
- if (Math.abs(w) > Math.abs(L) && R) {
1401
- n.clearTimeout(S), n.clearTimeout(v), g && f && (f.removeAttribute("data-pressing"), g = !1), d = !0, p = k.clientX, u.scrollLeft -= w, this.clearPendingTabDragMetrics();
1608
+ const V = !!g && g.scrollWidth > g.clientWidth;
1609
+ if (Math.abs(O) > Math.abs(Y) && V) {
1610
+ o.clearTimeout(P), o.clearTimeout(z), p && m && (m.removeAttribute("data-pressing"), p = !1), f = !0, h = v.clientX, g.scrollLeft -= O, this.clearPendingTabDragMetrics();
1402
1611
  return;
1403
1612
  }
1404
- m(), this.clearPendingTabDragMetrics();
1405
- }, b = (k) => {
1406
- h || k.pointerId !== l || (m(), this.clearPendingTabDragMetrics());
1407
- }, z = (k) => {
1408
- h || k.pointerId !== l || (m(), this.clearPendingTabDragMetrics());
1409
- }, S = n.setTimeout(() => {
1410
- if (h) return;
1411
- m();
1613
+ y(), this.clearPendingTabDragMetrics();
1614
+ }, k = (v) => {
1615
+ u || v.pointerId !== a || (y(), this.clearPendingTabDragMetrics());
1616
+ }, D = (v) => {
1617
+ u || v.pointerId !== a || (y(), this.clearPendingTabDragMetrics());
1618
+ }, P = o.setTimeout(() => {
1619
+ if (u) return;
1620
+ y();
1412
1621
  try {
1413
- this.setPointerCapture(l);
1622
+ this.setPointerCapture(a);
1414
1623
  } catch {
1415
1624
  }
1416
1625
  if (typeof navigator < "u" && typeof navigator.vibrate == "function")
@@ -1418,79 +1627,79 @@ class P extends A {
1418
1627
  navigator.vibrate(10);
1419
1628
  } catch {
1420
1629
  }
1421
- const k = new PointerEvent("pointermove", {
1422
- pointerId: l,
1630
+ const v = new PointerEvent("pointermove", {
1631
+ pointerId: a,
1423
1632
  pointerType: "touch",
1424
1633
  isPrimary: !0,
1425
- clientX: s,
1426
- clientY: a,
1634
+ clientX: c,
1635
+ clientY: l,
1427
1636
  bubbles: !1,
1428
1637
  cancelable: !1
1429
1638
  });
1430
- this.beginPaneDrag(k, e, i, o);
1431
- }, P.TOUCH_LONG_PRESS_MS), v = n.setTimeout(() => {
1432
- h || !f || (g = !0, f.setAttribute("data-pressing", "true"));
1433
- }, P.TOUCH_PRESS_FEEDBACK_DELAY_MS);
1434
- n.addEventListener("pointermove", y, !0), n.addEventListener("pointerup", b, !0), n.addEventListener("pointercancel", z, !0);
1639
+ this.beginPaneDrag(v, e, i, n);
1640
+ }, L.TOUCH_LONG_PRESS_MS), z = o.setTimeout(() => {
1641
+ u || !m || (p = !0, m.setAttribute("data-pressing", "true"));
1642
+ }, L.TOUCH_PRESS_FEEDBACK_DELAY_MS);
1643
+ o.addEventListener("pointermove", b, !0), o.addEventListener("pointerup", k, !0), o.addEventListener("pointercancel", D, !0);
1435
1644
  }
1436
- beginPaneDrag(t, e, i, o) {
1645
+ beginPaneDrag(t, e, i, n) {
1437
1646
  const {
1438
- path: n,
1647
+ path: o,
1439
1648
  floatingIndex: r,
1440
- pointerOffsetX: c,
1441
- pointerOffsetY: l
1442
- } = this.preparePaneDragSource(e, i, o, t), s = o ? this.getStackStripEl(o) : null, a = s ? s.getBoundingClientRect() : null, p = a ? { left: a.left, top: a.top, right: a.right, bottom: a.bottom } : null, h = this.pendingTabDragMetrics;
1649
+ pointerOffsetX: d,
1650
+ pointerOffsetY: a
1651
+ } = this.preparePaneDragSource(e, i, n, t), c = n ? this.getStackStripEl(n) : null, l = c ? c.getBoundingClientRect() : null, h = l ? { left: l.left, top: l.top, right: l.right, bottom: l.bottom } : null, u = this.pendingTabDragMetrics;
1443
1652
  if (this.dragState = {
1444
1653
  pane: i,
1445
- sourcePath: this.clonePath(n),
1654
+ sourcePath: T(o),
1446
1655
  floatingIndex: r,
1447
- pointerOffsetX: c,
1448
- pointerOffsetY: l,
1656
+ pointerOffsetX: d,
1657
+ pointerOffsetY: a,
1449
1658
  dropHandled: !1,
1450
- sourceStackEl: o,
1451
- sourceHeaderBounds: p,
1452
- startClientX: h && Number.isFinite(h.startClientX) ? h.startClientX : t.clientX,
1453
- startClientY: h && Number.isFinite(h.startClientY) ? h.startClientY : t.clientY
1659
+ sourceStackEl: n,
1660
+ sourceHeaderBounds: h,
1661
+ startClientX: u && Number.isFinite(u.startClientX) ? u.startClientX : t.clientX,
1662
+ startClientY: u && Number.isFinite(u.startClientY) ? u.startClientY : t.clientY
1454
1663
  }, this.lastDragPointerPosition = {
1455
1664
  x: this.dragState.startClientX,
1456
1665
  y: this.dragState.startClientY
1457
1666
  }, this.updateDraggedFloatingPositionFromPoint(t.clientX, t.clientY), this.startDragPointerTracking(), this.markDraggedFloatingWrapper(), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
1458
- const d = this.resolveStackLocation(this.dragState.sourcePath);
1459
- if (d && Array.isArray(d.node.panes) && d.node.panes.length === 1) {
1460
- let g = !1;
1461
- if (d.context === "docked")
1462
- g = !0;
1463
- else if (d.context === "floating") {
1464
- const f = this.floatingLayouts[d.index];
1465
- g = (f && f.root ? this.countPanesInTree(f.root) : 0) > 1;
1667
+ const f = this.resolveStackLocation(this.dragState.sourcePath);
1668
+ if (f && Array.isArray(f.node.panes) && f.node.panes.length === 1) {
1669
+ let p = !1;
1670
+ if (f.context === "docked")
1671
+ p = !0;
1672
+ else if (f.context === "floating") {
1673
+ const m = this.floatingLayouts[f.index];
1674
+ p = (m && m.root ? J(m.root) : 0) > 1;
1466
1675
  }
1467
- g && this.convertPendingTabDragToFloating(t.clientX, t.clientY);
1676
+ p && this.convertPendingTabDragToFloating(t.clientX, t.clientY);
1468
1677
  }
1469
1678
  }
1470
1679
  }
1471
- preparePaneDragSource(t, e, i, o) {
1472
- const n = this.resolveStackLocation(t);
1473
- if (!n || !n.node.panes.includes(e))
1680
+ preparePaneDragSource(t, e, i, n) {
1681
+ const o = this.resolveStackLocation(t);
1682
+ if (!o || !o.node.panes.includes(e))
1474
1683
  return {
1475
1684
  path: t,
1476
1685
  floatingIndex: null,
1477
1686
  pointerOffsetX: 0,
1478
1687
  pointerOffsetY: 0
1479
1688
  };
1480
- const r = this.pendingTabDragMetrics, c = !!i && Array.from(i.querySelectorAll(".dock-tab")).some(
1481
- (g) => g.dataset.pane && g.dataset.pane !== e
1482
- ), l = n.node.panes.some((g) => g !== e), s = n.context === "floating" ? this.floatingLayouts[n.index] : null, a = s && s.root ? this.countPanesInTree(s.root) : l ? 2 : 1;
1483
- if (n.context === "floating" && !!s && !l && !c && a <= 1) {
1484
- if (s) {
1485
- s.activePane = e, this.updateFloatingWindowTitle(n.index);
1486
- const g = this.getFloatingWrapper(n.index);
1487
- g && this.promoteFloatingPane(n.index, g);
1488
- const f = this.getBoundingClientRect(), u = r && Number.isFinite(r.pointerOffsetX) && Number.isFinite(r.left) && Number.isFinite(s.bounds.left) ? r.pointerOffsetX + (r.left - s.bounds.left) : Number.isFinite(o.clientX) && Number.isFinite(s.bounds.left) ? o.clientX - f.left - s.bounds.left : s.bounds.width / 2, m = r && Number.isFinite(r.pointerOffsetY) && Number.isFinite(r.top) && Number.isFinite(s.bounds.top) ? r.pointerOffsetY + (r.top - s.bounds.top) : Number.isFinite(o.clientY) && Number.isFinite(s.bounds.top) ? o.clientY - f.top - s.bounds.top : s.bounds.height / 2;
1689
+ const r = this.pendingTabDragMetrics, d = !!i && Array.from(i.querySelectorAll(".dock-tab")).some(
1690
+ (p) => p.dataset.pane && p.dataset.pane !== e
1691
+ ), a = o.node.panes.some((p) => p !== e), c = o.context === "floating" ? this.floatingLayouts[o.index] : null, l = c && c.root ? J(c.root) : a ? 2 : 1;
1692
+ if (o.context === "floating" && !!c && !a && !d && l <= 1) {
1693
+ if (c) {
1694
+ c.activePane = e, this.updateFloatingWindowTitle(o.index);
1695
+ const p = this.getFloatingWrapper(o.index);
1696
+ p && this.promoteFloatingPane(o.index, p);
1697
+ const m = this.getBoundingClientRect(), g = r && Number.isFinite(r.pointerOffsetX) && Number.isFinite(r.left) && Number.isFinite(c.bounds.left) ? r.pointerOffsetX + (r.left - c.bounds.left) : Number.isFinite(n.clientX) && Number.isFinite(c.bounds.left) ? n.clientX - m.left - c.bounds.left : c.bounds.width / 2, y = r && Number.isFinite(r.pointerOffsetY) && Number.isFinite(r.top) && Number.isFinite(c.bounds.top) ? r.pointerOffsetY + (r.top - c.bounds.top) : Number.isFinite(n.clientY) && Number.isFinite(c.bounds.top) ? n.clientY - m.top - c.bounds.top : c.bounds.height / 2;
1489
1698
  return {
1490
1699
  path: t,
1491
- floatingIndex: n.index,
1492
- pointerOffsetX: u,
1493
- pointerOffsetY: m
1700
+ floatingIndex: o.index,
1701
+ pointerOffsetX: g,
1702
+ pointerOffsetY: y
1494
1703
  };
1495
1704
  }
1496
1705
  return {
@@ -1500,12 +1709,12 @@ class P extends A {
1500
1709
  pointerOffsetY: 0
1501
1710
  };
1502
1711
  }
1503
- const h = r && Number.isFinite(r.pointerOffsetX) ? r.pointerOffsetX : 0, d = r && Number.isFinite(r.pointerOffsetY) ? r.pointerOffsetY : 0;
1712
+ const u = r && Number.isFinite(r.pointerOffsetX) ? r.pointerOffsetX : 0, f = r && Number.isFinite(r.pointerOffsetY) ? r.pointerOffsetY : 0;
1504
1713
  return {
1505
1714
  path: t,
1506
1715
  floatingIndex: -1,
1507
- pointerOffsetX: h,
1508
- pointerOffsetY: d
1716
+ pointerOffsetX: u,
1717
+ pointerOffsetY: f
1509
1718
  };
1510
1719
  }
1511
1720
  endPaneDrag() {
@@ -1517,42 +1726,42 @@ class P extends A {
1517
1726
  if (!this.dragState || !Number.isFinite(t) || !Number.isFinite(e))
1518
1727
  return;
1519
1728
  if (this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
1520
- const p = this.dragState.sourceHeaderBounds, h = this.dragState.startClientX ?? t, d = this.dragState.startClientY ?? e, g = Math.hypot(t - h, e - d), f = 8;
1521
- let u = !0;
1522
- const m = p ? this.isPointWithinBounds(p, t, e) : !0, y = this.isPointerOverSourceHeader(t, e);
1523
- u = m || y, !u && g > f && this.convertPendingTabDragToFloating(t, e);
1729
+ const h = this.dragState.sourceHeaderBounds, u = this.dragState.startClientX ?? t, f = this.dragState.startClientY ?? e, p = Math.hypot(t - u, e - f), m = 8;
1730
+ let g = !0;
1731
+ const y = h ? j(h, t, e) : !0, b = this.isPointerOverSourceHeader(t, e);
1732
+ g = y || b, !g && p > m && this.convertPendingTabDragToFloating(t, e);
1524
1733
  }
1525
1734
  this.updatePaneDragDropTargetFromPoint(t, e);
1526
- const { floatingIndex: i, pointerOffsetX: o, pointerOffsetY: n } = this.dragState;
1735
+ const { floatingIndex: i, pointerOffsetX: n, pointerOffsetY: o } = this.dragState;
1527
1736
  if (i === null || i < 0)
1528
1737
  return;
1529
1738
  const r = this.floatingLayouts[i];
1530
1739
  if (!r)
1531
1740
  return;
1532
- const c = this.getBoundingClientRect(), l = t - c.left - o, s = e - c.top - n;
1533
- r.bounds.left = l, r.bounds.top = s;
1534
- const a = this.getFloatingWrapper(i);
1535
- a && (a.style.left = `${l}px`, a.style.top = `${s}px`);
1741
+ const d = this.getBoundingClientRect(), a = t - d.left - n, c = e - d.top - o;
1742
+ r.bounds.left = a, r.bounds.top = c;
1743
+ const l = this.getFloatingWrapper(i);
1744
+ l && (l.style.left = `${a}px`, l.style.top = `${c}px`);
1536
1745
  }
1537
1746
  updatePaneDragDropTargetFromPoint(t, e) {
1538
1747
  if (!this.dragState)
1539
1748
  return;
1540
- const i = this.findStackAtPoint(t, e), o = i ? this.parsePath(i.dataset.path) : null;
1541
- if (!i || !o) {
1749
+ const i = this.findStackAtPoint(t, e), n = i ? S(i.dataset.path) : null;
1750
+ if (!i || !n) {
1542
1751
  this.dropJoystick.dataset.visible !== "true" && this.hideDropIndicator(), this.clearHeaderDragPlaceholder();
1543
1752
  return;
1544
1753
  }
1545
- if (this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null)), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && o && this.pathsEqual(o, this.dragState.sourcePath)) {
1546
- const c = !!this.dragState.sourceHeaderBounds && this.isPointWithinBounds(this.dragState.sourceHeaderBounds, t, e), l = this.isPointerOverSourceHeader(t, e);
1547
- if (c || l) {
1754
+ if (this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null)), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && n && B(n, this.dragState.sourcePath)) {
1755
+ const d = !!this.dragState.sourceHeaderBounds && j(this.dragState.sourceHeaderBounds, t, e), a = this.isPointerOverSourceHeader(t, e);
1756
+ if (d || a) {
1548
1757
  this.ensureHeaderDragPlaceholder(i, this.dragState.pane);
1549
- const s = this.computeHeaderInsertIndex(i, t);
1550
- this.dragState.liveReorderIndex !== s && (this.updateHeaderDragPlaceholderPosition(i, s), this.dragState.liveReorderIndex = s), this.hideDropIndicator();
1758
+ const c = this.computeHeaderInsertIndex(i, t);
1759
+ this.dragState.liveReorderIndex !== c && (this.updateHeaderDragPlaceholderPosition(i, c), this.dragState.liveReorderIndex = c), this.hideDropIndicator();
1551
1760
  return;
1552
1761
  }
1553
1762
  }
1554
1763
  this.clearHeaderDragPlaceholder();
1555
- const n = this.findDropZoneByPoint(t, e), r = this.computeDropZone(i, { clientX: t, clientY: e }, n);
1764
+ const o = this.findDropZoneByPoint(t, e), r = this.computeDropZone(i, { clientX: t, clientY: e }, o);
1556
1765
  this.showDropIndicator(i, r);
1557
1766
  }
1558
1767
  // Returns true when the pointer is currently over the source stack's header (tab strip).
@@ -1563,15 +1772,12 @@ class P extends A {
1563
1772
  const i = this.dragState;
1564
1773
  if (!i)
1565
1774
  return !1;
1566
- const o = i.sourceStackEl ?? null, n = o ? this.getStackStripEl(o) : null;
1567
- if (!n)
1775
+ const n = i.sourceStackEl ?? null, o = n ? this.getStackStripEl(n) : null;
1776
+ if (!o)
1568
1777
  return !0;
1569
- const r = n.getBoundingClientRect();
1778
+ const r = o.getBoundingClientRect();
1570
1779
  return t >= r.left && t <= r.right && e >= r.top && e <= r.bottom;
1571
1780
  }
1572
- isPointWithinBounds(t, e, i) {
1573
- return e >= t.left && e <= t.right && i >= t.top && i <= t.bottom;
1574
- }
1575
1781
  // Ensure a placeholder tab exists during in-header drag and hide the real dragged tab visually.
1576
1782
  // Operates on the mp-tab-control stack: the dragged content div gets `data-hidden`
1577
1783
  // (mp-tab-control then skips its tab in the strip), and a placeholder header+content
@@ -1582,19 +1788,19 @@ class P extends A {
1582
1788
  return;
1583
1789
  const i = t.querySelector(
1584
1790
  `:scope > .dock-tab[data-pane="${CSS.escape(e)}"]`
1585
- ), o = t.querySelector(
1791
+ ), n = t.querySelector(
1586
1792
  `:scope > .dock-stack__pane[data-pane="${CSS.escape(e)}"]`
1587
1793
  );
1588
- if (!i || !o) return;
1589
- const n = this.windowRef ? this.windowRef.getComputedStyle(i) : globalThis.getComputedStyle(i), r = parseFloat(n.paddingLeft) + parseFloat(n.paddingRight), c = Math.max(
1794
+ if (!i || !n) return;
1795
+ const o = this.windowRef ? this.windowRef.getComputedStyle(i) : globalThis.getComputedStyle(i), r = parseFloat(o.paddingLeft) + parseFloat(o.paddingRight), d = Math.max(
1590
1796
  0,
1591
1797
  i.offsetWidth - r
1592
1798
  );
1593
- o.setAttribute("data-hidden", "");
1594
- const l = "__dock-placeholder__", s = this.documentRef.createElement("span");
1595
- s.setAttribute("slot", `${l}-header`), s.classList.add("dock-tab"), s.dataset.placeholder = "true", s.dataset.tabId = l, s.setAttribute("aria-hidden", "true"), s.textContent = i.textContent, s.style.display = "inline-block", s.style.minWidth = `${c}px`, s.style.opacity = "0.5";
1596
- const a = this.documentRef.createElement("div");
1597
- a.setAttribute("slot", `${l}-content`), a.classList.add("dock-stack__pane"), a.dataset.placeholder = "true", t.insertBefore(s, i), t.insertBefore(a, o), this.dragState && (this.dragState.placeholderHeader = t, this.dragState.placeholderEl = s);
1799
+ n.setAttribute("data-hidden", "");
1800
+ const a = "__dock-placeholder__", c = this.documentRef.createElement("span");
1801
+ c.setAttribute("slot", `${a}-header`), c.classList.add("dock-tab"), c.dataset.placeholder = "true", c.dataset.tabId = a, c.setAttribute("aria-hidden", "true"), c.textContent = i.textContent, c.style.display = "inline-block", c.style.minWidth = `${d}px`, c.style.opacity = "0.5";
1802
+ const l = this.documentRef.createElement("div");
1803
+ l.setAttribute("slot", `${a}-content`), l.classList.add("dock-stack__pane"), l.dataset.placeholder = "true", t.insertBefore(c, i), t.insertBefore(l, n), this.dragState && (this.dragState.placeholderHeader = t, this.dragState.placeholderEl = c);
1598
1804
  }
1599
1805
  // Move the placeholder to the computed target index within the strip.
1600
1806
  // We reorder light-DOM children (header span + matching content div); the
@@ -1603,16 +1809,16 @@ class P extends A {
1603
1809
  if (t.tagName !== "MP-TAB-CONTROL") return;
1604
1810
  const i = this.dragState?.placeholderEl ?? null;
1605
1811
  if (!i) return;
1606
- const o = this.dragState?.pane ?? null, n = Array.from(
1812
+ const n = this.dragState?.pane ?? null, o = Array.from(
1607
1813
  t.querySelectorAll(":scope > .dock-tab")
1608
1814
  ).filter(
1609
- (s) => s !== i && (!o || s.dataset.pane !== o)
1610
- ), r = Math.max(0, Math.min(e, n.length)), c = n[r] ?? null;
1611
- t.insertBefore(i, c);
1612
- const l = t.querySelector(
1815
+ (c) => c !== i && (!n || c.dataset.pane !== n)
1816
+ ), r = Math.max(0, Math.min(e, o.length)), d = o[r] ?? null;
1817
+ t.insertBefore(i, d);
1818
+ const a = t.querySelector(
1613
1819
  ':scope > .dock-stack__pane[data-placeholder="true"]'
1614
1820
  );
1615
- l && i.nextElementSibling !== l && t.insertBefore(l, i.nextElementSibling);
1821
+ a && i.nextElementSibling !== a && t.insertBefore(a, i.nextElementSibling);
1616
1822
  }
1617
1823
  // Remove placeholder and restore the dragged tab's visibility.
1618
1824
  clearHeaderDragPlaceholder() {
@@ -1661,28 +1867,28 @@ class P extends A {
1661
1867
  if (i.floatingIndex !== null && i.floatingIndex >= 0)
1662
1868
  return;
1663
1869
  this.clearHeaderDragPlaceholder();
1664
- const o = this.resolveStackLocation(i.sourcePath);
1665
- if (!o)
1870
+ const n = this.resolveStackLocation(i.sourcePath);
1871
+ if (!n)
1666
1872
  return;
1667
- const n = i.pane, r = i.sourceStackEl ?? null, c = this.getBoundingClientRect(), l = r?.getBoundingClientRect() ?? null, s = this.pendingTabDragMetrics, a = 320, p = 240, h = s && Number.isFinite(s.width) && s.width > 0 ? s.width : l && Number.isFinite(l.width) ? l.width : a, d = s && Number.isFinite(s.height) && s.height > 0 ? s.height : l && Number.isFinite(l.height) ? l.height : p, g = 1, f = s && Number.isFinite(s.left) ? s.left - g : Number.isFinite(t) ? t - c.left - h / 2 : 0, u = s && Number.isFinite(s.top) ? s.top - g : Number.isFinite(e) ? e - c.top - d / 2 : 0, m = this.clampBoundsToHost(
1668
- { left: f, top: u, width: h, height: d },
1873
+ const o = i.pane, r = i.sourceStackEl ?? null, d = this.getBoundingClientRect(), a = r?.getBoundingClientRect() ?? null, c = this.pendingTabDragMetrics, l = 320, h = 240, u = c && Number.isFinite(c.width) && c.width > 0 ? c.width : a && Number.isFinite(a.width) ? a.width : l, f = c && Number.isFinite(c.height) && c.height > 0 ? c.height : a && Number.isFinite(a.height) ? a.height : h, p = 1, m = c && Number.isFinite(c.left) ? c.left - p : Number.isFinite(t) ? t - d.left - u / 2 : 0, g = c && Number.isFinite(c.top) ? c.top - p : Number.isFinite(e) ? e - d.top - f / 2 : 0, y = R(
1874
+ { left: m, top: g, width: u, height: f },
1669
1875
  this.getHostSize()
1670
- ), y = Number.isFinite(t) ? t - c.left - m.left : m.width / 2, b = Number.isFinite(e) ? e - c.top - m.top : m.height / 2;
1671
- this.removePaneFromLocation(o, n);
1672
- const S = {
1673
- bounds: m,
1876
+ ), b = Number.isFinite(t) ? t - d.left - y.left : y.width / 2, k = Number.isFinite(e) ? e - d.top - y.top : y.height / 2;
1877
+ this.removePaneFromLocation(n, o);
1878
+ const P = {
1879
+ bounds: y,
1674
1880
  root: {
1675
1881
  kind: "stack",
1676
- panes: [n],
1677
- activePane: n
1882
+ panes: [o],
1883
+ activePane: o
1678
1884
  },
1679
- activePane: n
1885
+ activePane: o
1680
1886
  };
1681
- this.floatingLayouts.push(S);
1682
- const v = this.floatingLayouts.length - 1;
1887
+ this.floatingLayouts.push(P);
1888
+ const z = this.floatingLayouts.length - 1;
1683
1889
  this.renderLayout();
1684
- const k = this.getFloatingWrapper(v);
1685
- k && this.promoteFloatingPane(v, k), this.liveAnnouncer.announce(`Pane ${this.titles[n] ?? n} torn off into a floating window.`), i.sourcePath = { type: "floating", index: v, segments: [] }, i.floatingIndex = v, i.pointerOffsetX = y, i.pointerOffsetY = b, this.markDraggedFloatingWrapper(), this.dispatchLayoutChanged();
1890
+ const v = this.getFloatingWrapper(z);
1891
+ v && this.promoteFloatingPane(z, v), this.liveAnnouncer.announce(`Pane ${this.titles[o] ?? o} torn off into a floating window.`), i.sourcePath = { type: "floating", index: z, segments: [] }, i.floatingIndex = z, i.pointerOffsetX = b, i.pointerOffsetY = k, this.markDraggedFloatingWrapper(), this.dispatchLayoutChanged();
1686
1892
  }
1687
1893
  // Toggle data-dragging on the floating wrapper currently associated with
1688
1894
  // the active pane drag (dragState.floatingIndex), if any. Used to make the
@@ -1709,54 +1915,52 @@ class P extends A {
1709
1915
  const i = this.getStackTabButtons(t);
1710
1916
  if (i.length === 0)
1711
1917
  return 0;
1712
- const n = t.querySelector(
1918
+ const o = t.querySelector(
1713
1919
  ':scope > .dock-tab[data-placeholder="true"]'
1714
- )?.dataset.tabId, r = n ? i.find((u) => u.id === `${n}-header-button`) ?? null : null, c = this.dragState?.pane ?? null;
1715
- let l = null;
1716
- if (c) {
1717
- for (const u of Array.from(t.children))
1718
- if (u instanceof HTMLElement && u.classList.contains("dock-tab") && !u.hasAttribute("data-placeholder") && u.dataset.pane === c) {
1719
- l = u.dataset.tabId ?? null;
1920
+ )?.dataset.tabId, r = o ? i.find((m) => m.id === `${o}-header-button`) ?? null : null, d = this.dragState?.pane ?? null;
1921
+ let a = null;
1922
+ if (d) {
1923
+ for (const m of Array.from(t.children))
1924
+ if (m instanceof HTMLElement && m.classList.contains("dock-tab") && !m.hasAttribute("data-placeholder") && m.dataset.pane === d) {
1925
+ a = m.dataset.tabId ?? null;
1720
1926
  break;
1721
1927
  }
1722
1928
  }
1723
- const s = l ? i.find((u) => u.id === `${l}-header-button`) ?? null : null, a = i.filter(
1724
- (u) => u !== r && u !== s
1929
+ const c = a ? i.find((m) => m.id === `${a}-header-button`) ?? null : null, l = i.filter(
1930
+ (m) => m !== r && m !== c
1725
1931
  );
1726
- if (a.length === 0)
1932
+ if (l.length === 0)
1727
1933
  return 0;
1728
- const p = 12, h = 0, d = r ? r.getBoundingClientRect() : null, f = !!d && Number.isFinite(d.width) && d.width > 0 && d ? d.left + d.width / 2 : null;
1729
- for (let u = 0; u < a.length; u += 1) {
1730
- const m = a[u].getBoundingClientRect(), y = m.left + m.width / 2, z = (f !== null ? y >= f : !1) ? y + p : y - h;
1731
- if (e < z)
1732
- return u;
1733
- }
1734
- return a.length;
1934
+ const h = r ? r.getBoundingClientRect() : null, f = !!h && Number.isFinite(h.width) && h.width > 0 && h ? h.left + h.width / 2 : null, p = l.map((m) => {
1935
+ const g = m.getBoundingClientRect();
1936
+ return g.left + g.width / 2;
1937
+ });
1938
+ return yt(p, e, f);
1735
1939
  }
1736
1940
  reorderPaneInLocationAtIndex(t, e, i) {
1737
- const o = t.node.panes, n = o.indexOf(e);
1738
- if (n === -1)
1941
+ const n = t.node.panes, o = n.indexOf(e);
1942
+ if (o === -1)
1739
1943
  return;
1740
- const r = Math.max(0, Math.min(i, o.length - 1));
1741
- if (r !== n && (o.splice(n, 1), o.splice(r, 0, e), t.node.activePane = e, t.context === "floating")) {
1742
- const c = this.floatingLayouts[t.index];
1743
- c && (c.activePane = e);
1944
+ const r = Math.max(0, Math.min(i, n.length - 1));
1945
+ if (r !== o && (n.splice(o, 1), n.splice(r, 0, e), t.node.activePane = e, t.context === "floating")) {
1946
+ const d = this.floatingLayouts[t.index];
1947
+ d && (d.activePane = e);
1744
1948
  }
1745
1949
  }
1746
1950
  // Commit a drop using current pointer coordinates and joystick state
1747
1951
  finalizeDropFromPoint(t, e) {
1748
1952
  if (!this.dragState)
1749
1953
  return;
1750
- const i = this.findStackAtPoint(t, e), o = i ? this.parsePath(i.dataset.path) : null, n = this.dropJoystick.dataset.visible === "true", r = this.parsePath(this.dropJoystick.dataset.path), c = this.dropJoystickTarget, l = c ? this.parsePath(c.dataset.path) : null, s = (n ? r ?? l : null) ?? o, a = this.dropJoystick.dataset.zone, p = this.isDropZone(a) ? a : i ? this.computeDropZone(i, { clientX: t, clientY: e }, null) : null;
1751
- if (this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && i && s && o && this.pathsEqual(o, this.dragState.sourcePath) && (!p || p === "center")) {
1752
- const h = this.resolveStackLocation(s);
1753
- if (h) {
1754
- const d = this.computeHeaderInsertIndex(i, t);
1755
- this.reorderPaneInLocationAtIndex(h, this.dragState.pane, d), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState.dropHandled = !0;
1954
+ const i = this.findStackAtPoint(t, e), n = i ? S(i.dataset.path) : null, o = this.dropJoystick.dataset.visible === "true", r = S(this.dropJoystick.dataset.path), d = this.dropJoystickTarget, a = d ? S(d.dataset.path) : null, c = (o ? r ?? a : null) ?? n, l = this.dropJoystick.dataset.zone, h = this.isDropZone(l) ? l : i ? this.computeDropZone(i, { clientX: t, clientY: e }, null) : null;
1955
+ if (this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && i && c && n && B(n, this.dragState.sourcePath) && (!h || h === "center")) {
1956
+ const u = this.resolveStackLocation(c);
1957
+ if (u) {
1958
+ const f = this.computeHeaderInsertIndex(i, t);
1959
+ this.reorderPaneInLocationAtIndex(u, this.dragState.pane, f), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState.dropHandled = !0;
1756
1960
  return;
1757
1961
  }
1758
1962
  }
1759
- s && this.isDropZone(p) && (this.handleDrop(s, p), this.dragState.dropHandled = !0);
1963
+ c && this.isDropZone(h) && (this.handleDrop(c, h), this.dragState.dropHandled = !0);
1760
1964
  }
1761
1965
  clearPendingDragEndTimeout() {
1762
1966
  if (this.pendingDragEndTimeout !== null) {
@@ -1779,107 +1983,80 @@ class P extends A {
1779
1983
  handleDrop(t, e) {
1780
1984
  if (!this.dragState || !t)
1781
1985
  return;
1782
- const { pane: i, sourcePath: o } = this.dragState, n = this.resolveStackLocation(o), r = this.resolveStackLocation(t);
1986
+ const { pane: i, sourcePath: n } = this.dragState, o = this.resolveStackLocation(n), r = this.resolveStackLocation(t);
1783
1987
  if (!r && t.type === "docked" && !this.rootLayout) {
1784
- if (!n)
1988
+ if (!o)
1785
1989
  return;
1786
- this.removePaneFromLocation(n, i, !0);
1787
- const l = {
1990
+ this.removePaneFromLocation(o, i, !0);
1991
+ const a = {
1788
1992
  kind: "stack",
1789
1993
  panes: [i],
1790
1994
  activePane: i
1791
1995
  };
1792
- this.rootLayout = l, this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1996
+ this.rootLayout = a, this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1793
1997
  return;
1794
1998
  }
1795
- if (!n || !r)
1999
+ if (!o || !r)
1796
2000
  return;
1797
- if (e === "center" && this.pathsEqual(o, t)) {
1798
- if (!n.node.panes.includes(i))
2001
+ if (e === "center" && B(n, t)) {
2002
+ if (!o.node.panes.includes(i))
1799
2003
  return;
1800
- this.reorderPaneInLocation(n, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
2004
+ this.reorderPaneInLocation(o, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1801
2005
  return;
1802
2006
  }
1803
- if (this.removePaneFromLocation(n, i, !0), e === "center") {
2007
+ if (this.removePaneFromLocation(o, i, !0), e === "center") {
1804
2008
  this.addPaneToLocation(r, i), this.setActivePaneForLocation(r, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1805
2009
  return;
1806
2010
  }
1807
- const c = {
2011
+ const d = {
1808
2012
  kind: "stack",
1809
2013
  panes: [i],
1810
2014
  activePane: i
1811
2015
  };
1812
2016
  if (r.context === "docked")
1813
- this.rootLayout = this.dockNodeBeside(this.rootLayout, r.node, c, e);
2017
+ this.rootLayout = _(this.rootLayout, r.node, d, e);
1814
2018
  else {
1815
- const l = this.floatingLayouts[r.index];
1816
- if (!l) {
2019
+ const a = this.floatingLayouts[r.index];
2020
+ if (!a) {
1817
2021
  this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged();
1818
2022
  return;
1819
2023
  }
1820
- l.root = this.dockNodeBeside(l.root, r.node, c, e), l.activePane = i;
2024
+ a.root = _(a.root, r.node, d, e), a.activePane = i;
1821
2025
  }
1822
2026
  this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1823
2027
  }
1824
2028
  handleFloatingStackDrop(t, e, i) {
1825
- const o = this.floatingLayouts[t];
1826
- if (!o || !o.root)
2029
+ const n = this.floatingLayouts[t];
2030
+ if (!n || !n.root)
1827
2031
  return !1;
1828
- const n = this.resolveStackLocation(e);
1829
- if (!n && e.type === "docked" && !this.rootLayout)
1830
- return this.rootLayout = this.cloneLayoutNode(o.root), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
1831
- if (!n || n.context === "floating" && n.index === t)
2032
+ const o = this.resolveStackLocation(e);
2033
+ if (!o && e.type === "docked" && !this.rootLayout)
2034
+ return this.rootLayout = F(n.root), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
2035
+ if (!o || o.context === "floating" && o.index === t)
1832
2036
  return !1;
1833
2037
  if (i === "center") {
1834
- const r = this.collectPaneNames(o.root);
2038
+ const r = I(n.root);
1835
2039
  if (r.length === 0)
1836
2040
  return !1;
1837
- r.forEach((l) => {
1838
- this.addPaneToLocation(n, l);
2041
+ r.forEach((a) => {
2042
+ this.addPaneToLocation(o, a);
1839
2043
  });
1840
- const c = o.activePane && r.includes(o.activePane) ? o.activePane : this.findFirstPaneName(o.root) ?? r[0];
1841
- return c && this.setActivePaneForLocation(n, c), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
2044
+ const d = n.activePane && r.includes(n.activePane) ? n.activePane : E(n.root) ?? r[0];
2045
+ return d && this.setActivePaneForLocation(o, d), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
1842
2046
  }
1843
- if (n.context === "floating") {
1844
- const r = this.floatingLayouts[n.index];
1845
- return r ? (r.root = this.dockNodeBeside(r.root, n.node, o.root, i), r.activePane = o.activePane ?? this.findFirstPaneName(o.root) ?? void 0, this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0) : !1;
2047
+ if (o.context === "floating") {
2048
+ const r = this.floatingLayouts[o.index];
2049
+ return r ? (r.root = _(r.root, o.node, n.root, i), r.activePane = n.activePane ?? E(n.root) ?? void 0, this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0) : !1;
1846
2050
  }
1847
- return this.rootLayout = this.dockNodeBeside(this.rootLayout, n.node, o.root, i), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
1848
- }
1849
- insertWeight(t, e, i) {
1850
- const o = i - 1, n = this.normalizeSizesArray(t, o), r = 1 / i, c = 1 - r, l = [];
1851
- for (let s = 0; s < i; s += 1)
1852
- if (s === e)
1853
- l.push(r);
1854
- else {
1855
- const a = s < e ? s : s - 1;
1856
- l.push(n[a] * c);
1857
- }
1858
- return l;
1859
- }
1860
- removePaneFromStack(t, e, i = !1) {
1861
- return t.panes = t.panes.filter((o) => o !== e), t.panes.includes(t.activePane ?? "") || (t.panes.length > 0 ? t.activePane = t.panes[0] : delete t.activePane), t.panes.length > 0 ? !1 : (i || this.normalizeAllLayouts(), !0);
1862
- }
1863
- findParentSplit(t, e) {
1864
- if (!t || t === e || t.kind !== "split")
1865
- return null;
1866
- const i = t.children.indexOf(e);
1867
- if (i !== -1)
1868
- return { parent: t, index: i };
1869
- for (let o = 0; o < t.children.length; o += 1) {
1870
- const n = this.findParentSplit(t.children[o], e);
1871
- if (n)
1872
- return n;
1873
- }
1874
- return null;
2051
+ return this.rootLayout = _(this.rootLayout, o.node, n.root, i), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
1875
2052
  }
1876
2053
  computeDropZone(t, e, i) {
1877
- const o = this.isDropZone(i) ? i : null;
1878
- if (o)
1879
- return this.updateDropJoystickActiveZone(o), o;
1880
- const n = e && Number.isFinite(e.clientX) && Number.isFinite(e.clientY) ? this.findDropZoneByPoint(e.clientX, e.clientY) : null;
2054
+ const n = this.isDropZone(i) ? i : null;
1881
2055
  if (n)
1882
2056
  return this.updateDropJoystickActiveZone(n), n;
2057
+ const o = e && Number.isFinite(e.clientX) && Number.isFinite(e.clientY) ? this.findDropZoneByPoint(e.clientX, e.clientY) : null;
2058
+ if (o)
2059
+ return this.updateDropJoystickActiveZone(o), o;
1883
2060
  if (this.dropJoystickTarget === t) {
1884
2061
  const r = this.dropJoystick.dataset.zone;
1885
2062
  if (this.isDropZone(r))
@@ -1925,64 +2102,64 @@ class P extends A {
1925
2102
  for (const i of this.dropJoystickButtons) {
1926
2103
  if (i.dataset.hidden === "true" || i.style.visibility === "hidden" || i.style.display === "none")
1927
2104
  continue;
1928
- const o = i.getBoundingClientRect();
1929
- if (t >= o.left && t <= o.right && e >= o.top && e <= o.bottom) {
1930
- const n = i.dataset.zone;
1931
- if (this.isDropZone(n))
1932
- return n;
2105
+ const n = i.getBoundingClientRect();
2106
+ if (t >= n.left && t <= n.right && e >= n.top && e <= n.bottom) {
2107
+ const o = i.dataset.zone;
2108
+ if (this.isDropZone(o))
2109
+ return o;
1933
2110
  }
1934
2111
  }
1935
2112
  return null;
1936
2113
  }
1937
2114
  updateDropJoystickActiveZone(t) {
1938
- const i = this.dropJoystick.dataset.visible === "true" ? this.dropJoystick.dataset.zone : void 0, o = t ?? (this.isDropZone(i) ? i : null);
1939
- this.dropJoystickButtons.forEach((n) => {
1940
- o !== null && n.dataset.zone === o ? n.dataset.active = "true" : delete n.dataset.active;
1941
- }), o ? this.dropJoystick.dataset.zone = o : delete this.dropJoystick.dataset.zone;
2115
+ const i = this.dropJoystick.dataset.visible === "true" ? this.dropJoystick.dataset.zone : void 0, n = t ?? (this.isDropZone(i) ? i : null);
2116
+ this.dropJoystickButtons.forEach((o) => {
2117
+ n !== null && o.dataset.zone === n ? o.dataset.active = "true" : delete o.dataset.active;
2118
+ }), n ? this.dropJoystick.dataset.zone = n : delete this.dropJoystick.dataset.zone;
1942
2119
  }
1943
2120
  isDropZone(t) {
1944
2121
  return t === "left" || t === "right" || t === "top" || t === "bottom" || t === "center";
1945
2122
  }
1946
2123
  showDropIndicator(t, e) {
1947
- const i = this.parsePath(t.dataset.path), o = this.dragState?.sourcePath ?? null;
1948
- if (i && o && this.isOrIsAncestorOf(i, o))
2124
+ const i = S(t.dataset.path), n = this.dragState?.sourcePath ?? null;
2125
+ if (i && n && bt(i, n))
1949
2126
  return;
1950
- const n = t.getBoundingClientRect(), r = this.getBoundingClientRect(), c = this.dropIndicator, l = this.dropJoystick;
1951
- l.hidden = !1;
1952
- const s = this.parsePath(t.dataset.path);
1953
- let a = 100;
1954
- s && s.type === "floating" && (a = this.getFloatingPaneZIndex(s.index) + 100), c.style.zIndex = String(a), l.style.zIndex = String(a + 1);
1955
- let p = n.left - r.left, h = n.top - r.top, d = n.width, g = n.height;
1956
- const f = 0.5;
2127
+ const o = t.getBoundingClientRect(), r = this.getBoundingClientRect(), d = this.dropIndicator, a = this.dropJoystick;
2128
+ a.hidden = !1;
2129
+ const c = S(t.dataset.path);
2130
+ let l = 100;
2131
+ c && c.type === "floating" && (l = H(this.floatingLayouts[c.index], c.index) + 100), d.style.zIndex = String(l), a.style.zIndex = String(l + 1);
2132
+ let h = o.left - r.left, u = o.top - r.top, f = o.width, p = o.height;
2133
+ const m = 0.5;
1957
2134
  if (e) {
1958
2135
  switch (e) {
1959
2136
  case "left":
1960
- d = n.width * f;
2137
+ f = o.width * m;
1961
2138
  break;
1962
2139
  case "right":
1963
- d = n.width * f, p += n.width * (1 - f);
2140
+ f = o.width * m, h += o.width * (1 - m);
1964
2141
  break;
1965
2142
  case "top":
1966
- g = n.height * f;
2143
+ p = o.height * m;
1967
2144
  break;
1968
2145
  case "bottom":
1969
- g = n.height * f, h += n.height * (1 - f);
2146
+ p = o.height * m, u += o.height * (1 - m);
1970
2147
  break;
1971
2148
  }
1972
- c.style.left = `${p}px`, c.style.top = `${h}px`, c.style.width = `${d}px`, c.style.height = `${g}px`, c.dataset.visible = "true";
2149
+ d.style.left = `${h}px`, d.style.top = `${u}px`, d.style.width = `${f}px`, d.style.height = `${p}px`, d.dataset.visible = "true";
1973
2150
  } else
1974
- c.dataset.visible = "false";
1975
- l.style.left = `${n.left - r.left + n.width / 2}px`, l.style.top = `${n.top - r.top + n.height / 2}px`, l.dataset.visible = "true", this.dropJoystick.style.display = "grid", l.dataset.path = t.dataset.path ?? "";
1976
- const u = this.dropJoystickTarget && this.dropJoystickTarget !== t;
1977
- this.dropJoystickTarget = t, u && delete this.dropJoystick.dataset.zone;
1978
- const m = !this.rootLayout && (t === this.dockedEl || i && i.type === "docked" && i.segments.length === 0), y = Array.from(this.dropJoystick.querySelectorAll(".dock-drop-joystick__spacer"));
1979
- m ? (y.forEach((b) => {
1980
- b.style.display = "";
1981
- }), this.dropJoystickButtons.forEach((b) => {
1982
- b.dataset.zone === "center" ? (b.style.visibility = "", b.style.pointerEvents = "", delete b.dataset.hidden, b.style.display = "") : (b.style.visibility = "hidden", b.style.pointerEvents = "none", b.dataset.hidden = "true", b.style.display = "");
1983
- }), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = "") : (this.dropJoystickButtons.forEach((b) => {
1984
- b.style.visibility = "", b.style.pointerEvents = "", delete b.dataset.hidden, b.style.display = "";
1985
- }), y.forEach((b) => b.style.display = ""), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = ""), this.updateDropJoystickActiveZone(e);
2151
+ d.dataset.visible = "false";
2152
+ a.style.left = `${o.left - r.left + o.width / 2}px`, a.style.top = `${o.top - r.top + o.height / 2}px`, a.dataset.visible = "true", this.dropJoystick.style.display = "grid", a.dataset.path = t.dataset.path ?? "";
2153
+ const g = this.dropJoystickTarget && this.dropJoystickTarget !== t;
2154
+ this.dropJoystickTarget = t, g && delete this.dropJoystick.dataset.zone;
2155
+ const y = !this.rootLayout && (t === this.dockedEl || i && i.type === "docked" && i.segments.length === 0), b = Array.from(this.dropJoystick.querySelectorAll(".dock-drop-joystick__spacer"));
2156
+ y ? (b.forEach((k) => {
2157
+ k.style.display = "";
2158
+ }), this.dropJoystickButtons.forEach((k) => {
2159
+ k.dataset.zone === "center" ? (k.style.visibility = "", k.style.pointerEvents = "", delete k.dataset.hidden, k.style.display = "") : (k.style.visibility = "hidden", k.style.pointerEvents = "none", k.dataset.hidden = "true", k.style.display = "");
2160
+ }), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = "") : (this.dropJoystickButtons.forEach((k) => {
2161
+ k.style.visibility = "", k.style.pointerEvents = "", delete k.dataset.hidden, k.style.display = "";
2162
+ }), b.forEach((k) => k.style.display = ""), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = ""), this.updateDropJoystickActiveZone(e);
1986
2163
  }
1987
2164
  hideDropIndicator() {
1988
2165
  this.dropIndicator.dataset.visible = "false", this.dropJoystick.dataset.visible = "false", this.dropJoystick.style.display = "none", delete this.dropJoystick.dataset.path, this.dropJoystickTarget = null, this.updateDropJoystickActiveZone(null), this.dropJoystickButtons.forEach((t) => {
@@ -1993,9 +2170,9 @@ class P extends A {
1993
2170
  const i = this.shadowRoot;
1994
2171
  if (!i)
1995
2172
  return null;
1996
- const o = i.elementsFromPoint(t, e), n = this.findStackInTargets(o);
1997
- if (n)
1998
- return n;
2173
+ const n = i.elementsFromPoint(t, e), o = this.findStackInTargets(n);
2174
+ if (o)
2175
+ return o;
1999
2176
  if (!this.rootLayout) {
2000
2177
  const r = this.dockedEl.getBoundingClientRect();
2001
2178
  if (t >= r.left && t <= r.right && e >= r.top && e <= r.bottom)
@@ -2020,122 +2197,15 @@ class P extends A {
2020
2197
  )?.dataset.tabId;
2021
2198
  r && t.setAttribute("active-tab", r);
2022
2199
  }
2023
- const o = this.resolveStackLocation(i);
2024
- if (o) {
2025
- if (o.node.activePane = e, i.type === "floating") {
2026
- const n = this.floatingLayouts[i.index];
2027
- n && (n.activePane = e), this.updateFloatingWindowTitle(i.index);
2200
+ const n = this.resolveStackLocation(i);
2201
+ if (n) {
2202
+ if (n.node.activePane = e, i.type === "floating") {
2203
+ const o = this.floatingLayouts[i.index];
2204
+ o && (o.activePane = e), this.updateFloatingWindowTitle(i.index);
2028
2205
  }
2029
2206
  this.dispatchLayoutChanged();
2030
2207
  }
2031
2208
  }
2032
- getNodeAtPath(t, e) {
2033
- if (!t)
2034
- return null;
2035
- let i = t;
2036
- if (e.length === 0)
2037
- return i;
2038
- for (const o of e) {
2039
- if (!i || i.kind !== "split")
2040
- return null;
2041
- i = i.children[o] ?? null;
2042
- }
2043
- return i;
2044
- }
2045
- resolveSplitNode(t) {
2046
- if (t.type === "docked") {
2047
- const o = this.getNodeAtPath(this.rootLayout, t.segments);
2048
- return o && o.kind === "split" ? o : null;
2049
- }
2050
- const e = this.floatingLayouts[t.index];
2051
- if (!e || !e.root)
2052
- return null;
2053
- const i = this.getNodeAtPath(e.root, t.segments);
2054
- return i && i.kind === "split" ? i : null;
2055
- }
2056
- replaceNodeInTree(t, e, i) {
2057
- if (!t || t === e)
2058
- return i;
2059
- const o = this.findParentSplit(t, e);
2060
- return o && (o.parent.children[o.index] = i, this.normalizeSplitNode(o.parent)), t;
2061
- }
2062
- dockNodeBeside(t, e, i, o) {
2063
- const n = o === "left" || o === "right" ? "horizontal" : "vertical", r = o === "left" || o === "top", c = this.findParentSplit(t, e);
2064
- if (c && c.parent.direction === n) {
2065
- const s = r ? c.index : c.index + 1;
2066
- return c.parent.children.splice(s, 0, i), c.parent.sizes = this.insertWeight(
2067
- c.parent.sizes,
2068
- s,
2069
- c.parent.children.length
2070
- ), t ?? i;
2071
- }
2072
- const l = {
2073
- kind: "split",
2074
- direction: n,
2075
- children: r ? [i, e] : [e, i],
2076
- sizes: [0.5, 0.5]
2077
- };
2078
- return this.replaceNodeInTree(t, e, l);
2079
- }
2080
- forEachStack(t, e, i = []) {
2081
- if (t) {
2082
- if (t.kind === "stack") {
2083
- e(t, i);
2084
- return;
2085
- }
2086
- t.children.forEach(
2087
- (o, n) => this.forEachStack(o, e, [...i, n])
2088
- );
2089
- }
2090
- }
2091
- findStackContainingPane(t, e) {
2092
- let i = null;
2093
- return this.forEachStack(t, (o) => {
2094
- !i && o.panes.includes(e) && (i = o);
2095
- }), i;
2096
- }
2097
- findFirstPaneName(t) {
2098
- let e = null;
2099
- return this.forEachStack(t, (i) => {
2100
- e || i.panes.length === 0 || (i.activePane && i.panes.includes(i.activePane) ? e = i.activePane : e = i.panes[0]);
2101
- }), e;
2102
- }
2103
- collectFloatingPaneMetadata(t) {
2104
- const e = this.collectPaneNames(t), i = {};
2105
- return e.forEach((o) => {
2106
- const n = this.titles[o];
2107
- n && (i[o] = n);
2108
- }), { panes: e, titles: i };
2109
- }
2110
- collectPaneNames(t) {
2111
- const e = [];
2112
- return this.forEachStack(t, (i) => {
2113
- i.panes.forEach((o) => e.push(o));
2114
- }), e;
2115
- }
2116
- normalizeFloatingLayout(t) {
2117
- const e = t.bounds ?? { left: 0, top: 0, width: 320, height: 200 }, i = {
2118
- left: Number.isFinite(e.left) ? e.left : 0,
2119
- top: Number.isFinite(e.top) ? e.top : 0,
2120
- width: Number.isFinite(e.width) ? Math.max(e.width, 160) : 320,
2121
- height: Number.isFinite(e.height) ? Math.max(e.height, 120) : 200
2122
- }, o = t.root ? this.cloneLayoutNode(t.root) : null;
2123
- return {
2124
- id: t.id,
2125
- bounds: i,
2126
- zIndex: t.zIndex,
2127
- root: o,
2128
- activePane: t.activePane
2129
- };
2130
- }
2131
- formatPath(t) {
2132
- if (t.type === "floating") {
2133
- const i = t.segments.length > 0 ? `/${t.segments.map((o) => o.toString()).join("/")}` : "";
2134
- return `f:${t.index}${i}`;
2135
- }
2136
- const e = t.segments.join("/");
2137
- return e.length > 0 ? `d:${e}` : "d:";
2138
- }
2139
2209
  // Layer identity of a splitter in the rendered shadow tree. Splitters inside
2140
2210
  // floating pane N are nested under `.dock-floating[data-path="f:N"]`;
2141
2211
  // docked-layer splitters have no such ancestor. Two splitters share a layer
@@ -2146,55 +2216,27 @@ class P extends A {
2146
2216
  const e = t.closest(".dock-floating");
2147
2217
  return e ? e.dataset.path ?? "f:?" : "d";
2148
2218
  }
2149
- clonePath(t) {
2150
- return t.type === "floating" ? { type: "floating", index: t.index, segments: [...t.segments] } : { type: "docked", segments: [...t.segments] };
2151
- }
2152
- parsePath(t) {
2153
- if (t == null)
2154
- return null;
2155
- if (t.startsWith("f:")) {
2156
- const o = t.slice(2), [n, ...r] = o.split("/"), c = Number.parseInt(n, 10);
2157
- if (!Number.isFinite(c))
2158
- return null;
2159
- const l = r.filter((s) => s.length > 0).map((s) => Number.parseInt(s, 10)).filter((s) => Number.isFinite(s));
2160
- return { type: "floating", index: c, segments: l };
2161
- }
2162
- const e = t.startsWith("d:") ? t.slice(2) : t;
2163
- return e.length === 0 ? { type: "docked", segments: [] } : { type: "docked", segments: e.split("/").filter((o) => o.length > 0).map((o) => Number.parseInt(o, 10)).filter((o) => Number.isFinite(o)) };
2164
- }
2165
- pathsEqual(t, e) {
2166
- if (t.type !== e.type)
2167
- return !1;
2168
- if (t.type === "floating") {
2169
- const o = e;
2170
- return t.index !== o.index || t.segments.length !== o.segments.length ? !1 : t.segments.every((n, r) => n === o.segments[r]);
2171
- }
2172
- const i = e;
2173
- return t.segments.length !== i.segments.length ? !1 : t.segments.every((o, n) => o === i.segments[n]);
2174
- }
2175
- isOrIsAncestorOf(t, e) {
2176
- return t.type !== e.type || t.type === "floating" && e.index !== t.index || t.segments.length > e.segments.length ? !1 : t.segments.every((i, o) => i === e.segments[o]);
2177
- }
2178
- countPanesInTree(t) {
2179
- return t ? t.kind === "stack" ? t.panes.length : t.children.reduce((e, i) => e + this.countPanesInTree(i), 0) : 0;
2180
- }
2181
2219
  resolveStackLocation(t) {
2182
2220
  if (t.type === "floating") {
2183
2221
  const i = this.floatingLayouts[t.index];
2184
2222
  if (!i || !i.root)
2185
2223
  return null;
2186
- const o = this.getNodeAtPath(i.root, t.segments);
2187
- return !o || o.kind !== "stack" ? null : { context: "floating", index: t.index, path: [...t.segments], node: o };
2224
+ const n = M(i.root, t.segments);
2225
+ return !n || n.kind !== "stack" ? null : { context: "floating", index: t.index, path: [...t.segments], node: n };
2188
2226
  }
2189
- const e = this.getNodeAtPath(this.rootLayout, t.segments);
2227
+ const e = M(this.rootLayout, t.segments);
2190
2228
  return !e || e.kind !== "stack" ? null : { context: "docked", path: [...t.segments], node: e };
2191
2229
  }
2192
2230
  removePaneFromLocation(t, e, i = !1) {
2193
- return t.context === "docked" ? this.removePaneFromStack(t.node, e, i) : this.removePaneFromFloating(t.index, t.path, e, i);
2231
+ if (t.context === "docked") {
2232
+ const n = ht(t.node, e);
2233
+ return n && !i && this.normalizeAllLayouts(), n;
2234
+ }
2235
+ return this.removePaneFromFloating(t.index, t.path, e, i);
2194
2236
  }
2195
2237
  addPaneToLocation(t, e) {
2196
- const i = t.node.panes, o = i.indexOf(e);
2197
- o !== -1 && i.splice(o, 1), i.push(e);
2238
+ const i = t.node.panes, n = i.indexOf(e);
2239
+ n !== -1 && i.splice(n, 1), i.push(e);
2198
2240
  }
2199
2241
  setActivePaneForLocation(t, e) {
2200
2242
  if (t.node.activePane = e, t.context === "floating") {
@@ -2203,10 +2245,10 @@ class P extends A {
2203
2245
  }
2204
2246
  }
2205
2247
  reorderPaneInLocation(t, e) {
2206
- const i = t.node.panes, o = i.indexOf(e);
2207
- if (o !== -1 && (i.splice(o, 1), i.push(e), t.node.activePane = e, t.context === "floating")) {
2208
- const n = this.floatingLayouts[t.index];
2209
- n && (n.activePane = e);
2248
+ const i = t.node.panes, n = i.indexOf(e);
2249
+ if (n !== -1 && (i.splice(n, 1), i.push(e), t.node.activePane = e, t.context === "floating")) {
2250
+ const o = this.floatingLayouts[t.index];
2251
+ o && (o.activePane = e);
2210
2252
  }
2211
2253
  }
2212
2254
  removeFloatingAt(t) {
@@ -2259,14 +2301,14 @@ class P extends A {
2259
2301
  const e = t.composedPath()[0];
2260
2302
  if (e instanceof HTMLElement && (e.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(e.tagName)))
2261
2303
  return;
2262
- const o = {
2304
+ const n = {
2263
2305
  ArrowRight: 1,
2264
2306
  ArrowDown: 1,
2265
2307
  ArrowLeft: -1,
2266
2308
  ArrowUp: -1
2267
2309
  }[t.key];
2268
- if (o) {
2269
- t.preventDefault(), t.stopPropagation(), this.cyclePaneMoveCandidate(o);
2310
+ if (n) {
2311
+ t.preventDefault(), t.stopPropagation(), this.cyclePaneMoveCandidate(n);
2270
2312
  return;
2271
2313
  }
2272
2314
  if (t.key === "Enter") {
@@ -2274,14 +2316,14 @@ class P extends A {
2274
2316
  t.preventDefault(), t.stopPropagation(), this.commitHighlightedPaneMoveCandidate();
2275
2317
  return;
2276
2318
  }
2277
- const n = t.key.toLowerCase(), c = {
2319
+ const o = t.key.toLowerCase(), d = {
2278
2320
  t: "top",
2279
2321
  r: "right",
2280
2322
  b: "bottom",
2281
2323
  l: "left",
2282
2324
  f: "float"
2283
- }[n];
2284
- c && (t.preventDefault(), t.stopPropagation(), c === "float" ? this.commitPaneMoveAsFloat() : this.commitPaneMoveToZone(c));
2325
+ }[o];
2326
+ d && (t.preventDefault(), t.stopPropagation(), d === "float" ? this.commitPaneMoveAsFloat() : this.commitPaneMoveToZone(d));
2285
2327
  }
2286
2328
  /**
2287
2329
  * Enumerated keyboard drop targets, in cycle order: every docked leaf stack
@@ -2296,16 +2338,16 @@ class P extends A {
2296
2338
  * land exactly where a pointer drop on that stack would.
2297
2339
  */
2298
2340
  buildPaneMoveCandidates() {
2299
- const t = this.paneMoveMode ? this.formatPath(this.paneMoveMode.sourcePath) : null, e = [];
2300
- return this.forEachStack(this.rootLayout, (i, o) => {
2301
- const n = this.formatPath({ type: "docked", segments: o });
2302
- n !== t && e.push({
2303
- pathStr: n,
2341
+ const t = this.paneMoveMode ? w(this.paneMoveMode.sourcePath) : null, e = [];
2342
+ return N(this.rootLayout, (i, n) => {
2343
+ const o = w({ type: "docked", segments: n });
2344
+ o !== t && e.push({
2345
+ pathStr: o,
2304
2346
  targetTitles: i.panes.map((r) => this.titles[r] ?? r).join(", ")
2305
2347
  });
2306
2348
  }), [
2307
2349
  ...e.flatMap(
2308
- ({ pathStr: i, targetTitles: o }) => P.PANE_MOVE_ZONE_ORDER.map((n) => ({ pathStr: i, zone: n, targetTitles: o }))
2350
+ ({ pathStr: i, targetTitles: n }) => L.PANE_MOVE_ZONE_ORDER.map((o) => ({ pathStr: i, zone: o, targetTitles: n }))
2309
2351
  ),
2310
2352
  { pathStr: null, zone: "float", targetTitles: "" }
2311
2353
  ];
@@ -2313,12 +2355,12 @@ class P extends A {
2313
2355
  cyclePaneMoveCandidate(t) {
2314
2356
  const e = this.buildPaneMoveCandidates();
2315
2357
  if (e.length === 0) return;
2316
- const i = this.paneMoveCandidateIndex, o = i === null ? t > 0 ? 0 : e.length - 1 : (i + t + e.length) % e.length;
2317
- this.paneMoveCandidateIndex = o;
2318
- const n = e[o];
2319
- this.highlightPaneMoveCandidate(n);
2320
- const r = n.zone === "float" ? "Float" : `${n.zone[0].toUpperCase()}${n.zone.slice(1)} of ${n.targetTitles}`;
2321
- this.liveAnnouncer.announce(`${r}, option ${o + 1} of ${e.length}.`);
2358
+ const i = this.paneMoveCandidateIndex, n = i === null ? t > 0 ? 0 : e.length - 1 : (i + t + e.length) % e.length;
2359
+ this.paneMoveCandidateIndex = n;
2360
+ const o = e[n];
2361
+ this.highlightPaneMoveCandidate(o);
2362
+ const r = o.zone === "float" ? "Float" : `${o.zone[0].toUpperCase()}${o.zone.slice(1)} of ${o.targetTitles}`;
2363
+ this.liveAnnouncer.announce(`${r}, option ${n + 1} of ${e.length}.`);
2322
2364
  }
2323
2365
  highlightPaneMoveCandidate(t) {
2324
2366
  if (this.hideDropIndicator(), t.zone === "float" || !t.pathStr) return;
@@ -2341,7 +2383,7 @@ class P extends A {
2341
2383
  this.commitPaneMoveAsFloat();
2342
2384
  return;
2343
2385
  }
2344
- this.commitPaneMoveToZone(e.zone, this.parsePath(e.pathStr));
2386
+ this.commitPaneMoveToZone(e.zone, S(e.pathStr));
2345
2387
  }
2346
2388
  /** Sole exit point for move mode: drops the arming AND any highlight together. */
2347
2389
  clearPaneMoveState() {
@@ -2362,10 +2404,10 @@ class P extends A {
2362
2404
  `.dock-tab[data-tab-id="${e}"]`
2363
2405
  );
2364
2406
  if (!i) return null;
2365
- const o = i.closest(".dock-stack");
2366
- if (!o) return null;
2367
- const n = this.parsePath(o.dataset.path);
2368
- return n ? { paneName: i.dataset.pane, sourcePath: n } : null;
2407
+ const n = i.closest(".dock-stack");
2408
+ if (!n) return null;
2409
+ const o = S(n.dataset.path);
2410
+ return o ? { paneName: i.dataset.pane, sourcePath: o } : null;
2369
2411
  }
2370
2412
  /**
2371
2413
  * Synthesise a minimal dragState so handleDrop's existing pipeline can
@@ -2376,7 +2418,7 @@ class P extends A {
2376
2418
  synthesiseDragStateForKeyboardMove() {
2377
2419
  this.paneMoveMode && (this.dragState = {
2378
2420
  pane: this.paneMoveMode.paneName,
2379
- sourcePath: this.clonePath(this.paneMoveMode.sourcePath),
2421
+ sourcePath: T(this.paneMoveMode.sourcePath),
2380
2422
  floatingIndex: this.paneMoveMode.sourcePath.type === "floating" ? this.paneMoveMode.sourcePath.index : null,
2381
2423
  pointerOffsetX: 0,
2382
2424
  pointerOffsetY: 0,
@@ -2396,11 +2438,11 @@ class P extends A {
2396
2438
  if (!this.paneMoveMode) return;
2397
2439
  const i = this.paneMoveMode;
2398
2440
  this.synthesiseDragStateForKeyboardMove(), this.handleDrop(e ?? i.sourcePath, t);
2399
- const o = this.dragState?.dropHandled === !0;
2441
+ const n = this.dragState?.dropHandled === !0;
2400
2442
  this.dragState = null, this.clearPaneMoveState();
2401
- const n = this.titles[i.paneName] ?? i.paneName;
2443
+ const o = this.titles[i.paneName] ?? i.paneName;
2402
2444
  this.liveAnnouncer.announce(
2403
- o ? `Pane ${n} docked to ${t}.` : `Move failed. Pane ${n} was not moved.`
2445
+ n ? `Pane ${o} docked to ${t}.` : `Move failed. Pane ${o} was not moved.`
2404
2446
  );
2405
2447
  }
2406
2448
  commitPaneMoveAsFloat() {
@@ -2422,8 +2464,8 @@ class P extends A {
2422
2464
  activePane: t.paneName
2423
2465
  };
2424
2466
  this.floatingLayouts.push(i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.clearPaneMoveState();
2425
- const o = this.titles[t.paneName] ?? t.paneName;
2426
- this.liveAnnouncer.announce(`Pane ${o} torn off into a floating window.`);
2467
+ const n = this.titles[t.paneName] ?? t.paneName;
2468
+ this.liveAnnouncer.announce(`Pane ${n} torn off into a floating window.`);
2427
2469
  }
2428
2470
  /**
2429
2471
  * Close a floating pane via the chrome's close button (or any external
@@ -2438,61 +2480,18 @@ class P extends A {
2438
2480
  const i = this.getFloatingWindowTitle(e);
2439
2481
  this.removeFloatingAt(t), this.renderLayout(), this.dispatchLayoutChanged(), this.liveAnnouncer.announce(`Closed floating pane ${i}.`);
2440
2482
  }
2441
- removePaneFromFloating(t, e, i, o = !1) {
2442
- const n = this.floatingLayouts[t];
2443
- if (!n || !n.root)
2483
+ removePaneFromFloating(t, e, i, n = !1) {
2484
+ const o = this.floatingLayouts[t];
2485
+ if (!o || !o.root)
2444
2486
  return !1;
2445
- const r = this.getNodeAtPath(n.root, e);
2487
+ const r = M(o.root, e);
2446
2488
  if (!r || r.kind !== "stack")
2447
2489
  return !1;
2448
- if (r.panes = r.panes.filter((c) => c !== i), r.panes.includes(r.activePane ?? "") || (r.panes.length > 0 ? r.activePane = r.panes[0] : delete r.activePane), n.activePane === i) {
2449
- const c = this.findFirstPaneName(n.root);
2450
- c ? n.activePane = c : delete n.activePane;
2490
+ if (r.panes = r.panes.filter((d) => d !== i), r.panes.includes(r.activePane ?? "") || (r.panes.length > 0 ? r.activePane = r.panes[0] : delete r.activePane), o.activePane === i) {
2491
+ const d = E(o.root);
2492
+ d ? o.activePane = d : delete o.activePane;
2451
2493
  }
2452
- return r.panes.length > 0 ? !1 : (o || this.normalizeAllLayouts(), !0);
2453
- }
2454
- normalizeSizesArray(t, e) {
2455
- if (e <= 0)
2456
- return [];
2457
- if (!Array.isArray(t) || t.length !== e)
2458
- return Array.from({ length: e }, () => 1 / e);
2459
- const i = t.map((n) => Number.isFinite(n) ? Math.max(n, 0) : 0), o = i.reduce((n, r) => n + r, 0);
2460
- return o <= 0 ? Array.from({ length: e }, () => 1 / e) : i.map((n) => n / o);
2461
- }
2462
- normalizeSplitNode(t) {
2463
- t.sizes = this.normalizeSizesArray(t.sizes, t.children.length);
2464
- }
2465
- /**
2466
- * Bottom-up layout sanitizer. Returns a normalized version of `node` where:
2467
- * - Empty stacks (panes.length === 0) are dropped (returned as null).
2468
- * - A stack's `activePane` is repaired if it no longer references one of `panes`.
2469
- * - Splits whose direction matches a child split are flattened, with sizes
2470
- * combined multiplicatively so the resulting on-screen pixel layout is
2471
- * identical to the pre-merge one.
2472
- * - Splits with 0 children become null. Splits with 1 child are unwrapped.
2473
- *
2474
- * Idempotent: passing the result back through this method yields the same
2475
- * structure. Mutates the input tree in place but only returns nodes that
2476
- * remain part of the layout.
2477
- */
2478
- normalizeLayoutNode(t) {
2479
- if (!t) return null;
2480
- if (t.kind === "stack")
2481
- return t.panes.length === 0 ? null : ((!t.activePane || !t.panes.includes(t.activePane)) && (t.activePane = t.panes[0]), t);
2482
- const e = this.normalizeSizesArray(t.sizes, t.children.length), i = t.children.map((o, n) => ({ child: this.normalizeLayoutNode(o), slot: e[n] })).filter((o) => o.child !== null).flatMap(({ child: o, slot: n }) => {
2483
- if (o.kind === "split" && o.direction === t.direction) {
2484
- const r = this.normalizeSizesArray(o.sizes, o.children.length);
2485
- return o.children.map((c, l) => ({
2486
- child: c,
2487
- slot: n * r[l]
2488
- }));
2489
- }
2490
- return [{ child: o, slot: n }];
2491
- });
2492
- return i.length === 0 ? null : i.length === 1 ? i[0].child : (t.children = i.map((o) => o.child), t.sizes = this.normalizeSizesArray(
2493
- i.map((o) => o.slot),
2494
- i.length
2495
- ), t);
2494
+ return r.panes.length > 0 ? !1 : (n || this.normalizeAllLayouts(), !0);
2496
2495
  }
2497
2496
  /**
2498
2497
  * Apply `normalizeLayoutNode` to `rootLayout` and every floating window's
@@ -2502,11 +2501,11 @@ class P extends A {
2502
2501
  * pane removal) so the tree the renderer sees is always in canonical form.
2503
2502
  */
2504
2503
  normalizeAllLayouts() {
2505
- this.rootLayout = this.normalizeLayoutNode(this.rootLayout), this.floatingLayouts = this.floatingLayouts.map((t) => {
2506
- if (t.root = this.normalizeLayoutNode(t.root), !t.root) return null;
2507
- const e = this.collectPaneNames(t.root);
2504
+ this.rootLayout = $(this.rootLayout), this.floatingLayouts = this.floatingLayouts.map((t) => {
2505
+ if (t.root = $(t.root), !t.root) return null;
2506
+ const e = I(t.root);
2508
2507
  if (!t.activePane || !e.includes(t.activePane)) {
2509
- const i = this.findFirstPaneName(t.root);
2508
+ const i = E(t.root);
2510
2509
  i ? t.activePane = i : delete t.activePane;
2511
2510
  }
2512
2511
  return t;
@@ -2525,14 +2524,14 @@ class P extends A {
2525
2524
  const t = this.shadowRoot;
2526
2525
  if (!t) return;
2527
2526
  const e = new Set(
2528
- Array.from(t.querySelectorAll("slot")).map((n) => n.getAttribute("name")).filter((n) => !!n)
2529
- ), o = [
2530
- ...this.collectPaneNames(this.rootLayout),
2531
- ...this.floatingLayouts.flatMap((n) => this.collectPaneNames(n.root))
2532
- ].find((n) => !e.has(n));
2533
- if (o)
2527
+ Array.from(t.querySelectorAll("slot")).map((o) => o.getAttribute("name")).filter((o) => !!o)
2528
+ ), n = [
2529
+ ...I(this.rootLayout),
2530
+ ...this.floatingLayouts.flatMap((o) => I(o.root))
2531
+ ].find((o) => !e.has(o));
2532
+ if (n)
2534
2533
  throw new Error(
2535
- `mint-dock-manager: pane "${o}" has no projection slot in the shadow DOM. The layout tree got into a state the renderer can't display — likely a missing normalize() call or a render bug.`
2534
+ `mint-dock-manager: pane "${n}" has no projection slot in the shadow DOM. The layout tree got into a state the renderer can't display — likely a missing normalize() call or a render bug.`
2536
2535
  );
2537
2536
  }
2538
2537
  dispatchLayoutChanged() {
@@ -2544,15 +2543,12 @@ class P extends A {
2544
2543
  })
2545
2544
  );
2546
2545
  }
2547
- cloneLayoutNode(t) {
2548
- return t ? JSON.parse(JSON.stringify(t)) : null;
2549
- }
2550
2546
  cloneFloatingArray(t) {
2551
2547
  return JSON.parse(JSON.stringify(t));
2552
2548
  }
2553
2549
  }
2554
- const x = "mint-dock-manager";
2555
- typeof customElements < "u" && !customElements.get(x) && customElements.define(x, P);
2550
+ const K = "mint-dock-manager";
2551
+ typeof customElements < "u" && !customElements.get(K) && customElements.define(K, L);
2556
2552
  export {
2557
- P as MintDockManagerElement
2553
+ L as MintDockManagerElement
2558
2554
  };