"""Stimulation parameter domain model."""

from __future__ import annotations

from pydantic import BaseModel, ConfigDict

from radiens_core.models.enums import (
    StimPolarity,
    StimPulseMode,
    StimShape,
    StimTriggerEdge,
    StimTriggerLevel,
)


class StimParams(BaseModel):
    """Stimulation parameters for a single channel.

    All timing values are in seconds. Current amplitudes are in μA
    for amplifier channels and V for DAC channels.
    """

    model_config = ConfigDict(frozen=True)

    # --- Waveform shape ---
    stim_shape: StimShape
    stim_polarity: StimPolarity

    # --- Phase timing (seconds) ---
    first_phase_duration: float
    second_phase_duration: float
    interphase_delay: float

    # --- Amplitudes (μA for amp, V for DAC) ---
    first_phase_amplitude: float
    second_phase_amplitude: float
    baseline_voltage: float

    # --- Trigger ---
    trigger_edge_or_level: StimTriggerEdge
    trigger_high_or_low: StimTriggerLevel
    enabled: bool
    post_trigger_delay: float

    # --- Pulse train ---
    pulse_or_train: StimPulseMode
    number_of_stim_pulses: int
    pulse_train_period: float
    refractory_period: float

    # --- Amp settle ---
    pre_stim_amp_settle: float
    post_stim_amp_settle: float
    maintain_amp_settle: bool
    enable_amp_settle: bool

    # --- Charge recovery ---
    post_stim_charge_recov_on: float
    post_stim_charge_recov_off: float
    enable_charge_recovery: bool

    # --- Trigger source ---
    trigger_source_is_keypress: bool
    trigger_source_idx: int
    """AIN/DIN sysChanIdx, or keypress number."""

    # --- Channel identity ---
    stim_sys_chan_idx: int
    """System channel index (ntvAbsKeyIdx)."""
