import { z } from "zod"

const timeRegex = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/
const optionalTimeFormat = z
    .string()
    .optional()
    .refine((v) => !v || timeRegex.test(v), "Time must be in HH:MM:SS format")

const shopTimingFormSchema = z.object({
    title: z.string().min(1, "Title is required").max(255, "Title cannot exceed 255 characters"),
    in_time: z.string().min(1, "In time is required").regex(timeRegex, "In time must be in HH:MM:SS format"),
    out_time: z.string().min(1, "Out time is required").regex(timeRegex, "Out time must be in HH:MM:SS format"),
    full_day_hours: optionalTimeFormat,
    half_day_hours: optionalTimeFormat,
    punch_in: optionalTimeFormat,
    punch_out: optionalTimeFormat,
    before_time: optionalTimeFormat,
    after_time: optionalTimeFormat,
    is_default: z.boolean().default(false),
})

type ShopTimingFormValues = z.infer<typeof shopTimingFormSchema>

export { shopTimingFormSchema }
export type { ShopTimingFormValues }
