import Component from '../component.js';
import DivComponent from '../div.js';
import CoEuiButton from './eui-button.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CdkNestedTreeNode from '../cdk-nested-tree-node.js';
import CoEuiTreeNodeTemplate from './eui-tree-node-template.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 DivComponent(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 DivComponent(this.cdkNestedTreeNodeNoChildCO).addPredicateClassContains('eui-tree-node');
  }
  async hasTreeItemModelNoChild() {
    return await (await this.treeNodeNoChildCO.element()).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 treeNodeTemplateDefaultCO(){
    return new CoEuiTreeNodeTemplate(this.treeNodeWrapperContainerNoChildCO);
  }
  get cdkNestedTreeNodeWithChildCO()  {
    return new CdkNestedTreeNode(this.cdkTree).addPredicateClassContains('eui-cdk-nested-tree-node--with-child');
  }
  get treeNodeWithChildCO() {
    return new DivComponent(this.cdkNestedTreeNodeWithChildCO).addPredicateClassContains('eui-tree-node--with-child');
  }
  async hasTreeItemModelWithChild() {
    return await (await this.treeNodeWithChildCO.element()).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-tree-node__button');
  }
  get collapsedIconCO() {
    return new CoEuiIconSvg(this.actionButtonCO).addPredicateIconContains('expandedSvgIconClass');
  }
  async hasCollapsedIconClass() {
    return await (await this.collapsedIconCO.element()).isExisting();
  }
  get expandedIconCO() {
    return new CoEuiIconSvg(this.actionButtonCO).addPredicateIconContains('collapsedSvgIconClass')
  }
  async hasExpandedIconClass() {
    return await (await this.expandedIconCO.element()).isExisting();
  }
  get treeNodeChildTemplateDefaultCO(){
    return new CoEuiTreeNodeTemplate(this.treeNodeWrapperContainerWithChildCO);
  }
  get treeNodeCO() {
    return new DivComponent(this.treeNodeWithChildCO).addPredicateAttributeContains('role','group');
  }
}


