{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2015-2021 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}


{%- if config.ACCOUNTS %}
    {%- if not current_user.is_authenticated %}
        <form>
            <a href="{{ url_for_security('login', next=request.path) }}"
               class="ui button">
                <i class="sign-in icon"></i>
                {{ _('Log in') }}</a>
            {% if security.registerable %}
                <a href="{{ url_for_security('register') }}" class="ui button signup">
                    <i class="edit outline icon"></i>
                    {{ _('Sign up') }}
                </a>
            {% endif %}
        </form>
    {%- else %}

        {# Quick-create ("plus") menu #}
        {%- set plus_menu_items = current_menu.submenu('plus').children %}
        {%- if plus_menu_items %}
            <div class="rdm-plus-menu rdm-plus-menu-responsive ui dropdown floating pr-15">
                <i class="fitted plus icon inverted"></i>
                <i class="fitted dropdown icon inverted"></i>
                <div class="menu">
                    {%- for item in plus_menu_items if item.visible %}
                        <a class="item"
                           style="color:black;"
                           href="{{ item.url }}">{{ item.text|safe }}
                        </a>
                    {%- endfor %}
                </div>
            </div>
        {% endif %}

        {%- if config.USERPROFILES %}
            <div class="ui buttons user-profile">
                <a class="ui button"
                   href="{{ url_for('invenio_userprofiles.profile') }}">
                    <i class="user icon"></i> {{ current_user.email|truncate(31,true) }}
                </a>

                <div class="ui dropdown icon button floating">
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        {%- for item in current_menu.submenu('settings').children if item.visible %}
                            <a class="item"
                               style="color:black;"
                               href="{{ item.url }}">{{ item.text|safe }}
                            </a>

                        {%- endfor %}
                        <div class="divider"></div>
                        <a class="item" style="color:black;" href="{{ url_for_security('logout') }}">
                            <i class="sign-out icon"></i>
                            {{ _('Log out') }}
                        </a>
                    </div>
                </div>
            </div>

        {%- else %}
            <a href=" {{ url_for_security('logout') }}" class="ui button"><i
                    class="sign-out icon"></i> {{ _('Log out') }}</a>
        {%- endif %}
    {%- endif %}
{%- endif %}
