namespace StellaOps.Feedser.Source.Vndr.Chromium.Configuration;

public sealed class ChromiumOptions
{
    public const string HttpClientName = "source-vndr-chromium";

    public Uri FeedUri { get; set; } = new("https://chromereleases.googleblog.com/atom.xml");

    public TimeSpan InitialBackfill { get; set; } = TimeSpan.FromDays(30);

    public TimeSpan WindowOverlap { get; set; } = TimeSpan.FromDays(2);

    public int MaxFeedPages { get; set; } = 4;

    public int MaxEntriesPerPage { get; set; } = 50;

    public void Validate()
    {
        if (FeedUri is null || !FeedUri.IsAbsoluteUri)
        {
            throw new ArgumentException("FeedUri must be an absolute URI.", nameof(FeedUri));
        }

        if (InitialBackfill <= TimeSpan.Zero)
        {
            throw new ArgumentException("InitialBackfill must be positive.", nameof(InitialBackfill));
        }

        if (WindowOverlap < TimeSpan.Zero)
        {
            throw new ArgumentException("WindowOverlap cannot be negative.", nameof(WindowOverlap));
        }

        if (MaxFeedPages <= 0)
        {
            throw new ArgumentException("MaxFeedPages must be positive.", nameof(MaxFeedPages));
        }

        if (MaxEntriesPerPage <= 0 || MaxEntriesPerPage > 100)
        {
            throw new ArgumentException("MaxEntriesPerPage must be between 1 and 100.", nameof(MaxEntriesPerPage));
        }
    }
}
