using Avalonia;
using Avalonia.Media;

namespace ClaudeDo.Ui.Services;

public static class AccentPresetService
{
    public static void Apply(AccentPreset preset)
    {
        if (Application.Current is not { } app) return;

        SetBrushColor(app, "AccentBrush",     preset.Accent);
        SetBrushColor(app, "AccentDimBrush",  preset.Dim);
        SetBrushColor(app, "AccentSoftBrush", preset.Soft);
        SetBrushColor(app, "AccentGlowBrush", preset.Glow);
        SetBrushColor(app, "MossBrush",       preset.Accent);
    }

    private static void SetBrushColor(Application app, string key, string hex)
    {
        if (app.TryGetResource(key, null, out var value) && value is SolidColorBrush brush)
            brush.Color = Color.Parse(hex);
    }
}
