'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React, { useState } from 'react';
import { CopyIcon } from '../../icons/Copy/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { Tooltip } from '../Tooltip/index.js';
import './index.scss';
const baseClass = 'copy-to-clipboard';
export const CopyToClipboard = ({ defaultMessage, successMessage, value })=>{
    const [copied, setCopied] = useState(false);
    const [hovered, setHovered] = useState(false);
    const { t } = useTranslation();
    if (value) {
        return /*#__PURE__*/ _jsxDEV("button", {
            className: baseClass,
            onClick: async ()=>{
                await navigator.clipboard.writeText(value);
                setCopied(true);
            },
            onMouseEnter: ()=>{
                setHovered(true);
                setCopied(false);
            },
            onMouseLeave: ()=>{
                setHovered(false);
                setCopied(false);
            },
            type: "button",
            children: [
                /*#__PURE__*/ _jsxDEV(CopyIcon, {}, void 0, false, {
                    fileName: "src/elements/CopyToClipboard/index.tsx",
                    lineNumber: 40,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV(Tooltip, {
                    delay: copied ? 0 : undefined,
                    show: hovered || copied,
                    children: [
                        copied && (successMessage ?? t('general:copied')),
                        !copied && (defaultMessage ?? t('general:copy'))
                    ]
                }, void 0, true, {
                    fileName: "src/elements/CopyToClipboard/index.tsx",
                    lineNumber: 41,
                    columnNumber: 9
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/elements/CopyToClipboard/index.tsx",
            lineNumber: 24,
            columnNumber: 7
        }, this);
    }
    return null;
};

//# sourceMappingURL=index.js.map