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 { PlatformServiceName, SelectLimeTypes, } from "@limetech/lime-web-components";
import { h, } from "@stencil/core";
import { getItemIndex, getUpdatedItems } from "./utils/searcher-utils";
import { ARROW_DOWN, ARROW_UP, ENTER, ESCAPE, TAB } from "../../util/keycodes";
import { createRandomString } from "../../util/random-string";
import { getMentionLimetypes, MentionsService } from "./mentions";
import { debounce } from "lodash-es";
import { UploadHandler, } from "./uploader/building-blocks-upload-handler";
const DEBOUNCE_SEARCH_TIMEOUT = 300;
/**
 * This component is a wrapper on the `limel-text-editor`. It adds support for platform
 * specific things that can't reside in lime-elements. So this is basically an
 * invocation of the text editor with support for mentions.
 *
 * A mention is practically an inserted <limebb-mention /> tag that will visually show
 * the mention in the text editor but will also trigger the creation of a mention on
 * the server side if saved together with a text field in a limeobject.
 *
 * The mention will always point towards a limeobject with the combination of a limetype
 * that has the label USER and an object id.
 *
 * :::note
 * To enable mentions, the feature switch `useNotifications` needs to be enabled.
 * :::
 *
 * @exampleComponent limebb-example-text-editor-basic
 * @exampleComponent limebb-example-text-editor-as-form-component
 * @exampleComponent limebb-example-text-editor-composite
 * @exampleComponent limebb-example-text-editor-allow-resize
 * @exampleComponent limebb-example-text-editor-focus
 * @exampleComponent limebb-example-text-editor-many-picker-items
 * @beta
 */
