"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;
