"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.messageThreadSchema = exports.ThreadMemberSchema = void 0;
const zod_1 = require("zod");
exports.ThreadMemberSchema = zod_1.z
    .object({
    id: zod_1.z.number().int().positive(),
    thread: zod_1.z.number().int().positive(),
    user: zod_1.z.number().int().positive().nullable(),
    group: zod_1.z.number().int().positive().nullable(),
    status: zod_1.z.enum(['Addressed', 'Requiring Action']), // Updated status values
    ack_time: zod_1.z
        .string()
        .nullable()
        .refine((val) => val === null || !isNaN(Date.parse(val)), {
        message: "Invalid date format for 'ack_time'",
    }),
})
    .refine((data) => !(data.user !== null && data.group !== null), {
    message: 'Should only ever be one of either a user or group set for the thread member', // Updated error message to match docs
});
const CreateThreadMemberSchema = zod_1.z.object({
    user: zod_1.z.number().int().positive().nullable().optional(),
    group: zod_1.z.number().int().positive().nullable().optional(),
    status: zod_1.z.enum(['Addressed', 'Requiring Action']),
});
exports.messageThreadSchema = zod_1.z.object({
    patient: zod_1.z.number().int().positive(),
    sender: zod_1.z.number().int().positive(),
    practice: zod_1.z.number().int().positive(),
    document_date: zod_1.z.string().refine((val) => !isNaN(Date.parse(val)), {
        message: "Invalid date format for 'document_date'",
    }),
    chart_date: zod_1.z.string().refine((val) => !isNaN(Date.parse(val)), {
        message: "Invalid date format for 'chart_date'",
    }),
    is_urgent: zod_1.z.boolean(),
    members: zod_1.z.array(CreateThreadMemberSchema),
    messages: zod_1.z.array(zod_1.z.object({
        body: zod_1.z.string().min(1, 'Message body is required'),
        send_date: zod_1.z.string().refine((val) => !isNaN(Date.parse(val)), {
            message: "Invalid date format for 'send_date'",
        }),
        sender: zod_1.z.number().int().positive(),
    })),
});
//# sourceMappingURL=messageThread.zod.js.map