/**
 * Entertainment page data layer.
 *
 * Same pattern as homepage & green-energy: bundled defaults with
 * Strapi merge-over-defaults when enabled.
 */

import { fetchSingle, getMediaUrl } from "@/lib/strapi/client"
import { isStrapiEnabled } from "@/lib/strapi/config"
import { titleCase } from "@/lib/api/casing"
import { normalizeCmsLink } from "@/lib/api/links"
import type {
  EntertainmentData,
  EntertainmentRideData,
  EntertainmentRideCategoryData,
  EntertainmentEventData,
  EntertainmentRestaurantData,
  EntertainmentStatData,
  StrapiMedia,
} from "@/lib/strapi/types"

/* ------------------------------------------------------------------ */
/*  Bundled defaults (current hardcoded content)                       */
/* ------------------------------------------------------------------ */

export const entertainmentDefaults: EntertainmentData = {
  hero: {
    heading: "MGM Dizzee World",
    description: "30 Years of Entertainment Excellence",
    mobileVideoUrl: "/assets/entertainment/hero-video-mobile.mp4",
    desktopVideoUrl: "/assets/entertainment/hero-video-desktop.mp4",
  },
  about: {
    badge: "about MGM Dizzee World",
    badgeIcon: "",
    watermarkText: "Dizzee World",
    paragraphs: [
      `A pioneer in India's amusement industry, MGM Dizzee World continues to set benchmarks in entertainment and family recreation along Chennai's scenic ECR. Spanning 30 acres, this iconic destination has been delighting visitors since 1995 and has evolved into a beloved family attraction, welcoming nearly a million guests each year.`,
      `MGM Dizzee World offers a wide range of thrilling rides and attractions, each maintained with international-standard safety measures to ensure a secure and memorable experience. The park is also certified with ISO 14001:2015 for Environmental Management Systems and ISO 45001:2018 for Occupational Health and Safety Management Systems, reflecting its strong commitment to sustainability, safety, and operational excellence.`,
      `From classic favourites to modern thrill rides, every attraction is designed to deliver excitement and unforgettable moments. The park also features an elegant amphitheatre and unique attractions that enhance the overall visitor experience. Guests can enjoy a diverse culinary journey, with vegetarian dining at the Surfin Food Court—featuring both air-conditioned (54 seats) and non-air-conditioned (300 seats) sections—and non-vegetarian cuisine at Dizzee Den.`,
      `Over the years, MGM Dizzee World has achieved several remarkable milestones that highlight its legacy and innovation. These include Tamil Nadu's first hot air balloon ride, bird shows, live pop concerts, and the 2005 launch event of Ford's Ikon car. The park also recorded 11,000 visitors in a single day in 2000 and again in 2017, along with 105,198 entries in May 2017—the highest annual footfall recorded. In February 2023, it further achieved a milestone by welcoming 70,000 visitors in a single month.`,
      `Today, MGM Dizzee World stands as a symbol of joy, adventure, safety, and togetherness, creating memorable experiences for generations of visitors.`,
    ],
  },
  rides: {
    badge: "Rides & Attractions",
    badgeIcon: "",
    watermarkText: "Rides & Attractions",
    ctaLabel: "View All",
    ctaHref: "#rides",
    categories: [
      {
        name: "Family Ride",
        rides: [
          { name: "Balloon Race", description: "Elevate the fun as you ascend gently in balloon-themed gondolas for views!", image: "/assets/Rides/Family Ride/BALLOON RACE.jpg" },
          { name: "Carousel", description: "Whirling dreams on a timeless spin for the young and young at heart.", image: "/assets/Rides/Family Ride/CAROUSEL.jpg" },
          { name: "Crocodile", description: "Hop on the Crocodile for a snappy ride filled with fun and laughter!", image: "/assets/Rides/Family Ride/CROCODILE.jpg" },
          { name: "Reindeer Coaster", description: "A sleigh-like ride through gentle hills and cheerful family fun for all.", image: "/assets/Rides/Family Ride/Reindeer Coaster.JPG" },
          { name: "Star Wheels", description: "Reach for the stars on our Ferris wheel, glowing bright against the night sky.", image: "/assets/Rides/Family Ride/STAR WHEELS.jpg" },
          { name: "Sky Glider", description: "Glide through the sky and enjoy a bird's-eye view of the park with nice views.", image: "/assets/Rides/Family Ride/Sky Glider .jpg" },
          { name: "Twister", description: "Spiralling joy and excitement for an unforgettable family adventure ride.", image: "/assets/Rides/Family Ride/TWISTER.jpg" },
          { name: "Tagada", description: "Enjoy laughs and excitement with friends and family on the thrilling Tagada ride.", image: "/assets/Rides/Family Ride/Tagada.JPG" },
          { name: "Tornado Coaster", description: "A whirlwind of gentle screams and gleeful cheers for all ages to enjoy today!", image: "/assets/Rides/Family Ride/Tornado Coaster.jpg" },
          { name: "Dashing Car", description: "Bump, dodge, and race your way through nonstop fun and excitement.", image: "/assets/Rides/Family Ride/dashing car.JPG" },
        ],
      },
      {
        name: "Adult Ride",
        rides: [
          { name: "Big Wheel", description: "Reach for the stars on our Ferris wheel, shining bright through the night.", image: "/assets/Rides/Adult Ride/Big Wheel.jpg" },
          { name: "Crazy Battle", description: "Experience a crazy battle where power, speed, and strategy collide, creating a high-energy clash.", image: "/assets/Rides/Adult Ride/CRAZY. BATTLE (1) (2).jpg" },
          { name: "Disco Saucer", description: "Spin in style with vibrant lights, energetic twists, and nonstop fun.", image: "/assets/Rides/Adult Ride/Disco Saucer.jpg" },
          { name: "Nilagiri Express", description: "Enjoy a delightful train ride filled with scenic views and excitement.", image: "/assets/Rides/Adult Ride/Nilagiri express.jpg" },
          { name: "Robo Cop", description: "A futuristic spinning and swinging ride with suspended seating for intense thrills.", image: "/assets/Rides/Adult Ride/ROBO COP (2).jpg" },
          { name: "Roll O Roll", description: "Twist, turn, and spin through a thrilling ride packed with excitement and fun.", image: "/assets/Rides/Adult Ride/ROLL O ROLL.jpg" },
          { name: "Roller Coaster", description: "Get ready for thrilling drops, sharp twists, and an adrenaline-filled adventure.", image: "/assets/Rides/Adult Ride/ROLLER COASTER.jpg" },
          { name: "Ranger", description: "Soar between earth and sky in a thrilling ride filled with gravity-defying fun.", image: "/assets/Rides/Adult Ride/Ranger.jpg" },
          { name: "Super Trooper", description: "Experience the thrill of spinning and bouncing together on this action-packed ride.", image: "/assets/Rides/Adult Ride/SUPER TROOPER.jpg" },
          { name: "Space Battle", description: "Fly through the galaxy on this intense space battle ride.", image: "/assets/Rides/Adult Ride/Space battle.jpeg" },
          { name: "Super Bike", description: "Spin and rotate your way through an exciting high-speed biking adventure.", image: "/assets/Rides/Adult Ride/Super Bike.jpg" },
          { name: "Water Coaster", description: "Dive into excitement with thrilling drops and refreshing water-filled fun.", image: "/assets/Rides/Adult Ride/WATER COASTER.jpg" },
          { name: "Wave Swinger", description: "Soar in circles and enjoy the feeling of flying high above the ground.", image: "/assets/Rides/Adult Ride/WAVE SWINGER.jpg" },
        ],
      },
      {
        name: "Kid Rides",
        rides: [
          { name: "Batman Jet", description: "Batman Jet takes you on a thrilling ride with fast spins and exciting superhero-style aerial fun!", image: "/assets/Rides/Kid Rides/BATMAN JET.jpg" },
          { name: "Caterpillar", description: "Wiggle, giggle, and bounce along with our fun-loving caterpillar ride.", image: "/assets/Rides/Kid Rides/Catterpillar.jpg" },
          { name: "Ferrari's Wheel", description: "Enjoy the thrill and excitement of soaring highs and gentle drops on Ferrari's Wheel.", image: "/assets/Rides/Kid Rides/FERRARI_S WHEEL.jpg" },
          { name: "Crazy Horse", description: "Little riders enjoy joyful gallops on our charming pony carousel ride.", image: "/assets/Rides/Kid Rides/GRACY HORSE.jpg" },
          { name: "Cracy Bus", description: "All aboard for a thrilling bus ride filled with loops, twists, and fun.", image: "/assets/Rides/Kid Rides/Gracy Bus.jpg" },
          { name: "Cracy Cup", description: "Spin into colourful fun with twirling teacups full of joy and excitement.", image: "/assets/Rides/Kid Rides/Gracy Cup.jpg" },
          { name: "Graffity Tower", description: "Fun-filled ups and downs designed for kids to enjoy a safe and exciting ride!", image: "/assets/Rides/Kid Rides/Graffity tower.jpg" },
          { name: "He Man Jet", description: "Fly through the air with exciting spins, swift turns, and nonstop adventure.", image: "/assets/Rides/Kid Rides/He man Jet.jpg" },
          { name: "Jurassic Train", description: "Travel back in time with every spin on this fun-filled classic ride.", image: "/assets/Rides/Kid Rides/JURASSIC TRAIN.jpg" },
          { name: "Magic MGR", description: "Spin through a world of magic and wonder on this enchanting family ride.", image: "/assets/Rides/Kid Rides/MAGIC MGR.jpg" },
          { name: "Sun N Moon", description: "Circle through the fun on this delightful Ferris wheel made for children.", image: "/assets/Rides/Kid Rides/SUN N MOON.jpg" },
          { name: "Baby Slumbum", description: "A gentle first ride for toddlers, filled with laughter and joyful moments.", image: "/assets/Rides/Kid Rides/baby slumbum.jpg" },
          { name: "Mini Jet", description: "Young pilots can take control and enjoy an exciting mini-flight adventure.", image: "/assets/Rides/Kid Rides/mini jet.JPG" },
        ],
      },
      {
        name: "Water Park",
        rides: [
          { name: "Get Wet", description: "Get Wet is an exciting water ride with fast slides and splashes, delivering thrilling fun!", image: "/assets/Rides/Water Park/GET WET water PArk.jpg" },
          { name: "Kids Zone", description: "A dedicated water fun area designed especially for our youngest guests.", image: "/assets/Rides/Water Park/Kids zone.jpg" },
          { name: "Rain Dance", description: "Dance and splash under refreshing showers in our thrilling artificial rain zone.", image: "/assets/Rides/Water Park/Rain Dance.jpg" },
          { name: "Splash Zone", description: "Cool off with a refreshing splash under the warmth of the sunny sky.", image: "/assets/Rides/Water Park/Splash zone 1.jpg" },
          { name: "Swimming Pool", description: "Bring the whole family together for splashing fun in this relaxing pool.", image: "/assets/Rides/Water Park/Swimming Pool 2.jpg" },
          { name: "Thunder Falls", description: "Cool off beneath the soothing flow of our tropical coconut waterfall.", image: "/assets/Rides/Water Park/Thunder Falls 1.jpg" },
          { name: "Water Coaster", description: "Enjoy the thrilling splash as you race down the exciting water tube ride.", image: "/assets/Rides/Water Park/Water Coaster.jpg" },
        ],
      },
      {
        name: "Paid Attraction",
        rides: [
          { name: "360 Cycle", description: "Hop on the 360 Cycle for a thrilling ride packed with fun and adventure.", image: "/assets/Rides/Photo Spot/360 cycle.JPG" },
          { name: "5D Theatre", description: "5D Theatre offers an immersive experience with motion seats, visuals, and effects for thrilling fun.", image: "/assets/Rides/Photo Spot/5-D theatre.jpg" },
          { name: "Boxing", description: "Test your strength and show off your punching power on the boxing dummy!", image: "/assets/Rides/Photo Spot/Boxing.jpg" },
          { name: "Cricket", description: "Step up to the crease and enjoy the excitement of a fast-paced 20-20 cricket match.", image: "/assets/Rides/Photo Spot/Cricket .jpg" },
          { name: "Devil House", description: "Step into the Devil House for a spine-chilling adventure filled with thrills and surprises.", image: "/assets/Rides/Photo Spot/Devil House.jpg" },
          { name: "Fun Area", description: "Carnival games and a fun-filled area for endless excitement and rewards.", image: "/assets/Rides/Photo Spot/Fun area.jpg" },
          { name: "Hammer", description: "Strike the target with full force and feel the thrill of becoming a champion.", image: "/assets/Rides/Photo Spot/Hammer.jpg" },
          { name: "Bull Ride", description: "Hold on tight and take on the excitement of an action-packed bull ride.", image: "/assets/Rides/Photo Spot/bull ride.JPG" },
          { name: "Gyro", description: "Spin in every direction for a fast-paced and thrilling adventure.", image: "/assets/Rides/Photo Spot/gyro.JPG" },
        ],
      },
      {
        name: "Free Attraction",
        rides: [
          { name: "Boot House", description: "Step into the giant boot and enjoy a fun-filled adventure for all ages!", image: "/assets/Rides/Free Attraction/BOOT HOUSE.jpg" },
          { name: "Crooked House", description: "Explore quirky rooms and enjoy a fun-filled adventure in this topsy-turvy house.", image: "/assets/Rides/Free Attraction/CROOKED HOUSE.jpg" },
          { name: "Humpty Dumpty", description: "Meet everyone's favourite egg character relaxing on his famous wall.", image: "/assets/Rides/Free Attraction/HUMPTY DUMPTY.jpg" },
          { name: "Kids Machan", description: "Little adventurers can enjoy exciting park views from this fun-filled high perch.", image: "/assets/Rides/Free Attraction/KIDS MACHAN.jpg" },
          { name: "Pumpkin", description: "Capture magical moments inside this giant fairy-tale pumpkin attraction.", image: "/assets/Rides/Free Attraction/PUMPKIN.jpg" },
          { name: "Tree House", description: "Climb up to our lofty hideaway and enjoy breathtaking views surrounded by nature.", image: "/assets/Rides/Free Attraction/TREE HOUSE.jpg" },
        ],
      },
    ],
  },
  events: {
    badge: "Events",
    badgeIcon: "",
    ctaLabel: "Book Ticket",
    ctaHref: "#events",
    events: [
      {
        image: "/assets/entertainment/Events/Chevalier M.G.M Muthu Holding a Bird.JPG",
        date: "1999",
        title: "India's First Jurong Bird Show",
        description: "MGM Dizzee World conducted India's first Jurong Bird Show from Singapore in Chennai, where families and students enjoyed colourful bird performances.",
      },
      {
        image: "/assets/entertainment/Events/DSC_2506.JPG",
        date: "2000",
        title: "India's First Public Helicopter Ride Experience",
        description: "MGM Dizzee World introduced one of India's first public helicopter ride experiences, offering visitors aerial views of Chennai and the ECR coastline.",
      },
      {
        image: "/assets/entertainment/Events/DSC_0934.JPG",
        date: "2001",
        title: "South India's First Massive Snow Show",
        description: "MGM Dizzee World launched South India's first large-scale snow show, creating a Kashmir-like snow experience that attracted 10,000–20,000 visitors daily.",
      },
      {
        image: "/assets/entertainment/event-4.jpg",
        date: "2005",
        title: "Ford Ikon Car Launch Event",
        description: "Ford Motor Company launched the Ford Ikon at MGM Dizzee World, making it one of the first automobile launch events held inside a theme park in India.",
      },
      {
        image: "/assets/entertainment/event-5.jpg",
        date: "2006",
        title: "Jaya TV New Year's Eve Celebration",
        description: "Jaya TV and MGM Dizzee World hosted a grand public New Year's Eve celebration with live telecast and huge audience participation.",
      },
      {
        image: "/assets/entertainment/event-1.jpg",
        date: "2009",
        title: "Pongal Blast \"Santhosathin Uchakkattam\"",
        description: "MGM Dizzee World organised a three-day Pongal festival featuring folk arts, cultural performances, celebrity appearances, and entertainment programs.",
      },
      {
        image: "/assets/entertainment/Events/Summer kondattam in MGM Dizzee world.JPG",
        date: "2010",
        title: "Summer Kondattam Festival",
        description: "MGM Dizzee World conducted a month-long summer festival with celebrity shows, DJ music, stage events, and audience participation games.",
      },
      {
        image: "/assets/entertainment/event-3.jpg",
        date: "2023",
        title: "Golden MAFTA Award Recognition",
        description: "MGM Dizzee World received the prestigious Golden MAFTA Award for excellence in the amusement and entertainment industry.",
      },
      {
        image: "/assets/entertainment/event-4.jpg",
        date: "2024",
        title: "Get Wet Water Park Expansion",
        description: "MGM Dizzee World expanded its Get Wet Water Park with new attractions including a wave pool, Thunder Falls, kids zone, Caribbean Island, and rain dance.",
      },
      {
        image: "/assets/entertainment/event-5.jpg",
        date: "2025",
        title: "Influencer ₹5 Lakh Contest Campaign",
        description: "MGM Dizzee World launched a major influencer campaign with a ₹5 lakh contest to promote visitor experiences and digital engagement.",
      },
    ],
  },
  restaurants: {
    badge: "Our Restaurants",
    badgeIcon: "",
    restaurants: [
      {
        name: "Dizzee Den",
        location: "MGM Dizzee World",
        description: "Experience a delightful dining adventure at Dizzee Den. Enjoy a wide array of mouth-watering non-vegetarian and vegetarian dishes in a vibrant and fun atmosphere, perfect for families and friends looking to recharge after thrilling rides.",
        image: "/assets/entertainment/restaurants/Dizzee Den.jpg",
      },
      {
        name: "Costume Counter",
        location: "MGM Dizzee World",
        description: "Step into our Costume Counter and transform your theme park experience! Choose from a variety of fun, colourful outfits and accessories to make your visit even more memorable and capture the perfect photos.",
        image: "/assets/entertainment/restaurants/Costume counter.jpg",
      },
      {
        name: "Kiosk 1",
        location: "MGM Dizzee World",
        description: "Stop by Kiosk 1 for your favourite classic theme park treats. From sweet delights to savoury snacks and refreshing beverages, we've got everything you need to keep your energy up for a full day of fun and adventure.",
        image: "/assets/entertainment/restaurants/Kiosk 1.jpg",
      },
      {
        name: "Kiosk 2",
        location: "MGM Dizzee World",
        description: "Grab a quick, delicious bite at Kiosk 2. Offering a great selection of cold drinks, ice creams, and tasty quick snacks, it's the ideal spot for a fast break before heading back to the excitement of the park.",
        image: "/assets/entertainment/restaurants/Kiosk 2.jpg",
      },
    ],
  },
  stats: {
    badge: "Our Impact in Numbers",
    badgeIcon: "",
    description: "A snapshot of the scale, reach, and progress we've built over decades of purpose-driven growth.",
    stats: [
      {
        number: "1995",
        suffix: " established",
        description: "30 Years of Entertainment Excellence",
        vector: "/assets/hospitality/stats-vector-1.svg",
      },
      {
        number: "54+",
        suffix: " Rides & Attractions",
        description: "Including Family, Adult, Kids, and Water Rides",
        vector: "/assets/entertainment/stats-vector-3.svg",
      },
      {
        number: "11000",
        suffix: " Guests in a Single Day (2017)",
        description: "A Record-Breaking Milestone in Tamil Nadu",
        vector: "/assets/entertainment/stats-vector-3.svg",
      },
      {
        number: "125,269",
        suffix: "Footfall in May 2023",
        description: "Highest monthly footfall ever recorded.",
        vector: "/assets/safl/stats-vector-1.svg",
      },
      {
        number: "750k+",
        suffix: " Visitors Every Year",
        description: "Welcoming Families, Friends, and Tour Groups",
        vector: "/assets/safl/stats-vector-2.svg",
      },
      {
        number: "1st",
        suffix: "in Tamil Nadu ",
        description: "To Host a Hot Air Balloon Ride",
        vector: "/assets/hospitality/stats-vector-3.svg",
      },
    ],
  },
  bookRideButtonText: "Book A Ride",
  bookRideButtonLink: "#",
}

