@ssgoi/core 4.3.0 → 4.3.2

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,38 +1,38 @@
1
- var tt = Object.defineProperty;
2
- var et = (e, n, t) => n in e ? tt(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var m = (e, n, t) => et(e, typeof n != "symbol" ? n + "" : n, t);
4
- import { normalizeToMultiAnimation as F, normalizeSchedule as X } from "./types.js";
5
- import { isCssAnimation as _t, isMultiAnimation as Nt, isSingleAnimation as Ut, isTickAnimation as Ht } from "./types.js";
6
- import { S as $, I as it, a as nt } from "./provider-Cu4NSF1Q.js";
7
- class rt {
1
+ var et = Object.defineProperty;
2
+ var it = (e, n, t) => n in e ? et(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var d = (e, n, t) => it(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import { normalizeToMultiAnimation as M, normalizeSchedule as H } from "./types.js";
5
+ import { isCssAnimation as Ut, isMultiAnimation as Xt, isSingleAnimation as Yt, isTickAnimation as Ht } from "./types.js";
6
+ import { S as K, I as nt, a as rt } from "./provider-Cu4NSF1Q.js";
7
+ class ot {
8
8
  constructor() {
9
- m(this, "listeners", /* @__PURE__ */ new Set());
10
- m(this, "rafId", null);
11
- m(this, "isRunning", !1);
9
+ d(this, "listeners", /* @__PURE__ */ new Set());
10
+ d(this, "rafId", null);
11
+ d(this, "isRunning", !1);
12
12
  // Timing
13
- m(this, "startTime", Date.now());
14
- m(this, "lastUpdate", this.startTime);
15
- m(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
- m(this, "lagThreshold", 500);
17
+ d(this, "lagThreshold", 500);
18
18
  // ms - detect tab switches, backgrounding
19
- m(this, "adjustedLag", 33);
19
+ d(this, "adjustedLag", 33);
20
20
  // ms - max time jump to prevent animation skip
21
- m(this, "maxDeltaTime", 33);
21
+ d(this, "maxDeltaTime", 33);
22
22
  // ms - clamp for physics stability (30fps minimum)
23
23
  // FPS throttling
24
- m(this, "gap", 1e3 / 240);
24
+ d(this, "gap", 1e3 / 240);
25
25
  // max 240fps
26
- m(this, "nextTime", this.gap);
27
- m(this, "tick", () => {
26
+ d(this, "nextTime", this.gap);
27
+ d(this, "tick", () => {
28
28
  const n = Date.now();
29
29
  let i = n - this.lastUpdate;
30
30
  i > this.lagThreshold || i < 0 ? (this.startTime += i - this.adjustedLag, i = this.adjustedLag) : i > this.maxDeltaTime && (i = this.maxDeltaTime), this.lastUpdate = n;
31
31
  const r = n - this.startTime, o = r - this.nextTime;
32
32
  if (o > 0) {
33
- const c = i / 1e3;
34
- this.elapsed = r / 1e3, this.nextTime += o + (o >= this.gap ? 4 : this.gap - o), this.listeners.forEach((a) => {
35
- a(c, this.elapsed);
33
+ const l = i / 1e3;
34
+ this.elapsed = r / 1e3, this.nextTime += o + (o >= this.gap ? 4 : this.gap - o), this.listeners.forEach((f) => {
35
+ f(l, this.elapsed);
36
36
  });
37
37
  }
38
38
  this.listeners.size > 0 ? this.rafId = requestAnimationFrame(this.tick) : (this.isRunning = !1, this.rafId = null);
@@ -68,64 +68,64 @@ class rt {
68
68
  return this.elapsed;
69
69
  }
70
70
  }
71
- const _ = new rt();
72
- function ot(e) {
71
+ const N = new ot();
72
+ function st(e) {
73
73
  const {
74
74
  integrator: n,
75
75
  from: t,
76
76
  to: i,
77
77
  velocity: r = 0,
78
78
  onUpdate: o,
79
- onComplete: c,
80
- onStart: a
79
+ onComplete: l,
80
+ onStart: f
81
81
  } = e;
82
- let s = { position: t, velocity: r }, u = !0, h = 0, p = !1;
83
- const w = (v) => {
84
- if (u) {
85
- if (p || (p = !0, a == null || a()), s = n.step(s, i, v), n.isSettled(s, i)) {
86
- if (h += Math.min(v, 0.033), h >= $) {
87
- s = { position: i, velocity: 0 }, u = !1, o(s.position), _.unsubscribe(w), c();
82
+ let a = { position: t, velocity: r }, m = !0, y = 0, S = !1;
83
+ const C = (A) => {
84
+ if (m) {
85
+ if (S || (S = !0, f == null || f()), a = n.step(a, i, A), n.isSettled(a, i)) {
86
+ if (y += Math.min(A, 0.033), y >= K) {
87
+ a = { position: i, velocity: 0 }, m = !1, o(a.position), N.unsubscribe(C), l();
88
88
  return;
89
89
  }
90
90
  } else
91
- h = 0;
92
- o(s.position);
91
+ y = 0;
92
+ o(a.position);
93
93
  }
94
94
  };
95
- return _.subscribe(w), {
95
+ return N.subscribe(C), {
96
96
  stop: () => {
97
- u && (u = !1, _.unsubscribe(w));
97
+ m && (m = !1, N.unsubscribe(C));
98
98
  },
99
- getPosition: () => s.position,
100
- getVelocity: () => s.velocity,
101
- isRunning: () => u
99
+ getPosition: () => a.position,
100
+ getVelocity: () => a.velocity,
101
+ isRunning: () => m
102
102
  };
103
103
  }
104
- const M = 1e3 / 60;
105
- function st(e, n, t, i = 0) {
106
- let o = { position: n, velocity: i }, c = 0;
107
- const a = [];
108
- for (let s = 0; s < 600; s++) {
109
- const u = s * M;
110
- if (a.push({
111
- time: u,
104
+ const O = 1e3 / 60;
105
+ function at(e, n, t, i = 0) {
106
+ let o = { position: n, velocity: i }, l = 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
- }), o = e.step(o, t, M / 1e3), e.isSettled(o, t)) {
115
- if (c += M / 1e3, c >= $) {
116
- a.push({
117
- time: (s + 1) * M,
114
+ }), o = e.step(o, t, O / 1e3), e.isSettled(o, t)) {
115
+ if (l += O / 1e3, l >= 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
- c = 0;
124
+ l = 0;
125
125
  }
126
- return a;
126
+ return f;
127
127
  }
128
- function Y(e, n) {
128
+ function j(e, n) {
129
129
  if (e.length === 0)
130
130
  return { position: 0, velocity: 0 };
131
131
  const t = e[0], i = e[e.length - 1];
@@ -135,105 +135,115 @@ function Y(e, n) {
135
135
  return { position: i.position, velocity: i.velocity };
136
136
  let r = 0, o = e.length - 1;
137
137
  for (; r < o - 1; ) {
138
- const u = Math.floor((r + o) / 2);
139
- e[u].time <= n ? r = u : o = u;
138
+ const m = Math.floor((r + o) / 2);
139
+ e[m].time <= n ? r = m : o = m;
140
140
  }
141
- const c = e[r], a = e[o], s = (n - c.time) / (a.time - c.time);
141
+ const l = e[r], f = e[o], a = (n - l.time) / (f.time - l.time);
142
142
  return {
143
- position: c.position + (a.position - c.position) * s,
144
- velocity: c.velocity + (a.velocity - c.velocity) * s
143
+ position: l.position + (f.position - l.position) * a,
144
+ velocity: l.velocity + (f.velocity - l.velocity) * a
145
145
  };
146
146
  }
147
- function at(e, n) {
147
+ function ct(e, n) {
148
148
  return e.map((t) => n(t.position));
149
149
  }
150
- function ct(e) {
150
+ function lt(e) {
151
151
  const {
152
152
  integrator: n,
153
153
  element: t,
154
154
  from: i,
155
155
  to: r,
156
156
  velocity: o = 0,
157
- style: c,
158
- onComplete: a,
159
- onStart: s
160
- } = e, u = st(n, i, r, o);
161
- if (u.length === 0)
162
- return s == null || s(), a(), {
157
+ style: l,
158
+ onComplete: f,
159
+ onStart: a
160
+ } = e, m = at(n, i, 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 h = at(u, c), p = u[u.length - 1], w = p.time, v = h[0];
170
- if (v)
171
- for (const y of Object.keys(v))
172
- t.style[y] = "";
173
- const d = t.animate(h, {
174
- duration: w,
169
+ const y = ct(m, l), S = m[m.length - 1], C = S.time, A = y[0];
170
+ if (A)
171
+ for (const h of Object.keys(A))
172
+ t.style[h] = "";
173
+ const c = t.animate(y, {
174
+ duration: C,
175
175
  fill: "forwards",
176
176
  easing: "linear",
177
177
  composite: "replace"
178
178
  });
179
- let l = !0;
180
- const C = performance.now();
181
- return s == null || s(), d.onfinish = () => {
182
- l && (l = !1, a());
179
+ let s = !0;
180
+ const g = performance.now();
181
+ return a == null || a(), c.onfinish = () => {
182
+ s && (s = !1, f());
183
183
  }, {
184
184
  stop: () => {
185
- l && (l = !1, d.cancel());
185
+ s && (s = !1, c.cancel());
186
186
  },
187
187
  getPosition: () => {
188
- if (!l)
189
- return p.position;
190
- const y = performance.now() - C;
191
- return Y(u, y).position;
188
+ if (!s)
189
+ return S.position;
190
+ const h = performance.now() - g;
191
+ return j(m, h).position;
192
192
  },
193
193
  getVelocity: () => {
194
- if (!l)
194
+ if (!s)
195
195
  return 0;
196
- const y = performance.now() - C;
197
- return Y(u, y).velocity;
196
+ const h = performance.now() - g;
197
+ return j(m, h).velocity;
198
+ },
199
+ isRunning: () => s
200
+ };
201
+ }
202
+ function ut(e) {
203
+ const { to: n, onStart: t, onComplete: i } = e;
204
+ return t == null || t(), i(), {
205
+ stop: () => {
198
206
  },
199
- isRunning: () => l
207
+ getPosition: () => n,
208
+ getVelocity: () => 0,
209
+ isRunning: () => !1
200
210
  };
201
211
  }
202
- class lt {
212
+ class ft {
203
213
  /**
204
214
  * Get bound runner based on animation mode
205
215
  *
206
216
  * @param options Animation mode options (tick or css)
207
- * @returns Bound runner function or null if no animation mode specified
217
+ * @returns Bound runner function (empty runner if no animation mode specified)
208
218
  * @throws Error if both tick and css are provided
209
219
  */
210
220
  static from(n) {
211
221
  const { tick: t, css: i } = n;
212
222
  if (t && i)
213
223
  throw new Error("Cannot use both 'tick' and 'css' options together");
214
- return i ? (r) => ct({
224
+ return i ? (r) => lt({
215
225
  ...r,
216
226
  element: i.element,
217
227
  style: i.style
218
- }) : t ? (r) => ot({
228
+ }) : t ? (r) => st({
219
229
  ...r,
220
230
  onUpdate: t
221
- }) : null;
231
+ }) : ut;
222
232
  }
223
233
  }
224
- class K {
234
+ class B {
225
235
  }
226
- const ut = { stiffness: 300, damping: 30 };
227
- class j extends K {
236
+ const mt = { stiffness: 300, damping: 30 };
237
+ class W extends B {
228
238
  constructor(t) {
229
239
  super();
230
- m(this, "options");
231
- m(this, "runner");
232
- m(this, "controls", null);
233
- m(this, "isAnimating", !1);
234
- m(this, "currentValue");
235
- m(this, "currentVelocity", 0);
236
- m(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");
237
247
  if (this.options = {
238
248
  from: t.from ?? 0,
239
249
  to: t.to ?? 1,
@@ -249,14 +259,14 @@ class j extends K {
249
259
  else if (t.css) {
250
260
  const { element: i, style: r } = t.css;
251
261
  this.updateFn = (o) => {
252
- const c = r(o);
253
- for (const [a, s] of Object.entries(c))
254
- i.style[a] = typeof s == "number" ? String(s) : s;
262
+ const l = r(o);
263
+ for (const [f, a] of Object.entries(l))
264
+ i.style[f] = typeof a == "number" ? String(a) : a;
255
265
  };
256
266
  } else
257
267
  this.updateFn = () => {
258
268
  };
259
- this.runner = lt.from({
269
+ this.runner = ft.from({
260
270
  tick: t.tick,
261
271
  css: t.css
262
272
  });
@@ -275,18 +285,13 @@ class j extends K {
275
285
  */
276
286
  createIntegrator() {
277
287
  const t = this.options.physics;
278
- return t != null && t.integrator ? t.integrator() : t != null && t.spring || t != null && t.inertia ? it.from({
288
+ return t != null && t.integrator ? t.integrator() : t != null && t.spring || t != null && t.inertia ? nt.from({
279
289
  spring: t.spring,
280
290
  inertia: t.inertia
281
- }) : new nt(ut);
291
+ }) : new rt(mt);
282
292
  }
283
293
  runAnimation(t) {
284
- var i, r;
285
- if (this.isAnimating = !0, !this.runner) {
286
- (r = (i = this.options).onStart) == null || r.call(i), this.currentValue = t, this.currentVelocity = 0, this.isAnimating = !1, this.options.onComplete();
287
- return;
288
- }
289
- this.controls = this.runner({
294
+ this.isAnimating = !0, this.controls = this.runner({
290
295
  integrator: this.createIntegrator(),
291
296
  from: this.currentValue,
292
297
  to: t,
@@ -339,20 +344,20 @@ class j extends K {
339
344
  this.options = { ...this.options, ...t };
340
345
  }
341
346
  }
342
- class L extends K {
347
+ class z extends B {
343
348
  constructor(t) {
344
349
  super();
345
- m(this, "config");
346
- m(this, "animators", /* @__PURE__ */ new Map());
347
- m(this, "itemOrder", []);
348
- m(this, "completedCount", 0);
349
- m(this, "completedAnimators", /* @__PURE__ */ new Set());
350
- m(this, "direction", "forward");
351
- m(this, "idCounter", 0);
352
- m(this, "rafId", null);
353
- m(this, "from");
354
- m(this, "to");
355
- m(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");
356
361
  this.config = t.config, this.from = t.from, this.to = t.to, this.initialState = t.state ?? {
357
362
  position: t.from,
358
363
  velocity: 0
@@ -363,7 +368,7 @@ class L extends K {
363
368
  }
364
369
  initializeAnimators() {
365
370
  this.config.items.forEach((t, i) => {
366
- const r = this.generateId(), o = new j({
371
+ const r = this.generateId(), o = new W({
367
372
  from: this.from,
368
373
  to: this.to,
369
374
  physics: t.physics,
@@ -397,9 +402,9 @@ class L extends K {
397
402
  return this.direction === "forward" ? this.itemOrder : [...this.itemOrder].reverse();
398
403
  }
399
404
  onAnimatorComplete(t) {
400
- var r, o, c, a, s, u;
405
+ var r, o, l, f, a, m;
401
406
  const i = this.animators.get(t);
402
- !i || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (o = (r = i.item).onComplete) == null || o.call(r), (a = (c = this.config).onProgress) == null || a.call(c, this.completedCount, this.config.items.length), this.completedCount === this.config.items.length && (this.stopScheduler(), (u = (s = this.config).onEnd) == null || u.call(s)));
407
+ !i || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (o = (r = i.item).onComplete) == null || o.call(r), (f = (l = this.config).onProgress) == null || f.call(l, this.completedCount, this.config.items.length), this.completedCount === this.config.items.length && (this.stopScheduler(), (m = (a = this.config).onEnd) == null || m.call(a)));
403
408
  }
404
409
  /**
405
410
  * Check and start springs based on previous spring's progress
@@ -414,10 +419,10 @@ class L extends K {
414
419
  this.startAnimator(r);
415
420
  continue;
416
421
  }
417
- const c = t[i - 1], a = this.animators.get(c);
418
- if (!a || !a.started) continue;
419
- const s = this.getAnimatorProgress(a), u = o.item.normalizedOffset;
420
- s >= u && this.startAnimator(r);
422
+ const l = t[i - 1], f = this.animators.get(l);
423
+ if (!f || !f.started) continue;
424
+ const a = this.getAnimatorProgress(f), m = o.item.normalizedOffset;
425
+ a >= m && this.startAnimator(r);
421
426
  }
422
427
  }
423
428
  startAnimator(t) {
@@ -465,7 +470,7 @@ class L extends K {
465
470
  return;
466
471
  const i = t.animator.getCurrentState();
467
472
  if (i.position === i.to) {
468
- const o = new j({
473
+ const o = new W({
469
474
  from: this.to,
470
475
  to: this.from,
471
476
  physics: t.item.physics,
@@ -532,10 +537,10 @@ class L extends K {
532
537
  * Uses first animator's state for initialization
533
538
  */
534
539
  static fromState(t, i) {
535
- return new L({ ...i, state: t });
540
+ return new z({ ...i, state: t });
536
541
  }
537
542
  }
538
- const B = Symbol.for("TRANSITION_STRATEGY"), ft = (e) => ({
543
+ const J = Symbol.for("TRANSITION_STRATEGY"), dt = (e) => ({
539
544
  runIn: async (n) => {
540
545
  const { currentAnimation: t } = e;
541
546
  if (t && t.direction === "out") {
@@ -602,7 +607,7 @@ const B = Symbol.for("TRANSITION_STRATEGY"), ft = (e) => ({
602
607
  direction: "forward"
603
608
  };
604
609
  }
605
- }), mt = () => ({
610
+ }), ht = () => ({
606
611
  runIn: async (e) => e.in ? {
607
612
  config: await e.in,
608
613
  state: {
@@ -639,25 +644,25 @@ const B = Symbol.for("TRANSITION_STRATEGY"), ft = (e) => ({
639
644
  to: 0,
640
645
  direction: "forward"
641
646
  }
642
- }), J = "data-ssgoi-scope", Q = "data-ssgoi-scope-ready";
643
- function It() {
647
+ }), Q = "data-ssgoi-scope", Z = "data-ssgoi-scope-ready";
648
+ function xt() {
644
649
  return (e) => {
645
650
  if (e)
646
- return e.setAttribute(J, ""), queueMicrotask(() => {
651
+ return e.setAttribute(Q, ""), queueMicrotask(() => {
647
652
  queueMicrotask(() => {
648
- e.setAttribute(Q, "true");
653
+ e.setAttribute(Z, "true");
649
654
  });
650
655
  }), () => {
651
656
  };
652
657
  };
653
658
  }
654
- function dt(e) {
655
- return e.hasAttribute(Q);
659
+ function gt(e) {
660
+ return e.hasAttribute(Z);
656
661
  }
657
- function ht(e) {
658
- return e.closest(`[${J}]`);
662
+ function pt(e) {
663
+ return e.closest(`[${Q}]`);
659
664
  }
660
- const gt = (e) => {
665
+ const wt = (e) => {
661
666
  let n = e.parentElement;
662
667
  for (; n && n !== document.body; ) {
663
668
  const t = window.getComputedStyle(n), i = t.overflow + t.overflowY + t.overflowX;
@@ -666,7 +671,7 @@ const gt = (e) => {
666
671
  n = n.parentElement;
667
672
  }
668
673
  return document.documentElement;
669
- }, pt = (e) => {
674
+ }, yt = (e) => {
670
675
  let n = e.parentElement;
671
676
  for (; n && n !== document.body; ) {
672
677
  const t = window.getComputedStyle(n).position;
@@ -676,7 +681,7 @@ const gt = (e) => {
676
681
  }
677
682
  return document.body;
678
683
  };
679
- function W(e) {
684
+ function G(e) {
680
685
  return new Promise((n) => {
681
686
  requestAnimationFrame(() => {
682
687
  requestAnimationFrame(() => {
@@ -685,123 +690,123 @@ function W(e) {
685
690
  });
686
691
  });
687
692
  }
688
- function wt(e, n) {
689
- var v;
693
+ function vt(e, n) {
694
+ var A;
690
695
  let t = null, i = null, r = null, o = null;
691
- const c = {
696
+ const l = {
692
697
  get currentAnimation() {
693
698
  return t;
694
699
  }
695
- }, a = ((v = n == null ? void 0 : n.strategy) == null ? void 0 : v.call(n, c)) || ft(c), s = async (d) => {
696
- var b;
700
+ }, f = ((A = n == null ? void 0 : n.strategy) == null ? void 0 : A.call(n, l)) || dt(l), a = async (c) => {
701
+ var R, P;
697
702
  i && (i.remove(), i = null);
698
- const l = e(), C = l.in && l.in(d), y = !(n != null && n.strategy) && l.out ? l.out(d) : void 0;
699
- if (!C)
703
+ const s = e(), g = s.in && s.in(c), h = !(n != null && n.strategy) && s.out ? s.out(c) : void 0;
704
+ if (!g)
700
705
  return;
701
- const P = {
702
- in: F(C),
703
- out: y ? F(y) : void 0
704
- }, g = await a.runIn(P);
705
- if (!g.config) {
706
+ const T = {
707
+ in: M(g),
708
+ out: h ? M(h) : void 0
709
+ }, p = await f.runIn(T);
710
+ if (!p.config) {
706
711
  t && (t.direction = "in");
707
712
  return;
708
713
  }
709
- const f = g.config;
710
- (b = f.prepare) == null || b.call(f);
711
- const S = X(
714
+ const u = p.config;
715
+ (R = u.prepare) == null || R.call(u);
716
+ const v = H(
712
717
  {
713
- ...f,
718
+ ...u,
714
719
  onEnd: () => {
715
720
  var k;
716
- t = null, (k = f.onEnd) == null || k.call(f);
721
+ t = null, (k = u.onEnd) == null || k.call(u);
717
722
  }
718
723
  },
719
- d
724
+ c
720
725
  );
721
- f.wait && await f.wait();
722
- const A = L.fromState(g.state, {
723
- config: S,
724
- from: g.from,
725
- to: g.to
726
+ u.wait && await u.wait();
727
+ const w = z.fromState(p.state, {
728
+ config: v,
729
+ from: p.from,
730
+ to: p.to
726
731
  });
727
- t = { controller: A, direction: "in" }, await W(), g.direction === "forward" ? A.forward() : A.backward();
728
- }, u = async (d) => {
729
- var k;
730
- i = d;
731
- const l = e(), C = !(n != null && n.strategy) && l.in ? l.in(d) : void 0, y = l.out && l.out(d);
732
- if (!y)
732
+ t = { controller: w, direction: "in" }, (P = u.onReady) == null || P.call(u), await G(), p.direction === "forward" ? w.forward() : w.backward();
733
+ }, m = async (c) => {
734
+ var P, k;
735
+ i = c;
736
+ const s = e(), g = !(n != null && n.strategy) && s.in ? s.in(c) : void 0, h = s.out && s.out(c);
737
+ if (!h)
733
738
  return;
734
- const P = {
735
- in: C ? F(C) : void 0,
736
- out: F(y)
737
- }, g = await a.runOut(P);
738
- if (!g.config) {
739
+ const T = {
740
+ in: g ? M(g) : void 0,
741
+ out: M(h)
742
+ }, p = await f.runOut(T);
743
+ if (!p.config) {
739
744
  t && (t.direction = "out"), i && (i.remove(), i = null);
740
745
  return;
741
746
  }
742
- const f = g.config;
743
- b(), (k = f.prepare) == null || k.call(f);
744
- const S = X(
747
+ const u = p.config;
748
+ R(), (P = u.prepare) == null || P.call(u);
749
+ const v = H(
745
750
  {
746
- ...f,
751
+ ...u,
747
752
  onEnd: () => {
748
- var V, R;
749
- (V = f.onEnd) == null || V.call(f), i && (i.remove(), i = null), t = null, (R = n == null ? void 0 : n.onCleanupEnd) == null || R.call(n);
753
+ var V, F;
754
+ (V = u.onEnd) == null || V.call(u), i && (i.remove(), i = null), t = null, (F = n == null ? void 0 : n.onCleanupEnd) == null || F.call(n);
750
755
  }
751
756
  },
752
- d
757
+ c
753
758
  );
754
- f.wait && await f.wait();
755
- const A = L.fromState(g.state, {
756
- config: S,
757
- from: g.from,
758
- to: g.to
759
+ u.wait && await u.wait();
760
+ const w = z.fromState(p.state, {
761
+ config: v,
762
+ from: p.from,
763
+ to: p.to
759
764
  });
760
- t = { controller: A, direction: "out" }, await W(), g.direction === "forward" ? A.forward() : A.backward();
761
- function b() {
765
+ t = { controller: w, direction: "out" }, (k = u.onReady) == null || k.call(u), await G(), p.direction === "forward" ? w.forward() : w.backward();
766
+ function R() {
762
767
  !r || !i || (o && r.contains(o) ? r.insertBefore(i, o) : r.appendChild(i));
763
768
  }
764
769
  };
765
- let h = null, p = !1;
766
- const w = (d) => () => {
767
- if (p) return;
768
- p = !0;
769
- const l = d.cloneNode(!0);
770
- h ? queueMicrotask(() => {
771
- document.contains(h) && u(l);
772
- }) : u(l);
770
+ let y = null, S = !1;
771
+ const C = (c) => () => {
772
+ if (S) return;
773
+ S = !0;
774
+ const s = c.cloneNode(!0);
775
+ y ? queueMicrotask(() => {
776
+ document.contains(y) && m(s);
777
+ }) : m(s);
773
778
  };
774
- return (d) => {
775
- if (d)
779
+ return (c) => {
780
+ if (c)
776
781
  return requestAnimationFrame(() => {
777
- r = d.parentElement, o = d.nextElementSibling;
778
- }), p = !1, (n == null ? void 0 : n.scope) === "local" ? queueMicrotask(() => {
779
- h = ht(d), !(h && !dt(h)) && s(d);
780
- }) : s(d), w(d);
782
+ r = c.parentElement, o = c.nextElementSibling;
783
+ }), S = !1, (n == null ? void 0 : n.scope) === "local" ? queueMicrotask(() => {
784
+ y = pt(c), !(y && !gt(y)) && a(c);
785
+ }) : a(c), C(c);
781
786
  };
782
787
  }
783
- const T = /* @__PURE__ */ new Map();
784
- let E = null, N = !1;
785
- function Z(e) {
786
- if (e instanceof HTMLElement && T.has(e)) {
787
- const t = T.get(e);
788
- T.delete(e), queueMicrotask(() => {
788
+ const b = /* @__PURE__ */ new Map();
789
+ let E = null, U = !1;
790
+ function tt(e) {
791
+ if (e instanceof HTMLElement && b.has(e)) {
792
+ const t = b.get(e);
793
+ b.delete(e), queueMicrotask(() => {
789
794
  t();
790
795
  });
791
796
  }
792
797
  const n = e.childNodes;
793
798
  for (let t = 0; t < n.length; t++) {
794
799
  const i = n[t];
795
- i && Z(i);
800
+ i && tt(i);
796
801
  }
797
802
  }
798
- function yt() {
799
- N || typeof document > "u" || (N = !0, E = new MutationObserver((e) => {
803
+ function St() {
804
+ U || typeof document > "u" || (U = !0, E = new MutationObserver((e) => {
800
805
  for (const n of e) {
801
806
  const t = n.removedNodes;
802
807
  for (let i = 0; i < t.length; i++) {
803
808
  const r = t[i];
804
- r && Z(r);
809
+ r && tt(r);
805
810
  }
806
811
  }
807
812
  }), document.body ? E.observe(document.body, {
@@ -818,69 +823,69 @@ function yt() {
818
823
  { once: !0 }
819
824
  ));
820
825
  }
821
- function vt(e, n) {
822
- yt(), T.set(e, n);
826
+ function Ct(e, n) {
827
+ St(), b.set(e, n);
823
828
  }
824
- function Ft(e) {
825
- return T.has(e);
829
+ function Mt(e) {
830
+ return b.has(e);
826
831
  }
827
- function Mt() {
828
- return T.size;
832
+ function Ot() {
833
+ return b.size;
829
834
  }
830
- function xt(e) {
831
- const n = T.get(e);
832
- return n ? (T.delete(e), n(), !0) : !1;
835
+ function Lt(e) {
836
+ const n = b.get(e);
837
+ return n ? (b.delete(e), n(), !0) : !1;
833
838
  }
834
- function Ot() {
835
- T.clear(), E == null || E.disconnect(), E = null, N = !1;
839
+ function Dt() {
840
+ b.clear(), E == null || E.disconnect(), E = null, U = !1;
836
841
  }
837
- const O = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map();
838
- function St(e, n, t) {
839
- O.set(e, n);
840
- let i = U.get(e);
842
+ const D = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
843
+ function At(e, n, t) {
844
+ D.set(e, n);
845
+ let i = X.get(e);
841
846
  if (i)
842
847
  return i;
843
848
  const r = n;
844
- return i = wt(
849
+ return i = vt(
845
850
  () => {
846
- const o = O.get(e);
851
+ const o = D.get(e);
847
852
  return o || (console.warn(`Transition "${String(e)}" not found`), {});
848
853
  },
849
854
  {
850
855
  strategy: t == null ? void 0 : t.strategy,
851
856
  scope: t == null ? void 0 : t.scope,
852
857
  onCleanupEnd: () => {
853
- O.get(e) === r && Ct(e);
858
+ D.get(e) === r && Tt(e);
854
859
  }
855
860
  }
856
- ), U.set(e, i), i;
861
+ ), X.set(e, i), i;
857
862
  }
858
- function Ct(e) {
859
- O.delete(e), U.delete(e), H.delete(e);
863
+ function Tt(e) {
864
+ D.delete(e), X.delete(e), Y.delete(e);
860
865
  }
861
- function Lt(e, n = "manual") {
862
- const t = St(
866
+ function zt(e, n = "manual") {
867
+ const t = At(
863
868
  e.key,
864
869
  {
865
870
  in: e.in,
866
871
  out: e.out
867
872
  },
868
873
  {
869
- strategy: e[B],
874
+ strategy: e[J],
870
875
  scope: e.scope
871
876
  }
872
877
  );
873
878
  if (n === "manual")
874
879
  return t;
875
- let i = H.get(e.key);
880
+ let i = Y.get(e.key);
876
881
  return i || (i = (r) => {
877
882
  if (r) {
878
883
  const o = t(r);
879
- o && vt(r, o);
884
+ o && Ct(r, o);
880
885
  }
881
- }, H.set(e.key, i), i);
886
+ }, Y.set(e.key, i), i);
882
887
  }
883
- function At(e) {
888
+ function Et(e) {
884
889
  const n = e.filter((t) => t.symmetric).map((t) => ({
885
890
  from: t.to,
886
891
  to: t.from,
@@ -888,64 +893,89 @@ function At(e) {
888
893
  }));
889
894
  return [...e, ...n];
890
895
  }
891
- function Et(e) {
896
+ function bt(e) {
892
897
  let n = !1, t = 0, i = 0, r = !1;
893
- const o = 50, c = (d) => {
898
+ const o = 50, l = (c) => {
894
899
  if (!e) return;
895
- const l = d.touches[0];
896
- l && (r = l.clientX < o, r && (t = l.clientX, i = l.clientY));
897
- }, a = (d) => {
900
+ const s = c.touches[0];
901
+ s && (r = s.clientX < o, r && (t = s.clientX, i = s.clientY));
902
+ }, f = (c) => {
898
903
  if (!e || !r) return;
899
- const l = d.touches[0];
900
- if (!l) return;
901
- const C = l.clientX - t, y = l.clientY - i;
902
- C > window.outerWidth / 2 - 5 && Math.abs(C) > Math.abs(y) ? n = !0 : n = !1;
903
- }, s = () => {
904
+ const s = c.touches[0];
905
+ if (!s) return;
906
+ const g = s.clientX - t, h = s.clientY - i;
907
+ g > window.outerWidth / 2 - 5 && Math.abs(g) > Math.abs(h) ? n = !0 : n = !1;
908
+ }, a = () => {
904
909
  e && (r = !1, t = 0, i = 0);
905
- }, u = () => n, h = () => {
906
- typeof window > "u" || e && (window.addEventListener("touchstart", c, { passive: !0 }), window.addEventListener("touchmove", a, { passive: !0 }), window.addEventListener("touchend", s, { passive: !0 }));
907
- }, p = () => {
908
- typeof window > "u" || (window.removeEventListener("touchstart", c), window.removeEventListener("touchmove", a), window.removeEventListener("touchend", s));
910
+ }, m = () => n, y = () => {
911
+ typeof window > "u" || e && (window.addEventListener("touchstart", l, { passive: !0 }), window.addEventListener("touchmove", f, { passive: !0 }), window.addEventListener("touchend", a, { passive: !0 }));
912
+ }, S = () => {
913
+ typeof window > "u" || (window.removeEventListener("touchstart", l), window.removeEventListener("touchmove", f), window.removeEventListener("touchend", a));
909
914
  };
910
- let w = 0;
915
+ let C = 0;
911
916
  return {
912
- initialize: h,
913
- cleanup: p,
914
- isSwipePending: u,
917
+ initialize: y,
918
+ cleanup: S,
919
+ isSwipePending: m,
915
920
  resetSwipeDetection: () => {
916
- w++, w > 1 && (w = 0, n = !1);
921
+ requestAnimationFrame(() => {
922
+ C++, C > 1 && (C = 0, n = !1);
923
+ });
917
924
  }
918
925
  };
919
926
  }
920
- function Tt() {
921
- let e = null, n = null;
922
- const t = /* @__PURE__ */ new Map();
923
- let i = null;
924
- const r = () => {
925
- e && i && t.set(i, {
926
- x: e.scrollLeft,
927
- y: e.scrollTop
927
+ function Rt(e = {}) {
928
+ const { preserveScroll: n = !1 } = e;
929
+ let t = null, i = null;
930
+ const r = /* @__PURE__ */ new Map();
931
+ let o = null, l = !1;
932
+ const f = () => {
933
+ t && o && !l && r.set(o, {
934
+ x: t.scrollLeft,
935
+ y: t.scrollTop
928
936
  });
937
+ }, a = (c) => {
938
+ if (!t || !n) return;
939
+ const s = r.get(c);
940
+ if (!s) return;
941
+ const g = 10;
942
+ let h = 0;
943
+ const T = () => {
944
+ if (!t) return;
945
+ t.scrollTo({
946
+ top: s.y,
947
+ left: s.x
948
+ });
949
+ const p = t.scrollTop, u = t.scrollLeft;
950
+ !(Math.abs(p - s.y) < 1 && Math.abs(u - s.x) < 1) && h < g && (h++, requestAnimationFrame(T));
951
+ };
952
+ requestAnimationFrame(T);
929
953
  };
930
954
  return {
931
- initializeContext: (h, p) => {
932
- n = h, e || (e = gt(h), (e === document.documentElement ? window : e).addEventListener("scroll", r, {
955
+ initializeContext: (c, s) => {
956
+ l = !0, i = c, t || (t = wt(c), (t === document.documentElement ? window : t).addEventListener("scroll", f, {
933
957
  passive: !0
934
- })), i = p;
958
+ })), o = s, n && t && (r.get(s) ? a(s) : t.scrollTo({ top: 0, left: 0 }));
959
+ const g = 10;
960
+ let h = 0;
961
+ const T = () => {
962
+ h++, h >= g ? l = !1 : requestAnimationFrame(T);
963
+ };
964
+ requestAnimationFrame(T);
935
965
  },
936
- calculateScrollOffset: (h, p) => {
937
- const w = h && t.has(h) ? t.get(h) : { x: 0, y: 0 }, v = p && t.has(p) ? t.get(p) : { x: 0, y: 0 };
966
+ calculateScrollOffset: (c, s) => {
967
+ const g = c && r.has(c) ? r.get(c) : { x: 0, y: 0 }, h = s && r.has(s) ? r.get(s) : { x: 0, y: 0 };
938
968
  return {
939
- x: -v.x + w.x,
940
- y: -v.y + w.y
969
+ x: -h.x + g.x,
970
+ y: -h.y + g.y
941
971
  };
942
972
  },
943
- getScrollContainer: () => e,
944
- getPositionedParentElement: () => n ? pt(n) : document.body,
945
- getScrollPosition: (h) => h && t.has(h) ? t.get(h) : { x: 0, y: 0 }
973
+ getScrollContainer: () => t,
974
+ getPositionedParentElement: () => i ? yt(i) : document.body,
975
+ getScrollPosition: (c) => c && r.has(c) ? r.get(c) : { x: 0, y: 0 }
946
976
  };
947
977
  }
948
- function x(e, n) {
978
+ function L(e, n) {
949
979
  if (n === "*")
950
980
  return !0;
951
981
  if (n.endsWith("/*")) {
@@ -954,16 +984,16 @@ function x(e, n) {
954
984
  }
955
985
  return e === n;
956
986
  }
957
- function G(e, n, t) {
987
+ function $(e, n, t) {
958
988
  for (const i of t)
959
- if (x(e, i.from) && x(n, i.to))
989
+ if (L(e, i.from) && L(n, i.to))
960
990
  return i.transition;
961
991
  for (const i of t)
962
- if ((i.from === "*" || x(e, i.from)) && (i.to === "*" || x(n, i.to)))
992
+ if ((i.from === "*" || L(e, i.from)) && (i.to === "*" || L(n, i.to)))
963
993
  return i.transition;
964
994
  return null;
965
995
  }
966
- function bt() {
996
+ function Pt() {
967
997
  let e = null;
968
998
  function n() {
969
999
  if (e != null && e.from && (e != null && e.to) && (e != null && e.outResolve) && (e != null && e.inResolve)) {
@@ -1005,111 +1035,119 @@ function kt() {
1005
1035
  }
1006
1036
  };
1007
1037
  }
1008
- function Dt(e, n) {
1038
+ function qt(e, n) {
1009
1039
  const {
1010
1040
  transitions: t = [],
1011
1041
  defaultTransition: i,
1012
- middleware: r = (g, f) => ({ from: g, to: f }),
1042
+ middleware: r = (u, v) => ({ from: u, to: v }),
1013
1043
  // Identity function as default
1014
- skipOnIosSwipe: o = !0
1044
+ skipOnIosSwipe: o = !0,
1015
1045
  // Default to true - skip animations on iOS swipe
1016
- } = e, { outFirst: c = !0, createNavigationDetector: a } = n || {}, s = (a == null ? void 0 : a()) ?? (c ? bt() : kt()), u = At(t), {
1017
- initializeContext: h,
1018
- calculateScrollOffset: p,
1019
- getScrollContainer: w,
1020
- getPositionedParentElement: v,
1021
- getScrollPosition: d
1022
- } = Tt(), l = Et(o);
1023
- l.initialize();
1024
- const C = async (g, f) => {
1025
- if (l.isSwipePending())
1026
- return l.resetSwipeDetection(), () => ({});
1027
- s.trigger(g, f);
1028
- const S = await s.get(f);
1029
- if (!S) return () => ({});
1030
- const { from: A, to: b } = r(
1031
- S.from,
1032
- S.to
1033
- ), V = G(
1034
- A,
1035
- b,
1036
- u
1046
+ experimentalPreserveScroll: l = !1
1047
+ // Default to false - manual scroll management
1048
+ } = e, { outFirst: f = !0, createNavigationDetector: a } = n || {}, m = (a == null ? void 0 : a()) ?? (f ? Pt() : kt()), y = Et(t), {
1049
+ initializeContext: S,
1050
+ calculateScrollOffset: C,
1051
+ getScrollContainer: A,
1052
+ getPositionedParentElement: c,
1053
+ getScrollPosition: s
1054
+ } = Rt({ preserveScroll: l }), g = bt(o);
1055
+ g.initialize();
1056
+ const h = async (u, v) => {
1057
+ if (g.isSwipePending())
1058
+ return g.resetSwipeDetection(), v === "in" ? async (I) => ({
1059
+ onReady: () => {
1060
+ I.style.visibility = "visible";
1061
+ }
1062
+ }) : () => ({});
1063
+ m.trigger(u, v);
1064
+ const w = await m.get(v);
1065
+ if (!w) return () => ({});
1066
+ const { from: R, to: P } = r(
1067
+ w.from,
1068
+ w.to
1069
+ ), V = $(
1070
+ R,
1071
+ P,
1072
+ y
1037
1073
  ) || i;
1038
1074
  if (!V) return () => ({});
1039
- const R = p(S.from, S.to);
1040
- if (f === "out") {
1041
- const D = {
1042
- scrollOffset: R,
1043
- scroll: d(S.from),
1075
+ const F = C(w.from, w.to);
1076
+ if (v === "out") {
1077
+ const I = {
1078
+ scrollOffset: F,
1079
+ scroll: s(w.from),
1044
1080
  get scrollingElement() {
1045
- return w() || document.documentElement;
1081
+ return A() || document.documentElement;
1046
1082
  },
1047
1083
  get positionedParent() {
1048
- return v();
1084
+ return c();
1049
1085
  }
1050
1086
  };
1051
- return (I) => V.out(I, D);
1087
+ return (x) => V.out(x, I);
1052
1088
  } else {
1053
- const D = {
1054
- scrollOffset: R,
1089
+ const I = {
1090
+ scrollOffset: F,
1055
1091
  get scroll() {
1056
- return d(S.to);
1092
+ return s(w.to);
1057
1093
  },
1058
1094
  get scrollingElement() {
1059
- return w() || document.documentElement;
1095
+ return A() || document.documentElement;
1060
1096
  },
1061
1097
  get positionedParent() {
1062
- return v();
1098
+ return c();
1063
1099
  }
1064
1100
  };
1065
- return async (I) => {
1066
- const z = await Promise.resolve(V.in(I, D)), q = z.onStart;
1067
- return z.onStart = () => {
1068
- I.style.visibility = "visible", q == null || q();
1069
- }, z;
1101
+ return async (x) => {
1102
+ const q = await Promise.resolve(V.in(x, I)), _ = q.onReady;
1103
+ return q.onReady = () => {
1104
+ x.style.visibility = "visible", _ == null || _();
1105
+ }, q;
1070
1106
  };
1071
1107
  }
1072
- }, y = (g) => ({
1073
- key: g,
1074
- in: async (f) => (h(f, g), (await C(g, "in"))(f)),
1075
- out: async (f) => (await C(g, "out"))(f),
1108
+ }, T = (u) => ({
1109
+ key: u,
1110
+ in: async (v) => (S(v, u), (await h(u, "in"))(v)),
1111
+ out: async (v) => (await h(u, "out"))(v),
1076
1112
  // Add page transition strategy for page-level transitions
1077
- [B]: mt
1078
- }), P = (g, f) => {
1079
- const { from: S, to: A } = r(g, f);
1080
- return !!(G(
1081
- S,
1082
- A,
1083
- u
1113
+ [J]: ht
1114
+ }), p = (u, v) => {
1115
+ if (g.isSwipePending())
1116
+ return !1;
1117
+ const { from: w, to: R } = r(u, v);
1118
+ return !!($(
1119
+ w,
1120
+ R,
1121
+ y
1084
1122
  ) || i);
1085
1123
  };
1086
1124
  return a ? {
1087
- getTransition: y,
1088
- hasMatchingTransition: P
1089
- } : y;
1125
+ getTransition: T,
1126
+ hasMatchingTransition: p
1127
+ } : T;
1090
1128
  }
1091
1129
  export {
1092
- J as SCOPE_ATTR,
1093
- Q as SCOPE_READY_ATTR,
1094
- B as TRANSITION_STRATEGY,
1130
+ Q as SCOPE_ATTR,
1131
+ Z as SCOPE_READY_ATTR,
1132
+ J as TRANSITION_STRATEGY,
1095
1133
  kt as createAnyOrderDetector,
1096
- ft as createDefaultStrategy,
1097
- bt as createOutFirstDetector,
1098
- mt as createPageTransitionStrategy,
1099
- Dt as createSggoiTransitionContext,
1100
- It as createTransitionScope,
1101
- ht as findScope,
1102
- Mt as getWatchedCount,
1103
- _t as isCssAnimation,
1104
- Nt as isMultiAnimation,
1105
- dt as isScopeReady,
1106
- Ut as isSingleAnimation,
1134
+ dt as createDefaultStrategy,
1135
+ Pt as createOutFirstDetector,
1136
+ ht as createPageTransitionStrategy,
1137
+ qt as createSggoiTransitionContext,
1138
+ xt as createTransitionScope,
1139
+ pt as findScope,
1140
+ Ot as getWatchedCount,
1141
+ Ut as isCssAnimation,
1142
+ Xt as isMultiAnimation,
1143
+ gt as isScopeReady,
1144
+ Yt as isSingleAnimation,
1107
1145
  Ht as isTickAnimation,
1108
- Ft as isWatched,
1109
- X as normalizeSchedule,
1110
- F as normalizeToMultiAnimation,
1111
- Ot as resetObserver,
1112
- Lt as transition,
1113
- xt as triggerUnmount,
1114
- vt as watchUnmount
1146
+ Mt as isWatched,
1147
+ H as normalizeSchedule,
1148
+ M as normalizeToMultiAnimation,
1149
+ Dt as resetObserver,
1150
+ zt as transition,
1151
+ Lt as triggerUnmount,
1152
+ Ct as watchUnmount
1115
1153
  };