using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor;
using MudBlazor.Services;
using NetinaShop.AdminPanel.PWA;
using NetinaShop.AdminPanel.PWA.Extensions;
using NetinaShop.AdminPanel.PWA.Services;
using NetinaShop.AdminPanel.PWA.Services.RestServices;
using NetinaShop.AdminPanel.PWA.Utilities;
using Toolbelt.Blazor.Extensions.DependencyInjection;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddOptions();
builder.Services.AddAuthorizationCore();
builder.Services.AddApiAuthorization();
builder.Services.AddScoped<AuthenticationStateProvider,
    CustomAuthenticationStateProvider>();
builder.Services.AddMudServices(config =>
{
    config.SnackbarConfiguration.VisibleStateDuration = 3500;
    config.SnackbarConfiguration.HideTransitionDuration = 200;
    config.SnackbarConfiguration.ShowTransitionDuration = 200;
    config.SnackbarConfiguration.SnackbarVariant = Variant.Filled;
    config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomCenter;
});

builder.Services.AddScoped<IRestWrapper, RestWrapper>();
builder.Services.AddScoped<IUserUtility, UserUtility>();
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped<Radzen.ContextMenuService>();
builder.Services.AddScoped<Radzen.DialogService>();
builder.Services.AddSingleton<IEncryptProvider, AesJsProvider>();
builder.Services.AddPWAUpdater();
await builder.Build().RunAsync();
