use crate::parser::ast::Priority;

pub fn infer_priority(raw: &str) -> Priority {
    let s = raw.trim_start_matches('/');
    if s.is_empty() {
        return Priority::Low;
    }
    let has_underscore = s.contains('_');
    let has_dash = s.contains('-');
    let has_upper = s.chars().any(|c| c.is_ascii_uppercase());
    let is_all_upper = s.chars().all(|c| !c.is_ascii_lowercase()) && has_upper;
    if is_all_upper {
        return Priority::Max;
    }
    if has_underscore {
        return Priority::Lowest;
    }
    if has_dash {
        return Priority::Low;
    }
    if !has_upper {
        return Priority::Low;
    }
    let first = s.chars().next().unwrap();
    if first.is_ascii_uppercase() {
        return Priority::High;
    }
    Priority::Medium
}
