import { cn } from "./cva.js";
import "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/Table.tsx
const tableClass = "w-full border-collapse text-fg text-sm";
const headClass = "border-b border-border bg-surface-raised";
const rowClass = "border-b border-border";
const cellClass = "px-3 py-2 text-left align-middle";
const thClass = cn(cellClass, "font-semibold text-fg");
const sortButtonClass = "inline-flex w-full items-center gap-1 bg-transparent text-inherit font-semibold focus-visible:outline focus-visible:outline-accent rounded-sm";
function TableRoot({ caption, children, className }) {
	return /* @__PURE__ */ jsxs("table", {
		className: cn(tableClass, className),
		children: [caption ? /* @__PURE__ */ jsx("caption", {
			className: "px-3 py-2 text-left text-sm font-semibold text-fg",
			children: caption
		}) : null, children]
	});
}
function TableHead({ children, className, ...props }) {
	return /* @__PURE__ */ jsx("thead", {
		className: cn(headClass, className),
		...props,
		children
	});
}
function TableBody({ children, className, ...props }) {
	return /* @__PURE__ */ jsx("tbody", {
		className,
		...props,
		children
	});
}
function TableRow({ children, className, ...props }) {
	return /* @__PURE__ */ jsx("tr", {
		className: cn(rowClass, className),
		...props,
		children
	});
}
function TableTh({ scope = "col", sort, onSort, children, className, ...props }) {
	return /* @__PURE__ */ jsx("th", {
		scope,
		"aria-sort": sort === "asc" ? "ascending" : sort === "desc" ? "descending" : sort === "none" ? "none" : void 0,
		className: cn(thClass, className),
		...props,
		children: sort !== void 0 && onSort ? /* @__PURE__ */ jsx("button", {
			type: "button",
			className: sortButtonClass,
			onClick: onSort,
			children
		}) : children
	});
}
function TableTd({ children, className, ...props }) {
	return /* @__PURE__ */ jsx("td", {
		className: cn(cellClass, className),
		...props,
		children
	});
}
const Table = Object.assign(TableRoot, {
	Head: TableHead,
	Body: TableBody,
	Row: TableRow,
	Th: TableTh,
	Td: TableTd
});
//#endregion
export { Table };
