<script lang="ts">
  import { appsById } from '$lib/data/apps';
  import type { WindowState } from '$lib/stores/windowStore';

  export let windows: WindowState[] = [];
  export let openApp: (id: string) => void;
  export let restoreApp: (id: string) => void;
  export let openPalette: () => void;
</script>

<nav class="taskbar" aria-label="ianOS taskbar">
  <button type="button" class="taskbar__start" on:click={() => openApp('readme')}>ianOS</button>
  <button type="button" on:click={openPalette}>Command</button>
  <a href="/simple">Simple Mode</a>
  <div class="taskbar__windows" aria-label="Open windows">
    {#each windows as item}
      {@const app = appsById.get(item.id)}
      {#if app}
        <button type="button" class:minimised={item.minimised} on:click={() => restoreApp(item.id)}>
          {app.shortTitle}
        </button>
      {/if}
    {/each}
  </div>
  <button type="button" class="taskbar__control" on:click={() => openApp('control')}>Control</button>
</nav>
