{{--
    Seletor de registros por página (padrão Projetos e Programas).

    Variáveis:
      $project          → Project
      $filterParams     → query string persistida (sem tab/página da aba atual)
      $viewTab          → table|timeline|...
      $pageParam        → ap|tp|arp (paginação Laravel da aba)
      $perPageOptions   → list<int>
      $currentPerPage   → int
      $selectId         → id único do <select>
--}}
@php
    $hiddenParams = collect($filterParams ?? [])
        ->except(['tab', $pageParam ?? 'ap', 'per_page'])
        ->all();
@endphp

<form method="get"
      action="{{ route('admin.cronogramas.projetos.show', $project) }}"
      class="d-flex flex-wrap align-items-center gap-2 mb-0">
    <input type="hidden" name="tab" value="{{ $viewTab }}">
    @include('components.cronogramas.persist-query', ['params' => $hiddenParams])
    <label class="form-label small mb-0 text-muted" for="{{ $selectId }}">{{ __('Por página') }}:</label>
    <select name="per_page"
            id="{{ $selectId }}"
            class="form-select form-select-sm w-auto"
            onchange="this.form.submit()"
            aria-label="{{ __('Registros por página') }}">
        @foreach($perPageOptions as $option)
            <option value="{{ $option }}" @selected((int) ($currentPerPage ?? 20) === (int) $option)>{{ $option }}</option>
        @endforeach
    </select>
</form>
