var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { MelodicComponent } from '@melodicdev/core';
import { fileUploadItemTemplate } from './file-upload-item.template.js';
import { fileUploadItemStyles } from './file-upload-item.styles.js';
let FileUploadItemComponent = class FileUploadItemComponent {
    constructor() {
        this.name = '';
        this.size = '';
        this.status = 'idle';
        this.progress = 0;
        this.error = '';
        this.file = null;
        this.handleRemove = () => {
            this.elementRef.dispatchEvent(new CustomEvent('ml:remove', {
                bubbles: true,
                composed: true,
                detail: { name: this.name, file: this.file }
            }));
        };
        this.handleRetry = () => {
            this.elementRef.dispatchEvent(new CustomEvent('ml:retry', {
                bubbles: true,
                composed: true,
                detail: { name: this.name, file: this.file }
            }));
        };
    }
    get extension() {
        const parts = this.name.split('.');
        return parts.length > 1 ? parts.pop() : '';
    }
    get displayProgress() {
        return `${Math.round(Math.min(Math.max(this.progress, 0), 100))}%`;
    }
    get progressWidth() {
        return Math.min(Math.max(this.progress, 0), 100);
    }
};
FileUploadItemComponent = __decorate([
    MelodicComponent({
        selector: 'ml-file-upload-item',
        template: fileUploadItemTemplate,
        styles: fileUploadItemStyles,
        attributes: ['name', 'size', 'status', 'progress', 'error']
    })
], FileUploadItemComponent);
export { FileUploadItemComponent };
