import { AppearanceMode } from '@/constants/appearance-mode';
import type { AppearanceMode as AppearanceModeType } from '@/types/account';

export function applyAppearance(mode: AppearanceModeType): void {
    const root = document.documentElement;

    root.classList.remove('dark');

    if (mode === AppearanceMode.DARK || (mode === AppearanceMode.SYSTEM && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
        root.classList.add('dark');
    }
}

export function useAppearance() {
    return {
        applyAppearance,
    };
}
