@applemusic-like-lyrics/core 0.0.11 → 0.0.12

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,17 +1,18 @@
1
1
  import { Container as C } from "@pixi/display";
2
- import { Application as M } from "@pixi/app";
2
+ import { Application as z } from "@pixi/app";
3
3
  import { BlurFilter as y } from "@pixi/filter-blur";
4
- import { ColorMatrixFilter as E } from "@pixi/filter-color-matrix";
5
- import { Texture as z } from "@pixi/core";
6
- import { Sprite as w } from "@pixi/sprite";
7
- import { create as D } from "jss";
8
- import A from "jss-preset-default";
9
- const I = /^(((?<hour>[0-9]+):)?(?<min>[0-9]+):)?(?<sec>[0-9]+([\.:]([0-9]+))?)/;
4
+ import { ColorMatrixFilter as v } from "@pixi/filter-color-matrix";
5
+ import { Texture as A } from "@pixi/core";
6
+ import { Sprite as S } from "@pixi/sprite";
7
+ import { BulgePinchFilter as E } from "@pixi/filter-bulge-pinch";
8
+ import { create as I } from "jss";
9
+ import D from "jss-preset-default";
10
+ const k = /^(((?<hour>[0-9]+):)?(?<min>[0-9]+):)?(?<sec>[0-9]+([\.:]([0-9]+))?)/;
10
11
  function T(h) {
11
- const e = I.exec(h);
12
+ const e = k.exec(h);
12
13
  if (e) {
13
- const t = Number(e.groups?.hour || "0"), n = Number(e.groups?.min || "0"), i = Number(e.groups?.sec.replace(/:/, ".") || "0");
14
- return Math.floor((t * 3600 + n * 60 + i) * 1e3);
14
+ const t = Number(e.groups?.hour || "0"), i = Number(e.groups?.min || "0"), s = Number(e.groups?.sec.replace(/:/, ".") || "0");
15
+ return Math.floor((t * 3600 + i * 60 + s) * 1e3);
15
16
  } else
16
17
  throw new TypeError("时间戳字符串解析失败");
17
18
  }
@@ -20,114 +21,114 @@ function B(h) {
20
21
  h,
21
22
  "application/xml"
22
23
  );
