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

import { h as helper } from '../_chunks/dep-b6ac6e96.js';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, computed } from '@vue/composition-api';
import baseTableProps from './base-table-props.js';
import primaryTableProps from './primary-table-props.js';
import enhancedTableProps from './enhanced-table-props.js';
import _PrimaryTable from './primary-table.js';
import useTreeData from './hooks/useTreeData.js';
import useTreeSelect from './hooks/useTreeSelect.js';
import { BASE_TABLE_ALL_EVENTS } from './base-table.js';
import 'lodash/get';
import 'lodash/omit';
import '../hooks/tnode.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../hooks/render-tnode.js';
import 'lodash/isString';
import 'lodash/isObject';
import './hooks/useColumnController.js';
import '@babel/runtime/helpers/slicedToArray';
import '@babel/runtime/helpers/toConsumableArray';
import '@ldesign/icons-vue';
import 'lodash/intersection';
import '../checkbox/index.js';
import '../utils/map-props.js';
import 'vue';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import '../checkbox/group.js';
import '@babel/runtime/helpers/typeof';
import '../utils/event.js';
import '../utils/helper.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-2cb61c79.js';
import 'dayjs';
import '../utils/mixins.js';
import '../checkbox/checkbox.js';
import '../utils/render-tnode.js';
import '../checkbox/props.js';
import '../checkbox/checkbox-group-props.js';
import '../dialog/plugin.js';
import '../utils/dom.js';
import 'raf';
import '../utils/easing.js';
import '../config-provider/config-provider.js';
import 'lodash/cloneDeep';
import '../dialog/dialog.js';
import 'lodash/isNumber';
import 'lodash/throttle';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/directive.js';
import 'lodash/mapKeys';
import 'lodash/isEqual';
import '../loading/plugin.js';
import '../config.js';
import '../loading/loading.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isArray';
import '../utils/ripple.js';
import '../button/props.js';
import '../hooks/useDestroyOnClose.js';
import '../_common/js/utils/getScrollbarWidth.js';
import '../dialog/stack.js';
import '../dialog/props.js';
import '../dialog/actions.js';
import '../config-provider/useConfig.js';
import '../hooks/useDefaultValue.js';
import '../hooks/useGlobalIcon.js';
import './utils.js';
import './hooks/useTableHeader.js';
import './ellipsis.js';
import 'lodash/debounce';
import '../tooltip/index.js';
import '../tooltip/tooltip.js';
import '../popup/props.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../popup/container.js';
import '../popup/utils.js';
import '../popup/trigger.js';
import '../tooltip/props.js';
import '../_common/js/log/log.js';
import './hooks/useClassName.js';
import './hooks/useMultiHeader.js';
import './hooks/useRowExpand.js';
import './hooks/useRowSelect.js';
import '../radio/index.js';
import '../radio/radio.js';
import '../radio/props.js';
import '../radio/group.js';
import '../radio/radio-group-props.js';
import '../radio/radio-button.js';
import './hooks/useSorter.js';
import './sorter-button.js';
import './hooks/useFilter.js';
import './filter-controller.js';
import 'lodash/lowerFirst';
import '../popup/index.js';
import '../popup/plugin.js';
import '../input/index.js';
import '../input/input.js';
import '../input/props.js';
import '../input/input-group.js';
import './hooks/useDragSort.js';
import 'sortablejs';
import '../_common/js/utils/swapDragArrayElement.js';
import './hooks/useAsyncLoading.js';
import './hooks/useEditableCell.js';
import './editable-cell.js';
import 'lodash/set';
import '../form/form-model.js';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/regenerator';
import './tr.js';
import 'lodash/upperFirst';
import 'lodash/pick';
import '../hooks/useLazyLoad.js';
import '../_common/js/utils/observe.js';
import './hooks/useFixed.js';
import './hooks/useRowspanAndColspan.js';
import './hooks/useEditableRow.js';
import './hooks/useStyle.js';
import '../hooks/useCommonClassName.js';
import '../hooks/useVirtualScrollNew.js';
import '../hooks/useResizeObserver.js';
import '../affix/index.js';
import '../affix/affix.js';
import '../affix/props.js';
import './hooks/useColumnResize.js';
import './hooks/usePagination.js';
import '../pagination/index.js';
import '../pagination/pagination.js';
import '../input-number/index.js';
import '../input-number/input-number.js';
import '../input-number/props.js';
import '../input-number/useInputNumber.js';
import '../hooks/useVModel.js';
import '../_common/js/input-number/number.js';
import 'lodash/isNil';
import '../_common/js/input-number/large-number.js';
import '../hooks/useFormDisabled.js';
import '../select/index.js';
import '../select/select.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../select-input/index.js';
import '../select-input/select-input.js';
import '../select-input/props.js';
import '../select-input/useSingle.js';
import '../hooks/useConfig.js';
import '../select-input/useMultiple.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/useTagScroll.js';
import '../tag-input/useTagList.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import '../select-input/useOverlayInnerStyle.js';
import '../common-components/fake-arrow.js';
import '../select/option.js';
import '../select/util.js';
import '../select/option-props.js';
import '../select/select-panel.js';
import '../hooks/useVirtualScroll.js';
import '../select/hooks/useSelectOptions.js';
import '../select/props.js';
import '../select/optionGroup.js';
import '../select/option-group-props.js';
import '../input-adornment/index.js';
import '../input-adornment/input-adornment.js';
import '../input-adornment/props.js';
import '../pagination/props.js';
import '../pagination/pagination-mini.js';
import '../pagination/pagination-mini-props.js';
import './hooks/useAffix.js';
import './tbody.js';
import './thead.js';
import './tfoot.js';
import '../_common/js/table/tree-store.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '../_common/js/table/utils.js';

