// src/lib/cloudinary.ts

const UNSPLASH_MAP: Record<string, string> = {
  rooms: "1566073771259-6a8506099945",
  deluxe_room_1: "1590490359683-658d3d23f972",
  superior_room_1: "1566665797739-1674de7a421a",
  family_suite_1: "1582719478250-c89cae4dc85d",
  honeymoon_suite_1: "1591088398332-8a7791972843",
  dining: "1514362545857-3bc16c4c7d1b",
  spa: "1544161515-436cefd54c37",
  beach: "1507525428034-b723cf961d3e",
  turkish_bath: "1584622650111-993a426fbf0a",
  aromatherapy: "1600334089648-b0d9d3028eb2",
  hot_stone: "1515377905703-c4788e51af15",
  facial_care: "1512290923902-8a9f81dc206e",
  spa_hero: "1540555700478-4be289fbecef",
  marble_texture: "1515377905703-c4788e51af15", // placeholder for marble vibe
  hero_video: "https://assets.mixkit.co/videos/preview/mixkit-beach-resort-with-palm-trees-4375-large.mp4"
};

interface CloudinaryOptions {
  width?: number;
  height?: number;
  quality?: "auto" | number;
  format?: "auto" | "webp" | "avif" | "jpg" | "png";
  crop?: "fill" | "fit" | "scale" | "thumb" | "limit";
  gravity?: "auto" | "face" | "center";
  aspectRatio?: string;
}

export function getCloudinaryUrl(
  publicId: string,
  options: CloudinaryOptions = {}
): string {
  const keyword = publicId.split('/').pop() || "resort";
  const photoId = UNSPLASH_MAP[keyword] || "1540541338287-41700207dee6"; // Fallback to a nice resort photo
  
  const width = options.width || 1200;
  const height = options.height || 800;
  
  // Official Unsplash Image URL structure
  return `https://images.unsplash.com/photo-${photoId}?auto=format&fit=crop&q=80&w=${width}&h=${height}`;
}

export function getBlurUrl(publicId: string): string {
  const keyword = publicId.split('/').pop() || "resort";
  const photoId = UNSPLASH_MAP[keyword] || "1540541338287-41700207dee6";
  return `https://images.unsplash.com/photo-${photoId}?auto=format&fit=crop&q=10&w=20`;
}

export function getCloudinaryVideoUrl(publicId: string): string {
  return UNSPLASH_MAP.hero_video;
}