23
- let n = "v1";
24
- for (const l of t.querySelectorAll("ttm\\:agent"))
25
- if (l.getAttribute("type") === "person") {
26
- const s = l.getAttribute("xml:id");
27
- s && (n = s);
24
+ let i = "v1";
25
+ for (const r of t.querySelectorAll("ttm\\:agent"))
26
+ if (r.getAttribute("type") === "person") {
27
+ const n = r.getAttribute("xml:id");
28
+ n && (i = n);
28
29
  }
29
- const i = [];
30
- for (const l of t.querySelectorAll("body p[begin][end]")) {
31
- const s = {
30
+ const s = [];
31
+ for (const r of t.querySelectorAll("body p[begin][end]")) {
32
+ const n = {
32
33
  words: [],
33
- startTime: T(l.getAttribute("begin") ?? "0:0"),
34
- endTime: T(l.getAttribute("end") ?? "0:0"),
34
+ startTime: T(r.getAttribute("begin") ?? "0:0"),
35
+ endTime: T(r.getAttribute("end") ?? "0:0"),
35
36
  translatedLyric: "",
36
37
  romanLyric: "",
37
38
  isBG: !1,
38
- isDuet: l.getAttribute("ttm:agent") !== n
39
+ isDuet: r.getAttribute("ttm:agent") !== i
39
40
  };
40
- let r = null;
41
- for (const a of l.childNodes)
42
- if (a.nodeType === Node.TEXT_NODE) {
43
- const o = a.textContent ?? "";
44
- /^(\s+)$/.test(o) ? s.words.push({
41
+ let a = null;
42
+ for (const l of r.childNodes)
43
+ if (l.nodeType === Node.TEXT_NODE) {
44
+ const o = l.textContent ?? "";
45
+ /^(\s+)$/.test(o) ? n.words.push({
45
46
  word: " ",
46
47
  startTime: 0,
47
48
  endTime: 0
48
- }) : s.words.push({
49
+ }) : n.words.push({
49
50
  word: o,
50
51
  startTime: 0,
51
52
  endTime: 0
52
53
  });
53
- } else if (a.nodeType === Node.ELEMENT_NODE) {
54
- const o = a, c = o.getAttribute("ttm:role");
54
+ } else if (l.nodeType === Node.ELEMENT_NODE) {
55
+ const o = l, c = o.getAttribute("ttm:role");
55
56
  if (o.nodeName === "span" && c)
56
57
  if (c === "x-bg") {
57
- const d = {
58
+ const m = {
58
59
  words: [],
59
- startTime: s.startTime,
60
- endTime: s.endTime,
60
+ startTime: n.startTime,
61
+ endTime: n.endTime,
61
62
  translatedLyric: "",
62
63
  romanLyric: "",
63
64
  isBG: !0,
64
- isDuet: s.isDuet
65
+ isDuet: n.isDuet
65
66
  };
66
- for (const m of o.childNodes)
67
- if (m.nodeType === Node.TEXT_NODE) {
68
- const p = m.textContent ?? "";
69
- /^(\s+)$/.test(p) ? d.words.push({
67
+ for (const p of o.childNodes)
68
+ if (p.nodeType === Node.TEXT_NODE) {
69
+ const d = p.textContent ?? "";
70
+ /^(\s+)$/.test(d) ? m.words.push({
70
71
  word: " ",
71
72
  startTime: 0,
72
73
  endTime: 0
73
- }) : d.words.push({
74
- word: p,
74
+ }) : m.words.push({
75
+ word: d,
75
76
  startTime: 0,
76
77
  endTime: 0
77
78
  });
78
- } else if (m.nodeType === Node.ELEMENT_NODE) {
79
- const p = m, L = p.getAttribute("ttm:role");
80
- if (p.nodeName === "span" && L)
81
- L === "x-translation" ? d.translatedLyric = p.innerHTML.trim() : L === "x-roman" && (d.romanLyric = p.innerHTML.trim());
82
- else if (p.hasAttribute("begin") && p.hasAttribute("end")) {
79
+ } else if (p.nodeType === Node.ELEMENT_NODE) {
80
+ const d = p, g = d.getAttribute("ttm:role");
81
+ if (d.nodeName === "span" && g)
82
+ g === "x-translation" ? m.translatedLyric = d.innerHTML.trim() : g === "x-roman" && (m.romanLyric = d.innerHTML.trim());
83
+ else if (d.hasAttribute("begin") && d.hasAttribute("end")) {
83
84
  const b = {
84
- word: m.textContent,
85
- startTime: T(p.getAttribute("begin")),
86
- endTime: T(p.getAttribute("end"))
85
+ word: p.textContent,
86
+ startTime: T(d.getAttribute("begin")),
87
+ endTime: T(d.getAttribute("end"))
87
88
  };
88
- d.words.push(b);
89
+ m.words.push(b);
89
90
  }
90
91
  }
91
- const u = d.words[0];
92
- d.startTime = u.startTime, u?.word.startsWith("(") && (u.word = u.word.substring(1));
93
- const f = d.words[d.words.length - 1];
94
- d.endTime = f.endTime, f?.word.endsWith(")") && (f.word = f.word.substring(
92
+ const u = m.words[0];
93
+ m.startTime = u.startTime, u?.word.startsWith("(") && (u.word = u.word.substring(1));
94
+ const f = m.words[m.words.length - 1];
95
+ m.endTime = f.endTime, f?.word.endsWith(")") && (f.word = f.word.substring(
95
96
  0,
96
97
  f.word.length - 1
97
- )), r = d;
98
+ )), a = m;
98
99
  } else
99
- c === "x-translation" ? s.translatedLyric = o.innerHTML : c === "x-roman" && (s.romanLyric = o.innerHTML);
100
+ c === "x-translation" ? n.translatedLyric = o.innerHTML : c === "x-roman" && (n.romanLyric = o.innerHTML);
100
101
  else if (o.hasAttribute("begin") && o.hasAttribute("end")) {
101
- const d = {
102
- word: a.textContent ?? "",
102
+ const m = {
103
+ word: l.textContent ?? "",
103
104
  startTime: T(o.getAttribute("begin")),
104
105
  endTime: T(o.getAttribute("end"))
105
106
  };
106
- s.words.push(d);
107
+ n.words.push(m);
107
108
  }
108
109
  }
109
- i.push(s), r && i.push(r);
110
+ s.push(n), a && s.push(a);
110
111
  }
111
- return i;
112
+ return s;
112
113
  }
113
- const ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
114
+ const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
114
115
  __proto__: null,
115
116
  parseTTML: B
116
117
  }, Symbol.toStringTag, { value: "Module" }));
117
- class k extends C {
118
+ class O extends C {
118
119
  time = 0;
119
120
  }
120
- class N {
121
+ class $ {
121
122
  constructor(e) {
122
123
  this.canvas = e;
123
124
  const t = e.getBoundingClientRect();
124
125
  this.canvas.width = t.width * this.currerntRenderScale, this.canvas.height = t.height * this.currerntRenderScale, this.observer = new ResizeObserver(() => {
125
- const n = e.getBoundingClientRect();
126
- this.canvas.width = Math.max(1, n.width), this.canvas.height = Math.max(1, n.height), this.app.renderer.resize(
126
+ const i = e.getBoundingClientRect();
127
+ this.canvas.width = Math.max(1, i.width), this.canvas.height = Math.max(1, i.height), this.app.renderer.resize(
127
128
  this.canvas.width * this.currerntRenderScale,
128
129
  this.canvas.height * this.currerntRenderScale
129
130
  ), this.app.ticker.start(), this.rebuildFilters();
130
- }), this.observer.observe(e), this.app = new M({
131
+ }), this.observer.observe(e), this.app = new z({
131
132
  view: e,
132
133
  resizeTo: this.canvas,
133
134
  powerPreference: "low-power",
@@ -141,17 +142,17 @@ class N {
141
142
  lastContainer = /* @__PURE__ */ new Set();
142
143
  onTick = (e) => {
143
144
  for (const t of this.lastContainer)
144
- t.alpha = Math.max(0, t.alpha - e / 60), t.alpha <= 0 && (this.app.stage.removeChild(t), this.lastContainer.delete(t));
145
+ t.alpha = Math.max(0, t.alpha - e / 60), t.alpha <= 0 && (this.app.stage.removeChild(t), this.lastContainer.delete(t), t.destroy(!0));
145
146
  if (this.curContainer) {
146
147
  this.curContainer.alpha = Math.min(
147
148
  1,
148
149
  this.curContainer.alpha + e / 60
149
150
  );
150
- const [t, n, i, l] = this.curContainer.children, s = Math.max(this.app.screen.width, this.app.screen.height);
151
- t.position.set(this.app.screen.width / 2, this.app.screen.height / 2), n.position.set(
151
+ const [t, i, s, r] = this.curContainer.children, n = Math.max(this.app.screen.width, this.app.screen.height);
152
+ t.position.set(this.app.screen.width / 2, this.app.screen.height / 2), i.position.set(
152
153
  this.app.screen.width / 2.5,
153
154
  this.app.screen.height / 2.5
154
- ), i.position.set(this.app.screen.width / 2, this.app.screen.height / 2), l.position.set(this.app.screen.width / 2, this.app.screen.height / 2), t.width = s * Math.sqrt(2), t.height = t.width, n.width = s * 0.8, n.height = n.width, i.width = s * 0.5, i.height = i.width, l.width = s * 0.25, l.height = l.width, this.curContainer.time += e * this.flowSpeed, t.rotation += e / 1e3 * this.flowSpeed, n.rotation -= e / 500 * this.flowSpeed, i.rotation += e / 1e3 * this.flowSpeed, l.rotation -= e / 750 * this.flowSpeed, i.x = this.app.screen.width / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), i.y = this.app.screen.height / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), l.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), l.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), this.curContainer.alpha >= 1 && this.lastContainer.size === 0 && this.staticMode && this.app.ticker.stop();
155
+ ), s.position.set(this.app.screen.width / 2, this.app.screen.height / 2), r.position.set(this.app.screen.width / 2, this.app.screen.height / 2), t.width = n * Math.sqrt(2), t.height = t.width, i.width = n * 0.8, i.height = i.width, s.width = n * 0.5, s.height = s.width, r.width = n * 0.25, r.height = r.width, this.curContainer.time += e * this.flowSpeed, t.rotation += e / 1e3 * this.flowSpeed, i.rotation -= e / 500 * this.flowSpeed, s.rotation += e / 1e3 * this.flowSpeed, r.rotation -= e / 750 * this.flowSpeed, s.x = this.app.screen.width / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), s.y = this.app.screen.height / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), r.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), r.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), this.curContainer.alpha >= 1 && this.lastContainer.size === 0 && this.staticMode && this.app.ticker.stop();
155
156
  }
156
157
  };
157
158
  flowSpeed = 2;
@@ -178,12 +179,38 @@ class N {
178
179
  ), this.rebuildFilters();
179
180
  }
180
181
  rebuildFilters() {
181
- const e = Math.min(this.canvas.width, this.canvas.height), t = new E();
182
- t.saturate(1.2, !1);
183
- const n = new E();
184
- n.brightness(0.6, !1);
185
- const i = new E();
186
- i.contrast(0.3, !0), this.app.stage.filters = [], this.app.stage.filters.push(new y(5, 1)), this.app.stage.filters.push(new y(10, 1)), this.app.stage.filters.push(new y(20, 2)), this.app.stage.filters.push(new y(40, 2)), e > 512 && this.app.stage.filters.push(new y(80, 2)), e > 768 && this.app.stage.filters.push(new y(160, 4)), e > 768 * 2 && this.app.stage.filters.push(new y(320, 4)), this.app.stage.filters.push(t, n, i), this.app.stage.filters.push(new y(5, 1));
182
+ const e = Math.min(this.canvas.width, this.canvas.height), t = Math.max(this.canvas.width, this.canvas.height), i = new v();
183
+ i.saturate(1.2, !1);
184
+ const s = new v();
185
+ s.brightness(0.6, !1);
186
+ const r = new v();
187
+ r.contrast(0.3, !0), this.app.stage.filters?.forEach((n) => {
188
+ n.destroy();
189
+ }), this.app.stage.filters = [], this.app.stage.filters.push(new y(5, 1)), this.app.stage.filters.push(new y(10, 1)), this.app.stage.filters.push(new y(20, 2)), this.app.stage.filters.push(new y(40, 2)), this.app.stage.filters.push(new y(80, 2)), e > 768 && this.app.stage.filters.push(new y(160, 4)), e > 768 * 2 && this.app.stage.filters.push(new y(320, 4)), this.app.stage.filters.push(i, s, r), this.app.stage.filters.push(new y(5, 1)), Math.random() > 0.5 ? (this.app.stage.filters.push(
190
+ new E({
191
+ radius: (t + e) / 2,
192
+ strength: 1,
193
+ center: [0.25, 1]
194
+ })
195
+ ), this.app.stage.filters.push(
196
+ new E({
197
+ radius: (t + e) / 2,
198
+ strength: 1,
199
+ center: [0.75, 0]
200
+ })
201
+ )) : (this.app.stage.filters.push(
202
+ new E({
203
+ radius: (t + e) / 2,
204
+ strength: 1,
205
+ center: [0.75, 1]
206
+ })
207
+ ), this.app.stage.filters.push(
208
+ new E({
209
+ radius: (t + e) / 2,
210
+ strength: 1,
211
+ center: [0.25, 0]
212
+ })
213
+ ));
187
214
  }
188
215
  /**
189
216
  * 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能
@@ -218,14 +245,33 @@ class N {
218
245
  * @param albumUrl 图片的目标链接
219
246
  */
220
247
  async setAlbumImage(e) {
221
- const t = await z.fromURL(e), n = new k(), i = new w(t), l = new w(t), s = new w(t), r = new w(t);
222
- i.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), s.anchor.set(0.5, 0.5), r.anchor.set(0.5, 0.5), i.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, s.rotation = Math.random() * Math.PI * 2, r.rotation = Math.random() * Math.PI * 2, n.addChild(i, l, s, r), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = n, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0, this.app.ticker.start();
248
+ const t = new Image();
249
+ t.src = e, t.crossOrigin = "anonymous";
250
+ let i = 5, s;
251
+ for (; !s?.baseTexture?.resource?.valid && i > 0; )
252
+ try {
253
+ await t.decode(), s = A.from(t, {
254
+ resourceOptions: {
255
+ autoLoad: !1
256
+ }
257
+ }), await s.baseTexture.resource.load();
258
+ } catch (c) {
259
+ console.warn(
260
+ `failed on loading album image, retrying (${i})`,
261
+ e,
262
+ c
263
+ ), s = void 0, i--;
264
+ }
265
+ if (!s)
266
+ return;
267
+ const r = new O(), n = new S(s), a = new S(s), l = new S(s), o = new S(s);
268
+ n.anchor.set(0.5, 0.5), a.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), o.anchor.set(0.5, 0.5), n.rotation = Math.random() * Math.PI * 2, a.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, o.rotation = Math.random() * Math.PI * 2, r.addChild(n, a, l, o), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = r, this.app.stage.addChild(this.curContainer), this.curContainer.alpha = 0, this.app.ticker.start();
223
269
  }
224
270
  dispose() {
225
- this.observer.disconnect(), this.app.ticker.remove(this.onTick);
271
+ this.observer.disconnect(), this.app.ticker.remove(this.onTick), this.app.destroy(!0);
226
272
  }
227
273
  }
228
- class te extends N {
274
+ class oe extends $ {
229
275
  element;
230
276
  constructor() {
231
277
  const e = document.createElement("canvas");
@@ -238,8 +284,8 @@ class te extends N {
238
284
  super.dispose(), this.element.remove();
239
285
  }
240
286
  }
241
- const O = (h, e) => h.size === e.size && [...h].every((t) => e.has(t));
242
- class S {
287
+ const W = (h, e) => h.size === e.size && [...h].every((t) => e.has(t));
288
+ class w {
243
289
  currentPosition = 0;
244
290
  targetPosition = 0;
245
291
  currentTime = 0;
@@ -253,13 +299,13 @@ class S {
253
299
  }
254
300
  resetSolver() {
255
301
  const e = this.getV(this.currentTime);
256
- this.currentTime = 0, this.currentSolver = $(
302
+ this.currentTime = 0, this.currentSolver = N(
257
303
  this.currentPosition,
258
304
  e,
259
305
  this.targetPosition,
260
306
  0,
261
307
  this.params
262
- ), this.getV = q(this.currentSolver);
308
+ ), this.getV = R(this.currentSolver);
263
309
  }
264
310
  arrived() {
265
311
  return Math.abs(this.targetPosition - this.currentPosition) < 0.01 && this.getV(this.currentTime) < 0.01 && this.queueParams === void 0 && this.queuePosition === void 0;
@@ -291,25 +337,25 @@ class S {
291
337
  return this.currentPosition;
292
338
  }
293
339
  }
294
- function $(h, e, t, n = 0, i) {
295
- const l = i?.soft ?? !1, s = i?.stiffness ?? 100, r = i?.damping ?? 10, a = i?.mass ?? 1, o = t - h;
296
- if (l || 1 <= r / (2 * Math.sqrt(s * a))) {
297
- const c = -Math.sqrt(s / a), d = -c * o - e;
298
- return (u) => (u -= n, u < 0 ? h : t - (o + u * d) * Math.E ** (u * c));
340
+ function N(h, e, t, i = 0, s) {
341
+ const r = s?.soft ?? !1, n = s?.stiffness ?? 100, a = s?.damping ?? 10, l = s?.mass ?? 1, o = t - h;
342
+ if (r || 1 <= a / (2 * Math.sqrt(n * l))) {
343
+ const c = -Math.sqrt(n / l), m = -c * o - e;
344
+ return (u) => (u -= i, u < 0 ? h : t - (o + u * m) * Math.E ** (u * c));
299
345
  } else {
300
346
  const c = Math.sqrt(
301
- 4 * a * s - r ** 2
302
- ), d = (r * o - 2 * a * e) / c, u = 0.5 * c / a, f = -(0.5 * r) / a;
303
- return (m) => (m -= n, m < 0 ? h : t - (Math.cos(m * u) * o + Math.sin(m * u) * d) * Math.E ** (m * f));
347
+ 4 * l * n - a ** 2
348
+ ), m = (a * o - 2 * l * e) / c, u = 0.5 * c / l, f = -(0.5 * a) / l;
349
+ return (p) => (p -= i, p < 0 ? h : t - (Math.cos(p * u) * o + Math.sin(p * u) * m) * Math.E ** (p * f));
304
350
  }
305
351
  }
306
- function _(h) {
352
+ function F(h) {
307
353
  return (t) => (h(t + 1e-3) - h(t - 1e-3)) / (2 * 1e-3);
308
354
  }
309
- function q(h) {
310
- return _(h);
355
+ function R(h) {
356
+ return F(h);
311
357
  }
312
- class F {
358
+ class q {
313
359
  constructor(e) {
314
360
  this.lyricPlayer = e, this.element.setAttribute(
315
361
  "class",
@@ -323,8 +369,8 @@ class F {
323
369
  // 由 LyricPlayer 来设置
324
370
  lineSize = [0, 0];
325
371
  lineTransforms = {
326
- posX: new S(0),
327
- posY: new S(0)
372
+ posX: new w(0),
373
+ posY: new w(0)
328
374
  };
329
375
  measureSize() {
330
376
  return [
@@ -346,21 +392,21 @@ class F {
346
392
  getElement() {
347
393
  return this.element;
348
394
  }
349
- setTransform(e = this.left, t = this.top, n = !1, i = 0) {
350
- this.left = e, this.top = t, this.delay = i * 1e3 | 0, n || !this.lyricPlayer.getEnableSpring() ? (n && this.element.classList.add(
395
+ setTransform(e = this.left, t = this.top, i = !1, s = 0) {
396
+ this.left = e, this.top = t, this.delay = s * 1e3 | 0, i || !this.lyricPlayer.getEnableSpring() ? (i && this.element.classList.add(
351
397
  this.lyricPlayer.style.classes.tmpDisableTransition
352
- ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), n && requestAnimationFrame(() => {
398
+ ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), i && requestAnimationFrame(() => {
353
399
  this.element.classList.remove(
354
400
  this.lyricPlayer.style.classes.tmpDisableTransition
355
401
  );
356
- })) : (this.lineTransforms.posX.setTargetPosition(e, i), this.lineTransforms.posY.setTargetPosition(t, i));
402
+ })) : (this.lineTransforms.posX.setTargetPosition(e, s), this.lineTransforms.posY.setTargetPosition(t, s));
357
403
  }
358
404
  update(e = 0) {
359
405
  this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(e), this.lineTransforms.posY.update(e), this.isInSight ? this.show() : this.hide());
360
406
  }
361
407
  get isInSight() {
362
- const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), n = e + this.lineSize[0], i = t + this.lineSize[1], l = this.lyricPlayer.pos[0], s = this.lyricPlayer.pos[1], r = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], a = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
363
- return !(e > r || t > a || n < l || i < s);
408
+ const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), i = e + this.lineSize[0], s = t + this.lineSize[1], r = this.lyricPlayer.size[0], n = this.lyricPlayer.size[1];
409
+ return !(e > r || t > n || i < 0 || s < 0);
364
410
  }
365
411
  dispose() {
366
412
  this.element.remove();
@@ -370,8 +416,8 @@ function X(h) {
370
416
  const t = 2.5949095;
371
417
  return h < 0.5 ? Math.pow(2 * h, 2) * ((t + 1) * 2 * h - t) / 2 : (Math.pow(2 * h - 2, 2) * ((t + 1) * (h * 2 - 2) + t) + 2) / 2;
372
418
  }
373
- const g = (h, e, t) => Math.max(h, Math.min(e, t));
374
- class R {
419
+ const L = (h, e, t) => Math.max(h, Math.min(e, t));
420
+ class Y {
375
421
  constructor(e) {
376
422
  this.lyricPlayer = e, this.element.className = this.lyricPlayer.style.classes.interludeDots, this.element.appendChild(this.dot0), this.element.appendChild(this.dot1), this.element.appendChild(this.dot2);
377
423
  }
@@ -399,41 +445,41 @@ class R {
399
445
  this.currentTime += e;
400
446
  let t = "";
401
447
  if (t += `transform:translate(${this.left}px, ${this.top}px)`, this.currentInterlude) {
402
- const n = this.currentInterlude[1] - this.currentInterlude[0], i = this.currentTime - this.currentInterlude[0];
403
- if (i <= n) {
404
- const l = n / Math.ceil(n / this.targetBreatheDuration);
405
- let s = 1, r = 1;
406
- s *= Math.sin(1.5 * Math.PI - i / l * 2) / 10 + 1, i < 1e3 && (s *= 1 - Math.pow((1e3 - i) / 1e3, 2)), i < 500 ? r = 0 : i < 1e3 && (r *= (i - 500) / 500), n - i < 750 && (s *= 1 - X(
407
- (750 - (n - i)) / 750 / 2
408
- )), n - i < 375 && (r *= g(
448
+ const i = this.currentInterlude[1] - this.currentInterlude[0], s = this.currentTime - this.currentInterlude[0];
449
+ if (s <= i) {
450
+ const r = i / Math.ceil(i / this.targetBreatheDuration);
451
+ let n = 1, a = 1;
452
+ n *= Math.sin(1.5 * Math.PI - s / r * 2) / 10 + 1, s < 1e3 && (n *= 1 - Math.pow((1e3 - s) / 1e3, 2)), s < 500 ? a = 0 : s < 1e3 && (a *= (s - 500) / 500), i - s < 750 && (n *= 1 - X(
453
+ (750 - (i - s)) / 750 / 2
454
+ )), i - s < 375 && (a *= L(
409
455
  0,
410
- (n - i) / 375,
456
+ (i - s) / 375,
411
457
  1
412
- )), s = Math.max(0, s), t += ` scale(${s})`;
413
- const a = g(
458
+ )), n = Math.max(0, n), t += ` scale(${n})`;
459
+ const l = L(
414
460
  0.25,
415
- i * 3 / n * 0.75,
461
+ s * 3 / i * 0.75,
416
462
  1
417
- ), o = g(
463
+ ), o = L(
418
464
  0.25,
419
- (i - n / 3) * 3 / n * 0.75,
465
+ (s - i / 3) * 3 / i * 0.75,
420
466
  1
421
- ), c = g(
467
+ ), c = L(
422
468
  0.25,
423
- (i - n / 3 * 2) * 3 / n * 0.75,
469
+ (s - i / 3 * 2) * 3 / i * 0.75,
424
470
  1
425
471
  );
426
- this.dot0.style.opacity = `${g(
472
+ this.dot0.style.opacity = `${L(
427
473
  0,
428
- Math.max(0, r * a),
474
+ Math.max(0, a * l),
429
475
  1
430
- )}`, this.dot1.style.opacity = `${g(
476
+ )}`, this.dot1.style.opacity = `${L(
431
477
  0,
432
- Math.max(0, r * o),
478
+ Math.max(0, a * o),
433
479
  1
434
- )}`, this.dot2.style.opacity = `${g(
480
+ )}`, this.dot2.style.opacity = `${L(
435
481
  0,
436
- Math.max(0, r * c),
482
+ Math.max(0, a * c),
437
483
  1
438
484
  )}`;
439
485
  } else
@@ -446,19 +492,34 @@ class R {
446
492
  this.element.remove();
447
493
  }
448
494
  }
449
- const v = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
450
- function W(h, e = "rgba(0,0,0,1)", t = "rgba(0,0,0,0.5)") {
451
- const n = 2 + h, i = h / n, l = (1 - i) / 2;
495
+ const _ = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u;
496
+ function G(h, e = "rgba(0,0,0,1)", t = "rgba(0,0,0,0.5)") {
497
+ const i = 2 + h, s = h / i, r = (1 - s) / 2;
452
498
  return [
453
- `linear-gradient(to right,${e} ${l * 100}%,${t} ${(l + i) * 100}%)`,
454
- i,
455
- n
499
+ `linear-gradient(to right,${e} ${r * 100}%,${t} ${(r + s) * 100}%)`,
500
+ s,
501
+ i
456
502
  ];
457
503
  }
504
+ function H(h, e) {
505
+ let t = [], i = [];
506
+ const s = [];
507
+ for (const r of h) {
508
+ const n = e(r);
509
+ t.push(n), i.push(r), n.length > 0 && n.trim().length === 0 ? (t.pop(), i.pop(), i.length === 1 ? s.push(i[0]) : i.length > 1 && s.push(i), s.push(r), t = [], i = []) : (!/^\s*[^\s]*\s*$/.test(t.join("")) || _.test(n)) && (t.pop(), i.pop(), i.length === 1 ? s.push(i[0]) : i.length > 1 && s.push(i), t = [n], i = [r]);
510
+ }
511
+ return i.length === 1 ? s.push(i[0]) : s.push(i), s;
512
+ }
458
513
  function x(h) {
459
514
  return h.endTime - h.startTime >= 1e3 && h.word.length <= 7;
460
515
  }
461
- class Y {
516
+ class V extends MouseEvent {
517
+ constructor(e, t) {
518
+ super(t.type, t), this.line = e;
519
+ }
520
+ }
521
+ class j extends EventTarget {
522
+ // rome-ignore lint/correctness/noUnreachableSuper: <explanation>
462
523
  constructor(e, t = {
463
524
  words: [],
464
525
  translatedLyric: "",
@@ -468,12 +529,12 @@ class Y {
468
529
  isBG: !1,
469
530
  isDuet: !1
470
531
  }) {
471
- this.lyricPlayer = e, this.lyricLine = t, this.element.setAttribute(
532
+ super(), this.lyricPlayer = e, this.lyricLine = t, this.element.setAttribute(
472
533
  "class",
473
534
  this.lyricPlayer.style.classes.lyricLine
474
535
  ), this.lyricLine.isBG && this.element.classList.add(this.lyricPlayer.style.classes.lyricBgLine), this.lyricLine.isDuet && this.element.classList.add(this.lyricPlayer.style.classes.lyricDuetLine), this.element.appendChild(document.createElement("div")), this.element.appendChild(document.createElement("div")), this.element.appendChild(document.createElement("div"));
475
- const n = this.element.children[0], i = this.element.children[1], l = this.element.children[2];
476
- n.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), i.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), l.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
536
+ const i = this.element.children[0], s = this.element.children[1], r = this.element.children[2];
537
+ i.setAttribute("class", this.lyricPlayer.style.classes.lyricMainLine), s.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), r.setAttribute("class", this.lyricPlayer.style.classes.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
477
538
  }
478
539
  element = document.createElement("div");
479
540
  left = 0;
@@ -485,17 +546,34 @@ class Y {
485
546
  // 由 LyricPlayer 来设置
486
547
  lineSize = [0, 0];
487
548
  lineTransforms = {
488
- posX: new S(0),
489
- posY: new S(0),
490
- scale: new S(1)
549
+ posX: new w(0),
550
+ posY: new w(0),
551
+ scale: new w(1)
552
+ };
553
+ listenersMap = /* @__PURE__ */ new Map();
554
+ onMouseEvent = (e) => {
555
+ if (!this.dispatchEvent(new V(this, e)))
556
+ return e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), !1;
491
557
  };
558
+ addEventListener(e, t, i) {
559
+ if (super.addEventListener(e, t, i), t) {
560
+ const s = this.listenersMap.get(e) ?? /* @__PURE__ */ new Set();
561
+ s.size === 0 && this.element.addEventListener(e, this.onMouseEvent), s.add(t), this.listenersMap.set(e, s);
562
+ }
563
+ }
564
+ removeEventListener(e, t, i) {
565
+ if (super.removeEventListener(e, t, i), t) {
566
+ const s = this.listenersMap.get(e);
567
+ s && (s.delete(t), s.size === 0 && this.element.removeEventListener(e, this.onMouseEvent));
568
+ }
569
+ }
492
570
  isEnabled = !1;
493
571
  enable() {
494
572
  this.isEnabled = !0, this.element.classList.add("active");
495
573
  const e = this.element.children[0];
496
574
  this.splittedWords.forEach((t) => {
497
- t.elementAnimations.forEach((n) => {
498
- n.currentTime = 0, n.playbackRate = 1, n.play();
575
+ t.elementAnimations.forEach((i) => {
576
+ i.currentTime = 0, i.playbackRate = 1, i.play();
499
577
  });
500
578
  }), e.classList.add("active");
501
579
  }
@@ -511,8 +589,8 @@ class Y {
511
589
  this.isEnabled = !1, this.element.classList.remove("active");
512
590
  const e = this.element.children[0];
513
591
  this.splittedWords.forEach((t) => {
514
- t.elementAnimations.forEach((n) => {
515
- n.id === "float-word" && (n.playbackRate = -1, n.play());
592
+ t.elementAnimations.forEach((i) => {
593
+ i.id === "float-word" && (i.playbackRate = -1, i.play());
516
594
  });
517
595
  }), e.classList.remove("active");
518
596
  }
@@ -544,84 +622,84 @@ class Y {
544
622
  !this.lyricPlayer.getEnableSpring() && this.isInSight && (e += `transition-delay:${this.delay}ms;`), e += `filter:blur(${Math.min(32, this.blur)}px);`, e !== this.lastStyle && (this.lastStyle = e, this.element.setAttribute("style", e));
545
623
  }
546
624
  rebuildElement() {
547
- const e = this.element.children[0], t = this.element.children[1], n = this.element.children[2];
625
+ const e = this.element.children[0], t = this.element.children[1], i = this.element.children[2];
548
626
  if (this.lyricPlayer._getIsNonDynamic()) {
549
- for (; e.firstChild; )
550
- e.removeChild(e.firstChild), s(e.firstChild);
551
- e.innerText = this.lyricLine.words.map((a) => a.word).join(""), t.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
627
+ e.innerText = this.lyricLine.words.map((r) => r.word).join(""), t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
552
628
  return;
553
629
  }
554
- this.splittedWords = [], this.lyricLine.words.forEach((a) => {
555
- const o = a.word.split(/\s+/), c = o.reduce((u, f) => u + f.length, 0);
556
- let d = 0;
557
- o.forEach((u, f) => {
558
- f > 0 && this.splittedWords.push({
559
- word: " ",
560
- startTime: 0,
561
- endTime: 0,
562
- width: 0,
563
- height: 0,
564
- elements: [],
565
- elementAnimations: [],
566
- shouldEmphasize: !1
567
- }), this.splittedWords.push({
568
- word: u,
569
- startTime: a.startTime + (a.endTime - a.startTime) / c * d,
570
- endTime: a.startTime + (a.endTime - a.startTime) / c * (d + u.length),
630
+ const s = H(this.lyricLine.words, (r) => r.word);
631
+ e.innerHTML = "", this.splittedWords = [];
632
+ for (const r of s)
633
+ if (r instanceof Array) {
634
+ const n = r.map((o) => x(o)).reduce((o, c) => o || c, !1), a = r.reduce(
635
+ (o, c) => (o.endTime = Math.max(o.endTime, c.endTime), o.startTime = Math.min(o.startTime, c.startTime), o.word += c.word, o),
636
+ { word: "", startTime: 1 / 0, endTime: -1 / 0 }
637
+ ), l = document.createElement("span");
638
+ for (const o of r) {
639
+ const c = document.createElement("span"), m = this.initFloatAnimation(
640
+ a,
641
+ c
642
+ );
643
+ if (n) {
644
+ const u = [];
645
+ for (const p of o.word.trim().split("")) {
646
+ const d = document.createElement("span");
647
+ d.innerText = p, u.push(d), c.appendChild(d);
648
+ }
649
+ const f = {
650
+ ...o,
651
+ mainElement: c,
652
+ subElements: u,
653
+ elementAnimations: [m],
654
+ width: 0,
655
+ height: 0,
656
+ shouldEmphasize: n
657
+ };
658
+ f.elementAnimations.push(
659
+ ...this.initEmphasizeAnimation(f)
660
+ ), this.splittedWords.push(f);
661
+ } else
662
+ c.innerText = o.word, this.splittedWords.push({
663
+ ...o,
664
+ mainElement: c,
665
+ subElements: [],
666
+ elementAnimations: [m],
667
+ width: 0,
668
+ height: 0,
669
+ shouldEmphasize: n
670
+ });
671
+ l.appendChild(c);
672
+ }
673
+ a.word.trimStart() !== a.word && e.appendChild(document.createTextNode(" ")), e.appendChild(l), a.word.trimEnd() !== a.word && e.appendChild(document.createTextNode(" "));
674
+ } else if (r.word.trim().length === 0)
675
+ e.appendChild(document.createTextNode(" "));
676
+ else {
677
+ const n = x(r), a = document.createElement("span"), l = {
678
+ ...r,
679
+ mainElement: a,
680
+ subElements: [],
681
+ elementAnimations: [this.initFloatAnimation(r, a)],
571
682
  width: 0,
572
683
  height: 0,
573
- elements: [],
574
- elementAnimations: [],
575
- shouldEmphasize: x(a)
576
- }), d += u.length;
577
- });
578
- });
579
- const i = [], l = [];
580
- function s(a) {
581
- for (; a.firstChild; )
582
- a.firstChild.nodeType === Node.ELEMENT_NODE ? i.push(e.firstChild) : a.firstChild.nodeType === Node.TEXT_NODE && l.push(e.firstChild), a.removeChild(a.firstChild), s(a.firstChild);
583
- }
584
- s(e);
585
- let r = null;
586
- this.splittedWords.forEach((a) => {
587
- if (a.word.trim().length > 0)
588
- if (a.shouldEmphasize) {
589
- const o = i.pop() ?? document.createElement("span");
590
- o.className = "emphasize", a.elements = [o];
591
- for (const c of a.word) {
592
- const d = i.pop() ?? document.createElement("span");
593
- d.className = "", d.innerText = c, o.appendChild(d), a.elements.push(d);
684
+ shouldEmphasize: n
685
+ };
686
+ if (n) {
687
+ const o = [];
688
+ for (const c of r.word.trim().split("")) {
689
+ const m = document.createElement("span");
690
+ m.innerText = c, o.push(m), a.appendChild(m);
594
691
  }
595
- if (a.elementAnimations = this.initEmphasizeAnimation(a), r && !v.test(a.word))
596
- if (r.childElementCount > 0)
597
- r.appendChild(o);
598
- else {
599
- const c = i.pop() ?? document.createElement("span");
600
- c.className = "", r.remove(), c.appendChild(r), c.appendChild(o), e.appendChild(c), r = c;
601
- }
602
- else
603
- r = v.test(a.word) ? null : o, e.appendChild(o);
604
- } else {
605
- const o = i.pop() ?? document.createElement("span");
606
- if (o.className = "", o.innerText = a.word, a.elements = [o], a.elementAnimations.push(this.initFloatAnimation(a, o)), r)
607
- if (r.childElementCount > 0)
608
- r.appendChild(o);
609
- else {
610
- const c = i.pop() ?? document.createElement("span");
611
- c.className = "", r.remove(), c.appendChild(r), c.appendChild(o), e.appendChild(c), r = c;
612
- }
613
- else
614
- r = o, e.appendChild(o);
615
- }
616
- else if (a.word.length > 0) {
617
- const o = l.pop() ?? document.createTextNode(" ");
618
- e.appendChild(o), r = null;
619
- } else
620
- r = null;
621
- }), t.innerText = this.lyricLine.translatedLyric, n.innerText = this.lyricLine.romanLyric;
692
+ l.subElements = o, l.elementAnimations.push(
693
+ ...this.initEmphasizeAnimation(l)
694
+ );
695
+ } else
696
+ a.innerText = r.word.trim();
697
+ r.word.trimStart() !== r.word && e.appendChild(document.createTextNode(" ")), e.appendChild(a), r.word.trimEnd() !== r.word && e.appendChild(document.createTextNode(" ")), this.splittedWords.push(l);
698
+ }
699
+ t.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
622
700
  }
623
701
  initFloatAnimation(e, t) {
624
- const n = e.startTime - this.lyricLine.startTime, i = Math.max(1e3, e.endTime - e.startTime), l = t.animate(
702
+ const i = e.startTime - this.lyricLine.startTime, s = Math.max(1e3, e.endTime - e.startTime), r = t.animate(
625
703
  [
626
704
  {
627
705
  transform: "translateY(0px)"
@@ -631,101 +709,113 @@ class Y {
631
709
  }
632
710
  ],
633
711
  {
634
- duration: isFinite(i) ? i : 0,
635
- delay: isFinite(n) ? n : 0,
712
+ duration: isFinite(s) ? s : 0,
713
+ delay: isFinite(i) ? i : 0,
636
714
  id: "float-word",
637
715
  composite: "add",
638
716
  fill: "both"
639
717
  }
640
718
  );
641
- return l.pause(), l;
719
+ return r.pause(), r;
642
720
  }
643
721
  initEmphasizeAnimation(e) {
644
- const t = e.startTime - this.lyricLine.startTime, n = e.endTime - e.startTime;
645
- return e.elements.map((i, l, s) => {
646
- if (l === 0)
647
- return this.initFloatAnimation(e, i);
648
- {
649
- const r = Math.max(1e3, e.endTime - e.startTime), a = t + n / (s.length - 1) * (l - 1), o = i.animate(
650
- [
651
- {
652
- offset: 0,
653
- transform: "translate3d(0, 0px, 0px)",
654
- filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
655
- },
656
- {
657
- offset: 0.5,
658
- transform: "translate3d(0, -2%, 20px)",
659
- filter: "drop-shadow(0 0 0.05em var(--amll-lyric-view-color,white))"
660
- },
661
- {
662
- offset: 1,
663
- transform: "translate3d(0, 0px, 0)",
664
- filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
665
- }
666
- ],
722
+ const t = e.startTime - this.lyricLine.startTime, i = e.endTime - e.startTime;
723
+ return e.subElements.map((s, r, n) => {
724
+ const a = Math.max(1e3, e.endTime - e.startTime), l = t + i / n.length * r, o = s.animate(
725
+ [
726
+ {
727
+ offset: 0,
728
+ transform: "translate3d(0, 0, 0px)",
729
+ filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
730
+ },
667
731
  {
668
- duration: isFinite(r) ? r : 0,
669
- delay: isFinite(a) ? a : 0,
670
- id: "glow-word",
671
- iterations: 1,
672
- composite: "replace",
673
- fill: "both"
732
+ offset: 0.5,
733
+ transform: "translate3d(0, -2%, 20px)",
734
+ filter: "drop-shadow(0 0 0.05em var(--amll-lyric-view-color,white))"
735
+ },
736
+ {
737
+ offset: 1,
738
+ transform: "translate3d(0, 0, 0)",
739
+ filter: "drop-shadow(0 0 0 var(--amll-lyric-view-color,white))"
674
740
  }
675
- );
676
- return o.pause(), o;
677
- }
741
+ ],
742
+ {
743
+ duration: isFinite(a) ? a : 0,
744
+ delay: isFinite(l) ? l : 0,
745
+ id: "glow-word",
746
+ iterations: 1,
747
+ composite: "replace",
748
+ fill: "both"
749
+ }
750
+ );
751
+ return o.pause(), o;
678
752
  });
679
753
  }
680
754
  updateMaskImage() {
681
755
  this._hide && (this.element.style.display = "", this.element.style.visibility = "hidden"), this.splittedWords.forEach((e) => {
682
- const t = e.elements[0];
756
+ const t = e.mainElement;
683
757
  if (t) {
684
758
  e.width = t.clientWidth, e.height = t.clientHeight;
685
- const [n, i, l] = W(
686
- 16 / e.width,
687
- "rgba(0,0,0,0.75)",
759
+ const i = e.height / 2, [s, r, n] = G(
760
+ i / e.width,
761
+ "rgba(0,0,0,1)",
688
762
  "rgba(0,0,0,0.25)"
689
- ), s = `${l * 100}% 100%`;
690
- this.lyricPlayer.supportMaskImage ? (t.style.maskImage = n, t.style.maskOrigin = "left", t.style.maskSize = s) : (t.style.webkitMaskImage = n, t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = s);
691
- const r = e.width + 16, a = `clamp(${-r}px,calc(${-r}px + (var(--amll-player-time) - ${e.startTime})*${r / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
692
- t.style.maskPosition = a, t.style.webkitMaskPosition = a;
763
+ ), a = `${n * 100}% 100%`;
764
+ this.lyricPlayer.supportMaskImage ? (t.style.maskImage = s, t.style.maskOrigin = "left", t.style.maskSize = a) : (t.style.webkitMaskImage = s, t.style.webkitMaskOrigin = "left", t.style.webkitMaskSize = a);
765
+ const l = e.width + i, o = `clamp(${-l}px,calc(${-l}px + (var(--amll-player-time) - ${e.startTime})*${l / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
766
+ t.style.maskPosition = o, t.style.webkitMaskPosition = o;
693
767
  }
694
768
  }), this._hide && (this.element.style.display = "none", this.element.style.visibility = "");
695
769
  }
696
770
  getElement() {
697
771
  return this.element;
698
772
  }
699
- setTransform(e = this.left, t = this.top, n = this.scale, i = 1, l = 0, s = !1, r = 0) {
700
- this.left = e, this.top = t, this.scale = n, this.delay = r * 1e3 | 0;
701
- const a = this.element.children[0];
702
- a.style.opacity = `${i}`, s || !this.lyricPlayer.getEnableSpring() ? (this.blur = Math.min(32, l), s && this.element.classList.add(
703
- this.lyricPlayer.style.classes.tmpDisableTransition
704
- ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(n), this.lyricPlayer.getEnableSpring() ? this.rebuildStyle() : this.show(), s && requestAnimationFrame(() => {
705
- this.element.classList.remove(
773
+ setTransform(e = this.left, t = this.top, i = this.scale, s = 1, r = 0, n = !1, a = 0) {
774
+ const l = this.isInSight, o = this.lyricPlayer.getEnableSpring();
775
+ this.left = e, this.top = t, this.scale = i, this.delay = a * 1e3 | 0;
776
+ const c = this.element.children[0], m = this.element.children[1], u = this.element.children[2];
777
+ if (c.style.opacity = `${s}`, m.style.opacity = `${s / 2}`, u.style.opacity = `${s / 2}`, n || !o) {
778
+ if (this.blur = Math.min(32, r), n && this.element.classList.add(
706
779
  this.lyricPlayer.style.classes.tmpDisableTransition
707
- );
708
- })) : (this.lineTransforms.posX.setTargetPosition(e, r), this.lineTransforms.posY.setTargetPosition(t, r), this.lineTransforms.scale.setTargetPosition(n), this.blur !== Math.min(32, l) && (this.blur = Math.min(32, l), this.element.style.filter = `blur(${Math.min(32, l)}px)`));
780
+ ), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(t), this.lineTransforms.scale.setPosition(i), o)
781
+ this.rebuildStyle();
782
+ else {
783
+ const f = this.isInSight;
784
+ l || f ? this.show() : this.hide();
785
+ }
786
+ n && requestAnimationFrame(() => {
787
+ this.element.classList.remove(
788
+ this.lyricPlayer.style.classes.tmpDisableTransition
789
+ );
790
+ });
791
+ } else
792
+ this.lineTransforms.posX.setTargetPosition(e, a), this.lineTransforms.posY.setTargetPosition(t, a), this.lineTransforms.scale.setTargetPosition(i), this.blur !== Math.min(32, r) && (this.blur = Math.min(32, r), this.element.style.filter = `blur(${Math.min(32, r)}px)`);
709
793
  }
710
794
  update(e = 0) {
711
795
  this.lyricPlayer.getEnableSpring() && (this.lineTransforms.posX.update(e), this.lineTransforms.posY.update(e), this.lineTransforms.scale.update(e), this.isInSight ? this.show() : this.hide());
712
796
  }
713
797
  get isInSight() {
714
- const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), n = e + this.lineSize[0], i = t + this.lineSize[1], l = this.lyricPlayer.pos[0], s = this.lyricPlayer.pos[1], r = this.lyricPlayer.pos[0] + this.lyricPlayer.size[0], a = this.lyricPlayer.pos[1] + this.lyricPlayer.size[1];
715
- return !(e > r || t > a || n < l || i < s);
798
+ const e = this.lineTransforms.posX.getCurrentPosition(), t = this.lineTransforms.posY.getCurrentPosition(), i = e + this.lineSize[0], s = t + this.lineSize[1], r = this.lyricPlayer.size[0], n = this.lyricPlayer.size[1];
799
+ return !(e > r || i < 0 || t > n || s < 0);
716
800
  }
717
801
  dispose() {
718
802
  this.element.remove();
719
803
  }
720
804
  }
721
- const G = D(A());
722
- class ie extends EventTarget {
805
+ const J = I(D());
806
+ class K extends MouseEvent {
807
+ constructor(e, t, i) {
808
+ super(`line-${i.type}`, i), this.lineIndex = e, this.line = t;
809
+ }
810
+ }
811
+ class le extends EventTarget {
723
812
  element = document.createElement("div");
724
813
  currentTime = 0;
725
814
  lyricLines = [];
726
815
  processedLines = [];
727
816
  lyricLinesEl = [];
728
- lyricLinesSize = /* @__PURE__ */ new Map();
817
+ lyricLinesSize = /* @__PURE__ */ new WeakMap();
818
+ lyricLinesIndexes = /* @__PURE__ */ new WeakMap();
729
819
  hotLines = /* @__PURE__ */ new Set();
730
820
  bufferedLines = /* @__PURE__ */ new Set();
731
821
  scrollToIndex = 0;
@@ -733,12 +823,14 @@ class ie extends EventTarget {
733
823
  scrolledHandler = 0;
734
824
  isScrolled = !1;
735
825
  invokedByScrollEvent = !1;
826
+ padding = 32;
736
827
  scrollOffset = 0;
828
+ hidePassedLines = !1;
737
829
  resizeObserver = new ResizeObserver((e) => {
738
830
  const t = e[0].contentRect;
739
- this.size[0] = t.width, this.size[1] = t.height, this.pos[0] = t.left, this.pos[1] = t.top;
740
- const n = getComputedStyle(e[0].target), i = this.element.clientWidth - parseFloat(n.paddingLeft) - parseFloat(n.paddingRight), l = this.element.clientHeight - parseFloat(n.paddingTop) - parseFloat(n.paddingBottom);
741
- this.innerSize[0] = i, this.innerSize[1] = l, this.rebuildStyle(), this.calcLayout(!0, !0), this.lyricLinesEl.forEach((s) => s.updateMaskImage());
831
+ this.size[0] = t.width, this.size[1] = t.height;
832
+ const i = getComputedStyle(e[0].target), s = this.element.clientWidth - parseFloat(i.paddingLeft) - parseFloat(i.paddingRight), r = this.element.clientHeight - parseFloat(i.paddingTop) - parseFloat(i.paddingBottom);
833
+ this.innerSize[0] = s, this.innerSize[1] = r, this.rebuildStyle(), this.calcLayout(!0, !0), this.lyricLinesEl.forEach((n) => n.updateMaskImage());
742
834
  });
743
835
  posXSpringParams = {
744
836
  mass: 1,
@@ -756,6 +848,7 @@ class ie extends EventTarget {
756
848
  stiffness: 100
757
849
  };
758
850
  enableBlur = !0;
851
+ enableScale = !0;
759
852
  interludeDots;
760
853
  interludeDotsSize = [0, 0];
761
854
  bottomLine;
@@ -767,7 +860,14 @@ class ie extends EventTarget {
767
860
  isNonDynamic = !1;
768
861
  size = [0, 0];
769
862
  innerSize = [0, 0];
770
- pos = [0, 0];
863
+ onLineClickedHandler = (e) => {
864
+ const t = new K(
865
+ this.lyricLinesIndexes.get(e.line) ?? -1,
866
+ e.line,
867
+ e
868
+ );
869
+ this.dispatchEvent(t) || (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation());
870
+ };
771
871
  _getIsNonDynamic() {
772
872
  return this.isNonDynamic;
773
873
  }
@@ -788,10 +888,28 @@ class ie extends EventTarget {
788
888
  getEnableSpring() {
789
889
  return !this.disableSpring;
790
890
  }
791
- style = G.createStyleSheet({
891
+ /**
892
+ * 是否启用歌词行缩放效果,默认启用
893
+ *
894
+ * 如果启用,非选中的歌词行会轻微缩小以凸显当前播放歌词行效果
895
+ *
896
+ * 此效果对性能影响微乎其微,推荐启用
897
+ * @param enable 是否启用歌词行缩放效果
898
+ */
899
+ setEnableScale(e = !0) {
900
+ this.enableScale = e, this.calcLayout();
901
+ }
902
+ /**
903
+ * 获取当前是否启用了歌词行缩放效果
904
+ * @returns 是否启用歌词行缩放效果
905
+ */
906
+ getEnableScale() {
907
+ return this.enableScale;
908
+ }
909
+ style = J.createStyleSheet({
792
910
  lyricPlayer: {
793
911
  userSelect: "none",
794
- fontSize: "var(--amll-lyric-player-font-size,max(5vh, 12px))",
912
+ fontSize: "var(--amll-lyric-player-font-size,max(min(5vh, 10vw), 12px))",
795
913
  padding: "1em",
796
914
  margin: "-1em",
797
915
  width: "100%",
@@ -802,7 +920,12 @@ class ie extends EventTarget {
802
920
  zIndex: 1,
803
921
  color: "var(--amll-lyric-view-color,white)",
804
922
  mixBlendMode: "plus-lighter",
805
- contain: "strict"
923
+ contain: "strict",
924
+ "&:hover": {
925
+ "& $lyricLine": {
926
+ filter: "unset !important"
927
+ }
928
+ }
806
929
  },
807
930
  lyricLine: {
808
931
  position: "absolute",
@@ -813,8 +936,20 @@ class ie extends EventTarget {
813
936
  padding: "2vh 0.05em",
814
937
  contain: "content",
815
938
  willChange: "filter,transform,opacity",
816
- transition: "filter 0.25s",
817
- boxSizing: "border-box"
939
+ transition: "filter 0.25s, background-color 0.25s, box-shadow 0.25s",
940
+ boxSizing: "border-box",
941
+ borderRadius: "8px",
942
+ "& span": {
943
+ padding: "0.05em",
944
+ margin: "-0.05em"
945
+ },
946
+ "&:hover": {
947
+ backgroundColor: "var(--amll-lyric-view-hover-bg-color,#fff1)",
948
+ boxShadow: "0 0 0 8px var(--amll-lyric-view-hover-bg-color,#fff1)"
949
+ },
950
+ "&:active": {
951
+ boxShadow: "0 0 0 4px var(--amll-lyric-view-hover-bg-color,#fff1)"
952
+ }
818
953
  },
819
954
  "@media (max-width: 1024px)": {
820
955
  lyricLine: {
@@ -844,7 +979,6 @@ class ie extends EventTarget {
844
979
  },
845
980
  "& > span": {
846
981
  whiteSpace: "pre-wrap",
847
- wordBreak: "keep-all",
848
982
  maxLines: "1",
849
983
  // willChange: "transform,display,mask-image",
850
984
  "&.emphasize": {
@@ -856,12 +990,13 @@ class ie extends EventTarget {
856
990
  }
857
991
  },
858
992
  lyricSubLine: {
859
- fontSize: "max(50%, 10px)",
993
+ fontSize: "max(0.5em, 10px)",
994
+ transition: "opacity 0.3s 0.25s",
860
995
  opacity: 0.5
861
996
  },
862
997
  disableSpring: {
863
998
  "& > *": {
864
- transition: "filter 0.25s, transform 0.5s"
999
+ transition: "filter 0.25s, transform 0.5s, background-color 0.25s, box-shadow 0.25s"
865
1000
  }
866
1001
  },
867
1002
  interludeDots: {
@@ -874,7 +1009,7 @@ class ie extends EventTarget {
874
1009
  gap: "0.25em",
875
1010
  left: "1em",
876
1011
  "& > *": {
877
- height: "100%",
1012
+ height: "clamp(0.5em,1vh,3em)",
878
1013
  display: "inline-block",
879
1014
  borderRadius: "50%",
880
1015
  aspectRatio: "1 / 1",
@@ -899,7 +1034,7 @@ class ie extends EventTarget {
899
1034
  this.calcLayout(!0, !0);
900
1035
  };
901
1036
  constructor() {
902
- super(), this.interludeDots = new R(this), this.bottomLine = new F(this), this.element.setAttribute("class", this.style.classes.lyricPlayer), this.disableSpring && this.element.classList.add(this.style.classes.disableSpring), this.rebuildStyle(), this.resizeObserver.observe(this.element), this.element.appendChild(this.interludeDots.getElement()), this.element.appendChild(this.bottomLine.getElement()), this.style.attach(), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow), this.element.addEventListener("wheel", (e) => {
1037
+ super(), this.interludeDots = new Y(this), this.bottomLine = new q(this), this.element.setAttribute("class", this.style.classes.lyricPlayer), this.disableSpring && this.element.classList.add(this.style.classes.disableSpring), this.rebuildStyle(), this.resizeObserver.observe(this.element), this.element.appendChild(this.interludeDots.getElement()), this.element.appendChild(this.bottomLine.getElement()), this.style.attach(), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow), this.element.addEventListener("wheel", (e) => {
903
1038
  this.allowScroll && (this.isScrolled = !0, clearTimeout(this.scrolledHandler), this.scrolledHandler = setTimeout(() => {
904
1039
  this.isScrolled = !1, this.scrollOffset = 0;
905
1040
  }, 5e3), this.invokedByScrollEvent = !0, e.deltaMode === e.DOM_DELTA_PIXEL ? (this.scrollOffset += e.deltaY, this.calcLayout(!0)) : (this.scrollOffset += e.deltaY * 50, this.calcLayout(!1)), this.invokedByScrollEvent = !1);
@@ -940,7 +1075,14 @@ class ie extends EventTarget {
940
1075
  */
941
1076
  rebuildStyle() {
942
1077
  let e = "";
943
- e += "--amll-lyric-player-width:", e += this.innerSize[0], e += "px;", e += "--amll-lyric-player-height:", e += this.innerSize[1], e += "px;", e += "--amll-player-time:", e += this.currentTime, e += ";", this.element.setAttribute("style", e);
1078
+ e += "--amll-lyric-player-width:", e += this.innerSize[0] - this.padding * 2, e += "px;", e += "--amll-lyric-player-height:", e += this.innerSize[1] - this.padding * 2, e += "px;", e += "--amll-player-time:", e += this.currentTime, e += ";", this.element.setAttribute("style", e);
1079
+ }
1080
+ /**
1081
+ * 设置是否隐藏已经播放过的歌词行,默认不隐藏
1082
+ * @param hide 是否隐藏已经播放过的歌词行,默认不隐藏
1083
+ */
1084
+ setHidePassedLines(e) {
1085
+ this.hidePassedLines = e, this.calcLayout();
944
1086
  }
945
1087
  /**
946
1088
  * 设置是否启用歌词行的模糊效果
@@ -957,24 +1099,29 @@ class ie extends EventTarget {
957
1099
  this.lyricLines = e;
958
1100
  const t = 750;
959
1101
  this.processedLines = e.filter(
960
- (i) => i.words.reduce((l, s) => l + s.word.trim().length, 0) > 0
961
- ).map((i, l, s) => {
1102
+ (i) => i.words.reduce((s, r) => s + r.word.trim().length, 0) > 0
1103
+ ).map((i, s, r) => {
962
1104
  if (i.isBG)
963
1105
  return {
964
1106
  ...i
965
1107
  };
1108
+ if (s === 0)
1109
+ return {
1110
+ ...i,
1111
+ startTime: Math.max(i.startTime - t, 0)
1112
+ };
966
1113
  {
967
- const r = s[l - 1], a = s[l - 2];
968
- if (r?.isBG && a) {
1114
+ const n = r[s - 1], a = r[s - 2];
1115
+ if (n?.isBG && a) {
969
1116
  if (a.endTime < i.startTime)
970
1117
  return {
971
1118
  ...i,
972
1119
  startTime: Math.max(a.endTime, i.startTime - t) || i.startTime
973
1120
  };
974
- } else if (r?.endTime && r.endTime < i.startTime)
1121
+ } else if (n?.endTime && n.endTime < i.startTime)
975
1122
  return {
976
1123
  ...i,
977
- startTime: Math.max(r?.endTime, i.startTime - t) || i.startTime
1124
+ startTime: Math.max(n?.endTime, i.startTime - t) || i.startTime
978
1125
  };
979
1126
  return {
980
1127
  ...i
@@ -986,22 +1133,31 @@ class ie extends EventTarget {
986
1133
  this.isNonDynamic = !1;
987
1134
  break;
988
1135
  }
989
- this.processedLines.forEach((i, l, s) => {
990
- const r = s[l + 1], a = i.words[i.words.length - 1];
991
- a && x(a) && (r ? r.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, r.startTime)) : i.endTime = i.endTime + 1500);
992
- }), this.processedLines.forEach((i, l, s) => {
1136
+ this.processedLines.forEach((i, s, r) => {
1137
+ const n = r[s + 1], a = i.words[i.words.length - 1];
1138
+ a && x(a) && (n ? n.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, n.startTime)) : i.endTime = i.endTime + 1500);
1139
+ }), this.processedLines.forEach((i, s, r) => {
993
1140
  if (i.isBG)
994
1141
  return;
995
- const r = s[l + 1];
996
- r?.isBG && (r.startTime = Math.min(r.startTime, i.startTime));
997
- });
998
- const n = this.lyricLinesEl;
999
- for (this.lyricLinesEl = this.processedLines.map((i, l) => this.lyricLinesEl[l] ?? new Y(this, i)); n.length > this.processedLines.length; )
1000
- n.pop()?.dispose();
1001
- this.lyricLinesEl.forEach((i) => {
1002
- this.element.appendChild(i.getElement()), i.updateMaskImage();
1142
+ const n = r[s + 1];
1143
+ n?.isBG && (n.startTime = Math.min(n.startTime, i.startTime));
1144
+ }), this.lyricLinesEl.forEach((i) => {
1145
+ i.removeEventListener("click", this.onLineClickedHandler), i.removeEventListener("contextmenu", this.onLineClickedHandler), i.dispose();
1146
+ }), this.lyricLinesEl = this.processedLines.map((i) => {
1147
+ const s = new j(this, i);
1148
+ return s.addEventListener("click", this.onLineClickedHandler), s.addEventListener("contextmenu", this.onLineClickedHandler), s;
1149
+ }), this.lyricLinesEl.forEach((i, s) => {
1150
+ this.element.appendChild(i.getElement()), this.lyricLinesIndexes.set(i, s), i.updateMaskImage();
1003
1151
  }), this.interludeDots.setInterlude(void 0), this.hotLines.clear(), this.bufferedLines.clear(), this.setLinePosXSpringParams({}), this.setLinePosYSpringParams({}), this.setLineScaleSpringParams({}), this.setCurrentTime(0, !0), this.calcLayout(!0, !0);
1004
1152
  }
1153
+ /**
1154
+ * 重置用户滚动状态
1155
+ *
1156
+ * 请在用户完成滚动点击跳转歌词时调用本事件再调用 `calcLayout` 以正确滚动到目标位置
1157
+ */
1158
+ resetScroll() {
1159
+ this.isScrolled = !1, this.scrollOffset = 0, this.invokedByScrollEvent = !1, clearTimeout(this.scrolledHandler), this.scrolledHandler = 0;
1160
+ }
1005
1161
  /**
1006
1162
  * 重新布局定位歌词行的位置,调用完成后再逐帧调用 `update`
1007
1163
  * 函数即可让歌词通过动画移动到目标位置。
@@ -1020,44 +1176,46 @@ class ie extends EventTarget {
1020
1176
  * @param reflow 是否进行重新布局(重新计算每行歌词大小)
1021
1177
  */
1022
1178
  calcLayout(e = !1, t = !1) {
1023
- t && (this.lyricLinesEl.forEach((m) => {
1024
- const p = m.measureSize();
1025
- this.lyricLinesSize.set(m, p), m.lineSize = p;
1179
+ t && (this.lyricLinesEl.forEach((p) => {
1180
+ const d = p.measureSize();
1181
+ this.lyricLinesSize.set(p, d), p.lineSize = d;
1026
1182
  }), this.interludeDotsSize[0] = this.interludeDots.getElement().clientWidth, this.interludeDotsSize[1] = this.interludeDots.getElement().clientHeight, this.bottomLine.lineSize = this.bottomLine.measureSize());
1027
- const n = this.getCurrentInterlude();
1028
- let i = -this.scrollOffset, l = this.scrollToIndex, s = 0;
1029
- n ? (s = n[1] - n[0], s >= 5e3 && this.lyricLinesEl[n[2] + 1] && (l = n[2] + 1)) : this.interludeDots.setInterlude(void 0);
1030
- const r = 0.95, a = this.lyricLinesEl.slice(0, l).reduce(
1031
- (m, p) => m + (p.getLine().isBG ? 0 : this.lyricLinesSize.get(p)?.[1] ?? 0),
1183
+ const i = this.getCurrentInterlude();
1184
+ let s = -this.scrollOffset, r = this.scrollToIndex, n = 0;
1185
+ i ? (n = i[1] - i[0], n >= 5e3 && this.lyricLinesEl[i[2] + 1] && (r = i[2] + 1)) : this.interludeDots.setInterlude(void 0);
1186
+ const a = this.enableScale ? 0.95 : 1, l = this.lyricLinesEl.slice(0, r).reduce(
1187
+ (p, d) => p + (d.getLine().isBG ? 0 : this.lyricLinesSize.get(d)?.[1] ?? 0),
1032
1188
  0
1033
1189
  );
1034
- i -= a, i += this.size[1] * this.alignPosition;
1035
- const o = this.lyricLinesEl[l];
1190
+ s -= l, s += this.size[1] * this.alignPosition;
1191
+ const o = this.lyricLinesEl[r];
1036
1192
  if (o) {
1037
- const m = this.lyricLinesSize.get(o)?.[1] ?? 0;
1193
+ const p = this.lyricLinesSize.get(o)?.[1] ?? 0;
1038
1194
  switch (this.alignAnchor) {
1039
1195
  case "bottom":
1040
- i -= m;
1196
+ s -= p;
1041
1197
  break;
1042
1198
  case "center":
1043
- i -= m / 2;
1199
+ s -= p / 2;
1044
1200
  break;
1045
1201
  }
1046
1202
  }
1047
1203
  const c = Math.max(...this.bufferedLines);
1048
- let d = 0, u = 0.05, f = !1;
1049
- this.lyricLinesEl.forEach((m, p) => {
1050
- const L = this.bufferedLines.has(p), b = L || p >= this.scrollToIndex && p < c, P = m.getLine();
1051
- P.isDuet && this.size[0] - (this.lyricLinesSize.get(m)?.[0] ?? 0), !f && s >= 5e3 && (p === this.scrollToIndex && n?.[2] === -2 || p === this.scrollToIndex + 1) && (f = !0, this.interludeDots.setTransform(32, i), n && this.interludeDots.setInterlude([n[0], n[1]]), i += this.interludeDotsSize[1]), m.setTransform(
1052
- 0,
1053
- i,
1054
- b ? 1 : r,
1055
- L ? 1 : 1 / 3,
1056
- !this.invokedByScrollEvent && this.enableBlur ? b ? 0 : 1 + (p < this.scrollToIndex ? Math.abs(this.scrollToIndex - p) : Math.abs(p - Math.max(this.scrollToIndex, c))) : 0,
1204
+ let m = 0, u = 0.05, f = !1;
1205
+ this.lyricLinesEl.forEach((p, d) => {
1206
+ const g = this.bufferedLines.has(d), b = g || d >= this.scrollToIndex && d < c, P = p.getLine();
1207
+ P.isDuet && this.size[0] - (this.lyricLinesSize.get(p)?.[0] ?? 0), !f && n >= 5e3 && (d === this.scrollToIndex && i?.[2] === -2 || d === this.scrollToIndex + 1) && (f = !0, this.interludeDots.setTransform(32, s), i && this.interludeDots.setInterlude([i[0], i[1]]), s += this.interludeDotsSize[1]);
1208
+ const M = this.hidePassedLines && d < (i ? i[2] + 1 : this.scrollToIndex) ? 0 : g ? 1 : 1 / 3;
1209
+ p.setTransform(
1210
+ this.padding,
1211
+ s,
1212
+ b ? 1 : a,
1213
+ M,
1214
+ !this.invokedByScrollEvent && this.enableBlur ? b ? 0 : 1 + (d < this.scrollToIndex ? Math.abs(this.scrollToIndex - d) : Math.abs(d - Math.max(this.scrollToIndex, c))) : 0,
1057
1215
  e,
1058
- d
1059
- ), P.isBG && b ? i += this.lyricLinesSize.get(m)?.[1] ?? 0 : P.isBG || (i += this.lyricLinesSize.get(m)?.[1] ?? 0), i >= 0 && (d += u, u /= 1.2);
1060
- }), this.bottomLine.setTransform(0, i, e, d);
1216
+ m
1217
+ ), P.isBG && b ? s += this.lyricLinesSize.get(p)?.[1] ?? 0 : P.isBG || (s += this.lyricLinesSize.get(p)?.[1] ?? 0), s >= 0 && (m += u, u /= 1.2);
1218
+ }), this.bottomLine.setTransform(this.padding, s, e, m);
1061
1219
  }
1062
1220
  /**
1063
1221
  * 获取当前歌词的播放位置
@@ -1120,34 +1278,34 @@ class ie extends EventTarget {
1120
1278
  setCurrentTime(e, t = !1) {
1121
1279
  if (this.currentTime = e, this.element.style.setProperty("--amll-player-time", `${e}`), this.isScrolled)
1122
1280
  return;
1123
- const n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
1124
- this.hotLines.forEach((s) => {
1125
- const r = this.processedLines[s];
1126
- if (r) {
1127
- if (r.isBG)
1281
+ const i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
1282
+ this.hotLines.forEach((n) => {
1283
+ const a = this.processedLines[n];
1284
+ if (a) {
1285
+ if (a.isBG)
1128
1286
  return;
1129
- const a = this.processedLines[s + 1];
1130
- if (a?.isBG) {
1131
- const o = Math.min(r.startTime, a?.startTime), c = Math.max(r.endTime, a?.endTime);
1132
- (o > e || c <= e) && (this.hotLines.delete(s), n.add(s), this.hotLines.delete(s + 1), n.add(s + 1), t && (this.lyricLinesEl[s].disable(), this.lyricLinesEl[s + 1].disable()));
1287
+ const l = this.processedLines[n + 1];
1288
+ if (l?.isBG) {
1289
+ const o = Math.min(a.startTime, l?.startTime), c = Math.max(a.endTime, l?.endTime);
1290
+ (o > e || c <= e) && (this.hotLines.delete(n), i.add(n), this.hotLines.delete(n + 1), i.add(n + 1), t && (this.lyricLinesEl[n].disable(), this.lyricLinesEl[n + 1].disable()));
1133
1291
  } else
1134
- (r.startTime > e || r.endTime <= e) && (this.hotLines.delete(s), n.add(s), t && this.lyricLinesEl[s].disable());
1292
+ (a.startTime > e || a.endTime <= e) && (this.hotLines.delete(n), i.add(n), t && this.lyricLinesEl[n].disable());
1135
1293
  } else
1136
- this.hotLines.delete(s), n.add(s), t && this.lyricLinesEl[s].disable();
1137
- }), this.processedLines.forEach((s, r, a) => {
1138
- !s.isBG && s.startTime <= e && s.endTime > e && (this.hotLines.has(r) || (this.hotLines.add(r), l.add(r), t && this.lyricLinesEl[r].enable(), a[r + 1]?.isBG && (this.hotLines.add(r + 1), l.add(r + 1), t && this.lyricLinesEl[r + 1].enable())));
1139
- }), this.bufferedLines.forEach((s) => {
1140
- this.hotLines.has(s) || (i.add(s), t && this.lyricLinesEl[s].disable());
1294
+ this.hotLines.delete(n), i.add(n), t && this.lyricLinesEl[n].disable();
1295
+ }), this.processedLines.forEach((n, a, l) => {
1296
+ !n.isBG && n.startTime <= e && n.endTime > e && (this.hotLines.has(a) || (this.hotLines.add(a), r.add(a), t && this.lyricLinesEl[a].enable(), l[a + 1]?.isBG && (this.hotLines.add(a + 1), r.add(a + 1), t && this.lyricLinesEl[a + 1].enable())));
1297
+ }), this.bufferedLines.forEach((n) => {
1298
+ this.hotLines.has(n) || (s.add(n), t && this.lyricLinesEl[n].disable());
1141
1299
  }), t ? (this.bufferedLines.size > 0 ? this.scrollToIndex = Math.min(...this.bufferedLines) : this.scrollToIndex = this.processedLines.findIndex(
1142
- (s) => s.startTime >= e
1143
- ), this.bufferedLines.clear(), this.hotLines.forEach((s) => this.bufferedLines.add(s)), this.calcLayout(!0)) : (i.size > 0 || l.size > 0) && (i.size === 0 && l.size > 0 ? (l.forEach((s) => {
1144
- this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
1145
- }), this.scrollToIndex = Math.min(...this.bufferedLines)) : l.size === 0 && i.size > 0 ? O(i, this.bufferedLines) && this.bufferedLines.forEach((s) => {
1146
- this.hotLines.has(s) || (this.bufferedLines.delete(s), this.lyricLinesEl[s].disable());
1147
- }) : (l.forEach((s) => {
1148
- this.bufferedLines.add(s), this.lyricLinesEl[s].enable();
1149
- }), i.forEach((s) => {
1150
- this.bufferedLines.delete(s), this.lyricLinesEl[s].disable();
1300
+ (n) => n.startTime >= e
1301
+ ), this.bufferedLines.clear(), this.hotLines.forEach((n) => this.bufferedLines.add(n)), this.calcLayout(!0)) : (s.size > 0 || r.size > 0) && (s.size === 0 && r.size > 0 ? (r.forEach((n) => {
1302
+ this.bufferedLines.add(n), this.lyricLinesEl[n].enable();
1303
+ }), this.scrollToIndex = Math.min(...this.bufferedLines)) : r.size === 0 && s.size > 0 ? W(s, this.bufferedLines) && this.bufferedLines.forEach((n) => {
1304
+ this.hotLines.has(n) || (this.bufferedLines.delete(n), this.lyricLinesEl[n].disable());
1305
+ }) : (r.forEach((n) => {
1306
+ this.bufferedLines.add(n), this.lyricLinesEl[n].enable();
1307
+ }), s.forEach((n) => {
1308
+ this.bufferedLines.delete(n), this.lyricLinesEl[n].disable();
1151
1309
  }), this.bufferedLines.size > 0 && (this.scrollToIndex = Math.min(...this.bufferedLines))), this.calcLayout());
1152
1310
  }
1153
1311
  /**
@@ -1158,7 +1316,7 @@ class ie extends EventTarget {
1158
1316
  */
1159
1317
  update(e = 0) {
1160
1318
  const t = e / 1e3;
1161
- this.interludeDots.update(e), this.bottomLine.update(t), this.lyricLinesEl.forEach((n) => n.update(t));
1319
+ this.interludeDots.update(e), this.bottomLine.update(t), this.lyricLinesEl.forEach((i) => i.update(t));
1162
1320
  }
1163
1321
  /**
1164
1322
  * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。
@@ -1204,8 +1362,8 @@ class ie extends EventTarget {
1204
1362
  }
1205
1363
  }
1206
1364
  export {
1207
- te as BackgroundRender,
1208
- ie as LyricPlayer,
1209
- ee as ttml
1365
+ oe as BackgroundRender,
1366
+ le as LyricPlayer,
1367
+ ae as ttml
1210
1368
  };
1211
1369
  //# sourceMappingURL=amll-core.mjs.map