/**
 * How this installation sends email.
 *
 * Set up in Settings -> Email: a Gmail address with an app password, a Brevo
 * SMTP login with an SMTP key, or any SMTP server typed in by hand. The
 * password is never sent to the browser — the page is told whether one is
 * saved, and a blank field keeps it.
 */
export type MailEncryption = 'tls' | 'ssl' | 'none';

/** The presets the settings screen offers. */
export type MailProvider = 'gmail' | 'brevo' | 'manual';

export type MailSettings = {
    /** Which preset is in use. */
    mailer: MailProvider;
    /** Whether enough has been saved to send at all. */
    configured: boolean;
    /** A sentence describing the saved server, or that nothing is saved yet. */
    current: string;
    /** The mailer in use before any of this was saved, from the server's .env. */
    transport: string;
    host: string | null;
    port: number;
    encryption: MailEncryption;
    username: string | null;
    /** Whether a password is stored. Its value is never sent back. */
    has_password: boolean;
    from_address: string | null;
    from_name: string;
    defaults: {
        mailer: MailProvider;
        host: string;
        port: number;
        encryption: MailEncryption;
        username: string;
        from_address: string;
        from_name: string;
    };
};

export type MailPreset = {
    label: string;
    host: string;
    port: number;
    encryption: MailEncryption;
    description: string;
};

export type MailSettingsProps = {
    mail: MailSettings;
    presets: Record<MailProvider, MailPreset>;
    can: { manage: boolean };
};
