import { renderSlot } from 'vue';
import '../../../../utils/index.mjs';
import '../../../../vue-components/index.mjs';
import { SELECTION_COLUMN } from './useSelection.mjs';
import { EXPAND_COLUMN } from '../../../../vue-components/vc-table/src/constant.mjs';
import { devWarning } from '../../../../utils/log.mjs';

function fillSlots(columns, contextSlots) {
  const $slots = contextSlots.value;
  return columns.map((column) => {
    var _a;
    if (column === SELECTION_COLUMN || column === EXPAND_COLUMN)
      return column;
    const cloneColumn = {
      ...column
    };
    const {
      slots = {}
    } = cloneColumn;
    cloneColumn.__originColumn__ = column;
    devWarning(!("slots" in cloneColumn), "Table", "`column.slots` is deprecated. Please use `v-slot:headerCell` `v-slot:bodyCell` instead.");
    Object.keys(slots).forEach((key) => {
      const name = slots[key];
      if (cloneColumn[key] === void 0 && $slots[name])
        cloneColumn[key] = $slots[name];
    });
    if (contextSlots.value.headerCell && !((_a = column.slots) == null ? void 0 : _a.title)) {
      cloneColumn.title = renderSlot(contextSlots.value, "headerCell", {
        title: column.title,
        column
      }, () => [column.title]);
    }
    if ("children" in cloneColumn && Array.isArray(cloneColumn.children))
      cloneColumn.children = fillSlots(cloneColumn.children, contextSlots);
    return cloneColumn;
  });
}
function useColumns(contextSlots) {
  const filledColumns = (columns) => fillSlots(columns, contextSlots);
  return [filledColumns];
}

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