namespace MailPrint;

public class MailPrintOptions
{
    public int PollIntervalSeconds { get; set; } = 60;
    public string SubjectFilter { get; set; } = "";
    public bool DeleteAfterPrint { get; set; } = true;
    public bool MarkAsRead { get; set; } = true;
    public string SumatraPath { get; set; } = "";
    public string TempDirectory { get; set; } = Path.Combine(Path.GetTempPath(), "MailPrint");
    public List<string> AllowedExtensions { get; set; } = new() { ".pdf" };

    /// <summary>Drucker-Profile: Name → Drucker + Fach + Kopien</summary>
    public List<PrinterProfile> PrinterProfiles { get; set; } = new();

    /// <summary>Postfächer: jedes hat eigene Credentials + zeigt auf ein PrinterProfile</summary>
    public List<MailAccount> Accounts { get; set; } = new();

    /// <summary>Global – wird verwendet wenn das Profil keine eigene Liste hat.</summary>
    public List<string> AllowedSenders { get; set; } = new();
    public List<string> BlockedSenders { get; set; } = new();

    public WebApiOptions WebApi { get; set; } = new();

    /// <summary>Ordner-Überwachung: PDFs in diesen Ordnern werden automatisch gedruckt.</summary>
    public List<FolderWatcher> FolderWatchers { get; set; } = new();
}

public class PrinterProfile
{
    public string Name { get; set; } = "";
    public string PrinterName { get; set; } = "";
    public string PaperSource { get; set; } = "";
    public int Copies { get; set; } = 1;
    /// <summary>none | long | short</summary>
    public string Duplex { get; set; } = "none";
    public List<string> AllowedSenders { get; set; } = new();
    public List<string> BlockedSenders { get; set; } = new();
}

public class MailAccount
{
    public string Name { get; set; } = "";
    public string Protocol { get; set; } = "IMAP";
    public string Host { get; set; } = "";
    public int Port { get; set; } = 993;
    public bool UseSsl { get; set; } = true;
    public string Username { get; set; } = "";
    public string Password { get; set; } = "";
    public string Folder { get; set; } = "INBOX";
    /// <summary>Name eines PrinterProfile – leer = erstes Profil</summary>
    public string PrinterProfileName { get; set; } = "";
}

public class WebApiOptions
{
    public int Port { get; set; } = 5100;
    public bool BindAllInterfaces { get; set; } = false;
    public string ApiKey { get; set; } = "";
}

public class FolderWatcher
{
    public string Name { get; set; } = "";
    /// <summary>Zu überwachender Ordner (vollständiger Pfad)</summary>
    public string Path { get; set; } = "";
    /// <summary>Auch Unterordner überwachen</summary>
    public bool IncludeSubfolders { get; set; } = false;
    /// <summary>Datei nach erfolgreichem Druck löschen</summary>
    public bool DeleteAfterPrint { get; set; } = true;
    public string PrinterProfileName { get; set; } = "";
}
