import Component  from '../component.js'

export default class MatProgressBar extends Component {
    constructor(parent) {
      let selector = 'mat-progress-bar';
      super(parent, selector);
      // https://github.com/angular/components/blob/master/src/material/progress-bar/progress-bar.html
    }
    get ariaHiddenDiv() {
        let path = '//div[@aria-hidden="true"]';
        return this.currentPath + path;
    }
    get background() {
      let path = '//svg[contains(@class, "mat-progress-bar-background")]';
      return this.currentPath + path;
    }
    get defs() {
      let path = '//defs';
      return this.background + path;
    }
    get pattern() {
      let path = '//pattern[@id,"progressbarId"]';
      return this.background + path;
    }
    get circle() {
      let path = '//circle';
      return this.pattern + path;
    }
    get rect() {
      let path = '//rect';
      return this.background + path;
    }
    get buffer() {
      let path = '//div[contains(@class, "mat-progress-bar-buffer")]';
      return this.currentPath + path;
    }
    get primary() {
      let path = '//div[contains(@class, "mat-progress-bar-primary")]';
      return this.currentPath + path;
    }
    async progressPercentage() {
      let result = await (await $(this.primary)).getAttribute('style');
      result = result.replace('transform: scaleX(', '');
      result = result.replace(');', '');
      if (result == 0){
        return 0;
      }
      else{
        return (result * 100);
      }
    }
    get secondary() {
      let path = '//div[contains(@class, "mat-progress-bar-secondary")]';
      return this.currentPath + path;
    }
}