@algorisys/tinyfly 0.81.0 → 0.86.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +12 -5
  2. package/lib/addons/adapters.js +363 -248
  3. package/lib/addons/characters.js +1658 -1342
  4. package/lib/addons/dom-adapter-Cphr2HZn.js +372 -0
  5. package/lib/addons/gsap-compat.js +197 -187
  6. package/lib/addons/load-scene-vp14_Jj-.js +324 -0
  7. package/lib/addons/scene-3d-webgl.js +237 -0
  8. package/lib/addons/scene-3d.js +306 -0
  9. package/lib/addons/shading-ByG9UXd0.js +85 -0
  10. package/lib/browser/tinyfly-scene-3d-webgl.iife.js +114 -0
  11. package/lib/browser/tinyfly-scene-3d.iife.js +3 -0
  12. package/lib/browser/tinyfly.iife.js +4 -4
  13. package/lib/browser/tinyfly.js +3295 -2613
  14. package/lib/browser/tinyfly.umd.js +4 -4
  15. package/lib/cli/tools.js +137 -22
  16. package/lib/embed/tinyfly-embed.iife.js +4 -4
  17. package/lib/embed/tinyfly-embed.js +921 -833
  18. package/lib/engine/tinyfly-engine.js +1022 -776
  19. package/lib/engine/tinyfly-engine.umd.cjs +2 -2
  20. package/lib/headless/headless.js +264 -7
  21. package/lib/player/tinyfly-player.es.js +459 -371
  22. package/lib/player/tinyfly-player.iife.js +2 -2
  23. package/lib/player/tinyfly-player.umd.js +2 -2
  24. package/lib/types/adapters/canvas/canvas-adapter.d.ts +36 -0
  25. package/lib/types/adapters/transform-3d.d.ts +99 -0
  26. package/lib/types/adapters/webgl/webgl-adapter.d.ts +17 -0
  27. package/lib/types/characters/character.d.ts +20 -1
  28. package/lib/types/characters/dance.d.ts +47 -0
  29. package/lib/types/characters/index.d.ts +3 -1
  30. package/lib/types/characters/rig/body-plan.d.ts +3 -1
  31. package/lib/types/characters/rig/skeleton.d.ts +57 -0
  32. package/lib/types/characters/scene-objects.d.ts +2 -0
  33. package/lib/types/characters/species/human.d.ts +8 -0
  34. package/lib/types/compat/gsap/vars.d.ts +8 -0
  35. package/lib/types/engine/core/bake.d.ts +3 -1
  36. package/lib/types/engine/index.d.ts +1 -0
  37. package/lib/types/engine/interpolation/interpolators.d.ts +10 -3
  38. package/lib/types/engine/math/index.d.ts +11 -0
  39. package/lib/types/engine/math/mat4.d.ts +37 -0
  40. package/lib/types/engine/math/quat.d.ts +39 -0
  41. package/lib/types/engine/math/vec3.d.ts +16 -0
  42. package/lib/types/engine/types.d.ts +23 -2
  43. package/lib/types/scene-3d/camera.d.ts +27 -0
  44. package/lib/types/scene-3d/canvas-2d-renderer.d.ts +21 -0
  45. package/lib/types/scene-3d/geometry/extrude.d.ts +17 -0
  46. package/lib/types/scene-3d/geometry/mesh.d.ts +36 -0
  47. package/lib/types/scene-3d/geometry/primitives.d.ts +16 -0
  48. package/lib/types/scene-3d/geometry/triangulate.d.ts +24 -0
  49. package/lib/types/scene-3d/index.d.ts +20 -0
  50. package/lib/types/scene-3d/load-scene.d.ts +31 -0
  51. package/lib/types/scene-3d/object-kind.d.ts +54 -0
  52. package/lib/types/scene-3d/resolve-scene.d.ts +122 -0
  53. package/lib/types/scene-3d/scene-3d-adapter.d.ts +46 -0
  54. package/lib/types/scene-3d/scene-types.d.ts +191 -0
  55. package/lib/types/scene-3d/shading.d.ts +20 -0
  56. package/lib/types/scene-3d/validate-scene.d.ts +11 -0
  57. package/lib/types/scene-3d/webgl/gl-data.d.ts +28 -0
  58. package/lib/types/scene-3d/webgl/index.d.ts +16 -0
  59. package/lib/types/scene-3d/webgl/shaders.d.ts +29 -0
  60. package/lib/types/scene-3d/webgl/webgl2-renderer.d.ts +33 -0
  61. package/package.json +10 -2
  62. package/lib/addons/dom-adapter-CrNwoomd.js +0 -243
