import Component from '../component.js';
import CoEuiButton from './eui-button.js';
import CdkOverlayContainer from '../cdk-overlay-container.js';
import DivComponent from '../div.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import OptionComponent from '../option.js';
import CoEuiSelect from './eui-select.js';

export default class CoEuiPaginator extends Component {
  constructor(parent) {
    let selector = 'eui-paginator';
    super(parent, selector);
    this.overlayContainer = new CdkOverlayContainer('//body');
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-paginator/eui-paginator.component.html?at=master
  }

  get pageDivCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-paginator__page');
  }
  async hasPaginatorPage() {
    return await (await this.pageDivCO.element()).isExisting();
  }
  get pageSelectorDivCO() {
    return new DivComponent(this.pageDivCO).addPredicateClassContains('eui-paginator__page-selector');
  }
  get itemsPerPagepaDivCO() {
    return new DivComponent(this.pageSelectorDivCO).addSelectorPredicate('[not(contains(@class, "eui-u-pl-xs"))]');
  }
  get itemsSelectDivCO() {
    return new DivComponent(this.pageSelectorDivCO).addPredicateClassContains('eui-u-pl-xs');
  }
  get selectItemCO() {
    return new CoEuiSelect(this.itemsSelectDivCO).addPredicateClassContains('page-size__select');
  }
  get optionCO() {
    return new OptionComponent(this.selectItemCO);
  }
  get pageRangeCO() {
    return new DivComponent(this.pageDivCO).addPredicateClassContains('eui-paginator__page-range-main');
  }
  async hasPageRange() {
    return await (await this.pageRangeCO.element()).isExisting();
  }
  get navigatorDivCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-paginator__page-navigation');
  }
  async hasNavigator() {
    return await (await this.navigatorDivCO.element()).isExisting();
  }
  get firstNavigationItemDivCO() {
    return new DivComponent(this.navigatorDivCO).addPredicateClassContains('eui-paginator__page-navigation-item').addSelectorPredicate('[1]');
  }
  get caretFirstButtonCO() {
    return new CoEuiButton(this.firstNavigationItemDivCO);
  }
  get caretFirstIconCO() {
    return new CoEuiIconSvg(this.caretFirstButtonCO).addPredicateIconContains('play-skip-back');
  }
  get secondNavigationItemDivCO() {
    return new DivComponent(this.navigatorDivCO).addPredicateClassContains('eui-paginator__page-navigation-item').addSelectorPredicate('[2]');
  }
  get caretLeftButtonCO() {
    return new CoEuiButton(this.secondNavigationItemDivCO);
  }
  get caretLeftIconCO() {
    return new CoEuiIconSvg(this.caretLeftButtonCO).addPredicateIconContains('play:sharp');
  }
  get navigationNumbersDivCO() {
    return new DivComponent(this.navigatorDivCO).addPredicateClassContains('eui-paginator__page-navigation-numbers');
  }
  async hasPageNumberNavigation() {
    return await (await this.navigationNumbersDivCO.element()).isExisting();
  }
  get goToPageButtonCO() {
    return new CoEuiButton(this.navigationNumbersDivCO);
  }
  get pageRangeLabelDivCO() {
    return new DivComponent(this.navigatorDivCO).addPredicateClassContains('eui-paginator__page-range');
  }
  async hasPageRangeLabel() {
    return await (await this.pageRangeLabelDivCO.element()).isExinsting();
  }
  get thirdNavigationItemDivCO() {
    return new DivComponent(this.navigatorDivCO).addPredicateClassContains('eui-paginator__page-navigation-item').addSelectorPredicate('[3]');
  }
  get caretRightButtonCO() {
    return new CoEuiButton(this.thirdNavigationItemDivCO);
  }
  get caretRightIconCO() {
    return new CoEuiIconSvg(this.caretRightButtonCO).addPredicateIconContains('play:sharp');
  }
  get fourthNavigationItemDivCO() {
    return new DivComponent(this.navigatorDivCO).addPredicateClassContains('eui-paginator__page-navigation-item').addSelectorPredicate('[4]');
  }
  get lastCaretButtonCO() {
    return new CoEuiButton(this.fourthNavigationItemDivCO);
  }
  get caretLastIconCO() {
    return new CoEuiIconSvg(this.lastCaretButtonCO).addPredicateIconContains('play-skip-forward');
  }
}


