import { Component, OnInit, Input, Output, HostBinding, EventEmitter } from '@angular/core';
import { TUTORIAL_STEP_POSITION } from 'app/tutorial/enums/tutorial-step-position.enum';

@Component({
  selector: 'app-tutorial-step-tooltip',
  templateUrl: './tutorial-step-tooltip.component.html',
  styleUrls: ['./tutorial-step-tooltip.component.scss']
})
export class TutorialStepTooltipComponent implements OnInit {

  @Input()
  @HostBinding('class.show')
  show: boolean = false;

  @Input()
  @HostBinding('class')
  position: TUTORIAL_STEP_POSITION = TUTORIAL_STEP_POSITION.BOTTOM;

  @Input()
  totalEntrys: number = 1;

  @Input()
  currentEntry: number = 1;

  @Output()
  onNext: EventEmitter<void> = new EventEmitter();

  @Output()
  onPrevious: EventEmitter<void> = new EventEmitter();

  @Output()
  onClose: EventEmitter<void> = new EventEmitter();


  get hasMultipleEntrys() {
    return this.totalEntrys > 1;
  }

  get hasNext() {
    return this.currentEntry < this.totalEntrys;
  }

  get hasPrevious() {
    return this.currentEntry > 1;
  }

  get lastEntry() {
    return this.currentEntry == this.totalEntrys;
  }

  constructor() { }

  ngOnInit() {
  }

  next(e) {
    e.stopPropagation();
    e.stopImmediatePropagation();
    this.onNext.emit();
  }

  previous(e) {
    e.stopPropagation();
    e.stopImmediatePropagation();
    this.onPrevious.emit();
  }

  close(e) {
    e.stopPropagation();
    e.stopImmediatePropagation();
    this.onClose.emit();
  }

}
