<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 />
		</NuxtLayout>
	</a-extract-style>
	<a-extract-style>
		<nuxt-error-boundary>
			<template #error="{ error, clearError }">
				<error-bound :error="error" />
			</template>
		</nuxt-error-boundary>
	</a-extract-style>
</template>
<style>
	body {
		margin: 0 !important;
	}

	body[data-theme="dark"] {
		color: #fff;
	}
</style>
