from core.models import Artist, EffectModule, Preset, SignalChainStep
from django.utils.text import slugify

# 1. Create Effect Modules
modules_data = [
    ('Noise Gate', 'dynamics', 'bi-shield-shaded'),
    ('Compressor', 'dynamics', 'bi-input-cursor'),
    ('Overdrive TS-808', 'drive', 'bi-lightning-charge'),
    ('High Gain Amp', 'amp', 'bi-speaker'),
    ('Clean Tube Amp', 'amp', 'bi-speaker'),
    ('Dual IR Loader', 'utility', 'bi-file-earmark-music'),
    ('Stereo Chorus', 'modulation', 'bi-water'),
    ('Classic Flanger', 'modulation', 'bi-wind'),
    ('Analog Delay', 'delay_reverb', 'bi-hourglass-split'),
    ('Wah Wah Pedal', 'utility', 'bi-reception-4'),
]

created_modules = {}
for name, cat, icon in modules_data:
    mod, _ = EffectModule.objects.get_or_create(
        name=name, 
        defaults={'category': cat, 'icon_class': icon}
    )
    created_modules[name] = mod

# 2. Get Artists
artists = Artist.objects.all()

# 3. Create 5 Presets per Artist
for artist in artists:
    for i in range(1, 6):
        title = f"{artist.name} Signature {i}"
        slug = slugify(f"{artist.name}-{i}-{title}")
        
        preset, created = Preset.objects.get_or_create(
            artist=artist,
            slug=slug,
            defaults={
                'title': title,
                'description': f"A signature tone for {artist.name}, optimized for {artist.style} style."
            }
        )
        
        if created:
            # Build a typical signal chain
            # Order: Gate -> Comp -> Wah -> Drive -> Amp -> IR -> Mod -> Delay
            steps = [
                ('Noise Gate', 'Threshold: -40dB'),
                ('Compressor', 'Ratio: 4:1'),
                ('Wah Wah Pedal', 'Auto-sweep'),
                ('Overdrive TS-808', 'Drive: 4, Tone: 6'),
                ('High Gain Amp', 'Gain: 7, Bass: 5, Mid: 6, Treble: 7'),
                ('Dual IR Loader', 'Cab A: 4x12 SM57, Cab B: 4x12 R121'),
                ('Stereo Chorus', 'Rate: 0.5Hz, Depth: 40%'),
                ('Analog Delay', 'Time: 450ms, Feedback: 30%'),
            ]
            
            for idx, (mod_name, settings) in enumerate(steps):
                SignalChainStep.objects.create(
                    preset=preset,
                    module=created_modules[mod_name],
                    order=idx,
                    settings_summary=settings
                )

print("Successfully seeded 5 presets per artist.")
