@mkbabb/keyframes.js 5.1.0 → 5.3.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,156 +0,0 @@
1
- import { g as e } from "./sequence-C_DCiOIQ.js";
2
- import { a as t, i as n, o as r, r as i, t as a, u as o } from "./animation-BGyzfzBq.js";
3
- import { r as s } from "./parse-flatten-ZZUSEQEL.js";
4
- import { t as c } from "./easing-registry-DHV2-5gA.js";
5
- import { ValueArray as l, ValueUnit as u, extractAnimationOptions as d, extractFunctions as f, extractKeyframes as p, extractProperties as m, extractTimelineOptions as h, isObject as g, parseCSSStylesheet as _ } from "@mkbabb/value.js";
6
- //#region src/animation/adapter.ts
7
- var v = (e, r) => {
8
- let a = {};
9
- for (let o of e.declarations) {
10
- let e = o.value;
11
- if (e instanceof l && i(e)) {
12
- let i = n(e, r);
13
- if (i === t) continue;
14
- e = i;
15
- }
16
- a[o.name] = e;
17
- }
18
- return a;
19
- }, y = (e) => {
20
- let t = [];
21
- for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
22
- return t;
23
- }, b = (e) => {
24
- let t = p(e);
25
- for (let e of t.values()) if (e.length > 0) return e;
26
- return [];
27
- }, x = (e, t) => {
28
- let n = [], i = (e, t) => {
29
- n.push({
30
- code: e,
31
- message: t.message ?? e,
32
- ...t
33
- });
34
- }, a = typeof e == "string" ? _(e) : e, o = b(a);
35
- typeof e == "string" && o.length === 0 && e.trim() && (a = _(`@keyframes anonymous {\n${e.trim()}\n}`), o = b(a)), typeof e == "string" && o.length === 0 && e.trim() && i("EMPTY_PARSE", {
36
- message: "the input is non-empty but parsed to zero @keyframes rules (no animatable stops) — the resulting animation has no frames",
37
- input: e
38
- });
39
- let s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = f(a), p = r(u, t, n);
40
- for (let e of o) {
41
- let t = v(e, p);
42
- for (let n of y(e)) {
43
- let r = s.get(n);
44
- s.set(n, {
45
- ...r ?? {},
46
- ...t
47
- }), e.timingFunction != null && c.set(n, e.timingFunction);
48
- let i = e.composition;
49
- i != null && l.set(n, i);
50
- }
51
- }
52
- return {
53
- keyframes: s,
54
- timingFunctions: c,
55
- composition: l,
56
- properties: m(a),
57
- functions: u,
58
- options: d(a),
59
- diagnostics: n,
60
- stylesheet: a
61
- };
62
- };
63
- //#endregion
64
- //#region src/animation/engine/css-metadata.ts
65
- function S(e) {
66
- let t = {};
67
- return e.duration != null && (t.duration = e.duration), e.timingFunction != null && (t.timingFunction = e.timingFunction), e.iterationCount !== void 0 && (t.iterationCount = e.iterationCount === null ? Infinity : e.iterationCount), e.direction != null && (t.direction = e.direction), e.delay != null && (t.delay = e.delay), e.fillMode != null && (t.fillMode = e.fillMode), e.composition != null && (t.composite = e.composition), t;
68
- }
69
- function C(e) {
70
- let t = h(e);
71
- return Object.keys(t).length > 0 ? t : void 0;
72
- }
73
- function w(e, t) {
74
- if (!(typeof CSS > "u" || typeof CSS.registerProperty != "function")) for (let [n, r] of e) {
75
- if (r.syntax == null) continue;
76
- let e = {
77
- name: n,
78
- syntax: r.syntax,
79
- inherits: r.inherits ?? !1
80
- };
81
- r.initialValue != null && (e.initialValue = r.initialValue.toString());
82
- try {
83
- CSS.registerProperty(e);
84
- } catch (e) {
85
- if (e instanceof DOMException && e.name === "InvalidModificationError") continue;
86
- t.push({
87
- code: "PROPERTY_REGISTER_REJECTED",
88
- property: n,
89
- message: `CSS.registerProperty refused @property ${n}: ${String(e)}`
90
- });
91
- }
92
- }
93
- }
94
- //#endregion
95
- //#region src/animation/engine/css-animation.ts
96
- var T = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", E = class extends a {
97
- _boundTimeline;
98
- constructor(e, ...t) {
99
- super(e, t), this.unflatten = !1;
100
- }
101
- bindTimeline(e) {
102
- this._boundTimeline = e;
103
- let t = !1;
104
- for (let e of this.compiler.templateFrames) e.start.superType?.includes("named-selector") && (e.start = new u(o(String(e.start.value)) * 100, "%"), t = !0);
105
- return t && this.compiler.frames.length > 0 && this.parse(), this;
106
- }
107
- resolveTransform(e) {
108
- return this.unflatten = e != null, e ?? this._defaultTransform;
109
- }
110
- fromVars(e, t) {
111
- t = this.resolveTransform(t);
112
- for (let n = 0; n < e.length; n++) {
113
- let r = e[n], i = Math.round(n / (e.length - 1) * 100);
114
- this.addFrame(i, r, t);
115
- }
116
- return this.parse(), this;
117
- }
118
- fromKeyframes(e, t) {
119
- t = this.resolveTransform(t), g(e) && (e = new Map(Object.entries(e)));
120
- let n = e instanceof Map ? e.entries() : Object.entries(e);
121
- for (let [e, r] of n) this.addFrame(e, r, t);
122
- return this.parse(), this;
123
- }
124
- propertyRegistry = /* @__PURE__ */ new Map();
125
- scrollOptions;
126
- fromString(t, n) {
127
- n = this.resolveTransform(n);
128
- let r = x(t);
129
- this.propertyRegistry = r.properties;
130
- let i = C(r.stylesheet);
131
- i === void 0 ? delete this.scrollOptions : this.scrollOptions = i, this.diagnostics = [...r.diagnostics];
132
- let a = S(r.options);
133
- Object.keys(a).length > 0 && this.setOptions({
134
- ...a,
135
- ...this._ctorOptions
136
- });
137
- for (let [t, i] of r.keyframes.entries()) {
138
- let a = Object.fromEntries(Object.entries(i).map(([e, t]) => [e, T(t) ? t.clone() : t])), o = r.timingFunctions.get(t), s = o ? c(o) : void 0, l;
139
- if (s) {
140
- let t = o ? e(o) : void 0;
141
- l = t ? {
142
- fn: s,
143
- css: t
144
- } : { fn: s };
145
- }
146
- let u = r.composition.get(t);
147
- this.addFrame(t, a, n, l, u);
148
- }
149
- return this.parse(), w(this.propertyRegistry, this.diagnostics), this;
150
- }
151
- transform(e) {
152
- s(e, this.targets);
153
- }
154
- };
155
- //#endregion
156
- export { x as n, E as t };
@@ -1,4 +0,0 @@
1
- import { f as e, g as t, h as n, n as r, p as i, t as a } from "./animation-BGyzfzBq.js";
2
- import { t as o } from "./easing-registry-DHV2-5gA.js";
3
- import { n as s, t as c } from "./engine-DEVgCTUy.js";
4
- export { c as CSSKeyframesAnimation, e as DIRECTIONS, i as FILL_MODES, a as KeyframesAnimation, n as defaultLayerConfig, t as defaultOptions, r as getAnimationId, o as getTimingFunction, s as resolveKeyframes };
@@ -1,123 +0,0 @@
1
- import { n as e } from "./presets-BG2Fczzq.js";
2
- import { y as t } from "./sequence-C_DCiOIQ.js";
3
- import { camelCaseToHyphen as n, formatCSS as r, reverseAnimationShorthand as i, reverseCSSTime as a, serializeStylesheetItem as o, timingFunctions as s, unflattenObjectToString as c } from "@mkbabb/value.js";
4
- //#region src/animation/compile/format.ts
5
- var l = /* @__PURE__ */ e({
6
- CSSKeyframesToString: () => w,
7
- CSSKeyframesToStrings: () => h,
8
- animationComposition: () => S,
9
- animationOptionsToString: () => _,
10
- animationShorthand: () => x,
11
- declaredKeyframeBodyFor: () => v,
12
- formatCSSKeyframeString: () => g,
13
- keyframesBlock: () => y,
14
- premultipliedKeyframesBlock: () => b,
15
- serializeEasing: () => u
16
- });
17
- function u(e) {
18
- if (e.css !== void 0) return e.css;
19
- let r = Object.entries(s).find(([t, n]) => n === e.fn)?.[0];
20
- if (r === void 0) throw new t("timingFunction", e.fn, "a custom TimingFunction has no CSS animation-timing-function representation — attach a faithful Easing.css twin, or use a registry name / cubic-bezier() / linear() literal");
21
- return n(r);
22
- }
23
- var d = 80, f = "@keyframes animation {\n", p = "\n}";
24
- function m(e, t, r) {
25
- let i = e.parsedVars[t] ?? {}, a = e.templateFrames[t], o = Object.entries(c(i)).map(([e, t]) => ` ${n(e)}: ${t};`), s = a.timingFunction ? u(a.timingFunction) : r;
26
- s !== r && o.push(` animation-timing-function: ${s};`);
27
- let l = a.composition;
28
- return l != null && l !== "replace" && o.push(` animation-composition: ${l};`), `{\n${o.join("\n").trim()}\n}`;
29
- }
30
- var h = async (e) => {
31
- let t = u(e.options.timingFunction), n = e.templateFrames.map(async (n, i) => {
32
- let a = m(e, i, t);
33
- return a = `${n.start}\n${a}\n`, a = f + a + p, a = await r(a, d), a.replace(f, "").replace(p, "");
34
- });
35
- return Promise.all(n);
36
- };
37
- function g(e) {
38
- let t = e.replace(/^[^{]*{/, "").replace(/^ /gm, "").replace(/}\s*$/, "");
39
- return t = t.trim(), t = t.replace(/^ /, ""), t;
40
- }
41
- function _(e, t = "animation") {
42
- let n = "";
43
- n += ` animation-name: ${t};\n`;
44
- let r = a(e.duration);
45
- n += ` animation-duration: ${r};\n`, n += ` animation-timing-function: ${u(e.timingFunction)};\n`, n += ` animation-iteration-count: ${isFinite(e.iterationCount) ? e.iterationCount : "infinite"};\n`, n += ` animation-direction: ${e.direction};\n`, n += ` animation-fill-mode: ${e.fillMode};\n`, e.delay > 0 && (n += ` animation-delay: ${a(e.delay)};\n`);
46
- let i = e.composite == null ? void 0 : S(e.composite);
47
- return i != null && (n += ` ${i}\n`), n = `.${t} {\n${n}}\n`, n;
48
- }
49
- function v(e, t, n) {
50
- return m(e, t, n);
51
- }
52
- function y(e, t, n) {
53
- let r = u(e.options.timingFunction), i = /* @__PURE__ */ new Map();
54
- e.templateFrames.forEach((t, a) => {
55
- let o = n?.get(a) ?? m(e, a, r), s = i.get(o);
56
- s ? s.push(t.start) : i.set(o, [t.start]);
57
- });
58
- let a = "";
59
- for (let [e, t] of i) a += `${t.join(", ")} ${e}\n`;
60
- return `@keyframes ${t} {\n${a}}`;
61
- }
62
- function b(e, t, r) {
63
- let i = u(e.options.timingFunction), a = /* @__PURE__ */ new Map();
64
- for (let t = 0; t < e.templateFrames.length; t++) {
65
- let o = e.templateFrames[t], s = e.parsedVars[t] ?? {}, l = {};
66
- for (let [e, t] of Object.entries(s)) {
67
- let n = t.clone();
68
- for (let t of n) if (typeof t.value == "number") t.value *= r;
69
- else if (t.unit === "color" || typeof t.value == "string") return {
70
- refused: !0,
71
- key: e
72
- };
73
- l[e] = n;
74
- }
75
- let d = Object.entries(c(l)).map(([e, t]) => ` ${n(e)}: ${t};`), f = o.timingFunction ? u(o.timingFunction) : i;
76
- f !== i && d.push(` animation-timing-function: ${f};`);
77
- let p = o.composition;
78
- p != null && p !== "replace" && d.push(` animation-composition: ${p};`);
79
- let m = `{\n${d.join("\n").trim()}\n}`, h = a.get(m);
80
- h ? h.push(o.start) : a.set(m, [o.start]);
81
- }
82
- let o = "";
83
- for (let [e, t] of a) o += `${t.join(", ")} ${e}\n`;
84
- return { block: `@keyframes ${t} {\n${o}}` };
85
- }
86
- function x(e, t) {
87
- let n = {
88
- name: t,
89
- duration: e.duration,
90
- timingFunction: u(e.timingFunction),
91
- iterationCount: isFinite(e.iterationCount) ? e.iterationCount : Infinity,
92
- direction: e.direction,
93
- fillMode: e.fillMode
94
- };
95
- return e.delay > 0 && (n.delay = e.delay), i(n);
96
- }
97
- function S(e) {
98
- return e === "replace" ? void 0 : `animation-composition: ${e};`;
99
- }
100
- function C(e) {
101
- let t = e.propertyRegistry;
102
- if (t == null || t.size === 0) return "";
103
- let n = [];
104
- for (let [e, r] of t) n.push(o({
105
- kind: "property",
106
- name: e,
107
- descriptor: r
108
- }));
109
- return n.join("\n");
110
- }
111
- async function w(e, t = "animation", n = void 0) {
112
- let i = e.options, a = /* @__PURE__ */ new Map(), o = u(i.timingFunction);
113
- e.templateFrames.forEach((t, n) => {
114
- let r = t.start, i = m(e, n, o);
115
- a.has(i) ? a.get(i).push(r) : a.set(i, [r]);
116
- });
117
- let s = "";
118
- for (let [e, t] of a) s += `${t.join(", ")} ${e}`;
119
- let c = _(i, t), l = C(e);
120
- return (await r(`${l ? `${l}\n\n` : ""}${c}\n@keyframes ${t} {\n${s}}`, n)).replace(/\(\s*\{/g, "{").replace(/\}\s*\)/g, "}");
121
- }
122
- //#endregion
123
- export { g as a, b as c, x as i, u as l, h as n, l as o, S as r, y as s, w as t };
@@ -1,23 +0,0 @@
1
- import { extractTimelineOptions as e, parseAnimationRange as t, parseAnimationTimeline as n, parseCSSStylesheet as r, serializeTimelineOptions as i } from "@mkbabb/value.js";
2
- //#region src/animation/scroll/grammar.ts
3
- function a(e) {
4
- return n(e);
5
- }
6
- function o(e) {
7
- return t(e);
8
- }
9
- function s(t) {
10
- return e(typeof t == "string" ? r(t) : t);
11
- }
12
- function c(e) {
13
- return i(e);
14
- }
15
- function l(e) {
16
- let t = s(e);
17
- return {
18
- options: t,
19
- declarations: c(t)
20
- };
21
- }
22
- //#endregion
23
- export { c as a, l as i, o as n, a as r, s as t };
@@ -1,360 +0,0 @@
1
- import { n as e } from "./presets-BG2Fczzq.js";
2
- import { d as t, l as n, s as r } from "./sequence-C_DCiOIQ.js";
3
- import { d as i, h as a, m as o, n as s, t as c } from "./animation-BGyzfzBq.js";
4
- import { n as l } from "./scheduler-CUtVnuoU.js";
5
- import { ValueUnit as u, lerp as d } from "@mkbabb/value.js";
6
- //#region src/animation/group/entries.ts
7
- var f = (e) => typeof e == "string" ? e : s(e), p = (e, t, n) => {
8
- let r = f(t), i = e[r];
9
- if (!i) throw Error(`AnimationGroup.${n}: no animation registered for key "${r}". Known keys: ${Object.keys(e).join(", ") || "(none)"}.`);
10
- return i;
11
- }, m = (e) => {
12
- let t = /* @__PURE__ */ new Set();
13
- for (let n of e) {
14
- let e = n.layer.properties;
15
- for (let r of n.animation.flatKeys) e && !e.has(r) || t.add(r);
16
- }
17
- return [...t];
18
- }, h = (e) => {
19
- let t = !0;
20
- for (let n of e) n.animation.interpFrames(n.animation.t, !0), t &&= n.animation.done;
21
- return t;
22
- }, g = (e) => {
23
- for (let t of e) {
24
- let e = t.animation;
25
- e.started = !0, e.t = e.options.duration, e.interpFrames(e.t, !0);
26
- }
27
- }, _ = (e, t) => {
28
- for (let n of e) n.animation.paused = t;
29
- }, v = (e, t) => {
30
- let n;
31
- for (let r of e) {
32
- let e = r.animation;
33
- if (e.paused && e.pausedTime !== 0) continue;
34
- let i = e.advanceTo(t);
35
- typeof i != "number" && (n ??= []).push(i);
36
- }
37
- return n && Promise.all(n).then(() => void 0);
38
- }, y = async (e, t, n) => {
39
- for (let r = 0; r < e.length; r += n) await v(e.slice(r, r + n), t), r + n < e.length && await l();
40
- }, b = (e, t, n) => {
41
- let i = new r({
42
- ...n,
43
- initial: e
44
- });
45
- return i.target = t, i;
46
- }, x = (e, t) => {
47
- let n = !1;
48
- for (let r of e) {
49
- let e = r.layer.weightSpring;
50
- e !== void 0 && (t > 0 && e.tickDt(t), e.settled ? (r.layer.weight = e.value, delete r.layer.weightSpring) : n = !0);
51
- }
52
- return n;
53
- }, S = (e) => e instanceof u && typeof e.value == "number", C = (e, t) => {
54
- let { carriers: n, incomings: r } = t, i = n.length;
55
- if (i !== 0) {
56
- for (let t = 0; t < i; t++) e[t] = n[t].value;
57
- if (t.weighted) {
58
- let n = t.layer.weightSpring?.value ?? t.layer.weight;
59
- for (let t = 0; t < i; t++) e[t] = d(e[t], r[t].value, n);
60
- } else for (let t = 0; t < i; t++) e[t] = e[t] + r[t].value;
61
- for (let t = 0; t < i; t++) n[t].value = e[t];
62
- }
63
- }, w = (e, t) => {
64
- let n = [], r = {}, i = 0;
65
- for (let t of e) {
66
- let { layer: e, values: a } = t;
67
- if (!e.enabled) continue;
68
- let o = e.properties, s = e.blendMode === "weighted";
69
- if (e.blendMode === "replace") {
70
- for (let e in a) {
71
- if (o && !o.has(e)) continue;
72
- let t = a[e];
73
- t !== void 0 && (r[e] = t);
74
- }
75
- continue;
76
- }
77
- let c = [], l = [], u = [];
78
- for (let e in a) {
79
- if (o && !o.has(e)) continue;
80
- let t = a[e];
81
- if (t === void 0) continue;
82
- let n = r[e];
83
- if (Array.isArray(n) && Array.isArray(t)) {
84
- let r = Math.min(n.length, t.length), i = !0;
85
- for (let e = 0; e < r; e++) if (!S(n[e]) || !S(t[e])) {
86
- i = !1;
87
- break;
88
- }
89
- if (i) for (let e = 0; e < r; e++) c.push(n[e]), l.push(t[e]);
90
- else u.push(e);
91
- } else u.push(e), r[e] = t;
92
- }
93
- c.length > i && (i = c.length), n.push({
94
- layer: e,
95
- weighted: s,
96
- carriers: c,
97
- incomings: l,
98
- boxedKeys: u
99
- });
100
- }
101
- let a = t;
102
- return i > 0 && (a === null || a.length < i) && (a = new Float64Array(i)), {
103
- plans: n,
104
- compositeBuf: a
105
- };
106
- };
107
- //#endregion
108
- //#region src/animation/group/compositor.ts
109
- function T(e, t) {
110
- let n = e._grouped;
111
- e._groupedKeysDirty && (e._groupedKeys = m(e.getEntries()), e._groupedKeysDirty = !1, e._soaPlans = null);
112
- let r = e._groupedKeys;
113
- for (let e = 0; e < r.length; e++) n[r[e]] = void 0;
114
- let i = e.getEntries(), a = e._soaPlans !== null, s = 0, c = !0;
115
- for (let t of i) {
116
- let { animation: r, layer: i, values: o } = t;
117
- if (c &&= r.done, !i.enabled) continue;
118
- r.interpFrames(r.t, !1, o);
119
- let l = i.properties;
120
- if (i.blendMode === "replace") {
121
- for (let e in o) {
122
- if (l && !l.has(e)) continue;
123
- let t = o[e];
124
- t !== void 0 && (n[e] = t);
125
- }
126
- continue;
127
- }
128
- if (a) {
129
- let t = e._soaPlans[s++];
130
- C(e._compositeBuf, t), t.boxedKeys.length > 0 && E(i, o, n, l, t.boxedKeys);
131
- } else E(i, o, n, l);
132
- }
133
- if (!a) {
134
- let { plans: t, compositeBuf: n } = w(i, e._compositeBuf);
135
- e._soaPlans = t, e._compositeBuf = n;
136
- }
137
- e.done = c;
138
- for (let e = 0; e < r.length; e++) {
139
- let t = r[e];
140
- n[t] === void 0 && delete n[t];
141
- }
142
- if (e.transform === o) for (let t of e.getEntries()) {
143
- let n = t.animation.frames[0];
144
- if (n != null && n.transform != null) {
145
- e.transform = n.transform;
146
- break;
147
- }
148
- }
149
- return e.transform(n, t), n;
150
- }
151
- function E(e, t, n, r, i) {
152
- let a = i ? new Set(i) : void 0;
153
- if (e.blendMode === "add") {
154
- for (let e in t) {
155
- if (a && !a.has(e) || r && !r.has(e)) continue;
156
- let i = t[e];
157
- if (i === void 0) continue;
158
- let o = n[e];
159
- if (Array.isArray(o) && Array.isArray(i)) {
160
- let e = Math.min(o.length, i.length);
161
- for (let t = 0; t < e; t++) S(o[t]) && S(i[t]) ? o[t].value += i[t].value : o[t] = i[t];
162
- } else n[e] = i;
163
- }
164
- return;
165
- }
166
- let o = e.weightSpring?.value ?? e.weight;
167
- for (let e in t) {
168
- if (a && !a.has(e) || r && !r.has(e)) continue;
169
- let i = t[e];
170
- if (i === void 0) continue;
171
- let s = n[e];
172
- if (Array.isArray(s) && Array.isArray(i)) {
173
- let e = Math.min(s.length, i.length);
174
- for (let t = 0; t < e; t++) S(s[t]) && S(i[t]) ? s[t].value = d(s[t].value, i[t].value, o) : s[t] = i[t];
175
- } else n[e] = i;
176
- }
177
- }
178
- //#endregion
179
- //#region src/animation/group/layer-api.ts
180
- function D(e, t, n) {
181
- let r = p(e.animations, t, "setLayerConfig");
182
- Object.assign(r.layer, n), e.invalidateEntries();
183
- }
184
- function O(e, t) {
185
- return e.animations[f(t)]?.layer;
186
- }
187
- function k(e, t, n) {
188
- let i = p(e.animations, t, "transitionLayer").layer;
189
- i.blendMode = "weighted";
190
- let a = i.weightSpring;
191
- a instanceof r ? a.target = n.weight : i.weightSpring = b(i.weight, n.weight, n.spring), e._hasLayerSprings = !0, e.invalidateEntries();
192
- }
193
- function A(e, t, n, r) {
194
- let i = r?.spring;
195
- k(e, t, {
196
- weight: 0,
197
- ...i ? { spring: i } : {}
198
- }), k(e, n, {
199
- weight: 1,
200
- ...i ? { spring: i } : {}
201
- });
202
- }
203
- //#endregion
204
- //#region src/animation/group/group.ts
205
- var j = class e {
206
- animations = {};
207
- transform = o;
208
- superKey;
209
- paused = !1;
210
- started = !1;
211
- done = !1;
212
- respectReducedMotion = !1;
213
- static YIELD_BATCH = 32;
214
- singleTarget = !0;
215
- lastTickTime = 0;
216
- playback = new n();
217
- resolvePromise = null;
218
- _playingPromise = null;
219
- _boundFrame;
220
- _entries = [];
221
- _entriesDirty = !0;
222
- _grouped = {};
223
- _groupedKeys = [];
224
- _groupedKeysDirty = !0;
225
- _soaPlans = null;
226
- _compositeBuf = null;
227
- _hasLayerSprings = !1;
228
- constructor(...e) {
229
- this._boundFrame = this._frame.bind(this);
230
- let t = [];
231
- for (let n of e) {
232
- let e, r;
233
- n instanceof c ? e = n : (e = n.animation, r = n.layer), this.transform === o && e.frames[0] != null && (this.transform = e.frames[0].transform);
234
- let i = s(e);
235
- this.animations[i] = {
236
- values: {},
237
- animation: e,
238
- layer: {
239
- ...a,
240
- ...r
241
- }
242
- }, e.managed = !0, t.push(e);
243
- }
244
- this.singleTarget = t.every((e) => e.targets[0] === t[0]?.targets[0]), this.invalidateEntries();
245
- }
246
- getEntries() {
247
- return this._entriesDirty &&= (this._entries = Object.values(this.animations), this._entries.sort((e, t) => e.layer.zIndex - t.layer.zIndex), !1), this._entries;
248
- }
249
- invalidateEntries() {
250
- this._entriesDirty = !0, this._groupedKeysDirty = !0;
251
- }
252
- setSuperKey(e) {
253
- this.superKey = e;
254
- for (let t of this.getEntries()) t.animation.superKey = e;
255
- return this;
256
- }
257
- setTargets(...e) {
258
- let t = this.getEntries();
259
- for (let n of t) n.animation.setTargets(...e);
260
- return this.singleTarget = t.every((e) => e.animation.targets[0] === t[0]?.animation.targets[0]), this;
261
- }
262
- transformFramesGrouped(e) {
263
- return T(this, e);
264
- }
265
- render(e = this.lastTickTime) {
266
- this.singleTarget ? this.transformFramesGrouped(e) : h(this.getEntries());
267
- }
268
- setChildTime(e, t) {
269
- let n = p(this.animations, e, "setChildTime").animation;
270
- return n.t = t, n.startTime !== void 0 && (n.pausedTime = n.startTime + t), this;
271
- }
272
- advanceTo(t) {
273
- let n = this.lastTickTime === 0 ? 0 : t - this.lastTickTime;
274
- this._hasLayerSprings && this.advanceLayerSprings(n), this.lastTickTime = t, this.started = !0;
275
- let r = this.getEntries(), i = e.YIELD_BATCH, a = r.length <= i ? v(r, t) : y(r, t, i);
276
- return a ? a.then(() => this) : this;
277
- }
278
- _frame(e) {
279
- let t = this.advanceTo(e);
280
- return typeof t.then == "function" ? t.then(() => this._renderFrame(e)) : this._renderFrame(e);
281
- }
282
- _renderFrame(e) {
283
- return this.paused ? !1 : (this.singleTarget ? this.transformFramesGrouped(e) : this.done = h(this.getEntries()), this.done ? (this.settle(), this._resolvePlay(), !1) : !0);
284
- }
285
- _resolvePlay() {
286
- let e = this.resolvePromise;
287
- this.resolvePromise = null, e?.();
288
- }
289
- get finished() {
290
- return this._playingPromise ?? Promise.resolve();
291
- }
292
- async play() {
293
- if (this._playingPromise) return this._playingPromise;
294
- let e = t(this.respectReducedMotion, () => this._playReducedMotion(), () => new Promise((e) => {
295
- this.resolvePromise = e, this.playback.loop(this._boundFrame);
296
- }));
297
- return this._playingPromise = e, e.finally(() => {
298
- this._playingPromise = null;
299
- }), e;
300
- }
301
- _playReducedMotion() {
302
- this.started = !0;
303
- let e = this.lastTickTime;
304
- return g(this.getEntries()), this.singleTarget && this.transformFramesGrouped(e), this.settle(), Promise.resolve();
305
- }
306
- pause() {
307
- if (!this.started || this.paused) return this;
308
- this.paused = !0;
309
- let e = this.lastTickTime;
310
- for (let t of this.getEntries()) {
311
- let n = t.animation;
312
- n.pause(), n.pausedTime === 0 && (n.pausedTime = e);
313
- }
314
- return this.playback.stop(), this.render(), this;
315
- }
316
- resume() {
317
- return !this.started || !this.paused ? this : (this.paused = !1, _(this.getEntries(), !1), this.playback.loop(this._boundFrame), this);
318
- }
319
- toggle() {
320
- return this.paused ? this.resume() : this.pause();
321
- }
322
- settle() {
323
- for (let e of this.getEntries()) e.animation.managed = !1, e.animation.settle();
324
- return this.started = !1, this.done = !1, this.paused = !1, this.lastTickTime = 0, this;
325
- }
326
- reset() {
327
- for (let e of this.getEntries()) {
328
- let t = e.animation;
329
- t.started && t.frames.length > 0 && t.interpFrames(0, !0);
330
- }
331
- return this.settle();
332
- }
333
- stop() {
334
- return this.playback.stop(), this.reset(), this._resolvePlay(), this;
335
- }
336
- playing() {
337
- return !(!this.started || this.paused);
338
- }
339
- setLayerConfig(e, t) {
340
- return D(this, e, t), this;
341
- }
342
- setLayerEnabled(e, t) {
343
- return this.setLayerConfig(e, { enabled: t });
344
- }
345
- getLayerConfig(e) {
346
- return O(this, e);
347
- }
348
- transitionLayer(e, t) {
349
- return k(this, e, t), this;
350
- }
351
- crossfade(e, t, n) {
352
- return A(this, e, t, n), this;
353
- }
354
- advanceLayerSprings(e) {
355
- this._hasLayerSprings = x(this.getEntries(), e);
356
- }
357
- }, M = /* @__PURE__ */ e({ AnimationGroup: () => j });
358
- i((e, ...t) => new j(e, ...t));
359
- //#endregion
360
- export { j as n, M as t };