import Component from '../component.js';
import CdkOverlayContainer from '../cdk-overlay-container.js';
import CoEuiButton from './eui-button.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import DivComponent from '../div.js';

export default class CoEuiPopover extends Component {
  constructor(parent) {
    let selector = 'eui-popover';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-popover/eui-popover.component.html?at=master
  }
  get overlayContainerCO() {
    return new CdkOverlayContainer('//body');
  }
  get overlayPopoverDivCO() {
    return new DivComponent(this.overlayContainerCO.overlayPane).addPredicateClassContains('eui-popover');
  }
  getOverlayPopoverDivByIndex(index) {
    return this.overlayPopoverDivCO.byIndex(index);
  }
  get arrowCO() {
    return new DivComponent(this.overlayPopoverDivCO).addPredicateClassContains('eui-popover__arrow');
  }
  get innerArrow() {
    return new DivComponent(this.arrowCO).addPredicateClassContains('eui-popover__arrow-inner');
  }
  get headerCO() {
    return new DivComponent(this.overlayPopoverDivCO).addPredicateClassContains('eui-popover__header');
  }
  async hasTitle() {
    return await (await this.headerCO.element()).isExisting();
  }
  get titleCO() {
    return new DivComponent(this.headerCO).addPredicateClassContains('eui-popover__header-title');
  }
  get closeButtonCO() {
    return new CoEuiButton(this.headerCO).addPredicateClassContains('eui-popover__header-close');
  }
  async hasCloseButton() {
    return await (await this.closeButtonCO.element()).isExisting();
  }
  get closeIconCO() {
    return new CoEuiIconSvg(this.closeButtonCO).addPredicateIconContains('close');
  }
  get contentCO() {
    return new DivComponent(this.overlayPopoverDivCO).addPredicateClassContains('eui-popover__content');
  }
}


