@mkbabb/keyframes.js 6.4.0 → 6.5.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.
@@ -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("./registry-Bs7A0T_s.js");
30
+ t = await import("./registry-BgJd9srG.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
  }
@@ -42,7 +42,7 @@ async function d(e) {
42
42
  }
43
43
  //#endregion
44
44
  //#region src/animation/internal/binary-search.ts
45
- function ee(e, t, n, r) {
45
+ function f(e, t, n, r) {
46
46
  let i = 0, a = e.length - 1;
47
47
  for (; i <= a;) {
48
48
  let o = i + a >> 1, s = e[o];
@@ -54,16 +54,16 @@ function ee(e, t, n, r) {
54
54
  }
55
55
  //#endregion
56
56
  //#region src/animation/internal/leaves.ts
57
- var f = 1e3 / 60;
58
- function p(e) {
57
+ var p = 1e3 / 60;
58
+ function m(e) {
59
59
  if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
60
- let t = f, n = Date.now();
60
+ let t = p, n = Date.now();
61
61
  return setTimeout(() => {
62
62
  let r = Date.now(), i = r - n;
63
- n = r, t = Math.max(0, f - i), e(r);
63
+ n = r, t = Math.max(0, p - i), e(r);
64
64
  }, t);
65
65
  }
66
- function m(e) {
66
+ function h(e) {
67
67
  if (e != null) {
68
68
  if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
69
69
  clearTimeout(e);
@@ -71,23 +71,23 @@ function m(e) {
71
71
  }
72
72
  //#endregion
73
73
  //#region src/animation/internal/reduced-motion.ts
74
- var te = "(prefers-reduced-motion: reduce)", h = null, g;
75
- function ne() {
74
+ var g = "(prefers-reduced-motion: reduce)", _ = null, v;
75
+ function y() {
76
76
  let e = typeof window > "u" ? void 0 : window.matchMedia;
77
- return typeof e == "function" ? h !== null && g === e ? h : (g = e, h = e.call(window, te), h) : (h = null, g = e, null);
77
+ return typeof e == "function" ? _ !== null && v === e ? _ : (v = e, _ = e.call(window, g), _) : (_ = null, v = e, null);
78
78
  }
79
- function _() {
80
- return ne()?.matches ?? !1;
79
+ function b() {
80
+ return y()?.matches ?? !1;
81
81
  }
82
- function v(e) {
83
- return e === !1 || e === void 0 || !_() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
82
+ function x(e) {
83
+ return e === !1 || e === void 0 || !b() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
84
84
  }
85
- function y(e, t, n) {
86
- return !e && e !== 0 || !_() ? n() : e === !0 || e === 0 ? t() : n();
85
+ function S(e, t, n) {
86
+ return !e && e !== 0 || !b() ? n() : e === !0 || e === 0 ? t() : n();
87
87
  }
88
88
  //#endregion
89
89
  //#region src/animation/physics/playback.ts
90
- var b = class {
90
+ var C = class {
91
91
  _rafId = null;
92
92
  _startTime = void 0;
93
93
  _lastFrameT = 0;
@@ -98,7 +98,7 @@ 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(i) : this._cleanup());
101
+ t === this._gen && (e ? this._rafId = m(i) : this._cleanup());
102
102
  }, r = (e) => {
103
103
  throw n(!1), e;
104
104
  }, i = (t) => {
@@ -111,11 +111,11 @@ var b = class {
111
111
  }
112
112
  i && typeof i.then == "function" ? i.then(n, r) : n(i);
113
113
  };
114
- this._rafId = p(i);
114
+ this._rafId = m(i);
115
115
  }
116
116
  play = (t, n, r) => {
117
117
  if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
118
- return this.stop(), y(r?.respectReducedMotion, () => (n(1), Promise.resolve()), () => new Promise((r) => {
118
+ return this.stop(), S(r?.respectReducedMotion, () => (n(1), Promise.resolve()), () => new Promise((r) => {
119
119
  this._resolve = r, this._startTime = void 0, this._run((r) => {
120
120
  this._startTime === void 0 && (this._startTime = r);
121
121
  let i = e((r - this._startTime) / t, 0, 1);
@@ -133,7 +133,7 @@ var b = class {
133
133
  this.stop(), this._run(e);
134
134
  };
135
135
  stop = () => {
136
- this._gen++, this._rafId !== null && m(this._rafId), this._cleanup();
136
+ this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
137
137
  };
138
138
  _cleanup() {
139
139
  this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
@@ -143,34 +143,34 @@ var b = class {
143
143
  };
144
144
  //#endregion
145
145
  //#region src/animation/physics/managed-stepper.ts
146
- function x(e) {
146
+ function w(e) {
147
147
  e._playback.drive(e, () => e._emitManagedFrame());
148
148
  }
149
- function S(e, t) {
150
- e.disposed || (e._onFrame = t, y(e.respectReducedMotion, () => {
149
+ function T(e, t) {
150
+ e.disposed || (e._onFrame = t, S(e.respectReducedMotion, () => {
151
151
  e.snap(), e._emitManagedFrame();
152
152
  }, () => {
153
- e.settled ? e._emitManagedFrame() : x(e);
153
+ e.settled ? e._emitManagedFrame() : w(e);
154
154
  }));
155
155
  }
156
- function C(e) {
156
+ function E(e) {
157
157
  e._onFrame = void 0, e._playback.stop();
158
158
  }
159
159
  //#endregion
160
160
  //#region src/animation/physics/smooth.ts
161
- var w = {
161
+ var D = {
162
162
  damping: .1,
163
163
  snapThreshold: .001,
164
164
  targetEpsilon: 0,
165
165
  initial: 0,
166
166
  clamp: !0,
167
167
  respectReducedMotion: !1
168
- }, T = class {
168
+ }, O = class {
169
169
  options;
170
170
  targetValue;
171
171
  currentValue;
172
172
  isSettled;
173
- _playback = new b();
173
+ _playback = new C();
174
174
  _onFrame = void 0;
175
175
  get respectReducedMotion() {
176
176
  return this.options.respectReducedMotion;
@@ -180,7 +180,7 @@ var w = {
180
180
  }
181
181
  constructor(e) {
182
182
  this.options = {
183
- ...w,
183
+ ...D,
184
184
  ...e
185
185
  }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
186
186
  }
@@ -196,8 +196,8 @@ var w = {
196
196
  setTarget(t) {
197
197
  this.options.clamp && (t = e(t, 0, 1));
198
198
  let n = Math.abs(t - this.targetValue);
199
- n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
200
- this.isSettled = !1, this._onFrame && x(this);
199
+ n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
200
+ this.isSettled = !1, this._onFrame && w(this);
201
201
  }));
202
202
  }
203
203
  _snapSettled() {
@@ -216,12 +216,12 @@ var w = {
216
216
  this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
217
217
  }
218
218
  play(e) {
219
- S(this, e);
219
+ T(this, e);
220
220
  }
221
221
  stop() {
222
- C(this);
222
+ E(this);
223
223
  }
224
- }, E = {
224
+ }, k = {
225
225
  response: .5,
226
226
  dampingFraction: .86,
227
227
  initial: 0,
@@ -232,18 +232,18 @@ var w = {
232
232
  };
233
233
  //#endregion
234
234
  //#region src/animation/physics/spring/managed-play.ts
235
- function D(e) {
236
- x(e);
235
+ function ee(e) {
236
+ w(e);
237
237
  }
238
- function O(e, t) {
239
- S(e, t);
238
+ function te(e, t) {
239
+ T(e, t);
240
240
  }
241
- function re(e) {
242
- C(e);
241
+ function ne(e) {
242
+ E(e);
243
243
  }
244
244
  //#endregion
245
245
  //#region src/animation/physics/spring/solver/duration.ts
246
- function ie(t) {
246
+ function A(t) {
247
247
  let { visualDuration: n, duration: r, bounce: i = 0, ...a } = t, o = n ?? r ?? .5, s = 1 - e(i, -1, 1);
248
248
  return {
249
249
  ...a,
@@ -253,7 +253,7 @@ function ie(t) {
253
253
  }
254
254
  //#endregion
255
255
  //#region src/animation/physics/spring/solver/solver.ts
256
- function k(e, t, n, r) {
256
+ function j(e, t, n, r) {
257
257
  if (t < 1) return {
258
258
  regime: "under",
259
259
  w: e,
@@ -278,7 +278,7 @@ function k(e, t, n, r) {
278
278
  e2: Math.exp(o * r)
279
279
  };
280
280
  }
281
- function A(e, t, n, r = {
281
+ function M(e, t, n, r = {
282
282
  x: 0,
283
283
  v: 0
284
284
  }) {
@@ -293,12 +293,12 @@ function A(e, t, n, r = {
293
293
  let { r1: i, r2: a, e1: o, e2: s } = n, c = (t - a * e) / (i - a), l = e - c;
294
294
  return r.x = c * o + l * s, r.v = c * i * o + l * a * s, r;
295
295
  }
296
- function ae(e, t, n, r, i, a) {
297
- return A(e, t, k(n, r, i, a));
296
+ function N(e, t, n, r, i, a) {
297
+ return M(e, t, j(n, r, i, a));
298
298
  }
299
299
  //#endregion
300
300
  //#region src/animation/physics/spring/solver/vector.ts
301
- var j = new Float64Array(), oe = class {
301
+ var P = new Float64Array(), re = class {
302
302
  solution = {
303
303
  x: 0,
304
304
  v: 0
@@ -316,10 +316,10 @@ var j = new Float64Array(), oe = class {
316
316
  this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
317
317
  }
318
318
  get values() {
319
- return this.vecCurrent ?? j;
319
+ return this.vecCurrent ?? P;
320
320
  }
321
321
  get velocities() {
322
- return this.vecVelocity ?? j;
322
+ return this.vecVelocity ?? P;
323
323
  }
324
324
  get armed() {
325
325
  return this.vecTarget !== null;
@@ -327,32 +327,32 @@ var j = new Float64Array(), oe = class {
327
327
  tick(e, t, n, r) {
328
328
  if (this.vecTarget === null || e <= 0) return this.values;
329
329
  this.vecElapsed += e / 1e3;
330
- let i = this.vecElapsed, a = this.vecOrigin, o = this.vecOriginVel, s = this.vecTarget, c = this.vecCurrent, l = this.vecVelocity, u = k(t, n, r, i), d = this.solution;
330
+ let i = this.vecElapsed, a = this.vecOrigin, o = this.vecOriginVel, s = this.vecTarget, c = this.vecCurrent, l = this.vecVelocity, u = j(t, n, r, i), d = this.solution;
331
331
  for (let e = 0; e < c.length; e++) {
332
332
  let t = a[e] - s[e], n = o[e];
333
- A(t, n, u, d), c[e] = s[e] + d.x, l[e] = d.v;
333
+ M(t, n, u, d), c[e] = s[e] + d.x, l[e] = d.v;
334
334
  }
335
335
  return c;
336
336
  }
337
337
  };
338
338
  //#endregion
339
339
  //#region src/animation/physics/spring/vector-surface.ts
340
- function se(e, t) {
341
- let n = e ?? new oe();
340
+ function ie(e, t) {
341
+ let n = e ?? new re();
342
342
  return n.setTargets(t), n;
343
343
  }
344
- function ce(e) {
345
- return e?.values ?? j;
344
+ function ae(e) {
345
+ return e?.values ?? P;
346
346
  }
347
- function le(e) {
348
- return e?.velocities ?? j;
347
+ function oe(e) {
348
+ return e?.velocities ?? P;
349
349
  }
350
- function M(e, t, n, r, i) {
351
- return e === null || t <= 0 ? j : e.tick(t, n, r, i);
350
+ function se(e, t, n, r, i) {
351
+ return e === null || t <= 0 ? P : e.tick(t, n, r, i);
352
352
  }
353
353
  //#endregion
354
354
  //#region src/animation/physics/spring/progress.ts
355
- var N = class e {
355
+ var F = class e {
356
356
  options;
357
357
  get respectReducedMotion() {
358
358
  return this.options.respectReducedMotion;
@@ -371,19 +371,19 @@ var N = class e {
371
371
  subscribers = /* @__PURE__ */ new Set();
372
372
  disposed = !1;
373
373
  vectorLanes = null;
374
- _playback = new b();
374
+ _playback = new C();
375
375
  _onFrame = void 0;
376
376
  _emitManagedFrame() {
377
377
  this._onFrame?.(this.value, this.velocity);
378
378
  }
379
379
  constructor(e) {
380
380
  this.options = {
381
- ...E,
381
+ ...k,
382
382
  ...e
383
- }, 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;
383
+ }, 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 = x(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;
384
384
  }
385
385
  static fromDuration(t) {
386
- return new e(ie(t ?? {}));
386
+ return new e(A(t ?? {}));
387
387
  }
388
388
  get target() {
389
389
  return this.targetValue;
@@ -401,8 +401,8 @@ var N = class e {
401
401
  e === this.targetValue && this.currentVelocity === 0 || this.reseatTarget(e);
402
402
  }
403
403
  reseatTarget(e) {
404
- this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
405
- this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = v(this.options.respectReducedMotion), this._onFrame && D(this);
404
+ this.targetValue = e, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
405
+ this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = x(this.options.respectReducedMotion), this._onFrame && ee(this);
406
406
  });
407
407
  }
408
408
  _snapSettled() {
@@ -418,7 +418,7 @@ var N = class e {
418
418
  return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
419
419
  }
420
420
  evaluateAt(e) {
421
- let t = this.scaledTarget(), n = this.originValue - t, r = this.originVelocity, { x: i, v: a } = ae(n, r, this.omega, this.zeta, this.omegaD, e);
421
+ let t = this.scaledTarget(), n = this.originValue - t, r = this.originVelocity, { x: i, v: a } = N(n, r, this.omega, this.zeta, this.omegaD, e);
422
422
  this.currentValue = t + i, this.currentVelocity = a;
423
423
  }
424
424
  scaledTarget() {
@@ -434,19 +434,19 @@ var N = class e {
434
434
  }
435
435
  reset(e, t) {
436
436
  let n = e ?? 0, r = t ?? 0;
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();
437
+ this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale = x(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
438
438
  }
439
439
  setTargets(e) {
440
- this.vectorLanes = se(this.vectorLanes, e);
440
+ this.vectorLanes = ie(this.vectorLanes, e);
441
441
  }
442
442
  get values() {
443
- return ce(this.vectorLanes);
443
+ return ae(this.vectorLanes);
444
444
  }
445
445
  get velocities() {
446
- return le(this.vectorLanes);
446
+ return oe(this.vectorLanes);
447
447
  }
448
448
  tickVector(e) {
449
- return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : M(this.vectorLanes, e, this.omega, this.zeta, this.omegaD);
449
+ return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : se(this.vectorLanes, e, this.omega, this.zeta, this.omegaD);
450
450
  }
451
451
  subscribe(e) {
452
452
  return this.subscribers.add(e), () => {
@@ -460,86 +460,216 @@ var N = class e {
460
460
  this.disposed = !0, this._playback.stop(), this.subscribers.clear();
461
461
  }
462
462
  play(e) {
463
- O(this, e);
463
+ te(this, e);
464
464
  }
465
465
  stop() {
466
- re(this);
466
+ ne(this);
467
467
  }
468
- };
469
- //#endregion
470
- //#region src/animation/physics/spring/solver/sample.ts
471
- function P(e) {
472
- let t = new N({
468
+ }, ce = 12, le = .02;
469
+ function I(e) {
470
+ let t = e.initialVelocity ?? 0, n = new F({
473
471
  response: e.response,
474
472
  dampingFraction: e.dampingFraction,
475
473
  initial: 0,
474
+ initialVelocity: t,
476
475
  settleThreshold: e.settleThreshold,
477
476
  velocitySettleThreshold: e.settleThreshold
478
477
  });
479
- t.target = 1;
480
- let n = [];
481
- for (let r = 1; r <= e.sampleCount; r++) t._stepSeconds(e.dt), n.push(t.settled ? 1 : t.value);
482
- return t.dispose(), n;
478
+ n.target = 1;
479
+ let r = () => n.settled ? 1 : n.value, i = [], a = 0;
480
+ if (t !== 0) for (let t = ce; t >= 1; t--) {
481
+ let o = 2 ** -t;
482
+ n._stepSeconds(o * e.dt - a), a = o * e.dt, i.push([o, r()]);
483
+ }
484
+ let o = [];
485
+ for (let t = 1; t <= e.sampleCount; t++) n._stepSeconds(e.dt - a), a = 0, o.push(r());
486
+ if (n.dispose(), i.length > 0) {
487
+ let n = (n, r) => Math.abs(r / (n * e.dt) - t) <= le * Math.abs(t);
488
+ if (o.length > 0 && n(1, o[0])) i = [];
489
+ else {
490
+ let e = 0;
491
+ for (let t = i.length - 1; t >= 0; t--) if (n(i[t][0], i[t][1])) {
492
+ e = t;
493
+ break;
494
+ }
495
+ i = i.slice(e);
496
+ }
497
+ }
498
+ return {
499
+ positions: o,
500
+ head: i
501
+ };
502
+ }
503
+ //#endregion
504
+ //#region src/animation/physics/spring/solver/settle.ts
505
+ var ue = 4096, de = 20, L = 2 ** 32;
506
+ function R(e) {
507
+ let t = e.response, n = e.dampingFraction, r = e.initialVelocity ?? k.initialVelocity, i = e.settleThreshold ?? k.settleThreshold, a = e.velocitySettleThreshold ?? k.velocitySettleThreshold;
508
+ if (!(t > 0) || !Number.isFinite(t)) throw RangeError(`settleTime: response must be finite and > 0; got ${t}.`);
509
+ if (!(n >= 0) || !Number.isFinite(n)) throw RangeError(`settleTime: dampingFraction must be finite and >= 0; got ${n}.`);
510
+ if (!(i > 0) || !Number.isFinite(i)) throw RangeError(`settleTime: settleThreshold must be finite and > 0; got ${i}.`);
511
+ if (!(a > 0)) throw RangeError(`settleTime: velocitySettleThreshold must be > 0 (Infinity allowed); got ${a}.`);
512
+ if (!Number.isFinite(r)) throw RangeError(`settleTime: initialVelocity must be finite; got ${r}.`);
513
+ let o = 2 * Math.PI / t, s = n < 1 ? o * Math.sqrt(1 - n * n) : 0, c, l = (e) => c(e), u = 0;
514
+ if (n < 1) {
515
+ let e = (r + n * o * -1) / s, t = Math.hypot(-1, e);
516
+ c = (e) => {
517
+ let r = Math.exp(-n * o * e) * t;
518
+ return [r, r * o];
519
+ };
520
+ } else if (n === 1) {
521
+ let e = r + o * -1, t = Math.abs(e), n = Math.abs(e - o * -1);
522
+ u = 1 / o, c = (e) => {
523
+ let r = Math.exp(-o * e);
524
+ return [r * (1 + t * e), r * (n + o * t * e)];
525
+ }, l = (e, r) => {
526
+ let i = Math.exp(-o * e);
527
+ return [i * (1 + t * (e + r)), i * (n + o * t * (e + r))];
528
+ };
529
+ } else {
530
+ let e = o * Math.sqrt(n * n - 1), t = -n * o + e, i = -n * o - e, a = (r - i * -1) / (t - i), s = -1 - a;
531
+ c = (e) => {
532
+ let n = Math.abs(a) * Math.exp(t * e), r = Math.abs(s) * Math.exp(i * e);
533
+ return [n + r, n * -t + r * -i];
534
+ };
535
+ }
536
+ let d = (e) => {
537
+ let [t, n] = c(e);
538
+ return t < i && n < a;
539
+ }, f = u, p = Math.max(t, u);
540
+ for (; !d(p);) {
541
+ if (p > L * t) return Infinity;
542
+ f = p, p *= 2;
543
+ }
544
+ for (let e = 0; e < 30; e++) {
545
+ let e = (f + p) / 2;
546
+ d(e) ? p = e : f = e;
547
+ }
548
+ let m = {
549
+ x: 0,
550
+ v: 0
551
+ }, h = (e) => {
552
+ M(-1, r, j(o, n, s, e), m);
553
+ }, g = (e) => (h(e), !(Math.abs(m.x) < i && Math.abs(m.v) < a)), _ = (e, t) => {
554
+ h(e);
555
+ let [r, s] = l(e, t), c = o * o * r + 2 * n * o * s;
556
+ return Math.abs(m.x) + t * s < i && Math.abs(m.v) + t * c < a;
557
+ }, v = (e, t, n) => {
558
+ if (_(e, t - e)) return null;
559
+ if (n === 0) return g(e) ? [e, t] : null;
560
+ let r = (e + t) / 2;
561
+ return v(r, t, n - 1) ?? v(e, r, n - 1);
562
+ }, y = t / ue;
563
+ for (let e = p; e > 0;) {
564
+ let t = Math.max(0, e - y), n = v(t, e, de);
565
+ if (n) {
566
+ let [e, t] = n;
567
+ for (let n = 0; n < 40; n++) {
568
+ let n = (e + t) / 2;
569
+ g(n) ? e = n : t = n;
570
+ }
571
+ return t;
572
+ }
573
+ e = t;
574
+ }
575
+ return 0;
576
+ }
577
+ //#endregion
578
+ //#region src/animation/physics/spring/css/span.ts
579
+ function z(e) {
580
+ if (e.maxDuration !== "settle") return e.maxDuration ?? e.response * 4;
581
+ let t = R({
582
+ response: e.response,
583
+ dampingFraction: e.dampingFraction,
584
+ ...e.initialVelocity !== void 0 && { initialVelocity: e.initialVelocity },
585
+ ...e.settleThreshold !== void 0 && { settleThreshold: e.settleThreshold }
586
+ });
587
+ if (t === Infinity) throw RangeError(e.dampingFraction === 0 ? "maxDuration \"settle\": an undamped spring never settles; pass a finite maxDuration." : "maxDuration \"settle\": this spring never settles in floating-point arithmetic (damped so hard its slow root rounds to 0); pass a finite maxDuration.");
588
+ if (!(t > 0)) throw RangeError("maxDuration \"settle\": the spring starts at rest inside settleThreshold, so there is no span to take; pass a finite maxDuration.");
589
+ return t;
483
590
  }
484
591
  //#endregion
485
592
  //#region src/animation/physics/spring/css/linear-stops.ts
486
- function F(e) {
487
- let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = P({
593
+ function B(e) {
594
+ let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = z(e), { positions: i, head: a } = I({
488
595
  response: e.response,
489
596
  dampingFraction: e.dampingFraction,
490
597
  sampleCount: t,
491
598
  settleThreshold: n,
599
+ initialVelocity: e.initialVelocity ?? 0,
492
600
  dt: r / (t + 1)
493
- }), a = ["0"];
601
+ }), o = ["0"];
602
+ for (let [e, n] of a) {
603
+ let r = e / (t + 1) * 100;
604
+ o.push(`${n.toFixed(9)} ${r.toFixed(6)}%`);
605
+ }
494
606
  for (let e = 1; e <= t; e++) {
495
607
  let n = e / (t + 1) * 100, r = i[e - 1];
496
- a.push(`${r.toFixed(5)} ${n.toFixed(3)}%`);
608
+ o.push(`${r.toFixed(5)} ${n.toFixed(3)}%`);
497
609
  }
498
- return a.push("1"), `linear(${a.join(", ")})`;
610
+ return o.push("1"), `linear(${o.join(", ")})`;
499
611
  }
500
- var I = (e) => Math.round(e * 1e5) / 1e5;
501
- function L(e) {
612
+ var V = (e) => Math.round(e * 1e5) / 1e5;
613
+ function H(e) {
502
614
  let t = e.length - 1;
503
615
  if (t < 1) throw RangeError(`linearFromSamples needs at least 2 samples; got ${e.length}.`);
504
616
  let n = [];
505
- for (let r = 0; r <= t; r++) n.push(`${I(e[r])} ${I(r / t * 100)}%`);
617
+ for (let r = 0; r <= t; r++) n.push(`${V(e[r])} ${V(r / t * 100)}%`);
506
618
  return `linear(${n.join(", ")})`;
507
619
  }
508
620
  //#endregion
509
621
  //#region src/animation/physics/spring/css/timing-function.ts
510
- function R(e) {
511
- let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = P({
622
+ function fe(e) {
623
+ return U(e, z(e)).lut;
624
+ }
625
+ function U(e, t) {
626
+ let n = e.sampleCount ?? 64, r = e.settleThreshold ?? .001, { positions: i, head: a } = I({
512
627
  response: e.response,
513
628
  dampingFraction: e.dampingFraction,
514
- sampleCount: t,
515
- settleThreshold: n,
516
- dt: r / t
517
- }), a = new Float64Array(t + 1);
518
- a[0] = 0;
519
- for (let e = 1; e <= t; e++) a[e] = i[e - 1];
520
- return a[t] = 1, a;
629
+ sampleCount: n,
630
+ settleThreshold: r,
631
+ initialVelocity: e.initialVelocity ?? 0,
632
+ dt: t / n
633
+ }), o = new Float64Array(n + 1);
634
+ o[0] = 0;
635
+ for (let e = 1; e <= n; e++) o[e] = i[e - 1];
636
+ return o[n] = 1, {
637
+ lut: o,
638
+ head: a.map(([e, t]) => [e / n, t])
639
+ };
521
640
  }
522
- function z(e) {
523
- let t = R(e), n = t.length - 1, r = (e) => {
641
+ function pe(e) {
642
+ let t = z(e), { lut: n, head: r } = U(e, t), i = n.length - 1, a = [
643
+ [0, 0],
644
+ ...r,
645
+ [1 / i, n[1]]
646
+ ], o = (e) => {
524
647
  if (e <= 0) return 0;
525
648
  if (e >= 1) return 1;
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 = {
649
+ if (r.length > 0 && e < a[a.length - 1][0]) {
650
+ let t = 1;
651
+ for (; a[t][0] < e;) t++;
652
+ let [n, r] = a[t - 1], [i, o] = a[t];
653
+ return r + (o - r) * (e - n) / (i - n);
654
+ }
655
+ let t = e * i, o = Math.floor(t), s = t - o, c = n[o];
656
+ return c + (n[o + 1] - c) * s;
657
+ }, s = {
529
658
  response: e.response,
530
- dampingFraction: e.dampingFraction
659
+ dampingFraction: e.dampingFraction,
660
+ maxDuration: t
531
661
  };
532
- return e.settleThreshold !== void 0 && (i.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (i.maxDuration = e.maxDuration), {
533
- fn: r,
534
- css: F(i)
662
+ return e.settleThreshold !== void 0 && (s.settleThreshold = e.settleThreshold), e.initialVelocity !== void 0 && (s.initialVelocity = e.initialVelocity), {
663
+ fn: o,
664
+ css: B(s)
535
665
  };
536
666
  }
537
667
  //#endregion
538
668
  //#region src/animation/compile/emit/selector.ts
539
- var B = (e) => e.kind === "percent" ? `${e.value * 100}%` : e.offset === void 0 ? e.name : `${e.name} ${e.offset * 100}%`;
669
+ var me = (e) => e.kind === "percent" ? `${e.value * 100}%` : e.offset === void 0 ? e.name : `${e.name} ${e.offset * 100}%`;
540
670
  //#endregion
541
671
  //#region src/animation/orchestration/timeline/native.ts
542
- function V(e) {
672
+ function he(e) {
543
673
  if (typeof window > "u") return null;
544
674
  if (e.kind === "scroll") {
545
675
  if (globalThis.ScrollTimeline === void 0) return null;
@@ -552,9 +682,9 @@ function V(e) {
552
682
  }
553
683
  //#endregion
554
684
  //#region src/animation/physics/decay.ts
555
- var H = 5;
556
- function U(e) {
557
- let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? H;
685
+ var W = 5;
686
+ function ge(e) {
687
+ let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? W;
558
688
  if (r <= 0) throw Error("decay() requires a friction coefficient > 0.");
559
689
  let i = t + n / r;
560
690
  return (e) => {
@@ -569,8 +699,8 @@ function U(e) {
569
699
  };
570
700
  };
571
701
  }
572
- function W(e) {
573
- let t = e.friction ?? H;
702
+ function _e(e) {
703
+ let t = e.friction ?? W;
574
704
  if (t <= 0) throw Error("decayRest() requires a friction coefficient > 0.");
575
705
  return (e.initial ?? 0) + e.velocity / t;
576
706
  }
@@ -594,24 +724,24 @@ function q(e, t, n) {
594
724
  if (i === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
595
725
  return i;
596
726
  }
597
- function ue(t, n, r, i) {
727
+ function ve(t, n, r, i) {
598
728
  if (n <= 0) return 0;
599
729
  let a = e(t, 0, n * r), o = Math.floor(a / n), s = a - o * n;
600
730
  return s === 0 && o > 0 && (--o, s = n), i && o % 2 == 1 ? n - s : s;
601
731
  }
602
- function de(e, t, n) {
732
+ function ye(e, t, n) {
603
733
  return n && (t - 1) % 2 == 1 ? 0 : e;
604
734
  }
605
- function fe(e, t, n) {
735
+ function be(e, t, n) {
606
736
  return e === 1 && t === 1 && !n;
607
737
  }
608
738
  function J(e, t, n) {
609
739
  return n === 0 ? e : e - t / n;
610
740
  }
611
- async function pe(e, t) {
741
+ async function xe(e, t) {
612
742
  e._playOrigin === void 0 && (e._playOrigin = J(t, e._time, e._rate)), e._lastClock = t;
613
- 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 ? de(e.duration, e._repeatCount, e._yoyoOn) : 0 : ue(n, e.duration, e._repeatCount, e._yoyoOn);
614
- if (e._time = a, fe(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);
743
+ 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 ? ye(e.duration, e._repeatCount, e._yoyoOn) : 0 : ve(n, e.duration, e._repeatCount, e._yoyoOn);
744
+ if (e._time = a, be(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);
615
745
  if (K(e.events, e.entries, e.labels, a), G(e.entries, a), i) {
616
746
  Y(e);
617
747
  let t = e._resolvePlay;
@@ -641,57 +771,57 @@ function Z(e, t) {
641
771
  e._playingPromise === n && (e._playingPromise = null);
642
772
  }), n;
643
773
  }
644
- function me(e) {
774
+ function Q(e) {
645
775
  return e.started && !e.paused;
646
776
  }
647
- function he(e, t, n) {
777
+ function Se(e, t, n) {
648
778
  e.paused ? n() : t();
649
779
  }
650
780
  //#endregion
651
781
  //#region src/animation/orchestration/sequence/lifecycle.ts
652
- function ge(e) {
653
- return Q(e, 0);
782
+ function Ce(e) {
783
+ return $(e, 0);
654
784
  }
655
- function Q(e, t) {
785
+ function $(e, t) {
656
786
  if (e._playingPromise) return e._playingPromise;
657
- if (e.respectReducedMotion && _()) return e.seek(e.duration), Promise.resolve();
787
+ if (e.respectReducedMotion && b()) return e.seek(e.duration), Promise.resolve();
658
788
  for (let { animation: t, at: n } of e.entries) t.startTime = n, t.started = !0, t.managed = !0;
659
789
  return e._time = t, e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, Z(e, () => new Promise((t) => {
660
790
  e._resolvePlay = t, e.playback.loop(e._boundFrame);
661
791
  }));
662
792
  }
663
- function $(e) {
793
+ function we(e) {
664
794
  e.playback.stop(), Y(e);
665
795
  let t = e._resolvePlay;
666
796
  e._resolvePlay = null, t?.();
667
797
  }
668
- function _e(e) {
798
+ function Te(e) {
669
799
  !e._playingPromise || e._paused || (e._paused = !0, e.playback.stop(), e._playOrigin = void 0);
670
800
  }
671
- function ve(e) {
801
+ function Ee(e) {
672
802
  if (!e._playingPromise) {
673
- Q(e, e._time);
803
+ $(e, e._time);
674
804
  return;
675
805
  }
676
806
  e._paused && (e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, e.playback.loop(e._boundFrame));
677
807
  }
678
- function ye(e, t) {
808
+ function De(e, t) {
679
809
  if (!Number.isFinite(t)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${t}.`);
680
810
  e._rate = t, X(e, e._playingPromise != null);
681
811
  }
682
- function be(e) {
812
+ function Oe(e) {
683
813
  e._rate = -e._rate, X(e, e._playingPromise != null);
684
814
  }
685
- function xe(e, t) {
815
+ function ke(e, t) {
686
816
  if (t !== Infinity && (!Number.isInteger(t) || t < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${t}.`);
687
817
  e._repeatCount = t;
688
818
  }
689
- function Se(e, t) {
819
+ function Ae(e, t) {
690
820
  e._yoyoOn = t;
691
821
  }
692
822
  //#endregion
693
823
  //#region src/animation/orchestration/sequence/events.ts
694
- var Ce = class {
824
+ var je = class {
695
825
  subscribers = new Map([
696
826
  ["segment:enter", /* @__PURE__ */ new Set()],
697
827
  ["segment:leave", /* @__PURE__ */ new Set()],
@@ -726,14 +856,14 @@ var Ce = class {
726
856
  }
727
857
  this._prevPhase = n;
728
858
  }
729
- }, we = class {
859
+ }, Me = class {
730
860
  entries = [];
731
861
  labels = /* @__PURE__ */ new Map();
732
- events = new Ce();
862
+ events = new je();
733
863
  cursor = 0;
734
864
  _time = 0;
735
865
  respectReducedMotion;
736
- playback = new b();
866
+ playback = new C();
737
867
  _boundFrame;
738
868
  _resolvePlay = null;
739
869
  _playOrigin = void 0;
@@ -786,32 +916,32 @@ var Ce = class {
786
916
  return this._playingPromise ?? Promise.resolve();
787
917
  }
788
918
  play() {
789
- return ge(this);
919
+ return Ce(this);
790
920
  }
791
921
  async _frame(e) {
792
- return pe(this, e);
922
+ return xe(this, e);
793
923
  }
794
924
  stop() {
795
- return $(this), this;
925
+ return we(this), this;
796
926
  }
797
927
  pause() {
798
- return _e(this), this;
928
+ return Te(this), this;
799
929
  }
800
930
  resume() {
801
- return ve(this), this;
931
+ return Ee(this), this;
802
932
  }
803
933
  timeScale(e) {
804
- return ye(this, e), this;
934
+ return De(this, e), this;
805
935
  }
806
936
  reverse() {
807
- return be(this), this;
937
+ return Oe(this), this;
808
938
  }
809
939
  repeat(e) {
810
- return xe(this, e), this;
940
+ return ke(this, e), this;
811
941
  }
812
942
  yoyo(e = !0) {
813
- return Se(this, e), this;
943
+ return Ae(this, e), this;
814
944
  }
815
945
  };
816
946
  //#endregion
817
- export { u as C, a as D, i as E, o as O, ee as S, s as T, y as _, U as a, t as b, B as c, L as d, F as f, v as g, b as h, he as i, z as l, T as m, Z as n, W as o, N as p, me as r, V as s, we as t, R as u, f as v, d as w, n as x, e as y };
947
+ export { f as C, i as D, s as E, a as O, n as S, d as T, x as _, ge as a, e as b, me as c, H as d, B as f, C as g, O as h, Se as i, o as k, pe as l, F as m, Z as n, _e as o, R as p, Q as r, he as s, Me as t, fe as u, S as v, u as w, t as x, p as y };