horeg-audio 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,828 @@
1
+ "use strict";var M=Object.defineProperty;var B=(l,e,i)=>e in l?M(l,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[e]=i;var r=(l,e,i)=>B(l,typeof e!="symbol"?e+"":e,i);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C={"horeg-classic":{primaryGlowColor:"#f59e0b",accentColor:"#ef4444",cardBackground:"#121214",textColor:"#f4f4f5",sliderProgressColor:"#f59e0b",borderRadius:"14px"},"horeg-nightclub":{primaryGlowColor:"#06b6d4",accentColor:"#ec4899",cardBackground:"#0b0c10",textColor:"#f8fafc",sliderProgressColor:"#06b6d4",borderRadius:"14px"},"horeg-stealth":{primaryGlowColor:"#94a3b8",accentColor:"#e2e8f0",cardBackground:"#0f1115",textColor:"#e2e8f0",sliderProgressColor:"#94a3b8",borderRadius:"8px"}};function T(l={}){const e=l.variant||"horeg-classic",i=C[e]||C["horeg-classic"],t=l.primaryGlowColor||i.primaryGlowColor||"#f59e0b",a=l.accentColor||i.accentColor||"#ef4444",s=l.cardBackground||i.cardBackground||"#121214",n=l.textColor||i.textColor||"#f4f4f5",c=l.sliderProgressColor||i.sliderProgressColor||t,h=l.borderRadius||i.borderRadius||"14px";return`
2
+ :host {
3
+ --horeg-bg: ${s};
4
+ --horeg-surface: #18181b;
5
+ --horeg-surface-hover: #222226;
6
+ --horeg-border: #27272a;
7
+ --horeg-glow: ${t};
8
+ --horeg-glow-rgb: 245, 158, 11;
9
+ --horeg-accent: ${a};
10
+ --horeg-progress: ${c};
11
+ --horeg-text-main: ${n};
12
+ --horeg-text-muted: #a1a1aa;
13
+ --horeg-radius: ${h};
14
+ display: block;
15
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
16
+ box-sizing: border-box;
17
+ outline: none;
18
+ user-select: none;
19
+ -webkit-user-select: none;
20
+ }
21
+
22
+ *, *::before, *::after {
23
+ box-sizing: border-box;
24
+ margin: 0;
25
+ padding: 0;
26
+ }
27
+
28
+ .horeg-player-box {
29
+ background: var(--horeg-bg);
30
+ border: 2px solid var(--horeg-border);
31
+ border-radius: var(--horeg-radius);
32
+ box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.9), 0 0 20px -5px var(--horeg-glow);
33
+ color: var(--horeg-text-main);
34
+ position: relative;
35
+ overflow: hidden;
36
+ max-width: 520px;
37
+ width: 100%;
38
+ margin: 0 auto;
39
+ transition: box-shadow 0.3s ease, border-color 0.3s ease;
40
+ }
41
+
42
+ /* Player Box active glow when focused within */
43
+ :host(:focus) .horeg-player-box,
44
+ :host(:focus-within) .horeg-player-box,
45
+ .horeg-player-box:focus-within {
46
+ border-color: var(--horeg-glow);
47
+ box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.95), 0 0 30px -2px var(--horeg-glow), 0 0 10px var(--horeg-glow);
48
+ }
49
+
50
+ :host(:focus) .horeg-player-box .horeg-bolt,
51
+ :host(:focus-within) .horeg-player-box .horeg-bolt,
52
+ .horeg-player-box:focus-within .horeg-bolt {
53
+ box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), 0 0 4px var(--horeg-glow);
54
+ }
55
+
56
+ .horeg-speaker-grill {
57
+ position: absolute;
58
+ inset: 0;
59
+ background-image: radial-gradient(#2c2d33 1.2px, transparent 1.2px);
60
+ background-size: 8px 8px;
61
+ opacity: 0.3;
62
+ pointer-events: none;
63
+ z-index: 1;
64
+ }
65
+
66
+ /* Metal Corner Brackets / Screws (Sound System Rig Rigging) */
67
+ .horeg-bolt {
68
+ position: absolute;
69
+ width: 8px;
70
+ height: 8px;
71
+ background: #3f3f46;
72
+ border: 1px solid #18181b;
73
+ border-radius: 50%;
74
+ box-shadow: inset 0 1px 1px rgba(255,255,255,0.2), 0 1px 2px rgba(0,0,0,0.8);
75
+ z-index: 2;
76
+ }
77
+ .horeg-bolt::after {
78
+ content: '';
79
+ position: absolute;
80
+ top: 50%;
81
+ left: 50%;
82
+ width: 4px;
83
+ height: 1px;
84
+ background: #18181b;
85
+ transform: translate(-50%, -50%) rotate(45deg);
86
+ }
87
+ .horeg-bolt.top-left { top: 7px; left: 7px; }
88
+ .horeg-bolt.top-right { top: 7px; right: 7px; }
89
+ .horeg-bolt.bottom-left { bottom: 7px; left: 7px; }
90
+ .horeg-bolt.bottom-right { bottom: 7px; right: 7px; }
91
+
92
+ .horeg-content-wrap {
93
+ position: relative;
94
+ z-index: 3;
95
+ padding: 18px 20px 16px 20px;
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: 14px;
99
+ }
100
+
101
+ /* Top Rig Header */
102
+ .horeg-header {
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: space-between;
106
+ border-bottom: 1px solid #27272a;
107
+ padding-bottom: 8px;
108
+ }
109
+
110
+ .horeg-rig-badge {
111
+ display: flex;
112
+ align-items: center;
113
+ gap: 6px;
114
+ font-size: 10px;
115
+ letter-spacing: 1.5px;
116
+ text-transform: uppercase;
117
+ font-weight: 800;
118
+ color: var(--horeg-glow);
119
+ text-shadow: 0 0 8px var(--horeg-glow);
120
+ }
121
+
122
+ .horeg-badge-led {
123
+ width: 7px;
124
+ height: 7px;
125
+ background-color: var(--horeg-glow);
126
+ border-radius: 50%;
127
+ box-shadow: 0 0 6px var(--horeg-glow);
128
+ animation: ledPulse 2s infinite ease-in-out;
129
+ }
130
+
131
+ @keyframes ledPulse {
132
+ 0%, 100% { opacity: 0.5; transform: scale(0.9); }
133
+ 50% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 10px var(--horeg-glow); }
134
+ }
135
+
136
+ /* Track Display & Visualizer Section */
137
+ .horeg-track-row {
138
+ display: flex;
139
+ align-items: center;
140
+ gap: 14px;
141
+ }
142
+
143
+ .horeg-cover-container {
144
+ position: relative;
145
+ width: 64px;
146
+ height: 64px;
147
+ min-width: 64px;
148
+ border-radius: 8px;
149
+ overflow: hidden;
150
+ background: #18181b;
151
+ border: 1px solid #3f3f46;
152
+ display: flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ box-shadow: inset 0 0 10px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.6);
156
+ }
157
+
158
+ .horeg-cover-img {
159
+ width: 100%;
160
+ height: 100%;
161
+ object-fit: cover;
162
+ }
163
+
164
+ .horeg-cover-fallback {
165
+ color: var(--horeg-glow);
166
+ opacity: 0.7;
167
+ }
168
+
169
+ .horeg-track-info {
170
+ flex: 1;
171
+ min-width: 0;
172
+ display: flex;
173
+ flex-direction: column;
174
+ gap: 2px;
175
+ }
176
+
177
+ .horeg-track-title {
178
+ font-size: 15px;
179
+ font-weight: 700;
180
+ white-space: nowrap;
181
+ overflow: hidden;
182
+ text-overflow: ellipsis;
183
+ color: var(--horeg-text-main);
184
+ letter-spacing: 0.2px;
185
+ }
186
+
187
+ .horeg-track-artist {
188
+ font-size: 12px;
189
+ font-weight: 500;
190
+ color: var(--horeg-text-muted);
191
+ white-space: nowrap;
192
+ overflow: hidden;
193
+ text-overflow: ellipsis;
194
+ }
195
+
196
+ .horeg-track-album {
197
+ font-size: 10px;
198
+ color: #71717a;
199
+ white-space: nowrap;
200
+ overflow: hidden;
201
+ text-overflow: ellipsis;
202
+ }
203
+
204
+ /* Mini EQ Visualizer */
205
+ .horeg-eq-wrapper {
206
+ display: flex;
207
+ align-items: flex-end;
208
+ gap: 2px;
209
+ height: 24px;
210
+ padding: 0 4px;
211
+ }
212
+
213
+ .horeg-eq-bar {
214
+ width: 3px;
215
+ height: 4px;
216
+ background: var(--horeg-glow);
217
+ border-radius: 1px;
218
+ transition: height 0.1s ease;
219
+ box-shadow: 0 0 4px var(--horeg-glow);
220
+ }
221
+
222
+ /* Scrubbing / Fader Progress Bar */
223
+ .horeg-progress-container {
224
+ display: flex;
225
+ flex-direction: column;
226
+ gap: 5px;
227
+ }
228
+
229
+ .horeg-time-row {
230
+ display: flex;
231
+ justify-content: space-between;
232
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
233
+ font-size: 11px;
234
+ color: var(--horeg-text-muted);
235
+ }
236
+
237
+ .horeg-slider-track {
238
+ position: relative;
239
+ width: 100%;
240
+ height: 7px;
241
+ background: #27272a;
242
+ border-radius: 4px;
243
+ cursor: pointer;
244
+ overflow: hidden;
245
+ box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
246
+ }
247
+
248
+ .horeg-buffer-bar {
249
+ position: absolute;
250
+ top: 0;
251
+ bottom: 0;
252
+ left: 0;
253
+ width: 0%;
254
+ background: #3f3f46;
255
+ border-radius: 4px;
256
+ transition: width 0.2s linear;
257
+ }
258
+
259
+ .horeg-fill-bar {
260
+ position: absolute;
261
+ top: 0;
262
+ bottom: 0;
263
+ left: 0;
264
+ width: 0%;
265
+ background: linear-gradient(90deg, var(--horeg-accent) 0%, var(--horeg-progress) 100%);
266
+ border-radius: 4px;
267
+ box-shadow: 0 0 8px var(--horeg-glow);
268
+ transition: width 0.08s linear;
269
+ }
270
+
271
+ /* Controls Row */
272
+ .horeg-controls-row {
273
+ display: flex;
274
+ align-items: center;
275
+ justify-content: space-between;
276
+ padding-top: 4px;
277
+ }
278
+
279
+ .horeg-side-controls {
280
+ display: flex;
281
+ align-items: center;
282
+ gap: 8px;
283
+ }
284
+
285
+ .horeg-center-controls {
286
+ display: flex;
287
+ align-items: center;
288
+ gap: 12px;
289
+ }
290
+
291
+ .horeg-btn {
292
+ background: transparent;
293
+ border: none;
294
+ outline: none;
295
+ color: var(--horeg-text-muted);
296
+ cursor: pointer;
297
+ padding: 6px;
298
+ border-radius: 8px;
299
+ display: inline-flex;
300
+ align-items: center;
301
+ justify-content: center;
302
+ transition: all 0.15s ease;
303
+ touch-action: manipulation;
304
+ }
305
+
306
+ .horeg-btn:hover {
307
+ color: var(--horeg-text-main);
308
+ background: var(--horeg-surface-hover);
309
+ }
310
+
311
+ .horeg-btn:active {
312
+ transform: scale(0.92);
313
+ filter: brightness(1.2);
314
+ }
315
+
316
+ .horeg-btn:focus-visible {
317
+ outline: 2px solid var(--horeg-glow);
318
+ outline-offset: 1px;
319
+ }
320
+
321
+ .horeg-btn.active {
322
+ color: var(--horeg-glow);
323
+ background: rgba(255, 255, 255, 0.06);
324
+ text-shadow: 0 0 8px var(--horeg-glow);
325
+ box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.05);
326
+ }
327
+
328
+ /* Primary Play / Pause Button with Neon Glow Pulse */
329
+ .horeg-btn-play {
330
+ width: 44px;
331
+ height: 44px;
332
+ border-radius: 50%;
333
+ background: #1f1f23;
334
+ border: 2px solid var(--horeg-glow);
335
+ color: var(--horeg-glow);
336
+ box-shadow: 0 0 12px -2px var(--horeg-glow);
337
+ transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
338
+ }
339
+
340
+ .horeg-btn-play:hover {
341
+ background: #27272a;
342
+ transform: scale(1.06);
343
+ box-shadow: 0 0 18px 2px var(--horeg-glow);
344
+ }
345
+
346
+ .horeg-btn-play:active {
347
+ transform: scale(0.96);
348
+ }
349
+
350
+ .horeg-btn-play.playing {
351
+ background: var(--horeg-glow);
352
+ color: #09090b;
353
+ box-shadow: 0 0 20px var(--horeg-glow), inset 0 0 8px rgba(255, 255, 255, 0.4);
354
+ animation: playPulse 2.2s infinite ease-in-out;
355
+ }
356
+
357
+ @keyframes playPulse {
358
+ 0%, 100% {
359
+ box-shadow: 0 0 15px var(--horeg-glow);
360
+ }
361
+ 50% {
362
+ box-shadow: 0 0 25px var(--horeg-glow), 0 0 8px #fff;
363
+ }
364
+ }
365
+
366
+ /* Volume Slider Rel Mixer */
367
+ .horeg-volume-wrap {
368
+ display: flex;
369
+ align-items: center;
370
+ gap: 6px;
371
+ }
372
+
373
+ .horeg-volume-slider {
374
+ -webkit-appearance: none;
375
+ appearance: none;
376
+ width: 70px;
377
+ height: 5px;
378
+ background: #27272a;
379
+ border-radius: 3px;
380
+ outline: none;
381
+ cursor: pointer;
382
+ }
383
+
384
+ .horeg-volume-slider::-webkit-slider-thumb {
385
+ -webkit-appearance: none;
386
+ appearance: none;
387
+ width: 12px;
388
+ height: 12px;
389
+ border-radius: 50%;
390
+ background: var(--horeg-glow);
391
+ border: 1px solid #18181b;
392
+ box-shadow: 0 0 6px var(--horeg-glow);
393
+ cursor: pointer;
394
+ transition: transform 0.1s ease;
395
+ }
396
+
397
+ .horeg-volume-slider::-webkit-slider-thumb:hover {
398
+ transform: scale(1.2);
399
+ }
400
+
401
+ .horeg-volume-slider::-moz-range-thumb {
402
+ width: 12px;
403
+ height: 12px;
404
+ border-radius: 50%;
405
+ background: var(--horeg-glow);
406
+ border: 1px solid #18181b;
407
+ box-shadow: 0 0 6px var(--horeg-glow);
408
+ cursor: pointer;
409
+ }
410
+
411
+ /* Drag Over Highlight on main player */
412
+ .horeg-player-box.drag-over {
413
+ border-color: var(--horeg-glow);
414
+ box-shadow: 0 0 25px var(--horeg-glow), 0 8px 32px rgba(0, 0, 0, 0.9);
415
+ }
416
+
417
+ /* Rack Mount Playlist Drawer */
418
+ .horeg-drawer {
419
+ max-height: 0;
420
+ opacity: 0;
421
+ overflow-y: auto;
422
+ transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
423
+ background: #141416;
424
+ border-top: 1px solid #27272a;
425
+ border-radius: 0 0 calc(var(--horeg-radius) - 2px) calc(var(--horeg-radius) - 2px);
426
+ scrollbar-width: thin;
427
+ scrollbar-color: #3f3f46 #18181b;
428
+ position: relative;
429
+ z-index: 3;
430
+ }
431
+
432
+ .horeg-drawer.open {
433
+ max-height: 220px;
434
+ max-height: 380px;
435
+ opacity: 1;
436
+ }
437
+
438
+ /* Drawer Header */
439
+ .horeg-drawer-header {
440
+ display: flex;
441
+ align-items: center;
442
+ justify-content: space-between;
443
+ padding: 10px 14px 8px 14px;
444
+ border-bottom: 1px solid #27272a;
445
+ position: sticky;
446
+ top: 0;
447
+ background: #141416;
448
+ z-index: 2;
449
+ }
450
+
451
+ .horeg-drawer-heading {
452
+ display: flex;
453
+ align-items: center;
454
+ gap: 8px;
455
+ font-size: 11px;
456
+ font-weight: 700;
457
+ letter-spacing: 0.8px;
458
+ color: var(--horeg-text-muted);
459
+ text-transform: uppercase;
460
+ font-family: ui-monospace, monospace;
461
+ }
462
+
463
+ .horeg-drawer-count {
464
+ padding: 1px 6px;
465
+ background: #27272a;
466
+ color: var(--horeg-glow);
467
+ border-radius: 10px;
468
+ font-size: 10px;
469
+ font-weight: 700;
470
+ }
471
+
472
+ .horeg-btn-add-track {
473
+ display: inline-flex;
474
+ align-items: center;
475
+ gap: 5px;
476
+ padding: 4px 9px;
477
+ font-size: 11px;
478
+ font-weight: 600;
479
+ color: var(--horeg-text-main);
480
+ background: #1f1f23;
481
+ border: 1px solid #3f3f46;
482
+ border-radius: 5px;
483
+ cursor: pointer;
484
+ transition: all 0.15s ease;
485
+ }
486
+
487
+ .horeg-btn-add-track:hover {
488
+ background: #27272a;
489
+ border-color: var(--horeg-glow);
490
+ color: var(--horeg-glow);
491
+ box-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
492
+ }
493
+
494
+ .horeg-btn-add-track.active {
495
+ background: #27272a;
496
+ border-color: var(--horeg-glow);
497
+ color: var(--horeg-glow);
498
+ box-shadow: 0 0 12px var(--horeg-glow);
499
+ text-shadow: 0 0 6px var(--horeg-glow);
500
+ }
501
+
502
+ .horeg-btn-add-track:active {
503
+ transform: scale(0.95);
504
+ }
505
+
506
+ /* Add Track Panel Form */
507
+ .horeg-add-panel {
508
+ display: none;
509
+ flex-direction: column;
510
+ gap: 10px;
511
+ margin: 10px 12px;
512
+ padding: 12px;
513
+ background: #18181b;
514
+ border: 1px solid #3f3f46;
515
+ border-radius: 8px;
516
+ box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
517
+ animation: fadeIn 0.2s ease;
518
+ }
519
+
520
+ .horeg-add-panel.open {
521
+ display: flex;
522
+ }
523
+
524
+ .horeg-add-tabs {
525
+ display: flex;
526
+ gap: 6px;
527
+ border-bottom: 1px solid #27272a;
528
+ padding-bottom: 8px;
529
+ }
530
+
531
+ .horeg-tab-btn {
532
+ flex: 1;
533
+ display: flex;
534
+ align-items: center;
535
+ justify-content: center;
536
+ gap: 6px;
537
+ padding: 6px 10px;
538
+ font-size: 11px;
539
+ font-weight: 600;
540
+ background: #202024;
541
+ color: var(--horeg-text-muted);
542
+ border: 1px solid #2e2e33;
543
+ border-radius: 5px;
544
+ cursor: pointer;
545
+ transition: all 0.15s ease;
546
+ }
547
+
548
+ .horeg-tab-btn:hover {
549
+ color: var(--horeg-text-main);
550
+ border-color: #52525b;
551
+ }
552
+
553
+ .horeg-tab-btn.active {
554
+ background: #27272a;
555
+ color: var(--horeg-glow);
556
+ border-color: var(--horeg-glow);
557
+ box-shadow: 0 0 10px var(--horeg-glow);
558
+ text-shadow: 0 0 6px var(--horeg-glow);
559
+ }
560
+
561
+ .horeg-tab-btn:active {
562
+ transform: scale(0.97);
563
+ }
564
+
565
+ .horeg-tab-pane {
566
+ display: none;
567
+ flex-direction: column;
568
+ gap: 8px;
569
+ }
570
+
571
+ .horeg-tab-pane.active {
572
+ display: flex;
573
+ }
574
+
575
+ /* Dropzone for local file */
576
+ .horeg-dropzone {
577
+ display: flex;
578
+ flex-direction: column;
579
+ align-items: center;
580
+ justify-content: center;
581
+ gap: 6px;
582
+ padding: 16px 10px;
583
+ border: 2px dashed #3f3f46;
584
+ border-radius: 6px;
585
+ background: #141416;
586
+ cursor: pointer;
587
+ transition: all 0.2s ease;
588
+ text-align: center;
589
+ }
590
+
591
+ .horeg-dropzone:hover,
592
+ .horeg-dropzone.drag-active {
593
+ border-color: var(--horeg-glow);
594
+ background: rgba(245, 158, 11, 0.05);
595
+ box-shadow: 0 0 10px rgba(245, 158, 11, 0.15);
596
+ }
597
+
598
+ .horeg-dropzone-icon {
599
+ color: var(--horeg-glow);
600
+ display: flex;
601
+ align-items: center;
602
+ justify-content: center;
603
+ }
604
+
605
+ .horeg-dropzone-text {
606
+ font-size: 11px;
607
+ font-weight: 600;
608
+ color: var(--horeg-text-main);
609
+ }
610
+
611
+ .horeg-dropzone-hint {
612
+ font-size: 10px;
613
+ color: var(--horeg-text-muted);
614
+ }
615
+
616
+ /* Inputs for URL / Meta */
617
+ .horeg-input-field {
618
+ width: 100%;
619
+ box-sizing: border-box;
620
+ padding: 7px 10px;
621
+ font-size: 12px;
622
+ background: #121214;
623
+ border: 1px solid #3f3f46;
624
+ border-radius: 5px;
625
+ color: var(--horeg-text-main);
626
+ outline: none;
627
+ transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
628
+ }
629
+
630
+ .horeg-input-field:focus {
631
+ border-color: var(--horeg-glow);
632
+ background: #18181b;
633
+ box-shadow: 0 0 0 1px var(--horeg-glow), 0 0 10px var(--horeg-glow);
634
+ outline: none;
635
+ }
636
+
637
+ .horeg-input-field::placeholder {
638
+ color: #71717a;
639
+ font-size: 11px;
640
+ }
641
+
642
+ .horeg-form-actions {
643
+ display: flex;
644
+ align-items: center;
645
+ justify-content: flex-end;
646
+ gap: 6px;
647
+ margin-top: 4px;
648
+ }
649
+
650
+ .horeg-btn-submit {
651
+ display: inline-flex;
652
+ align-items: center;
653
+ gap: 5px;
654
+ padding: 6px 12px;
655
+ font-size: 11px;
656
+ font-weight: 700;
657
+ background: var(--horeg-glow);
658
+ color: #09090b;
659
+ border: none;
660
+ border-radius: 5px;
661
+ cursor: pointer;
662
+ transition: opacity 0.15s ease, transform 0.1s ease;
663
+ }
664
+
665
+ .horeg-btn-submit:hover {
666
+ opacity: 0.9;
667
+ transform: translateY(-1px);
668
+ }
669
+
670
+ .horeg-btn-submit:active {
671
+ transform: scale(0.96);
672
+ filter: brightness(1.15);
673
+ }
674
+
675
+ .horeg-btn-cancel {
676
+ padding: 6px 10px;
677
+ font-size: 11px;
678
+ font-weight: 600;
679
+ background: transparent;
680
+ color: var(--horeg-text-muted);
681
+ border: 1px solid transparent;
682
+ border-radius: 5px;
683
+ cursor: pointer;
684
+ transition: color 0.15s ease, transform 0.1s ease;
685
+ }
686
+
687
+ .horeg-btn-cancel:hover {
688
+ color: var(--horeg-text-main);
689
+ }
690
+
691
+ .horeg-btn-cancel:active {
692
+ transform: scale(0.96);
693
+ }
694
+
695
+ .horeg-drawer-inner {
696
+ padding: 6px 10px 10px 10px;
697
+ display: flex;
698
+ flex-direction: column;
699
+ gap: 4px;
700
+ }
701
+
702
+ .horeg-track-item {
703
+ display: flex;
704
+ align-items: center;
705
+ gap: 10px;
706
+ padding: 8px 10px;
707
+ border-radius: 6px;
708
+ cursor: pointer;
709
+ transition: background 0.15s ease;
710
+ font-size: 13px;
711
+ }
712
+
713
+ .horeg-track-item:hover {
714
+ background: #1f1f23;
715
+ }
716
+
717
+ .horeg-track-item.active {
718
+ background: linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
719
+ color: var(--horeg-glow);
720
+ border-left: 3px solid var(--horeg-glow);
721
+ box-shadow: inset 3px 0 6px -2px var(--horeg-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
722
+ position: relative;
723
+ }
724
+
725
+ .horeg-track-item.active .horeg-track-num {
726
+ color: var(--horeg-glow);
727
+ font-weight: 700;
728
+ text-shadow: 0 0 8px var(--horeg-glow);
729
+ }
730
+
731
+ .horeg-track-item.active .horeg-item-title {
732
+ color: var(--horeg-glow);
733
+ font-weight: 700;
734
+ text-shadow: 0 0 8px var(--horeg-glow);
735
+ }
736
+
737
+ .horeg-track-item.active .horeg-item-artist {
738
+ color: var(--horeg-text-main);
739
+ opacity: 0.9;
740
+ }
741
+
742
+ .horeg-track-item.active .horeg-item-duration {
743
+ color: var(--horeg-glow);
744
+ opacity: 0.9;
745
+ }
746
+
747
+ .horeg-track-item:focus-visible {
748
+ outline: 2px solid var(--horeg-glow);
749
+ outline-offset: -1px;
750
+ }
751
+
752
+ .horeg-track-num {
753
+ font-family: ui-monospace, monospace;
754
+ font-size: 11px;
755
+ color: var(--horeg-text-muted);
756
+ width: 18px;
757
+ }
758
+
759
+ .horeg-track-details {
760
+ flex: 1;
761
+ min-width: 0;
762
+ }
763
+
764
+ .horeg-item-title {
765
+ font-weight: 600;
766
+ white-space: nowrap;
767
+ overflow: hidden;
768
+ text-overflow: ellipsis;
769
+ }
770
+
771
+ .horeg-item-artist {
772
+ font-size: 11px;
773
+ color: var(--horeg-text-muted);
774
+ white-space: nowrap;
775
+ overflow: hidden;
776
+ text-overflow: ellipsis;
777
+ }
778
+
779
+ .horeg-item-duration {
780
+ font-family: ui-monospace, monospace;
781
+ font-size: 11px;
782
+ color: var(--horeg-text-muted);
783
+ margin-right: 4px;
784
+ }
785
+
786
+ /* Track Item Actions (Remove button) */
787
+ .horeg-track-actions {
788
+ display: flex;
789
+ align-items: center;
790
+ opacity: 0.5;
791
+ transition: opacity 0.15s ease;
792
+ }
793
+
794
+ .horeg-track-item:hover .horeg-track-actions {
795
+ opacity: 1;
796
+ }
797
+
798
+ .horeg-btn-remove {
799
+ background: transparent;
800
+ border: none;
801
+ color: var(--horeg-text-muted);
802
+ cursor: pointer;
803
+ padding: 4px;
804
+ border-radius: 4px;
805
+ display: flex;
806
+ align-items: center;
807
+ justify-content: center;
808
+ transition: all 0.15s ease;
809
+ }
810
+
811
+ .horeg-btn-remove:hover {
812
+ color: #ef4444;
813
+ background: rgba(239, 68, 68, 0.15);
814
+ }
815
+
816
+ .horeg-empty-playlist {
817
+ padding: 24px 12px;
818
+ text-align: center;
819
+ color: var(--horeg-text-muted);
820
+ font-size: 12px;
821
+ font-style: italic;
822
+ }
823
+ `}function b(l){if(isNaN(l)||!isFinite(l)||l<0)return"00:00";const e=Math.floor(l),i=Math.floor(e/3600),t=Math.floor(e%3600/60),a=e%60,s=n=>n.toString().padStart(2,"0");return i>0?`${i}:${s(t)}:${s(a)}`:`${s(t)}:${s(a)}`}function u(l,e,i){return Math.min(Math.max(l,e),i)}class I{constructor(e,i={}){r(this,"audio");r(this,"playlist",[]);r(this,"currentIndex",0);r(this,"loopMode","all");r(this,"shuffleMode",!1);r(this,"volumeLevel",.8);r(this,"previousVolume",.8);r(this,"callbacks",{});r(this,"handlePlay",()=>{const e=this.getCurrentTrack();e&&this.callbacks.onPlay&&this.callbacks.onPlay(e)});r(this,"handlePause",()=>{this.callbacks.onPause&&this.callbacks.onPause()});r(this,"handleTimeUpdate",()=>{const e=this.audio.currentTime||0,i=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(e,i)});r(this,"handleProgress",()=>{if(this.audio.buffered.length>0&&this.audio.duration>0){const e=this.audio.buffered.end(this.audio.buffered.length-1),i=u(e/this.audio.duration*100,0,100);this.callbacks.onBufferUpdate&&this.callbacks.onBufferUpdate(i)}});r(this,"handleLoadedMetadata",()=>{const e=this.audio.currentTime||0,i=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(e,i),this.handleProgress()});r(this,"handleWaiting",()=>{this.callbacks.onLoadingChange&&this.callbacks.onLoadingChange(!0)});r(this,"handlePlaying",()=>{this.callbacks.onLoadingChange&&this.callbacks.onLoadingChange(!1)});r(this,"handleEnded",()=>{const e=this.getCurrentTrack();e&&this.callbacks.onEnded&&this.callbacks.onEnded(e),this.loopMode==="one"?(this.audio.currentTime=0,this.play()):this.next(!0)});r(this,"handleError",()=>{const e=this.audio.error||new Error("Unknown audio playback error");this.callbacks.onError&&this.callbacks.onError(e)});this.audio=new Audio,this.playlist=[...e.playlist||[]],this.currentIndex=e.initialIndex!==void 0?u(e.initialIndex,0,Math.max(0,this.playlist.length-1)):0,this.loopMode=e.loop||"all",this.shuffleMode=!!e.shuffle,this.volumeLevel=e.volume!==void 0?u(e.volume,0,1):.8,this.callbacks=i||{onPlay:e.onPlay,onPause:e.onPause,onTrackChange:e.onTrackChange,onPlaylistChange:e.onPlaylistChange,onTimeUpdate:e.onTimeUpdate,onEnded:e.onEnded,onError:e.onError},this.audio.volume=this.volumeLevel,this.attachEvents(),this.playlist.length>0&&this.loadTrack(this.currentIndex,!!e.autoplay)}attachEvents(){this.audio.addEventListener("play",this.handlePlay),this.audio.addEventListener("pause",this.handlePause),this.audio.addEventListener("timeupdate",this.handleTimeUpdate),this.audio.addEventListener("progress",this.handleProgress),this.audio.addEventListener("ended",this.handleEnded),this.audio.addEventListener("error",this.handleError),this.audio.addEventListener("waiting",this.handleWaiting),this.audio.addEventListener("playing",this.handlePlaying),this.audio.addEventListener("loadedmetadata",this.handleLoadedMetadata)}detachEvents(){this.audio.removeEventListener("play",this.handlePlay),this.audio.removeEventListener("pause",this.handlePause),this.audio.removeEventListener("timeupdate",this.handleTimeUpdate),this.audio.removeEventListener("progress",this.handleProgress),this.audio.removeEventListener("ended",this.handleEnded),this.audio.removeEventListener("error",this.handleError),this.audio.removeEventListener("waiting",this.handleWaiting),this.audio.removeEventListener("playing",this.handlePlaying),this.audio.removeEventListener("loadedmetadata",this.handleLoadedMetadata)}getCurrentTrack(){return this.playlist[this.currentIndex]}getCurrentIndex(){return this.currentIndex}getPlaylist(){return this.playlist}setPlaylist(e,i=0){this.playlist=[...e],this.currentIndex=u(i,0,Math.max(0,this.playlist.length-1)),this.loadTrack(this.currentIndex,!1),this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex),this.playlist.length>0?this.loadTrack(this.currentIndex,!1):(this.audio.pause(),this.audio.src="",this.callbacks.onTrackChange&&this.callbacks.onTrackChange({title:"No Track Loaded",src:""},0))}addTrack(e,i=!1){const t=this.playlist.length===0;this.playlist.push(e);const a=this.playlist.length-1;return this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex),t?this.loadTrack(0,i):i&&this.loadTrack(a,!0),a}addTracks(e,i=!1){if(!e||e.length===0)return;const t=this.playlist.length===0,a=this.playlist.length;this.playlist.push(...e),this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex),t?this.loadTrack(0,i):i&&this.loadTrack(a,!0)}removeTrack(e){if(e<0||e>=this.playlist.length)return;const i=e===this.currentIndex;if(this.playlist.splice(e,1),this.playlist.length===0)this.currentIndex=0,this.audio.pause(),this.audio.src="",this.callbacks.onTrackChange&&this.callbacks.onTrackChange({title:"No Track Loaded",src:""},0);else if(i){const t=u(e,0,this.playlist.length-1);this.loadTrack(t,!1)}else e<this.currentIndex&&this.currentIndex--;this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex)}getDuration(){const e=this.audio.duration;if(e&&!isNaN(e)&&isFinite(e))return e;const i=this.getCurrentTrack();return(i==null?void 0:i.duration)||0}getCurrentTime(){return this.audio.currentTime||0}isPlaying(){return!this.audio.paused&&!this.audio.ended}isMuted(){return this.audio.muted||this.audio.volume===0}getVolume(){return this.audio.volume}getLoop(){return this.loopMode}isShuffle(){return this.shuffleMode}loadTrack(e,i=!1){let t;typeof e=="number"?t=u(e,0,Math.max(0,this.playlist.length-1)):(t=this.playlist.findIndex(s=>s.src===e.src),t===-1&&(this.playlist.push(e),t=this.playlist.length-1)),this.currentIndex=t;const a=this.playlist[this.currentIndex];a&&(this.audio.src=a.src,this.callbacks.onTrackChange&&this.callbacks.onTrackChange(a,this.currentIndex),i&&this.play())}async play(){try{await this.audio.play()}catch(e){console.warn("[HoregAudio] Autoplay / Audio play was prevented by browser policy:",e)}}pause(){this.audio.pause()}toggle(){this.audio.paused?this.play():this.pause()}seek(e){const i=this.getDuration(),t=u(e,0,i>0?i:1/0);this.audio.currentTime=t}setVolume(e){const i=u(e,0,1);this.volumeLevel=i,this.audio.volume=i,i>0&&(this.audio.muted=!1,this.previousVolume=i)}toggleMute(){return this.isMuted()?(this.audio.muted=!1,this.setVolume(this.previousVolume>0?this.previousVolume:.5),!1):(this.previousVolume=this.audio.volume,this.audio.muted=!0,!0)}next(e=!1){if(this.playlist.length===0)return;if(this.shuffleMode&&this.playlist.length>1){let t;do t=Math.floor(Math.random()*this.playlist.length);while(t===this.currentIndex);this.loadTrack(t,!0);return}const i=this.currentIndex+1;i<this.playlist.length?this.loadTrack(i,!0):this.loopMode==="all"?this.loadTrack(0,!0):e?this.pause():this.loadTrack(0,!0)}prev(){if(this.playlist.length===0)return;if(this.audio.currentTime>2){this.seek(0);return}if(this.shuffleMode&&this.playlist.length>1){let i;do i=Math.floor(Math.random()*this.playlist.length);while(i===this.currentIndex);this.loadTrack(i,!0);return}const e=this.currentIndex-1;e>=0?this.loadTrack(e,!0):this.loopMode==="all"?this.loadTrack(this.playlist.length-1,!0):this.seek(0)}setLoop(e){this.loopMode=e}setShuffle(e){this.shuffleMode=e}setCallbacks(e){this.callbacks={...this.callbacks,...e}}destroy(){this.detachEvents(),this.audio.pause(),this.audio.src="",this.audio.load()}}const d={play:'<svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20"><path d="M8 5v14l11-7z"/></svg>',pause:'<svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20"><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/></svg>',prev:'<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M6 6h2v12H6zm3.5 6l8.5 6V6z"/></svg>',next:'<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/></svg>',volumeHigh:'<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>',volumeMute:'<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27l4.73 4.73H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></svg>',shuffle:'<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z"/></svg>',repeat:'<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"/></svg>',repeatOne:'<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4zm-4-2V9h-1l-2 1v1h1.5v4H13z"/></svg>',playlist:'<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M3 10h11v2H3zm0-4h11v2H3zm0 8h7v2H3zm13-1v8l6-4-6-4z"/></svg>',speaker:'<svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M17 2H7c-1.1 0-2 .9-2 2v16c0 1.1.9 1.99 2 1.99L17 22c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm0 16c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>',plus:'<svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',trash:'<svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>',upload:'<svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"/></svg>',link:'<svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>'};function o(l,e){const i=document.createElement(l);if(e!=null&&e.className&&(i.className=e.className),e!=null&&e.attributes)for(const[t,a]of Object.entries(e.attributes))i.setAttribute(t,a);return e!=null&&e.innerHTML?i.innerHTML=e.innerHTML:e!=null&&e.textContent&&(i.textContent=e.textContent),i}class z{constructor(e){r(this,"root");r(this,"eqContainer");r(this,"playBtn");r(this,"prevBtn");r(this,"nextBtn");r(this,"shuffleBtn");r(this,"loopBtn");r(this,"muteBtn");r(this,"drawerBtn");r(this,"titleEl");r(this,"artistEl");r(this,"albumEl");r(this,"coverImgEl",null);r(this,"coverContainer");r(this,"currentTimeEl");r(this,"durationEl");r(this,"sliderTrack");r(this,"fillBar");r(this,"bufferBar");r(this,"volumeSlider");r(this,"drawerEl");r(this,"drawerCountEl");r(this,"addTrackBtn");r(this,"addPanelEl");r(this,"fileInputEl");r(this,"tabBtnFile");r(this,"tabBtnUrl");r(this,"tabPaneFile");r(this,"tabPaneUrl");r(this,"urlInput");r(this,"titleInput");r(this,"artistInput");r(this,"submitUrlBtn");r(this,"cancelAddBtn");r(this,"dropzoneEl");r(this,"drawerInner");r(this,"isScrubbing",!1);r(this,"currentDuration",0);r(this,"events");r(this,"startScrubbing",e=>{e.preventDefault(),this.isScrubbing=!0,this.handleScrubbingMove(e);const i=a=>{this.isScrubbing&&this.handleScrubbingMove(a)},t=a=>{this.isScrubbing&&(this.isScrubbing=!1,this.finishScrubbing(a),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",t),window.removeEventListener("touchmove",i),window.removeEventListener("touchend",t))};window.addEventListener("mousemove",i),window.addEventListener("mouseup",t),window.addEventListener("touchmove",i,{passive:!1}),window.addEventListener("touchend",t)});this.events=e,this.root=o("div",{className:"horeg-player-box"});const i=o("div",{className:"horeg-speaker-grill"});this.root.appendChild(i),["top-left","top-right","bottom-left","bottom-right"].forEach(P=>{this.root.appendChild(o("div",{className:`horeg-bolt ${P}`}))});const t=o("div",{className:"horeg-content-wrap"});this.root.appendChild(t);const a=o("div",{className:"horeg-header"}),s=o("div",{className:"horeg-rig-badge",innerHTML:'<span class="horeg-badge-led"></span> HOREG RIG • HIGH VOLTAGE'});a.appendChild(s),t.appendChild(a);const n=o("div",{className:"horeg-track-row"});this.coverContainer=o("div",{className:"horeg-cover-container"}),this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${d.speaker}</span>`,n.appendChild(this.coverContainer);const c=o("div",{className:"horeg-track-info"});this.titleEl=o("div",{className:"horeg-track-title",textContent:"No Track Loaded"}),this.artistEl=o("div",{className:"horeg-track-artist",textContent:"Unknown Artist"}),this.albumEl=o("div",{className:"horeg-track-album",textContent:""}),c.appendChild(this.titleEl),c.appendChild(this.artistEl),c.appendChild(this.albumEl),n.appendChild(c),this.eqContainer=o("div",{className:"horeg-eq-wrapper"}),n.appendChild(this.eqContainer),t.appendChild(n);const h=o("div",{className:"horeg-progress-container"}),g=o("div",{className:"horeg-time-row"});this.currentTimeEl=o("span",{textContent:"00:00"}),this.durationEl=o("span",{textContent:"00:00"}),g.appendChild(this.currentTimeEl),g.appendChild(this.durationEl),h.appendChild(g),this.sliderTrack=o("div",{className:"horeg-slider-track",attributes:{role:"slider","aria-label":"Seek progress","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":"0",tabindex:"0"}}),this.bufferBar=o("div",{className:"horeg-buffer-bar"}),this.fillBar=o("div",{className:"horeg-fill-bar"}),this.sliderTrack.appendChild(this.bufferBar),this.sliderTrack.appendChild(this.fillBar),h.appendChild(this.sliderTrack),t.appendChild(h);const p=o("div",{className:"horeg-controls-row"}),f=o("div",{className:"horeg-side-controls"});this.shuffleBtn=o("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle shuffle",type:"button"},innerHTML:d.shuffle}),this.loopBtn=o("button",{className:"horeg-btn active",attributes:{"aria-label":"Toggle loop mode",type:"button"},innerHTML:d.repeat}),f.appendChild(this.shuffleBtn),f.appendChild(this.loopBtn),p.appendChild(f);const v=o("div",{className:"horeg-center-controls"});this.prevBtn=o("button",{className:"horeg-btn",attributes:{"aria-label":"Previous track",type:"button"},innerHTML:d.prev}),this.playBtn=o("button",{className:"horeg-btn horeg-btn-play",attributes:{"aria-label":"Play track",type:"button"},innerHTML:d.play}),this.nextBtn=o("button",{className:"horeg-btn",attributes:{"aria-label":"Next track",type:"button"},innerHTML:d.next}),v.appendChild(this.prevBtn),v.appendChild(this.playBtn),v.appendChild(this.nextBtn),p.appendChild(v);const m=o("div",{className:"horeg-side-controls"}),x=o("div",{className:"horeg-volume-wrap"});this.muteBtn=o("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle mute",type:"button"},innerHTML:d.volumeHigh}),this.volumeSlider=o("input",{className:"horeg-volume-slider",attributes:{type:"range",min:"0",max:"1",step:"0.01",value:"0.8","aria-label":"Volume control"}}),x.appendChild(this.muteBtn),x.appendChild(this.volumeSlider),m.appendChild(x),this.drawerBtn=o("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle playlist drawer",type:"button"},innerHTML:d.playlist}),m.appendChild(this.drawerBtn),p.appendChild(m),t.appendChild(p),this.drawerEl=o("div",{className:"horeg-drawer"});const w=o("div",{className:"horeg-drawer-header"}),y=o("div",{className:"horeg-drawer-heading"});y.innerHTML="<span>PLAYLIST</span>",this.drawerCountEl=o("span",{className:"horeg-drawer-count",textContent:"0"}),y.appendChild(this.drawerCountEl),w.appendChild(y),this.addTrackBtn=o("button",{className:"horeg-btn-add-track",attributes:{type:"button","aria-label":"Add track to playlist"},innerHTML:`${d.plus} <span>Add Track</span>`}),w.appendChild(this.addTrackBtn),this.drawerEl.appendChild(w),this.addPanelEl=o("div",{className:"horeg-add-panel"});const k=o("div",{className:"horeg-add-tabs"});this.tabBtnFile=o("button",{className:"horeg-tab-btn active",attributes:{type:"button"},innerHTML:`${d.upload} <span>File Lokal</span>`}),this.tabBtnUrl=o("button",{className:"horeg-tab-btn",attributes:{type:"button"},innerHTML:`${d.link} <span>Audio URL</span>`}),k.appendChild(this.tabBtnFile),k.appendChild(this.tabBtnUrl),this.addPanelEl.appendChild(k),this.tabPaneFile=o("div",{className:"horeg-tab-pane active"}),this.fileInputEl=o("input",{attributes:{type:"file",accept:"audio/*",multiple:"true",style:"display: none;"}}),this.dropzoneEl=o("div",{className:"horeg-dropzone"}),this.dropzoneEl.innerHTML=`
824
+ <div class="horeg-dropzone-icon">${d.upload}</div>
825
+ <div class="horeg-dropzone-text">Pilih File Audio Komputer</div>
826
+ <div class="horeg-dropzone-hint">Klik di sini atau drag & drop file (.mp3, .wav, .flac, .ogg, .m4a)</div>
827
+ `,this.tabPaneFile.appendChild(this.fileInputEl),this.tabPaneFile.appendChild(this.dropzoneEl),this.addPanelEl.appendChild(this.tabPaneFile),this.tabPaneUrl=o("div",{className:"horeg-tab-pane"}),this.urlInput=o("input",{className:"horeg-input-field",attributes:{type:"url",placeholder:"Audio URL (https://...mp3/wav)",required:"true"}}),this.titleInput=o("input",{className:"horeg-input-field",attributes:{type:"text",placeholder:"Judul Lagu (Opsional)"}}),this.artistInput=o("input",{className:"horeg-input-field",attributes:{type:"text",placeholder:"Nama Artis (Opsional)"}});const E=o("div",{className:"horeg-form-actions"});this.cancelAddBtn=o("button",{className:"horeg-btn-cancel",attributes:{type:"button"},textContent:"Batal"}),this.submitUrlBtn=o("button",{className:"horeg-btn-submit",attributes:{type:"button"},innerHTML:`${d.plus} Tambah`}),E.appendChild(this.cancelAddBtn),E.appendChild(this.submitUrlBtn),this.tabPaneUrl.appendChild(this.urlInput),this.tabPaneUrl.appendChild(this.titleInput),this.tabPaneUrl.appendChild(this.artistInput),this.tabPaneUrl.appendChild(E),this.addPanelEl.appendChild(this.tabPaneUrl),this.drawerEl.appendChild(this.addPanelEl),this.drawerInner=o("div",{className:"horeg-drawer-inner"}),this.drawerEl.appendChild(this.drawerInner),this.root.appendChild(this.drawerEl),this.bindDOMEvents()}bindDOMEvents(){this.playBtn.addEventListener("click",()=>this.events.onPlayPauseClick()),this.prevBtn.addEventListener("click",()=>this.events.onPrevClick()),this.nextBtn.addEventListener("click",()=>this.events.onNextClick()),this.shuffleBtn.addEventListener("click",()=>this.events.onShuffleToggle()),this.loopBtn.addEventListener("click",()=>this.events.onLoopToggle()),this.muteBtn.addEventListener("click",()=>this.events.onMuteToggle()),this.volumeSlider.addEventListener("input",()=>{this.events.onVolumeChange(parseFloat(this.volumeSlider.value))}),this.drawerBtn.addEventListener("click",()=>{this.toggleDrawer()}),this.addTrackBtn.addEventListener("click",()=>{const t=this.addPanelEl.classList.toggle("open");this.addTrackBtn.classList.toggle("active",t),t&&this.toggleDrawer(!0)}),this.tabBtnFile.addEventListener("click",()=>{this.tabBtnFile.classList.add("active"),this.tabBtnUrl.classList.remove("active"),this.tabPaneFile.classList.add("active"),this.tabPaneUrl.classList.remove("active")}),this.tabBtnUrl.addEventListener("click",()=>{this.tabBtnUrl.classList.add("active"),this.tabBtnFile.classList.remove("active"),this.tabPaneUrl.classList.add("active"),this.tabPaneFile.classList.remove("active"),this.urlInput.focus()}),this.dropzoneEl.addEventListener("click",()=>{this.fileInputEl.click()}),this.fileInputEl.addEventListener("change",()=>{if(this.fileInputEl.files&&this.fileInputEl.files.length>0){const t=Array.from(this.fileInputEl.files);this.events.onAddTrackFiles&&this.events.onAddTrackFiles(t),this.fileInputEl.value="",this.closeAddPanel()}}),this.dropzoneEl.addEventListener("dragover",t=>{t.preventDefault(),this.dropzoneEl.classList.add("drag-active")}),this.dropzoneEl.addEventListener("dragleave",()=>{this.dropzoneEl.classList.remove("drag-active")}),this.dropzoneEl.addEventListener("drop",t=>{var a;if(t.preventDefault(),this.dropzoneEl.classList.remove("drag-active"),(a=t.dataTransfer)!=null&&a.files&&t.dataTransfer.files.length>0){const s=Array.from(t.dataTransfer.files).filter(n=>n.type.startsWith("audio/")||/\.(mp3|wav|ogg|flac|m4a|aac)$/i.test(n.name));s.length>0&&this.events.onAddTrackFiles&&(this.events.onAddTrackFiles(s),this.closeAddPanel())}}),this.root.addEventListener("dragover",t=>{t.preventDefault(),this.root.classList.add("drag-over")}),this.root.addEventListener("dragleave",t=>{this.root.contains(t.relatedTarget)||this.root.classList.remove("drag-over")}),this.root.addEventListener("drop",t=>{var a;if(t.preventDefault(),this.root.classList.remove("drag-over"),(a=t.dataTransfer)!=null&&a.files&&t.dataTransfer.files.length>0){const s=Array.from(t.dataTransfer.files).filter(n=>n.type.startsWith("audio/")||/\.(mp3|wav|ogg|flac|m4a|aac)$/i.test(n.name));s.length>0&&this.events.onAddTrackFiles&&(this.events.onAddTrackFiles(s),this.closeAddPanel())}});const e=()=>{const t=this.urlInput.value.trim();if(!t){this.urlInput.focus();return}const a=this.titleInput.value.trim(),s=this.artistInput.value.trim();this.events.onAddTrackUrl&&this.events.onAddTrackUrl(t,a||void 0,s||void 0),this.urlInput.value="",this.titleInput.value="",this.artistInput.value="",this.closeAddPanel()};this.submitUrlBtn.addEventListener("click",e);const i=t=>{t.stopPropagation(),t.key==="Enter"&&(t.preventDefault(),e())};this.urlInput.addEventListener("keydown",i),this.titleInput.addEventListener("keydown",i),this.artistInput.addEventListener("keydown",i),this.cancelAddBtn.addEventListener("click",()=>{this.closeAddPanel()}),this.sliderTrack.addEventListener("mousedown",this.startScrubbing),this.sliderTrack.addEventListener("touchstart",this.startScrubbing,{passive:!1}),this.sliderTrack.addEventListener("keydown",t=>{if(this.currentDuration){if(t.key==="ArrowRight"||t.key==="ArrowUp"){t.preventDefault();const a=parseFloat(this.fillBar.style.width)/100*this.currentDuration;this.events.onSeek(Math.min(a+5,this.currentDuration))}else if(t.key==="ArrowLeft"||t.key==="ArrowDown"){t.preventDefault();const a=parseFloat(this.fillBar.style.width)/100*this.currentDuration;this.events.onSeek(Math.max(a-5,0))}}})}calculateProgressPercent(e){const i=this.sliderTrack.getBoundingClientRect(),t="touches"in e?(e.touches[0]||e.changedTouches[0]).clientX:e.clientX,a=u(t-i.left,0,i.width);return i.width>0?a/i.width*100:0}handleScrubbingMove(e){const i=this.calculateProgressPercent(e);if(this.fillBar.style.width=`${i}%`,this.currentDuration>0){const t=i/100*this.currentDuration;this.currentTimeEl.textContent=b(t)}}finishScrubbing(e){const i=this.calculateProgressPercent(e);if(this.currentDuration>0){const t=i/100*this.currentDuration;this.events.onSeek(t)}}updateTrackInfo(e){this.titleEl.textContent=e.title||"Untitled Track",this.artistEl.textContent=e.artist||"Unknown Artist",this.albumEl.textContent=e.album||"",e.coverArt?(this.coverContainer.innerHTML="",this.coverImgEl=o("img",{className:"horeg-cover-img",attributes:{src:e.coverArt,alt:`${e.title} cover`}}),this.coverImgEl.onerror=()=>{this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${d.speaker}</span>`},this.coverContainer.appendChild(this.coverImgEl)):this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${d.speaker}</span>`}updatePlayState(e){e?(this.playBtn.classList.add("playing"),this.playBtn.innerHTML=d.pause,this.playBtn.setAttribute("aria-label","Pause track")):(this.playBtn.classList.remove("playing"),this.playBtn.innerHTML=d.play,this.playBtn.setAttribute("aria-label","Play track"))}updateProgress(e,i){if(this.currentDuration=i,this.durationEl.textContent=b(i),!this.isScrubbing){this.currentTimeEl.textContent=b(e);const t=i>0?e/i*100:0;this.fillBar.style.width=`${u(t,0,100)}%`,this.sliderTrack.setAttribute("aria-valuenow",Math.round(t).toString())}}updateBuffer(e){this.bufferBar.style.width=`${u(e,0,100)}%`}updateVolume(e,i){this.volumeSlider.value=e.toString(),i||e===0?(this.muteBtn.innerHTML=d.volumeMute,this.muteBtn.setAttribute("aria-label","Unmute")):(this.muteBtn.innerHTML=d.volumeHigh,this.muteBtn.setAttribute("aria-label","Mute"))}updateLoopState(e){e==="none"?(this.loopBtn.classList.remove("active"),this.loopBtn.innerHTML=d.repeat):e==="all"?(this.loopBtn.classList.add("active"),this.loopBtn.innerHTML=d.repeat):e==="one"&&(this.loopBtn.classList.add("active"),this.loopBtn.innerHTML=d.repeatOne),this.loopBtn.setAttribute("aria-label",`Repeat mode: ${e}`)}updateShuffleState(e){e?this.shuffleBtn.classList.add("active"):this.shuffleBtn.classList.remove("active")}toggleDrawer(e){(e!==void 0?e:!this.drawerEl.classList.contains("open"))?(this.drawerEl.classList.add("open"),this.drawerBtn.classList.add("active")):(this.drawerEl.classList.remove("open"),this.drawerBtn.classList.remove("active"),this.closeAddPanel())}closeAddPanel(){this.addPanelEl.classList.remove("open"),this.addTrackBtn.classList.remove("active")}renderPlaylist(e,i){if(this.drawerCountEl.textContent=e.length.toString(),this.drawerInner.innerHTML="",e.length===0){const t=o("div",{className:"horeg-empty-playlist",textContent:'Playlist masih kosong. Klik "Add Track" untuk menambahkan lagu.'});this.drawerInner.appendChild(t);return}e.forEach((t,a)=>{const s=o("div",{className:`horeg-track-item ${a===i?"active":""}`}),n=o("div",{className:"horeg-track-num",textContent:(a+1).toString().padStart(2,"0")});s.appendChild(n);const c=o("div",{className:"horeg-track-details"}),h=o("div",{className:"horeg-item-title",textContent:t.title}),g=o("div",{className:"horeg-item-artist",textContent:t.artist||"Unknown Artist"});if(c.appendChild(h),c.appendChild(g),s.appendChild(c),t.duration){const v=o("div",{className:"horeg-item-duration",textContent:b(t.duration)});s.appendChild(v)}const p=o("div",{className:"horeg-track-actions"}),f=o("button",{className:"horeg-btn-remove",attributes:{type:"button","aria-label":"Hapus lagu dari playlist"},innerHTML:d.trash});f.addEventListener("click",v=>{v.stopPropagation(),this.events.onRemoveTrack&&this.events.onRemoveTrack(a)}),p.appendChild(f),s.appendChild(p),s.addEventListener("click",()=>{this.events.onTrackSelect(a)}),this.drawerInner.appendChild(s)})}destroy(){this.root.remove()}}class A{constructor(e){r(this,"container");r(this,"bars",[]);r(this,"isRunning",!1);r(this,"animFrameId",null);r(this,"isEnabled",!0);r(this,"baseHeights",[]);r(this,"loop",()=>{if(!this.isRunning)return;const e=Date.now()/150;for(let i=0;i<this.bars.length;i++){const t=Math.sin(e*1.8+i*1.2),a=Math.cos(e*2.5+i*.8),s=Math.abs(t*.6+a*.4),n=Math.floor(4+s*18);this.bars[i].style.height=`${n}px`}this.animFrameId=requestAnimationFrame(this.loop)});this.container=e.container,this.isEnabled=e.enableAnimation!==!1;const i=e.barCount||5;this.initBars(i)}initBars(e){this.container.innerHTML="",this.bars=[],this.baseHeights=[];for(let i=0;i<e;i++){const t=document.createElement("span");t.className="horeg-eq-bar",this.container.appendChild(t),this.bars.push(t),this.baseHeights.push(3+i%2*2),t.style.height=`${this.baseHeights[i]}px`}}setEnabled(e){this.isEnabled=e,e||this.stop()}start(){this.isRunning||!this.isEnabled||(this.isRunning=!0,this.loop())}stop(){this.isRunning=!1,this.animFrameId!==null&&(cancelAnimationFrame(this.animFrameId),this.animFrameId=null);for(let e=0;e<this.bars.length;e++)this.bars[e].style.height=`${this.baseHeights[e]||3}px`}destroy(){this.stop(),this.bars=[],this.container.innerHTML=""}}class L{constructor(e){r(this,"container");r(this,"shadow");r(this,"styleEl");r(this,"audioEngine");r(this,"ui");r(this,"visualizer");r(this,"theme");r(this,"boundKeyHandler");if(typeof e.container=="string"){const t=document.querySelector(e.container);if(!t)throw new Error(`[HoregAudio] Container "${e.container}" not found in DOM.`);this.container=t}else if(e.container instanceof HTMLElement)this.container=e.container;else throw new Error("[HoregAudio] Invalid container option provided.");this.theme=e.theme||{variant:"horeg-classic"},this.shadow=this.container.attachShadow({mode:"open"}),this.styleEl=document.createElement("style"),this.styleEl.textContent=T(this.theme),this.shadow.appendChild(this.styleEl),this.ui=new z({onPlayPauseClick:()=>this.toggle(),onPrevClick:()=>this.prev(),onNextClick:()=>this.next(),onSeek:t=>this.seek(t),onVolumeChange:t=>this.setVolume(t),onMuteToggle:()=>{const t=this.audioEngine.toggleMute();this.ui.updateVolume(this.audioEngine.getVolume(),t)},onShuffleToggle:()=>{const t=!this.audioEngine.isShuffle();this.audioEngine.setShuffle(t),this.ui.updateShuffleState(t)},onLoopToggle:()=>{const t=this.audioEngine.getLoop(),a=t==="all"?"one":t==="one"?"none":"all";this.audioEngine.setLoop(a),this.ui.updateLoopState(a)},onTrackSelect:t=>{this.loadTrack(t,!0)},onAddTrackFiles:t=>{this.addTrackFromFiles(t,!1)},onAddTrackUrl:(t,a,s)=>{this.addTrackFromUrl(t,{title:a,artist:s},!1)},onRemoveTrack:t=>{this.removeTrack(t)}}),this.shadow.appendChild(this.ui.root),this.visualizer=new A({container:this.ui.eqContainer,enableAnimation:this.theme.enableEqAnimation!==!1}),this.audioEngine=new I(e,{onPlay:t=>{this.ui.updatePlayState(!0),this.visualizer.start(),e.onPlay&&e.onPlay(t)},onPause:()=>{this.ui.updatePlayState(!1),this.visualizer.stop(),e.onPause&&e.onPause()},onTrackChange:(t,a)=>{this.ui.updateTrackInfo(t);const s=this.audioEngine?this.audioEngine.getPlaylist():e.playlist||[];this.ui.renderPlaylist(s,a),this.ui.updateProgress(0,t.duration||0),e.onTrackChange&&e.onTrackChange(t,a)},onPlaylistChange:(t,a)=>{this.ui.renderPlaylist(t,a),e.onPlaylistChange&&e.onPlaylistChange(t,a)},onTimeUpdate:(t,a)=>{this.ui.updateProgress(t,a),e.onTimeUpdate&&e.onTimeUpdate(t,a)},onBufferUpdate:t=>{this.ui.updateBuffer(t)},onEnded:t=>{this.visualizer.stop(),e.onEnded&&e.onEnded(t)},onError:t=>{this.ui.updatePlayState(!1),this.visualizer.stop(),e.onError&&e.onError(t)}}),this.ui.updateVolume(this.audioEngine.getVolume(),this.audioEngine.isMuted()),this.ui.updateLoopState(this.audioEngine.getLoop()),this.ui.updateShuffleState(this.audioEngine.isShuffle()),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex());const i=this.audioEngine.getCurrentTrack();i&&(this.ui.updateTrackInfo(i),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex())),this.boundKeyHandler=this.handleKeyDown.bind(this),this.container.tabIndex=this.container.tabIndex>=0?this.container.tabIndex:0,this.container.addEventListener("keydown",this.boundKeyHandler)}handleKeyDown(e){var n;const i=e.composedPath?e.composedPath():[],t=i.length>0?i[0]:e.target,a=((n=this.shadow)==null?void 0:n.activeElement)||document.activeElement,s=c=>{if(!c)return!1;const h=c.tagName;return h==="INPUT"||h==="TEXTAREA"||h==="SELECT"||c.isContentEditable};if(!(s(t)||s(a)))if(e.code==="Space"){if((t==null?void 0:t.tagName)==="BUTTON"||(a==null?void 0:a.tagName)==="BUTTON")return;e.preventDefault(),this.toggle()}else e.key==="ArrowRight"&&!e.shiftKey?(e.preventDefault(),this.seek(this.audioEngine.getCurrentTime()+5)):e.key==="ArrowLeft"&&!e.shiftKey?(e.preventDefault(),this.seek(this.audioEngine.getCurrentTime()-5)):e.key==="ArrowUp"?(e.preventDefault(),this.setVolume(this.audioEngine.getVolume()+.05)):e.key==="ArrowDown"&&(e.preventDefault(),this.setVolume(this.audioEngine.getVolume()-.05))}async play(){await this.audioEngine.play()}pause(){this.audioEngine.pause()}toggle(){this.audioEngine.toggle()}next(){this.audioEngine.next()}prev(){this.audioEngine.prev()}seek(e){this.audioEngine.seek(e)}setVolume(e){this.audioEngine.setVolume(e),this.ui.updateVolume(this.audioEngine.getVolume(),this.audioEngine.isMuted())}loadTrack(e,i=!1){this.audioEngine.loadTrack(e,i)}addTrack(e,i=!1){const t=this.audioEngine.addTrack(e,i);return this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex()),t}addTracks(e,i=!1){this.audioEngine.addTracks(e,i),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex())}async addTrackFromFile(e,i=!1){const t=URL.createObjectURL(e),a=e.name.replace(/\.[^/.]+$/,""),s={id:`local-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,title:a,artist:"File Audio Lokal",src:t};try{const n=await this.probeAudioDuration(t);n>0&&(s.duration=n)}catch{}return this.addTrack(s,i),s}async addTrackFromFiles(e,i=!1){const t=Array.from(e),a=[];for(let s=0;s<t.length;s++){const n=t[s],c=i&&s===0,h=await this.addTrackFromFile(n,c);a.push(h)}return a}async addTrackFromUrl(e,i={},t=!1){var n,c;let a="Online Track";try{const g=new URL(e).pathname,p=g.substring(g.lastIndexOf("/")+1);p&&(a=decodeURIComponent(p).replace(/\.[^/.]+$/,""))}catch{}const s={id:i.id||`url-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,title:((n=i.title)==null?void 0:n.trim())||a,artist:((c=i.artist)==null?void 0:c.trim())||"Audio Stream",album:i.album,coverArt:i.coverArt,src:e,duration:i.duration};if(!s.duration)try{const h=await this.probeAudioDuration(e);h>0&&(s.duration=h)}catch{}return this.addTrack(s,t),s}removeTrack(e){this.audioEngine.removeTrack(e),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex());const i=this.audioEngine.getCurrentTrack();i?this.ui.updateTrackInfo(i):this.ui.updateTrackInfo({title:"No Track Loaded",src:""})}getPlaylist(){return this.audioEngine.getPlaylist()}probeAudioDuration(e){return new Promise(i=>{const t=new Audio;let a=!1;const s=h=>{a||(a=!0,t.removeEventListener("loadedmetadata",n),t.removeEventListener("error",c),t.src="",i(h))},n=()=>{const h=t.duration;s(h&&!isNaN(h)&&isFinite(h)?h:0)},c=()=>s(0);t.addEventListener("loadedmetadata",n),t.addEventListener("error",c),t.src=e,setTimeout(()=>s(0),3e3)})}setTheme(e){this.theme={...this.theme,...e},this.styleEl.textContent=T(this.theme),this.theme.enableEqAnimation!==void 0&&this.visualizer.setEnabled(this.theme.enableEqAnimation)}getAudioEngine(){return this.audioEngine}destroy(){this.container.removeEventListener("keydown",this.boundKeyHandler),this.audioEngine.destroy(),this.visualizer.destroy(),this.ui.destroy(),this.shadow.innerHTML=""}}exports.HoregAudio=L;exports.default=L;
828
+ //# sourceMappingURL=horeg-audio.cjs.map