{% load i18n %}
{% load hk_generic %}
{% load cache %}
{% export_allowed as export_allowed %}

<!-- right column -->
<section id="thread-overview-info">
    <!-- Start stats re: dates -->
    <div id="thread-date-info" class="row">
      <div class="col">
        <span class="days-num">{{ days_inactive }}</span>
        <div class="days-text">
          {% trans 'Age (days ago)' %}
        </div>
      </div>
      <div class="col">
        <span class="days-num">{{ days_old }}</span>
        <div class="days-text">
          {% trans 'Last active (days ago)' %}
        </div>
        </div>
    </div> <!-- /Stats re: dates -->

    <p>
        <a href="{% url 'hk_list_overview' mlist_fqdn=mlist.name %}" class="btn btn-outline-primary btn-sm">
            {% trans 'List overview' %}
        </a>
    </p>

    {% if 'postorius' in INSTALLED_APPS  and user.is_authenticated%}
    <p class="postorius">
      <a class="btn btn-outline-primary btn-sm" href="{% url 'list_summary' mlist.list_id %}">
        <i class="fa fa-fw fa-inbox"></i>
        Manage subscription</a>
    </p>
    {% endif %}

    {% if export and export_allowed %}
    <a href="{{ export.url }}" title="{{ export.title }}"
          class="btn btn-outline-primary">
        <i class="fa fa-download"></i> {{ export.message }}</a>
    {% endif %}

    <p class="thread-overview-details">
    <div>
        <i class="fa fa-fw fa-comment"></i>
        {% blocktrans %}{{ num_comments }} comments{% endblocktrans %}
    </div>
    <div>
        <i class="fa fa-fw fa-user"></i>
        {% blocktrans with participants_count=thread.participants_count %}{{ participants_count }} participants{% endblocktrans %}
    </div>
    {% if user.is_authenticated %}
    <div>
        <i class="fa fa-fw fa-envelope"></i>
        {% blocktrans %}{{ unread_count }} unread <span class="hidden-sm">messages</span>{% endblocktrans %}
    </div>
    {% endif %}
    </p>

    <form id="fav_form" name="favorite" method="post" class="favorite"
          action="{% url 'hk_favorite' mlist_fqdn=mlist.name threadid=thread.thread_id %}">
        {% csrf_token %}
        <input type="hidden" name="action" value="{{ fav_action }}" />
        <p>
            <a href="#AddFav" class="notsaved{% if not user.is_authenticated %} disabled" title="{% trans 'You must be logged-in to have favorites.' %}{% endif %}">
                <i class="fa fa-fw fa-star"></i>{% trans "Add to favorites" %}</a>
            <a href="#RmFav" class="saved">
                <i class="fa fa-fw fa-star"></i>{% trans "Remove from favorites" %}</a>
        </p>
    </form>

    {% if user.is_staff or user.is_superuser or user_is_owner %}
    <div class="card border-danger">
        <div class="card-body">
            <div><i class="fa fa-fw fa-plug"></i>
               <a href="{% url 'hk_thread_reattach' mlist_fqdn=mlist.name threadid=thread.thread_id %}"
                  >{% trans "Reattach this thread" %}</a>
            </div>
            <div><i class="fa fa-fw fa-trash"></i>
               <a href="{% url 'hk_thread_delete' mlist_fqdn=mlist.name threadid=thread.thread_id %}"
                  >{% trans "Delete this thread" %}</a>
            </div>
        </div>
    </div>
    {% endif %}

    <div id="tags">
        {% include 'hyperkitty/threads/tags.html' %}
    </div>
    {% if user.is_authenticated %}
    <div id="add-tag">
        <form id="add-tag-form" name="addtag" method="post"
              action="{% url 'hk_tags' mlist_fqdn=mlist.name threadid=thread.thread_id %}"
              data-autocompleteurl="{% url 'hk_suggest_tags' mlist_fqdn=mlist.name threadid=thread.thread_id %}"
              >
            {% csrf_token %}
            {{ addtag_form.as_p }}
        </form>
    </div>
    {% endif %}
    {% cache 86400 thread_participants thread.id %}
    <div id="participants">
        <h3 id="participants_title">{% trans "participants" %} ({{ thread.participants_count }})</h3>
        <ul class="list-unstyled">
            {% for participant in thread.participants|sort_by_name %}
            <li class="d-flex">
                <div class="participant-gravatar circle">{% gravatar participant.address 48 %}</div>
                <div class="participant-name d-flex align-items-center">
                    <span>{{ participant.name|default:participant.address|escapeemail }}</span>
                </div>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endcache %}
</section>

{% if user.is_authenticated %}
<div id="unreadnavbar">
    <div>
    {% trans "Unreads:" %} <span class="unreadindex">0</span>/{{unread_count}}
    &nbsp;
    {% trans "Go to:" %} <a href="#" class="nextunread" title="hotkey: j">{% trans "next" %} &darr;</a>
         - <a href="#" class="prevunread" title="hotkey: k">{% trans "prev" %} &uarr;</a>
    </div>
</div>
{% endif %}
