@mintplayer/web-components 2.12.0 → 2.14.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.
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 W, unsafeCSS as U, LitElement as G } 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 V } from "../chunks/live-announcer-Bi0orG4n.mjs";
5
+ import { F as Q } from "../chunks/focus-restore-DxuP1Oe2.mjs";
6
+ const tt = W`<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>`, et = U(`:host {
58
58
  display: block;
59
59
  position: relative;
60
60
  width: 100%;
@@ -427,21 +427,221 @@ const I = D`<div class="dock-root">
427
427
  animation: none !important;
428
428
  }
429
429
  }`);
430
- class P extends A {
430
+ function R(a, t) {
431
+ if (t.width <= 0 || t.height <= 0) return a;
432
+ const e = Math.min(a.width, t.width), i = Math.min(a.height, t.height), n = Math.min(Math.max(a.left, 0), t.width - e), o = Math.min(Math.max(a.top, 0), t.height - i);
433
+ return { left: n, top: o, width: e, height: i };
434
+ }
435
+ function J(a, t, e) {
436
+ return t >= a.left && t <= a.right && e >= a.top && e <= a.bottom;
437
+ }
438
+ function N(a, t) {
439
+ return a && typeof a.zIndex == "number" && Number.isFinite(a.zIndex) ? a.zIndex : 10 + t;
440
+ }
441
+ function x(a, t) {
442
+ if (t <= 0)
443
+ return [];
444
+ if (!Array.isArray(a) || a.length !== t)
445
+ return Array.from({ length: t }, () => 1 / t);
446
+ const e = a.map((n) => Number.isFinite(n) ? Math.max(n, 0) : 0), i = e.reduce((n, o) => n + o, 0);
447
+ return i <= 0 ? Array.from({ length: t }, () => 1 / t) : e.map((n) => n / i);
448
+ }
449
+ function it(a) {
450
+ a.sizes = x(a.sizes, a.children.length);
451
+ }
452
+ function nt(a, t, e) {
453
+ const i = e - 1, n = x(a, i), o = 1 / e, r = 1 - o, d = [];
454
+ for (let s = 0; s < e; s += 1)
455
+ if (s === t)
456
+ d.push(o);
457
+ else {
458
+ const c = s < t ? s : s - 1;
459
+ d.push(n[c] * r);
460
+ }
461
+ return d;
462
+ }
463
+ function T(a, t) {
464
+ if (!a)
465
+ return null;
466
+ let e = a;
467
+ if (t.length === 0)
468
+ return e;
469
+ for (const i of t) {
470
+ if (!e || e.kind !== "split")
471
+ return null;
472
+ e = e.children[i] ?? null;
473
+ }
474
+ return e;
475
+ }
476
+ function B(a, t) {
477
+ if (!a || a === t || a.kind !== "split")
478
+ return null;
479
+ const e = a.children.indexOf(t);
480
+ if (e !== -1)
481
+ return { parent: a, index: e };
482
+ for (let i = 0; i < a.children.length; i += 1) {
483
+ const n = B(a.children[i], t);
484
+ if (n)
485
+ return n;
486
+ }
487
+ return null;
488
+ }
489
+ function ot(a, t, e) {
490
+ if (!a || a === t)
491
+ return e;
492
+ const i = B(a, t);
493
+ return i && (i.parent.children[i.index] = e, it(i.parent)), a;
494
+ }
495
+ function A(a, t, e, i) {
496
+ const n = i === "left" || i === "right" ? "horizontal" : "vertical", o = i === "left" || i === "top", r = B(a, t);
497
+ if (r && r.parent.direction === n) {
498
+ const s = o ? r.index : r.index + 1;
499
+ return r.parent.children.splice(s, 0, e), r.parent.sizes = nt(
500
+ r.parent.sizes,
501
+ s,
502
+ r.parent.children.length
503
+ ), a ?? e;
504
+ }
505
+ return ot(a, t, {
506
+ kind: "split",
507
+ direction: n,
508
+ children: o ? [e, t] : [t, e],
509
+ sizes: [0.5, 0.5]
510
+ });
511
+ }
512
+ function M(a, t, e = []) {
513
+ if (a) {
514
+ if (a.kind === "stack") {
515
+ t(a, e);
516
+ return;
517
+ }
518
+ a.children.forEach((i, n) => M(i, t, [...e, n]));
519
+ }
520
+ }
521
+ function E(a) {
522
+ let t = null;
523
+ return M(a, (e) => {
524
+ t || e.panes.length === 0 || (e.activePane && e.panes.includes(e.activePane) ? t = e.activePane : t = e.panes[0]);
525
+ }), t;
526
+ }
527
+ function I(a) {
528
+ const t = [];
529
+ return M(a, (e) => {
530
+ e.panes.forEach((i) => t.push(i));
531
+ }), t;
532
+ }
533
+ function rt(a, t) {
534
+ return a.panes = a.panes.filter((e) => e !== t), a.panes.includes(a.activePane ?? "") || (a.panes.length > 0 ? a.activePane = a.panes[0] : delete a.activePane), a.panes.length === 0;
535
+ }
536
+ function H(a) {
537
+ if (!a) return null;
538
+ if (a.kind === "stack")
539
+ return a.panes.length === 0 ? null : ((!a.activePane || !a.panes.includes(a.activePane)) && (a.activePane = a.panes[0]), a);
540
+ const t = x(a.sizes, a.children.length), e = a.children.map((i, n) => ({ child: H(i), slot: t[n] })).filter((i) => i.child !== null).flatMap(({ child: i, slot: n }) => {
541
+ if (i.kind === "split" && i.direction === a.direction) {
542
+ const o = x(i.sizes, i.children.length);
543
+ return i.children.map((r, d) => ({
544
+ child: r,
545
+ slot: n * o[d]
546
+ }));
547
+ }
548
+ return [{ child: i, slot: n }];
549
+ });
550
+ return e.length === 0 ? null : e.length === 1 ? e[0].child : (a.children = e.map((i) => i.child), a.sizes = x(
551
+ e.map((i) => i.slot),
552
+ e.length
553
+ ), a);
554
+ }
555
+ function _(a) {
556
+ return a ? JSON.parse(JSON.stringify(a)) : null;
557
+ }
558
+ const st = 192, at = 128;
559
+ function X(a, t) {
560
+ return t > 0 ? Math.min(a, t) : a;
561
+ }
562
+ function Y(a, t, e, i) {
563
+ const n = X(st, i.width), o = X(at, i.height);
564
+ let r = a.width, d = a.height, s = a.left, c = a.top;
565
+ return t.horizontal === "right" ? (r = Math.max(n, a.width + e.x), i.width > 0 && (r = Math.min(r, i.width - a.left))) : t.horizontal === "left" && (r = Math.max(n, a.width - e.x), r = Math.min(r, a.left + a.width), s = a.left + a.width - r), t.vertical === "bottom" ? (d = Math.max(o, a.height + e.y), i.height > 0 && (d = Math.min(d, i.height - a.top))) : t.vertical === "top" && (d = Math.max(o, a.height - e.y), d = Math.min(d, a.top + a.height), c = a.top + a.height - d), { left: s, top: c, width: r, height: d };
566
+ }
567
+ const C = [1 / 3, 1 / 2, 2 / 3];
568
+ function lt(a, t) {
569
+ if (t <= 0) return a;
570
+ const e = a / t;
571
+ let i = C[0], n = Math.abs(e - i);
572
+ for (let o = 1; o < C.length; o += 1) {
573
+ const r = Math.abs(e - C[o]);
574
+ r < n && (n = r, i = C[o]);
575
+ }
576
+ return i * t;
577
+ }
578
+ function j(a, t, e) {
579
+ let i = a, n = e + 1;
580
+ for (const o of t) {
581
+ const r = Math.abs(o - a);
582
+ r < n && (n = r, i = o);
583
+ }
584
+ return n <= e ? i : a;
585
+ }
586
+ function ct(a, t, e, i, n = !1) {
587
+ const o = a + t;
588
+ let r = Math.min(Math.max(a + e, i), o - i);
589
+ return n && (r = lt(r, o)), { before: r, after: o - r };
590
+ }
591
+ function dt(a, t, e, i = 12) {
592
+ for (let n = 0; n < a.length; n += 1) {
593
+ const r = (e !== null ? a[n] >= e : !1) ? a[n] + i : a[n];
594
+ if (t < r)
595
+ return n;
596
+ }
597
+ return a.length;
598
+ }
599
+ function w(a) {
600
+ if (a.type === "floating") {
601
+ const e = a.segments.length > 0 ? `/${a.segments.map((i) => i.toString()).join("/")}` : "";
602
+ return `f:${a.index}${e}`;
603
+ }
604
+ const t = a.segments.join("/");
605
+ return t.length > 0 ? `d:${t}` : "d:";
606
+ }
607
+ function S(a) {
608
+ if (a == null)
609
+ return null;
610
+ if (a.startsWith("f:")) {
611
+ const i = a.slice(2), [n, ...o] = i.split("/"), r = Number.parseInt(n, 10);
612
+ if (!Number.isFinite(r))
613
+ return null;
614
+ const d = o.filter((s) => s.length > 0).map((s) => Number.parseInt(s, 10)).filter((s) => Number.isFinite(s));
615
+ return { type: "floating", index: r, segments: d };
616
+ }
617
+ const t = a.startsWith("d:") ? a.slice(2) : a;
618
+ 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)) };
619
+ }
620
+ function O(a, t) {
621
+ if (a.type !== t.type)
622
+ return !1;
623
+ if (a.type === "floating") {
624
+ const i = t;
625
+ return a.index !== i.index || a.segments.length !== i.segments.length ? !1 : a.segments.every((n, o) => n === i.segments[o]);
626
+ }
627
+ const e = t;
628
+ return a.segments.length !== e.segments.length ? !1 : a.segments.every((i, n) => i === e.segments[n]);
629
+ }
630
+ class L extends G {
431
631
  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, {
632
+ super(), this.liveAnnouncer = new V(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 Q(() => this.shadowRoot, {
433
633
  selector: ".dock-intersection-handle[data-key], mp-tab-control, .dock-tab[data-tab-id]",
434
634
  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);
635
+ }), 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
636
  }
437
637
  static {
438
- this.styles = [_];
638
+ this.styles = [et];
439
639
  }
440
640
  static {
441
641
  this.documentRef = typeof document < "u" ? document : null;
442
642
  }
443
643
  static configureDocument(t) {
444
- t && (P.documentRef = t);
644
+ t && (L.documentRef = t);
445
645
  }
446
646
  static get observedAttributes() {
447
647
  return [...super.observedAttributes ?? [], "layout", "debug-layout-integrity"];
@@ -466,22 +666,22 @@ class P extends A {
466
666
  const t = this.shadowRoot?.querySelector(".dock-intersections-layer, .dock-intersection-layer");
467
667
  if (!t || (Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((r) => r.remove()), !this.cornerResizeState)) return;
468
668
  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);
669
+ let i = null, n = null;
670
+ const o = this.cornerResizeState;
671
+ if (o.vs.length > 0) {
672
+ const r = o.vs[0], s = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
673
+ s && (i = s.left + s.width / 2 - e.left);
474
674
  }
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);
675
+ if (o.hs.length > 0) {
676
+ const r = o.hs[0], s = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
677
+ s && (n = s.top + s.height / 2 - e.top);
478
678
  }
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);
679
+ n != null && this.cornerSnapXTargets.forEach((r) => {
680
+ const d = this.documentRef.createElement("div");
681
+ d.className = "dock-snap-marker", d.style.left = `${r}px`, d.style.top = `${n}px`, t.appendChild(d);
482
682
  }), 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);
683
+ const d = this.documentRef.createElement("div");
684
+ d.className = "dock-snap-marker", d.style.left = `${i}px`, d.style.top = `${r}px`, t.appendChild(d);
485
685
  });
486
686
  }
487
687
  clearSnapMarkers() {
@@ -490,7 +690,7 @@ class P extends A {
490
690
  t && Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((e) => e.remove());
491
691
  }
492
692
  render() {
493
- return D`${I}${this.liveAnnouncer.template()}`;
693
+ return W`${tt}${this.liveAnnouncer.template()}`;
494
694
  }
495
695
  firstUpdated() {
496
696
  const t = this.resolveDocument();
@@ -498,24 +698,24 @@ class P extends A {
498
698
  const e = this.shadowRoot, i = e.querySelector(".dock-root");
499
699
  if (!i)
500
700
  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");
701
+ const n = e.querySelector(".dock-docked");
505
702
  if (!n)
703
+ throw new Error("mint-dock-manager template is missing the docked surface element.");
704
+ const o = e.querySelector(".dock-floating-layer");
705
+ if (!o)
506
706
  throw new Error("mint-dock-manager template is missing the floating layer element.");
507
707
  const r = e.querySelector(".dock-drop-indicator");
508
708
  if (!r)
509
709
  throw new Error("mint-dock-manager template is missing the drop indicator element.");
510
- const c = e.querySelector(".dock-drop-joystick");
511
- if (!c)
710
+ const d = e.querySelector(".dock-drop-joystick");
711
+ if (!d)
512
712
  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]")
713
+ const s = Array.from(
714
+ d.querySelectorAll(".dock-drop-joystick__button[data-zone]")
515
715
  );
516
- if (l.length === 0)
716
+ if (s.length === 0)
517
717
  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(() => {
718
+ this.rootEl = i, this.dockedEl = n, this.floatingLayerEl = o, this.dropIndicator = r, this.dropJoystick = d, this.dropJoystickButtons = s, 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
719
  this.scheduleRenderIntersectionHandles(), this.updateFloatingPanePositions();
520
720
  }), 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
721
  }
@@ -531,7 +731,7 @@ class P extends A {
531
731
  }
532
732
  get layout() {
533
733
  return {
534
- root: this.cloneLayoutNode(this.rootLayout),
734
+ root: _(this.rootLayout),
535
735
  floating: this.cloneFloatingArray(this.floatingLayouts),
536
736
  titles: { ...this.titles }
537
737
  };
@@ -543,8 +743,8 @@ class P extends A {
543
743
  root: this.rootLayout,
544
744
  floating: this.floatingLayouts,
545
745
  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());
746
+ }), n = JSON.stringify(e);
747
+ i !== n && (this.rootLayout = _(e.root), this.floatingLayouts = this.cloneFloatingArray(e.floating), this.titles = e.titles ? { ...e.titles } : {}, this.normalizeAllLayouts(), this.renderLayout());
548
748
  }
549
749
  /**
550
750
  * True while the user is actively interacting with the dock — pane drag,
@@ -562,10 +762,10 @@ class P extends A {
562
762
  return this.snapshot;
563
763
  }
564
764
  resolveDocument() {
565
- const t = P.documentRef, e = this.ownerDocument ?? null, o = t ?? e ?? (typeof document < "u" ? document : null);
566
- if (!o)
765
+ const t = L.documentRef, e = this.ownerDocument ?? null, n = t ?? e ?? (typeof document < "u" ? document : null);
766
+ if (!n)
567
767
  throw new Error("mint-dock-manager requires a Document to initialize.");
568
- return P.documentRef || (P.documentRef = o), o;
768
+ return L.documentRef || (L.documentRef = n), n;
569
769
  }
570
770
  resolveWindow(t) {
571
771
  return typeof window < "u" ? window : t.defaultView ?? null;
@@ -606,40 +806,40 @@ class P extends A {
606
806
  this.floatingLayerEl.innerHTML = "";
607
807
  const t = this.getHostSize();
608
808
  this.floatingLayouts.forEach((e, i) => {
609
- const o = this.documentRef.createElement("div");
610
- o.classList.add("dock-floating"), o.dataset.path = this.formatPath({
809
+ const n = this.documentRef.createElement("div");
810
+ n.classList.add("dock-floating"), n.dataset.path = w({
611
811
  type: "floating",
612
812
  index: i,
613
813
  segments: []
614
814
  });
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);
815
+ const o = this.getFloatingWindowTitle(e), r = `${this.instanceId}-floating-${i}-title`;
816
+ n.setAttribute("role", "dialog"), n.setAttribute("aria-labelledby", r), n.setAttribute("aria-modal", "false");
817
+ const { left: d, top: s, width: c, height: l } = R(e.bounds, t);
818
+ n.style.left = `${d}px`, n.style.top = `${s}px`, n.style.width = `${c}px`, n.style.height = `${l}px`, n.style.minWidth = "0", n.style.minHeight = "0";
819
+ const u = N(this.floatingLayouts[i], i);
820
+ n.style.zIndex = String(u);
621
821
  const h = this.documentRef.createElement("div");
622
822
  h.classList.add("dock-floating__chrome"), h.addEventListener(
623
823
  "pointerdown",
624
- (u) => this.beginFloatingDrag(u, i, o, h)
824
+ (f) => this.beginFloatingDrag(f, i, n, h)
625
825
  );
626
- const d = this.documentRef.createElement("div");
627
- d.classList.add("dock-floating__title"), d.id = r, d.textContent = n, h.appendChild(d);
826
+ const p = this.documentRef.createElement("div");
827
+ p.classList.add("dock-floating__title"), p.id = r, p.textContent = o, h.appendChild(p);
628
828
  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);
829
+ if (g.type = "button", g.classList.add("dock-floating__close"), g.setAttribute("aria-label", `Close pane: ${o}`), g.textContent = "×", g.addEventListener("click", (f) => {
830
+ f.stopPropagation(), this.closeFloatingPane(i);
831
+ }), g.addEventListener("pointerdown", (f) => f.stopPropagation()), h.appendChild(g), n.appendChild(h), e.root) {
832
+ const f = this.renderNode(e.root, [], i);
833
+ f.classList.add("dock-floating__stack"), n.appendChild(f);
634
834
  } else {
635
- const u = this.documentRef.createElement("div");
636
- u.classList.add("dock-stack"), u.dataset.path = this.formatPath({
835
+ const f = this.documentRef.createElement("div");
836
+ f.classList.add("dock-stack"), f.dataset.path = w({
637
837
  type: "floating",
638
838
  index: i,
639
839
  segments: []
640
840
  });
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);
841
+ const y = this.documentRef.createElement("div");
842
+ y.classList.add("dock-stack__pane"), y.textContent = "No panes configured", f.appendChild(y), n.appendChild(f);
643
843
  }
644
844
  [
645
845
  {
@@ -674,23 +874,23 @@ class P extends A {
674
874
  classes: ["dock-floating__resizer", "dock-floating__resizer--left"],
675
875
  edges: { horizontal: "left", vertical: "none" }
676
876
  }
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(
877
+ ].forEach(({ classes: f, edges: y }) => {
878
+ const b = this.documentRef.createElement("div");
879
+ b.classList.add(...f), b.setAttribute("role", "separator");
880
+ const k = y.horizontal === "none" && y.vertical !== "none", D = y.vertical === "none" && y.horizontal !== "none";
881
+ k ? b.setAttribute("aria-orientation", "horizontal") : D && b.setAttribute("aria-orientation", "vertical");
882
+ const P = [];
883
+ 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
884
  "aria-label",
685
- `Resize pane ${S.length === 2 ? "corner " : "edge "}${S.join("-")}`
686
- ), y.addEventListener(
885
+ `Resize pane ${P.length === 2 ? "corner " : "edge "}${P.join("-")}`
886
+ ), b.addEventListener(
687
887
  "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(
888
+ (z) => this.beginFloatingResize(z, i, n, b, y)
889
+ ), b.setAttribute("tabindex", "0"), b.setAttribute("aria-valuemin", "0"), b.setAttribute("aria-valuemax", "100"), this.syncFloatingResizerValue(b, i, y), b.addEventListener(
690
890
  "keydown",
691
- (v) => this.onFloatingResizeKeydown(v, i, o, y, m)
692
- ), o.appendChild(y);
693
- }), this.floatingLayerEl.appendChild(o);
891
+ (z) => this.onFloatingResizeKeydown(z, i, n, b, y)
892
+ ), n.appendChild(b);
893
+ }), this.floatingLayerEl.appendChild(n);
694
894
  });
695
895
  }
696
896
  onSplitterResize() {
@@ -708,45 +908,45 @@ class P extends A {
708
908
  if (!t) return;
709
909
  const e = this.rootEl.getBoundingClientRect();
710
910
  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();
911
+ const s = this.cornerResizeState, c = s.hs[0], l = s.vs[0], u = this.findSplitterByPath(c.path.segments), h = this.findSplitterByPath(l.path.segments), p = u ? this.getSplitterDividers(u)[c.index] : null, g = h ? this.getSplitterDividers(h)[l.index] : null;
912
+ if (p && g) {
913
+ const m = p.getBoundingClientRect(), f = g.getBoundingClientRect(), y = f.left + f.width / 2 - e.left, b = m.top + m.height / 2 - e.top;
914
+ s.handle.style.left = `${y}px`, s.handle.style.top = `${b}px`, Array.from(t.querySelectorAll(".dock-intersection-handle")).forEach((k) => {
915
+ k !== s.handle && k.remove();
716
916
  });
717
917
  }
718
918
  return;
719
919
  }
720
920
  t.replaceChildren();
721
- const i = [], o = [];
921
+ const i = [], n = [];
722
922
  Array.from(
723
923
  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);
924
+ ).forEach((s) => {
925
+ const c = s.dataset.direction, l = s.dataset.path ?? "", u = this.splitterLayerKey(s);
926
+ this.getSplitterDividers(s).forEach((h, p) => {
927
+ const g = { rect: h.getBoundingClientRect(), pathStr: l, index: p, layerKey: u };
928
+ c === "horizontal" ? n.push(g) : c === "vertical" && i.push(g);
729
929
  });
730
930
  });
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);
931
+ const r = 24, d = /* @__PURE__ */ new Map();
932
+ i.forEach((s) => {
933
+ const c = s.rect.top + s.rect.height / 2;
934
+ n.forEach((l) => {
935
+ if (s.layerKey !== l.layerKey) return;
936
+ const u = l.rect.left + l.rect.width / 2, h = u < s.rect.left ? s.rect.left - u : u > s.rect.right ? u - s.rect.right : 0, p = c < l.rect.top ? l.rect.top - c : c > l.rect.bottom ? c - l.rect.bottom : 0;
937
+ if (h > r || p > r) return;
938
+ const g = u - e.left, m = c - e.top, f = `${Math.round(g)}:${Math.round(m)}`, y = d.get(f) ?? { x: g, y: m, pairs: [] };
939
+ y.pairs.push({ h: { pathStr: s.pathStr, index: s.index }, v: { pathStr: l.pathStr, index: l.index } }), d.set(f, y);
740
940
  });
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);
941
+ }), d.forEach((s, c) => {
942
+ const l = this.documentRef.createElement("div");
943
+ l.classList.add("dock-intersection-handle", "glyph"), l.setAttribute("role", "separator"), l.setAttribute("aria-label", "Resize split intersection");
944
+ const u = e.width > 0 ? Math.round(s.x / e.width * 100) : 0;
945
+ l.setAttribute("aria-valuemin", "0"), l.setAttribute("aria-valuemax", "100"), l.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, u)))), l.setAttribute("tabindex", "0");
946
+ const h = s.pairs[0], p = `${h.h.pathStr}:${h.h.index}|${h.v.pathStr}:${h.v.index}`;
947
+ l.dataset.key = p, l.dataset.pairs = JSON.stringify(s.pairs), l.style.left = `${s.x}px`, l.style.top = `${s.y}px`;
948
+ const g = { path: S(h.h.pathStr), index: h.h.index, container: this.findSplitterByPath(S(h.h.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() }, m = { path: S(h.v.pathStr), index: h.v.index, container: this.findSplitterByPath(S(h.v.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() };
949
+ l.addEventListener("pointerdown", (f) => this.beginCornerResize(f, g, m, l)), l.addEventListener("dblclick", (f) => this.onIntersectionDoubleClick(f, l)), l.addEventListener("keydown", (f) => this.onIntersectionKeyDown(f, l)), t.appendChild(l);
750
950
  });
751
951
  }
752
952
  /**
@@ -761,67 +961,67 @@ class P extends A {
761
961
  * pair drives — same precedence as the pointer drag path.
762
962
  */
763
963
  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;
964
+ const i = t.key === "ArrowLeft" || t.key === "ArrowRight", n = t.key === "ArrowUp" || t.key === "ArrowDown", o = t.key === "Home" || t.key === "End";
965
+ if (!i && !n && !o) return;
766
966
  const r = e.dataset.pairs;
767
967
  if (!r) return;
768
- let c;
968
+ let d;
769
969
  try {
770
- c = JSON.parse(r);
970
+ d = JSON.parse(r);
771
971
  } catch {
772
972
  return;
773
973
  }
774
- if (c.length === 0) return;
974
+ if (d.length === 0) return;
775
975
  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);
976
+ const s = t.shiftKey, l = i || o ? d[0].v : d[0].h, u = S(l.pathStr);
977
+ this.findSplitterByPath(u?.segments ?? [])?.resizeDividerBy?.(l.index, t.key, s);
778
978
  }
779
- beginCornerResize(t, e, i, o) {
979
+ beginCornerResize(t, e, i, n) {
780
980
  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);
981
+ const o = n.dataset.pairs, r = o ? JSON.parse(o) : [], d = [], s = [], c = (l, u, h) => {
982
+ const p = S(l);
983
+ if (!p) return;
984
+ const g = this.findSplitterByPath(p.segments);
785
985
  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);
986
+ const m = this.getSplitterPanels(g);
987
+ if (m.length === 0) return;
988
+ const f = h === "h" ? "height" : "width", y = m.map((k) => k.getBoundingClientRect()[f]), b = { path: p, index: u, container: g, initialSizes: y, before: y[u], after: y[u + 1] };
989
+ h === "h" ? d.push(b) : s.push(b);
790
990
  };
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)) {
991
+ if (r.length > 0 ? r.forEach((l) => {
992
+ c(l.h.pathStr, l.h.index, "h"), c(l.v.pathStr, l.v.index, "v");
993
+ }) : e.path && i.path && (c(w(e.path), e.index, "h"), c(w(i.path), i.index, "v")), !(d.length === 0 && s.length === 0)) {
794
994
  try {
795
- o.setPointerCapture(t.pointerId), o.dataset.resizing = "true", o.classList.add("hovering");
995
+ n.setPointerCapture(t.pointerId), n.dataset.resizing = "true", n.classList.add("hovering");
796
996
  } catch {
797
997
  }
798
998
  this.cornerResizeState = {
799
999
  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();
1000
+ handle: n,
1001
+ hs: d.map((l) => ({ path: this.clonePath(l.path), index: l.index, container: l.container, beforeSize: l.before, afterSize: l.after, initialSizes: l.initialSizes, startY: t.clientY })),
1002
+ vs: s.map((l) => ({ path: this.clonePath(l.path), index: l.index, container: l.container, beforeSize: l.before, afterSize: l.after, initialSizes: l.initialSizes, startX: t.clientX }))
1003
+ }, this.startPointerTracking(), n.dataset.key || (n.dataset.key = n.dataset.group ?? ""), this.renderSnapMarkersForCorner();
804
1004
  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);
1005
+ const l = this.rootEl.getBoundingClientRect();
1006
+ let u = null, h = null;
1007
+ if (s.length > 0) {
1008
+ const f = s[0], b = this.getSplitterDividers(f.container)[f.index]?.getBoundingClientRect();
1009
+ b && (u = b.left + b.width / 2);
810
1010
  }
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);
1011
+ if (d.length > 0) {
1012
+ const f = d[0], b = this.getSplitterDividers(f.container)[f.index]?.getBoundingClientRect();
1013
+ b && (h = b.top + b.height / 2);
814
1014
  }
815
- const d = [], g = [];
1015
+ const p = [], g = [];
816
1016
  Array.from(
817
1017
  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);
1018
+ ).forEach((f) => {
1019
+ const y = f.dataset.direction ?? void 0;
1020
+ this.getSplitterDividers(f).forEach((b) => {
1021
+ const k = b.getBoundingClientRect();
1022
+ y === "horizontal" && h != null ? h >= k.top && h <= k.bottom && p.push(k.left + k.width / 2 - l.left) : y === "vertical" && u != null && u >= k.left && u <= k.right && g.push(k.top + k.height / 2 - l.top);
823
1023
  });
824
- }), this.cornerSnapXTargets = d, this.cornerSnapYTargets = g;
1024
+ }), this.cornerSnapXTargets = p, this.cornerSnapYTargets = g;
825
1025
  } catch {
826
1026
  this.cornerSnapXTargets = [], this.cornerSnapYTargets = [];
827
1027
  }
@@ -830,43 +1030,29 @@ class P extends A {
830
1030
  handleCornerResizeMove(t) {
831
1031
  const e = this.cornerResizeState;
832
1032
  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);
1033
+ const i = 10, n = this.rootEl.getBoundingClientRect(), o = j(
1034
+ t.clientX,
1035
+ this.cornerSnapXTargets.map((s) => n.left + s),
1036
+ i
1037
+ ), r = j(
1038
+ t.clientY,
1039
+ this.cornerSnapYTargets.map((s) => n.top + s),
1040
+ i
1041
+ ), d = (s, c) => {
1042
+ const l = this.resolveSplitNode(s.path);
1043
+ if (!l) return;
1044
+ const u = 48, { before: h, after: p } = ct(
1045
+ s.beforeSize,
1046
+ s.afterSize,
1047
+ c,
1048
+ u,
1049
+ t.shiftKey
1050
+ ), g = [...s.initialSizes];
1051
+ g[s.index] = h, g[s.index + 1] = p;
1052
+ const m = g.reduce((f, y) => f + y, 0);
1053
+ l.sizes = m > 0 ? g.map((f) => f / m) : [], s.container.setPanelSizes?.(g);
868
1054
  };
869
- e.hs.forEach((s) => l(s, c - s.startY)), e.vs.forEach((s) => l(s, r - s.startX)), this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
1055
+ e.hs.forEach((s) => d(s, r - s.startY)), e.vs.forEach((s) => d(s, o - s.startX)), this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
870
1056
  }
871
1057
  endCornerResize(t) {
872
1058
  const e = this.cornerResizeState;
@@ -880,78 +1066,78 @@ class P extends A {
880
1066
  }
881
1067
  onIntersectionDoubleClick(t, e) {
882
1068
  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 } });
1069
+ const i = e.dataset.pairs, n = i ? JSON.parse(i) : [];
1070
+ if (!Array.isArray(n) || n.length === 0) {
1071
+ const l = (e.dataset.key ?? "").split("|");
1072
+ if (l.length === 2) {
1073
+ const [u, h] = l, p = u.lastIndexOf(":"), g = h.lastIndexOf(":");
1074
+ if (p > 0 && g > 0) {
1075
+ const m = u.slice(0, p), f = h.slice(0, g), y = Number.parseInt(u.slice(p + 1), 10), b = Number.parseInt(h.slice(g + 1), 10);
1076
+ n.push({ h: { pathStr: m, index: y }, v: { pathStr: f, index: b } });
891
1077
  }
892
1078
  }
893
1079
  }
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);
1080
+ if (n.length === 0) return;
1081
+ const o = /* @__PURE__ */ new Set();
1082
+ n.forEach((c) => {
1083
+ o.add(c.h.pathStr), o.add(c.v.pathStr);
898
1084
  });
899
1085
  let r = !1;
900
- n.forEach((s) => {
901
- this.previousSplitSizes.has(s) && (r = !0);
1086
+ o.forEach((c) => {
1087
+ this.previousSplitSizes.has(c) && (r = !0);
902
1088
  });
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);
1089
+ const d = (c, l) => {
1090
+ const u = this.findSplitterByPath(c.segments);
1091
+ if (!u) return;
1092
+ const p = (u.dataset.direction ?? "horizontal") === "horizontal" ? u.getBoundingClientRect().width : u.getBoundingClientRect().height;
1093
+ if (!Number.isFinite(p) || p <= 0) return;
1094
+ const g = l.reduce((f, y) => f + Math.max(y, 0), 0);
909
1095
  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);
1096
+ const m = l.map((f) => Math.max(f, 0) / g * p);
1097
+ u.setPanelSizes?.(m);
1098
+ }, s = (c, l, u) => {
1099
+ const h = S(c);
914
1100
  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);
1101
+ const p = this.resolveSplitNode(h);
1102
+ if (!p) return;
1103
+ const g = x(p.sizes ?? [], p.children.length), m = u([...g], l);
1104
+ p.sizes = m, d(h, m);
919
1105
  };
920
1106
  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);
1107
+ this.previousSplitSizes.forEach((c, l) => {
1108
+ const u = S(l), h = u ? this.resolveSplitNode(u) : null;
1109
+ if (!h || !u) return;
1110
+ const p = x(c, h.children.length);
1111
+ h.sizes = p, d(u, p);
926
1112
  }), this.previousSplitSizes.clear();
927
1113
  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);
1114
+ const c = /* @__PURE__ */ new Set();
1115
+ n.forEach((l) => {
1116
+ [l.h.pathStr, l.v.pathStr].forEach((h) => {
1117
+ if (c.has(h)) return;
1118
+ const p = S(h), g = p ? this.resolveSplitNode(p) : null;
1119
+ g && Array.isArray(g.sizes) && this.previousSplitSizes.set(h, [...g.sizes]), c.add(h);
934
1120
  });
935
- const p = (h, d) => {
936
- const g = (h[d] ?? 0) + (h[d + 1] ?? 0);
1121
+ const u = (h, p) => {
1122
+ const g = (h[p] ?? 0) + (h[p + 1] ?? 0);
937
1123
  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;
1124
+ h[p] = g / 2, h[p + 1] = g / 2;
1125
+ const m = h.reduce((f, y) => f + y, 0);
1126
+ return m > 0 ? h.map((f) => f / m) : h;
941
1127
  };
942
- l(a.h.pathStr, a.h.index, p), l(a.v.pathStr, a.v.index, p);
1128
+ s(l.h.pathStr, l.h.index, u), s(l.v.pathStr, l.v.index, u);
943
1129
  });
944
1130
  }
945
1131
  this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
946
1132
  }
947
- beginFloatingDrag(t, e, i, o) {
948
- const n = this.floatingLayouts[e];
949
- if (!n)
1133
+ beginFloatingDrag(t, e, i, n) {
1134
+ const o = this.floatingLayouts[e];
1135
+ if (!o)
950
1136
  return;
951
- t.preventDefault(), t.stopPropagation(), n.bounds = this.clampBoundsToHost(n.bounds, this.getHostSize());
952
- const { left: r, top: c } = n.bounds;
1137
+ t.preventDefault(), t.stopPropagation(), o.bounds = R(o.bounds, this.getHostSize());
1138
+ const { left: r, top: d } = o.bounds;
953
1139
  try {
954
- o.setPointerCapture(t.pointerId);
1140
+ n.setPointerCapture(t.pointerId);
955
1141
  } catch {
956
1142
  }
957
1143
  this.promoteFloatingPane(e, i), i.dataset.dragging = "true", this.floatingDragState = {
@@ -960,17 +1146,17 @@ class P extends A {
960
1146
  startX: t.clientX,
961
1147
  startY: t.clientY,
962
1148
  startLeft: r,
963
- startTop: c,
1149
+ startTop: d,
964
1150
  wrapper: i,
965
- handle: o
1151
+ handle: n
966
1152
  }, this.startPointerTracking();
967
1153
  }
968
1154
  /** The percent-of-host size of the dimension a handle drives (width for
969
1155
  * horizontal/corner handles, height for pure-vertical ones). */
970
1156
  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;
1157
+ const n = this.floatingLayouts[e], o = this.getHostSize();
1158
+ if (!n || o.width <= 0 || o.height <= 0) return;
1159
+ const r = i.horizontal !== "none" ? n.bounds.width / o.width * 100 : n.bounds.height / o.height * 100;
974
1160
  t.setAttribute("aria-valuenow", String(Math.round(Math.min(100, Math.max(0, r)))));
975
1161
  }
976
1162
  /**
@@ -979,35 +1165,30 @@ class P extends A {
979
1165
  * ±10px per arrow, Shift for 1px. Off-axis arrows and modifier chords pass
980
1166
  * through untouched.
981
1167
  */
982
- onFloatingResizeKeydown(t, e, i, o, n) {
1168
+ onFloatingResizeKeydown(t, e, i, n, o) {
983
1169
  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;
1170
+ const r = t.key === "ArrowLeft" ? -1 : t.key === "ArrowRight" ? 1 : 0, d = t.key === "ArrowUp" ? -1 : t.key === "ArrowDown" ? 1 : 0;
1171
+ if (r === 0 && d === 0 || r !== 0 && o.horizontal === "none" || d !== 0 && o.vertical === "none") return;
1172
+ const s = this.floatingLayouts[e];
1173
+ if (!s) return;
988
1174
  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();
1175
+ const c = t.shiftKey ? 1 : 10, l = Y(
1176
+ s.bounds,
1177
+ o,
1178
+ { x: r * c, y: d * c },
1179
+ this.getHostSize()
1180
+ );
1181
+ this.applyFloatingBounds(i, e, l), this.syncFloatingResizerValue(n, e, o), this.dispatchLayoutChanged();
1001
1182
  }
1002
- beginFloatingResize(t, e, i, o, n) {
1183
+ beginFloatingResize(t, e, i, n, o) {
1003
1184
  const r = this.floatingLayouts[e];
1004
1185
  if (r) {
1005
1186
  t.preventDefault(), t.stopPropagation();
1006
1187
  try {
1007
- o.setPointerCapture(t.pointerId), o.dataset.resizing = "true";
1188
+ n.setPointerCapture(t.pointerId), n.dataset.resizing = "true";
1008
1189
  } catch {
1009
1190
  }
1010
- this.promoteFloatingPane(e, i), r.bounds = this.clampBoundsToHost(r.bounds, this.getHostSize()), this.floatingResizeState = {
1191
+ this.promoteFloatingPane(e, i), r.bounds = R(r.bounds, this.getHostSize()), this.floatingResizeState = {
1011
1192
  index: e,
1012
1193
  pointerId: t.pointerId,
1013
1194
  startX: t.clientX,
@@ -1017,8 +1198,8 @@ class P extends A {
1017
1198
  startLeft: r.bounds.left,
1018
1199
  startTop: r.bounds.top,
1019
1200
  wrapper: i,
1020
- handle: o,
1021
- edges: n
1201
+ handle: n,
1202
+ edges: o
1022
1203
  }, this.startPointerTracking();
1023
1204
  }
1024
1205
  }
@@ -1028,10 +1209,10 @@ class P extends A {
1028
1209
  return;
1029
1210
  const i = this.floatingLayouts[e.index];
1030
1211
  if (!i) return;
1031
- const o = t.clientX - e.startX, n = t.clientY - e.startY, r = this.clampBoundsToHost(
1212
+ const n = t.clientX - e.startX, o = t.clientY - e.startY, r = R(
1032
1213
  {
1033
- left: e.startLeft + o,
1034
- top: e.startTop + n,
1214
+ left: e.startLeft + n,
1215
+ top: e.startTop + o,
1035
1216
  width: i.bounds.width,
1036
1217
  height: i.bounds.height
1037
1218
  },
@@ -1060,24 +1241,41 @@ class P extends A {
1060
1241
  e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
1061
1242
  return;
1062
1243
  }
1063
- const o = this.parsePath(i.dataset.path);
1064
- if (!o || o.type === "floating" && o.index === e.index) {
1244
+ const n = S(i.dataset.path);
1245
+ if (!n || n.type === "floating" && n.index === e.index) {
1065
1246
  e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
1066
1247
  return;
1067
1248
  }
1068
1249
  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);
1250
+ const o = this.computeDropZone(i, t, this.extractDropZoneFromEvent(t));
1251
+ o ? e.dropTarget = { path: n, zone: o } : e.dropTarget && delete e.dropTarget, this.showDropIndicator(i, o);
1071
1252
  }
1072
1253
  handleFloatingResizeMove(t) {
1073
1254
  const e = this.floatingResizeState;
1074
1255
  if (!e || t.pointerId !== e.pointerId)
1075
1256
  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 });
1257
+ const i = Y(
1258
+ {
1259
+ left: e.startLeft,
1260
+ top: e.startTop,
1261
+ width: e.startWidth,
1262
+ height: e.startHeight
1263
+ },
1264
+ e.edges,
1265
+ { x: t.clientX - e.startX, y: t.clientY - e.startY },
1266
+ this.getHostSize()
1267
+ );
1268
+ this.applyFloatingBounds(e.wrapper, e.index, i);
1269
+ }
1270
+ /**
1271
+ * Commit resolved bounds to both the DOM and the layout. Written directly
1272
+ * rather than through a re-render: a resize runs once per pointer move, and
1273
+ * tearing the wrapper down would drop the pointer capture mid-gesture.
1274
+ */
1275
+ applyFloatingBounds(t, e, i) {
1276
+ t.style.left = `${i.left}px`, t.style.top = `${i.top}px`, t.style.width = `${i.width}px`, t.style.height = `${i.height}px`;
1277
+ const n = this.floatingLayouts[e];
1278
+ n && (n.bounds = i);
1081
1279
  }
1082
1280
  endFloatingResize(t) {
1083
1281
  const e = this.floatingResizeState;
@@ -1089,21 +1287,12 @@ class P extends A {
1089
1287
  delete e.handle.dataset.resizing, this.syncFloatingResizerValue(e.handle, e.index, e.edges), this.floatingResizeState = null, this.dispatchLayoutChanged();
1090
1288
  }
1091
1289
  }
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
1290
  getHostSize() {
1097
1291
  return {
1098
1292
  width: this.rootEl.clientWidth,
1099
1293
  height: this.rootEl.clientHeight
1100
1294
  };
1101
1295
  }
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
1296
  // Re-clamp existing floating-pane wrappers in place. Avoids the full
1108
1297
  // renderFloatingPanes() teardown (which would release pointer capture if
1109
1298
  // a user is mid-drag when the host resizes).
@@ -1111,26 +1300,26 @@ class P extends A {
1111
1300
  if (!this.floatingLayerEl) return;
1112
1301
  const t = this.getHostSize();
1113
1302
  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";
1303
+ const n = this.floatingLayerEl.children[i];
1304
+ if (!n) return;
1305
+ const { left: o, top: r, width: d, height: s } = R(e.bounds, t);
1306
+ n.style.left = `${o}px`, n.style.top = `${r}px`, n.style.width = `${d}px`, n.style.height = `${s}px`, n.style.minWidth = "0", n.style.minHeight = "0";
1118
1307
  });
1119
1308
  }
1120
1309
  promoteFloatingPane(t, e) {
1121
1310
  const i = this.floatingLayouts[t];
1122
1311
  if (!i)
1123
1312
  return;
1124
- const o = this.floatingLayouts.reduce((r, c, l) => {
1125
- if (!c)
1313
+ const n = this.floatingLayouts.reduce((r, d, s) => {
1314
+ if (!d)
1126
1315
  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);
1316
+ const c = s === t ? Number.NEGATIVE_INFINITY : N(this.floatingLayouts[s], s);
1317
+ return Math.max(r, c);
1318
+ }, 0), o = Math.max(n + 2, 12);
1319
+ i.zIndex = o, e.style.zIndex = String(o);
1131
1320
  }
1132
1321
  getFloatingWrapper(t) {
1133
- const e = `.dock-floating[data-path="${this.formatPath({
1322
+ const e = `.dock-floating[data-path="${w({
1134
1323
  type: "floating",
1135
1324
  index: t,
1136
1325
  segments: []
@@ -1153,87 +1342,87 @@ class P extends A {
1153
1342
  const e = "Floating Pane";
1154
1343
  if (!t || !t.root)
1155
1344
  return e;
1156
- const i = t.activePane ?? this.findFirstPaneName(t.root);
1345
+ const i = t.activePane ?? E(t.root);
1157
1346
  return i ? this.titles[i] ?? i ?? e : e;
1158
1347
  }
1159
1348
  updateFloatingWindowTitle(t) {
1160
1349
  const e = this.floatingLayouts[t];
1161
1350
  if (!e)
1162
1351
  return;
1163
- const i = `.dock-floating[data-path="${this.formatPath({
1352
+ const i = `.dock-floating[data-path="${w({
1164
1353
  type: "floating",
1165
1354
  index: t,
1166
1355
  segments: []
1167
- })}"]`, o = this.floatingLayerEl.querySelector(i);
1168
- if (!o)
1356
+ })}"]`, n = this.floatingLayerEl.querySelector(i);
1357
+ if (!n)
1169
1358
  return;
