@mkbabb/keyframes.js 4.2.0 → 4.4.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,442 @@
1
+ import { n as e, t } from "./errors-W8zkvPw4.js";
2
+ //#region src/animation/easing.ts
3
+ var n = (e) => typeof e == "function" ? { fn: e } : e, r = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, i = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, a = (e) => {
4
+ let t = e.trim();
5
+ if (r.test(t) || i.test(t)) return t;
6
+ };
7
+ async function o(t) {
8
+ let n;
9
+ try {
10
+ n = await import("./engine-CNHvTgpw.js");
11
+ } catch (e) {
12
+ throw Error(`keyframes: the engine chunk failed to load while resolving easing "${t}" — the easing registry is unreachable.`, { cause: e });
13
+ }
14
+ let r = n.getTimingFunction(t);
15
+ if (!r) throw new e(t);
16
+ let i = { fn: r }, o = a(t);
17
+ return o && (i.css = o), i;
18
+ }
19
+ //#endregion
20
+ //#region src/animation/internal/leaves.ts
21
+ var s = 1e3 / 60;
22
+ function c(e, t, n) {
23
+ return Math.min(Math.max(e, t), n);
24
+ }
25
+ function l(e, t, n, r = 0, i = 1) {
26
+ if (n === t) throw Error("fromMax and fromMin cannot be equal");
27
+ let a = (i - r) / (n - t);
28
+ return (e - t) * a + r;
29
+ }
30
+ function u(e, t, n, r) {
31
+ let i = e.length, a = 1 - n;
32
+ for (let o = 0; o < i; o++) r[o] = a * e[o] + n * t[o];
33
+ return r;
34
+ }
35
+ function d(e) {
36
+ if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
37
+ let t = s, n = Date.now();
38
+ return setTimeout(() => {
39
+ let r = Date.now(), i = r - n;
40
+ n = r, t = Math.max(0, s - i), e(r);
41
+ }, t);
42
+ }
43
+ function f(e) {
44
+ if (e != null) {
45
+ if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
46
+ clearTimeout(e);
47
+ }
48
+ }
49
+ //#endregion
50
+ //#region src/animation/internal/reduced-motion.ts
51
+ var p = "(prefers-reduced-motion: reduce)", m = null, h;
52
+ function g() {
53
+ let e = typeof window > "u" ? void 0 : window.matchMedia;
54
+ return typeof e == "function" ? m !== null && h === e ? m : (h = e, m = e.call(window, p), m) : (m = null, h = e, null);
55
+ }
56
+ function _() {
57
+ return g()?.matches ?? !1;
58
+ }
59
+ function v(e) {
60
+ return e === !1 || e === void 0 || !_() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
61
+ }
62
+ function y(e, t, n) {
63
+ return !e && e !== 0 || !_() ? n() : e === !0 || e === 0 ? t() : n();
64
+ }
65
+ //#endregion
66
+ //#region src/animation/playback.ts
67
+ var b = class {
68
+ _rafId = null;
69
+ _startTime = void 0;
70
+ _lastFrameT = 0;
71
+ _resolve = null;
72
+ _gen = 0;
73
+ get running() {
74
+ return this._rafId !== null;
75
+ }
76
+ _run(e) {
77
+ let t = ++this._gen, n = (e) => {
78
+ t === this._gen && (e ? this._rafId = d(r) : this._cleanup());
79
+ }, r = (t) => {
80
+ let r = e(t);
81
+ r && typeof r.then == "function" ? r.then(n) : n(r);
82
+ };
83
+ this._rafId = d(r);
84
+ }
85
+ play = (e, t, n) => {
86
+ if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
87
+ return this.stop(), y(n?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((n) => {
88
+ this._resolve = n, this._startTime = void 0, this._run((n) => {
89
+ this._startTime === void 0 && (this._startTime = n);
90
+ let r = c((n - this._startTime) / e, 0, 1);
91
+ return t(r), r < 1;
92
+ });
93
+ }));
94
+ };
95
+ drive = (e, t) => {
96
+ this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
97
+ let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
98
+ return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
99
+ }));
100
+ };
101
+ loop = (e) => {
102
+ this.stop(), this._run(e);
103
+ };
104
+ stop = () => {
105
+ this._gen++, this._rafId !== null && f(this._rafId), this._cleanup();
106
+ };
107
+ _cleanup() {
108
+ this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
109
+ let e = this._resolve;
110
+ this._resolve = null, e?.();
111
+ }
112
+ }, x = {
113
+ damping: .1,
114
+ snapThreshold: .001,
115
+ targetEpsilon: 0,
116
+ initial: 0,
117
+ clamp: !0,
118
+ respectReducedMotion: !1
119
+ }, S = class {
120
+ options;
121
+ targetValue;
122
+ currentValue;
123
+ isSettled;
124
+ _playback = new b();
125
+ _onFrame = void 0;
126
+ constructor(e) {
127
+ this.options = {
128
+ ...x,
129
+ ...e
130
+ }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
131
+ }
132
+ get target() {
133
+ return this.targetValue;
134
+ }
135
+ get current() {
136
+ return this.currentValue;
137
+ }
138
+ get settled() {
139
+ return this.isSettled;
140
+ }
141
+ setTarget(e) {
142
+ this.options.clamp && (e = c(e, 0, 1));
143
+ let t = Math.abs(e - this.targetValue);
144
+ t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
145
+ this.isSettled = !1, this._onFrame && this._startLoop();
146
+ }));
147
+ }
148
+ _snapSettled() {
149
+ this.currentValue = this.targetValue, this.isSettled = !0, this._onFrame?.(this.currentValue), this._playback.stop();
150
+ }
151
+ tickDt(e) {
152
+ if (this.isSettled) return this.currentValue;
153
+ let t = 1 - Math.exp(-this.options.damping * e / 16.667);
154
+ return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = c(this.currentValue, 0, 1)), this.currentValue;
155
+ }
156
+ snap() {
157
+ this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
158
+ }
159
+ reset(e) {
160
+ let t = e ?? 0;
161
+ this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
162
+ }
163
+ play(e) {
164
+ this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
165
+ if (this.isSettled) {
166
+ e?.(this.currentValue);
167
+ return;
168
+ }
169
+ this._startLoop();
170
+ });
171
+ }
172
+ stop() {
173
+ this._onFrame = void 0, this._playback.stop();
174
+ }
175
+ _startLoop() {
176
+ this._playback.drive(this, () => this._onFrame?.(this.currentValue));
177
+ }
178
+ };
179
+ //#endregion
180
+ //#region src/animation/spring-duration.ts
181
+ function C(e) {
182
+ let { visualDuration: t, duration: n, bounce: r = 0, ...i } = e, a = t ?? n ?? .5, o = 1 - c(r, -1, 1);
183
+ return {
184
+ ...i,
185
+ response: a,
186
+ dampingFraction: o
187
+ };
188
+ }
189
+ //#endregion
190
+ //#region src/animation/spring-reseat.ts
191
+ function w(e) {
192
+ let t = e.curr.time - e.prev.time;
193
+ return t <= 0 ? 0 : (e.curr.value - e.prev.value) / (t / 1e3);
194
+ }
195
+ function T(e, t, n) {
196
+ let r = w(e), i = new O({
197
+ ...n,
198
+ initial: e.curr.value,
199
+ initialVelocity: r
200
+ });
201
+ return i.target = t, i;
202
+ }
203
+ //#endregion
204
+ //#region src/animation/spring.ts
205
+ var E = new Float64Array(), D = {
206
+ response: .5,
207
+ dampingFraction: .86,
208
+ initial: 0,
209
+ initialVelocity: 0,
210
+ settleThreshold: .001,
211
+ velocitySettleThreshold: .001,
212
+ respectReducedMotion: !1
213
+ }, O = class e {
214
+ options;
215
+ targetValue;
216
+ currentValue;
217
+ currentVelocity;
218
+ isSettled;
219
+ elapsed;
220
+ originValue;
221
+ originVelocity;
222
+ amplitudeScale = 1;
223
+ omega;
224
+ zeta;
225
+ omegaD;
226
+ subscribers = /* @__PURE__ */ new Set();
227
+ disposed = !1;
228
+ vecOrigin = null;
229
+ vecOriginVel = null;
230
+ vecTarget = null;
231
+ vecCurrent = null;
232
+ vecVelocity = null;
233
+ vecElapsed = 0;
234
+ _playback = new b();
235
+ _onFrame = void 0;
236
+ constructor(e) {
237
+ this.options = {
238
+ ...D,
239
+ ...e
240
+ }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.currentVelocity = this.options.initialVelocity, this.isSettled = this.options.initialVelocity === 0, this.elapsed = 0, this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.amplitudeScale = v(this.options.respectReducedMotion), this.omega = 2 * Math.PI / this.options.response, this.zeta = this.options.dampingFraction, this.omegaD = this.zeta < 1 ? this.omega * Math.sqrt(1 - this.zeta * this.zeta) : 0;
241
+ }
242
+ static fromDuration(t) {
243
+ return new e(C(t ?? {}));
244
+ }
245
+ get target() {
246
+ return this.targetValue;
247
+ }
248
+ get value() {
249
+ return this.currentValue;
250
+ }
251
+ get velocity() {
252
+ return this.currentVelocity;
253
+ }
254
+ get settled() {
255
+ return this.isSettled;
256
+ }
257
+ set target(e) {
258
+ e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
259
+ }
260
+ reseatTarget(e) {
261
+ this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
262
+ this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = v(this.options.respectReducedMotion), this._onFrame && this._startLoop();
263
+ });
264
+ }
265
+ _snapSettled() {
266
+ this.currentValue = this.targetValue, this.currentVelocity = 0, this.originValue = this.targetValue, this.originVelocity = 0, this.elapsed = 0, this.isSettled = !0, this.emit(), this._playback.stop();
267
+ }
268
+ tickDt(e) {
269
+ return this._stepSeconds(e / 1e3);
270
+ }
271
+ _stepSeconds(e) {
272
+ return this.disposed || this.isSettled || e <= 0 ? this.currentValue : (this.elapsed += e, this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
273
+ }
274
+ tickToTime(e) {
275
+ return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
276
+ }
277
+ evaluateAt(e) {
278
+ let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, a = this.omega, o = this.zeta, s, c;
279
+ if (o < 1) {
280
+ let t = this.omegaD, n = Math.exp(-o * a * e), l = r, u = (i + o * a * r) / t, d = Math.cos(t * e), f = Math.sin(t * e);
281
+ s = n * (l * d + u * f), c = n * ((u * t - l * o * a) * d - (l * t + u * o * a) * f);
282
+ } else if (o === 1) {
283
+ let t = Math.exp(-a * e), n = r, o = i + a * r;
284
+ s = t * (n + o * e), c = t * (o - a * (n + o * e));
285
+ } else {
286
+ let t = a * Math.sqrt(o * o - 1), n = -o * a + t, l = -o * a - t, u = (i - l * r) / (n - l), d = r - u, f = Math.exp(n * e), p = Math.exp(l * e);
287
+ s = u * f + d * p, c = u * n * f + d * l * p;
288
+ }
289
+ this.currentValue = n + s, this.currentVelocity = c;
290
+ }
291
+ checkSettled() {
292
+ let e = this.amplitudeScale, t = this.originValue + e * (this.targetValue - this.originValue), n = Math.abs(this.currentValue - t), r = Math.abs(this.currentVelocity);
293
+ n < this.options.settleThreshold && r < this.options.velocitySettleThreshold && (this.currentValue = t, this.currentVelocity = 0, this.isSettled = !0);
294
+ }
295
+ snap() {
296
+ this._snapSettled();
297
+ }
298
+ reset(e, t) {
299
+ let n = e ?? 0, r = t ?? 0;
300
+ 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();
301
+ }
302
+ setTargets(e) {
303
+ let t = e.length;
304
+ if (this.vecTarget === null) this.vecOrigin = new Float64Array(t), this.vecOriginVel = new Float64Array(t), this.vecTarget = new Float64Array(t), this.vecCurrent = new Float64Array(t), this.vecVelocity = new Float64Array(t);
305
+ else if (this.vecTarget.length !== t) throw RangeError(`setTargets length ${t} does not match the armed lane count ${this.vecTarget.length}; the lane buffers are stable references — construct a new SpringProgress for a new arity.`);
306
+ this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
307
+ }
308
+ get values() {
309
+ return this.vecCurrent ?? E;
310
+ }
311
+ get velocities() {
312
+ return this.vecVelocity ?? E;
313
+ }
314
+ tickVector(e) {
315
+ if (this.disposed || this.vecTarget === null || e <= 0) return this.values;
316
+ this.vecElapsed += e / 1e3;
317
+ let t = this.vecElapsed, n = this.omega, r = this.zeta, i = this.omegaD, a = this.vecOrigin, o = this.vecOriginVel, s = this.vecTarget, c = this.vecCurrent, l = this.vecVelocity, u = r < 1 ? Math.exp(-r * n * t) : 0, d = r < 1 ? Math.cos(i * t) : 0, f = r < 1 ? Math.sin(i * t) : 0, p = r === 1 ? Math.exp(-n * t) : 0, m = 0, h = 0, g = 0, _ = 0;
318
+ if (r > 1) {
319
+ let e = n * Math.sqrt(r * r - 1);
320
+ m = -r * n + e, h = -r * n - e, g = Math.exp(m * t), _ = Math.exp(h * t);
321
+ }
322
+ for (let e = 0; e < c.length; e++) {
323
+ let v = a[e] - s[e], y = o[e], b, x;
324
+ if (r < 1) {
325
+ let e = v, t = (y + r * n * v) / i;
326
+ b = u * (e * d + t * f), x = u * ((t * i - e * r * n) * d - (e * i + t * r * n) * f);
327
+ } else if (r === 1) {
328
+ let e = v, r = y + n * v;
329
+ b = p * (e + r * t), x = p * (r - n * (e + r * t));
330
+ } else {
331
+ let e = (y - h * v) / (m - h), t = v - e;
332
+ b = e * g + t * _, x = e * m * g + t * h * _;
333
+ }
334
+ c[e] = s[e] + b, l[e] = x;
335
+ }
336
+ return c;
337
+ }
338
+ subscribe(e) {
339
+ return this.subscribers.add(e), () => {
340
+ this.subscribers.delete(e);
341
+ };
342
+ }
343
+ emit() {
344
+ if (this.subscribers.size !== 0) for (let e of this.subscribers) e(this.currentValue, this.currentVelocity);
345
+ }
346
+ dispose() {
347
+ this.disposed = !0, this._playback.stop(), this.subscribers.clear();
348
+ }
349
+ play(e) {
350
+ this.disposed || (this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
351
+ if (this.isSettled) {
352
+ e?.(this.currentValue, this.currentVelocity);
353
+ return;
354
+ }
355
+ this._startLoop();
356
+ }));
357
+ }
358
+ stop() {
359
+ this._onFrame = void 0, this._playback.stop();
360
+ }
361
+ _startLoop() {
362
+ this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
363
+ }
364
+ }, k = class {
365
+ smoother;
366
+ _easingFn;
367
+ currentProgress = 0;
368
+ boundaryEpsilon;
369
+ constructor(e) {
370
+ this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
371
+ let r = e?.easing;
372
+ if (typeof r == "string") throw new t("easing", r, "Timeline accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
373
+ this._easingFn = r == null ? (e) => e : n(r).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new S(e?.smoothing);
374
+ }
375
+ applyPipeline() {
376
+ let e = c(this.sample(), 0, 1);
377
+ e = this._easingFn(e);
378
+ let t = this.boundaryEpsilon;
379
+ return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
380
+ }
381
+ _advance(e) {
382
+ let t = this.applyPipeline();
383
+ return this.smoother ? (this.smoother.setTarget(t), t <= 0 || t >= 1 ? this.smoother.snap() : this.smoother.tickDt(e), this.currentProgress = this.smoother.current) : this.currentProgress = t, this.currentProgress;
384
+ }
385
+ tick() {
386
+ return this._advance(16.667);
387
+ }
388
+ tickDt(e) {
389
+ return this._advance(e);
390
+ }
391
+ get progress() {
392
+ return this.currentProgress;
393
+ }
394
+ get settled() {
395
+ return this.smoother == null || this.smoother.settled;
396
+ }
397
+ snap() {
398
+ this.smoother?.snap(), this.smoother && (this.currentProgress = this.smoother.current);
399
+ }
400
+ reset(e) {
401
+ let t = e ?? 0;
402
+ this.smoother && this.smoother.reset(t), this.currentProgress = t;
403
+ }
404
+ }, A = class extends k {
405
+ threshold;
406
+ getScrollY;
407
+ getViewportHeight;
408
+ constructor(e) {
409
+ super(e), this.threshold = e?.threshold ?? .35, this.getScrollY = e?.getScrollY ?? (() => window.scrollY), this.getViewportHeight = e?.getViewportHeight ?? (() => window.innerHeight);
410
+ }
411
+ sample() {
412
+ let e = this.getViewportHeight() * this.threshold;
413
+ return e <= 0 ? 0 : this.getScrollY() / e;
414
+ }
415
+ }, j = class extends k {
416
+ value = 0;
417
+ constructor(e) {
418
+ super({
419
+ smoothing: !1,
420
+ ...e
421
+ });
422
+ }
423
+ set(e) {
424
+ this.value = e;
425
+ }
426
+ sample() {
427
+ return this.value;
428
+ }
429
+ };
430
+ function M(e) {
431
+ if (typeof window > "u") return null;
432
+ if (e.kind === "scroll") {
433
+ if (globalThis.ScrollTimeline === void 0) return null;
434
+ let t = {};
435
+ return e.source !== void 0 && (t.source = e.source), e.axis !== void 0 && (t.axis = e.axis), new globalThis.ScrollTimeline(t);
436
+ }
437
+ if (globalThis.ViewTimeline === void 0) return null;
438
+ let t = { subject: e.subject };
439
+ return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
440
+ }
441
+ //#endregion
442
+ export { n as _, O as a, S as c, y as d, c as f, o as g, a as h, M as i, b as l, l as m, j as n, w as o, u as p, k as r, T as s, A as t, v as u };
@@ -0,0 +1,97 @@
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { CSSCubicBezier as t, FunctionValue as n, ValueArray as r, ValueUnit as i, cssLinear as a, flattenObject as o, functionIdentityValue as s, memoize as c, normalizeValueUnits as l, parseCSSSubValue as u, parseLinearStops as d, parseSteps as f, prepareInterpVar as p, steppedEase as m, timingFunctions as h, unflattenObjectToString as g } from "@mkbabb/value.js";
3
+ //#region src/animation/utils.ts
4
+ var _ = /* @__PURE__ */ e({
5
+ calcFrameTime: () => j,
6
+ createInterpVarValue: () => A,
7
+ getTimingFunction: () => D,
8
+ parseAndFlattenObject: () => k,
9
+ transformTargetsStyle: () => N
10
+ }), v = /* @__PURE__ */ new WeakMap(), y = (e) => v.get(e), b = (e, t) => (t !== void 0 && v.set(e, t), e), x = (e, t) => {
11
+ if (e instanceof i) return [b(e.clone(), t ?? y(e))];
12
+ if (e instanceof n) return e.values.flatMap((t) => x(t, e.name));
13
+ if (e instanceof r) return e.flatMap((e) => x(e, t));
14
+ throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
15
+ }, S = (e) => {
16
+ let t = e.split(".").pop(), n = e.split(".").shift();
17
+ if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
18
+ return {
19
+ mainKey: n,
20
+ childKey: t
21
+ };
22
+ }, C = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), w = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, T = /^\s*steps\s*\(/i, E = /^\s*linear\s*\(/i, D = (e) => {
23
+ if (e == null) return;
24
+ if (typeof e != "string") return e;
25
+ let n = e.match(w);
26
+ if (n) {
27
+ let e = n.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
28
+ if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
29
+ let [n, r, i, a] = e;
30
+ return t(n, r, i, a);
31
+ }
32
+ }
33
+ if (T.test(e)) try {
34
+ let { count: t, jumpTerm: n } = f(e);
35
+ return m(t, n);
36
+ } catch {}
37
+ if (e === "step-start") return m(1, "jump-start");
38
+ if (e === "step-end") return m(1, "jump-end");
39
+ if (E.test(e)) try {
40
+ return a(d(e));
41
+ } catch {}
42
+ let r = h[e];
43
+ if (typeof r == "function" && r.length <= 1) return r;
44
+ }, O = c((e, t) => x(u(t, { subProperty: e })), {
45
+ maxCacheSize: 2048,
46
+ keyFn: (e, t) => `${e}:${t}`
47
+ });
48
+ function k(e) {
49
+ let t = o(e), a = (e, t) => {
50
+ let { childKey: o, mainKey: s } = S(e);
51
+ return t instanceof i ? C(new r(...x(t)), s, o) : t instanceof n ? C(new r(...t.values.flatMap((n) => x(a(e, n), t.name))), s, o) : t instanceof r ? C(new r(...t.flatMap((t) => x(a(e, t)))), s, o) : C(new r(...O(o, String(t)).map((e) => b(e.clone(), y(e)))), s, o);
52
+ };
53
+ return Object.entries(t).reduce((e, [t, n]) => (e[t] = a(t, n), e), {});
54
+ }
55
+ var A = (e, t, n, r, a = "oklab", o) => {
56
+ let c = r[t], u = r[n];
57
+ if (!c || !u) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
58
+ let d = c[e], f = u[e];
59
+ if (!d || !f) throw Error(`Missing variable "${e}" in interpolation bounds.`);
60
+ let m = Math.max(d.length, f.length), h = (t, n) => {
61
+ let r = t.map((t) => {
62
+ if (!(t instanceof i)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
63
+ return t;
64
+ });
65
+ for (; r.length < m;) {
66
+ let e = n[r.length], t = e instanceof i ? y(e) : void 0, a = t ? s(t) : void 0;
67
+ r.push(a ?? new i(0));
68
+ }
69
+ return r;
70
+ }, g = h(d, f), _ = h(f, d);
71
+ return g.map((t, n) => {
72
+ let r = _[n];
73
+ if (!r) throw Error(`Missing right-hand interpolation value at index ${n}.`);
74
+ if (!(t instanceof i) || !(r instanceof i)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
75
+ let s = { colorSpace: a };
76
+ return o !== void 0 && (s.hueMethod = o), p(l(t, r, s));
77
+ });
78
+ };
79
+ function j(e, t, n) {
80
+ let [r, i] = [e.start, t.start];
81
+ return {
82
+ start: r.value * n / 100,
83
+ stop: i.value * n / 100
84
+ };
85
+ }
86
+ var M = {};
87
+ function N(e, t, n = !0) {
88
+ e = n ? e : o(e);
89
+ let r = g(e, M);
90
+ t.forEach((e) => {
91
+ Object.entries(r).forEach(([t, n]) => {
92
+ e.style.setProperty(t, n);
93
+ });
94
+ });
95
+ }
96
+ //#endregion
97
+ export { N as a, k as i, A as n, _ as o, D as r, j as t };
@@ -0,0 +1,35 @@
1
+ import { n as e } from "./waapi-D9MHMm_9.js";
2
+ import { CSSKeyframesAnimation as t } from "./engine-CNHvTgpw.js";
3
+ import { compileToCSS as n } from "./compile-DgNRG6Lo.js";
4
+ import { extractKeyframes as r, parseCSSStylesheet as i } from "@mkbabb/value.js";
5
+ //#region src/animation/validate.ts
6
+ var a = (e) => new t().fromString(e);
7
+ async function o(t, r = {}) {
8
+ let i = a(t), o = [...i.diagnostics], s = o.some((e) => e.code === "PARSE_ERROR" || e.code === "EMPTY_PARSE"), c = t.trim().length > 0 && !s, l = await n([i], r.compile ?? {}), u = e(i);
9
+ return {
10
+ parseable: c,
11
+ eligible: l.eligible,
12
+ refusals: l.refusals,
13
+ diagnostics: o,
14
+ waapi: u
15
+ };
16
+ }
17
+ var s = (e) => {
18
+ try {
19
+ return [...r(i(e)).keys()];
20
+ } catch {
21
+ return [];
22
+ }
23
+ };
24
+ async function c(e, t = {}) {
25
+ let n = await o(e, t), r = s(e), i = r.length > 0 ? r.join(", ") : "(no @keyframes block)", a = [];
26
+ a.push(`@keyframes ${i}:`), a.push(` parseable: ${n.parseable ? "yes" : "no"}`), a.push(` compile-eligible: ${n.eligible ? "yes" : "no"}`);
27
+ for (let e of n.refusals) a.push(` – ${e.reason}: ${e.message}`);
28
+ if (a.push(` waapi-eligible: ${n.waapi.eligible ? "yes" : "no"}`), n.waapi.eligible || a.push(` – ${n.waapi.reason}`), n.diagnostics.length > 0) {
29
+ a.push(" diagnostics:");
30
+ for (let e of n.diagnostics) a.push(` – ${e.code}: ${e.message}`);
31
+ }
32
+ return a.join("\n");
33
+ }
34
+ //#endregion
35
+ export { c as explain, o as validate };