use std::sync::LazyLock;

/// Legacy: <user>uuid</user> or <user>username</user>
static USER_MENTION_RE: LazyLock<regex_lite::Regex, fn() -> regex_lite::Regex> =
    LazyLock::new(|| regex_lite::Regex::new(r"<user>\s*([^<]+?)\s*</user>").unwrap());

/// Legacy: <mention type="..." id="...">label</mention>
static MENTION_TAG_RE: LazyLock<regex_lite::Regex, fn() -> regex_lite::Regex> =
    LazyLock::new(|| {
        regex_lite::Regex::new(
            r#"<mention\s+type="([^"]+)"\s+id="([^"]+)"[^>]*>\s*([^<]*?)\s*</mention>"#,
        )
        .unwrap()
    });

/// New format: @[type:id:label]
static MENTION_BRACKET_RE: LazyLock<regex_lite::Regex, fn() -> regex_lite::Regex> =
    LazyLock::new(|| regex_lite::Regex::new(r"@\[([a-z]+):([^:\]]+):([^\]]+)\]").unwrap());

pub fn user_mention_re() -> &'static regex_lite::Regex {
    &USER_MENTION_RE
}

pub fn mention_tag_re() -> &'static regex_lite::Regex {
    &MENTION_TAG_RE
}

pub fn mention_bracket_re() -> &'static regex_lite::Regex {
    &MENTION_BRACKET_RE
}