1170
- const n = o.querySelector(".dock-floating__title");
1171
- n && (n.textContent = this.getFloatingWindowTitle(e));
1359
+ const o = n.querySelector(".dock-floating__title");
1360
+ o && (o.textContent = this.getFloatingWindowTitle(e));
1172
1361
  }
1173
1362
  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));
1363
+ const n = this.documentRef.createElement("mp-splitter");
1364
+ n.classList.add("dock-split"), n.dataset.direction = t.direction, n.dataset.path = e.join("/"), n.setAttribute("orientation", t.direction);
1365
+ const o = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
1366
+ t.children.forEach((d, s) => {
1367
+ n.appendChild(this.renderNode(d, [...e, s], i));
1179
1368
  });
1180
1369
  const r = Array.isArray(t.sizes) ? t.sizes : [];
1181
1370
  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),
1371
+ const d = r.reduce((l, u) => l + Math.max(u, 0), 0);
1372
+ if (d <= 0) return;
1373
+ const s = t.direction === "horizontal" ? n.getBoundingClientRect().width : n.getBoundingClientRect().height;
1374
+ if (!Number.isFinite(s) || s <= 0) return;
1375
+ const c = r.map((l) => Math.max(l, 0) / d * s);
1376
+ n.setPanelSizes?.(c), requestAnimationFrame(() => this.scheduleRenderIntersectionHandles());
1377
+ }), n.addEventListener("resize-end", (d) => {
1378
+ if (d.target !== n) return;
1379
+ const s = d.detail;
1380
+ if (!Array.isArray(s?.sizes) || s.sizes.length === 0) return;
1381
+ const c = this.resolveSplitNode(o);
1382
+ if (!c) return;
1383
+ const l = (c.sizes ?? []).reduce(
1384
+ (p, g) => p + Math.max(g, 0),
1196
1385
  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
1386
+ ), u = s.sizes.reduce((p, g) => p + Math.max(g, 0), 0), h = l > 0 ? l : s.sizes.length;
1387
+ u > 0 && (c.sizes = s.sizes.map(
1388
+ (p) => Math.max(p, 0) / u * h
1200
1389
  ), this.dispatchLayoutChanged());
1201
- }), o;
1390
+ }), n;
1202
1391
  }
