import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2024-2025 GoodData Corporation
import { useCallback } from "react";
import cx from "classnames";
import { Bubble } from "../Bubble/Bubble.js";
import { BubbleHoverTrigger } from "../Bubble/BubbleHoverTrigger.js";
import { Button } from "../Button/Button.js";
const defaultTooltipAlignPoints = [{ align: "cl cr" }, { align: "cr cl" }];
/**
 * @internal
 */
export function AddButton({ title, isDisabled, onClick, tooltip, tooltipAlignPoints = defaultTooltipAlignPoints, className, }) {
    const buttonClassNames = cx({
        disabled: isDisabled,
    }, "gd-button-link", "gd-icon-plus", "s-add-button", className);
    const handleClick = useCallback((e) => {
        e.preventDefault();
        if (isDisabled) {
            return;
        }
        onClick?.();
    }, [isDisabled, onClick]);
    if (!tooltip) {
        return (_jsx(Button, { className: buttonClassNames, onClick: handleClick, children: title }));
    }
    return (_jsxs(BubbleHoverTrigger, { showDelay: 0, hideDelay: 0, children: [
            _jsx(Button, { className: buttonClassNames, onClick: handleClick, children: title }), _jsx(Bubble, { className: "bubble-primary", alignPoints: tooltipAlignPoints, children: tooltip })
        ] }));
}
