"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Command } from "cmdk";
import {
  Plus,
  Edit,
  Trash,
  Search,
  Eye,
  List,
  Package,
  Users,
  ShoppingCart,
  Lock,
  BookOpen,
  Folder,
  DollarSign,
  ToggleLeft,
  Zap
} from "lucide-react";
import { cn } from "@open-mercato/shared/lib/utils";
import { humanizeToolName } from "../../utils/toolMatcher.js";
const MODULE_ICONS = {
  customers: Users,
  catalog: Package,
  sales: ShoppingCart,
  search: Search,
  auth: Lock,
  dictionaries: BookOpen,
  directory: Folder,
  currencies: DollarSign,
  feature_toggles: ToggleLeft
};
const ACTION_ICONS = {
  create: Plus,
  update: Edit,
  delete: Trash,
  search: Search,
  query: Search,
  get: Eye,
  list: List
};
function getIcon(tool) {
  const nameParts = tool.name.split(".");
  const action = nameParts[nameParts.length - 1];
  if (ACTION_ICONS[action]) {
    return ACTION_ICONS[action];
  }
  const module = tool.module || nameParts[0];
  if (MODULE_ICONS[module]) {
    return MODULE_ICONS[module];
  }
  return Zap;
}
function CommandItem({ tool, isSelected, onSelect }) {
  const Icon = getIcon(tool);
  const displayName = humanizeToolName(tool.name);
  const module = tool.module || tool.name.split(".")[0];
  return /* @__PURE__ */ jsxs(
    Command.Item,
    {
      value: tool.name,
      onSelect,
      className: cn(
        "flex items-center gap-3 px-3 py-2 cursor-pointer rounded-md",
        "text-sm text-foreground",
        isSelected ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"
      ),
      children: [
        /* @__PURE__ */ jsx(
          "div",
          {
            className: cn(
              "flex items-center justify-center w-8 h-8 rounded-md",
              "bg-muted text-muted-foreground"
            ),
            children: /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" })
          }
        ),
        /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
          /* @__PURE__ */ jsx("div", { className: "font-medium truncate", children: displayName }),
          /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground truncate", children: tool.description })
        ] }),
        /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground capitalize", children: module })
      ]
    }
  );
}
export {
  CommandItem
};
//# sourceMappingURL=CommandItem.js.map
