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

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

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