@flemo/core 1.3.0 → 1.4.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,1061 +1,837 @@
1
- import { create as w } from "zustand";
2
- import { pathToRegexp as v, match as B } from "path-to-regexp";
3
- class Q {
4
- tasks = /* @__PURE__ */ new Map();
5
- instanceId = Date.now().toString();
6
- isLocked = !1;
7
- currentTaskId = null;
8
- taskQueue = Promise.resolve();
9
- signalListeners = /* @__PURE__ */ new Map();
10
- pendingTaskQueue = [];
11
- isProcessingPending = !1;
12
- async acquireLock(t) {
13
- for (let a = 0; a < 10; a++) {
14
- if (!this.isLocked)
15
- return this.isLocked = !0, this.currentTaskId = t, !0;
16
- await new Promise((r) => setTimeout(r, 100));
17
- }
18
- return !1;
19
- }
20
- releaseLock(t) {
21
- this.currentTaskId === t && (this.isLocked = !1, this.currentTaskId = null);
22
- }
23
- generateTaskId() {
24
- return `${this.instanceId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
25
- }
26
- emitSignal(t) {
27
- const e = this.signalListeners.get(t);
28
- e && (e.forEach((s) => {
29
- this.resolveTask(s);
30
- }), this.signalListeners.delete(t));
31
- }
32
- // 대기 중인 태스크들을 처리하는 메서드
33
- async processPendingTasks() {
34
- if (!(this.isProcessingPending || this.pendingTaskQueue.length === 0)) {
35
- this.isProcessingPending = !0;
36
- try {
37
- for (; this.pendingTaskQueue.length > 0; ) {
38
- const t = this.pendingTaskQueue[0];
39
- if (t.status === "COMPLETED" || t.status === "FAILED" || t.status === "ROLLEDBACK") {
40
- this.pendingTaskQueue.shift();
41
- continue;
42
- }
43
- if (t.status === "MANUAL_PENDING" || t.status === "SIGNAL_PENDING" || t.status === "PROCESSING" || t.status === "PENDING")
44
- break;
45
- }
46
- } finally {
47
- this.isProcessingPending = !1;
48
- }
49
- }
50
- }
51
- // 모든 대기 중인 태스크가 완료될 때까지 대기
52
- async waitForPendingTasks() {
53
- return new Promise((t) => {
54
- const e = () => {
55
- this.pendingTaskQueue.filter(
56
- (a) => a.status === "MANUAL_PENDING" || a.status === "SIGNAL_PENDING"
57
- ).length === 0 ? t() : setTimeout(e, 100);
58
- };
59
- e();
60
- });
61
- }
62
- // 태스크 상태 변경 대기 큐 처리
63
- async onTaskStatusChange(t, e) {
64
- (e === "COMPLETED" || e === "FAILED" || e === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((s) => s.id !== t), await this.processPendingTasks());
65
- }
66
- async addTask(t, e = {}) {
67
- const s = e.id || this.generateTaskId();
68
- return new Promise((a, r) => {
69
- this.taskQueue = this.taskQueue.then(async () => {
70
- try {
71
- const { control: o, validate: c, rollback: l, dependencies: u = [], delay: d } = e, m = new AbortController(), i = {
72
- id: s,
73
- execute: t,
74
- timestamp: Date.now(),
75
- retryCount: 0,
76
- status: "PENDING",
77
- dependencies: u,
78
- instanceId: this.instanceId,
79
- validate: c,
80
- rollback: l,
81
- control: o,
82
- abortController: m
83
- };
84
- this.tasks.set(i.id, i), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(i), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((P) => P.id !== i.id));
85
- try {
86
- if (!await this.acquireLock(i.id))
87
- throw i.status = "FAILED", new Error("FAILED");
88
- try {
89
- i.status = "PROCESSING";
90
- for (const f of i.dependencies) {
91
- const y = this.tasks.get(f);
92
- if (!y || y.status !== "COMPLETED")
93
- throw i.status = "FAILED", new Error("FAILED");
94
- }
95
- if (i.validate && !await i.validate())
96
- throw i.status = "FAILED", new Error("FAILED");
97
- d && d > 0 && await new Promise((f) => setTimeout(f, d));
98
- const h = await i.execute(i.abortController);
99
- if (i.abortController.signal.aborted) {
100
- i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), a({
101
- success: !0,
102
- result: void 0,
103
- taskId: i.id,
104
- timestamp: Date.now(),
105
- instanceId: this.instanceId
106
- });
107
- return;
108
- }
109
- if (e.control) {
110
- const f = e.control;
111
- if (f.delay && f.delay > 0 && await new Promise((y) => setTimeout(y, f.delay)), f.manual) {
112
- i.status = "MANUAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
113
- return;
114
- }
115
- if (f.signal) {
116
- i.status = "SIGNAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.signalListeners.has(f.signal) || this.signalListeners.set(f.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(f.signal).add(i.id), this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "SIGNAL_PENDING");
117
- return;
118
- }
119
- if (f.condition && !await f.condition()) {
120
- i.status = "MANUAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
121
- return;
122
- }
123
- }
124
- i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), a({
125
- success: !0,
126
- result: h,
127
- taskId: i.id,
128
- timestamp: Date.now(),
129
- instanceId: this.instanceId
130
- });
131
- } catch (h) {
132
- if (i.status = "FAILED", i.rollback)
133
- try {
134
- await i.rollback(), i.status = "ROLLEDBACK";
135
- } catch {
136
- }
137
- throw await this.onTaskStatusChange(i.id, i.status), h;
138
- } finally {
139
- this.releaseLock(i.id);
140
- }
141
- } catch (P) {
142
- r(P);
143
- }
144
- } catch (o) {
145
- r(o);
146
- }
147
- }).catch(r);
148
- });
149
- }
150
- async resolveTask(t) {
151
- const e = this.tasks.get(t);
152
- if (!e || e.status !== "MANUAL_PENDING" && e.status !== "SIGNAL_PENDING")
153
- return !1;
154
- if (e.manualResolver) {
155
- if (e.control?.condition && !await e.control.condition())
156
- return !1;
157
- e.status = "COMPLETED";
158
- const s = e.manualResolver;
159
- return s.resolve({
160
- success: !0,
161
- result: s.result,
162
- taskId: e.id,
163
- timestamp: Date.now(),
164
- instanceId: this.instanceId
165
- }), delete e.manualResolver, await this.onTaskStatusChange(t, "COMPLETED"), !0;
166
- }
167
- return !1;
168
- }
169
- async resolveAllPending() {
170
- const t = Array.from(this.tasks.values()).filter(
171
- (e) => ["PENDING", "MANUAL_PENDING", "SIGNAL_PENDING"].includes(e.status)
172
- );
173
- await Promise.all(t.map((e) => this.resolveTask(e.id)));
174
- }
1
+ import { createStore as e } from "zustand/vanilla";
2
+ import { match as t, pathToRegexp as n } from "path-to-regexp";
3
+ var r = new class {
4
+ tasks = /* @__PURE__ */ new Map();
5
+ instanceId = Date.now().toString();
6
+ isLocked = !1;
7
+ currentTaskId = null;
8
+ taskQueue = Promise.resolve();
9
+ signalListeners = /* @__PURE__ */ new Map();
10
+ pendingTaskQueue = [];
11
+ isProcessingPending = !1;
12
+ async acquireLock(e) {
13
+ for (let t = 0; t < 10; t++) {
14
+ if (!this.isLocked) return this.isLocked = !0, this.currentTaskId = e, !0;
15
+ await new Promise((e) => setTimeout(e, 100));
16
+ }
17
+ return !1;
18
+ }
19
+ releaseLock(e) {
20
+ this.currentTaskId === e && (this.isLocked = !1, this.currentTaskId = null);
21
+ }
22
+ generateTaskId() {
23
+ return `${this.instanceId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
24
+ }
25
+ emitSignal(e) {
26
+ let t = this.signalListeners.get(e);
27
+ t && (t.forEach((e) => {
28
+ this.resolveTask(e);
29
+ }), this.signalListeners.delete(e));
30
+ }
31
+ async processPendingTasks() {
32
+ if (!(this.isProcessingPending || this.pendingTaskQueue.length === 0)) {
33
+ this.isProcessingPending = !0;
34
+ try {
35
+ for (; this.pendingTaskQueue.length > 0;) {
36
+ let e = this.pendingTaskQueue[0];
37
+ if (e.status === "COMPLETED" || e.status === "FAILED" || e.status === "ROLLEDBACK") {
38
+ this.pendingTaskQueue.shift();
39
+ continue;
40
+ }
41
+ if (e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING" || e.status === "PROCESSING" || e.status === "PENDING") break;
42
+ }
43
+ } finally {
44
+ this.isProcessingPending = !1;
45
+ }
46
+ }
47
+ }
48
+ async waitForPendingTasks() {
49
+ 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);
52
+ };
53
+ t();
54
+ });
55
+ }
56
+ async onTaskStatusChange(e, t) {
57
+ (t === "COMPLETED" || t === "FAILED" || t === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((t) => t.id !== e), await this.processPendingTasks());
58
+ }
59
+ async addTask(e, t = {}) {
60
+ let n = t.id || this.generateTaskId();
61
+ return new Promise((r, i) => {
62
+ this.taskQueue = this.taskQueue.then(async () => {
63
+ try {
64
+ let { control: a, validate: o, rollback: s, dependencies: c = [], delay: l } = t, u = new AbortController(), d = {
65
+ id: n,
66
+ execute: e,
67
+ timestamp: Date.now(),
68
+ retryCount: 0,
69
+ status: "PENDING",
70
+ dependencies: c,
71
+ instanceId: this.instanceId,
72
+ validate: o,
73
+ rollback: s,
74
+ control: a,
75
+ abortController: u
76
+ };
77
+ this.tasks.set(d.id, d), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(d), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((e) => e.id !== d.id));
78
+ try {
79
+ if (!await this.acquireLock(d.id)) throw d.status = "FAILED", Error("FAILED");
80
+ try {
81
+ d.status = "PROCESSING";
82
+ for (let e of d.dependencies) {
83
+ let t = this.tasks.get(e);
84
+ if (!t || t.status !== "COMPLETED") throw d.status = "FAILED", Error("FAILED");
85
+ }
86
+ if (d.validate && !await d.validate()) throw d.status = "FAILED", Error("FAILED");
87
+ l && l > 0 && await new Promise((e) => setTimeout(e, l));
88
+ let e = await d.execute(d.abortController);
89
+ if (d.abortController.signal.aborted) {
90
+ d.status = "COMPLETED", await this.onTaskStatusChange(d.id, "COMPLETED"), r({
91
+ success: !0,
92
+ result: void 0,
93
+ taskId: d.id,
94
+ timestamp: Date.now(),
95
+ instanceId: this.instanceId
96
+ });
97
+ return;
98
+ }
99
+ if (t.control) {
100
+ let n = t.control;
101
+ if (n.delay && n.delay > 0 && await new Promise((e) => setTimeout(e, n.delay)), n.manual) {
102
+ d.status = "MANUAL_PENDING", d.manualResolver = {
103
+ resolve: r,
104
+ reject: i,
105
+ result: e
106
+ }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
107
+ return;
108
+ }
109
+ if (n.signal) {
110
+ d.status = "SIGNAL_PENDING", d.manualResolver = {
111
+ resolve: r,
112
+ reject: i,
113
+ 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");
115
+ return;
116
+ }
117
+ if (n.condition && !await n.condition()) {
118
+ d.status = "MANUAL_PENDING", d.manualResolver = {
119
+ resolve: r,
120
+ reject: i,
121
+ result: e
122
+ }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
123
+ return;
124
+ }
125
+ }
126
+ d.status = "COMPLETED", await this.onTaskStatusChange(d.id, "COMPLETED"), r({
127
+ success: !0,
128
+ result: e,
129
+ taskId: d.id,
130
+ timestamp: Date.now(),
131
+ instanceId: this.instanceId
132
+ });
133
+ } catch (e) {
134
+ if (d.status = "FAILED", d.rollback) try {
135
+ await d.rollback(), d.status = "ROLLEDBACK";
136
+ } catch {}
137
+ throw await this.onTaskStatusChange(d.id, d.status), e;
138
+ } finally {
139
+ this.releaseLock(d.id);
140
+ }
141
+ } catch (e) {
142
+ i(e);
143
+ }
144
+ } catch (e) {
145
+ i(e);
146
+ }
147
+ }).catch(i);
148
+ });
149
+ }
150
+ async resolveTask(e) {
151
+ let t = this.tasks.get(e);
152
+ if (!t || t.status !== "MANUAL_PENDING" && t.status !== "SIGNAL_PENDING") return !1;
153
+ if (t.manualResolver) {
154
+ if (t.control?.condition && !await t.control.condition()) return !1;
155
+ t.status = "COMPLETED";
156
+ let n = t.manualResolver;
157
+ return n.resolve({
158
+ success: !0,
159
+ result: n.result,
160
+ taskId: t.id,
161
+ timestamp: Date.now(),
162
+ instanceId: this.instanceId
163
+ }), delete t.manualResolver, await this.onTaskStatusChange(e, "COMPLETED"), !0;
164
+ }
165
+ return !1;
166
+ }
167
+ async resolveAllPending() {
168
+ let e = Array.from(this.tasks.values()).filter((e) => [
169
+ "PENDING",
170
+ "MANUAL_PENDING",
171
+ "SIGNAL_PENDING"
172
+ ].includes(e.status));
173
+ await Promise.all(e.map((e) => this.resolveTask(e.id)));
174
+ }
175
+ }();
176
+ //#endregion
177
+ //#region src/history/store.ts
178
+ function i(t = [], n = -1) {
179
+ return e((e) => ({
180
+ index: n,
181
+ histories: t,
182
+ addHistory: (t) => e((e) => ({
183
+ index: e.index + 1,
184
+ histories: e.histories.concat(t)
185
+ })),
186
+ replaceHistory: (t) => e((e) => (e.histories.splice(t, 1), {
187
+ index: e.index - 1,
188
+ histories: e.histories
189
+ })),
190
+ popHistory: (t) => e((e) => ({
191
+ index: e.index - 1,
192
+ histories: e.histories.filter((e, n) => n !== t)
193
+ })),
194
+ popHistories: (t) => {
195
+ t <= 0 || e((e) => {
196
+ let n = e.index;
197
+ return {
198
+ index: e.index - t,
199
+ histories: e.histories.filter((e, r) => r < n - t || r >= n)
200
+ };
201
+ });
202
+ },
203
+ setTransitionName: (t, n) => e((e) => {
204
+ let r = e.histories[t];
205
+ if (!r || r.transitionName === n) return {};
206
+ let i = e.histories.slice();
207
+ return i[t] = {
208
+ ...r,
209
+ transitionName: n
210
+ }, { histories: i };
211
+ })
212
+ }));
175
213
  }
