{% load i18n %}
{% load navigation %}

{% if settings.RELEASE.features.help_center %}
  {# Help center control #}
  <a href="#" class="nav-link px-1" aria-label="{% trans "Help center" %}">
    <i class="mdi mdi-forum-outline"></i>
  </a>
{% endif %}

{% if request.user.is_authenticated %}
  {# Notifications #}
  {% with notifications=request.user.notifications.unread.exists %}
    <div class="dropdown">
      <button class="nav-link fs-2 p-0" data-bs-toggle="dropdown" hx-get="{% url 'extras:notifications' %}" hx-target="next .notifications" aria-label="{% trans "Notifications" %}">
        {% include 'inc/notification_bell.html' %}
      </button>
      <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow notifications"></div>
    </div>
  {% endwith %}

  {# User menu #}
  <div class="nav-item dropdown">
    <a href="#" class="nav-link d-flex lh-1 text-reset p-0" data-bs-toggle="dropdown" aria-label="Open user menu">
      <div class="d-xl-block ps-2">
        <div>{{ request.user }}</div>
        <div class="mt-1 small text-secondary">
          {% if request.user.is_superuser %}
            {% trans "Admin" %}
          {% else %}
            {% trans "User" %}
          {% endif %}
        </div>
      </div>
    </a>
    <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
      <a href="{% url 'account:profile' %}" class="dropdown-item">
        <i class="dropdown-item-icon mdi mdi-account"></i> {% trans "Profile" %}
      </a>
      <a href="{% url 'account:bookmarks' %}" class="dropdown-item">
        <i class="dropdown-item-icon mdi mdi-bookmark"></i> {% trans "Bookmarks" %}
      </a>
      <a href="{% url 'account:subscriptions' %}" class="dropdown-item">
        <i class="dropdown-item-icon mdi mdi-bell"></i> {% trans "Subscriptions" %}
      </a>
      <a href="{% url 'account:preferences' %}" class="dropdown-item">
        <i class="dropdown-item-icon mdi mdi-wrench"></i> {% trans "Preferences" %}
      </a>
      <a href="{% url 'account:usertoken_list' %}" class="dropdown-item">
        <i class="dropdown-item-icon mdi mdi-key"></i> {% trans "API Tokens" %}
      </a>
      <hr class="dropdown-divider" />
      <a href="{% url 'logout' %}" hx-disable="true" class="dropdown-item">
        <i class="dropdown-item-icon mdi mdi-logout-variant"></i> {% trans "Log Out" %}
      </a>
    </div>
  </div>
{% else %}
  <div class="btn-group align-items-center ps-2">
    <a class="btn btn-primary" type="button" href="{% url 'login' %}?next={{ request.path }}">
      <i class="mdi mdi-login-variant"></i> {% trans "Log In" %}
    </a>
  </div>
{% endif %}
