<?php
declare(strict_types=1);
// Generated exact public routes. Never resolve a filename supplied by a request.
$routes = [
    '/' => 'index.html',
    '/tarjetas-metalicas/' => 'tarjetas-metalicas/index.html',
    '/tarjetas-a-color/' => 'tarjetas-a-color/index.html',
    '/como-funciona/' => 'como-funciona/index.html',
    '/empresas/' => 'empresas/index.html',
    '/ayuda/' => 'ayuda/index.html',
    '/guias/' => 'guias/index.html',
    '/guias/grabado-o-color/' => 'guias/grabado-o-color/index.html',
    '/guias/disenar-tu-tarjeta/' => 'guias/disenar-tu-tarjeta/index.html',
    '/envios/' => 'envios/index.html',
    '/terminos/' => 'terminos/index.html',
    '/cambios/' => 'cambios/index.html',
    '/privacidad/' => 'privacidad/index.html',
    '/lanzamiento/' => 'lanzamiento/index.html',
    '/us/' => 'us/index.html',
    '/us/contact/' => 'us/contact/index.html',
    '/funciones/' => 'funciones/index.html',
    '/mini-crm/' => 'mini-crm/index.html',
    '/intercambio-de-contactos/' => 'intercambio-de-contactos/index.html',
    '/tarjeta-digital/' => 'tarjeta-digital/index.html',
    '/estadisticas/' => 'estadisticas/index.html',
    '/guias/seguimiento-de-contactos/' => 'guias/seguimiento-de-contactos/index.html',
    '/tarjetas-para-eventos/' => 'tarjetas-para-eventos/index.html',
    '/regalos-corporativos/' => 'regalos-corporativos/index.html',
    '/membresias-metalicas/' => 'membresias-metalicas/index.html',
    '/robots.txt' => 'robots.txt',
    '/llms.txt' => 'llms.txt',
    '/llms-full.txt' => 'llms-full.txt',
    '/agents.md' => 'agents.md',
    '/sitemap.xml' => 'sitemap.xml',
    '/comprar/' => 'comprar/index.html',
    '/estudio/' => 'estudio/index.html',
    '/estudio-color/' => 'estudio-color/index.html',
    '/.well-known/ai-plugin.json' => '.well-known/ai-plugin.json',
    '/.well-known/openapi.json' => '.well-known/openapi.json',
];
$dynamicRoutes = [
    '/disena/' => 'disena/index.php',
];
$path=explode('?',(string)($_SERVER['REQUEST_URI']??''),2)[0];
$method=$_SERVER['REQUEST_METHOD']??'';
if(!in_array($method,['GET','HEAD'],true)){http_response_code(405);header('Allow: GET, HEAD');exit;}
if(!isset($routes[$path])&&!isset($dynamicRoutes[$path])){http_response_code(404);exit;}
parse_str((string)($_SERVER['QUERY_STRING']??''),$query);
$privateQuery=false;
foreach(array_keys($query) as $key)if(str_starts_with((string)$key,'nova_')||str_starts_with((string)$key,'workshop_')||in_array($key,['rp','taller'],true)){$privateQuery=true;break;}
$root=realpath(__DIR__);
$file=realpath($root.'/'.($dynamicRoutes[$path]??$routes[$path]));
if($file===false||!str_starts_with($file,$root.DIRECTORY_SEPARATOR)||!is_file($file)){http_response_code(404);exit;}
$collect=static function(int $status)use($path):void{
    // Optional collection cannot replace the response; neither query nor fragment is stored.
    @ini_set('display_errors','0');
    try {
        $module='/home/u997145576/lsc-observability/current/core.php';
        if(is_file($module)){require_once $module;lscRadarLog($_SERVER,$path,$status,lscRadarDir());}
    } catch(Throwable $e) {error_log('[LSC radar] collection unavailable');}
};
if(isset($dynamicRoutes[$path])){
    // Execute the original handler. Keep its authentication, cookies, status and cache headers.
    if(!$privateQuery){
        header('X-LSC-Radar: 1');
        define('LSC_RADAR_ENTRY_OBSERVED',true);
        register_shutdown_function(static function()use($collect):void{
            $status=http_response_code();$collect(is_int($status)?$status:200);
        });
    }
    require $file;
    exit;
}
if($privateQuery){http_response_code(404);exit;}
$type=pathinfo($file,PATHINFO_EXTENSION);
$types=['html'=>'text/html; charset=UTF-8','txt'=>'text/plain; charset=UTF-8','md'=>'text/plain; charset=UTF-8','xml'=>'application/xml; charset=UTF-8','json'=>'application/json; charset=UTF-8'];
if(!isset($types[$type])){http_response_code(404);exit;}
$status=200;$body=null;
if(in_array($path,['/llms.txt','/llms-full.txt','/agents.md'],true)){
    try {
        @require_once '/home/u997145576/lsc-merchant/current/agent-context.php';
        $body=lscAgentRender($file);
    } catch(Throwable $e) {
        $status=503;http_response_code($status);header('Retry-After: 60');
        $body="Los precios vigentes no están disponibles temporalmente. Consulta https://luxurysteelcards.com/tarjetas-metalicas/ o vuelve a intentarlo.\n";
        error_log('[LSC agent documents] current price unavailable');
    }
}
header('Content-Type: '.$types[$type]);
header('Content-Length: '.($body===null?filesize($file):strlen($body)));
header('Cache-Control: private, no-store');
header('X-LiteSpeed-Cache-Control: no-cache');
header('X-LSC-Radar: 1');
if($method==='GET'){if($body===null)readfile($file);else echo $body;}
if(function_exists('litespeed_finish_request'))litespeed_finish_request();
elseif(function_exists('fastcgi_finish_request'))fastcgi_finish_request();
else {@ob_end_flush();@flush();}
$collect($status);
