import { useCallback, useEffect, useState, useRef } from "react";
var noop = function noop() {};
var emptyObj = {};
export default (function (defaultColumnSizing, onChange) {
  if (defaultColumnSizing === void 0) {
    defaultColumnSizing = emptyObj;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var _useState = useState(function () {
      return defaultColumnSizing;
    }),
    columnSizing = _useState[0],
    setColumnSizing = _useState[1];
  var initialSetRef = useRef(false);
  useEffect(function () {
    if (columnSizing === defaultColumnSizing) return;
    initialSetRef.current = true;
    setColumnSizing(defaultColumnSizing);
  }, [defaultColumnSizing]);
  var onSizingChange = useCallback(function (getValue) {
    onChange(getValue(columnSizing));
    setColumnSizing(getValue(columnSizing));
  }, [columnSizing]);
  return [columnSizing, onSizingChange];
});