<script lang="ts">
	// The ordering of these imports is critical to your app working properly
	//import '@skeletonlabs/skeleton/themes/theme-skeleton.css';
	import '../theme.postcss';
	// If you have source.organizeImports set to true in VSCode, then it will auto change this ordering
	//import '@skeletonlabs/skeleton/styles/skeleton.css';
	// Most of your app wide CSS should be put in this file
	import '../app.postcss';
	import { AppShell, AppBar } from '@skeletonlabs/skeleton';
	import { locale, locales } from 'svelte-i18n';

	import { mapLocaleToDir } from '$lib/i18n';

	locale.subscribe((l) => {
		if (typeof document !== 'undefined') {
			document.dir = mapLocaleToDir(l);
		}
	});
</script>

<!-- App Shell -->
<AppShell>
	<svelte:fragment slot="header">
		<!-- App Bar -->
		<AppBar>
			<svelte:fragment slot="lead">
				<strong class="text-xl">Anvil</strong>
			</svelte:fragment>
			<svelte:fragment slot="trail">
				<select bind:value={$locale} class="select">
					{#each $locales as locale}
						<option value={locale}>{locale}</option>
					{/each}
				</select>
				<a
					class="btn btn-sm variant-ghost-surface"
					href="https://matrix.to/#/#general-forgefed:matrix.batsense.net"
					target="_blank"
					rel="noreferrer"
				>
					Matrix
				</a>
				<a
					class="btn btn-sm variant-ghost-surface"
					href="https://forgefed.org"
					target="_blank"
					rel="noreferrer"
				>
					ForgeFed
				</a>
				<a
					class="btn btn-sm variant-ghost-surface"
					href="https://codeberg.org/anvil/anvil"
					target="_blank"
					rel="noreferrer"
				>
					Code
				</a>
			</svelte:fragment>
		</AppBar>
	</svelte:fragment>
	<!-- Page Route Content -->
	<slot />
</AppShell>
