import Component from '../../component.js'
import CoEuiButton from './eui-button.js'
import CoEuiIcon from './eui-icon.js'


export default class CoEuiFilePreview extends Component {
  constructor(parent) {
    let selector = 'eui-file-preview';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/components/eui-file-upload/file-preview/file-preview.component.html
  }
  get preview() {
    return this.currentPath + '//div[contains(@class,"file-upload__preview")]';
  }
  get previewImage() {
    return this.preview + '//div[contains(@class,"file-upload__preview__image")]';
  }
  async hasPreviewImage() {
    return await (await $(this.previewImage)).isExisting();
  }
  get image() {
    return this.previewImage + '//img';
  }
  async hasImage() {
    return await (await $(this.image)).isExisting();
  }
  get text() {
    return this.previewImage + '//i[contains(@class,"fa")]';
  }
  async hasText() {
    return await (await $(this.text)).isExisting();
  }
  get previewIconContainer() {
    return this.preview + '//div[contains(@class,"file-upload__preview__icon")]';
  }
  async hasPreviewIcon() {
    return await (await $(this.previewIconContainer)).isExisting();
  }
  get previewIcon() {
    return this.previewIcon + '//span[contains(@class,"eui-icon eui-icon-color")]';
  }
  get previewFilename() {
    return this.preview + '//div[contains(@class,"file-upload__preview__filename")]';
  }
  async isFilenameDisplayed() {
    return await (await $(this.previewFilename)).isExisting();
  }
  get previewFilesize() {
    return this.preview + '//div[contains(@class,"file-upload__preview__filesize")]';
  }
  async isFilesizeDisplayed() {
    return await (await $(this.previewFilesize)).isExisting();
  }
  get previewFiletype() {
    return this.preview + '//div[contains(@class,"file-upload__preview__filetype")]';
  }
  async isFiletypeDisplayed() {
    return await (await $(this.previewFiletype)).isExisting();
  }
  get previewActions() {
    return this.preview + '//div[contains(@class,"file-upload__preview__actions")]';
  }
  get previewActionsContainer() {
    return this.previewActions + '//div[contains(@class,"file-upload__preview__actions-container")]';
  }
  get removeFromListActionButtonCo() {
    return new CoEuiButton(this.previewActionsContainer);
  }
  get euiIconCo() {
    return new CoEuiIcon(this.removeFromListActionButtonCo.currentPath).byAttributeContains('iconClass','eui-icon-times');
  }
}


