"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { MoreVertical, Pencil, Copy, Users, Trash2 } from "lucide-react";
import { Button } from "../../primitives/button.js";
import { IconButton } from "../../primitives/icon-button.js";
import { Popover, PopoverTrigger, PopoverContent, PopoverClose } from "../../primitives/popover.js";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function ViewChipMenu({ kind, canApplyToRoles, deleting, onRenameStart, onClone, onShareStart, onDelete }) {
  const t = useT();
  const showRename = kind === "personal" && !!onRenameStart;
  const showShare = kind === "personal" && canApplyToRoles && !!onShareStart;
  return /* @__PURE__ */ jsxs(Popover, { children: [
    /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
      IconButton,
      {
        type: "button",
        variant: "ghost",
        size: "xs",
        className: "h-auto px-0.5 shrink-0 hover:bg-transparent group",
        "aria-label": t("ui.perspectives.chip.menu", "View options"),
        children: /* @__PURE__ */ jsx(MoreVertical, { className: "size-3 opacity-60 group-hover:opacity-100 transition-opacity" })
      }
    ) }),
    /* @__PURE__ */ jsxs(PopoverContent, { align: "start", className: "w-48 p-1.5", children: [
      showRename ? /* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsxs(
        Button,
        {
          type: "button",
          variant: "ghost",
          size: "sm",
          className: "w-full justify-start h-9 py-2 px-3 text-sm",
          onClick: onRenameStart,
          children: [
            /* @__PURE__ */ jsx(Pencil, { className: "size-3 mr-2" }),
            t("ui.perspectives.menu.rename", "Rename")
          ]
        }
      ) }) : null,
      /* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsxs(
        Button,
        {
          type: "button",
          variant: "ghost",
          size: "sm",
          className: "w-full justify-start h-9 py-2 px-3 text-sm",
          onClick: onClone,
          children: [
            /* @__PURE__ */ jsx(Copy, { className: "size-3 mr-2" }),
            t("ui.perspectives.menu.clone", "Clone")
          ]
        }
      ) }),
      showShare ? /* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsxs(
        Button,
        {
          type: "button",
          variant: "ghost",
          size: "sm",
          className: "w-full justify-start h-9 py-2 px-3 text-sm",
          onClick: onShareStart,
          children: [
            /* @__PURE__ */ jsx(Users, { className: "size-3 mr-2" }),
            t("ui.perspectives.menu.share", "Share with roles...")
          ]
        }
      ) }) : null,
      /* @__PURE__ */ jsx("div", { className: "my-1 border-t" }),
      /* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsxs(
        Button,
        {
          type: "button",
          variant: "ghost",
          size: "sm",
          className: "w-full justify-start h-9 py-2 px-3 text-sm text-destructive hover:text-destructive",
          onClick: onDelete,
          disabled: deleting,
          children: [
            /* @__PURE__ */ jsx(Trash2, { className: "size-3 mr-2" }),
            deleting ? t("ui.perspectives.actions.removing", "Removing\u2026") : t("common.delete", "Delete")
          ]
        }
      ) })
    ] })
  ] });
}
export {
  ViewChipMenu
};
//# sourceMappingURL=ViewChipMenu.js.map
