//! Core content types and enums

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ContentType {
    Blog,
    Page,
    Article,
    Documentation,
    Tutorial,
    Custom(String),
}

impl ContentType {
    pub fn as_str(&self) -> &str {
        match self {
            ContentType::Blog => "blog",
            ContentType::Page => "page",
            ContentType::Article => "article",
            ContentType::Documentation => "documentation",
            ContentType::Tutorial => "tutorial",
            ContentType::Custom(s) => s,
        }
    }
}

impl From<String> for ContentType {
    fn from(s: String) -> Self {
        match s.as_str() {
            "blog" => ContentType::Blog,
            "page" => ContentType::Page,
            "article" => ContentType::Article,
            "documentation" => ContentType::Documentation,
            "tutorial" => ContentType::Tutorial,
            _ => ContentType::Custom(s),
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ContentState {
    Draft,
    Published,
    Archived,
    Scheduled,
}

impl ContentState {
    pub fn as_str(&self) -> &str {
        match self {
            ContentState::Draft => "draft",
            ContentState::Published => "published",
            ContentState::Archived => "archived",
            ContentState::Scheduled => "scheduled",
        }
    }
}

impl From<String> for ContentState {
    fn from(s: String) -> Self {
        match s.as_str() {
            "draft" => ContentState::Draft,
            "published" => ContentState::Published,
            "archived" => ContentState::Archived,
            "scheduled" => ContentState::Scheduled,
            _ => ContentState::Draft,
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ContentFormat {
    Markdown,
    Html,
    PlainText,
}

impl ContentFormat {
    pub fn as_str(&self) -> &str {
        match self {
            ContentFormat::Markdown => "markdown",
            ContentFormat::Html => "html",
            ContentFormat::PlainText => "plaintext",
        }
    }
}

impl From<String> for ContentFormat {
    fn from(s: String) -> Self {
        match s.as_str() {
            "markdown" => ContentFormat::Markdown,
            "html" => ContentFormat::Html,
            "plaintext" => ContentFormat::PlainText,
            _ => ContentFormat::Markdown,
        }
    }
}

/// Result of slug resolution containing canonical ID and detected language
#[derive(Debug, Clone)]
pub struct SlugResolution {
    pub canonical_id: String,
    pub language: String,
    pub content_type: String,
}
