// src/features/commit/domain/workspace.ts
function formatPendingChanges(snapshot) {
  if (!snapshot.available) {
    return snapshot.note;
  }
  return [
    `- Git Root: \`${snapshot.gitRoot}\``,
    `- Branch: \`${snapshot.branch || "(detached)"}\``,
    "",
    "### git status --short",
    "```text",
    snapshot.statusLines.join("\n") || "(\uC5C6\uC74C)",
    "```",
    "",
    "### git diff --stat",
    "```text",
    snapshot.diffStat || "(\uC5C6\uC74C)",
    "```"
  ].join("\n");
}
function getCommitUntrackedFilePaths(snapshot) {
  return snapshot.statusLines.map((line) => line.trim()).filter((line) => line.startsWith("?? ")).map((line) => line.slice(3).trim()).filter(Boolean);
}
function getCommitTargetFilePaths(snapshot) {
  const fromDiffNameStatus = snapshot.diffNameStatus.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => line.split("	").pop()?.trim() || "").filter(Boolean);
  if (fromDiffNameStatus.length > 0) {
    return Array.from(new Set(fromDiffNameStatus));
  }
  const fromStatusLines = snapshot.statusLines.map((line) => line.trim().slice(3).split(" -> ").pop()?.trim() || "").filter(Boolean);
  return Array.from(new Set(fromStatusLines));
}

export { formatPendingChanges, getCommitTargetFilePaths, getCommitUntrackedFilePaths };
