@mkbabb/keyframes.js 4.1.0 → 4.2.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
- import { _ as e, c as t, d as n, f as r, h as i, o as a, s as o } from "./timeline-BHz0o8dZ.js";
2
- import { COLOR_SPACE_RANGES as s, COMPUTED_UNITS as c, CSSCubicBezier as l, CSSFunction as u, CSSValues as d, FunctionValue as f, ValueArray as p, ValueUnit as m, clamp as h, convertToMs as g, cssLinear as _, easeInOutCubic as v, extractAnimationOptions as y, extractKeyframes as ee, extractProperties as te, flattenObject as b, isObject as ne, jumpTerms as re, lerp as ie, lerpValue as ae, normalizeValueUnits as oe, parseCSSStylesheet as x, parseCSSTime as S, parseCSSValueUnit as se, prepareInterpVar as ce, scale as le, seekPreviousValue as C, sleep as w, steppedEase as T, timingFunctions as E, tryParse as ue, unflattenObject as de, unflattenObjectToString as D } from "@mkbabb/value.js";
3
- import { any as fe } from "@mkbabb/parse-that";
1
+ import { _ as e, c as t, d as n, f as r, h as i, o as a, s as o } from "./timeline-CPT7qUV1.js";
2
+ import { COLOR_SPACE_RANGES as s, COMPUTED_UNITS as c, CSSCubicBezier as l, CSSFunction as u, CSSValues as d, FunctionValue as f, ValueArray as p, ValueUnit as m, clamp as h, cssLinear as ee, easeInOutCubic as te, extractAnimationOptions as ne, extractKeyframes as re, extractProperties as ie, flattenObject as g, isObject as ae, jumpTerms as _, lerp as v, lerpValue as oe, normalizeValueUnits as se, parseCSSStylesheet as y, parseCSSTime as ce, parseCSSValueUnit as le, prepareInterpVar as ue, scale as b, seekPreviousValue as x, sleep as S, steppedEase as C, timingFunctions as w, tryParse as de, unflattenObject as fe, unflattenObjectToString as T } from "@mkbabb/value.js";
3
+ import { any as pe } from "@mkbabb/parse-that";
4
4
  //#region src/animation/adapter.ts
