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

export default class CoUxProgressCircle extends Component {
  constructor(parent) {
    let selector = 'ux-progress-circle';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-progress-circle/ux-progress-circle.component.ts
  }
  get dataE2E() {
    let path = '//div[@data-e2e = "ux-progress-circle"]';
    return this.currentPath + path;
  }
  async isLongLabelOrBottomLabel() {
    return await elementAttributeContains(this.currentPath, 'class', 'ux-progress-circle-wrapper-bottom-label');
  }
  get percentage() {
    let path = '/div[contains(@class,"ux-progress-circle") and not(contains(@class,"ux-progress-circle__label") or contains(@class,"ux-progress-circle__icon"))]';
    return this.dataE2E + path;
  }
  async isOver50() {
    return await elementAttributeContains(this.percentage, 'class', 'ux-progress-circle--over50');
  }
  async isSmall() {
    return await elementAttributeContains(this.percentage, 'class', 'ux-progress-circle--small');
  }
  async isLarge() {
    return await elementAttributeContains(this.percentage, 'class', 'ux-progress-circle--large');
  }
  get label() {
    let path = '//span[contains(@class,"ux-progress-circle__label")]';
    return this.percentage + path;
  }
  get labelValue() {
    let path = '//span';
    return this.label + path;
  }
  get leftHalfClipper() {
    let path = '//div[contains(@class,"ux-progress-circle__left-half-clipper")]';
    return this.percentage + path;
  }
  get first50Bar() {
    let path = '//div[contains(@class,"ux-progress-circle__first50-bar")]';
    return this.leftHalfClipper + path;
  }
  get valueBar() {
    let path = '//div[contains(@class,"ux-progress-circle__value-bar")]';
    return this.leftHalfClipper + path;
  }
  get bottomLabel() {
    let path = '//div[contains(@class,"ux-progress-circle__bottom-label")]';
    return this.dataE2E + path;
  }
  async isLongLabelOrBottomLabel() {
    return await (await $(this.bottomLabel)).isExisting();
  }
  async isSmallBottomLabel() {
    return await elementAttributeContains(this.bottomLabel, 'class', 'ux-progress-circle--small');
  }
  async isLargeBottomLabel() {
    return await elementAttributeContains(this.bottomLabel, 'class', 'ux-progress-circle--large');
  }
  get bottomLabelValue() {
    let path = '//span';
    return this.bottomLabel + path;
  }
  get iconLabel() {
    let path = '//div[contains(@class,"ux-progress-circle__icon-label")]';
    return this.dataE2E + path;
  }
  async isSmallIconLabel() {
    return await elementAttributeContains(this.iconLabel, 'class', 'ux-progress-circle__icon-label--small');
  }
  async isLargeIconLabel() {
    return await elementAttributeContains(this.iconLabel, 'class', 'ux-progress-circle__icon-label--large');
  }
  get iconLabelSpan() {
    let path = '//span';
    return this.iconLabel + path;
  }
}