export class LimeBBTextEditor {
    watchOpen() {
        this.setupHandlers();
        this.setPickerMessage();
    }
    watchQuery() {
        this.setPickerMessage();
    }
    constructor() {
        /**
         * Set to true to enable mentioning a coworker or groups of coworkers.
         *
         * Mentions already present will still be rendered with a link to the coworker or
         * the group of coworkers regardless of the value of this property
         */
        this.allowMentioning = false;
        /**
         * The type of content that the editor should handle and emit, defaults to `markdown`
         *
         * Assumed to be set only once, so not reactive to changes
         */
        this.contentType = 'markdown';
        /**
         * Defines the language for translations.
         */
        this.language = 'en';
        /**
         * Set to `true` to disable the field.
         * Use `disabled` to indicate that the field can normally be interacted
         * with, but is currently disabled. This tells the user that if certain
         * requirements are met, the field may become enabled again.
         */
        this.disabled = false;
        /**
         * Set to `true` to make the component read-only.
         * Use `readonly` when the field is only there to present the data it holds,
         * and will not become possible for the current user to edit.
         * :::note
         * Consider that it might be better to use `limel-markdown`
         * instead of `limel-text-editor` when the goal is visualizing data.
         * :::
         */
        this.readonly = false;
        /**
         * Set to `true` to indicate that the current value of the editor is
         * invalid.
         */
        this.invalid = false;
        /**
         * Set to `true` to indicate that the field is required.
         *
         * :::important
         * An empty but required field is not automatically considered invalid.
         * You must make sure to check the validity of the field on your own,
         * and properly handle the `invalid` state.
         * :::
         */
        this.required = false;
        /**
         * Specifies the visual appearance of the editor.
         *
         * - `standard`: The default editor appearance with a full toolbar and
         * standard layout.
         * - `minimal`: A compact editor appearance, ideal for limited space
         * scenarios such as mobile devices. In this mode, the toolbar is hidden
         * until the editor is focused.
         */
        this.ui = 'standard';
        /**
         * Set to `true` to allow the user to vertically resize the editor.
         * Set to `false` to disable the resize functionality.
         */
        this.allowResize = true;
        this.value = '';
        this.triggerMap = {};
        this.customElements = [];
        /**
         * Enables image pasting in the editor.
         * Default: `false`
         *
         * :::note
         * This component handles the upload process.
         * The consumer must process the uploaded images by listening to `metadataChange` event.
         * :::
         */
        this.allowInlineImages = false;
        this.items = [];
        this.highlightedItemIndex = 0;
        /**
         * Open state of the picker
         */
        this.isPickerOpen = false;
        /**
         * Loading state of the picker
         */
        this.isSearching = false;
        this.registeredTriggers = [];
        this.registeredTriggerMap = this.triggerMap;
        this.registeredCustomElements = this.customElements;
        this.activeTrigger = undefined;
        this.handleMouseClick = (event) => {
            if (!this.textEditorPickerElement) {
                return;
            }
            const clickedOnTextEditorPicker = event.target === this.textEditorPickerElement;
            if (!clickedOnTextEditorPicker) {
                this.resetTriggerAndPicker();
            }
        };
        this.handleKeyPress = (event) => {
            if (!this.isPickerOpen || !this.activeTrigger) {
                return;
            }
            const capturedKeys = [ESCAPE, ARROW_UP, ARROW_DOWN, ENTER, TAB];
            if (!capturedKeys.includes(event.key)) {
                return;
            }
            event.stopPropagation();
            event.preventDefault();
            if (event.type === 'keyup') {
                return;
            }
            const handlers = {
                [ESCAPE]: this.handleEscapeKey,
                [ENTER]: this.handleEnterOrTabKey,
                [TAB]: this.handleEnterOrTabKey,
                [ARROW_DOWN]: this.handleArrowKeyPress,
                [ARROW_UP]: this.handleArrowKeyPress,
            };
            const handler = handlers[event.key];
            if (handler) {
                handler(event);
            }
        };
        this.handleArrowKeyPress = (event) => {
            this.highlightedItemIndex = this.findNonSeparatorIndex(event.key, this.highlightedItemIndex);
        };
        this.findNonSeparatorIndex = (direction, currentIndex, depth = 0) => {
            // Safety check to avoid infinite recursion
            if (this.items.length === 0 || depth > this.items.length) {
                return currentIndex;
            }
            const nextIndex = getItemIndex(direction, currentIndex, this.items.length);
            if (!this.isListSeparator(this.items[nextIndex])) {
                return nextIndex;
            }
            return this.findNonSeparatorIndex(direction, nextIndex, depth + 1);
        };
        this.handleEscapeKey = () => {
            var _a;
            // We only call this when ESCAPE is pressed
            (_a = this.triggerFunction) === null || _a === void 0 ? void 0 : _a.stopTrigger();
            this.resetTriggerAndPicker();
        };
        this.handleEnterOrTabKey = (event) => {
            this.handleItemSelection(event);
        };
        this.handleMetadataChange = (event) => {
            event.stopPropagation();
            const editorMetadata = event.detail;
            const enhancedImages = this.getEnhancedImages(editorMetadata.images || []);
            const enhancedMetadata = Object.assign(Object.assign({}, editorMetadata), { images: enhancedImages });
            this.metadataChange.emit(enhancedMetadata);
        };
        this.handleImagePasted = (event) => {
            event.stopPropagation();
            if (!this.allowInlineImages) {
                return;
            }
            this.uploadHandler.handleImagePasted(event.detail);
        };
        this.handleTriggerStart = (event) => {
            event.stopPropagation();
            this.activeTrigger = event.detail.trigger;
            this.triggerFunction = event.detail.textEditor;
            this.isPickerOpen = true;
        };
        this.handleTriggerStop = (event) => {
            event.stopPropagation();
            this.resetTriggerAndPicker();
        };
        this.handleTriggerChange = (event) => {
            var _a;
            event.stopImmediatePropagation();
            this.editorPickerQuery = event.detail.value;
            const trigger = event.detail.trigger;
            const searcher = (_a = this.registeredTriggerMap[trigger]) === null || _a === void 0 ? void 0 : _a.searcher;
            if (searcher) {
                this.isSearching = true;
                this.debouncedSearchFn(searcher, this.editorPickerQuery);
            }
        };
        this.resetTriggerAndPicker = () => {
            this.isPickerOpen = false;
            this.activeTrigger = undefined;
            this.triggerFunction = undefined;
            this.isSearching = false;
            this.highlightedItemIndex = 0;
            this.items = [];
        };
        this.handleItemSelection = (event) => {
            var _a;
            let selectedItem;
            if (event instanceof CustomEvent) {
                selectedItem = event.detail;
            }
            else if (event instanceof KeyboardEvent) {
                const currentItem = this.items[this.highlightedItemIndex];
                if (this.isListSeparator(currentItem)) {
                    return;
                }
                selectedItem = currentItem;
            }
            else {
                return;
            }
            if (!this.activeTrigger || (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.disabled)) {
                return;
            }
            const triggerHandler = this.registeredTriggerMap[this.activeTrigger];
            try {
                triggerHandler.inserter(this.triggerFunction, selectedItem);
            }
            catch (error) {
                console.error('Error inserting', error);
            }
            this.resetTriggerAndPicker();
            (_a = this.textEditor) === null || _a === void 0 ? void 0 : _a.focus();
        };
        this.handleVisibilityChange = () => {
            if (document.visibilityState === 'hidden') {
                this.saveDraft();
            }
        };
        this.handleBeforeUnload = () => {
            this.saveDraft();
        };
        this.portalId = createRandomString();
        this.debouncedSearchFn = debounce(async (searcher, editorPickerQuery) => {
            try {
                const items = await searcher(editorPickerQuery);
                if (editorPickerQuery !== this.editorPickerQuery ||
                    !this.activeTrigger) {
                    return;
                }
                this.items = items;
            }
            catch (error) {
                console.error('Error searching', error);
            }
            finally {
                this.isSearching = false;
            }
        }, DEBOUNCE_SEARCH_TIMEOUT);
    }
    connectedCallback() {
        var _a, _b, _c, _d;
        if (this.draftIdentifier) {
            const limeObjectId = (_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 'no-limeobject';
            const limeTypeName = (_d = (_c = this.context) === null || _c === void 0 ? void 0 : _c.limetype) !== null && _d !== void 0 ? _d : 'no-limetype';
            this.textEditorInnerId = [
                'text-editor-draft',
                limeTypeName,
                limeObjectId,
                this.draftIdentifier,
            ].join('-');
        }
        if (this.textEditorInnerId) {
            document.addEventListener('visibilitychange', this.handleVisibilityChange);
            window.addEventListener('beforeunload', this.handleBeforeUnload);
        }
        this.uploadHandler = new UploadHandler(this.platform);
    }
    componentWillLoad() {
        if (this.allowMentioning) {
            this.registerMentions();
        }
        this.registerTriggers();
        this.loadDraft();
    }
    disconnectedCallback() {
        // These can be called even if the listeners were not set up,
        // so we don't need to check for that
        document.removeEventListener('visibilitychange', this.handleVisibilityChange);
        window.removeEventListener('beforeunload', this.handleBeforeUnload);
        document.removeEventListener('mousedown', this.handleMouseClick);
        this.saveDraft();
        if (this.host) {
            this.host.removeEventListener('keyup', this.handleKeyPress, {
                capture: true,
            });
            this.host.removeEventListener('keydown', this.handleKeyPress, {
                capture: true,
            });
        }
        if (this.debouncedSearchFn && this.debouncedSearchFn.cancel) {
            this.debouncedSearchFn.cancel();
        }
    }
    registerMentions() {
        const mentions = new MentionsService(this.platform, this.context, this.searchableLimetypes);
        const nodeDefinition = mentions.triggerHandler.nodeDefinition;
        if (nodeDefinition) {
            this.registeredCustomElements.push(nodeDefinition.customElement);
            this.registeredTriggerMap[mentions.triggerCharacter] =
                mentions.triggerHandler;
            mentions.initialize();
        }
    }
    registerTriggers() {
        this.registeredTriggers = Object.keys(this.registeredTriggerMap);
    }
    setPickerMessage() {
        var _a;
        if (!this.activeTrigger) {
            return;
        }
        const triggerHandler = this.registeredTriggerMap[this.activeTrigger];
        if (((_a = this.editorPickerQuery) === null || _a === void 0 ? void 0 : _a.length) > 0) {
            this.pickerMessage = triggerHandler.noItemsFoundMessage;
        }
        else {
            this.pickerMessage = triggerHandler.emptySearchMessage;
        }
    }
    setupHandlers() {
        if (this.isPickerOpen) {
            this.host.addEventListener('keyup', this.handleKeyPress, {
                capture: true,
            });
            this.host.addEventListener('keydown', this.handleKeyPress, {
                capture: true,
            });
            document.addEventListener('mousedown', this.handleMouseClick);
        }
        else {
            this.host.removeEventListener('keyup', this.handleKeyPress, {
                capture: true,
            });
            this.host.removeEventListener('keydown', this.handleKeyPress, {
                capture: true,
            });
            document.removeEventListener('mousedown', this.handleMouseClick);
        }
    }
    isListSeparator(item) {
        return 'separator' in item && item.separator === true;
    }
    render() {
        return [
            h("limel-text-editor", { key: '38d692ec58c569a0429caddf7ecfe418e21ac14b', ref: (el) => (this.textEditor = el), tabindex: this.disabled ? -1 : 0, value: this.value, contentType: this.contentType, customElements: this.registeredCustomElements, "aria-disabled": this.disabled, language: this.language, triggers: this.registeredTriggers, onTriggerStart: this.handleTriggerStart, onTriggerStop: this.handleTriggerStop, onTriggerChange: this.handleTriggerChange, onImagePasted: this.handleImagePasted, onMetadataChange: this.handleMetadataChange, ui: this.ui, allowResize: this.allowResize, required: this.required, disabled: this.disabled, readonly: this.readonly, helperText: this.helperText, placeholder: this.placeholder, label: this.label, invalid: this.invalid }),
            this.renderPicker(),
        ];
    }
    renderPicker() {
        if (!this.isPickerOpen) {
            return;
        }
        return (h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, h("limebb-text-editor-picker", { ref: (el) => (this.textEditorPickerElement =
                el), items: getUpdatedItems(this.items, this.highlightedItemIndex), onItemSelected: this.handleItemSelection, emptyMessage: this.pickerMessage, isSearching: this.isSearching })));
    }
    getEnhancedImages(images) {
        return images.map((image) => {
            let fileId;
            if (image.state === 'success') {
                fileId = this.uploadHandler.parseFileIdFromSrc(image.src);
            }
            return fileId ? Object.assign(Object.assign({}, image), { fileId: fileId }) : image;
        });
    }
    loadDraft() {
        if (!this.userDataService || !this.textEditorInnerId) {
            return;
        }
        if (this.value) {
            // If the text-editor is loaded with a value, don't replace it.
            return;
        }
        const draft = this.userDataService.get(this.textEditorInnerId);
        if (draft) {
            this.change.emit(draft);
        }
    }
    saveDraft() {
        var _a, _b, _c, _d;
        if (!this.textEditorInnerId) {
            return;
        }
        const currentValue = (_a = this.value) === null || _a === void 0 ? void 0 : _a.trim();
        const existingDraft = (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.get(this.textEditorInnerId);
        // Save draft
        if (currentValue && currentValue !== existingDraft) {
            (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, currentValue);
        }
        // Delete draft
        else if (!currentValue && existingDraft) {
            (_d = this.userDataService) === null || _d === void 0 ? void 0 : _d.set(this.textEditorInnerId, undefined);
        }
    }
    get userDataService() {
        return this.platform.get(PlatformServiceName.UserDataRepository);
    }
    static get is() { return "limebb-text-editor"; }
    static get encapsulation() { return "shadow"; }
    static get delegatesFocus() { return true; }
    static get originalStyleUrls() {
        return {
            "$": ["text-editor.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["text-editor.css"]
        };
    }
    static get properties() {
        return {
            "platform": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "LimeWebComponentPlatform",
                    "resolved": "LimeWebComponentPlatform",
                    "references": {
                        "LimeWebComponentPlatform": {
                            "location": "import",
                            "path": "@limetech/lime-web-components",
                            "id": "node_modules::LimeWebComponentPlatform",
                            "referenceLocation": "LimeWebComponentPlatform"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "inheritdoc",
                            "text": undefined
                        }],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "context": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "LimeWebComponentContext",
                    "resolved": "LimeWebComponentContext",
                    "references": {
                        "LimeWebComponentContext": {
                            "location": "import",
                            "path": "@limetech/lime-web-components",
                            "id": "node_modules::LimeWebComponentContext",
                            "referenceLocation": "LimeWebComponentContext"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "inheritdoc",
                            "text": undefined
                        }],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "allowMentioning": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Set to true to enable mentioning a coworker or groups of coworkers.\n\nMentions already present will still be rendered with a link to the coworker or\nthe group of coworkers regardless of the value of this property"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "allow-mentioning",
                "defaultValue": "false"
            },
            "contentType": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'markdown' | 'html'",
                    "resolved": "\"html\" | \"markdown\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The type of content that the editor should handle and emit, defaults to `markdown`\n\nAssumed to be set only once, so not reactive to changes"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "content-type",
                "defaultValue": "'markdown'"
            },
            "language": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "Languages",
                    "resolved": "\"da\" | \"de\" | \"en\" | \"fi\" | \"fr\" | \"nb\" | \"nl\" | \"no\" | \"sv\"",
                    "references": {
                        "Languages": {
                            "location": "import",
                            "path": "@limetech/lime-elements",
                            "id": "node_modules::Languages",
                            "referenceLocation": "Languages"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Defines the language for translations."
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "language",
                "defaultValue": "'en'"
            },
            "disabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to disable the field.\nUse `disabled` to indicate that the field can normally be interacted\nwith, but is currently disabled. This tells the user that if certain\nrequirements are met, the field may become enabled again."
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "disabled",
                "defaultValue": "false"
            },
            "readonly": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to make the component read-only.\nUse `readonly` when the field is only there to present the data it holds,\nand will not become possible for the current user to edit.\n:::note\nConsider that it might be better to use `limel-markdown`\ninstead of `limel-text-editor` when the goal is visualizing data.\n:::"
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "readonly",
                "defaultValue": "false"
            },
            "helperText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Optional helper text to display below the input field when it has focus"
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "helper-text"
            },
            "placeholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The placeholder text shown inside the input field,\nwhen the field is empty."
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "placeholder"
            },
            "label": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The label of the editor"
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "label"
            },
            "invalid": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to indicate that the current value of the editor is\ninvalid."
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "invalid",
                "defaultValue": "false"
            },
            "required": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to indicate that the field is required.\n\n:::important\nAn empty but required field is not automatically considered invalid.\nYou must make sure to check the validity of the field on your own,\nand properly handle the `invalid` state.\n:::"
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "required",
                "defaultValue": "false"
            },
            "selectedContext": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "LimeWebComponentContext",
                    "resolved": "LimeWebComponentContext | undefined",
                    "references": {
                        "LimeWebComponentContext": {
                            "location": "import",
                            "path": "@limetech/lime-web-components",
                            "id": "node_modules::LimeWebComponentContext",
                            "referenceLocation": "LimeWebComponentContext"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Context of the selected object in the list"
                },
                "getter": false,
                "setter": false
            },
            "ui": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "EditorUiType",
                    "resolved": "\"minimal\" | \"no-toolbar\" | \"standard\" | undefined",
                    "references": {
                        "EditorUiType": {
                            "location": "import",
                            "path": "@limetech/lime-elements",
                            "id": "node_modules::EditorUiType",
                            "referenceLocation": "EditorUiType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Specifies the visual appearance of the editor.\n\n- `standard`: The default editor appearance with a full toolbar and\nstandard layout.\n- `minimal`: A compact editor appearance, ideal for limited space\nscenarios such as mobile devices. In this mode, the toolbar is hidden\nuntil the editor is focused."
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "ui",
                "defaultValue": "'standard'"
            },
            "allowResize": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to allow the user to vertically resize the editor.\nSet to `false` to disable the resize functionality."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "allow-resize",
                "defaultValue": "true"
            },
            "value": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The value of the current property"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "value",
                "defaultValue": "''"
            },
            "draftIdentifier": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "example",
                            "text": "```typescript\n<limebb-text-editor\n    draftIdentifier=\"activity-feed-editor\"\n    value=\"\"\n></limebb-text-editor>\n```"
                        }],
                    "text": "A unique string identifier for this text editor instance.\n\nThis identifier is used to manage and persist draft data in the user\ndata repository. It allows distinguishing between different text editor\ninstances within the same or different contexts. The identifier should\nbe consistent across sessions where the same instance is being used but\nshould differ for distinct instances.\n\n### Use Cases\n- **Shared Contexts:** For example, if a text editor is used in the\nactivity feed on both the Overview tab and the Activities tab, the\nidentifier should remain the same to ensure that drafts are preserved\nbetween these tabs.\n- **Distinct Contexts:** If there are multiple text editors within the\nsame view (e.g., one for the activity feed and another for a description\nfield), each editor should have a unique identifier to avoid\ncross-contamination of draft data.\n\n### Implementation Notes\n- If no value is provided by the consumer, the draft functionality will\nbe disabled. No draft data will be loaded and no draft will be saved.\n- The current limeobject ID and limetype name are always included\nautomatically in the final identifier. This means that the same text\neditor instance in two different limeobjects will have a different\ndraft identifier and will not affect each other's draft data.\n\n:::note\nIf the `value` property is set to any truthy value, the text editor\nwill not load any draft data. It _will_ still save a draft, but if the\n`value` property is still set to a truthy value next time the editor is\nloaded, the draft will not be loaded.\n:::"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "draft-identifier"
            },
            "triggerMap": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "TriggerMap",
                    "resolved": "{ \".\"?: TriggerHandler | undefined; \"#\"?: TriggerHandler | undefined; \"/\"?: TriggerHandler | undefined; \"&\"?: TriggerHandler | undefined; \"@\"?: TriggerHandler | undefined; $?: TriggerHandler | undefined; \"!\"?: TriggerHandler | undefined; \"?\"?: TriggerHandler | undefined; \"*\"?: TriggerHandler | undefined; \"%\"?: TriggerHandler | undefined; \"+\"?: TriggerHandler | undefined; \"-\"?: TriggerHandler | undefined; \"=\"?: TriggerHandler | undefined; \"\\\\\"?: TriggerHandler | undefined; \"^\"?: TriggerHandler | undefined; \"~\"?: TriggerHandler | undefined; \"`\"?: TriggerHandler | undefined; \":\"?: TriggerHandler | undefined; \";\"?: TriggerHandler | undefined; \"|\"?: TriggerHandler | undefined; \",\"?: TriggerHandler | undefined; \"<\"?: TriggerHandler | undefined; \">\"?: TriggerHandler | undefined; \"[\"?: TriggerHandler | undefined; \"]\"?: TriggerHandler | undefined; \"{\"?: TriggerHandler | undefined; \"}\"?: TriggerHandler | undefined; \"(\"?: TriggerHandler | undefined; \")\"?: TriggerHandler | undefined; \"'\"?: TriggerHandler | undefined; }",
                    "references": {
                        "TriggerMap": {
                            "location": "import",
                            "path": "./text-editor.types",
                            "id": "src/components/text-editor/text-editor.types.ts::TriggerMap",
                            "referenceLocation": "TriggerMap"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "defaultValue": "{}"
            },
            "customElements": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "CustomElementDefinition[]",
                    "resolved": "CustomElementDefinition[]",
                    "references": {
                        "CustomElementDefinition": {
                            "location": "import",
                            "path": "@limetech/lime-elements",
                            "id": "node_modules::CustomElementDefinition",
                            "referenceLocation": "CustomElementDefinition"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "defaultValue": "[]"
            },
            "allowInlineImages": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Enables image pasting in the editor.\nDefault: `false`\n\n:::note\nThis component handles the upload process.\nThe consumer must process the uploaded images by listening to `metadataChange` event.\n:::"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "allow-inline-images",
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "items": {},
            "highlightedItemIndex": {},
            "editorPickerQuery": {},
            "searchableLimetypes": {},
            "isPickerOpen": {},
            "isSearching": {}
        };
    }
    static get events() {
        return [{
                "method": "change",
                "name": "change",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Dispatched when a change is made to the editor"
                },
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                }
            }, {
                "method": "metadataChange",
                "name": "metadataChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Dispatched when the metadata of the editor changes"
                },
                "complexType": {
                    "original": "EnhancedEditorMetadata",
                    "resolved": "EnhancedEditorMetadata",
                    "references": {
                        "EnhancedEditorMetadata": {
                            "location": "import",
                            "path": "./uploader/building-blocks-upload-handler",
                            "id": "src/components/text-editor/uploader/building-blocks-upload-handler.ts::EnhancedEditorMetadata",
                            "referenceLocation": "EnhancedEditorMetadata"
                        }
                    }
                }
            }];
    }
    static get elementRef() { return "host"; }
    static get watchers() {
        return [{
                "propName": "isPickerOpen",
                "methodName": "watchOpen"
            }, {
                "propName": "editorPickerQuery",
                "methodName": "watchQuery"
            }];
    }
}
__decorate([
    SelectLimeTypes({
        map: [getMentionLimetypes],
    })
], LimeBBTextEditor.prototype, "searchableLimetypes", void 0);
