@aigamo/nostalgic-diva 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,33 +1,33 @@
1
- var R = Object.defineProperty;
2
- var Y = (a, e, t) => e in a ? R(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var v = (a, e, t) => (Y(a, typeof e != "symbol" ? e + "" : e, t), t);
1
+ var F = Object.defineProperty;
2
+ var Y = (a, t, e) => t in a ? F(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var m = (a, t, e) => (Y(a, typeof t != "symbol" ? t + "" : t, e), e);
4
4
  import i, { useRef as V } from "react";
5
- var u = /* @__PURE__ */ ((a) => (a[a.Trace = 0] = "Trace", a[a.Debug = 1] = "Debug", a[a.Information = 2] = "Information", a[a.Warning = 3] = "Warning", a[a.Error = 4] = "Error", a[a.Critical = 5] = "Critical", a[a.None = 6] = "None", a))(u || {});
6
- class E {
7
- constructor(e, t, r) {
8
- this.logger = e, this.player = t, this.options = r, this.logger.log(u.Debug, "ctor");
5
+ var d = /* @__PURE__ */ ((a) => (a[a.Trace = 0] = "Trace", a[a.Debug = 1] = "Debug", a[a.Information = 2] = "Information", a[a.Warning = 3] = "Warning", a[a.Error = 4] = "Error", a[a.Critical = 5] = "Critical", a[a.None = 6] = "None", a))(d || {});
6
+ class w {
7
+ constructor(t, e, r) {
8
+ this.logger = t, this.player = e, this.options = r, this.logger.log(d.Debug, "ctor");
9
9
  }
10
10
  }
11
- class W extends E {
11
+ class j extends w {
12
12
  async attach() {
13
- this.player.onerror = (e) => {
14
- var t, r;
15
- return (r = (t = this.options) == null ? void 0 : t.onError) == null ? void 0 : r.call(t, e);
13
+ this.player.onerror = (t) => {
14
+ var e, r;
15
+ return (r = (e = this.options) == null ? void 0 : e.onError) == null ? void 0 : r.call(e, t);
16
16
  }, this.player.onloadeddata = () => {
17
- var e, t;
18
- return (t = (e = this.options) == null ? void 0 : e.onLoaded) == null ? void 0 : t.call(e, { id: this.player.src });
17
+ var t, e;
18
+ return (e = (t = this.options) == null ? void 0 : t.onLoaded) == null ? void 0 : e.call(t, { id: this.player.src });
19
19
  }, this.player.onplay = () => {
20
- var e, t;
21
- return (t = (e = this.options) == null ? void 0 : e.onPlay) == null ? void 0 : t.call(e);
20
+ var t, e;
21
+ return (e = (t = this.options) == null ? void 0 : t.onPlay) == null ? void 0 : e.call(t);
22
22
  }, this.player.onpause = () => {
23
- var e, t;
24
- return (t = (e = this.options) == null ? void 0 : e.onPause) == null ? void 0 : t.call(e);
23
+ var t, e;
24
+ return (e = (t = this.options) == null ? void 0 : t.onPause) == null ? void 0 : e.call(t);
25
25
  }, this.player.onended = () => {
26
- var e, t;
27
- return (t = (e = this.options) == null ? void 0 : e.onEnded) == null ? void 0 : t.call(e);
26
+ var t, e;
27
+ return (e = (t = this.options) == null ? void 0 : t.onEnded) == null ? void 0 : e.call(t);
28
28
  }, this.player.ontimeupdate = () => {
29
- var e, t;
30
- (t = (e = this.options) == null ? void 0 : e.onTimeUpdate) == null || t.call(e, {
29
+ var t, e;
30
+ (e = (t = this.options) == null ? void 0 : t.onTimeUpdate) == null || e.call(t, {
31
31
  duration: this.player.duration,
32
32
  percent: this.player.currentTime / this.player.duration,
33
33
  seconds: this.player.currentTime
@@ -37,8 +37,8 @@ class W extends E {
37
37
  async detach() {
38
38
  this.player.onerror = null, this.player.onloadeddata = null, this.player.onplay = null, this.player.onpause = null, this.player.onended = null, this.player.ontimeupdate = null;
39
39
  }
40
- async loadVideo(e) {
41
- this.player.src = e;
40
+ async loadVideo(t) {
41
+ this.player.src = t;
42
42
  }
43
43
  async play() {
44
44
  this.player.play();
@@ -46,14 +46,14 @@ class W extends E {
46
46
  async pause() {
47
47
  this.player.pause();
48
48
  }
49
- async setCurrentTime(e) {
50
- this.player.currentTime = e;
49
+ async setCurrentTime(t) {
50
+ this.player.currentTime = t;
51
51
  }
52
- async setVolume(e) {
53
- this.player.volume = e;
52
+ async setVolume(t) {
53
+ this.player.volume = t;
54
54
  }
55
- async setMuted(e) {
56
- this.player.muted = e;
55
+ async setMuted(t) {
56
+ this.player.muted = t;
57
57
  }
58
58
  async getDuration() {
59
59
  return this.player.duration;
@@ -66,30 +66,30 @@ class W extends E {
66
66
  }
67
67
  }
68
68
  const U = class {
69
- constructor(e, t, r, s, l) {
70
- v(this, "id");
71
- v(this, "impl");
72
- this.logger = e, this.type = t, this.player = r, this.options = s, this.playerApiFactory = l, this.id = U.nextId++;
69
+ constructor(t, e, r, s, l) {
70
+ m(this, "id");
71
+ m(this, "impl");
72
+ this.logger = t, this.type = e, this.player = r, this.options = s, this.playerApiFactory = l, this.id = U.nextId++;
73
73
  }
74
- createMessage(e) {
75
- return `${this.type}#${this.id} ${e}`;
74
+ createMessage(t) {
75
+ return `${this.type}#${this.id} ${t}`;
76
76
  }
77
- debug(e, ...t) {
77
+ debug(t, ...e) {
78
78
  this.logger.log(
79
- u.Debug,
80
- this.createMessage(e),
81
- ...t
79
+ d.Debug,
80
+ this.createMessage(t),
81
+ ...e
82
82
  );
83
83
  }
84
- error(e, ...t) {
84
+ error(t, ...e) {
85
85
  this.logger.log(
86
- u.Error,
87
- this.createMessage(e),
88
- ...t
86
+ d.Error,
87
+ this.createMessage(t),
88
+ ...e
89
89
  );
90
90
  }
91
- async attach(e) {
92
- if (this.debug("attach", e), this.impl) {
91
+ async attach(t) {
92
+ if (this.debug("attach", t), this.impl) {
93
93
  this.debug("player is already attached");
94
94
  return;
95
95
  }
@@ -97,7 +97,7 @@ const U = class {
97
97
  this.logger,
98
98
  this.player,
99
99
  this.options
100
- ), await this.impl.attach(e), this.debug("player attached");
100
+ ), await this.impl.attach(t), this.debug("player attached");
101
101
  }
102
102
  createPlayerNotAttachedError() {
103
103
  return new Error("player is not attached");
@@ -107,10 +107,10 @@ const U = class {
107
107
  throw this.createPlayerNotAttachedError();
108
108
  await this.impl.detach(), this.impl = void 0;
109
109
  }
110
- async loadVideo(e) {
111
- if (this.debug("loadVideo", e), this.impl === void 0)
110
+ async loadVideo(t) {
111
+ if (this.debug("loadVideo", t), this.impl === void 0)
112
112
  throw this.createPlayerNotAttachedError();
113
- this.debug("Loading video..."), await this.impl.loadVideo(e), this.debug("video loaded", e);
113
+ this.debug("Loading video..."), await this.impl.loadVideo(t), this.debug("video loaded", t);
114
114
  }
115
115
  play() {
116
116
  if (this.debug("play"), this.impl === void 0)
@@ -122,20 +122,20 @@ const U = class {
122
122
  throw this.createPlayerNotAttachedError();
123
123
  return this.impl.pause();
124
124
  }
125
- setCurrentTime(e) {
126
- if (this.debug("setCurrentTime", e), this.impl === void 0)
125
+ setCurrentTime(t) {
126
+ if (this.debug("setCurrentTime", t), this.impl === void 0)
127
127
  throw this.createPlayerNotAttachedError();
128
- return this.impl.setCurrentTime(e);
128
+ return this.impl.setCurrentTime(t);
129
129
  }
130
- setVolume(e) {
131
- if (this.debug("setVolume", e), this.impl === void 0)
130
+ setVolume(t) {
131
+ if (this.debug("setVolume", t), this.impl === void 0)
132
132
  throw this.createPlayerNotAttachedError();
133
- return this.impl.setVolume(e);
133
+ return this.impl.setVolume(t);
134
134
  }
135
- setMuted(e) {
136
- if (this.debug("setMuted", e), this.impl === void 0)
135
+ setMuted(t) {
136
+ if (this.debug("setMuted", t), this.impl === void 0)
137
137
  throw this.createPlayerNotAttachedError();
138
- return this.impl.setMuted(e);
138
+ return this.impl.setMuted(t);
139
139
  }
140
140
  getDuration() {
141
141
  if (this.debug("getDuration"), this.impl === void 0)
@@ -153,81 +153,81 @@ const U = class {
153
153
  return this.impl.getVolume();
154
154
  }
155
155
  };
156
- let T = U;
157
- v(T, "nextId", 1);
158
- function j() {
156
+ let C = U;
157
+ m(C, "nextId", 1);
158
+ function W() {
159
159
  const a = V(!0);
160
160
  return a.current ? (a.current = !1, !0) : a.current;
161
161
  }
162
- const x = (a, e) => a === e;
163
- function $(a, e = x) {
164
- const t = V(), r = V(a);
165
- return !j() && !e(r.current, a) && (t.current = r.current, r.current = a), t.current;
162
+ const x = (a, t) => a === t;
163
+ function $(a, t = x) {
164
+ const e = V(), r = V(a);
165
+ return !W() && !t(r.current, a) && (e.current = r.current, r.current = a), e.current;
166
166
  }
167
- const w = ({
167
+ const b = ({
168
168
  logger: a,
169
- type: e,
170
- loadScript: t,
169
+ type: t,
170
+ loadScript: e,
171
171
  playerFactory: r,
172
172
  playerApiRef: s,
173
173
  videoId: l,
174
174
  options: o,
175
175
  playerApiFactory: n,
176
- children: d
176
+ children: u
177
177
  }) => {
178
- a.log(u.Debug, "PlayerContainer");
179
- const y = i.useRef(l), p = i.useRef(void 0), [m, g] = i.useState(), [c, h] = i.useState();
178
+ a.log(d.Debug, "PlayerContainer");
179
+ const y = i.useRef(l), p = i.useRef(void 0), [g, v] = i.useState(), [c, h] = i.useState();
180
180
  i.useEffect(() => {
181
- ((t == null ? void 0 : t()) ?? Promise.resolve()).then(() => {
181
+ ((e == null ? void 0 : e()) ?? Promise.resolve()).then(() => {
182
182
  r(p.current, y.current).then(
183
- (b) => {
184
- g(b);
183
+ (E) => {
184
+ v(E);
185
185
  }
186
186
  );
187
187
  });
188
- }, [t, r]), i.useEffect(() => {
189
- if (m === void 0)
188
+ }, [e, r]), i.useEffect(() => {
189
+ if (g === void 0)
190
190
  return;
191
- const b = new T(
191
+ const E = new C(
192
192
  a,
193
- e,
194
- m,
193
+ t,
194
+ g,
195
195
  o,
196
196
  n
197
197
  );
198
- return s && (s.current = b), b.attach(y.current).then(() => h(b)), () => {
199
- if (s && b !== s.current)
198
+ return s && (s.current = E), E.attach(y.current).then(() => h(E)), () => {
199
+ if (s && E !== s.current)
200
200
  throw new Error("playerApi differs");
201
- b.detach().finally(() => h(void 0));
201
+ E.detach().finally(() => h(void 0));
202
202
  };
203
203
  }, [
204
204
  a,
205
- e,
206
205
  t,
207
- m,
206
+ e,
207
+ g,
208
208
  o,
209
209
  n,
210
210
  s
211
211
  ]);
212
- const f = $(l);
212
+ const T = $(l);
213
213
  return i.useEffect(() => {
214
- f !== void 0 && (c == null || c.loadVideo(l));
215
- }, [f, l, c]), /* @__PURE__ */ i.createElement(i.Fragment, null, d(p, y.current));
216
- }, G = i.memo(
214
+ T !== void 0 && (c == null || c.loadVideo(l));
215
+ }, [T, l, c]), /* @__PURE__ */ i.createElement(i.Fragment, null, u(p, y.current));
216
+ }, L = i.memo(
217
217
  ({ ...a }) => {
218
- const { logger: e } = a;
219
- e.log(u.Debug, "AudioPlayer");
220
- const t = i.useCallback(
218
+ const { logger: t } = a;
219
+ t.log(d.Debug, "AudioPlayer");
220
+ const e = i.useCallback(
221
221
  (r) => Promise.resolve(r),
222
222
  []
223
223
  );
224
224
  return /* @__PURE__ */ i.createElement(
225
- w,
225
+ b,
226
226
  {
227
227
  ...a,
228
228
  loadScript: void 0,
229
- playerFactory: t,
230
- playerApiFactory: W
229
+ playerFactory: e,
230
+ playerApiFactory: j
231
231
  },
232
232
  (r, s) => /* @__PURE__ */ i.createElement(
233
233
  "audio",
@@ -251,12 +251,12 @@ const w = ({
251
251
  "playing",
252
252
  "error"
253
253
  ];
254
- class B extends E {
254
+ class G extends w {
255
255
  constructor() {
256
256
  super(...arguments);
257
- v(this, "handlePlayerEvents", (t) => {
258
- var r, s, l, o, n, d, y, p, m, g, c, h;
259
- switch (t.type) {
257
+ m(this, "handlePlayerEvents", (e) => {
258
+ var r, s, l, o, n, u, y, p, g, v, c, h;
259
+ switch (e.type) {
260
260
  case "apiready":
261
261
  (s = (r = this.options) == null ? void 0 : r.onLoaded) == null || s.call(r, { id: this.player.video.videoId });
262
262
  break;
@@ -268,7 +268,7 @@ class B extends E {
268
268
  });
269
269
  break;
270
270
  case "video_end":
271
- (d = (n = this.options) == null ? void 0 : n.onEnded) == null || d.call(n);
271
+ (u = (n = this.options) == null ? void 0 : n.onEnded) == null || u.call(n);
272
272
  break;
273
273
  case "durationchange":
274
274
  break;
@@ -276,24 +276,24 @@ class B extends E {
276
276
  (p = (y = this.options) == null ? void 0 : y.onPause) == null || p.call(y);
277
277
  break;
278
278
  case "playing":
279
- (g = (m = this.options) == null ? void 0 : m.onPlay) == null || g.call(m);
279
+ (v = (g = this.options) == null ? void 0 : g.onPlay) == null || v.call(g);
280
280
  break;
281
281
  case "error":
282
- (h = (c = this.options) == null ? void 0 : c.onError) == null || h.call(c, t);
282
+ (h = (c = this.options) == null ? void 0 : c.onError) == null || h.call(c, e);
283
283
  break;
284
284
  }
285
285
  });
286
286
  }
287
- async attach(t) {
287
+ async attach(e) {
288
288
  for (const r of M)
289
289
  this.player.addEventListener(r, this.handlePlayerEvents);
290
290
  }
291
291
  async detach() {
292
- for (const t of M)
293
- this.player.removeEventListener(t, this.handlePlayerEvents);
292
+ for (const e of M)
293
+ this.player.removeEventListener(e, this.handlePlayerEvents);
294
294
  }
295
- async loadVideo(t) {
296
- this.player.load(t);
295
+ async loadVideo(e) {
296
+ this.player.load(e);
297
297
  }
298
298
  async play() {
299
299
  this.player.play();
@@ -301,14 +301,14 @@ class B extends E {
301
301
  async pause() {
302
302
  this.player.pause();
303
303
  }
304
- async setCurrentTime(t) {
305
- this.player.seek(t);
304
+ async setCurrentTime(e) {
305
+ this.player.seek(e);
306
306
  }
307
- async setVolume(t) {
308
- this.player.setVolume(t);
307
+ async setVolume(e) {
308
+ this.player.setVolume(e);
309
309
  }
310
- async setMuted(t) {
311
- this.player.setMuted(t);
310
+ async setMuted(e) {
311
+ this.player.setMuted(e);
312
312
  }
313
313
  async getDuration() {
314
314
  return this.player.duration;
@@ -320,32 +320,32 @@ class B extends E {
320
320
  return this.player.volume;
321
321
  }
322
322
  }
323
- function O(a) {
324
- return new Promise((e, t) => {
323
+ function B(a) {
324
+ return new Promise((t, e) => {
325
325
  const r = document.createElement("script");
326
- r.src = a, r.async = !0, r.onerror = t, r.onload = r.onreadystatechange = function() {
326
+ r.src = a, r.async = !0, r.onerror = e, r.onload = r.onreadystatechange = function() {
327
327
  const s = this.readyState;
328
- s && s !== "loaded" && s !== "complete" || (r.onload = r.onreadystatechange = null, e());
328
+ s && s !== "loaded" && s !== "complete" || (r.onload = r.onreadystatechange = null, t());
329
329
  }, document.head.appendChild(r);
330
330
  });
331
331
  }
332
332
  const k = [];
333
- async function D(a, e) {
333
+ async function P(a, t) {
334
334
  if (k.includes(a))
335
- return e.log(u.Debug, a, "script is already loaded"), !1;
335
+ return t.log(d.Debug, a, "script is already loaded"), !1;
336
336
  try {
337
- return e.log(u.Debug, a, "Loading script..."), await O(a), k.includes(a) ? (e.log(u.Debug, a, "script is already loaded"), !1) : (k.push(a), e.log(u.Debug, a, "script loaded"), !0);
338
- } catch (t) {
339
- throw e.log(u.Error, a, "Failed to load script"), t;
337
+ return t.log(d.Debug, a, "Loading script..."), await B(a), k.includes(a) ? (t.log(d.Debug, a, "script is already loaded"), !1) : (k.push(a), t.log(d.Debug, a, "script loaded"), !0);
338
+ } catch (e) {
339
+ throw t.log(d.Error, a, "Failed to load script"), e;
340
340
  }
341
341
  }
342
- const _ = i.memo(
343
- ({ options: a, ...e }) => {
344
- const { logger: t } = e;
345
- t.log(u.Debug, "DailymotionPlayer");
342
+ const O = i.memo(
343
+ ({ options: a, ...t }) => {
344
+ const { logger: e } = t;
345
+ e.log(d.Debug, "DailymotionPlayer");
346
346
  const r = i.useCallback(async () => {
347
- await D("https://api.dmcdn.net/all.js", t);
348
- }, [t]), s = i.useCallback(
347
+ await P("https://api.dmcdn.net/all.js", e);
348
+ }, [e]), s = i.useCallback(
349
349
  (l, o) => Promise.resolve(
350
350
  new DM.player(l, {
351
351
  video: o,
@@ -381,8 +381,8 @@ const _ = i.memo(
381
381
  waiting: () => {
382
382
  },
383
383
  error: (n) => {
384
- var d;
385
- (d = a == null ? void 0 : a.onError) == null || d.call(a, n);
384
+ var u;
385
+ (u = a == null ? void 0 : a.onError) == null || u.call(a, n);
386
386
  }
387
387
  }
388
388
  })
@@ -390,41 +390,41 @@ const _ = i.memo(
390
390
  [a]
391
391
  );
392
392
  return /* @__PURE__ */ i.createElement(
393
- w,
393
+ b,
394
394
  {
395
- ...e,
395
+ ...t,
396
396
  options: a,
397
397
  loadScript: r,
398
398
  playerFactory: s,
399
- playerApiFactory: B
399
+ playerApiFactory: G
400
400
  },
401
401
  (l) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement("div", { ref: l }))
402
402
  );
403
403
  }
404
404
  );
405
- var I = /* @__PURE__ */ ((a) => (a[a.Play = 2] = "Play", a[a.Pause = 3] = "Pause", a[a.End = 4] = "End", a))(I || {});
406
- const P = class extends E {
405
+ var A = /* @__PURE__ */ ((a) => (a[a.Play = 2] = "Play", a[a.Pause = 3] = "Pause", a[a.End = 4] = "End", a))(A || {});
406
+ const D = class extends w {
407
407
  constructor() {
408
408
  super(...arguments);
409
- v(this, "duration");
410
- v(this, "currentTime");
411
- v(this, "volume");
412
- v(this, "handleMessage", (t) => {
413
- var s, l, o, n, d, y, p, m, g, c, h, f, b, N;
414
- if (t.origin !== P.origin)
409
+ m(this, "duration");
410
+ m(this, "currentTime");
411
+ m(this, "volume");
412
+ m(this, "handleMessage", (e) => {
413
+ var s, l, o, n, u, y, p, g, v, c, h, T, E, N;
414
+ if (e.origin !== D.origin)
415
415
  return;
416
- const r = t.data;
416
+ const r = e.data;
417
417
  switch (r.eventName) {
418
418
  case "playerStatusChange":
419
419
  this.logger.log(
420
- u.Debug,
421
- `player status changed: ${I[r.data.playerStatus] ?? r.data.playerStatus}`
420
+ d.Debug,
421
+ `player status changed: ${A[r.data.playerStatus] ?? r.data.playerStatus}`
422
422
  );
423
423
  break;
424
424
  case "statusChange":
425
425
  switch (this.logger.log(
426
- u.Debug,
427
- `status changed: ${I[r.data.playerStatus] ?? r.data.playerStatus}`
426
+ d.Debug,
427
+ `status changed: ${A[r.data.playerStatus] ?? r.data.playerStatus}`
428
428
  ), r.data.playerStatus) {
429
429
  case 2:
430
430
  (l = (s = this.options) == null ? void 0 : s.onPlay) == null || l.call(s);
@@ -433,30 +433,30 @@ const P = class extends E {
433
433
  (n = (o = this.options) == null ? void 0 : o.onPause) == null || n.call(o);
434
434
  break;
435
435
  case 4:
436
- (y = (d = this.options) == null ? void 0 : d.onEnded) == null || y.call(d);
436
+ (y = (u = this.options) == null ? void 0 : u.onEnded) == null || y.call(u);
437
437
  break;
438
438
  }
439
439
  break;
440
440
  case "playerMetadataChange":
441
- r.data.duration !== void 0 && (this.duration = r.data.duration / 1e3), this.currentTime = r.data.currentTime === void 0 ? void 0 : r.data.currentTime / 1e3, this.volume = r.data.volume, (m = (p = this.options) == null ? void 0 : p.onTimeUpdate) == null || m.call(p, {
441
+ r.data.duration !== void 0 && (this.duration = r.data.duration / 1e3), this.currentTime = r.data.currentTime === void 0 ? void 0 : r.data.currentTime / 1e3, this.volume = r.data.volume, (g = (p = this.options) == null ? void 0 : p.onTimeUpdate) == null || g.call(p, {
442
442
  duration: this.duration,
443
443
  percent: this.currentTime !== void 0 && this.duration !== void 0 ? this.currentTime / this.duration : void 0,
444
444
  seconds: this.currentTime
445
445
  });
446
446
  break;
447
447
  case "loadComplete":
448
- this.logger.log(u.Debug, "load completed"), this.duration = r.data.videoInfo.lengthInSeconds, (c = (g = this.options) == null ? void 0 : g.onLoaded) == null || c.call(g, { id: r.data.videoInfo.watchId });
448
+ this.logger.log(d.Debug, "load completed"), this.duration = r.data.videoInfo.lengthInSeconds, (c = (v = this.options) == null ? void 0 : v.onLoaded) == null || c.call(v, { id: r.data.videoInfo.watchId });
449
449
  break;
450
450
  case "error":
451
- (f = (h = this.options) == null ? void 0 : h.onError) == null || f.call(h, r);
451
+ (T = (h = this.options) == null ? void 0 : h.onError) == null || T.call(h, r);
452
452
  break;
453
453
  case "player-error:video:play":
454
454
  case "player-error:video:seek":
455
- (N = (b = this.options) == null ? void 0 : b.onError) == null || N.call(b, r);
455
+ (N = (E = this.options) == null ? void 0 : E.onError) == null || N.call(E, r);
456
456
  break;
457
457
  default:
458
458
  this.logger.log(
459
- u.Debug,
459
+ d.Debug,
460
460
  "message",
461
461
  r.eventName,
462
462
  r.data
@@ -471,23 +471,23 @@ const P = class extends E {
471
471
  async detach() {
472
472
  window.removeEventListener("message", this.handleMessage);
473
473
  }
474
- async loadVideo(t) {
474
+ async loadVideo(e) {
475
475
  return new Promise((r, s) => {
476
476
  this.duration = void 0, this.currentTime = void 0, this.player.onload = () => {
477
477
  this.player.onload = null, r();
478
- }, this.player.src = `https://embed.nicovideo.jp/watch/${t}?jsapi=1&playerId=1`;
478
+ }, this.player.src = `https://embed.nicovideo.jp/watch/${e}?jsapi=1&playerId=1`;
479
479
  });
480
480
  }
481
481
  // https://blog.hayu.io/web/create/nicovideo-embed-player-api/.
482
- postMessage(t) {
482
+ postMessage(e) {
483
483
  var r;
484
484
  (r = this.player.contentWindow) == null || r.postMessage(
485
485
  {
486
- ...t,
486
+ ...e,
487
487
  playerId: "1",
488
488
  sourceConnectorType: 1
489
489
  },
490
- P.origin
490
+ D.origin
491
491
  );
492
492
  }
493
493
  async play() {
@@ -496,19 +496,19 @@ const P = class extends E {
496
496
  async pause() {
497
497
  this.postMessage({ eventName: "pause" });
498
498
  }
499
- async setCurrentTime(t) {
500
- this.postMessage({ eventName: "seek", data: { time: t * 1e3 } });
499
+ async setCurrentTime(e) {
500
+ this.postMessage({ eventName: "seek", data: { time: e * 1e3 } });
501
501
  }
502
- async setVolume(t) {
502
+ async setVolume(e) {
503
503
  this.postMessage({
504
504
  eventName: "volumeChange",
505
- data: { volume: t }
505
+ data: { volume: e }
506
506
  });
507
507
  }
508
- async setMuted(t) {
508
+ async setMuted(e) {
509
509
  this.postMessage({
510
510
  eventName: "mute",
511
- data: { mute: t }
511
+ data: { mute: e }
512
512
  });
513
513
  }
514
514
  async getDuration() {
@@ -521,23 +521,23 @@ const P = class extends E {
521
521
  return this.volume;
522
522
  }
523
523
  };
524
- let C = P;
525
- v(C, "origin", "https://embed.nicovideo.jp");
526
- const H = i.memo(
524
+ let f = D;
525
+ m(f, "origin", "https://embed.nicovideo.jp");
526
+ const _ = i.memo(
527
527
  ({ ...a }) => {
528
- const { logger: e } = a;
529
- e.log(u.Debug, "NiconicoPlayer");
530
- const t = i.useCallback(
528
+ const { logger: t } = a;
529
+ t.log(d.Debug, "NiconicoPlayer");
530
+ const e = i.useCallback(
531
531
  (r) => Promise.resolve(r),
532
532
  []
533
533
  );
534
534
  return /* @__PURE__ */ i.createElement(
535
- w,
535
+ b,
536
536
  {
537
537
  ...a,
538
538
  loadScript: void 0,
539
- playerFactory: t,
540
- playerApiFactory: C
539
+ playerFactory: e,
540
+ playerApiFactory: f
541
541
  },
542
542
  (r, s) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement(
543
543
  "iframe",
@@ -556,82 +556,82 @@ const H = i.memo(
556
556
  ), S = i.createContext(
557
557
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
558
558
  void 0
559
- ), L = new class {
559
+ ), H = new class {
560
560
  constructor() {
561
- v(this, "title", "nostalgic-diva");
561
+ m(this, "title", "nostalgic-diva");
562
562
  }
563
563
  createMessage(a) {
564
564
  return `[${this.title}] ${a}`;
565
565
  }
566
- debug(a, ...e) {
567
- console.debug(this.createMessage(a), ...e);
566
+ debug(a, ...t) {
567
+ console.debug(this.createMessage(a), ...t);
568
568
  }
569
- error(a, ...e) {
570
- console.error(this.createMessage(a), ...e);
569
+ error(a, ...t) {
570
+ console.error(this.createMessage(a), ...t);
571
571
  }
572
- warn(a, ...e) {
573
- console.warn(this.createMessage(a), ...e);
572
+ warn(a, ...t) {
573
+ console.warn(this.createMessage(a), ...t);
574
574
  }
575
575
  isEnabled() {
576
576
  return !0;
577
577
  }
578
- log(a, e, ...t) {
578
+ log(a, t, ...e) {
579
579
  switch (a) {
580
- case u.Debug:
581
- this.debug(e, ...t);
580
+ case d.Debug:
581
+ this.debug(t, ...e);
582
582
  break;
583
- case u.Warning:
584
- this.warn(e, ...t);
583
+ case d.Warning:
584
+ this.warn(t, ...e);
585
585
  break;
586
- case u.Error:
587
- this.error(e, ...t);
586
+ case d.Error:
587
+ this.error(t, ...e);
588
588
  break;
589
589
  }
590
590
  }
591
- }(), re = ({
592
- logger: a = L,
593
- children: e
591
+ }(), ie = ({
592
+ logger: a = H,
593
+ children: t
594
594
  }) => {
595
- const t = i.useRef(), r = i.useCallback(async (c) => {
595
+ const e = i.useRef(), r = i.useCallback(async (c) => {
596
596
  var h;
597
- await ((h = t.current) == null ? void 0 : h.loadVideo(c));
597
+ await ((h = e.current) == null ? void 0 : h.loadVideo(c));
598
598
  }, []), s = i.useCallback(async () => {
599
599
  var c;
600
- await ((c = t.current) == null ? void 0 : c.play());
600
+ await ((c = e.current) == null ? void 0 : c.play());
601
601
  }, []), l = i.useCallback(async () => {
602
602
  var c;
603
- await ((c = t.current) == null ? void 0 : c.pause());
603
+ await ((c = e.current) == null ? void 0 : c.pause());
604
604
  }, []), o = i.useCallback(async (c) => {
605
- const h = t.current;
605
+ const h = e.current;
606
606
  h && (await h.setCurrentTime(c), await h.play());
607
607
  }, []), n = i.useCallback(async (c) => {
608
608
  var h;
609
- await ((h = t.current) == null ? void 0 : h.setVolume(c));
610
- }, []), d = i.useCallback(async (c) => {
609
+ await ((h = e.current) == null ? void 0 : h.setVolume(c));
610
+ }, []), u = i.useCallback(async (c) => {
611
611
  var h;
612
- await ((h = t.current) == null ? void 0 : h.setMuted(c));
612
+ await ((h = e.current) == null ? void 0 : h.setMuted(c));
613
613
  }, []), y = i.useCallback(async () => {
614
614
  var c;
615
- return await ((c = t.current) == null ? void 0 : c.getDuration());
615
+ return await ((c = e.current) == null ? void 0 : c.getDuration());
616
616
  }, []), p = i.useCallback(async () => {
617
617
  var c;
618
- return await ((c = t.current) == null ? void 0 : c.getCurrentTime());
619
- }, []), m = i.useCallback(async () => {
618
+ return await ((c = e.current) == null ? void 0 : c.getCurrentTime());
619
+ }, []), g = i.useCallback(async () => {
620
620
  var c;
621
- return await ((c = t.current) == null ? void 0 : c.getVolume());
622
- }, []), g = i.useMemo(
621
+ return await ((c = e.current) == null ? void 0 : c.getVolume());
622
+ }, []), v = i.useMemo(
623
623
  () => ({
624
624
  logger: a,
625
- playerApiRef: t,
625
+ playerApiRef: e,
626
626
  loadVideo: r,
627
627
  play: s,
628
628
  pause: l,
629
629
  setCurrentTime: o,
630
630
  setVolume: n,
631
- setMuted: d,
631
+ setMuted: u,
632
632
  getDuration: y,
633
633
  getCurrentTime: p,
634
- getVolume: m
634
+ getVolume: g
635
635
  }),
636
636
  [
637
637
  a,
@@ -640,30 +640,30 @@ const H = i.memo(
640
640
  l,
641
641
  o,
642
642
  n,
643
- d,
643
+ u,
644
644
  y,
645
645
  p,
646
- m
646
+ g
647
647
  ]
648
648
  );
649
- return /* @__PURE__ */ i.createElement(S.Provider, { value: g }, e);
649
+ return /* @__PURE__ */ i.createElement(S.Provider, { value: v }, t);
650
650
  }, q = () => i.useContext(S);
651
- class A extends E {
651
+ class I extends w {
652
652
  getDurationCore() {
653
- return new Promise((e, t) => {
654
- this.player.getDuration(e);
653
+ return new Promise((t, e) => {
654
+ this.player.getDuration(t);
655
655
  });
656
656
  }
657
- attach(e) {
658
- return new Promise((t, r) => {
657
+ attach(t) {
658
+ return new Promise((e, r) => {
659
659
  this.player.bind(SC.Widget.Events.READY, () => {
660
660
  var s, l;
661
661
  this.player.bind(
662
662
  SC.Widget.Events.PLAY_PROGRESS,
663
663
  async (o) => {
664
- var d, y;
664
+ var u, y;
665
665
  const n = await this.getDurationCore();
666
- (y = (d = this.options) == null ? void 0 : d.onTimeUpdate) == null || y.call(d, {
666
+ (y = (u = this.options) == null ? void 0 : u.onTimeUpdate) == null || y.call(u, {
667
667
  duration: n / 1e3,
668
668
  percent: o.currentPosition / n,
669
669
  seconds: o.currentPosition / 1e3
@@ -672,8 +672,8 @@ class A extends E {
672
672
  ), this.player.bind(
673
673
  SC.Widget.Events.ERROR,
674
674
  (o) => {
675
- var n, d;
676
- return (d = (n = this.options) == null ? void 0 : n.onError) == null ? void 0 : d.call(n, o);
675
+ var n, u;
676
+ return (u = (n = this.options) == null ? void 0 : n.onError) == null ? void 0 : u.call(n, o);
677
677
  }
678
678
  ), this.player.bind(
679
679
  SC.Widget.Events.PLAY,
@@ -693,23 +693,23 @@ class A extends E {
693
693
  var o, n;
694
694
  return (n = (o = this.options) == null ? void 0 : o.onEnded) == null ? void 0 : n.call(o);
695
695
  }
696
- ), (l = (s = this.options) == null ? void 0 : s.onLoaded) == null || l.call(s, { id: e }), t();
696
+ ), (l = (s = this.options) == null ? void 0 : s.onLoaded) == null || l.call(s, { id: t }), e();
697
697
  });
698
698
  });
699
699
  }
700
700
  async detach() {
701
701
  this.player.unbind(SC.Widget.Events.READY), this.player.unbind(SC.Widget.Events.PLAY_PROGRESS), this.player.unbind(SC.Widget.Events.ERROR), this.player.unbind(SC.Widget.Events.PLAY), this.player.unbind(SC.Widget.Events.PAUSE), this.player.unbind(SC.Widget.Events.FINISH);
702
702
  }
703
- static playerLoadAsync(e, t, r) {
703
+ static playerLoadAsync(t, e, r) {
704
704
  return new Promise((s, l) => {
705
- e.load(t, { ...r, callback: s });
705
+ t.load(e, { ...r, callback: s });
706
706
  });
707
707
  }
708
- async loadVideo(e) {
709
- var t, r;
710
- await A.playerLoadAsync(this.player, e, {
708
+ async loadVideo(t) {
709
+ var e, r;
710
+ await I.playerLoadAsync(this.player, t, {
711
711
  auto_play: !0
712
- }), (r = (t = this.options) == null ? void 0 : t.onLoaded) == null || r.call(t, { id: e });
712
+ }), (r = (e = this.options) == null ? void 0 : e.onLoaded) == null || r.call(e, { id: t });
713
713
  }
714
714
  async play() {
715
715
  this.player.play();
@@ -717,15 +717,15 @@ class A extends E {
717
717
  async pause() {
718
718
  this.player.pause();
719
719
  }
720
- async setCurrentTime(e) {
721
- this.player.seekTo(e * 1e3);
720
+ async setCurrentTime(t) {
721
+ this.player.seekTo(t * 1e3);
722
722
  }
723
- async setVolume(e) {
724
- this.player.setVolume(e * 100);
723
+ async setVolume(t) {
724
+ this.player.setVolume(t * 100);
725
725
  }
726
- async setMuted(e) {
726
+ async setMuted(t) {
727
727
  this.setVolume(
728
- e ? 0 : 1
728
+ t ? 0 : 1
729
729
  /* TODO */
730
730
  );
731
731
  }
@@ -733,42 +733,42 @@ class A extends E {
733
733
  return await this.getDurationCore() / 1e3;
734
734
  }
735
735
  getCurrentTimeCore() {
736
- return new Promise((e, t) => {
737
- this.player.getPosition(e);
736
+ return new Promise((t, e) => {
737
+ this.player.getPosition(t);
738
738
  });
739
739
  }
740
740
  async getCurrentTime() {
741
741
  return await this.getCurrentTimeCore() / 1e3;
742
742
  }
743
743
  getVolumeCore() {
744
- return new Promise((e, t) => {
745
- this.player.getVolume(e);
744
+ return new Promise((t, e) => {
745
+ this.player.getVolume(t);
746
746
  });
747
747
  }
748
748
  async getVolume() {
749
749
  return await this.getVolumeCore() / 100;
750
750
  }
751
751
  }
752
- const z = i.memo(
752
+ const K = i.memo(
753
753
  ({ ...a }) => {
754
- const { logger: e } = a;
755
- e.log(u.Debug, "SoundCloudPlayer");
756
- const t = i.useCallback(async () => {
757
- await D(
754
+ const { logger: t } = a;
755
+ t.log(d.Debug, "SoundCloudPlayer");
756
+ const e = i.useCallback(async () => {
757
+ await P(
758
758
  "https://w.soundcloud.com/player/api.js",
759
- e
759
+ t
760
760
  );
761
- }, [e]), r = i.useCallback(
761
+ }, [t]), r = i.useCallback(
762
762
  (s) => Promise.resolve(SC.Widget(s)),
763
763
  []
764
764
  );
765
765
  return /* @__PURE__ */ i.createElement(
766
- w,
766
+ b,
767
767
  {
768
768
  ...a,
769
- loadScript: t,
769
+ loadScript: e,
770
770
  playerFactory: r,
771
- playerApiFactory: A
771
+ playerApiFactory: I
772
772
  },
773
773
  (s, l) => (
774
774
  // eslint-disable-next-line jsx-a11y/iframe-has-title
@@ -786,40 +786,138 @@ const z = i.memo(
786
786
  );
787
787
  }
788
788
  );
789
- class J extends E {
789
+ class z extends w {
790
+ constructor() {
791
+ super(...arguments);
792
+ m(this, "handleReady", () => {
793
+ var e, r;
794
+ (r = (e = this.options) == null ? void 0 : e.onLoaded) == null || r.call(e, { id: this.player.getVideo() });
795
+ });
796
+ m(this, "handlePlay", () => {
797
+ var e, r;
798
+ (r = (e = this.options) == null ? void 0 : e.onPlay) == null || r.call(e);
799
+ });
800
+ m(this, "handlePause", () => {
801
+ var e, r;
802
+ (r = (e = this.options) == null ? void 0 : e.onPause) == null || r.call(e);
803
+ });
804
+ m(this, "handleEnded", () => {
805
+ var e, r;
806
+ (r = (e = this.options) == null ? void 0 : e.onEnded) == null || r.call(e);
807
+ });
808
+ m(this, "handleSeek", () => {
809
+ var e, r;
810
+ (r = (e = this.options) == null ? void 0 : e.onTimeUpdate) == null || r.call(e, {
811
+ duration: 0,
812
+ percent: 0,
813
+ seconds: 0
814
+ });
815
+ });
816
+ }
817
+ async attach(e) {
818
+ this.player.addEventListener(Twitch.Player.READY, this.handleReady), this.player.addEventListener(Twitch.Player.PLAYING, this.handlePlay), this.player.addEventListener(Twitch.Player.PAUSE, this.handlePause), this.player.addEventListener(Twitch.Player.ENDED, this.handleEnded), this.player.addEventListener(Twitch.Player.SEEK, this.handleSeek);
819
+ }
820
+ async detach() {
821
+ }
822
+ async loadVideo(e) {
823
+ this.player.setVideo(e, 0);
824
+ }
825
+ async play() {
826
+ this.player.play();
827
+ }
828
+ async pause() {
829
+ this.player.pause();
830
+ }
831
+ async setCurrentTime(e) {
832
+ this.player.seek(e);
833
+ }
834
+ async setVolume(e) {
835
+ this.player.setVolume(e);
836
+ }
837
+ async setMuted(e) {
838
+ this.player.setMuted(e);
839
+ }
840
+ async getDuration() {
841
+ return this.player.getDuration();
842
+ }
843
+ async getCurrentTime() {
844
+ return this.player.getCurrentTime();
845
+ }
846
+ async getVolume() {
847
+ return this.player.getVolume();
848
+ }
849
+ }
850
+ const J = i.memo(
851
+ ({ ...a }) => {
852
+ const { logger: t } = a;
853
+ t.log(d.Debug, "TwitchPlayer");
854
+ const e = i.useCallback(async () => {
855
+ await P(
856
+ "https://embed.twitch.tv/embed/v1.js",
857
+ t
858
+ );
859
+ }, [t]), r = i.useCallback(
860
+ async (s, l) => Promise.resolve(
861
+ new Twitch.Player(s, {
862
+ video: l,
863
+ width: "100%",
864
+ height: "100%"
865
+ })
866
+ ),
867
+ []
868
+ );
869
+ return /* @__PURE__ */ i.createElement(
870
+ b,
871
+ {
872
+ ...a,
873
+ loadScript: e,
874
+ playerFactory: r,
875
+ playerApiFactory: z
876
+ },
877
+ (s) => /* @__PURE__ */ i.createElement(
878
+ "div",
879
+ {
880
+ ref: s,
881
+ style: { width: "100%", height: "100%" }
882
+ }
883
+ )
884
+ );
885
+ }
886
+ );
887
+ class Q extends w {
790
888
  async attach() {
791
- await this.player.ready(), this.player.on("error", (e) => {
792
- var t, r;
793
- return (r = (t = this.options) == null ? void 0 : t.onError) == null ? void 0 : r.call(t, e);
889
+ await this.player.ready(), this.player.on("error", (t) => {
890
+ var e, r;
891
+ return (r = (e = this.options) == null ? void 0 : e.onError) == null ? void 0 : r.call(e, t);
794
892
  }), this.player.on(
795
893
  "loaded",
796
- (e) => {
797
- var t, r;
798
- return (r = (t = this.options) == null ? void 0 : t.onLoaded) == null ? void 0 : r.call(t, { id: e.id.toString() });
894
+ (t) => {
895
+ var e, r;
896
+ return (r = (e = this.options) == null ? void 0 : e.onLoaded) == null ? void 0 : r.call(e, { id: t.id.toString() });
799
897
  }
800
898
  ), this.player.on("play", () => {
801
- var e, t;
802
- return (t = (e = this.options) == null ? void 0 : e.onPlay) == null ? void 0 : t.call(e);
899
+ var t, e;
900
+ return (e = (t = this.options) == null ? void 0 : t.onPlay) == null ? void 0 : e.call(t);
803
901
  }), this.player.on("pause", () => {
804
- var e, t;
805
- return (t = (e = this.options) == null ? void 0 : e.onPause) == null ? void 0 : t.call(e);
902
+ var t, e;
903
+ return (e = (t = this.options) == null ? void 0 : t.onPause) == null ? void 0 : e.call(t);
806
904
  }), this.player.on("ended", () => {
807
- var e, t;
808
- return (t = (e = this.options) == null ? void 0 : e.onEnded) == null ? void 0 : t.call(e);
809
- }), this.player.on("timeupdate", (e) => {
810
- var t, r;
811
- (r = (t = this.options) == null ? void 0 : t.onTimeUpdate) == null || r.call(t, {
812
- duration: e.duration,
813
- percent: e.percent,
814
- seconds: e.seconds
905
+ var t, e;
906
+ return (e = (t = this.options) == null ? void 0 : t.onEnded) == null ? void 0 : e.call(t);
907
+ }), this.player.on("timeupdate", (t) => {
908
+ var e, r;
909
+ (r = (e = this.options) == null ? void 0 : e.onTimeUpdate) == null || r.call(e, {
910
+ duration: t.duration,
911
+ percent: t.percent,
912
+ seconds: t.seconds
815
913
  });
816
914
  });
817
915
  }
818
916
  async detach() {
819
917
  this.player.off("error"), this.player.off("loaded"), this.player.off("play"), this.player.off("pause"), this.player.off("ended"), this.player.off("timeupdate");
820
918
  }
821
- async loadVideo(e) {
822
- await this.player.loadVideo(e);
919
+ async loadVideo(t) {
920
+ await this.player.loadVideo(t);
823
921
  }
824
922
  async play() {
825
923
  await this.player.play();
@@ -827,14 +925,14 @@ class J extends E {
827
925
  async pause() {
828
926
  await this.player.pause();
829
927
  }
830
- async setCurrentTime(e) {
831
- await this.player.setCurrentTime(e);
928
+ async setCurrentTime(t) {
929
+ await this.player.setCurrentTime(t);
832
930
  }
833
- async setVolume(e) {
834
- await this.player.setVolume(e);
931
+ async setVolume(t) {
932
+ await this.player.setVolume(t);
835
933
  }
836
- async setMuted(e) {
837
- await this.player.setMuted(e);
934
+ async setMuted(t) {
935
+ await this.player.setMuted(t);
838
936
  }
839
937
  async getDuration() {
840
938
  return this.player.getDuration();
@@ -846,26 +944,26 @@ class J extends E {
846
944
  return await this.player.getVolume();
847
945
  }
848
946
  }
849
- const K = i.memo(
947
+ const X = i.memo(
850
948
  ({ ...a }) => {
851
- const { logger: e } = a;
852
- e.log(u.Debug, "VimeoPlayer");
853
- const t = i.useCallback(async () => {
854
- await D(
949
+ const { logger: t } = a;
950
+ t.log(d.Debug, "VimeoPlayer");
951
+ const e = i.useCallback(async () => {
952
+ await P(
855
953
  "https://player.vimeo.com/api/player.js",
856
- e
954
+ t
857
955
  );
858
- }, [e]), r = i.useCallback(
956
+ }, [t]), r = i.useCallback(
859
957
  (s) => Promise.resolve(new Vimeo.Player(s)),
860
958
  []
861
959
  );
862
960
  return /* @__PURE__ */ i.createElement(
863
- w,
961
+ b,
864
962
  {
865
963
  ...a,
866
- loadScript: t,
964
+ loadScript: e,
867
965
  playerFactory: r,
868
- playerApiFactory: J
966
+ playerApiFactory: Q
869
967
  },
870
968
  (s, l) => (
871
969
  // eslint-disable-next-line jsx-a11y/iframe-has-title
@@ -883,26 +981,26 @@ const K = i.memo(
883
981
  );
884
982
  }
885
983
  );
886
- var F = /* @__PURE__ */ ((a) => (a[a.UNSTARTED = -1] = "UNSTARTED", a[a.ENDED = 0] = "ENDED", a[a.PLAYING = 1] = "PLAYING", a[a.PAUSED = 2] = "PAUSED", a[a.BUFFERING = 3] = "BUFFERING", a[a.CUED = 5] = "CUED", a))(F || {});
887
- class Q extends E {
984
+ var R = /* @__PURE__ */ ((a) => (a[a.UNSTARTED = -1] = "UNSTARTED", a[a.ENDED = 0] = "ENDED", a[a.PLAYING = 1] = "PLAYING", a[a.PAUSED = 2] = "PAUSED", a[a.BUFFERING = 3] = "BUFFERING", a[a.CUED = 5] = "CUED", a))(R || {});
985
+ class Z extends w {
888
986
  constructor() {
889
987
  super(...arguments);
890
- v(this, "previousTime");
891
- v(this, "timeUpdateIntervalId");
988
+ m(this, "previousTime");
989
+ m(this, "timeUpdateIntervalId");
892
990
  }
893
991
  clearTimeUpdateInterval() {
894
992
  this.logger.log(
895
- u.Debug,
993
+ d.Debug,
896
994
  "clearTimeUpdateInterval",
897
995
  this.timeUpdateIntervalId
898
996
  ), window.clearInterval(this.timeUpdateIntervalId), this.timeUpdateIntervalId = void 0;
899
997
  }
900
- invokeTimeUpdate(t) {
998
+ invokeTimeUpdate(e) {
901
999
  var l, o;
902
- const r = t.getCurrentTime();
1000
+ const r = e.getCurrentTime();
903
1001
  if (r === this.previousTime)
904
1002
  return;
905
- const s = t.getDuration();
1003
+ const s = e.getDuration();
906
1004
  (o = (l = this.options) == null ? void 0 : l.onTimeUpdate) == null || o.call(l, {
907
1005
  duration: s,
908
1006
  percent: r / s,
@@ -910,16 +1008,16 @@ class Q extends E {
910
1008
  }), this.previousTime = r;
911
1009
  }
912
1010
  setTimeUpdateInterval() {
913
- this.logger.log(u.Debug, "setTimeUpdateInterval"), this.clearTimeUpdateInterval(), this.timeUpdateIntervalId = window.setInterval(
1011
+ this.logger.log(d.Debug, "setTimeUpdateInterval"), this.clearTimeUpdateInterval(), this.timeUpdateIntervalId = window.setInterval(
914
1012
  () => this.invokeTimeUpdate(this.player),
915
1013
  250
916
1014
  ), this.logger.log(
917
- u.Debug,
1015
+ d.Debug,
918
1016
  "timeUpdateIntervalId",
919
1017
  this.timeUpdateIntervalId
920
1018
  ), this.invokeTimeUpdate(this.player);
921
1019
  }
922
- attach(t) {
1020
+ attach(e) {
923
1021
  return new Promise((r, s) => {
924
1022
  this.player.addEventListener("onReady", async () => {
925
1023
  this.player.addEventListener(
@@ -931,34 +1029,34 @@ class Q extends E {
931
1029
  ), this.player.addEventListener(
932
1030
  "onStateChange",
933
1031
  (l) => {
934
- var o, n, d, y, p, m, g, c;
1032
+ var o, n, u, y, p, g, v, c;
935
1033
  switch (this.logger.log(
936
- u.Debug,
937
- `state changed: ${F[l.data]}`
1034
+ d.Debug,
1035
+ `state changed: ${R[l.data]}`
938
1036
  ), l.data) {
939
1037
  case YT.PlayerState.CUED:
940
- (n = (o = this.options) == null ? void 0 : o.onLoaded) == null || n.call(o, { id: t });
1038
+ (n = (o = this.options) == null ? void 0 : o.onLoaded) == null || n.call(o, { id: e });
941
1039
  break;
942
1040
  case YT.PlayerState.PLAYING:
943
- (y = (d = this.options) == null ? void 0 : d.onPlay) == null || y.call(d), this.setTimeUpdateInterval();
1041
+ (y = (u = this.options) == null ? void 0 : u.onPlay) == null || y.call(u), this.setTimeUpdateInterval();
944
1042
  break;
945
1043
  case YT.PlayerState.PAUSED:
946
- (m = (p = this.options) == null ? void 0 : p.onPause) == null || m.call(p), this.clearTimeUpdateInterval();
1044
+ (g = (p = this.options) == null ? void 0 : p.onPause) == null || g.call(p), this.clearTimeUpdateInterval();
947
1045
  break;
948
1046
  case YT.PlayerState.ENDED:
949
- (c = (g = this.options) == null ? void 0 : g.onEnded) == null || c.call(g), this.clearTimeUpdateInterval();
1047
+ (c = (v = this.options) == null ? void 0 : v.onEnded) == null || c.call(v), this.clearTimeUpdateInterval();
950
1048
  break;
951
1049
  }
952
1050
  }
953
- ), await this.loadVideo(t), r();
1051
+ ), await this.loadVideo(e), r();
954
1052
  });
955
1053
  });
956
1054
  }
957
1055
  async detach() {
958
1056
  this.clearTimeUpdateInterval();
959
1057
  }
960
- async loadVideo(t) {
961
- this.previousTime = void 0, this.player.cueVideoById(t);
1058
+ async loadVideo(e) {
1059
+ this.previousTime = void 0, this.player.cueVideoById(e);
962
1060
  }
963
1061
  async play() {
964
1062
  this.player.playVideo();
@@ -966,14 +1064,14 @@ class Q extends E {
966
1064
  async pause() {
967
1065
  this.player.pauseVideo();
968
1066
  }
969
- async setCurrentTime(t) {
970
- this.player.seekTo(t), this.invokeTimeUpdate(this.player);
1067
+ async setCurrentTime(e) {
1068
+ this.player.seekTo(e), this.invokeTimeUpdate(this.player);
971
1069
  }
972
- async setVolume(t) {
973
- this.player.setVolume(t * 100);
1070
+ async setVolume(e) {
1071
+ this.player.setVolume(e * 100);
974
1072
  }
975
- async setMuted(t) {
976
- t ? this.player.mute() : this.player.unMute();
1073
+ async setMuted(e) {
1074
+ e ? this.player.mute() : this.player.unMute();
977
1075
  }
978
1076
  async getDuration() {
979
1077
  return this.player.getDuration();
@@ -985,21 +1083,21 @@ class Q extends E {
985
1083
  return this.player.getVolume() / 100;
986
1084
  }
987
1085
  }
988
- const X = "https://www.youtube-nocookie.com", Z = i.memo(
1086
+ const ee = "https://www.youtube-nocookie.com", te = i.memo(
989
1087
  ({ ...a }) => {
990
- const { logger: e } = a;
991
- e.log(u.Debug, "YouTubePlayer");
992
- const t = i.useCallback(() => new Promise(async (s, l) => {
993
- await D(
1088
+ const { logger: t } = a;
1089
+ t.log(d.Debug, "YouTubePlayer");
1090
+ const e = i.useCallback(() => new Promise(async (s, l) => {
1091
+ await P(
994
1092
  "https://www.youtube.com/iframe_api",
995
- e
1093
+ t
996
1094
  ) ? window.onYouTubeIframeAPIReady = () => {
997
- e.log(u.Debug, "YouTube iframe API ready"), s();
1095
+ t.log(d.Debug, "YouTube iframe API ready"), s();
998
1096
  } : s();
999
- }), [e]), r = i.useCallback(
1097
+ }), [t]), r = i.useCallback(
1000
1098
  (s) => Promise.resolve(
1001
1099
  new YT.Player(s, {
1002
- host: X,
1100
+ host: ee,
1003
1101
  width: "100%",
1004
1102
  height: "100%"
1005
1103
  })
@@ -1007,56 +1105,59 @@ const X = "https://www.youtube-nocookie.com", Z = i.memo(
1007
1105
  []
1008
1106
  );
1009
1107
  return /* @__PURE__ */ i.createElement(
1010
- w,
1108
+ b,
1011
1109
  {
1012
1110
  ...a,
1013
- loadScript: t,
1111
+ loadScript: e,
1014
1112
  playerFactory: r,
1015
- playerApiFactory: Q
1113
+ playerApiFactory: Z
1016
1114
  },
1017
1115
  (s) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement("div", { ref: s }))
1018
1116
  );
1019
1117
  }
1020
- ), ee = {
1021
- Audio: G,
1022
- Dailymotion: _,
1023
- Niconico: H,
1024
- SoundCloud: z,
1025
- Vimeo: K,
1026
- YouTube: Z
1027
- }, se = i.memo(
1028
- ({ type: a, videoId: e, options: t }) => {
1118
+ ), ae = {
1119
+ Audio: L,
1120
+ Dailymotion: O,
1121
+ Niconico: _,
1122
+ SoundCloud: K,
1123
+ Twitch: J,
1124
+ Vimeo: X,
1125
+ YouTube: te
1126
+ }, ne = i.memo(
1127
+ ({ type: a, videoId: t, options: e }) => {
1029
1128
  const { logger: r, playerApiRef: s } = q();
1030
- r.log(u.Debug, "NostalgicDiva");
1031
- const l = ee[a];
1129
+ r.log(d.Debug, "NostalgicDiva");
1130
+ const l = ae[a];
1032
1131
  return /* @__PURE__ */ i.createElement(
1033
1132
  l,
1034
1133
  {
1035
1134
  logger: r,
1036
1135
  type: a,
1037
1136
  playerApiRef: s,
1038
- videoId: e,
1039
- options: t
1137
+ videoId: t,
1138
+ options: e
1040
1139
  }
1041
1140
  );
1042
1141
  }
1043
1142
  );
1044
1143
  export {
1045
- G as AudioPlayer,
1046
- W as AudioPlayerApi,
1047
- _ as DailymotionPlayer,
1048
- B as DailymotionPlayerApi,
1049
- H as NiconicoPlayer,
1050
- C as NiconicoPlayerApi,
1051
- se as NostalgicDiva,
1052
- re as NostalgicDivaProvider,
1053
- T as PlayerApi,
1054
- z as SoundCloudPlayer,
1055
- A as SoundCloudPlayerApi,
1056
- K as VimeoPlayer,
1057
- J as VimeoPlayerApi,
1058
- Z as YouTubePlayer,
1059
- Q as YouTubePlayerApi,
1144
+ L as AudioPlayer,
1145
+ j as AudioPlayerApi,
1146
+ O as DailymotionPlayer,
1147
+ G as DailymotionPlayerApi,
1148
+ _ as NiconicoPlayer,
1149
+ f as NiconicoPlayerApi,
1150
+ ne as NostalgicDiva,
1151
+ ie as NostalgicDivaProvider,
1152
+ C as PlayerApi,
1153
+ K as SoundCloudPlayer,
1154
+ I as SoundCloudPlayerApi,
1155
+ J as TwitchPlayer,
1156
+ z as TwitchPlayerApi,
1157
+ X as VimeoPlayer,
1158
+ Q as VimeoPlayerApi,
1159
+ te as YouTubePlayer,
1160
+ Z as YouTubePlayerApi,
1060
1161
  q as useNostalgicDiva
1061
1162
  };
1062
1163
  //# sourceMappingURL=index.es.js.map