"use client";
import { jsx } from 'react/jsx-runtime';
import { CopyIcon } from '../../node_modules/.pnpm/@radix-ui_react-icons@1.3.2_react@19.1.1/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js';
import { forwardRef, useState } from 'react';
import { useCopyToClipboard } from '../../hooks/useCopyToClipboard.js';
import { ReactComponent as SvgCheckCircleFilled } from '../../icons/assets/check-circle-filled.svg.js';
import { IconButton } from '../icon-button/icon-button.js';

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

export { CopyButton };
//# sourceMappingURL=copy-button.js.map
