"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = require("react");
var noop = function noop() {};
var emptyObj = {};
var _default = exports["default"] = function _default(defaultColumnVisibility, onChange) {
  if (defaultColumnVisibility === void 0) {
    defaultColumnVisibility = emptyObj;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var _useState = (0, _react.useState)(function () {
      return defaultColumnVisibility;
    }),
    columnVisibility = _useState[0],
    setColumnVisibility = _useState[1];
  (0, _react.useEffect)(function () {
    if (columnVisibility === defaultColumnVisibility) return;
    setColumnVisibility(defaultColumnVisibility);
  }, [defaultColumnVisibility]);
  var onVisibilityChange = (0, _react.useCallback)(function (getValue) {
    var newValue = getValue(columnVisibility);
    onChange(newValue);
    setColumnVisibility(newValue);
  }, [columnVisibility]);
  return [columnVisibility, onVisibilityChange];
};