"use client";
import { useMemo } from "react";
import { useEnsuredState } from "../useEnsuredState.js";
import { useColorSchemeMetaTag } from "./useColorSchemeMetaTag.js";
import { usePrefersDarkTheme } from "./usePrefersDarkTheme.js";
export function useColorSchemeProvider(options = {}) {
    const { disableMetaTag, colorScheme: propColorScheme, setColorScheme: propSetColorScheme, defaultColorScheme } = options;
    const [colorScheme, setColorScheme] = useEnsuredState({
        name: "colorScheme",
        value: propColorScheme,
        setValue: propSetColorScheme,
        defaultValue: defaultColorScheme
    });
    const prefersDarkTheme = usePrefersDarkTheme(colorScheme !== "system");
    const derivedColorScheme = prefersDarkTheme ? "dark" : "light";
    const currentColor = colorScheme === "system" ? derivedColorScheme : colorScheme;
    useColorSchemeMetaTag({
        disabled: disableMetaTag,
        colorScheme: currentColor
    });
    return useMemo(()=>({
            currentColor,
            colorScheme,
            setColorScheme
        }), [
        currentColor,
        colorScheme,
        setColorScheme
    ]);
}

//# sourceMappingURL=useColorSchemeProvider.js.map