using IntegryApiClient.Blazor;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor.Services;
using SteUp.Shared.Components;
using SteUp.Shared.Core.Interface;
using SteUp.Shared.Core.Services;
using SteUp.Web.Services;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Services.AddMudServices();
builder.Services.AddAuthorizationCore();

const string appToken = "4fef1843-793d-499b-a7ed-1edd8cac465c";
builder.Services.UseIntegry(appToken: appToken, useLoginAzienda: true);

builder.Services.AddScoped<IFormFactor, FormFactor>();

builder.Services.AddScoped<AppAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(provider => provider.GetRequiredService<AppAuthenticationStateProvider>());

builder.RootComponents.Add<Routes>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

var host = builder.Build();
await host.RunAsync();