import Button from '../../core/Button/index.js';
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
import React__default, { useState } from 'react';
import CopyTooltip from './CopyTooltip.js';

const CopyButton = ({
  text,
  buttonText,
  tooltipText
}) => {
  const { t } = useParrotTranslation();
  const [tooltipVisible, setTooltipVisible] = useState(false);
  const handleCopy = async () => {
    try {
      setTooltipVisible(true);
      setTimeout(() => {
        setTooltipVisible(false);
      }, 1e3);
    } catch (err) {
    }
  };
  return /* @__PURE__ */ React__default.createElement(
    CopyTooltip,
    {
      tooltipProps: { visible: tooltipVisible },
      text,
      afterTooltip: tooltipText ? tooltipText : t("common.has_copied_to_clipboard")
    },
    /* @__PURE__ */ React__default.createElement(Button, { onClick: handleCopy }, buttonText ? buttonText : t("common.copy"))
  );
};
var CopyButton$1 = CopyButton;

export { CopyButton$1 as default };
