import CoEuiIconSvg from './eui-icon-svg.js';
import Component from '../component.js';
import CoEuiDropdown from './eui-dropdown.js';
import CoEuiLanguageSelectorMenuItem from './eui-language-selector-menu-item.js';
import ButtonComponent from '../button.js';
import SpanComponent from '../span.js';
import DivComponent from '../div.js';

export default class CoEuiLanguageSelector extends Component {
  constructor(parent) {
    let selector = 'eui-language-selector';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-language-selector/language-selector.component.html?at=refs%2Fheads%2Fmaster
  }
  get buttonCO() {
    return new ButtonComponent(this.currentPath).addPredicateClassContains('eui-language-selector-button');
  }
  get iconCO() {
    return new CoEuiIconSvg(this.buttonCO).addPredicateIconContains('eui-ecl-language');
  }
  get languageCodeCO() {
    return new SpanComponent(this.buttonCO).addPredicateClassContains('eui-language-selector-button__language-code');
  }

  get dropdownCO() {
    return new CoEuiDropdown(this.currentPath);
  }
  get dropdownButtonCO() {
    return new ButtonComponent(this.dropdownCO).addPredicateClassContains('eui-language-selector-button');
  }
  async hasLanguageSelector() {
    return await (await this.dropdownCO.element()).isExisting();
  }
  get dropdownButtonIconCO() {
    return new CoEuiIconSvg(this.dropdownButtonCO).addPredicateIconContains('eui-ecl-language');
  }
  get dropdownButtonLanguageCodeCO() {
    return new SpanComponent(this.dropdownButtonCO).addPredicateClassContains('eui-language-selector-button__language-code');
  }
  get dropdownContentCO() {
    return this.dropdownCO.dropdownContentCO;
  }
  get languageSelectorMenuCO() {
    return new DivComponent(this.dropdownContentCO).addPredicateClassContains('eui-language-selector-menu');
  }
  get languageSelectorItemCO() {
    return new CoEuiLanguageSelectorMenuItem(this.languageSelectorMenuCO);
  }
  async isShowModal() {
    return ! await (await this.dropdownCO.element()).isExisting();
  }
  async buttonModalCO() {
    if (await isShowModal()) {
      return new ButtonComponent(this.currentPath).addPredicateClassContains('eui-language-selector-button');
    }
  }
  async iconModalCO() {
    return new CoEuiIconSvg(await this.buttonModalCO());
  }
  async languageCodeModalCO() {
    return new SpanComponent(await this.buttonModalCO()).addPredicateClassContains('eui-language-selector-button__language-code');
  }
}