@algorisys/tinyfly 0.78.0 → 0.81.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 +8 -5
- package/lib/addons/characters.js +2479 -1009
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +4768 -3221
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/engine/tinyfly-engine.js +874 -797
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/types/characters/acrobatics.d.ts +398 -0
- package/lib/types/characters/character.d.ts +26 -0
- package/lib/types/characters/dance.d.ts +196 -0
- package/lib/types/characters/hand.d.ts +57 -4
- package/lib/types/characters/hands/draw-cartoon-hand.d.ts +39 -0
- package/lib/types/characters/hands/hand-rig.d.ts +116 -0
- package/lib/types/characters/hands/index.d.ts +3 -0
- package/lib/types/characters/index.d.ts +4 -0
- package/lib/types/characters/species/human.d.ts +4 -1
- package/lib/types/characters/stick-figure.d.ts +86 -4
- package/lib/types/characters/stick-to-human.d.ts +27 -0
- package/lib/types/engine/authoring/beats.d.ts +64 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _e(t) {
|
|
2
2
|
return typeof t == "object" && t !== null && t.type === "cubic-bezier";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function Mt(t) {
|
|
5
5
|
return typeof t == "object" && t !== null && t.type !== "cubic-bezier";
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const it = 1;
|
|
8
8
|
function kt(t) {
|
|
9
9
|
return t.property === "text" && "textConfig" in t;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function V(t) {
|
|
12
12
|
return t.kind === "inertia" && "inertia" in t;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function H(t) {
|
|
15
15
|
return t.kind === "spring" && "spring" in t;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function qt(t) {
|
|
18
18
|
return t.property === "motionPath" && "motionPathConfig" in t;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Yn(t) {
|
|
21
21
|
return typeof t == "object" && t !== null && "x" in t && "y" in t && "angle" in t;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function Me(t) {
|
|
24
24
|
return "keyframes" in t;
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class Un {
|
|
27
27
|
_currentTime = 0;
|
|
28
28
|
_isRunning = !1;
|
|
29
29
|
onTick = null;
|
|
@@ -49,7 +49,7 @@ class On {
|
|
|
49
49
|
this._currentTime = e;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
class
|
|
52
|
+
class Vn {
|
|
53
53
|
_currentTime = 0;
|
|
54
54
|
_isRunning = !1;
|
|
55
55
|
_lastFrameTime = null;
|
|
@@ -89,18 +89,18 @@ class Nn {
|
|
|
89
89
|
_onFrame(e) {
|
|
90
90
|
if (this._isRunning) {
|
|
91
91
|
if (this._lastFrameTime !== null) {
|
|
92
|
-
const
|
|
93
|
-
this._currentTime +=
|
|
92
|
+
const r = (e - this._lastFrameTime) * this._speed;
|
|
93
|
+
this._currentTime += r, this.onTick?.(r, this._currentTime);
|
|
94
94
|
}
|
|
95
95
|
this._lastFrameTime = e, this._scheduleFrame();
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function Wt(t, e, n = "start") {
|
|
100
100
|
if (e <= 1) return 0;
|
|
101
101
|
if (typeof n == "number") {
|
|
102
|
-
const
|
|
103
|
-
return Math.abs(t -
|
|
102
|
+
const r = Math.max(0, Math.min(e - 1, n));
|
|
103
|
+
return Math.abs(t - r);
|
|
104
104
|
}
|
|
105
105
|
switch (n) {
|
|
106
106
|
case "end":
|
|
@@ -113,36 +113,36 @@ function zt(t, e, n = "start") {
|
|
|
113
113
|
return t;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function be(t, e = "start") {
|
|
117
117
|
if (t <= 1) return 0;
|
|
118
118
|
let n = 0;
|
|
119
|
-
for (let
|
|
120
|
-
n = Math.max(n,
|
|
119
|
+
for (let r = 0; r < t; r++)
|
|
120
|
+
n = Math.max(n, Wt(r, t, e));
|
|
121
121
|
return n;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function jt(t, e, n) {
|
|
124
124
|
if (n.offsets) return n.offsets[t] ?? 0;
|
|
125
|
-
const
|
|
125
|
+
const r = n.from ?? "start", s = Wt(t, e, r);
|
|
126
126
|
if (n.amount !== void 0) {
|
|
127
|
-
const i =
|
|
128
|
-
return i === 0 ? 0 : n.amount *
|
|
127
|
+
const i = be(e, r);
|
|
128
|
+
return i === 0 ? 0 : n.amount * s / i;
|
|
129
129
|
}
|
|
130
|
-
return n.each !== void 0 ? n.each *
|
|
130
|
+
return n.each !== void 0 ? n.each * s : 0;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
return Array.from({ length: t }, (n,
|
|
132
|
+
function Te(t, e) {
|
|
133
|
+
return Array.from({ length: t }, (n, r) => jt(r, t, e));
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
return t <= 1 ? 0 : Math.max(...
|
|
135
|
+
function vt(t, e) {
|
|
136
|
+
return t <= 1 ? 0 : Math.max(...Te(t, e));
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const Z = 1, Kt = 6e4, nt = Kt / Z, E = {
|
|
139
139
|
stiffness: 180,
|
|
140
140
|
damping: 12,
|
|
141
141
|
mass: 1,
|
|
142
142
|
velocity: 0,
|
|
143
143
|
restDelta: 0.01,
|
|
144
144
|
restSpeed: 0.1
|
|
145
|
-
},
|
|
145
|
+
}, Hn = {
|
|
146
146
|
gentle: { stiffness: 120, damping: 18, mass: 1 },
|
|
147
147
|
default: { stiffness: 180, damping: 12, mass: 1 },
|
|
148
148
|
snappy: { stiffness: 280, damping: 20, mass: 1 },
|
|
@@ -150,7 +150,7 @@ const G = 1, Wt = 6e4, et = Wt / G, C = {
|
|
|
150
150
|
wobbly: { stiffness: 180, damping: 5, mass: 1 },
|
|
151
151
|
stiff: { stiffness: 400, damping: 30, mass: 1 }
|
|
152
152
|
};
|
|
153
|
-
class
|
|
153
|
+
class at {
|
|
154
154
|
from;
|
|
155
155
|
to;
|
|
156
156
|
stiffness;
|
|
@@ -175,7 +175,7 @@ class it {
|
|
|
175
175
|
/** Once at rest we stop simulating; every later time returns `to`. */
|
|
176
176
|
settledStep = null;
|
|
177
177
|
constructor(e) {
|
|
178
|
-
this.from = e.from, this.to = e.to, this.stiffness = e.stiffness ??
|
|
178
|
+
this.from = e.from, this.to = e.to, this.stiffness = e.stiffness ?? E.stiffness, this.damping = e.damping ?? E.damping, this.mass = e.mass ?? E.mass, this.restDelta = e.restDelta ?? E.restDelta, this.restSpeed = e.restSpeed ?? E.restSpeed, this.distance = Math.abs(this.to - this.from) || 1, this.samples = [this.from], this.velocity = e.velocity ?? E.velocity, this.isAtRest(this.from) && (this.settledStep = 0);
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* Whether a position/velocity pair counts as settled.
|
|
@@ -193,155 +193,155 @@ class it {
|
|
|
193
193
|
*/
|
|
194
194
|
valueAt(e) {
|
|
195
195
|
if (e <= 0) return this.from;
|
|
196
|
-
const n = Math.floor(e /
|
|
196
|
+
const n = Math.floor(e / Z);
|
|
197
197
|
if (this.simulateTo(n + 1), this.settledStep !== null && n >= this.settledStep)
|
|
198
198
|
return this.to;
|
|
199
|
-
const
|
|
200
|
-
return
|
|
199
|
+
const r = this.samples[Math.min(n, this.samples.length - 1)], s = this.samples[Math.min(n + 1, this.samples.length - 1)], i = e / Z - n;
|
|
200
|
+
return r + (s - r) * i;
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* How long the spring takes to settle, in milliseconds — the natural duration
|
|
204
204
|
* of a spring track. Runs the simulation to completion once.
|
|
205
205
|
*/
|
|
206
206
|
settleTime() {
|
|
207
|
-
return this.simulateTo(
|
|
207
|
+
return this.simulateTo(nt + 1), this.settledStep !== null ? this.settledStep * Z : Kt;
|
|
208
208
|
}
|
|
209
209
|
/** Advance the cached simulation until it holds at least `steps` samples. */
|
|
210
210
|
simulateTo(e) {
|
|
211
211
|
if (this.settledStep !== null) return;
|
|
212
|
-
const n = Math.min(e,
|
|
212
|
+
const n = Math.min(e, nt + 1), r = Z / 1e3;
|
|
213
213
|
for (; this.samples.length < n; ) {
|
|
214
|
-
const
|
|
215
|
-
this.velocity += c *
|
|
216
|
-
const u =
|
|
214
|
+
const s = this.samples[this.samples.length - 1], i = s - this.to, a = -this.stiffness * i, o = -this.damping * this.velocity, c = (a + o) / this.mass;
|
|
215
|
+
this.velocity += c * r;
|
|
216
|
+
const u = s + this.velocity * r;
|
|
217
217
|
if (this.samples.push(u), this.isAtRest(u)) {
|
|
218
218
|
this.settledStep = this.samples.length - 1;
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
this.samples.length >
|
|
222
|
+
this.samples.length > nt && (this.settledStep = nt);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
return new
|
|
225
|
+
function zn(t, e) {
|
|
226
|
+
return new at(t).valueAt(e);
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return new
|
|
228
|
+
function Bn(t) {
|
|
229
|
+
return new at(t).settleTime();
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
const e = t.stiffness ??
|
|
233
|
-
return n < 2 * Math.sqrt(e *
|
|
231
|
+
function qn(t) {
|
|
232
|
+
const e = t.stiffness ?? E.stiffness, n = t.damping ?? E.damping, r = t.mass ?? E.mass;
|
|
233
|
+
return n < 2 * Math.sqrt(e * r);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
const e = t.stiffness ??
|
|
235
|
+
function Wn(t) {
|
|
236
|
+
const e = t.stiffness ?? E.stiffness, n = t.mass ?? E.mass;
|
|
237
237
|
return 2 * Math.sqrt(e * n);
|
|
238
238
|
}
|
|
239
|
-
const
|
|
240
|
-
function
|
|
241
|
-
const e = t.friction ??
|
|
242
|
-
return e > 0 ? e :
|
|
239
|
+
const Rt = 4, xe = 2e-3, ke = 1e-4, ve = 6e4;
|
|
240
|
+
function ot(t) {
|
|
241
|
+
const e = t.friction ?? Rt;
|
|
242
|
+
return e > 0 ? e : Rt;
|
|
243
243
|
}
|
|
244
|
-
function
|
|
245
|
-
return t.from + t.velocity /
|
|
244
|
+
function Se(t) {
|
|
245
|
+
return t.from + t.velocity / ot(t);
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function Ae(t, e) {
|
|
248
248
|
if (e === void 0) return t;
|
|
249
249
|
if (typeof e == "number")
|
|
250
250
|
return e > 0 ? Math.round(t / e) * e : t;
|
|
251
251
|
if (e.length === 0) return t;
|
|
252
252
|
let n = e[0];
|
|
253
|
-
for (const
|
|
254
|
-
Math.abs(
|
|
253
|
+
for (const r of e)
|
|
254
|
+
Math.abs(r - t) < Math.abs(n - t) && (n = r);
|
|
255
255
|
return n;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
258
|
-
let e =
|
|
257
|
+
function ct(t) {
|
|
258
|
+
let e = Ae(Se(t), t.end);
|
|
259
259
|
return t.min !== void 0 && (e = Math.max(t.min, e)), t.max !== void 0 && (e = Math.min(t.max, e)), e;
|
|
260
260
|
}
|
|
261
|
-
function
|
|
262
|
-
const e = Math.abs(
|
|
261
|
+
function ut(t) {
|
|
262
|
+
const e = Math.abs(ct(t) - t.from);
|
|
263
263
|
if (e === 0) return 0;
|
|
264
|
-
const n = t.restDelta ?? Math.max(
|
|
264
|
+
const n = t.restDelta ?? Math.max(ke, e * xe);
|
|
265
265
|
if (n >= e) return 0;
|
|
266
|
-
const
|
|
267
|
-
return Math.min(
|
|
266
|
+
const r = Math.log(e / n) / ot(t);
|
|
267
|
+
return Math.min(ve, r * 1e3);
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function bt(t, e) {
|
|
270
270
|
if (e <= 0) return t.from;
|
|
271
|
-
const n =
|
|
272
|
-
if (e >=
|
|
273
|
-
const
|
|
274
|
-
return t.from + (n - t.from) * (1 - Math.exp(-
|
|
271
|
+
const n = ct(t);
|
|
272
|
+
if (e >= ut(t)) return n;
|
|
273
|
+
const r = ot(t);
|
|
274
|
+
return t.from + (n - t.from) * (1 - Math.exp(-r * e / 1e3));
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const n =
|
|
278
|
-
return e >=
|
|
276
|
+
function jn(t, e) {
|
|
277
|
+
const n = ot(t), r = ct(t);
|
|
278
|
+
return e >= ut(t) ? 0 : (r - t.from) * n * Math.exp(-n * Math.max(0, e) / 1e3);
|
|
279
279
|
}
|
|
280
|
-
const Tt = (t) => t,
|
|
280
|
+
const Tt = (t) => t, we = (t) => t * t, Pe = (t) => 1 - (1 - t) * (1 - t), $e = (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2, Qt = (t) => t * t * t, Gt = (t) => 1 - Math.pow(1 - t, 3), Zt = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2, Re = Qt, De = Gt, Ce = Zt, Ie = {
|
|
281
281
|
linear: Tt,
|
|
282
|
-
"ease-in":
|
|
283
|
-
"ease-out":
|
|
284
|
-
"ease-in-out":
|
|
285
|
-
"ease-in-quad":
|
|
286
|
-
"ease-out-quad":
|
|
287
|
-
"ease-in-out-quad":
|
|
288
|
-
"ease-in-cubic":
|
|
289
|
-
"ease-out-cubic":
|
|
290
|
-
"ease-in-out-cubic":
|
|
282
|
+
"ease-in": Re,
|
|
283
|
+
"ease-out": De,
|
|
284
|
+
"ease-in-out": Ce,
|
|
285
|
+
"ease-in-quad": we,
|
|
286
|
+
"ease-out-quad": Pe,
|
|
287
|
+
"ease-in-out-quad": $e,
|
|
288
|
+
"ease-in-cubic": Qt,
|
|
289
|
+
"ease-out-cubic": Gt,
|
|
290
|
+
"ease-in-out-cubic": Zt
|
|
291
291
|
};
|
|
292
|
-
function
|
|
293
|
-
const [e, n,
|
|
292
|
+
function Ee(t) {
|
|
293
|
+
const [e, n, r, s] = t, i = 3 * e, a = 3 * (r - e) - i, o = 1 - i - a, c = 3 * n, u = 3 * (s - n) - c, l = 1 - c - u, h = (d) => ((o * d + a) * d + i) * d, p = (d) => ((l * d + u) * d + c) * d, f = (d) => (3 * o * d + 2 * a) * d + i, _ = (d) => {
|
|
294
294
|
let g = d;
|
|
295
|
-
for (let
|
|
296
|
-
const
|
|
297
|
-
if (Math.abs(
|
|
295
|
+
for (let k = 0; k < 8; k++) {
|
|
296
|
+
const A = h(g) - d;
|
|
297
|
+
if (Math.abs(A) < 1e-7)
|
|
298
298
|
return g;
|
|
299
|
-
const
|
|
300
|
-
if (Math.abs(
|
|
299
|
+
const y = f(g);
|
|
300
|
+
if (Math.abs(y) < 1e-7)
|
|
301
301
|
break;
|
|
302
|
-
g -=
|
|
302
|
+
g -= A / y;
|
|
303
303
|
}
|
|
304
|
-
let
|
|
305
|
-
for (g = d;
|
|
306
|
-
const
|
|
307
|
-
if (Math.abs(
|
|
304
|
+
let M = 0, b = 1;
|
|
305
|
+
for (g = d; M < b; ) {
|
|
306
|
+
const k = h(g);
|
|
307
|
+
if (Math.abs(k - d) < 1e-7)
|
|
308
308
|
return g;
|
|
309
|
-
d >
|
|
309
|
+
d > k ? M = g : b = g, g = (M + b) / 2;
|
|
310
310
|
}
|
|
311
311
|
return g;
|
|
312
312
|
};
|
|
313
313
|
return (d) => {
|
|
314
314
|
if (d <= 0) return 0;
|
|
315
315
|
if (d >= 1) return 1;
|
|
316
|
-
const g =
|
|
316
|
+
const g = _(d);
|
|
317
317
|
return p(g);
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function ft(t, e = "out") {
|
|
321
321
|
if (e === "out") return t;
|
|
322
|
-
const n = (
|
|
323
|
-
return e === "in" ? n : (
|
|
322
|
+
const n = (r) => 1 - t(1 - r);
|
|
323
|
+
return e === "in" ? n : (r) => r < 0.5 ? n(r * 2) / 2 : t(r * 2 - 1) / 2 + 0.5;
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
const n = Math.max(1, t),
|
|
327
|
-
return (
|
|
325
|
+
function Le(t = 1, e = 0.3) {
|
|
326
|
+
const n = Math.max(1, t), r = e / (2 * Math.PI) * Math.asin(1 / n);
|
|
327
|
+
return (s) => s <= 0 ? 0 : s >= 1 ? 1 : n * Math.pow(2, -10 * s) * Math.sin((s - r) * (2 * Math.PI) / e) + 1;
|
|
328
328
|
}
|
|
329
|
-
const
|
|
329
|
+
const Fe = (t) => {
|
|
330
330
|
if (t <= 0) return 0;
|
|
331
331
|
if (t >= 1) return 1;
|
|
332
332
|
if (t < 1 / 2.75) return 7.5625 * t * t;
|
|
333
333
|
if (t < 2 / 2.75) {
|
|
334
|
-
const
|
|
335
|
-
return 7.5625 *
|
|
334
|
+
const s = t - 0.5454545454545454;
|
|
335
|
+
return 7.5625 * s * s + 0.75;
|
|
336
336
|
}
|
|
337
337
|
if (t < 2.5 / 2.75) {
|
|
338
|
-
const
|
|
339
|
-
return 7.5625 *
|
|
338
|
+
const s = t - 0.8181818181818182;
|
|
339
|
+
return 7.5625 * s * s + 0.9375;
|
|
340
340
|
}
|
|
341
|
-
const
|
|
342
|
-
return 7.5625 *
|
|
341
|
+
const r = t - 2.625 / 2.75;
|
|
342
|
+
return 7.5625 * r * r + 0.984375;
|
|
343
343
|
};
|
|
344
|
-
function
|
|
344
|
+
function Oe(t = 1.70158) {
|
|
345
345
|
return (e) => {
|
|
346
346
|
if (e <= 0) return 0;
|
|
347
347
|
if (e >= 1) return 1;
|
|
@@ -349,40 +349,40 @@ function Ie(t = 1.70158) {
|
|
|
349
349
|
return n * n * ((t + 1) * n + t) + 1;
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function Ne(t, e = "end") {
|
|
353
353
|
const n = Math.max(1, Math.floor(t));
|
|
354
|
-
return (
|
|
355
|
-
if (
|
|
356
|
-
if (
|
|
357
|
-
const
|
|
354
|
+
return (r) => {
|
|
355
|
+
if (r >= 1) return 1;
|
|
356
|
+
if (r <= 0) return e === "start" || e === "both" ? e === "start" ? 1 / n : 1 / (n + 1) : 0;
|
|
357
|
+
const s = Math.floor(r * n);
|
|
358
358
|
switch (e) {
|
|
359
359
|
case "start":
|
|
360
|
-
return Math.min(1, (
|
|
360
|
+
return Math.min(1, (s + 1) / n);
|
|
361
361
|
case "both":
|
|
362
|
-
return (
|
|
362
|
+
return (s + 1) / (n + 1);
|
|
363
363
|
case "none":
|
|
364
|
-
return n === 1 ? 0 : Math.min(1,
|
|
364
|
+
return n === 1 ? 0 : Math.min(1, s / (n - 1));
|
|
365
365
|
default:
|
|
366
|
-
return
|
|
366
|
+
return s / n;
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function Xe(t) {
|
|
371
371
|
switch (t.type) {
|
|
372
372
|
case "steps":
|
|
373
|
-
return
|
|
373
|
+
return Ne(t.count, t.position);
|
|
374
374
|
case "elastic":
|
|
375
|
-
return
|
|
375
|
+
return ft(Le(t.amplitude, t.period), t.mode);
|
|
376
376
|
case "bounce":
|
|
377
|
-
return
|
|
377
|
+
return ft(Fe, t.mode);
|
|
378
378
|
case "back":
|
|
379
|
-
return
|
|
379
|
+
return ft(Oe(t.overshoot), t.mode);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
function
|
|
383
|
-
return t === void 0 ? Tt :
|
|
382
|
+
function Jt(t) {
|
|
383
|
+
return t === void 0 ? Tt : _e(t) ? Ee(t.points) : Mt(t) ? Xe(t) : Ie[t] ?? Tt;
|
|
384
384
|
}
|
|
385
|
-
const
|
|
385
|
+
const Dt = 32, Ye = 256, q = /* @__PURE__ */ new Map(), Ue = /[MmLlHhVvCcSsQqTtAaZz]/, Ve = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, He = {
|
|
386
386
|
M: 2,
|
|
387
387
|
L: 2,
|
|
388
388
|
H: 1,
|
|
@@ -394,90 +394,90 @@ const Pt = 32, Fe = 256, z = /* @__PURE__ */ new Map(), Oe = /[MmLlHhVvCcSsQqTtA
|
|
|
394
394
|
A: 7,
|
|
395
395
|
Z: 0
|
|
396
396
|
};
|
|
397
|
-
function
|
|
397
|
+
function ze(t) {
|
|
398
398
|
const e = [];
|
|
399
|
-
let n = 0,
|
|
400
|
-
const
|
|
399
|
+
let n = 0, r = null;
|
|
400
|
+
const s = () => {
|
|
401
401
|
for (; n < t.length && /[\s,]/.test(t[n]); ) n++;
|
|
402
402
|
};
|
|
403
|
-
for (; n < t.length && (
|
|
403
|
+
for (; n < t.length && (s(), !(n >= t.length)); ) {
|
|
404
404
|
const i = t[n];
|
|
405
|
-
if (
|
|
406
|
-
|
|
405
|
+
if (Ue.test(i)) {
|
|
406
|
+
r = { type: i, args: [] }, e.push(r), n++;
|
|
407
407
|
continue;
|
|
408
408
|
}
|
|
409
|
-
if (!
|
|
410
|
-
const a =
|
|
409
|
+
if (!r) break;
|
|
410
|
+
const a = r.type === "A" || r.type === "a", o = r.args.length % 7;
|
|
411
411
|
if (a && (o === 3 || o === 4)) {
|
|
412
412
|
if (i !== "0" && i !== "1") break;
|
|
413
|
-
|
|
413
|
+
r.args.push(i === "1" ? 1 : 0), n++;
|
|
414
414
|
continue;
|
|
415
415
|
}
|
|
416
|
-
const c =
|
|
416
|
+
const c = Ve.exec(t.slice(n));
|
|
417
417
|
if (!c) break;
|
|
418
|
-
|
|
418
|
+
r.args.push(parseFloat(c[0])), n += c[0].length;
|
|
419
419
|
}
|
|
420
420
|
return e;
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function Be(t, e, n, r, s, i, a, o, c) {
|
|
423
423
|
if (t === o && e === c) return [];
|
|
424
|
-
let u = Math.abs(n), l = Math.abs(
|
|
424
|
+
let u = Math.abs(n), l = Math.abs(r);
|
|
425
425
|
if (u === 0 || l === 0) return [[t, e, o, c, o, c]];
|
|
426
|
-
const h =
|
|
427
|
-
if (
|
|
428
|
-
const
|
|
429
|
-
u *=
|
|
430
|
-
}
|
|
431
|
-
const
|
|
432
|
-
const
|
|
433
|
-
return
|
|
434
|
-
},
|
|
435
|
-
let
|
|
436
|
-
!a &&
|
|
437
|
-
const
|
|
438
|
-
const
|
|
439
|
-
return [p *
|
|
440
|
-
},
|
|
441
|
-
const
|
|
442
|
-
return [p *
|
|
443
|
-
},
|
|
444
|
-
for (let
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
return
|
|
449
|
-
}
|
|
450
|
-
function
|
|
451
|
-
const i = 1 -
|
|
452
|
-
return i * i * i * t + 3 * i * i *
|
|
453
|
-
}
|
|
454
|
-
function
|
|
455
|
-
const i = 1 -
|
|
456
|
-
return 3 * i * i * (e - t) + 6 * i *
|
|
457
|
-
}
|
|
458
|
-
function
|
|
426
|
+
const h = s * Math.PI / 180, p = Math.cos(h), f = Math.sin(h), _ = (t - o) / 2, d = (e - c) / 2, g = p * _ + f * d, M = -f * _ + p * d, b = g * g / (u * u) + M * M / (l * l);
|
|
427
|
+
if (b > 1) {
|
|
428
|
+
const P = Math.sqrt(b);
|
|
429
|
+
u *= P, l *= P;
|
|
430
|
+
}
|
|
431
|
+
const k = i === a ? -1 : 1, A = u * u * l * l - u * u * M * M - l * l * g * g, y = u * u * M * M + l * l * g * g, w = k * Math.sqrt(Math.max(0, A / y)), S = w * u * M / l, I = -w * l * g / u, m = p * S - f * I + (t + o) / 2, T = f * S + p * I + (e + c) / 2, x = (P, D, C, z) => {
|
|
432
|
+
const ht = P * C + D * z, et = Math.sqrt((P * P + D * D) * (C * C + z * z)), K = Math.acos(Math.max(-1, Math.min(1, ht / et)));
|
|
433
|
+
return P * z - D * C < 0 ? -K : K;
|
|
434
|
+
}, v = x(1, 0, (g - S) / u, (M - I) / l);
|
|
435
|
+
let $ = x((g - S) / u, (M - I) / l, (-g - S) / u, (-M - I) / l);
|
|
436
|
+
!a && $ > 0 && ($ -= 2 * Math.PI), a && $ < 0 && ($ += 2 * Math.PI);
|
|
437
|
+
const Y = Math.max(1, Math.ceil(Math.abs($) / (Math.PI / 2))), lt = $ / Y, tt = 4 / 3 * Math.tan(lt / 4), wt = (P) => {
|
|
438
|
+
const D = u * Math.cos(P), C = l * Math.sin(P);
|
|
439
|
+
return [p * D - f * C + m, f * D + p * C + T];
|
|
440
|
+
}, Pt = (P) => {
|
|
441
|
+
const D = -u * Math.sin(P), C = l * Math.cos(P);
|
|
442
|
+
return [p * D - f * C, f * D + p * C];
|
|
443
|
+
}, $t = [];
|
|
444
|
+
for (let P = 0; P < Y; P++) {
|
|
445
|
+
const D = v + P * lt, C = D + lt, [z, ht] = wt(D), [et, K] = P === Y - 1 ? [o, c] : wt(C), [de, ge] = Pt(D), [me, ye] = Pt(C);
|
|
446
|
+
$t.push([z + tt * de, ht + tt * ge, et - tt * me, K - tt * ye, et, K]);
|
|
447
|
+
}
|
|
448
|
+
return $t;
|
|
449
|
+
}
|
|
450
|
+
function X(t, e, n, r, s) {
|
|
451
|
+
const i = 1 - s;
|
|
452
|
+
return i * i * i * t + 3 * i * i * s * e + 3 * i * s * s * n + s * s * s * r;
|
|
453
|
+
}
|
|
454
|
+
function Ct(t, e, n, r, s) {
|
|
455
|
+
const i = 1 - s;
|
|
456
|
+
return 3 * i * i * (e - t) + 6 * i * s * (n - e) + 3 * s * s * (r - n);
|
|
457
|
+
}
|
|
458
|
+
function Q(t, e, n, r) {
|
|
459
459
|
return {
|
|
460
460
|
subpath: 0,
|
|
461
461
|
type: "L",
|
|
462
|
-
points: [n,
|
|
462
|
+
points: [n, r],
|
|
463
463
|
startX: t,
|
|
464
464
|
startY: e,
|
|
465
465
|
endX: n,
|
|
466
|
-
endY:
|
|
467
|
-
length: Math.hypot(n - t,
|
|
466
|
+
endY: r,
|
|
467
|
+
length: Math.hypot(n - t, r - e)
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
|
-
function
|
|
471
|
-
const [
|
|
470
|
+
function rt(t, e, n) {
|
|
471
|
+
const [r, s, i, a, o, c] = n, u = [0];
|
|
472
472
|
let l = t, h = e, p = 0;
|
|
473
|
-
for (let f = 1; f <=
|
|
474
|
-
const
|
|
473
|
+
for (let f = 1; f <= Dt; f++) {
|
|
474
|
+
const _ = f / Dt, d = X(t, r, i, o, _), g = X(e, s, a, c, _);
|
|
475
475
|
p += Math.hypot(d - l, g - h), u.push(p), l = d, h = g;
|
|
476
476
|
}
|
|
477
477
|
return {
|
|
478
478
|
subpath: 0,
|
|
479
479
|
type: "C",
|
|
480
|
-
points: [
|
|
480
|
+
points: [r, s, i, a, o, c],
|
|
481
481
|
startX: t,
|
|
482
482
|
startY: e,
|
|
483
483
|
endX: o,
|
|
@@ -486,99 +486,99 @@ function nt(t, e, n) {
|
|
|
486
486
|
lengths: u
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
|
-
function
|
|
490
|
-
const e =
|
|
489
|
+
function W(t) {
|
|
490
|
+
const e = q.get(t);
|
|
491
491
|
if (e) return e;
|
|
492
492
|
const n = [];
|
|
493
|
-
let
|
|
493
|
+
let r = 0, s = 0, i = 0, a = 0, o = null, c = null, u = -1;
|
|
494
494
|
const l = /* @__PURE__ */ new Set(), h = (d) => {
|
|
495
495
|
u < 0 && (u = 0), d.subpath = u, n.push(d);
|
|
496
496
|
};
|
|
497
|
-
for (const { type: d, args: g } of
|
|
498
|
-
const
|
|
499
|
-
if (
|
|
500
|
-
(
|
|
497
|
+
for (const { type: d, args: g } of ze(t)) {
|
|
498
|
+
const M = d.toUpperCase(), b = d !== M, k = He[M];
|
|
499
|
+
if (M === "Z") {
|
|
500
|
+
(r !== i || s !== a) && h(Q(r, s, i, a)), u >= 0 && l.add(u), r = i, s = a, o = c = null;
|
|
501
501
|
continue;
|
|
502
502
|
}
|
|
503
|
-
for (let
|
|
504
|
-
const
|
|
505
|
-
let
|
|
506
|
-
switch (
|
|
503
|
+
for (let A = 0; A + k <= g.length; A += k) {
|
|
504
|
+
const y = g.slice(A, A + k), w = b ? r : 0, S = b ? s : 0;
|
|
505
|
+
let I = null, m = null;
|
|
506
|
+
switch (M) {
|
|
507
507
|
case "M":
|
|
508
|
-
|
|
508
|
+
A === 0 ? (r = y[0] + w, s = y[1] + S, i = r, a = s, (u < 0 || n[n.length - 1]?.subpath === u) && u++) : (h(Q(r, s, y[0] + w, y[1] + S)), r = y[0] + w, s = y[1] + S);
|
|
509
509
|
break;
|
|
510
510
|
case "L":
|
|
511
|
-
h(
|
|
511
|
+
h(Q(r, s, y[0] + w, y[1] + S)), r = y[0] + w, s = y[1] + S;
|
|
512
512
|
break;
|
|
513
513
|
case "H":
|
|
514
|
-
h(
|
|
514
|
+
h(Q(r, s, y[0] + w, s)), r = y[0] + w;
|
|
515
515
|
break;
|
|
516
516
|
case "V":
|
|
517
|
-
h(
|
|
517
|
+
h(Q(r, s, r, y[0] + S)), s = y[0] + S;
|
|
518
518
|
break;
|
|
519
519
|
case "C": {
|
|
520
|
-
const
|
|
521
|
-
h(
|
|
520
|
+
const T = [y[0] + w, y[1] + S, y[2] + w, y[3] + S, y[4] + w, y[5] + S];
|
|
521
|
+
h(rt(r, s, T)), I = [T[2], T[3]], r = T[4], s = T[5];
|
|
522
522
|
break;
|
|
523
523
|
}
|
|
524
524
|
case "S": {
|
|
525
|
-
const [
|
|
526
|
-
h(
|
|
525
|
+
const [T, x] = o ? [2 * r - o[0], 2 * s - o[1]] : [r, s], v = [T, x, y[0] + w, y[1] + S, y[2] + w, y[3] + S];
|
|
526
|
+
h(rt(r, s, v)), I = [v[2], v[3]], r = v[4], s = v[5];
|
|
527
527
|
break;
|
|
528
528
|
}
|
|
529
529
|
case "Q":
|
|
530
530
|
case "T": {
|
|
531
|
-
let
|
|
532
|
-
|
|
533
|
-
const
|
|
531
|
+
let T = r, x = s;
|
|
532
|
+
M === "Q" ? (T = y[0] + w, x = y[1] + S) : c && (T = 2 * r - c[0], x = 2 * s - c[1]);
|
|
533
|
+
const v = M === "Q" ? y[2] + w : y[0] + w, $ = M === "Q" ? y[3] + S : y[1] + S;
|
|
534
534
|
h(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
535
|
+
rt(r, s, [
|
|
536
|
+
r + 2 / 3 * (T - r),
|
|
537
|
+
s + 2 / 3 * (x - s),
|
|
538
|
+
v + 2 / 3 * (T - v),
|
|
539
|
+
$ + 2 / 3 * (x - $),
|
|
540
|
+
v,
|
|
541
|
+
$
|
|
542
542
|
])
|
|
543
|
-
),
|
|
543
|
+
), m = [T, x], r = v, s = $;
|
|
544
544
|
break;
|
|
545
545
|
}
|
|
546
546
|
case "A": {
|
|
547
|
-
const
|
|
548
|
-
let
|
|
549
|
-
for (const
|
|
550
|
-
h(
|
|
551
|
-
|
|
547
|
+
const T = y[5] + w, x = y[6] + S;
|
|
548
|
+
let v = r, $ = s;
|
|
549
|
+
for (const Y of Be(r, s, y[0], y[1], y[2], y[3], y[4], T, x))
|
|
550
|
+
h(rt(v, $, Y)), v = Y[4], $ = Y[5];
|
|
551
|
+
r = T, s = x;
|
|
552
552
|
break;
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
-
o =
|
|
555
|
+
o = I, c = m;
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
const p = n.reduce((d, g) => d + g.length, 0), f = [];
|
|
559
559
|
for (let d = 0; d < n.length; ) {
|
|
560
560
|
const g = n[d].subpath;
|
|
561
|
-
let
|
|
562
|
-
for (;
|
|
563
|
-
const
|
|
564
|
-
f.push({ start: d, end:
|
|
561
|
+
let M = d, b = 0;
|
|
562
|
+
for (; M < n.length && n[M].subpath === g; ) b += n[M++].length;
|
|
563
|
+
const k = n[d], A = n[M - 1], y = l.has(g) || Math.abs(A.endX - k.startX) < 1e-9 && Math.abs(A.endY - k.startY) < 1e-9;
|
|
564
|
+
f.push({ start: d, end: M, length: b, closed: y }), d = M;
|
|
565
565
|
}
|
|
566
|
-
const
|
|
567
|
-
return
|
|
566
|
+
const _ = { segments: n, totalLength: p, subpaths: f };
|
|
567
|
+
return q.size >= Ye && q.delete(q.keys().next().value), q.set(t, _), _;
|
|
568
568
|
}
|
|
569
|
-
function
|
|
569
|
+
function qe(t, e) {
|
|
570
570
|
const n = t.lengths;
|
|
571
571
|
if (e <= 0) return 0;
|
|
572
572
|
if (e >= t.length) return 1;
|
|
573
|
-
let
|
|
574
|
-
for (;
|
|
575
|
-
const o =
|
|
576
|
-
n[o] < e ?
|
|
573
|
+
let r = 0, s = n.length - 1;
|
|
574
|
+
for (; r < s - 1; ) {
|
|
575
|
+
const o = r + s >> 1;
|
|
576
|
+
n[o] < e ? r = o : s = o;
|
|
577
577
|
}
|
|
578
|
-
const i = n[
|
|
579
|
-
return (
|
|
578
|
+
const i = n[s] - n[r], a = i > 0 ? (e - n[r]) / i : 0;
|
|
579
|
+
return (r + a) / (n.length - 1);
|
|
580
580
|
}
|
|
581
|
-
function
|
|
581
|
+
function We(t, e) {
|
|
582
582
|
if (t.type === "L") {
|
|
583
583
|
const h = t.length > 0 ? Math.max(0, Math.min(1, e / t.length)) : 0;
|
|
584
584
|
return {
|
|
@@ -587,263 +587,263 @@ function He(t, e) {
|
|
|
587
587
|
angle: Math.atan2(t.endY - t.startY, t.endX - t.startX) * 180 / Math.PI
|
|
588
588
|
};
|
|
589
589
|
}
|
|
590
|
-
const [n,
|
|
591
|
-
let u =
|
|
590
|
+
const [n, r, s, i, a, o] = t.points, c = qe(t, e);
|
|
591
|
+
let u = Ct(t.startX, n, s, a, c), l = Ct(t.startY, r, i, o, c);
|
|
592
592
|
if (Math.hypot(u, l) < 1e-9) {
|
|
593
|
-
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), p =
|
|
594
|
-
u = c < 0.5 ? p -
|
|
593
|
+
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), p = X(t.startX, n, s, a, h), f = X(t.startY, r, i, o, h), _ = X(t.startX, n, s, a, c), d = X(t.startY, r, i, o, c);
|
|
594
|
+
u = c < 0.5 ? p - _ : _ - p, l = c < 0.5 ? f - d : d - f;
|
|
595
595
|
}
|
|
596
596
|
return {
|
|
597
|
-
x:
|
|
598
|
-
y:
|
|
597
|
+
x: X(t.startX, n, s, a, c),
|
|
598
|
+
y: X(t.startY, r, i, o, c),
|
|
599
599
|
angle: Math.atan2(l, u) * 180 / Math.PI
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
|
-
function
|
|
603
|
-
if (
|
|
604
|
-
let
|
|
605
|
-
for (let i = n; i <
|
|
602
|
+
function te(t, e, n = 0, r = t.length) {
|
|
603
|
+
if (r <= n) return { x: 0, y: 0, angle: 0 };
|
|
604
|
+
let s = 0;
|
|
605
|
+
for (let i = n; i < r; i++) {
|
|
606
606
|
const a = t[i];
|
|
607
|
-
if (
|
|
608
|
-
return
|
|
609
|
-
|
|
607
|
+
if (s + a.length >= e || i === r - 1)
|
|
608
|
+
return We(a, e - s);
|
|
609
|
+
s += a.length;
|
|
610
610
|
}
|
|
611
611
|
return { x: 0, y: 0, angle: 0 };
|
|
612
612
|
}
|
|
613
|
-
function
|
|
614
|
-
const { segments: n, totalLength:
|
|
615
|
-
return
|
|
613
|
+
function je(t, e) {
|
|
614
|
+
const { segments: n, totalLength: r } = W(t);
|
|
615
|
+
return te(n, Math.max(0, Math.min(1, e)) * r);
|
|
616
616
|
}
|
|
617
|
-
function
|
|
618
|
-
|
|
617
|
+
function Kn() {
|
|
618
|
+
q.clear();
|
|
619
619
|
}
|
|
620
|
-
function
|
|
621
|
-
return
|
|
620
|
+
function Qn(t) {
|
|
621
|
+
return W(t).totalLength;
|
|
622
622
|
}
|
|
623
|
-
const
|
|
624
|
-
let st = 0,
|
|
625
|
-
const
|
|
626
|
-
function
|
|
627
|
-
const { segments: n, subpaths:
|
|
623
|
+
const Ke = 24, Qe = 320, Ge = 2.5, G = 72, Gn = 64, Ze = 0.2, Je = 128, J = /* @__PURE__ */ new Map();
|
|
624
|
+
let st = 0, N;
|
|
625
|
+
const It = (t) => Math.round(t * 100) / 100;
|
|
626
|
+
function Et(t, e) {
|
|
627
|
+
const { segments: n, subpaths: r, totalLength: s } = W(t);
|
|
628
628
|
if (n.length === 0) return [];
|
|
629
629
|
if (e) {
|
|
630
|
-
const i =
|
|
631
|
-
return [{ segments: n, start: 0, end: n.length, length:
|
|
630
|
+
const i = r.every((a) => a.closed);
|
|
631
|
+
return [{ segments: n, start: 0, end: n.length, length: s, closed: i }];
|
|
632
632
|
}
|
|
633
|
-
return
|
|
633
|
+
return r.filter((i) => i.length > 0).map((i) => ({ segments: n, start: i.start, end: i.end, length: i.length, closed: i.closed }));
|
|
634
634
|
}
|
|
635
|
-
function
|
|
636
|
-
const n = t.closed ? (e % 1 + 1) % 1 : Math.max(0, Math.min(1, e)),
|
|
637
|
-
return [
|
|
635
|
+
function xt(t, e) {
|
|
636
|
+
const n = t.closed ? (e % 1 + 1) % 1 : Math.max(0, Math.min(1, e)), r = te(t.segments, n * t.length, t.start, t.end);
|
|
637
|
+
return [r.x, r.y];
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Lt(t) {
|
|
640
640
|
const e = [];
|
|
641
641
|
let n = 0;
|
|
642
|
-
for (let
|
|
643
|
-
n += t.segments[
|
|
642
|
+
for (let r = t.start; r < t.end; r++)
|
|
643
|
+
n += t.segments[r].length, t.length > 0 && e.push(n / t.length);
|
|
644
644
|
return e;
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function Ft(t, e) {
|
|
647
647
|
const n = [];
|
|
648
|
-
for (let
|
|
649
|
-
n.push(
|
|
648
|
+
for (let r = 0; r < e; r++)
|
|
649
|
+
n.push(xt(t, t.closed ? r / e : r / (e - 1)));
|
|
650
650
|
return n;
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Ot(t) {
|
|
653
653
|
let e = 0, n = 0;
|
|
654
|
-
for (const [
|
|
655
|
-
e +=
|
|
656
|
-
return e /= t.length, n /= t.length, t.map(([
|
|
654
|
+
for (const [r, s] of t)
|
|
655
|
+
e += r, n += s;
|
|
656
|
+
return e /= t.length, n /= t.length, t.map(([r, s]) => [r - e, s - n]);
|
|
657
657
|
}
|
|
658
|
-
function
|
|
659
|
-
const
|
|
658
|
+
function tn(t, e, n) {
|
|
659
|
+
const r = t.closed && e.closed;
|
|
660
660
|
if (n !== void 0)
|
|
661
|
-
return { offset:
|
|
662
|
-
const
|
|
661
|
+
return { offset: r ? Math.abs(n) % G / G : 0, reversed: n < 0 };
|
|
662
|
+
const s = Ot(Ft(t, G)), i = Ot(Ft(e, G)), a = G;
|
|
663
663
|
let o = { offset: 0, reversed: !1 }, c = 1 / 0;
|
|
664
664
|
for (const u of [!1, !0]) {
|
|
665
|
-
const l =
|
|
665
|
+
const l = r ? a : 1;
|
|
666
666
|
for (let h = 0; h < l; h++) {
|
|
667
667
|
let p = 0;
|
|
668
668
|
for (let f = 0; f < a && p < c; f++) {
|
|
669
|
-
const
|
|
669
|
+
const _ = r ? u ? (h - f + a) % a : (f + h) % a : u ? a - 1 - f : f, d = s[f][0] - i[_][0], g = s[f][1] - i[_][1];
|
|
670
670
|
p += d * d + g * g;
|
|
671
671
|
}
|
|
672
|
-
p < c && (c = p, o = { offset:
|
|
672
|
+
p < c && (c = p, o = { offset: r ? h / a : 0, reversed: u });
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
return o;
|
|
676
676
|
}
|
|
677
|
-
function
|
|
677
|
+
function en(t, e, n) {
|
|
678
678
|
return n ? ((e.reversed ? e.offset - t : t + e.offset) % 1 + 1) % 1 : e.reversed ? 1 - t : t;
|
|
679
679
|
}
|
|
680
|
-
function
|
|
680
|
+
function nn(t, e, n) {
|
|
681
681
|
return n ? ((e.reversed ? e.offset - t : t - e.offset) % 1 + 1) % 1 : e.reversed ? 1 - t : t;
|
|
682
682
|
}
|
|
683
|
-
function
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
Math.min(
|
|
683
|
+
function rn(t, e, n) {
|
|
684
|
+
const r = t.closed && e.closed, s = tn(t, e, n.shapeIndex), i = Math.max(
|
|
685
|
+
Ke,
|
|
686
|
+
Math.min(Qe, Math.ceil(Math.max(t.length, e.length) / Ge))
|
|
687
687
|
), a = /* @__PURE__ */ new Set(), o = (h) => a.add(Math.round(h * 1e7) / 1e7);
|
|
688
688
|
for (let h = 0; h <= i; h++) o(h / i);
|
|
689
|
-
for (const h of
|
|
690
|
-
for (const h of
|
|
689
|
+
for (const h of Lt(t)) o(h);
|
|
690
|
+
for (const h of Lt(e)) o(nn(h, s, r));
|
|
691
691
|
let c = [...a].sort((h, p) => h - p);
|
|
692
|
-
|
|
692
|
+
r && (c = c.filter((h) => h < 1));
|
|
693
693
|
const u = [], l = [];
|
|
694
694
|
for (const h of c)
|
|
695
|
-
u.push(...
|
|
696
|
-
return
|
|
695
|
+
u.push(...xt(t, h)), l.push(...xt(e, en(h, s, r)));
|
|
696
|
+
return sn({ from: u, to: l, closed: r });
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function sn(t) {
|
|
699
699
|
const e = t.from.length / 2;
|
|
700
700
|
if (e <= 3) return t;
|
|
701
701
|
const n = new Uint8Array(e);
|
|
702
702
|
n[0] = 1, n[e - 1] = 1;
|
|
703
|
-
const
|
|
704
|
-
for (;
|
|
705
|
-
const [a, o] =
|
|
706
|
-
let c = -1, u =
|
|
703
|
+
const r = [[0, e - 1]];
|
|
704
|
+
for (; r.length > 0; ) {
|
|
705
|
+
const [a, o] = r.pop();
|
|
706
|
+
let c = -1, u = Ze;
|
|
707
707
|
for (let l = a + 1; l < o; l++) {
|
|
708
|
-
const h = Math.max(
|
|
708
|
+
const h = Math.max(Nt(t.from, a, o, l), Nt(t.to, a, o, l));
|
|
709
709
|
h > u && (u = h, c = l);
|
|
710
710
|
}
|
|
711
|
-
c !== -1 && (n[c] = 1,
|
|
711
|
+
c !== -1 && (n[c] = 1, r.push([a, c], [c, o]));
|
|
712
712
|
}
|
|
713
|
-
const
|
|
713
|
+
const s = [], i = [];
|
|
714
714
|
for (let a = 0; a < e; a++)
|
|
715
|
-
n[a] && (
|
|
716
|
-
return { from:
|
|
715
|
+
n[a] && (s.push(t.from[a * 2], t.from[a * 2 + 1]), i.push(t.to[a * 2], t.to[a * 2 + 1]));
|
|
716
|
+
return { from: s, to: i, closed: t.closed };
|
|
717
717
|
}
|
|
718
|
-
function
|
|
719
|
-
const
|
|
718
|
+
function Nt(t, e, n, r) {
|
|
719
|
+
const s = t[e * 2], i = t[e * 2 + 1], a = t[n * 2] - s, o = t[n * 2 + 1] - i, c = t[r * 2] - s, u = t[r * 2 + 1] - i, l = a * a + o * o, h = l === 0 ? 0 : Math.max(0, Math.min(1, (c * a + u * o) / l));
|
|
720
720
|
return Math.hypot(c - h * a, u - h * o);
|
|
721
721
|
}
|
|
722
|
-
function
|
|
723
|
-
const
|
|
724
|
-
if (
|
|
725
|
-
const i =
|
|
722
|
+
function an(t, e, n) {
|
|
723
|
+
const r = n.shapeIndex;
|
|
724
|
+
if (N && N.from === t && N.to === e && N.shapeIndex === r) return N.plan;
|
|
725
|
+
const i = J.get(String(r ?? "auto"))?.get(t)?.get(e);
|
|
726
726
|
if (i)
|
|
727
|
-
return
|
|
728
|
-
const a =
|
|
729
|
-
pairs: o.map((f,
|
|
727
|
+
return N = { from: t, to: e, shapeIndex: r, plan: i }, i;
|
|
728
|
+
const a = W(t).subpaths.filter((f) => f.length > 0).length === W(e).subpaths.filter((f) => f.length > 0).length, o = Et(t, !a), c = Et(e, !a), u = {
|
|
729
|
+
pairs: o.map((f, _) => rn(f, c[_], n))
|
|
730
730
|
};
|
|
731
|
-
st >=
|
|
732
|
-
const l = String(
|
|
733
|
-
|
|
731
|
+
st >= Je && (J.clear(), st = 0);
|
|
732
|
+
const l = String(r ?? "auto"), h = J.get(l) ?? /* @__PURE__ */ new Map();
|
|
733
|
+
J.set(l, h);
|
|
734
734
|
const p = h.get(t) ?? /* @__PURE__ */ new Map();
|
|
735
|
-
return h.set(t, p), p.set(e, u), st++,
|
|
735
|
+
return h.set(t, p), p.set(e, u), st++, N = { from: t, to: e, shapeIndex: r, plan: u }, u;
|
|
736
736
|
}
|
|
737
|
-
function
|
|
737
|
+
function on(t, e, n, r = {}) {
|
|
738
738
|
if (!t) return e;
|
|
739
739
|
if (!e) return t;
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
if (
|
|
743
|
-
const i =
|
|
744
|
-
if (i.pairs.length === 0) return
|
|
740
|
+
const s = Math.max(0, Math.min(1, n));
|
|
741
|
+
if (s === 0) return t;
|
|
742
|
+
if (s === 1) return e;
|
|
743
|
+
const i = an(t, e, r);
|
|
744
|
+
if (i.pairs.length === 0) return s < 0.5 ? t : e;
|
|
745
745
|
let a = "";
|
|
746
746
|
for (const o of i.pairs) {
|
|
747
747
|
for (let c = 0; c < o.from.length; c += 2) {
|
|
748
|
-
const u =
|
|
748
|
+
const u = It(o.from[c] + (o.to[c] - o.from[c]) * s), l = It(o.from[c + 1] + (o.to[c + 1] - o.from[c + 1]) * s);
|
|
749
749
|
a += `${c === 0 ? a ? " M" : "M" : " L"}${u} ${l}`;
|
|
750
750
|
}
|
|
751
751
|
o.closed && (a += " Z");
|
|
752
752
|
}
|
|
753
753
|
return a;
|
|
754
754
|
}
|
|
755
|
-
function
|
|
756
|
-
|
|
755
|
+
function Zn() {
|
|
756
|
+
J.clear(), st = 0, N = void 0;
|
|
757
757
|
}
|
|
758
|
-
function
|
|
758
|
+
function cn(t) {
|
|
759
759
|
return /^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t);
|
|
760
760
|
}
|
|
761
|
-
const
|
|
762
|
-
function
|
|
763
|
-
const e =
|
|
761
|
+
const O = (t, e, n) => t + (e - t) * n, ee = 512, pt = /* @__PURE__ */ new Map(), dt = /* @__PURE__ */ new Map();
|
|
762
|
+
function Xt(t) {
|
|
763
|
+
const e = pt.get(t);
|
|
764
764
|
if (e) return e;
|
|
765
|
-
const n = t.replace("#", ""),
|
|
765
|
+
const n = t.replace("#", ""), r = [
|
|
766
766
|
parseInt(n.slice(0, 2), 16),
|
|
767
767
|
parseInt(n.slice(2, 4), 16),
|
|
768
768
|
parseInt(n.slice(4, 6), 16)
|
|
769
769
|
];
|
|
770
|
-
return
|
|
770
|
+
return pt.size < ee && pt.set(t, r), r;
|
|
771
771
|
}
|
|
772
|
-
const
|
|
773
|
-
function
|
|
774
|
-
return `#${
|
|
772
|
+
const Yt = (t) => t.charCodeAt(0) === 35, Ut = (t) => t.startsWith("rgb"), Vt = (t) => t.startsWith("rgba"), un = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, gt = (t) => Math.round(t).toString(16).padStart(2, "0");
|
|
773
|
+
function ln(t, e, n) {
|
|
774
|
+
return `#${gt(t)}${gt(e)}${gt(n)}`;
|
|
775
775
|
}
|
|
776
|
-
function
|
|
777
|
-
const e =
|
|
776
|
+
function Ht(t) {
|
|
777
|
+
const e = dt.get(t);
|
|
778
778
|
if (e) return e;
|
|
779
|
-
const n = t.match(
|
|
779
|
+
const n = t.match(un);
|
|
780
780
|
if (!n)
|
|
781
781
|
throw new Error(`Invalid rgb color: ${t}`);
|
|
782
|
-
const
|
|
783
|
-
return
|
|
784
|
-
}
|
|
785
|
-
const
|
|
786
|
-
if (
|
|
787
|
-
const [
|
|
788
|
-
return
|
|
789
|
-
}
|
|
790
|
-
if ((
|
|
791
|
-
const
|
|
792
|
-
if (
|
|
793
|
-
const c =
|
|
782
|
+
const r = parseInt(n[1], 10), s = parseInt(n[2], 10), i = parseInt(n[3], 10), a = n[4] !== void 0 ? [r, s, i, parseFloat(n[4])] : [r, s, i];
|
|
783
|
+
return dt.size < ee && dt.set(t, a), a;
|
|
784
|
+
}
|
|
785
|
+
const hn = (t, e, n) => {
|
|
786
|
+
if (Yt(t) && Yt(e)) {
|
|
787
|
+
const [r, s, i] = Xt(t), [a, o, c] = Xt(e), u = O(r, a, n), l = O(s, o, n), h = O(i, c, n);
|
|
788
|
+
return ln(u, l, h);
|
|
789
|
+
}
|
|
790
|
+
if ((Ut(t) || Vt(t)) && (Ut(e) || Vt(e))) {
|
|
791
|
+
const r = Ht(t), s = Ht(e), i = Math.round(O(r[0], s[0], n)), a = Math.round(O(r[1], s[1], n)), o = Math.round(O(r[2], s[2], n));
|
|
792
|
+
if (r.length === 4 || s.length === 4) {
|
|
793
|
+
const c = r[3] ?? 1, u = s[3] ?? 1, l = O(c, u, n);
|
|
794
794
|
return `rgba(${i}, ${a}, ${o}, ${l})`;
|
|
795
795
|
}
|
|
796
796
|
return `rgb(${i}, ${a}, ${o})`;
|
|
797
797
|
}
|
|
798
798
|
return n < 1 ? t : e;
|
|
799
|
-
},
|
|
800
|
-
const
|
|
801
|
-
for (let i = 0; i <
|
|
802
|
-
|
|
803
|
-
return
|
|
804
|
-
},
|
|
805
|
-
function
|
|
806
|
-
return typeof t == "number" ?
|
|
799
|
+
}, fn = (t, e, n) => {
|
|
800
|
+
const r = Math.min(t.length, e.length), s = [];
|
|
801
|
+
for (let i = 0; i < r; i++)
|
|
802
|
+
s.push(O(t[i], e[i], n));
|
|
803
|
+
return s;
|
|
804
|
+
}, zt = (t, e, n) => n < 1 ? t : e, pn = (t, e, n) => on(t, e, n);
|
|
805
|
+
function ne(t) {
|
|
806
|
+
return typeof t == "number" ? O : Array.isArray(t) ? fn : typeof t == "string" ? t.startsWith("#") || t.startsWith("rgb") ? hn : cn(t) ? pn : zt : zt;
|
|
807
807
|
}
|
|
808
|
-
const
|
|
809
|
-
function
|
|
810
|
-
if (!
|
|
808
|
+
const re = 1e3 / 60;
|
|
809
|
+
function se(t, e = {}) {
|
|
810
|
+
if (!H(t))
|
|
811
811
|
throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);
|
|
812
|
-
const n = new
|
|
813
|
-
return
|
|
812
|
+
const n = new at(t.spring);
|
|
813
|
+
return ae(t, (r) => n.valueAt(r), n.settleTime(), t.spring.from, t.spring.to, e);
|
|
814
814
|
}
|
|
815
|
-
function
|
|
816
|
-
if (!
|
|
815
|
+
function ie(t, e = {}) {
|
|
816
|
+
if (!V(t))
|
|
817
817
|
throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);
|
|
818
818
|
const n = t.inertia;
|
|
819
|
-
return
|
|
819
|
+
return ae(
|
|
820
820
|
t,
|
|
821
|
-
(
|
|
822
|
-
|
|
821
|
+
(r) => bt(n, r),
|
|
822
|
+
ut(n),
|
|
823
823
|
n.from,
|
|
824
|
-
|
|
824
|
+
ct(n),
|
|
825
825
|
e
|
|
826
826
|
);
|
|
827
827
|
}
|
|
828
|
-
function
|
|
829
|
-
const a = i.intervalMs ??
|
|
828
|
+
function ae(t, e, n, r, s, i) {
|
|
829
|
+
const a = i.intervalMs ?? re, o = i.tolerance ?? 0.01, c = t.delay ?? 0, u = [];
|
|
830
830
|
for (let h = 0; h <= n; h += a)
|
|
831
831
|
u.push({ time: h + c, value: e(h), easing: "linear" });
|
|
832
832
|
const l = u[u.length - 1];
|
|
833
|
-
return !l || l.time < n + c ? u.push({ time: n + c, value:
|
|
833
|
+
return !l || l.time < n + c ? u.push({ time: n + c, value: s, easing: "linear" }) : l.value = s, c > 0 && u.unshift({ time: 0, value: r, easing: "linear" }), {
|
|
834
834
|
id: t.id,
|
|
835
835
|
target: t.target,
|
|
836
836
|
property: t.property,
|
|
837
|
-
keyframes: o > 0 ?
|
|
837
|
+
keyframes: o > 0 ? mn(u, o) : u,
|
|
838
838
|
...t.targets && { targets: [...t.targets] },
|
|
839
839
|
...t.stagger && { stagger: { ...t.stagger } }
|
|
840
840
|
};
|
|
841
841
|
}
|
|
842
|
-
function
|
|
843
|
-
const
|
|
842
|
+
function dn(t, e, n, r = {}) {
|
|
843
|
+
const s = r.intervalMs ?? re, i = typeof n == "function" ? n : Jt(n), a = ne(t.value), o = e.time - t.time;
|
|
844
844
|
if (o <= 0) return [e];
|
|
845
845
|
const c = [];
|
|
846
|
-
for (let l =
|
|
846
|
+
for (let l = s; l < o; l += s) {
|
|
847
847
|
const h = l / o;
|
|
848
848
|
c.push({
|
|
849
849
|
time: t.time + l,
|
|
@@ -854,55 +854,55 @@ function ln(t, e, n, s = {}) {
|
|
|
854
854
|
const u = i(1);
|
|
855
855
|
return c.push({ ...e, ...u !== 1 && { value: a(t.value, e.value, u) }, easing: "linear" }), c;
|
|
856
856
|
}
|
|
857
|
-
function
|
|
858
|
-
return
|
|
857
|
+
function Jn(t, e) {
|
|
858
|
+
return H(t) ? se(t, e) : V(t) ? ie(t, e) : t;
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function gn(t, e = {}) {
|
|
861
861
|
const n = t.keyframes;
|
|
862
|
-
if (!n.some((
|
|
863
|
-
const
|
|
864
|
-
for (let
|
|
865
|
-
const i = n[
|
|
866
|
-
|
|
867
|
-
}
|
|
868
|
-
return { ...t, keyframes:
|
|
869
|
-
}
|
|
870
|
-
function
|
|
871
|
-
return t.filter(
|
|
872
|
-
t.filter(
|
|
873
|
-
t.filter(
|
|
862
|
+
if (!n.some((s) => Mt(s.easing))) return t;
|
|
863
|
+
const r = n.length > 0 ? [n[0]] : [];
|
|
864
|
+
for (let s = 1; s < n.length; s++) {
|
|
865
|
+
const i = n[s];
|
|
866
|
+
Mt(i.easing) ? r.push(...dn(n[s - 1], i, i.easing, e)) : r.push(i);
|
|
867
|
+
}
|
|
868
|
+
return { ...t, keyframes: r };
|
|
869
|
+
}
|
|
870
|
+
function tr(t, e) {
|
|
871
|
+
return t.filter(Me).map((n) => gn(n, e)).concat(
|
|
872
|
+
t.filter(H).map((n) => se(n, e)),
|
|
873
|
+
t.filter(V).map((n) => ie(n, e))
|
|
874
874
|
);
|
|
875
875
|
}
|
|
876
|
-
function
|
|
876
|
+
function mn(t, e) {
|
|
877
877
|
if (t.length <= 2) return t;
|
|
878
878
|
const n = [t[0]];
|
|
879
|
-
for (let
|
|
880
|
-
const
|
|
879
|
+
for (let r = 1; r < t.length - 1; r++) {
|
|
880
|
+
const s = n[n.length - 1], i = t[r], a = t[r + 1], o = a.time - s.time;
|
|
881
881
|
if (o <= 0) continue;
|
|
882
|
-
const c = (i.time -
|
|
882
|
+
const c = (i.time - s.time) / o, u = s.value + (a.value - s.value) * c;
|
|
883
883
|
Math.abs(i.value - u) > e && n.push(i);
|
|
884
884
|
}
|
|
885
885
|
return n.push(t[t.length - 1]), n;
|
|
886
886
|
}
|
|
887
|
-
function
|
|
888
|
-
const e = [...t.keyframes].sort((n,
|
|
887
|
+
function yn(t) {
|
|
888
|
+
const e = [...t.keyframes].sort((n, r) => n.time - r.time);
|
|
889
889
|
return {
|
|
890
890
|
...t,
|
|
891
891
|
keyframes: e
|
|
892
892
|
};
|
|
893
893
|
}
|
|
894
|
-
function
|
|
894
|
+
function U(t) {
|
|
895
895
|
return t.targets && t.targets.length > 0 ? t.targets : [t.target];
|
|
896
896
|
}
|
|
897
|
-
function
|
|
898
|
-
const
|
|
899
|
-
return !
|
|
897
|
+
function j(t, e, n, r) {
|
|
898
|
+
const s = n ?? 0;
|
|
899
|
+
return !r || e <= 1 ? s : s + jt(t, e, r);
|
|
900
900
|
}
|
|
901
|
-
class
|
|
901
|
+
class mt {
|
|
902
902
|
track;
|
|
903
903
|
targets;
|
|
904
904
|
constructor(e) {
|
|
905
|
-
this.track = e, this.targets =
|
|
905
|
+
this.track = e, this.targets = U(e);
|
|
906
906
|
}
|
|
907
907
|
/**
|
|
908
908
|
* Get the interpolated value at a specific time.
|
|
@@ -911,7 +911,7 @@ class gt {
|
|
|
911
911
|
* that need every target should use `getTargetValues`.
|
|
912
912
|
*/
|
|
913
913
|
getValueAtTime(e) {
|
|
914
|
-
return this.valueForOffset(e -
|
|
914
|
+
return this.valueForOffset(e - j(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
915
915
|
}
|
|
916
916
|
/**
|
|
917
917
|
* Every target's value at a specific time, in target order.
|
|
@@ -920,12 +920,12 @@ class gt {
|
|
|
920
920
|
* each sampled at its own offset time.
|
|
921
921
|
*/
|
|
922
922
|
getTargetValues(e) {
|
|
923
|
-
const n = this.targets.length,
|
|
924
|
-
for (let
|
|
925
|
-
const i =
|
|
926
|
-
a !== void 0 &&
|
|
923
|
+
const n = this.targets.length, r = [];
|
|
924
|
+
for (let s = 0; s < n; s++) {
|
|
925
|
+
const i = j(s, n, this.track.delay, this.track.stagger), a = this.valueForOffset(e - i);
|
|
926
|
+
a !== void 0 && r.push({ target: this.targets[s], value: a, start: i + this.track.keyframes[0].time });
|
|
927
927
|
}
|
|
928
|
-
return
|
|
928
|
+
return r;
|
|
929
929
|
}
|
|
930
930
|
/**
|
|
931
931
|
* Get the duration of this track — the last keyframe, plus any delay, the
|
|
@@ -935,8 +935,8 @@ class gt {
|
|
|
935
935
|
const { keyframes: e } = this.track;
|
|
936
936
|
if (e.length === 0)
|
|
937
937
|
return 0;
|
|
938
|
-
const n = e[e.length - 1].time,
|
|
939
|
-
return n + (this.track.delay ?? 0) +
|
|
938
|
+
const n = e[e.length - 1].time, r = this.track.stagger ? vt(this.targets.length, this.track.stagger) : 0;
|
|
939
|
+
return n + (this.track.delay ?? 0) + r + (this.track.endDelay ?? 0);
|
|
940
940
|
}
|
|
941
941
|
/**
|
|
942
942
|
* Get the track metadata.
|
|
@@ -953,126 +953,126 @@ class gt {
|
|
|
953
953
|
return n[0].value;
|
|
954
954
|
if (e >= n[n.length - 1].time)
|
|
955
955
|
return n[n.length - 1].value;
|
|
956
|
-
const { from:
|
|
957
|
-
if (!
|
|
956
|
+
const { from: r, to: s } = this.findSurroundingKeyframes(e);
|
|
957
|
+
if (!r || !s)
|
|
958
958
|
return;
|
|
959
|
-
if (
|
|
960
|
-
return
|
|
961
|
-
const i =
|
|
962
|
-
return
|
|
959
|
+
if (r.time === e)
|
|
960
|
+
return r.value;
|
|
961
|
+
const i = s.time - r.time, a = (e - r.time) / i, c = Jt(s.easing)(a);
|
|
962
|
+
return ne(r.value)(r.value, s.value, c);
|
|
963
963
|
}
|
|
964
964
|
/**
|
|
965
965
|
* Find the keyframes surrounding a given time.
|
|
966
966
|
*/
|
|
967
967
|
findSurroundingKeyframes(e) {
|
|
968
968
|
const { keyframes: n } = this.track;
|
|
969
|
-
for (let
|
|
970
|
-
if (e >= n[
|
|
971
|
-
return { from: n[
|
|
969
|
+
for (let r = 0; r < n.length - 1; r++)
|
|
970
|
+
if (e >= n[r].time && e <= n[r + 1].time)
|
|
971
|
+
return { from: n[r], to: n[r + 1] };
|
|
972
972
|
return { from: null, to: null };
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
|
-
class
|
|
975
|
+
class _n {
|
|
976
976
|
track;
|
|
977
977
|
targets;
|
|
978
978
|
sampler;
|
|
979
979
|
constructor(e) {
|
|
980
|
-
this.track = e, this.targets =
|
|
980
|
+
this.track = e, this.targets = U(e), this.sampler = new at(e.spring);
|
|
981
981
|
}
|
|
982
982
|
getValueAtTime(e) {
|
|
983
|
-
return this.sampler.valueAt(e -
|
|
983
|
+
return this.sampler.valueAt(e - j(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
984
984
|
}
|
|
985
985
|
getTargetValues(e) {
|
|
986
|
-
const n = this.targets.length,
|
|
987
|
-
for (let
|
|
988
|
-
const i =
|
|
989
|
-
|
|
986
|
+
const n = this.targets.length, r = [];
|
|
987
|
+
for (let s = 0; s < n; s++) {
|
|
988
|
+
const i = j(s, n, this.track.delay, this.track.stagger);
|
|
989
|
+
r.push({ target: this.targets[s], value: this.sampler.valueAt(e - i), start: i });
|
|
990
990
|
}
|
|
991
|
-
return
|
|
991
|
+
return r;
|
|
992
992
|
}
|
|
993
993
|
/** Settle time plus delay and the widest stagger offset. */
|
|
994
994
|
getDuration() {
|
|
995
|
-
const e = this.track.stagger ?
|
|
995
|
+
const e = this.track.stagger ? vt(this.targets.length, this.track.stagger) : 0;
|
|
996
996
|
return this.sampler.settleTime() + (this.track.delay ?? 0) + e;
|
|
997
997
|
}
|
|
998
998
|
getTrack() {
|
|
999
999
|
return this.track;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
class
|
|
1002
|
+
class Mn {
|
|
1003
1003
|
track;
|
|
1004
1004
|
targets;
|
|
1005
1005
|
duration;
|
|
1006
1006
|
constructor(e) {
|
|
1007
|
-
this.track = e, this.targets =
|
|
1007
|
+
this.track = e, this.targets = U(e), this.duration = ut(e.inertia);
|
|
1008
1008
|
}
|
|
1009
1009
|
getValueAtTime(e) {
|
|
1010
|
-
return
|
|
1010
|
+
return bt(this.track.inertia, e - j(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
1011
1011
|
}
|
|
1012
1012
|
getTargetValues(e) {
|
|
1013
|
-
const n = this.targets.length,
|
|
1014
|
-
for (let
|
|
1015
|
-
const i =
|
|
1016
|
-
|
|
1013
|
+
const n = this.targets.length, r = [];
|
|
1014
|
+
for (let s = 0; s < n; s++) {
|
|
1015
|
+
const i = j(s, n, this.track.delay, this.track.stagger);
|
|
1016
|
+
r.push({ target: this.targets[s], value: bt(this.track.inertia, e - i), start: i });
|
|
1017
1017
|
}
|
|
1018
|
-
return
|
|
1018
|
+
return r;
|
|
1019
1019
|
}
|
|
1020
1020
|
/** Settle time plus delay and the widest stagger offset. */
|
|
1021
1021
|
getDuration() {
|
|
1022
|
-
const e = this.track.stagger ?
|
|
1022
|
+
const e = this.track.stagger ? vt(this.targets.length, this.track.stagger) : 0;
|
|
1023
1023
|
return this.duration + (this.track.delay ?? 0) + e;
|
|
1024
1024
|
}
|
|
1025
1025
|
getTrack() {
|
|
1026
1026
|
return this.track;
|
|
1027
1027
|
}
|
|
1028
1028
|
}
|
|
1029
|
-
function
|
|
1030
|
-
const n = { ...
|
|
1029
|
+
function oe(t, e) {
|
|
1030
|
+
const n = { ...je(t.pathData, e) };
|
|
1031
1031
|
if (t.matrix) {
|
|
1032
|
-
const [
|
|
1033
|
-
n.x =
|
|
1032
|
+
const [r, s, i, a, o, c] = t.matrix, { x: u, y: l } = n;
|
|
1033
|
+
n.x = r * u + i * l + o, n.y = s * u + a * l + c;
|
|
1034
1034
|
const h = n.angle * Math.PI / 180, p = Math.cos(h), f = Math.sin(h);
|
|
1035
|
-
n.angle = Math.atan2(
|
|
1035
|
+
n.angle = Math.atan2(s * p + a * f, r * p + i * f) * 180 / Math.PI;
|
|
1036
1036
|
}
|
|
1037
1037
|
return t.autoRotate && t.rotateOffset && (n.angle += t.rotateOffset), n;
|
|
1038
1038
|
}
|
|
1039
|
-
function
|
|
1040
|
-
const
|
|
1041
|
-
return
|
|
1039
|
+
function er(t, e, n, r) {
|
|
1040
|
+
const s = e + (n - e) * r;
|
|
1041
|
+
return oe(t, s);
|
|
1042
1042
|
}
|
|
1043
|
-
const
|
|
1043
|
+
const yt = {
|
|
1044
1044
|
upperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
1045
1045
|
lowerCase: "abcdefghijklmnopqrstuvwxyz",
|
|
1046
1046
|
upperAndLowerCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
1047
1047
|
numbers: "0123456789"
|
|
1048
|
-
},
|
|
1049
|
-
function
|
|
1050
|
-
const e =
|
|
1051
|
-
return n.length > 0 ? n : Array.from(
|
|
1052
|
-
}
|
|
1053
|
-
function
|
|
1054
|
-
let
|
|
1055
|
-
return
|
|
1056
|
-
}
|
|
1057
|
-
function
|
|
1058
|
-
const
|
|
1059
|
-
if (i <= 0) return
|
|
1060
|
-
if (i >= 1) return
|
|
1061
|
-
const a = Array.from(
|
|
1048
|
+
}, bn = 20;
|
|
1049
|
+
function Tn(t) {
|
|
1050
|
+
const e = yt[t ?? "upperCase"] ?? t ?? yt.upperCase, n = Array.from(e);
|
|
1051
|
+
return n.length > 0 ? n : Array.from(yt.upperCase);
|
|
1052
|
+
}
|
|
1053
|
+
function xn(t, e, n) {
|
|
1054
|
+
let r = (t | 0) ^ Math.imul(e + 1, 2654435761) ^ Math.imul(n + 1, 2246822507);
|
|
1055
|
+
return r = Math.imul(r ^ r >>> 16, 2146121005), r = Math.imul(r ^ r >>> 15, 2221713035), (r ^ r >>> 16) >>> 0;
|
|
1056
|
+
}
|
|
1057
|
+
function kn(t, e, n = 0) {
|
|
1058
|
+
const r = t.from ?? "", s = t.to, i = Math.max(0, Math.min(1, e));
|
|
1059
|
+
if (i <= 0) return r;
|
|
1060
|
+
if (i >= 1) return s;
|
|
1061
|
+
const a = Array.from(r), o = Array.from(s), c = t.rightToLeft ?? !1;
|
|
1062
1062
|
if (t.mode === "type") {
|
|
1063
|
-
const
|
|
1064
|
-
return c ? a.slice(0, Math.max(0, a.length -
|
|
1063
|
+
const b = Math.round(i * Math.max(a.length, o.length));
|
|
1064
|
+
return c ? a.slice(0, Math.max(0, a.length - b)).join("") + o.slice(Math.max(0, o.length - b)).join("") : o.slice(0, b).join("") + a.slice(b).join("");
|
|
1065
1065
|
}
|
|
1066
|
-
const u = Math.max(0, Math.min(0.999, t.revealDelay ?? 0)), l = Math.max(0, (i - u) / (1 - u)), h = Math.floor(l * o.length), p = t.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * i), f =
|
|
1067
|
-
let
|
|
1068
|
-
for (let
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
` ?
|
|
1066
|
+
const u = Math.max(0, Math.min(0.999, t.revealDelay ?? 0)), l = Math.max(0, (i - u) / (1 - u)), h = Math.floor(l * o.length), p = t.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * i), f = Tn(t.chars), _ = t.refreshRate ?? bn, d = _ > 0 ? Math.floor(n * _ / 1e3) : 0, g = t.seed ?? 1;
|
|
1067
|
+
let M = "";
|
|
1068
|
+
for (let b = 0; b < p; b++) {
|
|
1069
|
+
const k = c ? b >= p - h : b < h, A = c ? o[o.length - (p - b)] : o[b];
|
|
1070
|
+
k && A !== void 0 || A === " " || A === `
|
|
1071
|
+
` ? M += A : M += f[xn(g, b, d) % f.length];
|
|
1072
1072
|
}
|
|
1073
|
-
return
|
|
1073
|
+
return M;
|
|
1074
1074
|
}
|
|
1075
|
-
class
|
|
1075
|
+
class vn {
|
|
1076
1076
|
id;
|
|
1077
1077
|
name;
|
|
1078
1078
|
_captions;
|
|
@@ -1185,31 +1185,31 @@ class Tn {
|
|
|
1185
1185
|
const n = this.duration;
|
|
1186
1186
|
if (n <= 0)
|
|
1187
1187
|
return;
|
|
1188
|
-
let
|
|
1188
|
+
let s = e * this.speed;
|
|
1189
1189
|
if (this._repeatDelayRemaining > 0) {
|
|
1190
|
-
const o = Math.min(this._repeatDelayRemaining,
|
|
1191
|
-
if (this._repeatDelayRemaining -= o,
|
|
1190
|
+
const o = Math.min(this._repeatDelayRemaining, s);
|
|
1191
|
+
if (this._repeatDelayRemaining -= o, s -= o, this._repeatDelayRemaining > 0) {
|
|
1192
1192
|
this.onUpdate?.(this.getStateAtTime(this._currentTime));
|
|
1193
1193
|
return;
|
|
1194
1194
|
}
|
|
1195
1195
|
this._wrapAfterDelay && (this._wrapAfterDelay = !1, this._currentTime = 0);
|
|
1196
1196
|
}
|
|
1197
1197
|
const i = 1e3;
|
|
1198
|
-
for (let o = 0; o < i &&
|
|
1198
|
+
for (let o = 0; o < i && s > 0 && this._playbackState === "playing"; o++)
|
|
1199
1199
|
if (this._direction === "forward") {
|
|
1200
1200
|
const c = n - this._currentTime;
|
|
1201
|
-
if (
|
|
1202
|
-
if (
|
|
1201
|
+
if (s >= c) {
|
|
1202
|
+
if (s -= c, this._currentTime = n, !this._handleEndReached())
|
|
1203
1203
|
break;
|
|
1204
1204
|
} else
|
|
1205
|
-
this._currentTime +=
|
|
1205
|
+
this._currentTime += s, s = 0;
|
|
1206
1206
|
} else {
|
|
1207
1207
|
const c = this._currentTime;
|
|
1208
|
-
if (
|
|
1209
|
-
if (
|
|
1208
|
+
if (s >= c) {
|
|
1209
|
+
if (s -= c, this._currentTime = 0, !this._handleStartReached())
|
|
1210
1210
|
break;
|
|
1211
1211
|
} else
|
|
1212
|
-
this._currentTime -=
|
|
1212
|
+
this._currentTime -= s, s = 0;
|
|
1213
1213
|
}
|
|
1214
1214
|
const a = this.getStateAtTime(this._currentTime);
|
|
1215
1215
|
this.onUpdate?.(a);
|
|
@@ -1222,10 +1222,10 @@ class Tn {
|
|
|
1222
1222
|
if (this._hasSharedWrites())
|
|
1223
1223
|
this._resolveShared(e, n);
|
|
1224
1224
|
else
|
|
1225
|
-
for (const [
|
|
1226
|
-
const i =
|
|
1227
|
-
for (const { target: a, value: o, start: c } of
|
|
1228
|
-
this._write(n,
|
|
1225
|
+
for (const [r, s] of this._trackPlayers) {
|
|
1226
|
+
const i = s.getTrack().property;
|
|
1227
|
+
for (const { target: a, value: o, start: c } of s.getTargetValues(e))
|
|
1228
|
+
this._write(n, r, a, i, o, e - c);
|
|
1229
1229
|
}
|
|
1230
1230
|
return {
|
|
1231
1231
|
values: n,
|
|
@@ -1249,37 +1249,37 @@ class Tn {
|
|
|
1249
1249
|
* turn. `findConflicts()` reports overlaps by the same rule.
|
|
1250
1250
|
*/
|
|
1251
1251
|
_resolveShared(e, n) {
|
|
1252
|
-
const
|
|
1253
|
-
for (const [
|
|
1252
|
+
const r = /* @__PURE__ */ new Map();
|
|
1253
|
+
for (const [s, i] of this._trackPlayers) {
|
|
1254
1254
|
const a = i.getTrack().property;
|
|
1255
1255
|
for (const { target: o, value: c, start: u } of i.getTargetValues(e)) {
|
|
1256
|
-
const l = `${o}\0${a}`, h = u <= e, p =
|
|
1257
|
-
(!p || (h !== p.started ? h : h ? u >= p.start : u <= p.start)) &&
|
|
1256
|
+
const l = `${o}\0${a}`, h = u <= e, p = r.get(l);
|
|
1257
|
+
(!p || (h !== p.started ? h : h ? u >= p.start : u <= p.start)) && r.set(l, { trackId: s, target: o, property: a, value: c, start: u, started: h });
|
|
1258
1258
|
}
|
|
1259
1259
|
}
|
|
1260
|
-
for (const { trackId:
|
|
1261
|
-
this._write(n,
|
|
1260
|
+
for (const { trackId: s, target: i, property: a, value: o, start: c } of r.values())
|
|
1261
|
+
this._write(n, s, i, a, o, e - c);
|
|
1262
1262
|
}
|
|
1263
1263
|
/**
|
|
1264
1264
|
* Write one track's value for a target, expanding the progress of motion paths
|
|
1265
1265
|
* (into x/y/rotation) and text tracks (into the string). `elapsed` is the time
|
|
1266
1266
|
* since this target's animation on the track started.
|
|
1267
1267
|
*/
|
|
1268
|
-
_write(e, n,
|
|
1268
|
+
_write(e, n, r, s, i, a) {
|
|
1269
1269
|
if (i === void 0) return;
|
|
1270
|
-
let o = e.get(
|
|
1271
|
-
o || (o = /* @__PURE__ */ new Map(), e.set(
|
|
1270
|
+
let o = e.get(r);
|
|
1271
|
+
o || (o = /* @__PURE__ */ new Map(), e.set(r, o));
|
|
1272
1272
|
const c = this._textTracks.get(n);
|
|
1273
1273
|
if (c && typeof i == "number") {
|
|
1274
|
-
o.set("text",
|
|
1274
|
+
o.set("text", kn(c.textConfig, i, Math.max(0, a)));
|
|
1275
1275
|
return;
|
|
1276
1276
|
}
|
|
1277
1277
|
const u = this._motionPathTracks.get(n);
|
|
1278
1278
|
if (u && typeof i == "number") {
|
|
1279
|
-
const l =
|
|
1279
|
+
const l = oe(u.motionPathConfig, i);
|
|
1280
1280
|
o.set("motionPathX", l.x), o.set("motionPathY", l.y), u.motionPathConfig.autoRotate && o.set("motionPathRotate", l.angle);
|
|
1281
1281
|
} else
|
|
1282
|
-
o.set(
|
|
1282
|
+
o.set(s, i);
|
|
1283
1283
|
}
|
|
1284
1284
|
/** Cached: does any target+property have more than one track? */
|
|
1285
1285
|
_sharedWrites = null;
|
|
@@ -1288,13 +1288,13 @@ class Tn {
|
|
|
1288
1288
|
const e = /* @__PURE__ */ new Set();
|
|
1289
1289
|
this._sharedWrites = !1;
|
|
1290
1290
|
t: for (const n of this._tracks)
|
|
1291
|
-
for (const
|
|
1292
|
-
const
|
|
1293
|
-
if (e.has(
|
|
1291
|
+
for (const r of U(n)) {
|
|
1292
|
+
const s = `${r}\0${n.property}`;
|
|
1293
|
+
if (e.has(s)) {
|
|
1294
1294
|
this._sharedWrites = !0;
|
|
1295
1295
|
break t;
|
|
1296
1296
|
}
|
|
1297
|
-
e.add(
|
|
1297
|
+
e.add(s);
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
1300
|
return this._sharedWrites;
|
|
@@ -1303,17 +1303,17 @@ class Tn {
|
|
|
1303
1303
|
* Add a track to the timeline.
|
|
1304
1304
|
*/
|
|
1305
1305
|
addTrack(e) {
|
|
1306
|
-
if (this._tracks.push(e), this._sharedWrites = null,
|
|
1307
|
-
this._trackPlayers.set(e.id, new
|
|
1306
|
+
if (this._tracks.push(e), this._sharedWrites = null, V(e)) {
|
|
1307
|
+
this._trackPlayers.set(e.id, new Mn(e));
|
|
1308
1308
|
return;
|
|
1309
1309
|
}
|
|
1310
|
-
if (
|
|
1311
|
-
this._trackPlayers.set(e.id, new
|
|
1310
|
+
if (H(e)) {
|
|
1311
|
+
this._trackPlayers.set(e.id, new _n(e)), this._springTracks.set(e.id, e);
|
|
1312
1312
|
return;
|
|
1313
1313
|
}
|
|
1314
1314
|
if (kt(e))
|
|
1315
|
-
this._trackPlayers.set(e.id, new
|
|
1316
|
-
else if (
|
|
1315
|
+
this._trackPlayers.set(e.id, new mt(e)), this._textTracks.set(e.id, e);
|
|
1316
|
+
else if (qt(e)) {
|
|
1317
1317
|
const n = {
|
|
1318
1318
|
id: e.id,
|
|
1319
1319
|
target: e.target,
|
|
@@ -1324,9 +1324,9 @@ class Tn {
|
|
|
1324
1324
|
targets: e.targets,
|
|
1325
1325
|
stagger: e.stagger
|
|
1326
1326
|
};
|
|
1327
|
-
this._trackPlayers.set(e.id, new
|
|
1327
|
+
this._trackPlayers.set(e.id, new mt(n)), this._motionPathTracks.set(e.id, e);
|
|
1328
1328
|
} else
|
|
1329
|
-
this._trackPlayers.set(e.id, new
|
|
1329
|
+
this._trackPlayers.set(e.id, new mt(e));
|
|
1330
1330
|
}
|
|
1331
1331
|
/**
|
|
1332
1332
|
* Replace a track with a new version, keeping its place in the track order
|
|
@@ -1334,13 +1334,13 @@ class Tn {
|
|
|
1334
1334
|
* different id. Does nothing if no track has `trackId`.
|
|
1335
1335
|
*/
|
|
1336
1336
|
replaceTrack(e, n) {
|
|
1337
|
-
const
|
|
1338
|
-
if (
|
|
1339
|
-
const
|
|
1337
|
+
const r = this._tracks.findIndex((i) => i.id === e);
|
|
1338
|
+
if (r < 0) return;
|
|
1339
|
+
const s = this._tracks.slice(r + 1);
|
|
1340
1340
|
this.removeTrack(e);
|
|
1341
|
-
for (const i of
|
|
1341
|
+
for (const i of s) this.removeTrack(i.id);
|
|
1342
1342
|
this.addTrack(n);
|
|
1343
|
-
for (const i of
|
|
1343
|
+
for (const i of s) this.addTrack(i);
|
|
1344
1344
|
}
|
|
1345
1345
|
/**
|
|
1346
1346
|
* Remove a track by its ID.
|
|
@@ -1365,9 +1365,9 @@ class Tn {
|
|
|
1365
1365
|
* tweens on an element.
|
|
1366
1366
|
*/
|
|
1367
1367
|
removeTracks(e = {}) {
|
|
1368
|
-
const n = this.getTracks(e).map((
|
|
1369
|
-
for (const
|
|
1370
|
-
this.removeTrack(
|
|
1368
|
+
const n = this.getTracks(e).map((r) => r.id);
|
|
1369
|
+
for (const r of n)
|
|
1370
|
+
this.removeTrack(r);
|
|
1371
1371
|
return n;
|
|
1372
1372
|
}
|
|
1373
1373
|
/**
|
|
@@ -1376,12 +1376,12 @@ class Tn {
|
|
|
1376
1376
|
getTrackSpan(e) {
|
|
1377
1377
|
const n = this._trackPlayers.get(e);
|
|
1378
1378
|
if (!n) return;
|
|
1379
|
-
const
|
|
1380
|
-
if (
|
|
1381
|
-
return { from:
|
|
1382
|
-
const i =
|
|
1379
|
+
const r = n.getTrack(), s = r.delay ?? 0;
|
|
1380
|
+
if (H(r) || V(r))
|
|
1381
|
+
return { from: s, to: n.getDuration() };
|
|
1382
|
+
const i = r.keyframes;
|
|
1383
1383
|
if (!(!i || i.length === 0))
|
|
1384
|
-
return { from: i[0].time +
|
|
1384
|
+
return { from: i[0].time + s, to: n.getDuration() };
|
|
1385
1385
|
}
|
|
1386
1386
|
/**
|
|
1387
1387
|
* Overlapping writes to the same target+property.
|
|
@@ -1394,32 +1394,32 @@ class Tn {
|
|
|
1394
1394
|
findConflicts() {
|
|
1395
1395
|
const e = [];
|
|
1396
1396
|
for (let n = 0; n < this._tracks.length; n++) {
|
|
1397
|
-
const
|
|
1398
|
-
if (
|
|
1397
|
+
const r = this._tracks[n], s = this.getTrackSpan(r.id);
|
|
1398
|
+
if (s)
|
|
1399
1399
|
for (let i = 0; i < n; i++) {
|
|
1400
1400
|
const a = this._tracks[i];
|
|
1401
|
-
if (a.property !==
|
|
1402
|
-
const o =
|
|
1401
|
+
if (a.property !== r.property) continue;
|
|
1402
|
+
const o = U(a).filter((h) => U(r).includes(h));
|
|
1403
1403
|
if (o.length === 0) continue;
|
|
1404
1404
|
const c = this.getTrackSpan(a.id);
|
|
1405
|
-
if (!c || !(c.from <=
|
|
1406
|
-
const l =
|
|
1405
|
+
if (!c || !(c.from <= s.to && s.from <= c.to)) continue;
|
|
1406
|
+
const l = s.from >= c.from;
|
|
1407
1407
|
for (const h of o)
|
|
1408
1408
|
e.push({
|
|
1409
1409
|
target: h,
|
|
1410
|
-
property:
|
|
1411
|
-
losingTrackId: l ? a.id :
|
|
1412
|
-
winningTrackId: l ?
|
|
1410
|
+
property: r.property,
|
|
1411
|
+
losingTrackId: l ? a.id : r.id,
|
|
1412
|
+
winningTrackId: l ? r.id : a.id
|
|
1413
1413
|
});
|
|
1414
1414
|
}
|
|
1415
1415
|
}
|
|
1416
1416
|
return e;
|
|
1417
1417
|
}
|
|
1418
1418
|
_matches(e, n) {
|
|
1419
|
-
if (n.id !== void 0 && e.id !== n.id || n.property !== void 0 && e.property !== n.property || n.target !== void 0 && !
|
|
1419
|
+
if (n.id !== void 0 && e.id !== n.id || n.property !== void 0 && e.property !== n.property || n.target !== void 0 && !U(e).includes(n.target)) return !1;
|
|
1420
1420
|
if (n.timeRange) {
|
|
1421
|
-
const
|
|
1422
|
-
if (!
|
|
1421
|
+
const r = this.getTrackSpan(e.id);
|
|
1422
|
+
if (!r || r.to < n.timeRange.from || r.from > n.timeRange.to) return !1;
|
|
1423
1423
|
}
|
|
1424
1424
|
return !0;
|
|
1425
1425
|
}
|
|
@@ -1428,7 +1428,7 @@ class Tn {
|
|
|
1428
1428
|
*/
|
|
1429
1429
|
toDefinition() {
|
|
1430
1430
|
return {
|
|
1431
|
-
formatVersion:
|
|
1431
|
+
formatVersion: it,
|
|
1432
1432
|
id: this.id,
|
|
1433
1433
|
name: this.name,
|
|
1434
1434
|
config: { ...this._config },
|
|
@@ -1446,8 +1446,8 @@ class Tn {
|
|
|
1446
1446
|
}
|
|
1447
1447
|
/** Replace the markers (kept in time order); an empty list removes them. */
|
|
1448
1448
|
setMarkers(e) {
|
|
1449
|
-
const n = e && e.length > 0 ? [...e].sort((
|
|
1450
|
-
n ?
|
|
1449
|
+
const n = e && e.length > 0 ? [...e].sort((s, i) => s.time - i.time).map((s) => ({ ...s })) : void 0, r = { ...this._config };
|
|
1450
|
+
n ? r.markers = n : delete r.markers, this._config = r;
|
|
1451
1451
|
}
|
|
1452
1452
|
/** Caption text per language, per marker id */
|
|
1453
1453
|
get captions() {
|
|
@@ -1456,7 +1456,7 @@ class Tn {
|
|
|
1456
1456
|
/** Replace the captions; languages with no captions are dropped. */
|
|
1457
1457
|
setCaptions(e) {
|
|
1458
1458
|
const n = {};
|
|
1459
|
-
for (const [
|
|
1459
|
+
for (const [r, s] of Object.entries(e ?? {})) n[r] = { ...s };
|
|
1460
1460
|
this._captions = Object.keys(n).length > 0 ? n : void 0;
|
|
1461
1461
|
}
|
|
1462
1462
|
/** Start the between-iterations pause, if the timeline configures one. */
|
|
@@ -1486,72 +1486,72 @@ class Tn {
|
|
|
1486
1486
|
return this._config.alternate && (e === -1 || this._loopIteration < e) ? (this._loopIteration++, this._armRepeatDelay(), this._direction = "forward", this._repeatDelayRemaining === 0) : (this._playbackState = "idle", this.onComplete?.(), !1);
|
|
1487
1487
|
}
|
|
1488
1488
|
}
|
|
1489
|
-
const
|
|
1490
|
-
function
|
|
1491
|
-
const
|
|
1492
|
-
i.push([f,
|
|
1493
|
-
const
|
|
1494
|
-
t.forEach((
|
|
1495
|
-
(d === "forward" ? (g ?
|
|
1496
|
-
}),
|
|
1497
|
-
for (const
|
|
1489
|
+
const Sn = 100;
|
|
1490
|
+
function nr(t, e, n, r) {
|
|
1491
|
+
const s = [], i = [], { duration: a, alternate: o } = r, c = (f, _, d, g) => {
|
|
1492
|
+
i.push([f, _]);
|
|
1493
|
+
const M = [];
|
|
1494
|
+
t.forEach((b, k) => {
|
|
1495
|
+
(d === "forward" ? (g ? b >= f : b > f) && b <= _ : (g ? b <= f : b < f) && b >= _) && M.push(k);
|
|
1496
|
+
}), M.sort((b, k) => (d === "forward" ? t[b] - t[k] : t[k] - t[b]) || b - k);
|
|
1497
|
+
for (const b of M) s.push({ kind: "event", index: b, direction: d });
|
|
1498
1498
|
};
|
|
1499
1499
|
let u = e.time, l = e.direction, h = e.fresh === !0;
|
|
1500
|
-
const p = Math.min(
|
|
1500
|
+
const p = Math.min(Sn, Math.max(0, n.iteration - e.iteration));
|
|
1501
1501
|
for (let f = 0; f < p; f++) {
|
|
1502
|
-
const
|
|
1503
|
-
c(u,
|
|
1502
|
+
const _ = l === "forward" ? a : 0;
|
|
1503
|
+
c(u, _, l, h), s.push({ kind: "repeat" }), o ? (l = l === "forward" ? "reverse" : "forward", u = _, h = !1) : (u = l === "forward" ? 0 : a, h = !0);
|
|
1504
1504
|
}
|
|
1505
|
-
return p > 0 &&
|
|
1505
|
+
return p > 0 && r.holding && !o ? { crossings: s, passes: i } : (c(u, n.time, l, h), { crossings: s, passes: i });
|
|
1506
1506
|
}
|
|
1507
|
-
function
|
|
1508
|
-
return
|
|
1507
|
+
function An(t) {
|
|
1508
|
+
return V(t) ? {
|
|
1509
1509
|
id: t.id,
|
|
1510
1510
|
target: t.target,
|
|
1511
1511
|
property: t.property,
|
|
1512
1512
|
kind: "inertia",
|
|
1513
|
-
inertia:
|
|
1514
|
-
...
|
|
1515
|
-
} :
|
|
1513
|
+
inertia: ce(t.inertia),
|
|
1514
|
+
...F(t)
|
|
1515
|
+
} : H(t) ? {
|
|
1516
1516
|
id: t.id,
|
|
1517
1517
|
target: t.target,
|
|
1518
1518
|
property: t.property,
|
|
1519
1519
|
kind: "spring",
|
|
1520
1520
|
spring: { ...t.spring },
|
|
1521
|
-
...
|
|
1521
|
+
...F(t)
|
|
1522
1522
|
} : kt(t) ? {
|
|
1523
1523
|
id: t.id,
|
|
1524
1524
|
target: t.target,
|
|
1525
1525
|
property: "text",
|
|
1526
1526
|
textConfig: { ...t.textConfig },
|
|
1527
|
-
keyframes: t.keyframes.map(
|
|
1528
|
-
...
|
|
1529
|
-
} :
|
|
1527
|
+
keyframes: t.keyframes.map(_t),
|
|
1528
|
+
...F(t)
|
|
1529
|
+
} : qt(t) ? {
|
|
1530
1530
|
id: t.id,
|
|
1531
1531
|
target: t.target,
|
|
1532
1532
|
property: "motionPath",
|
|
1533
1533
|
motionPathConfig: { ...t.motionPathConfig },
|
|
1534
|
-
keyframes: t.keyframes.map(
|
|
1535
|
-
...
|
|
1534
|
+
keyframes: t.keyframes.map(_t),
|
|
1535
|
+
...F(t)
|
|
1536
1536
|
} : {
|
|
1537
1537
|
id: t.id,
|
|
1538
1538
|
target: t.target,
|
|
1539
1539
|
property: t.property,
|
|
1540
|
-
keyframes: t.keyframes.map(
|
|
1541
|
-
...
|
|
1540
|
+
keyframes: t.keyframes.map(_t),
|
|
1541
|
+
...F(t)
|
|
1542
1542
|
};
|
|
1543
1543
|
}
|
|
1544
|
-
function
|
|
1544
|
+
function ce(t) {
|
|
1545
1545
|
return { ...t, ...Array.isArray(t.end) && { end: [...t.end] } };
|
|
1546
1546
|
}
|
|
1547
|
-
function
|
|
1547
|
+
function _t(t) {
|
|
1548
1548
|
return {
|
|
1549
1549
|
time: t.time,
|
|
1550
1550
|
value: t.value,
|
|
1551
1551
|
...t.easing && { easing: t.easing }
|
|
1552
1552
|
};
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1554
|
+
function F(t) {
|
|
1555
1555
|
const e = t.endDelay;
|
|
1556
1556
|
return {
|
|
1557
1557
|
...t.delay !== void 0 && { delay: t.delay },
|
|
@@ -1560,19 +1560,19 @@ function E(t) {
|
|
|
1560
1560
|
...t.stagger !== void 0 && { stagger: { ...t.stagger } }
|
|
1561
1561
|
};
|
|
1562
1562
|
}
|
|
1563
|
-
function
|
|
1564
|
-
if (
|
|
1563
|
+
function wn(t) {
|
|
1564
|
+
if (V(t)) {
|
|
1565
1565
|
const e = t;
|
|
1566
1566
|
return {
|
|
1567
1567
|
id: e.id,
|
|
1568
1568
|
target: e.target,
|
|
1569
1569
|
property: e.property,
|
|
1570
1570
|
kind: "inertia",
|
|
1571
|
-
inertia:
|
|
1572
|
-
...
|
|
1571
|
+
inertia: ce(e.inertia),
|
|
1572
|
+
...F(e)
|
|
1573
1573
|
};
|
|
1574
1574
|
}
|
|
1575
|
-
if (
|
|
1575
|
+
if (H(t)) {
|
|
1576
1576
|
const e = t;
|
|
1577
1577
|
return {
|
|
1578
1578
|
id: e.id,
|
|
@@ -1580,7 +1580,7 @@ function xn(t) {
|
|
|
1580
1580
|
property: e.property,
|
|
1581
1581
|
kind: "spring",
|
|
1582
1582
|
spring: { ...e.spring },
|
|
1583
|
-
...
|
|
1583
|
+
...F(e)
|
|
1584
1584
|
};
|
|
1585
1585
|
}
|
|
1586
1586
|
if (kt(t)) {
|
|
@@ -1590,33 +1590,33 @@ function xn(t) {
|
|
|
1590
1590
|
target: e.target,
|
|
1591
1591
|
property: "text",
|
|
1592
1592
|
textConfig: { ...e.textConfig },
|
|
1593
|
-
keyframes: [...e.keyframes].sort((n,
|
|
1594
|
-
...
|
|
1593
|
+
keyframes: [...e.keyframes].sort((n, r) => n.time - r.time),
|
|
1594
|
+
...F(e)
|
|
1595
1595
|
};
|
|
1596
1596
|
}
|
|
1597
1597
|
if (t.property === "motionPath" && "motionPathConfig" in t) {
|
|
1598
|
-
const e = t, n = [...e.keyframes].sort((
|
|
1598
|
+
const e = t, n = [...e.keyframes].sort((r, s) => r.time - s.time);
|
|
1599
1599
|
return {
|
|
1600
1600
|
id: e.id,
|
|
1601
1601
|
target: e.target,
|
|
1602
1602
|
property: "motionPath",
|
|
1603
1603
|
motionPathConfig: { ...e.motionPathConfig },
|
|
1604
1604
|
keyframes: n,
|
|
1605
|
-
...
|
|
1605
|
+
...F(e)
|
|
1606
1606
|
};
|
|
1607
1607
|
}
|
|
1608
|
-
return
|
|
1608
|
+
return yn({
|
|
1609
1609
|
id: t.id,
|
|
1610
1610
|
target: t.target,
|
|
1611
1611
|
property: t.property,
|
|
1612
1612
|
keyframes: t.keyframes,
|
|
1613
|
-
...
|
|
1613
|
+
...F(t)
|
|
1614
1614
|
});
|
|
1615
1615
|
}
|
|
1616
|
-
function
|
|
1616
|
+
function Pn(t) {
|
|
1617
1617
|
const e = t._config.markers;
|
|
1618
1618
|
return {
|
|
1619
|
-
formatVersion:
|
|
1619
|
+
formatVersion: it,
|
|
1620
1620
|
id: t.id,
|
|
1621
1621
|
name: t.name,
|
|
1622
1622
|
config: {
|
|
@@ -1627,38 +1627,38 @@ function vn(t) {
|
|
|
1627
1627
|
repeatDelay: t._config.repeatDelay,
|
|
1628
1628
|
...e && { markers: e.map((n) => ({ ...n })) }
|
|
1629
1629
|
},
|
|
1630
|
-
tracks: t.tracks.map(
|
|
1630
|
+
tracks: t.tracks.map(An),
|
|
1631
1631
|
...t.captions && { captions: JSON.parse(JSON.stringify(t.captions)) }
|
|
1632
1632
|
};
|
|
1633
1633
|
}
|
|
1634
|
-
function
|
|
1634
|
+
function $n(t) {
|
|
1635
1635
|
const e = t.formatVersion ?? 1;
|
|
1636
|
-
if (e >
|
|
1636
|
+
if (e > it)
|
|
1637
1637
|
throw new Error(
|
|
1638
|
-
`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${
|
|
1638
|
+
`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${it}. Update tinyfly to play it.`
|
|
1639
1639
|
);
|
|
1640
|
-
return new
|
|
1640
|
+
return new vn({
|
|
1641
1641
|
id: t.id,
|
|
1642
1642
|
name: t.name,
|
|
1643
1643
|
config: t.config,
|
|
1644
|
-
tracks: t.tracks.map(
|
|
1644
|
+
tracks: t.tracks.map(wn),
|
|
1645
1645
|
captions: t.captions
|
|
1646
1646
|
});
|
|
1647
1647
|
}
|
|
1648
|
-
function
|
|
1649
|
-
return JSON.stringify(
|
|
1648
|
+
function rr(t) {
|
|
1649
|
+
return JSON.stringify(Pn(t));
|
|
1650
1650
|
}
|
|
1651
|
-
function
|
|
1651
|
+
function sr(t) {
|
|
1652
1652
|
const e = JSON.parse(t);
|
|
1653
|
-
return
|
|
1653
|
+
return $n(e);
|
|
1654
1654
|
}
|
|
1655
|
-
function
|
|
1655
|
+
function ir(t) {
|
|
1656
1656
|
let e = 2166136261;
|
|
1657
1657
|
for (let n = 0; n < t.length; n++)
|
|
1658
1658
|
e ^= t.charCodeAt(n), e = Math.imul(e, 16777619);
|
|
1659
1659
|
return e >>> 0;
|
|
1660
1660
|
}
|
|
1661
|
-
function
|
|
1661
|
+
function Rn(t) {
|
|
1662
1662
|
let e = t >>> 0 || 2654435769;
|
|
1663
1663
|
return {
|
|
1664
1664
|
seed: t >>> 0,
|
|
@@ -1667,27 +1667,27 @@ function An(t) {
|
|
|
1667
1667
|
}
|
|
1668
1668
|
};
|
|
1669
1669
|
}
|
|
1670
|
-
function
|
|
1670
|
+
function ue(t, e, n) {
|
|
1671
1671
|
return e + t.next() * (n - e);
|
|
1672
1672
|
}
|
|
1673
|
-
function
|
|
1674
|
-
if (
|
|
1675
|
-
const
|
|
1676
|
-
return e + i *
|
|
1673
|
+
function Dn(t, e, n, r) {
|
|
1674
|
+
if (r <= 0) return ue(t, e, n);
|
|
1675
|
+
const s = Math.floor((n - e) / r), i = Math.round(t.next() * s);
|
|
1676
|
+
return e + i * r;
|
|
1677
1677
|
}
|
|
1678
|
-
function
|
|
1678
|
+
function ar(t, e) {
|
|
1679
1679
|
if (e.length !== 0)
|
|
1680
1680
|
return e[Math.floor(t.next() * e.length)];
|
|
1681
1681
|
}
|
|
1682
|
-
const
|
|
1683
|
-
function
|
|
1684
|
-
return typeof t != "string" ? !1 :
|
|
1682
|
+
const le = /^([+\-*/])=\s*(-?[\d.]+)$/, he = /^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;
|
|
1683
|
+
function or(t) {
|
|
1684
|
+
return typeof t != "string" ? !1 : le.test(t.trim()) || he.test(t.trim());
|
|
1685
1685
|
}
|
|
1686
|
-
function
|
|
1686
|
+
function fe(t, e = {}) {
|
|
1687
1687
|
if (typeof t != "string") return t;
|
|
1688
|
-
const n = t.trim(),
|
|
1689
|
-
if (
|
|
1690
|
-
const [, i, a] =
|
|
1688
|
+
const n = t.trim(), r = le.exec(n);
|
|
1689
|
+
if (r) {
|
|
1690
|
+
const [, i, a] = r, o = e.base ?? 0, c = Number.parseFloat(a);
|
|
1691
1691
|
switch (i) {
|
|
1692
1692
|
case "+":
|
|
1693
1693
|
return o + c;
|
|
@@ -1699,134 +1699,134 @@ function ue(t, e = {}) {
|
|
|
1699
1699
|
return c === 0 ? o : o / c;
|
|
1700
1700
|
}
|
|
1701
1701
|
}
|
|
1702
|
-
const
|
|
1703
|
-
if (
|
|
1702
|
+
const s = he.exec(n);
|
|
1703
|
+
if (s) {
|
|
1704
1704
|
if (!e.random)
|
|
1705
1705
|
throw new Error(
|
|
1706
1706
|
`resolveValue: "${n}" needs a random source — pass one via context.random`
|
|
1707
1707
|
);
|
|
1708
|
-
const i = Number.parseFloat(
|
|
1709
|
-
return o !== void 0 ?
|
|
1708
|
+
const i = Number.parseFloat(s[1]), a = Number.parseFloat(s[2]), o = s[3] !== void 0 ? Number.parseFloat(s[3]) : void 0;
|
|
1709
|
+
return o !== void 0 ? Dn(e.random, i, a, o) : ue(e.random, i, a);
|
|
1710
1710
|
}
|
|
1711
1711
|
return t;
|
|
1712
1712
|
}
|
|
1713
|
-
function
|
|
1714
|
-
const
|
|
1715
|
-
let
|
|
1713
|
+
function Cn(t, e = 0, n) {
|
|
1714
|
+
const r = [];
|
|
1715
|
+
let s = e;
|
|
1716
1716
|
for (const i of t) {
|
|
1717
|
-
const a =
|
|
1718
|
-
|
|
1717
|
+
const a = fe(i, { base: s, random: n });
|
|
1718
|
+
r.push(a), typeof a == "number" && (s = a);
|
|
1719
1719
|
}
|
|
1720
|
-
return
|
|
1720
|
+
return r;
|
|
1721
1721
|
}
|
|
1722
|
-
class
|
|
1722
|
+
class cr {
|
|
1723
1723
|
random;
|
|
1724
1724
|
constructor(e) {
|
|
1725
|
-
this.random =
|
|
1725
|
+
this.random = Rn(e);
|
|
1726
1726
|
}
|
|
1727
1727
|
/** The seed, to be stored alongside the timeline so this can be reproduced. */
|
|
1728
1728
|
get seed() {
|
|
1729
1729
|
return this.random.seed;
|
|
1730
1730
|
}
|
|
1731
1731
|
resolve(e, n = 0) {
|
|
1732
|
-
return
|
|
1732
|
+
return fe(e, { base: n, random: this.random });
|
|
1733
1733
|
}
|
|
1734
1734
|
resolveSequence(e, n = 0) {
|
|
1735
|
-
return
|
|
1735
|
+
return Cn(e, n, this.random);
|
|
1736
1736
|
}
|
|
1737
1737
|
}
|
|
1738
|
-
const
|
|
1739
|
-
function
|
|
1738
|
+
const In = 600;
|
|
1739
|
+
function ur(t) {
|
|
1740
1740
|
if (Array.isArray(t)) {
|
|
1741
|
-
const [p, f,
|
|
1742
|
-
return { fn:
|
|
1741
|
+
const [p, f, _, d] = t;
|
|
1742
|
+
return { fn: Bt(p, f, _, d), bezier: [p, f, _, d] };
|
|
1743
1743
|
}
|
|
1744
|
-
const { segments: e } =
|
|
1744
|
+
const { segments: e } = W(t);
|
|
1745
1745
|
if (e.length === 0) throw new Error(`customEase: no curve in "${t}"`);
|
|
1746
|
-
const n = e[0].startX,
|
|
1746
|
+
const n = e[0].startX, r = e[0].startY, s = e[e.length - 1], i = s.endX - n, a = s.endY - r;
|
|
1747
1747
|
if (i === 0 || a === 0) throw new Error(`customEase: "${t}" must move along both axes`);
|
|
1748
|
-
const o = (p) => (p - n) / i, c = (p) => (p -
|
|
1749
|
-
if (e.length === 1 &&
|
|
1750
|
-
const [p, f,
|
|
1751
|
-
return { fn:
|
|
1748
|
+
const o = (p) => (p - n) / i, c = (p) => (p - r) / a;
|
|
1749
|
+
if (e.length === 1 && s.type === "C") {
|
|
1750
|
+
const [p, f, _, d] = s.points, g = [o(p), c(f), o(_), c(d)];
|
|
1751
|
+
return { fn: Bt(...g), bezier: g };
|
|
1752
1752
|
}
|
|
1753
|
-
const u = [], l = [], h = Math.max(8, Math.ceil(
|
|
1753
|
+
const u = [], l = [], h = Math.max(8, Math.ceil(In / e.length));
|
|
1754
1754
|
for (const p of e)
|
|
1755
1755
|
for (let f = u.length === 0 ? 0 : 1; f <= h; f++) {
|
|
1756
|
-
const [
|
|
1757
|
-
u.push(o(
|
|
1756
|
+
const [_, d] = En(p, f / h);
|
|
1757
|
+
u.push(o(_)), l.push(c(d));
|
|
1758
1758
|
}
|
|
1759
|
-
return { fn:
|
|
1759
|
+
return { fn: Ln(u, l) };
|
|
1760
1760
|
}
|
|
1761
|
-
function
|
|
1762
|
-
const n = 0.1 + Math.max(0, Math.min(1, t.strength ?? 0.7)) * 0.7,
|
|
1763
|
-
for (let i = n; i > 2e-3; i *= n)
|
|
1764
|
-
const
|
|
1761
|
+
function lr(t = {}) {
|
|
1762
|
+
const n = 0.1 + Math.max(0, Math.min(1, t.strength ?? 0.7)) * 0.7, r = [1];
|
|
1763
|
+
for (let i = n; i > 2e-3; i *= n) r.push(2 * Math.sqrt(i));
|
|
1764
|
+
const s = r.reduce((i, a) => i + a, 0);
|
|
1765
1765
|
return (i) => {
|
|
1766
1766
|
if (i <= 0) return 0;
|
|
1767
1767
|
if (i >= 1) return 1;
|
|
1768
|
-
let a = i *
|
|
1769
|
-
for (let o = 0; o <
|
|
1770
|
-
if (a <=
|
|
1771
|
-
if (o === 0) return (a /
|
|
1772
|
-
const c =
|
|
1768
|
+
let a = i * s;
|
|
1769
|
+
for (let o = 0; o < r.length; o++) {
|
|
1770
|
+
if (a <= r[o]) {
|
|
1771
|
+
if (o === 0) return (a / r[0]) ** 2;
|
|
1772
|
+
const c = r[o] / 2, u = c * c, l = a - c;
|
|
1773
1773
|
return 1 - (u - l * l);
|
|
1774
1774
|
}
|
|
1775
|
-
a -=
|
|
1775
|
+
a -= r[o];
|
|
1776
1776
|
}
|
|
1777
1777
|
return 1;
|
|
1778
1778
|
};
|
|
1779
1779
|
}
|
|
1780
|
-
function
|
|
1781
|
-
const e = Math.max(1, t.wiggles ?? 10), n = t.type ?? "easeOut",
|
|
1782
|
-
return (
|
|
1780
|
+
function hr(t = {}) {
|
|
1781
|
+
const e = Math.max(1, t.wiggles ?? 10), n = t.type ?? "easeOut", r = (s) => n === "uniform" ? 1 : n === "easeInOut" ? Math.sin(Math.PI * s) : (1 - s) ** 2;
|
|
1782
|
+
return (s) => s <= 0 || s >= 1 ? 0 : Math.sin(s * e * Math.PI * 2) * r(s);
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1784
|
+
function En(t, e) {
|
|
1785
1785
|
if (t.type === "L") {
|
|
1786
1786
|
const [u, l] = t.points;
|
|
1787
1787
|
return [t.startX + (u - t.startX) * e, t.startY + (l - t.startY) * e];
|
|
1788
1788
|
}
|
|
1789
|
-
const [n,
|
|
1789
|
+
const [n, r, s, i, a, o] = t.points, c = 1 - e;
|
|
1790
1790
|
return [
|
|
1791
|
-
c * c * c * t.startX + 3 * c * c * e * n + 3 * c * e * e *
|
|
1792
|
-
c * c * c * t.startY + 3 * c * c * e *
|
|
1791
|
+
c * c * c * t.startX + 3 * c * c * e * n + 3 * c * e * e * s + e * e * e * a,
|
|
1792
|
+
c * c * c * t.startY + 3 * c * c * e * r + 3 * c * e * e * i + e * e * e * o
|
|
1793
1793
|
];
|
|
1794
1794
|
}
|
|
1795
|
-
function
|
|
1795
|
+
function Ln(t, e) {
|
|
1796
1796
|
return (n) => {
|
|
1797
1797
|
if (n <= t[0]) return e[0];
|
|
1798
1798
|
if (n >= t[t.length - 1]) return e[e.length - 1];
|
|
1799
|
-
let
|
|
1800
|
-
for (;
|
|
1801
|
-
const a =
|
|
1802
|
-
t[a] <= n ?
|
|
1799
|
+
let r = 0, s = t.length - 1;
|
|
1800
|
+
for (; s - r > 1; ) {
|
|
1801
|
+
const a = r + s >> 1;
|
|
1802
|
+
t[a] <= n ? r = a : s = a;
|
|
1803
1803
|
}
|
|
1804
|
-
const i = t[
|
|
1805
|
-
return i === 0 ? e[
|
|
1804
|
+
const i = t[s] - t[r];
|
|
1805
|
+
return i === 0 ? e[s] : e[r] + (n - t[r]) / i * (e[s] - e[r]);
|
|
1806
1806
|
};
|
|
1807
1807
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const
|
|
1808
|
+
function Bt(t, e, n, r) {
|
|
1809
|
+
const s = (a, o, c) => 3 * (1 - a) * (1 - a) * a * o + 3 * (1 - a) * a * a * c + a * a * a, i = (a, o, c) => 3 * (1 - a) * (1 - a) * o + 6 * (1 - a) * a * (c - o) + 3 * a * a * (1 - c);
|
|
1810
1810
|
return (a) => {
|
|
1811
1811
|
if (a <= 0) return 0;
|
|
1812
1812
|
if (a >= 1) return 1;
|
|
1813
1813
|
let o = a;
|
|
1814
1814
|
for (let l = 0; l < 8; l++) {
|
|
1815
|
-
const h =
|
|
1816
|
-
if (Math.abs(h) < 1e-6) return
|
|
1815
|
+
const h = s(o, t, n) - a, p = i(o, t, n);
|
|
1816
|
+
if (Math.abs(h) < 1e-6) return s(o, e, r);
|
|
1817
1817
|
if (Math.abs(p) < 1e-6) break;
|
|
1818
1818
|
o -= h / p;
|
|
1819
1819
|
}
|
|
1820
1820
|
let c = 0, u = 1;
|
|
1821
1821
|
o = a;
|
|
1822
1822
|
for (let l = 0; l < 40; l++)
|
|
1823
|
-
|
|
1824
|
-
return
|
|
1823
|
+
s(o, t, n) < a ? c = o : u = o, o = (c + u) / 2;
|
|
1824
|
+
return s(o, e, r);
|
|
1825
1825
|
};
|
|
1826
1826
|
}
|
|
1827
|
-
const
|
|
1828
|
-
function
|
|
1829
|
-
const n = e.lead ??
|
|
1827
|
+
const Fn = 350, On = 300, Nn = 550;
|
|
1828
|
+
function fr(t, e = {}) {
|
|
1829
|
+
const n = e.lead ?? Fn, r = e.gap ?? On, s = e.tail ?? Nn, i = [];
|
|
1830
1830
|
let a = 0;
|
|
1831
1831
|
return t.forEach((o, c) => {
|
|
1832
1832
|
const u = [];
|
|
@@ -1834,7 +1834,7 @@ function cs(t, e = {}) {
|
|
|
1834
1834
|
o.lines.forEach((p, f) => {
|
|
1835
1835
|
if (!(p.duration >= 0))
|
|
1836
1836
|
throw new Error(`narration: scene ${c} line ${f} has an invalid duration (${p.duration})`);
|
|
1837
|
-
f > 0 && (l +=
|
|
1837
|
+
f > 0 && (l += r), u.push({
|
|
1838
1838
|
id: p.id ?? `s${c}-l${f}`,
|
|
1839
1839
|
scene: c,
|
|
1840
1840
|
line: f,
|
|
@@ -1843,180 +1843,257 @@ function cs(t, e = {}) {
|
|
|
1843
1843
|
text: p.text
|
|
1844
1844
|
}), l += p.duration;
|
|
1845
1845
|
});
|
|
1846
|
-
const h = l +
|
|
1846
|
+
const h = l + s + (o.tail ?? 0);
|
|
1847
1847
|
i.push({ id: o.id ?? `s${c}`, start: a, duration: h - a, cues: u }), a = h;
|
|
1848
1848
|
}), { duration: a, scenes: i, cues: i.flatMap((o) => o.cues) };
|
|
1849
1849
|
}
|
|
1850
|
-
function
|
|
1850
|
+
function pr(t) {
|
|
1851
1851
|
return t.cues.map((e) => ({ id: e.id, time: e.start, label: e.text }));
|
|
1852
1852
|
}
|
|
1853
|
-
function
|
|
1853
|
+
function dr(t, e) {
|
|
1854
1854
|
let n = t.scenes[0];
|
|
1855
|
-
for (const
|
|
1856
|
-
if (e >=
|
|
1855
|
+
for (const r of t.scenes)
|
|
1856
|
+
if (e >= r.start) n = r;
|
|
1857
1857
|
else break;
|
|
1858
1858
|
return n;
|
|
1859
1859
|
}
|
|
1860
|
-
const
|
|
1861
|
-
function
|
|
1860
|
+
const pe = (t) => 6e4 / t.bpm;
|
|
1861
|
+
function St(t, e) {
|
|
1862
|
+
return t.offset + e * pe(t);
|
|
1863
|
+
}
|
|
1864
|
+
function At(t, e) {
|
|
1865
|
+
return (e - t.offset) / pe(t);
|
|
1866
|
+
}
|
|
1867
|
+
function gr(t, e) {
|
|
1868
|
+
return St(t, Math.round(At(t, e)));
|
|
1869
|
+
}
|
|
1870
|
+
function mr(t, e) {
|
|
1871
|
+
return St(t, Math.ceil(At(t, e) - 1e-9));
|
|
1872
|
+
}
|
|
1873
|
+
function yr(t, e, n) {
|
|
1874
|
+
const r = Math.max(1, Math.round(t.beatsPerBar ?? 4)), s = [];
|
|
1875
|
+
if (!(t.bpm > 0) || n < e) return s;
|
|
1876
|
+
for (let i = Math.ceil(At(t, e) - 1e-9); ; i++) {
|
|
1877
|
+
const a = St(t, i);
|
|
1878
|
+
if (a > n + 1e-9) break;
|
|
1879
|
+
s.push({ time: a, bar: (i % r + r) % r === 0, n: i });
|
|
1880
|
+
}
|
|
1881
|
+
return s;
|
|
1882
|
+
}
|
|
1883
|
+
const B = 100;
|
|
1884
|
+
function _r(t, e, n = {}) {
|
|
1885
|
+
const r = n.minBpm ?? 70, s = n.maxBpm ?? 180, i = Math.max(1, Math.round(e / B)), a = Math.min(t.length, Math.round((n.maxSeconds ?? 60) * e)), o = Math.floor(a / i);
|
|
1886
|
+
if (o < 4) return { bpm: 120, offset: 0, confidence: 0 };
|
|
1887
|
+
const c = new Float64Array(o);
|
|
1888
|
+
for (let m = 0; m < o; m++) {
|
|
1889
|
+
let T = 0;
|
|
1890
|
+
for (let x = m * i; x < (m + 1) * i; x++) T += t[x] * t[x];
|
|
1891
|
+
c[m] = Math.log(1e-6 + T / i);
|
|
1892
|
+
}
|
|
1893
|
+
const u = new Float64Array(o);
|
|
1894
|
+
for (let m = 1; m < o; m++) u[m] = Math.max(0, c[m] - c[m - 1]);
|
|
1895
|
+
const l = u.reduce((m, T) => m + T, 0) / o;
|
|
1896
|
+
for (let m = 0; m < o; m++) u[m] = Math.max(0, u[m] - l);
|
|
1897
|
+
const h = Math.max(1, Math.floor(60 * B / s)), p = Math.min(o - 1, Math.ceil(60 * B / r)), f = (m) => {
|
|
1898
|
+
let T = 0;
|
|
1899
|
+
for (let x = m; x < o; x++) T += u[x] * u[x - m];
|
|
1900
|
+
return T / (o - m);
|
|
1901
|
+
};
|
|
1902
|
+
let _ = 0;
|
|
1903
|
+
for (let m = 0; m < o; m++) _ += u[m] * u[m];
|
|
1904
|
+
_ /= o;
|
|
1905
|
+
let d = h, g = -1 / 0;
|
|
1906
|
+
for (let m = h; m <= p; m++) {
|
|
1907
|
+
const T = 60 * B / m, x = Math.exp(-0.5 * (Math.log2(T / 120) / 0.9) ** 2), v = f(m) * x;
|
|
1908
|
+
v > g && (g = v, d = m);
|
|
1909
|
+
}
|
|
1910
|
+
const M = (m) => {
|
|
1911
|
+
const T = Math.floor(m);
|
|
1912
|
+
return T < 0 || T + 1 >= o ? 0 : u[T] + (u[T + 1] - u[T]) * (m - T);
|
|
1913
|
+
}, b = (m, T) => {
|
|
1914
|
+
let x = 0;
|
|
1915
|
+
for (let v = T; v < o; v += m) x += M(v);
|
|
1916
|
+
return x;
|
|
1917
|
+
};
|
|
1918
|
+
let k = d, A = 0, y = -1 / 0;
|
|
1919
|
+
for (let m = d - 0.6; m <= d + 0.6 + 1e-9; m += 0.02) {
|
|
1920
|
+
if (m < 1) continue;
|
|
1921
|
+
const T = Math.max(1, Math.round(m * 4));
|
|
1922
|
+
for (let x = 0; x < T; x++) {
|
|
1923
|
+
const v = x / T * m, $ = b(m, v);
|
|
1924
|
+
$ > y && (y = $, A = v, k = m);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
const w = 60 * B / k, S = _ > 0 ? Math.max(0, Math.min(1, f(d) / _)) : 0, I = (A + 0.5) * 1e3 / B;
|
|
1928
|
+
return { bpm: Math.round(w * 100) / 100, offset: Math.round(I % (6e4 / w)), confidence: S };
|
|
1929
|
+
}
|
|
1930
|
+
const L = (t) => Math.round(t * 1e3) / 1e3;
|
|
1931
|
+
function Mr(t, e = {}) {
|
|
1862
1932
|
if (t.length === 0) return "";
|
|
1863
|
-
const n = e.curviness ?? 1,
|
|
1864
|
-
let i = `M${
|
|
1865
|
-
if (
|
|
1866
|
-
const a = (c) =>
|
|
1933
|
+
const n = e.curviness ?? 1, r = e.closed ?? !1, s = t.length;
|
|
1934
|
+
let i = `M${L(t[0].x)} ${L(t[0].y)}`;
|
|
1935
|
+
if (s === 1) return i;
|
|
1936
|
+
const a = (c) => r ? t[(c % s + s) % s] : t[Math.max(0, Math.min(s - 1, c))], o = r ? s : s - 1;
|
|
1867
1937
|
for (let c = 0; c < o; c++) {
|
|
1868
1938
|
const u = a(c - 1), l = a(c), h = a(c + 1), p = a(c + 2);
|
|
1869
1939
|
if (n === 0) {
|
|
1870
|
-
i += ` L${
|
|
1940
|
+
i += ` L${L(h.x)} ${L(h.y)}`;
|
|
1871
1941
|
continue;
|
|
1872
1942
|
}
|
|
1873
|
-
const f = n / 6,
|
|
1874
|
-
i += ` C${
|
|
1943
|
+
const f = n / 6, _ = l.x + (h.x - u.x) * f, d = l.y + (h.y - u.y) * f, g = h.x - (p.x - l.x) * f, M = h.y - (p.y - l.y) * f;
|
|
1944
|
+
i += ` C${L(_)} ${L(d)} ${L(g)} ${L(M)} ${L(h.x)} ${L(h.y)}`;
|
|
1875
1945
|
}
|
|
1876
|
-
return
|
|
1946
|
+
return r ? `${i} Z` : i;
|
|
1877
1947
|
}
|
|
1878
|
-
const
|
|
1948
|
+
const R = (t, e = 0) => {
|
|
1879
1949
|
const n = parseFloat(t ?? "");
|
|
1880
1950
|
return Number.isFinite(n) ? n : e;
|
|
1881
1951
|
};
|
|
1882
|
-
function
|
|
1952
|
+
function Xn(t) {
|
|
1883
1953
|
const e = (t ?? "").trim().split(/[\s,]+/).filter(Boolean).map(Number), n = [];
|
|
1884
|
-
for (let
|
|
1954
|
+
for (let r = 0; r + 1 < e.length; r += 2) n.push({ x: e[r], y: e[r + 1] });
|
|
1885
1955
|
return n;
|
|
1886
1956
|
}
|
|
1887
|
-
function
|
|
1957
|
+
function br(t) {
|
|
1888
1958
|
const e = t.attributes;
|
|
1889
1959
|
switch (t.tag.toLowerCase()) {
|
|
1890
1960
|
case "path":
|
|
1891
1961
|
return e.d ?? null;
|
|
1892
1962
|
case "circle":
|
|
1893
1963
|
case "ellipse": {
|
|
1894
|
-
const n =
|
|
1895
|
-
return `M${n +
|
|
1964
|
+
const n = R(e.cx), r = R(e.cy), s = t.tag.toLowerCase() === "circle" ? R(e.r) : R(e.rx), i = t.tag.toLowerCase() === "circle" ? R(e.r) : R(e.ry);
|
|
1965
|
+
return `M${n + s} ${r} A${s} ${i} 0 1 1 ${n - s} ${r} A${s} ${i} 0 1 1 ${n + s} ${r} Z`;
|
|
1896
1966
|
}
|
|
1897
1967
|
case "rect": {
|
|
1898
|
-
const n =
|
|
1899
|
-
let a = e.rx != null ?
|
|
1900
|
-
return a = Math.min(a,
|
|
1968
|
+
const n = R(e.x), r = R(e.y), s = R(e.width), i = R(e.height);
|
|
1969
|
+
let a = e.rx != null ? R(e.rx) : e.ry != null ? R(e.ry) : 0, o = e.ry != null ? R(e.ry) : a;
|
|
1970
|
+
return a = Math.min(a, s / 2), o = Math.min(o, i / 2), a === 0 || o === 0 ? `M${n} ${r} H${n + s} V${r + i} H${n} Z` : `M${n + a} ${r} H${n + s - a} A${a} ${o} 0 0 1 ${n + s} ${r + o} V${r + i - o} A${a} ${o} 0 0 1 ${n + s - a} ${r + i} H${n + a} A${a} ${o} 0 0 1 ${n} ${r + i - o} V${r + o} A${a} ${o} 0 0 1 ${n + a} ${r} Z`;
|
|
1901
1971
|
}
|
|
1902
1972
|
case "line":
|
|
1903
|
-
return `M${
|
|
1973
|
+
return `M${R(e.x1)} ${R(e.y1)} L${R(e.x2)} ${R(e.y2)}`;
|
|
1904
1974
|
case "polyline":
|
|
1905
1975
|
case "polygon": {
|
|
1906
|
-
const n =
|
|
1976
|
+
const n = Xn(e.points);
|
|
1907
1977
|
if (n.length === 0) return null;
|
|
1908
|
-
const
|
|
1909
|
-
return t.tag.toLowerCase() === "polygon" ? `${
|
|
1978
|
+
const r = n.map((s, i) => `${i === 0 ? "M" : "L"}${s.x} ${s.y}`).join(" ");
|
|
1979
|
+
return t.tag.toLowerCase() === "polygon" ? `${r} Z` : r;
|
|
1910
1980
|
}
|
|
1911
1981
|
default:
|
|
1912
1982
|
return null;
|
|
1913
1983
|
}
|
|
1914
1984
|
}
|
|
1915
1985
|
export {
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
Gt as
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
V as
|
|
1986
|
+
Vn as Clock,
|
|
1987
|
+
re as DEFAULT_BAKE_INTERVAL_MS,
|
|
1988
|
+
Rt as DEFAULT_INERTIA_FRICTION,
|
|
1989
|
+
E as DEFAULT_SPRING,
|
|
1990
|
+
it as FORMAT_VERSION,
|
|
1991
|
+
ve as INERTIA_MAX_DURATION_MS,
|
|
1992
|
+
Mn as InertiaTrackPlayer,
|
|
1993
|
+
Gn as MORPH_SAMPLES,
|
|
1994
|
+
Un as ManualClock,
|
|
1995
|
+
Kt as SPRING_MAX_DURATION_MS,
|
|
1996
|
+
Hn as SPRING_PRESETS,
|
|
1997
|
+
Z as SPRING_STEP_MS,
|
|
1998
|
+
at as SpringSampler,
|
|
1999
|
+
_n as SpringTrackPlayer,
|
|
2000
|
+
vn as Timeline,
|
|
2001
|
+
mt as TrackPlayer,
|
|
2002
|
+
cr as ValueResolver,
|
|
2003
|
+
Oe as backOut,
|
|
2004
|
+
dn as bakeEasing,
|
|
2005
|
+
ie as bakeInertiaTrack,
|
|
2006
|
+
se as bakeSpringTrack,
|
|
2007
|
+
At as beatAtTime,
|
|
2008
|
+
pe as beatLength,
|
|
2009
|
+
St as beatTime,
|
|
2010
|
+
yr as beatsBetween,
|
|
2011
|
+
Fe as bounceOut,
|
|
2012
|
+
Tn as charactersFor,
|
|
2013
|
+
Zn as clearMorphCache,
|
|
2014
|
+
Kn as clearPathCache,
|
|
2015
|
+
Ee as createCubicBezier,
|
|
2016
|
+
Rn as createRandom,
|
|
2017
|
+
yn as createTrack,
|
|
2018
|
+
Wn as criticalDamping,
|
|
2019
|
+
lr as customBounce,
|
|
2020
|
+
ur as customEase,
|
|
2021
|
+
hr as customWiggle,
|
|
2022
|
+
$n as deserializeTimeline,
|
|
2023
|
+
wn as deserializeTrack,
|
|
2024
|
+
_r as detectTempo,
|
|
2025
|
+
Re as easeIn,
|
|
2026
|
+
Qt as easeInCubic,
|
|
2027
|
+
Ce as easeInOut,
|
|
2028
|
+
Zt as easeInOutCubic,
|
|
2029
|
+
$e as easeInOutQuad,
|
|
2030
|
+
we as easeInQuad,
|
|
2031
|
+
De as easeOut,
|
|
2032
|
+
Gt as easeOutCubic,
|
|
2033
|
+
Pe as easeOutQuad,
|
|
2034
|
+
Le as elasticOut,
|
|
2035
|
+
gn as expandParametricEasings,
|
|
2036
|
+
sr as fromJSON,
|
|
2037
|
+
Jt as getEasingFunction,
|
|
2038
|
+
ne as getInterpolator,
|
|
2039
|
+
oe as getMotionPathPoint,
|
|
2040
|
+
Qn as getPathLength,
|
|
2041
|
+
je as getPointAtProgress,
|
|
2042
|
+
Me as hasKeyframes,
|
|
2043
|
+
ir as hashSeed,
|
|
2044
|
+
ut as inertiaDuration,
|
|
2045
|
+
ct as inertiaRest,
|
|
2046
|
+
bt as inertiaValueAt,
|
|
2047
|
+
jn as inertiaVelocityAt,
|
|
2048
|
+
fn as interpolateArray,
|
|
2049
|
+
hn as interpolateColor,
|
|
2050
|
+
er as interpolateMotionPath,
|
|
2051
|
+
O as interpolateNumber,
|
|
2052
|
+
pn as interpolatePathString,
|
|
2053
|
+
zt as interpolateString,
|
|
2054
|
+
_e as isCubicBezierEasing,
|
|
2055
|
+
V as isInertiaTrack,
|
|
2056
|
+
Yn as isMotionPathPoint,
|
|
2057
|
+
qt as isMotionPathTrack,
|
|
2058
|
+
Mt as isParametricEasing,
|
|
2059
|
+
cn as isPathData,
|
|
2060
|
+
H as isSpringTrack,
|
|
1986
2061
|
kt as isTextTrack,
|
|
1987
|
-
|
|
1988
|
-
|
|
2062
|
+
qn as isUnderdamped,
|
|
2063
|
+
or as isUnresolved,
|
|
1989
2064
|
Tt as linear,
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2065
|
+
be as maxStaggerDistance,
|
|
2066
|
+
on as morphPath,
|
|
2067
|
+
pr as narrationMarkers,
|
|
2068
|
+
dr as narrationSceneAt,
|
|
2069
|
+
Se as naturalRest,
|
|
2070
|
+
gr as nearestBeat,
|
|
2071
|
+
mr as nextBeat,
|
|
2072
|
+
Xe as parametricEasing,
|
|
2073
|
+
W as parsePath,
|
|
2074
|
+
fr as planNarration,
|
|
2075
|
+
nr as playheadCrossings,
|
|
2076
|
+
te as pointAtDistance,
|
|
2077
|
+
Mr as pointsToPath,
|
|
2078
|
+
ue as randomBetween,
|
|
2079
|
+
ar as randomChoice,
|
|
2080
|
+
Dn as randomSnapped,
|
|
2081
|
+
Cn as resolveSequence,
|
|
2082
|
+
fe as resolveValue,
|
|
2083
|
+
Pn as serializeTimeline,
|
|
2084
|
+
An as serializeTrack,
|
|
2085
|
+
br as shapeToPathData,
|
|
2086
|
+
mn as simplifyKeyframes,
|
|
2087
|
+
Bn as springDuration,
|
|
2088
|
+
zn as springValueAt,
|
|
2089
|
+
Wt as staggerDistance,
|
|
2090
|
+
jt as staggerOffset,
|
|
2091
|
+
Te as staggerOffsets,
|
|
2092
|
+
vt as staggerSpan,
|
|
2093
|
+
Ne as stepsEasing,
|
|
2094
|
+
kn as textAt,
|
|
2095
|
+
rr as toJSON,
|
|
2096
|
+
Jn as toKeyframedTrack,
|
|
2097
|
+
tr as toKeyframedTracks,
|
|
2098
|
+
U as trackTargets
|
|
2022
2099
|
};
|