@ssgoi/core 2.5.4 → 2.5.6

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.
Files changed (41) hide show
  1. package/dist/animator/animate/css-runner.d.ts +17 -0
  2. package/dist/animator/animate/css-runner.d.ts.map +1 -0
  3. package/dist/animator/animate/index.d.ts +42 -0
  4. package/dist/animator/animate/index.d.ts.map +1 -0
  5. package/dist/animator/animate/tick-runner.d.ts +16 -0
  6. package/dist/animator/animate/tick-runner.d.ts.map +1 -0
  7. package/dist/animator/animate/types.d.ts +31 -0
  8. package/dist/animator/animate/types.d.ts.map +1 -0
  9. package/dist/animator/animation-scheduler.d.ts +4 -17
  10. package/dist/animator/animation-scheduler.d.ts.map +1 -1
  11. package/dist/animator/index.d.ts +32 -32
  12. package/dist/animator/index.d.ts.map +1 -1
  13. package/dist/animator/spring-core.d.ts +63 -0
  14. package/dist/animator/spring-core.d.ts.map +1 -0
  15. package/dist/animator/ticker.d.ts +1 -0
  16. package/dist/animator/ticker.d.ts.map +1 -1
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.js +567 -608
  19. package/dist/jaemin-BG8HRXG1.cjs +1 -0
  20. package/dist/{jaemin-BAi8PTrj.js → jaemin-BWkrXq0V.js} +21 -20
  21. package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
  22. package/dist/ssgoi-transition/create-swipe-detector.d.ts +1 -0
  23. package/dist/ssgoi-transition/create-swipe-detector.d.ts.map +1 -1
  24. package/dist/transition/create-transition-callback.d.ts +2 -2
  25. package/dist/transition/create-transition-callback.d.ts.map +1 -1
  26. package/dist/transition/transition-strategy.d.ts +16 -16
  27. package/dist/transition/transition-strategy.d.ts.map +1 -1
  28. package/dist/transition/transition.d.ts +2 -18
  29. package/dist/transition/transition.d.ts.map +1 -1
  30. package/dist/types.cjs +1 -1
  31. package/dist/types.d.ts +74 -34
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/types.js +21 -6
  34. package/dist/view-transitions/drill.d.ts.map +1 -1
  35. package/dist/view-transitions/hero.d.ts.map +1 -1
  36. package/dist/view-transitions/index.cjs +7 -7
  37. package/dist/view-transitions/index.js +298 -284
  38. package/package.json +1 -1
  39. package/dist/animator/animate.d.ts +0 -35
  40. package/dist/animator/animate.d.ts.map +0 -1
  41. package/dist/jaemin-DL1-g_B5.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,36 +1,38 @@
