@using QuantEngine.Web.Models

@model PaginationModel

@if (Model.TotalPages > 1)
{
    <nav aria-label="Page navigation">
        <ul class="pagination">
            @if (Model.Page > 1)
            {
                <li class="page-item">
                    <a class="page-link" href="@Model.BuildPageUrl(1)">첫 페이지</a>
                </li>
                <li class="page-item">
                    <a class="page-link" href="@Model.BuildPageUrl(Model.Page - 1)">이전</a>
                </li>
            }
            else
            {
                <li class="page-item disabled">
                    <span class="page-link">첫 페이지</span>
                </li>
                <li class="page-item disabled">
                    <span class="page-link">이전</span>
                </li>
            }

            @for (int i = Math.Max(1, Model.Page - 2); i <= Math.Min(Model.TotalPages, Model.Page + 2); i++)
            {
                if (i == Model.Page)
                {
                    <li class="page-item active">
                        <span class="page-link">@i</span>
                    </li>
                }
                else
                {
                    <li class="page-item">
                        <a class="page-link" href="@Model.BuildPageUrl(i)">@i</a>
                    </li>
                }
            }

            @if (Model.Page < Model.TotalPages)
            {
                <li class="page-item">
                    <a class="page-link" href="@Model.BuildPageUrl(Model.Page + 1)">다음</a>
                </li>
                <li class="page-item">
                    <a class="page-link" href="@Model.BuildPageUrl(Model.TotalPages)">마지막 페이지</a>
                </li>
            }
            else
            {
                <li class="page-item disabled">
                    <span class="page-link">다음</span>
                </li>
                <li class="page-item disabled">
                    <span class="page-link">마지막 페이지</span>
                </li>
            }
        </ul>
    </nav>
}
