using Spectre.Console;

namespace ZB.MOM.WW.Secrets.Cli.Interactive;

/// <summary>
/// One menu action of the interactive console. Implementations are UI-owning (they render to the
/// supplied <see cref="IAnsiConsole"/>) but store-logic-free — they operate through the seams on the
/// <see cref="SecretsSession"/> the shell hands them and never open stores or resolve keys themselves.
/// </summary>
public interface IInteractiveFlow
{
    /// <summary>The menu label shown for this flow in the shell's action list.</summary>
    string Title { get; }

    /// <summary>
    /// Whether the flow needs a decrypt/seal-capable session; the shell upgrades a degraded session
    /// (by prompting the operator for a KEK) before dispatch when this is <see langword="true"/>.
    /// </summary>
    bool RequiresKek { get; }

    /// <summary>Runs the flow against the current session, rendering its own UI to <paramref name="console"/>.</summary>
    /// <param name="console">The console the flow renders to (the shell owns lifecycle; flows only draw).</param>
    /// <param name="session">The open session — guaranteed KEK-capable when <see cref="RequiresKek"/> is <see langword="true"/>.</param>
    /// <param name="ct">A token to cancel the flow.</param>
    Task RunAsync(IAnsiConsole console, SecretsSession session, CancellationToken ct);
}