/* ------------------------------------------------------------------ */
/*  Helpers                                                            */
/* ------------------------------------------------------------------ */

type AnyRec = Record<string, unknown>

function str(val: unknown, fallback = ""): string {
  if (typeof val === "string") return val.trim() !== "" ? val : fallback
  if (typeof val === "number") return String(val)
  return fallback
}

function media(val: unknown): string {
  return getMediaUrl(val as StrapiMedia | null | undefined)
}

function withFallback<T>(value: T[] | undefined | null, fallback: T[]): T[] {
  return value && value.length > 0 ? value : fallback
}

/* ------------------------------------------------------------------ */
/*  Public API                                                         */
/* ------------------------------------------------------------------ */

export async function getEntertainmentData(): Promise<EntertainmentData> {
  const d = entertainmentDefaults

  if (!isStrapiEnabled) return d

  const entry = await fetchSingle<AnyRec>("entertainment")

  if (!entry) return d

  const hero = (entry.hero as AnyRec | undefined) ?? {}
  const about = (entry.about as AnyRec | undefined) ?? {}
  const ridesWrapper = (entry.rides as AnyRec | undefined) ?? {}
  const eventsWrapper = (entry.events as AnyRec | undefined) ?? {}
  const restaurantsWrapper = (entry.restaurants as AnyRec | undefined) ?? {}
  const statsWrapper = (entry.stats as AnyRec | undefined) ?? {}

  const categoryRows = (ridesWrapper.categories as AnyRec[] | undefined) ?? []
  const eventRows = (eventsWrapper.events as AnyRec[] | undefined) ?? []
  const restaurantRows = (restaurantsWrapper.restaurants as AnyRec[] | undefined) ?? []
  const statRows = (statsWrapper.stats as AnyRec[] | undefined) ?? []
  const paragraphRows = (about.paragraphs as AnyRec[] | undefined) ?? []

  return {
    hero: {
      heading: str(hero.heading, d.hero.heading),
      description: str(hero.description, d.hero.description),
      mobileVideoUrl: str(hero.mobileVideoUrl_9x16) || media(hero.mobileVideoUrl_9x16) || d.hero.mobileVideoUrl,
      desktopVideoUrl: str(hero.desktopVideoUrl_16x9) || media(hero.desktopVideoUrl_16x9) || d.hero.desktopVideoUrl,
    },
    about: {
      badge: str(about.badge, d.about.badge),
      badgeIcon: d.about.badgeIcon,
      watermarkText: titleCase(str(about.watermarkText, d.about.watermarkText)),
      paragraphs: withFallback(
        paragraphRows.map((row) => str(row.text)),
        d.about.paragraphs,
      ),
    },
    rides: {
      badge: str(ridesWrapper.badge, d.rides.badge),
      badgeIcon: d.rides.badgeIcon,
      watermarkText: titleCase(str(ridesWrapper.watermarkText, d.rides.watermarkText)),
      ctaLabel: str(ridesWrapper.ctaButtonText, d.rides.ctaLabel),
      ctaHref: normalizeCmsLink(ridesWrapper.ctaButtonLink, d.rides.ctaHref),
      categories: withFallback(
        categoryRows.map((cat, ci) => {
          const fbCat = d.rides.categories[ci] ?? d.rides.categories[0]
          return {
            name: str(cat.name, fbCat?.name || ""),
            rides: withFallback(
              ((cat.rides as AnyRec[] | undefined) ?? []).map((ride, ri) => {
                const fbRide = fbCat?.rides[ri] ?? fbCat?.rides[0]
                return {
                  name: str(ride.name, fbRide?.name || ""),
                  description: str(ride.description, fbRide?.description || ""),
                  image: media(ride.image_3x4) || str(ride.imageUrl) || fbRide?.image || "",
                  video: media(ride.video_3x4) || str(ride.videoUrl) || fbRide?.video || "",
                }
              }),
              fbCat?.rides || [],
            ),
          }
        }),
        d.rides.categories,
      ),
    },
    events: {
      badge: str(eventsWrapper.badge, d.events.badge),
      badgeIcon: d.events.badgeIcon,
      ctaLabel: str(eventsWrapper.ctaButtonText, d.events.ctaLabel),
      ctaHref: normalizeCmsLink(eventsWrapper.ctaButtonLink, d.events.ctaHref),
      events: withFallback(
        eventRows.map((event, i) => {
          const fb = d.events.events[i] ?? d.events.events[0]
          return {
            image: media(event.image_6x5) || str(event.imageUrl) || fb?.image || "",
            date: str(event.date, fb?.date || ""),
            title: str(event.title, fb?.title || ""),
            description: str(event.description, fb?.description || ""),
          }
        }),
        d.events.events,
      ),
    },
    restaurants: {
      badge: str(restaurantsWrapper.badge, d.restaurants.badge),
      badgeIcon: d.restaurants.badgeIcon,
      restaurants: withFallback(
        restaurantRows.map((restaurant, i) => {
          const fb = d.restaurants.restaurants[i] ?? d.restaurants.restaurants[0]
          return {
            name: str(restaurant.name, fb?.name || ""),
            location: str(restaurant.location, fb?.location || ""),
            description: str(restaurant.description, fb?.description || ""),
            image: media(restaurant.image_6x5) || str(restaurant.imageUrl) || fb?.image || "",
          }
        }),
        d.restaurants.restaurants,
      ),
    },
    stats: {
      badge: str(statsWrapper.badge, d.stats.badge),
      badgeIcon: d.stats.badgeIcon,
      description: str(statsWrapper.description, d.stats.description),
      stats: withFallback(
        statRows.map((row, i) => {
          const fb = d.stats.stats[i] ?? d.stats.stats[0]
          return {
            number: str(row.number, fb?.number || ""),
            suffix: str(row.suffix, fb?.suffix || ""),
            description: str(row.description, fb?.description || ""),
            vector: media(row.vector_9x8) || fb?.vector || "",
          }
        }),
        d.stats.stats,
      ),
    },
    bookRideButtonText: str(entry.bookRideButtonText, d.bookRideButtonText),
    bookRideButtonLink: normalizeCmsLink(entry.bookRideButtonLink, d.bookRideButtonLink),
  }
}
