import Component  from '../component.js'
import CoEuiIconSvg from './eui-icon-svg.js'

export default class CoEuiAlert extends Component {
  constructor(parent) {
    let selector = '*[self::eui-alert or self::div[@euiAlert]]';
    super(parent, selector);
    // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-alert/eui-alert.component.html
  }
  get contentWrapper() {
    return this.currentPath + '//div[contains(@class, "eui-alert__content-wrapper")]';
  }
  get typeContainer() {
    return this.contentWrapper + '//div[contains(@class, "eui-alert__type-container")]';
  }
  async euiAlertMuted() {
    return ! await (await $(this.typeContainer)).isExisting();
  }
  get alertIconTypeCO() {
    return new CoEuiIconSvg(this.typeContainer);
  }
  get alertContent() {
    return this.contentWrapper + '//div[contains(@class, "eui-alert__content")]';
  }
  get alertClose() {
    return this.contentWrapper + '/a[contains(@role, "button")]';
  }
  get alertCloseIconCO() {
    return new CoEuiIconSvg(this.alertClose).byAttributeContains('class', 'eui-alert__close-icon');
  }
  async isCloseable() {
    return await (await $(this.alertClose)).isExisting();
  }
  async isMuted() {
    return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--muted');
  }
  async isHidden() {
    return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--hidden');
  }
}
