<script lang="ts" context="module">
  import type { Load } from "@sveltejs/kit/types/internal";

  export const load: Load = async({ fetch, session, url }) => {
    if (session.user == null && !url.pathname.startsWith("/login")) {
      return { status: 302, redirect: "/login" };
    }

    return { props: {} };
	}
</script>

<script lang="ts">
  import { page } from "$app/stores";
  
  import Background from "$lib/components/layout/Background.svelte"
  import TimeContext from "$lib/components/contexts/TimeContext.svelte";
  import ModalContext from "$lib/components/contexts/ModalContext.svelte";

  let opacity = 0.175;
  
  $: opacity = $page.url.pathname === "/" ? 0.3 : 0.2;
</script>

<ModalContext>
  <TimeContext>
    <Background initialOrientation="landscape" opacity={opacity} />
    <slot></slot>
  </TimeContext>
</ModalContext>