176
- const yt = new Q(), Pt = w((n) => ({
177
- index: -1,
178
- histories: [],
179
- addHistory: (t) => n((e) => ({
180
- index: e.index + 1,
181
- histories: e.histories.concat(t)
182
- })),
183
- replaceHistory: (t) => n((e) => (e.histories.splice(t, 1), {
184
- index: e.index - 1,
185
- histories: e.histories
186
- })),
187
- popHistory: (t) => n((e) => ({
188
- index: e.index - 1,
189
- histories: e.histories.filter((s, a) => a !== t)
190
- })),
191
- // Drop `count` entries sitting directly below the current top, keeping the
192
- // top itself. Used by pop(n) to remove the screens it skips over in the same
193
- // synchronous block that starts the transition — so they never paint — while
194
- // the leaving top stays mounted to drive and resolve the animation.
195
- popHistories: (t) => {
196
- t <= 0 || n((e) => {
197
- const s = e.index;
198
- return {
199
- index: e.index - t,
200
- histories: e.histories.filter((a, r) => r < s - t || r >= s)
201
- };
202
- });
203
- },
204
- // Override one entry's transition. Used by pop() to relabel the leaving top
205
- // before the POPPING flip so the back animation uses the caller's
206
- // `transitionName` from the first frame — its original transition never
207
- // paints. Returns a fresh array so the renderer re-reads it.
208
- setTransitionName: (t, e) => n((s) => {
209
- const a = s.histories[t];
210
- if (!a || a.transitionName === e) return {};
211
- const r = s.histories.slice();
212
- return r[t] = { ...a, transitionName: e }, { histories: r };
213
- })
214
- })), gt = w((n) => ({
215
- status: "IDLE",
216
- transitionTaskId: null,
217
- setStatus: (t) => n({ status: t }),
218
- setTransitionTaskId: (t) => n({ transitionTaskId: t })
219
- }));
220
- let L = 0;
221
- function It() {
222
- L += 1;
214
+ //#endregion
215
+ //#region src/navigate/store.ts
216
+ function a() {
217
+ return e((e) => ({
218
+ status: "IDLE",
219
+ transitionTaskId: null,
220
+ setStatus: (t) => e({ status: t }),
221
+ setTransitionTaskId: (t) => e({ transitionTaskId: t })
222
+ }));
223
223
  }
224
- function Et() {
225
- return L > 0 ? (L -= 1, !0) : !1;
224
+ //#endregion
225
+ //#region src/navigate/selfPopGuard.ts
226
+ var o = 0;
227
+ function s() {
228
+ o += 1;
226
229
  }
227
- function T({
228
- name: n,
229
- initial: t,
230
- idle: e,
231
- enter: s,
232
- enterBack: a,
233
- exit: r,
234
- exitBack: o,
235
- options: c
236
- }) {
237
- return {
238
- name: n,
239
- initial: t,
240
- variants: {
241
- "IDLE-true": e,
242
- "IDLE-false": e,
243
- "PUSHING-false": r,
244
- "PUSHING-true": s,
245
- "REPLACING-false": r,
246
- "REPLACING-true": s,
247
- "POPPING-false": o,
248
- "POPPING-true": a,
249
- "COMPLETED-false": r,
250
- "COMPLETED-true": s
251
- },
252
- ...c
253
- };
230
+ function c() {
231
+ return o > 0 ? (--o, !0) : !1;
254
232
  }
255
- function kt({
256
- name: n,
257
- initial: t,
258
- idle: e,
259
- pushOnEnter: s,
260
- pushOnExit: a,
261
- replaceOnEnter: r,
262
- replaceOnExit: o,
263
- popOnEnter: c,
264
- popOnExit: l,
265
- completedOnExit: u,
266
- completedOnEnter: d,
267
- options: m
268
- }) {
269
- return {
270
- name: n,
271
- initial: t,
272
- variants: {
273
- "IDLE-true": e,
274
- "IDLE-false": e,
275
- "PUSHING-false": a,
276
- "PUSHING-true": s,
277
- "REPLACING-false": o,
278
- "REPLACING-true": r,
279
- "POPPING-false": l,
280
- "POPPING-true": c,
281
- "COMPLETED-false": u,
282
- "COMPLETED-true": d
283
- },
284
- ...m
285
- };
233
+ //#endregion
234
+ //#region src/transition/createTransition.ts
235
+ function l({ name: e, initial: t, idle: n, enter: r, enterBack: i, exit: a, exitBack: o, options: s }) {
236
+ return {
237
+ name: e,
238
+ initial: t,
239
+ variants: {
240
+ "IDLE-true": n,
241
+ "IDLE-false": n,
242
+ "PUSHING-false": a,
243
+ "PUSHING-true": r,
244
+ "REPLACING-false": a,
245
+ "REPLACING-true": r,
246
+ "POPPING-false": o,
247
+ "POPPING-true": i,
248
+ "COMPLETED-false": a,
249
+ "COMPLETED-true": r
250
+ },
251
+ ...s
252
+ };
286
253
  }
287
- const X = (n, t, e) => {
288
- const [s, a] = t, [r, o] = e;
289
- if (a === s) return r;
290
- const c = (n - s) / (a - s);
291
- return r + c * (o - r);
292
- }, F = T({
293
- name: "cupertino",
294
- initial: {
295
- x: "100%"
296
- },
297
- idle: {
298
- value: {
299
- x: 0
300
- },
301
- options: {
302
- duration: 0
303
- }
304
- },
305
- enter: {
306
- value: {
307
- x: 0
308
- },
309
- options: {
310
- duration: 0.7,
311
- ease: [0.32, 0.72, 0, 1]
312
- }
313
- },
314
- enterBack: {
315
- value: {
316
- x: "100%"
317
- },
318
- options: {
319
- duration: 0.6,
320
- ease: [0.32, 0.72, 0, 1]
321
- }
322
- },
323
- exit: {
324
- value: {
325
- x: "-30%"
326
- },
327
- options: {
328
- duration: 0.7,
329
- ease: [0.32, 0.72, 0, 1]
330
- }
331
- },
332
- exitBack: {
333
- value: {
334
- x: 0
335
- },
336
- options: {
337
- duration: 0.6,
338
- ease: [0.32, 0.72, 0, 1]
339
- }
340
- },
341
- options: {
342
- decoratorName: "overlay",
343
- swipeDirection: "x",
344
- onSwipeStart: async () => !0,
345
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
346
- const { offset: o } = t, c = o.x, l = X(c, [0, window.innerWidth], [0, 100]);
347
- return r?.(!0, l), e(
348
- s,
349
- {
350
- x: Math.max(0, c)
351
- },
352
- {
353
- duration: 0
354
- }
355
- ), e(
356
- a,
357
- {
358
- x: `${-30 + l * 0.3}%`
359
- },
360
- {
361
- duration: 0
362
- }
363
- ), l;
364
- },
365
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
366
- const { offset: o, velocity: c } = t, u = o.x > 50 || c.x > 20;
367
- return r?.(u), await Promise.all([
368
- e(
369
- s,
370
- {
371
- x: u ? "100%" : 0
372
- },
373
- {
374
- duration: 0.3,
375
- ease: [0.32, 0.72, 0, 1]
376
- }
377
- ),
378
- e(
379
- a,
380
- {
381
- x: u ? 0 : "-30%"
382
- },
383
- {
384
- duration: 0.3,
385
- ease: [0.32, 0.72, 0, 1]
386
- }
387
- )
388
- ]), u;
389
- }
390
- }
391
- }), z = (n, t, e) => {
392
- const [s, a] = t, [r, o] = e;
393
- if (a === s) return r;
394
- const c = (n - s) / (a - s);
395
- return r + c * (o - r);
396
- }, V = T({
397
- name: "layout",
398
- initial: {
399
- opacity: 0.97
400
- },
401
- idle: {
402
- value: {
403
- opacity: 1
404
- },
405
- options: {
406
- duration: 0.3
407
- }
408
- },
409
- enter: {
410
- value: {
411
- opacity: 1
412
- },
413
- options: {
414
- duration: 0.3
415
- }
416
- },
417
- enterBack: {
418
- value: {
419
- opacity: 0.97
420
- },
421
- options: {
422
- duration: 0.3
423
- }
424
- },
425
- exit: {
426
- value: {
427
- opacity: 0.97
428
- },
429
- options: {
430
- duration: 0.3
431
- }
432
- },
433
- exitBack: {
434
- value: {
435
- opacity: 1
436
- },
437
- options: {
438
- duration: 0.3
439
- }
440
- },
441
- options: {
442
- decoratorName: "overlay",
443
- swipeDirection: "y",
444
- onSwipeStart: async () => !0,
445
- onSwipe: (n, t, { animate: e, currentScreen: s, onProgress: a }) => {
446
- const { offset: r } = t, o = r.y, c = Math.max(0, Math.min(56, o)), l = z(c, [0, 56], [1, 0.96]), u = Math.max(0, o - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, i = Math.max(0, c + m), p = Math.min(56, i);
447
- return a?.(!0, 100), e(
448
- s,
449
- {
450
- y: i,
451
- opacity: l
452
- },
453
- {
454
- duration: 0
455
- }
456
- ), p;
457
- },
458
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
459
- const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
460
- return r?.(u), await Promise.all([
461
- e(
462
- s,
463
- {
464
- y: u ? "100%" : 0,
465
- opacity: u ? 0.96 : 1
466
- },
467
- {
468
- duration: 0.3
469
- }
470
- ),
471
- e(
472
- a,
473
- {
474
- y: 0,
475
- opacity: u ? 1 : 0.97
476
- },
477
- {
478
- duration: 0.3
479
- }
480
- )
481
- ]), u;
482
- }
483
- }
484
- }), Z = T({
485
- name: "material",
486
- initial: {
487
- y: "100%"
488
- },
489
- idle: {
490
- value: {
491
- y: 0,
492
- opacity: 1
493
- },
494
- options: {
495
- duration: 0
496
- }
497
- },
498
- enter: {
499
- value: {
500
- y: 0
501
- },
502
- options: {
503
- duration: 0.35,
504
- ease: [0, 0, 0.2, 1]
505
- }
506
- },
507
- enterBack: {
508
- value: {
509
- y: "100%"
510
- },
511
- options: {
512
- duration: 0.25,
513
- ease: [0.4, 0, 1, 1]
514
- }
515
- },
516
- exit: {
517
- value: {
518
- y: -56,
519
- opacity: 0
520
- },
521
- options: {
522
- duration: 0.35,
523
- ease: [0.4, 0, 1, 1]
524
- }
525
- },
526
- exitBack: {
527
- value: {
528
- y: 0,
529
- opacity: 1
530
- },
531
- options: {
532
- duration: 0.25,
533
- ease: [0, 0, 0.2, 1]
534
- }
535
- },
536
- options: {
537
- swipeDirection: "y",
538
- onSwipeStart: async () => !0,
539
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
540
- const { offset: o } = t, c = o.y, l = Math.max(0, Math.min(56, c)), u = Math.max(0, c - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, i = Math.max(0, l + m), p = Math.min(56, i);
541
- return r?.(!0, p), e(
542
- s,
543
- {
544
- y: i
545
- },
546
- {
547
- duration: 0
548
- }
549
- ), e(
550
- a,
551
- {
552
- y: -56 + p,
553
- opacity: p / 56
554
- },
555
- { duration: 0 }
556
- ), p;
557
- },
558
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
559
- const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
560
- return r?.(u), await Promise.all([
561
- e(
562
- s,
563
- {
564
- y: u ? "100%" : 0
565
- },
566
- {
567
- duration: u ? 0.22 : 0.24,
568
- ease: u ? [0.4, 0, 1, 1] : [0, 0, 0.2, 1]
569
- }
570
- ),
571
- e(
572
- a,
573
- {
574
- y: u ? 0 : -56,
575
- opacity: u ? 1 : 0
576
- },
577
- {
578
- duration: u ? 0.22 : 0.24,
579
- ease: u ? [0, 0, 0.2, 1] : [0.4, 0, 1, 1]
580
- }
581
- )
582
- ]), u;
583
- }
584
- }
585
- }), j = T({
586
- name: "none",
587
- initial: {},
588
- idle: {
589
- value: {},
590
- options: {
591
- duration: 0
592
- }
593
- },
594
- enter: {
595
- value: {},
596
- options: {
597
- duration: 0
598
- }
599
- },
600
- enterBack: {
601
- value: {},
602
- options: {
603
- duration: 0
604
- }
605
- },
606
- exit: {
607
- value: {},
608
- options: {
609
- duration: 0
610
- }
611
- },
612
- exitBack: {
613
- value: {},
614
- options: {
615
- duration: 0
616
- }
617
- }
618
- }), Tt = /* @__PURE__ */ new Map([
619
- ["none", j],
620
- ["cupertino", F],
621
- ["material", Z],
622
- ["layout", V]
623
- ]), Nt = w((n) => ({
624
- defaultTransitionName: "cupertino",
625
- setDefaultTransitionName: (t) => n({ defaultTransitionName: t })
626
- }));
627
- function K({
628
- name: n,
629
- initial: t,
630
- idle: e,
631
- enter: s,
632
- exit: a,
633
- options: r
634
- }) {
635
- return {
636
- name: n,
637
- initial: t,
638
- variants: {
639
- "IDLE-true": e,
640
- "IDLE-false": e,
641
- "PUSHING-true": e,
642
- "PUSHING-false": s,
643
- "REPLACING-true": e,
644
- "REPLACING-false": s,
645
- "POPPING-true": e,
646
- "POPPING-false": a,
647
- "COMPLETED-true": e,
648
- "COMPLETED-false": s
649
- },
650
- ...r
651
- };
254
+ //#endregion
255
+ //#region src/transition/createRawTransition.ts
256
+ function u({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnExit: l, completedOnEnter: u, options: d }) {
257
+ return {
258
+ name: e,
259
+ initial: t,
260
+ variants: {
261
+ "IDLE-true": n,
262
+ "IDLE-false": n,
263
+ "PUSHING-false": i,
264
+ "PUSHING-true": r,
265
+ "REPLACING-false": o,
266
+ "REPLACING-true": a,
267
+ "POPPING-false": c,
268
+ "POPPING-true": s,
269
+ "COMPLETED-false": l,
270
+ "COMPLETED-true": u
271
+ },
272
+ ...d
273
+ };
652
274
  }
653
- function Lt({
654
- name: n,
655
- initial: t,
656
- idle: e,
657
- pushOnEnter: s,
658
- pushOnExit: a,
659
- replaceOnEnter: r,
660
- replaceOnExit: o,
661
- popOnEnter: c,
662
- popOnExit: l,
663
- completedOnEnter: u,
664
- completedOnExit: d,
665
- options: m
666
- }) {
667
- return {
668
- name: n,
669
- initial: t,
670
- variants: {
671
- "IDLE-true": e,
672
- "IDLE-false": e,
673
- "PUSHING-false": a,
674
- "PUSHING-true": s,
675
- "REPLACING-false": o,
676
- "REPLACING-true": r,
677
- "POPPING-false": l,
678
- "POPPING-true": c,
679
- "COMPLETED-false": d,
680
- "COMPLETED-true": u
681
- },
682
- ...m
683
- };
275
+ //#endregion
276
+ //#region src/transition/cupertino.ts
277
+ var d = (e, t, n) => {
278
+ let [r, i] = t, [a, o] = n;
279
+ return i === r ? a : a + (e - r) / (i - r) * (o - a);
280
+ }, f = l({
281
+ name: "cupertino",
282
+ initial: { x: "100%" },
283
+ idle: {
284
+ value: { x: 0 },
285
+ options: { duration: 0 }
286
+ },
287
+ enter: {
288
+ value: { x: 0 },
289
+ options: {
290
+ duration: .7,
291
+ ease: [
292
+ .32,
293
+ .72,
294
+ 0,
295
+ 1
296
+ ]
297
+ }
298
+ },
299
+ enterBack: {
300
+ value: { x: "100%" },
301
+ options: {
302
+ duration: .6,
303
+ ease: [
304
+ .32,
305
+ .72,
306
+ 0,
307
+ 1
308
+ ]
309
+ }
310
+ },
311
+ exit: {
312
+ value: { x: "-30%" },
313
+ options: {
314
+ duration: .7,
315
+ ease: [
316
+ .32,
317
+ .72,
318
+ 0,
319
+ 1
320
+ ]
321
+ }
322
+ },
323
+ exitBack: {
324
+ value: { x: 0 },
325
+ options: {
326
+ duration: .6,
327
+ ease: [
328
+ .32,
329
+ .72,
330
+ 0,
331
+ 1
332
+ ]
333
+ }
334
+ },
335
+ options: {
336
+ decoratorName: "overlay",
337
+ swipeDirection: "x",
338
+ onSwipeStart: async () => !0,
339
+ onSwipe: (e, t, { animate: n, currentScreen: r, prevScreen: i, onProgress: a }) => {
340
+ let { offset: o } = t, s = o.x, c = d(s, [0, window.innerWidth], [0, 100]);
341
+ return a?.(!0, c), n(r, { x: Math.max(0, s) }, { duration: 0 }), n(i, { x: `${-30 + c * .3}%` }, { duration: 0 }), c;
342
+ },
343
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
344
+ let { offset: o, velocity: s } = t, c = o.x > 50 || s.x > 20;
345
+ return a?.(c), await Promise.all([n(r, { x: c ? "100%" : 0 }, {
346
+ duration: .3,
347
+ ease: [
348
+ .32,
349
+ .72,
350
+ 0,
351
+ 1
352
+ ]
353
+ }), n(i, { x: c ? 0 : "-30%" }, {
354
+ duration: .3,
355
+ ease: [
356
+ .32,
357
+ .72,
358
+ 0,
359
+ 1
360
+ ]
361
+ })]), c;
362
+ }
363
+ }
364
+ }), p = (e, t, n) => {
365
+ let [r, i] = t, [a, o] = n;
366
+ return i === r ? a : a + (e - r) / (i - r) * (o - a);
367
+ }, m = l({
368
+ name: "layout",
369
+ initial: { opacity: .97 },
370
+ idle: {
371
+ value: { opacity: 1 },
372
+ options: { duration: .3 }
373
+ },
374
+ enter: {
375
+ value: { opacity: 1 },
376
+ options: { duration: .3 }
377
+ },
378
+ enterBack: {
379
+ value: { opacity: .97 },
380
+ options: { duration: .3 }
381
+ },
382
+ exit: {
383
+ value: { opacity: .97 },
384
+ options: { duration: .3 }
385
+ },
386
+ exitBack: {
387
+ value: { opacity: 1 },
388
+ options: { duration: .3 }
389
+ },
390
+ options: {
391
+ decoratorName: "overlay",
392
+ swipeDirection: "y",
393
+ onSwipeStart: async () => !0,
394
+ onSwipe: (e, t, { animate: n, currentScreen: r, onProgress: i }) => {
395
+ let { offset: a } = t, o = a.y, s = Math.max(0, Math.min(56, o)), c = p(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), m = Math.min(56, f);
396
+ return i?.(!0, 100), n(r, {
397
+ y: f,
398
+ opacity: c
399
+ }, { duration: 0 }), m;
400
+ },
401
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
402
+ let { offset: o, velocity: s } = t, c = o.y > 56 || s.y > 20;
403
+ return a?.(c), await Promise.all([n(r, {
404
+ y: c ? "100%" : 0,
405
+ opacity: c ? .96 : 1
406
+ }, { duration: .3 }), n(i, {
407
+ y: 0,
408
+ opacity: c ? 1 : .97
409
+ }, { duration: .3 })]), c;
410
+ }
411
+ }
412
+ }), h = l({
413
+ name: "material",
414
+ initial: { y: "100%" },
415
+ idle: {
416
+ value: {
417
+ y: 0,
418
+ opacity: 1
419
+ },
420
+ options: { duration: 0 }
421
+ },
422
+ enter: {
423
+ value: { y: 0 },
424
+ options: {
425
+ duration: .35,
426
+ ease: [
427
+ 0,
428
+ 0,
429
+ .2,
430
+ 1
431
+ ]
432
+ }
433
+ },
434
+ enterBack: {
435
+ value: { y: "100%" },
436
+ options: {
437
+ duration: .25,
438
+ ease: [
439
+ .4,
440
+ 0,
441
+ 1,
442
+ 1
443
+ ]
444
+ }
445
+ },
446
+ exit: {
447
+ value: {
448
+ y: -56,
449
+ opacity: 0
450
+ },
451
+ options: {
452
+ duration: .35,
453
+ ease: [
454
+ .4,
455
+ 0,
456
+ 1,
457
+ 1
458
+ ]
459
+ }
460
+ },
461
+ exitBack: {
462
+ value: {
463
+ y: 0,
464
+ opacity: 1
465
+ },
466
+ options: {
467
+ duration: .25,
468
+ ease: [
469
+ 0,
470
+ 0,
471
+ .2,
472
+ 1
473
+ ]
474
+ }
475
+ },
476
+ options: {
477
+ swipeDirection: "y",
478
+ onSwipeStart: async () => !0,
479
+ onSwipe: (e, t, { animate: n, currentScreen: r, prevScreen: i, onProgress: a }) => {
480
+ let { offset: o } = t, s = o.y, c = Math.max(0, Math.min(56, s)), l = Math.max(0, s - 56), u = Math.min(1, l / 160), d = Math.sqrt(u) * 12, f = Math.max(0, c + d), p = Math.min(56, f);
481
+ return a?.(!0, p), n(r, { y: f }, { duration: 0 }), n(i, {
482
+ y: -56 + p,
483
+ opacity: p / 56
484
+ }, { duration: 0 }), p;
485
+ },
486
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
487
+ let { offset: o, velocity: s } = t, c = o.y > 56 || s.y > 20;
488
+ return a?.(c), await Promise.all([n(r, { y: c ? "100%" : 0 }, {
489
+ duration: c ? .22 : .24,
490
+ ease: c ? [
491
+ .4,
492
+ 0,
493
+ 1,
494
+ 1
495
+ ] : [
496
+ 0,
497
+ 0,
498
+ .2,
499
+ 1
500
+ ]
501
+ }), n(i, {
502
+ y: c ? 0 : -56,
503
+ opacity: +!!c
504
+ }, {
505
+ duration: c ? .22 : .24,
506
+ ease: c ? [
507
+ 0,
508
+ 0,
509
+ .2,
510
+ 1
511
+ ] : [
512
+ .4,
513
+ 0,
514
+ 1,
515
+ 1
516
+ ]
517
+ })]), c;
518
+ }
519
+ }
520
+ }), g = l({
521
+ name: "none",
522
+ initial: {},
523
+ idle: {
524
+ value: {},
525
+ options: { duration: 0 }
526
+ },
527
+ enter: {
528
+ value: {},
529
+ options: { duration: 0 }
530
+ },
531
+ enterBack: {
532
+ value: {},
533
+ options: { duration: 0 }
534
+ },
535
+ exit: {
536
+ value: {},
537
+ options: { duration: 0 }
538
+ },
539
+ exitBack: {
540
+ value: {},
541
+ options: { duration: 0 }
542
+ }
543
+ }), _ = new Map([
544
+ ["none", g],
545
+ ["cupertino", f],
546
+ ["material", h],
547
+ ["layout", m]
548
+ ]);
549
+ //#endregion
550
+ //#region src/transition/store.ts
551
+ function v(t = "cupertino") {
552
+ return e((e) => ({
553
+ defaultTransitionName: t,
554
+ setDefaultTransitionName: (t) => e({ defaultTransitionName: t })
555
+ }));
684
556
  }
