/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var isString = require('lodash/isString');
var isFunction = require('lodash/isFunction');
var get = require('lodash/get');
var hooks_tnode = require('../hooks/tnode.js');
var table_utils = require('./utils.js');
var table_hooks_useFixed = require('./hooks/useFixed.js');
var table_hooks_useRowspanAndColspan = require('./hooks/useRowspanAndColspan.js');
var table_hooks_useClassName = require('./hooks/useClassName.js');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('@babel/runtime/helpers/typeof');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/isUndefined');
require('lodash/debounce');
require('../_common/js/log/log.js');
require('../_common/js/utils/getScrollbarWidth.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isNumber');
require('lodash/isArray');
require('../utils/dom.js');
require('../_chunks/dep-f4db2590.js');
require('../utils/easing.js');
require('../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('dayjs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var TFoot = vue.defineComponent({
  name: "TFoot",
  props: {
    rowKey: String,
    isFixedHeader: Boolean,
    rowAndColFixedPosition: Map,
    footData: Array,
    columns: Array,
    rowAttributes: [Array, Object, Function],
    rowClassName: [Array, String, Object, Function],
    thWidthList: [Object],
    footerSummary: [String, Function],
    rowspanAndColspanInFooter: Function
  },
  setup: function setup(props, context) {
    var renderTNode = hooks_tnode.useTNodeJSX();
    var classnames = table_hooks_useClassName["default"]();
    var _toRefs = vue.toRefs(props),
      footData = _toRefs.footData,
      columns = _toRefs.columns,
      rowKey = _toRefs.rowKey,
      rowspanAndColspanInFooter = _toRefs.rowspanAndColspanInFooter;
    var _useRowspanAndColspan = table_hooks_useRowspanAndColspan["default"](footData, columns, rowKey, rowspanAndColspanInFooter),
      skipSpansMap = _useRowspanAndColspan.skipSpansMap;
    var renderTFootCell = function renderTFootCell(p) {
      var col = p.col,
        row = p.row;
      if (isFunction__default["default"](col.foot)) return col.foot(vue.h, p);
      if (isString__default["default"](col.foot) && context.slots[col.foot]) return context.slots[col.foot](p) || col.foot;
      return col.foot || get__default["default"](row, col.colKey);
    };
    return _objectSpread(_objectSpread({
      skipSpansMap: skipSpansMap
    }, classnames), {}, {
      renderTFootCell: renderTFootCell,
      renderTNode: renderTNode
    });
  },
  render: function render() {
    var _this$footData,
      _this = this;
    if (!this.columns) return null;
    var theadClasses = [this.tableFooterClasses.footer, _defineProperty__default["default"]({}, this.tableFooterClasses.fixed, this.isFixedHeader)];
    var footerDomList = (_this$footData = this.footData) === null || _this$footData === void 0 ? void 0 : _this$footData.map(function (row, rowIndex) {
      var trAttributes = table_utils.formatRowAttributes(_this.rowAttributes, {
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      });
      var customClasses = table_utils.formatRowClassNames(_this.rowClassName, {
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      }, _this.rowKey || "id");
      return vue.createVNode("tr", vue.mergeProps(trAttributes, {
        "key": rowIndex,
        "class": customClasses
      }), [_this.columns.map(function (col, colIndex) {
        var _this$thWidthList;
        var cellSpans = {};
        var spanState = null;
        if (_this.skipSpansMap.size) {
          var _spanState, _spanState2;
          var cellKey = table_hooks_useRowspanAndColspan.getCellKey(row, _this.rowKey, col.colKey, colIndex);
          spanState = _this.skipSpansMap.get(cellKey) || {};
          ((_spanState = spanState) === null || _spanState === void 0 ? void 0 : _spanState.rowspan) > 1 && (cellSpans.rowspan = spanState.rowspan);
          ((_spanState2 = spanState) === null || _spanState2 === void 0 ? void 0 : _spanState2.colspan) > 1 && (cellSpans.colspan = spanState.colspan);
          if (spanState.skipped) return null;
        }
        var tdStyles = table_hooks_useFixed.getColumnFixedStyles(col, colIndex, _this.rowAndColFixedPosition, _this.tableColFixedClasses);
        var style = _objectSpread({}, tdStyles.style);
        if ((_this$thWidthList = _this.thWidthList) !== null && _this$thWidthList !== void 0 && _this$thWidthList[col.colKey]) style.width = "".concat(_this.thWidthList[col.colKey], "px");
        return vue.createVNode("td", vue.mergeProps(_objectSpread({
          key: col.colKey
        }, cellSpans), {
          "class": tdStyles.classes,
          "style": style
        }), [_this.renderTFootCell({
          row: row,
          rowIndex: rowIndex,
          col: col,
          colIndex: colIndex
        })]);
      })]);
    });
    var footerSummary = this.renderTNode("footerSummary");
    if (!footerSummary && (!this.footData || !this.footData.length)) return null;
    return vue.createVNode("tfoot", {
      "ref": "tFooterRef",
      "class": theadClasses
    }, [footerSummary && vue.createVNode("tr", {
      "class": this.tableFullRowClasses.base
    }, [vue.createVNode("td", {
      "colspan": this.columns.length
    }, [vue.createVNode("div", {
      "class": this.tableFullRowClasses.innerFullElement
    }, [footerSummary])])]), footerDomList]);
  }
});

exports["default"] = TFoot;
//# sourceMappingURL=tfoot.js.map
