<script lang="ts" setup>
	const { getSession, signIn } = useAuth();

	await getSession({ force: true });

	const { data } = useAuth();

	let darkBool = ref(data.value?.user?.profile?.nightMode || false);
	// provide("user", ref(dop?.user || null));
	provide("dark", darkBool);
	useHead({
		bodyAttrs: {
			"data-theme": computed(() => {
				return darkBool.value ? "dark" : undefined;
			}).value,
		},
		titleTemplate: (title) => (title ? `Rockfic | ${title}` : "Rockfic | Band fiction that rocks"),
	});
	// provide("loaded", useNuxtApp().$loaded);
	// let loaded = ref<boolean[]>([]);
	// provide("loaded", {
	// 	loaded,
	// 	pushState() {
	// 		loaded.value.push(false)
	// 	},
	// 	flipLast() {
	// 		loaded.value[ loaded.value.length ] = true
	// 	}
	// });
</script>
<template>
	<a-extract-style>
		<NuxtLayout>
			<NuxtPage />
			<!-- <NuxtWelcome /> -->
		</NuxtLayout>
	</a-extract-style>
	<nuxt-error-boundary>
		<template #error="{ error, clearError }">
			<error-bound :error="error" />
		</template>
	</nuxt-error-boundary>
</template>
<style>
	body[data-theme="dark"],
	body[data-theme="dark"] .alayhead {
		background-color: #141414;
		color: #fff;
	}

	html {
		background: #f5f5f5;
	}

	html,
	body {
		height: 100%;
	}

	html:has(body[data-theme="dark"]) {
		background-color: #141414 !important;
	}

	body {
		margin: 0px !important;
	}

	body:not([data-theme="dark"]) .alayhead {
		background-color: #f5f5f5 !important;
	}
</style>
