@algorisys/tinyfly 0.64.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.
Files changed (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +672 -0
  3. package/bin/tinyfly.mjs +59 -0
  4. package/lib/addons/adapters.js +756 -0
  5. package/lib/addons/dom-adapter-ChrbtkLC.js +243 -0
  6. package/lib/addons/drivers.js +72 -0
  7. package/lib/addons/export.js +1169 -0
  8. package/lib/addons/gsap-compat.js +2576 -0
  9. package/lib/addons/interaction.js +225 -0
  10. package/lib/addons/smooth-scroll-DaSacemU.js +671 -0
  11. package/lib/addons/teach.js +215 -0
  12. package/lib/browser/tinyfly.iife.js +2 -0
  13. package/lib/browser/tinyfly.js +6372 -0
  14. package/lib/browser/tinyfly.umd.js +2 -0
  15. package/lib/cli/tools.js +2325 -0
  16. package/lib/embed/tinyfly-embed.iife.js +18 -0
  17. package/lib/embed/tinyfly-embed.js +2316 -0
  18. package/lib/engine/tinyfly-engine.js +1972 -0
  19. package/lib/engine/tinyfly-engine.umd.cjs +2 -0
  20. package/lib/frameworks/react.js +32 -0
  21. package/lib/frameworks/solid.js +27 -0
  22. package/lib/frameworks/svelte.js +15 -0
  23. package/lib/frameworks/vue.js +29 -0
  24. package/lib/player/tinyfly-player.es.js +2306 -0
  25. package/lib/player/tinyfly-player.iife.js +2 -0
  26. package/lib/player/tinyfly-player.umd.js +2 -0
  27. package/lib/types/adapters/canvas/canvas-adapter.d.ts +238 -0
  28. package/lib/types/adapters/canvas/index.d.ts +1 -0
  29. package/lib/types/adapters/dom/dom-adapter.d.ts +50 -0
  30. package/lib/types/adapters/dom/flip.d.ts +60 -0
  31. package/lib/types/adapters/dom/index.d.ts +2 -0
  32. package/lib/types/adapters/filter-utils.d.ts +32 -0
  33. package/lib/types/adapters/index.d.ts +5 -0
  34. package/lib/types/adapters/shine-utils.d.ts +26 -0
  35. package/lib/types/adapters/svg/index.d.ts +1 -0
  36. package/lib/types/adapters/svg/svg-adapter.d.ts +47 -0
  37. package/lib/types/adapters/svg-transform-box.d.ts +13 -0
  38. package/lib/types/adapters/text-content.d.ts +11 -0
  39. package/lib/types/adapters/webgl/index.d.ts +1 -0
  40. package/lib/types/adapters/webgl/webgl-adapter.d.ts +69 -0
  41. package/lib/types/browser/index.d.ts +41 -0
  42. package/lib/types/compat/gsap/custom-eases.d.ts +28 -0
  43. package/lib/types/compat/gsap/defaults.d.ts +19 -0
  44. package/lib/types/compat/gsap/draw-svg-vars.d.ts +36 -0
  45. package/lib/types/compat/gsap/ease-map.d.ts +51 -0
  46. package/lib/types/compat/gsap/image-sequence.d.ts +61 -0
  47. package/lib/types/compat/gsap/index.d.ts +65 -0
  48. package/lib/types/compat/gsap/inertia-vars.d.ts +39 -0
  49. package/lib/types/compat/gsap/keyframes-vars.d.ts +8 -0
  50. package/lib/types/compat/gsap/layout.d.ts +6 -0
  51. package/lib/types/compat/gsap/live-context.d.ts +87 -0
  52. package/lib/types/compat/gsap/live-draggable.d.ts +75 -0
  53. package/lib/types/compat/gsap/live-flip.d.ts +73 -0
  54. package/lib/types/compat/gsap/live-morph.d.ts +18 -0
  55. package/lib/types/compat/gsap/live-motion-path.d.ts +33 -0
  56. package/lib/types/compat/gsap/live-scroll-to.d.ts +52 -0
  57. package/lib/types/compat/gsap/live-scroll.d.ts +108 -0
  58. package/lib/types/compat/gsap/live-transition.d.ts +40 -0
  59. package/lib/types/compat/gsap/live.d.ts +341 -0
  60. package/lib/types/compat/gsap/morph-vars.d.ts +21 -0
  61. package/lib/types/compat/gsap/motion-path-vars.d.ts +38 -0
  62. package/lib/types/compat/gsap/playhead-crossings.d.ts +47 -0
  63. package/lib/types/compat/gsap/position.d.ts +37 -0
  64. package/lib/types/compat/gsap/quick-play.d.ts +38 -0
  65. package/lib/types/compat/gsap/split-text.d.ts +66 -0
  66. package/lib/types/compat/gsap/spring-vars.d.ts +34 -0
  67. package/lib/types/compat/gsap/stage.d.ts +182 -0
  68. package/lib/types/compat/gsap/stagger-grid.d.ts +30 -0
  69. package/lib/types/compat/gsap/text-vars.d.ts +39 -0
  70. package/lib/types/compat/gsap/timeline.d.ts +161 -0
  71. package/lib/types/compat/gsap/utils.d.ts +60 -0
  72. package/lib/types/compat/gsap/vars.d.ts +79 -0
  73. package/lib/types/drivers/index.d.ts +8 -0
  74. package/lib/types/drivers/scroll-driver.d.ts +218 -0
  75. package/lib/types/drivers/scroll-markers.d.ts +41 -0
  76. package/lib/types/drivers/scroll-math.d.ts +87 -0
  77. package/lib/types/drivers/scroll-pin.d.ts +45 -0
  78. package/lib/types/drivers/scroll-snap.d.ts +47 -0
  79. package/lib/types/drivers/smooth-scroll.d.ts +118 -0
  80. package/lib/types/drivers/types.d.ts +23 -0
  81. package/lib/types/drivers/visibility-driver.d.ts +56 -0
  82. package/lib/types/embed/controls.d.ts +46 -0
  83. package/lib/types/embed/index.d.ts +17 -0
  84. package/lib/types/embed/mount.d.ts +41 -0
  85. package/lib/types/embed/tools.d.ts +33 -0
  86. package/lib/types/engine/authoring/custom-ease.d.ts +49 -0
  87. package/lib/types/engine/authoring/index.d.ts +3 -0
  88. package/lib/types/engine/authoring/random.d.ts +38 -0
  89. package/lib/types/engine/authoring/resolve-values.d.ts +57 -0
  90. package/lib/types/engine/core/bake.d.ts +66 -0
  91. package/lib/types/engine/core/clock.d.ts +44 -0
  92. package/lib/types/engine/core/index.d.ts +8 -0
  93. package/lib/types/engine/core/inertia.d.ts +30 -0
  94. package/lib/types/engine/core/playhead-crossings.d.ts +47 -0
  95. package/lib/types/engine/core/spring.d.ts +132 -0
  96. package/lib/types/engine/core/stagger.d.ts +40 -0
  97. package/lib/types/engine/core/timeline.d.ts +203 -0
  98. package/lib/types/engine/core/track.d.ts +90 -0
  99. package/lib/types/engine/export/byte-writer.d.ts +36 -0
  100. package/lib/types/engine/export/css.d.ts +31 -0
  101. package/lib/types/engine/export/gif-decode.test-helper.d.ts +24 -0
  102. package/lib/types/engine/export/gif.d.ts +134 -0
  103. package/lib/types/engine/export/index.d.ts +9 -0
  104. package/lib/types/engine/export/lottie.d.ts +104 -0
  105. package/lib/types/engine/export/mp4.d.ts +64 -0
  106. package/lib/types/engine/export/quantize.d.ts +56 -0
  107. package/lib/types/engine/export/sprite-sheet.d.ts +46 -0
  108. package/lib/types/engine/export/video.d.ts +99 -0
  109. package/lib/types/engine/export/webp.d.ts +82 -0
  110. package/lib/types/engine/index.d.ts +7 -0
  111. package/lib/types/engine/interpolation/easing.d.ts +65 -0
  112. package/lib/types/engine/interpolation/index.d.ts +2 -0
  113. package/lib/types/engine/interpolation/interpolators.d.ts +25 -0
  114. package/lib/types/engine/path/index.d.ts +11 -0
  115. package/lib/types/engine/path/motion-path.d.ts +24 -0
  116. package/lib/types/engine/path/path-builders.d.ts +38 -0
  117. package/lib/types/engine/path/path-morph.d.ts +47 -0
  118. package/lib/types/engine/path/path-utils.d.ts +73 -0
  119. package/lib/types/engine/serialization/index.d.ts +1 -0
  120. package/lib/types/engine/serialization/json.d.ts +30 -0
  121. package/lib/types/engine/text/index.d.ts +2 -0
  122. package/lib/types/engine/text/text-value.d.ts +16 -0
  123. package/lib/types/engine/types.d.ts +401 -0
  124. package/lib/types/frameworks/react.d.ts +35 -0
  125. package/lib/types/frameworks/solid.d.ts +16 -0
  126. package/lib/types/frameworks/svelte.d.ts +19 -0
  127. package/lib/types/frameworks/vue.d.ts +27 -0
  128. package/lib/types/interaction/draggable.d.ts +133 -0
  129. package/lib/types/interaction/index.d.ts +3 -0
  130. package/lib/types/interaction/observer.d.ts +80 -0
  131. package/lib/types/interaction/snap.d.ts +30 -0
  132. package/lib/types/player/index.d.ts +7 -0
  133. package/lib/types/player/media-sync.d.ts +60 -0
  134. package/lib/types/player/player.d.ts +238 -0
  135. package/lib/types/player/sequence-types.d.ts +68 -0
  136. package/lib/types/player/sequencer.d.ts +91 -0
  137. package/lib/types/teach/diagrams.d.ts +137 -0
  138. package/lib/types/teach/index.d.ts +11 -0
  139. package/lib/types/teach/lesson.d.ts +55 -0
  140. package/package.json +170 -0
@@ -0,0 +1,2316 @@
1
+ function ae(e) {
2
+ return typeof e == "object" && e !== null && e.type === "cubic-bezier";
3
+ }
4
+ function oe(e) {
5
+ return typeof e == "object" && e !== null && e.type !== "cubic-bezier";
6
+ }
7
+ const Z = 1;
8
+ function Ut(e) {
9
+ return e.property === "text" && "textConfig" in e;
10
+ }
11
+ function pt(e) {
12
+ return e.kind === "inertia" && "inertia" in e;
13
+ }
14
+ function mt(e) {
15
+ return e.kind === "spring" && "spring" in e;
16
+ }
17
+ function ce(e) {
18
+ return e.property === "motionPath" && "motionPathConfig" in e;
19
+ }
20
+ function jt(e, t, s = "start") {
21
+ if (t <= 1) return 0;
22
+ if (typeof s == "number") {
23
+ const n = Math.max(0, Math.min(t - 1, s));
24
+ return Math.abs(e - n);
25
+ }
26
+ switch (s) {
27
+ case "end":
28
+ return t - 1 - e;
29
+ case "center":
30
+ return Math.abs(e - (t - 1) / 2);
31
+ case "edges":
32
+ return (t - 1) / 2 - Math.abs(e - (t - 1) / 2);
33
+ default:
34
+ return e;
35
+ }
36
+ }
37
+ function le(e, t = "start") {
38
+ if (e <= 1) return 0;
39
+ let s = 0;
40
+ for (let n = 0; n < e; n++)
41
+ s = Math.max(s, jt(n, e, t));
42
+ return s;
43
+ }
44
+ function Ht(e, t, s) {
45
+ if (s.offsets) return s.offsets[e] ?? 0;
46
+ const n = s.from ?? "start", i = jt(e, t, n);
47
+ if (s.amount !== void 0) {
48
+ const r = le(t, n);
49
+ return r === 0 ? 0 : s.amount * i / r;
50
+ }
51
+ return s.each !== void 0 ? s.each * i : 0;
52
+ }
53
+ function he(e, t) {
54
+ return Array.from({ length: e }, (s, n) => Ht(n, e, t));
55
+ }
56
+ function kt(e, t) {
57
+ return e <= 1 ? 0 : Math.max(...he(e, t));
58
+ }
59
+ const Q = 1, zt = 6e4, J = zt / Q, q = {
60
+ stiffness: 180,
61
+ damping: 12,
62
+ mass: 1,
63
+ velocity: 0,
64
+ restDelta: 0.01,
65
+ restSpeed: 0.1
66
+ };
67
+ class ue {
68
+ from;
69
+ to;
70
+ stiffness;
71
+ damping;
72
+ mass;
73
+ restDelta;
74
+ restSpeed;
75
+ /** value[i] is the spring's position at time i * SPRING_STEP_MS */
76
+ /**
77
+ * Travel distance, used to scale the rest thresholds.
78
+ *
79
+ * Without this the thresholds are absolute, and a spring animating `scale`
80
+ * from 0 to 1 hits them ~100x sooner than one animating `x` from 0 to 100 —
81
+ * so the small one is declared "settled" at its first pass through the
82
+ * target and never shows the overshoot at all. Scaling by travel makes
83
+ * settling depend on the spring's parameters, not on the units of whatever
84
+ * property it happens to drive.
85
+ */
86
+ distance;
87
+ samples;
88
+ velocity;
89
+ /** Once at rest we stop simulating; every later time returns `to`. */
90
+ settledStep = null;
91
+ constructor(t) {
92
+ this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ?? q.stiffness, this.damping = t.damping ?? q.damping, this.mass = t.mass ?? q.mass, this.restDelta = t.restDelta ?? q.restDelta, this.restSpeed = t.restSpeed ?? q.restSpeed, this.distance = Math.abs(this.to - this.from) || 1, this.samples = [this.from], this.velocity = t.velocity ?? q.velocity, this.isAtRest(this.from) && (this.settledStep = 0);
93
+ }
94
+ /**
95
+ * Whether a position/velocity pair counts as settled.
96
+ *
97
+ * Both thresholds are fractions of the spring's travel distance:
98
+ * `restDelta` as a fraction of the distance, and `restSpeed` as a fraction
99
+ * of the distance per second. That keeps settling scale-invariant.
100
+ */
101
+ isAtRest(t) {
102
+ return Math.abs(t - this.to) < this.restDelta * this.distance && Math.abs(this.velocity) < this.restSpeed * this.distance;
103
+ }
104
+ /**
105
+ * Position at `timeMs`. Times before 0 clamp to the start value; times past
106
+ * settling return the target exactly.
107
+ */
108
+ valueAt(t) {
109
+ if (t <= 0) return this.from;
110
+ const s = Math.floor(t / Q);
111
+ if (this.simulateTo(s + 1), this.settledStep !== null && s >= this.settledStep)
112
+ return this.to;
113
+ const n = this.samples[Math.min(s, this.samples.length - 1)], i = this.samples[Math.min(s + 1, this.samples.length - 1)], r = t / Q - s;
114
+ return n + (i - n) * r;
115
+ }
116
+ /**
117
+ * How long the spring takes to settle, in milliseconds — the natural duration
118
+ * of a spring track. Runs the simulation to completion once.
119
+ */
120
+ settleTime() {
121
+ return this.simulateTo(J + 1), this.settledStep !== null ? this.settledStep * Q : zt;
122
+ }
123
+ /** Advance the cached simulation until it holds at least `steps` samples. */
124
+ simulateTo(t) {
125
+ if (this.settledStep !== null) return;
126
+ const s = Math.min(t, J + 1), n = Q / 1e3;
127
+ for (; this.samples.length < s; ) {
128
+ const i = this.samples[this.samples.length - 1], r = i - this.to, a = -this.stiffness * r, o = -this.damping * this.velocity, l = (a + o) / this.mass;
129
+ this.velocity += l * n;
130
+ const c = i + this.velocity * n;
131
+ if (this.samples.push(c), this.isAtRest(c)) {
132
+ this.settledStep = this.samples.length - 1;
133
+ return;
134
+ }
135
+ }
136
+ this.samples.length > J && (this.settledStep = J);
137
+ }
138
+ }
139
+ const wt = 4, fe = 2e-3, de = 1e-4, pe = 6e4;
140
+ function Mt(e) {
141
+ const t = e.friction ?? wt;
142
+ return t > 0 ? t : wt;
143
+ }
144
+ function me(e) {
145
+ return e.from + e.velocity / Mt(e);
146
+ }
147
+ function ge(e, t) {
148
+ if (t === void 0) return e;
149
+ if (typeof t == "number")
150
+ return t > 0 ? Math.round(e / t) * t : e;
151
+ if (t.length === 0) return e;
152
+ let s = t[0];
153
+ for (const n of t)
154
+ Math.abs(n - e) < Math.abs(s - e) && (s = n);
155
+ return s;
156
+ }
157
+ function Gt(e) {
158
+ let t = ge(me(e), e.end);
159
+ return e.min !== void 0 && (t = Math.max(e.min, t)), e.max !== void 0 && (t = Math.min(e.max, t)), t;
160
+ }
161
+ function Qt(e) {
162
+ const t = Math.abs(Gt(e) - e.from);
163
+ if (t === 0) return 0;
164
+ const s = e.restDelta ?? Math.max(de, t * fe);
165
+ if (s >= t) return 0;
166
+ const n = Math.log(t / s) / Mt(e);
167
+ return Math.min(pe, n * 1e3);
168
+ }
169
+ function xt(e, t) {
170
+ if (t <= 0) return e.from;
171
+ const s = Gt(e);
172
+ if (t >= Qt(e)) return s;
173
+ const n = Mt(e);
174
+ return e.from + (s - e.from) * (1 - Math.exp(-n * t / 1e3));
175
+ }
176
+ const gt = (e) => e, ye = (e) => e * e, be = (e) => 1 - (1 - e) * (1 - e), ke = (e) => e < 0.5 ? 2 * e * e : 1 - Math.pow(-2 * e + 2, 2) / 2, Zt = (e) => e * e * e, Kt = (e) => 1 - Math.pow(1 - e, 3), Jt = (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2, Me = Zt, Te = Kt, Se = Jt, we = {
177
+ linear: gt,
178
+ "ease-in": Me,
179
+ "ease-out": Te,
180
+ "ease-in-out": Se,
181
+ "ease-in-quad": ye,
182
+ "ease-out-quad": be,
183
+ "ease-in-out-quad": ke,
184
+ "ease-in-cubic": Zt,
185
+ "ease-out-cubic": Kt,
186
+ "ease-in-out-cubic": Jt
187
+ };
188
+ function xe(e) {
189
+ const [t, s, n, i] = e, r = 3 * t, a = 3 * (n - t) - r, o = 1 - r - a, l = 3 * s, c = 3 * (i - s) - l, u = 1 - l - c, h = (p) => ((o * p + a) * p + r) * p, f = (p) => ((u * p + c) * p + l) * p, d = (p) => (3 * o * p + 2 * a) * p + r, k = (p) => {
190
+ let m = p;
191
+ for (let T = 0; T < 8; T++) {
192
+ const x = h(m) - p;
193
+ if (Math.abs(x) < 1e-7)
194
+ return m;
195
+ const g = d(m);
196
+ if (Math.abs(g) < 1e-7)
197
+ break;
198
+ m -= x / g;
199
+ }
200
+ let y = 0, b = 1;
201
+ for (m = p; y < b; ) {
202
+ const T = h(m);
203
+ if (Math.abs(T - p) < 1e-7)
204
+ return m;
205
+ p > T ? y = m : b = m, m = (y + b) / 2;
206
+ }
207
+ return m;
208
+ };
209
+ return (p) => {
210
+ if (p <= 0) return 0;
211
+ if (p >= 1) return 1;
212
+ const m = k(p);
213
+ return f(m);
214
+ };
215
+ }
216
+ function ot(e, t = "out") {
217
+ if (t === "out") return e;
218
+ const s = (n) => 1 - e(1 - n);
219
+ return t === "in" ? s : (n) => n < 0.5 ? s(n * 2) / 2 : e(n * 2 - 1) / 2 + 0.5;
220
+ }
221
+ function _e(e = 1, t = 0.3) {
222
+ const s = Math.max(1, e), n = t / (2 * Math.PI) * Math.asin(1 / s);
223
+ return (i) => i <= 0 ? 0 : i >= 1 ? 1 : s * Math.pow(2, -10 * i) * Math.sin((i - n) * (2 * Math.PI) / t) + 1;
224
+ }
225
+ const ve = (e) => {
226
+ if (e <= 0) return 0;
227
+ if (e >= 1) return 1;
228
+ if (e < 1 / 2.75) return 7.5625 * e * e;
229
+ if (e < 2 / 2.75) {
230
+ const i = e - 0.5454545454545454;
231
+ return 7.5625 * i * i + 0.75;
232
+ }
233
+ if (e < 2.5 / 2.75) {
234
+ const i = e - 0.8181818181818182;
235
+ return 7.5625 * i * i + 0.9375;
236
+ }
237
+ const n = e - 2.625 / 2.75;
238
+ return 7.5625 * n * n + 0.984375;
239
+ };
240
+ function Ae(e = 1.70158) {
241
+ return (t) => {
242
+ if (t <= 0) return 0;
243
+ if (t >= 1) return 1;
244
+ const s = t - 1;
245
+ return s * s * ((e + 1) * s + e) + 1;
246
+ };
247
+ }
248
+ function Pe(e, t = "end") {
249
+ const s = Math.max(1, Math.floor(e));
250
+ return (n) => {
251
+ if (n >= 1) return 1;
252
+ if (n <= 0) return t === "start" || t === "both" ? t === "start" ? 1 / s : 1 / (s + 1) : 0;
253
+ const i = Math.floor(n * s);
254
+ switch (t) {
255
+ case "start":
256
+ return Math.min(1, (i + 1) / s);
257
+ case "both":
258
+ return (i + 1) / (s + 1);
259
+ case "none":
260
+ return s === 1 ? 0 : Math.min(1, i / (s - 1));
261
+ default:
262
+ return i / s;
263
+ }
264
+ };
265
+ }
266
+ function Ie(e) {
267
+ switch (e.type) {
268
+ case "steps":
269
+ return Pe(e.count, e.position);
270
+ case "elastic":
271
+ return ot(_e(e.amplitude, e.period), e.mode);
272
+ case "bounce":
273
+ return ot(ve, e.mode);
274
+ case "back":
275
+ return ot(Ae(e.overshoot), e.mode);
276
+ }
277
+ }
278
+ function Ce(e) {
279
+ return e === void 0 ? gt : ae(e) ? xe(e.points) : oe(e) ? Ie(e) : we[e] ?? gt;
280
+ }
281
+ const _t = 32, Re = 256, j = /* @__PURE__ */ new Map(), Ee = /[MmLlHhVvCcSsQqTtAaZz]/, $e = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, De = {
282
+ M: 2,
283
+ L: 2,
284
+ H: 1,
285
+ V: 1,
286
+ C: 6,
287
+ S: 4,
288
+ Q: 4,
289
+ T: 2,
290
+ A: 7,
291
+ Z: 0
292
+ };
293
+ function Oe(e) {
294
+ const t = [];
295
+ let s = 0, n = null;
296
+ const i = () => {
297
+ for (; s < e.length && /[\s,]/.test(e[s]); ) s++;
298
+ };
299
+ for (; s < e.length && (i(), !(s >= e.length)); ) {
300
+ const r = e[s];
301
+ if (Ee.test(r)) {
302
+ n = { type: r, args: [] }, t.push(n), s++;
303
+ continue;
304
+ }
305
+ if (!n) break;
306
+ const a = n.type === "A" || n.type === "a", o = n.args.length % 7;
307
+ if (a && (o === 3 || o === 4)) {
308
+ if (r !== "0" && r !== "1") break;
309
+ n.args.push(r === "1" ? 1 : 0), s++;
310
+ continue;
311
+ }
312
+ const l = $e.exec(e.slice(s));
313
+ if (!l) break;
314
+ n.args.push(parseFloat(l[0])), s += l[0].length;
315
+ }
316
+ return t;
317
+ }
318
+ function Le(e, t, s, n, i, r, a, o, l) {
319
+ if (e === o && t === l) return [];
320
+ let c = Math.abs(s), u = Math.abs(n);
321
+ if (c === 0 || u === 0) return [[e, t, o, l, o, l]];
322
+ const h = i * Math.PI / 180, f = Math.cos(h), d = Math.sin(h), k = (e - o) / 2, p = (t - l) / 2, m = f * k + d * p, y = -d * k + f * p, b = m * m / (c * c) + y * y / (u * u);
323
+ if (b > 1) {
324
+ const P = Math.sqrt(b);
325
+ c *= P, u *= P;
326
+ }
327
+ const T = r === a ? -1 : 1, x = c * c * u * u - c * c * y * y - u * u * m * m, g = c * c * y * y + u * u * m * m, _ = T * Math.sqrt(Math.max(0, x / g)), S = _ * c * y / u, I = -_ * u * m / c, O = f * S - d * I + (e + o) / 2, v = d * S + f * I + (t + l) / 2, A = (P, E, $, Y) => {
328
+ const at = P * $ + E * Y, K = Math.sqrt((P * P + E * E) * ($ * $ + Y * Y)), U = Math.acos(Math.max(-1, Math.min(1, at / K)));
329
+ return P * Y - E * $ < 0 ? -U : U;
330
+ }, M = A(1, 0, (m - S) / c, (y - I) / u);
331
+ let w = A((m - S) / c, (y - I) / u, (-m - S) / c, (-y - I) / u);
332
+ !a && w > 0 && (w -= 2 * Math.PI), a && w < 0 && (w += 2 * Math.PI);
333
+ const C = Math.max(1, Math.ceil(Math.abs(w) / (Math.PI / 2))), D = w / C, R = 4 / 3 * Math.tan(D / 4), W = (P) => {
334
+ const E = c * Math.cos(P), $ = u * Math.sin(P);
335
+ return [f * E - d * $ + O, d * E + f * $ + v];
336
+ }, B = (P) => {
337
+ const E = -c * Math.sin(P), $ = u * Math.cos(P);
338
+ return [f * E - d * $, d * E + f * $];
339
+ }, St = [];
340
+ for (let P = 0; P < C; P++) {
341
+ const E = M + P * D, $ = E + D, [Y, at] = W(E), [K, U] = P === C - 1 ? [o, l] : W($), [se, ne] = B(E), [ie, re] = B($);
342
+ St.push([Y + R * se, at + R * ne, K - R * ie, U - R * re, K, U]);
343
+ }
344
+ return St;
345
+ }
346
+ function N(e, t, s, n, i) {
347
+ const r = 1 - i;
348
+ return r * r * r * e + 3 * r * r * i * t + 3 * r * i * i * s + i * i * i * n;
349
+ }
350
+ function vt(e, t, s, n, i) {
351
+ const r = 1 - i;
352
+ return 3 * r * r * (t - e) + 6 * r * i * (s - t) + 3 * i * i * (n - s);
353
+ }
354
+ function H(e, t, s, n) {
355
+ return {
356
+ subpath: 0,
357
+ type: "L",
358
+ points: [s, n],
359
+ startX: e,
360
+ startY: t,
361
+ endX: s,
362
+ endY: n,
363
+ length: Math.hypot(s - e, n - t)
364
+ };
365
+ }
366
+ function tt(e, t, s) {
367
+ const [n, i, r, a, o, l] = s, c = [0];
368
+ let u = e, h = t, f = 0;
369
+ for (let d = 1; d <= _t; d++) {
370
+ const k = d / _t, p = N(e, n, r, o, k), m = N(t, i, a, l, k);
371
+ f += Math.hypot(p - u, m - h), c.push(f), u = p, h = m;
372
+ }
373
+ return {
374
+ subpath: 0,
375
+ type: "C",
376
+ points: [n, i, r, a, o, l],
377
+ startX: e,
378
+ startY: t,
379
+ endX: o,
380
+ endY: l,
381
+ length: f,
382
+ lengths: c
383
+ };
384
+ }
385
+ function nt(e) {
386
+ const t = j.get(e);
387
+ if (t) return t;
388
+ const s = [];
389
+ let n = 0, i = 0, r = 0, a = 0, o = null, l = null, c = -1;
390
+ const u = /* @__PURE__ */ new Set(), h = (p) => {
391
+ c < 0 && (c = 0), p.subpath = c, s.push(p);
392
+ };
393
+ for (const { type: p, args: m } of Oe(e)) {
394
+ const y = p.toUpperCase(), b = p !== y, T = De[y];
395
+ if (y === "Z") {
396
+ (n !== r || i !== a) && h(H(n, i, r, a)), c >= 0 && u.add(c), n = r, i = a, o = l = null;
397
+ continue;
398
+ }
399
+ for (let x = 0; x + T <= m.length; x += T) {
400
+ const g = m.slice(x, x + T), _ = b ? n : 0, S = b ? i : 0;
401
+ let I = null, O = null;
402
+ switch (y) {
403
+ case "M":
404
+ x === 0 ? (n = g[0] + _, i = g[1] + S, r = n, a = i, (c < 0 || s[s.length - 1]?.subpath === c) && c++) : (h(H(n, i, g[0] + _, g[1] + S)), n = g[0] + _, i = g[1] + S);
405
+ break;
406
+ case "L":
407
+ h(H(n, i, g[0] + _, g[1] + S)), n = g[0] + _, i = g[1] + S;
408
+ break;
409
+ case "H":
410
+ h(H(n, i, g[0] + _, i)), n = g[0] + _;
411
+ break;
412
+ case "V":
413
+ h(H(n, i, n, g[0] + S)), i = g[0] + S;
414
+ break;
415
+ case "C": {
416
+ const v = [g[0] + _, g[1] + S, g[2] + _, g[3] + S, g[4] + _, g[5] + S];
417
+ h(tt(n, i, v)), I = [v[2], v[3]], n = v[4], i = v[5];
418
+ break;
419
+ }
420
+ case "S": {
421
+ const [v, A] = o ? [2 * n - o[0], 2 * i - o[1]] : [n, i], M = [v, A, g[0] + _, g[1] + S, g[2] + _, g[3] + S];
422
+ h(tt(n, i, M)), I = [M[2], M[3]], n = M[4], i = M[5];
423
+ break;
424
+ }
425
+ case "Q":
426
+ case "T": {
427
+ let v = n, A = i;
428
+ y === "Q" ? (v = g[0] + _, A = g[1] + S) : l && (v = 2 * n - l[0], A = 2 * i - l[1]);
429
+ const M = y === "Q" ? g[2] + _ : g[0] + _, w = y === "Q" ? g[3] + S : g[1] + S;
430
+ h(
431
+ tt(n, i, [
432
+ n + 2 / 3 * (v - n),
433
+ i + 2 / 3 * (A - i),
434
+ M + 2 / 3 * (v - M),
435
+ w + 2 / 3 * (A - w),
436
+ M,
437
+ w
438
+ ])
439
+ ), O = [v, A], n = M, i = w;
440
+ break;
441
+ }
442
+ case "A": {
443
+ const v = g[5] + _, A = g[6] + S;
444
+ let M = n, w = i;
445
+ for (const C of Le(n, i, g[0], g[1], g[2], g[3], g[4], v, A))
446
+ h(tt(M, w, C)), M = C[4], w = C[5];
447
+ n = v, i = A;
448
+ break;
449
+ }
450
+ }
451
+ o = I, l = O;
452
+ }
453
+ }
454
+ const f = s.reduce((p, m) => p + m.length, 0), d = [];
455
+ for (let p = 0; p < s.length; ) {
456
+ const m = s[p].subpath;
457
+ let y = p, b = 0;
458
+ for (; y < s.length && s[y].subpath === m; ) b += s[y++].length;
459
+ const T = s[p], x = s[y - 1], g = u.has(m) || Math.abs(x.endX - T.startX) < 1e-9 && Math.abs(x.endY - T.startY) < 1e-9;
460
+ d.push({ start: p, end: y, length: b, closed: g }), p = y;
461
+ }
462
+ const k = { segments: s, totalLength: f, subpaths: d };
463
+ return j.size >= Re && j.delete(j.keys().next().value), j.set(e, k), k;
464
+ }
465
+ function Ne(e, t) {
466
+ const s = e.lengths;
467
+ if (t <= 0) return 0;
468
+ if (t >= e.length) return 1;
469
+ let n = 0, i = s.length - 1;
470
+ for (; n < i - 1; ) {
471
+ const o = n + i >> 1;
472
+ s[o] < t ? n = o : i = o;
473
+ }
474
+ const r = s[i] - s[n], a = r > 0 ? (t - s[n]) / r : 0;
475
+ return (n + a) / (s.length - 1);
476
+ }
477
+ function Xe(e, t) {
478
+ if (e.type === "L") {
479
+ const h = e.length > 0 ? Math.max(0, Math.min(1, t / e.length)) : 0;
480
+ return {
481
+ x: e.startX + (e.endX - e.startX) * h,
482
+ y: e.startY + (e.endY - e.startY) * h,
483
+ angle: Math.atan2(e.endY - e.startY, e.endX - e.startX) * 180 / Math.PI
484
+ };
485
+ }
486
+ const [s, n, i, r, a, o] = e.points, l = Ne(e, t);
487
+ let c = vt(e.startX, s, i, a, l), u = vt(e.startY, n, r, o, l);
488
+ if (Math.hypot(c, u) < 1e-9) {
489
+ const h = l < 0.5 ? Math.min(1, l + 1e-3) : Math.max(0, l - 1e-3), f = N(e.startX, s, i, a, h), d = N(e.startY, n, r, o, h), k = N(e.startX, s, i, a, l), p = N(e.startY, n, r, o, l);
490
+ c = l < 0.5 ? f - k : k - f, u = l < 0.5 ? d - p : p - d;
491
+ }
492
+ return {
493
+ x: N(e.startX, s, i, a, l),
494
+ y: N(e.startY, n, r, o, l),
495
+ angle: Math.atan2(u, c) * 180 / Math.PI
496
+ };
497
+ }
498
+ function te(e, t, s = 0, n = e.length) {
499
+ if (n <= s) return { x: 0, y: 0, angle: 0 };
500
+ let i = 0;
501
+ for (let r = s; r < n; r++) {
502
+ const a = e[r];
503
+ if (i + a.length >= t || r === n - 1)
504
+ return Xe(a, t - i);
505
+ i += a.length;
506
+ }
507
+ return { x: 0, y: 0, angle: 0 };
508
+ }
509
+ function Fe(e, t) {
510
+ const { segments: s, totalLength: n } = nt(e);
511
+ return te(s, Math.max(0, Math.min(1, t)) * n);
512
+ }
513
+ const Ye = 24, qe = 320, Ve = 2.5, z = 72, We = 0.2, Be = 128, et = /* @__PURE__ */ new Map();
514
+ let ct = 0, X;
515
+ const At = (e) => Math.round(e * 100) / 100;
516
+ function Pt(e, t) {
517
+ const { segments: s, subpaths: n, totalLength: i } = nt(e);
518
+ if (s.length === 0) return [];
519
+ if (t) {
520
+ const r = n.every((a) => a.closed);
521
+ return [{ segments: s, start: 0, end: s.length, length: i, closed: r }];
522
+ }
523
+ return n.filter((r) => r.length > 0).map((r) => ({ segments: s, start: r.start, end: r.end, length: r.length, closed: r.closed }));
524
+ }
525
+ function yt(e, t) {
526
+ const s = e.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)), n = te(e.segments, s * e.length, e.start, e.end);
527
+ return [n.x, n.y];
528
+ }
529
+ function It(e) {
530
+ const t = [];
531
+ let s = 0;
532
+ for (let n = e.start; n < e.end; n++)
533
+ s += e.segments[n].length, e.length > 0 && t.push(s / e.length);
534
+ return t;
535
+ }
536
+ function Ct(e, t) {
537
+ const s = [];
538
+ for (let n = 0; n < t; n++)
539
+ s.push(yt(e, e.closed ? n / t : n / (t - 1)));
540
+ return s;
541
+ }
542
+ function Rt(e) {
543
+ let t = 0, s = 0;
544
+ for (const [n, i] of e)
545
+ t += n, s += i;
546
+ return t /= e.length, s /= e.length, e.map(([n, i]) => [n - t, i - s]);
547
+ }
548
+ function Ue(e, t, s) {
549
+ const n = e.closed && t.closed;
550
+ if (s !== void 0)
551
+ return { offset: n ? Math.abs(s) % z / z : 0, reversed: s < 0 };
552
+ const i = Rt(Ct(e, z)), r = Rt(Ct(t, z)), a = z;
553
+ let o = { offset: 0, reversed: !1 }, l = 1 / 0;
554
+ for (const c of [!1, !0]) {
555
+ const u = n ? a : 1;
556
+ for (let h = 0; h < u; h++) {
557
+ let f = 0;
558
+ for (let d = 0; d < a && f < l; d++) {
559
+ const k = n ? c ? (h - d + a) % a : (d + h) % a : c ? a - 1 - d : d, p = i[d][0] - r[k][0], m = i[d][1] - r[k][1];
560
+ f += p * p + m * m;
561
+ }
562
+ f < l && (l = f, o = { offset: n ? h / a : 0, reversed: c });
563
+ }
564
+ }
565
+ return o;
566
+ }
567
+ function je(e, t, s) {
568
+ return s ? ((t.reversed ? t.offset - e : e + t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
569
+ }
570
+ function He(e, t, s) {
571
+ return s ? ((t.reversed ? t.offset - e : e - t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
572
+ }
573
+ function ze(e, t, s) {
574
+ const n = e.closed && t.closed, i = Ue(e, t, s.shapeIndex), r = Math.max(
575
+ Ye,
576
+ Math.min(qe, Math.ceil(Math.max(e.length, t.length) / Ve))
577
+ ), a = /* @__PURE__ */ new Set(), o = (h) => a.add(Math.round(h * 1e7) / 1e7);
578
+ for (let h = 0; h <= r; h++) o(h / r);
579
+ for (const h of It(e)) o(h);
580
+ for (const h of It(t)) o(He(h, i, n));
581
+ let l = [...a].sort((h, f) => h - f);
582
+ n && (l = l.filter((h) => h < 1));
583
+ const c = [], u = [];
584
+ for (const h of l)
585
+ c.push(...yt(e, h)), u.push(...yt(t, je(h, i, n)));
586
+ return Ge({ from: c, to: u, closed: n });
587
+ }
588
+ function Ge(e) {
589
+ const t = e.from.length / 2;
590
+ if (t <= 3) return e;
591
+ const s = new Uint8Array(t);
592
+ s[0] = 1, s[t - 1] = 1;
593
+ const n = [[0, t - 1]];
594
+ for (; n.length > 0; ) {
595
+ const [a, o] = n.pop();
596
+ let l = -1, c = We;
597
+ for (let u = a + 1; u < o; u++) {
598
+ const h = Math.max(Et(e.from, a, o, u), Et(e.to, a, o, u));
599
+ h > c && (c = h, l = u);
600
+ }
601
+ l !== -1 && (s[l] = 1, n.push([a, l], [l, o]));
602
+ }
603
+ const i = [], r = [];
604
+ for (let a = 0; a < t; a++)
605
+ s[a] && (i.push(e.from[a * 2], e.from[a * 2 + 1]), r.push(e.to[a * 2], e.to[a * 2 + 1]));
606
+ return { from: i, to: r, closed: e.closed };
607
+ }
608
+ function Et(e, t, s, n) {
609
+ const i = e[t * 2], r = e[t * 2 + 1], a = e[s * 2] - i, o = e[s * 2 + 1] - r, l = e[n * 2] - i, c = e[n * 2 + 1] - r, u = a * a + o * o, h = u === 0 ? 0 : Math.max(0, Math.min(1, (l * a + c * o) / u));
610
+ return Math.hypot(l - h * a, c - h * o);
611
+ }
612
+ function Qe(e, t, s) {
613
+ const n = s.shapeIndex;
614
+ if (X && X.from === e && X.to === t && X.shapeIndex === n) return X.plan;
615
+ const r = et.get(String(n ?? "auto"))?.get(e)?.get(t);
616
+ if (r)
617
+ return X = { from: e, to: t, shapeIndex: n, plan: r }, r;
618
+ const a = nt(e).subpaths.filter((d) => d.length > 0).length === nt(t).subpaths.filter((d) => d.length > 0).length, o = Pt(e, !a), l = Pt(t, !a), c = {
619
+ pairs: o.map((d, k) => ze(d, l[k], s))
620
+ };
621
+ ct >= Be && (et.clear(), ct = 0);
622
+ const u = String(n ?? "auto"), h = et.get(u) ?? /* @__PURE__ */ new Map();
623
+ et.set(u, h);
624
+ const f = h.get(e) ?? /* @__PURE__ */ new Map();
625
+ return h.set(e, f), f.set(t, c), ct++, X = { from: e, to: t, shapeIndex: n, plan: c }, c;
626
+ }
627
+ function Ze(e, t, s, n = {}) {
628
+ if (!e) return t;
629
+ if (!t) return e;
630
+ const i = Math.max(0, Math.min(1, s));
631
+ if (i === 0) return e;
632
+ if (i === 1) return t;
633
+ const r = Qe(e, t, n);
634
+ if (r.pairs.length === 0) return i < 0.5 ? e : t;
635
+ let a = "";
636
+ for (const o of r.pairs) {
637
+ for (let l = 0; l < o.from.length; l += 2) {
638
+ const c = At(o.from[l] + (o.to[l] - o.from[l]) * i), u = At(o.from[l + 1] + (o.to[l + 1] - o.from[l + 1]) * i);
639
+ a += `${l === 0 ? a ? " M" : "M" : " L"}${c} ${u}`;
640
+ }
641
+ o.closed && (a += " Z");
642
+ }
643
+ return a;
644
+ }
645
+ function Ke(e) {
646
+ return /^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e);
647
+ }
648
+ const L = (e, t, s) => e + (t - e) * s, ee = 512, lt = /* @__PURE__ */ new Map(), ht = /* @__PURE__ */ new Map();
649
+ function $t(e) {
650
+ const t = lt.get(e);
651
+ if (t) return t;
652
+ const s = e.replace("#", ""), n = [
653
+ parseInt(s.slice(0, 2), 16),
654
+ parseInt(s.slice(2, 4), 16),
655
+ parseInt(s.slice(4, 6), 16)
656
+ ];
657
+ return lt.size < ee && lt.set(e, n), n;
658
+ }
659
+ const Dt = (e) => e.charCodeAt(0) === 35, Ot = (e) => e.startsWith("rgb"), Lt = (e) => e.startsWith("rgba"), Je = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, ut = (e) => Math.round(e).toString(16).padStart(2, "0");
660
+ function ts(e, t, s) {
661
+ return `#${ut(e)}${ut(t)}${ut(s)}`;
662
+ }
663
+ function Nt(e) {
664
+ const t = ht.get(e);
665
+ if (t) return t;
666
+ const s = e.match(Je);
667
+ if (!s)
668
+ throw new Error(`Invalid rgb color: ${e}`);
669
+ const n = parseInt(s[1], 10), i = parseInt(s[2], 10), r = parseInt(s[3], 10), a = s[4] !== void 0 ? [n, i, r, parseFloat(s[4])] : [n, i, r];
670
+ return ht.size < ee && ht.set(e, a), a;
671
+ }
672
+ const es = (e, t, s) => {
673
+ if (Dt(e) && Dt(t)) {
674
+ const [n, i, r] = $t(e), [a, o, l] = $t(t), c = L(n, a, s), u = L(i, o, s), h = L(r, l, s);
675
+ return ts(c, u, h);
676
+ }
677
+ if ((Ot(e) || Lt(e)) && (Ot(t) || Lt(t))) {
678
+ const n = Nt(e), i = Nt(t), r = Math.round(L(n[0], i[0], s)), a = Math.round(L(n[1], i[1], s)), o = Math.round(L(n[2], i[2], s));
679
+ if (n.length === 4 || i.length === 4) {
680
+ const l = n[3] ?? 1, c = i[3] ?? 1, u = L(l, c, s);
681
+ return `rgba(${r}, ${a}, ${o}, ${u})`;
682
+ }
683
+ return `rgb(${r}, ${a}, ${o})`;
684
+ }
685
+ return s < 1 ? e : t;
686
+ }, ss = (e, t, s) => {
687
+ const n = Math.min(e.length, t.length), i = [];
688
+ for (let r = 0; r < n; r++)
689
+ i.push(L(e[r], t[r], s));
690
+ return i;
691
+ }, Xt = (e, t, s) => s < 1 ? e : t, ns = (e, t, s) => Ze(e, t, s);
692
+ function is(e) {
693
+ return typeof e == "number" ? L : Array.isArray(e) ? ss : typeof e == "string" ? e.startsWith("#") || e.startsWith("rgb") ? es : Ke(e) ? ns : Xt : Xt;
694
+ }
695
+ function rs(e) {
696
+ const t = [...e.keyframes].sort((s, n) => s.time - n.time);
697
+ return {
698
+ ...e,
699
+ keyframes: t
700
+ };
701
+ }
702
+ function F(e) {
703
+ return e.targets && e.targets.length > 0 ? e.targets : [e.target];
704
+ }
705
+ function V(e, t, s, n) {
706
+ const i = s ?? 0;
707
+ return !n || t <= 1 ? i : i + Ht(e, t, n);
708
+ }
709
+ class ft {
710
+ track;
711
+ targets;
712
+ constructor(t) {
713
+ this.track = t, this.targets = F(t);
714
+ }
715
+ /**
716
+ * Get the interpolated value at a specific time.
717
+ *
718
+ * For a multi-target track this returns the *first* target's value; callers
719
+ * that need every target should use `getTargetValues`.
720
+ */
721
+ getValueAtTime(t) {
722
+ return this.valueForOffset(t - V(0, this.targets.length, this.track.delay, this.track.stagger));
723
+ }
724
+ /**
725
+ * Every target's value at a specific time, in target order.
726
+ *
727
+ * Single-target tracks yield one entry; staggered tracks yield one per target,
728
+ * each sampled at its own offset time.
729
+ */
730
+ getTargetValues(t) {
731
+ const s = this.targets.length, n = [];
732
+ for (let i = 0; i < s; i++) {
733
+ const r = V(i, s, this.track.delay, this.track.stagger), a = this.valueForOffset(t - r);
734
+ a !== void 0 && n.push({ target: this.targets[i], value: a, start: r + this.track.keyframes[0].time });
735
+ }
736
+ return n;
737
+ }
738
+ /**
739
+ * Get the duration of this track — the last keyframe, plus any delay, the
740
+ * widest stagger offset, and any trailing hold.
741
+ */
742
+ getDuration() {
743
+ const { keyframes: t } = this.track;
744
+ if (t.length === 0)
745
+ return 0;
746
+ const s = t[t.length - 1].time, n = this.track.stagger ? kt(this.targets.length, this.track.stagger) : 0;
747
+ return s + (this.track.delay ?? 0) + n + (this.track.endDelay ?? 0);
748
+ }
749
+ /**
750
+ * Get the track metadata.
751
+ */
752
+ getTrack() {
753
+ return this.track;
754
+ }
755
+ /** Interpolated value at a time already shifted into the track's own frame. */
756
+ valueForOffset(t) {
757
+ const { keyframes: s } = this.track;
758
+ if (s.length === 0)
759
+ return;
760
+ if (s.length === 1 || t <= s[0].time)
761
+ return s[0].value;
762
+ if (t >= s[s.length - 1].time)
763
+ return s[s.length - 1].value;
764
+ const { from: n, to: i } = this.findSurroundingKeyframes(t);
765
+ if (!n || !i)
766
+ return;
767
+ if (n.time === t)
768
+ return n.value;
769
+ const r = i.time - n.time, a = (t - n.time) / r, l = Ce(i.easing)(a);
770
+ return is(n.value)(n.value, i.value, l);
771
+ }
772
+ /**
773
+ * Find the keyframes surrounding a given time.
774
+ */
775
+ findSurroundingKeyframes(t) {
776
+ const { keyframes: s } = this.track;
777
+ for (let n = 0; n < s.length - 1; n++)
778
+ if (t >= s[n].time && t <= s[n + 1].time)
779
+ return { from: s[n], to: s[n + 1] };
780
+ return { from: null, to: null };
781
+ }
782
+ }
783
+ class as {
784
+ track;
785
+ targets;
786
+ sampler;
787
+ constructor(t) {
788
+ this.track = t, this.targets = F(t), this.sampler = new ue(t.spring);
789
+ }
790
+ getValueAtTime(t) {
791
+ return this.sampler.valueAt(t - V(0, this.targets.length, this.track.delay, this.track.stagger));
792
+ }
793
+ getTargetValues(t) {
794
+ const s = this.targets.length, n = [];
795
+ for (let i = 0; i < s; i++) {
796
+ const r = V(i, s, this.track.delay, this.track.stagger);
797
+ n.push({ target: this.targets[i], value: this.sampler.valueAt(t - r), start: r });
798
+ }
799
+ return n;
800
+ }
801
+ /** Settle time plus delay and the widest stagger offset. */
802
+ getDuration() {
803
+ const t = this.track.stagger ? kt(this.targets.length, this.track.stagger) : 0;
804
+ return this.sampler.settleTime() + (this.track.delay ?? 0) + t;
805
+ }
806
+ getTrack() {
807
+ return this.track;
808
+ }
809
+ }
810
+ class os {
811
+ track;
812
+ targets;
813
+ duration;
814
+ constructor(t) {
815
+ this.track = t, this.targets = F(t), this.duration = Qt(t.inertia);
816
+ }
817
+ getValueAtTime(t) {
818
+ return xt(this.track.inertia, t - V(0, this.targets.length, this.track.delay, this.track.stagger));
819
+ }
820
+ getTargetValues(t) {
821
+ const s = this.targets.length, n = [];
822
+ for (let i = 0; i < s; i++) {
823
+ const r = V(i, s, this.track.delay, this.track.stagger);
824
+ n.push({ target: this.targets[i], value: xt(this.track.inertia, t - r), start: r });
825
+ }
826
+ return n;
827
+ }
828
+ /** Settle time plus delay and the widest stagger offset. */
829
+ getDuration() {
830
+ const t = this.track.stagger ? kt(this.targets.length, this.track.stagger) : 0;
831
+ return this.duration + (this.track.delay ?? 0) + t;
832
+ }
833
+ getTrack() {
834
+ return this.track;
835
+ }
836
+ }
837
+ function cs(e, t) {
838
+ const s = { ...Fe(e.pathData, t) };
839
+ if (e.matrix) {
840
+ const [n, i, r, a, o, l] = e.matrix, { x: c, y: u } = s;
841
+ s.x = n * c + r * u + o, s.y = i * c + a * u + l;
842
+ const h = s.angle * Math.PI / 180, f = Math.cos(h), d = Math.sin(h);
843
+ s.angle = Math.atan2(i * f + a * d, n * f + r * d) * 180 / Math.PI;
844
+ }
845
+ return e.autoRotate && e.rotateOffset && (s.angle += e.rotateOffset), s;
846
+ }
847
+ const dt = {
848
+ upperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
849
+ lowerCase: "abcdefghijklmnopqrstuvwxyz",
850
+ upperAndLowerCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
851
+ numbers: "0123456789"
852
+ }, ls = 20;
853
+ function hs(e) {
854
+ const t = dt[e ?? "upperCase"] ?? e ?? dt.upperCase, s = Array.from(t);
855
+ return s.length > 0 ? s : Array.from(dt.upperCase);
856
+ }
857
+ function us(e, t, s) {
858
+ let n = (e | 0) ^ Math.imul(t + 1, 2654435761) ^ Math.imul(s + 1, 2246822507);
859
+ return n = Math.imul(n ^ n >>> 16, 2146121005), n = Math.imul(n ^ n >>> 15, 2221713035), (n ^ n >>> 16) >>> 0;
860
+ }
861
+ function fs(e, t, s = 0) {
862
+ const n = e.from ?? "", i = e.to, r = Math.max(0, Math.min(1, t));
863
+ if (r <= 0) return n;
864
+ if (r >= 1) return i;
865
+ const a = Array.from(n), o = Array.from(i), l = e.rightToLeft ?? !1;
866
+ if (e.mode === "type") {
867
+ const b = Math.round(r * Math.max(a.length, o.length));
868
+ return l ? 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
+ }
870
+ const c = Math.max(0, Math.min(0.999, e.revealDelay ?? 0)), u = Math.max(0, (r - c) / (1 - c)), h = Math.floor(u * o.length), f = e.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), d = hs(e.chars), k = e.refreshRate ?? ls, p = k > 0 ? Math.floor(s * k / 1e3) : 0, m = e.seed ?? 1;
871
+ let y = "";
872
+ for (let b = 0; b < f; b++) {
873
+ const T = l ? b >= f - h : b < h, x = l ? o[o.length - (f - b)] : o[b];
874
+ T && x !== void 0 || x === " " || x === `
875
+ ` ? y += x : y += d[us(m, b, p) % d.length];
876
+ }
877
+ return y;
878
+ }
879
+ class ds {
880
+ id;
881
+ name;
882
+ /** Caption text per language, per marker id */
883
+ captions;
884
+ _tracks = [];
885
+ _trackPlayers = /* @__PURE__ */ new Map();
886
+ _motionPathTracks = /* @__PURE__ */ new Map();
887
+ _springTracks = /* @__PURE__ */ new Map();
888
+ _textTracks = /* @__PURE__ */ new Map();
889
+ _config;
890
+ _currentTime = 0;
891
+ _playbackState = "idle";
892
+ _direction = "forward";
893
+ _loopIteration = 0;
894
+ _explicitDuration;
895
+ /** Milliseconds still to wait at a loop boundary before the next iteration */
896
+ _repeatDelayRemaining = 0;
897
+ /**
898
+ * A forward loop reached its end with a repeat delay armed: the playhead
899
+ * holds on the last frame for the delay, then returns to the start.
900
+ */
901
+ _wrapAfterDelay = !1;
902
+ onUpdate = null;
903
+ onComplete = null;
904
+ constructor(t) {
905
+ if (this.id = t.id, this.name = t.name, this.captions = t.captions, this._config = t.config ?? {}, this._explicitDuration = t.config?.duration, t.tracks)
906
+ for (const s of t.tracks)
907
+ this.addTrack(s);
908
+ }
909
+ get tracks() {
910
+ return [...this._tracks];
911
+ }
912
+ get duration() {
913
+ return this._explicitDuration !== void 0 ? this._explicitDuration : this._calculateDuration();
914
+ }
915
+ /**
916
+ * Set an explicit timeline duration (ms). Pass `undefined` to fall back to the
917
+ * duration calculated from the last keyframe across all tracks.
918
+ */
919
+ setDuration(t) {
920
+ if (this._explicitDuration = t, t !== void 0)
921
+ this._config = { ...this._config, duration: t };
922
+ else if (this._config.duration !== void 0) {
923
+ const s = { ...this._config };
924
+ delete s.duration, this._config = s;
925
+ }
926
+ }
927
+ get currentTime() {
928
+ return this._currentTime;
929
+ }
930
+ get playbackState() {
931
+ return this._playbackState;
932
+ }
933
+ get direction() {
934
+ return this._direction;
935
+ }
936
+ get loopIteration() {
937
+ return this._loopIteration;
938
+ }
939
+ /** Milliseconds of `repeatDelay` still to wait at a loop boundary (0 when not waiting). */
940
+ get repeatDelayRemaining() {
941
+ return this._repeatDelayRemaining;
942
+ }
943
+ get speed() {
944
+ return this._config.speed ?? 1;
945
+ }
946
+ set speed(t) {
947
+ this._config.speed = t;
948
+ }
949
+ /**
950
+ * Start or resume playback.
951
+ * If at the end and direction is forward, reset to beginning.
952
+ * If at the beginning and direction is reverse, reset to end.
953
+ */
954
+ play() {
955
+ const t = this.duration;
956
+ this._direction === "forward" && this._currentTime >= t && t > 0 ? (this._currentTime = 0, this._loopIteration = 0) : this._direction === "reverse" && this._currentTime <= 0 && t > 0 && (this._currentTime = t, this._loopIteration = 0), this._playbackState = "playing";
957
+ }
958
+ /**
959
+ * Pause playback at current position.
960
+ */
961
+ pause() {
962
+ this._playbackState = "paused";
963
+ }
964
+ /**
965
+ * Stop playback and reset to beginning.
966
+ */
967
+ stop() {
968
+ this._playbackState = "idle", this._repeatDelayRemaining = 0, this._wrapAfterDelay = !1, this._currentTime = 0, this._loopIteration = 0, this._direction = "forward";
969
+ }
970
+ /**
971
+ * Seek to a specific time.
972
+ */
973
+ seek(t) {
974
+ const s = this.duration > 0 ? this.duration : 1 / 0;
975
+ this._currentTime = Math.max(0, Math.min(t, s)), this._repeatDelayRemaining = 0, this._wrapAfterDelay = !1;
976
+ }
977
+ /**
978
+ * Toggle or set playback direction.
979
+ */
980
+ reverse() {
981
+ this._direction = this._direction === "forward" ? "reverse" : "forward";
982
+ }
983
+ /**
984
+ * Advance the timeline by delta milliseconds.
985
+ * Call this from your animation loop or clock.
986
+ */
987
+ tick(t) {
988
+ if (this._playbackState !== "playing")
989
+ return;
990
+ const s = this.duration;
991
+ if (s <= 0)
992
+ return;
993
+ let i = t * this.speed;
994
+ if (this._repeatDelayRemaining > 0) {
995
+ const o = Math.min(this._repeatDelayRemaining, i);
996
+ if (this._repeatDelayRemaining -= o, i -= o, this._repeatDelayRemaining > 0) {
997
+ this.onUpdate?.(this.getStateAtTime(this._currentTime));
998
+ return;
999
+ }
1000
+ this._wrapAfterDelay && (this._wrapAfterDelay = !1, this._currentTime = 0);
1001
+ }
1002
+ const r = 1e3;
1003
+ for (let o = 0; o < r && i > 0 && this._playbackState === "playing"; o++)
1004
+ if (this._direction === "forward") {
1005
+ const l = s - this._currentTime;
1006
+ if (i >= l) {
1007
+ if (i -= l, this._currentTime = s, !this._handleEndReached())
1008
+ break;
1009
+ } else
1010
+ this._currentTime += i, i = 0;
1011
+ } else {
1012
+ const l = this._currentTime;
1013
+ if (i >= l) {
1014
+ if (i -= l, this._currentTime = 0, !this._handleStartReached())
1015
+ break;
1016
+ } else
1017
+ this._currentTime -= i, i = 0;
1018
+ }
1019
+ const a = this.getStateAtTime(this._currentTime);
1020
+ this.onUpdate?.(a);
1021
+ }
1022
+ /**
1023
+ * Get the animation state at a specific time.
1024
+ */
1025
+ getStateAtTime(t) {
1026
+ const s = /* @__PURE__ */ new Map();
1027
+ if (this._hasSharedWrites())
1028
+ this._resolveShared(t, s);
1029
+ else
1030
+ for (const [n, i] of this._trackPlayers) {
1031
+ const r = i.getTrack().property;
1032
+ for (const { target: a, value: o, start: l } of i.getTargetValues(t))
1033
+ this._write(s, n, a, r, o, t - l);
1034
+ }
1035
+ return {
1036
+ values: s,
1037
+ currentTime: this._currentTime,
1038
+ playbackState: this._playbackState,
1039
+ direction: this._direction,
1040
+ loopIteration: this._loopIteration
1041
+ };
1042
+ }
1043
+ /**
1044
+ * Several tracks drive the same target+property. Which one applies at `time`:
1045
+ *
1046
+ * 1. Of the tracks that have started (their first keyframe, plus delay and
1047
+ * stagger, is at or before `time`), the one that started LAST.
1048
+ * 2. If none has started yet, the one that starts FIRST — so the value before
1049
+ * anything plays is the first animation's starting value.
1050
+ * 3. Ties on start time go to the track added LAST.
1051
+ *
1052
+ * This is what makes a sequence of tweens on one property play as a sequence:
1053
+ * a later tween holds its starting value, but does not apply it until its
1054
+ * turn. `findConflicts()` reports overlaps by the same rule.
1055
+ */
1056
+ _resolveShared(t, s) {
1057
+ const n = /* @__PURE__ */ new Map();
1058
+ for (const [i, r] of this._trackPlayers) {
1059
+ const a = r.getTrack().property;
1060
+ for (const { target: o, value: l, start: c } of r.getTargetValues(t)) {
1061
+ const u = `${o}\0${a}`, h = c <= t, f = n.get(u);
1062
+ (!f || (h !== f.started ? h : h ? c >= f.start : c <= f.start)) && n.set(u, { trackId: i, target: o, property: a, value: l, start: c, started: h });
1063
+ }
1064
+ }
1065
+ for (const { trackId: i, target: r, property: a, value: o, start: l } of n.values())
1066
+ this._write(s, i, r, a, o, t - l);
1067
+ }
1068
+ /**
1069
+ * Write one track's value for a target, expanding the progress of motion paths
1070
+ * (into x/y/rotation) and text tracks (into the string). `elapsed` is the time
1071
+ * since this target's animation on the track started.
1072
+ */
1073
+ _write(t, s, n, i, r, a) {
1074
+ if (r === void 0) return;
1075
+ let o = t.get(n);
1076
+ o || (o = /* @__PURE__ */ new Map(), t.set(n, o));
1077
+ const l = this._textTracks.get(s);
1078
+ if (l && typeof r == "number") {
1079
+ o.set("text", fs(l.textConfig, r, Math.max(0, a)));
1080
+ return;
1081
+ }
1082
+ const c = this._motionPathTracks.get(s);
1083
+ if (c && typeof r == "number") {
1084
+ const u = cs(c.motionPathConfig, r);
1085
+ o.set("motionPathX", u.x), o.set("motionPathY", u.y), c.motionPathConfig.autoRotate && o.set("motionPathRotate", u.angle);
1086
+ } else
1087
+ o.set(i, r);
1088
+ }
1089
+ /** Cached: does any target+property have more than one track? */
1090
+ _sharedWrites = null;
1091
+ _hasSharedWrites() {
1092
+ if (this._sharedWrites === null) {
1093
+ const t = /* @__PURE__ */ new Set();
1094
+ this._sharedWrites = !1;
1095
+ t: for (const s of this._tracks)
1096
+ for (const n of F(s)) {
1097
+ const i = `${n}\0${s.property}`;
1098
+ if (t.has(i)) {
1099
+ this._sharedWrites = !0;
1100
+ break t;
1101
+ }
1102
+ t.add(i);
1103
+ }
1104
+ }
1105
+ return this._sharedWrites;
1106
+ }
1107
+ /**
1108
+ * Add a track to the timeline.
1109
+ */
1110
+ addTrack(t) {
1111
+ if (this._tracks.push(t), this._sharedWrites = null, pt(t)) {
1112
+ this._trackPlayers.set(t.id, new os(t));
1113
+ return;
1114
+ }
1115
+ if (mt(t)) {
1116
+ this._trackPlayers.set(t.id, new as(t)), this._springTracks.set(t.id, t);
1117
+ return;
1118
+ }
1119
+ if (Ut(t))
1120
+ this._trackPlayers.set(t.id, new ft(t)), this._textTracks.set(t.id, t);
1121
+ else if (ce(t)) {
1122
+ const s = {
1123
+ id: t.id,
1124
+ target: t.target,
1125
+ property: t.property,
1126
+ keyframes: t.keyframes,
1127
+ delay: t.delay,
1128
+ endDelay: t.endDelay,
1129
+ targets: t.targets,
1130
+ stagger: t.stagger
1131
+ };
1132
+ this._trackPlayers.set(t.id, new ft(s)), this._motionPathTracks.set(t.id, t);
1133
+ } else
1134
+ this._trackPlayers.set(t.id, new ft(t));
1135
+ }
1136
+ /**
1137
+ * Replace a track with a new version, keeping its place in the track order
1138
+ * (which decides ties when tracks overlap). The new track may have a
1139
+ * different id. Does nothing if no track has `trackId`.
1140
+ */
1141
+ replaceTrack(t, s) {
1142
+ const n = this._tracks.findIndex((r) => r.id === t);
1143
+ if (n < 0) return;
1144
+ const i = this._tracks.slice(n + 1);
1145
+ this.removeTrack(t);
1146
+ for (const r of i) this.removeTrack(r.id);
1147
+ this.addTrack(s);
1148
+ for (const r of i) this.addTrack(r);
1149
+ }
1150
+ /**
1151
+ * Remove a track by its ID.
1152
+ */
1153
+ removeTrack(t) {
1154
+ this._tracks = this._tracks.filter((s) => s.id !== t), this._sharedWrites = null, this._trackPlayers.delete(t), this._motionPathTracks.delete(t), this._springTracks.delete(t), this._textTracks.delete(t);
1155
+ }
1156
+ /**
1157
+ * Tracks matching a filter. All provided fields must match (AND).
1158
+ *
1159
+ * This is the closest principled equivalent to GSAP's per-tween handle: we
1160
+ * have no live tween objects to hold, so a "tween" is addressed by describing
1161
+ * the tracks it produced.
1162
+ */
1163
+ getTracks(t = {}) {
1164
+ return this._tracks.filter((s) => this._matches(s, t));
1165
+ }
1166
+ /**
1167
+ * Remove every track matching a filter. Returns the ids removed.
1168
+ *
1169
+ * `timeline.removeTracks({ target: 'box' })` is the equivalent of killing all
1170
+ * tweens on an element.
1171
+ */
1172
+ removeTracks(t = {}) {
1173
+ const s = this.getTracks(t).map((n) => n.id);
1174
+ for (const n of s)
1175
+ this.removeTrack(n);
1176
+ return s;
1177
+ }
1178
+ /**
1179
+ * The time span a track is active over: [start, end] in milliseconds.
1180
+ */
1181
+ getTrackSpan(t) {
1182
+ const s = this._trackPlayers.get(t);
1183
+ if (!s) return;
1184
+ const n = s.getTrack(), i = n.delay ?? 0;
1185
+ if (mt(n) || pt(n))
1186
+ return { from: i, to: s.getDuration() };
1187
+ const r = n.keyframes;
1188
+ if (!(!r || r.length === 0))
1189
+ return { from: r[0].time + i, to: s.getDuration() };
1190
+ }
1191
+ /**
1192
+ * Overlapping writes to the same target+property.
1193
+ *
1194
+ * Where two spans overlap, the track that starts later wins from the moment it
1195
+ * starts (ties: the one added later) — see `_resolveShared`. That is
1196
+ * predictable but silent, so an authoring tool should call this and warn,
1197
+ * because a silently discarded stretch of a track looks like a bug.
1198
+ */
1199
+ findConflicts() {
1200
+ const t = [];
1201
+ for (let s = 0; s < this._tracks.length; s++) {
1202
+ const n = this._tracks[s], i = this.getTrackSpan(n.id);
1203
+ if (i)
1204
+ for (let r = 0; r < s; r++) {
1205
+ const a = this._tracks[r];
1206
+ if (a.property !== n.property) continue;
1207
+ const o = F(a).filter((h) => F(n).includes(h));
1208
+ if (o.length === 0) continue;
1209
+ const l = this.getTrackSpan(a.id);
1210
+ if (!l || !(l.from <= i.to && i.from <= l.to)) continue;
1211
+ const u = i.from >= l.from;
1212
+ for (const h of o)
1213
+ t.push({
1214
+ target: h,
1215
+ property: n.property,
1216
+ losingTrackId: u ? a.id : n.id,
1217
+ winningTrackId: u ? n.id : a.id
1218
+ });
1219
+ }
1220
+ }
1221
+ return t;
1222
+ }
1223
+ _matches(t, s) {
1224
+ if (s.id !== void 0 && t.id !== s.id || s.property !== void 0 && t.property !== s.property || s.target !== void 0 && !F(t).includes(s.target)) return !1;
1225
+ if (s.timeRange) {
1226
+ const n = this.getTrackSpan(t.id);
1227
+ if (!n || n.to < s.timeRange.from || n.from > s.timeRange.to) return !1;
1228
+ }
1229
+ return !0;
1230
+ }
1231
+ /**
1232
+ * Export timeline as a serializable definition.
1233
+ */
1234
+ toDefinition() {
1235
+ return {
1236
+ formatVersion: Z,
1237
+ id: this.id,
1238
+ name: this.name,
1239
+ config: { ...this._config },
1240
+ tracks: [...this._tracks],
1241
+ ...this.captions && { captions: this.captions }
1242
+ };
1243
+ }
1244
+ /** The playback configuration, as loaded (read-only). */
1245
+ get config() {
1246
+ return this._config;
1247
+ }
1248
+ /** The timeline's markers, in time order (empty when it has none). */
1249
+ get markers() {
1250
+ return [...this._config.markers ?? []].sort((t, s) => t.time - s.time);
1251
+ }
1252
+ /** Start the between-iterations pause, if the timeline configures one. */
1253
+ _armRepeatDelay() {
1254
+ this._repeatDelayRemaining = this._config.repeatDelay ?? 0;
1255
+ }
1256
+ _calculateDuration() {
1257
+ let t = 0;
1258
+ for (const [, s] of this._trackPlayers)
1259
+ t = Math.max(t, s.getDuration());
1260
+ return t;
1261
+ }
1262
+ /**
1263
+ * Handle reaching the end of the timeline.
1264
+ * Returns true if we looped and should continue, false if we stopped.
1265
+ */
1266
+ _handleEndReached() {
1267
+ const t = this._config.loop ?? 0;
1268
+ return t === -1 || this._loopIteration < t ? (this._loopIteration++, this._armRepeatDelay(), this._config.alternate ? this._direction = "reverse" : this._repeatDelayRemaining > 0 ? this._wrapAfterDelay = !0 : this._currentTime = 0, this._repeatDelayRemaining === 0) : (this._playbackState = "idle", this.onComplete?.(), !1);
1269
+ }
1270
+ /**
1271
+ * Handle reaching the start of the timeline (in reverse).
1272
+ * Returns true if we looped and should continue, false if we stopped.
1273
+ */
1274
+ _handleStartReached() {
1275
+ const t = this._config.loop ?? 0;
1276
+ 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);
1277
+ }
1278
+ }
1279
+ const ps = 100;
1280
+ function ms(e, t, s, n) {
1281
+ const i = [], r = [], { duration: a, alternate: o } = n, l = (d, k, p, m) => {
1282
+ r.push([d, k]);
1283
+ const y = [];
1284
+ e.forEach((b, T) => {
1285
+ (p === "forward" ? (m ? b >= d : b > d) && b <= k : (m ? b <= d : b < d) && b >= k) && y.push(T);
1286
+ }), y.sort((b, T) => (p === "forward" ? e[b] - e[T] : e[T] - e[b]) || b - T);
1287
+ for (const b of y) i.push({ kind: "event", index: b, direction: p });
1288
+ };
1289
+ let c = t.time, u = t.direction, h = t.fresh === !0;
1290
+ const f = Math.min(ps, Math.max(0, s.iteration - t.iteration));
1291
+ for (let d = 0; d < f; d++) {
1292
+ const k = u === "forward" ? a : 0;
1293
+ l(c, k, u, h), i.push({ kind: "repeat" }), o ? (u = u === "forward" ? "reverse" : "forward", c = k, h = !1) : (c = u === "forward" ? 0 : a, h = !0);
1294
+ }
1295
+ return f > 0 && n.holding && !o ? { crossings: i, passes: r } : (l(c, s.time, u, h), { crossings: i, passes: r });
1296
+ }
1297
+ function gs(e) {
1298
+ return { ...e, ...Array.isArray(e.end) && { end: [...e.end] } };
1299
+ }
1300
+ function G(e) {
1301
+ const t = e.endDelay;
1302
+ return {
1303
+ ...e.delay !== void 0 && { delay: e.delay },
1304
+ ...t !== void 0 && { endDelay: t },
1305
+ ...e.targets !== void 0 && { targets: [...e.targets] },
1306
+ ...e.stagger !== void 0 && { stagger: { ...e.stagger } }
1307
+ };
1308
+ }
1309
+ function ys(e) {
1310
+ if (pt(e)) {
1311
+ const t = e;
1312
+ return {
1313
+ id: t.id,
1314
+ target: t.target,
1315
+ property: t.property,
1316
+ kind: "inertia",
1317
+ inertia: gs(t.inertia),
1318
+ ...G(t)
1319
+ };
1320
+ }
1321
+ if (mt(e)) {
1322
+ const t = e;
1323
+ return {
1324
+ id: t.id,
1325
+ target: t.target,
1326
+ property: t.property,
1327
+ kind: "spring",
1328
+ spring: { ...t.spring },
1329
+ ...G(t)
1330
+ };
1331
+ }
1332
+ if (Ut(e)) {
1333
+ const t = e;
1334
+ return {
1335
+ id: t.id,
1336
+ target: t.target,
1337
+ property: "text",
1338
+ textConfig: { ...t.textConfig },
1339
+ keyframes: [...t.keyframes].sort((s, n) => s.time - n.time),
1340
+ ...G(t)
1341
+ };
1342
+ }
1343
+ if (e.property === "motionPath" && "motionPathConfig" in e) {
1344
+ const t = e, s = [...t.keyframes].sort((n, i) => n.time - i.time);
1345
+ return {
1346
+ id: t.id,
1347
+ target: t.target,
1348
+ property: "motionPath",
1349
+ motionPathConfig: { ...t.motionPathConfig },
1350
+ keyframes: s,
1351
+ ...G(t)
1352
+ };
1353
+ }
1354
+ return rs({
1355
+ id: e.id,
1356
+ target: e.target,
1357
+ property: e.property,
1358
+ keyframes: e.keyframes,
1359
+ ...G(e)
1360
+ });
1361
+ }
1362
+ function it(e) {
1363
+ const t = e.formatVersion ?? 1;
1364
+ if (t > Z)
1365
+ throw new Error(
1366
+ `tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${Z}. Update tinyfly to play it.`
1367
+ );
1368
+ return new ds({
1369
+ id: e.id,
1370
+ name: e.name,
1371
+ config: e.config,
1372
+ tracks: e.tracks.map(ys),
1373
+ captions: e.captions
1374
+ });
1375
+ }
1376
+ const bs = /* @__PURE__ */ new Set([
1377
+ "blur",
1378
+ "brightness",
1379
+ "glow",
1380
+ "glowColor",
1381
+ "shadowX",
1382
+ "shadowY",
1383
+ "shadowBlur",
1384
+ "shadowColor"
1385
+ ]), ks = "#ffffff", Ms = "rgba(0, 0, 0, 0.5)";
1386
+ function Ts(e) {
1387
+ const t = [];
1388
+ if (e.blur !== void 0 && t.push(`blur(${Math.max(0, e.blur)}px)`), e.brightness !== void 0 && t.push(`brightness(${Math.max(0, e.brightness)})`), e.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, e.glow)}px ${e.glowColor ?? ks})`), e.shadowX !== void 0 || e.shadowY !== void 0 || e.shadowBlur !== void 0) {
1389
+ const s = e.shadowX ?? 0, n = e.shadowY ?? 0, i = Math.max(0, e.shadowBlur ?? 0);
1390
+ t.push(`drop-shadow(${s}px ${n}px ${i}px ${e.shadowColor ?? Ms})`);
1391
+ }
1392
+ return t.length > 0 ? t.join(" ") : null;
1393
+ }
1394
+ function Ss(e, t) {
1395
+ const s = e.childNodes.length === 1 ? e.firstChild : null;
1396
+ if (s && s.nodeType === 3) {
1397
+ const n = s;
1398
+ n.data !== t && (n.data = t);
1399
+ return;
1400
+ }
1401
+ e.textContent !== t && (e.textContent = t);
1402
+ }
1403
+ function ws(e) {
1404
+ if (!("ownerSVGElement" in e)) return;
1405
+ const t = e.style;
1406
+ !t || t.transformBox || (t.transformBox = "fill-box", t.transformOrigin || (t.transformOrigin = "50% 50%"));
1407
+ }
1408
+ const Ft = /* @__PURE__ */ new Set([
1409
+ "width",
1410
+ "height",
1411
+ "top",
1412
+ "right",
1413
+ "bottom",
1414
+ "left",
1415
+ "margin",
1416
+ "marginTop",
1417
+ "marginRight",
1418
+ "marginBottom",
1419
+ "marginLeft",
1420
+ "padding",
1421
+ "paddingTop",
1422
+ "paddingRight",
1423
+ "paddingBottom",
1424
+ "paddingLeft",
1425
+ "borderRadius",
1426
+ "borderWidth",
1427
+ "fontSize",
1428
+ "lineHeight",
1429
+ "letterSpacing",
1430
+ "outlineWidth",
1431
+ "gap",
1432
+ "rowGap",
1433
+ "columnGap"
1434
+ ]), xs = /* @__PURE__ */ new Set([
1435
+ "x",
1436
+ "y",
1437
+ "z",
1438
+ "rotate",
1439
+ "rotateX",
1440
+ "rotateY",
1441
+ "rotateZ",
1442
+ "scale",
1443
+ "scaleX",
1444
+ "scaleY",
1445
+ "scaleZ",
1446
+ "skewX",
1447
+ "skewY",
1448
+ // Motion path properties
1449
+ "motionPathX",
1450
+ "motionPathY",
1451
+ "motionPathRotate"
1452
+ ]), _s = /* @__PURE__ */ new Set(["originX", "originY"]), vs = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]), As = {
1453
+ fill: "backgroundColor",
1454
+ stroke: "borderColor",
1455
+ strokeWidth: "borderWidth",
1456
+ color: "color",
1457
+ backgroundColor: "backgroundColor",
1458
+ borderColor: "borderColor"
1459
+ }, Yt = {
1460
+ fill: "fill",
1461
+ stroke: "stroke",
1462
+ strokeWidth: "strokeWidth",
1463
+ strokeDasharray: "strokeDasharray",
1464
+ strokeDashoffset: "strokeDashoffset",
1465
+ fillOpacity: "fillOpacity",
1466
+ strokeOpacity: "strokeOpacity"
1467
+ }, Ps = "http://www.w3.org/2000/svg";
1468
+ class bt {
1469
+ targets = /* @__PURE__ */ new Map();
1470
+ /**
1471
+ * Register an HTML element as an animation target.
1472
+ */
1473
+ registerTarget(t, s) {
1474
+ this.targets.set(t, s);
1475
+ }
1476
+ /**
1477
+ * Unregister a target by its ID.
1478
+ */
1479
+ unregisterTarget(t) {
1480
+ this.targets.delete(t);
1481
+ }
1482
+ /**
1483
+ * Get a registered target element.
1484
+ */
1485
+ getTarget(t) {
1486
+ return this.targets.get(t);
1487
+ }
1488
+ /**
1489
+ * Clear all registered targets.
1490
+ */
1491
+ clearTargets() {
1492
+ this.targets.clear();
1493
+ }
1494
+ /**
1495
+ * Apply animation state to all registered targets.
1496
+ */
1497
+ applyState(t) {
1498
+ for (const [s, n] of t.values) {
1499
+ const i = this.targets.get(s);
1500
+ i && this.applyProperties(i, n);
1501
+ }
1502
+ }
1503
+ /**
1504
+ * Apply properties to a single element.
1505
+ */
1506
+ applyProperties(t, s) {
1507
+ const n = [];
1508
+ let i = null, r = null, a = null;
1509
+ const o = s.has("motionPathX"), l = s.has("motionPathY"), c = s.has("motionPathRotate");
1510
+ for (const [f, d] of s)
1511
+ if (!(f === "x" && o) && !(f === "y" && l) && !((f === "rotate" || f === "rotateZ") && c)) {
1512
+ if (xs.has(f)) {
1513
+ const k = this.buildTransformPart(f, d);
1514
+ k && n.push(k);
1515
+ } else if (_s.has(f))
1516
+ typeof d == "number" && ((i ??= {})[f] = d);
1517
+ else if (vs.has(f))
1518
+ typeof d == "number" && ((r ??= {})[f] = d);
1519
+ else if (bs.has(f))
1520
+ (a ??= {})[f] = d;
1521
+ else if (f !== "perspective") {
1522
+ if (f !== "shine") if (f === "text" && typeof d == "string")
1523
+ Ss(t, d);
1524
+ else if (f === "d" && typeof d == "string") {
1525
+ const k = t;
1526
+ (k.tagName?.toLowerCase() === "path" ? k : k.querySelector?.("path"))?.setAttribute?.("d", d);
1527
+ } else
1528
+ this.applyStyleProperty(t, f, d);
1529
+ }
1530
+ }
1531
+ const u = s.get("shine");
1532
+ typeof u == "number" && this.applyShine(t, u);
1533
+ const h = s.get("perspective");
1534
+ if (typeof h == "number" && n.unshift(`perspective(${h}px)`), n.length > 0 && (t.style.transform = n.join(" "), ws(t)), i) {
1535
+ const f = i.originX ?? 50, d = i.originY ?? 50;
1536
+ t.style.transformOrigin = `${f}% ${d}%`;
1537
+ }
1538
+ if (r) {
1539
+ const f = r.clipTop ?? 0, d = r.clipRight ?? 0, k = r.clipBottom ?? 0, p = r.clipLeft ?? 0;
1540
+ t.style.clipPath = `inset(${f}% ${d}% ${k}% ${p}%)`;
1541
+ }
1542
+ if (a) {
1543
+ const f = Ts(a);
1544
+ f && (t.style.filter = f);
1545
+ }
1546
+ }
1547
+ /**
1548
+ * Build a transform function string for a property.
1549
+ */
1550
+ buildTransformPart(t, s) {
1551
+ if (typeof s != "number") return null;
1552
+ switch (t) {
1553
+ case "x":
1554
+ case "motionPathX":
1555
+ return `translateX(${s}px)`;
1556
+ case "y":
1557
+ case "motionPathY":
1558
+ return `translateY(${s}px)`;
1559
+ case "z":
1560
+ return `translateZ(${s}px)`;
1561
+ case "rotate":
1562
+ case "rotateZ":
1563
+ case "motionPathRotate":
1564
+ return `rotate(${s}deg)`;
1565
+ case "rotateX":
1566
+ return `rotateX(${s}deg)`;
1567
+ case "rotateY":
1568
+ return `rotateY(${s}deg)`;
1569
+ case "scale":
1570
+ return `scale(${s})`;
1571
+ case "scaleX":
1572
+ return `scaleX(${s})`;
1573
+ case "scaleY":
1574
+ return `scaleY(${s})`;
1575
+ case "scaleZ":
1576
+ return `scaleZ(${s})`;
1577
+ case "skewX":
1578
+ return `skewX(${s}deg)`;
1579
+ case "skewY":
1580
+ return `skewY(${s}deg)`;
1581
+ default:
1582
+ return null;
1583
+ }
1584
+ }
1585
+ /**
1586
+ * Apply a shine sweep to a (text) element.
1587
+ *
1588
+ * `progress` runs 0..1 as the highlight travels from just off the left edge to
1589
+ * just off the right. Two layered, text-clipped gradients are used: a moving
1590
+ * white highlight band on top of a solid layer of the element's base colour,
1591
+ * so the text stays visible while the sheen passes over the glyphs.
1592
+ */
1593
+ applyShine(t, s) {
1594
+ t.dataset.shineBase || (t.dataset.shineBase = t.style.color || "currentColor");
1595
+ const n = t.dataset.shineBase, i = -20 + s * 140, r = t.style;
1596
+ r.color = "transparent", r.backgroundImage = `linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${n}, ${n})`, r.backgroundSize = "250% 100%, 100% 100%", r.backgroundPosition = `${i}% 0, 0 0`, r.backgroundRepeat = "no-repeat", r.webkitBackgroundClip = "text", r.backgroundClip = "text";
1597
+ }
1598
+ /**
1599
+ * Apply a single style property to an element.
1600
+ */
1601
+ applyStyleProperty(t, s, n) {
1602
+ let i;
1603
+ if (t.namespaceURI === Ps && s in Yt) {
1604
+ const o = Array.isArray(n) ? n.join(", ") : String(n);
1605
+ t.style[Yt[s]] = o;
1606
+ return;
1607
+ } else s === "fill" && t.dataset?.elementType === "text" ? i = "color" : i = As[s] ?? s;
1608
+ let a;
1609
+ typeof n == "number" ? Ft.has(s) || Ft.has(i) ? a = `${n}px` : a = String(n) : Array.isArray(n) ? a = n.join(", ") : a = n, t.style[i] = a;
1610
+ }
1611
+ }
1612
+ class qt {
1613
+ media;
1614
+ offset;
1615
+ driftTolerance;
1616
+ constructor(t, s = {}) {
1617
+ this.media = t, this.offset = s.offset ?? 0, this.driftTolerance = Math.max(0, s.driftTolerance ?? 0.15);
1618
+ }
1619
+ /** Map a timeline time (ms) to the media's time (seconds), never negative. */
1620
+ targetTime(t) {
1621
+ return Math.max(0, t / 1e3 + this.offset);
1622
+ }
1623
+ /**
1624
+ * Reconcile the media with the timeline for the current frame.
1625
+ *
1626
+ * @param timelineTimeMs current timeline time in milliseconds
1627
+ * @param isPlaying whether the timeline is playing
1628
+ */
1629
+ update(t, s) {
1630
+ const n = this.targetTime(t);
1631
+ s ? (this.media.paused && this.safePlay(), Math.abs(this.media.currentTime - n) > this.driftTolerance && (this.media.currentTime = n)) : (this.media.paused || this.media.pause(), this.media.currentTime !== n && (this.media.currentTime = n));
1632
+ }
1633
+ /** Hard-align the media to a timeline time (used on explicit seeks). */
1634
+ seek(t) {
1635
+ this.media.currentTime = this.targetTime(t);
1636
+ }
1637
+ /** Mirror the timeline playback rate onto the media. */
1638
+ setRate(t) {
1639
+ this.media.playbackRate = t;
1640
+ }
1641
+ /** Pause the media and release it. */
1642
+ dispose() {
1643
+ this.media.paused || this.media.pause();
1644
+ }
1645
+ safePlay() {
1646
+ const t = this.media.play();
1647
+ t && typeof t.catch == "function" && t.catch(() => {
1648
+ });
1649
+ }
1650
+ }
1651
+ function Is(e, t, s, n, i) {
1652
+ const r = s - i;
1653
+ if (r < 0) {
1654
+ t.paused || t.pause(), t.currentTime = 0;
1655
+ return;
1656
+ }
1657
+ e.update(r, n);
1658
+ }
1659
+ class Tt {
1660
+ container;
1661
+ timeline = null;
1662
+ adapter;
1663
+ animationFrameId;
1664
+ lastTime;
1665
+ options;
1666
+ targets = {};
1667
+ isDestroyed = !1;
1668
+ mediaSync;
1669
+ mediaTargets = [];
1670
+ symbolInstances = [];
1671
+ markerList = [];
1672
+ listeners = /* @__PURE__ */ new Set();
1673
+ /** Where the playhead was when marker crossings were last worked out */
1674
+ playhead = { time: 0, iteration: 0, direction: "forward" };
1675
+ /** Stop at the next marker crossed (step mode, or `next()`) */
1676
+ stepping = !1;
1677
+ lastMarkerId = null;
1678
+ reducedQuery;
1679
+ onReducedChange = () => this.applyReducedMotion();
1680
+ visibilityObserver;
1681
+ onScreen = !0;
1682
+ /** Playback was paused by leaving the screen, and resumes on return */
1683
+ pausedByVisibility = !1;
1684
+ /** `autoplay` waits for the first time the container is seen */
1685
+ autoplayWhenSeen = !1;
1686
+ onDocumentVisibility = () => this.updateVisibility();
1687
+ constructor(t, s = {}) {
1688
+ if (typeof t == "string") {
1689
+ const n = document.querySelector(t);
1690
+ if (!n)
1691
+ throw new Error(`Container not found: ${t}`);
1692
+ this.container = n;
1693
+ } else
1694
+ this.container = t;
1695
+ this.options = s, this.adapter = new bt();
1696
+ }
1697
+ /**
1698
+ * Load animation from a URL or JSON object.
1699
+ */
1700
+ async load(t) {
1701
+ let s;
1702
+ if (typeof t == "string") {
1703
+ const n = await fetch(t);
1704
+ if (!n.ok)
1705
+ throw new Error(`Failed to load animation: ${n.statusText}`);
1706
+ s = await n.json();
1707
+ } else
1708
+ s = t;
1709
+ this.options.speed !== void 0 && (s.config = { ...s.config, speed: this.options.speed }), this.options.loop !== void 0 && (s.config = { ...s.config, loop: this.options.loop }), this.options.alternate !== void 0 && (s.config = { ...s.config, alternate: this.options.alternate }), this.timeline = it(s), this.markerList = this.timeline.markers, this.lastMarkerId = null, this.options.onComplete && (this.timeline.onComplete = this.options.onComplete), this.options.onUpdate && (this.timeline.onUpdate = this.options.onUpdate), this.autoRegisterTargets(), this.setupSymbolInstances(), this.scanMedia(), this.showInitialFrame(), this.watchReducedMotion(), this.watchVisibility(), this.options.autoplay && !this.reducedMotion && (this.options.playWhenVisible && !this.onScreen ? this.autoplayWhenSeen = !0 : this.play());
1710
+ }
1711
+ // --- teaching: frames, markers, reduced motion, visibility -----------------
1712
+ /**
1713
+ * Be told whenever the time, play state or current marker may have changed —
1714
+ * for controls and captions. Returns a function that stops it.
1715
+ */
1716
+ subscribe(t) {
1717
+ return this.listeners.add(t), () => this.listeners.delete(t);
1718
+ }
1719
+ notify() {
1720
+ for (const t of this.listeners) t();
1721
+ }
1722
+ /** Whether the reader asked for reduced motion (and the player respects it). */
1723
+ get reducedMotion() {
1724
+ return this.reducedQuery?.matches === !0;
1725
+ }
1726
+ /** The timeline's markers, in time order. */
1727
+ get markers() {
1728
+ return this.markerList;
1729
+ }
1730
+ /** The last marker at or before the playhead. */
1731
+ get currentMarker() {
1732
+ const t = this.currentTime;
1733
+ let s;
1734
+ for (const n of this.markers)
1735
+ if (n.time <= t + 0.5) s = n;
1736
+ else break;
1737
+ return s;
1738
+ }
1739
+ /**
1740
+ * Caption for a marker (default: the current one) in a language (default: the
1741
+ * container's closest `lang`, then the document's), falling back to the
1742
+ * marker's own label.
1743
+ */
1744
+ caption(t, s) {
1745
+ const n = t ? this.markers.find((a) => a.id === t) : this.currentMarker;
1746
+ if (!n) return;
1747
+ const i = s ?? this.language(), r = (a) => a?.[i]?.[n.id] ?? a?.[i.split("-")[0]]?.[n.id];
1748
+ return r(this.options.captions) ?? r(this.timeline?.captions) ?? n.label;
1749
+ }
1750
+ /** Move to the next marker: animated, or a jump under reduced motion. At the last marker, to the end. */
1751
+ next() {
1752
+ if (!this.timeline) return;
1753
+ const t = this.currentTime, s = this.markers.find((n) => n.time > t + 0.5);
1754
+ if (this.reducedMotion) {
1755
+ this.seek(s ? s.time : this.duration);
1756
+ return;
1757
+ }
1758
+ t >= this.duration - 0.5 || (this.stepping = s !== void 0, this.startPlaying());
1759
+ }
1760
+ /** Jump back to the previous marker (or the start). */
1761
+ prev() {
1762
+ if (!this.timeline) return;
1763
+ const t = this.currentTime, s = [...this.markers].reverse().find((n) => n.time < t - 0.5);
1764
+ this.pause(), this.seek(s ? s.time : 0);
1765
+ }
1766
+ /** Jump to a marker by id, paused there. */
1767
+ goToMarker(t) {
1768
+ const s = this.markers.find((n) => n.id === t);
1769
+ s && (this.pause(), this.seek(s.time));
1770
+ }
1771
+ language() {
1772
+ return this.container.closest("[lang]")?.getAttribute("lang") || (typeof document < "u" ? document.documentElement.lang : "") || "en";
1773
+ }
1774
+ showInitialFrame() {
1775
+ if (!this.timeline) return;
1776
+ const t = this.options.initialFrame ?? "start";
1777
+ if (t === "none") return;
1778
+ const s = t === "end" ? this.timeline.duration : t === "start" ? 0 : t;
1779
+ this.timeline.seek(Math.max(0, Math.min(this.timeline.duration, s))), this.applyState();
1780
+ }
1781
+ watchReducedMotion() {
1782
+ this.options.respectReducedMotion === !1 || typeof window > "u" || typeof window.matchMedia != "function" || (this.reducedQuery ??= window.matchMedia("(prefers-reduced-motion: reduce)"), this.reducedQuery.addEventListener?.("change", this.onReducedChange), this.reducedQuery.matches && this.applyReducedMotion());
1783
+ }
1784
+ /** Under reduced motion: stop, and show the finished state. */
1785
+ applyReducedMotion() {
1786
+ !this.reducedMotion || !this.timeline || (this.autoplayWhenSeen = !1, this.pause(), this.seek(this.timeline.duration));
1787
+ }
1788
+ watchVisibility() {
1789
+ if (!(!this.options.playWhenVisible || typeof window > "u")) {
1790
+ if (typeof IntersectionObserver == "function") {
1791
+ this.visibilityObserver?.disconnect(), this.listeners.clear(), this.visibilityObserver = new IntersectionObserver((s) => {
1792
+ for (const n of s) this.onScreen = n.isIntersecting;
1793
+ this.updateVisibility();
1794
+ }), this.visibilityObserver.observe(this.container);
1795
+ const t = this.container.getBoundingClientRect?.();
1796
+ t && (t.width > 0 || t.height > 0) && (this.onScreen = t.bottom > 0 && t.top < window.innerHeight && t.right > 0 && t.left < window.innerWidth);
1797
+ }
1798
+ document.addEventListener("visibilitychange", this.onDocumentVisibility);
1799
+ }
1800
+ }
1801
+ updateVisibility() {
1802
+ const t = this.onScreen && document.visibilityState !== "hidden";
1803
+ !t && this.isPlaying ? (this.pausedByVisibility = !0, this.pause()) : t && (this.pausedByVisibility || this.autoplayWhenSeen) && !this.reducedMotion && (this.pausedByVisibility = !1, this.autoplayWhenSeen = !1, this.startPlaying());
1804
+ }
1805
+ /** Report the current marker if it changed since the last frame. */
1806
+ announceMarker() {
1807
+ if (!this.options.onMarker) return;
1808
+ const t = this.currentMarker, s = t?.id;
1809
+ s !== this.lastMarkerId && (this.lastMarkerId = s, this.options.onMarker(t));
1810
+ }
1811
+ /**
1812
+ * Find embedded media elements (`[data-tinyfly-media]`) in the container and
1813
+ * bind each to the timeline. Emitted by the editor's export for audio/video
1814
+ * scene elements; the `data-tinyfly-start` attribute sets when each begins.
1815
+ */
1816
+ scanMedia() {
1817
+ this.mediaTargets = [], this.container.querySelectorAll("[data-tinyfly-media]").forEach((s) => {
1818
+ const n = s, i = Number(n.getAttribute("data-tinyfly-start") ?? "0") || 0, r = n.getAttribute("data-volume");
1819
+ r !== null && (n.volume = Math.max(0, Math.min(1, Number(r) || 0))), this.mediaTargets.push({ el: n, startTime: i, sync: new qt(n) });
1820
+ });
1821
+ }
1822
+ /** Sync all discovered media targets to a timeline time. */
1823
+ syncAllMedia(t, s) {
1824
+ for (const n of this.mediaTargets)
1825
+ Is(n.sync, n.el, t, s, n.startTime);
1826
+ }
1827
+ /**
1828
+ * Load animation from inline JSON string.
1829
+ */
1830
+ loadFromString(t) {
1831
+ const s = JSON.parse(t);
1832
+ this.load(s);
1833
+ }
1834
+ /**
1835
+ * Register a target element by name.
1836
+ */
1837
+ registerTarget(t, s) {
1838
+ if (typeof s == "string") {
1839
+ const n = this.container.querySelector(s);
1840
+ n && (this.targets[t] = n, this.adapter.registerTarget(t, n));
1841
+ } else
1842
+ this.targets[t] = s, this.adapter.registerTarget(t, s);
1843
+ }
1844
+ /**
1845
+ * Auto-register targets using data-tinyfly attribute.
1846
+ */
1847
+ autoRegisterTargets() {
1848
+ this.container.querySelectorAll("[data-tinyfly]").forEach((s) => {
1849
+ const n = s.closest("[data-tinyfly-symbol]");
1850
+ if (n && n !== s) return;
1851
+ const i = s.getAttribute("data-tinyfly");
1852
+ i && this.registerTarget(i, s);
1853
+ }), this.timeline && new Set(this.timeline.tracks.map((n) => n.target)).forEach((n) => {
1854
+ if (!this.targets[n]) {
1855
+ const i = this.container.querySelector(`[data-tinyfly="${n}"]`) || this.container.querySelector(`.${n}`) || this.container.querySelector(`#${n}`);
1856
+ i && this.registerTarget(n, i);
1857
+ }
1858
+ });
1859
+ }
1860
+ /**
1861
+ * Bind each embedded symbol instance (`[data-tinyfly-symbol="id"]`) to its
1862
+ * symbol's nested timeline: a private adapter drives the instance's inner
1863
+ * elements, looped over the symbol's duration and synced to the main playhead.
1864
+ */
1865
+ setupSymbolInstances() {
1866
+ this.symbolInstances = [];
1867
+ const t = this.options.symbols;
1868
+ if (!t || t.length === 0) return;
1869
+ const s = new Map(t.map((n) => [n.id, n]));
1870
+ this.container.querySelectorAll("[data-tinyfly-symbol]").forEach((n) => {
1871
+ const i = n.getAttribute("data-tinyfly-symbol");
1872
+ if (!i) return;
1873
+ const r = s.get(i);
1874
+ if (!r || !r.timeline.tracks?.length) return;
1875
+ const a = new bt();
1876
+ n.querySelectorAll("[data-tinyfly]").forEach((o) => {
1877
+ const l = o.getAttribute("data-tinyfly");
1878
+ l && a.registerTarget(l, o);
1879
+ }), this.symbolInstances.push({ adapter: a, timeline: it(r.timeline) });
1880
+ });
1881
+ }
1882
+ /**
1883
+ * Attach an audio/video element (or any {@link SyncableMedia}) that should
1884
+ * stay in sync with the animation timeline. The timeline remains the clock;
1885
+ * the media follows its play/pause/seek and rate, with drift corrected as it
1886
+ * plays. Pass `{ offset }` to start the media at a timeline offset.
1887
+ */
1888
+ attachMedia(t, s) {
1889
+ this.mediaSync = new qt(t, s), this.timeline && (this.mediaSync.setRate(this.timeline.speed), this.mediaSync.update(this.timeline.currentTime, this.isPlaying));
1890
+ }
1891
+ /** Detach and pause the currently synced media, if any. */
1892
+ detachMedia() {
1893
+ this.mediaSync?.dispose(), this.mediaSync = void 0;
1894
+ }
1895
+ /**
1896
+ * Start or resume playback.
1897
+ */
1898
+ play() {
1899
+ !this.timeline || this.isDestroyed || (this.autoplayWhenSeen = !1, this.stepping = this.options.stepMode === !0, this.startPlaying());
1900
+ }
1901
+ startPlaying() {
1902
+ if (!this.timeline || this.isDestroyed) return;
1903
+ const t = this.timeline.playbackState === "idle";
1904
+ this.timeline.play(), t && this.timeline.currentTime === 0 && this.applyState(), this.playhead = { time: this.timeline.currentTime, iteration: this.timeline.loopIteration, direction: this.timeline.direction }, this.mediaSync?.update(this.timeline.currentTime, !0), this.syncAllMedia(this.timeline.currentTime, !0), this.startAnimationLoop(), this.notify();
1905
+ }
1906
+ /**
1907
+ * Pause playback.
1908
+ */
1909
+ pause() {
1910
+ this.timeline && (this.stepping = !1, this.timeline.pause(), this.notify(), this.mediaSync?.update(this.timeline.currentTime, !1), this.syncAllMedia(this.timeline.currentTime, !1), this.stopAnimationLoop());
1911
+ }
1912
+ /**
1913
+ * Stop playback and reset to beginning.
1914
+ */
1915
+ stop() {
1916
+ this.timeline && (this.timeline.stop(), this.stopAnimationLoop(), this.applyState(), this.mediaSync?.update(this.timeline.currentTime, !1), this.syncAllMedia(this.timeline.currentTime, !1));
1917
+ }
1918
+ /**
1919
+ * Seek to a specific time (in milliseconds).
1920
+ */
1921
+ seek(t) {
1922
+ this.timeline && (this.timeline.seek(t), this.applyState(), this.playhead = { time: this.timeline.currentTime, iteration: this.timeline.loopIteration, direction: this.timeline.direction }, this.mediaSync?.seek(this.timeline.currentTime), this.syncAllMedia(this.timeline.currentTime, this.isPlaying));
1923
+ }
1924
+ /**
1925
+ * Set playback speed.
1926
+ */
1927
+ setSpeed(t) {
1928
+ this.timeline && (this.timeline.speed = t, this.mediaSync?.setRate(t));
1929
+ }
1930
+ /**
1931
+ * Reverse playback direction.
1932
+ */
1933
+ reverse() {
1934
+ this.timeline && this.timeline.reverse();
1935
+ }
1936
+ /**
1937
+ * Get current playback time.
1938
+ */
1939
+ get currentTime() {
1940
+ return this.timeline?.currentTime ?? 0;
1941
+ }
1942
+ /**
1943
+ * Get total duration.
1944
+ */
1945
+ get duration() {
1946
+ return this.timeline?.duration ?? 0;
1947
+ }
1948
+ /**
1949
+ * Check if currently playing.
1950
+ */
1951
+ get isPlaying() {
1952
+ return this.timeline?.playbackState === "playing";
1953
+ }
1954
+ /**
1955
+ * Clean up resources.
1956
+ */
1957
+ destroy() {
1958
+ this.isDestroyed = !0, this.stopAnimationLoop(), this.reducedQuery?.removeEventListener?.("change", this.onReducedChange), this.visibilityObserver?.disconnect(), typeof document < "u" && document.removeEventListener("visibilitychange", this.onDocumentVisibility), this.mediaSync?.dispose(), this.mediaSync = void 0;
1959
+ for (const t of this.mediaTargets)
1960
+ t.el.paused || t.el.pause();
1961
+ this.mediaTargets = [], this.adapter.clearTargets();
1962
+ for (const t of this.symbolInstances) t.adapter.clearTargets();
1963
+ this.symbolInstances = [], this.timeline = null;
1964
+ }
1965
+ startAnimationLoop() {
1966
+ if (this.animationFrameId !== void 0) return;
1967
+ this.lastTime = performance.now();
1968
+ const t = (s) => {
1969
+ if (this.isDestroyed || !this.timeline) return;
1970
+ const n = s - (this.lastTime ?? s);
1971
+ this.lastTime = s;
1972
+ const i = this.playhead;
1973
+ this.timeline.tick(n), this.stopAtMarker(i), this.applyState();
1974
+ const r = this.timeline.playbackState === "playing";
1975
+ this.mediaSync?.update(this.timeline.currentTime, r), this.syncAllMedia(this.timeline.currentTime, r), this.timeline.playbackState === "playing" ? this.animationFrameId = requestAnimationFrame(t) : (this.animationFrameId = void 0, this.notify());
1976
+ };
1977
+ this.animationFrameId = requestAnimationFrame(t);
1978
+ }
1979
+ /**
1980
+ * If this frame crossed a marker it should stop at — the next one while
1981
+ * stepping, or any marker with `pause` — put the playhead exactly there and pause.
1982
+ */
1983
+ stopAtMarker(t) {
1984
+ const s = this.timeline, n = { time: s.currentTime, iteration: s.loopIteration, direction: s.direction };
1985
+ this.playhead = n;
1986
+ const i = this.markers;
1987
+ if (i.length === 0) return;
1988
+ const { crossings: r } = ms(
1989
+ i.map((a) => a.time),
1990
+ t,
1991
+ n,
1992
+ { duration: s.duration, alternate: s.config.alternate === !0, holding: s.repeatDelayRemaining > 0 }
1993
+ );
1994
+ for (const a of r) {
1995
+ if (a.kind !== "event") continue;
1996
+ const o = i[a.index];
1997
+ if (this.stepping || o.pause) {
1998
+ this.stepping = !1, s.pause(), s.seek(o.time), this.playhead = { time: o.time, iteration: s.loopIteration, direction: s.direction };
1999
+ return;
2000
+ }
2001
+ }
2002
+ }
2003
+ stopAnimationLoop() {
2004
+ this.animationFrameId !== void 0 && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0);
2005
+ }
2006
+ applyState() {
2007
+ if (!this.timeline) return;
2008
+ const t = this.timeline.currentTime;
2009
+ this.adapter.applyState(this.timeline.getStateAtTime(t)), this.announceMarker(), this.notify();
2010
+ for (const s of this.symbolInstances) {
2011
+ const n = s.timeline.duration;
2012
+ s.adapter.applyState(s.timeline.getStateAtTime(n > 0 ? t % n : t));
2013
+ }
2014
+ }
2015
+ }
2016
+ async function Bs(e, t, s = {}) {
2017
+ const n = new Tt(e, { ...s, autoplay: !0 });
2018
+ return await n.load(t), n;
2019
+ }
2020
+ function Us(e, t = {}) {
2021
+ return new Tt(e, t);
2022
+ }
2023
+ const Cs = {
2024
+ play: "Play",
2025
+ pause: "Pause",
2026
+ prev: "Previous step",
2027
+ next: "Next step",
2028
+ restart: "Restart",
2029
+ scrub: "Position",
2030
+ speed: "Speed",
2031
+ reveal: "Reveal",
2032
+ step: "Step",
2033
+ of: "of"
2034
+ }, Vt = "tinyfly-controls-style", Rs = `
2035
+ .tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
2036
+ font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
2037
+ .tf-ctl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); }
2038
+ .tf-ctl-btn { min-width: 36px; height: 36px; padding: 0 10px; border: 0; border-radius: calc(var(--tf-ctl-radius) - 2px); background: transparent; color: inherit; font: inherit; cursor: pointer; }
2039
+ .tf-ctl-btn:hover { background: color-mix(in srgb, var(--tf-ctl-fg) 8%, transparent); }
2040
+ .tf-ctl-btn:focus-visible, .tf-ctl-scrub:focus-visible, .tf-ctl-speed:focus-visible { outline: 2px solid var(--tf-ctl-accent); outline-offset: 2px; }
2041
+ .tf-ctl-btn[disabled] { opacity: 0.4; cursor: default; }
2042
+ .tf-ctl-primary { background: var(--tf-ctl-accent); color: #fff; }
2043
+ .tf-ctl-primary:hover { background: var(--tf-ctl-accent); filter: brightness(1.08); }
2044
+ .tf-ctl-scrub { flex: 1 1 120px; min-width: 80px; accent-color: var(--tf-ctl-accent); }
2045
+ .tf-ctl-speed { height: 32px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; }
2046
+ .tf-ctl-step { font-variant-numeric: tabular-nums; opacity: 0.75; padding: 0 4px; }
2047
+ .tf-ctl-caption { margin: 6px 2px 0; min-height: 1.4em; }
2048
+ .tf-ctl-question { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 2px 0; font-weight: 600; }
2049
+ .tf-ctl-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
2050
+ `;
2051
+ function Es(e) {
2052
+ if (e.getElementById(Vt)) return;
2053
+ const t = e.createElement("style");
2054
+ t.id = Vt, t.textContent = Rs, e.head.appendChild(t);
2055
+ }
2056
+ function $s(e, t, s = {}) {
2057
+ const n = t.ownerDocument;
2058
+ Es(n);
2059
+ const i = { ...Cs, ...s.labels }, r = s.speeds ?? [0.5, 1, 2], a = () => e.markers.length > 0, o = n.createElement("div");
2060
+ o.className = "tf-ctl";
2061
+ const l = n.createElement("div");
2062
+ l.className = "tf-ctl-bar", l.setAttribute("role", "group");
2063
+ const c = (M, w, C, D = "") => {
2064
+ const R = n.createElement("button");
2065
+ return R.type = "button", R.className = `tf-ctl-btn ${D}`.trim(), R.setAttribute("aria-label", M), R.title = M, R.textContent = w, R.addEventListener("click", C), R;
2066
+ }, u = c(i.restart, "⟲", () => {
2067
+ e.pause(), e.seek(0);
2068
+ }), h = c(i.prev, "◀", () => e.prev()), f = c(i.play, "▶", () => e.isPlaying ? e.pause() : k(), "tf-ctl-primary"), d = c(i.next, "▶|", () => e.next()), k = () => {
2069
+ e.currentTime >= e.duration - 0.5 && e.seek(0), e.play();
2070
+ }, p = n.createElement("input");
2071
+ p.type = "range", p.className = "tf-ctl-scrub", p.min = "0", p.max = "1000", p.step = "1", p.setAttribute("aria-label", i.scrub), p.addEventListener("input", () => {
2072
+ e.pause(), e.seek(Number(p.value) / 1e3 * e.duration);
2073
+ });
2074
+ const m = n.createElement("span");
2075
+ m.className = "tf-ctl-step";
2076
+ const y = n.createElement("select");
2077
+ y.className = "tf-ctl-speed", y.setAttribute("aria-label", i.speed);
2078
+ for (const M of r) {
2079
+ const w = n.createElement("option");
2080
+ w.value = String(M), w.textContent = `${M}×`, M === 1 && (w.selected = !0), y.appendChild(w);
2081
+ }
2082
+ y.addEventListener("change", () => e.setSpeed(Number(y.value))), l.append(u, h, f, d, p, m), r.length > 0 && l.append(y), o.append(l);
2083
+ const b = n.createElement("p");
2084
+ b.className = "tf-ctl-caption", b.setAttribute("aria-live", "polite"), s.captions !== !1 && o.append(b);
2085
+ const T = n.createElement("div");
2086
+ T.className = "tf-ctl-question", T.hidden = !0;
2087
+ const x = n.createElement("span"), g = c(i.reveal, i.reveal, () => e.play(), "tf-ctl-primary");
2088
+ T.append(x, g), o.append(T);
2089
+ const _ = s.mount;
2090
+ _ ? _.appendChild(o) : t.insertAdjacentElement("afterend", o);
2091
+ const S = () => {
2092
+ const M = e.isPlaying;
2093
+ f.textContent = M ? "❚❚" : "▶", f.setAttribute("aria-label", M ? i.pause : i.play), f.title = M ? i.pause : i.play;
2094
+ const w = e.duration;
2095
+ n.activeElement !== p && (p.value = String(w > 0 ? Math.round(e.currentTime / w * 1e3) : 0));
2096
+ const C = e.markers;
2097
+ if (h.hidden = d.hidden = m.hidden = C.length === 0, C.length > 0) {
2098
+ const D = e.currentMarker, R = D ? C.indexOf(D) + 1 : 0;
2099
+ m.textContent = `${R} / ${C.length}`, m.setAttribute("aria-label", `${i.step} ${R} ${i.of} ${C.length}`), h.disabled = e.currentTime <= 0.5, d.disabled = e.currentTime >= w - 0.5;
2100
+ const W = e.caption() ?? "";
2101
+ b.textContent !== W && (b.textContent = W);
2102
+ const B = !M && D?.question !== void 0 && Math.abs(e.currentTime - D.time) < 1;
2103
+ T.hidden = !B, B && x.textContent !== D.question && (x.textContent = D.question);
2104
+ } else
2105
+ T.hidden = !0;
2106
+ }, I = e.subscribe(S);
2107
+ S();
2108
+ const O = s.keyboardScope ?? t;
2109
+ !O.hasAttribute("tabindex") && O.tabIndex < 0 && (O.tabIndex = 0);
2110
+ const v = /* @__PURE__ */ new WeakSet(), A = (M) => {
2111
+ if (v.has(M) || (v.add(M), M.defaultPrevented || M.altKey || M.ctrlKey || M.metaKey)) return;
2112
+ const w = M.target;
2113
+ if (!(w.tagName === "INPUT" || w.tagName === "SELECT") && !(M.key === " " && w.tagName === "BUTTON"))
2114
+ switch (M.key) {
2115
+ case " ":
2116
+ M.preventDefault(), e.isPlaying ? e.pause() : k();
2117
+ break;
2118
+ case "ArrowRight":
2119
+ if (!a()) return;
2120
+ M.preventDefault(), e.next();
2121
+ break;
2122
+ case "ArrowLeft":
2123
+ if (!a()) return;
2124
+ M.preventDefault(), e.prev();
2125
+ break;
2126
+ case "Home":
2127
+ M.preventDefault(), e.pause(), e.seek(0);
2128
+ break;
2129
+ }
2130
+ };
2131
+ return O.addEventListener("keydown", A), o.addEventListener("keydown", A), {
2132
+ element: o,
2133
+ destroy() {
2134
+ I(), O.removeEventListener("keydown", A), o.removeEventListener("keydown", A), o.remove();
2135
+ }
2136
+ };
2137
+ }
2138
+ const rt = /* @__PURE__ */ new WeakMap();
2139
+ let Ds = 0;
2140
+ function st(e, t, s) {
2141
+ if (e)
2142
+ try {
2143
+ return JSON.parse(e);
2144
+ } catch (n) {
2145
+ console.warn(`tinyfly: invalid ${t} JSON on`, s, n);
2146
+ return;
2147
+ }
2148
+ }
2149
+ async function Os(e, t = {}) {
2150
+ const s = rt.get(e);
2151
+ if (s) return s;
2152
+ const n = e.querySelector("script[data-tinyfly-timeline]"), i = e.getAttribute("data-src"), r = n ? st(n.textContent, "timeline", e) : void 0;
2153
+ if (!r && !i) {
2154
+ console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)', e);
2155
+ return;
2156
+ }
2157
+ const a = st(e.querySelector("script[data-tinyfly-captions]")?.textContent, "captions", e), o = {
2158
+ playWhenVisible: !0,
2159
+ ...t.player,
2160
+ ...a && { captions: a },
2161
+ ...st(e.getAttribute("data-options"), "data-options", e)
2162
+ };
2163
+ Ns(e);
2164
+ const l = new Tt(e, o), c = { element: e, player: l };
2165
+ if (rt.set(e, c), e.setAttribute("data-tinyfly-mounted", ""), await l.load(r ?? i), e.getAttribute("data-controls") !== "false") {
2166
+ const u = st(e.getAttribute("data-labels"), "data-labels", e), h = e.querySelector("figcaption");
2167
+ c.controls = $s(l, e, {
2168
+ ...t.controls,
2169
+ labels: { ...t.controls?.labels, ...u },
2170
+ // Inside the figure, before its figcaption, so the caption stays last.
2171
+ mount: void 0
2172
+ }), h ? e.insertBefore(c.controls.element, h) : e.appendChild(c.controls.element);
2173
+ }
2174
+ return c;
2175
+ }
2176
+ async function Ls(e = document, t = {}) {
2177
+ const s = Array.from(e.querySelectorAll("[data-tinyfly-embed]"));
2178
+ return (await Promise.all(s.map((i) => Os(i, t)))).filter((i) => i !== void 0);
2179
+ }
2180
+ function js(e) {
2181
+ const t = rt.get(e);
2182
+ t && (t.controls?.destroy(), t.player.destroy(), rt.delete(e), e.removeAttribute("data-tinyfly-mounted"));
2183
+ }
2184
+ function Ns(e) {
2185
+ const t = e.querySelector("svg");
2186
+ if (!t || t.hasAttribute("role") || t.hasAttribute("aria-hidden")) return;
2187
+ const s = e.getAttribute("data-alt"), n = e.querySelector("figcaption");
2188
+ t.setAttribute("role", "img"), s ? t.setAttribute("aria-label", s) : n && (n.id ||= `tinyfly-caption-${++Ds}`, t.setAttribute("aria-labelledby", n.id));
2189
+ }
2190
+ function Xs(e) {
2191
+ const t = /* @__PURE__ */ new Set();
2192
+ for (const s of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(s[2] ?? s[3]);
2193
+ return [...t];
2194
+ }
2195
+ function Hs(e, t = {}) {
2196
+ const s = [], n = (c) => s.push({ level: "error", message: c }), i = (c) => s.push({ level: "warning", message: c });
2197
+ if ((e.formatVersion ?? 1) > Z)
2198
+ return n(`format version ${e.formatVersion} is newer than this tinyfly reads (${Z})`), s;
2199
+ let r = 0;
2200
+ try {
2201
+ r = it(e).duration;
2202
+ } catch (c) {
2203
+ return n(`the timeline does not load: ${c instanceof Error ? c.message : String(c)}`), s;
2204
+ }
2205
+ const a = e.config?.duration;
2206
+ if (a !== void 0)
2207
+ for (const c of e.tracks) {
2208
+ if (!("keyframes" in c)) continue;
2209
+ const u = c.keyframes.filter((h) => h.time > a);
2210
+ u.length > 0 && n(`track "${c.id}" has a keyframe at ${u[0].time}ms, after the ${a}ms duration`);
2211
+ }
2212
+ const o = e.config?.markers ?? [], l = /* @__PURE__ */ new Set();
2213
+ o.forEach((c, u) => {
2214
+ l.has(c.id) && n(`marker id "${c.id}" is used more than once`), l.add(c.id), (c.time < 0 || c.time > r) && n(`marker "${c.id}" at ${c.time}ms is outside the animation (0–${r}ms)`), u > 0 && c.time < o[u - 1].time && n(`marker "${c.id}" comes before "${o[u - 1].id}" in time; list markers in order`);
2215
+ });
2216
+ for (const [c, u] of Object.entries(e.captions ?? {})) {
2217
+ for (const h of Object.keys(u))
2218
+ l.has(h) || n(`caption "${h}" (${c}) has no marker with that id`);
2219
+ for (const h of l)
2220
+ h in u || i(`marker "${h}" has no ${c} caption; its label is shown instead`);
2221
+ }
2222
+ if (t.markup !== void 0) {
2223
+ const c = new Set(Xs(t.markup)), u = /* @__PURE__ */ new Set();
2224
+ for (const h of e.tracks)
2225
+ for (const f of [h.target, ...h.targets ?? []])
2226
+ u.add(f), c.has(f) || n(`track "${h.id}" targets "${f}", but no element has data-tinyfly="${f}"`);
2227
+ for (const h of c) u.has(h) || i(`data-tinyfly="${h}" is never animated`);
2228
+ }
2229
+ return s;
2230
+ }
2231
+ function zs(e, t, s = "end") {
2232
+ const n = it(t), i = t.config?.markers ?? [], r = s === "start" ? 0 : s === "end" ? n.duration : typeof s == "number" ? s : i.find((f) => f.id === s)?.time ?? n.duration, a = n.getStateAtTime(Math.max(0, Math.min(n.duration, r))), o = new bt(), l = /* @__PURE__ */ new Map(), c = Ys(e);
2233
+ for (const f of e.matchAll(Wt)) {
2234
+ const d = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(f[2] ?? "");
2235
+ if (!d) continue;
2236
+ const k = d[2] ?? d[3];
2237
+ if (l.has(k)) continue;
2238
+ const p = Fs(c(f.index ?? 0));
2239
+ l.set(k, p), o.registerTarget(k, p);
2240
+ }
2241
+ o.applyState(a);
2242
+ let u = "", h = 0;
2243
+ for (const f of e.matchAll(Wt)) {
2244
+ const [d, k, p = "", m] = f, y = f.index ?? 0, b = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(p), T = b ? l.get(b[2] ?? b[3]) : void 0;
2245
+ if (!T || Object.keys(T.style).length === 0 && T.text === void 0) continue;
2246
+ u += e.slice(h, y);
2247
+ const x = Object.entries(T.style).map(([S, I]) => `${qs(S)}: ${I}`).join("; "), g = /\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(p);
2248
+ let _ = p;
2249
+ if (x)
2250
+ if (g) {
2251
+ const S = `${(g[2] ?? g[3]).trim().replace(/;?$/, ";")} ${x}`.trim();
2252
+ _ = p.replace(g[0], ` style="${Bt(S)}"`);
2253
+ } else
2254
+ _ = `${p} style="${Bt(x)}"`;
2255
+ if (u += `<${k}${_}${m ? " /" : ""}>`, h = y + d.length, T.text !== void 0 && !m) {
2256
+ const S = e.indexOf(`</${k}`, h), I = S === -1 ? "" : e.slice(h, S);
2257
+ S !== -1 && !I.includes("<") && (u += Vs(T.text), h = S);
2258
+ }
2259
+ }
2260
+ return u + e.slice(h);
2261
+ }
2262
+ const Wt = /<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;
2263
+ function Fs(e) {
2264
+ const t = {
2265
+ style: {},
2266
+ dataset: {},
2267
+ namespaceURI: e ? "http://www.w3.org/2000/svg" : "http://www.w3.org/1999/xhtml",
2268
+ childNodes: [],
2269
+ get textContent() {
2270
+ return t.text ?? "";
2271
+ },
2272
+ set textContent(s) {
2273
+ t.text = s;
2274
+ }
2275
+ };
2276
+ return e && (t.ownerSVGElement = null), t;
2277
+ }
2278
+ function Ys(e) {
2279
+ const t = [], s = /<svg[\s>]/gi;
2280
+ let n;
2281
+ for (; n = s.exec(e); ) {
2282
+ const i = e.toLowerCase().indexOf("</svg>", n.index);
2283
+ t.push([n.index + 1, i === -1 ? e.length : i]);
2284
+ }
2285
+ return (i) => t.some(([r, a]) => i > r && i < a);
2286
+ }
2287
+ function qs(e) {
2288
+ const t = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
2289
+ return /^(webkit|moz|ms)-/.test(t) ? `-${t}` : t;
2290
+ }
2291
+ function Bt(e) {
2292
+ return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
2293
+ }
2294
+ function Vs(e) {
2295
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;");
2296
+ }
2297
+ const Ws = typeof document < "u" ? document.currentScript : null;
2298
+ if (Ws?.hasAttribute("data-tinyfly-auto")) {
2299
+ const e = () => {
2300
+ Ls();
2301
+ };
2302
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e, { once: !0 }) : e();
2303
+ }
2304
+ export {
2305
+ Cs as DEFAULT_LABELS,
2306
+ Tt as TinyflyPlayer,
2307
+ Us as create,
2308
+ $s as createControls,
2309
+ Os as mount,
2310
+ Ls as mountAll,
2311
+ Bs as play,
2312
+ zs as renderFrame,
2313
+ Xs as targetNamesIn,
2314
+ js as unmount,
2315
+ Hs as validateEmbed
2316
+ };