"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const types = require("../../../../utils/types.js");
const style = require("../../../../utils/dom/style.js");
const utils = require("../utils.js");
const vue = require("vue");
const useStyles = (props, { columnsTotalWidth, rowsHeight, fixedColumnsOnLeft, fixedColumnsOnRight }) => {
  const bodyWidth = vue.computed(() => {
    const { fixed, width, vScrollbarSize } = props;
    const ret = width - vScrollbarSize;
    return fixed ? Math.max(Math.round(vue.unref(columnsTotalWidth)), ret) : ret;
  });
  const mainTableHeight = vue.computed(() => {
    const { height = 0, maxHeight = 0, footerHeight, hScrollbarSize } = props;
    if (maxHeight > 0) {
      const _fixedRowsHeight = vue.unref(fixedRowsHeight);
      const _rowsHeight = vue.unref(rowsHeight);
      const total = vue.unref(headerHeight) + _fixedRowsHeight + _rowsHeight + hScrollbarSize;
      return Math.min(total, maxHeight - footerHeight);
    }
    return height - footerHeight;
  });
  const fixedTableHeight = vue.computed(() => {
    const { maxHeight } = props;
    const tableHeight = vue.unref(mainTableHeight);
    if (types.isNumber(maxHeight) && maxHeight > 0) return tableHeight;
    const totalHeight = vue.unref(rowsHeight) + vue.unref(headerHeight) + vue.unref(fixedRowsHeight);
    return Math.min(tableHeight, totalHeight);
  });
  const mapColumn = (column) => column.width;
  const leftTableWidth = vue.computed(() => utils.sum(vue.unref(fixedColumnsOnLeft).map(mapColumn)));
  const rightTableWidth = vue.computed(() => utils.sum(vue.unref(fixedColumnsOnRight).map(mapColumn)));
  const headerHeight = vue.computed(() => utils.sum(props.headerHeight));
  const fixedRowsHeight = vue.computed(() => {
    var _a;
    return (((_a = props.fixedData) == null ? void 0 : _a.length) || 0) * props.rowHeight;
  });
  const windowHeight = vue.computed(() => {
    return vue.unref(mainTableHeight) - vue.unref(headerHeight) - vue.unref(fixedRowsHeight);
  });
  const rootStyle = vue.computed(() => {
    const { style: style2 = {}, height, width } = props;
    return utils.enforceUnit({
      ...style2,
      height,
      width
    });
  });
  return {
    bodyWidth,
    fixedTableHeight,
    mainTableHeight,
    leftTableWidth,
    rightTableWidth,
    windowHeight,
    footerHeight: vue.computed(() => utils.enforceUnit({ height: props.footerHeight })),
    emptyStyle: vue.computed(() => ({
      top: style.addUnit(vue.unref(headerHeight)),
      bottom: style.addUnit(props.footerHeight),
      width: style.addUnit(props.width)
    })),
    rootStyle,
    headerHeight
  };
};
exports.useStyles = useStyles;
