/** Shared PRD plan sections (discovery phases → document headings). */

export const DISCOVERY_PHASE_ORDER = [
  "big_picture",
  "users_personas",
  "features_scope",
  "business_model",
  "screens_data",
  "risks_questions",
] as const;

export type DiscoveryPhaseId = (typeof DISCOVERY_PHASE_ORDER)[number];

export const PRD_PLAN_SECTIONS = [
  { id: "executive_summary", label: "Executive Summary", phaseId: "big_picture" as const },
  { id: "problem_statement", label: "Problem Statement", phaseId: "big_picture" as const },
  { id: "vision_metrics", label: "Vision & Success Metrics", phaseId: "big_picture" as const },
  { id: "users_personas", label: "Users & Personas", phaseId: "users_personas" as const },
  { id: "user_flows", label: "User Flows", phaseId: "users_personas" as const },
  { id: "feature_requirements", label: "Feature Requirements", phaseId: "features_scope" as const },
  { id: "screen_specs", label: "Screen Specs", phaseId: "screens_data" as const },
  { id: "business_model", label: "Business Model", phaseId: "business_model" as const },
  { id: "integrations", label: "Integrations & Dependencies", phaseId: "features_scope" as const },
  { id: "non_functional", label: "Non-Functional Reqs", phaseId: null },
  { id: "risks", label: "Risks & Mitigations", phaseId: "risks_questions" as const },
  { id: "open_questions", label: "Open Questions", phaseId: "risks_questions" as const },
] as const;

/** Matches legacy PrdContent: sections without a phase are never marked done in the checklist. */
export function isSectionFilled(phaseId: string | null, savedPhaseIds: Set<string>): boolean {
  if (phaseId === null) return false;
  return savedPhaseIds.has(phaseId);
}
