from typing import Annotated, Literal, Union

from pydantic import BaseModel, Field


class ScenarioSettings(BaseModel, frozen=True):
    """Base class for scenario settings."""

    type: str


class PortfolioHoldingsScenarioOverride(BaseModel, frozen=True):
    """A single holding override within a scenario."""

    portfolio_id: str = Field(description="The portfolio to override.")
    asset_id: str = Field(description="The asset to override.")
    nav: float = Field(description="Absolute NAV override.")


class PortfolioHoldingsScenario(ScenarioSettings):
    """Scenario definition for portfolio holdings."""

    type: Literal["portfolio_holdings"] = "portfolio_holdings"

    overrides: list[PortfolioHoldingsScenarioOverride] = Field(
        description="The list of holding overrides to apply."
    )


# Discriminated union — extend this Union when new scenario types are added.
AnyScenarioSettings = Annotated[
    Union[PortfolioHoldingsScenario], Field(discriminator="type")
]
