"""
Base classes and context dataclass for all calculators.
"""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any


@dataclass
class CalculationContext:
    """Context object holding all inputs for calculators."""

    team_pred: Any
    player_pred: Any
    odds_pred: Any
    referee_pred: Any
    upset_factors: Any

    weights: dict[str, float]
    player_mods: dict[str, float]
    referee_mods: dict[str, float]

    match_id: str
    home_team_name: str
    away_team_name: str

    odds_data: dict[str, float]
    home_xg: float
    away_xg: float
    total_xg: float

    league_id: str | None = None
    sport: str = "football"
    is_top_league: bool = False

    # Risk info (populated later)
    risk_level: str = "MEDIUM"
    is_surprise: bool = False

    # XGBoost Predictions (New)
    xgboost_preds: dict[str, Any] = field(default_factory=dict)


class BaseCalculator:
    """Base class for all market calculators."""

    def __init__(self, config: dict[str, Any]) -> None:
        self.config = config

    def calculate(self, ctx: CalculationContext) -> dict[str, Any]:
        raise NotImplementedError("Subclasses must implement calculate()")
