<script lang="ts">
  // @ts-nocheck
  // v0.2 Phase 6 — thin composition. The three split-out shells own
  // their respective responsibilities; this file just decides whether
  // to render the chrome (main window) or pass children straight
  // through (secondary windows like /float, /viewer, /preview, which
  // also have their own +layout@.svelte to break out of this layout).
  import "../app.css";
  import { page as sveltePage } from "$app/stores";
  import AppRuntime from "$lib/shell/AppRuntime.svelte";
  import AppChrome from "$lib/shell/AppChrome.svelte";
  import AppOverlays from "$lib/shell/AppOverlays.svelte";

  let { children } = $props();

  // Defensive: secondary windows use +layout@.svelte to escape this
  // root layout, but if any /float, /viewer, /preview load ever
  // reaches here we still drop the chrome.
  let isSecondaryWindow = $derived(
    $sveltePage.url.pathname.startsWith("/float") ||
    $sveltePage.url.pathname.startsWith("/viewer") ||
    $sveltePage.url.pathname.startsWith("/preview")
  );
</script>

<AppRuntime />

{#if isSecondaryWindow}
  {@render children()}
{:else}
  <AppChrome>
    {@render children()}
  </AppChrome>
{/if}

<AppOverlays />
