/**
 * 🎯 ANALYTICS EVENTS MAP
 *
 * Used for tracking player interactions and system states.
 *
 * Legend:
 *  ✅ — event already implemented
 *  ❌ — event not yet implemented
 *  🎮 — must be implemented on the game side (inside game scenes or activities)
 *
 * The parentheses indicate where the event is implemented or planned.
 *
 * Each event lists its payload structure (data sent with `track()`).
 */
export const ANALYTICS_EVENTS = {
  // === 1. Settings Interactions ===

  /**
   * ✅ Player increased bet size (UIViewModel → isPlusButtonPressed)
   * Payload: { totalBet: number }
   */
  BET_SIZE_INCREASED: 'bet_size_increased',

  /**
   * ✅ Player decreased bet size (UIViewModel → isMinusButtonPressed)
   * Payload: { totalBet: number }
   */
  BET_SIZE_REDUCED: 'bet_size_reduced',

  /**
   * ✅ Player selected maximum bet (UIViewModel → isMaxButtonPressed)
   * Payload: { totalBet: number }
   */
  MAX_BET_SELECTED: 'max_bet_selected',

  /**
   * ✅ Player opened the list of available bet sizes (BetPicker → show())
   * Payload: none
   */
  BETS_LIST_OPENED: 'bets_list_opened',

  /**
   * ✅ Player toggled turbospin mode (UIViewModel → isTurboButtonPressed)
   * Payload: { enabled: boolean }
   */
  TURBOSPIN_CHANGED: 'turbospin_changed',

  /**
   * ✅ Player toggled turbospin from the settings panel (GameSettings → checkbox_turbo_spin)
   * Trigger: player clicks the Turbospin checkbox inside the settings panel.
   * Payload:
   * {
   *   enabled: boolean // true if turbospin is ON after toggle
   * }
   */
  TURBOSPIN_CHANGED_PANEL: 'turbospin_changed_panel',

  /**
   * 🎮 Player skipped animation (game-side event)
   * Payload: { roundId: string }
   */
  ANIMATION_SKIPPED: 'animation_skipped',

  /**
   * ✅ Player started autoplay (UIViewModel → autoRoundsIssued)
   * Payload: { rounds: number, balance: number, bet: number }
   */
  AUTOPLAY_STARTED: 'autoplay_started',

  /**
   * ✅ Player changed volume in the settings menu (GameSettings → volumeSlider.onup)
   * Trigger: when the player releases the volume slider after adjusting it.
   * Payload:
   * {
   *   volume: number // normalized value between 0 and 1
   * }
   */
  VOLUME_CHANGED_UI: 'volume_changed_ui',

  /**
   * ✅ Player muted/unmuted sound on main screen (UIViewModel → isSoundOnButtonPressed / isSoundOffButtonPressed)
   * Trigger: when the player toggles sound directly from the main HUD (not settings panel).
   * Payload:
   * {
   *   muted: boolean // true if sound is turned off
   * }
   */
  VOLUME_TOGGLED_MAIN: 'volume_toggled_main',

  /**
   * 🎮 Player opened mini paytable (game-side)
   * Payload: { symbol: string }
   */
  MINI_PAYTABLE_DISPLAYED: 'mini_paytable_displayed',

  /**
   * ✅ Player double-clicked the spin button (UIViewModel)
   * Trigger: two consecutive clicks on the Spin button within 300 ms.
   * Payload:
   * {
   *   intervalMs: number; // actual time in milliseconds between the two clicks
   * }
   */
  SPIN_BUTTON_DOUBLE_CLICK: 'spin_button_double_click',

  /**
   * ⚠️ DEPRECATED — previously intended to track scroll position in menus.
   * Replaced by more meaningful interaction events (e.g., BETS_LIST_OPENED or BET_SELECTED).
   * Payload: { progress: number } // 0–1 range
   */
  // SCROLL_MENU_POSITION: 'scroll_menu_position',

  // === 2. Device and Orientation Changes ===
  /**
   * 🎮 Device rotated to landscape (TrackOrientationActivity)
   * Trigger: when the viewport width becomes greater than height.
   * Automatically tracked by the `TrackOrientationActivity` added to `ActivityRunner`.
   *
   * Payload:
   * {
   *   width: number,   // current window.innerWidth
   *   height: number   // current window.innerHeight
   * }
   */
  ORIENTATION_LANDSCAPE: 'orientation_landscape',

  /**
   * 🎮 Device rotated to portrait (TrackOrientationActivity)
   * Trigger: when the viewport height becomes greater than width.
   * Automatically tracked by the `TrackOrientationActivity` added to `ActivityRunner`.
   *
   * Payload:
   * {
   *   width: number,   // current window.innerWidth
   *   height: number   // current window.innerHeight
   * }
   */
  ORIENTATION_PORTRAIT: 'orientation_portrait',

  // === 3. Rules and Paytable ===

  /**
   * ✅ Player opened Rules modal (UIViewModel → isRulesButtonPressed)
   * Payload: none
   */
  RULES_OPENED: 'rules_opened',

  /**
   * ✅ Player opened Paytable modal (UIViewModel → isPaytableButtonPressed)
   * Payload: none
   */
  PAYTABLE_OPENED: 'paytable_opened',

  // === 4. Bonus Features and Purchases ===

  /**
   * ✅ Player activated Chance X (BuyBonusViewModel → toggleBetFeatureActive)
   * Payload: { enabled: boolean }
   */
  CHANCE_X_ACTIVATED: 'chance_x_activated',

  /**
   * ✅ Player purchased a bonus via Bonus Buy or Free Spins (BuyBonusViewModel → buyBonus / buyFreespins)
   * Payload: { bonusLevel: string, cost: number, balanceBefore: number }
   */
  BONUS_BUY_PURCHASED: 'bonus_buy_purchased',

  /**
   * ✅ Player increased bet size inside Bonus Buy popup (BuyBonusViewModel → isPlusButtonPressed)
   * Payload: { bet: number }
   */
  BONUS_BUY_BET_INCREASED: 'bonus_buy_bet_increased',

  /**
   * ✅ Player decreased bet size inside Bonus Buy popup (BuyBonusViewModel → isMinusButtonPressed)
   * Payload: { bet: number }
   */
  BONUS_BUY_BET_REDUCED: 'bonus_buy_bet_reduced',

  /**
   * 🎮 Player closed Bonus Buy popup without making a purchase
   * (implemented on the game side, inside the BonusBuy scene/UI)
   * Payload: none
   */
  BONUS_BUY_CLOSED_NO_PURCHASE: 'bonus_buy_closed_no_purchase',

  // === 5. Player’s Browser, Device, OS, and Platform ===

  /**
   * ✅ Player’s environment info — automatically collected on session start
   * Activity: `GatherClientSessionEnvironmentInfo`
   * Integration: add this activity to your `ActivityRunner` chain on game startup.
   *
   * Payload:
   * {
   *   browser: string,
   *   browserVersion: string,
   *   os: string,
   *   osVersion?: string,
   *   device: string,
   *   platform: 'desktop' | 'mobile' | 'tablet',
   *   timestamp: number,    // ms since session start
   *   duration: number      // ms spent collecting info
   * }
   */
  SESSION_ENVIRONMENT_INFO: 'session_environment_info',

  /**
   * ⚠️ DEPRECATED — merged into SESSION_ENVIRONMENT_INFO
   */
  //SESSION_BROWSER_INFO: 'session_browser_info',
  //SESSION_DEVICE_INFO: 'session_device_info',
  //SESSION_OS_INFO: 'session_os_info',
  //SESSION_PLATFORM_INFO: 'session_platform_info',
} as const;

export type AnalyticsEventName = typeof ANALYTICS_EVENTS[keyof typeof ANALYTICS_EVENTS];