1203
1392
  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);
1393
+ const n = this.documentRef.createElement("mp-tab-control");
1394
+ n.classList.add("dock-stack"), n.setAttribute("select-first-tab", "false"), n.setAttribute("border", "top");
1395
+ const o = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
1396
+ n.dataset.path = w(o);
1208
1397
  const r = Array.from(new Set(t.panes));
1209
1398
  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;
1399
+ const l = this.documentRef.createElement("span");
1400
+ l.setAttribute("slot", "__empty__-header"), l.textContent = "(empty)";
1401
+ const u = this.documentRef.createElement("div");
1402
+ return u.setAttribute("slot", "__empty__-content"), u.classList.add("dock-stack__pane"), u.textContent = "No panes configured", n.append(l, u), n.setAttribute("active-tab", "__empty__"), n;
1214
1403
  }
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();
1404
+ const d = r.includes(t.activePane ?? "") ? t.activePane : r[0], s = e.length ? e.join("-") : "root", c = typeof i == "number" ? `f${i}-${s}` : s;
1405
+ return r.forEach((l) => {
1406
+ const u = l.replace(/[^a-zA-Z0-9_-]/g, "-"), h = u.length > 0 ? u : "pane", p = `${this.instanceId}-tab-${c}-${h}`, g = `${this.instanceId}-panel-${c}-${h}`, m = this.documentRef.createElement("span");
1407
+ m.setAttribute("slot", `${p}-header`), m.classList.add("dock-tab"), m.dataset.pane = l, m.dataset.tabId = p, m.textContent = this.titles[l] ?? l, m.addEventListener("pointerdown", (b) => {
1408
+ this.captureTabDragMetrics(b, n), this.armPaneDragGesture(b, this.clonePath(o), l, n), b.stopPropagation();
1220
1409
  });
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}"]`
1410
+ const f = this.documentRef.createElement("div");
1411
+ f.setAttribute("slot", `${p}-content`), f.classList.add("dock-stack__pane"), f.dataset.pane = l, f.dataset.tabId = p, f.id = g;
1412
+ const y = this.documentRef.createElement("slot");
1413
+ y.name = l, f.appendChild(y), n.append(m, f), l === d && n.setAttribute("active-tab", p);
1414
+ }), n.dataset.activePane = d, n.addEventListener("tab-activate", (l) => {
1415
+ const u = l.detail, p = n.querySelector(
1416
+ `:scope > [data-tab-id="${u.tabId}"]`
1228
1417
  )?.dataset.pane;
1229
- d && (this.activatePane(o, d, this.clonePath(n)), this.dispatchEvent(
1418
+ p && (this.activatePane(n, p, this.clonePath(o)), this.dispatchEvent(
1230
1419
  new CustomEvent("dock-pane-activated", {
1231
- detail: { pane: d },
1420
+ detail: { pane: p },
1232
1421
  bubbles: !0,
1233
1422
  composed: !0
1234
1423
  })
1235
1424
  ));
1236
- }), o;
1425
+ }), n;
1237
1426
  }
