import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2025-2026 GoodData Corporation
import cx from "classnames";
import { defineMessages, useIntl } from "react-intl";
import { UiButton, UiIconButton } from "@gooddata/sdk-ui-kit";
import { useKdaState } from "../providers/KdaState.js";
/**
 * Renders the KDA dialog actions (expand/minimize toggle + divider + close).
 *
 * @internal
 */
export function KdaDialogActionButtons({ size, onClose, className, status, titleElementId, }) {
    const intl = useIntl();
    const { state, setState } = useKdaState();
    const { isMinimized } = state;
    const expandLabel = intl.formatMessage({ id: "kdaDialog.floatingStatus.expand" });
    const shrinkLabel = intl.formatMessage({ id: "kdaDialog.floatingStatus.minimize" });
    const closeLabel = intl.formatMessage({ id: "kdaDialog.dialog.closeLabel" });
    const handleToggle = () => {
        setState({ isMinimized: !isMinimized });
    };
    return (_jsx(KdaDialogActionButtonsView, { className: className, status: status, size: size, titleElementId: titleElementId, isMinimized: isMinimized, expandLabel: expandLabel, shrinkLabel: shrinkLabel, closeLabel: closeLabel, onToggle: handleToggle, onClose: onClose }));
}
// oxlint-disable-next-line typescript-eslint/no-redundant-type-constituents
const buttonMessages = defineMessages({
    done: { id: "kdaDialog.floatingStatus.done.opener" },
    error: { id: "kdaDialog.floatingStatus.error.opener" },
});
function KdaDialogActionButtonsView(props) {
    const { size, status, isMinimized, expandLabel, titleElementId, shrinkLabel, closeLabel, onToggle, onClose, className, } = props;
    const intl = useIntl();
    const text = status && buttonMessages[status] ? intl.formatMessage(buttonMessages[status]) : "";
    const isFinished = status === "done" || status === "error";
    return (_jsxs("div", { className: cx("gd-kda-dialog-action-buttons", `gd-kda-dialog-action-buttons--size-${size}`, className), children: [
            _jsx("div", { className: cx("gd-kda-dialog-action-buttons__button", isMinimized ? "s-kda-dialog-expand-button" : "s-kda-dialog-minimize-button", status), children: isMinimized && isFinished ? (_jsx("div", { className: "gd-kda-dialog-action-buttons__button__open", children: _jsx(UiButton, { label: text, accessibilityConfig: {
                            ariaDescribedBy: titleElementId,
                        }, variant: "tooltip", size: "medium", onClick: onToggle }) })) : (_jsx(UiIconButton, { label: isMinimized ? expandLabel : shrinkLabel, icon: isMinimized ? "expand" : "shrink", accessibilityConfig: {
                        ariaDescribedBy: titleElementId,
                    }, iconColor: "complementary-7", variant: "tertiary", size: size, onClick: onToggle })) }), _jsx("div", { className: cx("gd-kda-dialog-action-buttons__divider", status) }), _jsx("div", { className: cx("gd-kda-dialog-action-buttons__button", "s-dialog-close-button", "s-kda-dialog-close-button", status), children: _jsx(UiIconButton, { label: closeLabel, icon: "cross", variant: "tertiary", size: size, onClick: onClose, iconColor: isFinished ? "complementary-0" : "complementary-7" }) })
        ] }));
}
