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

export default class CoEuiSlideToggle extends Component {

  constructor(parent) {
    let selector = 'eui-slide-toggle';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-slide-toggle/eui-slide-toggle.component.html
  }
  get container() {
    return this.currentPath + '//div[contains(@class, "eui-slide-toggle__container")]';
  }
  async containerIsDisabled() {
    return elementAttributeContains(this.container, 'class', 'eui-slide-toggle__container--disabled');
  }
  get inputCO() {
    return new InputComponent(this.container).byAttributeContains('class', 'eui-u-display-hidden');
  }
  async inputIsChecked() {
    return await (await $(this.inputCO.currentPath + '[@checked="true"]')).isExisting();
  }
  get toggleTrack() {
    return this.container + '//div[contains(@class, "eui-slide-toggle__track")]';
  }
  async toggleTrackIsChecked() {
    return await elementAttributeContains(this.toggleTrack, 'class', 'eui-slide-toggle__track--on');
  }
  async toggleTrackIsNotChecked() {
    return await elementAttributeContains(this.toggleTrack, 'class', 'eui-slide-toggle__track--off');
  }
  get toggleHandler() {
    return this.container + '//div[contains(@class, "eui-slide-toggle__handler")]';
  }
  async toggleHandlerIsChecked() {
    return await elementAttributeContains(this.toggleHandler, 'class', 'eui-slide-toggle__handler--on');
  }
  async toggleHandlerIsNotChecked() {
    return await elementAttributeContains(this.toggleHandler, 'class', 'eui-slide-toggle__handler--off');
  }
}


