---
import LoginComponent from "@components/Login.svelte";
import NavbarLayout from "@layouts/NavbarLayout.astro";
import {t} from "astro-i18n";
import BackgroundImage from "../components/BackgroundImage.astro";
---

<NavbarLayout title={t("login.page")}>
    <script>
        import {l} from "../util/util";
        import {navigate} from "astro:transitions/client";
        import {loggedIn} from "../components/repo/authv2";
        import {get} from "svelte/store";

        document.addEventListener("astro:page-load", () => {
            if (window.location.href.endsWith("/login") || window.location.href.endsWith("/login/")) {
                if (get(loggedIn)) {
                    navigate(l("/dashboard"), {history: "replace"});
                }
            }
        });
    </script>
    <div class="h-screen w-screen fixed -z-10">
        <BackgroundImage />
    </div>
    <div class="h-screen mx-auto  p-8 rounded-b-md pt-40 sm:pt-28 md:pt-14 flex flex-col justify-center items-center
            dark:text-white " style="width: min(100vw, 75em);">
        <LoginComponent client:load/>
    </div>
</NavbarLayout>