@algorisys/tinyfly 0.67.1 → 0.69.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/README.md +17 -16
- package/bin/tinyfly.mjs +20 -6
- package/lib/addons/gsap-compat.js +202 -198
- package/lib/browser/tinyfly.iife.js +18 -3
- package/lib/browser/tinyfly.js +1153 -954
- package/lib/browser/tinyfly.umd.js +18 -3
- package/lib/cli/tools.js +34 -1
- package/lib/embed/tinyfly-embed.iife.js +18 -3
- package/lib/embed/tinyfly-embed.js +972 -749
- package/lib/player/tinyfly-player.es.js +200 -128
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/browser/index.d.ts +1 -0
- package/lib/types/compat/gsap/live.d.ts +1 -1
- package/lib/types/compat/gsap/stage.d.ts +8 -0
- package/lib/types/embed/choices.d.ts +3 -0
- package/lib/types/embed/controls.d.ts +10 -2
- package/lib/types/embed/index.d.ts +3 -2
- package/lib/types/embed/mount.d.ts +7 -0
- package/lib/types/embed/tools.d.ts +10 -0
- package/lib/types/player/index.d.ts +1 -1
- package/lib/types/player/player.d.ts +50 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
function
|
|
1
|
+
function he(e) {
|
|
2
2
|
return typeof e == "object" && e !== null && e.type === "cubic-bezier";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function ue(e) {
|
|
5
5
|
return typeof e == "object" && e !== null && e.type !== "cubic-bezier";
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
function
|
|
7
|
+
const J = 1;
|
|
8
|
+
function Ht(e) {
|
|
9
9
|
return e.property === "text" && "textConfig" in e;
|
|
10
10
|
}
|
|
11
11
|
function mt(e) {
|
|
@@ -14,14 +14,14 @@ function mt(e) {
|
|
|
14
14
|
function gt(e) {
|
|
15
15
|
return e.kind === "spring" && "spring" in e;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function de(e) {
|
|
18
18
|
return e.property === "motionPath" && "motionPathConfig" in e;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Gt(e, t, s = "start") {
|
|
21
21
|
if (t <= 1) return 0;
|
|
22
22
|
if (typeof s == "number") {
|
|
23
|
-
const
|
|
24
|
-
return Math.abs(e -
|
|
23
|
+
const i = Math.max(0, Math.min(t - 1, s));
|
|
24
|
+
return Math.abs(e - i);
|
|
25
25
|
}
|
|
26
26
|
switch (s) {
|
|
27
27
|
case "end":
|
|
@@ -34,29 +34,29 @@ function jt(e, t, s = "start") {
|
|
|
34
34
|
return e;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function fe(e, t = "start") {
|
|
38
38
|
if (e <= 1) return 0;
|
|
39
39
|
let s = 0;
|
|
40
|
-
for (let
|
|
41
|
-
s = Math.max(s,
|
|
40
|
+
for (let i = 0; i < e; i++)
|
|
41
|
+
s = Math.max(s, Gt(i, e, t));
|
|
42
42
|
return s;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function zt(e, t, s) {
|
|
45
45
|
if (s.offsets) return s.offsets[e] ?? 0;
|
|
46
|
-
const
|
|
46
|
+
const i = s.from ?? "start", n = Gt(e, t, i);
|
|
47
47
|
if (s.amount !== void 0) {
|
|
48
|
-
const r =
|
|
49
|
-
return r === 0 ? 0 : s.amount *
|
|
48
|
+
const r = fe(t, i);
|
|
49
|
+
return r === 0 ? 0 : s.amount * n / r;
|
|
50
50
|
}
|
|
51
|
-
return s.each !== void 0 ? s.each *
|
|
51
|
+
return s.each !== void 0 ? s.each * n : 0;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return Array.from({ length: e }, (s,
|
|
53
|
+
function pe(e, t) {
|
|
54
|
+
return Array.from({ length: e }, (s, i) => zt(i, e, t));
|
|
55
55
|
}
|
|
56
56
|
function Mt(e, t) {
|
|
57
|
-
return e <= 1 ? 0 : Math.max(...
|
|
57
|
+
return e <= 1 ? 0 : Math.max(...pe(e, t));
|
|
58
58
|
}
|
|
59
|
-
const Z = 1,
|
|
59
|
+
const Z = 1, Qt = 6e4, et = Qt / Z, W = {
|
|
60
60
|
stiffness: 180,
|
|
61
61
|
damping: 12,
|
|
62
62
|
mass: 1,
|
|
@@ -64,7 +64,7 @@ const Z = 1, zt = 6e4, tt = zt / Z, V = {
|
|
|
64
64
|
restDelta: 0.01,
|
|
65
65
|
restSpeed: 0.1
|
|
66
66
|
};
|
|
67
|
-
class
|
|
67
|
+
class me {
|
|
68
68
|
from;
|
|
69
69
|
to;
|
|
70
70
|
stiffness;
|
|
@@ -89,7 +89,7 @@ class ue {
|
|
|
89
89
|
/** Once at rest we stop simulating; every later time returns `to`. */
|
|
90
90
|
settledStep = null;
|
|
91
91
|
constructor(t) {
|
|
92
|
-
this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ??
|
|
92
|
+
this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ?? W.stiffness, this.damping = t.damping ?? W.damping, this.mass = t.mass ?? W.mass, this.restDelta = t.restDelta ?? W.restDelta, this.restSpeed = t.restSpeed ?? W.restSpeed, this.distance = Math.abs(this.to - this.from) || 1, this.samples = [this.from], this.velocity = t.velocity ?? W.velocity, this.isAtRest(this.from) && (this.settledStep = 0);
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Whether a position/velocity pair counts as settled.
|
|
@@ -110,134 +110,134 @@ class ue {
|
|
|
110
110
|
const s = Math.floor(t / Z);
|
|
111
111
|
if (this.simulateTo(s + 1), this.settledStep !== null && s >= this.settledStep)
|
|
112
112
|
return this.to;
|
|
113
|
-
const
|
|
114
|
-
return
|
|
113
|
+
const i = this.samples[Math.min(s, this.samples.length - 1)], n = this.samples[Math.min(s + 1, this.samples.length - 1)], r = t / Z - s;
|
|
114
|
+
return i + (n - i) * r;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* How long the spring takes to settle, in milliseconds — the natural duration
|
|
118
118
|
* of a spring track. Runs the simulation to completion once.
|
|
119
119
|
*/
|
|
120
120
|
settleTime() {
|
|
121
|
-
return this.simulateTo(
|
|
121
|
+
return this.simulateTo(et + 1), this.settledStep !== null ? this.settledStep * Z : Qt;
|
|
122
122
|
}
|
|
123
123
|
/** Advance the cached simulation until it holds at least `steps` samples. */
|
|
124
124
|
simulateTo(t) {
|
|
125
125
|
if (this.settledStep !== null) return;
|
|
126
|
-
const s = Math.min(t,
|
|
126
|
+
const s = Math.min(t, et + 1), i = Z / 1e3;
|
|
127
127
|
for (; this.samples.length < s; ) {
|
|
128
|
-
const
|
|
129
|
-
this.velocity += c *
|
|
130
|
-
const l =
|
|
128
|
+
const n = this.samples[this.samples.length - 1], r = n - this.to, a = -this.stiffness * r, o = -this.damping * this.velocity, c = (a + o) / this.mass;
|
|
129
|
+
this.velocity += c * i;
|
|
130
|
+
const l = n + this.velocity * i;
|
|
131
131
|
if (this.samples.push(l), this.isAtRest(l)) {
|
|
132
132
|
this.settledStep = this.samples.length - 1;
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
this.samples.length >
|
|
136
|
+
this.samples.length > et && (this.settledStep = et);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
function
|
|
141
|
-
const t = e.friction ??
|
|
142
|
-
return t > 0 ? t :
|
|
139
|
+
const vt = 4, ge = 2e-3, ye = 1e-4, be = 6e4;
|
|
140
|
+
function St(e) {
|
|
141
|
+
const t = e.friction ?? vt;
|
|
142
|
+
return t > 0 ? t : vt;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return e.from + e.velocity /
|
|
144
|
+
function ke(e) {
|
|
145
|
+
return e.from + e.velocity / St(e);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function xe(e, t) {
|
|
148
148
|
if (t === void 0) return e;
|
|
149
149
|
if (typeof t == "number")
|
|
150
150
|
return t > 0 ? Math.round(e / t) * t : e;
|
|
151
151
|
if (t.length === 0) return e;
|
|
152
152
|
let s = t[0];
|
|
153
|
-
for (const
|
|
154
|
-
Math.abs(
|
|
153
|
+
for (const i of t)
|
|
154
|
+
Math.abs(i - e) < Math.abs(s - e) && (s = i);
|
|
155
155
|
return s;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
let t =
|
|
157
|
+
function Zt(e) {
|
|
158
|
+
let t = xe(ke(e), e.end);
|
|
159
159
|
return e.min !== void 0 && (t = Math.max(e.min, t)), e.max !== void 0 && (t = Math.min(e.max, t)), t;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
const t = Math.abs(
|
|
161
|
+
function Kt(e) {
|
|
162
|
+
const t = Math.abs(Zt(e) - e.from);
|
|
163
163
|
if (t === 0) return 0;
|
|
164
|
-
const s = e.restDelta ?? Math.max(
|
|
164
|
+
const s = e.restDelta ?? Math.max(ye, t * ge);
|
|
165
165
|
if (s >= t) return 0;
|
|
166
|
-
const
|
|
167
|
-
return Math.min(
|
|
166
|
+
const i = Math.log(t / s) / St(e);
|
|
167
|
+
return Math.min(be, i * 1e3);
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function Tt(e, t) {
|
|
170
170
|
if (t <= 0) return e.from;
|
|
171
|
-
const s =
|
|
172
|
-
if (t >=
|
|
173
|
-
const
|
|
174
|
-
return e.from + (s - e.from) * (1 - Math.exp(-
|
|
171
|
+
const s = Zt(e);
|
|
172
|
+
if (t >= Kt(e)) return s;
|
|
173
|
+
const i = St(e);
|
|
174
|
+
return e.from + (s - e.from) * (1 - Math.exp(-i * t / 1e3));
|
|
175
175
|
}
|
|
176
|
-
const yt = (e) => e,
|
|
176
|
+
const yt = (e) => e, Me = (e) => e * e, Se = (e) => 1 - (1 - e) * (1 - e), we = (e) => e < 0.5 ? 2 * e * e : 1 - Math.pow(-2 * e + 2, 2) / 2, Jt = (e) => e * e * e, te = (e) => 1 - Math.pow(1 - e, 3), ee = (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2, ve = Jt, Te = te, _e = ee, Ae = {
|
|
177
177
|
linear: yt,
|
|
178
|
-
"ease-in":
|
|
178
|
+
"ease-in": ve,
|
|
179
179
|
"ease-out": Te,
|
|
180
|
-
"ease-in-out":
|
|
181
|
-
"ease-in-quad":
|
|
182
|
-
"ease-out-quad":
|
|
183
|
-
"ease-in-out-quad":
|
|
184
|
-
"ease-in-cubic":
|
|
185
|
-
"ease-out-cubic":
|
|
186
|
-
"ease-in-out-cubic":
|
|
180
|
+
"ease-in-out": _e,
|
|
181
|
+
"ease-in-quad": Me,
|
|
182
|
+
"ease-out-quad": Se,
|
|
183
|
+
"ease-in-out-quad": we,
|
|
184
|
+
"ease-in-cubic": Jt,
|
|
185
|
+
"ease-out-cubic": te,
|
|
186
|
+
"ease-in-out-cubic": ee
|
|
187
187
|
};
|
|
188
|
-
function
|
|
189
|
-
const [t, s,
|
|
188
|
+
function Pe(e) {
|
|
189
|
+
const [t, s, i, n] = e, r = 3 * t, a = 3 * (i - t) - r, o = 1 - r - a, c = 3 * s, l = 3 * (n - s) - c, u = 1 - c - l, h = (p) => ((o * p + a) * p + r) * p, d = (p) => ((u * p + l) * p + c) * p, f = (p) => (3 * o * p + 2 * a) * p + r, g = (p) => {
|
|
190
190
|
let m = p;
|
|
191
|
-
for (let
|
|
191
|
+
for (let x = 0; x < 8; x++) {
|
|
192
192
|
const w = h(m) - p;
|
|
193
193
|
if (Math.abs(w) < 1e-7)
|
|
194
194
|
return m;
|
|
195
|
-
const
|
|
196
|
-
if (Math.abs(
|
|
195
|
+
const y = f(m);
|
|
196
|
+
if (Math.abs(y) < 1e-7)
|
|
197
197
|
break;
|
|
198
|
-
m -= w /
|
|
198
|
+
m -= w / y;
|
|
199
199
|
}
|
|
200
|
-
let
|
|
201
|
-
for (m = p;
|
|
202
|
-
const
|
|
203
|
-
if (Math.abs(
|
|
200
|
+
let b = 0, k = 1;
|
|
201
|
+
for (m = p; b < k; ) {
|
|
202
|
+
const x = h(m);
|
|
203
|
+
if (Math.abs(x - p) < 1e-7)
|
|
204
204
|
return m;
|
|
205
|
-
p >
|
|
205
|
+
p > x ? b = m : k = m, m = (b + k) / 2;
|
|
206
206
|
}
|
|
207
207
|
return m;
|
|
208
208
|
};
|
|
209
209
|
return (p) => {
|
|
210
210
|
if (p <= 0) return 0;
|
|
211
211
|
if (p >= 1) return 1;
|
|
212
|
-
const m =
|
|
213
|
-
return
|
|
212
|
+
const m = g(p);
|
|
213
|
+
return d(m);
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
function ct(e, t = "out") {
|
|
217
217
|
if (t === "out") return e;
|
|
218
|
-
const s = (
|
|
219
|
-
return t === "in" ? s : (
|
|
218
|
+
const s = (i) => 1 - e(1 - i);
|
|
219
|
+
return t === "in" ? s : (i) => i < 0.5 ? s(i * 2) / 2 : e(i * 2 - 1) / 2 + 0.5;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
const s = Math.max(1, e),
|
|
223
|
-
return (
|
|
221
|
+
function Ce(e = 1, t = 0.3) {
|
|
222
|
+
const s = Math.max(1, e), i = t / (2 * Math.PI) * Math.asin(1 / s);
|
|
223
|
+
return (n) => n <= 0 ? 0 : n >= 1 ? 1 : s * Math.pow(2, -10 * n) * Math.sin((n - i) * (2 * Math.PI) / t) + 1;
|
|
224
224
|
}
|
|
225
|
-
const
|
|
225
|
+
const Ie = (e) => {
|
|
226
226
|
if (e <= 0) return 0;
|
|
227
227
|
if (e >= 1) return 1;
|
|
228
228
|
if (e < 1 / 2.75) return 7.5625 * e * e;
|
|
229
229
|
if (e < 2 / 2.75) {
|
|
230
|
-
const
|
|
231
|
-
return 7.5625 *
|
|
230
|
+
const n = e - 0.5454545454545454;
|
|
231
|
+
return 7.5625 * n * n + 0.75;
|
|
232
232
|
}
|
|
233
233
|
if (e < 2.5 / 2.75) {
|
|
234
|
-
const
|
|
235
|
-
return 7.5625 *
|
|
234
|
+
const n = e - 0.8181818181818182;
|
|
235
|
+
return 7.5625 * n * n + 0.9375;
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
return 7.5625 *
|
|
237
|
+
const i = e - 2.625 / 2.75;
|
|
238
|
+
return 7.5625 * i * i + 0.984375;
|
|
239
239
|
};
|
|
240
|
-
function
|
|
240
|
+
function Ee(e = 1.70158) {
|
|
241
241
|
return (t) => {
|
|
242
242
|
if (t <= 0) return 0;
|
|
243
243
|
if (t >= 1) return 1;
|
|
@@ -245,40 +245,40 @@ function Ae(e = 1.70158) {
|
|
|
245
245
|
return s * s * ((e + 1) * s + e) + 1;
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function Re(e, t = "end") {
|
|
249
249
|
const s = Math.max(1, Math.floor(e));
|
|
250
|
-
return (
|
|
251
|
-
if (
|
|
252
|
-
if (
|
|
253
|
-
const
|
|
250
|
+
return (i) => {
|
|
251
|
+
if (i >= 1) return 1;
|
|
252
|
+
if (i <= 0) return t === "start" || t === "both" ? t === "start" ? 1 / s : 1 / (s + 1) : 0;
|
|
253
|
+
const n = Math.floor(i * s);
|
|
254
254
|
switch (t) {
|
|
255
255
|
case "start":
|
|
256
|
-
return Math.min(1, (
|
|
256
|
+
return Math.min(1, (n + 1) / s);
|
|
257
257
|
case "both":
|
|
258
|
-
return (
|
|
258
|
+
return (n + 1) / (s + 1);
|
|
259
259
|
case "none":
|
|
260
|
-
return s === 1 ? 0 : Math.min(1,
|
|
260
|
+
return s === 1 ? 0 : Math.min(1, n / (s - 1));
|
|
261
261
|
default:
|
|
262
|
-
return
|
|
262
|
+
return n / s;
|
|
263
263
|
}
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function $e(e) {
|
|
267
267
|
switch (e.type) {
|
|
268
268
|
case "steps":
|
|
269
|
-
return
|
|
269
|
+
return Re(e.count, e.position);
|
|
270
270
|
case "elastic":
|
|
271
|
-
return ct(
|
|
271
|
+
return ct(Ce(e.amplitude, e.period), e.mode);
|
|
272
272
|
case "bounce":
|
|
273
|
-
return ct(
|
|
273
|
+
return ct(Ie, e.mode);
|
|
274
274
|
case "back":
|
|
275
|
-
return ct(
|
|
275
|
+
return ct(Ee(e.overshoot), e.mode);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
function
|
|
279
|
-
return e === void 0 ? yt :
|
|
278
|
+
function De(e) {
|
|
279
|
+
return e === void 0 ? yt : he(e) ? Pe(e.points) : ue(e) ? $e(e) : Ae[e] ?? yt;
|
|
280
280
|
}
|
|
281
|
-
const _t = 32,
|
|
281
|
+
const _t = 32, Le = 256, H = /* @__PURE__ */ new Map(), Oe = /[MmLlHhVvCcSsQqTtAaZz]/, Ne = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, Fe = {
|
|
282
282
|
M: 2,
|
|
283
283
|
L: 2,
|
|
284
284
|
H: 1,
|
|
@@ -290,191 +290,191 @@ const _t = 32, Re = 256, H = /* @__PURE__ */ new Map(), Ee = /[MmLlHhVvCcSsQqTtA
|
|
|
290
290
|
A: 7,
|
|
291
291
|
Z: 0
|
|
292
292
|
};
|
|
293
|
-
function
|
|
293
|
+
function Xe(e) {
|
|
294
294
|
const t = [];
|
|
295
|
-
let s = 0,
|
|
296
|
-
const
|
|
295
|
+
let s = 0, i = null;
|
|
296
|
+
const n = () => {
|
|
297
297
|
for (; s < e.length && /[\s,]/.test(e[s]); ) s++;
|
|
298
298
|
};
|
|
299
|
-
for (; s < e.length && (
|
|
299
|
+
for (; s < e.length && (n(), !(s >= e.length)); ) {
|
|
300
300
|
const r = e[s];
|
|
301
|
-
if (
|
|
302
|
-
|
|
301
|
+
if (Oe.test(r)) {
|
|
302
|
+
i = { type: r, args: [] }, t.push(i), s++;
|
|
303
303
|
continue;
|
|
304
304
|
}
|
|
305
|
-
if (!
|
|
306
|
-
const a =
|
|
305
|
+
if (!i) break;
|
|
306
|
+
const a = i.type === "A" || i.type === "a", o = i.args.length % 7;
|
|
307
307
|
if (a && (o === 3 || o === 4)) {
|
|
308
308
|
if (r !== "0" && r !== "1") break;
|
|
309
|
-
|
|
309
|
+
i.args.push(r === "1" ? 1 : 0), s++;
|
|
310
310
|
continue;
|
|
311
311
|
}
|
|
312
|
-
const c =
|
|
312
|
+
const c = Ne.exec(e.slice(s));
|
|
313
313
|
if (!c) break;
|
|
314
|
-
|
|
314
|
+
i.args.push(parseFloat(c[0])), s += c[0].length;
|
|
315
315
|
}
|
|
316
316
|
return t;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function Ye(e, t, s, i, n, r, a, o, c) {
|
|
319
319
|
if (e === o && t === c) return [];
|
|
320
|
-
let l = Math.abs(s), u = Math.abs(
|
|
320
|
+
let l = Math.abs(s), u = Math.abs(i);
|
|
321
321
|
if (l === 0 || u === 0) return [[e, t, o, c, o, c]];
|
|
322
|
-
const h =
|
|
323
|
-
if (
|
|
324
|
-
const
|
|
325
|
-
l *=
|
|
326
|
-
}
|
|
327
|
-
const
|
|
328
|
-
const ot =
|
|
329
|
-
return
|
|
330
|
-
},
|
|
331
|
-
let
|
|
332
|
-
!a &&
|
|
333
|
-
const
|
|
334
|
-
const R = l * Math.cos(
|
|
335
|
-
return [
|
|
336
|
-
},
|
|
337
|
-
const R = -l * Math.sin(
|
|
338
|
-
return [
|
|
322
|
+
const h = n * Math.PI / 180, d = Math.cos(h), f = Math.sin(h), g = (e - o) / 2, p = (t - c) / 2, m = d * g + f * p, b = -f * g + d * p, k = m * m / (l * l) + b * b / (u * u);
|
|
323
|
+
if (k > 1) {
|
|
324
|
+
const T = Math.sqrt(k);
|
|
325
|
+
l *= T, u *= T;
|
|
326
|
+
}
|
|
327
|
+
const x = r === a ? -1 : 1, w = l * l * u * u - l * l * b * b - u * u * m * m, y = l * l * b * b + u * u * m * m, v = x * Math.sqrt(Math.max(0, w / y)), S = v * l * b / u, E = -v * u * m / l, X = d * S - f * E + (e + o) / 2, _ = f * S + d * E + (t + c) / 2, A = (T, R, D, V) => {
|
|
328
|
+
const ot = T * D + R * V, tt = Math.sqrt((T * T + R * R) * (D * D + V * V)), j = Math.acos(Math.max(-1, Math.min(1, ot / tt)));
|
|
329
|
+
return T * V - R * D < 0 ? -j : j;
|
|
330
|
+
}, C = A(1, 0, (m - S) / l, (b - E) / u);
|
|
331
|
+
let P = A((m - S) / l, (b - E) / u, (-m - S) / l, (-b - E) / u);
|
|
332
|
+
!a && P > 0 && (P -= 2 * Math.PI), a && P < 0 && (P += 2 * Math.PI);
|
|
333
|
+
const M = Math.max(1, Math.ceil(Math.abs(P) / (Math.PI / 2))), I = P / M, L = 4 / 3 * Math.tan(I / 4), O = (T) => {
|
|
334
|
+
const R = l * Math.cos(T), D = u * Math.sin(T);
|
|
335
|
+
return [d * R - f * D + X, f * R + d * D + _];
|
|
336
|
+
}, $ = (T) => {
|
|
337
|
+
const R = -l * Math.sin(T), D = u * Math.cos(T);
|
|
338
|
+
return [d * R - f * D, f * R + d * D];
|
|
339
339
|
}, U = [];
|
|
340
|
-
for (let
|
|
341
|
-
const R =
|
|
342
|
-
U.push([
|
|
340
|
+
for (let T = 0; T < M; T++) {
|
|
341
|
+
const R = C + T * I, D = R + I, [V, ot] = O(R), [tt, j] = T === M - 1 ? [o, c] : O(D), [ae, oe] = $(R), [ce, le] = $(D);
|
|
342
|
+
U.push([V + L * ae, ot + L * oe, tt - L * ce, j - L * le, tt, j]);
|
|
343
343
|
}
|
|
344
344
|
return U;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
const r = 1 -
|
|
348
|
-
return r * r * r * e + 3 * r * r *
|
|
346
|
+
function F(e, t, s, i, n) {
|
|
347
|
+
const r = 1 - n;
|
|
348
|
+
return r * r * r * e + 3 * r * r * n * t + 3 * r * n * n * s + n * n * n * i;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
351
|
-
const r = 1 -
|
|
352
|
-
return 3 * r * r * (t - e) + 6 * r *
|
|
350
|
+
function At(e, t, s, i, n) {
|
|
351
|
+
const r = 1 - n;
|
|
352
|
+
return 3 * r * r * (t - e) + 6 * r * n * (s - t) + 3 * n * n * (i - s);
|
|
353
353
|
}
|
|
354
|
-
function
|
|
354
|
+
function G(e, t, s, i) {
|
|
355
355
|
return {
|
|
356
356
|
subpath: 0,
|
|
357
357
|
type: "L",
|
|
358
|
-
points: [s,
|
|
358
|
+
points: [s, i],
|
|
359
359
|
startX: e,
|
|
360
360
|
startY: t,
|
|
361
361
|
endX: s,
|
|
362
|
-
endY:
|
|
363
|
-
length: Math.hypot(s - e,
|
|
362
|
+
endY: i,
|
|
363
|
+
length: Math.hypot(s - e, i - t)
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
const [
|
|
368
|
-
let u = e, h = t,
|
|
369
|
-
for (let
|
|
370
|
-
const
|
|
371
|
-
|
|
366
|
+
function st(e, t, s) {
|
|
367
|
+
const [i, n, r, a, o, c] = s, l = [0];
|
|
368
|
+
let u = e, h = t, d = 0;
|
|
369
|
+
for (let f = 1; f <= _t; f++) {
|
|
370
|
+
const g = f / _t, p = F(e, i, r, o, g), m = F(t, n, a, c, g);
|
|
371
|
+
d += Math.hypot(p - u, m - h), l.push(d), u = p, h = m;
|
|
372
372
|
}
|
|
373
373
|
return {
|
|
374
374
|
subpath: 0,
|
|
375
375
|
type: "C",
|
|
376
|
-
points: [
|
|
376
|
+
points: [i, n, r, a, o, c],
|
|
377
377
|
startX: e,
|
|
378
378
|
startY: t,
|
|
379
379
|
endX: o,
|
|
380
380
|
endY: c,
|
|
381
|
-
length:
|
|
381
|
+
length: d,
|
|
382
382
|
lengths: l
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function nt(e) {
|
|
386
386
|
const t = H.get(e);
|
|
387
387
|
if (t) return t;
|
|
388
388
|
const s = [];
|
|
389
|
-
let
|
|
389
|
+
let i = 0, n = 0, r = 0, a = 0, o = null, c = null, l = -1;
|
|
390
390
|
const u = /* @__PURE__ */ new Set(), h = (p) => {
|
|
391
391
|
l < 0 && (l = 0), p.subpath = l, s.push(p);
|
|
392
392
|
};
|
|
393
|
-
for (const { type: p, args: m } of
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
396
|
-
(
|
|
393
|
+
for (const { type: p, args: m } of Xe(e)) {
|
|
394
|
+
const b = p.toUpperCase(), k = p !== b, x = Fe[b];
|
|
395
|
+
if (b === "Z") {
|
|
396
|
+
(i !== r || n !== a) && h(G(i, n, r, a)), l >= 0 && u.add(l), i = r, n = a, o = c = null;
|
|
397
397
|
continue;
|
|
398
398
|
}
|
|
399
|
-
for (let w = 0; w +
|
|
400
|
-
const
|
|
401
|
-
let
|
|
402
|
-
switch (
|
|
399
|
+
for (let w = 0; w + x <= m.length; w += x) {
|
|
400
|
+
const y = m.slice(w, w + x), v = k ? i : 0, S = k ? n : 0;
|
|
401
|
+
let E = null, X = null;
|
|
402
|
+
switch (b) {
|
|
403
403
|
case "M":
|
|
404
|
-
w === 0 ? (
|
|
404
|
+
w === 0 ? (i = y[0] + v, n = y[1] + S, r = i, a = n, (l < 0 || s[s.length - 1]?.subpath === l) && l++) : (h(G(i, n, y[0] + v, y[1] + S)), i = y[0] + v, n = y[1] + S);
|
|
405
405
|
break;
|
|
406
406
|
case "L":
|
|
407
|
-
h(
|
|
407
|
+
h(G(i, n, y[0] + v, y[1] + S)), i = y[0] + v, n = y[1] + S;
|
|
408
408
|
break;
|
|
409
409
|
case "H":
|
|
410
|
-
h(
|
|
410
|
+
h(G(i, n, y[0] + v, n)), i = y[0] + v;
|
|
411
411
|
break;
|
|
412
412
|
case "V":
|
|
413
|
-
h(
|
|
413
|
+
h(G(i, n, i, y[0] + S)), n = y[0] + S;
|
|
414
414
|
break;
|
|
415
415
|
case "C": {
|
|
416
|
-
const _ = [
|
|
417
|
-
h(
|
|
416
|
+
const _ = [y[0] + v, y[1] + S, y[2] + v, y[3] + S, y[4] + v, y[5] + S];
|
|
417
|
+
h(st(i, n, _)), E = [_[2], _[3]], i = _[4], n = _[5];
|
|
418
418
|
break;
|
|
419
419
|
}
|
|
420
420
|
case "S": {
|
|
421
|
-
const [_,
|
|
422
|
-
h(
|
|
421
|
+
const [_, A] = o ? [2 * i - o[0], 2 * n - o[1]] : [i, n], C = [_, A, y[0] + v, y[1] + S, y[2] + v, y[3] + S];
|
|
422
|
+
h(st(i, n, C)), E = [C[2], C[3]], i = C[4], n = C[5];
|
|
423
423
|
break;
|
|
424
424
|
}
|
|
425
425
|
case "Q":
|
|
426
426
|
case "T": {
|
|
427
|
-
let _ =
|
|
428
|
-
|
|
429
|
-
const
|
|
427
|
+
let _ = i, A = n;
|
|
428
|
+
b === "Q" ? (_ = y[0] + v, A = y[1] + S) : c && (_ = 2 * i - c[0], A = 2 * n - c[1]);
|
|
429
|
+
const C = b === "Q" ? y[2] + v : y[0] + v, P = b === "Q" ? y[3] + S : y[1] + S;
|
|
430
430
|
h(
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
431
|
+
st(i, n, [
|
|
432
|
+
i + 2 / 3 * (_ - i),
|
|
433
|
+
n + 2 / 3 * (A - n),
|
|
434
|
+
C + 2 / 3 * (_ - C),
|
|
435
|
+
P + 2 / 3 * (A - P),
|
|
436
|
+
C,
|
|
437
|
+
P
|
|
438
438
|
])
|
|
439
|
-
),
|
|
439
|
+
), X = [_, A], i = C, n = P;
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
case "A": {
|
|
443
|
-
const _ =
|
|
444
|
-
let
|
|
445
|
-
for (const
|
|
446
|
-
h(
|
|
447
|
-
|
|
443
|
+
const _ = y[5] + v, A = y[6] + S;
|
|
444
|
+
let C = i, P = n;
|
|
445
|
+
for (const M of Ye(i, n, y[0], y[1], y[2], y[3], y[4], _, A))
|
|
446
|
+
h(st(C, P, M)), C = M[4], P = M[5];
|
|
447
|
+
i = _, n = A;
|
|
448
448
|
break;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
o =
|
|
451
|
+
o = E, c = X;
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
-
const
|
|
454
|
+
const d = s.reduce((p, m) => p + m.length, 0), f = [];
|
|
455
455
|
for (let p = 0; p < s.length; ) {
|
|
456
456
|
const m = s[p].subpath;
|
|
457
|
-
let
|
|
458
|
-
for (;
|
|
459
|
-
const
|
|
460
|
-
|
|
457
|
+
let b = p, k = 0;
|
|
458
|
+
for (; b < s.length && s[b].subpath === m; ) k += s[b++].length;
|
|
459
|
+
const x = s[p], w = s[b - 1], y = u.has(m) || Math.abs(w.endX - x.startX) < 1e-9 && Math.abs(w.endY - x.startY) < 1e-9;
|
|
460
|
+
f.push({ start: p, end: b, length: k, closed: y }), p = b;
|
|
461
461
|
}
|
|
462
|
-
const
|
|
463
|
-
return H.size >=
|
|
462
|
+
const g = { segments: s, totalLength: d, subpaths: f };
|
|
463
|
+
return H.size >= Le && H.delete(H.keys().next().value), H.set(e, g), g;
|
|
464
464
|
}
|
|
465
|
-
function
|
|
465
|
+
function qe(e, t) {
|
|
466
466
|
const s = e.lengths;
|
|
467
467
|
if (t <= 0) return 0;
|
|
468
468
|
if (t >= e.length) return 1;
|
|
469
|
-
let
|
|
470
|
-
for (;
|
|
471
|
-
const o =
|
|
472
|
-
s[o] < t ?
|
|
469
|
+
let i = 0, n = s.length - 1;
|
|
470
|
+
for (; i < n - 1; ) {
|
|
471
|
+
const o = i + n >> 1;
|
|
472
|
+
s[o] < t ? i = o : n = o;
|
|
473
473
|
}
|
|
474
|
-
const r = s[
|
|
475
|
-
return (
|
|
474
|
+
const r = s[n] - s[i], a = r > 0 ? (t - s[i]) / r : 0;
|
|
475
|
+
return (i + a) / (s.length - 1);
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function Ve(e, t) {
|
|
478
478
|
if (e.type === "L") {
|
|
479
479
|
const h = e.length > 0 ? Math.max(0, Math.min(1, t / e.length)) : 0;
|
|
480
480
|
return {
|
|
@@ -483,234 +483,234 @@ function Fe(e, t) {
|
|
|
483
483
|
angle: Math.atan2(e.endY - e.startY, e.endX - e.startX) * 180 / Math.PI
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
|
-
const [s,
|
|
487
|
-
let l =
|
|
486
|
+
const [s, i, n, r, a, o] = e.points, c = qe(e, t);
|
|
487
|
+
let l = At(e.startX, s, n, a, c), u = At(e.startY, i, r, o, c);
|
|
488
488
|
if (Math.hypot(l, u) < 1e-9) {
|
|
489
|
-
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3),
|
|
490
|
-
l = c < 0.5 ?
|
|
489
|
+
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), d = F(e.startX, s, n, a, h), f = F(e.startY, i, r, o, h), g = F(e.startX, s, n, a, c), p = F(e.startY, i, r, o, c);
|
|
490
|
+
l = c < 0.5 ? d - g : g - d, u = c < 0.5 ? f - p : p - f;
|
|
491
491
|
}
|
|
492
492
|
return {
|
|
493
|
-
x:
|
|
494
|
-
y:
|
|
493
|
+
x: F(e.startX, s, n, a, c),
|
|
494
|
+
y: F(e.startY, i, r, o, c),
|
|
495
495
|
angle: Math.atan2(u, l) * 180 / Math.PI
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
if (
|
|
500
|
-
let
|
|
501
|
-
for (let r = s; r <
|
|
498
|
+
function se(e, t, s = 0, i = e.length) {
|
|
499
|
+
if (i <= s) return { x: 0, y: 0, angle: 0 };
|
|
500
|
+
let n = 0;
|
|
501
|
+
for (let r = s; r < i; r++) {
|
|
502
502
|
const a = e[r];
|
|
503
|
-
if (
|
|
504
|
-
return
|
|
505
|
-
|
|
503
|
+
if (n + a.length >= t || r === i - 1)
|
|
504
|
+
return Ve(a, t - n);
|
|
505
|
+
n += a.length;
|
|
506
506
|
}
|
|
507
507
|
return { x: 0, y: 0, angle: 0 };
|
|
508
508
|
}
|
|
509
|
-
function
|
|
510
|
-
const { segments: s, totalLength:
|
|
511
|
-
return
|
|
509
|
+
function We(e, t) {
|
|
510
|
+
const { segments: s, totalLength: i } = nt(e);
|
|
511
|
+
return se(s, Math.max(0, Math.min(1, t)) * i);
|
|
512
512
|
}
|
|
513
|
-
const
|
|
514
|
-
let lt = 0,
|
|
515
|
-
const
|
|
516
|
-
function
|
|
517
|
-
const { segments: s, subpaths:
|
|
513
|
+
const Be = 24, Ue = 320, je = 2.5, z = 72, He = 0.2, Ge = 128, it = /* @__PURE__ */ new Map();
|
|
514
|
+
let lt = 0, Y;
|
|
515
|
+
const Pt = (e) => Math.round(e * 100) / 100;
|
|
516
|
+
function Ct(e, t) {
|
|
517
|
+
const { segments: s, subpaths: i, totalLength: n } = nt(e);
|
|
518
518
|
if (s.length === 0) return [];
|
|
519
519
|
if (t) {
|
|
520
|
-
const r =
|
|
521
|
-
return [{ segments: s, start: 0, end: s.length, length:
|
|
520
|
+
const r = i.every((a) => a.closed);
|
|
521
|
+
return [{ segments: s, start: 0, end: s.length, length: n, closed: r }];
|
|
522
522
|
}
|
|
523
|
-
return
|
|
523
|
+
return i.filter((r) => r.length > 0).map((r) => ({ segments: s, start: r.start, end: r.end, length: r.length, closed: r.closed }));
|
|
524
524
|
}
|
|
525
525
|
function bt(e, t) {
|
|
526
|
-
const s = e.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)),
|
|
527
|
-
return [
|
|
526
|
+
const s = e.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)), i = se(e.segments, s * e.length, e.start, e.end);
|
|
527
|
+
return [i.x, i.y];
|
|
528
528
|
}
|
|
529
529
|
function It(e) {
|
|
530
530
|
const t = [];
|
|
531
531
|
let s = 0;
|
|
532
|
-
for (let
|
|
533
|
-
s += e.segments[
|
|
532
|
+
for (let i = e.start; i < e.end; i++)
|
|
533
|
+
s += e.segments[i].length, e.length > 0 && t.push(s / e.length);
|
|
534
534
|
return t;
|
|
535
535
|
}
|
|
536
|
-
function
|
|
536
|
+
function Et(e, t) {
|
|
537
537
|
const s = [];
|
|
538
|
-
for (let
|
|
539
|
-
s.push(bt(e, e.closed ?
|
|
538
|
+
for (let i = 0; i < t; i++)
|
|
539
|
+
s.push(bt(e, e.closed ? i / t : i / (t - 1)));
|
|
540
540
|
return s;
|
|
541
541
|
}
|
|
542
542
|
function Rt(e) {
|
|
543
543
|
let t = 0, s = 0;
|
|
544
|
-
for (const [
|
|
545
|
-
t +=
|
|
546
|
-
return t /= e.length, s /= e.length, e.map(([
|
|
544
|
+
for (const [i, n] of e)
|
|
545
|
+
t += i, s += n;
|
|
546
|
+
return t /= e.length, s /= e.length, e.map(([i, n]) => [i - t, n - s]);
|
|
547
547
|
}
|
|
548
|
-
function
|
|
549
|
-
const
|
|
548
|
+
function ze(e, t, s) {
|
|
549
|
+
const i = e.closed && t.closed;
|
|
550
550
|
if (s !== void 0)
|
|
551
|
-
return { offset:
|
|
552
|
-
const
|
|
551
|
+
return { offset: i ? Math.abs(s) % z / z : 0, reversed: s < 0 };
|
|
552
|
+
const n = Rt(Et(e, z)), r = Rt(Et(t, z)), a = z;
|
|
553
553
|
let o = { offset: 0, reversed: !1 }, c = 1 / 0;
|
|
554
554
|
for (const l of [!1, !0]) {
|
|
555
|
-
const u =
|
|
555
|
+
const u = i ? a : 1;
|
|
556
556
|
for (let h = 0; h < u; h++) {
|
|
557
|
-
let
|
|
558
|
-
for (let
|
|
559
|
-
const
|
|
560
|
-
|
|
557
|
+
let d = 0;
|
|
558
|
+
for (let f = 0; f < a && d < c; f++) {
|
|
559
|
+
const g = i ? l ? (h - f + a) % a : (f + h) % a : l ? a - 1 - f : f, p = n[f][0] - r[g][0], m = n[f][1] - r[g][1];
|
|
560
|
+
d += p * p + m * m;
|
|
561
561
|
}
|
|
562
|
-
|
|
562
|
+
d < c && (c = d, o = { offset: i ? h / a : 0, reversed: l });
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
return o;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function Qe(e, t, s) {
|
|
568
568
|
return s ? ((t.reversed ? t.offset - e : e + t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function Ze(e, t, s) {
|
|
571
571
|
return s ? ((t.reversed ? t.offset - e : e - t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
Math.min(
|
|
573
|
+
function Ke(e, t, s) {
|
|
574
|
+
const i = e.closed && t.closed, n = ze(e, t, s.shapeIndex), r = Math.max(
|
|
575
|
+
Be,
|
|
576
|
+
Math.min(Ue, Math.ceil(Math.max(e.length, t.length) / je))
|
|
577
577
|
), a = /* @__PURE__ */ new Set(), o = (h) => a.add(Math.round(h * 1e7) / 1e7);
|
|
578
578
|
for (let h = 0; h <= r; h++) o(h / r);
|
|
579
579
|
for (const h of It(e)) o(h);
|
|
580
|
-
for (const h of It(t)) o(
|
|
581
|
-
let c = [...a].sort((h,
|
|
582
|
-
|
|
580
|
+
for (const h of It(t)) o(Ze(h, n, i));
|
|
581
|
+
let c = [...a].sort((h, d) => h - d);
|
|
582
|
+
i && (c = c.filter((h) => h < 1));
|
|
583
583
|
const l = [], u = [];
|
|
584
584
|
for (const h of c)
|
|
585
|
-
l.push(...bt(e, h)), u.push(...bt(t,
|
|
586
|
-
return
|
|
585
|
+
l.push(...bt(e, h)), u.push(...bt(t, Qe(h, n, i)));
|
|
586
|
+
return Je({ from: l, to: u, closed: i });
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function Je(e) {
|
|
589
589
|
const t = e.from.length / 2;
|
|
590
590
|
if (t <= 3) return e;
|
|
591
591
|
const s = new Uint8Array(t);
|
|
592
592
|
s[0] = 1, s[t - 1] = 1;
|
|
593
|
-
const
|
|
594
|
-
for (;
|
|
595
|
-
const [a, o] =
|
|
596
|
-
let c = -1, l =
|
|
593
|
+
const i = [[0, t - 1]];
|
|
594
|
+
for (; i.length > 0; ) {
|
|
595
|
+
const [a, o] = i.pop();
|
|
596
|
+
let c = -1, l = He;
|
|
597
597
|
for (let u = a + 1; u < o; u++) {
|
|
598
|
-
const h = Math.max(
|
|
598
|
+
const h = Math.max($t(e.from, a, o, u), $t(e.to, a, o, u));
|
|
599
599
|
h > l && (l = h, c = u);
|
|
600
600
|
}
|
|
601
|
-
c !== -1 && (s[c] = 1,
|
|
601
|
+
c !== -1 && (s[c] = 1, i.push([a, c], [c, o]));
|
|
602
602
|
}
|
|
603
|
-
const
|
|
603
|
+
const n = [], r = [];
|
|
604
604
|
for (let a = 0; a < t; a++)
|
|
605
|
-
s[a] && (
|
|
606
|
-
return { from:
|
|
605
|
+
s[a] && (n.push(e.from[a * 2], e.from[a * 2 + 1]), r.push(e.to[a * 2], e.to[a * 2 + 1]));
|
|
606
|
+
return { from: n, to: r, closed: e.closed };
|
|
607
607
|
}
|
|
608
|
-
function
|
|
609
|
-
const
|
|
608
|
+
function $t(e, t, s, i) {
|
|
609
|
+
const n = e[t * 2], r = e[t * 2 + 1], a = e[s * 2] - n, o = e[s * 2 + 1] - r, c = e[i * 2] - n, l = e[i * 2 + 1] - r, u = a * a + o * o, h = u === 0 ? 0 : Math.max(0, Math.min(1, (c * a + l * o) / u));
|
|
610
610
|
return Math.hypot(c - h * a, l - h * o);
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
const
|
|
614
|
-
if (
|
|
615
|
-
const r =
|
|
612
|
+
function ts(e, t, s) {
|
|
613
|
+
const i = s.shapeIndex;
|
|
614
|
+
if (Y && Y.from === e && Y.to === t && Y.shapeIndex === i) return Y.plan;
|
|
615
|
+
const r = it.get(String(i ?? "auto"))?.get(e)?.get(t);
|
|
616
616
|
if (r)
|
|
617
|
-
return
|
|
618
|
-
const a =
|
|
619
|
-
pairs: o.map((
|
|
617
|
+
return Y = { from: e, to: t, shapeIndex: i, plan: r }, r;
|
|
618
|
+
const a = nt(e).subpaths.filter((f) => f.length > 0).length === nt(t).subpaths.filter((f) => f.length > 0).length, o = Ct(e, !a), c = Ct(t, !a), l = {
|
|
619
|
+
pairs: o.map((f, g) => Ke(f, c[g], s))
|
|
620
620
|
};
|
|
621
|
-
lt >=
|
|
622
|
-
const u = String(
|
|
623
|
-
|
|
624
|
-
const
|
|
625
|
-
return h.set(e,
|
|
621
|
+
lt >= Ge && (it.clear(), lt = 0);
|
|
622
|
+
const u = String(i ?? "auto"), h = it.get(u) ?? /* @__PURE__ */ new Map();
|
|
623
|
+
it.set(u, h);
|
|
624
|
+
const d = h.get(e) ?? /* @__PURE__ */ new Map();
|
|
625
|
+
return h.set(e, d), d.set(t, l), lt++, Y = { from: e, to: t, shapeIndex: i, plan: l }, l;
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function es(e, t, s, i = {}) {
|
|
628
628
|
if (!e) return t;
|
|
629
629
|
if (!t) return e;
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
if (
|
|
633
|
-
const r =
|
|
634
|
-
if (r.pairs.length === 0) return
|
|
630
|
+
const n = Math.max(0, Math.min(1, s));
|
|
631
|
+
if (n === 0) return e;
|
|
632
|
+
if (n === 1) return t;
|
|
633
|
+
const r = ts(e, t, i);
|
|
634
|
+
if (r.pairs.length === 0) return n < 0.5 ? e : t;
|
|
635
635
|
let a = "";
|
|
636
636
|
for (const o of r.pairs) {
|
|
637
637
|
for (let c = 0; c < o.from.length; c += 2) {
|
|
638
|
-
const l =
|
|
638
|
+
const l = Pt(o.from[c] + (o.to[c] - o.from[c]) * n), u = Pt(o.from[c + 1] + (o.to[c + 1] - o.from[c + 1]) * n);
|
|
639
639
|
a += `${c === 0 ? a ? " M" : "M" : " L"}${l} ${u}`;
|
|
640
640
|
}
|
|
641
641
|
o.closed && (a += " Z");
|
|
642
642
|
}
|
|
643
643
|
return a;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function ss(e) {
|
|
646
646
|
return /^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e);
|
|
647
647
|
}
|
|
648
|
-
const
|
|
649
|
-
function
|
|
648
|
+
const N = (e, t, s) => e + (t - e) * s, ie = 512, ht = /* @__PURE__ */ new Map(), ut = /* @__PURE__ */ new Map();
|
|
649
|
+
function Dt(e) {
|
|
650
650
|
const t = ht.get(e);
|
|
651
651
|
if (t) return t;
|
|
652
|
-
const s = e.replace("#", ""),
|
|
652
|
+
const s = e.replace("#", ""), i = [
|
|
653
653
|
parseInt(s.slice(0, 2), 16),
|
|
654
654
|
parseInt(s.slice(2, 4), 16),
|
|
655
655
|
parseInt(s.slice(4, 6), 16)
|
|
656
656
|
];
|
|
657
|
-
return ht.size <
|
|
657
|
+
return ht.size < ie && ht.set(e, i), i;
|
|
658
658
|
}
|
|
659
|
-
const
|
|
660
|
-
function
|
|
661
|
-
return `#${
|
|
659
|
+
const Lt = (e) => e.charCodeAt(0) === 35, Ot = (e) => e.startsWith("rgb"), Nt = (e) => e.startsWith("rgba"), is = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, dt = (e) => Math.round(e).toString(16).padStart(2, "0");
|
|
660
|
+
function ns(e, t, s) {
|
|
661
|
+
return `#${dt(e)}${dt(t)}${dt(s)}`;
|
|
662
662
|
}
|
|
663
|
-
function
|
|
663
|
+
function Ft(e) {
|
|
664
664
|
const t = ut.get(e);
|
|
665
665
|
if (t) return t;
|
|
666
|
-
const s = e.match(
|
|
666
|
+
const s = e.match(is);
|
|
667
667
|
if (!s)
|
|
668
668
|
throw new Error(`Invalid rgb color: ${e}`);
|
|
669
|
-
const
|
|
670
|
-
return ut.size <
|
|
671
|
-
}
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
const [
|
|
675
|
-
return
|
|
676
|
-
}
|
|
677
|
-
if ((Ot(e) ||
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
const c =
|
|
669
|
+
const i = parseInt(s[1], 10), n = parseInt(s[2], 10), r = parseInt(s[3], 10), a = s[4] !== void 0 ? [i, n, r, parseFloat(s[4])] : [i, n, r];
|
|
670
|
+
return ut.size < ie && ut.set(e, a), a;
|
|
671
|
+
}
|
|
672
|
+
const rs = (e, t, s) => {
|
|
673
|
+
if (Lt(e) && Lt(t)) {
|
|
674
|
+
const [i, n, r] = Dt(e), [a, o, c] = Dt(t), l = N(i, a, s), u = N(n, o, s), h = N(r, c, s);
|
|
675
|
+
return ns(l, u, h);
|
|
676
|
+
}
|
|
677
|
+
if ((Ot(e) || Nt(e)) && (Ot(t) || Nt(t))) {
|
|
678
|
+
const i = Ft(e), n = Ft(t), r = Math.round(N(i[0], n[0], s)), a = Math.round(N(i[1], n[1], s)), o = Math.round(N(i[2], n[2], s));
|
|
679
|
+
if (i.length === 4 || n.length === 4) {
|
|
680
|
+
const c = i[3] ?? 1, l = n[3] ?? 1, u = N(c, l, s);
|
|
681
681
|
return `rgba(${r}, ${a}, ${o}, ${u})`;
|
|
682
682
|
}
|
|
683
683
|
return `rgb(${r}, ${a}, ${o})`;
|
|
684
684
|
}
|
|
685
685
|
return s < 1 ? e : t;
|
|
686
|
-
},
|
|
687
|
-
const
|
|
688
|
-
for (let r = 0; r <
|
|
689
|
-
|
|
690
|
-
return
|
|
691
|
-
},
|
|
692
|
-
function
|
|
693
|
-
return typeof e == "number" ?
|
|
694
|
-
}
|
|
695
|
-
function
|
|
696
|
-
const t = [...e.keyframes].sort((s,
|
|
686
|
+
}, as = (e, t, s) => {
|
|
687
|
+
const i = Math.min(e.length, t.length), n = [];
|
|
688
|
+
for (let r = 0; r < i; r++)
|
|
689
|
+
n.push(N(e[r], t[r], s));
|
|
690
|
+
return n;
|
|
691
|
+
}, Xt = (e, t, s) => s < 1 ? e : t, os = (e, t, s) => es(e, t, s);
|
|
692
|
+
function cs(e) {
|
|
693
|
+
return typeof e == "number" ? N : Array.isArray(e) ? as : typeof e == "string" ? e.startsWith("#") || e.startsWith("rgb") ? rs : ss(e) ? os : Xt : Xt;
|
|
694
|
+
}
|
|
695
|
+
function ls(e) {
|
|
696
|
+
const t = [...e.keyframes].sort((s, i) => s.time - i.time);
|
|
697
697
|
return {
|
|
698
698
|
...e,
|
|
699
699
|
keyframes: t
|
|
700
700
|
};
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function q(e) {
|
|
703
703
|
return e.targets && e.targets.length > 0 ? e.targets : [e.target];
|
|
704
704
|
}
|
|
705
|
-
function
|
|
706
|
-
const
|
|
707
|
-
return !
|
|
705
|
+
function B(e, t, s, i) {
|
|
706
|
+
const n = s ?? 0;
|
|
707
|
+
return !i || t <= 1 ? n : n + zt(e, t, i);
|
|
708
708
|
}
|
|
709
|
-
class
|
|
709
|
+
class ft {
|
|
710
710
|
track;
|
|
711
711
|
targets;
|
|
712
712
|
constructor(t) {
|
|
713
|
-
this.track = t, this.targets =
|
|
713
|
+
this.track = t, this.targets = q(t);
|
|
714
714
|
}
|
|
715
715
|
/**
|
|
716
716
|
* Get the interpolated value at a specific time.
|
|
@@ -719,7 +719,7 @@ class dt {
|
|
|
719
719
|
* that need every target should use `getTargetValues`.
|
|
720
720
|
*/
|
|
721
721
|
getValueAtTime(t) {
|
|
722
|
-
return this.valueForOffset(t -
|
|
722
|
+
return this.valueForOffset(t - B(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
723
723
|
}
|
|
724
724
|
/**
|
|
725
725
|
* Every target's value at a specific time, in target order.
|
|
@@ -728,12 +728,12 @@ class dt {
|
|
|
728
728
|
* each sampled at its own offset time.
|
|
729
729
|
*/
|
|
730
730
|
getTargetValues(t) {
|
|
731
|
-
const s = this.targets.length,
|
|
732
|
-
for (let
|
|
733
|
-
const r =
|
|
734
|
-
a !== void 0 &&
|
|
731
|
+
const s = this.targets.length, i = [];
|
|
732
|
+
for (let n = 0; n < s; n++) {
|
|
733
|
+
const r = B(n, s, this.track.delay, this.track.stagger), a = this.valueForOffset(t - r);
|
|
734
|
+
a !== void 0 && i.push({ target: this.targets[n], value: a, start: r + this.track.keyframes[0].time });
|
|
735
735
|
}
|
|
736
|
-
return
|
|
736
|
+
return i;
|
|
737
737
|
}
|
|
738
738
|
/**
|
|
739
739
|
* Get the duration of this track — the last keyframe, plus any delay, the
|
|
@@ -743,8 +743,8 @@ class dt {
|
|
|
743
743
|
const { keyframes: t } = this.track;
|
|
744
744
|
if (t.length === 0)
|
|
745
745
|
return 0;
|
|
746
|
-
const s = t[t.length - 1].time,
|
|
747
|
-
return s + (this.track.delay ?? 0) +
|
|
746
|
+
const s = t[t.length - 1].time, i = this.track.stagger ? Mt(this.targets.length, this.track.stagger) : 0;
|
|
747
|
+
return s + (this.track.delay ?? 0) + i + (this.track.endDelay ?? 0);
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
750
750
|
* Get the track metadata.
|
|
@@ -761,42 +761,42 @@ class dt {
|
|
|
761
761
|
return s[0].value;
|
|
762
762
|
if (t >= s[s.length - 1].time)
|
|
763
763
|
return s[s.length - 1].value;
|
|
764
|
-
const { from:
|
|
765
|
-
if (!
|
|
764
|
+
const { from: i, to: n } = this.findSurroundingKeyframes(t);
|
|
765
|
+
if (!i || !n)
|
|
766
766
|
return;
|
|
767
|
-
if (
|
|
768
|
-
return
|
|
769
|
-
const r =
|
|
770
|
-
return
|
|
767
|
+
if (i.time === t)
|
|
768
|
+
return i.value;
|
|
769
|
+
const r = n.time - i.time, a = (t - i.time) / r, c = De(n.easing)(a);
|
|
770
|
+
return cs(i.value)(i.value, n.value, c);
|
|
771
771
|
}
|
|
772
772
|
/**
|
|
773
773
|
* Find the keyframes surrounding a given time.
|
|
774
774
|
*/
|
|
775
775
|
findSurroundingKeyframes(t) {
|
|
776
776
|
const { keyframes: s } = this.track;
|
|
777
|
-
for (let
|
|
778
|
-
if (t >= s[
|
|
779
|
-
return { from: s[
|
|
777
|
+
for (let i = 0; i < s.length - 1; i++)
|
|
778
|
+
if (t >= s[i].time && t <= s[i + 1].time)
|
|
779
|
+
return { from: s[i], to: s[i + 1] };
|
|
780
780
|
return { from: null, to: null };
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
class
|
|
783
|
+
class hs {
|
|
784
784
|
track;
|
|
785
785
|
targets;
|
|
786
786
|
sampler;
|
|
787
787
|
constructor(t) {
|
|
788
|
-
this.track = t, this.targets =
|
|
788
|
+
this.track = t, this.targets = q(t), this.sampler = new me(t.spring);
|
|
789
789
|
}
|
|
790
790
|
getValueAtTime(t) {
|
|
791
|
-
return this.sampler.valueAt(t -
|
|
791
|
+
return this.sampler.valueAt(t - B(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
792
792
|
}
|
|
793
793
|
getTargetValues(t) {
|
|
794
|
-
const s = this.targets.length,
|
|
795
|
-
for (let
|
|
796
|
-
const r =
|
|
797
|
-
|
|
794
|
+
const s = this.targets.length, i = [];
|
|
795
|
+
for (let n = 0; n < s; n++) {
|
|
796
|
+
const r = B(n, s, this.track.delay, this.track.stagger);
|
|
797
|
+
i.push({ target: this.targets[n], value: this.sampler.valueAt(t - r), start: r });
|
|
798
798
|
}
|
|
799
|
-
return
|
|
799
|
+
return i;
|
|
800
800
|
}
|
|
801
801
|
/** Settle time plus delay and the widest stagger offset. */
|
|
802
802
|
getDuration() {
|
|
@@ -807,23 +807,23 @@ class as {
|
|
|
807
807
|
return this.track;
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
|
-
class
|
|
810
|
+
class us {
|
|
811
811
|
track;
|
|
812
812
|
targets;
|
|
813
813
|
duration;
|
|
814
814
|
constructor(t) {
|
|
815
|
-
this.track = t, this.targets =
|
|
815
|
+
this.track = t, this.targets = q(t), this.duration = Kt(t.inertia);
|
|
816
816
|
}
|
|
817
817
|
getValueAtTime(t) {
|
|
818
|
-
return
|
|
818
|
+
return Tt(this.track.inertia, t - B(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
819
819
|
}
|
|
820
820
|
getTargetValues(t) {
|
|
821
|
-
const s = this.targets.length,
|
|
822
|
-
for (let
|
|
823
|
-
const r =
|
|
824
|
-
|
|
821
|
+
const s = this.targets.length, i = [];
|
|
822
|
+
for (let n = 0; n < s; n++) {
|
|
823
|
+
const r = B(n, s, this.track.delay, this.track.stagger);
|
|
824
|
+
i.push({ target: this.targets[n], value: Tt(this.track.inertia, t - r), start: r });
|
|
825
825
|
}
|
|
826
|
-
return
|
|
826
|
+
return i;
|
|
827
827
|
}
|
|
828
828
|
/** Settle time plus delay and the widest stagger offset. */
|
|
829
829
|
getDuration() {
|
|
@@ -834,13 +834,13 @@ class os {
|
|
|
834
834
|
return this.track;
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
const s = { ...
|
|
837
|
+
function ds(e, t) {
|
|
838
|
+
const s = { ...We(e.pathData, t) };
|
|
839
839
|
if (e.matrix) {
|
|
840
|
-
const [
|
|
841
|
-
s.x =
|
|
842
|
-
const h = s.angle * Math.PI / 180,
|
|
843
|
-
s.angle = Math.atan2(
|
|
840
|
+
const [i, n, r, a, o, c] = e.matrix, { x: l, y: u } = s;
|
|
841
|
+
s.x = i * l + r * u + o, s.y = n * l + a * u + c;
|
|
842
|
+
const h = s.angle * Math.PI / 180, d = Math.cos(h), f = Math.sin(h);
|
|
843
|
+
s.angle = Math.atan2(n * d + a * f, i * d + r * f) * 180 / Math.PI;
|
|
844
844
|
}
|
|
845
845
|
return e.autoRotate && e.rotateOffset && (s.angle += e.rotateOffset), s;
|
|
846
846
|
}
|
|
@@ -849,34 +849,34 @@ const pt = {
|
|
|
849
849
|
lowerCase: "abcdefghijklmnopqrstuvwxyz",
|
|
850
850
|
upperAndLowerCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
851
851
|
numbers: "0123456789"
|
|
852
|
-
},
|
|
853
|
-
function
|
|
852
|
+
}, fs = 20;
|
|
853
|
+
function ps(e) {
|
|
854
854
|
const t = pt[e ?? "upperCase"] ?? e ?? pt.upperCase, s = Array.from(t);
|
|
855
855
|
return s.length > 0 ? s : Array.from(pt.upperCase);
|
|
856
856
|
}
|
|
857
|
-
function
|
|
858
|
-
let
|
|
859
|
-
return
|
|
857
|
+
function ms(e, t, s) {
|
|
858
|
+
let i = (e | 0) ^ Math.imul(t + 1, 2654435761) ^ Math.imul(s + 1, 2246822507);
|
|
859
|
+
return i = Math.imul(i ^ i >>> 16, 2146121005), i = Math.imul(i ^ i >>> 15, 2221713035), (i ^ i >>> 16) >>> 0;
|
|
860
860
|
}
|
|
861
|
-
function
|
|
862
|
-
const
|
|
863
|
-
if (r <= 0) return
|
|
864
|
-
if (r >= 1) return
|
|
865
|
-
const a = Array.from(
|
|
861
|
+
function gs(e, t, s = 0) {
|
|
862
|
+
const i = e.from ?? "", n = e.to, r = Math.max(0, Math.min(1, t));
|
|
863
|
+
if (r <= 0) return i;
|
|
864
|
+
if (r >= 1) return n;
|
|
865
|
+
const a = Array.from(i), o = Array.from(n), c = e.rightToLeft ?? !1;
|
|
866
866
|
if (e.mode === "type") {
|
|
867
|
-
const
|
|
868
|
-
return c ? a.slice(0, Math.max(0, a.length -
|
|
867
|
+
const k = Math.round(r * Math.max(a.length, o.length));
|
|
868
|
+
return c ? a.slice(0, Math.max(0, a.length - k)).join("") + o.slice(Math.max(0, o.length - k)).join("") : o.slice(0, k).join("") + a.slice(k).join("");
|
|
869
869
|
}
|
|
870
|
-
const l = Math.max(0, Math.min(0.999, e.revealDelay ?? 0)), u = Math.max(0, (r - l) / (1 - l)), h = Math.floor(u * o.length),
|
|
871
|
-
let
|
|
872
|
-
for (let
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
` ?
|
|
870
|
+
const l = Math.max(0, Math.min(0.999, e.revealDelay ?? 0)), u = Math.max(0, (r - l) / (1 - l)), h = Math.floor(u * o.length), d = e.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), f = ps(e.chars), g = e.refreshRate ?? fs, p = g > 0 ? Math.floor(s * g / 1e3) : 0, m = e.seed ?? 1;
|
|
871
|
+
let b = "";
|
|
872
|
+
for (let k = 0; k < d; k++) {
|
|
873
|
+
const x = c ? k >= d - h : k < h, w = c ? o[o.length - (d - k)] : o[k];
|
|
874
|
+
x && w !== void 0 || w === " " || w === `
|
|
875
|
+
` ? b += w : b += f[ms(m, k, p) % f.length];
|
|
876
876
|
}
|
|
877
|
-
return
|
|
877
|
+
return b;
|
|
878
878
|
}
|
|
879
|
-
class
|
|
879
|
+
class ys {
|
|
880
880
|
id;
|
|
881
881
|
name;
|
|
882
882
|
_captions;
|
|
@@ -989,31 +989,31 @@ class ds {
|
|
|
989
989
|
const s = this.duration;
|
|
990
990
|
if (s <= 0)
|
|
991
991
|
return;
|
|
992
|
-
let
|
|
992
|
+
let n = t * this.speed;
|
|
993
993
|
if (this._repeatDelayRemaining > 0) {
|
|
994
|
-
const o = Math.min(this._repeatDelayRemaining,
|
|
995
|
-
if (this._repeatDelayRemaining -= o,
|
|
994
|
+
const o = Math.min(this._repeatDelayRemaining, n);
|
|
995
|
+
if (this._repeatDelayRemaining -= o, n -= o, this._repeatDelayRemaining > 0) {
|
|
996
996
|
this.onUpdate?.(this.getStateAtTime(this._currentTime));
|
|
997
997
|
return;
|
|
998
998
|
}
|
|
999
999
|
this._wrapAfterDelay && (this._wrapAfterDelay = !1, this._currentTime = 0);
|
|
1000
1000
|
}
|
|
1001
1001
|
const r = 1e3;
|
|
1002
|
-
for (let o = 0; o < r &&
|
|
1002
|
+
for (let o = 0; o < r && n > 0 && this._playbackState === "playing"; o++)
|
|
1003
1003
|
if (this._direction === "forward") {
|
|
1004
1004
|
const c = s - this._currentTime;
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1005
|
+
if (n >= c) {
|
|
1006
|
+
if (n -= c, this._currentTime = s, !this._handleEndReached())
|
|
1007
1007
|
break;
|
|
1008
1008
|
} else
|
|
1009
|
-
this._currentTime +=
|
|
1009
|
+
this._currentTime += n, n = 0;
|
|
1010
1010
|
} else {
|
|
1011
1011
|
const c = this._currentTime;
|
|
1012
|
-
if (
|
|
1013
|
-
if (
|
|
1012
|
+
if (n >= c) {
|
|
1013
|
+
if (n -= c, this._currentTime = 0, !this._handleStartReached())
|
|
1014
1014
|
break;
|
|
1015
1015
|
} else
|
|
1016
|
-
this._currentTime -=
|
|
1016
|
+
this._currentTime -= n, n = 0;
|
|
1017
1017
|
}
|
|
1018
1018
|
const a = this.getStateAtTime(this._currentTime);
|
|
1019
1019
|
this.onUpdate?.(a);
|
|
@@ -1026,10 +1026,10 @@ class ds {
|
|
|
1026
1026
|
if (this._hasSharedWrites())
|
|
1027
1027
|
this._resolveShared(t, s);
|
|
1028
1028
|
else
|
|
1029
|
-
for (const [
|
|
1030
|
-
const r =
|
|
1031
|
-
for (const { target: a, value: o, start: c } of
|
|
1032
|
-
this._write(s,
|
|
1029
|
+
for (const [i, n] of this._trackPlayers) {
|
|
1030
|
+
const r = n.getTrack().property;
|
|
1031
|
+
for (const { target: a, value: o, start: c } of n.getTargetValues(t))
|
|
1032
|
+
this._write(s, i, a, r, o, t - c);
|
|
1033
1033
|
}
|
|
1034
1034
|
return {
|
|
1035
1035
|
values: s,
|
|
@@ -1053,37 +1053,37 @@ class ds {
|
|
|
1053
1053
|
* turn. `findConflicts()` reports overlaps by the same rule.
|
|
1054
1054
|
*/
|
|
1055
1055
|
_resolveShared(t, s) {
|
|
1056
|
-
const
|
|
1057
|
-
for (const [
|
|
1056
|
+
const i = /* @__PURE__ */ new Map();
|
|
1057
|
+
for (const [n, r] of this._trackPlayers) {
|
|
1058
1058
|
const a = r.getTrack().property;
|
|
1059
1059
|
for (const { target: o, value: c, start: l } of r.getTargetValues(t)) {
|
|
1060
|
-
const u = `${o}\0${a}`, h = l <= t,
|
|
1061
|
-
(!
|
|
1060
|
+
const u = `${o}\0${a}`, h = l <= t, d = i.get(u);
|
|
1061
|
+
(!d || (h !== d.started ? h : h ? l >= d.start : l <= d.start)) && i.set(u, { trackId: n, target: o, property: a, value: c, start: l, started: h });
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
for (const { trackId:
|
|
1065
|
-
this._write(s,
|
|
1064
|
+
for (const { trackId: n, target: r, property: a, value: o, start: c } of i.values())
|
|
1065
|
+
this._write(s, n, r, a, o, t - c);
|
|
1066
1066
|
}
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Write one track's value for a target, expanding the progress of motion paths
|
|
1069
1069
|
* (into x/y/rotation) and text tracks (into the string). `elapsed` is the time
|
|
1070
1070
|
* since this target's animation on the track started.
|
|
1071
1071
|
*/
|
|
1072
|
-
_write(t, s,
|
|
1072
|
+
_write(t, s, i, n, r, a) {
|
|
1073
1073
|
if (r === void 0) return;
|
|
1074
|
-
let o = t.get(
|
|
1075
|
-
o || (o = /* @__PURE__ */ new Map(), t.set(
|
|
1074
|
+
let o = t.get(i);
|
|
1075
|
+
o || (o = /* @__PURE__ */ new Map(), t.set(i, o));
|
|
1076
1076
|
const c = this._textTracks.get(s);
|
|
1077
1077
|
if (c && typeof r == "number") {
|
|
1078
|
-
o.set("text",
|
|
1078
|
+
o.set("text", gs(c.textConfig, r, Math.max(0, a)));
|
|
1079
1079
|
return;
|
|
1080
1080
|
}
|
|
1081
1081
|
const l = this._motionPathTracks.get(s);
|
|
1082
1082
|
if (l && typeof r == "number") {
|
|
1083
|
-
const u =
|
|
1083
|
+
const u = ds(l.motionPathConfig, r);
|
|
1084
1084
|
o.set("motionPathX", u.x), o.set("motionPathY", u.y), l.motionPathConfig.autoRotate && o.set("motionPathRotate", u.angle);
|
|
1085
1085
|
} else
|
|
1086
|
-
o.set(
|
|
1086
|
+
o.set(n, r);
|
|
1087
1087
|
}
|
|
1088
1088
|
/** Cached: does any target+property have more than one track? */
|
|
1089
1089
|
_sharedWrites = null;
|
|
@@ -1092,13 +1092,13 @@ class ds {
|
|
|
1092
1092
|
const t = /* @__PURE__ */ new Set();
|
|
1093
1093
|
this._sharedWrites = !1;
|
|
1094
1094
|
t: for (const s of this._tracks)
|
|
1095
|
-
for (const
|
|
1096
|
-
const
|
|
1097
|
-
if (t.has(
|
|
1095
|
+
for (const i of q(s)) {
|
|
1096
|
+
const n = `${i}\0${s.property}`;
|
|
1097
|
+
if (t.has(n)) {
|
|
1098
1098
|
this._sharedWrites = !0;
|
|
1099
1099
|
break t;
|
|
1100
1100
|
}
|
|
1101
|
-
t.add(
|
|
1101
|
+
t.add(n);
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
1104
|
return this._sharedWrites;
|
|
@@ -1108,16 +1108,16 @@ class ds {
|
|
|
1108
1108
|
*/
|
|
1109
1109
|
addTrack(t) {
|
|
1110
1110
|
if (this._tracks.push(t), this._sharedWrites = null, mt(t)) {
|
|
1111
|
-
this._trackPlayers.set(t.id, new
|
|
1111
|
+
this._trackPlayers.set(t.id, new us(t));
|
|
1112
1112
|
return;
|
|
1113
1113
|
}
|
|
1114
1114
|
if (gt(t)) {
|
|
1115
|
-
this._trackPlayers.set(t.id, new
|
|
1115
|
+
this._trackPlayers.set(t.id, new hs(t)), this._springTracks.set(t.id, t);
|
|
1116
1116
|
return;
|
|
1117
1117
|
}
|
|
1118
|
-
if (
|
|
1119
|
-
this._trackPlayers.set(t.id, new
|
|
1120
|
-
else if (
|
|
1118
|
+
if (Ht(t))
|
|
1119
|
+
this._trackPlayers.set(t.id, new ft(t)), this._textTracks.set(t.id, t);
|
|
1120
|
+
else if (de(t)) {
|
|
1121
1121
|
const s = {
|
|
1122
1122
|
id: t.id,
|
|
1123
1123
|
target: t.target,
|
|
@@ -1128,9 +1128,9 @@ class ds {
|
|
|
1128
1128
|
targets: t.targets,
|
|
1129
1129
|
stagger: t.stagger
|
|
1130
1130
|
};
|
|
1131
|
-
this._trackPlayers.set(t.id, new
|
|
1131
|
+
this._trackPlayers.set(t.id, new ft(s)), this._motionPathTracks.set(t.id, t);
|
|
1132
1132
|
} else
|
|
1133
|
-
this._trackPlayers.set(t.id, new
|
|
1133
|
+
this._trackPlayers.set(t.id, new ft(t));
|
|
1134
1134
|
}
|
|
1135
1135
|
/**
|
|
1136
1136
|
* Replace a track with a new version, keeping its place in the track order
|
|
@@ -1138,13 +1138,13 @@ class ds {
|
|
|
1138
1138
|
* different id. Does nothing if no track has `trackId`.
|
|
1139
1139
|
*/
|
|
1140
1140
|
replaceTrack(t, s) {
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
const
|
|
1141
|
+
const i = this._tracks.findIndex((r) => r.id === t);
|
|
1142
|
+
if (i < 0) return;
|
|
1143
|
+
const n = this._tracks.slice(i + 1);
|
|
1144
1144
|
this.removeTrack(t);
|
|
1145
|
-
for (const r of
|
|
1145
|
+
for (const r of n) this.removeTrack(r.id);
|
|
1146
1146
|
this.addTrack(s);
|
|
1147
|
-
for (const r of
|
|
1147
|
+
for (const r of n) this.addTrack(r);
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
1150
1150
|
* Remove a track by its ID.
|
|
@@ -1169,9 +1169,9 @@ class ds {
|
|
|
1169
1169
|
* tweens on an element.
|
|
1170
1170
|
*/
|
|
1171
1171
|
removeTracks(t = {}) {
|
|
1172
|
-
const s = this.getTracks(t).map((
|
|
1173
|
-
for (const
|
|
1174
|
-
this.removeTrack(
|
|
1172
|
+
const s = this.getTracks(t).map((i) => i.id);
|
|
1173
|
+
for (const i of s)
|
|
1174
|
+
this.removeTrack(i);
|
|
1175
1175
|
return s;
|
|
1176
1176
|
}
|
|
1177
1177
|
/**
|
|
@@ -1180,12 +1180,12 @@ class ds {
|
|
|
1180
1180
|
getTrackSpan(t) {
|
|
1181
1181
|
const s = this._trackPlayers.get(t);
|
|
1182
1182
|
if (!s) return;
|
|
1183
|
-
const
|
|
1184
|
-
if (gt(
|
|
1185
|
-
return { from:
|
|
1186
|
-
const r =
|
|
1183
|
+
const i = s.getTrack(), n = i.delay ?? 0;
|
|
1184
|
+
if (gt(i) || mt(i))
|
|
1185
|
+
return { from: n, to: s.getDuration() };
|
|
1186
|
+
const r = i.keyframes;
|
|
1187
1187
|
if (!(!r || r.length === 0))
|
|
1188
|
-
return { from: r[0].time +
|
|
1188
|
+
return { from: r[0].time + n, to: s.getDuration() };
|
|
1189
1189
|
}
|
|
1190
1190
|
/**
|
|
1191
1191
|
* Overlapping writes to the same target+property.
|
|
@@ -1198,32 +1198,32 @@ class ds {
|
|
|
1198
1198
|
findConflicts() {
|
|
1199
1199
|
const t = [];
|
|
1200
1200
|
for (let s = 0; s < this._tracks.length; s++) {
|
|
1201
|
-
const
|
|
1202
|
-
if (
|
|
1201
|
+
const i = this._tracks[s], n = this.getTrackSpan(i.id);
|
|
1202
|
+
if (n)
|
|
1203
1203
|
for (let r = 0; r < s; r++) {
|
|
1204
1204
|
const a = this._tracks[r];
|
|
1205
|
-
if (a.property !==
|
|
1206
|
-
const o =
|
|
1205
|
+
if (a.property !== i.property) continue;
|
|
1206
|
+
const o = q(a).filter((h) => q(i).includes(h));
|
|
1207
1207
|
if (o.length === 0) continue;
|
|
1208
1208
|
const c = this.getTrackSpan(a.id);
|
|
1209
|
-
if (!c || !(c.from <=
|
|
1210
|
-
const u =
|
|
1209
|
+
if (!c || !(c.from <= n.to && n.from <= c.to)) continue;
|
|
1210
|
+
const u = n.from >= c.from;
|
|
1211
1211
|
for (const h of o)
|
|
1212
1212
|
t.push({
|
|
1213
1213
|
target: h,
|
|
1214
|
-
property:
|
|
1215
|
-
losingTrackId: u ? a.id :
|
|
1216
|
-
winningTrackId: u ?
|
|
1214
|
+
property: i.property,
|
|
1215
|
+
losingTrackId: u ? a.id : i.id,
|
|
1216
|
+
winningTrackId: u ? i.id : a.id
|
|
1217
1217
|
});
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
1220
|
return t;
|
|
1221
1221
|
}
|
|
1222
1222
|
_matches(t, s) {
|
|
1223
|
-
if (s.id !== void 0 && t.id !== s.id || s.property !== void 0 && t.property !== s.property || s.target !== void 0 && !
|
|
1223
|
+
if (s.id !== void 0 && t.id !== s.id || s.property !== void 0 && t.property !== s.property || s.target !== void 0 && !q(t).includes(s.target)) return !1;
|
|
1224
1224
|
if (s.timeRange) {
|
|
1225
|
-
const
|
|
1226
|
-
if (!
|
|
1225
|
+
const i = this.getTrackSpan(t.id);
|
|
1226
|
+
if (!i || i.to < s.timeRange.from || i.from > s.timeRange.to) return !1;
|
|
1227
1227
|
}
|
|
1228
1228
|
return !0;
|
|
1229
1229
|
}
|
|
@@ -1232,7 +1232,7 @@ class ds {
|
|
|
1232
1232
|
*/
|
|
1233
1233
|
toDefinition() {
|
|
1234
1234
|
return {
|
|
1235
|
-
formatVersion:
|
|
1235
|
+
formatVersion: J,
|
|
1236
1236
|
id: this.id,
|
|
1237
1237
|
name: this.name,
|
|
1238
1238
|
config: { ...this._config },
|
|
@@ -1250,8 +1250,8 @@ class ds {
|
|
|
1250
1250
|
}
|
|
1251
1251
|
/** Replace the markers (kept in time order); an empty list removes them. */
|
|
1252
1252
|
setMarkers(t) {
|
|
1253
|
-
const s = t && t.length > 0 ? [...t].sort((
|
|
1254
|
-
s ?
|
|
1253
|
+
const s = t && t.length > 0 ? [...t].sort((n, r) => n.time - r.time).map((n) => ({ ...n })) : void 0, i = { ...this._config };
|
|
1254
|
+
s ? i.markers = s : delete i.markers, this._config = i;
|
|
1255
1255
|
}
|
|
1256
1256
|
/** Caption text per language, per marker id */
|
|
1257
1257
|
get captions() {
|
|
@@ -1260,7 +1260,7 @@ class ds {
|
|
|
1260
1260
|
/** Replace the captions; languages with no captions are dropped. */
|
|
1261
1261
|
setCaptions(t) {
|
|
1262
1262
|
const s = {};
|
|
1263
|
-
for (const [
|
|
1263
|
+
for (const [i, n] of Object.entries(t ?? {})) s[i] = { ...n };
|
|
1264
1264
|
this._captions = Object.keys(s).length > 0 ? s : void 0;
|
|
1265
1265
|
}
|
|
1266
1266
|
/** Start the between-iterations pause, if the timeline configures one. */
|
|
@@ -1290,25 +1290,25 @@ class ds {
|
|
|
1290
1290
|
return this._config.alternate && (t === -1 || this._loopIteration < t) ? (this._loopIteration++, this._armRepeatDelay(), this._direction = "forward", this._repeatDelayRemaining === 0) : (this._playbackState = "idle", this.onComplete?.(), !1);
|
|
1291
1291
|
}
|
|
1292
1292
|
}
|
|
1293
|
-
const
|
|
1294
|
-
function
|
|
1295
|
-
const
|
|
1296
|
-
r.push([
|
|
1297
|
-
const
|
|
1298
|
-
e.forEach((
|
|
1299
|
-
(p === "forward" ? (m ?
|
|
1300
|
-
}),
|
|
1301
|
-
for (const
|
|
1293
|
+
const bs = 100;
|
|
1294
|
+
function ks(e, t, s, i) {
|
|
1295
|
+
const n = [], r = [], { duration: a, alternate: o } = i, c = (f, g, p, m) => {
|
|
1296
|
+
r.push([f, g]);
|
|
1297
|
+
const b = [];
|
|
1298
|
+
e.forEach((k, x) => {
|
|
1299
|
+
(p === "forward" ? (m ? k >= f : k > f) && k <= g : (m ? k <= f : k < f) && k >= g) && b.push(x);
|
|
1300
|
+
}), b.sort((k, x) => (p === "forward" ? e[k] - e[x] : e[x] - e[k]) || k - x);
|
|
1301
|
+
for (const k of b) n.push({ kind: "event", index: k, direction: p });
|
|
1302
1302
|
};
|
|
1303
1303
|
let l = t.time, u = t.direction, h = t.fresh === !0;
|
|
1304
|
-
const
|
|
1305
|
-
for (let
|
|
1306
|
-
const
|
|
1307
|
-
c(l,
|
|
1304
|
+
const d = Math.min(bs, Math.max(0, s.iteration - t.iteration));
|
|
1305
|
+
for (let f = 0; f < d; f++) {
|
|
1306
|
+
const g = u === "forward" ? a : 0;
|
|
1307
|
+
c(l, g, u, h), n.push({ kind: "repeat" }), o ? (u = u === "forward" ? "reverse" : "forward", l = g, h = !1) : (l = u === "forward" ? 0 : a, h = !0);
|
|
1308
1308
|
}
|
|
1309
|
-
return
|
|
1309
|
+
return d > 0 && i.holding && !o ? { crossings: n, passes: r } : (c(l, s.time, u, h), { crossings: n, passes: r });
|
|
1310
1310
|
}
|
|
1311
|
-
function
|
|
1311
|
+
function xs(e) {
|
|
1312
1312
|
return { ...e, ...Array.isArray(e.end) && { end: [...e.end] } };
|
|
1313
1313
|
}
|
|
1314
1314
|
function Q(e) {
|
|
@@ -1320,7 +1320,7 @@ function Q(e) {
|
|
|
1320
1320
|
...e.stagger !== void 0 && { stagger: { ...e.stagger } }
|
|
1321
1321
|
};
|
|
1322
1322
|
}
|
|
1323
|
-
function
|
|
1323
|
+
function Ms(e) {
|
|
1324
1324
|
if (mt(e)) {
|
|
1325
1325
|
const t = e;
|
|
1326
1326
|
return {
|
|
@@ -1328,7 +1328,7 @@ function ys(e) {
|
|
|
1328
1328
|
target: t.target,
|
|
1329
1329
|
property: t.property,
|
|
1330
1330
|
kind: "inertia",
|
|
1331
|
-
inertia:
|
|
1331
|
+
inertia: xs(t.inertia),
|
|
1332
1332
|
...Q(t)
|
|
1333
1333
|
};
|
|
1334
1334
|
}
|
|
@@ -1343,19 +1343,19 @@ function ys(e) {
|
|
|
1343
1343
|
...Q(t)
|
|
1344
1344
|
};
|
|
1345
1345
|
}
|
|
1346
|
-
if (
|
|
1346
|
+
if (Ht(e)) {
|
|
1347
1347
|
const t = e;
|
|
1348
1348
|
return {
|
|
1349
1349
|
id: t.id,
|
|
1350
1350
|
target: t.target,
|
|
1351
1351
|
property: "text",
|
|
1352
1352
|
textConfig: { ...t.textConfig },
|
|
1353
|
-
keyframes: [...t.keyframes].sort((s,
|
|
1353
|
+
keyframes: [...t.keyframes].sort((s, i) => s.time - i.time),
|
|
1354
1354
|
...Q(t)
|
|
1355
1355
|
};
|
|
1356
1356
|
}
|
|
1357
1357
|
if (e.property === "motionPath" && "motionPathConfig" in e) {
|
|
1358
|
-
const t = e, s = [...t.keyframes].sort((
|
|
1358
|
+
const t = e, s = [...t.keyframes].sort((i, n) => i.time - n.time);
|
|
1359
1359
|
return {
|
|
1360
1360
|
id: t.id,
|
|
1361
1361
|
target: t.target,
|
|
@@ -1365,7 +1365,7 @@ function ys(e) {
|
|
|
1365
1365
|
...Q(t)
|
|
1366
1366
|
};
|
|
1367
1367
|
}
|
|
1368
|
-
return
|
|
1368
|
+
return ls({
|
|
1369
1369
|
id: e.id,
|
|
1370
1370
|
target: e.target,
|
|
1371
1371
|
property: e.property,
|
|
@@ -1375,19 +1375,19 @@ function ys(e) {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
function rt(e) {
|
|
1377
1377
|
const t = e.formatVersion ?? 1;
|
|
1378
|
-
if (t >
|
|
1378
|
+
if (t > J)
|
|
1379
1379
|
throw new Error(
|
|
1380
|
-
`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${
|
|
1380
|
+
`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${J}. Update tinyfly to play it.`
|
|
1381
1381
|
);
|
|
1382
|
-
return new
|
|
1382
|
+
return new ys({
|
|
1383
1383
|
id: e.id,
|
|
1384
1384
|
name: e.name,
|
|
1385
1385
|
config: e.config,
|
|
1386
|
-
tracks: e.tracks.map(
|
|
1386
|
+
tracks: e.tracks.map(Ms),
|
|
1387
1387
|
captions: e.captions
|
|
1388
1388
|
});
|
|
1389
1389
|
}
|
|
1390
|
-
const
|
|
1390
|
+
const Ss = /* @__PURE__ */ new Set([
|
|
1391
1391
|
"blur",
|
|
1392
1392
|
"brightness",
|
|
1393
1393
|
"glow",
|
|
@@ -1396,30 +1396,30 @@ const bs = /* @__PURE__ */ new Set([
|
|
|
1396
1396
|
"shadowY",
|
|
1397
1397
|
"shadowBlur",
|
|
1398
1398
|
"shadowColor"
|
|
1399
|
-
]),
|
|
1399
|
+
]), ws = "#ffffff", vs = "rgba(0, 0, 0, 0.5)";
|
|
1400
1400
|
function Ts(e) {
|
|
1401
1401
|
const t = [];
|
|
1402
|
-
if (e.blur !== void 0 && t.push(`blur(${Math.max(0, e.blur)}px)`), e.brightness !== void 0 && t.push(`brightness(${Math.max(0, e.brightness)})`), e.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, e.glow)}px ${e.glowColor ??
|
|
1403
|
-
const s = e.shadowX ?? 0,
|
|
1404
|
-
t.push(`drop-shadow(${s}px ${
|
|
1402
|
+
if (e.blur !== void 0 && t.push(`blur(${Math.max(0, e.blur)}px)`), e.brightness !== void 0 && t.push(`brightness(${Math.max(0, e.brightness)})`), e.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, e.glow)}px ${e.glowColor ?? ws})`), e.shadowX !== void 0 || e.shadowY !== void 0 || e.shadowBlur !== void 0) {
|
|
1403
|
+
const s = e.shadowX ?? 0, i = e.shadowY ?? 0, n = Math.max(0, e.shadowBlur ?? 0);
|
|
1404
|
+
t.push(`drop-shadow(${s}px ${i}px ${n}px ${e.shadowColor ?? vs})`);
|
|
1405
1405
|
}
|
|
1406
1406
|
return t.length > 0 ? t.join(" ") : null;
|
|
1407
1407
|
}
|
|
1408
|
-
function
|
|
1408
|
+
function _s(e, t) {
|
|
1409
1409
|
const s = e.childNodes.length === 1 ? e.firstChild : null;
|
|
1410
1410
|
if (s && s.nodeType === 3) {
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1411
|
+
const i = s;
|
|
1412
|
+
i.data !== t && (i.data = t);
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
1415
|
e.textContent !== t && (e.textContent = t);
|
|
1416
1416
|
}
|
|
1417
|
-
function
|
|
1417
|
+
function As(e) {
|
|
1418
1418
|
if (!("ownerSVGElement" in e)) return;
|
|
1419
1419
|
const t = e.style;
|
|
1420
1420
|
!t || t.transformBox || (t.transformBox = "fill-box", t.transformOrigin || (t.transformOrigin = "50% 50%"));
|
|
1421
1421
|
}
|
|
1422
|
-
const
|
|
1422
|
+
const Yt = /* @__PURE__ */ new Set([
|
|
1423
1423
|
"width",
|
|
1424
1424
|
"height",
|
|
1425
1425
|
"top",
|
|
@@ -1445,7 +1445,7 @@ const Xt = /* @__PURE__ */ new Set([
|
|
|
1445
1445
|
"gap",
|
|
1446
1446
|
"rowGap",
|
|
1447
1447
|
"columnGap"
|
|
1448
|
-
]),
|
|
1448
|
+
]), Ps = /* @__PURE__ */ new Set([
|
|
1449
1449
|
"x",
|
|
1450
1450
|
"y",
|
|
1451
1451
|
"z",
|
|
@@ -1463,14 +1463,14 @@ const Xt = /* @__PURE__ */ new Set([
|
|
|
1463
1463
|
"motionPathX",
|
|
1464
1464
|
"motionPathY",
|
|
1465
1465
|
"motionPathRotate"
|
|
1466
|
-
]),
|
|
1466
|
+
]), Cs = /* @__PURE__ */ new Set(["originX", "originY"]), Is = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]), Es = {
|
|
1467
1467
|
fill: "backgroundColor",
|
|
1468
1468
|
stroke: "borderColor",
|
|
1469
1469
|
strokeWidth: "borderWidth",
|
|
1470
1470
|
color: "color",
|
|
1471
1471
|
backgroundColor: "backgroundColor",
|
|
1472
1472
|
borderColor: "borderColor"
|
|
1473
|
-
},
|
|
1473
|
+
}, qt = {
|
|
1474
1474
|
fill: "fill",
|
|
1475
1475
|
stroke: "stroke",
|
|
1476
1476
|
strokeWidth: "strokeWidth",
|
|
@@ -1478,7 +1478,7 @@ const Xt = /* @__PURE__ */ new Set([
|
|
|
1478
1478
|
strokeDashoffset: "strokeDashoffset",
|
|
1479
1479
|
fillOpacity: "fillOpacity",
|
|
1480
1480
|
strokeOpacity: "strokeOpacity"
|
|
1481
|
-
},
|
|
1481
|
+
}, Rs = "http://www.w3.org/2000/svg";
|
|
1482
1482
|
class kt {
|
|
1483
1483
|
targets = /* @__PURE__ */ new Map();
|
|
1484
1484
|
/**
|
|
@@ -1509,53 +1509,53 @@ class kt {
|
|
|
1509
1509
|
* Apply animation state to all registered targets.
|
|
1510
1510
|
*/
|
|
1511
1511
|
applyState(t) {
|
|
1512
|
-
for (const [s,
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1512
|
+
for (const [s, i] of t.values) {
|
|
1513
|
+
const n = this.targets.get(s);
|
|
1514
|
+
n && this.applyProperties(n, i);
|
|
1515
1515
|
}
|
|
1516
1516
|
}
|
|
1517
1517
|
/**
|
|
1518
1518
|
* Apply properties to a single element.
|
|
1519
1519
|
*/
|
|
1520
1520
|
applyProperties(t, s) {
|
|
1521
|
-
const
|
|
1522
|
-
let
|
|
1521
|
+
const i = [];
|
|
1522
|
+
let n = null, r = null, a = null;
|
|
1523
1523
|
const o = s.has("motionPathX"), c = s.has("motionPathY"), l = s.has("motionPathRotate");
|
|
1524
|
-
for (const [
|
|
1525
|
-
if (!(
|
|
1526
|
-
if (
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
} else if (
|
|
1530
|
-
typeof
|
|
1531
|
-
else if (
|
|
1532
|
-
typeof
|
|
1533
|
-
else if (
|
|
1534
|
-
(a ??= {})[
|
|
1535
|
-
else if (
|
|
1536
|
-
if (
|
|
1537
|
-
|
|
1538
|
-
else if (
|
|
1539
|
-
const
|
|
1540
|
-
(
|
|
1524
|
+
for (const [d, f] of s)
|
|
1525
|
+
if (!(d === "x" && o) && !(d === "y" && c) && !((d === "rotate" || d === "rotateZ") && l)) {
|
|
1526
|
+
if (Ps.has(d)) {
|
|
1527
|
+
const g = this.buildTransformPart(d, f);
|
|
1528
|
+
g && i.push(g);
|
|
1529
|
+
} else if (Cs.has(d))
|
|
1530
|
+
typeof f == "number" && ((n ??= {})[d] = f);
|
|
1531
|
+
else if (Is.has(d))
|
|
1532
|
+
typeof f == "number" && ((r ??= {})[d] = f);
|
|
1533
|
+
else if (Ss.has(d))
|
|
1534
|
+
(a ??= {})[d] = f;
|
|
1535
|
+
else if (d !== "perspective") {
|
|
1536
|
+
if (d !== "shine") if (d === "text" && typeof f == "string")
|
|
1537
|
+
_s(t, f);
|
|
1538
|
+
else if (d === "d" && typeof f == "string") {
|
|
1539
|
+
const g = t;
|
|
1540
|
+
(g.tagName?.toLowerCase() === "path" ? g : g.querySelector?.("path"))?.setAttribute?.("d", f);
|
|
1541
1541
|
} else
|
|
1542
|
-
this.applyStyleProperty(t,
|
|
1542
|
+
this.applyStyleProperty(t, d, f);
|
|
1543
1543
|
}
|
|
1544
1544
|
}
|
|
1545
1545
|
const u = s.get("shine");
|
|
1546
1546
|
typeof u == "number" && this.applyShine(t, u);
|
|
1547
1547
|
const h = s.get("perspective");
|
|
1548
|
-
if (typeof h == "number" &&
|
|
1549
|
-
const
|
|
1550
|
-
t.style.transformOrigin = `${
|
|
1548
|
+
if (typeof h == "number" && i.unshift(`perspective(${h}px)`), i.length > 0 && (t.style.transform = i.join(" "), As(t)), n) {
|
|
1549
|
+
const d = n.originX ?? 50, f = n.originY ?? 50;
|
|
1550
|
+
t.style.transformOrigin = `${d}% ${f}%`;
|
|
1551
1551
|
}
|
|
1552
1552
|
if (r) {
|
|
1553
|
-
const
|
|
1554
|
-
t.style.clipPath = `inset(${
|
|
1553
|
+
const d = r.clipTop ?? 0, f = r.clipRight ?? 0, g = r.clipBottom ?? 0, p = r.clipLeft ?? 0;
|
|
1554
|
+
t.style.clipPath = `inset(${d}% ${f}% ${g}% ${p}%)`;
|
|
1555
1555
|
}
|
|
1556
1556
|
if (a) {
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1557
|
+
const d = Ts(a);
|
|
1558
|
+
d && (t.style.filter = d);
|
|
1559
1559
|
}
|
|
1560
1560
|
}
|
|
1561
1561
|
/**
|
|
@@ -1606,24 +1606,24 @@ class kt {
|
|
|
1606
1606
|
*/
|
|
1607
1607
|
applyShine(t, s) {
|
|
1608
1608
|
t.dataset.shineBase || (t.dataset.shineBase = t.style.color || "currentColor");
|
|
1609
|
-
const
|
|
1610
|
-
r.color = "transparent", r.backgroundImage = `linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${
|
|
1609
|
+
const i = t.dataset.shineBase, n = -20 + s * 140, r = t.style;
|
|
1610
|
+
r.color = "transparent", r.backgroundImage = `linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`, r.backgroundSize = "250% 100%, 100% 100%", r.backgroundPosition = `${n}% 0, 0 0`, r.backgroundRepeat = "no-repeat", r.webkitBackgroundClip = "text", r.backgroundClip = "text";
|
|
1611
1611
|
}
|
|
1612
1612
|
/**
|
|
1613
1613
|
* Apply a single style property to an element.
|
|
1614
1614
|
*/
|
|
1615
|
-
applyStyleProperty(t, s,
|
|
1616
|
-
let
|
|
1617
|
-
if (t.namespaceURI ===
|
|
1618
|
-
const o = Array.isArray(
|
|
1619
|
-
t.style[
|
|
1615
|
+
applyStyleProperty(t, s, i) {
|
|
1616
|
+
let n;
|
|
1617
|
+
if (t.namespaceURI === Rs && s in qt) {
|
|
1618
|
+
const o = Array.isArray(i) ? i.join(", ") : String(i);
|
|
1619
|
+
t.style[qt[s]] = o;
|
|
1620
1620
|
return;
|
|
1621
|
-
} else s === "fill" && t.dataset?.elementType === "text" ?
|
|
1621
|
+
} else s === "fill" && t.dataset?.elementType === "text" ? n = "color" : n = Es[s] ?? s;
|
|
1622
1622
|
let a;
|
|
1623
|
-
typeof
|
|
1623
|
+
typeof i == "number" ? Yt.has(s) || Yt.has(n) ? a = `${i}px` : a = String(i) : Array.isArray(i) ? a = i.join(", ") : a = i, t.style[n] = a;
|
|
1624
1624
|
}
|
|
1625
1625
|
}
|
|
1626
|
-
class
|
|
1626
|
+
class Vt {
|
|
1627
1627
|
media;
|
|
1628
1628
|
offset;
|
|
1629
1629
|
driftTolerance;
|
|
@@ -1641,8 +1641,8 @@ class qt {
|
|
|
1641
1641
|
* @param isPlaying whether the timeline is playing
|
|
1642
1642
|
*/
|
|
1643
1643
|
update(t, s) {
|
|
1644
|
-
const
|
|
1645
|
-
s ? (this.media.paused && this.safePlay(), Math.abs(this.media.currentTime -
|
|
1644
|
+
const i = this.targetTime(t);
|
|
1645
|
+
s ? (this.media.paused && this.safePlay(), Math.abs(this.media.currentTime - i) > this.driftTolerance && (this.media.currentTime = i)) : (this.media.paused || this.media.pause(), this.media.currentTime !== i && (this.media.currentTime = i));
|
|
1646
1646
|
}
|
|
1647
1647
|
/** Hard-align the media to a timeline time (used on explicit seeks). */
|
|
1648
1648
|
seek(t) {
|
|
@@ -1662,15 +1662,15 @@ class qt {
|
|
|
1662
1662
|
});
|
|
1663
1663
|
}
|
|
1664
1664
|
}
|
|
1665
|
-
function
|
|
1666
|
-
const r = s -
|
|
1665
|
+
function $s(e, t, s, i, n) {
|
|
1666
|
+
const r = s - n;
|
|
1667
1667
|
if (r < 0) {
|
|
1668
1668
|
t.paused || t.pause(), t.currentTime = 0;
|
|
1669
1669
|
return;
|
|
1670
1670
|
}
|
|
1671
|
-
e.update(r,
|
|
1671
|
+
e.update(r, i);
|
|
1672
1672
|
}
|
|
1673
|
-
class
|
|
1673
|
+
class wt {
|
|
1674
1674
|
container;
|
|
1675
1675
|
timeline = null;
|
|
1676
1676
|
adapter;
|
|
@@ -1682,6 +1682,9 @@ class St {
|
|
|
1682
1682
|
mediaSync;
|
|
1683
1683
|
mediaTargets = [];
|
|
1684
1684
|
symbolInstances = [];
|
|
1685
|
+
scenarioList = [];
|
|
1686
|
+
scenarioId;
|
|
1687
|
+
authored = /* @__PURE__ */ new Map();
|
|
1685
1688
|
markerList = [];
|
|
1686
1689
|
listeners = /* @__PURE__ */ new Set();
|
|
1687
1690
|
/** Where the playhead was when marker crossings were last worked out */
|
|
@@ -1700,10 +1703,10 @@ class St {
|
|
|
1700
1703
|
onDocumentVisibility = () => this.updateVisibility();
|
|
1701
1704
|
constructor(t, s = {}) {
|
|
1702
1705
|
if (typeof t == "string") {
|
|
1703
|
-
const
|
|
1704
|
-
if (!
|
|
1706
|
+
const i = document.querySelector(t);
|
|
1707
|
+
if (!i)
|
|
1705
1708
|
throw new Error(`Container not found: ${t}`);
|
|
1706
|
-
this.container =
|
|
1709
|
+
this.container = i;
|
|
1707
1710
|
} else
|
|
1708
1711
|
this.container = t;
|
|
1709
1712
|
this.options = s, this.adapter = new kt();
|
|
@@ -1712,15 +1715,84 @@ class St {
|
|
|
1712
1715
|
* Load animation from a URL or JSON object.
|
|
1713
1716
|
*/
|
|
1714
1717
|
async load(t) {
|
|
1718
|
+
this.scenarioList = [], this.scenarioId = void 0, await this.loadSource(t);
|
|
1719
|
+
}
|
|
1720
|
+
async loadSource(t) {
|
|
1715
1721
|
let s;
|
|
1716
1722
|
if (typeof t == "string") {
|
|
1717
|
-
const
|
|
1718
|
-
if (!
|
|
1719
|
-
throw new Error(`Failed to load animation: ${
|
|
1720
|
-
s = await
|
|
1723
|
+
const i = await fetch(t);
|
|
1724
|
+
if (!i.ok)
|
|
1725
|
+
throw new Error(`Failed to load animation: ${i.statusText}`);
|
|
1726
|
+
s = await i.json();
|
|
1721
1727
|
} else
|
|
1722
1728
|
s = t;
|
|
1723
|
-
this.
|
|
1729
|
+
this.useDefinition(s), this.showInitialFrame(), this.watchReducedMotion(), this.watchVisibility(), this.options.autoplay && !this.reducedMotion && (this.options.playWhenVisible && !this.onScreen ? this.autoplayWhenSeen = !0 : this.play());
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Make a definition the current timeline: targets, symbols and media bound, no
|
|
1733
|
+
* frame drawn and nothing played. The definition itself is not modified, so a
|
|
1734
|
+
* scenario's timeline can be used again.
|
|
1735
|
+
*/
|
|
1736
|
+
useDefinition(t) {
|
|
1737
|
+
const s = { ...t.config };
|
|
1738
|
+
this.options.speed !== void 0 && (s.speed = this.options.speed), this.options.loop !== void 0 && (s.loop = this.options.loop), this.options.alternate !== void 0 && (s.alternate = this.options.alternate), this.timeline = rt({ ...t, config: s }), this.markerList = this.timeline.markers, this.lastMarkerId = null, this.options.onComplete && (this.timeline.onComplete = this.options.onComplete), this.options.onUpdate && (this.timeline.onUpdate = this.options.onUpdate), this.autoRegisterTargets(), this.setupSymbolInstances(), this.scanMedia();
|
|
1739
|
+
}
|
|
1740
|
+
// --- scenarios: the reader chooses which timeline plays --------------------
|
|
1741
|
+
/**
|
|
1742
|
+
* Load several timelines for the same markup, and show one. The reader switches
|
|
1743
|
+
* with `setScenario`; the embed's controls and `data-tinyfly-choose` hotspots
|
|
1744
|
+
* call it.
|
|
1745
|
+
*/
|
|
1746
|
+
async loadScenarios(t, s = {}) {
|
|
1747
|
+
if (t.length === 0) throw new Error("tinyfly: loadScenarios needs at least one scenario");
|
|
1748
|
+
const i = /* @__PURE__ */ new Set();
|
|
1749
|
+
for (const r of t) {
|
|
1750
|
+
if (i.has(r.id)) throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);
|
|
1751
|
+
i.add(r.id);
|
|
1752
|
+
}
|
|
1753
|
+
const n = s.initial === void 0 ? t[0] : t.find((r) => r.id === s.initial);
|
|
1754
|
+
if (!n) throw new Error(`tinyfly: there is no scenario "${s.initial}"`);
|
|
1755
|
+
this.scenarioList = [...t], this.scenarioId = n.id, await this.loadSource(n.timeline);
|
|
1756
|
+
}
|
|
1757
|
+
/** The scenarios to choose from (empty for a single timeline). */
|
|
1758
|
+
get scenarios() {
|
|
1759
|
+
return this.scenarioList.map((t) => ({ id: t.id, label: t.label ?? t.id }));
|
|
1760
|
+
}
|
|
1761
|
+
/** The id of the scenario showing, if scenarios were loaded. */
|
|
1762
|
+
get scenario() {
|
|
1763
|
+
return this.scenarioId;
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Switch to another scenario. Whatever the previous one drew is undone first.
|
|
1767
|
+
* The reader stays at the same step when the new scenario has a marker with the
|
|
1768
|
+
* same id, stays at the end if they were at the end, and otherwise starts from
|
|
1769
|
+
* the beginning. Playback continues if it was playing. Under reduced motion the
|
|
1770
|
+
* new scenario's final frame shows. Returns false for an unknown id.
|
|
1771
|
+
*/
|
|
1772
|
+
setScenario(t) {
|
|
1773
|
+
const s = this.scenarioList.find((o) => o.id === t);
|
|
1774
|
+
if (!s || !this.timeline) return !1;
|
|
1775
|
+
if (t === this.scenarioId) return !0;
|
|
1776
|
+
const i = this.isPlaying, n = this.currentTime >= this.duration - 0.5, r = this.currentMarker?.id;
|
|
1777
|
+
this.stopAnimationLoop(), this.stepping = !1, this.pausedByVisibility = !1, this.restoreAuthored(), this.scenarioId = t, this.useDefinition(s.timeline), this.lastMarkerId = null;
|
|
1778
|
+
let a = 0;
|
|
1779
|
+
return this.reducedMotion || n ? a = this.duration : r !== void 0 && (a = this.markers.find((o) => o.id === r)?.time ?? 0), this.seek(a), i && !this.reducedMotion ? (this.stepping = this.options.stepMode === !0, this.startPlaying()) : this.notify(), !0;
|
|
1780
|
+
}
|
|
1781
|
+
/** Remember how an element was authored, the first time it becomes a target. */
|
|
1782
|
+
rememberAuthored(t) {
|
|
1783
|
+
if (this.authored.has(t)) return;
|
|
1784
|
+
const s = { style: t.getAttribute("style") };
|
|
1785
|
+
t.children.length === 0 && (s.text = t.textContent ?? "");
|
|
1786
|
+
const i = t.tagName.toLowerCase() === "path" ? t : t.querySelector("path");
|
|
1787
|
+
i && (s.path = { element: i, d: i.getAttribute("d") }), this.authored.set(t, s);
|
|
1788
|
+
}
|
|
1789
|
+
/** Put every target back the way it was authored. */
|
|
1790
|
+
restoreAuthored() {
|
|
1791
|
+
for (const [t, s] of this.authored) {
|
|
1792
|
+
s.style === null ? t.removeAttribute("style") : t.setAttribute("style", s.style), s.text !== void 0 && t.textContent !== s.text && (t.textContent = s.text), s.path && (s.path.d === null ? s.path.element.removeAttribute("d") : s.path.element.setAttribute("d", s.path.d));
|
|
1793
|
+
const i = t.dataset;
|
|
1794
|
+
i && delete i.shineBase;
|
|
1795
|
+
}
|
|
1724
1796
|
}
|
|
1725
1797
|
// --- teaching: frames, markers, reduced motion, visibility -----------------
|
|
1726
1798
|
/**
|
|
@@ -1745,8 +1817,8 @@ class St {
|
|
|
1745
1817
|
get currentMarker() {
|
|
1746
1818
|
const t = this.currentTime;
|
|
1747
1819
|
let s;
|
|
1748
|
-
for (const
|
|
1749
|
-
if (
|
|
1820
|
+
for (const i of this.markers)
|
|
1821
|
+
if (i.time <= t + 0.5) s = i;
|
|
1750
1822
|
else break;
|
|
1751
1823
|
return s;
|
|
1752
1824
|
}
|
|
@@ -1756,15 +1828,15 @@ class St {
|
|
|
1756
1828
|
* marker's own label.
|
|
1757
1829
|
*/
|
|
1758
1830
|
caption(t, s) {
|
|
1759
|
-
const
|
|
1760
|
-
if (!
|
|
1761
|
-
const
|
|
1762
|
-
return r(this.options.captions) ?? r(this.timeline?.captions) ??
|
|
1831
|
+
const i = t ? this.markers.find((a) => a.id === t) : this.currentMarker;
|
|
1832
|
+
if (!i) return;
|
|
1833
|
+
const n = s ?? this.language(), r = (a) => a?.[n]?.[i.id] ?? a?.[n.split("-")[0]]?.[i.id];
|
|
1834
|
+
return r(this.options.captions) ?? r(this.timeline?.captions) ?? i.label;
|
|
1763
1835
|
}
|
|
1764
1836
|
/** Move to the next marker: animated, or a jump under reduced motion. At the last marker, to the end. */
|
|
1765
1837
|
next() {
|
|
1766
1838
|
if (!this.timeline) return;
|
|
1767
|
-
const t = this.currentTime, s = this.markers.find((
|
|
1839
|
+
const t = this.currentTime, s = this.markers.find((i) => i.time > t + 0.5);
|
|
1768
1840
|
if (this.reducedMotion) {
|
|
1769
1841
|
this.seek(s ? s.time : this.duration);
|
|
1770
1842
|
return;
|
|
@@ -1774,12 +1846,12 @@ class St {
|
|
|
1774
1846
|
/** Jump back to the previous marker (or the start). */
|
|
1775
1847
|
prev() {
|
|
1776
1848
|
if (!this.timeline) return;
|
|
1777
|
-
const t = this.currentTime, s = [...this.markers].reverse().find((
|
|
1849
|
+
const t = this.currentTime, s = [...this.markers].reverse().find((i) => i.time < t - 0.5);
|
|
1778
1850
|
this.pause(), this.seek(s ? s.time : 0);
|
|
1779
1851
|
}
|
|
1780
1852
|
/** Jump to a marker by id, paused there. */
|
|
1781
1853
|
goToMarker(t) {
|
|
1782
|
-
const s = this.markers.find((
|
|
1854
|
+
const s = this.markers.find((i) => i.id === t);
|
|
1783
1855
|
s && (this.pause(), this.seek(s.time));
|
|
1784
1856
|
}
|
|
1785
1857
|
language() {
|
|
@@ -1802,8 +1874,8 @@ class St {
|
|
|
1802
1874
|
watchVisibility() {
|
|
1803
1875
|
if (!(!this.options.playWhenVisible || typeof window > "u")) {
|
|
1804
1876
|
if (typeof IntersectionObserver == "function") {
|
|
1805
|
-
this.visibilityObserver?.disconnect(), this.
|
|
1806
|
-
for (const
|
|
1877
|
+
this.visibilityObserver?.disconnect(), this.visibilityObserver = new IntersectionObserver((s) => {
|
|
1878
|
+
for (const i of s) this.onScreen = i.isIntersecting;
|
|
1807
1879
|
this.updateVisibility();
|
|
1808
1880
|
}), this.visibilityObserver.observe(this.container);
|
|
1809
1881
|
const t = this.container.getBoundingClientRect?.();
|
|
@@ -1829,14 +1901,14 @@ class St {
|
|
|
1829
1901
|
*/
|
|
1830
1902
|
scanMedia() {
|
|
1831
1903
|
this.mediaTargets = [], this.container.querySelectorAll("[data-tinyfly-media]").forEach((s) => {
|
|
1832
|
-
const
|
|
1833
|
-
r !== null && (
|
|
1904
|
+
const i = s, n = Number(i.getAttribute("data-tinyfly-start") ?? "0") || 0, r = i.getAttribute("data-volume");
|
|
1905
|
+
r !== null && (i.volume = Math.max(0, Math.min(1, Number(r) || 0))), this.mediaTargets.push({ el: i, startTime: n, sync: new Vt(i) });
|
|
1834
1906
|
});
|
|
1835
1907
|
}
|
|
1836
1908
|
/** Sync all discovered media targets to a timeline time. */
|
|
1837
1909
|
syncAllMedia(t, s) {
|
|
1838
|
-
for (const
|
|
1839
|
-
|
|
1910
|
+
for (const i of this.mediaTargets)
|
|
1911
|
+
$s(i.sync, i.el, t, s, i.startTime);
|
|
1840
1912
|
}
|
|
1841
1913
|
/**
|
|
1842
1914
|
* Load animation from inline JSON string.
|
|
@@ -1850,24 +1922,24 @@ class St {
|
|
|
1850
1922
|
*/
|
|
1851
1923
|
registerTarget(t, s) {
|
|
1852
1924
|
if (typeof s == "string") {
|
|
1853
|
-
const
|
|
1854
|
-
|
|
1925
|
+
const i = this.container.querySelector(s);
|
|
1926
|
+
i && (this.rememberAuthored(i), this.targets[t] = i, this.adapter.registerTarget(t, i));
|
|
1855
1927
|
} else
|
|
1856
|
-
this.targets[t] = s, this.adapter.registerTarget(t, s);
|
|
1928
|
+
this.rememberAuthored(s), this.targets[t] = s, this.adapter.registerTarget(t, s);
|
|
1857
1929
|
}
|
|
1858
1930
|
/**
|
|
1859
1931
|
* Auto-register targets using data-tinyfly attribute.
|
|
1860
1932
|
*/
|
|
1861
1933
|
autoRegisterTargets() {
|
|
1862
1934
|
this.container.querySelectorAll("[data-tinyfly]").forEach((s) => {
|
|
1863
|
-
const
|
|
1864
|
-
if (
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1867
|
-
}), this.timeline && new Set(this.timeline.tracks.map((
|
|
1868
|
-
if (!this.targets[
|
|
1869
|
-
const
|
|
1870
|
-
|
|
1935
|
+
const i = s.closest("[data-tinyfly-symbol]");
|
|
1936
|
+
if (i && i !== s) return;
|
|
1937
|
+
const n = s.getAttribute("data-tinyfly");
|
|
1938
|
+
n && this.registerTarget(n, s);
|
|
1939
|
+
}), this.timeline && new Set(this.timeline.tracks.map((i) => i.target)).forEach((i) => {
|
|
1940
|
+
if (!this.targets[i]) {
|
|
1941
|
+
const n = this.container.querySelector(`[data-tinyfly="${i}"]`) || this.container.querySelector(`.${i}`) || this.container.querySelector(`#${i}`);
|
|
1942
|
+
n && this.registerTarget(i, n);
|
|
1871
1943
|
}
|
|
1872
1944
|
});
|
|
1873
1945
|
}
|
|
@@ -1880,14 +1952,14 @@ class St {
|
|
|
1880
1952
|
this.symbolInstances = [];
|
|
1881
1953
|
const t = this.options.symbols;
|
|
1882
1954
|
if (!t || t.length === 0) return;
|
|
1883
|
-
const s = new Map(t.map((
|
|
1884
|
-
this.container.querySelectorAll("[data-tinyfly-symbol]").forEach((
|
|
1885
|
-
const
|
|
1886
|
-
if (!
|
|
1887
|
-
const r = s.get(
|
|
1955
|
+
const s = new Map(t.map((i) => [i.id, i]));
|
|
1956
|
+
this.container.querySelectorAll("[data-tinyfly-symbol]").forEach((i) => {
|
|
1957
|
+
const n = i.getAttribute("data-tinyfly-symbol");
|
|
1958
|
+
if (!n) return;
|
|
1959
|
+
const r = s.get(n);
|
|
1888
1960
|
if (!r || !r.timeline.tracks?.length) return;
|
|
1889
1961
|
const a = new kt();
|
|
1890
|
-
|
|
1962
|
+
i.querySelectorAll("[data-tinyfly]").forEach((o) => {
|
|
1891
1963
|
const c = o.getAttribute("data-tinyfly");
|
|
1892
1964
|
c && a.registerTarget(c, o);
|
|
1893
1965
|
}), this.symbolInstances.push({ adapter: a, timeline: rt(r.timeline) });
|
|
@@ -1900,7 +1972,7 @@ class St {
|
|
|
1900
1972
|
* plays. Pass `{ offset }` to start the media at a timeline offset.
|
|
1901
1973
|
*/
|
|
1902
1974
|
attachMedia(t, s) {
|
|
1903
|
-
this.mediaSync = new
|
|
1975
|
+
this.mediaSync = new Vt(t, s), this.timeline && (this.mediaSync.setRate(this.timeline.speed), this.mediaSync.update(this.timeline.currentTime, this.isPlaying));
|
|
1904
1976
|
}
|
|
1905
1977
|
/** Detach and pause the currently synced media, if any. */
|
|
1906
1978
|
detachMedia() {
|
|
@@ -1974,17 +2046,17 @@ class St {
|
|
|
1974
2046
|
t.el.paused || t.el.pause();
|
|
1975
2047
|
this.mediaTargets = [], this.adapter.clearTargets();
|
|
1976
2048
|
for (const t of this.symbolInstances) t.adapter.clearTargets();
|
|
1977
|
-
this.symbolInstances = [], this.timeline = null;
|
|
2049
|
+
this.symbolInstances = [], this.authored.clear(), this.timeline = null;
|
|
1978
2050
|
}
|
|
1979
2051
|
startAnimationLoop() {
|
|
1980
2052
|
if (this.animationFrameId !== void 0) return;
|
|
1981
2053
|
this.lastTime = performance.now();
|
|
1982
2054
|
const t = (s) => {
|
|
1983
2055
|
if (this.isDestroyed || !this.timeline) return;
|
|
1984
|
-
const
|
|
2056
|
+
const i = s - (this.lastTime ?? s);
|
|
1985
2057
|
this.lastTime = s;
|
|
1986
|
-
const
|
|
1987
|
-
this.timeline.tick(
|
|
2058
|
+
const n = this.playhead;
|
|
2059
|
+
this.timeline.tick(i), this.stopAtMarker(n), this.applyState();
|
|
1988
2060
|
const r = this.timeline.playbackState === "playing";
|
|
1989
2061
|
this.mediaSync?.update(this.timeline.currentTime, r), this.syncAllMedia(this.timeline.currentTime, r), this.timeline.playbackState === "playing" ? this.animationFrameId = requestAnimationFrame(t) : (this.animationFrameId = void 0, this.notify());
|
|
1990
2062
|
};
|
|
@@ -1995,19 +2067,19 @@ class St {
|
|
|
1995
2067
|
* stepping, or any marker with `pause` — put the playhead exactly there and pause.
|
|
1996
2068
|
*/
|
|
1997
2069
|
stopAtMarker(t) {
|
|
1998
|
-
const s = this.timeline,
|
|
1999
|
-
this.playhead =
|
|
2000
|
-
const
|
|
2001
|
-
if (
|
|
2002
|
-
const { crossings: r } =
|
|
2003
|
-
|
|
2070
|
+
const s = this.timeline, i = { time: s.currentTime, iteration: s.loopIteration, direction: s.direction };
|
|
2071
|
+
this.playhead = i;
|
|
2072
|
+
const n = this.markers;
|
|
2073
|
+
if (n.length === 0) return;
|
|
2074
|
+
const { crossings: r } = ks(
|
|
2075
|
+
n.map((a) => a.time),
|
|
2004
2076
|
t,
|
|
2005
|
-
|
|
2077
|
+
i,
|
|
2006
2078
|
{ duration: s.duration, alternate: s.config.alternate === !0, holding: s.repeatDelayRemaining > 0 }
|
|
2007
2079
|
);
|
|
2008
2080
|
for (const a of r) {
|
|
2009
2081
|
if (a.kind !== "event") continue;
|
|
2010
|
-
const o =
|
|
2082
|
+
const o = n[a.index];
|
|
2011
2083
|
if (this.stepping || o.pause) {
|
|
2012
2084
|
this.stepping = !1, s.pause(), s.seek(o.time), this.playhead = { time: o.time, iteration: s.loopIteration, direction: s.direction };
|
|
2013
2085
|
return;
|
|
@@ -2022,19 +2094,19 @@ class St {
|
|
|
2022
2094
|
const t = this.timeline.currentTime;
|
|
2023
2095
|
this.adapter.applyState(this.timeline.getStateAtTime(t)), this.announceMarker(), this.notify();
|
|
2024
2096
|
for (const s of this.symbolInstances) {
|
|
2025
|
-
const
|
|
2026
|
-
s.adapter.applyState(s.timeline.getStateAtTime(
|
|
2097
|
+
const i = s.timeline.duration;
|
|
2098
|
+
s.adapter.applyState(s.timeline.getStateAtTime(i > 0 ? t % i : t));
|
|
2027
2099
|
}
|
|
2028
2100
|
}
|
|
2029
2101
|
}
|
|
2030
|
-
async function
|
|
2031
|
-
const
|
|
2032
|
-
return await
|
|
2102
|
+
async function si(e, t, s = {}) {
|
|
2103
|
+
const i = new wt(e, { ...s, autoplay: !0 });
|
|
2104
|
+
return await i.load(t), i;
|
|
2033
2105
|
}
|
|
2034
|
-
function
|
|
2035
|
-
return new
|
|
2106
|
+
function ii(e, t = {}) {
|
|
2107
|
+
return new wt(e, t);
|
|
2036
2108
|
}
|
|
2037
|
-
const
|
|
2109
|
+
const Ds = {
|
|
2038
2110
|
play: "Play",
|
|
2039
2111
|
pause: "Pause",
|
|
2040
2112
|
prev: "Previous step",
|
|
@@ -2045,8 +2117,9 @@ const Cs = {
|
|
|
2045
2117
|
reveal: "Reveal",
|
|
2046
2118
|
step: "Step",
|
|
2047
2119
|
of: "of",
|
|
2048
|
-
stepFormat: "{index} / {total}"
|
|
2049
|
-
|
|
2120
|
+
stepFormat: "{index} / {total}",
|
|
2121
|
+
scenario: "Scenario"
|
|
2122
|
+
}, Wt = "tinyfly-controls-style", Ls = `
|
|
2050
2123
|
.tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
|
|
2051
2124
|
font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
|
|
2052
2125
|
.tf-ctl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); }
|
|
@@ -2065,70 +2138,86 @@ const Cs = {
|
|
|
2065
2138
|
/* The hidden attribute only hides through the browser's default stylesheet; any rule
|
|
2066
2139
|
above that sets display would override it, so enforce it for everything here. */
|
|
2067
2140
|
.tf-ctl [hidden] { display: none !important; }
|
|
2141
|
+
.tf-ctl-choices { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 0; padding: 0; border: 0; }
|
|
2142
|
+
.tf-ctl-choices legend { float: left; margin-right: 4px; padding: 0; font-weight: 600; }
|
|
2143
|
+
.tf-ctl-choice { position: relative; display: inline-flex; }
|
|
2144
|
+
.tf-ctl-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
|
|
2145
|
+
.tf-ctl-choice span { display: inline-block; padding: 6px 12px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); cursor: pointer; }
|
|
2146
|
+
.tf-ctl-choice input:checked + span { background: var(--tf-ctl-accent); color: #fff; }
|
|
2147
|
+
.tf-ctl-choice input:focus-visible + span { outline: 2px solid var(--tf-ctl-accent); outline-offset: 2px; }
|
|
2148
|
+
.tf-ctl-choice-slider { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; }
|
|
2149
|
+
.tf-ctl-choice-slider span { font-weight: 600; }
|
|
2150
|
+
.tf-ctl-choice-slider input { flex: 1 1 140px; accent-color: var(--tf-ctl-accent); }
|
|
2151
|
+
.tf-ctl-choice-slider input:focus-visible { outline: 2px solid var(--tf-ctl-accent); outline-offset: 2px; }
|
|
2152
|
+
.tf-ctl-choice-slider output { font-variant-numeric: tabular-nums; min-width: 4em; }
|
|
2068
2153
|
`;
|
|
2069
|
-
|
|
2070
|
-
|
|
2154
|
+
let Os = 0;
|
|
2155
|
+
function Ns(e) {
|
|
2156
|
+
if (e.getElementById(Wt)) return;
|
|
2071
2157
|
const t = e.createElement("style");
|
|
2072
|
-
t.id =
|
|
2158
|
+
t.id = Wt, t.textContent = Ls, e.head.appendChild(t);
|
|
2073
2159
|
}
|
|
2074
|
-
function
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
const
|
|
2160
|
+
function Fs(e, t, s = {}) {
|
|
2161
|
+
const i = t.ownerDocument;
|
|
2162
|
+
Ns(i);
|
|
2163
|
+
const n = { ...Ds, ...s.labels }, r = s.speeds ?? [0.5, 1, 2], a = () => e.markers.length > 0, o = () => e.markers.some((M) => M.label !== void 0 || e.caption(M.id) !== void 0), c = i.createElement("div");
|
|
2078
2164
|
c.className = "tf-ctl";
|
|
2079
|
-
const l =
|
|
2165
|
+
const l = i.createElement("div");
|
|
2080
2166
|
l.className = "tf-ctl-bar", l.setAttribute("role", "group");
|
|
2081
|
-
const u = (M,
|
|
2082
|
-
const $ =
|
|
2083
|
-
return $.type = "button", $.className = `tf-ctl-btn ${
|
|
2084
|
-
}, h = u(
|
|
2167
|
+
const u = (M, I, L, O = "") => {
|
|
2168
|
+
const $ = i.createElement("button");
|
|
2169
|
+
return $.type = "button", $.className = `tf-ctl-btn ${O}`.trim(), $.setAttribute("aria-label", M), $.title = M, $.textContent = I, $.addEventListener("click", L), $;
|
|
2170
|
+
}, h = u(n.restart, "⟲", () => {
|
|
2085
2171
|
e.pause(), e.seek(0);
|
|
2086
|
-
}),
|
|
2172
|
+
}), d = u(n.prev, "◀", () => e.prev()), f = u(n.play, "▶", () => e.isPlaying ? e.pause() : p(), "tf-ctl-primary"), g = u(n.next, "▶|", () => e.next()), p = () => {
|
|
2087
2173
|
e.currentTime >= e.duration - 0.5 && e.seek(0), e.play();
|
|
2088
|
-
}, m =
|
|
2089
|
-
m.type = "range", m.className = "tf-ctl-scrub", m.min = "0", m.max = "1000", m.step = "1", m.setAttribute("aria-label",
|
|
2174
|
+
}, m = i.createElement("input");
|
|
2175
|
+
m.type = "range", m.className = "tf-ctl-scrub", m.min = "0", m.max = "1000", m.step = "1", m.setAttribute("aria-label", n.scrub), m.addEventListener("input", () => {
|
|
2090
2176
|
e.pause(), e.seek(Number(m.value) / 1e3 * e.duration);
|
|
2091
2177
|
});
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2178
|
+
const b = i.createElement("span");
|
|
2179
|
+
b.className = "tf-ctl-step";
|
|
2180
|
+
const k = i.createElement("select");
|
|
2181
|
+
k.className = "tf-ctl-speed", k.setAttribute("aria-label", n.speed);
|
|
2096
2182
|
for (const M of r) {
|
|
2097
|
-
const
|
|
2098
|
-
|
|
2183
|
+
const I = i.createElement("option");
|
|
2184
|
+
I.value = String(M), I.textContent = `${M}×`, M === 1 && (I.selected = !0), k.appendChild(I);
|
|
2099
2185
|
}
|
|
2100
|
-
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
const w =
|
|
2186
|
+
k.addEventListener("change", () => e.setSpeed(Number(k.value))), l.append(h, d, f, g, m, b), r.length > 0 && l.append(k), c.append(l);
|
|
2187
|
+
const x = i.createElement("p");
|
|
2188
|
+
x.className = "tf-ctl-caption", x.setAttribute("aria-live", "polite"), s.captions !== !1 && c.append(x);
|
|
2189
|
+
const w = i.createElement("div");
|
|
2104
2190
|
w.className = "tf-ctl-question", w.hidden = !0;
|
|
2105
|
-
const
|
|
2106
|
-
w.append(
|
|
2107
|
-
const S = s.
|
|
2108
|
-
S
|
|
2109
|
-
const
|
|
2191
|
+
const y = i.createElement("span"), v = u(n.reveal, n.reveal, () => e.play(), "tf-ctl-primary");
|
|
2192
|
+
w.append(y, v), c.append(w);
|
|
2193
|
+
const S = Xs(e, i, n.scenario, s.scenarioControl ?? "buttons");
|
|
2194
|
+
S && c.append(S.element);
|
|
2195
|
+
const E = s.mount;
|
|
2196
|
+
E ? E.appendChild(c) : t.insertAdjacentElement("afterend", c);
|
|
2197
|
+
const X = () => {
|
|
2110
2198
|
const M = e.isPlaying;
|
|
2111
|
-
|
|
2112
|
-
const
|
|
2113
|
-
|
|
2114
|
-
const
|
|
2115
|
-
if (
|
|
2116
|
-
const
|
|
2117
|
-
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
const
|
|
2121
|
-
w.hidden = !
|
|
2199
|
+
f.textContent = M ? "❚❚" : "▶", f.setAttribute("aria-label", M ? n.pause : n.play), f.title = M ? n.pause : n.play;
|
|
2200
|
+
const I = e.duration;
|
|
2201
|
+
i.activeElement !== m && (m.value = String(I > 0 ? Math.round(e.currentTime / I * 1e3) : 0));
|
|
2202
|
+
const L = e.markers;
|
|
2203
|
+
if (d.hidden = g.hidden = b.hidden = L.length === 0, L.length > 0) {
|
|
2204
|
+
const O = e.currentMarker, $ = O ? L.indexOf(O) + 1 : 0;
|
|
2205
|
+
b.textContent = n.stepFormat.replace("{index}", String($)).replace("{total}", String(L.length)), b.setAttribute("aria-label", `${n.step} ${$} ${n.of} ${L.length}`), d.disabled = e.currentTime <= 0.5, g.disabled = e.currentTime >= I - 0.5;
|
|
2206
|
+
const U = e.caption() ?? "";
|
|
2207
|
+
x.textContent !== U && (x.textContent = U), x.hidden = !o();
|
|
2208
|
+
const T = !M && O?.question !== void 0 && Math.abs(e.currentTime - O.time) < 1;
|
|
2209
|
+
w.hidden = !T, T && y.textContent !== O.question && (y.textContent = O.question);
|
|
2122
2210
|
} else
|
|
2123
|
-
w.hidden = !0,
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2211
|
+
w.hidden = !0, x.hidden = !0;
|
|
2212
|
+
S?.update();
|
|
2213
|
+
}, _ = e.subscribe(X);
|
|
2214
|
+
X();
|
|
2215
|
+
const A = s.keyboardScope ?? t;
|
|
2216
|
+
!A.hasAttribute("tabindex") && A.tabIndex < 0 && (A.tabIndex = 0);
|
|
2217
|
+
const C = /* @__PURE__ */ new WeakSet(), P = (M) => {
|
|
2129
2218
|
if (C.has(M) || (C.add(M), M.defaultPrevented || M.altKey || M.ctrlKey || M.metaKey)) return;
|
|
2130
|
-
const
|
|
2131
|
-
if (!(
|
|
2219
|
+
const I = M.target;
|
|
2220
|
+
if (!(I.tagName === "INPUT" || I.tagName === "SELECT") && !(M.key === " " && I.tagName === "BUTTON"))
|
|
2132
2221
|
switch (M.key) {
|
|
2133
2222
|
case " ":
|
|
2134
2223
|
M.preventDefault(), e.isPlaying ? e.pause() : p();
|
|
@@ -2146,157 +2235,289 @@ function $s(e, t, s = {}) {
|
|
|
2146
2235
|
break;
|
|
2147
2236
|
}
|
|
2148
2237
|
};
|
|
2149
|
-
return
|
|
2238
|
+
return A.addEventListener("keydown", P), c.addEventListener("keydown", P), {
|
|
2150
2239
|
element: c,
|
|
2151
2240
|
destroy() {
|
|
2152
|
-
|
|
2241
|
+
_(), A.removeEventListener("keydown", P), c.removeEventListener("keydown", P), c.remove();
|
|
2153
2242
|
}
|
|
2154
2243
|
};
|
|
2155
2244
|
}
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2245
|
+
function Xs(e, t, s, i) {
|
|
2246
|
+
const n = e.scenarios;
|
|
2247
|
+
if (n.length < 2) return;
|
|
2248
|
+
if (i === "slider") {
|
|
2249
|
+
const u = t.createElement("div");
|
|
2250
|
+
u.className = "tf-ctl-choice-slider";
|
|
2251
|
+
const h = t.createElement("span");
|
|
2252
|
+
h.textContent = s, h.setAttribute("aria-hidden", "true");
|
|
2253
|
+
const d = t.createElement("input");
|
|
2254
|
+
d.type = "range", d.min = "0", d.max = String(n.length - 1), d.step = "1", d.setAttribute("aria-label", s);
|
|
2255
|
+
const f = t.createElement("output");
|
|
2256
|
+
return f.setAttribute("aria-hidden", "true"), d.addEventListener("input", () => {
|
|
2257
|
+
const p = n[Number(d.value)];
|
|
2258
|
+
p && e.setScenario(p.id);
|
|
2259
|
+
}), u.append(h, d, f), { element: u, update: () => {
|
|
2260
|
+
const p = Math.max(0, n.findIndex((b) => b.id === e.scenario));
|
|
2261
|
+
t.activeElement !== d && (d.value = String(p));
|
|
2262
|
+
const m = n[p].label;
|
|
2263
|
+
f.textContent !== m && (f.textContent = m), d.setAttribute("aria-valuetext", m);
|
|
2264
|
+
} };
|
|
2265
|
+
}
|
|
2266
|
+
const r = t.createElement("fieldset");
|
|
2267
|
+
r.className = "tf-ctl-choices";
|
|
2268
|
+
const a = t.createElement("legend");
|
|
2269
|
+
a.textContent = s, r.append(a);
|
|
2270
|
+
const o = `tf-ctl-scenario-${++Os}`, c = n.map((u) => {
|
|
2271
|
+
const h = t.createElement("label");
|
|
2272
|
+
h.className = "tf-ctl-choice";
|
|
2273
|
+
const d = t.createElement("input");
|
|
2274
|
+
d.type = "radio", d.name = o, d.value = u.id, d.addEventListener("change", () => {
|
|
2275
|
+
d.checked && e.setScenario(u.id);
|
|
2276
|
+
});
|
|
2277
|
+
const f = t.createElement("span");
|
|
2278
|
+
return f.textContent = u.label, h.append(d, f), r.append(h), d;
|
|
2279
|
+
});
|
|
2280
|
+
return { element: r, update: () => {
|
|
2281
|
+
for (const u of c) {
|
|
2282
|
+
const h = u.value === e.scenario;
|
|
2283
|
+
u.checked !== h && (u.checked = h);
|
|
2284
|
+
}
|
|
2285
|
+
} };
|
|
2286
|
+
}
|
|
2287
|
+
const Bt = "tinyfly-choices-style", Ys = `
|
|
2288
|
+
[data-tinyfly-choose] { cursor: pointer; }
|
|
2289
|
+
[data-tinyfly-choose]:focus-visible { outline: 2px solid var(--tf-ctl-accent, #c2410c); outline-offset: 2px; }
|
|
2290
|
+
`;
|
|
2291
|
+
function qs(e) {
|
|
2292
|
+
if (e.getElementById(Bt)) return;
|
|
2293
|
+
const t = e.createElement("style");
|
|
2294
|
+
t.id = Bt, t.textContent = Ys, e.head.appendChild(t);
|
|
2295
|
+
}
|
|
2296
|
+
function Vs(e, t) {
|
|
2297
|
+
const s = Array.from(t.querySelectorAll("[data-tinyfly-choose]"));
|
|
2298
|
+
if (s.length === 0) return () => {
|
|
2299
|
+
};
|
|
2300
|
+
qs(t.ownerDocument);
|
|
2301
|
+
const i = [], n = [];
|
|
2302
|
+
for (const o of s) {
|
|
2303
|
+
const c = o.getAttribute("data-tinyfly-choose") ?? "", l = [], u = (g, p) => {
|
|
2304
|
+
o.hasAttribute(g) || (o.setAttribute(g, p), l.push(g));
|
|
2305
|
+
};
|
|
2306
|
+
u("role", "button"), u("tabindex", "0");
|
|
2307
|
+
const h = e.scenarios.find((g) => g.id === c)?.label;
|
|
2308
|
+
h !== void 0 && u("aria-label", h), o.setAttribute("aria-pressed", "false"), l.push("aria-pressed"), i.push({ element: o, attributes: l });
|
|
2309
|
+
const d = () => e.setScenario(c), f = (g) => {
|
|
2310
|
+
const p = g.key;
|
|
2311
|
+
p !== "Enter" && p !== " " || (g.preventDefault(), d());
|
|
2312
|
+
};
|
|
2313
|
+
o.addEventListener("click", d), o.addEventListener("keydown", f), n.push(() => {
|
|
2314
|
+
o.removeEventListener("click", d), o.removeEventListener("keydown", f);
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
const r = () => {
|
|
2318
|
+
for (const { element: o } of i)
|
|
2319
|
+
o.setAttribute("aria-pressed", String(o.getAttribute("data-tinyfly-choose") === e.scenario));
|
|
2320
|
+
}, a = e.subscribe(r);
|
|
2321
|
+
return r(), () => {
|
|
2322
|
+
a();
|
|
2323
|
+
for (const o of n) o();
|
|
2324
|
+
for (const { element: o, attributes: c } of i) for (const l of c) o.removeAttribute(l);
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
const at = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
|
|
2328
|
+
let Ws = 0;
|
|
2329
|
+
function K(e, t, s) {
|
|
2159
2330
|
if (e)
|
|
2160
2331
|
try {
|
|
2161
2332
|
return JSON.parse(e);
|
|
2162
|
-
} catch (
|
|
2163
|
-
console.warn(`tinyfly: invalid ${t} JSON on`, s,
|
|
2333
|
+
} catch (i) {
|
|
2334
|
+
console.warn(`tinyfly: invalid ${t} JSON on`, s, i);
|
|
2164
2335
|
return;
|
|
2165
2336
|
}
|
|
2166
2337
|
}
|
|
2167
|
-
async function
|
|
2338
|
+
async function Bs(e, t = {}) {
|
|
2168
2339
|
const s = at.get(e);
|
|
2169
2340
|
if (s) return s;
|
|
2170
|
-
const
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
if (!
|
|
2174
|
-
const
|
|
2175
|
-
|
|
2176
|
-
}
|
|
2177
|
-
if (
|
|
2341
|
+
const i = Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")), n = i[0], r = e.getAttribute("data-src"), a = js(e.getAttribute("data-markers")), o = i.length > 1 || n?.hasAttribute("data-scenario") ? Us(i, a, e) : void 0;
|
|
2342
|
+
if (o && o.length === 0) return;
|
|
2343
|
+
let c = n && !o ? K(n.textContent, "timeline", e) : void 0;
|
|
2344
|
+
if (!c && r && a) {
|
|
2345
|
+
const f = await fetch(r);
|
|
2346
|
+
f.ok && (c = await f.json());
|
|
2347
|
+
}
|
|
2348
|
+
if (c && a && (c = ne(c, a)), !c && !r && !o) {
|
|
2178
2349
|
console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)', e);
|
|
2179
2350
|
return;
|
|
2180
2351
|
}
|
|
2181
|
-
const
|
|
2352
|
+
const l = K(e.querySelector("script[data-tinyfly-captions]")?.textContent, "captions", e), u = {
|
|
2182
2353
|
playWhenVisible: !0,
|
|
2183
2354
|
...t.player,
|
|
2184
|
-
...
|
|
2185
|
-
...
|
|
2355
|
+
...l && { captions: l },
|
|
2356
|
+
...K(e.getAttribute("data-options"), "data-options", e)
|
|
2186
2357
|
};
|
|
2187
|
-
|
|
2188
|
-
const
|
|
2189
|
-
if (at.set(e,
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2358
|
+
Gs(e);
|
|
2359
|
+
const h = new wt(e, u), d = { element: e, player: h };
|
|
2360
|
+
if (at.set(e, d), e.setAttribute("data-tinyfly-mounted", ""), o) {
|
|
2361
|
+
const f = e.getAttribute("data-scenario") ?? void 0;
|
|
2362
|
+
await h.loadScenarios(o, { initial: o.some((g) => g.id === f) ? f : void 0 }), xt.set(e, Vs(h, e));
|
|
2363
|
+
} else
|
|
2364
|
+
await h.load(c ?? r);
|
|
2365
|
+
if (e.getAttribute("data-controls") !== "false") {
|
|
2366
|
+
const f = K(e.getAttribute("data-labels"), "data-labels", e), g = e.querySelector("figcaption"), p = e.getAttribute("data-scenario-legend"), m = e.getAttribute("data-scenario-control");
|
|
2367
|
+
d.controls = Fs(h, e, {
|
|
2192
2368
|
...t.controls,
|
|
2193
|
-
|
|
2369
|
+
...m === "slider" || m === "buttons" ? { scenarioControl: m } : {},
|
|
2370
|
+
labels: { ...t.controls?.labels, ...f, ...p ? { scenario: p } : {} },
|
|
2194
2371
|
// Inside the figure, before its figcaption, so the caption stays last.
|
|
2195
2372
|
mount: void 0
|
|
2196
|
-
}),
|
|
2197
|
-
}
|
|
2198
|
-
return
|
|
2373
|
+
}), g ? e.insertBefore(d.controls.element, g) : e.appendChild(d.controls.element);
|
|
2374
|
+
}
|
|
2375
|
+
return d;
|
|
2376
|
+
}
|
|
2377
|
+
function Us(e, t, s) {
|
|
2378
|
+
const i = [];
|
|
2379
|
+
return e.forEach((n, r) => {
|
|
2380
|
+
const a = K(n.textContent, "timeline", s);
|
|
2381
|
+
if (!a) return;
|
|
2382
|
+
const o = n.getAttribute("data-scenario") || `scenario-${r + 1}`;
|
|
2383
|
+
if (i.some((l) => l.id === o)) {
|
|
2384
|
+
console.warn(`tinyfly: scenario id "${o}" is used more than once; the later one is skipped`, s);
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
const c = n.getAttribute("data-scenario-label") ?? void 0;
|
|
2388
|
+
i.push({ id: o, label: c, timeline: t ? ne(a, t) : a });
|
|
2389
|
+
}), i;
|
|
2199
2390
|
}
|
|
2200
|
-
function
|
|
2391
|
+
function ne(e, t) {
|
|
2392
|
+
return e.config.markers?.length ? e : { ...e, config: { ...e.config, markers: t.map((s, i) => ({ id: `step-${i + 1}`, time: s })) } };
|
|
2393
|
+
}
|
|
2394
|
+
function js(e) {
|
|
2201
2395
|
if (!e) return;
|
|
2202
|
-
const t = e.split(/[\s,]+/).filter(Boolean).map(Number).filter((s) => Number.isFinite(s) && s >= 0).sort((s,
|
|
2396
|
+
const t = e.split(/[\s,]+/).filter(Boolean).map(Number).filter((s) => Number.isFinite(s) && s >= 0).sort((s, i) => s - i);
|
|
2203
2397
|
return t.length > 0 ? t : void 0;
|
|
2204
2398
|
}
|
|
2205
|
-
async function
|
|
2399
|
+
async function Hs(e = document, t = {}) {
|
|
2206
2400
|
const s = Array.from(e.querySelectorAll("[data-tinyfly-embed]"));
|
|
2207
|
-
return (await Promise.all(s.map((
|
|
2401
|
+
return (await Promise.all(s.map((n) => Bs(n, t)))).filter((n) => n !== void 0);
|
|
2208
2402
|
}
|
|
2209
|
-
function
|
|
2403
|
+
function ni(e) {
|
|
2210
2404
|
const t = at.get(e);
|
|
2211
|
-
t && (t.controls?.destroy(), t.player.destroy(), at.delete(e), e.removeAttribute("data-tinyfly-mounted"));
|
|
2405
|
+
t && (xt.get(e)?.(), xt.delete(e), t.controls?.destroy(), t.player.destroy(), at.delete(e), e.removeAttribute("data-tinyfly-mounted"));
|
|
2212
2406
|
}
|
|
2213
|
-
function
|
|
2407
|
+
function Gs(e) {
|
|
2214
2408
|
const t = e.querySelector("svg");
|
|
2215
2409
|
if (!t || t.hasAttribute("role") || t.hasAttribute("aria-hidden")) return;
|
|
2216
|
-
const s = e.getAttribute("data-alt"),
|
|
2217
|
-
t.setAttribute("role", "img"), s ? t.setAttribute("aria-label", s) :
|
|
2410
|
+
const s = e.getAttribute("data-alt"), i = e.querySelector("figcaption");
|
|
2411
|
+
t.setAttribute("role", "img"), s ? t.setAttribute("aria-label", s) : i && (i.id ||= `tinyfly-caption-${++Ws}`, t.setAttribute("aria-labelledby", i.id));
|
|
2218
2412
|
}
|
|
2219
|
-
function
|
|
2413
|
+
function zs() {
|
|
2220
2414
|
if (!(typeof document < "u" ? document.currentScript : null)?.hasAttribute("data-tinyfly-auto")) return;
|
|
2221
2415
|
const t = () => {
|
|
2222
|
-
|
|
2416
|
+
Hs();
|
|
2223
2417
|
};
|
|
2224
2418
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t, { once: !0 }) : t();
|
|
2225
2419
|
}
|
|
2226
|
-
function
|
|
2420
|
+
function re(e) {
|
|
2227
2421
|
const t = /* @__PURE__ */ new Set();
|
|
2228
2422
|
for (const s of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(s[2] ?? s[3]);
|
|
2229
2423
|
return [...t];
|
|
2230
2424
|
}
|
|
2231
|
-
function
|
|
2232
|
-
const s = [],
|
|
2233
|
-
if ((e.formatVersion ?? 1) >
|
|
2234
|
-
return
|
|
2425
|
+
function Qs(e, t = {}) {
|
|
2426
|
+
const s = [], i = (l) => s.push({ level: "error", message: l }), n = (l) => s.push({ level: "warning", message: l });
|
|
2427
|
+
if ((e.formatVersion ?? 1) > J)
|
|
2428
|
+
return i(`format version ${e.formatVersion} is newer than this tinyfly reads (${J})`), s;
|
|
2235
2429
|
let r = 0;
|
|
2236
2430
|
try {
|
|
2237
2431
|
r = rt(e).duration;
|
|
2238
2432
|
} catch (l) {
|
|
2239
|
-
return
|
|
2433
|
+
return i(`the timeline does not load: ${l instanceof Error ? l.message : String(l)}`), s;
|
|
2240
2434
|
}
|
|
2241
2435
|
const a = e.config?.duration;
|
|
2242
2436
|
if (a !== void 0)
|
|
2243
2437
|
for (const l of e.tracks) {
|
|
2244
2438
|
if (!("keyframes" in l)) continue;
|
|
2245
2439
|
const u = l.keyframes.filter((h) => h.time > a);
|
|
2246
|
-
u.length > 0 &&
|
|
2440
|
+
u.length > 0 && i(`track "${l.id}" has a keyframe at ${u[0].time}ms, after the ${a}ms duration`);
|
|
2247
2441
|
}
|
|
2248
2442
|
const o = e.config?.markers ?? [], c = /* @__PURE__ */ new Set();
|
|
2249
2443
|
o.forEach((l, u) => {
|
|
2250
|
-
c.has(l.id) &&
|
|
2444
|
+
c.has(l.id) && i(`marker id "${l.id}" is used more than once`), c.add(l.id), (l.time < 0 || l.time > r) && i(`marker "${l.id}" at ${l.time}ms is outside the animation (0–${r}ms)`), u > 0 && l.time < o[u - 1].time && i(`marker "${l.id}" comes before "${o[u - 1].id}" in time; list markers in order`);
|
|
2251
2445
|
});
|
|
2252
2446
|
for (const [l, u] of Object.entries(e.captions ?? {})) {
|
|
2253
2447
|
for (const h of Object.keys(u))
|
|
2254
|
-
c.has(h) ||
|
|
2448
|
+
c.has(h) || i(`caption "${h}" (${l}) has no marker with that id`);
|
|
2255
2449
|
for (const h of c)
|
|
2256
|
-
h in u ||
|
|
2450
|
+
h in u || n(`marker "${h}" has no ${l} caption; its label is shown instead`);
|
|
2257
2451
|
}
|
|
2258
2452
|
if (t.markup !== void 0) {
|
|
2259
|
-
const l = new Set(
|
|
2453
|
+
const l = new Set(re(t.markup)), u = /* @__PURE__ */ new Set();
|
|
2260
2454
|
for (const h of e.tracks)
|
|
2261
|
-
for (const
|
|
2262
|
-
u.add(
|
|
2263
|
-
for (const h of l) u.has(h) ||
|
|
2455
|
+
for (const d of [h.target, ...h.targets ?? []])
|
|
2456
|
+
u.add(d), l.has(d) || i(`track "${h.id}" targets "${d}", but no element has data-tinyfly="${d}"`);
|
|
2457
|
+
for (const h of l) u.has(h) || n(`data-tinyfly="${h}" is never animated`);
|
|
2264
2458
|
}
|
|
2265
2459
|
return s;
|
|
2266
2460
|
}
|
|
2267
|
-
function
|
|
2268
|
-
const
|
|
2269
|
-
for (const
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2461
|
+
function Zs(e) {
|
|
2462
|
+
const t = /* @__PURE__ */ new Set();
|
|
2463
|
+
for (const s of e.matchAll(/data-tinyfly-choose\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(s[2] ?? s[3]);
|
|
2464
|
+
return [...t];
|
|
2465
|
+
}
|
|
2466
|
+
function ri(e, t = {}) {
|
|
2467
|
+
const s = [];
|
|
2468
|
+
e.length === 1 && s.push({ level: "warning", message: "only one scenario, so the reader has nothing to choose" });
|
|
2469
|
+
const i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
2470
|
+
for (const r of e) {
|
|
2471
|
+
if (i.has(r.id)) {
|
|
2472
|
+
s.push({ level: "error", message: `scenario id "${r.id}" is used more than once` });
|
|
2473
|
+
continue;
|
|
2474
|
+
}
|
|
2475
|
+
i.add(r.id);
|
|
2476
|
+
for (const a of Qs(r.timeline, t))
|
|
2477
|
+
/is never animated$/.test(a.message) || s.push({ level: a.level, message: `scenario "${r.id}": ${a.message}` });
|
|
2478
|
+
for (const a of r.timeline.tracks) for (const o of [a.target, ...a.targets ?? []]) n.add(o);
|
|
2479
|
+
}
|
|
2480
|
+
if (t.markup !== void 0) {
|
|
2481
|
+
for (const r of Zs(t.markup))
|
|
2482
|
+
i.has(r) || s.push({ level: "error", message: `data-tinyfly-choose="${r}" names no scenario` });
|
|
2483
|
+
for (const r of re(t.markup))
|
|
2484
|
+
n.has(r) || s.push({ level: "warning", message: `data-tinyfly="${r}" is never animated in any scenario` });
|
|
2485
|
+
}
|
|
2486
|
+
return s;
|
|
2487
|
+
}
|
|
2488
|
+
function ai(e, t, s = "end") {
|
|
2489
|
+
const i = rt(t), n = t.config?.markers ?? [], r = s === "start" ? 0 : s === "end" ? i.duration : typeof s == "number" ? s : n.find((d) => d.id === s)?.time ?? i.duration, a = i.getStateAtTime(Math.max(0, Math.min(i.duration, r))), o = new kt(), c = /* @__PURE__ */ new Map(), l = Js(e);
|
|
2490
|
+
for (const d of e.matchAll(Ut)) {
|
|
2491
|
+
const f = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(d[2] ?? "");
|
|
2492
|
+
if (!f) continue;
|
|
2493
|
+
const g = f[2] ?? f[3];
|
|
2494
|
+
if (c.has(g)) continue;
|
|
2495
|
+
const p = Ks(l(d.index ?? 0));
|
|
2496
|
+
c.set(g, p), o.registerTarget(g, p);
|
|
2276
2497
|
}
|
|
2277
2498
|
o.applyState(a);
|
|
2278
2499
|
let u = "", h = 0;
|
|
2279
|
-
for (const
|
|
2280
|
-
const [
|
|
2281
|
-
if (!
|
|
2282
|
-
u += e.slice(h,
|
|
2283
|
-
const w = Object.entries(
|
|
2284
|
-
let
|
|
2500
|
+
for (const d of e.matchAll(Ut)) {
|
|
2501
|
+
const [f, g, p = "", m] = d, b = d.index ?? 0, k = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(p), x = k ? c.get(k[2] ?? k[3]) : void 0;
|
|
2502
|
+
if (!x || Object.keys(x.style).length === 0 && x.text === void 0) continue;
|
|
2503
|
+
u += e.slice(h, b);
|
|
2504
|
+
const w = Object.entries(x.style).map(([S, E]) => `${ti(S)}: ${E}`).join("; "), y = /\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(p);
|
|
2505
|
+
let v = p;
|
|
2285
2506
|
if (w)
|
|
2286
|
-
if (
|
|
2287
|
-
const S = `${(
|
|
2288
|
-
|
|
2507
|
+
if (y) {
|
|
2508
|
+
const S = `${(y[2] ?? y[3]).trim().replace(/;?$/, ";")} ${w}`.trim();
|
|
2509
|
+
v = p.replace(y[0], ` style="${jt(S)}"`);
|
|
2289
2510
|
} else
|
|
2290
|
-
|
|
2291
|
-
if (u += `<${
|
|
2292
|
-
const S = e.indexOf(`</${
|
|
2293
|
-
S !== -1 && !
|
|
2511
|
+
v = `${p} style="${jt(w)}"`;
|
|
2512
|
+
if (u += `<${g}${v}${m ? " /" : ""}>`, h = b + f.length, x.text !== void 0 && !m) {
|
|
2513
|
+
const S = e.indexOf(`</${g}`, h), E = S === -1 ? "" : e.slice(h, S);
|
|
2514
|
+
S !== -1 && !E.includes("<") && (u += ei(x.text), h = S);
|
|
2294
2515
|
}
|
|
2295
2516
|
}
|
|
2296
2517
|
return u + e.slice(h);
|
|
2297
2518
|
}
|
|
2298
|
-
const
|
|
2299
|
-
function
|
|
2519
|
+
const Ut = /<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;
|
|
2520
|
+
function Ks(e) {
|
|
2300
2521
|
const t = {
|
|
2301
2522
|
style: {},
|
|
2302
2523
|
dataset: {},
|
|
@@ -2311,36 +2532,38 @@ function qs(e) {
|
|
|
2311
2532
|
};
|
|
2312
2533
|
return e && (t.ownerSVGElement = null), t;
|
|
2313
2534
|
}
|
|
2314
|
-
function
|
|
2535
|
+
function Js(e) {
|
|
2315
2536
|
const t = [], s = /<svg[\s>]/gi;
|
|
2316
|
-
let
|
|
2317
|
-
for (;
|
|
2318
|
-
const
|
|
2319
|
-
t.push([
|
|
2537
|
+
let i;
|
|
2538
|
+
for (; i = s.exec(e); ) {
|
|
2539
|
+
const n = e.toLowerCase().indexOf("</svg>", i.index);
|
|
2540
|
+
t.push([i.index + 1, n === -1 ? e.length : n]);
|
|
2320
2541
|
}
|
|
2321
|
-
return (
|
|
2542
|
+
return (n) => t.some(([r, a]) => n > r && n < a);
|
|
2322
2543
|
}
|
|
2323
|
-
function
|
|
2544
|
+
function ti(e) {
|
|
2324
2545
|
const t = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
|
|
2325
2546
|
return /^(webkit|moz|ms)-/.test(t) ? `-${t}` : t;
|
|
2326
2547
|
}
|
|
2327
|
-
function
|
|
2548
|
+
function jt(e) {
|
|
2328
2549
|
return e.replace(/&/g, "&").replace(/"/g, """);
|
|
2329
2550
|
}
|
|
2330
|
-
function
|
|
2551
|
+
function ei(e) {
|
|
2331
2552
|
return e.replace(/&/g, "&").replace(/</g, "<");
|
|
2332
2553
|
}
|
|
2333
|
-
|
|
2554
|
+
zs();
|
|
2334
2555
|
export {
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2556
|
+
Ds as DEFAULT_LABELS,
|
|
2557
|
+
wt as TinyflyPlayer,
|
|
2558
|
+
Vs as bindChoiceHotspots,
|
|
2559
|
+
ii as create,
|
|
2560
|
+
Fs as createControls,
|
|
2561
|
+
Bs as mount,
|
|
2562
|
+
Hs as mountAll,
|
|
2563
|
+
si as play,
|
|
2564
|
+
ai as renderFrame,
|
|
2565
|
+
re as targetNamesIn,
|
|
2566
|
+
ni as unmount,
|
|
2567
|
+
Qs as validateEmbed,
|
|
2568
|
+
ri as validateScenarios
|
|
2346
2569
|
};
|