namespace SVSim.Database.Services.Guild;

public sealed record ChatWindow(IReadOnlyList<Entities.Guild.GuildChatMessage> Messages, int WaitIntervalSeconds);
public sealed record ChatPostResult(bool Ok, int? AssignedMessageId);

public interface IGuildChatService
{
    Task<ChatWindow> GetWindowAsync(long viewerId, int startMessageId, int direction, int waitIntervalHint, CancellationToken ct = default);
    Task<ChatPostResult> PostTextOrStampAsync(long viewerId, int type, string message, CancellationToken ct = default);
    Task<ChatPostResult> PostDeckAsync(long viewerId, string deckPayloadJson, CancellationToken ct = default);
    Task<bool> DeleteDeckAsync(long viewerId, int messageId, CancellationToken ct = default);
    Task<ChatPostResult> PostReplayAsync(long viewerId, string replayPayloadJson, CancellationToken ct = default);
    Task<string?> GetReplayDetailAsync(long viewerId, int messageId, CancellationToken ct = default);
    Task<string?> GetDeckLogAsync(long viewerId, int messageId, CancellationToken ct = default);

    /// <summary>Emit a system-event row. Called by IGuildService at create/join/leave/remove/role-change/description-change.</summary>
    Task EmitSystemEventAsync(int guildId, long actorViewerId, Entities.Guild.GuildChatMessageType type, string? body = null, CancellationToken ct = default);
}
