import { defineComponent, createVNode } from 'vue';
import Cell from '../Cell/index.mjs';
import { useInjectTable } from '../context/TableContext.mjs';
import { getCellFixedInfo } from '../utils/fixUtil.mjs';
import { getColumnsKey } from '../utils/valueUtil.mjs';
import DragHandleVue from './DragHandle.mjs';

var HeaderRow = /* @__PURE__ */ defineComponent({
  name: "HeaderRow",
  props: ["cells", "stickyOffsets", "flattenColumns", "rowComponent", "cellComponent", "index", "customHeaderRow"],
  setup(props) {
    const tableContext = useInjectTable();
    return () => {
      const {
        prefixCls,
        direction
      } = tableContext;
      const {
        cells,
        stickyOffsets,
        flattenColumns,
        rowComponent: RowComponent,
        cellComponent: CellComponent,
        customHeaderRow,
        index
      } = props;
      let rowProps;
      if (customHeaderRow) {
        rowProps = customHeaderRow(cells.map((cell) => cell.column), index);
      }
      const columnsKey = getColumnsKey(cells.map((cell) => cell.column));
      return createVNode(RowComponent, rowProps, {
        default: () => [cells.map((cell, cellIndex) => {
          const {
            column
          } = cell;
          const fixedInfo = getCellFixedInfo(cell.colStart, cell.colEnd, flattenColumns, stickyOffsets, direction);
          let additionalProps;
          if (column && column.customHeaderCell)
            additionalProps = cell.column.customHeaderCell(column);
          const col = column;
          return createVNode(Cell, {
            ...cell,
            "cellType": "header",
            "ellipsis": column.ellipsis,
            "align": column.align,
            "component": CellComponent,
            "prefixCls": prefixCls,
            "key": columnsKey[cellIndex],
            ...fixedInfo,
            "additionalProps": additionalProps,
            "rowType": "header",
            "column": column
          }, {
            default: () => column.title,
            dragHandle: () => col.resizable ? createVNode(DragHandleVue, {
              "prefixCls": prefixCls,
              "width": col.width,
              "minWidth": col.minWidth,
              "maxWidth": col.maxWidth,
              "column": col
            }, null) : null
          });
        })]
      });
    };
  }
});

export { HeaderRow as default };
//# sourceMappingURL=HeaderRow.mjs.map
