/**
 * User-friendly event-type labels — client-safe module.
 *
 * Extracted from site-tag-analytics.ts so "use client" components
 * can import `eventTypeLabel` without pulling in Prisma (which
 * triggers "Missing required variable: DATABASE_URL" in the browser
 * console because the Prisma client references process.env at
 * import time).
 *
 * This file has ZERO server-only imports — safe for both server
 * and client bundles.
 */

export const EVENT_TYPE_LABELS: Record<string, string> = {
  page_view: "Page View",
  session_start: "Session Start",
  click_to_call: "Click to Call",
  outbound_click: "Outbound Click",
  form_start: "Form Start",
  form_submit: "Form Submit",
  form_intent: "Form Intent",
  form_iframe_present: "Form Plugin Detected",
  appointment_intent: "Appointment Intent",
  sms_submit: "SMS",
  sms_click: "SMS Click",
  booking_widget_opened: "Booking Opened",
  booking_step: "Booking Step",
  booking_submit: "Booking Submit",
  booking_confirmed: "Booking Confirmed",
  plugin_detected: "Plugin Detected",
  custom_event: "Custom Event (gtag)",
  purchase: "Purchase",
  checkout_started: "Checkout Started",
  add_to_cart: "Add to Cart",
  product_view: "Product View",
  email_click: "Email Click",
  newsletter_signup: "Newsletter Signup",
  file_download: "File Download",
  waitlist_signup: "Waitlist Signup",
  page_lifecycle: "Page Lifecycle",
  paid_click_landing: "Paid Click Landing",
  scroll: "Scroll",
  click: "Click",
  custom: "Custom",
};

export function eventTypeLabel(raw: string): string {
  if (EVENT_TYPE_LABELS[raw]) return EVENT_TYPE_LABELS[raw];
  return raw
    .split("_")
    .map((w) => (w ? w[0].toUpperCase() + w.slice(1) : w))
    .join(" ");
}
