<?php

declare(strict_types=1);

/** @maestro-core-managed — reset via `php artisan core:install --force` */

/*
|--------------------------------------------------------------------------
| Public + SPA routes (required)
|--------------------------------------------------------------------------
|
| Public root route is loaded from routes/public.php (managed by CORE install).
| The route delegates to Maestro settings (`publicPage.rootMode`) so `/` can
| resolve to login, dashboard, or public homepage without per-project rewiring.
|
| Single global fallback so Maestro CORE API routes (/login, /api/*) match first and Vue
| deep links resolve through your Blade shell. Paths under `vendor/maestro/branding/*`
| must hit CORE static routes; **`/api/*`** must resolve to Laravel (session JSON + auth),
| not the SPA shell — otherwise GET/POST to `/api/...` can bind the catch‑all and return
| 405 / HTML for XHR. Do not register a second package-level `/{any?}` — precedence becomes
| host-dependent when duplicates exist.
|
*/

use Illuminate\Support\Facades\Route;

if (is_file(__DIR__.'/public.php')) {
    require __DIR__.'/public.php';
}

/*
|--------------------------------------------------------------------------
| Exclude packaged static branding from the SPA shell so GET /vendor/maestro/branding/*
| hits Maestro CORE routes registered in routes/core.php (see CoreBrandingAssetController).
|--------------------------------------------------------------------------
*/
Route::get('/{any?}', fn () => view('spa'))->where(
    'any',
    '^(?!vendor/maestro/branding/)(?!api(?:/|$)).*$',
);
