flemo 1.1.2 → 1.1.4

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,28 +1,29 @@
1
- import { jsx as P, jsxs as tt } from "react/jsx-runtime";
2
- import { useEffect as R, createContext as X, useReducer as gt, Children as et, useContext as q, Suspense as Pt, useImperativeHandle as yt, useRef as L } from "react";
3
- import { d as I, c as U } from "./vendor-C8cPYUOQ.js";
1
+ import { jsx as w, jsxs as et } from "react/jsx-runtime";
2
+ import { useEffect as G, createContext as X, useReducer as Pt, Children as nt, useContext as q, Suspense as Et, useImperativeHandle as St, useRef as I } from "react";
3
+ import { d as x, c as _ } from "./vendor-C8cPYUOQ.js";
4
4
  import { animate as F } from "motion";
5
- import { animate as M, transform as nt, useAnimate as rt, motion as at, useDragControls as wt } from "motion/react";
6
- function St(n, e, t) {
7
- const a = Array.isArray(n) ? n.find((i) => I.pathToRegexp(i).regexp.test(e)) || "" : I.pathToRegexp(n).regexp.test(e) ? n : "", r = I.match(a)(e), s = new URLSearchParams(t), o = Object.fromEntries(s.entries());
8
- return r ? { ...r.params, ...o } : {};
5
+ import { animate as A, transform as st, useAnimate as at, motion as rt, useDragControls as wt } from "motion/react";
6
+ function yt(s, e, t) {
7
+ const a = Array.isArray(s) ? s.find((c) => x.pathToRegexp(c).regexp.test(e)) || "" : x.pathToRegexp(s).regexp.test(e) ? s : "", n = x.match(a)(e), i = new URLSearchParams(t), o = Object.fromEntries(i.entries());
8
+ return n ? { ...n.params, ...o } : {};
9
9
  }
10
- function J() {
10
+ function Z() {
11
11
  return typeof document > "u";
12
12
  }
13
- class Et {
13
+ class Lt {
14
14
  tasks = /* @__PURE__ */ new Map();
15
15
  instanceId = Date.now().toString();
16
16
  isLocked = !1;
17
17
  currentTaskId = null;
18
18
  taskQueue = Promise.resolve();
19
19
  signalListeners = /* @__PURE__ */ new Map();
20
- // 신호 리스너
20
+ pendingTaskQueue = [];
21
+ isProcessingPending = !1;
21
22
  async acquireLock(e) {
22
- for (let r = 0; r < 10; r++) {
23
+ for (let n = 0; n < 10; n++) {
23
24
  if (!this.isLocked)
24
25
  return this.isLocked = !0, this.currentTaskId = e, !0;
25
- await new Promise((s) => setTimeout(s, 100));
26
+ await new Promise((i) => setTimeout(i, 100));
26
27
  }
27
28
  return !1;
28
29
  }
@@ -38,76 +39,122 @@ class Et {
38
39
  this.resolveTask(a);
39
40
  }), this.signalListeners.delete(e));
40
41
  }
42
+ // 대기 중인 태스크들을 처리하는 메서드
43
+ async processPendingTasks() {
44
+ if (!(this.isProcessingPending || this.pendingTaskQueue.length === 0)) {
45
+ this.isProcessingPending = !0;
46
+ try {
47
+ for (; this.pendingTaskQueue.length > 0; ) {
48
+ const e = this.pendingTaskQueue[0];
49
+ if (e.status === "COMPLETED" || e.status === "FAILED" || e.status === "ROLLEDBACK") {
50
+ this.pendingTaskQueue.shift();
51
+ continue;
52
+ }
53
+ if (e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING" || e.status === "PROCESSING" || e.status === "PENDING")
54
+ break;
55
+ }
56
+ } finally {
57
+ this.isProcessingPending = !1;
58
+ }
59
+ }
60
+ }
61
+ // 모든 대기 중인 태스크가 완료될 때까지 대기
62
+ async waitForPendingTasks() {
63
+ return new Promise((e) => {
64
+ const t = () => {
65
+ this.pendingTaskQueue.filter(
66
+ (n) => n.status === "MANUAL_PENDING" || n.status === "SIGNAL_PENDING"
67
+ ).length === 0 ? e() : setTimeout(t, 100);
68
+ };
69
+ t();
70
+ });
71
+ }
72
+ // 태스크 상태 변경 시 대기 큐 처리
73
+ async onTaskStatusChange(e, t) {
74
+ (t === "COMPLETED" || t === "FAILED" || t === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((a) => a.id !== e), await this.processPendingTasks());
75
+ }
41
76
  async addTask(e, t = {}) {
42
77
  const a = t.id || this.generateTaskId();
43
- return new Promise((r, s) => {
78
+ return new Promise((n, i) => {
44
79
  this.taskQueue = this.taskQueue.then(async () => {
45
80
  try {
46
- const { control: o, validate: i, rollback: c, dependencies: p = [] } = t, u = {
81
+ const { control: o, validate: c, rollback: u, dependencies: l = [], delay: p } = t, f = new AbortController(), r = {
47
82
  id: a,
48
83
  execute: e,
49
84
  timestamp: Date.now(),
50
85
  retryCount: 0,
51
86
  status: "PENDING",
52
- dependencies: p,
87
+ dependencies: l,
53
88
  instanceId: this.instanceId,
54
- validate: i,
55
- rollback: c,
56
- control: o
89
+ validate: c,
90
+ rollback: u,
91
+ control: o,
92
+ abortController: f
57
93
  };
58
- this.tasks.set(u.id, u);
94
+ this.tasks.set(r.id, r), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(r), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((P) => P.id !== r.id));
59
95
  try {
60
- if (!await this.acquireLock(u.id))
61
- throw u.status = "FAILED", new Error("FAILED");
96
+ if (!await this.acquireLock(r.id))
97
+ throw r.status = "FAILED", new Error("FAILED");
62
98
  try {
63
- u.status = "PROCESSING";
64
- for (const l of u.dependencies) {
65
- const w = this.tasks.get(l);
66
- if (!w || w.status !== "COMPLETED")
67
- throw u.status = "FAILED", new Error("FAILED");
99
+ r.status = "PROCESSING";
100
+ for (const h of r.dependencies) {
101
+ const m = this.tasks.get(h);
102
+ if (!m || m.status !== "COMPLETED")
103
+ throw r.status = "FAILED", new Error("FAILED");
104
+ }
105
+ if (r.validate && !await r.validate())
106
+ throw r.status = "FAILED", new Error("FAILED");
107
+ p && p > 0 && await new Promise((h) => setTimeout(h, p));
108
+ const E = await r.execute(r.abortController);
109
+ if (r.abortController.signal.aborted) {
110
+ r.status = "COMPLETED", await this.onTaskStatusChange(r.id, "COMPLETED"), n({
111
+ success: !0,
112
+ result: void 0,
113
+ taskId: r.id,
114
+ timestamp: Date.now(),
115
+ instanceId: this.instanceId
116
+ });
117
+ return;
68
118
  }
69
- if (u.validate && !await u.validate())
70
- throw u.status = "FAILED", new Error("FAILED");
71
- const d = await u.execute();
72
119
  if (t.control) {
73
- const l = t.control;
74
- if (l.delay && l.delay > 0 && await new Promise((w) => setTimeout(w, l.delay)), l.manual) {
75
- u.status = "MANUAL_PENDING", u.manualResolver = { resolve: r, reject: s, result: d };
120
+ const h = t.control;
121
+ if (h.delay && h.delay > 0 && await new Promise((m) => setTimeout(m, h.delay)), h.manual) {
122
+ r.status = "MANUAL_PENDING", r.manualResolver = { resolve: n, reject: i, result: E }, this.pendingTaskQueue.push(r), await this.onTaskStatusChange(r.id, "MANUAL_PENDING");
76
123
  return;
77
124
  }
78
- if (l.signal) {
79
- u.status = "MANUAL_PENDING", u.manualResolver = { resolve: r, reject: s, result: d }, this.signalListeners.has(l.signal) || this.signalListeners.set(l.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(l.signal).add(u.id);
125
+ if (h.signal) {
126
+ r.status = "SIGNAL_PENDING", r.manualResolver = { resolve: n, reject: i, result: E }, this.signalListeners.has(h.signal) || this.signalListeners.set(h.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(h.signal).add(r.id), this.pendingTaskQueue.push(r), await this.onTaskStatusChange(r.id, "SIGNAL_PENDING");
80
127
  return;
81
128
  }
82
- if (l.condition && !await l.condition()) {
83
- u.status = "MANUAL_PENDING", u.manualResolver = { resolve: r, reject: s, result: d };
129
+ if (h.condition && !await h.condition()) {
130
+ r.status = "MANUAL_PENDING", r.manualResolver = { resolve: n, reject: i, result: E }, this.pendingTaskQueue.push(r), await this.onTaskStatusChange(r.id, "MANUAL_PENDING");
84
131
  return;
85
132
  }
86
133
  }
87
- u.status = "COMPLETED", r({
134
+ r.status = "COMPLETED", await this.onTaskStatusChange(r.id, "COMPLETED"), n({
88
135
  success: !0,
89
- result: d,
90
- taskId: u.id,
136
+ result: E,
137
+ taskId: r.id,
91
138
  timestamp: Date.now(),
92
139
  instanceId: this.instanceId
93
140
  });
94
- } catch (d) {
95
- if (u.status = "FAILED", u.rollback)
141
+ } catch (E) {
142
+ if (r.status = "FAILED", r.rollback)
96
143
  try {
97
- await u.rollback(), u.status = "ROLLEDBACK";
144
+ await r.rollback(), r.status = "ROLLEDBACK";
98
145
  } catch {
99
146
  }
100
- throw d;
147
+ throw await this.onTaskStatusChange(r.id, r.status), E;
101
148
  } finally {
102
- this.releaseLock(u.id);
149
+ this.releaseLock(r.id);
103
150
  }
104
- } catch (h) {
105
- s(h);
151
+ } catch (P) {
152
+ i(P);
106
153
  }
107
154
  } catch (o) {
108
- s(o);
155
+ i(o);
109
156
  }
110
- }).catch(s);
157
+ }).catch(i);
111
158
  });
112
159
  }
113
160
  async resolveTask(e) {
@@ -125,117 +172,102 @@ class Et {
125
172
  taskId: t.id,
126
173
  timestamp: Date.now(),
127
174
  instanceId: this.instanceId
128
- }), delete t.manualResolver, !0;
175
+ }), delete t.manualResolver, await this.onTaskStatusChange(e, "COMPLETED"), !0;
129
176
  }
130
177
  return !1;
131
178
  }
132
179
  async resolveAllPending() {
133
180
  const e = Array.from(this.tasks.values()).filter(
134
- (t) => ["PENDING", "MANUAL_PENDING"].includes(t.status)
181
+ (t) => ["PENDING", "MANUAL_PENDING", "SIGNAL_PENDING"].includes(t.status)
135
182
  );
136
183
  await Promise.all(e.map((t) => this.resolveTask(t.id)));
137
184
  }
138
- getManualPendingTasks() {
139
- return Array.from(this.tasks.values()).filter((e) => e.status === "MANUAL_PENDING");
140
- }
141
185
  }
142
- const m = new Et(), x = U((n) => ({
186
+ const N = new Lt(), R = _((s) => ({
143
187
  index: -1,
144
188
  histories: [],
145
- addHistory: (e) => n((t) => ({
189
+ addHistory: (e) => s((t) => ({
146
190
  index: t.index + 1,
147
191
  histories: t.histories.concat(e)
148
192
  })),
149
- replaceHistory: (e) => n((t) => (t.histories.splice(e, 1), {
193
+ replaceHistory: (e) => s((t) => (t.histories.splice(e, 1), {
150
194
  index: t.index - 1,
151
195
  histories: t.histories
152
196
  })),
153
- popHistory: (e) => n((t) => ({
197
+ popHistory: (e) => s((t) => ({
154
198
  index: t.index - 1,
155
- histories: t.histories.filter((a, r) => r !== e)
199
+ histories: t.histories.filter((a, n) => n !== e)
156
200
  }))
157
- })), C = U((n) => ({
201
+ })), T = _((s) => ({
158
202
  status: "IDLE",
159
- setStatus: (e) => n({ status: e })
203
+ setStatus: (e) => s({ status: e })
160
204
  }));
161
- function vt() {
162
- return R(() => {
163
- const n = async (e) => {
164
- await m.resolveAllPending();
165
- const { index: t, addHistory: a, popHistory: r } = x.getState(), s = C.getState().setStatus, o = e.state?.id, i = e.state?.index, c = e.state?.status, p = e.state?.params, u = e.state?.transitionName, h = i < t, d = c === "PUSHING" && i > t, l = c === "REPLACING" && i > t;
166
- h ? (await m.addTask(
167
- async () => (s("POPPING"), async () => {
168
- r(i + 1), m.getManualPendingTasks().length || s("COMPLETED");
169
- }),
170
- {
171
- id: o,
172
- control: {
173
- manual: !0
174
- }
175
- }
176
- ))?.result?.() : d ? (await m.addTask(
177
- async () => (s("PUSHING"), a({
178
- id: o,
179
- pathname: window.location.pathname,
180
- params: p,
181
- transitionName: u
182
- }), async () => {
183
- m.getManualPendingTasks().length || s("COMPLETED");
184
- }),
185
- {
186
- id: o,
187
- control: {
188
- manual: !0
205
+ function Tt() {
206
+ return G(() => {
207
+ const s = async (e) => {
208
+ const t = e.state?.id;
209
+ (await N.addTask(
210
+ async (a) => {
211
+ const n = e.state?.index, i = e.state?.status, o = e.state?.params, c = e.state?.transitionName, u = T.getState().setStatus, { index: l, addHistory: p, popHistory: f } = R.getState(), r = n < l, g = i === "PUSHING" && n > l, P = i === "REPLACING" && n > l, E = window.location.pathname;
212
+ if (!r && !g && !P) {
213
+ a.abort();
214
+ return;
189
215
  }
190
- }
191
- ))?.result?.() : l && (await m.addTask(
192
- async () => (s("REPLACING"), a({
193
- id: o,
194
- pathname: window.location.pathname,
195
- params: p,
196
- transitionName: u
197
- }), async () => {
198
- m.getManualPendingTasks().length || s("COMPLETED");
199
- }),
216
+ return r ? u("POPPING") : g ? (u("PUSHING"), p({
217
+ id: t,
218
+ pathname: E,
219
+ params: o,
220
+ transitionName: c
221
+ })) : P && (u("REPLACING"), p({
222
+ id: t,
223
+ pathname: E,
224
+ params: o,
225
+ transitionName: c
226
+ })), async () => {
227
+ r && f(n + 1), u("COMPLETED");
228
+ };
229
+ },
200
230
  {
201
- id: o,
231
+ id: t,
202
232
  control: {
203
233
  manual: !0
204
234
  }
205
235
  }
206
- ))?.result?.();
236
+ )).result?.();
207
237
  };
208
- return window.addEventListener("popstate", n), () => {
209
- window.removeEventListener("popstate", n);
238
+ return window.addEventListener("popstate", s), () => {
239
+ window.removeEventListener("popstate", s);
210
240
  };
211
241
  }, []), null;
212
242
  }
213
- const st = X({}), ot = X(() => {
243
+ const it = X({}), ot = X(() => {
214
244
  });
215
- function Lt(n, e) {
245
+ function Dt(s, e) {
216
246
  switch (e.type) {
217
247
  case "SET":
218
248
  return e.params;
219
249
  default:
220
- return n;
250
+ return s;
221
251
  }
222
252
  }
223
- function Tt({
224
- children: n,
253
+ function It({
254
+ children: s,
225
255
  active: e,
226
256
  params: t
227
257
  }) {
228
- const [a, r] = gt(Lt, t);
229
- return R(() => {
230
- const s = (o) => {
231
- o.state?.step && r({ type: "SET", params: o.state?.params || {} });
258
+ const [a, n] = Pt(Dt, t);
259
+ return G(() => {
260
+ const i = async (o) => {
261
+ o.state?.step && await N.addTask(async () => {
262
+ n({ type: "SET", params: o.state?.params || {} });
263
+ });
232
264
  };
233
- return e && window.addEventListener("popstate", s), () => {
234
- window.removeEventListener("popstate", s);
265
+ return e && window.addEventListener("popstate", i), () => {
266
+ window.removeEventListener("popstate", i);
235
267
  };
236
- }, [e, r]), /* @__PURE__ */ P(ot.Provider, { value: r, children: /* @__PURE__ */ P(st.Provider, { value: a, children: n }) });
268
+ }, [e, n]), /* @__PURE__ */ w(ot.Provider, { value: n, children: /* @__PURE__ */ w(it.Provider, { value: a, children: s }) });
237
269
  }
238
- const it = X({
270
+ const ct = X({
239
271
  id: "",
240
272
  isActive: !1,
241
273
  isRoot: !0,
@@ -246,42 +278,42 @@ const it = X({
246
278
  transitionName: "none",
247
279
  prevTransitionName: "none"
248
280
  });
249
- function Dt({ children: n }) {
250
- const e = x((a) => a.index), t = x((a) => a.histories);
281
+ function Nt({ children: s }) {
282
+ const e = R((a) => a.index), t = R((a) => a.histories);
251
283
  return t.map(
252
- (a) => et.toArray(n).filter(
253
- (r) => I.pathToRegexp(r.props.path).regexp.test(
284
+ (a) => nt.toArray(s).filter(
285
+ (n) => x.pathToRegexp(n.props.path).regexp.test(
254
286
  a.pathname
255
287
  )
256
288
  )
257
- ).map(([a], r) => /* @__PURE__ */ P(
258
- it.Provider,
289
+ ).map(([a], n) => /* @__PURE__ */ w(
290
+ ct.Provider,
259
291
  {
260
292
  value: {
261
- id: t[r].id,
262
- isActive: r === e,
263
- isRoot: r === 0,
264
- isPrev: r < e - 1,
265
- zIndex: r,
266
- pathname: t[r].pathname,
267
- params: t[r].params,
293
+ id: t[n].id,
294
+ isActive: n === e,
295
+ isRoot: n === 0,
296
+ isPrev: n < e - 1,
297
+ zIndex: n,
298
+ pathname: t[n].pathname,
299
+ params: t[n].params,
268
300
  transitionName: t[e].transitionName,
269
301
  prevTransitionName: t[e - 1]?.transitionName
270
302
  },
271
- children: /* @__PURE__ */ P(Tt, { active: r === e, params: t[r].params, children: a })
303
+ children: /* @__PURE__ */ w(It, { active: n === e, params: t[n].params, children: a })
272
304
  },
273
- t[r].id
305
+ t[n].id
274
306
  ));
275
307
  }
276
- function Nt({
277
- name: n,
308
+ function kt({
309
+ name: s,
278
310
  initial: e,
279
311
  enter: t,
280
312
  exit: a,
281
- options: r
313
+ options: n
282
314
  }) {
283
315
  return {
284
- name: n,
316
+ name: s,
285
317
  initial: e,
286
318
  variants: {
287
319
  "IDLE-true": t,
@@ -295,10 +327,10 @@ function Nt({
295
327
  "COMPLETED-false": a,
296
328
  "COMPLETED-true": t
297
329
  },
298
- ...r
330
+ ...n
299
331
  };
300
332
  }
301
- const kt = Nt({
333
+ const vt = kt({
302
334
  name: "overlay",
303
335
  initial: {
304
336
  opacity: 0,
@@ -326,16 +358,16 @@ const kt = Nt({
326
358
  }
327
359
  },
328
360
  options: {
329
- onSwipeStart: (n, { prevDecorator: e }) => F(
361
+ onSwipeStart: (s, { prevDecorator: e }) => F(
330
362
  e,
331
363
  {
332
- opacity: n ? 1 : 0
364
+ opacity: s ? 1 : 0
333
365
  },
334
366
  {
335
367
  duration: 0.3
336
368
  }
337
369
  ),
338
- onSwipe: (n, e, { prevDecorator: t }) => F(
370
+ onSwipe: (s, e, { prevDecorator: t }) => F(
339
371
  t,
340
372
  {
341
373
  opacity: Math.max(0, 1 - e / 100)
@@ -344,49 +376,49 @@ const kt = Nt({
344
376
  duration: 0
345
377
  }
346
378
  ),
347
- onSwipeEnd: (n, { prevDecorator: e }) => F(
379
+ onSwipeEnd: (s, { prevDecorator: e }) => F(
348
380
  e,
349
381
  {
350
- opacity: n ? 0 : 1
382
+ opacity: s ? 0 : 1
351
383
  },
352
384
  {
353
385
  duration: 0.3
354
386
  }
355
387
  )
356
388
  }
357
- }), j = /* @__PURE__ */ new Map([["overlay", kt]]), _ = U((n) => ({
389
+ }), K = /* @__PURE__ */ new Map([["overlay", vt]]), B = _((s) => ({
358
390
  defaultTransitionName: "cupertino",
359
- setDefaultTransitionName: (e) => n({ defaultTransitionName: e })
391
+ setDefaultTransitionName: (e) => s({ defaultTransitionName: e })
360
392
  }));
361
- function K({
362
- name: n,
393
+ function j({
394
+ name: s,
363
395
  initial: e,
364
396
  idle: t,
365
397
  enter: a,
366
- enterBack: r,
367
- exit: s,
398
+ enterBack: n,
399
+ exit: i,
368
400
  exitBack: o,
369
- options: i
401
+ options: c
370
402
  }) {
371
403
  return {
372
- name: n,
404
+ name: s,
373
405
  initial: e,
374
406
  variants: {
375
407
  "IDLE-true": t,
376
408
  "IDLE-false": t,
377
- "PUSHING-false": s,
409
+ "PUSHING-false": i,
378
410
  "PUSHING-true": a,
379
- "REPLACING-false": s,
411
+ "REPLACING-false": i,
380
412
  "REPLACING-true": a,
381
413
  "POPPING-false": o,
382
- "POPPING-true": r,
383
- "COMPLETED-false": s,
414
+ "POPPING-true": n,
415
+ "COMPLETED-false": i,
384
416
  "COMPLETED-true": a
385
417
  },
386
- ...i
418
+ ...c
387
419
  };
388
420
  }
389
- const It = K({
421
+ const Mt = j({
390
422
  name: "cupertino",
391
423
  initial: {
392
424
  x: "100%",
@@ -442,9 +474,9 @@ const It = K({
442
474
  decoratorName: "overlay",
443
475
  swipeDirection: "x",
444
476
  onSwipeStart: async () => !0,
445
- onSwipe: (n, e, { currentScreen: t, prevScreen: a, onProgress: r }) => {
446
- const { offset: s } = e, o = s.x, i = nt(o, [0, window.innerWidth], [0, 100]);
447
- return r?.(!0, i), M(
477
+ onSwipe: (s, e, { currentScreen: t, prevScreen: a, onProgress: n }) => {
478
+ const { offset: i } = e, o = i.x, c = st(o, [0, window.innerWidth], [0, 100]);
479
+ return n?.(!0, c), A(
448
480
  t,
449
481
  {
450
482
  x: Math.max(0, o)
@@ -452,43 +484,43 @@ const It = K({
452
484
  {
453
485
  duration: 0
454
486
  }
455
- ), M(
487
+ ), A(
456
488
  a,
457
489
  {
458
- x: -100 + i
490
+ x: -100 + c
459
491
  },
460
492
  {
461
493
  duration: 0
462
494
  }
463
- ), i;
495
+ ), c;
464
496
  },
465
- onSwipeEnd: async (n, e, { currentScreen: t, prevScreen: a, onStart: r }) => {
466
- const { offset: s, velocity: o } = e, c = s.x > 50 || o.x > 20;
467
- return r?.(c), await Promise.all([
468
- M(
497
+ onSwipeEnd: async (s, e, { currentScreen: t, prevScreen: a, onStart: n }) => {
498
+ const { offset: i, velocity: o } = e, u = i.x > 50 || o.x > 20;
499
+ return n?.(u), await Promise.all([
500
+ A(
469
501
  t,
470
502
  {
471
- x: c ? "100%" : 0
503
+ x: u ? "100%" : 0
472
504
  },
473
505
  {
474
506
  duration: 0.3,
475
507
  ease: [0.32, 0.72, 0, 1]
476
508
  }
477
509
  ),
478
- M(
510
+ A(
479
511
  a,
480
512
  {
481
- x: c ? 0 : -100
513
+ x: u ? 0 : -100
482
514
  },
483
515
  {
484
516
  duration: 0.3,
485
517
  ease: [0.32, 0.72, 0, 1]
486
518
  }
487
519
  )
488
- ]), c;
520
+ ]), u;
489
521
  }
490
522
  }
491
- }), Mt = K({
523
+ }), Ct = j({
492
524
  name: "material",
493
525
  initial: {
494
526
  y: "100%",
@@ -549,55 +581,55 @@ const It = K({
549
581
  options: {
550
582
  swipeDirection: "y",
551
583
  onSwipeStart: async () => !0,
552
- onSwipe: (n, e, { currentScreen: t, prevScreen: a, onProgress: r }) => {
553
- const { offset: s } = e, o = s.y, i = Math.max(0, Math.min(56, o)), c = nt(i, [0, 56], [1, 0.96]), p = Math.max(0, o - 56), u = Math.min(1, p / 160), h = Math.sqrt(u) * 12, d = Math.max(0, i + h), l = Math.min(56, d);
554
- return r?.(!0, l), M(
584
+ onSwipe: (s, e, { currentScreen: t, prevScreen: a, onProgress: n }) => {
585
+ const { offset: i } = e, o = i.y, c = Math.max(0, Math.min(56, o)), u = st(c, [0, 56], [1, 0.96]), l = Math.max(0, o - 56), p = Math.min(1, l / 160), f = Math.sqrt(p) * 12, r = Math.max(0, c + f), g = Math.min(56, r);
586
+ return n?.(!0, g), A(
555
587
  t,
556
588
  {
557
- y: d,
558
- opacity: c
589
+ y: r,
590
+ opacity: u
559
591
  },
560
592
  {
561
593
  duration: 0
562
594
  }
563
- ), M(
595
+ ), A(
564
596
  a,
565
597
  {
566
- y: -56 + l,
567
- opacity: l / 56
598
+ y: -56 + g,
599
+ opacity: g / 56
568
600
  },
569
601
  { duration: 0 }
570
- ), l;
602
+ ), g;
571
603
  },
572
- onSwipeEnd: async (n, e, { currentScreen: t, prevScreen: a, onStart: r }) => {
573
- const { offset: s, velocity: o } = e, c = s.y > 56 || o.y > 20;
574
- return r?.(c), await Promise.all([
575
- M(
604
+ onSwipeEnd: async (s, e, { currentScreen: t, prevScreen: a, onStart: n }) => {
605
+ const { offset: i, velocity: o } = e, u = i.y > 56 || o.y > 20;
606
+ return n?.(u), await Promise.all([
607
+ A(
576
608
  t,
577
609
  {
578
- y: c ? "100%" : 0,
579
- opacity: c ? 0.96 : 1
610
+ y: u ? "100%" : 0,
611
+ opacity: u ? 0.96 : 1
580
612
  },
581
613
  {
582
- duration: c ? 0.22 : 0.24,
583
- ease: c ? [0.4, 0, 1, 1] : [0, 0, 0.2, 1]
614
+ duration: u ? 0.22 : 0.24,
615
+ ease: u ? [0.4, 0, 1, 1] : [0, 0, 0.2, 1]
584
616
  }
585
617
  ),
586
- M(
618
+ A(
587
619
  a,
588
620
  {
589
- y: c ? 0 : -56,
590
- opacity: c ? 1 : 0.96
621
+ y: u ? 0 : -56,
622
+ opacity: u ? 1 : 0.96
591
623
  },
592
624
  {
593
- duration: c ? 0.22 : 0.24,
594
- ease: c ? [0, 0, 0.2, 1] : [0.4, 0, 1, 1]
625
+ duration: u ? 0.22 : 0.24,
626
+ ease: u ? [0, 0, 0.2, 1] : [0.4, 0, 1, 1]
595
627
  }
596
628
  )
597
- ]), c;
629
+ ]), u;
598
630
  }
599
631
  }
600
- }), xt = K({
632
+ }), xt = j({
601
633
  name: "none",
602
634
  initial: {
603
635
  transition: {
@@ -634,48 +666,48 @@ const It = K({
634
666
  duration: 0
635
667
  }
636
668
  }
637
- }), $ = /* @__PURE__ */ new Map([
669
+ }), Q = /* @__PURE__ */ new Map([
638
670
  ["none", xt],
639
- ["cupertino", It],
640
- ["material", Mt]
641
- ]), Rt = (() => {
642
- const n = /* @__PURE__ */ Object.create(null), e = Object.prototype.hasOwnProperty;
643
- for (const t of $.values()) {
671
+ ["cupertino", Mt],
672
+ ["material", Ct]
673
+ ]), At = (() => {
674
+ const s = /* @__PURE__ */ Object.create(null), e = Object.prototype.hasOwnProperty;
675
+ for (const t of Q.values()) {
644
676
  const a = t.variants["IDLE-true"].value;
645
- for (const r in a)
646
- e.call(a, r) && (n[r] = a[r]);
677
+ for (const n in a)
678
+ e.call(a, n) && (s[n] = a[n]);
647
679
  }
648
- return n;
680
+ return s;
649
681
  })();
650
682
  function Yt({
651
- children: n,
683
+ children: s,
652
684
  initPath: e = "/",
653
685
  defaultTransitionName: t = "cupertino",
654
686
  transitions: a = [],
655
- decorators: r = []
687
+ decorators: n = []
656
688
  }) {
657
- const s = J() ? e || "/" : window.location.pathname, o = J() ? s.split("?")[1] || "" : window.location.search;
658
- return _.setState({
689
+ const i = Z() ? e || "/" : window.location.pathname, o = Z() ? i.split("?")[1] || "" : window.location.search;
690
+ return B.setState({
659
691
  defaultTransitionName: t
660
- }), x.setState({
692
+ }), R.setState({
661
693
  index: 0,
662
694
  histories: [
663
695
  {
664
696
  id: "root",
665
- pathname: s,
666
- params: St(
667
- et.toArray(n).map((i) => i.props.path).flat(),
668
- s,
697
+ pathname: i,
698
+ params: yt(
699
+ nt.toArray(s).map((c) => c.props.path).flat(),
700
+ i,
669
701
  o
670
702
  ),
671
703
  transitionName: t
672
704
  }
673
705
  ]
674
- }), R(() => {
675
- a.forEach((i) => $.set(i.name, i));
676
- }, [a]), R(() => {
677
- r.forEach((i) => j.set(i.name, i));
678
- }, [r]), /* @__PURE__ */ tt(
706
+ }), G(() => {
707
+ a.forEach((c) => Q.set(c.name, c));
708
+ }, [a]), G(() => {
709
+ n.forEach((c) => K.set(c.name, c));
710
+ }, [n]), /* @__PURE__ */ et(
679
711
  "div",
680
712
  {
681
713
  style: {
@@ -686,95 +718,97 @@ function Yt({
686
718
  height: "100%"
687
719
  },
688
720
  children: [
689
- /* @__PURE__ */ P(vt, {}),
690
- /* @__PURE__ */ P(Dt, { children: n })
721
+ /* @__PURE__ */ w(Tt, {}),
722
+ /* @__PURE__ */ w(Nt, { children: s })
691
723
  ]
692
724
  }
693
725
  );
694
726
  }
695
- function Xt({ element: n }) {
696
- return n;
727
+ function Xt({ element: s }) {
728
+ return s;
697
729
  }
698
730
  function qt() {
699
731
  return {
700
- push: async (a, r, s = {}) => {
701
- if (m.getManualPendingTasks().length)
732
+ push: async (a, n, i = {}) => {
733
+ const { status: o, setStatus: c } = T.getState();
734
+ if (o !== "COMPLETED" && o !== "IDLE")
702
735
  return;
703
- const { index: o, addHistory: i } = x.getState(), c = C.getState().setStatus, p = _.getState().defaultTransitionName, { transitionName: u = p } = s, h = m.generateTaskId();
704
- (await m.addTask(
736
+ const { index: u, addHistory: l } = R.getState(), p = B.getState().defaultTransitionName, { transitionName: f = p } = i, r = N.generateTaskId();
737
+ (await N.addTask(
705
738
  async () => {
706
739
  c("PUSHING");
707
- const d = I.compile(a)(r), l = I.parse(a).tokens.filter((v) => v.type === "param").map((v) => v.name), w = Object.fromEntries(
708
- Object.entries(r).filter(([v]) => !l.includes(v))
709
- ), A = new URLSearchParams(w).toString(), S = `${d}${A ? `?${A}` : ""}`;
740
+ const g = x.compile(a)(n), P = x.parse(a).tokens.filter((D) => D.type === "param").map((D) => D.name), E = Object.fromEntries(
741
+ Object.entries(n).filter(([D]) => !P.includes(D))
742
+ ), h = new URLSearchParams(E).toString(), m = `${g}${h ? `?${h}` : ""}`;
710
743
  return window.history.state?.id || window.history.replaceState(
711
744
  {
712
745
  id: "root",
713
746
  index: 0,
714
747
  status: "IDLE",
715
748
  params: {},
716
- transitionName: u
749
+ transitionName: f
717
750
  },
718
751
  "",
719
752
  window.location.pathname
720
753
  ), window.history.pushState(
721
754
  {
722
- id: h,
723
- index: o + 1,
755
+ id: r,
756
+ index: u + 1,
724
757
  status: "PUSHING",
725
- params: r,
726
- transitionName: u
758
+ params: n,
759
+ transitionName: f
727
760
  },
728
761
  "",
729
- S
730
- ), i({
731
- id: h,
732
- pathname: d,
733
- params: r,
734
- transitionName: u
762
+ m
763
+ ), l({
764
+ id: r,
765
+ pathname: g,
766
+ params: n,
767
+ transitionName: f
735
768
  }), () => {
736
- m.getManualPendingTasks().length || c("COMPLETED");
769
+ c("COMPLETED");
737
770
  };
738
771
  },
739
772
  {
740
- id: h,
773
+ id: r,
741
774
  control: {
742
775
  manual: !0
743
776
  }
744
777
  }
745
778
  )).result?.();
746
779
  },
747
- replace: async (a, r, s = {}) => {
748
- if (m.getManualPendingTasks().length)
780
+ replace: async (a, n, i = {}) => {
781
+ const { status: o, setStatus: c } = T.getState();
782
+ if (o !== "COMPLETED" && o !== "IDLE")
749
783
  return;
750
- const { index: o, addHistory: i } = x.getState(), c = x.getState().replaceHistory, p = C.getState().setStatus, u = _.getState().defaultTransitionName, { transitionName: h = u } = s, d = m.generateTaskId();
751
- (await m.addTask(
784
+ const { index: u, addHistory: l } = R.getState(), p = R.getState().replaceHistory, f = B.getState().defaultTransitionName, { transitionName: r = f } = i, g = N.generateTaskId();
785
+ (await N.addTask(
752
786
  async () => {
753
- p("REPLACING");
754
- const l = I.compile(a)(r), w = I.parse(a).tokens.filter((E) => E.type === "param").map((E) => E.name), A = Object.fromEntries(
755
- Object.entries(r).filter(([E]) => !w.includes(E))
756
- ), S = new URLSearchParams(A).toString(), v = `${l}${S ? `?${S}` : ""}`;
787
+ c("REPLACING");
788
+ const P = x.compile(a)(n), E = x.parse(a).tokens.filter((L) => L.type === "param").map((L) => L.name), h = Object.fromEntries(
789
+ Object.entries(n).filter(([L]) => !E.includes(L))
790
+ ), m = new URLSearchParams(h).toString(), D = `${P}${m ? `?${m}` : ""}`;
757
791
  return window.history.replaceState(
758
792
  {
759
- id: d,
760
- index: o,
793
+ id: g,
794
+ index: u,
761
795
  status: "REPLACING",
762
- params: r,
763
- transitionName: h
796
+ params: n,
797
+ transitionName: r
764
798
  },
765
799
  "",
766
- v
767
- ), i({
768
- id: d,
769
- pathname: l,
770
- params: r,
771
- transitionName: h
800
+ D
801
+ ), l({
802
+ id: g,
803
+ pathname: P,
804
+ params: n,
805
+ transitionName: r
772
806
  }), async () => {
773
- await m.addTask(async () => c(o)), m.getManualPendingTasks().length || p("COMPLETED");
807
+ p(u), c("COMPLETED");
774
808
  };
775
809
  },
776
810
  {
777
- id: d,
811
+ id: g,
778
812
  control: {
779
813
  manual: !0
780
814
  }
@@ -782,16 +816,18 @@ function qt() {
782
816
  )).result?.();
783
817
  },
784
818
  pop: () => {
785
- m.getManualPendingTasks().length || window.history.back();
819
+ const a = T.getState().status;
820
+ a !== "COMPLETED" && a !== "IDLE" || window.history.back();
786
821
  }
787
822
  };
788
823
  }
789
- function jt() {
790
- const n = q(ot);
824
+ function Kt() {
825
+ const s = q(ot);
791
826
  return {
792
- pushStep: async (r) => {
793
- m.getManualPendingTasks().length || (await m.addTask(async () => {
794
- const s = new URLSearchParams(r).toString(), o = `${window.location.pathname}${s ? `?${s}` : ""}`;
827
+ pushStep: async (n) => {
828
+ const i = T.getState().status;
829
+ i !== "COMPLETED" && i !== "IDLE" || (await N.addTask(async () => {
830
+ const o = new URLSearchParams(n).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
795
831
  return window.history.state?.step || window.history.replaceState(
796
832
  {
797
833
  ...window.history.state,
@@ -803,177 +839,179 @@ function jt() {
803
839
  {
804
840
  ...window.history.state,
805
841
  step: !0,
806
- params: r
842
+ params: n
807
843
  },
808
844
  "",
809
- o
810
- ), async () => n({ type: "SET", params: r });
845
+ c
846
+ ), async () => s({ type: "SET", params: n });
811
847
  })).result?.();
812
848
  },
813
- replaceStep: async (r) => {
814
- m.getManualPendingTasks().length || (await m.addTask(async () => {
815
- const s = new URLSearchParams(r).toString(), o = `${window.location.pathname}${s ? `?${s}` : ""}`;
849
+ replaceStep: async (n) => {
850
+ const i = T.getState().status;
851
+ i !== "COMPLETED" && i !== "IDLE" || (await N.addTask(async () => {
852
+ const o = new URLSearchParams(n).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
816
853
  return window.history.replaceState(
817
854
  {
818
855
  ...window.history.state,
819
856
  step: !0,
820
- params: r
857
+ params: n
821
858
  },
822
859
  "",
823
- o
824
- ), async () => n({ type: "SET", params: r });
860
+ c
861
+ ), async () => s({ type: "SET", params: n });
825
862
  })).result?.();
826
863
  },
827
864
  popStep: () => {
828
- m.getManualPendingTasks().length || window.history.back();
865
+ const n = T.getState().status;
866
+ n !== "COMPLETED" && n !== "IDLE" || window.history.back();
829
867
  }
830
868
  };
831
869
  }
832
- function Q() {
833
- return q(it);
870
+ function V() {
871
+ return q(ct);
834
872
  }
835
- function Kt() {
836
- return q(st);
873
+ function jt() {
874
+ return q(it);
837
875
  }
838
- function Qt({
839
- name: n,
876
+ function Vt({
877
+ name: s,
840
878
  initial: e,
841
879
  idle: t,
842
880
  pushOnEnter: a,
843
- pushOnExit: r,
844
- replaceOnEnter: s,
881
+ pushOnExit: n,
882
+ replaceOnEnter: i,
845
883
  replaceOnExit: o,
846
- popOnEnter: i,
847
- popOnExit: c,
848
- completedOnExit: p,
849
- completedOnEnter: u,
850
- options: h
884
+ popOnEnter: c,
885
+ popOnExit: u,
886
+ completedOnExit: l,
887
+ completedOnEnter: p,
888
+ options: f
851
889
  }) {
852
890
  return {
853
- name: n,
891
+ name: s,
854
892
  initial: e,
855
893
  variants: {
856
894
  "IDLE-true": t,
857
895
  "IDLE-false": t,
858
- "PUSHING-false": r,
896
+ "PUSHING-false": n,
859
897
  "PUSHING-true": a,
860
898
  "REPLACING-false": o,
861
- "REPLACING-true": s,
862
- "POPPING-false": c,
863
- "POPPING-true": i,
864
- "COMPLETED-false": p,
865
- "COMPLETED-true": u
899
+ "REPLACING-true": i,
900
+ "POPPING-false": u,
901
+ "POPPING-true": c,
902
+ "COMPLETED-false": l,
903
+ "COMPLETED-true": p
866
904
  },
867
- ...h
905
+ ...f
868
906
  };
869
907
  }
870
- function Vt({
871
- name: n,
908
+ function Wt({
909
+ name: s,
872
910
  initial: e,
873
911
  idle: t,
874
912
  pushOnEnter: a,
875
- pushOnExit: r,
876
- replaceOnEnter: s,
913
+ pushOnExit: n,
914
+ replaceOnEnter: i,
877
915
  replaceOnExit: o,
878
- popOnEnter: i,
879
- popOnExit: c,
880
- completedOnEnter: p,
881
- completedOnExit: u,
882
- options: h
916
+ popOnEnter: c,
917
+ popOnExit: u,
918
+ completedOnEnter: l,
919
+ completedOnExit: p,
920
+ options: f
883
921
  }) {
884
922
  return {
885
- name: n,
923
+ name: s,
886
924
  initial: e,
887
925
  variants: {
888
926
  "IDLE-true": t,
889
927
  "IDLE-false": t,
890
- "PUSHING-false": r,
928
+ "PUSHING-false": n,
891
929
  "PUSHING-true": a,
892
930
  "REPLACING-false": o,
893
- "REPLACING-true": s,
894
- "POPPING-false": c,
895
- "POPPING-true": i,
896
- "COMPLETED-false": u,
897
- "COMPLETED-true": p
931
+ "REPLACING-true": i,
932
+ "POPPING-false": u,
933
+ "POPPING-true": c,
934
+ "COMPLETED-false": p,
935
+ "COMPLETED-true": l
898
936
  },
899
- ...h
937
+ ...f
900
938
  };
901
939
  }
902
- const At = { then() {
940
+ const Rt = { then() {
903
941
  } };
904
- function Ct({
905
- freeze: n,
942
+ function Gt({
943
+ freeze: s,
906
944
  children: e
907
945
  }) {
908
- if (n)
909
- throw At;
946
+ if (s)
947
+ throw Rt;
910
948
  return e;
911
949
  }
912
- function Gt({ freeze: n, children: e, placeholder: t }) {
913
- return /* @__PURE__ */ P(Pt, { fallback: t, children: /* @__PURE__ */ P(Ct, { freeze: n, children: e }) });
950
+ function bt({ freeze: s, children: e, placeholder: t }) {
951
+ return /* @__PURE__ */ w(Et, { fallback: t, children: /* @__PURE__ */ w(Gt, { freeze: s, children: e }) });
914
952
  }
915
- function Z(n, e) {
953
+ function z(s, e) {
916
954
  const {
917
955
  direction: t = "x",
918
956
  markerSelector: a = "[data-swipe-at-edge]",
919
- depthLimit: r = 24,
920
- verifyByScroll: s = !1
921
- } = e ?? {}, o = bt(n);
957
+ depthLimit: n = 24,
958
+ verifyByScroll: i = !1
959
+ } = e ?? {}, o = Ot(s);
922
960
  if (!o) return { element: null, hasMarker: !1 };
923
- const i = o.closest?.(a);
924
- if (i instanceof HTMLElement && B(i, t) && (!s || z(i, t)))
925
- return { element: i, hasMarker: !0 };
926
- let c = o, p = 0;
927
- for (; c && c !== document.body && p < r; ) {
928
- if (B(c, t) && (!s || z(c, t)))
929
- return { element: c, hasMarker: !1 };
930
- c = c.parentElement, p++;
961
+ const c = o.closest?.(a);
962
+ if (c instanceof HTMLElement && Y(c, t) && (!i || tt(c, t)))
963
+ return { element: c, hasMarker: !0 };
964
+ let u = o, l = 0;
965
+ for (; u && u !== document.body && l < n; ) {
966
+ if (Y(u, t) && (!i || tt(u, t)))
967
+ return { element: u, hasMarker: !1 };
968
+ u = u.parentElement, l++;
931
969
  }
932
970
  return { element: null, hasMarker: !1 };
933
971
  }
934
- function bt(n) {
935
- if (!n) return null;
936
- const e = n, t = typeof e.composedPath == "function" ? e.composedPath() : void 0;
972
+ function Ot(s) {
973
+ if (!s) return null;
974
+ const e = s, t = typeof e.composedPath == "function" ? e.composedPath() : void 0;
937
975
  if (t && t.length) {
938
976
  for (const a of t)
939
977
  if (a instanceof HTMLElement) return a;
940
978
  }
941
- return n;
979
+ return s;
942
980
  }
943
- function B(n, e) {
944
- return e === "y" ? n.scrollHeight - n.clientHeight > 1 : n.scrollWidth - n.clientWidth > 1;
981
+ function Y(s, e) {
982
+ return e === "y" ? s.scrollHeight - s.clientHeight > 1 : s.scrollWidth - s.clientWidth > 1;
945
983
  }
946
- function z(n, e) {
947
- if (!B(n, e)) return !1;
984
+ function tt(s, e) {
985
+ if (!Y(s, e)) return !1;
948
986
  if (e === "y") {
949
- const t = n.scrollTop;
950
- if (n.scrollTop = t + 1, n.scrollTop !== t)
951
- return n.scrollTop = t, !0;
952
- n.scrollTop = t - 1;
953
- const r = n.scrollTop !== t;
954
- return n.scrollTop = t, r;
987
+ const t = s.scrollTop;
988
+ if (s.scrollTop = t + 1, s.scrollTop !== t)
989
+ return s.scrollTop = t, !0;
990
+ s.scrollTop = t - 1;
991
+ const n = s.scrollTop !== t;
992
+ return s.scrollTop = t, n;
955
993
  } else {
956
- const t = n.scrollLeft;
957
- if (n.scrollLeft = t + 1, n.scrollLeft !== t)
958
- return n.scrollLeft = t, !0;
959
- n.scrollLeft = t - 1;
960
- const r = n.scrollLeft !== t;
961
- return n.scrollLeft = t, r;
994
+ const t = s.scrollLeft;
995
+ if (s.scrollLeft = t + 1, s.scrollLeft !== t)
996
+ return s.scrollLeft = t, !0;
997
+ s.scrollLeft = t - 1;
998
+ const n = s.scrollLeft !== t;
999
+ return s.scrollLeft = t, n;
962
1000
  }
963
1001
  }
964
- function Ot({ children: n, ref: e, ...t }) {
965
- const { isActive: a, transitionName: r } = Q(), [s, o] = rt();
966
- yt(e, () => s.current);
967
- const i = C((d) => d.status), c = $.get(r), { decoratorName: p } = c, { initial: u, variants: h } = j.get(p);
968
- return R(() => {
969
- if (!s.current) return;
970
- const { value: d, options: l } = h[`${i}-${a}`];
971
- o(s.current, d, l);
972
- }, [i, a, o, h, s]), /* @__PURE__ */ P(
973
- at.div,
1002
+ function Ht({ children: s, ref: e, ...t }) {
1003
+ const { isActive: a, transitionName: n } = V(), [i, o] = at();
1004
+ St(e, () => i.current);
1005
+ const c = T((r) => r.status), u = Q.get(n), { decoratorName: l } = u, { initial: p, variants: f } = K.get(l);
1006
+ return G(() => {
1007
+ if (!i.current) return;
1008
+ const { value: r, options: g } = f[`${c}-${a}`];
1009
+ o(i.current, r, g);
1010
+ }, [c, a, o, f, i]), /* @__PURE__ */ w(
1011
+ rt.div,
974
1012
  {
975
- ref: s,
976
- initial: u,
1013
+ ref: i,
1014
+ initial: p,
977
1015
  style: {
978
1016
  position: "absolute",
979
1017
  top: 0,
@@ -987,114 +1025,117 @@ function Ot({ children: n, ref: e, ...t }) {
987
1025
  }
988
1026
  );
989
1027
  }
990
- const Y = U((n) => ({
991
- transitionStatus: "IDLE",
992
- setTransitionStatus: (e) => n({ transitionStatus: e })
1028
+ const O = _((s) => ({
1029
+ dragStatus: "IDLE",
1030
+ replaceTransitionStatus: "IDLE",
1031
+ setDragStatus: (e) => s({ dragStatus: e }),
1032
+ setReplaceTransitionStatus: (e) => s({ replaceTransitionStatus: e })
993
1033
  }));
994
- function Ht({
995
- children: n,
1034
+ function Ut({
1035
+ children: s,
996
1036
  ...e
997
1037
  }) {
998
- const [t, a] = rt(), { id: r, isActive: s, isRoot: o, transitionName: i, prevTransitionName: c } = Q(), p = wt(), u = C((f) => f.status), h = Y((f) => f.transitionStatus), d = Y.getState().setTransitionStatus, l = $.get(i), { variants: w, initial: A, swipeDirection: S, decoratorName: v } = l, E = j.get(v), b = L(null), O = L(null), H = L(null), T = L(!1), G = L(!1), D = L({
1038
+ const [t, a] = at(), { id: n, isActive: i, isRoot: o, transitionName: c, prevTransitionName: u } = V(), l = wt(), p = T((d) => d.status), f = O((d) => d.dragStatus), r = O.getState().setDragStatus, g = O.getState().setReplaceTransitionStatus, P = Q.get(c), { variants: E, initial: h, swipeDirection: m, decoratorName: D } = P, L = K.get(D), H = I(null), U = I(null), $ = I(null), k = I(!1), b = I(!1), v = I({
999
1039
  element: null,
1000
1040
  hasMarker: !1
1001
- }), N = L({ element: null, hasMarker: !1 }), V = L(0), W = L(0), ct = async (f, y) => {
1002
- if (!S)
1041
+ }), M = I({ element: null, hasMarker: !1 }), W = I(0), J = I(0), ut = async (d, y) => {
1042
+ if (!m)
1003
1043
  return;
1004
- b.current = t.current?.previousSibling, H.current = t.current?.previousSibling?.querySelector("[data-decorator]");
1005
- const g = await l?.onSwipeStart(f, y, {
1044
+ H.current = t.current?.previousSibling, $.current = t.current?.previousSibling?.querySelector("[data-decorator]");
1045
+ const S = await P?.onSwipeStart(d, y, {
1006
1046
  currentScreen: t.current,
1007
- prevScreen: b.current,
1008
- dragControls: p,
1009
- onStart: (k) => E?.onSwipeStart?.(k, {
1010
- currentDecorator: O.current,
1011
- prevDecorator: H.current
1047
+ prevScreen: H.current,
1048
+ dragControls: l,
1049
+ onStart: (C) => L?.onSwipeStart?.(C, {
1050
+ currentDecorator: U.current,
1051
+ prevDecorator: $.current
1012
1052
  })
1013
1053
  });
1014
- d(g ? "PENDING" : "IDLE");
1015
- }, ut = (f, y) => {
1016
- !S || h !== "PENDING" || l?.onSwipe(f, y, {
1054
+ r(S ? "PENDING" : "IDLE");
1055
+ }, lt = (d, y) => {
1056
+ !m || f !== "PENDING" || P?.onSwipe(d, y, {
1017
1057
  currentScreen: t.current,
1018
- prevScreen: b.current,
1019
- dragControls: p,
1020
- onProgress: (g, k) => E?.onSwipe?.(g, k, {
1021
- currentDecorator: O.current,
1022
- prevDecorator: H.current
1058
+ prevScreen: H.current,
1059
+ dragControls: l,
1060
+ onProgress: (S, C) => L?.onSwipe?.(S, C, {
1061
+ currentDecorator: U.current,
1062
+ prevDecorator: $.current
1023
1063
  })
1024
1064
  });
1025
- }, lt = async (f, y) => {
1026
- if (!S || h !== "PENDING")
1065
+ }, dt = async (d, y) => {
1066
+ if (!m || f !== "PENDING")
1027
1067
  return;
1028
- await l?.onSwipeEnd(f, y, {
1068
+ await P?.onSwipeEnd(d, y, {
1029
1069
  currentScreen: t.current,
1030
- prevScreen: b.current,
1031
- onStart: (k) => E?.onSwipeEnd?.(k, {
1032
- currentDecorator: O.current,
1033
- prevDecorator: H.current
1070
+ prevScreen: H.current,
1071
+ onStart: (C) => L?.onSwipeEnd?.(C, {
1072
+ currentDecorator: U.current,
1073
+ prevDecorator: $.current
1034
1074
  })
1035
- }) ? window.history.back() : d("IDLE");
1036
- }, dt = (f) => {
1037
- if (!(!o && s && u === "COMPLETED" && h === "IDLE" && !!S))
1075
+ }) ? window.history.back() : r("IDLE");
1076
+ }, pt = (d) => {
1077
+ if (!(!o && i && p === "COMPLETED" && f === "IDLE" && !!m))
1038
1078
  return;
1039
- D.current = Z(f.target, {
1079
+ v.current = z(d.target, {
1040
1080
  direction: "x"
1041
- }), N.current = Z(f.target, {
1081
+ }), M.current = z(d.target, {
1042
1082
  direction: "y"
1043
- }), V.current = f.clientX, W.current = f.clientY, (!D.current.element && !N.current.element || D.current.element || N.current.element) && (T.current = !0);
1044
- }, pt = (f) => {
1045
- const y = !D.current.element && !N.current.element;
1046
- if (T.current && y)
1047
- T.current = !1, G.current = !0, p.start(f);
1048
- else if (T.current && !y) {
1049
- const g = f.clientX - V.current, k = f.clientY - W.current, ht = N.current.element && N.current.element.scrollTop <= 0 && N.current.hasMarker, mt = D.current.element && D.current.element.scrollLeft <= 0 && D.current.hasMarker;
1050
- (S === "y" && (ht || D.current.element) && k > 0 && Math.abs(g) < 4 || S === "x" && (mt || N.current.element) && g > 0 && Math.abs(k) < 4) && (T.current = !1, G.current = !0, p.start(f));
1083
+ }), W.current = d.clientX, J.current = d.clientY, (!v.current.element && !M.current.element || v.current.element || M.current.element) && (k.current = !0);
1084
+ }, ft = (d) => {
1085
+ const y = !v.current.element && !M.current.element;
1086
+ if (k.current && y)
1087
+ k.current = !1, b.current = !0, l.start(d);
1088
+ else if (k.current && !y) {
1089
+ const S = d.clientX - W.current, C = d.clientY - J.current, gt = M.current.element && M.current.element.scrollTop <= 0 && M.current.hasMarker, mt = v.current.element && v.current.element.scrollLeft <= 0 && v.current.hasMarker;
1090
+ (m === "y" && (gt || v.current.element) && C > 0 && Math.abs(S) < 4 || m === "x" && (mt || M.current.element) && S > 0 && Math.abs(C) < 4) && (k.current = !1, b.current = !0, l.start(d));
1051
1091
  }
1052
- }, ft = () => {
1053
- T.current = !1, G.current = !1;
1092
+ }, ht = () => {
1093
+ k.current = !1, b.current = !1;
1054
1094
  };
1055
- return R(() => {
1056
- const f = t.current;
1057
- if (!f) return;
1058
- const y = (g) => {
1059
- G.current && g.preventDefault(), g.target?.dataset.swipeAtEdgeBar === "true" && g.preventDefault();
1095
+ return G(() => {
1096
+ const d = t.current;
1097
+ if (!d) return;
1098
+ const y = (S) => {
1099
+ b.current && S.preventDefault(), S.target?.dataset.swipeAtEdgeBar === "true" && S.preventDefault();
1060
1100
  };
1061
- return f.addEventListener("touchmove", y, {
1101
+ return d.addEventListener("touchmove", y, {
1062
1102
  passive: !1
1063
1103
  }), () => {
1064
- f.removeEventListener("touchmove", y);
1104
+ d.removeEventListener("touchmove", y);
1065
1105
  };
1066
- }, [t]), R(() => {
1106
+ }, [t]), G(() => {
1067
1107
  t.current && (async () => {
1068
- const { value: f, options: y } = w[`${u}-${s}`], g = u === "REPLACING" && c !== i;
1069
- !s && g && (d("PENDING"), await a(t.current, Rt, {
1070
- duration: 0.01
1071
- })), await a(t.current, f, y), await m.resolveTask(r), !s && !g && d("IDLE");
1108
+ const { value: d, options: y } = E[`${p}-${i}`], S = u !== c;
1109
+ !i && p === "REPLACING" && S && (g("PENDING"), await a(t.current, At, {
1110
+ duration: 0.1
1111
+ })), await a(t.current, d, y), await N.resolveTask(n), !i && S && g("IDLE"), i && p === "COMPLETED" && r("IDLE");
1072
1112
  })();
1073
1113
  }, [
1114
+ p,
1115
+ i,
1116
+ n,
1074
1117
  u,
1075
- s,
1076
- r,
1077
1118
  c,
1078
- i,
1079
1119
  a,
1080
1120
  t,
1081
- d,
1082
- w
1083
- ]), /* @__PURE__ */ tt(
1084
- at.div,
1121
+ E,
1122
+ r,
1123
+ g
1124
+ ]), /* @__PURE__ */ et(
1125
+ rt.div,
1085
1126
  {
1086
1127
  ref: t,
1087
1128
  ...e,
1088
- initial: A,
1089
- drag: S,
1129
+ initial: h,
1130
+ drag: m,
1090
1131
  dragListener: !1,
1091
- dragControls: p,
1092
- onDragStart: ct,
1093
- onDrag: ut,
1094
- onDragEnd: lt,
1095
- onPointerDown: dt,
1096
- onPointerMove: pt,
1097
- onPointerUp: ft,
1132
+ dragControls: l,
1133
+ onDragStart: ut,
1134
+ onDrag: lt,
1135
+ onDragEnd: dt,
1136
+ onPointerDown: pt,
1137
+ onPointerMove: ft,
1138
+ onPointerUp: ht,
1098
1139
  style: {
1099
1140
  position: "absolute",
1100
1141
  top: 0,
@@ -1108,10 +1149,11 @@ function Ht({
1108
1149
  touchAction: "none",
1109
1150
  isolation: "isolate",
1110
1151
  contain: "strict",
1152
+ overscrollBehavior: "contain",
1111
1153
  ...e.style
1112
1154
  },
1113
1155
  children: [
1114
- /* @__PURE__ */ P(
1156
+ /* @__PURE__ */ w(
1115
1157
  "div",
1116
1158
  {
1117
1159
  "data-swipe-at-edge-bar": !0,
@@ -1125,7 +1167,7 @@ function Ht({
1125
1167
  }
1126
1168
  }
1127
1169
  ),
1128
- /* @__PURE__ */ P(
1170
+ /* @__PURE__ */ w(
1129
1171
  "div",
1130
1172
  {
1131
1173
  style: {
@@ -1135,11 +1177,11 @@ function Ht({
1135
1177
  width: "100%",
1136
1178
  height: "100%"
1137
1179
  },
1138
- children: n
1180
+ children: s
1139
1181
  }
1140
1182
  ),
1141
- E && /* @__PURE__ */ P(Ot, { ref: O }),
1142
- /* @__PURE__ */ P(
1183
+ L && /* @__PURE__ */ w(Ht, { ref: U }),
1184
+ /* @__PURE__ */ w(
1143
1185
  "div",
1144
1186
  {
1145
1187
  "data-swipe-at-edge-bar": !0,
@@ -1157,23 +1199,23 @@ function Ht({
1157
1199
  }
1158
1200
  );
1159
1201
  }
1160
- function Wt({
1161
- children: n,
1202
+ function Jt({
1203
+ children: s,
1162
1204
  ...e
1163
1205
  }) {
1164
- const { isActive: t, isPrev: a } = Q(), r = C((c) => c.status), s = Y((c) => c.transitionStatus);
1165
- return /* @__PURE__ */ P(Gt, { freeze: !t && (r === "COMPLETED" && s === "IDLE" || a), children: /* @__PURE__ */ P(Ht, { ...e, children: n }) });
1206
+ const { isActive: t, isPrev: a } = V(), n = T((l) => l.status), i = O((l) => l.dragStatus), o = O((l) => l.replaceTransitionStatus);
1207
+ return /* @__PURE__ */ w(bt, { freeze: !t && (n === "COMPLETED" && i === "IDLE" && o === "IDLE" || a && o === "IDLE"), children: /* @__PURE__ */ w(Ut, { ...e, children: s }) });
1166
1208
  }
1167
1209
  export {
1168
1210
  Xt as Route,
1169
1211
  Yt as Router,
1170
- Wt as Screen,
1171
- Nt as createDecorator,
1172
- Vt as createRawDecorator,
1173
- Qt as createRawTransition,
1174
- K as createTransition,
1212
+ Jt as Screen,
1213
+ kt as createDecorator,
1214
+ Wt as createRawDecorator,
1215
+ Vt as createRawTransition,
1216
+ j as createTransition,
1175
1217
  qt as useNavigate,
1176
- Kt as useParams,
1177
- Q as useScreen,
1178
- jt as useStep
1218
+ jt as useParams,
1219
+ V as useScreen,
1220
+ Kt as useStep
1179
1221
  };