5
- var pe = (e) => {
5
+ var me = (e) => {
6
6
  let t = {};
7
7
  for (let n of e.declarations) t[n.name] = n.value;
8
8
  return t;
9
- }, me = (e) => {
9
+ }, he = (e) => {
10
10
  let t = [];
11
11
  for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
12
12
  return t;
13
- }, O = (e) => {
14
- let t = ee(e);
13
+ }, E = (e) => {
14
+ let t = re(e);
15
15
  for (let e of t.values()) if (e.length > 0) return e;
16
16
  return [];
17
- }, k = (e) => {
18
- let t = typeof e == "string" ? x(e) : e, n = O(t);
19
- typeof e == "string" && n.length === 0 && e.trim() && (t = x(`@keyframes anonymous {\n${e.trim()}\n}`), n = O(t));
17
+ }, D = (e) => {
18
+ let t = typeof e == "string" ? y(e) : e, n = E(t);
19
+ typeof e == "string" && n.length === 0 && e.trim() && (t = y(`@keyframes anonymous {\n${e.trim()}\n}`), n = E(t));
20
20
  let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
21
21
  for (let e of n) {
22
- let t = pe(e);
23
- for (let n of me(e)) {
22
+ let t = me(e);
23
+ for (let n of he(e)) {
24
24
  let o = r.get(n);
25
25
  r.set(n, {
26
26
  ...o ?? {},
@@ -34,54 +34,54 @@ var pe = (e) => {
34
34
  keyframes: r,
35
35
  timingFunctions: i,
36
36
  composition: a,
37
- properties: te(t),
38
- options: y(t)
37
+ properties: ie(t),
38
+ options: ne(t)
39
39
  };
40
- }, A = [
40
+ }, O = [
41
41
  "normal",
42
42
  "reverse",
43
43
  "alternate",
44
44
  "alternate-reverse"
45
- ], j = [
45
+ ], k = [
46
46
  "none",
47
47
  "forwards",
48
48
  "backwards",
49
49
  "both"
50
- ], M = Object.keys(s), N = [
50
+ ], A = Object.keys(s), j = [
51
51
  "shorter",
52
52
  "longer",
53
53
  "increasing",
54
54
  "decreasing"
55
- ], P = {
55
+ ], M = () => {}, N = {
56
56
  duration: 1e3,
57
57
  delay: 0,
58
58
  iterationCount: 1,
59
59
  direction: "normal",
60
60
  fillMode: "forwards",
61
- timingFunction: { fn: v },
61
+ timingFunction: { fn: te },
62
62
  useWAAPI: !0,
63
63
  respectReducedMotion: !1,
64
64
  colorSpace: "oklab"
65
- }, F = {
65
+ }, P = {
66
66
  zIndex: 0,
67
67
  weight: 1,
68
68
  blendMode: "replace",
69
69
  enabled: !0
70
- }, I = null, L = () => typeof MessageChannel == "function" ? () => new Promise((e) => {
70
+ }, F = null, I = () => typeof MessageChannel == "function" ? () => new Promise((e) => {
71
71
  let t = new MessageChannel();
72
72
  t.port1.onmessage = () => {
73
73
  t.port1.close(), e();
74
74
  }, t.port2.postMessage(void 0);
75
75
  }) : () => new Promise((e) => setTimeout(e, 0));
76
- function R() {
76
+ function L() {
77
77
  let e = globalThis.scheduler;
78
- return e && typeof e.yield == "function" ? e.yield() : (I ??= L(), I());
78
+ return e && typeof e.yield == "function" ? e.yield() : (F ??= I(), F());
79
79
  }
80
80
  //#endregion
81
81
  //#region src/animation/group.ts
82
- var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
82
+ var R = (e) => e instanceof m && typeof e.value == "number", z = class e {
83
83
  animations = {};
84
- transform;
84
+ transform = M;
85
85
  superKey;
86
86
  paused = !1;
87
87
  started = !1;
@@ -104,13 +104,13 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
104
104
  let t = [];
105
105
  for (let n of e) {
106
106
  let e, r;
107
- n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform == null && e.frames[0] != null && (this.transform = e.frames[0].transform);
107
+ n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform === M && e.frames[0] != null && (this.transform = e.frames[0].transform);
108
108
  let i = Q(e);
109
109
  this.animations[i] = {
110
110
  values: {},
111
111
  animation: e,
112
112
  layer: {
113
- ...F,
113
+ ...P,
114
114
  ...r
115
115
  }
116
116
  }, e.managed = !0, t.push(e);
@@ -174,7 +174,7 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
174
174
  let r = t[e];
175
175
  if (Array.isArray(r) && Array.isArray(n)) {
176
176
  let e = Math.min(r.length, n.length);
177
- for (let t = 0; t < e; t++) z(r[t]) && z(n[t]) ? r[t].value += n[t].value : r[t] = n[t];
177
+ for (let t = 0; t < e; t++) R(r[t]) && R(n[t]) ? r[t].value += n[t].value : r[t] = n[t];
178
178
  } else t[e] = n;
179
179
  }
180
180
  break;
@@ -186,7 +186,7 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
186
186
  let i = t[e];
187
187
  if (Array.isArray(i) && Array.isArray(n)) {
188
188
  let e = Math.min(i.length, n.length);
189
- for (let t = 0; t < e; t++) z(i[t]) && z(n[t]) ? i[t].value = ie(i[t].value, n[t].value, r.weight) : i[t] = n[t];
189
+ for (let t = 0; t < e; t++) R(i[t]) && R(n[t]) ? i[t].value = v(i[t].value, n[t].value, r.weight) : i[t] = n[t];
190
190
  } else t[e] = n;
191
191
  }
192
192
  break;
@@ -197,6 +197,13 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
197
197
  let r = n[e];
198
198
  t[r] === void 0 && delete t[r];
199
199
  }
200
+ if (this.transform === M) for (let e of this.getEntries()) {
201
+ let t = e.animation.frames[0];
202
+ if (t != null && t.transform != null) {
203
+ this.transform = t.transform;
204
+ break;
205
+ }
206
+ }
200
207
  return this.transform(t, e), t;
201
208
  }
202
209
  render() {
@@ -210,23 +217,33 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
210
217
  let i = r.animation;
211
218
  return i.t = t, i.startTime !== void 0 && (i.pausedTime = i.startTime + t), this;
212
219
  }
213
- async advanceTo(t) {
220
+ advanceTo(t) {
214
221
  this.lastTickTime = t, this.started || this.onStart();
215
- let n = this.getEntries(), r = e.YIELD_BATCH;
216
- if (n.length <= r) await this._advanceSlice(n, t);
217
- else for (let e = 0; e < n.length; e += r) await this._advanceSlice(n.slice(e, e + r), t), e + r < n.length && await R();
222
+ let n = this.getEntries(), r = e.YIELD_BATCH, i = n.length <= r ? this._advanceSlice(n, t) : this._advanceBatched(n, t, r);
223
+ return i ? i.then(() => this._endAdvance()) : this._endAdvance();
224
+ }
225
+ async _advanceBatched(e, t, n) {
226
+ for (let r = 0; r < e.length; r += n) await this._advanceSlice(e.slice(r, r + n), t), r + n < e.length && await L();
227
+ }
228
+ _endAdvance() {
218
229
  return this.done && this.onEnd(), this;
219
230
  }
220
- async _advanceSlice(e, t) {
221
- let n = [];
231
+ _advanceSlice(e, t) {
232
+ let n;
222
233
  for (let r of e) {
223
234
  let e = r.animation;
224
- (!e.paused || e.pausedTime === 0) && n.push(e.advanceTo(t));
235
+ if (e.paused && e.pausedTime !== 0) continue;
236
+ let i = e.advanceTo(t);
237
+ typeof i != "number" && (n ??= []).push(i);
225
238
  }
226
- await Promise.all(n);
239
+ return n && Promise.all(n).then(() => void 0);
240
+ }
241
+ _frame(e) {
242
+ let t = this.advanceTo(e);
243
+ return typeof t.then == "function" ? t.then(() => this._renderFrame(e)) : this._renderFrame(e);
227
244
  }
228
- async _frame(e) {
229
- if (await this.advanceTo(e), this.paused) return !1;
245
+ _renderFrame(e) {
246
+ if (this.paused) return !1;
230
247
  if (this.singleTarget) this.transformFramesGrouped(e);
231
248
  else {
232
249
  let e = !0;
@@ -317,19 +334,19 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
317
334
  let t = typeof e == "string" ? e : Q(e);
318
335
  return this.animations[t]?.layer;
319
336
  }
320
- }, V = (e) => {
337
+ }, B = (e) => {
321
338
  if (e instanceof m) return [e.clone()];
322
- if (e instanceof f) return e.values.flatMap((e) => V(e));
323
- if (e instanceof p) return e.flatMap((e) => V(e));
339
+ if (e instanceof f) return e.values.flatMap((e) => B(e));
340
+ if (e instanceof p) return e.flatMap((e) => B(e));
324
341
  throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
325
- }, he = (e) => {
342
+ }, ge = (e) => {
326
343
  let t = e.split(".").pop(), n = e.split(".").shift();
327
344
  if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
328
345
  return {
329
346
  mainKey: n,
330
347
  childKey: t
331
348
  };
332
- }, H = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), ge = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, _e = /^\s*steps\s*\(\s*(\d+)\s*(?:,\s*(jump-start|jump-end|jump-none|jump-both|start|end|both)\s*)?\)\s*$/i, U = /^\s*linear\s*\(\s*(.+)\s*\)\s*$/i, ve = (e) => {
349
+ }, V = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), _e = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, ve = /^\s*steps\s*\(\s*(\d+)\s*(?:,\s*(jump-start|jump-end|jump-none|jump-both|start|end|both)\s*)?\)\s*$/i, ye = /^\s*linear\s*\(\s*(.+)\s*\)\s*$/i, H = (e) => {
333
350
  let t = [];
334
351
  for (let n of e.split(",")) {
335
352
  let e = n.trim().split(/\s+/).filter(Boolean);
@@ -351,10 +368,10 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
351
368
  }
352
369
  }
353
370
  return t.length >= 2 ? t : void 0;
354
- }, W = (e) => {
371
+ }, U = (e) => {
355
372
  if (e == null) return;
356
373
  if (typeof e != "string") return e;
357
- let t = e.match(ge);
374
+ let t = e.match(_e);
358
375
  if (t) {
359
376
  let e = t.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
360
377
  if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
@@ -362,35 +379,35 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
362
379
  return l(t, n, r, i);
363
380
  }
364
381
  }
365
- let n = e.match(_e);
382
+ let n = e.match(ve);
366
383
  if (n) {
367
384
  let e = Number.parseInt(n[1], 10), t = n[2]?.toLowerCase() ?? "end";
368
- if (e > 0 && re.includes(t)) return T(e, t);
385
+ if (e > 0 && _.includes(t)) return C(e, t);
369
386
  }
370
- if (e === "step-start") return T(1, "jump-start");
371
- if (e === "step-end") return T(1, "jump-end");
372
- let r = e.match(U);
387
+ if (e === "step-start") return C(1, "jump-start");
388
+ if (e === "step-end") return C(1, "jump-end");
389
+ let r = e.match(ye);
373
390
  if (r) {
374
- let e = ve(r[1]);
375
- if (e) return _(e);
391
+ let e = H(r[1]);
392
+ if (e) return ee(e);
376
393
  }
377
- let i = E[e];
394
+ let i = w[e];
378
395
  if (typeof i == "function" && i.length <= 1) return i;
379
- }, G = /* @__PURE__ */ new Map();
380
- function ye(e) {
381
- let t = b(e), n = (e, t) => {
382
- let { childKey: r, mainKey: i } = he(e);
383
- if (t instanceof m) return H(new p(...V(t)), i, r);
384
- if (t instanceof f) return H(new p(...t.values.flatMap((t) => V(n(e, t)))), i, r);
385
- if (t instanceof p) return H(new p(...t.flatMap((t) => V(n(e, t)))), i, r);
386
- let a = String(t), o = `${r}:${a}`, s = G.get(o);
387
- if (s) return H(s.clone(), i, r);
388
- let c = H(new p(...V(ue(fe(u.FunctionArgs.map((e) => (e.setSubProperty(r), e)), d.Value), a))), i, r);
389
- return G.set(o, c.clone()), c;
396
+ }, W = /* @__PURE__ */ new Map();
397
+ function be(e) {
398
+ let t = g(e), n = (e, t) => {
399
+ let { childKey: r, mainKey: i } = ge(e);
400
+ if (t instanceof m) return V(new p(...B(t)), i, r);
401
+ if (t instanceof f) return V(new p(...t.values.flatMap((t) => B(n(e, t)))), i, r);
402
+ if (t instanceof p) return V(new p(...t.flatMap((t) => B(n(e, t)))), i, r);
403
+ let a = String(t), o = `${r}:${a}`, s = W.get(o);
404
+ if (s) return V(s.clone(), i, r);
405
+ let c = V(new p(...B(de(pe(u.FunctionArgs.map((e) => (e.setSubProperty(r), e)), d.Value), a))), i, r);
406
+ return W.set(o, c.clone()), c;
390
407
  };
391
408
  return Object.entries(t).reduce((e, [t, r]) => (e[t] = n(t, r), e), {});
392
409
  }
393
- var K = (e, t, n, r, i = "oklab", a) => {
410
+ var G = (e, t, n, r, i = "oklab", a) => {
394
411
  let o = r[t], s = r[n];
395
412
  if (!o || !s) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
396
413
  let c = o[e], l = s[e];
@@ -408,19 +425,19 @@ var K = (e, t, n, r, i = "oklab", a) => {
408
425
  if (!r) throw Error(`Missing right-hand interpolation value at index ${n}.`);
409
426
  if (!(t instanceof m) || !(r instanceof m)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
410
427
  let o = { colorSpace: i };
411
- return a !== void 0 && (o.hueMethod = a), ce(oe(t, r, o));
428
+ return a !== void 0 && (o.hueMethod = a), ue(se(t, r, o));
412
429
  });
413
430
  };
414
- function be(e, t, n) {
431
+ function xe(e, t, n) {
415
432
  let [r, i] = [e.start, t.start];
416
433
  return {
417
434
  start: r.value * n / 100,
418
435
  stop: i.value * n / 100
419
436
  };
420
437
  }
421
- function q(e, t, n = !0) {
422
- e = n ? e : b(e);
423
- let r = D(e);
438
+ function K(e, t, n = !0) {
439
+ e = n ? e : g(e);
440
+ let r = T(e);
424
441
  t.forEach((e) => {
425
442
  Object.entries(r).forEach(([t, n]) => {
426
443
  e.style.setProperty(t, n);
@@ -429,20 +446,20 @@ function q(e, t, n = !0) {
429
446
  }
430
447
  //#endregion
431
448
  //#region src/animation/frame-compiler.ts
432
- var J = (e, t) => {
449
+ var q = (e, t) => {
433
450
  if (typeof t == "function") return { fn: t };
434
451
  if (typeof t == "object") {
435
452
  if (typeof t.fn == "function") return t;
436
453
  throw new i(e, t, "an Easing must carry a callable `fn`");
437
454
  }
438
- let n = W(t);
439
- if (!n) throw new i(e, t, "unknown timing function — pass a callable TimingFunction, a typed Easing, a registry name, or a cubic-bezier() literal");
455
+ let n = U(t);
456
+ if (!n) throw new i(e, t, "unknown timing function — pass a callable TimingFunction, a typed Easing, a registry name, or a cubic-bezier() literal", "UNKNOWN_TIMING_FN");
440
457
  let a = r(t);
441
458
  return a ? {
442
459
  fn: n,
443
460
  css: a
444
461
  } : { fn: n };
445
- }, xe = 1e6, Se = class {
462
+ }, Se = 1e6, Ce = /^(?:from|to)$/i, we = /^(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?%$/, J = "a keyframe selector must be a percentage 0%–100% (e.g. \"0%\", \"50%\") or the keyword 'from'/'to'", Te = class {
446
463
  _options;
447
464
  templateFrames = [];
448
465
  parsedVars = [];
@@ -454,40 +471,36 @@ var J = (e, t) => {
454
471
  get options() {
455
472
  return this._options;
456
473
  }
457
- convertFrameStart(e) {
458
- if (e.start.unit === "s" || e.start.unit === "ms" || !e.start.unit) {
459
- let t = e.start.unit === "s" ? "s" : "ms", n = g(e.start.value, t);
460
- e.start.value = n / this.options.duration * 100, e.start.unit = "%";
461
- }
462
- return e.start.value = h(e.start.value, 0, 100), e;
463
- }
464
474
  addFrame(e, t, n, r) {
465
475
  typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof m && (e = String(e));
466
- let i = se(e), a = {
476
+ let a = e.trim();
477
+ if (a === "") throw new i("start", e, `${J} — got an empty/blank string`, "EMPTY_PARSE");
478
+ if (!Ce.test(a) && !(we.test(a) && parseFloat(a) <= 100)) throw new i("start", e, `${J} — got ${JSON.stringify(e)}`);
479
+ let o = le(a), s = {
467
480
  id: this.frameId,
468
- start: i,
481
+ start: o,
469
482
  vars: t,
470
483
  transform: n,
471
- timingFunction: r == null ? this.options.timingFunction : J("timingFunction", r)
484
+ timingFunction: r == null ? this.options.timingFunction : q("timingFunction", r)
472
485
  };
473
- this.convertFrameStart(a), this.templateFrames.push(a), this.frameId += 1;
486
+ this.templateFrames.push(s), this.frameId += 1;
474
487
  }
475
488
  createFrame(e, t) {
476
489
  let n = this.templateFrames[e], r = this.templateFrames[t], i = {
477
490
  start: e,
478
491
  stop: t
479
- }, a = be(n, r, this.options.duration), o = n.transform;
492
+ }, a = xe(n, r, this.options.duration), o = n.transform;
480
493
  if (o == null) {
481
- let t = C(e, this.templateFrames, (e) => e.transform != null);
482
- o = this.templateFrames[t].transform;
494
+ let t = x(e, this.templateFrames, (e) => e.transform != null);
495
+ o = (t === void 0 ? void 0 : this.templateFrames[t].transform) ?? M;
483
496
  }
484
497
  let s = n.timingFunction;
485
498
  if (s == null) {
486
- let t = C(e, this.templateFrames, (e) => e.timingFunction != null);
487
- s = this.templateFrames[t].timingFunction;
499
+ let t = x(e, this.templateFrames, (e) => e.timingFunction != null);
500
+ s = (t === void 0 ? void 0 : this.templateFrames[t].timingFunction) ?? this.options.timingFunction;
488
501
  }
489
502
  return {
490
- id: e * xe + t,
503
+ id: e * Se + t,
491
504
  ixs: i,
492
505
  start: n.start,
493
506
  time: a,
@@ -519,12 +532,12 @@ var J = (e, t) => {
519
532
  }
520
533
  if (i === -1) continue;
521
534
  let [a, o] = [e, i], s = this.frames.findIndex((e) => e.ixs.start === a && e.ixs.stop === o), c = s === -1 ? this.createFrame(a, o) : this.frames[s];
522
- c.interpVars[r] = K(r, a, o, this.parsedVars, this.options.colorSpace, this.options.hueMethod), s === -1 && this.frames.push(c);
535
+ c.interpVars[r] = G(r, a, o, this.parsedVars, this.options.colorSpace, this.options.hueMethod), s === -1 && this.frames.push(c);
523
536
  }
524
537
  }
525
538
  parse(e) {
526
539
  this.frames = [], this.templateFrames.sort((e, t) => e.start.value - t.start.value), this.parsedVars = this.templateFrames.map((t) => {
527
- let n = ye(t.vars);
540
+ let n = be(t.vars);
528
541
  return Object.values(n).forEach((t) => {
529
542
  t.setTargets(e);
530
543
  }), n;
@@ -534,15 +547,15 @@ var J = (e, t) => {
534
547
  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));
535
548
  }
536
549
  finalizeFrameVars(e) {
537
- e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars = de(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat();
550
+ 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();
538
551
  }
539
552
  renormalizeColors() {
540
553
  for (let e of this.frames) {
541
- for (let t of Object.keys(e.interpVars)) e.interpVars[t] = K(t, e.ixs.start, e.ixs.stop, this.parsedVars, this.options.colorSpace, this.options.hueMethod);
554
+ for (let t of Object.keys(e.interpVars)) e.interpVars[t] = G(t, e.ixs.start, e.ixs.stop, this.parsedVars, this.options.colorSpace, this.options.hueMethod);
542
555
  this.finalizeFrameVars(e);
543
556
  }
544
557
  }
545
- }, Ce = new Set([
558
+ }, Ee = new Set([
546
559
  ...c,
547
560
  "%",
548
561
  "vh",
@@ -575,8 +588,8 @@ var J = (e, t) => {
575
588
  "cqb",
576
589
  "cqmin",
577
590
  "cqmax"
578
- ]), Y = (e) => typeof e == "string" && Ce.has(e), X = new Set(["offset-distance"]), we = (e) => X.has(e) || X.has(e.split(".").pop() ?? e);
579
- function Te(e) {
591
+ ]), Y = (e) => typeof e == "string" && Ee.has(e), X = new Set(["offset-distance"]), De = (e) => X.has(e) || X.has(e.split(".").pop() ?? e), Oe = () => typeof globalThis.webkitConvertPointFromNodeToPage == "function";
592
+ function ke(e) {
580
593
  if (!e.targets || e.targets.length === 0) return {
581
594
  eligible: !1,
582
595
  reason: "no DOM targets"
@@ -604,8 +617,12 @@ function Te(e) {
604
617
  eligible: !1,
605
618
  reason: "easing has no faithful CSS twin (would run bare linear on the compositor)"
606
619
  };
620
+ if (t?.css?.startsWith("linear(") && Oe()) return {
621
+ eligible: !1,
622
+ reason: "WebKit refuses HW-accel for linear() easing — the spring twin stays on the rAF path (CE-1.0)"
623
+ };
607
624
  for (let t of e.frames) for (let [e, n] of Object.entries(t.interpVars)) {
608
- let t = we(e);
625
+ let t = De(e);
609
626
  for (let e of n) {
610
627
  let n = Y(e.start?.unit) && !(t && e.start?.unit === "%"), r = Y(e.stop?.unit) && !(t && e.stop?.unit === "%");
611
628
  if (n || r) return {
@@ -620,19 +637,19 @@ function Te(e) {
620
637
  }
621
638
  return { eligible: !0 };
622
639
  }
623
- var Ee = 8;
624
- function De(e) {
640
+ var Ae = 8;
641
+ function je(e) {
625
642
  let n = e.options.duration, r = [], i = /* @__PURE__ */ new Set();
626
643
  for (let t of e.frames) i.add(t.time.start), i.add(t.time.stop);
627
644
  let a = [...i].sort((e, t) => e - t), o = new Set(a);
628
645
  if (n > 0) for (let e = 1; e < a.length; e++) {
629
646
  let t = a[e - 1], n = a[e] - t;
630
- if (!(n <= 0)) for (let e = 1; e <= Ee; e++) o.add(t + n * e / 9);
647
+ if (!(n <= 0)) for (let e = 1; e <= Ae; e++) o.add(t + n * e / 9);
631
648
  }
632
649
  for (let i of [...o].sort((e, t) => e - t)) {
633
650
  let a = e.interpFrames(i, !1);
634
651
  if (Object.keys(a).length === 0) continue;
635
- let o = D(a);
652
+ let o = T(a);
636
653
  r.push({
637
654
  offset: t(i / n, 0, 1),
638
655
  ...o
@@ -640,19 +657,19 @@ function De(e) {
640
657
  }
641
658
  return r;
642
659
  }
643
- var Oe = {
660
+ var Me = {
644
661
  normal: "normal",
645
662
  reverse: "reverse",
646
663
  alternate: "alternate",
647
664
  "alternate-reverse": "alternate-reverse"
648
- }, ke = {
665
+ }, Ne = {
649
666
  none: "none",
650
667
  forwards: "forwards",
651
668
  backwards: "backwards",
652
669
  both: "both"
653
670
  };
654
- function Ae(e) {
655
- let t = e.options, n = Oe[t.direction], r = ke[t.fillMode];
671
+ function Pe(e) {
672
+ let t = e.options, n = Me[t.direction], r = Ne[t.fillMode];
656
673
  if (n == null) throw TypeError(`Unrecognised animation direction "${t.direction}".`);
657
674
  if (r == null) throw TypeError(`Unrecognised animation fill mode "${t.fillMode}".`);
658
675
  let i = (e.frames[0]?.timingFunction ?? e.options.timingFunction).css ?? "linear";
@@ -665,8 +682,8 @@ function Ae(e) {
665
682
  easing: i
666
683
  };
667
684
  }
668
- async function je(e) {
669
- let t = De(e), n = Ae(e), r = e.targets.map((e) => e.animate(t, n));
685
+ async function Fe(e) {
686
+ let t = je(e), n = Pe(e), r = e.targets.map((e) => e.animate(t, n));
670
687
  e._waAnimations = r, e.playback.loop(async (t) => {
671
688
  if (e.done) return !1;
672
689
  if (await e.advanceTo(t), e.paused) for (let e of r) e.pause();
@@ -686,13 +703,13 @@ async function je(e) {
686
703
  //#region src/animation/engine.ts
687
704
  var Z = (e) => {
688
705
  try {
689
- let t = S(e);
706
+ let t = ce(e);
690
707
  return Number.isFinite(t) ? t : void 0;
691
708
  } catch {
692
709
  return;
693
710
  }
694
- }, Me = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", Q = (e) => typeof e == "string" ? e : e.name ?? String(e.id), Ne = 0, $ = class {
695
- id = Ne++;
711
+ }, Ie = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", Q = (e) => typeof e == "string" ? e : e.name ?? String(e.id), Le = 0, $ = class {
712
+ id = Le++;
696
713
  name;
697
714
  superKey;
698
715
  targets;
@@ -723,7 +740,7 @@ var Z = (e) => {
723
740
  get flatKeys() {
724
741
  return this._stableKeys;
725
742
  }
726
- _defaultTransform = (e) => q(e, this.targets);
743
+ _defaultTransform = (e) => K(e, this.targets);
727
744
  usesDefaultRenderer(e) {
728
745
  return e === this._defaultTransform;
729
746
  }
@@ -734,8 +751,8 @@ var Z = (e) => {
734
751
  }));
735
752
  }
736
753
  constructor(e, t, n, r) {
737
- this.options = {}, this._compiler = new Se(this.options), this._ctorOptions = e ?? {}, this.setOptions({
738
- ...P,
754
+ this.options = {}, this._compiler = new Te(this.options), this._ctorOptions = e ?? {}, this.setOptions({
755
+ ...N,
739
756
  ...this._ctorOptions
740
757
  }), this.targets = t == null ? [] : Array.isArray(t) ? t : [t], this.name = n, this.superKey = r;
741
758
  }
@@ -769,10 +786,10 @@ var Z = (e) => {
769
786
  this._stableKeys = [...e];
770
787
  }
771
788
  setTimingFunction(e) {
772
- return this.options.timingFunction = e == null ? P.timingFunction : J("timingFunction", e), this;
789
+ return this.options.timingFunction = e == null ? N.timingFunction : q("timingFunction", e), this;
773
790
  }
774
791
  setIterationCount(t) {
775
- return t == null ? (this.options.iterationCount = P.iterationCount, this) : t === "infinite" || t === "∞" || t === "Infinity" || t === Infinity ? (this.options.iterationCount = Infinity, this) : (this.options.iterationCount = e("iterationCount", t, (e) => {
792
+ return t == null ? (this.options.iterationCount = N.iterationCount, this) : t === "infinite" || t === "∞" || t === "Infinity" || t === Infinity ? (this.options.iterationCount = Infinity, this) : (this.options.iterationCount = e("iterationCount", t, (e) => {
776
793
  let t = typeof e == "string" ? Number.parseFloat(e.trim()) : e;
777
794
  return typeof t == "number" && !Number.isNaN(t) && t >= 0 ? t : void 0;
778
795
  }, "expected a non-negative count, \"infinite\", or Infinity"), this);
@@ -790,39 +807,39 @@ var Z = (e) => {
790
807
  return this.options.duration = n, this;
791
808
  }
792
809
  setDelay(t) {
793
- return t == null ? (this.options.delay = P.delay, this) : (this.options.delay = e("delay", t, (e) => {
810
+ return t == null ? (this.options.delay = N.delay, this) : (this.options.delay = e("delay", t, (e) => {
794
811
  let t = typeof e == "string" ? Z(e) : e;
795
812
  return typeof t == "number" && isFinite(t) ? t : void 0;
796
813
  }, "expected a delay in milliseconds or a CSS time string"), this);
797
814
  }
798
815
  setDirection(e) {
799
- if (e == null) e = P.direction;
800
- else if (!A.includes(e)) throw new i("direction", e, `expected one of: ${A.join(", ")}`);
816
+ if (e == null) e = N.direction;
817
+ else if (!O.includes(e)) throw new i("direction", e, `expected one of: ${O.join(", ")}`);
801
818
  return this.options.direction = 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;
802
819
  }
803
820
  setFillMode(e) {
804
- if (e == null) e = P.fillMode;
805
- else if (!j.includes(e)) throw new i("fillMode", e, `expected one of: ${j.join(", ")}`);
821
+ if (e == null) e = N.fillMode;
822
+ else if (!k.includes(e)) throw new i("fillMode", e, `expected one of: ${k.join(", ")}`);
806
823
  return this.options.fillMode = e, this;
807
824
  }
808
825
  setUseWAAPI(e) {
809
- if (e == null) return this.options.useWAAPI = P.useWAAPI, this;
826
+ if (e == null) return this.options.useWAAPI = N.useWAAPI, this;
810
827
  if (typeof e != "boolean") throw new i("useWAAPI", e, "expected a boolean");
811
828
  return this.options.useWAAPI = e, this;
812
829
  }
813
830
  setRespectReducedMotion(e) {
814
- if (e == null) return this.options.respectReducedMotion = P.respectReducedMotion, this;
831
+ if (e == null) return this.options.respectReducedMotion = N.respectReducedMotion, this;
815
832
  if (typeof e != "boolean") throw new i("respectReducedMotion", e, "expected a boolean");
816
833
  return this.options.respectReducedMotion = e, this;
817
834
  }
818
835
  setColorSpace(e) {
819
- if (e == null) return this.options.colorSpace = P.colorSpace, this;
820
- if (!M.includes(e)) throw new i("colorSpace", e, `expected one of: ${M.join(", ")}`);
836
+ if (e == null) return this.options.colorSpace = N.colorSpace, this;
837
+ if (!A.includes(e)) throw new i("colorSpace", e, `expected one of: ${A.join(", ")}`);
821
838
  return this.options.colorSpace = e, this.frames.length > 0 && this.compiler.renormalizeColors(), this;
822
839
  }
823
840
  setHueMethod(e) {
824
841
  if (e == null) return this;
825
- if (!N.includes(e)) throw new i("hueMethod", e, `expected one of: ${N.join(", ")}`);
842
+ if (!j.includes(e)) throw new i("hueMethod", e, `expected one of: ${j.join(", ")}`);
826
843
  return this.options.hueMethod = e, this.frames.length > 0 && this.compiler.renormalizeColors(), this;
827
844
  }
828
845
  setOptions(e) {
@@ -883,26 +900,41 @@ var Z = (e) => {
883
900
  for (let n = 0; n < t.length; n++) e[t[n]] = void 0;
884
901
  }
885
902
  processFrame(e, t, n) {
886
- let { start: r, stop: i } = e.time, a = r === i ? 1 : le(t, r, i, 0, 1), o = e.timingFunction.fn(a);
887
- for (let t of e.allInterpVars) ae(o, t);
903
+ let { start: r, stop: i } = e.time, a = r === i ? 1 : b(t, r, i, 0, 1), o = e.timingFunction.fn(a);
904
+ for (let t of e.allInterpVars) oe(o, t);
888
905
  n && e.transform(this.unflatten ? e.vars : e.flatVars, t);
889
906
  }
890
- async onStart() {
891
- 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 && (this.paused = !0, await w(this.options.delay), this.paused = !1), this.started = !0;
907
+ onStart() {
908
+ 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, S(this.options.delay).then(() => {
909
+ this.paused = !1, this.started = !0;
910
+ });
911
+ this.started = !0;
892
912
  }
893
- async onEnd() {
913
+ onEnd() {
894
914
  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"));
895
915
  }
896
- async advanceTo(e) {
897
- if (this.startTime === void 0 && (await this.onStart(), this.startTime = e + this.options.delay, this.dispatchAnimationEvent("animationstart")), this.paused && this.pausedTime === 0) return this.pausedTime = e, this.t;
916
+ advanceTo(e) {
917
+ if (this.startTime === void 0) {
918
+ let t = this.onStart(), n = () => (this.startTime = e + this.options.delay, this.dispatchAnimationEvent("animationstart"), this._advance(e));
919
+ return t ? t.then(n) : n();
920
+ }
921
+ return this._advance(e);
922
+ }
923
+ _advance(e) {
924
+ if (this.paused && this.pausedTime === 0) return this.pausedTime = e, this.t;
898
925
  if (this.pausedTime > 0 && !this.paused) {
899
926
  let t = e - this.pausedTime;
900
927
  this.startTime += t, this.pausedTime = 0;
901
928
  }
902
- return this.t = e - this.startTime, this.t >= this.options.duration && (await this.onEnd(), this.t = this.options.duration), this.t;
929
+ return this.t = e - this.startTime, this.t >= this.options.duration && (this.onEnd(), this.t = this.options.duration), this.t;
930
+ }
931
+ _frame(e) {
932
+ if (o(this.options.respectReducedMotion, () => !0, () => !1)) return this._snapToReducedMotion(), !1;
933
+ let t = this.advanceTo(e);
934
+ return typeof t == "number" ? this._renderFrame(t) : t.then((e) => this._renderFrame(e));
903
935
  }
904
- async _frame(e) {
905
- return o(this.options.respectReducedMotion, () => !0, () => !1) ? (await this._snapToReducedMotion(), !1) : (e = await this.advanceTo(e), this.paused ? !1 : this.done ? (this.settle(), this._resolvePlay(), !1) : (this.interpFrames(e, !0, this._interpOut), !0));
936
+ _renderFrame(e) {
937
+ return this.paused ? !1 : this.done ? (this.settle(), this._resolvePlay(), !1) : (this.interpFrames(e, !0, this._interpOut), !0);
906
938
  }
907
939
  _resolvePlay() {
908
940
  let e = this.resolvePromise;
@@ -914,7 +946,7 @@ var Z = (e) => {
914
946
  });
915
947
  }
916
948
  async _playWAAPI() {
917
- await je(this), this.settle();
949
+ await Fe(this), this.settle();
918
950
  }
919
951
  _cancelWAAPI() {
920
952
  if (this._waAnimations.length !== 0) {
@@ -927,7 +959,7 @@ var Z = (e) => {
927
959
  async _playReducedMotion() {
928
960
  this.started = !0, this.dispatchAnimationEvent("animationstart"), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle();
929
961
  }
930
- async _snapToReducedMotion() {
962
+ _snapToReducedMotion() {
931
963
  this._cancelWAAPI(), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle(), this._resolvePlay();
932
964
  }
933
965
  get finished() {
@@ -938,7 +970,7 @@ var Z = (e) => {
938
970
  if (this._playingPromise) return this._playingPromise;
939
971
  let e = o(this.options.respectReducedMotion, () => (this.waapiIneligibleReason = void 0, this._playReducedMotion()), () => {
940
972
  if (this.options.useWAAPI) {
941
- let e = Te(this);
973
+ let e = ke(this);
942
974
  return e.eligible ? (this.waapiIneligibleReason = void 0, this._playWAAPI()) : (this.waapiIneligibleReason = e.reason, this._playRAF());
943
975
  }
944
976
  return this.waapiIneligibleReason = void 0, this._playRAF();
@@ -983,9 +1015,9 @@ var Z = (e) => {
983
1015
  }), this;
984
1016
  }
985
1017
  group(...e) {
986
- return new B(this, ...e);
1018
+ return new z(this, ...e);
987
1019
  }
988
- }, Pe = class extends $ {
1020
+ }, Re = class extends $ {
989
1021
  constructor(e, ...t) {
990
1022
  super(e, t), this.unflatten = !1;
991
1023
  }
@@ -1001,7 +1033,7 @@ var Z = (e) => {
1001
1033
  return this.parse(), this;
1002
1034
  }
1003
1035
  fromKeyframes(e, t) {
1004
- t = this.resolveTransform(t), ne(e) && (e = new Map(Object.entries(e)));
1036
+ t = this.resolveTransform(t), ae(e) && (e = new Map(Object.entries(e)));
1005
1037
  let n = e instanceof Map ? e.entries() : Object.entries(e);
1006
1038
  for (let [e, r] of n) this.addFrame(e, r, t);
1007
1039
  return this.parse(), this;
@@ -1009,7 +1041,7 @@ var Z = (e) => {
1009
1041
  propertyRegistry = /* @__PURE__ */ new Map();
1010
1042
  fromString(e, t) {
1011
1043
  t = this.resolveTransform(t);
1012
- let n = k(e);
1044
+ let n = D(e);
1013
1045
  this.propertyRegistry = n.properties;
1014
1046
  let i = n.options, a = {};
1015
1047
  i.duration != null && (a.duration = i.duration), i.timingFunction != null && (a.timingFunction = i.timingFunction), i.iterationCount !== void 0 && (a.iterationCount = i.iterationCount === null ? Infinity : i.iterationCount), i.direction != null && (a.direction = i.direction), i.delay != null && (a.delay = i.delay), i.fillMode != null && (a.fillMode = i.fillMode), Object.keys(a).length > 0 && this.setOptions({
@@ -1017,7 +1049,7 @@ var Z = (e) => {
1017
1049
  ...this._ctorOptions
1018
1050
  });
1019
1051
  for (let [e, i] of n.keyframes.entries()) {
1020
- let a = Object.fromEntries(Object.entries(i).map(([e, t]) => [e, Me(t) ? t.clone() : t])), o = n.timingFunctions.get(e), s = o ? W(o) : void 0, c;
1052
+ let a = Object.fromEntries(Object.entries(i).map(([e, t]) => [e, Ie(t) ? t.clone() : t])), o = n.timingFunctions.get(e), s = o ? U(o) : void 0, c;
1021
1053
  if (s) {
1022
1054
  let e = o ? r(o) : void 0;
1023
1055
  c = e ? {
@@ -1044,8 +1076,8 @@ var Z = (e) => {
1044
1076
  }
1045
1077
  }
1046
1078
  transform(e) {
1047
- q(e, this.targets);
1079
+ K(e, this.targets);
1048
1080
  }
1049
1081
  };
1050
1082
  //#endregion
1051
- export { $ as Animation, B as AnimationGroup, Pe as CSSKeyframesAnimation, A as DIRECTIONS, j as FILL_MODES, F as defaultLayerConfig, P as defaultOptions, Q as getAnimationId, W as getTimingFunction, k as resolveKeyframes };
1083
+ export { $ as Animation, z as AnimationGroup, Re as CSSKeyframesAnimation, O as DIRECTIONS, k as FILL_MODES, P as defaultLayerConfig, N as defaultOptions, Q as getAnimationId, U as getTimingFunction, D as resolveKeyframes };