import Component  from '../component.js';
import DivComponent from '../div.js';
import CoEuiButton from './eui-button.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiLabel from './eui-label.js';

export default class CoEuiFieldset extends Component {
    constructor(parent) {
        let selector = 'eui-fieldset';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-fieldset/eui-fieldset.component.html?at=master
    }
    get containerCO() {
      return new DivComponent(this.currentPath).addPredicateClassContains('eui-fieldset__container');
    }
    get headerCO() {
      return new DivComponent(this.containerCO).addPredicateClassContains('eui-fieldset__header');
    }
    async hasLabel() {
        return await (await this.headerCO.element()).isExisting();
    }
    get headerLabelCO() {
        return new DivComponent(this.headerCO).addPredicateClassContains('eui-fieldset__header-label');
    }
    async isLarge() {
      return await (await $(this.headerLabelCO.currentPath + '/self::*[contains(@class,"eui-fieldset__header-label--large")]')).isExisting();
    }
    get iconClassCO() {
        return new DivComponent(this.headerLabelCO).addSelectorPredicate('[contains(@class, "eui-fieldset__header-icon") and contains(@class, "eui-icon")]');
    }
    async hasIconClass() {
        return await (await this.iconClassCO.element()).isExisting();
    }
    get iconSvgNameCO() {
      return new DivComponent(this.headerLabelCO).addSelectorPredicate('[contains(@class, "eui-fieldset__header-icon") and not(contains(@class, "eui-icon"))]');
    }
    get euiIconSvgCO() {
        return new CoEuiIconSvg(this.iconSvgNameCO);
    }
    async hasIconSvgName() {
        return await (await this.iconSvgNameCO.element()).isExisting();
    }
    get defaultIconCO(){
        return new DivComponent(this.headerLabelCO).byChildSelector('eui-icon-svg[@icon="iconSvgType"]');
    }
    get euiIconSvgTypeCO(){
        return new CoEuiIconSvg(this.defaultIconCO).addPredicateIconContains('eui-info');
    }
    async hasDefaultIcon() {
      return await (await this.euiIconSvgTypeCO.element()).isExisting();
    }
    get labelCO(){
      return new CoEuiLabel(this.headerLabelCO);
    }
    get euiFieldsetLabelExtraContent(){
      return this.headerLabelCO.currentPath + "//euiFieldsetLabelExtraContent";
    }
    get headerRightContentCO() {
      return new DivComponent(this.headerCO).addPredicateClassContains('eui-fieldset__header-right-content');
    }
    get euiFieldsetLabelRightContent(){
      return this.headerRightContentCO.currentPath + "//euiFieldsetLabelRightContent";
    }
    get expandToggleButtonCO() {
        return new CoEuiButton(this.headerRightContentCO).addPredicateClassContains('eui-fieldset__header-expand-toggle');
    }
    async isExpandable() {
        return await (await this.expandToggleButtonCO.element()).isExisting();
    }
    get forwardIconSvgCO() {
        return new CoEuiIconSvg(this.expandToggleButtonCO).addPredicateClassContains('eui-chevron-forward');
    }
    get contentCO() {
      return new DivComponent(this.containerCO).addPredicateClassContains('eui-fieldset__content');
    }
    async isExpanded() {
        return await (await this.contentCO.element()).isExisting();
    }
}


