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 dropAreaDivCO() {
        return new DivComponent(this.currentPath).addPredicateClassContains('drop-area');
    }
    async hasDragArea() {
        return await (await this.dropAreaDivCO.element()).isExisting();
    }
    get chooseFileSpanCO() {
        return new SpanComponent(this.dropAreaDivCO).addPredicateClassContains('fake-btn');
    }
    get dragAndDropFileHereSpanCO() {
        return new SpanComponent(this.dropAreaDivCO).byAttributeNotContains('class', 'fake-btn');
    }
    get dropAreaFileInputCO() {
        return new InputComponent(this.dropAreaDivCO).addPredicateClassContains('file-input');
    }
    get simpleInputFileDivCO() {
        return new DivComponent(this.currentPath).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');
    }
    get euiFileUploadProgressCO() {
        return new CoEuiFileUploadProgress(this.currentPath);
    }
    async hasProgressBar() {
        return await (await this.euiFileUploadProgressCO.element()).isExisting();
    }
    get euiFilePreviewUploadedFileCO() {
        return new CoEuiFilePreview(this.currentPath).byAttributeContains('file', 'uploadedFile');
    }
    get euiFilePreviewFileCO() {
        return new CoEuiFilePreview(this.currentPath).byAttributeEquals('file', 'file');
    }
    get fileUploadTotalSizeDivCO() {
        return new DivComponent(this.currentPath).addPredicateClassContains('file-upload__total-size');
    }
    async hasTotalSize() {
        return await (await this.fileUploadTotalSizeDivCO.element()).isExisting();
    }
    get fileUploadResetButtonCO() {
        return new CoEuiButton(this.currentPath);
    }
    async hasResetButton() {
        return await (await this.fileUploadResetButtonCO.element()).isExisting();
    }
}


