import Component  from '../component.js'
import CoEuiChipListAppendContent from './eui-chip-list-append-content.js'
import CoEuiChipListChipContainer from './eui-chip-list-chip-container.js'
import CoEuiChipListCustom from './eui-chip-list-custom.js'
import CoEuiChipListExpandButton from './eui-chip-list-expand-button.js'

export default class CoEuiChipList extends Component {
    constructor(parent) {
      let selector = '*[self::eui-chip-list or self::div[@euiChipList] or self::ul[@euiChipList]]';
      super(parent, selector);
      // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-chip-list/eui-chip-list.component.html
    }
    get container() {
      return this.currentPath + '//div[contains(@class,"eui-chip-list-container")]';
    }
    get wrapper() {
      return this.container + '//div[contains(@class,"eui-chip-list-wrapper")]';
    }
    get chipListList() {
      return this.wrapper + '//div[contains(@class,"eui-chip-list__list")]';
    }
    get chipListContainerCO() {
      return new CoEuiChipListChipContainer(this.chipListList);
    }
    get euiChipListAppendContentCO() {
      return new CoEuiChipListAppendContent(this.chipListList);
    }
    get expandButtonWrapperCO() {
      return new CoEuiChipListExpandButton(this.container);
    }
    get gridContainer(){
      let path = '//div[contains(@class,"eui-chip-list-container")]';
      return this.currentPath + '//descendant::div[contains(@class,"eui-chip-list__group")]//ancestor::' + path;  
    }
    async isGrid() {
      return await (await $(this.gridContainer)).isExisting();
    }
    get gridWrapper() {
      return this.gridContainer + '//div[contains(@class,"eui-chip-list-wrapper")]';
    }
    get group() {
      return this.currentPath + '//div[contains(@class,"eui-chip-list__group")]';
    }
    get euiChipListCustomCO() {
      return new CoEuiChipListCustom(this.group);
    }
    get euiChipListAppendContentGroupCO() {
      return new CoEuiChipListAppendContent(this.group);
    }
    get euiChipListAppendContentCustomCO() {
      return new CoEuiChipListAppendContent(this.currentPath);
    }
    get expandButtonWrapperGridCO() {
      return new CoEuiChipListExpandButton(this.gridContainer);
    }
}


