@mkbabb/keyframes.js 6.0.0 → 6.1.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.
@@ -0,0 +1,162 @@
1
+ import { CubicBezier as e, bezierPresets as t, easing as n, linearEasing as r, steppedEase as i } from "@mkbabb/value.js/easing";
2
+ import { collectAnimationOptions as a, collectCustomFunctions as o, collectKeyframes as s, collectPropertyDescriptors as c, collectStyleRules as l, collectTimelineOptions as u, parseAnimationRange as d, parseAnimationTimeline as f, parseCssScalar as p, parseCssValues as m, parseKeyframeSelector as h, parseStylesheet as g, parseTimingFunction as _, serializeCssValue as v, serializeTimelineOptions as y } from "@mkbabb/value.js/css";
3
+ //#region src/animation/compile/emit/serialize-value.ts
4
+ var b = class extends Error {
5
+ value;
6
+ issue;
7
+ code = "SERIALIZE_INVARIANT";
8
+ constructor(e, t) {
9
+ super(`ingest admitted a value the serializer refuses (${t.code}).`), this.value = e, this.issue = t, this.name = "SerializeInvariantError";
10
+ }
11
+ }, x = (e) => {
12
+ let t = v(e);
13
+ if (!t.ok) throw new b(e, t.error);
14
+ return t.value;
15
+ }, S = (e, t) => {
16
+ let n = `${e / 1e3}s`, r = `${e}ms`;
17
+ return t === "s" ? n : t === "ms" ? r : n.length <= r.length ? n : r;
18
+ }, C = (e) => e === Infinity ? "infinite" : String(e), w = (e) => [
19
+ e.duration == null ? void 0 : S(e.duration, e.durationUnit),
20
+ e.timingFunction == null ? void 0 : T(e.timingFunction),
21
+ e.delay == null ? void 0 : S(e.delay, e.delayUnit),
22
+ e.iterationCount == null ? void 0 : C(e.iterationCount),
23
+ e.direction,
24
+ e.fillMode,
25
+ e.composition,
26
+ e.name
27
+ ].filter((e) => e !== void 0).join(" "), T = (e) => {
28
+ switch (e.kind) {
29
+ case "keyword": return e.name;
30
+ case "cubic-bezier": return `cubic-bezier(${e.x1}, ${e.y1}, ${e.x2}, ${e.y2})`;
31
+ case "steps": return `steps(${e.count}, ${e.position})`;
32
+ case "linear-function": return `linear(${e.stops.map((e) => `${e.output}${e.input.map((e) => ` ${e * 100}%`).join("")}`).join(", ")})`;
33
+ }
34
+ }, E = (e) => e.kind === "percent" ? `${e.value * 100}%` : e.offset === void 0 ? e.name : `${e.name} ${e.offset * 100}%`, D = (e) => `${e.name}: ${x(e.value)}${e.important ? " !important" : ""}`, O = (e) => e.split("\n").map((e) => ` ${e}`).join("\n"), k = (e) => {
35
+ switch (e.kind) {
36
+ case "keyframes": return `@keyframes ${e.name} {\n${e.rules.map((e) => O(`${e.selectors.map(E).join(", ")} {\n${e.declarations.map((e) => O(`${D(e)};`)).join("\n")}\n}`)).join("\n")}\n}`;
37
+ case "property": {
38
+ let t = [];
39
+ return e.descriptor.syntax !== void 0 && t.push(`syntax: ${e.descriptor.syntax};`), e.descriptor.inherits !== void 0 && t.push(`inherits: ${e.descriptor.inherits};`), e.descriptor.initialValue !== void 0 && t.push(`initial-value: ${x(e.descriptor.initialValue)};`), `@property ${e.name} {\n${t.map(O).join("\n")}\n}`;
40
+ }
41
+ case "function": {
42
+ let t = e.descriptor.parameters?.map((e) => {
43
+ let t = e.syntax === void 0 ? "" : ` ${e.syntax}`, n = e.default === void 0 ? "" : `: ${x(e.default)}`;
44
+ return `${e.name}${t}${n}`;
45
+ }).join(", ") ?? "", n = e.descriptor.declarations?.map((e) => `${D(e)};`) ?? [];
46
+ return `@function ${e.name}(${t}) {\n${n.map(O).join("\n")}\n}`;
47
+ }
48
+ case "style": {
49
+ let t = e.declarations.map((e) => `${D(e)};`), n = e.children?.map((e) => k(e)) ?? [];
50
+ return `${e.selectors.join(", ")} {\n${[...t, ...n].map(O).join("\n")}\n}`;
51
+ }
52
+ case "scope": return `@scope (${e.root?.join(", ") ?? ""})${e.limit === void 0 ? "" : ` to (${e.limit.join(", ")})`} {\n${e.children.map((e) => O(k(e))).join("\n")}\n}`;
53
+ case "starting-style": return `@starting-style {\n${e.children.map((e) => O(k(e))).join("\n")}\n}`;
54
+ case "scroll-timeline": {
55
+ let t = Object.entries(e.descriptor).map(([e, t]) => `${e}: ${t};`);
56
+ return `@scroll-timeline ${e.name} {\n${t.map(O).join("\n")}\n}`;
57
+ }
58
+ case "view-timeline": {
59
+ let t = Object.entries(e.descriptor).map(([e, t]) => `${e}: ${t};`);
60
+ return `@view-timeline ${e.name} {\n${t.map(O).join("\n")}\n}`;
61
+ }
62
+ case "unknown": {
63
+ let t = e.prelude === "" ? "" : ` ${e.prelude}`;
64
+ return e.children === void 0 ? e.body === null ? `@${e.atName}${t};` : `@${e.atName}${t} {${e.body}}` : `@${e.atName}${t} {\n${e.children.map((e) => O(k(e))).join("\n")}\n}`;
65
+ }
66
+ }
67
+ }, A = (e) => `${e.code} at ${e.start}-${e.end}: expected ${e.expected.join(" or ")}, got ${e.actual ?? "end of input"}`;
68
+ function j(e, t) {
69
+ if (e.ok) return e.value;
70
+ throw t(e.diagnostics);
71
+ }
72
+ function M(e, t) {
73
+ return e.ok ? {
74
+ value: e.value,
75
+ issues: []
76
+ } : {
77
+ value: t,
78
+ issues: e.diagnostics
79
+ };
80
+ }
81
+ function N(e, t, n) {
82
+ try {
83
+ let r = e();
84
+ return r.ok ? t(r.value) : n;
85
+ } catch {
86
+ return n;
87
+ }
88
+ }
89
+ function P(e, t) {
90
+ return e.ok ? e.value : t;
91
+ }
92
+ //#endregion
93
+ //#region src/animation/compile/easing/registry.ts
94
+ var F = [
95
+ "easeOutCubic",
96
+ "easeInOutSine",
97
+ "easeInOutCubic",
98
+ "easeInOutQuad",
99
+ "easeInOutExpo",
100
+ "easeInOutCirc",
101
+ "easeOutExpo",
102
+ "smoothStep3",
103
+ "easeInBounce"
104
+ ], I = [
105
+ ...Object.keys(t),
106
+ "ease-in-bounce",
107
+ ...F
108
+ ], L = (e) => {
109
+ let t = n(e);
110
+ if (!t.ok) throw Error(`value.js rejected its own easing ${JSON.stringify(e)}: ${t.error.code}`);
111
+ return t.value;
112
+ }, R = I.map((e) => [e, L(e)]), z = new Set(I), B = (e) => {
113
+ let t = e.flatMap(({ output: e, input: t }) => t.length === 2 ? [{
114
+ output: e,
115
+ input: t[0]
116
+ }, {
117
+ output: e,
118
+ input: t[1]
119
+ }] : [{
120
+ output: e,
121
+ input: t[0]
122
+ }]);
123
+ t[0].input ??= 0, t[t.length - 1].input ??= 1;
124
+ let n = t[0].input;
125
+ for (let e = 1; e < t.length; e++) {
126
+ let r = t[e].input;
127
+ r !== void 0 && (t[e].input = Math.max(n, r), n = t[e].input);
128
+ }
129
+ for (let e = 0; e < t.length - 1;) {
130
+ let n = e + 1;
131
+ for (; t[n].input === void 0;) n++;
132
+ let r = t[e].input, i = t[n].input;
133
+ for (let a = e + 1; a < n; a++) t[a].input = r + (i - r) * (a - e) / (n - e);
134
+ e = n;
135
+ }
136
+ return t;
137
+ }, V = (t) => {
138
+ switch (t.kind) {
139
+ case "keyword": {
140
+ let e = n(t.name);
141
+ if (e.ok) return e.value;
142
+ throw TypeError(`Invalid timing function: ${e.error.code}.`);
143
+ }
144
+ case "cubic-bezier": {
145
+ let n = e(t.x1, t.y1, t.x2, t.y2);
146
+ if (n.ok) return n.value;
147
+ throw TypeError(`Invalid cubic-bezier(): ${n.error.code}.`);
148
+ }
149
+ case "steps": {
150
+ let e = i(t.count, t.position);
151
+ if (e.ok) return e.value;
152
+ throw TypeError(`Invalid steps(): ${e.error.code}.`);
153
+ }
154
+ case "linear-function": {
155
+ let e = r(B(t.stops));
156
+ if (e.ok) return e.value;
157
+ throw TypeError(`Invalid linear(): ${e.error.code}.`);
158
+ }
159
+ }
160
+ }, H = (e) => typeof e == "string" ? z.has(e) ? L(e) : V(j(_(e), () => /* @__PURE__ */ TypeError(`Unknown timing function "${e}".`))) : e;
161
+ //#endregion
162
+ export { S as C, x as D, T as E, w as S, k as T, g as _, o as a, y as b, l as c, P as d, d as f, h as g, m as h, a as i, u as l, p as m, R as n, s as o, f as p, M as r, c as s, H as t, A as u, _ as v, E as w, N as x, j as y };
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./easing-registry-B0rLmOtw.js";
1
+ import { n as e, t } from "./registry-CPtiwlwX.js";
2
2
  export { t as resolveTimingFunction, e as timingFunctionEntries };
