use serde::{Deserialize, Serialize};

use super::downbeats::DownbeatsState;

/// Response from the /api/gen/{clip_id}/key endpoint
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Key {
    /// State of the key detection: "running", "error", "complete", or "streaming"
    pub state: DownbeatsState,

    /// Error message if state is "error"
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_message: Option<String>,

    /// Whether this is the final result
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#final: Option<bool>,

    /// Detected musical key (e.g., "C_major", "A_minor", "Bb_minor")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub key: Option<String>,
}
