window.themeInterop = {
    isSystemLight: function () {
        return window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches;
    },
    setCachedTheme: function (themeClass, modeValue) {
        localStorage.setItem('theme-mode', modeValue);
        localStorage.setItem('theme', themeClass === 'theme-light' ? 'light' : 'dark');
        
        if (themeClass === 'theme-light') {
            document.documentElement.classList.add('theme-light');
            document.documentElement.classList.remove('theme-dark');
        } else {
            document.documentElement.classList.add('theme-dark');
            document.documentElement.classList.remove('theme-light');
        }
    },
    isLightMode: function () {
        return document.documentElement.classList.contains('theme-light');
    },
    setLightMode: function (isLight) {
        var themeClass = isLight ? 'theme-light' : 'theme-dark';
        var modeValue = isLight ? '2' : '1';
        this.setCachedTheme(themeClass, modeValue);
    }
};
