import i from "../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import { useLayoutUpdateEffect as l } from "../../../rc-util/es/hooks/useLayoutEffect.mjs";
import { useState as p, useRef as o } from "react";
function d(t) {
  var e = p(0), a = i(e, 2), f = a[0], s = a[1], r = o(0), u = o();
  return u.current = t, l(function() {
    var n;
    (n = u.current) === null || n === void 0 || n.call(u);
  }, [f]), function() {
    r.current === f && (r.current += 1, s(r.current));
  };
}
function U(t) {
  var e = o([]), a = p({}), f = i(a, 2), s = f[1], r = o(typeof t == "function" ? t() : t), u = d(function() {
    var c = r.current;
    e.current.forEach(function(v) {
      c = v(c);
    }), e.current = [], r.current = c, s({});
  });
  function n(c) {
    e.current.push(c), u();
  }
  return [r.current, n];
}
export {
  d as default,
  U as useUpdateState
};
