<?php
// Built-in server + index.php router: serve static assets before session/reff checks
if (PHP_SAPI === 'cli-server') {
    $assetPath = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH);
    if ($assetPath && preg_match('#^/(system/assets|fonts|images)(/|$)#', $assetPath)) {
        $file = __DIR__ . $assetPath;
        if (is_file($file)) {
            $mimes = [
                'js' => 'application/javascript',
                'css' => 'text/css',
                'woff' => 'font/woff',
                'woff2' => 'font/woff2',
                'ico' => 'image/x-icon',
                'png' => 'image/png',
                'jpg' => 'image/jpeg',
                'svg' => 'image/svg+xml',
            ];
            $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
            if (isset($mimes[$ext])) {
                header('Content-Type: ' . $mimes[$ext]);
            }
            readfile($file);
            exit;
        }
    }
}

require_once __DIR__ . '/system/core.php';

$router = require_once SYSTEM_PATH . '/route.php';
$router->dispatch();
