"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Wrench, AlertTriangle, Loader2, Check, X } from "lucide-react";
import { cn } from "@open-mercato/shared/lib/utils";
import { Button } from "@open-mercato/ui/primitives/button";
const DESTRUCTIVE_PATTERNS = [/^delete/i, /^remove/i, /\.delete$/i, /\.remove$/i];
function isDestructive(toolName) {
  return DESTRUCTIVE_PATTERNS.some((p) => p.test(toolName));
}
function ToolCallConfirmation({
  toolCall,
  onApprove,
  onReject
}) {
  const destructive = isDestructive(toolCall.toolName);
  if (toolCall.status === "executing") {
    return /* @__PURE__ */ jsx("div", { className: "bg-muted/50 rounded-lg p-3 border animate-pulse", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
      /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }),
      /* @__PURE__ */ jsxs("span", { className: "text-sm", children: [
        "Executing ",
        toolCall.toolName,
        "..."
      ] })
    ] }) });
  }
  if (toolCall.status === "completed") {
    return /* @__PURE__ */ jsx("div", { className: "bg-status-success-bg rounded-lg p-3 border border-status-success-border", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
      /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 text-status-success-icon" }),
      /* @__PURE__ */ jsxs("span", { className: "text-sm text-status-success-text", children: [
        toolCall.toolName,
        " completed successfully"
      ] })
    ] }) });
  }
  if (toolCall.status === "error") {
    return /* @__PURE__ */ jsx("div", { className: "bg-destructive/10 rounded-lg p-3 border border-destructive/20", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
      /* @__PURE__ */ jsx(X, { className: "h-4 w-4 text-destructive" }),
      /* @__PURE__ */ jsxs("span", { className: "text-sm text-destructive", children: [
        toolCall.toolName,
        " failed: ",
        toolCall.error || "Unknown error"
      ] })
    ] }) });
  }
  if (toolCall.status === "rejected") {
    return /* @__PURE__ */ jsx("div", { className: "bg-muted/30 rounded-lg p-3 border opacity-60", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
      /* @__PURE__ */ jsx(X, { className: "h-4 w-4 text-muted-foreground" }),
      /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground line-through", children: [
        toolCall.toolName,
        " cancelled"
      ] })
    ] }) });
  }
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: cn(
        "rounded-lg p-3 border",
        destructive ? "bg-destructive/5 border-destructive/20" : "bg-muted/50 border-border"
      ),
      children: [
        /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
          destructive ? /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4 text-destructive" }) : /* @__PURE__ */ jsx(Wrench, { className: "h-4 w-4 text-primary" }),
          /* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: destructive ? "Destructive action requested" : "AI wants to execute:" })
        ] }),
        /* @__PURE__ */ jsxs("div", { className: "font-mono text-xs bg-background rounded p-2 mb-3 overflow-auto max-h-32", children: [
          /* @__PURE__ */ jsx("div", { className: cn("font-medium", destructive ? "text-destructive" : "text-primary"), children: toolCall.toolName }),
          toolCall.args && Object.keys(toolCall.args).length > 0 && /* @__PURE__ */ jsx("pre", { className: "text-muted-foreground mt-1 whitespace-pre-wrap break-all", children: JSON.stringify(toolCall.args, null, 2) })
        ] }),
        destructive && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive mb-3", children: "This action may not be reversible." }),
        /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
          /* @__PURE__ */ jsx(Button, { size: "sm", variant: "outline", onClick: onReject, className: "flex-1", children: "Cancel" }),
          /* @__PURE__ */ jsx(
            Button,
            {
              size: "sm",
              variant: destructive ? "destructive" : "default",
              onClick: onApprove,
              className: "flex-1",
              children: destructive ? "Delete" : "Execute"
            }
          )
        ] })
      ]
    }
  );
}
export {
  ToolCallConfirmation
};
//# sourceMappingURL=ToolCallConfirmation.js.map
