@flemo/core 1.12.0 → 1.13.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.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createStore as e } from "zustand/vanilla";
2
2
  import { compile as t, match as n, parse as r, pathToRegexp as i } from "path-to-regexp";
3
- var a = new class {
3
+ //#region src/core/TaskManger.ts
4
+ var a = 1200, o = new class {
4
5
  tasks = /* @__PURE__ */ new Map();
5
6
  instanceId = Date.now().toString();
6
7
  isLocked = !1;
@@ -8,6 +9,9 @@ var a = new class {
8
9
  taskQueue = Promise.resolve();
9
10
  signalListeners = /* @__PURE__ */ new Map();
10
11
  pendingTaskQueue = [];
12
+ get pendingTaskIds() {
13
+ return this.pendingTaskQueue.map((e) => e.id);
14
+ }
11
15
  isProcessingPending = !1;
12
16
  async acquireLock(e) {
13
17
  for (let t = 0; t < 10; t++) {
@@ -45,16 +49,20 @@ var a = new class {
45
49
  }
46
50
  }
47
51
  }
52
+ pendingWaiters = /* @__PURE__ */ new Set();
53
+ notifyPendingWaiters() {
54
+ for (let e of [...this.pendingWaiters]) e();
55
+ }
48
56
  async waitForPendingTasks() {
49
57
  return new Promise((e) => {
50
- let t = () => {
51
- this.pendingTaskQueue.filter((e) => e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING").length === 0 ? e() : setTimeout(t, 100);
58
+ let t = null, n = () => {
59
+ this.pendingTaskQueue.filter((e) => e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING").length === 0 ? (this.pendingWaiters.delete(n), t && clearTimeout(t), e()) : (t && clearTimeout(t), t = setTimeout(n, 100));
52
60
  };
53
- t();
61
+ this.pendingWaiters.add(n), n();
54
62
  });
55
63
  }
56
64
  async onTaskStatusChange(e, t) {
57
- (t === "COMPLETED" || t === "FAILED" || t === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((t) => t.id !== e), await this.processPendingTasks());
65
+ (t === "COMPLETED" || t === "FAILED" || t === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((t) => t.id !== e), await this.processPendingTasks(), this.notifyPendingWaiters());
58
66
  }
59
67
  async addTask(e, t = {}) {
60
68
  let n = t.id || this.generateTaskId();
@@ -103,7 +111,7 @@ var a = new class {
103
111
  resolve: r,
104
112
  reject: i,
105
113
  result: e
106
- }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
114
+ }, this.pendingTaskQueue.push(d), this.armBackstop(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
107
115
  return;
108
116
  }
109
117
  if (n.signal) {
@@ -111,7 +119,7 @@ var a = new class {
111
119
  resolve: r,
112
120
  reject: i,
113
121
  result: e
114
- }, this.signalListeners.has(n.signal) || this.signalListeners.set(n.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(n.signal).add(d.id), this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "SIGNAL_PENDING");
122
+ }, this.signalListeners.has(n.signal) || this.signalListeners.set(n.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(n.signal).add(d.id), this.pendingTaskQueue.push(d), this.armBackstop(d), await this.onTaskStatusChange(d.id, "SIGNAL_PENDING");
115
123
  return;
116
124
  }
117
125
  if (n.condition && !await n.condition()) {
@@ -119,7 +127,7 @@ var a = new class {
119
127
  resolve: r,
120
128
  reject: i,
121
129
  result: e
122
- }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
130
+ }, this.pendingTaskQueue.push(d), this.armBackstop(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
123
131
  return;
124
132
  }
125
133
  }
@@ -147,9 +155,15 @@ var a = new class {
147
155
  }).catch(i);
148
156
  });
149
157
  }
158
+ armBackstop(e) {
159
+ let t = e.control?.maxLifetimeMs;
160
+ !t || t <= 0 || typeof setTimeout > "u" || (e.backstopTimer = setTimeout(() => {
161
+ delete e.backstopTimer, this.resolveTask(e.id);
162
+ }, t));
163
+ }
150
164
  async resolveTask(e) {
151
165
  let t = this.tasks.get(e);
152
- if (!t || t.status !== "MANUAL_PENDING" && t.status !== "SIGNAL_PENDING") return !1;
166
+ if (t?.backstopTimer && (clearTimeout(t.backstopTimer), delete t.backstopTimer), !t || t.status !== "MANUAL_PENDING" && t.status !== "SIGNAL_PENDING") return !1;
153
167
  if (t.manualResolver) {
154
168
  if (t.control?.condition && !await t.control.condition()) return !1;
155
169
  t.status = "COMPLETED";
@@ -175,7 +189,7 @@ var a = new class {
175
189
  }();
176
190
  //#endregion
177
191
  //#region src/history/store.ts
178
- function o(t = [], n = -1) {
192
+ function s(t = [], n = -1) {
179
193
  return e((e) => ({
180
194
  index: n,
181
195
  pendingIndex: n,
@@ -227,13 +241,13 @@ function o(t = [], n = -1) {
227
241
  }
228
242
  //#endregion
229
243
  //#region src/utils/getMatchedPathPattern.ts
230
- function s(e, t) {
244
+ function c(e, t) {
231
245
  return Array.isArray(e) ? e.find((e) => i(e).regexp.test(t)) ?? "" : i(e).regexp.test(t) ? e : "";
232
246
  }
233
247
  //#endregion
234
248
  //#region src/utils/getParams.ts
235
- function c(e, t, r) {
236
- let i = n(s(e, t))(t), a = new URLSearchParams(r), o = Object.fromEntries(a.entries());
249
+ function l(e, t, r) {
250
+ let i = n(c(e, t))(t), a = new URLSearchParams(r), o = Object.fromEntries(a.entries());
237
251
  return i ? {
238
252
  ...i.params,
239
253
  ...o
@@ -241,24 +255,24 @@ function c(e, t, r) {
241
255
  }
242
256
  //#endregion
243
257
  //#region src/history/seedInitialHistory.ts
244
- function l(e, t, n, r) {
258
+ function u(e, t, n, r) {
245
259
  return {
246
260
  id: "root",
247
261
  pathname: t,
248
- params: c(e, t, n),
262
+ params: l(e, t, n),
249
263
  transitionName: r,
250
264
  layoutId: null
251
265
  };
252
266
  }
253
267
  //#endregion
254
268
  //#region src/utils/isServer.ts
255
- function u() {
269
+ function d() {
256
270
  return typeof document > "u";
257
271
  }
258
272
  //#endregion
259
273
  //#region src/history/ensureWindowHistoryState.ts
260
- function d(e, t, n = {}) {
261
- if (u()) return;
274
+ function f(e, t, n = {}) {
275
+ if (d()) return;
262
276
  let r = {
263
277
  id: "root",
264
278
  index: 0,
@@ -279,12 +293,24 @@ function d(e, t, n = {}) {
279
293
  }, "", window.location.href);
280
294
  }
281
295
  //#endregion
296
+ //#region src/history/seedRouterEntry.ts
297
+ function p(e) {
298
+ let { driver: t, routerKey: n, nested: r, seedPathname: i, defaultTransitionName: a, rootParams: o } = e;
299
+ if (d()) return;
300
+ if (r) {
301
+ let e = t.readPathname().replace(/\/+$/, "") || "/";
302
+ if (!(e === i || e !== "/" && i.startsWith(`${e}/`))) return;
303
+ }
304
+ let s = r && n !== null ? t.readState() == null : !1;
305
+ f(n, a, o), r && n !== null && s && t.readPathname() !== i && t.replaceState(t.readState(), i);
306
+ }
307
+ //#endregion
282
308
  //#region src/history/historyDriver.ts
283
- var f = (e, t) => ({
309
+ var m = (e, t) => ({
284
310
  ...window.history.state ?? {},
285
311
  [e]: t
286
312
  });
287
- function p(e) {
313
+ function h(e) {
288
314
  return e === void 0 ? {
289
315
  readState: () => window.history.state,
290
316
  readPathname: () => window.location.pathname,
@@ -302,8 +328,8 @@ function p(e) {
302
328
  } : {
303
329
  readState: () => window.history.state?.[e] ?? null,
304
330
  readPathname: () => window.location.pathname,
305
- pushState: (t, n) => window.history.pushState(f(e, t), "", n),
306
- replaceState: (t, n) => window.history.replaceState(f(e, t), "", n),
331
+ pushState: (t, n) => window.history.pushState(m(e, t), "", n),
332
+ replaceState: (t, n) => window.history.replaceState(m(e, t), "", n),
307
333
  go: (e) => window.history.go(e),
308
334
  back: () => window.history.back(),
309
335
  subscribe: (t) => {
@@ -317,7 +343,7 @@ function p(e) {
317
343
  }
318
344
  //#endregion
319
345
  //#region src/navigate/selfPopGuard.ts
320
- function m() {
346
+ function g() {
321
347
  let e = 0;
322
348
  return {
323
349
  mark() {
@@ -328,72 +354,149 @@ function m() {
328
354
  }
329
355
  };
330
356
  }
331
- var h = m();
332
- function g() {
333
- h.mark();
357
+ var _ = g();
358
+ function v() {
359
+ _.mark();
334
360
  }
335
- function _() {
336
- return h.consume();
361
+ function y() {
362
+ return _.consume();
337
363
  }
338
364
  //#endregion
339
365
  //#region src/history/createHistorySync.ts
340
- function v(e) {
341
- let { stores: t, driver: n = p(), consume: r = _ } = e, i = !1, o = n.subscribe(async (e) => {
342
- if (i || r()) return;
343
- let o = e.state, s = t.history.getState().truncationEpoch, c = a.generateTaskId();
344
- (await a.addTask(async (r) => {
366
+ function b(e) {
367
+ let { stores: t, driver: n = h(), consume: r = y } = e, i = !1, s = 0, c = async (e) => {
368
+ let n = e.state, r = t.history.getState().truncationEpoch, i = o.generateTaskId();
369
+ s += 1;
370
+ try {
371
+ await l(e, n, r, i);
372
+ } finally {
373
+ --s;
374
+ }
375
+ }, l = async (r, s, l, u) => {
376
+ (await o.addTask(async (a) => {
345
377
  if (i) {
346
- r.abort();
378
+ a.abort();
347
379
  return;
348
380
  }
349
- let { setStatus: a, setTransitionTaskId: l } = t.navigate.getState(), { index: u, histories: d, addHistory: f, popHistory: p, popHistories: m, setPendingIndex: h } = t.history.getState();
350
- if (s !== t.history.getState().truncationEpoch && n.readState()?.id !== e.state?.id) {
351
- r.abort();
381
+ if (e.ownsPathname && !e.ownsPathname(r.pathname)) {
382
+ a.abort();
352
383
  return;
353
384
  }
354
- if (!o?.id) {
355
- r.abort();
385
+ let { setStatus: o, setTransitionTaskId: d } = t.navigate.getState(), { index: f, histories: p, addHistory: m, popHistory: h, setPendingIndex: g } = t.history.getState();
386
+ if (l !== t.history.getState().truncationEpoch && n.readState()?.id !== r.state?.id) {
387
+ a.abort();
356
388
  return;
357
389
  }
358
- let g = d.findIndex((e) => e.id === o.id);
359
- if (g === u) {
360
- r.abort();
390
+ if (!s?.id) {
391
+ a.abort();
392
+ return;
393
+ }
394
+ let _ = p.findIndex((e) => e.id === s.id);
395
+ if (_ === f) {
396
+ a.abort();
361
397
  return;
362
398
  }
363
- let _ = {
364
- id: o.id,
365
- pathname: e.pathname,
366
- params: o.params,
367
- transitionName: o.transitionName,
368
- layoutId: o.layoutId,
369
- frameIndex: o.index
399
+ let v = {
400
+ id: s.id,
401
+ pathname: r.pathname,
402
+ params: s.params,
403
+ transitionName: s.transitionName,
404
+ layoutId: s.layoutId,
405
+ frameIndex: s.index
370
406
  };
371
- if (g === -1) {
372
- let e = d[u]?.frameIndex ?? u;
373
- if (!(o.index > e && (o.status === "PUSHING" || o.status === "REPLACING"))) {
374
- t.history.getState().adoptHistory(_), r.abort();
407
+ if (_ === -1) {
408
+ let e = p[f]?.frameIndex ?? f;
409
+ if (!(s.index > e && (s.status === "PUSHING" || s.status === "REPLACING"))) {
410
+ t.history.getState().adoptHistory(v), a.abort();
375
411
  return;
376
412
  }
377
- return l(c), a(o.status === "REPLACING" ? "REPLACING" : "PUSHING"), f(_), async () => {
378
- a("COMPLETED");
413
+ return d(u), o(s.status === "REPLACING" ? "REPLACING" : "PUSHING"), m(v), async () => {
414
+ o("COMPLETED");
379
415
  };
380
416
  }
381
- let v = u - g - 1;
382
- return l(c), v > 0 && m(v), h(g), a("POPPING"), async () => {
383
- p(g + 1), a("COMPLETED");
417
+ let y = f - 1;
418
+ return d(u), g(y), o("POPPING"), async () => {
419
+ h(y + 1), o("COMPLETED"), y > _ && !i && c(r);
384
420
  };
385
421
  }, {
386
- id: c,
387
- control: { manual: !0 }
422
+ id: u,
423
+ control: {
424
+ manual: !0,
425
+ maxLifetimeMs: a
426
+ }
388
427
  })).result?.();
428
+ }, u = null, d = 0, f = "", p = 0, m = () => typeof performance < "u" ? performance.now() : Number.MAX_VALUE, g = () => {
429
+ i || typeof setTimeout > "u" || (u && clearTimeout(u), u = setTimeout(function e() {
430
+ if (u = null, i) return;
431
+ if (s > 0 || o.pendingTaskIds.length > 0 || m() - d < 400) {
432
+ u = setTimeout(e, 150);
433
+ return;
434
+ }
435
+ let r = n.readPathname(), { histories: a, index: l } = t.history.getState(), h = a[l];
436
+ if (!h || h.pathname === r) {
437
+ p = 0;
438
+ return;
439
+ }
440
+ let g = n.readState(), _ = `${l}:${h.id}:${g?.id ?? "-"}:${r}`;
441
+ if (_ === f) {
442
+ if (p += 1, p > 4) return;
443
+ } else f = _, p = 0;
444
+ g?.id && g.id !== h.id && c({
445
+ state: g,
446
+ pathname: r
447
+ }), u = setTimeout(e, 150);
448
+ }, 150));
449
+ }, _ = n.subscribe((e) => {
450
+ if (!i && (d = m(), g(), C(e.pathname), !r())) return c(e);
389
451
  });
390
- return () => {
391
- i = !0, o();
452
+ if (e.routerKey && e.zoneEntryId && T(n, e.zoneEntryId)) {
453
+ let n = t.history.getState().histories[t.history.getState().index]?.pathname, r = w(n);
454
+ for (let t of r) c({
455
+ state: t.raw?.[e.routerKey] ?? null,
456
+ pathname: t.pathname
457
+ });
458
+ }
459
+ return g(), () => {
460
+ i = !0, u && clearTimeout(u), _();
392
461
  };
393
462
  }
463
+ var x = [], S = !1, C = (e) => {
464
+ S || typeof window > "u" || (S = !0, queueMicrotask(() => {
465
+ S = !1;
466
+ }), x.push({
467
+ raw: window.history.state,
468
+ pathname: e
469
+ }));
470
+ }, w = (e) => {
471
+ if (!e) return [];
472
+ for (let t = x.length - 1; t >= 0; --t) if (x[t].pathname === e) return x.slice(t + 1);
473
+ return [];
474
+ }, T = (e, t) => {
475
+ if (typeof window > "u") return !1;
476
+ let n = window.history.state;
477
+ return n ? Object.values(n).some((e) => !!e && typeof e == "object" && e.id === t) : !1;
478
+ };
479
+ function E(e, t) {
480
+ for (let n = x.length - 1; n >= 0; --n) if (x[n].pathname === t) return x[n].raw?.[e] ?? null;
481
+ return null;
482
+ }
483
+ var D = /* @__PURE__ */ new WeakMap();
484
+ function ee(e) {
485
+ D.has(e) || D.set(e, b({
486
+ stores: e,
487
+ driver: e.driver,
488
+ consume: e.consume,
489
+ routerKey: e.routerKey,
490
+ zoneEntryId: e.zoneEntryId,
491
+ ownsPathname: e.ownsPathname
492
+ }));
493
+ }
494
+ function te(e) {
495
+ e.persistent || (D.get(e)?.(), D.delete(e));
496
+ }
394
497
  //#endregion
395
498
  //#region src/history/memoryHistoryDriver.ts
396
- function y(e) {
499
+ function ne(e) {
397
500
  let t = [{
398
501
  state: e?.state ?? null,
399
502
  url: e?.url ?? "/"
@@ -435,7 +538,7 @@ function y(e) {
435
538
  }
436
539
  //#endregion
437
540
  //#region src/navigate/store.ts
438
- function b() {
541
+ function re() {
439
542
  return e((e) => ({
440
543
  status: "IDLE",
441
544
  transitionTaskId: null,
@@ -445,11 +548,11 @@ function b() {
445
548
  }
446
549
  //#endregion
447
550
  //#region src/navigate/createNavigationController.ts
448
- var x = (e, t, n) => {
551
+ var O = (e, t, n) => {
449
552
  let { regexp: r } = i(e);
450
553
  for (let e = t - 1; e >= 0; e--) if (r.test(n[e].pathname)) return t - e;
451
554
  return -1;
452
- }, S = (e, t) => typeof e == "number" && Number.isFinite(e) ? Math.max(0, Math.trunc(e)) : t, C = async (e, t, n, r) => {
555
+ }, k = (e, t) => typeof e == "number" && Number.isFinite(e) ? Math.max(0, Math.trunc(e)) : t, ie = async (e, t, n, r) => {
453
556
  let i, a = new Promise((t) => {
454
557
  i = e.subscribe(() => t(!0));
455
558
  }), o = new Promise((e) => setTimeout(() => e(!1), 200));
@@ -457,8 +560,8 @@ var x = (e, t, n) => {
457
560
  let s = await Promise.race([a, o]);
458
561
  i(), s && r();
459
562
  };
460
- function w(e) {
461
- let { stores: t, buildPathname: n, driver: r = p(), markSelfInduced: i = g } = e, o = () => t.history.getState().bumpTruncationEpoch(), s = () => {
563
+ function ae(e) {
564
+ let { stores: t, buildPathname: n, driver: r = h(), markSelfInduced: i = v } = e, s = () => t.history.getState().bumpTruncationEpoch(), c = () => {
462
565
  let e = r.readState();
463
566
  if (!e?.id) return null;
464
567
  let { index: n, histories: i, adoptHistory: a, truncateHistory: o } = t.history.getState();
@@ -472,172 +575,181 @@ function w(e) {
472
575
  layoutId: e.layoutId ?? null,
473
576
  frameIndex: e.index
474
577
  }), e;
475
- }, c = async (e, c, l) => {
476
- let { status: u } = t.navigate.getState();
477
- if (u !== "COMPLETED" && u !== "IDLE") return;
478
- let d = t.transition.getState().defaultTransitionName, { transitionName: f = d, layoutId: p = null } = l ?? {}, m = a.generateTaskId();
479
- (await a.addTask(async (a) => {
578
+ }, l = async (e, l, u) => {
579
+ let { status: d } = t.navigate.getState();
580
+ if (d !== "COMPLETED" && d !== "IDLE") return;
581
+ let f = t.transition.getState().defaultTransitionName, { transitionName: p = f, layoutId: m = null } = u ?? {}, h = o.generateTaskId();
582
+ (await o.addTask(async (a) => {
480
583
  if (t.life && !t.life.alive) {
481
584
  a.abort();
482
585
  return;
483
586
  }
484
- let u = s(), { index: d, histories: h, addHistory: g, popHistories: _ } = t.history.getState(), v = (() => {
485
- if (l?.until != null) {
486
- let e = x(l.until, d, h);
587
+ let o = c(), { index: d, histories: f, addHistory: g, popHistories: _ } = t.history.getState(), v = (() => {
588
+ if (u?.until != null) {
589
+ let e = O(u.until, d, f);
487
590
  return e < 0 ? 0 : e;
488
591
  }
489
- return Math.min(S(l?.skip, 0), Math.max(0, d));
592
+ return Math.min(k(u?.skip, 0), Math.max(0, d));
490
593
  })(), { setStatus: y, setTransitionTaskId: b } = t.navigate.getState();
491
- y("PUSHING"), b(m);
492
- let { pathname: w, toPathname: T } = n(e, c ?? {}), E = {
493
- id: m,
494
- pathname: T,
495
- params: c ?? {},
496
- transitionName: f,
497
- layoutId: p
498
- }, D = u?.index ?? h[d]?.frameIndex ?? d;
499
- if (v === 0) return o(), r.pushState({
500
- id: m,
501
- index: D + 1,
594
+ y("PUSHING"), b(h);
595
+ let { pathname: x, toPathname: S } = n(e, l ?? {}), C = {
596
+ id: h,
597
+ pathname: S,
598
+ params: l ?? {},
599
+ transitionName: p,
600
+ layoutId: m
601
+ }, w = o?.index ?? f[d]?.frameIndex ?? d;
602
+ if (v === 0) return s(), r.pushState({
603
+ id: h,
604
+ index: w + 1,
502
605
  status: "PUSHING",
503
- params: c,
504
- transitionName: f,
505
- layoutId: p
506
- }, w), g({
507
- ...E,
508
- frameIndex: D + 1
606
+ params: l,
607
+ transitionName: p,
608
+ layoutId: m
609
+ }, x), g({
610
+ ...C,
611
+ frameIndex: w + 1
509
612
  }), () => {
510
613
  y("COMPLETED");
511
614
  };
512
- let O = h[d - v]?.frameIndex ?? d - v;
615
+ let T = f[d - v]?.frameIndex ?? d - v;
513
616
  return g({
514
- ...E,
515
- frameIndex: O + 1
516
- }), await C(r, i, v, () => {
517
- o(), r.pushState({
518
- id: m,
519
- index: O + 1,
617
+ ...C,
618
+ frameIndex: T + 1
619
+ }), await ie(r, i, v, () => {
620
+ s(), r.pushState({
621
+ id: h,
622
+ index: T + 1,
520
623
  status: "PUSHING",
521
- params: c,
522
- transitionName: f,
523
- layoutId: p
524
- }, w);
624
+ params: l,
625
+ transitionName: p,
626
+ layoutId: m
627
+ }, x);
525
628
  }), async () => {
526
629
  _(v), y("COMPLETED");
527
630
  };
528
631
  }, {
529
- id: m,
530
- control: { manual: !0 }
632
+ id: h,
633
+ control: {
634
+ manual: !0,
635
+ maxLifetimeMs: a
636
+ }
531
637
  })).result?.();
532
- }, l = async (e, c, l) => {
533
- let { status: u } = t.navigate.getState();
534
- if (u !== "COMPLETED" && u !== "IDLE") return;
535
- let d = t.transition.getState().defaultTransitionName, { transitionName: f = d, layoutId: p = null } = l ?? {}, m = a.generateTaskId();
536
- (await a.addTask(async (a) => {
638
+ }, u = async (e, l, u) => {
639
+ let { status: d } = t.navigate.getState();
640
+ if (d !== "COMPLETED" && d !== "IDLE") return;
641
+ let f = t.transition.getState().defaultTransitionName, { transitionName: p = f, layoutId: m = null } = u ?? {}, h = o.generateTaskId();
642
+ (await o.addTask(async (a) => {
537
643
  if (t.life && !t.life.alive) {
538
644
  a.abort();
539
645
  return;
540
646
  }
541
- let u = s(), { index: d, histories: h, addHistory: g, replaceHistory: _, popHistories: v } = t.history.getState(), y = (() => {
542
- if (l?.until != null) {
543
- let e = x(l.until, d, h);
647
+ let o = c(), { index: d, histories: f, addHistory: g, replaceHistory: _, popHistories: v } = t.history.getState(), y = (() => {
648
+ if (u?.until != null) {
649
+ let e = O(u.until, d, f);
544
650
  return e < 0 ? 0 : e + 1;
545
651
  }
546
- return Math.min(S(l?.skip, 0) + 1, d + 1);
652
+ return Math.min(k(u?.skip, 0) + 1, d + 1);
547
653
  })();
548
654
  if (y <= 0) {
549
655
  a.abort();
550
656
  return;
551
657
  }
552
- let { setStatus: b, setTransitionTaskId: w } = t.navigate.getState();
553
- b("REPLACING"), w(m);
554
- let { pathname: T, toPathname: E } = n(e, c ?? {}), D = {
555
- id: m,
556
- pathname: E,
557
- params: c ?? {},
558
- transitionName: f,
559
- layoutId: p
560
- }, O = u?.index ?? h[d]?.frameIndex ?? d;
561
- if (y === 1) return o(), r.replaceState({
562
- id: m,
563
- index: O,
658
+ let { setStatus: b, setTransitionTaskId: x } = t.navigate.getState();
659
+ b("REPLACING"), x(h);
660
+ let { pathname: S, toPathname: C } = n(e, l ?? {}), w = {
661
+ id: h,
662
+ pathname: C,
663
+ params: l ?? {},
664
+ transitionName: p,
665
+ layoutId: m
666
+ }, T = o?.index ?? f[d]?.frameIndex ?? d;
667
+ if (y === 1) return s(), r.replaceState({
668
+ id: h,
669
+ index: T,
564
670
  status: "REPLACING",
565
- params: c,
566
- transitionName: f,
567
- layoutId: p
568
- }, T), g({
569
- ...D,
570
- frameIndex: O
671
+ params: l,
672
+ transitionName: p,
673
+ layoutId: m
674
+ }, S), g({
675
+ ...w,
676
+ frameIndex: T
571
677
  }), async () => {
572
678
  _(d), b("COMPLETED");
573
679
  };
574
- let k = y <= d ? (h[d - y]?.frameIndex ?? d - y) + 1 : h[0]?.frameIndex ?? 0;
680
+ let E = y <= d ? (f[d - y]?.frameIndex ?? d - y) + 1 : f[0]?.frameIndex ?? 0;
575
681
  return v(y - 1), g({
576
- ...D,
577
- frameIndex: k
578
- }), y <= d ? await C(r, i, y, () => {
579
- o(), r.pushState({
580
- id: m,
581
- index: k,
682
+ ...w,
683
+ frameIndex: E
684
+ }), y <= d ? await ie(r, i, y, () => {
685
+ s(), r.pushState({
686
+ id: h,
687
+ index: E,
582
688
  status: "REPLACING",
583
- params: c,
584
- transitionName: f,
585
- layoutId: p
586
- }, T);
587
- }) : await C(r, i, d, () => {
588
- o(), r.replaceState({
589
- id: m,
590
- index: k,
689
+ params: l,
690
+ transitionName: p,
691
+ layoutId: m
692
+ }, S);
693
+ }) : await ie(r, i, d, () => {
694
+ s(), r.replaceState({
695
+ id: h,
696
+ index: E,
591
697
  status: "REPLACING",
592
- params: c,
593
- transitionName: f,
594
- layoutId: p
595
- }, T);
698
+ params: l,
699
+ transitionName: p,
700
+ layoutId: m
701
+ }, S);
596
702
  }), async () => {
597
703
  _(t.history.getState().index - 1), b("COMPLETED");
598
704
  };
599
705
  }, {
600
- id: m,
601
- control: { manual: !0 }
706
+ id: h,
707
+ control: {
708
+ manual: !0,
709
+ maxLifetimeMs: a
710
+ }
602
711
  })).result?.();
603
- }, u = async (e, n) => {
604
- let o = a.generateTaskId();
605
- (await a.addTask(async (a) => {
712
+ }, d = async (e, n) => {
713
+ let s = o.generateTaskId();
714
+ (await o.addTask(async (a) => {
606
715
  if (t.life && !t.life.alive) {
607
716
  a.abort();
608
717
  return;
609
718
  }
610
- s();
611
- let { index: c, histories: l, popHistory: u, popHistories: d, setPendingIndex: f, setTransitionName: p } = t.history.getState();
612
- if (c <= 0) {
719
+ c();
720
+ let { index: o, histories: l, popHistory: u, popHistories: d, setPendingIndex: f, setTransitionName: p } = t.history.getState();
721
+ if (o <= 0) {
613
722
  a.abort();
614
723
  return;
615
724
  }
616
- let m = Math.min(e(c, l), c);
725
+ let m = Math.min(e(o, l), o);
617
726
  if (m <= 0) {
618
727
  a.abort();
619
728
  return;
620
729
  }
621
- f(c - m);
730
+ f(o - m);
622
731
  let { setStatus: h, setTransitionTaskId: g } = t.navigate.getState();
623
- return n && p(c, n), h("POPPING"), g(o), d(m - 1), i(), m === 1 ? r.back() : r.go(-m), async () => {
732
+ return n && p(o, n), h("POPPING"), g(s), d(m - 1), i(), m === 1 ? r.back() : r.go(-m), async () => {
624
733
  u(t.history.getState().index), h("COMPLETED");
625
734
  };
626
735
  }, {
627
- id: o,
628
- control: { manual: !0 }
736
+ id: s,
737
+ control: {
738
+ manual: !0,
739
+ maxLifetimeMs: a
740
+ }
629
741
  })).result?.();
630
742
  };
631
743
  return {
632
- push: c,
633
- replace: l,
744
+ push: l,
745
+ replace: u,
634
746
  pop: async (e) => {
635
- await u((t, n) => {
747
+ await d((t, n) => {
636
748
  if (e?.until != null) {
637
- let r = x(e.until, t, n);
749
+ let r = O(e.until, t, n);
638
750
  return r < 0 ? 0 : r;
639
751
  }
640
- let r = S(e?.skip, 1);
752
+ let r = k(e?.skip, 1);
641
753
  return r <= 0 ? 0 : Math.min(r, t);
642
754
  }, e?.transitionName);
643
755
  }
@@ -645,18 +757,18 @@ function w(e) {
645
757
  }
646
758
  //#endregion
647
759
  //#region src/navigate/createStepController.ts
648
- var T = (e) => {
760
+ var oe = (e) => {
649
761
  let t = e;
650
762
  return t?.step ? t.params ?? {} : null;
651
- }, E = (e, t) => {
763
+ }, se = (e, t) => {
652
764
  let n = new URLSearchParams(Object.fromEntries(Object.entries(t).map(([e, t]) => [e, String(t)]))).toString();
653
765
  return n ? `${e}?${n}` : e;
654
766
  };
655
- function D(e) {
656
- let { stores: t, driver: n, markSelfInduced: r, buildStepPathname: i, applyParams: o } = e;
767
+ function ce(e) {
768
+ let { stores: t, driver: n, markSelfInduced: r, buildStepPathname: i, applyParams: s } = e;
657
769
  return {
658
770
  pushStep: async (e) => {
659
- (await a.addTask(async () => {
771
+ (await o.addTask(async () => {
660
772
  let t = i(e), r = n.readState();
661
773
  return r?.step || n.replaceState({
662
774
  ...r,
@@ -665,35 +777,35 @@ function D(e) {
665
777
  ...n.readState(),
666
778
  step: !0,
667
779
  params: e
668
- }, t), async () => o(e);
780
+ }, t), async () => s(e);
669
781
  })).result?.();
670
782
  },
671
783
  replaceStep: async (e) => {
672
- (await a.addTask(async () => {
784
+ (await o.addTask(async () => {
673
785
  let t = i(e);
674
786
  return n.replaceState({
675
787
  ...n.readState(),
676
788
  step: !0,
677
789
  params: e
678
- }, t), async () => o(e);
790
+ }, t), async () => s(e);
679
791
  })).result?.();
680
792
  },
681
793
  popStep: async () => {
682
- let e = a.generateTaskId();
683
- (await a.addTask(async (i) => {
794
+ let e = o.generateTaskId();
795
+ (await o.addTask(async (i) => {
684
796
  let a = new Promise((e) => {
685
797
  let t = n.subscribe((n) => {
686
798
  t(), e(n.state);
687
799
  });
688
- }), s = new Promise((e) => setTimeout(() => e(void 0), 200));
800
+ }), o = new Promise((e) => setTimeout(() => e(void 0), 200));
689
801
  r(), n.back();
690
- let c = await Promise.race([a, s]);
802
+ let c = await Promise.race([a, o]);
691
803
  if (!c) {
692
804
  i.abort();
693
805
  return;
694
806
  }
695
807
  if (c.step) {
696
- o(c.params ?? {}), i.abort();
808
+ s(c.params ?? {}), i.abort();
697
809
  return;
698
810
  }
699
811
  let { setStatus: l, setTransitionTaskId: u } = t.navigate.getState(), { index: d, popHistory: f } = t.history.getState();
@@ -702,30 +814,38 @@ function D(e) {
702
814
  };
703
815
  }, {
704
816
  id: e,
705
- control: { manual: !0 }
817
+ control: {
818
+ manual: !0,
819
+ maxLifetimeMs: a
820
+ }
706
821
  })).result?.();
707
822
  }
708
823
  };
709
824
  }
710
- function O(e, t) {
825
+ function le(e, t) {
711
826
  return e.subscribe((e) => {
712
827
  let n = e.state;
713
- n?.step && a.addTask(async () => {
828
+ n?.step && o.addTask(async () => {
714
829
  t(n.params ?? {});
715
830
  });
716
831
  });
717
832
  }
718
833
  //#endregion
719
834
  //#region src/transition/store.ts
720
- function k(t = "cupertino") {
835
+ function ue(t = "cupertino") {
721
836
  return e((e) => ({
722
837
  defaultTransitionName: t,
723
838
  setDefaultTransitionName: (t) => e({ defaultTransitionName: t })
724
839
  }));
725
840
  }
726
841
  //#endregion
842
+ //#region src/utils/matchesPathname.ts
843
+ function de(e, t) {
844
+ return i(e).regexp.test(t);
845
+ }
846
+ //#endregion
727
847
  //#region src/screen/store.ts
728
- function A() {
848
+ function fe() {
729
849
  return e((e) => ({
730
850
  dragStatus: "IDLE",
731
851
  replaceTransitionStatus: "IDLE",
@@ -756,49 +876,62 @@ function A() {
756
876
  }
757
877
  //#endregion
758
878
  //#region src/core/createRouterScope.ts
759
- var ee = {
879
+ var pe = {
760
880
  mark: () => {},
761
881
  consume: () => !1
762
- };
763
- function te(e) {
764
- let { routePaths: t, pathname: n, search: r, defaultTransitionName: i, memory: a, browserDriver: s } = e, c = l(t, n, r, i), d = s && !u() ? s.readState() : null, f = d?.id ? {
765
- ...c,
766
- id: d.id,
767
- params: d.params ?? c.params,
768
- frameIndex: d.index ?? 0
882
+ }, me = /* @__PURE__ */ new Map();
883
+ function he(e) {
884
+ let { routePaths: t, pathname: n, search: r, defaultTransitionName: i, memory: a, browserDriver: o } = e, c = d() ? void 0 : e.persistKey;
885
+ if (c) {
886
+ let e = me.get(c);
887
+ if (e) {
888
+ e.life.alive = !0, e.navigate.getState().setStatus("IDLE"), e.navigate.getState().setTransitionTaskId(null);
889
+ let t = e.history.getState();
890
+ return t.setPendingIndex(t.index), e;
891
+ }
892
+ }
893
+ let l = u(t, n, r, i), f = (e.routerKey && !d() ? E(e.routerKey, n) : null) ?? (o && !d() ? o.readState() : null), p = f?.id ? {
894
+ ...l,
895
+ id: f.id,
896
+ params: f.params ?? l.params,
897
+ frameIndex: f.index ?? 0
769
898
  } : {
770
- ...c,
899
+ ...l,
771
900
  frameIndex: 0
772
901
  };
773
902
  if (e.hostedScope) return e.hostedScope.life.alive = !0, e.hostedScope.history.getState().index === -1 && e.hostedScope.history.setState({
774
903
  index: 0,
775
- histories: [f]
904
+ histories: [p]
776
905
  }), e.hostedScope;
777
- let p = a ? y({
906
+ let m = a ? ne({
778
907
  state: {
779
- id: f.id,
908
+ id: p.id,
780
909
  index: 0,
781
910
  status: "IDLE",
782
- params: f.params,
783
- transitionName: f.transitionName,
784
- layoutId: f.layoutId
911
+ params: p.params,
912
+ transitionName: p.transitionName,
913
+ layoutId: p.layoutId
785
914
  },
786
- url: f.pathname
787
- }) : s, h = a ? ee : m();
788
- return {
789
- history: o([f], 0),
790
- navigate: b(),
791
- transition: k(i),
792
- screen: A(),
793
- driver: p,
915
+ url: p.pathname
916
+ }) : o, h = a ? pe : g(), _ = {
917
+ history: s([p], 0),
918
+ navigate: re(),
919
+ transition: ue(i),
920
+ screen: fe(),
921
+ driver: m,
794
922
  markSelfInduced: h.mark,
795
923
  consume: h.consume,
924
+ routerKey: e.routerKey,
925
+ zoneEntryId: e.zoneEntryId,
926
+ ownsPathname: (e) => de(t, e),
927
+ persistent: !!c,
796
928
  life: { alive: !0 }
797
929
  };
930
+ return c && me.set(c, _), _;
798
931
  }
799
932
  //#endregion
800
933
  //#region src/screen/createScreenSelector.ts
801
- function ne(e, t) {
934
+ function ge(e, t) {
802
935
  return e.map((n, r) => ({
803
936
  ...n,
804
937
  isActive: r === t,
@@ -811,13 +944,13 @@ function ne(e, t) {
811
944
  }
812
945
  //#endregion
813
946
  //#region src/screen/computeScreenFreeze.ts
814
- function re(e) {
947
+ function _e(e) {
815
948
  let t = e.status === "COMPLETED" && e.dragStatus === "IDLE";
816
949
  return !e.isActive && t || e.isPrev && e.index - 2 <= e.zIndex && e.replaceTransitionStatus === "IDLE" || e.isPrev && e.index - 2 > e.zIndex;
817
950
  }
818
951
  //#endregion
819
952
  //#region src/transition/createTransition.ts
820
- function j({ name: e, initial: t, idle: n, enter: r, enterBack: i, exit: a, exitBack: o, options: s }) {
953
+ function A({ name: e, initial: t, idle: n, enter: r, enterBack: i, exit: a, exitBack: o, options: s }) {
821
954
  return {
822
955
  name: e,
823
956
  initial: t,
@@ -838,7 +971,7 @@ function j({ name: e, initial: t, idle: n, enter: r, enterBack: i, exit: a, exit
838
971
  }
839
972
  //#endregion
840
973
  //#region src/transition/createRawTransition.ts
841
- function ie({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnExit: l, completedOnEnter: u, options: d }) {
974
+ function ve({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnExit: l, completedOnEnter: u, options: d }) {
842
975
  return {
843
976
  name: e,
844
977
  initial: t,
@@ -859,10 +992,10 @@ function ie({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, repla
859
992
  }
860
993
  //#endregion
861
994
  //#region src/transition/cupertino.ts
862
- var ae = (e, t, n) => {
995
+ var ye = (e, t, n) => {
863
996
  let [r, i] = t, [a, o] = n;
864
997
  return i === r ? a : a + (e - r) / (i - r) * (o - a);
865
- }, oe = j({
998
+ }, be = A({
866
999
  name: "cupertino",
867
1000
  initial: { x: "100%" },
868
1001
  idle: {
@@ -872,7 +1005,7 @@ var ae = (e, t, n) => {
872
1005
  enter: {
873
1006
  value: { x: 0 },
874
1007
  options: {
875
- duration: .7,
1008
+ duration: .6,
876
1009
  ease: [
877
1010
  .32,
878
1011
  .72,
@@ -894,9 +1027,9 @@ var ae = (e, t, n) => {
894
1027
  }
895
1028
  },
896
1029
  exit: {
897
- value: { x: "-30%" },
1030
+ value: { x: "-35%" },
898
1031
  options: {
899
- duration: .7,
1032
+ duration: .6,
900
1033
  ease: [
901
1034
  .32,
902
1035
  .72,
@@ -922,8 +1055,8 @@ var ae = (e, t, n) => {
922
1055
  swipeDirection: "x",
923
1056
  onSwipeStart: async () => !0,
924
1057
  onSwipe: (e, t, { animate: n, currentScreen: r, prevScreen: i, onProgress: a }) => {
925
- let { offset: o } = t, s = o.x, c = ae(s, [0, window.innerWidth], [0, 100]);
926
- return a?.(!0, c), n(r, { x: Math.max(0, s) }, { duration: 0 }), n(i, { x: `${-30 + c * .3}%` }, { duration: 0 }), c;
1058
+ let { offset: o } = t, s = o.x, c = ye(s, [0, window.innerWidth], [0, 100]);
1059
+ return a?.(!0, c), n(r, { x: Math.max(0, s) }, { duration: 0 }), n(i, { x: `${-35 + c * .35}%` }, { duration: 0 }), c;
927
1060
  },
928
1061
  onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
929
1062
  let { offset: o, velocity: s } = t, c = o.x > 50 || s.x > 20;
@@ -935,7 +1068,7 @@ var ae = (e, t, n) => {
935
1068
  0,
936
1069
  1
937
1070
  ]
938
- }), n(i, { x: c ? 0 : "-30%" }, {
1071
+ }), n(i, { x: c ? 0 : "-35%" }, {
939
1072
  duration: .3,
940
1073
  ease: [
941
1074
  .32,
@@ -946,10 +1079,10 @@ var ae = (e, t, n) => {
946
1079
  })]), c;
947
1080
  }
948
1081
  }
949
- }), se = (e, t, n) => {
1082
+ }), xe = (e, t, n) => {
950
1083
  let [r, i] = t, [a, o] = n;
951
1084
  return i === r ? a : a + (e - r) / (i - r) * (o - a);
952
- }, M = j({
1085
+ }, Se = A({
953
1086
  name: "layout",
954
1087
  initial: { opacity: .97 },
955
1088
  idle: {
@@ -977,7 +1110,7 @@ var ae = (e, t, n) => {
977
1110
  swipeDirection: "y",
978
1111
  onSwipeStart: async () => !0,
979
1112
  onSwipe: (e, t, { animate: n, currentScreen: r, onProgress: i }) => {
980
- let { offset: a } = t, o = a.y, s = Math.max(0, Math.min(56, o)), c = se(s, [0, 56], [1, .96]), l = Math.max(0, o - 56), u = Math.min(1, l / 160), d = Math.sqrt(u) * 12, f = Math.max(0, s + d), p = Math.min(56, f);
1113
+ let { offset: a } = t, o = a.y, s = Math.max(0, Math.min(56, o)), c = xe(s, [0, 56], [1, .96]), l = Math.max(0, o - 56), u = Math.min(1, l / 160), d = Math.sqrt(u) * 12, f = Math.max(0, s + d), p = Math.min(56, f);
981
1114
  return i?.(!0, 100), n(r, {
982
1115
  y: f,
983
1116
  opacity: c
@@ -994,7 +1127,7 @@ var ae = (e, t, n) => {
994
1127
  }, { duration: .3 })]), c;
995
1128
  }
996
1129
  }
997
- }), ce = j({
1130
+ }), Ce = A({
998
1131
  name: "material",
999
1132
  initial: { y: "100%" },
1000
1133
  idle: {
@@ -1102,7 +1235,7 @@ var ae = (e, t, n) => {
1102
1235
  })]), c;
1103
1236
  }
1104
1237
  }
1105
- }), le = j({
1238
+ }), we = A({
1106
1239
  name: "none",
1107
1240
  initial: {},
1108
1241
  idle: {
@@ -1125,20 +1258,20 @@ var ae = (e, t, n) => {
1125
1258
  value: {},
1126
1259
  options: { duration: 0 }
1127
1260
  }
1128
- }), N = new Map([
1129
- ["none", le],
1130
- ["cupertino", oe],
1131
- ["material", ce],
1132
- ["layout", M]
1261
+ }), j = new Map([
1262
+ ["none", we],
1263
+ ["cupertino", be],
1264
+ ["material", Ce],
1265
+ ["layout", Se]
1133
1266
  ]);
1134
1267
  //#endregion
1135
1268
  //#region src/transition/resolveTransition.ts
1136
- function ue(e) {
1137
- return N.get(e) ?? N.get("none");
1269
+ function M(e) {
1270
+ return j.get(e) ?? j.get("none");
1138
1271
  }
1139
1272
  //#endregion
1140
1273
  //#region src/transition/decorator/createDecorator.ts
1141
- function de({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
1274
+ function Te({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
1142
1275
  return {
1143
1276
  name: e,
1144
1277
  initial: t,
@@ -1159,7 +1292,7 @@ function de({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
1159
1292
  }
1160
1293
  //#endregion
1161
1294
  //#region src/transition/decorator/createRawDecorator.ts
1162
- function fe({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnEnter: l, completedOnExit: u, options: d }) {
1295
+ function Ee({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnEnter: l, completedOnExit: u, options: d }) {
1163
1296
  return {
1164
1297
  name: e,
1165
1298
  initial: t,
@@ -1180,30 +1313,30 @@ function fe({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, repla
1180
1313
  }
1181
1314
  //#endregion
1182
1315
  //#region src/transition/decorator/overlay.ts
1183
- var P = "rgba(0, 0, 0, 0.3)", pe = de({
1316
+ var N = "rgba(0, 0, 0, 0.2)", De = Te({
1184
1317
  name: "overlay",
1185
1318
  initial: {
1186
1319
  opacity: 0,
1187
- backgroundColor: P
1320
+ backgroundColor: N
1188
1321
  },
1189
1322
  idle: {
1190
1323
  value: {
1191
1324
  opacity: 0,
1192
- backgroundColor: P
1325
+ backgroundColor: N
1193
1326
  },
1194
1327
  options: { duration: 0 }
1195
1328
  },
1196
1329
  enter: {
1197
1330
  value: {
1198
1331
  opacity: 1,
1199
- backgroundColor: P
1332
+ backgroundColor: N
1200
1333
  },
1201
- options: { duration: .7 }
1334
+ options: { duration: .6 }
1202
1335
  },
1203
1336
  exit: {
1204
1337
  value: {
1205
1338
  opacity: 0,
1206
- backgroundColor: P
1339
+ backgroundColor: N
1207
1340
  },
1208
1341
  options: { duration: .6 }
1209
1342
  },
@@ -1212,10 +1345,10 @@ var P = "rgba(0, 0, 0, 0.3)", pe = de({
1212
1345
  onSwipe: (e, t, { animate: n, prevDecorator: r }) => n(r, { opacity: Math.max(0, 1 - t / 100) }, { duration: 0 }),
1213
1346
  onSwipeEnd: (e, { animate: t, prevDecorator: n }) => t(n, { opacity: +!e }, { duration: .3 })
1214
1347
  }
1215
- }), F = new Map([["overlay", pe]]);
1348
+ }), P = new Map([["overlay", De]]);
1216
1349
  //#endregion
1217
1350
  //#region src/transition/partTransition/createPartTransition.ts
1218
- function me({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
1351
+ function Oe({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
1219
1352
  return {
1220
1353
  name: e,
1221
1354
  initial: t,
@@ -1236,7 +1369,7 @@ function me({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
1236
1369
  }
1237
1370
  //#endregion
1238
1371
  //#region src/transition/partTransition/createRawPartTransition.ts
1239
- function he({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnEnter: l, completedOnExit: u, options: d }) {
1372
+ function ke({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnEnter: l, completedOnExit: u, options: d }) {
1240
1373
  return {
1241
1374
  name: e,
1242
1375
  initial: t,
@@ -1257,7 +1390,7 @@ function he({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, repla
1257
1390
  }
1258
1391
  //#endregion
1259
1392
  //#region src/transition/partTransition/partTransition.ts
1260
- var I = /* @__PURE__ */ new Map(), L = {
1393
+ var F = /* @__PURE__ */ new Map(), I = {
1261
1394
  "IDLE-true": "self",
1262
1395
  "IDLE-false": "self",
1263
1396
  "PUSHING-true": "initial",
@@ -1268,7 +1401,25 @@ var I = /* @__PURE__ */ new Map(), L = {
1268
1401
  "POPPING-false": "PUSHING-false",
1269
1402
  "COMPLETED-true": "self",
1270
1403
  "COMPLETED-false": "self"
1271
- }, ge = Object.keys(L), _e = ge, ve = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_"), ye = (e) => typeof e == "object" && !!e && !Array.isArray(e), be = new Set(/* @__PURE__ */ "opacity.scale.scaleX.scaleY.scaleZ.aspectRatio.columnCount.columns.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineHeight.lineClamp.order.orphans.tabSize.widows.zIndex.zoom.fillOpacity.floodOpacity.stopOpacity.strokeOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeWidth".split(".")), xe = (e, t) => t.startsWith("--") || be.has(t) ? `${e}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${e}deg` : `${e}px`, Se = (e, t) => typeof t == "number" ? xe(t, e) : typeof t == "string" ? t : "", Ce = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), we = new Set([
1404
+ }, Ae = Object.keys(I), L = (e) => {
1405
+ if (!e) return 0;
1406
+ let t = e.duration;
1407
+ return typeof t == "number" && t >= 0 ? t : 0;
1408
+ }, R = (e) => e && typeof e.delay == "number" && e.delay > 0 ? e.delay : 0, je = (e, t) => {
1409
+ let n = I[t];
1410
+ return n === "self" ? null : n === "initial" ? e.initial : e.variants[n].value;
1411
+ }, z = (e, t) => {
1412
+ let n = je(e, t);
1413
+ if (n === null) return null;
1414
+ let r = e.variants[t], i = L(r.options), a = R(r.options);
1415
+ return i <= 0 && a <= 0 ? null : {
1416
+ from: n,
1417
+ to: r.value,
1418
+ duration: i,
1419
+ delay: a,
1420
+ ease: r.options?.ease
1421
+ };
1422
+ }, Me = Ae, Ne = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_"), Pe = (e) => typeof e == "object" && !!e && !Array.isArray(e), Fe = new Set(/* @__PURE__ */ "opacity.scale.scaleX.scaleY.scaleZ.aspectRatio.columnCount.columns.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineHeight.lineClamp.order.orphans.tabSize.widows.zIndex.zoom.fillOpacity.floodOpacity.stopOpacity.strokeOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeWidth".split(".")), Ie = (e, t) => t.startsWith("--") || Fe.has(t) ? `${e}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${e}deg` : `${e}px`, Le = (e, t) => typeof t == "number" ? Ie(t, e) : typeof t == "string" ? t : "", Re = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), ze = new Set([
1272
1423
  "x",
1273
1424
  "y",
1274
1425
  "z",
@@ -1279,10 +1430,10 @@ var I = /* @__PURE__ */ new Map(), L = {
1279
1430
  "rotateX",
1280
1431
  "rotateY",
1281
1432
  "rotateZ"
1282
- ]), Te = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, Ee = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, De = /^1(\.0+)?$/, Oe = (e, t) => e === "scale" || e === "scaleX" || e === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? De.test(t.trim()) : !1 : e === "rotate" || e === "rotateX" || e === "rotateY" || e === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? Ee.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? Te.test(t.trim()) : !1, ke = (e, t) => {
1433
+ ]), Be = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, Ve = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, He = /^1(\.0+)?$/, Ue = (e, t) => e === "scale" || e === "scaleX" || e === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? He.test(t.trim()) : !1 : e === "rotate" || e === "rotateX" || e === "rotateY" || e === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? Ve.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? Be.test(t.trim()) : !1, We = (e, t) => {
1283
1434
  switch (e) {
1284
- case "x": return `translateX(${t})`;
1285
- case "y": return `translateY(${t})`;
1435
+ case "x": return `translate3d(${t}, 0, 0)`;
1436
+ case "y": return `translate3d(0, ${t}, 0)`;
1286
1437
  case "z": return `translateZ(${t})`;
1287
1438
  case "scale": return `scale(${t})`;
1288
1439
  case "scaleX": return `scaleX(${t})`;
@@ -1293,23 +1444,32 @@ var I = /* @__PURE__ */ new Map(), L = {
1293
1444
  case "rotateY": return `rotateY(${t})`;
1294
1445
  default: return "";
1295
1446
  }
1296
- }, Ae = (e) => {
1297
- let t = /* @__PURE__ */ new Set(), n = !1, r = (e) => {
1298
- if (ye(e)) for (let r of Object.keys(e)) {
1299
- let i = e[r];
1300
- Se(r, i) !== "" && (we.has(r) ? n = !0 : t.add(Ce(r)));
1447
+ }, Ge = (e) => {
1448
+ let t = /* @__PURE__ */ new Map(), n = !1, r = /* @__PURE__ */ new Set(), i = (e) => {
1449
+ if (!Pe(e)) return;
1450
+ let n = [];
1451
+ for (let r of Object.keys(e)) {
1452
+ let i = e[r], a = Le(r, i);
1453
+ if (a !== "") if (ze.has(r)) n.push(`${r}:${a}`);
1454
+ else {
1455
+ let e = t.get(Re(r)) ?? /* @__PURE__ */ new Set();
1456
+ e.add(a), t.set(Re(r), e);
1457
+ }
1301
1458
  }
1459
+ r.add(n.sort().join("|"));
1302
1460
  };
1303
- r(e.initial);
1304
- for (let t of Object.values(e.variants)) r(t.value);
1305
- return n && t.add("transform"), Array.from(t);
1306
- }, R = (e) => {
1307
- if (!ye(e)) return [];
1461
+ i(e.initial);
1462
+ for (let t of Object.values(e.variants)) i(t.value);
1463
+ n = r.size > 1;
1464
+ let a = Array.from(t.entries()).filter(([, e]) => e.size > 1).map(([e]) => e);
1465
+ return n && a.push("transform"), a;
1466
+ }, B = (e) => {
1467
+ if (!Pe(e)) return [];
1308
1468
  let t = [], n = !0, r = [];
1309
1469
  for (let i of Object.keys(e)) {
1310
- let a = e[i], o = Se(i, a);
1311
- o !== "" && (we.has(i) ? (t.push(ke(i, o)), Oe(i, a) || (n = !1)) : r.push({
1312
- property: Ce(i),
1470
+ let a = e[i], o = Le(i, a);
1471
+ o !== "" && (ze.has(i) ? (t.push(We(i, o)), Ue(i, a) || (n = !1)) : r.push({
1472
+ property: Re(i),
1313
1473
  value: o
1314
1474
  }));
1315
1475
  }
@@ -1317,7 +1477,7 @@ var I = /* @__PURE__ */ new Map(), L = {
1317
1477
  property: "transform",
1318
1478
  value: n ? "none" : t.join(" ")
1319
1479
  }), r;
1320
- }, z = (e) => e.map((e) => ` ${e.property}: ${e.value};`).join("\n"), B = (e) => Array.isArray(e) ? e.length === 4 && e.every((e) => typeof e == "number") ? `cubic-bezier(${e.join(", ")})` : "linear" : typeof e == "string" ? {
1480
+ }, V = (e) => e.map((e) => ` ${e.property}: ${e.value};`).join("\n"), H = (e) => Array.isArray(e) ? e.length === 4 && e.every((e) => typeof e == "number") ? `cubic-bezier(${e.join(", ")})` : "linear" : typeof e == "string" ? {
1321
1481
  linear: "linear",
1322
1482
  easeIn: "ease-in",
1323
1483
  easeOut: "ease-out",
@@ -1327,33 +1487,29 @@ var I = /* @__PURE__ */ new Map(), L = {
1327
1487
  backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
1328
1488
  backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
1329
1489
  anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
1330
- }[e] ?? "ease" : "ease", V = (e) => {
1331
- if (!e) return 0;
1332
- let t = e.duration;
1333
- return typeof t == "number" && t >= 0 ? t : 0;
1334
- }, je = (e) => e && typeof e.delay == "number" && e.delay > 0 ? e.delay : 0, Me = (e, t) => {
1490
+ }[e] ?? "ease" : "ease", Ke = (e, t) => {
1335
1491
  let [n, r] = t.split("-");
1336
1492
  return `[data-flemo-screen][data-flemo-transition="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
1337
- }, Ne = (e, t) => {
1493
+ }, qe = (e, t) => {
1338
1494
  let [n, r] = t.split("-");
1339
1495
  return `[data-flemo-decorator][data-flemo-decorator-name="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
1340
- }, Pe = (e, t) => {
1496
+ }, Je = (e, t) => {
1341
1497
  let [n, r] = t.split("-");
1342
1498
  return `[data-flemo-bar][data-flemo-bar-transition="${e}"][data-flemo-bar-status="${n}"][data-flemo-bar-active="${r}"][data-flemo-bar-riding="true"]`;
1343
- }, Fe = (e, t) => {
1499
+ }, Ye = (e, t) => {
1344
1500
  let [n, r] = t.split("-");
1345
1501
  return `[data-flemo-part-name="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
1346
- }, H = (e, t, n) => `flemo-${e}-${ve(t)}-${n}`, U = (e, t, n, r, i, a) => {
1347
- let o = R(r), s = R(i.value), c = V(i.options), l = je(i.options), u = B(i.options?.ease), d = a(t, n), f = e === "screen" ? `${d},\n${Pe(t, n)}` : d;
1502
+ }, Xe = (e, t, n) => `flemo-${e}-${Ne(t)}-${n}`, Ze = (e, t, n, r, i, a) => {
1503
+ let o = B(r), s = B(i.value), c = L(i.options), l = R(i.options), u = H(i.options?.ease), d = a(t, n), f = e === "screen" ? `${d},\n${Je(t, n)}` : d;
1348
1504
  if (s.length === 0 && o.length === 0) return "";
1349
- if (c <= 0 && l <= 0) return s.length === 0 ? "" : `${f} {\n${z(s)}\n animation: none;\n}`;
1350
- let p = H(e, t, n), m = [
1505
+ if (c <= 0 && l <= 0) return s.length === 0 ? "" : `${f} {\n${V(s)}\n animation: none;\n}`;
1506
+ let p = Xe(e, t, n), m = [
1351
1507
  `@keyframes ${p} {`,
1352
1508
  " from {",
1353
- z(o).replace(/^/gm, " "),
1509
+ V(o).replace(/^/gm, " "),
1354
1510
  " }",
1355
1511
  " to {",
1356
- z(s).replace(/^/gm, " "),
1512
+ V(s).replace(/^/gm, " "),
1357
1513
  " }",
1358
1514
  "}"
1359
1515
  ].join("\n"), h = [
@@ -1362,127 +1518,135 @@ var I = /* @__PURE__ */ new Map(), L = {
1362
1518
  u,
1363
1519
  l > 0 ? `${l}s` : null,
1364
1520
  "both"
1365
- ].filter(Boolean).join(" "), g = Array.from(new Set([...o.map((e) => e.property), ...s.map((e) => e.property)])), _ = g.length > 0 ? ` will-change: ${g.join(", ")};\n` : "", v = n.split("-")[0];
1366
- return `${m}\n${`${f} {\n animation: ${h};\n${_}${v === "PUSHING" || v === "REPLACING" ? " contain: layout;\n pointer-events: none;\n" : ""}}`}${e === "screen" && n.endsWith("-false") && Ie(r) && s.length > 0 ? `\n${d}[data-flemo-anim-hold="park"] {\n animation: none;\n${z(s)}\n}` : ""}`;
1367
- }, Ie = (e) => {
1521
+ ].filter(Boolean).join(" "), g = new Map(o.map((e) => [e.property, e.value])), _ = new Map(s.map((e) => [e.property, e.value])), v = Array.from(new Set([...g.keys(), ..._.keys()])).filter((e) => g.get(e) !== _.get(e)), y = v.length > 0 ? ` will-change: ${v.join(", ")};\n` : "", b = n.split("-")[0];
1522
+ return `${m}\n${`${f} {\n animation: ${h};\n${y}${b === "PUSHING" || b === "REPLACING" ? " contain: layout;\n pointer-events: none;\n" : ""}}`}${e === "screen" && n.endsWith("-false") && Qe(r) && s.length > 0 ? `\n${d}[data-flemo-anim-hold="park"] {\n animation: none;\n${V(s)}\n}` : ""}${e === "screen" && n.endsWith("-true") && (n.startsWith("PUSHING") || n.startsWith("REPLACING")) && Qe(r) && s.length > 0 ? `\n${d}[data-flemo-anim-hold="park-under"] {\n animation: none;\n${V(s)}\n}` : ""}`;
1523
+ }, Qe = (e) => {
1368
1524
  if (!e) return !1;
1369
1525
  if (e.opacity === 0) return !0;
1370
1526
  let t = (e) => typeof e == "string" && e.trim().endsWith("%") && Math.abs(parseFloat(e)) >= 100;
1371
1527
  return t(e.x) || t(e.y);
1372
- }, W = (e, t, n, r) => {
1373
- let i = R(r.value);
1374
- return i.length === 0 ? "" : `${e(t, n)} {\n${z(i)}\n}`;
1375
- }, Le = (e, t, n = []) => {
1528
+ }, $e = (e, t, n, r) => {
1529
+ let i = B(r.value);
1530
+ return i.length === 0 ? "" : `${e(t, n)} {\n${V(i)}\n}`;
1531
+ }, et = (e, t, n = []) => {
1376
1532
  let r = [];
1377
1533
  for (let t of e) {
1378
1534
  let e = t.name;
1379
- for (let n of ge) {
1380
- let i = t.variants[n], a = L[n];
1535
+ for (let n of Ae) {
1536
+ let i = t.variants[n], a = I[n];
1381
1537
  if (a === "self") {
1382
- r.push(W(Me, e, n, i));
1538
+ r.push($e(Ke, e, n, i));
1383
1539
  continue;
1384
1540
  }
1385
1541
  let o = a === "initial" ? t.initial : t.variants[a].value;
1386
- r.push(U("screen", e, n, o, i, Me));
1542
+ r.push(Ze("screen", e, n, o, i, Ke));
1387
1543
  }
1388
1544
  }
1389
1545
  for (let e of t) {
1390
1546
  let t = e.name;
1391
- for (let n of _e) {
1392
- let i = e.variants[n], a = L[n];
1547
+ for (let n of Me) {
1548
+ let i = e.variants[n], a = I[n];
1393
1549
  if (a === "self") {
1394
- r.push(W(Ne, t, n, i));
1550
+ r.push($e(qe, t, n, i));
1395
1551
  continue;
1396
1552
  }
1397
1553
  let o = a === "initial" ? e.initial : e.variants[a].value;
1398
- r.push(U("decorator", t, n, o, i, Ne));
1554
+ r.push(Ze("decorator", t, n, o, i, qe));
1399
1555
  }
1400
1556
  }
1401
1557
  for (let e of n) {
1402
1558
  let t = e.name;
1403
- for (let n of _e) {
1404
- let i = e.variants[n], a = L[n];
1559
+ for (let n of Me) {
1560
+ let i = e.variants[n], a = I[n];
1405
1561
  if (a === "self") {
1406
- r.push(W(Fe, t, n, i));
1562
+ r.push($e(Ye, t, n, i));
1407
1563
  continue;
1408
1564
  }
1409
1565
  let o = a === "initial" ? e.initial : e.variants[a].value;
1410
- r.push(U("part", t, n, o, i, Fe));
1566
+ r.push(Ze("part", t, n, o, i, Ye));
1411
1567
  }
1412
1568
  }
1413
- return [...r.filter((e) => e.length > 0), Re].join("\n\n");
1414
- }, Re = [
1569
+ return [...r.filter((e) => e.length > 0), tt].join("\n\n");
1570
+ }, tt = [
1415
1571
  "[data-flemo-anim-hold=\"true\"],",
1416
1572
  "[data-flemo-anim-hold=\"park\"],",
1573
+ "[data-flemo-anim-hold=\"park-under\"],",
1417
1574
  "[data-flemo-anim-hold=\"true\"] [data-flemo-part-name],",
1418
- "[data-flemo-anim-hold=\"park\"] [data-flemo-part-name] {",
1575
+ "[data-flemo-anim-hold=\"park\"] [data-flemo-part-name],",
1576
+ "[data-flemo-anim-hold=\"park-under\"] [data-flemo-part-name] {",
1419
1577
  " animation-play-state: paused !important;",
1420
1578
  "}"
1421
- ].join("\n"), ze = (e, t) => {
1422
- let n = L[t];
1579
+ ].join("\n"), nt = (e, t) => {
1580
+ let n = I[t];
1423
1581
  if (n === "self") return !1;
1424
- let r = e.variants[t], i = V(r.options), a = je(r.options);
1582
+ let r = e.variants[t], i = L(r.options), a = R(r.options);
1425
1583
  if (i <= 0 && a <= 0) return !1;
1426
- let o = R(n === "initial" ? e.initial : e.variants[n].value), s = R(r.value);
1584
+ let o = B(n === "initial" ? e.initial : e.variants[n].value), s = B(r.value);
1427
1585
  return o.length > 0 || s.length > 0;
1428
- }, Be = "data-flemo";
1429
- function G() {
1430
- if (u()) return;
1431
- let e = Le(N.values(), F.values(), I.values()), t = document.head.querySelector(`style[${Be}]`);
1432
- t || (t = document.createElement("style"), t.setAttribute(Be, ""), document.head.appendChild(t)), t.textContent !== e && (t.textContent = e);
1586
+ }, rt = "data-flemo";
1587
+ function it() {
1588
+ if (d()) return;
1589
+ let e = et(j.values(), P.values(), F.values()), t = document.head.querySelector(`style[${rt}]`);
1590
+ t || (t = document.createElement("style"), t.setAttribute(rt, ""), document.head.appendChild(t)), t.textContent !== e && (t.textContent = e);
1433
1591
  }
1434
1592
  //#endregion
1435
1593
  //#region src/transition/registerTransitionDefinitions.ts
1436
- function Ve(e, t, n = []) {
1437
- for (let t of e) N.set(t.name, t);
1438
- for (let e of t) F.set(e.name, e);
1439
- for (let e of n) I.set(e.name, e);
1440
- return G(), () => {
1441
- for (let t of e) N.delete(t.name);
1442
- for (let e of t) F.delete(e.name);
1443
- for (let e of n) I.delete(e.name);
1444
- G();
1594
+ var at = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Map(), st = /* @__PURE__ */ new Map(), ct = (e, t) => {
1595
+ e.set(t, (e.get(t) ?? 0) + 1);
1596
+ }, lt = (e, t) => {
1597
+ let n = (e.get(t) ?? 1) - 1;
1598
+ return n <= 0 ? (e.delete(t), !0) : (e.set(t, n), !1);
1599
+ };
1600
+ function ut(e, t, n = []) {
1601
+ for (let t of e) j.set(t.name, t), ct(at, t.name);
1602
+ for (let e of t) P.set(e.name, e), ct(ot, e.name);
1603
+ for (let e of n) F.set(e.name, e), ct(st, e.name);
1604
+ return it(), () => {
1605
+ for (let t of e) lt(at, t.name) && j.delete(t.name);
1606
+ for (let e of t) lt(ot, e.name) && P.delete(e.name);
1607
+ for (let e of n) lt(st, e.name) && F.delete(e.name);
1608
+ it();
1445
1609
  };
1446
1610
  }
1447
1611
  //#endregion
1448
1612
  //#region src/transition/enteringInitialStyle.ts
1449
- function He(e) {
1613
+ function dt(e) {
1450
1614
  let { initial: t, isActive: n, status: r } = e;
1451
1615
  if (!n || r !== "PUSHING" && r !== "REPLACING") return {};
1452
1616
  let i = {};
1453
- return typeof t.x == "number" && (i.transform = `translateX(${t.x}px)`), typeof t.x == "string" && (i.transform = `translateX(${t.x})`), typeof t.y == "number" && (i.transform = `translateY(${t.y}px)`), typeof t.y == "string" && (i.transform = `translateY(${t.y})`), typeof t.opacity == "number" && (i.opacity = `${t.opacity}`), i;
1617
+ return typeof t.x == "number" && (i.transform = `translate3d(${t.x}px, 0, 0)`), typeof t.x == "string" && (i.transform = `translate3d(${t.x}, 0, 0)`), typeof t.y == "number" && (i.transform = `translate3d(0, ${t.y}px, 0)`), typeof t.y == "string" && (i.transform = `translate3d(0, ${t.y}, 0)`), typeof t.opacity == "number" && (i.opacity = `${t.opacity}`), i;
1454
1618
  }
1455
1619
  //#endregion
1456
1620
  //#region src/transition/animateInline.ts
1457
- var Ue = (e) => typeof HTMLElement < "u" && e instanceof HTMLElement, K = /* @__PURE__ */ new WeakMap(), We = (e, t) => {
1458
- let n = K.get(e);
1459
- n || (n = /* @__PURE__ */ new Set(), K.set(e, n)), n.add(t);
1460
- }, q = (e, t) => {
1621
+ var ft = (e) => typeof HTMLElement < "u" && e instanceof HTMLElement, U = /* @__PURE__ */ new WeakMap(), W = (e, t) => {
1622
+ let n = U.get(e);
1623
+ n || (n = /* @__PURE__ */ new Set(), U.set(e, n)), n.add(t);
1624
+ }, G = (e, t) => {
1461
1625
  if (e.style.transition = "", t) {
1462
- let n = K.get(e);
1626
+ let n = U.get(e);
1463
1627
  for (let r of t) e.style.removeProperty(r), n?.delete(r);
1464
1628
  return;
1465
1629
  }
1466
- let n = K.get(e);
1630
+ let n = U.get(e);
1467
1631
  if (n && n.size > 0) {
1468
1632
  for (let t of n) e.style.removeProperty(t);
1469
1633
  n.clear();
1470
1634
  return;
1471
1635
  }
1472
1636
  e.style.removeProperty("transform"), e.style.removeProperty("opacity");
1473
- }, J = (e, t, n = {}) => {
1474
- if (!Ue(e)) return Promise.resolve();
1475
- let r = e, i = R(t);
1637
+ }, K = (e, t, n = {}) => {
1638
+ if (!ft(e)) return Promise.resolve();
1639
+ let r = e, i = B(t);
1476
1640
  if (i.length === 0) return Promise.resolve();
1477
- let a = typeof n.duration == "number" ? n.duration : 0, o = typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, s = B(n.ease);
1641
+ let a = typeof n.duration == "number" ? n.duration : 0, o = typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, s = H(n.ease);
1478
1642
  if (a <= 0 && o <= 0) {
1479
1643
  r.style.transition = "none";
1480
- for (let e of i) r.style.setProperty(e.property, e.value), We(r, e.property);
1644
+ for (let e of i) r.style.setProperty(e.property, e.value), W(r, e.property);
1481
1645
  return Promise.resolve();
1482
1646
  }
1483
1647
  let c = i.map((e) => `${e.property} ${a}s ${s} ${o}s`).join(", ");
1484
1648
  r.style.transition = c, r.offsetWidth;
1485
- for (let e of i) r.style.setProperty(e.property, e.value), We(r, e.property);
1649
+ for (let e of i) r.style.setProperty(e.property, e.value), W(r, e.property);
1486
1650
  return new Promise((e) => {
1487
1651
  let t = !1, n = () => {
1488
1652
  t || (t = !0, r.removeEventListener("transitionend", i), e());
@@ -1491,38 +1655,426 @@ var Ue = (e) => typeof HTMLElement < "u" && e instanceof HTMLElement, K = /* @__
1491
1655
  };
1492
1656
  r.addEventListener("transitionend", i), setTimeout(n, (a + o) * 1e3 + 60);
1493
1657
  });
1494
- }, Y = "data-flemo-skip-animation", X = () => {};
1495
- function Ge(e) {
1658
+ }, pt = "flemo:motion-driver", mt = "flemo:motion-driver-force", ht = !1, gt = () => {
1659
+ try {
1660
+ if (typeof localStorage > "u") return null;
1661
+ let e = localStorage.getItem(mt);
1662
+ return e !== "css" && e !== "raf" ? null : (!ht && typeof console < "u" && (ht = !0, console.warn(`[flemo] motion driver pinned to "${e}" via localStorage ${mt}; remove the key to restore automatic selection.`)), e);
1663
+ } catch {
1664
+ return null;
1665
+ }
1666
+ }, _t = () => ({
1667
+ read: () => {
1668
+ try {
1669
+ return typeof localStorage < "u" ? localStorage.getItem(pt) : null;
1670
+ } catch {
1671
+ return null;
1672
+ }
1673
+ },
1674
+ write: (e) => {
1675
+ try {
1676
+ typeof localStorage < "u" && localStorage.setItem(pt, e);
1677
+ } catch {}
1678
+ }
1679
+ }), vt = 30, yt = 2, bt = 2, q = ((e = _t()) => {
1680
+ let t = e.read() === "css", n = t;
1681
+ t &&= !1;
1682
+ let r = 0, i = 0, a = [];
1683
+ return {
1684
+ playerAllowed: () => {
1685
+ let e = gt();
1686
+ return e ? e === "raf" : !t;
1687
+ },
1688
+ beginRun: () => {
1689
+ i = 0, a = [];
1690
+ },
1691
+ reportGap: (e) => {
1692
+ a.push(e), e >= vt && (i += 1);
1693
+ },
1694
+ endRun: () => {
1695
+ let a = i >= yt;
1696
+ if (n) {
1697
+ n = !1, a ? t = !0 : e.write("raf");
1698
+ return;
1699
+ }
1700
+ a && (r += 1, r >= bt && !t && (t = !0, e.write("css")));
1701
+ },
1702
+ stats: () => ({
1703
+ runGaps: [...a],
1704
+ strikes: r,
1705
+ demoted: t
1706
+ })
1707
+ };
1708
+ })(), xt = (e, t, n, r) => {
1709
+ let i = (t) => 3 * (1 - t) * (1 - t) * t * e + 3 * (1 - t) * t * t * n + t ** 3, a = (e) => 3 * (1 - e) * (1 - e) * e * t + 3 * (1 - e) * e * e * r + e ** 3;
1710
+ return (e) => {
1711
+ if (e <= 0) return 0;
1712
+ if (e >= 1) return 1;
1713
+ let t = 0, n = 1;
1714
+ for (let r = 0; r < 40; r++) {
1715
+ let r = (t + n) / 2;
1716
+ i(r) < e ? t = r : n = r;
1717
+ }
1718
+ return a((t + n) / 2);
1719
+ };
1720
+ }, St = (e) => e, Ct = {
1721
+ ease: [
1722
+ .25,
1723
+ .1,
1724
+ .25,
1725
+ 1
1726
+ ],
1727
+ easeIn: [
1728
+ .42,
1729
+ 0,
1730
+ 1,
1731
+ 1
1732
+ ],
1733
+ easeOut: [
1734
+ 0,
1735
+ 0,
1736
+ .58,
1737
+ 1
1738
+ ],
1739
+ easeInOut: [
1740
+ .42,
1741
+ 0,
1742
+ .58,
1743
+ 1
1744
+ ],
1745
+ circIn: [
1746
+ 0,
1747
+ .55,
1748
+ .45,
1749
+ 1
1750
+ ],
1751
+ circOut: [
1752
+ .55,
1753
+ 0,
1754
+ 1,
1755
+ .45
1756
+ ],
1757
+ backIn: [
1758
+ .31,
1759
+ .01,
1760
+ .66,
1761
+ -.59
1762
+ ],
1763
+ backOut: [
1764
+ .33,
1765
+ 1.53,
1766
+ .69,
1767
+ .99
1768
+ ],
1769
+ anticipate: [
1770
+ .36,
1771
+ 0,
1772
+ .66,
1773
+ -.56
1774
+ ]
1775
+ }, wt = (e) => {
1776
+ if (Array.isArray(e)) {
1777
+ if (e.length === 4 && e.every((e) => typeof e == "number")) {
1778
+ let [t, n, r, i] = e;
1779
+ return xt(t, n, r, i);
1780
+ }
1781
+ return St;
1782
+ }
1783
+ return typeof e == "string" ? e === "linear" ? St : xt(...Ct[e] ?? Ct.ease) : xt(...Ct.ease);
1784
+ }, Tt = [
1785
+ "x",
1786
+ "y",
1787
+ "z",
1788
+ "scale",
1789
+ "scaleX",
1790
+ "scaleY",
1791
+ "rotate",
1792
+ "rotateX",
1793
+ "rotateY",
1794
+ "rotateZ"
1795
+ ], Et = new Set(Tt), Dt = {
1796
+ x: 0,
1797
+ y: 0,
1798
+ z: 0,
1799
+ scale: 1,
1800
+ scaleX: 1,
1801
+ scaleY: 1,
1802
+ rotate: 0,
1803
+ rotateX: 0,
1804
+ rotateY: 0,
1805
+ rotateZ: 0
1806
+ }, Ot = (e, t) => {
1807
+ if (typeof t == "number") return {
1808
+ value: t,
1809
+ unit: e === "x" || e === "y" || e === "z" ? "px" : ""
1810
+ };
1811
+ if (typeof t != "string") return null;
1812
+ let n = t.trim(), r = /^(-?\d*\.?\d+)(px|%|deg)?$/.exec(n);
1813
+ if (!r) return null;
1814
+ let i = parseFloat(r[1]), a = r[2] ?? "";
1815
+ return e === "rotate" || e === "rotateX" || e === "rotateY" || e === "rotateZ" ? a !== "deg" && !(a === "" && i === 0) ? null : {
1816
+ value: i,
1817
+ unit: ""
1818
+ } : e === "scale" || e === "scaleX" || e === "scaleY" ? a === "" ? {
1819
+ value: i,
1820
+ unit: ""
1821
+ } : null : a === "deg" ? null : {
1822
+ value: i,
1823
+ unit: a === "" && i === 0 ? "px" : a
1824
+ };
1825
+ }, J = /-?\d*\.?\d+/g, kt = (e, t) => {
1826
+ let n = e.match(J) ?? [], r = t.match(J) ?? [];
1827
+ if (n.length !== r.length || e.replace(J, "\0") !== t.replace(J, "\0")) return null;
1828
+ let i = n.map(Number), a = r.map(Number);
1829
+ return (t) => {
1830
+ let n = 0;
1831
+ return e.replace(J, () => {
1832
+ let e = n++, r = i[e] + (a[e] - i[e]) * t;
1833
+ return `${Math.round(r * 1e3) / 1e3}`;
1834
+ });
1835
+ };
1836
+ }, At = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), jt = (e) => typeof e == "object" && !!e && !Array.isArray(e), Mt = (e) => jt(e) ? Object.keys(e) : [], Nt = (e, t) => jt(e) ? e[t] : void 0, Pt = (e) => Ft(e, null) !== null, Ft = (e, t) => {
1837
+ let n = new Set([...Mt(e.from), ...Mt(e.to)]), r = [], i = null, a = [], o = [];
1838
+ for (let s of n) {
1839
+ let n = Nt(e.from, s), c = Nt(e.to, s);
1840
+ if (Et.has(s)) {
1841
+ let e = s, i = {
1842
+ value: Dt[e],
1843
+ unit: e === "x" || e === "y" || e === "z" ? "px" : ""
1844
+ }, a = n === void 0 ? i : Ot(e, n), o = c === void 0 ? i : Ot(e, c);
1845
+ if (!a || !o || a.unit !== o.unit && a.value !== 0 && o.value !== 0) return null;
1846
+ let l = a.value === 0 && a.unit !== o.unit ? o.unit : a.unit, u = l === "%", d = 0;
1847
+ u && t && (d = e === "y" ? t.offsetHeight / 100 : t.offsetWidth / 100), r.push({
1848
+ prop: e,
1849
+ from: {
1850
+ value: a.value,
1851
+ unit: l
1852
+ },
1853
+ to: {
1854
+ value: o.value,
1855
+ unit: l
1856
+ },
1857
+ percentBase: d
1858
+ });
1859
+ continue;
1860
+ }
1861
+ if (s === "opacity") {
1862
+ let e = n === void 0 ? 1 : n, t = c === void 0 ? 1 : c;
1863
+ if (typeof e != "number" || typeof t != "number") return null;
1864
+ i = {
1865
+ from: e,
1866
+ to: t
1867
+ };
1868
+ continue;
1869
+ }
1870
+ if (n === void 0 || c === void 0) return null;
1871
+ let l = typeof n == "number" ? `${n}` : n, u = typeof c == "number" ? `${c}` : c;
1872
+ if (typeof l != "string" || typeof u != "string") return null;
1873
+ if (l === u) {
1874
+ o.push({
1875
+ property: At(s),
1876
+ value: l
1877
+ });
1878
+ continue;
1879
+ }
1880
+ let d = kt(l, u);
1881
+ if (!d) return null;
1882
+ a.push({
1883
+ property: At(s),
1884
+ mix: d
1885
+ });
1886
+ }
1887
+ return {
1888
+ transforms: r,
1889
+ opacity: i,
1890
+ strings: a,
1891
+ constants: o
1892
+ };
1893
+ }, It = 1, Lt = (e, t, n, r) => {
1894
+ let i = 0, a = 0, o = !1, s = [], c = !0;
1895
+ for (let l of Tt) {
1896
+ let u = e.find((e) => e.prop === l);
1897
+ if (!u) continue;
1898
+ let d = u.from.value + (u.to.value - u.from.value) * t;
1899
+ if (u.from.unit === "%" && (d *= u.percentBase), l === "x" || l === "y") {
1900
+ let e = l === "x" ? r.x : r.y, t = (e === null || Math.abs(d - e) * n >= It) && n > 0 ? Math.round(d * n) / n : Math.round(d * 1e3) / 1e3;
1901
+ l === "x" ? (r.x = d, i = t) : (r.y = d, a = t), o = !0, t !== 0 && (c = !1);
1902
+ continue;
1903
+ }
1904
+ let f = Dt[l];
1905
+ d !== f && (c = !1), l === "z" ? s.push(`translateZ(${d}px)`) : l === "scale" ? s.push(`scale(${d})`) : l === "scaleX" ? s.push(`scaleX(${d})`) : l === "scaleY" ? s.push(`scaleY(${d})`) : l === "rotate" || l === "rotateZ" ? s.push(`rotate(${d}deg)`) : l === "rotateX" ? s.push(`rotateX(${d}deg)`) : l === "rotateY" && s.push(`rotateY(${d}deg)`);
1906
+ }
1907
+ return !o && s.length === 0 ? "" : c ? "none" : [...o ? [`translate3d(${i}px, ${a}px, 0)`] : [], ...s].join(" ");
1908
+ }, Rt = () => ({
1909
+ request: (e) => requestAnimationFrame(e),
1910
+ cancel: (e) => cancelAnimationFrame(e),
1911
+ devicePixelRatio: () => typeof window < "u" && window.devicePixelRatio || 1
1912
+ }), Y = ((e = Rt()) => {
1913
+ let t = /* @__PURE__ */ new Map(), n = {
1914
+ join: (n, r) => {
1915
+ let i = Ft(r.motion, r.element);
1916
+ if (!i) return null;
1917
+ let s = t.get(n);
1918
+ s || (s = {
1919
+ tracks: [],
1920
+ started: !1,
1921
+ startTime: null,
1922
+ lastTime: null,
1923
+ frameHandle: null
1924
+ }, t.set(n, s));
1925
+ let c = {
1926
+ ...r,
1927
+ parsed: i,
1928
+ completed: !1,
1929
+ detached: !1,
1930
+ snapMemory: {
1931
+ x: null,
1932
+ y: null
1933
+ }
1934
+ };
1935
+ s.tracks.push(c), c.element.style.animation = "none", W(c.element, "animation"), i.transforms.length > 0 && W(c.element, "transform"), i.opacity && W(c.element, "opacity");
1936
+ for (let e of i.strings) W(c.element, e.property);
1937
+ for (let e of i.constants) W(c.element, e.property);
1938
+ return a(c, 0), r.role === "active" && !s.started && (s.started = !0, q.beginRun(), o(n, s)), () => {
1939
+ c.detached = !0, G(c.element);
1940
+ let r = t.get(n);
1941
+ r && (r.tracks = r.tracks.filter((e) => e !== c), r.tracks.length === 0 && (r.frameHandle !== null && e.cancel(r.frameHandle), t.delete(n)));
1942
+ };
1943
+ },
1944
+ dispose: (n) => {
1945
+ let r = t.get(n);
1946
+ r && (r.frameHandle !== null && e.cancel(r.frameHandle), t.delete(n));
1947
+ }
1948
+ }, r = /* @__PURE__ */ new WeakMap(), i = (e) => {
1949
+ let t = r.get(e);
1950
+ return t || (t = wt(e.motion.ease), r.set(e, t)), t;
1951
+ };
1952
+ function a(t, n) {
1953
+ let { element: r, parsed: i } = t;
1954
+ if (r.isConnected) {
1955
+ if (i.transforms.length > 0) {
1956
+ let a = Lt(i.transforms, n, e.devicePixelRatio(), t.snapMemory);
1957
+ a !== "" && (r.style.transform = a);
1958
+ }
1959
+ if (i.opacity) {
1960
+ let { from: e, to: t } = i.opacity;
1961
+ r.style.opacity = `${e + (t - e) * n}`;
1962
+ }
1963
+ for (let e of i.strings) r.style.setProperty(e.property, e.mix(n));
1964
+ if (n === 0) for (let e of i.constants) r.style.setProperty(e.property, e.value);
1965
+ }
1966
+ }
1967
+ function o(t, n) {
1968
+ n.frameHandle = e.request((e) => {
1969
+ n.frameHandle = null, s(t, n, e);
1970
+ });
1971
+ }
1972
+ function s(e, r, s) {
1973
+ r.startTime === null && (r.startTime = s), r.lastTime !== null && (q.reportGap(s - r.lastTime), n.onFrameGap?.(s - r.lastTime)), r.lastTime = s;
1974
+ let c = !0;
1975
+ for (let e of r.tracks) {
1976
+ if (e.completed || e.detached) continue;
1977
+ let t = e.motion.duration * 1e3, n = e.motion.delay * 1e3, o = t <= 0 ? 1 : Math.min(1, Math.max(0, (s - r.startTime - n) / t));
1978
+ a(e, i(e)(o)), o >= 1 ? (e.completed = !0, e.onComplete?.()) : c = !1;
1979
+ }
1980
+ if (c) {
1981
+ q.endRun(), t.delete(e);
1982
+ return;
1983
+ }
1984
+ o(e, r);
1985
+ }
1986
+ return n;
1987
+ })();
1988
+ Y.onFrameGap = (e) => {
1989
+ if (typeof window < "u") {
1990
+ let t = window.__flemoPlayerGaps ??= [];
1991
+ t.push(Math.round(e * 10) / 10), t.length > 600 && t.splice(0, t.length - 600);
1992
+ }
1993
+ };
1994
+ //#endregion
1995
+ //#region src/core/engine/types.ts
1996
+ var X = "data-flemo-skip-animation", Z = () => {};
1997
+ function zt(e) {
1496
1998
  return { driveScreenLifecycle: (t) => {
1497
- let { getElements: n, transitionName: r, prevTransitionName: i, status: o, isActive: s } = t;
1498
- if (!s) return o === "REPLACING" && i !== r && e.setReplaceTransitionStatus("PENDING"), X;
1499
- if (o === "COMPLETED") {
1999
+ let { getElements: n, transitionName: r, prevTransitionName: i, status: a, isActive: s, animHoldReleased: c } = t, l = a === "PUSHING" || a === "POPPING" || a === "REPLACING", u = (t, i, a) => {
2000
+ let s = e.getTransitionTaskId();
2001
+ if (!s || o.pendingTaskIds.some((e) => e !== s) || !q.playerAllowed()) return null;
2002
+ let { scope: c, decorator: l, bars: u } = n();
2003
+ if (!c) return null;
2004
+ let d = M(r), f = z(d, t);
2005
+ if (!f || !Pt(f)) return null;
2006
+ let p = [], m = Y.join(s, {
2007
+ element: c,
2008
+ motion: f,
2009
+ role: i,
2010
+ onComplete: a
2011
+ });
2012
+ if (!m) return null;
2013
+ p.push(m);
2014
+ for (let e of u ?? []) {
2015
+ if (!e || e.getAttribute("data-flemo-bar-riding") !== "true") continue;
2016
+ let t = Y.join(s, {
2017
+ element: e,
2018
+ motion: f,
2019
+ role: "passive"
2020
+ });
2021
+ t && p.push(t);
2022
+ }
2023
+ if (l && d.decoratorName) {
2024
+ let e = P.get(d.decoratorName), n = e ? z(e, t) : null;
2025
+ if (n && Pt(n)) {
2026
+ let e = Y.join(s, {
2027
+ element: l,
2028
+ motion: n,
2029
+ role: "passive"
2030
+ });
2031
+ e && p.push(e);
2032
+ }
2033
+ }
2034
+ return () => p.forEach((e) => e());
2035
+ };
2036
+ if (!s) {
2037
+ if (a === "COMPLETED") {
2038
+ let { scope: e, decorator: t, bars: r } = n();
2039
+ e && G(e), t && G(t);
2040
+ for (let e of r ?? []) e && G(e);
2041
+ return Z;
2042
+ }
2043
+ if (a === "REPLACING" && i !== r && e.setReplaceTransitionStatus("PENDING"), l && c) {
2044
+ let e = u(`${a}-false`, "passive");
2045
+ if (e) return e;
2046
+ }
2047
+ return Z;
2048
+ }
2049
+ if (a === "COMPLETED") {
1500
2050
  e.setDragStatus("IDLE"), e.setReplaceTransitionStatus("IDLE");
1501
2051
  let { scope: t, decorator: r, bars: i } = n();
1502
- t && (q(t), t.removeAttribute(Y)), r && (q(r), r.removeAttribute(Y));
1503
- for (let e of i ?? []) e && (q(e), e.style.removeProperty("will-change"));
1504
- return X;
2052
+ t && (G(t), t.removeAttribute(X)), r && (G(r), r.removeAttribute(X));
2053
+ for (let e of i ?? []) e && (G(e), e.style.removeProperty("will-change"));
2054
+ return Z;
1505
2055
  }
1506
- if (o === "IDLE") return X;
1507
- let { scope: c } = n();
1508
- if (!c) return X;
1509
- let l = () => {
2056
+ if (a === "IDLE") return Z;
2057
+ let { scope: d } = n();
2058
+ if (!d) return Z;
2059
+ let f = () => {
1510
2060
  let t = e.getTransitionTaskId();
1511
- t && a.resolveTask(t);
1512
- }, u = ue(r), d = `${o}-true`;
1513
- if (!(c.getAttribute("data-flemo-skip-animation") !== "true" && ze(u, d))) return queueMicrotask(l), X;
1514
- let f = H("screen", r, d), p = (e) => {
1515
- e.target === c && e.animationName === f && (c.removeEventListener("animationend", p), l());
2061
+ t && o.resolveTask(t);
2062
+ }, p = M(r), m = `${a}-true`, h = d.getAttribute(X) === "true";
2063
+ if (!(!h && nt(p, m))) return queueMicrotask(f), Z;
2064
+ let g = z(p, m), _ = !h && !!g && Pt(g), v = Xe("screen", r, m), y = (e) => {
2065
+ e.target === d && e.animationName === v && (d.removeEventListener("animationend", y), f());
1516
2066
  };
1517
- return c.addEventListener("animationend", p), () => {
1518
- c.removeEventListener("animationend", p);
2067
+ d.addEventListener("animationend", y);
2068
+ let b = _ && c ? u(m, "active", f) : null, x = e.getTransitionTaskId(), S = ((g?.delay ?? 0) + (g?.duration ?? .6)) * 1e3 + 1500, C = x ? setTimeout(() => void o.resolveTask(x), S) : void 0;
2069
+ return () => {
2070
+ C !== void 0 && clearTimeout(C), d.removeEventListener("animationend", y), b?.();
1519
2071
  };
1520
2072
  } };
1521
2073
  }
1522
2074
  //#endregion
1523
2075
  //#region src/utils/findScrollable.ts
1524
- function Z(e, t) {
1525
- let { direction: n = "x", markerSelector: r = "[data-swipe-at-edge]", depthLimit: i = 24, verifyByScroll: a = !1 } = t ?? {}, o = Ke(e);
2076
+ function Bt(e, t) {
2077
+ let { direction: n = "x", markerSelector: r = "[data-swipe-at-edge]", depthLimit: i = 24, verifyByScroll: a = !1 } = t ?? {}, o = Vt(e);
1526
2078
  if (!o) return {
1527
2079
  element: null,
1528
2080
  hasMarker: !1
@@ -1545,7 +2097,7 @@ function Z(e, t) {
1545
2097
  hasMarker: !1
1546
2098
  };
1547
2099
  }
1548
- function Ke(e) {
2100
+ function Vt(e) {
1549
2101
  if (!e) return null;
1550
2102
  let t = e, n = typeof t.composedPath == "function" ? t.composedPath() : void 0;
1551
2103
  if (n && n.length) {
@@ -1563,8 +2115,8 @@ function $(e, t) {
1563
2115
  }
1564
2116
  //#endregion
1565
2117
  //#region src/core/engine/createSwipeController.ts
1566
- var qe = "data-flemo-skip-animation";
1567
- function Je(e) {
2118
+ var Ht = "data-flemo-skip-animation";
2119
+ function Ut(e) {
1568
2120
  let t = null, n = null, r = {
1569
2121
  current: [],
1570
2122
  prev: []
@@ -1610,9 +2162,9 @@ function Je(e) {
1610
2162
  y: e.clientY
1611
2163
  }, u = t;
1612
2164
  }, v = (n, i, a) => {
1613
- let o = J(n, i, a);
1614
- if (n === e.getElements().scope) for (let e of r.current) J(e, i, a);
1615
- else if (n === t) for (let e of r.prev) J(e, i, a);
2165
+ let o = K(n, i, a);
2166
+ if (n === e.getElements().scope) for (let e of r.current) K(e, i, a);
2167
+ else if (n === t) for (let e of r.prev) K(e, i, a);
1616
2168
  return o;
1617
2169
  }, y = (t) => {
1618
2170
  let n = e.getPartnerBars(), i = [], { sharedTopBar: a, sharedBottomBar: o } = e.getElements();
@@ -1626,12 +2178,12 @@ function Je(e) {
1626
2178
  current: i,
1627
2179
  prev: s
1628
2180
  };
1629
- let c = Ae(e.getTransition()).join(", ");
2181
+ let c = Ge(e.getTransition()).join(", ");
1630
2182
  for (let e of i) e.style.willChange = c;
1631
2183
  for (let e of s) e.style.willChange = c;
1632
2184
  }, b = () => {
1633
- for (let e of r.current) q(e), e.style.removeProperty("will-change");
1634
- for (let e of r.prev) q(e), e.style.removeProperty("will-change");
2185
+ for (let e of r.current) G(e), e.style.removeProperty("will-change");
2186
+ for (let e of r.prev) G(e), e.style.removeProperty("will-change");
1635
2187
  r = {
1636
2188
  current: [],
1637
2189
  prev: []
@@ -1644,10 +2196,10 @@ function Je(e) {
1644
2196
  };
1645
2197
  }, S = (e, t, n) => {
1646
2198
  let r = (r, i) => {
1647
- let a = I.get(r.getAttribute("data-flemo-part-name"));
2199
+ let a = F.get(r.getAttribute("data-flemo-part-name"));
1648
2200
  if (!a) return;
1649
2201
  let o = {
1650
- animate: J,
2202
+ animate: K,
1651
2203
  element: r,
1652
2204
  active: i
1653
2205
  };
@@ -1656,7 +2208,7 @@ function Je(e) {
1656
2208
  for (let e of i.current) r(e, !0);
1657
2209
  for (let e of i.prev) r(e, !1);
1658
2210
  }, C = () => {
1659
- for (let e of [...i.current, ...i.prev]) q(e);
2211
+ for (let e of [...i.current, ...i.prev]) G(e);
1660
2212
  i = {
1661
2213
  current: [],
1662
2214
  prev: []
@@ -1685,7 +2237,7 @@ function Je(e) {
1685
2237
  prevScreen: t,
1686
2238
  onStart: (e) => {
1687
2239
  m?.onSwipeStart?.(e, {
1688
- animate: J,
2240
+ animate: K,
1689
2241
  currentDecorator: f,
1690
2242
  prevDecorator: n
1691
2243
  }), S("start", e, 0);
@@ -1702,7 +2254,7 @@ function Je(e) {
1702
2254
  prevScreen: t,
1703
2255
  onProgress: (e, t) => {
1704
2256
  c?.onSwipe?.(e, t, {
1705
- animate: J,
2257
+ animate: K,
1706
2258
  currentDecorator: o,
1707
2259
  prevDecorator: n
1708
2260
  }), S("swipe", e, t);
@@ -1721,32 +2273,32 @@ function Je(e) {
1721
2273
  prevScreen: t,
1722
2274
  onStart: (e) => {
1723
2275
  u?.onSwipeEnd?.(e, {
1724
- animate: J,
2276
+ animate: K,
1725
2277
  currentDecorator: l,
1726
2278
  prevDecorator: n
1727
2279
  }), S("end", e, 0);
1728
2280
  }
1729
2281
  })) {
1730
- c?.setAttribute(qe, "true"), l?.setAttribute(qe, "true");
2282
+ c?.setAttribute(Ht, "true"), l?.setAttribute(Ht, "true");
1731
2283
  for (let e of r.current) e.style.removeProperty("will-change");
1732
- for (let e of r.prev) q(e), e.style.removeProperty("will-change");
2284
+ for (let e of r.prev) G(e), e.style.removeProperty("will-change");
1733
2285
  r = {
1734
2286
  current: [],
1735
2287
  prev: []
1736
2288
  };
1737
- for (let e of i.prev) q(e);
2289
+ for (let e of i.prev) G(e);
1738
2290
  i = {
1739
2291
  current: [],
1740
2292
  prev: []
1741
2293
  }, e.back();
1742
- } else c && q(c), t && q(t), l && q(l), n && q(n), b(), C(), e.setDragStatus("IDLE");
2294
+ } else c && G(c), t && G(t), l && G(l), n && G(n), b(), C(), e.setDragStatus("IDLE");
1743
2295
  };
1744
2296
  return {
1745
2297
  pointerDown: (t) => {
1746
- e.isReadyForDrag() && (f = Z(t.target, {
2298
+ e.isReadyForDrag() && (f = Bt(t.target, {
1747
2299
  direction: "x",
1748
2300
  verifyByScroll: !0
1749
- }), p = Z(t.target, {
2301
+ }), p = Bt(t.target, {
1750
2302
  direction: "y",
1751
2303
  verifyByScroll: !0
1752
2304
  }), m = t.clientX, h = t.clientY, (!f.element && !p.element || f.element || p.element) && (a = !0));
@@ -1775,7 +2327,7 @@ function Je(e) {
1775
2327
  }
1776
2328
  //#endregion
1777
2329
  //#region src/screen/computeBarRiding.ts
1778
- function Ye(e) {
2330
+ function Wt(e) {
1779
2331
  return !(e.status === "PUSHING" || e.status === "POPPING" || e.status === "REPLACING") || !e.isTopOrTopPrev ? {
1780
2332
  app: !1,
1781
2333
  nav: !1
@@ -1786,24 +2338,24 @@ function Ye(e) {
1786
2338
  }
1787
2339
  //#endregion
1788
2340
  //#region src/screen/animStartAnchor.ts
1789
- function Xe(e) {
2341
+ function Gt(e) {
1790
2342
  return !(e.status === "PUSHING" || e.status === "POPPING" || e.status === "REPLACING") || !e.isTopOrTopPrev ? null : `${e.status}:${e.transitionName}`;
1791
2343
  }
1792
- var Ze = 300, Qe = 20;
1793
- function $e(e) {
1794
- return Array.from(e.querySelectorAll("img")).filter((e) => e.complete && typeof e.decode == "function").slice(0, Qe);
2344
+ var Kt = 300, qt = 20;
2345
+ function Jt(e) {
2346
+ return Array.from(e.querySelectorAll("img")).filter((e) => e.complete && typeof e.decode == "function").slice(0, qt);
1795
2347
  }
1796
- function et(e) {
1797
- if (!(!e || typeof e.querySelectorAll != "function")) for (let t of $e(e)) t.decode().catch(() => {});
2348
+ function Yt(e) {
2349
+ if (!(!e || typeof e.querySelectorAll != "function")) for (let t of Jt(e)) t.decode().catch(() => {});
1798
2350
  }
1799
- function tt(e, t = {}) {
1800
- let n = !1, r = 0, i = () => {
2351
+ function Xt(e, t = {}) {
2352
+ let n = !1, r = 0, i = [], a = () => {
1801
2353
  let r = t.scope;
1802
2354
  if (!r || typeof r.querySelectorAll != "function") {
1803
2355
  e();
1804
2356
  return;
1805
2357
  }
1806
- let i = $e(r);
2358
+ let i = Jt(r);
1807
2359
  if (i.length === 0) {
1808
2360
  e();
1809
2361
  return;
@@ -1814,16 +2366,22 @@ function tt(e, t = {}) {
1814
2366
  Promise.race([a, o]).then(() => {
1815
2367
  n || e();
1816
2368
  });
1817
- }, a = requestAnimationFrame(() => {
1818
- r = requestAnimationFrame(i);
1819
- }), o = setTimeout(e, 300);
2369
+ }, o = (e) => {
2370
+ if (e <= 0) {
2371
+ a();
2372
+ return;
2373
+ }
2374
+ i.push(requestAnimationFrame(() => o(e - 1)));
2375
+ }, s = requestAnimationFrame(() => {
2376
+ r = requestAnimationFrame(() => o(t.extraFrames ?? 0));
2377
+ }), c = setTimeout(e, 300);
1820
2378
  return () => {
1821
- n = !0, cancelAnimationFrame(a), r && cancelAnimationFrame(r), clearTimeout(o);
2379
+ n = !0, cancelAnimationFrame(s), r && cancelAnimationFrame(r), i.forEach((e) => cancelAnimationFrame(e)), clearTimeout(c);
1822
2380
  };
1823
2381
  }
1824
2382
  //#endregion
1825
2383
  //#region src/screen/observeBarHeight.ts
1826
- function nt(e, t) {
2384
+ function Zt(e, t) {
1827
2385
  e.offsetHeight > 0 && t(e.offsetHeight);
1828
2386
  let n = new ResizeObserver(([e]) => {
1829
2387
  e.contentRect.height > 0 && t(e.contentRect.height);
@@ -1834,14 +2392,14 @@ function nt(e, t) {
1834
2392
  }
1835
2393
  //#endregion
1836
2394
  //#region src/screen/observeViewportScrollHeight.ts
1837
- var rt = 0;
1838
- function it(e) {
2395
+ var Qt = 0;
2396
+ function $t(e) {
1839
2397
  let t = 0, n = () => {
1840
2398
  cancelAnimationFrame(t), t = requestAnimationFrame(() => {
1841
2399
  let t = document.documentElement.scrollHeight - (window.visualViewport?.height || 0);
1842
2400
  t = t < 0 ? 0 : t;
1843
- let n = t - rt;
1844
- n = n < 0 ? 0 : n, rt ||= t, e(t, n);
2401
+ let n = t - Qt;
2402
+ n = n < 0 ? 0 : n, Qt ||= t, e(t, n);
1845
2403
  });
1846
2404
  };
1847
2405
  return window.visualViewport?.addEventListener("resize", n), window.visualViewport?.addEventListener("scroll", n), () => {
@@ -1849,13 +2407,8 @@ function it(e) {
1849
2407
  };
1850
2408
  }
1851
2409
  //#endregion
1852
- //#region src/utils/matchesPathname.ts
1853
- function at(e, t) {
1854
- return i(e).regexp.test(t);
1855
- }
1856
- //#endregion
1857
2410
  //#region src/utils/isOpaqueColor.ts
1858
- function ot(e) {
2411
+ function en(e) {
1859
2412
  let t = e.trim().toLowerCase();
1860
2413
  if (t === "transparent" || t === "") return !1;
1861
2414
  if (t.match(/^rgb\(\s*\d+[\s,]+\d+[\s,]+\d+\s*\)$/)) return !0;
@@ -1866,7 +2419,7 @@ function ot(e) {
1866
2419
  }
1867
2420
  //#endregion
1868
2421
  //#region src/utils/buildRoutePath.ts
1869
- function st(e, n) {
2422
+ function tn(e, n) {
1870
2423
  let i = n ?? {}, a = t(e)(Object.fromEntries(Object.entries(i).map(([e, t]) => [e, String(t)]))), o = (typeof e == "string" ? r(e) : e).tokens.filter((e) => e.type === "param").map((e) => e.name), s = Object.fromEntries(Object.entries(i).filter(([e]) => !o.includes(e))), c = new URLSearchParams(s).toString();
1871
2424
  return {
1872
2425
  pathname: `${a}${c ? `?${c}` : ""}`,
@@ -1874,4 +2427,4 @@ function st(e, n) {
1874
2427
  };
1875
2428
  }
1876
2429
  //#endregion
1877
- export { Ze as ANIM_HOLD_RELEASE_BACKSTOP_MS, Y as SKIP_ANIMATION_ATTR, a as TaskManger, Xe as animHoldKey, J as animateInline, H as animationName, E as appendParamsQuery, G as applyTransitionStyles, st as buildRoutePath, $ as canProgrammaticallyScroll, q as clearInlineAnimation, Ae as collectAnimatedProperties, Le as compileTransitionStyles, Ye as computeBarRiding, re as computeScreenFreeze, _ as consumeSelfInducedPop, p as createBrowserHistoryDriver, de as createDecorator, o as createHistoryStore, v as createHistorySync, y as createMemoryHistoryDriver, b as createNavigateStore, w as createNavigationController, me as createPartTransition, fe as createRawDecorator, he as createRawPartTransition, ie as createRawTransition, te as createRouterScope, ne as createScreenSelector, A as createScreenStore, m as createSelfPopGuard, D as createStepController, Je as createSwipeController, j as createTransition, Ge as createTransitionEngine, k as createTransitionStore, oe as cupertino, F as decoratorMap, et as eagerlyDecodeImages, B as easingToCss, d as ensureWindowHistoryState, He as enteringInitialStyle, Z as findScrollable, s as getMatchedPathPattern, c as getParams, ot as isOpaqueColor, u as isServer, M as layout, g as markSelfInducedPop, at as matchesPathname, ce as material, le as none, nt as observeBarHeight, it as observeViewportScrollHeight, Q as overflowsAxis, pe as overlay, I as partTransitionMap, T as readStepParams, Ve as registerTransitionDefinitions, ue as resolveTransition, tt as scheduleAnimHoldRelease, l as seedInitialHistory, O as subscribeStepParamsRestore, R as targetToDecls, N as transitionMap, ze as variantHasAnimation };
2430
+ export { Kt as ANIM_HOLD_RELEASE_BACKSTOP_MS, X as SKIP_ANIMATION_ATTR, o as TaskManger, Gt as animHoldKey, K as animateInline, Xe as animationName, se as appendParamsQuery, it as applyTransitionStyles, tn as buildRoutePath, $ as canProgrammaticallyScroll, G as clearInlineAnimation, Ge as collectAnimatedProperties, et as compileTransitionStyles, Wt as computeBarRiding, _e as computeScreenFreeze, y as consumeSelfInducedPop, h as createBrowserHistoryDriver, Te as createDecorator, s as createHistoryStore, b as createHistorySync, ne as createMemoryHistoryDriver, re as createNavigateStore, ae as createNavigationController, Oe as createPartTransition, Ee as createRawDecorator, ke as createRawPartTransition, ve as createRawTransition, he as createRouterScope, ge as createScreenSelector, fe as createScreenStore, g as createSelfPopGuard, ce as createStepController, Ut as createSwipeController, A as createTransition, zt as createTransitionEngine, ue as createTransitionStore, be as cupertino, P as decoratorMap, Yt as eagerlyDecodeImages, H as easingToCss, ee as ensureScopeHistorySync, f as ensureWindowHistoryState, dt as enteringInitialStyle, Bt as findScrollable, c as getMatchedPathPattern, l as getParams, en as isOpaqueColor, d as isServer, Se as layout, v as markSelfInducedPop, de as matchesPathname, Ce as material, we as none, Zt as observeBarHeight, $t as observeViewportScrollHeight, Q as overflowsAxis, De as overlay, F as partTransitionMap, oe as readStepParams, ut as registerTransitionDefinitions, te as releaseScopeHistorySync, M as resolveTransition, Xt as scheduleAnimHoldRelease, u as seedInitialHistory, p as seedRouterEntry, le as subscribeStepParamsRestore, B as targetToDecls, j as transitionMap, nt as variantHasAnimation };