import { z } from "zod";

// Validates AI-generated PhotoshootPlan output before persisting.
// Keep loose where the model is creative, strict where the UI depends on shape.
const HexColor = z.string().regex(/^#?[0-9a-fA-F]{3,8}$/, "Invalid hex color");

export const PhotoshootPlanSchema = z.object({
  emotionalGoal: z.string().min(1).max(2000),
  tone: z.string().min(1).max(500),
  visualTheme: z.string().min(1).max(500),
  storyTitle: z.string().min(1).max(200),
  storyNarrative: z.string().min(1).max(4000),
  visualDirection: z.string().min(1).max(4000),
  wardrobe: z.array(z.string().min(1).max(500)).min(1).max(20),
  colorPalette: z
    .array(z.object({ name: z.string().min(1).max(80), hex: HexColor }))
    .min(1)
    .max(12),
  locations: z
    .array(z.object({ name: z.string().min(1).max(200), reason: z.string().min(1).max(500) }))
    .min(1)
    .max(20),
  shotList: z.array(z.string().min(1).max(500)).min(1).max(60),
  aiPrompts: z
    .array(z.object({ tool: z.string().min(1).max(40), prompt: z.string().min(1).max(4000) }))
    .min(1)
    .max(20),
  moodboard: z.object({
    lighting: z.string().min(1).max(1000),
    wardrobeStyle: z.string().min(1).max(1000),
    poseStyle: z.string().min(1).max(1000),
    environment: z.string().min(1).max(1000),
  }),
  checklist: z.object({
    wardrobe: z.array(z.string().min(1).max(300)).min(1).max(20),
    props: z.array(z.string().min(1).max(300)).min(1).max(20),
    makeupHair: z.array(z.string().min(1).max(300)).min(1).max(20),
    logistics: z.array(z.string().min(1).max(300)).min(1).max(20),
    backupPlan: z.array(z.string().min(1).max(300)).min(1).max(20),
    weather: z.array(z.string().min(1).max(300)).min(1).max(20),
  }),
});

export type ValidatedPhotoshootPlan = z.infer<typeof PhotoshootPlanSchema>;
