{% load i18n %}
{% load evelinks %}

<li class="top-user-menu dropdown{% if request.user.profile.main_character %} with-main-character{% endif %}">
    <a href="#" class="dropdown-toggle" type="button" id="top-user-menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
        {% if request.user.profile.main_character %}
            {% with request.user.profile.main_character as main %}
                <img class="img-rounded ra-avatar" src="{{ main.character_id|character_portrait_url:32 }}" alt="{{ main.character_name }}">
            {% endwith %}
        {% else %}
            {% translate "Menu" %}
        {% endif %}
        <span class="caret"></span>
    </a>

    <ul class="dropdown-menu top-user-menu" aria-labelledby="top-user-menu">
        <!-- user avatar -->
        {% if request.user.profile.main_character %}
            <li class="user-main-character-avatar">
                {% with request.user.profile.main_character as main %}
                    <p class="text-center">
                        <img class="img-default ra-avatar" src="{{ main.character_id|character_portrait_url:256 }}" alt="{{ main.character_name }}">
                    </p>

                    <p class="text-center">
                        <span class="text-white text-primary" style="display: block; font-size: 1rem;">{{ main.character_name }}</span>
                        <span class="text-white text-primary" style="display: block; font-size: 1rem;">{{ main.corporation_name }}</span>

                        {% if main.alliance_name %}
                            <span class="text-white text-primary" style="display: block; font-size: 1rem;">{{ main.alliance_name }}</span>
                        {% endif %}
                    </p>
                {% endwith %}
            </li>
            <li role="separator" class="divider"></li>
        {% endif %}

        <li class="top-menu-bar-language-select">
            {% include 'public/lang_select.html' %}
        </li>

        <li role="separator" class="divider"></li>

        <!-- night mode toggle -->
        {% include 'allianceauth/night-toggle.html' %}

        <!-- tnnt related menu items -->
        {% include 'allianceauth/tnnt-menu-top.html' %}

        <!-- admin related menu items -->
        {% include 'allianceauth/top-menu-admin.html' %}

        <!-- logout / login -->
        <li role="separator" class="divider"></li>
        {% if user.is_authenticated %}
            <li><a href="{% url 'logout' %}">{% translate "Logout" %}</a></li>
        {% else %}
            <li><a href="{% url 'authentication:login' %}">{% translate "Login" %}</a></li>
        {% endif %}
    </ul>
</li>