var _excluded = ["store", "dataSource", "formatTreeColumn", "swapData"];
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(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 = ["cell-click", "change", "page-change", "expand-change", "filter-change", "select-change", "sort-change", "data-change", "async-loading-click", "column-change", "column-controller-visible-change", "display-columns-change", "drag-sort", "row-edit", "row-validate", "validate"];
var PRIMARY_ALL_EVENTS = BASE_TABLE_ALL_EVENTS.concat(PRIMARY_B_EVENTS);
var _EnhancedTable = defineComponent({
  name: "TEnhancedTable",
  props: _objectSpread(_objectSpread(_objectSpread({}, baseTableProps), primaryTableProps), enhancedTableProps),
  setup: function setup(props, context) {
    var primaryTableRef = ref();
    var _useTreeData = useTreeData(props, context),
      store = _useTreeData.store,
      dataSource = _useTreeData.dataSource,
      formatTreeColumn = _useTreeData.formatTreeColumn,
      swapData = _useTreeData.swapData,
      treeInstanceFunctions = _objectWithoutProperties(_useTreeData, _excluded);
    var treeDataMap = ref(store.value.treeDataMap);
    var _useTreeSelect = useTreeSelect(props, treeDataMap),
      tIndeterminateSelectedRowKeys = _useTreeSelect.tIndeterminateSelectedRowKeys,
      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 = formatTreeColumn(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 = computed(function () {
      var isTreeData = !props.tree || !Object.keys(props.tree).length;
      return isTreeData ? props.columns : getColumns(props.columns);
    });
    var onDragSortChange = function onDragSortChange(params) {
      var _props$onDragSort;
      if (props.beforeDragSort && !props.beforeDragSort(params)) return;
      swapData({
        current: params.current,
        target: params.target,
        currentIndex: params.currentIndex,
        targetIndex: params.targetIndex
      });
      (_props$onDragSort = props.onDragSort) === null || _props$onDragSort === void 0 ? void 0 : _props$onDragSort.call(props, params);
      context.emit("drag-sort", params);
    };
    var onEnhancedTableRowClick = function onEnhancedTableRowClick(p) {
      var _props$tree, _props$onRowClick;
      if ((_props$tree = props.tree) !== null && _props$tree !== void 0 && _props$tree.expandTreeNodeOnClick) {
        treeInstanceFunctions.toggleExpandData({
          row: p.row,
          rowIndex: p.index
        }, "row-click");
      }
      (_props$onRowClick = props.onRowClick) === null || _props$onRowClick === void 0 ? void 0 : _props$onRowClick.call(props, p);
      context.emit("row-click", p);
    };
    return _objectSpread({
      store: store,
      dataSource: dataSource,
      tColumns: tColumns,
      tIndeterminateSelectedRowKeys: tIndeterminateSelectedRowKeys,
      enhancedTableRef: primaryTableRef,
      primaryTableRef: primaryTableRef,
      onDragSortChange: onDragSortChange,
      onInnerSelectChange: onInnerSelectChange,
      onEnhancedTableRowClick: onEnhancedTableRowClick
    }, treeInstanceFunctions);
  },
  methods: {
    getListener: function getListener() {
      var _this = this;
      var listeners = {};
      PRIMARY_ALL_EVENTS.forEach(function (key) {
        listeners[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));
          if (key === "display-columns-change") _this.$emit.apply(_this, ["update:displayColumns"].concat(args));
        };
      });
      return listeners;
    }
  },
  render: function render() {
    var _this$tree;
    var h = arguments[0];
    var props = _objectSpread(_objectSpread({
      rowKey: this.rowKey || "id"
    }, this.$options.propsData), {}, {
      data: this.dataSource,
      columns: this.tColumns,
      indeterminateSelectedRowKeys: this.tIndeterminateSelectedRowKeys,
      disableDataPage: Boolean(this.tree && Object.keys(this.tree).length)
    });
    var on = _objectSpread(_objectSpread({}, this.getListener()), {}, {
      "select-change": this.onInnerSelectChange,
      "drag-sort": this.onDragSortChange
    });
    if ((_this$tree = this.tree) !== null && _this$tree !== void 0 && _this$tree.expandTreeNodeOnClick) on["row-click"] = this.onEnhancedTableRowClick;
    return h(_PrimaryTable, helper([{
      "ref": "primaryTableRef",
      "scopedSlots": this.$scopedSlots
    }, {
      "props": props
    }, {}, {
      "on": on
    }, {}, this.$attrs]));
  }
});

export { _EnhancedTable as default };
//# sourceMappingURL=enhanced-table.js.map
