"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HeadColumns = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const utils_1 = require("../../utils");
const GroupColumns_1 = require("./GroupColumns");
const HeadCellStartAdornment_1 = require("./HeadCellStartAdornment");
const SingleColumn_1 = require("./SingleColumn");
const useLogic_1 = require("./useLogic");
const utils_2 = require("./utils");
const HeadColumns = (props) => {
    const { checkboxProps, handleSort, gridPositions } = (0, useLogic_1.useLogic)(props);
    const { columns, isSelectable, sorting, isHideSelectAll, sectionOffset } = props;
    return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: columns.map((column, index) => {
            const { label, align, columnHint, field, sortable, showCheckbox } = (0, utils_2.getHeadCellProps)({
                column,
                index,
                sectionOffset,
                isSelectable,
                isHideSelectAll,
            });
            const startAdornment = showCheckbox || columnHint ? ((0, jsx_runtime_1.jsx)(HeadCellStartAdornment_1.HeadCellStartAdornment, { showCheckbox: showCheckbox, columnHint: columnHint, checkboxProps: checkboxProps })) : undefined;
            if ((0, utils_1.isGroupColumns)(column)) {
                const position = gridPositions.get(column.label);
                return ((0, jsx_runtime_1.jsx)(GroupColumns_1.GroupColumns, { column: column, sorting: sorting, onSort: handleSort, gridPosition: position, startAdornment: startAdornment }, column.label));
            }
            return ((0, jsx_runtime_1.jsx)(SingleColumn_1.SingleColumn, { sorting: sorting, field: field, label: label, isSortable: sortable, align: align, startAdornment: startAdornment, onSort: handleSort }, label));
        }) }));
};
exports.HeadColumns = HeadColumns;
