horeg-audio 1.1.0 → 1.1.1

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.
@@ -1,33 +1,36 @@
1
- "use strict";var U=Object.defineProperty;var q=(d,e,r)=>e in d?U(d,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):d[e]=r;var i=(d,e,r)=>q(d,typeof e!="symbol"?e+"":e,r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function B(d){const e=d.replace("#","");if(e.length===3){const r=parseInt(e[0]+e[0],16),t=parseInt(e[1]+e[1],16),o=parseInt(e[2]+e[2],16);return`${r}, ${t}, ${o}`}if(e.length===6){const r=parseInt(e.substring(0,2),16),t=parseInt(e.substring(2,4),16),o=parseInt(e.substring(4,6),16);return`${r}, ${t}, ${o}`}return"245, 158, 11"}function V(d){if(!d)return!1;const e=d.replace("#","");let r=0,t=0,o=0;if(e.length===3)r=parseInt(e[0]+e[0],16),t=parseInt(e[1]+e[1],16),o=parseInt(e[2]+e[2],16);else if(e.length===6)r=parseInt(e.substring(0,2),16),t=parseInt(e.substring(2,4),16),o=parseInt(e.substring(4,6),16);else return!1;return(r*299+t*587+o*114)/1e3>155}const E={"horeg-classic":{variant:"horeg-classic",primaryGlowColor:"#f59e0b",accentColor:"#ef4444",cardBackground:"#121214",textColor:"#f4f4f5",sliderProgressColor:"#f59e0b",borderRadius:"14px",isLight:!1},"horeg-nightclub":{variant:"horeg-nightclub",primaryGlowColor:"#06b6d4",accentColor:"#ec4899",cardBackground:"#0b0c10",textColor:"#f8fafc",sliderProgressColor:"#06b6d4",borderRadius:"14px",isLight:!1},"horeg-stealth":{variant:"horeg-stealth",primaryGlowColor:"#94a3b8",accentColor:"#e2e8f0",cardBackground:"#0f1115",textColor:"#e2e8f0",sliderProgressColor:"#94a3b8",borderRadius:"8px",isLight:!1},"horeg-light":{variant:"horeg-light",primaryGlowColor:"#d97706",accentColor:"#dc2626",cardBackground:"#ffffff",textColor:"#0f172a",sliderProgressColor:"#d97706",borderRadius:"14px",surfaceColor:"#f8fafc",surfaceHoverColor:"#f1f5f9",borderColor:"#e2e8f0",mutedTextColor:"#64748b",isLight:!0},"horeg-light-clean":{variant:"horeg-light-clean",primaryGlowColor:"#0284c7",accentColor:"#db2777",cardBackground:"#ffffff",textColor:"#0f172a",sliderProgressColor:"#0284c7",borderRadius:"14px",surfaceColor:"#f8fafc",surfaceHoverColor:"#f1f5f9",borderColor:"#e2e8f0",mutedTextColor:"#64748b",isLight:!0},"horeg-light-minimal":{variant:"horeg-light-minimal",primaryGlowColor:"#475569",accentColor:"#2563eb",cardBackground:"#f8fafc",textColor:"#1e293b",sliderProgressColor:"#2563eb",borderRadius:"8px",surfaceColor:"#f1f5f9",surfaceHoverColor:"#e2e8f0",borderColor:"#e2e8f0",mutedTextColor:"#64748b",isLight:!0}};function L(d={}){const e=d.variant||"horeg-classic",r=E[e]||E["horeg-classic"],t=d.isLight??r.isLight??(e.includes("light")||V(d.cardBackground||r.cardBackground)),o=d.primaryGlowColor||r.primaryGlowColor||(t?"#d97706":"#f59e0b"),n=d.accentColor||r.accentColor||(t?"#dc2626":"#ef4444"),a=d.cardBackground||r.cardBackground||(t?"#ffffff":"#121214"),l=d.textColor||r.textColor||(t?"#0f172a":"#f4f4f5"),h=d.sliderProgressColor||r.sliderProgressColor||o,g=d.borderRadius||r.borderRadius||"14px",p=d.surfaceColor||r.surfaceColor||(t?"#f8fafc":"#18181b"),b=d.surfaceHoverColor||r.surfaceHoverColor||(t?"#f1f5f9":"#222226"),u=d.borderColor||r.borderColor||(t?"#e2e8f0":"#27272a"),v=d.mutedTextColor||r.mutedTextColor||(t?"#64748b":"#a1a1aa"),x=t?p:"#141416",k=t?"#e2e8f0":"#27272a",y=t?"#cbd5e1":"#3f3f46",w=t?"#ffffff":"#1f1f23",f=t?"#ffffff":"#09090b",M=t?"#94a3b8":"#3f3f46",P=t?"#cbd5e1":"#18181b",S=t?"#cbd5e1":"#2c2d33",A=t?"0.35":"0.3",I=t?"#f8fafc":"#141416",z=t?"#ffffff":"#121214",N=t?"#f1f5f9":"#202024",H=t?"#ffffff":"#27272a",D=t?`linear-gradient(90deg, rgba(${B(o)}, 0.12) 0%, rgba(${B(o)}, 0.02) 100%)`:"linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%)",$=t?"rgba(0, 0, 0, 0.06)":"rgba(255, 255, 255, 0.06)",F=t?"0 14px 36px -8px rgba(15, 23, 42, 0.12), 0 2px 10px -2px rgba(15, 23, 42, 0.06), 0 0 16px -4px var(--horeg-glow)":"0 16px 40px -10px rgba(0, 0, 0, 0.9), 0 0 20px -5px var(--horeg-glow)",R=t?"0 18px 44px -8px rgba(15, 23, 42, 0.18), 0 0 24px -2px var(--horeg-glow)":"0 20px 48px -10px rgba(0, 0, 0, 0.95), 0 0 30px -2px var(--horeg-glow), 0 0 10px var(--horeg-glow)";return`
1
+ "use strict";var q=Object.defineProperty;var j=(d,e,r)=>e in d?q(d,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):d[e]=r;var i=(d,e,r)=>j(d,typeof e!="symbol"?e+"":e,r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function B(d){const e=d.replace("#","");if(e.length===3){const r=parseInt(e[0]+e[0],16),t=parseInt(e[1]+e[1],16),s=parseInt(e[2]+e[2],16);return`${r}, ${t}, ${s}`}if(e.length===6){const r=parseInt(e.substring(0,2),16),t=parseInt(e.substring(2,4),16),s=parseInt(e.substring(4,6),16);return`${r}, ${t}, ${s}`}return"245, 158, 11"}function W(d){if(!d)return!1;const e=d.replace("#","");let r=0,t=0,s=0;if(e.length===3)r=parseInt(e[0]+e[0],16),t=parseInt(e[1]+e[1],16),s=parseInt(e[2]+e[2],16);else if(e.length===6)r=parseInt(e.substring(0,2),16),t=parseInt(e.substring(2,4),16),s=parseInt(e.substring(4,6),16);else return!1;return(r*299+t*587+s*114)/1e3>155}const E={"horeg-classic":{variant:"horeg-classic",primaryGlowColor:"#f59e0b",accentColor:"#ef4444",cardBackground:"#121214",textColor:"#f4f4f5",sliderProgressColor:"#f59e0b",borderRadius:"14px",isLight:!1},"horeg-nightclub":{variant:"horeg-nightclub",primaryGlowColor:"#06b6d4",accentColor:"#ec4899",cardBackground:"#0b0c10",textColor:"#f8fafc",sliderProgressColor:"#06b6d4",borderRadius:"14px",isLight:!1},"horeg-stealth":{variant:"horeg-stealth",primaryGlowColor:"#94a3b8",accentColor:"#e2e8f0",cardBackground:"#0f1115",textColor:"#e2e8f0",sliderProgressColor:"#94a3b8",borderRadius:"8px",isLight:!1},"horeg-light":{variant:"horeg-light",primaryGlowColor:"#d97706",accentColor:"#dc2626",cardBackground:"#ffffff",textColor:"#0f172a",sliderProgressColor:"#d97706",borderRadius:"14px",surfaceColor:"#f8fafc",surfaceHoverColor:"#f1f5f9",borderColor:"#e2e8f0",mutedTextColor:"#64748b",isLight:!0},"horeg-light-clean":{variant:"horeg-light-clean",primaryGlowColor:"#0284c7",accentColor:"#db2777",cardBackground:"#ffffff",textColor:"#0f172a",sliderProgressColor:"#0284c7",borderRadius:"14px",surfaceColor:"#f8fafc",surfaceHoverColor:"#f1f5f9",borderColor:"#e2e8f0",mutedTextColor:"#64748b",isLight:!0},"horeg-light-minimal":{variant:"horeg-light-minimal",primaryGlowColor:"#475569",accentColor:"#2563eb",cardBackground:"#f8fafc",textColor:"#1e293b",sliderProgressColor:"#2563eb",borderRadius:"8px",surfaceColor:"#f1f5f9",surfaceHoverColor:"#e2e8f0",borderColor:"#e2e8f0",mutedTextColor:"#64748b",isLight:!0}};function L(d={},e){const r=d.variant||"horeg-classic",t=E[r]||E["horeg-classic"];let s="none";typeof e=="number"?s=`${e}px`:typeof e=="string"&&e.trim()!==""&&e.trim().toLowerCase()!=="fluid"&&(s=e.trim());const o=d.isLight??t.isLight??(r.includes("light")||W(d.cardBackground||t.cardBackground)),a=d.primaryGlowColor||t.primaryGlowColor||(o?"#d97706":"#f59e0b"),l=d.accentColor||t.accentColor||(o?"#dc2626":"#ef4444"),h=d.cardBackground||t.cardBackground||(o?"#ffffff":"#121214"),p=d.textColor||t.textColor||(o?"#0f172a":"#f4f4f5"),g=d.sliderProgressColor||t.sliderProgressColor||a,b=d.borderRadius||t.borderRadius||"14px",u=d.surfaceColor||t.surfaceColor||(o?"#f8fafc":"#18181b"),f=d.surfaceHoverColor||t.surfaceHoverColor||(o?"#f1f5f9":"#222226"),m=d.borderColor||t.borderColor||(o?"#e2e8f0":"#27272a"),y=d.mutedTextColor||t.mutedTextColor||(o?"#64748b":"#a1a1aa"),w=o?u:"#141416",k=o?"#e2e8f0":"#27272a",x=o?"#cbd5e1":"#3f3f46",A=o?"#ffffff":"#1f1f23",S=o?"#ffffff":"#09090b",M=o?"#94a3b8":"#3f3f46",P=o?"#cbd5e1":"#18181b",z=o?"#cbd5e1":"#2c2d33",I=o?"0.35":"0.3",N=o?"#f8fafc":"#141416",H=o?"#ffffff":"#121214",D=o?"#f1f5f9":"#202024",$=o?"#ffffff":"#27272a",R=o?`linear-gradient(90deg, rgba(${B(a)}, 0.12) 0%, rgba(${B(a)}, 0.02) 100%)`:"linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%)",F=o?"rgba(0, 0, 0, 0.06)":"rgba(255, 255, 255, 0.06)",U=o?"0 14px 36px -8px rgba(15, 23, 42, 0.12), 0 2px 10px -2px rgba(15, 23, 42, 0.06), 0 0 16px -4px var(--horeg-glow)":"0 16px 40px -10px rgba(0, 0, 0, 0.9), 0 0 20px -5px var(--horeg-glow)",V=o?"0 18px 44px -8px rgba(15, 23, 42, 0.18), 0 0 24px -2px var(--horeg-glow)":"0 20px 48px -10px rgba(0, 0, 0, 0.95), 0 0 30px -2px var(--horeg-glow), 0 0 10px var(--horeg-glow)";return`
2
2
  :host {
3
- --horeg-bg: ${a};
4
- --horeg-surface: ${p};
5
- --horeg-surface-hover: ${b};
6
- --horeg-border: ${u};
7
- --horeg-glow: ${o};
8
- --horeg-glow-rgb: ${B(o)};
9
- --horeg-accent: ${n};
10
- --horeg-progress: ${h};
11
- --horeg-text-main: ${l};
12
- --horeg-text-muted: ${v};
13
- --horeg-radius: ${g};
14
- --horeg-drawer-bg: ${x};
3
+ display: block;
4
+ width: 100%;
5
+ --horeg-max-width: ${s};
6
+ --horeg-bg: ${h};
7
+ --horeg-surface: ${u};
8
+ --horeg-surface-hover: ${f};
9
+ --horeg-border: ${m};
10
+ --horeg-glow: ${a};
11
+ --horeg-glow-rgb: ${B(a)};
12
+ --horeg-accent: ${l};
13
+ --horeg-progress: ${g};
14
+ --horeg-text-main: ${p};
15
+ --horeg-text-muted: ${y};
16
+ --horeg-radius: ${b};
17
+ --horeg-drawer-bg: ${w};
15
18
  --horeg-slider-bg: ${k};
16
- --horeg-slider-buffer: ${y};
17
- --horeg-btn-play-bg: ${w};
18
- --horeg-btn-play-text: ${f};
19
+ --horeg-slider-buffer: ${x};
20
+ --horeg-btn-play-bg: ${A};
21
+ --horeg-btn-play-text: ${S};
19
22
  --horeg-bolt-bg: ${M};
20
23
  --horeg-bolt-border: ${P};
21
- --horeg-grill-color: ${S};
22
- --horeg-grill-opacity: ${A};
23
- --horeg-dropzone-bg: ${I};
24
- --horeg-input-bg: ${z};
25
- --horeg-tab-bg: ${N};
26
- --horeg-tab-active-bg: ${H};
27
- --horeg-item-active-bg: ${D};
28
- --horeg-btn-active-bg: ${$};
29
- --horeg-box-shadow: ${F};
30
- --horeg-focus-shadow: ${R};
24
+ --horeg-grill-color: ${z};
25
+ --horeg-grill-opacity: ${I};
26
+ --horeg-dropzone-bg: ${N};
27
+ --horeg-input-bg: ${H};
28
+ --horeg-tab-bg: ${D};
29
+ --horeg-tab-active-bg: ${$};
30
+ --horeg-item-active-bg: ${R};
31
+ --horeg-btn-active-bg: ${F};
32
+ --horeg-box-shadow: ${U};
33
+ --horeg-focus-shadow: ${V};
31
34
  display: block;
32
35
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
33
36
  box-sizing: border-box;
@@ -43,6 +46,8 @@
43
46
  }
44
47
 
45
48
  .horeg-player-box {
49
+ container-type: inline-size;
50
+ container-name: horeg-box;
46
51
  background: var(--horeg-bg);
47
52
  border: 2px solid var(--horeg-border);
48
53
  border-radius: var(--horeg-radius);
@@ -50,8 +55,8 @@
50
55
  color: var(--horeg-text-main);
51
56
  position: relative;
52
57
  overflow: hidden;
53
- max-width: 520px;
54
58
  width: 100%;
59
+ max-width: var(--horeg-max-width, none);
55
60
  margin: 0 auto;
56
61
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
57
62
  }
@@ -161,7 +166,7 @@
161
166
  justify-content: center;
162
167
  gap: 12px;
163
168
  padding: 14px 24px;
164
- background: ${t?"rgba(0, 0, 0, 0.04)":"rgba(0, 0, 0, 0.45)"};
169
+ background: ${o?"rgba(0, 0, 0, 0.04)":"rgba(0, 0, 0, 0.45)"};
165
170
  border: 1px solid var(--horeg-border);
166
171
  border-radius: 12px;
167
172
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.35);
@@ -686,6 +691,7 @@
686
691
  justify-content: center;
687
692
  transition: all 0.15s ease;
688
693
  touch-action: manipulation;
694
+ position: relative;
689
695
  }
