import { registerLocaleData } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import zh from '@angular/common/locales/zh';
import { APP_INITIALIZER, Injector, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgCortexModule } from '@ng-cortex/core';
import { NzConfig, NZ_CONFIG } from 'ng-zorro-antd/core/config';
import { NZ_I18N, zh_CN } from 'ng-zorro-antd/i18n';
import { NzNotificationModule } from 'ng-zorro-antd/notification';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { AppStartupFactory } from './app-startup.factory';

/** NgZorroAntd配置 */
const ngZorroConfig: NzConfig = {
  descriptions: {
    nzBordered: true,
    nzColon: false,
    nzColumn: { xxl: 4, xl: 3, lg: 2, md: 2, sm: 1, xs: 1 },
    nzSize: 'small'
  },
  modal: { nzMaskClosable: false },
  notification: { nzPlacement: 'bottomRight' },
  table: {
    nzBordered: true,
    nzSize: 'small',
    nzShowSizeChanger: true
  }
};

/** 注册语言环境数据 */
registerLocaleData(zh);

/** 程序模块 */
@NgModule({
  bootstrap: [AppComponent],
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    NzNotificationModule,
    NgCortexModule,
    AppRoutingModule
  ],
  providers: [
    { provide: APP_INITIALIZER, useFactory: AppStartupFactory, deps: [Injector], multi: true },
    { provide: NZ_I18N, useValue: zh_CN },
    { provide: NZ_CONFIG, useValue: ngZorroConfig }
  ]
})
export class AppModule { }
