namespace NATS.Server.Configuration;

/// <summary>
/// Remote leaf node entry parsed from the remotes[] array inside a leafnodes {} block.
/// Go reference: opts.go RemoteLeafOpts struct.
/// </summary>
public sealed class RemoteLeafOptions
{
    /// <summary>Local account to bind this remote to.</summary>
    public string? LocalAccount { get; init; }

    /// <summary>Path to credentials file.</summary>
    public string? Credentials { get; init; }

    /// <summary>URLs for this remote entry.</summary>
    public List<string> Urls { get; init; } = [];

    /// <summary>Whether to not randomize URL order.</summary>
    public bool DontRandomize { get; init; }
}

public sealed class LeafNodeOptions
{
    public string Host { get; set; } = "0.0.0.0";
    public int Port { get; set; }

    // Auth for leaf listener
    public string? Username { get; set; }
    public string? Password { get; set; }
    public double AuthTimeout { get; set; }

    // Advertise address
    public string? Advertise { get; set; }

    // Per-subsystem write deadline
    public TimeSpan WriteDeadline { get; set; }

    /// <summary>
    /// Simple URL list for programmatic setup (tests, server-code wiring).
    /// Parsed config populates RemoteLeaves instead.
    /// </summary>
    public List<string> Remotes { get; set; } = [];

    /// <summary>
    /// Remote leaf node entries parsed from a config file (remotes: [] array).
    /// Each entry has a local account, credentials, and a list of URLs.
    /// </summary>
    public List<RemoteLeafOptions> RemoteLeaves { get; set; } = [];

    /// <summary>
    /// JetStream domain for this leaf node.
    /// Go reference: leafnode.go -- JsDomain in leafNodeCfg.
    /// </summary>
    public string? JetStreamDomain { get; set; }

    public List<string> DenyExports { get; set; } = [];
    public List<string> DenyImports { get; set; } = [];
    public List<string> ExportSubjects { get; set; } = [];
    public List<string> ImportSubjects { get; set; } = [];

    /// <summary>List of users for leaf listener authentication (from authorization.users).</summary>
    public List<NATS.Server.Auth.User>? Users { get; set; }
}
