"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.activeSchema = exports.canceledSchema = exports.baseWebhookPayloadSchema = exports.triggerEventSchema = void 0;
const zod_1 = require("zod");
const types_1 = require("./types");
exports.triggerEventSchema = zod_1.z.nativeEnum(types_1.TriggerEvent);
const questionAndAnswerSchema = zod_1.z.object({
    question: zod_1.z.string(),
    answer: zod_1.z.string(),
    position: zod_1.z.number(),
});
const trackingSchema = zod_1.z.object({
    utm_campaign: zod_1.z.string().nullable(),
    utm_source: zod_1.z.string().nullable(),
    utm_medium: zod_1.z.string().nullable(),
    utm_content: zod_1.z.string().nullable(),
    utm_term: zod_1.z.string().nullable(),
    salesforce_uuid: zod_1.z.string().nullable(),
});
const cancellationSchema = zod_1.z.object({
    canceled_by: zod_1.z.string(),
    reason: zod_1.z.string().nullable(),
    canceler_type: zod_1.z.union([zod_1.z.literal('invitee'), zod_1.z.literal('host')]),
    created_at: zod_1.z.string(),
});
exports.baseWebhookPayloadSchema = zod_1.z.object({
    event: exports.triggerEventSchema,
    created_at: zod_1.z.string(),
    created_by: zod_1.z.string(),
    payload: zod_1.z.object({
        created_at: zod_1.z.string(),
        updated_at: zod_1.z.string(),
        text_reminder_number: zod_1.z.string().nullable(),
        event: zod_1.z.string(),
        scheduled_event: zod_1.z.object({
            start_time: zod_1.z.string(),
            end_time: zod_1.z.string(),
            uri: zod_1.z.string(),
            event_type: zod_1.z.string(),
            event_memberships: zod_1.z.array(zod_1.z.object({
                user: zod_1.z.string(),
                user_email: zod_1.z.string(),
            })),
            location: zod_1.z.any(),
            name: zod_1.z.string(),
            status: zod_1.z.union([zod_1.z.literal('active'), zod_1.z.literal('canceled')]),
            invitees_counter: zod_1.z.object({
                total: zod_1.z.number(),
                active: zod_1.z.number(),
                limit: zod_1.z.number(),
            }),
            created_at: zod_1.z.string(),
            updated_at: zod_1.z.string(),
            event_guests: zod_1.z.array(zod_1.z.object({
                email: zod_1.z.string(),
                created_at: zod_1.z.string(),
                updated_at: zod_1.z.string().optional(),
            })),
        }),
        uri: zod_1.z.string(),
        email: zod_1.z.string(),
        name: zod_1.z.string(),
        status: zod_1.z.union([zod_1.z.literal('active'), zod_1.z.literal('canceled')]),
        timezone: zod_1.z.string(),
        rescheduled: zod_1.z.boolean(),
        cancel_url: zod_1.z.string(),
        reschedule_url: zod_1.z.string(),
        new_invitee: zod_1.z.string().nullable(),
        old_invitee: zod_1.z.string().nullable(),
        questions_and_answers: zod_1.z.array(questionAndAnswerSchema),
        tracking: trackingSchema,
        first_name: zod_1.z.string().optional().nullable(),
        last_name: zod_1.z.string().optional().nullable(),
        no_show: zod_1.z
            .object({
            uri: zod_1.z.string(),
            created_at: zod_1.z.string(),
        })
            .optional()
            .nullable(),
        reconfirmation: zod_1.z
            .object({
            confirmed_at: zod_1.z.string(),
            created_at: zod_1.z.string(),
        })
            .optional()
            .nullable(),
        payment: zod_1.z.null().optional(),
        invitee_scheduled_by: zod_1.z.string().optional().nullable(),
        routing_form_submission: zod_1.z.string().optional().nullable(),
        scheduling_method: zod_1.z.string().optional().nullable(),
    }),
});
const canceledScheduledEventSchema = exports.baseWebhookPayloadSchema.shape.payload.shape.scheduled_event.extend({
    status: zod_1.z.literal('canceled'),
});
const activeScheduledEventSchema = exports.baseWebhookPayloadSchema.shape.payload.shape.scheduled_event.extend({
    status: zod_1.z.literal('active'),
});
const canceledPayload = exports.baseWebhookPayloadSchema.shape.payload.extend({
    status: zod_1.z.literal('canceled'),
    scheduled_event: canceledScheduledEventSchema,
    cancellation: cancellationSchema,
});
const activePayload = exports.baseWebhookPayloadSchema.shape.payload.extend({
    status: zod_1.z.literal('active'),
    scheduled_event: activeScheduledEventSchema,
});
exports.canceledSchema = exports.baseWebhookPayloadSchema.extend({
    payload: canceledPayload,
});
exports.activeSchema = exports.baseWebhookPayloadSchema.extend({
    payload: activePayload,
});
//# sourceMappingURL=schema.js.map