"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Copy, ClipboardCopy, Trash2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { Button } from "../../ui/button.js";
import { cn } from "../../../lib/utils/index.js";
import { sel } from "../../../lib/test/index.js";
import { BLOCK_REGISTRY } from "@nextsparkjs/registries/block-registry";
function FloatingBlockToolbar({
  blockId,
  blockSlug,
  isVisible,
  onCopy,
  onDuplicate,
  onRemove
}) {
  const t = useTranslations("admin.builder.floatingToolbar");
  const blockConfig = BLOCK_REGISTRY[blockSlug];
  const blockName = (blockConfig == null ? void 0 : blockConfig.name) || blockSlug;
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: cn(
        "absolute -top-3 left-1/2 -translate-x-1/2 z-10",
        "bg-primary text-primary-foreground rounded-full",
        "px-3 py-1 text-xs font-medium shadow-lg",
        "flex items-center gap-3",
        "transition-[opacity,transform] duration-200",
        isVisible ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-2 pointer-events-none"
      ),
      "data-cy": sel("blockEditor.previewCanvas.floatingToolbar.container", { id: blockId }),
      children: [
        /* @__PURE__ */ jsx(
          "span",
          {
            className: "uppercase tracking-wider text-[10px]",
            "data-cy": sel("blockEditor.previewCanvas.floatingToolbar.blockName", { id: blockId }),
            children: blockName
          }
        ),
        /* @__PURE__ */ jsx(
          "div",
          {
            className: "h-3 w-px bg-primary-foreground/30",
            "data-cy": sel("blockEditor.previewCanvas.floatingToolbar.divider", { id: blockId })
          }
        ),
        /* @__PURE__ */ jsx(
          Button,
          {
            variant: "ghost",
            size: "icon",
            className: "h-5 w-5 hover:bg-primary-foreground/20 text-primary-foreground",
            onClick: (e) => {
              e.stopPropagation();
              onCopy();
            },
            "data-cy": sel("blockEditor.previewCanvas.floatingToolbar.duplicateBtn", { id: blockId }),
            title: t("copy"),
            children: /* @__PURE__ */ jsx(ClipboardCopy, { className: "h-3 w-3" })
          }
        ),
        /* @__PURE__ */ jsx(
          Button,
          {
            variant: "ghost",
            size: "icon",
            className: "h-5 w-5 hover:bg-primary-foreground/20 text-primary-foreground",
            onClick: (e) => {
              e.stopPropagation();
              onDuplicate();
            },
            "data-cy": sel("blockEditor.previewCanvas.floatingToolbar.duplicateBtn", { id: blockId }),
            title: t("duplicate"),
            children: /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3" })
          }
        ),
        /* @__PURE__ */ jsx(
          Button,
          {
            variant: "ghost",
            size: "icon",
            className: "h-5 w-5 hover:bg-destructive/20 text-primary-foreground",
            onClick: (e) => {
              e.stopPropagation();
              onRemove();
            },
            "data-cy": sel("blockEditor.previewCanvas.floatingToolbar.deleteBtn", { id: blockId }),
            title: t("delete"),
            children: /* @__PURE__ */ jsx(Trash2, { className: "h-3 w-3" })
          }
        )
      ]
    }
  );
}
export {
  FloatingBlockToolbar
};
