"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(defaultRowSelection, onChange) {
  if (defaultRowSelection === void 0) {
    defaultRowSelection = emptyObj;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var _useState = (0, _react.useState)(function () {
      return defaultRowSelection;
    }),
    rowSelection = _useState[0],
    setRowSelection = _useState[1];
  var initialSetRef = (0, _react.useRef)(false);
  (0, _react.useEffect)(function () {
    if (rowSelection === defaultRowSelection) return;

    // initialSetRef.current = true
    setRowSelection(defaultRowSelection);
  }, [defaultRowSelection]);
  var onRowSelectionChange = (0, _react.useCallback)(function (getValue) {
    onChange(getValue(rowSelection));
    setRowSelection(getValue(rowSelection));
  }, [rowSelection]);
  return [rowSelection, onRowSelectionChange];
};