import Component from '../../component.js'
import CoUxAlabel from './ux-a-label.js'
import { elementAttributeContains } from '../../../core/utils.js'

export default class CoUxTreeListItem extends Component {
    constructor(parent) {
      let selector = 'ux-tree-list-item';
      super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-tree-list/ux-tree-list-item.component.html
    }
    get dataE2E() {
      let path = '//div[@data-e2e="ux-tree-list-item"]';
      return this.currentPath + path;
    }
    async isActive() {
      return await elementAttributeContains(this.dataE2E, 'class', 'ux-tree-list-item--active');
    }
    async isHidden() {
      return await (await $(this.dataE2E + '/self::div[@hidden]')).isExisting();
    }
    get header() {
      let path = '//div[contains(@class,"ux-tree-list-item-header")]';
      return this.dataE2E + path;
    }
    get headerContent() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content")]';
      return this.header + path;
    }
    get customContentPlaceholder() {
      let path = '//uxTreeListItemCustomContent';
      return this.header + path;
    }
    async hasCustomContent() {
      return await (await $(this.customContentPlaceholder)).isExisting();
    }
    get headerContentRightContent() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content-right-content")]';
      return this.headerContent + path;
    }
    get rightContentPlaceholder() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__content-right-content-sub")]';
      return this.headerContentRightContent + path;
    }
    get headerContentExpandToggleWrapper() {
      let path = '//span[contains(@class, "ux-tree-list-item-header__content-expand-toggle-wrapper")]';
      return this.headerContentRightContent + path;
    }
    get headerContentExpandToggle() {
      let path = '//span[contains(@class, "ux-tree-list-item-header__content-expand-toggle")]';
      return this.headerContentExpandToggleWrapper + path;
    }
    get expandToggleIcon() {
      let path = '//span[contains(@class, "ux-icon")] ';
      return this.headerContentExpandToggle + path;
    }
    async isHeaderContentExpanded() {
      return await (await $(this.expandToggleIcon + '/self::span[contains(@class, "ux-icon-angle-down")]')).isExisting();
    }
    get alabelCO() {
      return new CoUxAlabel(this.headerContent);
    }
    get customSubLabelPlaceholder() {
      return this.alabelCO.customSubLabelPlaceholder;
    }
    get uxTreeListItemSubLabelPlaceholder() {
      let path = '//uxTreeListItemSubLabel';
      return this.alabelCO.customSubLabelPlaceholder + path;
    }
    async hasCustomSubLabel() {
      return await (await $(this.uxTreeListItemSubLabelPlaceholder)).isExisting();
    }

    get customDetailContent() {
      let path = '//div[contains(@class, "ux-tree-list-item-header__details-content")]';
      return this.header + path;
    }
    async hasCustomDetailContent() {
      return await (await $(this.customDetailContentPlaceholder)).isExisting();
    }
    get customDetailContentPlaceholder() {
      let path = '//uxtreelistitemdetailscontent';
      return this.header + path;
    }
    get customSubContainerContentPlaceholder() {
      let path = '//uxtreelistitemsubcontainercontent';
      return this.header + path;
    }
    async hasCustomSubContainerContentPlaceholder() {
      return await (await $(this.customSubContainerContentPlaceholder)).isExisting();
    }
    async isExpanded() {
      return await elementAttributeContains(this.headerContent, 'aria-expanded', 'true');
    }
}


