import Component  from '../component.js';
import UlComponent from '../ul.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiToolbarMenuItemSubChild from './eui-toolbar-menu-item-sub-child.js';

export default class CoEuiToolbarMenuItemChild extends Component {
  constructor(parent) {
    let selector = 'li[contains(@class, "child")]';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-toolbar/toolbar-menu/toolbar-menu.component.html
  }
  get tabIndexLink() {
    return this.currentPath + '//a[not(@routerLink)]';
  }
  async tabIndexLinkIsDisabled() {
    return await elementAttributeContains(this.tabIndexLink, 'class', 'disabled');
  }
  get tabIndexLinkIcon() {
    return this.tabIndexLink + '//span[contains(@class, "eui-icon") and contains(@class, "eui-toolbar-menu-item__icon")]';
  }
  async hasTabIndexLinkIcon() {
    return await (await $(this.tabIndexLinkIcon)).isExisting();
  }
  get tabIndexLinkSvgIconCO() {
    return new CoEuiIconSvg(this.tabIndexLink).byAttributeContains('class', 'eui-toolbar-menu-item__icon');
  }
  get tabIndexLinkLabel() {
    return this.tabIndexLink + '//span[contains(@class, "eui-toolbar-menu-item__label")]';
  }
  get routerLink() {
    return this.currentPath + '//a[@routerLink]';
  }
  async routerLinkIsDisabled() {
    return await elementAttributeContains(this.routerLink, 'class', 'disabled');
  }
  async hasSubLinkUrl() {
    return await (await $(this.routerLink)).isExisting();
  }
  get routerLinkIcon() {
    return this.routerLink + '//span[contains(@class, "eui-icon") and contains(@class, "eui-toolbar-menu-item__icon")]';
  }
  get routerLinkSvgIconCO() {
    return new CoEuiIconSvg(this.routerLink).byAttributeContains('class', 'eui-toolbar-menu-item__icon');
  }
  get routerLinkLabel() {
    return this.routerLink + '//span[contains(@class, "eui-toolbar-menu-item__label")]';
  }
  get childrenUlShowCO() {
    return new UlComponent(this.currentPath).byAttributeContains('class', 'show');
  }
  get children() {
    return new CoEuiToolbarMenuItemSubChild(this.childrenUlShowCO);
  }
  async hasChildren() {
    return await(await this.children.element()).isExisting();
  }
}


