<?php
$is_spa = isset($_SERVER['HTTP_X_SPA_REQUEST']) && $_SERVER['HTTP_X_SPA_REQUEST'] === 'true';
if ($is_spa) return;

// Versión única para invalidar recursos estáticos después de cada entrega.
$v = '9.1.1-ui-actions-settings-20260723';
?>
</div> 

<script src="https://accounts.google.com/gsi/client" async defer></script>

<script src="https://unpkg.com/lucide@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<script src="/assets/js/csrf.js?v=<?php echo $v; ?>"></script>
<script src="/assets/js/app.js?v=<?php echo $v; ?>"></script>
<script src="/assets/js/billing-bulk-actions.js?v=<?php echo $v; ?>"></script>

<script>
// =========================================================================
// ESCUCHAR TECLA ESCAPE PARA CERRAR MODALES GLOBALMENTE
// =========================================================================
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape' || e.keyCode === 27) {
        const modals = document.querySelectorAll('.product-modal-backdrop');
        for (let i = modals.length - 1; i >= 0; i--) {
            const modal = modals[i];
            
            if (window.getComputedStyle(modal).display !== 'none') {
                const activeLayer = modal.querySelector('.opp-view-layer.active');
                if (activeLayer && activeLayer.id !== 'layer-main' && typeof window.switchOppLayer === 'function') {
                    window.switchOppLayer('layer-main');
                    return; 
                }

                modal.dispatchEvent(new MouseEvent('click', {
                    bubbles: true,
                    cancelable: true,
                    view: window
                }));
                break; 
            }
        }
    }
});
</script>

</body>
</html>
