@lucaismyname/ginger 0.0.30 → 0.0.31

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.
Files changed (66) hide show
  1. package/README.md +140 -8
  2. package/dist/analyzer/liveAudioGraph.d.ts +14 -1
  3. package/dist/analyzer/liveAudioGraph.d.ts.map +1 -1
  4. package/dist/analyzer/useGingerLiveAnalyzer.d.ts +6 -0
  5. package/dist/analyzer/useGingerLiveAnalyzer.d.ts.map +1 -1
  6. package/dist/client.cjs +1 -1
  7. package/dist/client.js +36 -29
  8. package/dist/client.js.map +1 -1
  9. package/dist/context/GingerProvider.d.ts +1 -1
  10. package/dist/context/GingerProvider.d.ts.map +1 -1
  11. package/dist/core/playbackReducer.d.ts.map +1 -1
  12. package/dist/equalizer/index.cjs +2 -0
  13. package/dist/equalizer/index.cjs.map +1 -0
  14. package/dist/equalizer/index.d.ts +3 -0
  15. package/dist/equalizer/index.d.ts.map +1 -0
  16. package/dist/equalizer/index.js +51 -0
  17. package/dist/equalizer/index.js.map +1 -0
  18. package/dist/equalizer/useGingerEqualizer.d.ts +41 -0
  19. package/dist/equalizer/useGingerEqualizer.d.ts.map +1 -0
  20. package/dist/ginger-L2ZFgzH4.js +2223 -0
  21. package/dist/ginger-L2ZFgzH4.js.map +1 -0
  22. package/dist/ginger-NEcOSSJD.cjs +2 -0
  23. package/dist/ginger-NEcOSSJD.cjs.map +1 -0
  24. package/dist/hooks/useGingerChapterProgress.d.ts +14 -0
  25. package/dist/hooks/useGingerChapterProgress.d.ts.map +1 -0
  26. package/dist/hooks/useGingerKeyboardShortcuts.d.ts +6 -0
  27. package/dist/hooks/useGingerKeyboardShortcuts.d.ts.map +1 -1
  28. package/dist/hooks/useGingerPlaybackHistory.d.ts +26 -0
  29. package/dist/hooks/useGingerPlaybackHistory.d.ts.map +1 -0
  30. package/dist/hooks/useGingerSleepTimer.d.ts.map +1 -1
  31. package/dist/hooks/useGingerVolumeFade.d.ts +22 -0
  32. package/dist/hooks/useGingerVolumeFade.d.ts.map +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.ts +18 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +36 -29
  37. package/dist/index.js.map +1 -1
  38. package/dist/liveAudioGraph-CmEsdLgZ.js +150 -0
  39. package/dist/liveAudioGraph-CmEsdLgZ.js.map +1 -0
  40. package/dist/liveAudioGraph-D1BXMv_u.cjs +2 -0
  41. package/dist/liveAudioGraph-D1BXMv_u.cjs.map +1 -0
  42. package/dist/selectors-BalBCc7X.js +127 -0
  43. package/dist/selectors-BalBCc7X.js.map +1 -0
  44. package/dist/selectors-YXnP8Y8g.cjs +2 -0
  45. package/dist/selectors-YXnP8Y8g.cjs.map +1 -0
  46. package/dist/store.d.ts +46 -0
  47. package/dist/store.d.ts.map +1 -0
  48. package/dist/testing/index.cjs +1 -1
  49. package/dist/testing/index.js +1 -1
  50. package/dist/testing/mockWebAudio.d.ts +15 -1
  51. package/dist/testing/mockWebAudio.d.ts.map +1 -1
  52. package/dist/types.d.ts +30 -8
  53. package/dist/types.d.ts.map +1 -1
  54. package/dist/useGingerChapterProgress-BOqUimE7.cjs +2 -0
  55. package/dist/useGingerChapterProgress-BOqUimE7.cjs.map +1 -0
  56. package/dist/useGingerChapterProgress-DLYdGytK.js +321 -0
  57. package/dist/useGingerChapterProgress-DLYdGytK.js.map +1 -0
  58. package/package.json +7 -2
  59. package/dist/ginger-DYlsaFGA.js +0 -2283
  60. package/dist/ginger-DYlsaFGA.js.map +0 -1
  61. package/dist/ginger-YDZhJqet.cjs +0 -2
  62. package/dist/ginger-YDZhJqet.cjs.map +0 -1
  63. package/dist/useNextTrackPrefetch-BZdly__j.js +0 -265
  64. package/dist/useNextTrackPrefetch-BZdly__j.js.map +0 -1
  65. package/dist/useNextTrackPrefetch-pBFiWDyx.cjs +0 -2
  66. package/dist/useNextTrackPrefetch-pBFiWDyx.cjs.map +0 -1
