import * as z from "zod";

import { DIAGRAM_TYPES } from "./types";

export const selectedElementSchema = z.object({
  id: z.string().min(1),
  type: z.string().min(1),
  label: z.string().min(1),
});

export const copilotMessageSchema = z.object({
  id: z.string(),
  chatId: z.string(),
  diagramId: z.string(),
  diagramType: z.enum(DIAGRAM_TYPES as [string, ...string[]]),
  graphContext: z.string().optional(),
  selectedElements: z.array(selectedElementSchema).optional(),
  parts: z.array(
    z.object({
      type: z.literal("text"),
      text: z.string(),
    }),
  ),
  role: z.enum(["user", "assistant"]).optional().default("user"),
});

export type CopilotMessagePayload = z.infer<typeof copilotMessageSchema>;
