"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var FileRenderer_exports = {};
__export(FileRenderer_exports, {
  FileRenderer: () => FileRenderer
});
module.exports = __toCommonJS(FileRenderer_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_ink = require("ink");
var import_messageFormatting = require("../../utils/messageFormatting.js");
var import_diff_shared = require("./diff-shared.js");
function FileRenderer({ data, maxLines = 20 }) {
  const { operation, lineCount, path, content } = data;
  const relativePath = (0, import_messageFormatting.makeRelativePath)(path);
  if (operation === "read") {
    const lineText = lineCount !== void 0 ? `${lineCount} lines` : "file";
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
      "  \u23BF ",
      "Read ",
      lineText,
      " from ",
      relativePath
    ] });
  }
  if (operation === "write" || operation === "create") {
    const verb = operation === "create" ? "Created" : "Wrote";
    if (operation === "create" && content) {
      const lines = content.split("\n");
      const displayLines = lines.slice(0, maxLines);
      const truncatedCount = lines.length - displayLines.length;
      const lineNumWidth = (0, import_diff_shared.getLineNumWidth)(lines.length);
      return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { children: [
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: "  \u23BF " }),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { children: relativePath }),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "green", children: " (created)" })
        ] }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", paddingLeft: 2, children: [
          displayLines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { children: [
            /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: (0, import_diff_shared.formatLineNum)(index + 1, lineNumWidth) }),
            /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { wrap: "wrap", children: [
              "   ",
              line
            ] })
          ] }, index)),
          truncatedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
            "... +",
            truncatedCount,
            " lines"
          ] })
        ] })
      ] });
    }
    const lineText = lineCount !== void 0 ? `${lineCount} lines` : "content";
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
      "  \u23BF ",
      verb,
      " ",
      lineText,
      " to ",
      relativePath
    ] });
  }
  if (operation === "delete") {
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
      "  \u23BF ",
      "Deleted ",
      relativePath
    ] });
  }
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
    "  \u23BF ",
    operation
  ] });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FileRenderer
});
