@php
    $rawTabs = config('web.mypage_tabs', []);

    $items = collect($rawTabs)->map(function ($t) {
        $url = '#';
        if (!empty($t['route']) && \Illuminate\Support\Facades\Route::has($t['route'])) {
            $url = route($t['route']);
        }
        return [
            'label' => $t['label'] ?? '',
            'url'   => $url,
            'key'   => $t['key'] ?? null,
        ];
    })->values()->all();

    $activeKey = $activeKey ?? null;

    // activeKey가 없으면 현재 라우트로 자동 판별
    if (!$activeKey) {
        foreach ($rawTabs as $t) {
            if (!empty($t['route']) && request()->routeIs($t['route'])) {
                $activeKey = $t['key'] ?? null;
                break;
            }
        }
    }
@endphp

{{-- Mobile Tabs --}}
<div class="subpage-tabs">
    @include('web.partials.subpage-sidenav', [
        'items'  => $items,
        'active' => $activeKey,
        'mode'   => 'tabs'
    ])
</div>

{{-- Desktop Side --}}
<aside class="subpage-side" aria-label="마이페이지 메뉴">
    @include('web.partials.subpage-sidenav', [
        'items'  => $items,
        'active' => $activeKey,
        'mode'   => 'side'
    ])
</aside>
