import Component  from '../component.js'
import CoEuiButton from './eui-button.js'
import CoEuiDropdown from './eui-dropdown.js'
import CoEuiDropdownContent from './eui-dropdown-content.js'
import CoEuiLabel from './eui-label.js'
import { elementAttributeContains } from '../../core/utils.js'
import CoEuiButtonsActionsButtons from './eui-buttons-actions-buttons.js'
import CoEuiButtonsLocalMenu from './eui-buttons-local-menu.js'
import CoEuiList from './eui-list.js'
import CoEuiIconSvg from './eui-icon-svg.js'
import CoEuiButtonsActionsMenu from './eui-buttons-actions-content.js'

export default class CoEuiButtons extends Component {
  constructor(parent) {
    let selector = 'eui-buttons';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-buttons/eui-buttons.component.html
  }
  get wrapper() {
    return this.currentPath + '//div[contains(@class, "eui-buttons-wrapper")]';
  }
  async isMobileOrTablet() {
    return await elementAttributeContains(this.wrapper, 'class', 'eui-buttons-wrapper--mobile');
  }
  get actionsContainer() {
    return this.wrapper + '//div[contains(@class, "eui-buttons__actions-container")]';
  }
  get euiButtonsActionsButtonsCO() {
    return new CoEuiButtonsActionsButtons(this.actionsContainer);
  }
  get bookmarkBtnCO() {
    return new CoEuiButton(this.actionsContainer).byChildSelector('eui-icon-svg[contains(@icon,"eui-bookmark")]');
  }
  async isNotBookmarked() {
    return await elementAttributeContains(this.euiIconCO.currentPath, 'class', 'eui-bookmark-outline');
  }
  get euiIconCO() {
    return new CoEuiIconSvg(this.bookmarkBtnCO);
  }
  get bookmarkSpan() {
    return this.bookmarkBtnCO.currentPath + '//span';
  }
  get localMenu() {
    return this.actionsContainer + '//div[contains(@class, "eui-buttons__local-menu")]';
  }
  async isLocalMenuMobile() {
    return await elementAttributeContains(this.localMenu, 'class', 'eui-buttons__local-menu--mobile');
  }
  get euiDropdownCO() {
    return new CoEuiDropdown(this.localMenu);
  }
  get euiButtomCOinDropdown() {
    return new CoEuiButton(this.euiDropdownCO.currentPath);
  }
  get euiLabelCO() {
    return new CoEuiLabel(this.euiButtomCOinDropdown.currentPath);
  }
  get euiIconMoreVerticalCO() {
    return new CoEuiIconSvg(this.euiButtomCOinDropdown.currentPath).byAttributeContains('iconClass', 'eui-icon-more-vertical');
  }
  get euiDropdownContentCO() {
    return new CoEuiDropdownContent(this.euiDropdownCO.currentPath);
  }
  get euiButtonsActionsButtonsCOinDropdownContent() {
    return new CoEuiButtonsActionsButtons(this.euiDropdownContentCO.currentPath);
  }
  get euiButtonsLocalMenuCOinDropdownContent() {
    return new CoEuiButtonsLocalMenu(this.euiDropdownContentCO.currentPath);
  }
  get euiListCO() {
    return new CoEuiList(this.euiDropdownContentCO.currentPath).byAttributeContains('class', 'eui-buttons__local-menu-extras');
  }
  get listItemCO() {
    return this.euiListCO.euiListItemCO;
  }
  get euiIconSvgExtraMenuCO() {
    return new CoEuiIconSvg(this.listItemCO.currentPath).byAttributeContains('icon', 'eui-bookmark');
  }
  async isBookmarked() {
    return await (await this.euiIconSvgExtraMenuCO.element()).isExisting();
  }
  get notBookmarkedCO() {
    return new CoEuiIconSvg(this.listItemCO.currentPath).byAttributeContains('icon', 'eui-bookmark-outline');
  }
  get bookmarkedSpanExtraMenu(){
    return this.currentPath + '//div[contains(@class, "eui-buttons__actions-content")]';
  }
  get actionButtonsCO(){
    return new CoEuiButtonsActionsMenu(this.bookmarkedSpanExtraMenu);
  }
  get localMenuButtonsContainer(){
    return this.currentPath + '//div[contains(@class, "eui-buttons__local-menu-content")]';
  }
  get localMenuButtonsCO(){
    return new CoEuiButtonsLocalMenu(this.currentPath);
  }
}


