import type { BrandIntelligence, StoryIntelligence, VisualIntelligence } from "./types";
import type { WebsiteIntelligence } from "@/lib/context/website-intelligence";

export function buildVisualIntelligence(
  brand: BrandIntelligence,
  story: StoryIntelligence,
  website?: WebsiteIntelligence | null,
): VisualIntelligence {
  const mood = story.letterToGodBeat.visualMood;
  const emotionLead = story.emotions[0] ?? "professional";
  const colorNote = website?.themeColor
    ? `Website theme ${website.themeColor}; product: ${website.primaryService || brand.primaryService || brand.industry}`
    : `Brand-aligned; accent reflects ${story.act}; industry: ${brand.industry}`;

  return {
    photographyStyle: `Editorial B2B — clean, authentic, reflects ${brand.primaryService || brand.industry}`,
    mood: `${emotionLead} — ${mood}`,
    lighting: story.beatIndex <= 1 ? "Dramatic natural light" : "Warm, human-centered",
    colorPalette: colorNote,
    composition: "Single focal subject, readable at mobile scale, text-safe zones",
    people: "Real professionals in context — diverse, credible, not posed clichés",
    expressions: story.beatIndex === 1 ? "Concerned, reflective" : "Hopeful, determined",
    aspectRatio: "1:1 for feed; 16:9 for YouTube thumbnail",
  };
}

export function formatVisualIntelligenceMarkdown(visual: VisualIntelligence): string {
  return [
    "## Visual Intelligence",
    `Photography style: ${visual.photographyStyle}`,
    `Mood: ${visual.mood}`,
    `Lighting: ${visual.lighting}`,
    `Color palette: ${visual.colorPalette}`,
    `Composition: ${visual.composition}`,
    `People: ${visual.people}`,
    `Expressions: ${visual.expressions}`,
    `Aspect ratio: ${visual.aspectRatio}`,
  ].join("\n");
}
