/**
 * @since Wed Oct 10 2018
 * @author Charles Gouldmann - Klean
 */

// Core imports
import { Component, OnInit } from '@angular/core'
import { Router }            from '@angular/router'
import {
    trigger,
    state,
    style,
    animate,
    transition
} from '@angular/animations'


// Component
import { ConfiguratorPartial }  from '@k-core/modules/configurator/partial/cmp.configurator-partial'

// Global / Shared Services
import { PageService }  from '@k-services/svc.page'
import { SeoService }   from '@k-services/svc.seo'

// Module Services
import { StepNavigationService }            from '@k-core/modules/configurator/services/svc.step-navigation'
import { ConfiguratorService }              from '@k-core/modules/configurator/services/svc.configurator'
import { ConfiguratorProductLoaderService } from '@k-core/modules/configurator/services/svc.configurator-product-reloader'
import { Location } from '@angular/common'

@Component({
    moduleId: module.id+ '',
    selector: 'configurator-partial-ide',
    templateUrl: './templates/t--configuratorPartial.pug',
    styleUrls: ['sty.configurator-partial.scss'],
    animations: [
        // RotateOnActive
        trigger('show', [
            state('show', style({
                display: 'block'
            })),
            state('hide', style({
                display: 'none'
            })),

            transition('show <=> hide', [
                animate('.2s')
            ])
        ])
    ]
})

export class ConfiguratorPartial_IDEmobler extends ConfiguratorPartial {

    // ---- Variables ---- \\
    currentStep: string
    validationResults = new Map


    constructor(
        _configService: ConfiguratorService, 
        _dataCenter: ConfiguratorProductLoaderService, 
        _page: PageService, 
        _seo: SeoService, 
        _router: Router,
        _location: Location,
        private _stepNavigation: StepNavigationService
    ) {
        super(_configService, _dataCenter, _page, _seo, _router, _location)

        // Get current step and subscribe to changes
        this.currentStep = _stepNavigation.getCurrentStep()
        _stepNavigation.currentStep$.subscribe((resp: string) => {
            this.currentStep = resp
        })


        _configService.validationResults$.subscribe((response) => {
            this.validationResults = response
        })
    }


    // ---- Functions ---- \\

    setFixedState() {
        // Do nothing to nullify the original function
    }

    /**
     * Go to next step
     */
    nextStep() {
        this._stepNavigation.stepInDirection('next')
    }
}
