using System.IO;
using System.Windows;
using Noctalk.UI.Components.Confirmation;

namespace Noctalk.UI.Components.Chat;

public static class Chat__image_batch_policy
{
    public const long Warning_threshold_bytes = 10L * 1024L * 1024L;

    public static bool Confirm_if_large_image_batch(Window? The_owner, IReadOnlyList<string> The_image_paths)
    {
        long totalBytes = 0;
        foreach (string imagePath in The_image_paths)
        {
            if (File.Exists(imagePath))
            {
                totalBytes += new FileInfo(imagePath).Length;
            }
        }

        if (totalBytes <= Warning_threshold_bytes)
        {
            return true;
        }

        double totalMegabytes = totalBytes / 1024d / 1024d;
        return Noctalk_confirmation.Show(The_owner, "Large image batch", $"You are about to send {The_image_paths.Count} images ({totalMegabytes:0.0} MB). Continue?");
    }
}
