{% load aa_forum_template_variables %}
{% load i18n %}

{% if page_obj.paginator.num_pages > 1 %}
    <div class="col-4 offset-4">
        {% set_template_variable category = board.category %}

        <nav aria-label="{% translate 'Message Pagination' %}">
            <ul class="pagination pagination-sm">
                {% if page_obj.has_previous %}
                    <li class="page-item">
                        <a href="{{ board.get_absolute_url }}" class="page-link">
                            {% translate "First" %}
                        </a>
                    </li>

                    <li class="page-item">
                        {% if page_obj.previous_page_number == 1 %}
                            <a href="{{ board.get_absolute_url }}" class="page-link">
                                {% translate "Previous" %}
                            </a>
                        {% else %}
                            <a href="{% url 'aa_forum:forum_board' category.slug board.slug page_obj.previous_page_number %}" class="page-link">
                                {% translate "Previous" %}
                            </a>
                        {% endif %}
                    </li>

                    <li>
                        {% if page_obj.previous_page_number == 1 %}
                            <a href="{{ board.get_absolute_url }}" class="page-link">
                                {{ page_obj.previous_page_number }}
                            </a>
                        {% else %}
                            <a href="{% url 'aa_forum:forum_board' category.slug board.slug page_obj.previous_page_number %}" class="page-link">
                                {{ page_obj.previous_page_number }}
                            </a>
                        {% endif %}
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link">{% translate "First" %}</span>
                    </li>

                    <li class="page-item disabled">
                        <span class="page-link">{% translate "Previous" %}</span>
                    </li>
                {% endif %}

                <li class="page-item active">
                    <span class="page-link">{{ page_obj.number }}</span>
                </li>

                {% if page_obj.has_next %}
                    <li class="page-item">
                        <a href="{% url 'aa_forum:forum_board' category.slug board.slug page_obj.next_page_number %}" class="page-link">
                            {{ page_obj.next_page_number }}
                        </a>
                    </li>

                    <li class="page-item ">
                        <a href="{% url 'aa_forum:forum_board' category.slug board.slug page_obj.next_page_number %}" class="page-link">
                            {% translate "Next" %}
                        </a>
                    </li>

                    <li class="page-item ">
                        <a href="{% url 'aa_forum:forum_board' category.slug board.slug page_obj.paginator.num_pages %}" class="page-link">
                            {% translate "Last" %}
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link">{% translate "Next" %}</span>
                    </li>

                    <li class="page-item disabled">
                        <span class="page-link">{% translate "Last" %}</span>
                    </li>
                {% endif %}
            </ul>
        </nav>
    </div>
{% endif %}
