import { useRef as c, useEffect as i } from "react";
function u(e) {
  const t = c(e);
  i(() => {
    t.current = e;
  }, [e]), i(() => {
    const n = (r) => {
      !document.hidden && t.current && t.current(r);
    };
    return document.addEventListener("visibilitychange", n), () => {
      document.removeEventListener("visibilitychange", n);
    };
  }, []);
}
export {
  u as default
};
