import Component from '../component.js';
import CoEuiLabel from './eui-label.js';
import AComponent from '../a.js';

export default class CoEuiTreeNodeWrapperContainerMiddle extends Component {

  constructor(parent) {
    let selector = 'div[contains(@class,"eui-tree-node-wrapper__container-middle")]';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-tree/eui-tree.component.html?at=master
  }
 
  get labelCO() {
    return new CoEuiLabel(this.currentPath).addPredicateClassContains('eui-u-text-truncate');
  }
  async isSelected() {
    return await (await $(this.currentPath + '/self::div[contains(@class,"eui-label--selected")]')).isExisting();
  }
  async isSelectable() {
    return await (await $(this.currentPath + '/self::div[contains(@class,"eui-u-cursor-pointer")]')).isExisting();
  }
  get urlLabel() {
    return new CoEuiLabel(this.currentPath).currentPath + '/self::label[contains(@class,"eui-u-text-truncate")]//a[not(contains(@class,"eui-u-text-link-external"))]/ancestor::label'
  }
  get url() {
    return new AComponent(this.currentPath).currentPath + '/self::a[not(contains(@class,"eui-u-text-link-external"))]'
  }
  async hasUrl() {
    return await (await $(this.urlLabel)).isExisting();
  }
  get externalUrlLabelCO() {
    return new CoEuiLabel(this.currentPath).byChildSelector('a[contains(@class,"eui-u-text-link-external")]');
  }
  get externalUrl() {
    return new AComponent(this.currentPath).currentPath + '/self::a[contains(@class,"eui-u-text-link-external")]'
  }
  async hasExternalUrl() {
    return await (await $(this.externalUrl)).isExisting();
  }
}


