import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; import { APP_INITIALIZER, ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; import { initializeApp, provideFirebaseApp } from '@angular/fire/app'; import { provideClientHydration, withEventReplay } from '@angular/platform-browser'; import { provideRouter, withEnabledBlockingInitialNavigation, withInMemoryScrolling } from '@angular/router'; import { provideShareButtonsOptions } from 'ngx-sharebuttons'; import { shareIcons } from 'ngx-sharebuttons/icons'; import { environment } from '../environments/environment'; import { routes } from './app.routes'; import { AuthInterceptor } from './interceptors/auth.interceptor'; import { LoadingInterceptor } from './interceptors/loading.interceptor'; import { TimeoutInterceptor } from './interceptors/timeout.interceptor'; import { SelectOptionsService } from './services/select-options.service'; export const appConfig: ApplicationConfig = { providers: [ provideHttpClient(withInterceptorsFromDi()), { provide: APP_INITIALIZER, useFactory: initServices, multi: true, deps: [SelectOptionsService], }, { provide: HTTP_INTERCEPTORS, useClass: LoadingInterceptor, multi: true, }, { provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true, }, { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }, provideShareButtonsOptions(shareIcons()), provideZoneChangeDetection({ eventCoalescing: true }), provideRouter( routes, withEnabledBlockingInitialNavigation(), withInMemoryScrolling({ scrollPositionRestoration: 'enabled', anchorScrolling: 'enabled', }), ), provideClientHydration(withEventReplay()), provideFirebaseApp(() => initializeApp(environment.firebaseConfig)), ], }; function initServices(selectOptions: SelectOptionsService) { return async () => { await selectOptions.init(); }; }