import Component from '../../component.js'
import CoEuiIcon from './eui-icon.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoEuiButton extends Component {
    constructor(parent) {
      let selector = '*[self::eui-button or self::button[@euibutton]]';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/components/eui-button/eui-button.component.html?at=refs%2Fheads%2Fsupport%2F10.x
    }
    get container() {
      let path = '//span[contains(@class, "eui-button__container")]';
      return this.currentPath + path;
    }
    get loadingIcon() {
      let path = '//span[contains(@class, "eui-button__loading-icon")]';
      return this.container + path;
    }
    async isLoading() {
      return await (await $(this.loadingIcon)).isExisting();
    }
    get euiIconCO() {
      return new CoEuiIcon(this.loadingIcon);
    }
    async isBasic() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--basic');
    }
    async isBlock() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--block');
    }
    async isRaised() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--raised');
    }
    async isIconOnly() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--icon-only');
    }
    async isLineWrap() {
      return await elementAttributeContains(this.currentPath, 'class', 'eui-button--line-wrap');
    }
}


