{% load i18n %}

{% if app_list %}
  {% for app in app_list %}
    <div class="app-{{ app.app_label }} module{% if app.app_url in request.path %} current-app{% endif %}">
      <table class="border border-spacing-none border-separate rounded-md shadow-sm text-gray-700 text-sm w-full dark:border-gray-800 {% if not forloop.last %}mb-8{% endif %}">
        <caption class="font-semibold mb-4 text-gray-700 text-left dark:text-gray-200">
          <a href="{{ app.app_url }}" class="section" title="{% blocktranslate with name=app.name %}Models in the {{ name }} application{% endblocktranslate %}">
              {{ app.name }}
          </a>
        </caption>

        {% for model in app.models %}
          <tr class="model-{{ model.object_name|lower }}{% if model.admin_url in request.path %} current-model{% endif %} {% cycle "bg-white dark:bg-gray-900" "bg-gray-50 dark:bg-gray-800" %}">
            {% if model.admin_url %}
              <th scope="row" class="font-normal p-3 text-left dark:text-gray-400 {% if not forloop.last %}border-b dark:border-gray-800{% endif %}">
                  <a href="{{ model.admin_url }}"{% if model.admin_url in request.path %} aria-current="page"{% endif %}>
                      {{ model.name }}
                  </a>
              </th>
            {% else %}
              <th scope="row" class="font-normal p-3 text-left dark:text-gray-400 {% if not forloop.last %}border-b dark:border-gray-800{% endif %}">
                  {{ model.name }}
              </th>
            {% endif %}

            {% if model.add_url %}
              <td class="{% if not forloop.last %}border-b dark:border-gray-800{% endif %} p-3 text-right">
                  <a href="{{ model.add_url }}" class="addlink text-gray-500 transition-all underline dark:text-gray-400 dark:hover:text-gray-200">
                      {% translate 'Add' %}
                  </a>
              </td>
            {% else %}
              <td class="{% if not forloop.last %}border-b dark:border-gray-800{% endif %} p-3 text-right"></td>
            {% endif %}

            {% if model.admin_url and show_changelinks %}
              {% if model.view_only %}
                <td class="{% if not forloop.last %}border-b dark:border-gray-800{% endif %} p-3 text-right">
                    <a href="{{ model.admin_url }}" class="viewlink text-gray-500 transition-all underline dark:text-gray-400 dark:hover:text-gray-200">
                        {% translate 'View' %}
                    </a>
                </td>
              {% else %}
                <td class="{% if not forloop.last %}border-b dark:border-gray-800{% endif %} p-3 text-right">
                    <a href="{{ model.admin_url }}" class="changelink text-gray-500 transition-all underline dark:text-gray-400 dark:hover:text-gray-200">
                        {% translate 'Change' %}
                    </a>
                </td>
              {% endif %}
            {% elif show_changelinks %}
              <td class="{% if not forloop.last %}border-b dark:border-gray-800{% endif %} p-3 text-right"></td>
            {% endif %}
          </tr>
        {% endfor %}
      </table>
    </div>
  {% endfor %}
{% else %}
  <p>{% translate 'You don’t have permission to view or edit anything.' %}</p>
{% endif %}
