var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/table/hooks/useMergeColumnSetting.ts
var useMergeColumnSetting_exports = {};
__export(useMergeColumnSetting_exports, {
  default: () => useMergeColumnSetting_default
});
module.exports = __toCommonJS(useMergeColumnSetting_exports);
var import_react = require("react");
var import_ahooks = require("ahooks");
var import_utils = require("../Table/utils");
var useMergeColumnSetting = (params) => {
  const { tableId, defaultColumns, dispatch, storageMode, currentViewMode } = params;
  const [columns, setColumns] = (0, import_react.useState)(defaultColumns);
  const onChange = (0, import_ahooks.useMemoizedFn)((newColumns) => {
    if (tableId && storageMode === "localStorage") {
      (0, import_utils.setTableSettingToLocalStorage)({
        tableId,
        tableSettingObj: { column_setting: newColumns },
        currentViewMode,
        currentSettingHash: ""
      });
    }
    dispatch({
      type: "setDefaultColumns",
      payload: newColumns
    });
  });
  (0, import_react.useEffect)(() => {
    setColumns(defaultColumns);
  }, [defaultColumns]);
  const hideColumns = (0, import_react.useMemo)(() => {
    return columns.filter((item) => !(item == null ? void 0 : item.isShow));
  }, [columns]);
  return {
    columns,
    onChange,
    hideColumns
    // fixedColumns,
    // sortColumns,
  };
};
var useMergeColumnSetting_default = useMergeColumnSetting;
