import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxTimebarStep extends Component {
  constructor(parent) {
    let selector = 'div[contains(@class, "ux-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/src/lib/ux-components/ux-timebar/ux-timebar.component.html
  }
  async isShowCurrentDateMarker() {
    return await elementAttributeContains(this.currentPath, 'class', 'ux-timebar__step--with-current-date-marker');
  }
  get dateItem() {
    let path = '//div[contains(@class,"ux-timebar__step-date-item")]';
    return this.currentPath + path;
  }
  async hasGroupEndDate() {
    return await elementAttributeContains(this.dateItem, 'class', 'ux-timebar__step-date-item--with-end-date');
  }
  get groupedStep() {
    let path = '//span[contains(@class,"timebar__grouped__step")]';
    return this.dateItem + path;
  }
  async isGroupedStep() {
    return await (await $(this.groupedStep)).isExisting();
  }
  get label() {
    let path = '//div[contains(@class,"ux-timebar__step-label")]';
    return this.currentPath + path;
  }
  get labelSpan() {
    let path = '//span';
    return this.label + path;
  }
  async isMobile() {
    return !(await elementAttributeContains(this.currentPath + '//div', 'class', 'ux-timebar__step-date-item'));
  }
}

