/**
 * Flash Message Handler
 * Displays server-side flash messages using showToast
 */

document.addEventListener('DOMContentLoaded', () => {
    const flashDataEl = document.getElementById('flash-messages-data');
    if (flashDataEl) {
        try {
            const messages = JSON.parse(flashDataEl.textContent);
            
            if (messages.success_msg) {
                showToast('Success', messages.success_msg, 'success');
            }
            
            if (messages.error_msg) {
                showToast('Error', messages.error_msg, 'error');
            }
            
            if (messages.error) {
                showToast('Error', messages.error, 'error');
            }
        } catch (e) {
            console.error('Error parsing flash messages data:', e);
        }
    }
});
