import React__default, { forwardRef } from 'react';
import classnames from 'classnames';
import { _ as __rest } from './tslib.es6-es.js';
import { B as Button } from './Button-es.js';

var styles$1 = {"sortIcon":"NrRExUGE6GY-","inactive":"e3aVa36Y7W8-","active":"lDKd982Sr-w-","spinning":"D9cW6RdlpZ0-"};

var SortDirection;
(function (SortDirection) {
    SortDirection[SortDirection["ascending"] = 0] = "ascending";
    SortDirection[SortDirection["descending"] = 1] = "descending";
    SortDirection[SortDirection["equilibrium"] = 2] = "equilibrium";
})(SortDirection || (SortDirection = {}));
const sortStyleIndex = [
    {
        option: SortDirection.equilibrium,
        upArrowStyle: undefined,
        downArrowStyle: undefined,
    },
    {
        option: SortDirection.ascending,
        upArrowStyle: classnames(styles$1.active),
        downArrowStyle: classnames(styles$1.inactive),
    },
    {
        option: SortDirection.descending,
        upArrowStyle: classnames(styles$1.inactive),
        downArrowStyle: classnames(styles$1.active),
    },
];
function SortIcon({ direction }) {
    const foundStyle = sortStyleIndex.find(style => style.option === direction);
    const finalStyle = foundStyle === undefined ? sortStyleIndex[0] : foundStyle;
    return (React__default.createElement("div", { className: classnames(styles$1.sortIcon) },
        React__default.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
            React__default.createElement("path", { className: finalStyle.upArrowStyle, d: "M16.2929 10.6661C15.9024 11.0566 15.2692 11.0566 14.8787 10.6661L12.2891 8.14263L9.70711 10.6661C9.31658 11.0566 8.68342 11.0566 8.29289 10.6661C7.90237 10.2756 7.90237 9.64239 8.29289 9.25186L11.5858 5.95897C11.9763 5.56845 12.6095 5.56845 13 5.95897L16.2929 9.25186C16.6834 9.64239 16.6834 10.2756 16.2929 10.6661Z" }),
            React__default.createElement("path", { className: finalStyle.downArrowStyle, d: "M8.29292 13.3339C8.68345 12.9434 9.31661 12.9434 9.70714 13.3339L12.2968 15.8573L14.8787 13.3339C15.2692 12.9434 15.9024 12.9434 16.2929 13.3339C16.6834 13.7244 16.6834 14.3576 16.2929 14.7481L13 18.041C12.6095 18.4315 11.9763 18.4315 11.5858 18.041L8.29292 14.7481C7.9024 14.3576 7.9024 13.7244 8.29292 13.3339Z" }))));
}

var styles = {"container":"_1-DPmbxOkZ8-","tableElement":"kJeYcsgg700-","header":"_5d2OcsTVgzU-","headerCell":"LTx0tCU3F2I-","sortableButton":"WTQCrd2d8nw-","focusArea":"RipbH3rRU-E-","row":"sJQbtw-NEHU-","clickableRow":"J2p1EeT252A-","cell":"_1UpLYTK64uY-","footer":"qe-6UrAFLTo-","actions":"_2fZsLSaNPnI-","rowActions":"pElxuwpGmCI-","pagination":"thJ-CSoe0ps-","spinning":"EBpmC7cZzCs-"};

function DataTableActions(props) {
    return (React__default.createElement("div", Object.assign({}, props, { className: classnames(styles.actions, props.className) }), props.children));
}

function DataTableBody(props) {
    return (React__default.createElement("tbody", Object.assign({}, props, { className: classnames(props.className) }), props.children));
}

const DataTableCell = forwardRef((props, ref) => {
    return (React__default.createElement("td", Object.assign({}, props, { className: classnames(styles.cell, props.className), ref: ref }), props.children));
});
DataTableCell.displayName = "DataTableCell";

function DataTableContainer(props) {
    return (React__default.createElement("div", Object.assign({}, props, { className: classnames(styles.container, props.className) }), props.children));
}

function DataTableFooter(_a) {
    var { children, className } = _a, props = __rest(_a, ["children", "className"]);
    return (React__default.createElement("tfoot", Object.assign({}, props, { className: classnames(styles.footer, className) }), children));
}

function DataTableHeader(props) {
    return (React__default.createElement("thead", Object.assign({}, props, { className: classnames(styles.header, props.className) }),
        React__default.createElement("tr", null, props.children)));
}

function DataTableHeaderCell(props) {
    return (React__default.createElement("th", Object.assign({}, props, { className: classnames(styles.headerCell, props.className) }), props.children));
}
DataTableHeaderCell.displayName = "DataTableHeaderCell";

function DataTablePagination(_a) {
    var { children, className } = _a, props = __rest(_a, ["children", "className"]);
    return (React__default.createElement("div", Object.assign({}, props, { className: classnames(styles.pagination, className) }), children));
}

function DataTablePaginationButton({ direction, onClick, disabled = false, ariaLabel, }) {
    const isNext = direction === "next";
    return (React__default.createElement(Button, { label: "", onClick: onClick, icon: isNext ? "arrowRight" : "arrowLeft", type: "secondary", variation: "learning", disabled: disabled, ariaLabel: ariaLabel(direction) }));
}

const DataTableRow = forwardRef((_a, ref) => {
    var { className } = _a, props = __rest(_a, ["className"]);
    return (React__default.createElement("tr", Object.assign({}, props, { className: classnames(styles.row, props.onClick && styles.clickableRow, className), ref: ref }), props.children));
});
DataTableRow.displayName = "DataTableRow";

function DataTableRowActions(props) {
    return (React__default.createElement("div", { className: classnames(styles.rowActions, props.className) }, props.children));
}

function DataTableSortableHeader(props) {
    const { children, direction, onSort } = props, rest = __rest(props, ["children", "direction", "onSort"]);
    const isSortable = direction !== undefined && onSort !== undefined;
    if (!isSortable) {
        return React__default.createElement(DataTableHeaderCell, Object.assign({}, rest), children);
    }
    return (React__default.createElement(DataTableHeaderCell, Object.assign({}, rest),
        React__default.createElement("button", { type: "button", onClick: onSort, className: styles.sortableButton },
            React__default.createElement("span", { className: styles.focusArea },
                children,
                React__default.createElement(SortIcon, { direction: direction })))));
}

function DataTableTable(props) {
    const { layout = "auto", className, style } = props, rest = __rest(props, ["layout", "className", "style"]);
    return (React__default.createElement("table", Object.assign({}, rest, { className: classnames(styles.tableElement, className), style: Object.assign(Object.assign({}, style), { tableLayout: layout }) }), props.children));
}

export { DataTableActions as D, SortIcon as S, SortDirection as a, DataTableBody as b, DataTableCell as c, DataTableContainer as d, DataTableFooter as e, DataTableHeader as f, DataTableHeaderCell as g, DataTablePagination as h, DataTablePaginationButton as i, DataTableRow as j, DataTableRowActions as k, DataTableSortableHeader as l, DataTableTable as m };
