import Component  from '../component.js'
import { elementAttributeContains } from '../../core/utils.js'
import CoEuiChip from './eui-chip.js'
import CoEuiButton from './eui-button.js';
import CoEuiMenuItemIconContent from './eui-menu-item-icon-content.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiLabel from './eui-label.js';

export default class CoEuiMenuItemLinkContent extends Component {
  constructor(parent) {
    super(parent);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-menu/eui-menu-item.component.html
  }
  get iconContentCO() {
    return new CoEuiMenuItemIconContent(this.currentPath);
  }
  get iconCO() {
    return new CoEuiIconSvg(this.currentPath).byAttributeContains('class', 'eui-menu-item__link-marker--default');
  }
  get label() {
    let path = '//span[contains(@class,"eui-menu-item__link-label")]';
    return this.currentPath + path;
  }
  async isDisabledLinkLabel() {
    return await elementAttributeContains(this.label, 'class', 'eui-menu-item--disabled');
  }
  get itemLabel() {
    let path = '//span[contains(@class,"eui-menu-item__label")]';
    return this.label + path;
  }
  get iconLabelCO() {
    return new CoEuiIconSvg(this.label).byAttributeContains('class', 'eui-menu-item__label-external');
  }
  get rightContent() {
    let path = '//div[contains(@class, "eui-menu-item__link-right-content")]';
    return this.currentPath + path;
  }
  get euiChipCO() {
    return new CoEuiChip(this.rightContent);
  }
  async hasTagLabel() {
    return await (await this.euiChipCO.element()).isExisting();
  }
  get tagLabelCO() {
    return new CoEuiLabel(this.euiChipCO);
  }
  get euiButtonToggleCO() {
    return new CoEuiButton(this.rightContent).byAttributeContains('class', 'eui-menu-item__link-toggle');
  }
  async hasChildren() {
    return await (await this.euiButtonToggleCO.element()).isExisting();
  }
  get iconExpandedCO() {
    return new CoEuiIconSvg(this.euiButtonToggleCO).byAttributeContains('icon', 'eui-chevron-up');
  }
  async itemIsExpanded() {
    return await (await this.iconExpandedCO.element()).isExisting();
  }
  get iconCollapseCO() {
    return new CoEuiIconSvg(this.euiButtonToggleCO).byAttributeContains('icon', 'eui-chevron-down');
  }
}


