using CommunityToolkit.Maui;
using IntegryApiClient.MAUI;
using Microsoft.Extensions.Logging;
using MudBlazor.Services;
using MudExtensions.Services;
using SteUp.Maui.Core;
using SteUp.Shared;

namespace SteUp.Maui
{
    public static class MauiProgram
    {
        private const string AppToken = "4fef1843-793d-499b-a7ed-1edd8cac465c";

        public static MauiApp CreateMauiApp()
        {
            InteractiveRenderSettings.ConfigureBlazorHybridRenderModes();

            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .UseIntegry(appToken: AppToken, useLoginAzienda: true)
                .UseMauiCommunityToolkit()
                .UseSentry(options =>
                {
                    options.Dsn = "https://c1ff03e3d1d2dd973a1ce73c58f92a8d@o4508499810254848.ingest.de.sentry.io/4510900455866448";
#if DEBUG
                    options.Debug = true;
#endif
                    options.TracesSampleRate = 1.0;
                })
                .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); });

            builder.Services.AddMauiBlazorWebView();
            builder.Services.AddMudServices();
            builder.Services.AddMudExtensions();

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

            builder.AddAuthorizationCore();
            builder.RegisterAppServices();
            builder.RegisterIntegryServices();
            builder.RegisterSystemService();
            builder.RegisterDbServices();
            builder.RegisterMessageServices();
            builder.RegisterLoggerServices();

            return builder.Build();
        }
    }
}
