#nullable enable
namespace ErsatzTV.Core.Api.Channels;

// Server-derived per-channel health. The SPA and MCP both read Status/Faults rather than deriving a
// verdict themselves (the api.channel-health-object decision, superseding #72's raw-fact-only stance).
// Faults are plain strings (see ChannelFault) not a C# enum, to keep the OpenAPI schema simple — the
// SPA hand-maintains its own union, matching the ChannelPreviewAvailability pattern.
public record ChannelHealthResponseModel(
    // One of ChannelHealthStatus's values.
    string Status,
    // The specific fault classes that fired (each a ChannelFault value); empty when Healthy/Unknown.
    string[] Faults,
    // Retained #72 fact: total playouts (mirror-aware).
    int PlayoutCount,
    // Count of upcoming built items pointing at a FileNotFound/Unavailable MediaItem; 0 when none.
    int BrokenSourceItemCount);

public static class ChannelHealthStatus
{
    public const string Healthy = "Healthy";
    public const string Problems = "Problems";
    public const string Unknown = "Unknown";
}

public static class ChannelFault
{
    public const string NoPlayout = "NoPlayout";
    public const string NeverBuilt = "NeverBuilt";
    public const string BuildFailed = "BuildFailed";
    public const string EmptyUpcoming = "EmptyUpcoming";
    public const string BrokenSource = "BrokenSource";
}

// Per-playout upcoming-item aggregate (Task 2's repository query fills this). Lives in Core so both
// the repository interface (Core) and Mapper (Application) can reference it.
public readonly record struct PlayoutUpcoming(int TotalUpcoming, int BrokenUpcoming);
