@mkbabb/keyframes.js 4.4.0 → 5.0.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.
@@ -1,26 +1,26 @@
1
1
  import { r as e, t } from "./errors-W8zkvPw4.js";
2
- import { a as n, d as r, h as i, l as a } from "./timeline-B7SV3T_E.js";
3
- import { r as o } from "./springTimingFunction-CDHZ00JQ.js";
2
+ import { a as n, d as r, h as i, l as a } from "./timeline-vY3eD3Ax.js";
3
+ import { r as o } from "./springTimingFunction-D26gPkAy.js";
4
4
  import { n as s } from "./scheduler-7eIr_q1g.js";
5
- import { a as c, i as l, n as u, r as d, t as f } from "./utils-D7nuAND5.js";
6
- import { n as p, r as m } from "./waapi-D9MHMm_9.js";
7
- import { COLOR_SPACE_RANGES as ee, FunctionValue as h, ValueArray as g, ValueUnit as _, clamp as v, easeInOutCubic as te, extractAnimationOptions as ne, extractFunctions as re, extractKeyframes as ie, extractProperties as ae, extractTimelineOptions as oe, isObject as se, lerp as y, lerpValue as ce, parseCSSStylesheet as b, parseCSSTime as le, parseCSSValue as ue, parseCSSValueUnit as x, scale as S, seekPreviousValue as C, sleep as de, unflattenObject as fe } from "@mkbabb/value.js";
5
+ import { a as c, i as l, n as u, r as d, t as ee } from "./utils-BPRImVl5.js";
6
+ import { n as te, r as ne } from "./waapi-D0ssxKy1.js";
7
+ import { COLOR_SPACE_RANGES as re, FunctionValue as f, ValueArray as p, ValueUnit as m, clamp as ie, coerceToSyntax as ae, easeInOutCubic as oe, extractAnimationOptions as se, extractFunctions as ce, extractKeyframes as le, extractProperties as ue, extractTimelineOptions as de, isObject as fe, lerp as pe, lerpArray as me, lerpValue as he, parseCSSStylesheet as h, parseCSSTime as ge, parseCSSValue as g, parseCSSValueUnit as _e, scale as ve, seekPreviousValue as _, sleep as ye, unflattenObject as be } from "@mkbabb/value.js";
8
8
  //#region src/animation/resolve-values.ts
