/**
 * 聊天历史中的单条消息
 * 原始 Dart: ChatMessage (lib/data/models/chat/chat_response.dart)
 */
import { z } from "zod";

export const ChatMessageSchema = z
  .object({
    role: z.string(),
    content: z.string(),
    id: z.string().default(""),
    createdAt: z.string().default(""),
    created_at: z.string().optional(),
    isPrivate: z.boolean().nullable().default(null),
    privateLocked: z.boolean().nullable().default(null),
    privateHint: z.string().nullable().default(null),
  })
  .transform(({ created_at, ...data }) => ({
    ...data,
    createdAt: data.createdAt || created_at || "",
  }));

export type ChatMessageInput = z.input<typeof ChatMessageSchema>;
export type ChatMessageData = z.output<typeof ChatMessageSchema>;
