"""Dashboard read-model contract + view-models. The web adapter depends on this protocol, not on the
concrete service, so the rendering layer stays decoupled from persistence."""
from __future__ import annotations

from dataclasses import dataclass
from typing import Protocol

from fxhnt.application.forward_models import ForwardNavRow
from fxhnt.application.periods import PeriodPoint


@dataclass(frozen=True, slots=True)
class FleetRow:
    strategy_id: str
    display_name: str
    sleeve: str
    days: int
    total_return_pct: float
    sharpe: float
    maxdd: float
    gate_status: str
    gate_reason: str
    as_of: str


@dataclass(frozen=True, slots=True)
class StrategyDetail:
    strategy_id: str
    display_name: str
    sleeve: str
    venue: str
    days: int
    total_return_pct: float
    sharpe: float
    maxdd: float
    gate_status: str
    gate_reason: str
    as_of: str
    history: list[ForwardNavRow]
    periods: dict[str, list[PeriodPoint]]   # raw per-period rolling means: keys "daily","weekly","monthly"


class DashboardReadModel(Protocol):
    def fleet(self) -> list[FleetRow]: ...
    def detail(self, strategy_id: str) -> StrategyDetail | None: ...
