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
    }

    get fileUploadDivCO() {
        return new DivComponent(this.currentPath).addPredicateAttributeContains('class', 'file-upload');
    }
    get dropAreaClassDivCO() {
        return new DivComponent(this.fileUploadDivCO).addPredicateAttributeContains('class', 'dropAreaClass');
    }
    async hasDragArea() {
        return await (await this.dropAreaClassDivCO.element()).isExisting();
    }
    get chooseFileSpanCO() {
        return new SpanComponent(this.dropAreaClassDivCO).addPredicateAttributeContains('class', 'fake-btn');
    }
    get dragAndDropSpanCO() {
        return new SpanComponent(this.dropAreaClassDivCO).addPredicateAttributeContains('class', 'file-msg');
    }
    get dropAreaFileInputCO() {
        return new InputComponent(this.dropAreaClassDivCO).addPredicateAttributeContains('class', 'file-input');
    }
    get simpleInputFileDivCO() {
        return new DivComponent(this.fileUploadDivCO).addPredicateAttributeContains('class', '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 euiFilePreviewUploadedFileCO() {
        return new CoEuiFilePreview(this.fileUploadDivCO).byAttributeContains('file', 'uploadedFile');
    }
    get euiFilePreviewFileCO() {
        return new CoEuiFilePreview(this.fileUploadDivCO).byAttributeEquals('file', 'file');
    }
    get fileUploadTotalSizeDivCO() {
        return new DivComponent(this.fileUploadDivCO).addPredicateAttributeContains('class', 'file-upload__total-size');
    }
    async hasTotalSize() {
        return await (await this.fileUploadTotalSizeDivCO.element()).isExisting();
    }
    get fileUploadResetButtonCO() {
        return new CoEuiButton(this.currentPath).byAttributeContains('class', 'file-upload__reset-button');
    }
    async hasResetButton() {
        return await (await this.fileUploadResetButtonCO.element()).isExisting();
    }
}


