using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;

namespace ClaudeDo.Ui.Converters;

public sealed class CheckboxBorderConverter : IValueConverter
{
    public static readonly CheckboxBorderConverter Instance = new();

    private static readonly ISolidColorBrush Gray = new SolidColorBrush(Color.Parse("#475569"));
    private static readonly ISolidColorBrush Orange = new SolidColorBrush(Color.Parse("#e67e22"));
    private static readonly ISolidColorBrush Green = new SolidColorBrush(Color.Parse("#3d9474"));
    private static readonly ISolidColorBrush Red = new SolidColorBrush(Color.Parse("#ef4444"));

    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return value?.ToString()?.ToLowerInvariant() switch
        {
            "running" => Orange,
            "done" => Green,
            "failed" => Red,
            _ => Gray, // manual, queued
        };
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        => throw new NotSupportedException();
}
