1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use colored::*;
use console::Term;
use indicatif::{ProgressBar, ProgressStyle};
use std::time::Duration;
use ratatui::style::Color;

pub const STARLIGHT: Color = Color::Rgb(255, 255, 240);
pub const NEBULA_PURPLE: Color = Color::Rgb(167, 132, 239);
pub const CELESTIAL_BLUE: Color = Color::Rgb(75, 115, 235);
pub const SOLAR_YELLOW: Color = Color::Rgb(255, 225, 100);
pub const AURORA_GREEN: Color = Color::Rgb(140, 255, 170);
pub const PLASMA_CYAN: Color = Color::Rgb(20, 255, 255);
pub const METEOR_RED: Color = Color::Rgb(255, 89, 70);
pub const GALAXY_PINK: Color = Color::Rgb(255, 162, 213);
pub const COMET_ORANGE: Color = Color::Rgb(255, 165, 0);
pub const BLACK_HOLE: Color = Color::Rgb(0, 0, 0);

pub fn create_spinner(message: &str) -> ProgressBar {
    let pb = ProgressBar::new_spinner();
    pb.set_style(
        ProgressStyle::default_spinner()
            .tick_chars("✦✧✶✷✸✹✺✻✼✽")
            .template("{spinner} {msg}")
            .unwrap(),
    );
    pb.set_message(message.to_string());
    pb.enable_steady_tick(Duration::from_millis(100));
    pb
}

pub fn print_info(message: &str) {
    println!("{}", message.cyan().bold());
}

pub fn print_warning(message: &str) {
    println!("{}", message.yellow().bold());
}

pub fn print_error(message: &str) {
    eprintln!("{}", message.red().bold());
}

pub fn print_success(message: &str) {
    println!("{}", message.green().bold());
}

pub fn print_version(version: &str) {
    println!(
        "{} {} {}",
        "🔮 Git-Iris".magenta().bold(),
        "version".cyan(),
        version.green()
    );
}

pub fn create_gradient_text(text: &str) -> String {
    let gradient = vec![
        (129, 0, 255), // Deep purple
        (134, 51, 255),
        (139, 102, 255),
        (144, 153, 255),
        (149, 204, 255), // Light cyan
    ];

    apply_gradient(text, &gradient)
}

pub fn create_secondary_gradient_text(text: &str) -> String {
    let gradient = vec![
        (75, 0, 130),   // Indigo
        (106, 90, 205), // Slate blue
        (138, 43, 226), // Blue violet
        (148, 0, 211),  // Dark violet
        (153, 50, 204), // Dark orchid
    ];

    apply_gradient(text, &gradient)
}

fn apply_gradient(text: &str, gradient: &[(u8, u8, u8)]) -> String {
    let chars: Vec<char> = text.chars().collect();
    let step = (gradient.len() - 1) as f32 / (chars.len() - 1) as f32;

    chars
        .iter()
        .enumerate()
        .map(|(i, &c)| {
            let index = (i as f32 * step) as usize;
            let (r, g, b) = gradient[index];
            format!("{}", c.to_string().truecolor(r, g, b))
        })
        .collect()
}

pub fn write_gradient_text(
    term: &mut Term,
    text: &str,
    gradient: &[(u8, u8, u8)],
) -> std::io::Result<()> {
    let gradient_text = apply_gradient(text, gradient);
    term.write_line(&gradient_text)
}

pub fn write_colored_text(term: &mut Term, text: &str, color: (u8, u8, u8)) -> std::io::Result<()> {
    let colored_text = text.truecolor(color.0, color.1, color.2);
    term.write_line(&colored_text)
}

pub fn write_bold_text(term: &mut Term, text: &str) -> std::io::Result<()> {
    term.write_line(&text.bold())
}