/**
 * Scheduler Config — centralizes scheduling windows and material change thresholds.
 */

function readPositiveInt(name: string, fallback: number): number {
  const raw = Number(process.env[name]);
  if (!Number.isFinite(raw) || raw < 0) return fallback;
  return Math.floor(raw);
}

export const EU_LEAGUE_KEYS = ['epl', 'la_liga', 'bundesliga', 'serie_a', 'ligue_1', 'champions_league'] as const;
export const EU_LEAGUES = new Set<string>(EU_LEAGUE_KEYS);
export const isEuLeague = (lg: string) => EU_LEAGUES.has(lg.toLowerCase());

// Scheduling windows (minutes before starts_at)
export const EU_GENERATE_BEFORE_MIN = readPositiveInt('EU_GENERATE_BEFORE_MIN', 96 * 60); // T-96h default
export const EU_REFRESH_BEFORE_MIN = readPositiveInt('EU_REFRESH_BEFORE_MIN', 60);         // T-1h
export const US_MORNING_HOUR_ET = 7;        // 7:00 AM ET batch
export const US_MIDDAY_HOUR_ET = 14;        // 2:00 PM ET batch
export const PRE_EVENT_REFRESH_MIN = readPositiveInt('PRE_EVENT_REFRESH_MIN', 60);         // T-1h for all leagues
export const SCHEDULER_POLL_MS = 300_000;   // 5-minute polling

// Material change thresholds (tunable)
export const MATERIAL_THRESHOLDS = {
  spread_movement: 2.0,       // points
  total_movement: 3.0,        // points
  moneyline_movement: 50,     // American odds units
  confidence_shift: 0.10,     // 10 percentage points
};
