{# parameters: item, mark, collection_member, collection_edit + parameters passing down: show_tags, hide_category #}
{% load thumb %}
{% load i18n %}
{% load l10n %}
{% load user_actions %}
{% load duration %}
<article class="entity-sort item-card"
         {% if collection_edit %}data-member-id="{{ collection_member.id }}"{% endif %}>
  <span class="action">
    {% if collection_edit %}
      <span>
        <a title="{% trans "Remove from collection" %}"
           hx-target="#collection_items"
           hx-post="{% url 'journal:collection_remove_item' collection.uuid item.uuid %}">
          <i class="fa-solid fa-square-minus"></i>
        </a>
      </span>
    {% elif request.user.is_authenticated %}
      {% wish_item_action item as action %}
      <span>
        {% if not action.taken %}
          <a title="{% trans "add mark" %}"
             hx-get="{% url 'journal:mark' item.uuid %}?shelf_type=wishlist"
             hx-target="body"
             hx-swap="beforeend">
            <i class="fa-regular fa-bookmark"></i>
          </a>
        {% else %}
          <a class="activated"
             title="{% trans "update mark" %}"
             hx-get="{% url 'journal:mark' item.uuid %}"
             hx-target="body"
             hx-swap="beforeend">
            <i class="fa-solid fa-bookmark"></i>
          </a>
        {% endif %}
      </span>
    {% endif %}
  </span>
  {% include "_item_card.html" with item=item %}
  {% if mark or collection_edit or collection_member.note %}
    <footer>
      {% if mark %}
        {% if mark.action_label %}
          <section>
            <div class="action">
              <span class="timestamp">{{ mark.created_time|date }}</span>
            </div>
            <div>
              {% comment %} <a href="{{mark.owner.url }}" title="@{{ mark.owner.handle }}">{{ mark.owner.display_name }}</a> {% endcomment %}
              <span>{{ mark.action_label }}</span>
              {% if mark.rating_grade %}{{ mark.rating_grade|rating_star }}{% endif %}
            </div>
            {% if mark.tags %}
              <div class="tag-list">
                {% for tag in mark.tags %}
                  {% if forloop.counter <= 5 %}
                    <span>
                      <a href="{% url 'catalog:search' %}?tag={{ tag }}">{{ tag }}</a>
                    </span>
                  {% endif %}
                {% endfor %}
              </div>
            {% endif %}
            <div>{{ mark.comment.html|safe }}</div>
          </section>
        {% endif %}
        {% if mark.review %}
          <section>
            <span class="action">
              <span class="timestamp">{{ mark.review.created_time|date }}</span>
            </span>
            <div class="tldr">
              {% trans "Review" %}
              <span>
                <a href="{% url 'journal:review_retrieve' mark.review.uuid %}">{{ mark.review.title }}</a>
              </span>
              -
              {{ mark.review.plain_content }}
            </div>
          </section>
        {% endif %}
      {% endif %}
      {% if collection_member %}
        <p hx-target="this" hx-swap="innerHTML">
          {% if collection_edit %}
            <span class="action">
              <a title="{% trans "Update note" %}"
                 hx-get="{% url 'journal:collection_update_item_note' collection.uuid item.uuid %}"><i class="fa-regular fa-pen-to-square"></i></a>
            </span>
          {% endif %}
          {% if collection_member.note %}{{ collection_member.note }}{% endif %}
        </p>
      {% endif %}
    </footer>
  {% endif %}
</article>
