import Component from '../../component.js'
import { elementAttributeContains } from '../../../core/utils.js'
import CoEuiChip from './eui-chip.js'
import CoEuiButton from './eui-button.js'

export default class CoEuiMenuItem extends Component {
    constructor(parent) {
    let selector = 'eui-menu-item';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/components/eui-menu/eui-menu-item.component.html
  }
  get categoryListItem() {
    let path = '//li[contains(@class,"eui-menu-item__category")]';
    return this.currentPath + path;
  }
  async isDisabledCategoryList() {
    return await elementAttributeContains(this.categoryListItem, 'class', 'eui-menu-item--disabled');
  }
  get categoryIcon() {
    let path = '//span[contains(@class,"eui-menu-item__category-icon")]';
    return this.categoryListItem + path;
  }
  async hasCategoryIconDefault() {
    return await elementAttributeContains(this.categoryIcon, 'class', 'eui-menu-item__category-icon--default');
  }
  async hasCategoryIconNone() {
    return await elementAttributeContains(this.categoryIcon, 'class', 'eui-menu-item__category-icon--none');
  }
  get categoryLabel() {
    let path = '//span[contains(@class,"eui-menu-item__category-label")]';
    return this.categoryListItem + path;
  }
  get categoryItemLabel() {
    let path = '//span[contains(@class,"eui-menu-item__label")]';
    return this.categoryLabel + path;
  }
  get listItem() {
    let path = '//li[contains(@class,"eui-menu-item") and not(contains(@class,"eui-menu-item__category"))]';
    return this.currentPath + path;
  }
  async isExpandedList() {
    return await elementAttributeContains(this.listItem, 'class', 'eui-menu-item--expanded');
  }
  get link() {
    let path = '//a[contains(@class,"eui-menu-item__link")]';
    return this.listItem + path;
  }
  async isLinkDisabled() {
    return await elementAttributeContains(this.link, 'class', 'eui-menu-item--disabled');
  }
  async isLinkActive() {
    return await elementAttributeContains(this.link, 'class', 'eui-menu-item__link--active');
  }
  get linkIcon() {
    let path = '//span[contains(@class,"eui-menu-item__link-icon")]';
    return this.link + path;
  }
  async hasLinkIconDefault() {
    return await elementAttributeContains(this.linkIcon, 'class', 'eui-menu-item__link-icon--default');
  }
  async hasLinkIconNone() {
    return await elementAttributeContains(this.linkIcon, 'class', 'eui-menu-item__link-icon--none');
  }
  get linkMarker() {
    let path = '//span[contains(@class,"eui-menu-item__link-marker")]';
    return this.link + path;
  }
  async hasMarker() {
    return await (await $(this.linkMarker)).isExisting();
  }
  get linkLabel() {
    let path = '//span[contains(@class,"eui-menu-item__link-label")]';
    return this.link + path;
  }
  async isDisabledLinkLabel() {
    return await elementAttributeContains(this.linkLabel, 'class', 'eui-menu-item--disabled');
  }
  get itemLabel() {
    let path = '//span[contains(@class,"eui-menu-item__label")]';
    return this.linkLabel + path;
  }
  get externalLabel() {
    let path = '//span[contains(@class,"eui-menu-item__label-external")]';
    return this.linkLabel + path;
  }
  async hasUrlExternal() {
    return await (await $(this.externalLabel)).isExisting();
  }
  get linkRightContent() {
    let path = '//div[contains(@class,"eui-menu-item__link-right-content")]';
    return this.link + path;
  }
  get euiChipCO() {
    return new CoEuiChip(this.linkRightContent);
  }
  async hasTagLabel() {
    return await (await $(this.euiChipCO.currentPath)).isExisting();
  }
  get tagLabel() {
    let path = '//span';
    return this.euiChipCO.currentPath + path;
  }
  get euiButtonToggleCO() {
    return new CoEuiButton(this.linkRightContent).byAttributeContains('class','eui-menu-item__link-toggle');
  }
  async hasChildren() {
    return await (await $(this.euiButtonToggleCO.currentPath)).isExisting();
  }
  get icon() {
    let path = '//span[contains(@class,"eui-icon")]';
    return this.euiButtonToggleCO.currentPath + path;
  }
  async isExpandedIcon() {
    return await (await $(this.euiChipCO.currentPath)).isExisting();
  }
  get angleDownIcon() {
    let path = '//span[contains(@class,"eui-icon-angle-down")]';
    return this.euiButtonToggleCO.currentPath + path;
  }
  get angleUpIcon() {
    let path = '//span[contains(@class,"eui-icon-angle-up")]';
    return this.euiButtonToggleCO.currentPath + path;
  }
}


