@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,2576 @@
1
+ import { getEasingFunction as F, staggerOffset as qt, maxStaggerDistance as Bt, getInterpolator as at, pointsToPath as Ut, isPathData as z, naturalRest as H, SPRING_PRESETS as _, Timeline as Wt, createTrack as ct, springDuration as zt, inertiaDuration as _t, inertiaRest as Gt, staggerSpan as Yt, isParametricEasing as Xt, bakeEasing as Ht, shapeToPathData as et, customBounce as Kt, customEase as Zt, customWiggle as Jt, playheadCrossings as Qt, staggerOffsets as lt } from "@algorisys/tinyfly";
2
+ import { backOut as Er, bounceOut as Ar, elasticOut as Cr, playheadCrossings as Rr, stepsEasing as Fr } from "@algorisys/tinyfly";
3
+ import { D as St } from "./dom-adapter-ChrbtkLC.js";
4
+ import { a as Mt, d as ht } from "./smooth-scroll-DaSacemU.js";
5
+ import { Draggable as te } from "./interaction.js";
6
+ const q = {
7
+ "power1.in": [0.55, 0.085, 0.68, 0.53],
8
+ "power1.out": [0.25, 0.46, 0.45, 0.94],
9
+ "power1.inout": [0.455, 0.03, 0.515, 0.955],
10
+ "power2.in": [0.55, 0.055, 0.675, 0.19],
11
+ "power2.out": [0.215, 0.61, 0.355, 1],
12
+ "power2.inout": [0.645, 0.045, 0.355, 1],
13
+ "power3.in": [0.895, 0.03, 0.685, 0.22],
14
+ "power3.out": [0.165, 0.84, 0.44, 1],
15
+ "power3.inout": [0.77, 0, 0.175, 1],
16
+ "power4.in": [0.755, 0.05, 0.855, 0.06],
17
+ "power4.out": [0.23, 1, 0.32, 1],
18
+ "power4.inout": [0.86, 0, 0.07, 1],
19
+ "sine.in": [0.47, 0, 0.745, 0.715],
20
+ "sine.out": [0.39, 0.575, 0.565, 1],
21
+ "sine.inout": [0.445, 0.05, 0.55, 0.95],
22
+ "expo.in": [0.95, 0.05, 0.795, 0.035],
23
+ "expo.out": [0.19, 1, 0.22, 1],
24
+ "expo.inout": [1, 0, 0, 1],
25
+ "circ.in": [0.6, 0.04, 0.98, 0.335],
26
+ "circ.out": [0.075, 0.82, 0.165, 1],
27
+ "circ.inout": [0.785, 0.135, 0.15, 0.86],
28
+ "back.in": [0.6, -0.28, 0.735, 0.045],
29
+ "back.out": [0.175, 0.885, 0.32, 1.275],
30
+ "back.inout": [0.68, -0.55, 0.265, 1.55]
31
+ }, ut = {
32
+ none: "linear",
33
+ linear: "linear",
34
+ "linear.none": "linear",
35
+ // GSAP's powerN is a polynomial of degree N+1: power1 is quad, power2 cubic.
36
+ "power1.in": "ease-in-quad",
37
+ "power1.out": "ease-out-quad",
38
+ "power1.inout": "ease-in-out-quad",
39
+ "power2.in": "ease-in-cubic",
40
+ "power2.out": "ease-out-cubic",
41
+ "power2.inout": "ease-in-out-cubic"
42
+ };
43
+ function ee(n) {
44
+ let t = n.trim().toLowerCase();
45
+ t = t.replace(/\.ease(in|out|inout)$/, ".$1");
46
+ const e = /^([a-z]+\d?)(\(.*\))?$/.exec(t);
47
+ return e && e[1] !== "steps" && t !== "none" && t !== "linear" && (t = `${e[1]}.out${e[2] ?? ""}`), t;
48
+ }
49
+ const pr = (n = 1, t = 0.3) => F({ type: "elastic", mode: "in", amplitude: n, period: t }), yr = (n = 1, t = 0.3) => F({ type: "elastic", mode: "in-out", amplitude: n, period: t }), gr = F({ type: "bounce", mode: "in" }), wr = F({ type: "bounce", mode: "in-out" }), br = (n) => F({ type: "steps", count: Math.max(1, Math.floor(n)) + 1, position: "none" });
50
+ function V(n) {
51
+ const t = Et.get(n.trim().toLowerCase());
52
+ if (t) return t;
53
+ const e = ee(n), r = /^steps\(\s*(\d+)\s*\)$/.exec(e);
54
+ if (r) {
55
+ const s = { type: "steps", count: Math.max(1, Number.parseInt(r[1], 10)) + 1, position: "none" };
56
+ return { easing: s, fn: F(s) };
57
+ }
58
+ const i = /^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(e);
59
+ if (i) {
60
+ const [, o, s, c] = i, a = (c ?? "").split(",").map((f) => Number.parseFloat(f)).filter((f) => Number.isFinite(f)), l = s === "inout" ? "in-out" : s;
61
+ if (o === "back" && a.length === 0 && e in q)
62
+ return { easing: { type: "cubic-bezier", points: q[e] } };
63
+ const h = o === "elastic" ? { type: "elastic", mode: l, ...a[0] !== void 0 && { amplitude: a[0] }, ...a[1] !== void 0 && { period: a[1] } } : o === "bounce" ? { type: "bounce", mode: l } : { type: "back", mode: l, ...a[0] !== void 0 && { overshoot: a[0] } };
64
+ return { easing: h, fn: F(h) };
65
+ }
66
+ return e in ut ? { easing: ut[e] } : e in q ? { easing: { type: "cubic-bezier", points: q[e] } } : { easing: "ease-out" };
67
+ }
68
+ function vr(n) {
69
+ return V(n).requiresBaking !== void 0;
70
+ }
71
+ const Et = /* @__PURE__ */ new Map();
72
+ function rt(n, t) {
73
+ return Et.set(
74
+ n.trim().toLowerCase(),
75
+ t.bezier ? { easing: { type: "cubic-bezier", points: t.bezier }, fn: t.fn } : { fn: t.fn, requiresBaking: "custom" }
76
+ ), n;
77
+ }
78
+ function K(n) {
79
+ let t = n >>> 0;
80
+ return () => {
81
+ t = t + 1831565813 >>> 0;
82
+ let e = t;
83
+ return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
84
+ };
85
+ }
86
+ const At = /^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;
87
+ function Ct(n) {
88
+ return typeof n == "string" && At.test(n);
89
+ }
90
+ function re(n = 1) {
91
+ let t = K(n);
92
+ const e = (a, l) => ((...h) => h.length >= a ? l(...h) : (f) => l(...h, f)), r = (a, l, h) => Math.min(Math.max(h, Math.min(a, l)), Math.max(a, l)), i = (a, l, h, f, u) => l === a ? h : h + (u - a) / (l - a) * (f - h), o = (a, l) => {
93
+ if (typeof a == "number") return a === 0 ? l : Math.round(l / a) * a;
94
+ if (Array.isArray(a)) return ft(a, l, 1 / 0);
95
+ if ("values" in a) return ft(a.values, l, a.radius ?? 1 / 0);
96
+ const h = Math.round(l / a.increment) * a.increment;
97
+ return Math.abs(h - l) <= (a.radius ?? 1 / 0) ? h : l;
98
+ }, s = (a, l, h) => {
99
+ const f = a + t() * (l - a);
100
+ return h ? Math.round(f / h) * h : f;
101
+ };
102
+ return {
103
+ clamp: e(3, r),
104
+ mapRange: e(5, i),
105
+ normalize: e(3, (a, l, h) => i(a, l, 0, 1, h)),
106
+ interpolate: e(3, (a, l, h) => {
107
+ if (typeof a == "object" && !Array.isArray(a)) {
108
+ const f = {};
109
+ for (const u of Object.keys(a))
110
+ f[u] = at(a[u])(a[u], l[u], h);
111
+ return f;
112
+ }
113
+ return at(a)(a, l, h);
114
+ }),
115
+ wrap: ((a, l, h) => {
116
+ if (Array.isArray(a)) {
117
+ const d = a, y = (g) => d[(Math.round(g) % d.length + d.length) % d.length];
118
+ return l === void 0 ? y : y(l);
119
+ }
120
+ const f = a, m = l - f, p = (d) => m === 0 ? f : ((d - f) % m + m) % m + f;
121
+ return h === void 0 ? p : p(h);
122
+ }),
123
+ wrapYoyo: e(3, (a, l, h) => {
124
+ const f = l - a;
125
+ if (f === 0) return a;
126
+ const u = ((h - a) % (f * 2) + f * 2) % (f * 2);
127
+ return a + (u > f ? f * 2 - u : u);
128
+ }),
129
+ snap: e(2, o),
130
+ random: ((a, l, h, f) => {
131
+ if (Array.isArray(a)) {
132
+ const m = () => a[Math.floor(t() * a.length)];
133
+ return l === !0 ? m : m();
134
+ }
135
+ const u = () => s(a, l, h);
136
+ return f ? u : u();
137
+ }),
138
+ shuffle: (a) => {
139
+ for (let l = a.length - 1; l > 0; l--) {
140
+ const h = Math.floor(t() * (l + 1));
141
+ [a[l], a[h]] = [a[h], a[l]];
142
+ }
143
+ return a;
144
+ },
145
+ distribute: ({ base: a = 0, amount: l, each: h, from: f = "start", ease: u }) => (m, p, d) => {
146
+ const y = d.length, b = qt(m, y, { ...l !== void 0 ? { amount: l } : { each: h ?? 1 }, from: f }), w = l !== void 0 ? l : (h ?? 1) * Bt(y, f), k = u && w > 0 ? u(b / w) * w : b;
147
+ return a + k;
148
+ },
149
+ pipe: (...a) => (l) => a.reduce((h, f) => f(h), l),
150
+ splitColor: (a) => ne(a),
151
+ getUnit: (a) => typeof a == "number" ? "" : /^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(a.trim())?.[1] ?? "",
152
+ seed: (a) => {
153
+ t = K(a);
154
+ },
155
+ resolveRandomString: (a) => {
156
+ const l = At.exec(a)?.[1] ?? "";
157
+ if (l.startsWith("[")) {
158
+ const p = l.slice(1, -1).split(",").map((d) => d.trim()).filter(Boolean).map((d) => Number.isFinite(Number(d)) ? Number(d) : d.replace(/^['"]|['"]$/g, ""));
159
+ return p[Math.floor(t() * p.length)];
160
+ }
161
+ const [h, f, u] = l.split(",").map((m) => Number.parseFloat(m));
162
+ return s(h, f, Number.isFinite(u) ? u : void 0);
163
+ }
164
+ };
165
+ }
166
+ function ft(n, t, e) {
167
+ let r = t, i = 1 / 0;
168
+ for (const o of n) {
169
+ const s = Math.abs(o - t);
170
+ s < i && (i = s, r = o);
171
+ }
172
+ return i <= e ? r : t;
173
+ }
174
+ function ne(n) {
175
+ const t = n.trim(), e = /^#([0-9a-f]{3,8})$/i.exec(t)?.[1];
176
+ if (e) {
177
+ const o = (e.length <= 4 ? [...e].map((s) => s + s).join("") : e).match(/../g).map((s) => Number.parseInt(s, 16));
178
+ return o.length >= 4 ? [o[0], o[1], o[2], Math.round(o[3] / 255 * 1e3) / 1e3] : [o[0], o[1], o[2]];
179
+ }
180
+ const r = (/rgba?\(([^)]+)\)/i.exec(t)?.[1] ?? "0,0,0").split(/[\s,/]+/).filter(Boolean).map((i) => Number.parseFloat(i));
181
+ return r.length >= 4 ? [r[0], r[1], r[2], r[3]] : [r[0] ?? 0, r[1] ?? 0, r[2] ?? 0];
182
+ }
183
+ const oe = /^([+-])=\s*(-?[\d.]+)$/, ie = /^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;
184
+ function I(n, t) {
185
+ const e = t.scale ?? 1, r = (l) => Number.parseFloat(l) * e;
186
+ if (n === void 0) return t.cursor;
187
+ if (typeof n == "number") return n * e;
188
+ const i = n.trim();
189
+ if (i === "") return t.cursor;
190
+ const o = oe.exec(i);
191
+ if (o) {
192
+ const l = r(o[2]);
193
+ return t.cursor + (o[1] === "-" ? -l : l);
194
+ }
195
+ const s = ie.exec(i);
196
+ if (s) {
197
+ const l = s[1] === "<" ? t.previousStart : t.previousEnd;
198
+ if (s[3] === void 0) return l;
199
+ const h = r(s[3]);
200
+ return l + (s[2] === "-" ? -h : h);
201
+ }
202
+ const c = /^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(i);
203
+ if (c) {
204
+ const l = t.labels.get(c[1].trim());
205
+ if (l !== void 0) {
206
+ const h = r(c[3]);
207
+ return l + (c[2] === "-" ? -h : h);
208
+ }
209
+ }
210
+ const a = t.labels.get(i);
211
+ return a !== void 0 ? a : /^-?[\d.]+$/.test(i) ? r(i) : t.cursor;
212
+ }
213
+ function se(n) {
214
+ if (typeof n != "object" || n === null) return !1;
215
+ const t = n;
216
+ return t.grid !== void 0 || t.from === "random" || Array.isArray(t.from) || t.ease !== void 0 || t.axis !== void 0;
217
+ }
218
+ function ae(n, t, e = {}) {
219
+ if (n === 0) return [];
220
+ const r = t.grid === "auto" ? Math.max(1, Math.min(n, e.columnsFromLayout?.() ?? n)) : Array.isArray(t.grid) ? Math.max(1, t.grid[1]) : n, i = Array.isArray(t.grid) ? Math.max(1, t.grid[0]) : Math.ceil(n / r), o = (p) => ({ x: p % r, y: Math.floor(p / r) }), s = t.from ?? "start", c = Array.isArray(s) ? { x: s[0] * (r - 1), y: s[1] * (i - 1) } : typeof s == "number" ? o(Math.max(0, Math.min(n - 1, s))) : s === "end" ? o(n - 1) : s === "center" || s === "edges" ? { x: (r - 1) / 2, y: (i - 1) / 2 } : { x: 0, y: 0 }, a = (p) => {
221
+ const { x: d, y } = o(p), g = Math.abs(d - c.x), b = Math.abs(y - c.y);
222
+ return t.axis === "x" ? g : t.axis === "y" ? b : Math.hypot(g, b);
223
+ };
224
+ let l = Array.from({ length: n }, (p, d) => a(d));
225
+ const h = Math.max(...l);
226
+ if (s === "edges" && (l = l.map((p) => h - p)), s === "random") {
227
+ const p = e.random ?? Math.random;
228
+ l = l.map(() => p() * h);
229
+ }
230
+ const f = t.amount !== void 0 ? t.amount : (t.each ?? 0) * h, u = t.ease ? V(t.ease) : void 0, m = u ? u.fn ?? F(u.easing) : void 0;
231
+ return l.map((p) => {
232
+ const d = h === 0 ? 0 : p / h;
233
+ return (m ? m(d) : d) * f;
234
+ });
235
+ }
236
+ const nt = /* @__PURE__ */ new Set([
237
+ "duration",
238
+ "delay",
239
+ "ease",
240
+ "repeat",
241
+ "repeatDelay",
242
+ "yoyo",
243
+ "stagger",
244
+ "onComplete",
245
+ "onUpdate",
246
+ "onStart",
247
+ "onRepeat",
248
+ "onReverseComplete",
249
+ "repeatRefresh",
250
+ "keyframes",
251
+ "easeEach",
252
+ "scrollTo",
253
+ "id",
254
+ "immediateRender",
255
+ "overwrite",
256
+ "paused",
257
+ "scrollTrigger",
258
+ "spring"
259
+ ]);
260
+ function B(n) {
261
+ const t = {}, e = {};
262
+ for (const [r, i] of Object.entries(n))
263
+ nt.has(r) ? t[r] = i : e[r] = i;
264
+ return { config: t, properties: e };
265
+ }
266
+ function U(n, t) {
267
+ return n === void 0 ? t : n * 1e3;
268
+ }
269
+ function Z(n, t) {
270
+ if (n !== void 0)
271
+ return typeof n == "number" ? { each: n * 1e3 } : se(n) ? { offsets: ae(t?.count ?? 0, n, t ?? {}).map((r) => r * 1e3) } : {
272
+ ...n.each !== void 0 && { each: n.each * 1e3 },
273
+ ...n.amount !== void 0 && { amount: n.amount * 1e3 },
274
+ ...n.from !== void 0 && { from: n.from }
275
+ };
276
+ }
277
+ const ce = {
278
+ opacity: 1,
279
+ x: 0,
280
+ y: 0,
281
+ z: 0,
282
+ rotate: 0,
283
+ rotateX: 0,
284
+ rotateY: 0,
285
+ rotateZ: 0,
286
+ rotation: 0,
287
+ scale: 1,
288
+ scaleX: 1,
289
+ scaleY: 1,
290
+ scaleZ: 1,
291
+ skewX: 0,
292
+ skewY: 0,
293
+ originX: 50,
294
+ originY: 50,
295
+ perspective: 0,
296
+ blur: 0,
297
+ glow: 0,
298
+ clipTop: 0,
299
+ clipRight: 0,
300
+ clipBottom: 0,
301
+ clipLeft: 0
302
+ };
303
+ function Rt(n) {
304
+ return ce[n];
305
+ }
306
+ function le(n) {
307
+ const t = typeof n == "string" || Array.isArray(n) ? { path: n } : n;
308
+ if (!t || typeof t.path != "string" && !Array.isArray(t.path))
309
+ throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");
310
+ let e;
311
+ if (Array.isArray(t.path))
312
+ e = Ut(t.path, { curviness: t.curviness });
313
+ else if (z(t.path))
314
+ e = t.path;
315
+ else
316
+ throw new Error(
317
+ `gsap-compat: motionPath "${t.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`
318
+ );
319
+ const r = { pathData: e };
320
+ return t.autoRotate !== void 0 && t.autoRotate !== !1 && (r.autoRotate = !0, typeof t.autoRotate == "number" && (r.rotateOffset = t.autoRotate)), t.matrix && (r.matrix = t.matrix), { config: r, start: t.start ?? 0, end: t.end ?? 1 };
321
+ }
322
+ function he(n) {
323
+ const t = typeof n == "string" || Array.isArray(n) ? { path: n } : { ...n };
324
+ return { ...t, start: t.end ?? 1, end: t.start ?? 0 };
325
+ }
326
+ function Ft(n) {
327
+ return typeof n == "object" && n !== null && "shape" in n ? n.shape : n;
328
+ }
329
+ function ue(n) {
330
+ if (n.morphSVG === void 0) return n;
331
+ const { morphSVG: t, ...e } = n, r = Ft(t);
332
+ if (typeof r != "string" || !z(r))
333
+ throw new Error(
334
+ `gsap-compat: morphSVG "${String(r)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`
335
+ );
336
+ return { ...e, d: r };
337
+ }
338
+ function fe(n, t) {
339
+ if (n === !0) return [0, t];
340
+ if (n === !1) return [0, 0];
341
+ if (typeof n == "number") return [0, dt(n, t)];
342
+ const e = n.trim().split(/[\s,]+/).filter(Boolean), r = (s) => {
343
+ const c = Number.parseFloat(s);
344
+ if (Number.isNaN(c)) throw new Error(`gsap-compat: drawSVG "${n}" is not a length or percentage`);
345
+ return dt(s.endsWith("%") ? t * c / 100 : c, t);
346
+ };
347
+ if (e.length === 0) return [0, t];
348
+ if (e.length === 1) return [0, r(e[0])];
349
+ const i = r(e[0]), o = r(e[1]);
350
+ return i <= o ? [i, o] : [o, i];
351
+ }
352
+ function de(n, t) {
353
+ const [e, r] = fe(n, t);
354
+ return { strokeDasharray: [r - e, t], strokeDashoffset: -e };
355
+ }
356
+ function me(n, t) {
357
+ if (n.drawSVG === void 0) return n;
358
+ const { drawSVG: e, ...r } = n;
359
+ return { ...r, ...de(e, t) };
360
+ }
361
+ function pe(n) {
362
+ if (n.drawSVG !== void 0)
363
+ throw new Error(
364
+ "gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties)."
365
+ );
366
+ return n;
367
+ }
368
+ function dt(n, t) {
369
+ return Math.max(0, Math.min(t, n));
370
+ }
371
+ function ye(n) {
372
+ let t = 2166136261;
373
+ for (let e = 0; e < n.length; e++) t = Math.imul(t ^ n.charCodeAt(e), 16777619);
374
+ return t >>> 0;
375
+ }
376
+ function ge(n, t, e) {
377
+ if (n.scrambleText !== void 0) {
378
+ const r = n.scrambleText, i = typeof r == "string" ? { text: r } : r;
379
+ if (typeof i?.text != "string")
380
+ throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");
381
+ const o = i.revealDelay && e > 0 ? i.revealDelay * 1e3 / e : void 0;
382
+ return {
383
+ to: i.text,
384
+ mode: "scramble",
385
+ ...i.chars !== void 0 && { chars: i.chars },
386
+ ...i.speed !== void 0 && { refreshRate: 20 * i.speed },
387
+ ...o !== void 0 && { revealDelay: Math.min(o, 0.999) },
388
+ ...i.tweenLength !== void 0 && { tweenLength: i.tweenLength },
389
+ ...i.rightToLeft !== void 0 && { rightToLeft: i.rightToLeft },
390
+ seed: i.seed ?? ye(`${t}|${i.text}`)
391
+ };
392
+ }
393
+ if (n.text !== void 0) {
394
+ const r = n.text, i = typeof r == "string" ? { value: r } : r;
395
+ if (typeof i?.value != "string")
396
+ throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");
397
+ return {
398
+ to: i.value,
399
+ mode: "type",
400
+ ...i.rightToLeft !== void 0 && { rightToLeft: i.rightToLeft }
401
+ };
402
+ }
403
+ }
404
+ function ot(n) {
405
+ return Math.max(0.1, n / 25);
406
+ }
407
+ function we(n, t) {
408
+ const e = typeof t == "number" ? { velocity: t } : t;
409
+ if (typeof e?.velocity != "number" || !Number.isFinite(e.velocity))
410
+ throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");
411
+ const r = e.friction ?? (e.resistance !== void 0 ? ot(e.resistance) : void 0), i = {
412
+ from: n,
413
+ velocity: e.velocity,
414
+ ...r !== void 0 && { friction: r },
415
+ ...e.min !== void 0 && { min: e.min },
416
+ ...e.max !== void 0 && { max: e.max }
417
+ };
418
+ return typeof e.end == "function" ? i.end = [e.end(H(i))] : e.end !== void 0 && (i.end = Array.isArray(e.end) ? [...e.end] : e.end), i;
419
+ }
420
+ function be(n) {
421
+ const t = n === !0 ? {} : typeof n == "string" ? { preset: n } : n;
422
+ if (t.preset !== void 0 && !(t.preset in _))
423
+ throw new Error(
424
+ `gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(_).join(", ")}`
425
+ );
426
+ return {
427
+ ...t.preset ? _[t.preset] : {},
428
+ ...t.stiffness !== void 0 && { stiffness: t.stiffness },
429
+ ...t.damping !== void 0 && { damping: t.damping },
430
+ ...t.mass !== void 0 && { mass: t.mass },
431
+ ...t.restDelta !== void 0 && { restDelta: t.restDelta }
432
+ };
433
+ }
434
+ function ve(n, t) {
435
+ if (n === !0 || typeof n == "string") return;
436
+ const e = n.velocity;
437
+ return typeof e == "number" ? e : e?.[t];
438
+ }
439
+ class $ {
440
+ /** The engine timeline. Use it for anything the facade does not cover. */
441
+ timeline;
442
+ options;
443
+ cursor = 0;
444
+ fallbackRandom = K(1);
445
+ previousStart = 0;
446
+ previousEnd = 0;
447
+ labels = /* @__PURE__ */ new Map();
448
+ trackCounter = 0;
449
+ /** Last authored value per "target|property", for the resolution chain. */
450
+ lastValues = /* @__PURE__ */ new Map();
451
+ constructor(t = {}) {
452
+ this.options = t, this.timeline = new Wt({
453
+ // A timestamped default would make the same script compile to different
454
+ // JSON on every run, which breaks the determinism contract. Callers that
455
+ // need distinct ids pass one.
456
+ id: t.id ?? "gsap-compat",
457
+ name: t.name,
458
+ config: {
459
+ ...t.repeat !== void 0 && { loop: t.repeat },
460
+ ...t.yoyo !== void 0 && { alternate: t.yoyo },
461
+ ...t.repeatDelay !== void 0 && { repeatDelay: t.repeatDelay * 1e3 },
462
+ ...t.timeScale !== void 0 && { speed: t.timeScale }
463
+ }
464
+ });
465
+ }
466
+ // --- tween creation -----------------------------------------------------
467
+ /** Animate to the given values. */
468
+ to(t, e, r) {
469
+ return this.build(t, void 0, N(e), r);
470
+ }
471
+ /** Animate from the given values to where the property already is. */
472
+ from(t, e, r) {
473
+ const { config: i, properties: o } = B(N(e)), { motionPath: s, text: c, scrambleText: a, ...l } = o, h = this.targetsOf(t)[0], f = { ...i };
474
+ for (const p of Object.keys(l))
475
+ f[p] = this.resolveStart(h, p);
476
+ s !== void 0 && (f.motionPath = he(s));
477
+ const u = {}, m = String(this.resolveStart(h, "text"));
478
+ return c !== void 0 && (u.text = G(c), f.text = typeof c == "object" ? { ...c, value: m } : m), a !== void 0 && (u.text = G(a), f.scrambleText = typeof a == "object" ? { ...a, text: m } : m), this.build(t, { ...l, ...u }, f, r);
479
+ }
480
+ /** Animate between two explicit sets of values. */
481
+ fromTo(t, e, r, i) {
482
+ const { properties: o } = B(N(e));
483
+ return this.build(t, o, N(r), i);
484
+ }
485
+ /** Set values instantly — a single held keyframe. */
486
+ set(t, e, r) {
487
+ return this.build(t, void 0, { ...N(e), duration: 0 }, r);
488
+ }
489
+ // --- sequencing ---------------------------------------------------------
490
+ /** Start of the tween (after its delay) or call added last, in milliseconds. */
491
+ get lastStart() {
492
+ return this.previousStart;
493
+ }
494
+ /** End of the tween or call added last, in milliseconds. */
495
+ get lastEnd() {
496
+ return this.previousEnd;
497
+ }
498
+ /**
499
+ * Place a zero-length event (a callback or a pause) at a position, as a tween of
500
+ * no duration would be: `'<'` and `'>'` after it refer to it. Returns its time in ms.
501
+ */
502
+ addEvent(t) {
503
+ const e = Math.max(0, I(t, this.context()));
504
+ return this.previousStart = e, this.previousEnd = e, this.cursor = Math.max(this.cursor, e), e;
505
+ }
506
+ /** Resolve a position (seconds, label, relative) to milliseconds without adding anything. */
507
+ timeOf(t) {
508
+ return I(t, this.context());
509
+ }
510
+ /** Name a point in time, for use as a position parameter. */
511
+ addLabel(t, e) {
512
+ return this.labels.set(t, I(e, this.context())), this;
513
+ }
514
+ /** Time of a label, in milliseconds. */
515
+ /** Every label's time in milliseconds, in time order. */
516
+ labelTimes() {
517
+ return [...this.labels.values()].sort((t, e) => t - e);
518
+ }
519
+ labelTime(t) {
520
+ return this.labels.get(t);
521
+ }
522
+ /**
523
+ * Merge another compat timeline in at a position.
524
+ *
525
+ * Nested timelines are flattened at compile time — every keyframe is offset
526
+ * and copied in — so there is no nested-timeline runtime and the output is
527
+ * one flat, serializable track list.
528
+ */
529
+ add(t, e) {
530
+ const r = I(e, this.context());
531
+ for (const o of t.timeline.tracks) {
532
+ if (!("keyframes" in o)) continue;
533
+ const s = ct({
534
+ ...o,
535
+ id: this.nextTrackId(`nested-${o.id}`),
536
+ keyframes: o.keyframes.map((c) => ({ ...c, time: c.time + r }))
537
+ });
538
+ this.timeline.addTrack(s);
539
+ }
540
+ const i = r + t.timeline.duration;
541
+ return this.previousStart = r, this.previousEnd = i, this.cursor = Math.max(this.cursor, i), this;
542
+ }
543
+ // --- playback -----------------------------------------------------------
544
+ play() {
545
+ return this.timeline.play(), this;
546
+ }
547
+ pause() {
548
+ return this.timeline.pause(), this;
549
+ }
550
+ restart() {
551
+ return this.timeline.stop(), this.timeline.play(), this;
552
+ }
553
+ reverse() {
554
+ return this.timeline.reverse(), this;
555
+ }
556
+ kill() {
557
+ return this.timeline.removeTracks(), this;
558
+ }
559
+ /**
560
+ * Remove every tween and forget the cursor, labels and chained start values,
561
+ * so the same calls can build it again from scratch (`invalidate` in `live`).
562
+ */
563
+ reset() {
564
+ return this.timeline.removeTracks(), this.cursor = 0, this.previousStart = 0, this.previousEnd = 0, this.labels.clear(), this.lastValues.clear(), this.trackCounter = 0, this;
565
+ }
566
+ /** Seek to a time in seconds, or to a label. */
567
+ seek(t) {
568
+ if (typeof t == "string") {
569
+ const e = this.labels.get(t);
570
+ return e !== void 0 && this.timeline.seek(e), this;
571
+ }
572
+ return this.timeline.seek(t * 1e3), this;
573
+ }
574
+ /** Progress through the timeline, 0..1. */
575
+ progress(t) {
576
+ const e = this.timeline.duration;
577
+ return t !== void 0 && e > 0 && this.timeline.seek(t * e), e > 0 ? this.timeline.currentTime / e : 0;
578
+ }
579
+ /** Playback rate. */
580
+ timeScale(t) {
581
+ return t !== void 0 && (this.timeline.speed = t), this.timeline.speed;
582
+ }
583
+ /** Total duration in seconds (GSAP's unit). */
584
+ duration() {
585
+ return this.timeline.duration / 1e3;
586
+ }
587
+ /** Advance by `deltaMs` — the host still owns the animation loop. */
588
+ tick(t) {
589
+ return this.timeline.tick(t), this;
590
+ }
591
+ /** The compiled animation, as plain JSON. */
592
+ toDefinition() {
593
+ return this.timeline.toDefinition();
594
+ }
595
+ // --- compilation --------------------------------------------------------
596
+ /**
597
+ * Compile one tween into tracks.
598
+ *
599
+ * `fromProperties` holds explicit start values (fromTo / from); when absent,
600
+ * each property's start comes from the resolution chain.
601
+ */
602
+ build(t, e, r, i) {
603
+ const { config: o, properties: s } = B(r), { motionPath: c, text: a, scrambleText: l, inertia: h, ...f } = s, u = this.targetsOf(t), m = I(i, this.context()), p = U(o.delay, 0), d = U(o.duration, 500), y = Z(o.stagger, {
604
+ count: u.length,
605
+ columnsFromLayout: this.options.layoutColumns ? () => this.options.layoutColumns(u) : void 0,
606
+ random: this.options.random ?? this.fallbackRandom
607
+ }), g = this.easingFor(o.ease), b = [], w = o.spring;
608
+ let k = 0, x = !1;
609
+ for (const [T, R] of Object.entries(f)) {
610
+ const E = R;
611
+ let A = e?.[T] !== void 0 ? e[T] : this.resolveStart(u[0], T);
612
+ if (typeof A != typeof E && (this.warn(
613
+ `no usable start value for "${T}" on "${u[0]}" — it will snap to ${String(E)}. Use fromTo() to animate it.`
614
+ ), A = E), w !== void 0 && typeof A == "number" && typeof E == "number") {
615
+ const O = {
616
+ ...be(w),
617
+ from: A,
618
+ to: E,
619
+ velocity: ve(w, T) ?? this.options.startVelocity?.(u[0], T) ?? 0
620
+ }, st = this.nextTrackId(`${u[0]}-${T}-spring`), Vt = {
621
+ id: st,
622
+ target: u[0],
623
+ ...u.length > 1 && { targets: u },
624
+ ...y && u.length > 1 && { stagger: y },
625
+ property: T,
626
+ kind: "spring",
627
+ spring: O,
628
+ delay: m + p
629
+ };
630
+ this.timeline.addTrack(Vt), b.push(st), k = Math.max(k, zt(O));
631
+ for (const jt of u) this.lastValues.set(`${jt}|${T}`, E);
632
+ continue;
633
+ }
634
+ x = !0;
635
+ const D = this.keyframesFor(A, E, d, g, o.ease), j = this.nextTrackId(`${u[0]}-${T}`);
636
+ this.timeline.addTrack(
637
+ ct({
638
+ id: j,
639
+ target: u[0],
640
+ ...u.length > 1 && { targets: u },
641
+ ...y && u.length > 1 && { stagger: y },
642
+ property: T,
643
+ delay: m + p,
644
+ keyframes: D
645
+ })
646
+ ), b.push(j);
647
+ for (const O of u) this.lastValues.set(`${O}|${T}`, E);
648
+ }
649
+ const v = ge({ text: a, scrambleText: l }, u[0], d);
650
+ if (v) {
651
+ const T = e?.text ?? e?.scrambleText, R = T !== void 0 ? G(T) : this.resolveStart(u[0], "text"), E = this.nextTrackId(`${u[0]}-text`), A = {
652
+ id: E,
653
+ target: u[0],
654
+ ...u.length > 1 && { targets: u },
655
+ ...y && u.length > 1 && { stagger: y },
656
+ property: "text",
657
+ textConfig: { from: typeof R == "string" ? R : String(R ?? ""), ...v },
658
+ delay: m + p,
659
+ keyframes: this.keyframesFor(0, 1, d, g, o.ease)
660
+ };
661
+ this.timeline.addTrack(A), b.push(E);
662
+ for (const D of u) this.lastValues.set(`${D}|text`, v.to);
663
+ }
664
+ if (c !== void 0) {
665
+ const { config: T, start: R, end: E } = le(c), A = this.nextTrackId(`${u[0]}-motionPath`), D = {
666
+ id: A,
667
+ target: u[0],
668
+ ...u.length > 1 && { targets: u },
669
+ ...y && u.length > 1 && { stagger: y },
670
+ property: "motionPath",
671
+ motionPathConfig: T,
672
+ delay: m + p,
673
+ keyframes: this.keyframesFor(R, E, d, g, o.ease)
674
+ };
675
+ this.timeline.addTrack(D), b.push(A);
676
+ }
677
+ if (h !== void 0)
678
+ for (const [T, R] of Object.entries(h)) {
679
+ const E = this.resolveStart(u[0], T);
680
+ if (typeof E != "number") {
681
+ this.warn(`inertia on "${T}" needs a numeric start value; skipped`);
682
+ continue;
683
+ }
684
+ const A = we(E, R), D = this.nextTrackId(`${u[0]}-${T}-inertia`), j = {
685
+ id: D,
686
+ target: u[0],
687
+ ...u.length > 1 && { targets: u },
688
+ ...y && u.length > 1 && { stagger: y },
689
+ property: T,
690
+ kind: "inertia",
691
+ inertia: A,
692
+ delay: m + p
693
+ };
694
+ this.timeline.addTrack(j), b.push(D), k = Math.max(k, _t(A));
695
+ for (const O of u) this.lastValues.set(`${O}|${T}`, Gt(A));
696
+ }
697
+ const L = ((h !== void 0 || w !== void 0) && !x && !v && c === void 0 ? k : Math.max(d, k)) + (y && u.length > 1 ? Yt(u.length, y) : 0), M = m + p + L;
698
+ return this.previousStart = m + p, this.previousEnd = M, this.cursor = Math.max(this.cursor, M), {
699
+ trackIds: b,
700
+ start: m + p,
701
+ end: M,
702
+ kill: () => {
703
+ for (const T of b) this.timeline.removeTrack(T);
704
+ }
705
+ };
706
+ }
707
+ /**
708
+ * Two keyframes, or a baked sequence when the ease has no closed form.
709
+ */
710
+ keyframesFor(t, e, r, i, o) {
711
+ const s = { time: 0, value: t };
712
+ if (r <= 0)
713
+ return [{ time: 0, value: e }];
714
+ const c = typeof o == "string" ? V(o) : void 0;
715
+ if (c?.requiresBaking === "custom" || this.options.bakeEases && Xt(i)) {
716
+ const l = c?.fn ?? F(i);
717
+ return [s, ...Ht(s, { time: r, value: e }, l, { intervalMs: this.options.bakeIntervalMs })];
718
+ }
719
+ return [s, { time: r, value: e, ...i && { easing: i } }];
720
+ }
721
+ /** Resolve a start value through the documented chain. */
722
+ resolveStart(t, e) {
723
+ const r = this.lastValues.get(`${t}|${e}`);
724
+ if (r !== void 0) return r;
725
+ const i = this.options.startValue?.(t, e);
726
+ if (i !== void 0) return i;
727
+ const o = this.options.defaults?.[e];
728
+ if (o !== void 0) return o;
729
+ if (e === "text") return "";
730
+ if (e === "d")
731
+ throw new Error(
732
+ `gsap-compat: no starting shape for "${t}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`
733
+ );
734
+ const s = Rt(e);
735
+ return s !== void 0 ? (this.warn(
736
+ `no start value for "${e}" on "${t}" — using the static default ${s}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`
737
+ ), s) : (this.warn(`no start value or default for "${e}" on "${t}" — using 0`), 0);
738
+ }
739
+ easingFor(t) {
740
+ if (t !== void 0) {
741
+ if (typeof t == "string") return V(t).easing;
742
+ if (typeof t == "function")
743
+ throw new Error(
744
+ 'gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.'
745
+ );
746
+ return t;
747
+ }
748
+ }
749
+ targetsOf(t) {
750
+ return Array.isArray(t) ? t : [t];
751
+ }
752
+ context() {
753
+ return {
754
+ cursor: this.cursor,
755
+ previousStart: this.previousStart,
756
+ previousEnd: this.previousEnd,
757
+ labels: this.labels,
758
+ // Position literals are GSAP seconds; everything stored is milliseconds.
759
+ scale: 1e3
760
+ };
761
+ }
762
+ nextTrackId(t) {
763
+ return this.trackCounter += 1, `${t}-${this.trackCounter}`;
764
+ }
765
+ warn(t) {
766
+ this.options.onWarning?.(`gsap-compat: ${t}`);
767
+ }
768
+ }
769
+ function G(n) {
770
+ if (typeof n == "string") return n;
771
+ if (n && typeof n == "object") {
772
+ const t = n;
773
+ return String(t.value ?? t.text ?? "");
774
+ }
775
+ return String(n ?? "");
776
+ }
777
+ function ke(n) {
778
+ return new $(n);
779
+ }
780
+ function N(n) {
781
+ return pe(ue(n));
782
+ }
783
+ function kr(n) {
784
+ const { timeline: t } = n, e = new St();
785
+ for (const [l, h] of Object.entries(n.targets)) {
786
+ const f = typeof h == "string" ? document.querySelector(h) : h;
787
+ if (!f)
788
+ throw new Error(`quickPlay: no element found for target "${l}" (${String(h)})`);
789
+ e.registerTarget(l, f);
790
+ }
791
+ t.onUpdate = (l) => {
792
+ e.applyState(l), n.onUpdate?.(l);
793
+ }, n.onComplete && (t.onComplete = n.onComplete);
794
+ let r = null, i = null, o = !1;
795
+ const s = (l) => {
796
+ if (o) return;
797
+ const h = i === null ? 0 : l - i;
798
+ i = l, h > 0 && t.tick(h), r = requestAnimationFrame(s);
799
+ }, c = () => {
800
+ r !== null || o || (i = null, r = requestAnimationFrame(s));
801
+ }, a = () => {
802
+ r !== null && cancelAnimationFrame(r), r = null, i = null;
803
+ };
804
+ return e.applyState(t.getStateAtTime(t.currentTime)), n.autoplay !== !1 && (t.play(), c()), {
805
+ timeline: t,
806
+ adapter: e,
807
+ play() {
808
+ t.play(), c();
809
+ },
810
+ pause() {
811
+ t.pause(), a();
812
+ },
813
+ restart() {
814
+ t.stop(), t.play(), c();
815
+ },
816
+ seek(l) {
817
+ t.seek(l * 1e3), e.applyState(t.getStateAtTime(t.currentTime));
818
+ },
819
+ destroy() {
820
+ o = !0, a(), t.stop(), e.clearTargets();
821
+ }
822
+ };
823
+ }
824
+ const Pt = (n) => typeof n == "object" && n !== null && n.nodeType === 1;
825
+ function Dt(n) {
826
+ const t = {};
827
+ for (const e of Array.from(n.attributes)) t[e.name] = e.value;
828
+ return t;
829
+ }
830
+ function Lt(n) {
831
+ if (!n) return null;
832
+ const t = et({ tag: n.localName, attributes: Dt(n) });
833
+ return t || (n.querySelector("path")?.getAttribute("d") ?? null);
834
+ }
835
+ function Te(n, t, e) {
836
+ const r = Ft(n);
837
+ if (typeof r == "string" && z(r)) return r;
838
+ const i = Pt(r) ? r : typeof r == "string" ? t(r) : null, o = Lt(i);
839
+ return o || (e(`gsap-compat: morphSVG could not find a shape for "${String(r)}"`), "");
840
+ }
841
+ const xe = /* @__PURE__ */ new Set(["cx", "cy", "r", "rx", "ry", "x", "y", "width", "height", "x1", "y1", "x2", "y2", "points"]);
842
+ function Se(n, t = document) {
843
+ return (typeof n == "string" ? Array.from(t.querySelectorAll(n)) : Pt(n) ? [n] : Array.from(n)).map((r) => {
844
+ if (r.localName === "path") return r;
845
+ const i = et({ tag: r.localName, attributes: Dt(r) });
846
+ if (!i || !r.parentNode) return r;
847
+ const o = r.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
848
+ for (const s of Array.from(r.attributes))
849
+ xe.has(s.name) || o.setAttribute(s.name, s.value);
850
+ return o.setAttribute("d", i), r.parentNode.replaceChild(o, r), o;
851
+ });
852
+ }
853
+ function Me(n, t = {}) {
854
+ const e = new Set((t.type ?? "chars,words,lines").split(",").map((d) => d.trim())), r = {
855
+ chars: t.charsClass ?? "char",
856
+ words: t.wordsClass ?? "word",
857
+ lines: t.linesClass ?? "line"
858
+ }, i = t.aria !== !1, o = n.map((d) => ({
859
+ element: d,
860
+ html: d.innerHTML,
861
+ ariaLabel: d.getAttribute("aria-label")
862
+ }));
863
+ let s = { chars: [], words: [], lines: [], masks: [] }, c, a, l = !1;
864
+ const h = () => {
865
+ for (const { element: d, html: y, ariaLabel: g } of o)
866
+ d.innerHTML = y, g === null ? d.removeAttribute("aria-label") : d.setAttribute("aria-label", g);
867
+ }, f = () => {
868
+ c && (c.revert ? c.revert() : c.kill?.(), c = void 0);
869
+ }, u = () => {
870
+ const d = { chars: [], words: [], lines: [], masks: [] };
871
+ for (const { element: y } of o) {
872
+ const g = (y.textContent ?? "").replace(/\s+/g, " ").trim(), b = Ee(y, r.words), w = e.has("chars") ? b.flatMap((v) => Ae(v, r.chars)) : [], k = e.has("lines") ? Re(y, b, r.lines) : [];
873
+ if (i) {
874
+ !y.hasAttribute("aria-label") && g && y.setAttribute("aria-label", g);
875
+ for (const v of b) v.setAttribute("aria-hidden", "true");
876
+ }
877
+ if (e.has("words")) d.words.push(...b);
878
+ else for (const v of b) v.removeAttribute("class");
879
+ d.chars.push(...w), d.lines.push(...k);
880
+ const x = t.mask === "lines" ? k : t.mask === "words" ? b : t.mask === "chars" ? w : [];
881
+ for (const v of x) d.masks.push(Fe(v, `${r[t.mask]}-mask`));
882
+ }
883
+ s = d;
884
+ }, m = {
885
+ elements: n,
886
+ get chars() {
887
+ return s.chars;
888
+ },
889
+ get words() {
890
+ return s.words;
891
+ },
892
+ get lines() {
893
+ return s.lines;
894
+ },
895
+ get masks() {
896
+ return s.masks;
897
+ },
898
+ split() {
899
+ l || (f(), h(), u(), c = t.onSplit?.(m));
900
+ },
901
+ revert() {
902
+ l = !0, a?.disconnect(), f(), h();
903
+ }
904
+ };
905
+ u(), c = t.onSplit?.(m), t.autoSplit && p();
906
+ function p() {
907
+ const d = /* @__PURE__ */ new Map();
908
+ let y = !1;
909
+ const g = () => {
910
+ if (y) return;
911
+ y = !0;
912
+ const w = () => {
913
+ y = !1, m.split();
914
+ };
915
+ typeof requestAnimationFrame == "function" ? requestAnimationFrame(w) : setTimeout(w, 0);
916
+ };
917
+ if (typeof ResizeObserver == "function") {
918
+ a = new ResizeObserver((w) => {
919
+ let k = !1;
920
+ for (const x of w) {
921
+ const v = Math.round(x.contentRect.width), S = d.get(x.target);
922
+ d.set(x.target, v), S !== void 0 && S !== v && (k = !0);
923
+ }
924
+ k && g();
925
+ });
926
+ for (const w of n) a.observe(w);
927
+ }
928
+ const b = n[0]?.ownerDocument?.fonts;
929
+ b && b.status !== "loaded" && b.ready.then(() => g());
930
+ }
931
+ return m;
932
+ }
933
+ function Ee(n, t) {
934
+ const e = n.ownerDocument, r = [], i = e.createTreeWalker(
935
+ n,
936
+ 4
937
+ /* NodeFilter.SHOW_TEXT */
938
+ ), o = [];
939
+ for (let s = i.nextNode(); s; s = i.nextNode()) o.push(s);
940
+ for (const s of o) {
941
+ const c = s.data.match(/\s+|\S+/g) ?? [];
942
+ if (c.length === 0) continue;
943
+ const a = e.createDocumentFragment();
944
+ for (const l of c) {
945
+ if (/^\s/.test(l)) {
946
+ a.appendChild(e.createTextNode(l));
947
+ continue;
948
+ }
949
+ const h = e.createElement("span");
950
+ h.className = t, h.style.display = "inline-block", h.textContent = l, a.appendChild(h), r.push(h);
951
+ }
952
+ s.replaceWith(a);
953
+ }
954
+ return r;
955
+ }
956
+ function Ae(n, t) {
957
+ const e = n.ownerDocument, r = Ce(n.textContent ?? "").map((i) => {
958
+ const o = e.createElement("span");
959
+ return o.className = t, o.style.display = "inline-block", o.textContent = i, o;
960
+ });
961
+ return n.replaceChildren(...r), r;
962
+ }
963
+ function Ce(n) {
964
+ const t = Intl.Segmenter;
965
+ return t ? Array.from(new t(void 0, { granularity: "grapheme" }).segment(n), (e) => e.segment) : Array.from(n);
966
+ }
967
+ function Re(n, t, e) {
968
+ const r = n.ownerDocument, i = new Map(t.map((p) => [p, p.getBoundingClientRect()])), o = [], s = (p) => {
969
+ for (const d of Array.from(p.childNodes))
970
+ d.nodeType === 3 || i.has(d) || d.tagName === "BR" ? o.push(d) : s(d);
971
+ };
972
+ s(n);
973
+ const c = [];
974
+ let a = null, l = 0, h = 0, f = !1, u = [];
975
+ const m = () => {
976
+ a = r.createElement("span"), a.className = e, a.style.display = "block", c.push(a), u = [];
977
+ };
978
+ for (const p of o) {
979
+ if (p.tagName === "BR") {
980
+ f = !0;
981
+ continue;
982
+ }
983
+ const d = i.get(p);
984
+ if (d && (!a || f || d.top > l + h) && (m(), l = d.top, h = d.height / 2, f = !1), !a) continue;
985
+ const y = [];
986
+ for (let w = p.parentNode; w && w !== n; w = w.parentNode) y.unshift(w);
987
+ let g = 0;
988
+ for (; g < u.length && g < y.length && u[g].original === y[g]; ) g++;
989
+ u.length = g;
990
+ let b = g === 0 ? a : u[g - 1].clone;
991
+ for (const w of y.slice(g)) {
992
+ const k = w.cloneNode(!1);
993
+ b.appendChild(k), u.push({ original: w, clone: k }), b = k;
994
+ }
995
+ b.appendChild(p);
996
+ }
997
+ return n.replaceChildren(...c), c;
998
+ }
999
+ function Fe(n, t) {
1000
+ const e = n.ownerDocument.createElement("span");
1001
+ return e.className = t, e.style.display = n.style.display === "block" ? "block" : "inline-block", e.style.overflow = "clip", e.style.paddingBottom = "0.12em", e.style.marginBottom = "-0.12em", n.replaceWith(e), e.appendChild(n), e;
1002
+ }
1003
+ function Pe(n, t) {
1004
+ switch (t) {
1005
+ // Play forward from wherever it is; reverse() flips a reversed timeline and plays.
1006
+ // Neither restarts an animation that is already at that end.
1007
+ case "play":
1008
+ if (n.progress() >= 1) break;
1009
+ n.reversed() ? n.reverse() : n.play();
1010
+ break;
1011
+ case "reverse":
1012
+ if (n.progress() <= 0) break;
1013
+ n.reversed() ? n.play() : n.reverse();
1014
+ break;
1015
+ case "pause":
1016
+ n.pause();
1017
+ break;
1018
+ case "resume":
1019
+ n.resume();
1020
+ break;
1021
+ case "restart":
1022
+ n.restart();
1023
+ break;
1024
+ case "reset":
1025
+ n.pause(), n.progress(0);
1026
+ break;
1027
+ case "complete":
1028
+ n.pause(), n.progress(1);
1029
+ break;
1030
+ }
1031
+ }
1032
+ function it(n, t, e, r, i = () => {
1033
+ }) {
1034
+ const o = (m) => typeof m == "string" ? n.query(m) ?? void 0 : m, s = o(t.trigger) ?? r;
1035
+ if (!s) {
1036
+ i(`gsap-compat: scrollTrigger has no trigger element${typeof t.trigger == "string" ? ` for "${t.trigger}"` : ""}`);
1037
+ return;
1038
+ }
1039
+ const c = t.scrub === void 0 || t.scrub === !1 ? !1 : t.scrub, a = (t.toggleActions ?? "play none none none").trim().split(/\s+/);
1040
+ let l = 0, h;
1041
+ const f = (m, p) => () => {
1042
+ p?.(), e && !c && Pe(e, a[m] ?? "none"), t.once && m === 0 && queueMicrotask(() => h.destroy());
1043
+ }, u = t.containerAnimation ? Oe(n, t.containerAnimation, s, i) : void 0;
1044
+ return h = new Mt({
1045
+ trigger: s,
1046
+ start: t.start,
1047
+ end: t.end,
1048
+ scrub: c === !1 ? void 0 : c,
1049
+ pin: t.pin === !0 ? !0 : o(t.pin),
1050
+ scroller: o(t.scroller),
1051
+ horizontal: t.horizontal,
1052
+ pinSpacing: t.pinSpacing,
1053
+ onRefresh: t.invalidateOnRefresh && e?.invalidate ? () => e.invalidate() : void 0,
1054
+ snap: t.snap === void 0 ? void 0 : De(t.snap, e),
1055
+ markers: t.markers,
1056
+ container: u,
1057
+ onUpdate: (m, p) => {
1058
+ if (e && c !== !1 && e.progress(m), t.onUpdate) {
1059
+ const d = m < l || p < 0 ? -1 : 1;
1060
+ t.onUpdate({ progress: m, velocity: p, direction: d });
1061
+ }
1062
+ l = m;
1063
+ },
1064
+ onEnter: f(0, t.onEnter),
1065
+ onLeave: f(1, t.onLeave),
1066
+ onEnterBack: f(2, t.onEnterBack),
1067
+ onLeaveBack: f(3, t.onLeaveBack)
1068
+ }), e && c === !1 && e.progress(0), h.start(), n.own(h);
1069
+ }
1070
+ function De(n, t) {
1071
+ const e = (i) => i === "labels" ? (o) => Le(o, t?.labelProgresses?.() ?? []) : i;
1072
+ if (typeof n != "object" || Array.isArray(n)) return e(n);
1073
+ const r = n.ease ? V(n.ease) : void 0;
1074
+ return {
1075
+ snapTo: e(n.snapTo),
1076
+ duration: n.duration,
1077
+ delay: n.delay,
1078
+ ease: r ? r.fn ?? F(r.easing) : void 0
1079
+ };
1080
+ }
1081
+ function Le(n, t) {
1082
+ return t.reduce((e, r) => Math.abs(r - n) < Math.abs(e - n) ? r : e, t[0] ?? n);
1083
+ }
1084
+ function Oe(n, t, e, r) {
1085
+ const i = () => t.timeline.getTracks({ property: "x" }).map((o) => o.target).filter((o) => {
1086
+ const s = n.elementFor(o);
1087
+ return !!s && s !== e && s.contains(e);
1088
+ });
1089
+ return i().length === 0 && r("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"), {
1090
+ range: () => {
1091
+ const o = t.scrollTrigger;
1092
+ return o || r("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"), { start: o?.startOffset ?? 0, end: o?.endOffset ?? 0 };
1093
+ },
1094
+ progress: () => t.progress(),
1095
+ shiftAt: (o) => {
1096
+ const s = t.timeline.getStateAtTime(o * t.timeline.duration);
1097
+ let c = 0;
1098
+ for (const a of i()) {
1099
+ const l = s.values.get(a)?.get("x");
1100
+ typeof l == "number" && (c += l);
1101
+ }
1102
+ return c;
1103
+ }
1104
+ };
1105
+ }
1106
+ class Ot {
1107
+ /** For contexts made by matchMedia: which named queries match */
1108
+ conditions = {};
1109
+ scope;
1110
+ host;
1111
+ items = [];
1112
+ snapshots = /* @__PURE__ */ new Map();
1113
+ constructor(t, e) {
1114
+ this.host = t, this.scope = e;
1115
+ }
1116
+ /**
1117
+ * Run `fn` with this context collecting, and return what it returns. A function
1118
+ * it returns is kept as cleanup and called on `revert()`.
1119
+ */
1120
+ add(t) {
1121
+ const e = this.host.collector;
1122
+ this.host.setCollector(this);
1123
+ try {
1124
+ const r = t();
1125
+ return typeof r == "function" && this.items.push({ revert: r }), r;
1126
+ } finally {
1127
+ this.host.setCollector(e);
1128
+ }
1129
+ }
1130
+ track(t) {
1131
+ this.items.push(t);
1132
+ }
1133
+ touch(t, e) {
1134
+ this.snapshots.has(t) || this.snapshots.set(t, { name: e, style: t.getAttribute("style"), d: t.getAttribute("d") });
1135
+ }
1136
+ /** Undo everything, newest first, and restore the elements this context animated. */
1137
+ revert() {
1138
+ for (const t of this.items.splice(0).reverse())
1139
+ t.revert ? t.revert() : t.kill ? t.kill() : t.destroy?.();
1140
+ for (const [t, { name: e, style: r, d: i }] of this.snapshots)
1141
+ r === null ? t.removeAttribute("style") : t.setAttribute("style", r), i !== null && t.setAttribute("d", i), this.host.forget(e);
1142
+ this.snapshots.clear();
1143
+ }
1144
+ /** Same as `revert()`: GSAP's name for dropping a context. */
1145
+ kill() {
1146
+ this.revert();
1147
+ }
1148
+ }
1149
+ class $e {
1150
+ host;
1151
+ scope;
1152
+ entries = [];
1153
+ listeners = [];
1154
+ scheduled = !1;
1155
+ constructor(t, e) {
1156
+ this.host = t, this.scope = e;
1157
+ }
1158
+ add(t, e) {
1159
+ const r = { conditions: t, setup: e, queries: /* @__PURE__ */ new Map() }, i = typeof t == "string" ? { matches: t } : t;
1160
+ if (typeof window < "u" && typeof window.matchMedia == "function")
1161
+ for (const [o, s] of Object.entries(i)) {
1162
+ const c = window.matchMedia(s);
1163
+ r.queries.set(o, c);
1164
+ const a = () => this.scheduleUpdate();
1165
+ c.addEventListener("change", a), this.listeners.push(() => c.removeEventListener("change", a));
1166
+ }
1167
+ return this.entries.push(r), this.update(r), this;
1168
+ }
1169
+ /** Revert every active setup and stop listening. */
1170
+ revert() {
1171
+ for (const t of this.listeners.splice(0)) t();
1172
+ for (const t of this.entries.splice(0)) t.context?.revert();
1173
+ }
1174
+ kill() {
1175
+ this.revert();
1176
+ }
1177
+ /** Several queries change on one resize; handle them together. */
1178
+ scheduleUpdate() {
1179
+ this.scheduled || (this.scheduled = !0, queueMicrotask(() => {
1180
+ this.scheduled = !1;
1181
+ for (const t of this.entries) this.update(t);
1182
+ }));
1183
+ }
1184
+ update(t) {
1185
+ const e = {};
1186
+ for (const [s, c] of t.queries) e[s] = c.matches;
1187
+ const r = Object.values(e).some(Boolean), i = r ? JSON.stringify(e) : void 0;
1188
+ if (i === t.key || (t.context?.revert(), t.context = void 0, t.key = i, !r)) return;
1189
+ const o = new Ot(this.host, this.scope);
1190
+ o.conditions = e, o.add(() => t.setup(o)), t.context = o;
1191
+ }
1192
+ }
1193
+ class Ie {
1194
+ frames;
1195
+ canvas;
1196
+ context;
1197
+ options;
1198
+ images;
1199
+ ready;
1200
+ current = 0;
1201
+ drawn = -1;
1202
+ loadedCount = 0;
1203
+ inFlight = 0;
1204
+ destroyed = !1;
1205
+ onResize = () => this.resize();
1206
+ constructor(t, e) {
1207
+ this.canvas = t, this.context = t.getContext("2d"), this.options = e, this.frames = Math.max(1, Math.floor(e.frames)), this.images = new Array(this.frames), this.ready = new Array(this.frames).fill(!1), typeof window < "u" && window.addEventListener("resize", this.onResize, { passive: !0 }), this.resize(), this.pump();
1208
+ }
1209
+ /** The frame on screen (fractional values show the nearest frame) */
1210
+ get frame() {
1211
+ return this.current;
1212
+ }
1213
+ set frame(t) {
1214
+ this.current = Math.max(0, Math.min(this.frames - 1, t)), this.draw();
1215
+ }
1216
+ /** How many frames have loaded */
1217
+ get loaded() {
1218
+ return this.loadedCount;
1219
+ }
1220
+ /** Stop loading, forget the images, and stop listening for resizes. */
1221
+ destroy() {
1222
+ this.destroyed = !0, typeof window < "u" && window.removeEventListener("resize", this.onResize);
1223
+ for (const t of this.images) t && (t.src = "");
1224
+ }
1225
+ /** Match the canvas's pixels to its size on screen, then redraw. */
1226
+ resize() {
1227
+ const t = typeof window < "u" ? Math.min(window.devicePixelRatio || 1, 2) : 1, e = Math.round(this.canvas.clientWidth * t), r = Math.round(this.canvas.clientHeight * t);
1228
+ e > 0 && r > 0 && (this.canvas.width !== e || this.canvas.height !== r) && (this.canvas.width = e, this.canvas.height = r), this.drawn = -1, this.draw();
1229
+ }
1230
+ draw() {
1231
+ const t = Math.round(this.current), e = this.nearestReady(t);
1232
+ if (e === -1 || e === this.drawn || !this.context) return;
1233
+ const r = this.images[e], { width: i, height: o } = this.canvas, s = (this.options.fit ?? "cover") === "cover" ? Math.max(i / r.naturalWidth, o / r.naturalHeight) : Math.min(i / r.naturalWidth, o / r.naturalHeight), c = r.naturalWidth * s, a = r.naturalHeight * s;
1234
+ this.context.clearRect(0, 0, i, o), this.context.drawImage(r, (i - c) / 2, (o - a) / 2, c, a), this.drawn = e, this.pump();
1235
+ }
1236
+ /** The loaded frame closest to `index`, or -1. */
1237
+ nearestReady(t) {
1238
+ for (let e = 0; e < this.frames; e++) {
1239
+ if (t - e >= 0 && this.ready[t - e]) return t - e;
1240
+ if (t + e < this.frames && this.ready[t + e]) return t + e;
1241
+ }
1242
+ return -1;
1243
+ }
1244
+ /** Start loads, nearest to the current frame first, up to the concurrency. */
1245
+ pump() {
1246
+ const t = this.options.concurrency ?? 6, e = Math.round(this.current);
1247
+ for (let r = 0; r < this.frames && this.inFlight < t; r++)
1248
+ for (const i of r === 0 ? [e] : [e + r, e - r])
1249
+ i < 0 || i >= this.frames || this.images[i] || this.inFlight >= t || this.load(i);
1250
+ }
1251
+ load(t) {
1252
+ const e = new Image();
1253
+ e.decoding = "async", this.images[t] = e, this.inFlight++;
1254
+ const r = (i) => {
1255
+ if (!this.destroyed) {
1256
+ if (this.inFlight--, i) {
1257
+ this.ready[t] = !0, this.loadedCount++, this.options.onProgress?.(this.loadedCount, this.frames);
1258
+ const o = Math.round(this.current);
1259
+ (Math.abs(t - o) < Math.abs(this.drawn - o) || this.drawn === -1) && (this.drawn = -1, this.draw());
1260
+ }
1261
+ this.pump();
1262
+ }
1263
+ };
1264
+ e.onload = () => r(!0), e.onerror = () => r(!1), e.src = this.options.url(t);
1265
+ }
1266
+ }
1267
+ const Ne = {
1268
+ /** Register a curve from SVG path data or bezier points. Returns the name. */
1269
+ create: (n, t) => rt(n, Zt(t))
1270
+ }, Ve = {
1271
+ /** Register a bouncing ease that lands and settles on the end value. Returns the name. */
1272
+ create: (n, t) => rt(n, { fn: Kt(t) })
1273
+ }, je = {
1274
+ /** Register a wiggle that swings around the start value and returns to it. Returns the name. */
1275
+ create: (n, t) => rt(n, { fn: Jt(t) })
1276
+ };
1277
+ function W(n) {
1278
+ const t = n.style;
1279
+ if (!t) return n.getBoundingClientRect();
1280
+ const e = t.transform;
1281
+ t.transform = "none";
1282
+ const r = n.getBoundingClientRect();
1283
+ return t.transform = e, r;
1284
+ }
1285
+ const qe = { x: "x", y: "y", "x,y": "both" }, J = (n) => typeof n == "object" && n !== null && n.nodeType === 1;
1286
+ function mt(n, t) {
1287
+ const e = W(n), r = t.getBoundingClientRect();
1288
+ return {
1289
+ minX: r.left - e.left,
1290
+ maxX: r.right - e.right,
1291
+ minY: r.top - e.top,
1292
+ maxY: r.bottom - e.bottom
1293
+ };
1294
+ }
1295
+ function pt(n) {
1296
+ return Array.isArray(n) ? [...n] : n;
1297
+ }
1298
+ function Be(n, t, e, r = {}) {
1299
+ const [i] = t.resolveTargets(e), o = i ? t.elementFor(i) : void 0;
1300
+ if (!i || !o)
1301
+ throw new Error(`gsap-compat: live.draggable could not find ${String(e)}`);
1302
+ if (r.type === "rotation") return Ue(n, t, i, o, r);
1303
+ const s = qe[r.type ?? "x,y"], c = () => {
1304
+ const d = t.appliedValue(i, "x"), y = t.appliedValue(i, "y");
1305
+ return { x: typeof d == "number" ? d : 0, y: typeof y == "number" ? y : 0 };
1306
+ }, a = typeof r.bounds == "string" ? t.query(r.bounds) : J(r.bounds) ? r.bounds : null, h = { bounds: (!a && r.bounds && !J(r.bounds) ? r.bounds : void 0) ?? (a ? mt(o, a) : void 0) };
1307
+ let f = null;
1308
+ const u = () => {
1309
+ f?.kill(), f = null;
1310
+ }, m = (d) => {
1311
+ const y = r.inertia === !0 ? {} : r.inertia, g = y.friction ?? (y.resistance !== void 0 ? ot(y.resistance) : 4), b = c(), w = h.bounds ?? {};
1312
+ let k, x;
1313
+ const v = y.end;
1314
+ if (Array.isArray(v)) {
1315
+ const C = H({ from: b.x, velocity: s === "y" ? 0 : d.x, friction: g }), L = H({ from: b.y, velocity: s === "x" ? 0 : d.y, friction: g });
1316
+ let M = v[0];
1317
+ for (const T of v)
1318
+ Math.hypot(T.x - C, T.y - L) < Math.hypot(M.x - C, M.y - L) && (M = T);
1319
+ M && (k = [M.x], x = [M.y]);
1320
+ } else typeof v == "number" ? (k = v, x = v) : v && (k = pt(v.x), x = pt(v.y));
1321
+ const S = {};
1322
+ s !== "y" && (S.x = { velocity: d.x, friction: g, min: w.minX, max: w.maxX, end: k }), s !== "x" && (S.y = { velocity: d.y, friction: g, min: w.minY, max: w.maxY, end: x }), f = n.to(o, { inertia: S, onComplete: () => r.onThrowComplete?.() });
1323
+ }, p = new te({
1324
+ target: o,
1325
+ axis: s,
1326
+ snap: r.snap,
1327
+ get bounds() {
1328
+ return h.bounds;
1329
+ },
1330
+ getPosition: c,
1331
+ onPress: () => {
1332
+ u(), a && (h.bounds = mt(o, a)), r.onPress?.();
1333
+ },
1334
+ onDrag: (d) => {
1335
+ t.apply(i, s === "x" ? { x: d.x } : s === "y" ? { y: d.y } : { x: d.x, y: d.y }), r.onDrag?.(d);
1336
+ },
1337
+ onRelease: () => {
1338
+ const d = p.velocity;
1339
+ r.onRelease?.(d), r.inertia && m(d);
1340
+ }
1341
+ });
1342
+ return p.start(), {
1343
+ draggable: p,
1344
+ get position() {
1345
+ return c();
1346
+ },
1347
+ get rotation() {
1348
+ const d = t.appliedValue(i, "rotate");
1349
+ return typeof d == "number" ? d : 0;
1350
+ },
1351
+ destroy() {
1352
+ u(), p.destroy();
1353
+ }
1354
+ };
1355
+ }
1356
+ function Ue(n, t, e, r, i) {
1357
+ const o = typeof i.bounds == "object" && i.bounds !== null && !J(i.bounds) ? i.bounds : {}, s = () => {
1358
+ const w = t.appliedValue(e, "rotate");
1359
+ return typeof w == "number" ? w : 0;
1360
+ }, c = (w) => Math.min(o.maxRotation ?? 1 / 0, Math.max(o.minRotation ?? -1 / 0, w));
1361
+ let a = null, l = !1, h, f = { x: 0, y: 0 }, u = 0, m = 0, p = [];
1362
+ const d = (w) => Math.atan2(w.clientY - f.y, w.clientX - f.x) * 180 / Math.PI, y = (w) => {
1363
+ if (l) return;
1364
+ a?.kill(), a = null, l = !0, h = w.pointerId, r.setPointerCapture?.(w.pointerId);
1365
+ const k = r.getBoundingClientRect();
1366
+ f = { x: k.left + k.width / 2, y: k.top + k.height / 2 }, u = d(w), m = s(), p = [{ time: performance.now(), rotation: m }], i.onPress?.();
1367
+ }, g = (w) => {
1368
+ if (!l || w.pointerId !== h) return;
1369
+ const k = d(w);
1370
+ let x = k - u;
1371
+ x > 180 && (x -= 360), x < -180 && (x += 360), u = k, m += x;
1372
+ let v = c(m);
1373
+ i.snap && (v = c(Math.round(v / i.snap) * i.snap)), t.apply(e, { rotate: v });
1374
+ const S = performance.now();
1375
+ for (p.push({ time: S, rotation: v }); p.length > 2 && S - p[0].time > 100; ) p.shift();
1376
+ const C = { x: 0, y: 0 };
1377
+ i.onDrag?.(C);
1378
+ }, b = (w) => {
1379
+ if (!l || w.pointerId !== h) return;
1380
+ l = !1;
1381
+ const k = p[0], x = p[p.length - 1], v = k && x ? (x.time - k.time) / 1e3 : 0, S = v > 0 ? (x.rotation - k.rotation) / v : 0;
1382
+ if (i.onRelease?.({ x: S, y: 0 }), !i.inertia) return;
1383
+ const C = i.inertia === !0 ? {} : i.inertia, L = C.friction ?? (C.resistance !== void 0 ? ot(C.resistance) : 4), M = typeof C.end == "number" || Array.isArray(C.end) ? C.end : void 0;
1384
+ a = n.to(r, {
1385
+ inertia: {
1386
+ rotate: {
1387
+ velocity: S,
1388
+ friction: L,
1389
+ min: o.minRotation,
1390
+ max: o.maxRotation,
1391
+ end: Array.isArray(M) ? M.filter((T) => typeof T == "number") : M
1392
+ }
1393
+ },
1394
+ onComplete: () => i.onThrowComplete?.()
1395
+ });
1396
+ };
1397
+ return r.addEventListener("pointerdown", y), r.addEventListener("pointermove", g), r.addEventListener("pointerup", b), r.addEventListener("pointercancel", b), r.style.touchAction = "none", {
1398
+ draggable: void 0,
1399
+ position: { x: 0, y: 0 },
1400
+ get rotation() {
1401
+ return s();
1402
+ },
1403
+ destroy() {
1404
+ a?.kill(), r.removeEventListener("pointerdown", y), r.removeEventListener("pointermove", g), r.removeEventListener("pointerup", b), r.removeEventListener("pointercancel", b);
1405
+ }
1406
+ };
1407
+ }
1408
+ const We = { opacity: 0, scale: 0.6 };
1409
+ function ze(n) {
1410
+ const t = n.getBoundingClientRect();
1411
+ return t.width === 0 && t.height === 0 ? null : { cx: t.left + t.width / 2, cy: t.top + t.height / 2, width: t.width, height: t.height };
1412
+ }
1413
+ function yt(n) {
1414
+ const t = W(n);
1415
+ return t.width === 0 && t.height === 0 ? null : { cx: t.left + t.width / 2, cy: t.top + t.height / 2, width: t.width, height: t.height };
1416
+ }
1417
+ function Q(n, t) {
1418
+ const r = n.resolveTargets(t).map((s) => n.elementFor(s)).filter((s) => !!s), i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1419
+ for (const s of r) {
1420
+ const c = ze(s);
1421
+ i.set(s, c);
1422
+ const a = $t(s);
1423
+ c && a !== void 0 && !o.has(a) && o.set(a, { element: s, box: c });
1424
+ }
1425
+ return { elements: r, boxes: i, ids: o };
1426
+ }
1427
+ const Y = /* @__PURE__ */ new WeakMap();
1428
+ function tt(n, t, e, r = {}) {
1429
+ const i = r.duration ?? 0.6, o = r.ease ?? "power2.inOut", s = r.stagger ?? 0, c = r.scale !== !1, a = r.enter === void 0 ? We : r.enter, l = new Set(e.elements);
1430
+ if (r.targets !== void 0)
1431
+ for (const m of n.resolveTargets(r.targets)) {
1432
+ const p = n.elementFor(m);
1433
+ p && l.add(p);
1434
+ }
1435
+ const h = [...l].sort(
1436
+ (m, p) => m === p ? 0 : m.compareDocumentPosition(p) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1
1437
+ ), f = t({ onComplete: r.onComplete });
1438
+ let u = 0;
1439
+ for (const m of h) {
1440
+ const p = yt(m);
1441
+ if (!p) continue;
1442
+ let d = e.boxes.get(m) ?? null, y;
1443
+ const g = $t(m), b = !d && g !== void 0 ? e.ids.get(g) : void 0;
1444
+ b && b.element !== m && (d = b.box, y = b.element);
1445
+ const [w] = n.resolveTargets(m);
1446
+ Y.get(m)?.timeline.removeTracks({ target: w });
1447
+ const k = u * s;
1448
+ if (!d) {
1449
+ if (a === !1) continue;
1450
+ f.fromTo(m, { x: 0, y: 0, scaleX: 1, scaleY: 1, ...a }, { ...It(a), x: 0, y: 0, scaleX: 1, scaleY: 1, duration: i, ease: o, delay: k }, 0), Y.set(m, f), u++;
1451
+ continue;
1452
+ }
1453
+ const x = d.cx - p.cx, v = d.cy - p.cy, S = c ? d.width / p.width : 1, C = c ? d.height / p.height : 1;
1454
+ if (!(Math.abs(x) > 0.5 || Math.abs(v) > 0.5 || Math.abs(S - 1) > 1e-3 || Math.abs(C - 1) > 1e-3)) {
1455
+ const T = (R, E) => {
1456
+ const A = n.appliedValue(w, R);
1457
+ return typeof A == "number" && Math.abs(A - E) > 1e-6;
1458
+ };
1459
+ (T("x", 0) || T("y", 0) || T("scaleX", 1) || T("scaleY", 1)) && f.set(m, { x: 0, y: 0, scaleX: 1, scaleY: 1 }, 0);
1460
+ continue;
1461
+ }
1462
+ const M = r.fade === !0 && y !== void 0;
1463
+ f.fromTo(
1464
+ m,
1465
+ { x, y: v, scaleX: S, scaleY: C, ...M && { opacity: 0 } },
1466
+ { x: 0, y: 0, scaleX: 1, scaleY: 1, ...M && { opacity: 1 }, duration: i, ease: o, delay: k },
1467
+ 0
1468
+ ), M && y && yt(y) && f.fromTo(y, { opacity: 1 }, { opacity: 0, duration: i, ease: o, delay: k }, 0), Y.set(m, f), u++;
1469
+ }
1470
+ return f;
1471
+ }
1472
+ function $t(n) {
1473
+ return n.dataset?.flipId;
1474
+ }
1475
+ function It(n) {
1476
+ const t = {};
1477
+ for (const e of Object.keys(n))
1478
+ t[e] = e === "opacity" || e.startsWith("scale") ? 1 : 0;
1479
+ return t;
1480
+ }
1481
+ const gt = (n) => typeof n == "object" && n !== null && n.nodeType === 1;
1482
+ function _e(n) {
1483
+ const t = {};
1484
+ for (const e of Array.from(n.attributes)) t[e.name] = e.value;
1485
+ return t;
1486
+ }
1487
+ function Ge(n) {
1488
+ const t = n.getScreenCTM?.();
1489
+ if (t) return [t.a, t.b, t.c, t.d, t.e, t.f];
1490
+ const e = n.getBoundingClientRect();
1491
+ return [1, 0, 0, 1, e.left, e.top];
1492
+ }
1493
+ function Ye(n, t) {
1494
+ const e = typeof n == "string" || Array.isArray(n) || gt(n) ? { path: n } : n, { align: r, alignOrigin: i, path: o, ...s } = e, c = (v) => {
1495
+ const S = gt(v) ? v : t.query(v);
1496
+ return S || t.warn(`gsap-compat: motionPath could not find "${String(v)}"`), S;
1497
+ };
1498
+ let a = null, l = "";
1499
+ if (Array.isArray(o) || typeof o == "string" && z(o))
1500
+ l = o;
1501
+ else {
1502
+ a = c(o);
1503
+ const v = a && et({ tag: a.localName, attributes: _e(a) });
1504
+ a && !v && t.warn(`gsap-compat: motionPath element <${a.localName}> has no path geometry`), l = v ?? "";
1505
+ }
1506
+ const h = { ...s, path: l };
1507
+ if (r === void 0 || r === !1) return h;
1508
+ const f = r === !0 ? a : c(r);
1509
+ if (!f)
1510
+ return r === !0 && t.warn("gsap-compat: motionPath align: true needs the path to be an element"), h;
1511
+ const u = t.targets[0];
1512
+ if (!u) return h;
1513
+ const [m, p, d, y, g, b] = Ge(f), w = W(u), [k, x] = i ?? [0.5, 0.5];
1514
+ for (const v of t.targets.slice(1)) {
1515
+ const S = W(v);
1516
+ if (Math.abs(S.left - w.left) > 0.5 || Math.abs(S.top - w.top) > 0.5) {
1517
+ t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");
1518
+ break;
1519
+ }
1520
+ }
1521
+ return h.matrix = [m, p, d, y, g - w.left - k * w.width, b - w.top - x * w.height], h;
1522
+ }
1523
+ const Xe = /* @__PURE__ */ new Set([
1524
+ "keyframes",
1525
+ "duration",
1526
+ "delay",
1527
+ "ease",
1528
+ "easeEach",
1529
+ "stagger",
1530
+ "repeat",
1531
+ "repeatDelay",
1532
+ "yoyo",
1533
+ "repeatRefresh",
1534
+ "paused",
1535
+ "id",
1536
+ "onStart",
1537
+ "onUpdate",
1538
+ "onComplete",
1539
+ "onRepeat",
1540
+ "onReverseComplete",
1541
+ "scrollTrigger"
1542
+ ]), wt = 0.5, He = "power1.inOut";
1543
+ function Ke(n) {
1544
+ return n.keyframes !== void 0 && n.keyframes !== null;
1545
+ }
1546
+ function Ze(n) {
1547
+ const t = n.keyframes, e = {};
1548
+ for (const [l, h] of Object.entries(n)) Xe.has(l) || (e[l] = h);
1549
+ if (Array.isArray(t))
1550
+ return t.map((l) => ({
1551
+ ...e,
1552
+ ...l,
1553
+ duration: l.duration ?? n.duration ?? wt
1554
+ }));
1555
+ const r = Object.entries(t), i = n.duration ?? wt, o = t.easeEach ?? n.easeEach ?? He;
1556
+ if (r.length > 0 && r.every(([l]) => /^\s*-?\d+(\.\d+)?\s*%\s*$/.test(l) || l === "easeEach")) {
1557
+ const l = r.filter(([u]) => u !== "easeEach").map(([u, m]) => ({ at: Number.parseFloat(u) / 100, step: m })).sort((u, m) => u.at - m.at), h = [];
1558
+ let f = 0;
1559
+ for (const { at: u, step: m } of l) {
1560
+ const p = Math.max(0, u - f);
1561
+ h.push({ ...e, ease: o, ...m, duration: p * i }), f = u;
1562
+ }
1563
+ return h;
1564
+ }
1565
+ const s = r.filter(([l, h]) => l !== "easeEach" && Array.isArray(h)), c = Math.max(0, ...s.map(([, l]) => l.length)), a = [];
1566
+ for (let l = 0; l < c; l++) {
1567
+ const h = { ...e, ease: o, duration: i / c };
1568
+ for (const [f, u] of s)
1569
+ l < u.length && (h[f] = u[l]);
1570
+ a.push(h);
1571
+ }
1572
+ return a;
1573
+ }
1574
+ function bt(n, t, e, r = {}) {
1575
+ const i = t.collector?.scope ?? t.root, o = typeof r.scroller == "string" ? i.querySelector(r.scroller) : r.scroller ?? null, s = {
1576
+ x: o ? o.scrollLeft : window.scrollX,
1577
+ y: o ? o.scrollTop : window.scrollY
1578
+ }, c = {
1579
+ x: o ? o.scrollWidth - o.clientWidth : document.documentElement.scrollWidth - window.innerWidth,
1580
+ y: o ? o.scrollHeight - o.clientHeight : document.documentElement.scrollHeight - window.innerHeight
1581
+ }, a = (b, w) => {
1582
+ if (w === void 0) return s[b];
1583
+ if (typeof w == "number") return w;
1584
+ if (w === "max") return c[b];
1585
+ const k = typeof w == "string" ? i.querySelector(w) : w;
1586
+ if (!k) return s[b];
1587
+ const x = k.getBoundingClientRect(), v = o?.getBoundingClientRect(), S = (b === "x" ? r.offsetX : r.offsetY) ?? r.offset ?? 0;
1588
+ return b === "x" ? x.left - (v?.left ?? 0) + s.x - S : x.top - (v?.top ?? 0) + s.y - S;
1589
+ }, l = typeof e == "object" && e !== null && !("nodeType" in e) ? { x: a("x", e.x), y: a("y", e.y) } : { x: s.x, y: a("y", e) }, h = { x: Math.max(0, Math.min(c.x, l.x)), y: Math.max(0, Math.min(c.y, l.y)) }, f = { ...s }, u = () => {
1590
+ o ? (o.scrollLeft = f.x, o.scrollTop = f.y) : window.scrollTo({ left: f.x, top: f.y, behavior: "instant" });
1591
+ }, m = ["wheel", "touchstart", "keydown"], p = o ?? window, d = () => {
1592
+ g.kill(), y();
1593
+ }, y = () => {
1594
+ for (const b of m) p.removeEventListener(b, d);
1595
+ }, g = n.to(f, {
1596
+ x: h.x,
1597
+ y: h.y,
1598
+ duration: r.duration ?? 1,
1599
+ ease: r.ease ?? "power2.inOut",
1600
+ onStart: r.onStart,
1601
+ onUpdate: () => {
1602
+ u(), r.onUpdate?.();
1603
+ },
1604
+ onComplete: () => {
1605
+ y(), r.onComplete?.();
1606
+ }
1607
+ });
1608
+ if (r.autoKill !== !1) for (const b of m) p.addEventListener(b, d, { passive: !0 });
1609
+ return g;
1610
+ }
1611
+ function Je(n, t, e) {
1612
+ const r = n.collector?.scope ?? n.root, i = typeof t == "string" ? [...r.querySelectorAll(t)] : "nodeType" in t ? [t] : Array.from(t), { interval: o = 0.1, batchMax: s, onEnter: c, onLeave: a, onEnterBack: l, onLeaveBack: h, ...f } = e, u = { onEnter: c, onLeave: a, onEnterBack: l, onLeaveBack: h }, m = { onEnter: [], onLeave: [], onEnterBack: [], onLeaveBack: [] }, p = {}, d = (g) => {
1613
+ p[g] !== void 0 && clearTimeout(p[g]), p[g] = void 0;
1614
+ const b = m[g].splice(0);
1615
+ b.length > 0 && u[g]?.(b);
1616
+ }, y = (g, b) => {
1617
+ if (u[g]) {
1618
+ if (m[g].push(b), s !== void 0 && m[g].length >= s) return d(g);
1619
+ p[g] === void 0 && (p[g] = setTimeout(() => d(g), o * 1e3));
1620
+ }
1621
+ };
1622
+ return i.map(
1623
+ (g) => it(n, {
1624
+ ...f,
1625
+ trigger: g,
1626
+ onEnter: () => y("onEnter", g),
1627
+ onLeave: () => y("onLeave", g),
1628
+ onEnterBack: () => y("onEnterBack", g),
1629
+ onLeaveBack: () => y("onLeaveBack", g)
1630
+ })
1631
+ ).filter((g) => g !== void 0);
1632
+ }
1633
+ const Qe = {
1634
+ request: (n) => requestAnimationFrame(n),
1635
+ cancel: (n) => cancelAnimationFrame(n)
1636
+ };
1637
+ class tr {
1638
+ adapter = new St();
1639
+ scheduler;
1640
+ rootOption;
1641
+ /** Element → engine target name. The engine only ever sees names. */
1642
+ names = /* @__PURE__ */ new WeakMap();
1643
+ elements = /* @__PURE__ */ new Map();
1644
+ nameCounter = 0;
1645
+ /** Plain-object targets, named like elements but written directly. */
1646
+ objectNames = /* @__PURE__ */ new WeakMap();
1647
+ objects = /* @__PURE__ */ new Map();
1648
+ /** Things created for this stage that outlive a timeline (scroll triggers, pins). */
1649
+ owned = /* @__PURE__ */ new Set();
1650
+ currentCollector;
1651
+ tickerCallbacks = /* @__PURE__ */ new Set();
1652
+ tickerTime = 0;
1653
+ tickerFrame = 0;
1654
+ /**
1655
+ * Live timelines that may still move something — playing, paused or scroll
1656
+ * driven — for `live.killTweensOf`. Finished one-off timelines leave it.
1657
+ */
1658
+ liveTimelines = /* @__PURE__ */ new Set();
1659
+ /** GSAP-style utilities, with this stage's seeded random sequence (`live.utils`). */
1660
+ utils = re();
1661
+ /** Playing timelines, in activation order. */
1662
+ active = /* @__PURE__ */ new Map();
1663
+ /** Last applied value per target name and property. */
1664
+ applied = /* @__PURE__ */ new Map();
1665
+ /** Targets written since the last apply. */
1666
+ dirty = /* @__PURE__ */ new Set();
1667
+ frameId = null;
1668
+ lastTimestamp = null;
1669
+ destroyed = !1;
1670
+ constructor(t = {}) {
1671
+ this.scheduler = t.scheduler ?? Qe, this.rootOption = t.root;
1672
+ }
1673
+ // --- targets ------------------------------------------------------------
1674
+ /**
1675
+ * Where selector targets are resolved: the given root, or the document.
1676
+ * Read lazily so a stage can be created where there is no document (Node, a
1677
+ * Worker) as long as nothing is resolved there.
1678
+ */
1679
+ get root() {
1680
+ return this.rootOption ?? document;
1681
+ }
1682
+ /**
1683
+ * Resolve selectors, elements, plain objects and lists of them to engine
1684
+ * target names, registering each element with the adapter (and each object
1685
+ * with the stage) the first time it is seen.
1686
+ * Returns an empty array when nothing matches.
1687
+ */
1688
+ resolveTargets(t) {
1689
+ const e = [];
1690
+ for (const r of this.targetsOf(t)) {
1691
+ const i = this.nameFor(r);
1692
+ X(r) && this.currentCollector?.touch(r, i), e.push(i);
1693
+ }
1694
+ return e;
1695
+ }
1696
+ /** Find one element the way selector targets are found: within the stage's root (or the collecting context's scope). */
1697
+ query(t) {
1698
+ return this.selectorRoot.querySelector(t);
1699
+ }
1700
+ // --- contexts -----------------------------------------------------------
1701
+ /** The context collecting what is created right now, if any (see live-context.ts). */
1702
+ get collector() {
1703
+ return this.currentCollector;
1704
+ }
1705
+ setCollector(t) {
1706
+ this.currentCollector = t;
1707
+ }
1708
+ /** Drop the values applied to a target, so the next animation starts from its natural state. */
1709
+ forget(t) {
1710
+ this.applied.delete(t), this.dirty.delete(t);
1711
+ }
1712
+ get selectorRoot() {
1713
+ return this.currentCollector?.scope ?? this.root;
1714
+ }
1715
+ /** The element registered under a target name. */
1716
+ elementFor(t) {
1717
+ return this.elements.get(t);
1718
+ }
1719
+ /** The plain object registered under a target name. */
1720
+ objectFor(t) {
1721
+ return this.objects.get(t);
1722
+ }
1723
+ /** Last value the stage applied to a target's property, if any. */
1724
+ appliedValue(t, e) {
1725
+ return this.applied.get(t)?.get(e);
1726
+ }
1727
+ /**
1728
+ * How fast a property is changing right now, in units per second, taken from
1729
+ * the most recently played timeline that animates it — so a spring started
1730
+ * mid-motion carries the momentum. A finite difference over a few milliseconds
1731
+ * of that timeline's own (deterministic) state; undefined when nothing playing
1732
+ * animates the property.
1733
+ */
1734
+ velocityOf(t, e) {
1735
+ for (const i of [...this.active.keys()].reverse()) {
1736
+ if (i.getTracks({ target: t, property: e }).length === 0) continue;
1737
+ const o = i.currentTime;
1738
+ if (o < 4) return 0;
1739
+ const s = i.getStateAtTime(o).values.get(t)?.get(e), c = i.getStateAtTime(o - 4).values.get(t)?.get(e);
1740
+ if (typeof s != "number" || typeof c != "number") return;
1741
+ const a = (s - c) / 4;
1742
+ return (i.direction === "reverse" ? -a : a) * 1e3;
1743
+ }
1744
+ }
1745
+ /**
1746
+ * Run a callback every frame, after animations are applied. The frame loop
1747
+ * keeps going while any callback is registered, even with nothing playing.
1748
+ */
1749
+ ticker = {
1750
+ add: (t) => {
1751
+ this.destroyed || (this.tickerCallbacks.size === 0 && (this.tickerTime = 0, this.tickerFrame = 0), this.tickerCallbacks.add(t), this.currentCollector?.track({ revert: () => this.ticker.remove(t) }), this.startLoop());
1752
+ },
1753
+ remove: (t) => {
1754
+ this.tickerCallbacks.delete(t), this.running || this.stopLoop();
1755
+ }
1756
+ };
1757
+ // --- playback -----------------------------------------------------------
1758
+ /**
1759
+ * Add a timeline to the running set and make sure the loop is going. The
1760
+ * timeline must already be playing; activating an already active timeline
1761
+ * moves it to the end of the order, so it wins merges.
1762
+ */
1763
+ activate(t, e = {}) {
1764
+ this.destroyed || (t.onUpdate = (r) => this.write(r), this.active.delete(t), this.active.set(t, e), this.startLoop());
1765
+ }
1766
+ /** Remove a timeline from the running set. Its applied values remain. */
1767
+ deactivate(t) {
1768
+ this.active.delete(t), this.running || this.stopLoop();
1769
+ }
1770
+ /** Destroy `resource` along with the stage. Returns it. */
1771
+ own(t) {
1772
+ return this.destroyed ? t.destroy() : this.owned.add(t), t;
1773
+ }
1774
+ /**
1775
+ * Stop everything on this stage and release its elements. Animations that
1776
+ * are still running stop where they are; elements keep the styles last
1777
+ * applied. A destroyed stage ignores later playback, so a timeline whose
1778
+ * autoplay was already queued cannot restart the loop.
1779
+ */
1780
+ destroy() {
1781
+ this.destroyed = !0;
1782
+ for (const t of this.owned) t.destroy();
1783
+ this.owned.clear();
1784
+ for (const t of this.active.keys()) t.stop();
1785
+ this.active.clear(), this.stopLoop(), this.adapter.clearTargets(), this.elements.clear(), this.names = /* @__PURE__ */ new WeakMap(), this.objects.clear(), this.objectNames = /* @__PURE__ */ new WeakMap(), this.tickerCallbacks.clear(), this.liveTimelines.clear(), this.applied.clear(), this.dirty.clear();
1786
+ }
1787
+ /**
1788
+ * Write values for one target straight away, without a timeline — for direct
1789
+ * manipulation such as dragging, where every pointer move sets a position.
1790
+ * The values join the applied state, so later tweens start from them.
1791
+ */
1792
+ apply(t, e) {
1793
+ if (this.destroyed) return;
1794
+ const r = new Map(Object.entries(e));
1795
+ this.write({ values: /* @__PURE__ */ new Map([[t, r]]), currentTime: 0, playbackState: "idle", direction: "forward", loopIteration: 0 }), this.flush();
1796
+ }
1797
+ /** Apply a timeline's state at its current time, immediately. */
1798
+ render(t) {
1799
+ this.destroyed || (this.write(t.getStateAtTime(t.currentTime)), this.flush());
1800
+ }
1801
+ /**
1802
+ * Advance every active timeline by `deltaMs` and apply the merged result.
1803
+ * The frame loop calls this; it is public so hosts that own their own loop
1804
+ * (or tests) can drive the stage directly.
1805
+ */
1806
+ tick(t) {
1807
+ const e = [...this.active];
1808
+ for (const [r] of e)
1809
+ r.duration <= 0 ? (this.write(r.getStateAtTime(0)), r.stop()) : r.tick(t);
1810
+ this.flush();
1811
+ for (const [r, i] of e)
1812
+ i.onUpdate?.(), r.playbackState !== "playing" && this.active.get(r) === i && this.active.delete(r);
1813
+ this.flush(), this.runTicker(t), this.running || this.stopLoop();
1814
+ }
1815
+ // --- internals ----------------------------------------------------------
1816
+ /** Whether the frame loop has work: something playing, or a ticker callback. */
1817
+ get running() {
1818
+ return this.active.size > 0 || this.tickerCallbacks.size > 0;
1819
+ }
1820
+ runTicker(t) {
1821
+ if (this.tickerCallbacks.size !== 0) {
1822
+ this.tickerTime += t, this.tickerFrame += 1;
1823
+ for (const e of [...this.tickerCallbacks])
1824
+ e(this.tickerTime / 1e3, t, this.tickerFrame);
1825
+ }
1826
+ }
1827
+ write(t) {
1828
+ for (const [e, r] of t.values) {
1829
+ let i = this.applied.get(e);
1830
+ i || (i = /* @__PURE__ */ new Map(), this.applied.set(e, i));
1831
+ for (const [o, s] of r) i.set(o, s);
1832
+ this.dirty.add(e);
1833
+ }
1834
+ }
1835
+ flush() {
1836
+ if (this.dirty.size === 0) return;
1837
+ const t = /* @__PURE__ */ new Map();
1838
+ for (const e of this.dirty) {
1839
+ const r = this.applied.get(e), i = this.objects.get(e);
1840
+ if (i)
1841
+ for (const [o, s] of r) i[o] = s;
1842
+ else
1843
+ t.set(e, r);
1844
+ }
1845
+ this.dirty.clear(), t.size !== 0 && this.adapter.applyState({
1846
+ values: t,
1847
+ currentTime: 0,
1848
+ playbackState: "playing",
1849
+ direction: "forward",
1850
+ loopIteration: 0
1851
+ });
1852
+ }
1853
+ frame = (t) => {
1854
+ this.frameId = null;
1855
+ const e = this.lastTimestamp === null ? 0 : t - this.lastTimestamp;
1856
+ this.lastTimestamp = t, e > 0 && this.tick(e), this.running && this.frameId === null && (this.frameId = this.scheduler.request(this.frame));
1857
+ };
1858
+ startLoop() {
1859
+ this.frameId === null && (this.lastTimestamp = null, this.frameId = this.scheduler.request(this.frame));
1860
+ }
1861
+ stopLoop() {
1862
+ this.frameId !== null && this.scheduler.cancel(this.frameId), this.frameId = null, this.lastTimestamp = null;
1863
+ }
1864
+ targetsOf(t) {
1865
+ if (typeof t == "string")
1866
+ return Array.from(this.selectorRoot.querySelectorAll(t));
1867
+ if (X(t)) return [t];
1868
+ if (!er(t)) return [t];
1869
+ const e = [];
1870
+ for (const r of Array.from(t))
1871
+ e.push(...this.targetsOf(r));
1872
+ return e;
1873
+ }
1874
+ nameFor(t) {
1875
+ return X(t) ? this.elementName(t) : this.objectName(t);
1876
+ }
1877
+ objectName(t) {
1878
+ const e = this.objectNames.get(t);
1879
+ if (e) return e;
1880
+ let r;
1881
+ do
1882
+ this.nameCounter += 1, r = `obj-${this.nameCounter}`;
1883
+ while (this.objects.has(r) || this.elements.has(r));
1884
+ return this.objectNames.set(t, r), this.objects.set(r, t), r;
1885
+ }
1886
+ elementName(t) {
1887
+ const e = this.names.get(t);
1888
+ if (e) return e;
1889
+ let r = t.id ? `#${t.id}` : "";
1890
+ if (!r || this.elements.has(r))
1891
+ do
1892
+ this.nameCounter += 1, r = `el-${this.nameCounter}`;
1893
+ while (this.elements.has(r));
1894
+ return this.names.set(t, r), this.elements.set(r, t), this.adapter.registerTarget(r, t), r;
1895
+ }
1896
+ }
1897
+ function X(n) {
1898
+ return typeof n == "object" && n !== null && n.nodeType === 1;
1899
+ }
1900
+ function er(n) {
1901
+ if (Array.isArray(n)) return !0;
1902
+ const t = n;
1903
+ return typeof t.length == "number" && typeof t.item == "function";
1904
+ }
1905
+ const rr = { opacity: 0, y: -16 }, nr = { opacity: 0, y: 16 };
1906
+ async function or(n, t, e, r) {
1907
+ const i = t.collector?.scope ?? t.root, o = i.ownerDocument ?? i, s = () => r.shared ? [...i.querySelectorAll(r.shared)] : [];
1908
+ if (r.native && typeof o.startViewTransition == "function")
1909
+ return ir(o, r, s);
1910
+ const c = r.duration ?? 0.35, a = r.ease ?? "power2.inOut", l = (y) => new Promise((g) => {
1911
+ y(g) || g();
1912
+ }), h = s(), f = h.length ? Q(t, h) : void 0, u = r.from !== void 0 ? vt(t, r.from, r.shared) : [];
1913
+ if (u.length && r.leave !== !1) {
1914
+ const y = r.leave ?? rr;
1915
+ await l((g) => n.to(u, { ...y, duration: c, ease: a, onComplete: g }));
1916
+ }
1917
+ await r.update();
1918
+ const m = [], p = typeof r.to == "function" ? r.to() : r.to, d = p !== void 0 ? vt(t, p, r.shared) : [];
1919
+ if (d.length && r.enter !== !1) {
1920
+ const y = r.enter ?? nr;
1921
+ m.push(l((g) => n.fromTo(d, y, { ...It(y), duration: c, ease: a, onComplete: g })));
1922
+ }
1923
+ if (f) {
1924
+ const y = s().filter((g) => !h.includes(g));
1925
+ y.length && m.push(
1926
+ l(
1927
+ (g) => tt(t, e, f, {
1928
+ targets: y,
1929
+ duration: c * 1.4,
1930
+ ease: a,
1931
+ enter: !1,
1932
+ onComplete: g
1933
+ })
1934
+ )
1935
+ );
1936
+ }
1937
+ await Promise.all(m);
1938
+ }
1939
+ function vt(n, t, e) {
1940
+ const r = n.resolveTargets(t).map((i) => n.elementFor(i)).filter((i) => !!i);
1941
+ return e ? r.flatMap((i) => !i.querySelector(e) && !i.matches(e) ? [i] : [...i.children].filter((o) => !o.matches(e) && !o.querySelector(e))) : r;
1942
+ }
1943
+ async function ir(n, t, e) {
1944
+ const r = (c, a) => {
1945
+ const l = c.dataset?.flipId;
1946
+ l && c.style.setProperty("view-transition-name", a ? `tf-${l.replace(/[^\w-]/g, "-")}` : "");
1947
+ }, i = e();
1948
+ i.forEach((c) => r(c, !0));
1949
+ let o = [];
1950
+ await n.startViewTransition(async () => {
1951
+ i.forEach((c) => r(c, !1)), await t.update(), o = e(), o.forEach((c) => r(c, !0));
1952
+ }).finished, o.forEach((c) => r(c, !1));
1953
+ }
1954
+ class P {
1955
+ /** The compiled compat timeline. */
1956
+ compat;
1957
+ stage;
1958
+ options;
1959
+ /** Cleared once playback has been started or explicitly controlled. */
1960
+ autoplayPending;
1961
+ started = !1;
1962
+ killed = !1;
1963
+ /** The building calls, in order, so `invalidate()` can replay them. */
1964
+ recipe = [];
1965
+ /** The first element any tween targeted: a scroll trigger's default trigger. */
1966
+ firstElement;
1967
+ scrollDriver;
1968
+ /** Callbacks and pauses placed on the timeline (`call`, `addPause`, tween onStart / onComplete) */
1969
+ events = [];
1970
+ ranges = [];
1971
+ /** Where the playhead was when callbacks were last worked out */
1972
+ playhead = { time: 0, iteration: 0, direction: "forward", fresh: !0 };
1973
+ /** A plain repeat is waiting out its delay; the next loop starts fresh from 0 */
1974
+ waitingToWrap = !1;
1975
+ /** The engine finished during this frame; completion callbacks run after the frame's events */
1976
+ finishedThisFrame = !1;
1977
+ /** Set by `reverse()`: arriving at the start is a reverse completion */
1978
+ backwards = !1;
1979
+ constructor(t, e = {}) {
1980
+ if (this.stage = t, this.options = e, this.compat = new $({
1981
+ ...e,
1982
+ startValue: (r, i) => {
1983
+ const o = t.objectFor(r);
1984
+ if (o) return lr(o[i]);
1985
+ const s = t.appliedValue(r, i);
1986
+ if (s !== void 0) return s;
1987
+ if (i === "d") return Lt(t.elementFor(r)) ?? void 0;
1988
+ if (i === "text") return t.elementFor(r)?.textContent ?? void 0;
1989
+ if (i === "strokeDasharray" || i === "strokeDashoffset") {
1990
+ const c = xt(t.elementFor(r));
1991
+ if (c !== void 0) return i === "strokeDasharray" ? [c, c] : 0;
1992
+ }
1993
+ },
1994
+ startVelocity: (r, i) => t.velocityOf(r, i),
1995
+ layoutColumns: (r) => Tt(r.map((i) => t.elementFor(i))),
1996
+ random: () => t.utils.random(0, 1)
1997
+ }), this.compat.timeline.onComplete = () => {
1998
+ this.finishedThisFrame = !0;
1999
+ }, t.collector?.track(this), t.liveTimelines.add(this), this.autoplayPending = !e.paused && !e.scrollTrigger, e.scrollTrigger) {
2000
+ const r = e.scrollTrigger;
2001
+ queueMicrotask(() => {
2002
+ this.killed || (this.scrollDriver = it(t, r, this, this.firstElement, (i) => e.onWarning?.(i)));
2003
+ });
2004
+ }
2005
+ this.autoplayPending && queueMicrotask(() => {
2006
+ this.autoplayPending && this.play();
2007
+ });
2008
+ }
2009
+ /** The engine timeline. */
2010
+ get timeline() {
2011
+ return this.compat.timeline;
2012
+ }
2013
+ /** The scroll driver behind `scrollTrigger`, once attached (after a microtask). */
2014
+ get scrollTrigger() {
2015
+ return this.scrollDriver;
2016
+ }
2017
+ // --- building -----------------------------------------------------------
2018
+ to(t, e, r) {
2019
+ return Ke(e) ? this.record(() => this.keyframed(t, e, r)) : this.record(() => this.tween(t, [e], r, ([i], o, s) => this.compat.to(o, i, s)));
2020
+ }
2021
+ from(t, e, r) {
2022
+ return this.record(() => this.tween(t, [e], r, ([i], o, s) => this.compat.from(o, i, s)));
2023
+ }
2024
+ fromTo(t, e, r, i) {
2025
+ return this.record(
2026
+ () => this.tween(t, [e, r], i, ([o, s], c, a) => this.compat.fromTo(c, o, s, a))
2027
+ );
2028
+ }
2029
+ set(t, e, r) {
2030
+ return this.record(() => this.tween(t, [e], r, ([i], o, s) => this.compat.set(o, i, s)));
2031
+ }
2032
+ addLabel(t, e) {
2033
+ return this.record(() => this.compat.addLabel(t, e));
2034
+ }
2035
+ /** Merge another timeline in at a position (flattened, as in `tf`). */
2036
+ add(t, e) {
2037
+ return this.record(() => {
2038
+ t.autoplayPending = !1, t.timeline.stop(), t.stage.deactivate(t.timeline), this.compat.add(t.compat, e);
2039
+ });
2040
+ }
2041
+ /**
2042
+ * Build the timeline again from the same calls: rewind to the start (so start
2043
+ * values are read from what elements show before it ran), rebuild every tween —
2044
+ * re-running function values — and return to the same progress. Use after a
2045
+ * layout change; `scrollTrigger: { invalidateOnRefresh: true }` does it on refresh.
2046
+ */
2047
+ invalidate() {
2048
+ const t = this.compat.progress();
2049
+ this.compat.progress(0), this.stage.render(this.timeline), this.compat.reset(), this.events = [], this.ranges = [];
2050
+ for (const e of this.recipe) e();
2051
+ return this.syncDuration(), this.compat.progress(t), this.stage.render(this.timeline), this;
2052
+ }
2053
+ /**
2054
+ * Run `callback` when the playhead crosses `position` (default: the end so far),
2055
+ * in either direction (GSAP's `call`). It takes no time, but a call after the
2056
+ * last tween makes the timeline that long.
2057
+ */
2058
+ call(t, e = [], r) {
2059
+ return this.record(() => {
2060
+ const i = this.compat.addEvent(r);
2061
+ this.events.push({ time: i, run: () => t(...e) });
2062
+ });
2063
+ }
2064
+ /** Pause exactly at `position` when the playhead reaches it, then run `callback`. `play()` continues. */
2065
+ addPause(t, e, r = []) {
2066
+ return this.record(() => {
2067
+ const i = this.compat.addEvent(t);
2068
+ this.events.push({ time: i, pause: !0, run: () => e?.(...r) });
2069
+ });
2070
+ }
2071
+ /**
2072
+ * Pause, and animate the playhead from where it is to `position` (seconds or a
2073
+ * label), firing callbacks on the way. Returns the tween that moves it.
2074
+ */
2075
+ tweenTo(t, e = {}) {
2076
+ return this.tweenFromTo(this.timeline.currentTime / 1e3, t, e);
2077
+ }
2078
+ /** Jump to `from`, then animate the playhead to `to` (seconds or labels). */
2079
+ tweenFromTo(t, e, r = {}) {
2080
+ this.pause(), this.seek(t);
2081
+ const i = this.timeline.currentTime, o = Math.max(0, Math.min(this.timeline.duration, this.compat.timeOf(e))), s = { time: i }, c = r.duration ?? Math.abs(o - i) / 1e3 / (this.timeScale() || 1), a = new P(this.stage, { onStart: r.onStart, onComplete: r.onComplete });
2082
+ return a.to(s, {
2083
+ time: o,
2084
+ duration: c,
2085
+ ease: r.ease ?? "none",
2086
+ onUpdate: () => {
2087
+ this.moveTo(s.time), r.onUpdate?.();
2088
+ }
2089
+ }), a;
2090
+ }
2091
+ // --- playback -----------------------------------------------------------
2092
+ play() {
2093
+ this.autoplayPending = !1, this.started || (this.started = !0, this.options.onStart?.());
2094
+ const t = this.timeline.playbackState === "playing", e = this.timeline.playbackState === "paused";
2095
+ if (this.timeline.play(), !t) {
2096
+ const r = this.timeline, i = r.direction === "forward" ? r.currentTime === 0 : r.currentTime === r.duration;
2097
+ this.playhead = { ...this.readPlayhead(), fresh: i && !e }, this.waitingToWrap = !1;
2098
+ }
2099
+ return this.stage.liveTimelines.add(this), this.stage.render(this.timeline), this.stage.activate(this.timeline, { onUpdate: () => this.afterFrame() }), this;
2100
+ }
2101
+ pause() {
2102
+ return this.autoplayPending = !1, this.timeline.pause(), this.stage.deactivate(this.timeline), this;
2103
+ }
2104
+ /** Continue from the current position (GSAP's `resume`). */
2105
+ resume() {
2106
+ return this.play();
2107
+ }
2108
+ /** Play from the start. */
2109
+ restart() {
2110
+ return this.timeline.stop(), this.backwards = !1, this.play();
2111
+ }
2112
+ /** Flip direction and keep playing (from the end, if already finished). */
2113
+ reverse() {
2114
+ this.backwards = !this.backwards;
2115
+ const t = this.timeline.playbackState === "idle" && this.timeline.direction === "forward";
2116
+ return this.timeline.reverse(), t && this.timeline.currentTime === 0 && this.timeline.seek(this.timeline.duration), this.play();
2117
+ }
2118
+ /** Label times as progress (0..1), in order. */
2119
+ labelProgresses() {
2120
+ const t = this.timeline.duration;
2121
+ return t > 0 ? this.compat.labelTimes().map((e) => e / t) : [];
2122
+ }
2123
+ /** Whether the timeline is set to play backwards. */
2124
+ reversed() {
2125
+ return this.timeline.direction === "reverse";
2126
+ }
2127
+ /** Jump to a time in seconds, or to a label, and apply it immediately. */
2128
+ seek(t) {
2129
+ return this.autoplayPending = !1, this.compat.seek(t), this.stage.render(this.timeline), this.playhead = this.readPlayhead(), this.waitingToWrap = !1, this.options.onUpdate?.(), this;
2130
+ }
2131
+ /**
2132
+ * Read or set progress, 0..1. Setting applies immediately and fires the
2133
+ * callbacks crossed on the way, so a scroll scrub runs them.
2134
+ */
2135
+ progress(t) {
2136
+ return t === void 0 ? this.compat.progress() : (this.autoplayPending = !1, this.moveTo(Math.max(0, Math.min(1, t)) * this.timeline.duration), this.compat.progress());
2137
+ }
2138
+ timeScale(t) {
2139
+ return this.compat.timeScale(t);
2140
+ }
2141
+ /** Total duration in seconds. */
2142
+ duration() {
2143
+ return this.compat.duration();
2144
+ }
2145
+ isActive() {
2146
+ return this.timeline.playbackState === "playing";
2147
+ }
2148
+ /** Stop and remove every tween, and any scroll trigger (and its pin). Elements keep the values last applied. */
2149
+ kill() {
2150
+ return this.killed = !0, this.stage.liveTimelines.delete(this), this.scrollDriver?.destroy(), this.scrollDriver = void 0, this.autoplayPending = !1, this.timeline.stop(), this.stage.deactivate(this.timeline), this.compat.kill(), this;
2151
+ }
2152
+ /** The compiled animation, as plain JSON. */
2153
+ toDefinition() {
2154
+ return this.compat.toDefinition();
2155
+ }
2156
+ /**
2157
+ * Remove the tweens on these targets (and only these properties, if given)
2158
+ * from this timeline — `live.killTweensOf` asks every live timeline. A tween on
2159
+ * several elements shares one track, so it stops for all of them.
2160
+ */
2161
+ killTweensOf(t, e) {
2162
+ for (const r of t)
2163
+ for (const i of e ?? [void 0])
2164
+ this.timeline.removeTracks({ target: r, ...i !== void 0 && { property: i } });
2165
+ this.timeline.tracks.length === 0 && this.events.length === 0 && this.kill();
2166
+ }
2167
+ /** Run a building step now, and keep it so `invalidate()` can run it again. */
2168
+ record(t) {
2169
+ return this.recipe.push(t), t(), this.syncDuration(), this;
2170
+ }
2171
+ /** A call or pause after the last tween extends the timeline to reach it. */
2172
+ syncDuration() {
2173
+ if (this.events.length === 0) return;
2174
+ this.timeline.setDuration(void 0);
2175
+ const t = Math.max(...this.events.map((e) => e.time));
2176
+ t > this.timeline.duration && this.timeline.setDuration(t);
2177
+ }
2178
+ readPlayhead() {
2179
+ const t = this.timeline;
2180
+ return { time: t.currentTime, iteration: t.loopIteration, direction: t.direction };
2181
+ }
2182
+ /** Set the playhead to a time (ms) within the current loop, firing what it crosses. */
2183
+ moveTo(t) {
2184
+ const e = this.playhead;
2185
+ this.timeline.seek(t), this.stage.render(this.timeline);
2186
+ const r = { time: this.timeline.currentTime, iteration: this.timeline.loopIteration, direction: t >= e.time ? "forward" : "reverse" }, i = { ...e, iteration: r.iteration, direction: r.direction };
2187
+ this.playhead = { ...this.readPlayhead() }, this.waitingToWrap = !1, this.runCrossings(i, r, !1), this.options.onUpdate?.();
2188
+ }
2189
+ /**
2190
+ * Rebuild for a new loop, keeping the playhead where the engine put it. Unlike
2191
+ * `invalidate()`, start values are not re-read from a rewound render: the
2192
+ * rebuilt tweens start where the recorded calls say, with fresh function values.
2193
+ */
2194
+ refreshForRepeat() {
2195
+ const t = this.timeline.currentTime;
2196
+ this.compat.reset(), this.events = [], this.ranges = [];
2197
+ for (const e of this.recipe) e();
2198
+ this.syncDuration(), this.timeline.seek(Math.min(t, this.timeline.duration));
2199
+ }
2200
+ /** After each frame this timeline played: callbacks crossed, repeats, completion. */
2201
+ afterFrame() {
2202
+ const t = this.timeline, e = t.repeatDelayRemaining > 0;
2203
+ if (this.waitingToWrap && e) {
2204
+ this.options.onUpdate?.();
2205
+ return;
2206
+ }
2207
+ this.waitingToWrap = !1;
2208
+ const r = this.playhead, i = this.readPlayhead();
2209
+ this.playhead = i;
2210
+ const o = this.options.yoyo === !0;
2211
+ e && !o && i.iteration > r.iteration && (this.playhead = { time: 0, iteration: i.iteration, direction: "forward", fresh: !0 }, this.waitingToWrap = !0);
2212
+ const s = this.runCrossings(r, i, e);
2213
+ if (this.options.onUpdate?.(), this.finishedThisFrame && !s) {
2214
+ this.finishedThisFrame = !1;
2215
+ const c = t.currentTime === 0 && t.direction === "reverse";
2216
+ !this.scrollDriver && !o && this.stage.liveTimelines.delete(this), c && this.backwards ? this.options.onReverseComplete?.() : this.options.onComplete?.();
2217
+ }
2218
+ this.finishedThisFrame = !1;
2219
+ }
2220
+ /** Fire events and repeats between two playheads. Returns true if a pause stopped it. */
2221
+ runCrossings(t, e, r) {
2222
+ if (this.events.length === 0 && this.ranges.length === 0 && !this.options.onRepeat && !this.options.repeatRefresh) return !1;
2223
+ const i = this.events, { crossings: o, passes: s } = Qt(
2224
+ i.map((c) => c.time),
2225
+ t,
2226
+ e,
2227
+ { duration: this.timeline.duration, alternate: this.options.yoyo === !0, holding: r }
2228
+ );
2229
+ for (const c of o) {
2230
+ if (this.killed) return !0;
2231
+ if (c.kind === "repeat") {
2232
+ this.options.repeatRefresh && this.refreshForRepeat(), this.options.onRepeat?.();
2233
+ continue;
2234
+ }
2235
+ const a = i[c.index];
2236
+ if (!(a.direction && a.direction !== c.direction)) {
2237
+ if (a.pause)
2238
+ return this.timeline.seek(a.time), this.stage.render(this.timeline), this.pause(), this.playhead = this.readPlayhead(), this.waitingToWrap = !1, a.run(), !0;
2239
+ a.run();
2240
+ }
2241
+ }
2242
+ for (const c of this.ranges)
2243
+ s.some(([l, h]) => l !== h && Math.max(l, h) >= c.start && Math.min(l, h) <= c.end) && c.run();
2244
+ return !1;
2245
+ }
2246
+ /**
2247
+ * Compile one tween call. A track has one start value and one set of values,
2248
+ * but some tweens differ per element — each element's own shape, text or stroke
2249
+ * length, each plain object's own current values, or function values called per
2250
+ * element — so those build one tween per element at the same position, with any
2251
+ * stagger turned into delays. `varsList` is `[vars]`, or `[fromVars, toVars]`.
2252
+ */
2253
+ tween(t, e, r, i) {
2254
+ const o = this.resolve(t);
2255
+ if (!o) return;
2256
+ const { onStart: s, onUpdate: c, onComplete: a } = e[e.length - 1];
2257
+ if (s || c || a) {
2258
+ let l = 1 / 0, h = -1 / 0;
2259
+ const f = (u, m, p) => {
2260
+ i(u, m, p), l = Math.min(l, this.compat.lastStart), h = Math.max(h, this.compat.lastEnd);
2261
+ };
2262
+ if (this.buildTween(o, e, r, f), l === 1 / 0) return;
2263
+ s && this.events.push({ time: l, direction: "forward", run: s }), c && this.ranges.push({ start: l, end: h, run: c }), a && this.events.push({ time: h, direction: "forward", run: a });
2264
+ return;
2265
+ }
2266
+ this.buildTween(o, e, r, i);
2267
+ }
2268
+ /**
2269
+ * A tween with `keyframes`: its segments one after another, from the tween's
2270
+ * position and delay. With `stagger`, each target plays the whole sequence,
2271
+ * offset like any stagger. Callbacks belong to the sequence as a whole.
2272
+ */
2273
+ keyframed(t, e, r) {
2274
+ const i = this.resolve(t);
2275
+ if (!i) return;
2276
+ const o = Ze(e);
2277
+ if (o.length === 0) return;
2278
+ const s = i.length > 1 ? Z(e.stagger, this.staggerContext(i)) : void 0, c = i.map((y) => this.targetFor(y)).filter((y) => y !== void 0), a = s ? c.map((y) => [y]) : [c], l = s ? lt(i.length, s).map((y) => y / 1e3) : [0], h = this.compat.timeOf(r) / 1e3 + U(e.delay, 0) / 1e3;
2279
+ let f = 1 / 0, u = -1 / 0;
2280
+ if (a.forEach((y, g) => {
2281
+ o.forEach((b, w) => {
2282
+ const k = w === 0 ? h + l[g] : ">";
2283
+ this.tween(y, [b], k, ([x], v, S) => this.compat.to(v, x, S)), f = Math.min(f, this.compat.lastStart), u = Math.max(u, this.compat.lastEnd);
2284
+ });
2285
+ }), f === 1 / 0) return;
2286
+ const { onStart: m, onUpdate: p, onComplete: d } = e;
2287
+ m && this.events.push({ time: f, direction: "forward", run: m }), p && this.ranges.push({ start: f, end: u, run: p }), d && this.events.push({ time: u, direction: "forward", run: d });
2288
+ }
2289
+ staggerContext(t) {
2290
+ return {
2291
+ count: t.length,
2292
+ columnsFromLayout: () => Tt(t.map((e) => this.stage.elementFor(e))),
2293
+ random: () => this.stage.utils.random(0, 1)
2294
+ };
2295
+ }
2296
+ buildTween(t, e, r, i) {
2297
+ const o = t.map((u) => this.targetFor(u));
2298
+ if (!(t.length > 1 && (e.some(cr) || t.some((u) => this.stage.objectFor(u) !== void 0)))) {
2299
+ const u = this.targetFor(t[0]);
2300
+ i(e.map((m) => this.prepare(kt(m, 0, u, this.stage.utils, o), t)), t, r);
2301
+ return;
2302
+ }
2303
+ const c = e.length - 1, { stagger: a, ...l } = e[c], h = Z(a, this.staggerContext(t)), f = h ? lt(t.length, h).map((u) => u / 1e3) : t.map(() => 0);
2304
+ t.forEach((u, m) => {
2305
+ const p = m === 0 ? U(l.delay, 0) / 1e3 + f[0] : 0, d = m === 0 ? 0 : f[m] - f[m - 1], y = m === 0 ? r : `<${d < 0 ? "-" : "+"}${Math.abs(d).toFixed(6)}`, b = e.map((w, k) => k === c ? { ...l, delay: p } : w).map((w) => this.prepare(kt(w, m, this.targetFor(u), this.stage.utils, o), [u]));
2306
+ i(b, [u], y);
2307
+ });
2308
+ }
2309
+ /** The element or plain object behind a target name. */
2310
+ targetFor(t) {
2311
+ return this.stage.elementFor(t) ?? this.stage.objectFor(t);
2312
+ }
2313
+ /**
2314
+ * Resolve the parts of vars that refer to the page — today, a motion path
2315
+ * given as a selector or element, and its `align` — into plain data.
2316
+ */
2317
+ prepare(t, e) {
2318
+ const r = (s) => this.options.onWarning?.(s), i = (s) => this.stage.query(s);
2319
+ let o = t;
2320
+ if (t.motionPath !== void 0) {
2321
+ const s = Ye(t.motionPath, {
2322
+ query: i,
2323
+ targets: e.map((c) => this.stage.elementFor(c)).filter((c) => !!c),
2324
+ warn: r
2325
+ });
2326
+ o = { ...o, motionPath: s };
2327
+ }
2328
+ if (t.morphSVG !== void 0) {
2329
+ const s = Te(t.morphSVG, i, r), { morphSVG: c, ...a } = o;
2330
+ o = s ? { ...o, morphSVG: s } : a;
2331
+ }
2332
+ if (t.drawSVG !== void 0) {
2333
+ const s = xt(this.stage.elementFor(e[0]));
2334
+ if (s === void 0) {
2335
+ r("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");
2336
+ const { drawSVG: c, ...a } = o;
2337
+ o = a;
2338
+ } else
2339
+ o = me(o, s);
2340
+ }
2341
+ return o;
2342
+ }
2343
+ resolve(t) {
2344
+ const e = this.stage.resolveTargets(t);
2345
+ if (e.length === 0) {
2346
+ this.options.onWarning?.(`gsap-compat: no elements found for target ${hr(t)}`);
2347
+ return;
2348
+ }
2349
+ return this.firstElement ??= e.map((r) => this.stage.elementFor(r)).find((r) => r !== void 0), e;
2350
+ }
2351
+ }
2352
+ function sr(n = new tr()) {
2353
+ const t = (o) => {
2354
+ const { config: s } = B(o);
2355
+ return new P(n, {
2356
+ repeat: s.repeat,
2357
+ yoyo: s.yoyo,
2358
+ repeatDelay: s.repeatDelay,
2359
+ paused: s.paused,
2360
+ onStart: s.onStart,
2361
+ onUpdate: s.onUpdate,
2362
+ onComplete: s.onComplete,
2363
+ onRepeat: s.onRepeat,
2364
+ onReverseComplete: s.onReverseComplete,
2365
+ repeatRefresh: s.repeatRefresh,
2366
+ scrollTrigger: s.scrollTrigger
2367
+ });
2368
+ }, e = (o) => {
2369
+ const { onStart: s, onUpdate: c, onComplete: a, onRepeat: l, onReverseComplete: h, repeatRefresh: f, ...u } = o;
2370
+ return u;
2371
+ }, r = (o) => (o && n.collector?.track(o), o), i = {
2372
+ stage: n,
2373
+ ticker: n.ticker,
2374
+ utils: n.utils,
2375
+ getProperty: (o, s) => {
2376
+ const [c] = n.resolveTargets(o);
2377
+ if (c === void 0) return;
2378
+ const a = n.objectFor(c);
2379
+ return a ? a[s] : n.appliedValue(c, s) ?? Rt(s);
2380
+ },
2381
+ scrollTrigger: (o) => r(it(n, o)),
2382
+ scrollBatch: (o, s) => Je(n, o, s).map((c) => r(c)),
2383
+ scrollTo: (o, s) => bt(i, n, o, s),
2384
+ refreshScroll: () => {
2385
+ Mt.refreshAll(), ht.refreshAll();
2386
+ },
2387
+ smoothScroll: (o = {}) => {
2388
+ const s = typeof o.scroller == "string" ? (n.collector?.scope ?? n.root).querySelector(o.scroller) : o.scroller;
2389
+ return r(new ht({ ...o, scroller: s }).start());
2390
+ },
2391
+ context: (o, s) => {
2392
+ const c = new Ot(n, s);
2393
+ return o && c.add(() => o(c)), c;
2394
+ },
2395
+ matchMedia: (o) => new $e(n, o),
2396
+ customEase: Ne.create,
2397
+ customBounce: Ve.create,
2398
+ customWiggle: je.create,
2399
+ pageTransition: (o) => or(i, n, (s) => new P(n, s), o),
2400
+ imageSequence: (o, s) => {
2401
+ const c = typeof o == "string" ? (n.collector?.scope ?? n.root).querySelector(o) : o;
2402
+ if (!(c instanceof HTMLCanvasElement)) throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(o)}`);
2403
+ return r(new Ie(c, s));
2404
+ },
2405
+ quickTo: (o, s, c = {}) => {
2406
+ const a = new P(n, { paused: !0 }), [l] = n.resolveTargets(o);
2407
+ return Object.assign((f) => {
2408
+ if (!l) return;
2409
+ const u = c.spring !== void 0 ? n.velocityOf(l, s) ?? 0 : 0;
2410
+ a.compat.reset(), a.compat.to(l, {
2411
+ [s]: f,
2412
+ duration: c.duration ?? 0.4,
2413
+ ease: c.ease ?? "power3.out",
2414
+ ...c.spring !== void 0 && { spring: ar(c.spring, s, u) }
2415
+ }), a.timeline.stop(), a.timeline.play(), n.activate(a.timeline);
2416
+ }, { tween: a, kill: () => a.kill() });
2417
+ },
2418
+ timeline: (o) => new P(n, o),
2419
+ // A single tween's callbacks are its timeline's, so they are not placed again as events.
2420
+ to: (o, s) => {
2421
+ if (s.scrollTo !== void 0) {
2422
+ const { scrollTo: c, ...a } = s, l = typeof c == "object" && c !== null && !("nodeType" in c) ? c : {}, h = typeof o != "string" && o !== window && o.nodeType === 1;
2423
+ return bt(i, n, c, {
2424
+ ...a,
2425
+ offsetX: l.offsetX,
2426
+ offsetY: l.offsetY,
2427
+ scroller: h ? o : void 0
2428
+ });
2429
+ }
2430
+ return t(s).to(o, e(s));
2431
+ },
2432
+ from: (o, s) => t(s).from(o, e(s)),
2433
+ fromTo: (o, s, c) => t(c).fromTo(o, s, e(c)),
2434
+ set: (o, s) => t(s).set(o, e(s)),
2435
+ delayedCall: (o, s, c) => new P(n).call(s, c, o),
2436
+ killTweensOf: (o, s) => {
2437
+ const c = n.resolveTargets(o), a = typeof s == "string" ? s.split(",").map((l) => l.trim()).filter(Boolean) : s;
2438
+ for (const l of [...n.liveTimelines]) l.killTweensOf(c, a);
2439
+ },
2440
+ convertToPath: (o) => Se(o, n.root),
2441
+ splitText: (o, s) => {
2442
+ const c = n.collector?.scope ?? n.root, a = typeof o == "string" ? Array.from(c.querySelectorAll(o)) : "nodeType" in o ? [o] : Array.from(o);
2443
+ return r(Me(a, s));
2444
+ },
2445
+ draggable: (o, s) => r(Be(i, n, o, s)),
2446
+ getFlipState: (o) => Q(n, o),
2447
+ flipFrom: (o, s) => tt(n, (c) => new P(n, c), o, s),
2448
+ flip: (o, s, c) => {
2449
+ const a = Q(n, o);
2450
+ return s(), tt(n, (l) => new P(n, l), a, { targets: o, ...c });
2451
+ }
2452
+ };
2453
+ return i;
2454
+ }
2455
+ const Tr = /* @__PURE__ */ sr();
2456
+ function ar(n, t, e) {
2457
+ return n === !0 ? { velocity: { [t]: e } } : typeof n == "string" ? { preset: n, velocity: { [t]: e } } : { ...n, velocity: { [t]: e } };
2458
+ }
2459
+ function cr(n) {
2460
+ return n.morphSVG !== void 0 || n.drawSVG !== void 0 || n.text !== void 0 || n.scrambleText !== void 0 || Nt(n);
2461
+ }
2462
+ function Nt(n) {
2463
+ return Object.entries(n).some(([t, e]) => (typeof e == "function" || Ct(e)) && !nt.has(t));
2464
+ }
2465
+ function kt(n, t, e, r, i) {
2466
+ if (!Nt(n)) return n;
2467
+ const o = {};
2468
+ for (const [s, c] of Object.entries(n))
2469
+ nt.has(s) ? o[s] = c : typeof c == "function" ? o[s] = c(t, e, i) : Ct(c) ? o[s] = r.resolveRandomString(c) : o[s] = c;
2470
+ return o;
2471
+ }
2472
+ function Tt(n) {
2473
+ const t = n.map((r) => r?.getBoundingClientRect().top);
2474
+ if (t[0] === void 0) return n.length;
2475
+ let e = 0;
2476
+ for (const r of t) {
2477
+ if (r === void 0 || Math.abs(r - t[0]) > 1) break;
2478
+ e++;
2479
+ }
2480
+ return Math.max(1, e);
2481
+ }
2482
+ function xt(n) {
2483
+ const t = n;
2484
+ if (typeof t?.getTotalLength == "function")
2485
+ return t.getTotalLength();
2486
+ }
2487
+ function lr(n) {
2488
+ if (typeof n == "number" || typeof n == "string" || Array.isArray(n) && n.every((t) => typeof t == "number")) return n;
2489
+ }
2490
+ function hr(n) {
2491
+ return typeof n == "string" ? `"${n}"` : String(n);
2492
+ }
2493
+ const xr = {
2494
+ timeline: ke,
2495
+ to(n, t, e) {
2496
+ const r = new $(e);
2497
+ return r.to(n, t), r;
2498
+ },
2499
+ from(n, t, e) {
2500
+ const r = new $(e);
2501
+ return r.from(n, t), r;
2502
+ },
2503
+ fromTo(n, t, e, r) {
2504
+ const i = new $(r);
2505
+ return i.fromTo(n, t, e), i;
2506
+ },
2507
+ set(n, t, e) {
2508
+ const r = new $(e);
2509
+ return r.set(n, t), r;
2510
+ }
2511
+ };
2512
+ export {
2513
+ $ as CompatTimeline,
2514
+ Ve as CustomBounce,
2515
+ Ne as CustomEase,
2516
+ je as CustomWiggle,
2517
+ Ie as ImageSequence,
2518
+ Ot as LiveContext,
2519
+ $e as LiveMatchMedia,
2520
+ P as LiveTimeline,
2521
+ ce as PROPERTY_DEFAULTS,
2522
+ nt as RESERVED_KEYS,
2523
+ tr as Stage,
2524
+ Er as backOut,
2525
+ gr as bounceIn,
2526
+ wr as bounceInOut,
2527
+ Ar as bounceOut,
2528
+ we as compileInertiaProperty,
2529
+ le as compileMotionPath,
2530
+ ge as compileTextVars,
2531
+ Se as convertToPath,
2532
+ sr as createLive,
2533
+ Be as createLiveDraggable,
2534
+ it as createScrollTrigger,
2535
+ re as createUtils,
2536
+ Rt as defaultFor,
2537
+ ue as desugarMorph,
2538
+ fe as drawSegment,
2539
+ de as drawSvgProperties,
2540
+ vr as easeRequiresBaking,
2541
+ pr as elasticIn,
2542
+ yr as elasticInOut,
2543
+ Cr as elasticOut,
2544
+ Ze as expandKeyframes,
2545
+ tt as flipFrom,
2546
+ Q as getFlipState,
2547
+ ae as gridOffsets,
2548
+ Ct as isRandomString,
2549
+ Tr as live,
2550
+ V as mapEase,
2551
+ Ft as morphShapeOf,
2552
+ ee as normaliseEaseName,
2553
+ Lt as pathDataOf,
2554
+ Rr as playheadCrossings,
2555
+ kr as quickPlay,
2556
+ rt as registerEase,
2557
+ pe as rejectUnresolvedDrawSvg,
2558
+ ot as resistanceToFriction,
2559
+ me as resolveDrawSvg,
2560
+ Ye as resolveLiveMotionPath,
2561
+ I as resolvePosition,
2562
+ he as reverseMotionPath,
2563
+ Je as scrollBatch,
2564
+ bt as scrollTo,
2565
+ K as seededRandom,
2566
+ Me as splitText,
2567
+ B as splitVars,
2568
+ be as springParameters,
2569
+ ve as springVelocity,
2570
+ br as steps,
2571
+ Fr as stepsEasing,
2572
+ xr as tf,
2573
+ ke as timeline,
2574
+ U as toMs,
2575
+ Z as toStaggerConfig
2576
+ };