@props([
    'tabs' => [],
    'queryName' => 'status',
])

@php
    $current = (string) request()->query($queryName, '');
    $baseParams = request()->except([$queryName, 'page']);
@endphp

@if(count($tabs))
    <nav {{ $attributes->class(['mf-status-tabs']) }} aria-label="Quick status filters" data-ui="quick-status-tabs">
        @foreach($tabs as $tab)
            @php
                $value = (string) ($tab['value'] ?? '');
                $params = $baseParams;
                if ($value !== '') $params[$queryName] = $value;
                $url = url()->current().(count($params) ? '?'.http_build_query($params) : '');
            @endphp
            <a href="{{ $url }}" class="mf-status-tab {{ $current === $value ? 'is-active' : '' }}" @if($current === $value) aria-current="page" @endif>
                {{ $tab['label'] }}
                @if(isset($tab['count']))<span>{{ $tab['count'] }}</span>@endif
            </a>
        @endforeach
    </nav>
@endif