@@ -0,0 +1,2223 @@
1
+ import { jsx as c, jsxs as S, Fragment as ar } from "react/jsx-runtime";
2
+ import { useContext as Oe, createContext as $e, useRef as C, useState as nn, useEffect as E, useMemo as A, useReducer as tn, useCallback as M, Children as an, isValidElement as on, cloneElement as cn } from "react";
3
+ import { b as N, u as X, g as ir, c as P, G as un, d as sn } from "./GingerSplitContexts-BzBExb95.js";
4
+ import { b as Ye, g as K, r as ln, a as dn, p as or, e as pn, d as cr, t as Ve, f as gn, c as fn, s as ur, h as Ce, i as Y, j as mn, k as Ze, m as yn, l as er, n as rr, o as hn, q as vn } from "./selectors-BalBCc7X.js";
5
+ const sr = $e(null);
6
+ function bn() {
7
+ const e = Oe(sr);
8
+ if (!e) throw new Error("Ginger components must be used within <Ginger.Provider>");
9
+ return e;
10
+ }
11
+ function nr(e) {
12
+ const { buffered: r, duration: t } = e;
13
+ return !(t > 0) || r.length === 0 ? 0 : Math.min(1, r.end(r.length - 1) / t);
14
+ }
15
+ function kn({
16
+ className: e,
17
+ style: r,
18
+ preload: t = "metadata",
19
+ crossOrigin: a,
20
+ respectReducedMotion: n = !1
21
+ }) {
22
+ var x;
23
+ const { audioRef: i, dispatch: o, state: u, notifyEnded: d } = bn(), l = ((x = u.tracks[u.currentIndex]) == null ? void 0 : x.fileUrl) ?? "", f = C({
24
+ currentTime: -1,
25
+ duration: -1,
26
+ bufferedFraction: -1
27
+ }), m = C(""), [T, h] = nn(!1);
28
+ E(() => {
29
+ if (!n || typeof window > "u") return;
30
+ const g = window.matchMedia("(prefers-reduced-motion: reduce)"), I = () => h(g.matches);
31
+ return I(), g.addEventListener("change", I), () => g.removeEventListener("change", I);
32
+ }, [n]);
33
+ const v = (g, I = !1) => {
34
+ const G = {
35
+ currentTime: g.currentTime,
36
+ duration: g.duration,
37
+ bufferedFraction: nr(g)
38
+ }, F = f.current, Z = T ? 0.5 : 0.25, ee = Math.abs(G.currentTime - F.currentTime) >= Z || Math.abs(G.duration - F.duration) >= 0.01 || Math.abs(G.bufferedFraction - F.bufferedFraction) >= 0.01;
39
+ !I && !ee || (f.current = G, o({
40
+ type: "MEDIA_TIME_UPDATE",
41
+ payload: G
42
+ }));
43
+ };
44
+ return E(() => {
45
+ const g = i.current;
46
+ g && (g.volume = u.volume, g.muted = u.muted);
47
+ }, [i, u.volume, u.muted]), E(() => {
48
+ const g = i.current;
49
+ if (g) {
50
+ if (!l) {
51
+ g.removeAttribute("src"), f.current = { currentTime: -1, duration: -1, bufferedFraction: -1 }, m.current !== "" && o({ type: "MEDIA_SOURCE_CLEARED" }), m.current = "";
52
+ return;
53
+ }
54
+ g.getAttribute("src") !== l && (g.src = l, g.load(), f.current = { currentTime: -1, duration: -1, bufferedFraction: -1 }), m.current = l;
55
+ }
56
+ }, [i, o, u.currentIndex, u.tracks, l]), E(() => {
57
+ const g = i.current;
58
+ g && (g.playbackRate = u.playbackRate);
59
+ }, [i, u.playbackRate, l]), /* @__PURE__ */ c(
60
+ "audio",
61
+ {
62
+ "data-ginger-component": "Player",
63
+ ref: i,
64
+ className: e,
65
+ style: r,
66
+ preload: t,
67
+ crossOrigin: a,
68
+ controls: !1,
69
+ playsInline: !0,
70
+ onTimeUpdate: (g) => {
71
+ v(g.currentTarget);
72
+ },
73
+ onLoadedMetadata: (g) => {
74
+ const I = g.currentTarget;
75
+ f.current = { currentTime: -1, duration: -1, bufferedFraction: -1 }, o({
76
+ type: "MEDIA_LOADED_METADATA",
77
+ payload: {
78
+ duration: I.duration,
79
+ bufferedFraction: nr(I)
80
+ }
81
+ });
82
+ },
83
+ onSeeking: (g) => v(g.currentTarget, !0),
84
+ onSeeked: (g) => v(g.currentTarget, !0),
85
+ onEnded: () => d(),
86
+ onPlay: () => o({ type: "MEDIA_PLAY" }),
87
+ onPause: () => o({ type: "MEDIA_PAUSE" }),
88
+ onWaiting: () => o({ type: "MEDIA_WAITING" }),
89
+ onCanPlay: () => o({ type: "MEDIA_CANPLAY" }),
90
+ onProgress: (g) => v(g.currentTarget, !0),
91
+ onVolumeChange: (g) => {
92
+ const I = g.currentTarget;
93
+ o({
94
+ type: "MEDIA_VOLUME_SYNC",
95
+ payload: { volume: I.volume, muted: I.muted }
96
+ });
97
+ },
98
+ onError: () => {
99
+ var F;
100
+ const g = i.current, I = (F = g == null ? void 0 : g.error) == null ? void 0 : F.code;
101
+ o({ type: "MEDIA_ERROR", payload: { message: I === 1 ? "MEDIA_ERR_ABORTED" : I === 2 ? "MEDIA_ERR_NETWORK" : I === 3 ? "MEDIA_ERR_DECODE" : I === 4 ? "MEDIA_ERR_SRC_NOT_SUPPORTED" : "MEDIA_ERR_UNKNOWN" } });
102
+ }
103
+ }
104
+ );
105
+ }
106
+ const Le = {
107
+ seek: "Seek",
108
+ volume: "Volume",
109
+ playbackSpeed: "Playback speed",
110
+ chaptersList: "Chapters",
111
+ syncedLyricsList: "Synced lyrics",
112
+ nextTrack: "Next track",
113
+ previousTrack: "Previous track",
114
+ shuffle: "Shuffle",
115
+ mute: "Mute",
116
+ unmute: "Unmute",
117
+ play: "Play",
118
+ pause: "Pause",
119
+ repeat: {
120
+ off: "Repeat off",
121
+ all: "Repeat all",
122
+ one: "Repeat one"
123
+ },
124
+ playbackRateNormal: "1× normal",
125
+ playbackRateTimes: (e) => `${e}×`
126
+ };
127
+ function Tn(e) {
128
+ return e ? {
129
+ ...Le,
130
+ ...e,
131
+ repeat: { ...Le.repeat, ...e.repeat }
132
+ } : Le;
133
+ }
134
+ const lr = $e(Le);
135
+ function xn({
136
+ locale: e,
137
+ children: r
138
+ }) {
139
+ const t = Tn(e);
140
+ return /* @__PURE__ */ c(lr.Provider, { value: t, children: r });
141
+ }
142
+ function R() {
143
+ return Oe(lr);
144
+ }
145
+ function J(e) {
146
+ if (!Number.isFinite(e) || e < 0) return "0:00";
147
+ const r = Math.floor(e % 60);
148
+ return `${Math.floor(e / 60)}:${r.toString().padStart(2, "0")}`;
149
+ }
150
+ function Mn() {
151
+ const e = N(), r = X(), t = R(), a = A(() => ir(e, r), [e, r]), n = Ye(a), i = n > 0 ? a.currentTime : 0, o = Number.isFinite(i) ? i : 0, u = n > 0 ? `${J(o)} of ${J(n)}` : J(o), d = (l) => {
152
+ r.seek(Number(l.currentTarget.value));
153
+ };
154
+ return {
155
+ state: a,
156
+ value: o,
157
+ min: 0,
158
+ max: n > 0 ? n : 1,
159
+ step: "any",
160
+ ariaValueText: u,
161
+ ariaLabel: t.seek,
162
+ onSeekInput: d,
163
+ onSeekChange: d
164
+ };
165
+ }
166
+ function In() {
167
+ const e = N(), r = X(), t = R(), a = A(() => ir(e, r), [e, r]), n = (i) => {
168
+ r.setVolume(Number(i.currentTarget.value));
169
+ };
170
+ return {
171
+ state: a,
172
+ value: a.volume,
173
+ min: 0,
174
+ max: 1,
175
+ step: "any",
176
+ ariaValueText: `${Math.round(a.volume * 100)}%`,
177
+ ariaLabel: t.volume,
178
+ onVolumeInput: n,
179
+ onVolumeChange: n
180
+ };
181
+ }
182
+ function En(e) {
183
+ const r = N(), t = R(), a = (e == null ? void 0 : e.playAriaLabel) ?? t.play, n = (e == null ? void 0 : e.pauseAriaLabel) ?? t.pause;
184
+ return {
185
+ isPaused: r.isPaused,
186
+ toggle: r.togglePlayPause,
187
+ ariaLabel: r.isPaused ? a : n
188
+ };
189
+ }
190
+ function L(e) {
191
+ const {
192
+ className: r,
193
+ width: t,
194
+ height: a,
195
+ viewBox: n,
196
+ fill: i,
197
+ stroke: o,
198
+ strokeWidth: u,
199
+ strokeLinecap: d,
200
+ strokeLinejoin: l,
201
+ children: f,
202
+ ...m
203
+ } = e;
204
+ return /* @__PURE__ */ c(
205
+ "svg",
206
+ {
207
+ "data-ginger-component": "Wrapper",
208
+ xmlns: "http://www.w3.org/2000/svg",
209
+ width: t ?? 24,
210
+ height: a ?? 24,
211
+ viewBox: n ?? "0 0 24 24",
212
+ fill: "none",
213
+ stroke: o ?? "currentColor",
214
+ strokeWidth: u ?? 2,
215
+ strokeLinecap: d ?? "round",
216
+ strokeLinejoin: l ?? "round",
217
+ className: r,
218
+ "aria-hidden": !0,
219
+ role: "presentation",
220
+ ...m,
221
+ children: f
222
+ }
223
+ );
224
+ }
225
+ function dr() {
226
+ return /* @__PURE__ */ c(L, { children: /* @__PURE__ */ c("path", { "data-ginger-component": "Pause", d: "M6 4h4v16H6zM14 4h4v16h-4z" }) });
227
+ }
228
+ function pr() {
229
+ return /* @__PURE__ */ c(L, { children: /* @__PURE__ */ c("path", { "data-ginger-component": "Play", d: "M5 3L19 12 5 21 5 3z" }) });
230
+ }
231
+ function Fe() {
232
+ return /* @__PURE__ */ S(ar, { children: [
233
+ /* @__PURE__ */ c("path", { d: "m17 2 4 4-4 4" }),
234
+ /* @__PURE__ */ c("path", { d: "M3 11v-1a4 4 0 0 1 4-4h14" }),
235
+ /* @__PURE__ */ c("path", { d: "m7 22-4-4 4-4" }),
236
+ /* @__PURE__ */ c("path", { d: "M21 13v1a4 4 0 0 1-4 4H3" })
237
+ ] });
238
+ }
239
+ function gr({ mode: e }) {
240
+ return e === "one" ? /* @__PURE__ */ S(L, { children: [
241
+ /* @__PURE__ */ c(Fe, {}),
242
+ /* @__PURE__ */ c("path", { "data-ginger-component": "RepeatGlyph", d: "M11 10h1v4" })
243
+ ] }) : e === "all" ? /* @__PURE__ */ c(L, { children: /* @__PURE__ */ c(Fe, {}) }) : /* @__PURE__ */ S(L, { children: [
244
+ /* @__PURE__ */ c(Fe, {}),
245
+ /* @__PURE__ */ c("line", { "data-ginger-component": "RepeatGlyph", x1: "3", x2: "21", y1: "3", y2: "21" })
246
+ ] });
247
+ }
248
+ function fr() {
249
+ return /* @__PURE__ */ S(L, { children: [
250
+ /* @__PURE__ */ c("path", { d: "m18 14 4 4-4 4" }),
251
+ /* @__PURE__ */ c("path", { d: "m18 2 4 4-4 4" }),
252
+ /* @__PURE__ */ c(
253
+ "path",
254
+ {
255
+ "data-ginger-component": "ShuffleIcon",
256
+ d: "M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22"
257
+ }
258
+ ),
259
+ /* @__PURE__ */ c("path", { d: "M2 6h1.972a4 4 0 0 1 3.6 2.2" }),
260
+ /* @__PURE__ */ c("path", { d: "M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45" })
261
+ ] });
262
+ }
263
+ function mr() {
264
+ return /* @__PURE__ */ S(L, { children: [
265
+ /* @__PURE__ */ c(
266
+ "path",
267
+ {
268
+ "data-ginger-component": "SkipBack",
269
+ d: "M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z"
270
+ }
271
+ ),
272
+ /* @__PURE__ */ c("path", { d: "M3 20V4" })
273
+ ] });
274
+ }
275
+ function yr() {
276
+ return /* @__PURE__ */ S(L, { children: [
277
+ /* @__PURE__ */ c("path", { d: "M21 4v16" }),
278
+ /* @__PURE__ */ c(
279
+ "path",
280
+ {
281
+ "data-ginger-component": "SkipForward",
282
+ d: "M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z"
283
+ }
284
+ )
285
+ ] });
286
+ }
287
+ function hr() {
288
+ return /* @__PURE__ */ S(L, { children: [
289
+ /* @__PURE__ */ c(
290
+ "path",
291
+ {
292
+ "data-ginger-component": "Volume2",
293
+ d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"
294
+ }
295
+ ),
296
+ /* @__PURE__ */ c("path", { d: "M16 9a5 5 0 0 1 0 6" }),
297
+ /* @__PURE__ */ c("path", { d: "M19.364 18.364a9 9 0 0 0 0-12.728" })
298
+ ] });
299
+ }
300
+ function vr() {
301
+ return /* @__PURE__ */ S(L, { children: [
302
+ /* @__PURE__ */ c(
303
+ "path",
304
+ {
305
+ "data-ginger-component": "VolumeX",
306
+ d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"
307
+ }
308
+ ),
309
+ /* @__PURE__ */ c("line", { x1: "22", x2: "16", y1: "9", y2: "15" }),
310
+ /* @__PURE__ */ c("line", { x1: "16", x2: "22", y1: "9", y2: "15" })
311
+ ] });
312
+ }
313
+ function br({
314
+ playLabel: e = "Play",
315
+ pauseLabel: r = "Pause",
316
+ playAriaLabel: t,
317
+ pauseAriaLabel: a,
318
+ children: n,
319
+ type: i = "button",
320
+ onClick: o,
321
+ ...u
322
+ }) {
323
+ const d = R(), l = typeof e == "string" ? e : d.play, f = typeof r == "string" ? r : d.pause, m = En({
324
+ playAriaLabel: t ?? l,
325
+ pauseAriaLabel: a ?? f
326
+ });
327
+ return /* @__PURE__ */ c(
328
+ "button",
329
+ {
330
+ "data-ginger-component": "PlayPause",
331
+ ...u,
332
+ type: i,
333
+ "aria-label": m.ariaLabel,
334
+ onClick: (T) => {
335
+ m.toggle(), o == null || o(T);
336
+ },
337
+ children: n ?? (m.isPaused ? /* @__PURE__ */ c(pr, {}) : /* @__PURE__ */ c(dr, {}))
338
+ }
339
+ );
340
+ }
341
+ br.displayName = "Ginger.Control.PlayPause";
342
+ function kr({ type: e = "button", ariaLabel: r, onClick: t, children: a, ...n }) {
343
+ const { repeatMode: i, cycleRepeat: o } = N(), d = R().repeat[i];
344
+ return /* @__PURE__ */ c(
345
+ "button",
346
+ {
347
+ "data-ginger-component": "Repeat",
348
+ ...n,
349
+ type: e,
350
+ "aria-label": r ?? d,
351
+ onClick: (l) => {
352
+ o(), t == null || t(l);
353
+ },
354
+ children: a ?? /* @__PURE__ */ c(gr, { mode: i })
355
+ }
356
+ );
357
+ }
358
+ kr.displayName = "Ginger.Control.Repeat";
359
+ function Tr({ type: e = "button", children: r, ariaLabel: t, onClick: a, ...n }) {
360
+ const { next: i } = N(), o = R();
361
+ return /* @__PURE__ */ c(
362
+ "button",
363
+ {
364
+ "data-ginger-component": "Next",
365
+ ...n,
366
+ type: e,
367
+ "aria-label": t ?? o.nextTrack,
368
+ onClick: (u) => {
369
+ i(), a == null || a(u);
370
+ },
371
+ children: r ?? /* @__PURE__ */ c(yr, {})
372
+ }
373
+ );
374
+ }
375
+ Tr.displayName = "Ginger.Control.Next";
376
+ function xr({
377
+ type: e = "button",
378
+ children: r,
379
+ ariaLabel: t,
380
+ onClick: a,
381
+ ...n
382
+ }) {
383
+ const { prev: i } = N(), o = R();
384
+ return /* @__PURE__ */ c(
385
+ "button",
386
+ {
387
+ "data-ginger-component": "Previous",
388
+ ...n,
389
+ type: e,
390
+ "aria-label": t ?? o.previousTrack,
391
+ onClick: (u) => {
392
+ i(), a == null || a(u);
393
+ },
394
+ children: r ?? /* @__PURE__ */ c(mr, {})
395
+ }
396
+ );
397
+ }
398
+ xr.displayName = "Ginger.Control.Previous";
399
+ function Mr({ type: e = "button", children: r, ariaLabel: t, onClick: a, ...n }) {
400
+ const { isShuffled: i, toggleShuffle: o } = N(), u = R();
401
+ return /* @__PURE__ */ c(
402
+ "button",
403
+ {
404
+ "data-ginger-component": "Shuffle",
405
+ ...n,
406
+ type: e,
407
+ "aria-pressed": i,
408
+ "aria-label": t ?? u.shuffle,
409
+ onClick: (d) => {
410
+ o(), a == null || a(d);
411
+ },
412
+ children: r ?? /* @__PURE__ */ c(fr, {})
413
+ }
414
+ );
415
+ }
416
+ Mr.displayName = "Ginger.Control.Shuffle";
417
+ function Ir({ inputStyle: e, style: r, unstyled: t = !1, ariaLabel: a, ...n }) {
418
+ const i = Mn(), o = t ? { ...r, ...e } : { width: "100%", ...r, ...e };
419
+ return /* @__PURE__ */ c(
420
+ "input",
421
+ {
422
+ "data-ginger-component": "SeekBar",
423
+ ...n,
424
+ type: "range",
425
+ min: i.min,
426
+ max: i.max,
427
+ step: i.step,
428
+ value: i.value,
429
+ "aria-label": a ?? i.ariaLabel,
430
+ "aria-valuetext": i.ariaValueText,
431
+ onInput: i.onSeekInput,
432
+ onChange: i.onSeekChange,
433
+ style: o
434
+ }
435
+ );
436
+ }
437
+ Ir.displayName = "Ginger.Control.SeekBar";
438
+ function Er({ inputStyle: e, style: r, unstyled: t = !1, ariaLabel: a, ...n }) {
439
+ const i = In(), o = t ? { ...r, ...e } : { width: "100%", ...r, ...e };
440
+ return /* @__PURE__ */ c(
441
+ "input",
442
+ {
443
+ "data-ginger-component": "Volume",
444
+ ...n,
445
+ type: "range",
446
+ min: i.min,
447
+ max: i.max,
448
+ step: i.step,
449
+ value: i.value,
450
+ "aria-label": a ?? i.ariaLabel,
451
+ "aria-valuetext": i.ariaValueText,
452
+ onInput: i.onVolumeInput,
453
+ onChange: i.onVolumeChange,
454
+ style: o
455
+ }
456
+ );
457
+ }
458
+ Er.displayName = "Ginger.Control.Volume";
459
+ function Pr({
460
+ ariaLabel: e,
461
+ muteLabel: r,
462
+ unmuteLabel: t,
463
+ type: a = "button",
464
+ onClick: n,
465
+ children: i,
466
+ ...o
467
+ }) {
468
+ const { muted: u, toggleMute: d } = X(), l = R();
469
+ return /* @__PURE__ */ c(
470
+ "button",
471
+ {
472
+ "data-ginger-component": "Mute",
473
+ ...o,
474
+ type: a,
475
+ "aria-pressed": u,
476
+ "aria-label": e ?? (u ? l.unmute : l.mute),
477
+ onClick: (f) => {
478
+ d(), n == null || n(f);
479
+ },
480
+ children: i ?? (u ? t ?? /* @__PURE__ */ c(vr, {}) : r ?? /* @__PURE__ */ c(hr, {}))
481
+ }
482
+ );
483
+ }
484
+ Pr.displayName = "Ginger.Control.Mute";
485
+ const Pn = [0.5, 0.75, 1, 1.25, 1.5, 2];
486
+ function Ar({
487
+ rates: e = Pn,
488
+ style: r,
489
+ ariaLabel: t,
490
+ children: a,
491
+ ...n
492
+ }) {
493
+ const { playbackRate: i, setPlaybackRate: o } = X(), u = R(), d = A(
494
+ () => Array.from(/* @__PURE__ */ new Set([...e, i])).sort((l, f) => l - f),
495
+ [e, i]
496
+ );
497
+ return /* @__PURE__ */ c(
498
+ "select",
499
+ {
500
+ "data-ginger-component": "PlaybackRate",
501
+ ...n,
502
+ "aria-label": t ?? u.playbackSpeed,
503
+ value: String(i),
504
+ style: r,
505
+ onChange: (l) => o(Number(l.currentTarget.value)),
506
+ children: a ?? d.map((l) => /* @__PURE__ */ c("option", { value: String(l), children: l === 1 ? u.playbackRateNormal : u.playbackRateTimes(l) }, l))
507
+ }
508
+ );
509
+ }
510
+ Ar.displayName = "Ginger.Control.PlaybackRate";
511
+ function H(e, r) {
512
+ function t(a) {
513
+ const n = P(), o = (r(n) ?? "").trim(), { className: u, style: d, fallback: l, empty: f, children: m } = a;
514
+ if (!o) {
515
+ const T = f ?? l ?? null;
516
+ return T ? /* @__PURE__ */ c("span", { className: u, style: d, children: T }) : null;
517
+ }
518
+ return m ? /* @__PURE__ */ c("span", { className: u, style: d, children: m(o, n) }) : /* @__PURE__ */ c("span", { className: u, style: d, children: o });
519
+ }
520
+ return t.displayName = e, t;
521
+ }
522
+ function j(e, r) {
523
+ return H(e, (t) => r(K(t)));
524
+ }
525
+ const An = j("Ginger.Current.Title", (e) => e == null ? void 0 : e.title), Sn = j("Ginger.Current.Artist", (e) => e == null ? void 0 : e.artist), Rn = H("Ginger.Current.Album", (e) => ln(e)), Gn = j(
526
+ "Ginger.Current.Description",
527
+ (e) => e == null ? void 0 : e.description
528
+ ), wn = H("Ginger.Current.Copyright", (e) => {
529
+ var t;
530
+ const r = K(e);
531
+ return (r == null ? void 0 : r.copyright) ?? ((t = e.playlistMeta) == null ? void 0 : t.copyright);
532
+ }), Ln = j("Ginger.Current.Genre", (e) => e == null ? void 0 : e.genre), Nn = j("Ginger.Current.Label", (e) => e == null ? void 0 : e.label), _n = j("Ginger.Current.Isrc", (e) => e == null ? void 0 : e.isrc), Dn = j(
533
+ "Ginger.Current.TrackNumber",
534
+ (e) => (e == null ? void 0 : e.trackNumber) != null ? String(e.trackNumber) : void 0
535
+ );
536
+ function Sr({
537
+ className: e,
538
+ style: r,
539
+ fallback: t,
540
+ empty: a,
541
+ children: n,
542
+ format: i
543
+ }) {
544
+ var l;
545
+ const o = P(), u = (l = K(o)) == null ? void 0 : l.year;
546
+ if (typeof u != "number" || !Number.isFinite(u)) {
547
+ const f = a ?? t ?? null;
548
+ return f ? /* @__PURE__ */ c("span", { "data-ginger-component": "Year", className: e, style: r, children: f }) : null;
549
+ }
550
+ const d = i ? i(u) : String(u);
551
+ return n ? /* @__PURE__ */ c("span", { "data-ginger-component": "Year", className: e, style: r, children: n(d, o) }) : /* @__PURE__ */ c("span", { "data-ginger-component": "Year", className: e, style: r, children: d });
552
+ }
553
+ Sr.displayName = "Ginger.Current.Year";
554
+ function Rr({
555
+ className: e,
556
+ style: r,
557
+ fallback: t,
558
+ empty: a,
559
+ children: n,
560
+ preserveWhitespace: i = !0,
561
+ unstyled: o = !1
562
+ }) {
563
+ var m;
564
+ const u = P(), d = ((m = K(u)) == null ? void 0 : m.lyrics) ?? "", l = i ? d.replace(/^\s+|\s+$/g, "") : d.trim();
565
+ if (!l) {
566
+ const T = a ?? t ?? null;
567
+ return T ? /* @__PURE__ */ c(
568
+ "span",
569
+ {
570
+ "data-ginger-component": "Lyrics",
571
+ className: e,
572
+ style: r,
573
+ children: T
574
+ }
575
+ ) : null;
576
+ }
577
+ const f = !o && i ? { whiteSpace: "pre-wrap" } : void 0;
578
+ return n ? /* @__PURE__ */ c("span", { className: e, style: { ...f, ...r }, children: n(l, u) }) : /* @__PURE__ */ c("span", { className: e, style: { ...f, ...r }, children: l });
579
+ }
580
+ Rr.displayName = "Ginger.Current.Lyrics";
581
+ const tr = /\[(\d{1,2}):(\d{2})(?:\.(\d{1,3}))?\]/g;
582
+ function Cn(e) {
583
+ const r = [];
584
+ for (const t of e.split(/\r?\n/)) {
585
+ const a = [...t.matchAll(tr)];
586
+ if (a.length === 0) continue;
587
+ const n = t.replace(tr, "").trim();
588
+ for (const i of a) {
589
+ const o = Number(i[1] ?? 0), u = Number(i[2] ?? 0), d = Number((i[3] ?? "0").padEnd(3, "0")), l = o * 60 + u + d / 1e3;
590
+ Number.isFinite(l) && l >= 0 && r.push({ time: l, text: n });
591
+ }
592
+ }
593
+ return r.sort((t, a) => t.time - a.time);
594
+ }
595
+ function Fn() {
596
+ const { tracks: e, currentIndex: r } = N(), { currentTime: t } = X(), a = e[r], n = A(() => a ? Array.isArray(a.lyricsTimed) && a.lyricsTimed.length > 0 ? [...a.lyricsTimed].filter((o) => Number.isFinite(o.time) && o.time >= 0).sort((o, u) => o.time - u.time) : typeof a.lyrics == "string" ? Cn(a.lyrics) : [] : [], [a]), i = A(() => {
597
+ for (let o = n.length - 1; o >= 0; o -= 1)
598
+ if (t >= n[o].time) return o;
599
+ return -1;
600
+ }, [t, n]);
601
+ return {
602
+ lines: n,
603
+ activeIndex: i,
604
+ activeLine: i >= 0 ? n[i] ?? null : null
605
+ };
606
+ }
607
+ function Gr({
608
+ className: e,
609
+ style: r,
610
+ fallback: t,
611
+ empty: a,
612
+ unstyled: n = !1,
613
+ activeClassName: i,
614
+ lineClassName: o,
615
+ children: u
616
+ }) {
617
+ const d = P(), l = R(), { lines: f, activeIndex: m } = Fn();
618
+ if (f.length === 0) {
619
+ const h = a ?? t ?? null;
620
+ return h ? /* @__PURE__ */ c(
621
+ "span",
622
+ {
623
+ "data-ginger-component": "LyricsSynced",
624
+ className: e,
625
+ style: r,
626
+ children: h
627
+ }
628
+ ) : null;
629
+ }
630
+ return /* @__PURE__ */ c(
631
+ "ul",
632
+ {
633
+ className: e,
634
+ style: { ...n ? {} : {
635
+ listStyle: "none",
636
+ margin: 0,
637
+ padding: 0,
638
+ fontFamily: "var(--ginger-font-family, system-ui, sans-serif)",
639
+ fontSize: "var(--ginger-font-size, 14px)",
640
+ color: "var(--ginger-primary-color, #111827)"
641
+ }, ...r },
642
+ "aria-label": l.syncedLyricsList,
643
+ children: f.map((h, v) => {
644
+ const x = v === m;
645
+ return /* @__PURE__ */ c(
646
+ "li",
647
+ {
648
+ "aria-current": x ? "true" : void 0,
649
+ "data-ginger-active": x || void 0,
650
+ className: [o, x ? i : void 0].filter(Boolean).join(" ") || void 0,
651
+ style: n ? void 0 : {
652
+ padding: "var(--ginger-playlist-row-padding, 4px 8px)",
653
+ fontWeight: x ? 600 : 400,
654
+ opacity: x ? 1 : 0.75
655
+ },
656
+ children: u ? u(h, v, x, d) : h.text
657
+ },
658
+ `${h.time}-${v}`
659
+ );
660
+ })
661
+ }
662
+ );
663
+ }
664
+ Gr.displayName = "Ginger.Current.LyricsSynced";
665
+ function Un() {
666
+ const { tracks: e, currentIndex: r } = N(), { currentTime: t, seek: a } = X(), n = A(() => {
667
+ var u;
668
+ return [...((u = e[r]) == null ? void 0 : u.chapters) ?? []].filter((d) => d && Number.isFinite(d.startSeconds) && d.startSeconds >= 0).sort((d, l) => d.startSeconds - l.startSeconds);
669
+ }, [r, e]), i = A(() => {
670
+ if (n.length === 0) return -1;
671
+ for (let o = n.length - 1; o >= 0; o -= 1)
672
+ if (t >= n[o].startSeconds) return o;
673
+ return -1;
674
+ }, [t, n]);
675
+ return {
676
+ list: n,
677
+ activeIndex: i,
678
+ active: i >= 0 ? n[i] ?? null : null,
679
+ seekTo: (o) => {
680
+ const u = n[o];
681
+ u && a(u.startSeconds);
682
+ }
683
+ };
684
+ }
685
+ function wr({
686
+ className: e,
687
+ style: r,
688
+ fallback: t,
689
+ empty: a,
690
+ unstyled: n = !1,
691
+ formatStart: i = J,
692
+ children: o
693
+ }) {
694
+ const u = P(), d = R(), { list: l, activeIndex: f, seekTo: m } = Un();
695
+ if (l.length === 0) {
696
+ const h = a ?? t ?? null;
697
+ return h ? /* @__PURE__ */ c(
698
+ "span",
699
+ {
700
+ "data-ginger-component": "Chapters",
701
+ className: e,
702
+ style: r,
703
+ children: h
704
+ }
705
+ ) : null;
706
+ }
707
+ return /* @__PURE__ */ c(
708
+ "ul",
709
+ {
710
+ className: e,
711
+ style: { ...n ? {} : {
712
+ listStyle: "none",
713
+ margin: 0,
714
+ padding: 0,
715
+ fontFamily: "var(--ginger-font-family, system-ui, sans-serif)",
716
+ fontSize: "var(--ginger-font-size, 14px)",
717
+ color: "var(--ginger-primary-color, #111827)"
718
+ }, ...r },
719
+ "aria-label": d.chaptersList,
720
+ children: l.map((h, v) => {
721
+ const x = v === f;
722
+ return /* @__PURE__ */ c("li", { children: /* @__PURE__ */ c(
723
+ "button",
724
+ {
725
+ type: "button",
726
+ "aria-current": x ? "true" : void 0,
727
+ "data-ginger-active": x || void 0,
728
+ onClick: () => m(v),
729
+ style: {
730
+ width: n ? void 0 : "100%",
731
+ textAlign: n ? void 0 : "left",
732
+ border: n ? void 0 : "none",
733
+ background: n ? void 0 : x ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
734
+ color: n ? void 0 : "inherit",
735
+ font: n ? void 0 : "inherit",
736
+ cursor: n ? void 0 : "pointer",
737
+ padding: n ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)"
738
+ },
739
+ children: o ? o(h, v, x, u) : n ? /* @__PURE__ */ S(ar, { children: [
740
+ i(h.startSeconds),
741
+ " ",
742
+ h.title
743
+ ] }) : /* @__PURE__ */ S("span", { children: [
744
+ /* @__PURE__ */ c("span", { style: { opacity: 0.75, marginRight: "0.35em" }, children: i(h.startSeconds) }),
745
+ h.title
746
+ ] })
747
+ }
748
+ ) }, `${h.startSeconds}-${h.title}`);
749
+ })
750
+ }
751
+ );
752
+ }
753
+ wr.displayName = "Ginger.Current.Chapters";
754
+ function Lr({
755
+ visible: e = !1,
756
+ className: r,
757
+ style: t,
758
+ fallback: a,
759
+ empty: n,
760
+ children: i
761
+ }) {
762
+ var d;
763
+ const o = P();
764
+ if (!e) return null;
765
+ const u = ((d = K(o)) == null ? void 0 : d.fileUrl) ?? "";
766
+ if (!u) {
767
+ const l = n ?? a ?? null;
768
+ return l ? /* @__PURE__ */ c("span", { className: r, style: t, children: l }) : null;
769
+ }
770
+ return i ? /* @__PURE__ */ c("span", { "data-ginger-component": "FileUrl", className: r, style: t, children: i(u, o) }) : /* @__PURE__ */ c("span", { className: r, style: t, children: u });
771
+ }
772
+ Lr.displayName = "Ginger.Current.FileUrl";
773
+ function Nr({
774
+ className: e,
775
+ style: r,
776
+ fallback: t,
777
+ empty: a,
778
+ sizes: n,
779
+ loading: i,
780
+ onError: o,
781
+ decoding: u,
782
+ unstyled: d = !1,
783
+ imgStyle: l
784
+ }) {
785
+ const f = P(), m = K(f), T = dn(f);
786
+ if (!T) {
787
+ const v = a ?? t ?? null;
788
+ return v ? /* @__PURE__ */ c(
789
+ "span",
790
+ {
791
+ className: e,
792
+ style: r,
793
+ children: v
794
+ }
795
+ ) : null;
796
+ }
797
+ const h = [m == null ? void 0 : m.title, m == null ? void 0 : m.artist].filter(Boolean).join(" — ") || "Artwork";
798
+ return /* @__PURE__ */ c(
799
+ "div",
800
+ {
801
+ "data-ginger-component": "Artwork",
802
+ className: e,
803
+ style: d ? { ...r } : {
804
+ background: "var(--ginger-artwork-bg, transparent)",
805
+ borderRadius: "var(--ginger-artwork-radius, 0)",
806
+ overflow: "hidden",
807
+ ...r
808
+ },
809
+ children: /* @__PURE__ */ c(
810
+ "img",
811
+ {
812
+ src: T,
813
+ alt: h,
814
+ sizes: n,
815
+ loading: i,
816
+ decoding: u,
817
+ onError: o,
818
+ style: {
819
+ display: d ? void 0 : "block",
820
+ width: d ? void 0 : "100%",
821
+ height: d ? void 0 : "100%",
822
+ objectFit: d ? void 0 : "cover",
823
+ ...l
824
+ }
825
+ }
826
+ )
827
+ }
828
+ );
829
+ }
830
+ Nr.displayName = "Ginger.Current.Artwork";
831
+ function _r({
832
+ base: e = 0,
833
+ className: r,
834
+ style: t,
835
+ fallback: a,
836
+ empty: n,
837
+ children: i
838
+ }) {
839
+ const o = P();
840
+ if (o.tracks.length === 0) {
841
+ const l = n ?? a ?? null;
842
+ return l ? /* @__PURE__ */ c(
843
+ "span",
844
+ {
845
+ "data-ginger-component": "QueueIndex",
846
+ className: r,
847
+ style: t,
848
+ children: l
849
+ }
850
+ ) : null;
851
+ }
852
+ const d = String(o.currentIndex + e);
853
+ return i ? /* @__PURE__ */ c(
854
+ "span",
855
+ {
856
+ "data-ginger-component": "QueueIndex",
857
+ className: r,
858
+ style: t,
859
+ children: i(d, o)
860
+ }
861
+ ) : /* @__PURE__ */ c(
862
+ "span",
863
+ {
864
+ "data-ginger-component": "QueueIndex",
865
+ className: r,
866
+ style: t,
867
+ children: d
868
+ }
869
+ );
870
+ }
871
+ _r.displayName = "Ginger.Current.QueueIndex";
872
+ function Dr({
873
+ className: e,
874
+ style: r,
875
+ fallback: t,
876
+ empty: a,
877
+ children: n
878
+ }) {
879
+ const i = P(), o = String(i.tracks.length);
880
+ if (i.tracks.length === 0) {
881
+ const u = a ?? t ?? null;
882
+ return u ? /* @__PURE__ */ c("span", { className: e, style: r, children: u }) : null;
883
+ }
884
+ return n ? /* @__PURE__ */ c(
885
+ "span",
886
+ {
887
+ "data-ginger-component": "QueueLength",
888
+ className: e,
889
+ style: r,
890
+ children: n(o, i)
891
+ }
892
+ ) : /* @__PURE__ */ c(
893
+ "span",
894
+ {
895
+ "data-ginger-component": "QueueLength",
896
+ className: e,
897
+ style: r,
898
+ children: o
899
+ }
900
+ );
901
+ }
902
+ Dr.displayName = "Ginger.Current.QueueLength";
903
+ function Cr({
904
+ base: e = 0,
905
+ separator: r = " / ",
906
+ className: t,
907
+ style: a,
908
+ fallback: n,
909
+ empty: i,
910
+ children: o
911
+ }) {
912
+ const u = P(), d = u.tracks.length;
913
+ if (d === 0) {
914
+ const T = i ?? n ?? null;
915
+ return T ? /* @__PURE__ */ c("span", { className: t, style: a, children: T }) : null;
916
+ }
917
+ const l = String(u.currentIndex + e), f = String(d), m = `${l}${r}${f}`;
918
+ return o ? /* @__PURE__ */ c(
919
+ "span",
920
+ {
921
+ "data-ginger-component": "QueuePosition",
922
+ className: t,
923
+ style: a,
924
+ children: o({ index: l, length: f, label: m }, u)
925
+ }
926
+ ) : /* @__PURE__ */ c(
927
+ "span",
928
+ {
929
+ "data-ginger-component": "QueuePosition",
930
+ className: t,
931
+ style: a,
932
+ children: m
933
+ }
934
+ );
935
+ }
936
+ Cr.displayName = "Ginger.Current.QueuePosition";
937
+ function Qe(e, r, t) {
938
+ const {
939
+ className: a,
940
+ style: n,
941
+ fallback: i,
942
+ empty: o,
943
+ children: u,
944
+ format: d = J
945
+ } = t;
946
+ if (!(e >= 0) || !Number.isFinite(e)) {
947
+ const f = o ?? i ?? null;
948
+ return f ? /* @__PURE__ */ c(
949
+ "span",
950
+ {
951
+ "data-ginger-component": "TimeText",
952
+ className: a,
953
+ style: n,
954
+ children: f
955
+ }
956
+ ) : null;
957
+ }
958
+ const l = d(e);
959
+ return u ? /* @__PURE__ */ c(
960
+ "span",
961
+ {
962
+ "data-ginger-component": "TimeText",
963
+ className: a,
964
+ style: n,
965
+ children: u(l, r)
966
+ }
967
+ ) : /* @__PURE__ */ c("span", { "data-ginger-component": "TimeText", className: a, style: n, children: l });
968
+ }
969
+ function Fr(e) {
970
+ const r = P();
971
+ return Qe(r.currentTime, r, e);
972
+ }
973
+ Fr.displayName = "Ginger.Current.Elapsed";
974
+ function Ur(e) {
975
+ const r = P();
976
+ return Qe(Ye(r), r, e);
977
+ }
978
+ Ur.displayName = "Ginger.Current.Duration";
979
+ function Vr(e) {
980
+ const r = P();
981
+ return Qe(pn(r), r, e);
982
+ }
983
+ Vr.displayName = "Ginger.Current.Remaining";
984
+ function Br({
985
+ className: e,
986
+ style: r,
987
+ fallback: t,
988
+ empty: a,
989
+ children: n
990
+ }) {
991
+ const i = P(), o = Ye(i), u = or(i);
992
+ if (!(o > 0)) {
993
+ const d = a ?? t ?? null;
994
+ return d ? /* @__PURE__ */ c(
995
+ "span",
996
+ {
997
+ "data-ginger-component": "Progress",
998
+ className: e,
999
+ style: r,
1000
+ children: d
1001
+ }
1002
+ ) : null;
1003
+ }
1004
+ return n ? /* @__PURE__ */ c(
1005
+ "span",
1006
+ {
1007
+ "data-ginger-component": "Progress",
1008
+ className: e,
1009
+ style: r,
1010
+ children: n(
1011
+ { fraction: u, currentTime: i.currentTime, duration: o },
1012
+ i
1013
+ )
1014
+ }
1015
+ ) : /* @__PURE__ */ c("span", { "data-ginger-component": "Progress", className: e, style: r, children: `${Math.round(u * 100)}%` });
1016
+ }
1017
+ Br.displayName = "Ginger.Current.Progress";
1018
+ function Or({
1019
+ className: e,
1020
+ style: r,
1021
+ height: t = 4,
1022
+ showBuffered: a = !1,
1023
+ unstyled: n = !1
1024
+ }) {
1025
+ const i = P(), o = `${Math.round(or(i) * 100)}%`, u = `${Math.round(Math.min(1, Math.max(0, i.bufferedFraction)) * 100)}%`;
1026
+ return /* @__PURE__ */ S(
1027
+ "div",
1028
+ {
1029
+ "data-ginger-component": "TimeRail",
1030
+ className: e,
1031
+ style: n ? { ...r } : {
1032
+ width: "100%",
1033
+ height: t,
1034
+ background: "var(--ginger-muted-color, #e5e7eb)",
1035
+ borderRadius: 999,
1036
+ overflow: "hidden",
1037
+ position: "relative",
1038
+ ...r
1039
+ },
1040
+ "aria-hidden": !0,
1041
+ children: [
1042
+ a ? /* @__PURE__ */ c(
1043
+ "div",
1044
+ {
1045
+ "data-ginger-component": "TimeRail",
1046
+ style: {
1047
+ position: n ? void 0 : "absolute",
1048
+ left: n ? void 0 : 0,
1049
+ top: n ? void 0 : 0,
1050
+ height: n ? void 0 : "100%",
1051
+ width: u,
1052
+ background: n ? void 0 : "var(--ginger-buffer-color, rgba(107, 114, 128, 0.35))"
1053
+ }
1054
+ }
1055
+ ) : null,
1056
+ /* @__PURE__ */ c(
1057
+ "div",
1058
+ {
1059
+ "data-ginger-component": "TimeRail",
1060
+ style: {
1061
+ position: n ? void 0 : "relative",
1062
+ width: o,
1063
+ height: n ? void 0 : "100%",
1064
+ background: n ? void 0 : "var(--ginger-primary-color, #111827)"
1065
+ }
1066
+ }
1067
+ )
1068
+ ]
1069
+ }
1070
+ );
1071
+ }
1072
+ Or.displayName = "Ginger.Current.TimeRail";
1073
+ function $r({
1074
+ className: e,
1075
+ style: r,
1076
+ height: t = 4,
1077
+ unstyled: a = !1
1078
+ }) {
1079
+ const n = P(), i = `${Math.round(Math.min(1, Math.max(0, n.bufferedFraction)) * 100)}%`;
1080
+ return /* @__PURE__ */ c(
1081
+ "div",
1082
+ {
1083
+ "data-ginger-component": "BufferRail",
1084
+ className: e,
1085
+ style: a ? { ...r } : {
1086
+ width: "100%",
1087
+ height: t,
1088
+ background: "var(--ginger-muted-color, #e5e7eb)",
1089
+ borderRadius: 999,
1090
+ overflow: "hidden",
1091
+ ...r
1092
+ },
1093
+ "aria-hidden": !0,
1094
+ children: /* @__PURE__ */ c(
1095
+ "div",
1096
+ {
1097
+ "data-ginger-component": "BufferRail",
1098
+ style: {
1099
+ width: i,
1100
+ height: a ? void 0 : "100%",
1101
+ background: a ? void 0 : "var(--ginger-buffer-color, rgba(107, 114, 128, 0.35))"
1102
+ }
1103
+ }
1104
+ )
1105
+ }
1106
+ );
1107
+ }
1108
+ $r.displayName = "Ginger.Current.BufferRail";
1109
+ function Yr({
1110
+ className: e,
1111
+ style: r,
1112
+ fallback: t,
1113
+ empty: a,
1114
+ children: n
1115
+ }) {
1116
+ const i = P(), o = cr(i);
1117
+ return n ? /* @__PURE__ */ c(
1118
+ "span",
1119
+ {
1120
+ "data-ginger-component": "PlaybackState",
1121
+ className: e,
1122
+ style: r,
1123
+ children: n(o, i)
1124
+ }
1125
+ ) : /* @__PURE__ */ c(
1126
+ "span",
1127
+ {
1128
+ "data-ginger-component": "PlaybackState",
1129
+ className: e,
1130
+ style: r,
1131
+ children: o
1132
+ }
1133
+ );
1134
+ }
1135
+ Yr.displayName = "Ginger.Current.PlaybackState";
1136
+ function Qr({
1137
+ className: e,
1138
+ style: r,
1139
+ fallback: t,
1140
+ empty: a,
1141
+ live: n = "polite",
1142
+ children: i
1143
+ }) {
1144
+ const o = P(), u = o.errorMessage ?? "";
1145
+ if (!u) {
1146
+ const d = a ?? t ?? null;
1147
+ return d ? /* @__PURE__ */ c(
1148
+ "span",
1149
+ {
1150
+ "data-ginger-component": "ErrorMessage",
1151
+ className: e,
1152
+ style: r,
1153
+ children: d
1154
+ }
1155
+ ) : null;
1156
+ }
1157
+ return i ? /* @__PURE__ */ c(
1158
+ "span",
1159
+ {
1160
+ "data-ginger-component": "ErrorMessage",
1161
+ className: e,
1162
+ style: r,
1163
+ "aria-live": n,
1164
+ children: i(u, o)
1165
+ }
1166
+ ) : /* @__PURE__ */ c(
1167
+ "span",
1168
+ {
1169
+ "data-ginger-component": "ErrorMessage",
1170
+ className: e,
1171
+ style: r,
1172
+ "aria-live": n,
1173
+ children: u
1174
+ }
1175
+ );
1176
+ }
1177
+ Qr.displayName = "Ginger.Current.ErrorMessage";
1178
+ const Be = $e(
1179
+ null
1180
+ );
1181
+ function Vn() {
1182
+ const e = Oe(Be);
1183
+ if (!e)
1184
+ throw new Error(
1185
+ "Ginger.Playlist.Track must be used inside <Ginger.Playlist>"
1186
+ );
1187
+ return e;
1188
+ }
1189
+ function Hr({
1190
+ children: e,
1191
+ unstyled: r = !1,
1192
+ rowStyle: t,
1193
+ renderTrack: a,
1194
+ playOnSelect: n = !0,
1195
+ style: i,
1196
+ ...o
1197
+ }) {
1198
+ const { tracks: u, currentIndex: d, playTrackAt: l, selectTrackAt: f } = N(), m = r ? { ...i } : {
1199
+ listStyle: "none",
1200
+ margin: 0,
1201
+ padding: 0,
1202
+ fontFamily: "var(--ginger-font-family, system-ui, sans-serif)",
1203
+ fontSize: "var(--ginger-font-size, 14px)",
1204
+ color: "var(--ginger-primary-color, #111827)",
1205
+ ...i
1206
+ };
1207
+ return e !== void 0 ? /* @__PURE__ */ c(Be.Provider, { value: { playOnSelect: n }, children: /* @__PURE__ */ c("ul", { "data-ginger-component": "Playlist", style: m, ...o, children: e }) }) : /* @__PURE__ */ c(Be.Provider, { value: { playOnSelect: n }, children: /* @__PURE__ */ c("ul", { "data-ginger-component": "Playlist", style: m, ...o, children: u.map((h, v) => {
1208
+ const x = v === d;
1209
+ return /* @__PURE__ */ c("li", { children: /* @__PURE__ */ c(
1210
+ "button",
1211
+ {
1212
+ type: "button",
1213
+ onClick: () => {
1214
+ n ? l(v) : f(v);
1215
+ },
1216
+ style: {
1217
+ width: r ? void 0 : "100%",
1218
+ textAlign: r ? void 0 : "left",
1219
+ border: r ? void 0 : "none",
1220
+ background: r ? void 0 : x ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
1221
+ color: r ? void 0 : "inherit",
1222
+ font: r ? void 0 : "inherit",
1223
+ cursor: r ? void 0 : "pointer",
1224
+ padding: r ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)",
1225
+ ...t
1226
+ },
1227
+ children: a ? a(h, v, x) : /* @__PURE__ */ S("span", { children: [
1228
+ h.title,
1229
+ h.artist ? ` — ${h.artist}` : ""
1230
+ ] })
1231
+ }
1232
+ ) }, `${v}-${Ve(h)}`);
1233
+ }) }) });
1234
+ }
1235
+ Hr.displayName = "Ginger.Playlist";
1236
+ function jr({
1237
+ index: e,
1238
+ unstyled: r = !1,
1239
+ className: t,
1240
+ style: a,
1241
+ children: n,
1242
+ liProps: i,
1243
+ onClick: o,
1244
+ ...u
1245
+ }) {
1246
+ const { playOnSelect: d } = Vn(), { tracks: l, currentIndex: f, playTrackAt: m, selectTrackAt: T } = N(), h = e === f, v = l[e], x = v != null ? /* @__PURE__ */ S("span", { "data-ginger-component": "PlaylistTrack", children: [
1247
+ v.title,
1248
+ v.artist ? ` — ${v.artist}` : ""
1249
+ ] }) : null;
1250
+ return /* @__PURE__ */ c("li", { ...i, "data-ginger-component": "PlaylistTrack", children: /* @__PURE__ */ c(
1251
+ "button",
1252
+ {
1253
+ type: "button",
1254
+ "data-ginger-component": "PlaylistTrackButton",
1255
+ "aria-current": h ? "true" : void 0,
1256
+ "data-ginger-active": h || void 0,
1257
+ className: t,
1258
+ style: {
1259
+ width: r ? void 0 : "100%",
1260
+ textAlign: r ? void 0 : "left",
1261
+ border: r ? void 0 : "none",
1262
+ background: r ? void 0 : h ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
1263
+ color: r ? void 0 : "inherit",
1264
+ font: r ? void 0 : "inherit",
1265
+ cursor: r ? void 0 : "pointer",
1266
+ padding: r ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)",
1267
+ ...a
1268
+ },
1269
+ ...u,
1270
+ onClick: (g) => {
1271
+ o == null || o(g), !g.defaultPrevented && (d ? m(e) : T(e));
1272
+ },
1273
+ children: n ?? x
1274
+ }
1275
+ ) });
1276
+ }
1277
+ jr.displayName = "Ginger.Playlist.Track";
1278
+ const Bn = Object.assign(Hr, {
1279
+ Track: jr
1280
+ }), On = H(
1281
+ "Ginger.Queue.Title",
1282
+ (e) => {
1283
+ var r;
1284
+ return (r = e.playlistMeta) == null ? void 0 : r.title;
1285
+ }
1286
+ ), $n = H(
1287
+ "Ginger.Queue.Subtitle",
1288
+ (e) => {
1289
+ var r;
1290
+ return (r = e.playlistMeta) == null ? void 0 : r.subtitle;
1291
+ }
1292
+ ), Yn = H(
1293
+ "Ginger.Queue.Description",
1294
+ (e) => {
1295
+ var r;
1296
+ return (r = e.playlistMeta) == null ? void 0 : r.description;
1297
+ }
1298
+ ), Qn = H(
1299
+ "Ginger.Queue.Copyright",
1300
+ (e) => {
1301
+ var r;
1302
+ return (r = e.playlistMeta) == null ? void 0 : r.copyright;
1303
+ }
1304
+ );
1305
+ function zr({
1306
+ className: e,
1307
+ style: r,
1308
+ fallback: t,
1309
+ empty: a,
1310
+ unstyled: n = !1,
1311
+ imgStyle: i
1312
+ }) {
1313
+ var l, f;
1314
+ const o = P(), u = (l = o.playlistMeta) == null ? void 0 : l.artworkUrl;
1315
+ if (!u) {
1316
+ const m = a ?? t ?? null;
1317
+ return m ? /* @__PURE__ */ c("span", { className: e, style: r, children: m }) : null;
1318
+ }
1319
+ const d = ((f = o.playlistMeta) == null ? void 0 : f.title) ?? "Playlist artwork";
1320
+ return /* @__PURE__ */ c(
1321
+ "span",
1322
+ {
1323
+ "data-ginger-component": "Artwork",
1324
+ className: e,
1325
+ style: n ? { ...r } : {
1326
+ display: "inline-block",
1327
+ background: "var(--ginger-artwork-bg, #f3f4f6)",
1328
+ borderRadius: "var(--ginger-artwork-radius, 6px)",
1329
+ overflow: "hidden",
1330
+ ...r
1331
+ },
1332
+ children: /* @__PURE__ */ c(
1333
+ "img",
1334
+ {
1335
+ src: u,
1336
+ alt: d,
1337
+ style: {
1338
+ display: n ? void 0 : "block",
1339
+ width: n ? void 0 : "100%",
1340
+ height: n ? void 0 : "100%",
1341
+ objectFit: n ? void 0 : "cover",
1342
+ ...i
1343
+ }
1344
+ }
1345
+ )
1346
+ }
1347
+ );
1348
+ }
1349
+ zr.displayName = "Ginger.Queue.Artwork";
1350
+ function Ne(e) {
1351
+ return Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 1;
1352
+ }
1353
+ function He(e) {
1354
+ return Number.isFinite(e) ? Math.min(4, Math.max(0.25, e)) : 1;
1355
+ }
1356
+ const Q = {
1357
+ currentTime: 0,
1358
+ duration: 0,
1359
+ bufferedFraction: 0,
1360
+ isBuffering: !1,
1361
+ errorMessage: null
1362
+ }, Hn = {
1363
+ ...Q,
1364
+ volume: 1,
1365
+ muted: !1,
1366
+ playbackRate: 1
1367
+ };
1368
+ function Wr(e) {
1369
+ const r = [...e.tracks];
1370
+ let t = Y(e.currentIndex ?? 0, r.length), a = null, n = r;
1371
+ return e.isShuffled && r.length > 1 && (a = [...r], n = ur(r, t), t = 0), {
1372
+ tracks: n,
1373
+ currentIndex: t,
1374
+ playbackMode: e.playbackMode ?? "playlist",
1375
+ isPaused: e.isPaused ?? !0,
1376
+ isShuffled: !!(e.isShuffled && n.length > 1),
1377
+ repeatMode: e.repeatMode ?? "off",
1378
+ originalTracks: a,
1379
+ playlistMeta: e.playlistMeta ?? null,
1380
+ ...Hn,
1381
+ volume: Ne(e.volume ?? 1),
1382
+ muted: e.muted ?? !1,
1383
+ playbackRate: He(e.playbackRate ?? 1)
1384
+ };
1385
+ }
1386
+ function jn(e, r) {
1387
+ switch (r.type) {
1388
+ case "INIT": {
1389
+ const {
1390
+ tracks: t,
1391
+ currentIndex: a,
1392
+ playlistMeta: n,
1393
+ isPaused: i,
1394
+ isShuffled: o,
1395
+ repeatMode: u,
1396
+ playbackMode: d,
1397
+ volume: l,
1398
+ muted: f,
1399
+ playbackRate: m
1400
+ } = r.payload;
1401
+ return Wr({
1402
+ tracks: t,
1403
+ currentIndex: a,
1404
+ playlistMeta: n ?? null,
1405
+ isPaused: i ?? !0,
1406
+ isShuffled: o ?? !1,
1407
+ repeatMode: u ?? "off",
1408
+ playbackMode: d ?? "playlist",
1409
+ volume: l,
1410
+ muted: f,
1411
+ playbackRate: m
1412
+ });
1413
+ }
1414
+ case "SET_QUEUE": {
1415
+ const { tracks: t, currentIndex: a } = r.payload, n = [...t], i = Y(a ?? e.currentIndex, n.length);
1416
+ return {
1417
+ ...e,
1418
+ tracks: n,
1419
+ currentIndex: i,
1420
+ isShuffled: !1,
1421
+ originalTracks: null,
1422
+ ...Q
1423
+ };
1424
+ }
1425
+ case "INSERT_TRACK": {
1426
+ const t = r.payload.index ?? e.tracks.length, a = rr(e.tracks, r.payload.track, t);
1427
+ if (r.payload.autoPlay) {
1428
+ const o = Y(t, a.length);
1429
+ return {
1430
+ ...e,
1431
+ tracks: a,
1432
+ currentIndex: o,
1433
+ isShuffled: !1,
1434
+ originalTracks: null,
1435
+ isPaused: !1,
1436
+ ...Q
1437
+ };
1438
+ }
1439
+ const n = t <= e.currentIndex ? e.currentIndex + 1 : e.currentIndex, i = e.isShuffled && e.originalTracks ? rr(e.originalTracks, r.payload.track, e.originalTracks.length) : e.originalTracks;
1440
+ return {
1441
+ ...e,
1442
+ tracks: a,
1443
+ originalTracks: i,
1444
+ currentIndex: Y(n, a.length)
1445
+ };
1446
+ }
1447
+ case "REMOVE_TRACK": {
1448
+ const t = r.payload.index, a = er(e.tracks, t), n = t < e.currentIndex ? e.currentIndex - 1 : t === e.currentIndex ? Math.min(e.currentIndex, Math.max(0, a.length - 1)) : e.currentIndex, i = e.isShuffled && e.originalTracks ? (() => {
1449
+ const u = e.tracks[t], d = Ce(e.originalTracks, u);
1450
+ return er(e.originalTracks, d);
1451
+ })() : e.originalTracks, o = e.isShuffled && a.length > 1;
1452
+ return {
1453
+ ...e,
1454
+ tracks: a,
1455
+ isShuffled: o,
1456
+ originalTracks: o ? i : null,
1457
+ currentIndex: Y(n, a.length),
1458
+ ...t === e.currentIndex ? Q : {}
1459
+ };
1460
+ }
1461
+ case "MOVE_TRACK": {
1462
+ const { fromIndex: t, toIndex: a } = r.payload, n = yn(e.tracks, t, a);
1463
+ let i = e.currentIndex;
1464
+ return e.currentIndex === t ? i = a : t < e.currentIndex && a >= e.currentIndex ? i -= 1 : t > e.currentIndex && a <= e.currentIndex && (i += 1), {
1465
+ ...e,
1466
+ tracks: n,
1467
+ isShuffled: !1,
1468
+ originalTracks: null,
1469
+ currentIndex: Y(i, n.length)
1470
+ };
1471
+ }
1472
+ case "ADD_NEXT": {
1473
+ const t = Ze(e.tracks, e.currentIndex, r.payload.track), a = e.isShuffled && e.originalTracks ? (() => {
1474
+ const n = e.tracks[e.currentIndex], i = Ce(e.originalTracks, n);
1475
+ return Ze(e.originalTracks, i, r.payload.track);
1476
+ })() : e.originalTracks;
1477
+ return {
1478
+ ...e,
1479
+ tracks: t,
1480
+ originalTracks: a
1481
+ };
1482
+ }
1483
+ case "SET_INDEX": {
1484
+ const t = Y(r.payload.index, e.tracks.length), a = r.payload.autoPlay, n = a === !0 ? !1 : a === !1 ? !0 : e.isPaused;
1485
+ return {
1486
+ ...e,
1487
+ currentIndex: t,
1488
+ ...Q,
1489
+ isPaused: n
1490
+ };
1491
+ }
1492
+ case "PLAY":
1493
+ return { ...e, isPaused: !1 };
1494
+ case "PAUSE":
1495
+ return { ...e, isPaused: !0 };
1496
+ case "TOGGLE_PAUSE":
1497
+ return { ...e, isPaused: !e.isPaused };
1498
+ case "SET_REPEAT":
1499
+ return { ...e, repeatMode: r.payload };
1500
+ case "CYCLE_REPEAT":
1501
+ return { ...e, repeatMode: mn(e.repeatMode) };
1502
+ case "TOGGLE_SHUFFLE": {
1503
+ if (e.tracks.length <= 1) return { ...e, isShuffled: !1, originalTracks: null };
1504
+ if (!e.isShuffled) {
1505
+ const i = [...e.tracks], o = ur(i, e.currentIndex);
1506
+ return {
1507
+ ...e,
1508
+ isShuffled: !0,
1509
+ originalTracks: i,
1510
+ tracks: o,
1511
+ currentIndex: 0
1512
+ };
1513
+ }
1514
+ const t = e.originalTracks ? [...e.originalTracks] : [...e.tracks], a = e.tracks[e.currentIndex], n = Ce(t, a);
1515
+ return {
1516
+ ...e,
1517
+ isShuffled: !1,
1518
+ originalTracks: null,
1519
+ tracks: t,
1520
+ currentIndex: Y(n, t.length)
1521
+ };
1522
+ }
1523
+ case "NEXT": {
1524
+ const t = fn(e), a = t === e.currentIndex;
1525
+ return {
1526
+ ...e,
1527
+ currentIndex: t,
1528
+ ...a ? {} : Q,
1529
+ isPaused: a ? e.isPaused : !1
1530
+ };
1531
+ }
1532
+ case "PREV": {
1533
+ const t = gn(e), a = t === e.currentIndex;
1534
+ return {
1535
+ ...e,
1536
+ currentIndex: t,
1537
+ ...a ? {} : Q,
1538
+ isPaused: a ? e.isPaused : !1
1539
+ };
1540
+ }
1541
+ case "MEDIA_TIME_UPDATE":
1542
+ return {
1543
+ ...e,
1544
+ currentTime: r.payload.currentTime,
1545
+ duration: Number.isFinite(r.payload.duration) ? r.payload.duration : e.duration,
1546
+ bufferedFraction: r.payload.bufferedFraction,
1547
+ isBuffering: !1
1548
+ };
1549
+ case "MEDIA_LOADED_METADATA":
1550
+ return {
1551
+ ...e,
1552
+ duration: Number.isFinite(r.payload.duration) ? r.payload.duration : e.duration,
1553
+ bufferedFraction: r.payload.bufferedFraction,
1554
+ errorMessage: null
1555
+ };
1556
+ case "SET_PLAYLIST_META":
1557
+ return { ...e, playlistMeta: r.payload };
1558
+ case "SET_PLAYBACK_MODE":
1559
+ return { ...e, playbackMode: r.payload };
1560
+ case "MEDIA_ERROR":
1561
+ return {
1562
+ ...e,
1563
+ errorMessage: r.payload.message,
1564
+ isPaused: !0,
1565
+ isBuffering: !1
1566
+ };
1567
+ case "MEDIA_WAITING":
1568
+ return { ...e, isBuffering: !0 };
1569
+ case "MEDIA_CANPLAY":
1570
+ return { ...e, isBuffering: !1, errorMessage: null };
1571
+ case "MEDIA_PLAY":
1572
+ return { ...e, isPaused: !1, isBuffering: !1 };
1573
+ case "MEDIA_PAUSE":
1574
+ return { ...e, isPaused: !0 };
1575
+ case "RESET_MEDIA_TIMES":
1576
+ return { ...e, currentTime: 0, duration: 0, bufferedFraction: 0 };
1577
+ case "MEDIA_SOURCE_CLEARED":
1578
+ return { ...e, ...Q };
1579
+ case "SET_VOLUME":
1580
+ return { ...e, volume: Ne(r.payload) };
1581
+ case "SET_MUTED":
1582
+ return { ...e, muted: r.payload };
1583
+ case "TOGGLE_MUTE":
1584
+ return { ...e, muted: !e.muted };
1585
+ case "SET_PLAYBACK_RATE":
1586
+ return { ...e, playbackRate: He(r.payload) };
1587
+ case "MEDIA_VOLUME_SYNC": {
1588
+ const { volume: t, muted: a } = r.payload, n = Ne(t);
1589
+ return n === e.volume && a === e.muted ? e : { ...e, volume: n, muted: a };
1590
+ }
1591
+ default:
1592
+ return e;
1593
+ }
1594
+ }
1595
+ function Ue() {
1596
+ return typeof navigator > "u" || !("mediaSession" in navigator) ? null : navigator.mediaSession;
1597
+ }
1598
+ function zn(e, r, t) {
1599
+ var d;
1600
+ const a = r.tracks[r.currentIndex], n = a == null ? void 0 : a.title, i = a == null ? void 0 : a.artist, o = a == null ? void 0 : a.album, u = hn(a, (d = r.playlistMeta) == null ? void 0 : d.artworkUrl);
1601
+ E(() => {
1602
+ const l = Ue();
1603
+ !e || !l || (l.metadata = new MediaMetadata({
1604
+ title: n ?? "Unknown track",
1605
+ artist: i,
1606
+ album: o,
1607
+ artwork: u ? [{ src: u }] : void 0
1608
+ }));
1609
+ }, [e, n, i, o, u]), E(() => {
1610
+ const l = Ue();
1611
+ !e || !l || (l.playbackState = r.isPaused ? "paused" : "playing");
1612
+ }, [e, r.isPaused]), E(() => {
1613
+ const l = Ue();
1614
+ if (!(!e || !l)) {
1615
+ try {
1616
+ l.setActionHandler("play", t.play), l.setActionHandler("pause", t.pause), l.setActionHandler("nexttrack", t.next), l.setActionHandler("previoustrack", t.prev), l.setActionHandler("seekto", (f) => {
1617
+ typeof f.seekTime == "number" && Number.isFinite(f.seekTime) && t.seek(f.seekTime);
1618
+ });
1619
+ } catch {
1620
+ }
1621
+ return () => {
1622
+ try {
1623
+ l.setActionHandler("play", null), l.setActionHandler("pause", null), l.setActionHandler("nexttrack", null), l.setActionHandler("previoustrack", null), l.setActionHandler("seekto", null);
1624
+ } catch {
1625
+ }
1626
+ };
1627
+ }
1628
+ }, [e, t]);
1629
+ }
1630
+ const Wn = {
1631
+ "--ginger-primary-color": "#111827",
1632
+ "--ginger-muted-color": "#6b7280",
1633
+ "--ginger-font-size": "14px",
1634
+ "--ginger-font-family": "system-ui, sans-serif",
1635
+ "--ginger-playlist-row-padding": "6px 8px",
1636
+ "--ginger-artwork-radius": "6px",
1637
+ "--ginger-artwork-bg": "#f3f4f6",
1638
+ "--ginger-playlist-active-bg": "rgba(17, 24, 39, 0.06)",
1639
+ "--ginger-buffer-color": "rgba(107, 114, 128, 0.35)",
1640
+ "--ginger-focus-ring": "0 0 0 2px rgba(59, 130, 246, 0.45)"
1641
+ };
1642
+ function Xn({
1643
+ children: e,
1644
+ initialTracks: r = [],
1645
+ initialIndex: t = 0,
1646
+ initialPlaylistMeta: a = null,
1647
+ initialShuffle: n = !1,
1648
+ initialRepeatMode: i = "off",
1649
+ initialPlaybackMode: o = "playlist",
1650
+ initialPaused: u = !0,
1651
+ initialVolume: d = 1,
1652
+ initialMuted: l = !1,
1653
+ initialPlaybackRate: f = 1,
1654
+ initialStateKey: m,
1655
+ locale: T,
1656
+ mediaSession: h = !1,
1657
+ beforePlay: v,
1658
+ onPlayBlocked: x,
1659
+ persistence: g,
1660
+ hydrateOnMount: I = !1,
1661
+ resumeOnTrackChange: G = !1,
1662
+ unstyled: F = !1,
1663
+ asChild: Z = !1,
1664
+ className: ee,
1665
+ style: _e,
1666
+ dir: Xr,
1667
+ prevRestartThresholdSeconds: je = 3,
1668
+ onTrackChange: re,
1669
+ onPlay: ne,
1670
+ onPause: te,
1671
+ onQueueEnd: ae,
1672
+ onError: ie,
1673
+ onVolumeChange: oe,
1674
+ onPlaybackRateChange: ce,
1675
+ onSeek: U
1676
+ }) {
1677
+ var Je;
1678
+ const V = C(null), [s, y] = tn(
1679
+ jn,
1680
+ void 0,
1681
+ () => Wr({
1682
+ tracks: r,
1683
+ currentIndex: t,
1684
+ playlistMeta: a,
1685
+ isPaused: u,
1686
+ isShuffled: n,
1687
+ repeatMode: i,
1688
+ playbackMode: o,
1689
+ volume: d,
1690
+ muted: l,
1691
+ playbackRate: f
1692
+ })
1693
+ ), ze = C(s), De = C({
1694
+ tracks: r,
1695
+ currentIndex: t,
1696
+ playlistMeta: a,
1697
+ isPaused: u,
1698
+ isShuffled: n,
1699
+ repeatMode: i,
1700
+ playbackMode: o,
1701
+ volume: d,
1702
+ muted: l,
1703
+ playbackRate: f
1704
+ });
1705
+ De.current = {
1706
+ tracks: r,
1707
+ currentIndex: t,
1708
+ playlistMeta: a,
1709
+ isPaused: u,
1710
+ isShuffled: n,
1711
+ repeatMode: i,
1712
+ playbackMode: o,
1713
+ volume: d,
1714
+ muted: l,
1715
+ playbackRate: f
1716
+ };
1717
+ const q = C(void 0);
1718
+ E(() => {
1719
+ if (m === void 0) {
1720
+ q.current = void 0;
1721
+ return;
1722
+ }
1723
+ if (q.current === void 0) {
1724
+ q.current = m;
1725
+ return;
1726
+ }
1727
+ if (q.current === m) return;
1728
+ q.current = m;
1729
+ const p = De.current;
1730
+ y({
1731
+ type: "INIT",
1732
+ payload: {
1733
+ tracks: p.tracks,
1734
+ currentIndex: p.currentIndex,
1735
+ playlistMeta: p.playlistMeta,
1736
+ isPaused: p.isPaused,
1737
+ isShuffled: p.isShuffled,
1738
+ repeatMode: p.repeatMode,
1739
+ playbackMode: p.playbackMode,
1740
+ volume: p.volume,
1741
+ muted: p.muted,
1742
+ playbackRate: p.playbackRate
1743
+ }
1744
+ });
1745
+ }, [m, y]), E(() => {
1746
+ ze.current = s;
1747
+ }, [s]);
1748
+ const We = s.tracks[s.currentIndex] ?? null;
1749
+ E(() => {
1750
+ re == null || re(We, s.currentIndex);
1751
+ }, [We, s.currentIndex, re]), E(() => {
1752
+ s.errorMessage && (ie == null || ie(s.errorMessage));
1753
+ }, [s.errorMessage, ie]);
1754
+ const ue = C(void 0);
1755
+ E(() => {
1756
+ if (ue.current === void 0) {
1757
+ ue.current = s.isPaused;
1758
+ return;
1759
+ }
1760
+ ue.current !== s.isPaused && (s.isPaused ? te == null || te() : ne == null || ne()), ue.current = s.isPaused;
1761
+ }, [s.isPaused, te, ne]);
1762
+ const se = C(void 0), le = C(void 0);
1763
+ E(() => {
1764
+ if (se.current === void 0 || le.current === void 0) {
1765
+ se.current = s.volume, le.current = s.muted;
1766
+ return;
1767
+ }
1768
+ (se.current !== s.volume || le.current !== s.muted) && (oe == null || oe(s.volume, s.muted)), se.current = s.volume, le.current = s.muted;
1769
+ }, [s.volume, s.muted, oe]);
1770
+ const de = C(void 0);
1771
+ E(() => {
1772
+ if (de.current === void 0) {
1773
+ de.current = s.playbackRate;
1774
+ return;
1775
+ }
1776
+ de.current !== s.playbackRate && (ce == null || ce(s.playbackRate)), de.current = s.playbackRate;
1777
+ }, [s.playbackRate, ce]);
1778
+ const B = M(() => {
1779
+ y({ type: "PLAY" });
1780
+ }, []), O = M(() => {
1781
+ var p;
1782
+ y({ type: "PAUSE" }), (p = V.current) == null || p.pause();
1783
+ }, []), pe = M(() => {
1784
+ s.isPaused ? B() : O();
1785
+ }, [O, B, s.isPaused]), $ = M(
1786
+ (p) => {
1787
+ const b = V.current;
1788
+ b && Number.isFinite(p) && (b.currentTime = Math.max(0, p), U == null || U(Math.max(0, p)));
1789
+ },
1790
+ [U]
1791
+ ), ge = M((p) => {
1792
+ y({ type: "SET_VOLUME", payload: Ne(p) });
1793
+ }, []), fe = M((p) => {
1794
+ y({ type: "SET_MUTED", payload: p });
1795
+ }, []), me = M(() => {
1796
+ y({ type: "TOGGLE_MUTE" });
1797
+ }, []), ye = M((p) => {
1798
+ y({ type: "SET_PLAYBACK_RATE", payload: He(p) });
1799
+ }, []), z = M(() => {
1800
+ y({ type: "NEXT" });
1801
+ }, []), W = M(() => {
1802
+ const p = V.current, b = je ?? 3;
1803
+ p && b > 0 && p.currentTime > b ? (p.currentTime = 0, U == null || U(0)) : y({ type: "PREV" });
1804
+ }, [je, U]), he = M((p) => {
1805
+ y({ type: "SET_REPEAT", payload: p });
1806
+ }, []), ve = M(() => {
1807
+ y({ type: "CYCLE_REPEAT" });
1808
+ }, []), be = M(() => {
1809
+ y({ type: "TOGGLE_SHUFFLE" });
1810
+ }, []), ke = M((p, b) => {
1811
+ y({ type: "SET_QUEUE", payload: { tracks: p, currentIndex: b } });
1812
+ }, []), Te = M((p, b, k) => {
1813
+ y({ type: "INSERT_TRACK", payload: { track: p, index: b, autoPlay: k } });
1814
+ }, []), xe = M((p) => {
1815
+ y({ type: "REMOVE_TRACK", payload: { index: p } });
1816
+ }, []), Me = M((p, b) => {
1817
+ y({ type: "MOVE_TRACK", payload: { fromIndex: p, toIndex: b } });
1818
+ }, []), Ie = M((p) => {
1819
+ y({ type: "ADD_NEXT", payload: { track: p } });
1820
+ }, []), Ee = M((p) => {
1821
+ y({ type: "SET_INDEX", payload: { index: p, autoPlay: !0 } });
1822
+ }, []), Pe = M((p) => {
1823
+ y({ type: "SET_INDEX", payload: { index: p, autoPlay: !1 } });
1824
+ }, []), Ae = M((p) => {
1825
+ y({ type: "SET_PLAYLIST_META", payload: p });
1826
+ }, []), Se = M((p) => {
1827
+ y({ type: "SET_PLAYBACK_MODE", payload: p });
1828
+ }, []), Re = M((p) => {
1829
+ y({ type: "INIT", payload: p });
1830
+ }, []);
1831
+ E(() => {
1832
+ if (!(!g || !I))
1833
+ try {
1834
+ const p = g.get("ginger:volume"), b = g.get("ginger:muted"), k = g.get("ginger:playbackRate"), w = g.get("ginger:repeatMode"), we = g.get("ginger:currentIndex"), D = De.current;
1835
+ y({
1836
+ type: "INIT",
1837
+ payload: {
1838
+ tracks: D.tracks,
1839
+ playlistMeta: D.playlistMeta,
1840
+ isPaused: D.isPaused,
1841
+ isShuffled: D.isShuffled,
1842
+ playbackMode: D.playbackMode,
1843
+ currentIndex: typeof we == "number" ? we : D.currentIndex,
1844
+ repeatMode: w === "off" || w === "all" || w === "one" ? w : D.repeatMode,
1845
+ volume: typeof p == "number" ? p : D.volume,
1846
+ muted: typeof b == "boolean" ? b : D.muted,
1847
+ playbackRate: typeof k == "number" ? k : D.playbackRate
1848
+ }
1849
+ });
1850
+ } catch (p) {
1851
+ process.env.NODE_ENV !== "production" && console.warn("[@lucaismyname/ginger] persistence.get() threw during hydration:", p);
1852
+ }
1853
+ }, [I, g]), E(() => {
1854
+ if (g)
1855
+ try {
1856
+ g.set("ginger:volume", s.volume), g.set("ginger:muted", s.muted), g.set("ginger:playbackRate", s.playbackRate), g.set("ginger:repeatMode", s.repeatMode), g.set("ginger:currentIndex", s.currentIndex);
1857
+ } catch (p) {
1858
+ process.env.NODE_ENV !== "production" && console.warn("[@lucaismyname/ginger] persistence.set() threw:", p);
1859
+ }
1860
+ }, [
1861
+ g,
1862
+ s.volume,
1863
+ s.muted,
1864
+ s.playbackRate,
1865
+ s.repeatMode,
1866
+ s.currentIndex
1867
+ ]), E(() => {
1868
+ if (!g || !G) return;
1869
+ const p = s.tracks[s.currentIndex];
1870
+ if (!p) return;
1871
+ const b = `ginger:resume:${Ve(p)}`;
1872
+ try {
1873
+ const k = g.get(b);
1874
+ typeof k == "number" && Number.isFinite(k) && $(k);
1875
+ } catch (k) {
1876
+ process.env.NODE_ENV !== "production" && console.warn("[@lucaismyname/ginger] persistence.get() threw during resume:", k);
1877
+ }
1878
+ }, [g, G, s.currentIndex, s.tracks, $]), E(() => {
1879
+ if (!g || !G) return;
1880
+ const p = s.tracks[s.currentIndex];
1881
+ if (!p || !(s.currentTime >= 0)) return;
1882
+ const b = `ginger:resume:${Ve(p)}`, k = setTimeout(() => {
1883
+ try {
1884
+ g.set(b, s.currentTime);
1885
+ } catch (w) {
1886
+ process.env.NODE_ENV !== "production" && console.warn("[@lucaismyname/ginger] persistence.set() threw during resume save:", w);
1887
+ }
1888
+ }, 250);
1889
+ return () => clearTimeout(k);
1890
+ }, [g, G, s.currentIndex, s.tracks, s.currentTime]);
1891
+ const Kr = (Je = s.tracks[s.currentIndex]) == null ? void 0 : Je.fileUrl;
1892
+ E(() => {
1893
+ const p = V.current;
1894
+ if (!p) return;
1895
+ if (s.isPaused) {
1896
+ p.pause();
1897
+ return;
1898
+ }
1899
+ let b = !1;
1900
+ return (async () => {
1901
+ if (v) {
1902
+ let k = !1;
1903
+ try {
1904
+ k = await v();
1905
+ } catch (w) {
1906
+ const we = w instanceof Error ? w.message : "beforePlay rejected";
1907
+ y({ type: "MEDIA_ERROR", payload: { message: we } });
1908
+ return;
1909
+ }
1910
+ if (!k) {
1911
+ b || (y({ type: "PAUSE" }), x == null || x());
1912
+ return;
1913
+ }
1914
+ }
1915
+ b || p.play().catch((k) => {
1916
+ const w = k instanceof Error ? k.message : typeof k == "string" ? k : "Playback failed (e.g. autoplay blocked or unavailable source)";
1917
+ y({ type: "MEDIA_ERROR", payload: { message: w } });
1918
+ });
1919
+ })(), () => {
1920
+ b = !0;
1921
+ };
1922
+ }, [v, Kr, x, s.isPaused]);
1923
+ const Ge = M(() => {
1924
+ const p = vn(ze.current);
1925
+ if (p.kind === "replay_same") {
1926
+ const k = V.current;
1927
+ k && (k.currentTime = 0), y({ type: "PLAY" });
1928
+ return;
1929
+ }
1930
+ if (p.kind === "stop") {
1931
+ y({ type: "PAUSE" }), ae == null || ae();
1932
+ return;
1933
+ }
1934
+ const b = p.nextIndex;
1935
+ y({ type: "SET_INDEX", payload: { index: b, autoPlay: !0 } });
1936
+ }, [ae]), qr = A(
1937
+ () => ({ play: B, pause: O, next: z, prev: W, seek: $ }),
1938
+ [B, O, z, W, $]
1939
+ );
1940
+ zn(!!h, s, qr);
1941
+ const Xe = Xr ?? (T != null && T.seek && /[\u0590-\u08FF]/.test(T.seek) ? "rtl" : "ltr"), Jr = A(
1942
+ () => ({
1943
+ state: s,
1944
+ dispatch: y,
1945
+ audioRef: V,
1946
+ notifyEnded: Ge,
1947
+ init: Re,
1948
+ play: B,
1949
+ pause: O,
1950
+ togglePlayPause: pe,
1951
+ seek: $,
1952
+ setVolume: ge,
1953
+ setMuted: fe,
1954
+ toggleMute: me,
1955
+ setPlaybackRate: ye,
1956
+ next: z,
1957
+ prev: W,
1958
+ setRepeatMode: he,
1959
+ cycleRepeat: ve,
1960
+ toggleShuffle: be,
1961
+ setQueue: ke,
1962
+ insertTrackAt: Te,
1963
+ removeTrackAt: xe,
1964
+ moveTrack: Me,
1965
+ enqueueNext: Ie,
1966
+ playTrackAt: Ee,
1967
+ selectTrackAt: Pe,
1968
+ setPlaylistMeta: Ae,
1969
+ setPlaybackMode: Se
1970
+ }),
1971
+ [
1972
+ ve,
1973
+ y,
1974
+ Re,
1975
+ z,
1976
+ Ge,
1977
+ O,
1978
+ B,
1979
+ Ee,
1980
+ Te,
1981
+ xe,
1982
+ Me,
1983
+ Ie,
1984
+ Pe,
1985
+ W,
1986
+ $,
1987
+ fe,
1988
+ ye,
1989
+ ke,
1990
+ he,
1991
+ Ae,
1992
+ Se,
1993
+ ge,
1994
+ s,
1995
+ me,
1996
+ pe,
1997
+ be
1998
+ ]
1999
+ ), Zr = A(
2000
+ () => ({
2001
+ tracks: s.tracks,
2002
+ currentIndex: s.currentIndex,
2003
+ isPaused: s.isPaused,
2004
+ isShuffled: s.isShuffled,
2005
+ repeatMode: s.repeatMode,
2006
+ originalTracks: s.originalTracks,
2007
+ playlistMeta: s.playlistMeta,
2008
+ init: Re,
2009
+ play: B,
2010
+ pause: O,
2011
+ togglePlayPause: pe,
2012
+ next: z,
2013
+ prev: W,
2014
+ setRepeatMode: he,
2015
+ cycleRepeat: ve,
2016
+ toggleShuffle: be,
2017
+ playbackMode: s.playbackMode,
2018
+ setQueue: ke,
2019
+ insertTrackAt: Te,
2020
+ removeTrackAt: xe,
2021
+ moveTrack: Me,
2022
+ enqueueNext: Ie,
2023
+ playTrackAt: Ee,
2024
+ selectTrackAt: Pe,
2025
+ setPlaylistMeta: Ae,
2026
+ setPlaybackMode: Se,
2027
+ dispatch: y
2028
+ }),
2029
+ [
2030
+ s.tracks,
2031
+ s.currentIndex,
2032
+ s.isPaused,
2033
+ s.isShuffled,
2034
+ s.repeatMode,
2035
+ s.playbackMode,
2036
+ s.originalTracks,
2037
+ s.playlistMeta,
2038
+ Re,
2039
+ B,
2040
+ O,
2041
+ pe,
2042
+ z,
2043
+ W,
2044
+ he,
2045
+ ve,
2046
+ be,
2047
+ ke,
2048
+ Te,
2049
+ xe,
2050
+ Me,
2051
+ Ie,
2052
+ Ee,
2053
+ Pe,
2054
+ Ae,
2055
+ Se,
2056
+ y
2057
+ ]
2058
+ ), en = A(
2059
+ () => ({
2060
+ currentTime: s.currentTime,
2061
+ duration: s.duration,
2062
+ bufferedFraction: s.bufferedFraction,
2063
+ isBuffering: s.isBuffering,
2064
+ errorMessage: s.errorMessage,
2065
+ volume: s.volume,
2066
+ muted: s.muted,
2067
+ playbackRate: s.playbackRate,
2068
+ seek: $,
2069
+ setVolume: ge,
2070
+ setMuted: fe,
2071
+ toggleMute: me,
2072
+ setPlaybackRate: ye,
2073
+ audioRef: V,
2074
+ notifyEnded: Ge,
2075
+ dispatch: y
2076
+ }),
2077
+ [
2078
+ s.currentTime,
2079
+ s.duration,
2080
+ s.bufferedFraction,
2081
+ s.isBuffering,
2082
+ s.errorMessage,
2083
+ s.volume,
2084
+ s.muted,
2085
+ s.playbackRate,
2086
+ $,
2087
+ ge,
2088
+ fe,
2089
+ me,
2090
+ ye,
2091
+ V,
2092
+ Ge,
2093
+ y
2094
+ ]
2095
+ ), Ke = cr(s), qe = A(
2096
+ () => F ? _e : { ...Wn, ..._e },
2097
+ [_e, F]
2098
+ ), _ = A(
2099
+ () => ({
2100
+ className: ee,
2101
+ style: qe,
2102
+ "data-ginger-playback": Ke,
2103
+ dir: Xe
2104
+ }),
2105
+ [ee, qe, Ke, Xe]
2106
+ ), rn = A(() => {
2107
+ if (!Z)
2108
+ return /* @__PURE__ */ c(
2109
+ "div",
2110
+ {
2111
+ className: _.className,
2112
+ style: _.style,
2113
+ "data-ginger-playback": _["data-ginger-playback"],
2114
+ dir: _.dir,
2115
+ children: e
2116
+ }
2117
+ );
2118
+ const p = an.only(e);
2119
+ if (!on(p))
2120
+ throw new Error("Ginger.Provider asChild expects a single React element child.");
2121
+ const b = p, k = b.props.style;
2122
+ return cn(b, {
2123
+ className: Kn(b.props.className, _.className),
2124
+ style: k && typeof k == "object" ? { ...k, ..._.style } : _.style,
2125
+ "data-ginger-playback": _["data-ginger-playback"],
2126
+ dir: _.dir
2127
+ });
2128
+ }, [Z, e, _]);
2129
+ return /* @__PURE__ */ c(xn, { locale: T, children: /* @__PURE__ */ c(un.Provider, { value: Zr, children: /* @__PURE__ */ c(sn.Provider, { value: en, children: /* @__PURE__ */ c(sr.Provider, { value: Jr, children: rn }) }) }) });
2130
+ }
2131
+ function Kn(e, r) {
2132
+ const t = [e, r].filter(Boolean).join(" ");
2133
+ return t === "" ? void 0 : t;
2134
+ }
2135
+ const rt = {
2136
+ Provider: Xn,
2137
+ Player: kn,
2138
+ Current: {
2139
+ Title: An,
2140
+ Artist: Sn,
2141
+ Album: Rn,
2142
+ Description: Gn,
2143
+ Copyright: wn,
2144
+ Genre: Ln,
2145
+ Label: Nn,
2146
+ Isrc: _n,
2147
+ TrackNumber: Dn,
2148
+ Year: Sr,
2149
+ Lyrics: Rr,
2150
+ LyricsSynced: Gr,
2151
+ Chapters: wr,
2152
+ FileUrl: Lr,
2153
+ Artwork: Nr,
2154
+ QueueIndex: _r,
2155
+ QueueLength: Dr,
2156
+ QueuePosition: Cr,
2157
+ Elapsed: Fr,
2158
+ Duration: Ur,
2159
+ Remaining: Vr,
2160
+ Progress: Br,
2161
+ TimeRail: Or,
2162
+ BufferRail: $r,
2163
+ PlaybackState: Yr,
2164
+ ErrorMessage: Qr
2165
+ },
2166
+ Queue: {
2167
+ Title: On,
2168
+ Subtitle: $n,
2169
+ Description: Yn,
2170
+ Copyright: Qn,
2171
+ Artwork: zr
2172
+ },
2173
+ Control: {
2174
+ PlayPause: br,
2175
+ Repeat: kr,
2176
+ Next: Tr,
2177
+ Previous: xr,
2178
+ Shuffle: Mr,
2179
+ SeekBar: Ir,
2180
+ Volume: Er,
2181
+ Mute: Pr,
2182
+ PlaybackRate: Ar
2183
+ },
2184
+ Icon: {
2185
+ Play: pr,
2186
+ Pause: dr,
2187
+ SkipForward: yr,
2188
+ SkipBack: mr,
2189
+ Shuffle: fr,
2190
+ Volume2: hr,
2191
+ VolumeX: vr,
2192
+ RepeatGlyph: gr,
2193
+ Wrapper: L
2194
+ },
2195
+ Playlist: Bn
2196
+ };
2197
+ export {
2198
+ wr as C,
2199
+ rt as G,
2200
+ Gr as L,
2201
+ dr as P,
2202
+ gr as R,
2203
+ fr as S,
2204
+ hr as V,
2205
+ L as W,
2206
+ pr as a,
2207
+ mr as b,
2208
+ yr as c,
2209
+ vr as d,
2210
+ He as e,
2211
+ Ne as f,
2212
+ Le as g,
2213
+ R as h,
2214
+ Fn as i,
2215
+ En as j,
2216
+ Mn as k,
2217
+ In as l,
2218
+ Wr as m,
2219
+ jn as n,
2220
+ Cn as p,
2221
+ Un as u
2222
+ };
2223
+ //# sourceMappingURL=ginger-L2ZFgzH4.js.map