import Component from '../../component.js';
import DivComponent from '../div.js';
import SpanComponent from '../span.js';

export default class CoEuiTimebarStep extends Component {
  constructor(parent) {
    let selector = 'div[contains(@class, "eui-timebar__step") and not(contains(@class,"item") or contains(@class,"label"))]';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-timebar/eui-timebar.component.html?at=master
  }
  async isShowCurrentDateMarker() {
    return await (await $(this.currentPath + '/self::*[contains(@class,"eui-timebar__step--with-current-date-marker")]')).isExisting();
  }
  get dateItemStepCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-timebar__step-date-item');
  }
  async hasGroupEndDate() {
    return await (await $(this.dateItemStepCO.currentPath + '/self::*[contains(@class,"eui-timebar__step-date-item--with-end-date")]')).isExisting();
  }
  get groupEndDateCO() {
    return new SpanComponent(this.dateItemStepCO).addPredicateClassContains('timebar__grouped__step');
  }
  get dateItemCO() {
    return new SpanComponent(this.dateItemStepCO).addPredicateClassContains('eui-timebar__step--').addSelectorPredicate('[2]');
  }
  get stepLabelCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-timebar__step-label');
  }
  get itemLabelCO() {
    return new SpanComponent(this.stepLabelCO).byIndex(1);
  }
  get groupLabelCO() {
    return new SpanComponent(this.stepLabelCO).byIndex(2);
  }
  async hasGroupLabel() {
    return await (await this.groupLabelCO.element()).isExisting();
  }
  async isMobile() {
    return !(await (await this.dateItemStepCO.element()).isExisting());
  }
}

