// #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 { Disableable } from '../../../../../Behaviors/Disableable';
import { Attribute } from '../../../../../Decorators/AttributeDecorator';
import { DockSide } from '../../../../../Types/DockSide';
import { CustomElement } from '../../../../Abstracts/CustomElement';
// #endregion
/**
 * Chat Tool Base Element - The foundational base class for all chat tool components.
 *
 * @description
 * ChatToolBaseElement provides the core infrastructure for extensible chat tools that can be
 * attached to ChatElement instances. It defines the contract for tool execution, attachment
 * lifecycle, and docking behavior. Tools can be positioned on the left or right side of the
 * chat interface and can be enabled/disabled dynamically. This abstract class manages the
 * attachment state and provides protected access to the parent ChatElement for subclasses.
 * Concrete chat tools (e.g., file upload, emoji picker, voice recorder) extend this base
 * class to implement specific functionality via the execute() method.
 *
 * @name ChatToolBaseElement
 * @category Abstract Elements
 *
 * @fires connected {ConnectedEvent} - Emitted when the element is connected to the DOM
 * @fires disconnected {DisconnectedEvent} - Emitted when the element is disconnected from the DOM
 * @fires changed {PropertyChangedEvent} - Emitted when any attribute changes before update
 *
 * @example
 * Extending ChatToolBaseElement for a file upload tool:
 * ```typescript
 * export class FileUploadToolElement extends ChatToolBaseElement {
 *   public execute(args: { files: FileList }): boolean {
 *     if (!this.chatElement || this.disabled) return false;
 *
 *     this.chatElement.addAttachments(Array.from(args.files));
 *     return true;
 *   }
 *
 *   protected override render() {
 *     return html`<button @click="${this.onUploadClick}">Upload</button>`;
 *   }
 * }
 * ```
 *
 * @example
 * Using chat tools in HTML:
 * ```html
 * <mosaik-chat>
 *   <file-upload-tool dock="left"></file-upload-tool>
 *   <emoji-picker-tool dock="right" disabled></emoji-picker-tool>
 * </mosaik-chat>
 * ```
 *
 * @example
 * Programmatically attaching and executing a tool:
 * ```typescript
 * const tool = document.createElement('file-upload-tool');
 * const chat = document.querySelector('mosaik-chat');
 *
 * tool.attach(chat);
 * tool.execute({ files: inputElement.files });
 * ```
 *
 * @example
 * Accessing parent chat from tool implementation:
 * ```typescript
 * protected sendMessage(content: string): void {
 *   if (this.chatElement) {
 *     this.chatElement.addMessage({ content, role: 'user' });
 *   }
 * }
 * ```
 *
 * @public
 *
 * @remarks
 * The attach() method follows a single-attachment pattern - once attached to a ChatElement,
 * subsequent attach() calls are ignored. Tools inherit disabled state management from the
 * Disableable behavior and must implement the abstract execute() method to define their
 * specific functionality.
 * @abstract
 */
export class ChatToolBaseElement extends Disableable(CustomElement) {
    // #region Fields
    _isAttached;
    _chatElement;
    _dock;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._isAttached = false;
        this._chatElement = undefined;
        this._dock = 'left';
    }
    // #endregion
    // #region Properties
    /**
     * Gets or sets the `dock` property.
     *
     * @public
     * @attr
     */
    get dock() {
        return this._dock;
    }
    set dock(value) {
        if (this._dock !== value) {
            this._dock = value;
            this.requestUpdate('dock');
        }
    }
    /**
     * Gets the chat element associated with this tool.
     *
     * @protected
     * @readonly
     */
    get chatElement() {
        return this._chatElement;
    }
    /**
     * Attaches the tool to the specified chat element.
     *
     * @public
     * @param chat The chat element to attach to.
     */
    attach(chat) {
        if (this._isAttached) {
            return;
        }
        this._isAttached = true;
        this._chatElement = chat;
    }
}
__decorate([
    Attribute({ type: DockSide }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], ChatToolBaseElement.prototype, "dock", null);
//# sourceMappingURL=ChatToolBaseElement.js.map