import type { z } from "zod"

import type { Coordinates } from "@/types/components/maps/coordinates"
import type { Amenities } from "@/types/hotel"
import type { ProductTypeCheque } from "@/types/trpc/routers/hotel/availability"
import type { HotelResponse } from "@/components/HotelReservation/SelectHotel/helpers"
import type { imageSchema } from "@/server/routers/hotels/schemas/image"
import type { CategorizedFilters } from "./hotelFilters"
import type { SelectHotelBooking } from "./selectHotel"

export interface HotelListingProps {
  hotels: HotelResponse[]
}

export interface SelectHotelMapProps {
  apiKey: string
  hotelPins: HotelPin[]
  mapId: string
  hotels: HotelResponse[]
  filterList: CategorizedFilters
  cityCoordinates: Coordinates
  bookingCode: string | undefined
  isBookingCodeRateAvailable?: boolean
}

type ImageSizes = z.infer<typeof imageSchema>["imageSizes"]
type ImageMetaData = z.infer<typeof imageSchema>["metaData"]

export type HotelPin = {
  bookingCode?: string | null
  name: string
  coordinates: Coordinates
  chequePrice: ProductTypeCheque["localPrice"] | null
  publicPrice: number | null
  memberPrice: number | null
  redemptionPrice: number | null
  voucherPrice: number | null
  rateType: string | null
  currency: string
  images: {
    imageSizes: ImageSizes
    metaData: ImageMetaData
  }[]
  amenities: Amenities
  ratings: number | null
  operaId: string
  facilityIds: number[]
}

export interface HotelListingMapContentProps {
  hotelPins: HotelPin[]
}

export interface HotelCardDialogProps {
  type?: "listing" | "standalone"
  isOpen: boolean
  data: HotelPin
  handleClose: (event: { stopPropagation: () => void }) => void
}

export interface HotelCardDialogImageProps {
  firstImage?: string
  altText?: string
  rating?: number | null
  imageError: boolean
  setImageError: (error: boolean) => void
  position: "top" | "left"
}

export interface HotelCardDialogListingProps {
  hotels: HotelResponse[]
}

export type SelectHotelMapContainerProps = {
  booking: SelectHotelBooking
  isAlternativeHotels?: boolean
}
