using Microsoft.AspNetCore.Components.WebView.Maui;
using Microsoft.Extensions.Logging;
using VideoStudy.Native.Services;
using VideoStudy.Shared;
using VideoStudy.UI;

namespace VideoStudy.Native;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>();

        builder.Services.AddMauiBlazorWebView();

#if DEBUG
        builder.Services.AddBlazorWebViewDeveloperTools();
        builder.Logging.AddDebug();
        builder.Logging.SetMinimumLevel(LogLevel.Debug);
#endif

        // Configurar HttpClient para API Local (timeout longo para análise de vídeo)
        builder.Services.AddScoped(sp => new HttpClient
        {
            BaseAddress = new Uri("http://localhost:5000"),
            Timeout = TimeSpan.FromMinutes(10)
        });

        // PDF Saver (FileSavePicker do Windows)
        builder.Services.AddSingleton<IPdfSaver, WindowsPdfSaver>();

        return builder.Build();
    }
}