690
696
 
691
697
  .horeg-btn:hover {
@@ -710,6 +716,100 @@
710
716
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.05);
711
717
  }
712
718
 
719
+ /* Tooltip Bubble */
720
+ .horeg-btn[data-tooltip]::before {
721
+ content: attr(data-tooltip);
722
+ position: absolute;
723
+ bottom: calc(100% + 7px);
724
+ left: 50%;
725
+ transform: translateX(-50%) translateY(4px);
726
+ background: ${o?"rgba(15, 23, 42, 0.94)":"rgba(20, 20, 24, 0.96)"};
727
+ color: ${o?"#f8fafc":"var(--horeg-text-main)"};
728
+ border: 1px solid var(--horeg-border);
729
+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 8px rgba(var(--horeg-glow-rgb), 0.3);
730
+ padding: 3px 8px;
731
+ font-size: 11px;
732
+ font-weight: 600;
733
+ border-radius: 5px;
734
+ white-space: nowrap;
735
+ pointer-events: none;
736
+ opacity: 0;
737
+ visibility: hidden;
738
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
739
+ z-index: 35;
740
+ letter-spacing: 0.2px;
741
+ font-family: inherit;
742
+ }
743
+
744
+ /* Tooltip Arrow */
745
+ .horeg-btn[data-tooltip]::after {
746
+ content: '';
747
+ position: absolute;
748
+ bottom: calc(100% + 2px);
749
+ left: 50%;
750
+ transform: translateX(-50%) translateY(4px);
751
+ border-width: 5px 5px 0 5px;
752
+ border-style: solid;
753
+ border-color: ${o?"rgba(15, 23, 42, 0.94)":"rgba(20, 20, 24, 0.96)"} transparent transparent transparent;
754
+ pointer-events: none;
755
+ opacity: 0;
756
+ visibility: hidden;
757
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
758
+ z-index: 35;
759
+ }
760
+
761
+ .horeg-btn[data-tooltip]:hover::before,
762
+ .horeg-btn[data-tooltip]:focus-visible::before,
763
+ .horeg-btn[data-tooltip]:hover::after,
764
+ .horeg-btn[data-tooltip]:focus-visible::after {
765
+ opacity: 1;
766
+ visibility: visible;
767
+ transform: translateX(-50%) translateY(0);
768
+ }
769
+
770
+ /* Edge alignment so tooltips near container margins don't clip */
771
+ .horeg-side-controls:first-child .horeg-btn:first-child[data-tooltip]::before {
772
+ left: 0;
773
+ transform: translateY(4px);
774
+ }
775
+ .horeg-side-controls:first-child .horeg-btn:first-child[data-tooltip]::after {
776
+ left: 12px;
777
+ transform: translateY(4px);
778
+ }
779
+ .horeg-side-controls:first-child .horeg-btn:first-child[data-tooltip]:hover::before,
780
+ .horeg-side-controls:first-child .horeg-btn:first-child[data-tooltip]:focus-visible::before,
781
+ .horeg-side-controls:first-child .horeg-btn:first-child[data-tooltip]:hover::after,
782
+ .horeg-side-controls:first-child .horeg-btn:first-child[data-tooltip]:focus-visible::after {
783
+ transform: translateY(0);
784
+ }
785
+
786
+ .horeg-side-controls:last-child .horeg-btn:last-child[data-tooltip]::before {
787
+ left: auto;
788
+ right: 0;
789
+ transform: translateY(4px);
790
+ }
791
+ .horeg-side-controls:last-child .horeg-btn:last-child[data-tooltip]::after {
792
+ left: auto;
793
+ right: 12px;
794
+ transform: translateY(4px);
795
+ }
796
+ .horeg-side-controls:last-child .horeg-btn:last-child[data-tooltip]:hover::before,
797
+ .horeg-side-controls:last-child .horeg-btn:last-child[data-tooltip]:focus-visible::before,
798
+ .horeg-side-controls:last-child .horeg-btn:last-child[data-tooltip]:hover::after,
799
+ .horeg-side-controls:last-child .horeg-btn:last-child[data-tooltip]:focus-visible::after {
800
+ transform: translateY(0);
801
+ }
802
+
803
+ /* Suppress volume button tooltip when dropup is active */
804
+ .horeg-volume-wrap:hover .horeg-btn[data-tooltip]::before,
805
+ .horeg-volume-wrap:hover .horeg-btn[data-tooltip]::after,
806
+ .horeg-volume-wrap:focus-within .horeg-btn[data-tooltip]::before,
807
+ .horeg-volume-wrap:focus-within .horeg-btn[data-tooltip]::after,
808
+ .horeg-volume-wrap.open .horeg-btn[data-tooltip]::before,
809
+ .horeg-volume-wrap.open .horeg-btn[data-tooltip]::after {
810
+ display: none;
811
+ }
812
+
713
813
  /* Primary Play / Pause Button with Neon Glow Pulse */
714
814
  .horeg-btn-play {
715
815
  width: 44px;
@@ -748,47 +848,116 @@
748
848
  }
749
849
  }
750
850
 
751
- /* Volume Slider Rel Mixer */
851
+ /* Vertical Volume Dropup Mixer */
752
852
  .horeg-volume-wrap {
853
+ position: relative;
854
+ display: flex;
855
+ align-items: center;
856
+ justify-content: center;
857
+ }
858
+
859
+ .horeg-volume-dropup {
860
+ position: absolute;
861
+ bottom: calc(100% + 8px);
862
+ left: 50%;
863
+ transform: translateX(-50%) translateY(8px);
864
+ background: ${o?"#ffffff":"var(--horeg-surface)"};
865
+ border: 1px solid var(--horeg-border);
866
+ border-radius: 10px;
867
+ padding: 8px 6px 8px 6px;
868
+ box-shadow: 0 10px 24px -4px rgba(0, 0, 0, 0.6), 0 0 10px -2px var(--horeg-glow);
753
869
  display: flex;
870
+ flex-direction: column;
754
871
  align-items: center;
755
872
  gap: 6px;
873
+ width: 36px;
874
+ opacity: 0;
875
+ visibility: hidden;
876
+ pointer-events: none;
877
+ transition: opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1), transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.18s ease;
878
+ z-index: 40;
756
879
  }
757
880
 
