import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { isGroupColumns } from '../../utils';
import { GroupColumns } from './GroupColumns';
import { HeadCellStartAdornment } from './HeadCellStartAdornment';
import { SingleColumn } from './SingleColumn';
import { useLogic } from './useLogic';
import { getHeadCellProps } from './utils';
export const HeadColumns = (props) => {
    const { checkboxProps, handleSort, gridPositions } = useLogic(props);
    const { columns, isSelectable, sorting, isHideSelectAll, sectionOffset } = props;
    return (_jsx(_Fragment, { children: columns.map((column, index) => {
            const { label, align, columnHint, field, sortable, showCheckbox } = getHeadCellProps({
                column,
                index,
                sectionOffset,
                isSelectable,
                isHideSelectAll,
            });
            const startAdornment = showCheckbox || columnHint ? (_jsx(HeadCellStartAdornment, { showCheckbox: showCheckbox, columnHint: columnHint, checkboxProps: checkboxProps })) : undefined;
            if (isGroupColumns(column)) {
                const position = gridPositions.get(column.label);
                return (_jsx(GroupColumns, { column: column, sorting: sorting, onSort: handleSort, gridPosition: position, startAdornment: startAdornment }, column.label));
            }
            return (_jsx(SingleColumn, { sorting: sorting, field: field, label: label, isSortable: sortable, align: align, startAdornment: startAdornment, onSort: handleSort }, label));
        }) }));
};
