Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
646 lines (558 loc) · 50.4 KB
/
Copy pathapp.js
File metadata and controls
646 lines (558 loc) · 50.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
document.addEventListener('DOMContentLoaded', () => {
// --- DONNÉES INITIALES ---
const initialPresets = [
// Hip Hop (12)
{ id: 1, title: "Eminem Chopper Flow", genre: "Hip Hop", prompt: "An intense, dark, lyrical chopper rap in the style of Eminem's Marshall Mathers LP era. Hard-hitting drums, deep 808 bass, haunting minor-key piano. Aggressive, rapid-fire, double-time flow with razor-sharp enunciation.", isMix: false },
{ id: 11, title: "Gritty UK Drill", genre: "Hip Hop", prompt: "Gritty UK drill beat. Sliding 808 basslines, complex and skittering hi-hat patterns, ominous piano melodies, deep-voiced male rapper with a cold, detached delivery.", isMix: false },
{ id: 13, title: "Old School Boom Bap", genre: "Hip Hop", prompt: "90s Boom Bap hip hop. Hard acoustic drums, sampled jazz/soul loops, groovy acoustic bassline, MPC swing. Laid-back, confident flow. A Tribe Called Quest meets DJ Premier.", isMix: false },
{ id: 14, title: "Modern Trap Banger", genre: "Hip Hop", prompt: "A modern trap banger. Massive, distorted 808s, rapid-fire triplet hi-hats, dark synth melody, autotuned rap vocals with ad-libs. Migos, Travis Scott style.", isMix: false },
{ id: 15, title: "West Coast G-Funk", genre: "Hip Hop", prompt: "90s G-Funk from the West Coast. Slow, heavy groove, deep funk bassline, high-pitched whiny synth lead (Moog), laid-back rapping. Dr. Dre, Snoop Dogg style.", isMix: false },
{ id: 16, title: "Cloud Rap Ethereal", genre: "Hip Hop", prompt: "Ethereal and dreamy cloud rap. Washed-out synth pads, hazy and atmospheric textures, simple trap drums, melodic and introspective vocals with lots of reverb.", isMix: false },
{ id: 17, title: "Jazz Hop Relaxation", genre: "Hip Hop", prompt: "Relaxing Jazz Hop. Jazzy piano chords, smooth saxophone licks, sampled upright bass, boom-bap drums with a soft touch. Instrumental, Nujabes style.", isMix: false },
{ id: 18, title: "Abstract Hip Hop", genre: "Hip Hop", prompt: "Abstract, experimental hip hop. Unconventional drum patterns, obscure samples, spoken word and complex lyrical schemes. MF DOOM, Earl Sweatshirt style.", isMix: false },
{ id: 19, title: "UK Grime Energy", genre: "Hip Hop", prompt: "High-energy UK Grime. Fast tempo (140 BPM), aggressive synth bass, eski clicks, square wave synths, rapid and confrontational MCing. Skepta, Wiley style.", isMix: false },
{ id: 20, title: "Southern Crunk Anthem", genre: "Hip Hop", prompt: "Early 2000s Crunk anthem. Loud, repetitive vocal chants, heavy 808 bass, simple and catchy synth lead. High energy, perfect for a club. Lil Jon style.", isMix: false },
{ id: 21, title: "Horrorcore Menace", genre: "Hip Hop", prompt: "Dark and menacing horrorcore. Ominous orchestral samples, detuned pianos, hard and gritty drums, aggressive and dark lyrical content. Gravediggaz, Three 6 Mafia style.", isMix: false },
{ id: 2, title: "Lo-fi Chillhop Dreams", genre: "Lo-fi", prompt: "Ultra chill lo-fi hip hop, dusty drum samples, warm vinyl crackle, mellow rhodes piano, smooth jazzy chords, melancholic saxophone melody. Perfect for studying or relaxing.", isMix: false },
// Electronic (16)
{ id: 3, title: "80s Synthwave Sunset", genre: "Electronic", prompt: "80s retro synthwave, driving drum machine beat with heavy gated reverb, pulsing arpeggiated synth bass, soaring lead synth melodies, nostalgic and atmospheric pads. A sunset drive in a DeLorean.", isMix: false },
{ id: 12, title: "Psychedelic Trance", genre: "Electronic", prompt: "Hypnotic psychedelic trance (psytrance). Driving kick-bass rhythm, squelchy acid synth lines (TB-303), layered arpeggios, atmospheric pads, and trippy FX. High BPM, energetic and hypnotic.", isMix: false },
{ id: 22, title: "Deep House Groove", genre: "Electronic", prompt: "Deep house with a soulful, hypnotic groove. Muted four-on-the-floor kick, smooth bassline, jazzy electric piano chords, soulful female vocal chops, and light percussion.", isMix: false },
{ id: 23, title: "Berlin Techno Warehouse", genre: "Electronic", prompt: "Dark, hypnotic Berlin techno. Pounding, relentless kick drum, rumbling sub-bass, industrial textures, minimal and repetitive synth sequences. For a dark warehouse at 4 AM.", isMix: false },
{ id: 24, title: "Uplifting Trance Anthem", genre: "Electronic", prompt: "Euphoric and uplifting trance anthem. Pounding kick, rolling basslines, beautiful piano melody, supersaw synth chords, and an emotional, soaring lead synth. Tiesto, Armin van Buuren style.", isMix: false },
{ id: 25, title: "French House Filter", genre: "Electronic", prompt: "Classic French House. Funky, filtered disco sample loop, groovy bassline, four-on-the-floor house beat, heavy use of sidechain compression. Daft Punk, Stardust style.", isMix: false },
{ id: 26, title: "Future Bass Drop", genre: "Electronic", prompt: "Future Bass with a massive drop. Cute synth plucks, pitched-up vocal samples, emotional chord progressions building up to a huge drop with detuned supersaw synths and heavy trap drums.", isMix: false },
{ id: 27, title: "Liquid Drum & Bass", genre: "Electronic", prompt: "Smooth and soulful Liquid Drum & Bass. Fast breakbeat drums (Amen break), deep, rolling sub-bass, atmospheric pads, and a beautiful, melancholic piano or female vocal melody.", isMix: false },
{ id: 28, title: "Hardstyle Power", genre: "Electronic", prompt: "High-energy Hardstyle. Distorted, pounding kick drum (kick-bass), detuned screechy synth leads, and an epic, melodic breakdown. 150 BPM.", isMix: false },
{ id: 29, title: "Vaporwave Nostalgia", genre: "Electronic", prompt: "Vaporwave aesthetic. Chopped and screwed samples of 80s/90s smooth jazz or R&B, slowed down, heavy reverb, nostalgic and melancholic. Often includes classic Windows sound effects.", isMix: false },
{ id: 30, title: "Chiptune 8-bit Arcade", genre: "Electronic", prompt: "8-bit Chiptune music. Melodies and harmonies created with synthesized sounds from old video game consoles (NES, Game Boy). Fast arpeggios, simple square wave and triangle wave sounds.", isMix: false },
{ id: 31, title: "Downtempo Trip Hop", genre: "Electronic", prompt: "90s Trip Hop. Slow, dusty breakbeats, deep and dubby basslines, atmospheric samples (often from spy movies), and ethereal or smoky female vocals. Portishead, Massive Attack style.", isMix: false },
{ id: 32, title: "Eurodance 90s Hit", genre: "Electronic", prompt: "90s Eurodance hit. Upbeat four-on-the-floor beat, cheesy but catchy synth riff, powerful female vocals in the chorus, and a male rap verse. High energy and nostalgic.", isMix: false },
{ id: 33, title: "Hardcore Gabber", genre: "Electronic", prompt: "Ultra-fast and aggressive Gabber. Extremely distorted kick drums at 180-200 BPM, loud Hoover synths, and aggressive shouted samples. Pure high-octane energy.", isMix: false },
{ id: 34, title: "Glitch Hop", genre: "Electronic", prompt: "Glitch Hop. Funky mid-tempo beat, heavy use of digital glitches, stutters, and edits on the bass and synth sounds. Complex sound design, wobbling bass. Koan Sound style.", isMix: false },
{ id: 35, title: "Industrial EBM", genre: "Electronic", prompt: "Electronic Body Music (EBM). Driving, danceable beat, repetitive sequencer basslines, aggressive shouted or distorted vocals, and industrial or machine-like sounds. Cold and energetic.", isMix: false },
// Rock (15)
{ id: 5, title: "Stadium Rock Anthem", genre: "Rock", prompt: "A massive stadium rock anthem. Big, powerful drums, iconic electric guitar riff, driving bassline, soaring male vocals with layered harmonies. U2 meets Queen. Uplifting and energetic.", isMix: false },
{ id: 8, title: "Aggressive Nu Metal", genre: "Rock", prompt: "Aggressive Nu Metal in the style of Linkin Park. Distorted 7-string guitar riffs, rap-rock verses, powerful sung chorus, DJ scratching sounds, hard-hitting drums. Angsty and energetic.", isMix: false },
{ id: 36, title: "Classic Rock Revival", genre: "Rock", prompt: "70s Classic Rock. Bluesy electric guitar riff (Les Paul tone), powerful acoustic drums, groovy bassline, and soulful, high-pitched male vocals. Led Zeppelin, AC/DC style.", isMix: false },
{ id: 37, title: "Heavy Metal Power", genre: "Rock", prompt: "Classic Heavy Metal. Galloping bassline, dual harmonized electric guitar leads, powerful and clean operatic male vocals, fast and technical drum fills. Iron Maiden, Judas Priest style.", isMix: false },
{ id: 38, title: "90s Grunge Angst", genre: "Rock", prompt: "90s Seattle Grunge. Heavily distorted, sludgy guitar riff, quiet-loud dynamics, angsty and raw vocals, powerful and simple drumming. Nirvana, Soundgarden style.", isMix: false },
{ id: 39, title: "Pop Punk Energy", genre: "Rock", prompt: "Early 2000s Pop Punk. Fast-paced drums, simple and catchy power chord guitar riffs, energetic and whiny male vocals. Blink-182, Sum 41 style.", isMix: false },
{ id: 40, title: "Indie Rock Cool", genre: "Rock", prompt: "2000s Indie Rock revival. Jangly electric guitar with chorus effect, driving and melodic bassline, tight drumming, and effortlessly cool, slightly detached vocals. The Strokes, Arctic Monkeys style.", isMix: false },
{ id: 41, title: "Psychedelic Rock Trip", genre: "Rock", prompt: "60s Psychedelic Rock. Fuzzy electric guitar with heavy use of wah and phaser effects, hypnotic bassline, meandering drum patterns, and dreamy, reverb-drenched vocals. Pink Floyd, Jimi Hendrix style.", isMix: false },
{ id: 42, title: "Post-Rock Crescendo", genre: "Rock", prompt: "Instrumental Post-Rock. Clean, shimmering electric guitars with lots of delay, building slowly in intensity to a massive crescendo with distorted guitars and crashing drums. Explosions in the Sky style.", isMix: false },
{ id: 43, title: "Stoner Rock Fuzz", genre: "Rock", prompt: "Stoner Rock. Heavy, down-tuned, bluesy guitar riff with a thick fuzz distortion, thunderous bass, and powerful, heavy-hitting drums. Hypnotic and groovy. Kyuss, Sleep style.", isMix: false },
{ id: 44, title: "Black Metal Frost", genre: "Rock", prompt: "Raw, atmospheric Black Metal. Tremolo-picked, highly distorted guitars, relentless blast beat drumming, high-pitched shrieked vocals, and a lo-fi, cold production quality. Darkthrone style.", isMix: false },
{ id: 45, title: "Death Metal Guttural", genre: "Rock", prompt: "Technical Death Metal. Complex and fast guitar riffs, blast beats and double bass drumming, guttural and low-pitched growled vocals, and abrupt time signature changes. Cannibal Corpse style.", isMix: false },
{ id: 46, title: "Shoegaze Wall of Sound", genre: "Rock", prompt: "Shoegaze. A massive wall of sound created by heavily distorted, reverb-drenched guitars, dreamy and ethereal vocals buried in the mix, and a simple, driving drum beat. My Bloody Valentine style.", isMix: false },
{ id: 47, title: "Garage Rock Revival", genre: "Rock", prompt: "Raw and energetic Garage Rock. Overdriven, simple guitar riff, fuzzy bass, and lo-fi, trashy sounding drums. Energetic and rebellious vocals. The White Stripes style.", isMix: false },
{ id: 48, title: "Glam Rock Extravaganza", genre: "Rock", prompt: "70s Glam Rock. Catchy, stomping guitar riff, pounding piano, hand claps, and flamboyant, anthemic vocals with big choruses. T. Rex, David Bowie style.", isMix: false },
// Pop (8)
{ id: 6, title: "Modern Pop Hit", genre: "Pop", prompt: "A modern, upbeat commercial pop hit. Punchy four-on-the-floor beat, catchy synth hooks, clean electric guitar, polished female vocals with ad-libs. Radio-ready, high energy.", isMix: false },
{ id: 49, title: "90s Boy Band Ballad", genre: "Pop", prompt: "90s Boy Band pop ballad. Clean electric piano, simple drum machine beat, earnest male vocals with tight multi-part harmonies, and an emotional, key-changing chorus. Backstreet Boys style.", isMix: false },
{ id: 50, title: "K-Pop Banger", genre: "Pop", prompt: "High-production K-Pop banger. A mix of genres, with a hard-hitting chorus, rap verses, a pre-chorus build-up, and a dance break section. Polished, high-energy production. BTS, BLACKPINK style.", isMix: false },
{ id: 51, title: "Hyperpop Glitch", genre: "Pop", prompt: "Experimental Hyperpop. Pitched-up, autotuned vocals, distorted and glitchy synth sounds, heavy bass, and a chaotic, high-energy structure. 100 gecs, Charli XCX style.", isMix: false },
{ id: 52, title: "Indie Pop Dream", genre: "Pop", prompt: "Dreamy Indie Pop. Jangly guitars with chorus, vintage synth pads, simple and catchy bassline, and breathy, sweet female vocals with lots of reverb. The xx, CHVRCHES style.", isMix: false },
{ id: 53, title: "Dark Pop Atmosphere", genre: "Pop", prompt: "Dark and atmospheric pop. Minimalist beat, deep sub-bass, eerie synth textures, and intimate, whispered female vocals. Billie Eilish, Lorde style.", isMix: false },
{ id: 54, title: "R&B Pop Seduction", genre: "Pop", prompt: "Seductive R&B Pop. Slow, atmospheric beat with trap hi-hats, deep 808s, shimmering synth pads, and smooth, soulful male vocals with a high falsetto. The Weeknd style.", isMix: false },
{ id: 55, title: "Latin Pop Fiesta", genre: "Pop", prompt: "Upbeat Latin Pop. Fusion of reggaeton rhythms with pop melodies, spanish guitar, and a catchy, danceable chorus. Male and female duet. Enrique Iglesias, Shakira style.", isMix: false },
// Cinematic (8)
{ id: 4, title: "Epic Orchestral Score", genre: "Cinematic", prompt: "An epic, sweeping orchestral score. Powerful brass section, dramatic string arrangements (violins, cellos), thunderous percussion (timpani, taiko drums), heroic and emotional choir. Hans Zimmer style.", isMix: false },
{ id: 56, title: "Suspense Thriller Tension", genre: "Cinematic", prompt: "Tense and suspenseful thriller score. Dissonant string textures, a simple, repetitive piano motif, deep and ominous synth drones, and sudden percussive hits to create jump scares.", isMix: false },
{ id: 57, title: "Fantasy Adventure Theme", genre: "Cinematic", prompt: "A magical and adventurous fantasy score. Soaring french horn melody, whimsical woodwinds (flute, oboe), shimmering strings, and a grand, majestic choir. John Williams style.", isMix: false },
{ id: 58, title: "Spaghetti Western Standoff", genre: "Cinematic", prompt: "Spaghetti Western score. Baritone electric guitar with heavy tremolo, dramatic trumpet solo, whistling, male choir chants, and galloping percussion. Ennio Morricone style.", isMix: false },
{ id: 59, title: "Sci-Fi Cyberpunk City", genre: "Cinematic", prompt: "Cyberpunk sci-fi score. Dark, atmospheric synth pads, futuristic arpeggiated synths, deep electronic drums, and a feeling of a vast, rainy, neon-lit city. Blade Runner (Vangelis) style.", isMix: false },
{ id: 60, title: "Noir Jazz Detective", genre: "Cinematic", prompt: "Classic Noir film score. A smoky, melancholic saxophone solo, brushes on the drums, walking upright bass, and a sparse, moody piano. For a private detective in a rainy city.", isMix: false },
{ id: 61, title: "Ghibli-esque Piano", genre: "Cinematic", prompt: "A gentle and nostalgic piano piece in the style of Studio Ghibli films. Simple, emotional piano melody with a light orchestral string backing. Evokes a sense of wonder and childhood. Joe Hisaishi style.", isMix: false },
{ id: 62, title: "War Epic Drama", genre: "Cinematic", prompt: "An emotional and dramatic score for a war film. A solemn and patriotic string melody, military-style snare drum rolls, powerful brass, and a mournful choir. A sense of sacrifice and honor.", isMix: false },
// World (9)
{ id: 10, title: "Reggaeton Dancefloor", genre: "World", prompt: "Infectious reggaeton beat (dembow rhythm), heavy sub bass, catchy synthetic melodies, spanish male vocals with a smooth flow. High energy, perfect for a dance club.", isMix: false },
{ id: 63, title: "Classic Reggae Roots", genre: "World", prompt: "Classic 70s Roots Reggae. One-drop drum beat, heavy and deep bassline, skanking rhythm guitar (offbeat chords), and conscious, soulful vocals. Bob Marley & The Wailers style.", isMix: false },
{ id: 64, title: "Afrobeat Groove", genre: "World", prompt: "Hypnotic Afrobeat. Complex and interlocking rhythm section with multiple percussion instruments, groovy and repetitive bassline, a powerful horn section, and call-and-response vocals. Fela Kuti style.", isMix: false },
{ id: 65, title: "Bollywood Film Song", genre: "World", prompt: "A vibrant Bollywood song. A mix of traditional Indian instruments (sitar, tabla) with modern pop production, a catchy and melodic vocal line, and a grand, cinematic string section.", isMix: false },
{ id: 66, title: "Bossa Nova Cafe", genre: "World", prompt: "Relaxing Bossa Nova. Gentle nylon-string guitar playing complex chords, soft and syncopated drum beat (brushes), and a breathy, intimate Portuguese female vocal. Perfect for a cafe in Rio. Stan Getz, João Gilberto style.", isMix: false },
{ id: 67, title: "Salsa Club Dance", genre: "World", prompt: "High-energy Salsa for dancing. Complex polyrhythms from a full percussion section (congas, timbales, bongos), a powerful piano montuno, a blazing horn section, and passionate Spanish vocals.", isMix: false },
{ id: 68, title: "Celtic Folk Jig", genre: "World", prompt: "Upbeat and festive Celtic folk music. Fast-paced fiddle and tin whistle melodies, rhythmic acoustic guitar, and a bodhrán (Irish frame drum) providing the driving beat. Perfect for a traditional Irish dance (jig).", isMix: false },
{ id: 69, title: "Japanese City Pop", genre: "World", prompt: "80s Japanese City Pop. A sophisticated blend of pop, funk, and jazz. Funky bassline, clean electric guitar, bright brass section, and smooth, breezy Japanese vocals. Nostalgic and urban.", isMix: false },
{ id: 70, title: "Flamenco Passion", genre: "World", prompt: "Passionate and intense Flamenco. Virtuosic acoustic guitar playing with fast passages (picados) and rhythmic strumming (rasgueados), hand claps (palmas), and powerful, emotional Spanish vocals (cante).", isMix: false },
// Jazz & Blues (8)
{ id: 71, title: "Big Band Swing", genre: "Jazz", prompt: "Energetic 1940s Big Band Swing. A full horn section (saxophones, trumpets, trombones) playing powerful riffs, walking bassline, swinging ride cymbal, and a charismatic bandleader. Duke Ellington, Glenn Miller style.", isMix: false },
{ id: 72, title: "Bebop Jazz Club", genre: "Jazz", prompt: "Fast and complex Bebop. A small combo (saxophone, trumpet, piano, bass, drums) playing intricate melodies and fast improvised solos over complex chord changes. Charlie Parker, Dizzy Gillespie style.", isMix: false },
{ id: 73, title: "Cool Jazz Lounge", genre: "Jazz", prompt: "Relaxed and understated Cool Jazz. Mellow trumpet or saxophone melody, light and subtle drumming with brushes, sparse piano chords, and a calm, laid-back atmosphere. Miles Davis (Kind of Blue) style.", isMix: false },
{ id: 74, title: "Smooth Jazz Relaxation", genre: "Jazz", prompt: "80s/90s Smooth Jazz. A prominent, melodic saxophone or electric guitar lead, clean and polished production, simple R&B-influenced drum machine beat, and soft synth pads. Kenny G style.", isMix: false },
{ id: 75, title: "Acid Jazz Funk", genre: "Jazz", prompt: "Funky Acid Jazz. A fusion of jazz, funk, and hip hop. Groovy bassline, rhodes piano, funky drum breaks, and often features a horn section and rap verses. Jamiroquai, Brand New Heavies style.", isMix: false },
{ id: 76, title: "Chicago Blues Gritty", genre: "Blues", prompt: "Gritty, electric Chicago Blues. Overdriven electric guitar playing blues licks, harmonica solo, steady drum shuffle, and a raw, soulful vocal performance. Muddy Waters, Howlin' Wolf style.", isMix: false },
{ id: 77, title: "Acoustic Delta Blues", genre: "Blues", prompt: "Raw and emotional acoustic Delta Blues. A single acoustic guitar with a slide (bottleneck), foot stomping for rhythm, and a powerful, soulful male vocal. Robert Johnson style.", isMix: false },
{ id: 78, title: "Ragtime Piano", genre: "Jazz", prompt: "Upbeat and syncopated Ragtime piano solo. A complex, jaunty right-hand melody over a steady, stride left-hand rhythm. Scott Joplin style. No other instruments.", isMix: false },
// Folk, Acoustic & Country (8)
{ id: 7, title: "Acoustic Campfire Folk", genre: "Acoustic", prompt: "Intimate acoustic folk music. Warm acoustic guitar strumming, gentle fingerpicking, heartfelt male and female duet harmonies, subtle upright bass, maybe a soft harmonica solo. Evokes a campfire setting.", isMix: false },
{ id: 79, title: "Modern Country Radio Hit", genre: "Country", prompt: "Modern country pop. Acoustic guitar intro, building to a big chorus with electric guitars, powerful drums, and a male vocal with a slight southern twang. Themes of love and small-town life.", isMix: false },
{ id: 80, title: "Appalachian Folk", genre: "Folk", prompt: "Traditional Appalachian folk music. Clawhammer banjo, fiddle, acoustic guitar, and heartfelt, nasal vocal harmonies. A sense of history and storytelling.", isMix: false },
{ id: 81, title: "Singer-Songwriter Coffeehouse", genre: "Acoustic", prompt: "Introspective singer-songwriter. A single acoustic guitar and an emotional, honest vocal performance. The focus is on the lyrics and the intimate delivery. Elliott Smith, Nick Drake style.", isMix: false },
{ id: 82, title: "Bluegrass Breakdown", genre: "Country", prompt: "Fast-paced and virtuosic Bluegrass. Featuring fast solos from banjo, fiddle, and mandolin, with a driving upright bass and acoustic guitar rhythm. High energy and impressive musicianship.", isMix: false },
{ id: 83, title: "Country Ballad Heartbreak", genre: "Country", prompt: "A slow, emotional country ballad. Acoustic guitar, mournful pedal steel guitar, sparse piano, and a heartfelt vocal performance about heartbreak and loss. Johnny Cash, George Jones style.", isMix: false },
{ id: 84, title: "Indie Folk Anthem", genre: "Folk", prompt: "Anthemic Indie Folk. Stomping kick drum, hand claps, acoustic guitar, banjo, and a big gang vocal chorus. Upbeat, celebratory, and perfect for a festival. Mumford & Sons style.", isMix: false },
{ id: 85, title: "Americana Storytelling", genre: "Folk", prompt: "Americana. A blend of folk, country, and rock. Focus on storytelling lyrics, with acoustic and electric guitars, organ, and a steady, heartfelt rhythm section. Jason Isbell, The Band style.", isMix: false },
// Funk, Soul & R&B (8)
{ id: 86, title: "70s Funk Groove", genre: "Funk", prompt: "High-energy 70s Funk. Tight and syncopated drum groove, a slap bassline, rhythmic chicken-scratch guitar, and a powerful brass section. James Brown, Parliament-Funkadelic style.", isMix: false },
{ id: 87, title: "Motown Soul Classic", genre: "Soul", prompt: "60s Motown soul. A driving tambourine beat, melodic bassline, clean electric guitar, baritone saxophone, and soulful lead vocals with lush background harmonies. The Temptations, Marvin Gaye style.", isMix: false },
{ id: 88, title: "Modern R&B Slow Jam", genre: "R&B", prompt: "A modern R&B slow jam. Slow trap-influenced beat, deep 808 bass, atmospheric synth pads, and smooth, layered vocals with intricate runs and ad-libs. For late nights.", isMix: false },
{ id: 89, title: "Neo-Soul Vibe", genre: "Soul", prompt: "Laid-back Neo-Soul. A relaxed, hip hop-influenced drum beat, a warm and jazzy Rhodes piano, a deep and groovy bassline, and soulful, improvisational vocals. Erykah Badu, D'Angelo style.", isMix: false },
{ id: 90, title: "Disco Fever Night", genre: "Funk", prompt: "70s Disco. A four-on-the-floor kick drum, an iconic octave-jumping bassline, funky rhythm guitar, lush string section, and soaring falsetto vocals. Bee Gees, Earth, Wind & Fire style.", isMix: false },
{ id: 91, title: "P-Funk Extravaganza", genre: "Funk", prompt: "Psychedelic and experimental P-Funk. A wild and loose groove, synthesizer experimentation, comedic and bizarre vocal arrangements, and extended instrumental jams. George Clinton, Bootsy Collins style.", isMix: false },
{ id: 92, title: "Quiet Storm Ballad", genre: "R&B", prompt: "80s Quiet Storm R&B ballad. Slow, sensual drum machine beat, smooth synth bass, shimmering electric piano, and a romantic, soulful vocal performance. Luther Vandross, Anita Baker style.", isMix: false },
{ id: 93, title: "Gospel Choir Uplifting", genre: "Soul", prompt: "Uplifting Gospel music. A powerful and soulful lead vocalist backed by a large, energetic choir. Hammond organ, piano, and a driving drum beat. A feeling of joy and celebration.", isMix: false },
// Ambient (2)
{ id: 9, title: "Dark Ambient Drone", genre: "Ambient", prompt: "Dark, atmospheric ambient drone. Evolving synth pads, deep sub-bass frequencies, sparse, ethereal textures, haunting and meditative. No drums, no rhythm. For deep focus or sleep.", isMix: false },
{ id: 94, title: "Generative Ambient Music", genre: "Ambient", prompt: "Calm, generative ambient music. Ever-changing, non-repeating synth textures and soft, shimmering pads. Designed to be unobtrusive and create a peaceful atmosphere. Brian Eno style.", isMix: false }
];
// --- VARIABLES D'ÉTAT ---
let presets = [];
let favorites = new Set();
let currentFilter = 'All'; // Can be 'All', 'Favorites', or a genre name
let currentSearchTerm = '';
let selectedPresetIds = new Set();
let shouldClearSelectionAfterSave = false;
// --- SÉLECTEURS DOM ---
const genreMenu = document.getElementById('genre-menu');
const presetGrid = document.getElementById('preset-grid');
const searchBar = document.getElementById('search-bar');
const toastContainer = document.getElementById('toast-container');
const mixerPanel = document.getElementById('mixer-panel');
const selectedCount = document.getElementById('selected-count');
const mixedPromptTextarea = document.getElementById('mixed-prompt');
const copyMixedBtn = document.getElementById('copy-mixed-btn');
const saveMixedBtn = document.getElementById('save-mixed-btn');
const enhanceMixedBtn = document.getElementById('enhance-mixed-btn');
const clearSelectionBtn = document.getElementById('clear-selection-btn');
const previewMixedBtn = document.getElementById('preview-mixed-btn');
const modal = document.getElementById('preset-modal');
const modalTitle = document.getElementById('modal-title');
const presetForm = document.getElementById('preset-form');
const modalPresetIdInput = document.getElementById('modal-preset-id');
const presetTitleInput = document.getElementById('preset-title');
const presetGenreInput = document.getElementById('preset-genre');
const presetPromptTextarea = document.getElementById('preset-prompt');
const modalCancelBtn = document.getElementById('modal-cancel-btn');
const previewModal = document.getElementById('preview-modal');
const previewPromptText = document.getElementById('preview-prompt-text');
const previewCharCount = document.getElementById('preview-char-count');
const previewCloseBtn = document.getElementById('preview-close-btn');
const previewCopyCloseBtn = document.getElementById('preview-copy-close-btn');
const addNewPresetBtn = document.getElementById('add-new-preset-btn');
const exportBtn = document.getElementById('export-btn');
const importBtn = document.getElementById('import-btn');
const importInput = document.getElementById('import-input');
// --- FONCTIONS DE PERSISTANCE (localStorage) ---
function savePresets() {
localStorage.setItem('sunoStyleLabPresets', JSON.stringify(presets));
}
function loadPresets() {
const saved = localStorage.getItem('sunoStyleLabPresets');
presets = saved ? JSON.parse(saved) : initialPresets.sort((a, b) => a.genre.localeCompare(b.genre) || a.title.localeCompare(b.title));
}
function saveFavorites() {
localStorage.setItem('sunoStyleLabFavorites', JSON.stringify(Array.from(favorites)));
}
function loadFavorites() {
const saved = localStorage.getItem('sunoStyleLabFavorites');
favorites = new Set(saved ? JSON.parse(saved) : []);
}
// --- FONCTIONS DE RENDU ---
function renderGenreMenu() {
const genres = ['All', 'Favorites', ...new Set(presets.map(p => p.genre).sort())];
genreMenu.innerHTML = genres.map(genre => {
const isFavorite = genre === 'Favorites';
const isActive = currentFilter === genre;
const icon = isFavorite ? '⭐' : '';
return `
<a href="#" class="block py-2 px-4 rounded-lg text-gray-300 hover:bg-gray-700 hover:text-white transition-colors ${isActive ? 'bg-gray-700 text-white font-semibold' : ''}" data-filter="${genre}">
${icon} ${genre}
</a>
`}).join('');
}
function createPresetCardElement(p) {
const card = document.createElement('div');
const isFavorited = favorites.has(p.id);
card.className = `card bg-gray-800 rounded-lg p-5 flex flex-col justify-between shadow-lg hover:shadow-xl transition-all duration-300 ${selectedPresetIds.has(p.id) ? 'selected' : ''} ${isFavorited ? 'favorited' : ''}`;
card.dataset.id = p.id;
card.innerHTML = `
<div class="flex-1">
<div class="flex justify-between items-start mb-2">
<h3 class="font-bold text-lg text-white flex-1 pr-2">${p.title} ${p.isMix ? '<span class="text-xs bg-indigo-500 text-white px-2 py-1 rounded-full ml-2 align-middle">Mix</span>' : ''}</h3>
<button class="favorite-btn p-1 rounded-full hover:bg-gray-700 group flex-shrink-0" title="Ajouter aux favoris">
<svg class="star-icon text-gray-500 group-hover:text-yellow-400" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279L12 19.449l-7.416 4.024 1.48-8.279L0 9.306l8.332-1.151z"/></svg>
</button>
</div>
<p class="text-gray-400 text-sm mb-4">${p.prompt}</p>
</div>
<div class="flex items-center justify-between mt-4">
<span class="text-xs bg-gray-700 text-gray-300 px-2 py-1 rounded-full">${p.genre}</span>
<div class="flex space-x-2 card-actions">
<button class="edit-btn p-2 rounded-full bg-gray-700 hover:bg-yellow-600 group" title="Modifier le preset">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-gray-300 group-hover:text-white"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>
</button>
<button class="delete-btn p-2 rounded-full bg-gray-700 hover:bg-red-600 group" title="Supprimer le preset">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-gray-300 group-hover:text-white"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
</button>
<button class="copy-btn p-2 rounded-full bg-gray-700 hover:bg-blue-600 group" title="Copier le prompt">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-gray-300 group-hover:text-white"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
</button>
<button class="alt-btn p-2 rounded-full bg-gray-700 hover:bg-purple-600 group" title="Générer un alternatif">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-gray-300 group-hover:text-white"><path d="M12 3c7.2 0 9 1.8 9 9s-1.8 9-9 9-9-1.8-9-9 1.8-9 9-9z"/><path d="M8 12h8"/><path d="M12 8v8"/></svg>
</button>
</div>
</div>
`;
// Add a fade-in animation class after a short delay to ensure it's applied
setTimeout(() => card.classList.add('fade-in'), 10);
return card;
}
function renderPresets() {
presetGrid.innerHTML = '';
let filteredPresets = presets;
// Filter by genre or favorites
if (currentFilter === 'Favorites') {
filteredPresets = filteredPresets.filter(p => favorites.has(p.id));
} else if (currentFilter !== 'All') {
filteredPresets = filteredPresets.filter(p => p.genre === currentFilter);
}
// Filter by search term
if (currentSearchTerm) {
const lowerCaseSearchTerm = currentSearchTerm.toLowerCase();
filteredPresets = filteredPresets.filter(p =>
p.title.toLowerCase().includes(lowerCaseSearchTerm) ||
p.prompt.toLowerCase().includes(lowerCaseSearchTerm)
);
}
filteredPresets.forEach(p => {
const cardElement = createPresetCardElement(p);
presetGrid.appendChild(cardElement);
});
}
function updateMixerPanel() {
const count = selectedPresetIds.size;
selectedCount.textContent = count;
if (count > 0) {
mixerPanel.classList.remove('translate-y-full');
} else {
mixerPanel.classList.add('translate-y-full');
}
if (count > 1) {
const selectedPresets = presets.filter(p => selectedPresetIds.has(p.id));
const primaryStyle = selectedPresets[0];
const otherStyles = selectedPresets.slice(1).map(p => p.title.toLowerCase()).join(', ');
let mixedPrompt = `Fusion of ${primaryStyle.genre.toLowerCase()}: ${primaryStyle.title}, with influences from ${otherStyles}. A unique and cohesive blend.`;
if (mixedPrompt.length > 200) {
mixedPrompt = mixedPrompt.substring(0, 197) + '...';
}
mixedPromptTextarea.value = mixedPrompt;
[copyMixedBtn, saveMixedBtn, enhanceMixedBtn, previewMixedBtn].forEach(btn => btn.disabled = false);
} else {
mixedPromptTextarea.value = count === 1 ? 'Sélectionnez au moins un style de plus...' : 'Sélectionnez au moins 2 styles pour commencer le mixage...';
[copyMixedBtn, saveMixedBtn, enhanceMixedBtn, previewMixedBtn].forEach(btn => btn.disabled = true);
}
}
// --- FONCTIONS UTILITAIRES ---
function showToast(message, type = 'success') {
const colors = {
success: 'bg-green-600',
error: 'bg-red-600',
info: 'bg-blue-600'
};
const toast = document.createElement('div');
toast.className = `toast ${colors[type]} text-white font-bold py-2 px-4 rounded-lg shadow-lg`;
toast.textContent = message;
toastContainer.appendChild(toast);
setTimeout(() => toast.remove(), 3000);
}
function showModal(data = {}) {
presetForm.reset();
const isEditing = !!data.id;
const isPreFill = !!data.title && !isEditing;
modalTitle.textContent = isEditing ? 'Modifier le Preset' :
isPreFill ? 'Confirmer le nouveau Preset Mixé' : 'Ajouter un nouveau Preset';
modalPresetIdInput.value = data.id || '';
document.getElementById('modal-preset-isMix').value = data.isMix || false;
presetTitleInput.value = data.title || '';
presetGenreInput.value = data.genre || '';
presetPromptTextarea.value = data.prompt || '';
modal.classList.remove('hidden');
}
function hideModal() {
modal.classList.add('hidden');
}
function showPreviewModal() {
const prompt = mixedPromptTextarea.value;
previewPromptText.textContent = prompt;
const charCount = prompt.length;
previewCharCount.textContent = `${charCount} / 200`;
previewCharCount.className = `text-sm font-mono px-3 py-1 rounded-full ${charCount > 200 ? 'bg-red-500 text-white' : 'bg-green-500 text-white'}`;
previewModal.classList.remove('hidden');
}
function hidePreviewModal() {
previewModal.classList.add('hidden');
}
function copyTextToClipboard(text) {
const textArea = document.createElement("textarea");
textArea.value = text;
textArea.style.position = "fixed";
textArea.style.opacity = "0";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
showToast('Prompt copié !');
} catch (err) {
showToast("Erreur lors de la copie.", 'error');
}
document.body.removeChild(textArea);
}
function deletePreset(id) {
const presetToDelete = presets.find(p => p.id === id);
if (confirm(`Êtes-vous sûr de vouloir supprimer le preset "${presetToDelete.title}" ?`)) {
presets = presets.filter(p => p.id !== id);
favorites.delete(id);
savePresets();
saveFavorites();
renderPresets();
showToast(`"${presetToDelete.title}" a été supprimé.`, 'info');
}
}
function toggleFavorite(id) {
const card = presetGrid.querySelector(`[data-id="${id}"]`);
if (favorites.has(id)) {
favorites.delete(id);
card.classList.remove('favorited');
} else {
favorites.add(id);
card.classList.add('favorited');
}
saveFavorites();
// If we are in the favorites view, re-render to remove the card
if (currentFilter === 'Favorites') {
renderPresets();
}
}
// --- FONCTIONS GEMINI API ---
async function callGeminiAPI(systemPrompt, userPrompt) {
const apiKey = ""; // API Key is handled by the environment
const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-05-20:generateContent?key=${apiKey}`;
const payload = {
systemInstruction: { parts: [{ text: systemPrompt }] },
contents: [{ parts: [{ text: userPrompt }] }],
};
try {
const response = await fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(`API call failed with status: ${response.status}`);
const result = await response.json();
const candidate = result.candidates?.[0];
if (candidate && candidate.content?.parts?.[0]?.text) {
let text = candidate.content.parts[0].text.trim();
if (text.length > 200) {
text = text.substring(0, text.lastIndexOf(' ', 197)) + '...';
}
return text;
}
throw new Error('Invalid API response structure');
} catch (error) {
console.error('Error calling Gemini API:', error);
showToast("Erreur de connexion avec l'IA.", 'error');
return null;
}
}
async function enhancePromptWithGemini(promptToEnhance) {
const systemPrompt = `You are an expert music producer and a master prompt engineer for AI music generators like Suno.
Your task is to analyze the user's music style prompt and enhance it.
- Make it more descriptive, evocative, and detailed.
- Suggest specific instruments, moods, tempos (BPM), and production techniques that would blend the styles cohesively.
- Keep the core genres and artist influences mentioned by the user.
- The output should be a single, ready-to-use prompt in a paragraph. Do not use markdown or titles.
- Respond in the language of the original prompt.
- IMPORTANT: The final output prompt MUST be under 200 characters in total.`;
return await callGeminiAPI(systemPrompt, `Enhance this prompt: "${promptToEnhance}"`);
}
async function generateAlternativeWithAI(originalId, btnElement) {
const originalPreset = presets.find(p => p.id === originalId);
if (!originalPreset) return;
const originalIcon = btnElement.innerHTML;
btnElement.disabled = true;
btnElement.innerHTML = `<svg class="animate-spin h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>`;
// FIX: Always base the new title on the original, non-"Alt" version.
const baseTitle = originalPreset.title.replace(/^(Alt: )+/, '');
const basePreset = presets.find(p => p.title === baseTitle) || originalPreset;
const systemPrompt = `You are a creative music production expert. Given a music style title, generate a fresh, descriptive, and inspiring prompt for an AI music generator like Suno.
- The prompt must offer a unique perspective or a creative twist on the style.
- It should be evocative and detailed.
- IMPORTANT: The final prompt MUST be under 200 characters.`;
const newPrompt = await callGeminiAPI(systemPrompt, `Generate a new prompt for the style: "${baseTitle}"`);
if (newPrompt) {
const newPreset = {
id: Date.now(),
title: `Alt: ${baseTitle}`,
genre: basePreset.genre,
prompt: newPrompt,
isMix: false
};
presets.unshift(newPreset);
savePresets();
renderPresets();
const newCard = presetGrid.querySelector(`[data-id='${newPreset.id}']`);
if (newCard) newCard.scrollIntoView({ behavior: 'smooth', block: 'center' });
showToast("Alternative générée !");
}
btnElement.disabled = false;
btnElement.innerHTML = originalIcon;
}
// --- GESTIONNAIRES D'ÉVÉNEMENTS ---
searchBar.addEventListener('input', e => {
currentSearchTerm = e.target.value;
renderPresets();
});
genreMenu.addEventListener('click', e => {
const link = e.target.closest('a');
if (link) {
e.preventDefault();
currentFilter = link.dataset.filter;
searchBar.value = '';
currentSearchTerm = '';
renderGenreMenu();
renderPresets();
}
});
presetGrid.addEventListener('click', e => {
const card = e.target.closest('.card');
if (!card) return;
const presetId = parseInt(card.dataset.id);
const preset = presets.find(p => p.id === presetId);
if (e.target.closest('.copy-btn')) copyTextToClipboard(preset.prompt);
else if (e.target.closest('.alt-btn')) generateAlternativeWithAI(presetId, e.target.closest('.alt-btn'));
else if (e.target.closest('.delete-btn')) deletePreset(presetId);
else if (e.target.closest('.edit-btn')) showModal(preset);
else if (e.target.closest('.favorite-btn')) toggleFavorite(presetId);
else {
card.classList.toggle('selected');
selectedPresetIds.has(presetId) ? selectedPresetIds.delete(presetId) : selectedPresetIds.add(presetId);
updateMixerPanel();
}
});
clearSelectionBtn.addEventListener('click', () => {
selectedPresetIds.clear();
document.querySelectorAll('.card.selected').forEach(card => card.classList.remove('selected'));
updateMixerPanel();
});
copyMixedBtn.addEventListener('click', () => copyTextToClipboard(mixedPromptTextarea.value));
previewMixedBtn.addEventListener('click', () => {
if (!previewMixedBtn.disabled) {
showPreviewModal();
}
});
enhanceMixedBtn.addEventListener('click', async () => {
const originalPrompt = mixedPromptTextarea.value;
if (!originalPrompt || enhanceMixedBtn.disabled) return;
const originalBtnText = enhanceMixedBtn.innerHTML;
enhanceMixedBtn.innerHTML = `<svg class="animate-spin -ml-1 mr-3 h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>Amélioration...`;
[enhanceMixedBtn, copyMixedBtn, saveMixedBtn, previewMixedBtn].forEach(btn => btn.disabled = true);
const enhancedPrompt = await enhancePromptWithGemini(originalPrompt);
if (enhancedPrompt) mixedPromptTextarea.value = enhancedPrompt;
enhanceMixedBtn.innerHTML = originalBtnText;
[enhanceMixedBtn, copyMixedBtn, saveMixedBtn, previewMixedBtn].forEach(btn => btn.disabled = false);
});
saveMixedBtn.addEventListener('click', () => {
if (selectedPresetIds.size < 2) return;
const selected = presets.filter(p => selectedPresetIds.has(p.id));
const newTitle = selected.map(p => p.title.replace('Alt: ', '')).slice(0, 3).join(' + ') + ' Mix';
shouldClearSelectionAfterSave = true;
showModal({ title: newTitle, genre: 'Mix', prompt: mixedPromptTextarea.value, isMix: true });
});
addNewPresetBtn.addEventListener('click', () => showModal());
modalCancelBtn.addEventListener('click', hideModal);
modal.addEventListener('click', e => e.target === modal && hideModal());
previewCloseBtn.addEventListener('click', hidePreviewModal);
previewCopyCloseBtn.addEventListener('click', () => {
copyTextToClipboard(previewPromptText.textContent);
hidePreviewModal();
});
previewModal.addEventListener('click', e => e.target === previewModal && hidePreviewModal());
presetForm.addEventListener('submit', e => {
e.preventDefault();
const id = modalPresetIdInput.value ? parseInt(modalPresetIdInput.value) : Date.now();
const presetData = {
id,
title: presetTitleInput.value.trim(),
genre: presetGenreInput.value.trim(),
prompt: presetPromptTextarea.value.trim(),
isMix: document.getElementById('modal-preset-isMix').value === 'true'
};
if(!presetData.title || !presetData.genre || !presetData.prompt) {
return showToast("Veuillez remplir tous les champs.", "error");
}
const existingIndex = presets.findIndex(p => p.id === id);
if (existingIndex !== -1) {
presets[existingIndex] = presetData;
showToast("Preset modifié avec succès !");
} else {
presets.unshift(presetData);
showToast("Preset ajouté avec succès !");
}
savePresets();
hideModal();
if (shouldClearSelectionAfterSave) {
clearSelectionBtn.click();
shouldClearSelectionAfterSave = false;
}
currentFilter = presetData.genre;
renderGenreMenu();
renderPresets();
});
exportBtn.addEventListener('click', () => {
const dataStr = JSON.stringify({ presets, favorites: Array.from(favorites) }, null, 2);
const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
const exportFileDefaultName = 'suno_style_lab_collection.json';
const linkElement = document.createElement('a');
linkElement.setAttribute('href', dataUri);
linkElement.setAttribute('download', exportFileDefaultName);
linkElement.click();
});
importBtn.addEventListener('click', () => importInput.click());
importInput.addEventListener('change', (event) => {
const file = event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
try {
const data = JSON.parse(e.target.result);
if (Array.isArray(data.presets) && Array.isArray(data.favorites)) {
if (confirm("Voulez-vous remplacer votre collection actuelle par les presets importés ?")) {
presets = data.presets;
favorites = new Set(data.favorites);
savePresets();
saveFavorites();
currentFilter = 'All';
init();
showToast('Importation réussie !');
}
} else {
throw new Error("Le fichier JSON n'est pas valide.");
}
} catch (error) {
showToast(`Erreur lors de l'importation : ${error.message}`, 'error');
}
};
reader.readAsText(file);
importInput.value = '';
});
// --- INITIALISATION ---
function init() {
loadPresets();
loadFavorites();
renderGenreMenu();
renderPresets();
}
init();
});