<!-- Material Icons voor icoontjes in de interface -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0">

<!-- Define a robust global staticUrl helper BEFORE loading the chat client bundle -->
<script>
    (function(){
        if (typeof window === 'undefined') return;
        // If already defined (e.g., by chat.html head), reuse it and expose globally
        if (typeof window.staticUrl === 'function') {
            try { globalThis.staticUrl = window.staticUrl; } catch (e) {}
        } else {
            // Prefer runtime chatConfig.staticBase; else fallback to server-provided base or default
            var serverStaticBase = {{ static_url|default('')|tojson }} || '';
            if (!serverStaticBase) { serverStaticBase = {{ url_for('static', filename='')|tojson }}; }
            var base = (window.chatConfig && window.chatConfig.staticBase) ? window.chatConfig.staticBase : (serverStaticBase || '/static/');
            var normalizedBase = String(base).replace(/\/+$/, '/');
            window.staticUrl = function(path) {
                if (!path) return normalizedBase;
                return normalizedBase + String(path).replace(/^\/+/, '');
            };
            try { globalThis.staticUrl = window.staticUrl; } catch (e) {}
        }
        // Optional lightweight debug
        // console.debug('[scripts.html] staticUrl defined:', typeof window.staticUrl);
    })();
</script>

<!-- Chat client JS - bundled met alle componenten en ES modules -->
<script src="{{ asset_url('dist/chat-client.js') }}"></script>
<script>
    // Voeg taalinstellingen toe aan chatConfig indien deze nog niet bestaan
    if (window.chatConfig) {
        // Maak supportedLanguages beschikbaar voor de client
        window.chatConfig.supportedLanguages = [
            {% for lang_code in config.SUPPORTED_LANGUAGES %}
                {
                    code: {{ lang_code|tojson }},
                    name: {{ config.SUPPORTED_LANGUAGE_DETAILS[config.SUPPORTED_LANGUAGES_FULL[loop.index0]]['iso 639-1']|tojson }},
                    flag: {{ config.SUPPORTED_LANGUAGE_DETAILS[config.SUPPORTED_LANGUAGES_FULL[loop.index0]]['flag']|tojson }}
                }{% if not loop.last %},{% endif %}
            {% endfor %}
        ];

        // Voeg tenantMake toe aan chatConfig als die nog niet bestaat
        if (!window.chatConfig.tenantMake) {
            window.chatConfig.tenantMake = {{ {
                'name': tenant_make.name or 'EveAI',
                'logo_url': tenant_make.logo_url or ''
            }|tojson|safe }};
        }

        console.log('Taalinstellingen toegevoegd aan chatConfig');
    } else {
        console.warn('chatConfig is niet gedefinieerd in scripts.html');
    }
</script>

