// #region Imports
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { DomServiceLocator } from '../../../../Dom/Dom';
import { Listen } from '../../../../events/Decorators/ListenDecorator';
import { Themeable } from '../../../Behaviors/Themeable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { FileUploadView } from '../../../Types/FileUploadView';
import { KeyName } from '../../../Types/Key';
import { CustomElement } from '../../Abstracts/CustomElement';
import { FileUploadElement } from './FileUploadElement';
import { fileUploadItemElementTemplate } from './FileUploadItemElementTemplate';
import { fileUploadItemElementCosmopolitanStyle } from './Themes/FileUploadItemElement.Cosmopolitan';
import { fileUploadItemElementJoyStyle } from './Themes/FileUploadItemElement.Joy';
import { fileUploadItemElementMemphisStyle } from './Themes/FileUploadItemElement.Memphis';
// #endregion
/**
 * File Upload Item - A subcomponent that represents a single file within a file upload list.
 *
 * @description
 * The FileUploadItem component is used as part of the FileUpload workflow to display and manage an individual file.
 * It typically shows details such as the file name, size, type, and upload progress. Users can interact with each
 * FileUploadItem to remove files, retry failed uploads, or view upload status indicators.
 *
 * This component improves clarity and usability by breaking down the upload process into manageable units,
 * making it easier for users to track the status of each file independently.
 *
 * @name FileUploadItem
 * @element mosaik-file-upload-item
 * @category Input
 *
 * @slot actions - The slot for custom action content (e.g., remove or retry buttons).
 *
 * @csspart actions - The actions part.
 * @csspart extension - The extension part.
 * @csspart name - The name part.
 * @csspart size - The size part.
 *
 * @cssprop {String} --file-upload-item-background-color - The upload item background color CSS custom property.
 * @cssprop {String} --file-upload-item-border-color - The upload item border color CSS custom property.
 * @cssprop {String} --file-upload-item-border-radius - The upload item border radius CSS custom property.
 * @cssprop {String} --file-upload-item-border-style - The upload item border style CSS custom property.
 * @cssprop {String} --file-upload-item-border-width - The upload item border width CSS custom property.
 * @cssprop {String} --file-upload-item-font-family - The upload item font family CSS custom property.
 * @cssprop {String} --file-upload-item-font-letter-spacing - The upload item font letter spacing CSS custom property.
 * @cssprop {String} --file-upload-item-font-line-height - The upload item font line height CSS custom property.
 * @cssprop {String} --file-upload-item-font-size - The upload item font size CSS custom property.
 * @cssprop {String} --file-upload-item-font-text-decoration - The upload item font text decoration CSS custom property.
 * @cssprop {String} --file-upload-item-font-text-transform - The upload item font text transform CSS custom property.
 * @cssprop {String} --file-upload-item-font-weight - The upload item font weight CSS custom property.
 * @cssprop {String} --file-upload-item-foreground-color - The upload item foreground color CSS custom property.
 * @cssprop {String} --file-upload-item-gap - The upload item gap CSS custom property.
 * @cssprop {String} --file-upload-item-padding-bottom - The upload item padding bottom CSS custom property.
 * @cssprop {String} --file-upload-item-padding-left - The upload item padding left CSS custom property.
 * @cssprop {String} --file-upload-item-padding-right - The upload item padding right CSS custom property.
 * @cssprop {String} --file-upload-item-padding-top - The upload item padding top CSS custom property.
 * @cssprop {String} --file-upload-item-shadow - The upload item shadow CSS custom property.
 * @cssprop {String} --file-upload-item-shadow-blur - The upload item shadow blur CSS custom property.
 * @cssprop {String} --file-upload-item-shadow-color - The upload item shadow color CSS custom property.
 * @cssprop {String} --file-upload-item-shadow-offset-x - The upload item shadow offset x CSS custom property.
 * @cssprop {String} --file-upload-item-shadow-offset-y - The upload item shadow offset y CSS custom property.
 * @cssprop {String} --file-upload-item-shadow-spread - The upload item shadow spread CSS custom property.
 * @cssprop {String} --file-upload-item-transition-duration - The upload item transition duration CSS custom property.
 * @cssprop {String} --file-upload-item-transition-mode - The upload item transition mode CSS custom property.
 * @cssprop {String} --file-upload-item-transition-property - The upload item transition property CSS custom property.
 * @cssprop {String} --file-upload-item-translate - The upload item translate CSS custom property.
 *
 * @dependency mosaik-button - The Button element.
 * @dependency mosaik-chip - The Chip element.
 * @dependency mosaik-progress-ring - The Progress Ring element.
 * @dependency mosaik-stack - The Stack element.
 * @dependency mosaik-text - The Text element.
 *
 * @example
 * ```html
 * <mosaik-file-upload-item view="list">
 *   <span slot="label">document.pdf</span>
 *   <button slot="actions">Remove</button>
 * </mosaik-file-upload-item>
 * ```
 *
 * @public
 */
let FileUploadItemElement = class FileUploadItemElement extends Themeable(CustomElement) {
    // #region Fields
    _file;
    _view;
    _controlled;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._file = null;
        this._view = FileUploadView.List;
        this._controlled = false;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-file-upload-item';
    }
    /**
     * Gets or sets the `file` property.
     *
     */
    get file() {
        return this._file;
    }
    set file(value) {
        if (this._file !== value) {
            this._file = value;
            this.requestUpdate('file');
        }
    }
    /**
     * Gets or sets the `view` property.
     *
     * @public
     * @attr
     */
    get view() {
        return this._view;
    }
    set view(value) {
        if (this._view !== value) {
            this._view = value;
            this.requestUpdate('view');
        }
    }
    /**
     * Gets or sets the `controlled` property.
     *
     * @public
     * @attr
     */
    get controlled() {
        return this._controlled;
    }
    set controlled(value) {
        if (this._controlled !== value) {
            this._controlled = value;
            this.requestUpdate('controlled');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @internal
     * @template
     */
    onSave(e) {
        e.preventDefault();
        if (this._file) {
            const parent = DomServiceLocator.current.findAncestor(this, FileUploadElement.is, { strict: true });
            void parent.save(this._file);
        }
    }
    /**
     * @internal
     * @template
     */
    onDelete(e) {
        e.preventDefault();
        if (this._file) {
            const parent = DomServiceLocator.current.findAncestor(this, FileUploadElement.is, { strict: true });
            parent.delete(this._file);
        }
    }
    /**
     * @protected
     */
    onKeyDown(e) {
        if (e.key === KeyName.Delete) {
            e.preventDefault();
            if (this._file) {
                const parent = DomServiceLocator.current.findAncestor(this, FileUploadElement.is, { strict: true });
                parent.delete(this._file);
            }
        }
    }
};
__decorate([
    Property({ type: Object }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], FileUploadItemElement.prototype, "file", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], FileUploadItemElement.prototype, "view", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], FileUploadItemElement.prototype, "controlled", null);
__decorate([
    Listen('keydown'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [KeyboardEvent]),
    __metadata("design:returntype", void 0)
], FileUploadItemElement.prototype, "onKeyDown", null);
FileUploadItemElement = __decorate([
    Component({
        selector: 'mosaik-file-upload-item',
        template: fileUploadItemElementTemplate,
        themes: {
            joy: fileUploadItemElementJoyStyle,
            memphis: fileUploadItemElementMemphisStyle,
            cosmopolitan: fileUploadItemElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], FileUploadItemElement);
export { FileUploadItemElement };
//# sourceMappingURL=FileUploadItemElement.js.map