import { useCallback } from 'react';
export function useGuidance(index) {
    return useCallback((name)=>{
        return index[name] || '';
    }, [
        index
    ]);
}
export function useHandleClick(setName) {
    return useCallback((url)=>{
        if (!url.includes(window.location.origin)) {
            return window.open(url, '_blank');
        }
        const name = url.split(`/`).pop()?.replace(/.md/, '');
        if (name) {
            setName((prev)=>[
                    ...prev,
                    name
                ]);
        }
    }, [
        setName
    ]);
}
export function useGoBack(setName) {
    return useCallback(()=>{
        setName((prev)=>prev.slice(0, -1));
    }, [
        setName
    ]);
}
export function useGoHome(name, setName) {
    return useCallback(()=>{
        setName([
            name
        ]);
    }, [
        setName,
        name
    ]);
}
