/**
 * 发送消息响应
 * 
 */
import { z } from "zod";
import { booleanOrFalse, stringOrNull } from "../nullable-defaults";
import { ChatImageSchema, ChatLockDetailSchema } from "./chat_payloads";

export const ChatSendResponseSchema = z.object({
  reply: z.string(),
  audioUrl: z.string().default(""),
  messageId: z.string(),
  isGuest: booleanOrFalse,
  // 函数式 default —— 每次 parse 时重新调 Date.now()（后端不返回 timestamp 时用当下时间）
  timestamp: z.number().default(() => Date.now()),
  image: ChatImageSchema,
  lockDetail: ChatLockDetailSchema,
  canSendMessage: z.boolean().default(true),
  cannotSendReason: stringOrNull,
  creditBalance: z.number().default(0),
  creditsCharged: z.number().default(0),
  requiredCredits: z.number().default(0),
  shortfallCredits: z.number().default(0),
});

export type ChatSendResponseInput = z.input<typeof ChatSendResponseSchema>;
export type ChatSendResponseData = z.output<typeof ChatSendResponseSchema>;
