import '../../../../../node_modules/preact/compat/dist/compat.module.mjs';
import { useEffect as p } from '../../../../../node_modules/preact/hooks/dist/hooks.module.mjs';

const useBeforeUnloadNavigationBlock = (shouldWarn)=>{
    p(()=>{
        if (shouldWarn) {
            const handleBeforeUnload = (e)=>{
                e.preventDefault();
                e.returnValue = true;
            };
            window.addEventListener('beforeunload', handleBeforeUnload);
            return ()=>{
                window.removeEventListener('beforeunload', handleBeforeUnload);
            };
        }
    }, [
        shouldWarn
    ]);
};

export { useBeforeUnloadNavigationBlock };
//# sourceMappingURL=useNavigateAwayWarning.mjs.map
