import './bootstrap';

import Alpine from 'alpinejs';

window.Alpine = Alpine;

window.portalTheme = () => ({
    dark: localStorage.getItem('theme') !== 'light',
    init() {
        this.applyTheme();
        this.$watch('dark', () => this.applyTheme());
    },
    applyTheme() {
        document.documentElement.classList.toggle('dark', this.dark);
        localStorage.setItem('theme', this.dark ? 'dark' : 'light');
    },
});

Alpine.start();
