import { useEffect, useState } from "react";
export const useCSSVariable = (names)=>{
    const [variables, setVariables] = useState(()=>getCSSVariableValue(names ?? []));
    function getCSSVariableValue(names) {
        const root = document.documentElement;
        const styles = getComputedStyle(root);
        if (names) {
            const obj = names.reduce((acc, name, index)=>{
                acc[name] = styles.getPropertyValue(name);
                return acc;
            }, {});
            return obj;
        }
        return {};
    }
    useEffect(()=>{
        if (names?.length === 0) return;
        const styleObserver = new MutationObserver((mutations)=>{
            ;
            getCSSVariableValue(names);
        });
        styleObserver.observe(document.documentElement, {
            attributes: true,
            attributeFilter: [
                "style"
            ]
        });
        return ()=>{
            styleObserver.disconnect();
        };
    }, [
        names
    ]);
    return variables;
};

//# sourceMappingURL=useCSSVariable.js.map