import type { StoryAct } from "./context-library";

/**
 * Abstract 5-beat narrative scaffold — structure and tone guidance only.
 * Inspired by classic story arcs (e.g. hope → disruption → persistence → support → realism).
 * No story-specific prose is sent to LLMs; project/website data supplies the actual content.
 */
export interface NarrativeBeatScaffold {
  index: number;
  act: StoryAct;
  phase: string;
  emotions: string[];
  lesson: string;
  visualMood: string;
  structureGuidance: string;
}

export const NARRATIVE_SCAFFOLD: NarrativeBeatScaffold[] = [
  {
    index: 0,
    act: "challenge",
    phase: "Anticipation & Investment",
    emotions: ["hope", "anticipation", "optimism"],
    lesson: "Teams invest when early signals look promising — name that expectation honestly.",
    visualMood: "Forward-looking, warm, professional optimism",
    structureGuidance:
      "Open with the business goal or opportunity the company helps with — grounded in their real services.",
  },
  {
    index: 1,
    act: "recognition",
    phase: "Disruption & Reality Check",
    emotions: ["concern", "clarity", "urgency"],
    lesson: "External shocks expose gaps — diagnose root causes, not symptoms.",
    visualMood: "Contrast, thoughtful tension, credible business realism",
    structureGuidance:
      "Reveal what breaks down when the market, platform, or process shifts — name the industry pressure and the business cost clearly.",
  },
  {
    index: 2,
    act: "solution",
    phase: "Decisive Action",
    emotions: ["determination", "confidence", "trust"],
    lesson: "Clear action beats passive hope — show how the company's offer addresses the gap.",
    visualMood: "Focused professional taking purposeful action",
    structureGuidance:
      "Connect the company's products/services directly to the problem — no generic filler.",
  },
  {
    index: 3,
    act: "proof",
    phase: "Support & Validation",
    emotions: ["trust", "relief", "momentum"],
    lesson: "Evidence and outcomes rebuild confidence — use concrete benefits from the brand.",
    visualMood: "Collaborative, results-oriented, human warmth",
    structureGuidance:
      "Highlight measurable or credible outcomes the company's customers can expect.",
  },
  {
    index: 4,
    act: "path_forward",
    phase: "Realistic Expectations",
    emotions: ["wisdom", "resolve", "long-term thinking"],
    lesson: "Sustainable growth requires realistic expectations and the right partner.",
    visualMood: "Calm confidence, strategic horizon, professional maturity",
    structureGuidance:
      "Close with a forward-looking CTA aligned to the company website and tagline.",
  },
];

export function getNarrativeScaffold(beatIndex: number): NarrativeBeatScaffold {
  const normalized =
    ((beatIndex % NARRATIVE_SCAFFOLD.length) + NARRATIVE_SCAFFOLD.length) %
    NARRATIVE_SCAFFOLD.length;
  return NARRATIVE_SCAFFOLD[normalized]!;
}