1238
1427
  /**
1239
1428
  * Returns the strip (`.tsc`) element inside an `<mp-tab-control>`'s shadow
@@ -1311,14 +1500,14 @@ class P extends A {
1311
1500
  this.pendingTabDragMetrics = null;
1312
1501
  return;
1313
1502
  }
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;
1503
+ const i = this.getBoundingClientRect(), n = e.getBoundingClientRect(), o = t.clientX - n.left, r = t.clientY - n.top, d = n.left - i.left, s = n.top - i.top, c = Number.isFinite(n.width) ? n.width : 0, l = Number.isFinite(n.height) ? n.height : 0;
1315
1504
  this.pendingTabDragMetrics = {
1316
- pointerOffsetX: n,
1505
+ pointerOffsetX: o,
1317
1506
  pointerOffsetY: r,
1318
- left: c,
1319
- top: l,
1320
- width: s,
1321
- height: a,
1507
+ left: d,
1508
+ top: s,
1509
+ width: c,
1510
+ height: l,
1322
1511
  startClientX: t.clientX,
1323
1512
  startClientY: t.clientY
1324
1513
  };
@@ -1334,26 +1523,26 @@ class P extends A {
1334
1523
  * Once armed, both paths converge on {@link beginPaneDrag}. All listeners
1335
1524
  * self-clean on resolve so the gesture stays scoped to a single pointerdown.
1336
1525
  */
