<?php
// If the apache HMR proxy drop-in installed by `npm run dev:enable-hmr` is not
// present, fall back to dist/index.html. `npm run dev:disable-hmr` removes the
// drop-in and so disables HMR even when /usr/local/nagiosxi/developer is set;
// Debian devs whose setup never landed are unblocked the same way.
if (!file_exists('/etc/httpd/conf.d/00-nagiosxi-vite-proxy.conf')
    && !file_exists('/etc/apache2/conf-enabled/00-nagiosxi-vite-proxy.conf')) {
    return;
}

header('Content-Type: text/html; charset=UTF-8');
$vite = '/nagiosxi/__vite';
echo <<<HTML
<!doctype html>
<html lang="en"><head><meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Nagios XI</title></head><body>
<div id="root"></div>
<script type="module">
import { injectIntoGlobalHook } from "{$vite}/@react-refresh";
injectIntoGlobalHook(window);
window.\$RefreshReg\$ = () => {};
window.\$RefreshSig\$ = () => (type) => type;
</script>
<script type="module" src="{$vite}/@vite/client"></script>
<script type="module" src="{$vite}/src/main.tsx"></script>
</body></html>
HTML;
exit;
