/**
 * tdesign v0.39.1-alpha.1
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

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

var helper = require('../_chunks/dep-33ee4bce.js');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var table_baseTableProps = require('./base-table-props.js');
var table_primaryTableProps = require('./primary-table-props.js');
var table_enhancedTableProps = require('./enhanced-table-props.js');
var table_primaryTable = require('./primary-table.js');
var table_hooks_useTreeData = require('./hooks/useTreeData.js');
var table_hooks_useTreeSelect = require('./hooks/useTreeSelect.js');
var table_baseTable = require('./base-table.js');
require('../hooks/tnode.js');
require('lodash/isEmpty');
require('lodash/isFunction');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../hooks/render-tnode.js');
require('lodash/isString');
require('lodash/isObject');
require('../_common/js/log/log.js');
require('./hooks/useColumnController.js');
require('@babel/runtime/helpers/toConsumableArray');
require('tdesign-icons-vue');
require('lodash/intersection');
require('../checkbox/index.js');
require('../checkbox/group.js');
require('@babel/runtime/helpers/typeof');
require('vue');
require('../config.js');
require('../checkbox/checkbox.js');
require('../utils/render-tnode.js');
require('../utils/classnames.js');
require('../checkbox/props.js');
require('../utils/helper.js');
require('@babel/runtime/helpers/slicedToArray');
require('../utils/event.js');
require('../checkbox/checkbox-group-props.js');
require('../utils/map-props.js');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../dialog/plugin.js');
require('../dialog/dialog.js');
require('lodash/throttle');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/loading.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('../utils/dom.js');
require('raf');
require('../utils/easing.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/plugin.js');
require('../button/props.js');
require('../utils/ripple.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../utils/mixins.js');
require('../dialog/actions.js');
require('../dialog/props.js');
require('../hooks/useDestroyOnClose.js');
require('./hooks/useTableHeader.js');
require('./hooks/useMultiHeader.js');
require('./hooks/useClassName.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('./hooks/useRowExpand.js');
require('lodash/get');
require('../hooks/useDefaultValue.js');
require('./hooks/useRowSelect.js');
require('./utils.js');
require('../radio/index.js');
require('../radio/radio.js');
require('../radio/props.js');
require('../radio/group.js');
require('lodash/isNumber');
require('../radio/radio-group-props.js');
require('../radio/radio-button.js');
require('./hooks/useSorter.js');
require('./sorter-button.js');
require('../tooltip/index.js');
require('../tooltip/tooltip.js');
require('../tooltip/props.js');
require('../popup/props.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../popup/container.js');
require('./hooks/useFilter.js');
require('./filter-controller.js');
require('../popup/index.js');
require('../input/index.js');
require('../input/addon.js');
require('../input/input.js');
require('../input/props.js');
require('../input/input-group.js');
require('./hooks/useAsyncLoading.js');
require('lodash/pick');
require('./hooks/useFixed.js');
require('../_common/js/utils/getScrollbarWidth.js');
require('./hooks/usePagination.js');
require('../pagination/index.js');
require('../pagination/pagination.js');
require('../input-number/index.js');
require('../input-number/input-number.js');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/regenerator');
require('../input-number/props.js');
require('../select/index.js');
require('../select/select.js');
require('lodash/debounce');
require('lodash/set');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../tag/check-tag-props.js');
require('../common-components/fake-arrow.js');
require('../select/option.js');
require('../select/option-props.js');
require('../select/props.js');
require('../select/optionGroup.js');
require('../select/option-group-props.js');
require('../pagination/props.js');
require('../hooks/useVirtualScroll.js');
require('./tbody.js');
require('./tr.js');
require('lodash/upperFirst');
require('./ellipsis.js');
require('./hooks/useStyle.js');
require('../hooks/useCommonClassName.js');
require('../affix/index.js');
require('../affix/affix.js');
require('../affix/props.js');
require('./thead.js');
require('./tfoot.js');
require('./hooks/tree-store.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');

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

var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

var _excluded = ["store", "dataSource", "formatTreeColum"];

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 PRIMARY_B_EVENTS = ["change", "page-change", "expand-change", "filter-change", "sort-change", "data-change", "drag-sort", "async-loading-click"];
var PRIMARY_ALL_EVENTS = table_baseTable.BASE_TABLE_ALL_EVENTS.concat(PRIMARY_B_EVENTS);
var _EnhancedTable = VueCompositionAPI.defineComponent({
  name: "TEnhancedTable",
  props: _objectSpread(_objectSpread(_objectSpread({}, table_baseTableProps["default"]), table_primaryTableProps["default"]), table_enhancedTableProps["default"]),
  setup: function setup(props, context) {
    var _useTreeData = table_hooks_useTreeData["default"](props, context),
        store = _useTreeData.store,
        dataSource = _useTreeData.dataSource,
        formatTreeColum = _useTreeData.formatTreeColum,
        treeInstanceFunctions = _objectWithoutProperties__default["default"](_useTreeData, _excluded);

    var treeDataMap = VueCompositionAPI.ref(store.value.treeDataMap);

    var _useTreeSelect = table_hooks_useTreeSelect["default"](props, treeDataMap),
        onInnerSelectChange = _useTreeSelect.onInnerSelectChange;

    var getColumns = function getColumns(columns) {
      var arr = [];

      for (var i = 0, len = columns.length; i < len; i++) {
        var _item$children, _item$children2;

        var item = _objectSpread({}, columns[i]);

        item = formatTreeColum(item);

        if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
          item.children = getColumns(item.children);
        }

        if (!item.children || (_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length) {
          arr.push(item);
        }
      }

      return arr;
    };

    var tColumns = VueCompositionAPI.computed(function () {
      var isTreeData = !props.tree || !Object.keys(props.tree).length;
      return isTreeData ? props.columns : getColumns(props.columns);
    });
    return _objectSpread({
      store: store,
      dataSource: dataSource,
      tColumns: tColumns,
      onInnerSelectChange: onInnerSelectChange
    }, treeInstanceFunctions);
  },
  methods: {
    getListenser: function getListenser() {
      var _this = this;

      var listenser = {};
      PRIMARY_ALL_EVENTS.forEach(function (key) {
        listenser[key] = function () {
          for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
            args[_key] = arguments[_key];
          }

          _this.$emit.apply(_this, [key].concat(args));
        };
      });
      return listenser;
    }
  },
  render: function render() {
    var h = arguments[0];

    var props = _objectSpread(_objectSpread({}, this.$props), {}, {
      data: this.dataSource,
      columns: this.tColumns,
      disableDataPage: Boolean(this.tree && Object.keys(this.tree).length)
    });

    var on = _objectSpread(_objectSpread({}, this.getListenser()), {}, {
      "select-change": this.onInnerSelectChange
    });

    return h(table_primaryTable["default"], helper.helper([{
      "scopedSlots": this.$scopedSlots
    }, {
      "props": props
    }, {}, {
      "on": on
    }, {}, this.$attrs]));
  }
});

exports["default"] = _EnhancedTable;
//# sourceMappingURL=enhanced-table.js.map
