@props([
    'ancestors' => [],
    'pageTitle',
    'pageIcon' => 'fe fe-home',
])

@php
    $sep = '/';
@endphp

<nav class="erp-context-trail" aria-label="{{ __('common.breadcrumb') }}">
    <ol class="erp-context-trail__list">
        @foreach ($ancestors as $item)
            @php
                $label = $item['label'] ?? '';
                $url = $item['url'] ?? null;
            @endphp
            @if (! $loop->first)
                <li class="erp-context-trail__sep" aria-hidden="true">{{ $sep }}</li>
            @endif
            <li class="erp-context-trail__item">
                @if ($url)
                    <a href="{{ $url }}" class="erp-context-trail__link">{{ $label }}</a>
                @else
                    <span class="erp-context-trail__ancestor">{{ $label }}</span>
                @endif
            </li>
        @endforeach

        @if (count($ancestors))
            <li class="erp-context-trail__sep" aria-hidden="true">{{ $sep }}</li>
        @endif

        <li class="erp-context-trail__item erp-context-trail__item--current" aria-current="page">
            <span class="erp-context-trail__current">
                <i class="{{ $pageIcon }}" aria-hidden="true"></i>
                <span class="erp-context-trail__current-text">{{ $pageTitle }}</span>
            </span>
        </li>
    </ol>
</nav>