1
- var _ = Object.defineProperty;
2
- var $ = (n, t, e) => t in n ? _(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var m = (n, t, e) => $(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { isMultiSpring as V } from "./types.js";
5
- import { isSingleSpring as at } from "./types.js";
6
- import { j as lt } from "./jaemin-BAi8PTrj.js";
7
- class H {
1
+ var $ = Object.defineProperty;
2
+ var j = (n, t, i) => t in n ? $(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
3
+ var p = (n, t, i) => j(n, typeof t != "symbol" ? t + "" : t, i);
4
+ import { isMultiSpring as M } from "./types.js";
5
+ import { isCssAnimation as vt, isSingleSpring as St, isTickAnimation as Ct, validateAnimationMode as Et } from "./types.js";
6
+ import { j as At } from "./jaemin-BWkrXq0V.js";
7
+ class B {
8
8
  constructor() {
9
- m(this, "listeners", /* @__PURE__ */ new Set());
10
- m(this, "rafId", null);
11
- m(this, "isRunning", !1);
9
+ p(this, "listeners", /* @__PURE__ */ new Set());
10
+ p(this, "rafId", null);
11
+ p(this, "isRunning", !1);
12
12
  // Timing
13
- m(this, "startTime", Date.now());
14
- m(this, "lastUpdate", this.startTime);
15
- m(this, "elapsed", 0);
13
+ p(this, "startTime", Date.now());
14
+ p(this, "lastUpdate", this.startTime);
15
+ p(this, "elapsed", 0);
16
16
  // Lag smoothing (mobile optimization)
17
- m(this, "lagThreshold", 500);
17
+ p(this, "lagThreshold", 500);
18
18
  // ms - detect tab switches, backgrounding
19
- m(this, "adjustedLag", 33);
19
+ p(this, "adjustedLag", 33);
20
20
  // ms - max time jump to prevent animation skip
21
+ p(this, "maxDeltaTime", 33);
22
+ // ms - clamp for physics stability (30fps minimum)
21
23
  // FPS throttling
22
- m(this, "gap", 1e3 / 240);
24
+ p(this, "gap", 1e3 / 240);
23
25
  // max 240fps
24
- m(this, "nextTime", this.gap);
25
- m(this, "tick", () => {
26
+ p(this, "nextTime", this.gap);
27
+ p(this, "tick", () => {
26
28
  const t = Date.now();
27
29
  let e = t - this.lastUpdate;
28
- (e > this.lagThreshold || e < 0) && (this.startTime += e - this.adjustedLag, e = this.adjustedLag), this.lastUpdate = t;
29
- const i = t - this.startTime, o = i - this.nextTime;
30
- if (o > 0) {
31
- const r = e / 1e3;
32
- this.elapsed = i / 1e3, this.nextTime += o + (o >= this.gap ? 4 : this.gap - o), this.listeners.forEach((s) => {
33
- s(r, this.elapsed);
30
+ e > this.lagThreshold || e < 0 ? (this.startTime += e - this.adjustedLag, e = this.adjustedLag) : e > this.maxDeltaTime && (e = this.maxDeltaTime), this.lastUpdate = t;
31
+ const o = t - this.startTime, r = o - this.nextTime;
32
+ if (r > 0) {
33
+ const s = e / 1e3;
34
+ this.elapsed = o / 1e3, this.nextTime += r + (r >= this.gap ? 4 : this.gap - r), this.listeners.forEach((a) => {
35
+ a(s, this.elapsed);
34
36
  });
35
37
  }
36
38
  this.listeners.size > 0 ? this.rafId = requestAnimationFrame(this.tick) : (this.isRunning = !1, this.rafId = null);
@@ -49,8 +51,8 @@ class H {
49
51
  * @param threshold - Time threshold to detect lag (default: 500ms)
50
52
  * @param adjustedLag - Max time jump when lag detected (default: 33ms)
51
53
  */
52
- lagSmoothing(t, e) {
53
- this.lagThreshold = t, this.adjustedLag = Math.min(e, t);
54
+ lagSmoothing(t, i) {
55
+ this.lagThreshold = t, this.adjustedLag = Math.min(i, t);
54
56
  }
55
57
  /**
56
58
  * Set maximum FPS
@@ -66,189 +68,233 @@ class H {
66
68
  return this.elapsed;
67
69
  }
68
70
  }
69
- const I = new H();
70
- function k(n) {
71
+ const I = new B();
72
+ function z(n) {
73
+ const t = n.stiffness, i = n.damping, e = 1, o = Math.sqrt(t / e), r = i / (2 * Math.sqrt(t * e));
74
+ return { omega: o, zeta: r };
75
+ }
76
+ function H(n, t, i, e) {
77
+ const { omega: o, zeta: r } = i, { position: s, velocity: a } = n, c = Math.min(e, 0.033), m = -2 * c * r * o * a, h = c * o * o * (t - s), u = a + m + h;
78
+ return {
79
+ position: s + c * u,
80
+ velocity: u
81
+ };
82
+ }
83
+ const K = 0.01, U = 0.01, N = 0.05;
84
+ function W(n, t) {
85
+ const i = Math.abs(t - n.position), e = Math.abs(n.velocity);
86
+ return i < K && e < U;
87
+ }
88
+ function q(n) {
71
89
  const {
72
90
  from: t,
73
- to: e,
74
- stiffness: i,
75
- damping: o,
76
- mass: r,
77
- velocity: s = 0,
78
- onUpdate: d,
79
- onComplete: l
91
+ to: i,
92
+ spring: e,
93
+ velocity: o = 0,
94
+ onUpdate: r,
95
+ onComplete: s,
96
+ onStart: a
80
97
  } = n;
81
- let h = t, u = s, a = !0;
82
- const p = Math.sqrt(i / r), c = o / (2 * Math.sqrt(i * r)), g = 0.01, w = 0.01;
83
- let f = 0;
84
- const y = 0.05, S = (C) => {
85
- if (!a) return;
86
- const T = Math.min(C, 0.033), v = -2 * T * c * p * u, b = T * p * p * (e - h);
87
- u += v + b, h += T * u;
88
- const E = Math.abs(e - h), A = Math.abs(u);
89
- if (E < g && A < w) {
90
- if (f += T, f >= y) {
91
- h = e, u = 0, a = !1, d(h), I.unsubscribe(S), l();
92
- return;
98
+ let c = { position: t, velocity: o }, m = !0, h = 0, u = !1;
99
+ const g = z(e), l = (w) => {
100
+ if (m) {
101
+ if (u || (u = !0, a == null || a()), c = H(c, i, g, w), W(c, i)) {
102
+ if (h += Math.min(w, 0.033), h >= N) {
103
+ c = { position: i, velocity: 0 }, m = !1, r(c.position), I.unsubscribe(l), s();
104
+ return;
105
+ }
106
+ } else
107
+ h = 0;
108
+ r(c.position);
109
+ }
110
+ };
111
+ return I.subscribe(l), {
112
+ stop: () => {
113
+ m && (m = !1, I.unsubscribe(l));
114
+ },
115
+ getPosition: () => c.position,
116
+ getVelocity: () => c.velocity,
117
+ isRunning: () => m
118
+ };
119
+ }
120
+ const x = 1e3 / 60;
121
+ function G(n, t, i, e = 0) {
122
+ const o = z(i), r = 600;
123
+ let s = { position: n, velocity: e }, a = 0;
124
+ const c = [];
125
+ for (let m = 0; m < r; m++) {
126
+ const h = m * x;
127
+ if (c.push({
128
+ time: h,
129
+ position: s.position,
130
+ velocity: s.velocity
131
+ }), s = H(s, t, o, x / 1e3), W(s, t)) {
132
+ if (a += x / 1e3, a >= N) {
133
+ c.push({
134
+ time: (m + 1) * x,
135
+ position: t,
136
+ velocity: 0
137
+ });
138
+ break;
93
139
  }
94
140
  } else
95
- f = 0;
96
- d(h);
141
+ a = 0;
142
+ }
143
+ return c;
144
+ }
145
+ function D(n, t) {
146
+ if (n.length === 0)
147
+ return { position: 0, velocity: 0 };
148
+ const i = n[0], e = n[n.length - 1];
149
+ if (t <= 0)
150
+ return { position: i.position, velocity: i.velocity };
151
+ if (t >= e.time)
152
+ return { position: e.position, velocity: e.velocity };
153
+ let o = 0, r = n.length - 1;
154
+ for (; o < r - 1; ) {
155
+ const m = Math.floor((o + r) / 2);
156
+ n[m].time <= t ? o = m : r = m;
157
+ }
158
+ const s = n[o], a = n[r], c = (t - s.time) / (a.time - s.time);
159
+ return {
160
+ position: s.position + (a.position - s.position) * c,
161
+ velocity: s.velocity + (a.velocity - s.velocity) * c
97
162
  };
98
- return I.subscribe(S), {
163
+ }
164
+ function J(n, t) {
165
+ return n.map((i) => t(i.position));
166
+ }
167
+ function Q(n) {
168
+ const {
169
+ element: t,
170
+ from: i,
171
+ to: e,
172
+ spring: o,
173
+ velocity: r = 0,
174
+ style: s,
175
+ onComplete: a,
176
+ onStart: c
177
+ } = n, m = G(i, e, o, r);
178
+ if (m.length === 0)
179
+ return c == null || c(), a(), {
180
+ stop: () => {
181
+ },
182
+ getPosition: () => e,
183
+ getVelocity: () => 0,
184
+ isRunning: () => !1
185
+ };
186
+ const h = J(m, s), u = m[m.length - 1], g = u.time, l = t.animate(h, {
187
+ duration: g,
188
+ fill: "forwards",
189
+ easing: "linear"
190
+ // Spring physics already applied in keyframes
191
+ });
192
+ let w = !0;
193
+ const d = performance.now();
194
+ return c == null || c(), l.onfinish = () => {
195
+ w && (w = !1, a());
196
+ }, {
99
197
  stop: () => {
100
- a && (a = !1, I.unsubscribe(S));
101
- }
198
+ w && (w = !1, l.cancel());
199
+ },
200
+ getPosition: () => {
201
+ if (!w)
202
+ return u.position;
203
+ const f = performance.now() - d;
204
+ return D(m, f).position;
205
+ },
206
+ getVelocity: () => {
207
+ if (!w)
208
+ return 0;
209
+ const f = performance.now() - d;
210
+ return D(m, f).velocity;
211
+ },
212
+ isRunning: () => w
102
213
  };
103
214
  }
104
- class O {
215
+ function Z(n) {
216
+ const { from: t, to: i, spring: e, velocity: o, onComplete: r, onStart: s, tick: a, css: c } = n;
217
+ if (a && c)
218
+ throw new Error("Cannot use both 'tick' and 'css' options together");
219
+ return !a && !c ? (s == null || s(), r(), {
220
+ stop: () => {
221
+ },
222
+ getPosition: () => i,
223
+ getVelocity: () => 0,
224
+ isRunning: () => !1
225
+ }) : c ? Q({
226
+ element: c.element,
227
+ from: t,
228
+ to: i,
229
+ spring: e,
230
+ velocity: o,
231
+ style: c.style,
232
+ onComplete: r,
233
+ onStart: s
234
+ }) : q({
235
+ from: t,
236
+ to: i,
237
+ spring: e,
238
+ velocity: o,
239
+ onUpdate: a,
240
+ onComplete: r,
241
+ onStart: s
242
+ });
243
+ }
244
+ class k {
105
245
  constructor(t) {
106
- m(this, "options");
107
- m(this, "currentValue");
108
- m(this, "velocity");
109
- m(this, "isAnimating", !1);
110
- m(this, "controls", null);
111
- // For object animations
112
- m(this, "animationMap", null);
113
- m(this, "activeAnimations", /* @__PURE__ */ new Set());
114
- m(this, "completedAnimations", /* @__PURE__ */ new Set());
115
- m(this, "updatedProperties", /* @__PURE__ */ new Set());
116
- m(this, "animate", (t = !1) => {
117
- !this.isAnimating && this.options.onStart && this.options.onStart(), this.isAnimating = !0;
118
- const e = t ? this.options.from : this.options.to;
119
- if (typeof this.currentValue == "object" && this.currentValue !== null) {
120
- this.animateObject(e);
121
- return;
122
- }
123
- let i = this.currentValue, o = performance.now();
124
- const r = {
125
- from: this.currentValue,
126
- to: e,
127
- stiffness: this.options.spring.stiffness,
128
- damping: this.options.spring.damping,
129
- mass: 1
130
- };
131
- typeof this.velocity == "number" && (r.velocity = this.velocity * 1e3), this.controls = k({
132
- ...r,
133
- onUpdate: (s) => {
134
- const d = performance.now(), l = (d - o) / 1e3;
135
- if (l > 0) {
136
- if (typeof s == "number" && typeof i == "number") {
137
- const h = (s - i) / l;
138
- this.velocity = h / 1e3;
139
- } else if (typeof s == "object" && s !== null) {
140
- const h = {};
141
- Object.keys(s).forEach((u) => {
142
- const a = s[u], p = i[u];
143
- if (typeof a == "number" && typeof p == "number") {
144
- const c = (a - p) / l;
145
- h[u] = c / 1e3;
146
- }
147
- }), this.velocity = h;
148
- }
149
- i = s, o = d;
150
- }
151
- this.currentValue = s, this.options.onUpdate(s);
152
- },
153
- onComplete: () => {
154
- this.currentValue = e, this.isAnimating = !1, this.controls = null, typeof this.velocity == "object" && this.velocity !== null ? Object.keys(this.velocity).forEach((s) => {
155
- this.velocity[s] = 0;
156
- }) : this.velocity = 0, this.options.onComplete();
157
- }
158
- });
159
- });
160
- m(this, "animateObject", (t) => {
161
- const e = this.currentValue, i = Object.keys(e);
162
- this.animationMap = /* @__PURE__ */ new Map(), this.activeAnimations.clear(), this.completedAnimations.clear(), this.updatedProperties.clear();
163
- const o = { ...e }, r = {};
164
- let s = !1;
165
- const d = () => {
166
- const l = i.filter((u) => !this.completedAnimations.has(u));
167
- if (l.every(
168
- (u) => this.updatedProperties.has(u)
169
- ) && l.length > 0) {
170
- if (typeof this.velocity == "object" && this.velocity) {
171
- const u = performance.now();
172
- Object.keys(o).forEach((a) => {
173
- if (r[a]) {
174
- const p = (u - r[a]) / 1e3, c = this.currentValue[a], g = o[a];
175
- typeof c == "number" && typeof g == "number" && p > 0 && (this.velocity[a] = (g - c) / p / 1e3);
176
- }
177
- r[a] = u;
178
- });
179
- }
180
- this.currentValue = { ...o }, this.options.onUpdate(this.currentValue), this.updatedProperties.clear(), !s && this.options.onStart && (s = !0, this.options.onStart());
181
- }
182
- };
183
- i.forEach((l) => {
184
- this.activeAnimations.add(l);
185
- const h = {
186
- from: e[l],
187
- to: t[l],
188
- stiffness: this.options.spring.stiffness,
189
- damping: this.options.spring.damping,
190
- mass: 1
191
- };
192
- typeof this.velocity == "object" && this.velocity && l in this.velocity && (h.velocity = this.velocity[l] * 1e3);
193
- const u = k({
194
- ...h,
195
- onUpdate: (a) => {
196
- o[l] = a, this.updatedProperties.add(l), d();
197
- },
198
- onComplete: () => {
199
- this.completedAnimations.add(l), this.updatedProperties.delete(l), this.completedAnimations.size === i.length && (this.currentValue = t, this.isAnimating = !1, this.animationMap = null, typeof this.velocity == "object" && this.velocity && Object.keys(this.velocity).forEach((a) => {
200
- this.velocity[a] = 0;
201
- }), this.options.onComplete());
202
- }
203
- });
204
- this.animationMap.set(l, u);
205
- });
206
- });
207
- if (this.options = {
246
+ p(this, "options");
247
+ p(this, "controls", null);
248
+ p(this, "isAnimating", !1);
249
+ p(this, "currentValue");
250
+ p(this, "currentVelocity", 0);
251
+ if (t.tick && t.css)
252
+ throw new Error("Cannot use both 'tick' and 'css' options together");
253
+ this.options = {
208
254
  from: t.from ?? 0,
209
255
  to: t.to ?? 1,
210
- spring: t.spring ?? { stiffness: 100, damping: 10 },
211
- onUpdate: t.onUpdate ?? (() => {
212
- }),
256
+ spring: t.spring ?? { stiffness: 300, damping: 30 },
257
+ tick: t.tick,
258
+ css: t.css,
213
259
  onComplete: t.onComplete ?? (() => {
214
260
  }),
215
261
  onStart: t.onStart
216
- }, this.currentValue = this.options.from, typeof this.options.from == "object" && this.options.from !== null) {
217
- const e = {};
218
- Object.keys(this.options.from).forEach((i) => {
219
- e[i] = 0;
220
- }), this.velocity = e;
221
- } else
222
- this.velocity = 0;
262
+ }, this.currentValue = this.options.from;
263
+ }
264
+ runAnimation(t) {
265
+ this.isAnimating = !0, this.controls = Z({
266
+ from: this.currentValue,
267
+ to: t,
268
+ spring: this.options.spring,
269
+ velocity: this.currentVelocity,
270
+ tick: this.options.tick,
271
+ css: this.options.css,
272
+ onStart: this.options.onStart,
273
+ onComplete: () => {
274
+ this.currentValue = t, this.currentVelocity = 0, this.isAnimating = !1, this.controls = null, this.options.onComplete();
275
+ }
276
+ });
223
277
  }
224
- // Animation control methods
225
278
  forward() {
226
- this.stop(), this.animate(!1);
279
+ this.stop(), this.runAnimation(this.options.to);
227
280
  }
228
281
  backward() {
229
- this.stop(), this.animate(!0);
282
+ this.stop(), this.runAnimation(this.options.from);
230
283
  }
231
284
  reverse() {
232
285
  const t = this.options.from;
233
- if (this.options.from = this.options.to, this.options.to = t, this.isAnimating) {
234
- const e = this.shouldReverse();
235
- this.stop(), this.animate(!e);
236
- }
237
- }
238
- shouldReverse() {
239
- return typeof this.currentValue == "number" && typeof this.options.from == "number" && typeof this.options.to == "number" ? this.currentValue > (this.options.from + this.options.to) / 2 : !1;
286
+ this.options.from = this.options.to, this.options.to = t, this.isAnimating && (this.stop(), this.runAnimation(this.options.to));
240
287
  }
241
288
  stop() {
242
- this.isAnimating = !1, this.controls && (this.controls.stop(), this.controls = null), this.animationMap && (this.animationMap.forEach((t) => {
243
- t.stop();
244
- }), this.animationMap.clear(), this.animationMap = null), this.updatedProperties.clear();
289
+ this.controls && (this.currentValue = this.controls.getPosition(), this.currentVelocity = this.controls.getVelocity(), this.controls.stop(), this.controls = null), this.isAnimating = !1;
245
290
  }
246
- // State getters
247
291
  getVelocity() {
248
- return this.velocity;
292
+ var t;
293
+ return ((t = this.controls) == null ? void 0 : t.getVelocity()) ?? this.currentVelocity;
249
294
  }
250
295
  getCurrentValue() {
251
- return this.currentValue;
296
+ var t;
297
+ return ((t = this.controls) == null ? void 0 : t.getPosition()) ?? this.currentValue;
252
298
  }
253
299
  getIsAnimating() {
254
300
  return this.isAnimating;
@@ -256,42 +302,36 @@ class O {
256
302
  getCurrentState() {
257
303
  return {
258
304
  type: "single",
259
- position: this.currentValue,
260
- velocity: this.velocity,
305
+ position: this.getCurrentValue(),
306
+ velocity: this.getVelocity(),
261
307
  from: this.options.from,
262
308
  to: this.options.to
263
309
  };
264
310
  }
265
- // State setters
266
- setVelocity(t) {
267
- this.velocity = t;
268
- }
269
311
  setValue(t) {
270
312
  this.currentValue = t;
271
313
  }
272
- // Configuration
314
+ setVelocity(t) {
315
+ this.currentVelocity = t;
316
+ }
273
317
  updateOptions(t) {
274
- if (this.options = { ...this.options, ...t }, this.isAnimating && this.controls) {
275
- const e = this.shouldReverse();
276
- this.stop(), this.animate(!e);
277
- }
318
+ this.options = { ...this.options, ...t };
278
319
  }
279
- // Static factory method
280
- static fromState(t, e) {
281
- const i = new O(e);
282
- return i.setValue(t.position), i.setVelocity(t.velocity), i;
320
+ static fromState(t, i) {
321
+ const e = new k(i);
322
+ return e.setValue(t.position), e.setVelocity(t.velocity), e;
283
323
  }
284
324
  }
285
- class j {
325
+ class L {
286
326
  constructor(t) {
287
- m(this, "config");
288
- m(this, "animators", /* @__PURE__ */ new Map());
289
- m(this, "springOrder", []);
290
- m(this, "completedCount", 0);
291
- m(this, "completedAnimators", /* @__PURE__ */ new Set());
292
- m(this, "direction", "forward");
293
- m(this, "idCounter", 0);
294
- m(this, "timeoutIds", []);
327
+ p(this, "config");
328
+ p(this, "animators", /* @__PURE__ */ new Map());
329
+ p(this, "springOrder", []);
330
+ p(this, "completedCount", 0);
331
+ p(this, "completedAnimators", /* @__PURE__ */ new Set());
332
+ p(this, "direction", "forward");
333
+ p(this, "idCounter", 0);
334
+ p(this, "timeoutIds", []);
295
335
  this.config = t, this.initializeAnimators();
296
336
  }
297
337
  generateId() {
@@ -299,168 +339,102 @@ class j {
299
339
  }
300
340
  initializeAnimators() {
301
341
  this.config.springs.forEach((t) => {
302
- const e = this.generateId(), i = new O({
342
+ const i = this.generateId(), e = new k({
303
343
  from: t.from,
304
344
  to: t.to,
305
345
  spring: t.spring,
306
- onUpdate: t.tick,
307
- onComplete: () => this.onAnimatorComplete(e),
346
+ tick: t.tick,
347
+ onComplete: () => this.onAnimatorComplete(i),
308
348
  onStart: t.onStart
309
349
  });
310
- this.animators.set(e, {
311
- id: e,
350
+ this.animators.set(i, {
351
+ id: i,
312
352
  item: t,
313
- animator: i,
353
+ animator: e,
314
354
  startTime: null
315
- }), this.springOrder.push(e);
355
+ }), this.springOrder.push(i);
316
356
  });
317
357
  }
318
- /**
319
- * Normalize schedule configuration to unified internal representation
320
- * Uses discriminated union and early return pattern
321
- *
322
- * @param direction - "forward" or "backward" direction
323
- */
324
358
  normalizeSchedule(t) {
325
- const e = this.config.schedule ?? "overlap";
326
- return this.springOrder.map((i, o) => {
327
- const r = this.animators.get(i);
359
+ const i = this.config.schedule ?? "overlap";
360
+ return this.springOrder.map((e, o) => {
361
+ const r = this.animators.get(e);
328
362
  if (!r)
329
363
  throw new Error(
330
- `AnimationScheduler: animator with id "${i}" not found during normalization`
364
+ `AnimationScheduler: animator with id "${e}" not found`
331
365
  );
332
- if (e === "overlap")
333
- return {
334
- type: "offset",
335
- id: i,
336
- delay: 0
337
- };
338
- if (e === "wait")
339
- return t === "forward" && o === 0 ? {
340
- type: "offset",
341
- id: i,
342
- delay: 0
343
- } : t === "backward" && o === this.springOrder.length - 1 ? {
344
- type: "offset",
345
- id: i,
346
- delay: 0
347
- } : {
348
- type: "wait",
349
- id: i
350
- };
366
+ if (i === "overlap")
367
+ return { type: "offset", id: e, delay: 0 };
368
+ if (i === "wait")
369
+ return t === "forward" && o === 0 ? { type: "offset", id: e, delay: 0 } : t === "backward" && o === this.springOrder.length - 1 ? { type: "offset", id: e, delay: 0 } : { type: "wait", id: e };
351
370
  const s = r.item.offset ?? 0;
352
371
  if (t === "forward")
353
- return {
354
- type: "offset",
355
- id: i,
356
- delay: s
357
- };
358
- const d = this.animators.size === 0 ? 0 : Math.max(
359
- ...Array.from(this.animators.values()).map(
360
- (l) => l.item.offset ?? 0
361
- )
372
+ return { type: "offset", id: e, delay: s };
373
+ const a = Math.max(
374
+ ...Array.from(this.animators.values()).map((c) => c.item.offset ?? 0)
362
375
  );
363
- return {
364
- type: "offset",
365
- id: i,
366
- delay: d - s
367
- };
376
+ return { type: "offset", id: e, delay: a - s };
368
377
  });
369
378
  }
370
379
  onAnimatorComplete(t) {
371
- var i, o, r, s, d, l;
372
- const e = this.animators.get(t);
373
- if (!e) {
374
- console.warn(
375
- `AnimationScheduler: animator with id "${t}" not found on completion`
376
- );
377
- return;
378
- }
379
- this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (o = (i = e.item).onComplete) == null || o.call(i), (s = (r = this.config).onProgress) == null || s.call(r, this.completedCount, this.config.springs.length), this.handleWaitModeChaining(t), this.completedCount === this.config.springs.length && ((l = (d = this.config).onEnd) == null || l.call(d)));
380
+ var e, o, r, s, a, c;
381
+ const i = this.animators.get(t);
382
+ !i || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (o = (e = i.item).onComplete) == null || o.call(e), (s = (r = this.config).onProgress) == null || s.call(r, this.completedCount, this.config.springs.length), this.handleWaitModeChaining(t), this.completedCount === this.config.springs.length && ((c = (a = this.config).onEnd) == null || c.call(a)));
380
383
  }
381
- /**
382
- * Handle wait mode chaining: start next/previous spring after completion
383
- */
384
384
  handleWaitModeChaining(t) {
385
385
  if (this.config.schedule !== "wait")
386
386
  return;
387
- const e = this.springOrder.indexOf(t);
387
+ const i = this.springOrder.indexOf(t);
388
388
  if (this.direction === "forward") {
389
- const r = this.springOrder[e + 1];
390
- if (!r)
391
- return;
392
- const s = this.animators.get(r);
393
- s && s.startTime === null && this.startAnimator(r);
394
- return;
389
+ const e = this.springOrder[i + 1];
390
+ if (e) {
391
+ const o = this.animators.get(e);
392
+ o && o.startTime === null && this.startAnimator(e);
393
+ }
394
+ } else {
395
+ const e = this.springOrder[i - 1];
396
+ if (e) {
397
+ const o = this.animators.get(e);
398
+ o && o.startTime === null && this.startBackwardAnimator(e);
399
+ }
395
400
  }
396
- const i = this.springOrder[e - 1];
397
- if (!i)
398
- return;
399
- const o = this.animators.get(i);
400
- o && o.startTime === null && this.startBackwardAnimator(i);
401
401
  }
402
402
  startAnimator(t) {
403
- const e = this.animators.get(t);
404
- if (!e) {
405
- console.warn(
406
- `AnimationScheduler: animator with id "${t}" not found on start`
407
- );
408
- return;
409
- }
410
- if (e.startTime !== null) {
411
- console.warn(
412
- `AnimationScheduler: animator with id "${t}" already started`
413
- );
414
- return;
415
- }
416
- e.startTime = Date.now(), e.animator.forward();
403
+ const i = this.animators.get(t);
404
+ !i || i.startTime !== null || (i.startTime = Date.now(), i.animator.forward());
417
405
  }
418
406
  startBackwardAnimator(t) {
419
- const e = this.animators.get(t);
420
- if (!e) {
421
- console.warn(
422
- `AnimationScheduler: animator with id "${t}" not found on backward start`
423
- );
424
- return;
425
- }
426
- if (e.startTime !== null) {
427
- console.warn(
428
- `AnimationScheduler: animator with id "${t}" already started`
429
- );
430
- return;
431
- }
432
- e.startTime = Date.now(), e.animator.backward();
407
+ const i = this.animators.get(t);
408
+ !i || i.startTime !== null || (i.startTime = Date.now(), i.animator.backward());
433
409
  }
434
410
  forward() {
435
- var e, i;
436
- this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), (i = (e = this.config).onStart) == null || i.call(e), this.normalizeSchedule("forward").forEach((o) => {
437
- if (o.type === "wait")
438
- return;
439
- if (o.delay === 0) {
440
- this.startAnimator(o.id);
441
- return;
442
- }
443
- const r = window.setTimeout(
444
- () => this.startAnimator(o.id),
445
- o.delay
446
- );
447
- this.timeoutIds.push(r);
411
+ var i, e;
412
+ this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), (e = (i = this.config).onStart) == null || e.call(i), this.normalizeSchedule("forward").forEach((o) => {
413
+ if (o.type !== "wait")
414
+ if (o.delay === 0)
415
+ this.startAnimator(o.id);
416
+ else {
417
+ const r = window.setTimeout(
418
+ () => this.startAnimator(o.id),
419
+ o.delay
420
+ );
421
+ this.timeoutIds.push(r);
422
+ }
448
423
  });
449
424
  }
450
425
  backward() {
451
- var e, i;
452
- this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), (i = (e = this.config).onStart) == null || i.call(e), this.normalizeSchedule("backward").forEach((o) => {
453
- if (o.type === "wait")
454
- return;
455
- if (o.delay === 0) {
456
- this.startBackwardAnimator(o.id);
457
- return;
458
- }
459
- const r = window.setTimeout(
460
- () => this.startBackwardAnimator(o.id),
461
- o.delay
462
- );
463
- this.timeoutIds.push(r);
426
+ var i, e;
427
+ this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), (e = (i = this.config).onStart) == null || e.call(i), this.normalizeSchedule("backward").forEach((o) => {
428
+ if (o.type !== "wait")
429
+ if (o.delay === 0)
430
+ this.startBackwardAnimator(o.id);
431
+ else {
432
+ const r = window.setTimeout(
433
+ () => this.startBackwardAnimator(o.id),
434
+ o.delay
435
+ );
436
+ this.timeoutIds.push(r);
437
+ }
464
438
  });
465
439
  }
466
440
  stop() {
@@ -468,34 +442,28 @@ class j {
468
442
  t.animator.stop(), t.startTime = null;
469
443
  });
470
444
  }
471
- reverse(t) {
472
- ((t == null ? void 0 : t.offsetMode) ?? "immediate") !== "immediate" && console.warn(
473
- 'AnimationScheduler.reverse(): Only "immediate" offsetMode is currently supported. Falling back to "immediate".'
474
- ), this.direction = this.direction === "forward" ? "backward" : "forward", this.animators.forEach((i) => {
475
- if (i.startTime === null)
445
+ reverse() {
446
+ this.direction = this.direction === "forward" ? "backward" : "forward", this.animators.forEach((t) => {
447
+ if (t.startTime === null)
476
448
  return;
477
- const o = i.animator.getCurrentState();
478
- if (o.type !== "single")
449
+ const i = t.animator.getCurrentState();
450
+ if (i.type !== "single")
479
451
  return;
480
- if (o.position === o.to) {
481
- const s = O.fromState(
482
- {
483
- position: 1,
484
- velocity: 0
485
- },
452
+ if (i.position === i.to) {
453
+ const o = k.fromState(
454
+ { position: 1, velocity: 0 },
486
455
  {
487
- from: i.item.to ?? 1,
488
- to: i.item.from ?? 0,
489
- spring: i.item.spring,
490
- onUpdate: i.item.tick,
491
- onComplete: () => this.onAnimatorComplete(i.id),
492
- onStart: i.item.onStart
456
+ from: t.item.to ?? 1,
457
+ to: t.item.from ?? 0,
458
+ spring: t.item.spring,
459
+ tick: t.item.tick,
460
+ onComplete: () => this.onAnimatorComplete(t.id),
461
+ onStart: t.item.onStart
493
462
  }
494
463
  );
495
- s.forward(), i.animator = s;
496
- return;
497
- }
498
- i.animator.reverse();
464
+ o.forward(), t.animator = o;
465
+ } else
466
+ t.animator.reverse();
499
467
  });
500
468
  }
501
469
  getCurrentState() {
@@ -507,13 +475,13 @@ class j {
507
475
  };
508
476
  }
509
477
  }
510
- const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
478
+ const X = Symbol.for("TRANSITION_STRATEGY"), tt = (n) => ({
511
479
  runIn: async (t) => {
512
- const { currentAnimation: e } = n;
513
- if (e && e.direction === "out") {
514
- const s = e.controller.getCurrentState();
515
- if (e.controller.stop(), s.type === "multi")
516
- return e.controller.reverse(), {
480
+ const { currentAnimation: i } = n;
481
+ if (i && i.direction === "out") {
482
+ const s = i.controller.getCurrentState();
483
+ if (i.controller.stop(), s.type === "multi")
484
+ return i.controller.reverse(), {
517
485
  state: {
518
486
  position: 0,
519
487
  velocity: 0
@@ -523,24 +491,24 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
523
491
  direction: "forward"
524
492
  };
525
493
  if (t.out) {
526
- const d = await t.out, { from: l = 1, to: h = 0 } = d;
494
+ const a = await t.out, { from: c = 1, to: m = 0 } = a;
527
495
  return {
528
- config: d,
496
+ config: a,
529
497
  state: {
530
498
  position: s.position,
531
499
  velocity: s.velocity
532
500
  },
533
- from: l,
501
+ from: c,
534
502
  // OUT animation's from
535
- to: h,
503
+ to: m,
536
504
  // OUT animation's to
537
505
  direction: "backward"
538
- // Will actually go 0→1
506
+ // Will actually go 0→1 (backward means toward 'from')
539
507
  };
540
508
  }
541
509
  }
542
- const i = await t.in;
543
- if (!i)
510
+ const e = await t.in;
511
+ if (!e)
544
512
  return {
545
513
  state: {
546
514
  position: 0,
@@ -550,9 +518,9 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
550
518
  to: 1,
551
519
  direction: "forward"
552
520
  };
553
- if ("springs" in i)
521
+ if ("springs" in e)
554
522
  return {
555
- config: i,
523
+ config: e,
556
524
  state: {
557
525
  position: 0,
558
526
  velocity: 0
@@ -561,9 +529,9 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
561
529
  to: 1,
562
530
  direction: "forward"
563
531
  };
564
- const { from: o = 0, to: r = 1 } = i;
532
+ const { from: o = 0, to: r = 1 } = e;
565
533
  return {
566
- config: i,
534
+ config: e,
567
535
  state: {
568
536
  position: o,
569
537
  velocity: 0
@@ -574,11 +542,11 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
574
542
  };
575
543
  },
576
544
  runOut: async (t) => {
577
- const { currentAnimation: e } = n;
578
- if (e && e.direction === "in") {
579
- const s = e.controller.getCurrentState();
580
- if (e.controller.stop(), s.type === "multi")
581
- return e.controller.reverse(), {
545
+ const { currentAnimation: i } = n;
546
+ if (i && i.direction === "in") {
547
+ const s = i.controller.getCurrentState();
548
+ if (i.controller.stop(), s.type === "multi")
549
+ return i.controller.reverse(), {
582
550
  state: {
583
551
  position: 1,
584
552
  velocity: 0
@@ -588,24 +556,24 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
588
556
  direction: "forward"
589
557
  };
590
558
  if (t.in) {
591
- const d = await t.in, { from: l = 0, to: h = 1 } = d;
559
+ const a = await t.in, { from: c = 0, to: m = 1 } = a;
592
560
  return {
593
- config: d,
561
+ config: a,
594
562
  state: {
595
563
  position: s.position,
596
564
  velocity: s.velocity
597
565
  },
598
- from: l,
566
+ from: c,
599
567
  // IN animation's from
600
- to: h,
568
+ to: m,
601
569
  // IN animation's to
602
570
  direction: "backward"
603
- // Will actually go 1→0
571
+ // Will actually go 1→0 (backward means toward 'from')
604
572
  };
605
573
  }
606
574
  }
607
- const i = await t.out;
608
- if (!i)
575
+ const e = await t.out;
576
+ if (!e)
609
577
  return {
610
578
  state: {
611
579
  position: 1,
@@ -615,9 +583,9 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
615
583
  to: 0,
616
584
  direction: "forward"
617
585
  };
618
- if ("springs" in i)
586
+ if ("springs" in e)
619
587
  return {
620
- config: i,
588
+ config: e,
621
589
  state: {
622
590
  position: 1,
623
591
  velocity: 0
@@ -626,9 +594,9 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
626
594
  to: 0,
627
595
  direction: "forward"
628
596
  };
629
- const { from: o = 1, to: r = 0 } = i;
597
+ const { from: o = 1, to: r = 0 } = e;
630
598
  return {
631
- config: i,
599
+ config: e,
632
600
  state: {
633
601
  position: o,
634
602
  velocity: 0
@@ -638,7 +606,7 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
638
606
  direction: "forward"
639
607
  };
640
608
  }
641
- }), N = () => ({
609
+ }), it = () => ({
642
610
  runIn: async (n) => {
643
611
  const t = await n.in;
644
612
  if (!t)
@@ -662,15 +630,15 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
662
630
  to: 1,
663
631
  direction: "forward"
664
632
  };
665
- const { from: e = 0, to: i = 1 } = t;
633
+ const { from: i = 0, to: e = 1 } = t;
666
634
  return {
667
635
  config: t,
668
636
  state: {
669
- position: e,
637
+ position: i,
670
638
  velocity: 0
671
639
  },
672
- from: e,
673
- to: i,
640
+ from: i,
641
+ to: e,
674
642
  direction: "forward"
675
643
  };
676
644
  },
@@ -697,385 +665,376 @@ const z = Symbol.for("TRANSITION_STRATEGY"), F = (n) => ({
697
665
  to: 0,
698
666
  direction: "forward"
699
667
  };
700
- const { from: e = 1, to: i = 0 } = t;
668
+ const { from: i = 1, to: e = 0 } = t;
701
669
  return {
702
670
  config: t,
703
671
  state: {
704
- position: e,
672
+ position: i,
705
673
  velocity: 0
706
674
  },
707
- from: e,
708
- to: i,
675
+ from: i,
676
+ to: e,
709
677
  direction: "forward"
710
678
  };
711
679
  }
712
680
  });
713
- function W(n, t) {
714
- var u;
715
- let e = null, i = null, o = null, r = null;
681
+ function et(n, t) {
682
+ var h;
683
+ let i = null, e = null, o = null, r = null;
716
684
  const s = {
717
685
  get currentAnimation() {
718
- return e;
686
+ return i;
719
687
  }
720
- }, d = ((u = t == null ? void 0 : t.strategy) == null ? void 0 : u.call(t, s)) || F(s), l = async (a) => {
721
- var S, C, T;
722
- i && (i.remove(), i = null);
723
- const p = n(), c = p.in && await p.in(a), g = !(t != null && t.strategy) && p.out ? p.out(a) : void 0;
724
- if (!c)
688
+ }, a = ((h = t == null ? void 0 : t.strategy) == null ? void 0 : h.call(t, s)) || tt(s), c = async (u) => {
689
+ var S, E, A;
690
+ e && (e.remove(), e = null);
691
+ const g = n(), l = g.in && await g.in(u), w = !(t != null && t.strategy) && g.out ? g.out(u) : void 0;
692
+ if (!l)
725
693
  return;
726
- if (V(c)) {
694
+ if (M(l)) {
727
695
  const v = {
728
- in: Promise.resolve(c),
729
- out: g && Promise.resolve(g)
696
+ in: Promise.resolve(l),
697
+ out: w && Promise.resolve(w)
730
698
  };
731
- if (!(await d.runIn(v)).config) {
732
- e && (e.direction = "in");
699
+ if (!(await a.runIn(v)).config) {
700
+ i && (i.direction = "in");
733
701
  return;
734
702
  }
735
- (S = c.prepare) == null || S.call(c, a), c.wait && await c.wait();
736
- const E = new j({
737
- ...c,
703
+ (S = l.prepare) == null || S.call(l, u), l.wait && await l.wait();
704
+ const C = new L({
705
+ ...l,
738
706
  onEnd: () => {
739
- var A;
740
- e = null, (A = c.onEnd) == null || A.call(c);
707
+ var b;
708
+ i = null, (b = l.onEnd) == null || b.call(l);
741
709
  }
742
710
  });
743
- e = {
744
- controller: E,
745
- direction: "in"
746
- }, E.forward();
711
+ i = { controller: C, direction: "in" }, C.forward();
747
712
  return;
748
713
  }
749
- const w = {
750
- in: Promise.resolve(c),
751
- out: g && Promise.resolve(g)
752
- }, f = await d.runIn(w);
753
- if (!f.config)
754
- return;
755
- if ("springs" in f.config) {
756
- console.error("Unexpected MultiSpringConfig in single-spring path");
714
+ const d = {
715
+ in: Promise.resolve(l),
716
+ out: w && Promise.resolve(w)
717
+ }, f = await a.runIn(d);
718
+ if (!f.config || "springs" in f.config)
757
719
  return;
758
- }
759
- (T = (C = f.config).prepare) == null || T.call(C, a), f.config.wait && await f.config.wait();
760
- const y = O.fromState(f.state, {
720
+ (A = (E = f.config).prepare) == null || A.call(E, u), f.config.wait && await f.config.wait();
721
+ const y = k.fromState(f.state, {
761
722
  from: f.from,
762
723
  to: f.to,
763
724
  spring: f.config.spring,
725
+ tick: f.config.tick,
726
+ css: f.config.css ? { element: u, style: f.config.css } : void 0,
764
727
  onStart: f.config.onStart,
765
- onUpdate: f.config.tick,
766
728
  onComplete: () => {
767
- var v, b;
768
- e = null, (b = (v = f.config) == null ? void 0 : v.onEnd) == null || b.call(v);
729
+ var v, T;
730
+ i = null, (T = (v = f.config) == null ? void 0 : v.onEnd) == null || T.call(v);
769
731
  }
770
732
  });
771
- e = { controller: y, direction: "in" }, f.direction === "forward" ? y.forward() : y.backward();
772
- }, h = async (a) => {
773
- var S, C, T;
774
- i = a;
775
- const p = n(), c = p.out && await p.out(a);
776
- if (!c)
733
+ i = { controller: y, direction: "in" }, f.direction === "forward" ? y.forward() : y.backward();
734
+ }, m = async (u) => {
735
+ var S, E, A;
736
+ e = u;
737
+ const g = n(), l = g.out && await g.out(u);
738
+ if (!l)
777
739
  return;
778
- if (V(c)) {
740
+ if (M(l)) {
779
741
  const v = {
780
742
  in: void 0,
781
- // Don't fetch IN config for exit transitions
782
- out: Promise.resolve(c)
743
+ out: Promise.resolve(l)
783
744
  };
784
- if (!(await d.runOut(v)).config) {
785
- e && (e.direction = "out"), i && (i.remove(), i = null);
745
+ if (!(await a.runOut(v)).config) {
746
+ i && (i.direction = "out"), e && (e.remove(), e = null);
786
747
  return;
787
748
  }
788
- (S = c.prepare) == null || S.call(c, a), y(), c.wait && await c.wait();
789
- const E = new j({
790
- ...c,
749
+ (S = l.prepare) == null || S.call(l, u), y(), l.wait && await l.wait();
750
+ const C = new L({
751
+ ...l,
791
752
  onEnd: () => {
792
- var A, x;
793
- (A = c.onEnd) == null || A.call(c), i && (i.remove(), i = null), e = null, (x = t == null ? void 0 : t.onCleanupEnd) == null || x.call(t);
753
+ var b, O;
754
+ (b = l.onEnd) == null || b.call(l), e && (e.remove(), e = null), i = null, (O = t == null ? void 0 : t.onCleanupEnd) == null || O.call(t);
794
755
  }
795
756
  });
796
- e = {
797
- controller: E,
798
- direction: "out"
799
- }, E.forward();
757
+ i = { controller: C, direction: "out" }, C.forward();
800
758
  return;
801
759
  }
802
- const g = {
760
+ const w = {
803
761
  in: void 0,
804
- // Don't fetch IN config for exit transitions
805
- out: Promise.resolve(c)
806
- }, w = await d.runOut(g);
807
- if (!w.config)
762
+ out: Promise.resolve(l)
763
+ }, d = await a.runOut(w);
764
+ if (!d.config || "springs" in d.config)
808
765
  return;
809
- if ("springs" in w.config) {
810
- console.error("Unexpected MultiSpringConfig in single-spring path");
811
- return;
812
- }
813
- (T = (C = w.config).prepare) == null || T.call(C, a), y(), w.config.wait && await w.config.wait();
814
- const f = O.fromState(w.state, {
815
- from: w.from,
816
- to: w.to,
817
- spring: w.config.spring,
818
- onStart: w.config.onStart,
819
- onUpdate: w.config.tick,
766
+ (A = (E = d.config).prepare) == null || A.call(E, u), y(), d.config.wait && await d.config.wait();
767
+ const f = k.fromState(d.state, {
768
+ from: d.from,
769
+ to: d.to,
770
+ spring: d.config.spring,
771
+ tick: d.config.tick,
772
+ css: d.config.css ? { element: u, style: d.config.css } : void 0,
773
+ onStart: d.config.onStart,
820
774
  onComplete: () => {
821
- var v, b, E;
822
- (b = (v = w.config) == null ? void 0 : v.onEnd) == null || b.call(v), i && (i.remove(), i = null), e = null, (E = t == null ? void 0 : t.onCleanupEnd) == null || E.call(t);
775
+ var v, T, C;
776
+ (T = (v = d.config) == null ? void 0 : v.onEnd) == null || T.call(v), e && (e.remove(), e = null), i = null, (C = t == null ? void 0 : t.onCleanupEnd) == null || C.call(t);
823
777
  }
824
778
  });
825
- e = { controller: f, direction: "out" }, w.direction === "forward" ? f.forward() : f.backward();
779
+ i = { controller: f, direction: "out" }, d.direction === "forward" ? f.forward() : f.backward();
826
780
  function y() {
827
- !o || !i || (r && o.contains(r) ? o.insertBefore(i, r) : o.appendChild(i));
781
+ !o || !e || (r && o.contains(r) ? o.insertBefore(e, r) : o.appendChild(e));
828
782
  }
829
783
  };
830
- return (a) => {
831
- if (a)
832
- return o = a.parentElement, r = a.nextElementSibling, l(a), () => {
833
- if (a.isConnected) {
834
- const p = a.cloneNode(!0);
835
- h(p);
784
+ return (u) => {
785
+ if (u)
786
+ return o = u.parentElement, r = u.nextElementSibling, c(u), () => {
787
+ if (u.isConnected) {
788
+ const g = u.cloneNode(!0);
789
+ m(g);
836
790
  } else
837
- h(a);
791
+ m(u);
838
792
  };
839
793
  };
840
794
  }
841
- const Y = 3, X = (n) => {
795
+ const nt = 3, ot = (n) => {
842
796
  if (!n) return null;
843
797
  const t = n.split(`
844
- `).map((e) => e.trim());
845
- for (let e = Y; e < Math.min(t.length, 6); e++) {
846
- const i = t[e], o = i == null ? void 0 : i.match(/\(?([^):]+):(\d+):(\d+)\)?$/);
798
+ `).map((i) => i.trim());
799
+ for (let i = nt; i < Math.min(t.length, 6); i++) {
800
+ const e = t[i], o = e == null ? void 0 : e.match(/\(?([^):]+):(\d+):(\d+)\)?$/);
847
801
  if (!o)
848
802
  continue;
849
- const r = o[1] ?? "", s = o[2] ?? "0", d = o[3] ?? "0";
850
- return { file: r.split(/[\\/]/).pop() || r, line: s, column: d };
803
+ const r = o[1] ?? "", s = o[2] ?? "0", a = o[3] ?? "0";
804
+ return { file: r.split(/[\\/]/).pop() || r, line: s, column: a };
851
805
  }
852
806
  return null;
853
- }, M = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
854
- function B(n, t, e) {
855
- M.set(n, t);
856
- let i = R.get(n);
857
- return i || (i = W(
807
+ }, R = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
808
+ function rt(n, t, i) {
809
+ R.set(n, t);
810
+ let e = V.get(n);
811
+ return e || (e = et(
858
812
  () => {
859
- const o = M.get(n);
813
+ const o = R.get(n);
860
814
  return o || (console.warn(`Transition "${String(n)}" not found`), {});
861
815
  },
862
816
  {
863
- strategy: e,
864
- onCleanupEnd: () => D(n)
817
+ strategy: i,
818
+ onCleanupEnd: () => Y(n)
865
819
  }
866
- ), R.set(n, i), i);
820
+ ), V.set(n, e), e);
867
821
  }
868
- function D(n) {
869
- M.delete(n), R.delete(n);
822
+ function Y(n) {
823
+ R.delete(n), V.delete(n);
870
824
  }
871
- function K() {
872
- const n = X(new Error().stack);
825
+ function st() {
826
+ const n = ot(new Error().stack);
873
827
  return n ? `auto_${n.file}_${n.line}_${n.column}` : Symbol(`ssgoi_auto_${Date.now()}`);
874
828
  }
875
- const L = globalThis.FinalizationRegistry, U = L ? (
829
+ const _ = globalThis.FinalizationRegistry, F = _ ? (
876
830
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
877
- new L((n) => {
831
+ new _((n) => {
878
832
  try {
879
- D(n);
833
+ Y(n);
880
834
  } catch {
881
835
  }
882
836
  })
883
837
  ) : void 0;
884
- function nt(n) {
885
- const t = n.key ?? K();
886
- if (n.ref && U)
838
+ function gt(n) {
839
+ const t = n.key ?? st();
840
+ if (n.ref && F)
887
841
  try {
888
- U.register(n.ref, t);
842
+ F.register(n.ref, t);
889
843
  } catch {
890
844
  }
891
- return B(
845
+ return rt(
892
846
  t,
893
847
  {
894
848
  in: n.in,
895
849
  out: n.out
896
850
  },
897
- n[z]
851
+ n[X]
898
852
  );
899
853
  }
900
- function q(n) {
901
- const t = n.filter((e) => e.symmetric).map((e) => ({
902
- from: e.to,
903
- to: e.from,
904
- transition: e.transition
854
+ function ct(n) {
855
+ const t = n.filter((i) => i.symmetric).map((i) => ({
856
+ from: i.to,
857
+ to: i.from,
858
+ transition: i.transition
905
859
  }));
906
860
  return [...n, ...t];
907
861
  }
908
- function G(n) {
909
- let t = !1, e = 0, i = 0, o = !1;
910
- const r = 50, s = 50, d = (c) => {
862
+ function at(n) {
863
+ let t = !1, i = 0, e = 0, o = !1;
864
+ const r = 50, s = (w) => {
911
865
  if (!n) return;
912
- const g = c.touches[0];
913
- g && (o = g.clientX < s, o && (e = g.clientX, i = g.clientY));
914
- }, l = (c) => {
915
- if (!n || !o || t) return;
916
- const g = c.touches[0];
917
- if (!g) return;
918
- const w = g.clientX - e, f = g.clientY - i;
919
- w > r && Math.abs(w) > Math.abs(f) && (t = !0, setTimeout(() => {
920
- t = !1;
921
- }, 500));
922
- }, h = () => {
923
- n && (o = !1, e = 0, i = 0);
866
+ const d = w.touches[0];
867
+ d && (o = d.clientX < r, o && (i = d.clientX, e = d.clientY));
868
+ }, a = (w) => {
869
+ if (!n || !o) return;
870
+ const d = w.touches[0];
871
+ if (!d) return;
872
+ const f = d.clientX - i, y = d.clientY - e;
873
+ f > window.outerWidth / 2 - 5 && Math.abs(f) > Math.abs(y) ? t = !0 : t = !1;
874
+ }, c = () => {
875
+ n && (o = !1, i = 0, e = 0);
876
+ }, m = () => t, h = () => {
877
+ typeof window > "u" || n && (window.addEventListener("touchstart", s, { passive: !0 }), window.addEventListener("touchmove", a, { passive: !0 }), window.addEventListener("touchend", c, { passive: !0 }));
878
+ }, u = () => {
879
+ typeof window > "u" || (window.removeEventListener("touchstart", s), window.removeEventListener("touchmove", a), window.removeEventListener("touchend", c));
924
880
  };
881
+ let g = 0;
925
882
  return {
926
- initialize: () => {
927
- typeof window > "u" || n && (window.addEventListener("touchstart", d, { passive: !0 }), window.addEventListener("touchmove", l, { passive: !0 }), window.addEventListener("touchend", h, { passive: !0 }));
928
- },
929
- cleanup: () => {
930
- typeof window > "u" || (window.removeEventListener("touchstart", d), window.removeEventListener("touchmove", l), window.removeEventListener("touchend", h));
931
- },
932
- isSwipePending: () => t
883
+ initialize: h,
884
+ cleanup: u,
885
+ isSwipePending: m,
886
+ resetSwipeDetection: () => {
887
+ g++, g > 1 && (g = 0, t = !1);
888
+ }
933
889
  };
934
890
  }
935
- const J = (n) => {
891
+ const lt = (n) => {
936
892
  let t = n.parentElement;
937
893
  for (; t && t !== document.body; ) {
938
- const e = window.getComputedStyle(t), i = e.overflow + e.overflowY + e.overflowX;
939
- if (i.includes("auto") || i.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
894
+ const i = window.getComputedStyle(t), e = i.overflow + i.overflowY + i.overflowX;
895
+ if (e.includes("auto") || e.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
940
896
  return t;
941
897
  t = t.parentElement;
942
898
  }
943
899
  return document.documentElement;
944
- }, Q = (n) => {
900
+ }, ut = (n) => {
945
901
  let t = n.parentElement;
946
902
  for (; t && t !== document.body; ) {
947
- const e = window.getComputedStyle(t).position;
948
- if (e === "relative" || e === "absolute" || e === "fixed" || e === "sticky")
903
+ const i = window.getComputedStyle(t).position;
904
+ if (i === "relative" || i === "absolute" || i === "fixed" || i === "sticky")
949
905
  return t;
950
906
  t = t.parentElement;
951
907
  }
952
908
  return document.body;
953
909
  };
954
- function Z() {
910
+ function ft() {
955
911
  let n = null, t = null;
956
- const e = /* @__PURE__ */ new Map();
957
- let i = null;
912
+ const i = /* @__PURE__ */ new Map();
913
+ let e = null;
958
914
  const o = () => {
959
- n && i && e.set(i, {
915
+ n && e && i.set(e, {
960
916
  x: n.scrollLeft,
961
917
  y: n.scrollTop
962
918
  });
963
919
  };
964
920
  return {
965
- initializeContext: (u, a) => {
966
- t = u, n || (n = J(u), (n === document.documentElement ? window : n).addEventListener("scroll", o, {
921
+ initializeContext: (h, u) => {
922
+ t = h, n || (n = lt(h), (n === document.documentElement ? window : n).addEventListener("scroll", o, {
967
923
  passive: !0
968
- })), i = a;
924
+ })), e = u;
969
925
  },
970
- calculateScrollOffset: (u, a) => {
971
- const p = u && e.has(u) ? e.get(u) : { x: 0, y: 0 }, c = a && e.has(a) ? e.get(a) : { x: 0, y: 0 };
926
+ calculateScrollOffset: (h, u) => {
927
+ const g = h && i.has(h) ? i.get(h) : { x: 0, y: 0 }, l = u && i.has(u) ? i.get(u) : { x: 0, y: 0 };
972
928
  return {
973
- x: -c.x + p.x,
974
- y: -c.y + p.y
929
+ x: -l.x + g.x,
930
+ y: -l.y + g.y
975
931
  };
976
932
  },
977
933
  getScrollContainer: () => n,
978
- getPositionedParentElement: () => t ? Q(t) : document.body,
979
- getScrollPosition: (u) => u && e.has(u) ? e.get(u) : { x: 0, y: 0 }
934
+ getPositionedParentElement: () => t ? ut(t) : document.body,
935
+ getScrollPosition: (h) => h && i.has(h) ? i.get(h) : { x: 0, y: 0 }
980
936
  };
981
937
  }
982
938
  function P(n, t) {
983
939
  if (t === "*")
984
940
  return !0;
985
941
  if (t.endsWith("/*")) {
986
- const e = t.slice(0, -2);
987
- return n === e || n.startsWith(e + "/");
942
+ const i = t.slice(0, -2);
943
+ return n === i || n.startsWith(i + "/");
988
944
  }
989
945
  return n === t;
990
946
  }
991
- function tt(n, t, e) {
992
- for (const i of e)
993
- if (P(n, i.from) && P(t, i.to))
994
- return i.transition;
995
- for (const i of e)
996
- if ((i.from === "*" || P(n, i.from)) && (i.to === "*" || P(t, i.to)))
997
- return i.transition;
947
+ function mt(n, t, i) {
948
+ for (const e of i)
949
+ if (P(n, e.from) && P(t, e.to))
950
+ return e.transition;
951
+ for (const e of i)
952
+ if ((e.from === "*" || P(n, e.from)) && (e.to === "*" || P(t, e.to)))
953
+ return e.transition;
998
954
  return null;
999
955
  }
1000
- function ot(n) {
956
+ function pt(n) {
1001
957
  const {
1002
958
  transitions: t = [],
1003
- defaultTransition: e,
1004
- middleware: i = (f, y) => ({ from: f, to: y }),
959
+ defaultTransition: i,
960
+ middleware: e = (f, y) => ({ from: f, to: y }),
1005
961
  // Identity function as default
1006
962
  skipOnIosSwipe: o = !0
1007
963
  // Default to true - skip animations on iOS swipe
1008
964
  } = n;
1009
965
  let r = null;
1010
- const s = q(t), {
1011
- initializeContext: d,
1012
- calculateScrollOffset: l,
1013
- getScrollContainer: h,
1014
- getPositionedParentElement: u,
1015
- getScrollPosition: a
1016
- } = Z(), p = G(o);
1017
- p.initialize();
1018
- function c() {
966
+ const s = ct(t), {
967
+ initializeContext: a,
968
+ calculateScrollOffset: c,
969
+ getScrollContainer: m,
970
+ getPositionedParentElement: h,
971
+ getScrollPosition: u
972
+ } = ft(), g = at(o);
973
+ g.initialize();
974
+ function l() {
1019
975
  if (r != null && r.from && (r != null && r.to)) {
1020
- const { from: f, to: y } = i(
976
+ const { from: f, to: y } = e(
1021
977
  r.from,
1022
978
  r.to
1023
- ), C = tt(
979
+ ), E = mt(
1024
980
  f,
1025
981
  y,
1026
982
  s
1027
- ) || e, T = l(
983
+ ) || i, A = c(
1028
984
  r.from,
1029
985
  r.to
1030
986
  ), v = {
1031
- scrollOffset: T,
1032
- scroll: a(r.from),
987
+ scrollOffset: A,
988
+ scroll: u(r.from),
1033
989
  get scrollingElement() {
1034
- return h() || document.documentElement;
990
+ return m() || document.documentElement;
1035
991
  },
1036
992
  get positionedParent() {
1037
- return u();
993
+ return h();
1038
994
  }
1039
- }, b = {
1040
- scrollOffset: T,
995
+ }, T = {
996
+ scrollOffset: A,
1041
997
  get scroll() {
1042
- return r ? a(r.to) : { x: 0, y: 0 };
998
+ return r ? u(r.to) : { x: 0, y: 0 };
1043
999
  },
1044
1000
  get scrollingElement() {
1045
- return h() || document.documentElement;
1001
+ return m() || document.documentElement;
1046
1002
  },
1047
1003
  get positionedParent() {
1048
- return u();
1004
+ return h();
1049
1005
  }
1050
1006
  };
1051
- C && (C.out && r.outResolve && r.outResolve(
1052
- (E) => C.out(E, v)
1053
- ), C.in && r.inResolve && r.inResolve(
1054
- (E) => C.in(E, b)
1007
+ E && (E.out && r.outResolve && r.outResolve(
1008
+ (C) => E.out(C, v)
1009
+ ), E.in && r.inResolve && r.inResolve(
1010
+ (C) => E.in(C, T)
1055
1011
  )), r = null;
1056
1012
  }
1057
1013
  }
1058
- const g = async (f, y) => p.isSwipePending() ? () => ({}) : y === "in" && (!r || !r.from) ? () => ({}) : (r || (r = {}), y === "out" ? (r.from = f, new Promise((S) => {
1059
- r.outResolve = S, c();
1014
+ const w = async (f, y) => g.isSwipePending() ? (g.resetSwipeDetection(), () => ({})) : y === "in" && (!r || !r.from) ? () => ({}) : (r || (r = {}), y === "out" ? (r.from = f, new Promise((S) => {
1015
+ r.outResolve = S, l();
1060
1016
  })) : (r.to = f, new Promise((S) => {
1061
- r.inResolve = S, c();
1017
+ r.inResolve = S, l();
1062
1018
  })));
1063
1019
  return (f) => ({
1064
1020
  key: f,
1065
- in: async (y) => (d(y, f), (await g(f, "in"))(y)),
1066
- out: async (y) => (await g(f, "out"))(y),
1021
+ in: async (y) => (a(y, f), (await w(f, "in"))(y)),
1022
+ out: async (y) => (await w(f, "out"))(y),
1067
1023
  // Add page transition strategy for page-level transitions
1068
- [z]: N
1024
+ [X]: it
1069
1025
  });
1070
1026
  }
1071
1027
  export {
1072
- z as TRANSITION_STRATEGY,
1073
- F as createDefaultStrategy,
1074
- N as createPageTransitionStrategy,
1075
- ot as createSggoiTransitionContext,
1076
- K as generateAutoKey,
1077
- V as isMultiSpring,
1078
- at as isSingleSpring,
1079
- lt as jaeminInternal,
1080
- nt as transition
1028
+ X as TRANSITION_STRATEGY,
1029
+ tt as createDefaultStrategy,
1030
+ it as createPageTransitionStrategy,
1031
+ pt as createSggoiTransitionContext,
1032
+ st as generateAutoKey,
1033
+ vt as isCssAnimation,
1034
+ M as isMultiSpring,
1035
+ St as isSingleSpring,
1036
+ Ct as isTickAnimation,
1037
+ At as jaeminInternal,
1038
+ gt as transition,
1039
+ Et as validateAnimationMode
1081
1040
  };