1337
- armPaneDragGesture(t, e, i, o) {
1526
+ armPaneDragGesture(t, e, i, n) {
1338
1527
  if (t.pointerType === "touch") {
1339
- this.armPaneDragGestureTouch(t, e, i, o);
1528
+ this.armPaneDragGestureTouch(t, e, i, n);
1340
1529
  return;
1341
1530
  }
1342
1531
  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);
1532
+ const o = this.windowRef;
1533
+ if (!o) return;
1534
+ const r = t.clientX, d = t.clientY, s = t.pointerId, c = 5;
1535
+ let l = !1;
1536
+ const u = () => {
1537
+ l = !0, o.removeEventListener("pointermove", h, !0), o.removeEventListener("pointerup", p, !0), o.removeEventListener("pointercancel", p, !0);
1349
1538
  }, 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());
1539
+ if (l || g.pointerId !== s) return;
1540
+ const m = g.clientX - r, f = g.clientY - d;
1541
+ Math.hypot(m, f) < c || (u(), this.beginPaneDrag(g, e, i, n));
1542
+ }, p = (g) => {
1543
+ l || g.pointerId !== s || (u(), this.clearPendingTabDragMetrics());
1355
1544
  };
1356
- n.addEventListener("pointermove", h, !0), n.addEventListener("pointerup", d, !0), n.addEventListener("pointercancel", d, !0);
1545
+ o.addEventListener("pointermove", h, !0), o.addEventListener("pointerup", p, !0), o.addEventListener("pointercancel", p, !0);
1357
1546
  }
