type BookingExpiresAt = string | Date | Record | null | undefined const bookingExpiresAtMs = (expiresAt: BookingExpiresAt): number | null => { if (expiresAt == null) return null if (typeof expiresAt === 'string' || expiresAt instanceof Date) { const ms = new Date(expiresAt).getTime() return Number.isNaN(ms) ? null : ms } return null } /** Whether a pending_payment booking's hold window has passed (client clock). */ export const isBookingPaymentExpired = (booking: { status: string; expiresAt?: BookingExpiresAt }): boolean => { const expiresAtMs = bookingExpiresAtMs(booking.expiresAt) return booking.status === 'pending_payment' && expiresAtMs != null && expiresAtMs <= Date.now() }