@props(['items' => [], 'variant' => 'default', 'class' => ''])

@if (count($items))
    <nav aria-label="breadcrumb" @class(['mb-2' => $variant === 'default', 'erp-context-breadcrumb mb-0' => $variant === 'context', $class])>
        <ol class="breadcrumb mb-0 {{ $variant === 'context' ? 'erp-context-breadcrumb__list' : '' }}">
            @foreach ($items as $i => $item)
                @php
                    $label = $item['label'] ?? '';
                    $url = $item['url'] ?? null;
                    $isLast = $i === count($items) - 1;
                @endphp

                <li @class(['breadcrumb-item', 'active' => $isLast])
                    @if ($isLast) aria-current="page" @endif>
                    @if ($url && ! $isLast)
                        <a href="{{ $url }}">{{ $label }}</a>
                    @else
                        {{ $label }}
                    @endif
                </li>
            @endforeach
        </ol>
    </nav>
@endif
