// Copyright (c) 2026 Gordon Bolton. MIT License. // Global state (using objects for mutability across modules) export const state = { currentUser: null, downloads: [], downloadClients: [], // List of download clients from server (for ordering/filtering) selectedDownloadClients: [], // Array of selected client IDs for multi-select filter isAdmin: false, showAll: false, csrfToken: null, // double-submit CSRF token, sent as X-CSRF-Token on mutating requests ombiBaseUrl: null, // Ombi base URL for generating links ombiRequests: null, // Ombi requests data // History section state historyDays: 7, // Default value, will be loaded from localStorage historyRefreshHandle: null, ignoreAvailable: false, // Default value, will be loaded from localStorage lastHistoryItems: [], // raw items from last fetch, for re-filtering without a network round-trip // SSE stream state sseSource: null, sseReconnectTimer: null, // Status panel state statusRefreshHandle: null, // Webhooks state webhookSectionExpanded: false, webhookLoading: false, sonarrWebhook: { enabled: false, triggers: { onGrab: false, onDownload: false, onImport: false, onUpgrade: false }, stats: null }, radarrWebhook: { enabled: false, triggers: { onGrab: false, onDownload: false, onImport: false, onUpgrade: false }, stats: null }, ombiWebhook: { enabled: false, triggers: { requestAvailable: false, requestApproved: false, requestDeclined: false, requestPending: false, requestProcessing: false }, stats: null }, webhookMetrics: null, // Request filter state selectedRequestTypes: ['movie', 'tv'], selectedRequestStatuses: [], requestSortMode: 'requestedDate_desc', requestSearchQuery: '' }; // Constants export const SPLASH_MIN_MS = 1200; // minimum splash display time export const HISTORY_REFRESH_MS = 5 * 60 * 1000; // auto-refresh history every 5 min export const SSE_RECONNECT_MS = 3000; // browser already retries, but we add explicit backoff too export const STATUS_REFRESH_MS = 5000;