import Component  from '../component.js'
import CoEuiButton from './eui-button.js'
import CoEuiFileUploadProgress from './eui-file-upload-progress.js'
import CoEuiFilePreview from './eui-file-preview.js'

export default class CoEuiFileUpload extends Component {
  constructor(parent) {
    let selector = 'eui-file-upload';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-file-upload/eui-file-upload.component.html?at=support/13.x
  }
  get fileUploadContainer() {
    return this.currentPath + '//div[contains(@class,"file-upload")]';
  }
  get dropArea() {
    return this.fileUploadContainer + '//div[contains(@class,"file-drop-area")]';
  }
  async hasDragArea() {
    return await (await $(this.dropArea)).isExisting();
  }
  get chooseFile() {
    return this.dropArea + '//span[contains(@class,"fake-btn")]';
  }
  get dragAndDropMsg() {
    return this.dropArea + '//span[contains(@class,"file-msg")]';
  }
  get dropAreaFileInput() {
    return this.dropArea + '//input[contains(@class,"file-input")]';
  }
  get simpleInputFile() {
    return this.fileUploadContainer + '//div[contains(@class,"simple-input-file")]';
  }
  get chooseFileForSimpleInputFileLabel() {
    return this.simpleInputFile + '//label[contains(@for,"file-")]';
  }
  get euiButtonChooseFileCO() {
    return new CoEuiButton(this.chooseFileForSimpleInputFileLabel);
  }
  get multipleFilesInput() {
    return this.simpleInputFile + '//input[@multiple]';
  }
  async isMultiple() {
    return await (await $(this.multipleFilesInput)).isExisting();
  }
  get singleFileInput() {
    return this.simpleInputFile + '//input[not(@multiple)]';
  }
  get fileUploadResetButtonCO() {
    return new CoEuiButton(this.currentPath).byAttributeContains('class','file-upload__reset-button');
  }
  async hasResetButton() {
    return await (await $(this.fileUploadResetButtonCO.currentPath)).isExisting();
  }
  get euiFileUploadProgressCO() {
    return new CoEuiFileUploadProgress(this.fileUploadContainer);
  }
  async hasProgressBar() {
    return await (await $(this.euiFileUploadProgressCO.currentPath)).isExisting();
  }
  get euiFilePreviewUploadedFileCO() {
    return new CoEuiFilePreview(this.fileUploadContainer).byAttributeContains('file','uploadedFile');
  }
  get euiFilePreviewFileCO() {
    return new CoEuiFilePreview(this.fileUploadContainer).byAttributeEquals('file','file');
  }
  get fileUploadTotalSize() {
    return this.fileUploadContainer + '//div[contains(@class,"file-upload__total-size")]';
  }
  async hasTotalSize() {
    return await (await $(this.fileUploadTotalSize)).isExisting();
  }
}


