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';

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
    }
    get overlayContainerCO() {
      return new CdkOverlayContainer('//body');
    }
    get overlayPopoverDiv(){
      return this.overlayContainerCO.overlayPane + '//div[contains(@class,"eui-popover")]';
    }
    getOverlayPopoverDivByIndex(index) {
      return  '(' + this.overlayPopoverDiv +  ')[' + index + ']';
    }
    get arrow(){
      return this.overlayPopoverDiv + '//div[contains(@class,"eui-popover__arrow")]';
    }
    get innerArrow(){
      return this.arrow + '//div[contains(@class,"eui-popover__arrow-inner")]';
    }
    get header(){
      return this.overlayPopoverDiv + '//div[contains(@class,"eui-popover__header")]';
    }
    async hasTitle() {
      return await (await $(this.header)).isExisting();
    }
    get title(){
      return this.header + '//div[contains(@class,"eui-popover__header-title")]';
    }
    get closeButtonCO(){
      return new CoEuiButton(this.header);
    }
    async hasCloseButton() {
      return await (await $(this.closeButtonCO.currentPath)).isExisting();
    }
    get closeIconCO() {
      return new CoEuiIconSvg(this.closeButtonCO).byAttributeContains('class', 'eui-close');
   }
    get content(){
      return this.overlayPopoverDiv + '//div[contains(@class,"eui-popover__content")]';
    }
}


