<!-- chat.html - Clean componentized template -->
{% extends "base.html" %}

{% block title %}{{ tenant_make.name|default('EveAI') }} - AI Chat{% endblock %}

{% block head %}

<!-- Pass server data to JavaScript - vroeg in de head -->  
<script>
    // Definieer chatConfig voordat componenten worden geladen
    window.chatConfig = {
        explanation: {{ customisation.sidebar_markdown|default('')|tojson }},
        progress_tracker_insights: {{ customisation.progress_tracker_insights|default('No Information')|tojson }},
        form_title_display: {{ customisation.form_title_display|default('Full Title')|tojson }},
        conversationId: {{ conversation_id|default('default')|tojson }},
        messages: {{ messages|tojson|safe }},
        settings: {
            maxMessageLength: {{ settings.max_message_length|default(2000) }},
            allowFileUpload: {{ settings.allow_file_upload|default('true')|lower }},
            allowVoiceMessage: {{ settings.allow_voice_message|default('false')|lower }},
            autoScroll: {{ settings.auto_scroll|default('true')|lower }},
            allowReactions: {{ settings.allow_reactions|default('true')|lower }}
        },
        apiPrefix: '/chat-client/chat',
        language: {{ session.magic_link.specialist_args.language|default('en')|tojson }},
        supportedLanguageDetails: {{ config.SUPPORTED_LANGUAGE_DETAILS|tojson|safe }},
        allowedLanguages: {{ tenant_make.allowed_languages|tojson|safe }},
        tenantMake: {{ {
            'name': tenant_make.name or 'EveAI',
            'logo_url': tenant_make.logo_url or ''
        }|tojson|safe }},
        // Environment-aware static base provided by Flask's overridden url_for
        staticBase: {{ static_url|tojson }}
    };

    // Debug info om te controleren of chatConfig correct is ingesteld
    console.log('Chat configuration initialized:', window.chatConfig);
</script>
{% endblock %}

{% block content %}
<!-- De chat container is leeg en wordt via JavaScript gevuld -->
<!-- Het ChatApp component wordt via de app-initializer gemount -->
{% endblock %}

{% block scripts %}
<!-- Alle componenten worden al geladen via chat-client.js in scripts.html -->
<!-- Geen extra imports nodig -->
{% endblock %}
