import { jsx, jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { previewQueuedContent } from "../../utils/queuedComposerContent.js";
const isMac = process.platform === "darwin";
const QUEUE_EDIT_SHORTCUTS = {
  currentTurn: isMac ? "\u2325 + \u2191 edit" : "Alt + \u2191 edit",
  followUp: "\u2191 edit"
};
function truncateText(text, maxLength = 60) {
  const singleLine = text.replace(/\n/g, " ").trim();
  if (singleLine.length <= maxLength) {
    return singleLine;
  }
  return singleLine.slice(0, maxLength - 3) + "...";
}
function QueuedMessagesDisplay({
  messages,
  label = "queued",
  hint = "\u2191 to edit"
}) {
  if (messages.length === 0) return null;
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
    /* @__PURE__ */ jsxs(Box, { children: [
      /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
        messages.length,
        " message",
        messages.length !== 1 ? "s" : "",
        " ",
        label
      ] }),
      /* @__PURE__ */ jsx(Text, { color: "gray", children: " \u2022 " }),
      /* @__PURE__ */ jsx(Text, { color: "gray", children: hint })
    ] }),
    messages.map((message, index) => /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
      /* @__PURE__ */ jsx(Text, { color: "gray", children: index === messages.length - 1 ? "\u21B3 " : "\u2502 " }),
      /* @__PURE__ */ jsx(Text, { color: "gray", italic: true, children: truncateText(previewQueuedContent(message.content)) })
    ] }, message.id))
  ] });
}
export {
  QUEUE_EDIT_SHORTCUTS,
  QueuedMessagesDisplay
};
