import { z } from 'zod';

export const createLlmProviderSchema = z.object({
  name: z.string().min(1).max(50),
  display_name: z.string().min(1).max(100),
  api_base_url: z.string().url(),
  auth_header_format: z.string().default('Bearer'),
  api_key_env_var: z.string().max(100).optional().nullable(),
  is_active: z.boolean().optional(),
  display_order: z.number().int().optional(),
});

export const updateLlmProviderSchema = createLlmProviderSchema.partial();

export const createLlmModelSchema = z.object({
  provider_id: z.string().uuid(),
  model_id: z.string().min(1).max(200),
  display_name: z.string().min(1).max(200),
  context_length: z.number().int().positive().optional(),
  supports_functions: z.boolean().optional(),
  is_active: z.boolean().optional(),
  display_order: z.number().int().optional(),
});

export const updateLlmModelSchema = createLlmModelSchema.partial();

export type CreateLlmProviderInput = z.infer<typeof createLlmProviderSchema>;
export type UpdateLlmProviderInput = z.infer<typeof updateLlmProviderSchema>;

export const createVoiceProviderSchema = z.object({
  name: z.string().min(1).max(50),
  display_name: z.string().min(1).max(100),
  api_base_url: z.string().url(),
  api_key_env_var: z.string().max(100).optional().nullable(),
  is_active: z.boolean().optional(),
  display_order: z.number().int().optional(),
});

export const updateVoiceProviderSchema = createVoiceProviderSchema.partial();

export type CreateVoiceProviderInput = z.infer<typeof createVoiceProviderSchema>;
export type UpdateVoiceProviderInput = z.infer<typeof updateVoiceProviderSchema>;

export const createVoiceModelSchema = z.object({
  voice_provider_id: z.string().uuid(),
  voice_id: z.string().min(1).max(200),
  display_name: z.string().min(1).max(200),
  language_code: z.string().max(20).optional(),
  gender: z.string().max(20).optional(),
  is_active: z.boolean().optional(),
  display_order: z.number().int().optional(),
});

export const updateVoiceModelSchema = createVoiceModelSchema.partial();
