<script lang="ts">
import { browser } from "$app/environment";
import { goto } from "$app/navigation";
import root from "$lib/Utility/root";
import locale from "$stores/locale";
import { tools } from "./tools";

export let tool: string;
</script>

<blockquote>
  <select
    bind:value={tool}
    onchange={() => {
      if (browser) goto(root(`/tools/${tool}`));
    }}
  >
    <option value="default" selected disabled hidden
      >{$locale().tools.picker?.placeholder}</option
    >

    {#each Object.keys(tools).filter((t) => t !== 'default' && !tools[t].hidden) as t}
      <option value={t}>{tools[t].short || tools[t].name()}</option>
    {/each}
  </select>
</blockquote>
