import {
  ApplicationConfig,
  ErrorHandler,
  importProvidersFrom,
  provideZoneChangeDetection,
} from '@angular/core';
import { provideRouter, withComponentInputBinding } from '@angular/router';

import { provideHttpClient } from '@angular/common/http';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { provideHotToastConfig } from '@ngxpert/hot-toast';
import { environment } from '../environments/environment';
import { routes } from './app.routes';
import { MsAuthenticationModule } from './core/components/ms-authentication/ms-authentication.module';
import { GlobalErrorHandler } from './core/telemetry/global-error-handler';
import { graphqlProvider } from './graphql.provider';

export const appConfig: ApplicationConfig = {
  providers: [
    // provideAppInitializer(() => {
    //   const initializerFn = faroInitializer();
    //   return initializerFn();
    // }),
    {
      provide: ErrorHandler,
      useClass: GlobalErrorHandler,
    },
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideRouter(routes, withComponentInputBinding()),
    provideAnimationsAsync(),
    importProvidersFrom(
      MsAuthenticationModule.forRoot({
        clientId: environment.msAuth.clientId,
        authority: environment.msAuth.authority,
        redirectUri: environment.msAuth.redirectUri,
        postLogoutRedirectUri: environment.msAuth.postLogoutRedirectUri,
      })
    ),
    provideHttpClient(),
    graphqlProvider,
    provideHotToastConfig(),
  ],
};
