import { z } from 'zod';
import { DeviceLocation } from '../../domain/value-objects/device-location';
import { DeviceStatus } from '../../domain/value-objects/device-status';

export const createDeviceSchema = z.object({
  location: z.object({
    long: z.number(),
    lat: z.number(),
    country: z.string().min(1),
    state: z.string().min(1),
    city: z.string().min(1),
  }) as z.ZodType<DeviceLocation>,
  type: z.string().min(1),
  info: z.string().nullable().optional(),
  ipAddress: z.string().ip(),
  userAgent: z.string().nullable().optional(),
  acceptLanguage: z.string().nullable().optional(),
  fingerprint: z.string().min(1),
  pushToken: z.string().min(1).nullable().optional(),
  status: z.enum(['active', 'background', 'closed']).optional() as z.ZodType<DeviceStatus | undefined>,
});

export type CreateDeviceInput = z.infer<typeof createDeviceSchema>;

export const deviceIdParamSchema = z.object({
  id: z.string().uuid(),
});

export const updateDeviceStatusSchema = z.object({
  status: z.enum(['active', 'background', 'closed']),
});

export type UpdateDeviceStatusInput = z.infer<typeof updateDeviceStatusSchema>;

export const updateDevicePushTokenSchema = z.object({
  pushToken: z.string().min(1).nullable(),
});

export type UpdateDevicePushTokenInput = z.infer<typeof updateDevicePushTokenSchema>;
