"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var reactIcons_esm = require('../../node_modules/.pnpm/@radix-ui_react-icons@1.3.2_react@19.1.1/node_modules/@radix-ui/react-icons/dist/react-icons.esm.cjs');
var React = require('react');
var useCopyToClipboard = require('../../hooks/useCopyToClipboard.cjs');
var checkCircleFilled = require('../../icons/assets/check-circle-filled.svg.cjs');
var iconButton = require('../icon-button/icon-button.cjs');

const CopyButton = React.forwardRef(({ text, resetTimeout = 1000, resetIcon = true, ...props }, ref) => {
    const { copy } = useCopyToClipboard.useCopyToClipboard();
    const [isCopied, setIsCopied] = React.useState(false);
    async function onCopy() {
        const res = await copy(text);
        if (res) {
            setIsCopied(true);
            if (resetIcon) {
                setTimeout(() => {
                    setIsCopied(false);
                }, resetTimeout);
            }
        }
    }
    return (jsxRuntime.jsx(iconButton.IconButton, { ref: ref, ...props, onClick: onCopy, "data-test-id": 'copy-button', children: isCopied ? (jsxRuntime.jsx(checkCircleFilled.ReactComponent, { color: 'var(--rs-color-foreground-success-primary)' })) : (jsxRuntime.jsx(reactIcons_esm.CopyIcon, {})) }));
});
CopyButton.displayName = 'CopyButton';

exports.CopyButton = CopyButton;
//# sourceMappingURL=copy-button.cjs.map
