import Component  from '../component.js'
import { elementAttributeContains } from '../../core/utils.js'
import CoUxErrorGroupItem from './ux-error-group-item.js'

export default class CoUxErrorGroupOutputErrorGroup extends Component {

  constructor(parent) {
    let selector = 'div[contains(@class, "ux-error-group-wrapper__header-container")]';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-error-group-output/ux-error-group-output.component.html
  }

  get dangerIcon()  {
    let path = '//span[contains(@class, "ux-icon-times-circle") and contains(@class, "ux-u-color-danger")]';
    return this.currentPath + path;
  }
  async hasSeverity(severity) {
    return await elementAttributeContains(this.currentPath + '//span[contains(@class, "ux-u-color")]', 'class', severity);
  }
  get warningIcon()  {
    let path = '//span[contains(@class, "ux-icon-exclamation-triangle") and contains(@class, "ux-u-color-warning")]';
    return this.currentPath + path;
  }
    get infoIcon()  {
    let path = '//span[contains(@class, "ux-icon-exclamation-circle") and contains(@class, "ux-u-color-grey")]';
    return this.currentPath + path;
  }
  async hasSeverityInfo() {
    return await (await $(this.infoIcon)).isExisting();
  }
  get wrapperHeader()  {
    let path = '//div[contains(@class, "ux-error-group-wrapper__header")]';
    return this.currentPath + path;
  }
  get wrapperHeaderTitle()  {
    let path = '//div[contains(@class, "ux-error-group-wrapper__header__title")]';
    return this.wrapperHeader + path;
  }
  get titleLink()  {
    let path = '//a';
    return this.wrapperHeaderTitle + path;
  }
  get expandIconContainer()  {
    let path = '//div[contains(@class, "ux-error-group-wrapper__header__expand-icon")]';
    return this.currentPath + path;
  }
  get expandIcon()  {
    let path = '//span[contains(@class, "ux-icon")]';
    return this.expandIconContainer + path;
  }
  async isExpanded() {
    return await elementAttributeContains(this.expandIcon, 'class', 'ux-icon-angle-down');
  }
  get bodyContainer()  {
    let path = '//div[contains(@class, "ux-error-group-wrapper__body-container")]';
    return this.currentPath + path;
  }
  get errorGroupItemCO(){
    return new CoUxErrorGroupItem(this.currentPath);
  }
}


