'use client'; import * as React from 'react'; import { X, RotateCcw } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { Slider } from '@/components/ui/Slider'; import { RecordingSettings } from '@/components/recording/RecordingSettings'; import { cn } from '@/lib/utils/cn'; import type { RecordingSettings as RecordingSettingsType } from '@/lib/hooks/useRecording'; import type { Settings, AudioSettings, UISettings, EditorSettings, PerformanceSettings, } from '@/lib/hooks/useSettings'; export interface GlobalSettingsDialogProps { open: boolean; onClose: () => void; recordingSettings: RecordingSettingsType; onInputGainChange: (gain: number) => void; onRecordMonoChange: (mono: boolean) => void; onSampleRateChange: (sampleRate: number) => void; settings: Settings; onAudioSettingsChange: (updates: Partial) => void; onUISettingsChange: (updates: Partial) => void; onEditorSettingsChange: (updates: Partial) => void; onPerformanceSettingsChange: (updates: Partial) => void; onResetCategory: (category: 'audio' | 'ui' | 'editor' | 'performance') => void; } type TabType = 'recording' | 'audio' | 'editor' | 'interface' | 'performance'; export function GlobalSettingsDialog({ open, onClose, recordingSettings, onInputGainChange, onRecordMonoChange, onSampleRateChange, settings, onAudioSettingsChange, onUISettingsChange, onEditorSettingsChange, onPerformanceSettingsChange, onResetCategory, }: GlobalSettingsDialogProps) { const [activeTab, setActiveTab] = React.useState('recording'); if (!open) return null; return ( <> {/* Backdrop */}
{/* Dialog */}
{/* Header */}

Settings

{/* Tabs */}
{[ { id: 'recording', label: 'Recording' }, { id: 'audio', label: 'Audio' }, { id: 'editor', label: 'Editor' }, { id: 'interface', label: 'Interface' }, { id: 'performance', label: 'Performance' }, ].map((tab) => ( ))}
{/* Content */}
{/* Recording Tab */} {activeTab === 'recording' && (

Recording Settings

Note

These settings apply globally to all recordings. Arm a track (red button) to enable recording on that specific track.

)} {/* Audio Tab */} {activeTab === 'audio' && (

Audio Settings

{/* Buffer Size */}

Smaller buffer = lower latency but higher CPU usage. Requires reload.

{/* Sample Rate */}

Higher sample rate = better quality but larger file sizes.

{/* Auto Normalize */}
Auto-Normalize on Import

Automatically normalize audio when importing files

onAudioSettingsChange({ autoNormalizeOnImport: e.target.checked }) } className="h-4 w-4" />
)} {/* Editor Tab */} {activeTab === 'editor' && (

Editor Settings

{/* Auto-Save Interval */}
{settings.editor.autoSaveInterval === 0 ? 'Disabled' : `${settings.editor.autoSaveInterval}s`}
onEditorSettingsChange({ autoSaveInterval: value }) } min={0} max={30} step={1} className="w-full" />

Set to 0 to disable auto-save. Default: 3 seconds.

{/* Undo History Limit */}
{settings.editor.undoHistoryLimit} operations
onEditorSettingsChange({ undoHistoryLimit: value }) } min={10} max={200} step={10} className="w-full" />

Higher values use more memory. Default: 50.

{/* Snap to Grid */}
Snap to Grid

Snap playhead and selections to grid lines

onEditorSettingsChange({ snapToGrid: e.target.checked }) } className="h-4 w-4" />
{/* Grid Resolution */}
{settings.editor.gridResolution}s
onEditorSettingsChange({ gridResolution: value }) } min={0.1} max={5} step={0.1} className="w-full" />

Grid spacing in seconds. Default: 1.0s.

{/* Default Zoom */}
{settings.editor.defaultZoom}x
onEditorSettingsChange({ defaultZoom: value }) } min={1} max={20} step={1} className="w-full" />

Initial zoom level when opening projects. Default: 1x.

)} {/* Interface Tab */} {activeTab === 'interface' && (

Interface Settings

{/* Theme */}
{['dark', 'light', 'auto'].map((theme) => ( ))}

Use the theme toggle in header for quick switching.

{/* Font Size */}
{['small', 'medium', 'large'].map((size) => ( ))}

Adjust the UI font size. Requires reload.

)} {/* Performance Tab */} {activeTab === 'performance' && (

Performance Settings

{/* Peak Calculation Quality */}
{['low', 'medium', 'high'].map((quality) => ( ))}

Higher quality = more accurate waveforms, slower processing.

{/* Waveform Rendering Quality */}
{['low', 'medium', 'high'].map((quality) => ( ))}

Lower quality = better performance on slower devices.

{/* Enable Spectrogram */}
Enable Spectrogram

Show spectrogram in analysis tools (requires more CPU)

onPerformanceSettingsChange({ enableSpectrogram: e.target.checked }) } className="h-4 w-4" />
{/* Max File Size */}
{settings.performance.maxFileSizeMB} MB
onPerformanceSettingsChange({ maxFileSizeMB: value }) } min={100} max={1000} step={50} className="w-full" />

Warn when importing files larger than this. Default: 500 MB.

)}
{/* Footer */}
); }