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

export default class CoUxAppShell extends Component {

    constructor(parent) {
      let selector = 'ux-app-shell';
      super(parent, selector);
    }
    get sideBar() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar")]';
      return this.currentPath + path;
    }

    get sideBarHeader() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar-header")]';
      return this.sideBar + path;
    }

    get sideBarHeaderToggle() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar-header-toggle")]';
      return this.sideBarHeader + path;
    }

    get sideBarHeaderToggleIcon() {
      let path = '//span[contains(@class,"ux-icon")]';
      return this.sideBarHeaderToggle + path;
    }

    async isSidebarOpen() {
      let cl = await (await $(this.sideBarHeaderToggleIcon)).getAttribute('class');
      if (cl.includes('ux-icon-times')) {
         return true;
      } else if (cl.includes('ux-icon-bars')) {
         return false;
      } else {
         throw new Error('ux-app-shell component object needs to be revised, SideBarHeaderToggleIcon is missing class');
      }
    }

    get sideBarHeaderLogo() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar-header-logo")]';
      return this.sideBarHeader + path;
    }

    get sideBarHeaderTitle() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar-header-title")]';
      return this.sideBarHeader + path;
    }

    get sideBarHeaderTitleFullAppName() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar-header-title") and contains(@class,"full")]';
      return this.sideBarHeaderTitle + path;
    }

    get sideBarHeaderTitleSmallAppName() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar-header-title") and contains(@class,"small")]';
      return this.sideBarHeaderTitle + path;
    }

    get sideBarBody() {
      let path = '//div[contains(@class,"ux-app-shell__sidebar-body")]';
      return this.sideBar + path;
    }

    get sideBarBodyItemsPlaceholder() {
      let path = '//ux-layout-sidebar-items';
      return this.sideBarBody + path;
    }

    get main() {
      let path = '//div[contains(@class,"ux-app-shell__main")]';
      return this.currentPath + path;
    }

    get mainHeader() {
      let path = '//div[contains(@class,"ux-app-shell__header")]';
      return this.main + path;
    }

    get mainHeaderTitle() {
      let path = '//div[contains(@class,"ux-app-shell__header-app-title")]';
      return this.mainHeader + path;
    }

    get mainHeaderBreadcrumbsPlaceholder() {
      let path = '//ux-layout-breadcrumbs';
      return this.mainHeader + path;
    }

    get mainHeaderProfile() {
      let path = '//div[contains(@class,"ux-app-shell__header-profile")]';
      return this.mainHeader + path;
    }

    get mainHeaderProfileWrapper() {
      let path = '//div[contains(@class,"profile-wrapper")]';
      return this.mainHeaderProfile + path;
    }

    get mainHeaderProfileWrapperUserInfos() {
      let path = '//div[contains(@class,"profile-user-infos")]';
      return this.mainHeaderProfileWrapper + path;
    }

    get mainHeaderProfileWrapperUserInfosMessage() {
      let path = '/div/span';
      return this.mainHeaderProfileWrapperUserInfos + path;
    }

    get mainHeaderProfileWrapperUserInfosUserName() {
      let path = '//strong/span';
      return this.mainHeaderProfileWrapperUserInfos + path;
    }

    get mainHeaderProfileWrapperAvatar() {
      let path = '//div[contains(@class,"profile-avatar")]';
      return this.mainHeaderProfileWrapper + path;
    }

    get mainHeaderProfileWrapperAvatarConnectedState() {
      let path = '//div[contains(@class,"profile-avatar")]//span[contains(@class,"ion-social-rss")]';
      return this.mainHeaderProfileWrapperAvatar + path;
    }

    get mainHeaderProfileWrapperAvatarConnectedStateTitle() {
      let path = '@title';
      return this.mainHeaderProfileWrapperAvatarConnectedState + path;
    }

    async isConnected() {
      let cl = await (await $(this.mainHeaderProfileWrapperAvatarConnectedState)).getAttribute('class');
      if (cl.includes('ux-u-color-success')) {
         return true;
      } else if (cl.includes('ux-u-color-danger')) {
         return false;
      } else {
         throw new Error('ux-app-shell component object needs to be revised, ' +
         'MainHeaderProfileWrapperAvatarConnectedState is missing class');
      }
    }

    get mainHeaderProfileWrapperAvatarAvailableState() {
      let path = '//div[contains(@class,"profile-avatar")]//span[contains(@class,"ux-icon-circle")]';
      return this.mainHeaderProfileWrapperAvatar + path;
    }

    get mainHeaderProfileWrapperAvatarAvailableStateTitle() {
      let path = '@title';
      return this.mainHeaderProfileWrapperAvatarAvailableState + path;
    }

    async isOnline() {
      let cl = await (await $(this.mainHeaderProfileWrapperAvatarAvailableState)).getAttribute('class');
      if (cl.includes('ux-u-color-success')) {
         return true;
      } else if (cl.includes('ux-u-color-danger')) {
         return false;
      } else {
         throw new Error('ux-app-shell component object needs to be revised, ' +
         'MainHeaderProfileWrapperAvatarAvailableState is missing class');
      }
    }

    get mainHeaderProfileWrapperToggle() {
      let path = '//div[contains(@class,"profile-toggle")]';
      return this.mainHeaderProfileWrapper + path;
    }

    get mainHeaderProfileWrapperToggleIcon() {
      let path = '//span[contains(@class,"ux-icon")]';
      return this.mainHeaderProfileWrapperToggle + path;
    }

    async isProfileDropdownVisible() {
      let cl = await (await $(this.mainHeaderProfileWrapperToggleIcon)).getAttribute('class');
      if (cl.includes('ux-icon-angle-up')) {
         return true;
      } else if (cl.includes('ux-icon-angle-down')) {
         return false;
      } else {
         throw new Error('ux-app-shell component object needs to be revised, ' +
         'MainHeaderProfileWrapperToggleIcon is missing class');
      }
    }

    get mainHeaderProfileWrapperProfileMenuPlaceholder() {
      let path = '//ux-app-shell-header-profile-menu';
      return this.mainHeaderProfileWrapper + path;
    }

    get mainHeaderProfileActions() {
      let path = '//div[contains(@class,"ux-app-shell__header-actions")]';
      return this.mainHeaderProfile + path;
    }

    get mainHeaderProfileActionsPlaceholder() {
      let path = '//ux-app-shell-header-actions';
      return this.mainHeaderProfileActions + path;
    }

    get mainHeaderProfileActionsLanguageActionItem() {
      let path = '//div[contains(@class,"language-action-item")]';
      return this.mainHeaderProfileActions + path;
    }

    get mainHeaderProfileActionsLanguageActionItemLanguageSelectorPlaceholder() {
      let path = '//ux-language-selector"]';
      return this.mainHeaderProfileActions + path;
    }

    get mainHeaderProfileActionsNavBarActionItemPlaceholder() {
      let path = '//ux-layout-nav-bar-action-item"]';
      return this.mainHeaderProfileActions + path;
    }

    get mainTopMessageContent() {
      let path = '//div[contains(@class,"ux-app-shell__top-message-content")]';
      return this.main + path;
    }

    get mainTopMessageContentMessagePlaceholder() {
      let path = '//ux-app-shell-top-message';
      return this.main + path;
    }

    get mainContent() {
      let path = '//div[contains(@class,"ux-app-shell__main-content")]';
      return this.main + path;
    }

    get growlPlaceholder() {
      let path = '/ancestor::*[1]/eui-growl';
      return this.currentPath + path;
    }

    get blockDocumentPlaceholder() {
      let path = '/ancestor::*[1]/ux-block-document';
      return this.currentPath + path;
    }

    get feedback() {
      let path = '/ancestor::*[1]/div[contains(@class,"ux-app-shell__feedback")]';
      return this.currentPath + path;
    }

    get eclSvgDefinitionsPlaceholder() {
      let path = '/ancestor::*[1]/ecl-svg-definitions';
      return this.currentPath + path;
    }
}
