import Component from '../component.js';
import { elementAttributeContains } from '../../core/utils.js';
import CoEuiButton from './eui-button.js';
import DivComponent from '../div.js';
import SpanComponent from '../span.js';

export default class CoEuiAppSidebarHeaderUserProfile extends Component {
  constructor(parent) {
    let selector = 'eui-app-sidebar-header-user-profile';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-app/eui-app-sidebar/sidebar-header-user-profile/sidebar-header-user-profile.component.html?at=refs%2Fheads%2Fmaster
  }
  get contentCO() {
    return new DivComponent(this.currentPath).byClassContains('eui-app-sidebar-header-user-profile-content');
  }
  get avatarCO() {
    return new DivComponent(this.contentCO).byClassContains('eui-user-profile__avatar');
  }
  async isOnline() {
    return await elementAttributeContains(this.avatarCO.currentPath, 'class', 'eui-user-profile__avatar--online');
  }
  get infosCO() {
    return new DivComponent(this.contentCO).byClassContains('eui-user-profile__infos');
  }
  get infosWrapperCO() {
    return new DivComponent(this.infosCO).byClassContains('eui-user-profile__infos-wrapper');
  }
  get infosWelcomeLabelCO() {
    return new DivComponent(this.infosWrapperCO).byClassContains('eui-user-profile__infos-welcome');
  }
  async hasWelcomeLabel() {
    return await (await this.infosWelcomeLabelCO.element()).isExisting();
  }
  get infosContainer() {
    let path = '//div[contains(@class,"eui-user-profile__infos-welcome")]/following-sibling::div[contains(@class,"eui-user-profile__infos-container")]';
    return this.infosWrapperCO + path;
  }
  get userInfosCO() {
    return new SpanComponent(this.infosContainer).byClassContains('eui-user-profile__infos-name');
  }
  get infosContainerImpersonationWelcome() {
    let path = '//span[contains(@class,"eui-user-profile__infos-welcome"]//ancestor::div[contains(@class,"eui-user-profile__infos-container")]';
    return this.infosWrapper + path;
  }
  get welcomeLabelUserImpersonatedCO() {
    return new SpanComponent(this.infosContainerImpersonationWelcome).byClassContains('eui-user-profile__infos-welcome');
  }
  async hasWelcomeLabelUserImpersonated() {
    return await (await this.welcomeLabelUserImpersonatedCO.element()).isExisting();
  }
  get userInfosUserImpersonated() {
    let path = '//strong/ancestor::span[contains(@class,"eui-user-profile__infos-welcome")]';
    return this.infosContainerImpersonationWelcome + path;
  }
  get infosContainerImpersonate() {
    let path = '//div[contains(@class,"eui-user-profile__infos-container")]/following-sibling::div[contains(@class,"eui-user-profile__infos-container")]/';
    return this.infosWrapper + path;
  }
  get impersonatedLabel() {
    return new SpanComponent(this.infosContainerImpersonate).byClassContains('eui-user-profile__infos-impersonating');
  }
  get impersonatedUserInfos() {
    return new SpanComponent(this.infosContainerImpersonate).byClassContains('eui-user-profile__infos-name');
  }
  get infosSubinfosCO() {
    return new DivComponent(this.infos).byClassContains('eui-user-profile__infos-subinfos');
  }
  async hasUserSubInfos() {
    return await (await this.infosSubinfosCO.element()).isExisting();
  }
  get euiButtonToggleCO() {
    return new CoEuiButton(this.content).byAttributeContains('class', 'eui-user-profile__toggle');
  }
  get toggleIconCO() {
    return new SpanComponent(this.euiButtonToggleCO).byClassContains('eui-icon');
  }
  async hasIconAngleUp() {
    return await elementAttributeContains(this.toggleIconCO.currentPath, 'class', 'eui-icon-angle-up');
  }
  async hasIconAngleDown() {
    return await elementAttributeContains(this.toggleIconCO.currentPath, 'class', 'eui-icon-angle-down');
  }
}