export const ssr = false;

/** @type {import('./$types').LayoutLoad} */
export async function load() {
    const theme = localStorage.getItem("theme");
    const container = document.querySelector("html");
    const windowTheme = window.matchMedia("(prefers-color-scheme: dark)");

    if (theme) {
        container?.setAttribute("data-bs-theme", theme);
        return { theme };
    }

    const currentTheme = windowTheme.matches ? "dark" : "light";
    container?.setAttribute("data-bs-theme", currentTheme);

    return { theme: currentTheme };
}
