#nullable enable

namespace ErsatzTV.Core.Api.Channels;

/// <summary>Server-declared browser-preview capability for a channel.</summary>
/// <remarks>
/// The SPA renders and acts on this; it never derives preview eligibility itself (see
/// docs/decisions.md, api.healthcheck-remediation-dto for the same pattern). Deriving it in the
/// SPA would mean keying behavior off the human-readable StreamingMode label.
/// </remarks>
public record ChannelPreviewResponseModel(
    // One of ChannelPreviewAvailability's values. A plain string (not a C# enum), which keeps the
    // OpenAPI schema simple, but the tradeoff is that the generated TypeScript types this as a bare
    // `string`, not a literal union — the SPA hand-maintains its own `ChannelPreviewAvailability`
    // union (web/src/api/channels.ts) and narrows against it, rather than getting one for free.
    string Availability,
    // Rooted, directly-usable HLS manifest URL; null when Availability is Unavailable.
    string? ManifestUrl,
    // Human-readable reason; non-null only when Availability is Unavailable.
    string? UnavailableReason);

public static class ChannelPreviewAvailability
{
    /// <summary>The channel's configured mode is browser-playable; preview exercises the real pipeline.</summary>
    public const string Available = "Available";

    /// <summary>Configured for Transport Stream; preview must force an HLS session and is content-only.</summary>
    public const string ForcedHlsOnly = "ForcedHlsOnly";

    /// <summary>Preview cannot run at all (IPTV JWT auth is enabled and the SPA cannot mint a token).</summary>
    public const string Unavailable = "Unavailable";
}
