import { useCallback, useEffect, useState, useRef } from "react";
var noop = function noop() {};
var defaultPaginationOptions = {
  pageIndex: 0,
  pageSize: 0
};
export default (function (paginationOptions, onChange) {
  if (paginationOptions === void 0) {
    paginationOptions = defaultPaginationOptions;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var _useState = useState(function () {
      return paginationOptions;
    }),
    pagination = _useState[0],
    setPagination = _useState[1];
  var initialSetRef = useRef(false);
  useEffect(function () {
    if (pagination === paginationOptions) return;
    initialSetRef.current = true;
    setPagination(paginationOptions);
  }, [paginationOptions]);
  var onPaginationChange = useCallback(function (value) {
    onChange(value);
    setPagination(value);
  }, []);
  return [pagination, onPaginationChange];
});