<script>
  import { apikey, api_endpoint, lang, page } from "./store.js";
  import { addMessages, init } from "svelte-i18n";
  import en from "./locales/en.json";
  import de from "./locales/de.json";
  addMessages("en", en);
  addMessages("en-US", en);
  addMessages("de", de);
  addMessages("de-DE", de);
  //
  import Beamershow from "./Beamershow.svelte";
  import Login from "./Login.svelte";
  import Settings from "./Settings.svelte";
  $: is_configured = $apikey && $apikey !== "null" && $apikey !== "";
  $: settings_open = $page === "settings";
  init({
    fallbackLocale: "en-US",
    initialLocale: $lang,
  });
  console.log("app started with base url " + $api_endpoint);
</script>

{#if settings_open && is_configured}
  <Settings />
{:else if is_configured}
  <Beamershow />
{:else}
  <Login />
{/if}
