{% load i18n %}
{% load rules %}
{% load content_filters %}
<tr class="border-t border-gray-200 hover:bg-gray-100 text-gray-800">
    <td class="py-3 pl-4 pr-2">
        <input type="checkbox"
               name="selected_ids[]"
               value="{{ poi.id }}"
               form="bulk-action-form"
               class="bulk-select-item" />
    </td>
    <td class="pr-2">
        <a title="{% if poi_translation %} {{ poi_translation.title }}{% endif %}"
           href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}"
           class="block">
            {% if poi_translation %}
                {{ poi_translation.title|truncatechars:35 }}
            {% else %}
                <i>{% translate "Translation not available" %}</i>
            {% endif %}
        </a>
    </td>
    {% if backend_language and backend_language != language %}
        <td class="pr-2">
            <a title="{% if poi.backend_translation %} {{ poi.backend_translation.title }}{% endif %}"
               href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=LANGUAGE_CODE %}"
               class="block">
                {% if poi.backend_translation %}
                    {{ poi.backend_translation.title|truncatechars:35 }}
                {% else %}
                    <i>{% translate "Translation not available" %}</i>
                {% endif %}
            </a>
        </td>
    {% endif %}
    <td class="pr-2 lang-grid">
        {% spaceless %}
            {% for other_language, other_status in poi.translation_states.values %}
                <a href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=other_language.slug %}"
                   class="{{ other_language.slug }}">
                    <div id="translation-icon">
                        {% if other_status == translation_status.MACHINE_TRANSLATED %}
                            <span title="{% translate "Machine translated" %}">
                                <i icon-name="bot"
                                   class="{% if other_language.slug == language.slug %}text-violet-500{% else %}text-gray-800{% endif %}"></i>
                            </span>
                        {% elif other_status == translation_status.IN_TRANSLATION %}
                            <span title="{% translate "Currently in translation" %}">
                                <i icon-name="clock"
                                   class="{% if other_language.slug == language.slug %}text-blue-500{% else %}text-gray-800{% endif %}"></i>
                            </span>
                        {% elif other_status == translation_status.OUTDATED %}
                            <span title="{% translate "Translation outdated" %}">
                                <i icon-name="alert-triangle"
                                   class="{% if other_language.slug == language.slug %}text-yellow-500{% else %}text-gray-800{% endif %}"></i>
                            </span>
                        {% elif other_status == translation_status.UP_TO_DATE %}
                            <span title="{% translate "Translation up-to-date" %}">
                                <i icon-name="check"
                                   class="{% if other_language.slug == language.slug %}text-green-500{% else %}text-gray-800{% endif %}"></i>
                            </span>
                        {% elif other_status == translation_status.FALLBACK %}
                            <span title="{% translate "Default language is duplicated" %}">
                                <i icon-name="copy"
                                   class="{% if other_language.slug == language.slug %}text-blue-500{% else %}text-gray-800{% endif %}"></i>
                            </span>
                        {% elif other_status == translation_status.MISSING %}
                            <span title="{% translate "Translation missing" %}" class="no-trans">
                                <i icon-name="x"
                                   class="{% if other_language.slug == language.slug %}text-red-500{% else %}text-gray-800{% endif %}"></i>
                            </span>
                        {% endif %}
                    </div>
                    <div id="ajax-icon" class="hidden">
                        <span title="{% translate "Currently in translation" %}">
                            <i icon-name="clock"
                               class="{% if other_language.slug == language.slug %}text-blue-500{% else %}text-gray-800{% endif %}"></i>
                        </span>
                    </div>
                </a>
            {% endfor %}
        {% endspaceless %}
    </td>
    <td class="pr-2">
        <a href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}"
           class="block">
            {{ poi_translation.get_status_display }}
        </a>
    </td>
    <td class="pr-2">
        <a href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}"
           class="block">
            {{ poi.address }}
        </a>
    </td>
    <td class="pr-2">
        <a href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}"
           class="block">
            {{ poi.postcode }}
        </a>
    </td>
    <td class="pr-2">
        <a href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}"
           class="block">
            {{ poi.city }}
        </a>
    </td>
    <td class="pr-2">
        <a href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}"
           class="block">
            {{ poi.country }}
        </a>
    </td>
    <td class="pr-2">
        <a href="{% url 'edit_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}"
           class="block">
            {% translate "No category assigned" as no_category_text %}
            {% firstof poi.category no_category_text %}
        </a>
    </td>
    <td class="pl-2 pr-4 py-3 min text-right flex flex-nowrap gap-2">
        {% if poi_translation.status == PUBLIC %}
            <a href="{{ WEBAPP_URL }}{{ poi_translation.get_absolute_url }}"
               rel="noopener noreferrer"
               target="_blank"
               title="{% translate "Open location in web app" %}"
               class="btn-icon">
                <i icon-name="external-link"></i>
            </a>
        {% else %}
            <button title="{% translate "This location cannot be opened in the web app, because it is not public." %}"
                    class="btn-icon"
                    disabled>
                <i icon-name="external-link"></i>
            </button>
        {% endif %}
        {% if perms.cms.change_poi %}
            <button title="{% translate "Archive location" %}"
                    class="confirmation-button btn-icon"
                    data-confirmation-title="{{ archive_dialog_title }}"
                    data-confirmation-text="{{ archive_dialog_text }}"
                    data-confirmation-subject="{{ poi_translation.title }}"
                    data-action="{% url 'archive_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}">
                <i icon-name="archive"></i>
            </button>
        {% endif %}
        {% if perms.cms.delete_poi %}
            {% if poi.events.exists %}
                {# djlint:off H023 #}
                <button title="{% translate "You cannot delete a location which is used by an event." %}&#013;{% translate "This also involves archived events." %}"
                        class="btn-icon"
                        disabled>
                    <i icon-name="trash-2"></i>
                </button>
                {# djlint:on #}
            {% else %}
                <button title="{% translate "Delete location" %}"
                        class="confirmation-button btn-icon"
                        data-confirmation-title="{{ delete_dialog_title }}"
                        data-confirmation-text="{{ delete_dialog_text }}"
                        data-confirmation-subject="{{ poi_translation.title }}"
                        data-action="{% url 'delete_poi' poi_id=poi.id region_slug=request.region.slug language_slug=language.slug %}">
                    <i icon-name="trash-2"></i>
                </button>
            {% endif %}
        {% endif %}
    </td>
</tr>
