/* properties.jsx — Reads property catalog from HostData (single source of truth)
 *
 * When loaded after hostPortalData.js, window.NOVUS_PROPERTIES is already populated.
 * This file remains as a fallback for pages that don't load hostPortalData.js, and
 * defines NOVUS_EXPERIENCE / NOVUS_REVIEWS legacy globals.
 */

// If HostData is available, use it as the source of truth. Otherwise fall back to a static list.
const FALLBACK_PROPERTIES = [
  {
    id: 'villa-gaia', name: 'Española', kind: 'villa', neighborhood: 'Treasure Island',
    address: '7536 W Treasure Dr, Miami Beach, FL 33141',
    tagline: 'Discover this exquisite waterfront Spanish-style villa offering breathtaking views of Miami Downtown and Biscayne Bay.',
    short: 'Spanish-style · Bay views · sleeps 10',
    facts: ['5 bedrooms', '4 baths', 'Private pool', 'Bay views', 'Sleeps 10'],
    photo: 'https://images.unsplash.com/photo-1613977257363-707ba9348227?auto=format&fit=crop&w=1500&q=80',
    rate: 1890, rating: 4.96, reviews: 142, badge: 'WATERFRONT VILLA',
    amenities: ['Private pool', 'Fast Wi-Fi', 'Full kitchen', 'BBQ grill', 'Patio & loungers', 'Smart TV', 'Free parking', 'Beach gear'],
  },
];

const NOVUS_PROPERTIES = (typeof window !== 'undefined' && window.HostData && window.HostData.getProperties)
  ? window.HostData.getProperties()
  : (typeof window !== 'undefined' && window.NOVUS_PROPERTIES) || FALLBACK_PROPERTIES;

// Backfill amenities for any property missing them
NOVUS_PROPERTIES.forEach(p => {
  if (!p.amenities || p.amenities.length === 0) {
    p.amenities = ['Private pool', 'Fast Wi-Fi', 'Full kitchen', 'BBQ grill', 'Patio & loungers', 'Smart TV', 'Free parking', 'Beach gear'];
  }
});

const NOVUS_EXPERIENCE = (typeof window !== 'undefined' && window.NOVUS_EXPERIENCE) || {
  id: 'galeon-500',
  name: '2025 Galeon 500 Fly',
  tagline: 'Step aboard the exquisite Galeon 50 — a masterpiece of modern yachting designed to elevate your Miami boating experience. Perfect for celebrating life’s finest moments.',
  photo: 'https://images.unsplash.com/photo-1567899378494-47b22a2ae96a?auto=format&fit=crop&w=1500&q=80',
  facts: ['Up to 12 guests', 'Half-day & full-day', 'Captain & crew', 'On-water dining'],
};

const NOVUS_REVIEWS = [
  {
    name: 'Madavy',
    text: 'This home was perfect for a group of girls. Close to all the great spots — the house was great, great rooms and beds and bathrooms. Everyone felt right at home. Kitchen and outdoor grill were perfect for cooking, the pool and outdoor space perfect for lounging.',
    bg: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?auto=format&fit=crop&w=800&q=80',
  },
  {
    name: 'Kaly',
    text: 'This house is incredible. Slept 10 of us very comfortably. Great location directly between downtown and Miami Beach. We also saw an insane amount of dolphins swim right up to the backyard one of the nights. The host was responsive and flexible.',
    bg: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?auto=format&fit=crop&w=800&q=80',
  },
  {
    name: 'Robert',
    text: 'Really an amazing huge space with so many spaces for people to sleep, lots of utensils and stuff for us to use in the kitchen, a great pool — just everything we needed with a really responsive host.',
    bg: 'https://images.unsplash.com/photo-1438761681033-6461ffad8d80?auto=format&fit=crop&w=800&q=80',
  },
  {
    name: 'Kayla',
    text: 'Very comfortable for 4 couples, private bedrooms with en-suite baths. Property was as described, didn’t leave us guessing at all. Host was accommodating, friendly, very responsive.',
    bg: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?auto=format&fit=crop&w=800&q=80',
  },
];

window.NOVUS_PROPERTIES = NOVUS_PROPERTIES;
if (!window.NOVUS_EXPERIENCE) window.NOVUS_EXPERIENCE = NOVUS_EXPERIENCE;
window.NOVUS_REVIEWS = NOVUS_REVIEWS;
