import AComponent from '../a.js';
import Component from '../component.js';
import DivComponent from '../div.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 contentWrapperCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains("eui-alert__content-wrapper");
  }
  get typeContainerCO() {
    return new DivComponent(this.contentWrapperCO).addPredicateClassContains("eui-alert__type-container");
  }
  async euiAlertMuted() {
    return !await(await this.typeContainerCO.element()).isExisting();
  }
  get alertIconTypeCO() {
    return new CoEuiIconSvg(this.typeContainerCO);
  }
  get alertContentCO() {
    return new DivComponent(this.contentWrapperCO).addPredicateClassContains("eui-alert__content");
  }
  get alertCloseCO() {
    return new AComponent(this.contentWrapperCO).byAttributeEquals('role', 'button');
  }
  get alertCloseIconCO() {
    return new CoEuiIconSvg(this.alertCloseCO).byAttributeContains('class', 'eui-alert__close-icon');
  }
  async isCloseable() {
    return await (await this.alertCloseCO.element()).isExisting();
  }
  async isMuted() {
    return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--muted');
  }
  async isHidden() {
    return await elementAttributeContains(this.currentPath, 'class', 'eui-alert--hidden');
  }
}
