markdown-flow-ui 0.2.26-dev.5 → 0.2.26-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,56 +1,56 @@
1
- import { jsxs as H, jsx as s, Fragment as Pt } from "react/jsx-runtime";
2
- import _r, { memo as Mr, useId as wr, useContext as Tr, useRef as i, useState as Ge, useMemo as ce, useCallback as u, useEffect as m } from "react";
3
- import { getMarkdownFlowDirection as kr, getMarkdownFlowLanguage as vr } from "../../lib/locale.es.js";
4
- import { useDetachedLanguage as Lr } from "../../lib/useDetachedLanguage.es.js";
5
- import { useResolvedDirection as Ar } from "../../lib/useResolvedDirection.es.js";
6
- import { cn as Cr } from "../../lib/utils.es.js";
7
- import xr from "./MobilePlayerSettingsSheet.es.js";
8
- import { getSlidePlayerTexts as Nr } from "./slideI18n.es.js";
9
- import { DEFAULT_MOBILE_VIEW_MODE as Er } from "./utils/mobileScreenMode.es.js";
10
- import { hasReachedAudioEnd as Kr } from "./utils/audioCompletion.es.js";
11
- import { PlayerKeyboardShortcutContext as Fr } from "./utils/playerKeyboardShortcutContext.es.js";
12
- import { activatePlayerKeyboardShortcutOwner as Ur, registerPlayerKeyboardShortcutOwner as Br, isActivePlayerKeyboardShortcutOwner as Wr, getPlayerKeyboardShortcutAction as Or, shouldIgnorePlayerKeyboardShortcutEvent as Rr } from "./utils/playerKeyboardShortcuts.es.js";
13
- import { resolveAudioPlaybackSourceType as Vr } from "./utils/playbackSource.es.js";
14
- import { shouldKeepPlayingAfterNavigation as Ir } from "./utils/playbackPreference.es.js";
15
- import { toPlayerCustomActionList as $r } from "./utils/playerCustomActions.es.js";
1
+ import { jsxs as H, jsx as s, Fragment as jt } from "react/jsx-runtime";
2
+ import wr, { memo as Tr, useId as vr, useContext as kr, useRef as a, useState as Ge, useMemo as ce, useCallback as u, useEffect as m } from "react";
3
+ import { getMarkdownFlowDirection as Lr, getMarkdownFlowLanguage as Ar } from "../../lib/locale.es.js";
4
+ import { useDetachedLanguage as Cr } from "../../lib/useDetachedLanguage.es.js";
5
+ import { useResolvedDirection as xr } from "../../lib/useResolvedDirection.es.js";
6
+ import { cn as Nr } from "../../lib/utils.es.js";
7
+ import Er from "./MobilePlayerSettingsSheet.es.js";
8
+ import { getSlidePlayerTexts as Kr } from "./slideI18n.es.js";
9
+ import { DEFAULT_MOBILE_VIEW_MODE as Fr } from "./utils/mobileScreenMode.es.js";
10
+ import { hasReachedAudioEnd as Ur } from "./utils/audioCompletion.es.js";
11
+ import { PlayerKeyboardShortcutContext as Wr } from "./utils/playerKeyboardShortcutContext.es.js";
12
+ import { activatePlayerKeyboardShortcutOwner as Br, registerPlayerKeyboardShortcutOwner as Rr, isActivePlayerKeyboardShortcutOwner as Or, getPlayerKeyboardShortcutAction as Ir, shouldIgnorePlayerKeyboardShortcutEvent as Vr } from "./utils/playerKeyboardShortcuts.es.js";
13
+ import { resolveAudioPlaybackSourceType as $r } from "./utils/playbackSource.es.js";
14
+ import { shouldKeepPlayingAfterNavigation as Hr } from "./utils/playbackPreference.es.js";
15
+ import { toPlayerCustomActionList as Dr } from "./utils/playerCustomActions.es.js";
16
16
  import { suppressPlayerControlsWakeAfterNavigation as Qe } from "./utils/playerNavigationContext.es.js";
17
- import { isPlaybackTimeCoveredBySegments as Xe, resolveSegmentSeekTarget as Zt } from "./utils/segmentSeek.es.js";
18
- import { getSortedAudioSegments as jt } from "./utils/audioSegments.es.js";
19
- import { getSubtitleCueJumpTarget as Hr, shouldClearSubtitleCueJumpTarget as Dr } from "./utils/subtitleCue.es.js";
17
+ import { isPlaybackTimeCoveredBySegments as Xe, resolveSegmentSeekTarget as zt } from "./utils/segmentSeek.es.js";
18
+ import { getSortedAudioSegments as Yt } from "./utils/audioSegments.es.js";
19
+ import { getSubtitleCueJumpTarget as Jr, shouldClearSubtitleCueJumpTarget as Pr } from "./utils/subtitleCue.es.js";
20
20
  /* empty css */
