import Component from '../component.js';
import MatDateRangeInput from '../material/mat-date-range-input.js';
import MatDateRangePicker from '../material/mat-date-range-picker.js';
import CoEuiButton from './eui-button.js';
import CoEuiInputText from './eui-input-text.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import SpanComponent from '../span.js';

export default class CoEuiDateRangeSelector extends Component {
  constructor(parent) {
    let selector = 'eui-date-range-selector';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-date-range-selector/eui-date-range-selector.component.html?at=master
  }
  get matDateRangeInputCo() {
    return new MatDateRangeInput(this.currentPath);
  }
  async isReadOnly() {
    return await (await $(this.matDateRangeInputCo.currentPath + '/self::div[contains(@class, "mat-date-range-input--read-only")]')).isExisting();
  }
  async isDisabled() {
    return await (await $(this.matDateRangeInputCo.currentPath + '/self::div[contains(@class, "mat-date-range-input--disabled")]')).isExisting();
  }
  async isInvalid() {
    return await (await $(this.matDateRangeInputCo.currentPath + '/self::div[contains(@class, "mat-date-range-input--invalid")]')).isExisting();
  }
  get startDateInputTextCo() {
    return new CoEuiInputText(this.matDateRangeInputCo).addPredicateClassContains('eui-date-range-selector__start-date');
  }
  get endDateInputTextCo() {
    return new CoEuiInputText(this.matDateRangeInputCo).addPredicateClassContains('eui-date-range-selector__end-date');
  }
  get matDateRangePicker() {
    return new MatDateRangePicker(this.currentPath);
  }
  get togglerButtonCo() {
    return new CoEuiButton(this.currentPath).addPredicateClassContains('eui-date-range-selector__toggler');
  }
  get togglerIconSvgCo() {
    return new CoEuiIconSvg(this.togglerButtonCo).addPredicateAttributeContains('aria-label', 'Open Calendar');
  }
  async hasTogglerIconSvg() {
    return await (await this.togglerIconSvgCo.element()).isExisting();
  }
  get togglerLabelCo() {
    return new SpanComponent(this.togglerButtonCo);
  }
  async hasTogglerLabel() {
    return await (await this.togglerLabelCo.element()).isExisting();
  }
}


