import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Requestor, FetchRequestor } from '@openid/appauth';
import { ReactiveFormsModule } from '@angular/forms';
import { NzFormModule } from 'ng-zorro-antd/form';
import { NzInputModule } from 'ng-zorro-antd/input';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzSpinModule } from 'ng-zorro-antd/spin';

import { AuthenticationRoutingModule } from './authentication-routing.module';
import { AuthenticationService } from './authentication.service';
import { AuthenticationInterceptor } from './authentication.interceptor';
import { AuthenticationGuard } from './authentication.guard';
import { LoginComponent } from './login/login.component';
import { CallbackComponent } from './callback/callback.component';


@NgModule({
  declarations: [
    LoginComponent
    , CallbackComponent
  ],
  imports: [
    CommonModule
    , ReactiveFormsModule

    , NzFormModule
    , NzInputModule
    , NzButtonModule
    , NzSpinModule

    , AuthenticationRoutingModule
  ],
  providers: [
    AuthenticationService
    , AuthenticationGuard
    , [
      {
        provide: HTTP_INTERCEPTORS,
        useClass: AuthenticationInterceptor,
        multi: true
      }
    ]
    , {
      provide: Requestor,
      useValue: new FetchRequestor()
    }
  ]
})
export class AuthenticationModule { }
