"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index$5 = require("../../../hooks/use-locale/index.js");
const index$6 = require("../../../hooks/use-namespace/index.js");
const index = require("../../scrollbar/index.js");
const useGlobalConfig = require("../../config-provider/src/hooks/use-global-config.js");
const index$4 = require("../../../directives/mousewheel/index.js");
const helper = require("./store/helper.js");
const tableLayout = require("./table-layout.js");
const tokens = require("./tokens.js");
const utilsHelper = require("./table-header/utils-helper.js");
const index$3 = require("./table-header/index.js");
const index$2 = require("./table-body/index.js");
const index$1 = require("./table-footer/index.js");
const utilsHelper$1 = require("./table/utils-helper.js");
const styleHelper = require("./table/style-helper.js");
const keyRenderHelper = require("./table/key-render-helper.js");
const defaults = require("./table/defaults.js");
const hHelper = require("./h-helper.js");
const useScrollbar = require("./composables/use-scrollbar.js");
const vue = require("vue");
const debounce = require("../../../../../lodash-es/debounce.js");
let tableIdSeed = 1;
var table_vue_vue_type_script_lang_default = vue.defineComponent({
  name: "ElTable",
  directives: { Mousewheel: index$4.default },
  components: {
    TableHeader: index$3.default,
    TableBody: index$2.default,
    TableFooter: index$1.default,
    ElScrollbar: index.ElScrollbar,
    hColgroup: hHelper.hColgroup
  },
  props: defaults.default,
  emits: [
    "select",
    "select-all",
    "selection-change",
    "cell-mouse-enter",
    "cell-mouse-leave",
    "cell-contextmenu",
    "cell-click",
    "cell-dblclick",
    "row-click",
    "row-contextmenu",
    "row-dblclick",
    "header-click",
    "header-contextmenu",
    "sort-change",
    "filter-change",
    "current-change",
    "header-dragend",
    "expand-change",
    "scroll"
  ],
  setup(props) {
    const { t } = index$5.useLocale();
    const ns = index$6.useNamespace("table");
    const globalConfig = useGlobalConfig.useGlobalConfig("table");
    const table = vue.getCurrentInstance();
    vue.provide(tokens.TABLE_INJECTION_KEY, table);
    const store = helper.createStore(table, props);
    table.store = store;
    const layout = new tableLayout.default({
      store: table.store,
      table,
      fit: props.fit,
      showHeader: props.showHeader
    });
    table.layout = layout;
    const isEmpty = vue.computed(() => (store.states.data.value || []).length === 0);
    const { setCurrentRow, getSelectionRows, toggleRowSelection, clearSelection, clearFilter, toggleAllSelection, toggleRowExpansion, clearSort, sort, updateKeyChildren } = utilsHelper$1.default(store);
    const { isHidden, renderExpanded, setDragVisible, isGroup, handleMouseLeave, handleHeaderFooterMousewheel, tableSize, emptyBlockStyle, resizeProxyVisible, bodyWidth, resizeState, doLayout, tableBodyStyles, tableLayout: tableLayout$1, scrollbarViewStyle, scrollbarStyle } = styleHelper.default(props, layout, store, table);
    const { scrollBarRef, scrollTo, setScrollLeft, setScrollTop } = useScrollbar.useScrollbar();
    const debouncedUpdateLayout = debounce.default(doLayout, 50);
    const tableId = `${ns.namespace.value}-table_${tableIdSeed++}`;
    table.tableId = tableId;
    table.state = {
      isGroup,
      resizeState,
      doLayout,
      debouncedUpdateLayout
    };
    const computedSumText = vue.computed(() => props.sumText ?? t("el.table.sumText"));
    const computedEmptyText = vue.computed(() => {
      return props.emptyText ?? t("el.table.emptyText");
    });
    const computedTooltipEffect = vue.computed(() => {
      var _a;
      return props.tooltipEffect ?? ((_a = globalConfig.value) == null ? void 0 : _a.tooltipEffect);
    });
    const computedTooltipOptions = vue.computed(() => {
      var _a;
      return props.tooltipOptions ?? ((_a = globalConfig.value) == null ? void 0 : _a.tooltipOptions);
    });
    const columns = vue.computed(() => {
      return utilsHelper.convertToRows(store.states.originColumns.value)[0];
    });
    keyRenderHelper.default(table);
    vue.onBeforeUnmount(() => {
      debouncedUpdateLayout.cancel();
    });
    return {
      ns,
      layout,
      store,
      columns,
      handleHeaderFooterMousewheel,
      handleMouseLeave,
      tableId,
      tableSize,
      isHidden,
      isEmpty,
      renderExpanded,
      resizeProxyVisible,
      resizeState,
      isGroup,
      bodyWidth,
      tableBodyStyles,
      emptyBlockStyle,
      debouncedUpdateLayout,
      setCurrentRow,
      getSelectionRows,
      toggleRowSelection,
      clearSelection,
      clearFilter,
      toggleAllSelection,
      toggleRowExpansion,
      clearSort,
      doLayout,
      sort,
      updateKeyChildren,
      t,
      setDragVisible,
      context: table,
      computedSumText,
      computedEmptyText,
      computedTooltipEffect,
      computedTooltipOptions,
      tableLayout: tableLayout$1,
      scrollbarViewStyle,
      scrollbarStyle,
      scrollBarRef,
      scrollTo,
      setScrollLeft,
      setScrollTop,
      allowDragLastColumn: props.allowDragLastColumn
    };
  }
});
exports.default = table_vue_vue_type_script_lang_default;
