import Component from '../component.js';
import CoEuiIcon from './eui-icon.js';
import SpanComponent from '../span.js';

export default class CoEuiButton extends Component {
    constructor(parent) {
      let selector = '*[self::a[@euibutton] or self::button[@euibutton]]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-button/eui-button.component.html?at=master
    }
    get containerCO() {
      return new SpanComponent(this.currentPath).addPredicateClassContains('eui-button__container');
    }
    get loadingIconCO() {
      return new SpanComponent(this.containerCO).addPredicateClassContains('eui-button__loading-icon');
    }
    async isLoading() {
      return await (await $(this.loadingIconCO.currentPath)).isExisting();
    }
    get euiIconCO() {
      return new CoEuiIcon(this.loadingIconCO);
    }
    async isBasic() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-button--basic")]')).isExisting();
    }
    async isBlock() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-button--block")]')).isExisting();
    }
    async isLoading() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-button--loading")]')).isExisting();
    }
    async isIconOnly() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-button--icon-only")]')).isExisting();
    }
    async isLineWrap() {
      return await (await $(this.currentPath + '/self::*[contains(@class,"eui-button--line-wrap")]')).isExisting();
    }
}
