"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _chunkSNSG4HBQcjs = require('./chunk-SNSG4HBQ.cjs');


var _chunkUFU3BYZOcjs = require('./chunk-UFU3BYZO.cjs');


var _chunkWF7Z2VITcjs = require('./chunk-WF7Z2VIT.cjs');


var _chunkZ6EUSUADcjs = require('./chunk-Z6EUSUAD.cjs');

// src/components/CopyToClipboardButton.tsx
var _styled = require('@emotion/styled'); var _styled2 = _interopRequireDefault(_styled);
var _nanoid = require('nanoid');
var _react = require('react');
var _jsxruntime = require('@emotion/react/jsx-runtime');
var CopyToClipboardButton = (props) => {
  var _a;
  const originalTooltipContent = props.tooltipContent || "Click to copy";
  const icon = props.icon || "Copy";
  const id = `copy-node-name-${(_a = props.id) != null ? _a : _nanoid.nanoid.call(void 0, )}`;
  const [tooltipContent, setTooltipContent] = _react.useState.call(void 0, originalTooltipContent);
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
    /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, 
      Button,
      {
        type: "button",
        onClick: () => {
          void (() => _chunkZ6EUSUADcjs.__async.call(void 0, void 0, null, function* () {
            try {
              yield navigator.clipboard.writeText(props.value);
              setTooltipContent("Copied!");
            } catch (err) {
              setTooltipContent("Unable to copy");
            }
            setTimeout(() => {
              setTooltipContent(originalTooltipContent);
            }, 2e3);
          }))();
        },
        css: props.buttonCSS,
        ml: props.ml,
        "data-tooltip-id": id,
        children: [
          props.children ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Children, { children: props.children }) : null,
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWF7Z2VITcjs.Icon, { name: icon, width: props.isSm ? 12 : 16 })
        ]
      }
    ),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkUFU3BYZOcjs.Tooltip,
      {
        id,
        place: props.place || "right",
        content: tooltipContent
      }
    )
  ] });
};
var Children = _styled2.default.span`
  margin-right: 4px;
`;
var Button = _styled2.default.call(void 0, _chunkSNSG4HBQcjs.UnstyledButton)`
  background: rgba(0, 0, 0, 0);
  vertical-align: middle;
  ${({ ml }) => ml ? `margin-left: ${ml}px` : ""};
`;



exports.CopyToClipboardButton = CopyToClipboardButton;
