import { LoadingOutlined } from "@ant-design/icons";
import { TextOptimize } from "@sofa-design/icons";
import { ConfigProvider, Tooltip } from "antd";
import React, { useContext } from "react";
import { ErrorBoundary } from "react-error-boundary";
import { ActionIconBox } from "../../Components/ActionIconBox";
import { useStyle } from "./style";
export var RefinePromptButton = function(props) {
    var disabled = props.disabled, status = props.status, onRefine = props.onRefine;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var baseCls = getPrefixCls('agentic-md-input-field-refine-button');
    var wrapSSR = useStyle(baseCls).wrapSSR;
    var handleClick = function() {
        if (disabled) return;
        if (status === 'loading') return;
        onRefine();
    };
    var renderIcon = function() {
        if (status === 'loading') return /*#__PURE__*/ React.createElement(LoadingOutlined, null);
        return /*#__PURE__*/ React.createElement(TextOptimize, null);
    };
    if (typeof window === 'undefined' || typeof document === 'undefined' || !window.document) {
        return null;
    }
    return wrapSSR(/*#__PURE__*/ React.createElement(Tooltip, {
        title: status === 'loading' ? '优化中' : '一键优化提示词'
    }, /*#__PURE__*/ React.createElement(ActionIconBox, {
        title: '优化提示词',
        onClick: handleClick,
        "data-testid": "refine-prompt-button"
    }, /*#__PURE__*/ React.createElement(ErrorBoundary, {
        fallback: /*#__PURE__*/ React.createElement("div", null)
    }, renderIcon()))));
};
