"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SendCallResponseSchema = exports.SendCallInputSchema = void 0;
const lodash_1 = require("lodash");
const zod_1 = require("zod");
const atoms_1 = require("./atoms");
exports.SendCallInputSchema = zod_1.z
    .object({
    pathway_id: zod_1.z.string().optional(),
    pathway_version: zod_1.z.number().optional(),
    phone_number: zod_1.z.string().min(1), // For best results, use the E.164 format.
    task: zod_1.z.string().min(1).optional(),
    voice: zod_1.z.string().optional(),
    background_track: atoms_1.BackgroundTrackSchema.optional(),
    first_sentence: zod_1.z.string().optional(),
    wait_for_greeting: zod_1.z.boolean().optional(),
    block_interruptions: zod_1.z.boolean().optional(),
    interruption_threshold: zod_1.z.number().optional(),
    model: atoms_1.ModelSchema.optional(),
    temperature: zod_1.z.number().optional(),
    dynamic_data: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).optional(),
    keywords: zod_1.z.array(zod_1.z.string()).optional(),
    pronunciation_guide: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.string())).optional(),
    transfer_phone_number: zod_1.z.string().optional(),
    transfer_list: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
    language: zod_1.z.string().optional(),
    local_dialing: zod_1.z.boolean().optional(),
    voicemail_sms: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
    dispatch_hours: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
    sensitive_voicemail_detection: zod_1.z.boolean().optional(),
    noise_cancellation: zod_1.z.boolean().optional(),
    ignore_button_press: zod_1.z.boolean().optional(),
    timezone: zod_1.z.string().optional(),
    request_data: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
    tools: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.any())).optional(),
    start_time: zod_1.z.string().optional(),
    voicemail_message: zod_1.z.string().optional(),
    voicemail_action: atoms_1.VoicemailActionSchema.optional(),
    retry: zod_1.z
        .object({
        wait: zod_1.z.number(),
        voicemail_action: atoms_1.VoicemailActionSchema,
        voicemail_message: zod_1.z.string(),
    })
        .optional(),
    max_duration: zod_1.z.number().optional(),
    record: zod_1.z.boolean().optional(),
    from: zod_1.z.string().optional(),
    webhook: zod_1.z.string().optional(),
    webhook_events: atoms_1.WebhookEventsSchema.optional(),
    metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
    analysis_preset: zod_1.z.string().optional(),
    available_tags: zod_1.z.array(zod_1.z.string()).optional(),
    geospatial_dialing: zod_1.z.string().optional(),
    precall_dtmf_sequence: zod_1.z.string().optional(),
    // Can't the below parameters in the docs anymore
    start_node_id: zod_1.z.string().optional(),
    summary_prompt: zod_1.z.string().optional(),
    analysis_prompt: zod_1.z.string().optional(),
    analysis_schema: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
    answered_by_enabled: zod_1.z.boolean().optional(),
})
    .refine((data) => {
    if ((0, lodash_1.isNil)(data.pathway_id) && (0, lodash_1.isEmpty)(data.pathway_id)) {
        return !(0, lodash_1.isNil)(data.task) && !(0, lodash_1.isEmpty)(data.task);
    }
    return true;
}, {
    message: '`task` is required when not providing a `pathway_id`',
    path: ['task'],
})
    .refine((data) => {
    if ((0, lodash_1.isNil)(data.timezone))
        return true;
    try {
        return (Intl.DateTimeFormat(undefined, {
            timeZone: data.timezone,
        }).resolvedOptions().timeZone === data.timezone);
    }
    catch (_a) {
        return false;
    }
}, 'Invalid timezone. Must be a valid IANA timezone format');
exports.SendCallResponseSchema = zod_1.z.object({
    status: zod_1.z.string(),
    call_id: zod_1.z.string().uuid(),
    message: zod_1.z.string(),
});
//# sourceMappingURL=SendCall.schema.js.map