import Component  from '../component.js';
import DivComponent from '../div.js';
import IComponent from '../i.js';
import CoEuiButton from './eui-button.js'
import CoEuiIconSvg from './eui-icon-svg.js';

export default class CoEuiUploadedFile extends Component {
    constructor(parent) {
        let selector = 'eui-uploaded-file';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-file-upload/uploaded-file/uploaded-file.component.html
    }

    get fileUploadPreviewDivCO() {
        return new DivComponent(this.currentPath).addPredicateAttributeContains('class', 'file-upload__preview');
    }
    // file-upload__preview__image
    get fileUploadPreviewImageDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__image');
    }
    async hasPreviewAsImage() {
        return await (await this.fileUploadPreviewImageDivCO.element()).isExisting();
    }
    get image() {
        return this.fileUploadPreviewImageDivCO.currentPath + '//img';
    }
    async hasImage() {
        return await (await $(this.image)).isExisting();
    }
    get fileUploadPreviewImageICO() {
        return new IComponent(this.fileUploadPreviewImageDivCO).addPredicateClassContains('fa');
    }
    async hasPreviewText() {
        return await (await this.fileUploadPreviewImageICO.element()).isExisting();
    }

    // file-upload__preview__icon
    get fileUploadPreviewIconDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__icon');
    }
    async hasPreviewAsIcon() {
        return await (await this.fileUploadPreviewIconDivCO.element()).isExisting();
    }
    get previewAsIconICO() {
        return new IComponent(this.fileUploadPreviewIconDivCO).addPredicateClassContains('fa');
    }

    // file-upload__preview__filename
    get fileUploadPreviewFilenameDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__filename');
    }
    async isFilenameDisplayed() {
        return await (await this.fileUploadPreviewFilenameDivCO.element()).isExisting();
    }

    // file-upload__preview__filesize
    get fileUploadPreviewFilesizeDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__filesize');
    }
    async isFilesizeDisplayed() {
        return await (await this.fileUploadPreviewFilesizeDivCO.element()).isExisting();
    }

    // file-upload__preview__filetype
    get fileUploadPreviewFiletypeDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__filetype');
    }
    async isFiletypeDisplayed() {
        return await (await this.fileUploadPreviewFiletypeDivCO.element()).isExisting();
    }

    // file-upload__preview__actions
    get fileUploadPreviewActionsDivCO() {
        return new DivComponent(this.fileUploadPreviewDivCO).addPredicateAttributeContains('class', 'file-upload__preview__actions');
    }
    // file-upload__preview__actions-container
    get fileUploadPreviewActionsContainerDivCO() {
        return new DivComponent(this.fileUploadPreviewActionsDivCO).addPredicateAttributeContains('class', 'file-upload__preview__actions-container');
    }
    get btnCO() {
        return new CoEuiButton(this.fileUploadPreviewActionsContainerDivCO);
    }
    get closeIconSvgCO() {
        return new CoEuiIconSvg(this.btnCO).addPredicateAttributeContains('icon', 'eui-close');
    }
}


