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