/**
 * Zod schemas for the post-auth onboarding API surface.
 *
 * Used at API boundary (POST /api/user/onboarding, POST /api/address/reverse-geocode).
 * Shared client+server — no CF-runtime imports here.
 */

import { z } from 'zod';

export const onboardingBodySchema = z
  .object({
    displayName: z.string().trim().min(1).max(50).optional(),
    city: z.string().trim().max(100).optional(),
    cityCode: z.string().trim().max(20).optional(),
    birthMonth: z.number().int().min(1).max(12).optional(),
    birthDay: z.number().int().min(1).max(31).optional(),
    pushOptIn: z.boolean().optional(),
  })
  .refine((b) => !!b.city === !!b.cityCode, {
    message: 'city + cityCode together or neither',
    path: ['city'],
  })
  .refine((b) => !!b.birthMonth === !!b.birthDay, {
    message: 'birthday month + day together or neither',
    path: ['birthMonth'],
  });

export type OnboardingBody = z.infer<typeof onboardingBodySchema>;

export const reverseGeocodeBodySchema = z.object({
  lat: z.number().min(-90).max(90),
  lng: z.number().min(-180).max(180),
});
export type ReverseGeocodeBody = z.infer<typeof reverseGeocodeBodySchema>;
