import Component from '../../component.js'

export default class CoEuiTimepicker extends Component {
  constructor(parent) {
    let selector = 'eui-timepicker' ;
    super(parent, selector);
    // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/components/eui-timepicker/eui-timepicker.component.html
  }
  get timepicker() {
    return this.currentPath + '//div[@class = "eui-timepicker"]';
  }
  async isDatetimepicker() {
    return await (await $(this.currentPath + '//div[contains(@class, "eui-timepicker--centered")]')).isExisting();
  }
  //hour
  get hourInputContainer() {
    return this.timepicker + '//div[contains(@class, "eui-timepicker__input-container")][1]';
  }
  get hourTopChevronLink() {
    return this.hourInputContainer + '//a[contains(@class, "eui-timepicker__chevron")][1]';
  }
  get hourTopChevronIcon() {
    return this.hourTopChevronLink + '//span[contains(@class, "eui-icon-chevron-up")]';
  }
  get hourInput() {
    return this.hourInputContainer + '//input[contains(@class, "eui-timepicker__input")]';
  }
  get hourBottomChevronIcon() {
    return this.hourBottomChevronLink + '//span[contains(@class, "eui-icon-chevron-down")]';
  }
  get hourBottomChevronLink() {
    return this.hourInputContainer + '//a[contains(@class, "eui-timepicker__chevron")][2]';
  }
  get hourMinuteSpacer() {
    return this.timepicker + '//div[contains(@class, "eui-timepicker__spacer")][1]';
  }
  //minutes
  get minutesInputContainer() {
    return this.timepicker + '//div[contains(@class, "eui-timepicker__input-container")][2]';
  }
  get minutesTopChevronLink() {
    return this.minutesInputContainer + '//a[contains(@class, "eui-timepicker__chevron")][1]';
  }
  get minutesTopChevronIcon() {
    return this.minutesTopChevronLink + '//span[contains(@class, "eui-icon-chevron-up")]';
  }
  get minutesInput() {
    return this.minutesInputContainer + '//input[contains(@class, "eui-timepicker__input")]';
  }
  get minutesBottomChevronIcon() {
    return this.minutesBottomChevronLink + '//span[contains(@class, "eui-icon-chevron-down")]';
  }
  get minutesBottomChevronLink() {
    return this.minutesInputContainer + '//a[contains(@class, "eui-timepicker__chevron")][2]';
  }

  async hasSeconds() {
    let spacerState = await (await $(this.minutesSecondsSpacer)).isExisting();
    let secondsInputState = await (await $(this.secondsInputContainer)).isExisting();
    if(spacerState && secondsInputState) {
      return true;
    } else {
      return false;
    }
  }
  get minutesSecondsSpacer() {
    return this.timepicker + '//div[contains(@class, "eui-timepicker__spacer")][2]';
  }
  //seconds
  get secondsInputContainer() {
    return this.timepicker + '//div[contains(@class, "eui-timepicker__input-container")][3]';
  }
  get secondsTopChevronLink() {
    return this.secondsInputContainer + '//a[contains(@class, "eui-timepicker__chevron")][1]';
  }
  get secondsTopChevronIcon() {
    return this.secondsTopChevronLink + '//span[contains(@class, "eui-icon-chevron-up")]';
  }
  get secondsInput() {
    return this.secondsInputContainer + '//input[contains(@class, "eui-timepicker__input")]';
  }
  get secondsBottomChevronIcon() {
    return this.secondsBottomChevronLink + '//span[contains(@class, "eui-icon-chevron-down")]';
  }
  get secondsBottomChevronLink() {
    return this.secondsInputContainer + '//a[contains(@class, "eui-timepicker__chevron")][2]';
  }
}


