// @ts-nocheck
/**
 * tests/helpers/playerPrivacyManagerMock.js
 *
 * Canonical PlayerPrivacyManager mock factory.
 * ALL tests that need a PlayerPrivacyManager mock MUST use this factory.
 *
 * Usage:
 *   import { createPlayerPrivacyManagerMock } from '../helpers/playerPrivacyManagerMock.js'
 *   const manager = createPlayerPrivacyManagerMock()
 *   const manager = createPlayerPrivacyManagerMock({ getSettings: () => ({ reactionCamEnabled: true }) })
 */

import { vi } from "vitest";

/**
 * Creates a mock PlayerPrivacyManager with optional overrides.
 *
 * All methods are vi.fn() stubs by default; pass overrides to customise.
 * Default return values match PlayerPrivacyManager behavior.
 *
 * @param {Partial<PlayerPrivacyManagerSurface>} [overrides={}]
 * @returns {PlayerPrivacyManagerSurface}
 */
export function createPlayerPrivacyManagerMock(overrides = {}) {
  const defaults = {
    // Settings retrieval
    getSettings: vi.fn(() => ({
      reactionCamEnabled: false,
      customPortraitFallback: null,
    })),
    // Portrait methods
    getPortraitFallback: vi.fn(() => null),
    getPortraitFallbackDataURL: vi.fn(() => null),
    setPortraitFallback: vi.fn().mockResolvedValue(undefined),
    removePortraitFallback: vi.fn().mockResolvedValue(undefined),
    // Boolean setting methods
    setSetting: vi.fn().mockResolvedValue(undefined),
    isOptedIn: vi.fn(() => false),
    getAllSettings: vi.fn(() => new Map()),
    // Event handling
    onChange: vi.fn(() => () => {}), // Returns unsubscribe function
    teardown: vi.fn(),
    // Override with any custom implementations
    ...overrides,
  };

  return defaults;
}
