"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const iconsReact = require("@choiceform/icons-react");
const React = require("react");
const index = require("../../../../i18n/index.cjs");
const MessageToolCallTv = designSystem.tcv({
  slots: {
    root: "tool-call-message flex flex-col gap-2",
    header: "flex items-center gap-1",
    icon: "text-icon-secondary flex size-5 items-center justify-center",
    toolName: "font-strong",
    content: "text-secondary-foreground",
    block: "flex flex-col gap-1",
    blockTitle: "font-strong",
    blockContent: "overflow-x-auto rounded"
  },
  variants: {
    status: {
      completed: {
        root: ""
      },
      failed: {
        root: ""
      },
      executing: {
        root: ""
      },
      pending: {
        root: ""
      }
    }
  },
  defaultVariants: {
    status: "executing"
  }
});
const MessageToolCall = React.memo(function MessageToolCall2(props) {
  const { children, className, toolCall } = props;
  if (!toolCall) {
    return null;
  }
  const getStatusIcon = (status) => {
    switch (status) {
      case "completed":
        return /* @__PURE__ */ jsxRuntime.jsx(iconsReact.CircleCirclehecirclek, {});
      case "failed":
        return /* @__PURE__ */ jsxRuntime.jsx(iconsReact.CircleRemove, {});
      case "executing":
        return /* @__PURE__ */ jsxRuntime.jsx(iconsReact.InteractionTriggerAfterDelay, {});
      default:
        return /* @__PURE__ */ jsxRuntime.jsx(iconsReact.ToolbarSettings, {});
    }
  };
  const toolCallToolName = index.t("response", "tool-call-tool-name");
  const toolCallArguments = index.t("response", "tool-call-arguments");
  const toolCallResult = index.t("response", "tool-call-result");
  const tv = MessageToolCallTv({ status: toolCall.status });
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tv.root(), children: [
    /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tv.header(), children: [
      /* @__PURE__ */ jsxRuntime.jsx("div", { className: tv.icon(), children: getStatusIcon(toolCall.status) }),
      /* @__PURE__ */ jsxRuntime.jsxs("span", { className: tv.toolName(), children: [
        toolCallToolName,
        ": ",
        toolCall.toolName
      ] }),
      /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: toolCall.status })
    ] }),
    children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: tv.content(), children }),
    toolCall.arguments && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tv.block(), children: [
      /* @__PURE__ */ jsxRuntime.jsx("div", { className: tv.blockTitle(), children: toolCallArguments }),
      /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CodeBlock, { language: "json", children: [
        /* @__PURE__ */ jsxRuntime.jsx(designSystem.CodeBlock.Content, { code: JSON.stringify(toolCall.arguments, null, 2) }),
        /* @__PURE__ */ jsxRuntime.jsx(designSystem.CodeBlock.Footer, {})
      ] })
    ] }),
    toolCall.result !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tv.block(), children: [
      /* @__PURE__ */ jsxRuntime.jsx("div", { className: tv.blockTitle(), children: toolCallResult }),
      /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CodeBlock, { language: "json", children: [
        /* @__PURE__ */ jsxRuntime.jsx(
          designSystem.CodeBlock.Content,
          {
            code: typeof toolCall.result === "string" ? toolCall.result : JSON.stringify(toolCall.result, null, 2)
          }
        ),
        /* @__PURE__ */ jsxRuntime.jsx(designSystem.CodeBlock.Footer, {})
      ] })
    ] })
  ] });
});
exports.MessageToolCall = MessageToolCall;
//# sourceMappingURL=message-tool-call.cjs.map
