import Component  from '../component.js'
import { elementAttributeContains } from '../../core/utils.js'


export default class CoEuiUserProfileContent extends Component {
    constructor(parent) {
        let selector = 'div[contains(@class, "eui-user-profile-content")]';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/layout/eui-user-profile/user-profile.component.html
    }
    get infos(){
        return this.currentPath + '//div[contains(@class,"eui-user-profile__infos")]';
    }
    async hasNoSubInfos() {
        return await elementAttributeContains(this.infos, 'class', 'eui-user-profile__infos--no-subinfos');
    }

    get impersonatedInfosWelcome() {
        let selector = 'div[contains(@class,"eui-user-profile__infos-welcome")]'
        return this.infos + '//'+ selector + '/descendant::strong/ancestor::'+ selector + '[1]';
    }
    async hasImpersonatedUserInfos(){
        return await (await $(this.impersonatedUserInfos)).isExisting();
    }
    get impersonatedInfosWelcomeLabel() {
        return this.impersonatedInfosWelcome + '//span';
    }
    async hasWelcomeLabel() {
        return await (await $(this.impersonatedInfosWelcomeLabel)).isExisting();
    }
    get impersonatedUserInfos(){
        return this.impersonatedInfosWelcome + '//strong';
    }
    get impersonatedInfosName(){
        return this.impersonatedInfosWelcome + '/following-sibling::div[contains(@class, "eui-user-profile__infos-name")]';
    }
    get impersonatedSubInfos(){
        return this.impersonatedInfosWelcome + '/following-sibling::div[contains(@class, "eui-user-profile__infos-subinfos")]';
    }
    get infosWelcome() {
        return this.infos + '//div[contains(@class,"eui-user-profile__infos-welcome")][not(strong)]';
    }
    get infosName(){
        return this.infosWelcome + '/following-sibling::div[contains(@class, "eui-user-profile__infos-name")]';
    }
    get subInfos(){
        return this.infosWelcome + '/following-sibling::div[contains(@class, "eui-user-profile__infos-subinfos")]';
    }
    get avatarShadow() {
        return this.currentPath + '//div[contains(@class,"eui-user-profile__avatar-shadow")]';
    }
    get defaultAvatar() {
        return this.avatarShadow + '//div[contains(@class,"eui-u-svg--default-avatar")]';
    }
    get avatar() {
        return this.currentPath + '//span[contains(@class,"eui-user-profile__avatar")]';
    }
    async avatarOnline() {
        return await elementAttributeContains(this.avatar, 'class', 'eui-user-profile__avatar--online');
    }
    async avatarOffline() {
        return await elementAttributeContains(this.avatar, 'class', 'eui-user-profile__avatar--offline');
    }
    get avatarUrl() {
        return this.currentPath + '//div[contains(@class,"eui-user-profile__avatar") and contains(@class,"eui-u-svg")]';
    }
    async hasAvatarUrl() {
         return await (await $(this.avatarUrl)).isExisting();
    }
    get avatarImage() {
        return this.avatarUrl + '//img';
    }
}