9
- var pe = 32, me = () => {
9
+ var xe = 32, Se = () => {
10
10
  let e = typeof globalThis < "u" && typeof globalThis.CSS?.supports == "function", t = typeof globalThis < "u" && typeof globalThis.matchMedia == "function";
11
11
  return {
12
12
  supports: e ? (e) => globalThis.CSS.supports(e) : () => !1,
13
13
  matchMedia: t ? (e) => globalThis.matchMedia(e) : () => ({ matches: !1 })
14
14
  };
15
- }, he = (e, t) => ({
15
+ }, v = (e, t) => ({
16
16
  functions: e,
17
17
  env: {
18
- ...me(),
18
+ ...Se(),
19
19
  ...t
20
20
  },
21
21
  seen: /* @__PURE__ */ new Set(),
22
22
  depth: 0
23
- }), w = Symbol("kf.resolve.drop"), ge = (e) => {
23
+ }), y = Symbol("kf.resolve.drop"), b = (e) => {
24
24
  let t = e.indexOf("(");
25
25
  if (t <= 0 || !e.trimEnd().endsWith(")")) return;
26
26
  let n = e.slice(0, t).trim().toLowerCase(), r = e.slice(t + 1, e.lastIndexOf(")")).trim();
@@ -28,96 +28,175 @@ var pe = 32, me = () => {
28
28
  name: n,
29
29
  query: r
30
30
  };
31
- }, _e = (e, t) => {
32
- let n = String(e instanceof _ ? e.value : e).trim();
31
+ }, Ce = (e, t) => {
32
+ let n = String(e instanceof m ? e.value : e).trim();
33
33
  if (n === "else" || n === "") return !0;
34
- let r = ge(n);
34
+ let r = b(n);
35
35
  if (!r) return !1;
36
36
  let { name: i, query: a } = r;
37
- if (i === "supports") return t.env.supports?.(a) ?? !1;
38
- if (i === "media") return t.env.matchMedia?.(a)?.matches ?? !1;
39
- if (i !== "style") return !1;
40
- }, ve = (e) => e instanceof _ && String(e.value).trim() === "", T = (e) => {
41
- if (e === w) return e;
42
- if (e instanceof _ && e.unit === "string") try {
43
- return ue(String(e.value));
37
+ return i === "supports" ? t.env.supports?.(a) ?? !1 : i === "media" ? t.env.matchMedia?.(a)?.matches ?? !1 : i === "style" ? t.env.customProps === void 0 ? void 0 : we(a, t.env.customProps) : !1;
38
+ }, we = (e, t) => {
39
+ let n = e.indexOf(":");
40
+ if (n === -1) {
41
+ let n = e.trim();
42
+ return n === "" ? !1 : t(n) !== void 0;
43
+ }
44
+ let r = e.slice(0, n).trim(), i = e.slice(n + 1).trim();
45
+ if (r === "") return !1;
46
+ let a = t(r);
47
+ if (a === void 0) return !1;
48
+ let o = (e) => e.trim().replace(/\s+/g, " ");
49
+ return o(a) === o(i);
50
+ }, Te = (e) => e instanceof m && String(e.value).trim() === "", x = (e) => {
51
+ if (e === y) return e;
52
+ if (e instanceof m && e.unit === "string") try {
53
+ return g(String(e.value));
44
54
  } catch {
45
55
  return e;
46
56
  }
47
57
  return e;
48
- }, ye = (e, t) => {
58
+ }, Ee = (e) => {
59
+ let t = e.name.trim(), n = t.search(/\s/), r = n === -1 ? t : t.slice(0, n), i = n === -1 ? "" : t.slice(n).trim(), a = i.startsWith("<") && i.endsWith(">") ? i : void 0, o = e.type !== void 0 && !(e.type.startsWith("<") && e.type.endsWith(">")) ? e.type : void 0;
60
+ return {
61
+ ident: r,
62
+ syntax: a,
63
+ defaultValue: e.defaultValue ?? o
64
+ };
65
+ }, De = (e, t) => {
66
+ if (t.syntax === void 0) return e;
67
+ let n = ae(String(e), t.syntax);
68
+ if (n !== null) return n;
69
+ if (t.defaultValue === void 0) return y;
70
+ try {
71
+ return g(t.defaultValue);
72
+ } catch {
73
+ return y;
74
+ }
75
+ }, Oe = (e, t) => !(e instanceof m) || e.unit !== "var" ? !1 : String(e.value).split(",", 1)[0]?.trim() === t, S = (e, t) => {
76
+ if (e instanceof m) {
77
+ if (e.unit === "var") {
78
+ for (let [n, r] of t) if (Oe(e, n)) return r.clone();
79
+ }
80
+ return e;
81
+ }
82
+ let n = e.values.map((e) => S(e, t));
83
+ return new f(e.name, n);
84
+ }, ke = (e, t) => {
85
+ if (t.seen.has(e.name)) return y;
86
+ let n = t.functions.get(e.name);
87
+ if (n === void 0 || n.result === void 0) return y;
88
+ let r = (n.parameters ?? []).map(Ee), i = e.values;
89
+ if (i.length > r.length) return y;
90
+ let a = /* @__PURE__ */ new Map();
91
+ for (let e = 0; e < r.length; e++) {
92
+ let t = r[e], n = i[e], o;
93
+ if (n === void 0) {
94
+ if (t.defaultValue === void 0) return y;
95
+ try {
96
+ o = g(t.defaultValue);
97
+ } catch {
98
+ return y;
99
+ }
100
+ } else o = De(n, t);
101
+ if (o === y) return y;
102
+ a.set(t.ident, o);
103
+ }
104
+ let o = n.result.clone().map((e) => S(e, a));
105
+ t.seen.add(e.name);
106
+ let s = [];
107
+ for (let e of o) {
108
+ let n = C(e, {
109
+ ...t,
110
+ depth: t.depth + 1
111
+ });
112
+ n !== y && s.push(n);
113
+ }
114
+ return t.seen.delete(e.name), s.length === 0 ? y : s[0];
115
+ }, Ae = (e, t) => {
49
116
  let n = e.values, r = n[0], i = n[1], a = n[2];
50
- if (r === void 0 || i === void 0) return w;
51
- let o = _e(r, t);
52
- return o === void 0 ? e : o ? T(E(i, t)) : a !== void 0 && !ve(a) ? T(E(a, t)) : w;
53
- }, E = (e, t) => {
54
- if (t.depth > pe) return w;
55
- if (e instanceof _ || !(e instanceof h)) return e;
56
- if (e.name === "if") return ye(e, {
117
+ if (r === void 0 || i === void 0) return y;
118
+ let o = Ce(r, t);
119
+ return o === void 0 ? e : o ? x(C(i, t)) : a !== void 0 && !Te(a) ? x(C(a, t)) : y;
120
+ }, C = (e, t) => {
121
+ if (t.depth > xe) return y;
122
+ if (e instanceof m || !(e instanceof f)) return e;
123
+ if (e.name === "if") return Ae(e, {
57
124
  ...t,
58
125
  depth: t.depth + 1
59
126
  });
60
- if (e.name.startsWith("--") && t.functions.has(e.name)) return e;
127
+ if (e.name === "sibling-index") {
128
+ let n = t.env.siblingIndex;
129
+ return n === void 0 ? e : new m(n(), "");
130
+ }
131
+ if (e.name === "sibling-count") {
132
+ let n = t.env.siblingCount;
133
+ return n === void 0 ? e : new m(n(), "");
134
+ }
135
+ if (e.name.startsWith("--") && t.functions.has(e.name)) return ke(e, t);
61
136
  let n = [], r = !1;
62
137
  for (let i of e.values) {
63
- let e = E(i, {
138
+ let e = C(i, {
64
139
  ...t,
65
140
  depth: t.depth + 1
66
141
  });
67
- if (e === w) {
142
+ if (e === y) {
68
143
  r = !0;
69
144
  continue;
70
145
  }
71
146
  e !== i && (r = !0), n.push(e);
72
147
  }
73
- return r ? new h(e.name, n) : e;
74
- }, D = (e, t) => {
148
+ return r ? new f(e.name, n) : e;
149
+ }, w = (e, t) => {
75
150
  let n = [], r = !1;
76
151
  for (let i of e) {
77
- let e = E(i, t);
78
- if (e === w) {
152
+ let e = C(i, t);
153
+ if (e === y) {
79
154
  r = !0;
80
155
  continue;
81
156
  }
82
157
  e !== i && (r = !0), n.push(e);
83
158
  }
84
- return n.length === 0 ? w : r ? new g(...n) : e;
85
- }, O = (e) => e instanceof h ? e.name === "if" || e.name === "spring" ? !0 : e.values.some((e) => O(e)) : e instanceof g ? e.some((e) => O(e)) : !1, k = (e, t) => {
159
+ return n.length === 0 ? y : r ? new p(...n) : e;
160
+ }, je = (e) => {
161
+ if (e.name !== "if") return !1;
162
+ let t = e.values[0];
163
+ return t === void 0 ? !1 : b(String(t instanceof m ? t.value : t).trim())?.name === "style";
164
+ }, T = (e) => e instanceof f ? e.name === "if" || e.name === "spring" || e.name === "sibling-index" || e.name === "sibling-count" || e.name.startsWith("--") ? !0 : e.values.some((e) => T(e)) : e instanceof p ? e.some((e) => T(e)) : !1, E = (e) => e instanceof f ? e.name === "sibling-index" || e.name === "sibling-count" || je(e) ? !0 : e.values.some((e) => E(e)) : e instanceof p ? e.some((e) => E(e)) : !1, Me = (e, t) => {
86
165
  let n = {};
87
166
  for (let r of e.declarations) {
88
167
  let e = r.value;
89
- if (e instanceof g && O(e)) {
90
- let n = D(e, t);
91
- if (n === w) continue;
168
+ if (e instanceof p && T(e)) {
169
+ let n = w(e, t);
170
+ if (n === y) continue;
92
171
  e = n;
93
172
  }
94
173
  n[r.name] = e;
95
174
  }
96
175
  return n;
97
- }, A = (e) => {
176
+ }, Ne = (e) => {
98
177
  let t = [];
99
178
  for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
100
179
  return t;
101
- }, j = (e) => {
102
- let t = ie(e);
180
+ }, D = (e) => {
181
+ let t = le(e);
103
182
  for (let e of t.values()) if (e.length > 0) return e;
104
183
  return [];
105
- }, M = (e, t) => {
184
+ }, O = (e, t) => {
106
185
  let n = [], r = (e, t) => {
107
186
  n.push({
108
187
  code: e,
109
188
  message: t.message ?? e,
110
189
  ...t
111
190
  });
112
- }, i = typeof e == "string" ? b(e) : e, a = j(i);
113
- typeof e == "string" && a.length === 0 && e.trim() && (i = b(`@keyframes anonymous {\n${e.trim()}\n}`), a = j(i)), typeof e == "string" && a.length === 0 && e.trim() && r("EMPTY_PARSE", {
191
+ }, i = typeof e == "string" ? h(e) : e, a = D(i);
192
+ typeof e == "string" && a.length === 0 && e.trim() && (i = h(`@keyframes anonymous {\n${e.trim()}\n}`), a = D(i)), typeof e == "string" && a.length === 0 && e.trim() && r("EMPTY_PARSE", {
114
193
  message: "the input is non-empty but parsed to zero @keyframes rules (no animatable stops) — the resulting animation has no frames",
115
194
  input: e
116
195
  });
117
- let o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = re(i), u = he(l, t);
196
+ let o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = ce(i), u = v(l, t);
118
197
  for (let e of a) {
119
- let t = k(e, u);
120
- for (let n of A(e)) {
198
+ let t = Me(e, u);
199
+ for (let n of Ne(e)) {
121
200
  let r = o.get(n);
122
201
  o.set(n, {
123
202
  ...r ?? {},
@@ -131,60 +210,60 @@ var pe = 32, me = () => {
131
210
  keyframes: o,
132
211
  timingFunctions: s,
133
212
  composition: c,
134
- properties: ae(i),
213
+ properties: ue(i),
135
214
  functions: l,
136
- options: ne(i),
215
+ options: se(i),
137
216
  diagnostics: n,
138
217
  stylesheet: i
139
218
  };
140
- }, N = [
219
+ }, k = [
141
220
  "normal",
142
221
  "reverse",
143
222
  "alternate",
144
223
  "alternate-reverse"
145
- ], P = [
224
+ ], A = [
146
225
  "none",
147
226
  "forwards",
148
227
  "backwards",
149
228
  "both"
150
- ], F = Object.keys(ee), I = [
229
+ ], j = Object.keys(re), M = [
151
230
  "shorter",
152
231
  "longer",
153
232
  "increasing",
154
233
  "decreasing"
155
- ], L = () => {}, R = {
234
+ ], N = () => {}, P = {
156
235
  duration: 1e3,
157
236
  delay: 0,
158
237
  iterationCount: 1,
159
238
  direction: "normal",
160
239
  fillMode: "forwards",
161
- timingFunction: { fn: te },
240
+ timingFunction: { fn: oe },
162
241
  useWAAPI: !0,
163
242
  respectReducedMotion: !1,
164
243
  colorSpace: "oklab"
165
- }, z = {
244
+ }, F = {
166
245
  zIndex: 0,
167
246
  weight: 1,
168
247
  blendMode: "replace",
169
248
  enabled: !0
170
- }, B = (e) => typeof e == "string" ? e : Q(e), V = (e, t, n) => {
171
- let r = B(t), i = e[r];
249
+ }, I = (e) => typeof e == "string" ? e : Q(e), L = (e, t, n) => {
250
+ let r = I(t), i = e[r];
172
251
  if (!i) throw Error(`AnimationGroup.${n}: no animation registered for key "${r}". Known keys: ${Object.keys(e).join(", ") || "(none)"}.`);
173
252
  return i;
174
- }, be = (e, t, r) => {
253
+ }, Pe = (e, t, r) => {
175
254
  let i = new n({
176
255
  ...r,
177
256
  initial: e
178
257
  });
179
258
  return i.target = t, i;
180
- }, xe = (e) => {
259
+ }, Fe = (e) => {
181
260
  let t = /* @__PURE__ */ new Set();
182
261
  for (let n of e) {
183
262
  let e = n.layer.properties;
184
263
  for (let r of n.animation.flatKeys) e && !e.has(r) || t.add(r);
185
264
  }
186
265
  return [...t];
187
- }, H = (e, t) => {
266
+ }, R = (e, t) => {
188
267
  let n;
189
268
  for (let r of e) {
190
269
  let e = r.animation;
@@ -193,22 +272,75 @@ var pe = 32, me = () => {
193
272
  typeof i != "number" && (n ??= []).push(i);
194
273
  }
195
274
  return n && Promise.all(n).then(() => void 0);
196
- }, Se = async (e, t, n) => {
197
- for (let r = 0; r < e.length; r += n) await H(e.slice(r, r + n), t), r + n < e.length && await s();
198
- }, U = (e) => {
275
+ }, Ie = async (e, t, n) => {
276
+ for (let r = 0; r < e.length; r += n) await R(e.slice(r, r + n), t), r + n < e.length && await s();
277
+ }, z = (e) => {
199
278
  let t = !0;
200
279
  for (let n of e) n.animation.interpFrames(n.animation.t, !0), t &&= n.animation.done;
201
280
  return t;
202
- }, Ce = (e) => {
281
+ }, Le = (e) => {
203
282
  for (let t of e) {
204
283
  let e = t.animation;
205
284
  e.started = !0, e.t = e.options.duration, e.interpFrames(e.t, !0);
206
285
  }
207
- }, W = (e, t) => {
286
+ }, B = (e, t) => {
208
287
  for (let n of e) n.animation.paused = t;
209
- }, G = (e) => e instanceof _ && typeof e.value == "number", K = class e {
288
+ }, V = (e) => e instanceof m && typeof e.value == "number", Re = (e, t) => {
289
+ let { carriers: n, incomings: r } = t, i = n.length;
290
+ if (i !== 0) {
291
+ for (let t = 0; t < i; t++) e[t] = n[t].value;
292
+ if (t.weighted) {
293
+ let n = t.layer.weightSpring?.value ?? t.layer.weight;
294
+ for (let t = 0; t < i; t++) e[t] = pe(e[t], r[t].value, n);
295
+ } else for (let t = 0; t < i; t++) e[t] = e[t] + r[t].value;
296
+ for (let t = 0; t < i; t++) n[t].value = e[t];
297
+ }
298
+ }, ze = (e, t) => {
299
+ let n = [], r = {}, i = 0;
300
+ for (let t of e) {
301
+ let { layer: e, values: a } = t;
302
+ if (!e.enabled) continue;
303
+ let o = e.properties, s = e.blendMode === "weighted";
304
+ if (e.blendMode === "replace") {
305
+ for (let e in a) {
306
+ if (o && !o.has(e)) continue;
307
+ let t = a[e];
308
+ t !== void 0 && (r[e] = t);
309
+ }
310
+ continue;
311
+ }
312
+ let c = [], l = [], u = [];
313
+ for (let e in a) {
314
+ if (o && !o.has(e)) continue;
315
+ let t = a[e];
316
+ if (t === void 0) continue;
317
+ let n = r[e];
318
+ if (Array.isArray(n) && Array.isArray(t)) {
319
+ let r = Math.min(n.length, t.length), i = !0;
320
+ for (let e = 0; e < r; e++) if (!V(n[e]) || !V(t[e])) {
321
+ i = !1;
322
+ break;
323
+ }
324
+ if (i) for (let e = 0; e < r; e++) c.push(n[e]), l.push(t[e]);
325
+ else u.push(e);
326
+ } else u.push(e), r[e] = t;
327
+ }
328
+ c.length > i && (i = c.length), n.push({
329
+ layer: e,
330
+ weighted: s,
331
+ carriers: c,
332
+ incomings: l,
333
+ boxedKeys: u
334
+ });
335
+ }
336
+ let a = t;
337
+ return i > 0 && (a === null || a.length < i) && (a = new Float64Array(i)), {
338
+ plans: n,
339
+ compositeBuf: a
340
+ };
341
+ }, H = class e {
210
342
  animations = {};
211
- transform = L;
343
+ transform = N;
212
344
  superKey;
213
345
  paused = !1;
214
346
  started = !1;
@@ -234,13 +366,13 @@ var pe = 32, me = () => {
234
366
  let t = [];
235
367
  for (let n of e) {
236
368
  let e, r;
237
- n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform === L && e.frames[0] != null && (this.transform = e.frames[0].transform);
369
+ n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform === N && e.frames[0] != null && (this.transform = e.frames[0].transform);
238
370
  let i = Q(e);
239
371
  this.animations[i] = {
240
372
  values: {},
241
373
  animation: e,
242
374
  layer: {
243
- ...z,
375
+ ...F,
244
376
  ...r
245
377
  }
246
378
  }, e.managed = !0, t.push(e);
@@ -271,7 +403,7 @@ var pe = 32, me = () => {
271
403
  }
272
404
  transformFramesGrouped(e) {
273
405
  let t = this._grouped;
274
- this._groupedKeysDirty && (this._groupedKeys = xe(this.getEntries()), this._groupedKeysDirty = !1, this._soaPlans = null);
406
+ this._groupedKeysDirty && (this._groupedKeys = Fe(this.getEntries()), this._groupedKeysDirty = !1, this._soaPlans = null);
275
407
  let n = this._groupedKeys;
276
408
  for (let e = 0; e < n.length; e++) t[n[e]] = void 0;
277
409
  let r = this.getEntries(), i = this._soaPlans !== null, a = 0, o = !0;
@@ -293,12 +425,16 @@ var pe = 32, me = () => {
293
425
  this.soaBlendLayer(e), e.boxedKeys.length > 0 && this.boxedBlendArm(r, s, t, c, e.boxedKeys);
294
426
  } else this.boxedBlendArm(r, s, t, c);
295
427
  }
296
- i || (this._soaPlans = this.buildSoAPlans(r)), this.done = o;
428
+ if (!i) {
429
+ let { plans: e, compositeBuf: t } = ze(r, this._compositeBuf);
430
+ this._soaPlans = e, this._compositeBuf = t;
431
+ }
432
+ this.done = o;
297
433
  for (let e = 0; e < n.length; e++) {
298
434
  let r = n[e];
299
435
  t[r] === void 0 && delete t[r];
300
436
  }
301
- if (this.transform === L) for (let e of this.getEntries()) {
437
+ if (this.transform === N) for (let e of this.getEntries()) {
302
438
  let t = e.animation.frames[0];
303
439
  if (t != null && t.transform != null) {
304
440
  this.transform = t.transform;
@@ -317,7 +453,7 @@ var pe = 32, me = () => {
317
453
  let o = n[e];
318
454
  if (Array.isArray(o) && Array.isArray(i)) {
319
455
  let e = Math.min(o.length, i.length);
320
- for (let t = 0; t < e; t++) G(o[t]) && G(i[t]) ? o[t].value += i[t].value : o[t] = i[t];
456
+ for (let t = 0; t < e; t++) V(o[t]) && V(i[t]) ? o[t].value += i[t].value : o[t] = i[t];
321
457
  } else n[e] = i;
322
458
  }
323
459
  return;
@@ -330,73 +466,25 @@ var pe = 32, me = () => {
330
466
  let s = n[e];
331
467
  if (Array.isArray(s) && Array.isArray(i)) {
332
468
  let e = Math.min(s.length, i.length);
333
- for (let t = 0; t < e; t++) G(s[t]) && G(i[t]) ? s[t].value = y(s[t].value, i[t].value, o) : s[t] = i[t];
469
+ for (let t = 0; t < e; t++) V(s[t]) && V(i[t]) ? s[t].value = pe(s[t].value, i[t].value, o) : s[t] = i[t];
334
470
  } else n[e] = i;
335
471
  }
336
472
  }
337
473
  soaBlendLayer(e) {
338
- let { carriers: t, incomings: n } = e, r = t.length;
339
- if (r === 0) return;
340
- let i = this._compositeBuf;
341
- for (let e = 0; e < r; e++) i[e] = t[e].value;
342
- if (e.weighted) {
343
- let t = e.layer.weightSpring?.value ?? e.layer.weight;
344
- for (let e = 0; e < r; e++) i[e] = y(i[e], n[e].value, t);
345
- } else for (let e = 0; e < r; e++) i[e] = i[e] + n[e].value;
346
- for (let e = 0; e < r; e++) t[e].value = i[e];
347
- }
348
- buildSoAPlans(e) {
349
- let t = [], n = {}, r = 0;
350
- for (let i of e) {
351
- let { layer: e, values: a } = i;
352
- if (!e.enabled) continue;
353
- let o = e.properties, s = e.blendMode === "weighted";
354
- if (e.blendMode === "replace") {
355
- for (let e in a) {
356
- if (o && !o.has(e)) continue;
357
- let t = a[e];
358
- t !== void 0 && (n[e] = t);
359
- }
360
- continue;
361
- }
362
- let c = [], l = [], u = [];
363
- for (let e in a) {
364
- if (o && !o.has(e)) continue;
365
- let t = a[e];
366
- if (t === void 0) continue;
367
- let r = n[e];
368
- if (Array.isArray(r) && Array.isArray(t)) {
369
- let n = Math.min(r.length, t.length), i = !0;
370
- for (let e = 0; e < n; e++) if (!G(r[e]) || !G(t[e])) {
371
- i = !1;
372
- break;
373
- }
374
- if (i) for (let e = 0; e < n; e++) c.push(r[e]), l.push(t[e]);
375
- else u.push(e);
376
- } else u.push(e), n[e] = t;
377
- }
378
- c.length > r && (r = c.length), t.push({
379
- layer: e,
380
- weighted: s,
381
- carriers: c,
382
- incomings: l,
383
- boxedKeys: u
384
- });
385
- }
386
- return r > 0 && (this._compositeBuf === null || this._compositeBuf.length < r) && (this._compositeBuf = new Float64Array(r)), t;
474
+ Re(this._compositeBuf, e);
387
475
  }
388
476
  render() {
389
477
  let e = this.lastTickTime || performance.now();
390
- this.singleTarget ? this.transformFramesGrouped(e) : U(this.getEntries());
478
+ this.singleTarget ? this.transformFramesGrouped(e) : z(this.getEntries());
391
479
  }
392
480
  setChildTime(e, t) {
393
- let n = V(this.animations, e, "setChildTime").animation;
481
+ let n = L(this.animations, e, "setChildTime").animation;
394
482
  return n.t = t, n.startTime !== void 0 && (n.pausedTime = n.startTime + t), this;
395
483
  }
396
484
  advanceTo(t) {
397
485
  let n = this.lastTickTime === 0 ? 0 : t - this.lastTickTime;
398
486
  this._hasLayerSprings && this.advanceLayerSprings(n), this.lastTickTime = t, this.started || this.onStart();
399
- let r = this.getEntries(), i = e.YIELD_BATCH, a = r.length <= i ? H(r, t) : Se(r, t, i);
487
+ let r = this.getEntries(), i = e.YIELD_BATCH, a = r.length <= i ? R(r, t) : Ie(r, t, i);
400
488
  return a ? a.then(() => this._endAdvance()) : this._endAdvance();
401
489
  }
402
490
  _endAdvance() {
@@ -407,7 +495,7 @@ var pe = 32, me = () => {
407
495
  return typeof t.then == "function" ? t.then(() => this._renderFrame(e)) : this._renderFrame(e);
408
496
  }
409
497
  _renderFrame(e) {
410
- return this.paused ? !1 : (this.singleTarget ? this.transformFramesGrouped(e) : this.done = U(this.getEntries()), this.done ? (this.settle(), this._resolvePlay(), !1) : !0);
498
+ return this.paused ? !1 : (this.singleTarget ? this.transformFramesGrouped(e) : this.done = z(this.getEntries()), this.done ? (this.settle(), this._resolvePlay(), !1) : !0);
411
499
  }
412
500
  _resolvePlay() {
413
501
  let e = this.resolvePromise;
@@ -428,7 +516,7 @@ var pe = 32, me = () => {
428
516
  _playReducedMotion() {
429
517
  this.onStart();
430
518
  let e = this.lastTickTime || performance.now();
431
- return this.lastTickTime = e, Ce(this.getEntries()), this.singleTarget && this.transformFramesGrouped(e), this.settle(), Promise.resolve();
519
+ return this.lastTickTime = e, Le(this.getEntries()), this.singleTarget && this.transformFramesGrouped(e), this.settle(), Promise.resolve();
432
520
  }
433
521
  pause() {
434
522
  if (!this.started || this.paused) return this;
@@ -441,7 +529,7 @@ var pe = 32, me = () => {
441
529
  return this.playback.stop(), this.render(), this;
442
530
  }
443
531
  resume() {
444
- return !this.started || !this.paused ? this : (this.paused = !1, W(this.getEntries(), !1), this.playback.loop(this._boundFrame), this);
532
+ return !this.started || !this.paused ? this : (this.paused = !1, B(this.getEntries(), !1), this.playback.loop(this._boundFrame), this);
445
533
  }
446
534
  toggle() {
447
535
  return this.paused ? this.resume() : this.pause();
@@ -464,26 +552,26 @@ var pe = 32, me = () => {
464
552
  return !(!this.started || this.paused);
465
553
  }
466
554
  forcePause() {
467
- this.paused = !0, W(this.getEntries(), !0);
555
+ this.paused = !0, B(this.getEntries(), !0);
468
556
  }
469
557
  forcePlay() {
470
- this.paused = !1, W(this.getEntries(), !1);
558
+ this.paused = !1, B(this.getEntries(), !1);
471
559
  }
472
560
  setLayerConfig(e, t) {
473
- let n = V(this.animations, e, "setLayerConfig");
561
+ let n = L(this.animations, e, "setLayerConfig");
474
562
  return Object.assign(n.layer, t), this.invalidateEntries(), this;
475
563
  }
476
564
  setLayerEnabled(e, t) {
477
565
  return this.setLayerConfig(e, { enabled: t });
478
566
  }
479
567
  getLayerConfig(e) {
480
- return this.animations[B(e)]?.layer;
568
+ return this.animations[I(e)]?.layer;
481
569
  }
482
570
  transitionLayer(e, t) {
483
- let r = V(this.animations, e, "transitionLayer").layer;
571
+ let r = L(this.animations, e, "transitionLayer").layer;
484
572
  r.blendMode = "weighted";
485
573
  let i = r.weightSpring;
486
- return i instanceof n ? i.target = t.weight : r.weightSpring = be(r.weight, t.weight, t.spring), this._hasLayerSprings = !0, this.invalidateEntries(), this;
574
+ return i instanceof n ? i.target = t.weight : r.weightSpring = Pe(r.weight, t.weight, t.spring), this._hasLayerSprings = !0, this.invalidateEntries(), this;
487
575
  }
488
576
  crossfade(e, t, n) {
489
577
  let r = n?.spring;
@@ -506,34 +594,34 @@ var pe = 32, me = () => {
506
594
  };
507
595
  //#endregion
508
596
  //#region src/animation/engine-composition.ts
509
- function q(e) {
597
+ function Be(e) {
510
598
  for (let t of e) if (t.composition != null && t.composition !== "replace") return !0;
511
599
  return !1;
512
600
  }
513
- function we(e, t) {
601
+ function Ve(e, t) {
514
602
  e.clear(), t.clear();
515
603
  }
516
- function Te(e, t) {
604
+ function He(e, t) {
517
605
  let n = e.composition;
518
606
  if (n == null || n === "replace") return;
519
607
  let r = e.flatVars;
520
608
  for (let i in r) {
521
609
  let a = r[i];
522
610
  if (!Array.isArray(a) || a.length === 0) continue;
523
- if (!a.every((e) => e instanceof _ && typeof e.value == "number")) {
524
- Oe(i, n, t);
611
+ if (!a.every((e) => e instanceof m && typeof e.value == "number")) {
612
+ Ge(i, n, t);
525
613
  continue;
526
614
  }
527
615
  let o = t.compositionBase.get(i);
528
- o === void 0 && (o = Ee(t.target, i, a.length), t.compositionBase.set(i, o));
616
+ o === void 0 && (o = Ue(t.target, i, a.length), t.compositionBase.set(i, o));
529
617
  let s = n === "accumulate" ? t.iteration : 0;
530
618
  for (let n = 0; n < a.length; n++) {
531
619
  let r = a[n], c = o[n] ?? 0;
532
- s > 0 ? r.value = c + s * (De(e, i, n, t.compositionBase) - c) + r.value : r.value = c + r.value;
620
+ s > 0 ? r.value = c + s * (We(e, i, n, t.compositionBase) - c) + r.value : r.value = c + r.value;
533
621
  }
534
622
  }
535
623
  }
536
- function Ee(e, t, n) {
624
+ function Ue(e, t, n) {
537
625
  let r = Array(n).fill(0);
538
626
  if (e == null || e.style == null) return r;
539
627
  let i = t.split(".").pop() ?? t, a = e.style.getPropertyValue(i) || e.style[i] || "";
@@ -546,11 +634,11 @@ function Ee(e, t, n) {
546
634
  }
547
635
  return r;
548
636
  }
549
- function De(e, t, n, r) {
637
+ function We(e, t, n, r) {
550
638
  let i = e.interpVars[t]?.[n]?.stop;
551
- return i instanceof _ && typeof i.value == "number" ? i.value : r.get(t)?.[n] ?? 0;
639
+ return i instanceof m && typeof i.value == "number" ? i.value : r.get(t)?.[n] ?? 0;
552
640
  }
553
- function Oe(e, t, n) {
641
+ function Ge(e, t, n) {
554
642
  n.compositionFallbackSeen.has(e) || (n.compositionFallbackSeen.add(e), n.diagnostics.push({
555
643
  code: "COMPOSITION_FALLBACK",
556
644
  message: `animation-composition: ${t} on a non-numeric leaf "${e}" has no faithful numeric add — composited as \`replace\` (the lerped value), never a wrong sum`,
@@ -558,8 +646,20 @@ function Oe(e, t, n) {
558
646
  }));
559
647
  }
560
648
  //#endregion
561
- //#region src/animation/frame-compiler.ts
562
- var J = (e, n) => {
649
+ //#region src/animation/frame-compiler-numeric.ts
650
+ var Ke = (e) => typeof e.start.value == "number" && typeof e.stop.value == "number" && e.computed !== !0 && e.value.unit !== "color" && e._colorPlan == null, qe = (e) => {
651
+ let t = [], n = [];
652
+ for (let r of e) Ke(r) ? t.push(r) : n.push(r);
653
+ let r = t.length, i = new Float64Array(r), a = new Float64Array(r);
654
+ for (let e = 0; e < r; e++) i[e] = t[e].start.value, a[e] = t[e].stop.value;
655
+ return {
656
+ numeric: t,
657
+ from: i,
658
+ to: a,
659
+ out: new Float64Array(r),
660
+ boxed: n
661
+ };
662
+ }, U = (e, n) => {
563
663
  if (typeof n == "function") return { fn: n };
564
664
  if (typeof n == "object") {
565
665
  if (typeof n.fn == "function") return n;
@@ -572,7 +672,31 @@ var J = (e, n) => {
572
672
  fn: r,
573
673
  css: a
574
674
  } : { fn: r };
575
- }, ke = 1e6, Ae = /^(?:from|to)$/i, je = /^(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?%$/, Me = /^(?:entry|exit|cover|contain)(?:\s+\d+(?:\.\d+)?%)?$/i, Ne = "named-selector", Y = "a keyframe selector must be a percentage 0%–100% (e.g. \"0%\", \"50%\"), the keyword 'from'/'to', or a scroll-range named selector (entry/exit/cover/contain, optionally with a range fraction like 'entry 0%')", Pe = class {
675
+ }, Je = 1e6, Ye = /^(?:from|to)$/i, Xe = /^(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?%$/, Ze = /^(?:entry|exit|cover|contain)(?:\s+\d+(?:\.\d+)?%)?$/i, W = "named-selector", Qe = /^(entry|exit|cover|contain)(?:\s+(\d+(?:\.\d+)?)%)?$/i, $e = {
676
+ entry: {
677
+ start: 0,
678
+ end: .25
679
+ },
680
+ cover: {
681
+ start: .25,
682
+ end: .75
683
+ },
684
+ contain: {
685
+ start: .375,
686
+ end: .625
687
+ },
688
+ exit: {
689
+ start: .75,
690
+ end: 1
691
+ }
692
+ }, et = (e) => {
693
+ let n = Qe.exec(e.trim());
694
+ if (n === null) throw new t("start", e, "not a conforming scroll-range named selector (entry/exit/cover/contain, optionally with a range fraction like 'entry 50%')", "NAMED_SELECTOR_NO_TIMELINE");
695
+ let r = $e[n[1].toLowerCase()], i = n[2];
696
+ if (i === void 0) return r.start;
697
+ let a = Number.parseFloat(i) / 100;
698
+ return r.start + a * (r.end - r.start);
699
+ }, G = "a keyframe selector must be a percentage 0%–100% (e.g. \"0%\", \"50%\"), the keyword 'from'/'to', or a scroll-range named selector (entry/exit/cover/contain, optionally with a range fraction like 'entry 0%')", tt = class {
576
700
  _options;
577
701
  templateFrames = [];
578
702
  parsedVars = [];
@@ -585,21 +709,21 @@ var J = (e, n) => {
585
709
  return this._options;
586
710
  }
587
711
  addFrame(e, n, r, i, a) {
588
- typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof _ && (e = String(e));
712
+ typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof m && (e = String(e));
589
713
  let o = e.trim();
590
- if (o === "") throw new t("start", e, `${Y} — got an empty/blank string`, "EMPTY_PARSE");
714
+ if (o === "") throw new t("start", e, `${G} — got an empty/blank string`, "EMPTY_PARSE");
591
715
  let s;
592
- if (Me.test(o)) s = new _(o, void 0, [Ne]);
716
+ if (Ze.test(o)) s = new m(o, void 0, [W]);
593
717
  else {
594
- if (!Ae.test(o) && !(je.test(o) && parseFloat(o) <= 100)) throw new t("start", e, `${Y} — got ${JSON.stringify(e)}`);
595
- s = x(o);
718
+ if (!Ye.test(o) && !(Xe.test(o) && parseFloat(o) <= 100)) throw new t("start", e, `${G} — got ${JSON.stringify(e)}`);
719
+ s = _e(o);
596
720
  }
597
721
  let c = {
598
722
  id: this.frameId,
599
723
  start: s,
600
724
  vars: n,
601
725
  transform: r,
602
- timingFunction: i == null ? this.options.timingFunction : J("timingFunction", i),
726
+ timingFunction: i == null ? this.options.timingFunction : U("timingFunction", i),
603
727
  composition: a
604
728
  };
605
729
  this.templateFrames.push(c), this.frameId += 1;
@@ -608,17 +732,17 @@ var J = (e, n) => {
608
732
  let n = this.templateFrames[e], r = this.templateFrames[t], i = {
609
733
  start: e,
610
734
  stop: t
611
- }, a = f(n, r, this.options.duration), o = n.transform;
735
+ }, a = ee(n, r, this.options.duration), o = n.transform;
612
736
  if (o == null) {
613
- let t = C(e, this.templateFrames, (e) => e.transform != null);
614
- o = (t === void 0 ? void 0 : this.templateFrames[t].transform) ?? L;
737
+ let t = _(e, this.templateFrames, (e) => e.transform != null);
738
+ o = (t === void 0 ? void 0 : this.templateFrames[t].transform) ?? N;
615
739
  }
616
740
  let s = n.timingFunction;
617
741
  if (s == null) {
618
- let t = C(e, this.templateFrames, (e) => e.timingFunction != null);
742
+ let t = _(e, this.templateFrames, (e) => e.timingFunction != null);
619
743
  s = (t === void 0 ? void 0 : this.templateFrames[t].timingFunction) ?? this.options.timingFunction;
620
744
  }
621
- let c = e * ke + t, l = r.composition;
745
+ let c = e * Je + t, l = r.composition;
622
746
  return {
623
747
  id: c,
624
748
  ixs: i,
@@ -668,7 +792,7 @@ var J = (e, n) => {
668
792
  this.frames.forEach((e, n) => this.reconcileVars(n, t)), this.frames.sort((e, t) => e.time.start === t.time.start ? e.time.stop - t.time.stop : e.time.start - t.time.start), this.frames = this.frames.filter((e) => e.interpVars != null && Object.keys(e.interpVars).length > 0), this.frames.forEach((e) => this.finalizeFrameVars(e));
669
793
  }
670
794
  finalizeFrameVars(e) {
671
- e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars = fe(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat();
795
+ e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars = be(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat(), e._numericPlan = qe(e.allInterpVars);
672
796
  }
673
797
  renormalizeColors() {
674
798
  for (let e of this.frames) {
@@ -676,72 +800,72 @@ var J = (e, n) => {
676
800
  this.finalizeFrameVars(e);
677
801
  }
678
802
  }
679
- }, X = (e) => {
803
+ }, K = (e) => {
680
804
  try {
681
- let t = le(e);
805
+ let t = ge(e);
682
806
  return Number.isFinite(t) ? t : void 0;
683
807
  } catch {
684
808
  return;
685
809
  }
686
810
  };
687
- function Fe(e) {
688
- return e == null ? R.timingFunction : J("timingFunction", e);
811
+ function nt(e) {
812
+ return e == null ? P.timingFunction : U("timingFunction", e);
689
813
  }
690
- function Ie(t) {
691
- return t == null ? R.iterationCount : t === "infinite" || t === "∞" || t === "Infinity" || t === Infinity ? Infinity : e("iterationCount", t, (e) => {
814
+ function rt(t) {
815
+ return t == null ? P.iterationCount : t === "infinite" || t === "∞" || t === "Infinity" || t === Infinity ? Infinity : e("iterationCount", t, (e) => {
692
816
  let t = typeof e == "string" ? Number.parseFloat(e.trim()) : e;
693
817
  return typeof t == "number" && !Number.isNaN(t) && t >= 0 ? t : void 0;
694
818
  }, "expected a non-negative count, \"infinite\", or Infinity");
695
819
  }
696
- function Le(t) {
820
+ function it(t) {
697
821
  if (t != null) return e("duration", t, (e) => {
698
- let t = typeof e == "string" ? X(e) : e;
822
+ let t = typeof e == "string" ? K(e) : e;
699
823
  return typeof t == "number" && isFinite(t) && t > 0 ? t : void 0;
700
824
  }, "expected a positive duration in milliseconds or a CSS time string");
701
825
  }
702
- function Re(t) {
703
- return t == null ? R.delay : e("delay", t, (e) => {
704
- let t = typeof e == "string" ? X(e) : e;
826
+ function at(t) {
827
+ return t == null ? P.delay : e("delay", t, (e) => {
828
+ let t = typeof e == "string" ? K(e) : e;
705
829
  return typeof t == "number" && isFinite(t) ? t : void 0;
706
830
  }, "expected a delay in milliseconds or a CSS time string");
707
831
  }
708
- function ze(e) {
709
- if (e == null) return R.direction;
710
- if (!N.includes(e)) throw new t("direction", e, `expected one of: ${N.join(", ")}`);
832
+ function ot(e) {
833
+ if (e == null) return P.direction;
834
+ if (!k.includes(e)) throw new t("direction", e, `expected one of: ${k.join(", ")}`);
711
835
  return e;
712
836
  }
713
- function Be(e) {
714
- if (e == null) return R.fillMode;
715
- if (!P.includes(e)) throw new t("fillMode", e, `expected one of: ${P.join(", ")}`);
837
+ function st(e) {
838
+ if (e == null) return P.fillMode;
839
+ if (!A.includes(e)) throw new t("fillMode", e, `expected one of: ${A.join(", ")}`);
716
840
  return e;
717
841
  }
718
- function Z(e, n) {
719
- if (n == null) return R[e];
842
+ function q(e, n) {
843
+ if (n == null) return P[e];
720
844
  if (typeof n != "boolean") throw new t(e, n, "expected a boolean");
721
845
  return n;
722
846
  }
723
- function Ve(e) {
724
- if (e == null) return R.colorSpace;
725
- if (!F.includes(e)) throw new t("colorSpace", e, `expected one of: ${F.join(", ")}`);
847
+ function ct(e) {
848
+ if (e == null) return P.colorSpace;
849
+ if (!j.includes(e)) throw new t("colorSpace", e, `expected one of: ${j.join(", ")}`);
726
850
  return e;
727
851
  }
728
- function He(e) {
852
+ function lt(e) {
729
853
  if (e != null) {
730
- if (!I.includes(e)) throw new t("hueMethod", e, `expected one of: ${I.join(", ")}`);
854
+ if (!M.includes(e)) throw new t("hueMethod", e, `expected one of: ${M.join(", ")}`);
731
855
  return e;
732
856
  }
733
857
  }
734
858
  //#endregion
735
859
  //#region src/animation/engine-css-metadata.ts
736
- function Ue(e) {
860
+ function ut(e) {
737
861
  let t = {};
738
862
  return e.duration != null && (t.duration = e.duration), e.timingFunction != null && (t.timingFunction = e.timingFunction), e.iterationCount !== void 0 && (t.iterationCount = e.iterationCount === null ? Infinity : e.iterationCount), e.direction != null && (t.direction = e.direction), e.delay != null && (t.delay = e.delay), e.fillMode != null && (t.fillMode = e.fillMode), e.composition != null && (t.composite = e.composition), t;
739
863
  }
740
- function We(e) {
741
- let t = oe(e);
864
+ function dt(e) {
865
+ let t = de(e);
742
866
  return Object.keys(t).length > 0 ? t : void 0;
743
867
  }
744
- function Ge(e) {
868
+ function ft(e) {
745
869
  if (!(typeof CSS > "u" || typeof CSS.registerProperty != "function")) for (let [t, n] of e) {
746
870
  if (n.syntax == null) continue;
747
871
  let e = {
@@ -756,9 +880,105 @@ function Ge(e) {
756
880
  }
757
881
  }
758
882
  //#endregion
883
+ //#region src/animation/engine-playback.ts
884
+ function J(e) {
885
+ if (e.reversed = !1, (e.options.direction === "reverse" || e.options.direction === "alternate-reverse" && e.iteration % 2 == 0 || e.options.direction === "alternate" && e.iteration % 2 == 1) && e.reverse(), (e.options.fillMode === "backwards" || e.options.fillMode === "both") && e.fillBackwards(), e.options.delay > 0) return e.paused = !0, ye(e.options.delay).then(() => {
886
+ e.paused = !1, e.started = !0;
887
+ });
888
+ e.started = !0;
889
+ }
890
+ function pt(e) {
891
+ e.paintRest(), e.startTime = void 0, e.iteration >= e.options.iterationCount - 1 ? (e.done = !0, e.iteration = 0, e.dispatchAnimationEvent("animationend")) : (e.iteration += 1, e.dispatchAnimationEvent("animationiteration"));
892
+ }
893
+ function mt(e, t) {
894
+ if (e.startTime === void 0) {
895
+ let n = J(e), r = () => (e.startTime = t + e.options.delay, e.dispatchAnimationEvent("animationstart"), ht(e, t));
896
+ return n ? n.then(r) : r();
897
+ }
898
+ return ht(e, t);
899
+ }
900
+ function ht(e, t) {
901
+ if (e.paused && e.pausedTime === 0) return e.pausedTime = t, e.t;
902
+ if (e.pausedTime > 0 && !e.paused) {
903
+ let n = t - e.pausedTime;
904
+ e.startTime += n, e.pausedTime = 0;
905
+ }
906
+ return e.t = t - e.startTime, e.t >= e.options.duration && (pt(e), e.t = e.options.duration), e.t;
907
+ }
908
+ function gt(e, t) {
909
+ if (r(e.options.respectReducedMotion, () => !0, () => !1)) return xt(e), !1;
910
+ let n = e.advanceTo(t);
911
+ return typeof n == "number" ? _t(e, n) : n.then((t) => _t(e, t));
912
+ }
913
+ function _t(e, t) {
914
+ return e.paused ? !1 : e.done ? (Z(e), Y(e), !1) : (e.interpFrames(t, !0, e._interpOut), !0);
915
+ }
916
+ function Y(e) {
917
+ let t = e.resolvePromise;
918
+ e.resolvePromise = null, t?.();
919
+ }
920
+ function vt(e) {
921
+ return new Promise((t) => {
922
+ e.resolvePromise = t, e.playback.loop(e._boundFrame);
923
+ });
924
+ }
925
+ async function yt(e) {
926
+ await ne(e), Z(e);
927
+ }
928
+ function X(e) {
929
+ if (e._waAnimations.length !== 0) {
930
+ for (let t of e._waAnimations) try {
931
+ t.cancel();
932
+ } catch {}
933
+ e._waAnimations = [];
934
+ }
935
+ }
936
+ async function bt(e) {
937
+ e.started = !0, e.dispatchAnimationEvent("animationstart"), e.fillForwards(), e.iteration = 0, e.done = !0, e.dispatchAnimationEvent("animationend"), Z(e);
938
+ }
939
+ function xt(e) {
940
+ X(e), e.fillForwards(), e.iteration = 0, e.done = !0, e.dispatchAnimationEvent("animationend"), Z(e), Y(e);
941
+ }
942
+ async function St(e) {
943
+ if (e.managed) throw Error("Animation.play() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play() instead.");
944
+ if (e.assertNoUnresolvedNamedSelector(), e._playingPromise) return e._playingPromise;
945
+ let t = r(e.options.respectReducedMotion, () => (e.waapiIneligibleReason = void 0, bt(e)), () => {
946
+ if (e.options.useWAAPI) {
947
+ let t = te(e);
948
+ return t.eligible ? (e.waapiIneligibleReason = void 0, yt(e)) : (e.waapiIneligibleReason = t.reason, vt(e));
949
+ }
950
+ return e.waapiIneligibleReason = void 0, vt(e);
951
+ });
952
+ return e._playingPromise = t, t.finally(() => {
953
+ e._playingPromise = null;
954
+ }), t;
955
+ }
956
+ function Ct(e) {
957
+ e.started && (e.paused = !0);
958
+ }
959
+ function wt(e) {
960
+ if (e.started && e.paused) if (e.paused = !1, e._waAnimations.length > 0) for (let t of e._waAnimations) t.play();
961
+ else e.playback.running || e.playback.loop(e._boundFrame);
962
+ }
963
+ function Tt(e) {
964
+ X(e), e.playback.stop(), Z(e), Y(e);
965
+ }
966
+ function Et(e) {
967
+ return !(!e.started || e.paused);
968
+ }
969
+ function Dt(e) {
970
+ return e.reversed ? e.options.duration - e.t : e.t;
971
+ }
972
+ function Z(e) {
973
+ e.done = !1, e.started = !1, e.paused = !1, e.reversed = !1, e.iteration = 0, e.startTime = void 0, e.pausedTime = 0, e.t = 0;
974
+ }
975
+ function Ot(e) {
976
+ X(e), e.started && e.frames.length > 0 && e.fillBackwards(), Z(e);
977
+ }
978
+ //#endregion
759
979
  //#region src/animation/engine.ts
760
- var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", Q = (e) => typeof e == "string" ? e : e.name ?? String(e.id), qe = 0, $ = class {
761
- id = qe++;
980
+ var kt = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", Q = (e) => typeof e == "string" ? e : e.name ?? String(e.id), At = 0, $ = class {
981
+ id = At++;
762
982
  name;
763
983
  superKey;
764
984
  targets;
@@ -804,8 +1024,8 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
804
1024
  }));
805
1025
  }
806
1026
  constructor(e, t, n, r) {
807
- this.options = {}, this._compiler = new Pe(this.options), this._ctorOptions = e ?? {}, this.setOptions({
808
- ...R,
1027
+ this.options = {}, this._compiler = new tt(this.options), this._ctorOptions = e ?? {}, this.setOptions({
1028
+ ...P,
809
1029
  ...this._ctorOptions
810
1030
  }), this.targets = t == null ? [] : Array.isArray(t) ? t : [t], this.name = n, this.superKey = r;
811
1031
  }
@@ -831,7 +1051,7 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
831
1051
  return this.compiler.parse(this.targets), this.computeStableKeys(), this.computeHasComposition(), this;
832
1052
  }
833
1053
  computeHasComposition() {
834
- this._hasComposition = q(this.frames), we(this._compositionBase, this._compositionFallbackSeen);
1054
+ this._hasComposition = Be(this.frames), Ve(this._compositionBase, this._compositionFallbackSeen);
835
1055
  }
836
1056
  adoptCompiled(e) {
837
1057
  return this._compiler = e.compiler, this.options = this.compiler.options, this.unflatten = e.unflatten, this.computeStableKeys(), this.computeHasComposition(), this;
@@ -842,13 +1062,13 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
842
1062
  this._stableKeys = [...e];
843
1063
  }
844
1064
  setTimingFunction(e) {
845
- return this.options.timingFunction = Fe(e), this;
1065
+ return this.options.timingFunction = nt(e), this;
846
1066
  }
847
1067
  setIterationCount(e) {
848
- return this.options.iterationCount = Ie(e), this;
1068
+ return this.options.iterationCount = rt(e), this;
849
1069
  }
850
1070
  setDuration(e) {
851
- let t = Le(e);
1071
+ let t = it(e);
852
1072
  if (t === void 0) return this;
853
1073
  let n = t / this.options.duration;
854
1074
  for (let e = 0; e < this.frames.length; e++) {
@@ -858,25 +1078,25 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
858
1078
  return this.options.duration = t, this;
859
1079
  }
860
1080
  setDelay(e) {
861
- return this.options.delay = Re(e), this;
1081
+ return this.options.delay = at(e), this;
862
1082
  }
863
1083
  setDirection(e) {
864
- return this.options.direction = ze(e), this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && (this.reversed = !0), this;
1084
+ return this.options.direction = ot(e), this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && (this.reversed = !0), this;
865
1085
  }
866
1086
  setFillMode(e) {
867
- return this.options.fillMode = Be(e), this;
1087
+ return this.options.fillMode = st(e), this;
868
1088
  }
869
1089
  setUseWAAPI(e) {
870
- return this.options.useWAAPI = Z("useWAAPI", e), this;
1090
+ return this.options.useWAAPI = q("useWAAPI", e), this;
871
1091
  }
872
1092
  setRespectReducedMotion(e) {
873
- return this.options.respectReducedMotion = Z("respectReducedMotion", e), this;
1093
+ return this.options.respectReducedMotion = q("respectReducedMotion", e), this;
874
1094
  }
875
1095
  setColorSpace(e) {
876
- return this.options.colorSpace = Ve(e), this.frames.length > 0 && this.compiler.renormalizeColors(), this;
1096
+ return this.options.colorSpace = ct(e), this.frames.length > 0 && this.compiler.renormalizeColors(), this;
877
1097
  }
878
1098
  setHueMethod(e) {
879
- let t = He(e);
1099
+ let t = lt(e);
880
1100
  return t === void 0 ? this : (this.options.hueMethod = t, this.frames.length > 0 && this.compiler.renormalizeColors(), this);
881
1101
  }
882
1102
  setComposite(e) {
@@ -904,10 +1124,18 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
904
1124
  paintRest() {
905
1125
  this.restPosition === "final" ? this.fillForwards() : this.fillBackwards();
906
1126
  }
1127
+ assertNoUnresolvedNamedSelector() {
1128
+ let e = this.compiler.templateFrames.find((e) => e.start.superType?.includes(W));
1129
+ if (e != null) {
1130
+ let n = String(e.start.value);
1131
+ throw new t("start", n, `named scroll-range selector ("${n}") requires a ScrollTimeline or ManualTimeline — call bindTimeline(timeline) before play() to resolve the named phase to a numeric position`, "NAMED_SELECTOR_NO_TIMELINE");
1132
+ }
1133
+ }
907
1134
  at(e, t = !1) {
1135
+ this.assertNoUnresolvedNamedSelector();
908
1136
  let n = this.reversed;
909
1137
  this.reversed = !1;
910
- let r = v(e, 0, 1) * this.options.duration, i = this.interpFrames(r, t);
1138
+ let r = ie(e, 0, 1) * this.options.duration, i = this.interpFrames(r, t);
911
1139
  return this.reversed = n, i;
912
1140
  }
913
1141
  interpFrames(e, t = !1, n) {
@@ -940,12 +1168,17 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
940
1168
  for (let n = 0; n < t.length; n++) e[t[n]] = void 0;
941
1169
  }
942
1170
  processFrame(e, t, n) {
943
- let { start: r, stop: i } = e.time, a = r === i ? 1 : S(t, r, i, 0, 1), o = e.timingFunction.fn(a);
944
- for (let t of e.allInterpVars) ce(o, t);
1171
+ let { start: r, stop: i } = e.time, a = r === i ? 1 : ve(t, r, i, 0, 1), o = e.timingFunction.fn(a), s = e._numericPlan;
1172
+ if (s !== void 0 && s.numeric.length > 0) {
1173
+ let { numeric: e, from: t, to: n, out: r } = s;
1174
+ me(t, n, o, r);
1175
+ for (let t = 0; t < e.length; t++) e[t].value.value = r[t];
1176
+ for (let e of s.boxed) he(o, e);
1177
+ } else for (let t of e.allInterpVars) he(o, t);
945
1178
  n && this._hasComposition && e.composition != null && this.applyComposition(e), n && e.transform(this.unflatten ? e.vars : e.flatVars, t);
946
1179
  }
947
1180
  applyComposition(e) {
948
- Te(e, {
1181
+ He(e, {
949
1182
  iteration: this.iteration,
950
1183
  target: this.targets[0],
951
1184
  compositionBase: this._compositionBase,
@@ -954,108 +1187,52 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
954
1187
  });
955
1188
  }
956
1189
  onStart() {
957
- if (this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && this.reverse(), (this.options.fillMode === "backwards" || this.options.fillMode === "both") && this.fillBackwards(), this.options.delay > 0) return this.paused = !0, de(this.options.delay).then(() => {
958
- this.paused = !1, this.started = !0;
959
- });
960
- this.started = !0;
1190
+ return J(this._host);
961
1191
  }
962
1192
  onEnd() {
963
- this.paintRest(), this.startTime = void 0, this.iteration >= this.options.iterationCount - 1 ? (this.done = !0, this.iteration = 0, this.dispatchAnimationEvent("animationend")) : (this.iteration += 1, this.dispatchAnimationEvent("animationiteration"));
1193
+ pt(this._host);
964
1194
  }
965
1195
  advanceTo(e) {
966
- if (this.startTime === void 0) {
967
- let t = this.onStart(), n = () => (this.startTime = e + this.options.delay, this.dispatchAnimationEvent("animationstart"), this._advance(e));
968
- return t ? t.then(n) : n();
969
- }
970
- return this._advance(e);
1196
+ return mt(this._host, e);
971
1197
  }
972
- _advance(e) {
973
- if (this.paused && this.pausedTime === 0) return this.pausedTime = e, this.t;
974
- if (this.pausedTime > 0 && !this.paused) {
975
- let t = e - this.pausedTime;
976
- this.startTime += t, this.pausedTime = 0;
977
- }
978
- return this.t = e - this.startTime, this.t >= this.options.duration && (this.onEnd(), this.t = this.options.duration), this.t;
1198
+ get _host() {
1199
+ return this;
979
1200
  }
980
1201
  _frame(e) {
981
- if (r(this.options.respectReducedMotion, () => !0, () => !1)) return this._snapToReducedMotion(), !1;
982
- let t = this.advanceTo(e);
983
- return typeof t == "number" ? this._renderFrame(t) : t.then((e) => this._renderFrame(e));
984
- }
985
- _renderFrame(e) {
986
- return this.paused ? !1 : this.done ? (this.settle(), this._resolvePlay(), !1) : (this.interpFrames(e, !0, this._interpOut), !0);
987
- }
988
- _resolvePlay() {
989
- let e = this.resolvePromise;
990
- this.resolvePromise = null, e?.();
991
- }
992
- _playRAF() {
993
- return new Promise((e) => {
994
- this.resolvePromise = e, this.playback.loop(this._boundFrame);
995
- });
996
- }
997
- async _playWAAPI() {
998
- await m(this), this.settle();
999
- }
1000
- _cancelWAAPI() {
1001
- if (this._waAnimations.length !== 0) {
1002
- for (let e of this._waAnimations) try {
1003
- e.cancel();
1004
- } catch {}
1005
- this._waAnimations = [];
1006
- }
1007
- }
1008
- async _playReducedMotion() {
1009
- this.started = !0, this.dispatchAnimationEvent("animationstart"), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle();
1010
- }
1011
- _snapToReducedMotion() {
1012
- this._cancelWAAPI(), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle(), this._resolvePlay();
1202
+ return gt(this._host, e);
1013
1203
  }
1014
1204
  get finished() {
1015
1205
  return this._playingPromise ?? Promise.resolve();
1016
1206
  }
1017
1207
  async play() {
1018
- if (this.managed) throw Error("Animation.play() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play() instead.");
1019
- if (this._playingPromise) return this._playingPromise;
1020
- let e = r(this.options.respectReducedMotion, () => (this.waapiIneligibleReason = void 0, this._playReducedMotion()), () => {
1021
- if (this.options.useWAAPI) {
1022
- let e = p(this);
1023
- return e.eligible ? (this.waapiIneligibleReason = void 0, this._playWAAPI()) : (this.waapiIneligibleReason = e.reason, this._playRAF());
1024
- }
1025
- return this.waapiIneligibleReason = void 0, this._playRAF();
1026
- });
1027
- return this._playingPromise = e, e.finally(() => {
1028
- this._playingPromise = null;
1029
- }), e;
1208
+ return St(this._host);
1030
1209
  }
1031
1210
  pause() {
1032
- return this.started && (this.paused = !0), this;
1211
+ return Ct(this._host), this;
1033
1212
  }
1034
1213
  resume() {
1035
- if (this.started && this.paused) if (this.paused = !1, this._waAnimations.length > 0) for (let e of this._waAnimations) e.play();
1036
- else this.playback.running || this.playback.loop(this._boundFrame);
1037
- return this;
1214
+ return wt(this._host), this;
1038
1215
  }
1039
1216
  toggle() {
1040
1217
  return this.paused ? this.resume() : this.pause();
1041
1218
  }
1042
1219
  stop() {
1043
- this._cancelWAAPI(), this.playback.stop(), this.settle(), this._resolvePlay();
1220
+ Tt(this._host);
1044
1221
  }
1045
1222
  playing() {
1046
- return !(!this.started || this.paused);
1223
+ return Et(this._host);
1047
1224
  }
1048
1225
  get effectiveT() {
1049
- return this.reversed ? this.options.duration - this.t : this.t;
1226
+ return Dt(this._host);
1050
1227
  }
1051
1228
  settle() {
1052
- return this.done = !1, this.started = !1, this.paused = !1, this.reversed = !1, this.iteration = 0, this.startTime = void 0, this.pausedTime = 0, this.t = 0, this;
1229
+ return Z(this._host), this;
1053
1230
  }
1054
1231
  reset() {
1055
- return this._cancelWAAPI(), this.started && this.frames.length > 0 && this.fillBackwards(), this.settle();
1232
+ return Ot(this._host), this;
1056
1233
  }
1057
1234
  setTargets(...e) {
1058
- return this.targets = e, this.frames.forEach((e) => {
1235
+ return this.targets = e, this._resolveElementAwareValues() || this.frames.forEach((e) => {
1059
1236
  Object.values(e.interpVars).forEach((e) => {
1060
1237
  e.forEach(({ start: e, stop: t, value: n }) => {
1061
1238
  e.setTargets(this.targets), t.setTargets(this.targets), n.setTargets(this.targets);
@@ -1063,13 +1240,63 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
1063
1240
  });
1064
1241
  }), this;
1065
1242
  }
1243
+ _resolveElementAwareValues() {
1244
+ let e = this.compiler.templateFrames, t = !1;
1245
+ for (let n of e) {
1246
+ let e = n.vars;
1247
+ for (let n in e) if (E(e[n])) {
1248
+ t = !0;
1249
+ break;
1250
+ }
1251
+ if (t) break;
1252
+ }
1253
+ if (!t) return !1;
1254
+ let n = this._buildElementAwareEnv();
1255
+ if (n === void 0) return !1;
1256
+ let r = v(/* @__PURE__ */ new Map(), n), i = !1;
1257
+ for (let t of e) {
1258
+ let e = t.vars;
1259
+ for (let t in e) {
1260
+ let n = e[t];
1261
+ if (!(n instanceof p) || !E(n)) continue;
1262
+ let a = w(n, r);
1263
+ if (a === y) {
1264
+ delete e[t], i = !0;
1265
+ continue;
1266
+ }
1267
+ a !== n && (e[t] = a, i = !0);
1268
+ }
1269
+ }
1270
+ return i ? (this.parse(), !0) : !1;
1271
+ }
1272
+ _buildElementAwareEnv() {
1273
+ let e = this.targets[0];
1274
+ if (e == null) return;
1275
+ let t = { customProps: (t) => {
1276
+ let n = "";
1277
+ if (typeof getComputedStyle == "function") try {
1278
+ n = getComputedStyle(e).getPropertyValue(t).trim();
1279
+ } catch {
1280
+ n = "";
1281
+ }
1282
+ return n === "" && (n = e.style.getPropertyValue(t).trim()), n === "" ? void 0 : n;
1283
+ } }, n = e.parentElement;
1284
+ return n != null && (t.siblingIndex = () => Array.prototype.indexOf.call(n.children, e) + 1, t.siblingCount = () => n.children.length), t;
1285
+ }
1066
1286
  group(...e) {
1067
- return new K(this, ...e);
1287
+ return new H(this, ...e);
1068
1288
  }
1069
- }, Je = class extends $ {
1289
+ }, jt = class extends $ {
1290
+ _boundTimeline;
1070
1291
  constructor(e, ...t) {
1071
1292
  super(e, t), this.unflatten = !1;
1072
1293
  }
1294
+ bindTimeline(e) {
1295
+ this._boundTimeline = e;
1296
+ let t = !1;
1297
+ for (let e of this.compiler.templateFrames) e.start.superType?.includes("named-selector") && (e.start = new m(et(String(e.start.value)) * 100, "%"), t = !0);
1298
+ return t && this.compiler.frames.length > 0 && this.parse(), this;
1299
+ }
1073
1300
  resolveTransform(e) {
1074
1301
  return this.unflatten = e != null, e ?? this._defaultTransform;
1075
1302
  }
@@ -1082,7 +1309,7 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
1082
1309
  return this.parse(), this;
1083
1310
  }
1084
1311
  fromKeyframes(e, t) {
1085
- t = this.resolveTransform(t), se(e) && (e = new Map(Object.entries(e)));
1312
+ t = this.resolveTransform(t), fe(e) && (e = new Map(Object.entries(e)));
1086
1313
  let n = e instanceof Map ? e.entries() : Object.entries(e);
1087
1314
  for (let [e, r] of n) this.addFrame(e, r, t);
1088
1315
  return this.parse(), this;
@@ -1091,17 +1318,17 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
1091
1318
  scrollOptions;
1092
1319
  fromString(e, t) {
1093
1320
  t = this.resolveTransform(t);
1094
- let n = M(e);
1321
+ let n = O(e);
1095
1322
  this.propertyRegistry = n.properties;
1096
- let r = We(n.stylesheet);
1323
+ let r = dt(n.stylesheet);
1097
1324
  r === void 0 ? delete this.scrollOptions : this.scrollOptions = r, this.diagnostics = [...n.diagnostics];
1098
- let a = Ue(n.options);
1325
+ let a = ut(n.options);
1099
1326
  Object.keys(a).length > 0 && this.setOptions({
1100
1327
  ...a,
1101
1328
  ...this._ctorOptions
1102
1329
  });
1103
1330
  for (let [e, r] of n.keyframes.entries()) {
1104
- let a = Object.fromEntries(Object.entries(r).map(([e, t]) => [e, Ke(t) ? t.clone() : t])), o = n.timingFunctions.get(e), s = o ? d(o) : void 0, c;
1331
+ let a = Object.fromEntries(Object.entries(r).map(([e, t]) => [e, kt(t) ? t.clone() : t])), o = n.timingFunctions.get(e), s = o ? d(o) : void 0, c;
1105
1332
  if (s) {
1106
1333
  let e = o ? i(o) : void 0;
1107
1334
  c = e ? {
@@ -1112,11 +1339,11 @@ var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function",
1112
1339
  let l = n.composition.get(e);
1113
1340
  this.addFrame(e, a, t, c, l);
1114
1341
  }
1115
- return this.parse(), Ge(this.propertyRegistry), this;
1342
+ return this.parse(), ft(this.propertyRegistry), this;
1116
1343
  }
1117
1344
  transform(e) {
1118
1345
  c(e, this.targets);
1119
1346
  }
1120
1347
  };
1121
1348
  //#endregion
1122
- export { $ as Animation, $ as KeyframesAnimation, K as AnimationGroup, Je as CSSKeyframesAnimation, N as DIRECTIONS, P as FILL_MODES, z as defaultLayerConfig, R as defaultOptions, Q as getAnimationId, d as getTimingFunction, M as resolveKeyframes };
1349
+ export { H as AnimationGroup, jt as CSSKeyframesAnimation, k as DIRECTIONS, A as FILL_MODES, $ as KeyframesAnimation, F as defaultLayerConfig, P as defaultOptions, Q as getAnimationId, d as getTimingFunction, O as resolveKeyframes };