import { j as o } from "../../node_modules/react/jsx-runtime.js";
import { useState as d } from "react";
import { cn as r } from "../../utils/index.js";
import { Icon as l } from "../Icon/index.js";
import { Button as p } from "../Button/index.js";
import { Tooltip as b, TooltipTrigger as j, TooltipContent as C } from "../Tooltip/index.js";
import { cva as v } from "../../node_modules/class-variance-authority/dist/index.js";
import { Row as w } from "../Layout/Row/index.js";
const i = v([], {
  variants: {
    variant: {
      code: "bg-grey-90 font-code text-content-inverse-strong",
      input: "bg-interaction-support-disabled-subtle text-content-secondary border-none font-sans"
    }
  },
  defaultVariants: {
    variant: "code"
  }
});
function I({
  className: m,
  variant: t,
  children: n,
  hide: c,
  ...f
}) {
  const [e, a] = d(!1), [s, x] = d(c || !1), g = () => {
    a(!0), navigator.clipboard.writeText(n), setTimeout(() => a(!1), 2e3);
  }, u = () => {
    x(!s);
  }, h = s ? n.replace(/./g, "*") : n;
  return /* @__PURE__ */ o.jsxs(b, { open: e || void 0, children: [
    /* @__PURE__ */ o.jsxs(
      "div",
      {
        className: r(
          "border border-grey-80 rounded-md h-12 flex-grow flex flex-row justify-between items-center pl-4 pr-1 gap-3 font-code",
          i({ variant: t }),
          m
        ),
        ...f,
        children: [
          h,
          /* @__PURE__ */ o.jsxs(w, { className: "!gap-0", children: [
            c && /* @__PURE__ */ o.jsx(
              p,
              {
                variant: "ghost",
                className: r(
                  i({ variant: t }),
                  "w-0 hover:bg-transparent"
                ),
                onClick: u,
                children: /* @__PURE__ */ o.jsx(l, { name: s ? "show" : "hide", size: "xs" })
              }
            ),
            /* @__PURE__ */ o.jsx(j, { children: /* @__PURE__ */ o.jsx(
              p,
              {
                variant: "ghost",
                className: r(
                  i({ variant: t }),
                  "hover:bg-transparent outline-0"
                ),
                onClick: g,
                disabled: e,
                children: /* @__PURE__ */ o.jsx(l, { name: e ? "check" : "copy", size: "xs" })
              }
            ) })
          ] })
        ]
      }
    ),
    /* @__PURE__ */ o.jsx(C, { children: e ? "Copied!" : "Copy" })
  ] });
}
export {
  I as CodeBlock
};
