use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum AddonKind {
    ContentBlocker,
    Theme,
    Tool,
    Privacy,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AddonManifest {
    pub id: String,
    pub name: String,
    pub description: String,
    pub kind: AddonKind,
    pub enabled: bool,
    pub built_in: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AddonSettings {
    #[serde(default = "default_addons_enabled")]
    pub enabled: bool,
    #[serde(default = "planned_addons")]
    pub installed: Vec<AddonManifest>,
}

impl Default for AddonSettings {
    fn default() -> Self {
        Self {
            enabled: true,
            installed: planned_addons(),
        }
    }
}

fn default_addons_enabled() -> bool {
    true
}

fn planned_addons() -> Vec<AddonManifest> {
    vec![
        AddonManifest {
            id: "content-blocker-api".to_string(),
            name: "Content Blocker API".to_string(),
            description: "Reserved extension point for a full add-on ad blocker.".to_string(),
            kind: AddonKind::ContentBlocker,
            enabled: false,
            built_in: true,
        },
        AddonManifest {
            id: "theme-pack-api".to_string(),
            name: "Theme Pack API".to_string(),
            description: "Reserved extension point for installable browser themes.".to_string(),
            kind: AddonKind::Theme,
            enabled: false,
            built_in: true,
        },
    ]
}
