import {
  getGitForCwd
} from "./chunk-2UFQ3A3C.js";
import {
  die
} from "./chunk-RXRKBBSM.js";

// ../core/dist/git-staged-validator.js
function ensureStaged(paths) {
  const git = getGitForCwd();
  const raw = git.run("git diff --cached --name-only");
  const staged = raw ? raw.split(/\r?\n/).filter((s) => Boolean(s)) : [];
  const normalizedPaths = paths.filter((p) => typeof p === "string" && p.length > 0);
  const missing = normalizedPaths.filter((p) => {
    const pathToCheck = p.endsWith("/") ? p.slice(0, -1) : p;
    return !staged.some((name) => name === pathToCheck || name.startsWith(`${pathToCheck}/`));
  });
  if (missing.length) {
    die(`Stage updates for: ${missing.join(", ")}`);
  }
  return staged;
}

export {
  ensureStaged
};
