import Component from '../../component.js'

export default class CoUxAtoolbarFilter extends Component {
    constructor(parent) {

      let selector = 'ux-a-toolbar-filter';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/atomic/ux-a-toolbar-filter/ux-a-toolbar-filter.component.html?at=support/10.x
    }
    get dataE2E() {
      let path = '/div[@data-e2e="ux-a-toolbar-filter"]';
      return this.currentPath + path;
    }
    async isVisible() {
      return await (await $(this.dataE2E)).isExisting();
    }
    get filterContent() {
      let path = '//div[contains(@class, "ux-a-toolbar-filter-content")]';
      return this.dataE2E + path;
    }
    get toolbarFilter() {
      let path = '//div[contains(@class, "ux-a-toolbar-filter-filter")]';
      return this.filterContent + path;
    }
    get inputGroup() {
      let path = '//div[contains(@class, "ux-input-group")]';
      return this.toolbarFilter + path;
    }
    get inputGroupPrepend() {
      let path = '//span[contains(@class, "ux-input-group-prepend")]';
      return this.inputGroup + path;
    }
    get inputGroupTextSpan() {
      let path = '//span[contains(@class, "ux-input-group-text")]';
      return this.inputGroupPrepend + path;
    }
    get inputGroupPrependIcon() {
      let path = '//span[contains(@class, "eui-icon-search")]';
      return this.inputGroupTextSpan + path;
    }

    get inputGroupFilterInput() {
      let path = '//input[contains(@class, "ux-a-toolbar-filter-filter-input")]';
      return this.inputGroup + path;
    }
    async isToggleVisible() {
      return await (await $(this.filterContent + '//div[contains(@class, "ux-a-toolbar-filter-trigger-wrapper")]')).isExisting();
    }
    async isFilterVisible() {
      return await (await $(this.filterContent + '//div[contains(@class, "ux-a-toolbar-filter-filter")]')).isExisting();
    }
    get toolbarFilterTriggerWrapper() {
      let path = '//div[contains(@class, "ux-a-toolbar-filter-trigger-wrapper")]';
      return this.filterContent + path;
    }
    get toolbarFilterTriggerButton() {
      let path = '//button[contains(@class, "ux-a-toolbar-filter-trigger")]';
      return this.toolbarFilterTriggerWrapper + path;
    }
    get toolbarFilterTriggerButtonIcon() {
      let path = '//span[contains(@class, "eui-icon")]';
      return this.toolbarFilterTriggerButton + path;
    }
    get toolbarFilterButtonsPlaceholder() {
      let path = '//uxToolbarFilterButtons';
      return this.toolbarFilterTriggerWrapper + path;
    }
    get toolbarFilterTriggerFlex() {
      let path = '//div[contains(@class, "d-flex-none")]';
      return this.filterContent + path;
    }
    async isToggleExpanded() {
      let cl = await (await $(this.toolbarFilterTriggerButtonIcon)).getAttribute('class');
      if (await cl.includes('eui-icon-level-down')) {
         return false;
      } else if (await cl.includes('eui-icon-level-up')) {
         return true;
      }
    }
}


