using VideoStudy.Desktop.Components;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents()
    .AddInteractiveWebAssemblyComponents();

// Add HttpClient for API communication
builder.Services.AddScoped(sp =>
    new HttpClient { BaseAddress = new Uri(builder.Configuration["ApiSettings:BaseUrl"] ?? "http://localhost:5000") }
);

// Register Services
builder.Services.AddSingleton<VideoStudy.Desktop.Services.FFmpegService>();
builder.Services.AddScoped<VideoStudy.Desktop.Services.YouTubeService>();
builder.Services.AddScoped<VideoStudy.Desktop.Services.TranscriptionService>();
builder.Services.AddScoped<VideoStudy.Desktop.Services.ScreenshotService>();
builder.Services.AddScoped<VideoStudy.Desktop.Services.PdfGeneratorService>();
builder.Services.AddSingleton<VideoStudy.Shared.Services.IHardwareIdService, VideoStudy.Shared.Services.HardwareIdService>();
builder.Services.AddScoped<VideoStudy.Desktop.Services.LicenseManager>();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseWebAssemblyDebugging();
}
else
{
    app.UseExceptionHandler("/Error", createScopeForErrors: true);
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();

app.UseStaticFiles();
app.UseAntiforgery();

app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode();
    // .AddInteractiveWebAssemblyRenderMode()
    // .AddAdditionalAssemblies(typeof(VideoStudy.Desktop.Client._Imports).Assembly);

app.Run();
