import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2021-2026 GoodData Corporation
import { useCallback } from "react";
import { FormattedMessage } from "react-intl";
import { Bubble, BubbleHoverTrigger, Button, useMediaQuery } from "@gooddata/sdk-ui-kit";
import { messages } from "../../../../../locales.js";
import { useDashboardDispatch, useDashboardSelector, } from "../../../../../model/react/DashboardStoreProvider.js";
import { selectIsInEditMode } from "../../../../../model/store/renderMode/renderModeSelectors.js";
import { selectIsDashboardSaving } from "../../../../../model/store/saving/savingSelectors.js";
import { uiActions } from "../../../../../model/store/ui/index.js";
/**
 * @internal
 */
export function useSettingButtonProps() {
    const isSmall = useMediaQuery("<=md");
    const dispatch = useDashboardDispatch();
    const onSettingClick = useCallback(() => dispatch(uiActions.openSettingsDialog()), [dispatch]);
    const isEditing = useDashboardSelector(selectIsInEditMode);
    const isSaving = useDashboardSelector(selectIsDashboardSaving);
    const isVisible = isEditing && !isSmall;
    const isEnabled = true;
    const buttonValue = messages.controlButtonsSettingValue;
    const buttonTitle = messages.controlButtonsSettingTitle;
    return {
        isVisible,
        isEnabled,
        isSaving,
        buttonValue,
        buttonTitle,
        onSettingClick,
    };
}
/**
 * @internal
 */
export function DefaultSettingButton({ isVisible, isEnabled, isSaving, buttonTitle, onSettingClick, }) {
    if (!isVisible) {
        return null;
    }
    return (_jsxs(BubbleHoverTrigger, { children: [
            _jsx(Button, { className: "gd-button-secondary gd-button-icon-only setting-button s-setting_button gd-icon-settings", onClick: onSettingClick, disabled: !isEnabled || isSaving }), _jsx(Bubble, { alignPoints: [{ align: "bc tr" }], arrowOffsets: { "bc tr": [10, 20] }, alignTo: `.setting-button`, children: _jsx(FormattedMessage, { ...buttonTitle }) })
        ] }));
}
