import { jsx as t, jsxs as u } from "react/jsx-runtime";
import { Copy as d, Check as f } from "lucide-react";
import { useState as y, useCallback as C } from "react";
import { cn as a } from "../../../lib/utils.js";
import { Button as b } from "./button.js";
const x = 2e3;
function k({
  content: o,
  onCopy: i,
  className: l,
  variant: r = "ghost",
  size: c = "icon",
  children: n,
  ...p
}) {
  const [e, s] = y(!1), m = C(async () => {
    await navigator.clipboard.writeText(o), s(!0), setTimeout(() => s(!1), x), i?.();
  }, [o, i]);
  return /* @__PURE__ */ t(
    b,
    {
      "aria-label": e ? "Copied" : "Copy to clipboard",
      className: a("size-8", e && "text-green-500", l),
      disabled: e,
      onClick: m,
      size: c,
      type: "button",
      variant: r,
      ...p,
      children: n ?? /* @__PURE__ */ u("span", { className: "relative flex size-4 items-center justify-center", children: [
        /* @__PURE__ */ t(
          d,
          {
            className: a(
              "absolute size-4 transition-all duration-200",
              e ? "scale-0 opacity-0" : "scale-100 opacity-100"
            )
          }
        ),
        /* @__PURE__ */ t(
          f,
          {
            className: a(
              "absolute size-4 transition-all duration-200",
              e ? "scale-100 opacity-100" : "scale-0 opacity-0"
            )
          }
        )
      ] })
    }
  );
}
export {
  k as CopyButton
};
