{# Let's see if there are loginfault messages to show #}
{% set loginfaults = flash.getMessage('loginfault') %}
{% if loginfault_detected is defined and loginfault_detected is iterable %}
    {% for l in loginfault_detected %}
        {% set loginfaults = loginfaults|merge([l]) %}
    {% endfor %}
{% endif %}

{# Let's see if there are error messages to show #}
{% set errors = flash.getMessage('error_detected') ?? []|merge(flash.getMessage('error') ?? [])|merge(loginfaults ?? []) %}
{% if error_detected is defined and error_detected is iterable %}
    {% for e in error_detected %}
        {% set errors = errors|merge([e]) %}
    {% endfor %}
{% endif %}
{% if errors is iterable and errors|length > 0 %}
    <div class="ui error icon message with-transition">
        <i class="times icon"></i>
        <i class="window close outline icon"></i>
        <div class="content">
            <div class="header">{{ _T("- ERROR -") }}</div>
            {% if errors|length > 1 %}
                <ul class="list">
                {% for error in errors %}
                    <li>{{ error|raw }}</li>
                {% endfor %}
                </ul>
            {% else %}
                {% for error in errors %}
                    <p>{{ error|raw }}</p>
                {% endfor %}
            {% endif %}
        </div>
    </div>
{% endif %}

{# Let's see if there are warning messages to show #}
{% set warnings = flash.getMessage('warning_detected') ?? []|merge(flash.getMessage('warning') ?? []) %}
{% if warning_detected is defined and warning_detected is iterable %}
    {% for w in warning_detected %}
        {% set warnings = warnings|merge([w]) %}
    {% endfor %}
{% endif %}
{% if warnings is iterable and warnings|length > 0 %}
    <div class="ui warning icon message with-transition">
        <i class="exclamation triangle icon"></i>
        <i class="window close outline icon"></i>
        <div class="content">
            <div class="header">{{ _T("- WARNING -") }}</div>
            {% if warnings|length > 1 %}
                <ul class="list">
                {% for warning in warnings %}
                    <li>{{ warning|raw }}</li>
                {% endfor %}
                </ul>
            {% else %}
                {% for warning in warnings %}
                    <p>{{ warning|raw }}</p>
                {% endfor %}
            {% endif %}
        </div>
    </div>
{% endif %}

{# Let's see if there are success messages to show #}
{% set successs = flash.getMessage('success_detected') ?? []|merge(flash.getMessage('success') ?? []) %}
{% if success_detected is defined and success_detected is iterable %}
    {% for s in success_detected %}
        {% set successs = successs|merge([s]) %}
    {% endfor %}
{% endif %}
{% if successs is iterable and successs|length > 0 %}
    <noscript>
        <div class="ui success icon message">
            <i class="check circle outline icon"></i>
            <i class="window close outline icon"></i>
            <div class="content">
            {% if successs|length > 1 %}
                <ul class="list">
                {% for success in successs %}
                    <li>{{ success|raw }}</li>
                {% endfor %}
                </ul>
            {% else %}
                {% for success in successs %}
                    <p>{{ success|raw }}</p>
                {% endfor %}
            {% endif %}
            </div>
        </div>
    </noscript>
{% endif %}

{# Renew telemetry #}
{% if renew_telemetry is defined and renew_telemetry %}
    {% include "modals/telemetry.html.twig" with {part: "dialog"} %}
    <noscript>
        <div class="ui info icon message" id="renewbox">
            <i class="info icon"></i>
            <div class="content">
                <div class="header">{{ _T("Your telemetry data are more than one year old.") }}</div>
                <p>{{ _T("Do you want to send it again?") }}</p>
                <a href="#" id="telemetry" class="ui large green button">{{ _T("Yes") }}</a>
                <a href="#" id="norenew" class="ui large red button">{{ _T("No") }}</a>
                <a href="#" id="renewlater" class="ui large blue button">{{ _T("Later") }}</a>
            </div>
        </div>
    </noscript>
{% endif %}
