<script>
  import { setContext, onMount } from "svelte"
  import Component from "./Component.svelte"
  import SDK from "../sdk"
  import { routeStore, screenStore } from "../store"

  // Provide SDK for components
  setContext("app", SDK)

  let loaded = false

  // Load app config
  onMount(async () => {
    await routeStore.actions.fetchRoutes()
    await screenStore.actions.fetchScreens()
    loaded = true
  })
</script>

{#if loaded}
  <Component definition={$screenStore.page.props} />
{/if}
