using System.Numerics;

namespace LightlessSync.UI.Tags;

public readonly record struct ProfileTagDefinition(
    string? Text,
    string? SeStringPayload = null,
    bool UseTextureSegments = false,
    Vector4? BackgroundColor = null,
    Vector4? BorderColor = null,
    Vector4? TextColor = null)
{
    public bool HasContent => !string.IsNullOrWhiteSpace(Text) || !string.IsNullOrWhiteSpace(SeStringPayload);
    public bool HasSeString => !string.IsNullOrWhiteSpace(SeStringPayload);

    public ProfileTagDefinition WithColors(Vector4? background, Vector4? border, Vector4? textColor = null)
        => this with { BackgroundColor = background, BorderColor = border, TextColor = textColor };

    public static ProfileTagDefinition FromText(string text, Vector4? background = null, Vector4? border = null, Vector4? textColor = null)
        => new(text, null, false, background, border, textColor);

    public static ProfileTagDefinition FromIcon(uint iconId, Vector4? background = null, Vector4? border = null)
        => new(null, $"<icon({iconId})>", true, background, border, null);

    public static ProfileTagDefinition FromIconAndText(uint iconId, string text, Vector4? background = null, Vector4? border = null, Vector4? textColor = null)
        => new(text, $"<icon({iconId})> {text}", true, background, border, textColor);

    public static ProfileTagDefinition FromSeString(string payload, Vector4? background = null, Vector4? border = null, Vector4? textColor = null)
        => new(null, payload, true, background, border, textColor);
}
