/**
 * @license
 * Copyright Akveo. All Rights Reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 */
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { CoreModule } from './@core/core.module';
import { ThemeModule } from './@theme/theme.module';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

import {
  NbChatModule,
  NbDatepickerModule,
  NbDialogModule,
  NbMenuModule,
  NbSidebarModule,
  NbTimepickerModule,
  NbToastrModule,
  NbWindowModule,
} from '@nebular/theme';
import { NbDateFnsDateModule } from '@nebular/date-fns';
import { NbAuthModule, NbOAuth2AuthStrategy, NbOAuth2ResponseType, NbPasswordAuthStrategy } from '@nebular/auth';
import { environment } from '../environments/environment';
import { LoginModule } from './login/login.module';
import { HttpInterceptorProviders } from './providers/http-interceptors/httpInterceptorProviders';
import { DefaultUrlSerializer, UrlSerializer, UrlTree } from '@angular/router';
import { DateUtils } from './utilities/date-utils';
import { NgxMaskModule, IConfig } from 'ngx-mask'

const maskConfig: Partial<IConfig> = {
  validation: false,
};

const socialLinks = [
  {
    link: '/CellGroup/googleLogin',
    target: '_blank',
    icon: 'google',
    title: 'Continue with Google Login'
  },
  // {
  //   url: 'https://www.facebook.com/akveo/',
  //   target: '_blank',
  //   icon: 'facebook',
  // },
  // {
  //   url: 'https://twitter.com/akveo_inc',
  //   target: '_blank',
  //   icon: 'twitter',
  // },
];
@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    AppRoutingModule,
    NbSidebarModule.forRoot(),
    NbMenuModule.forRoot(),
    NbTimepickerModule.forRoot({ format: "yyyy/MM/dd HH:mm" }),
    NbDatepickerModule.forRoot(),
    NbDialogModule.forRoot(),
    NbWindowModule.forRoot(),
    NbToastrModule.forRoot(),
    NbChatModule.forRoot({
      messageGoogleMapKey: 'AIzaSyA_wNuCzia92MAmdLRemailRGvCF7wCZPY',
    }),
    NbDialogModule.forRoot({
      closeOnBackdropClick: false,
      closeOnEsc: false
    }),
    NbDateFnsDateModule.forRoot({ format: 'MM/dd/yyyy' }),
    CoreModule.forRoot(),
    ThemeModule.forRoot(),
    NbAuthModule.forRoot({
      strategies: [
        NbPasswordAuthStrategy.setup({
          name: 'email',
          baseEndpoint: '',
          login: {
            // ...
            method: 'post',
            endpoint: `${environment.apiUrl}/auth/login`,
          },
          register: {
            // ...
            method: 'post',
            endpoint: `${environment.apiUrl}/auth/sign-up`,
          },
        }),
        NbOAuth2AuthStrategy.setup({
          name: 'google',
          clientId: environment.GAPI_CLIENT_ID,
          clientSecret: '',
          authorize: {
            endpoint: 'https://accounts.google.com/o/oauth2/v2/auth',
            responseType: NbOAuth2ResponseType.TOKEN,
            scope: 'profile email',
            redirectUri: environment.GAPI_LOGIN_CALL_BACK,
          },
          // ...
        }),
      ],
      forms: {
        login: {
          socialLinks: socialLinks,
        },
        register: {
          socialLinks: socialLinks,
        },
        validation: {
          password: {
            required: true,
            minLength: 4,
            maxLength: 50,
          },
          email: {
            required: true,
          },
          fullName: {
            required: true,
            minLength: 2,
            maxLength: 50,
          },
        },
      },
    }),
    LoginModule,
  ],
  bootstrap: [AppComponent],
  providers: [
    HttpInterceptorProviders,
  ]
})
export class AppModule {
  /**
   *
   */
  constructor() {
    //this.overrideJsonParseDate();

  }
  overrideJsonParseDate() {

    Date.prototype.toJSON = function (key) {
      return DateUtils.format(this, "yyyy-MM-ddTHH:mm:ss");
    };
  }

}

