import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { Button } from '../../../Button';
import { ConfirmAction, } from '../../../ConfirmAction';
import { Tooltip } from '../../../Tooltip';
import { useLogic } from './useLogic';
export const Action = (props) => {
    const { tooltipProps } = useLogic(props);
    const { action, onActionClick, isDisabled } = props;
    const { name, needConfirm, confirmText, confirmButtonProps, disabledReason, disabled, loading, isBlockingOperation, loadingNote, note, onClick, component, variant, color, ...restProps } = action;
    const renderButton = (renderProps) => {
        return (_jsx(Tooltip, { withoutContainer: !disabled, placement: "bottom", ...tooltipProps, children: _jsx(Button, { disabled: isDisabled || disabled, loading: loading, component: component, variant: variant, color: color, ...restProps, ...renderProps, children: name }) }, name));
    };
    return (_jsx(_Fragment, { children: needConfirm ? (_jsx(ConfirmAction, { text: confirmText, confirmButtonProps: confirmButtonProps, actionComponent: (renderProps) => renderButton(renderProps), onConfirm: onActionClick(onClick) })) : (renderButton({
            onClick: onActionClick(onClick),
        })) }));
};
