import { ModalDetallesPage } from './../modals/modal-detalles/modal-detalles';
import { ModalvalorizacionPage } from './../modals/modalvalorizacion/modalvalorizacion';
import { BrowserModule } from '@angular/platform-browser';
import {ErrorHandler, LOCALE_ID, NgModule, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { HttpModule, Http } from '@angular/http';
import { HttpClientModule,HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
//import { OptionCoreModule } from '@option/core';
import { IonicStorageModule } from '@ionic/storage';
import { AgmCoreModule, GoogleMapsAPIWrapper } from '@agm/core';
import { BarcodeScanner } from '@ionic-native/barcode-scanner';
import { Geolocation } from '@ionic-native/geolocation';
import { Camera, CameraOptions } from '@ionic-native/camera';
import { DatePicker } from '@ionic-native/date-picker';
import { FCM } from '@ionic-native/fcm';
import { Device } from '@ionic-native/device';
import { InAppBrowser } from '@ionic-native/in-app-browser'; 
import { MyApp } from './app.component';
import { Insomnia } from '@ionic-native/insomnia';

// Pages
import { Profile } from '../pages/profile/profile';
import { HomePage } from '../pages/home/home';
import { NewsDetalle } from '../pages/noticias/newsDetalle';
import { OnboardingPage } from '../pages/onboarding/onboarding';
import { LoginPage } from '../pages/login/login';
import { SignupPage } from '../pages/signup/signup';
import { AyudaPage } from '../pages/ayuda/ayuda';
import { SignupPage2 } from '../pages/signup/signup2';
import { SignupPage3 } from '../pages/signup/signup3';
import { PedidosPage } from '../pages/pedidos/pedidos';
import { NoticiasPage } from '../pages/noticias/noticias';
import { LostPasswordPage } from '../pages/lostpassword/lostpassword';
import { FarmaciaPage } from './../pages/farmacia/farmacia';
import { AgmSnazzyInfoWindowModule } from '@agm/snazzy-info-window';

import { Pata } from '../pata';
// Popovers
import { PetMediaOptionsPage } from '../pages/popovers/pet-media-options/pet-media-options';
import { ProfileMedia } from '../pages/popovers/profile-media/profile-media';
import { AdsMedia } from '../pages/popovers/ads/ads';

// Services
import { AuthService } from '../services/auth.service';
import { UserService } from '../services/user.service';
import { PetService } from '../services/pet.service';
import { NewsService } from '../services/news.service';
import { DoctorService } from '../services/doctor.service';

// Components
import { NewsPreviewComponent } from '../components/news-preview/news-preview';
import { QrCardComponent } from '../components/qr-card/qr-card';
import { BrMaskerModule } from 'brmasker-ionic-3';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

// Constant
import { environment } from '../environments/environment';
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";

// Modals
import { ModalOK } from '../modals/ok/ok';
import { ModalERR } from '../modals/err/err';
import {SocialSharing} from "@ionic-native/social-sharing";
import {ChangePasswordPage} from "../pages/change-password/change-password";
import {DatePipe} from "@angular/common";
//import {EmailComposer} from "@ionic-native/email-composer";
import { SplitpaneProvider } from '../providers/splitpane/splitpane';
import { Ionic2RatingModule } from 'ionic2-rating';
//import {Ionic2MaskDirective} from "ionic2-mask-directive";
import { registerLocaleData } from '@angular/common';
import localeEs from '@angular/common/locales/ES';
import { IonPullupModule } from 'ionic-pullup';

import { BackgroundGeolocation } from '@ionic-native/background-geolocation';
import { TrackingProvider } from '../providers/tracking/tracking';
registerLocaleData(localeEs);
import { UserInfoPage } from '../modals/user-info/user-info';
import { VerRecorridoPage } from '../pages/ver-recorrido/ver-recorrido';
import { AgmDirectionModule } from 'agm-direction' 
import { Market } from '@ionic-native/market';
import { HistorialPage } from '../pages/historial/historial';
import { PagosPage } from '../pages/pagos/pagos';
import { RecetaPage } from '../pages/receta/receta';
import { Ng2Rut, RutValidator } from 'ng2-rut';
import { RecetaAddPage } from '../pages/receta/add';
import { ReversePipe } from '../reverse.pipe';
import { ProductoPage } from '../pages/producto/producto';
import { CategoryPage } from '../pages/category/category';
import { ModalCart } from '../modals/cart/cart';
import { ModalCheckout } from '../modals/checkout/checkout';
import { ModalTermsPage } from '../modals/modal-terms/modal-terms';
import { ModalPagoOkPage } from '../modals/modal-pago-ok/modal-pago-ok';
// import { GoogleMaps } from "@ionic-native/google-maps";
// The translate loader needs to know where to load i18n files
// in Ionic's static asset pipeline.
export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    MyApp,
    HomePage,
    NewsDetalle,
    PetMediaOptionsPage,
    ProfileMedia,
    OnboardingPage,
    LoginPage,
    Profile,
    SignupPage,
    SignupPage2,
    SignupPage3,
    AdsMedia,
    PedidosPage,
    PagosPage,
    HistorialPage,
    NoticiasPage,
    LostPasswordPage,
    ModalOK,
    ModalERR,
    ModalCart,
    NewsPreviewComponent,
    QrCardComponent,
    ChangePasswordPage,
    FarmaciaPage,
    RecetaPage,
    ModalDetallesPage,
    ModalvalorizacionPage,
    UserInfoPage,
    VerRecorridoPage,
    AyudaPage,
    RecetaAddPage,
    ProductoPage,
    CategoryPage,
    ModalCheckout,
    ReversePipe,
    ModalTermsPage,
    ModalPagoOkPage
  ],
  imports: [
    BrowserModule,
    IonPullupModule,
    BrMaskerModule,
    Ionic2RatingModule,
    IonicModule.forRoot(MyApp, {
      backButtonText: '',
      backButtonIcon: 'ios-arrow-back',
      iconMode: 'ios',
      tabsPlacement: 'bottom',
      pageTransition: 'ios-transition',
      scrollAssist: true,
      autoFocusAssist: true,
      doneText: 'Listo',
      cancelText: 'Cancelar',
      monthNames: ['Enero','Febrero','Marzo', 'Abril', 'Mayo','Junio','Julio', 'Agosto', 'Septiembre', 'Octubre','Noviembre','Diciembre'],
      monthShortNames: ['ene','feb','mar','abr','may','jun','jul','ago','sep','oct','nov','dic' ],
      dayNames: ['domingo','lunes', 'martes','miercoles','jueves','viernes','sabado','domingo' ],
      dayShortNames: ['dom', 'lun','mar','mie','jue','vie','sab' ],
    }),
    HttpModule,
    HttpClientModule,
    AgmCoreModule.forRoot({
      apiKey: 'AIzaSyBIckYy0s-R_wqEy6bVNstu_vCdrDnmjZQ',
      libraries: ["places"]
    }),
    AgmSnazzyInfoWindowModule,
    AgmDirectionModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient]
      }
    }),
    IonicStorageModule.forRoot({
      name: "__greenapp",
      driverOrder: ['indexeddb','websql']
    }),
    Ng2Rut
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    NewsDetalle,
    PetMediaOptionsPage,
    ProfileMedia,
    OnboardingPage,
    LoginPage,
    SignupPage,
    SignupPage2,
    SignupPage3,
    AdsMedia,
    PedidosPage,
    PagosPage,
    HistorialPage,
    NoticiasPage,
    LostPasswordPage,
    NewsPreviewComponent,
    QrCardComponent,
    ModalOK,
    ModalERR,
    ModalCart,
    Profile,
    FarmaciaPage,
    ChangePasswordPage,
    RecetaPage,
    ModalDetallesPage,
    ModalvalorizacionPage,
    UserInfoPage,
    VerRecorridoPage,
    AyudaPage,
    RecetaAddPage,
    ProductoPage,
    CategoryPage,
    ModalCheckout,
    ModalTermsPage,
    ModalPagoOkPage
  ],
  providers: [
    AuthService,
    UserService,
    PetService,
    NewsService,
    DoctorService,
    Insomnia,
    StatusBar,
    SplashScreen,
    GoogleMapsAPIWrapper,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    Pata,
    BarcodeScanner,
    Geolocation,
    BackgroundGeolocation,
    Camera,
    DatePicker,
    FCM,
    Device,
    { provide: LOCALE_ID, useValue: "es-ES" },
    SocialSharing,
    DatePipe,
    //EmailComposer,
    RutValidator,
    InAppBrowser,
    SplitpaneProvider,
    TrackingProvider,
    Market,
    ReversePipe
    // GoogleMaps

  ],
  schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule {
  constructor(private translate: TranslateService) {
    this.initTranslate();
  }

  initTranslate() {
    // Set the default language for translation strings, and the current language.
    this.translate.setDefaultLang('es-cl');
    this.translate.use('es-cl');
  }
}

