namespace NATS.Server.JetStream.Storage;

// Go: server/store.go:376
/// <summary>
/// Pairs a consumer-sequence number with the corresponding stream-sequence number.
/// Both point to the same message. Mirrors Go's SequencePair struct.
/// </summary>
public record struct SequencePair(ulong Consumer, ulong Stream);

// Go: server/store.go:461
/// <summary>
/// Tracks a single pending (unacknowledged) message for an explicit-ack consumer.
/// Sequence is the original consumer delivery sequence; Timestamp is the Unix-nanosecond
/// wall clock at which the message was delivered.
/// Mirrors Go's Pending struct.
/// </summary>
public record struct Pending(ulong Sequence, long Timestamp);

// Go: server/store.go:382
/// <summary>
/// Complete durable state for a consumer, persisted by IConsumerStore.
/// Contains the high-water delivery and ack-floor marks, plus optional maps of
/// pending (unacknowledged) and redelivered messages.
/// Mirrors Go's ConsumerState struct.
/// </summary>
public sealed class ConsumerState
{
    // Go: ConsumerState.Delivered — highest consumer-seq and stream-seq delivered
    public SequencePair Delivered { get; set; }

    // Go: ConsumerState.AckFloor — highest consumer-seq and stream-seq fully acknowledged
    public SequencePair AckFloor { get; set; }

    // Go: ConsumerState.Pending — pending acks keyed by stream sequence; only present
    //     when AckPolicy is Explicit.
    public Dictionary<ulong, Pending>? Pending { get; set; }

    // Go: ConsumerState.Redelivered — redelivery counts keyed by stream sequence;
    //     only present when a message has been delivered more than once.
    public Dictionary<ulong, ulong>? Redelivered { get; set; }
}
