import Component  from '../component.js'
import LiComponent from '../li.js'
import PComponent from '../p.js'
import { elementAttributeContains } from '../../core/utils.js'

export default class CoEuiDiscussionThreadItem extends Component {
  constructor(parent) {
    let selector = 'eui-discussion-thread-item';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-discussion-thread/eui-discussion-thread-item.component.html
  }
  get listItemCO() {
    return LiComponent(this.currentPath).byAttributeContains('class','eui-discussion-thread__item');
  }
  async isOdd() {
    return await elementAttributeContains(this.listItemCO.currentPath, 'class', 'eui-discussion-thread-inverted');
  }
  get badge() {
    return this.listItemCO.currentPath + '//div[contains(@class,"eui-discussion-thread-badge")]';
  }
  get icon() {
    return this.badge + '//span';
  }
  async hasInfoIcon() {
    return await elementAttributeContains(this.icon, 'iconclass', 'eui-icon-info');
  }
  async hasSuccessIcon() {
    return await elementAttributeContains(this.icon, 'iconclass', 'eui-icon-check');
  }
  async hasWarningIcon() {
    return await elementAttributeContains(this.icon, 'iconclass', 'eui-icon-exclamation');
  }
  async hasDangerIcon() {
    return await elementAttributeContains(this.icon, 'iconclass', 'eui-icon-times');
  }
  async hasMoreIcon() {
    return await elementAttributeContains(this.icon, 'iconclass', 'eui-icon-more-horizontal');
  }
  get panel() {
    return this.listItemCO.currentPath + '//div[contains(@class,"eui-discussion-thread-panel")]';
  }
  get header() {
    return this.panel + '//div[contains(@class,"eui-discussion-thread-header")]';
  }
  get heading() {
    return this.header + '//div[contains(@class,"eui-discussion-thread-heading")]';
  }
  get title() {
    return this.heading + '//div[contains(@class,"eui-discussion-thread-title")]';
  }
  get time() {
    return this.heading + '//div[contains(@class,"eui-discussion-thread-time")]';
  }
  get timeSpan() {
    return this.time + '//span[contains(@class,"ion-android-time")]';
  }
  get subheading() {
    return this.header + '//div[contains(@class,"eui-discussion-thread-subheading")]';
  }
  get body() {
    return this.panel + '//div[contains(@class,"eui-discussion-thread-body")]';
  }
  get wordBreakCO() {
    return PComponent(this.body).byAttributeContains('class','eui-discussion-thread-body__word-break');
  }
}


