@mkbabb/keyframes.js 5.3.5 → 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 };
@@ -0,0 +1,2 @@
1
+ import { n as e, t } from "./registry-CPtiwlwX.js";
2
+ export { t as resolveTimingFunction, e as timingFunctionEntries };
@@ -27,17 +27,21 @@ 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-BAgudUsG.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
  }
34
- let n = t.getTimingFunction(e);
35
- if (!n) throw new a(e);
34
+ let n;
35
+ try {
36
+ n = t.resolveTimingFunction(e);
37
+ } catch {
38
+ throw new a(e);
39
+ }
36
40
  let r = { fn: n }, i = u(e);
37
41
  return i && (r.css = i), r;
38
42
  }
39
43
  //#endregion
40
- //#region src/animation/internal/binarySearch.ts
44
+ //#region src/animation/internal/binary-search.ts
41
45
  function ee(e, t, n, r) {
42
46
  let i = 0, a = e.length - 1;
43
47
  for (; i <= a;) {
@@ -94,12 +98,20 @@ var b = class {
94
98
  }
95
99
  _run(e) {
96
100
  let t = ++this._gen, n = (e) => {
97
- t === this._gen && (e ? this._rafId = p(r) : this._cleanup());
98
- }, r = (t) => {
99
- let r = e(t);
100
- 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);
101
113
  };
102
- this._rafId = p(r);
114
+ this._rafId = p(i);
103
115
  }
104
116
  play = (t, n, r) => {
105
117
  if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
@@ -209,9 +221,6 @@ var w = {
209
221
  stop() {
210
222
  C(this);
211
223
  }
212
- _startLoop() {
213
- x(this);
214
- }
215
224
  }, E = {
216
225
  response: .5,
217
226
  dampingFraction: .86,
@@ -289,7 +298,7 @@ function ie(e, t, n, r, i, a) {
289
298
  }
290
299
  //#endregion
291
300
  //#region src/animation/physics/spring/solver/vector.ts
292
- var M = new Float64Array(), N = class {
301
+ var M = new Float64Array(), ae = class {
293
302
  solution = {
294
303
  x: 0,
295
304
  v: 0
@@ -328,22 +337,22 @@ var M = new Float64Array(), N = class {
328
337
  };
329
338
  //#endregion
330
339
  //#region src/animation/physics/spring/vector-surface.ts
331
- function P(e, t) {
332
- let n = e ?? new N();
340
+ function oe(e, t) {
341
+ let n = e ?? new ae();
333
342
  return n.setTargets(t), n;
334
343
  }
335
- function F(e) {
344
+ function se(e) {
336
345
  return e?.values ?? M;
337
346
  }
338
- function I(e) {
347
+ function ce(e) {
339
348
  return e?.velocities ?? M;
340
349
  }
341
- function L(e, t, n, r, i) {
350
+ function N(e, t, n, r, i) {
342
351
  return e === null || t <= 0 ? M : e.tick(t, n, r, i);
343
352
  }
344
353
  //#endregion
345
354
  //#region src/animation/physics/spring/progress.ts
346
- var R = class e {
355
+ var P = class e {
347
356
  options;
348
357
  get respectReducedMotion() {
349
358
  return this.options.respectReducedMotion;
@@ -389,7 +398,7 @@ var R = class e {
389
398
  return this.isSettled;
390
399
  }
391
400
  set target(e) {
392
- e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
401
+ e === this.targetValue && this.currentVelocity === 0 || this.reseatTarget(e);
393
402
  }
394
403
  reseatTarget(e) {
395
404
  this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
@@ -409,12 +418,16 @@ var R = class e {
409
418
  return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
410
419
  }
411
420
  evaluateAt(e) {
412
- 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);
413
- 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);
414
427
  }
415
428
  checkSettled() {
416
- let e = this.amplitudeScale, t = this.originValue + e * (this.targetValue - this.originValue), n = Math.abs(this.currentValue - t), r = Math.abs(this.currentVelocity);
417
- 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);
418
431
  }
419
432
  snap() {
420
433
  this._snapSettled();
@@ -424,16 +437,16 @@ var R = class e {
424
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();
425
438
  }
426
439
  setTargets(e) {
427
- this.vectorLanes = P(this.vectorLanes, e);
440
+ this.vectorLanes = oe(this.vectorLanes, e);
428
441
  }
429
442
  get values() {
430
- return F(this.vectorLanes);
443
+ return se(this.vectorLanes);
431
444
  }
432
445
  get velocities() {
433
- return I(this.vectorLanes);
446
+ return ce(this.vectorLanes);
434
447
  }
435
448
  tickVector(e) {
436
- 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);
437
450
  }
438
451
  subscribe(e) {
439
452
  return this.subscribers.add(e), () => {
@@ -455,8 +468,8 @@ var R = class e {
455
468
  };
456
469
  //#endregion
457
470
  //#region src/animation/physics/spring/solver/sample.ts
458
- function z(e) {
459
- let t = new R({
471
+ function F(e) {
472
+ let t = new P({
460
473
  response: e.response,
461
474
  dampingFraction: e.dampingFraction,
462
475
  initial: 0,
@@ -470,8 +483,8 @@ function z(e) {
470
483
  }
471
484
  //#endregion
472
485
  //#region src/animation/physics/spring/css/linear-stops.ts
473
- function B(e) {
474
- 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({
475
488
  response: e.response,
476
489
  dampingFraction: e.dampingFraction,
477
490
  sampleCount: t,
@@ -484,10 +497,18 @@ function B(e) {
484
497
  }
485
498
  return a.push("1"), `linear(${a.join(", ")})`;
486
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
+ }
487
508
  //#endregion
488
509
  //#region src/animation/physics/spring/css/timing-function.ts
489
- function V(e) {
490
- 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({
491
512
  response: e.response,
492
513
  dampingFraction: e.dampingFraction,
493
514
  sampleCount: t,
@@ -496,24 +517,26 @@ function V(e) {
496
517
  }), a = new Float64Array(t + 1);
497
518
  a[0] = 0;
498
519
  for (let e = 1; e <= t; e++) a[e] = i[e - 1];
499
- a[t] = 1;
500
- 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) => {
501
524
  if (e <= 0) return 0;
502
525
  if (e >= 1) return 1;
503
- let n = e * t, r = Math.floor(n), i = n - r, o = a[r];
504
- return o + (a[r + 1] - o) * i;
505
- }, 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 = {
506
529
  response: e.response,
507
530
  dampingFraction: e.dampingFraction
508
531
  };
509
- return e.settleThreshold !== void 0 && (s.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (s.maxDuration = e.maxDuration), {
510
- fn: o,
511
- 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)
512
535
  };
513
536
  }
514
537
  //#endregion
515
538
  //#region src/animation/orchestration/timeline/native.ts
516
- function H(e) {
539
+ function V(e) {
517
540
  if (typeof window > "u") return null;
518
541
  if (e.kind === "scroll") {
519
542
  if (globalThis.ScrollTimeline === void 0) return null;
@@ -526,9 +549,9 @@ function H(e) {
526
549
  }
527
550
  //#endregion
528
551
  //#region src/animation/physics/decay.ts
529
- var U = 5;
530
- function W(e) {
531
- 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;
532
555
  if (r <= 0) throw Error("decay() requires a friction coefficient > 0.");
533
556
  let i = t + n / r;
534
557
  return (e) => {
@@ -543,23 +566,23 @@ function W(e) {
543
566
  };
544
567
  };
545
568
  }
546
- function G(e) {
547
- let t = e.friction ?? U;
569
+ function W(e) {
570
+ let t = e.friction ?? H;
548
571
  if (t <= 0) throw Error("decayRest() requires a friction coefficient > 0.");
549
572
  return (e.initial ?? 0) + e.velocity / t;
550
573
  }
551
574
  //#endregion
552
575
  //#region src/animation/orchestration/sequence/transport.ts
553
- function K(t, n) {
576
+ function G(t, n) {
554
577
  for (let { animation: r, at: i } of t) {
555
578
  let t = e(n - i, 0, r.options.duration);
556
579
  r.interpFrames(t, !0);
557
580
  }
558
581
  }
559
- function q(e, t, n, r) {
582
+ function K(e, t, n, r) {
560
583
  e.fire(t, n, r);
561
584
  }
562
- function J(e, t, n) {
585
+ function q(e, t, n) {
563
586
  if (e === void 0) return t;
564
587
  if (typeof e == "number") return e;
565
588
  let r = /^([+-])=(\d*\.?\d+)$/.exec(e);
@@ -568,97 +591,104 @@ function J(e, t, n) {
568
591
  if (i === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
569
592
  return i;
570
593
  }
571
- function ae(t, n, r, i) {
594
+ function le(t, n, r, i) {
572
595
  if (n <= 0) return 0;
573
596
  let a = e(t, 0, n * r), o = Math.floor(a / n), s = a - o * n;
574
597
  return s === 0 && o > 0 && (--o, s = n), i && o % 2 == 1 ? n - s : s;
575
598
  }
576
- function oe(e, t, n) {
599
+ function ue(e, t, n) {
577
600
  return n && (t - 1) % 2 == 1 ? 0 : e;
578
601
  }
579
- function se(e, t, n) {
602
+ function de(e, t, n) {
580
603
  return e === 1 && t === 1 && !n;
581
604
  }
582
- function Y(e, t, n) {
605
+ function J(e, t, n) {
583
606
  return n === 0 ? e : e - t / n;
584
607
  }
585
- async function ce(e, t) {
586
- e._playOrigin === void 0 && (e._playOrigin = Y(t, e._time, e._rate)), e._lastClock = t;
587
- 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);
588
- 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);
589
- if (q(e.events, e.entries, e.labels, a), K(e.entries, a), i) {
590
- 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);
591
614
  let t = e._resolvePlay;
592
615
  return e._resolvePlay = null, t?.(), !1;
593
616
  }
594
617
  return !0;
595
618
  }
596
- function X(e) {
619
+ function Y(e) {
597
620
  for (let { animation: t } of e.entries) t.managed = !1, t.started = !1, t.startTime = void 0;
598
621
  e._playOrigin = void 0, e._lastClock = void 0, e._paused = !1;
599
622
  }
600
- function Z(e, t) {
623
+ function X(e, t) {
601
624
  if (!t) return;
602
625
  let n = e._lastClock;
603
626
  if (n === void 0) {
604
627
  e._playOrigin = void 0;
605
628
  return;
606
629
  }
607
- e._playOrigin = Y(n, e._time, e._rate);
630
+ e._playOrigin = J(n, e._time, e._rate);
608
631
  }
609
632
  //#endregion
610
- //#region src/animation/internal/transport/core.ts
611
- function Q(e, t) {
633
+ //#region src/animation/internal/transport-core.ts
634
+ function Z(e, t) {
612
635
  if (e._playingPromise) return e._playingPromise;
613
636
  let n = t();
614
637
  return e._playingPromise = n, n.finally(() => {
615
638
  e._playingPromise === n && (e._playingPromise = null);
616
639
  }), n;
617
640
  }
618
- function le(e) {
641
+ function pe(e) {
619
642
  return e.started && !e.paused;
620
643
  }
621
- function ue(e, t, n) {
644
+ function me(e, t, n) {
622
645
  e.paused ? n() : t();
623
646
  }
624
647
  //#endregion
625
648
  //#region src/animation/orchestration/sequence/lifecycle.ts
626
- function de(e) {
649
+ function he(e) {
650
+ return Q(e, 0);
651
+ }
652
+ function Q(e, t) {
627
653
  if (e._playingPromise) return e._playingPromise;
628
654
  if (e.respectReducedMotion && _()) return e.seek(e.duration), Promise.resolve();
629
655
  for (let { animation: t, at: n } of e.entries) t.startTime = n, t.started = !0, t.managed = !0;
630
- 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) => {
631
657
  e._resolvePlay = t, e.playback.loop(e._boundFrame);
632
658
  }));
633
659
  }
634
- function fe(e) {
635
- e.playback.stop(), X(e);
660
+ function ge(e) {
661
+ e.playback.stop(), Y(e);
636
662
  let t = e._resolvePlay;
637
663
  e._resolvePlay = null, t?.();
638
664
  }
639
- function pe(e) {
665
+ function $(e) {
640
666
  !e._playingPromise || e._paused || (e._paused = !0, e.playback.stop(), e._playOrigin = void 0);
641
667
  }
642
- function $(e) {
643
- !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));
644
674
  }
645
- function me(e, t) {
675
+ function ve(e, t) {
646
676
  if (!Number.isFinite(t)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${t}.`);
647
- e._rate = t, Z(e, e._playingPromise != null);
677
+ e._rate = t, X(e, e._playingPromise != null);
648
678
  }
649
- function he(e) {
650
- e._rate = -e._rate, Z(e, e._playingPromise != null);
679
+ function ye(e) {
680
+ e._rate = -e._rate, X(e, e._playingPromise != null);
651
681
  }
652
- function ge(e, t) {
682
+ function be(e, t) {
653
683
  if (t !== Infinity && (!Number.isInteger(t) || t < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${t}.`);
654
684
  e._repeatCount = t;
655
685
  }
656
- function _e(e, t) {
686
+ function xe(e, t) {
657
687
  e._yoyoOn = t;
658
688
  }
659
689
  //#endregion
660
690
  //#region src/animation/orchestration/sequence/events.ts
661
- var ve = class {
691
+ var Se = class {
662
692
  subscribers = new Map([
663
693
  ["segment:enter", /* @__PURE__ */ new Set()],
664
694
  ["segment:leave", /* @__PURE__ */ new Set()],
@@ -693,10 +723,10 @@ var ve = class {
693
723
  }
694
724
  this._prevPhase = n;
695
725
  }
696
- }, ye = class {
726
+ }, Ce = class {
697
727
  entries = [];
698
728
  labels = /* @__PURE__ */ new Map();
699
- events = new ve();
729
+ events = new Se();
700
730
  cursor = 0;
701
731
  _time = 0;
702
732
  respectReducedMotion;
@@ -712,7 +742,7 @@ var ve = class {
712
742
  _paused = !1;
713
743
  _lastClock = void 0;
714
744
  constructor(e) {
715
- this.respectReducedMotion = e?.respectReducedMotion ?? !1, this._boundFrame = this._frame.bind(this);
745
+ this.respectReducedMotion = e?.respectReducedMotion ?? !0, this._boundFrame = this._frame.bind(this);
716
746
  }
717
747
  get duration() {
718
748
  return this._duration;
@@ -730,20 +760,20 @@ var ve = class {
730
760
  return this._rate;
731
761
  }
732
762
  label(e, t) {
733
- 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;
734
764
  }
735
765
  on(e, t) {
736
766
  return this.events.subscribe(e, t);
737
767
  }
738
768
  add(e, t) {
739
- let n = J(t, this.cursor, this.labels);
769
+ let n = q(t, this.cursor, this.labels);
740
770
  return this.entries.push({
741
771
  animation: e,
742
772
  at: n
743
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;
744
774
  }
745
775
  seek(e) {
746
- 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;
747
777
  }
748
778
  setTargets(...e) {
749
779
  for (let { animation: t } of this.entries) t.setTargets(...e);
@@ -753,32 +783,32 @@ var ve = class {
753
783
  return this._playingPromise ?? Promise.resolve();
754
784
  }
755
785
  play() {
756
- return de(this);
786
+ return he(this);
757
787
  }
758
788
  async _frame(e) {
759
- return ce(this, e);
789
+ return fe(this, e);
760
790
  }
761
791
  stop() {
762
- return fe(this), this;
792
+ return ge(this), this;
763
793
  }
764
794
  pause() {
765
- return pe(this), this;
795
+ return $(this), this;
766
796
  }
767
797
  resume() {
768
- return $(this), this;
798
+ return _e(this), this;
769
799
  }
770
800
  timeScale(e) {
771
- return me(this, e), this;
801
+ return ve(this, e), this;
772
802
  }
773
803
  reverse() {
774
- return he(this), this;
804
+ return ye(this), this;
775
805
  }
776
806
  repeat(e) {
777
- return ge(this, e), this;
807
+ return be(this, e), this;
778
808
  }
779
809
  yoyo(e = !0) {
780
- return _e(this, e), this;
810
+ return xe(this, e), this;
781
811
  }
782
812
  };
783
813
  //#endregion
784
- 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 };