// Exported as runtime arrays (not just types) so stored-settings validation
// can whitelist-check them without hardcoding the values a second time.
export const AUDIO_QUALITY_PRESETS = ['speech', 'music', 'musicHighQuality', 'musicHighQualityStereo'] as const;
export type AudioQualityPreset = typeof AUDIO_QUALITY_PRESETS[number];

export const NOISE_SUPPRESSION_MODES = ['disabled', 'browser', 'rnnoise'] as const;
export type NoiseSuppressionMode = typeof NOISE_SUPPRESSION_MODES[number];

export const CAMERA_EFFECTS = ['none', 'blur'] as const;
export type CameraEffect = typeof CAMERA_EFFECTS[number];

export interface AppSettings {
  audioQuality: AudioQualityPreset;
  autoGainControl: boolean;
  echoCancellation: boolean;
  noiseSuppressionMode: NoiseSuppressionMode;
  silenceGate: number; // 0 = off, otherwise dBFS threshold e.g. -40 to -10
  audioInputDeviceId?: string;
  audioOutputDeviceId?: string;
  videoInputDeviceId?: string;
  pushToTalk: boolean;
  pushToTalkKey: string;
  videoResolution: string;
  cameraEffect: CameraEffect; // 'none' | 'blur' — background blur via @livekit/track-processors
  screenShareFpsIdx: number;
  screenShareBrIdx: number;
  screenShareSkipDialog: boolean;
  screenShareAudio: boolean;
  accentColor?: string;
  chatTTS: boolean;
  ttsVolume: number;       // 0–100, default 50
  ttsReadOwn: boolean;     // read own messages aloud
  ttsMaxLength: number;    // truncate message at this char count
  ttsVoice: string;        // SpeechSynthesis voice name, '' = default
  ambientMode: boolean;    // Ambient glow behind video (default on)
  simulcast: boolean;      // Encode multiple quality layers (off = saves CPU/upload for small rooms)
  soundJoinLeave: boolean;
  soundChat: boolean;
  soundScreenShare: boolean;
  soundMicFeedback: boolean;
  soundTalkingWhileMuted: boolean;
  shortcutsEnabled: boolean;
  keyMic: string;
  keyCam: string;
  keyDeafen: string;
  keyChat: string;
  keyFullscreen: string;
  keyScreenShare: string;
  language: string;
}

export const DEFAULT_SETTINGS: AppSettings = {
  audioQuality: 'musicHighQuality',
  autoGainControl: true,
  echoCancellation: true,
  pushToTalk: false,
  pushToTalkKey: 'Space',
  videoResolution: 'h720',
  cameraEffect: 'none',
  screenShareFpsIdx: 0,     // 30fps
  screenShareBrIdx: 2,      // 5 Mbps (1080p)
  screenShareSkipDialog: false,
  screenShareAudio: true,
  noiseSuppressionMode: 'browser',
  silenceGate: 0,
  chatTTS: true,
  ttsVolume: 15,
  ttsReadOwn: false,
  ttsMaxLength: 200,
  ttsVoice: '',
  ambientMode: true,
  simulcast: true,
  soundJoinLeave: true,
  soundChat: true,
  soundScreenShare: true,
  soundMicFeedback: true,
  soundTalkingWhileMuted: true,
  shortcutsEnabled: true,
  keyMic: 'KeyM',
  keyCam: 'KeyV',
  keyDeafen: 'KeyD',
  keyChat: 'KeyC',
  keyFullscreen: 'KeyF',
  keyScreenShare: 'KeyS',
  language: 'en',
};
