namespace NATS.Server.Mqtt;

/// <summary>
/// JetStream API helper context for MQTT account/session operations.
/// Go reference: mqtt.go mqttJSA.
/// </summary>
public sealed class MqttJsa
{
    public string AccountName { get; set; } = string.Empty;
    public string ReplyPrefix { get; set; } = string.Empty;
    public string? Domain { get; set; }
}

/// <summary>
/// MQTT JetStream publish request shape.
/// Go reference: mqtt.go mqttJSPubMsg.
/// </summary>
public sealed class MqttJsPubMsg
{
    public string Subject { get; set; } = string.Empty;
    public byte[] Payload { get; set; } = [];
    public string? ReplyTo { get; set; }
}

/// <summary>
/// Retained-message delete notification payload.
/// Go reference: mqtt.go mqttRetMsgDel.
/// </summary>
public sealed class MqttRetMsgDel
{
    public string Topic { get; set; } = string.Empty;
    public ulong Sequence { get; set; }
}

/// <summary>
/// Persisted MQTT session metadata.
/// Go reference: mqtt.go mqttPersistedSession.
/// </summary>
public sealed class MqttPersistedSession
{
    public string ClientId { get; set; } = string.Empty;
    public int LastPacketId { get; set; }
    public int MaxAckPending { get; set; }
}

/// <summary>
/// Reference to a retained message in storage.
/// Go reference: mqtt.go mqttRetainedMsgRef.
/// </summary>
public sealed class MqttRetainedMessageRef
{
    public ulong StreamSequence { get; set; }
    public string Subject { get; set; } = string.Empty;
}

/// <summary>
/// MQTT subscription metadata.
/// Go reference: mqtt.go mqttSub.
/// </summary>
public sealed class MqttSub
{
    public string Filter { get; set; } = string.Empty;
    public byte Qos { get; set; }
    public string? JsDur { get; set; }
    public bool Prm { get; set; }
    public bool Reserved { get; set; }
}

/// <summary>
/// Parsed MQTT filter metadata.
/// Go reference: mqtt.go mqttFilter.
/// </summary>
public sealed class MqttFilter
{
    public string Filter { get; set; } = string.Empty;
    public byte Qos { get; set; }
    public string? TopicToken { get; set; }
}

/// <summary>
/// Parsed NATS headers associated with an MQTT publish flow.
/// Go reference: mqtt.go mqttParsedPublishNATSHeader.
/// </summary>
public sealed class MqttParsedPublishNatsHeader
{
    public string? Subject { get; set; }
    public string? Mapped { get; set; }
    public bool IsPublish { get; set; }
    public bool IsPubRel { get; set; }
}
