import { a as IconSize } from "./constants2.js";
import { t as Icon_default } from "./Icon.js";
import { t as ArrowDown_default } from "./ArrowDown.js";
import { t as ArrowUp_default } from "./ArrowUp.js";
import { i as SortDirection, n as ModeType } from "./constants3.js";
import classNames from "classnames";
import { jsx, jsxs } from "react/jsx-runtime";
import styles from "./components/Table/styles.module.scss";
const TableHeadCell = ({ sortable, onClick, className, children, sortDir, mode = ModeType.normal, scope = "col", ...rest }) => {
	const tableHeadCellDefaultClass = classNames(styles["table__head-cell"], className, { [styles["table__head-cell--compact"]]: mode === ModeType.compact });
	if (!sortable && !children) return /* @__PURE__ */ jsx("td", { className: tableHeadCellDefaultClass });
	if (!sortable) return /* @__PURE__ */ jsx("th", {
		scope,
		className: tableHeadCellDefaultClass,
		...rest,
		children
	});
	const sortableClasses = classNames(tableHeadCellDefaultClass, styles["table__head-cell--sortable"], className);
	const renderSortIcon = () => sortDir && /* @__PURE__ */ jsx("div", {
		className: styles["table__head-cell-sort-icon-wrapper"],
		children: /* @__PURE__ */ jsx(Icon_default, {
			svgIcon: sortDir == SortDirection.asc ? ArrowDown_default : ArrowUp_default,
			size: IconSize.XXSmall
		})
	});
	const getSortDirection = () => {
		switch (sortDir) {
			case SortDirection.asc: return "ascending";
			case SortDirection.desc: return "descending";
		}
	};
	return /* @__PURE__ */ jsx("th", {
		scope,
		className: sortableClasses,
		"aria-sort": getSortDirection(),
		...rest,
		children: /* @__PURE__ */ jsxs("button", {
			type: "button",
			onClick,
			className: styles["table__sort-button"],
			"aria-pressed": sortDir ? !!sortDir : void 0,
			children: [renderSortIcon(), children]
		})
	});
};
var TableHeadCell_default$1 = TableHeadCell;
export { TableHeadCell as n, TableHeadCell_default$1 as t };

//# sourceMappingURL=TableHeadCell.js.map