import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2026 GoodData Corporation
import { useRef } from "react";
import { Dropdown, DropdownList } from "@gooddata/sdk-ui-kit";
import { SelectionTypeButton } from "./SelectionTypeButton.js";
import { SelectionTypeItem } from "./SelectionTypeItem.js";
const ITEM_HEIGHT = 28;
const ALIGN_POINTS = [
    {
        align: "br tr",
        offset: { x: 0, y: 1 },
    },
    {
        align: "tr br",
        offset: { x: 0, y: -1 },
    },
];
export function SelectionType({ asLabelText, listOrTextOptionText, listOrTextTooltip, listOptionText, listTooltip, textOptionText, textTooltip, selectionType, onSelectionTypeChange, isSingleSelectionMode, singleSelectionDisabledTooltip, }) {
    const buttonRef = useRef(null);
    const optionTitleMap = {
        listOrText: listOrTextOptionText,
        list: listOptionText,
        text: textOptionText,
    };
    const optionTooltipMap = {
        listOrText: listOrTextTooltip,
        list: listTooltip,
        text: textTooltip,
    };
    const items = ["listOrText", "list", "text"];
    const getDropdownWidth = () => {
        return buttonRef.current?.offsetWidth;
    };
    return (_jsxs("div", { className: "configuration-selection-kind", children: [
            _jsx("span", { className: "configuration-selection-kind-label", children: asLabelText }), _jsx(Dropdown, { className: "selection-kind-dropdown", alignPoints: ALIGN_POINTS, renderButton: ({ isOpen, toggleDropdown }) => (_jsx(SelectionTypeButton, { ref: buttonRef, isOpen: isOpen, title: optionTitleMap[selectionType], toggleDropdown: toggleDropdown })), renderBody: ({ closeDropdown }) => (_jsx(DropdownList, { className: "attribute-display-form-dropdown-body s-selection-kind-dropdown-body", items: items, itemHeight: ITEM_HEIGHT, width: getDropdownWidth(), renderItem: ({ item }) => (_jsx(SelectionTypeItem, { item: item, itemTitle: optionTitleMap[item], tooltip: optionTooltipMap[item], selected: item === selectionType, disabled: isSingleSelectionMode ? item !== "list" : undefined, disabledTooltip: singleSelectionDisabledTooltip, onClick: () => {
                            closeDropdown();
                            onSelectionTypeChange(item);
                        } })) })) })] }));
}
//# sourceMappingURL=SelectionType.js.map