<script lang="ts">
	import { loginFromStorage, userState } from '$lib/userstore';
	import Register from './Register.svelte';
	import { onMount } from 'svelte';
	import Login from './Login.svelte';

	$: printEnabled = false;

	onMount(() => {
		const params = new URLSearchParams(window.location.search);
		if (params.get('print') === 'true') {
			printEnabled = true;
		}
		loginFromStorage();
	});
</script>

{#if $userState.isLoggedIn}
	<Register bind:printEnabled />
{:else}
	<Login />
{/if}
<div class="fixed bottom-0 w-full text-center text-xl p-4 dark:text-white select-none print:absolute print:bottom-auto">
	{#if $userState.isLoggedIn}
		<b class="font-bold">LfK!2025</b> powered by
		<b class="font-bold">ODIT.Services</b>
	{:else}
		<a
			rel="noopener noreferrer"
			target="_blank"
			href="https://lauf-fuer-kaya.de/datenschutz/"
			class="underline">Datenschutzerklärung</a
		>
		|
		<a
			rel="noopener noreferrer"
			target="_blank"
			href="https://lauf-fuer-kaya.de/impressum/"
			class="underline">Impressum</a
		>
		<br />
		<b class="font-bold">LfK!2025</b> powered by
		<a
			rel="noopener noreferrer"
			target="_blank"
			href="https://odit.services?ref=lfk"
			class="underline">ODIT.Services</a
		>
	{/if}
</div>
