import Component from '../../component.js'
import CoUxTimebarStep from './ux-timebar-step.js'
import CoUxTimebarLegendItem from './ux-timebar-legend-item.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxTimebar extends Component {
  constructor(parent) {
    let selector = 'ux-timebar';
    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
  }
  get dataE2E() {
    let path = '//div[@data-e2e = "ux-timebar"]';
    return this.currentPath + path;
  }
  get timebarStartLabel() {
    let path = '//div[contains(@class,"col-2 ux-timebar__start-label")]';
    return this.dataE2E + path;
  }
  async hasTimebarStartLabel() {
    return await (await $(this.timebarStartLabel)).isExisting();
  }
  get timebar() {
    let path = '//div[@class="ux-timebar"]';
    return this.dataE2E + path;
  }
  get currentProgress() {
    let path = '//div[contains(@class,"ux-timebar__current-progress")]';
    return this.timebar + path;
  }
  async isShowCurrentDateMarker() {
    return await (await $(this.currentProgress)).isExisting();
  }
  get timebarStepCO() {
    return new CoUxTimebarStep(this.timebar);
  }
  get dateMarker() {
    let path = '//div[contains(@class,"ux-timebar__current-date-marker")]';
    return this.timebar + path;
  }
  get mapMarkerIcon() {
    let path = '//span[contains(@class,"ux-icon-map-marker")]';
    return this.timebar + path;
  }
  get dateMarkerStep() {
    let path = '//div[contains(@class,"ux-timebar__current-date-marker-step")]';
    return this.timebar + path;
  }
  get circleIcon() {
    let path = '//span[contains(@class,"ux-icon-map-marker")]';
    return this.timebar + path;
  }
  async hasMarkedDate() {
    return await (await $(this.dateMarker)).isExisting();
  }
  get timebarEndLabel() {
    let path = '//div[contains(@class,"col-2 ux-timebar__end-label")]';
    return this.dataE2E + path;
  }
  async hasTimebarEndLabel() {
    return await (await $(this.timebarEndLabel)).isExisting();
  }
  get secondContainer() {
    let path = '/following-sibling::div[contains(@class,"row flex-container")]';
    return this.dataE2E + path;
  }
  get timebarLegend() {
    let path = '//div[contains(@class,"ux-timebar__legend")]';
    return this.secondContainer + path;
  }
  get timebarLegendItemCO() {
    return new CoUxTimebarLegendItem(this.timebarLegend);
  }
  async isShowLegend() {
    return await (await $(this.timebarLegendItemCO.currentPath)).isExisting();
  }
}

