import Component from '../component.js'
import CoEuiButton from './eui-button.js'
import CoEuiCardHeaderTitle from './eui-card-header-title.js'
import CoEuiCardHeaderBody from './eui-card-header-body.js'
import CoEuiCardHeaderLeftContent from './eui-card-header-left-content.js'
import CoEuiCardHeaderRightContent from './eui-card-header-right-content.js'
import CoEuiCardHeaderSubtitle from './eui-card-header-subtitle.js'
import CoEuiIconSvg from './eui-icon-svg.js'
import DivComponent from '../div.js'
import SpanComponent from '../span.js'


export default class CoEuiCardHeader extends Component {
  constructor(parent) {
    let selector = 'eui-card-header';
    super(parent, selector);
    // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-card/components/eui-card-header/eui-card-header.component.html?at=master
  }
  get containerCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-card-header__container');
  }
  async isHeaderBodyOnly() {
    return !(await (await this.containerCO.element()).isExisting());
  }
  get euiCardHeaderLeftContentCO() {
    return new CoEuiCardHeaderLeftContent(this.containerCO);
  }
  get avatarCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-card-header__avatar');
  }
  async hasAvatar() {
    return await (await this.avatarCO.element()).isExisting();
  }
  get iconCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-card-header__icon');
  }
  get iconDescriptionCO() {
    return new SpanComponent(this.iconCO).addPredicateAttributeContains('role', 'img');
  }
  async hasIcon() {
    return await (await this.iconCO.element()).isExisting();
  }
  async titleContainerCO() {
    if (await this.hasFullTitle()) {
      return new DivComponent(this.middleContainerCO).addPredicateClassContains('eui-card-header__title-container');
    }
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-card-header__title-container');
  }
  get middleContainerCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-card-header__middle-container');
  }
  get middleContentCO() {
    return new DivComponent(this.middleContainerCO).addPredicateClassContains('eui-card-header__middle-content');
  }
  async hasFullTitle() {
    return await (await this.middleContainerCO.element()).isExisting();
  }
  async euiCardHeaderTitleCO() {
    return new CoEuiCardHeaderTitle(await this.titleContainerCO());
  }
  async euiCardHeaderSubtitleCO() {
    if (await this.hasFullTitle()) {
      return new CoEuiCardHeaderSubtitle(this.middleContentCO);
    }
    return new CoEuiCardHeaderSubtitle(await this.titleContainerCO());
  }
  async euiCardHeaderRightContentCO() {
    if (await this.hasFullTitle()) {
      return new CoEuiCardHeaderRightContent(this.middleContentCO);
    }
    return new CoEuiCardHeaderRightContent(this.containerCO);
  }
  get expanderCO() {
    return new DivComponent(this.containerCO).addPredicateClassContains('eui-card-header__expander');
  }
  async isCollapsible() {
    return await (await this.expanderCO.element()).isExisting();
  }
  async hasBottomExpander() {
    return await (await $(this.expanderCO.currentPath + '/self::div[contains(@class,"eui-card-header__expander--bottom")]')).isExisting();
  }
  async isHeaderMultilines() {
    return await (await $(this.expanderCO.currentPath + '/self::div[contains(@class,"eui-card-header__expander--top")]')).isExisting();
  }
  get expanderButtonCO() {
    return new CoEuiButton(this.expanderCO).addPredicateClassContains('eui-card-header__expander-icon');
  }
  async isCollapsed() {
    return await (await $(this.expanderButtonCO.currentPath + '/self::button[@aria-label="expandLabel"]')).isExisting();
  }
  get iconChevronUpCO() {
    return new CoEuiIconSvg(this.expanderButtonCO).addPredicateIconContains('eui-chevron-up');
  }
  get urgentIndicatorCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-card-header__urgent-indicator');
  }
  get iconAlertCO() {
    return new CoEuiIconSvg(this.urgentIndicatorCO).addPredicateIconContains('eui-alert-circle');
  }
  get euiCardHeaderBodyCO() {
    return new CoEuiCardHeaderBody(this.currentPath);
  }
}


