import * as u from "react";
import { u as f } from "./index-DOfn3ixy.mjs";
function R(e, t, { checkForDefaultPrevented: o = !0 } = {}) {
  return function(n) {
    if (e?.(n), o === !1 || !n.defaultPrevented)
      return t?.(n);
  };
}
function h({
  prop: e,
  defaultProp: t,
  onChange: o = () => {
  }
}) {
  const [r, n] = v({ defaultProp: t, onChange: o }), s = e !== void 0, i = s ? e : r, l = f(o), d = u.useCallback(
    (c) => {
      if (s) {
        const a = typeof c == "function" ? c(e) : c;
        a !== e && l(a);
      } else
        n(c);
    },
    [s, e, n, l]
  );
  return [i, d];
}
function v({
  defaultProp: e,
  onChange: t
}) {
  const o = u.useState(e), [r] = o, n = u.useRef(r), s = f(t);
  return u.useEffect(() => {
    n.current !== r && (s(r), n.current = r);
  }, [r, n, s]), o;
}
function P(e) {
  const t = u.useRef({ value: e, previous: e });
  return u.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
}
export {
  P as a,
  R as c,
  h as u
};
//# sourceMappingURL=index-tyLV0iiH.mjs.map
