import Component from '../component.js';
import DiVComponent from '../div.js';
import CoEuiButton from './eui-button.js';
import CoEuiIcon from './eui-icon.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiTreeNodeWrapperContainerLeft from './eui-tree-node-wrapper-container-left.js';
import CoEuiTreeNodeWrapperContainerRight from './eui-tree-node-wrapper-container-right.js';
import CoEuiTreeNodeWrapperContainerMiddle from './eui-tree-node-wrapper-container-middle.js';
import CoEuiTreeNodeMetacontent from './eui-tree-node-metacontent.js';
import CoEuiTreeNodeMetadataContainerButton from './eui-tree-node-metadata-container-button.js';
import CdkNestedTreeNode from '../cdk-nested-tree-node.js';
import UlComponent from '../ul.js';
import LiComponent from '../li.js';

export default class CoEuiTree extends Component {

  constructor(parent) {
    let selector = 'eui-tree';
    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 wrapperCO() {
    return new UlComponent(this.currentPath).addPredicateClassContains('eui-tree__wrapper');
  }
  get cdkTree()  {
    return this.wrapperCO.currentPath + '//cdk-tree[contains(@class,"eui-cdk-tree")]';
  }
  async hasRenderTree() {
    return await (await $(this.cdkTree)).isExisting();
  }
  get cdkNestedTreeNodeNoChildCO()  {
    return new CdkNestedTreeNode(this.cdkTree).addSelectorPredicate('[not (contains(@class,"eui-cdk-nested-tree-node--with-child"))]');
  }
  get treeNodeNoChildCO() {
    return new LiComponent(this.cdkNestedTreeNodeNoChild).addPredicateClassContains('eui-tree-node');
  }
  async hasTreeItemModelNoChild() {
    return await (await $(this.treeNodeNoChildCO.currentPath)).isExisting();
  }
  get treeNodeWrapperNoChildCO() {
    return new DiVComponent(this.treeNodeNoChildCO).addPredicateClassContains('eui-tree-node-wrapper');
  }
  get treeNodeWrapperContainerNoChildCO() {
    return new DiVComponent(this.treeNodeWrapperNoChildCO).addPredicateClassContains('eui-tree-node-wrapper__container');
  }
  get treeNodeWrapperContainerLeftCO() {
    return new CoEuiTreeNodeWrapperContainerLeft(this.treeNodeWrapperContainerNoChildCO);
  }
  get treeNodeWrapperContainerRightCO() {
    return new CoEuiTreeNodeWrapperContainerRight(this.treeNodeWrapperContainerNoChildCO);
  }
  get treeNodeWrapperContainerMiddleCO() {
    return new CoEuiTreeNodeWrapperContainerMiddle(this.treeNodeWrapperContainerNoChildCO);
  }
  get treeNodeMetacontentCO() {
    return new CoEuiTreeNodeMetacontent(this.treeNodeWrapperContainerNoChildCO);
  }
  get treeNodeMetadataContainerButtonCO() {
    return new CoEuiTreeNodeMetadataContainerButton(this.treeNodeWrapperContainerNoChildCO);
  }
  get cdkNestedTreeNodeWithChildCO()  {
    return new CdkNestedTreeNode(this.cdkTree).addPredicateClassContains('eui-cdk-nested-tree-node--with-child');
  }
  get treeNodeWithChildCO() {
    return new LiComponent(this.cdkNestedTreeNodeWithChild).addPredicateClassContains('eui-tree-node');
  }
  async hasTreeItemModelWithChild() {
    return await (await $(this.treeNodeWithChildCO.currentPath)).isExisting();
  }
  get treeNodeWrapperWithChildCO() {
    return new DiVComponent(this.treeNodeWithChildCO).addPredicateClassContains('eui-tree-node-wrapper');
  }
  get treeNodeWrapperContainerWithChildCO() {
    return new DiVComponent(this.treeNodeWrapperWithChildCO).addPredicateClassContains('eui-tree-node-wrapper__container');
  }
  get actionButtonCO() {
    return new CoEuiButton(this.treeNodeWrapperContainerWithChildCO).addPredicateClassContains('eui-u-mr-xs');
  }
  get collapsedIconCO() {
    return new CoEuiIcon(this.actionButtonCO).addPredicateAttributeContains('iconClass','collapsedIconClass');
  }
  async hasCollapsedIconClass() {
    return await (await $(this.collapsedIconCO.currentPath)).isExisting();
  }
  get expandedIconCO() {
    return new CoEuiIcon(this.actionButtonCO).addPredicateAttributeContains('iconClass','expandedIconClass')
  }
  async hasExpandedIconClass() {
    return await (await $(this.expandedIconCO.currentPath)).isExisting();
  }
  get expandedSvgIconCO() {
    return new CoEuiIconSvg(this.actionButtonCO).addPredicateIconContains('expandedSvgIconClass');
  }
  async hasExpandedSvgIconClass() {
    return await (await $(this.expandedSvgIconCO.currentPath)).isExisting();
  }
  get collapsedSvgIconCO() {
    return new CoEuiIconSvg(this.actionButtonCO).addPredicateIconContains('collapsedSvgIconClass');
  }
  async hasCollapsedSvgIconClass() {
    return await (await $(this.collapsedSvgIconCO.currentPath)).isExisting();
  }
  get treeNodeWrapperContainerLeftCO() {
    return new CoEuiTreeNodeWrapperContainerLeft(this.treeNodeWrapperContainerWithChildCO);
  }
  get treeNodeWrapperContainerRightCO() {
    return new CoEuiTreeNodeWrapperContainerRight(this.treeNodeWrapperContainerWithChildCO);
  }
  get treeNodeWrapperContainerMiddleCO() {
    return new CoEuiTreeNodeWrapperContainerMiddle(this.treeNodeWrapperContainerWithChildCO);
  }
  get treeNodeMetacontentCO() {
    return new CoEuiTreeNodeMetacontent(this.treeNodeWrapperContainerWithChildCO);
  }
  get treeNodeMetadataContainerButtonCO() {
    return new CoEuiTreeNodeMetadataContainerButton(this.treeNodeWrapperContainerWithChildCO);
  }
  get treeNodeCO() {
    return new UlComponent(this.treeNodeWithChildCO).addPredicateClassContains('eui-tree-node');
  }

}


