// src/actions/result.ts
function actionResult({
  errorCount,
  exitCode = errorCount,
  warningCount
}) {
  if (errorCount === 0 && warningCount === 0 && exitCode === 0) return 0;
  return {
    envelope: {
      errorCount,
      warningCount
    },
    exitCode
  };
}
function resultFromExitCode(exitCode) {
  return actionResult({
    errorCount: exitCode === 0 ? 0 : Math.max(1, exitCode),
    exitCode,
    warningCount: 0
  });
}
function resultExitCode(result) {
  return typeof result === "number" ? result : result.exitCode;
}
function resultErrorCount(result) {
  if (typeof result === "number") return result === 0 ? 0 : Math.max(1, result);
  return result.envelope?.errorCount ?? (result.exitCode === 0 ? 0 : Math.max(1, result.exitCode));
}
function resultWarningCount(result) {
  return typeof result === "number" ? 0 : result.envelope?.warningCount ?? 0;
}
function isCleanResult(result) {
  return resultExitCode(result) === 0 && resultErrorCount(result) === 0 && resultWarningCount(result) === 0;
}
function combineResults(results) {
  const errorCount = results.reduce((sum, result) => sum + resultErrorCount(result), 0);
  const warningCount = results.reduce((sum, result) => sum + resultWarningCount(result), 0);
  const exitCode = results.reduce((sum, result) => sum + resultExitCode(result), 0);
  return actionResult({
    errorCount,
    exitCode,
    warningCount
  });
}
export {
  actionResult,
  combineResults,
  isCleanResult,
  resultErrorCount,
  resultExitCode,
  resultFromExitCode,
  resultWarningCount
};
//# sourceMappingURL=result.mjs.map
