"use client";
import { jsx as s } from "react/jsx-runtime";
import { forwardRef as r } from "react";
import { r as f } from "./resolve-variant-gw6eh7fa4st8ej7m.js";
import { C as k } from "./checkbox-k355pnfisqt0h4eg.js";
import { c as l } from "./vendor-styling-ofvnbcuht98q88oo.js";
const h = {
  layout: {
    auto: {
      classes: "",
      description: "Auto table layout - columns resize based on content"
    },
    fixed: {
      classes: "table-fixed",
      description: "Fixed table layout - columns have equal width, controlled via colgroup"
    }
  },
  variant: {
    default: {
      classes: "",
      description: "Default row variant"
    },
    selected: {
      classes: "bg-kumo-tint",
      description: "Selected row variant"
    }
  },
  sticky: {
    left: {
      classes: "sticky left-0",
      description: "Pin column to the left edge of the scroll container"
    },
    right: {
      classes: "sticky right-0",
      description: "Pin column to the right edge of the scroll container"
    }
  }
}, N = (e, a) => {
  const t = f(h.sticky, e, "left").classes, o = a === "head" ? "z-2" : "z-1", n = e === "right" ? "before:-left-6" : "before:-right-6", c = "before:pointer-events-none before:absolute before:inset-y-0 before:w-6";
  return a === "cell" ? l(t, o, "bg-kumo-base", c, n, e === "right" ? "before:bg-gradient-to-r before:from-transparent before:to-kumo-base" : "before:bg-gradient-to-l before:from-transparent before:to-kumo-base") : l(t, o, "bg-kumo-base group-data-[compact]/header:bg-kumo-elevated", c, n, e === "right" ? "before:bg-gradient-to-r before:from-transparent before:to-kumo-base group-data-[compact]/header:before:to-kumo-elevated" : "before:bg-gradient-to-l before:from-transparent before:to-kumo-base group-data-[compact]/header:before:to-kumo-elevated");
}, u = {
  layout: "auto",
  variant: "default"
}, y = r(({ layout: e = "auto", ...a }, t) => {
  const o = l(
    "isolate w-full",
    // isolate creates a stacking context so z-0/z-1/z-2 never leak out
    f(h.layout, e, u.layout).classes,
    "[&_td]:border-b [&_td]:border-kumo-fill [&_tr:last-child_td]:border-b-0",
    // Row border
    "[&_td]:p-3",
    // Cell padding
    "[&_th]:border-b [&_th]:border-kumo-fill [&_th]:p-3 [&_th]:font-semibold [&_th]:text-base",
    // Header styles
    "[&_th]:bg-kumo-base",
    // Header background color
    "text-base text-left text-kumo-default",
    a.className
  );
  return /* @__PURE__ */ s("table", { ref: t, ...a, className: o });
}), T = r(({ variant: e = "default", sticky: a, ...t }, o) => {
  const n = e === "compact", c = l(
    "group/header",
    n && "[&_th]:bg-kumo-elevated [&_th]:py-2 text-xs text-kumo-strong",
    a && "[&_th]:sticky [&_th]:top-0 [&_th]:z-1",
    t.className
  );
  return /* @__PURE__ */ s(
    "thead",
    {
      ref: o,
      ...t,
      className: c,
      ...n && { "data-compact": "" }
    }
  );
}), g = r(({ sticky: e, ...a }, t) => {
  const o = l(
    "group relative",
    e && N(e, "head"),
    a.className
  );
  return /* @__PURE__ */ s("th", { ref: t, ...a, className: o });
}), v = r(({ variant: e = u.variant, ...a }, t) => {
  const o = l(
    f(h.variant, e, u.variant).classes,
    a.className
  );
  return /* @__PURE__ */ s("tr", { ref: t, ...a, className: o });
}), _ = r((e, a) => /* @__PURE__ */ s("tbody", { ref: a, ...e })), p = r(({ sticky: e, ...a }, t) => {
  const o = l(
    e && N(e, "cell"),
    a.className
  );
  return /* @__PURE__ */ s("td", { ref: t, ...a, className: o });
}), C = r((e, a) => /* @__PURE__ */ s("tfoot", { ref: a, ...e })), x = r((e, a) => /* @__PURE__ */ s(
  "button",
  {
    ref: a,
    ...e,
    type: "button",
    "aria-label": "Resize column",
    className: l(
      "invisible h-full group-hover:visible",
      // Make the handle invisible by default
      "w-[10px]",
      // Hitting area
      "flex items-center justify-center",
      // Center the handle
      "cursor-col-resize touch-none select-none",
      // Prevent selection and touch events
      "absolute top-0 right-0",
      // Position the handle
      "m-0 bg-kumo-base p-0",
      // Override the stratus button styles
      "focus-visible:ring-2 focus-visible:ring-kumo-brand"
      // Consistent keyboard focus styling
    ),
    children: /* @__PURE__ */ s("span", { className: "h-5 w-[2px] rounded bg-kumo-hairline" })
  }
)), w = r(
  ({
    checked: e,
    indeterminate: a,
    onCheckedChange: t,
    onValueChange: o,
    label: n,
    disabled: c,
    ...i
  }, d) => /* @__PURE__ */ s(
    p,
    {
      ref: d,
      ...i,
      className: l("w-10 leading-none", i.className),
      children: /* @__PURE__ */ s(
        k,
        {
          checked: e,
          indeterminate: a,
          onCheckedChange: (b, m) => {
            t?.(b, m), o?.(b);
          },
          "aria-label": n ?? "Select row",
          disabled: c,
          className: "relative before:absolute before:-inset-3 before:content-['']"
        }
      )
    }
  )
), H = r(
  ({
    checked: e,
    indeterminate: a,
    onCheckedChange: t,
    onValueChange: o,
    label: n,
    disabled: c,
    ...i
  }, d) => /* @__PURE__ */ s(
    g,
    {
      ref: d,
      ...i,
      className: l("w-10 leading-none", i.className),
      children: /* @__PURE__ */ s(
        k,
        {
          checked: e,
          indeterminate: a,
          onCheckedChange: (b, m) => {
            t?.(b, m), o?.(b);
          },
          "aria-label": n ?? "Select all rows",
          disabled: c,
          className: "relative before:absolute before:-inset-3 before:content-['']"
        }
      )
    }
  )
);
y.displayName = "Table";
_.displayName = "Table.Body";
g.displayName = "Table.Head";
v.displayName = "Table.Row";
p.displayName = "Table.Cell";
C.displayName = "Table.Footer";
T.displayName = "Table.Header";
x.displayName = "Table.ResizeHandle";
w.displayName = "Table.CheckCell";
H.displayName = "Table.CheckHead";
const S = Object.assign(y, {
  Header: T,
  Head: g,
  Row: v,
  Body: _,
  Cell: p,
  CheckCell: w,
  CheckHead: H,
  Footer: C,
  ResizeHandle: x
});
export {
  u as K,
  S as T,
  h as a
};
//# sourceMappingURL=table-ojjjeqszmt9jgnug.js.map