685
- const I = "rgba(0, 0, 0, 0.3)", q = K({
686
- name: "overlay",
687
- initial: {
688
- opacity: 0,
689
- backgroundColor: I
690
- },
691
- idle: {
692
- value: {
693
- opacity: 0,
694
- backgroundColor: I
695
- },
696
- options: {
697
- duration: 0
698
- }
699
- },
700
- // Visible dim — applied when this screen is the one going behind / sitting
701
- // behind a new active screen (PUSHING-false / REPLACING-false / COMPLETED-false).
702
- // Duration matches cupertino's enter so the dim resolves in lockstep with the
703
- // underlying screen slide (and there's no animation-vs-hold-by-fill window for
704
- // the rest-rule handoff to race against — that's a function of duration + fill,
705
- // not the curve). Easing is intentionally left at the default: this animates
706
- // `opacity` (a luminance channel), not position, so cupertino's positional
707
- // decelerate curve would front-load the darkening into an abrupt step with a
708
- // long invisible tail. The default ease spreads the perceived dim evenly across
709
- // the duration, matching this decorator's linear-perceived-ramp design (see the
710
- // DIM_COLOR note above).
711
- enter: {
712
- value: {
713
- opacity: 1,
714
- backgroundColor: I
715
- },
716
- options: {
717
- duration: 0.7
718
- }
719
- },
720
- // POPPING-false target: the previously-behind screen is returning to active.
721
- // Fades from `enter` (visible dim) back to invisible so the overlay clears
722
- // before the screen lands at COMPLETED-true (= idle). Mirrors cupertino's
723
- // enterBack (the returning screen's slide-in) duration.
724
- exit: {
725
- value: {
726
- opacity: 0,
727
- backgroundColor: I
728
- },
729
- options: {
730
- duration: 0.6
731
- }
732
- },
733
- options: {
734
- onSwipeStart: (n, { animate: t, prevDecorator: e }) => t(
735
- e,
736
- {
737
- opacity: n ? 1 : 0
738
- },
739
- {
740
- duration: 0.3
741
- }
742
- ),
743
- onSwipe: (n, t, { animate: e, prevDecorator: s }) => e(
744
- s,
745
- {
746
- opacity: Math.max(0, 1 - t / 100)
747
- },
748
- {
749
- duration: 0
750
- }
751
- ),
752
- onSwipeEnd: (n, { animate: t, prevDecorator: e }) => t(
753
- e,
754
- {
755
- opacity: n ? 0 : 1
756
- },
757
- {
758
- duration: 0.3
759
- }
760
- )
761
- }
762
- }), Dt = /* @__PURE__ */ new Map([["overlay", q]]), k = {
763
- "IDLE-true": "self",
764
- "IDLE-false": "self",
765
- "PUSHING-true": "initial",
766
- "PUSHING-false": "IDLE-true",
767
- "REPLACING-true": "initial",
768
- "REPLACING-false": "IDLE-true",
769
- "POPPING-true": "IDLE-true",
770
- "POPPING-false": "PUSHING-false",
771
- "COMPLETED-true": "self",
772
- "COMPLETED-false": "self"
773
- }, O = Object.keys(k), W = O, J = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), b = (n) => typeof n == "object" && n !== null && !Array.isArray(n), tt = /* @__PURE__ */ new Set([
774
- "opacity",
775
- "scale",
776
- "scaleX",
777
- "scaleY",
778
- "scaleZ",
779
- "aspectRatio",
780
- "columnCount",
781
- "columns",
782
- "flex",
783
- "flexGrow",
784
- "flexShrink",
785
- "fontWeight",
786
- "gridArea",
787
- "gridColumn",
788
- "gridColumnEnd",
789
- "gridColumnStart",
790
- "gridRow",
791
- "gridRowEnd",
792
- "gridRowStart",
793
- "lineHeight",
794
- "lineClamp",
795
- "order",
796
- "orphans",
797
- "tabSize",
798
- "widows",
799
- "zIndex",
800
- "zoom",
801
- // SVG numerics
802
- "fillOpacity",
803
- "floodOpacity",
804
- "stopOpacity",
805
- "strokeOpacity",
806
- "strokeDasharray",
807
- "strokeDashoffset",
808
- "strokeMiterlimit",
809
- "strokeWidth"
810
- ]), et = (n, t) => t.startsWith("--") ? `${n}` : tt.has(t) ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, $ = (n, t) => typeof t == "number" ? et(t, n) : typeof t == "string" ? t : "", R = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), _ = /* @__PURE__ */ new Set([
811
- "x",
812
- "y",
813
- "z",
814
- "scale",
815
- "scaleX",
816
- "scaleY",
817
- "rotate",
818
- "rotateX",
819
- "rotateY",
820
- "rotateZ"
821
- ]), nt = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, st = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, at = /^1(\.0+)?$/, rt = (n, t) => n === "scale" || n === "scaleX" || n === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? at.test(t.trim()) : !1 : n === "rotate" || n === "rotateX" || n === "rotateY" || n === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? st.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? nt.test(t.trim()) : !1, ot = (n, t) => {
822
- switch (n) {
823
- case "x":
824
- return `translateX(${t})`;
825
- case "y":
826
- return `translateY(${t})`;
827
- case "z":
828
- return `translateZ(${t})`;
829
- case "scale":
830
- return `scale(${t})`;
831
- case "scaleX":
832
- return `scaleX(${t})`;
833
- case "scaleY":
834
- return `scaleY(${t})`;
835
- case "rotate":
836
- case "rotateZ":
837
- return `rotate(${t})`;
838
- case "rotateX":
839
- return `rotateX(${t})`;
840
- case "rotateY":
841
- return `rotateY(${t})`;
842
- default:
843
- return "";
844
- }
845
- }, wt = (n) => {
846
- const t = /* @__PURE__ */ new Set();
847
- let e = !1;
848
- const s = (a) => {
849
- if (b(a))
850
- for (const r of Object.keys(a)) {
851
- const o = a[r];
852
- $(r, o) !== "" && (_.has(r) ? e = !0 : t.add(R(r)));
853
- }
854
- };
855
- s(n.initial);
856
- for (const a of Object.values(n.variants))
857
- s(a.value);
858
- return e && t.add("transform"), Array.from(t);
859
- }, g = (n) => {
860
- if (!b(n)) return [];
861
- const t = [];
862
- let e = !0;
863
- const s = [];
864
- for (const a of Object.keys(n)) {
865
- const r = n[a], o = $(a, r);
866
- o !== "" && (_.has(a) ? (t.push(ot(a, o)), rt(a, r) || (e = !1)) : s.push({ property: R(a), value: o }));
867
- }
868
- return t.length > 0 && s.push({
869
- property: "transform",
870
- value: e ? "none" : t.join(" ")
871
- }), s;
872
- }, E = (n) => n.map((t) => ` ${t.property}: ${t.value};`).join(`
873
- `), it = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
874
- linear: "linear",
875
- easeIn: "ease-in",
876
- easeOut: "ease-out",
877
- easeInOut: "ease-in-out",
878
- circIn: "cubic-bezier(0, 0.55, 0.45, 1)",
879
- circOut: "cubic-bezier(0.55, 0, 1, 0.45)",
880
- backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
881
- backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
882
- anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
883
- }[n] ?? "ease" : "ease", H = (n) => {
884
- if (!n) return 0;
885
- const t = n.duration;
886
- return typeof t == "number" && t >= 0 ? t : 0;
887
- }, U = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, A = (n, t) => {
888
- const [e, s] = t.split("-");
889
- return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
890
- }, M = (n, t) => {
891
- const [e, s] = t.split("-");
892
- return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
893
- }, ct = (n, t) => {
894
- const [e, s] = t.split("-");
895
- return `[data-flemo-bar][data-flemo-bar-transition="${n}"][data-flemo-bar-status="${e}"][data-flemo-bar-active="${s}"][data-flemo-bar-riding="true"]`;
896
- }, ut = (n, t, e) => `flemo-${n}-${J(t)}-${e}`, x = (n, t, e, s, a, r) => {
897
- const o = g(s), c = g(a.value), l = H(a.options), u = U(a.options), d = it(a.options?.ease), m = r(t, e), i = n === "screen" ? `${m},
898
- ${ct(t, e)}` : m;
899
- if (c.length === 0 && o.length === 0)
900
- return "";
901
- if (l <= 0 && u <= 0)
902
- return c.length === 0 ? "" : `${i} {
903
- ${E(c)}
904
- animation: none;
905
- }`;
906
- const p = ut(n, t, e), P = [
907
- `@keyframes ${p} {`,
908
- " from {",
909
- E(o).replace(/^/gm, " "),
910
- " }",
911
- " to {",
912
- E(c).replace(/^/gm, " "),
913
- " }",
914
- "}"
915
- ].join(`
916
- `), h = [
917
- `${p}`,
918
- `${l}s`,
919
- d,
920
- u > 0 ? `${u}s` : null,
921
- "both"
922
- ].filter(Boolean).join(" "), f = Array.from(
923
- /* @__PURE__ */ new Set([...o.map((N) => N.property), ...c.map((N) => N.property)])
924
- ), y = f.length > 0 ? ` will-change: ${f.join(", ")};
925
- ` : "", S = e.split("-")[0], Y = `${i} {
926
- animation: ${h};
927
- ${y}${S === "PUSHING" || S === "REPLACING" ? ` contain: layout;
928
- pointer-events: none;
929
- ` : ""}}`;
930
- return `${P}
931
- ${Y}`;
932
- }, C = (n, t, e, s) => {
933
- const a = g(s.value);
934
- return a.length === 0 ? "" : `${n(t, e)} {
935
- ${E(a)}
936
- }`;
937
- }, St = (n, t) => {
938
- const e = [];
939
- for (const s of n) {
940
- const a = s.name;
941
- for (const r of O) {
942
- const o = s.variants[r], c = k[r];
943
- if (c === "self") {
944
- e.push(C(A, a, r, o));
945
- continue;
946
- }
947
- const l = c === "initial" ? s.initial : s.variants[c].value;
948
- e.push(
949
- x("screen", a, r, l, o, A)
950
- );
951
- }
952
- }
953
- for (const s of t) {
954
- const a = s.name;
955
- for (const r of W) {
956
- const o = s.variants[r], c = k[r];
957
- if (c === "self") {
958
- e.push(C(M, a, r, o));
959
- continue;
960
- }
961
- const l = c === "initial" ? s.initial : s.variants[c].value;
962
- e.push(
963
- x(
964
- "decorator",
965
- a,
966
- r,
967
- l,
968
- o,
969
- M
970
- )
971
- );
972
- }
973
- }
974
- return e.filter((s) => s.length > 0).join(`
975
-
976
- `);
977
- }, vt = (n, t) => {
978
- const e = k[t];
979
- if (e === "self") return !1;
980
- const s = n.variants[t], a = H(s.options), r = U(s.options);
981
- if (a <= 0 && r <= 0) return !1;
982
- const o = e === "initial" ? n.initial : n.variants[e].value, c = g(o), l = g(s.value);
983
- return c.length > 0 || l.length > 0;
557
+ //#endregion
558
+ //#region src/transition/decorator/createDecorator.ts
559
+ function y({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
560
+ return {
561
+ name: e,
562
+ initial: t,
563
+ variants: {
564
+ "IDLE-true": n,
565
+ "IDLE-false": n,
566
+ "PUSHING-true": n,
567
+ "PUSHING-false": r,
568
+ "REPLACING-true": n,
569
+ "REPLACING-false": r,
570
+ "POPPING-true": n,
571
+ "POPPING-false": i,
572
+ "COMPLETED-true": n,
573
+ "COMPLETED-false": r
574
+ },
575
+ ...a
576
+ };
577
+ }
578
+ //#endregion
579
+ //#region src/transition/decorator/createRawDecorator.ts
580
+ 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 }) {
581
+ return {
582
+ name: e,
583
+ initial: t,
584
+ variants: {
585
+ "IDLE-true": n,
586
+ "IDLE-false": n,
587
+ "PUSHING-false": i,
588
+ "PUSHING-true": r,
589
+ "REPLACING-false": o,
590
+ "REPLACING-true": a,
591
+ "POPPING-false": c,
592
+ "POPPING-true": s,
593
+ "COMPLETED-false": u,
594
+ "COMPLETED-true": l
595
+ },
596
+ ...d
597
+ };
598
+ }
599
+ //#endregion
600
+ //#region src/transition/decorator/overlay.ts
601
+ var b = "rgba(0, 0, 0, 0.3)", x = y({
602
+ name: "overlay",
603
+ initial: {
604
+ opacity: 0,
605
+ backgroundColor: b
606
+ },
607
+ idle: {
608
+ value: {
609
+ opacity: 0,
610
+ backgroundColor: b
611
+ },
612
+ options: { duration: 0 }
613
+ },
614
+ enter: {
615
+ value: {
616
+ opacity: 1,
617
+ backgroundColor: b
618
+ },
619
+ options: { duration: .7 }
620
+ },
621
+ exit: {
622
+ value: {
623
+ opacity: 0,
624
+ backgroundColor: b
625
+ },
626
+ options: { duration: .6 }
627
+ },
628
+ options: {
629
+ onSwipeStart: (e, { animate: t, prevDecorator: n }) => t(n, { opacity: +!!e }, { duration: .3 }),
630
+ onSwipe: (e, t, { animate: n, prevDecorator: r }) => n(r, { opacity: Math.max(0, 1 - t / 100) }, { duration: 0 }),
631
+ onSwipeEnd: (e, { animate: t, prevDecorator: n }) => t(n, { opacity: +!e }, { duration: .3 })
632
+ }
633
+ }), te = new Map([["overlay", x]]), S = {
634
+ "IDLE-true": "self",
635
+ "IDLE-false": "self",
636
+ "PUSHING-true": "initial",
637
+ "PUSHING-false": "IDLE-true",
638
+ "REPLACING-true": "initial",
639
+ "REPLACING-false": "IDLE-true",
640
+ "POPPING-true": "IDLE-true",
641
+ "POPPING-false": "PUSHING-false",
642
+ "COMPLETED-true": "self",
643
+ "COMPLETED-false": "self"
644
+ }, C = Object.keys(S), w = C, ne = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_"), T = (e) => typeof e == "object" && !!e && !Array.isArray(e), E = 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(".")), D = (e, t) => t.startsWith("--") || E.has(t) ? `${e}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${e}deg` : `${e}px`, O = (e, t) => typeof t == "number" ? D(t, e) : typeof t == "string" ? t : "", k = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), A = new Set([
645
+ "x",
646
+ "y",
647
+ "z",
648
+ "scale",
649
+ "scaleX",
650
+ "scaleY",
651
+ "rotate",
652
+ "rotateX",
653
+ "rotateY",
654
+ "rotateZ"
655
+ ]), j = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, M = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, N = /^1(\.0+)?$/, P = (e, t) => e === "scale" || e === "scaleX" || e === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? N.test(t.trim()) : !1 : e === "rotate" || e === "rotateX" || e === "rotateY" || e === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? M.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? j.test(t.trim()) : !1, F = (e, t) => {
656
+ switch (e) {
657
+ case "x": return `translateX(${t})`;
658
+ case "y": return `translateY(${t})`;
659
+ case "z": return `translateZ(${t})`;
660
+ case "scale": return `scale(${t})`;
661
+ case "scaleX": return `scaleX(${t})`;
662
+ case "scaleY": return `scaleY(${t})`;
663
+ case "rotate":
664
+ case "rotateZ": return `rotate(${t})`;
665
+ case "rotateX": return `rotateX(${t})`;
666
+ case "rotateY": return `rotateY(${t})`;
667
+ default: return "";
668
+ }
669
+ }, I = (e) => {
670
+ let t = /* @__PURE__ */ new Set(), n = !1, r = (e) => {
671
+ if (T(e)) for (let r of Object.keys(e)) {
672
+ let i = e[r];
673
+ O(r, i) !== "" && (A.has(r) ? n = !0 : t.add(k(r)));
674
+ }
675
+ };
676
+ r(e.initial);
677
+ for (let t of Object.values(e.variants)) r(t.value);
678
+ return n && t.add("transform"), Array.from(t);
679
+ }, L = (e) => {
680
+ if (!T(e)) return [];
681
+ let t = [], n = !0, r = [];
682
+ for (let i of Object.keys(e)) {
683
+ let a = e[i], o = O(i, a);
684
+ o !== "" && (A.has(i) ? (t.push(F(i, o)), P(i, a) || (n = !1)) : r.push({
685
+ property: k(i),
686
+ value: o
687
+ }));
688
+ }
689
+ return t.length > 0 && r.push({
690
+ property: "transform",
691
+ value: n ? "none" : t.join(" ")
692
+ }), r;
693
+ }, R = (e) => e.map((e) => ` ${e.property}: ${e.value};`).join("\n"), z = (e) => Array.isArray(e) ? e.length === 4 && e.every((e) => typeof e == "number") ? `cubic-bezier(${e.join(", ")})` : "linear" : typeof e == "string" ? {
694
+ linear: "linear",
695
+ easeIn: "ease-in",
696
+ easeOut: "ease-out",
697
+ easeInOut: "ease-in-out",
698
+ circIn: "cubic-bezier(0, 0.55, 0.45, 1)",
699
+ circOut: "cubic-bezier(0.55, 0, 1, 0.45)",
700
+ backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
701
+ backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
702
+ anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
703
+ }[e] ?? "ease" : "ease", B = (e) => {
704
+ if (!e) return 0;
705
+ let t = e.duration;
706
+ return typeof t == "number" && t >= 0 ? t : 0;
707
+ }, V = (e) => e && typeof e.delay == "number" && e.delay > 0 ? e.delay : 0, H = (e, t) => {
708
+ let [n, r] = t.split("-");
709
+ return `[data-flemo-screen][data-flemo-transition="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
710
+ }, U = (e, t) => {
711
+ let [n, r] = t.split("-");
712
+ return `[data-flemo-decorator][data-flemo-decorator-name="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
713
+ }, W = (e, t) => {
714
+ let [n, r] = t.split("-");
715
+ return `[data-flemo-bar][data-flemo-bar-transition="${e}"][data-flemo-bar-status="${n}"][data-flemo-bar-active="${r}"][data-flemo-bar-riding="true"]`;
716
+ }, G = (e, t, n) => `flemo-${e}-${ne(t)}-${n}`, K = (e, t, n, r, i, a) => {
717
+ let o = L(r), s = L(i.value), c = B(i.options), l = V(i.options), u = z(i.options?.ease), d = a(t, n), f = e === "screen" ? `${d},\n${W(t, n)}` : d;
718
+ if (s.length === 0 && o.length === 0) return "";
719
+ if (c <= 0 && l <= 0) return s.length === 0 ? "" : `${f} {\n${R(s)}\n animation: none;\n}`;
720
+ let p = G(e, t, n), m = [
721
+ `@keyframes ${p} {`,
722
+ " from {",
723
+ R(o).replace(/^/gm, " "),
724
+ " }",
725
+ " to {",
726
+ R(s).replace(/^/gm, " "),
727
+ " }",
728
+ "}"
729
+ ].join("\n"), h = [
730
+ `${p}`,
731
+ `${c}s`,
732
+ u,
733
+ l > 0 ? `${l}s` : null,
734
+ "both"
735
+ ].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];
736
+ return `${m}\n${`${f} {\n animation: ${h};\n${_}${v === "PUSHING" || v === "REPLACING" ? " contain: layout;\n pointer-events: none;\n" : ""}}`}`;
737
+ }, q = (e, t, n, r) => {
738
+ let i = L(r.value);
739
+ return i.length === 0 ? "" : `${e(t, n)} {\n${R(i)}\n}`;
740
+ }, J = (e, t) => {
741
+ let n = [];
742
+ for (let t of e) {
743
+ let e = t.name;
744
+ for (let r of C) {
745
+ let i = t.variants[r], a = S[r];
746
+ if (a === "self") {
747
+ n.push(q(H, e, r, i));
748
+ continue;
749
+ }
750
+ let o = a === "initial" ? t.initial : t.variants[a].value;
751
+ n.push(K("screen", e, r, o, i, H));
752
+ }
753
+ }
754
+ for (let e of t) {
755
+ let t = e.name;
756
+ for (let r of w) {
757
+ let i = e.variants[r], a = S[r];
758
+ if (a === "self") {
759
+ n.push(q(U, t, r, i));
760
+ continue;
761
+ }
762
+ let o = a === "initial" ? e.initial : e.variants[a].value;
763
+ n.push(K("decorator", t, r, o, i, U));
764
+ }
765
+ }
766
+ return n.filter((e) => e.length > 0).join("\n\n");
767
+ }, Y = (e, t) => {
768
+ let n = S[t];
769
+ if (n === "self") return !1;
770
+ let r = e.variants[t], i = B(r.options), a = V(r.options);
771
+ if (i <= 0 && a <= 0) return !1;
772
+ let o = L(n === "initial" ? e.initial : e.variants[n].value), s = L(r.value);
773
+ return o.length > 0 || s.length > 0;
984
774
  };
