<script lang="ts">
	import { onMount } from 'svelte';
	import { authStore } from '$lib/stores/auth.svelte.js';
	import { page } from '$app/stores';
	import Navigation from '$lib/components/Navigation.svelte';
	import favicon from '$lib/assets/favicon.svg';
	import '../app.css';

	let { children } = $props();

	onMount(async () => {
		// Authentifizierung beim Laden der App initialisieren
		await authStore.init();
	});

	// Seiten ohne Navigation
	const noNavPages = ['/login', '/register', '/forgot-password', '/reset-password'];
	let showNav = $derived(authStore.isAuthenticated && !noNavPages.includes($page.url.pathname));
</script>

<svelte:head>
	<link rel="icon" href={favicon} />
	<title>Smartes Klassenzimmer</title>
</svelte:head>

{#if showNav}
	<Navigation />
{/if}

{@render children()}
