{#
/**
 * @file
 * Theme override for account menu block.
 */
#}
{% set classes = [
  'block',
  'block-menu',
  'navigation',
  'menu--' ~ derivative_plugin_id|clean_class,
] %}
{% set heading_id = attributes.id ~ '-menu'|clean_id %}

{% if current_user.id %}
  <nav role="navigation"
       aria-labelledby="{{ heading_id }}"{{ attributes.addClass(classes)|without('role', 'aria-labelledby') }}>
    {# Label. If not displayed, we still provide it for screen readers. #}
    {% if not configuration.label_display %}
      {% set title_attributes = title_attributes.addClass('visually-hidden') %}
    {% endif %}
    {{ title_prefix }}
    <h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>
    {{ title_suffix }}

    {# Menu. #}
    {% block content %}
      <div class="dropdown">
        <button class="btn dropdown-toggle d-flex align-items-center gap-2" type="button" data-bs-toggle="dropdown"
                aria-expanded="false">
          {% if current_user.user_picture.value %}
            <div class="user-avatar rounded-circle">
              {{ drupal_field('user_picture', 'user', current_user.id, {
                type: 'image',
                settings: {
                  image_style: 'thumbnail'
                },
                label: 'hidden'
              }) }}
            </div>
          {% endif %}
          <span class="user-name">
            {% if current_user.field_first_name.value %}
              {{ current_user.field_first_name.value }}
              {% if current_user.field_last_name.value %}
                {{ current_user.field_last_name.value }}
              {% endif %}
            {% else %}
              {{ current_user.name.value }}
            {% endif %}
          </span>
        </button>
        <div class="dropdown-menu dropdown-menu-end">
          {{ content }}
        </div>
      </div>
    {% endblock %}
  </nav>
{% else %}
  <nav role="navigation"
       aria-labelledby="{{ heading_id }}"{{ attributes.addClass(classes)|without('role', 'aria-labelledby') }}>
    {% block content_anonymous %}
      {{ content }}
    {% endblock %}
  </nav>
{% endif %}