985
- function At() {
986
- return typeof document > "u";
775
+ //#endregion
776
+ //#region src/utils/isServer.ts
777
+ function X() {
778
+ return typeof document > "u";
987
779
  }
988
- function lt(n, t) {
989
- return Array.isArray(n) ? n.find((e) => v(e).regexp.test(t)) ?? "" : v(n).regexp.test(t) ? n : "";
780
+ //#endregion
781
+ //#region src/utils/getMatchedPathPattern.ts
782
+ function Z(e, t) {
783
+ return Array.isArray(e) ? e.find((e) => n(e).regexp.test(t)) ?? "" : n(e).regexp.test(t) ? e : "";
990
784
  }
991
- function Mt(n, t, e) {
992
- const s = lt(n, t), a = B(s)(t), r = new URLSearchParams(e), o = Object.fromEntries(r.entries());
993
- return a ? { ...a.params, ...o } : {};
785
+ //#endregion
786
+ //#region src/utils/getParams.ts
787
+ function re(e, n, r) {
788
+ let i = t(Z(e, n))(n), a = new URLSearchParams(r), o = Object.fromEntries(a.entries());
789
+ return i ? {
790
+ ...i.params,
791
+ ...o
792
+ } : {};
994
793
  }
995
- function xt(n, t) {
996
- const {
997
- direction: e = "x",
998
- markerSelector: s = "[data-swipe-at-edge]",
999
- depthLimit: a = 24,
1000
- verifyByScroll: r = !1
1001
- } = t ?? {}, o = ft(n);
1002
- if (!o) return { element: null, hasMarker: !1 };
1003
- const c = o.closest?.(s);
1004
- if (c instanceof HTMLElement && D(c, e) && (!r || G(c, e)))
1005
- return { element: c, hasMarker: !0 };
1006
- let l = o, u = 0;
1007
- for (; l && u < a; ) {
1008
- if (D(l, e) && (!r || G(l, e)))
1009
- return { element: l, hasMarker: !1 };
1010
- l = l.parentElement, u++;
1011
- }
1012
- return { element: null, hasMarker: !1 };
794
+ //#endregion
795
+ //#region src/utils/findScrollable.ts
796
+ function ie(e, t) {
797
+ let { direction: n = "x", markerSelector: r = "[data-swipe-at-edge]", depthLimit: i = 24, verifyByScroll: a = !1 } = t ?? {}, o = ae(e);
798
+ if (!o) return {
799
+ element: null,
800
+ hasMarker: !1
801
+ };
802
+ let s = o.closest?.(r);
803
+ if (s instanceof HTMLElement && Q(s, n) && (!a || $(s, n))) return {
804
+ element: s,
805
+ hasMarker: !0
806
+ };
807
+ let c = o, l = 0;
808
+ for (; c && l < i;) {
809
+ if (Q(c, n) && (!a || $(c, n))) return {
810
+ element: c,
811
+ hasMarker: !1
812
+ };
813
+ c = c.parentElement, l++;
814
+ }
815
+ return {
816
+ element: null,
817
+ hasMarker: !1
818
+ };
1013
819
  }
1014
- function ft(n) {
1015
- if (!n) return null;
1016
- const t = n, e = typeof t.composedPath == "function" ? t.composedPath() : void 0;
1017
- if (e && e.length) {
1018
- for (const s of e)
1019
- if (s instanceof HTMLElement) return s;
1020
- }
1021
- return n instanceof HTMLElement ? n : null;
820
+ function ae(e) {
821
+ if (!e) return null;
822
+ let t = e, n = typeof t.composedPath == "function" ? t.composedPath() : void 0;
823
+ if (n && n.length) {
824
+ for (let e of n) if (e instanceof HTMLElement) return e;
825
+ }
826
+ return e instanceof HTMLElement ? e : null;
1022
827
  }
1023
- function D(n, t) {
1024
- return t === "y" ? n.scrollHeight - n.clientHeight > 1 : n.scrollWidth - n.clientWidth > 1;
828
+ function Q(e, t) {
829
+ return t === "y" ? e.scrollHeight - e.clientHeight > 1 : e.scrollWidth - e.clientWidth > 1;
1025
830
  }
1026
- function G(n, t) {
1027
- if (!D(n, t) || typeof window > "u") return !1;
1028
- const e = window.getComputedStyle(n), s = t === "y" ? e.overflowY : e.overflowX;
1029
- return s === "auto" || s === "scroll" || s === "overlay";
831
+ function $(e, t) {
832
+ if (!Q(e, t) || typeof window > "u") return !1;
833
+ let n = window.getComputedStyle(e), r = t === "y" ? n.overflowY : n.overflowX;
834
+ return r === "auto" || r === "scroll" || r === "overlay";
1030
835
  }
1031
- export {
1032
- yt as TaskManger,
1033
- ut as animationName,
1034
- G as canProgrammaticallyScroll,
1035
- wt as collectAnimatedProperties,
1036
- St as compileTransitionStyles,
1037
- Et as consumeSelfInducedPop,
1038
- K as createDecorator,
1039
- Lt as createRawDecorator,
1040
- kt as createRawTransition,
1041
- T as createTransition,
1042
- F as cupertino,
1043
- Dt as decoratorMap,
1044
- it as easingToCss,
1045
- xt as findScrollable,
1046
- lt as getMatchedPathPattern,
1047
- Mt as getParams,
1048
- At as isServer,
1049
- V as layout,
1050
- It as markSelfInducedPop,
1051
- Z as material,
1052
- j as none,
1053
- D as overflowsAxis,
1054
- q as overlay,
1055
- g as targetToDecls,
1056
- Tt as transitionMap,
1057
- Pt as useHistoryStore,
1058
- gt as useNavigateStore,
1059
- Nt as useTransitionStore,
1060
- vt as variantHasAnimation
1061
- };
836
+ //#endregion
837
+ export { r as TaskManger, G as animationName, $ as canProgrammaticallyScroll, I as collectAnimatedProperties, J as compileTransitionStyles, c as consumeSelfInducedPop, y as createDecorator, i as createHistoryStore, a as createNavigateStore, ee as createRawDecorator, u as createRawTransition, l as createTransition, v as createTransitionStore, f as cupertino, te as decoratorMap, z as easingToCss, ie as findScrollable, Z as getMatchedPathPattern, re as getParams, X as isServer, m as layout, s as markSelfInducedPop, h as material, g as none, Q as overflowsAxis, x as overlay, L as targetToDecls, _ as transitionMap, Y as variantHasAnimation };