<div>
  <nav class="inline-flex -space-x-px h-7">
    [% prev_page = pager.page - 1 %]
    [% IF prev_page <= 0 %]
      [% prev_page = 1 %]
    [% END %]
    <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem]" href="[% uri_with(c, 'page' => prev_page) %]"><i class="uil uil-angle-left text-lg contents"></i></a>
    [% IF pager.total_pages <= 13 %]
      [% page  = 1 %]
      [% WHILE page <= pager.total_pages %]
        [% class = "" %]
        [% IF page == pager.page %]
          [% class = " textActive2" %]
        [% ELSE %]
          [% class = " small-pager" %]
        [% END %]
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem][% class %]" href="[% uri_with(c, 'page' => page) %]">[% page %]</a>
        [% page  = page + 1 %]
      [% END %]
    [% ELSE %]
      [% IF pager.page < 8 %]
        [% page  = 1 %]
        [% WHILE page < 10 %]
          [% class = "" %]
          [% IF page == pager.page %]
            [% class = " textActive2" %]
          [% ELSE %]
            [% class = " small-pager" %]
          [% END %]
          <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem][% class %]" href="[% uri_with(c, 'page' => page) %]">[% page %]</a>
          [% page  = page + 1 %]
        [% END %]
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] bg-transparent cursor-default small-pager">...</a>
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] small-pager" href="[% uri_with(c, 'page' => pager.total_pages) %]">[% pager.total_pages %]</a>
      [% ELSIF pager.page > pager.total_pages - 8 %]
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] small-pager" href="[% uri_with(c, page => 1) %]">1</a>
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] bg-transparent cursor-default small-pager">...</a>
        [% page  = pager.total_pages - 8 %]
        [% WHILE page <= pager.total_pages %]
          [% class = "" %]
          [% IF page == pager.page %]
            [% class = " textActive2" %]
          [% ELSE %]
            [% class = " small-pager" %]
          [% END %]
          <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem][% class %]" href="[% uri_with(c, 'page' => page) %]">[% page %]</a>
          [% page  = page + 1 %]
        [% END %]
      [% ELSE %]
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] small-pager" href="[% uri_with(c, page => 1) %]">1</a>
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] bg-transparent cursor-default small-pager">...</a>
        [% page  = pager.page - 3 %]
        [% endpage = pager.page + 3 %]
        [% WHILE page <= endpage %]
          [% class = "" %]
          [% IF page == pager.page %]
            [% class = " textActive2" %]
          [% ELSE %]
            [% class = " small-pager" %]
          [% END %]
          <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem][% class %]" href="[% uri_with(c, 'page' => page) %]">[% page %]</a>
          [% page  = page + 1 %]
        [% END %]
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] bg-transparent cursor-default small-pager">...</a>
        <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem] small-pager" href="[% uri_with(c, 'page' => pager.total_pages) %]">[% pager.total_pages %]</a>
      [% END %]
    [% END %]

    [% next_page = pager.page + 1 %]
    [% IF next_page > pager.total_pages %]
      [% next_page = pager.total_pages %]
    [% END %]
    <a class="pager rounded-md inline-flex items-center font-medium justify-center px-1.5 min-w-[2rem]" href="[% uri_with(c, 'page' => next_page) %]"><i class="uil uil-angle-right text-lg contents"></i></a>
  </nav>
</div>
