@tidal-music/player-web-components 0.1.1 → 0.1.2

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,4 +1,4 @@
1
- let R = Object.freeze({
1
+ let x = Object.freeze({
2
2
  apiUrl: "https://api.tidal.com/v1",
3
3
  appVersion: "TIDAL Player",
4
4
  clientPlatform: "web",
@@ -9,55 +9,69 @@ let R = Object.freeze({
9
9
  outputDevicesEnabled: !1,
10
10
  streamingWifiAudioQuality: "LOW"
11
11
  });
12
- function k(t) {
13
- return R[t];
12
+ function M(t) {
13
+ return x[t];
14
14
  }
15
15
  function G(t) {
16
- return R = Object.freeze({
17
- ...R,
16
+ return x = Object.freeze({
17
+ ...x,
18
18
  ...t
19
19
  }), Object.keys(t).forEach((e) => {
20
20
  const r = e;
21
- Me.dispatchEvent(new CustomEvent(r, { detail: t[r] }));
22
- }), R;
21
+ we.dispatchEvent(new CustomEvent(r, { detail: t[r] }));
22
+ }), x;
23
23
  }
24
- const Me = new EventTarget();
25
- var ee = (t, e, r) => {
24
+ const we = new EventTarget();
25
+ var Z = (t, e, r) => {
26
26
  if (!e.has(t))
27
27
  throw TypeError("Cannot " + r);
28
- }, T = (t, e, r) => (ee(t, e, "read from private field"), r ? r.call(t) : e.get(t)), F = (t, e, r) => {
28
+ }, S = (t, e, r) => (Z(t, e, "read from private field"), r ? r.call(t) : e.get(t)), R = (t, e, r) => {
29
29
  if (e.has(t))
30
30
  throw TypeError("Cannot add the same private member more than once");
31
31
  e instanceof WeakSet ? e.add(t) : e.set(t, r);
32
- }, B = (t, e, r, s) => (ee(t, e, "write to private field"), s ? s.call(t, r) : e.set(t, r), r), A, C, x, D;
33
- class te {
32
+ }, A = (t, e, r, s) => (Z(t, e, "write to private field"), e.set(t, r), r), P, _, N, D;
33
+ class be {
34
34
  constructor(e) {
35
- F(this, A, void 0), F(this, C, void 0), F(this, x, !1), F(this, D, void 0), B(this, D, new URL(e)), B(this, A, performance.now());
35
+ R(this, P, void 0), R(this, _, !1), R(this, N, void 0), R(this, D, void 0), A(this, D, new URL(e)), this.synchronize();
36
36
  }
37
- now(e = performance.now()) {
38
- if (!T(this, C) || !T(this, A))
39
- throw new ReferenceError(
40
- "Initialization has not been done yet. You need to call and await the synchronize method once."
41
- );
42
- return Number.parseInt(
43
- (T(this, C) + Math.abs(T(this, A) - e)).toFixed(0),
44
- 10
45
- );
37
+ /**
38
+ * Returns the current time adjusted to server-time.
39
+ *
40
+ * @param clientCurrentTime The current time on the client side. Defaults to Date.now().
41
+ * @returns The current adjusted time (or the client time if not synced yet).
42
+ */
43
+ // eslint-disable-next-line no-restricted-syntax
44
+ now(e = Date.now()) {
45
+ return !S(this, N) || !S(this, P) ? (console.warn("TrueTime is not yet synchronized"), e) : S(this, N) + (e - S(this, P));
46
46
  }
47
47
  /**
48
- * Use this method to synchronize time with the server.
48
+ * Synchronizes the client's time with the server's time.
49
+ * If the client's time is already synchronized within an hour, this method does nothing.
49
50
  *
50
- * @param url - server url
51
+ * @returns {Promise<void>} A promise that resolves when the synchronization is complete.
51
52
  */
52
53
  async synchronize() {
53
- if (!T(this, x))
54
+ if (!(S(this, P) && // eslint-disable-next-line no-restricted-syntax
55
+ Math.abs(Date.now() - S(this, P)) < 36e5 || S(this, _))) {
56
+ A(this, _, !0);
54
57
  try {
55
- const e = await fetch(T(this, D));
56
- e.ok && e.headers.has("date") && (B(this, C, new Date(e.headers.get("date")).getTime()), B(this, x, !0));
58
+ const e = await fetch(S(this, D));
59
+ e.ok && e.headers.has("date") && (A(this, N, new Date(e.headers.get("date")).getTime()), A(this, P, Date.now()));
57
60
  } catch (e) {
58
61
  console.error(e);
59
62
  }
63
+ A(this, _, !1);
64
+ }
60
65
  }
66
+ /**
67
+ * Returns the timestamp of a performance mark with the specified name and detail.
68
+ * PS: `performance.mark` must be called with `startTime: trueTime.now()`.
69
+ *
70
+ * @param markName - The name of the performance mark.
71
+ * @param detail - Optional. The detail of the performance mark.
72
+ * @returns The timestamp of the performance mark, or undefined if not found.
73
+ * @throws ReferenceError if the performance mark is not found.
74
+ */
61
75
  timestamp(e, r) {
62
76
  let s;
63
77
  if (r) {
@@ -67,18 +81,17 @@ class te {
67
81
  );
68
82
  } else
69
83
  s = performance.getEntriesByName(e).pop();
70
- return s ? this.now(s.startTime) : void 0;
84
+ return s ? s.startTime : void 0;
71
85
  }
72
86
  }
73
- A = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap();
74
- new te("https://api.tidal.com/v1/ping");
75
- const b = new te("https://api.tidal.com/v1/ping"), K = (t, e, r) => {
87
+ P = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap();
88
+ const y = new be("https://api.tidal.com/v1/ping"), Q = (t, e, r) => {
76
89
  for (const s of t) {
77
90
  const n = s.addedNodes[0];
78
91
  s.type === "childList" && n.id === e && r();
79
92
  }
80
93
  };
81
- function Ee() {
94
+ function ve() {
82
95
  const t = document.getElementById("tidal-player-root");
83
96
  if (!t)
84
97
  return Promise.reject("No player root");
@@ -88,59 +101,59 @@ function Ee() {
88
101
  return "video-one" in t.children || e.push(
89
102
  new Promise((r) => {
90
103
  new MutationObserver(
91
- (s) => K(s, "video-one", r)
104
+ (s) => Q(s, "video-one", r)
92
105
  ).observe(t, { childList: !0 });
93
106
  })
94
107
  ), "video-two" in t.children || e.push(
95
108
  new Promise((r) => {
96
109
  new MutationObserver(
97
- (s) => K(s, "video-two", r)
110
+ (s) => Q(s, "video-two", r)
98
111
  ).observe(t, { childList: !0 });
99
112
  })
100
113
  ), Promise.all(e);
101
114
  }
102
- const E = document.createElement("video"), P = document.createElement("video"), re = (t) => {
115
+ const T = document.createElement("video"), I = document.createElement("video"), ee = (t) => {
103
116
  t.setAttribute("crossorigin", "anonymous"), t.setAttribute("playsinline", "playsinline");
104
117
  };
105
- re(E);
106
- E.id = "video-one";
107
- re(P);
108
- P.id = "video-two";
109
- const U = "tidal-player-root";
110
- function Pe() {
111
- let t = document.getElementById(U);
118
+ ee(T);
119
+ T.id = "video-one";
120
+ ee(I);
121
+ I.id = "video-two";
122
+ const W = "tidal-player-root";
123
+ function Se() {
124
+ let t = document.getElementById(W);
112
125
  if (!t) {
113
126
  const e = document.createElement("template");
114
- e.id = U, document.body.appendChild(e), t = document.getElementById(U);
127
+ e.id = W, document.body.appendChild(e), t = document.getElementById(W);
115
128
  }
116
- return Te();
129
+ return ke();
117
130
  }
118
- function Te() {
131
+ function ke() {
119
132
  const t = document.getElementById(
120
- U
133
+ W
121
134
  );
122
- return t && (E.id in t.children || t.appendChild(E), P.id in t.children || t.appendChild(P)), Ee();
135
+ return t && (T.id in t.children || t.appendChild(T), I.id in t.children || t.appendChild(I)), ve();
123
136
  }
124
- function Ie() {
137
+ function Me() {
125
138
  return new Promise(
126
139
  (t) => document.addEventListener(
127
140
  "click",
128
141
  () => {
129
- E.readyState === HTMLMediaElement.HAVE_NOTHING && !E.src && E.load(), P.readyState === HTMLMediaElement.HAVE_NOTHING && !P.src && P.load(), t();
142
+ T.readyState === HTMLMediaElement.HAVE_NOTHING && !T.src && T.load(), I.readyState === HTMLMediaElement.HAVE_NOTHING && !I.src && I.load(), t();
130
143
  },
131
144
  { once: !0 }
132
145
  )
133
146
  );
134
147
  }
135
- function Le(t) {
148
+ function Ee(t) {
136
149
  return new Promise((e) => setTimeout(() => e(), t));
137
150
  }
138
- function Oe(t, e) {
151
+ function Pe(t, e) {
139
152
  return new Promise((r) => {
140
153
  t.addEventListener(e, (s) => r(s), !1);
141
154
  });
142
155
  }
143
- class Ae extends EventTarget {
156
+ class Te extends EventTarget {
144
157
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
145
158
  // @ts-ignore - Setter
146
159
  #e;
@@ -170,7 +183,7 @@ class Ae extends EventTarget {
170
183
  return this.#e;
171
184
  }
172
185
  }
173
- class W extends Error {
186
+ class V extends Error {
174
187
  errorCode = null;
175
188
  errorId = null;
176
189
  referenceId;
@@ -188,19 +201,19 @@ class W extends Error {
188
201
  return JSON.stringify(this.toJSON());
189
202
  }
190
203
  }
191
- async function N() {
204
+ async function B() {
192
205
  if (v.credentialsProvider) {
193
206
  const t = await v.credentialsProvider.getCredentials();
194
207
  return !!(t.token && t.userId);
195
208
  }
196
- return await Oe(v, "authorized"), N();
209
+ return await Pe(v, "authorized"), B();
197
210
  }
198
- const v = new Ae();
199
- async function Ce() {
200
- const t = await N(), e = async () => {
201
- const { Pushkin: s } = await Promise.resolve().then(() => Lt);
211
+ const v = new Te();
212
+ async function Ie() {
213
+ const t = await B(), e = async () => {
214
+ const { Pushkin: s } = await Promise.resolve().then(() => Et);
202
215
  return s.refresh();
203
- }, r = async () => (await Promise.resolve().then(() => ft)).start();
216
+ }, r = async () => (await Promise.resolve().then(() => ut)).start();
204
217
  if (t) {
205
218
  G({
206
219
  gatherEvents: !0
@@ -216,12 +229,12 @@ async function Ce() {
216
229
  });
217
230
  }
218
231
  v.addEventListener("authorized", () => {
219
- Ce().then().catch(console.error);
232
+ Ie().then().catch(console.error);
220
233
  });
221
- async function Y() {
234
+ async function K() {
222
235
  return v.credentialsProvider ? (await v.credentialsProvider.getCredentials()).token ?? null : null;
223
236
  }
224
- class _e extends EventTarget {
237
+ class Le extends EventTarget {
225
238
  dispatchError(e) {
226
239
  this.dispatchEvent(
227
240
  new CustomEvent("error", {
@@ -230,10 +243,10 @@ class _e extends EventTarget {
230
243
  );
231
244
  }
232
245
  }
233
- const h = new _e();
234
- class Ne {
246
+ const h = new Le();
247
+ class Oe {
235
248
  #e = /* @__PURE__ */ new Map();
236
- #r = /* @__PURE__ */ new Map();
249
+ #t = /* @__PURE__ */ new Map();
237
250
  #s = /* @__PURE__ */ new Map();
238
251
  /**
239
252
  * Clones a session to re-use the media product and playback content for a new session.
@@ -271,7 +284,7 @@ class Ne {
271
284
  * @see {@link StreamingSessionStore.clone}
272
285
  */
273
286
  deleteSession(e) {
274
- this.deleteMediaProductTransition(e), this.#r.delete(e), this.deleteStreamInfo(e);
287
+ this.deleteMediaProductTransition(e), this.#t.delete(e), this.deleteStreamInfo(e);
275
288
  }
276
289
  deleteStreamInfo(e) {
277
290
  this.#s.delete(e);
@@ -280,7 +293,7 @@ class Ne {
280
293
  return e ? this.#e.get(e) : void 0;
281
294
  }
282
295
  getPlaybackInfo(e) {
283
- return e ? this.#r.get(e) : void 0;
296
+ return e ? this.#t.get(e) : void 0;
284
297
  }
285
298
  getStreamInfo(e) {
286
299
  return e ? this.#s.get(e) : void 0;
@@ -289,14 +302,17 @@ class Ne {
289
302
  return this.#e.has(e);
290
303
  }
291
304
  hasPlaybackInfo(e) {
292
- return this.#r.has(e);
305
+ return this.#t.has(e);
293
306
  }
294
307
  hasStreamInfo(e) {
295
308
  return this.#s.has(e);
296
309
  }
297
310
  overwriteDuration(e, r) {
298
311
  const s = this.#e.get(e);
299
- s && (s.playbackContext.actualDuration = r, this.saveMediaProductTransition(e, s));
312
+ s && (s.playbackContext = {
313
+ ...s.playbackContext,
314
+ actualDuration: r
315
+ }, this.saveMediaProductTransition(e, s));
300
316
  }
301
317
  saveMediaProductTransition(e, r) {
302
318
  this.#e.set(
@@ -305,18 +321,18 @@ class Ne {
305
321
  );
306
322
  }
307
323
  savePlaybackInfo(e, r) {
308
- this.#r.set(e, r);
324
+ this.#t.set(e, r);
309
325
  }
310
326
  saveStreamInfo(e, r) {
311
327
  this.#s.set(e, r);
312
328
  }
313
329
  }
314
- const Q = new Ne();
315
- class Fe {
330
+ const q = new Oe();
331
+ class Ae {
316
332
  activePlayer;
317
333
  preloadPlayer;
318
334
  get preloadedMediaProduct() {
319
- return Q.getMediaProductTransition(
335
+ return q.getMediaProductTransition(
320
336
  this.preloadedStreamingSessionId
321
337
  )?.mediaProduct ?? void 0;
322
338
  }
@@ -324,171 +340,200 @@ class Fe {
324
340
  return this.preloadPlayer?.preloadedStreamingSessionId ?? void 0;
325
341
  }
326
342
  }
327
- const p = new Fe();
328
- let Be;
329
- const Re = [
343
+ const p = new Ae();
344
+ let Ce;
345
+ const _e = [
330
346
  {
331
347
  itemTypes: ["track", "video"],
332
348
  player: "shaka",
333
349
  qualities: ["HIGH", "LOSSLESS", "LOW", "HI_RES_LOSSLESS"]
334
350
  }
335
351
  ];
336
- let q = Re;
352
+ let H = _e;
337
353
  const w = {
338
354
  browser: void 0,
339
355
  native: void 0,
340
356
  shaka: void 0
341
357
  };
342
- async function xe() {
358
+ async function Ne() {
343
359
  await Promise.all(
344
- q.map((t) => {
360
+ H.map((t) => {
345
361
  const e = w[t.player];
346
362
  return e ? e.reset() : Promise.resolve();
347
363
  })
348
364
  ), p.activePlayer = void 0, p.preloadPlayer = void 0;
349
365
  }
350
- function De(t) {
366
+ function Fe(t) {
351
367
  t.name !== "nativePlayer" && w.native && w.native.abandon(), p.activePlayer = t;
352
368
  }
353
- function Ue() {
354
- h.removeEventListener("ended", Be);
369
+ function Be() {
370
+ h.removeEventListener("ended", Ce);
355
371
  }
356
- async function We() {
357
- const { default: t } = await import("./nativePlayer-U375Dfm5-hUK7oXzY.js");
372
+ async function Re() {
373
+ const { default: t } = await import("./nativePlayer-DdpXKE9r-B14o92dS.js");
358
374
  return w.native || (w.native = new t()), w.native;
359
375
  }
360
- async function ze() {
361
- const { default: t } = await import("./browserPlayer-oNOpDVm6-UW0N6pFH.js");
376
+ async function xe() {
377
+ const { default: t } = await import("./browserPlayer-B1V50MdI-D65N_aRN.js");
362
378
  return w.browser || (w.browser = new t()), w.browser;
363
379
  }
364
- async function Ve() {
365
- const { default: t } = await import("./shakaPlayer-izGFLVQr--XUsjgT2.js");
380
+ async function De() {
381
+ const { default: t } = await import("./shakaPlayer-Brgd4rob-DJ5uJTjr.js");
366
382
  return w.shaka || (w.shaka = new t()), w.shaka;
367
383
  }
368
- async function He(t, e) {
369
- const r = q.filter((n) => n.itemTypes.includes(t)).filter(
384
+ async function We(t, e) {
385
+ const r = H.filter((n) => n.itemTypes.includes(t)).filter(
370
386
  (n) => t === "track" && n.qualities && e ? n.qualities.includes(e) : !0
371
387
  );
372
388
  r.length === 0 && console.error(
373
389
  `No player found to handle audio quality "${String(
374
390
  e
375
391
  )}" for product type "${t}" in player config: `,
376
- q
392
+ H
377
393
  );
378
394
  const { player: s } = r[0];
379
395
  switch (s) {
380
396
  case "shaka":
381
- return Ve();
397
+ return De();
382
398
  case "browser":
383
- return ze();
399
+ return xe();
384
400
  case "native":
385
- return We();
401
+ return Re();
386
402
  default:
387
403
  throw new Error("No player found.");
388
404
  }
389
405
  }
390
- function qe() {
406
+ function Ve() {
391
407
  return p.activePlayer?.getPosition() ?? 0;
392
408
  }
393
- function Qe() {
409
+ function ze() {
394
410
  return p.activePlayer?.currentMediaProduct ?? null;
395
411
  }
396
- function $e() {
412
+ function Ue() {
397
413
  const t = p.activePlayer;
398
414
  if (t) {
399
- const e = Q.getMediaProductTransition(
415
+ const e = q.getMediaProductTransition(
400
416
  t.currentStreamingSessionId
401
417
  );
402
418
  if (e)
403
419
  return e.playbackContext;
404
420
  }
405
421
  }
406
- function se() {
422
+ function te() {
407
423
  return p.activePlayer?.playbackState ?? "IDLE";
408
424
  }
409
- function $(t) {
410
- return new Promise((e, r) => {
411
- t.oncomplete = t.onsuccess = () => e(t.result), t.onabort = t.onerror = () => r(t.error);
412
- });
413
- }
414
- function je(t, e) {
415
- const r = indexedDB.open(t);
416
- r.onupgradeneeded = () => r.result.createObjectStore(e);
417
- const s = $(r);
418
- return (n, o) => s.then((a) => o(a.transaction(e, n).objectStore(e)));
419
- }
420
- let V;
421
- function ie() {
422
- return V || (V = je("keyval-store", "keyval")), V;
423
- }
424
- function ne(t, e = ie()) {
425
- return e("readonly", (r) => $(r.get(t)));
426
- }
427
- function ae(t, e, r = ie()) {
428
- return r("readwrite", (s) => (s.put(e, t), $(s.transaction)));
429
- }
430
- async function L(t, e) {
431
- let r = /* @__PURE__ */ new Map(), s;
432
- if (!k("gatherEvents"))
433
- return (n) => Promise.resolve(void 0);
434
- try {
435
- s = await ne(t), s && (r = new Map(s));
436
- } catch (n) {
437
- console.error(n);
425
+ class He {
426
+ #e;
427
+ constructor() {
428
+ this.#e = /* @__PURE__ */ new Map();
438
429
  }
439
- return async (n) => {
440
- const o = r.get(n.streamingSessionId) || e, a = {
441
- ...o,
442
- ...n
443
- };
444
- for (const c of Object.keys(n)) {
445
- const d = c;
446
- Array.isArray(n[d]) && (a[d] = [
447
- ...o[d] || [],
448
- ...n[d] || []
449
- ]);
450
- }
451
- r.set(n.streamingSessionId, a);
430
+ async #t(e, r) {
431
+ const s = new TextEncoder().encode(
432
+ `${e}-${r}`
433
+ ), n = await crypto.subtle.digest("SHA-1", s);
434
+ return Array.from(new Uint8Array(n)).map((o) => o.toString(16).padStart(2, "0")).join("");
435
+ }
436
+ /**
437
+ * Delete a logged event by name and streamingSessionId.
438
+ */
439
+ async delete({
440
+ name: e,
441
+ streamingSessionId: r
442
+ }) {
443
+ const s = await this.#t(
444
+ r,
445
+ e
446
+ );
447
+ this.#e.delete(s);
448
+ }
449
+ /**
450
+ * Get a logged event by name and streamingSessionId.
451
+ */
452
+ async get({
453
+ name: e,
454
+ streamingSessionId: r
455
+ }) {
456
+ const s = await this.#t(
457
+ r,
458
+ e
459
+ );
460
+ return this.#e.get(s);
461
+ }
462
+ /**
463
+ * Adds or updates an event.
464
+ */
465
+ async put(e) {
466
+ const r = await this.#t(
467
+ e.streamingSessionId,
468
+ e.name
469
+ );
470
+ this.#e.set(r, e);
471
+ }
472
+ }
473
+ const $ = new He();
474
+ async function O(t, e) {
475
+ return M("gatherEvents") ? async (r) => {
452
476
  try {
453
- await ae(t, [...r]);
454
- } catch (c) {
455
- console.error(c);
477
+ const s = await $.get({
478
+ name: t,
479
+ streamingSessionId: r.streamingSessionId
480
+ }), n = Object.assign(
481
+ {},
482
+ e,
483
+ s ? s.payload : {},
484
+ r
485
+ );
486
+ for (const o of Object.keys(r)) {
487
+ const a = o;
488
+ Array.isArray(r[a]) && (n[a] = [
489
+ ...e[a] || [],
490
+ ...s && s.payload[a] || [],
491
+ ...r[a] || []
492
+ ]);
493
+ }
494
+ return await $.put({
495
+ name: t,
496
+ payload: n,
497
+ streamingSessionId: r.streamingSessionId
498
+ }), {
499
+ name: t,
500
+ payload: n,
501
+ streamingSessionId: r.streamingSessionId
502
+ };
503
+ } catch (s) {
504
+ console.error(s);
456
505
  }
457
- return {
458
- name: t,
459
- payload: a
460
- };
461
- };
506
+ } : (r) => Promise.resolve(void 0);
462
507
  }
463
- const Ge = {
508
+ const $e = {
464
509
  endReason: "COMPLETE",
465
510
  endTimestamp: 0,
466
511
  errorCode: null,
467
512
  errorMessage: null,
468
513
  startTimestamp: 0,
469
514
  streamingSessionId: ""
470
- }, Ke = await L(
515
+ }, qe = await O(
471
516
  "drm_license_fetch",
472
- Ge
517
+ $e
473
518
  );
474
- function Yt(t) {
475
- return Ke(t);
519
+ function Gt(t) {
520
+ return qe(t);
476
521
  }
477
- const Ye = {
522
+ const je = {
478
523
  endReason: "COMPLETE",
479
524
  endTimestamp: 0,
480
525
  errorCode: null,
481
526
  errorMessage: null,
482
527
  startTimestamp: 0,
483
528
  streamingSessionId: ""
484
- }, Je = await L(
529
+ }, Ge = await O(
485
530
  "playback_info_fetch",
486
- Ye
531
+ je
487
532
  );
488
- function H(t) {
489
- return Je(t);
533
+ function U(t) {
534
+ return Ge(t);
490
535
  }
491
- function Jt(t) {
536
+ function Qt(t) {
492
537
  switch (t) {
493
538
  case "bluetooth":
494
539
  return "BLUETOOTH";
@@ -510,7 +555,7 @@ function Jt(t) {
510
555
  return;
511
556
  }
512
557
  }
513
- const Xe = {
558
+ const Qe = {
514
559
  actualAssetPresentation: "FULL",
515
560
  actualAudioMode: "STEREO",
516
561
  actualProductId: null,
@@ -530,24 +575,24 @@ const Xe = {
530
575
  productType: "TRACK",
531
576
  stalls: [],
532
577
  streamingSessionId: ""
533
- }, Ze = await L(
578
+ }, Ke = await O(
534
579
  "playback_statistics",
535
- Xe
580
+ Qe
536
581
  );
537
582
  function J(t) {
538
- return Ze(t);
583
+ return Ke(t);
539
584
  }
540
- const et = {
585
+ const Je = {
541
586
  streamingSessionId: "",
542
587
  timestamp: 0
543
- }, tt = await L(
588
+ }, Ye = await O(
544
589
  "streaming_session_end",
545
- et
590
+ Je
546
591
  );
547
- function rt(t) {
548
- return tt(t);
592
+ function Xe(t) {
593
+ return Ye(t);
549
594
  }
550
- const st = {
595
+ const Ze = {
551
596
  "Amazon Silk": "amazon_silk",
552
597
  "Android Browser": "android",
553
598
  Bada: "bada",
@@ -587,7 +632,7 @@ const st = {
587
632
  WeChat: "wechat",
588
633
  "Yandex Browser": "yandex",
589
634
  Roku: "roku"
590
- }, oe = {
635
+ }, re = {
591
636
  amazon_silk: "Amazon Silk",
592
637
  android: "Android Browser",
593
638
  bada: "Bada",
@@ -645,7 +690,7 @@ const st = {
645
690
  ChromeOS: "Chrome OS",
646
691
  PlayStation4: "PlayStation 4",
647
692
  Roku: "Roku"
648
- }, S = {
693
+ }, k = {
649
694
  EdgeHTML: "EdgeHTML",
650
695
  Blink: "Blink",
651
696
  Trident: "Trident",
@@ -850,18 +895,18 @@ class i {
850
895
  static compareVersions(e, r, s = !1) {
851
896
  const n = i.getVersionPrecision(e), o = i.getVersionPrecision(r);
852
897
  let a = Math.max(n, o), c = 0;
853
- const d = i.map([e, r], (l) => {
854
- const y = a - i.getVersionPrecision(l), M = l + new Array(y + 1).join(".0");
855
- return i.map(M.split("."), (f) => new Array(20 - f.length).join("0") + f).reverse();
898
+ const l = i.map([e, r], (d) => {
899
+ const b = a - i.getVersionPrecision(d), E = d + new Array(b + 1).join(".0");
900
+ return i.map(E.split("."), (f) => new Array(20 - f.length).join("0") + f).reverse();
856
901
  });
857
902
  for (s && (c = a - Math.min(n, o)), a -= 1; a >= c; ) {
858
- if (d[0][a] > d[1][a])
903
+ if (l[0][a] > l[1][a])
859
904
  return 1;
860
- if (d[0][a] === d[1][a]) {
905
+ if (l[0][a] === l[1][a]) {
861
906
  if (a === c)
862
907
  return 0;
863
908
  a -= 1;
864
- } else if (d[0][a] < d[1][a])
909
+ } else if (l[0][a] < l[1][a])
865
910
  return -1;
866
911
  }
867
912
  }
@@ -928,7 +973,7 @@ class i {
928
973
  * @return {string}
929
974
  */
930
975
  static getBrowserAlias(e) {
931
- return st[e];
976
+ return Ze[e];
932
977
  }
933
978
  /**
934
979
  * Get short version/alias for a browser name
@@ -940,10 +985,10 @@ class i {
940
985
  * @return {string}
941
986
  */
942
987
  static getBrowserTypeByAlias(e) {
943
- return oe[e] || "";
988
+ return re[e] || "";
944
989
  }
945
990
  }
946
- const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
991
+ const u = /version\/(\d+(\.?_?\d+)+)/i, et = [
947
992
  /* Googlebot */
948
993
  {
949
994
  test: [/googlebot/i],
@@ -1342,7 +1387,7 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1342
1387
  };
1343
1388
  }
1344
1389
  }
1345
- ], nt = [
1390
+ ], tt = [
1346
1391
  /* Roku */
1347
1392
  {
1348
1393
  test: [/Roku\/DVP/],
@@ -1495,7 +1540,7 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1495
1540
  };
1496
1541
  }
1497
1542
  }
1498
- ], at = [
1543
+ ], rt = [
1499
1544
  /* Googlebot */
1500
1545
  {
1501
1546
  test: [/googlebot/i],
@@ -1727,7 +1772,7 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1727
1772
  };
1728
1773
  }
1729
1774
  }
1730
- ], ot = [
1775
+ ], st = [
1731
1776
  /* EdgeHTML */
1732
1777
  {
1733
1778
  test(t) {
@@ -1736,11 +1781,11 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1736
1781
  describe(t) {
1737
1782
  if (/\sedg\//i.test(t))
1738
1783
  return {
1739
- name: S.Blink
1784
+ name: k.Blink
1740
1785
  };
1741
1786
  const e = i.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, t);
1742
1787
  return {
1743
- name: S.EdgeHTML,
1788
+ name: k.EdgeHTML,
1744
1789
  version: e
1745
1790
  };
1746
1791
  }
@@ -1750,7 +1795,7 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1750
1795
  test: [/trident/i],
1751
1796
  describe(t) {
1752
1797
  const e = {
1753
- name: S.Trident
1798
+ name: k.Trident
1754
1799
  }, r = i.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, t);
1755
1800
  return r && (e.version = r), e;
1756
1801
  }
@@ -1762,7 +1807,7 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1762
1807
  },
1763
1808
  describe(t) {
1764
1809
  const e = {
1765
- name: S.Presto
1810
+ name: k.Presto
1766
1811
  }, r = i.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, t);
1767
1812
  return r && (e.version = r), e;
1768
1813
  }
@@ -1775,7 +1820,7 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1775
1820
  },
1776
1821
  describe(t) {
1777
1822
  const e = {
1778
- name: S.Gecko
1823
+ name: k.Gecko
1779
1824
  }, r = i.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, t);
1780
1825
  return r && (e.version = r), e;
1781
1826
  }
@@ -1785,7 +1830,7 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1785
1830
  test: [/(apple)?webkit\/537\.36/i],
1786
1831
  describe() {
1787
1832
  return {
1788
- name: S.Blink
1833
+ name: k.Blink
1789
1834
  };
1790
1835
  }
1791
1836
  },
@@ -1794,13 +1839,13 @@ const u = /version\/(\d+(\.?_?\d+)+)/i, it = [
1794
1839
  test: [/(apple)?webkit/i],
1795
1840
  describe(t) {
1796
1841
  const e = {
1797
- name: S.WebKit
1842
+ name: k.WebKit
1798
1843
  }, r = i.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, t);
1799
1844
  return r && (e.version = r), e;
1800
1845
  }
1801
1846
  }
1802
1847
  ];
1803
- class X {
1848
+ class Y {
1804
1849
  /**
1805
1850
  * Create instance of Parser
1806
1851
  *
@@ -1841,7 +1886,7 @@ class X {
1841
1886
  */
1842
1887
  parseBrowser() {
1843
1888
  this.parsedResult.browser = {};
1844
- const e = i.find(it, (r) => {
1889
+ const e = i.find(et, (r) => {
1845
1890
  if (typeof r.test == "function")
1846
1891
  return r.test(this);
1847
1892
  if (r.test instanceof Array)
@@ -1897,7 +1942,7 @@ class X {
1897
1942
  */
1898
1943
  parseOS() {
1899
1944
  this.parsedResult.os = {};
1900
- const e = i.find(nt, (r) => {
1945
+ const e = i.find(tt, (r) => {
1901
1946
  if (typeof r.test == "function")
1902
1947
  return r.test(this);
1903
1948
  if (r.test instanceof Array)
@@ -1944,7 +1989,7 @@ class X {
1944
1989
  */
1945
1990
  parsePlatform() {
1946
1991
  this.parsedResult.platform = {};
1947
- const e = i.find(at, (r) => {
1992
+ const e = i.find(rt, (r) => {
1948
1993
  if (typeof r.test == "function")
1949
1994
  return r.test(this);
1950
1995
  if (r.test instanceof Array)
@@ -1975,7 +2020,7 @@ class X {
1975
2020
  */
1976
2021
  parseEngine() {
1977
2022
  this.parsedResult.engine = {};
1978
- const e = i.find(ot, (r) => {
2023
+ const e = i.find(st, (r) => {
1979
2024
  if (typeof r.test == "function")
1980
2025
  return r.test(this);
1981
2026
  if (r.test instanceof Array)
@@ -2025,24 +2070,24 @@ class X {
2025
2070
  const c = e[a];
2026
2071
  typeof c == "string" ? (n[a] = c, o += 1) : typeof c == "object" && (r[a] = c, s += 1);
2027
2072
  }), s > 0) {
2028
- const a = Object.keys(r), c = i.find(a, (l) => this.isOS(l));
2073
+ const a = Object.keys(r), c = i.find(a, (d) => this.isOS(d));
2029
2074
  if (c) {
2030
- const l = this.satisfies(r[c]);
2031
- if (l !== void 0)
2032
- return l;
2075
+ const d = this.satisfies(r[c]);
2076
+ if (d !== void 0)
2077
+ return d;
2033
2078
  }
2034
- const d = i.find(
2079
+ const l = i.find(
2035
2080
  a,
2036
- (l) => this.isPlatform(l)
2081
+ (d) => this.isPlatform(d)
2037
2082
  );
2038
- if (d) {
2039
- const l = this.satisfies(r[d]);
2040
- if (l !== void 0)
2041
- return l;
2083
+ if (l) {
2084
+ const d = this.satisfies(r[l]);
2085
+ if (d !== void 0)
2086
+ return d;
2042
2087
  }
2043
2088
  }
2044
2089
  if (o > 0) {
2045
- const a = Object.keys(n), c = i.find(a, (d) => this.isBrowser(d, !0));
2090
+ const a = Object.keys(n), c = i.find(a, (l) => this.isBrowser(l, !0));
2046
2091
  if (c !== void 0)
2047
2092
  return this.compareVersion(n[c]);
2048
2093
  }
@@ -2101,7 +2146,7 @@ class X {
2101
2146
  * MIT License | (c) Dustin Diaz 2012-2015
2102
2147
  * MIT License | (c) Denis Demchenko 2015-2019
2103
2148
  */
2104
- class ct {
2149
+ class it {
2105
2150
  /**
2106
2151
  * Creates a {@link Parser} instance
2107
2152
  *
@@ -2118,7 +2163,7 @@ class ct {
2118
2163
  static getParser(e, r = !1) {
2119
2164
  if (typeof e != "string")
2120
2165
  throw new Error("UserAgent should be a string");
2121
- return new X(e, r);
2166
+ return new Y(e, r);
2122
2167
  }
2123
2168
  /**
2124
2169
  * Creates a {@link Parser} instance and runs {@link Parser.getResult} immediately
@@ -2130,13 +2175,13 @@ class ct {
2130
2175
  * const result = Bowser.parse(window.navigator.userAgent);
2131
2176
  */
2132
2177
  static parse(e) {
2133
- return new X(e).getResult();
2178
+ return new Y(e).getResult();
2134
2179
  }
2135
2180
  static get BROWSER_MAP() {
2136
- return oe;
2181
+ return re;
2137
2182
  }
2138
2183
  static get ENGINE_MAP() {
2139
- return S;
2184
+ return k;
2140
2185
  }
2141
2186
  static get OS_MAP() {
2142
2187
  return g;
@@ -2145,17 +2190,17 @@ class ct {
2145
2190
  return m;
2146
2191
  }
2147
2192
  }
2148
- const O = ct.parse(navigator.userAgent), dt = {
2193
+ const C = it.parse(navigator.userAgent), nt = {
2149
2194
  abTestGroup: null,
2150
2195
  abTestName: null,
2151
- browser: O.browser.name ?? null,
2152
- browserVersion: O.browser.version ?? null,
2153
- hardwarePlatform: O.browser.name === "Electron" ? "DESKTOP" : "WEB",
2196
+ browser: C.browser.name ?? null,
2197
+ browserVersion: C.browser.version ?? null,
2198
+ hardwarePlatform: C.browser.name === "Electron" ? "DESKTOP" : "WEB",
2154
2199
  isOfflineModeStart: !1,
2155
2200
  mobileNetworkType: null,
2156
2201
  networkType: "WIFI",
2157
- operatingSystem: O.os.name ?? null,
2158
- operatingSystemVersion: O.os.version ?? null,
2202
+ operatingSystem: C.os.name ?? null,
2203
+ operatingSystemVersion: C.os.version ?? null,
2159
2204
  screenHeight: window.screen.height,
2160
2205
  screenWidth: window.screen.width,
2161
2206
  sessionProductId: "",
@@ -2165,36 +2210,38 @@ const O = ct.parse(navigator.userAgent), dt = {
2165
2210
  startReason: "IMPLICIT",
2166
2211
  streamingSessionId: "",
2167
2212
  timestamp: 0
2168
- }, lt = await L(
2213
+ }, at = await O(
2169
2214
  "streaming_session_start",
2170
- dt
2215
+ nt
2171
2216
  );
2172
- function ut(t) {
2173
- return lt(t);
2217
+ function ot(t) {
2218
+ return at(t);
2174
2219
  }
2175
- function ce(t) {
2220
+ function se(t) {
2176
2221
  const e = `(${t.toString()})();`, r = new Blob([e], { type: "text/javascript" });
2177
2222
  return URL.createObjectURL(r);
2178
2223
  }
2179
- let _;
2180
- async function ht(t) {
2181
- const e = await ne(t.data.eventName), r = new Map(e);
2182
- r.delete(t.data.streamingSessionId), await ae(t.data.eventName, [...r]);
2183
- }
2184
- async function mt() {
2185
- if (!_) {
2186
- const { beacon: t } = await import("./worker-qh_9Fyf6-Li0uY2-a.js");
2187
- _ = new Worker(ce(t)), _.addEventListener("message", (e) => {
2188
- ht(e);
2224
+ let F;
2225
+ async function ct(t) {
2226
+ $.delete({
2227
+ name: t.data.eventName,
2228
+ streamingSessionId: t.data.streamingSessionId
2229
+ });
2230
+ }
2231
+ async function dt() {
2232
+ if (!F) {
2233
+ const { beacon: t } = await import("./worker-DrRlSx4a-BTanKBsS.js");
2234
+ F = new Worker(se(t)), F.addEventListener("message", (e) => {
2235
+ ct(e);
2189
2236
  });
2190
2237
  }
2191
2238
  }
2192
- function pt(t) {
2239
+ function lt(t) {
2193
2240
  return t != null;
2194
2241
  }
2195
- async function de(t, e) {
2242
+ async function ie(t, e) {
2196
2243
  if (t) {
2197
- const r = (await Promise.all(e.events)).filter(pt);
2244
+ const r = (await Promise.all(e.events)).filter(lt);
2198
2245
  e.events = r;
2199
2246
  const { clientId: s, token: n } = await v.credentialsProvider.getCredentials();
2200
2247
  if (!n)
@@ -2202,49 +2249,49 @@ async function de(t, e) {
2202
2249
  const o = {
2203
2250
  ...e,
2204
2251
  accessToken: n,
2205
- apiUrl: k("apiUrl"),
2206
- appVersion: k("appVersion"),
2252
+ apiUrl: M("apiUrl"),
2253
+ appVersion: M("appVersion"),
2207
2254
  clientId: s,
2208
- clientPlatform: k("clientPlatform"),
2209
- eventUrl: k("eventUrl"),
2210
- ts: b.now()
2255
+ clientPlatform: M("clientPlatform"),
2256
+ eventUrl: M("eventUrl"),
2257
+ ts: y.now()
2211
2258
  };
2212
2259
  return t.postMessage(JSON.stringify(o)), o;
2213
2260
  } else
2214
2261
  console.warn("Event beacon is not running.");
2215
2262
  }
2216
- const ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2263
+ const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2217
2264
  __proto__: null,
2218
- commit: de,
2219
- start: mt,
2265
+ commit: ie,
2266
+ start: dt,
2220
2267
  get worker() {
2221
- return _;
2268
+ return F;
2222
2269
  },
2223
- workerize: ce
2270
+ workerize: se
2224
2271
  }, Symbol.toStringTag, { value: "Module" }));
2225
- async function gt(t) {
2226
- if (await N())
2272
+ async function ht(t) {
2273
+ if (await B())
2227
2274
  return t();
2228
2275
  }
2229
- function le(t) {
2230
- return gt(
2231
- () => de(_, {
2276
+ function ne(t) {
2277
+ return ht(
2278
+ () => ie(F, {
2232
2279
  type: "streaming_metrics",
2233
2280
  ...t
2234
2281
  })
2235
2282
  );
2236
2283
  }
2237
- function wt(t = !0) {
2284
+ function mt(t = !0) {
2238
2285
  const e = t && "crypto" in window && "getRandomValues" in crypto;
2239
- return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(
2240
- /[018]/g,
2241
- (r) => (r ^ (e ? crypto.getRandomValues(new Uint8Array(1))[0] : Math.floor(256 * Math.random())) & 15 >> r / 4).toString(16)
2242
- );
2286
+ return ("10000000-1000-4000-8000" + -1e11).replace(/[018]/g, (r) => {
2287
+ const s = e ? crypto.getRandomValues(new Uint8Array(1))[0] : Math.floor(256 * Math.random());
2288
+ return (r ^ (s ?? 0) & 15 >> r / 4).toString(16);
2289
+ });
2243
2290
  }
2244
- function yt(t) {
2291
+ function pt(t) {
2245
2292
  return JSON.parse(atob(t));
2246
2293
  }
2247
- function bt(t, e) {
2294
+ function ft(t, e) {
2248
2295
  if ("codecs" in t)
2249
2296
  switch (t.codecs) {
2250
2297
  case "aac":
@@ -2275,7 +2322,7 @@ function bt(t, e) {
2275
2322
  }
2276
2323
  return "none";
2277
2324
  }
2278
- function vt(t) {
2325
+ function gt(t) {
2279
2326
  switch (t) {
2280
2327
  case "mp3":
2281
2328
  return "mp3";
@@ -2291,17 +2338,17 @@ function vt(t) {
2291
2338
  return;
2292
2339
  }
2293
2340
  }
2294
- function St(t) {
2341
+ function yt(t) {
2295
2342
  const e = /codecs=(["'])?((?:.(?!\1|>))*.?)\1?/.exec(t);
2296
2343
  if (e === null)
2297
2344
  return;
2298
- const r = e[2];
2345
+ const r = e[2] ?? "";
2299
2346
  if (r.includes("mp4a") || r.includes("aac"))
2300
2347
  return "aac";
2301
2348
  if (r === "mqa" || r === "flac")
2302
2349
  return r;
2303
2350
  }
2304
- function kt(t) {
2351
+ function wt(t) {
2305
2352
  const { prefetched: e, streamingSessionId: r } = t, s = "albumReplayGain" in t ? {
2306
2353
  albumPeakAmplitude: t.albumPeakAmplitude,
2307
2354
  albumReplayGain: t.albumReplayGain,
@@ -2314,20 +2361,20 @@ function kt(t) {
2314
2361
  type: "trackId" in t ? "track" : "video"
2315
2362
  };
2316
2363
  if (t.manifestMimeType === "application/vnd.tidal.bts" || t.manifestMimeType === "application/vnd.tidal.emu") {
2317
- const a = yt(t.manifest), c = a.urls[0], d = bt(
2364
+ const a = pt(t.manifest), c = a.urls[0], l = ft(
2318
2365
  a,
2319
2366
  "audioQuality" in t ? t.audioQuality : null
2320
2367
  );
2321
- let l;
2322
- return "keyId" in a && (l = a.keyId), "licenseSecurityToken" in t && (l = t.licenseSecurityToken), {
2368
+ let d;
2369
+ return "keyId" in a && (d = a.keyId), "licenseSecurityToken" in t && (d = t.licenseSecurityToken), {
2323
2370
  ...s,
2324
2371
  bitDepth: "bitDepth" in t ? t.bitDepth ?? void 0 : void 0,
2325
- codec: vt(d),
2372
+ codec: gt(l),
2326
2373
  prefetched: e,
2327
2374
  quality: n,
2328
2375
  sampleRate: "sampleRate" in t ? t.sampleRate ?? void 0 : void 0,
2329
- securityToken: l,
2330
- streamFormat: d,
2376
+ securityToken: d,
2377
+ streamFormat: l,
2331
2378
  streamUrl: c,
2332
2379
  streamingSessionId: r,
2333
2380
  ...o,
@@ -2339,7 +2386,7 @@ function kt(t) {
2339
2386
  return {
2340
2387
  ...s,
2341
2388
  bitDepth: "bitDepth" in t ? t.bitDepth ?? void 0 : void 0,
2342
- codec: St(c),
2389
+ codec: yt(c),
2343
2390
  prefetched: e,
2344
2391
  quality: n,
2345
2392
  sampleRate: "sampleRate" in t ? t.sampleRate ?? void 0 : void 0,
@@ -2354,7 +2401,7 @@ function kt(t) {
2354
2401
  `${t.manifestMimeType} not supported as playback info manifest mime type.`
2355
2402
  );
2356
2403
  }
2357
- const ue = async (t, e = {}, r = 3) => {
2404
+ const ae = async (t, e = {}, r = 3) => {
2358
2405
  let s, n;
2359
2406
  try {
2360
2407
  s = await fetch(t, e);
@@ -2372,13 +2419,13 @@ const ue = async (t, e = {}, r = 3) => {
2372
2419
  `Retrying request for ${Math.abs(
2373
2420
  4 - r
2374
2421
  )}th time in ${c}ms`
2375
- ), await Le(c), ue(t, e, r - 1);
2422
+ ), await Ee(c), ae(t, e, r - 1);
2376
2423
  }
2377
2424
  if (!s)
2378
2425
  throw new Error("Retries exchaused. Cannot fetch playbackinfo.");
2379
2426
  return s;
2380
2427
  };
2381
- function Mt(t, e) {
2428
+ function bt(t, e) {
2382
2429
  switch (e) {
2383
2430
  case 4032:
2384
2431
  case 4035:
@@ -2390,7 +2437,7 @@ function Mt(t, e) {
2390
2437
  }
2391
2438
  return t >= 500 && t < 600 || t === 429 ? "PERetryable" : t >= 400 && t < 500 ? "PENotAllowed" : "EUnexpected";
2392
2439
  }
2393
- async function Et(t) {
2440
+ async function vt(t) {
2394
2441
  const {
2395
2442
  accessToken: e,
2396
2443
  audioQuality: r,
@@ -2398,18 +2445,18 @@ async function Et(t) {
2398
2445
  mediaProduct: n,
2399
2446
  prefetch: o,
2400
2447
  streamingSessionId: a
2401
- } = t, c = k("apiUrl"), d = new URL(
2448
+ } = t, c = M("apiUrl"), l = new URL(
2402
2449
  `${c}/${n.productType}s/${n.productId}/playbackinfo`
2403
- ), l = d.searchParams;
2404
- n.productType === "video" ? l.set("videoquality", "HIGH") : l.set("audioquality", r), l.set("playbackmode", "STREAM"), l.set("assetpresentation", "FULL");
2405
- const y = new Headers();
2406
- o && y.set("x-tidal-prefetch", "true"), s && y.set("x-tidal-token", s), e && y.set("authorization", "Bearer " + e), a && y.set("x-tidal-streamingsessionid", a);
2407
- let M;
2450
+ ), d = l.searchParams;
2451
+ n.productType === "video" ? d.set("videoquality", "HIGH") : d.set("audioquality", r), d.set("playbackmode", "STREAM"), d.set("assetpresentation", "FULL");
2452
+ const b = new Headers();
2453
+ o && b.set("x-tidal-prefetch", "true"), s && b.set("x-tidal-token", s), e && b.set("authorization", "Bearer " + e), a && b.set("x-tidal-streamingsessionid", a);
2454
+ let E;
2408
2455
  try {
2409
- M = await ue(
2410
- d.toString(),
2456
+ E = await ae(
2457
+ l.toString(),
2411
2458
  {
2412
- headers: y,
2459
+ headers: b,
2413
2460
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2414
2461
  // @ts-ignore - It is a thing.
2415
2462
  importance: "high"
@@ -2417,31 +2464,32 @@ async function Et(t) {
2417
2464
  3
2418
2465
  );
2419
2466
  } catch {
2420
- throw new W("PENetwork", "NPBI0");
2467
+ throw new V("PENetwork", "NPBI0");
2421
2468
  }
2422
- const f = await M.json();
2469
+ const f = await E.json();
2423
2470
  if ("status" in f) {
2424
- const ke = `A${f.subStatus}`;
2425
- throw new W(Mt(f.status, f.subStatus), ke);
2471
+ const ye = `A${f.subStatus}`;
2472
+ throw new V(bt(f.status, f.subStatus), ye);
2426
2473
  }
2427
- const ve = "trackId" in f, Se = "videoId" in f;
2428
- if (!ve && !Se)
2429
- throw new W("EUnexpected", "B9999");
2474
+ const fe = "trackId" in f, ge = "videoId" in f;
2475
+ if (!fe && !ge)
2476
+ throw new V("EUnexpected", "B9999");
2430
2477
  return {
2431
2478
  ...f,
2432
2479
  prefetched: o
2433
2480
  };
2434
2481
  }
2435
- async function Pt(t) {
2482
+ async function St(t) {
2436
2483
  const { streamingSessionId: e } = t, r = [];
2437
2484
  performance.mark("streaming_metrics:playback_info_fetch:startTimestamp", {
2438
- detail: e
2485
+ detail: e,
2486
+ startTime: y.now()
2439
2487
  });
2440
2488
  try {
2441
- const s = await Et(t);
2489
+ const s = await vt(t);
2442
2490
  if (s === void 0)
2443
2491
  throw new Error("Playback info was fetched, but undefined.");
2444
- H({
2492
+ U({
2445
2493
  endReason: "COMPLETE",
2446
2494
  streamingSessionId: e
2447
2495
  }).catch(console.error), s.expires = Date.now() + 36e5;
@@ -2465,36 +2513,38 @@ async function Pt(t) {
2465
2513
  productType: "VIDEO",
2466
2514
  streamingSessionId: e
2467
2515
  }).catch(console.error), performance.mark("streaming_metrics:playback_info_fetch:endTimestamp", {
2468
- detail: e
2516
+ detail: e,
2517
+ startTime: y.now()
2469
2518
  }), s;
2470
2519
  } catch (s) {
2471
2520
  throw performance.mark("streaming_metrics:playback_info_fetch:endTimestamp", {
2472
- detail: e
2473
- }), H({
2521
+ detail: e,
2522
+ startTime: y.now()
2523
+ }), U({
2474
2524
  endReason: "ERROR",
2475
2525
  errorCode: s.message,
2476
2526
  errorMessage: s.stack,
2477
2527
  streamingSessionId: e
2478
2528
  }).catch(console.error), r.push(
2479
- rt({
2529
+ Xe({
2480
2530
  streamingSessionId: e,
2481
- timestamp: b.timestamp(
2531
+ timestamp: y.timestamp(
2482
2532
  "streaming_metrics:playback_info_fetch:endTimestamp"
2483
2533
  )
2484
2534
  })
2485
2535
  ), s;
2486
2536
  } finally {
2487
2537
  r.push(
2488
- H({
2489
- endTimestamp: b.timestamp(
2538
+ U({
2539
+ endTimestamp: y.timestamp(
2490
2540
  "streaming_metrics:playback_info_fetch:endTimestamp"
2491
2541
  ),
2492
- startTimestamp: b.timestamp(
2542
+ startTimestamp: y.timestamp(
2493
2543
  "streaming_metrics:playback_info_fetch:startTimestamp"
2494
2544
  ),
2495
2545
  streamingSessionId: e
2496
2546
  })
2497
- ), le({
2547
+ ), ne({
2498
2548
  events: r
2499
2549
  }).catch(console.error), performance.clearMarks(
2500
2550
  "streaming_metrics:playback_info_fetch:endTimestamp"
@@ -2503,24 +2553,24 @@ async function Pt(t) {
2503
2553
  );
2504
2554
  }
2505
2555
  }
2506
- class he {
2556
+ class oe {
2507
2557
  /**
2508
2558
  * The current time position to restore playback from when connection is back online.
2509
2559
  */
2510
2560
  static #e = 0;
2511
- static #r = !1;
2561
+ static #t = !1;
2512
2562
  /**
2513
2563
  * The media product to restore when connection is back online.
2514
2564
  */
2515
2565
  static #s = null;
2516
- static #t;
2566
+ static #r;
2517
2567
  static #i;
2518
2568
  static #n;
2519
2569
  static disable() {
2520
- this.#r && (this.#t && window.removeEventListener("offline", this.#t, !1), this.#i && window.removeEventListener("online", this.#i, !1), this.#i = void 0, this.#t = void 0, this.#r = !1);
2570
+ this.#t && (this.#r && window.removeEventListener("offline", this.#r, !1), this.#i && window.removeEventListener("online", this.#i, !1), this.#i = void 0, this.#r = void 0, this.#t = !1);
2521
2571
  }
2522
2572
  static enable() {
2523
- this.#r || (this.#i = () => this.#o(), this.#t = () => this.#a(), window.addEventListener("offline", this.#t, !1), window.addEventListener("online", this.#i, !1), this.#r = !0);
2573
+ this.#t || (this.#i = () => this.#o(), this.#r = () => this.#a(), window.addEventListener("offline", this.#r, !1), window.addEventListener("online", this.#i, !1), this.#t = !0);
2524
2574
  }
2525
2575
  static #a() {
2526
2576
  const { activePlayer: e } = p;
@@ -2551,15 +2601,15 @@ class he {
2551
2601
  e && (this.#e = e.currentTime);
2552
2602
  }
2553
2603
  }
2554
- const Tt = "streaming-privileges-revoked";
2555
- function It(t) {
2556
- return new CustomEvent(Tt, {
2604
+ const kt = "streaming-privileges-revoked";
2605
+ function Mt(t) {
2606
+ return new CustomEvent(kt, {
2557
2607
  detail: t
2558
2608
  });
2559
2609
  }
2560
- let I;
2561
- async function me(t) {
2562
- const e = k("apiUrl"), r = await fetch(e + "/rt/connect", {
2610
+ let L;
2611
+ async function ce(t) {
2612
+ const e = M("apiUrl"), r = await fetch(e + "/rt/connect", {
2563
2613
  headers: new Headers({
2564
2614
  Authorization: "Bearer " + t,
2565
2615
  "Content-Type": "application/json"
@@ -2568,18 +2618,18 @@ async function me(t) {
2568
2618
  }), { url: s } = await r.json();
2569
2619
  return s;
2570
2620
  }
2571
- function pe(t) {
2621
+ function de(t) {
2572
2622
  return new Promise((e) => {
2573
2623
  t.addEventListener("open", () => e(), { once: !0 });
2574
2624
  });
2575
2625
  }
2576
2626
  class z {
2577
2627
  #e;
2578
- #r;
2579
- #s;
2580
2628
  #t;
2629
+ #s;
2630
+ #r;
2581
2631
  constructor() {
2582
- this.#t = void 0, this.#r = this.#i(), h.addEventListener("user-action", () => {
2632
+ this.#r = void 0, this.#t = this.#i(), h.addEventListener("user-action", () => {
2583
2633
  this.connected && this.userAction().then().catch(console.error);
2584
2634
  });
2585
2635
  }
@@ -2587,42 +2637,42 @@ class z {
2587
2637
  * Call this method to ensure pushkin is running.
2588
2638
  */
2589
2639
  static async ensure() {
2590
- await N() && (I ? I.connected || await I.reconnect() : I = new z());
2640
+ await B() && (L ? L.connected || await L.reconnect() : L = new z());
2591
2641
  }
2592
2642
  /**
2593
2643
  * Call this method when credentials changes to re-setup pushkin with the new credentials
2594
2644
  */
2595
2645
  static async refresh() {
2596
- if (!await N())
2646
+ if (!await B())
2597
2647
  return;
2598
- const e = await Y();
2599
- I && e && I.reconnect().catch(console.error);
2648
+ const e = await K();
2649
+ L && e && L.reconnect().catch(console.error);
2600
2650
  }
2601
2651
  async #i() {
2602
- const e = await Y();
2652
+ const e = await K();
2603
2653
  if (!e)
2604
2654
  throw new Error("No access token to connect to Pushkin.");
2605
- const r = await me(e);
2606
- r && (this.#t = new WebSocket(r), await pe(this.#t), this.#s = (s) => this.#o(s.data), this.#e = () => this.#a(), this.#t.addEventListener("message", this.#s, !1), this.#t.addEventListener("closed", this.#e, !1), window.addEventListener("online", () => this.#a(), {
2655
+ const r = await ce(e);
2656
+ r && (this.#r = new WebSocket(r), await de(this.#r), this.#s = (s) => this.#o(s.data), this.#e = () => this.#a(), this.#r.addEventListener("message", this.#s, !1), this.#r.addEventListener("closed", this.#e, !1), window.addEventListener("online", () => this.#a(), {
2607
2657
  once: !0
2608
2658
  }));
2609
2659
  }
2610
2660
  async #n(e) {
2611
- if (!this.#t)
2661
+ if (!this.#r)
2612
2662
  throw new Error(
2613
2663
  "No socket connected. Did you forget to call connect method in Pushkin service first?"
2614
2664
  );
2615
- this.#t.readyState !== WebSocket.OPEN && await this.#r, this.#t.send(JSON.stringify(e));
2665
+ this.#r.readyState !== WebSocket.OPEN && await this.#t, this.#r.send(JSON.stringify(e));
2616
2666
  }
2617
2667
  #a() {
2618
- this.#r = this.#i();
2668
+ this.#t = this.#i();
2619
2669
  }
2620
2670
  #o(e) {
2621
2671
  const r = JSON.parse(e);
2622
2672
  switch (r.type) {
2623
2673
  case "PRIVILEGED_SESSION_NOTIFICATION": {
2624
2674
  h.dispatchEvent(
2625
- It(
2675
+ Mt(
2626
2676
  String(r.payload.clientDisplayName)
2627
2677
  )
2628
2678
  ), p.activePlayer?.pause();
@@ -2637,7 +2687,7 @@ class z {
2637
2687
  }
2638
2688
  }
2639
2689
  reconnect() {
2640
- return this.#t ? (this.#s && this.#t.removeEventListener("message", this.#s), this.#e && this.#t.removeEventListener("closed", this.#e), this.#t.close(), this.#r = this.#i(), this.#r) : Promise.resolve();
2690
+ return this.#r ? (this.#s && this.#r.removeEventListener("message", this.#s), this.#e && this.#r.removeEventListener("closed", this.#e), this.#r.close(), this.#t = this.#i(), this.#t) : Promise.resolve();
2641
2691
  }
2642
2692
  /**
2643
2693
  * Call this method to tell Pushkin a user action happened, so it can
@@ -2648,7 +2698,7 @@ class z {
2648
2698
  try {
2649
2699
  await this.#n({
2650
2700
  payload: {
2651
- startedAt: b.now()
2701
+ startedAt: y.now()
2652
2702
  },
2653
2703
  type: "USER_ACTION"
2654
2704
  });
@@ -2657,19 +2707,19 @@ class z {
2657
2707
  }
2658
2708
  }
2659
2709
  get connected() {
2660
- return this.#t && this.#t.readyState === WebSocket.OPEN;
2710
+ return this.#r && this.#r.readyState === WebSocket.OPEN;
2661
2711
  }
2662
2712
  }
2663
- const Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2713
+ const Et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2664
2714
  __proto__: null,
2665
2715
  Pushkin: z,
2666
- fetchWebSocketURL: me,
2667
- socketOpen: pe
2716
+ fetchWebSocketURL: ce,
2717
+ socketOpen: de
2668
2718
  }, Symbol.toStringTag, { value: "Module" }));
2669
- async function Ot() {
2670
- Ue(), he.disable(), await xe();
2719
+ async function Pt() {
2720
+ Be(), oe.disable(), await Ne();
2671
2721
  }
2672
- const At = {
2722
+ const Tt = {
2673
2723
  actions: [],
2674
2724
  actualAssetPresentation: "PREVIEW",
2675
2725
  actualAudioMode: "STEREO",
@@ -2685,50 +2735,56 @@ const At = {
2685
2735
  sourceType: "",
2686
2736
  startAssetPosition: -1,
2687
2737
  startTimestamp: -1
2688
- }, fe = await L(
2738
+ }, le = await O(
2689
2739
  "playback_session",
2690
- At
2740
+ Tt
2691
2741
  );
2692
- function Xt(t) {
2693
- return fe(t);
2742
+ function Kt(t) {
2743
+ return le(t);
2694
2744
  }
2695
- function Zt(t, e) {
2696
- return fe({
2745
+ function Jt(t, e) {
2746
+ return le({
2697
2747
  actions: [e],
2698
2748
  streamingSessionId: t
2699
2749
  });
2700
2750
  }
2701
- async function ge(t, e = 0, r = !1) {
2702
- if (await b.synchronize(), z.ensure().catch(console.error), p.activePlayer?.nextItem && p.activePlayer.nextItem.mediaProduct.productId === t.productId) {
2751
+ async function ue(t, e = 0, r = !1) {
2752
+ if (await y.synchronize(), z.ensure().catch(console.error), p.activePlayer?.nextItem && p.activePlayer.nextItem.mediaProduct.productId === t.productId) {
2703
2753
  const f = p.activePlayer;
2704
2754
  return performance.mark(
2705
2755
  "streaming_metrics:playback_statistics:idealStartTimestamp",
2706
- { detail: p.preloadedStreamingSessionId }
2756
+ {
2757
+ detail: p.preloadedStreamingSessionId,
2758
+ startTime: y.now()
2759
+ }
2707
2760
  ), await f.reset({ keepPreload: !0 }), t.referenceId && p.preloadedStreamingSessionId && f.overwriteMediaProduct(
2708
2761
  p.preloadedStreamingSessionId,
2709
2762
  t
2710
2763
  ), f.skipToPreloadedMediaProduct();
2711
2764
  }
2712
- const s = Ot(), n = wt();
2713
- le({
2765
+ const s = Pt(), n = mt();
2766
+ ne({
2714
2767
  events: [
2715
- ut({
2768
+ ot({
2716
2769
  sessionProductId: t.productId,
2717
2770
  sessionProductType: t.productType === "track" ? "TRACK" : "VIDEO",
2718
2771
  sessionType: "PLAYBACK",
2719
2772
  startReason: "EXPLICIT",
2720
2773
  streamingSessionId: n,
2721
- timestamp: b.now()
2774
+ timestamp: y.now()
2722
2775
  })
2723
2776
  ]
2724
2777
  }).catch(console.error), performance.mark(
2725
2778
  "streaming_metrics:playback_statistics:idealStartTimestamp",
2726
- { detail: n }
2779
+ {
2780
+ detail: n,
2781
+ startTime: y.now()
2782
+ }
2727
2783
  );
2728
- const { clientId: o, token: a } = await v.credentialsProvider.getCredentials(), c = k("streamingWifiAudioQuality");
2729
- let d = null;
2784
+ const { clientId: o, token: a } = await v.credentialsProvider.getCredentials(), c = M("streamingWifiAudioQuality");
2785
+ let l = null;
2730
2786
  try {
2731
- d = await Pt({
2787
+ l = await St({
2732
2788
  accessToken: a,
2733
2789
  audioQuality: c,
2734
2790
  clientId: o,
@@ -2737,25 +2793,25 @@ async function ge(t, e = 0, r = !1) {
2737
2793
  streamingSessionId: n
2738
2794
  });
2739
2795
  } catch (f) {
2740
- f instanceof W && h.dispatchError(f), document.location.href.includes("localhost") && console.error(f);
2796
+ f instanceof V && h.dispatchError(f), document.location.href.includes("localhost") && console.error(f);
2741
2797
  }
2742
- if (!d)
2798
+ if (!l)
2743
2799
  return;
2744
- const l = kt(d);
2745
- Q.saveStreamInfo(
2746
- l.streamingSessionId,
2747
- l
2748
- ), await s, he.enable();
2749
- const y = "trackId" in d ? d.audioQuality : void 0, M = await He(
2800
+ const d = wt(l);
2801
+ q.saveStreamInfo(
2802
+ d.streamingSessionId,
2803
+ d
2804
+ ), await s, oe.enable();
2805
+ const b = "trackId" in l ? l.audioQuality : void 0, E = await We(
2750
2806
  t.productType,
2751
- y
2807
+ b
2752
2808
  );
2753
- return De(M), M.load(
2809
+ return Fe(E), E.load(
2754
2810
  {
2755
2811
  assetPosition: e,
2756
2812
  mediaProduct: t,
2757
- playbackInfo: d,
2758
- streamInfo: l
2813
+ playbackInfo: l,
2814
+ streamInfo: d
2759
2815
  },
2760
2816
  "explicit"
2761
2817
  );
@@ -2763,44 +2819,44 @@ async function ge(t, e = 0, r = !1) {
2763
2819
  h.addEventListener("load", (t) => {
2764
2820
  if (t instanceof CustomEvent) {
2765
2821
  const { currentTime: e, mediaProduct: r } = t.detail;
2766
- ge(r, e).then().catch(console.error);
2822
+ ue(r, e).then().catch(console.error);
2767
2823
  }
2768
2824
  });
2769
- function Ct() {
2825
+ function It() {
2770
2826
  return p.activePlayer?.pause();
2771
2827
  }
2772
- async function _t() {
2773
- await b.synchronize();
2828
+ async function Lt() {
2829
+ await y.synchronize();
2774
2830
  const { activePlayer: t } = p;
2775
2831
  return t ? (h.dispatchEvent(new CustomEvent("user-action")), t.play()) : Promise.reject(new Error("No active player"));
2776
2832
  }
2777
- async function Nt(t) {
2833
+ async function Ot(t) {
2778
2834
  const { activePlayer: e } = p;
2779
2835
  return e?.seek(t);
2780
2836
  }
2781
- function er(t) {
2837
+ function Yt(t) {
2782
2838
  v.credentialsProvider = t;
2783
2839
  }
2784
- const Ft = "active-device-changed";
2785
- function tr(t) {
2786
- return new CustomEvent(Ft, {
2840
+ const At = "active-device-changed";
2841
+ function Xt(t) {
2842
+ return new CustomEvent(At, {
2787
2843
  detail: t
2788
2844
  });
2789
2845
  }
2790
- const Bt = "active-device-mode-changed";
2791
- function rr(t) {
2792
- return new CustomEvent(Bt, {
2846
+ const Ct = "active-device-mode-changed";
2847
+ function Zt(t) {
2848
+ return new CustomEvent(Ct, {
2793
2849
  detail: t
2794
2850
  });
2795
2851
  }
2796
- const Rt = "active-device-pass-through-changed";
2797
- function sr(t) {
2798
- return new CustomEvent(Rt, {
2852
+ const _t = "active-device-pass-through-changed";
2853
+ function er(t) {
2854
+ return new CustomEvent(_t, {
2799
2855
  detail: t
2800
2856
  });
2801
2857
  }
2802
- b.synchronize().then().catch(console.error);
2803
- function we() {
2858
+ y.synchronize().then().catch(console.error);
2859
+ function he() {
2804
2860
  const { activePlayer: t } = p;
2805
2861
  if (!t)
2806
2862
  return null;
@@ -2813,10 +2869,19 @@ function we() {
2813
2869
  return null;
2814
2870
  }
2815
2871
  }
2816
- Pe().then().catch(console.error);
2817
- Ie().then().catch(console.error);
2818
- const j = String.raw, xt = String.raw;
2819
- function ye(t) {
2872
+ function Nt() {
2873
+ const t = localStorage.getItem("ssuid");
2874
+ try {
2875
+ t && indexedDB.deleteDatabase("streaming-sessions-" + t);
2876
+ } catch (e) {
2877
+ console.warn(`DB streaming-sessions-${t} could not be deleted`), console.error(e);
2878
+ }
2879
+ }
2880
+ Se().then().catch(console.error);
2881
+ Me().then().catch(console.error);
2882
+ Nt();
2883
+ const j = String.raw, Ft = String.raw;
2884
+ function me(t) {
2820
2885
  if (t === void 0)
2821
2886
  return "0:00";
2822
2887
  const e = parseInt(String(t), 10), r = Math.floor(e / 3600), s = Math.floor((e - r * 3600) / 60), n = e - r * 3600 - s * 60;
@@ -2828,52 +2893,52 @@ function ye(t) {
2828
2893
  o = `${s}:`;
2829
2894
  return o += n < 10 ? `0${n}` : String(n), o;
2830
2895
  }
2831
- function be(t = 0) {
2832
- const e = typeof t == "number" ? t : parseInt(t, 10), r = Math.floor(e / 3600) % 24, s = Math.floor(e / 60) % 60, n = e % 60, o = (c, d) => {
2833
- if (c === 0 && d !== 1)
2896
+ function pe(t = 0) {
2897
+ const e = typeof t == "number" ? t : parseInt(t, 10), r = Math.floor(e / 3600) % 24, s = Math.floor(e / 60) % 60, n = e % 60, o = (c, l) => {
2898
+ if (c === 0 && l !== 1)
2834
2899
  return "";
2835
- let l;
2836
- switch (d) {
2900
+ let d;
2901
+ switch (l) {
2837
2902
  case 0:
2838
- l = "H";
2903
+ d = "H";
2839
2904
  break;
2840
2905
  case 1:
2841
- l = "M";
2906
+ d = "M";
2842
2907
  break;
2843
2908
  default:
2844
- l = "S";
2909
+ d = "S";
2845
2910
  break;
2846
2911
  }
2847
- return `${l}${c}`;
2912
+ return `${d}${c}`;
2848
2913
  };
2849
2914
  return `P${[r, s, n].map(o).join("")}`;
2850
2915
  }
2851
- const Dt = "tidal-current-time";
2852
- class Ut extends HTMLElement {
2916
+ const Bt = "tidal-current-time";
2917
+ class Rt extends HTMLElement {
2853
2918
  #e = void 0;
2854
- #r = /* @__PURE__ */ new Set();
2919
+ #t = /* @__PURE__ */ new Set();
2855
2920
  #s;
2856
- #t;
2921
+ #r;
2857
2922
  #i;
2858
2923
  constructor() {
2859
- super(), this.#i = (e) => this.renderTime(e.target.currentTime), this.#t = () => this.renderTime(0), this.#s = this.#n.bind(this);
2924
+ super(), this.#i = (e) => this.renderTime(e.target.currentTime), this.#r = () => this.renderTime(0), this.#s = this.#n.bind(this);
2860
2925
  }
2861
2926
  #n() {
2862
- const e = we();
2863
- e && this.#e && !this.#r.has(e) && (e.addEventListener("timeupdate", this.#i, !1), this.#r.add(e));
2927
+ const e = he();
2928
+ e && this.#e && !this.#t.has(e) && (e.addEventListener("timeupdate", this.#i, !1), this.#t.add(e));
2864
2929
  }
2865
2930
  connectedCallback() {
2866
2931
  const e = this.attachShadow({ mode: "open" });
2867
2932
  e.innerHTML = "<time></time>";
2868
2933
  const r = e.querySelector("time");
2869
- this.#e === void 0 && r !== null && (this.#e = r), this.renderTime(qe()), h.addEventListener(
2934
+ this.#e === void 0 && r !== null && (this.#e = r), this.renderTime(Ve()), h.addEventListener(
2870
2935
  "media-product-transition",
2871
2936
  this.#s,
2872
2937
  !1
2873
- ), h.addEventListener("ended", this.#t, !1);
2938
+ ), h.addEventListener("ended", this.#r, !1);
2874
2939
  }
2875
2940
  disconnectedCallback() {
2876
- for (let e of this.#r)
2941
+ for (let e of this.#t)
2877
2942
  e.removeEventListener(
2878
2943
  "timeupdate",
2879
2944
  this.#i,
@@ -2883,58 +2948,58 @@ class Ut extends HTMLElement {
2883
2948
  "media-product-transition",
2884
2949
  this.#s,
2885
2950
  !1
2886
- ), h.removeEventListener("ended", this.#t, !1);
2951
+ ), h.removeEventListener("ended", this.#r, !1);
2887
2952
  }
2888
2953
  renderTime(e) {
2889
2954
  const r = Math.floor(e);
2890
- this.#e && (this.#e.textContent = ye(r), this.#e.setAttribute("datetime", be(r)));
2955
+ this.#e && (this.#e.textContent = me(r), this.#e.setAttribute("datetime", pe(r)));
2891
2956
  }
2892
2957
  }
2893
- customElements.define(Dt, Ut);
2894
- const Wt = "tidal-duration-time";
2895
- class zt extends HTMLElement {
2958
+ customElements.define(Bt, Rt);
2959
+ const xt = "tidal-duration-time";
2960
+ class Dt extends HTMLElement {
2896
2961
  #e;
2897
- #r = !1;
2962
+ #t = !1;
2898
2963
  #s;
2899
2964
  constructor() {
2900
2965
  super(), this.#s = (e) => {
2901
2966
  const r = e;
2902
2967
  this.renderTime(r.detail.playbackContext.actualDuration);
2903
- }, this.#t();
2968
+ }, this.#r();
2904
2969
  }
2905
- #t() {
2906
- this.#r || (h.addEventListener(
2970
+ #r() {
2971
+ this.#t || (h.addEventListener(
2907
2972
  "media-product-transition",
2908
2973
  this.#s,
2909
2974
  !1
2910
- ), this.#r = !0);
2975
+ ), this.#t = !0);
2911
2976
  }
2912
2977
  #i() {
2913
2978
  const e = this.attachShadow({ mode: "open" });
2914
2979
  this.#e = document.createElement("time"), e.appendChild(this.#e);
2915
2980
  }
2916
2981
  connectedCallback() {
2917
- this.#t(), this.#i();
2982
+ this.#r(), this.#i();
2918
2983
  const e = parseInt(String(this.textContent), 10), r = Number.isNaN(e) ? 0 : e;
2919
- this.renderTime($e()?.actualDuration ?? r);
2984
+ this.renderTime(Ue()?.actualDuration ?? r);
2920
2985
  }
2921
2986
  disconnectedCallback() {
2922
2987
  h.removeEventListener(
2923
2988
  "media-product-transition",
2924
2989
  this.#s,
2925
2990
  !1
2926
- ), this.#r = !1;
2991
+ ), this.#t = !1;
2927
2992
  }
2928
2993
  renderTime(e) {
2929
2994
  const r = parseInt(e.toFixed(0), 10);
2930
- this.#e && (this.#e.textContent = ye(r), this.#e.setAttribute("datetime", be(r)));
2995
+ this.#e && (this.#e.textContent = me(r), this.#e.setAttribute("datetime", pe(r)));
2931
2996
  }
2932
2997
  }
2933
- customElements.define(Wt, zt);
2934
- const Vt = "tidal-play-trigger";
2935
- class Ht extends HTMLElement {
2998
+ customElements.define(xt, Dt);
2999
+ const Wt = "tidal-play-trigger";
3000
+ class Vt extends HTMLElement {
2936
3001
  #e;
2937
- #r = !1;
3002
+ #t = !1;
2938
3003
  constructor() {
2939
3004
  super(), this.#e = (e) => {
2940
3005
  e.preventDefault(), this.#s().catch(console.error);
@@ -2944,15 +3009,15 @@ class Ht extends HTMLElement {
2944
3009
  return ["product-id", "product-type"];
2945
3010
  }
2946
3011
  async #s() {
2947
- await this.#t(), se() === "PLAYING" ? Ct() : await _t();
3012
+ await this.#r(), te() === "PLAYING" ? It() : await Lt();
2948
3013
  }
2949
- #t() {
2950
- const e = Qe()?.productId ?? void 0;
3014
+ #r() {
3015
+ const e = ze()?.productId ?? void 0;
2951
3016
  if (this.mediaProduct && this.mediaProduct.productId !== e)
2952
- return ge(this.mediaProduct, 0);
3017
+ return ue(this.mediaProduct, 0);
2953
3018
  }
2954
3019
  #i() {
2955
- this.#r || this.addEventListener("click", this.#e, { passive: !0 });
3020
+ this.#t || this.addEventListener("click", this.#e, { passive: !0 });
2956
3021
  }
2957
3022
  #n() {
2958
3023
  const e = this.attachShadow({ mode: "closed" }), r = document.createElement("style");
@@ -2970,7 +3035,7 @@ class Ht extends HTMLElement {
2970
3035
  disconnectedCallback() {
2971
3036
  this.removeEventListener("click", this.#e, {
2972
3037
  passive: !0
2973
- }), this.#r = !1;
3038
+ }), this.#t = !1;
2974
3039
  }
2975
3040
  get mediaProduct() {
2976
3041
  const e = this.getAttribute("product-id");
@@ -2985,8 +3050,8 @@ class Ht extends HTMLElement {
2985
3050
  };
2986
3051
  }
2987
3052
  }
2988
- customElements.define(Vt, Ht);
2989
- const qt = j`
3053
+ customElements.define(Wt, Vt);
3054
+ const zt = j`
2990
3055
  :host {
2991
3056
  display: inline-block;
2992
3057
  }
@@ -3007,22 +3072,22 @@ const qt = j`
3007
3072
  background-color: currentColor;
3008
3073
  pointer-events: none;
3009
3074
  }
3010
- `, Z = {
3075
+ `, X = {
3011
3076
  NO_DURATION: "You need to set duration before you can start/stop the progress bar."
3012
3077
  };
3013
- class Qt extends HTMLElement {
3078
+ class Ut extends HTMLElement {
3014
3079
  #e;
3015
- #r = 1;
3080
+ #t = 1;
3016
3081
  #s = null;
3017
- #t;
3082
+ #r;
3018
3083
  #i;
3019
3084
  #n = /* @__PURE__ */ new Set();
3020
3085
  #a = null;
3021
3086
  #o;
3022
3087
  constructor() {
3023
- super(), this.#t = (e) => {
3088
+ super(), this.#r = (e) => {
3024
3089
  const r = e;
3025
- if (this.duration = r.detail.playbackContext.actualDuration, se() === "PLAYING")
3090
+ if (this.duration = r.detail.playbackContext.actualDuration, te() === "PLAYING")
3026
3091
  try {
3027
3092
  this.start();
3028
3093
  } catch (s) {
@@ -3042,7 +3107,7 @@ class Qt extends HTMLElement {
3042
3107
  #c() {
3043
3108
  this.#n.has("media-product-transition") || (h.addEventListener(
3044
3109
  "media-product-transition",
3045
- this.#t,
3110
+ this.#r,
3046
3111
  !1
3047
3112
  ), this.#n.add("media-product-transition")), this.#n.has("playback-state-change") || (h.addEventListener(
3048
3113
  "playback-state-change",
@@ -3051,9 +3116,9 @@ class Qt extends HTMLElement {
3051
3116
  }
3052
3117
  #d() {
3053
3118
  const e = this.attachShadow({ mode: "closed" });
3054
- e.innerHTML = xt`
3119
+ e.innerHTML = Ft`
3055
3120
  <style>
3056
- ${qt}
3121
+ ${zt}
3057
3122
  </style>
3058
3123
  <div id="wrapper">
3059
3124
  <div id="indicator"></div>
@@ -3071,7 +3136,7 @@ class Qt extends HTMLElement {
3071
3136
  disconnectedCallback() {
3072
3137
  h.removeEventListener(
3073
3138
  "media-product-transition",
3074
- this.#t,
3139
+ this.#r,
3075
3140
  !1
3076
3141
  ), h.removeEventListener(
3077
3142
  "playback-state-change",
@@ -3102,8 +3167,8 @@ class Qt extends HTMLElement {
3102
3167
  * @param {MouseEvent | PointerEvent} event
3103
3168
  */
3104
3169
  handleClick(e) {
3105
- const r = this.getMousePositionAsPercent(e), s = this.#r * r;
3106
- this.currentTime = s, Nt(s / 1e3);
3170
+ const r = this.getMousePositionAsPercent(e), s = this.#t * r;
3171
+ this.currentTime = s, Ot(s / 1e3);
3107
3172
  }
3108
3173
  /**
3109
3174
  * Starts the animation if duration is defined.
@@ -3112,7 +3177,7 @@ class Qt extends HTMLElement {
3112
3177
  */
3113
3178
  start() {
3114
3179
  if (!this.#e)
3115
- throw new Error(Z.NO_DURATION);
3180
+ throw new Error(X.NO_DURATION);
3116
3181
  this.#e.play();
3117
3182
  }
3118
3183
  /**
@@ -3122,7 +3187,7 @@ class Qt extends HTMLElement {
3122
3187
  */
3123
3188
  stop() {
3124
3189
  if (!this.#e)
3125
- throw new Error(Z.NO_DURATION);
3190
+ throw new Error(X.NO_DURATION);
3126
3191
  this.#e.pause();
3127
3192
  }
3128
3193
  /**
@@ -3137,7 +3202,7 @@ class Qt extends HTMLElement {
3137
3202
  * Setting this recrates the animation with the new duraton and pauses the animation.
3138
3203
  */
3139
3204
  set duration(e) {
3140
- this.#r = e * 1e3;
3205
+ this.#t = e * 1e3;
3141
3206
  const r = [
3142
3207
  {
3143
3208
  transform: "translateX(-100%)"
@@ -3147,7 +3212,7 @@ class Qt extends HTMLElement {
3147
3212
  }
3148
3213
  ];
3149
3214
  this.#e = this.#s?.animate(r, {
3150
- duration: this.#r,
3215
+ duration: this.#t,
3151
3216
  iterations: 1
3152
3217
  }), this.#e?.pause();
3153
3218
  }
@@ -3158,9 +3223,9 @@ class Qt extends HTMLElement {
3158
3223
  this.stop(), this.#e && (this.#e.playbackRate = e), this.start();
3159
3224
  }
3160
3225
  }
3161
- const $t = "tidal-progress-bar";
3162
- customElements.define($t, Qt);
3163
- const jt = j`
3226
+ const Ht = "tidal-progress-bar";
3227
+ customElements.define(Ht, Ut);
3228
+ const $t = j`
3164
3229
  :host {
3165
3230
  position: relative;
3166
3231
  display: block;
@@ -3177,13 +3242,13 @@ const jt = j`
3177
3242
  position: relative;
3178
3243
  background-color: black;
3179
3244
  }
3180
- `, Gt = "tidal-video-view";
3181
- class Kt extends HTMLElement {
3245
+ `, qt = "tidal-video-view";
3246
+ class jt extends HTMLElement {
3182
3247
  #e = !1;
3183
- #r;
3248
+ #t;
3184
3249
  #s;
3185
3250
  constructor() {
3186
- super(), this.#r = (e) => {
3251
+ super(), this.#t = (e) => {
3187
3252
  e.detail.mediaProduct.productType === "video" && this.mountPlayer();
3188
3253
  }, this.#s = (e) => {
3189
3254
  const r = e;
@@ -3191,12 +3256,12 @@ class Kt extends HTMLElement {
3191
3256
  "playback-state",
3192
3257
  r.detail.state.toLocaleLowerCase()
3193
3258
  );
3194
- }, this.#t();
3259
+ }, this.#r();
3195
3260
  }
3196
- #t() {
3261
+ #r() {
3197
3262
  this.#e || (h.addEventListener(
3198
3263
  "media-product-transition",
3199
- this.#r,
3264
+ this.#t,
3200
3265
  !1
3201
3266
  ), h.addEventListener(
3202
3267
  "playback-state-change",
@@ -3205,16 +3270,16 @@ class Kt extends HTMLElement {
3205
3270
  ));
3206
3271
  }
3207
3272
  connectedCallback() {
3208
- this.#t();
3273
+ this.#r();
3209
3274
  const e = this.attachShadow({ mode: "closed" }), r = document.createElement("style");
3210
- r.textContent = jt;
3275
+ r.textContent = $t;
3211
3276
  const s = document.createElement("slot");
3212
3277
  e.appendChild(r), e.appendChild(s);
3213
3278
  }
3214
3279
  disconnectedCallback() {
3215
3280
  h.removeEventListener(
3216
3281
  "media-product-transition",
3217
- this.#r,
3282
+ this.#t,
3218
3283
  !1
3219
3284
  ), h.removeEventListener(
3220
3285
  "playback-state-change",
@@ -3223,45 +3288,45 @@ class Kt extends HTMLElement {
3223
3288
  ), this.#e = !0;
3224
3289
  }
3225
3290
  mountPlayer() {
3226
- const e = we();
3291
+ const e = he();
3227
3292
  e && (this.innerHTML = "", this.appendChild(e));
3228
3293
  }
3229
3294
  }
3230
- customElements.define(Gt, Kt);
3295
+ customElements.define(qt, jt);
3231
3296
  export {
3232
- E as A,
3233
- ge as B,
3234
- Me as F,
3235
- Zt as G,
3236
- W as H,
3237
- Te as N,
3238
- P as O,
3239
- b as P,
3240
- Jt as Q,
3241
- Le as R,
3242
- v as S,
3243
- Yt as U,
3244
- er as X,
3245
- L as _,
3246
- Xt as a,
3247
- k as b,
3248
- gt as c,
3249
- _ as d,
3250
- Dt as e,
3251
- Wt as f,
3252
- wt as g,
3253
- ct as h,
3254
- sr as i,
3255
- le as j,
3256
- Q as k,
3297
+ V as $,
3298
+ Kt as A,
3299
+ ke as C,
3300
+ F as D,
3301
+ ne as G,
3302
+ Yt as K,
3303
+ O as N,
3304
+ T as O,
3305
+ v as P,
3306
+ M as S,
3307
+ q as T,
3308
+ Qt as V,
3309
+ Gt as W,
3310
+ Xt as X,
3311
+ Ee as _,
3312
+ I as a,
3313
+ h as b,
3314
+ we as c,
3315
+ Xe as d,
3316
+ Zt as e,
3317
+ ue as f,
3318
+ y as g,
3319
+ ie as h,
3320
+ it as i,
3321
+ Bt as j,
3322
+ xt as k,
3257
3323
  p as l,
3258
- Vt as m,
3259
- J as n,
3260
- rt as o,
3261
- $t as p,
3262
- Gt as q,
3263
- rr as s,
3264
- tr as t,
3265
- de as w,
3266
- h as y
3324
+ mt as m,
3325
+ Wt as n,
3326
+ Ht as o,
3327
+ ht as p,
3328
+ qt as q,
3329
+ er as r,
3330
+ J as s,
3331
+ Jt as z
3267
3332
  };