@@ -1,11 +1,14 @@
1
- function ee(i) {
1
+ function ie(i) {
2
2
  return typeof i == "object" && i !== null && i.type === "cubic-bezier";
3
3
  }
4
- function ie(i) {
4
+ function se(i) {
5
5
  return typeof i == "object" && i !== null && i.type !== "cubic-bezier";
6
6
  }
7
- const lt = 1;
8
- function Xt(i) {
7
+ const At = 2;
8
+ function ne(i) {
9
+ return i.some((t) => t.interpolation !== void 0) ? 2 : 1;
10
+ }
11
+ function Yt(i) {
9
12
  return i.property === "text" && "textConfig" in i;
10
13
  }
11
14
  function ut(i) {
@@ -14,10 +17,10 @@ function ut(i) {
14
17
  function dt(i) {
15
18
  return i.kind === "spring" && "spring" in i;
16
19
  }
17
- function se(i) {
20
+ function re(i) {
18
21
  return i.property === "motionPath" && "motionPathConfig" in i;
19
22
  }
20
- function qt(i, t, e = "start") {
23
+ function Nt(i, t, e = "start") {
21
24
  if (t <= 1) return 0;
22
25
  if (typeof e == "number") {
23
26
  const s = Math.max(0, Math.min(t - 1, e));
@@ -34,29 +37,29 @@ function qt(i, t, e = "start") {
34
37
  return i;
35
38
  }
36
39
  }
37
- function ne(i, t = "start") {
40
+ function ae(i, t = "start") {
38
41
  if (i <= 1) return 0;
39
42
  let e = 0;
40
43
  for (let s = 0; s < i; s++)
41
- e = Math.max(e, qt(s, i, t));
44
+ e = Math.max(e, Nt(s, i, t));
42
45
  return e;
43
46
  }
44
- function Yt(i, t, e) {
47
+ function qt(i, t, e) {
45
48
  if (e.offsets) return e.offsets[i] ?? 0;
46
- const s = e.from ?? "start", n = qt(i, t, s);
49
+ const s = e.from ?? "start", n = Nt(i, t, s);
47
50
  if (e.amount !== void 0) {
48
- const r = ne(t, s);
51
+ const r = ae(t, s);
49
52
  return r === 0 ? 0 : e.amount * n / r;
50
53
  }
51
54
  return e.each !== void 0 ? e.each * n : 0;
52
55
  }
53
- function re(i, t) {
54
- return Array.from({ length: i }, (e, s) => Yt(s, i, t));
56
+ function oe(i, t) {
57
+ return Array.from({ length: i }, (e, s) => qt(s, i, t));
55
58
  }
56
59
  function mt(i, t) {
57
- return i <= 1 ? 0 : Math.max(...re(i, t));
60
+ return i <= 1 ? 0 : Math.max(...oe(i, t));
58
61
  }
59
- const U = 1, Nt = 6e4, G = Nt / U, F = {
62
+ const U = 1, Vt = 6e4, Z = Vt / U, X = {
60
63
  stiffness: 180,
61
64
  damping: 12,
62
65
  mass: 1,
@@ -64,7 +67,7 @@ const U = 1, Nt = 6e4, G = Nt / U, F = {
64
67
  restDelta: 0.01,
65
68
  restSpeed: 0.1
66
69
  };
67
- class ae {
70
+ class ce {
68
71
  from;
69
72
  to;
70
73
  stiffness;
@@ -89,7 +92,7 @@ class ae {
89
92
  /** Once at rest we stop simulating; every later time returns `to`. */
90
93
  settledStep = null;
91
94
  constructor(t) {
92
- this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ?? F.stiffness, this.damping = t.damping ?? F.damping, this.mass = t.mass ?? F.mass, this.restDelta = t.restDelta ?? F.restDelta, this.restSpeed = t.restSpeed ?? F.restSpeed, this.distance = Math.abs(this.to - this.from) || 1, this.samples = [this.from], this.velocity = t.velocity ?? F.velocity, this.isAtRest(this.from) && (this.settledStep = 0);
95
+ this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ?? X.stiffness, this.damping = t.damping ?? X.damping, this.mass = t.mass ?? X.mass, this.restDelta = t.restDelta ?? X.restDelta, this.restSpeed = t.restSpeed ?? X.restSpeed, this.distance = Math.abs(this.to - this.from) || 1, this.samples = [this.from], this.velocity = t.velocity ?? X.velocity, this.isAtRest(this.from) && (this.settledStep = 0);
93
96
  }
94
97
  /**
95
98
  * Whether a position/velocity pair counts as settled.
@@ -118,12 +121,12 @@ class ae {
118
121
  * of a spring track. Runs the simulation to completion once.
119
122
  */
120
123
  settleTime() {
121
- return this.simulateTo(G + 1), this.settledStep !== null ? this.settledStep * U : Nt;
124
+ return this.simulateTo(Z + 1), this.settledStep !== null ? this.settledStep * U : Vt;
122
125
  }
123
126
  /** Advance the cached simulation until it holds at least `steps` samples. */
124
127
  simulateTo(t) {
125
128
  if (this.settledStep !== null) return;
126
- const e = Math.min(t, G + 1), s = U / 1e3;
129
+ const e = Math.min(t, Z + 1), s = U / 1e3;
127
130
  for (; this.samples.length < e; ) {
128
131
  const n = this.samples[this.samples.length - 1], r = n - this.to, a = -this.stiffness * r, o = -this.damping * this.velocity, c = (a + o) / this.mass;
129
132
  this.velocity += c * s;
@@ -133,18 +136,18 @@ class ae {
133
136
  return;
134
137
  }
135
138
  }
136
- this.samples.length > G && (this.settledStep = G);
139
+ this.samples.length > Z && (this.settledStep = Z);
137
140
  }
138
141
  }
139
- const At = 4, oe = 2e-3, ce = 1e-4, he = 6e4;
142
+ const St = 4, he = 2e-3, le = 1e-4, ue = 6e4;
140
143
  function gt(i) {
141
- const t = i.friction ?? At;
142
- return t > 0 ? t : At;
144
+ const t = i.friction ?? St;
145
+ return t > 0 ? t : St;
143
146
  }
144
- function le(i) {
147
+ function de(i) {
145
148
  return i.from + i.velocity / gt(i);
146
149
  }
147
- function ue(i, t) {
150
+ function fe(i, t) {
148
151
  if (t === void 0) return i;
149
152
  if (typeof t == "number")
150
153
  return t > 0 ? Math.round(i / t) * t : i;
@@ -154,75 +157,75 @@ function ue(i, t) {
154
157
  Math.abs(s - i) < Math.abs(e - i) && (e = s);
155
158
  return e;
156
159
  }
157
- function Vt(i) {
158
- let t = ue(le(i), i.end);
160
+ function Wt(i) {
161
+ let t = fe(de(i), i.end);
159
162
  return i.min !== void 0 && (t = Math.max(i.min, t)), i.max !== void 0 && (t = Math.min(i.max, t)), t;
160
163
  }
161
- function Wt(i) {
162
- const t = Math.abs(Vt(i) - i.from);
164
+ function Ut(i) {
165
+ const t = Math.abs(Wt(i) - i.from);
163
166
  if (t === 0) return 0;
164
- const e = i.restDelta ?? Math.max(ce, t * oe);
167
+ const e = i.restDelta ?? Math.max(le, t * he);
165
168
  if (e >= t) return 0;
166
169
  const s = Math.log(t / e) / gt(i);
167
- return Math.min(he, s * 1e3);
170
+ return Math.min(ue, s * 1e3);
168
171
  }
169
- function St(i, t) {
172
+ function Mt(i, t) {
170
173
  if (t <= 0) return i.from;
171
- const e = Vt(i);
172
- if (t >= Wt(i)) return e;
174
+ const e = Wt(i);
175
+ if (t >= Ut(i)) return e;
173
176
  const s = gt(i);
174
177
  return i.from + (e - i.from) * (1 - Math.exp(-s * t / 1e3));
175
178
  }
176
- const ft = (i) => i, de = (i) => i * i, fe = (i) => 1 - (1 - i) * (1 - i), pe = (i) => i < 0.5 ? 2 * i * i : 1 - Math.pow(-2 * i + 2, 2) / 2, Ut = (i) => i * i * i, Ht = (i) => 1 - Math.pow(1 - i, 3), Qt = (i) => i < 0.5 ? 4 * i * i * i : 1 - Math.pow(-2 * i + 2, 3) / 2, me = Ut, ge = Ht, ye = Qt, Te = {
179
+ const ft = (i) => i, pe = (i) => i * i, me = (i) => 1 - (1 - i) * (1 - i), ge = (i) => i < 0.5 ? 2 * i * i : 1 - Math.pow(-2 * i + 2, 2) / 2, Ht = (i) => i * i * i, Qt = (i) => 1 - Math.pow(1 - i, 3), zt = (i) => i < 0.5 ? 4 * i * i * i : 1 - Math.pow(-2 * i + 2, 3) / 2, ye = Ht, Te = Qt, be = zt, Ae = {
177
180
  linear: ft,
178
- "ease-in": me,
179
- "ease-out": ge,
180
- "ease-in-out": ye,
181
- "ease-in-quad": de,
182
- "ease-out-quad": fe,
183
- "ease-in-out-quad": pe,
184
- "ease-in-cubic": Ut,
185
- "ease-out-cubic": Ht,
186
- "ease-in-out-cubic": Qt
181
+ "ease-in": ye,
182
+ "ease-out": Te,
183
+ "ease-in-out": be,
184
+ "ease-in-quad": pe,
185
+ "ease-out-quad": me,
186
+ "ease-in-out-quad": ge,
187
+ "ease-in-cubic": Ht,
188
+ "ease-out-cubic": Qt,
189
+ "ease-in-out-cubic": zt
187
190
  };
188
- function be(i) {
189
- const [t, e, s, n] = i, r = 3 * t, a = 3 * (s - t) - r, o = 1 - r - a, c = 3 * e, h = 3 * (n - e) - c, u = 1 - c - h, l = (p) => ((o * p + a) * p + r) * p, d = (p) => ((u * p + h) * p + c) * p, f = (p) => (3 * o * p + 2 * a) * p + r, b = (p) => {
190
- let g = p;
191
+ function Se(i) {
192
+ const [t, e, s, n] = i, r = 3 * t, a = 3 * (s - t) - r, o = 1 - r - a, c = 3 * e, h = 3 * (n - e) - c, u = 1 - c - h, l = (d) => ((o * d + a) * d + r) * d, g = (d) => ((u * d + h) * d + c) * d, p = (d) => (3 * o * d + 2 * a) * d + r, f = (d) => {
193
+ let m = d;
191
194
  for (let A = 0; A < 8; A++) {
192
- const _ = l(g) - p;
193
- if (Math.abs(_) < 1e-7)
194
- return g;
195
- const m = f(g);
196
- if (Math.abs(m) < 1e-7)
195
+ const M = l(m) - d;
196
+ if (Math.abs(M) < 1e-7)
197
+ return m;
198
+ const y = p(m);
199
+ if (Math.abs(y) < 1e-7)
197
200
  break;
198
- g -= _ / m;
201
+ m -= M / y;
199
202
  }
200
- let y = 0, T = 1;
201
- for (g = p; y < T; ) {
202
- const A = l(g);
203
- if (Math.abs(A - p) < 1e-7)
204
- return g;
205
- p > A ? y = g : T = g, g = (y + T) / 2;
203
+ let T = 0, b = 1;
204
+ for (m = d; T < b; ) {
205
+ const A = l(m);
206
+ if (Math.abs(A - d) < 1e-7)
207
+ return m;
208
+ d > A ? T = m : b = m, m = (T + b) / 2;
206
209
  }
207
- return g;
210
+ return m;
208
211
  };
209
- return (p) => {
210
- if (p <= 0) return 0;
211
- if (p >= 1) return 1;
212
- const g = b(p);
213
- return d(g);
212
+ return (d) => {
213
+ if (d <= 0) return 0;
214
+ if (d >= 1) return 1;
215
+ const m = f(d);
216
+ return g(m);
214
217
  };
215
218
  }
216
- function st(i, t = "out") {
219
+ function nt(i, t = "out") {
217
220
  if (t === "out") return i;
218
221
  const e = (s) => 1 - i(1 - s);
219
222
  return t === "in" ? e : (s) => s < 0.5 ? e(s * 2) / 2 : i(s * 2 - 1) / 2 + 0.5;
220
223
  }
221
- function Ae(i = 1, t = 0.3) {
224
+ function Me(i = 1, t = 0.3) {
222
225
  const e = Math.max(1, i), s = t / (2 * Math.PI) * Math.asin(1 / e);
223
226
  return (n) => n <= 0 ? 0 : n >= 1 ? 1 : e * Math.pow(2, -10 * n) * Math.sin((n - s) * (2 * Math.PI) / t) + 1;
224
227
  }
225
- const Se = (i) => {
228
+ const _e = (i) => {
226
229
  if (i <= 0) return 0;
227
230
  if (i >= 1) return 1;
228
231
  if (i < 1 / 2.75) return 7.5625 * i * i;
@@ -237,7 +240,7 @@ const Se = (i) => {
237
240
  const s = i - 2.625 / 2.75;
238
241
  return 7.5625 * s * s + 0.984375;
239
242
  };
240
- function _e(i = 1.70158) {
243
+ function ke(i = 1.70158) {
241
244
  return (t) => {
242
245
  if (t <= 0) return 0;
243
246
  if (t >= 1) return 1;
@@ -245,7 +248,7 @@ function _e(i = 1.70158) {
245
248
  return e * e * ((i + 1) * e + i) + 1;
246
249
  };
247
250
  }
248
- function Me(i, t = "end") {
251
+ function we(i, t = "end") {
249
252
  const e = Math.max(1, Math.floor(i));
250
253
  return (s) => {
251
254
  if (s >= 1) return 1;
@@ -263,22 +266,22 @@ function Me(i, t = "end") {
263
266
  }
264
267
  };
265
268
  }
266
- function ke(i) {
269
+ function Pe(i) {
267
270
  switch (i.type) {
268
271
  case "steps":
269
- return Me(i.count, i.position);
272
+ return we(i.count, i.position);
270
273
  case "elastic":
271
- return st(Ae(i.amplitude, i.period), i.mode);
274
+ return nt(Me(i.amplitude, i.period), i.mode);
272
275
  case "bounce":
273
- return st(Se, i.mode);
276
+ return nt(_e, i.mode);
274
277
  case "back":
275
- return st(_e(i.overshoot), i.mode);
278
+ return nt(ke(i.overshoot), i.mode);
276
279
  }
277
280
  }
278
- function we(i) {
279
- return i === void 0 ? ft : ee(i) ? be(i.points) : ie(i) ? ke(i) : Te[i] ?? ft;
281
+ function ve(i) {
282
+ return i === void 0 ? ft : ie(i) ? Se(i.points) : se(i) ? Pe(i) : Ae[i] ?? ft;
280
283
  }
281
- const _t = 32, Pe = 256, Y = /* @__PURE__ */ new Map(), xe = /[MmLlHhVvCcSsQqTtAaZz]/, ve = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, Ce = {
284
+ const _t = 32, xe = 256, N = /* @__PURE__ */ new Map(), Ce = /[MmLlHhVvCcSsQqTtAaZz]/, Ie = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, Re = {
282
285
  M: 2,
283
286
  L: 2,
284
287
  H: 1,
@@ -290,7 +293,7 @@ const _t = 32, Pe = 256, Y = /* @__PURE__ */ new Map(), xe = /[MmLlHhVvCcSsQqTtA
290
293
  A: 7,
291
294
  Z: 0
292
295
  };
293
- function Ie(i) {
296
+ function De(i) {
294
297
  const t = [];
295
298
  let e = 0, s = null;
296
299
  const n = () => {
@@ -298,7 +301,7 @@ function Ie(i) {
298
301
  };
299
302
  for (; e < i.length && (n(), !(e >= i.length)); ) {
300
303
  const r = i[e];
301
- if (xe.test(r)) {
304
+ if (Ce.test(r)) {
302
305
  s = { type: r, args: [] }, t.push(s), e++;
303
306
  continue;
304
307
  }
@@ -309,49 +312,49 @@ function Ie(i) {
309
312
  s.args.push(r === "1" ? 1 : 0), e++;
310
313
  continue;
311
314
  }
312
- const c = ve.exec(i.slice(e));
315
+ const c = Ie.exec(i.slice(e));
313
316
  if (!c) break;
314
317
  s.args.push(parseFloat(c[0])), e += c[0].length;
315
318
  }
316
319
  return t;
317
320
  }
318
- function Re(i, t, e, s, n, r, a, o, c) {
321
+ function Ee(i, t, e, s, n, r, a, o, c) {
319
322
  if (i === o && t === c) return [];
320
323
  let h = Math.abs(e), u = Math.abs(s);
321
324
  if (h === 0 || u === 0) return [[i, t, o, c, o, c]];
322
- const l = n * Math.PI / 180, d = Math.cos(l), f = Math.sin(l), b = (i - o) / 2, p = (t - c) / 2, g = d * b + f * p, y = -f * b + d * p, T = g * g / (h * h) + y * y / (u * u);
323
- if (T > 1) {
324
- const w = Math.sqrt(T);
325
+ const l = n * Math.PI / 180, g = Math.cos(l), p = Math.sin(l), f = (i - o) / 2, d = (t - c) / 2, m = g * f + p * d, T = -p * f + g * d, b = m * m / (h * h) + T * T / (u * u);
326
+ if (b > 1) {
327
+ const w = Math.sqrt(b);
325
328
  h *= w, u *= w;
326
329
  }
327
- const A = r === a ? -1 : 1, _ = h * h * u * u - h * h * y * y - u * u * g * g, m = h * h * y * y + u * u * g * g, M = A * Math.sqrt(Math.max(0, _ / m)), S = M * h * y / u, R = -M * u * g / h, Q = d * S - f * R + (i + o) / 2, k = f * S + d * R + (t + c) / 2, C = (w, v, I, $) => {
328
- const it = w * I + v * $, z = Math.sqrt((w * w + v * v) * (I * I + $ * $)), q = Math.acos(Math.max(-1, Math.min(1, it / z)));
329
- return w * $ - v * I < 0 ? -q : q;
330
- }, P = C(1, 0, (g - S) / h, (y - R) / u);
331
- let x = C((g - S) / h, (y - R) / u, (-g - S) / h, (-y - R) / u);
332
- !a && x > 0 && (x -= 2 * Math.PI), a && x < 0 && (x += 2 * Math.PI);
333
- const E = Math.max(1, Math.ceil(Math.abs(x) / (Math.PI / 2))), et = x / E, j = 4 / 3 * Math.tan(et / 4), yt = (w) => {
334
- const v = h * Math.cos(w), I = u * Math.sin(w);
335
- return [d * v - f * I + Q, f * v + d * I + k];
330
+ const A = r === a ? -1 : 1, M = h * h * u * u - h * h * T * T - u * u * m * m, y = h * h * T * T + u * u * m * m, _ = A * Math.sqrt(Math.max(0, M / y)), S = _ * h * T / u, R = -_ * u * m / h, z = g * S - p * R + (i + o) / 2, k = p * S + g * R + (t + c) / 2, C = (w, x, I, $) => {
331
+ const st = w * I + x * $, G = Math.sqrt((w * w + x * x) * (I * I + $ * $)), Y = Math.acos(Math.max(-1, Math.min(1, st / G)));
332
+ return w * $ - x * I < 0 ? -Y : Y;
333
+ }, P = C(1, 0, (m - S) / h, (T - R) / u);
334
+ let v = C((m - S) / h, (T - R) / u, (-m - S) / h, (-T - R) / u);
335
+ !a && v > 0 && (v -= 2 * Math.PI), a && v < 0 && (v += 2 * Math.PI);
336
+ const B = Math.max(1, Math.ceil(Math.abs(v) / (Math.PI / 2))), it = v / B, j = 4 / 3 * Math.tan(it / 4), yt = (w) => {
337
+ const x = h * Math.cos(w), I = u * Math.sin(w);
338
+ return [g * x - p * I + z, p * x + g * I + k];
336
339
  }, Tt = (w) => {
337
- const v = -h * Math.sin(w), I = u * Math.cos(w);
338
- return [d * v - f * I, f * v + d * I];
340
+ const x = -h * Math.sin(w), I = u * Math.cos(w);
341
+ return [g * x - p * I, p * x + g * I];
339
342
  }, bt = [];
340
- for (let w = 0; w < E; w++) {
341
- const v = P + w * et, I = v + et, [$, it] = yt(v), [z, q] = w === E - 1 ? [o, c] : yt(I), [Zt, Kt] = Tt(v), [Jt, te] = Tt(I);
342
- bt.push([$ + j * Zt, it + j * Kt, z - j * Jt, q - j * te, z, q]);
343
+ for (let w = 0; w < B; w++) {
344
+ const x = P + w * it, I = x + it, [$, st] = yt(x), [G, Y] = w === B - 1 ? [o, c] : yt(I), [Kt, Jt] = Tt(x), [te, ee] = Tt(I);
345
+ bt.push([$ + j * Kt, st + j * Jt, G - j * te, Y - j * ee, G, Y]);
343
346
  }
344
347
  return bt;
345
348
  }
346
- function B(i, t, e, s, n) {
349
+ function E(i, t, e, s, n) {
347
350
  const r = 1 - n;
348
351
  return r * r * r * i + 3 * r * r * n * t + 3 * r * n * n * e + n * n * n * s;
349
352
  }
350
- function Mt(i, t, e, s, n) {
353
+ function kt(i, t, e, s, n) {
351
354
  const r = 1 - n;
352
355
  return 3 * r * r * (t - i) + 6 * r * n * (e - t) + 3 * n * n * (s - e);
353
356
  }
354
- function N(i, t, e, s) {
357
+ function q(i, t, e, s) {
355
358
  return {
356
359
  subpath: 0,
357
360
  type: "L",
@@ -363,12 +366,12 @@ function N(i, t, e, s) {
363
366
  length: Math.hypot(e - i, s - t)
364
367
  };
365
368
  }
366
- function Z(i, t, e) {
369
+ function K(i, t, e) {
367
370
  const [s, n, r, a, o, c] = e, h = [0];
368
- let u = i, l = t, d = 0;
369
- for (let f = 1; f <= _t; f++) {
370
- const b = f / _t, p = B(i, s, r, o, b), g = B(t, n, a, c, b);
371
- d += Math.hypot(p - u, g - l), h.push(d), u = p, l = g;
371
+ let u = i, l = t, g = 0;
372
+ for (let p = 1; p <= _t; p++) {
373
+ const f = p / _t, d = E(i, s, r, o, f), m = E(t, n, a, c, f);
374
+ g += Math.hypot(d - u, m - l), h.push(g), u = d, l = m;
372
375
  }
373
376
  return {
374
377
  subpath: 0,
@@ -378,91 +381,91 @@ function Z(i, t, e) {
378
381
  startY: t,
379
382
  endX: o,
380
383
  endY: c,
381
- length: d,
384
+ length: g,
382
385
  lengths: h
383
386
  };
384
387
  }
385
- function J(i) {
386
- const t = Y.get(i);
388
+ function tt(i) {
389
+ const t = N.get(i);
387
390
  if (t) return t;
388
391
  const e = [];
389
392
  let s = 0, n = 0, r = 0, a = 0, o = null, c = null, h = -1;
390
- const u = /* @__PURE__ */ new Set(), l = (p) => {
391
- h < 0 && (h = 0), p.subpath = h, e.push(p);
393
+ const u = /* @__PURE__ */ new Set(), l = (d) => {
394
+ h < 0 && (h = 0), d.subpath = h, e.push(d);
392
395
  };
393
- for (const { type: p, args: g } of Ie(i)) {
394
- const y = p.toUpperCase(), T = p !== y, A = Ce[y];
395
- if (y === "Z") {
396
- (s !== r || n !== a) && l(N(s, n, r, a)), h >= 0 && u.add(h), s = r, n = a, o = c = null;
396
+ for (const { type: d, args: m } of De(i)) {
397
+ const T = d.toUpperCase(), b = d !== T, A = Re[T];
398
+ if (T === "Z") {
399
+ (s !== r || n !== a) && l(q(s, n, r, a)), h >= 0 && u.add(h), s = r, n = a, o = c = null;
397
400
  continue;
398
401
  }
399
- for (let _ = 0; _ + A <= g.length; _ += A) {
400
- const m = g.slice(_, _ + A), M = T ? s : 0, S = T ? n : 0;
401
- let R = null, Q = null;
402
- switch (y) {
402
+ for (let M = 0; M + A <= m.length; M += A) {
403
+ const y = m.slice(M, M + A), _ = b ? s : 0, S = b ? n : 0;
404
+ let R = null, z = null;
405
+ switch (T) {
403
406
  case "M":
404
- _ === 0 ? (s = m[0] + M, n = m[1] + S, r = s, a = n, (h < 0 || e[e.length - 1]?.subpath === h) && h++) : (l(N(s, n, m[0] + M, m[1] + S)), s = m[0] + M, n = m[1] + S);
407
+ M === 0 ? (s = y[0] + _, n = y[1] + S, r = s, a = n, (h < 0 || e[e.length - 1]?.subpath === h) && h++) : (l(q(s, n, y[0] + _, y[1] + S)), s = y[0] + _, n = y[1] + S);
405
408
  break;
406
409
  case "L":
407
- l(N(s, n, m[0] + M, m[1] + S)), s = m[0] + M, n = m[1] + S;
410
+ l(q(s, n, y[0] + _, y[1] + S)), s = y[0] + _, n = y[1] + S;
408
411
  break;
409
412
  case "H":
410
- l(N(s, n, m[0] + M, n)), s = m[0] + M;
413
+ l(q(s, n, y[0] + _, n)), s = y[0] + _;
411
414
  break;
412
415
  case "V":
413
- l(N(s, n, s, m[0] + S)), n = m[0] + S;
416
+ l(q(s, n, s, y[0] + S)), n = y[0] + S;
414
417
  break;
415
418
  case "C": {
416
- const k = [m[0] + M, m[1] + S, m[2] + M, m[3] + S, m[4] + M, m[5] + S];
417
- l(Z(s, n, k)), R = [k[2], k[3]], s = k[4], n = k[5];
419
+ const k = [y[0] + _, y[1] + S, y[2] + _, y[3] + S, y[4] + _, y[5] + S];
420
+ l(K(s, n, k)), R = [k[2], k[3]], s = k[4], n = k[5];
418
421
  break;
419
422
  }
420
423
  case "S": {
421
- const [k, C] = o ? [2 * s - o[0], 2 * n - o[1]] : [s, n], P = [k, C, m[0] + M, m[1] + S, m[2] + M, m[3] + S];
422
- l(Z(s, n, P)), R = [P[2], P[3]], s = P[4], n = P[5];
424
+ const [k, C] = o ? [2 * s - o[0], 2 * n - o[1]] : [s, n], P = [k, C, y[0] + _, y[1] + S, y[2] + _, y[3] + S];
425
+ l(K(s, n, P)), R = [P[2], P[3]], s = P[4], n = P[5];
423
426
  break;
424
427
  }
425
428
  case "Q":
426
429
  case "T": {
427
430
  let k = s, C = n;
428
- y === "Q" ? (k = m[0] + M, C = m[1] + S) : c && (k = 2 * s - c[0], C = 2 * n - c[1]);
429
- const P = y === "Q" ? m[2] + M : m[0] + M, x = y === "Q" ? m[3] + S : m[1] + S;
431
+ T === "Q" ? (k = y[0] + _, C = y[1] + S) : c && (k = 2 * s - c[0], C = 2 * n - c[1]);
432
+ const P = T === "Q" ? y[2] + _ : y[0] + _, v = T === "Q" ? y[3] + S : y[1] + S;
430
433
  l(
431
- Z(s, n, [
434
+ K(s, n, [
432
435
  s + 2 / 3 * (k - s),
433
436
  n + 2 / 3 * (C - n),
434
437
  P + 2 / 3 * (k - P),
435
- x + 2 / 3 * (C - x),
438
+ v + 2 / 3 * (C - v),
436
439
  P,
437
- x
440
+ v
438
441
  ])
439
- ), Q = [k, C], s = P, n = x;
442
+ ), z = [k, C], s = P, n = v;
440
443
  break;
441
444
  }
442
445
  case "A": {
443
- const k = m[5] + M, C = m[6] + S;
444
- let P = s, x = n;
445
- for (const E of Re(s, n, m[0], m[1], m[2], m[3], m[4], k, C))
446
- l(Z(P, x, E)), P = E[4], x = E[5];
446
+ const k = y[5] + _, C = y[6] + S;
447
+ let P = s, v = n;
448
+ for (const B of Ee(s, n, y[0], y[1], y[2], y[3], y[4], k, C))
449
+ l(K(P, v, B)), P = B[4], v = B[5];
447
450
  s = k, n = C;
448
451
  break;
449
452
  }
450
453
  }
451
- o = R, c = Q;
454
+ o = R, c = z;
452
455
  }
453
456
  }
454
- const d = e.reduce((p, g) => p + g.length, 0), f = [];
455
- for (let p = 0; p < e.length; ) {
456
- const g = e[p].subpath;
457
- let y = p, T = 0;
458
- for (; y < e.length && e[y].subpath === g; ) T += e[y++].length;
459
- const A = e[p], _ = e[y - 1], m = u.has(g) || Math.abs(_.endX - A.startX) < 1e-9 && Math.abs(_.endY - A.startY) < 1e-9;
460
- f.push({ start: p, end: y, length: T, closed: m }), p = y;
457
+ const g = e.reduce((d, m) => d + m.length, 0), p = [];
458
+ for (let d = 0; d < e.length; ) {
459
+ const m = e[d].subpath;
460
+ let T = d, b = 0;
461
+ for (; T < e.length && e[T].subpath === m; ) b += e[T++].length;
462
+ const A = e[d], M = e[T - 1], y = u.has(m) || Math.abs(M.endX - A.startX) < 1e-9 && Math.abs(M.endY - A.startY) < 1e-9;
463
+ p.push({ start: d, end: T, length: b, closed: y }), d = T;
461
464
  }
462
- const b = { segments: e, totalLength: d, subpaths: f };
463
- return Y.size >= Pe && Y.delete(Y.keys().next().value), Y.set(i, b), b;
465
+ const f = { segments: e, totalLength: g, subpaths: p };
466
+ return N.size >= xe && N.delete(N.keys().next().value), N.set(i, f), f;
464
467
  }
465
- function De(i, t) {
468
+ function Be(i, t) {
466
469
  const e = i.lengths;
467
470
  if (t <= 0) return 0;
468
471
  if (t >= i.length) return 1;
@@ -474,7 +477,7 @@ function De(i, t) {
474
477
  const r = e[n] - e[s], a = r > 0 ? (t - e[s]) / r : 0;
475
478
  return (s + a) / (e.length - 1);
476
479
  }
477
- function Be(i, t) {
480
+ function Le(i, t) {
478
481
  if (i.type === "L") {
479
482
  const l = i.length > 0 ? Math.max(0, Math.min(1, t / i.length)) : 0;
480
483
  return {
@@ -483,15 +486,15 @@ function Be(i, t) {
483
486
  angle: Math.atan2(i.endY - i.startY, i.endX - i.startX) * 180 / Math.PI
484
487
  };
485
488
  }
486
- const [e, s, n, r, a, o] = i.points, c = De(i, t);
487
- let h = Mt(i.startX, e, n, a, c), u = Mt(i.startY, s, r, o, c);
489
+ const [e, s, n, r, a, o] = i.points, c = Be(i, t);
490
+ let h = kt(i.startX, e, n, a, c), u = kt(i.startY, s, r, o, c);
488
491
  if (Math.hypot(h, u) < 1e-9) {
489
- const l = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), d = B(i.startX, e, n, a, l), f = B(i.startY, s, r, o, l), b = B(i.startX, e, n, a, c), p = B(i.startY, s, r, o, c);
490
- h = c < 0.5 ? d - b : b - d, u = c < 0.5 ? f - p : p - f;
492
+ const l = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), g = E(i.startX, e, n, a, l), p = E(i.startY, s, r, o, l), f = E(i.startX, e, n, a, c), d = E(i.startY, s, r, o, c);
493
+ h = c < 0.5 ? g - f : f - g, u = c < 0.5 ? p - d : d - p;
491
494
  }
492
495
  return {
493
- x: B(i.startX, e, n, a, c),
494
- y: B(i.startY, s, r, o, c),
496
+ x: E(i.startX, e, n, a, c),
497
+ y: E(i.startY, s, r, o, c),
495
498
  angle: Math.atan2(u, h) * 180 / Math.PI
496
499
  };
497
500
  }
@@ -501,20 +504,20 @@ function jt(i, t, e = 0, s = i.length) {
501
504
  for (let r = e; r < s; r++) {
502
505
  const a = i[r];
503
506
  if (n + a.length >= t || r === s - 1)
504
- return Be(a, t - n);
507
+ return Le(a, t - n);
505
508
  n += a.length;
506
509
  }
507
510
  return { x: 0, y: 0, angle: 0 };
508
511
  }
509
- function Ee(i, t) {
510
- const { segments: e, totalLength: s } = J(i);
512
+ function Oe(i, t) {
513
+ const { segments: e, totalLength: s } = tt(i);
511
514
  return jt(e, Math.max(0, Math.min(1, t)) * s);
512
515
  }
513
- const Le = 24, Oe = 320, $e = 2.5, V = 72, Fe = 0.2, Xe = 128, K = /* @__PURE__ */ new Map();
514
- let nt = 0, L;
515
- const kt = (i) => Math.round(i * 100) / 100;
516
- function wt(i, t) {
517
- const { segments: e, subpaths: s, totalLength: n } = J(i);
516
+ const $e = 24, Xe = 320, Fe = 2.5, V = 72, Ye = 0.2, Ne = 128, J = /* @__PURE__ */ new Map();
517
+ let rt = 0, L;
518
+ const wt = (i) => Math.round(i * 100) / 100;
519
+ function Pt(i, t) {
520
+ const { segments: e, subpaths: s, totalLength: n } = tt(i);
518
521
  if (e.length === 0) return [];
519
522
  if (t) {
520
523
  const r = s.every((a) => a.closed);
@@ -526,7 +529,7 @@ function pt(i, t) {
526
529
  const e = i.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)), s = jt(i.segments, e * i.length, i.start, i.end);
527
530
  return [s.x, s.y];
528
531
  }
529
- function Pt(i) {
532
+ function vt(i) {
530
533
  const t = [];
531
534
  let e = 0;
532
535
  for (let s = i.start; s < i.end; s++)
@@ -539,7 +542,7 @@ function xt(i, t) {
539
542
  e.push(pt(i, i.closed ? s / t : s / (t - 1)));
540
543
  return e;
541
544
  }
542
- function vt(i) {
545
+ function Ct(i) {
543
546
  let t = 0, e = 0;
544
547
  for (const [s, n] of i)
545
548
  t += s, e += n;
@@ -549,43 +552,43 @@ function qe(i, t, e) {
549
552
  const s = i.closed && t.closed;
550
553
  if (e !== void 0)
551
554
  return { offset: s ? Math.abs(e) % V / V : 0, reversed: e < 0 };
552
- const n = vt(xt(i, V)), r = vt(xt(t, V)), a = V;
555
+ const n = Ct(xt(i, V)), r = Ct(xt(t, V)), a = V;
553
556
  let o = { offset: 0, reversed: !1 }, c = 1 / 0;
554
557
  for (const h of [!1, !0]) {
555
558
  const u = s ? a : 1;
556
559
  for (let l = 0; l < u; l++) {
557
- let d = 0;
558
- for (let f = 0; f < a && d < c; f++) {
559
- const b = s ? h ? (l - f + a) % a : (f + l) % a : h ? a - 1 - f : f, p = n[f][0] - r[b][0], g = n[f][1] - r[b][1];
560
- d += p * p + g * g;
560
+ let g = 0;
561
+ for (let p = 0; p < a && g < c; p++) {
562
+ const f = s ? h ? (l - p + a) % a : (p + l) % a : h ? a - 1 - p : p, d = n[p][0] - r[f][0], m = n[p][1] - r[f][1];
563
+ g += d * d + m * m;
561
564
  }
562
- d < c && (c = d, o = { offset: s ? l / a : 0, reversed: h });
565
+ g < c && (c = g, o = { offset: s ? l / a : 0, reversed: h });
563
566
  }
564
567
  }
565
568
  return o;
566
569
  }
567
- function Ye(i, t, e) {
570
+ function Ve(i, t, e) {
568
571
  return e ? ((t.reversed ? t.offset - i : i + t.offset) % 1 + 1) % 1 : t.reversed ? 1 - i : i;
569
572
  }
570
- function Ne(i, t, e) {
573
+ function We(i, t, e) {
571
574
  return e ? ((t.reversed ? t.offset - i : i - t.offset) % 1 + 1) % 1 : t.reversed ? 1 - i : i;
572
575
  }
573
- function Ve(i, t, e) {
576
+ function Ue(i, t, e) {
574
577
  const s = i.closed && t.closed, n = qe(i, t, e.shapeIndex), r = Math.max(
575
- Le,
576
- Math.min(Oe, Math.ceil(Math.max(i.length, t.length) / $e))
578
+ $e,
579
+ Math.min(Xe, Math.ceil(Math.max(i.length, t.length) / Fe))
577
580
  ), a = /* @__PURE__ */ new Set(), o = (l) => a.add(Math.round(l * 1e7) / 1e7);
578
581
  for (let l = 0; l <= r; l++) o(l / r);
579
- for (const l of Pt(i)) o(l);
580
- for (const l of Pt(t)) o(Ne(l, n, s));
581
- let c = [...a].sort((l, d) => l - d);
582
+ for (const l of vt(i)) o(l);
583
+ for (const l of vt(t)) o(We(l, n, s));
584
+ let c = [...a].sort((l, g) => l - g);
582
585
  s && (c = c.filter((l) => l < 1));
583
586
  const h = [], u = [];
584
587
  for (const l of c)
585
- h.push(...pt(i, l)), u.push(...pt(t, Ye(l, n, s)));
586
- return We({ from: h, to: u, closed: s });
588
+ h.push(...pt(i, l)), u.push(...pt(t, Ve(l, n, s)));
589
+ return He({ from: h, to: u, closed: s });
587
590
  }
588
- function We(i) {
591
+ function He(i) {
589
592
  const t = i.from.length / 2;
590
593
  if (t <= 3) return i;
591
594
  const e = new Uint8Array(t);
@@ -593,9 +596,9 @@ function We(i) {
593
596
  const s = [[0, t - 1]];
594
597
  for (; s.length > 0; ) {
595
598
  const [a, o] = s.pop();
596
- let c = -1, h = Fe;
599
+ let c = -1, h = Ye;
597
600
  for (let u = a + 1; u < o; u++) {
598
- const l = Math.max(Ct(i.from, a, o, u), Ct(i.to, a, o, u));
601
+ const l = Math.max(It(i.from, a, o, u), It(i.to, a, o, u));
599
602
  l > h && (h = l, c = u);
600
603
  }
601
604
  c !== -1 && (e[c] = 1, s.push([a, c], [c, o]));
@@ -605,77 +608,109 @@ function We(i) {
605
608
  e[a] && (n.push(i.from[a * 2], i.from[a * 2 + 1]), r.push(i.to[a * 2], i.to[a * 2 + 1]));
606
609
  return { from: n, to: r, closed: i.closed };
607
610
  }
608
- function Ct(i, t, e, s) {
611
+ function It(i, t, e, s) {
609
612
  const n = i[t * 2], r = i[t * 2 + 1], a = i[e * 2] - n, o = i[e * 2 + 1] - r, c = i[s * 2] - n, h = i[s * 2 + 1] - r, u = a * a + o * o, l = u === 0 ? 0 : Math.max(0, Math.min(1, (c * a + h * o) / u));
610
613
  return Math.hypot(c - l * a, h - l * o);
611
614
  }
612
- function Ue(i, t, e) {
615
+ function Qe(i, t, e) {
613
616
  const s = e.shapeIndex;
614
617
  if (L && L.from === i && L.to === t && L.shapeIndex === s) return L.plan;
615
- const r = K.get(String(s ?? "auto"))?.get(i)?.get(t);
618
+ const r = J.get(String(s ?? "auto"))?.get(i)?.get(t);
616
619
  if (r)
617
620
  return L = { from: i, to: t, shapeIndex: s, plan: r }, r;
618
- const a = J(i).subpaths.filter((f) => f.length > 0).length === J(t).subpaths.filter((f) => f.length > 0).length, o = wt(i, !a), c = wt(t, !a), h = {
619
- pairs: o.map((f, b) => Ve(f, c[b], e))
621
+ const a = tt(i).subpaths.filter((p) => p.length > 0).length === tt(t).subpaths.filter((p) => p.length > 0).length, o = Pt(i, !a), c = Pt(t, !a), h = {
622
+ pairs: o.map((p, f) => Ue(p, c[f], e))
620
623
  };
621
- nt >= Xe && (K.clear(), nt = 0);
622
- const u = String(s ?? "auto"), l = K.get(u) ?? /* @__PURE__ */ new Map();
623
- K.set(u, l);
624
- const d = l.get(i) ?? /* @__PURE__ */ new Map();
625
- return l.set(i, d), d.set(t, h), nt++, L = { from: i, to: t, shapeIndex: s, plan: h }, h;
624
+ rt >= Ne && (J.clear(), rt = 0);
625
+ const u = String(s ?? "auto"), l = J.get(u) ?? /* @__PURE__ */ new Map();
626
+ J.set(u, l);
627
+ const g = l.get(i) ?? /* @__PURE__ */ new Map();
628
+ return l.set(i, g), g.set(t, h), rt++, L = { from: i, to: t, shapeIndex: s, plan: h }, h;
626
629
  }
627
- function He(i, t, e, s = {}) {
630
+ function ze(i, t, e, s = {}) {
628
631
  if (!i) return t;
629
632
  if (!t) return i;
630
633
  const n = Math.max(0, Math.min(1, e));
631
634
  if (n === 0) return i;
632
635
  if (n === 1) return t;
633
- const r = Ue(i, t, s);
636
+ const r = Qe(i, t, s);
634
637
  if (r.pairs.length === 0) return n < 0.5 ? i : t;
635
638
  let a = "";
636
639
  for (const o of r.pairs) {
637
640
  for (let c = 0; c < o.from.length; c += 2) {
638
- const h = kt(o.from[c] + (o.to[c] - o.from[c]) * n), u = kt(o.from[c + 1] + (o.to[c + 1] - o.from[c + 1]) * n);
641
+ const h = wt(o.from[c] + (o.to[c] - o.from[c]) * n), u = wt(o.from[c + 1] + (o.to[c + 1] - o.from[c + 1]) * n);
639
642
  a += `${c === 0 ? a ? " M" : "M" : " L"}${h} ${u}`;
640
643
  }
641
644
  o.closed && (a += " Z");
642
645
  }
643
646
  return a;
644
647
  }
645
- function Qe(i) {
648
+ function je(i) {
646
649
  return /^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(i);
647
650
  }
648
- const D = (i, t, e) => i + (t - i) * e, zt = 512, rt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map();
649
- function It(i) {
650
- const t = rt.get(i);
651
+ const Ge = 0.9995;
652
+ function Ze() {
653
+ return [0, 0, 0, 1];
654
+ }
655
+ function Ke(i, t) {
656
+ return i[0] * t[0] + i[1] * t[1] + i[2] * t[2] + i[3] * t[3];
657
+ }
658
+ function Je(i) {
659
+ return Math.hypot(i[0], i[1], i[2], i[3]);
660
+ }
661
+ function H(i) {
662
+ const t = Je(i);
663
+ return t === 0 ? Ze() : [i[0] / t, i[1] / t, i[2] / t, i[3] / t];
664
+ }
665
+ function ti(i, t, e) {
666
+ const s = H(i);
667
+ let n = H(t), r = Ke(s, n);
668
+ if (r < 0 && (n = [-n[0], -n[1], -n[2], -n[3]], r = -r), r > Ge)
669
+ return H([
670
+ s[0] + (n[0] - s[0]) * e,
671
+ s[1] + (n[1] - s[1]) * e,
672
+ s[2] + (n[2] - s[2]) * e,
673
+ s[3] + (n[3] - s[3]) * e
674
+ ]);
675
+ const a = Math.acos(r), o = Math.sin(a), c = Math.sin((1 - e) * a) / o, h = Math.sin(e * a) / o;
676
+ return H([
677
+ s[0] * c + n[0] * h,
678
+ s[1] * c + n[1] * h,
679
+ s[2] * c + n[2] * h,
680
+ s[3] * c + n[3] * h
681
+ ]);
682
+ }
683
+ const D = (i, t, e) => i + (t - i) * e, Gt = 512, at = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Map();
684
+ function Rt(i) {
685
+ const t = at.get(i);
651
686
  if (t) return t;
652
687
  const e = i.replace("#", ""), s = [
653
688
  parseInt(e.slice(0, 2), 16),
654
689
  parseInt(e.slice(2, 4), 16),
655
690
  parseInt(e.slice(4, 6), 16)
656
691
  ];
657
- return rt.size < zt && rt.set(i, s), s;
692
+ return at.size < Gt && at.set(i, s), s;
658
693
  }
659
- const Rt = (i) => i.charCodeAt(0) === 35, Dt = (i) => i.startsWith("rgb"), Bt = (i) => i.startsWith("rgba"), je = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, ot = (i) => Math.round(i).toString(16).padStart(2, "0");
660
- function ze(i, t, e) {
661
- return `#${ot(i)}${ot(t)}${ot(e)}`;
694
+ const Dt = (i) => i.charCodeAt(0) === 35, Et = (i) => i.startsWith("rgb"), Bt = (i) => i.startsWith("rgba"), ei = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, ct = (i) => Math.round(i).toString(16).padStart(2, "0");
695
+ function ii(i, t, e) {
696
+ return `#${ct(i)}${ct(t)}${ct(e)}`;
662
697
  }
663
- function Et(i) {
664
- const t = at.get(i);
698
+ function Lt(i) {
699
+ const t = ot.get(i);
665
700
  if (t) return t;
666
- const e = i.match(je);
701
+ const e = i.match(ei);
667
702
  if (!e)
668
703
  throw new Error(`Invalid rgb color: ${i}`);
669
704
  const s = parseInt(e[1], 10), n = parseInt(e[2], 10), r = parseInt(e[3], 10), a = e[4] !== void 0 ? [s, n, r, parseFloat(e[4])] : [s, n, r];
670
- return at.size < zt && at.set(i, a), a;
705
+ return ot.size < Gt && ot.set(i, a), a;
671
706
  }
672
- const Ge = (i, t, e) => {
673
- if (Rt(i) && Rt(t)) {
674
- const [s, n, r] = It(i), [a, o, c] = It(t), h = D(s, a, e), u = D(n, o, e), l = D(r, c, e);
675
- return ze(h, u, l);
707
+ const si = (i, t, e) => {
708
+ if (Dt(i) && Dt(t)) {
709
+ const [s, n, r] = Rt(i), [a, o, c] = Rt(t), h = D(s, a, e), u = D(n, o, e), l = D(r, c, e);
710
+ return ii(h, u, l);
676
711
  }
677
- if ((Dt(i) || Bt(i)) && (Dt(t) || Bt(t))) {
678
- const s = Et(i), n = Et(t), r = Math.round(D(s[0], n[0], e)), a = Math.round(D(s[1], n[1], e)), o = Math.round(D(s[2], n[2], e));
712
+ if ((Et(i) || Bt(i)) && (Et(t) || Bt(t))) {
713
+ const s = Lt(i), n = Lt(t), r = Math.round(D(s[0], n[0], e)), a = Math.round(D(s[1], n[1], e)), o = Math.round(D(s[2], n[2], e));
679
714
  if (s.length === 4 || n.length === 4) {
680
715
  const c = s[3] ?? 1, h = n[3] ?? 1, u = D(c, h, e);
681
716
  return `rgba(${r}, ${a}, ${o}, ${u})`;
@@ -683,16 +718,16 @@ const Ge = (i, t, e) => {
683
718
  return `rgb(${r}, ${a}, ${o})`;
684
719
  }
685
720
  return e < 1 ? i : t;
686
- }, Ze = (i, t, e) => {
721
+ }, ni = (i, t, e) => {
687
722
  const s = Math.min(i.length, t.length), n = [];
688
723
  for (let r = 0; r < s; r++)
689
724
  n.push(D(i[r], t[r], e));
690
725
  return n;
691
- }, Lt = (i, t, e) => e < 1 ? i : t, Ke = (i, t, e) => He(i, t, e);
692
- function Je(i) {
693
- return typeof i == "number" ? D : Array.isArray(i) ? Ze : typeof i == "string" ? i.startsWith("#") || i.startsWith("rgb") ? Ge : Qe(i) ? Ke : Lt : Lt;
726
+ }, ri = (i, t, e) => ti(i, t, e), Ot = (i, t, e) => e < 1 ? i : t, ai = (i, t, e) => ze(i, t, e);
727
+ function oi(i, t) {
728
+ return t === "slerp" ? ri : typeof i == "number" ? D : Array.isArray(i) ? ni : typeof i == "string" ? i.startsWith("#") || i.startsWith("rgb") ? si : je(i) ? ai : Ot : Ot;
694
729
  }
695
- function ti(i) {
730
+ function ci(i) {
696
731
  const t = [...i.keyframes].sort((e, s) => e.time - s.time);
697
732
  return {
698
733
  ...i,
@@ -702,11 +737,11 @@ function ti(i) {
702
737
  function O(i) {
703
738
  return i.targets && i.targets.length > 0 ? i.targets : [i.target];
704
739
  }
705
- function X(i, t, e, s) {
740
+ function F(i, t, e, s) {
706
741
  const n = e ?? 0;
707
- return !s || t <= 1 ? n : n + Yt(i, t, s);
742
+ return !s || t <= 1 ? n : n + qt(i, t, s);
708
743
  }
709
- class ct {
744
+ class ht {
710
745
  track;
711
746
  targets;
712
747
  constructor(t) {
@@ -719,7 +754,7 @@ class ct {
719
754
  * that need every target should use `getTargetValues`.
720
755
  */
721
756
  getValueAtTime(t) {
722
- return this.valueForOffset(t - X(0, this.targets.length, this.track.delay, this.track.stagger));
757
+ return this.valueForOffset(t - F(0, this.targets.length, this.track.delay, this.track.stagger));
723
758
  }
724
759
  /**
725
760
  * Every target's value at a specific time, in target order.
@@ -730,7 +765,7 @@ class ct {
730
765
  getTargetValues(t) {
731
766
  const e = this.targets.length, s = [];
732
767
  for (let n = 0; n < e; n++) {
733
- const r = X(n, e, this.track.delay, this.track.stagger), a = this.valueForOffset(t - r);
768
+ const r = F(n, e, this.track.delay, this.track.stagger), a = this.valueForOffset(t - r);
734
769
  a !== void 0 && s.push({ target: this.targets[n], value: a, start: r + this.track.keyframes[0].time });
735
770
  }
736
771
  return s;
@@ -766,8 +801,8 @@ class ct {
766
801
  return;
767
802
  if (s.time === t)
768
803
  return s.value;
769
- const r = n.time - s.time, a = (t - s.time) / r, c = we(n.easing)(a);
770
- return Je(s.value)(s.value, n.value, c);
804
+ const r = n.time - s.time, a = (t - s.time) / r, c = ve(n.easing)(a);
805
+ return oi(s.value, this.track.interpolation)(s.value, n.value, c);
771
806
  }
772
807
  /**
773
808
  * Find the keyframes surrounding a given time.
@@ -780,20 +815,20 @@ class ct {
780
815
  return { from: null, to: null };
781
816
  }
782
817
  }
783
- class ei {
818
+ class hi {
784
819
  track;
785
820
  targets;
786
821
  sampler;
787
822
  constructor(t) {
788
- this.track = t, this.targets = O(t), this.sampler = new ae(t.spring);
823
+ this.track = t, this.targets = O(t), this.sampler = new ce(t.spring);
789
824
  }
790
825
  getValueAtTime(t) {
791
- return this.sampler.valueAt(t - X(0, this.targets.length, this.track.delay, this.track.stagger));
826
+ return this.sampler.valueAt(t - F(0, this.targets.length, this.track.delay, this.track.stagger));
792
827
  }
793
828
  getTargetValues(t) {
794
829
  const e = this.targets.length, s = [];
795
830
  for (let n = 0; n < e; n++) {
796
- const r = X(n, e, this.track.delay, this.track.stagger);
831
+ const r = F(n, e, this.track.delay, this.track.stagger);
797
832
  s.push({ target: this.targets[n], value: this.sampler.valueAt(t - r), start: r });
798
833
  }
799
834
  return s;
@@ -807,21 +842,21 @@ class ei {
807
842
  return this.track;
808
843
  }
809
844
  }
810
- class ii {
845
+ class li {
811
846
  track;
812
847
  targets;
813
848
  duration;
814
849
  constructor(t) {
815
- this.track = t, this.targets = O(t), this.duration = Wt(t.inertia);
850
+ this.track = t, this.targets = O(t), this.duration = Ut(t.inertia);
816
851
  }
817
852
  getValueAtTime(t) {
818
- return St(this.track.inertia, t - X(0, this.targets.length, this.track.delay, this.track.stagger));
853
+ return Mt(this.track.inertia, t - F(0, this.targets.length, this.track.delay, this.track.stagger));
819
854
  }
820
855
  getTargetValues(t) {
821
856
  const e = this.targets.length, s = [];
822
857
  for (let n = 0; n < e; n++) {
823
- const r = X(n, e, this.track.delay, this.track.stagger);
824
- s.push({ target: this.targets[n], value: St(this.track.inertia, t - r), start: r });
858
+ const r = F(n, e, this.track.delay, this.track.stagger);
859
+ s.push({ target: this.targets[n], value: Mt(this.track.inertia, t - r), start: r });
825
860
  }
826
861
  return s;
827
862
  }
@@ -834,49 +869,49 @@ class ii {
834
869
  return this.track;
835
870
  }
836
871
  }
837
- function si(i, t) {
838
- const e = { ...Ee(i.pathData, t) };
872
+ function ui(i, t) {
873
+ const e = { ...Oe(i.pathData, t) };
839
874
  if (i.matrix) {
840
875
  const [s, n, r, a, o, c] = i.matrix, { x: h, y: u } = e;
841
876
  e.x = s * h + r * u + o, e.y = n * h + a * u + c;
842
- const l = e.angle * Math.PI / 180, d = Math.cos(l), f = Math.sin(l);
843
- e.angle = Math.atan2(n * d + a * f, s * d + r * f) * 180 / Math.PI;
877
+ const l = e.angle * Math.PI / 180, g = Math.cos(l), p = Math.sin(l);
878
+ e.angle = Math.atan2(n * g + a * p, s * g + r * p) * 180 / Math.PI;
844
879
  }
845
880
  return i.autoRotate && i.rotateOffset && (e.angle += i.rotateOffset), e;
846
881
  }
847
- const ht = {
882
+ const lt = {
848
883
  upperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
849
884
  lowerCase: "abcdefghijklmnopqrstuvwxyz",
850
885
  upperAndLowerCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
851
886
  numbers: "0123456789"
852
- }, ni = 20;
853
- function ri(i) {
854
- const t = ht[i ?? "upperCase"] ?? i ?? ht.upperCase, e = Array.from(t);
855
- return e.length > 0 ? e : Array.from(ht.upperCase);
887
+ }, di = 20;
888
+ function fi(i) {
889
+ const t = lt[i ?? "upperCase"] ?? i ?? lt.upperCase, e = Array.from(t);
890
+ return e.length > 0 ? e : Array.from(lt.upperCase);
856
891
  }
857
- function ai(i, t, e) {
892
+ function pi(i, t, e) {
858
893
  let s = (i | 0) ^ Math.imul(t + 1, 2654435761) ^ Math.imul(e + 1, 2246822507);
859
894
  return s = Math.imul(s ^ s >>> 16, 2146121005), s = Math.imul(s ^ s >>> 15, 2221713035), (s ^ s >>> 16) >>> 0;
860
895
  }
861
- function oi(i, t, e = 0) {
896
+ function mi(i, t, e = 0) {
862
897
  const s = i.from ?? "", n = i.to, r = Math.max(0, Math.min(1, t));
863
898
  if (r <= 0) return s;
864
899
  if (r >= 1) return n;
865
900
  const a = Array.from(s), o = Array.from(n), c = i.rightToLeft ?? !1;
866
901
  if (i.mode === "type") {
867
- const T = Math.round(r * Math.max(a.length, o.length));
868
- return c ? a.slice(0, Math.max(0, a.length - T)).join("") + o.slice(Math.max(0, o.length - T)).join("") : o.slice(0, T).join("") + a.slice(T).join("");
902
+ const b = Math.round(r * Math.max(a.length, o.length));
903
+ 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("");
869
904
  }
870
- const h = Math.max(0, Math.min(0.999, i.revealDelay ?? 0)), u = Math.max(0, (r - h) / (1 - h)), l = Math.floor(u * o.length), d = i.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), f = ri(i.chars), b = i.refreshRate ?? ni, p = b > 0 ? Math.floor(e * b / 1e3) : 0, g = i.seed ?? 1;
871
- let y = "";
872
- for (let T = 0; T < d; T++) {
873
- const A = c ? T >= d - l : T < l, _ = c ? o[o.length - (d - T)] : o[T];
874
- A && _ !== void 0 || _ === " " || _ === `
875
- ` ? y += _ : y += f[ai(g, T, p) % f.length];
905
+ const h = Math.max(0, Math.min(0.999, i.revealDelay ?? 0)), u = Math.max(0, (r - h) / (1 - h)), l = Math.floor(u * o.length), g = i.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), p = fi(i.chars), f = i.refreshRate ?? di, d = f > 0 ? Math.floor(e * f / 1e3) : 0, m = i.seed ?? 1;
906
+ let T = "";
907
+ for (let b = 0; b < g; b++) {
908
+ const A = c ? b >= g - l : b < l, M = c ? o[o.length - (g - b)] : o[b];
909
+ A && M !== void 0 || M === " " || M === `
910
+ ` ? T += M : T += p[pi(m, b, d) % p.length];
876
911
  }
877
- return y;
912
+ return T;
878
913
  }
879
- class ci {
914
+ class gi {
880
915
  id;
881
916
  name;
882
917
  _captions;
@@ -1057,8 +1092,8 @@ class ci {
1057
1092
  for (const [n, r] of this._trackPlayers) {
1058
1093
  const a = r.getTrack().property;
1059
1094
  for (const { target: o, value: c, start: h } of r.getTargetValues(t)) {
1060
- const u = `${o}\0${a}`, l = h <= t, d = s.get(u);
1061
- (!d || (l !== d.started ? l : l ? h >= d.start : h <= d.start)) && s.set(u, { trackId: n, target: o, property: a, value: c, start: h, started: l });
1095
+ const u = `${o}\0${a}`, l = h <= t, g = s.get(u);
1096
+ (!g || (l !== g.started ? l : l ? h >= g.start : h <= g.start)) && s.set(u, { trackId: n, target: o, property: a, value: c, start: h, started: l });
1062
1097
  }
1063
1098
  }
1064
1099
  for (const { trackId: n, target: r, property: a, value: o, start: c } of s.values())
@@ -1075,12 +1110,12 @@ class ci {
1075
1110
  o || (o = /* @__PURE__ */ new Map(), t.set(s, o));
1076
1111
  const c = this._textTracks.get(e);
1077
1112
  if (c && typeof r == "number") {
1078
- o.set("text", oi(c.textConfig, r, Math.max(0, a)));
1113
+ o.set("text", mi(c.textConfig, r, Math.max(0, a)));
1079
1114
  return;
1080
1115
  }
1081
1116
  const h = this._motionPathTracks.get(e);
1082
1117
  if (h && typeof r == "number") {
1083
- const u = si(h.motionPathConfig, r);
1118
+ const u = ui(h.motionPathConfig, r);
1084
1119
  o.set("motionPathX", u.x), o.set("motionPathY", u.y), h.motionPathConfig.autoRotate && o.set("motionPathRotate", u.angle);
1085
1120
  } else
1086
1121
  o.set(n, r);
@@ -1108,16 +1143,16 @@ class ci {
1108
1143
  */
1109
1144
  addTrack(t) {
1110
1145
  if (this._tracks.push(t), this._sharedWrites = null, ut(t)) {
1111
- this._trackPlayers.set(t.id, new ii(t));
1146
+ this._trackPlayers.set(t.id, new li(t));
1112
1147
  return;
1113
1148
  }
1114
1149
  if (dt(t)) {
1115
- this._trackPlayers.set(t.id, new ei(t)), this._springTracks.set(t.id, t);
1150
+ this._trackPlayers.set(t.id, new hi(t)), this._springTracks.set(t.id, t);
1116
1151
  return;
1117
1152
  }
1118
- if (Xt(t))
1119
- this._trackPlayers.set(t.id, new ct(t)), this._textTracks.set(t.id, t);
1120
- else if (se(t)) {
1153
+ if (Yt(t))
1154
+ this._trackPlayers.set(t.id, new ht(t)), this._textTracks.set(t.id, t);
1155
+ else if (re(t)) {
1121
1156
  const e = {
1122
1157
  id: t.id,
1123
1158
  target: t.target,
@@ -1128,9 +1163,9 @@ class ci {
1128
1163
  targets: t.targets,
1129
1164
  stagger: t.stagger
1130
1165
  };
1131
- this._trackPlayers.set(t.id, new ct(e)), this._motionPathTracks.set(t.id, t);
1166
+ this._trackPlayers.set(t.id, new ht(e)), this._motionPathTracks.set(t.id, t);
1132
1167
  } else
1133
- this._trackPlayers.set(t.id, new ct(t));
1168
+ this._trackPlayers.set(t.id, new ht(t));
1134
1169
  }
1135
1170
  /**
1136
1171
  * Replace a track with a new version, keeping its place in the track order
@@ -1232,7 +1267,7 @@ class ci {
1232
1267
  */
1233
1268
  toDefinition() {
1234
1269
  return {
1235
- formatVersion: lt,
1270
+ formatVersion: ne(this._tracks),
1236
1271
  id: this.id,
1237
1272
  name: this.name,
1238
1273
  config: { ...this._config },
@@ -1290,25 +1325,25 @@ class ci {
1290
1325
  return this._config.alternate && (t === -1 || this._loopIteration < t) ? (this._loopIteration++, this._armRepeatDelay(), this._direction = "forward", this._repeatDelayRemaining === 0) : (this._playbackState = "idle", this.onComplete?.(), !1);
1291
1326
  }
1292
1327
  }
1293
- const hi = 100;
1294
- function li(i, t, e, s) {
1295
- const n = [], r = [], { duration: a, alternate: o } = s, c = (f, b, p, g) => {
1296
- r.push([f, b]);
1297
- const y = [];
1298
- i.forEach((T, A) => {
1299
- (p === "forward" ? (g ? T >= f : T > f) && T <= b : (g ? T <= f : T < f) && T >= b) && y.push(A);
1300
- }), y.sort((T, A) => (p === "forward" ? i[T] - i[A] : i[A] - i[T]) || T - A);
1301
- for (const T of y) n.push({ kind: "event", index: T, direction: p });
1328
+ const yi = 100;
1329
+ function Ti(i, t, e, s) {
1330
+ const n = [], r = [], { duration: a, alternate: o } = s, c = (p, f, d, m) => {
1331
+ r.push([p, f]);
1332
+ const T = [];
1333
+ i.forEach((b, A) => {
1334
+ (d === "forward" ? (m ? b >= p : b > p) && b <= f : (m ? b <= p : b < p) && b >= f) && T.push(A);
1335
+ }), T.sort((b, A) => (d === "forward" ? i[b] - i[A] : i[A] - i[b]) || b - A);
1336
+ for (const b of T) n.push({ kind: "event", index: b, direction: d });
1302
1337
  };
1303
1338
  let h = t.time, u = t.direction, l = t.fresh === !0;
1304
- const d = Math.min(hi, Math.max(0, e.iteration - t.iteration));
1305
- for (let f = 0; f < d; f++) {
1306
- const b = u === "forward" ? a : 0;
1307
- c(h, b, u, l), n.push({ kind: "repeat" }), o ? (u = u === "forward" ? "reverse" : "forward", h = b, l = !1) : (h = u === "forward" ? 0 : a, l = !0);
1339
+ const g = Math.min(yi, Math.max(0, e.iteration - t.iteration));
1340
+ for (let p = 0; p < g; p++) {
1341
+ const f = u === "forward" ? a : 0;
1342
+ c(h, f, u, l), n.push({ kind: "repeat" }), o ? (u = u === "forward" ? "reverse" : "forward", h = f, l = !1) : (h = u === "forward" ? 0 : a, l = !0);
1308
1343
  }
1309
- return d > 0 && s.holding && !o ? { crossings: n, passes: r } : (c(h, e.time, u, l), { crossings: n, passes: r });
1344
+ return g > 0 && s.holding && !o ? { crossings: n, passes: r } : (c(h, e.time, u, l), { crossings: n, passes: r });
1310
1345
  }
1311
- function ui(i) {
1346
+ function bi(i) {
1312
1347
  return { ...i, ...Array.isArray(i.end) && { end: [...i.end] } };
1313
1348
  }
1314
1349
  function W(i) {
@@ -1320,7 +1355,7 @@ function W(i) {
1320
1355
  ...i.stagger !== void 0 && { stagger: { ...i.stagger } }
1321
1356
  };
1322
1357
  }
1323
- function di(i) {
1358
+ function Ai(i) {
1324
1359
  if (ut(i)) {
1325
1360
  const t = i;
1326
1361
  return {
@@ -1328,7 +1363,7 @@ function di(i) {
1328
1363
  target: t.target,
1329
1364
  property: t.property,
1330
1365
  kind: "inertia",
1331
- inertia: ui(t.inertia),
1366
+ inertia: bi(t.inertia),
1332
1367
  ...W(t)
1333
1368
  };
1334
1369
  }
@@ -1343,7 +1378,7 @@ function di(i) {
1343
1378
  ...W(t)
1344
1379
  };
1345
1380
  }
1346
- if (Xt(i)) {
1381
+ if (Yt(i)) {
1347
1382
  const t = i;
1348
1383
  return {
1349
1384
  id: t.id,
@@ -1365,29 +1400,54 @@ function di(i) {
1365
1400
  ...W(t)
1366
1401
  };
1367
1402
  }
1368
- return ti({
1403
+ return ci({
1369
1404
  id: i.id,
1370
1405
  target: i.target,
1371
1406
  property: i.property,
1372
1407
  keyframes: i.keyframes,
1408
+ ...i.interpolation !== void 0 && { interpolation: i.interpolation },
1373
1409
  ...W(i)
1374
1410
  });
1375
1411
  }
1376
- function tt(i) {
1412
+ function et(i) {
1377
1413
  const t = i.formatVersion ?? 1;
1378
- if (t > lt)
1414
+ if (t > At)
1379
1415
  throw new Error(
1380
- `tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${lt}. Update tinyfly to play it.`
1416
+ `tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${At}. Update tinyfly to play it.`
1381
1417
  );
1382
- return new ci({
1418
+ return new gi({
1383
1419
  id: i.id,
1384
1420
  name: i.name,
1385
1421
  config: i.config,
1386
- tracks: i.tracks.map(di),
1422
+ tracks: i.tracks.map(Ai),
1387
1423
  captions: i.captions
1388
1424
  });
1389
1425
  }
1390
- const fi = /* @__PURE__ */ new Set([
1426
+ function Si(i) {
1427
+ const [t, e, s, n] = i;
1428
+ return [
1429
+ 1 - 2 * (e * e + s * s),
1430
+ 2 * (t * e + s * n),
1431
+ 2 * (t * s - e * n),
1432
+ 0,
1433
+ 2 * (t * e - s * n),
1434
+ 1 - 2 * (t * t + s * s),
1435
+ 2 * (e * s + t * n),
1436
+ 0,
1437
+ 2 * (t * s + e * n),
1438
+ 2 * (e * s - t * n),
1439
+ 1 - 2 * (t * t + e * e),
1440
+ 0,
1441
+ 0,
1442
+ 0,
1443
+ 0,
1444
+ 1
1445
+ ];
1446
+ }
1447
+ function Mi(i) {
1448
+ return !Array.isArray(i) || i.length !== 4 ? null : `matrix3d(${Si(H(i)).map((e) => Math.round(e * 1e6) / 1e6 + 0).join(", ")})`;
1449
+ }
1450
+ const _i = /* @__PURE__ */ new Set([
1391
1451
  "blur",
1392
1452
  "brightness",
1393
1453
  "glow",
@@ -1396,16 +1456,16 @@ const fi = /* @__PURE__ */ new Set([
1396
1456
  "shadowY",
1397
1457
  "shadowBlur",
1398
1458
  "shadowColor"
1399
- ]), pi = "#ffffff", mi = "rgba(0, 0, 0, 0.5)";
1400
- function gi(i) {
1459
+ ]), ki = "#ffffff", wi = "rgba(0, 0, 0, 0.5)";
1460
+ function Pi(i) {
1401
1461
  const t = [];
1402
- if (i.blur !== void 0 && t.push(`blur(${Math.max(0, i.blur)}px)`), i.brightness !== void 0 && t.push(`brightness(${Math.max(0, i.brightness)})`), i.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, i.glow)}px ${i.glowColor ?? pi})`), i.shadowX !== void 0 || i.shadowY !== void 0 || i.shadowBlur !== void 0) {
1462
+ if (i.blur !== void 0 && t.push(`blur(${Math.max(0, i.blur)}px)`), i.brightness !== void 0 && t.push(`brightness(${Math.max(0, i.brightness)})`), i.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, i.glow)}px ${i.glowColor ?? ki})`), i.shadowX !== void 0 || i.shadowY !== void 0 || i.shadowBlur !== void 0) {
1403
1463
  const e = i.shadowX ?? 0, s = i.shadowY ?? 0, n = Math.max(0, i.shadowBlur ?? 0);
1404
- t.push(`drop-shadow(${e}px ${s}px ${n}px ${i.shadowColor ?? mi})`);
1464
+ t.push(`drop-shadow(${e}px ${s}px ${n}px ${i.shadowColor ?? wi})`);
1405
1465
  }
1406
1466
  return t.length > 0 ? t.join(" ") : null;
1407
1467
  }
1408
- function yi(i, t) {
1468
+ function vi(i, t) {
1409
1469
  const e = i.childNodes.length === 1 ? i.firstChild : null;
1410
1470
  if (e && e.nodeType === 3) {
1411
1471
  const s = e;
@@ -1414,12 +1474,12 @@ function yi(i, t) {
1414
1474
  }
1415
1475
  i.textContent !== t && (i.textContent = t);
1416
1476
  }
1417
- function Ti(i) {
1477
+ function xi(i) {
1418
1478
  if (!("ownerSVGElement" in i)) return;
1419
1479
  const t = i.style;
1420
1480
  !t || t.transformBox || (t.transformBox = "fill-box", t.transformOrigin || (t.transformOrigin = "50% 50%"));
1421
1481
  }
1422
- const Ot = /* @__PURE__ */ new Set([
1482
+ const $t = /* @__PURE__ */ new Set([
1423
1483
  "width",
1424
1484
  "height",
1425
1485
  "top",
@@ -1445,7 +1505,7 @@ const Ot = /* @__PURE__ */ new Set([
1445
1505
  "gap",
1446
1506
  "rowGap",
1447
1507
  "columnGap"
1448
- ]), bi = /* @__PURE__ */ new Set([
1508
+ ]), Ci = /* @__PURE__ */ new Set([
1449
1509
  "x",
1450
1510
  "y",
1451
1511
  "z",
@@ -1459,18 +1519,38 @@ const Ot = /* @__PURE__ */ new Set([
1459
1519
  "scaleZ",
1460
1520
  "skewX",
1461
1521
  "skewY",
1522
+ // A rotation as an [x, y, z, w] quaternion (a track with `interpolation: 'slerp'`)
1523
+ "quaternion",
1462
1524
  // Motion path properties
1463
1525
  "motionPathX",
1464
1526
  "motionPathY",
1465
1527
  "motionPathRotate"
1466
- ]), Ai = /* @__PURE__ */ new Set(["originX", "originY"]), Si = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]), _i = /* @__PURE__ */ new Set(["drawOn"]), Mi = {
1528
+ ]), Ii = [
1529
+ "x",
1530
+ "motionPathX",
1531
+ "y",
1532
+ "motionPathY",
1533
+ "z",
1534
+ "rotate",
1535
+ "rotateZ",
1536
+ "motionPathRotate",
1537
+ "rotateX",
1538
+ "rotateY",
1539
+ "quaternion",
1540
+ "scale",
1541
+ "scaleX",
1542
+ "scaleY",
1543
+ "scaleZ",
1544
+ "skewX",
1545
+ "skewY"
1546
+ ], Ri = /* @__PURE__ */ new Set(["childPerspective", "perspectiveOriginX", "perspectiveOriginY"]), Di = /* @__PURE__ */ new Set(["originX", "originY"]), Ei = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]), Bi = /* @__PURE__ */ new Set(["drawOn"]), Li = {
1467
1547
  fill: "backgroundColor",
1468
1548
  stroke: "borderColor",
1469
1549
  strokeWidth: "borderWidth",
1470
1550
  color: "color",
1471
1551
  backgroundColor: "backgroundColor",
1472
1552
  borderColor: "borderColor"
1473
- }, $t = {
1553
+ }, Xt = {
1474
1554
  fill: "fill",
1475
1555
  stroke: "stroke",
1476
1556
  strokeWidth: "strokeWidth",
@@ -1478,8 +1558,8 @@ const Ot = /* @__PURE__ */ new Set([
1478
1558
  strokeDashoffset: "strokeDashoffset",
1479
1559
  fillOpacity: "fillOpacity",
1480
1560
  strokeOpacity: "strokeOpacity"
1481
- }, ki = "http://www.w3.org/2000/svg";
1482
- class H {
1561
+ }, Oi = "http://www.w3.org/2000/svg";
1562
+ class Q {
1483
1563
  targets = /* @__PURE__ */ new Map();
1484
1564
  /**
1485
1565
  * Register an HTML element as an animation target.
@@ -1518,50 +1598,58 @@ class H {
1518
1598
  * Apply properties to a single element.
1519
1599
  */
1520
1600
  applyProperties(t, e) {
1521
- const s = [];
1522
- let n = null, r = null, a = null;
1523
- const o = e.has("motionPathX"), c = e.has("motionPathY"), h = e.has("motionPathRotate");
1524
- for (const [d, f] of e)
1525
- if (!(d === "x" && o) && !(d === "y" && c) && !((d === "rotate" || d === "rotateZ") && h) && !_i.has(d)) {
1526
- if (bi.has(d)) {
1527
- const b = this.buildTransformPart(d, f);
1528
- b && s.push(b);
1529
- } else if (Ai.has(d))
1530
- typeof f == "number" && ((n ??= {})[d] = f);
1531
- else if (Si.has(d))
1532
- typeof f == "number" && ((r ??= {})[d] = f);
1533
- else if (fi.has(d))
1534
- (a ??= {})[d] = f;
1535
- else if (d !== "perspective") {
1536
- if (d !== "shine") if (d === "text" && typeof f == "string")
1537
- yi(t, f);
1538
- else if (d === "d" && typeof f == "string") {
1539
- const b = t;
1540
- (b.tagName?.toLowerCase() === "path" ? b : b.querySelector?.("path"))?.setAttribute?.("d", f);
1601
+ let s = null, n = null, r = null, a = null, o = null;
1602
+ const c = e.has("motionPathX"), h = e.has("motionPathY"), u = e.has("motionPathRotate");
1603
+ for (const [f, d] of e)
1604
+ if (!(f === "x" && c) && !(f === "y" && h) && !((f === "rotate" || f === "rotateZ") && u) && !Bi.has(f)) {
1605
+ if (Ci.has(f))
1606
+ (s ??= {})[f] = d;
1607
+ else if (Ri.has(f))
1608
+ typeof d == "number" && ((n ??= {})[f] = d);
1609
+ else if (Di.has(f))
1610
+ typeof d == "number" && ((r ??= {})[f] = d);
1611
+ else if (Ei.has(f))
1612
+ typeof d == "number" && ((a ??= {})[f] = d);
1613
+ else if (_i.has(f))
1614
+ (o ??= {})[f] = d;
1615
+ else if (f !== "perspective") {
1616
+ if (f !== "shine") if (f === "text" && typeof d == "string")
1617
+ vi(t, d);
1618
+ else if (f === "d" && typeof d == "string") {
1619
+ const m = t;
1620
+ (m.tagName?.toLowerCase() === "path" ? m : m.querySelector?.("path"))?.setAttribute?.("d", d);
1541
1621
  } else
1542
- this.applyStyleProperty(t, d, f);
1622
+ this.applyStyleProperty(t, f, d);
1543
1623
  }
1544
1624
  }
1545
- const u = e.get("shine");
1546
- typeof u == "number" && this.applyShine(t, u);
1547
- const l = e.get("perspective");
1548
- if (typeof l == "number" && s.unshift(`perspective(${l}px)`), s.length > 0 && (t.style.transform = s.join(" "), Ti(t)), n) {
1549
- const d = n.originX ?? 50, f = n.originY ?? 50;
1550
- t.style.transformOrigin = `${d}% ${f}%`;
1551
- }
1552
- if (r) {
1553
- const d = r.clipTop ?? 0, f = r.clipRight ?? 0, b = r.clipBottom ?? 0, p = r.clipLeft ?? 0;
1554
- t.style.clipPath = `inset(${d}% ${f}% ${b}% ${p}%)`;
1625
+ const l = e.get("shine");
1626
+ typeof l == "number" && this.applyShine(t, l);
1627
+ const g = [], p = e.get("perspective");
1628
+ if (typeof p == "number" && p > 0 && g.push(`perspective(${p}px)`), s)
1629
+ for (const f of Ii) {
1630
+ const d = s[f];
1631
+ if (d === void 0) continue;
1632
+ const m = this.buildTransformPart(f, d);
1633
+ m && g.push(m);
1634
+ }
1635
+ if (g.length > 0 && (t.style.transform = g.join(" "), xi(t)), n && (n.childPerspective !== void 0 && (t.style.perspective = `${n.childPerspective}px`), (n.perspectiveOriginX !== void 0 || n.perspectiveOriginY !== void 0) && (t.style.perspectiveOrigin = `${n.perspectiveOriginX ?? 50}% ${n.perspectiveOriginY ?? 50}%`)), r) {
1636
+ const f = r.originX ?? 50, d = r.originY ?? 50;
1637
+ t.style.transformOrigin = `${f}% ${d}%`;
1555
1638
  }
1556
1639
  if (a) {
1557
- const d = gi(a);
1558
- d && (t.style.filter = d);
1640
+ const f = a.clipTop ?? 0, d = a.clipRight ?? 0, m = a.clipBottom ?? 0, T = a.clipLeft ?? 0;
1641
+ t.style.clipPath = `inset(${f}% ${d}% ${m}% ${T}%)`;
1642
+ }
1643
+ if (o) {
1644
+ const f = Pi(o);
1645
+ f && (t.style.filter = f);
1559
1646
  }
1560
1647
  }
1561
1648
  /**
1562
1649
  * Build a transform function string for a property.
1563
1650
  */
1564
1651
  buildTransformPart(t, e) {
1652
+ if (t === "quaternion") return Mi(e);
1565
1653
  if (typeof e != "number") return null;
1566
1654
  switch (t) {
1567
1655
  case "x":
@@ -1614,13 +1702,13 @@ class H {
1614
1702
  */
1615
1703
  applyStyleProperty(t, e, s) {
1616
1704
  let n;
1617
- if (t.namespaceURI === ki && e in $t) {
1705
+ if (t.namespaceURI === Oi && e in Xt) {
1618
1706
  const o = Array.isArray(s) ? s.join(", ") : String(s);
1619
- t.style[$t[e]] = o;
1707
+ t.style[Xt[e]] = o;
1620
1708
  return;
1621
- } else e === "fill" && t.dataset?.elementType === "text" ? n = "color" : n = Mi[e] ?? e;
1709
+ } else e === "fill" && t.dataset?.elementType === "text" ? n = "color" : n = Li[e] ?? e;
1622
1710
  let a;
1623
- typeof s == "number" ? Ot.has(e) || Ot.has(n) ? a = `${s}px` : a = String(s) : Array.isArray(s) ? a = s.join(", ") : a = s, t.style[n] = a;
1711
+ typeof s == "number" ? $t.has(e) || $t.has(n) ? a = `${s}px` : a = String(s) : Array.isArray(s) ? a = s.join(", ") : a = s, t.style[n] = a;
1624
1712
  }
1625
1713
  }
1626
1714
  class Ft {
@@ -1662,7 +1750,7 @@ class Ft {
1662
1750
  });
1663
1751
  }
1664
1752
  }
1665
- function wi(i, t, e, s, n) {
1753
+ function $i(i, t, e, s, n) {
1666
1754
  const r = e - n;
1667
1755
  if (r < 0) {
1668
1756
  t.paused || t.pause(), t.currentTime = 0;
@@ -1670,7 +1758,7 @@ function wi(i, t, e, s, n) {
1670
1758
  }
1671
1759
  i.update(r, s);
1672
1760
  }
1673
- class Gt {
1761
+ class Zt {
1674
1762
  container;
1675
1763
  timeline = null;
1676
1764
  adapter;
@@ -1709,7 +1797,7 @@ class Gt {
1709
1797
  this.container = s;
1710
1798
  } else
1711
1799
  this.container = t;
1712
- this.options = e, this.adapter = new H();
1800
+ this.options = e, this.adapter = new Q();
1713
1801
  }
1714
1802
  /**
1715
1803
  * Load animation from a URL or JSON object.
@@ -1735,7 +1823,7 @@ class Gt {
1735
1823
  */
1736
1824
  useDefinition(t) {
1737
1825
  const e = { ...t.config };
1738
- this.options.speed !== void 0 && (e.speed = this.options.speed), this.options.loop !== void 0 && (e.loop = this.options.loop), this.options.alternate !== void 0 && (e.alternate = this.options.alternate), this.timeline = tt({ ...t, config: e }), this.markerList = this.timeline.markers, this.lastMarkerId = null, this.options.onComplete && (this.timeline.onComplete = this.options.onComplete), this.options.onUpdate && (this.timeline.onUpdate = this.options.onUpdate), this.autoRegisterTargets(), this.setupSymbolInstances(), this.scanMedia();
1826
+ this.options.speed !== void 0 && (e.speed = this.options.speed), this.options.loop !== void 0 && (e.loop = this.options.loop), this.options.alternate !== void 0 && (e.alternate = this.options.alternate), this.timeline = et({ ...t, config: e }), this.markerList = this.timeline.markers, this.lastMarkerId = null, this.options.onComplete && (this.timeline.onComplete = this.options.onComplete), this.options.onUpdate && (this.timeline.onUpdate = this.options.onUpdate), this.autoRegisterTargets(), this.setupSymbolInstances(), this.scanMedia();
1739
1827
  }
1740
1828
  // --- scenarios: the reader chooses which timeline plays --------------------
1741
1829
  /**
@@ -1908,7 +1996,7 @@ class Gt {
1908
1996
  /** Sync all discovered media targets to a timeline time. */
1909
1997
  syncAllMedia(t, e) {
1910
1998
  for (const s of this.mediaTargets)
1911
- wi(s.sync, s.el, t, e, s.startTime);
1999
+ $i(s.sync, s.el, t, e, s.startTime);
1912
2000
  }
1913
2001
  /**
1914
2002
  * Load animation from inline JSON string.
@@ -1958,11 +2046,11 @@ class Gt {
1958
2046
  if (!n) return;
1959
2047
  const r = e.get(n);
1960
2048
  if (!r || !r.timeline.tracks?.length) return;
1961
- const a = new H();
2049
+ const a = new Q();
1962
2050
  s.querySelectorAll("[data-tinyfly]").forEach((o) => {
1963
2051
  const c = o.getAttribute("data-tinyfly");
1964
2052
  c && a.registerTarget(c, o);
1965
- }), this.symbolInstances.push({ adapter: a, timeline: tt(r.timeline) });
2053
+ }), this.symbolInstances.push({ adapter: a, timeline: et(r.timeline) });
1966
2054
  });
1967
2055
  }
1968
2056
  /**
@@ -2071,7 +2159,7 @@ class Gt {
2071
2159
  this.playhead = s;
2072
2160
  const n = this.markers;
2073
2161
  if (n.length === 0) return;
2074
- const { crossings: r } = li(
2162
+ const { crossings: r } = Ti(
2075
2163
  n.map((a) => a.time),
2076
2164
  t,
2077
2165
  s,
@@ -2099,14 +2187,14 @@ class Gt {
2099
2187
  }
2100
2188
  }
2101
2189
  }
2102
- async function xi(i, t, e = {}) {
2103
- const s = new Gt(i, { ...e, autoplay: !0 });
2190
+ async function Fi(i, t, e = {}) {
2191
+ const s = new Zt(i, { ...e, autoplay: !0 });
2104
2192
  return await s.load(t), s;
2105
2193
  }
2106
- function vi(i, t = {}) {
2107
- return new Gt(i, t);
2194
+ function Yi(i, t = {}) {
2195
+ return new Zt(i, t);
2108
2196
  }
2109
- class Pi {
2197
+ class Xi {
2110
2198
  container;
2111
2199
  containerA;
2112
2200
  containerB;
@@ -2136,7 +2224,7 @@ class Pi {
2136
2224
  this.container = s;
2137
2225
  } else
2138
2226
  this.container = t;
2139
- this.options = e, this.container.style.position = "relative", this.container.style.overflow = "hidden", this.containerA = this.createSceneContainer(), this.containerB = this.createSceneContainer(), this.container.appendChild(this.containerA), this.container.appendChild(this.containerB), this.containerB.style.visibility = "hidden", this.adapterA = new H(), this.adapterB = new H();
2227
+ this.options = e, this.container.style.position = "relative", this.container.style.overflow = "hidden", this.containerA = this.createSceneContainer(), this.containerB = this.createSceneContainer(), this.container.appendChild(this.containerA), this.container.appendChild(this.containerB), this.containerB.style.visibility = "hidden", this.adapterA = new Q(), this.adapterB = new Q();
2140
2228
  }
2141
2229
  /**
2142
2230
  * Load a sequence from a URL or inline definition.
@@ -2256,11 +2344,11 @@ class Pi {
2256
2344
  if (!r) return;
2257
2345
  const a = this.symbolDefs.get(r);
2258
2346
  if (!a) return;
2259
- const o = new H();
2347
+ const o = new Q();
2260
2348
  n.querySelectorAll("[data-tinyfly]").forEach((c) => {
2261
2349
  const h = c.getAttribute("data-tinyfly");
2262
2350
  h && o.registerTarget(h, c);
2263
- }), s.push({ adapter: o, timeline: tt(a) });
2351
+ }), s.push({ adapter: o, timeline: et(a) });
2264
2352
  }), s.length ? this.nestedByAdapter.set(e, s) : this.nestedByAdapter.delete(e);
2265
2353
  }
2266
2354
  /** Apply the nested symbol states for a slot at a given scene time. */
@@ -2276,7 +2364,7 @@ class Pi {
2276
2364
  t.innerHTML = "";
2277
2365
  }
2278
2366
  createTimeline(t) {
2279
- return t.timeline ? tt(t.timeline) : null;
2367
+ return t.timeline ? et(t.timeline) : null;
2280
2368
  }
2281
2369
  onSceneComplete() {
2282
2370
  if (this._isDestroyed || !this.sequence) return;
@@ -2375,18 +2463,18 @@ class Pi {
2375
2463
  this.animationFrameId !== void 0 && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0);
2376
2464
  }
2377
2465
  }
2378
- async function Ci(i, t, e = {}) {
2379
- const s = new Pi(i, { ...e, autoplay: !0 });
2466
+ async function Ni(i, t, e = {}) {
2467
+ const s = new Xi(i, { ...e, autoplay: !0 });
2380
2468
  return await s.load(t), s;
2381
2469
  }
2382
- const Ii = { type: "none", duration: 0 };
2470
+ const qi = { type: "none", duration: 0 };
2383
2471
  export {
2384
- Ii as DEFAULT_TRANSITION,
2472
+ qi as DEFAULT_TRANSITION,
2385
2473
  Ft as MediaSync,
2386
- Gt as TinyflyPlayer,
2387
- Pi as TinyflySequencer,
2388
- vi as create,
2389
- xi as play,
2390
- Ci as playSequence,
2391
- wi as syncMediaElement
2474
+ Zt as TinyflyPlayer,
2475
+ Xi as TinyflySequencer,
2476
+ Yi as create,
2477
+ Fi as play,
2478
+ Ni as playSequence,
2479
+ $i as syncMediaElement
2392
2480
  };