"use strict";

import { tickStatus, tickPlayers, tickWhitelist, refreshWhitelistSoon } from "./modules/panels.js";
import { setupConsole } from "./modules/console.js";
import { setupAutocomplete } from "./modules/autocomplete.js";
import { setupWhitelistActions } from "./modules/whitelist.js";
import { setupServerControls } from "./modules/serverControls.js";
import { setupPregen } from "./modules/pregen.js";
import { setupAuth } from "./modules/auth.js";
import { setupUpdate } from "./modules/update.js";
import { setupDanger } from "./modules/danger.js";
import { setupBackup } from "./modules/backup.js";
import { setupModalTriggers } from "./modules/modal.js";
import { setupSettings } from "./modules/settings.js";
import { setupMap } from "./modules/map.js";

setupModalTriggers();
setupAuth();
setupConsole();
setupAutocomplete();
setupWhitelistActions(refreshWhitelistSoon);
setupServerControls();
setupPregen();
setupUpdate();
setupBackup();
setupDanger();
setupSettings();
setupMap();

// First paint
tickStatus();
tickPlayers();
tickWhitelist();

// Polling cadence:
//   status   3 s -- pid/uptime/pack version (cheap, doesn't change much)
//   players 10 s -- RCON `list` call; players join/leave infrequently
//   whitelist 30 s -- file read; mostly relies on refresh-on-action via add/remove
// (Logs are NOT polled -- they stream live via Server-Sent Events from /api/logs/stream.)
setInterval(tickStatus,    3000);
setInterval(tickPlayers,  10000);
setInterval(tickWhitelist, 30000);
