@props([
    'items' => [],
    'ariaLabel' => null,
])

@php
    $ariaLabel = $ariaLabel ?? __('Navegação em trilha');
@endphp

<nav class="ma-breadcrumb" aria-label="{{ $ariaLabel }}">
    <ol {{ $attributes->merge(['class' => 'ma-breadcrumb__list']) }}>
        @foreach ($items as $index => $item)
            @php
                $isLast = $index === count($items) - 1;
                $url = $item['url'] ?? null;
                $label = $item['label'] ?? '';
            @endphp
            <li @class(['ma-breadcrumb__item', 'ma-breadcrumb__item--active' => $isLast])>
                @if (! $isLast && filled($url))
                    <a href="{{ $url }}" class="ma-breadcrumb__link">{{ $label }}</a>
                @else
                    <span @if ($isLast) aria-current="page" @endif>{{ $label }}</span>
                @endif
            </li>
        @endforeach
    </ol>
</nav>
