import { h, } from "@stencil/core";
import { isNestedInIfxComponent } from "../../../shared/utils/dom-utils";
import { detectFramework } from "../../../shared/utils/framework-detection";
import { trackComponent } from "../../../shared/utils/tracking";
function debounce(func, wait) {
    let timeout;
    return function executedFunction(...args) {
        const later = () => {
            clearTimeout(timeout);
            func(...args);
        };
        clearTimeout(timeout);
        timeout = setTimeout(later, wait);
    };
}
export class Multiselect {
    name;
    disabled = false;
    required = false;
    error = false;
    caption = "";
    label = "";
    placeholder = "";
    showSearch = true;
    showSelectAll = true;
    showClearButton = true;
    showExpandCollapse = true;
    noResultsMessage = "No results found.";
    showNoResultsMessage = true;
    searchPlaceholder = "Search";
    selectAllLabel = "Select all";
    expandLabel = "Expand";
    collapseLabel = "Collapse";
    ariaMultiSelectLabel = "Multi-select dropdown";
    ariaMultiSelectLabelledBy = "";
    ariaMultiSelectDescribedBy = "";
    ariaSearchLabel = "Search options";
    ariaClearLabel = "Clear all selections";
    ariaToggleLabel = "Toggle dropdown";
    ariaSelectAllLabel = "Select all options";
    ariaExpandAllLabel = "Expand all categories";
    ariaCollapseAllLabel = "Collapse all categories";
    internalError = false;
    persistentSelectedOptions = [];
    dropdownOpen = false;
    dropdownFlipped;
    searchTerm = "";
    ifxSelect;
    ifxOpen;
    el;
    dropdownElement;
    internals;
    parseChildOptions() {
        const options = [];
        const childElements = Array.from(this.el.children);
        childElements.forEach((child, index) => {
            if (child.tagName === "IFX-MULTISELECT-OPTION") {
                const option = this.parseOptionElement(child, index);
                if (option) {
                    options.push(option);
                }
            }
        });
        return options;
    }
    parseOptionElement(element, index) {
        const value = element.getAttribute("value") || `option-${index}`;
        const selected = element.hasAttribute("selected");
        const disabled = element.hasAttribute("disabled");
        const indeterminate = element.hasAttribute("indeterminate");
        const option = {
            value,
            selected,
            disabled,
            indeterminate,
        };
        const nestedOptions = Array.from(element.children)
            .filter((child) => child.tagName === "IFX-MULTISELECT-OPTION")
            .map((child, childIndex) => this.parseOptionElement(child, childIndex))
            .filter((opt) => opt !== null);
        if (nestedOptions.length > 0) {
            option.children = nestedOptions;
        }
        return option;
    }
    loadInitialOptions() {
        this.internalError = this.error;
        const allOptions = this.parseChildOptions();
        const initiallySelected = this.collectSelectedOptions(allOptions);
        const initiallySelectedNotInState = initiallySelected.filter((init) => !this.persistentSelectedOptions.some((opt) => opt.value == init.value));
        this.persistentSelectedOptions = [
            ...this.persistentSelectedOptions,
            ...initiallySelectedNotInState,
        ];
    }
    collectSelectedOptions(options) {
        let selectedOptions = [];
        for (const option of options) {
            if (option.selected) {
                if (option.children && option.children.length > 0) {
                    selectedOptions = selectedOptions.concat(this.collectLeafOptions(option.children));
                }
                else {
                    if (!selectedOptions.some((existingOption) => existingOption.value === option.value)) {
                        selectedOptions.push(option);
                    }
                }
            }
            else {
                if (option.children && option.children.length > 0) {
                    selectedOptions = selectedOptions.concat(this.collectSelectedOptions(option.children));
                }
            }
        }
        return selectedOptions;
    }
    collectLeafOptions(children) {
        let leafOptions = [];
        for (const child of children) {
            if (child.children && child.children.length > 0) {
                leafOptions = leafOptions.concat(this.collectLeafOptions(child.children));
            }
            else {
                leafOptions.push(child);
            }
        }
        return leafOptions;
    }
    handleSearch = debounce((targetElement) => {
        const searchTerm = targetElement.value.toLowerCase();
        const isSearchActive = searchTerm !== "";
        this.searchTerm = searchTerm;
        const wrapper = this.el.shadowRoot.querySelector(".ifx-multiselect-wrapper");
        if (wrapper) {
            if (isSearchActive) {
                wrapper.classList.remove("active");
            }
            else {
                const searchField = this.el.shadowRoot.querySelector("ifx-search-field");
                const searchFieldHasFocus = searchField && searchField.matches(":focus-within");
                if (!searchFieldHasFocus) {
                    wrapper.classList.add("active");
                }
            }
        }
        const optionsContainer = this.el.shadowRoot.querySelector(".ifx-multiselect-options");
        if (optionsContainer) {
            if (isSearchActive) {
                optionsContainer.classList.add("has-search-filter");
            }
            else {
                optionsContainer.classList.remove("has-search-filter");
            }
        }
        requestAnimationFrame(() => {
            const allOptions = this.el.querySelectorAll("ifx-multiselect-option");
            allOptions.forEach((option) => {
                const searchEvent = new CustomEvent("ifx-search-filter", {
                    detail: { searchTerm, isActive: isSearchActive },
                });
                option.dispatchEvent(searchEvent);
            });
            if (isSearchActive) {
                setTimeout(() => {
                    const allOptions = this.el.querySelectorAll("ifx-multiselect-option");
                    let visibleCount = 0;
                    allOptions.forEach((option) => {
                        const style = window.getComputedStyle(option);
                        const rect = option.getBoundingClientRect();
                        if (style.display !== "none" &&
                            style.visibility !== "hidden" &&
                            style.opacity !== "0" &&
                            rect.height > 0) {
                            visibleCount++;
                        }
                    });
                    const optionsContainer = this.el.shadowRoot.querySelector(".ifx-multiselect-options");
                    if (optionsContainer) {
                        if (visibleCount === 0) {
                            optionsContainer.classList.add("show-no-results");
                        }
                        else {
                            optionsContainer.classList.remove("show-no-results");
                        }
                    }
                }, 200);
            }
            else {
                const optionsContainer = this.el.shadowRoot.querySelector(".ifx-multiselect-options");
                if (optionsContainer) {
                    optionsContainer.classList.remove("show-no-results");
                }
            }
        });
    }, 150);
    handleSearchFocus(hasFocus) {
        const wrapper = this.el.shadowRoot.querySelector(".ifx-multiselect-wrapper");
        if (wrapper) {
            if (hasFocus || this.searchTerm !== "") {
                wrapper.classList.remove("active");
            }
            else {
                wrapper.classList.add("active");
            }
        }
    }
    positionDropdown() {
        const wrapperRect = this.el.shadowRoot
            .querySelector(".ifx-multiselect-wrapper")
            ?.getBoundingClientRect();
        const spaceBelow = window.innerHeight - wrapperRect.bottom;
        const spaceAbove = wrapperRect.top;
        if ((spaceAbove > spaceBelow && wrapperRect.height > spaceBelow) ||
            wrapperRect.bottom > window.innerHeight) {
            this.dropdownFlipped = true;
        }
        else {
            this.dropdownFlipped = false;
        }
    }
    //private pendingSelectionUpdate = false;
    updateSlotBasedSelections(emitEvent = false) {
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        const selectedLeafOptions = [];
        allOptionElements.forEach((optionEl) => {
            const instance = optionEl["__stencil_instance"];
            if (instance && instance.selected && !instance.hasChildren) {
                selectedLeafOptions.push({
                    value: instance.value,
                    selected: true,
                    disabled: instance.disabled,
                    label: instance.getTextContent() || instance.value,
                });
            }
        });
        this.persistentSelectedOptions = selectedLeafOptions;
        if (emitEvent) {
            this.ifxSelect.emit(this.persistentSelectedOptions);
        }
    }
    updateInitialParentStates() {
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        const optionsByDepth = Array.from(allOptionElements)
            .map((el) => ({
            element: el,
            instance: el["__stencil_instance"],
            depth: parseInt(el.getAttribute("data-level") || "0"),
        }))
            .filter((item) => item.instance)
            .sort((a, b) => b.depth - a.depth);
        optionsByDepth.forEach(({ instance }) => {
            if (instance.hasChildren) {
                this.updateParentState(instance);
            }
        });
    }
    updateParentState(parentInstance) {
        const directChildren = Array.from(parentInstance.el.children)
            .filter((child) => child.tagName === "IFX-MULTISELECT-OPTION")
            .map((child) => child["__stencil_instance"])
            .filter((instance) => instance !== null);
        const selectedCount = directChildren.filter((child) => child.selected).length;
        const indeterminateCount = directChildren.filter((child) => child.indeterminate).length;
        const totalCount = directChildren.length;
        if (selectedCount === totalCount && indeterminateCount === 0) {
            parentInstance.selected = true;
            parentInstance.indeterminate = false;
        }
        else if (selectedCount === 0 && indeterminateCount === 0) {
            parentInstance.selected = false;
            parentInstance.indeterminate = false;
        }
        else {
            parentInstance.selected = false;
            parentInstance.indeterminate = true;
        }
    }
    async componentDidLoad() {
        if (!isNestedInIfxComponent(this.el)) {
            const framework = detectFramework();
            trackComponent("ifx-multiselect", await framework);
        }
        setTimeout(() => {
            this.positionDropdown();
        }, 500);
        this.el.addEventListener("ifx-option-changed", (event) => {
            const optionInstance = event.target?.__stencil_instance;
            if (optionInstance && !optionInstance.hasChildren) {
                this.updateSlotBasedSelections(true);
            }
        });
        setTimeout(() => {
            this.updateSlotBasedSelections(false);
            this.updateInitialParentStates();
        }, 100);
    }
    componentWillLoad() {
        this.loadInitialOptions();
    }
    updateInternalError() {
        this.internalError = this.error;
    }
    onSelectionChange(newValue, _) {
        const formData = new FormData();
        newValue.forEach((option) => formData.append(this.name, option.value));
        //this.internals.setFormValue(formData);
    }
    collapseAll() {
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        allOptionElements.forEach((optionEl) => {
            const instance = optionEl["__stencil_instance"];
            if (instance && instance.hasChildren) {
                instance.isExpanded = false;
            }
        });
    }
    expandAll() {
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        allOptionElements.forEach((optionEl) => {
            const instance = optionEl["__stencil_instance"];
            if (instance && instance.hasChildren) {
                instance.isExpanded = true;
            }
        });
    }
    selectAll() {
        this.resetSearch();
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        allOptionElements.forEach((optionEl) => {
            const instance = optionEl["__stencil_instance"];
            if (instance) {
                if (instance.hasChildren) {
                    instance.isExpanded = true;
                }
                else {
                    instance.selected = true;
                }
            }
        });
        setTimeout(() => {
            this.updateInitialParentStates();
            this.updateSlotBasedSelections(false);
            this.ifxSelect.emit(this.persistentSelectedOptions);
        }, 0);
    }
    async clearSelection() {
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        allOptionElements.forEach((optionEl) => {
            const instance = optionEl["__stencil_instance"];
            if (instance) {
                instance.selected = false;
                instance.indeterminate = false;
                if (instance.hasChildren) {
                    instance.isExpanded = false;
                }
            }
        });
        this.persistentSelectedOptions = [];
        setTimeout(() => {
            this.updateSlotBasedSelections(false);
            this.ifxSelect.emit(this.persistentSelectedOptions);
        }, 0);
    }
    handleDocumentClick = (event) => {
        const path = event.composedPath();
        if (!path.includes(this.dropdownElement)) {
            this.dropdownOpen = false;
            document.removeEventListener("click", this.handleDocumentClick);
            this.resetSearch();
            this.ifxOpen.emit(this.dropdownOpen);
        }
    };
    toggleDropdown() {
        this.dropdownOpen = !this.dropdownOpen;
        setTimeout(() => {
            if (this.dropdownOpen) {
                document.addEventListener("click", this.handleDocumentClick);
            }
            else {
                this.resetSearch();
            }
            this.ifxOpen.emit(this.dropdownOpen);
        }, 0);
    }
    resetSearch() {
        this.searchTerm = "";
        const searchField = this.el.shadowRoot.querySelector("ifx-search-field");
        if (searchField) {
            searchField.value = "";
        }
        const optionsContainer = this.el.shadowRoot.querySelector(".ifx-multiselect-options");
        if (optionsContainer) {
            optionsContainer.classList.remove("has-search-filter");
        }
        const allOptions = this.el.querySelectorAll("ifx-multiselect-option");
        allOptions.forEach((option) => {
            const searchEvent = new CustomEvent("ifx-search-filter", {
                detail: { searchTerm: "", isActive: false },
            });
            option.dispatchEvent(searchEvent);
        });
    }
    handleWrapperClick(event) {
        this.positionDropdown();
        if (event.currentTarget === event.target) {
            this.toggleDropdown();
        }
    }
    handleKeyDown(event) {
        if (this.disabled)
            return;
        // If dropdown is closed, only allow opening
        if (!this.dropdownOpen) {
            switch (event.code) {
                case "Enter":
                case "Space":
                case "ArrowDown":
                    event.preventDefault();
                    this.toggleDropdown();
                    break;
            }
            return;
        }
        // Dropdown is open - handle navigation and controls
        switch (event.code) {
            case "Escape":
                event.preventDefault();
                this.toggleDropdown();
                break;
            case "Enter":
            case "Space": {
                // Don't close dropdown when pressing space/enter in controls area
                const target = event.target;
                if (!target.closest(".ifx-multiselect-dropdown-functions")) {
                    event.preventDefault();
                    this.toggleDropdown();
                }
                break;
            }
            case "ArrowDown":
            case "ArrowUp":
                // Focus first/last option for navigation
                event.preventDefault();
                this.focusFirstOption();
                break;
        }
    }
    focusFirstOption() {
        const firstOption = this.el.querySelector("ifx-multiselect-option:not(.search-hidden)");
        if (firstOption) {
            const labelElement = firstOption.shadowRoot?.querySelector(".option-label");
            labelElement?.focus();
        }
    }
    renderSelectAll() {
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        const leafOptions = Array.from(allOptionElements).filter((el) => !el.hasChildren);
        const selectedLeafOptions = Array.from(allOptionElements).filter((el) => !el.hasChildren && el.selected);
        const allSelected = leafOptions.length > 0 &&
            selectedLeafOptions.length === leafOptions.length;
        const toggleSelectAll = (event) => {
            if (event) {
                event.preventDefault();
                event.stopPropagation();
            }
            if (allSelected) {
                this.clearSelection();
            }
            else {
                this.selectAll();
            }
        };
        return (h("div", { class: "select-all-wrapper" }, h("ifx-checkbox", { id: "selectAll", checked: allSelected, size: "s", "aria-label": this.ariaSelectAllLabel, onClick: toggleSelectAll, onKeyDown: (e) => {
                if (e.key === "Enter" || e.key === " ") {
                    e.preventDefault();
                    e.stopPropagation();
                    toggleSelectAll(e);
                }
            } }, this.selectAllLabel)));
    }
    renderNoResultsMessage() {
        return (h("div", { class: "ifx-multiselect-no-results" }, h("div", { class: "no-results-content" }, h("span", { class: "no-results-text" }, this.noResultsMessage))));
    }
    render() {
        const selectedOptionsLabels = this.persistentSelectedOptions
            .map((option) => option.label || option.value)
            .join(", ");
        const hasSelections = this.persistentSelectedOptions.length > 0;
        let isFlatMultiselect = false;
        const allOptionElements = this.el.querySelectorAll("ifx-multiselect-option");
        if (allOptionElements.length > 0) {
            isFlatMultiselect = Array.from(allOptionElements).every((option) => option.children.length === 0);
        }
        return (h("div", { key: 'a4e3e72b531b8060e3226061dd232926a5ebfee6', class: `ifx-multiselect-container ${this.disabled && !this.error ? "disabled" : ""}`, ref: (el) => (this.dropdownElement = el) }, h("div", { key: 'c8aad790baa016b83f8f35fc010cb231d48f0a7d', class: "ifx-label-wrapper" }, this.label && (h("span", { key: '67a1e098db24df782857b01ab77cbb1b8b7e155d', class: "wrapper-label" }, h("span", { key: 'e73d4d6188885c25641e8226e5676881e5ed6bcd' }, this.label), this.required && (h("span", { key: '8fa2e6b89c6c1b2266db0970b7c86101407e2bfe', class: `required ${this.error ? "error" : ""}` }, "*"))))), h("div", { key: 'f02a7dd1e9a26c43bfaf2c53e93d43f6cfe22d48', class: `ifx-multiselect-wrapper
        ${this.dropdownOpen ? "active" : ""}
        ${this.dropdownFlipped ? "is-flipped" : ""}
        ${this.internalError ? "error" : ""}
        ${this.disabled && !this.error ? "disabled" : ""}`, role: "combobox", "aria-label": this.ariaMultiSelectLabel, "aria-labelledby": this.ariaMultiSelectLabelledBy || undefined, "aria-describedby": this.ariaMultiSelectDescribedBy || undefined, "aria-expanded": this.dropdownOpen, "aria-haspopup": "listbox", "aria-disabled": this.disabled && !this.error, tabindex: "0", onClick: this.disabled && !this.error
                ? undefined
                : (event) => this.handleWrapperClick(event), onKeyDown: this.disabled && !this.error
                ? undefined
                : (event) => this.handleKeyDown(event) }, h("div", { key: '7b19166e96dd14a8549478406faf0434aa27c209', class: `ifx-multiselect-input
          ${hasSelections ? "" : "placeholder"}
          `, onClick: this.disabled && !this.error
                ? undefined
                : () => this.toggleDropdown() }, hasSelections ? selectedOptionsLabels : this.placeholder), this.dropdownOpen && (h("div", { key: '8a4c2e9013df39ff1c0eb4690c5c2187cce9f029', class: "ifx-multiselect-dropdown-menu" }, (this.showSearch ||
            this.showSelectAll ||
            (this.showExpandCollapse && !isFlatMultiselect)) && (h("div", { key: 'd536106eebac9d8dd4bf5764e7766de47aa941fd', class: "ifx-multiselect-dropdown-functions", onClick: (e) => e.stopPropagation() }, this.showSearch && (h("div", { key: '08e2f51c37edab4df91f9138d5a2466e897f02ee', class: "ifx-multiselect-dropdown-search" }, h("ifx-search-field", { key: '4075d6050a0ed41c7af36f00679a96821736027a', class: "search-input", placeholder: this.searchPlaceholder, size: "s", "show-delete-icon": "true", "aria-label": this.ariaSearchLabel, onKeyDown: (e) => {
                e.stopPropagation();
            }, onIfxInput: (event) => this.handleSearch(event.target), onFocus: () => this.handleSearchFocus(true), onBlur: () => this.handleSearchFocus(false) }))), h("div", { key: '452751a4035927d87a71b3922ecbabf12a194cb0', class: "ifx-multiselect-dropdown-controls" }, this.showSelectAll && this.renderSelectAll(), this.showExpandCollapse && !isFlatMultiselect && (h("div", { key: '4226fcd084791fb6087ad6563cad54b18846bef0', class: "expand-collapse-controls" }, h("span", { key: '397327a63efbe420315af05791fd778c6927f0e3', class: "control-item", role: "button", tabIndex: 0, "aria-label": this.ariaExpandAllLabel, onClick: (e) => {
                e.stopPropagation();
                this.expandAll();
            }, onKeyDown: (e) => {
                if (e.key === "Enter" || e.key === " ") {
                    e.preventDefault();
                    e.stopPropagation();
                    this.expandAll();
                }
            } }, this.expandLabel), h("span", { key: '0cea92d704c19a958309b390cb718663e357759d', class: "control-item", role: "button", tabIndex: 0, "aria-label": this.ariaCollapseAllLabel, onClick: (e) => {
                e.stopPropagation();
                this.collapseAll();
            }, onKeyDown: (e) => {
                if (e.key === "Enter" || e.key === " ") {
                    e.preventDefault();
                    e.stopPropagation();
                    this.collapseAll();
                }
            } }, this.collapseLabel)))))), h("div", { key: 'c79d5ce3c6ab3807357dffb4b8de0af3813ad2e6', class: "ifx-multiselect-options", role: "listbox", "aria-multiselectable": "true" }, h("slot", { key: '3cfa89969c6b7a9b1f4743f443fcf376f3d1c7ca' }), this.searchTerm &&
            this.showNoResultsMessage &&
            this.renderNoResultsMessage()))), h("div", { key: '97d106e0c51ec7869ac18c9705948f4bd88436cd', class: "ifx-multiselect-icon-container" }, this.persistentSelectedOptions.length > 0 && (h("div", { key: 'fc80681f947c4bb8e809b392101551c2dca1caa0', class: `ifx-clear-button ${!this.showClearButton ? "hide" : ""}`, onClick: this.disabled && !this.error
                ? undefined
                : () => this.clearSelection() }, h("ifx-icon", { key: '8c80a22bb7519676b65c4cda18dcf5e4a4daef36', icon: "cRemove16" }))), h("div", { key: 'b0c1887b75b8899687d44c57b6cd2075feaf3685', class: "icon-wrapper-up", onClick: this.disabled && !this.error
                ? undefined
                : () => this.toggleDropdown() }, h("ifx-icon", { key: "icon-up", icon: "chevron-up-16" })), h("div", { key: 'e7c1688d351460cba09524828bc2e05dabfaae59', class: "icon-wrapper-down", onClick: this.disabled && !this.error
                ? undefined
                : () => this.toggleDropdown() }, h("ifx-icon", { key: "icon-down", icon: "chevron-down-16" })))), this.caption && (h("div", { key: '862d00dad48520232f2d02985537c9af3828b200', class: `multi__select-caption ${this.error ? "error" : ""} ${this.disabled && !this.error ? "disabled" : ""}` }, this.caption))));
    }
    static get is() { return "ifx-multiselect"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["multiselect.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["multiselect.css"]
        };
    }
    static get properties() {
        return {
            "name": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "name"
            },
            "disabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "disabled",
                "defaultValue": "false"
            },
            "required": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "required",
                "defaultValue": "false"
            },
            "error": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "error",
                "defaultValue": "false"
            },
            "caption": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "caption",
                "defaultValue": "\"\""
            },
            "label": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "label",
                "defaultValue": "\"\""
            },
            "placeholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "placeholder",
                "defaultValue": "\"\""
            },
            "showSearch": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-search",
                "defaultValue": "true"
            },
            "showSelectAll": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-select-all",
                "defaultValue": "true"
            },
            "showClearButton": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-clear-button",
                "defaultValue": "true"
            },
            "showExpandCollapse": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-expand-collapse",
                "defaultValue": "true"
            },
            "noResultsMessage": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "no-results-message",
                "defaultValue": "\"No results found.\""
            },
            "showNoResultsMessage": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-no-results-message",
                "defaultValue": "true"
            },
            "searchPlaceholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "search-placeholder",
                "defaultValue": "\"Search\""
            },
            "selectAllLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "select-all-label",
                "defaultValue": "\"Select all\""
            },
            "expandLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "expand-label",
                "defaultValue": "\"Expand\""
            },
            "collapseLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "collapse-label",
                "defaultValue": "\"Collapse\""
            },
            "ariaMultiSelectLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-multi-select-label",
                "defaultValue": "\"Multi-select dropdown\""
            },
            "ariaMultiSelectLabelledBy": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-multi-select-labelled-by",
                "defaultValue": "\"\""
            },
            "ariaMultiSelectDescribedBy": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-multi-select-described-by",
                "defaultValue": "\"\""
            },
            "ariaSearchLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-search-label",
                "defaultValue": "\"Search options\""
            },
            "ariaClearLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-clear-label",
                "defaultValue": "\"Clear all selections\""
            },
            "ariaToggleLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-toggle-label",
                "defaultValue": "\"Toggle dropdown\""
            },
            "ariaSelectAllLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-select-all-label",
                "defaultValue": "\"Select all options\""
            },
            "ariaExpandAllLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-expand-all-label",
                "defaultValue": "\"Expand all categories\""
            },
            "ariaCollapseAllLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-collapse-all-label",
                "defaultValue": "\"Collapse all categories\""
            }
        };
    }
    static get states() {
        return {
            "internalError": {},
            "persistentSelectedOptions": {},
            "dropdownOpen": {},
            "dropdownFlipped": {},
            "searchTerm": {}
        };
    }
    static get events() {
        return [{
                "method": "ifxSelect",
                "name": "ifxSelect",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }, {
                "method": "ifxOpen",
                "name": "ifxOpen",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
    static get methods() {
        return {
            "clearSelection": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
    static get watchers() {
        return [{
                "propName": "error",
                "methodName": "updateInternalError"
            }, {
                "propName": "persistentSelectedOptions",
                "methodName": "onSelectionChange"
            }];
    }
    static get attachInternalsMemberName() { return "internals"; }
}
//# sourceMappingURL=multiselect.js.map
