import Component from '../component.js'
import CoEuiButton from './eui-button.js'
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiInputGroup from './eui-input-group.js';
import CoEuiInputText from './eui-input-text.js';
import DivComponent from '../div.js';
import CoEuiAutocomplete from './eui-autocomplete.js';
import CoEuiIcon from './eui-icon.js';

export default class CoEuiSearch extends Component {
  constructor(parent) {
    let selector = 'eui-search';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-search/search.component.html
  }
  get inputGroupCO() {
    return new CoEuiInputGroup(this.currentPath);
  }
  get inputAddonCO() {
    return new DivComponent(this.inputGroupCO).addPredicateClassContains('eui-input-group-addon');
  }
  get autocompleteCO() {
    return new CoEuiAutocomplete(this.inputAddonCO);
  }
  async isAutocomplete() {
    return await (await this.autocompleteCO.element()).isExisting();
  }
  get searchInputCO() {
    return new CoEuiInputText(this.inputAddonCO);
  }
  get buttonSearchCO() {
    return new CoEuiButton(this.inputAddonCO).addPredicateClassContains('eui-search__input-button');;
  }
  get buttonIconSearchCO() {
    return new CoEuiIcon(this.buttonSearchCO).addPredicateIconContains('eui-icon-search');
  }
  async hasSearchButton() {
    return await (await this.buttonSearchCO.element()).isExisting();
  }
  get searchIconDivCO() {
    return new DivComponent(this.inputAddonCO).addPredicateClassContains('eui-search__icon');
  }
  get searchIconCO() {
    return new CoEuiIconSvg(this.searchIconDivCO);
  }
}


