'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var index = require('../Cell/index.js');
var TableContext = require('../context/TableContext.js');
var fixUtil = require('../utils/fixUtil.js');
var valueUtil = require('../utils/valueUtil.js');
var DragHandle = require('./DragHandle.js');

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
}
var HeaderRow = /* @__PURE__ */ vue.defineComponent({
  name: "HeaderRow",
  props: ["cells", "stickyOffsets", "flattenColumns", "rowComponent", "cellComponent", "index", "customHeaderRow"],
  setup(props) {
    const tableContext = TableContext.useInjectTable();
    return () => {
      let _slot;
      const {
        prefixCls,
        direction
      } = tableContext;
      const {
        cells,
        stickyOffsets,
        flattenColumns,
        rowComponent: RowComponent,
        cellComponent: CellComponent,
        customHeaderRow,
        index: index$1
      } = props;
      let rowProps;
      if (customHeaderRow) {
        rowProps = customHeaderRow(cells.map((cell) => cell.column), index$1);
      }
      const columnsKey = valueUtil.getColumnsKey(cells.map((cell) => cell.column));
      return vue.createVNode(RowComponent, rowProps, _isSlot(_slot = cells.map((cell, cellIndex) => {
        const {
          column
        } = cell;
        const fixedInfo = fixUtil.getCellFixedInfo(cell.colStart, cell.colEnd, flattenColumns, stickyOffsets, direction);
        let additionalProps;
        if (column && column.customHeaderCell)
          additionalProps = cell.column.customHeaderCell(column);
        const col = column;
        return vue.createVNode(index.default, vue.mergeProps(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 ? vue.createVNode(DragHandle.default, {
            "prefixCls": prefixCls,
            "width": col.width,
            "minWidth": col.minWidth,
            "maxWidth": col.maxWidth,
            "column": col
          }, null) : null
        });
      })) ? _slot : {
        default: () => [_slot]
      });
    };
  }
});

exports.default = HeaderRow;
//# sourceMappingURL=HeaderRow.js.map
