@therealtinhtute/baroiplayer 1.0.2 → 1.0.4

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,13 +1,13 @@
1
1
  import * as re from "react";
2
- import N, { useEffect as q, useOptimistic as ce, useRef as W, useTransition as le, useCallback as A, useMemo as ue, useState as Q } from "react";
3
- import { c as H, d as pe, e as j, M as K } from "./context-Af84FynT.js";
2
+ import B, { useEffect as j, useOptimistic as ce, useRef as z, useTransition as le, useCallback as A, useMemo as ue, useState as Y } from "react";
3
+ import { c as N, d as pe, e as W, M as H } from "./context-Af84FynT.js";
4
4
  import { s as ve } from "./utils-nTO4AnHo.js";
5
5
  function Ie({ enabled: e = !0, state: t, controls: n, seekStep: s = 10, volumeStep: u = 0.1 }) {
6
6
  const o = (a) => {
7
7
  if (!e)
8
8
  return;
9
- const d = a.target;
10
- if (!(d.tagName === "INPUT" || d.tagName === "TEXTAREA" || d.contentEditable === "true"))
9
+ const m = a.target;
10
+ if (!(m.tagName === "INPUT" || m.tagName === "TEXTAREA" || m.contentEditable === "true"))
11
11
  switch (a.code) {
12
12
  case "Space":
13
13
  case "KeyK":
@@ -42,8 +42,8 @@ function Ie({ enabled: e = !0, state: t, controls: n, seekStep: s = 10, volumeSt
42
42
  case "Digit8":
43
43
  case "Digit9":
44
44
  a.preventDefault();
45
- const D = parseInt(a.code.replace("Digit", ""), 10) / 10;
46
- n.seek(t.duration * D);
45
+ const F = parseInt(a.code.replace("Digit", ""), 10) / 10;
46
+ n.seek(t.duration * F);
47
47
  break;
48
48
  case "Home":
49
49
  a.preventDefault(), n.seek(0);
@@ -53,7 +53,7 @@ function Ie({ enabled: e = !0, state: t, controls: n, seekStep: s = 10, volumeSt
53
53
  break;
54
54
  }
55
55
  };
56
- return q(() => {
56
+ return j(() => {
57
57
  if (e)
58
58
  return document.addEventListener("keydown", o), () => {
59
59
  document.removeEventListener("keydown", o);
@@ -102,33 +102,33 @@ function ye(e, t) {
102
102
  }
103
103
  }
104
104
  function Ee(e) {
105
- const t = N.useSyncExternalStore(e.subscribe, e.getState, e.getState), [n, s] = ce(t, ye), u = N.useCallback(async (d) => {
106
- d.optimistic && s(d), await e.dispatchOptimistic(d);
107
- }, [e, s]), o = N.useMemo(() => ({
105
+ const t = B.useSyncExternalStore(e.subscribe, e.getState, e.getState), [n, s] = ce(t, ye), u = B.useCallback(async (m) => {
106
+ m.optimistic && s(m), await e.dispatchOptimistic(m);
107
+ }, [e, s]), o = B.useMemo(() => ({
108
108
  // Play/Pause with immediate feedback
109
109
  togglePlayPause: async () => {
110
- const d = {
110
+ const m = {
111
111
  type: n.isPlaying ? "PAUSE" : "PLAY",
112
112
  optimistic: !0,
113
113
  timestamp: Date.now()
114
114
  };
115
- await u(d);
115
+ await u(m);
116
116
  },
117
117
  // Volume control with immediate slider feedback
118
- setVolumeOptimistic: async (d) => {
118
+ setVolumeOptimistic: async (m) => {
119
119
  const S = {
120
120
  type: "SET_VOLUME",
121
- detail: Math.max(0, Math.min(1, d)),
121
+ detail: Math.max(0, Math.min(1, m)),
122
122
  optimistic: !0,
123
123
  timestamp: Date.now()
124
124
  };
125
125
  await u(S);
126
126
  },
127
127
  // Seek with immediate scrub feedback
128
- seekOptimistic: async (d) => {
128
+ seekOptimistic: async (m) => {
129
129
  const S = {
130
130
  type: "SEEK",
131
- detail: d,
131
+ detail: m,
132
132
  optimistic: !0,
133
133
  timestamp: Date.now()
134
134
  };
@@ -136,27 +136,27 @@ function Ee(e) {
136
136
  },
137
137
  // Mute toggle with immediate icon change
138
138
  toggleMuteOptimistic: async () => {
139
- const d = {
139
+ const m = {
140
140
  type: "TOGGLE_MUTE",
141
141
  optimistic: !0,
142
142
  timestamp: Date.now()
143
143
  };
144
- await u(d);
144
+ await u(m);
145
145
  },
146
146
  // Fullscreen toggle with immediate layout change
147
147
  toggleFullscreenOptimistic: async () => {
148
- const d = {
148
+ const m = {
149
149
  type: n.isFullscreen ? "EXIT_FULLSCREEN" : "ENTER_FULLSCREEN",
150
150
  optimistic: !0,
151
151
  timestamp: Date.now()
152
152
  };
153
- await u(d);
153
+ await u(m);
154
154
  },
155
155
  // Playback rate with immediate feedback
156
- setPlaybackRateOptimistic: async (d) => {
156
+ setPlaybackRateOptimistic: async (m) => {
157
157
  const S = {
158
158
  type: "SET_PLAYBACK_RATE",
159
- detail: d,
159
+ detail: m,
160
160
  optimistic: !0,
161
161
  timestamp: Date.now()
162
162
  };
@@ -164,14 +164,14 @@ function Ee(e) {
164
164
  },
165
165
  // Subtitle toggle with immediate visibility change
166
166
  toggleSubtitlesOptimistic: async () => {
167
- const d = {
167
+ const m = {
168
168
  type: "TOGGLE_SUBTITLES",
169
169
  optimistic: !0,
170
170
  timestamp: Date.now()
171
171
  };
172
- await u(d);
172
+ await u(m);
173
173
  }
174
- }), [n, u]), a = N.useMemo(() => ({
174
+ }), [n, u]), a = B.useMemo(() => ({
175
175
  isPlaying: n.isPlaying,
176
176
  currentTime: n.currentTime,
177
177
  volume: n.volume,
@@ -203,7 +203,7 @@ function me(e) {
203
203
  const t = Math.floor(e / 60), n = Math.floor(e % 60), s = Math.floor(t / 60);
204
204
  return s > 0 ? `${s}:${String(t % 60).padStart(2, "0")}:${String(n).padStart(2, "0")}` : `${t}:${String(n).padStart(2, "0")}`;
205
205
  }
206
- function $(e, t) {
206
+ function K(e, t) {
207
207
  return ((n, s = !1) => {
208
208
  const u = {
209
209
  type: e,
@@ -215,43 +215,43 @@ function $(e, t) {
215
215
  });
216
216
  }
217
217
  function we(e) {
218
- const [t, n] = N.useState(e.getActionState());
219
- return N.useEffect(() => e.subscribe(() => {
218
+ const [t, n] = B.useState(e.getActionState());
219
+ return B.useEffect(() => e.subscribe(() => {
220
220
  const u = e.getActionState();
221
221
  n((o) => JSON.stringify(o) !== JSON.stringify(u) ? u : o);
222
222
  }), [e]), t;
223
223
  }
224
224
  function Te(e) {
225
- const t = N.useMemo(() => ({
225
+ const t = B.useMemo(() => ({
226
226
  // Playback actions
227
- play: $(H.PLAY, e),
228
- pause: $(H.PAUSE, e),
229
- seek: $(H.SEEK, e),
227
+ play: K(N.PLAY, e),
228
+ pause: K(N.PAUSE, e),
229
+ seek: K(N.SEEK, e),
230
230
  // Volume actions
231
- setVolume: $(H.SET_VOLUME, e),
232
- mute: $(H.MUTE, e),
233
- unmute: $(H.UNMUTE, e),
234
- toggleMute: $(H.TOGGLE_MUTE, e),
231
+ setVolume: K(N.SET_VOLUME, e),
232
+ mute: K(N.MUTE, e),
233
+ unmute: K(N.UNMUTE, e),
234
+ toggleMute: K(N.TOGGLE_MUTE, e),
235
235
  // Media state actions
236
- setDuration: $(H.SET_DURATION, e),
237
- setCurrentTime: $(H.SET_CURRENT_TIME, e),
238
- setBuffered: $(H.SET_BUFFERED, e),
239
- setLoading: $(H.SET_LOADING, e),
240
- setError: $(H.SET_ERROR, e),
236
+ setDuration: K(N.SET_DURATION, e),
237
+ setCurrentTime: K(N.SET_CURRENT_TIME, e),
238
+ setBuffered: K(N.SET_BUFFERED, e),
239
+ setLoading: K(N.SET_LOADING, e),
240
+ setError: K(N.SET_ERROR, e),
241
241
  // Display actions
242
- enterFullscreen: $(H.ENTER_FULLSCREEN, e),
243
- exitFullscreen: $(H.EXIT_FULLSCREEN, e),
244
- enterPiP: $(H.ENTER_PIP, e),
245
- exitPiP: $(H.EXIT_PIP, e),
242
+ enterFullscreen: K(N.ENTER_FULLSCREEN, e),
243
+ exitFullscreen: K(N.EXIT_FULLSCREEN, e),
244
+ enterPiP: K(N.ENTER_PIP, e),
245
+ exitPiP: K(N.EXIT_PIP, e),
246
246
  // Advanced actions
247
- setPlaybackRate: $(H.SET_PLAYBACK_RATE, e),
248
- setSubtitleTrack: $(H.SET_SUBTITLE_TRACK, e),
249
- setRendition: $(H.SET_RENDITION, e),
250
- toggleSubtitles: $(H.TOGGLE_SUBTITLES, e),
247
+ setPlaybackRate: K(N.SET_PLAYBACK_RATE, e),
248
+ setSubtitleTrack: K(N.SET_SUBTITLE_TRACK, e),
249
+ setRendition: K(N.SET_RENDITION, e),
250
+ toggleSubtitles: K(N.TOGGLE_SUBTITLES, e),
251
251
  // Preview actions
252
- previewTime: $(H.PREVIEW_TIME, e),
253
- clearPreview: $(H.CLEAR_PREVIEW, e)
254
- }), [e]), n = we(e), s = N.useMemo(() => ({
252
+ previewTime: K(N.PREVIEW_TIME, e),
253
+ clearPreview: K(N.CLEAR_PREVIEW, e)
254
+ }), [e]), n = we(e), s = B.useMemo(() => ({
255
255
  // These actions benefit from immediate UI feedback
256
256
  togglePlayPause: async (o) => {
257
257
  o ? await t.pause(!0) : await t.play(!0);
@@ -260,13 +260,13 @@ function Te(e) {
260
260
  await t.previewTime(o, !0), await t.seek(o, !0);
261
261
  },
262
262
  adjustVolume: async (o, a) => {
263
- const d = Math.max(0, Math.min(1, a + o));
264
- await t.setVolume(d, !0);
263
+ const m = Math.max(0, Math.min(1, a + o));
264
+ await t.setVolume(m, !0);
265
265
  },
266
266
  toggleFullscreenOptimistic: async (o) => {
267
267
  o ? await t.exitFullscreen(!0) : await t.enterFullscreen(!0);
268
268
  }
269
- }), [t]), u = N.useCallback(async () => {
269
+ }), [t]), u = B.useCallback(async () => {
270
270
  const { lastAction: o } = n;
271
271
  o && n.error && await e.dispatchOptimistic({
272
272
  ...o,
@@ -285,17 +285,17 @@ function Te(e) {
285
285
  };
286
286
  }
287
287
  function Oe(e) {
288
- const t = W(null), n = W(null), [s, u] = le(), [o, a] = le();
289
- N.useRef(0);
290
- const d = N.useRef(0), S = N.useRef(0);
291
- W();
292
- const D = W(0), R = pe(), g = "getOptimisticState" in R, r = j((i) => i.isPlaying), y = j((i) => i.currentTime), p = j((i) => i.duration), l = j((i) => i.volume), v = j((i) => i.isMuted), M = j((i) => i.isLoading), h = j((i) => i.isBuffering), c = j((i) => i.error), T = j((i) => i.buffered), E = j((i) => i.isFullscreen), b = R, w = g ? Ee(b) : null, m = g ? Te(b) : null, [z, F] = N.useState({
288
+ const t = z(null), n = z(null), [s, u] = le(), [o, a] = le();
289
+ B.useRef(0);
290
+ const m = B.useRef(0), S = B.useRef(0);
291
+ z();
292
+ const F = z(0), D = pe(), g = "getOptimisticState" in D, r = W((i) => i.isPlaying), y = W((i) => i.currentTime), p = W((i) => i.duration), d = W((i) => i.volume), v = W((i) => i.isMuted), L = W((i) => i.isLoading), h = W((i) => i.isBuffering), l = W((i) => i.error), T = W((i) => i.buffered), E = W((i) => i.isFullscreen), w = D, b = g ? Ee(w) : null, f = g ? Te(w) : null, [G, R] = B.useState({
293
293
  frameRate: 0,
294
294
  averageRenderTime: 0,
295
295
  droppedFrames: 0,
296
296
  bufferHealth: 0
297
- }), [O, P] = ce(l, (i, k) => Math.max(0, Math.min(1, k)));
298
- ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))), q(() => {
297
+ }), [I, P] = ce(d, (i, k) => Math.max(0, Math.min(1, k)));
298
+ ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))), j(() => {
299
299
  const i = t.current;
300
300
  if (!i)
301
301
  return;
@@ -307,8 +307,8 @@ function Oe(e) {
307
307
  preload: e.preload,
308
308
  crossOrigin: e.crossOrigin
309
309
  };
310
- Object.entries(k).forEach(([B, Y]) => {
311
- Y !== void 0 && (i[B] = Y);
310
+ Object.entries(k).forEach(([V, X]) => {
311
+ X !== void 0 && (i[V] = X);
312
312
  }), i.setAttribute("preload", e.preloadStrategy === "eager" ? "auto" : "metadata"), e.bufferingStrategy === "aggressive" && i.setAttribute("buffered", "auto"), i instanceof HTMLVideoElement && (i.style.willChange = "transform", i.style.transform = "translateZ(0)");
313
313
  }, [
314
314
  e.volume,
@@ -320,106 +320,106 @@ function Oe(e) {
320
320
  e.preloadStrategy,
321
321
  e.bufferingStrategy
322
322
  ]);
323
- const L = A(() => {
323
+ const M = A(() => {
324
324
  const i = t.current;
325
325
  if (!i)
326
326
  return;
327
327
  const k = performance.now();
328
328
  if (e.enableTimeUpdateThrottling !== !1) {
329
- if (k - D.current < (e.timeUpdateThrottleMs || 100))
329
+ if (k - F.current < (e.timeUpdateThrottleMs || 100))
330
330
  return;
331
- D.current = k;
331
+ F.current = k;
332
332
  }
333
333
  u(() => {
334
- g && m && m.setCurrentTime(i.currentTime);
334
+ g && f && f.setCurrentTime(i.currentTime);
335
335
  });
336
- }, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g, m]), I = A(() => {
336
+ }, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g, f]), C = A(() => {
337
337
  u(() => {
338
- g && m && m.play(!0);
338
+ g && f && f.play(!0);
339
339
  }), e.onPlay?.();
340
- }, [g, m, e.onPlay]), U = A(() => {
340
+ }, [g, f, e.onPlay]), O = A(() => {
341
341
  u(() => {
342
- g && m && m.pause(!0);
342
+ g && f && f.pause(!0);
343
343
  }), e.onPause?.();
344
- }, [g, m, e.onPause]), _ = A(() => {
344
+ }, [g, f, e.onPause]), U = A(() => {
345
345
  const i = t.current;
346
346
  i && u(() => {
347
- g && m && (m.setVolume(i.volume, !0), i.muted ? m.mute(!0) : m.unmute(!0));
347
+ g && f && (f.setVolume(i.volume, !0), i.muted ? f.mute(!0) : f.unmute(!0));
348
348
  });
349
- }, [g, m]), C = A(() => {
349
+ }, [g, f]), c = A(() => {
350
350
  a(() => {
351
351
  });
352
+ }, []), _ = A(() => {
352
353
  }, []), ee = A(() => {
353
- }, []), f = A(() => {
354
354
  const i = t.current;
355
355
  i && u(() => {
356
- g && m && m.setBuffered(i.buffered);
356
+ g && f && f.setBuffered(i.buffered);
357
357
  });
358
- }, [g, m]), V = A(() => {
358
+ }, [g, f]), Q = A(() => {
359
359
  const i = performance.now();
360
- if (i - S.current > 0 && (d.current++, d.current >= 60)) {
361
- const B = Math.round(d.current * 1e3 / (i - S.current));
362
- F((Y) => ({
363
- ...Y,
364
- frameRate: B,
365
- droppedFrames: Math.max(0, 60 - B)
366
- })), d.current = 0, S.current = i;
360
+ if (i - S.current > 0 && (m.current++, m.current >= 60)) {
361
+ const V = Math.round(m.current * 1e3 / (i - S.current));
362
+ R((X) => ({
363
+ ...X,
364
+ frameRate: V,
365
+ droppedFrames: Math.max(0, 60 - V)
366
+ })), m.current = 0, S.current = i;
367
367
  }
368
368
  }, []);
369
- q(() => {
369
+ j(() => {
370
370
  const i = t.current;
371
371
  if (!i)
372
372
  return;
373
373
  const k = [
374
- { event: "timeupdate", handler: L, passive: !0 },
375
- { event: "play", handler: I },
376
- { event: "pause", handler: U },
377
- { event: "volumechange", handler: _ },
378
- { event: "seeking", handler: C },
379
- { event: "seeked", handler: ee },
380
- { event: "progress", handler: f, passive: !0 },
381
- { event: "loadedmetadata", handler: () => V() },
382
- { event: "loadeddata", handler: () => V() }
374
+ { event: "timeupdate", handler: M, passive: !0 },
375
+ { event: "play", handler: C },
376
+ { event: "pause", handler: O },
377
+ { event: "volumechange", handler: U },
378
+ { event: "seeking", handler: c },
379
+ { event: "seeked", handler: _ },
380
+ { event: "progress", handler: ee, passive: !0 },
381
+ { event: "loadedmetadata", handler: () => Q() },
382
+ { event: "loadeddata", handler: () => Q() }
383
383
  ];
384
384
  k.forEach(({ event: te, handler: ne, passive: ie }) => {
385
385
  const oe = ie ? { passive: !0 } : {};
386
386
  i.addEventListener(te, ne, oe);
387
387
  });
388
- let B;
389
- const Y = () => {
390
- V(), B = requestAnimationFrame(Y);
388
+ let V;
389
+ const X = () => {
390
+ Q(), V = requestAnimationFrame(X);
391
391
  };
392
- return e.enablePerformanceMonitoring && Y(), () => {
392
+ return e.enablePerformanceMonitoring && X(), () => {
393
393
  k.forEach(({ event: te, handler: ne }) => {
394
394
  i.removeEventListener(te, ne);
395
- }), B && cancelAnimationFrame(B);
395
+ }), V && cancelAnimationFrame(V);
396
396
  };
397
397
  }, [
398
- L,
399
- I,
398
+ M,
399
+ C,
400
+ O,
400
401
  U,
402
+ c,
401
403
  _,
402
- C,
403
404
  ee,
404
- f,
405
- V,
405
+ Q,
406
406
  e.enablePerformanceMonitoring
407
407
  ]);
408
408
  const se = ue(() => {
409
409
  const i = async () => {
410
410
  const x = t.current;
411
411
  if (x)
412
- if (g && m)
413
- await m.play(!0);
412
+ if (g && f)
413
+ await f.play(!0);
414
414
  else
415
415
  try {
416
416
  await x.play();
417
- } catch (X) {
418
- console.error("Failed to play media:", X);
417
+ } catch (q) {
418
+ console.error("Failed to play media:", q);
419
419
  }
420
420
  }, k = () => {
421
421
  const x = t.current;
422
- x && (g && m ? m.pause(!0) : x.pause());
422
+ x && (g && f ? f.pause(!0) : x.pause());
423
423
  };
424
424
  return {
425
425
  play: i,
@@ -428,40 +428,40 @@ function Oe(e) {
428
428
  r ? k() : i();
429
429
  },
430
430
  seek: (x) => {
431
- const X = t.current;
432
- if (!X)
431
+ const q = t.current;
432
+ if (!q)
433
433
  return;
434
434
  const Z = Math.max(0, Math.min(x, p || 0));
435
- g && m ? a(() => {
436
- m.seek(Z, !0);
437
- }) : X.currentTime = Z;
435
+ g && f ? a(() => {
436
+ f.seek(Z, !0);
437
+ }) : q.currentTime = Z;
438
438
  },
439
439
  setVolume: (x) => {
440
- const X = t.current;
441
- if (!X)
440
+ const q = t.current;
441
+ if (!q)
442
442
  return;
443
443
  const Z = Math.max(0, Math.min(1, x));
444
- g && m ? (P(Z), u(() => {
445
- m.setVolume(Z, !0);
446
- })) : X.volume = Z;
444
+ g && f ? (P(Z), u(() => {
445
+ f.setVolume(Z, !0);
446
+ })) : q.volume = Z;
447
447
  },
448
448
  toggleMute: () => {
449
449
  const x = t.current;
450
- x && (g && m ? m.toggleMute(!0) : x.muted = !x.muted);
450
+ x && (g && f ? f.toggleMute(!0) : x.muted = !x.muted);
451
451
  },
452
452
  enterFullscreen: async () => {
453
453
  const x = n.current;
454
454
  if (!(!x || !document.fullscreenEnabled))
455
455
  try {
456
- await x.requestFullscreen(), g && m && m.enterFullscreen(!0);
457
- } catch (X) {
458
- console.error("Failed to enter fullscreen:", X);
456
+ await x.requestFullscreen(), g && f && f.enterFullscreen(!0);
457
+ } catch (q) {
458
+ console.error("Failed to enter fullscreen:", q);
459
459
  }
460
460
  },
461
461
  exitFullscreen: async () => {
462
462
  if (document.fullscreenElement)
463
463
  try {
464
- await document.exitFullscreen(), g && m && m.exitFullscreen(!0);
464
+ await document.exitFullscreen(), g && f && f.exitFullscreen(!0);
465
465
  } catch (x) {
466
466
  console.error("Failed to exit fullscreen:", x);
467
467
  }
@@ -471,34 +471,34 @@ function Oe(e) {
471
471
  r,
472
472
  p,
473
473
  g,
474
- m,
474
+ f,
475
475
  u,
476
476
  a,
477
477
  P
478
478
  ]), ae = ue(() => ({
479
- isPlaying: w?.isPlaying ?? r,
480
- currentTime: w?.currentTime ?? y,
481
- duration: w?.duration ?? p,
482
- volume: w?.volume ?? O,
483
- isMuted: w?.isMuted ?? v,
484
- isLoading: w?.isBuffering ?? M,
485
- isBuffering: w?.isBuffering ?? h,
486
- error: w?.error ?? c,
487
- buffered: w?.buffered ?? T,
488
- isFullscreen: w?.isFullscreen ?? E,
479
+ isPlaying: b?.isPlaying ?? r,
480
+ currentTime: b?.currentTime ?? y,
481
+ duration: b?.duration ?? p,
482
+ volume: b?.volume ?? I,
483
+ isMuted: b?.isMuted ?? v,
484
+ isLoading: b?.isBuffering ?? L,
485
+ isBuffering: b?.isBuffering ?? h,
486
+ error: b?.error ?? l,
487
+ buffered: b?.buffered ?? T,
488
+ isFullscreen: b?.isFullscreen ?? E,
489
489
  progress: p > 0 ? y / p : 0,
490
490
  isTransitioning: s || o,
491
- canPlay: !M && !h && !c
491
+ canPlay: !L && !h && !l
492
492
  }), [
493
- w,
493
+ b,
494
494
  r,
495
495
  y,
496
496
  p,
497
- O,
497
+ I,
498
498
  v,
499
- M,
499
+ L,
500
500
  h,
501
- c,
501
+ l,
502
502
  T,
503
503
  E,
504
504
  s,
@@ -510,17 +510,17 @@ function Oe(e) {
510
510
  containerRef: n,
511
511
  // State
512
512
  state: ae,
513
- actualState: w?.actualState,
513
+ actualState: b?.actualState,
514
514
  // Controls
515
515
  controls: se,
516
516
  // Performance metrics
517
- performanceMetrics: z,
517
+ performanceMetrics: G,
518
518
  isTransitioning: s || o,
519
519
  // Enhanced features
520
- actions: w?.actions,
521
- actionState: w?.actionState,
520
+ actions: b?.actions,
521
+ actionState: b?.actionState,
522
522
  // Optimistic features
523
- optimisticState: w,
523
+ optimisticState: b,
524
524
  isEnhanced: g
525
525
  };
526
526
  }
@@ -533,8 +533,8 @@ function Ue(e = {}) {
533
533
  enableGC: s = !0,
534
534
  monitorMemory: u = !0
535
535
  } = e;
536
- W();
537
- const o = W(/* @__PURE__ */ new Set()), a = W(/* @__PURE__ */ new Map()), d = W(/* @__PURE__ */ new Set()), S = W(/* @__PURE__ */ new Set()), D = A(() => {
536
+ z();
537
+ const o = z(/* @__PURE__ */ new Set()), a = z(/* @__PURE__ */ new Map()), m = z(/* @__PURE__ */ new Set()), S = z(/* @__PURE__ */ new Set()), F = A(() => {
538
538
  if (typeof window > "u" || !("memory" in performance))
539
539
  return { used: 0, total: 0, limit: 0 };
540
540
  const h = performance.memory;
@@ -543,87 +543,87 @@ function Ue(e = {}) {
543
543
  total: h.totalJSHeapSize,
544
544
  limit: h.jsHeapSizeLimit
545
545
  };
546
- }, []), [R, g] = N.useState({
546
+ }, []), [D, g] = B.useState({
547
547
  used: 0,
548
548
  total: 0,
549
549
  limit: 0,
550
550
  usage: 0,
551
551
  isHighUsage: !1
552
552
  });
553
- q(() => {
553
+ j(() => {
554
554
  if (!u)
555
555
  return;
556
556
  const h = () => {
557
- const T = D(), E = T.used / 1024 / 1024, b = E > t;
557
+ const T = F(), E = T.used / 1024 / 1024, w = E > t;
558
558
  g({
559
559
  ...T,
560
560
  usage: E,
561
- isHighUsage: b
562
- }), b && s && r();
561
+ isHighUsage: w
562
+ }), w && s && r();
563
563
  };
564
564
  h();
565
- const c = p(h, n);
566
- return d.current.add(c), () => {
567
- clearInterval(c), d.current.delete(c);
565
+ const l = p(h, n);
566
+ return m.current.add(l), () => {
567
+ clearInterval(l), m.current.delete(l);
568
568
  };
569
- }, [u, D, t, s, n]);
569
+ }, [u, F, t, s, n]);
570
570
  const r = A(() => {
571
- d.current.forEach((h) => {
571
+ m.current.forEach((h) => {
572
572
  clearTimeout(h);
573
- }), d.current.clear(), S.current.forEach((h) => {
573
+ }), m.current.clear(), S.current.forEach((h) => {
574
574
  cancelAnimationFrame(h);
575
575
  }), S.current.clear(), o.current.forEach((h) => {
576
576
  h.disconnect();
577
- }), o.current.clear(), a.current.forEach((h, c) => {
577
+ }), o.current.clear(), a.current.forEach((h, l) => {
578
578
  h.forEach(({ event: T, handler: E }) => {
579
- c.removeEventListener(T, E);
579
+ l.removeEventListener(T, E);
580
580
  });
581
581
  }), a.current.clear(), s && "gc" in window && window.gc();
582
- }, [s]), y = A((h, c, T, E) => (h.addEventListener(c, T, E), a.current.has(h) || a.current.set(h, []), a.current.get(h).push({ event: c, handler: T }), () => {
583
- h.removeEventListener(c, T);
584
- const b = a.current.get(h);
585
- if (b) {
586
- const w = b.findIndex((m) => m.event === c && m.handler === T);
587
- w > -1 && b.splice(w, 1), b.length === 0 && a.current.delete(h);
582
+ }, [s]), y = A((h, l, T, E) => (h.addEventListener(l, T, E), a.current.has(h) || a.current.set(h, []), a.current.get(h).push({ event: l, handler: T }), () => {
583
+ h.removeEventListener(l, T);
584
+ const w = a.current.get(h);
585
+ if (w) {
586
+ const b = w.findIndex((f) => f.event === l && f.handler === T);
587
+ b > -1 && w.splice(b, 1), w.length === 0 && a.current.delete(h);
588
588
  }
589
- }), []), p = A((h, c) => {
590
- const T = p(h, c);
591
- return d.current.add(T), () => {
592
- clearInterval(T), d.current.delete(T);
589
+ }), []), p = A((h, l) => {
590
+ const T = p(h, l);
591
+ return m.current.add(T), () => {
592
+ clearInterval(T), m.current.delete(T);
593
593
  };
594
- }, []), l = A((h, c) => {
595
- const T = l(h, c);
596
- return d.current.add(T), () => {
597
- clearTimeout(T), d.current.delete(T);
594
+ }, []), d = A((h, l) => {
595
+ const T = d(h, l);
596
+ return m.current.add(T), () => {
597
+ clearTimeout(T), m.current.delete(T);
598
598
  };
599
599
  }, []), v = A((h) => {
600
- const c = v(h);
601
- return S.current.add(c), () => {
602
- cancelAnimationFrame(c), S.current.delete(c);
600
+ const l = v(h);
601
+ return S.current.add(l), () => {
602
+ cancelAnimationFrame(l), S.current.delete(l);
603
603
  };
604
- }, []), M = A((h) => (o.current.add(h), () => {
604
+ }, []), L = A((h) => (o.current.add(h), () => {
605
605
  h.disconnect(), o.current.delete(h);
606
606
  }), []);
607
- return q(() => () => {
607
+ return j(() => () => {
608
608
  r();
609
609
  }, [r]), {
610
610
  // Memory stats
611
- memoryStats: R,
612
- getMemoryUsage: D,
611
+ memoryStats: D,
612
+ getMemoryUsage: F,
613
613
  // Cleanup functions
614
614
  performCleanup: r,
615
615
  // Safe API functions
616
616
  addEventListener: y,
617
617
  setInterval: p,
618
- setTimeout: l,
618
+ setTimeout: d,
619
619
  requestAnimationFrame: v,
620
- addObserver: M,
620
+ addObserver: L,
621
621
  // Utilities
622
622
  formatBytes: (h) => {
623
623
  if (h === 0)
624
624
  return "0 Bytes";
625
- const c = 1024, T = ["Bytes", "KB", "MB", "GB"], E = Math.floor(Math.log(h) / Math.log(c));
626
- return parseFloat((h / Math.pow(c, E)).toFixed(2)) + " " + T[E];
625
+ const l = 1024, T = ["Bytes", "KB", "MB", "GB"], E = Math.floor(Math.log(h) / Math.log(l));
626
+ return parseFloat((h / Math.pow(l, E)).toFixed(2)) + " " + T[E];
627
627
  }
628
628
  };
629
629
  }
@@ -636,8 +636,8 @@ function be({
636
636
  }) {
637
637
  const o = (a) => {
638
638
  if (!e) return;
639
- const d = a.target;
640
- if (!(d.tagName === "INPUT" || d.tagName === "TEXTAREA" || d.contentEditable === "true"))
639
+ const m = a.target;
640
+ if (!(m.tagName === "INPUT" || m.tagName === "TEXTAREA" || m.contentEditable === "true"))
641
641
  switch (a.code) {
642
642
  case "Space":
643
643
  case "KeyK":
@@ -672,8 +672,8 @@ function be({
672
672
  case "Digit8":
673
673
  case "Digit9":
674
674
  a.preventDefault();
675
- const D = parseInt(a.code.replace("Digit", ""), 10) / 10;
676
- n.seek(t.duration * D);
675
+ const F = parseInt(a.code.replace("Digit", ""), 10) / 10;
676
+ n.seek(t.duration * F);
677
677
  break;
678
678
  case "Home":
679
679
  a.preventDefault(), n.seek(0);
@@ -683,7 +683,7 @@ function be({
683
683
  break;
684
684
  }
685
685
  };
686
- return q(() => {
686
+ return j(() => {
687
687
  if (e)
688
688
  return document.addEventListener("keydown", o), () => {
689
689
  document.removeEventListener("keydown", o);
@@ -696,91 +696,8 @@ const Ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
696
696
  __proto__: null,
697
697
  useKeyboardControls: be
698
698
  }, Symbol.toStringTag, { value: "Module" }));
699
- function G(e, t) {
700
- return ((n, s = !1) => {
701
- const u = {
702
- type: e,
703
- detail: n,
704
- optimistic: s,
705
- timestamp: Date.now()
706
- };
707
- return s ? t.dispatchOptimistic(u) : (t.dispatch(u), Promise.resolve());
708
- });
709
- }
710
- function Se(e) {
711
- const [t, n] = N.useState(e.getActionState());
712
- return N.useEffect(() => e.subscribe(() => {
713
- const u = e.getActionState();
714
- n(
715
- (o) => JSON.stringify(o) !== JSON.stringify(u) ? u : o
716
- );
717
- }), [e]), t;
718
- }
719
- function _e(e) {
720
- const t = N.useMemo(() => ({
721
- // Playback actions
722
- play: G(K.PLAY, e),
723
- pause: G(K.PAUSE, e),
724
- seek: G(K.SEEK, e),
725
- // Volume actions
726
- setVolume: G(K.SET_VOLUME, e),
727
- mute: G(K.MUTE, e),
728
- unmute: G(K.UNMUTE, e),
729
- toggleMute: G(K.TOGGLE_MUTE, e),
730
- // Media state actions
731
- setDuration: G(K.SET_DURATION, e),
732
- setCurrentTime: G(K.SET_CURRENT_TIME, e),
733
- setBuffered: G(K.SET_BUFFERED, e),
734
- setLoading: G(K.SET_LOADING, e),
735
- setError: G(K.SET_ERROR, e),
736
- // Display actions
737
- enterFullscreen: G(K.ENTER_FULLSCREEN, e),
738
- exitFullscreen: G(K.EXIT_FULLSCREEN, e),
739
- enterPiP: G(K.ENTER_PIP, e),
740
- exitPiP: G(K.EXIT_PIP, e),
741
- // Advanced actions
742
- setPlaybackRate: G(K.SET_PLAYBACK_RATE, e),
743
- setSubtitleTrack: G(K.SET_SUBTITLE_TRACK, e),
744
- setRendition: G(K.SET_RENDITION, e),
745
- toggleSubtitles: G(K.TOGGLE_SUBTITLES, e),
746
- // Preview actions
747
- previewTime: G(K.PREVIEW_TIME, e),
748
- clearPreview: G(K.CLEAR_PREVIEW, e)
749
- }), [e]), n = Se(e), s = N.useMemo(() => ({
750
- // These actions benefit from immediate UI feedback
751
- togglePlayPause: async (o) => {
752
- o ? await t.pause(!0) : await t.play(!0);
753
- },
754
- seekWithPreview: async (o) => {
755
- await t.previewTime(o, !0), await t.seek(o, !0);
756
- },
757
- adjustVolume: async (o, a) => {
758
- const d = Math.max(0, Math.min(1, a + o));
759
- await t.setVolume(d, !0);
760
- },
761
- toggleFullscreenOptimistic: async (o) => {
762
- o ? await t.exitFullscreen(!0) : await t.enterFullscreen(!0);
763
- }
764
- }), [t]), u = N.useCallback(async () => {
765
- const { lastAction: o } = n;
766
- o && n.error && await e.dispatchOptimistic({
767
- ...o,
768
- retryCount: (o.retryCount || 0) + 1
769
- });
770
- }, [e, n]);
771
- return {
772
- ...t,
773
- ...s,
774
- actionState: n,
775
- retryLastAction: u,
776
- isLoading: n.pending,
777
- hasError: !!n.error,
778
- errorMessage: n.error,
779
- retryCount: n.retryCount
780
- };
781
- }
782
- function Me() {
783
- const [e, t] = Q({
699
+ function Se() {
700
+ const [e, t] = Y({
784
701
  isPlaying: !1,
785
702
  currentTime: 0,
786
703
  duration: 0,
@@ -825,138 +742,130 @@ function Me() {
825
742
  }
826
743
  };
827
744
  }
828
- function Le(e) {
829
- const t = W(null), n = W(null), {
745
+ function Me(e) {
746
+ const t = z(null), n = z(null), {
830
747
  state: s,
831
748
  setPlaying: u,
832
749
  setCurrentTime: o,
833
750
  setDuration: a,
834
- setVolume: d,
751
+ setVolume: m,
835
752
  setMuted: S,
836
- setLoading: D,
837
- setFullscreen: R,
753
+ setLoading: F,
754
+ setFullscreen: D,
838
755
  setError: g,
839
756
  setBuffered: r
840
- } = Me();
841
- q(() => {
842
- const f = t.current;
843
- f && (e.volume !== void 0 && (f.volume = e.volume, d(e.volume)), e.muted !== void 0 && (f.muted = e.muted, S(e.muted)), e.autoPlay !== void 0 && (f.autoplay = e.autoPlay), e.loop !== void 0 && (f.loop = e.loop), e.preload !== void 0 && (f.preload = e.preload), e.crossOrigin !== void 0 && (f.crossOrigin = e.crossOrigin));
844
- }, [e, d, S]);
757
+ } = Se();
758
+ j(() => {
759
+ const c = t.current;
760
+ c && (e.volume !== void 0 && (c.volume = e.volume, m(e.volume)), e.muted !== void 0 && (c.muted = e.muted, S(e.muted)), e.autoPlay !== void 0 && (c.autoplay = e.autoPlay), e.loop !== void 0 && (c.loop = e.loop), e.preload !== void 0 && (c.preload = e.preload), e.crossOrigin !== void 0 && (c.crossOrigin = e.crossOrigin));
761
+ }, [e, m, S]);
845
762
  const y = () => {
846
763
  u(!0), e.onPlay?.();
847
764
  }, p = () => {
848
765
  u(!1), e.onPause?.();
849
- }, l = () => {
850
- const f = t.current;
851
- f && (o(f.currentTime), e.onTimeUpdate?.(f.currentTime));
766
+ }, d = () => {
767
+ const c = t.current;
768
+ c && (o(c.currentTime), e.onTimeUpdate?.(c.currentTime));
852
769
  }, v = () => {
853
- const f = t.current;
854
- f && (a(f.duration), e.onDurationChange?.(f.duration));
855
- }, M = () => {
856
- const f = t.current;
857
- f && (d(f.volume), S(f.muted), e.onVolumeChange?.(f.volume));
770
+ const c = t.current;
771
+ c && (a(c.duration), e.onDurationChange?.(c.duration));
772
+ }, L = () => {
773
+ const c = t.current;
774
+ c && (m(c.volume), S(c.muted), e.onVolumeChange?.(c.volume));
858
775
  }, h = () => {
859
- D(!0), g(null), e.onLoadStart?.();
860
- }, c = () => {
861
- D(!1), e.onLoadedData?.();
776
+ F(!0), g(null), e.onLoadStart?.();
777
+ }, l = () => {
778
+ F(!1), e.onLoadedData?.();
862
779
  }, T = () => {
863
- const f = t.current;
864
- if (!f) return;
865
- const V = f.error?.message || "An error occurred while loading the media";
866
- g(V), D(!1), e.onError?.(V);
780
+ const c = t.current;
781
+ if (!c) return;
782
+ const _ = c.error?.message || "An error occurred while loading the media";
783
+ g(_), F(!1), e.onError?.(_);
867
784
  }, E = () => {
868
785
  u(!1), e.onEnded?.();
869
- }, b = () => {
870
- const f = t.current;
871
- f && r(f.buffered);
786
+ }, w = () => {
787
+ const c = t.current;
788
+ c && r(c.buffered);
872
789
  };
873
- q(() => {
874
- const f = t.current;
875
- if (f)
876
- return f.addEventListener("play", y), f.addEventListener("pause", p), f.addEventListener("timeupdate", l), f.addEventListener("durationchange", v), f.addEventListener("volumechange", M), f.addEventListener("loadstart", h), f.addEventListener("loadeddata", c), f.addEventListener("error", T), f.addEventListener("ended", E), f.addEventListener("progress", b), () => {
877
- f.removeEventListener("play", y), f.removeEventListener("pause", p), f.removeEventListener("timeupdate", l), f.removeEventListener("durationchange", v), f.removeEventListener("volumechange", M), f.removeEventListener("loadstart", h), f.removeEventListener("loadeddata", c), f.removeEventListener("error", T), f.removeEventListener("ended", E), f.removeEventListener("progress", b);
790
+ j(() => {
791
+ const c = t.current;
792
+ if (c)
793
+ return c.addEventListener("play", y), c.addEventListener("pause", p), c.addEventListener("timeupdate", d), c.addEventListener("durationchange", v), c.addEventListener("volumechange", L), c.addEventListener("loadstart", h), c.addEventListener("loadeddata", l), c.addEventListener("error", T), c.addEventListener("ended", E), c.addEventListener("progress", w), () => {
794
+ c.removeEventListener("play", y), c.removeEventListener("pause", p), c.removeEventListener("timeupdate", d), c.removeEventListener("durationchange", v), c.removeEventListener("volumechange", L), c.removeEventListener("loadstart", h), c.removeEventListener("loadeddata", l), c.removeEventListener("error", T), c.removeEventListener("ended", E), c.removeEventListener("progress", w);
878
795
  };
879
796
  }, [
880
797
  y,
881
798
  p,
882
- l,
799
+ d,
883
800
  v,
884
- M,
801
+ L,
885
802
  h,
886
- c,
803
+ l,
887
804
  T,
888
805
  E,
889
- b
806
+ w
890
807
  ]);
891
- const w = async () => {
892
- const f = t.current;
893
- if (f)
808
+ const b = async () => {
809
+ const c = t.current;
810
+ if (c)
894
811
  try {
895
- await f.play();
896
- } catch (V) {
897
- console.error("Failed to play media:", V), g("Failed to play media");
812
+ await c.play();
813
+ } catch (_) {
814
+ console.error("Failed to play media:", _), g("Failed to play media");
898
815
  }
899
- }, m = () => {
900
- const f = t.current;
901
- f && f.pause();
902
- }, z = () => {
903
- s.isPlaying ? m() : w();
904
- }, F = (f) => {
905
- const V = t.current;
906
- V && (V.currentTime = Math.max(0, Math.min(f, V.duration || 0)));
907
- }, O = (f) => {
908
- const V = t.current;
909
- if (!V) return;
910
- const se = Math.max(0, Math.min(1, f));
911
- V.volume = se;
816
+ }, f = () => {
817
+ const c = t.current;
818
+ c && c.pause();
819
+ }, G = () => {
820
+ s.isPlaying ? f() : b();
821
+ }, R = (c) => {
822
+ const _ = t.current;
823
+ _ && (_.currentTime = Math.max(0, Math.min(c, _.duration || 0)));
824
+ }, I = (c) => {
825
+ const _ = t.current;
826
+ if (!_) return;
827
+ const ee = Math.max(0, Math.min(1, c));
828
+ _.volume = ee;
912
829
  }, P = () => {
913
- const f = t.current;
914
- f && (f.muted = !0);
915
- }, L = () => {
916
- const f = t.current;
917
- f && (f.muted = !1);
918
- }, I = () => {
919
- const f = t.current;
920
- f && (f.muted = !f.muted);
921
- }, U = async () => {
922
- const f = n.current;
923
- if (!(!f || !document.fullscreenEnabled))
830
+ const c = t.current;
831
+ c && (c.muted = !c.muted);
832
+ }, M = async () => {
833
+ const c = n.current;
834
+ if (!(!c || !document.fullscreenEnabled))
924
835
  try {
925
- await f.requestFullscreen(), R(!0);
926
- } catch (V) {
927
- console.error("Failed to enter fullscreen:", V);
836
+ await c.requestFullscreen(), D(!0);
837
+ } catch (_) {
838
+ console.error("Failed to enter fullscreen:", _);
928
839
  }
929
- }, _ = async () => {
840
+ }, C = async () => {
930
841
  if (document.fullscreenElement)
931
842
  try {
932
- await document.exitFullscreen(), R(!1);
933
- } catch (f) {
934
- console.error("Failed to exit fullscreen:", f);
843
+ await document.exitFullscreen(), D(!1);
844
+ } catch (c) {
845
+ console.error("Failed to exit fullscreen:", c);
935
846
  }
936
- }, C = () => {
937
- document.fullscreenElement ? _() : U();
847
+ }, O = () => {
848
+ document.fullscreenElement ? C() : M();
938
849
  };
939
- return q(() => {
940
- const f = () => {
941
- R(!!document.fullscreenElement);
850
+ return j(() => {
851
+ const c = () => {
852
+ D(!!document.fullscreenElement);
942
853
  };
943
- return document.addEventListener("fullscreenchange", f), () => {
944
- document.removeEventListener("fullscreenchange", f);
854
+ return document.addEventListener("fullscreenchange", c), () => {
855
+ document.removeEventListener("fullscreenchange", c);
945
856
  };
946
- }, [R]), {
857
+ }, [D]), {
947
858
  state: s,
948
859
  controls: {
949
- play: w,
950
- pause: m,
951
- toggle: z,
952
- seek: F,
953
- setVolume: O,
954
- mute: P,
955
- unmute: L,
956
- toggleMute: I,
957
- enterFullscreen: U,
958
- exitFullscreen: _,
959
- toggleFullscreen: C
860
+ play: b,
861
+ pause: f,
862
+ toggle: G,
863
+ seek: R,
864
+ setVolume: I,
865
+ toggleMute: P,
866
+ enterFullscreen: M,
867
+ exitFullscreen: C,
868
+ toggleFullscreen: O
960
869
  },
961
870
  mediaRef: t,
962
871
  containerRef: n
@@ -1007,7 +916,7 @@ function de() {
1007
916
  });
1008
917
  return re.useEffect(() => {
1009
918
  const n = () => {
1010
- const a = window.innerWidth, d = window.innerHeight;
919
+ const a = window.innerWidth, m = window.innerHeight;
1011
920
  t({
1012
921
  isMobile: a < J.mobile,
1013
922
  isTablet: a >= J.mobile && a < J.desktop,
@@ -1015,8 +924,8 @@ function de() {
1015
924
  isTouchDevice: ge(),
1016
925
  platform: fe(),
1017
926
  supportsHaptics: he(),
1018
- screenSize: { width: a, height: d },
1019
- orientation: a > d ? "landscape" : "portrait"
927
+ screenSize: { width: a, height: m },
928
+ orientation: a > m ? "landscape" : "portrait"
1020
929
  });
1021
930
  };
1022
931
  window.addEventListener("resize", n), window.addEventListener("orientationchange", n);
@@ -1026,7 +935,7 @@ function de() {
1026
935
  };
1027
936
  }, []), e;
1028
937
  }
1029
- function Be() {
938
+ function _e() {
1030
939
  const { platform: e, isMobile: t } = de();
1031
940
  re.useEffect(() => {
1032
941
  if (t) {
@@ -1042,7 +951,7 @@ function Be() {
1042
951
  }
1043
952
  }, [e, t]);
1044
953
  }
1045
- function ke() {
954
+ function Le() {
1046
955
  const { supportsHaptics: e } = de();
1047
956
  return { triggerHaptic: re.useCallback((n = "light") => {
1048
957
  if (!e) return;
@@ -1057,7 +966,7 @@ function ke() {
1057
966
  "vibrate" in navigator && navigator.vibrate(u);
1058
967
  }, [e]), supportsHaptics: e };
1059
968
  }
1060
- const Pe = {
969
+ const ke = {
1061
970
  enabledGestures: ["tap", "double-tap", "long-press", "swipe-left", "swipe-right", "swipe-up", "swipe-down", "pinch-in", "pinch-out"],
1062
971
  tapThreshold: 200,
1063
972
  doubleTapThreshold: 300,
@@ -1068,106 +977,106 @@ const Pe = {
1068
977
  rotationThreshold: 15,
1069
978
  enableHapticFeedback: !0
1070
979
  };
1071
- function Fe(e, t, n = {}) {
1072
- const s = { ...Pe, ...n }, { isTouchDevice: u } = de(), { triggerHaptic: o } = ke(), a = re.useRef({
980
+ function Pe(e, t, n = {}) {
981
+ const s = { ...ke, ...n }, { isTouchDevice: u } = de(), { triggerHaptic: o } = Le(), a = re.useRef({
1073
982
  isTracking: !1,
1074
983
  touches: [],
1075
984
  startTouches: []
1076
- }), d = (p) => ({
985
+ }), m = (p) => ({
1077
986
  id: p.identifier,
1078
987
  x: p.clientX,
1079
988
  y: p.clientY,
1080
989
  timestamp: Date.now()
1081
- }), S = (p, l) => Math.sqrt(Math.pow(l.x - p.x, 2) + Math.pow(l.y - p.y, 2)), D = (p, l) => {
1082
- const v = Math.max(l.timestamp - p.timestamp, 1);
990
+ }), S = (p, d) => Math.sqrt(Math.pow(d.x - p.x, 2) + Math.pow(d.y - p.y, 2)), F = (p, d) => {
991
+ const v = Math.max(d.timestamp - p.timestamp, 1);
1083
992
  return {
1084
- x: (l.x - p.x) / v,
1085
- y: (l.y - p.y) / v
993
+ x: (d.x - p.x) / v,
994
+ y: (d.y - p.y) / v
1086
995
  };
1087
- }, R = (p, l, v, M = {}) => ({
996
+ }, D = (p, d, v, L = {}) => ({
1088
997
  type: p,
1089
- startPoint: { x: l.x, y: l.y },
998
+ startPoint: { x: d.x, y: d.y },
1090
999
  currentPoint: { x: v.x, y: v.y },
1091
- duration: v.timestamp - l.timestamp,
1000
+ duration: v.timestamp - d.timestamp,
1092
1001
  target: e.current,
1093
1002
  preventDefault: () => {
1094
1003
  },
1095
- ...M
1004
+ ...L
1096
1005
  }), g = re.useCallback((p) => {
1097
1006
  if (!s.enabledGestures.length) return;
1098
- const l = Array.from(p.touches).map(d), v = a.current;
1099
- v.isTracking = !0, v.touches = l, v.startTouches = [...l], v.longPressTimer && clearTimeout(v.longPressTimer), l.length === 1 && s.enabledGestures.includes("long-press") && (v.longPressTimer = setTimeout(() => {
1100
- if (v.touches.length === 1 && l[0]) {
1101
- const M = R("long-press", l[0], l[0]);
1102
- t(M), s.enableHapticFeedback && o("heavy");
1007
+ const d = Array.from(p.touches).map(m), v = a.current;
1008
+ v.isTracking = !0, v.touches = d, v.startTouches = [...d], v.longPressTimer && clearTimeout(v.longPressTimer), d.length === 1 && s.enabledGestures.includes("long-press") && (v.longPressTimer = setTimeout(() => {
1009
+ if (v.touches.length === 1 && d[0]) {
1010
+ const L = D("long-press", d[0], d[0]);
1011
+ t(L), s.enableHapticFeedback && o("heavy");
1103
1012
  }
1104
- }, s.longPressThreshold)), l.length === 2 && l[0] && l[1] && (v.initialDistance = S(l[0], l[1]), v.initialScale = 1, v.lastScale = 1);
1013
+ }, s.longPressThreshold)), d.length === 2 && d[0] && d[1] && (v.initialDistance = S(d[0], d[1]), v.initialScale = 1, v.lastScale = 1);
1105
1014
  }, [s, t, o]), r = re.useCallback((p) => {
1106
- const l = a.current;
1107
- if (!l.isTracking) return;
1108
- const v = Array.from(p.touches).map(d);
1109
- if (l.touches = v, v.length === 2 && l.initialDistance && v[0] && v[1]) {
1110
- const M = S(v[0], v[1]), h = M / l.initialDistance;
1111
- if (Math.abs(h - (l.lastScale || 1)) > s.pinchThreshold) {
1112
- const T = h > (l.lastScale || 1) ? "pinch-out" : "pinch-in";
1015
+ const d = a.current;
1016
+ if (!d.isTracking) return;
1017
+ const v = Array.from(p.touches).map(m);
1018
+ if (d.touches = v, v.length === 2 && d.initialDistance && v[0] && v[1]) {
1019
+ const L = S(v[0], v[1]), h = L / d.initialDistance;
1020
+ if (Math.abs(h - (d.lastScale || 1)) > s.pinchThreshold) {
1021
+ const T = h > (d.lastScale || 1) ? "pinch-out" : "pinch-in";
1113
1022
  if (s.enabledGestures.includes(T)) {
1114
1023
  const E = {
1115
1024
  x: (v[0].x + v[1].x) / 2,
1116
1025
  y: (v[0].y + v[1].y) / 2,
1117
1026
  timestamp: Date.now()
1118
- }, b = {
1119
- x: ((l.startTouches[0]?.x ?? 0) + (l.startTouches[1]?.x ?? 0)) / 2,
1120
- y: ((l.startTouches[0]?.y ?? 0) + (l.startTouches[1]?.y ?? 0)) / 2,
1121
- timestamp: l.startTouches[0]?.timestamp ?? Date.now()
1122
- }, w = R(T, b, E, {
1027
+ }, w = {
1028
+ x: ((d.startTouches[0]?.x ?? 0) + (d.startTouches[1]?.x ?? 0)) / 2,
1029
+ y: ((d.startTouches[0]?.y ?? 0) + (d.startTouches[1]?.y ?? 0)) / 2,
1030
+ timestamp: d.startTouches[0]?.timestamp ?? Date.now()
1031
+ }, b = D(T, w, E, {
1123
1032
  scale: h,
1124
- distance: M
1033
+ distance: L
1125
1034
  });
1126
- t(w), l.lastScale = h;
1035
+ t(b), d.lastScale = h;
1127
1036
  }
1128
1037
  }
1129
1038
  }
1130
- if (l.longPressTimer && v.length === 1 && l.startTouches[0] && v[0]) {
1131
- const M = l.startTouches[0], h = v[0];
1132
- S(M, h) > s.swipeThreshold && (clearTimeout(l.longPressTimer), l.longPressTimer = void 0);
1039
+ if (d.longPressTimer && v.length === 1 && d.startTouches[0] && v[0]) {
1040
+ const L = d.startTouches[0], h = v[0];
1041
+ S(L, h) > s.swipeThreshold && (clearTimeout(d.longPressTimer), d.longPressTimer = void 0);
1133
1042
  }
1134
1043
  }, [s, t]), y = re.useCallback((p) => {
1135
- const l = a.current;
1136
- if (!l.isTracking) return;
1137
- const v = Array.from(p.changedTouches).map(d), M = Date.now();
1138
- if (l.longPressTimer && (clearTimeout(l.longPressTimer), l.longPressTimer = void 0), l.startTouches.length === 1 && v.length === 1 && l.startTouches[0] && v[0]) {
1139
- const h = l.startTouches[0], c = v[0], T = S(h, c), E = c.timestamp - h.timestamp;
1044
+ const d = a.current;
1045
+ if (!d.isTracking) return;
1046
+ const v = Array.from(p.changedTouches).map(m), L = Date.now();
1047
+ if (d.longPressTimer && (clearTimeout(d.longPressTimer), d.longPressTimer = void 0), d.startTouches.length === 1 && v.length === 1 && d.startTouches[0] && v[0]) {
1048
+ const h = d.startTouches[0], l = v[0], T = S(h, l), E = l.timestamp - h.timestamp;
1140
1049
  if (T > s.swipeThreshold) {
1141
- const b = D(h, c), w = Math.abs(b.x), m = Math.abs(b.y);
1142
- if (w > s.swipeVelocityThreshold || m > s.swipeVelocityThreshold) {
1143
- let z;
1144
- if (w > m ? z = b.x > 0 ? "swipe-right" : "swipe-left" : z = b.y > 0 ? "swipe-down" : "swipe-up", s.enabledGestures.includes(z)) {
1145
- const F = R(z, h, c, {
1146
- velocity: b,
1050
+ const w = F(h, l), b = Math.abs(w.x), f = Math.abs(w.y);
1051
+ if (b > s.swipeVelocityThreshold || f > s.swipeVelocityThreshold) {
1052
+ let G;
1053
+ if (b > f ? G = w.x > 0 ? "swipe-right" : "swipe-left" : G = w.y > 0 ? "swipe-down" : "swipe-up", s.enabledGestures.includes(G)) {
1054
+ const R = D(G, h, l, {
1055
+ velocity: w,
1147
1056
  distance: T
1148
1057
  });
1149
- t(F), s.enableHapticFeedback && o("light");
1058
+ t(R), s.enableHapticFeedback && o("light");
1150
1059
  }
1151
1060
  }
1152
1061
  } else if (E < s.tapThreshold && T < s.swipeThreshold)
1153
- if (l.lastTap && M - l.lastTap.timestamp < s.doubleTapThreshold && S({ ...l.lastTap.point }, c) < s.swipeThreshold) {
1062
+ if (d.lastTap && L - d.lastTap.timestamp < s.doubleTapThreshold && S({ ...d.lastTap.point }, l) < s.swipeThreshold) {
1154
1063
  if (s.enabledGestures.includes("double-tap")) {
1155
- const b = R("double-tap", h, c);
1156
- t(b), s.enableHapticFeedback && o("medium");
1064
+ const w = D("double-tap", h, l);
1065
+ t(w), s.enableHapticFeedback && o("medium");
1157
1066
  }
1158
- l.lastTap = void 0;
1067
+ d.lastTap = void 0;
1159
1068
  } else {
1160
1069
  if (s.enabledGestures.includes("tap")) {
1161
- const b = R("tap", h, c);
1162
- t(b), s.enableHapticFeedback && o("light");
1070
+ const w = D("tap", h, l);
1071
+ t(w), s.enableHapticFeedback && o("light");
1163
1072
  }
1164
- l.lastTap = {
1165
- timestamp: M,
1166
- point: { x: c.x, y: c.y }
1073
+ d.lastTap = {
1074
+ timestamp: L,
1075
+ point: { x: l.x, y: l.y }
1167
1076
  };
1168
1077
  }
1169
1078
  }
1170
- p.touches.length === 0 && (l.isTracking = !1, l.touches = [], l.startTouches = [], l.initialDistance = void 0, l.initialScale = void 0, l.lastScale = void 0);
1079
+ p.touches.length === 0 && (d.isTracking = !1, d.touches = [], d.startTouches = [], d.initialDistance = void 0, d.initialScale = void 0, d.lastScale = void 0);
1171
1080
  }, [s, t, o]);
1172
1081
  return re.useEffect(() => {
1173
1082
  const p = e.current;
@@ -1179,9 +1088,9 @@ function Fe(e, t, n = {}) {
1179
1088
  isGestureEnabled: u && s.enabledGestures.length > 0
1180
1089
  };
1181
1090
  }
1182
- function Ne(e, t) {
1091
+ function Be(e, t) {
1183
1092
  const n = re.useCallback((u) => {
1184
- const { type: o, distance: a, scale: d } = u;
1093
+ const { type: o, distance: a, scale: m } = u;
1185
1094
  switch (o) {
1186
1095
  case "double-tap":
1187
1096
  t.onPlayPause?.();
@@ -1191,41 +1100,41 @@ function Ne(e, t) {
1191
1100
  t.onSeek?.("backward", S);
1192
1101
  break;
1193
1102
  case "swipe-right":
1194
- const D = Math.min((a || 0) / 10, 30);
1195
- t.onSeek?.("forward", D);
1103
+ const F = Math.min((a || 0) / 10, 30);
1104
+ t.onSeek?.("forward", F);
1196
1105
  break;
1197
1106
  case "swipe-up":
1198
1107
  if (u.startPoint.x > (e.current?.clientWidth || 0) / 2) {
1199
- const R = Math.min((a || 0) / 100, 0.2);
1200
- t.onVolumeChange?.("up", R);
1108
+ const D = Math.min((a || 0) / 100, 0.2);
1109
+ t.onVolumeChange?.("up", D);
1201
1110
  }
1202
1111
  break;
1203
1112
  case "swipe-down":
1204
1113
  if (u.startPoint.x > (e.current?.clientWidth || 0) / 2) {
1205
- const R = Math.min((a || 0) / 100, 0.2);
1206
- t.onVolumeChange?.("down", R);
1114
+ const D = Math.min((a || 0) / 100, 0.2);
1115
+ t.onVolumeChange?.("down", D);
1207
1116
  }
1208
1117
  break;
1209
1118
  case "pinch-out":
1210
- t.onZoom?.(d || 1);
1119
+ t.onZoom?.(m || 1);
1211
1120
  break;
1212
1121
  case "pinch-in":
1213
- t.onZoom?.(d || 1);
1122
+ t.onZoom?.(m || 1);
1214
1123
  break;
1215
1124
  case "long-press":
1216
1125
  t.onToggleFullscreen?.();
1217
1126
  break;
1218
1127
  }
1219
1128
  }, [t, e]);
1220
- return Fe(e, n, {
1129
+ return Pe(e, n, {
1221
1130
  enabledGestures: ["tap", "double-tap", "long-press", "swipe-left", "swipe-right", "swipe-up", "swipe-down", "pinch-in", "pinch-out"],
1222
1131
  enableHapticFeedback: !0,
1223
1132
  swipeThreshold: 30,
1224
1133
  swipeVelocityThreshold: 0.3
1225
1134
  });
1226
1135
  }
1227
- function He(e) {
1228
- const t = W(null), [n, s] = Q({
1136
+ function Ne(e) {
1137
+ const t = z(null), [n, s] = Y({
1229
1138
  isPlaying: !1,
1230
1139
  currentTime: 0,
1231
1140
  duration: 0,
@@ -1237,55 +1146,55 @@ function He(e) {
1237
1146
  isBuffering: !1,
1238
1147
  bufferedRanges: []
1239
1148
  });
1240
- return q(() => {
1149
+ return j(() => {
1241
1150
  const r = t.current;
1242
1151
  if (!r) return;
1243
1152
  const y = () => {
1244
- s((F) => ({ ...F, currentTime: r.currentTime }));
1153
+ s((R) => ({ ...R, currentTime: r.currentTime }));
1245
1154
  }, p = () => {
1246
- s((F) => ({ ...F, duration: r.duration }));
1247
- }, l = () => {
1248
- s((F) => ({ ...F, isPlaying: !0, isBuffering: !1 }));
1155
+ s((R) => ({ ...R, duration: r.duration }));
1156
+ }, d = () => {
1157
+ s((R) => ({ ...R, isPlaying: !0, isBuffering: !1 }));
1249
1158
  }, v = () => {
1250
- s((F) => ({ ...F, isPlaying: !1 }));
1251
- }, M = () => {
1252
- s((F) => ({
1253
- ...F,
1159
+ s((R) => ({ ...R, isPlaying: !1 }));
1160
+ }, L = () => {
1161
+ s((R) => ({
1162
+ ...R,
1254
1163
  volume: r.volume,
1255
1164
  isMuted: r.muted
1256
1165
  }));
1257
1166
  }, h = () => {
1258
- s((F) => ({ ...F, isLoading: !0 }));
1259
- }, c = () => {
1260
- s((F) => ({ ...F, isLoading: !1 }));
1167
+ s((R) => ({ ...R, isLoading: !0 }));
1168
+ }, l = () => {
1169
+ s((R) => ({ ...R, isLoading: !1 }));
1261
1170
  }, T = () => {
1262
- s((F) => ({ ...F, isSeeking: !0 }));
1171
+ s((R) => ({ ...R, isSeeking: !0 }));
1263
1172
  }, E = () => {
1264
- s((F) => ({ ...F, isSeeking: !1 }));
1265
- }, b = () => {
1266
- s((F) => ({ ...F, isBuffering: !0 }));
1173
+ s((R) => ({ ...R, isSeeking: !1 }));
1267
1174
  }, w = () => {
1268
- s((F) => ({ ...F, isBuffering: !1, isLoading: !1 }));
1269
- }, m = () => {
1270
- s((F) => ({ ...F, isLoading: !1, isBuffering: !1 }));
1271
- }, z = () => {
1175
+ s((R) => ({ ...R, isBuffering: !0 }));
1176
+ }, b = () => {
1177
+ s((R) => ({ ...R, isBuffering: !1, isLoading: !1 }));
1178
+ }, f = () => {
1179
+ s((R) => ({ ...R, isLoading: !1, isBuffering: !1 }));
1180
+ }, G = () => {
1272
1181
  if (!r.buffered || r.buffered.length === 0 || r.duration === 0) {
1273
- s((O) => ({ ...O, bufferedRanges: [] }));
1182
+ s((I) => ({ ...I, bufferedRanges: [] }));
1274
1183
  return;
1275
1184
  }
1276
- const F = [];
1277
- for (let O = 0; O < r.buffered.length; O++) {
1278
- const P = r.buffered.start(O), L = r.buffered.end(O);
1279
- F.push({
1185
+ const R = [];
1186
+ for (let I = 0; I < r.buffered.length; I++) {
1187
+ const P = r.buffered.start(I), M = r.buffered.end(I);
1188
+ R.push({
1280
1189
  start: P,
1281
- end: L,
1282
- percentage: (L - P) / r.duration * 100
1190
+ end: M,
1191
+ percentage: (M - P) / r.duration * 100
1283
1192
  });
1284
1193
  }
1285
- s((O) => ({ ...O, bufferedRanges: F }));
1194
+ s((I) => ({ ...I, bufferedRanges: R }));
1286
1195
  };
1287
- return r.addEventListener("timeupdate", y), r.addEventListener("loadedmetadata", p), r.addEventListener("play", l), r.addEventListener("pause", v), r.addEventListener("volumechange", M), r.addEventListener("loadstart", h), r.addEventListener("loadeddata", c), r.addEventListener("seeking", T), r.addEventListener("seeked", E), r.addEventListener("waiting", b), r.addEventListener("playing", w), r.addEventListener("canplay", m), r.addEventListener("progress", z), () => {
1288
- r.removeEventListener("timeupdate", y), r.removeEventListener("loadedmetadata", p), r.removeEventListener("play", l), r.removeEventListener("pause", v), r.removeEventListener("volumechange", M), r.removeEventListener("loadstart", h), r.removeEventListener("loadeddata", c), r.removeEventListener("seeking", T), r.removeEventListener("seeked", E), r.removeEventListener("waiting", b), r.removeEventListener("playing", w), r.removeEventListener("canplay", m), r.removeEventListener("progress", z);
1196
+ return r.addEventListener("timeupdate", y), r.addEventListener("loadedmetadata", p), r.addEventListener("play", d), r.addEventListener("pause", v), r.addEventListener("volumechange", L), r.addEventListener("loadstart", h), r.addEventListener("loadeddata", l), r.addEventListener("seeking", T), r.addEventListener("seeked", E), r.addEventListener("waiting", w), r.addEventListener("playing", b), r.addEventListener("canplay", f), r.addEventListener("progress", G), () => {
1197
+ r.removeEventListener("timeupdate", y), r.removeEventListener("loadedmetadata", p), r.removeEventListener("play", d), r.removeEventListener("pause", v), r.removeEventListener("volumechange", L), r.removeEventListener("loadstart", h), r.removeEventListener("loadeddata", l), r.removeEventListener("seeking", T), r.removeEventListener("seeked", E), r.removeEventListener("waiting", w), r.removeEventListener("playing", b), r.removeEventListener("canplay", f), r.removeEventListener("progress", G);
1289
1198
  };
1290
1199
  }, []), {
1291
1200
  videoRef: t,
@@ -1322,144 +1231,144 @@ function He(e) {
1322
1231
  }
1323
1232
  };
1324
1233
  }
1325
- function De({
1234
+ function Fe({
1326
1235
  subtitleSrc: e,
1327
1236
  subtitleTracks: t = [],
1328
1237
  defaultFontSize: n = "medium",
1329
1238
  onLoadError: s
1330
1239
  } = {}) {
1331
- const [u, o] = Q(!1), [a, d] = Q([]), [S, D] = Q(""), [R, g] = Q(null), [r, y] = Q(n), [p, l] = Q(null), [v, M] = Q(!1), h = {
1240
+ const [u, o] = Y(!1), [a, m] = Y([]), [S, F] = Y(""), [D, g] = Y(null), [r, y] = Y(n), [p, d] = Y(null), [v, L] = Y(!1), h = {
1332
1241
  small: "text-sm",
1333
1242
  medium: "text-base",
1334
1243
  large: "text-lg"
1335
- }, c = !!(e || t && t.length > 0), T = (P) => {
1336
- const L = P.split(":"), I = L[2] ? parseFloat(L[2]) : 0, U = L[1] ? parseInt(L[1], 10) * 60 : 0;
1337
- return (L[0] ? parseInt(L[0], 10) * 3600 : 0) + U + I;
1244
+ }, l = !!(e || t && t.length > 0), T = (P) => {
1245
+ const M = P.split(":"), C = M[2] ? parseFloat(M[2]) : 0, O = M[1] ? parseInt(M[1], 10) * 60 : 0;
1246
+ return (M[0] ? parseInt(M[0], 10) * 3600 : 0) + O + C;
1338
1247
  }, E = (P) => {
1339
- const [L, I] = P.split(","), U = (L || "").split(":"), _ = I ? parseInt(I, 10) / 1e3 : 0, C = U[2] ? parseInt(U[2], 10) : 0, ee = U[1] ? parseInt(U[1], 10) * 60 : 0;
1340
- return (U[0] ? parseInt(U[0], 10) * 3600 : 0) + ee + C + _;
1341
- }, b = async (P) => {
1342
- M(!0), l(null);
1248
+ const [M, C] = P.split(","), O = (M || "").split(":"), U = C ? parseInt(C, 10) / 1e3 : 0, c = O[2] ? parseInt(O[2], 10) : 0, _ = O[1] ? parseInt(O[1], 10) * 60 : 0;
1249
+ return (O[0] ? parseInt(O[0], 10) * 3600 : 0) + _ + c + U;
1250
+ }, w = async (P) => {
1251
+ L(!0), d(null);
1343
1252
  try {
1344
- const L = await fetch(P);
1345
- if (!L.ok)
1346
- throw new Error(`Failed to load subtitles: ${L.status} ${L.statusText}`);
1347
- const I = await L.text(), U = [], _ = I.split(`
1253
+ const M = await fetch(P);
1254
+ if (!M.ok)
1255
+ throw new Error(`Failed to load subtitles: ${M.status} ${M.statusText}`);
1256
+ const C = await M.text(), O = [], U = C.split(`
1348
1257
  `);
1349
- let C = 0;
1350
- const ee = I.includes("WEBVTT") || P.endsWith(".vtt"), f = P.endsWith(".srt") || /^\d+$/.test(_[0]?.trim() || "");
1351
- if (ee)
1352
- for (; C < _.length; ) {
1353
- if (_[C]?.includes("-->")) {
1354
- const [V, se] = (_[C] || "").split("-->").map((B) => B.trim()), ae = T(V || ""), i = T(se || "");
1355
- C++;
1258
+ let c = 0;
1259
+ const _ = C.includes("WEBVTT") || P.endsWith(".vtt"), ee = P.endsWith(".srt") || /^\d+$/.test(U[0]?.trim() || "");
1260
+ if (_)
1261
+ for (; c < U.length; ) {
1262
+ if (U[c]?.includes("-->")) {
1263
+ const [Q, se] = (U[c] || "").split("-->").map((V) => V.trim()), ae = T(Q || ""), i = T(se || "");
1264
+ c++;
1356
1265
  let k = "";
1357
- for (; C < _.length && _[C]?.trim() !== ""; )
1358
- k += (k ? " " : "") + _[C]?.trim(), C++;
1359
- k && U.push({ start: ae, end: i, text: k });
1266
+ for (; c < U.length && U[c]?.trim() !== ""; )
1267
+ k += (k ? " " : "") + U[c]?.trim(), c++;
1268
+ k && O.push({ start: ae, end: i, text: k });
1360
1269
  }
1361
- C++;
1270
+ c++;
1362
1271
  }
1363
- else if (f)
1364
- for (; C < _.length; ) {
1365
- if (/^\d+$/.test(_[C]?.trim() || "") && (C++, _[C]?.includes("-->"))) {
1366
- const [V, se] = (_[C] || "").split("-->").map((B) => B.trim()), ae = E(V || ""), i = E(se || "");
1367
- C++;
1272
+ else if (ee)
1273
+ for (; c < U.length; ) {
1274
+ if (/^\d+$/.test(U[c]?.trim() || "") && (c++, U[c]?.includes("-->"))) {
1275
+ const [Q, se] = (U[c] || "").split("-->").map((V) => V.trim()), ae = E(Q || ""), i = E(se || "");
1276
+ c++;
1368
1277
  let k = "";
1369
- for (; C < _.length && _[C]?.trim() !== ""; )
1370
- k += (k ? " " : "") + _[C]?.trim(), C++;
1371
- k && U.push({ start: ae, end: i, text: k });
1278
+ for (; c < U.length && U[c]?.trim() !== ""; )
1279
+ k += (k ? " " : "") + U[c]?.trim(), c++;
1280
+ k && O.push({ start: ae, end: i, text: k });
1372
1281
  }
1373
- C++;
1282
+ c++;
1374
1283
  }
1375
1284
  else
1376
1285
  throw new Error("Unsupported subtitle format. Only VTT and SRT are supported.");
1377
- if (U.length === 0)
1286
+ if (O.length === 0)
1378
1287
  throw new Error("No subtitle cues found in file");
1379
- d(U), M(!1);
1380
- } catch (L) {
1381
- const I = L instanceof Error ? L : new Error("Failed to load subtitles");
1382
- console.error("Failed to load subtitles:", I), l(I), M(!1), d([]), s?.(I);
1288
+ m(O), L(!1);
1289
+ } catch (M) {
1290
+ const C = M instanceof Error ? M : new Error("Failed to load subtitles");
1291
+ console.error("Failed to load subtitles:", C), d(C), L(!1), m([]), s?.(C);
1383
1292
  }
1384
- }, w = (P) => !u || a.length === 0 ? "" : a.find(
1385
- (I) => P >= I.start && P <= I.end
1386
- )?.text || "", m = () => {
1293
+ }, b = (P) => !u || a.length === 0 ? "" : a.find(
1294
+ (C) => P >= C.start && P <= C.end
1295
+ )?.text || "", f = () => {
1387
1296
  o((P) => {
1388
- const L = !P;
1389
- if (L && !p) {
1297
+ const M = !P;
1298
+ if (M && !p) {
1390
1299
  if (a.length === 0 && !v) {
1391
- const I = e || t[0]?.src;
1392
- I && (b(I), t[0] && g(t[0].id));
1300
+ const C = e || t[0]?.src;
1301
+ C && (w(C), t[0] && g(t[0].id));
1393
1302
  }
1394
- } else L || D("");
1395
- return L;
1303
+ } else M || F("");
1304
+ return M;
1396
1305
  });
1397
- }, z = (P) => {
1306
+ }, G = (P) => {
1398
1307
  if (!P) {
1399
- o(!1), g(null), D("");
1308
+ o(!1), g(null), F("");
1400
1309
  return;
1401
1310
  }
1402
- const L = t.find((I) => I.id === P);
1403
- L?.src && (g(P), b(L.src), o(!0));
1404
- }, F = (P) => {
1311
+ const M = t.find((C) => C.id === P);
1312
+ M?.src && (g(P), w(M.src), o(!0));
1313
+ }, R = (P) => {
1405
1314
  y(P);
1406
- }, O = {
1315
+ }, I = {
1407
1316
  fontSize: h[r],
1408
1317
  className: `${h[r]} font-medium`
1409
1318
  };
1410
- return q(() => {
1411
- u || D("");
1412
- }, [u]), q(() => {
1319
+ return j(() => {
1320
+ u || F("");
1321
+ }, [u]), j(() => {
1413
1322
  }, []), {
1414
1323
  // State
1415
1324
  subtitlesEnabled: u,
1416
1325
  currentSubtitle: S,
1417
1326
  subtitleCues: a,
1418
- currentTrackId: R,
1327
+ currentTrackId: D,
1419
1328
  fontSize: r,
1420
1329
  loadError: p,
1421
1330
  isLoading: v,
1422
- hasSubtitles: c,
1331
+ hasSubtitles: l,
1423
1332
  // Actions
1424
- toggleSubtitles: m,
1425
- selectSubtitleTrack: z,
1426
- changeSubtitleFontSize: F,
1427
- setCurrentSubtitle: D,
1333
+ toggleSubtitles: f,
1334
+ selectSubtitleTrack: G,
1335
+ changeSubtitleFontSize: R,
1336
+ setCurrentSubtitle: F,
1428
1337
  // Utilities
1429
- getCurrentSubtitle: w,
1430
- getSubtitleStyles: O,
1338
+ getCurrentSubtitle: b,
1339
+ getSubtitleStyles: I,
1431
1340
  // Track info
1432
1341
  availableTracks: t
1433
1342
  };
1434
1343
  }
1435
- const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1344
+ const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1436
1345
  __proto__: null,
1437
- useEnhancedSubtitles: De
1346
+ useEnhancedSubtitles: Fe
1438
1347
  }, Symbol.toStringTag, { value: "Module" }));
1439
- function $e(e, t) {
1440
- const [n, s] = Q(!0), [u, o] = Q(!1), a = W(null), d = () => {
1348
+ function Ke(e, t) {
1349
+ const [n, s] = Y(!0), [u, o] = Y(!1), a = z(null), m = () => {
1441
1350
  s(!0), a.current && clearTimeout(a.current), e && !t && (a.current = setTimeout(() => {
1442
1351
  s(!1);
1443
1352
  }, 3e3));
1444
1353
  }, S = () => {
1445
- d();
1446
- }, D = () => {
1354
+ m();
1355
+ }, F = () => {
1447
1356
  s(!0);
1448
- }, R = () => {
1357
+ }, D = () => {
1449
1358
  e && s(!1);
1450
1359
  };
1451
- return q(() => (d(), () => {
1360
+ return j(() => (m(), () => {
1452
1361
  a.current && clearTimeout(a.current);
1453
- }), [d]), {
1362
+ }), [m]), {
1454
1363
  controlsVisible: n,
1455
1364
  showVolumeSlider: u,
1456
1365
  setShowVolumeSlider: o,
1457
1366
  handleMouseMove: S,
1458
- handleMouseEnter: D,
1459
- handleMouseLeave: R
1367
+ handleMouseEnter: F,
1368
+ handleMouseLeave: D
1460
1369
  };
1461
1370
  }
1462
- function Ge({
1371
+ function $e({
1463
1372
  videoControls: e,
1464
1373
  toggleSubtitles: t,
1465
1374
  takeScreenshot: n,
@@ -1505,9 +1414,9 @@ function Ge({
1505
1414
  break;
1506
1415
  }
1507
1416
  };
1508
- q(() => (document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u)), [u]);
1417
+ j(() => (document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u)), [u]);
1509
1418
  }
1510
- function ze(e) {
1419
+ function Ge(e) {
1511
1420
  return { takeScreenshot: (n = !1) => {
1512
1421
  if (!e.current) return;
1513
1422
  const s = e.current, u = document.createElement("canvas");
@@ -1522,15 +1431,15 @@ function ze(e) {
1522
1431
  }
1523
1432
  if (n)
1524
1433
  if (navigator.clipboard && window.ClipboardItem) {
1525
- const d = new ClipboardItem({ "image/png": a });
1526
- navigator.clipboard.write([d]).catch((S) => {
1434
+ const m = new ClipboardItem({ "image/png": a });
1435
+ navigator.clipboard.write([m]).catch((S) => {
1527
1436
  console.error("Failed to copy to clipboard:", S);
1528
1437
  });
1529
1438
  } else
1530
1439
  console.warn("Clipboard API not supported");
1531
1440
  else {
1532
- const d = URL.createObjectURL(a), S = document.createElement("a");
1533
- S.href = d, S.download = `screenshot-${Date.now()}.png`, S.click(), URL.revokeObjectURL(d);
1441
+ const m = URL.createObjectURL(a), S = document.createElement("a");
1442
+ S.href = m, S.download = `screenshot-${Date.now()}.png`, S.click(), URL.revokeObjectURL(m);
1534
1443
  }
1535
1444
  }, "image/png");
1536
1445
  } catch (a) {
@@ -1538,18 +1447,147 @@ function ze(e) {
1538
1447
  }
1539
1448
  } };
1540
1449
  }
1541
- function We(e) {
1542
- const t = W(null), n = W(null), [s, u] = le(), [o, a] = le();
1543
- N.useRef(0);
1544
- const d = N.useRef(0), S = N.useRef(0);
1545
- W(void 0);
1546
- const D = W(0), R = pe(), g = "getOptimisticState" in R, r = j((i) => i.isPlaying), y = j((i) => i.currentTime), p = j((i) => i.duration), l = j((i) => i.volume), v = j((i) => i.isMuted), M = j((i) => i.isLoading), h = j((i) => i.isBuffering), c = j((i) => i.error), T = j((i) => i.buffered), E = j((i) => i.isFullscreen), b = R, w = g ? Ee(b) : null, m = g ? Te(b) : null, [z, F] = N.useState({
1450
+ function $(e, t) {
1451
+ return ((n, s = !1) => {
1452
+ const u = {
1453
+ type: e,
1454
+ detail: n,
1455
+ optimistic: s,
1456
+ timestamp: Date.now()
1457
+ };
1458
+ return s ? t.dispatchOptimistic(u) : (t.dispatch(u), Promise.resolve());
1459
+ });
1460
+ }
1461
+ function De(e) {
1462
+ const [t, n] = B.useState(e.getActionState());
1463
+ return B.useEffect(() => e.subscribe(() => {
1464
+ const u = e.getActionState();
1465
+ n(
1466
+ (o) => JSON.stringify(o) !== JSON.stringify(u) ? u : o
1467
+ );
1468
+ }), [e]), t;
1469
+ }
1470
+ function ze(e) {
1471
+ const t = B.useMemo(() => ({
1472
+ // Playback actions
1473
+ play: $(H.PLAY, e),
1474
+ pause: $(H.PAUSE, e),
1475
+ seek: $(H.SEEK, e),
1476
+ // Volume actions
1477
+ setVolume: $(H.SET_VOLUME, e),
1478
+ mute: $(H.MUTE, e),
1479
+ unmute: $(H.UNMUTE, e),
1480
+ toggleMute: $(H.TOGGLE_MUTE, e),
1481
+ // Media state actions
1482
+ setDuration: $(H.SET_DURATION, e),
1483
+ setCurrentTime: $(H.SET_CURRENT_TIME, e),
1484
+ setBuffered: $(H.SET_BUFFERED, e),
1485
+ setLoading: $(H.SET_LOADING, e),
1486
+ setError: $(H.SET_ERROR, e),
1487
+ // Display actions
1488
+ enterFullscreen: $(H.ENTER_FULLSCREEN, e),
1489
+ exitFullscreen: $(H.EXIT_FULLSCREEN, e),
1490
+ enterPiP: $(H.ENTER_PIP, e),
1491
+ exitPiP: $(H.EXIT_PIP, e),
1492
+ // Advanced actions
1493
+ setPlaybackRate: $(H.SET_PLAYBACK_RATE, e),
1494
+ setSubtitleTrack: $(H.SET_SUBTITLE_TRACK, e),
1495
+ setRendition: $(H.SET_RENDITION, e),
1496
+ toggleSubtitles: $(H.TOGGLE_SUBTITLES, e),
1497
+ // Preview actions
1498
+ previewTime: $(H.PREVIEW_TIME, e),
1499
+ clearPreview: $(H.CLEAR_PREVIEW, e)
1500
+ }), [e]), n = De(e), s = B.useMemo(() => ({
1501
+ // These actions benefit from immediate UI feedback
1502
+ togglePlayPause: async (o) => {
1503
+ o ? await t.pause(!0) : await t.play(!0);
1504
+ },
1505
+ seekWithPreview: async (o) => {
1506
+ await t.previewTime(o, !0), await t.seek(o, !0);
1507
+ },
1508
+ adjustVolume: async (o, a) => {
1509
+ const m = Math.max(0, Math.min(1, a + o));
1510
+ await t.setVolume(m, !0);
1511
+ },
1512
+ toggleFullscreenOptimistic: async (o) => {
1513
+ o ? await t.exitFullscreen(!0) : await t.enterFullscreen(!0);
1514
+ }
1515
+ }), [t]), u = B.useCallback(async () => {
1516
+ const { lastAction: o } = n;
1517
+ o && n.error && await e.dispatchOptimistic({
1518
+ ...o,
1519
+ retryCount: (o.retryCount || 0) + 1
1520
+ });
1521
+ }, [e, n]);
1522
+ return {
1523
+ ...t,
1524
+ ...s,
1525
+ actionState: n,
1526
+ retryLastAction: u,
1527
+ isLoading: n.pending,
1528
+ hasError: !!n.error,
1529
+ errorMessage: n.error,
1530
+ retryCount: n.retryCount
1531
+ };
1532
+ }
1533
+ function We() {
1534
+ const [e, t] = Y({
1535
+ isPlaying: !1,
1536
+ currentTime: 0,
1537
+ duration: 0,
1538
+ volume: 1,
1539
+ isMuted: !1,
1540
+ isLoading: !1,
1541
+ isFullscreen: !1,
1542
+ error: null,
1543
+ buffered: null
1544
+ }), n = (r) => {
1545
+ t((y) => ({ ...y, ...r }));
1546
+ };
1547
+ return {
1548
+ state: e,
1549
+ updateState: n,
1550
+ setPlaying: (r) => {
1551
+ n({ isPlaying: r });
1552
+ },
1553
+ setCurrentTime: (r) => {
1554
+ n({ currentTime: r });
1555
+ },
1556
+ setDuration: (r) => {
1557
+ n({ duration: r });
1558
+ },
1559
+ setVolume: (r) => {
1560
+ n({ volume: Math.max(0, Math.min(1, r)) });
1561
+ },
1562
+ setMuted: (r) => {
1563
+ n({ isMuted: r });
1564
+ },
1565
+ setLoading: (r) => {
1566
+ n({ isLoading: r });
1567
+ },
1568
+ setFullscreen: (r) => {
1569
+ n({ isFullscreen: r });
1570
+ },
1571
+ setError: (r) => {
1572
+ n({ error: r });
1573
+ },
1574
+ setBuffered: (r) => {
1575
+ n({ buffered: r });
1576
+ }
1577
+ };
1578
+ }
1579
+ function je(e) {
1580
+ const t = z(null), n = z(null), [s, u] = le(), [o, a] = le();
1581
+ B.useRef(0);
1582
+ const m = B.useRef(0), S = B.useRef(0);
1583
+ z(void 0);
1584
+ const F = z(0), D = pe(), g = "getOptimisticState" in D, r = W((i) => i.isPlaying), y = W((i) => i.currentTime), p = W((i) => i.duration), d = W((i) => i.volume), v = W((i) => i.isMuted), L = W((i) => i.isLoading), h = W((i) => i.isBuffering), l = W((i) => i.error), T = W((i) => i.buffered), E = W((i) => i.isFullscreen), w = D, b = g ? Ee(w) : null, f = g ? Te(w) : null, [G, R] = B.useState({
1547
1585
  frameRate: 0,
1548
1586
  averageRenderTime: 0,
1549
1587
  droppedFrames: 0,
1550
1588
  bufferHealth: 0
1551
- }), [O, P] = ce(l, (i, k) => Math.max(0, Math.min(1, k)));
1552
- ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))), q(() => {
1589
+ }), [I, P] = ce(d, (i, k) => Math.max(0, Math.min(1, k)));
1590
+ ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))), j(() => {
1553
1591
  const i = t.current;
1554
1592
  if (!i) return;
1555
1593
  const k = {
@@ -1560,8 +1598,8 @@ function We(e) {
1560
1598
  preload: e.preload,
1561
1599
  crossOrigin: e.crossOrigin
1562
1600
  };
1563
- Object.entries(k).forEach(([B, Y]) => {
1564
- Y !== void 0 && (i[B] = Y);
1601
+ Object.entries(k).forEach(([V, X]) => {
1602
+ X !== void 0 && (i[V] = X);
1565
1603
  }), i.setAttribute("preload", e.preloadStrategy === "eager" ? "auto" : "metadata"), e.bufferingStrategy === "aggressive" && i.setAttribute("buffered", "auto"), i instanceof HTMLVideoElement && (i.style.willChange = "transform", i.style.transform = "translateZ(0)");
1566
1604
  }, [
1567
1605
  e.volume,
@@ -1573,135 +1611,135 @@ function We(e) {
1573
1611
  e.preloadStrategy,
1574
1612
  e.bufferingStrategy
1575
1613
  ]);
1576
- const L = A(() => {
1614
+ const M = A(() => {
1577
1615
  const i = t.current;
1578
1616
  if (!i) return;
1579
1617
  const k = performance.now();
1580
1618
  if (e.enableTimeUpdateThrottling !== !1) {
1581
- if (k - D.current < (e.timeUpdateThrottleMs || 100))
1619
+ if (k - F.current < (e.timeUpdateThrottleMs || 100))
1582
1620
  return;
1583
- D.current = k;
1621
+ F.current = k;
1584
1622
  }
1585
1623
  u(() => {
1586
- g && m && m.setCurrentTime(i.currentTime);
1624
+ g && f && f.setCurrentTime(i.currentTime);
1587
1625
  });
1588
- }, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g, m]), I = A(() => {
1626
+ }, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g, f]), C = A(() => {
1589
1627
  u(() => {
1590
- g && m && m.play(!0);
1628
+ g && f && f.play(!0);
1591
1629
  }), e.onPlay?.();
1592
- }, [g, m, e.onPlay]), U = A(() => {
1630
+ }, [g, f, e.onPlay]), O = A(() => {
1593
1631
  u(() => {
1594
- g && m && m.pause(!0);
1632
+ g && f && f.pause(!0);
1595
1633
  }), e.onPause?.();
1596
- }, [g, m, e.onPause]), _ = A(() => {
1634
+ }, [g, f, e.onPause]), U = A(() => {
1597
1635
  const i = t.current;
1598
1636
  i && u(() => {
1599
- g && m && (m.setVolume(i.volume, !0), i.muted ? m.mute(!0) : m.unmute(!0));
1637
+ g && f && (f.setVolume(i.volume, !0), i.muted ? f.mute(!0) : f.unmute(!0));
1600
1638
  });
1601
- }, [g, m]), C = A(() => {
1639
+ }, [g, f]), c = A(() => {
1602
1640
  a(() => {
1603
1641
  });
1642
+ }, []), _ = A(() => {
1604
1643
  }, []), ee = A(() => {
1605
- }, []), f = A(() => {
1606
1644
  const i = t.current;
1607
1645
  i && u(() => {
1608
- g && m && m.setBuffered(i.buffered);
1646
+ g && f && f.setBuffered(i.buffered);
1609
1647
  });
1610
- }, [g, m]), V = A(() => {
1648
+ }, [g, f]), Q = A(() => {
1611
1649
  const i = performance.now();
1612
- if (i - S.current > 0 && (d.current++, d.current >= 60)) {
1613
- const B = Math.round(d.current * 1e3 / (i - S.current));
1614
- F((Y) => ({
1615
- ...Y,
1616
- frameRate: B,
1617
- droppedFrames: Math.max(0, 60 - B)
1618
- })), d.current = 0, S.current = i;
1650
+ if (i - S.current > 0 && (m.current++, m.current >= 60)) {
1651
+ const V = Math.round(m.current * 1e3 / (i - S.current));
1652
+ R((X) => ({
1653
+ ...X,
1654
+ frameRate: V,
1655
+ droppedFrames: Math.max(0, 60 - V)
1656
+ })), m.current = 0, S.current = i;
1619
1657
  }
1620
1658
  }, []);
1621
- q(() => {
1659
+ j(() => {
1622
1660
  const i = t.current;
1623
1661
  if (!i) return;
1624
1662
  const k = [
1625
- { event: "timeupdate", handler: L, passive: !0 },
1626
- { event: "play", handler: I },
1627
- { event: "pause", handler: U },
1628
- { event: "volumechange", handler: _ },
1629
- { event: "seeking", handler: C },
1630
- { event: "seeked", handler: ee },
1631
- { event: "progress", handler: f, passive: !0 },
1632
- { event: "loadedmetadata", handler: () => V() },
1633
- { event: "loadeddata", handler: () => V() }
1663
+ { event: "timeupdate", handler: M, passive: !0 },
1664
+ { event: "play", handler: C },
1665
+ { event: "pause", handler: O },
1666
+ { event: "volumechange", handler: U },
1667
+ { event: "seeking", handler: c },
1668
+ { event: "seeked", handler: _ },
1669
+ { event: "progress", handler: ee, passive: !0 },
1670
+ { event: "loadedmetadata", handler: () => Q() },
1671
+ { event: "loadeddata", handler: () => Q() }
1634
1672
  ];
1635
1673
  k.forEach(({ event: te, handler: ne, passive: ie }) => {
1636
1674
  const oe = ie ? { passive: !0 } : {};
1637
1675
  i.addEventListener(te, ne, oe);
1638
1676
  });
1639
- let B;
1640
- const Y = () => {
1641
- V(), B = requestAnimationFrame(Y);
1677
+ let V;
1678
+ const X = () => {
1679
+ Q(), V = requestAnimationFrame(X);
1642
1680
  };
1643
- return e.enablePerformanceMonitoring && Y(), () => {
1681
+ return e.enablePerformanceMonitoring && X(), () => {
1644
1682
  k.forEach(({ event: te, handler: ne }) => {
1645
1683
  i.removeEventListener(te, ne);
1646
- }), B && cancelAnimationFrame(B);
1684
+ }), V && cancelAnimationFrame(V);
1647
1685
  };
1648
1686
  }, [
1649
- L,
1650
- I,
1687
+ M,
1688
+ C,
1689
+ O,
1651
1690
  U,
1691
+ c,
1652
1692
  _,
1653
- C,
1654
1693
  ee,
1655
- f,
1656
- V,
1694
+ Q,
1657
1695
  e.enablePerformanceMonitoring
1658
1696
  ]);
1659
1697
  const se = ue(() => {
1660
1698
  const i = async () => {
1661
1699
  const x = t.current;
1662
1700
  if (x)
1663
- if (g && m)
1664
- await m.play(!0);
1701
+ if (g && f)
1702
+ await f.play(!0);
1665
1703
  else
1666
1704
  try {
1667
1705
  await x.play();
1668
- } catch (X) {
1669
- console.error("Failed to play media:", X);
1706
+ } catch (q) {
1707
+ console.error("Failed to play media:", q);
1670
1708
  }
1671
1709
  }, k = () => {
1672
1710
  const x = t.current;
1673
- x && (g && m ? m.pause(!0) : x.pause());
1674
- }, B = () => {
1711
+ x && (g && f ? f.pause(!0) : x.pause());
1712
+ }, V = () => {
1675
1713
  r ? k() : i();
1676
- }, Y = (x) => {
1677
- const X = t.current;
1678
- if (!X) return;
1714
+ }, X = (x) => {
1715
+ const q = t.current;
1716
+ if (!q) return;
1679
1717
  const Z = Math.max(0, Math.min(x, p || 0));
1680
- g && m ? a(() => {
1681
- m.seek(Z, !0);
1682
- }) : X.currentTime = Z;
1718
+ g && f ? a(() => {
1719
+ f.seek(Z, !0);
1720
+ }) : q.currentTime = Z;
1683
1721
  }, te = (x) => {
1684
- const X = t.current;
1685
- if (!X) return;
1722
+ const q = t.current;
1723
+ if (!q) return;
1686
1724
  const Z = Math.max(0, Math.min(1, x));
1687
- g && m ? (P(Z), u(() => {
1688
- m.setVolume(Z, !0);
1689
- })) : X.volume = Z;
1725
+ g && f ? (P(Z), u(() => {
1726
+ f.setVolume(Z, !0);
1727
+ })) : q.volume = Z;
1690
1728
  }, ne = () => {
1691
1729
  const x = t.current;
1692
- x && (g && m ? m.toggleMute(!0) : x.muted = !x.muted);
1730
+ x && (g && f ? f.toggleMute(!0) : x.muted = !x.muted);
1693
1731
  }, ie = async () => {
1694
1732
  const x = n.current;
1695
1733
  if (!(!x || !document.fullscreenEnabled))
1696
1734
  try {
1697
- await x.requestFullscreen(), g && m && m.enterFullscreen(!0);
1698
- } catch (X) {
1699
- console.error("Failed to enter fullscreen:", X);
1735
+ await x.requestFullscreen(), g && f && f.enterFullscreen(!0);
1736
+ } catch (q) {
1737
+ console.error("Failed to enter fullscreen:", q);
1700
1738
  }
1701
1739
  }, oe = async () => {
1702
1740
  if (document.fullscreenElement)
1703
1741
  try {
1704
- await document.exitFullscreen(), g && m && m.exitFullscreen(!0);
1742
+ await document.exitFullscreen(), g && f && f.exitFullscreen(!0);
1705
1743
  } catch (x) {
1706
1744
  console.error("Failed to exit fullscreen:", x);
1707
1745
  }
@@ -1709,8 +1747,8 @@ function We(e) {
1709
1747
  return {
1710
1748
  play: i,
1711
1749
  pause: k,
1712
- toggle: B,
1713
- seek: Y,
1750
+ toggle: V,
1751
+ seek: X,
1714
1752
  setVolume: te,
1715
1753
  toggleMute: ne,
1716
1754
  enterFullscreen: ie,
@@ -1723,34 +1761,34 @@ function We(e) {
1723
1761
  r,
1724
1762
  p,
1725
1763
  g,
1726
- m,
1764
+ f,
1727
1765
  u,
1728
1766
  a,
1729
1767
  P
1730
1768
  ]), ae = ue(() => ({
1731
- isPlaying: w?.isPlaying ?? r,
1732
- currentTime: w?.currentTime ?? y,
1733
- duration: w?.duration ?? p,
1734
- volume: w?.volume ?? O,
1735
- isMuted: w?.isMuted ?? v,
1736
- isLoading: w?.isBuffering ?? M,
1737
- isBuffering: w?.isBuffering ?? h,
1738
- error: w?.error ?? c,
1739
- buffered: w?.buffered ?? T,
1740
- isFullscreen: w?.isFullscreen ?? E,
1769
+ isPlaying: b?.state?.isPlaying ?? r,
1770
+ currentTime: b?.state?.currentTime ?? y,
1771
+ duration: b?.state?.duration ?? p,
1772
+ volume: b?.state?.volume ?? I,
1773
+ isMuted: b?.state?.isMuted ?? v,
1774
+ isLoading: b?.state?.isBuffering ?? L,
1775
+ isBuffering: b?.state?.isBuffering ?? h,
1776
+ error: b?.state?.error ?? l,
1777
+ buffered: b?.state?.buffered ?? T,
1778
+ isFullscreen: b?.state?.isFullscreen ?? E,
1741
1779
  progress: p > 0 ? y / p : 0,
1742
1780
  isTransitioning: s || o,
1743
- canPlay: !M && !h && !c
1781
+ canPlay: !L && !h && !l
1744
1782
  }), [
1745
- w,
1783
+ b,
1746
1784
  r,
1747
1785
  y,
1748
1786
  p,
1749
- O,
1787
+ I,
1750
1788
  v,
1751
- M,
1789
+ L,
1752
1790
  h,
1753
- c,
1791
+ l,
1754
1792
  T,
1755
1793
  E,
1756
1794
  s,
@@ -1762,28 +1800,29 @@ function We(e) {
1762
1800
  containerRef: n,
1763
1801
  // State
1764
1802
  state: ae,
1765
- actualState: w?.actualState,
1803
+ actualState: b?.actualState,
1766
1804
  // Controls
1767
1805
  controls: se,
1768
1806
  // Performance metrics
1769
- performanceMetrics: z,
1807
+ performanceMetrics: G,
1770
1808
  isTransitioning: s || o,
1771
1809
  // Enhanced features
1772
- actions: w?.actions,
1773
- actionState: w?.actionState,
1810
+ actions: b,
1811
+ // The optimisticState object contains all the actions
1812
+ actionState: b?.state,
1774
1813
  // Optimistic features
1775
- optimisticState: w,
1814
+ optimisticState: b,
1776
1815
  isEnhanced: g
1777
1816
  };
1778
1817
  }
1779
- const je = (e, t = {}) => {
1818
+ const qe = (e, t = {}) => {
1780
1819
  const {
1781
1820
  trackUserBehavior: n = !0,
1782
1821
  adaptToNetwork: s = !0,
1783
1822
  strategy: u = "balanced",
1784
1823
  maxPreloadItems: o = 3,
1785
1824
  preloadRadius: a = 2
1786
- } = t, d = W({
1825
+ } = t, m = z({
1787
1826
  mouseMovements: 0,
1788
1827
  scrollEvents: 0,
1789
1828
  keyPresses: 0,
@@ -1791,124 +1830,114 @@ const je = (e, t = {}) => {
1791
1830
  timeOnPage: 0,
1792
1831
  engagementScore: 0,
1793
1832
  lastInteraction: Date.now()
1794
- }), S = W(null), D = W(/* @__PURE__ */ new Set()), R = W([]), g = A(() => {
1795
- const c = d.current, T = Math.min(c.timeOnPage / 6e4, 1), E = Math.min(
1796
- (c.mouseMovements + c.scrollEvents + c.keyPresses) / 100,
1833
+ }), S = z(null), F = z(/* @__PURE__ */ new Set()), D = z([]), g = A(() => {
1834
+ const l = m.current, T = Math.min(l.timeOnPage / 6e4, 1), E = Math.min(
1835
+ (l.mouseMovements + l.scrollEvents + l.keyPresses) / 100,
1797
1836
  1
1798
1837
  );
1799
1838
  return (T * 0.4 + E * 0.6) * 100;
1800
- }, []), r = A((c, T = 1) => {
1801
- const E = d.current;
1802
- E[c] = typeof E[c] == "number" ? E[c] + T : Date.now(), E.engagementScore = g(), E.lastInteraction = Date.now();
1839
+ }, []), r = A((l, T = 1) => {
1840
+ const E = m.current;
1841
+ E[l] = typeof E[l] == "number" ? E[l] + T : Date.now(), E.engagementScore = g(), E.lastInteraction = Date.now();
1803
1842
  }, [g]), y = A(() => {
1804
1843
  if (!S.current || !s)
1805
1844
  return { type: "unknown", downlink: 10, effectiveType: "4g", saveData: !1 };
1806
- const c = S.current;
1845
+ const l = S.current;
1807
1846
  return {
1808
- type: c.type,
1809
- downlink: c.downlink || 10,
1810
- effectiveType: c.effectiveType || "4g",
1811
- saveData: c.saveData || !1,
1812
- rtt: c.rtt || 100
1847
+ type: l.effectiveType || "4g",
1848
+ // Use effectiveType as the primary type indicator
1849
+ downlink: l.downlink || 10,
1850
+ effectiveType: l.effectiveType || "4g",
1851
+ saveData: l.saveData || !1,
1852
+ rtt: l.rtt || 100
1813
1853
  };
1814
- }, [s]), p = A((c, T, E = 0) => {
1815
- if (D.current.has(c.src))
1854
+ }, [s]), p = A((l, T, E = 0) => {
1855
+ if (F.current.has(l.src))
1816
1856
  return { shouldPreload: !1, priority: "low", reason: "Already preloaded" };
1817
- const b = Math.abs(T - E);
1818
- if (b > a)
1857
+ const w = Math.abs(T - E);
1858
+ if (w > a)
1819
1859
  return { shouldPreload: !1, priority: "low", reason: "Outside preload radius" };
1820
- const w = d.current, m = y(), z = w.engagementScore, F = Date.now() - w.lastInteraction;
1821
- if (m.saveData)
1860
+ const b = m.current, f = y(), G = b.engagementScore, R = Date.now() - b.lastInteraction;
1861
+ if (f.saveData)
1822
1862
  return { shouldPreload: !1, priority: "low", reason: "Data saver mode" };
1823
- let O = !1, P = "medium", L = "";
1863
+ let I = !1, P = "medium", M = "";
1824
1864
  switch (u) {
1825
1865
  case "conservative":
1826
- O = z > 70 && m.effectiveType !== "2g" && b === 1, P = O ? "medium" : "low", L = O ? "High engagement and optimal network" : "Conservative strategy";
1866
+ I = G > 70 && f.effectiveType !== "2g" && w === 1, P = I ? "medium" : "low", M = I ? "High engagement and optimal network" : "Conservative strategy";
1827
1867
  break;
1828
1868
  case "aggressive":
1829
- O = z > 30 && m.effectiveType !== "slow-2g", P = z > 70 ? "high" : z > 50 ? "medium" : "low", L = O ? "Aggressive preloading" : "Low engagement";
1869
+ I = G > 30 && f.effectiveType !== "slow-2g", P = G > 70 ? "high" : G > 50 ? "medium" : "low", M = I ? "Aggressive preloading" : "Low engagement";
1830
1870
  break;
1831
1871
  case "balanced":
1832
1872
  default:
1833
- const I = m.effectiveType === "4g" ? 1 : m.effectiveType === "3g" ? 0.7 : 0.3, U = z * I;
1834
- O = U > 40 && b <= 2, P = U > 70 ? "high" : U > 55 ? "medium" : "low", L = O ? `Balanced: score ${U.toFixed(1)}` : "Low adjusted score";
1873
+ const C = f.effectiveType === "4g" ? 1 : f.effectiveType === "3g" ? 0.7 : 0.3, O = G * C;
1874
+ I = O > 40 && w <= 2, P = O > 70 ? "high" : O > 55 ? "medium" : "low", M = I ? `Balanced: score ${O.toFixed(1)}` : "Low adjusted score";
1835
1875
  break;
1836
1876
  }
1837
- return O && ((c.type === "hls" || c.type === "m3u8") && (P = P === "low" ? "medium" : "high"), F < 5e3 && (P = "high", L += " + Recent interaction"), (c.type === "mp4" || c.type === "webm") && (P = P === "low" ? "medium" : P)), { shouldPreload: O, priority: P, reason: L };
1838
- }, [u, a, y, g]), l = A(async (c, T) => {
1877
+ if (I) {
1878
+ const C = l.src.toLowerCase();
1879
+ (C.includes(".m3u8") || C.includes("hls")) && (P = P === "low" ? "medium" : "high"), R < 5e3 && (P = "high", M += " + Recent interaction"), (l.type?.includes("mp4") || l.type?.includes("webm") || C.includes(".mp4") || C.includes(".webm")) && (P = P === "low" ? "medium" : P);
1880
+ }
1881
+ return { shouldPreload: I, priority: P, reason: M };
1882
+ }, [u, a, y, g]), d = A(async (l, T) => {
1839
1883
  try {
1840
1884
  const E = document.createElement("link");
1841
- switch (E.rel = "preload", E.href = c.src, c.type) {
1842
- case "hls":
1843
- case "m3u8":
1844
- E.as = "fetch";
1845
- break;
1846
- case "mp4":
1847
- case "webm":
1848
- E.as = "video";
1849
- break;
1850
- case "mp3":
1851
- case "wav":
1852
- case "ogg":
1853
- E.as = "audio";
1854
- break;
1855
- default:
1856
- E.as = "fetch";
1857
- }
1858
- E.crossOrigin = "anonymous", document.head.appendChild(E), D.current.add(c.src), console.debug(`Preloaded: ${c.src} (${T})`), setTimeout(() => {
1885
+ E.rel = "preload", E.href = l.src;
1886
+ const w = l.src.toLowerCase(), b = l.type?.toLowerCase() || "";
1887
+ w.includes(".m3u8") || w.includes("hls") ? E.as = "fetch" : b.includes("mp4") || b.includes("webm") || w.includes(".mp4") || w.includes(".webm") ? E.as = "video" : b.includes("mp3") || b.includes("wav") || b.includes("ogg") || w.includes(".mp3") || w.includes(".wav") || w.includes(".ogg") ? E.as = "audio" : E.as = "fetch", E.crossOrigin = "anonymous", document.head.appendChild(E), F.current.add(l.src), console.debug(`Preloaded: ${l.src} (${T})`), setTimeout(() => {
1859
1888
  document.head.contains(E) && document.head.removeChild(E);
1860
1889
  }, 3e4);
1861
1890
  } catch (E) {
1862
- console.warn("Failed to preload source:", c.src, E);
1891
+ console.warn("Failed to preload source:", l.src, E);
1863
1892
  }
1864
1893
  }, []), v = A(() => {
1865
- if (R.current.length === 0) return;
1866
- const T = [...R.current].sort((E, b) => b.priority - E.priority).slice(0, o);
1867
- R.current = [], T.forEach(({ source: E, priority: b }) => {
1868
- l(E, b);
1894
+ if (D.current.length === 0) return;
1895
+ const T = [...D.current].sort((E, w) => w.priority - E.priority).slice(0, o);
1896
+ D.current = [], T.forEach(({ source: E, priority: w }) => {
1897
+ d(E, w);
1869
1898
  });
1870
- }, [o, l]), M = A((c = 0) => {
1871
- R.current = [], e.forEach((T, E) => {
1872
- const b = p(T, E, c);
1873
- if (b.shouldPreload) {
1874
- const w = b.priority === "high" ? 3 : b.priority === "medium" ? 2 : 1;
1875
- R.current.push({ source: T, priority: w });
1899
+ }, [o, d]), L = A((l = 0) => {
1900
+ D.current = [], e.forEach((T, E) => {
1901
+ const w = p(T, E, l);
1902
+ if (w.shouldPreload) {
1903
+ const b = w.priority === "high" ? 3 : w.priority === "medium" ? 2 : 1;
1904
+ D.current.push({ source: T, priority: b });
1876
1905
  }
1877
1906
  }), v();
1878
1907
  }, [e, p, v]);
1879
- return q(() => {
1908
+ return j(() => {
1880
1909
  if (!n) return;
1881
- const c = () => r("mouseMovements"), T = () => r("scrollEvents"), E = () => r("keyPresses"), b = () => r("focusEvents");
1882
- document.addEventListener("mousemove", c, { passive: !0 }), document.addEventListener("scroll", T, { passive: !0 }), document.addEventListener("keydown", E, { passive: !0 }), document.addEventListener("focusin", b, { passive: !0 });
1883
- const w = setInterval(() => {
1910
+ const l = () => r("mouseMovements"), T = () => r("scrollEvents"), E = () => r("keyPresses"), w = () => r("focusEvents");
1911
+ document.addEventListener("mousemove", l, { passive: !0 }), document.addEventListener("scroll", T, { passive: !0 }), document.addEventListener("keydown", E, { passive: !0 }), document.addEventListener("focusin", w, { passive: !0 });
1912
+ const b = setInterval(() => {
1884
1913
  r("timeOnPage", 1);
1885
1914
  }, 1e3);
1886
1915
  return () => {
1887
- document.removeEventListener("mousemove", c), document.removeEventListener("scroll", T), document.removeEventListener("keydown", E), document.removeEventListener("focusin", b), clearInterval(w);
1916
+ document.removeEventListener("mousemove", l), document.removeEventListener("scroll", T), document.removeEventListener("keydown", E), document.removeEventListener("focusin", w), clearInterval(b);
1888
1917
  };
1889
- }, [n, r]), q(() => {
1918
+ }, [n, r]), j(() => {
1890
1919
  if (!s || !("connection" in navigator)) return;
1891
- const c = navigator.connection;
1892
- S.current = c;
1920
+ const l = navigator.connection;
1921
+ S.current = l;
1893
1922
  const T = () => {
1894
- M();
1923
+ L();
1895
1924
  };
1896
- return c.addEventListener("change", T), () => {
1897
- c.removeEventListener("change", T);
1925
+ return l.addEventListener("change", T), () => {
1926
+ l.removeEventListener("change", T);
1898
1927
  };
1899
- }, [s, M]), q(() => {
1900
- M();
1901
- }, [M]), ue(() => ({
1928
+ }, [s, L]), j(() => {
1929
+ L();
1930
+ }, [L]), ue(() => ({
1902
1931
  /**
1903
1932
  * Manually trigger preloading for specific index
1904
1933
  */
1905
- preloadAtIndex: (c) => {
1906
- M(c);
1934
+ preloadAtIndex: (l) => {
1935
+ L(l);
1907
1936
  },
1908
1937
  /**
1909
1938
  * Get current user behavior data
1910
1939
  */
1911
- getUserBehavior: () => ({ ...d.current }),
1940
+ getUserBehavior: () => ({ ...m.current }),
1912
1941
  /**
1913
1942
  * Get current network conditions
1914
1943
  */
@@ -1917,36 +1946,36 @@ const je = (e, t = {}) => {
1917
1946
  * Clear preloaded items cache
1918
1947
  */
1919
1948
  clearCache: () => {
1920
- D.current.clear();
1949
+ F.current.clear();
1921
1950
  },
1922
1951
  /**
1923
1952
  * Get preloading statistics
1924
1953
  */
1925
1954
  getStats: () => ({
1926
- preloadedItems: D.current.size,
1927
- engagementScore: d.current.engagementScore,
1928
- queueLength: R.current.length,
1955
+ preloadedItems: F.current.size,
1956
+ engagementScore: m.current.engagementScore,
1957
+ queueLength: D.current.length,
1929
1958
  maxPreloadItems: o
1930
1959
  })
1931
- }), [M, y, o]);
1960
+ }), [L, y, o]);
1932
1961
  };
1933
1962
  function Re(e) {
1934
- const [t, n] = Q(!1), [s, u] = Q([]), [o, a] = Q(""), d = (g) => {
1963
+ const [t, n] = Y(!1), [s, u] = Y([]), [o, a] = Y(""), m = (g) => {
1935
1964
  const r = g.split(":"), y = r[2] ? parseFloat(r[2]) : 0, p = r[1] ? parseInt(r[1], 10) * 60 : 0;
1936
1965
  return (r[0] ? parseInt(r[0], 10) * 3600 : 0) + p + y;
1937
1966
  }, S = async (g) => {
1938
1967
  try {
1939
- const y = await (await fetch(g)).text(), p = [], l = y.split(`
1968
+ const y = await (await fetch(g)).text(), p = [], d = y.split(`
1940
1969
  `);
1941
1970
  let v = 0;
1942
- for (; v < l.length; ) {
1943
- if (l[v]?.includes("-->")) {
1944
- const [M, h] = (l[v] || "").split("-->").map((b) => b.trim()), c = d(M || ""), T = d(h || "");
1971
+ for (; v < d.length; ) {
1972
+ if (d[v]?.includes("-->")) {
1973
+ const [L, h] = (d[v] || "").split("-->").map((w) => w.trim()), l = m(L || ""), T = m(h || "");
1945
1974
  v++;
1946
1975
  let E = "";
1947
- for (; v < l.length && l[v]?.trim() !== ""; )
1948
- E += (E ? " " : "") + l[v]?.trim(), v++;
1949
- E && p.push({ start: c, end: T, text: E });
1976
+ for (; v < d.length && d[v]?.trim() !== ""; )
1977
+ E += (E ? " " : "") + d[v]?.trim(), v++;
1978
+ E && p.push({ start: l, end: T, text: E });
1950
1979
  }
1951
1980
  v++;
1952
1981
  }
@@ -1954,60 +1983,60 @@ function Re(e) {
1954
1983
  } catch (r) {
1955
1984
  console.error("Failed to load subtitles:", r);
1956
1985
  }
1957
- }, D = (g) => !t || s.length === 0 ? "" : s.find(
1986
+ }, F = (g) => !t || s.length === 0 ? "" : s.find(
1958
1987
  (y) => g >= y.start && g <= y.end
1959
- )?.text || "", R = () => {
1988
+ )?.text || "", D = () => {
1960
1989
  n((g) => {
1961
1990
  const r = !g;
1962
1991
  return r && e && s.length === 0 ? S(e) : r || a(""), r;
1963
1992
  });
1964
1993
  };
1965
- return q(() => {
1994
+ return j(() => {
1966
1995
  t || a("");
1967
1996
  }, [t]), {
1968
1997
  subtitlesEnabled: t,
1969
1998
  currentSubtitle: o,
1970
- toggleSubtitles: R,
1971
- getCurrentSubtitle: D,
1999
+ toggleSubtitles: D,
2000
+ getCurrentSubtitle: F,
1972
2001
  setCurrentSubtitle: a
1973
2002
  };
1974
2003
  }
1975
- function qe(e) {
2004
+ function Xe(e) {
1976
2005
  return ve(
1977
2006
  "useVideoPlayer",
1978
2007
  "useMediaPlayer (the primary media player hook)"
1979
- ), Le(e);
2008
+ ), Me(e);
1980
2009
  }
1981
- function Xe(e) {
2010
+ function Ye(e) {
1982
2011
  return ve(
1983
2012
  "useEnhancedSubtitles",
1984
2013
  "useSubtitles (the current subtitle hook)"
1985
2014
  ), Re(e);
1986
2015
  }
1987
2016
  export {
1988
- Be as a,
1989
- Ne as b,
1990
- He as c,
1991
- De as d,
1992
- $e as e,
1993
- Ge as f,
1994
- ze as g,
2017
+ _e as a,
2018
+ Be as b,
2019
+ Ne as c,
2020
+ Fe as d,
2021
+ Ke as e,
2022
+ $e as f,
2023
+ Ge as g,
1995
2024
  Oe as h,
1996
2025
  Ue as i,
1997
2026
  Ie as j,
1998
- Le as k,
2027
+ Me as k,
1999
2028
  be as l,
2000
- Me as m,
2001
- We as n,
2002
- _e as o,
2003
- Se as p,
2004
- je as q,
2005
- Fe as r,
2029
+ We as m,
2030
+ je as n,
2031
+ ze as o,
2032
+ De as p,
2033
+ qe as q,
2034
+ Pe as r,
2006
2035
  Re as s,
2007
- qe as t,
2036
+ Xe as t,
2008
2037
  de as u,
2009
- Xe as v,
2038
+ Ye as v,
2010
2039
  Ve as w,
2011
- Ke as x
2040
+ He as x
2012
2041
  };
2013
- //# sourceMappingURL=hooks-BhW_i-9L.js.map
2042
+ //# sourceMappingURL=hooks-BPtHV1ZT.js.map