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';
import SpanComponent from '../span.js';
import DivComponent from '../div.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 labelCO() {
    return new SpanComponent(this.currentPath).byClassContains('eui-menu-item__link-label');
  }
  async isDisabledLinkLabel() {
    return await elementAttributeContains(this.labelCO.currentPath, 'class', 'eui-menu-item--disabled');
  }
  get itemLabelCO() {
    return new SpanComponent(this.labelCO).byClassContains('eui-menu-item__label');
  }
  get iconLabelCO() {
    return new CoEuiIconSvg(this.labelCO).byAttributeContains('class', 'eui-menu-item__label-external');
  }
  get rightContentCO() {
    return new DivComponent(this.currentPath).byClassContains('eui-menu-item__link-right-content');
  }
  get euiChipCO() {
    return new CoEuiChip(this.rightContentCO);
  }
  async hasTagLabel() {
    return await (await this.euiChipCO.element()).isExisting();
  }
  get tagLabelCO() {
    return new CoEuiLabel(this.euiChipCO);
  }
  get euiButtonActionCO() {
    return new CoEuiButton(this.rightContentCO).byAttributeContains('class', 'eui-menu-item__link-action-icon');
  }
  get iconActionCO() {
    return new CoEuiIconSvg(this.euiButtonActionCO);
  }
  get euiButtonToggleCO() {
    return new CoEuiButton(this.rightContentCO).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');
  }
}


