import { Component, HostListener } from '@angular/core'
import { Router } from '@angular/router'
import { Location } from '@angular/common'

// Settings
import { store } from  '@k-settings/app-setup'

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

// Services
import { ConfiguratorService } from '@k-core/modules/configurator/services/svc.configurator'
import { ConfiguratorProductLoaderService } from '@k-core/modules/configurator/services/svc.configurator-product-reloader'
import { HelperService } from '@k-core/services/svc.helper'
import { PageService } from '@k-core/services/svc.page'
import { SeoService } from '@k-core/services/svc.seo'


@Component({
	moduleId: module.id+ '',
	selector: 'configurator-partial',
	templateUrl: './templates/t--configuratorPartial.bilka.pug',
	styleUrls: ['sty.configurator-partial.bilka.scss']
})

export class ConfiguratorPartialBilka extends ConfiguratorPartial {
	
	// ---- Variables ---- \\
	isPalm: boolean = this._helper.currentBreakPoint('palm')
	private resizeTimeout
	public currentStore = store


	constructor(
		protected _configService: ConfiguratorService,
        protected _dataCenter: ConfiguratorProductLoaderService,
        protected _page:  PageService,
        protected _seo:  SeoService,
        protected _router: Router,
        protected _location: Location,
		protected _helper: HelperService
	) {
		super(
			_configService, 
			_dataCenter,
			_page,
			_seo,
			_router,
			_location,
		)
	}


	// ---- Listeners ---- \\

	/**
	 * Listen to window resize
	 */
	@HostListener('window:resize', ['$event'])
	onWindowResize() {

		// Reset timeout
		clearTimeout(this.resizeTimeout)

		// Set timout for calling current breakpoint to stop calls before resize is done
		this.resizeTimeout = setTimeout(() => {
			this.isPalm = this._helper.currentBreakPoint('palm')
		}, 100)
	}


	//---- Lifecycle hooks ---- \\



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

}
