export default defineNuxtRouteMiddleware(async (to) => {
    const auth = useAuthStore()
    if (!auth.isAuthenticated) {
        return
    }

    const { loaded, loadSidebar, isRouteDisabled } = useSidebar()
    if (!loaded.value) {
        await loadSidebar()
    }

    if (isRouteDisabled(to.path)) {
        return navigateTo('/')
    }
})
