import Component  from '../component.js'
import CoUxAicon from './ux-a-icon.js';
import InputComponent from '../input.js';
import CoUxBadge from './ux-badge.js';
import CoUxDisableContent from './ux-disable-content.js';
import CoUxDropdownButton from './ux-dropdown-button.js';

export default class CoUxCard extends Component {

    constructor(parent) {
      let selector = 'ux-card';
      super(parent, selector);
      //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/core/src/lib/commons/ux-components/ux-card/ux-card.component.html?at=refs%2Fheads%2Fsupport%2F7.x
    }

    get dataE2E() {
      let path = '//div[@data-e2e="ux-card"]';
      return this.currentPath + path;
    }
    get header() {
      let path = '//div[@class = "ux-card__header"]';
      return this.dataE2E + path;
    }
    // STATUS INDICATOR
    get statusIndicator() {
      let path = '//span[contains(@class, "ux-card__header-status-indicator")]';
      return this.dataE2E + path;
    }
    async hasStatusIndicator() {
      return await (await $(this.statusIndicator)).isExisting();
    }
    get statusIndicatorIcon() {
      let path = '//span[contains(@class, "ux-card__header-status-indicator-icon")]';
      return this.statusIndicator + path;
    }
    //
    get headerLeftContent() {
      let path = '//div[contains(@class, "ux-card__header-left-content")]';
      return this.header + path;
    }
    get headerLeftContentLabel() {
      return this.headerLeftContent + '//label[@class = "p-0"]';
    }
    // while we can't click on this label we have to add a special element
    get selectableDiv() {
      return this.headerLeftContentLabel + '/ancestor::div[1]';
    }
    get headerLeftContentCheckbox() {
      return this.headerLeftContent + '//input[@name= "checkbox"]';
    }
    async isSelectable() {
      return await (await $(this.headerLeftContentCheckbox)).isExisting();
    }
    async isChecked() {
      return await (await $(this.headerLeftContentCheckbox)).isSelected();
    }
// FAVORITE
    get headerLeftContentFavouriteIconCo() {
      return new CoUxAicon(this.headerLeftContent).byAttributeContains('iconClass', 'fa-star');
    }
    async isFavouritable() {
      return await (await (await this.headerLeftContentFavouriteIconCo.element())).isExisting();
    }
    async isFavourite() {
      return await (await (await this.headerLeftContentFavouriteIconCo.byAttributeContains('class', 'ux-u-color-accent-dark').element())).isExisting();
    }
// URGENT
    get headerLeftContentUrgentIconCo() {
      return new CoUxAicon(this.headerLeftContent).byAttributeContains('iconClass', 'fa-flag');
    }
    async isUrgentable() {
      return await (await (await this.headerLeftContentUrgentIconCo.element())).isExisting();
    }
    async isUrgent() {
      return await (await (await this.headerLeftContentUrgentIconCo.byAttributeContains('class', 'ux-u-color-accent-dark').element())).isExisting();
    }
// TITLE
    get headerTitle() {
      let path = '//div[@class = "ux-card__header-title"]';
      return this.header + path;
    }
    get headerTitleMain() {
      let path = '//div[contains(@class, "ux-card__header-title-main")]';
      return this.headerTitle + path;
    }
    get cardTitle() {
      return this.headerTitleMain + '/uxCardTitle'
    }
    get headerTitleSub() {
      let path = '//div[contains(@class, "ux-card__header-title-sub")]';
      return this.headerTitle + path;
    }
    get cardSubTitle() {
      return this.headerTitleSub + '/uxcardsubtitle';
    }
// RIGHT CONTENT
    get headerRightContent() {
      let path = '//div[contains(@class, "ux-card__header-right-content")]';
      return this.header + path;
    }
    get headerRightCustomContent() {
      let path = '//div[contains(@class, "ux-card__header-right-content__custom-content")]';
      return this.headerRightContent + path;
    }
    get uxCardHeaderRightContent() {
      return this.headerRightCustomContent + '/uxCardHeaderRightContent'
    }
    get headerRightContentStatus() {
      let path = '//div[contains(@class, "ux-card__header-right-content__status")]';
      return this.headerRightContent + path;
    }
// STATUS BADGE (info/success/warning/danger)
    get headerRightContentStatusBadgeCo (){
      return new CoUxBadge(this.headerRightContentStatus);
    }
    get headerRightContentStatusLabel() {
      let path = '/div[contains(@class, "ux-u-font-size-h7")]';
      return this.headerRightContentStatus + path;
    }
// LOCAL MENU
    get headerRightContentLocalMenu() {
      let path = '//div[contains(@class, "ux-card__header-right-content__local-menu")]';
      return this.headerRightContent + path;
    }
    get headerRightContentLocalMenuDisableContentCo () {
      return new CoUxDisableContent(this.headerRightContentLocalMenu);
    }
    get headerRightContentLocalMenuDropdownButtonCo () {
      return new CoUxDropdownButton(this.headerRightContentLocalMenuDisableContentCo.dataE2E);
    }
// BODY
    get body() {
      let path = '//div[contains(@class,"ux-card__body")]';
      return this.dataE2E + path;
    }
    async isCardBodyHidden() {
      return !await (await $(this.body)).isExisting();
    }
// EXPAND TOGGLE
    get expandTrigger() {
      return this.dataE2E + '//div[contains(@class,"ux-card__expand-trigger")]';
    }
    get expandToggle() {
      let path = '//span[contains(@class,"ux-card__expand-trigger-toggle")]';
      return this.expandTrigger + path;
    }
    get expandToggleIcon() {
      let path = '//span[contains(@class,"ux-icon")]';
      return this.expandToggle + path;
    }
    async isCollapsible() {
      return await (await $(this.expandTrigger)).isExisting();
    }
    async isCollapsed() {
      return await (await $(this.expandToggleIcon + '/self::*[contains(@class, "ux-icon-angle-down")]')).isExisting();
    }

}


