@lucaismyname/ginger 0.0.25 → 0.0.28

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