import { useCallback as o, useEffect as u } from "react";
function a(r = !0, e) {
  const n = o(
    (t) => {
      if (typeof r != "function" || r())
        return t.preventDefault(), t.returnValue = e, e;
    },
    [r, e]
  );
  u(() => {
    if (r)
      return window.addEventListener("beforeunload", n), () => window.removeEventListener("beforeunload", n);
  }, [r, n]);
}
export {
  a as default
};
//# sourceMappingURL=use-beforeunload.js.map