@@ -27,7 +27,7 @@ var s = (e) => typeof e == "function" ? { fn: e } : e, c = /^(linear|ease|ease-i
27
27
  async function d(e) {
28
28
  let t;
29
29
  try {
30
- t = await import("./easing-registry-Db7xwtXT.js");
30
+ t = await import("./registry-Dd7GzvJm.js");
31
31
  } catch (t) {
32
32
  throw Error(`keyframes: the easing-registry chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
33
33
  }
@@ -41,7 +41,7 @@ async function d(e) {
41
41
  return i && (r.css = i), r;
42
42
  }
43
43
  //#endregion
44
- //#region src/animation/internal/binarySearch.ts
44
+ //#region src/animation/internal/binary-search.ts
45
45
  function ee(e, t, n, r) {
46
46
  let i = 0, a = e.length - 1;
47
47
  for (; i <= a;) {
@@ -98,12 +98,20 @@ var b = class {
98
98
  }
99
99
  _run(e) {
100
100
  let t = ++this._gen, n = (e) => {
101
- t === this._gen && (e ? this._rafId = p(r) : this._cleanup());
102
- }, r = (t) => {
103
- let r = e(t);
104
- r && typeof r.then == "function" ? r.then(n) : n(r);
101
+ t === this._gen && (e ? this._rafId = p(i) : this._cleanup());
102
+ }, r = (e) => {
103
+ throw n(!1), e;
104
+ }, i = (t) => {
105
+ let i;
106
+ try {
107
+ i = e(t);
108
+ } catch (e) {
109
+ r(e);
110
+ return;
111
+ }
112
+ i && typeof i.then == "function" ? i.then(n, r) : n(i);
105
113
  };
106
- this._rafId = p(r);
114
+ this._rafId = p(i);
107
115
  }
108
116
  play = (t, n, r) => {
109
117
  if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
@@ -213,9 +221,6 @@ var w = {
213
221
  stop() {
214
222
  C(this);
215
223
  }
216
- _startLoop() {
217
- x(this);
218
- }
219
224
  }, E = {
220
225
  response: .5,
221
226
  dampingFraction: .86,
@@ -293,7 +298,7 @@ function ie(e, t, n, r, i, a) {
293
298
  }
294
299
  //#endregion
295
300
  //#region src/animation/physics/spring/solver/vector.ts
296
- var M = new Float64Array(), N = class {
301
+ var M = new Float64Array(), ae = class {
297
302
  solution = {
298
303
  x: 0,
299
304
  v: 0
@@ -332,22 +337,22 @@ var M = new Float64Array(), N = class {
332
337
  };
333
338
  //#endregion
334
339
  //#region src/animation/physics/spring/vector-surface.ts
335
- function P(e, t) {
336
- let n = e ?? new N();
340
+ function oe(e, t) {
341
+ let n = e ?? new ae();
337
342
  return n.setTargets(t), n;
338
343
  }
339
- function F(e) {
344
+ function se(e) {
340
345
  return e?.values ?? M;
341
346
  }
342
- function I(e) {
347
+ function ce(e) {
343
348
  return e?.velocities ?? M;
344
349
  }
345
- function L(e, t, n, r, i) {
350
+ function N(e, t, n, r, i) {
346
351
  return e === null || t <= 0 ? M : e.tick(t, n, r, i);
347
352
  }
348
353
  //#endregion
349
354
  //#region src/animation/physics/spring/progress.ts
350
- var R = class e {
355
+ var P = class e {
351
356
  options;
352
357
  get respectReducedMotion() {
353
358
  return this.options.respectReducedMotion;
@@ -393,7 +398,7 @@ var R = class e {
393
398
  return this.isSettled;
394
399
  }
395
400
  set target(e) {
396
- e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
401
+ e === this.targetValue && this.currentVelocity === 0 || this.reseatTarget(e);
397
402
  }
398
403
  reseatTarget(e) {
399
404
  this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
@@ -413,12 +418,16 @@ var R = class e {
413
418
  return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
414
419
  }
415
420
  evaluateAt(e) {
416
- let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, { x: a, v: o } = ie(r, i, this.omega, this.zeta, this.omegaD, e);
417
- this.currentValue = n + a, this.currentVelocity = o;
421
+ let t = this.scaledTarget(), n = this.originValue - t, r = this.originVelocity, { x: i, v: a } = ie(n, r, this.omega, this.zeta, this.omegaD, e);
422
+ this.currentValue = t + i, this.currentVelocity = a;
423
+ }
424
+ scaledTarget() {
425
+ let e = this.amplitudeScale;
426
+ return e === 1 ? this.targetValue : this.originValue + e * (this.targetValue - this.originValue);
418
427
  }
419
428
  checkSettled() {
420
- let e = this.amplitudeScale, t = this.originValue + e * (this.targetValue - this.originValue), n = Math.abs(this.currentValue - t), r = Math.abs(this.currentVelocity);
421
- n < this.options.settleThreshold && r < this.options.velocitySettleThreshold && (this.currentValue = t, this.currentVelocity = 0, this.isSettled = !0);
429
+ let e = this.scaledTarget(), t = Math.abs(this.currentValue - e), n = Math.abs(this.currentVelocity);
430
+ t < this.options.settleThreshold && n < this.options.velocitySettleThreshold && (this.currentValue = e, this.currentVelocity = 0, this.isSettled = !0);
422
431
  }
423
432
  snap() {
424
433
  this._snapSettled();
@@ -428,16 +437,16 @@ var R = class e {
428
437
  this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale = v(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
429
438
  }
430
439
  setTargets(e) {
431
- this.vectorLanes = P(this.vectorLanes, e);
440
+ this.vectorLanes = oe(this.vectorLanes, e);
432
441
  }
433
442
  get values() {
434
- return F(this.vectorLanes);
443
+ return se(this.vectorLanes);
435
444
  }
436
445
  get velocities() {
437
- return I(this.vectorLanes);
446
+ return ce(this.vectorLanes);
438
447
  }
439
448
  tickVector(e) {
440
- return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : L(this.vectorLanes, e, this.omega, this.zeta, this.omegaD);
449
+ return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : N(this.vectorLanes, e, this.omega, this.zeta, this.omegaD);
441
450
  }
442
451
  subscribe(e) {
443
452
  return this.subscribers.add(e), () => {
@@ -459,8 +468,8 @@ var R = class e {
459
468
  };
460
469
  //#endregion
461
470
  //#region src/animation/physics/spring/solver/sample.ts
462
- function z(e) {
463
- let t = new R({
471
+ function F(e) {
472
+ let t = new P({
464
473
  response: e.response,
465
474
  dampingFraction: e.dampingFraction,
466
475
  initial: 0,
@@ -474,8 +483,8 @@ function z(e) {
474
483
  }
475
484
  //#endregion
476
485
  //#region src/animation/physics/spring/css/linear-stops.ts
477
- function B(e) {
478
- let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = z({
486
+ function I(e) {
487
+ let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = F({
479
488
  response: e.response,
480
489
  dampingFraction: e.dampingFraction,
481
490
  sampleCount: t,
@@ -488,10 +497,18 @@ function B(e) {
488
497
  }
489
498
  return a.push("1"), `linear(${a.join(", ")})`;
490
499
  }
500
+ var L = (e) => Math.round(e * 1e5) / 1e5;
501
+ function R(e) {
502
+ let t = e.length - 1;
503
+ if (t < 1) throw RangeError(`linearFromSamples needs at least 2 samples; got ${e.length}.`);
504
+ let n = [];
505
+ for (let r = 0; r <= t; r++) n.push(`${L(e[r])} ${L(r / t * 100)}%`);
506
+ return `linear(${n.join(", ")})`;
507
+ }
491
508
  //#endregion
492
509
  //#region src/animation/physics/spring/css/timing-function.ts
493
- function V(e) {
494
- let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = z({
510
+ function z(e) {
511
+ let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = F({
495
512
  response: e.response,
496
513
  dampingFraction: e.dampingFraction,
497
514
  sampleCount: t,
@@ -500,24 +517,26 @@ function V(e) {
500
517
  }), a = new Float64Array(t + 1);
501
518
  a[0] = 0;
502
519
  for (let e = 1; e <= t; e++) a[e] = i[e - 1];
503
- a[t] = 1;
504
- let o = (e) => {
520
+ return a[t] = 1, a;
521
+ }
522
+ function B(e) {
523
+ let t = z(e), n = t.length - 1, r = (e) => {
505
524
  if (e <= 0) return 0;
506
525
  if (e >= 1) return 1;
507
- let n = e * t, r = Math.floor(n), i = n - r, o = a[r];
508
- return o + (a[r + 1] - o) * i;
509
- }, s = {
526
+ let r = e * n, i = Math.floor(r), a = r - i, o = t[i];
527
+ return o + (t[i + 1] - o) * a;
528
+ }, i = {
510
529
  response: e.response,
511
530
  dampingFraction: e.dampingFraction
512
531
  };
513
- return e.settleThreshold !== void 0 && (s.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (s.maxDuration = e.maxDuration), {
514
- fn: o,
515
- css: B(s)
532
+ return e.settleThreshold !== void 0 && (i.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (i.maxDuration = e.maxDuration), {
533
+ fn: r,
534
+ css: I(i)
516
535
  };
517
536
  }
518
537
  //#endregion
519
538
  //#region src/animation/orchestration/timeline/native.ts
520
- function H(e) {
539
+ function V(e) {
521
540
  if (typeof window > "u") return null;
522
541
  if (e.kind === "scroll") {
523
542
  if (globalThis.ScrollTimeline === void 0) return null;
@@ -530,9 +549,9 @@ function H(e) {
530
549
  }
531
550
  //#endregion
532
551
  //#region src/animation/physics/decay.ts
533
- var U = 5;
534
- function W(e) {
535
- let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? U;
552
+ var H = 5;
553
+ function U(e) {
554
+ let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? H;
536
555
  if (r <= 0) throw Error("decay() requires a friction coefficient > 0.");
537
556
  let i = t + n / r;
538
557
  return (e) => {
@@ -547,23 +566,23 @@ function W(e) {
547
566
  };
548
567
  };
549
568
  }
550
- function G(e) {
551
- let t = e.friction ?? U;
569
+ function W(e) {
570
+ let t = e.friction ?? H;
552
571
  if (t <= 0) throw Error("decayRest() requires a friction coefficient > 0.");
553
572
  return (e.initial ?? 0) + e.velocity / t;
554
573
  }
555
574
  //#endregion
556
575
  //#region src/animation/orchestration/sequence/transport.ts
557
- function K(t, n) {
576
+ function G(t, n) {
558
577
  for (let { animation: r, at: i } of t) {
559
578
  let t = e(n - i, 0, r.options.duration);
560
579
  r.interpFrames(t, !0);
561
580
  }
562
581
  }
563
- function q(e, t, n, r) {
582
+ function K(e, t, n, r) {
564
583
  e.fire(t, n, r);
565
584
  }
566
- function J(e, t, n) {
585
+ function q(e, t, n) {
567
586
  if (e === void 0) return t;
568
587
  if (typeof e == "number") return e;
569
588
  let r = /^([+-])=(\d*\.?\d+)$/.exec(e);
@@ -572,97 +591,104 @@ function J(e, t, n) {
572
591
  if (i === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
573
592
  return i;
574
593
  }
575
- function ae(t, n, r, i) {
594
+ function le(t, n, r, i) {
576
595
  if (n <= 0) return 0;
577
596
  let a = e(t, 0, n * r), o = Math.floor(a / n), s = a - o * n;
578
597
  return s === 0 && o > 0 && (--o, s = n), i && o % 2 == 1 ? n - s : s;
579
598
  }
580
- function oe(e, t, n) {
599
+ function ue(e, t, n) {
581
600
  return n && (t - 1) % 2 == 1 ? 0 : e;
582
601
  }
583
- function se(e, t, n) {
602
+ function de(e, t, n) {
584
603
  return e === 1 && t === 1 && !n;
585
604
  }
586
- function Y(e, t, n) {
605
+ function J(e, t, n) {
587
606
  return n === 0 ? e : e - t / n;
588
607
  }
589
- async function ce(e, t) {
590
- e._playOrigin === void 0 && (e._playOrigin = Y(t, e._time, e._rate)), e._lastClock = t;
591
- let n = (t - e._playOrigin) * e._rate, r = e.duration * e._repeatCount, i = e._rate >= 0 ? n >= r : n <= 0, a = i ? e._rate >= 0 ? oe(e.duration, e._repeatCount, e._yoyoOn) : 0 : ae(n, e.duration, e._repeatCount, e._yoyoOn);
592
- if (e._time = a, se(e._rate, e._repeatCount, e._yoyoOn)) for (let { animation: t, at: n } of e.entries) a >= n && a - n < t.options.duration && await t.advanceTo(a);
593
- if (q(e.events, e.entries, e.labels, a), K(e.entries, a), i) {
594
- X(e);
608
+ async function fe(e, t) {
609
+ e._playOrigin === void 0 && (e._playOrigin = J(t, e._time, e._rate)), e._lastClock = t;
610
+ let n = (t - e._playOrigin) * e._rate, r = e.duration * e._repeatCount, i = e._rate >= 0 ? n >= r : n <= 0, a = i ? e._rate >= 0 ? ue(e.duration, e._repeatCount, e._yoyoOn) : 0 : le(n, e.duration, e._repeatCount, e._yoyoOn);
611
+ if (e._time = a, de(e._rate, e._repeatCount, e._yoyoOn)) for (let { animation: t, at: n } of e.entries) a >= n && a - n < t.options.duration && await t.advanceTo(a);
612
+ if (K(e.events, e.entries, e.labels, a), G(e.entries, a), i) {
613
+ Y(e);
595
614
  let t = e._resolvePlay;
596
615
  return e._resolvePlay = null, t?.(), !1;
597
616
  }
598
617
  return !0;
599
618
  }
600
- function X(e) {
619
+ function Y(e) {
601
620
  for (let { animation: t } of e.entries) t.managed = !1, t.started = !1, t.startTime = void 0;
602
621
  e._playOrigin = void 0, e._lastClock = void 0, e._paused = !1;
603
622
  }
604
- function Z(e, t) {
623
+ function X(e, t) {
605
624
  if (!t) return;
606
625
  let n = e._lastClock;
607
626
  if (n === void 0) {
608
627
  e._playOrigin = void 0;
609
628
  return;
610
629
  }
611
- e._playOrigin = Y(n, e._time, e._rate);
630
+ e._playOrigin = J(n, e._time, e._rate);
612
631
  }
613
632
  //#endregion
614
- //#region src/animation/internal/transport/core.ts
615
- function Q(e, t) {
633
+ //#region src/animation/internal/transport-core.ts
634
+ function Z(e, t) {
616
635
  if (e._playingPromise) return e._playingPromise;
617
636
  let n = t();
618
637
  return e._playingPromise = n, n.finally(() => {
619
638
  e._playingPromise === n && (e._playingPromise = null);
620
639
  }), n;
621
640
  }
622
- function le(e) {
641
+ function pe(e) {
623
642
  return e.started && !e.paused;
624
643
  }
625
- function ue(e, t, n) {
644
+ function me(e, t, n) {
626
645
  e.paused ? n() : t();
627
646
  }
628
647
  //#endregion
629
648
  //#region src/animation/orchestration/sequence/lifecycle.ts
630
- function de(e) {
649
+ function he(e) {
650
+ return Q(e, 0);
651
+ }
652
+ function Q(e, t) {
631
653
  if (e._playingPromise) return e._playingPromise;
632
654
  if (e.respectReducedMotion && _()) return e.seek(e.duration), Promise.resolve();
633
655
  for (let { animation: t, at: n } of e.entries) t.startTime = n, t.started = !0, t.managed = !0;
634
- return e._time = 0, e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, Q(e, () => new Promise((t) => {
656
+ return e._time = t, e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, Z(e, () => new Promise((t) => {
635
657
  e._resolvePlay = t, e.playback.loop(e._boundFrame);
636
658
  }));
637
659
  }
638
- function fe(e) {
639
- e.playback.stop(), X(e);
660
+ function ge(e) {
661
+ e.playback.stop(), Y(e);
640
662
  let t = e._resolvePlay;
641
663
  e._resolvePlay = null, t?.();
642
664
  }
643
- function pe(e) {
665
+ function $(e) {
644
666
  !e._playingPromise || e._paused || (e._paused = !0, e.playback.stop(), e._playOrigin = void 0);
645
667
  }
646
- function $(e) {
647
- !e._playingPromise || !e._paused || (e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, e.playback.loop(e._boundFrame));
668
+ function _e(e) {
669
+ if (!e._playingPromise) {
670
+ Q(e, e._time);
671
+ return;
672
+ }
673
+ e._paused && (e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, e.playback.loop(e._boundFrame));
648
674
  }
649
- function me(e, t) {
675
+ function ve(e, t) {
650
676
  if (!Number.isFinite(t)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${t}.`);
651
- e._rate = t, Z(e, e._playingPromise != null);
677
+ e._rate = t, X(e, e._playingPromise != null);
652
678
  }
653
- function he(e) {
654
- e._rate = -e._rate, Z(e, e._playingPromise != null);
679
+ function ye(e) {
680
+ e._rate = -e._rate, X(e, e._playingPromise != null);
655
681
  }
656
- function ge(e, t) {
682
+ function be(e, t) {
657
683
  if (t !== Infinity && (!Number.isInteger(t) || t < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${t}.`);
658
684
  e._repeatCount = t;
659
685
  }
660
- function _e(e, t) {
686
+ function xe(e, t) {
661
687
  e._yoyoOn = t;
662
688
  }
663
689
  //#endregion
664
690
  //#region src/animation/orchestration/sequence/events.ts
665
- var ve = class {
691
+ var Se = class {
666
692
  subscribers = new Map([
667
693
  ["segment:enter", /* @__PURE__ */ new Set()],
668
694
  ["segment:leave", /* @__PURE__ */ new Set()],
@@ -697,10 +723,10 @@ var ve = class {
697
723
  }
698
724
  this._prevPhase = n;
699
725
  }
700
- }, ye = class {
726
+ }, Ce = class {
701
727
  entries = [];
702
728
  labels = /* @__PURE__ */ new Map();
703
- events = new ve();
729
+ events = new Se();
704
730
  cursor = 0;
705
731
  _time = 0;
706
732
  respectReducedMotion;
@@ -716,7 +742,7 @@ var ve = class {
716
742
  _paused = !1;
717
743
  _lastClock = void 0;
718
744
  constructor(e) {
719
- this.respectReducedMotion = e?.respectReducedMotion ?? !1, this._boundFrame = this._frame.bind(this);
745
+ this.respectReducedMotion = e?.respectReducedMotion ?? !0, this._boundFrame = this._frame.bind(this);
720
746
  }
721
747
  get duration() {
722
748
  return this._duration;
@@ -734,20 +760,20 @@ var ve = class {
734
760
  return this._rate;
735
761
  }
736
762
  label(e, t) {
737
- return this.labels.set(e, J(t, this.cursor, this.labels)), this;
763
+ return this.labels.set(e, q(t, this.cursor, this.labels)), this;
738
764
  }
739
765
  on(e, t) {
740
766
  return this.events.subscribe(e, t);
741
767
  }
742
768
  add(e, t) {
743
- let n = J(t, this.cursor, this.labels);
769
+ let n = q(t, this.cursor, this.labels);
744
770
  return this.entries.push({
745
771
  animation: e,
746
772
  at: n
747
773
  }), this.entries.sort((e, t) => e.at - t.at), this.cursor = n + e.options.duration, this._duration = Math.max(this._duration, this.cursor), this;
748
774
  }
749
775
  seek(e) {
750
- return this._time = e, q(this.events, this.entries, this.labels, e), K(this.entries, e), this;
776
+ return this._time = e, K(this.events, this.entries, this.labels, e), G(this.entries, e), this;
751
777
  }
752
778
  setTargets(...e) {
753
779
  for (let { animation: t } of this.entries) t.setTargets(...e);
@@ -757,32 +783,32 @@ var ve = class {
757
783
  return this._playingPromise ?? Promise.resolve();
758
784
  }
759
785
  play() {
760
- return de(this);
786
+ return he(this);
761
787
  }
762
788
  async _frame(e) {
763
- return ce(this, e);
789
+ return fe(this, e);
764
790
  }
765
791
  stop() {
766
- return fe(this), this;
792
+ return ge(this), this;
767
793
  }
768
794
  pause() {
769
- return pe(this), this;
795
+ return $(this), this;
770
796
  }
771
797
  resume() {
772
- return $(this), this;
798
+ return _e(this), this;
773
799
  }
774
800
  timeScale(e) {
775
- return me(this, e), this;
801
+ return ve(this, e), this;
776
802
  }
777
803
  reverse() {
778
- return he(this), this;
804
+ return ye(this), this;
779
805
  }
780
806
  repeat(e) {
781
- return ge(this, e), this;
807
+ return be(this, e), this;
782
808
  }
783
809
  yoyo(e = !0) {
784
- return _e(this, e), this;
810
+ return xe(this, e), this;
785
811
  }
786
812
  };
787
813
  //#endregion
788
- export { a as C, i as S, n as _, W as a, d as b, V as c, T as d, b as f, t as g, e as h, ue as i, B as l, y as m, Q as n, G as o, v as p, le as r, H as s, ye as t, R as u, ee as v, o as w, s as x, u as y };
814
+ export { d as C, o as D, a as E, u as S, i as T, f as _, U as a, n as b, B as c, I as d, P as f, y as g, v as h, me as i, z as l, b as m, Z as n, W as o, T as p, pe as r, V as s, Ce as t, R as u, e as v, s as w, ee as x, t as y };