@php
    $activeConfigurator = $activeConfigurator ?? null;
    $switcherVariant = $switcherVariant ?? 'planner';
    $activeConfiguratorService = $configuratorServices->firstWhere('slug', $activeConfigurator);
    $activeConfiguratorMeta = $activeConfiguratorService
        ? \App\Support\ServiceConfigurator::meta($activeConfiguratorService)
        : null;
    $switcherMenuId = 'configurator-switcher-'.$switcherVariant.'-'.($activeConfigurator ?: 'selection');
@endphp

<nav class="configurator-switcher configurator-switcher--{{ $switcherVariant }}" aria-label="Fach-Planer auswählen" data-configurator-switcher>
    <div class="configurator-switcher-label">
        <span>Projektart</span>
        <strong>Was möchten Sie planen?</strong>
    </div>
    @if($activeConfiguratorMeta)
        <button class="configurator-switcher-toggle" type="button" aria-expanded="false" aria-controls="{{ $switcherMenuId }}" data-configurator-switcher-toggle>
            <i aria-hidden="true">@include('services.partials.visual-icon', ['icon' => $activeConfiguratorMeta['icon']])</i>
            <span><small>Gewählter Fach-Planer</small><strong>{{ $activeConfiguratorMeta['label'] }}</strong></span>
            <b><span>Planer wechseln</span><svg viewBox="0 0 20 20" aria-hidden="true"><path d="m5 7.5 5 5 5-5"/></svg></b>
        </button>
    @endif
    <div class="configurator-switcher-track" id="{{ $switcherMenuId }}" data-configurator-switcher-menu>
        @foreach($configuratorServices as $configuratorService)
            @php
                $meta = \App\Support\ServiceConfigurator::meta($configuratorService);
                $target = $configuratorService->slug === 'photovoltaik'
                    ? route('pv-configurator.create')
                    : route('service-configurator.create', $configuratorService);
                $isActive = $activeConfigurator === $configuratorService->slug;
            @endphp
            <a href="{{ $target }}" @if($isActive) aria-current="page" @endif data-configurator-choice="{{ $configuratorService->slug }}">
                <i aria-hidden="true">@include('services.partials.visual-icon', ['icon' => $meta['icon']])</i>
                <span><strong>{{ $meta['label'] }}</strong></span>
                <b aria-hidden="true">{{ $isActive ? '✓' : '→' }}</b>
            </a>
        @endforeach
    </div>
</nav>
