import Component  from '../component.js';
import DivComponent from '../div.js';
import CoEuiButton from './eui-button.js';
import CoEuiIconSvg from './eui-icon-svg.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
    }
    get container() {
        return this.currentPath + '//div[contains(@class,"eui-fieldset__container")]';
    }
    get header() {
        return this.container + '//div[contains(@class,"eui-fieldset__header")]';
    }
    async hasLabel() {
        return await (await $(this.header)).isExisting();
    }
    get headerLabel() {
        return this.header + '//div[contains(@class,"eui-fieldset__header-label")]';
    }
    get iconClass() {
        return this.headerLabel + '//div[contains(@class,"eui-fieldset__header-icon") and contains(@class, "eui-icon")]';
    }
    async hasIconClass() {
        return await (await $(this.iconClass)).isExisting();
    }
    get iconSvgName() {
        return this.headerLabel + '//div[contains(@class,"eui-fieldset__header-icon")]';
    }
    get euiIconSvgCO() {
        return new CoEuiIconSvg(this.iconSvgName);
    }
    async hasIconSvgName() {
        return await (await $(this.iconSvgName)).isExisting();
    }
    get defaultIcon(){
        return new DivComponent(this.headerLabel).byChildSelector('eui-icon-svg[contains(@class, "eui-info")]');
    }
    get euiIconSvgInfoCO(){
        return new CoEuiIconSvg(this.defaultIcon).byAttributeContains('icon', 'eui-info');
    }
    get euiIconSvgSuccessCO(){
        return new CoEuiIconSvg(this.defaultIcon).byAttributeContains('icon', 'eui-ecl-check-filled');
    }
    get euiIconSvgWarningCO(){
        return new CoEuiIconSvg(this.defaultIcon).byAttributeContains('icon', 'eui-ecl-warning');
    }
    get euiIconSvgDangerCO(){
        return new CoEuiIconSvg(this.defaultIcon).byAttributeContains('icon', 'eui-ecl-error');
    }
    get headerRightContent() {
        return this.header + '//div[contains(@class,"eui-fieldset__header-right-content")]';
    }
    async hasCustomLabelRightContent() {
        return await (await $(this.headerRightContent)).isExisting();
    }
    get expandToggleButtonCO() {
        return new CoEuiButton(this.headerRightContent).byAttributeContains('class', 'eui-fieldset__header-expand-toggle');
    }
    async isExpandable() {
        return await (await $(this.expandToggleButtonCO.currentPath)).isExisting();
    }
    get forwardIconSvgCO() {
        return new CoEuiIconSvg(this.expandToggleButtonCO).byAttributeContains('icon', 'eui-chevron-forward');
    }
    async isExpanded() {
        return await (await $(this.container + '//div[contains(@class,"eui-fieldset__content")]')).isExisting();
    }
}


