@ssgoi/core 5.0.2 → 5.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.
package/dist/index.js CHANGED
@@ -1,65 +1,65 @@
1
- var it = Object.defineProperty;
2
- var nt = (e, n, t) => n in e ? it(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var f = (e, n, t) => nt(e, typeof n != "symbol" ? n + "" : n, t);
4
- import { normalizeToMultiAnimation as M, normalizeSchedule as j } from "./types.js";
5
- import { isCssAnimation as Yt, isMultiAnimation as Kt, isSingleAnimation as $t, isTickAnimation as Jt } from "./types.js";
6
- import { S as Y, I as rt, a as ot } from "./provider-Cu4NSF1Q.js";
7
- class st {
1
+ var et = Object.defineProperty;
2
+ var nt = (e, i, t) => i in e ? et(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
+ var d = (e, i, t) => nt(e, typeof i != "symbol" ? i + "" : i, t);
4
+ import { normalizeToMultiAnimation as F, normalizeSchedule as W } from "./types.js";
5
+ import { isCssAnimation as jt, isMultiAnimation as Gt, isSingleAnimation as Kt, isTickAnimation as $t } from "./types.js";
6
+ import { S as K, I as it, a as rt } from "./provider-Cu4NSF1Q.js";
7
+ class ot {
8
8
  constructor() {
9
- f(this, "listeners", /* @__PURE__ */ new Set());
10
- f(this, "rafId", null);
11
- f(this, "isRunning", !1);
9
+ d(this, "listeners", /* @__PURE__ */ new Set());
10
+ d(this, "rafId", null);
11
+ d(this, "isRunning", !1);
12
12
  // Timing
13
- f(this, "startTime", Date.now());
14
- f(this, "lastUpdate", this.startTime);
15
- f(this, "elapsed", 0);
13
+ d(this, "startTime", Date.now());
14
+ d(this, "lastUpdate", this.startTime);
15
+ d(this, "elapsed", 0);
16
16
  // Lag smoothing (mobile optimization)
17
- f(this, "lagThreshold", 500);
17
+ d(this, "lagThreshold", 500);
18
18
  // ms - detect tab switches, backgrounding
19
- f(this, "adjustedLag", 33);
19
+ d(this, "adjustedLag", 33);
20
20
  // ms - max time jump to prevent animation skip
21
- f(this, "maxDeltaTime", 33);
21
+ d(this, "maxDeltaTime", 33);
22
22
  // ms - clamp for physics stability (30fps minimum)
23
23
  // FPS throttling
24
- f(this, "gap", 1e3 / 240);
24
+ d(this, "gap", 1e3 / 240);
25
25
  // max 240fps
26
- f(this, "nextTime", this.gap);
27
- f(this, "tick", () => {
28
- const n = Date.now();
29
- let i = n - this.lastUpdate;
30
- i > this.lagThreshold || i < 0 ? (this.startTime += i - this.adjustedLag, i = this.adjustedLag) : i > this.maxDeltaTime && (i = this.maxDeltaTime), this.lastUpdate = n;
31
- const r = n - this.startTime, o = r - this.nextTime;
26
+ d(this, "nextTime", this.gap);
27
+ d(this, "tick", () => {
28
+ const i = Date.now();
29
+ let n = i - this.lastUpdate;
30
+ n > this.lagThreshold || n < 0 ? (this.startTime += n - this.adjustedLag, n = this.adjustedLag) : n > this.maxDeltaTime && (n = this.maxDeltaTime), this.lastUpdate = i;
31
+ const r = i - this.startTime, o = r - this.nextTime;
32
32
  if (o > 0) {
33
- const l = i / 1e3;
34
- this.elapsed = r / 1e3, this.nextTime += o + (o >= this.gap ? 4 : this.gap - o), this.listeners.forEach((u) => {
35
- u(l, this.elapsed);
33
+ const u = n / 1e3;
34
+ this.elapsed = r / 1e3, this.nextTime += o + (o >= this.gap ? 4 : this.gap - o), this.listeners.forEach((f) => {
35
+ f(u, this.elapsed);
36
36
  });
37
37
  }
38
38
  this.listeners.size > 0 ? this.rafId = requestAnimationFrame(this.tick) : (this.isRunning = !1, this.rafId = null);
39
39
  });
40
40
  }
41
- subscribe(n) {
42
- return this.listeners.add(n), this.isRunning || (this.isRunning = !0, this.rafId = requestAnimationFrame(this.tick)), () => {
43
- this.unsubscribe(n);
41
+ subscribe(i) {
42
+ return this.listeners.add(i), this.isRunning || (this.isRunning = !0, this.rafId = requestAnimationFrame(this.tick)), () => {
43
+ this.unsubscribe(i);
44
44
  };
45
45
  }
46
- unsubscribe(n) {
47
- this.listeners.delete(n), 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);
48
48
  }
49
49
  /**
50
50
  * Configure lag smoothing behavior
51
51
  * @param threshold - Time threshold to detect lag (default: 500ms)
52
52
  * @param adjustedLag - Max time jump when lag detected (default: 33ms)
53
53
  */
54
- lagSmoothing(n, t) {
55
- this.lagThreshold = n, this.adjustedLag = Math.min(t, n);
54
+ lagSmoothing(i, t) {
55
+ this.lagThreshold = i, this.adjustedLag = Math.min(t, i);
56
56
  }
57
57
  /**
58
58
  * Set maximum FPS
59
59
  * @param fps - Target FPS (default: 240)
60
60
  */
61
- fps(n) {
62
- this.gap = 1e3 / n, this.nextTime = this.elapsed * 1e3 + this.gap;
61
+ fps(i) {
62
+ this.gap = 1e3 / i, this.nextTime = this.elapsed * 1e3 + this.gap;
63
63
  }
64
64
  getListenerCount() {
65
65
  return this.listeners.size;
@@ -68,148 +68,148 @@ class st {
68
68
  return this.elapsed;
69
69
  }
70
70
  }
71
- const q = new st();
72
- function at(e) {
71
+ const z = new ot();
72
+ function st(e) {
73
73
  const {
74
- integrator: n,
74
+ integrator: i,
75
75
  from: t,
76
- to: i,
76
+ to: n,
77
77
  velocity: r = 0,
78
78
  onUpdate: o,
79
- onComplete: l,
80
- onStart: u
79
+ onComplete: u,
80
+ onStart: f
81
81
  } = e;
82
- let s = { position: t, velocity: r }, c = !0, d = 0, w = !1;
83
- const b = (E) => {
84
- if (c) {
85
- if (w || (w = !0, u == null || u()), s = n.step(s, i, E), n.isSettled(s, i)) {
86
- if (d += Math.min(E, 0.033), d >= Y) {
87
- s = { position: i, velocity: 0 }, c = !1, o(s.position), q.unsubscribe(b), l();
82
+ let a = { position: t, velocity: r }, m = !0, w = 0, E = !1;
83
+ const A = (T) => {
84
+ if (m) {
85
+ if (E || (E = !0, f == null || f()), a = i.step(a, n, T), i.isSettled(a, n)) {
86
+ if (w += Math.min(T, 0.033), w >= K) {
87
+ a = { position: n, velocity: 0 }, m = !1, o(a.position), z.unsubscribe(A), u();
88
88
  return;
89
89
  }
90
90
  } else
91
- d = 0;
92
- o(s.position);
91
+ w = 0;
92
+ o(a.position);
93
93
  }
94
94
  };
95
- return q.subscribe(b), {
95
+ return z.subscribe(A), {
96
96
  stop: () => {
97
- c && (c = !1, q.unsubscribe(b));
97
+ m && (m = !1, z.unsubscribe(A));
98
98
  },
99
- getPosition: () => s.position,
100
- getVelocity: () => s.velocity,
101
- isRunning: () => c
99
+ getPosition: () => a.position,
100
+ getVelocity: () => a.velocity,
101
+ isRunning: () => m
102
102
  };
103
103
  }
104
104
  const O = 1e3 / 60;
105
- function ct(e, n, t, i = 0) {
106
- let o = { position: n, velocity: i }, l = 0;
107
- const u = [];
108
- for (let s = 0; s < 600; s++) {
109
- const c = s * O;
110
- if (u.push({
111
- time: c,
105
+ function ct(e, i, t, n = 0) {
106
+ let o = { position: i, velocity: n }, u = 0;
107
+ const f = [];
108
+ for (let a = 0; a < 600; a++) {
109
+ const m = a * O;
110
+ if (f.push({
111
+ time: m,
112
112
  position: o.position,
113
113
  velocity: o.velocity
114
114
  }), o = e.step(o, t, O / 1e3), e.isSettled(o, t)) {
115
- if (l += O / 1e3, l >= Y) {
116
- u.push({
117
- time: (s + 1) * O,
115
+ if (u += O / 1e3, u >= K) {
116
+ f.push({
117
+ time: (a + 1) * O,
118
118
  position: t,
119
119
  velocity: 0
120
120
  });
121
121
  break;
122
122
  }
123
123
  } else
124
- l = 0;
124
+ u = 0;
125
125
  }
126
- return u;
126
+ return f;
127
127
  }
128
- function H(e, n) {
128
+ function H(e, i) {
129
129
  if (e.length === 0)
130
130
  return { position: 0, velocity: 0 };
131
- const t = e[0], i = e[e.length - 1];
132
- if (n <= 0)
131
+ const t = e[0], n = e[e.length - 1];
132
+ if (i <= 0)
133
133
  return { position: t.position, velocity: t.velocity };
134
- if (n >= i.time)
135
- return { position: i.position, velocity: i.velocity };
134
+ if (i >= n.time)
135
+ return { position: n.position, velocity: n.velocity };
136
136
  let r = 0, o = e.length - 1;
137
137
  for (; r < o - 1; ) {
138
- const c = Math.floor((r + o) / 2);
139
- e[c].time <= n ? r = c : o = c;
138
+ const m = Math.floor((r + o) / 2);
139
+ e[m].time <= i ? r = m : o = m;
140
140
  }
141
- const l = e[r], u = e[o], s = (n - l.time) / (u.time - l.time);
141
+ const u = e[r], f = e[o], a = (i - u.time) / (f.time - u.time);
142
142
  return {
143
- position: l.position + (u.position - l.position) * s,
144
- velocity: l.velocity + (u.velocity - l.velocity) * s
143
+ position: u.position + (f.position - u.position) * a,
144
+ velocity: u.velocity + (f.velocity - u.velocity) * a
145
145
  };
146
146
  }
147
- function lt(e, n) {
148
- return e.map((t) => n(t.position));
147
+ function at(e, i) {
148
+ return e.map((t) => i(t.position));
149
149
  }
150
- function ut(e) {
150
+ function lt(e) {
151
151
  const {
152
- integrator: n,
152
+ integrator: i,
153
153
  element: t,
154
- from: i,
154
+ from: n,
155
155
  to: r,
156
156
  velocity: o = 0,
157
- style: l,
158
- onComplete: u,
159
- onStart: s
160
- } = e, c = ct(n, i, r, o);
161
- if (c.length === 0)
162
- return s == null || s(), u(), {
157
+ style: u,
158
+ onComplete: f,
159
+ onStart: a
160
+ } = e, m = ct(i, n, r, o);
161
+ if (m.length === 0)
162
+ return a == null || a(), f(), {
163
163
  stop: () => {
164
164
  },
165
165
  getPosition: () => r,
166
166
  getVelocity: () => 0,
167
167
  isRunning: () => !1
168
168
  };
169
- const d = lt(c, l), w = c[c.length - 1], b = w.time, E = d[0];
170
- if (E)
171
- for (const A of Object.keys(E))
172
- t.style[A] = "";
173
- const y = t.animate(d, {
174
- duration: b,
169
+ const w = at(m, u), E = m[m.length - 1], A = E.time, T = w[0];
170
+ if (T)
171
+ for (const C of Object.keys(T))
172
+ t.style[C] = "";
173
+ const p = t.animate(w, {
174
+ duration: A,
175
175
  fill: "forwards",
176
176
  easing: "linear",
177
177
  composite: "replace"
178
178
  });
179
- let p = !0;
180
- const T = performance.now();
181
- return s == null || s(), y.onfinish = () => {
182
- p && (p = !1, u());
179
+ let y = !0;
180
+ const R = performance.now();
181
+ return a == null || a(), p.onfinish = () => {
182
+ y && (y = !1, f());
183
183
  }, {
184
184
  stop: () => {
185
- p && (p = !1, y.cancel());
185
+ y && (y = !1, p.cancel());
186
186
  },
187
187
  getPosition: () => {
188
- if (!p)
189
- return w.position;
190
- const A = performance.now() - T;
191
- return H(c, A).position;
188
+ if (!y)
189
+ return E.position;
190
+ const C = performance.now() - R;
191
+ return H(m, C).position;
192
192
  },
193
193
  getVelocity: () => {
194
- if (!p)
194
+ if (!y)
195
195
  return 0;
196
- const A = performance.now() - T;
197
- return H(c, A).velocity;
196
+ const C = performance.now() - R;
197
+ return H(m, C).velocity;
198
198
  },
199
- isRunning: () => p
199
+ isRunning: () => y
200
200
  };
201
201
  }
202
- function ft(e) {
203
- const { to: n, onStart: t, onComplete: i } = e;
204
- return t == null || t(), i(), {
202
+ function ut(e) {
203
+ const { to: i, onStart: t, onComplete: n } = e;
204
+ return t == null || t(), n(), {
205
205
  stop: () => {
206
206
  },
207
- getPosition: () => n,
207
+ getPosition: () => i,
208
208
  getVelocity: () => 0,
209
209
  isRunning: () => !1
210
210
  };
211
211
  }
212
- class dt {
212
+ class ft {
213
213
  /**
214
214
  * Get bound runner based on animation mode
215
215
  *
@@ -217,33 +217,33 @@ class dt {
217
217
  * @returns Bound runner function (empty runner if no animation mode specified)
218
218
  * @throws Error if both tick and css are provided
219
219
  */
220
- static from(n) {
221
- const { tick: t, css: i } = n;
222
- if (t && i)
220
+ static from(i) {
221
+ const { tick: t, css: n } = i;
222
+ if (t && n)
223
223
  throw new Error("Cannot use both 'tick' and 'css' options together");
224
- return i ? (r) => ut({
224
+ return n ? (r) => lt({
225
225
  ...r,
226
- element: i.element,
227
- style: i.style
228
- }) : t ? (r) => at({
226
+ element: n.element,
227
+ style: n.style
228
+ }) : t ? (r) => st({
229
229
  ...r,
230
230
  onUpdate: t
231
- }) : ft;
231
+ }) : ut;
232
232
  }
233
233
  }
234
- class K {
234
+ class $ {
235
235
  }
236
236
  const mt = { stiffness: 300, damping: 30 };
237
- class G extends K {
237
+ class U extends $ {
238
238
  constructor(t) {
239
239
  super();
240
- f(this, "options");
241
- f(this, "runner");
242
- f(this, "controls", null);
243
- f(this, "isAnimating", !1);
244
- f(this, "currentValue");
245
- f(this, "currentVelocity", 0);
246
- f(this, "updateFn");
240
+ d(this, "options");
241
+ d(this, "runner");
242
+ d(this, "controls", null);
243
+ d(this, "isAnimating", !1);
244
+ d(this, "currentValue");
245
+ d(this, "currentVelocity", 0);
246
+ d(this, "updateFn");
247
247
  if (this.options = {
248
248
  from: t.from ?? 0,
249
249
  to: t.to ?? 1,
@@ -252,21 +252,21 @@ class G extends K {
252
252
  }),
253
253
  onStart: t.onStart
254
254
  }, this.currentValue = this.options.from, t.tick)
255
- this.updateFn = (i) => {
255
+ this.updateFn = (n) => {
256
256
  var r;
257
- return (r = t.tick) == null ? void 0 : r.call(t, i);
257
+ return (r = t.tick) == null ? void 0 : r.call(t, n);
258
258
  };
259
259
  else if (t.css) {
260
- const { element: i, style: r } = t.css;
260
+ const { element: n, style: r } = t.css;
261
261
  this.updateFn = (o) => {
262
- const l = r(o);
263
- for (const [u, s] of Object.entries(l))
264
- i.style[u] = typeof s == "number" ? String(s) : s;
262
+ const u = r(o);
263
+ for (const [f, a] of Object.entries(u))
264
+ n.style[f] = typeof a == "number" ? String(a) : a;
265
265
  };
266
266
  } else
267
267
  this.updateFn = () => {
268
268
  };
269
- this.runner = dt.from({
269
+ this.runner = ft.from({
270
270
  tick: t.tick,
271
271
  css: t.css
272
272
  });
@@ -285,10 +285,10 @@ class G extends K {
285
285
  */
286
286
  createIntegrator() {
287
287
  const t = this.options.physics;
288
- return t != null && t.integrator ? t.integrator() : t != null && t.spring || t != null && t.inertia ? rt.from({
288
+ return t != null && t.integrator ? t.integrator() : t != null && t.spring || t != null && t.inertia ? it.from({
289
289
  spring: t.spring,
290
290
  inertia: t.inertia
291
- }) : new ot(mt);
291
+ }) : new rt(mt);
292
292
  }
293
293
  runAnimation(t) {
294
294
  this.isAnimating = !0, this.controls = this.runner({
@@ -344,20 +344,20 @@ class G extends K {
344
344
  this.options = { ...this.options, ...t };
345
345
  }
346
346
  }
347
- class L extends K {
347
+ class D extends $ {
348
348
  constructor(t) {
349
349
  super();
350
- f(this, "config");
351
- f(this, "animators", /* @__PURE__ */ new Map());
352
- f(this, "itemOrder", []);
353
- f(this, "completedCount", 0);
354
- f(this, "completedAnimators", /* @__PURE__ */ new Set());
355
- f(this, "direction", "forward");
356
- f(this, "idCounter", 0);
357
- f(this, "rafId", null);
358
- f(this, "from");
359
- f(this, "to");
360
- f(this, "initialState");
350
+ d(this, "config");
351
+ d(this, "animators", /* @__PURE__ */ new Map());
352
+ d(this, "itemOrder", []);
353
+ d(this, "completedCount", 0);
354
+ d(this, "completedAnimators", /* @__PURE__ */ new Set());
355
+ d(this, "direction", "forward");
356
+ d(this, "idCounter", 0);
357
+ d(this, "rafId", null);
358
+ d(this, "from");
359
+ d(this, "to");
360
+ d(this, "initialState");
361
361
  this.config = t.config, this.from = t.from, this.to = t.to, this.initialState = t.state ?? {
362
362
  position: t.from,
363
363
  velocity: 0
@@ -367,8 +367,8 @@ class L extends K {
367
367
  return `spring_${this.idCounter++}`;
368
368
  }
369
369
  initializeAnimators() {
370
- this.config.items.forEach((t, i) => {
371
- const r = this.generateId(), o = new G({
370
+ this.config.items.forEach((t, n) => {
371
+ const r = this.generateId(), o = new U({
372
372
  from: this.from,
373
373
  to: this.to,
374
374
  physics: t.physics,
@@ -377,7 +377,7 @@ class L extends K {
377
377
  onComplete: () => this.onAnimatorComplete(r),
378
378
  onStart: t.onStart
379
379
  });
380
- (i === 0 || t.normalizedOffset === 0) && (o.setValue(this.initialState.position), o.setVelocity(this.initialState.velocity), o.syncState()), this.animators.set(r, {
380
+ (n === 0 || t.normalizedOffset === 0) && (o.setValue(this.initialState.position), o.setVelocity(this.initialState.velocity), o.syncState()), this.animators.set(r, {
381
381
  id: r,
382
382
  item: t,
383
383
  animator: o,
@@ -390,8 +390,8 @@ class L extends K {
390
390
  * Progress = |position - from| / |to - from|
391
391
  */
392
392
  getAnimatorProgress(t) {
393
- const i = t.animator.getCurrentState(), r = Math.abs(i.to - i.from);
394
- return r === 0 ? 1 : Math.abs(i.position - i.from) / r;
393
+ const n = t.animator.getCurrentState(), r = Math.abs(n.to - n.from);
394
+ return r === 0 ? 1 : Math.abs(n.position - n.from) / r;
395
395
  }
396
396
  /**
397
397
  * Get order of springs based on direction
@@ -402,9 +402,9 @@ class L extends K {
402
402
  return this.direction === "forward" ? this.itemOrder : [...this.itemOrder].reverse();
403
403
  }
404
404
  onAnimatorComplete(t) {
405
- var r, o, l, u, s, c;
406
- const i = this.animators.get(t);
407
- !i || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (o = (r = i.item).onComplete) == null || o.call(r), (u = (l = this.config).onProgress) == null || u.call(l, this.completedCount, this.config.items.length), this.completedCount === this.config.items.length && (this.stopScheduler(), (c = (s = this.config).onEnd) == null || c.call(s)));
405
+ var r, o, u, f, a, m;
406
+ const n = this.animators.get(t);
407
+ !n || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (o = (r = n.item).onComplete) == null || o.call(r), (f = (u = this.config).onProgress) == null || f.call(u, this.completedCount, this.config.items.length), this.completedCount === this.config.items.length && (this.stopScheduler(), (m = (a = this.config).onEnd) == null || m.call(a)));
408
408
  }
409
409
  /**
410
410
  * Check and start springs based on previous spring's progress
@@ -412,22 +412,22 @@ class L extends K {
412
412
  */
413
413
  checkAndStartSprings() {
414
414
  const t = this.getOrderedIds();
415
- for (let i = 0; i < t.length; i++) {
416
- const r = t[i], o = this.animators.get(r);
415
+ for (let n = 0; n < t.length; n++) {
416
+ const r = t[n], o = this.animators.get(r);
417
417
  if (!o || o.started) continue;
418
- if (i === 0) {
418
+ if (n === 0) {
419
419
  this.startAnimator(r);
420
420
  continue;
421
421
  }
422
- const l = t[i - 1], u = this.animators.get(l);
423
- if (!u || !u.started) continue;
424
- const s = this.getAnimatorProgress(u), c = o.item.normalizedOffset;
425
- s >= c && this.startAnimator(r);
422
+ const u = t[n - 1], f = this.animators.get(u);
423
+ if (!f || !f.started) continue;
424
+ const a = this.getAnimatorProgress(f), m = o.item.normalizedOffset;
425
+ a >= m && this.startAnimator(r);
426
426
  }
427
427
  }
428
428
  startAnimator(t) {
429
- const i = this.animators.get(t);
430
- !i || i.started || (i.started = !0, this.direction === "forward" ? i.animator.forward() : i.animator.backward());
429
+ const n = this.animators.get(t);
430
+ !n || n.started || (n.started = !0, this.direction === "forward" ? n.animator.forward() : n.animator.backward());
431
431
  }
432
432
  /**
433
433
  * Start the scheduler loop that checks spring progress
@@ -442,17 +442,17 @@ class L extends K {
442
442
  this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
443
443
  }
444
444
  getFirstAnimator() {
445
- var i;
445
+ var n;
446
446
  const t = this.itemOrder[0];
447
- return t ? ((i = this.animators.get(t)) == null ? void 0 : i.animator) ?? null : null;
447
+ return t ? ((n = this.animators.get(t)) == null ? void 0 : n.animator) ?? null : null;
448
448
  }
449
449
  forward() {
450
- var t, i;
451
- this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (i = (t = this.config).onStart) == null || i.call(t), this.startScheduler();
450
+ var t, n;
451
+ this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (n = (t = this.config).onStart) == null || n.call(t), this.startScheduler();
452
452
  }
453
453
  backward() {
454
- var t, i;
455
- this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (i = (t = this.config).onStart) == null || i.call(t), this.startScheduler();
454
+ var t, n;
455
+ this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), this.resetStartedFlags(), (n = (t = this.config).onStart) == null || n.call(t), this.startScheduler();
456
456
  }
457
457
  resetStartedFlags() {
458
458
  this.animators.forEach((t) => {
@@ -468,9 +468,9 @@ class L extends K {
468
468
  this.direction = this.direction === "forward" ? "backward" : "forward", this.animators.forEach((t) => {
469
469
  if (!t.started)
470
470
  return;
471
- const i = t.animator.getCurrentState();
472
- if (i.position === i.to) {
473
- const o = new G({
471
+ const n = t.animator.getCurrentState();
472
+ if (n.position === n.to) {
473
+ const o = new U({
474
474
  from: this.to,
475
475
  to: this.from,
476
476
  physics: t.item.physics,
@@ -512,16 +512,16 @@ class L extends K {
512
512
  * TODO: Support per-spring control
513
513
  */
514
514
  setValue(t) {
515
- const i = this.getFirstAnimator();
516
- i == null || i.setValue(t);
515
+ const n = this.getFirstAnimator();
516
+ n == null || n.setValue(t);
517
517
  }
518
518
  /**
519
519
  * Set velocity on first animator
520
520
  * TODO: Support per-spring control
521
521
  */
522
522
  setVelocity(t) {
523
- const i = this.getFirstAnimator();
524
- i == null || i.setVelocity(t);
523
+ const n = this.getFirstAnimator();
524
+ n == null || n.setVelocity(t);
525
525
  }
526
526
  /**
527
527
  * Check if any animation is currently running
@@ -536,18 +536,18 @@ class L extends K {
536
536
  * Create MultiAnimator from existing state
537
537
  * Uses first animator's state for initialization
538
538
  */
539
- static fromState(t, i) {
540
- return new L({ ...i, state: t });
539
+ static fromState(t, n) {
540
+ return new D({ ...n, state: t });
541
541
  }
542
542
  }
543
- const $ = Symbol.for("TRANSITION_STRATEGY"), ht = (e) => ({
544
- runIn: async (n) => {
543
+ const Z = Symbol.for("TRANSITION_STRATEGY"), dt = (e) => ({
544
+ runIn: async (i) => {
545
545
  const { currentAnimation: t } = e;
546
546
  if (t && t.direction === "out") {
547
547
  const r = t.controller.getCurrentValue(), o = t.controller.getVelocity();
548
- if (t.controller.stop(), n.out)
548
+ if (t.controller.stop(), i.out)
549
549
  return {
550
- config: await n.out,
550
+ config: await i.out,
551
551
  state: { position: r, velocity: o },
552
552
  from: 1,
553
553
  to: 0,
@@ -555,8 +555,8 @@ const $ = Symbol.for("TRANSITION_STRATEGY"), ht = (e) => ({
555
555
  // Will actually go 0→1 (backward means toward 'from')
556
556
  };
557
557
  }
558
- return n.in ? {
559
- config: await n.in,
558
+ return i.in ? {
559
+ config: await i.in,
560
560
  state: {
561
561
  position: 0,
562
562
  velocity: 0
@@ -574,13 +574,13 @@ const $ = Symbol.for("TRANSITION_STRATEGY"), ht = (e) => ({
574
574
  direction: "forward"
575
575
  };
576
576
  },
577
- runOut: async (n) => {
577
+ runOut: async (i) => {
578
578
  const { currentAnimation: t } = e;
579
579
  if (t && t.direction === "in") {
580
580
  const r = t.controller.getCurrentValue(), o = t.controller.getVelocity();
581
- if (t.controller.stop(), n.in)
581
+ if (t.controller.stop(), i.in)
582
582
  return {
583
- config: await n.in,
583
+ config: await i.in,
584
584
  state: { position: r, velocity: o },
585
585
  from: 0,
586
586
  to: 1,
@@ -588,8 +588,8 @@ const $ = Symbol.for("TRANSITION_STRATEGY"), ht = (e) => ({
588
588
  // Will actually go 1→0 (backward means toward 'from')
589
589
  };
590
590
  }
591
- return n.out ? {
592
- config: await n.out,
591
+ return i.out ? {
592
+ config: await i.out,
593
593
  state: {
594
594
  position: 1,
595
595
  velocity: 0
@@ -607,7 +607,7 @@ const $ = Symbol.for("TRANSITION_STRATEGY"), ht = (e) => ({
607
607
  direction: "forward"
608
608
  };
609
609
  }
610
- }), gt = () => ({
610
+ }), ht = () => ({
611
611
  runIn: async (e) => e.in ? {
612
612
  config: await e.in,
613
613
  state: {
@@ -645,7 +645,7 @@ const $ = Symbol.for("TRANSITION_STRATEGY"), ht = (e) => ({
645
645
  direction: "forward"
646
646
  }
647
647
  }), J = "data-ssgoi-scope", Q = "data-ssgoi-scope-ready";
648
- function qt() {
648
+ function zt() {
649
649
  return (e) => {
650
650
  if (e)
651
651
  return e.setAttribute(J, ""), queueMicrotask(() => {
@@ -656,179 +656,166 @@ function qt() {
656
656
  };
657
657
  };
658
658
  }
659
- function yt(e) {
659
+ function gt(e) {
660
660
  return e.hasAttribute(Q);
661
661
  }
662
- function pt(e) {
662
+ function wt(e) {
663
663
  return e.closest(`[${J}]`);
664
664
  }
665
- const wt = (e) => {
666
- let n = e.parentElement;
667
- for (; n && n !== document.body; ) {
668
- const t = window.getComputedStyle(n), i = t.overflow + t.overflowY + t.overflowX;
669
- if (i.includes("auto") || i.includes("scroll") || n.scrollHeight > n.clientHeight || n.scrollWidth > n.clientWidth)
670
- return n;
671
- n = n.parentElement;
665
+ const pt = (e) => {
666
+ let i = e.parentElement;
667
+ for (; i && i !== document.body; ) {
668
+ const t = window.getComputedStyle(i), n = t.overflow + t.overflowY + t.overflowX;
669
+ if (n.includes("auto") || n.includes("scroll") || i.scrollHeight > i.clientHeight || i.scrollWidth > i.clientWidth)
670
+ return i;
671
+ i = i.parentElement;
672
672
  }
673
673
  return document.documentElement;
674
- }, vt = (e) => {
675
- let n = e.parentElement;
676
- for (; n && n !== document.body; ) {
677
- const t = window.getComputedStyle(n).position;
674
+ }, yt = (e) => {
675
+ let i = e.parentElement;
676
+ for (; i && i !== document.body; ) {
677
+ const t = window.getComputedStyle(i).position;
678
678
  if (t === "relative" || t === "absolute" || t === "fixed" || t === "sticky")
679
- return n;
680
- n = n.parentElement;
679
+ return i;
680
+ i = i.parentElement;
681
681
  }
682
682
  return document.body;
683
683
  };
684
- function X(e) {
685
- return new Promise((n) => {
684
+ function B(e) {
685
+ return new Promise((i) => {
686
686
  requestAnimationFrame(() => {
687
687
  requestAnimationFrame(() => {
688
- n();
688
+ i();
689
689
  });
690
690
  });
691
691
  });
692
692
  }
693
- function Z() {
694
- return typeof window > "u" || typeof navigator > "u" ? !1 : /iPad|iPhone|iPod/.test(navigator.userAgent) || // iPad on iOS 13+ reports as MacIntel but has touch
695
- navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
696
- }
697
- function tt() {
698
- return typeof window > "u" || typeof navigator > "u" ? !1 : /Android/i.test(navigator.userAgent);
699
- }
700
- function St() {
701
- return typeof window > "u" || typeof navigator > "u" ? !1 : !Z() && !tt();
702
- }
703
- function At(e) {
704
- return e.length === 0 ? !1 : !!(e.includes("all") || e.includes("ios") && Z() || e.includes("android") && tt() || e.includes("desktop") && St());
705
- }
706
- function Ct(e, n) {
707
- var E;
708
- let t = null, i = null, r = null, o = null;
709
- const l = {
693
+ function vt(e, i) {
694
+ var T;
695
+ let t = null, n = null, r = null, o = null;
696
+ const u = {
710
697
  get currentAnimation() {
711
698
  return t;
712
699
  }
713
- }, u = ((E = n == null ? void 0 : n.strategy) == null ? void 0 : E.call(n, l)) || ht(l), s = async (y) => {
714
- var m, g;
715
- i && (i.remove(), i = null);
716
- const p = e(), T = p.in && p.in(y), A = !(n != null && n.strategy) && p.out ? p.out(y) : void 0;
717
- if (!T)
700
+ }, f = ((T = i == null ? void 0 : i.strategy) == null ? void 0 : T.call(i, u)) || dt(u), a = async (p) => {
701
+ var h, S;
702
+ n && (n.remove(), n = null);
703
+ const y = e(), R = y.in && y.in(p), C = !(i != null && i.strategy) && y.out ? y.out(p) : void 0;
704
+ if (!R)
718
705
  return;
719
- const P = {
720
- in: M(T),
721
- out: A ? M(A) : void 0
722
- }, v = await u.runIn(P);
723
- if (!v.config) {
706
+ const g = {
707
+ in: F(R),
708
+ out: C ? F(C) : void 0
709
+ }, l = await f.runIn(g);
710
+ if (!l.config) {
724
711
  t && (t.direction = "in");
725
712
  return;
726
713
  }
727
- const h = v.config;
728
- (m = h.prepare) == null || m.call(h);
729
- const C = j(
714
+ const s = l.config;
715
+ (h = s.prepare) == null || h.call(s);
716
+ const v = W(
730
717
  {
731
- ...h,
718
+ ...s,
732
719
  onEnd: () => {
733
- var S;
734
- t = null, (S = h.onEnd) == null || S.call(h);
720
+ var b;
721
+ t = null, (b = s.onEnd) == null || b.call(s);
735
722
  }
736
723
  },
737
- y
724
+ p
738
725
  );
739
- h.wait && await h.wait();
740
- const a = L.fromState(v.state, {
741
- config: C,
742
- from: v.from,
743
- to: v.to
726
+ s.wait && await s.wait();
727
+ const c = D.fromState(l.state, {
728
+ config: v,
729
+ from: l.from,
730
+ to: l.to
744
731
  });
745
- t = { controller: a, direction: "in" }, (g = h.onReady) == null || g.call(h), await X(), v.direction === "forward" ? a.forward() : a.backward();
746
- }, c = async (y) => {
747
- var g, S;
748
- i = y;
749
- const p = e(), T = !(n != null && n.strategy) && p.in ? p.in(y) : void 0, A = p.out && p.out(y);
750
- if (!A)
732
+ t = { controller: c, direction: "in" }, (S = s.onReady) == null || S.call(s), await B(), l.direction === "forward" ? c.forward() : c.backward();
733
+ }, m = async (p) => {
734
+ var S, b;
735
+ n = p;
736
+ const y = e(), R = !(i != null && i.strategy) && y.in ? y.in(p) : void 0, C = y.out && y.out(p);
737
+ if (!C)
751
738
  return;
752
- const P = {
753
- in: T ? M(T) : void 0,
754
- out: M(A)
755
- }, v = await u.runOut(P);
756
- if (!v.config) {
757
- t && (t.direction = "out"), i && (i.remove(), i = null);
739
+ const g = {
740
+ in: R ? F(R) : void 0,
741
+ out: F(C)
742
+ }, l = await f.runOut(g);
743
+ if (!l.config) {
744
+ t && (t.direction = "out"), n && (n.remove(), n = null);
758
745
  return;
759
746
  }
760
- const h = v.config;
761
- m(), (g = h.prepare) == null || g.call(h);
762
- const C = j(
747
+ const s = l.config;
748
+ h(), (S = s.prepare) == null || S.call(s);
749
+ const v = W(
763
750
  {
764
- ...h,
751
+ ...s,
765
752
  onEnd: () => {
766
- var R, V;
767
- (R = h.onEnd) == null || R.call(h), i && (i.remove(), i = null), t = null, (V = n == null ? void 0 : n.onCleanupEnd) == null || V.call(n);
753
+ var k, M;
754
+ (k = s.onEnd) == null || k.call(s), n && (n.remove(), n = null), t = null, (M = i == null ? void 0 : i.onCleanupEnd) == null || M.call(i);
768
755
  }
769
756
  },
770
- y
757
+ p
771
758
  );
772
- h.wait && await h.wait();
773
- const a = L.fromState(v.state, {
774
- config: C,
775
- from: v.from,
776
- to: v.to
759
+ s.wait && await s.wait();
760
+ const c = D.fromState(l.state, {
761
+ config: v,
762
+ from: l.from,
763
+ to: l.to
777
764
  });
778
- t = { controller: a, direction: "out" }, (S = h.onReady) == null || S.call(h), await X(), v.direction === "forward" ? a.forward() : a.backward();
779
- function m() {
780
- !r || !i || (o && r.contains(o) ? r.insertBefore(i, o) : r.appendChild(i));
765
+ t = { controller: c, direction: "out" }, (b = s.onReady) == null || b.call(s), await B(), l.direction === "forward" ? c.forward() : c.backward();
766
+ function h() {
767
+ !r || !n || (o && r.contains(o) ? r.insertBefore(n, o) : r.appendChild(n));
781
768
  }
782
769
  };
783
- let d = null, w = !1;
784
- const b = (y) => () => {
785
- if (w) return;
786
- w = !0;
787
- const p = y.cloneNode(!0);
788
- d ? queueMicrotask(() => {
789
- document.contains(d) && c(p);
790
- }) : c(p);
770
+ let w = null, E = !1;
771
+ const A = (p) => () => {
772
+ if (E) return;
773
+ E = !0;
774
+ const y = p.cloneNode(!0);
775
+ w ? queueMicrotask(() => {
776
+ document.contains(w) && m(y);
777
+ }) : m(y);
791
778
  };
792
- return (y) => {
793
- if (y)
779
+ return (p) => {
780
+ if (p)
794
781
  return requestAnimationFrame(() => {
795
- r = y.parentElement, o = y.nextElementSibling;
796
- }), w = !1, (n == null ? void 0 : n.scope) === "local" ? queueMicrotask(() => {
797
- d = pt(y), !(d && !yt(d)) && s(y);
798
- }) : s(y), b(y);
782
+ r = p.parentElement, o = p.nextElementSibling;
783
+ }), E = !1, (i == null ? void 0 : i.scope) === "local" ? queueMicrotask(() => {
784
+ w = wt(p), !(w && !gt(w)) && a(p);
785
+ }) : a(p), A(p);
799
786
  };
800
787
  }
801
- const I = /* @__PURE__ */ new Map();
802
- let k = null, N = !1;
803
- function et(e) {
804
- if (e instanceof HTMLElement && I.has(e)) {
805
- const t = I.get(e);
806
- I.delete(e), queueMicrotask(() => {
788
+ const P = /* @__PURE__ */ new Map();
789
+ let I = null, N = !1;
790
+ function tt(e) {
791
+ if (e instanceof HTMLElement && P.has(e)) {
792
+ const t = P.get(e);
793
+ P.delete(e), queueMicrotask(() => {
807
794
  t();
808
795
  });
809
796
  }
810
- const n = e.childNodes;
811
- for (let t = 0; t < n.length; t++) {
812
- const i = n[t];
813
- i && et(i);
797
+ const i = e.childNodes;
798
+ for (let t = 0; t < i.length; t++) {
799
+ const n = i[t];
800
+ n && tt(n);
814
801
  }
815
802
  }
816
- function bt() {
817
- N || typeof document > "u" || (N = !0, k = new MutationObserver((e) => {
818
- for (const n of e) {
819
- const t = n.removedNodes;
820
- for (let i = 0; i < t.length; i++) {
821
- const r = t[i];
822
- r && et(r);
803
+ function St() {
804
+ N || typeof document > "u" || (N = !0, I = new MutationObserver((e) => {
805
+ for (const i of e) {
806
+ const t = i.removedNodes;
807
+ for (let n = 0; n < t.length; n++) {
808
+ const r = t[n];
809
+ r && tt(r);
823
810
  }
824
811
  }
825
- }), document.body ? k.observe(document.body, {
812
+ }), document.body ? I.observe(document.body, {
826
813
  childList: !0,
827
814
  subtree: !0
828
815
  }) : document.addEventListener(
829
816
  "DOMContentLoaded",
830
817
  () => {
831
- k == null || k.observe(document.body, {
818
+ I == null || I.observe(document.body, {
832
819
  childList: !0,
833
820
  subtree: !0
834
821
  });
@@ -836,322 +823,385 @@ function bt() {
836
823
  { once: !0 }
837
824
  ));
838
825
  }
839
- function Et(e, n) {
840
- bt(), I.set(e, n);
826
+ function Et(e, i) {
827
+ St(), P.set(e, i);
841
828
  }
842
829
  function Nt(e) {
843
- return I.has(e);
830
+ return P.has(e);
844
831
  }
845
- function Bt() {
846
- return I.size;
832
+ function qt() {
833
+ return P.size;
847
834
  }
848
- function Ut(e) {
849
- const n = I.get(e);
850
- return n ? (I.delete(e), n(), !0) : !1;
835
+ function Xt(e) {
836
+ const i = P.get(e);
837
+ return i ? (P.delete(e), i(), !0) : !1;
851
838
  }
852
839
  function Wt() {
853
- I.clear(), k == null || k.disconnect(), k = null, N = !1;
840
+ P.clear(), I == null || I.disconnect(), I = null, N = !1;
854
841
  }
855
- const z = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map();
856
- function Tt(e, n, t) {
857
- z.set(e, n);
858
- let i = B.get(e);
859
- if (i)
860
- return i;
861
- const r = n;
862
- return i = Ct(
842
+ const L = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map();
843
+ function At(e, i, t) {
844
+ L.set(e, i);
845
+ let n = q.get(e);
846
+ if (n)
847
+ return n;
848
+ const r = i;
849
+ return n = vt(
863
850
  () => {
864
- const o = z.get(e);
851
+ const o = L.get(e);
865
852
  return o || (console.warn(`Transition "${String(e)}" not found`), {});
866
853
  },
867
854
  {
868
855
  strategy: t == null ? void 0 : t.strategy,
869
856
  scope: t == null ? void 0 : t.scope,
870
857
  onCleanupEnd: () => {
871
- z.get(e) === r && kt(e);
858
+ L.get(e) === r && Tt(e);
872
859
  }
873
860
  }
874
- ), B.set(e, i), i;
861
+ ), q.set(e, n), n;
875
862
  }
876
- function kt(e) {
877
- z.delete(e), B.delete(e), U.delete(e);
863
+ function Tt(e) {
864
+ L.delete(e), q.delete(e), X.delete(e);
878
865
  }
879
- function jt(e, n = "manual") {
880
- const t = Tt(
866
+ function Ht(e, i = "manual") {
867
+ const t = At(
881
868
  e.key,
882
869
  {
883
870
  in: e.in,
884
871
  out: e.out
885
872
  },
886
873
  {
887
- strategy: e[$],
874
+ strategy: e[Z],
888
875
  scope: e.scope
889
876
  }
890
877
  );
891
- if (n === "manual")
878
+ if (i === "manual")
892
879
  return t;
893
- let i = U.get(e.key);
894
- return i || (i = (r) => {
880
+ let n = X.get(e.key);
881
+ return n || (n = (r) => {
895
882
  if (r) {
896
883
  const o = t(r);
897
884
  o && Et(r, o);
898
885
  }
899
- }, U.set(e.key, i), i);
886
+ }, X.set(e.key, n), n);
900
887
  }
901
- function It(e) {
902
- const n = e.filter((t) => t.symmetric).map((t) => ({
888
+ function Ct(e) {
889
+ const i = e.filter((t) => t.symmetric).map((t) => ({
903
890
  from: t.to,
904
891
  to: t.from,
905
892
  transition: t.transition
906
893
  }));
907
- return [...e, ...n];
908
- }
909
- function Pt() {
910
- var s;
911
- let e = typeof history < "u" ? ((s = history.state) == null ? void 0 : s.ssgoiIndex) ?? 0 : 0, n = "push", t = !1, i = !1;
912
- const r = (c) => {
913
- var w;
914
- t = !0;
915
- const d = ((w = c.state) == null ? void 0 : w.ssgoiIndex) ?? 0;
916
- d < e ? (n = "back", i = !0) : d > e && (n = "forward"), e = d;
917
- };
918
- return {
919
- initialize: () => {
920
- var c;
921
- typeof window > "u" || (window.addEventListener("popstate", r), ((c = history.state) == null ? void 0 : c.ssgoiIndex) == null ? history.replaceState({ ...history.state, ssgoiIndex: e }, "") : e = history.state.ssgoiIndex);
922
- },
923
- onPageEnter: () => {
924
- t || (e++, history.replaceState({ ...history.state, ssgoiIndex: e }, ""));
925
- const c = n;
926
- return n = "push", t = !1, setTimeout(() => {
927
- i = !1;
928
- }, 0), c;
929
- },
930
- isBack: () => i || n === "back"
931
- };
894
+ return [...e, ...i];
932
895
  }
933
- function x(e, n) {
934
- if (n === "*")
896
+ function V(e, i) {
897
+ if (i === "*")
935
898
  return !0;
936
- if (n.endsWith("/*")) {
937
- const t = n.slice(0, -1);
899
+ if (i.endsWith("/*")) {
900
+ const t = i.slice(0, -1);
938
901
  return e.startsWith(t) && e.length > t.length;
939
902
  }
940
- return e === n;
903
+ return e === i;
941
904
  }
942
- function Rt(e, n, t) {
943
- for (const i of t)
944
- if (x(e, i.from) && x(n, i.to))
945
- return i.transition;
946
- for (const i of t)
947
- if ((i.from === "*" || x(e, i.from)) && (i.to === "*" || x(n, i.to)))
948
- return i.transition;
905
+ function bt(e, i, t) {
906
+ for (const n of t)
907
+ if (V(e, n.from) && V(i, n.to))
908
+ return n.transition;
909
+ for (const n of t)
910
+ if ((n.from === "*" || V(e, n.from)) && (n.to === "*" || V(i, n.to)))
911
+ return n.transition;
949
912
  return null;
950
913
  }
951
- const xt = 768, Vt = 10, Ft = 10;
952
- function Mt(e = {}) {
953
- const { preserveScroll: n = (a) => a } = e, t = typeof n == "function" ? n : () => n;
954
- let i = null, r = !1, o = !1;
955
- const l = () => {
956
- const a = (i == null ? void 0 : i.clientWidth) ?? 0, m = a > 0 ? a : typeof window < "u" ? window.innerWidth : 0;
957
- return m > 0 && m < xt;
958
- }, u = () => (o || (r = l(), o = !0), r), s = (a) => {
959
- const m = t(u());
960
- return m === !1 ? !1 : m === !0 ? !0 : !m.exclude.some((g) => x(a, g));
914
+ const Rt = 768, kt = 10, It = 10;
915
+ function Pt(e = {}) {
916
+ const { preserveScroll: i = (c) => c } = e, t = typeof i == "function" ? i : () => i;
917
+ let n = null, r = !1, o = !1;
918
+ const u = () => {
919
+ const c = (n == null ? void 0 : n.clientWidth) ?? 0, h = c > 0 ? c : typeof window < "u" ? window.innerWidth : 0;
920
+ return h > 0 && h < Rt;
921
+ }, f = () => (o || (r = u(), o = !0), r), a = (c) => {
922
+ const h = t(f());
923
+ return h === !1 ? !1 : h === !0 ? !0 : !h.exclude.some((S) => V(c, S));
961
924
  };
962
- let c = null;
963
- const d = /* @__PURE__ */ new Map();
964
- let w = null, b = !1, E = 0;
965
- const y = () => {
966
- i && w && !b && d.set(w, {
967
- x: i.scrollLeft,
968
- y: i.scrollTop
925
+ let m = null;
926
+ const w = /* @__PURE__ */ new Map();
927
+ let E = null, A = !1, T = 0;
928
+ const p = () => {
929
+ n && E && !A && w.set(E, {
930
+ x: n.scrollLeft,
931
+ y: n.scrollTop
969
932
  });
970
- }, p = (a) => {
971
- if (!i) return;
972
- const m = s(a) && d.has(a) ? d.get(a) : { x: 0, y: 0 };
973
- let g = 0;
974
- const S = () => {
975
- if (!i) return;
976
- i.scrollTo({
977
- top: m.y,
978
- left: m.x
979
- }), !(Math.abs(i.scrollTop - m.y) < 1 && Math.abs(i.scrollLeft - m.x) < 1) && g < Vt && (g++, requestAnimationFrame(S));
933
+ }, y = (c) => {
934
+ if (!n) return;
935
+ const h = a(c) && w.has(c) ? w.get(c) : { x: 0, y: 0 };
936
+ let S = 0;
937
+ const b = () => {
938
+ if (!n) return;
939
+ n.scrollTo({
940
+ top: h.y,
941
+ left: h.x
942
+ }), !(Math.abs(n.scrollTop - h.y) < 1 && Math.abs(n.scrollLeft - h.x) < 1) && S < kt && (S++, requestAnimationFrame(b));
980
943
  };
981
- requestAnimationFrame(S);
944
+ requestAnimationFrame(b);
982
945
  };
983
946
  return {
984
- initializeContext: (a, m) => {
985
- b = !0;
986
- const g = ++E;
987
- c = a, i || (i = wt(a), r = l(), o = !0, typeof ResizeObserver < "u" && new ResizeObserver(() => {
988
- r = l();
989
- }).observe(i), (i === document.documentElement ? window : i).addEventListener("scroll", y, {
947
+ initializeContext: (c, h) => {
948
+ A = !0;
949
+ const S = ++T;
950
+ m = c, n || (n = pt(c), r = u(), o = !0, typeof ResizeObserver < "u" && new ResizeObserver(() => {
951
+ r = u();
952
+ }).observe(n), (n === document.documentElement ? window : n).addEventListener("scroll", p, {
990
953
  passive: !0
991
- })), w = m, p(m);
992
- let S = 0;
993
- const R = () => {
994
- g === E && (S++, S >= Ft ? b = !1 : requestAnimationFrame(R));
954
+ })), E = h, y(h);
955
+ let b = 0;
956
+ const k = () => {
957
+ S === T && (b++, b >= It ? A = !1 : requestAnimationFrame(k));
995
958
  };
996
- requestAnimationFrame(R);
959
+ requestAnimationFrame(k);
997
960
  },
998
- calculateScrollOffset: (a, m) => {
999
- const g = a && d.has(a) ? d.get(a) : { x: 0, y: 0 }, S = m && s(m) && d.has(m) ? d.get(m) : { x: 0, y: 0 };
961
+ calculateScrollOffset: (c, h) => {
962
+ const S = c && w.has(c) ? w.get(c) : { x: 0, y: 0 }, b = h && a(h) && w.has(h) ? w.get(h) : { x: 0, y: 0 };
1000
963
  return {
1001
- x: -S.x + g.x,
1002
- y: -S.y + g.y
964
+ x: -b.x + S.x,
965
+ y: -b.y + S.y
1003
966
  };
1004
967
  },
1005
- evictScrollPosition: (a) => {
1006
- d.delete(a);
968
+ evictScrollPosition: (c) => {
969
+ w.delete(c);
1007
970
  },
1008
- shouldPreserve: s,
1009
- getScrollContainer: () => i,
1010
- getPositionedParentElement: () => c ? vt(c) : document.body,
1011
- getScrollPosition: (a) => a && d.has(a) ? d.get(a) : { x: 0, y: 0 }
971
+ shouldPreserve: a,
972
+ getScrollContainer: () => n,
973
+ getPositionedParentElement: () => m ? yt(m) : document.body,
974
+ getScrollPosition: (c) => c && w.has(c) ? w.get(c) : { x: 0, y: 0 }
1012
975
  };
1013
976
  }
1014
- function Ot() {
977
+ const Y = 30, j = 8, G = 1.2, Mt = 30, Vt = 600;
978
+ function xt() {
979
+ let e = null, i = !1, t = !1, n = null, r = null, o = !1;
980
+ const u = (g, l) => {
981
+ for (let s = 0; s < g.length; s++) {
982
+ const v = g.item(s);
983
+ if (v && v.identifier === l) return v;
984
+ }
985
+ return null;
986
+ }, f = () => {
987
+ n !== null && (clearTimeout(n), n = null);
988
+ }, a = () => {
989
+ r !== null && (clearTimeout(r), r = null);
990
+ }, m = () => {
991
+ i = !0, t = !0, f(), a(), n = setTimeout(() => {
992
+ i = !1, t = !1, n = null;
993
+ }, Vt);
994
+ }, w = (g) => {
995
+ if (g.touches.length !== 1) {
996
+ e = null;
997
+ return;
998
+ }
999
+ const l = g.touches.item(0);
1000
+ if (!l) {
1001
+ e = null;
1002
+ return;
1003
+ }
1004
+ const s = window.innerWidth, v = l.clientX <= Y, c = l.clientX >= s - Y;
1005
+ if (!v && !c) {
1006
+ e = null;
1007
+ return;
1008
+ }
1009
+ e = {
1010
+ identifier: l.identifier,
1011
+ startX: l.clientX,
1012
+ startY: l.clientY,
1013
+ fromLeftEdge: v,
1014
+ moved: !1
1015
+ };
1016
+ }, E = (g) => {
1017
+ if (!e) return;
1018
+ if (g.touches.length !== 1) {
1019
+ e = null;
1020
+ return;
1021
+ }
1022
+ const l = u(g.touches, e.identifier);
1023
+ if (!l) {
1024
+ e = null;
1025
+ return;
1026
+ }
1027
+ const s = l.clientX - e.startX, v = l.clientY - e.startY, c = Math.abs(s), h = Math.abs(v);
1028
+ if (h > j && h > c * G) {
1029
+ e = null;
1030
+ return;
1031
+ }
1032
+ const S = e.fromLeftEdge ? s > 0 : s < 0;
1033
+ c > j && c > h * G && S && (e.moved = !0);
1034
+ }, A = (g) => {
1035
+ if (!e) return;
1036
+ const l = u(g.changedTouches, e.identifier);
1037
+ if (!l) {
1038
+ e = null;
1039
+ return;
1040
+ }
1041
+ const s = l.clientX - e.startX, v = e.fromLeftEdge ? s > 0 : s < 0;
1042
+ e.moved && v && Math.abs(s) >= Mt && m(), e = null;
1043
+ }, T = () => {
1044
+ e && (e.moved && m(), e = null);
1045
+ };
1046
+ return { initialize: () => {
1047
+ if (typeof window > "u" || o) return;
1048
+ o = !0;
1049
+ const g = { passive: !0, capture: !0 };
1050
+ window.addEventListener("touchstart", w, g), window.addEventListener("touchmove", E, g), window.addEventListener("touchend", A, g), window.addEventListener("touchcancel", T, g);
1051
+ }, destroy: () => {
1052
+ if (typeof window > "u" || !o) return;
1053
+ o = !1;
1054
+ const g = { capture: !0 };
1055
+ window.removeEventListener("touchstart", w, g), window.removeEventListener("touchmove", E, g), window.removeEventListener("touchend", A, g), window.removeEventListener("touchcancel", T, g), f(), a(), e = null, i = !1, t = !1;
1056
+ }, isSwipeBack: () => {
1057
+ const g = i || t;
1058
+ return g && f(), g;
1059
+ }, onPageEnter: () => {
1060
+ i = !1, f(), a(), r = setTimeout(() => {
1061
+ t = !1, r = null;
1062
+ }, 0);
1063
+ } };
1064
+ }
1065
+ function Ft() {
1015
1066
  let e = null;
1016
- function n() {
1067
+ function i() {
1017
1068
  if (e != null && e.from && (e != null && e.to) && (e != null && e.outResolve) && (e != null && e.inResolve)) {
1018
1069
  const t = { from: e.from, to: e.to };
1019
1070
  e.outResolve(t), e.inResolve(t), e = null;
1020
1071
  }
1021
1072
  }
1022
1073
  return {
1023
- trigger(t, i) {
1024
- e || (e = {}), i === "out" ? e.from = t : e.to = t;
1074
+ trigger(t, n) {
1075
+ e || (e = {}), n === "out" ? e.from = t : e.to = t;
1025
1076
  },
1026
1077
  get(t) {
1027
- return t === "in" && (!e || !e.from) ? Promise.resolve(null) : new Promise((i) => {
1028
- e || (e = {}), t === "out" ? e.outResolve = i : e.inResolve = i, n();
1078
+ return t === "in" && (!e || !e.from) ? Promise.resolve(null) : new Promise((n) => {
1079
+ e || (e = {}), t === "out" ? e.outResolve = n : e.inResolve = n, i();
1029
1080
  });
1030
1081
  }
1031
1082
  };
1032
1083
  }
1033
- function zt() {
1084
+ function Ot() {
1034
1085
  let e = null;
1035
- function n() {
1036
- var i, r;
1037
- e && ((i = e.outResolve) == null || i.call(e, null), (r = e.inResolve) == null || r.call(e, null), e = null);
1086
+ function i() {
1087
+ var n, r;
1088
+ e && ((n = e.outResolve) == null || n.call(e, null), (r = e.inResolve) == null || r.call(e, null), e = null);
1038
1089
  }
1039
1090
  function t() {
1040
1091
  if (e != null && e.from && (e != null && e.to) && (e != null && e.outResolve) && (e != null && e.inResolve)) {
1041
1092
  if (e.from === e.to) {
1042
- n();
1093
+ i();
1043
1094
  return;
1044
1095
  }
1045
- const i = { from: e.from, to: e.to };
1046
- e.outResolve(i), e.inResolve(i), e = null;
1096
+ const n = { from: e.from, to: e.to };
1097
+ e.outResolve(n), e.inResolve(n), e = null;
1047
1098
  }
1048
1099
  }
1049
1100
  return {
1050
- trigger(i, r) {
1051
- e && (r === "out" && e.from && e.from !== i || r === "in" && e.to && e.to !== i) && n(), e || (e = {}), r === "out" ? e.from = i : e.to = i;
1101
+ trigger(n, r) {
1102
+ e && (r === "out" && e.from && e.from !== n || r === "in" && e.to && e.to !== n) && i(), e || (e = {}), r === "out" ? e.from = n : e.to = n;
1052
1103
  },
1053
- get(i) {
1104
+ get(n) {
1054
1105
  return new Promise((r) => {
1055
- e || (e = {}), i === "out" ? e.outResolve = r : e.inResolve = r, t();
1106
+ e || (e = {}), n === "out" ? e.outResolve = r : e.inResolve = r, t();
1056
1107
  });
1057
1108
  }
1058
1109
  };
1059
1110
  }
1060
- function Ht(e, n) {
1111
+ function Ut(e, i) {
1061
1112
  const {
1062
1113
  transitions: t = [],
1063
- defaultTransition: i,
1064
- middleware: r = (C, a) => ({ from: C, to: a }),
1114
+ defaultTransition: n,
1115
+ middleware: r = (l, s) => ({ from: l, to: s }),
1065
1116
  // Identity function as default
1066
- skipAnimationOnBack: o = ["ios"],
1067
- preserveScroll: l = (C) => C
1068
- } = e, u = At(o), { outFirst: s = !0 } = n || {}, c = s ? Ot() : zt(), d = It(t), {
1117
+ preserveScroll: o = (l) => l
1118
+ } = e, { outFirst: u = !0 } = i || {}, f = u ? Ft() : Ot(), a = Ct(t), m = xt();
1119
+ m.initialize();
1120
+ const {
1069
1121
  initializeContext: w,
1070
- calculateScrollOffset: b,
1071
- evictScrollPosition: E,
1072
- shouldPreserve: y,
1122
+ calculateScrollOffset: E,
1123
+ evictScrollPosition: A,
1124
+ shouldPreserve: T,
1073
1125
  getScrollContainer: p,
1074
- getPositionedParentElement: T,
1075
- getScrollPosition: A
1076
- } = Mt({
1077
- preserveScroll: l
1078
- }), P = Pt();
1079
- u && P.initialize();
1080
- const v = async (C, a) => {
1081
- const m = u && P.isBack();
1082
- c.trigger(C, a);
1083
- const g = await c.get(a);
1084
- if (!g) return () => ({});
1085
- if (a === "in" && u && P.onPageEnter(), m)
1086
- return () => ({});
1087
- const { from: S, to: R } = r(
1088
- g.from,
1089
- g.to
1090
- ), F = Rt(
1126
+ getPositionedParentElement: y,
1127
+ getScrollPosition: R
1128
+ } = Pt({
1129
+ preserveScroll: o
1130
+ }), C = async (l, s) => {
1131
+ const v = m.isSwipeBack();
1132
+ f.trigger(l, s);
1133
+ const c = await f.get(s);
1134
+ if (s === "in" && m.onPageEnter(), !c) return () => ({});
1135
+ if (v)
1136
+ return s === "out" && c.from && !T(c.from) && A(c.from), () => ({});
1137
+ const { from: h, to: S } = r(
1138
+ c.from,
1139
+ c.to
1140
+ ), k = bt(
1141
+ h,
1091
1142
  S,
1092
- R,
1093
- d
1094
- ) || i;
1095
- if (!F) return () => ({});
1096
- const W = b(g.from, g.to);
1097
- if (a === "out") {
1098
- const D = {
1099
- scrollOffset: W,
1100
- scroll: A(g.from),
1143
+ a
1144
+ ) || n;
1145
+ if (!k) return () => ({});
1146
+ const M = E(c.from, c.to);
1147
+ if (s === "out") {
1148
+ const x = {
1149
+ scrollOffset: M,
1150
+ scroll: R(c.from),
1101
1151
  get scrollingElement() {
1102
1152
  return p() || document.documentElement;
1103
1153
  },
1104
1154
  get positionedParent() {
1105
- return T();
1155
+ return y();
1106
1156
  }
1107
1157
  };
1108
- return g.from && !y(g.from) && E(g.from), (_) => F.out(_, D);
1158
+ return c.from && !T(c.from) && A(c.from), (_) => k.out(_, x);
1109
1159
  } else {
1110
- const D = {
1111
- scrollOffset: W,
1160
+ const x = {
1161
+ scrollOffset: M,
1112
1162
  get scroll() {
1113
- return A(g.to);
1163
+ return R(c.to);
1114
1164
  },
1115
1165
  get scrollingElement() {
1116
1166
  return p() || document.documentElement;
1117
1167
  },
1118
1168
  get positionedParent() {
1119
- return T();
1169
+ return y();
1120
1170
  }
1121
1171
  };
1122
- return (_) => F.in(_, D);
1172
+ return (_) => k.in(_, x);
1123
1173
  }
1124
1174
  };
1125
- return (C) => ({
1126
- key: C,
1127
- in: async (a) => (w(a, C), (await v(C, "in"))(a)),
1128
- out: async (a) => (await v(C, "out"))(a),
1175
+ return (l) => ({
1176
+ key: l,
1177
+ in: async (s) => (w(s, l), (await C(l, "in"))(s)),
1178
+ out: async (s) => (await C(l, "out"))(s),
1129
1179
  // Add page transition strategy for page-level transitions
1130
- [$]: gt
1180
+ [Z]: ht
1131
1181
  });
1132
1182
  }
1133
1183
  export {
1134
1184
  J as SCOPE_ATTR,
1135
1185
  Q as SCOPE_READY_ATTR,
1136
- $ as TRANSITION_STRATEGY,
1137
- zt as createAnyOrderDetector,
1138
- ht as createDefaultStrategy,
1139
- Ot as createOutFirstDetector,
1140
- gt as createPageTransitionStrategy,
1141
- Ht as createSggoiTransitionContext,
1142
- qt as createTransitionScope,
1143
- pt as findScope,
1144
- Bt as getWatchedCount,
1145
- Yt as isCssAnimation,
1146
- Kt as isMultiAnimation,
1147
- yt as isScopeReady,
1148
- $t as isSingleAnimation,
1149
- Jt as isTickAnimation,
1186
+ Z as TRANSITION_STRATEGY,
1187
+ Ot as createAnyOrderDetector,
1188
+ dt as createDefaultStrategy,
1189
+ Ft as createOutFirstDetector,
1190
+ ht as createPageTransitionStrategy,
1191
+ Ut as createSggoiTransitionContext,
1192
+ zt as createTransitionScope,
1193
+ wt as findScope,
1194
+ qt as getWatchedCount,
1195
+ jt as isCssAnimation,
1196
+ Gt as isMultiAnimation,
1197
+ gt as isScopeReady,
1198
+ Kt as isSingleAnimation,
1199
+ $t as isTickAnimation,
1150
1200
  Nt as isWatched,
1151
- j as normalizeSchedule,
1152
- M as normalizeToMultiAnimation,
1201
+ W as normalizeSchedule,
1202
+ F as normalizeToMultiAnimation,
1153
1203
  Wt as resetObserver,
1154
- jt as transition,
1155
- Ut as triggerUnmount,
1204
+ Ht as transition,
1205
+ Xt as triggerUnmount,
1156
1206
  Et as watchUnmount
1157
1207
  };