"use client";
import { jsx as ae } from "react/jsx-runtime";
import { createContext as ut, useState as de, useRef as F, useEffect as pe, useSyncExternalStore as ct, useMemo as dt, useId as ft, useContext as pt, useLayoutEffect as ht, useCallback as He, useImperativeHandle as Ve } from "react";
function gt(e, t) {
  const n = getComputedStyle(e), o = parseFloat(n.fontSize);
  return t * o;
}
function vt(e, t) {
  const n = getComputedStyle(e.ownerDocument.body), o = parseFloat(n.fontSize);
  return t * o;
}
function mt(e) {
  return e / 100 * window.innerHeight;
}
function bt(e) {
  return e / 100 * window.innerWidth;
}
function yt(e) {
  switch (typeof e) {
    case "number":
      return [e, "px"];
    case "string": {
      const t = parseFloat(e);
      return e.endsWith("%") ? [t, "%"] : e.endsWith("px") ? [t, "px"] : e.endsWith("rem") ? [t, "rem"] : e.endsWith("em") ? [t, "em"] : e.endsWith("vh") ? [t, "vh"] : e.endsWith("vw") ? [t, "vw"] : [t, "%"];
    }
  }
}
function oe({
  groupSize: e,
  panelElement: t,
  styleProp: n
}) {
  let o;
  const [r, i] = yt(n);
  switch (i) {
    case "%": {
      o = r / 100 * e;
      break;
    }
    case "px": {
      o = r;
      break;
    }
    case "rem": {
      o = vt(t, r);
      break;
    }
    case "em": {
      o = gt(t, r);
      break;
    }
    case "vh": {
      o = mt(r);
      break;
    }
    case "vw": {
      o = bt(r);
      break;
    }
  }
  return o;
}
function I(e) {
  return parseFloat(e.toFixed(3));
}
function ee({
  group: e
}) {
  const { orientation: t, panels: n } = e;
  return n.reduce((o, r) => (o += t === "horizontal" ? r.element.offsetWidth : r.element.offsetHeight, o), 0);
}
function ve(e) {
  const { panels: t } = e, n = ee({ group: e });
  return n === 0 ? t.map((o) => ({
    groupResizeBehavior: o.panelConstraints.groupResizeBehavior,
    collapsedSize: 0,
    collapsible: o.panelConstraints.collapsible === !0,
    defaultSize: void 0,
    disabled: o.panelConstraints.disabled,
    minSize: 0,
    maxSize: 100,
    panelId: o.id
  })) : t.map((o) => {
    const { element: r, panelConstraints: i } = o;
    let u = 0;
    if (i.collapsedSize !== void 0) {
      const l = oe({
        groupSize: n,
        panelElement: r,
        styleProp: i.collapsedSize
      });
      u = I(l / n * 100);
    }
    let a;
    if (i.defaultSize !== void 0) {
      const l = oe({
        groupSize: n,
        panelElement: r,
        styleProp: i.defaultSize
      });
      a = I(l / n * 100);
    }
    let s = 0;
    if (i.minSize !== void 0) {
      const l = oe({
        groupSize: n,
        panelElement: r,
        styleProp: i.minSize
      });
      s = I(l / n * 100);
    }
    let c = 100;
    if (i.maxSize !== void 0) {
      const l = oe({
        groupSize: n,
        panelElement: r,
        styleProp: i.maxSize
      });
      c = I(l / n * 100);
    }
    return {
      groupResizeBehavior: i.groupResizeBehavior,
      collapsedSize: u,
      collapsible: i.collapsible === !0,
      defaultSize: a,
      disabled: i.disabled,
      minSize: s,
      maxSize: c,
      panelId: o.id
    };
  });
}
function P(e, t = "Assertion error") {
  if (!e)
    throw Error(t);
}
function me(e, t) {
  return Array.from(t).sort(
    e === "horizontal" ? zt : St
  );
}
function zt(e, t) {
  const n = e.element.offsetLeft - t.element.offsetLeft;
  return n !== 0 ? n : e.element.offsetWidth - t.element.offsetWidth;
}
function St(e, t) {
  const n = e.element.offsetTop - t.element.offsetTop;
  return n !== 0 ? n : e.element.offsetHeight - t.element.offsetHeight;
}
function Ye(e) {
  return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.ELEMENT_NODE;
}
function Xe(e, t) {
  return {
    x: e.x >= t.left && e.x <= t.right ? 0 : Math.min(
      Math.abs(e.x - t.left),
      Math.abs(e.x - t.right)
    ),
    y: e.y >= t.top && e.y <= t.bottom ? 0 : Math.min(
      Math.abs(e.y - t.top),
      Math.abs(e.y - t.bottom)
    )
  };
}
function wt({
  orientation: e,
  rects: t,
  targetRect: n
}) {
  const o = {
    x: n.x + n.width / 2,
    y: n.y + n.height / 2
  };
  let r, i = Number.MAX_VALUE;
  for (const u of t) {
    const { x: a, y: s } = Xe(o, u), c = e === "horizontal" ? a : s;
    c < i && (i = c, r = u);
  }
  return P(r, "No rect found"), r;
}
let ue;
function xt() {
  return ue === void 0 && (typeof matchMedia == "function" ? ue = !!matchMedia("(pointer:coarse)").matches : ue = !1), ue;
}
function Ue(e) {
  const { element: t, orientation: n, panels: o, separators: r } = e, i = me(
    n,
    Array.from(t.children).filter(Ye).map((m) => ({ element: m }))
  ).map(({ element: m }) => m), u = [];
  let a = !1, s = !1, c = -1, l = -1, v = 0, f, w = [];
  {
    let m = -1;
    for (const d of i)
      d.hasAttribute("data-panel") && (m++, d.hasAttribute("data-disabled") || (v++, c === -1 && (c = m), l = m));
  }
  if (v > 1) {
    let m = -1;
    for (const d of i)
      if (d.hasAttribute("data-panel")) {
        m++;
        const g = o.find(
          (p) => p.element === d
        );
        if (g) {
          if (f) {
            const p = f.element.getBoundingClientRect(), z = d.getBoundingClientRect();
            let y;
            if (s) {
              const b = n === "horizontal" ? new DOMRect(
                p.right,
                p.top,
                0,
                p.height
              ) : new DOMRect(
                p.left,
                p.bottom,
                p.width,
                0
              ), h = n === "horizontal" ? new DOMRect(z.left, z.top, 0, z.height) : new DOMRect(z.left, z.top, z.width, 0);
              switch (w.length) {
                case 0: {
                  y = [
                    b,
                    h
                  ];
                  break;
                }
                case 1: {
                  const L = w[0], k = wt({
                    orientation: n,
                    rects: [p, z],
                    targetRect: L.element.getBoundingClientRect()
                  });
                  y = [
                    L,
                    k === p ? h : b
                  ];
                  break;
                }
                default: {
                  y = w;
                  break;
                }
              }
            } else
              w.length ? y = w : y = [
                n === "horizontal" ? new DOMRect(
                  p.right,
                  z.top,
                  z.left - p.right,
                  z.height
                ) : new DOMRect(
                  z.left,
                  p.bottom,
                  z.width,
                  z.top - p.bottom
                )
              ];
            for (const b of y) {
              let h = "width" in b ? b : b.element.getBoundingClientRect();
              const L = xt() ? e.resizeTargetMinimumSize.coarse : e.resizeTargetMinimumSize.fine;
              if (h.width < L) {
                const E = L - h.width;
                h = new DOMRect(
                  h.x - E / 2,
                  h.y,
                  h.width + E,
                  h.height
                );
              }
              if (h.height < L) {
                const E = L - h.height;
                h = new DOMRect(
                  h.x,
                  h.y - E / 2,
                  h.width,
                  h.height + E
                );
              }
              const k = m <= c || m > l;
              !a && !k && u.push({
                group: e,
                groupSize: ee({ group: e }),
                panels: [f, g],
                separator: "width" in b ? void 0 : b,
                rect: h
              }), a = !1;
            }
          }
          s = !1, f = g, w = [];
        }
      } else if (d.hasAttribute("data-separator")) {
        d.ariaDisabled !== null && (a = !0);
        const g = r.find(
          (p) => p.element === d
        );
        g ? w.push(g) : (f = void 0, w = []);
      } else
        s = !0;
  }
  return u;
}
class qe {
  #e = {};
  addListener(t, n) {
    const o = this.#e[t];
    return o === void 0 ? this.#e[t] = [n] : o.includes(n) || o.push(n), () => {
      this.removeListener(t, n);
    };
  }
  emit(t, n) {
    const o = this.#e[t];
    if (o !== void 0)
      if (o.length === 1)
        o[0].call(null, n);
      else {
        let r = !1, i = null;
        const u = Array.from(o);
        for (let a = 0; a < u.length; a++) {
          const s = u[a];
          try {
            s.call(null, n);
          } catch (c) {
            i === null && (r = !0, i = c);
          }
        }
        if (r)
          throw i;
      }
  }
  removeAllListeners() {
    this.#e = {};
  }
  removeListener(t, n) {
    const o = this.#e[t];
    if (o !== void 0) {
      const r = o.indexOf(n);
      r >= 0 && o.splice(r, 1);
    }
  }
}
let A = /* @__PURE__ */ new Map();
const Je = new qe();
function Ct(e) {
  A = new Map(A), A.delete(e);
}
function ke(e, t) {
  for (const [n] of A)
    if (n.id === e)
      return n;
}
function W(e, t) {
  for (const [n, o] of A)
    if (n.id === e)
      return o;
  if (t)
    throw Error(`Could not find data for Group with id ${e}`);
}
function U() {
  return A;
}
function be(e, t) {
  return Je.addListener("groupChange", (n) => {
    n.group.id === e && t(n);
  });
}
function j(e, t) {
  const n = A.get(e);
  A = new Map(A), A.set(e, t), Je.emit("groupChange", {
    group: e,
    prev: n,
    next: t
  });
}
function Pt(e, t, n) {
  let o, r = {
    x: 1 / 0,
    y: 1 / 0
  };
  for (const i of t) {
    const u = Xe(n, i.rect);
    switch (e) {
      case "horizontal": {
        u.x <= r.x && (o = i, r = u);
        break;
      }
      case "vertical": {
        u.y <= r.y && (o = i, r = u);
        break;
      }
    }
  }
  return o ? {
    distance: r,
    hitRegion: o
  } : void 0;
}
function Lt(e) {
  return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
}
function kt(e, t) {
  if (e === t) throw new Error("Cannot compare node with itself");
  const n = {
    a: Re(e),
    b: Re(t)
  };
  let o;
  for (; n.a.at(-1) === n.b.at(-1); )
    o = n.a.pop(), n.b.pop();
  P(
    o,
    "Stacking order can only be calculated for elements with a common ancestor"
  );
  const r = {
    a: Ee(Me(n.a)),
    b: Ee(Me(n.b))
  };
  if (r.a === r.b) {
    const i = o.childNodes, u = {
      a: n.a.at(-1),
      b: n.b.at(-1)
    };
    let a = i.length;
    for (; a--; ) {
      const s = i[a];
      if (s === u.a) return 1;
      if (s === u.b) return -1;
    }
  }
  return Math.sign(r.a - r.b);
}
const Mt = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
function Et(e) {
  const t = getComputedStyle(Qe(e) ?? e).display;
  return t === "flex" || t === "inline-flex";
}
function Rt(e) {
  const t = getComputedStyle(e);
  return !!(t.position === "fixed" || t.zIndex !== "auto" && (t.position !== "static" || Et(e)) || +t.opacity < 1 || "transform" in t && t.transform !== "none" || "webkitTransform" in t && t.webkitTransform !== "none" || "mixBlendMode" in t && t.mixBlendMode !== "normal" || "filter" in t && t.filter !== "none" || "webkitFilter" in t && t.webkitFilter !== "none" || "isolation" in t && t.isolation === "isolate" || Mt.test(t.willChange) || t.webkitOverflowScrolling === "touch");
}
function Me(e) {
  let t = e.length;
  for (; t--; ) {
    const n = e[t];
    if (P(n, "Missing node"), Rt(n)) return n;
  }
  return null;
}
function Ee(e) {
  return e && Number(getComputedStyle(e).zIndex) || 0;
}
function Re(e) {
  const t = [];
  for (; e; )
    t.push(e), e = Qe(e);
  return t;
}
function Qe(e) {
  const { parentNode: t } = e;
  return Lt(t) ? t.host : t;
}
function Dt(e, t) {
  return e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y;
}
function It({
  groupElement: e,
  hitRegion: t,
  pointerEventTarget: n
}) {
  if (!Ye(n) || n.contains(e) || e.contains(n))
    return !0;
  if (kt(n, e) > 0) {
    let o = n;
    for (; o; ) {
      if (o.contains(e))
        return !0;
      if (Dt(o.getBoundingClientRect(), t))
        return !1;
      o = o.parentElement;
    }
  }
  return !0;
}
function ye(e, t) {
  const n = [];
  return t.forEach((o, r) => {
    if (r.disabled)
      return;
    const i = Ue(r), u = Pt(r.orientation, i, {
      x: e.clientX,
      y: e.clientY
    });
    u && u.distance.x <= 0 && u.distance.y <= 0 && It({
      groupElement: r.element,
      hitRegion: u.hitRegion.rect,
      pointerEventTarget: e.target
    }) && n.push(u.hitRegion);
  }), n;
}
function Tt(e, t) {
  if (e.length !== t.length)
    return !1;
  for (let n = 0; n < e.length; n++)
    if (e[n] != t[n])
      return !1;
  return !0;
}
function D(e, t, n = 0) {
  return Math.abs(I(e) - I(t)) <= n;
}
function O(e, t) {
  return D(e, t) ? 0 : e > t ? 1 : -1;
}
function Z({
  overrideDisabledPanels: e,
  panelConstraints: t,
  prevSize: n,
  size: o
}) {
  const {
    collapsedSize: r = 0,
    collapsible: i,
    disabled: u,
    maxSize: a = 100,
    minSize: s = 0
  } = t;
  if (u && !e)
    return n;
  if (O(o, s) < 0)
    if (i) {
      const c = (r + s) / 2;
      O(o, c) < 0 ? o = r : o = s;
    } else
      o = s;
  return o = Math.min(a, o), o = I(o), o;
}
function ie({
  delta: e,
  initialLayout: t,
  panelConstraints: n,
  pivotIndices: o,
  prevLayout: r,
  trigger: i
}) {
  if (D(e, 0))
    return t;
  const u = i === "imperative-api", a = Object.values(t), s = Object.values(r), c = [...a], [l, v] = o;
  P(l != null, "Invalid first pivot index"), P(v != null, "Invalid second pivot index");
  let f = 0;
  switch (i) {
    case "keyboard": {
      {
        const d = e < 0 ? v : l, g = n[d];
        P(
          g,
          `Panel constraints not found for index ${d}`
        );
        const {
          collapsedSize: p = 0,
          collapsible: z,
          minSize: y = 0
        } = g;
        if (z) {
          const b = a[d];
          if (P(
            b != null,
            `Previous layout not found for panel index ${d}`
          ), D(b, p)) {
            const h = y - b;
            O(h, Math.abs(e)) > 0 && (e = e < 0 ? 0 - h : h);
          }
        }
      }
      {
        const d = e < 0 ? l : v, g = n[d];
        P(
          g,
          `No panel constraints found for index ${d}`
        );
        const {
          collapsedSize: p = 0,
          collapsible: z,
          minSize: y = 0
        } = g;
        if (z) {
          const b = a[d];
          if (P(
            b != null,
            `Previous layout not found for panel index ${d}`
          ), D(b, y)) {
            const h = b - p;
            O(h, Math.abs(e)) > 0 && (e = e < 0 ? 0 - h : h);
          }
        }
      }
      break;
    }
    default: {
      const d = e < 0 ? v : l, g = n[d];
      P(
        g,
        `Panel constraints not found for index ${d}`
      );
      const p = a[d], { collapsible: z, collapsedSize: y, minSize: b } = g;
      if (z && O(p, b) < 0)
        if (e > 0) {
          const h = b - y, L = h / 2, k = p + e;
          O(k, b) < 0 && (e = O(e, L) <= 0 ? 0 : h);
        } else {
          const h = b - y, L = 100 - h / 2, k = p - e;
          O(k, b) < 0 && (e = O(100 + e, L) > 0 ? 0 : -h);
        }
      break;
    }
  }
  {
    const d = e < 0 ? 1 : -1;
    let g = e < 0 ? v : l, p = 0;
    for (; ; ) {
      const y = a[g];
      P(
        y != null,
        `Previous layout not found for panel index ${g}`
      );
      const b = Z({
        overrideDisabledPanels: u,
        panelConstraints: n[g],
        prevSize: y,
        size: 100
      }) - y;
      if (p += b, g += d, g < 0 || g >= n.length)
        break;
    }
    const z = Math.min(Math.abs(e), Math.abs(p));
    e = e < 0 ? 0 - z : z;
  }
  {
    let d = e < 0 ? l : v;
    for (; d >= 0 && d < n.length; ) {
      const g = Math.abs(e) - Math.abs(f), p = a[d];
      P(
        p != null,
        `Previous layout not found for panel index ${d}`
      );
      const z = p - g, y = Z({
        overrideDisabledPanels: u,
        panelConstraints: n[d],
        prevSize: p,
        size: z
      });
      if (!D(p, y) && (f += p - y, c[d] = y, f.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
        numeric: !0
      }) >= 0))
        break;
      e < 0 ? d-- : d++;
    }
  }
  if (Tt(s, c))
    return r;
  {
    const d = e < 0 ? v : l, g = a[d];
    P(
      g != null,
      `Previous layout not found for panel index ${d}`
    );
    const p = g + f, z = Z({
      overrideDisabledPanels: u,
      panelConstraints: n[d],
      prevSize: g,
      size: p
    });
    if (c[d] = z, !D(z, p)) {
      let y = p - z, b = e < 0 ? v : l;
      for (; b >= 0 && b < n.length; ) {
        const h = c[b];
        P(
          h != null,
          `Previous layout not found for panel index ${b}`
        );
        const L = h + y, k = Z({
          overrideDisabledPanels: u,
          panelConstraints: n[b],
          prevSize: h,
          size: L
        });
        if (D(h, k) || (y -= k - h, c[b] = k), D(y, 0))
          break;
        e > 0 ? b-- : b++;
      }
    }
  }
  const w = Object.values(c).reduce(
    (d, g) => g + d,
    0
  );
  if (!D(w, 100, 0.1))
    return r;
  const m = Object.keys(r);
  return c.reduce((d, g, p) => (d[m[p]] = g, d), {});
}
function V(e, t) {
  if (Object.keys(e).length !== Object.keys(t).length)
    return !1;
  for (const n in e)
    if (t[n] === void 0 || O(e[n], t[n]) !== 0)
      return !1;
  return !0;
}
function Y({
  layout: e,
  panelConstraints: t
}) {
  const n = Object.values(e), o = [...n], r = o.reduce(
    (a, s) => a + s,
    0
  );
  if (o.length !== t.length)
    throw Error(
      `Invalid ${t.length} panel layout: ${o.map((a) => `${a}%`).join(", ")}`
    );
  if (!D(r, 100) && o.length > 0)
    for (let a = 0; a < t.length; a++) {
      const s = o[a];
      P(s != null, `No layout data found for index ${a}`);
      const c = 100 / r * s;
      o[a] = c;
    }
  let i = 0;
  for (let a = 0; a < t.length; a++) {
    const s = n[a];
    P(s != null, `No layout data found for index ${a}`);
    const c = o[a];
    P(c != null, `No layout data found for index ${a}`);
    const l = Z({
      overrideDisabledPanels: !0,
      panelConstraints: t[a],
      prevSize: s,
      size: c
    });
    c != l && (i += c - l, o[a] = l);
  }
  if (!D(i, 0))
    for (let a = 0; a < t.length; a++) {
      const s = o[a];
      P(s != null, `No layout data found for index ${a}`);
      const c = s + i, l = Z({
        overrideDisabledPanels: !0,
        panelConstraints: t[a],
        prevSize: s,
        size: c
      });
      if (s !== l && (i -= l - s, o[a] = l, D(i, 0)))
        break;
    }
  const u = Object.keys(e);
  return o.reduce((a, s, c) => (a[u[c]] = s, a), {});
}
function Ze({
  groupId: e,
  panelId: t
}) {
  const n = () => {
    const a = U();
    for (const [
      s,
      {
        defaultLayoutDeferred: c,
        derivedPanelConstraints: l,
        layout: v,
        groupSize: f,
        separatorToPanels: w
      }
    ] of a)
      if (s.id === e)
        return {
          defaultLayoutDeferred: c,
          derivedPanelConstraints: l,
          group: s,
          groupSize: f,
          layout: v,
          separatorToPanels: w
        };
    throw Error(`Group ${e} not found`);
  }, o = () => {
    const a = n().derivedPanelConstraints.find(
      (s) => s.panelId === t
    );
    if (a !== void 0)
      return a;
    throw Error(`Panel constraints not found for Panel ${t}`);
  }, r = () => {
    const a = n().group.panels.find((s) => s.id === t);
    if (a !== void 0)
      return a;
    throw Error(`Layout not found for Panel ${t}`);
  }, i = () => {
    const a = n().layout[t];
    if (a !== void 0)
      return a;
    throw Error(`Layout not found for Panel ${t}`);
  }, u = (a) => {
    const s = i();
    if (a === s)
      return;
    const {
      defaultLayoutDeferred: c,
      derivedPanelConstraints: l,
      group: v,
      groupSize: f,
      layout: w,
      separatorToPanels: m
    } = n(), d = v.panels.findIndex((y) => y.id === t), g = d === v.panels.length - 1, p = ie({
      delta: g ? s - a : a - s,
      initialLayout: w,
      panelConstraints: l,
      pivotIndices: g ? [d - 1, d] : [d, d + 1],
      prevLayout: w,
      trigger: "imperative-api"
    }), z = Y({
      layout: p,
      panelConstraints: l
    });
    V(w, z) || j(v, {
      defaultLayoutDeferred: c,
      derivedPanelConstraints: l,
      groupSize: f,
      layout: z,
      separatorToPanels: m
    });
  };
  return {
    collapse: () => {
      const { collapsible: a, collapsedSize: s } = o(), { mutableValues: c } = r(), l = i();
      a && l !== s && (c.expandToSize = l, u(s));
    },
    expand: () => {
      const { collapsible: a, collapsedSize: s, minSize: c } = o(), { mutableValues: l } = r(), v = i();
      if (a && v === s) {
        let f = l.expandToSize ?? c;
        f === 0 && (f = 1), u(f);
      }
    },
    getSize: () => {
      const { group: a } = n(), s = i(), { element: c } = r(), l = a.orientation === "horizontal" ? c.offsetWidth : c.offsetHeight;
      return {
        asPercentage: s,
        inPixels: l
      };
    },
    isCollapsed: () => {
      const { collapsible: a, collapsedSize: s } = o(), c = i();
      return a && D(s, c);
    },
    resize: (a) => {
      const { group: s } = n(), { element: c } = r(), l = ee({ group: s }), v = oe({
        groupSize: l,
        panelElement: c,
        styleProp: a
      }), f = I(v / l * 100);
      u(f);
    }
  };
}
function De(e) {
  if (e.defaultPrevented)
    return;
  const t = U();
  ye(e, t).forEach((n) => {
    if (n.separator && !n.separator.disableDoubleClick) {
      const o = n.panels.find(
        (r) => r.panelConstraints.defaultSize !== void 0
      );
      if (o) {
        const r = o.panelConstraints.defaultSize, i = Ze({
          groupId: n.group.id,
          panelId: o.id
        });
        i && r !== void 0 && (i.resize(r), e.preventDefault());
      }
    }
  });
}
function fe(e) {
  const t = U();
  for (const [n] of t)
    if (n.separators.some(
      (o) => o.element === e
    ))
      return n;
  throw Error("Could not find parent Group for separator element");
}
function Ke({
  groupId: e
}) {
  const t = () => {
    const n = U();
    for (const [o, r] of n)
      if (o.id === e)
        return { group: o, ...r };
    throw Error(`Could not find Group with id "${e}"`);
  };
  return {
    getLayout() {
      const { defaultLayoutDeferred: n, layout: o } = t();
      return n ? {} : o;
    },
    setLayout(n) {
      const {
        defaultLayoutDeferred: o,
        derivedPanelConstraints: r,
        group: i,
        groupSize: u,
        layout: a,
        separatorToPanels: s
      } = t(), c = Y({
        layout: n,
        panelConstraints: r
      });
      return o ? a : (V(a, c) || j(i, {
        defaultLayoutDeferred: o,
        derivedPanelConstraints: r,
        groupSize: u,
        layout: c,
        separatorToPanels: s
      }), c);
    }
  };
}
function H(e, t) {
  const n = fe(e), o = W(n.id, !0), r = n.separators.find(
    (l) => l.element === e
  );
  P(r, "Matching separator not found");
  const i = o.separatorToPanels.get(r);
  P(i, "Matching panels not found");
  const u = i.map((l) => n.panels.indexOf(l)), a = Ke({ groupId: n.id }).getLayout(), s = ie({
    delta: t,
    initialLayout: a,
    panelConstraints: o.derivedPanelConstraints,
    pivotIndices: u,
    prevLayout: a,
    trigger: "keyboard"
  }), c = Y({
    layout: s,
    panelConstraints: o.derivedPanelConstraints
  });
  V(a, c) || j(n, {
    defaultLayoutDeferred: o.defaultLayoutDeferred,
    derivedPanelConstraints: o.derivedPanelConstraints,
    groupSize: o.groupSize,
    layout: c,
    separatorToPanels: o.separatorToPanels
  });
}
function Ie(e) {
  if (e.defaultPrevented)
    return;
  const t = e.currentTarget, n = fe(t);
  if (!n.disabled)
    switch (e.key) {
      case "ArrowDown": {
        e.preventDefault(), n.orientation === "vertical" && H(t, 5);
        break;
      }
      case "ArrowLeft": {
        e.preventDefault(), n.orientation === "horizontal" && H(t, -5);
        break;
      }
      case "ArrowRight": {
        e.preventDefault(), n.orientation === "horizontal" && H(t, 5);
        break;
      }
      case "ArrowUp": {
        e.preventDefault(), n.orientation === "vertical" && H(t, -5);
        break;
      }
      case "End": {
        e.preventDefault(), H(t, 100);
        break;
      }
      case "Enter": {
        e.preventDefault();
        const o = fe(t), r = W(o.id, !0), { derivedPanelConstraints: i, layout: u, separatorToPanels: a } = r, s = o.separators.find(
          (f) => f.element === t
        );
        P(s, "Matching separator not found");
        const c = a.get(s);
        P(c, "Matching panels not found");
        const l = c[0], v = i.find(
          (f) => f.panelId === l.id
        );
        if (P(v, "Panel metadata not found"), v.collapsible) {
          const f = u[l.id], w = v.collapsedSize === f ? o.mutableState.expandedPanelSizes[l.id] ?? v.minSize : v.collapsedSize;
          H(t, w - f);
        }
        break;
      }
      case "F6": {
        e.preventDefault();
        const o = fe(t).separators.map(
          (u) => u.element
        ), r = Array.from(o).findIndex(
          (u) => u === e.currentTarget
        );
        P(r !== null, "Index not found");
        const i = e.shiftKey ? r > 0 ? r - 1 : o.length - 1 : r + 1 < o.length ? r + 1 : 0;
        o[i].focus({
          preventScroll: !0
        });
        break;
      }
      case "Home": {
        e.preventDefault(), H(t, -100);
        break;
      }
    }
}
let K = {
  cursorFlags: 0,
  state: "inactive"
};
const ze = new qe();
function X() {
  return K;
}
function Nt(e) {
  return ze.addListener("change", e);
}
function Ot(e) {
  const t = K, n = { ...K };
  n.cursorFlags = e, K = n, ze.emit("change", {
    prev: t,
    next: n
  });
}
function _(e) {
  const t = K;
  K = e, ze.emit("change", {
    prev: t,
    next: e
  });
}
function Te(e) {
  if (e.defaultPrevented || e.pointerType === "mouse" && e.button > 0)
    return;
  const t = U(), n = ye(e, t), o = /* @__PURE__ */ new Map();
  let r = !1;
  n.forEach((i) => {
    i.separator && (r || (r = !0, i.separator.element.focus({
      preventScroll: !0
    })));
    const u = t.get(i.group);
    u && o.set(i.group, u.layout);
  }), _({
    cursorFlags: 0,
    hitRegions: n,
    initialLayoutMap: o,
    pointerDownAtPoint: { x: e.clientX, y: e.clientY },
    state: "active"
  }), n.length && e.preventDefault();
}
const Ft = (e) => e, ge = () => {
}, _e = 1, et = 2, tt = 4, nt = 8, Ne = 3, Oe = 12;
let ce;
function Fe() {
  return ce === void 0 && (ce = !1, typeof window < "u" && (window.navigator.userAgent.includes("Chrome") || window.navigator.userAgent.includes("Firefox")) && (ce = !0)), ce;
}
function At({
  cursorFlags: e,
  groups: t,
  state: n
}) {
  let o = 0, r = 0;
  switch (n) {
    case "active":
    case "hover":
      t.forEach((i) => {
        if (!i.mutableState.disableCursor)
          switch (i.orientation) {
            case "horizontal": {
              o++;
              break;
            }
            case "vertical": {
              r++;
              break;
            }
          }
      });
  }
  if (!(o === 0 && r === 0)) {
    switch (n) {
      case "active": {
        if (e && Fe()) {
          const i = (e & _e) !== 0, u = (e & et) !== 0, a = (e & tt) !== 0, s = (e & nt) !== 0;
          if (i)
            return a ? "se-resize" : s ? "ne-resize" : "e-resize";
          if (u)
            return a ? "sw-resize" : s ? "nw-resize" : "w-resize";
          if (a)
            return "s-resize";
          if (s)
            return "n-resize";
        }
        break;
      }
    }
    return Fe() ? o > 0 && r > 0 ? "move" : o > 0 ? "ew-resize" : "ns-resize" : o > 0 && r > 0 ? "grab" : o > 0 ? "col-resize" : "row-resize";
  }
}
const Ae = /* @__PURE__ */ new WeakMap();
function Se(e) {
  if (e.defaultView === null || e.defaultView === void 0)
    return;
  let { prevStyle: t, styleSheet: n } = Ae.get(e) ?? {};
  n === void 0 && (n = new e.defaultView.CSSStyleSheet(), e.adoptedStyleSheets && e.adoptedStyleSheets.push(n));
  const o = X();
  switch (o.state) {
    case "active":
    case "hover": {
      const r = At({
        cursorFlags: o.cursorFlags,
        groups: o.hitRegions.map((u) => u.group),
        state: o.state
      }), i = `*, *:hover {cursor: ${r} !important; }`;
      if (t === i)
        return;
      t = i, r ? n.cssRules.length === 0 ? n.insertRule(i) : n.replaceSync(i) : n.cssRules.length === 1 && n.deleteRule(0);
      break;
    }
    case "inactive": {
      t = void 0, n.cssRules.length === 1 && n.deleteRule(0);
      break;
    }
  }
  Ae.set(e, {
    prevStyle: t,
    styleSheet: n
  });
}
function ot({
  document: e,
  event: t,
  hitRegions: n,
  initialLayoutMap: o,
  mountedGroups: r,
  pointerDownAtPoint: i,
  prevCursorFlags: u
}) {
  let a = 0;
  n.forEach((c) => {
    const { group: l, groupSize: v } = c, { orientation: f, panels: w } = l, { disableCursor: m } = l.mutableState;
    let d = 0;
    i ? f === "horizontal" ? d = (t.clientX - i.x) / v * 100 : d = (t.clientY - i.y) / v * 100 : f === "horizontal" ? d = t.clientX < 0 ? -100 : 100 : d = t.clientY < 0 ? -100 : 100;
    const g = o.get(l), p = r.get(l);
    if (!g || !p)
      return;
    const {
      defaultLayoutDeferred: z,
      derivedPanelConstraints: y,
      groupSize: b,
      layout: h,
      separatorToPanels: L
    } = p;
    if (y && h && L) {
      const k = ie({
        delta: d,
        initialLayout: g,
        panelConstraints: y,
        pivotIndices: c.panels.map((E) => w.indexOf(E)),
        prevLayout: h,
        trigger: "mouse-or-touch"
      });
      if (V(k, h)) {
        if (d !== 0 && !m)
          switch (f) {
            case "horizontal": {
              a |= d < 0 ? _e : et;
              break;
            }
            case "vertical": {
              a |= d < 0 ? tt : nt;
              break;
            }
          }
      } else
        j(c.group, {
          defaultLayoutDeferred: z,
          derivedPanelConstraints: y,
          groupSize: b,
          layout: k,
          separatorToPanels: L
        });
    }
  });
  let s = 0;
  t.movementX === 0 ? s |= u & Ne : s |= a & Ne, t.movementY === 0 ? s |= u & Oe : s |= a & Oe, Ot(s), Se(e);
}
function $e(e) {
  const t = U(), n = X();
  n.state === "active" && ot({
    document: e.currentTarget,
    event: e,
    hitRegions: n.hitRegions,
    initialLayoutMap: n.initialLayoutMap,
    mountedGroups: t,
    prevCursorFlags: n.cursorFlags
  });
}
function Ge(e) {
  if (e.defaultPrevented)
    return;
  const t = X(), n = U();
  switch (t.state) {
    case "active": {
      if (
        // Skip this check for "pointerleave" events, else Firefox triggers a false positive (see #514)
        e.buttons === 0
      ) {
        _({
          cursorFlags: 0,
          state: "inactive"
        }), t.hitRegions.forEach((o) => {
          const r = W(o.group.id, !0);
          j(o.group, r);
        });
        return;
      }
      for (const o of t.hitRegions)
        if (o.separator) {
          const { element: r } = o.separator;
          r.hasPointerCapture?.(e.pointerId) || r.setPointerCapture?.(e.pointerId);
        }
      ot({
        document: e.currentTarget,
        event: e,
        hitRegions: t.hitRegions,
        initialLayoutMap: t.initialLayoutMap,
        mountedGroups: n,
        pointerDownAtPoint: t.pointerDownAtPoint,
        prevCursorFlags: t.cursorFlags
      });
      break;
    }
    default: {
      const o = ye(e, n);
      o.length === 0 ? t.state !== "inactive" && _({
        cursorFlags: 0,
        state: "inactive"
      }) : _({
        cursorFlags: 0,
        hitRegions: o,
        state: "hover"
      }), Se(e.currentTarget);
      break;
    }
  }
}
function je(e) {
  e.relatedTarget instanceof HTMLIFrameElement && X().state === "hover" && _({
    cursorFlags: 0,
    state: "inactive"
  });
}
function Be(e) {
  if (e.defaultPrevented || e.pointerType === "mouse" && e.button > 0)
    return;
  const t = X();
  t.state === "active" && (_({
    cursorFlags: 0,
    state: "inactive"
  }), t.hitRegions.length > 0 && (Se(e.currentTarget), t.hitRegions.forEach((n) => {
    const o = W(n.group.id, !0);
    j(n.group, o);
  }), e.preventDefault()));
}
function We(e) {
  let t = 0, n = 0;
  const o = {};
  for (const i of e)
    if (i.defaultSize !== void 0) {
      t++;
      const u = I(i.defaultSize);
      n += u, o[i.panelId] = u;
    } else
      o[i.panelId] = void 0;
  const r = e.length - t;
  if (r !== 0) {
    const i = I((100 - n) / r);
    for (const u of e)
      u.defaultSize === void 0 && (o[u.panelId] = i);
  }
  return o;
}
function $t(e, t, n) {
  if (!n[0])
    return;
  const o = e.panels.find((s) => s.element === t);
  if (!o || !o.onResize)
    return;
  const r = ee({ group: e }), i = e.orientation === "horizontal" ? o.element.offsetWidth : o.element.offsetHeight, u = o.mutableValues.prevSize, a = {
    asPercentage: I(i / r * 100),
    inPixels: i
  };
  o.mutableValues.prevSize = a, o.onResize(a, o.id, u);
}
function Gt(e, t) {
  if (Object.keys(e).length !== Object.keys(t).length)
    return !1;
  for (const n in e)
    if (e[n] !== t[n])
      return !1;
  return !0;
}
function jt({
  group: e,
  nextGroupSize: t,
  prevGroupSize: n,
  prevLayout: o
}) {
  if (n <= 0 || t <= 0 || n === t)
    return o;
  let r = 0, i = 0, u = !1;
  const a = /* @__PURE__ */ new Map(), s = [];
  for (const v of e.panels) {
    const f = o[v.id] ?? 0;
    if (v.panelConstraints.groupResizeBehavior === "preserve-pixel-size") {
      u = !0;
      const w = f / 100 * n, m = I(
        w / t * 100
      );
      a.set(v.id, m), r += m;
    } else
      s.push(v.id), i += f;
  }
  if (!u || s.length === 0)
    return o;
  const c = 100 - r, l = { ...o };
  if (a.forEach((v, f) => {
    l[f] = v;
  }), i > 0)
    for (const v of s) {
      const f = o[v] ?? 0;
      l[v] = I(
        f / i * c
      );
    }
  else {
    const v = I(
      c / s.length
    );
    for (const f of s)
      l[f] = v;
  }
  return l;
}
function Bt(e, t) {
  const n = e.map((r) => r.id), o = Object.keys(t);
  if (n.length !== o.length)
    return !1;
  for (const r of n)
    if (!o.includes(r))
      return !1;
  return !0;
}
const Q = /* @__PURE__ */ new Map();
function Wt(e) {
  let t = !0;
  P(
    e.element.ownerDocument.defaultView,
    "Cannot register an unmounted Group"
  );
  const n = e.element.ownerDocument.defaultView.ResizeObserver, o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = new n((m) => {
    for (const d of m) {
      const { borderBoxSize: g, target: p } = d;
      if (p === e.element) {
        if (t) {
          const z = ee({ group: e });
          if (z === 0)
            return;
          const y = W(e.id);
          if (!y)
            return;
          const b = ve(e), h = y.defaultLayoutDeferred ? We(b) : y.layout, L = jt({
            group: e,
            nextGroupSize: z,
            prevGroupSize: y.groupSize,
            prevLayout: h
          }), k = Y({
            layout: L,
            panelConstraints: b
          });
          if (!y.defaultLayoutDeferred && V(y.layout, k) && Gt(
            y.derivedPanelConstraints,
            b
          ) && y.groupSize === z)
            return;
          j(e, {
            defaultLayoutDeferred: !1,
            derivedPanelConstraints: b,
            groupSize: z,
            layout: k,
            separatorToPanels: y.separatorToPanels
          });
        }
      } else
        $t(e, p, g);
    }
  });
  i.observe(e.element), e.panels.forEach((m) => {
    P(
      !o.has(m.id),
      `Panel ids must be unique; id "${m.id}" was used more than once`
    ), o.add(m.id), m.onResize && i.observe(m.element);
  });
  const u = ee({ group: e }), a = ve(e), s = e.panels.map(({ id: m }) => m).join(",");
  let c = e.mutableState.defaultLayout;
  c && (Bt(e.panels, c) || (c = void 0));
  const l = e.mutableState.layouts[s] ?? c ?? We(a), v = Y({
    layout: l,
    panelConstraints: a
  }), f = e.element.ownerDocument;
  Q.set(
    f,
    (Q.get(f) ?? 0) + 1
  );
  const w = /* @__PURE__ */ new Map();
  return Ue(e).forEach((m) => {
    m.separator && w.set(m.separator, m.panels);
  }), j(e, {
    defaultLayoutDeferred: u === 0,
    derivedPanelConstraints: a,
    groupSize: u,
    layout: v,
    separatorToPanels: w
  }), e.separators.forEach((m) => {
    P(
      !r.has(m.id),
      `Separator ids must be unique; id "${m.id}" was used more than once`
    ), r.add(m.id), m.element.addEventListener("keydown", Ie);
  }), Q.get(f) === 1 && (f.addEventListener("dblclick", De, !0), f.addEventListener("pointerdown", Te, !0), f.addEventListener("pointerleave", $e), f.addEventListener("pointermove", Ge), f.addEventListener("pointerout", je), f.addEventListener("pointerup", Be, !0)), function() {
    t = !1, Q.set(
      f,
      Math.max(0, (Q.get(f) ?? 0) - 1)
    ), Ct(e), e.separators.forEach((m) => {
      m.element.removeEventListener("keydown", Ie);
    }), Q.get(f) || (f.removeEventListener(
      "dblclick",
      De,
      !0
    ), f.removeEventListener(
      "pointerdown",
      Te,
      !0
    ), f.removeEventListener("pointerleave", $e), f.removeEventListener("pointermove", Ge), f.removeEventListener("pointerout", je), f.removeEventListener("pointerup", Be, !0)), i.disconnect();
  };
}
function Ht() {
  const [e, t] = de({}), n = He(() => t({}), []);
  return [e, n];
}
function we(e) {
  const t = ft();
  return `${e ?? t}`;
}
const q = typeof window < "u" ? ht : pe;
function re(e) {
  const t = F(e);
  return q(() => {
    t.current = e;
  }, [e]), He(
    (...n) => t.current?.(...n),
    [t]
  );
}
function xe(...e) {
  return re((t) => {
    e.forEach((n) => {
      if (n)
        switch (typeof n) {
          case "function": {
            n(t);
            break;
          }
          case "object": {
            n.current = t;
            break;
          }
        }
    });
  });
}
function Ce(e) {
  const t = F({ ...e });
  return q(() => {
    for (const n in e)
      t.current[n] = e[n];
  }, [e]), t.current;
}
const rt = ut(null);
function Vt(e, t) {
  const n = F({
    getLayout: () => ({}),
    setLayout: Ft
  });
  Ve(t, () => n.current, []), q(() => {
    Object.assign(
      n.current,
      Ke({ groupId: e })
    );
  });
}
function Yt({
  children: e,
  className: t,
  defaultLayout: n,
  disableCursor: o,
  disabled: r,
  elementRef: i,
  groupRef: u,
  id: a,
  onLayoutChange: s,
  onLayoutChanged: c,
  orientation: l = "horizontal",
  resizeTargetMinimumSize: v = {
    coarse: 20,
    fine: 10
  },
  style: f,
  ...w
}) {
  const m = F({
    onLayoutChange: {},
    onLayoutChanged: {}
  }), d = re((S) => {
    V(m.current.onLayoutChange, S) || (m.current.onLayoutChange = S, s?.(S));
  }), g = re((S) => {
    V(m.current.onLayoutChanged, S) || (m.current.onLayoutChanged = S, c?.(S));
  }), p = we(a), z = F(null), [y, b] = Ht(), h = F({
    lastExpandedPanelSizes: {},
    layouts: {},
    panels: [],
    resizeTargetMinimumSize: v,
    separators: []
  }), L = xe(z, i);
  Vt(p, u);
  const k = re(
    (S, x) => {
      const M = X(), C = ke(S), R = W(S);
      if (R) {
        let T = !1;
        return M.state === "active" && (T = M.hitRegions.some(
          (te) => te.group === C
        )), {
          flexGrow: R.layout[x] ?? 1,
          pointerEvents: T ? "none" : void 0
        };
      }
      if (n?.[x])
        return {
          flexGrow: n?.[x]
        };
    }
  ), E = Ce({
    defaultLayout: n,
    disableCursor: o
  }), N = dt(
    () => ({
      get disableCursor() {
        return !!E.disableCursor;
      },
      getPanelStyles: k,
      id: p,
      orientation: l,
      registerPanel: (S) => {
        const x = h.current;
        return x.panels = me(l, [
          ...x.panels,
          S
        ]), b(), () => {
          x.panels = x.panels.filter(
            (M) => M !== S
          ), b();
        };
      },
      registerSeparator: (S) => {
        const x = h.current;
        return x.separators = me(l, [
          ...x.separators,
          S
        ]), b(), () => {
          x.separators = x.separators.filter(
            (M) => M !== S
          ), b();
        };
      },
      updatePanelProps: (S, { disabled: x }) => {
        const M = h.current.panels.find(
          (T) => T.id === S
        );
        M && (M.panelConstraints.disabled = x);
        const C = ke(p), R = W(p);
        C && R && j(C, {
          ...R,
          derivedPanelConstraints: ve(C)
        });
      },
      updateSeparatorProps: (S, {
        disabled: x,
        disableDoubleClick: M
      }) => {
        const C = h.current.separators.find(
          (R) => R.id === S
        );
        C && (C.disabled = x, C.disableDoubleClick = M);
      }
    }),
    [k, p, b, l, E]
  ), $ = F(null);
  return q(() => {
    const S = z.current;
    if (S === null)
      return;
    const x = h.current;
    let M;
    if (E.defaultLayout !== void 0 && Object.keys(E.defaultLayout).length === x.panels.length) {
      M = {};
      for (const B of x.panels) {
        const J = E.defaultLayout[B.id];
        J !== void 0 && (M[B.id] = J);
      }
    }
    const C = {
      disabled: !!r,
      element: S,
      id: p,
      mutableState: {
        defaultLayout: M,
        disableCursor: !!E.disableCursor,
        expandedPanelSizes: h.current.lastExpandedPanelSizes,
        layouts: h.current.layouts
      },
      orientation: l,
      panels: x.panels,
      resizeTargetMinimumSize: x.resizeTargetMinimumSize,
      separators: x.separators
    };
    $.current = C;
    const R = Wt(C), { defaultLayoutDeferred: T, derivedPanelConstraints: te, layout: se } = W(C.id, !0);
    !T && te.length > 0 && (d(se), g(se));
    const ne = be(p, (B) => {
      const { defaultLayoutDeferred: J, derivedPanelConstraints: Le, layout: le } = B.next;
      if (J || Le.length === 0)
        return;
      const at = C.panels.map(({ id: G }) => G).join(",");
      C.mutableState.layouts[at] = le, Le.forEach((G) => {
        if (G.collapsible) {
          const { layout: he } = B.prev ?? {};
          if (he) {
            const st = D(
              G.collapsedSize,
              le[G.panelId]
            ), lt = D(
              G.collapsedSize,
              he[G.panelId]
            );
            st && !lt && (C.mutableState.expandedPanelSizes[G.panelId] = he[G.panelId]);
          }
        }
      });
      const it = X().state !== "active";
      d(le), it && g(le);
    });
    return () => {
      $.current = null, R(), ne();
    };
  }, [
    r,
    p,
    g,
    d,
    l,
    y,
    E
  ]), pe(() => {
    const S = $.current;
    S && (S.mutableState.defaultLayout = n, S.mutableState.disableCursor = !!o);
  }), /* @__PURE__ */ ae(rt.Provider, { value: N, children: /* @__PURE__ */ ae(
    "div",
    {
      ...w,
      className: t,
      "data-group": !0,
      "data-testid": p,
      id: p,
      ref: L,
      style: {
        height: "100%",
        width: "100%",
        overflow: "hidden",
        ...f,
        display: "flex",
        flexDirection: l === "horizontal" ? "row" : "column",
        flexWrap: "nowrap",
        // Inform the browser that the library is handling touch events for this element
        // but still allow users to scroll content within panels in the non-resizing direction
        // NOTE This is not an inherited style
        // See github.com/bvaughn/react-resizable-panels/issues/662
        touchAction: l === "horizontal" ? "pan-y" : "pan-x"
      },
      children: e
    }
  ) });
}
Yt.displayName = "Group";
function Pe() {
  const e = pt(rt);
  return P(
    e,
    "Group Context not found; did you render a Panel or Separator outside of a Group?"
  ), e;
}
function Xt(e, t) {
  const { id: n } = Pe(), o = F({
    collapse: ge,
    expand: ge,
    getSize: () => ({
      asPercentage: 0,
      inPixels: 0
    }),
    isCollapsed: () => !1,
    resize: ge
  });
  Ve(t, () => o.current, []), q(() => {
    Object.assign(
      o.current,
      Ze({ groupId: n, panelId: e })
    );
  });
}
function Ut({
  children: e,
  className: t,
  collapsedSize: n = "0%",
  collapsible: o = !1,
  defaultSize: r,
  disabled: i,
  elementRef: u,
  groupResizeBehavior: a = "preserve-relative-size",
  id: s,
  maxSize: c = "100%",
  minSize: l = "0%",
  onResize: v,
  panelRef: f,
  style: w,
  ...m
}) {
  const d = !!s, g = we(s), p = Ce({
    disabled: i
  }), z = F(null), y = xe(z, u), {
    getPanelStyles: b,
    id: h,
    orientation: L,
    registerPanel: k,
    updatePanelProps: E
  } = Pe(), N = v !== null, $ = re(
    (C, R, T) => {
      v?.(C, s, T);
    }
  );
  q(() => {
    const C = z.current;
    if (C !== null) {
      const R = {
        element: C,
        id: g,
        idIsStable: d,
        mutableValues: {
          expandToSize: void 0,
          prevSize: void 0
        },
        onResize: N ? $ : void 0,
        panelConstraints: {
          groupResizeBehavior: a,
          collapsedSize: n,
          collapsible: o,
          defaultSize: r,
          disabled: p.disabled,
          maxSize: c,
          minSize: l
        }
      };
      return k(R);
    }
  }, [
    a,
    n,
    o,
    r,
    N,
    g,
    d,
    c,
    l,
    $,
    k,
    p
  ]), pe(() => {
    E(g, { disabled: i });
  }, [i, g, E]), Xt(g, f);
  const S = () => {
    const C = b(h, g);
    if (C)
      return JSON.stringify(C);
  }, x = ct(
    (C) => be(h, C),
    S,
    S
  );
  let M;
  return x ? M = JSON.parse(x) : r ? M = {
    flexGrow: void 0,
    flexShrink: void 0,
    flexBasis: r
  } : M = { flexGrow: 1 }, /* @__PURE__ */ ae(
    "div",
    {
      ...m,
      "data-disabled": i || void 0,
      "data-panel": !0,
      "data-testid": g,
      id: g,
      ref: y,
      style: {
        ...qt,
        display: "flex",
        flexBasis: 0,
        flexShrink: 1,
        overflow: "visible",
        ...M
      },
      children: /* @__PURE__ */ ae(
        "div",
        {
          className: t,
          style: {
            maxHeight: "100%",
            maxWidth: "100%",
            flexGrow: 1,
            overflow: "auto",
            ...w,
            // Inform the browser that the library is handling touch events for this element
            // but still allow users to scroll content within panels in the non-resizing direction
            // NOTE This is not an inherited style
            // See github.com/bvaughn/react-resizable-panels/issues/662
            touchAction: L === "horizontal" ? "pan-y" : "pan-x"
          },
          children: e
        }
      )
    }
  );
}
Ut.displayName = "Panel";
const qt = {
  minHeight: 0,
  maxHeight: "100%",
  height: "auto",
  minWidth: 0,
  maxWidth: "100%",
  width: "auto",
  border: "none",
  borderWidth: 0,
  padding: 0,
  margin: 0
};
function Jt({
  layout: e,
  panelConstraints: t,
  panelId: n,
  panelIndex: o
}) {
  let r, i;
  const u = e[n], a = t.find(
    (s) => s.panelId === n
  );
  if (a) {
    const s = a.maxSize, c = a.collapsible ? a.collapsedSize : a.minSize, l = [o, o + 1];
    i = Y({
      layout: ie({
        delta: c - u,
        initialLayout: e,
        panelConstraints: t,
        pivotIndices: l,
        prevLayout: e
      }),
      panelConstraints: t
    })[n], r = Y({
      layout: ie({
        delta: s - u,
        initialLayout: e,
        panelConstraints: t,
        pivotIndices: l,
        prevLayout: e
      }),
      panelConstraints: t
    })[n];
  }
  return {
    valueControls: n,
    valueMax: r,
    valueMin: i,
    valueNow: u
  };
}
function Qt({
  children: e,
  className: t,
  disabled: n,
  disableDoubleClick: o,
  elementRef: r,
  id: i,
  style: u,
  ...a
}) {
  const s = we(i), c = Ce({
    disabled: n,
    disableDoubleClick: o
  }), [l, v] = de({}), [f, w] = de("inactive"), [m, d] = de(!1), g = F(null), p = xe(g, r), {
    disableCursor: z,
    id: y,
    orientation: b,
    registerSeparator: h,
    updateSeparatorProps: L
  } = Pe(), k = b === "horizontal" ? "vertical" : "horizontal";
  q(() => {
    const $ = g.current;
    if ($ !== null) {
      const S = {
        disabled: c.disabled,
        disableDoubleClick: c.disableDoubleClick,
        element: $,
        id: s
      }, x = h(S), M = Nt(
        (R) => {
          w(
            R.next.state !== "inactive" && R.next.hitRegions.some(
              (T) => T.separator === S
            ) ? R.next.state : "inactive"
          );
        }
      ), C = be(
        y,
        (R) => {
          const { derivedPanelConstraints: T, layout: te, separatorToPanels: se } = R.next, ne = se.get(S);
          if (ne) {
            const B = ne[0], J = ne.indexOf(B);
            v(
              Jt({
                layout: te,
                panelConstraints: T,
                panelId: B.id,
                panelIndex: J
              })
            );
          }
        }
      );
      return () => {
        M(), C(), x();
      };
    }
  }, [y, s, h, c]), pe(() => {
    L(s, { disabled: n, disableDoubleClick: o });
  }, [n, o, s, L]);
  let E;
  n && !z && (E = "not-allowed");
  let N;
  return n ? N = "disabled" : f === "active" ? N = "active" : m ? N = "focus" : N = f, /* @__PURE__ */ ae(
    "div",
    {
      ...a,
      "aria-controls": l.valueControls,
      "aria-disabled": n || void 0,
      "aria-orientation": k,
      "aria-valuemax": l.valueMax,
      "aria-valuemin": l.valueMin,
      "aria-valuenow": l.valueNow,
      children: e,
      className: t,
      "data-separator": N,
      "data-testid": s,
      id: s,
      onBlur: () => d(!1),
      onFocus: () => d(!0),
      ref: p,
      role: "separator",
      style: {
        flexBasis: "auto",
        cursor: E,
        ...u,
        flexGrow: 0,
        flexShrink: 0,
        // Inform the browser that the library is handling touch events for this element
        // See github.com/bvaughn/react-resizable-panels/issues/662
        touchAction: "none"
      },
      tabIndex: n ? void 0 : 0
    }
  );
}
Qt.displayName = "Separator";
export {
  Qt as Q,
  Yt as U,
  Ut as Y
};
