{% trans_default_domain 'admin' %}

{% if app.user %}
    <span hidden data-current-user-fullname>{{ app.user.firstname ~ ' ' ~ app.user.lastname }}</span>
    <span hidden data-current-user-lastname>{{ app.user.lastname }}</span>
    <span hidden data-current-user-initials>{{ (app.user.firstname|first ~ app.user.lastname|first)|upper }}</span>
    <span hidden data-current-user-email>{{ app.user.email }}</span>

    <div class="flex-shrink-0 relative">

        <twig:Admin:Dropdown>
            <twig:block name="toggle">
                <button class="group max-w-xs flex items-center px-2 py-1.5 space-x-1 text-sm rounded-md focus:outline-none focus:shadow-outline bg-gray-100 dark:bg-gray-900/50 hover:bg-gray-200 dark:hover:bg-gray-900/80">
                    <span class="inline-flex items-center justify-center h-6 w-6 rounded-full bg-gray-400 dark:bg-gray-600">
                        <span class="text-xs font-medium leading-none text-white dark:text-gray-200">{{ app.user.firstname|first|upper ~ app.user.lastname|first|upper }}</span>
                    </span>
                    <span class="text-left">
                        <span class="block text-gray-900 dark:text-gray-100 font-medium"><span data-current-user-firstname>{{ app.user.firstname }}</span> {{ app.user.lastname }}</span>
                    </span>
                    <span class="text-gray-400 group-hover:text-gray-500 w-4 h-4">
                        <twig:ux:icon name="ph:caret-down" />
                    </span>
                </button>
            </twig:block>

            <twig:block name="dropdown">
                {% set menu = knp_menu_get('host_user_navigation') %}
                {% for item in menu.children %}
                    {% if item.current %}
                        <twig:Admin:DropdownHeading>
                            {% trans_default_domain 'admin' %}
                            <span class="mr-1.5 size-4">{{ item.extra('icon') ? ux_icon('ph:'~item.extra('icon')) }}</span>
                            <span>{{ item.label|trans }}</span>
                        </twig:Admin:DropdownHeading>
                    {% else %}
                        {% set itemAttrs = item.linkAttributes|default([]) %}
                        <twig:Admin:DropdownItem 
                            href="{{ item.uri }}" 
                            :attributes="itemAttrs"
                            :method="item.extra('method', 'get')"
                        >
                            {% trans_default_domain 'admin' %}
                            <span class="mr-1.5 size-4">{{ item.extra('icon') ? ux_icon('ph:'~item.extra('icon')) }}</span>
                            <span>{{ item.label|trans }}</span>
                        </twig:Admin:DropdownItem>
                    {% endif %}
                {% endfor %}
            </twig:block>
        </twig:Admin:Dropdown>

    </div>
{% endif %}
