'use client';
// packages/ui/src/routing/hooks/useNavigate.vite.ts
/**
 * @fileoverview Vite-specific navigation hooks
 * @description Navigation hooks for React Router (Vite)
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
import { useCallback } from 'react';
import { useNavigate as useRouterNavigate } from 'react-router-dom';
import { isClient, useOverlayStore } from '@donotdev/core';
export function useNavigate() {
    const navigate = useRouterNavigate();
    const closeAll = useOverlayStore((state) => state.closeAll);
    return useCallback((to, options) => {
        if (to === 'back') {
            closeAll();
            return navigate(-1);
        }
        closeAll();
        if (options?.replace)
            return navigate(to, { replace: true });
        return navigate(to);
    }, [navigate, closeAll]);
}
export function useBack() {
    const navigate = useRouterNavigate();
    return useCallback(() => navigate(-1), [navigate]);
}
export function useRefresh() {
    return useCallback(() => {
        if (isClient())
            window.location.reload();
    }, []);
}
export function usePrefetch() {
    return useCallback((_to) => {
        // Vite: no-op
    }, []);
}
