// #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 { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Emit } from '../../../../events/Decorators/EmitDecorator';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Slottable } from '../../../Behaviors/Slottable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { ChipElement } from '../Chip/ChipElement';
import { chatInputAttachmentListElementTemplate } from './ChatInputAttachmentListElementTemplate';
import { chatInputAttachmentListElementCosmopolitanStyle } from './Themes/ChatInputAttachmentListElement.Cosmopolitan';
import { chatInputAttachmentListElementJoyStyle } from './Themes/ChatInputAttachmentListElement.Joy';
import { chatInputAttachmentListElementMemphisStyle } from './Themes/ChatInputAttachmentListElement.Memphis';
// #endregion
/**
 * Chat Input Attachment List - Represents the list of attachments in the chat input.
 *
 * @fires attachmentAdd {AttachmentAddEvent} - Called when an attachment is added.
 * @fires attachmentRemove {AttachmentRemoveEvent} - Called when an attachment is removed.
 *
 * @public
 */
let ChatInputAttachmentListElement = class ChatInputAttachmentListElement extends Themeable(Variantable(Appearanceable(Disableable(Slottable(CustomElement))))) {
    // #region Fields
    _attachmentAdded;
    _attachmentRemoved;
    _files;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._files = new Array();
        this._attachmentAdded = new HTMLElementEventEmitter(this, 'attachmentAdd', { bubbles: false });
        this._attachmentRemoved = new HTMLElementEventEmitter(this, 'attachmentRemove', { bubbles: false });
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-chat-input-attachment-list';
    }
    /**
     * Gets or sets the `files` property.
     *
     * @public
     */
    get files() {
        return this._files;
    }
    set files(value) {
        if (this._files !== value) {
            this._files = value;
            this.requestUpdate('files');
        }
    }
    /**
     * Called when an attachment is added.
     * Provides reference to `{@link IEventDetail}` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get attachmentAdded() {
        return this._attachmentAdded;
    }
    /**
     * Called when an attachment is removed.
     * Provides reference to `{@link IEventDetail}` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get attachmentRemoved() {
        return this._attachmentRemoved;
    }
    // #endregion
    // #region Methods
    /**
     * @public
     */
    addAttachment(file) {
        this.files = [...this.files, file];
        this.onAttachmentAdded({ file });
    }
    /**
     * @public
     */
    removeAttachment(file) {
        this.files = this.files.filter((f) => f !== file);
        this.onAttachmentRemoved({ file });
    }
    /**
     * @private
     * @template
     */
    onDismiss(e, file) {
        e.stopPropagation();
        this.removeAttachment(file);
    }
    /**
     * Emits the {@link attachmentAdded} event.
     *
     * @protected
     */
    onAttachmentAdded(args) {
        this._attachmentAdded.emit(args);
    }
    /**
     * Emits the {@link attachmentRemoved} event.
     *
     * @protected
     */
    onAttachmentRemoved(args) {
        this._attachmentRemoved.emit(args);
    }
};
__decorate([
    Emit({ eventName: 'attachmentAdd' }),
    __metadata("design:type", Object)
], ChatInputAttachmentListElement.prototype, "_attachmentAdded", void 0);
__decorate([
    Emit({ eventName: 'attachmentRemove' }),
    __metadata("design:type", Object)
], ChatInputAttachmentListElement.prototype, "_attachmentRemoved", void 0);
__decorate([
    Property({ type: Array }),
    __metadata("design:type", Array),
    __metadata("design:paramtypes", [Array])
], ChatInputAttachmentListElement.prototype, "files", null);
ChatInputAttachmentListElement = __decorate([
    Component({
        selector: 'mosaik-chat-input-attachment-list',
        template: chatInputAttachmentListElementTemplate,
        themes: {
            joy: chatInputAttachmentListElementJoyStyle,
            memphis: chatInputAttachmentListElementMemphisStyle,
            cosmopolitan: chatInputAttachmentListElementCosmopolitanStyle
        },
        host: {
            role: 'list'
        },
        imports: [
            TextElement,
            ChipElement
        ]
    }),
    __metadata("design:paramtypes", [])
], ChatInputAttachmentListElement);
export { ChatInputAttachmentListElement };
//# sourceMappingURL=ChatInputAttachmentListElement.js.map