use serde::Deserialize;
use tailspin::config::*;
use tailspin::style::Style;

mod mappers;
pub mod reader;

#[derive(Debug)]
pub struct Theme {
    pub keywords: Vec<KeywordConfig>,
    pub regexes: Vec<RegexConfig>,
    pub numbers: NumberConfig,
    pub uuids: UuidConfig,
    pub quotes: QuoteConfig,
    pub ip_v4_addresses: IpV4Config,
    pub ip_v6_addresses: IpV6Config,
    pub dates: DateTimeConfig,
    pub paths: UnixPathConfig,
    pub urls: UrlConfig,
    pub emails: EmailConfig,
    pub pointers: PointerConfig,
    pub processes: UnixProcessConfig,
    pub key_value_pairs: KeyValueConfig,
    pub json: JsonConfig,
    pub jvm_stack_traces: JvmStackTraceConfig,
}

#[derive(Deserialize, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct TomlTheme {
    pub keywords: Option<Vec<KeywordToml>>,
    pub regexes: Option<Vec<RegexToml>>,
    pub numbers: Option<NumberToml>,
    pub uuids: Option<UuidToml>,
    pub quotes: Option<QuotesToml>,
    pub ip_addresses: Option<IpToml>,
    pub dates: Option<DateToml>,
    pub paths: Option<PathToml>,
    pub urls: Option<UrlToml>,
    pub emails: Option<EmailToml>,
    pub pointers: Option<PointerToml>,
    pub processes: Option<UnixProcessToml>,
    pub key_value_pairs: Option<KeyValueToml>,
    pub json: Option<JsonToml>,
    pub jvm_stack_traces: Option<JvmStackTraceToml>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct KeywordToml {
    pub words: Vec<String>,
    pub style: Style,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RegexToml {
    pub regex: String,
    pub style: Style,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct NumberToml {
    pub number: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct UuidToml {
    pub number: Option<Style>,
    pub letter: Option<Style>,
    pub separator: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct QuotesToml {
    pub quote_token: Option<char>,
    pub style: Option<Style>,
}

#[derive(Deserialize, Debug, Copy, Clone)]
#[serde(deny_unknown_fields)]
pub struct IpToml {
    pub number: Option<Style>,
    pub letter: Option<Style>,
    pub separator: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DateToml {
    pub date: Option<Style>,
    pub time: Option<Style>,
    pub zone: Option<Style>,
    pub separator: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct PathToml {
    pub segment: Option<Style>,
    pub separator: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct UrlToml {
    pub http: Option<Style>,
    pub https: Option<Style>,
    pub host: Option<Style>,
    pub path: Option<Style>,
    pub query_params_key: Option<Style>,
    pub query_params_value: Option<Style>,
    pub symbols: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct EmailToml {
    pub local_part: Option<Style>,
    pub at_sign: Option<Style>,
    pub domain: Option<Style>,
    pub dot: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct PointerToml {
    pub number: Option<Style>,
    pub letter: Option<Style>,
    pub x: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct UnixProcessToml {
    pub name: Option<Style>,
    pub id: Option<Style>,
    pub bracket: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct KeyValueToml {
    pub key: Option<Style>,
    pub separator: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct JsonToml {
    pub key: Option<Style>,
    pub quote_token: Option<Style>,
    pub curly_bracket: Option<Style>,
    pub square_bracket: Option<Style>,
    pub comma: Option<Style>,
    pub colon: Option<Style>,
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct JvmStackTraceToml {
    pub caused_by: Option<Style>,
    pub package: Option<Style>,
    pub exception: Option<Style>,
    pub frame: Option<Style>,
    pub file: Option<Style>,
    pub unknown_source: Option<Style>,
    pub line_number: Option<Style>,
}
