@web-ppt/viewer-core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/video.js CHANGED
@@ -1,39 +1,39 @@
1
- import { transitionPreferredDirection as bt, slideToSvgFile as vt, groupSteps as Mt, hiddenBefore as kt, staticHidden as xt } from "@web-ppt/core";
2
- const H = 6;
1
+ import { transitionPreferredDirection as Mt, slideToSvgFile as xt, groupSteps as kt, placeGroupChild as $t, hiddenBefore as Et, staticHidden as Pt } from "@web-ppt/core";
2
+ const j = 6;
3
3
  function M(r) {
4
4
  return `${Math.round(r * 1e3) / 1e3}%`;
5
5
  }
6
6
  function ct(r, t) {
7
- const e = r === "vert", a = [];
8
- for (let n = 0; n < H; n++) {
9
- const o = n / H * 100, s = (n + 1) / H * 100, c = t ? s : o;
10
- a.push(e ? x(o, 0, c, 100) : x(0, o, 100, c));
7
+ const e = r === "vert", n = [];
8
+ for (let a = 0; a < j; a++) {
9
+ const o = a / j * 100, s = (a + 1) / j * 100, l = t ? s : o;
10
+ n.push(e ? $(o, 0, l, 100) : $(0, o, 100, l));
11
11
  }
12
- return z(a);
12
+ return D(n);
13
13
  }
14
14
  const lt = [
15
15
  "linear-gradient(#000,#000)",
16
16
  "linear-gradient(#000,#000)",
17
17
  "linear-gradient(#000,#000)",
18
18
  "linear-gradient(#000,#000)"
19
- ].join(", "), yt = { l: 0, t: 0, w: 100, h: 100 };
20
- function wt(r) {
19
+ ].join(", "), gt = { l: 0, t: 0, w: 100, h: 100 };
20
+ function bt(r) {
21
21
  return r.l === 0 && r.t === 0 && r.w === 100 && r.h === 100;
22
22
  }
23
- function q(r, t = yt) {
24
- if (wt(t)) {
25
- const c = r ? 50 : 0, l = `100% ${c}%, 100% ${c}%, ${c}% 100%, ${c}% 100%`;
23
+ function q(r, t = gt) {
24
+ if (bt(t)) {
25
+ const l = r ? 50 : 0, i = `100% ${l}%, 100% ${l}%, ${l}% 100%, ${l}% 100%`;
26
26
  return {
27
27
  opacity: 1,
28
28
  maskImage: lt,
29
29
  maskRepeat: "no-repeat",
30
30
  maskPosition: "center top, center bottom, left center, right center",
31
- maskSize: l,
31
+ maskSize: i,
32
32
  maskOrigin: "fill-box",
33
33
  maskClip: "fill-box"
34
34
  };
35
35
  }
36
- const e = r ? 0.501 : 0, a = t.h * e, n = t.w * e, o = 100 - (t.t + t.h), s = 100 - (t.l + t.w);
36
+ const e = r ? 0.501 : 0, n = t.h * e, a = t.w * e, o = 100 - (t.t + t.h), s = 100 - (t.l + t.w);
37
37
  return {
38
38
  opacity: 1,
39
39
  maskImage: lt,
@@ -46,29 +46,29 @@ function q(r, t = yt) {
46
46
  `right ${M(s)} top ${M(t.t)}`
47
47
  ].join(", "),
48
48
  maskSize: [
49
- `${M(t.w)} ${M(a)}`,
50
- `${M(t.w)} ${M(a)}`,
51
- `${M(n)} ${M(t.h)}`,
52
- `${M(n)} ${M(t.h)}`
49
+ `${M(t.w)} ${M(n)}`,
50
+ `${M(t.w)} ${M(n)}`,
51
+ `${M(a)} ${M(t.h)}`,
52
+ `${M(a)} ${M(t.h)}`
53
53
  ].join(", "),
54
54
  maskOrigin: "fill-box",
55
55
  maskClip: "fill-box"
56
56
  };
57
57
  }
58
- function U(r, t = yt) {
59
- if (wt(t))
58
+ function H(r, t = gt) {
59
+ if (bt(t))
60
60
  return r ? "inset(0% 0% 0% 0%) fill-box" : "inset(50% 50% 50% 50%) fill-box";
61
- const e = r ? t.t : t.t + t.h / 2, a = r ? t.l : t.l + t.w / 2, n = r ? 100 - (t.t + t.h) : 100 - (t.t + t.h / 2), o = r ? 100 - (t.l + t.w) : 100 - (t.l + t.w / 2);
62
- return `inset(${M(e)} ${M(o)} ${M(n)} ${M(a)}) fill-box`;
61
+ const e = r ? t.t : t.t + t.h / 2, n = r ? t.l : t.l + t.w / 2, a = r ? 100 - (t.t + t.h) : 100 - (t.t + t.h / 2), o = r ? 100 - (t.l + t.w) : 100 - (t.l + t.w / 2);
62
+ return `inset(${M(e)} ${M(o)} ${M(a)} ${M(n)}) fill-box`;
63
63
  }
64
- function z(r, t = []) {
64
+ function D(r, t = []) {
65
65
  return {
66
66
  opacity: 1,
67
67
  maskImage: r.map(() => "linear-gradient(#000,#000)").join(", "),
68
68
  maskRepeat: "no-repeat",
69
- maskPosition: r.map((e, a) => {
70
- var n, o;
71
- return `${((n = t[a]) == null ? void 0 : n.x) === "right" ? `right ${M(100 - e[2][0])}` : `left ${M(e[0][0])}`} ${((o = t[a]) == null ? void 0 : o.y) === "bottom" ? `bottom ${M(100 - e[2][1])}` : `top ${M(e[0][1])}`}`;
69
+ maskPosition: r.map((e, n) => {
70
+ var a, o;
71
+ return `${((a = t[n]) == null ? void 0 : a.x) === "right" ? `right ${M(100 - e[2][0])}` : `left ${M(e[0][0])}`} ${((o = t[n]) == null ? void 0 : o.y) === "bottom" ? `bottom ${M(100 - e[2][1])}` : `top ${M(e[0][1])}`}`;
72
72
  }).join(", "),
73
73
  maskSize: r.map((e) => `${M(e[2][0] - e[0][0])} ${M(e[2][1] - e[0][1])}`).join(", "),
74
74
  maskOrigin: "fill-box",
@@ -76,10 +76,10 @@ function z(r, t = []) {
76
76
  };
77
77
  }
78
78
  function Q(r, t = !1) {
79
- const e = (o) => Math.round(o * 1e3) / 1e3, a = r.map((o) => `M${e(o[0][0])} ${e(o[0][1])} ` + o.slice(1).map(([s, c]) => `L${e(s)} ${e(c)}`).join(" ") + " Z").join(" "), n = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path fill="#000" fill-rule="${t ? "evenodd" : "nonzero"}" d="${a}"/></svg>`;
79
+ const e = (o) => Math.round(o * 1e3) / 1e3, n = r.map((o) => `M${e(o[0][0])} ${e(o[0][1])} ` + o.slice(1).map(([s, l]) => `L${e(s)} ${e(l)}`).join(" ") + " Z").join(" "), a = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path fill="#000" fill-rule="${t ? "evenodd" : "nonzero"}" d="${n}"/></svg>`;
80
80
  return {
81
81
  opacity: 1,
82
- maskImage: `url("data:image/svg+xml,${encodeURIComponent(n)}")`,
82
+ maskImage: `url("data:image/svg+xml,${encodeURIComponent(a)}")`,
83
83
  maskRepeat: "no-repeat",
84
84
  maskPosition: "center",
85
85
  maskSize: "100% 100%",
@@ -87,50 +87,50 @@ function Q(r, t = !1) {
87
87
  maskClip: "fill-box"
88
88
  };
89
89
  }
90
- function x(r, t, e, a) {
91
- return [[r, t], [e, t], [e, a], [r, a]];
90
+ function $(r, t, e, n) {
91
+ return [[r, t], [e, t], [e, n], [r, n]];
92
92
  }
93
93
  function ft(r, t) {
94
- const e = (r == null ? void 0 : r.endsWith("vert")) ?? !0, a = (r == null ? void 0 : r.startsWith("in")) ?? !1, n = t ? 50 : 0;
95
- return z(e ? a ? [x(0, 0, n, 100), x(100 - n, 0, 100, 100)] : [x(50 - n, 0, 50, 100), x(50, 0, 50 + n, 100)] : a ? [x(0, 0, 100, n), x(0, 100 - n, 100, 100)] : [x(0, 50 - n, 100, 50), x(0, 50, 100, 50 + n)]);
94
+ const e = (r == null ? void 0 : r.endsWith("vert")) ?? !0, n = (r == null ? void 0 : r.startsWith("in")) ?? !1, a = t ? 50 : 0;
95
+ return D(e ? n ? [$(0, 0, a, 100), $(100 - a, 0, 100, 100)] : [$(50 - a, 0, 50, 100), $(50, 0, 50 + a, 100)] : n ? [$(0, 0, 100, a), $(0, 100 - a, 100, 100)] : [$(0, 50 - a, 100, 50), $(0, 50, 100, 50 + a)]);
96
96
  }
97
97
  function ut(r, t) {
98
98
  const e = [];
99
- for (let a = 0; a < 6; a++) for (let n = 0; n < 8; n++) {
100
- const o = n * 12.5, s = a * (100 / 6), c = o + 12.5, l = s + 100 / 6, f = (a + n) % 2 === 1;
101
- r === "down" ? e.push(x(
99
+ for (let n = 0; n < 6; n++) for (let a = 0; a < 8; a++) {
100
+ const o = a * 12.5, s = n * (100 / 6), l = o + 12.5, i = s + 100 / 6, f = (n + a) % 2 === 1;
101
+ r === "down" ? e.push($(
102
102
  o,
103
- f ? l - (t ? l - s : 0) : s,
104
- c,
105
- f ? l : s + (t ? l - s : 0)
106
- )) : e.push(x(
107
- f ? c - (t ? c - o : 0) : o,
103
+ f ? i - (t ? i - s : 0) : s,
104
+ l,
105
+ f ? i : s + (t ? i - s : 0)
106
+ )) : e.push($(
107
+ f ? l - (t ? l - o : 0) : o,
108
108
  s,
109
- f ? c : o + (t ? c - o : 0),
110
- l
109
+ f ? l : o + (t ? l - o : 0),
110
+ i
111
111
  ));
112
112
  }
113
- return z(e);
113
+ return D(e);
114
114
  }
115
115
  function Z(r, t) {
116
- const e = r === "vert", a = 128, n = typeof t == "boolean" ? Number(t) : t, o = [];
117
- for (let s = 0; s < a; s++) {
118
- const c = s * 100 / a, l = (s + 1) * 100 / a, f = s * 73 % a, u = Math.min(1, Math.max(0, n * a - f)) * (l - c);
119
- o.push(e ? x(c, 0, c + u, 100) : x(0, c, 100, c + u));
116
+ const e = r === "vert", n = 128, a = typeof t == "boolean" ? Number(t) : t, o = [];
117
+ for (let s = 0; s < n; s++) {
118
+ const l = s * 100 / n, i = (s + 1) * 100 / n, f = s * 73 % n, u = Math.min(1, Math.max(0, a * n - f)) * (i - l);
119
+ o.push(e ? $(l, 0, l + u, 100) : $(0, l, 100, l + u));
120
120
  }
121
- return z(o);
121
+ return D(o);
122
122
  }
123
123
  function J(r, t) {
124
- const e = (r == null ? void 0 : r.startsWith("l")) ?? !1, a = (r == null ? void 0 : r.endsWith("u")) ?? !1, n = typeof t == "boolean" ? Number(t) : t, o = 8, s = [];
125
- for (let c = 0; c < o; c++) {
126
- const l = c * 100 / o, f = (c + 1) * 100 / o, u = (a ? o - c - 1 : c) / (2 * o), h = Math.min(1, Math.max(0, (n - u) / (1 - (o - 1) / (2 * o)))) * 100;
127
- s.push(e ? x(100 - h, l, 100, f) : x(0, l, h, f));
124
+ const e = (r == null ? void 0 : r.startsWith("l")) ?? !1, n = (r == null ? void 0 : r.endsWith("u")) ?? !1, a = typeof t == "boolean" ? Number(t) : t, o = 8, s = [];
125
+ for (let l = 0; l < o; l++) {
126
+ const i = l * 100 / o, f = (l + 1) * 100 / o, u = (n ? o - l - 1 : l) / (2 * o), h = Math.min(1, Math.max(0, (a - u) / (1 - (o - 1) / (2 * o)))) * 100;
127
+ s.push(e ? $(100 - h, i, 100, f) : $(0, i, h, f));
128
128
  }
129
- return z(s, e ? s.map(() => ({ x: "right" })) : []);
129
+ return D(s, e ? s.map(() => ({ x: "right" })) : []);
130
130
  }
131
- function $t(r, t) {
132
- if (r === "circle") return Array.from({ length: 40 }, (a, n) => {
133
- const o = n * Math.PI / 20 - Math.PI / 2;
131
+ function St(r, t) {
132
+ if (r === "circle") return Array.from({ length: 40 }, (n, a) => {
133
+ const o = a * Math.PI / 20 - Math.PI / 2;
134
134
  return [50 + t * Math.cos(o), 50 + t * Math.sin(o)];
135
135
  });
136
136
  if (r === "diamond") return [
@@ -156,105 +156,105 @@ function $t(r, t) {
156
156
  ];
157
157
  }
158
158
  function tt(r, t, e) {
159
- const a = typeof e == "boolean" ? Number(e) : e;
159
+ const n = typeof e == "boolean" ? Number(e) : e;
160
160
  if (r === "plus" && t === "in") {
161
- const c = a * 50;
162
- return z([
163
- x(0, 0, c, c),
164
- x(100 - c, 0, 100, c),
165
- x(0, 100 - c, c, 100),
166
- x(100 - c, 100 - c, 100, 100)
161
+ const l = n * 50;
162
+ return D([
163
+ $(0, 0, l, l),
164
+ $(100 - l, 0, 100, l),
165
+ $(0, 100 - l, l, 100),
166
+ $(100 - l, 100 - l, 100, 100)
167
167
  ], [{}, { x: "right" }, { y: "bottom" }, { x: "right", y: "bottom" }]);
168
168
  }
169
- const n = r === "circle" ? 72 : r === "diamond" ? 101 : 151, o = (t === "in" ? 1 - a : a) * n, s = $t(r, o);
170
- return t === "in" ? Q([x(0, 0, 100, 100), s], !0) : Q([s]);
169
+ const a = r === "circle" ? 72 : r === "diamond" ? 101 : 151, o = (t === "in" ? 1 - n : n) * a, s = St(r, o);
170
+ return t === "in" ? Q([$(0, 0, 100, 100), s], !0) : Q([s]);
171
171
  }
172
172
  function et(r, t) {
173
- const e = [1, 2, 3, 4, 8].includes(Number(r)) ? Number(r) : 1, a = typeof t == "boolean" ? Number(t) : t, n = [];
173
+ const e = [1, 2, 3, 4, 8].includes(Number(r)) ? Number(r) : 1, n = typeof t == "boolean" ? Number(t) : t, a = [];
174
174
  for (let o = 0; o < e; o++) {
175
- const s = -Math.PI / 2 + o * 2 * Math.PI / e, c = a * 2 * Math.PI / e, l = [[50, 50]];
175
+ const s = -Math.PI / 2 + o * 2 * Math.PI / e, l = n * 2 * Math.PI / e, i = [[50, 50]];
176
176
  for (let f = 0; f <= 16; f++) {
177
- const u = s + c * f / 16;
178
- l.push([50 + 200 * Math.cos(u), 50 + 200 * Math.sin(u)]);
177
+ const u = s + l * f / 16;
178
+ i.push([50 + 200 * Math.cos(u), 50 + 200 * Math.sin(u)]);
179
179
  }
180
- n.push(l);
180
+ a.push(i);
181
181
  }
182
- return Q(n);
182
+ return Q(a);
183
183
  }
184
184
  function rt(r, t) {
185
- const e = typeof r == "boolean" ? Number(r) : r, a = [];
186
- for (let n = 0; n < 8; n++) for (let o = 0; o < 10; o++) {
187
- const s = o * 10, c = n * 12.5, l = (o + 1) * 10, f = (n + 1) * 12.5;
188
- let u = Math.imul(n * 10 + o + t * 101, 73244475);
185
+ const e = typeof r == "boolean" ? Number(r) : r, n = [];
186
+ for (let a = 0; a < 8; a++) for (let o = 0; o < 10; o++) {
187
+ const s = o * 10, l = a * 12.5, i = (o + 1) * 10, f = (a + 1) * 12.5;
188
+ let u = Math.imul(a * 10 + o + t * 101, 73244475);
189
189
  u = Math.imul(u ^ u >>> 16, 73244475), u = (u ^ u >>> 16) >>> 0;
190
- const i = u % 17 / 17, h = s + (l - s) * i, d = c + (f - c) * (1 - i), w = (u >>> 8) % 8, v = Math.min(1, Math.max(0, e * 8 - w));
191
- a.push(x(
192
- h + (s - h) * v,
193
- d + (c - d) * v,
194
- h + (l - h) * v,
195
- d + (f - d) * v
190
+ const c = u % 17 / 17, h = s + (i - s) * c, d = l + (f - l) * (1 - c), m = (u >>> 8) % 8, g = Math.min(1, Math.max(0, e * 8 - m));
191
+ n.push($(
192
+ h + (s - h) * g,
193
+ d + (l - d) * g,
194
+ h + (i - h) * g,
195
+ d + (f - d) * g
196
196
  ));
197
197
  }
198
- return z(a);
198
+ return D(n);
199
199
  }
200
- const Et = 2147483647;
201
- function Pt(r, t, e) {
202
- const a = r.querySelector("audio,video");
203
- if (!a) return null;
200
+ const At = 2147483647;
201
+ function Ct(r, t, e) {
202
+ const n = r.querySelector("audio,video");
203
+ if (!n) return null;
204
204
  if (!Number.isFinite(e) || e < 0)
205
205
  throw new Error(`媒体调用的起始时间无效:${e}ms`);
206
- let n = null, o = e, s = !1, c = !1, l, f;
207
- const u = new Promise((w, v) => {
208
- l = w, f = v;
209
- }), i = () => {
210
- c = !0, Promise.resolve(a.play()).then(l, f);
206
+ let a = null, o = e, s = !1, l = !1, i, f;
207
+ const u = new Promise((m, g) => {
208
+ i = m, f = g;
209
+ }), c = () => {
210
+ l = !0, Promise.resolve(n.play()).then(i, f);
211
211
  }, h = () => {
212
- if (n = null, !s)
212
+ if (a = null, !s)
213
213
  try {
214
214
  switch (t.action) {
215
215
  case "play":
216
- t.fromSeconds !== void 0 && (a.currentTime = t.fromSeconds), i();
216
+ t.fromSeconds !== void 0 && (n.currentTime = t.fromSeconds), c();
217
217
  return;
218
218
  case "resume":
219
- i();
219
+ c();
220
220
  return;
221
221
  case "pause":
222
- a.pause();
222
+ n.pause();
223
223
  break;
224
224
  case "stop":
225
- a.pause(), a.currentTime = 0;
225
+ n.pause(), n.currentTime = 0;
226
226
  break;
227
227
  case "togglePause":
228
- if (a.paused) {
229
- i();
228
+ if (n.paused) {
229
+ c();
230
230
  return;
231
231
  }
232
- a.pause();
232
+ n.pause();
233
233
  break;
234
234
  }
235
- l();
236
- } catch (w) {
237
- f(w);
235
+ i();
236
+ } catch (m) {
237
+ f(m);
238
238
  }
239
239
  }, d = () => {
240
240
  if (o === 0) {
241
241
  h();
242
242
  return;
243
243
  }
244
- const w = Math.min(o, Et);
245
- n = setTimeout(() => {
246
- o -= w, d();
247
- }, w);
244
+ const m = Math.min(o, At);
245
+ a = setTimeout(() => {
246
+ o -= m, d();
247
+ }, m);
248
248
  };
249
249
  return d(), {
250
250
  finished: u,
251
251
  cancel: () => {
252
- s = !0, n !== null && clearTimeout(n), c && a.pause(), l();
252
+ s = !0, a !== null && clearTimeout(a), l && n.pause(), i();
253
253
  }
254
254
  };
255
255
  }
256
256
  const C = 1.15;
257
- function St(r) {
257
+ function Nt(r) {
258
258
  switch (r) {
259
259
  case "l":
260
260
  return [-100 * C, 0];
@@ -276,56 +276,56 @@ function St(r) {
276
276
  return [0, 100 * C];
277
277
  }
278
278
  }
279
- function At(r, t, e) {
280
- const a = r.querySelector("svg");
281
- if (!a || typeof a.getBoundingClientRect != "function" || typeof t.getBoundingClientRect != "function") return null;
282
- const n = a.getBoundingClientRect(), o = t.getBoundingClientRect();
283
- if (n.width < 1 || n.height < 1 || o.width < 1 || o.height < 1) return null;
284
- const s = (n.left - o.right - 4) / o.width * 100, c = (n.right - o.left + 4) / o.width * 100, l = (n.top - o.bottom - 4) / o.height * 100, f = (n.bottom - o.top + 4) / o.height * 100, u = e != null && e.includes("l") ? s : e != null && e.includes("r") ? c : 0, i = e != null && e.includes("u") ? l : e != null && e.includes("d") || !e ? f : 0;
285
- return `translate(${u}%, ${i}%)`;
279
+ function Ot(r, t, e) {
280
+ const n = r.querySelector("svg");
281
+ if (!n || typeof n.getBoundingClientRect != "function" || typeof t.getBoundingClientRect != "function") return null;
282
+ const a = n.getBoundingClientRect(), o = t.getBoundingClientRect();
283
+ if (a.width < 1 || a.height < 1 || o.width < 1 || o.height < 1) return null;
284
+ const s = (a.left - o.right - 4) / o.width * 100, l = (a.right - o.left + 4) / o.width * 100, i = (a.top - o.bottom - 4) / o.height * 100, f = (a.bottom - o.top + 4) / o.height * 100, u = e != null && e.includes("l") ? s : e != null && e.includes("r") ? l : 0, c = e != null && e.includes("u") ? i : e != null && e.includes("d") || !e ? f : 0;
285
+ return `translate(${u}%, ${c}%)`;
286
286
  }
287
- function X(r, t) {
287
+ function L(r, t) {
288
288
  return r === t ? `scale(${r})` : `scale(${r}, ${t})`;
289
289
  }
290
- const Ct = ["maskImage", "maskRepeat", "maskPosition", "maskSize"];
291
- function Nt(r) {
292
- var i, h;
293
- const t = (i = r.getBoundingClientRect) == null ? void 0 : i.call(r), e = (h = r.ownerDocument) == null ? void 0 : h.createRange;
290
+ const Tt = ["maskImage", "maskRepeat", "maskPosition", "maskSize"];
291
+ function Ft(r) {
292
+ var c, h;
293
+ const t = (c = r.getBoundingClientRect) == null ? void 0 : c.call(r), e = (h = r.ownerDocument) == null ? void 0 : h.createRange;
294
294
  if (!t || t.width < 1 || t.height < 1 || typeof e != "function") return null;
295
- const a = e.call(r.ownerDocument);
296
- a.selectNodeContents(r);
297
- const n = a.getBoundingClientRect();
298
- if (n.width < 1 || n.height < 1) return null;
299
- const o = Math.min(100, Math.max(0, (n.left - t.left) / t.width * 100)), s = Math.min(100, Math.max(0, (n.top - t.top) / t.height * 100)), c = Math.min(100, Math.max(o, (n.right - t.left) / t.width * 100)), l = Math.min(100, Math.max(s, (n.bottom - t.top) / t.height * 100)), f = c - o, u = l - s;
295
+ const n = e.call(r.ownerDocument);
296
+ n.selectNodeContents(r);
297
+ const a = n.getBoundingClientRect();
298
+ if (a.width < 1 || a.height < 1) return null;
299
+ const o = Math.min(100, Math.max(0, (a.left - t.left) / t.width * 100)), s = Math.min(100, Math.max(0, (a.top - t.top) / t.height * 100)), l = Math.min(100, Math.max(o, (a.right - t.left) / t.width * 100)), i = Math.min(100, Math.max(s, (a.bottom - t.top) / t.height * 100)), f = l - o, u = i - s;
300
300
  return f < 1 || u < 1 ? null : { l: o, t: s, w: f, h: u };
301
301
  }
302
- function Tt(r, t) {
302
+ function It(r, t) {
303
303
  if (!t || typeof r.querySelectorAll != "function") return [];
304
304
  const e = [];
305
- for (const n of r.querySelectorAll("[data-p]")) {
306
- const o = Number(n.getAttribute("data-p"));
307
- Number.isInteger(o) && o >= t.start && o <= t.end && e.push(n);
305
+ for (const a of r.querySelectorAll("[data-p]")) {
306
+ const o = Number(a.getAttribute("data-p"));
307
+ Number.isInteger(o) && o >= t.start && o <= t.end && e.push(a);
308
308
  }
309
309
  if (e.length) return e;
310
- const a = [];
311
- for (const n of r.querySelectorAll("foreignObject > :first-child")) {
312
- const o = [...n.children].filter((s) => s.localName === "div");
310
+ const n = [];
311
+ for (const a of r.querySelectorAll("foreignObject > :first-child")) {
312
+ const o = [...a.children].filter((s) => s.localName === "div");
313
313
  for (let s = t.start; s <= t.end && s < o.length; s++)
314
- a.push(o[s]);
314
+ n.push(o[s]);
315
315
  }
316
- return a;
316
+ return n;
317
317
  }
318
- function Ft(r, t, e) {
318
+ function Rt(r, t, e) {
319
319
  if (r.kind !== "emphasis" && r.kind !== "motion" && r.effect === "zoom" && (r.dir === "in" || r.dir === "out")) {
320
- const a = Nt(t);
321
- if (a) {
322
- const n = r.dir === "in" ? {
323
- from: q(!1, a),
324
- to: q(!0, a)
320
+ const n = Ft(t);
321
+ if (n) {
322
+ const a = r.dir === "in" ? {
323
+ from: q(!1, n),
324
+ to: q(!0, n)
325
325
  } : {
326
- from: { opacity: 1, clipPath: U(!1, a) },
327
- to: { opacity: 1, clipPath: U(!0, a) }
328
- }, o = r.kind === "exit" ? [n.to, n.from] : [n.from, n.to];
326
+ from: { opacity: 1, clipPath: H(!1, n) },
327
+ to: { opacity: 1, clipPath: H(!0, n) }
328
+ }, o = r.kind === "exit" ? [a.to, a.from] : [a.from, a.to];
329
329
  return ot(o);
330
330
  }
331
331
  }
@@ -334,10 +334,10 @@ function Ft(r, t, e) {
334
334
  function ot(r) {
335
335
  const t = (e) => e.clipPath !== void 0 || e.maskSize !== void 0;
336
336
  return r.some(t) ? r.map((e) => {
337
- const a = {};
338
- e.clipPath !== void 0 && (a.clipPath = String(e.clipPath).replace(/ fill-box/g, ""));
339
- for (const n of Ct) e[n] !== void 0 && (a[n] = e[n]);
340
- return e.maskSize !== void 0 && (a.maskOrigin = "border-box", a.maskClip = "border-box"), e.offset !== void 0 && (a.offset = e.offset), a;
337
+ const n = {};
338
+ e.clipPath !== void 0 && (n.clipPath = String(e.clipPath).replace(/ fill-box/g, ""));
339
+ for (const a of Tt) e[a] !== void 0 && (n[a] = e[a]);
340
+ return e.maskSize !== void 0 && (n.maskOrigin = "border-box", n.maskClip = "border-box"), e.offset !== void 0 && (n.offset = e.offset), n;
341
341
  }) : null;
342
342
  }
343
343
  function V(r, t) {
@@ -357,7 +357,7 @@ function V(r, t) {
357
357
  return `inset(${e}% 0 0 0)`;
358
358
  }
359
359
  }
360
- const Ot = {
360
+ const Yt = {
361
361
  d: { origin: "center bottom", axis: "scaleY" },
362
362
  u: { origin: "center top", axis: "scaleY" },
363
363
  l: { origin: "left center", axis: "scaleX" },
@@ -367,8 +367,8 @@ const Ot = {
367
367
  ld: { origin: "left bottom", axis: "scale" },
368
368
  rd: { origin: "right bottom", axis: "scale" }
369
369
  };
370
- function It(r) {
371
- return (r ? Ot[r] : void 0) ?? { origin: "center", axis: "scaleX" };
370
+ function Wt(r) {
371
+ return (r ? Yt[r] : void 0) ?? { origin: "center", axis: "scaleX" };
372
372
  }
373
373
  function nt(r, t) {
374
374
  const e = Math.round(Math.sin(2.5 * Math.PI * t) * 1e4) / 1e4;
@@ -378,29 +378,29 @@ function nt(r, t) {
378
378
  };
379
379
  }
380
380
  function st(r) {
381
- var t, e, a, n, o, s, c, l, f, u;
381
+ var t, e, n, a, o, s, l, i, f, u;
382
382
  switch (r.effect) {
383
383
  case "appear":
384
384
  return { from: { opacity: 0 }, to: { opacity: 1 } };
385
385
  case "fly": {
386
- const [i, h] = St(r.dir);
386
+ const [c, h] = Nt(r.dir);
387
387
  return {
388
- from: { opacity: 0, transform: `translate(${i}%, ${h}%)` },
388
+ from: { opacity: 0, transform: `translate(${c}%, ${h}%)` },
389
389
  to: { opacity: 1, transform: "translate(0, 0)" }
390
390
  };
391
391
  }
392
392
  case "zoom":
393
393
  return r.dir === "in" ? { from: q(!1), to: q(!0) } : r.dir === "out" ? {
394
- from: { opacity: 1, clipPath: U(!1) },
395
- to: { opacity: 1, clipPath: U(!0) }
394
+ from: { opacity: 1, clipPath: H(!1) },
395
+ to: { opacity: 1, clipPath: H(!0) }
396
396
  } : {
397
- from: { opacity: 0, transform: X(((t = r.scale) == null ? void 0 : t.fromX) ?? 0, ((e = r.scale) == null ? void 0 : e.fromY) ?? 0) },
398
- to: { opacity: 1, transform: X(((a = r.scale) == null ? void 0 : a.toX) ?? 1, ((n = r.scale) == null ? void 0 : n.toY) ?? 1) }
397
+ from: { opacity: 0, transform: L(((t = r.scale) == null ? void 0 : t.fromX) ?? 0, ((e = r.scale) == null ? void 0 : e.fromY) ?? 0) },
398
+ to: { opacity: 1, transform: L(((n = r.scale) == null ? void 0 : n.toX) ?? 1, ((a = r.scale) == null ? void 0 : a.toY) ?? 1) }
399
399
  };
400
400
  case "grow":
401
401
  return {
402
- from: { opacity: 1, transform: `${X(((o = r.scale) == null ? void 0 : o.fromX) ?? 0, ((s = r.scale) == null ? void 0 : s.fromY) ?? 0)} rotate(${((c = r.rotation) == null ? void 0 : c.from) ?? 0}deg)` },
403
- to: { opacity: 1, transform: `${X(((l = r.scale) == null ? void 0 : l.toX) ?? 1, ((f = r.scale) == null ? void 0 : f.toY) ?? 1)} rotate(${((u = r.rotation) == null ? void 0 : u.to) ?? 90}deg)` }
402
+ from: { opacity: 1, transform: `${L(((o = r.scale) == null ? void 0 : o.fromX) ?? 0, ((s = r.scale) == null ? void 0 : s.fromY) ?? 0)} rotate(${((l = r.rotation) == null ? void 0 : l.from) ?? 0}deg)` },
403
+ to: { opacity: 1, transform: `${L(((i = r.scale) == null ? void 0 : i.toX) ?? 1, ((f = r.scale) == null ? void 0 : f.toY) ?? 1)} rotate(${((u = r.rotation) == null ? void 0 : u.to) ?? 90}deg)` }
404
404
  };
405
405
  case "spin":
406
406
  return { from: { opacity: 0, transform: "rotate(-180deg) scale(0.4)" }, to: { opacity: 1, transform: "rotate(0) scale(1)" } };
@@ -413,13 +413,13 @@ function st(r) {
413
413
  case "stretch": {
414
414
  if (r.scale)
415
415
  return {
416
- from: { opacity: 0, transform: X(r.scale.fromX, r.scale.fromY) },
417
- to: { opacity: 1, transform: X(r.scale.toX, r.scale.toY) }
416
+ from: { opacity: 0, transform: L(r.scale.fromX, r.scale.fromY) },
417
+ to: { opacity: 1, transform: L(r.scale.toX, r.scale.toY) }
418
418
  };
419
- const { origin: i, axis: h } = It(r.dir);
419
+ const { origin: c, axis: h } = Wt(r.dir);
420
420
  return {
421
- from: { opacity: 1, transform: `${h}(0)`, transformOrigin: i },
422
- to: { opacity: 1, transform: `${h}(1)`, transformOrigin: i }
421
+ from: { opacity: 1, transform: `${h}(0)`, transformOrigin: c },
422
+ to: { opacity: 1, transform: `${h}(1)`, transformOrigin: c }
423
423
  };
424
424
  }
425
425
  case "blinds":
@@ -476,132 +476,132 @@ function st(r) {
476
476
  return { from: { opacity: 0 }, to: { opacity: 1 } };
477
477
  }
478
478
  }
479
- function Rt(r) {
479
+ function Xt(r) {
480
480
  const t = st({ ...r, kind: "entrance" });
481
481
  return { from: t.to, to: t.from };
482
482
  }
483
- function Yt(r) {
484
- var t, e, a, n;
483
+ function Lt(r) {
484
+ var t, e, n, a;
485
485
  switch (r.effect) {
486
486
  case "spin":
487
487
  return { from: { transform: "rotate(0)" }, to: { transform: "rotate(360deg)" } };
488
488
  case "grow":
489
489
  return {
490
- from: { transform: X(((t = r.scale) == null ? void 0 : t.fromX) ?? 1, ((e = r.scale) == null ? void 0 : e.fromY) ?? 1) },
491
- to: { transform: X(((a = r.scale) == null ? void 0 : a.toX) ?? 1.25, ((n = r.scale) == null ? void 0 : n.toY) ?? 1.25) }
490
+ from: { transform: L(((t = r.scale) == null ? void 0 : t.fromX) ?? 1, ((e = r.scale) == null ? void 0 : e.fromY) ?? 1) },
491
+ to: { transform: L(((n = r.scale) == null ? void 0 : n.toX) ?? 1.25, ((a = r.scale) == null ? void 0 : a.toY) ?? 1.25) }
492
492
  };
493
493
  default:
494
494
  return { from: { opacity: 1 }, to: { opacity: 0.5 } };
495
495
  }
496
496
  }
497
- function Wt(r) {
498
- return r.kind === "exit" ? Rt(r) : r.kind === "emphasis" ? Yt(r) : r.kind === "motion" ? { from: { opacity: 1 }, to: { opacity: 1 } } : st(r);
497
+ function Vt(r) {
498
+ return r.kind === "exit" ? Xt(r) : r.kind === "emphasis" ? Lt(r) : r.kind === "motion" ? { from: { opacity: 1 }, to: { opacity: 1 } } : st(r);
499
499
  }
500
- function Lt(r, t) {
501
- var l, f, u;
502
- const e = [], a = [], n = [];
503
- let o = !1, s = 0, c = 0;
504
- for (const i of t) {
505
- const h = i.trigger === "afterPrev" ? c + i.delayMs : i.trigger === "withPrev" ? s + i.delayMs : i.delayMs;
506
- s = h, c = h + i.durationMs;
507
- const d = r.querySelector(`[data-el="${i.target}"]`);
500
+ function Dt(r, t) {
501
+ var i, f, u;
502
+ const e = [], n = [], a = [];
503
+ let o = !1, s = 0, l = 0;
504
+ for (const c of t) {
505
+ const h = c.trigger === "afterPrev" ? l + c.delayMs : c.trigger === "withPrev" ? s + c.delayMs : c.delayMs;
506
+ s = h, l = h + c.durationMs;
507
+ const d = r.querySelector(`[data-el="${c.target}"]`);
508
508
  if (!d) continue;
509
- if (i.mediaCommand) {
510
- const g = Pt(d, i.mediaCommand, h);
511
- g && n.push(g);
509
+ if (c.mediaCommand) {
510
+ const b = Ct(d, c.mediaCommand, h);
511
+ b && a.push(b);
512
512
  continue;
513
513
  }
514
- i.kind === "exit" && a.push(d);
515
- const { from: w, to: v } = Wt(i);
516
- if (d.style.visibility = "visible", i.kind === "entrance" && (d.style.opacity = ""), i.effect === "fly" && (i.kind === "entrance" || i.kind === "exit")) {
517
- const g = At(r, d, i.dir);
518
- g && (i.kind === "entrance" ? w.transform = g : v.transform = g);
514
+ c.kind === "exit" && n.push(d);
515
+ const { from: m, to: g } = Vt(c);
516
+ if (d.style.visibility = "visible", c.kind === "entrance" && (d.style.opacity = ""), c.effect === "fly" && (c.kind === "entrance" || c.kind === "exit")) {
517
+ const b = Ot(r, d, c.dir);
518
+ b && (c.kind === "entrance" ? m.transform = b : g.transform = b);
519
519
  }
520
- const E = (l = i.motionPath) == null ? void 0 : l.reduce((g, [m, R], N, p) => (N === 0 ? g.push(0) : g.push(g[N - 1] + Math.hypot(m - p[N - 1][0], R - p[N - 1][1])), g), []), A = (E == null ? void 0 : E[E.length - 1]) ?? 0, I = (f = i.motionPath) != null && f.length ? i.motionPath.map(([g, m], R) => ({
521
- transform: `translate(${g}px, ${m}px)`,
522
- offset: A > 0 ? E[R] / A : R / (i.motionPath.length - 1)
523
- })) : i.effect === "randomBar" ? Array.from({ length: 13 }, (g, m) => ({
524
- ...Z(i.dir, i.kind === "exit" ? 1 - m / 12 : m / 12),
525
- offset: m / 12
526
- })) : i.effect === "strips" ? Array.from({ length: 21 }, (g, m) => ({
527
- ...J(i.dir, i.kind === "exit" ? 1 - m / 20 : m / 20),
528
- offset: m / 20
529
- })) : i.effect === "wheel" ? Array.from({ length: 73 }, (g, m) => ({
530
- ...et(i.dir, i.kind === "exit" ? 1 - m / 72 : m / 72),
531
- offset: m / 72
532
- })) : i.effect === "circle" || i.effect === "diamond" || i.effect === "plus" && i.dir !== "in" ? Array.from({ length: 37 }, (g, m) => ({
520
+ const k = (i = c.motionPath) == null ? void 0 : i.reduce((b, [p, R], N, y) => (N === 0 ? b.push(0) : b.push(b[N - 1] + Math.hypot(p - y[N - 1][0], R - y[N - 1][1])), b), []), A = (k == null ? void 0 : k[k.length - 1]) ?? 0, I = (f = c.motionPath) != null && f.length ? c.motionPath.map(([b, p], R) => ({
521
+ transform: `translate(${b}px, ${p}px)`,
522
+ offset: A > 0 ? k[R] / A : R / (c.motionPath.length - 1)
523
+ })) : c.effect === "randomBar" ? Array.from({ length: 13 }, (b, p) => ({
524
+ ...Z(c.dir, c.kind === "exit" ? 1 - p / 12 : p / 12),
525
+ offset: p / 12
526
+ })) : c.effect === "strips" ? Array.from({ length: 21 }, (b, p) => ({
527
+ ...J(c.dir, c.kind === "exit" ? 1 - p / 20 : p / 20),
528
+ offset: p / 20
529
+ })) : c.effect === "wheel" ? Array.from({ length: 73 }, (b, p) => ({
530
+ ...et(c.dir, c.kind === "exit" ? 1 - p / 72 : p / 72),
531
+ offset: p / 72
532
+ })) : c.effect === "circle" || c.effect === "diamond" || c.effect === "plus" && c.dir !== "in" ? Array.from({ length: 37 }, (b, p) => ({
533
533
  ...tt(
534
- i.effect,
535
- i.dir,
536
- i.kind === "exit" ? 1 - m / 36 : m / 36
534
+ c.effect,
535
+ c.dir,
536
+ c.kind === "exit" ? 1 - p / 36 : p / 36
537
537
  ),
538
- offset: m / 36
539
- })) : i.effect === "dissolve" ? Array.from({ length: 9 }, (g, m) => ({
540
- ...rt(i.kind === "exit" ? 1 - m / 8 : m / 8, i.target),
541
- offset: m / 8
542
- })) : i.effect === "swivel" && (i.kind === "entrance" || i.kind === "exit") ? Array.from({ length: 41 }, (g, m) => ({
543
- ...nt(i.dir, i.kind === "exit" ? 1 - m / 40 : m / 40),
544
- offset: m / 40
545
- })) : i.effect === "bounce" && i.kind === "entrance" ? [
538
+ offset: p / 36
539
+ })) : c.effect === "dissolve" ? Array.from({ length: 9 }, (b, p) => ({
540
+ ...rt(c.kind === "exit" ? 1 - p / 8 : p / 8, c.target),
541
+ offset: p / 8
542
+ })) : c.effect === "swivel" && (c.kind === "entrance" || c.kind === "exit") ? Array.from({ length: 41 }, (b, p) => ({
543
+ ...nt(c.dir, c.kind === "exit" ? 1 - p / 40 : p / 40),
544
+ offset: p / 40
545
+ })) : c.effect === "bounce" && c.kind === "entrance" ? [
546
546
  { opacity: 0, transform: "translateY(-60%)", offset: 0 },
547
547
  { opacity: 1, transform: "translateY(10%)", offset: 0.5 },
548
548
  { opacity: 1, transform: "translateY(-8%)", offset: 0.7 },
549
549
  { opacity: 1, transform: "translateY(3%)", offset: 0.85 },
550
550
  { opacity: 1, transform: "translateY(0)", offset: 1 }
551
- ] : [w, v];
551
+ ] : [m, g];
552
552
  try {
553
- const g = (u = i.motionPath) != null && u.length || i.effect === "randomBar" || i.effect === "strips" || i.effect === "wheel" || i.effect === "circle" || i.effect === "diamond" || i.effect === "plus" || i.effect === "dissolve" || i.effect === "bounce" || i.effect === "swivel" ? "linear" : i.effect === "appear" && i.kind === "entrance" ? "steps(1, start)" : i.effect === "appear" && i.kind === "exit" ? "steps(1, end)" : "cubic-bezier(0.25, 0.46, 0.45, 0.94)", m = d.animate(I, {
554
- duration: i.durationMs,
553
+ const b = (u = c.motionPath) != null && u.length || c.effect === "randomBar" || c.effect === "strips" || c.effect === "wheel" || c.effect === "circle" || c.effect === "diamond" || c.effect === "plus" || c.effect === "dissolve" || c.effect === "bounce" || c.effect === "swivel" ? "linear" : c.effect === "appear" && c.kind === "entrance" ? "steps(1, start)" : c.effect === "appear" && c.kind === "exit" ? "steps(1, end)" : "cubic-bezier(0.25, 0.46, 0.45, 0.94)", p = d.animate(I, {
554
+ duration: c.durationMs,
555
555
  delay: h,
556
556
  // 路径动画在 PowerPoint 里是匀速,不能套入场用的缓动
557
- easing: g,
557
+ easing: b,
558
558
  fill: "both"
559
559
  });
560
- i.kind === "exit" && m.finished.then(() => {
560
+ c.kind === "exit" && p.finished.then(() => {
561
561
  o || (d.style.visibility = "hidden");
562
562
  }).catch(() => {
563
- }), e.push(m);
563
+ }), e.push(p);
564
564
  const R = ot(I);
565
565
  if (!R || typeof d.querySelectorAll != "function") continue;
566
- const N = Tt(d, i.paragraphRange), p = N.length ? N : d.querySelectorAll("foreignObject > :first-child");
567
- for (const b of p) {
568
- if (!(b instanceof HTMLElement)) continue;
569
- const P = N.length ? Ft(i, b, I) : R;
570
- P && e.push(b.animate(P, {
571
- duration: i.durationMs,
566
+ const N = It(d, c.paragraphRange), y = N.length ? N : d.querySelectorAll("foreignObject > :first-child");
567
+ for (const v of y) {
568
+ if (!(v instanceof HTMLElement)) continue;
569
+ const P = N.length ? Rt(c, v, I) : R;
570
+ P && e.push(v.animate(P, {
571
+ duration: c.durationMs,
572
572
  delay: h,
573
- easing: g,
573
+ easing: b,
574
574
  fill: "both"
575
575
  }));
576
576
  }
577
577
  } catch {
578
- Object.assign(d.style, I[I.length - 1] ?? v), i.kind === "exit" && (d.style.visibility = "hidden");
578
+ Object.assign(d.style, I[I.length - 1] ?? g), c.kind === "exit" && (d.style.visibility = "hidden");
579
579
  }
580
580
  }
581
581
  return {
582
582
  animations: e,
583
583
  cancel: () => {
584
- o = !0, e.forEach((i) => {
584
+ o = !0, e.forEach((c) => {
585
585
  try {
586
- i.finish();
586
+ c.finish();
587
587
  } catch {
588
588
  }
589
- }), n.forEach((i) => i.cancel());
590
- for (const i of a) i.style.visibility = "hidden";
589
+ }), a.forEach((c) => c.cancel());
590
+ for (const c of n) c.style.visibility = "hidden";
591
591
  },
592
592
  // 等全部视觉与媒体调用落定后再报告:媒体失败不能让批次提前收尾、截断仍在播的视觉动画。
593
593
  finished: Promise.all([
594
- Promise.all(e.map((i) => i.finished.catch(() => {
594
+ Promise.all(e.map((c) => c.finished.catch(() => {
595
595
  }))),
596
- Promise.allSettled(n.map((i) => i.finished))
597
- ]).then(([, i]) => {
598
- const h = i.find((d) => d.status === "rejected");
596
+ Promise.allSettled(a.map((c) => c.finished))
597
+ ]).then(([, c]) => {
598
+ const h = c.find((d) => d.status === "rejected");
599
599
  if (h) throw h.reason;
600
600
  })
601
601
  };
602
602
  }
603
603
  function ht(r, t) {
604
- const e = r.dir ?? bt(r.type) ?? "", a = (o, s) => `translate(${o}, ${s})`, n = () => {
604
+ const e = r.dir ?? Mt(r.type) ?? "", n = (o, s) => `translate(${o}, ${s})`, a = () => {
605
605
  const o = {
606
606
  l: ["-100%", "0"],
607
607
  r: ["100%", "0"],
@@ -629,20 +629,20 @@ function ht(r, t) {
629
629
  ];
630
630
  case "push":
631
631
  case "pull": {
632
- const [o, s] = n(), c = r.type === "pull" ? -1 : 1, l = (f) => f === "0" ? "0" : `${-parseFloat(f) * c}%`;
633
- return t ? [{ transform: a(c > 0 ? o : l(o), c > 0 ? s : l(s)) }, { transform: "translate(0,0)" }] : [{ transform: "translate(0,0)" }, { transform: a(l(o), l(s)) }];
632
+ const [o, s] = a(), l = r.type === "pull" ? -1 : 1, i = (f) => f === "0" ? "0" : `${-parseFloat(f) * l}%`;
633
+ return t ? [{ transform: n(l > 0 ? o : i(o), l > 0 ? s : i(s)) }, { transform: "translate(0,0)" }] : [{ transform: "translate(0,0)" }, { transform: n(i(o), i(s)) }];
634
634
  }
635
635
  case "cover": {
636
- const [o, s] = n();
637
- return t ? [{ transform: a(o, s) }, { transform: "translate(0,0)" }] : [{ opacity: 1 }, { opacity: 1 }];
636
+ const [o, s] = a();
637
+ return t ? [{ transform: n(o, s) }, { transform: "translate(0,0)" }] : [{ opacity: 1 }, { opacity: 1 }];
638
638
  }
639
639
  case "wipe": {
640
640
  const o = V(e || "d", !0), s = V(e || "d", !1);
641
641
  return t ? [{ clipPath: o }, { clipPath: s }] : [{ opacity: 1 }, { opacity: 1 }];
642
642
  }
643
643
  case "split": {
644
- const o = e.startsWith("vert"), s = e.endsWith("out"), c = o ? "inset(0 50% 0 50%)" : "inset(50% 0 50% 0)", l = "inset(0 0 0 0)";
645
- return t ? s ? [{ clipPath: c }, { clipPath: l }] : [{ clipPath: l }, { clipPath: l }] : [{ clipPath: l }, { clipPath: c }];
644
+ const o = e.startsWith("vert"), s = e.endsWith("out"), l = o ? "inset(0 50% 0 50%)" : "inset(50% 0 50% 0)", i = "inset(0 0 0 0)";
645
+ return t ? s ? [{ clipPath: l }, { clipPath: i }] : [{ clipPath: i }, { clipPath: i }] : [{ clipPath: i }, { clipPath: l }];
646
646
  }
647
647
  case "zoom":
648
648
  return t ? [{ opacity: 0, transform: e === "out" ? "scale(1.4)" : "scale(0.6)" }, { opacity: 1, transform: "scale(1)" }] : [{ opacity: 1 }, { opacity: 0 }];
@@ -663,8 +663,8 @@ function ht(r, t) {
663
663
  return t ? [{ clipPath: `circle(0% at ${s})` }, { clipPath: `circle(145% at ${s})` }] : [{ opacity: 1 }, { opacity: 1 }];
664
664
  }
665
665
  case "vortex": {
666
- const [o, s] = n(), c = e === "r" || e === "d" ? 180 : -180;
667
- return t ? [{ opacity: 0, transformOrigin: `${o === "0" ? "50%" : o.startsWith("-") ? "0%" : "100%"} ${s === "0" ? "50%" : s.startsWith("-") ? "0%" : "100%"}`, transform: `scale(0.2) rotate(${c}deg)` }, { opacity: 1, transform: "none" }] : [{ opacity: 1 }, { opacity: 0 }];
666
+ const [o, s] = a(), l = e === "r" || e === "d" ? 180 : -180;
667
+ return t ? [{ opacity: 0, transformOrigin: `${o === "0" ? "50%" : o.startsWith("-") ? "0%" : "100%"} ${s === "0" ? "50%" : s.startsWith("-") ? "0%" : "100%"}`, transform: `scale(0.2) rotate(${l}deg)` }, { opacity: 1, transform: "none" }] : [{ opacity: 1 }, { opacity: 0 }];
668
668
  }
669
669
  case "honeycomb":
670
670
  return t ? [{ opacity: 0, transform: "scale(0.85) rotate(-6deg)" }, { opacity: 1, transform: "none" }] : [{ opacity: 1, transform: "none" }, { opacity: 0, transform: "scale(1.1)" }];
@@ -677,8 +677,8 @@ function ht(r, t) {
677
677
  case "flash":
678
678
  return t ? [{ opacity: 0, filter: "brightness(3)" }, { opacity: 1, filter: "brightness(1)" }] : [{ opacity: 1, filter: "brightness(1)" }, { opacity: 0, filter: "brightness(3)" }];
679
679
  case "reveal": {
680
- const [o, s] = n();
681
- return t ? [{ opacity: 0, transform: a(o, s) }, { opacity: 1, transform: "translate(0,0)" }] : [{ opacity: 1 }, { opacity: 0 }];
680
+ const [o, s] = a();
681
+ return t ? [{ opacity: 0, transform: n(o, s) }, { opacity: 1, transform: "translate(0,0)" }] : [{ opacity: 1 }, { opacity: 0 }];
682
682
  }
683
683
  case "wheelReverse":
684
684
  return t ? [{ opacity: 0, transform: "scale(1.3) rotate(20deg)" }, { opacity: 1, transform: "none" }] : [{ opacity: 1 }, { opacity: 0 }];
@@ -698,13 +698,13 @@ function ht(r, t) {
698
698
  ];
699
699
  }
700
700
  case "prism": {
701
- const o = e === "u" || e === "d", s = e === "r" || e === "d" ? -1 : 1, c = (l) => o ? `rotateX(${l}deg)` : `rotateY(${l}deg)`;
701
+ const o = e === "u" || e === "d", s = e === "r" || e === "d" ? -1 : 1, l = (i) => o ? `rotateX(${i}deg)` : `rotateY(${i}deg)`;
702
702
  return t ? [
703
- { opacity: 0, transform: `perspective(1400px) ${c(s * -70)}` },
704
- { opacity: 1, transform: `perspective(1400px) ${c(0)}` }
703
+ { opacity: 0, transform: `perspective(1400px) ${l(s * -70)}` },
704
+ { opacity: 1, transform: `perspective(1400px) ${l(0)}` }
705
705
  ] : [
706
- { opacity: 1, transform: `perspective(1400px) ${c(0)}` },
707
- { opacity: 0, transform: `perspective(1400px) ${c(s * 70)}` }
706
+ { opacity: 1, transform: `perspective(1400px) ${l(0)}` },
707
+ { opacity: 0, transform: `perspective(1400px) ${l(s * 70)}` }
708
708
  ];
709
709
  }
710
710
  case "ferris": {
@@ -719,18 +719,18 @@ function ht(r, t) {
719
719
  }
720
720
  case "gallery":
721
721
  case "conveyor": {
722
- const o = r.type === "conveyor" ? 25 : 12, s = e.includes("l") ? "-100%" : "100%", c = e.includes("l") ? "100%" : "-100%";
722
+ const o = r.type === "conveyor" ? 25 : 12, s = e.includes("l") ? "-100%" : "100%", l = e.includes("l") ? "100%" : "-100%";
723
723
  return t ? [
724
724
  { transform: `perspective(1600px) translateX(${s}) rotateY(${o}deg)` },
725
725
  { transform: "perspective(1600px) translateX(0) rotateY(0)" }
726
726
  ] : [
727
727
  { transform: "perspective(1600px) translateX(0) rotateY(0)" },
728
- { transform: `perspective(1600px) translateX(${c}) rotateY(${-o}deg)` }
728
+ { transform: `perspective(1600px) translateX(${l}) rotateY(${-o}deg)` }
729
729
  ];
730
730
  }
731
731
  case "pan": {
732
- const [o, s] = n(), c = (l) => l === "0" ? "0" : `${-parseFloat(l)}%`;
733
- return t ? [{ transform: a(o, s) }, { transform: "translate(0,0)" }] : [{ transform: "translate(0,0)" }, { transform: a(c(o), c(s)) }];
732
+ const [o, s] = a(), l = (i) => i === "0" ? "0" : `${-parseFloat(i)}%`;
733
+ return t ? [{ transform: n(o, s) }, { transform: "translate(0,0)" }] : [{ transform: "translate(0,0)" }, { transform: n(l(o), l(s)) }];
734
734
  }
735
735
  case "flythrough":
736
736
  return t ? [{ opacity: 0, transform: `perspective(1000px) scale(${e === "out" ? 2.2 : 0.15})` }, { opacity: 1, transform: "none" }] : [{ opacity: 1, transform: "none" }, { opacity: 0, transform: `perspective(1000px) scale(${e === "out" ? 0.15 : 2.2})` }];
@@ -763,32 +763,32 @@ function ht(r, t) {
763
763
  return t ? [{ opacity: 0 }, { opacity: 1 }] : [{ opacity: 1 }, { opacity: 0 }];
764
764
  }
765
765
  }
766
- function Xt(r, t) {
766
+ function zt(r, t) {
767
767
  const e = /* @__PURE__ */ new Map();
768
- r.querySelectorAll("[data-el]").forEach((n) => {
769
- const o = n.getBoundingClientRect();
770
- (o.width > 0 || o.height > 0) && e.set(n.getAttribute("data-el") ?? "", o);
768
+ r.querySelectorAll("[data-el]").forEach((a) => {
769
+ const o = a.getBoundingClientRect();
770
+ (o.width > 0 || o.height > 0) && e.set(a.getAttribute("data-el") ?? "", o);
771
771
  });
772
- const a = [];
773
- return t.querySelectorAll("[data-el]").forEach((n) => {
774
- const o = e.get(n.getAttribute("data-el") ?? "");
772
+ const n = [];
773
+ return t.querySelectorAll("[data-el]").forEach((a) => {
774
+ const o = e.get(a.getAttribute("data-el") ?? "");
775
775
  if (!o) return;
776
- const s = n.getBoundingClientRect();
777
- s.width <= 0 && s.height <= 0 || a.push({ node: n, from: o, to: s });
778
- }), a;
776
+ const s = a.getBoundingClientRect();
777
+ s.width <= 0 && s.height <= 0 || n.push({ node: a, from: o, to: s });
778
+ }), n;
779
779
  }
780
780
  const G = "http://www.w3.org/2000/svg", dt = ["transform", "transform-origin", "transform-box", "opacity", "clip-path", "filter", "visibility"];
781
- class Vt {
781
+ class Bt {
782
782
  constructor(t, e) {
783
783
  this.pres = t, this.showComments = e, this.host = document.createElement("div"), this.svg = document.createElementNS(G, "svg"), this.animations = [], this.host.style.cssText = `position:fixed;left:-20000px;top:0;width:${t.width}px;height:${t.height}px;pointer-events:none;contain:layout style;`, this.host.setAttribute("aria-hidden", "true"), this.svg.setAttribute("xmlns", G), this.svg.setAttribute("width", String(t.width)), this.svg.setAttribute("height", String(t.height)), this.svg.setAttribute("viewBox", `0 0 ${t.width} ${t.height}`), this.host.append(this.svg), document.body.append(this.host);
784
784
  }
785
785
  async page(t, e) {
786
- const a = await vt(this.pres, t, e, { showComments: this.showComments });
787
- if (/<image\b[^>]*\bhref="(?:blob:|https?:)/.test(a) || /@font-face\{[^}]*src:url\(['"]?(?:blob:|https?:)/.test(a)) throw new Error("视频资源内联失败");
788
- const n = new DOMParser().parseFromString(a, "image/svg+xml");
789
- if (n.querySelector("parsererror")) throw new Error("视频页面 SVG 无效");
786
+ const n = await xt(this.pres, t, e, { showComments: this.showComments });
787
+ if (/<image\b[^>]*\bhref="(?:blob:|https?:)/.test(n) || /@font-face\{[^}]*src:url\(['"]?(?:blob:|https?:)/.test(n)) throw new Error("视频资源内联失败");
788
+ const a = new DOMParser().parseFromString(n, "image/svg+xml");
789
+ if (a.querySelector("parsererror")) throw new Error("视频页面 SVG 无效");
790
790
  const o = document.createElementNS(G, "g");
791
- return o.style.transformBox = "fill-box", o.style.transformOrigin = "center", o.append(document.importNode(n.documentElement, !0)), this.svg.append(o), o;
791
+ return o.style.transformBox = "fill-box", o.style.transformOrigin = "center", o.append(document.importNode(a.documentElement, !0)), this.svg.append(o), o;
792
792
  }
793
793
  pause(t) {
794
794
  for (const e of t)
@@ -796,97 +796,97 @@ class Vt {
796
796
  return this.animations.push(...t), [...t];
797
797
  }
798
798
  group(t, e) {
799
- return this.pause(Lt(t, e).animations);
799
+ return this.pause(Dt(t, e).animations);
800
800
  }
801
- transition(t, e, a) {
802
- const n = a.transition;
803
- if (!n || n.type === "none") return [];
804
- const o = [], s = (c, l) => {
805
- const f = c.animate(l, { duration: n.durationMs, easing: "ease-in-out", fill: "both" });
801
+ transition(t, e, n) {
802
+ const a = n.transition;
803
+ if (!a || a.type === "none") return [];
804
+ const o = [], s = (l, i) => {
805
+ const f = l.animate(i, { duration: a.durationMs, easing: "ease-in-out", fill: "both" });
806
806
  f.finished.catch(() => {
807
807
  }), o.push(f);
808
808
  };
809
- if (n.type === "morph") {
810
- const c = Xt(t, e), l = new Set(c.map((f) => f.node.getAttribute("data-el")));
811
- for (const { node: f, from: u, to: i } of c) s(f, [{ transformOrigin: "left top", transform: `translate(${u.left - i.left}px,${u.top - i.top}px) scale(${i.width ? u.width / i.width : 1},${i.height ? u.height / i.height : 1})` }, { transformOrigin: "left top", transform: "none" }]);
812
- for (const f of t.querySelectorAll("[data-el]")) s(f, l.has(f.getAttribute("data-el")) ? [{ opacity: 0 }, { opacity: 0 }] : [{ opacity: 1 }, { opacity: 0 }]);
813
- for (const f of e.querySelectorAll("[data-el]")) l.has(f.getAttribute("data-el")) || s(f, [{ opacity: 0 }, { opacity: 1 }]);
809
+ if (a.type === "morph") {
810
+ const l = zt(t, e), i = new Set(l.map((f) => f.node.getAttribute("data-el")));
811
+ for (const { node: f, from: u, to: c } of l) s(f, [{ transformOrigin: "left top", transform: `translate(${u.left - c.left}px,${u.top - c.top}px) scale(${c.width ? u.width / c.width : 1},${c.height ? u.height / c.height : 1})` }, { transformOrigin: "left top", transform: "none" }]);
812
+ for (const f of t.querySelectorAll("[data-el]")) s(f, i.has(f.getAttribute("data-el")) ? [{ opacity: 0 }, { opacity: 0 }] : [{ opacity: 1 }, { opacity: 0 }]);
813
+ for (const f of e.querySelectorAll("[data-el]")) i.has(f.getAttribute("data-el")) || s(f, [{ opacity: 0 }, { opacity: 1 }]);
814
814
  } else
815
- s(t, ht(n, !1)), s(e, ht(n, !0));
815
+ s(t, ht(a, !1)), s(e, ht(a, !0));
816
816
  return this.pause(o);
817
817
  }
818
818
  settle(t) {
819
819
  for (const e of t) {
820
- const a = e.effect, n = a == null ? void 0 : a.target;
821
- if (a && n) {
822
- e.currentTime = Number(a.getComputedTiming().endTime);
823
- const o = getComputedStyle(n);
824
- for (const s of dt) n.style.setProperty(s, o.getPropertyValue(s));
820
+ const n = e.effect, a = n == null ? void 0 : n.target;
821
+ if (n && a) {
822
+ e.currentTime = Number(n.getComputedTiming().endTime);
823
+ const o = getComputedStyle(a);
824
+ for (const s of dt) a.style.setProperty(s, o.getPropertyValue(s));
825
825
  }
826
826
  e.cancel(), this.animations.splice(this.animations.indexOf(e), 1);
827
827
  }
828
828
  }
829
- async draw(t, e, a) {
830
- const n = this.svg.cloneNode(!0), o = [this.svg, ...this.svg.querySelectorAll("*")], s = [n, ...n.querySelectorAll("*")], c = new Set(this.animations.map((f) => {
829
+ async draw(t, e, n) {
830
+ const a = this.svg.cloneNode(!0), o = [this.svg, ...this.svg.querySelectorAll("*")], s = [a, ...a.querySelectorAll("*")], l = new Set(this.animations.map((f) => {
831
831
  var u;
832
832
  return (u = f.effect) == null ? void 0 : u.target;
833
833
  }));
834
- for (let f = 0; f < o.length; f++) if (c.has(o[f])) {
834
+ for (let f = 0; f < o.length; f++) if (l.has(o[f])) {
835
835
  const u = getComputedStyle(o[f]);
836
- for (const i of dt) s[f].style.setProperty(i, u.getPropertyValue(i));
836
+ for (const c of dt) s[f].style.setProperty(c, u.getPropertyValue(c));
837
837
  }
838
- const l = new Image();
839
- l.decoding = "sync", await new Promise((f, u) => {
840
- l.onload = () => f(), l.onerror = () => u(new Error("视频帧 SVG 渲染失败")), l.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`;
841
- }), t.fillStyle = "#fff", t.fillRect(0, 0, e, a), t.drawImage(l, 0, 0, e, a);
838
+ const i = new Image();
839
+ i.decoding = "sync", await new Promise((f, u) => {
840
+ i.onload = () => f(), i.onerror = () => u(new Error("视频帧 SVG 渲染失败")), i.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(a))}`;
841
+ }), t.fillStyle = "#fff", t.fillRect(0, 0, e, n), t.drawImage(i, 0, 0, e, n);
842
842
  }
843
843
  dispose() {
844
844
  for (const t of this.animations) t.cancel();
845
845
  this.animations.length = 0, this.host.remove();
846
846
  }
847
847
  }
848
- const gt = (r) => new TextEncoder().encode(r);
848
+ const vt = (r) => new TextEncoder().encode(r);
849
849
  function at(r, t = Math.max(1, Math.ceil(Math.log2(r + 1) / 8))) {
850
850
  const e = new Uint8Array(t);
851
- for (let a = t - 1; a >= 0; a--)
852
- e[a] = r % 256, r = Math.floor(r / 256);
851
+ for (let n = t - 1; n >= 0; n--)
852
+ e[n] = r % 256, r = Math.floor(r / 256);
853
853
  return e;
854
854
  }
855
- function zt(r) {
856
- const t = new Uint8Array(r.reduce((a, n) => a + n.length, 0));
855
+ function _t(r) {
856
+ const t = new Uint8Array(r.reduce((n, a) => n + a.length, 0));
857
857
  let e = 0;
858
- for (const a of r)
859
- t.set(a, e), e += a.length;
858
+ for (const n of r)
859
+ t.set(n, e), e += n.length;
860
860
  return t;
861
861
  }
862
- function $(r, ...t) {
862
+ function E(r, ...t) {
863
863
  const e = t.reduce((o, s) => o + s.length, 0);
864
- let a = 1;
865
- for (; e >= 2 ** (7 * a) - 1; ) a++;
866
- const n = at(e, a);
867
- return n[0] |= 1 << 8 - a, zt([at(r), n, ...t]);
864
+ let n = 1;
865
+ for (; e >= 2 ** (7 * n) - 1; ) n++;
866
+ const a = at(e, n);
867
+ return a[0] |= 1 << 8 - n, _t([at(r), a, ...t]);
868
868
  }
869
- const k = (r, t) => $(r, at(t)), D = (r, t) => $(r, gt(t));
869
+ const x = (r, t) => E(r, at(t)), B = (r, t) => E(r, vt(t));
870
870
  function mt(r, t) {
871
871
  const e = new Uint8Array(8);
872
- return new DataView(e.buffer).setFloat64(0, t), $(r, e);
872
+ return new DataView(e.buffer).setFloat64(0, t), E(r, e);
873
873
  }
874
- class Bt {
875
- constructor(t, e, a, n, o) {
876
- if (this.width = t, this.height = e, this.fps = a, this.codec = n, this.audio = o, this.clusters = [], this.last = -1, this.audioLast = -1, this.audioBlocks = 0, this.duration = 0, this.length = 0, this.closed = !1, ![t, e, a].every((s) => Number.isInteger(s) && s > 0) || t * e > 8388608 || a > 60) throw new Error("WebM 视频尺寸或帧率无效");
874
+ class qt {
875
+ constructor(t, e, n, a, o) {
876
+ if (this.width = t, this.height = e, this.fps = n, this.codec = a, this.audio = o, this.clusters = [], this.last = -1, this.audioLast = -1, this.audioBlocks = 0, this.duration = 0, this.length = 0, this.closed = !1, ![t, e, n].every((s) => Number.isInteger(s) && s > 0) || t * e > 8388608 || n > 60) throw new Error("WebM 视频尺寸或帧率无效");
877
877
  if (o && (!Number.isInteger(o.sampleRate) || o.sampleRate <= 0)) throw new Error("WebM 音频采样率无效");
878
878
  }
879
879
  clusterFor(t, e) {
880
- let a = this.clusters[this.clusters.length - 1];
881
- return (!a || t - a.time > 32767 || e && t - a.time >= 1e3 || t - a.time >= 3e4) && (a = { time: t, blocks: [], key: e }, this.clusters.push(a)), a;
880
+ let n = this.clusters[this.clusters.length - 1];
881
+ return (!n || t - n.time > 32767 || e && t - n.time >= 1e3 || t - n.time >= 3e4) && (n = { time: t, blocks: [], key: e }, this.clusters.push(n)), n;
882
882
  }
883
- addFrame(t, e, a, n) {
883
+ addFrame(t, e, n, a) {
884
884
  if (this.closed) throw new Error("WebM 已结束");
885
- if (!Number.isSafeInteger(e) || e <= this.last || e < 0 || !Number.isSafeInteger(a) || a <= 0) throw new Error("WebM 帧时间必须严格递增");
885
+ if (!Number.isSafeInteger(e) || e <= this.last || e < 0 || !Number.isSafeInteger(n) || n <= 0) throw new Error("WebM 帧时间必须严格递增");
886
886
  if (!t.length || t.length > 32 * 1024 * 1024 || this.length + t.length > 256 * 1024 * 1024) throw new Error("WebM 视频超过导出大小限制");
887
- if (!this.clusters.length && !n) throw new Error("WebM 第一帧必须是关键帧");
888
- const o = Math.round(e / 1e3), s = this.clusterFor(o, n), c = new Uint8Array(4);
889
- c[0] = 129, new DataView(c.buffer).setInt16(1, o - s.time), c[3] = n ? 128 : 0, s.blocks.push($(163, c, t)), this.length += t.length, this.last = e, this.duration = (e + a) / 1e3;
887
+ if (!this.clusters.length && !a) throw new Error("WebM 第一帧必须是关键帧");
888
+ const o = Math.round(e / 1e3), s = this.clusterFor(o, a), l = new Uint8Array(4);
889
+ l[0] = 129, new DataView(l.buffer).setInt16(1, o - s.time), l[3] = a ? 128 : 0, s.blocks.push(E(163, l, t)), this.length += t.length, this.last = e, this.duration = (e + n) / 1e3;
890
890
  }
891
891
  /** Opus 音频块:时间戳毫秒、流内严格递增;与视频块按簇交错 */
892
892
  addAudio(t, e) {
@@ -894,151 +894,204 @@ class Bt {
894
894
  if (!this.audio) throw new Error("WebM 未声明音频轨");
895
895
  if (!Number.isSafeInteger(e) || e < 0 || e <= this.audioLast) throw new Error("WebM 音频时间必须严格递增");
896
896
  if (!t.length || t.length > 1024 * 1024) throw new Error("WebM 音频块为空或超限");
897
- const a = Math.round(e), n = this.clusterFor(a, !1), o = new Uint8Array(4);
898
- o[0] = 130, new DataView(o.buffer).setInt16(1, Math.max(0, a - n.time)), n.blocks.push($(163, o, t)), this.audioBlocks++, this.audioLast = e, this.length += t.length;
897
+ const n = Math.round(e), a = this.clusterFor(n, !1), o = new Uint8Array(4);
898
+ o[0] = 130, new DataView(o.buffer).setInt16(1, Math.max(0, n - a.time)), a.blocks.push(E(163, o, t)), this.audioBlocks++, this.audioLast = e, this.length += t.length;
899
899
  }
900
900
  finish() {
901
901
  if (this.closed) throw new Error("WebM 已结束");
902
902
  if (!this.clusters.length) throw new Error("没有可导出的视频帧");
903
903
  if (this.audio && !this.audioBlocks) throw new Error("声明了音频轨但没有音频块");
904
904
  this.closed = !0;
905
- const t = $(440786851, k(17030, 1), k(17143, 1), k(17138, 4), k(17139, 8), D(17026, "webm"), k(17031, 4), k(17029, 2)), e = $(357149030, k(2807729, 1e6), mt(17545, this.duration), D(19840, "Web-PPT"), D(22337, "Web-PPT")), n = [$(174, k(215, 1), k(29637, 1), k(131, 1), k(156, 0), D(134, `V_${this.codec}`), k(2352003, Math.round(1e9 / this.fps)), $(224, k(176, this.width), k(186, this.height)))];
905
+ const t = E(440786851, x(17030, 1), x(17143, 1), x(17138, 4), x(17139, 8), B(17026, "webm"), x(17031, 4), x(17029, 2)), e = E(357149030, x(2807729, 1e6), mt(17545, this.duration), B(19840, "Web-PPT"), B(22337, "Web-PPT")), a = [E(174, x(215, 1), x(29637, 1), x(131, 1), x(156, 0), B(134, `V_${this.codec}`), x(2352003, Math.round(1e9 / this.fps)), E(224, x(176, this.width), x(186, this.height)))];
906
906
  if (this.audio) {
907
907
  const u = new Uint8Array(19);
908
- u.set(gt("OpusHead"), 0), u[8] = 1, u[9] = this.audio.channels, new DataView(u.buffer).setUint16(10, 312, !0), new DataView(u.buffer).setUint32(12, this.audio.sampleRate, !0), n.push($(
908
+ u.set(vt("OpusHead"), 0), u[8] = 1, u[9] = this.audio.channels, new DataView(u.buffer).setUint16(10, 312, !0), new DataView(u.buffer).setUint32(12, this.audio.sampleRate, !0), a.push(E(
909
909
  174,
910
- k(215, 2),
911
- k(29637, 2),
912
- k(131, 2),
913
- k(156, 0),
914
- D(134, "A_OPUS"),
915
- $(25506, u),
916
- $(225, mt(181, this.audio.sampleRate), k(159, this.audio.channels))
910
+ x(215, 2),
911
+ x(29637, 2),
912
+ x(131, 2),
913
+ x(156, 0),
914
+ B(134, "A_OPUS"),
915
+ E(25506, u),
916
+ E(225, mt(181, this.audio.sampleRate), x(159, this.audio.channels))
917
917
  ));
918
918
  }
919
- const o = $(374648427, ...n), s = [], c = [];
920
- let l = e.length + o.length;
919
+ const o = E(374648427, ...a), s = [], l = [];
920
+ let i = e.length + o.length;
921
921
  for (const u of this.clusters) {
922
- const i = $(524531317, k(231, u.time), ...u.blocks);
923
- u.key && c.push($(187, k(179, u.time), $(183, k(247, 1), k(241, l)))), s.push(i), l += i.length;
922
+ const c = E(524531317, x(231, u.time), ...u.blocks);
923
+ u.key && l.push(E(187, x(179, u.time), E(183, x(247, 1), x(241, i)))), s.push(c), i += c.length;
924
924
  }
925
- const f = $(408125543, e, o, ...s, $(475249515, ...c));
925
+ const f = E(408125543, e, o, ...s, E(475249515, ...l));
926
926
  return this.clusters.length = 0, new Blob([t.buffer, f.buffer], { type: "video/webm" });
927
927
  }
928
928
  }
929
929
  function _(r) {
930
- let t = 0, e = 0, a = 0;
931
- for (const n of r) {
932
- if (![n.delayMs, n.durationMs].every((o) => Number.isFinite(o) && o >= 0 && o <= 36e5)) throw new Error("视频动画时长无效");
933
- t = (n.trigger === "afterPrev" ? e : n.trigger === "withPrev" ? t : 0) + n.delayMs, e = t + n.durationMs, a = Math.max(a, e);
930
+ let t = 0, e = 0, n = 0;
931
+ for (const a of r) {
932
+ if (![a.delayMs, a.durationMs].every((o) => Number.isFinite(o) && o >= 0 && o <= 36e5)) throw new Error("视频动画时长无效");
933
+ t = (a.trigger === "afterPrev" ? e : a.trigger === "withPrev" ? t : 0) + a.delayMs, e = t + a.durationMs, n = Math.max(n, e);
934
934
  }
935
- return a;
935
+ return n;
936
936
  }
937
- function Dt(r, t) {
938
- const e = t.fps ?? 24, a = t.scale ?? 1, n = t.slideDurationMs ?? 3e3, o = t.clickDelayMs ?? 700;
939
- if (!Number.isInteger(e) || e < 1 || e > 60 || !Number.isFinite(a) || a <= 0 || ![n, o].every((h) => Number.isFinite(h) && h >= 0 && h <= 36e5)) throw new Error("视频帧率、倍率或停留时长无效");
940
- const s = Math.round(r.width * a), c = Math.round(r.height * a);
941
- if (![s, c].every((h) => Number.isFinite(h) && h > 0 && h <= 4096) || s * c > 8388608) throw new Error("视频尺寸需要在 4096 边长、800 万像素以内");
942
- const l = t.bitrate ?? Math.max(1e6, s * c * e * 0.15);
943
- if (!Number.isFinite(l) || l < 1e4 || l > 1e8) throw new Error("视频码率无效");
937
+ function Ht(r, t) {
938
+ const e = t.fps ?? 24, n = t.scale ?? 1, a = t.slideDurationMs ?? 3e3, o = t.clickDelayMs ?? 700;
939
+ if (!Number.isInteger(e) || e < 1 || e > 60 || !Number.isFinite(n) || n <= 0 || ![a, o].every((h) => Number.isFinite(h) && h >= 0 && h <= 36e5)) throw new Error("视频帧率、倍率或停留时长无效");
940
+ const s = Math.round(r.width * n), l = Math.round(r.height * n);
941
+ if (![s, l].every((h) => Number.isFinite(h) && h > 0 && h <= 4096) || s * l > 8388608) throw new Error("视频尺寸需要在 4096 边长、800 万像素以内");
942
+ const i = t.bitrate ?? Math.max(1e6, s * l * e * 0.15);
943
+ if (!Number.isFinite(i) || i < 1e4 || i > 1e8) throw new Error("视频码率无效");
944
944
  const f = (h) => Math.max(1, Math.ceil(h * e / 1e3)), u = r.slides.flatMap((h, d) => {
945
- var A, I, g;
945
+ var A, I, b;
946
946
  if (t.skipHidden && h.hidden) return [];
947
- const w = t.animations === !1 ? [] : Mt(h.animations), v = t.transitions !== !1 && ((A = h.transition) == null ? void 0 : A.type) !== "none" ? ((I = h.transition) == null ? void 0 : I.durationMs) ?? 0 : 0, E = ((g = h.transition) == null ? void 0 : g.advanceAfterMs) ?? n;
948
- if (![E, v].every((m) => Number.isFinite(m) && m >= 0 && m <= 36e5)) throw new Error("视频页面时长无效");
949
- return [{ slide: h, slideNumber: d + 1, groups: w, transition: v, hold: E, click: o }];
950
- }), i = u.reduce((h, d, w) => h + (w && d.transition ? f(d.transition) : 0) + f(d.hold) + d.groups.reduce((v, E) => v + (o ? f(o) : 0) + f(_(E)), 0), 0);
947
+ const m = t.animations === !1 ? [] : kt(h.animations), g = t.transitions !== !1 && ((A = h.transition) == null ? void 0 : A.type) !== "none" ? ((I = h.transition) == null ? void 0 : I.durationMs) ?? 0 : 0, k = ((b = h.transition) == null ? void 0 : b.advanceAfterMs) ?? a;
948
+ if (![k, g].every((p) => Number.isFinite(p) && p >= 0 && p <= 36e5)) throw new Error("视频页面时长无效");
949
+ return [{ slide: h, slideNumber: d + 1, groups: m, transition: g, hold: k, click: o }];
950
+ }), c = u.reduce((h, d, m) => h + (m && d.transition ? f(d.transition) : 0) + f(d.hold) + d.groups.reduce((g, k) => g + (o ? f(o) : 0) + f(_(k)), 0), 0);
951
951
  if (!u.length) throw new Error("没有可导出的视频页面");
952
- if (i / e > 3600 || i > 108e3) throw new Error("视频不能超过一小时或 108000 帧");
953
- return { width: s, height: c, fps: e, bitrate: Math.round(l), pages: u, total: i, frames: f };
952
+ if (c / e > 3600 || c > 108e3) throw new Error("视频不能超过一小时或 108000 帧");
953
+ return { width: s, height: l, fps: e, bitrate: Math.round(i), pages: u, total: c, frames: f };
954
954
  }
955
- function _t(r, t, e) {
956
- const a = r.samples.length / r.channels;
957
- if (!Number.isInteger(a)) return null;
958
- let n = t;
959
- if (r.loop) n %= a;
960
- else if (t < 0 || t >= a) return null;
961
- const o = Math.floor(n), s = n - o, c = Math.min(o + 1, a - 1), l = r.samples[o * r.channels + e], f = r.samples[c * r.channels + e];
962
- return l + (f - l) * s;
955
+ function Ut(r, t, e) {
956
+ const n = r.samples.length / r.channels;
957
+ if (!Number.isInteger(n)) return null;
958
+ let a = t;
959
+ if (r.loop) a %= n;
960
+ else if (t < 0 || t >= n) return null;
961
+ const o = Math.floor(a), s = a - o, l = Math.min(o + 1, n - 1), i = r.samples[o * r.channels + e], f = r.samples[l * r.channels + e];
962
+ return i + (f - i) * s;
963
963
  }
964
- function qt(r, t, e = {}) {
965
- const a = e.sampleRate ?? 48e3, n = e.channels ?? 2;
964
+ function jt(r, t, e = {}) {
965
+ const n = e.sampleRate ?? 48e3, a = e.channels ?? 2;
966
966
  if (!Number.isFinite(t) || t < 0) throw new Error("混音总时长必须是非负毫秒");
967
- if (!Number.isInteger(a) || a <= 0) throw new Error("输出采样率必须是正整数");
968
- if (r.some((l) => !Number.isInteger(l.sampleRate) || l.sampleRate <= 0)) throw new Error("片段采样率必须是正整数");
969
- if (r.some((l) => l.channels !== 1 && l.channels !== 2)) throw new Error("片段声道数只支持单声道或立体声");
970
- if (r.some((l) => !Number.isFinite(l.startMs) || l.startMs < 0)) throw new Error("片段起始时间必须是非负毫秒");
971
- if (r.some((l) => l.samples.length % l.channels !== 0)) throw new Error("片段样本长度必须是声道数的整数倍");
972
- const o = r.map((l) => l.volume ?? 1);
973
- if (o.some((l) => !Number.isFinite(l) || l < 0 || l > 1)) throw new Error("片段音量必须在 [0,1]");
974
- const s = Math.ceil(t / 1e3 * a), c = new Float32Array(s * n);
975
- for (const [l, f] of r.entries()) {
967
+ if (!Number.isInteger(n) || n <= 0) throw new Error("输出采样率必须是正整数");
968
+ if (r.some((i) => !Number.isInteger(i.sampleRate) || i.sampleRate <= 0)) throw new Error("片段采样率必须是正整数");
969
+ if (r.some((i) => i.channels !== 1 && i.channels !== 2)) throw new Error("片段声道数只支持单声道或立体声");
970
+ if (r.some((i) => !Number.isFinite(i.startMs) || i.startMs < 0)) throw new Error("片段起始时间必须是非负毫秒");
971
+ if (r.some((i) => i.samples.length % i.channels !== 0)) throw new Error("片段样本长度必须是声道数的整数倍");
972
+ const o = r.map((i) => i.volume ?? 1);
973
+ if (o.some((i) => !Number.isFinite(i) || i < 0 || i > 1)) throw new Error("片段音量必须在 [0,1]");
974
+ const s = Math.ceil(t / 1e3 * n), l = new Float32Array(s * a);
975
+ for (const [i, f] of r.entries()) {
976
976
  if (f.endMs !== void 0 && f.endMs < f.startMs) throw new Error("片段截止时间早于起始时间");
977
- const u = f.endMs ?? Number.POSITIVE_INFINITY, i = Math.floor(f.startMs / 1e3 * a);
978
- for (let h = Math.max(i, 0); h < s && !(h / a * 1e3 >= u); h++) {
979
- const d = (h - f.startMs / 1e3 * a) * f.sampleRate / a;
980
- for (let w = 0; w < n; w++) {
981
- const v = _t(f, d, f.channels === 1 ? 0 : w);
982
- v !== null && (c[h * n + w] += v * o[l]);
977
+ const u = f.endMs ?? Number.POSITIVE_INFINITY, c = Math.floor(f.startMs / 1e3 * n);
978
+ for (let h = Math.max(c, 0); h < s && !(h / n * 1e3 >= u); h++) {
979
+ const d = (h - f.startMs / 1e3 * n) * f.sampleRate / n;
980
+ for (let m = 0; m < a; m++) {
981
+ const g = Ut(f, d, f.channels === 1 ? 0 : m);
982
+ g !== null && (l[h * a + m] += g * o[i]);
983
983
  }
984
984
  }
985
985
  }
986
- for (let l = 0; l < c.length; l++) c[l] = Math.max(-1, Math.min(1, c[l]));
987
- return c;
986
+ for (let i = 0; i < l.length; i++) l[i] = Math.max(-1, Math.min(1, l[i]));
987
+ return l;
988
988
  }
989
- const Ut = 5e3, jt = 500, Ht = (r) => new Promise((t) => {
989
+ const Gt = 5e3, Kt = 500, Qt = (r) => new Promise((t) => {
990
990
  const e = (s) => {
991
- clearTimeout(o), r.removeEventListener("loadeddata", a), r.removeEventListener("error", n), t(s && Number.isFinite(r.duration));
992
- }, a = () => e(!0), n = () => e(!1), o = setTimeout(n, Ut);
993
- r.addEventListener("loadeddata", a), r.addEventListener("error", n), r.readyState >= 2 && e(!0);
994
- }), Gt = (r, t) => new Promise((e) => {
995
- const a = (s) => {
996
- clearTimeout(o), r.removeEventListener("seeked", n), e(s);
997
- }, n = () => a(!0), o = setTimeout(() => a(!1), jt);
998
- r.addEventListener("seeked", n), r.currentTime = t;
991
+ clearTimeout(o), r.removeEventListener("loadeddata", n), r.removeEventListener("error", a), t(s && Number.isFinite(r.duration) && r.duration > 0);
992
+ }, n = () => e(!0), a = () => e(!1), o = setTimeout(a, Gt);
993
+ r.addEventListener("loadeddata", n), r.addEventListener("error", a), r.readyState >= 2 && e(!0);
994
+ }), Zt = (r, t) => new Promise((e) => {
995
+ const n = (s) => {
996
+ clearTimeout(o), r.removeEventListener("seeked", a), e(s);
997
+ }, a = () => n(!0), o = setTimeout(() => n(!1), Kt);
998
+ r.addEventListener("seeked", a), r.currentTime = t;
999
999
  }), K = (r) => {
1000
1000
  r.removeAttribute("src"), r.load();
1001
- };
1002
- class Kt {
1001
+ }, pt = (r) => {
1002
+ const t = r.x + r.w / 2, e = r.y + r.h / 2, n = new DOMMatrix().translateSelf(t, e);
1003
+ return r.rot && n.rotateSelf(r.rot), n.translateSelf(-t, -e).translateSelf(r.x, r.y);
1004
+ }, yt = (r) => !r.flipH && !r.flipV ? new DOMMatrix() : new DOMMatrix().translateSelf(r.w / 2, r.h / 2).scaleSelf(r.flipH ? -1 : 1, r.flipV ? -1 : 1).translateSelf(-r.w / 2, -r.h / 2);
1005
+ class Jt {
1003
1006
  constructor(t) {
1004
1007
  this.warn = t, this.videos = /* @__PURE__ */ new Map(), this.disposed = !1;
1005
1008
  }
1006
1009
  /** 预加载页面的视频媒体(每页一个列表;须在导出循环前调用) */
1007
- async load(t, e, a, n) {
1008
- const o = [], s = (f) => {
1009
- for (const u of f)
1010
- if (u.kind === "image" && u.media && u.media.kind === "video" && u.media.src) {
1011
- const i = u.media.playback;
1012
- if (!i) continue;
1013
- const h = n.length ? n[Math.min(i.clickGroup, n.length - 1)] : 0, d = document.createElement("video");
1014
- d.muted = !0, d.preload = "auto", d.playsInline = !0, d.src = u.media.src, o.push({ el: d, x: u.x, y: u.y, w: u.w, h: u.h, startMs: h, name: u.name ?? "", frameWarned: !1 });
1015
- } else u.kind === "group" && s(u.children);
1010
+ async load(t, e, n, a) {
1011
+ const o = [], s = (f, u, c) => {
1012
+ for (const h of f) {
1013
+ const d = c ? $t(c, h) : h;
1014
+ if (d.kind === "group") {
1015
+ const m = [...u, pt(d), yt(d)];
1016
+ s(d.children, m, d);
1017
+ } else if (d.kind === "image" && d.media && d.media.kind === "video" && d.media.src) {
1018
+ const m = d.media.playback;
1019
+ if (!m) continue;
1020
+ const g = a.length ? a[Math.min(m.clickGroup, a.length - 1)] : 0, k = document.createElement("video");
1021
+ k.muted = !0, k.preload = "auto", k.playsInline = !0, k.src = d.media.src, o.push({
1022
+ el: k,
1023
+ x: d.x,
1024
+ y: d.y,
1025
+ w: d.w,
1026
+ h: d.h,
1027
+ rot: d.rot,
1028
+ flipH: d.flipH,
1029
+ flipV: d.flipV,
1030
+ crop: d.crop,
1031
+ alpha: d.alpha,
1032
+ clipPath: d.clipPath,
1033
+ filter: d.filter,
1034
+ chain: u,
1035
+ startMs: g,
1036
+ durationS: Number.isFinite(k.duration) ? k.duration : 0,
1037
+ loop: m.loop,
1038
+ name: d.name ?? "",
1039
+ frameWarned: !1
1040
+ });
1041
+ }
1042
+ }
1016
1043
  };
1017
- if (s(e.elements), !o.length) return;
1018
- const c = await Promise.all(o.map((f) => Ht(f.el)));
1044
+ if (s(e.elements, []), !o.length) return;
1045
+ const l = await Promise.all(o.map((f) => Qt(f.el)));
1019
1046
  if (this.disposed) {
1020
1047
  for (const f of o) K(f.el);
1021
1048
  return;
1022
1049
  }
1023
- const l = o.filter((f, u) => {
1024
- var i;
1025
- return c[u] ? !0 : (K(f.el), (i = this.warn) == null || i.call(this, "video-overlay-unavailable", { slideNumber: a, elementName: f.name }), !1);
1050
+ const i = o.filter((f, u) => {
1051
+ var c;
1052
+ return l[u] ? (f.durationS = f.el.duration, !0) : (K(f.el), (c = this.warn) == null || c.call(this, "video-overlay-unavailable", { slideNumber: n, elementName: f.name }), !1);
1026
1053
  });
1027
- this.videos.set(a, l);
1054
+ this.videos.set(n, i);
1028
1055
  }
1029
1056
  /**
1030
- * 把当前时间轴的视频帧画到画布。在 SVG 光栅化之后调用,叠加在海报帧之上。
1057
+ * 把当前时间轴的视频帧画到画布。在 SVG 光栅化之后调用,叠加在海报帧之上;
1031
1058
  * scaleX/scaleY 把幻灯片坐标换算到导出画布坐标。
1032
1059
  */
1033
- async draw(t, e, a, n, o) {
1034
- var c;
1060
+ async draw(t, e, n, a, o) {
1061
+ var l;
1035
1062
  const s = this.videos.get(e);
1036
1063
  if (s)
1037
- for (const l of s) {
1038
- const f = (a - l.startMs) / 1e3;
1064
+ for (const i of s) {
1065
+ const f = (n - i.startMs) / 1e3;
1039
1066
  if (f < 0) continue;
1040
- const u = Math.min(f, l.el.duration);
1041
- (!(Math.abs(l.el.currentTime - u) <= 1 / 30 || await Gt(l.el, u)) || l.el.readyState < 2) && (l.frameWarned || (l.frameWarned = !0, (c = this.warn) == null || c.call(this, "video-overlay-frame-unavailable", { slideNumber: e, elementName: l.name })), l.el.readyState < 2) || t.drawImage(l.el, l.x * n, l.y * o, l.w * n, l.h * o);
1067
+ const u = i.loop ? i.durationS > 0 ? f % i.durationS : 0 : Math.min(f, i.durationS);
1068
+ if ((!(Math.abs(i.el.currentTime - u) <= 1 / 30 || await Zt(i.el, u)) || i.el.readyState < 2) && (i.frameWarned || (i.frameWarned = !0, (l = this.warn) == null || l.call(this, "video-overlay-frame-unavailable", { slideNumber: e, elementName: i.name })), i.el.readyState < 2))
1069
+ continue;
1070
+ t.save(), t.setTransform(new DOMMatrix().scaleSelf(a, o));
1071
+ for (const m of i.chain) t.transform(m.a, m.b, m.c, m.d, m.e, m.f);
1072
+ t.transform(...(() => {
1073
+ const m = pt(i);
1074
+ return [m.a, m.b, m.c, m.d, m.e, m.f];
1075
+ })());
1076
+ const h = yt(i);
1077
+ t.transform(h.a, h.b, h.c, h.d, h.e, h.f), i.clipPath && t.clip(new Path2D(i.clipPath)), i.alpha !== void 0 && (t.globalAlpha *= Math.max(0, Math.min(1, i.alpha))), i.filter && (t.filter = i.filter);
1078
+ const d = i.el;
1079
+ if (i.crop && (i.crop.l || i.crop.t || i.crop.r || i.crop.b)) {
1080
+ const m = d.videoWidth, g = d.videoHeight;
1081
+ t.drawImage(
1082
+ d,
1083
+ i.crop.l * m,
1084
+ i.crop.t * g,
1085
+ Math.max(1, (1 - i.crop.l - i.crop.r) * m),
1086
+ Math.max(1, (1 - i.crop.t - i.crop.b) * g),
1087
+ 0,
1088
+ 0,
1089
+ i.w,
1090
+ i.h
1091
+ );
1092
+ } else
1093
+ t.drawImage(d, 0, 0, i.w, i.h);
1094
+ t.restore();
1042
1095
  }
1043
1096
  }
1044
1097
  dispose() {
@@ -1047,28 +1100,28 @@ class Kt {
1047
1100
  this.videos.clear();
1048
1101
  }
1049
1102
  }
1050
- const pt = (r) => {
1051
- const t = [], e = (a) => {
1052
- for (const n of a)
1053
- n.kind === "image" && n.media && n.media.playback && n.media.src ? t.push(n) : n.kind === "group" && e(n.children);
1103
+ const wt = (r) => {
1104
+ const t = [], e = (n) => {
1105
+ for (const a of n)
1106
+ a.kind === "image" && a.media && a.media.playback && a.media.src ? t.push(a) : a.kind === "group" && e(a.children);
1054
1107
  };
1055
1108
  return e(r), t;
1056
1109
  };
1057
- async function Qt(r, t) {
1110
+ async function te(r, t) {
1058
1111
  const e = await fetch(r, { signal: t });
1059
1112
  if (!e.ok) throw new Error(`音频媒体读取失败:HTTP ${e.status}`);
1060
- const a = await e.arrayBuffer(), n = globalThis.OfflineAudioContext;
1061
- if (!n) throw new Error("当前浏览器不支持音频解码(OfflineAudioContext 缺失)");
1062
- const o = await new n(1, 1, 48e3).decodeAudioData(a), s = new Float32Array(o.length * o.numberOfChannels);
1063
- for (let c = 0; c < o.numberOfChannels; c++)
1064
- s.set(o.getChannelData(c), c * o.length);
1113
+ const n = await e.arrayBuffer(), a = globalThis.OfflineAudioContext;
1114
+ if (!a) throw new Error("当前浏览器不支持音频解码(OfflineAudioContext 缺失)");
1115
+ const o = await new a(1, 1, 48e3).decodeAudioData(n), s = new Float32Array(o.length * o.numberOfChannels);
1116
+ for (let l = 0; l < o.numberOfChannels; l++)
1117
+ s.set(o.getChannelData(l), l * o.length);
1065
1118
  return { samples: s, sampleRate: o.sampleRate, channels: Math.min(2, o.numberOfChannels) };
1066
1119
  }
1067
- async function Zt(r, t, e, a, n) {
1068
- const o = { codec: "opus", sampleRate: e, numberOfChannels: a, bitrate: 96e3 };
1120
+ async function ee(r, t, e, n, a) {
1121
+ const o = { codec: "opus", sampleRate: e, numberOfChannels: n, bitrate: 96e3 };
1069
1122
  if (typeof AudioEncoder > "u" || typeof AudioData > "u" || !(await AudioEncoder.isConfigSupported(o)).supported) throw new Error("当前浏览器不支持 Opus 音频编码");
1070
1123
  let s;
1071
- const c = new AudioEncoder({ output: (f) => {
1124
+ const l = new AudioEncoder({ output: (f) => {
1072
1125
  try {
1073
1126
  const u = new Uint8Array(f.byteLength);
1074
1127
  f.copyTo(u), r.addAudio(u, Math.round(f.timestamp / 1e3));
@@ -1077,172 +1130,172 @@ async function Zt(r, t, e, a, n) {
1077
1130
  }
1078
1131
  }, error: (f) => {
1079
1132
  s = f;
1080
- } }), l = () => {
1081
- c.state !== "closed" && c.close();
1133
+ } }), i = () => {
1134
+ l.state !== "closed" && l.close();
1082
1135
  };
1083
- n == null || n.addEventListener("abort", l, { once: !0 });
1136
+ a == null || a.addEventListener("abort", i, { once: !0 });
1084
1137
  try {
1085
- c.configure(o);
1138
+ l.configure(o);
1086
1139
  const f = Math.round(e * 0.02);
1087
- for (let u = 0; u * a < t.length; u += f) {
1088
- if (n != null && n.aborted) throw new DOMException("视频导出已取消", "AbortError");
1140
+ for (let u = 0; u * n < t.length; u += f) {
1141
+ if (a != null && a.aborted) throw new DOMException("视频导出已取消", "AbortError");
1089
1142
  if (s) throw s;
1090
- const i = Math.min(f, Math.floor(t.length / a) - u);
1091
- if (i <= 0) break;
1143
+ const c = Math.min(f, Math.floor(t.length / n) - u);
1144
+ if (c <= 0) break;
1092
1145
  const h = new AudioData({
1093
1146
  format: "f32",
1094
1147
  sampleRate: e,
1095
- numberOfFrames: i,
1096
- numberOfChannels: a,
1148
+ numberOfFrames: c,
1149
+ numberOfChannels: n,
1097
1150
  timestamp: Math.round(u / e * 1e6),
1098
- data: new Float32Array(t.subarray(u * a, (u + i) * a))
1151
+ data: new Float32Array(t.subarray(u * n, (u + c) * n))
1099
1152
  });
1100
1153
  try {
1101
- c.encode(h);
1154
+ l.encode(h);
1102
1155
  } finally {
1103
1156
  h.close();
1104
1157
  }
1105
- c.encodeQueueSize >= 16 && await new Promise((d) => {
1106
- const w = () => {
1107
- (c.encodeQueueSize < 16 || s) && (c.removeEventListener("dequeue", w), d());
1158
+ l.encodeQueueSize >= 16 && await new Promise((d) => {
1159
+ const m = () => {
1160
+ (l.encodeQueueSize < 16 || s) && (l.removeEventListener("dequeue", m), d());
1108
1161
  };
1109
- c.addEventListener("dequeue", w), w();
1162
+ l.addEventListener("dequeue", m), m();
1110
1163
  });
1111
1164
  }
1112
- if (await c.flush(), s) throw s;
1165
+ if (await l.flush(), s) throw s;
1113
1166
  } finally {
1114
- n == null || n.removeEventListener("abort", l), l();
1167
+ a == null || a.removeEventListener("abort", i), i();
1115
1168
  }
1116
1169
  }
1117
- async function te(r, t = {}) {
1118
- var m, R, N;
1119
- const e = Dt(r, t), a = () => {
1120
- var p;
1121
- if ((p = t.signal) != null && p.aborted) throw new DOMException("视频导出已取消", "AbortError");
1170
+ async function oe(r, t = {}) {
1171
+ var p, R, N;
1172
+ const e = Ht(r, t), n = () => {
1173
+ var y;
1174
+ if ((y = t.signal) != null && y.aborted) throw new DOMException("视频导出已取消", "AbortError");
1122
1175
  };
1123
- if (a(), typeof VideoEncoder > "u" || typeof VideoFrame > "u" || typeof document > "u") throw new Error("当前浏览器不支持 WebCodecs 视频编码,请使用支持的 HTTPS 或本机浏览器");
1124
- const n = (p) => p.some((b) => b.kind === "image" && !!b.media || b.kind === "group" && n(b.children));
1125
- if (!t.mediaPosters && e.pages.some((p) => n(p.slide.elements))) throw new Error("文稿含内嵌音视频,导出时可能以静态封面呈现(含 audio / videoOverlay 未覆盖或失败的媒体);请设置 mediaPosters: true 显式允许");
1176
+ if (n(), typeof VideoEncoder > "u" || typeof VideoFrame > "u" || typeof document > "u") throw new Error("当前浏览器不支持 WebCodecs 视频编码,请使用支持的 HTTPS 或本机浏览器");
1177
+ const a = (y) => y.some((v) => v.kind === "image" && !!v.media || v.kind === "group" && a(v.children));
1178
+ if (!t.mediaPosters && e.pages.some((y) => a(y.slide.elements))) throw new Error("文稿含内嵌音视频,导出时可能以静态封面呈现(含 audio / videoOverlay 未覆盖或失败的媒体);请设置 mediaPosters: true 显式允许");
1126
1179
  let o, s = "VP9";
1127
- for (const p of ["vp09.00.10.08", "vp8"]) {
1128
- const b = { codec: p, width: e.width, height: e.height, framerate: e.fps, bitrate: e.bitrate, latencyMode: "realtime" };
1129
- if ((await VideoEncoder.isConfigSupported(b)).supported) {
1130
- o = b, s = p === "vp8" ? "VP8" : "VP9";
1180
+ for (const y of ["vp09.00.10.08", "vp8"]) {
1181
+ const v = { codec: y, width: e.width, height: e.height, framerate: e.fps, bitrate: e.bitrate, latencyMode: "realtime" };
1182
+ if ((await VideoEncoder.isConfigSupported(v)).supported) {
1183
+ o = v, s = y === "vp8" ? "VP8" : "VP9";
1131
1184
  break;
1132
1185
  }
1133
1186
  }
1134
1187
  if (!o) throw new Error("当前浏览器没有支持此尺寸的 VP8/VP9 视频编码器");
1135
- a();
1136
- const c = !!t.audio && e.pages.some((p) => pt(p.slide.elements).length > 0), l = new Bt(e.width, e.height, e.fps, s, c ? { sampleRate: 48e3, channels: 2 } : void 0);
1188
+ n();
1189
+ const l = !!t.audio && e.pages.some((y) => wt(y.slide.elements).length > 0), i = new qt(e.width, e.height, e.fps, s, l ? { sampleRate: 48e3, channels: 2 } : void 0);
1137
1190
  let f, u = 0;
1138
- const i = new VideoEncoder({
1139
- output: (p) => {
1191
+ const c = new VideoEncoder({
1192
+ output: (y) => {
1140
1193
  try {
1141
- const b = new Uint8Array(p.byteLength);
1142
- p.copyTo(b), l.addFrame(b, p.timestamp, p.duration ?? Math.round(1e6 / e.fps), p.type === "key");
1143
- } catch (b) {
1144
- f = b;
1194
+ const v = new Uint8Array(y.byteLength);
1195
+ y.copyTo(v), i.addFrame(v, y.timestamp, y.duration ?? Math.round(1e6 / e.fps), y.type === "key");
1196
+ } catch (v) {
1197
+ f = v;
1145
1198
  }
1146
1199
  },
1147
- error: (p) => {
1148
- f = p;
1200
+ error: (y) => {
1201
+ f = y;
1149
1202
  }
1150
1203
  }), h = document.createElement("canvas");
1151
1204
  h.width = e.width, h.height = e.height;
1152
1205
  const d = h.getContext("2d");
1153
1206
  if (!d)
1154
- throw i.close(), new Error("无法获取视频画布");
1155
- const w = new Vt(r, !!t.showComments), v = t.videoOverlay ? new Kt(t.onWarning) : null, E = () => {
1156
- i.state !== "closed" && i.close();
1207
+ throw c.close(), new Error("无法获取视频画布");
1208
+ const m = new Bt(r, !!t.showComments), g = t.videoOverlay ? new Jt(t.onWarning) : null, k = () => {
1209
+ c.state !== "closed" && c.close();
1157
1210
  };
1158
- (m = t.signal) == null || m.addEventListener("abort", E, { once: !0 });
1211
+ (p = t.signal) == null || p.addEventListener("abort", k, { once: !0 });
1159
1212
  const A = () => {
1160
- if (a(), f) throw f;
1213
+ if (n(), f) throw f;
1161
1214
  }, I = async () => {
1162
- i.encodeQueueSize < 8 || (await new Promise((p, b) => {
1163
- var T;
1215
+ c.encodeQueueSize < 8 || (await new Promise((y, v) => {
1216
+ var O;
1164
1217
  const P = () => {
1165
- var F;
1166
- clearTimeout(W), i.removeEventListener("dequeue", y), (F = t.signal) == null || F.removeEventListener("abort", Y);
1167
- }, y = () => {
1168
- (i.encodeQueueSize < 8 || f) && (P(), p());
1218
+ var T;
1219
+ clearTimeout(W), c.removeEventListener("dequeue", w), (T = t.signal) == null || T.removeEventListener("abort", Y);
1220
+ }, w = () => {
1221
+ (c.encodeQueueSize < 8 || f) && (P(), y());
1169
1222
  }, Y = () => {
1170
- P(), b(new DOMException("视频导出已取消", "AbortError"));
1223
+ P(), v(new DOMException("视频导出已取消", "AbortError"));
1171
1224
  }, W = setTimeout(() => {
1172
- P(), b(new Error("视频编码器等待超时"));
1225
+ P(), v(new Error("视频编码器等待超时"));
1173
1226
  }, 3e4);
1174
- i.addEventListener("dequeue", y), (T = t.signal) == null || T.addEventListener("abort", Y, { once: !0 }), y();
1227
+ c.addEventListener("dequeue", w), (O = t.signal) == null || O.addEventListener("abort", Y, { once: !0 }), w();
1175
1228
  }), A());
1176
- }, g = async (p, b, P = [], y) => {
1229
+ }, b = async (y, v, P = [], w) => {
1177
1230
  var W;
1178
- const Y = e.frames(p);
1179
- for (let T = 0; T < Y; T++) {
1231
+ const Y = e.frames(y);
1232
+ for (let O = 0; O < Y; O++) {
1180
1233
  A();
1181
- for (const L of P) L.currentTime = p * T / Y;
1182
- await w.draw(d, e.width, e.height), A(), v && await v.draw(d, b, (y ?? 0) + p * T / Y, e.width / r.width, e.height / r.height), await I();
1183
- const F = Math.round(u * 1e6 / e.fps), O = Math.round((u + 1) * 1e6 / e.fps), S = new VideoFrame(h, { timestamp: F, duration: O - F });
1234
+ for (const X of P) X.currentTime = y * O / Y;
1235
+ await m.draw(d, e.width, e.height), A(), g && await g.draw(d, v, (w ?? 0) + y * O / Y, e.width / r.width, e.height / r.height), await I();
1236
+ const T = Math.round(u * 1e6 / e.fps), F = Math.round((u + 1) * 1e6 / e.fps), S = new VideoFrame(h, { timestamp: T, duration: F - T });
1184
1237
  try {
1185
- i.encode(S, { keyFrame: u % (e.fps * 2) === 0 });
1238
+ c.encode(S, { keyFrame: u % (e.fps * 2) === 0 });
1186
1239
  } finally {
1187
1240
  S.close();
1188
1241
  }
1189
- u++, (W = t.onProgress) == null || W.call(t, { completed: u, total: e.total, slideNumber: b });
1242
+ u++, (W = t.onProgress) == null || W.call(t, { completed: u, total: e.total, slideNumber: v });
1190
1243
  }
1191
- w.settle(P), await Promise.resolve();
1244
+ m.settle(P), await Promise.resolve();
1192
1245
  };
1193
1246
  try {
1194
- const p = [];
1195
- i.configure(o);
1196
- let b, P = 0;
1197
- for (const y of e.pages) {
1247
+ const y = [];
1248
+ c.configure(o);
1249
+ let v, P = 0;
1250
+ for (const w of e.pages) {
1198
1251
  A();
1199
- const Y = y.groups.length ? kt(y.groups, 0) : xt(y.slide), W = b && y.transition ? y.transition : 0, T = await w.page(y.slide, [...Y]);
1252
+ const Y = w.groups.length ? Et(w.groups, 0) : Pt(w.slide), W = v && w.transition ? w.transition : 0, O = await m.page(w.slide, [...Y]);
1200
1253
  A();
1201
- const F = [];
1254
+ const T = [];
1202
1255
  {
1203
1256
  let S = P + W;
1204
- for (const L of y.groups)
1205
- F.push(S), S += (y.click ?? 0) + _(L);
1257
+ for (const X of w.groups)
1258
+ T.push(S), S += (w.click ?? 0) + _(X);
1206
1259
  }
1207
- v && await v.load(r, y.slide, y.slideNumber, F);
1208
- let O = P;
1209
- if (W && (await g(y.transition, y.slideNumber, w.transition(b, T, y.slide), O), O += W), b == null || b.remove(), t.audio)
1210
- for (const S of pt(y.slide.elements)) {
1211
- const L = S.media.playback, it = F.length ? F[Math.min(L.clickGroup, F.length - 1)] : P + W;
1212
- let B;
1260
+ g && await g.load(r, w.slide, w.slideNumber, T);
1261
+ let F = P;
1262
+ if (W && (await b(w.transition, w.slideNumber, m.transition(v, O, w.slide), F), F += W), v == null || v.remove(), t.audio)
1263
+ for (const S of wt(w.slide.elements)) {
1264
+ const X = S.media.playback, it = T.length ? T[Math.min(X.clickGroup, T.length - 1)] : P + W;
1265
+ let z;
1213
1266
  try {
1214
- B = await Qt(S.media.src, t.signal);
1215
- } catch (j) {
1216
- if (!(j instanceof DOMException && j.name === "AbortError") && S.media.kind === "video") {
1217
- (R = t.onWarning) == null || R.call(t, "video-audio-decode-failed", { slideNumber: y.slideNumber, elementName: S.name ?? "" });
1267
+ z = await te(S.media.src, t.signal);
1268
+ } catch (U) {
1269
+ if (!(U instanceof DOMException && U.name === "AbortError") && S.media.kind === "video") {
1270
+ (R = t.onWarning) == null || R.call(t, "video-audio-decode-failed", { slideNumber: w.slideNumber, elementName: S.name ?? "" });
1218
1271
  continue;
1219
1272
  }
1220
- throw j;
1273
+ throw U;
1221
1274
  }
1222
- A(), p.push({
1223
- samples: B.samples,
1224
- sampleRate: B.sampleRate,
1225
- channels: B.channels,
1275
+ A(), y.push({
1276
+ samples: z.samples,
1277
+ sampleRate: z.sampleRate,
1278
+ channels: z.channels,
1226
1279
  startMs: it,
1227
- loop: L.loop,
1228
- volume: L.volume,
1229
- endMs: L.loop ? void 0 : it + B.samples.length / B.channels / B.sampleRate * 1e3
1280
+ loop: X.loop,
1281
+ volume: X.volume,
1282
+ endMs: X.loop ? void 0 : it + z.samples.length / z.channels / z.sampleRate * 1e3
1230
1283
  });
1231
1284
  }
1232
- for (const S of y.groups)
1233
- y.click && (await g(y.click, y.slideNumber, void 0, O), O += y.click), await g(_(S), y.slideNumber, w.group(T, S), O), O += _(S);
1234
- await g(y.hold, y.slideNumber, void 0, O), O += y.hold, P = O, b = T;
1285
+ for (const S of w.groups)
1286
+ w.click && (await b(w.click, w.slideNumber, void 0, F), F += w.click), await b(_(S), w.slideNumber, m.group(O, S), F), F += _(S);
1287
+ await b(w.hold, w.slideNumber, void 0, F), F += w.hold, P = F, v = O;
1235
1288
  }
1236
- if (await i.flush(), A(), t.audio && p.length) {
1237
- const y = Math.round(u / e.fps * 1e3), Y = qt(p, y, { sampleRate: 48e3, channels: 2 });
1238
- await Zt(l, Y, 48e3, 2, t.signal);
1289
+ if (await c.flush(), A(), t.audio && y.length) {
1290
+ const w = Math.round(u / e.fps * 1e3), Y = jt(y, w, { sampleRate: 48e3, channels: 2 });
1291
+ await ee(i, Y, 48e3, 2, t.signal);
1239
1292
  }
1240
- return l.finish();
1293
+ return i.finish();
1241
1294
  } finally {
1242
- (N = t.signal) == null || N.removeEventListener("abort", E), E(), v == null || v.dispose(), w.dispose(), h.width = h.height = 0;
1295
+ (N = t.signal) == null || N.removeEventListener("abort", k), k(), g == null || g.dispose(), m.dispose(), h.width = h.height = 0;
1243
1296
  }
1244
1297
  }
1245
1298
  export {
1246
- te as presentationToVideo,
1247
- Dt as videoPlan
1299
+ oe as presentationToVideo,
1300
+ Ht as videoPlan
1248
1301
  };