<script lang="ts">
    import "../app.css";
    import favicon from "$lib/assets/favicon.svg";
    import { afterNavigate } from "$app/navigation";
    import { isAuthenticated } from "$lib/Auth.svelte";

    let { children } = $props();

    let renderit = $state(false);

    afterNavigate(() => {
        isAuthenticated()
            .then(() => {
                renderit = true;
            })
            .catch(() => {
                renderit = true;
            });
    });
</script>

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

{#if renderit}
    {@render children?.()}
{/if}
