'use client'; import * as React from 'react'; import { GripVertical, Power, PowerOff, Trash2, Settings } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { cn } from '@/lib/utils/cn'; import type { ChainEffect, EffectChain } from '@/lib/audio/effects/chain'; import { EFFECT_NAMES } from '@/lib/audio/effects/chain'; export interface EffectRackProps { chain: EffectChain; onToggleEffect: (effectId: string) => void; onRemoveEffect: (effectId: string) => void; onReorderEffects: (fromIndex: number, toIndex: number) => void; onEditEffect?: (effect: ChainEffect) => void; className?: string; } export function EffectRack({ chain, onToggleEffect, onRemoveEffect, onReorderEffects, onEditEffect, className, }: EffectRackProps) { const [draggedIndex, setDraggedIndex] = React.useState(null); const [dragOverIndex, setDragOverIndex] = React.useState(null); const handleDragStart = (e: React.DragEvent, index: number) => { setDraggedIndex(index); e.dataTransfer.effectAllowed = 'move'; }; const handleDragOver = (e: React.DragEvent, index: number) => { e.preventDefault(); if (draggedIndex === null || draggedIndex === index) return; setDragOverIndex(index); }; const handleDrop = (e: React.DragEvent, index: number) => { e.preventDefault(); if (draggedIndex === null || draggedIndex === index) return; onReorderEffects(draggedIndex, index); setDraggedIndex(null); setDragOverIndex(null); }; const handleDragEnd = () => { setDraggedIndex(null); setDragOverIndex(null); }; if (chain.effects.length === 0) { return (

No effects in chain. Add effects from the side panel to get started.

); } return (
{chain.effects.map((effect, index) => (
handleDragStart(e, index)} onDragOver={(e) => handleDragOver(e, index)} onDrop={(e) => handleDrop(e, index)} onDragEnd={handleDragEnd} className={cn( 'flex items-center gap-2 p-3 rounded-lg border transition-all', effect.enabled ? 'bg-card border-border' : 'bg-muted/50 border-border/50 opacity-60', draggedIndex === index && 'opacity-50', dragOverIndex === index && 'border-primary' )} > {/* Drag Handle */}
{/* Effect Info */}
{effect.name}
{EFFECT_NAMES[effect.type]}
{/* Actions */}
{/* Edit Button (if edit handler provided) */} {onEditEffect && ( )} {/* Toggle Enable/Disable */} {/* Remove */}
))}
); }