import {
  PROGRESSABLE_WU_STATUSES
} from "./chunk-V6OJGLBA.js";

// ../initiatives/dist/initiative-validation.js
var PROGRESSABLE_STATUSES = ["draft", "open"];
function validateInitiativeCompleteness(initiative) {
  const warnings = [];
  const id = initiative.id || "unknown";
  if (!initiative.description || initiative.description.trim() === "") {
    warnings.push(`[${id}] Initiative has no description. Add a description to explain its purpose.`);
  }
  if (!initiative.phases || initiative.phases.length === 0) {
    warnings.push(`[${id}] Initiative has no phases defined. Add phases to break down the work.`);
  }
  if (!initiative.success_metrics || initiative.success_metrics.length === 0) {
    warnings.push(`[${id}] Initiative has no success_metrics defined. Add metrics to measure completion.`);
  }
  return {
    valid: true,
    // Always valid - issues are warnings not errors
    warnings
  };
}
function checkInitiativePhases(initiative) {
  const hasPhases = Array.isArray(initiative.phases) && initiative.phases.length > 0;
  const id = initiative.id || "unknown";
  return {
    hasPhases,
    warning: hasPhases ? null : `Initiative ${id} has no phases defined. Consider adding phases before linking WUs.`
  };
}
function shouldProgressInitiativeStatus(initiative, wus) {
  const currentStatus = initiative.status || "draft";
  const initiativeId = initiative.id;
  if (!PROGRESSABLE_STATUSES.includes(currentStatus)) {
    return {
      shouldProgress: false,
      newStatus: null
    };
  }
  const initiativeWUs = wus.filter((wu) => wu.initiative === initiativeId);
  const hasActiveWU = initiativeWUs.some((wu) => PROGRESSABLE_WU_STATUSES.includes(wu.status || ""));
  if (hasActiveWU) {
    return {
      shouldProgress: true,
      newStatus: "in_progress"
    };
  }
  return {
    shouldProgress: false,
    newStatus: null
  };
}

export {
  validateInitiativeCompleteness,
  checkInitiativePhases,
  shouldProgressInitiativeStatus
};
