@ssgoi/core 3.5.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/animator/integrator/double-spring-integrator.d.ts +31 -0
  2. package/dist/animator/integrator/double-spring-integrator.d.ts.map +1 -0
  3. package/dist/animator/integrator/index.d.ts +13 -0
  4. package/dist/animator/integrator/index.d.ts.map +1 -0
  5. package/dist/animator/integrator/inertia-integrator.d.ts +34 -0
  6. package/dist/animator/integrator/inertia-integrator.d.ts.map +1 -0
  7. package/dist/animator/integrator/provider.d.ts +22 -0
  8. package/dist/animator/integrator/provider.d.ts.map +1 -0
  9. package/dist/animator/integrator/spring-integrator.d.ts +19 -0
  10. package/dist/animator/integrator/spring-integrator.d.ts.map +1 -0
  11. package/dist/animator/integrator/types.d.ts +34 -0
  12. package/dist/animator/integrator/types.d.ts.map +1 -0
  13. package/dist/animator/multi-animator.d.ts +18 -13
  14. package/dist/animator/multi-animator.d.ts.map +1 -1
  15. package/dist/animator/{animate → runner}/css-runner.d.ts +2 -2
  16. package/dist/animator/runner/css-runner.d.ts.map +1 -0
  17. package/dist/animator/runner/provider.d.ts +35 -0
  18. package/dist/animator/runner/provider.d.ts.map +1 -0
  19. package/dist/animator/{animate → runner}/tick-runner.d.ts +2 -2
  20. package/dist/animator/runner/tick-runner.d.ts.map +1 -0
  21. package/dist/animator/runner/ticker.d.ts.map +1 -0
  22. package/dist/animator/{animate → runner}/types.d.ts +6 -3
  23. package/dist/animator/runner/types.d.ts.map +1 -0
  24. package/dist/animator/{index.d.ts → single-animator.d.ts} +22 -12
  25. package/dist/animator/single-animator.d.ts.map +1 -0
  26. package/dist/animator/{animation.d.ts → types.d.ts} +2 -2
  27. package/dist/animator/types.d.ts.map +1 -0
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.js +552 -569
  30. package/dist/provider-Cs5iBqRD.cjs +1 -0
  31. package/dist/provider-Cu4NSF1Q.js +167 -0
  32. package/dist/transition/create-transition-callback.d.ts.map +1 -1
  33. package/dist/transition/transition-strategy.d.ts +8 -8
  34. package/dist/transition/transition-strategy.d.ts.map +1 -1
  35. package/dist/transitions/blur.d.ts +4 -4
  36. package/dist/transitions/blur.d.ts.map +1 -1
  37. package/dist/transitions/bounce.d.ts +4 -4
  38. package/dist/transitions/bounce.d.ts.map +1 -1
  39. package/dist/transitions/fade.d.ts +4 -4
  40. package/dist/transitions/fade.d.ts.map +1 -1
  41. package/dist/transitions/index.cjs +1 -1
  42. package/dist/transitions/index.d.ts +5 -0
  43. package/dist/transitions/index.d.ts.map +1 -1
  44. package/dist/transitions/index.js +141 -191
  45. package/dist/transitions/rotate.d.ts +4 -4
  46. package/dist/transitions/rotate.d.ts.map +1 -1
  47. package/dist/transitions/scale.d.ts +4 -4
  48. package/dist/transitions/scale.d.ts.map +1 -1
  49. package/dist/transitions/slide.d.ts +4 -4
  50. package/dist/transitions/slide.d.ts.map +1 -1
  51. package/dist/transitions/utils.d.ts +8 -0
  52. package/dist/transitions/utils.d.ts.map +1 -0
  53. package/dist/types.cjs +1 -1
  54. package/dist/types.d.ts +124 -38
  55. package/dist/types.d.ts.map +1 -1
  56. package/dist/types.js +41 -48
  57. package/dist/utils/index.d.ts +1 -0
  58. package/dist/utils/index.d.ts.map +1 -1
  59. package/dist/utils/wait-paint.d.ts +15 -0
  60. package/dist/utils/wait-paint.d.ts.map +1 -0
  61. package/dist/view-transitions/blind.d.ts +2 -3
  62. package/dist/view-transitions/blind.d.ts.map +1 -1
  63. package/dist/view-transitions/curtain-reveal.d.ts +2 -3
  64. package/dist/view-transitions/curtain-reveal.d.ts.map +1 -1
  65. package/dist/view-transitions/depth.d.ts +2 -2
  66. package/dist/view-transitions/depth.d.ts.map +1 -1
  67. package/dist/view-transitions/drill.d.ts +2 -2
  68. package/dist/view-transitions/drill.d.ts.map +1 -1
  69. package/dist/view-transitions/fade.d.ts +2 -3
  70. package/dist/view-transitions/fade.d.ts.map +1 -1
  71. package/dist/view-transitions/film.d.ts +2 -1
  72. package/dist/view-transitions/film.d.ts.map +1 -1
  73. package/dist/view-transitions/hero.d.ts +2 -2
  74. package/dist/view-transitions/hero.d.ts.map +1 -1
  75. package/dist/view-transitions/index.cjs +19 -19
  76. package/dist/view-transitions/index.d.ts +1 -0
  77. package/dist/view-transitions/index.d.ts.map +1 -1
  78. package/dist/view-transitions/index.js +874 -869
  79. package/dist/view-transitions/instagram.d.ts +2 -2
  80. package/dist/view-transitions/instagram.d.ts.map +1 -1
  81. package/dist/view-transitions/jaemin.d.ts +2 -2
  82. package/dist/view-transitions/jaemin.d.ts.map +1 -1
  83. package/dist/view-transitions/pinterest.d.ts +2 -2
  84. package/dist/view-transitions/pinterest.d.ts.map +1 -1
  85. package/dist/view-transitions/rotate.d.ts +5 -2
  86. package/dist/view-transitions/rotate.d.ts.map +1 -1
  87. package/dist/view-transitions/scroll.d.ts +2 -2
  88. package/dist/view-transitions/scroll.d.ts.map +1 -1
  89. package/dist/view-transitions/sheet.d.ts +2 -2
  90. package/dist/view-transitions/sheet.d.ts.map +1 -1
  91. package/dist/view-transitions/slide.d.ts +2 -2
  92. package/dist/view-transitions/slide.d.ts.map +1 -1
  93. package/dist/view-transitions/snap.d.ts +14 -0
  94. package/dist/view-transitions/snap.d.ts.map +1 -0
  95. package/dist/view-transitions/strip.d.ts +6 -2
  96. package/dist/view-transitions/strip.d.ts.map +1 -1
  97. package/dist/view-transitions/swap.d.ts +2 -2
  98. package/dist/view-transitions/swap.d.ts.map +1 -1
  99. package/package.json +1 -1
  100. package/dist/animator/animate/css-runner.d.ts.map +0 -1
  101. package/dist/animator/animate/index.d.ts +0 -42
  102. package/dist/animator/animate/index.d.ts.map +0 -1
  103. package/dist/animator/animate/tick-runner.d.ts.map +0 -1
  104. package/dist/animator/animate/types.d.ts.map +0 -1
  105. package/dist/animator/animation.d.ts.map +0 -1
  106. package/dist/animator/index.d.ts.map +0 -1
  107. package/dist/animator/spring-core.d.ts +0 -82
  108. package/dist/animator/spring-core.d.ts.map +0 -1
  109. package/dist/animator/ticker.d.ts.map +0 -1
  110. /package/dist/animator/{ticker.d.ts → runner/ticker.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,64 +1,65 @@
1
- var nt = Object.defineProperty;
2
- var it = (i, e, t) => e in i ? nt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var m = (i, e, t) => it(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { normalizeToMultiSpring as P, normalizeMultiSpringSchedule as Y } from "./types.js";
5
- import { isCssAnimation as zt, isMultiSpring as Dt, isSingleSpring as _t, isTickAnimation as qt, validateAnimationMode as Ht, validateSpringItem as Nt } from "./types.js";
6
- class ot {
1
+ var J = Object.defineProperty;
2
+ var Q = (n, i, t) => i in n ? J(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t;
3
+ var d = (n, i, t) => Q(n, typeof i != "symbol" ? i + "" : i, t);
4
+ import { normalizeToMultiAnimation as R, normalizeSchedule as N } from "./types.js";
5
+ import { isCssAnimation as Lt, isMultiAnimation as Dt, isSingleAnimation as zt, isTickAnimation as qt } from "./types.js";
6
+ import { S as Y, I as Z, a as tt } from "./provider-Cu4NSF1Q.js";
7
+ class et {
7
8
  constructor() {
8
- m(this, "listeners", /* @__PURE__ */ new Set());
9
- m(this, "rafId", null);
10
- m(this, "isRunning", !1);
9
+ d(this, "listeners", /* @__PURE__ */ new Set());
10
+ d(this, "rafId", null);
11
+ d(this, "isRunning", !1);
11
12
  // Timing
12
- m(this, "startTime", Date.now());
13
- m(this, "lastUpdate", this.startTime);
14
- m(this, "elapsed", 0);
13
+ d(this, "startTime", Date.now());
14
+ d(this, "lastUpdate", this.startTime);
15
+ d(this, "elapsed", 0);
15
16
  // Lag smoothing (mobile optimization)
16
- m(this, "lagThreshold", 500);
17
+ d(this, "lagThreshold", 500);
17
18
  // ms - detect tab switches, backgrounding
18
- m(this, "adjustedLag", 33);
19
+ d(this, "adjustedLag", 33);
19
20
  // ms - max time jump to prevent animation skip
20
- m(this, "maxDeltaTime", 33);
21
+ d(this, "maxDeltaTime", 33);
21
22
  // ms - clamp for physics stability (30fps minimum)
22
23
  // FPS throttling
23
- m(this, "gap", 1e3 / 240);
24
+ d(this, "gap", 1e3 / 240);
24
25
  // max 240fps
25
- m(this, "nextTime", this.gap);
26
- m(this, "tick", () => {
27
- const e = Date.now();
28
- let n = e - this.lastUpdate;
29
- n > this.lagThreshold || n < 0 ? (this.startTime += n - this.adjustedLag, n = this.adjustedLag) : n > this.maxDeltaTime && (n = this.maxDeltaTime), this.lastUpdate = e;
30
- const r = e - this.startTime, s = r - this.nextTime;
26
+ d(this, "nextTime", this.gap);
27
+ d(this, "tick", () => {
28
+ const i = Date.now();
29
+ let e = i - this.lastUpdate;
30
+ e > this.lagThreshold || e < 0 ? (this.startTime += e - this.adjustedLag, e = this.adjustedLag) : e > this.maxDeltaTime && (e = this.maxDeltaTime), this.lastUpdate = i;
31
+ const o = i - this.startTime, s = o - this.nextTime;
31
32
  if (s > 0) {
32
- const a = n / 1e3;
33
- this.elapsed = r / 1e3, this.nextTime += s + (s >= this.gap ? 4 : this.gap - s), this.listeners.forEach((o) => {
34
- o(a, this.elapsed);
33
+ const c = e / 1e3;
34
+ this.elapsed = o / 1e3, this.nextTime += s + (s >= this.gap ? 4 : this.gap - s), this.listeners.forEach((r) => {
35
+ r(c, this.elapsed);
35
36
  });
36
37
  }
37
38
  this.listeners.size > 0 ? this.rafId = requestAnimationFrame(this.tick) : (this.isRunning = !1, this.rafId = null);
38
39
  });
39
40
  }
40
- subscribe(e) {
41
- return this.listeners.add(e), this.isRunning || (this.isRunning = !0, this.rafId = requestAnimationFrame(this.tick)), () => {
42
- this.unsubscribe(e);
41
+ subscribe(i) {
42
+ return this.listeners.add(i), this.isRunning || (this.isRunning = !0, this.rafId = requestAnimationFrame(this.tick)), () => {
43
+ this.unsubscribe(i);
43
44
  };
44
45
  }
45
- unsubscribe(e) {
46
- this.listeners.delete(e), this.listeners.size === 0 && this.rafId !== null && (cancelAnimationFrame(this.rafId), this.isRunning = !1, this.rafId = null);
46
+ unsubscribe(i) {
47
+ this.listeners.delete(i), this.listeners.size === 0 && this.rafId !== null && (cancelAnimationFrame(this.rafId), this.isRunning = !1, this.rafId = null);
47
48
  }
48
49
  /**
49
50
  * Configure lag smoothing behavior
50
51
  * @param threshold - Time threshold to detect lag (default: 500ms)
51
52
  * @param adjustedLag - Max time jump when lag detected (default: 33ms)
52
53
  */
53
- lagSmoothing(e, t) {
54
- this.lagThreshold = e, this.adjustedLag = Math.min(t, e);
54
+ lagSmoothing(i, t) {
55
+ this.lagThreshold = i, this.adjustedLag = Math.min(t, i);
55
56
  }
56
57
  /**
57
58
  * Set maximum FPS
58
59
  * @param fps - Target FPS (default: 240)
59
60
  */
60
- fps(e) {
61
- this.gap = 1e3 / e, this.nextTime = this.elapsed * 1e3 + this.gap;
61
+ fps(i) {
62
+ this.gap = 1e3 / i, this.nextTime = this.elapsed * 1e3 + this.gap;
62
63
  }
63
64
  getListenerCount() {
64
65
  return this.listeners.size;
@@ -67,254 +68,229 @@ class ot {
67
68
  return this.elapsed;
68
69
  }
69
70
  }
70
- const D = new ot();
71
- function j(i) {
72
- const e = i.stiffness, t = i.damping, n = 1, r = Math.sqrt(e / n), s = t / (2 * Math.sqrt(e * n)), a = { omega: r, zeta: s };
73
- if (i.doubleSpring) {
74
- const o = typeof i.doubleSpring == "number" ? i.doubleSpring : 1, c = e * o, u = Math.sqrt(c / n), f = t / (2 * Math.sqrt(c * n));
75
- a.follower = { omega: u, zeta: f };
76
- }
77
- return a;
78
- }
79
- function _(i, e, t, n, r, s) {
80
- const a = -2 * s * r * n * e, o = s * n * n * (t - i), c = e + a + o;
81
- return { position: i + s * c, velocity: c };
82
- }
83
- function G(i, e, t, n) {
84
- const r = Math.min(n, 0.033);
85
- if (t.follower) {
86
- const u = i._leader ?? {
87
- position: i.position,
88
- velocity: i.velocity
89
- }, f = _(
90
- u.position,
91
- u.velocity,
92
- e,
93
- t.omega,
94
- t.zeta,
95
- r
96
- ), h = _(
97
- i.position,
98
- i.velocity,
99
- f.position,
100
- t.follower.omega,
101
- t.follower.zeta,
102
- r
103
- );
104
- return {
105
- position: h.position,
106
- velocity: h.velocity,
107
- _leader: f
108
- };
109
- }
110
- const { omega: s, zeta: a } = t, o = _(
111
- i.position,
112
- i.velocity,
113
- e,
114
- s,
115
- a,
116
- r
117
- );
118
- return {
119
- position: o.position,
120
- velocity: o.velocity
121
- };
122
- }
123
- const U = 0.01, W = 0.01, $ = 0.05;
124
- function B(i, e) {
125
- const t = Math.abs(e - i.position), n = Math.abs(i.velocity), r = t < U && n < W, s = i;
126
- if (s._leader) {
127
- const a = Math.abs(e - s._leader.position), o = Math.abs(s._leader.velocity);
128
- return a < U && o < W && r;
129
- }
130
- return r;
131
- }
132
- function rt(i) {
71
+ const D = new et();
72
+ function it(n) {
133
73
  const {
134
- from: e,
135
- to: t,
136
- spring: n,
137
- velocity: r = 0,
74
+ integrator: i,
75
+ from: t,
76
+ to: e,
77
+ velocity: o = 0,
138
78
  onUpdate: s,
139
- onComplete: a,
140
- onStart: o
141
- } = i;
142
- let c = { position: e, velocity: r }, u = !0, f = 0, h = !1;
143
- const y = j(n), v = (l) => {
79
+ onComplete: c,
80
+ onStart: r
81
+ } = n;
82
+ let a = { position: t, velocity: o }, u = !0, m = 0, g = !1;
83
+ const y = (S) => {
144
84
  if (u) {
145
- if (h || (h = !0, o == null || o()), c = G(c, t, y, l), B(c, t)) {
146
- if (f += Math.min(l, 0.033), f >= $) {
147
- c = { position: t, velocity: 0 }, u = !1, s(c.position), D.unsubscribe(v), a();
85
+ if (g || (g = !0, r == null || r()), a = i.step(a, e, S), i.isSettled(a, e)) {
86
+ if (m += Math.min(S, 0.033), m >= Y) {
87
+ a = { position: e, velocity: 0 }, u = !1, s(a.position), D.unsubscribe(y), c();
148
88
  return;
149
89
  }
150
90
  } else
151
- f = 0;
152
- s(c.position);
91
+ m = 0;
92
+ s(a.position);
153
93
  }
154
94
  };
155
- return D.subscribe(v), {
95
+ return D.subscribe(y), {
156
96
  stop: () => {
157
- u && (u = !1, D.unsubscribe(v));
97
+ u && (u = !1, D.unsubscribe(y));
158
98
  },
159
- getPosition: () => c.position,
160
- getVelocity: () => c.velocity,
99
+ getPosition: () => a.position,
100
+ getVelocity: () => a.velocity,
161
101
  isRunning: () => u
162
102
  };
163
103
  }
164
- const I = 1e3 / 60;
165
- function st(i, e, t, n = 0) {
166
- const r = j(t), s = 600;
167
- let a = { position: i, velocity: n }, o = 0;
168
- const c = [];
169
- for (let u = 0; u < s; u++) {
170
- const f = u * I;
171
- if (c.push({
172
- time: f,
173
- position: a.position,
174
- velocity: a.velocity
175
- }), a = G(a, e, r, I / 1e3), B(a, e)) {
176
- if (o += I / 1e3, o >= $) {
177
- c.push({
178
- time: (u + 1) * I,
179
- position: e,
104
+ const F = 1e3 / 60;
105
+ function nt(n, i, t, e = 0) {
106
+ let s = { position: i, velocity: e }, c = 0;
107
+ const r = [];
108
+ for (let a = 0; a < 600; a++) {
109
+ const u = a * F;
110
+ if (r.push({
111
+ time: u,
112
+ position: s.position,
113
+ velocity: s.velocity
114
+ }), s = n.step(s, t, F / 1e3), n.isSettled(s, t)) {
115
+ if (c += F / 1e3, c >= Y) {
116
+ r.push({
117
+ time: (a + 1) * F,
118
+ position: t,
180
119
  velocity: 0
181
120
  });
182
121
  break;
183
122
  }
184
123
  } else
185
- o = 0;
124
+ c = 0;
186
125
  }
187
- return c;
126
+ return r;
188
127
  }
189
- function X(i, e) {
190
- if (i.length === 0)
128
+ function U(n, i) {
129
+ if (n.length === 0)
191
130
  return { position: 0, velocity: 0 };
192
- const t = i[0], n = i[i.length - 1];
193
- if (e <= 0)
131
+ const t = n[0], e = n[n.length - 1];
132
+ if (i <= 0)
194
133
  return { position: t.position, velocity: t.velocity };
195
- if (e >= n.time)
196
- return { position: n.position, velocity: n.velocity };
197
- let r = 0, s = i.length - 1;
198
- for (; r < s - 1; ) {
199
- const u = Math.floor((r + s) / 2);
200
- i[u].time <= e ? r = u : s = u;
134
+ if (i >= e.time)
135
+ return { position: e.position, velocity: e.velocity };
136
+ let o = 0, s = n.length - 1;
137
+ for (; o < s - 1; ) {
138
+ const u = Math.floor((o + s) / 2);
139
+ n[u].time <= i ? o = u : s = u;
201
140
  }
202
- const a = i[r], o = i[s], c = (e - a.time) / (o.time - a.time);
141
+ const c = n[o], r = n[s], a = (i - c.time) / (r.time - c.time);
203
142
  return {
204
- position: a.position + (o.position - a.position) * c,
205
- velocity: a.velocity + (o.velocity - a.velocity) * c
143
+ position: c.position + (r.position - c.position) * a,
144
+ velocity: c.velocity + (r.velocity - c.velocity) * a
206
145
  };
207
146
  }
208
- function ct(i, e) {
209
- return i.map((t) => e(t.position));
147
+ function rt(n, i) {
148
+ return n.map((t) => i(t.position));
210
149
  }
211
- function at(i) {
150
+ function ot(n) {
212
151
  const {
213
- element: e,
214
- from: t,
215
- to: n,
216
- spring: r,
152
+ integrator: i,
153
+ element: t,
154
+ from: e,
155
+ to: o,
217
156
  velocity: s = 0,
218
- style: a,
219
- onComplete: o,
220
- onStart: c
221
- } = i, u = st(t, n, r, s);
157
+ style: c,
158
+ onComplete: r,
159
+ onStart: a
160
+ } = n, u = nt(i, e, o, s);
222
161
  if (u.length === 0)
223
- return c == null || c(), o(), {
162
+ return a == null || a(), r(), {
224
163
  stop: () => {
225
164
  },
226
- getPosition: () => n,
165
+ getPosition: () => o,
227
166
  getVelocity: () => 0,
228
167
  isRunning: () => !1
229
168
  };
230
- const f = ct(u, a), h = u[u.length - 1], y = h.time, v = e.animate(f, {
169
+ const m = rt(u, c), g = u[u.length - 1], y = g.time, S = m[0];
170
+ if (S)
171
+ for (const A of Object.keys(S))
172
+ t.style[A] = "";
173
+ const f = t.animate(m, {
231
174
  duration: y,
232
175
  fill: "forwards",
233
- easing: "linear"
176
+ easing: "linear",
177
+ composite: "replace"
234
178
  });
235
179
  let l = !0;
236
- const d = performance.now();
237
- return c == null || c(), v.onfinish = () => {
238
- l && (l = !1, o());
180
+ const E = performance.now();
181
+ return a == null || a(), f.onfinish = () => {
182
+ l && (l = !1, r());
239
183
  }, {
240
184
  stop: () => {
241
- l && (l = !1, v.cancel());
185
+ l && (l = !1, f.cancel());
242
186
  },
243
187
  getPosition: () => {
244
188
  if (!l)
245
- return h.position;
246
- const A = performance.now() - d;
247
- return X(u, A).position;
189
+ return g.position;
190
+ const A = performance.now() - E;
191
+ return U(u, A).position;
248
192
  },
249
193
  getVelocity: () => {
250
194
  if (!l)
251
195
  return 0;
252
- const A = performance.now() - d;
253
- return X(u, A).velocity;
196
+ const A = performance.now() - E;
197
+ return U(u, A).velocity;
254
198
  },
255
199
  isRunning: () => l
256
200
  };
257
201
  }
258
- function lt(i) {
259
- const { from: e, to: t, spring: n, velocity: r, onComplete: s, onStart: a, tick: o, css: c } = i;
260
- if (o && c)
261
- throw new Error("Cannot use both 'tick' and 'css' options together");
262
- return !o && !c ? (a == null || a(), s(), {
263
- stop: () => {
264
- },
265
- getPosition: () => t,
266
- getVelocity: () => 0,
267
- isRunning: () => !1
268
- }) : c ? at({
269
- element: c.element,
270
- from: e,
271
- to: t,
272
- spring: n,
273
- velocity: r,
274
- style: c.style,
275
- onComplete: s,
276
- onStart: a
277
- }) : rt({
278
- from: e,
279
- to: t,
280
- spring: n,
281
- velocity: r,
282
- onUpdate: o,
283
- onComplete: s,
284
- onStart: a
285
- });
202
+ class st {
203
+ /**
204
+ * Get bound runner based on animation mode
205
+ *
206
+ * @param options Animation mode options (tick or css)
207
+ * @returns Bound runner function or null if no animation mode specified
208
+ * @throws Error if both tick and css are provided
209
+ */
210
+ static from(i) {
211
+ const { tick: t, css: e } = i;
212
+ if (t && e)
213
+ throw new Error("Cannot use both 'tick' and 'css' options together");
214
+ return e ? (o) => ot({
215
+ ...o,
216
+ element: e.element,
217
+ style: e.style
218
+ }) : t ? (o) => it({
219
+ ...o,
220
+ onUpdate: t
221
+ }) : null;
222
+ }
286
223
  }
287
- class K {
224
+ class j {
288
225
  }
289
- class F extends K {
226
+ const at = { stiffness: 300, damping: 30 };
227
+ class H extends j {
290
228
  constructor(t) {
291
229
  super();
292
- m(this, "options");
293
- m(this, "controls", null);
294
- m(this, "isAnimating", !1);
295
- m(this, "currentValue");
296
- m(this, "currentVelocity", 0);
297
- if (t.tick && t.css)
298
- throw new Error("Cannot use both 'tick' and 'css' options together");
299
- this.options = {
230
+ d(this, "options");
231
+ d(this, "runner");
232
+ d(this, "controls", null);
233
+ d(this, "isAnimating", !1);
234
+ d(this, "currentValue");
235
+ d(this, "currentVelocity", 0);
236
+ d(this, "updateFn");
237
+ if (this.options = {
300
238
  from: t.from ?? 0,
301
239
  to: t.to ?? 1,
302
- spring: t.spring ?? { stiffness: 300, damping: 30 },
303
- tick: t.tick,
304
- css: t.css,
240
+ physics: t.physics,
305
241
  onComplete: t.onComplete ?? (() => {
306
242
  }),
307
243
  onStart: t.onStart
308
- }, this.currentValue = this.options.from;
244
+ }, this.currentValue = this.options.from, t.tick)
245
+ this.updateFn = (e) => {
246
+ var o;
247
+ return (o = t.tick) == null ? void 0 : o.call(t, e);
248
+ };
249
+ else if (t.css) {
250
+ const { element: e, style: o } = t.css;
251
+ this.updateFn = (s) => {
252
+ const c = o(s);
253
+ for (const [r, a] of Object.entries(c))
254
+ e.style[r] = typeof a == "number" ? String(a) : a;
255
+ };
256
+ } else
257
+ this.updateFn = () => {
258
+ };
259
+ this.runner = st.from({
260
+ tick: t.tick,
261
+ css: t.css
262
+ });
263
+ }
264
+ /**
265
+ * Sync element state to current progress value
266
+ * Uses the update callback if provided
267
+ */
268
+ syncState() {
269
+ var t;
270
+ (t = this.updateFn) == null || t.call(this, this.currentValue);
271
+ }
272
+ /**
273
+ * Create Integrator from physics options
274
+ * Priority: integrator factory > inertia/spring config > default spring
275
+ */
276
+ createIntegrator() {
277
+ const t = this.options.physics;
278
+ return t != null && t.integrator ? t.integrator() : t != null && t.spring || t != null && t.inertia ? Z.from({
279
+ spring: t.spring,
280
+ inertia: t.inertia
281
+ }) : new tt(at);
309
282
  }
310
283
  runAnimation(t) {
311
- this.isAnimating = !0, this.controls = lt({
284
+ var e, o;
285
+ if (this.isAnimating = !0, !this.runner) {
286
+ (o = (e = this.options).onStart) == null || o.call(e), this.currentValue = t, this.currentVelocity = 0, this.isAnimating = !1, this.options.onComplete();
287
+ return;
288
+ }
289
+ this.controls = this.runner({
290
+ integrator: this.createIntegrator(),
312
291
  from: this.currentValue,
313
292
  to: t,
314
- spring: this.options.spring,
315
293
  velocity: this.currentVelocity,
316
- tick: this.options.tick,
317
- css: this.options.css,
318
294
  onStart: this.options.onStart,
319
295
  onComplete: () => {
320
296
  this.currentValue = t, this.currentVelocity = 0, this.isAnimating = !1, this.controls = null, this.options.onComplete();
@@ -362,46 +338,46 @@ class F extends K {
362
338
  updateOptions(t) {
363
339
  this.options = { ...this.options, ...t };
364
340
  }
365
- static fromState(t, n) {
366
- const r = new F(n);
367
- return r.setValue(t.position), r.setVelocity(t.velocity), r;
368
- }
369
341
  }
370
- class L extends K {
342
+ class M extends j {
371
343
  constructor(t) {
372
344
  super();
373
- m(this, "config");
374
- m(this, "animators", /* @__PURE__ */ new Map());
375
- m(this, "springOrder", []);
376
- m(this, "completedCount", 0);
377
- m(this, "completedAnimators", /* @__PURE__ */ new Set());
378
- m(this, "direction", "forward");
379
- m(this, "idCounter", 0);
380
- m(this, "rafId", null);
381
- m(this, "from");
382
- m(this, "to");
383
- this.config = t.config, this.from = t.from, this.to = t.to, this.initializeAnimators();
345
+ d(this, "config");
346
+ d(this, "animators", /* @__PURE__ */ new Map());
347
+ d(this, "itemOrder", []);
348
+ d(this, "completedCount", 0);
349
+ d(this, "completedAnimators", /* @__PURE__ */ new Set());
350
+ d(this, "direction", "forward");
351
+ d(this, "idCounter", 0);
352
+ d(this, "rafId", null);
353
+ d(this, "from");
354
+ d(this, "to");
355
+ d(this, "initialState");
356
+ this.config = t.config, this.from = t.from, this.to = t.to, this.initialState = t.state ?? {
357
+ position: t.from,
358
+ velocity: 0
359
+ }, this.initializeAnimators();
384
360
  }
385
361
  generateId() {
386
362
  return `spring_${this.idCounter++}`;
387
363
  }
388
364
  initializeAnimators() {
389
- this.config.springs.forEach((t) => {
390
- const n = this.generateId(), r = new F({
365
+ this.config.items.forEach((t, e) => {
366
+ const o = this.generateId(), s = new H({
391
367
  from: this.from,
392
368
  to: this.to,
393
- spring: t.spring,
369
+ physics: t.physics,
394
370
  tick: t.tick,
395
371
  css: t.css,
396
- onComplete: () => this.onAnimatorComplete(n),
372
+ onComplete: () => this.onAnimatorComplete(o),
397
373
  onStart: t.onStart
398
374
  });
399
- this.animators.set(n, {
400
- id: n,
375
+ (e === 0 || t.normalizedOffset === 0) && (s.setValue(this.initialState.position), s.setVelocity(this.initialState.velocity), s.syncState()), this.animators.set(o, {
376
+ id: o,
401
377
  item: t,
402
- animator: r,
378
+ animator: s,
403
379
  started: !1
404
- }), this.springOrder.push(n);
380
+ }), this.itemOrder.push(o);
405
381
  });
406
382
  }
407
383
  /**
@@ -409,8 +385,8 @@ class L extends K {
409
385
  * Progress = |position - from| / |to - from|
410
386
  */
411
387
  getAnimatorProgress(t) {
412
- const n = t.animator.getCurrentState(), r = Math.abs(n.to - n.from);
413
- return r === 0 ? 1 : Math.abs(n.position - n.from) / r;
388
+ const e = t.animator.getCurrentState(), o = Math.abs(e.to - e.from);
389
+ return o === 0 ? 1 : Math.abs(e.position - e.from) / o;
414
390
  }
415
391
  /**
416
392
  * Get order of springs based on direction
@@ -418,12 +394,12 @@ class L extends K {
418
394
  * Backward: n-1, n-2, ..., 0
419
395
  */
420
396
  getOrderedIds() {
421
- return this.direction === "forward" ? this.springOrder : [...this.springOrder].reverse();
397
+ return this.direction === "forward" ? this.itemOrder : [...this.itemOrder].reverse();
422
398
  }
423
399
  onAnimatorComplete(t) {
424
- var r, s, a, o, c, u;
425
- const n = this.animators.get(t);
426
- !n || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (s = (r = n.item).onComplete) == null || s.call(r), (o = (a = this.config).onProgress) == null || o.call(a, this.completedCount, this.config.springs.length), this.completedCount === this.config.springs.length && (this.stopScheduler(), (u = (c = this.config).onEnd) == null || u.call(c)));
400
+ var o, s, c, r, a, u;
401
+ const e = this.animators.get(t);
402
+ !e || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (s = (o = e.item).onComplete) == null || s.call(o), (r = (c = this.config).onProgress) == null || r.call(c, this.completedCount, this.config.items.length), this.completedCount === this.config.items.length && (this.stopScheduler(), (u = (a = this.config).onEnd) == null || u.call(a)));
427
403
  }
428
404
  /**
429
405
  * Check and start springs based on previous spring's progress
@@ -431,22 +407,22 @@ class L extends K {
431
407
  */
432
408
  checkAndStartSprings() {
433
409
  const t = this.getOrderedIds();
434
- for (let n = 0; n < t.length; n++) {
435
- const r = t[n], s = this.animators.get(r);
410
+ for (let e = 0; e < t.length; e++) {
411
+ const o = t[e], s = this.animators.get(o);
436
412
  if (!s || s.started) continue;
437
- if (n === 0) {
438
- this.startAnimator(r);
413
+ if (e === 0) {
414
+ this.startAnimator(o);
439
415
  continue;
440
416
  }
441
- const a = t[n - 1], o = this.animators.get(a);
442
- if (!o || !o.started) continue;
443
- const c = this.getAnimatorProgress(o), u = s.item.normalizedOffset;
444
- c >= u && this.startAnimator(r);
417
+ const c = t[e - 1], r = this.animators.get(c);
418
+ if (!r || !r.started) continue;
419
+ const a = this.getAnimatorProgress(r), u = s.item.normalizedOffset;
420
+ a >= u && this.startAnimator(o);
445
421
  }
446
422
  }
447
423
  startAnimator(t) {
448
- const n = this.animators.get(t);
449
- !n || n.started || (n.started = !0, this.direction === "forward" ? n.animator.forward() : n.animator.backward());
424
+ const e = this.animators.get(t);
425
+ !e || e.started || (e.started = !0, this.direction === "forward" ? e.animator.forward() : e.animator.backward());
450
426
  }
451
427
  /**
452
428
  * Start the scheduler loop that checks spring progress
@@ -461,17 +437,17 @@ class L extends K {
461
437
  this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
462
438
  }
463
439
  getFirstAnimator() {
464
- var n;
465
- const t = this.springOrder[0];
466
- return t ? ((n = this.animators.get(t)) == null ? void 0 : n.animator) ?? null : null;
440
+ var e;
441
+ const t = this.itemOrder[0];
442
+ return t ? ((e = this.animators.get(t)) == null ? void 0 : e.animator) ?? null : null;
467
443
  }
468
444
  forward() {
469
- var t, n;
470
- this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (n = (t = this.config).onStart) == null || n.call(t), this.startScheduler();
445
+ var t, e;
446
+ this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (e = (t = this.config).onStart) == null || e.call(t), this.startScheduler();
471
447
  }
472
448
  backward() {
473
- var t, n;
474
- this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (n = (t = this.config).onStart) == null || n.call(t), this.startScheduler();
449
+ var t, e;
450
+ this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (e = (t = this.config).onStart) == null || e.call(t), this.startScheduler();
475
451
  }
476
452
  resetStartedFlags() {
477
453
  this.animators.forEach((t) => {
@@ -487,21 +463,18 @@ class L extends K {
487
463
  this.direction = this.direction === "forward" ? "backward" : "forward", this.animators.forEach((t) => {
488
464
  if (!t.started)
489
465
  return;
490
- const n = t.animator.getCurrentState();
491
- if (n.position === n.to) {
492
- const s = F.fromState(
493
- { position: this.to, velocity: 0 },
494
- {
495
- from: this.to,
496
- to: this.from,
497
- spring: t.item.spring,
498
- tick: t.item.tick,
499
- css: t.item.css,
500
- onComplete: () => this.onAnimatorComplete(t.id),
501
- onStart: t.item.onStart
502
- }
503
- );
504
- s.forward(), t.animator = s;
466
+ const e = t.animator.getCurrentState();
467
+ if (e.position === e.to) {
468
+ const s = new H({
469
+ from: this.to,
470
+ to: this.from,
471
+ physics: t.item.physics,
472
+ tick: t.item.tick,
473
+ css: t.item.css,
474
+ onComplete: () => this.onAnimatorComplete(t.id),
475
+ onStart: t.item.onStart
476
+ });
477
+ s.setValue(this.to), s.setVelocity(0), s.syncState(), s.forward(), t.animator = s;
505
478
  } else
506
479
  t.animator.reverse();
507
480
  });
@@ -534,16 +507,16 @@ class L extends K {
534
507
  * TODO: Support per-spring control
535
508
  */
536
509
  setValue(t) {
537
- const n = this.getFirstAnimator();
538
- n == null || n.setValue(t);
510
+ const e = this.getFirstAnimator();
511
+ e == null || e.setValue(t);
539
512
  }
540
513
  /**
541
514
  * Set velocity on first animator
542
515
  * TODO: Support per-spring control
543
516
  */
544
517
  setVelocity(t) {
545
- const n = this.getFirstAnimator();
546
- n == null || n.setVelocity(t);
518
+ const e = this.getFirstAnimator();
519
+ e == null || e.setVelocity(t);
547
520
  }
548
521
  /**
549
522
  * Check if any animation is currently running
@@ -558,28 +531,27 @@ class L extends K {
558
531
  * Create MultiAnimator from existing state
559
532
  * Uses first animator's state for initialization
560
533
  */
561
- static fromState(t, n) {
562
- const r = new L(n);
563
- return r.setValue(t.position), r.setVelocity(t.velocity), r;
534
+ static fromState(t, e) {
535
+ return new M({ ...e, state: t });
564
536
  }
565
537
  }
566
- const Z = Symbol.for("TRANSITION_STRATEGY"), ut = (i) => ({
567
- runIn: async (e) => {
568
- const { currentAnimation: t } = i;
538
+ const W = Symbol.for("TRANSITION_STRATEGY"), ct = (n) => ({
539
+ runIn: async (i) => {
540
+ const { currentAnimation: t } = n;
569
541
  if (t && t.direction === "out") {
570
- const r = t.controller.getCurrentValue(), s = t.controller.getVelocity();
571
- if (t.controller.stop(), e.out)
542
+ const o = t.controller.getCurrentValue(), s = t.controller.getVelocity();
543
+ if (t.controller.stop(), i.out)
572
544
  return {
573
- config: await e.out,
574
- state: { position: r, velocity: s },
545
+ config: await i.out,
546
+ state: { position: o, velocity: s },
575
547
  from: 1,
576
548
  to: 0,
577
549
  direction: "backward"
578
550
  // Will actually go 0→1 (backward means toward 'from')
579
551
  };
580
552
  }
581
- return e.in ? {
582
- config: await e.in,
553
+ return i.in ? {
554
+ config: await i.in,
583
555
  state: {
584
556
  position: 0,
585
557
  velocity: 0
@@ -597,22 +569,22 @@ const Z = Symbol.for("TRANSITION_STRATEGY"), ut = (i) => ({
597
569
  direction: "forward"
598
570
  };
599
571
  },
600
- runOut: async (e) => {
601
- const { currentAnimation: t } = i;
572
+ runOut: async (i) => {
573
+ const { currentAnimation: t } = n;
602
574
  if (t && t.direction === "in") {
603
- const r = t.controller.getCurrentValue(), s = t.controller.getVelocity();
604
- if (t.controller.stop(), e.in)
575
+ const o = t.controller.getCurrentValue(), s = t.controller.getVelocity();
576
+ if (t.controller.stop(), i.in)
605
577
  return {
606
- config: await e.in,
607
- state: { position: r, velocity: s },
578
+ config: await i.in,
579
+ state: { position: o, velocity: s },
608
580
  from: 0,
609
581
  to: 1,
610
582
  direction: "backward"
611
583
  // Will actually go 1→0 (backward means toward 'from')
612
584
  };
613
585
  }
614
- return e.out ? {
615
- config: await e.out,
586
+ return i.out ? {
587
+ config: await i.out,
616
588
  state: {
617
589
  position: 1,
618
590
  velocity: 0
@@ -630,9 +602,9 @@ const Z = Symbol.for("TRANSITION_STRATEGY"), ut = (i) => ({
630
602
  direction: "forward"
631
603
  };
632
604
  }
633
- }), ft = () => ({
634
- runIn: async (i) => i.in ? {
635
- config: await i.in,
605
+ }), lt = () => ({
606
+ runIn: async (n) => n.in ? {
607
+ config: await n.in,
636
608
  state: {
637
609
  position: 0,
638
610
  velocity: 0
@@ -649,8 +621,8 @@ const Z = Symbol.for("TRANSITION_STRATEGY"), ut = (i) => ({
649
621
  to: 1,
650
622
  direction: "forward"
651
623
  },
652
- runOut: async (i) => i.out ? {
653
- config: await i.out,
624
+ runOut: async (n) => n.out ? {
625
+ config: await n.out,
654
626
  state: {
655
627
  position: 1,
656
628
  velocity: 0
@@ -667,48 +639,76 @@ const Z = Symbol.for("TRANSITION_STRATEGY"), ut = (i) => ({
667
639
  to: 0,
668
640
  direction: "forward"
669
641
  }
670
- }), J = "data-ssgoi-scope", Q = "data-ssgoi-scope-ready";
671
- function Vt() {
672
- return (i) => {
673
- if (i)
674
- return i.setAttribute(J, ""), queueMicrotask(() => {
642
+ }), G = "data-ssgoi-scope", $ = "data-ssgoi-scope-ready";
643
+ function kt() {
644
+ return (n) => {
645
+ if (n)
646
+ return n.setAttribute(G, ""), queueMicrotask(() => {
675
647
  queueMicrotask(() => {
676
- i.setAttribute(Q, "true");
648
+ n.setAttribute($, "true");
677
649
  });
678
650
  }), () => {
679
651
  };
680
652
  };
681
653
  }
682
- function dt(i) {
683
- return i.hasAttribute(Q);
654
+ function ut(n) {
655
+ return n.hasAttribute($);
684
656
  }
685
- function mt(i) {
686
- return i.closest(`[${J}]`);
657
+ function ft(n) {
658
+ return n.closest(`[${G}]`);
687
659
  }
688
- function ht(i, e) {
689
- var v;
690
- let t = null, n = null, r = null, s = null;
691
- const a = {
660
+ const dt = (n) => {
661
+ let i = n.parentElement;
662
+ for (; i && i !== document.body; ) {
663
+ const t = window.getComputedStyle(i), e = t.overflow + t.overflowY + t.overflowX;
664
+ if (e.includes("auto") || e.includes("scroll") || i.scrollHeight > i.clientHeight || i.scrollWidth > i.clientWidth)
665
+ return i;
666
+ i = i.parentElement;
667
+ }
668
+ return document.documentElement;
669
+ }, mt = (n) => {
670
+ let i = n.parentElement;
671
+ for (; i && i !== document.body; ) {
672
+ const t = window.getComputedStyle(i).position;
673
+ if (t === "relative" || t === "absolute" || t === "fixed" || t === "sticky")
674
+ return i;
675
+ i = i.parentElement;
676
+ }
677
+ return document.body;
678
+ };
679
+ function X(n) {
680
+ return new Promise((i) => {
681
+ requestAnimationFrame(() => {
682
+ requestAnimationFrame(() => {
683
+ i();
684
+ });
685
+ });
686
+ });
687
+ }
688
+ function ht(n, i) {
689
+ var S;
690
+ let t = null, e = null, o = null, s = null;
691
+ const c = {
692
692
  get currentAnimation() {
693
693
  return t;
694
694
  }
695
- }, o = ((v = e == null ? void 0 : e.strategy) == null ? void 0 : v.call(e, a)) || ut(a), c = async (l) => {
696
- var E;
697
- n && (n.remove(), n = null);
698
- const d = i(), A = d.in && d.in(l), k = !(e != null && e.strategy) && d.out ? d.out(l) : void 0;
699
- if (!A)
695
+ }, r = ((S = i == null ? void 0 : i.strategy) == null ? void 0 : S.call(i, c)) || ct(c), a = async (f) => {
696
+ var T;
697
+ e && (e.remove(), e = null);
698
+ const l = n(), E = l.in && l.in(f), A = !(i != null && i.strategy) && l.out ? l.out(f) : void 0;
699
+ if (!E)
700
700
  return;
701
- const M = {
702
- in: P(A),
703
- out: k ? P(k) : void 0
704
- }, S = await o.runIn(M);
705
- if (!S.config) {
701
+ const I = {
702
+ in: R(E),
703
+ out: A ? R(A) : void 0
704
+ }, v = await r.runIn(I);
705
+ if (!v.config) {
706
706
  t && (t.direction = "in");
707
707
  return;
708
708
  }
709
- const p = S.config;
710
- (E = p.prepare) == null || E.call(p, l), p.wait && await p.wait();
711
- const w = Y(
709
+ const p = v.config;
710
+ (T = p.prepare) == null || T.call(p);
711
+ const w = N(
712
712
  {
713
713
  ...p,
714
714
  onEnd: () => {
@@ -716,97 +716,101 @@ function ht(i, e) {
716
716
  t = null, (C = p.onEnd) == null || C.call(p);
717
717
  }
718
718
  },
719
- l
720
- ), g = L.fromState(S.state, {
719
+ f
720
+ );
721
+ p.wait && await p.wait();
722
+ const h = M.fromState(v.state, {
721
723
  config: w,
722
- from: S.from,
723
- to: S.to
724
+ from: v.from,
725
+ to: v.to
724
726
  });
725
- t = { controller: g, direction: "in" }, S.direction === "forward" ? g.forward() : g.backward();
726
- }, u = async (l) => {
727
+ t = { controller: h, direction: "in" }, await X(), v.direction === "forward" ? h.forward() : h.backward();
728
+ }, u = async (f) => {
727
729
  var C;
728
- n = l;
729
- const d = i(), A = !(e != null && e.strategy) && d.in ? d.in(l) : void 0, k = d.out && d.out(l);
730
- if (!k)
730
+ e = f;
731
+ const l = n(), E = !(i != null && i.strategy) && l.in ? l.in(f) : void 0, A = l.out && l.out(f);
732
+ if (!A)
731
733
  return;
732
- const M = {
733
- in: A ? P(A) : void 0,
734
- out: P(k)
735
- }, S = await o.runOut(M);
736
- if (!S.config) {
737
- t && (t.direction = "out"), n && (n.remove(), n = null);
734
+ const I = {
735
+ in: E ? R(E) : void 0,
736
+ out: R(A)
737
+ }, v = await r.runOut(I);
738
+ if (!v.config) {
739
+ t && (t.direction = "out"), e && (e.remove(), e = null);
738
740
  return;
739
741
  }
740
- const p = S.config;
741
- (C = p.prepare) == null || C.call(p, l), E(), p.wait && await p.wait();
742
- const w = Y(
742
+ const p = v.config;
743
+ T(), (C = p.prepare) == null || C.call(p);
744
+ const w = N(
743
745
  {
744
746
  ...p,
745
747
  onEnd: () => {
746
- var V, R;
747
- (V = p.onEnd) == null || V.call(p), n && (n.remove(), n = null), t = null, (R = e == null ? void 0 : e.onCleanupEnd) == null || R.call(e);
748
+ var V, P;
749
+ (V = p.onEnd) == null || V.call(p), e && (e.remove(), e = null), t = null, (P = i == null ? void 0 : i.onCleanupEnd) == null || P.call(i);
748
750
  }
749
751
  },
750
- l
751
- ), g = L.fromState(S.state, {
752
+ f
753
+ );
754
+ p.wait && await p.wait();
755
+ const h = M.fromState(v.state, {
752
756
  config: w,
753
- from: S.from,
754
- to: S.to
757
+ from: v.from,
758
+ to: v.to
755
759
  });
756
- t = { controller: g, direction: "out" }, S.direction === "forward" ? g.forward() : g.backward();
757
- function E() {
758
- !r || !n || (s && r.contains(s) ? r.insertBefore(n, s) : r.appendChild(n));
760
+ t = { controller: h, direction: "out" }, await X(), v.direction === "forward" ? h.forward() : h.backward();
761
+ function T() {
762
+ !o || !e || (s && o.contains(s) ? o.insertBefore(e, s) : o.appendChild(e));
759
763
  }
760
764
  };
761
- let f = null, h = !1;
762
- const y = (l) => () => {
763
- if (h) return;
764
- h = !0;
765
- const d = l.cloneNode(!0);
766
- f ? queueMicrotask(() => {
767
- document.contains(f) && u(d);
768
- }) : u(d);
765
+ let m = null, g = !1;
766
+ const y = (f) => () => {
767
+ if (g) return;
768
+ g = !0;
769
+ const l = f.cloneNode(!0);
770
+ m ? queueMicrotask(() => {
771
+ document.contains(m) && u(l);
772
+ }) : u(l);
769
773
  };
770
- return (l) => {
771
- if (l)
774
+ return (f) => {
775
+ if (f)
772
776
  return requestAnimationFrame(() => {
773
- r = l.parentElement, s = l.nextElementSibling;
774
- }), h = !1, (e == null ? void 0 : e.scope) === "local" ? queueMicrotask(() => {
775
- f = mt(l), !(f && !dt(f)) && c(l);
776
- }) : c(l), y(l);
777
+ o = f.parentElement, s = f.nextElementSibling;
778
+ }), g = !1, (i == null ? void 0 : i.scope) === "local" ? queueMicrotask(() => {
779
+ m = ft(f), !(m && !ut(m)) && a(f);
780
+ }) : a(f), y(f);
777
781
  };
778
782
  }
779
- const b = /* @__PURE__ */ new Map();
780
- let T = null, q = !1;
781
- function tt(i) {
782
- if (i instanceof HTMLElement && b.has(i)) {
783
- const t = b.get(i);
784
- b.delete(i), queueMicrotask(() => {
783
+ const k = /* @__PURE__ */ new Map();
784
+ let b = null, z = !1;
785
+ function K(n) {
786
+ if (n instanceof HTMLElement && k.has(n)) {
787
+ const t = k.get(n);
788
+ k.delete(n), queueMicrotask(() => {
785
789
  t();
786
790
  });
787
791
  }
788
- const e = i.childNodes;
789
- for (let t = 0; t < e.length; t++) {
790
- const n = e[t];
791
- n && tt(n);
792
+ const i = n.childNodes;
793
+ for (let t = 0; t < i.length; t++) {
794
+ const e = i[t];
795
+ e && K(e);
792
796
  }
793
797
  }
794
798
  function gt() {
795
- q || typeof document > "u" || (q = !0, T = new MutationObserver((i) => {
796
- for (const e of i) {
797
- const t = e.removedNodes;
798
- for (let n = 0; n < t.length; n++) {
799
- const r = t[n];
800
- r && tt(r);
799
+ z || typeof document > "u" || (z = !0, b = new MutationObserver((n) => {
800
+ for (const i of n) {
801
+ const t = i.removedNodes;
802
+ for (let e = 0; e < t.length; e++) {
803
+ const o = t[e];
804
+ o && K(o);
801
805
  }
802
806
  }
803
- }), document.body ? T.observe(document.body, {
807
+ }), document.body ? b.observe(document.body, {
804
808
  childList: !0,
805
809
  subtree: !0
806
810
  }) : document.addEventListener(
807
811
  "DOMContentLoaded",
808
812
  () => {
809
- T == null || T.observe(document.body, {
813
+ b == null || b.observe(document.body, {
810
814
  childList: !0,
811
815
  subtree: !0
812
816
  });
@@ -814,270 +818,249 @@ function gt() {
814
818
  { once: !0 }
815
819
  ));
816
820
  }
817
- function pt(i, e) {
818
- gt(), b.set(i, e);
821
+ function pt(n, i) {
822
+ gt(), k.set(n, i);
819
823
  }
820
- function Mt(i) {
821
- return b.has(i);
824
+ function Vt(n) {
825
+ return k.has(n);
822
826
  }
823
- function Rt() {
824
- return b.size;
827
+ function It() {
828
+ return k.size;
825
829
  }
826
- function Pt(i) {
827
- const e = b.get(i);
828
- return e ? (b.delete(i), e(), !0) : !1;
830
+ function Pt(n) {
831
+ const i = k.get(n);
832
+ return i ? (k.delete(n), i(), !0) : !1;
829
833
  }
830
- function It() {
831
- b.clear(), T == null || T.disconnect(), T = null, q = !1;
834
+ function Rt() {
835
+ k.clear(), b == null || b.disconnect(), b = null, z = !1;
832
836
  }
833
- const x = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map();
834
- function wt(i, e, t) {
835
- x.set(i, e);
836
- let n = H.get(i);
837
- if (n)
838
- return n;
839
- const r = e;
840
- return n = ht(
837
+ const O = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
838
+ function wt(n, i, t) {
839
+ O.set(n, i);
840
+ let e = q.get(n);
841
+ if (e)
842
+ return e;
843
+ const o = i;
844
+ return e = ht(
841
845
  () => {
842
- const s = x.get(i);
843
- return s || (console.warn(`Transition "${String(i)}" not found`), {});
846
+ const s = O.get(n);
847
+ return s || (console.warn(`Transition "${String(n)}" not found`), {});
844
848
  },
845
849
  {
846
850
  strategy: t == null ? void 0 : t.strategy,
847
851
  scope: t == null ? void 0 : t.scope,
848
852
  onCleanupEnd: () => {
849
- x.get(i) === r && yt(i);
853
+ O.get(n) === o && yt(n);
850
854
  }
851
855
  }
852
- ), H.set(i, n), n;
856
+ ), q.set(n, e), e;
853
857
  }
854
- function yt(i) {
855
- x.delete(i), H.delete(i), N.delete(i);
858
+ function yt(n) {
859
+ O.delete(n), q.delete(n), _.delete(n);
856
860
  }
857
- function Ot(i, e = "manual") {
861
+ function Ft(n, i = "manual") {
858
862
  const t = wt(
859
- i.key,
863
+ n.key,
860
864
  {
861
- in: i.in,
862
- out: i.out
865
+ in: n.in,
866
+ out: n.out
863
867
  },
864
868
  {
865
- strategy: i[Z],
866
- scope: i.scope
869
+ strategy: n[W],
870
+ scope: n.scope
867
871
  }
868
872
  );
869
- if (e === "manual")
873
+ if (i === "manual")
870
874
  return t;
871
- let n = N.get(i.key);
872
- return n || (n = (r) => {
873
- if (r) {
874
- const s = t(r);
875
- s && pt(r, s);
875
+ let e = _.get(n.key);
876
+ return e || (e = (o) => {
877
+ if (o) {
878
+ const s = t(o);
879
+ s && pt(o, s);
876
880
  }
877
- }, N.set(i.key, n), n);
881
+ }, _.set(n.key, e), e);
878
882
  }
879
- function vt(i) {
880
- const e = i.filter((t) => t.symmetric).map((t) => ({
883
+ function vt(n) {
884
+ const i = n.filter((t) => t.symmetric).map((t) => ({
881
885
  from: t.to,
882
886
  to: t.from,
883
887
  transition: t.transition
884
888
  }));
885
- return [...i, ...e];
889
+ return [...n, ...i];
886
890
  }
887
- function St(i) {
888
- let e = !1, t = 0, n = 0, r = !1;
889
- const s = 50, a = (l) => {
890
- if (!i) return;
891
- const d = l.touches[0];
892
- d && (r = d.clientX < s, r && (t = d.clientX, n = d.clientY));
893
- }, o = (l) => {
894
- if (!i || !r) return;
895
- const d = l.touches[0];
896
- if (!d) return;
897
- const A = d.clientX - t, k = d.clientY - n;
898
- A > window.outerWidth / 2 - 5 && Math.abs(A) > Math.abs(k) ? e = !0 : e = !1;
899
- }, c = () => {
900
- i && (r = !1, t = 0, n = 0);
901
- }, u = () => e, f = () => {
902
- typeof window > "u" || i && (window.addEventListener("touchstart", a, { passive: !0 }), window.addEventListener("touchmove", o, { passive: !0 }), window.addEventListener("touchend", c, { passive: !0 }));
903
- }, h = () => {
904
- typeof window > "u" || (window.removeEventListener("touchstart", a), window.removeEventListener("touchmove", o), window.removeEventListener("touchend", c));
891
+ function St(n) {
892
+ let i = !1, t = 0, e = 0, o = !1;
893
+ const s = 50, c = (f) => {
894
+ if (!n) return;
895
+ const l = f.touches[0];
896
+ l && (o = l.clientX < s, o && (t = l.clientX, e = l.clientY));
897
+ }, r = (f) => {
898
+ if (!n || !o) return;
899
+ const l = f.touches[0];
900
+ if (!l) return;
901
+ const E = l.clientX - t, A = l.clientY - e;
902
+ E > window.outerWidth / 2 - 5 && Math.abs(E) > Math.abs(A) ? i = !0 : i = !1;
903
+ }, a = () => {
904
+ n && (o = !1, t = 0, e = 0);
905
+ }, u = () => i, m = () => {
906
+ typeof window > "u" || n && (window.addEventListener("touchstart", c, { passive: !0 }), window.addEventListener("touchmove", r, { passive: !0 }), window.addEventListener("touchend", a, { passive: !0 }));
907
+ }, g = () => {
908
+ typeof window > "u" || (window.removeEventListener("touchstart", c), window.removeEventListener("touchmove", r), window.removeEventListener("touchend", a));
905
909
  };
906
910
  let y = 0;
907
911
  return {
908
- initialize: f,
909
- cleanup: h,
912
+ initialize: m,
913
+ cleanup: g,
910
914
  isSwipePending: u,
911
915
  resetSwipeDetection: () => {
912
- y++, y > 1 && (y = 0, e = !1);
916
+ y++, y > 1 && (y = 0, i = !1);
913
917
  }
914
918
  };
915
919
  }
916
- const Ct = (i) => {
917
- let e = i.parentElement;
918
- for (; e && e !== document.body; ) {
919
- const t = window.getComputedStyle(e), n = t.overflow + t.overflowY + t.overflowX;
920
- if (n.includes("auto") || n.includes("scroll") || e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth)
921
- return e;
922
- e = e.parentElement;
923
- }
924
- return document.documentElement;
925
- }, At = (i) => {
926
- let e = i.parentElement;
927
- for (; e && e !== document.body; ) {
928
- const t = window.getComputedStyle(e).position;
929
- if (t === "relative" || t === "absolute" || t === "fixed" || t === "sticky")
930
- return e;
931
- e = e.parentElement;
932
- }
933
- return document.body;
934
- };
935
- function Et() {
936
- let i = null, e = null;
920
+ function Ct() {
921
+ let n = null, i = null;
937
922
  const t = /* @__PURE__ */ new Map();
938
- let n = null;
939
- const r = () => {
940
- i && n && t.set(n, {
941
- x: i.scrollLeft,
942
- y: i.scrollTop
923
+ let e = null;
924
+ const o = () => {
925
+ n && e && t.set(e, {
926
+ x: n.scrollLeft,
927
+ y: n.scrollTop
943
928
  });
944
929
  };
945
930
  return {
946
- initializeContext: (f, h) => {
947
- e = f, i || (i = Ct(f), (i === document.documentElement ? window : i).addEventListener("scroll", r, {
931
+ initializeContext: (m, g) => {
932
+ i = m, n || (n = dt(m), (n === document.documentElement ? window : n).addEventListener("scroll", o, {
948
933
  passive: !0
949
- })), n = h;
934
+ })), e = g;
950
935
  },
951
- calculateScrollOffset: (f, h) => {
952
- const y = f && t.has(f) ? t.get(f) : { x: 0, y: 0 }, v = h && t.has(h) ? t.get(h) : { x: 0, y: 0 };
936
+ calculateScrollOffset: (m, g) => {
937
+ const y = m && t.has(m) ? t.get(m) : { x: 0, y: 0 }, S = g && t.has(g) ? t.get(g) : { x: 0, y: 0 };
953
938
  return {
954
- x: -v.x + y.x,
955
- y: -v.y + y.y
939
+ x: -S.x + y.x,
940
+ y: -S.y + y.y
956
941
  };
957
942
  },
958
- getScrollContainer: () => i,
959
- getPositionedParentElement: () => e ? At(e) : document.body,
960
- getScrollPosition: (f) => f && t.has(f) ? t.get(f) : { x: 0, y: 0 }
943
+ getScrollContainer: () => n,
944
+ getPositionedParentElement: () => i ? mt(i) : document.body,
945
+ getScrollPosition: (m) => m && t.has(m) ? t.get(m) : { x: 0, y: 0 }
961
946
  };
962
947
  }
963
- function O(i, e) {
964
- if (e === "*")
948
+ function x(n, i) {
949
+ if (i === "*")
965
950
  return !0;
966
- if (e.endsWith("/*")) {
967
- const t = e.slice(0, -2);
968
- return i === t || i.startsWith(t + "/");
951
+ if (i.endsWith("/*")) {
952
+ const t = i.slice(0, -2);
953
+ return n === t || n.startsWith(t + "/");
969
954
  }
970
- return i === e;
955
+ return n === i;
971
956
  }
972
- function Tt(i, e, t) {
973
- for (const n of t)
974
- if (O(i, n.from) && O(e, n.to))
975
- return n.transition;
976
- for (const n of t)
977
- if ((n.from === "*" || O(i, n.from)) && (n.to === "*" || O(e, n.to)))
978
- return n.transition;
957
+ function At(n, i, t) {
958
+ for (const e of t)
959
+ if (x(n, e.from) && x(i, e.to))
960
+ return e.transition;
961
+ for (const e of t)
962
+ if ((e.from === "*" || x(n, e.from)) && (e.to === "*" || x(i, e.to)))
963
+ return e.transition;
979
964
  return null;
980
965
  }
981
- function xt(i, e) {
966
+ function xt(n, i) {
982
967
  const {
983
968
  transitions: t = [],
984
- defaultTransition: n,
985
- middleware: r = (w, g) => ({ from: w, to: g }),
969
+ defaultTransition: e,
970
+ middleware: o = (w, h) => ({ from: w, to: h }),
986
971
  // Identity function as default
987
972
  skipOnIosSwipe: s = !0
988
973
  // Default to true - skip animations on iOS swipe
989
- } = i, { outFirst: a = !0 } = e || {};
990
- let o = null;
991
- const c = vt(t), {
974
+ } = n, { outFirst: c = !0 } = i || {};
975
+ let r = null;
976
+ const a = vt(t), {
992
977
  initializeContext: u,
993
- calculateScrollOffset: f,
994
- getScrollContainer: h,
978
+ calculateScrollOffset: m,
979
+ getScrollContainer: g,
995
980
  getPositionedParentElement: y,
996
- getScrollPosition: v
997
- } = Et(), l = St(s);
998
- l.initialize();
999
- function d() {
1000
- if (o != null && o.from && (o != null && o.to)) {
1001
- const { from: w, to: g } = r(
1002
- o.from,
1003
- o.to
1004
- ), C = Tt(
981
+ getScrollPosition: S
982
+ } = Ct(), f = St(s);
983
+ f.initialize();
984
+ function l() {
985
+ if (r != null && r.from && (r != null && r.to)) {
986
+ const { from: w, to: h } = o(
987
+ r.from,
988
+ r.to
989
+ ), C = At(
1005
990
  w,
1006
- g,
1007
- c
1008
- ) || n, V = f(
1009
- o.from,
1010
- o.to
1011
- ), R = {
991
+ h,
992
+ a
993
+ ) || e, V = m(
994
+ r.from,
995
+ r.to
996
+ ), P = {
1012
997
  scrollOffset: V,
1013
- scroll: v(o.from),
998
+ scroll: S(r.from),
1014
999
  get scrollingElement() {
1015
- return h() || document.documentElement;
1000
+ return g() || document.documentElement;
1016
1001
  },
1017
1002
  get positionedParent() {
1018
1003
  return y();
1019
1004
  }
1020
- }, et = {
1005
+ }, B = {
1021
1006
  scrollOffset: V,
1022
1007
  get scroll() {
1023
- return o ? v(o.to) : { x: 0, y: 0 };
1008
+ return r ? S(r.to) : { x: 0, y: 0 };
1024
1009
  },
1025
1010
  get scrollingElement() {
1026
- return h() || document.documentElement;
1011
+ return g() || document.documentElement;
1027
1012
  },
1028
1013
  get positionedParent() {
1029
1014
  return y();
1030
1015
  }
1031
1016
  };
1032
- C && (C.out && o.outResolve && o.outResolve(
1033
- (z) => C.out(z, R)
1034
- ), C.in && o.inResolve && o.inResolve(
1035
- (z) => C.in(z, et)
1036
- )), o = null;
1017
+ C && (C.out && r.outResolve && r.outResolve(
1018
+ (L) => C.out(L, P)
1019
+ ), C.in && r.inResolve && r.inResolve(
1020
+ (L) => C.in(L, B)
1021
+ )), r = null;
1037
1022
  }
1038
1023
  }
1039
- function A() {
1040
- o && (o.inResolve && o.inResolve(() => ({})), o.outResolve && o.outResolve(() => ({})), o = null);
1024
+ function E() {
1025
+ r && (r.inResolve && r.inResolve(() => ({})), r.outResolve && r.outResolve(() => ({})), r = null);
1041
1026
  }
1042
- const S = a ? async (w, g) => l.isSwipePending() ? (l.resetSwipeDetection(), () => ({})) : g === "in" && (!o || !o.from) ? () => ({}) : (o || (o = {}), g === "out" ? (o.from = w, new Promise((E) => {
1043
- o.outResolve = E, d();
1044
- })) : (o.to = w, new Promise((E) => {
1045
- o.inResolve = E, d();
1046
- }))) : async (w, g) => l.isSwipePending() ? (l.resetSwipeDetection(), () => ({})) : (o && (g === "out" && o.from && o.from !== w || g === "in" && o.to && o.to !== w) && A(), o || (o = {}), g === "out" ? (o.from = w, new Promise((C) => {
1047
- o.outResolve = C, d();
1048
- })) : (o.to = w, new Promise((C) => {
1049
- o.inResolve = C, d();
1027
+ const v = c ? async (w, h) => f.isSwipePending() ? (f.resetSwipeDetection(), () => ({})) : h === "in" && (!r || !r.from) ? () => ({}) : (r || (r = {}), h === "out" ? (r.from = w, new Promise((T) => {
1028
+ r.outResolve = T, l();
1029
+ })) : (r.to = w, new Promise((T) => {
1030
+ r.inResolve = T, l();
1031
+ }))) : async (w, h) => f.isSwipePending() ? (f.resetSwipeDetection(), () => ({})) : (r && (h === "out" && r.from && r.from !== w || h === "in" && r.to && r.to !== w) && E(), r || (r = {}), h === "out" ? (r.from = w, new Promise((C) => {
1032
+ r.outResolve = C, l();
1033
+ })) : (r.to = w, new Promise((C) => {
1034
+ r.inResolve = C, l();
1050
1035
  })));
1051
1036
  return (w) => ({
1052
1037
  key: w,
1053
- in: async (g) => (u(g, w), (await S(w, "in"))(g)),
1054
- out: async (g) => (await S(w, "out"))(g),
1038
+ in: async (h) => (u(h, w), (await v(w, "in"))(h)),
1039
+ out: async (h) => (await v(w, "out"))(h),
1055
1040
  // Add page transition strategy for page-level transitions
1056
- [Z]: ft
1041
+ [W]: lt
1057
1042
  });
1058
1043
  }
1059
1044
  export {
1060
- J as SCOPE_ATTR,
1061
- Q as SCOPE_READY_ATTR,
1062
- Z as TRANSITION_STRATEGY,
1063
- ut as createDefaultStrategy,
1064
- ft as createPageTransitionStrategy,
1045
+ G as SCOPE_ATTR,
1046
+ $ as SCOPE_READY_ATTR,
1047
+ W as TRANSITION_STRATEGY,
1048
+ ct as createDefaultStrategy,
1049
+ lt as createPageTransitionStrategy,
1065
1050
  xt as createSggoiTransitionContext,
1066
- Vt as createTransitionScope,
1067
- mt as findScope,
1068
- Rt as getWatchedCount,
1069
- zt as isCssAnimation,
1070
- Dt as isMultiSpring,
1071
- dt as isScopeReady,
1072
- _t as isSingleSpring,
1051
+ kt as createTransitionScope,
1052
+ ft as findScope,
1053
+ It as getWatchedCount,
1054
+ Lt as isCssAnimation,
1055
+ Dt as isMultiAnimation,
1056
+ ut as isScopeReady,
1057
+ zt as isSingleAnimation,
1073
1058
  qt as isTickAnimation,
1074
- Mt as isWatched,
1075
- Y as normalizeMultiSpringSchedule,
1076
- P as normalizeToMultiSpring,
1077
- It as resetObserver,
1078
- Ot as transition,
1059
+ Vt as isWatched,
1060
+ N as normalizeSchedule,
1061
+ R as normalizeToMultiAnimation,
1062
+ Rt as resetObserver,
1063
+ Ft as transition,
1079
1064
  Pt as triggerUnmount,
1080
- Ht as validateAnimationMode,
1081
- Nt as validateSpringItem,
1082
1065
  pt as watchUnmount
1083
1066
  };