import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2021-2026 GoodData Corporation
import { useCallback } from "react";
import { useIntl } from "react-intl";
import { Button } from "@gooddata/sdk-ui-kit";
import { useDashboardDispatch, useDashboardSelector, } from "../../../../../model/react/DashboardStoreProvider.js";
import { selectIsSaveAsNewButtonVisible } from "../../../../../model/store/topBar/topBarSelectors.js";
import { uiActions } from "../../../../../model/store/ui/index.js";
/**
 * @internal
 */
export function useSaveAsNewButtonProps() {
    const dashboardDispatch = useDashboardDispatch();
    const isVisible = useDashboardSelector(selectIsSaveAsNewButtonVisible);
    const onSaveAsNewClick = useCallback(() => {
        dashboardDispatch(uiActions.openSaveAsDialog());
    }, [dashboardDispatch]);
    return {
        isVisible,
        onSaveAsNewClick,
    };
}
/**
 * @internal
 */
export function DefaultSaveAsNewButton({ isVisible, onSaveAsNewClick }) {
    const intl = useIntl();
    if (!isVisible) {
        return null;
    }
    return (_jsx(Button, { className: "gd-button-secondary s-save_as_new_button", value: intl.formatMessage({ id: "save.as.new" }), onClick: onSaveAsNewClick, accessibilityConfig: {
            popupType: "dialog",
            popupId: "save-as-new-dialog",
        } }));
}
//# sourceMappingURL=DefaultSaveAsNewButton.js.map