758
- .horeg-volume-slider {
759
- -webkit-appearance: none;
760
- appearance: none;
761
- width: 70px;
762
- height: 5px;
881
+ /* Dropup hover bridge */
882
+ .horeg-volume-dropup::before {
883
+ content: '';
884
+ position: absolute;
885
+ top: 100%;
886
+ left: -8px;
887
+ right: -8px;
888
+ height: 12px;
889
+ background: transparent;
890
+ }
891
+
892
+ /* Dropup arrow pointer */
893
+ .horeg-volume-dropup::after {
894
+ content: '';
895
+ position: absolute;
896
+ top: 100%;
897
+ left: 50%;
898
+ transform: translateX(-50%);
899
+ border-width: 5px 5px 0 5px;
900
+ border-style: solid;
901
+ border-color: ${o?"#ffffff":"var(--horeg-surface)"} transparent transparent transparent;
902
+ }
903
+
904
+ .horeg-volume-wrap:hover .horeg-volume-dropup,
905
+ .horeg-volume-wrap:focus-within .horeg-volume-dropup,
906
+ .horeg-volume-wrap.open .horeg-volume-dropup {
907
+ opacity: 1;
908
+ visibility: visible;
909
+ pointer-events: auto;
910
+ transform: translateX(-50%) translateY(0);
911
+ }
912
+
913
+ .horeg-volume-percent {
914
+ font-size: 10px;
915
+ font-weight: 700;
916
+ color: var(--horeg-glow);
917
+ font-family: ui-monospace, monospace;
918
+ letter-spacing: 0.5px;
919
+ user-select: none;
920
+ text-align: center;
921
+ line-height: 1;
922
+ }
923
+
924
+ .horeg-volume-slider-vertical {
925
+ -webkit-appearance: slider-vertical;
926
+ appearance: slider-vertical;
927
+ writing-mode: vertical-lr;
928
+ direction: rtl;
929
+ width: 8px;
930
+ height: 84px;
763
931
  background: var(--horeg-slider-bg);
764
- border-radius: 3px;
932
+ border-radius: 4px;
765
933
  outline: none;
766
934
  cursor: pointer;
935
+ margin: 0 auto;
767
936
  }
768
937
 
769
- .horeg-volume-slider::-webkit-slider-thumb {
938
+ .horeg-volume-slider-vertical::-webkit-slider-thumb {
770
939
  -webkit-appearance: none;
771
940
  appearance: none;
772
- width: 12px;
773
- height: 12px;
941
+ width: 14px;
942
+ height: 14px;
774
943
  border-radius: 50%;
775
944
  background: var(--horeg-glow);
776
- border: 1px solid var(--horeg-border);
945
+ border: 2px solid ${o?"#ffffff":"#18181b"};
777
946
  box-shadow: 0 0 6px var(--horeg-glow);
778
947
  cursor: pointer;
779
948
  transition: transform 0.1s ease;
780
949
  }
781
950
 
782
- .horeg-volume-slider::-webkit-slider-thumb:hover {
951
+ .horeg-volume-slider-vertical::-webkit-slider-thumb:hover {
783
952
  transform: scale(1.2);
784
953
  }
785
954
 
786
- .horeg-volume-slider::-moz-range-thumb {
787
- width: 12px;
788
- height: 12px;
955
+ .horeg-volume-slider-vertical::-moz-range-thumb {
956
+ width: 14px;
957
+ height: 14px;
789
958
  border-radius: 50%;
790
959
  background: var(--horeg-glow);
791
- border: 1px solid var(--horeg-border);
960
+ border: 2px solid ${o?"#ffffff":"#18181b"};
792
961
  box-shadow: 0 0 6px var(--horeg-glow);
793
962
  cursor: pointer;
794
963
  }
@@ -1205,11 +1374,83 @@
1205
1374
  font-size: 12px;
1206
1375
  font-style: italic;
1207
1376
  }
1208
- `}function T(d){if(isNaN(d)||!isFinite(d)||d<0)return"00:00";const e=Math.floor(d),r=Math.floor(e/3600),t=Math.floor(e%3600/60),o=e%60,n=a=>a.toString().padStart(2,"0");return r>0?`${r}:${n(t)}:${n(o)}`:`${n(t)}:${n(o)}`}function m(d,e,r){return Math.min(Math.max(d,e),r)}class j{constructor(e,r={}){i(this,"audio");i(this,"playlist",[]);i(this,"currentIndex",0);i(this,"loopMode","all");i(this,"shuffleMode",!1);i(this,"volumeLevel",.8);i(this,"previousVolume",.8);i(this,"callbacks",{});i(this,"audioContext",null);i(this,"analyser",null);i(this,"sourceNode",null);i(this,"freqData",null);i(this,"webAudioInitialized",!1);i(this,"bassRollingAvg",.2);i(this,"bassPulseEnvelope",0);i(this,"handlePlay",()=>{const e=this.getCurrentTrack();e&&this.callbacks.onPlay&&this.callbacks.onPlay(e)});i(this,"handlePause",()=>{this.callbacks.onPause&&this.callbacks.onPause()});i(this,"handleTimeUpdate",()=>{if(this.audio.seeking)return;const e=this.audio.currentTime||0,r=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(e,r)});i(this,"handleSeeked",()=>{const e=this.audio.currentTime||0,r=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(e,r)});i(this,"handleProgress",()=>{if(this.audio.buffered.length>0&&this.audio.duration>0){const e=this.audio.buffered.end(this.audio.buffered.length-1),r=this.audio.duration,t=m(e/r*100,0,100);this.callbacks.onBufferUpdate&&this.callbacks.onBufferUpdate(t)}});i(this,"handleWaiting",()=>{this.callbacks.onLoadingChange&&this.callbacks.onLoadingChange(!0)});i(this,"handlePlaying",()=>{this.callbacks.onLoadingChange&&this.callbacks.onLoadingChange(!1)});i(this,"handleLoadedMetadata",()=>{const e=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(this.audio.currentTime||0,e)});i(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)});i(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.audio.crossOrigin="anonymous",this.playlist=[...e.playlist||[]],this.currentIndex=e.initialIndex!==void 0?m(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?m(e.volume,0,1):.8,this.callbacks=r||{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),this.audio.addEventListener("seeked",this.handleSeeked)}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),this.audio.removeEventListener("seeked",this.handleSeeked)}getCurrentTrack(){return this.playlist[this.currentIndex]}getCurrentIndex(){return this.currentIndex}getPlaylist(){return this.playlist}setPlaylist(e,r=0){this.playlist=[...e],this.currentIndex=m(r,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,r=!1){const t=this.playlist.length===0;this.playlist.push(e);const o=this.playlist.length-1;return this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex),t?this.loadTrack(0,r):r&&this.loadTrack(o,!0),o}addTracks(e,r=!1){if(!e||e.length===0)return;const t=this.playlist.length===0,o=this.playlist.length;this.playlist.push(...e),this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex),t?this.loadTrack(0,r):r&&this.loadTrack(o,!0)}removeTrack(e){if(e<0||e>=this.playlist.length)return;const r=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(r){const t=m(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 r=this.getCurrentTrack();return(r==null?void 0:r.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,r=!1){let t;typeof e=="number"?t=m(e,0,Math.max(0,this.playlist.length-1)):(t=this.playlist.findIndex(n=>n.src===e.src),t===-1&&(this.playlist.push(e),t=this.playlist.length-1)),this.currentIndex=t;const o=this.playlist[this.currentIndex];o&&(this.audio.src=o.src,this.callbacks.onTrackChange&&this.callbacks.onTrackChange(o,this.currentIndex),r&&this.play())}async play(){this.initWebAudio();try{await this.audio.play()}catch(e){console.warn("[HoregAudio] Autoplay / Audio play was prevented by browser policy:",e)}}initWebAudio(){if(this.webAudioInitialized){this.audioContext&&this.audioContext.state==="suspended"&&this.audioContext.resume().catch(()=>{});return}try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;this.audioContext=new e,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=128,this.analyser.smoothingTimeConstant=.65,this.sourceNode=this.audioContext.createMediaElementSource(this.audio),this.sourceNode.connect(this.analyser),this.analyser.connect(this.audioContext.destination),this.freqData=new Uint8Array(this.analyser.frequencyBinCount),this.webAudioInitialized=!0}catch{this.webAudioInitialized=!0}}getAudioEnergy(){if(!this.isPlaying())return{bass:0,midHigh:0,left:0,right:0};const e=this.isMuted()?0:Math.max(.35,Math.sqrt(this.volumeLevel));if(this.analyser&&this.freqData&&this.audioContext&&this.audioContext.state==="running")try{this.analyser.getByteFrequencyData(this.freqData);let r=0;const t=Math.min(4,this.freqData.length);for(let f=0;f<t;f++)r+=this.freqData[f];let o=0;const n=Math.min(16,this.freqData.length);for(let f=t;f<n;f++)o+=this.freqData[f];const a=r/(t*255),l=o/((n-t)*255);if(a<.025&&l<.025)return this.bassPulseEnvelope*=.5,this.bassPulseEnvelope<.01&&(this.bassPulseEnvelope=0),{bass:0,midHigh:0,left:0,right:0};const h=Math.max(a,l*.7),g=a*.75;this.bassRollingAvg=this.bassRollingAvg*.92+a*.08;const p=Math.max(0,a-this.bassRollingAvg),b=p>.006?Math.min(1,p*4.5+.3+a*.35):0,u=this.audio.currentTime>0?this.audio.currentTime:Date.now()/1e3,v=(Math.sin(u*13)*.5+.5)*.08*Math.min(1,h*2.5),x=.09*Math.min(1,h*3)+v,k=Math.max(b,g,x);this.bassPulseEnvelope=Math.max(k,this.bassPulseEnvelope*.82);const y=Math.min(1,this.bassPulseEnvelope)*e,w=Math.min(1,l*1.3)*e;return{bass:y,midHigh:w,left:w*.9,right:w*.95}}catch{}if(!this.analyser||!this.audioContext||this.audioContext.state!=="running"){const r=this.audio.currentTime>0?this.audio.currentTime:Date.now()/1e3,o=60/130,n=r%o/o,a=Math.pow(Math.max(0,1-n*2.2),3.2),l=m(Math.max(.12,a),0,1)*e,h=m(Math.sin(r*8)*.25+.35+a*.25,0,1)*e;return{bass:l,midHigh:h,left:h*.85,right:h*.9}}return{bass:0,midHigh:0,left:0,right:0}}pause(){this.audio.pause()}toggle(){this.audio.paused?this.play():this.pause()}seek(e){const r=this.getDuration();this.audio.currentTime=m(e,0,r||0)}setVolume(e){this.volumeLevel=m(e,0,1),this.audio.volume=this.volumeLevel,this.volumeLevel>0&&(this.audio.muted=!1)}toggleMute(){return this.isMuted()?(this.audio.muted=!1,this.audio.volume=this.previousVolume||.8,this.volumeLevel=this.previousVolume||.8,!1):(this.previousVolume=this.volumeLevel,this.audio.muted=!0,!0)}next(e=!1){if(this.playlist.length===0)return;if(this.loopMode==="one"){this.seek(0),this.play();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 r=this.currentIndex+1;r<this.playlist.length?this.loadTrack(r,!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>3){this.seek(0);return}if(this.loopMode==="one"){this.seek(0),this.play();return}if(this.shuffleMode&&this.playlist.length>1){let r;do r=Math.floor(Math.random()*this.playlist.length);while(r===this.currentIndex);this.loadTrack(r,!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(),this.audioContext&&this.audioContext.state!=="closed"&&this.audioContext.close().catch(()=>{})}}const c={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="32" height="32"><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 s(d,e){const r=document.createElement(d);if(e!=null&&e.className&&(r.className=e.className),e!=null&&e.attributes)for(const[t,o]of Object.entries(e.attributes))r.setAttribute(t,o);return e!=null&&e.innerHTML?r.innerHTML=e.innerHTML:e!=null&&e.textContent&&(r.textContent=e.textContent),r}class W{constructor(e){i(this,"root");i(this,"stageContainer");i(this,"eqContainer");i(this,"coverContainer");i(this,"titleWrap");i(this,"playBtn");i(this,"prevBtn");i(this,"nextBtn");i(this,"shuffleBtn");i(this,"loopBtn");i(this,"muteBtn");i(this,"drawerBtn");i(this,"titleEl");i(this,"artistEl");i(this,"albumEl");i(this,"coverImgEl",null);i(this,"currentTimeEl");i(this,"durationEl");i(this,"sliderTrack");i(this,"fillBar");i(this,"bufferBar");i(this,"volumeSlider");i(this,"drawerEl");i(this,"drawerCountEl");i(this,"addTrackBtn");i(this,"addPanelEl");i(this,"fileInputEl");i(this,"tabBtnFile");i(this,"tabBtnUrl");i(this,"tabPaneFile");i(this,"tabPaneUrl");i(this,"urlInput");i(this,"titleInput");i(this,"artistInput");i(this,"submitUrlBtn");i(this,"cancelAddBtn");i(this,"dropzoneEl");i(this,"drawerInner");i(this,"isScrubbing",!1);i(this,"currentDuration",0);i(this,"events");i(this,"startScrubbing",e=>{e.preventDefault(),this.isScrubbing=!0,document.body.style.userSelect="none",this.handleScrubbingMove(e);const r=o=>{this.isScrubbing&&this.handleScrubbingMove(o)},t=o=>{this.isScrubbing&&(this.finishScrubbing(o),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",t),window.removeEventListener("touchmove",r),window.removeEventListener("touchend",t))};window.addEventListener("mousemove",r),window.addEventListener("mouseup",t),window.addEventListener("touchmove",r,{passive:!1}),window.addEventListener("touchend",t)});this.events=e,this.root=s("div",{className:"horeg-player-box"});const r=s("div",{className:"horeg-speaker-grill"});this.root.appendChild(r),["top-left","top-right","bottom-left","bottom-right"].forEach(f=>{this.root.appendChild(s("div",{className:`horeg-bolt ${f}`}))});const t=s("div",{className:"horeg-content-wrap"});this.root.appendChild(t);const o=s("div",{className:"horeg-header"}),n=s("div",{className:"horeg-rig-badge",innerHTML:'<span class="horeg-badge-led"></span> SOUND HOREG • HIGH VOLTAGE'});o.appendChild(n),t.appendChild(o),this.stageContainer=s("div",{className:"horeg-soundbox-stage"}),this.eqContainer=this.stageContainer,this.coverContainer=s("div",{className:"horeg-sub-cover-wrap"}),this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${c.speaker}</span>`;const a=s("div",{className:"horeg-track-meta"});this.titleWrap=s("div",{className:"horeg-title-wrap"}),this.titleEl=s("div",{className:"horeg-track-title",textContent:"No Track Loaded"}),this.titleWrap.appendChild(this.titleEl),this.artistEl=s("div",{className:"horeg-track-artist",textContent:"Unknown Artist"}),this.albumEl=s("div",{className:"horeg-track-album",textContent:""}),a.appendChild(this.titleWrap),a.appendChild(this.artistEl),a.appendChild(this.albumEl),t.appendChild(this.stageContainer),t.appendChild(a);const l=s("div",{className:"horeg-progress-container"}),h=s("div",{className:"horeg-time-row"});this.currentTimeEl=s("span",{textContent:"00:00"}),this.durationEl=s("span",{textContent:"00:00"}),h.appendChild(this.currentTimeEl),h.appendChild(this.durationEl),l.appendChild(h),this.sliderTrack=s("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=s("div",{className:"horeg-buffer-bar"}),this.fillBar=s("div",{className:"horeg-fill-bar"}),this.sliderTrack.appendChild(this.bufferBar),this.sliderTrack.appendChild(this.fillBar),l.appendChild(this.sliderTrack),t.appendChild(l);const g=s("div",{className:"horeg-controls-row"}),p=s("div",{className:"horeg-side-controls"});this.shuffleBtn=s("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle shuffle",type:"button"},innerHTML:c.shuffle}),this.loopBtn=s("button",{className:"horeg-btn active",attributes:{"aria-label":"Toggle loop mode",type:"button"},innerHTML:c.repeat}),p.appendChild(this.shuffleBtn),p.appendChild(this.loopBtn),g.appendChild(p);const b=s("div",{className:"horeg-center-controls"});this.prevBtn=s("button",{className:"horeg-btn",attributes:{"aria-label":"Previous track",type:"button"},innerHTML:c.prev}),this.playBtn=s("button",{className:"horeg-btn horeg-btn-play",attributes:{"aria-label":"Play track",type:"button"},innerHTML:c.play}),this.nextBtn=s("button",{className:"horeg-btn",attributes:{"aria-label":"Next track",type:"button"},innerHTML:c.next}),b.appendChild(this.prevBtn),b.appendChild(this.playBtn),b.appendChild(this.nextBtn),g.appendChild(b);const u=s("div",{className:"horeg-side-controls"}),v=s("div",{className:"horeg-volume-wrap"});this.muteBtn=s("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle mute",type:"button"},innerHTML:c.volumeHigh}),this.volumeSlider=s("input",{className:"horeg-volume-slider",attributes:{type:"range",min:"0",max:"1",step:"0.01",value:"0.8","aria-label":"Volume control"}}),v.appendChild(this.muteBtn),v.appendChild(this.volumeSlider),u.appendChild(v),this.drawerBtn=s("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle playlist drawer",type:"button"},innerHTML:c.playlist}),u.appendChild(this.drawerBtn),g.appendChild(u),t.appendChild(g),this.drawerEl=s("div",{className:"horeg-drawer"});const x=s("div",{className:"horeg-drawer-header"}),k=s("div",{className:"horeg-drawer-heading"});k.innerHTML="<span>PLAYLIST</span>",this.drawerCountEl=s("span",{className:"horeg-drawer-count",textContent:"0"}),k.appendChild(this.drawerCountEl),x.appendChild(k),this.addTrackBtn=s("button",{className:"horeg-btn-add-track",attributes:{type:"button","aria-label":"Add track to playlist"},innerHTML:`${c.plus} <span>Add Track</span>`}),x.appendChild(this.addTrackBtn),this.drawerEl.appendChild(x),this.addPanelEl=s("div",{className:"horeg-add-panel"});const y=s("div",{className:"horeg-add-tabs"});this.tabBtnFile=s("button",{className:"horeg-tab-btn active",attributes:{type:"button"},innerHTML:`${c.upload} <span>File Lokal</span>`}),this.tabBtnUrl=s("button",{className:"horeg-tab-btn",attributes:{type:"button"},innerHTML:`${c.link} <span>Audio URL</span>`}),y.appendChild(this.tabBtnFile),y.appendChild(this.tabBtnUrl),this.addPanelEl.appendChild(y),this.tabPaneFile=s("div",{className:"horeg-tab-pane active"}),this.fileInputEl=s("input",{attributes:{type:"file",accept:"audio/*",multiple:"true",style:"display: none;"}}),this.dropzoneEl=s("div",{className:"horeg-dropzone"}),this.dropzoneEl.innerHTML=`
1377
+
1378
+ /* Responsive Layout (<= 360px): Single Center Soundbox & Wrapped Controls */
1379
+ @container horeg-box (max-width: 360px) {
1380
+ .horeg-content-wrap {
1381
+ padding: 14px 14px 12px 14px;
1382
+ gap: 10px;
1383
+ }
1384
+
1385
+ /* 1. Visualizer: Hide Satellite Soundboxes, Center Subwoofer Dominates */
1386
+ .horeg-soundbox.is-satellite {
1387
+ display: none !important;
1388
+ }
1389
+
1390
+ .horeg-soundbox-stage {
1391
+ padding: 10px 12px;
1392
+ gap: 0;
1393
+ }
1394
+
1395
+ /* 2. Controls Row: Wrap into 2 Rows */
1396
+ .horeg-controls-row {
1397
+ flex-wrap: wrap;
1398
+ gap: 10px 0;
1399
+ justify-content: space-between;
1400
+ }
1401
+
1402
+ /* Row 1: Center Controls (Prev, Play, Next) centered on top */
1403
+ .horeg-center-controls {
1404
+ order: 1;
1405
+ width: 100%;
1406
+ justify-content: center;
1407
+ gap: 16px;
1408
+ margin-bottom: 2px;
1409
+ }
1410
+
1411
+ /* Row 2: Left Tools (Shuffle, Loop) & Right Tools (Volume, Playlist) with space-between */
1412
+ .horeg-side-controls:first-child {
1413
+ order: 2;
1414
+ }
1415
+
1416
+ .horeg-side-controls:last-child {
1417
+ order: 3;
1418
+ }
1419
+ }
1420
+
1421
+ /* Viewport Media Query fallback */
1422
+ @media (max-width: 360px) {
1423
+ .horeg-soundbox.is-satellite {
1424
+ display: none !important;
1425
+ }
1426
+ .horeg-soundbox-stage {
1427
+ padding: 10px 12px;
1428
+ gap: 0;
1429
+ }
1430
+ .horeg-controls-row {
1431
+ flex-wrap: wrap;
1432
+ gap: 10px 0;
1433
+ justify-content: space-between;
1434
+ }
1435
+ .horeg-center-controls {
1436
+ order: 1;
1437
+ width: 100%;
1438
+ justify-content: center;
1439
+ gap: 16px;
1440
+ margin-bottom: 2px;
1441
+ }
1442
+ .horeg-side-controls:first-child {
1443
+ order: 2;
1444
+ }
1445
+ .horeg-side-controls:last-child {
1446
+ order: 3;
1447
+ }
1448
+ }
1449
+ `}function T(d){if(isNaN(d)||!isFinite(d)||d<0)return"00:00";const e=Math.floor(d),r=Math.floor(e/3600),t=Math.floor(e%3600/60),s=e%60,o=a=>a.toString().padStart(2,"0");return r>0?`${r}:${o(t)}:${o(s)}`:`${o(t)}:${o(s)}`}function v(d,e,r){return Math.min(Math.max(d,e),r)}class O{constructor(e,r={}){i(this,"audio");i(this,"playlist",[]);i(this,"currentIndex",0);i(this,"loopMode","all");i(this,"shuffleMode",!1);i(this,"volumeLevel",.8);i(this,"previousVolume",.8);i(this,"callbacks",{});i(this,"audioContext",null);i(this,"analyser",null);i(this,"sourceNode",null);i(this,"freqData",null);i(this,"webAudioInitialized",!1);i(this,"bassRollingAvg",.2);i(this,"bassPulseEnvelope",0);i(this,"handlePlay",()=>{const e=this.getCurrentTrack();e&&this.callbacks.onPlay&&this.callbacks.onPlay(e)});i(this,"handlePause",()=>{this.callbacks.onPause&&this.callbacks.onPause()});i(this,"handleTimeUpdate",()=>{if(this.audio.seeking)return;const e=this.audio.currentTime||0,r=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(e,r)});i(this,"handleSeeked",()=>{const e=this.audio.currentTime||0,r=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(e,r)});i(this,"handleProgress",()=>{if(this.audio.buffered.length>0&&this.audio.duration>0){const e=this.audio.buffered.end(this.audio.buffered.length-1),r=this.audio.duration,t=v(e/r*100,0,100);this.callbacks.onBufferUpdate&&this.callbacks.onBufferUpdate(t)}});i(this,"handleWaiting",()=>{this.callbacks.onLoadingChange&&this.callbacks.onLoadingChange(!0)});i(this,"handlePlaying",()=>{this.callbacks.onLoadingChange&&this.callbacks.onLoadingChange(!1)});i(this,"handleLoadedMetadata",()=>{const e=this.getDuration();this.callbacks.onTimeUpdate&&this.callbacks.onTimeUpdate(this.audio.currentTime||0,e)});i(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)});i(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.audio.crossOrigin="anonymous",this.playlist=[...e.playlist||[]],this.currentIndex=e.initialIndex!==void 0?v(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?v(e.volume,0,1):.8,this.callbacks=r||{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),this.audio.addEventListener("seeked",this.handleSeeked)}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),this.audio.removeEventListener("seeked",this.handleSeeked)}getCurrentTrack(){return this.playlist[this.currentIndex]}getCurrentIndex(){return this.currentIndex}getPlaylist(){return this.playlist}setPlaylist(e,r=0){this.playlist=[...e],this.currentIndex=v(r,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,r=!1){const t=this.playlist.length===0;this.playlist.push(e);const s=this.playlist.length-1;return this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex),t?this.loadTrack(0,r):r&&this.loadTrack(s,!0),s}addTracks(e,r=!1){if(!e||e.length===0)return;const t=this.playlist.length===0,s=this.playlist.length;this.playlist.push(...e),this.callbacks.onPlaylistChange&&this.callbacks.onPlaylistChange([...this.playlist],this.currentIndex),t?this.loadTrack(0,r):r&&this.loadTrack(s,!0)}removeTrack(e){if(e<0||e>=this.playlist.length)return;const r=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(r){const t=v(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 r=this.getCurrentTrack();return(r==null?void 0:r.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,r=!1){let t;typeof e=="number"?t=v(e,0,Math.max(0,this.playlist.length-1)):(t=this.playlist.findIndex(o=>o.src===e.src),t===-1&&(this.playlist.push(e),t=this.playlist.length-1)),this.currentIndex=t;const s=this.playlist[this.currentIndex];s&&(this.audio.src=s.src,this.callbacks.onTrackChange&&this.callbacks.onTrackChange(s,this.currentIndex),r&&this.play())}async play(){this.initWebAudio();try{await this.audio.play()}catch(e){console.warn("[HoregAudio] Autoplay / Audio play was prevented by browser policy:",e)}}initWebAudio(){if(this.webAudioInitialized){this.audioContext&&this.audioContext.state==="suspended"&&this.audioContext.resume().catch(()=>{});return}try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;this.audioContext=new e,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=128,this.analyser.smoothingTimeConstant=.65,this.sourceNode=this.audioContext.createMediaElementSource(this.audio),this.sourceNode.connect(this.analyser),this.analyser.connect(this.audioContext.destination),this.freqData=new Uint8Array(this.analyser.frequencyBinCount),this.webAudioInitialized=!0}catch{this.webAudioInitialized=!0}}getAudioEnergy(){if(!this.isPlaying())return{bass:0,midHigh:0,left:0,right:0};const e=this.isMuted()?0:Math.max(.35,Math.sqrt(this.volumeLevel));if(this.analyser&&this.freqData&&this.audioContext&&this.audioContext.state==="running")try{this.analyser.getByteFrequencyData(this.freqData);let r=0;const t=Math.min(4,this.freqData.length);for(let x=0;x<t;x++)r+=this.freqData[x];let s=0;const o=Math.min(16,this.freqData.length);for(let x=t;x<o;x++)s+=this.freqData[x];const a=r/(t*255),l=s/((o-t)*255);if(a<.025&&l<.025)return this.bassPulseEnvelope*=.5,this.bassPulseEnvelope<.01&&(this.bassPulseEnvelope=0),{bass:0,midHigh:0,left:0,right:0};const h=Math.max(a,l*.7),p=a*.75;this.bassRollingAvg=this.bassRollingAvg*.92+a*.08;const g=Math.max(0,a-this.bassRollingAvg),b=g>.006?Math.min(1,g*4.5+.3+a*.35):0,u=this.audio.currentTime>0?this.audio.currentTime:Date.now()/1e3,f=(Math.sin(u*13)*.5+.5)*.08*Math.min(1,h*2.5),m=.09*Math.min(1,h*3)+f,y=Math.max(b,p,m);this.bassPulseEnvelope=Math.max(y,this.bassPulseEnvelope*.82);const w=Math.min(1,this.bassPulseEnvelope)*e,k=Math.min(1,l*1.3)*e;return{bass:w,midHigh:k,left:k*.9,right:k*.95}}catch{}if(!this.analyser||!this.audioContext||this.audioContext.state!=="running"){const r=this.audio.currentTime>0?this.audio.currentTime:Date.now()/1e3,s=60/130,o=r%s/s,a=Math.pow(Math.max(0,1-o*2.2),3.2),l=v(Math.max(.12,a),0,1)*e,h=v(Math.sin(r*8)*.25+.35+a*.25,0,1)*e;return{bass:l,midHigh:h,left:h*.85,right:h*.9}}return{bass:0,midHigh:0,left:0,right:0}}pause(){this.audio.pause()}toggle(){this.audio.paused?this.play():this.pause()}seek(e){const r=this.getDuration();this.audio.currentTime=v(e,0,r||0)}setVolume(e){this.volumeLevel=v(e,0,1),this.audio.volume=this.volumeLevel,this.volumeLevel>0&&(this.audio.muted=!1)}toggleMute(){return this.isMuted()?(this.audio.muted=!1,this.audio.volume=this.previousVolume||.8,this.volumeLevel=this.previousVolume||.8,!1):(this.previousVolume=this.volumeLevel,this.audio.muted=!0,!0)}next(e=!1){if(this.playlist.length===0)return;if(this.loopMode==="one"){this.seek(0),this.play();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 r=this.currentIndex+1;r<this.playlist.length?this.loadTrack(r,!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>3){this.seek(0);return}if(this.loopMode==="one"){this.seek(0),this.play();return}if(this.shuffleMode&&this.playlist.length>1){let r;do r=Math.floor(Math.random()*this.playlist.length);while(r===this.currentIndex);this.loadTrack(r,!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(),this.audioContext&&this.audioContext.state!=="closed"&&this.audioContext.close().catch(()=>{})}}const c={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>',volumeMedium:'<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"/></svg>',volumeLow:'<svg viewBox="0 0 24 24" fill="currentColor" width="18" height="18"><path d="M7 9v6h4l5 5V4L11 9H7z"/></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="32" height="32"><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 n(d,e){const r=document.createElement(d);if(e!=null&&e.className&&(r.className=e.className),e!=null&&e.attributes)for(const[t,s]of Object.entries(e.attributes))r.setAttribute(t,s);return e!=null&&e.innerHTML?r.innerHTML=e.innerHTML:e!=null&&e.textContent&&(r.textContent=e.textContent),r}class X{constructor(e){i(this,"root");i(this,"stageContainer");i(this,"eqContainer");i(this,"coverContainer");i(this,"titleWrap");i(this,"playBtn");i(this,"prevBtn");i(this,"nextBtn");i(this,"shuffleBtn");i(this,"loopBtn");i(this,"muteBtn");i(this,"drawerBtn");i(this,"titleEl");i(this,"artistEl");i(this,"albumEl");i(this,"coverImgEl",null);i(this,"currentTimeEl");i(this,"durationEl");i(this,"sliderTrack");i(this,"fillBar");i(this,"bufferBar");i(this,"volumeSlider");i(this,"volumeWrap");i(this,"volumeDropup");i(this,"volumePercentEl");i(this,"drawerEl");i(this,"drawerCountEl");i(this,"addTrackBtn");i(this,"addPanelEl");i(this,"fileInputEl");i(this,"tabBtnFile");i(this,"tabBtnUrl");i(this,"tabPaneFile");i(this,"tabPaneUrl");i(this,"urlInput");i(this,"titleInput");i(this,"artistInput");i(this,"submitUrlBtn");i(this,"cancelAddBtn");i(this,"dropzoneEl");i(this,"drawerInner");i(this,"isScrubbing",!1);i(this,"currentDuration",0);i(this,"events");i(this,"startScrubbing",e=>{e.preventDefault(),this.isScrubbing=!0,document.body.style.userSelect="none",this.handleScrubbingMove(e);const r=s=>{this.isScrubbing&&this.handleScrubbingMove(s)},t=s=>{this.isScrubbing&&(this.finishScrubbing(s),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",t),window.removeEventListener("touchmove",r),window.removeEventListener("touchend",t))};window.addEventListener("mousemove",r),window.addEventListener("mouseup",t),window.addEventListener("touchmove",r,{passive:!1}),window.addEventListener("touchend",t)});this.events=e,this.root=n("div",{className:"horeg-player-box"});const r=n("div",{className:"horeg-speaker-grill"});this.root.appendChild(r),["top-left","top-right","bottom-left","bottom-right"].forEach(k=>{this.root.appendChild(n("div",{className:`horeg-bolt ${k}`}))});const t=n("div",{className:"horeg-content-wrap"});this.root.appendChild(t);const s=n("div",{className:"horeg-header"}),o=n("div",{className:"horeg-rig-badge",innerHTML:'<span class="horeg-badge-led"></span> SOUND HOREG • HIGH VOLTAGE'});s.appendChild(o),t.appendChild(s),this.stageContainer=n("div",{className:"horeg-soundbox-stage"}),this.eqContainer=this.stageContainer,this.coverContainer=n("div",{className:"horeg-sub-cover-wrap"}),this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${c.speaker}</span>`;const a=n("div",{className:"horeg-track-meta"});this.titleWrap=n("div",{className:"horeg-title-wrap"}),this.titleEl=n("div",{className:"horeg-track-title",textContent:"No Track Loaded"}),this.titleWrap.appendChild(this.titleEl),this.artistEl=n("div",{className:"horeg-track-artist",textContent:"Unknown Artist"}),this.albumEl=n("div",{className:"horeg-track-album",textContent:""}),a.appendChild(this.titleWrap),a.appendChild(this.artistEl),a.appendChild(this.albumEl),t.appendChild(this.stageContainer),t.appendChild(a);const l=n("div",{className:"horeg-progress-container"}),h=n("div",{className:"horeg-time-row"});this.currentTimeEl=n("span",{textContent:"00:00"}),this.durationEl=n("span",{textContent:"00:00"}),h.appendChild(this.currentTimeEl),h.appendChild(this.durationEl),l.appendChild(h),this.sliderTrack=n("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=n("div",{className:"horeg-buffer-bar"}),this.fillBar=n("div",{className:"horeg-fill-bar"}),this.sliderTrack.appendChild(this.bufferBar),this.sliderTrack.appendChild(this.fillBar),l.appendChild(this.sliderTrack),t.appendChild(l);const p=n("div",{className:"horeg-controls-row"}),g=n("div",{className:"horeg-side-controls"});this.shuffleBtn=n("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle shuffle","data-tooltip":"Shuffle (S)",type:"button"},innerHTML:c.shuffle}),this.loopBtn=n("button",{className:"horeg-btn active",attributes:{"aria-label":"Toggle loop mode","data-tooltip":"Repeat All (L)",type:"button"},innerHTML:c.repeat}),g.appendChild(this.shuffleBtn),g.appendChild(this.loopBtn),p.appendChild(g);const b=n("div",{className:"horeg-center-controls"});this.prevBtn=n("button",{className:"horeg-btn",attributes:{"aria-label":"Previous track","data-tooltip":"Previous (K)",type:"button"},innerHTML:c.prev}),this.playBtn=n("button",{className:"horeg-btn horeg-btn-play",attributes:{"aria-label":"Play track","data-tooltip":"Play (Space)",type:"button"},innerHTML:c.play}),this.nextBtn=n("button",{className:"horeg-btn",attributes:{"aria-label":"Next track","data-tooltip":"Next (J)",type:"button"},innerHTML:c.next}),b.appendChild(this.prevBtn),b.appendChild(this.playBtn),b.appendChild(this.nextBtn),p.appendChild(b);const u=n("div",{className:"horeg-side-controls"});this.volumeWrap=n("div",{className:"horeg-volume-wrap"}),this.muteBtn=n("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle mute","data-tooltip":"Volume 80% (M)",type:"button"},innerHTML:c.volumeHigh}),this.volumeDropup=n("div",{className:"horeg-volume-dropup"}),this.volumePercentEl=n("span",{className:"horeg-volume-percent",textContent:"80%"}),this.volumeSlider=n("input",{className:"horeg-volume-slider-vertical",attributes:{type:"range",min:"0",max:"1",step:"0.01",value:"0.8",orient:"vertical","aria-label":"Volume control"}}),this.volumeDropup.appendChild(this.volumePercentEl),this.volumeDropup.appendChild(this.volumeSlider),this.volumeWrap.appendChild(this.muteBtn),this.volumeWrap.appendChild(this.volumeDropup),u.appendChild(this.volumeWrap),this.drawerBtn=n("button",{className:"horeg-btn",attributes:{"aria-label":"Toggle playlist drawer","data-tooltip":"Playlist",type:"button"},innerHTML:c.playlist}),u.appendChild(this.drawerBtn),p.appendChild(u),t.appendChild(p),this.drawerEl=n("div",{className:"horeg-drawer"});const f=n("div",{className:"horeg-drawer-header"}),m=n("div",{className:"horeg-drawer-heading"});m.innerHTML="<span>PLAYLIST</span>",this.drawerCountEl=n("span",{className:"horeg-drawer-count",textContent:"0"}),m.appendChild(this.drawerCountEl),f.appendChild(m),this.addTrackBtn=n("button",{className:"horeg-btn-add-track",attributes:{type:"button","aria-label":"Add track to playlist","data-tooltip":"Add Track"},innerHTML:`${c.plus} <span>Add Track</span>`}),f.appendChild(this.addTrackBtn),this.drawerEl.appendChild(f),this.addPanelEl=n("div",{className:"horeg-add-panel"});const y=n("div",{className:"horeg-add-tabs"});this.tabBtnFile=n("button",{className:"horeg-tab-btn active",attributes:{type:"button"},innerHTML:`${c.upload} <span>Local File</span>`}),this.tabBtnUrl=n("button",{className:"horeg-tab-btn",attributes:{type:"button"},innerHTML:`${c.link} <span>Audio URL</span>`}),y.appendChild(this.tabBtnFile),y.appendChild(this.tabBtnUrl),this.addPanelEl.appendChild(y),this.tabPaneFile=n("div",{className:"horeg-tab-pane active"}),this.fileInputEl=n("input",{attributes:{type:"file",accept:"audio/*",multiple:"true",style:"display: none;"}}),this.dropzoneEl=n("div",{className:"horeg-dropzone"}),this.dropzoneEl.innerHTML=`
1209
1450
  <div class="horeg-dropzone-icon">${c.upload}</div>
1210
- <div class="horeg-dropzone-text">Pilih File Audio Komputer</div>
1211
- <div class="horeg-dropzone-hint">Klik di sini atau drag & drop file (.mp3, .wav, .flac, .ogg, .m4a)</div>
1212
- `,this.tabPaneFile.appendChild(this.fileInputEl),this.tabPaneFile.appendChild(this.dropzoneEl),this.addPanelEl.appendChild(this.tabPaneFile),this.tabPaneUrl=s("div",{className:"horeg-tab-pane"}),this.urlInput=s("input",{className:"horeg-input-field",attributes:{type:"url",placeholder:"Audio URL (https://...mp3/wav)",required:"true"}}),this.titleInput=s("input",{className:"horeg-input-field",attributes:{type:"text",placeholder:"Judul Lagu (Opsional)"}}),this.artistInput=s("input",{className:"horeg-input-field",attributes:{type:"text",placeholder:"Nama Artis (Opsional)"}});const w=s("div",{className:"horeg-form-actions"});this.cancelAddBtn=s("button",{className:"horeg-btn-cancel",attributes:{type:"button"},textContent:"Batal"}),this.submitUrlBtn=s("button",{className:"horeg-btn-submit",attributes:{type:"button"},innerHTML:`${c.plus} Tambah`}),w.appendChild(this.cancelAddBtn),w.appendChild(this.submitUrlBtn),this.tabPaneUrl.appendChild(this.urlInput),this.tabPaneUrl.appendChild(this.titleInput),this.tabPaneUrl.appendChild(this.artistInput),this.tabPaneUrl.appendChild(w),this.addPanelEl.appendChild(this.tabPaneUrl),this.drawerEl.appendChild(this.addPanelEl),this.drawerInner=s("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 o;if(t.preventDefault(),this.dropzoneEl.classList.remove("drag-active"),(o=t.dataTransfer)!=null&&o.files&&t.dataTransfer.files.length>0){const n=Array.from(t.dataTransfer.files).filter(a=>a.type.startsWith("audio/")||/\.(mp3|wav|ogg|flac|m4a|aac)$/i.test(a.name));n.length>0&&this.events.onAddTrackFiles&&(this.events.onAddTrackFiles(n),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 o;if(t.preventDefault(),this.root.classList.remove("drag-over"),(o=t.dataTransfer)!=null&&o.files&&t.dataTransfer.files.length>0){const n=Array.from(t.dataTransfer.files).filter(a=>a.type.startsWith("audio/")||/\.(mp3|wav|ogg|flac|m4a|aac)$/i.test(a.name));n.length>0&&this.events.onAddTrackFiles&&(this.events.onAddTrackFiles(n),this.closeAddPanel())}});const e=()=>{const t=this.urlInput.value.trim();if(!t){this.urlInput.focus();return}const o=this.titleInput.value.trim(),n=this.artistInput.value.trim();this.events.onAddTrackUrl&&this.events.onAddTrackUrl(t,o||void 0,n||void 0),this.urlInput.value="",this.titleInput.value="",this.artistInput.value="",this.closeAddPanel()};this.submitUrlBtn.addEventListener("click",e);const r=t=>{t.stopPropagation(),t.key==="Enter"&&(t.preventDefault(),e())};this.urlInput.addEventListener("keydown",r),this.titleInput.addEventListener("keydown",r),this.artistInput.addEventListener("keydown",r),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 o=parseFloat(this.fillBar.style.width)/100*this.currentDuration;this.events.onSeek(Math.min(o+5,this.currentDuration))}else if(t.key==="ArrowLeft"||t.key==="ArrowDown"){t.preventDefault();const o=parseFloat(this.fillBar.style.width)/100*this.currentDuration;this.events.onSeek(Math.max(o-5,0))}}})}calculateProgressPercent(e){var n,a,l,h;const r=this.sliderTrack.getBoundingClientRect(),t="touches"in e?((a=(n=e.touches)==null?void 0:n[0])==null?void 0:a.clientX)??((h=(l=e.changedTouches)==null?void 0:l[0])==null?void 0:h.clientX)??0:e.clientX,o=m(t-r.left,0,r.width);return r.width>0?o/r.width*100:0}handleScrubbingMove(e){const r=this.calculateProgressPercent(e);if(this.fillBar.style.width=`${r}%`,this.sliderTrack.setAttribute("aria-valuenow",Math.round(r).toString()),this.currentDuration>0){const t=r/100*this.currentDuration;this.currentTimeEl.textContent=T(t)}}finishScrubbing(e){const r=this.calculateProgressPercent(e);if(this.fillBar.style.width=`${r}%`,this.sliderTrack.setAttribute("aria-valuenow",Math.round(r).toString()),this.currentDuration>0){const t=r/100*this.currentDuration;this.currentTimeEl.textContent=T(t),this.events.onSeek(t)}this.isScrubbing=!1,document.body.style.userSelect=""}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=s("img",{className:"horeg-cover-img",attributes:{src:e.coverArt,alt:`${e.title} cover`}}),this.coverImgEl.onerror=()=>{this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${c.speaker}</span>`},this.coverContainer.appendChild(this.coverImgEl)):this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${c.speaker}</span>`,this.checkTitleMarquee()}checkTitleMarquee(){!this.titleEl||!this.titleWrap||(this.titleEl.classList.remove("is-marquee"),this.titleWrap.classList.remove("is-overflowing"),this.titleWrap.style.removeProperty("--marquee-dist"),this.titleWrap.style.removeProperty("--marquee-duration"),this.titleEl.style.removeProperty("--marquee-dist"),this.titleEl.style.removeProperty("--marquee-duration"),requestAnimationFrame(()=>{const e=this.titleEl.scrollWidth,r=this.titleWrap.clientWidth;if(e>r&&r>0){const t=e-r+20,o=Math.max(6,Math.round(t/18)+3),n=`-${t}px`,a=`${o}s`;this.titleWrap.style.setProperty("--marquee-dist",n),this.titleWrap.style.setProperty("--marquee-duration",a),this.titleEl.style.setProperty("--marquee-dist",n),this.titleEl.style.setProperty("--marquee-duration",a),this.titleWrap.classList.add("is-overflowing"),this.titleEl.classList.add("is-marquee")}}))}updatePlayState(e){e?(this.playBtn.classList.add("playing"),this.playBtn.innerHTML=c.pause,this.playBtn.setAttribute("aria-label","Pause track")):(this.playBtn.classList.remove("playing"),this.playBtn.innerHTML=c.play,this.playBtn.setAttribute("aria-label","Play track"))}updateProgress(e,r){if(this.currentDuration=r,this.durationEl.textContent=T(r),!this.isScrubbing){this.currentTimeEl.textContent=T(e);const t=r>0?e/r*100:0;this.fillBar.style.width=`${m(t,0,100)}%`,this.sliderTrack.setAttribute("aria-valuenow",Math.round(t).toString())}}updateBuffer(e){this.bufferBar.style.width=`${m(e,0,100)}%`}updateVolume(e,r){this.volumeSlider.value=e.toString(),r||e===0?(this.muteBtn.innerHTML=c.volumeMute,this.muteBtn.setAttribute("aria-label","Unmute")):(this.muteBtn.innerHTML=c.volumeHigh,this.muteBtn.setAttribute("aria-label","Mute"))}updateLoopState(e){e==="none"?(this.loopBtn.classList.remove("active"),this.loopBtn.innerHTML=c.repeat):e==="all"?(this.loopBtn.classList.add("active"),this.loopBtn.innerHTML=c.repeat):e==="one"&&(this.loopBtn.classList.add("active"),this.loopBtn.innerHTML=c.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,r){if(this.drawerCountEl.textContent=e.length.toString(),this.drawerInner.innerHTML="",e.length===0){const t=s("div",{className:"horeg-empty-playlist",textContent:'Playlist masih kosong. Klik "Add Track" untuk menambahkan lagu.'});this.drawerInner.appendChild(t);return}e.forEach((t,o)=>{const n=s("div",{className:`horeg-track-item ${o===r?"active":""}`}),a=s("div",{className:"horeg-track-num",textContent:(o+1).toString().padStart(2,"0")});n.appendChild(a);const l=s("div",{className:"horeg-track-details"}),h=s("div",{className:"horeg-item-title",textContent:t.title}),g=s("div",{className:"horeg-item-artist",textContent:t.artist||"Unknown Artist"});if(l.appendChild(h),l.appendChild(g),n.appendChild(l),t.duration){const u=s("div",{className:"horeg-item-duration",textContent:T(t.duration)});n.appendChild(u)}const p=s("div",{className:"horeg-track-actions"}),b=s("button",{className:"horeg-btn-remove",attributes:{type:"button","aria-label":"Hapus lagu dari playlist"},innerHTML:c.trash});b.addEventListener("click",u=>{u.stopPropagation(),this.events.onRemoveTrack&&this.events.onRemoveTrack(o)}),p.appendChild(b),n.appendChild(p),n.addEventListener("click",()=>{this.events.onTrackSelect(o)}),this.drawerInner.appendChild(n)})}destroy(){this.root.remove()}}class O{constructor(e){i(this,"stageContainer");i(this,"coverContainer",null);i(this,"isEnabled",!0);i(this,"isRunning",!1);i(this,"animFrameId",null);i(this,"getAudioEnergy");i(this,"leftBoxEl");i(this,"leftTopDriverEl");i(this,"leftBottomDriverEl");i(this,"leftRipples",[]);i(this,"subBoxEl");i(this,"subConeEl");i(this,"shockwave1El");i(this,"shockwave2El");i(this,"rightBoxEl");i(this,"rightTopDriverEl");i(this,"rightBottomDriverEl");i(this,"rightRipples",[]);i(this,"smoothBass",0);i(this,"smoothLeft",0);i(this,"smoothRight",0);i(this,"loop",()=>{if(!this.isRunning)return;const e=this.getAudioEnergy?this.getAudioEnergy():{bass:0,left:0,right:0},r=e.bass<.01?0:e.bass,t=e.left<.01?0:e.left,o=e.right<.01?0:e.right;r>this.smoothBass?this.smoothBass+=(r-this.smoothBass)*.7:this.smoothBass+=(r-this.smoothBass)*.25,this.smoothBass<.01&&(this.smoothBass=0),this.smoothLeft+=(t-this.smoothLeft)*.4,this.smoothLeft<.01&&(this.smoothLeft=0),this.smoothRight+=(o-this.smoothRight)*.4,this.smoothRight<.01&&(this.smoothRight=0),this.applyExcursion(this.smoothBass,this.smoothLeft,this.smoothRight),this.animFrameId=requestAnimationFrame(this.loop)});this.stageContainer=e.stageContainer,this.coverContainer=e.coverContainer||null,this.isEnabled=e.enableAnimation!==!1,this.getAudioEnergy=e.getAudioEnergy,this.buildStage()}setAudioEnergyGetter(e){this.getAudioEnergy=e}buildStage(){this.stageContainer.innerHTML="",this.leftBoxEl=document.createElement("div"),this.leftBoxEl.className="horeg-soundbox is-satellite is-left",this.leftBoxEl.innerHTML=`
1451
+ <div class="horeg-dropzone-text">Choose Local Audio File</div>
1452
+ <div class="horeg-dropzone-hint">Click here or drag & drop audio files (.mp3, .wav, .flac, .ogg, .m4a)</div>
1453
+ `,this.tabPaneFile.appendChild(this.fileInputEl),this.tabPaneFile.appendChild(this.dropzoneEl),this.addPanelEl.appendChild(this.tabPaneFile),this.tabPaneUrl=n("div",{className:"horeg-tab-pane"}),this.urlInput=n("input",{className:"horeg-input-field",attributes:{type:"url",placeholder:"Audio URL (https://...mp3/wav)",required:"true"}}),this.titleInput=n("input",{className:"horeg-input-field",attributes:{type:"text",placeholder:"Track Title (Optional)"}}),this.artistInput=n("input",{className:"horeg-input-field",attributes:{type:"text",placeholder:"Artist Name (Optional)"}});const w=n("div",{className:"horeg-form-actions"});this.cancelAddBtn=n("button",{className:"horeg-btn-cancel",attributes:{type:"button"},textContent:"Cancel"}),this.submitUrlBtn=n("button",{className:"horeg-btn-submit",attributes:{type:"button"},innerHTML:`${c.plus} Add Track`}),w.appendChild(this.cancelAddBtn),w.appendChild(this.submitUrlBtn),this.tabPaneUrl.appendChild(this.urlInput),this.tabPaneUrl.appendChild(this.titleInput),this.tabPaneUrl.appendChild(this.artistInput),this.tabPaneUrl.appendChild(w),this.addPanelEl.appendChild(this.tabPaneUrl),this.drawerEl.appendChild(this.addPanelEl),this.drawerInner=n("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",()=>{const t=parseFloat(this.volumeSlider.value);this.events.onVolumeChange(t);const s=Math.round(t*100);this.volumePercentEl.textContent=t===0?"MUTE":`${s}%`}),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 s;if(t.preventDefault(),this.dropzoneEl.classList.remove("drag-active"),(s=t.dataTransfer)!=null&&s.files&&t.dataTransfer.files.length>0){const o=Array.from(t.dataTransfer.files).filter(a=>a.type.startsWith("audio/")||/\.(mp3|wav|ogg|flac|m4a|aac)$/i.test(a.name));o.length>0&&this.events.onAddTrackFiles&&(this.events.onAddTrackFiles(o),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 s;if(t.preventDefault(),this.root.classList.remove("drag-over"),(s=t.dataTransfer)!=null&&s.files&&t.dataTransfer.files.length>0){const o=Array.from(t.dataTransfer.files).filter(a=>a.type.startsWith("audio/")||/\.(mp3|wav|ogg|flac|m4a|aac)$/i.test(a.name));o.length>0&&this.events.onAddTrackFiles&&(this.events.onAddTrackFiles(o),this.closeAddPanel())}});const e=()=>{const t=this.urlInput.value.trim();if(!t){this.urlInput.focus();return}const s=this.titleInput.value.trim(),o=this.artistInput.value.trim();this.events.onAddTrackUrl&&this.events.onAddTrackUrl(t,s||void 0,o||void 0),this.urlInput.value="",this.titleInput.value="",this.artistInput.value="",this.closeAddPanel()};this.submitUrlBtn.addEventListener("click",e);const r=t=>{t.stopPropagation(),t.key==="Enter"&&(t.preventDefault(),e())};this.urlInput.addEventListener("keydown",r),this.titleInput.addEventListener("keydown",r),this.artistInput.addEventListener("keydown",r),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 s=parseFloat(this.fillBar.style.width)/100*this.currentDuration;this.events.onSeek(Math.min(s+5,this.currentDuration))}else if(t.key==="ArrowLeft"||t.key==="ArrowDown"){t.preventDefault();const s=parseFloat(this.fillBar.style.width)/100*this.currentDuration;this.events.onSeek(Math.max(s-5,0))}}})}calculateProgressPercent(e){var o,a,l,h;const r=this.sliderTrack.getBoundingClientRect(),t="touches"in e?((a=(o=e.touches)==null?void 0:o[0])==null?void 0:a.clientX)??((h=(l=e.changedTouches)==null?void 0:l[0])==null?void 0:h.clientX)??0:e.clientX,s=v(t-r.left,0,r.width);return r.width>0?s/r.width*100:0}handleScrubbingMove(e){const r=this.calculateProgressPercent(e);if(this.fillBar.style.width=`${r}%`,this.sliderTrack.setAttribute("aria-valuenow",Math.round(r).toString()),this.currentDuration>0){const t=r/100*this.currentDuration;this.currentTimeEl.textContent=T(t)}}finishScrubbing(e){const r=this.calculateProgressPercent(e);if(this.fillBar.style.width=`${r}%`,this.sliderTrack.setAttribute("aria-valuenow",Math.round(r).toString()),this.currentDuration>0){const t=r/100*this.currentDuration;this.currentTimeEl.textContent=T(t),this.events.onSeek(t)}this.isScrubbing=!1,document.body.style.userSelect=""}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=n("img",{className:"horeg-cover-img",attributes:{src:e.coverArt,alt:`${e.title} cover`}}),this.coverImgEl.onerror=()=>{this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${c.speaker}</span>`},this.coverContainer.appendChild(this.coverImgEl)):this.coverContainer.innerHTML=`<span class="horeg-cover-fallback">${c.speaker}</span>`,this.checkTitleMarquee()}checkTitleMarquee(){!this.titleEl||!this.titleWrap||(this.titleEl.classList.remove("is-marquee"),this.titleWrap.classList.remove("is-overflowing"),this.titleWrap.style.removeProperty("--marquee-dist"),this.titleWrap.style.removeProperty("--marquee-duration"),this.titleEl.style.removeProperty("--marquee-dist"),this.titleEl.style.removeProperty("--marquee-duration"),requestAnimationFrame(()=>{const e=this.titleEl.scrollWidth,r=this.titleWrap.clientWidth;if(e>r&&r>0){const t=e-r+20,s=Math.max(6,Math.round(t/18)+3),o=`-${t}px`,a=`${s}s`;this.titleWrap.style.setProperty("--marquee-dist",o),this.titleWrap.style.setProperty("--marquee-duration",a),this.titleEl.style.setProperty("--marquee-dist",o),this.titleEl.style.setProperty("--marquee-duration",a),this.titleWrap.classList.add("is-overflowing"),this.titleEl.classList.add("is-marquee")}}))}updatePlayState(e){e?(this.playBtn.classList.add("playing"),this.playBtn.innerHTML=c.pause,this.playBtn.setAttribute("aria-label","Pause track"),this.playBtn.setAttribute("data-tooltip","Pause (Space)")):(this.playBtn.classList.remove("playing"),this.playBtn.innerHTML=c.play,this.playBtn.setAttribute("aria-label","Play track"),this.playBtn.setAttribute("data-tooltip","Play (Space)"))}updateProgress(e,r){if(this.currentDuration=r,this.durationEl.textContent=T(r),!this.isScrubbing){this.currentTimeEl.textContent=T(e);const t=r>0?e/r*100:0;this.fillBar.style.width=`${v(t,0,100)}%`,this.sliderTrack.setAttribute("aria-valuenow",Math.round(t).toString())}}updateBuffer(e){this.bufferBar.style.width=`${v(e,0,100)}%`}updateVolume(e,r){this.volumeSlider.value=e.toString();const t=Math.round(e*100);r||e===0?(this.muteBtn.innerHTML=c.volumeMute,this.muteBtn.setAttribute("aria-label","Unmute"),this.muteBtn.setAttribute("data-tooltip","Unmute (M)"),this.volumePercentEl.textContent="MUTE"):(this.volumePercentEl.textContent=`${t}%`,this.muteBtn.setAttribute("data-tooltip",`Volume ${t}% (M)`),e<=.35?(this.muteBtn.innerHTML=c.volumeLow,this.muteBtn.setAttribute("aria-label","Volume low")):e<=.7?(this.muteBtn.innerHTML=c.volumeMedium,this.muteBtn.setAttribute("aria-label","Volume medium")):(this.muteBtn.innerHTML=c.volumeHigh,this.muteBtn.setAttribute("aria-label","Volume high")))}updateLoopState(e){e==="none"?(this.loopBtn.classList.remove("active"),this.loopBtn.innerHTML=c.repeat,this.loopBtn.setAttribute("data-tooltip","Repeat Off (L)")):e==="all"?(this.loopBtn.classList.add("active"),this.loopBtn.innerHTML=c.repeat,this.loopBtn.setAttribute("data-tooltip","Repeat All (L)")):e==="one"&&(this.loopBtn.classList.add("active"),this.loopBtn.innerHTML=c.repeatOne,this.loopBtn.setAttribute("data-tooltip","Repeat One (L)")),this.loopBtn.setAttribute("aria-label",`Repeat mode: ${e}`)}updateShuffleState(e){e?(this.shuffleBtn.classList.add("active"),this.shuffleBtn.setAttribute("data-tooltip","Shuffle Off (S)")):(this.shuffleBtn.classList.remove("active"),this.shuffleBtn.setAttribute("data-tooltip","Shuffle (S)"))}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,r){if(this.drawerCountEl.textContent=e.length.toString(),this.drawerInner.innerHTML="",e.length===0){const t=n("div",{className:"horeg-empty-playlist",textContent:'Playlist is empty. Click "Add Track" to add music.'});this.drawerInner.appendChild(t);return}e.forEach((t,s)=>{const o=n("div",{className:`horeg-track-item ${s===r?"active":""}`}),a=n("div",{className:"horeg-track-num",textContent:(s+1).toString().padStart(2,"0")});o.appendChild(a);const l=n("div",{className:"horeg-track-details"}),h=n("div",{className:"horeg-item-title",textContent:t.title}),p=n("div",{className:"horeg-item-artist",textContent:t.artist||"Unknown Artist"});if(l.appendChild(h),l.appendChild(p),o.appendChild(l),t.duration){const u=n("div",{className:"horeg-item-duration",textContent:T(t.duration)});o.appendChild(u)}const g=n("div",{className:"horeg-track-actions"}),b=n("button",{className:"horeg-btn-remove",attributes:{type:"button","aria-label":"Remove track from playlist","data-tooltip":"Remove"},innerHTML:c.trash});b.addEventListener("click",u=>{u.stopPropagation(),this.events.onRemoveTrack&&this.events.onRemoveTrack(s)}),g.appendChild(b),o.appendChild(g),o.addEventListener("click",()=>{this.events.onTrackSelect(s)}),this.drawerInner.appendChild(o)})}destroy(){this.root.remove()}}class K{constructor(e){i(this,"stageContainer");i(this,"coverContainer",null);i(this,"isEnabled",!0);i(this,"isRunning",!1);i(this,"animFrameId",null);i(this,"getAudioEnergy");i(this,"leftBoxEl");i(this,"leftTopDriverEl");i(this,"leftBottomDriverEl");i(this,"leftRipples",[]);i(this,"subBoxEl");i(this,"subConeEl");i(this,"shockwave1El");i(this,"shockwave2El");i(this,"rightBoxEl");i(this,"rightTopDriverEl");i(this,"rightBottomDriverEl");i(this,"rightRipples",[]);i(this,"smoothBass",0);i(this,"smoothLeft",0);i(this,"smoothRight",0);i(this,"loop",()=>{if(!this.isRunning)return;const e=this.getAudioEnergy?this.getAudioEnergy():{bass:0,left:0,right:0},r=e.bass<.01?0:e.bass,t=e.left<.01?0:e.left,s=e.right<.01?0:e.right;r>this.smoothBass?this.smoothBass+=(r-this.smoothBass)*.7:this.smoothBass+=(r-this.smoothBass)*.25,this.smoothBass<.01&&(this.smoothBass=0),this.smoothLeft+=(t-this.smoothLeft)*.4,this.smoothLeft<.01&&(this.smoothLeft=0),this.smoothRight+=(s-this.smoothRight)*.4,this.smoothRight<.01&&(this.smoothRight=0),this.applyExcursion(this.smoothBass,this.smoothLeft,this.smoothRight),this.animFrameId=requestAnimationFrame(this.loop)});this.stageContainer=e.stageContainer,this.coverContainer=e.coverContainer||null,this.isEnabled=e.enableAnimation!==!1,this.getAudioEnergy=e.getAudioEnergy,this.buildStage()}setAudioEnergyGetter(e){this.getAudioEnergy=e}buildStage(){this.stageContainer.innerHTML="",this.leftBoxEl=document.createElement("div"),this.leftBoxEl.className="horeg-soundbox is-satellite is-left",this.leftBoxEl.innerHTML=`
1213
1454
  <div class="horeg-box-header">
1214
1455
  <span class="horeg-box-bolt top-left"></span>
1215
1456
  <span class="horeg-tweeter-slot"></span>
@@ -1252,7 +1493,7 @@
1252
1493
  <span class="horeg-sub-port left"></span>
1253
1494
  <span class="horeg-sub-port right"></span>
1254
1495
  </div>
1255
- `;const t=document.createElement("div");t.className="horeg-sub-baffle";const o=document.createElement("div");o.className="horeg-sub-surround",this.subConeEl=document.createElement("div"),this.subConeEl.className="horeg-sub-cone",this.coverContainer&&this.subConeEl.appendChild(this.coverContainer),o.appendChild(this.subConeEl),t.appendChild(o),this.subBoxEl.appendChild(r),this.subBoxEl.appendChild(t),this.stageContainer.appendChild(this.subBoxEl),this.rightBoxEl=document.createElement("div"),this.rightBoxEl.className="horeg-soundbox is-satellite is-right",this.rightBoxEl.innerHTML=`
1496
+ `;const t=document.createElement("div");t.className="horeg-sub-baffle";const s=document.createElement("div");s.className="horeg-sub-surround",this.subConeEl=document.createElement("div"),this.subConeEl.className="horeg-sub-cone",this.coverContainer&&this.subConeEl.appendChild(this.coverContainer),s.appendChild(this.subConeEl),t.appendChild(s),this.subBoxEl.appendChild(r),this.subBoxEl.appendChild(t),this.stageContainer.appendChild(this.subBoxEl),this.rightBoxEl=document.createElement("div"),this.rightBoxEl.className="horeg-soundbox is-satellite is-right",this.rightBoxEl.innerHTML=`
1256
1497
  <div class="horeg-box-header">
1257
1498
  <span class="horeg-box-bolt top-left"></span>
1258
1499
  <span class="horeg-tweeter-slot"></span>
@@ -1285,5 +1526,5 @@
1285
1526
  <span class="horeg-port-slot"></span>
1286
1527
  <span class="horeg-box-bolt bottom-right"></span>
1287
1528
  </div>
1288
- `,this.rightTopDriverEl=this.rightBoxEl.querySelector(".top .horeg-driver-cone"),this.rightBottomDriverEl=this.rightBoxEl.querySelector(".bottom .horeg-driver-cone"),this.rightRipples=Array.from(this.rightBoxEl.querySelectorAll(".horeg-driver-ripple")),this.stageContainer.appendChild(this.rightBoxEl)}setCoverContainer(e){this.coverContainer=e,this.subConeEl&&!this.subConeEl.contains(e)&&(this.subConeEl.innerHTML="",this.subConeEl.appendChild(e))}setEnabled(e){this.isEnabled=e,e||this.stop()}start(){this.isRunning||!this.isEnabled||(this.isRunning=!0,this.loop())}stop(){this.isRunning=!1,this.decayToIdle()}decayToIdle(){this.animFrameId!==null&&(cancelAnimationFrame(this.animFrameId),this.animFrameId=null);const e=()=>{this.smoothBass*=.8,this.smoothLeft*=.8,this.smoothRight*=.8,this.applyExcursion(this.smoothBass,this.smoothLeft,this.smoothRight),this.smoothBass>.005||this.smoothLeft>.005||this.smoothRight>.005?this.animFrameId=requestAnimationFrame(e):(this.smoothBass=0,this.smoothLeft=0,this.smoothRight=0,this.applyExcursion(0,0,0),this.animFrameId=null)};this.animFrameId=requestAnimationFrame(e)}applyExcursion(e,r,t){const o=1+e*.34;this.subConeEl.style.transform=`scale(${o.toFixed(3)})`;const n=1+e*.04;if(this.subBoxEl.style.transform=`scale(${n.toFixed(3)})`,e>.18){const g=(e-.18)/.82,p=1+g*.7,b=Math.min(.95,g*1.3);this.shockwave1El.style.transform=`scale(${p.toFixed(3)})`,this.shockwave1El.style.opacity=b.toFixed(2);const u=1+g*1.1,v=Math.max(0,(g-.2)*1.2);this.shockwave2El.style.transform=`scale(${u.toFixed(3)})`,this.shockwave2El.style.opacity=v.toFixed(2)}else this.shockwave1El.style.transform="scale(1)",this.shockwave1El.style.opacity="0",this.shockwave2El.style.transform="scale(1)",this.shockwave2El.style.opacity="0";const a=1+r*.1;this.leftTopDriverEl&&(this.leftTopDriverEl.style.transform=`scale(${a.toFixed(3)})`),this.leftBottomDriverEl&&(this.leftBottomDriverEl.style.transform=`scale(${a.toFixed(3)})`);const l=1+t*.1;this.rightTopDriverEl&&(this.rightTopDriverEl.style.transform=`scale(${l.toFixed(3)})`),this.rightBottomDriverEl&&(this.rightBottomDriverEl.style.transform=`scale(${l.toFixed(3)})`);const h=(g,p)=>{const b=p>.06;for(let u=0;u<g.length;u++){const v=g[u],x=v.classList.contains("ripple-2");if(!b){v.style.transform="scale(1)",v.style.opacity="0";continue}const y=1+p*(x?.42:.28),f=Math.max(0,Math.min(1,p*(x?.65:.85)-(x?.15:.05)));v.style.transform=`scale(${y.toFixed(3)})`,v.style.opacity=f.toFixed(2)}};h(this.leftRipples,r),h(this.rightRipples,t)}destroy(){this.stop(),this.stageContainer.innerHTML=""}}class C{constructor(e){i(this,"container");i(this,"shadow");i(this,"styleEl");i(this,"audioEngine");i(this,"ui");i(this,"visualizer");i(this,"theme");i(this,"boundKeyHandler");var n;if(typeof e.container=="string"){const a=document.querySelector(e.container);if(!a)throw new Error(`[HoregAudio] Container "${e.container}" not found in DOM.`);this.container=a}else if(e.container instanceof HTMLElement)this.container=e.container;else throw new Error("[HoregAudio] Invalid container option provided.");const r=((n=e.theme)==null?void 0:n.variant)||"horeg-classic",t=E[r]||E["horeg-classic"];this.theme={...t,...e.theme||{}},this.shadow=this.container.attachShadow({mode:"open"}),this.styleEl=document.createElement("style"),this.styleEl.textContent=L(this.theme),this.shadow.appendChild(this.styleEl),this.ui=new W({onPlayPauseClick:()=>this.toggle(),onPrevClick:()=>this.prev(),onNextClick:()=>this.next(),onSeek:a=>this.seek(a),onVolumeChange:a=>this.setVolume(a),onMuteToggle:()=>{const a=this.audioEngine.toggleMute();this.ui.updateVolume(this.audioEngine.getVolume(),a)},onShuffleToggle:()=>{const a=!this.audioEngine.isShuffle();this.audioEngine.setShuffle(a),this.ui.updateShuffleState(a)},onLoopToggle:()=>{const a=this.audioEngine.getLoop(),l=a==="all"?"one":a==="one"?"none":"all";this.audioEngine.setLoop(l),this.ui.updateLoopState(l)},onTrackSelect:a=>{this.loadTrack(a,!0)},onAddTrackFiles:a=>{this.addTrackFromFiles(a,!1)},onAddTrackUrl:(a,l,h)=>{this.addTrackFromUrl(a,{title:l,artist:h},!1)},onRemoveTrack:a=>{this.removeTrack(a)}}),this.shadow.appendChild(this.ui.root),this.visualizer=new O({stageContainer:this.ui.stageContainer,coverContainer:this.ui.coverContainer,enableAnimation:this.theme.enableEqAnimation!==!1}),this.audioEngine=new j(e,{onPlay:a=>{this.ui.updatePlayState(!0),this.visualizer.start(),e.onPlay&&e.onPlay(a)},onPause:()=>{this.ui.updatePlayState(!1),this.visualizer.stop(),e.onPause&&e.onPause()},onTrackChange:(a,l)=>{this.ui.updateTrackInfo(a);const h=this.audioEngine?this.audioEngine.getPlaylist():e.playlist||[];this.ui.renderPlaylist(h,l),this.ui.updateProgress(0,a.duration||0),e.onTrackChange&&e.onTrackChange(a,l)},onPlaylistChange:(a,l)=>{this.ui.renderPlaylist(a,l),e.onPlaylistChange&&e.onPlaylistChange(a,l)},onTimeUpdate:(a,l)=>{this.ui.updateProgress(a,l),e.onTimeUpdate&&e.onTimeUpdate(a,l)},onBufferUpdate:a=>{this.ui.updateBuffer(a)},onEnded:a=>{this.visualizer.stop(),e.onEnded&&e.onEnded(a)},onError:a=>{this.ui.updatePlayState(!1),this.visualizer.stop(),e.onError&&e.onError(a)}}),this.visualizer.setAudioEnergyGetter(()=>this.audioEngine.getAudioEnergy()),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 o=this.audioEngine.getCurrentTrack();o&&(this.ui.updateTrackInfo(o),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 a;const r=e.composedPath?e.composedPath():[],t=r.length>0?r[0]:e.target,o=((a=this.shadow)==null?void 0:a.activeElement)||document.activeElement,n=l=>{if(!l)return!1;const h=l.tagName;return h==="INPUT"||h==="TEXTAREA"||h==="SELECT"||l.isContentEditable};if(!(n(t)||n(o)))if(e.code==="Space"){if((t==null?void 0:t.tagName)==="BUTTON"||(o==null?void 0:o.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,r=!1){this.audioEngine.loadTrack(e,r)}addTrack(e,r=!1){const t=this.audioEngine.addTrack(e,r);return this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex()),t}addTracks(e,r=!1){this.audioEngine.addTracks(e,r),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex())}async addTrackFromFile(e,r=!1){const t=URL.createObjectURL(e),o=e.name.replace(/\.[^/.]+$/,""),n={id:`local-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,title:o,artist:"File Audio Lokal",src:t};try{const a=await this.probeAudioDuration(t);a>0&&(n.duration=a)}catch{}return this.addTrack(n,r),n}async addTrackFromFiles(e,r=!1){const t=Array.from(e),o=[];for(let n=0;n<t.length;n++){const a=t[n],l=r&&n===0,h=await this.addTrackFromFile(a,l);o.push(h)}return o}async addTrackFromUrl(e,r={},t=!1){var a,l;let o="Online Track";try{const g=new URL(e).pathname,p=g.substring(g.lastIndexOf("/")+1);p&&(o=decodeURIComponent(p).replace(/\.[^/.]+$/,""))}catch{}const n={id:r.id||`url-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,title:((a=r.title)==null?void 0:a.trim())||o,artist:((l=r.artist)==null?void 0:l.trim())||"Audio Stream",album:r.album,coverArt:r.coverArt,src:e,duration:r.duration};if(!n.duration)try{const h=await this.probeAudioDuration(e);h>0&&(n.duration=h)}catch{}return this.addTrack(n,t),n}removeTrack(e){this.audioEngine.removeTrack(e),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex());const r=this.audioEngine.getCurrentTrack();r?this.ui.updateTrackInfo(r):this.ui.updateTrackInfo({title:"No Track Loaded",src:""})}getPlaylist(){return this.audioEngine.getPlaylist()}probeAudioDuration(e){return new Promise(r=>{const t=new Audio;let o=!1;const n=h=>{o||(o=!0,t.removeEventListener("loadedmetadata",a),t.removeEventListener("error",l),t.src="",r(h))},a=()=>{const h=t.duration;n(h&&!isNaN(h)&&isFinite(h)?h:0)},l=()=>n(0);t.addEventListener("loadedmetadata",a),t.addEventListener("error",l),t.src=e,setTimeout(()=>n(0),3e3)})}setTheme(e){if(e.variant){const r=E[e.variant]||E["horeg-classic"];this.theme={...r,...e}}else this.theme={...this.theme,...e};this.styleEl.textContent=L(this.theme),this.theme.enableEqAnimation!==void 0&&this.visualizer.setEnabled(this.theme.enableEqAnimation)}getTheme(){return{...this.theme}}getAudioEngine(){return this.audioEngine}destroy(){this.container.removeEventListener("keydown",this.boundKeyHandler),this.audioEngine.destroy(),this.visualizer.destroy(),this.ui.destroy(),this.shadow.innerHTML=""}}C.HoregAudio=C;C.default=C;C.THEME_PRESETS=E;C.generateStyles=L;exports.HoregAudio=C;exports.THEME_PRESETS=E;exports.default=C;exports.generateStyles=L;module.exports=Object.assign(exports.default||exports.HoregAudio,exports);
1529
+ `,this.rightTopDriverEl=this.rightBoxEl.querySelector(".top .horeg-driver-cone"),this.rightBottomDriverEl=this.rightBoxEl.querySelector(".bottom .horeg-driver-cone"),this.rightRipples=Array.from(this.rightBoxEl.querySelectorAll(".horeg-driver-ripple")),this.stageContainer.appendChild(this.rightBoxEl)}setCoverContainer(e){this.coverContainer=e,this.subConeEl&&!this.subConeEl.contains(e)&&(this.subConeEl.innerHTML="",this.subConeEl.appendChild(e))}setEnabled(e){this.isEnabled=e,e||this.stop()}start(){this.isRunning||!this.isEnabled||(this.isRunning=!0,this.loop())}stop(){this.isRunning=!1,this.decayToIdle()}decayToIdle(){this.animFrameId!==null&&(cancelAnimationFrame(this.animFrameId),this.animFrameId=null);const e=()=>{this.smoothBass*=.8,this.smoothLeft*=.8,this.smoothRight*=.8,this.applyExcursion(this.smoothBass,this.smoothLeft,this.smoothRight),this.smoothBass>.005||this.smoothLeft>.005||this.smoothRight>.005?this.animFrameId=requestAnimationFrame(e):(this.smoothBass=0,this.smoothLeft=0,this.smoothRight=0,this.applyExcursion(0,0,0),this.animFrameId=null)};this.animFrameId=requestAnimationFrame(e)}applyExcursion(e,r,t){const s=1+e*.34;this.subConeEl.style.transform=`scale(${s.toFixed(3)})`;const o=1+e*.04;if(this.subBoxEl.style.transform=`scale(${o.toFixed(3)})`,e>.18){const p=(e-.18)/.82,g=1+p*.7,b=Math.min(.95,p*1.3);this.shockwave1El.style.transform=`scale(${g.toFixed(3)})`,this.shockwave1El.style.opacity=b.toFixed(2);const u=1+p*1.1,f=Math.max(0,(p-.2)*1.2);this.shockwave2El.style.transform=`scale(${u.toFixed(3)})`,this.shockwave2El.style.opacity=f.toFixed(2)}else this.shockwave1El.style.transform="scale(1)",this.shockwave1El.style.opacity="0",this.shockwave2El.style.transform="scale(1)",this.shockwave2El.style.opacity="0";const a=1+r*.1;this.leftTopDriverEl&&(this.leftTopDriverEl.style.transform=`scale(${a.toFixed(3)})`),this.leftBottomDriverEl&&(this.leftBottomDriverEl.style.transform=`scale(${a.toFixed(3)})`);const l=1+t*.1;this.rightTopDriverEl&&(this.rightTopDriverEl.style.transform=`scale(${l.toFixed(3)})`),this.rightBottomDriverEl&&(this.rightBottomDriverEl.style.transform=`scale(${l.toFixed(3)})`);const h=(p,g)=>{const b=g>.06;for(let u=0;u<p.length;u++){const f=p[u],m=f.classList.contains("ripple-2");if(!b){f.style.transform="scale(1)",f.style.opacity="0";continue}const w=1+g*(m?.42:.28),x=Math.max(0,Math.min(1,g*(m?.65:.85)-(m?.15:.05)));f.style.transform=`scale(${w.toFixed(3)})`,f.style.opacity=x.toFixed(2)}};h(this.leftRipples,r),h(this.rightRipples,t)}destroy(){this.stop(),this.stageContainer.innerHTML=""}}class C{constructor(e){i(this,"container");i(this,"shadow");i(this,"styleEl");i(this,"audioEngine");i(this,"ui");i(this,"visualizer");i(this,"theme");i(this,"boundKeyHandler");var o;if(typeof e.container=="string"){const a=document.querySelector(e.container);if(!a)throw new Error(`[HoregAudio] Container "${e.container}" not found in DOM.`);this.container=a}else if(e.container instanceof HTMLElement)this.container=e.container;else throw new Error("[HoregAudio] Invalid container option provided.");const r=((o=e.theme)==null?void 0:o.variant)||"horeg-classic",t=E[r]||E["horeg-classic"];this.theme={...t,...e.theme||{}},this.shadow=this.container.attachShadow({mode:"open"}),this.styleEl=document.createElement("style"),this.styleEl.textContent=L(this.theme,e.maxWidth),this.shadow.appendChild(this.styleEl),this.ui=new X({onPlayPauseClick:()=>this.toggle(),onPrevClick:()=>this.prev(),onNextClick:()=>this.next(),onSeek:a=>this.seek(a),onVolumeChange:a=>this.setVolume(a),onMuteToggle:()=>{const a=this.audioEngine.toggleMute();this.ui.updateVolume(this.audioEngine.getVolume(),a)},onShuffleToggle:()=>{const a=!this.audioEngine.isShuffle();this.audioEngine.setShuffle(a),this.ui.updateShuffleState(a)},onLoopToggle:()=>{const a=this.audioEngine.getLoop(),l=a==="all"?"one":a==="one"?"none":"all";this.audioEngine.setLoop(l),this.ui.updateLoopState(l)},onTrackSelect:a=>{this.loadTrack(a,!0)},onAddTrackFiles:a=>{this.addTrackFromFiles(a,!1)},onAddTrackUrl:(a,l,h)=>{this.addTrackFromUrl(a,{title:l,artist:h},!1)},onRemoveTrack:a=>{this.removeTrack(a)}}),this.shadow.appendChild(this.ui.root),this.visualizer=new K({stageContainer:this.ui.stageContainer,coverContainer:this.ui.coverContainer,enableAnimation:this.theme.enableEqAnimation!==!1}),this.audioEngine=new O(e,{onPlay:a=>{this.ui.updatePlayState(!0),this.visualizer.start(),e.onPlay&&e.onPlay(a)},onPause:()=>{this.ui.updatePlayState(!1),this.visualizer.stop(),e.onPause&&e.onPause()},onTrackChange:(a,l)=>{this.ui.updateTrackInfo(a);const h=this.audioEngine?this.audioEngine.getPlaylist():e.playlist||[];this.ui.renderPlaylist(h,l),this.ui.updateProgress(0,a.duration||0),e.onTrackChange&&e.onTrackChange(a,l)},onPlaylistChange:(a,l)=>{this.ui.renderPlaylist(a,l),e.onPlaylistChange&&e.onPlaylistChange(a,l)},onTimeUpdate:(a,l)=>{this.ui.updateProgress(a,l),e.onTimeUpdate&&e.onTimeUpdate(a,l)},onBufferUpdate:a=>{this.ui.updateBuffer(a)},onEnded:a=>{this.visualizer.stop(),e.onEnded&&e.onEnded(a)},onError:a=>{this.ui.updatePlayState(!1),this.visualizer.stop(),e.onError&&e.onError(a)}}),this.visualizer.setAudioEnergyGetter(()=>this.audioEngine.getAudioEnergy()),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 s=this.audioEngine.getCurrentTrack();s&&(this.ui.updateTrackInfo(s),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 a;const r=e.composedPath?e.composedPath():[],t=r.length>0?r[0]:e.target,s=((a=this.shadow)==null?void 0:a.activeElement)||document.activeElement,o=l=>{if(!l)return!1;const h=l.tagName;return h==="INPUT"||h==="TEXTAREA"||h==="SELECT"||l.isContentEditable};if(!(o(t)||o(s)))if(e.code==="Space"){if((t==null?void 0:t.tagName)==="BUTTON"||(s==null?void 0:s.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,r=!1){this.audioEngine.loadTrack(e,r)}addTrack(e,r=!1){const t=this.audioEngine.addTrack(e,r);return this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex()),t}addTracks(e,r=!1){this.audioEngine.addTracks(e,r),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex())}async addTrackFromFile(e,r=!1){const t=URL.createObjectURL(e),s=e.name.replace(/\.[^/.]+$/,""),o={id:`local-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,title:s,artist:"Local Audio File",src:t};try{const a=await this.probeAudioDuration(t);a>0&&(o.duration=a)}catch{}return this.addTrack(o,r),o}async addTrackFromFiles(e,r=!1){const t=Array.from(e),s=[];for(let o=0;o<t.length;o++){const a=t[o],l=r&&o===0,h=await this.addTrackFromFile(a,l);s.push(h)}return s}async addTrackFromUrl(e,r={},t=!1){var a,l;let s="Online Track";try{const p=new URL(e).pathname,g=p.substring(p.lastIndexOf("/")+1);g&&(s=decodeURIComponent(g).replace(/\.[^/.]+$/,""))}catch{}const o={id:r.id||`url-${Date.now()}-${Math.random().toString(36).substring(2,7)}`,title:((a=r.title)==null?void 0:a.trim())||s,artist:((l=r.artist)==null?void 0:l.trim())||"Audio Stream",album:r.album,coverArt:r.coverArt,src:e,duration:r.duration};if(!o.duration)try{const h=await this.probeAudioDuration(e);h>0&&(o.duration=h)}catch{}return this.addTrack(o,t),o}removeTrack(e){this.audioEngine.removeTrack(e),this.ui.renderPlaylist(this.audioEngine.getPlaylist(),this.audioEngine.getCurrentIndex());const r=this.audioEngine.getCurrentTrack();r?this.ui.updateTrackInfo(r):this.ui.updateTrackInfo({title:"No Track Loaded",src:""})}getPlaylist(){return this.audioEngine.getPlaylist()}probeAudioDuration(e){return new Promise(r=>{const t=new Audio;let s=!1;const o=h=>{s||(s=!0,t.removeEventListener("loadedmetadata",a),t.removeEventListener("error",l),t.src="",r(h))},a=()=>{const h=t.duration;o(h&&!isNaN(h)&&isFinite(h)?h:0)},l=()=>o(0);t.addEventListener("loadedmetadata",a),t.addEventListener("error",l),t.src=e,setTimeout(()=>o(0),3e3)})}setTheme(e){if(e.variant){const r=E[e.variant]||E["horeg-classic"];this.theme={...r,...e}}else this.theme={...this.theme,...e};this.styleEl.textContent=L(this.theme),this.theme.enableEqAnimation!==void 0&&this.visualizer.setEnabled(this.theme.enableEqAnimation)}getTheme(){return{...this.theme}}getAudioEngine(){return this.audioEngine}destroy(){this.container.removeEventListener("keydown",this.boundKeyHandler),this.audioEngine.destroy(),this.visualizer.destroy(),this.ui.destroy(),this.shadow.innerHTML=""}}C.HoregAudio=C;C.default=C;C.THEME_PRESETS=E;C.generateStyles=L;exports.HoregAudio=C;exports.THEME_PRESETS=E;exports.default=C;exports.generateStyles=L;module.exports=Object.assign(exports.default||exports.HoregAudio,exports);
1289
1530
  //# sourceMappingURL=horeg-audio.cjs.map