import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2007-2026 GoodData Corporation
import { useCallback } from "react";
import cx from "classnames";
import { FormattedMessage } from "react-intl";
import { simplifyText } from "@gooddata/util";
/**
 * @internal
 */
export function InvertableSelectItem({ title, onClick, onMouseOver, onMouseOut, isSelected, onOnly, renderOnly, renderRight, icon, isDisabled, accessibilityConfig, }) {
    const handleOnly = useCallback((e) => {
        if (isDisabled) {
            return;
        }
        e.stopPropagation();
        onOnly?.();
    }, [onOnly, isDisabled]);
    return (_jsxs("div", { className: cx({
            "gd-list-item": true,
            [`s-${simplifyText(title ?? "")}`]: true,
            "has-only-visible": true,
            "is-selected": isSelected,
            "is-disabled": isDisabled,
        }), onClick: isDisabled ? () => { } : onClick, "aria-labelledby": accessibilityConfig?.ariaLabelledBy, onMouseOver: onMouseOver, onMouseOut: onMouseOut, children: [
            _jsxs("label", { className: "input-checkbox-label", children: [
                    _jsx("input", { type: "checkbox", className: "input-checkbox", readOnly: true, checked: isSelected, disabled: isDisabled }), icon ?? null, _jsx("span", { className: "input-label-text", children: title })
                ] }), renderOnly?.({ onOnly: onOnly }) ?? (_jsx("span", { className: "gd-list-item-only", onClick: handleOnly, children: _jsx(FormattedMessage, { id: "gs.list.only" }) })), renderRight?.()] }));
}