1358
1547
  /**
1359
1548
  * Touch-specific gesture arming. With `.dock-tab` set to `touch-action:
@@ -1376,41 +1565,41 @@ class P extends A {
1376
1565
  * promote it, so first move after a long-press fires pointercancel and
1377
1566
  * strands the panel. JS-driven scroll is the only model that holds.
1378
1567
  */
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(
1568
+ armPaneDragGestureTouch(t, e, i, n) {
1569
+ const o = this.windowRef;
1570
+ if (!o) return;
1571
+ const r = t.clientX, d = t.clientY, s = t.pointerId;
1572
+ let c = r, l = d, u = r, h = !1, p = !1, g = !1;
1573
+ const m = t.currentTarget instanceof HTMLElement ? t.currentTarget : t.target instanceof HTMLElement ? t.target.closest(".dock-tab") : null, f = n ? this.getStackStripEl(n)?.querySelector(
1385
1574
  "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);
1575
+ ) ?? null : null, y = () => {
1576
+ h || (h = !0, o.clearTimeout(P), o.clearTimeout(z), o.removeEventListener("pointermove", b, !0), o.removeEventListener("pointerup", k, !0), o.removeEventListener("pointercancel", D, !0), g && m && m.removeAttribute("data-pressing"));
1577
+ }, b = (v) => {
1578
+ if (h || v.pointerId !== s) return;
1579
+ if (p) {
1580
+ const K = v.clientX - u;
1581
+ u = v.clientX, f && (f.scrollLeft -= K);
1393
1582
  return;
1394
1583
  }
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)
1584
+ c = v.clientX, l = v.clientY;
1585
+ const F = v.clientX - r, $ = v.clientY - d;
1586
+ if (Math.hypot(F, $) <= L.TOUCH_LONG_PRESS_SLOP_PX)
1398
1587
  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();
1588
+ const Z = !!f && f.scrollWidth > f.clientWidth;
1589
+ if (Math.abs(F) > Math.abs($) && Z) {
1590
+ o.clearTimeout(P), o.clearTimeout(z), g && m && (m.removeAttribute("data-pressing"), g = !1), p = !0, u = v.clientX, f.scrollLeft -= F, this.clearPendingTabDragMetrics();
1402
1591
  return;
1403
1592
  }
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(() => {
1593
+ y(), this.clearPendingTabDragMetrics();
1594
+ }, k = (v) => {
1595
+ h || v.pointerId !== s || (y(), this.clearPendingTabDragMetrics());
1596
+ }, D = (v) => {
1597
+ h || v.pointerId !== s || (y(), this.clearPendingTabDragMetrics());
1598
+ }, P = o.setTimeout(() => {
1410
1599
  if (h) return;
1411
- m();
1600
+ y();
1412
1601
  try {
1413
- this.setPointerCapture(l);
1602
+ this.setPointerCapture(s);
1414
1603
  } catch {
1415
1604
  }
1416
1605
  if (typeof navigator < "u" && typeof navigator.vibrate == "function")
@@ -1418,79 +1607,79 @@ class P extends A {
1418
1607
  navigator.vibrate(10);
1419
1608
  } catch {
1420
1609
  }
1421
- const k = new PointerEvent("pointermove", {
1422
- pointerId: l,
1610
+ const v = new PointerEvent("pointermove", {
1611
+ pointerId: s,
1423
1612
  pointerType: "touch",
1424
1613
  isPrimary: !0,
1425
- clientX: s,
1426
- clientY: a,
1614
+ clientX: c,
1615
+ clientY: l,
1427
1616
  bubbles: !1,
1428
1617
  cancelable: !1
1429
1618
  });
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);
1619
+ this.beginPaneDrag(v, e, i, n);
1620
+ }, L.TOUCH_LONG_PRESS_MS), z = o.setTimeout(() => {
1621
+ h || !m || (g = !0, m.setAttribute("data-pressing", "true"));
1622
+ }, L.TOUCH_PRESS_FEEDBACK_DELAY_MS);
1623
+ o.addEventListener("pointermove", b, !0), o.addEventListener("pointerup", k, !0), o.addEventListener("pointercancel", D, !0);
1435
1624
  }
1436
- beginPaneDrag(t, e, i, o) {
1625
+ beginPaneDrag(t, e, i, n) {
1437
1626
  const {
1438
- path: n,
1627
+ path: o,
1439
1628
  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;
1629
+ pointerOffsetX: d,
1630
+ pointerOffsetY: s
1631
+ } = this.preparePaneDragSource(e, i, n, t), c = n ? this.getStackStripEl(n) : null, l = c ? c.getBoundingClientRect() : null, u = l ? { left: l.left, top: l.top, right: l.right, bottom: l.bottom } : null, h = this.pendingTabDragMetrics;
1443
1632
  if (this.dragState = {
1444
1633
  pane: i,
1445
- sourcePath: this.clonePath(n),
1634
+ sourcePath: this.clonePath(o),
1446
1635
  floatingIndex: r,
1447
- pointerOffsetX: c,
1448
- pointerOffsetY: l,
1636
+ pointerOffsetX: d,
1637
+ pointerOffsetY: s,
1449
1638
  dropHandled: !1,
1450
- sourceStackEl: o,
1451
- sourceHeaderBounds: p,
1639
+ sourceStackEl: n,
1640
+ sourceHeaderBounds: u,
1452
1641
  startClientX: h && Number.isFinite(h.startClientX) ? h.startClientX : t.clientX,
1453
1642
  startClientY: h && Number.isFinite(h.startClientY) ? h.startClientY : t.clientY
1454
1643
  }, this.lastDragPointerPosition = {
1455
1644
  x: this.dragState.startClientX,
1456
1645
  y: this.dragState.startClientY
1457
1646
  }, 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) {
1647
+ const p = this.resolveStackLocation(this.dragState.sourcePath);
1648
+ if (p && Array.isArray(p.node.panes) && p.node.panes.length === 1) {
1460
1649
  let g = !1;
1461
- if (d.context === "docked")
1650
+ if (p.context === "docked")
1462
1651
  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;
1652
+ else if (p.context === "floating") {
1653
+ const m = this.floatingLayouts[p.index];
1654
+ g = (m && m.root ? this.countPanesInTree(m.root) : 0) > 1;
1466
1655
  }
1467
1656
  g && this.convertPendingTabDragToFloating(t.clientX, t.clientY);
1468
1657
  }
1469
1658
  }
1470
1659
  }
1471
- preparePaneDragSource(t, e, i, o) {
1472
- const n = this.resolveStackLocation(t);
1473
- if (!n || !n.node.panes.includes(e))
1660
+ preparePaneDragSource(t, e, i, n) {
1661
+ const o = this.resolveStackLocation(t);
1662
+ if (!o || !o.node.panes.includes(e))
1474
1663
  return {
1475
1664
  path: t,
1476
1665
  floatingIndex: null,
1477
1666
  pointerOffsetX: 0,
1478
1667
  pointerOffsetY: 0
1479
1668
  };
1480
- const r = this.pendingTabDragMetrics, c = !!i && Array.from(i.querySelectorAll(".dock-tab")).some(
1669
+ const r = this.pendingTabDragMetrics, d = !!i && Array.from(i.querySelectorAll(".dock-tab")).some(
1481
1670
  (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;
1671
+ ), s = o.node.panes.some((g) => g !== e), c = o.context === "floating" ? this.floatingLayouts[o.index] : null, l = c && c.root ? this.countPanesInTree(c.root) : s ? 2 : 1;
1672
+ if (o.context === "floating" && !!c && !s && !d && l <= 1) {
1673
+ if (c) {
1674
+ c.activePane = e, this.updateFloatingWindowTitle(o.index);
1675
+ const g = this.getFloatingWrapper(o.index);
1676
+ g && this.promoteFloatingPane(o.index, g);
1677
+ const m = this.getBoundingClientRect(), f = 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
1678
  return {
1490
1679
  path: t,
1491
- floatingIndex: n.index,
1492
- pointerOffsetX: u,
1493
- pointerOffsetY: m
1680
+ floatingIndex: o.index,
1681
+ pointerOffsetX: f,
1682
+ pointerOffsetY: y
1494
1683
  };
1495
1684
  }
1496
1685
  return {
@@ -1500,12 +1689,12 @@ class P extends A {
1500
1689
  pointerOffsetY: 0
1501
1690
  };
1502
1691
  }
1503
- const h = r && Number.isFinite(r.pointerOffsetX) ? r.pointerOffsetX : 0, d = r && Number.isFinite(r.pointerOffsetY) ? r.pointerOffsetY : 0;
1692
+ const h = r && Number.isFinite(r.pointerOffsetX) ? r.pointerOffsetX : 0, p = r && Number.isFinite(r.pointerOffsetY) ? r.pointerOffsetY : 0;
1504
1693
  return {
1505
1694
  path: t,
1506
1695
  floatingIndex: -1,
1507
1696
  pointerOffsetX: h,
1508
- pointerOffsetY: d
1697
+ pointerOffsetY: p
1509
1698
  };
1510
1699
  }
1511
1700
  endPaneDrag() {
@@ -1517,42 +1706,42 @@ class P extends A {
1517
1706
  if (!this.dragState || !Number.isFinite(t) || !Number.isFinite(e))
1518
1707
  return;
1519
1708
  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);
1709
+ const u = this.dragState.sourceHeaderBounds, h = this.dragState.startClientX ?? t, p = this.dragState.startClientY ?? e, g = Math.hypot(t - h, e - p), m = 8;
1710
+ let f = !0;
1711
+ const y = u ? J(u, t, e) : !0, b = this.isPointerOverSourceHeader(t, e);
1712
+ f = y || b, !f && g > m && this.convertPendingTabDragToFloating(t, e);
1524
1713
  }
1525
1714
  this.updatePaneDragDropTargetFromPoint(t, e);
1526
- const { floatingIndex: i, pointerOffsetX: o, pointerOffsetY: n } = this.dragState;
1715
+ const { floatingIndex: i, pointerOffsetX: n, pointerOffsetY: o } = this.dragState;
1527
1716
  if (i === null || i < 0)
1528
1717
  return;
1529
1718
  const r = this.floatingLayouts[i];
1530
1719
  if (!r)
1531
1720
  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`);
1721
+ const d = this.getBoundingClientRect(), s = t - d.left - n, c = e - d.top - o;
1722
+ r.bounds.left = s, r.bounds.top = c;
1723
+ const l = this.getFloatingWrapper(i);
1724
+ l && (l.style.left = `${s}px`, l.style.top = `${c}px`);
1536
1725
  }
1537
1726
  updatePaneDragDropTargetFromPoint(t, e) {
1538
1727
  if (!this.dragState)
1539
1728
  return;
1540
- const i = this.findStackAtPoint(t, e), o = i ? this.parsePath(i.dataset.path) : null;
1541
- if (!i || !o) {
1729
+ const i = this.findStackAtPoint(t, e), n = i ? S(i.dataset.path) : null;
1730
+ if (!i || !n) {
1542
1731
  this.dropJoystick.dataset.visible !== "true" && this.hideDropIndicator(), this.clearHeaderDragPlaceholder();
1543
1732
  return;
1544
1733
  }
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) {
1734
+ 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 && O(n, this.dragState.sourcePath)) {
1735
+ const d = !!this.dragState.sourceHeaderBounds && J(this.dragState.sourceHeaderBounds, t, e), s = this.isPointerOverSourceHeader(t, e);
1736
+ if (d || s) {
1548
1737
  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();
1738
+ const c = this.computeHeaderInsertIndex(i, t);
1739
+ this.dragState.liveReorderIndex !== c && (this.updateHeaderDragPlaceholderPosition(i, c), this.dragState.liveReorderIndex = c), this.hideDropIndicator();
1551
1740
  return;
1552
1741
  }
1553
1742
  }
1554
1743
  this.clearHeaderDragPlaceholder();
1555
- const n = this.findDropZoneByPoint(t, e), r = this.computeDropZone(i, { clientX: t, clientY: e }, n);
1744
+ const o = this.findDropZoneByPoint(t, e), r = this.computeDropZone(i, { clientX: t, clientY: e }, o);
1556
1745
  this.showDropIndicator(i, r);
1557
1746
  }
1558
1747
  // Returns true when the pointer is currently over the source stack's header (tab strip).
@@ -1563,15 +1752,12 @@ class P extends A {
1563
1752
  const i = this.dragState;
1564
1753
  if (!i)
1565
1754
  return !1;
1566
- const o = i.sourceStackEl ?? null, n = o ? this.getStackStripEl(o) : null;
1567
- if (!n)
1755
+ const n = i.sourceStackEl ?? null, o = n ? this.getStackStripEl(n) : null;
1756
+ if (!o)
1568
1757
  return !0;
1569
- const r = n.getBoundingClientRect();
1758
+ const r = o.getBoundingClientRect();
1570
1759
  return t >= r.left && t <= r.right && e >= r.top && e <= r.bottom;
1571
1760
  }
1572
- isPointWithinBounds(t, e, i) {
1573
- return e >= t.left && e <= t.right && i >= t.top && i <= t.bottom;
1574
- }
1575
1761
  // Ensure a placeholder tab exists during in-header drag and hide the real dragged tab visually.
1576
1762
  // Operates on the mp-tab-control stack: the dragged content div gets `data-hidden`
1577
1763
  // (mp-tab-control then skips its tab in the strip), and a placeholder header+content
@@ -1582,19 +1768,19 @@ class P extends A {
1582
1768
  return;
1583
1769
  const i = t.querySelector(
1584
1770
  `:scope > .dock-tab[data-pane="${CSS.escape(e)}"]`
1585
- ), o = t.querySelector(
1771
+ ), n = t.querySelector(
1586
1772
  `:scope > .dock-stack__pane[data-pane="${CSS.escape(e)}"]`
1587
1773
  );
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(
1774
+ if (!i || !n) return;
1775
+ const o = this.windowRef ? this.windowRef.getComputedStyle(i) : globalThis.getComputedStyle(i), r = parseFloat(o.paddingLeft) + parseFloat(o.paddingRight), d = Math.max(
1590
1776
  0,
1591
1777
  i.offsetWidth - r
1592
1778
  );
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);
1779
+ n.setAttribute("data-hidden", "");
1780
+ const s = "__dock-placeholder__", c = this.documentRef.createElement("span");
1781
+ c.setAttribute("slot", `${s}-header`), c.classList.add("dock-tab"), c.dataset.placeholder = "true", c.dataset.tabId = s, c.setAttribute("aria-hidden", "true"), c.textContent = i.textContent, c.style.display = "inline-block", c.style.minWidth = `${d}px`, c.style.opacity = "0.5";
1782
+ const l = this.documentRef.createElement("div");
1783
+ l.setAttribute("slot", `${s}-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
1784
  }
1599
1785
  // Move the placeholder to the computed target index within the strip.
1600
1786
  // We reorder light-DOM children (header span + matching content div); the
@@ -1603,16 +1789,16 @@ class P extends A {
1603
1789
  if (t.tagName !== "MP-TAB-CONTROL") return;
1604
1790
  const i = this.dragState?.placeholderEl ?? null;
1605
1791
  if (!i) return;
1606
- const o = this.dragState?.pane ?? null, n = Array.from(
1792
+ const n = this.dragState?.pane ?? null, o = Array.from(
1607
1793
  t.querySelectorAll(":scope > .dock-tab")
1608
1794
  ).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(
1795
+ (c) => c !== i && (!n || c.dataset.pane !== n)
1796
+ ), r = Math.max(0, Math.min(e, o.length)), d = o[r] ?? null;
1797
+ t.insertBefore(i, d);
1798
+ const s = t.querySelector(
1613
1799
  ':scope > .dock-stack__pane[data-placeholder="true"]'
1614
1800
  );
1615
- l && i.nextElementSibling !== l && t.insertBefore(l, i.nextElementSibling);
1801
+ s && i.nextElementSibling !== s && t.insertBefore(s, i.nextElementSibling);
1616
1802
  }
1617
1803
  // Remove placeholder and restore the dragged tab's visibility.
1618
1804
  clearHeaderDragPlaceholder() {
@@ -1661,28 +1847,28 @@ class P extends A {
1661
1847
  if (i.floatingIndex !== null && i.floatingIndex >= 0)
1662
1848
  return;
1663
1849
  this.clearHeaderDragPlaceholder();
1664
- const o = this.resolveStackLocation(i.sourcePath);
1665
- if (!o)
1850
+ const n = this.resolveStackLocation(i.sourcePath);
1851
+ if (!n)
1666
1852
  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 },
1853
+ const o = i.pane, r = i.sourceStackEl ?? null, d = this.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = this.pendingTabDragMetrics, l = 320, u = 240, h = c && Number.isFinite(c.width) && c.width > 0 ? c.width : s && Number.isFinite(s.width) ? s.width : l, p = c && Number.isFinite(c.height) && c.height > 0 ? c.height : s && Number.isFinite(s.height) ? s.height : u, g = 1, m = c && Number.isFinite(c.left) ? c.left - g : Number.isFinite(t) ? t - d.left - h / 2 : 0, f = c && Number.isFinite(c.top) ? c.top - g : Number.isFinite(e) ? e - d.top - p / 2 : 0, y = R(
1854
+ { left: m, top: f, width: h, height: p },
1669
1855
  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,
1856
+ ), b = Number.isFinite(t) ? t - d.left - y.left : y.width / 2, k = Number.isFinite(e) ? e - d.top - y.top : y.height / 2;
1857
+ this.removePaneFromLocation(n, o);
1858
+ const P = {
1859
+ bounds: y,
1674
1860
  root: {
1675
1861
  kind: "stack",
1676
- panes: [n],
1677
- activePane: n
1862
+ panes: [o],
1863
+ activePane: o
1678
1864
  },
1679
- activePane: n
1865
+ activePane: o
1680
1866
  };
1681
- this.floatingLayouts.push(S);
1682
- const v = this.floatingLayouts.length - 1;
1867
+ this.floatingLayouts.push(P);
1868
+ const z = this.floatingLayouts.length - 1;
1683
1869
  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();
1870
+ const v = this.getFloatingWrapper(z);
1871
+ 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
1872
  }
1687
1873
  // Toggle data-dragging on the floating wrapper currently associated with
1688
1874
  // the active pane drag (dragState.floatingIndex), if any. Used to make the
@@ -1709,54 +1895,52 @@ class P extends A {
1709
1895
  const i = this.getStackTabButtons(t);
1710
1896
  if (i.length === 0)
1711
1897
  return 0;
1712
- const n = t.querySelector(
1898
+ const o = t.querySelector(
1713
1899
  ':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;
1900
+ )?.dataset.tabId, r = o ? i.find((m) => m.id === `${o}-header-button`) ?? null : null, d = this.dragState?.pane ?? null;
1901
+ let s = null;
1902
+ if (d) {
1903
+ for (const m of Array.from(t.children))
1904
+ if (m instanceof HTMLElement && m.classList.contains("dock-tab") && !m.hasAttribute("data-placeholder") && m.dataset.pane === d) {
1905
+ s = m.dataset.tabId ?? null;
1720
1906
  break;
1721
1907
  }
1722
1908
  }
1723
- const s = l ? i.find((u) => u.id === `${l}-header-button`) ?? null : null, a = i.filter(
1724
- (u) => u !== r && u !== s
1909
+ const c = s ? i.find((m) => m.id === `${s}-header-button`) ?? null : null, l = i.filter(
1910
+ (m) => m !== r && m !== c
1725
1911
  );
1726
- if (a.length === 0)
1912
+ if (l.length === 0)
1727
1913
  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;
1914
+ const u = r ? r.getBoundingClientRect() : null, p = !!u && Number.isFinite(u.width) && u.width > 0 && u ? u.left + u.width / 2 : null, g = l.map((m) => {
1915
+ const f = m.getBoundingClientRect();
1916
+ return f.left + f.width / 2;
1917
+ });
1918
+ return dt(g, e, p);
1735
1919
  }
1736
1920
  reorderPaneInLocationAtIndex(t, e, i) {
1737
- const o = t.node.panes, n = o.indexOf(e);
1738
- if (n === -1)
1921
+ const n = t.node.panes, o = n.indexOf(e);
1922
+ if (o === -1)
1739
1923
  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);
1924
+ const r = Math.max(0, Math.min(i, n.length - 1));
1925
+ if (r !== o && (n.splice(o, 1), n.splice(r, 0, e), t.node.activePane = e, t.context === "floating")) {
1926
+ const d = this.floatingLayouts[t.index];
1927
+ d && (d.activePane = e);
1744
1928
  }
1745
1929
  }
1746
1930
  // Commit a drop using current pointer coordinates and joystick state
1747
1931
  finalizeDropFromPoint(t, e) {
1748
1932
  if (!this.dragState)
1749
1933
  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);
1934
+ 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, s = d ? S(d.dataset.path) : null, c = (o ? r ?? s : null) ?? n, l = this.dropJoystick.dataset.zone, u = this.isDropZone(l) ? l : i ? this.computeDropZone(i, { clientX: t, clientY: e }, null) : null;
1935
+ if (this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && i && c && n && O(n, this.dragState.sourcePath) && (!u || u === "center")) {
1936
+ const h = this.resolveStackLocation(c);
1753
1937
  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;
1938
+ const p = this.computeHeaderInsertIndex(i, t);
1939
+ this.reorderPaneInLocationAtIndex(h, this.dragState.pane, p), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState.dropHandled = !0;
1756
1940
  return;
1757
1941
  }
1758
1942
  }
1759
- s && this.isDropZone(p) && (this.handleDrop(s, p), this.dragState.dropHandled = !0);
1943
+ c && this.isDropZone(u) && (this.handleDrop(c, u), this.dragState.dropHandled = !0);
1760
1944
  }
1761
1945
  clearPendingDragEndTimeout() {
1762
1946
  if (this.pendingDragEndTimeout !== null) {
@@ -1779,107 +1963,80 @@ class P extends A {
1779
1963
  handleDrop(t, e) {
1780
1964
  if (!this.dragState || !t)
1781
1965
  return;
1782
- const { pane: i, sourcePath: o } = this.dragState, n = this.resolveStackLocation(o), r = this.resolveStackLocation(t);
1966
+ const { pane: i, sourcePath: n } = this.dragState, o = this.resolveStackLocation(n), r = this.resolveStackLocation(t);
1783
1967
  if (!r && t.type === "docked" && !this.rootLayout) {
1784
- if (!n)
1968
+ if (!o)
1785
1969
  return;
1786
- this.removePaneFromLocation(n, i, !0);
1787
- const l = {
1970
+ this.removePaneFromLocation(o, i, !0);
1971
+ const s = {
1788
1972
  kind: "stack",
1789
1973
  panes: [i],
1790
1974
  activePane: i
1791
1975
  };
1792
- this.rootLayout = l, this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1976
+ this.rootLayout = s, this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1793
1977
  return;
1794
1978
  }
1795
- if (!n || !r)
1979
+ if (!o || !r)
1796
1980
  return;
1797
- if (e === "center" && this.pathsEqual(o, t)) {
1798
- if (!n.node.panes.includes(i))
1981
+ if (e === "center" && O(n, t)) {
1982
+ if (!o.node.panes.includes(i))
1799
1983
  return;
1800
- this.reorderPaneInLocation(n, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1984
+ this.reorderPaneInLocation(o, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1801
1985
  return;
1802
1986
  }
1803
- if (this.removePaneFromLocation(n, i, !0), e === "center") {
1987
+ if (this.removePaneFromLocation(o, i, !0), e === "center") {
1804
1988
  this.addPaneToLocation(r, i), this.setActivePaneForLocation(r, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1805
1989
  return;
1806
1990
  }
1807
- const c = {
1991
+ const d = {
1808
1992
  kind: "stack",
1809
1993
  panes: [i],
1810
1994
  activePane: i
1811
1995
  };
1812
1996
  if (r.context === "docked")
1813
- this.rootLayout = this.dockNodeBeside(this.rootLayout, r.node, c, e);
1997
+ this.rootLayout = A(this.rootLayout, r.node, d, e);
1814
1998
  else {
1815
- const l = this.floatingLayouts[r.index];
1816
- if (!l) {
1999
+ const s = this.floatingLayouts[r.index];
2000
+ if (!s) {
1817
2001
  this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged();
1818
2002
  return;
1819
2003
  }
1820
- l.root = this.dockNodeBeside(l.root, r.node, c, e), l.activePane = i;
2004
+ s.root = A(s.root, r.node, d, e), s.activePane = i;
1821
2005
  }
1822
2006
  this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
1823
2007
  }
1824
2008
  handleFloatingStackDrop(t, e, i) {
1825
- const o = this.floatingLayouts[t];
1826
- if (!o || !o.root)
2009
+ const n = this.floatingLayouts[t];
2010
+ if (!n || !n.root)
1827
2011
  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)
2012
+ const o = this.resolveStackLocation(e);
2013
+ if (!o && e.type === "docked" && !this.rootLayout)
2014
+ return this.rootLayout = _(n.root), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
2015
+ if (!o || o.context === "floating" && o.index === t)
1832
2016
  return !1;
1833
2017
  if (i === "center") {
1834
- const r = this.collectPaneNames(o.root);
2018
+ const r = I(n.root);
1835
2019
  if (r.length === 0)
1836
2020
  return !1;
1837
- r.forEach((l) => {
1838
- this.addPaneToLocation(n, l);
2021
+ r.forEach((s) => {
2022
+ this.addPaneToLocation(o, s);
1839
2023
  });
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;
2024
+ const d = n.activePane && r.includes(n.activePane) ? n.activePane : E(n.root) ?? r[0];
2025
+ return d && this.setActivePaneForLocation(o, d), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
1842
2026
  }
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;
1846
- }
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;
2027
+ if (o.context === "floating") {
2028
+ const r = this.floatingLayouts[o.index];
2029
+ return r ? (r.root = A(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;
1873
2030
  }
1874
- return null;
2031
+ return this.rootLayout = A(this.rootLayout, o.node, n.root, i), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
1875
2032
  }
1876
2033
  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;
2034
+ const n = this.isDropZone(i) ? i : null;
1881
2035
  if (n)
1882
2036
  return this.updateDropJoystickActiveZone(n), n;
2037
+ const o = e && Number.isFinite(e.clientX) && Number.isFinite(e.clientY) ? this.findDropZoneByPoint(e.clientX, e.clientY) : null;
2038
+ if (o)
2039
+ return this.updateDropJoystickActiveZone(o), o;
1883
2040
  if (this.dropJoystickTarget === t) {
1884
2041
  const r = this.dropJoystick.dataset.zone;
1885
2042
  if (this.isDropZone(r))
@@ -1925,64 +2082,64 @@ class P extends A {
1925
2082
  for (const i of this.dropJoystickButtons) {
1926
2083
  if (i.dataset.hidden === "true" || i.style.visibility === "hidden" || i.style.display === "none")
1927
2084
  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;
2085
+ const n = i.getBoundingClientRect();
2086
+ if (t >= n.left && t <= n.right && e >= n.top && e <= n.bottom) {
2087
+ const o = i.dataset.zone;
2088
+ if (this.isDropZone(o))
2089
+ return o;
1933
2090
  }
1934
2091
  }
1935
2092
  return null;
1936
2093
  }
1937
2094
  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;
2095
+ const i = this.dropJoystick.dataset.visible === "true" ? this.dropJoystick.dataset.zone : void 0, n = t ?? (this.isDropZone(i) ? i : null);
2096
+ this.dropJoystickButtons.forEach((o) => {
2097
+ n !== null && o.dataset.zone === n ? o.dataset.active = "true" : delete o.dataset.active;
2098
+ }), n ? this.dropJoystick.dataset.zone = n : delete this.dropJoystick.dataset.zone;
1942
2099
  }
1943
2100
  isDropZone(t) {
1944
2101
  return t === "left" || t === "right" || t === "top" || t === "bottom" || t === "center";
1945
2102
  }
1946
2103
  showDropIndicator(t, e) {
1947
- const i = this.parsePath(t.dataset.path), o = this.dragState?.sourcePath ?? null;
1948
- if (i && o && this.isOrIsAncestorOf(i, o))
2104
+ const i = S(t.dataset.path), n = this.dragState?.sourcePath ?? null;
2105
+ if (i && n && this.isOrIsAncestorOf(i, n))
1949
2106
  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;
2107
+ const o = t.getBoundingClientRect(), r = this.getBoundingClientRect(), d = this.dropIndicator, s = this.dropJoystick;
2108
+ s.hidden = !1;
2109
+ const c = S(t.dataset.path);
2110
+ let l = 100;
2111
+ c && c.type === "floating" && (l = N(this.floatingLayouts[c.index], c.index) + 100), d.style.zIndex = String(l), s.style.zIndex = String(l + 1);
2112
+ let u = o.left - r.left, h = o.top - r.top, p = o.width, g = o.height;
2113
+ const m = 0.5;
1957
2114
  if (e) {
1958
2115
  switch (e) {
1959
2116
  case "left":
1960
- d = n.width * f;
2117
+ p = o.width * m;
1961
2118
  break;
1962
2119
  case "right":
1963
- d = n.width * f, p += n.width * (1 - f);
2120
+ p = o.width * m, u += o.width * (1 - m);
1964
2121
  break;
1965
2122
  case "top":
1966
- g = n.height * f;
2123
+ g = o.height * m;
1967
2124
  break;
1968
2125
  case "bottom":
1969
- g = n.height * f, h += n.height * (1 - f);
2126
+ g = o.height * m, h += o.height * (1 - m);
1970
2127
  break;
1971
2128
  }
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";
2129
+ d.style.left = `${u}px`, d.style.top = `${h}px`, d.style.width = `${p}px`, d.style.height = `${g}px`, d.dataset.visible = "true";
1973
2130
  } 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);
2131
+ d.dataset.visible = "false";
2132
+ s.style.left = `${o.left - r.left + o.width / 2}px`, s.style.top = `${o.top - r.top + o.height / 2}px`, s.dataset.visible = "true", this.dropJoystick.style.display = "grid", s.dataset.path = t.dataset.path ?? "";
2133
+ const f = this.dropJoystickTarget && this.dropJoystickTarget !== t;
2134
+ this.dropJoystickTarget = t, f && delete this.dropJoystick.dataset.zone;
2135
+ 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"));
2136
+ y ? (b.forEach((k) => {
2137
+ k.style.display = "";
2138
+ }), this.dropJoystickButtons.forEach((k) => {
2139
+ 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 = "");
2140
+ }), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = "") : (this.dropJoystickButtons.forEach((k) => {
2141
+ k.style.visibility = "", k.style.pointerEvents = "", delete k.dataset.hidden, k.style.display = "";
2142
+ }), b.forEach((k) => k.style.display = ""), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = ""), this.updateDropJoystickActiveZone(e);
1986
2143
  }
1987
2144
  hideDropIndicator() {
1988
2145
  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 +2150,9 @@ class P extends A {
1993
2150
  const i = this.shadowRoot;
1994
2151
  if (!i)
1995
2152
  return null;
1996
- const o = i.elementsFromPoint(t, e), n = this.findStackInTargets(o);
1997
- if (n)
1998
- return n;
2153
+ const n = i.elementsFromPoint(t, e), o = this.findStackInTargets(n);
2154
+ if (o)
2155
+ return o;
1999
2156
  if (!this.rootLayout) {
2000
2157
  const r = this.dockedEl.getBoundingClientRect();
2001
2158
  if (t >= r.left && t <= r.right && e >= r.top && e <= r.bottom)
@@ -2020,122 +2177,41 @@ class P extends A {
2020
2177
  )?.dataset.tabId;
2021
2178
  r && t.setAttribute("active-tab", r);
2022
2179
  }
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);
2180
+ const n = this.resolveStackLocation(i);
2181
+ if (n) {
2182
+ if (n.node.activePane = e, i.type === "floating") {
2183
+ const o = this.floatingLayouts[i.index];
2184
+ o && (o.activePane = e), this.updateFloatingWindowTitle(i.index);
2028
2185
  }
2029
2186
  this.dispatchLayoutChanged();
2030
2187
  }
2031
2188
  }
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
2189
  resolveSplitNode(t) {
2046
2190
  if (t.type === "docked") {
2047
- const o = this.getNodeAtPath(this.rootLayout, t.segments);
2048
- return o && o.kind === "split" ? o : null;
2191
+ const n = T(this.rootLayout, t.segments);
2192
+ return n && n.kind === "split" ? n : null;
2049
2193
  }
2050
2194
  const e = this.floatingLayouts[t.index];
2051
2195
  if (!e || !e.root)
2052
2196
  return null;
2053
- const i = this.getNodeAtPath(e.root, t.segments);
2197
+ const i = T(e.root, t.segments);
2054
2198
  return i && i.kind === "split" ? i : null;
2055
2199
  }
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
2200
  normalizeFloatingLayout(t) {
2117
2201
  const e = t.bounds ?? { left: 0, top: 0, width: 320, height: 200 }, i = {
2118
2202
  left: Number.isFinite(e.left) ? e.left : 0,
2119
2203
  top: Number.isFinite(e.top) ? e.top : 0,
2120
2204
  width: Number.isFinite(e.width) ? Math.max(e.width, 160) : 320,
2121
2205
  height: Number.isFinite(e.height) ? Math.max(e.height, 120) : 200
2122
- }, o = t.root ? this.cloneLayoutNode(t.root) : null;
2206
+ }, n = t.root ? _(t.root) : null;
2123
2207
  return {
2124
2208
  id: t.id,
2125
2209
  bounds: i,
2126
2210
  zIndex: t.zIndex,
2127
- root: o,
2211
+ root: n,
2128
2212
  activePane: t.activePane
2129
2213
  };
2130
2214
  }
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
2215
  // Layer identity of a splitter in the rendered shadow tree. Splitters inside
2140
2216
  // floating pane N are nested under `.dock-floating[data-path="f:N"]`;
2141
2217
  // docked-layer splitters have no such ancestor. Two splitters share a layer
@@ -2149,31 +2225,8 @@ class P extends A {
2149
2225
  clonePath(t) {
2150
2226
  return t.type === "floating" ? { type: "floating", index: t.index, segments: [...t.segments] } : { type: "docked", segments: [...t.segments] };
2151
2227
  }
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
2228
  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]);
2229
+ return t.type !== e.type || t.type === "floating" && e.index !== t.index || t.segments.length > e.segments.length ? !1 : t.segments.every((i, n) => i === e.segments[n]);
2177
2230
  }
2178
2231
  countPanesInTree(t) {
2179
2232
  return t ? t.kind === "stack" ? t.panes.length : t.children.reduce((e, i) => e + this.countPanesInTree(i), 0) : 0;
@@ -2183,18 +2236,22 @@ class P extends A {
2183
2236
  const i = this.floatingLayouts[t.index];
2184
2237
  if (!i || !i.root)
2185
2238
  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 };
2239
+ const n = T(i.root, t.segments);
2240
+ return !n || n.kind !== "stack" ? null : { context: "floating", index: t.index, path: [...t.segments], node: n };
2188
2241
  }
2189
- const e = this.getNodeAtPath(this.rootLayout, t.segments);
2242
+ const e = T(this.rootLayout, t.segments);
2190
2243
  return !e || e.kind !== "stack" ? null : { context: "docked", path: [...t.segments], node: e };
2191
2244
  }
2192
2245
  removePaneFromLocation(t, e, i = !1) {
2193
- return t.context === "docked" ? this.removePaneFromStack(t.node, e, i) : this.removePaneFromFloating(t.index, t.path, e, i);
2246
+ if (t.context === "docked") {
2247
+ const n = rt(t.node, e);
2248
+ return n && !i && this.normalizeAllLayouts(), n;
2249
+ }
2250
+ return this.removePaneFromFloating(t.index, t.path, e, i);
2194
2251
  }
2195
2252
  addPaneToLocation(t, e) {
2196
- const i = t.node.panes, o = i.indexOf(e);
2197
- o !== -1 && i.splice(o, 1), i.push(e);
2253
+ const i = t.node.panes, n = i.indexOf(e);
2254
+ n !== -1 && i.splice(n, 1), i.push(e);
2198
2255
  }
2199
2256
  setActivePaneForLocation(t, e) {
2200
2257
  if (t.node.activePane = e, t.context === "floating") {
@@ -2203,10 +2260,10 @@ class P extends A {
2203
2260
  }
2204
2261
  }
2205
2262
  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);
2263
+ const i = t.node.panes, n = i.indexOf(e);
2264
+ if (n !== -1 && (i.splice(n, 1), i.push(e), t.node.activePane = e, t.context === "floating")) {
2265
+ const o = this.floatingLayouts[t.index];
2266
+ o && (o.activePane = e);
2210
2267
  }
2211
2268
  }
2212
2269
  removeFloatingAt(t) {
@@ -2259,14 +2316,14 @@ class P extends A {
2259
2316
  const e = t.composedPath()[0];
2260
2317
  if (e instanceof HTMLElement && (e.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(e.tagName)))
2261
2318
  return;
2262
- const o = {
2319
+ const n = {
2263
2320
  ArrowRight: 1,
2264
2321
  ArrowDown: 1,
2265
2322
  ArrowLeft: -1,
2266
2323
  ArrowUp: -1
2267
2324
  }[t.key];
2268
- if (o) {
2269
- t.preventDefault(), t.stopPropagation(), this.cyclePaneMoveCandidate(o);
2325
+ if (n) {
2326
+ t.preventDefault(), t.stopPropagation(), this.cyclePaneMoveCandidate(n);
2270
2327
  return;
2271
2328
  }
2272
2329
  if (t.key === "Enter") {
@@ -2274,14 +2331,14 @@ class P extends A {
2274
2331
  t.preventDefault(), t.stopPropagation(), this.commitHighlightedPaneMoveCandidate();
2275
2332
  return;
2276
2333
  }
2277
- const n = t.key.toLowerCase(), c = {
2334
+ const o = t.key.toLowerCase(), d = {
2278
2335
  t: "top",
2279
2336
  r: "right",
2280
2337
  b: "bottom",
2281
2338
  l: "left",
2282
2339
  f: "float"
2283
- }[n];
2284
- c && (t.preventDefault(), t.stopPropagation(), c === "float" ? this.commitPaneMoveAsFloat() : this.commitPaneMoveToZone(c));
2340
+ }[o];
2341
+ d && (t.preventDefault(), t.stopPropagation(), d === "float" ? this.commitPaneMoveAsFloat() : this.commitPaneMoveToZone(d));
2285
2342
  }
2286
2343
  /**
2287
2344
  * Enumerated keyboard drop targets, in cycle order: every docked leaf stack
@@ -2296,16 +2353,16 @@ class P extends A {
2296
2353
  * land exactly where a pointer drop on that stack would.
2297
2354
  */
2298
2355
  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,
2356
+ const t = this.paneMoveMode ? w(this.paneMoveMode.sourcePath) : null, e = [];
2357
+ return M(this.rootLayout, (i, n) => {
2358
+ const o = w({ type: "docked", segments: n });
2359
+ o !== t && e.push({
2360
+ pathStr: o,
2304
2361
  targetTitles: i.panes.map((r) => this.titles[r] ?? r).join(", ")
2305
2362
  });
2306
2363
  }), [
2307
2364
  ...e.flatMap(
2308
- ({ pathStr: i, targetTitles: o }) => P.PANE_MOVE_ZONE_ORDER.map((n) => ({ pathStr: i, zone: n, targetTitles: o }))
2365
+ ({ pathStr: i, targetTitles: n }) => L.PANE_MOVE_ZONE_ORDER.map((o) => ({ pathStr: i, zone: o, targetTitles: n }))
2309
2366
  ),
2310
2367
  { pathStr: null, zone: "float", targetTitles: "" }
2311
2368
  ];
@@ -2313,12 +2370,12 @@ class P extends A {
2313
2370
  cyclePaneMoveCandidate(t) {
2314
2371
  const e = this.buildPaneMoveCandidates();
2315
2372
  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}.`);
2373
+ const i = this.paneMoveCandidateIndex, n = i === null ? t > 0 ? 0 : e.length - 1 : (i + t + e.length) % e.length;
2374
+ this.paneMoveCandidateIndex = n;
2375
+ const o = e[n];
2376
+ this.highlightPaneMoveCandidate(o);
2377
+ const r = o.zone === "float" ? "Float" : `${o.zone[0].toUpperCase()}${o.zone.slice(1)} of ${o.targetTitles}`;
2378
+ this.liveAnnouncer.announce(`${r}, option ${n + 1} of ${e.length}.`);
2322
2379
  }
2323
2380
  highlightPaneMoveCandidate(t) {
2324
2381
  if (this.hideDropIndicator(), t.zone === "float" || !t.pathStr) return;
@@ -2341,7 +2398,7 @@ class P extends A {
2341
2398
  this.commitPaneMoveAsFloat();
2342
2399
  return;
2343
2400
  }
2344
- this.commitPaneMoveToZone(e.zone, this.parsePath(e.pathStr));
2401
+ this.commitPaneMoveToZone(e.zone, S(e.pathStr));
2345
2402
  }
2346
2403
  /** Sole exit point for move mode: drops the arming AND any highlight together. */
2347
2404
  clearPaneMoveState() {
@@ -2362,10 +2419,10 @@ class P extends A {
2362
2419
  `.dock-tab[data-tab-id="${e}"]`
2363
2420
  );
2364
2421
  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;
2422
+ const n = i.closest(".dock-stack");
2423
+ if (!n) return null;
2424
+ const o = S(n.dataset.path);
2425
+ return o ? { paneName: i.dataset.pane, sourcePath: o } : null;
2369
2426
  }
2370
2427
  /**
2371
2428
  * Synthesise a minimal dragState so handleDrop's existing pipeline can
@@ -2396,11 +2453,11 @@ class P extends A {
2396
2453
  if (!this.paneMoveMode) return;
2397
2454
  const i = this.paneMoveMode;
2398
2455
  this.synthesiseDragStateForKeyboardMove(), this.handleDrop(e ?? i.sourcePath, t);
2399
- const o = this.dragState?.dropHandled === !0;
2456
+ const n = this.dragState?.dropHandled === !0;
2400
2457
  this.dragState = null, this.clearPaneMoveState();
2401
- const n = this.titles[i.paneName] ?? i.paneName;
2458
+ const o = this.titles[i.paneName] ?? i.paneName;
2402
2459
  this.liveAnnouncer.announce(
2403
- o ? `Pane ${n} docked to ${t}.` : `Move failed. Pane ${n} was not moved.`
2460
+ n ? `Pane ${o} docked to ${t}.` : `Move failed. Pane ${o} was not moved.`
2404
2461
  );
2405
2462
  }
2406
2463
  commitPaneMoveAsFloat() {
@@ -2422,8 +2479,8 @@ class P extends A {
2422
2479
  activePane: t.paneName
2423
2480
  };
2424
2481
  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.`);
2482
+ const n = this.titles[t.paneName] ?? t.paneName;
2483
+ this.liveAnnouncer.announce(`Pane ${n} torn off into a floating window.`);
2427
2484
  }
2428
2485
  /**
2429
2486
  * Close a floating pane via the chrome's close button (or any external
@@ -2438,61 +2495,18 @@ class P extends A {
2438
2495
  const i = this.getFloatingWindowTitle(e);
2439
2496
  this.removeFloatingAt(t), this.renderLayout(), this.dispatchLayoutChanged(), this.liveAnnouncer.announce(`Closed floating pane ${i}.`);
2440
2497
  }
2441
- removePaneFromFloating(t, e, i, o = !1) {
2442
- const n = this.floatingLayouts[t];
2443
- if (!n || !n.root)
2498
+ removePaneFromFloating(t, e, i, n = !1) {
2499
+ const o = this.floatingLayouts[t];
2500
+ if (!o || !o.root)
2444
2501
  return !1;
2445
- const r = this.getNodeAtPath(n.root, e);
2502
+ const r = T(o.root, e);
2446
2503
  if (!r || r.kind !== "stack")
2447
2504
  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;
2505
+ 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) {
2506
+ const d = E(o.root);
2507
+ d ? o.activePane = d : delete o.activePane;
2451
2508
  }
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);
2509
+ return r.panes.length > 0 ? !1 : (n || this.normalizeAllLayouts(), !0);
2496
2510
  }
2497
2511
  /**
2498
2512
  * Apply `normalizeLayoutNode` to `rootLayout` and every floating window's
@@ -2502,11 +2516,11 @@ class P extends A {
2502
2516
  * pane removal) so the tree the renderer sees is always in canonical form.
2503
2517
  */
2504
2518
  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);
2519
+ this.rootLayout = H(this.rootLayout), this.floatingLayouts = this.floatingLayouts.map((t) => {
2520
+ if (t.root = H(t.root), !t.root) return null;
2521
+ const e = I(t.root);
2508
2522
  if (!t.activePane || !e.includes(t.activePane)) {
2509
- const i = this.findFirstPaneName(t.root);
2523
+ const i = E(t.root);
2510
2524
  i ? t.activePane = i : delete t.activePane;
2511
2525
  }
2512
2526
  return t;
@@ -2525,14 +2539,14 @@ class P extends A {
2525
2539
  const t = this.shadowRoot;
2526
2540
  if (!t) return;
2527
2541
  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)
2542
+ Array.from(t.querySelectorAll("slot")).map((o) => o.getAttribute("name")).filter((o) => !!o)
2543
+ ), n = [
2544
+ ...I(this.rootLayout),
2545
+ ...this.floatingLayouts.flatMap((o) => I(o.root))
2546
+ ].find((o) => !e.has(o));
2547
+ if (n)
2534
2548
  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.`
2549
+ `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
2550
  );
2537
2551
  }
2538
2552
  dispatchLayoutChanged() {
@@ -2544,15 +2558,12 @@ class P extends A {
2544
2558
  })
2545
2559
  );
2546
2560
  }
2547
- cloneLayoutNode(t) {
2548
- return t ? JSON.parse(JSON.stringify(t)) : null;
2549
- }
2550
2561
  cloneFloatingArray(t) {
2551
2562
  return JSON.parse(JSON.stringify(t));
2552
2563
  }
2553
2564
  }
2554
- const x = "mint-dock-manager";
2555
- typeof customElements < "u" && !customElements.get(x) && customElements.define(x, P);
2565
+ const q = "mint-dock-manager";
2566
+ typeof customElements < "u" && !customElements.get(q) && customElements.define(q, L);
2556
2567
  export {
2557
- P as MintDockManagerElement
2568
+ L as MintDockManagerElement
2558
2569
  };