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';
import DivComponent from '../div.js';
import SpanComponent from '../span.js';
import InputComponent from '../input.js';
import LabelComponent from '../label.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=master
    }

    get fileUploadDivCO() {
        return new DivComponent(this.currentPath).addPredicateClassContains('file-upload');
    }
    get dropAreaClassDivCO() {
        return new DivComponent(this.fileUploadDivCO).addPredicateClassContains('dropAreaClass');
    }
    async hasDragArea() {
        return await (await this.dropAreaClassDivCO.element()).isExisting();
    }
    get chooseFileSpanCO() {
        return new SpanComponent(this.dropAreaClassDivCO).addPredicateClassContains('fake-btn');
    }
    get dragAndDropSpanCO() {
        return new SpanComponent(this.dropAreaClassDivCO).addPredicateClassContains('file-msg');
    }
    get dropAreaFileInputCO() {
        return new InputComponent(this.dropAreaClassDivCO).addPredicateClassContains('file-input');
    }
    get simpleInputFileDivCO() {
        return new DivComponent(this.fileUploadDivCO).addPredicateClassContains('simple-input-file');
    }
    get labelCO() {
        return new LabelComponent(this.simpleInputFileDivCO);
    }
    get chooseFileBtnCO() {
        return new CoEuiButton(this.labelCO);
    }
    get chooseMultipleFilesInputCO() {
        return new InputComponent(this.simpleInputFileDivCO).addPredicateAttributeContains('aria-label', 'Choose Multiple Files');
    }
    async isMultiple() {
        return await (await this.chooseMultipleFilesInputCO.element()).isExisting();
    }
    get chooseASingleFileInputCO() {
        return new InputComponent(this.simpleInputFileDivCO).addPredicateAttributeContains('aria-label', 'Choose a single file');
    }
    //eui-file-upload-progress
    get euiFileUploadProgressCO() {
        return new CoEuiFileUploadProgress(this.fileUploadDivCO);
    }
    async hasProgressBar() {
        return await (await this.euiFileUploadProgressCO.element()).isExisting();
    }
    get divCO() {
      return new DivComponent(this.fileUploadDivCO);
  }
    get euiFilePreviewUploadedFileCO() {
        return new CoEuiFilePreview(this.divCO).byAttributeContains('file', 'uploadedFile');
    }
    get euiFilePreviewFileCO() {
        return new CoEuiFilePreview(this.divCO).byAttributeEquals('file', 'file');
    }
    get fileUploadTotalSizeDivCO() {
        return new DivComponent(this.fileUploadDivCO).addPredicateClassContains('file-upload__total-size');
    }
    async hasTotalSize() {
        return await (await this.fileUploadTotalSizeDivCO.element()).isExisting();
    }
    get fileUploadResetButtonCO() {
        return new CoEuiButton(this.currentPath).addPredicateClassContains('file-upload__reset-button');
    }
    async hasResetButton() {
        return await (await this.fileUploadResetButtonCO.element()).isExisting();
    }
}


