"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TrackPersonEventResponseSchema = exports.TrackPersonEventInputSchema = exports.IdentifiersSchema = void 0;
const zod_1 = __importDefault(require("zod"));
const atoms_1 = require("./atoms");
const emailValidation_1 = require("../../../../../src/utils/emailValidation");
exports.IdentifiersSchema = zod_1.default
    .object({
    // Only one of these should be present
    id: zod_1.default.string().optional(),
    email: emailValidation_1.optionalEmailSchema,
    cio_id: zod_1.default.string().optional(),
})
    .refine((data) => {
    // Ensure exactly one identifier is provided
    const count = [data.id, data.email, data.cio_id].filter(Boolean).length;
    return count === 1;
}, {
    message: 'Must provide exactly one of: id, email, or cio_id',
    path: ['identifiers'],
});
exports.TrackPersonEventInputSchema = zod_1.default.object({
    type: zod_1.default.literal(atoms_1.EventType.Values.person),
    action: zod_1.default.literal(atoms_1.ActionType.Values.event),
    identifiers: exports.IdentifiersSchema,
    name: zod_1.default.string().min(1),
    attributes: zod_1.default.record(zod_1.default.string(), zod_1.default.string()).optional(),
});
exports.TrackPersonEventResponseSchema = zod_1.default.object({
    errors: zod_1.default
        .array(zod_1.default.object({
        reason: zod_1.default.string(),
        field: zod_1.default.string(),
        message: zod_1.default.string(),
    }))
        .optional(),
});
//# sourceMappingURL=TrackPersonEvent.schema.js.map