@php /** @var array $items */ @endphp
@hook('store.menu.before', ['slug' => $slug])

<ul class="navbar-nav align-items-center">
    @foreach($items as $item)
        @php $hasChildren = ! empty($item['children']); @endphp
        @if($hasChildren)
            <li class="nav-item dropdown {{ $item['is_mega'] ? 'has-megamenu' : '' }}">
                <a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                    @if(! empty($item['icon']))<i class="{{ $item['icon'] }} me-1"></i>@endif
                    {{ $item['label'] }}
                </a>
                <ul class="dropdown-menu {{ $item['is_mega'] ? 'mega-cols-' . (int) $item['mega_columns'] : '' }}">
                    @foreach($item['children'] as $child)
                        <li>
                            <a class="dropdown-item d-flex align-items-center {{ request()->fullUrl() === url($child['url'] ?? '#') ? 'active' : '' }}"
                               href="{{ $child['url'] ?? '#' }}"
                               @if($child['target_blank']) target="_blank" rel="noopener" @endif>
                                @if(! empty($child['icon']))<i class="{{ $child['icon'] }} me-2"></i>@endif
                                {{ $child['label'] }}
                            </a>
                        </li>
                    @endforeach
                </ul>
            </li>
        @else
            <li class="nav-item">
                <a class="nav-link d-flex align-items-center {{ request()->fullUrl() === url($item['url'] ?? '#') ? 'active' : '' }}"
                   href="{{ $item['url'] ?? '#' }}"
                   @if($item['target_blank']) target="_blank" rel="noopener" @endif>
                    @if(! empty($item['icon']))<i class="{{ $item['icon'] }} me-1"></i>@endif
                    {{ $item['label'] }}
                </a>
            </li>
        @endif
    @endforeach
</ul>
@hook('store.menu.after', ['slug' => $slug])