21
- import Jr from "../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js";
22
- import Pr from "../../node_modules/lucide-react/dist/esm/icons/volume-2.es.js";
23
- import Zr from "../../node_modules/lucide-react/dist/esm/icons/skip-back.es.js";
24
- import jr from "../../node_modules/lucide-react/dist/esm/icons/skip-forward.es.js";
25
- import zr from "../../node_modules/lucide-react/dist/esm/icons/rewind.es.js";
26
- import Yr from "../../node_modules/lucide-react/dist/esm/icons/fast-forward.es.js";
27
- import Gr from "../../node_modules/lucide-react/dist/esm/icons/captions.es.js";
28
- import Qr from "../../node_modules/lucide-react/dist/esm/icons/captions-off.es.js";
29
- import Xr from "../../node_modules/lucide-react/dist/esm/icons/scan-line.es.js";
30
- import qr from "../../node_modules/lucide-react/dist/esm/icons/maximize.es.js";
31
- const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
32
- if (typeof window > "u" || !d || zt.has(d))
21
+ import Zr from "../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js";
22
+ import jr from "../../node_modules/lucide-react/dist/esm/icons/volume-2.es.js";
23
+ import zr from "../../node_modules/lucide-react/dist/esm/icons/skip-back.es.js";
24
+ import Yr from "../../node_modules/lucide-react/dist/esm/icons/skip-forward.es.js";
25
+ import Gr from "../../node_modules/lucide-react/dist/esm/icons/rewind.es.js";
26
+ import Qr from "../../node_modules/lucide-react/dist/esm/icons/fast-forward.es.js";
27
+ import Xr from "../../node_modules/lucide-react/dist/esm/icons/captions.es.js";
28
+ import qr from "../../node_modules/lucide-react/dist/esm/icons/captions-off.es.js";
29
+ import en from "../../node_modules/lucide-react/dist/esm/icons/scan-line.es.js";
30
+ import tn from "../../node_modules/lucide-react/dist/esm/icons/maximize.es.js";
31
+ const Gt = /* @__PURE__ */ new Map(), Qt = (d) => {
32
+ if (typeof window > "u" || !d || Gt.has(d))
33
33
  return;
34
34
  const p = window.document.createElement("audio");
35
- p.preload = "auto", p.setAttribute("playsinline", "true"), p.src = d, p.load(), zt.set(d, p);
36
- }, en = (d, p) => p !== null && p.audioList === d && p.subtitleCueLists.length === d.length && d.every((l, w) => {
37
- const T = l.element?.subtitle_cues;
35
+ p.preload = "auto", p.setAttribute("playsinline", "true"), p.src = d, p.load(), Gt.set(d, p);
36
+ }, rn = (d, p) => p !== null && p.audioList === d && p.subtitleCueLists.length === d.length && d.every((i, w) => {
37
+ const T = i.element?.subtitle_cues;
38
38
  return p.subtitleCueLists[w] === T && p.subtitleCueLengths[w] === (T?.length ?? 0);
39
- }), tn = (d) => {
39
+ }), nn = (d) => {
40
40
  const p = d.map(
41
- (l) => l.element?.subtitle_cues
41
+ (i) => i.element?.subtitle_cues
42
42
  );
43
43
  return {
44
44
  audioList: d,
45
45
  subtitleCueLists: p,
46
46
  subtitleCueLengths: p.map(
47
- (l) => l?.length ?? 0
47
+ (i) => i?.length ?? 0
48
48
  ),
49
- tracks: p.map((l) => ({
50
- subtitleCues: l ?? []
49
+ tracks: p.map((i) => ({
50
+ subtitleCues: i ?? []
51
51
  }))
52
52
  };
53
- }, rn = () => /* @__PURE__ */ H(
53
+ }, un = () => /* @__PURE__ */ H(
54
54
  "svg",
55
55
  {
56
56
  xmlns: "http://www.w3.org/2000/svg",
@@ -69,7 +69,7 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
69
69
  /* @__PURE__ */ s("path", { d: "M12 10H16V24H12V10ZM18 10H22V24H18V10Z", fill: "white" })
70
70
  ]
71
71
  }
72
- ), nn = () => /* @__PURE__ */ H(
72
+ ), ln = () => /* @__PURE__ */ H(
73
73
  "svg",
74
74
  {
75
75
  xmlns: "http://www.w3.org/2000/svg",
@@ -88,21 +88,21 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
88
88
  /* @__PURE__ */ s("path", { d: "M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z", fill: "white" })
89
89
  ]
90
90
  }
91
- ), j = {
91
+ ), z = {
92
92
  fullscreen: "F",
93
93
  next: "→",
94
94
  nextSubtitle: "Shift+→",
95
95
  previous: "←",
96
96
  previousSubtitle: "Shift+←",
97
97
  subtitle: "C"
98
- }, un = 250, an = 15e3, ln = (d, p) => d ? `${d} (${p})` : p, sn = ({
98
+ }, an = 250, sn = 15e3, cn = (d, p) => d ? `${d} (${p})` : p, on = ({
99
99
  audioList: d = [],
100
100
  className: p,
101
- currentAudioIndex: l = -1,
101
+ currentAudioIndex: i = -1,
102
102
  defaultPlaying: w = !0,
103
103
  isPlaybackPaused: T = !1,
104
- isAutoAdvanceEnabled: z = !0,
105
- useAutoAdvanceToggle: O = !1,
104
+ isAutoAdvanceEnabled: Y = !0,
105
+ useAutoAdvanceToggle: R = !1,
106
106
  onLoadingChange: qe,
107
107
  onPlaybackPreferenceChange: et,
108
108
  onPlaybackStarted: tt,
@@ -114,102 +114,102 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
114
114
  onPrev: _e,
115
115
  onNext: Me,
116
116
  onSubtitleJump: we,
117
- canJumpToSubtitleTarget: Be,
117
+ canJumpToSubtitleTarget: We,
118
118
  onFullscreen: de,
119
119
  isFullscreen: rt = !1,
120
- mobileViewMode: Gt = Er,
121
- settingsPortalContainer: Qt,
120
+ mobileViewMode: Xt = Fr,
121
+ settingsPortalContainer: qt,
122
122
  onMobileViewModeChange: nt,
123
123
  onEnded: ut,
124
- onAutoAdvanceToggle: at,
125
- onInteractionToggle: on,
126
- hasInteraction: fn,
124
+ onAutoAdvanceToggle: lt,
125
+ onInteractionToggle: dn,
126
+ hasInteraction: mn,
127
127
  isInteractionOpen: Te = !1,
128
- isSubtitleEnabled: We = !0,
129
- prevDisabled: Oe = !1,
130
- nextDisabled: Re = !1,
131
- showControls: Ve = !0,
132
- onControlsPointerEnter: Xt,
133
- onControlsPointerLeave: qt,
134
- slideProgress: N = null,
135
- enableKeyboardShortcuts: er = !0,
128
+ isSubtitleEnabled: Be = !0,
129
+ prevDisabled: Re = !1,
130
+ nextDisabled: Oe = !1,
131
+ showControls: Ie = !0,
132
+ onControlsPointerEnter: er,
133
+ onControlsPointerLeave: tr,
134
+ slideProgress: v = null,
135
+ enableKeyboardShortcuts: rr = !0,
136
136
  subtitleSeekRequest: D = null,
137
- customActions: lt,
137
+ customActions: at,
138
138
  customActionContext: it,
139
- locale: ke,
139
+ locale: ve,
140
140
  texts: st,
141
141
  onFocusCapture: ct,
142
142
  onPointerDown: ot,
143
- ...Ie
143
+ ...Ve
144
144
  }) => {
145
- const $e = Ie.dir ?? kr(ke), ft = Ie.lang ?? vr(ke), tr = wr(), dt = Tr(Fr), g = i(null), { resolvedDirection: mt, readDirection: pt } = Ar(g, $e), ve = mt === "rtl", rr = Lr(g, ft), ht = i(Te), R = i(null), Le = i(null), F = i(0), h = i(null), me = i(void 0), k = i([]), pe = i(
146
- O ? z : w
147
- ), he = i(!1), gt = i(!1), v = i(!1), W = i(null), Y = i(null), E = i(!1), c = i(!1), x = i(null), U = i(!1), G = i(null), Ae = i(0), St = i(() => {
148
- }), Ce = i(null), ge = i(null), yt = i(null), Q = i(null), bt = i(0), He = i(!1), De = i(!1), _t = i(ne), Mt = i(() => 0), wt = i(null), V = i("unknown"), [xe, S] = Ge(w), [Tt, ue] = Ge(!1), [ae, nr] = Ge({
145
+ const $e = Ve.dir ?? Lr(ve), ft = Ve.lang ?? Ar(ve), nr = vr(), dt = kr(Wr), g = a(null), mt = a(null), pt = a(null), { resolvedDirection: ht, readDirection: gt } = xr(g, $e), ke = ht === "rtl", ur = Cr(g, ft), St = a(Te), O = a(null), Le = a(null), F = a(0), h = a(null), me = a(void 0), k = a([]), pe = a(
146
+ R ? Y : w
147
+ ), he = a(!1), yt = a(!1), L = a(!1), B = a(null), G = a(null), E = a(!1), c = a(!1), N = a(null), U = a(!1), Q = a(null), Ae = a(0), bt = a(() => {
148
+ }), Ce = a(null), ge = a(null), _t = a(null), X = a(null), Mt = a(0), He = a(!1), De = a(!1), wt = a(ne), Tt = a(() => 0), vt = a(null), I = a("unknown"), [xe, S] = Ge(w), [kt, ue] = Ge(!1), [le, lr] = Ge({
149
149
  next: !1,
150
150
  previous: !1
151
- }), X = dt?.ownerId ?? tr, I = er && (dt?.enabled ?? !0), f = l >= 0 ? d[l] : void 0, A = f?.audioUrl, kt = f?.audioSegments, ur = kt?.length ?? 0, B = ce(
152
- () => jt(f),
153
- [f, ur, kt]
151
+ }), q = dt?.ownerId ?? nr, V = rr && (dt?.enabled ?? !0), f = i >= 0 ? d[i] : void 0, C = f?.audioUrl, Lt = f?.audioSegments, ar = Lt?.length ?? 0, W = ce(
152
+ () => Yt(f),
153
+ [f, ar, Lt]
154
154
  );
155
- let Ne = wt.current;
156
- en(d, Ne) || (Ne = tn(d), wt.current = Ne);
157
- const vt = Ne.tracks, Je = ce(
158
- () => $r(lt, it),
159
- [it, lt]
160
- ), Lt = Je.length + 6, ar = ce(
155
+ let Ne = vt.current;
156
+ rn(d, Ne) || (Ne = nn(d), vt.current = Ne);
157
+ const At = Ne.tracks, Je = ce(
158
+ () => Dr(at, it),
159
+ [it, at]
160
+ ), Ct = Je.length + 6, ir = ce(
161
161
  () => ({
162
- "--slide-player-mobile-control-count": String(Lt)
162
+ "--slide-player-mobile-control-count": String(Ct)
163
163
  }),
164
- [Lt]
164
+ [Ct]
165
165
  ), o = ce(
166
166
  () => ({
167
- ...Nr(ke),
167
+ ...Kr(ve),
168
168
  ...st
169
169
  }),
170
- [ke, st]
171
- ), Pe = ce(() => f ? f.audioKey ?? `${String(f.sequenceNumber ?? "none")}:${String(f.audioUrl ?? "")}` : "none", [f]), lr = O ? z : xe, At = O ? z ? o.pauseAutoplayLabel : o.playAutoplayLabel : xe ? o.pauseLabel : o.playLabel, Ct = rt ? o.exitFullscreenLabel : o.enterFullscreenLabel, q = u(
170
+ [ve, st]
171
+ ), Pe = ce(() => f ? f.audioKey ?? `${String(f.sequenceNumber ?? "none")}:${String(f.audioUrl ?? "")}` : "none", [f]), sr = R ? Y : xe, xt = R ? Y ? o.pauseAutoplayLabel : o.playAutoplayLabel : xe ? o.pauseLabel : o.playLabel, Nt = rt ? o.exitFullscreenLabel : o.enterFullscreenLabel, ee = u(
172
172
  (e, t, r) => ({
173
- ariaKeyShortcuts: I ? r : void 0,
174
- title: I ? ln(e, t) : e
173
+ ariaKeyShortcuts: V ? r : void 0,
174
+ title: V ? cn(e, t) : e
175
175
  }),
176
- [I]
177
- ), xt = q(
176
+ [V]
177
+ ), Et = ee(
178
178
  o.subtitleToggleAriaLabel,
179
- j.subtitle,
179
+ z.subtitle,
180
180
  "c"
181
- ), Nt = q(
181
+ ), Kt = ee(
182
182
  o.previousLabel,
183
- ve ? j.next : j.previous,
184
- ve ? "ArrowRight" : "ArrowLeft"
185
- ), Et = q(
183
+ ke ? z.next : z.previous,
184
+ ke ? "ArrowRight" : "ArrowLeft"
185
+ ), Ft = ee(
186
186
  o.previousSubtitleLabel,
187
- j.previousSubtitle,
187
+ z.previousSubtitle,
188
188
  "Shift+ArrowLeft"
189
- ), Kt = q(
190
- At,
189
+ ), Ut = ee(
190
+ xt,
191
191
  o.playbackShortcutLabel,
192
192
  "Space"
193
- ), Ft = q(
193
+ ), Wt = ee(
194
194
  o.nextLabel,
195
- ve ? j.previous : j.next,
196
- ve ? "ArrowLeft" : "ArrowRight"
197
- ), Ut = q(
195
+ ke ? z.previous : z.next,
196
+ ke ? "ArrowLeft" : "ArrowRight"
197
+ ), Bt = ee(
198
198
  o.nextSubtitleLabel,
199
- j.nextSubtitle,
199
+ z.nextSubtitle,
200
200
  "Shift+ArrowRight"
201
- ), Bt = q(
202
- Ct,
203
- j.fullscreen,
201
+ ), Rt = ee(
202
+ Nt,
203
+ z.fullscreen,
204
204
  "f"
205
205
  ), Ee = u(() => {
206
- I && Ur(X);
207
- }, [X, I]), ir = u(
206
+ V && Br(q);
207
+ }, [q, V]), cr = u(
208
208
  (e) => {
209
209
  Ee(), ot?.(e);
210
210
  },
211
211
  [Ee, ot]
212
- ), sr = u(
212
+ ), or = u(
213
213
  (e) => {
214
214
  Ee(), ct?.(e);
215
215
  },
@@ -218,20 +218,20 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
218
218
  m(() => {
219
219
  me.current = f;
220
220
  }, [f]), m(() => {
221
- pe.current = O ? z : w;
222
- }, [w, z, O]), m(() => {
223
- Ve || ue(!1);
224
- }, [Ve]), m(() => {
225
- !ht.current && Te && ue(!1), ht.current = Te;
221
+ pe.current = R ? Y : w;
222
+ }, [w, Y, R]), m(() => {
223
+ Ie || ue(!1);
224
+ }, [Ie]), m(() => {
225
+ !St.current && Te && ue(!1), St.current = Te;
226
226
  }, [Te]), m(() => {
227
- k.current = B;
228
- }, [B]), m(() => {
229
- const e = f?.audioUrl, t = l >= 0 ? d[l + 1]?.audioUrl : void 0;
230
- Yt(e), Yt(t);
231
- }, [d, f?.audioUrl, l]);
232
- const a = u(
227
+ k.current = W;
228
+ }, [W]), m(() => {
229
+ const e = f?.audioUrl, t = i >= 0 ? d[i + 1]?.audioUrl : void 0;
230
+ Qt(e), Qt(t);
231
+ }, [d, f?.audioUrl, i]);
232
+ const l = u(
233
233
  (e, t = null) => {
234
- gt.current === e && (!e || t === null) || (gt.current = e, qe?.({
234
+ yt.current === e && (!e || t === null) || (yt.current = e, qe?.({
235
235
  loading: e,
236
236
  reason: e ? t : null
237
237
  }));
@@ -242,14 +242,22 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
242
242
  pe.current = e, et?.(e);
243
243
  },
244
244
  [et]
245
- ), ee = u(() => O ? {
245
+ ), J = u(() => R ? {
246
246
  shouldContinuePlayback: pe.current
247
247
  } : {
248
- shouldContinuePlayback: Ir({
248
+ shouldContinuePlayback: Hr({
249
249
  defaultPlaying: pe.current,
250
- isPausedByUser: v.current
250
+ isPausedByUser: L.current
251
251
  })
252
- }, [O]), Wt = u((e) => e instanceof DOMException ? e.name === "NotAllowedError" || e.name === "SecurityError" : !1, []), J = u(() => w && !T && !v.current && V.current !== "blocked", [w, T]), Ot = u((e) => e ? e.startsWith("data:") ? e : `data:audio/mpeg;base64,${e}` : "", []), Rt = u(() => {
252
+ }, [R]);
253
+ m(() => {
254
+ const e = mt.current, t = pt.current;
255
+ !e || !t || typeof e.scrollTo != "function" || e.scrollTo({
256
+ behavior: "smooth",
257
+ left: t.offsetLeft - e.clientWidth / 2 + t.clientWidth / 2
258
+ });
259
+ }, [v?.currentIndex, v?.totalSteps]);
260
+ const Ot = u((e) => e instanceof DOMException ? e.name === "NotAllowedError" || e.name === "SecurityError" : !1, []), P = u(() => w && !T && !L.current && I.current !== "blocked", [w, T]), It = u((e) => e ? e.startsWith("data:") ? e : `data:audio/mpeg;base64,${e}` : "", []), Vt = u(() => {
253
261
  const e = h.current;
254
262
  return e == null || e <= 0 ? 0 : k.current.slice(0, e).reduce(
255
263
  (t, r) => t + Math.max(Number(r.duration_ms ?? 0), 0),
@@ -260,153 +268,153 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
260
268
  0
261
269
  ), []), Ke = u(
262
270
  (e, t) => !e || T ? !1 : e.audioUrl ? !0 : Xe(
263
- jt(e),
271
+ Yt(e),
264
272
  t
265
273
  ),
266
274
  [T]
267
275
  ), Se = u(
268
276
  (e, t, r = {}) => {
269
- const n = Hr({
270
- currentAudioIndex: l,
277
+ const n = Jr({
278
+ currentAudioIndex: i,
271
279
  currentTimeMs: t,
272
280
  direction: e,
273
281
  excludeTarget: r.excludeTarget,
274
- tracks: vt
282
+ tracks: At
275
283
  });
276
284
  return !n || !Ke(
277
285
  d[n.audioIndex],
278
286
  n.timeMs
279
- ) || n.audioIndex !== l && (!we || Be && !Be(n)) ? null : n;
287
+ ) || n.audioIndex !== i && (!we || We && !We(n)) ? null : n;
280
288
  },
281
289
  [
282
290
  d,
283
- Be,
291
+ We,
284
292
  Ke,
285
- l,
293
+ i,
286
294
  we,
287
- vt
295
+ At
288
296
  ]
289
297
  ), Ze = u(
290
298
  (e, t = !1) => {
291
299
  const r = Math.max(Number(e), 0);
292
300
  if (!t && Ce.current !== null && Math.abs(
293
301
  r - Ce.current
294
- ) < un)
302
+ ) < an)
295
303
  return;
296
304
  Ce.current = r;
297
305
  const n = {
298
306
  previous: Se("previous", r) !== null,
299
307
  next: Se("next", r) !== null
300
308
  };
301
- nr((b) => b.previous === n.previous && b.next === n.next ? b : n);
309
+ lr((b) => b.previous === n.previous && b.next === n.next ? b : n);
302
310
  },
303
311
  [Se]
304
312
  );
305
313
  m(() => {
306
- St.current = Ze, Ze(Ae.current, !0);
314
+ bt.current = Ze, Ze(Ae.current, !0);
307
315
  }, [Ze]);
308
- const P = u(() => {
316
+ const Z = u(() => {
309
317
  const e = g.current;
310
- return e ? W.current === "segment" ? te(F.current) + Math.max(e.currentTime, 0) * 1e3 : x.current !== null && e.readyState === 0 ? x.current * 1e3 : Math.max(e.currentTime, 0) * 1e3 : h.current != null ? te(h.current) : 0;
318
+ return e ? B.current === "segment" ? te(F.current) + Math.max(e.currentTime, 0) * 1e3 : N.current !== null && e.readyState === 0 ? N.current * 1e3 : Math.max(e.currentTime, 0) * 1e3 : h.current != null ? te(h.current) : 0;
311
319
  }, [te]);
312
320
  m(() => {
313
- _t.current = ne;
321
+ wt.current = ne;
314
322
  }, [ne]), m(() => {
315
- Mt.current = P;
316
- }, [P]);
323
+ Tt.current = Z;
324
+ }, [Z]);
317
325
  const K = u(
318
326
  (e) => {
319
327
  const t = Math.max(e, 0);
320
- Ae.current !== t && (Ae.current = t, Dr({
321
- currentAudioIndex: l,
328
+ Ae.current !== t && (Ae.current = t, Pr({
329
+ currentAudioIndex: i,
322
330
  currentTimeMs: t,
323
331
  target: ge.current
324
- }) && (ge.current = null), be?.(t), St.current(t));
332
+ }) && (ge.current = null), be?.(t), bt.current(t));
325
333
  },
326
- [l, be]
334
+ [i, be]
327
335
  ), y = u(() => {
328
- K(P());
329
- }, [P, K]), Z = u(
336
+ K(Z());
337
+ }, [Z, K]), j = u(
330
338
  (e = !1, t = !1) => {
331
339
  const r = Le.current;
332
340
  if (!ne || !r)
333
341
  return;
334
342
  const n = Date.now();
335
- !e && n - bt.current < 5e3 || (bt.current = n, He.current = t, ne({
343
+ !e && n - Mt.current < 5e3 || (Mt.current = n, He.current = t, ne({
336
344
  audioKey: r,
337
345
  isComplete: t,
338
- timeMs: P()
346
+ timeMs: Z()
339
347
  }));
340
348
  },
341
- [P, ne]
349
+ [Z, ne]
342
350
  );
343
351
  m(
344
352
  () => () => {
345
- He.current || _t.current?.({
353
+ He.current || wt.current?.({
346
354
  audioKey: Le.current ?? "none",
347
355
  isComplete: !1,
348
- timeMs: Mt.current()
356
+ timeMs: Tt.current()
349
357
  });
350
358
  },
351
359
  []
352
360
  ), m(() => {
353
361
  He.current = !1;
354
- }, [l]);
362
+ }, [i]);
355
363
  const M = u(() => {
356
- typeof window > "u" || G.current === null || (window.cancelAnimationFrame(G.current), G.current = null);
357
- }, []), Vt = u(() => {
358
- if (typeof window > "u" || G.current !== null)
364
+ typeof window > "u" || Q.current === null || (window.cancelAnimationFrame(Q.current), Q.current = null);
365
+ }, []), $t = u(() => {
366
+ if (typeof window > "u" || Q.current !== null)
359
367
  return;
360
368
  const e = () => {
361
369
  y();
362
370
  const t = g.current;
363
371
  if (!t || t.paused || t.ended) {
364
- G.current = null;
372
+ Q.current = null;
365
373
  return;
366
374
  }
367
- G.current = window.requestAnimationFrame(e);
375
+ Q.current = window.requestAnimationFrame(e);
368
376
  };
369
- G.current = window.requestAnimationFrame(e);
370
- }, [y]), le = u(() => {
377
+ Q.current = window.requestAnimationFrame(e);
378
+ }, [y]), ae = u(() => {
371
379
  const e = g.current;
372
- e && (M(), c.current = !1, v.current = !1, he.current = !1, W.current = null, x.current = null, E.current = !1, U.current = !1, Y.current = null, e.pause(), e.removeAttribute("src"), e.load(), R.current = null, F.current = 0, h.current = null, K(0), S(!1), a(!1));
373
- }, [K, M, a]), L = u(
380
+ e && (M(), c.current = !1, L.current = !1, he.current = !1, B.current = null, N.current = null, E.current = !1, U.current = !1, G.current = null, e.pause(), e.removeAttribute("src"), e.load(), O.current = null, F.current = 0, h.current = null, K(0), S(!1), l(!1));
381
+ }, [K, M, l]), A = u(
374
382
  (e) => {
375
383
  const t = g.current;
376
384
  if (!t)
377
385
  return !1;
378
386
  const r = t.play();
379
387
  return r && typeof r.then == "function" && r.then(() => {
380
- V.current === "unknown" && (V.current = "auto"), c.current = !1, U.current = !1;
388
+ I.current === "unknown" && (I.current = "auto"), c.current = !1, U.current = !1;
381
389
  }).catch((n) => {
382
- V.current === "unknown" && Wt(n) && (V.current = "blocked", c.current = !1, a(!1)), U.current = !1, S(!1);
390
+ I.current === "unknown" && Ot(n) && (I.current = "blocked", c.current = !1, l(!1)), U.current = !1, S(!1);
383
391
  }), !0;
384
392
  },
385
- [Wt, a]
386
- ), C = u(
393
+ [Ot, l]
394
+ ), x = u(
387
395
  (e, t, r = {}) => {
388
396
  const n = g.current, b = k.current[e];
389
397
  if (!n || !b)
390
398
  return !1;
391
- const re = Ot(b.audio_data), Ye = Math.max(
399
+ const re = It(b.audio_data), Ye = Math.max(
392
400
  Number(r.seekTimeSeconds ?? 0),
393
401
  0
394
402
  );
395
- F.current = e, h.current = null, E.current = !1, U.current = !0, Y.current = "segment", K(
403
+ F.current = e, h.current = null, E.current = !1, U.current = !0, G.current = "segment", K(
396
404
  te(e) + Ye * 1e3
397
405
  );
398
- const Jt = r.shouldResume ?? J();
399
- c.current = Jt, a(!1);
400
- const br = R.current !== re;
401
- return W.current = "segment", br && (n.pause(), n.removeAttribute("src"), n.load(), R.current = re, n.src = re, n.load()), x.current = Ye, n.readyState > 0 && (n.currentTime = Ye, x.current = null), Jt ? L(`start-segment:${t}`) : (c.current = !1, U.current = !1, n.pause(), S(!1), !0);
406
+ const Zt = r.shouldResume ?? P();
407
+ c.current = Zt, l(!1);
408
+ const Mr = O.current !== re;
409
+ return B.current = "segment", Mr && (n.pause(), n.removeAttribute("src"), n.load(), O.current = re, n.src = re, n.load()), N.current = Ye, n.readyState > 0 && (n.currentTime = Ye, N.current = null), Zt ? A(`start-segment:${t}`) : (c.current = !1, U.current = !1, n.pause(), S(!1), !0);
402
410
  },
403
411
  [
404
- J,
405
- Ot,
412
+ P,
413
+ It,
406
414
  te,
407
415
  K,
408
- L,
409
- a
416
+ A,
417
+ l
410
418
  ]
411
419
  ), ie = u(
412
420
  (e, t) => {
@@ -414,7 +422,7 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
414
422
  if (!r)
415
423
  return !1;
416
424
  const n = Math.max(Number(t), 0) / 1e3;
417
- return R.current !== e && (r.pause(), r.removeAttribute("src"), r.load(), R.current = e, W.current = "url", Y.current = "url", r.src = e, r.load()), x.current = n, K(n * 1e3), r.readyState > 0 && (r.currentTime = n, x.current = null), !0;
425
+ return O.current !== e && (r.pause(), r.removeAttribute("src"), r.load(), O.current = e, B.current = "url", G.current = "url", r.src = e, r.load()), N.current = n, K(n * 1e3), r.readyState > 0 && (r.currentTime = n, N.current = null), !0;
418
426
  },
419
427
  [K]
420
428
  ), Fe = u(
@@ -422,114 +430,114 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
422
430
  const t = g.current;
423
431
  if (!t || !f || T)
424
432
  return !1;
425
- const r = Math.max(Number(e), 0), n = !t.paused && !t.ended || c.current || U.current || h.current !== null && pe.current && !v.current, b = Xe(
433
+ const r = Math.max(Number(e), 0), n = !t.paused && !t.ended || c.current || U.current || h.current !== null && pe.current && !L.current, b = Xe(
426
434
  k.current,
427
435
  r
428
- ) ? Zt(
436
+ ) ? zt(
429
437
  k.current,
430
438
  r
431
439
  ) : null;
432
- return Ce.current = null, M(), c.current = n, a(!1), n && (V.current = "manual", v.current = !1, $(!0)), b && (W.current === "segment" || !A) ? C(
440
+ return Ce.current = null, M(), c.current = n, l(!1), n && (I.current = "manual", L.current = !1, $(!0)), b && (B.current === "segment" || !C) ? x(
433
441
  b.segmentIndex,
434
442
  "subtitle-seek-segment",
435
443
  {
436
444
  seekTimeSeconds: b.segmentTimeSeconds,
437
445
  shouldResume: n
438
446
  }
439
- ) : A && ie(A, r) ? n ? L("subtitle-seek-url") : (c.current = !1, t.pause(), S(!1), !0) : !1;
447
+ ) : C && ie(C, r) ? n ? A("subtitle-seek-url") : (c.current = !1, t.pause(), S(!1), !0) : !1;
440
448
  },
441
449
  [
442
450
  f,
443
- A,
451
+ C,
444
452
  T,
445
453
  ie,
446
- C,
454
+ x,
447
455
  M,
448
- L,
449
- a,
456
+ A,
457
+ l,
450
458
  $
451
459
  ]
452
- ), It = u(
460
+ ), Ht = u(
453
461
  (e) => {
454
462
  if (!g.current || !f)
455
463
  return !1;
456
464
  const r = Math.max(Number(e), 0), n = Xe(
457
465
  k.current,
458
466
  r
459
- ) ? Zt(
467
+ ) ? zt(
460
468
  k.current,
461
469
  r
462
470
  ) : null;
463
- return c.current = !0, a(!1), n && (W.current === "segment" || !A) ? C(n.segmentIndex, "restore", {
471
+ return c.current = !0, l(!1), n && (B.current === "segment" || !C) ? x(n.segmentIndex, "restore", {
464
472
  seekTimeSeconds: n.segmentTimeSeconds,
465
473
  shouldResume: !0
466
- }) : !A || !ie(A, r) ? !1 : (L("restore"), !0);
474
+ }) : !C || !ie(C, r) ? !1 : (A("restore"), !0);
467
475
  },
468
476
  [
469
477
  f,
470
- A,
471
- ie,
472
478
  C,
473
- L,
474
- a
479
+ ie,
480
+ x,
481
+ A,
482
+ l
475
483
  ]
476
484
  ), ye = u(
477
485
  (e) => {
478
486
  const t = Se(
479
487
  e,
480
- P(),
488
+ Z(),
481
489
  {
482
490
  excludeTarget: e === "previous" ? ge.current : null
483
491
  }
484
492
  );
485
493
  if (t === null)
486
494
  return !1;
487
- if (t.audioIndex === l) {
495
+ if (t.audioIndex === i) {
488
496
  const n = Fe(t.timeMs);
489
497
  return n && (ge.current = t), n;
490
498
  }
491
499
  const r = !!we?.(
492
500
  t,
493
- Qe(ee())
501
+ Qe(J())
494
502
  );
495
503
  return r && (ge.current = t), r;
496
504
  },
497
505
  [
498
- l,
499
- P,
500
- ee,
506
+ i,
507
+ Z,
508
+ J,
501
509
  Se,
502
510
  we,
503
511
  Fe
504
512
  ]
505
513
  ), se = u(
506
514
  (e) => {
507
- M(), c.current = !1, E.current = !1, U.current = !1, y(), S(!1), a(!1), l >= 0 && ut?.(l);
515
+ M(), c.current = !1, E.current = !1, U.current = !1, y(), S(!1), l(!1), i >= 0 && ut?.(i);
508
516
  },
509
517
  [
510
- l,
518
+ i,
511
519
  ut,
512
520
  M,
513
521
  y,
514
- a
522
+ l
515
523
  ]
516
524
  ), Ue = u(
517
525
  (e) => {
518
526
  const t = g.current;
519
- return !t || W.current !== "url" || !Kr({
527
+ return !t || B.current !== "url" || !Ur({
520
528
  currentTimeSeconds: Math.max(t.currentTime, 0),
521
529
  durationSeconds: t.duration
522
530
  }) ? !1 : (c.current = !1, t.pause(), se(e), !0);
523
531
  },
524
532
  [se]
525
- ), $t = u(() => {
533
+ ), Dt = u(() => {
526
534
  const e = F.current + 1, t = k.current, r = t[e], n = me.current, b = t.some((re) => re.is_final);
527
535
  if (r) {
528
- C(e, "ended");
536
+ x(e, "ended");
529
537
  return;
530
538
  }
531
539
  if (n?.isAudioStreaming || !b) {
532
- F.current = e, h.current = e, E.current = !0, c.current = w, K(te(e)), S(!1), a(!0, "waitingForMoreAudio");
540
+ F.current = e, h.current = e, E.current = !0, c.current = w, K(te(e)), S(!1), l(!0, "waitingForMoreAudio");
533
541
  return;
534
542
  }
535
543
  se("segments-completed");
@@ -538,42 +546,42 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
538
546
  se,
539
547
  te,
540
548
  K,
541
- C,
542
- a
549
+ x,
550
+ l
543
551
  ]);
544
552
  m(() => {
545
553
  if (Le.current === Pe)
546
554
  return;
547
- Z(!0), Le.current = Pe, F.current = 0, h.current = null, E.current = !1, v.current = !1, he.current = !1, c.current = !1, U.current = !1, W.current = null, Y.current = null, R.current = null, M(), K(0), a(!1);
555
+ j(!0), Le.current = Pe, F.current = 0, h.current = null, E.current = !1, L.current = !1, he.current = !1, c.current = !1, U.current = !1, B.current = null, G.current = null, O.current = null, M(), K(0), l(!1);
548
556
  const e = g.current;
549
557
  e && (De.current = !0, e.pause(), e.removeAttribute("src"), e.load(), De.current = !1, S(!1));
550
558
  }, [
551
- l,
559
+ i,
552
560
  Pe,
553
- B.length,
554
- A,
555
- Z,
561
+ W.length,
562
+ C,
563
+ j,
556
564
  K,
557
565
  M,
558
- a
566
+ l
559
567
  ]), m(() => {
560
568
  const e = g.current;
561
569
  if (e) {
562
570
  if (T) {
563
- he.current = !!(me.current && !v.current && (!e.paused || c.current || h.current !== null)), c.current = !1, a(!1), e.pause(), S(!1);
571
+ he.current = !!(me.current && !L.current && (!e.paused || c.current || h.current !== null)), c.current = !1, l(!1), e.pause(), S(!1);
564
572
  return;
565
573
  }
566
- if (!(!he.current || !me.current || v.current)) {
574
+ if (!(!he.current || !me.current || L.current)) {
567
575
  if (he.current = !1, h.current !== null) {
568
576
  if (h.current < k.current.length) {
569
- C(h.current, "external-resume");
577
+ x(h.current, "external-resume");
570
578
  return;
571
579
  }
572
- c.current = !0, a(!0, "waitingForMoreAudio");
580
+ c.current = !0, l(!0, "waitingForMoreAudio");
573
581
  return;
574
582
  }
575
- if (!R.current && k.current.length > 0) {
576
- C(
583
+ if (!O.current && k.current.length > 0) {
584
+ x(
577
585
  Math.min(
578
586
  F.current,
579
587
  k.current.length - 1
@@ -582,287 +590,287 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
582
590
  );
583
591
  return;
584
592
  }
585
- e.paused && (c.current = !0, L("external-resume"));
593
+ e.paused && (c.current = !0, A("external-resume"));
586
594
  }
587
595
  }
588
596
  }, [
589
597
  T,
590
- C,
591
- L,
592
- a
598
+ x,
599
+ A,
600
+ l
593
601
  ]), m(() => {
594
602
  const e = g.current;
595
603
  if (!e)
596
604
  return;
597
605
  if (!f) {
598
- le();
606
+ ae();
599
607
  return;
600
608
  }
601
- if (_ && _.id !== Q.current)
609
+ if (_ && _.id !== X.current)
602
610
  return;
603
611
  if (T) {
604
- c.current = !1, a(!1), e.pause(), S(!1);
612
+ c.current = !1, l(!1), e.pause(), S(!1);
605
613
  return;
606
614
  }
607
- const t = Vr({
608
- activeSourceType: W.current,
609
- hasAudioUrl: !!A,
610
- segmentCount: B.length,
611
- preferredSourceType: Y.current,
615
+ const t = $r({
616
+ activeSourceType: B.current,
617
+ hasAudioUrl: !!C,
618
+ segmentCount: W.length,
619
+ preferredSourceType: G.current,
612
620
  waitingSegmentIndex: h.current
613
621
  });
614
- if (t && Y.current !== t && (Y.current = t), t === "url" && A) {
615
- const r = R.current !== A, n = J();
622
+ if (t && G.current !== t && (G.current = t), t === "url" && C) {
623
+ const r = O.current !== C, n = P();
616
624
  if (r) {
617
- const b = h.current !== null ? Rt() : 0;
618
- ie(A, b * 1e3);
625
+ const b = h.current !== null ? Vt() : 0;
626
+ ie(C, b * 1e3);
619
627
  }
620
- if (c.current = n, E.current = !1, U.current = !1, a(!1), !n) {
628
+ if (c.current = n, E.current = !1, U.current = !1, l(!1), !n) {
621
629
  c.current = !1, e.pause(), S(!1);
622
630
  return;
623
631
  }
624
- L(r ? "sync-url-init" : "sync-url");
632
+ A(r ? "sync-url-init" : "sync-url");
625
633
  return;
626
634
  }
627
635
  if (t === "segment" && h.current !== null) {
628
- if (h.current < B.length) {
629
- if (v.current) {
630
- S(!1), a(!1);
636
+ if (h.current < W.length) {
637
+ if (L.current) {
638
+ S(!1), l(!1);
631
639
  return;
632
640
  }
633
- C(h.current, "wait-resume");
641
+ x(h.current, "wait-resume");
634
642
  return;
635
643
  }
636
- E.current = !0, c.current = J(), S(!1), a(J());
644
+ E.current = !0, c.current = P(), S(!1), l(P());
637
645
  return;
638
646
  }
639
- if (t === "segment" && !B.length) {
647
+ if (t === "segment" && !W.length) {
640
648
  if (f.isAudioStreaming) {
641
- h.current = F.current, E.current = !0, c.current = J(), S(!1), a(J());
649
+ h.current = F.current, E.current = !0, c.current = P(), S(!1), l(P());
642
650
  return;
643
651
  }
644
- le();
652
+ ae();
645
653
  return;
646
654
  }
647
- if (t === "segment" && !R.current) {
648
- C(
655
+ if (t === "segment" && !O.current) {
656
+ x(
649
657
  Math.min(
650
658
  F.current,
651
- B.length - 1
659
+ W.length - 1
652
660
  ),
653
661
  "effect-init"
654
662
  );
655
663
  return;
656
664
  }
657
665
  if (t !== "segment") {
658
- le();
666
+ ae();
659
667
  return;
660
668
  }
661
- if (!w || v.current) {
669
+ if (!w || L.current) {
662
670
  c.current = !1, e.pause(), S(!1);
663
671
  return;
664
672
  }
665
- e.paused && (c.current = !0, L("sync-paused-retry"));
673
+ e.paused && (c.current = !0, A("sync-paused-retry"));
666
674
  }, [
667
675
  f,
668
- l,
669
- B,
670
- A,
676
+ i,
677
+ W,
678
+ C,
671
679
  w,
672
680
  T,
673
681
  _,
674
- J,
675
- le,
682
+ P,
683
+ ae,
676
684
  ie,
677
- C,
678
- L,
679
- Rt,
680
- a
685
+ x,
686
+ A,
687
+ Vt,
688
+ l
681
689
  ]), m(() => {
682
- if (!D || D.id === yt.current || D.audioIndex !== l)
690
+ if (!D || D.id === _t.current || D.audioIndex !== i)
683
691
  return;
684
692
  const e = d[D.audioIndex];
685
- Ke(e, D.timeMs) && (yt.current = D.id, Fe(D.timeMs));
693
+ Ke(e, D.timeMs) && (_t.current = D.id, Fe(D.timeMs));
686
694
  }, [
687
695
  d,
688
696
  Ke,
689
- l,
697
+ i,
690
698
  Fe,
691
699
  D
692
700
  ]), m(() => {
693
- if (!(!_ || _.id === Q.current || l < 0)) {
694
- if (It(_.timeMs)) {
695
- Q.current = _.id, oe?.(_.id);
701
+ if (!(!_ || _.id === X.current || i < 0)) {
702
+ if (Ht(_.timeMs)) {
703
+ X.current = _.id, oe?.(_.id);
696
704
  return;
697
705
  }
698
- f?.isAudioStreaming || (Q.current = _.id, oe?.(_.id));
706
+ f?.isAudioStreaming || (X.current = _.id, oe?.(_.id));
699
707
  }
700
708
  }, [
701
709
  f?.isAudioStreaming,
702
- l,
710
+ i,
703
711
  oe,
704
712
  _,
705
- It
713
+ Ht
706
714
  ]), m(() => {
707
- if (!_ || _.id === Q.current || l < 0 || !f?.isAudioStreaming)
715
+ if (!_ || _.id === X.current || i < 0 || !f?.isAudioStreaming)
708
716
  return;
709
717
  const e = window.setTimeout(() => {
710
- _.id !== Q.current && (Q.current = _.id, oe?.(_.id));
711
- }, an);
718
+ _.id !== X.current && (X.current = _.id, oe?.(_.id));
719
+ }, sn);
712
720
  return () => {
713
721
  window.clearTimeout(e);
714
722
  };
715
723
  }, [
716
724
  f?.isAudioStreaming,
717
- l,
725
+ i,
718
726
  oe,
719
727
  _
720
- ]), m(() => le, [le]), m(() => M, [M]);
721
- const cr = u(() => {
722
- y(), Vt(), S(!0), a(!1), tt?.();
728
+ ]), m(() => ae, [ae]), m(() => M, [M]);
729
+ const fr = u(() => {
730
+ y(), $t(), S(!0), l(!1), tt?.();
723
731
  }, [
724
732
  tt,
725
- Vt,
733
+ $t,
726
734
  y,
727
- a
728
- ]), or = u(() => {
729
- De.current || E.current || U.current || (M(), y(), Z(!0), S(!1));
730
- }, [Z, M, y]), fr = u(() => {
735
+ l
736
+ ]), dr = u(() => {
737
+ De.current || E.current || U.current || (M(), y(), j(!0), S(!1));
738
+ }, [j, M, y]), mr = u(() => {
731
739
  const e = g.current;
732
- e && x.current !== null && (e.currentTime = x.current, x.current = null), y(), !Ue("canplay-seek-finished") && (!c.current || !w || L("canplay"));
740
+ e && N.current !== null && (e.currentTime = N.current, N.current = null), y(), !Ue("canplay-seek-finished") && (!c.current || !w || A("canplay"));
733
741
  }, [
734
- l,
742
+ i,
735
743
  w,
736
744
  Ue,
737
745
  y,
738
- L
739
- ]), dr = u(() => {
746
+ A
747
+ ]), pr = u(() => {
740
748
  const e = g.current;
741
- e && x.current !== null && (e.currentTime = x.current, x.current = null), y(), Ue("metadata-seek-finished");
742
- }, [l, Ue, y]), mr = u(() => {
743
- y(), Z();
744
- }, [Z, y]), pr = u(() => {
745
- E.current || a(!0, "loadingAudio");
746
- }, [a]), hr = u(() => {
749
+ e && N.current !== null && (e.currentTime = N.current, N.current = null), y(), Ue("metadata-seek-finished");
750
+ }, [i, Ue, y]), hr = u(() => {
751
+ y(), j();
752
+ }, [j, y]), gr = u(() => {
753
+ E.current || l(!0, "loadingAudio");
754
+ }, [l]), Sr = u(() => {
747
755
  if (E.current) {
748
- a(!0, "waitingForMoreAudio");
756
+ l(!0, "waitingForMoreAudio");
749
757
  return;
750
758
  }
751
- a(!0, "loadingAudio");
752
- }, [a]), Ht = u(() => {
759
+ l(!0, "loadingAudio");
760
+ }, [l]), Jt = u(() => {
753
761
  y();
754
- }, [y]), gr = u(() => {
755
- const e = me.current, t = W.current === "url" || k.current.length === 0, r = !!k.current[F.current + 1], n = k.current.some(
762
+ }, [y]), yr = u(() => {
763
+ const e = me.current, t = B.current === "url" || k.current.length === 0, r = !!k.current[F.current + 1], n = k.current.some(
756
764
  (re) => re.is_final
757
765
  ), b = !!e?.isAudioStreaming;
758
- if (Z(
766
+ if (j(
759
767
  !0,
760
768
  t || !b && !r && n
761
769
  ), M(), U.current = !1, t) {
762
770
  se("url-ended");
763
771
  return;
764
772
  }
765
- $t();
773
+ Dt();
766
774
  }, [
767
- Z,
775
+ j,
768
776
  se,
769
- $t,
777
+ Dt,
770
778
  M
771
- ]), Sr = u(() => {
772
- M(), y(), S(!1), a(!1);
773
- }, [M, y, a]), yr = u(
779
+ ]), br = u(() => {
780
+ M(), y(), S(!1), l(!1);
781
+ }, [M, y, l]), _r = u(
774
782
  (e) => {
775
783
  nt?.(e), ue(!1);
776
784
  },
777
785
  [nt]
778
786
  ), je = u(() => {
779
- if (O) {
780
- const t = !z;
781
- return $(t), at?.(t), !0;
787
+ if (R) {
788
+ const t = !Y;
789
+ return $(t), lt?.(t), !0;
782
790
  }
783
791
  const e = g.current;
784
- return T || !e || !f ? !1 : h.current !== null ? xe ? ($(!1), c.current = !1, v.current = !0, h.current = null, E.current = !1, S(!1), a(!1), e.pause(), !0) : ($(!0), V.current = "manual", v.current = !1, c.current = !0, a(!0, "waitingForMoreAudio"), !0) : !e.src && B.length > 0 ? ($(!0), V.current = "manual", v.current = !1, C(
792
+ return T || !e || !f ? !1 : h.current !== null ? xe ? ($(!1), c.current = !1, L.current = !0, h.current = null, E.current = !1, S(!1), l(!1), e.pause(), !0) : ($(!0), I.current = "manual", L.current = !1, c.current = !0, l(!0, "waitingForMoreAudio"), !0) : !e.src && W.length > 0 ? ($(!0), I.current = "manual", L.current = !1, x(
785
793
  Math.min(
786
794
  F.current,
787
- B.length - 1
795
+ W.length - 1
788
796
  ),
789
797
  "toggle"
790
- ), !0) : e.paused ? ($(!0), V.current = "manual", v.current = !1, c.current = !0, L("toggle-resume"), !0) : ($(!1), c.current = !1, v.current = !0, e.pause(), !0);
798
+ ), !0) : e.paused ? ($(!0), I.current = "manual", L.current = !1, c.current = !0, A("toggle-resume"), !0) : ($(!1), c.current = !1, L.current = !0, e.pause(), !0);
791
799
  }, [
792
800
  f,
793
- B.length,
794
- z,
801
+ W.length,
802
+ Y,
795
803
  T,
796
804
  xe,
797
- at,
798
- C,
799
- L,
800
- a,
805
+ lt,
806
+ x,
807
+ A,
808
+ l,
801
809
  $,
802
- O
810
+ R
803
811
  ]);
804
812
  m(() => {
805
- if (I)
806
- return Br(X);
807
- }, [X, I]);
813
+ if (V)
814
+ return Rr(q);
815
+ }, [q, V]);
808
816
  const ze = ce(
809
817
  () => ({
810
818
  fullscreen: () => de ? (de(), !0) : !1,
811
- next: () => Me ? (Re || Me(
812
- Qe(ee())
819
+ next: () => Me ? (Oe || Me(
820
+ Qe(J())
813
821
  ), !0) : !1,
814
- nextSubtitle: () => ae.next ? ye("next") : !0,
815
- previous: () => _e ? (Oe || _e(
816
- Qe(ee())
822
+ nextSubtitle: () => le.next ? ye("next") : !0,
823
+ previous: () => _e ? (Re || _e(
824
+ Qe(J())
817
825
  ), !0) : !1,
818
- previousSubtitle: () => ae.previous ? ye("previous") : !0,
826
+ previousSubtitle: () => le.previous ? ye("previous") : !0,
819
827
  subtitle: () => fe ? (fe(), !0) : !1,
820
828
  togglePlayback: () => (je(), !0)
821
829
  }),
822
830
  [
823
- ee,
831
+ J,
824
832
  ye,
825
- Re,
833
+ Oe,
826
834
  de,
827
835
  Me,
828
836
  _e,
829
837
  fe,
830
- Oe,
831
- ae.next,
832
- ae.previous,
838
+ Re,
839
+ le.next,
840
+ le.previous,
833
841
  je
834
842
  ]
835
- ), Dt = i(ze);
843
+ ), Pt = a(ze);
836
844
  return m(() => {
837
- Dt.current = ze;
845
+ Pt.current = ze;
838
846
  }, [ze]), m(() => {
839
- if (!I || typeof document > "u")
847
+ if (!V || typeof document > "u")
840
848
  return;
841
849
  const e = (t) => {
842
- if (!Wr(X))
850
+ if (!Or(q))
843
851
  return;
844
- const r = Or(t, pt());
845
- if (!r || Rr(t, r))
852
+ const r = Ir(t, gt());
853
+ if (!r || Vr(t, r))
846
854
  return;
847
855
  let n = !1;
848
- const b = Dt.current[r];
856
+ const b = Pt.current[r];
849
857
  n = b(), n && t.preventDefault();
850
858
  };
851
859
  return document.addEventListener("keydown", e), () => {
852
860
  document.removeEventListener("keydown", e);
853
861
  };
854
- }, [X, pt, I]), m(() => {
862
+ }, [q, gt, V]), m(() => {
855
863
  be?.(Ae.current);
856
864
  }, [be]), /* @__PURE__ */ H(
857
865
  "div",
858
866
  {
859
- ...Ie,
867
+ ...Ve,
860
868
  dir: $e,
861
869
  lang: ft,
862
- "data-slide-player-shortcut-owner": X,
863
- className: Cr("slide-player", p),
864
- onFocusCapture: sr,
865
- onPointerDown: ir,
870
+ "data-slide-player-shortcut-owner": q,
871
+ className: Nr("slide-player", p),
872
+ onFocusCapture: or,
873
+ onPointerDown: cr,
866
874
  children: [
867
875
  /* @__PURE__ */ s(
868
876
  "audio",
@@ -870,26 +878,26 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
870
878
  ref: g,
871
879
  preload: "auto",
872
880
  playsInline: !0,
873
- onLoadStart: pr,
874
- onLoadedMetadata: dr,
875
- onCanPlay: fr,
876
- onPlay: cr,
877
- onPause: or,
878
- onWaiting: hr,
879
- onSeeking: Ht,
880
- onSeeked: Ht,
881
- onTimeUpdate: mr,
882
- onEnded: gr,
883
- onError: Sr
881
+ onLoadStart: gr,
882
+ onLoadedMetadata: pr,
883
+ onCanPlay: mr,
884
+ onPlay: fr,
885
+ onPause: dr,
886
+ onWaiting: Sr,
887
+ onSeeking: Jt,
888
+ onSeeked: Jt,
889
+ onTimeUpdate: hr,
890
+ onEnded: yr,
891
+ onError: br
884
892
  }
885
893
  ),
886
- Ve ? /* @__PURE__ */ H(Pt, { children: [
894
+ Ie ? /* @__PURE__ */ H(jt, { children: [
887
895
  /* @__PURE__ */ s(
888
- xr,
896
+ Er,
889
897
  {
890
- container: Qt,
891
- dir: $e ?? mt,
892
- lang: rr,
898
+ container: qt,
899
+ dir: $e ?? ht,
900
+ lang: ur,
893
901
  labels: {
894
902
  closeSettings: o.closeSettingsLabel,
895
903
  fullscreen: o.fullscreenLabel,
@@ -900,29 +908,29 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
900
908
  subtitleToggle: o.subtitleToggleAriaLabel,
901
909
  title: o.settingsTitle
902
910
  },
903
- isSubtitleEnabled: We,
911
+ isSubtitleEnabled: Be,
904
912
  onClose: () => ue(!1),
905
913
  onOpenChange: ue,
906
914
  onSubtitleToggle: fe ?? (() => {
907
915
  }),
908
- onViewModeChange: yr,
909
- open: Tt,
910
- viewMode: Gt
916
+ onViewModeChange: _r,
917
+ open: kt,
918
+ viewMode: Xt
911
919
  }
912
920
  ),
913
921
  /* @__PURE__ */ H(
914
922
  "div",
915
923
  {
916
924
  className: "slide-player__controls",
917
- onPointerEnter: Xt,
918
- onPointerLeave: qt,
919
- style: ar,
925
+ onPointerEnter: er,
926
+ onPointerLeave: tr,
927
+ style: ir,
920
928
  children: [
921
929
  /* @__PURE__ */ H("div", { className: "slide-player__group", children: [
922
930
  /* @__PURE__ */ s(
923
931
  "button",
924
932
  {
925
- "aria-expanded": Tt,
933
+ "aria-expanded": kt,
926
934
  "aria-haspopup": "dialog",
927
935
  "aria-label": o.moreOptionsAriaLabel,
928
936
  className: "slide-player__action slide-player__action--mobile-more",
@@ -931,7 +939,7 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
931
939
  },
932
940
  type: "button",
933
941
  children: /* @__PURE__ */ s(
934
- Jr,
942
+ Zr,
935
943
  {
936
944
  className: "slide-player__icon",
937
945
  strokeWidth: 2.25
@@ -945,52 +953,52 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
945
953
  "aria-label": o.volumeAriaLabel,
946
954
  className: "hidden",
947
955
  type: "button",
948
- children: /* @__PURE__ */ s(Pr, { className: "slide-player__icon", strokeWidth: 2.25 })
956
+ children: /* @__PURE__ */ s(jr, { className: "slide-player__icon", strokeWidth: 2.25 })
949
957
  }
950
958
  ),
951
959
  /* @__PURE__ */ s(
952
960
  "button",
953
961
  {
954
- "aria-label": At,
955
- "aria-keyshortcuts": Kt.ariaKeyShortcuts,
962
+ "aria-label": xt,
963
+ "aria-keyshortcuts": Ut.ariaKeyShortcuts,
956
964
  className: "slide-player__toggle slide-player__toggle--playback",
957
965
  onClick: () => {
958
966
  je();
959
967
  },
960
- title: Kt.title,
968
+ title: Ut.title,
961
969
  type: "button",
962
- children: lr ? /* @__PURE__ */ s(rn, {}) : /* @__PURE__ */ s(nn, {})
970
+ children: sr ? /* @__PURE__ */ s(un, {}) : /* @__PURE__ */ s(ln, {})
963
971
  }
964
972
  ),
965
973
  /* @__PURE__ */ s(
966
974
  "button",
967
975
  {
968
- "aria-keyshortcuts": Nt.ariaKeyShortcuts,
976
+ "aria-keyshortcuts": Kt.ariaKeyShortcuts,
969
977
  "aria-label": o.previousLabel,
970
978
  className: "slide-player__action slide-player__action--prev",
971
- disabled: Oe,
979
+ disabled: Re,
972
980
  onClick: () => {
973
- _e?.(ee());
981
+ _e?.(J());
974
982
  },
975
- title: Nt.title,
983
+ title: Kt.title,
976
984
  type: "button",
977
- children: /* @__PURE__ */ s(Zr, { className: "slide-player__icon", strokeWidth: 2.25 })
985
+ children: /* @__PURE__ */ s(zr, { className: "slide-player__icon", strokeWidth: 2.25 })
978
986
  }
979
987
  ),
980
988
  /* @__PURE__ */ s(
981
989
  "button",
982
990
  {
983
- "aria-keyshortcuts": Ft.ariaKeyShortcuts,
991
+ "aria-keyshortcuts": Wt.ariaKeyShortcuts,
984
992
  "aria-label": o.nextLabel,
985
993
  className: "slide-player__action slide-player__action--next",
986
- disabled: Re,
994
+ disabled: Oe,
987
995
  onClick: () => {
988
- Me?.(ee());
996
+ Me?.(J());
989
997
  },
990
- title: Ft.title,
998
+ title: Wt.title,
991
999
  type: "button",
992
1000
  children: /* @__PURE__ */ s(
993
- jr,
1001
+ Yr,
994
1002
  {
995
1003
  className: "slide-player__icon",
996
1004
  strokeWidth: 2.25
@@ -1001,32 +1009,32 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
1001
1009
  /* @__PURE__ */ s(
1002
1010
  "button",
1003
1011
  {
1004
- "aria-keyshortcuts": Et.ariaKeyShortcuts,
1012
+ "aria-keyshortcuts": Ft.ariaKeyShortcuts,
1005
1013
  "aria-label": o.previousSubtitleLabel,
1006
1014
  className: "slide-player__action slide-player__action--prev-subtitle",
1007
- disabled: !ae.previous,
1015
+ disabled: !le.previous,
1008
1016
  onClick: () => {
1009
1017
  ye("previous");
1010
1018
  },
1011
- title: Et.title,
1019
+ title: Ft.title,
1012
1020
  type: "button",
1013
- children: /* @__PURE__ */ s(zr, { className: "slide-player__icon", strokeWidth: 2.25 })
1021
+ children: /* @__PURE__ */ s(Gr, { className: "slide-player__icon", strokeWidth: 2.25 })
1014
1022
  }
1015
1023
  ),
1016
1024
  /* @__PURE__ */ s(
1017
1025
  "button",
1018
1026
  {
1019
- "aria-keyshortcuts": Ut.ariaKeyShortcuts,
1027
+ "aria-keyshortcuts": Bt.ariaKeyShortcuts,
1020
1028
  "aria-label": o.nextSubtitleLabel,
1021
1029
  className: "slide-player__action slide-player__action--next-subtitle",
1022
- disabled: !ae.next,
1030
+ disabled: !le.next,
1023
1031
  onClick: () => {
1024
1032
  ye("next");
1025
1033
  },
1026
- title: Ut.title,
1034
+ title: Bt.title,
1027
1035
  type: "button",
1028
1036
  children: /* @__PURE__ */ s(
1029
- Yr,
1037
+ Qr,
1030
1038
  {
1031
1039
  className: "slide-player__icon",
1032
1040
  strokeWidth: 2.25
@@ -1038,14 +1046,14 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
1038
1046
  "button",
1039
1047
  {
1040
1048
  "aria-label": o.subtitleToggleAriaLabel,
1041
- "aria-keyshortcuts": xt.ariaKeyShortcuts,
1042
- "aria-pressed": We,
1049
+ "aria-keyshortcuts": Et.ariaKeyShortcuts,
1050
+ "aria-pressed": Be,
1043
1051
  className: "slide-player__action slide-player__action--subtitle",
1044
1052
  onClick: fe,
1045
- title: xt.title,
1053
+ title: Et.title,
1046
1054
  type: "button",
1047
- children: We ? /* @__PURE__ */ s(Gr, { className: "slide-player__icon", strokeWidth: 2.25 }) : /* @__PURE__ */ s(
1048
- Qr,
1055
+ children: Be ? /* @__PURE__ */ s(Xr, { className: "slide-player__icon", strokeWidth: 2.25 }) : /* @__PURE__ */ s(
1056
+ qr,
1049
1057
  {
1050
1058
  className: "slide-player__icon",
1051
1059
  strokeWidth: 2.25
@@ -1056,20 +1064,20 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
1056
1064
  de ? /* @__PURE__ */ s(
1057
1065
  "button",
1058
1066
  {
1059
- "aria-label": Ct,
1060
- "aria-keyshortcuts": Bt.ariaKeyShortcuts,
1067
+ "aria-label": Nt,
1068
+ "aria-keyshortcuts": Rt.ariaKeyShortcuts,
1061
1069
  className: "slide-player__action slide-player__action--fullscreen",
1062
1070
  onClick: de,
1063
- title: Bt.title,
1071
+ title: Rt.title,
1064
1072
  type: "button",
1065
1073
  children: rt ? /* @__PURE__ */ s(
1066
- Xr,
1074
+ en,
1067
1075
  {
1068
1076
  className: "slide-player__icon",
1069
1077
  strokeWidth: 2.25
1070
1078
  }
1071
1079
  ) : /* @__PURE__ */ s(
1072
- qr,
1080
+ tn,
1073
1081
  {
1074
1082
  className: "slide-player__icon",
1075
1083
  strokeWidth: 2.25
@@ -1078,49 +1086,60 @@ const zt = /* @__PURE__ */ new Map(), Yt = (d) => {
1078
1086
  }
1079
1087
  ) : null
1080
1088
  ] }),
1081
- Je.length > 0 ? /* @__PURE__ */ H(Pt, { children: [
1089
+ Je.length > 0 ? /* @__PURE__ */ H(jt, { children: [
1082
1090
  /* @__PURE__ */ s("div", { className: "slide-player__separator" }),
1083
- /* @__PURE__ */ s("div", { className: "slide-player__group slide-player__group--custom-actions", children: Je.map((e, t) => /* @__PURE__ */ s(_r.Fragment, { children: e }, `custom-action-${t}`)) })
1091
+ /* @__PURE__ */ s("div", { className: "slide-player__group slide-player__group--custom-actions", children: Je.map((e, t) => /* @__PURE__ */ s(wr.Fragment, { children: e }, `custom-action-${t}`)) })
1084
1092
  ] }) : null
1085
1093
  ]
1086
1094
  }
1087
1095
  ),
1088
- N && (N.totalSteps > 1 || N.isGenerating) ? /* @__PURE__ */ s(
1096
+ v && (v.totalSteps > 1 || v.isGenerating) ? /* @__PURE__ */ H(
1089
1097
  "div",
1090
1098
  {
1091
- "aria-label": N.ariaLabel,
1099
+ "aria-label": v.ariaLabel,
1092
1100
  className: "slide-player__slide-progress",
1093
1101
  role: "navigation",
1094
- children: /* @__PURE__ */ H("div", { className: "slide-player__slide-progress-track", children: [
1095
- Array.from(
1096
- { length: N.totalSteps },
1097
- (e, t) => /* @__PURE__ */ s(
1098
- "button",
1099
- {
1100
- "aria-current": t === N.currentIndex ? "step" : void 0,
1101
- "aria-label": `${N.ariaLabel} ${t + 1}`,
1102
- className: "slide-player__slide-progress-segment",
1103
- "data-state": t < N.currentIndex ? "completed" : t === N.currentIndex ? "current" : "upcoming",
1104
- onClick: () => N.onNavigate?.(t),
1105
- type: "button"
1106
- },
1107
- t
1108
- )
1102
+ children: [
1103
+ /* @__PURE__ */ s(
1104
+ "div",
1105
+ {
1106
+ className: "slide-player__slide-progress-viewport",
1107
+ ref: mt,
1108
+ children: /* @__PURE__ */ s("div", { className: "slide-player__slide-progress-track", children: Array.from(
1109
+ { length: v.totalSteps },
1110
+ (e, t) => /* @__PURE__ */ s(
1111
+ "button",
1112
+ {
1113
+ "aria-current": t === v.currentIndex ? "step" : void 0,
1114
+ "aria-label": `${v.ariaLabel} ${t + 1}`,
1115
+ className: "slide-player__slide-progress-segment",
1116
+ "data-state": t < v.currentIndex ? "completed" : t === v.currentIndex ? "current" : "upcoming",
1117
+ onClick: () => v.onNavigate?.(
1118
+ t,
1119
+ J()
1120
+ ),
1121
+ ref: t === v.currentIndex ? pt : void 0,
1122
+ type: "button"
1123
+ },
1124
+ t
1125
+ )
1126
+ ) })
1127
+ }
1109
1128
  ),
1110
- N.isGenerating ? /* @__PURE__ */ H("span", { className: "slide-player__slide-progress-generating", children: [
1129
+ v.isGenerating ? /* @__PURE__ */ H("span", { className: "slide-player__slide-progress-generating", children: [
1111
1130
  /* @__PURE__ */ s("span", { "aria-hidden": "true" }),
1112
- N.generatingLabel
1131
+ v.generatingLabel
1113
1132
  ] }) : null
1114
- ] })
1133
+ ]
1115
1134
  }
1116
1135
  ) : null
1117
1136
  ] }) : null
1118
1137
  ]
1119
1138
  }
1120
1139
  );
1121
- }, cn = Mr(sn);
1122
- cn.displayName = "Player";
1140
+ }, fn = Tr(on);
1141
+ fn.displayName = "Player";
1123
1142
  export {
1124
- cn as default
1143
+ fn as default
1125
1144
  };
1126
1145
  //# sourceMappingURL=Player.es.js.map