import React from 'react'; import { IcStar, IcClose, IcBookmark, IcShare, IcNavigation, IcHotel, IcLayers, IcPhone, IcGlobe, IcMore, IcCheck, } from '../../res/icons'; import { getPlaceTypeLabel } from '../../constants'; import { getDate as timeGetDate } from '../../../../os/TimeService'; import { buildAboutSections, computeOpeningStatusFromPeriods } from '../../utils/placeUtils'; import { HoursCard } from '../HoursCard'; import { AddressCard } from '../AddressCard'; import { useMapBackHandler } from '../../hooks/useMapBackHandler'; import { useMapStrings } from '../../hooks/useMapStrings'; import { useLocale } from '../../locale'; import { readLatLngLike } from '../../utils/latLng'; interface PlaceDetailSheetProps { sheetRef: React.RefObject; sheetHeight: number; isDragging: boolean; isLoading: boolean; detailSheetPointerHandlers: { onPointerDown: React.PointerEventHandler; onPointerMove: React.PointerEventHandler; onPointerUp: React.PointerEventHandler; onPointerCancel: React.PointerEventHandler; }; selectedPlace: google.maps.places.PlaceResult & Record; setSelectedPlace: (p: google.maps.places.PlaceResult | null) => void; replaceState: (state: Record) => void; detailTab: 'overview' | 'about'; setDetailTab: (t: 'overview' | 'about') => void; } export const PlaceDetailSheet: React.FC = ({ sheetRef, sheetHeight, isDragging, isLoading, detailSheetPointerHandlers, selectedPlace, setSelectedPlace, replaceState, detailTab, setDetailTab, }) => { const s = useMapStrings(); const locale = useLocale(); const handleClose = () => { setSelectedPlace(null); replaceState({}); }; useMapBackHandler( () => { handleClose(); return true; }, { priority: 450 }, ); return (
e.stopPropagation()}>

{selectedPlace.name || s.place_detail_title}

{isLoading && (
{s.place_loading_detail}
)} {!isLoading && selectedPlace.rating != null && (
{selectedPlace.rating.toFixed(1)}
{[...Array(5)].map((_, i) => ( ))}
{selectedPlace.user_ratings_total != null && ( ({selectedPlace.user_ratings_total.toLocaleString()}) )}
)} {!isLoading && (
{getPlaceTypeLabel( selectedPlace.types, (selectedPlace as { primaryType?: string }).primaryType, (selectedPlace as { primaryTypeDisplayName?: string }).primaryTypeDisplayName, locale, )}
)} {!isLoading && (() => { const hrs = (selectedPlace as { regularOpeningHours?: { periods?: unknown[] } }).regularOpeningHours; if (!hrs?.periods?.length) return null; const { isOpen, closesAt, opensNextLabel } = computeOpeningStatusFromPeriods(hrs as { periods: any[] }, timeGetDate(), locale); return (
{isOpen ? s.place_open_now : s.place_closed_now} {isOpen && closesAt && · {s.place_closes_at}{closesAt}} {!isOpen && opensNextLabel && · {s.place_opens_at}{opensNextLabel}}
); })()}
{isLoading ? (
e.stopPropagation()}>
) : (
e.stopPropagation()}> {selectedPlace.types?.includes('lodging') || selectedPlace.types?.includes('hotel') ? ( ) : selectedPlace.types?.includes('tourist_attraction') && !selectedPlace.types?.includes('park') ? ( ) : null} {selectedPlace.types?.includes('restaurant') || selectedPlace.types?.includes('food') ? ( <> ) : ( <> {!(selectedPlace.types?.includes('lodging') || selectedPlace.types?.includes('hotel')) && ( )} )}
)}
{isLoading ? (
{s.place_loading_detail}
) : ( <>
{selectedPlace.types?.includes('tourist_attraction') && ( )} {(selectedPlace.types?.includes('lodging') || selectedPlace.types?.includes('hotel')) && ( )}
{detailTab === 'about' && (() => { const aboutSections = buildAboutSections((selectedPlace as { _aboutData?: Record })._aboutData, locale); if (!aboutSections.length) return
{s.place_no_description}
; return (
{aboutSections.map((section) => (

{section.title}

{section.items.map((item) => (
{item.label}
))}
))}
); })()} {detailTab === 'overview' && (
{(selectedPlace as { editorialSummary?: string }).editorialSummary && (
{(selectedPlace as { editorialSummary?: string }).editorialSummary}
)}
{(selectedPlace as { regularOpeningHours?: { periods?: unknown[] } }).regularOpeningHours?.periods?.length ? ( (() => { const hrs = (selectedPlace as { regularOpeningHours: { periods: any[]; weekdayDescriptions?: string[] } }) .regularOpeningHours; const st = computeOpeningStatusFromPeriods(hrs, timeGetDate(), locale); return ( ); })() ) : null} {(selectedPlace as { websiteURI?: string }).websiteURI && (
{(selectedPlace as { websiteURI: string }).websiteURI.replace(/^https?:\/\//, '').replace(/\/$/, '')}
)} {selectedPlace.formatted_phone_number && (
{selectedPlace.formatted_phone_number}
)}
)} )}
); };