react-modal-navigation 1.1.10 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,140 +1,155 @@
1
- import { jsx as s, jsxs as ce } from "react/jsx-runtime";
2
- import be, { createContext as ie, useRef as l, useState as pe, useEffect as Q, useCallback as w, useMemo as K, useSyncExternalStore as fe, useLayoutEffect as He, Suspense as bn, useReducer as qn, useInsertionEffect as zn, useContext as oe } from "react";
3
- import { createPortal as On } from "react-dom";
4
- const yn = ie(null), vn = ie(null), je = ie(null), Me = ie(null), tn = ie(null), rn = ie(null), _e = ie(null), We = ie(null), Ue = ie(null), xn = ie(null), wn = ie(null), on = ie(null);
5
- function kn(e) {
1
+ import { jsx as i, jsxs as Ce } from "react/jsx-runtime";
2
+ import fe, { createContext as se, useState as xe, useEffect as H, useRef as k, useMemo as F, useSyncExternalStore as Ee, useContext as V, memo as Ue, useCallback as K, useReducer as Qn, useLayoutEffect as Ie, Suspense as Ln, useInsertionEffect as Zn } from "react";
3
+ import { createPortal as Xn } from "react-dom";
4
+ function Oe(e) {
6
5
  let n = e;
7
- const r = /* @__PURE__ */ new Set();
6
+ const t = /* @__PURE__ */ new Set();
7
+ let r = !1;
8
8
  return {
9
9
  getSnapshot: () => n,
10
- subscribe: (t) => (r.add(t), () => r.delete(t)),
11
- publish(t) {
12
- if (n !== t) {
13
- n = t;
14
- for (const i of [...r]) i();
10
+ subscribe: (o) => (r || t.add(o), () => t.delete(o)),
11
+ publish(o) {
12
+ if (!(r || Object.is(n, o))) {
13
+ n = o;
14
+ for (const g of [...t]) g();
15
15
  }
16
16
  },
17
- listenerCount: () => r.size
18
- };
19
- }
20
- function Te(e) {
21
- let n = e;
22
- const r = /* @__PURE__ */ new Set();
23
- return {
24
- getSnapshot: () => n,
25
- subscribe: (t) => (r.add(t), () => r.delete(t)),
26
- publish(t) {
27
- if (!Object.is(n, t)) {
28
- n = t;
29
- for (const i of [...r]) i();
30
- }
17
+ destroy() {
18
+ r = !0, t.clear();
31
19
  },
32
- listenerCount: () => r.size
20
+ listenerCount: () => t.size
33
21
  };
34
22
  }
35
- let Fn = 0;
36
- const nn = (e, n) => ({ key: `modal-route-${++Fn}`, name: e, params: n ?? {} }), Sn = (e, n) => [nn(e, n)];
37
- function Ke(e, n) {
23
+ const tn = se(null), An = se(null), Nn = se(null), Ve = se(null), De = se(null), bn = se(null), vn = se(null), rn = se(null), on = se(null), an = se(null), zn = se(null), Bn = se(null), sn = se(null), wn = se(null), xn = se(null), kn = se(null);
24
+ let Jn = 0;
25
+ const yn = (e, n) => ({ key: `modal-route-${++Jn}`, name: e, params: n ?? {} }), Fn = (e, n) => [yn(e, n)];
26
+ function Xe(e, n) {
38
27
  switch (n.type) {
28
+ case "COMMIT":
29
+ return n.stack;
39
30
  case "RESET":
40
- return Sn(n.name, n.params);
31
+ return Fn(n.name, n.params);
41
32
  case "NAVIGATE": {
42
- const r = e.findIndex((t) => t.name === n.name);
43
- return r < 0 ? [...e, nn(n.name, n.params)] : e.slice(0, r + 1).map((t, i) => i === r ? { ...t, params: n.params ?? {} } : t);
33
+ const t = e.findIndex((r) => r.name === n.name);
34
+ return t < 0 ? [...e, yn(n.name, n.params)] : e.slice(0, t + 1).map((r, o) => o === t ? { ...r, params: n.params ?? {} } : r);
44
35
  }
45
36
  case "SET_OPTIONS":
46
- return e.map((r, t) => t === e.length - 1 ? { ...r, options: { ...r.options ?? {}, ...n.options ?? {} } } : r);
37
+ return e.map((t, r) => r === e.length - 1 ? { ...t, options: { ...t.options ?? {}, ...n.options ?? {} } } : t);
47
38
  case "SET_PARAMS":
48
- return e.map((r, t) => t === e.length - 1 ? { ...r, params: { ...r.params ?? {}, ...n.params ?? {} } } : r);
39
+ return e.map((t, r) => r === e.length - 1 ? { ...t, params: { ...t.params ?? {}, ...n.params ?? {} } } : t);
49
40
  case "BACK":
50
41
  return e.length > 1 ? e.slice(0, -1) : e;
51
42
  case "REPLACE":
52
- return e.length ? [...e.slice(0, -1), nn(n.name, n.params)] : e;
43
+ return e.length ? [...e.slice(0, -1), yn(n.name, n.params)] : e;
53
44
  default:
54
45
  return e;
55
46
  }
56
47
  }
57
- function $n(e, n, r = 1 / 0) {
58
- const t = r === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(r) || 0)), i = e.slice(0, -1).filter((p) => n[p.name]?.keepAlive !== !1), g = new Set((t === 0 ? [] : i.slice(-t)).map((p) => p.key));
59
- return e.filter((p, f) => f === e.length - 1 || g.has(p.key));
48
+ function et(e, n, t = 1 / 0) {
49
+ const r = t === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(t) || 0)), o = e.slice(0, -1).filter((p) => n[p.name]?.keepAlive !== !1), g = new Set((r === 0 ? [] : o.slice(-r)).map((p) => p.key));
50
+ return e.filter((p, h) => h === e.length - 1 || g.has(p.key));
51
+ }
52
+ function nt(e, n) {
53
+ const t = e.responsive;
54
+ if (!t) return e;
55
+ const { sm: r, md: o, lg: g, xl: p } = t;
56
+ return { ...e, ...n < 768 ? r : n < 1024 ? o : n < 1280 ? g : p, ...e.runtimeLayout };
60
57
  }
61
- const jn = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Fe = (e) => typeof e == "number" ? `${e}px` : e, pn = () => {
58
+ function tt(e, n, t, r) {
59
+ const o = Math.max(0, Math.min(t ?? 1 / 0, r));
60
+ return Math.min(o, Math.max(Math.min(n ?? 240, o), e));
61
+ }
62
+ const rt = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Te = (e) => typeof e == "number" ? `${e}px` : e, Rn = () => {
62
63
  if (typeof document > "u") return "light";
63
64
  const e = document.documentElement, n = document.body;
64
65
  return e.classList.contains("dark") || n.classList.contains("dark") || e.dataset.theme === "dark" || n.dataset.theme === "dark" ? "dark" : e.classList.contains("light") || n.classList.contains("light") || e.dataset.theme === "light" || n.dataset.theme === "light" ? "light" : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
65
66
  };
66
- let $e = 0;
67
- const xe = [];
68
- let Xe = null;
69
- function In() {
70
- if ($e++, $e === 1) {
71
- const n = document.documentElement, r = document.body, t = { html: n.style.overflow, body: r.style.overflow, padding: r.style.paddingRight, width: r.style.getPropertyValue("--modal-scrollbar-width") }, i = Math.max(0, window.innerWidth - n.clientWidth), g = parseFloat(getComputedStyle(r).paddingRight) || 0;
72
- i && (r.style.paddingRight = `${g + i}px`), r.style.setProperty("--modal-scrollbar-width", `${i}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", Xe = () => {
73
- n.style.overflow = t.html, r.style.overflow = t.body, r.style.paddingRight = t.padding, t.width ? r.style.setProperty("--modal-scrollbar-width", t.width) : r.style.removeProperty("--modal-scrollbar-width");
67
+ let Ge = 0;
68
+ const Ne = [];
69
+ let gn = null;
70
+ function ot() {
71
+ if (Ge++, Ge === 1) {
72
+ const n = document.documentElement, t = document.body, r = { html: n.style.overflow, body: t.style.overflow, padding: t.style.paddingRight, width: t.style.getPropertyValue("--modal-scrollbar-width") }, o = Math.max(0, window.innerWidth - n.clientWidth), g = parseFloat(getComputedStyle(t).paddingRight) || 0;
73
+ o && (t.style.paddingRight = `${g + o}px`), t.style.setProperty("--modal-scrollbar-width", `${o}px`), n.style.overflow = "hidden", t.style.overflow = "hidden", gn = () => {
74
+ n.style.overflow = r.html, t.style.overflow = r.body, t.style.paddingRight = r.padding, r.width ? t.style.setProperty("--modal-scrollbar-width", r.width) : t.style.removeProperty("--modal-scrollbar-width");
74
75
  };
75
76
  }
76
77
  let e = !1;
77
78
  return () => {
78
- e || (e = !0, $e = Math.max(0, $e - 1), $e || (Xe?.(), Xe = null));
79
+ e || (e = !0, Ge = Math.max(0, Ge - 1), Ge || (gn?.(), gn = null));
79
80
  };
80
81
  }
81
- const Dn = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', Kn = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
82
- function En({ dialogRef: e, options: n, requestClose: r, children: t, exiting: i = !1 }) {
83
- const g = l(null), p = l(null), f = l(r);
84
- f.current = r;
85
- const u = l(n.closeOnEsc);
86
- u.current = n.closeOnEsc;
87
- const [y, M] = pe(pn), k = n.theme === "light" || n.theme === "dark" ? n.theme : y;
88
- Q(() => {
82
+ const at = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', st = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
83
+ function it({ dialogRef: e, options: n, requestClose: t, children: r, exiting: o = !1 }) {
84
+ const [g, p] = xe(() => typeof window > "u" ? 1024 : window.innerWidth), h = !!n.responsive;
85
+ H(() => {
86
+ if (!h) return;
87
+ const C = () => p(window.innerWidth < 768 ? 0 : window.innerWidth < 1024 ? 768 : window.innerWidth < 1280 ? 1024 : 1280);
88
+ return window.addEventListener("resize", C), C(), () => window.removeEventListener("resize", C);
89
+ }, [h]), n = nt(n, g);
90
+ const [l, d] = xe(null);
91
+ H(() => d(null), [n.width, n.placement]);
92
+ const u = k(null), x = k(0);
93
+ H(() => () => {
94
+ x.current && cancelAnimationFrame(x.current);
95
+ }, []);
96
+ const w = k(null), b = k(null), s = k(t);
97
+ s.current = t;
98
+ const m = k(n.closeOnEsc);
99
+ m.current = n.closeOnEsc;
100
+ const [M, I] = xe(Rn), j = n.theme === "light" || n.theme === "dark" ? n.theme : M;
101
+ H(() => {
89
102
  if (n.theme === "light" || n.theme === "dark") return;
90
- const O = () => M(pn()), F = new MutationObserver(O);
91
- for (const J of [document.documentElement, document.body]) F.observe(J, { attributes: !0, attributeFilter: ["class", "data-theme"] });
92
- const U = window.matchMedia?.("(prefers-color-scheme: dark)");
93
- return U?.addEventListener?.("change", O), O(), () => {
94
- F.disconnect(), U?.removeEventListener?.("change", O);
103
+ const C = () => I(Rn()), R = new MutationObserver(C);
104
+ for (const ge of [document.documentElement, document.body]) R.observe(ge, { attributes: !0, attributeFilter: ["class", "data-theme"] });
105
+ const de = window.matchMedia?.("(prefers-color-scheme: dark)");
106
+ return de?.addEventListener?.("change", C), C(), () => {
107
+ R.disconnect(), de?.removeEventListener?.("change", C);
95
108
  };
96
- }, [n.theme]), Q(() => {
97
- p.current = document.activeElement;
98
- const O = In(), F = g.current;
99
- xe.push(F), e.current?.focus({ preventScroll: !0 });
100
- const U = (E) => {
101
- const _ = e.current;
102
- if (!_ || xe.at(-1) !== F) return;
103
- if (E.key === "Escape" && u.current !== !1) {
104
- E.preventDefault(), f.current("escape");
109
+ }, [n.theme]), H(() => {
110
+ b.current = document.activeElement;
111
+ const C = ot(), R = w.current;
112
+ Ne.push(R), e.current?.focus({ preventScroll: !0 });
113
+ const de = (te) => {
114
+ const A = e.current;
115
+ if (!A || Ne.at(-1) !== R) return;
116
+ if (te.key === "Escape" && m.current !== !1) {
117
+ te.preventDefault(), s.current("escape");
105
118
  return;
106
119
  }
107
- if (E.key !== "Tab") return;
108
- const q = [..._.querySelectorAll(Dn)].filter(Kn);
109
- if (!q.length) {
110
- E.preventDefault(), _.focus();
120
+ if (te.key !== "Tab") return;
121
+ const y = [...A.querySelectorAll(at)].filter(st);
122
+ if (!y.length) {
123
+ te.preventDefault(), A.focus();
111
124
  return;
112
125
  }
113
- const re = q[0], X = q.at(-1);
114
- _.contains(document.activeElement) ? E.shiftKey && (document.activeElement === re || document.activeElement === _) ? (E.preventDefault(), X.focus()) : !E.shiftKey && (document.activeElement === X || document.activeElement === _) && (E.preventDefault(), re.focus()) : (E.preventDefault(), (E.shiftKey ? X : re).focus());
115
- }, J = (E) => {
116
- xe.at(-1) === F && e.current && !e.current.contains(E.target) && e.current.focus({ preventScroll: !0 });
126
+ const U = y[0], ve = y.at(-1);
127
+ A.contains(document.activeElement) ? te.shiftKey && (document.activeElement === U || document.activeElement === A) ? (te.preventDefault(), ve.focus()) : !te.shiftKey && (document.activeElement === ve || document.activeElement === A) && (te.preventDefault(), U.focus()) : (te.preventDefault(), (te.shiftKey ? ve : U).focus());
128
+ }, ge = (te) => {
129
+ Ne.at(-1) === R && e.current && !e.current.contains(te.target) && e.current.focus({ preventScroll: !0 });
117
130
  };
118
- return document.addEventListener("keydown", U), document.addEventListener("focusin", J), () => {
119
- document.removeEventListener("keydown", U), document.removeEventListener("focusin", J);
120
- const E = xe.at(-1) === F, _ = xe.indexOf(F);
121
- if (_ !== -1 && xe.splice(_, 1), O(), E) {
122
- const q = p.current;
123
- q?.isConnected && !q.closest("[inert], [hidden]") ? q.focus?.({ preventScroll: !0 }) : xe.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
131
+ return document.addEventListener("keydown", de), document.addEventListener("focusin", ge), () => {
132
+ document.removeEventListener("keydown", de), document.removeEventListener("focusin", ge);
133
+ const te = Ne.at(-1) === R, A = Ne.indexOf(R);
134
+ if (A !== -1 && Ne.splice(A, 1), C(), te) {
135
+ const y = b.current;
136
+ y?.isConnected && !y.closest("[inert], [hidden]") ? y.focus?.({ preventScroll: !0 }) : Ne.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
124
137
  }
125
138
  };
126
139
  }, [e]);
127
- const d = n.backgroundColor ?? n.backgroudColor, m = typeof d == "string" ? d : d?.[k], a = typeof m == "string" && /^(#|(?:rgb|rgba|hsl|hsla|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark|var)\(|transparent$|currentColor$|[a-z]+$)/i.test(m.trim()) ? m.trim() : null, P = typeof m == "string" && !a ? m.trim() : "", N = !!(a || P), D = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", L = Fe(n.width ?? jn[n.size] ?? 460), G = Fe(n.height), x = Fe(n.maxHeight), B = Fe(n.maxWidth), $ = Number(n.viewportGap ?? 5), H = Number.isFinite($) ? Math.max(0, $) : 5, T = n.top == null ? null : Fe(n.top), v = D === "top" && T !== null ? T : null, j = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
128
- return On(/* @__PURE__ */ s(
140
+ const q = n.backgroundColor ?? n.backgroudColor, O = typeof q == "string" ? q : q?.[j], P = typeof O == "string" && /^(#|(?:rgb|rgba|hsl|hsla|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark|var)\(|transparent$|currentColor$|[a-z]+$)/i.test(O.trim()) ? O.trim() : null, L = typeof O == "string" && !P ? O.trim() : "", Y = !!(P || L), T = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", $ = Te(l ?? n.width ?? rt[n.size] ?? 460), Q = Te(n.height), X = Te(n.maxHeight), ne = Te(n.maxWidth), oe = Number(n.viewportGap ?? 5), be = Number.isFinite(oe) ? Math.max(0, oe) : 5, z = n.top == null ? null : Te(n.top), _ = T !== "bottom" && z !== null ? z : null, le = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px", W = n.resizable && !n.fullscreen && ["left", "right"].includes(T), ue = (C) => tt(C, n.minWidth, typeof n.maxWidth == "number" ? n.maxWidth : void 0, w.current?.clientWidth - be * 2 || window.innerWidth), ie = (C) => {
141
+ !u.current || u.current.id !== C.pointerId || (cancelAnimationFrame(x.current), d(u.current.width), e.current?.style.removeProperty("--pmn-drag-width"), u.current = null);
142
+ };
143
+ return Xn(/* @__PURE__ */ i(
129
144
  "div",
130
145
  {
131
- ref: g,
132
- className: `pmn-overlay ${i ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${D} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
133
- style: { padding: H, ...v !== null ? { paddingTop: v, "--pmn-top-offset": v } : {}, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
134
- onMouseDown: (O) => {
135
- O.target === O.currentTarget && n.closeOnOverlay === !0 && f.current("overlay");
146
+ ref: w,
147
+ className: `pmn-overlay ${o ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${T} ${n.fullscreen ? "pmn-fullscreen" : ""} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
148
+ style: { padding: be, ...n.bottom != null ? { paddingBottom: Te(n.bottom) } : {}, ...n.left != null ? { paddingLeft: Te(n.left) } : {}, ...n.right != null ? { paddingRight: Te(n.right) } : {}, ..._ !== null ? { paddingTop: _, "--pmn-top-offset": _ } : {}, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
149
+ onMouseDown: (C) => {
150
+ C.target === C.currentTarget && n.closeOnOverlay === !0 && s.current("overlay");
136
151
  },
137
- children: /* @__PURE__ */ ce(
152
+ children: /* @__PURE__ */ Ce(
138
153
  "section",
139
154
  {
140
155
  ref: e,
@@ -142,899 +157,1170 @@ function En({ dialogRef: e, options: n, requestClose: r, children: t, exiting: i
142
157
  role: "dialog",
143
158
  "aria-modal": "true",
144
159
  "aria-label": n.ariaLabel ?? "Dialog",
145
- "data-modal-theme": k,
146
- className: `pmn-dialog ${k === "dark" ? "dark" : ""} ${N ? "pmn-has-custom-background" : ""} ${n.className ?? ""}`,
147
- style: { "--pmn-width": L, "--pmn-gap": `${H}px`, ...v !== null ? { "--pmn-top-offset": v } : {}, ...G !== void 0 ? { "--pmn-height": G } : {}, ...x !== void 0 ? { "--pmn-max-height": x } : {}, ...B !== void 0 ? { "--pmn-max-width": B } : {}, borderRadius: j },
160
+ "data-modal-theme": j,
161
+ className: `pmn-dialog ${j === "dark" ? "dark" : ""} ${Y ? "pmn-has-custom-background" : ""} ${n.className ?? ""}`,
162
+ style: { "--pmn-width": $, "--pmn-gap": `${be}px`, ..._ !== null ? { "--pmn-top-offset": _ } : {}, ...Q !== void 0 ? { "--pmn-height": Q } : {}, ...X !== void 0 ? { "--pmn-max-height": X } : {}, ...ne !== void 0 ? { "--pmn-max-width": ne } : {}, borderRadius: le },
148
163
  children: [
149
- N && /* @__PURE__ */ s("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${P}`, style: a ? { backgroundColor: a } : void 0 }),
150
- t
164
+ Y && /* @__PURE__ */ i("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${L}`, style: P ? { backgroundColor: P } : void 0 }),
165
+ r,
166
+ W && /* @__PURE__ */ i(
167
+ "div",
168
+ {
169
+ role: "separator",
170
+ "aria-label": "调整弹窗宽度",
171
+ "aria-orientation": "vertical",
172
+ tabIndex: 0,
173
+ className: `pmn-resize-handle pmn-resize-${T}`,
174
+ onKeyDown: (C) => {
175
+ ["ArrowLeft", "ArrowRight"].includes(C.key) && (C.preventDefault(), d(ue(e.current.getBoundingClientRect().width + (C.key === "ArrowRight" ? 16 : -16) * (T === "left" ? 1 : -1))));
176
+ },
177
+ onPointerDown: (C) => {
178
+ if (C.button !== 0) return;
179
+ C.preventDefault(), C.currentTarget.setPointerCapture(C.pointerId);
180
+ const R = e.current.getBoundingClientRect().width;
181
+ u.current = { id: C.pointerId, x: C.clientX, start: R, width: R };
182
+ },
183
+ onPointerMove: (C) => {
184
+ const R = u.current;
185
+ !R || R.id !== C.pointerId || (R.width = ue(R.start + (C.clientX - R.x) * (T === "left" ? 1 : -1)), cancelAnimationFrame(x.current), x.current = requestAnimationFrame(() => e.current?.style.setProperty("--pmn-drag-width", `${R.width}px`)));
186
+ },
187
+ onPointerUp: ie,
188
+ onPointerCancel: ie,
189
+ onLostPointerCapture: ie
190
+ }
191
+ )
151
192
  ]
152
193
  }
153
194
  )
154
195
  }
155
196
  ), document.body);
156
197
  }
157
- function fn({ back: e }) {
158
- return /* @__PURE__ */ s("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ s("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ s("path", { d: "M18 6 6 18M6 6l12 12" }) });
198
+ const ct = (e) => e;
199
+ function ke(e, n = ct, t = Object.is) {
200
+ const r = k({ store: null, initialized: !1, selection: void 0 }), o = F(() => {
201
+ let p = !1, h, l;
202
+ return () => {
203
+ const d = e.getSnapshot();
204
+ if (p && Object.is(h, d)) return l;
205
+ const u = n(d);
206
+ if (p)
207
+ t(l, u) || (l = u);
208
+ else {
209
+ const x = r.current;
210
+ l = x.initialized && x.store === e && t(x.selection, u) ? x.selection : u;
211
+ }
212
+ return h = d, p = !0, l;
213
+ };
214
+ }, [e, n, t]), g = Ee(e.subscribe, o, o);
215
+ return H(() => {
216
+ r.current = { store: e, initialized: !0, selection: g };
217
+ }, [e, g]), g;
218
+ }
219
+ function ze(e, n) {
220
+ if (Object.is(e, n)) return !0;
221
+ if (!e || !n || typeof e != "object" || typeof n != "object") return !1;
222
+ const t = Object.keys(e);
223
+ return t.length === Object.keys(n).length && t.every((r) => Object.hasOwn(n, r) && Object.is(e[r], n[r]));
224
+ }
225
+ const Ke = (e) => (n) => Object.fromEntries(e.map((t) => [t, n[t]])), lt = Ke(["pageAnimationDuration", "pageAnimationDistance", "pageAnimation", "animation", "lockCloseWhileLoading", "maxCachedScreens", "bodyClassName", "lazyFallback", "onBlur", "onNavigate", "onRouteChange", "onFocus"]), ut = Ke(["bodyClassName", "lazyFallback"]), dt = Ke(["showHeader", "showTitle", "renderHeader", "renderHeaderRight", "showHeaderBorder", "headerClassName", "showBackButton", "showCloseButton"]), jn = Ke(["showFooter", "renderFooter", "done", "cancel", "cancle", "showFooterBorder", "footerClassName", "actions", "loadingText", "cancelText", "doneText", "doneDisabled"]), mt = Ke(["fullscreenable", "fullscreen"]), Sn = ["responsive", "width", "height", "maxWidth", "maxHeight", "minWidth", "size", "placement", "viewportGap", "top", "bottom", "left", "right", "borderRadius", "resizable", "fullscreen", "mobileFullscreen", "animation", "animationDuration", "closeOnEsc", "closeOnOverlay", "theme", "backgroundColor", "backgroudColor", "ariaLabel", "className"], pt = Ke(Sn);
226
+ function ft(e, n) {
227
+ const t = { ...e, ...n, ...e.runtimeLayout };
228
+ return { ...pt(t), runtimeLayout: Object.fromEntries(Sn.filter((r) => Object.hasOwn(e.runtimeLayout ?? {}, r)).map((r) => [r, e.runtimeLayout[r]])) };
159
229
  }
160
- function Rn({ options: e, screen: n, route: r, navigation: t, requestClose: i, translate: g, canGoBack: p }) {
230
+ function gt(e, n) {
231
+ return ze(e.runtimeLayout, n.runtimeLayout) && Sn.every((t) => Object.is(e[t], n[t]));
232
+ }
233
+ const qn = {}, ht = () => qn, yt = () => () => {
234
+ }, bt = fe.memo(function({ action: n, context: t }) {
235
+ const r = k(!1), [o, g] = xe(!1), p = k(!1);
236
+ return H(() => (p.current = !0, () => {
237
+ p.current = !1;
238
+ }), []), /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": n.tooltip ?? n.key, title: n.tooltip, disabled: o || n.disabled || n.loading, onClick: async () => {
239
+ if (!(r.current || !p.current || n.disabled || n.loading)) {
240
+ r.current = !0, g(!0);
241
+ try {
242
+ await n.onClick?.(t);
243
+ } catch (h) {
244
+ console.error("[react-modal-navigation] header action", h);
245
+ } finally {
246
+ r.current = !1, p.current && g(!1);
247
+ }
248
+ }
249
+ }, children: o ? "…" : n.icon ?? n.label });
250
+ });
251
+ function Pn({ back: e }) {
252
+ return /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ i("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ i("path", { d: "M18 6 6 18M6 6l12 12" }) });
253
+ }
254
+ function vt({ options: e, screen: n, route: t, navigation: r, requestClose: o, translate: g, canGoBack: p }) {
255
+ const h = V(tn), l = () => h?.getSnapshot()[t.key] ?? qn, d = Ee(h?.subscribe ?? yt, l, ht);
256
+ n = { ...n, ...d };
257
+ const u = g ?? ((M) => M), x = n.showTitle ?? e.showTitle ?? !0, w = typeof n.title == "function" ? n.title({ t: u, route: t, navigation: r }) : n.title ?? t.name, b = F(() => ({ route: t, navigation: r, close: o, canGoBack: p, title: w, t: u }), [t, r, o, p, w, u]);
161
258
  if (e.showHeader === !1) return null;
162
- const f = g ?? ((m) => m), u = n.showTitle ?? e.showTitle ?? !0, y = typeof n.title == "function" ? n.title({ t: f, route: r, navigation: t }) : n.title ?? r.name, M = { route: r, navigation: t, close: i, canGoBack: p, title: y, t: f }, k = n.renderHeader ?? e.renderHeader;
163
- if (k) return k(M);
164
- const d = n.renderHeaderRight ?? e.renderHeaderRight;
165
- return /* @__PURE__ */ ce("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
166
- (n.showBackButton ?? e.showBackButton) !== !1 && p && /* @__PURE__ */ s("button", { type: "button", className: "pmn-icon-button", "aria-label": f("modal.back"), onClick: () => t.goBack(), children: /* @__PURE__ */ s(fn, { back: !0 }) }),
167
- u ? /* @__PURE__ */ s("h2", { children: y }) : /* @__PURE__ */ s("div", { className: "pmn-header-spacer" }),
168
- d?.(M),
169
- e.showCloseButton !== !1 && /* @__PURE__ */ s("button", { type: "button", className: "pmn-icon-button", "aria-label": f("modal.close"), onClick: () => i("header"), children: /* @__PURE__ */ s(fn, {}) })
259
+ const s = n.renderHeader ?? e.renderHeader;
260
+ if (s) return s(b);
261
+ const m = n.renderHeaderRight ?? e.renderHeaderRight;
262
+ return /* @__PURE__ */ Ce("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
263
+ (n.showBackButton ?? e.showBackButton) !== !1 && p && /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": u("modal.back"), onClick: () => r.goBack(), children: /* @__PURE__ */ i(Pn, { back: !0 }) }),
264
+ x ? /* @__PURE__ */ i("h2", { children: w }) : /* @__PURE__ */ i("div", { className: "pmn-header-spacer" }),
265
+ m?.(b),
266
+ d.actions?.filter((M) => !M.hidden).map((M) => /* @__PURE__ */ i(bt, { action: M, context: b }, `${t.key}:${M.key}`)),
267
+ /* @__PURE__ */ i(wt, { hidden: n.showFullscreenButton === !1 }),
268
+ (n.showCloseButton ?? e.showCloseButton) !== !1 && /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": u("modal.close"), onClick: () => o("header"), children: /* @__PURE__ */ i(Pn, {}) })
170
269
  ] });
171
270
  }
172
- function Cn({ screen: e, options: n, override: r, route: t, navigation: i, requestClose: g, translate: p, onError: f, loadingApi: u }) {
173
- const [y, M] = pe(null), k = l(/* @__PURE__ */ new Set()), d = l(!0);
174
- Q(() => (d.current = !0, () => {
271
+ const wt = fe.memo(function({ hidden: n }) {
272
+ const t = V(wn), r = V(kn), o = ke(r.stores.layout, mt, ze);
273
+ return n || !o.fullscreenable ? null : /* @__PURE__ */ i("button", { type: "button", className: "pmn-icon-button", "aria-label": o.fullscreen ? "还原" : "全屏", onClick: t?.toggleFullscreen, children: /* @__PURE__ */ i("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ i("path", { d: o.fullscreen ? "M3 9h6V3 M21 9h-6V3 M3 15h6v6 M21 15h-6v6" : "M3 9V3h6 M15 3h6v6 M3 15v6h6 M15 21h6v-6" }) }) });
274
+ }), $n = Ue(function({ store: n, screenOptions: t, ...r }) {
275
+ const o = K((p) => ft(p, t), [t]), g = ke(n, o, gt);
276
+ return /* @__PURE__ */ i(it, { ...r, options: g });
277
+ }), In = Ue(function({ store: n, ...t }) {
278
+ const r = ke(n, dt, ze);
279
+ return /* @__PURE__ */ i(vt, { ...t, options: r });
280
+ }), xt = fe.memo(function({ action: n, context: t, loadingApi: r, onError: o, loadingText: g }) {
281
+ const p = k(!1), [h, l] = xe(!1), d = k(!1);
282
+ H(() => (d.current = !0, () => {
175
283
  d.current = !1;
176
284
  }), []);
177
- const m = p ?? ((v) => v), a = { ...n, ...e, ...r }, { showFooter: P, renderFooter: N, done: D, cancel: L, cancle: G } = a, x = L ?? G, B = { route: t, navigation: i, close: g, t: m };
178
- if (P === !1) return null;
179
- const $ = `pmn-footer ${a.showFooterBorder ? "pmn-border-top" : ""} ${a.footerClassName ?? ""}`;
180
- if (typeof N == "function") return /* @__PURE__ */ s("footer", { className: $, children: N({ ...B, pending: k.current.size > 0 }) });
181
- const H = Array.isArray(a.actions) ? a.actions : null;
182
- if (!H && typeof D != "function" && typeof x != "function") return null;
183
- const T = async (v, j, O) => {
184
- if (k.current.has(v) || typeof j != "function") return;
185
- k.current.add(v), M(v);
186
- const F = u?.begin(t.key, O ?? a.loadingText ?? m("modal.processing"));
285
+ const u = h || n.loading === !0, x = n.loadingText ?? g ?? t.t("modal.processing"), w = async () => {
286
+ if (!d.current || p.current || n.disabled || n.loading || typeof n.onClick != "function") return;
287
+ p.current = !0, l(!0);
288
+ const b = r?.begin(t.route.key, x);
187
289
  try {
188
- await j(B);
189
- } catch (U) {
190
- f?.(U, { phase: "footer", action: v, route: t });
290
+ await n.onClick(t);
291
+ } catch (s) {
292
+ o?.(s, { phase: "footer", action: n.key, route: t.route });
191
293
  } finally {
192
- u?.end(t.key, F), k.current.delete(v), d.current && M((U) => U === v ? null : U);
294
+ b != null && r?.end(t.route.key, b), p.current = !1, d.current && l(!1);
193
295
  }
194
296
  };
195
- return H ? /* @__PURE__ */ s("footer", { className: $, children: H.filter((v) => !v.hidden).map((v) => {
196
- const j = k.current.has(v.key) || v.loading === !0;
197
- return /* @__PURE__ */ s(
198
- "button",
199
- {
200
- type: "button",
201
- disabled: v.disabled === !0 || j,
202
- className: `pmn-button ${v.variant === "primary" || v.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${v.variant === "danger" ? "pmn-button-danger" : ""}`,
203
- onClick: () => T(v.key, v.onClick, v.loadingText),
204
- children: j ? v.loadingText ?? a.loadingText ?? m("modal.processing") : v.label
205
- },
206
- v.key
207
- );
208
- }) }) : /* @__PURE__ */ ce("footer", { className: $, children: [
209
- typeof x == "function" && /* @__PURE__ */ s("button", { type: "button", disabled: y !== null, onClick: () => T("cancel", x), className: "pmn-button pmn-button-secondary", children: a.cancelText ?? m("modal.cancel") }),
210
- typeof D == "function" && /* @__PURE__ */ s("button", { type: "button", disabled: y !== null || a.doneDisabled === !0, onClick: () => T("done", D), className: "pmn-button pmn-button-primary", children: y === "done" ? a.loadingText ?? m("modal.processing") : a.doneText ?? m("modal.done") })
297
+ return /* @__PURE__ */ i(
298
+ "button",
299
+ {
300
+ type: "button",
301
+ disabled: n.disabled === !0 || u,
302
+ className: `pmn-button ${n.variant === "primary" || n.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${n.variant === "danger" ? "pmn-button-danger" : ""}`,
303
+ onClick: w,
304
+ children: u ? x : n.label
305
+ }
306
+ );
307
+ });
308
+ function Dn({ screen: e, options: n, override: t, route: r, navigation: o, requestClose: g, translate: p, onError: h, loadingApi: l }) {
309
+ const [d, u] = xe(null), x = k(/* @__PURE__ */ new Set()), w = k(!0);
310
+ H(() => (w.current = !0, () => {
311
+ w.current = !1;
312
+ }), []);
313
+ const b = p ?? (($) => $), s = { ...n, ...e, ...t }, { showFooter: m, renderFooter: M, done: I, cancel: j, cancle: q } = s, O = j ?? q, P = F(() => ({ route: r, navigation: o, close: g, t: b }), [r, o, g, b]);
314
+ if (m === !1) return null;
315
+ const L = `pmn-footer ${s.showFooterBorder ? "pmn-border-top" : ""} ${s.footerClassName ?? ""}`;
316
+ if (typeof M == "function") return /* @__PURE__ */ i("footer", { className: L, children: M({ ...P, pending: x.current.size > 0 }) });
317
+ const Y = Array.isArray(s.actions) ? s.actions : null;
318
+ if (!Y && typeof I != "function" && typeof O != "function") return null;
319
+ const T = async ($, Q, X) => {
320
+ if (!w.current || x.current.size > 0 || x.current.has($) || typeof Q != "function") return;
321
+ x.current.add($), u($);
322
+ const ne = l?.begin(r.key, s.loadingText ?? b("modal.processing"));
323
+ try {
324
+ await Q(P);
325
+ } catch (oe) {
326
+ h?.(oe, { phase: "footer", action: $, route: r });
327
+ } finally {
328
+ ne != null && l?.end(r.key, ne), x.current.delete($), w.current && u((oe) => oe === $ ? null : oe);
329
+ }
330
+ };
331
+ return Y ? /* @__PURE__ */ i("footer", { className: L, children: Y.filter(($) => !$.hidden).map(
332
+ ($) => /* @__PURE__ */ i(xt, { action: $, context: P, loadingApi: l, onError: h, loadingText: s.loadingText }, `${r.key}:${$.key}`)
333
+ ) }) : /* @__PURE__ */ Ce("footer", { className: L, children: [
334
+ typeof O == "function" && /* @__PURE__ */ i("button", { type: "button", disabled: d !== null, onClick: () => T("cancel", O), className: "pmn-button pmn-button-secondary", children: s.cancelText ?? b("modal.cancel") }),
335
+ typeof I == "function" && /* @__PURE__ */ i("button", { type: "button", disabled: d !== null || s.doneDisabled === !0, onClick: () => T("done", I), className: "pmn-button pmn-button-primary", children: d === "done" ? s.loadingText ?? b("modal.processing") : s.doneText ?? b("modal.done") })
211
336
  ] });
212
337
  }
213
- function Tn({ loading: e, translate: n }) {
338
+ function Kn({ loading: e, translate: n }) {
214
339
  if (!e.visible) return null;
215
- const t = (n ?? ((g) => g))("modal.loading"), i = e.text ?? (t === "modal.loading" ? "加载中..." : t);
216
- return /* @__PURE__ */ s("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ ce("div", { className: "pmn-loading-content", children: [
217
- /* @__PURE__ */ s("span", { className: "pmn-spinner", "aria-hidden": "true" }),
218
- i && /* @__PURE__ */ s("span", { className: "pmn-loading-text", children: i })
340
+ const r = (n ?? ((g) => g))("modal.loading"), o = e.text ?? (r === "modal.loading" ? "加载中..." : r);
341
+ return /* @__PURE__ */ i("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ Ce("div", { className: "pmn-loading-content", children: [
342
+ /* @__PURE__ */ i("span", { className: "pmn-spinner", "aria-hidden": "true" }),
343
+ o && /* @__PURE__ */ i("span", { className: "pmn-loading-text", children: o })
219
344
  ] }) });
220
345
  }
221
- class Mn extends be.Component {
346
+ class Cn extends fe.Component {
222
347
  state = { error: null };
223
348
  static getDerivedStateFromError(n) {
224
349
  return { error: n };
225
350
  }
226
- componentDidCatch(n, r) {
227
- this.props.onError?.(n, { phase: "render", route: this.props.route, componentStack: r.componentStack });
351
+ componentDidCatch(n, t) {
352
+ this.props.onError?.(n, { phase: "render", route: this.props.route, componentStack: t.componentStack });
228
353
  }
229
354
  componentDidUpdate(n) {
230
355
  n.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
231
356
  }
232
357
  render() {
233
- return this.state.error ? /* @__PURE__ */ ce("div", { role: "alert", className: "pmn-error-screen", children: [
234
- /* @__PURE__ */ s("strong", { children: "页面加载失败" }),
235
- /* @__PURE__ */ s("p", { children: this.state.error.message }),
236
- /* @__PURE__ */ s("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => this.setState({ error: null }), children: "重试" })
358
+ return this.state.error ? /* @__PURE__ */ Ce("div", { role: "alert", className: "pmn-error-screen", children: [
359
+ /* @__PURE__ */ i("strong", { children: "页面加载失败" }),
360
+ /* @__PURE__ */ i("p", { children: this.state.error.message }),
361
+ /* @__PURE__ */ i("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => {
362
+ this.props.onRetry?.(), this.setState({ error: null });
363
+ }, children: "重试" })
237
364
  ] }) : this.props.children;
238
365
  }
239
366
  }
240
- const Gn = { success: "✓", error: "×", warning: "!", info: "i" };
241
- function Pn({ items: e, dismiss: n }) {
242
- return e.length ? /* @__PURE__ */ s("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((r) => /* @__PURE__ */ ce("div", { className: `pmn-toast pmn-toast-${r.type}`, role: r.type === "error" || r.type === "warning" ? "alert" : "status", children: [
243
- /* @__PURE__ */ s("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: Gn[r.type] }),
244
- /* @__PURE__ */ s("span", { className: "pmn-toast-message", children: r.message }),
245
- r.dismissible && /* @__PURE__ */ s("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => n(r.id), children: "×" })
246
- ] }, r.id)) }) : null;
367
+ const kt = { success: "✓", error: "×", warning: "!", info: "i" };
368
+ function Hn({ items: e, dismiss: n }) {
369
+ return e.length ? /* @__PURE__ */ i("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((t) => /* @__PURE__ */ Ce("div", { className: `pmn-toast pmn-toast-${t.type}`, role: t.type === "error" || t.type === "warning" ? "alert" : "status", children: [
370
+ /* @__PURE__ */ i("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: kt[t.type] }),
371
+ /* @__PURE__ */ i("span", { className: "pmn-toast-message", children: t.message }),
372
+ t.dismissible && /* @__PURE__ */ i("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => n(t.id), children: "×" })
373
+ ] }, t.id)) }) : null;
247
374
  }
248
- function Nn(e, n) {
249
- const r = l(0), t = l(/* @__PURE__ */ new Map()), i = w((f) => {
250
- clearTimeout(t.current.get(f)), t.current.delete(f), n.current && e.current.publish(e.current.getSnapshot().filter((u) => u.id !== f));
251
- }, []), g = w((f, u = {}) => {
252
- if (typeof f != "string" || !f.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
253
- const y = typeof u == "string" ? { type: u } : u ?? {}, M = ["success", "error", "warning", "info"].includes(y.type) ? y.type : "info", k = ++r.current, d = Number.isFinite(y.duration) ? Math.max(0, y.duration) : 3e3;
375
+ function Wn(e, n, t) {
376
+ const r = k(0), o = k(/* @__PURE__ */ new Map()), g = K((l) => {
377
+ clearTimeout(o.current.get(l)), o.current.delete(l), n.current && e.current.publish(e.current.getSnapshot().filter((d) => d.id !== l));
378
+ }, []), p = K((l, d = {}) => {
379
+ if (typeof l != "string" || !l.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
380
+ const u = typeof d == "string" ? { type: d } : d ?? {}, x = ["success", "error", "warning", "info"].includes(u.type) ? u.type : "info", w = ++r.current, b = Number.isFinite(u.duration) ? Math.max(0, u.duration) : 3e3;
254
381
  if (!n.current) return null;
255
- const m = e.current.getSnapshot(), a = m.slice(0, Math.max(0, m.length - 4));
256
- for (const P of a)
257
- clearTimeout(t.current.get(P.id)), t.current.delete(P.id);
258
- return e.current.publish([...m.slice(-4), { id: k, message: f, type: M, dismissible: y.dismissible !== !1 }]), d > 0 && t.current.set(k, setTimeout(() => i(k), d)), k;
259
- }, [i]), p = K(() => {
260
- const f = (u, y) => g(u, y);
261
- for (const u of ["success", "error", "warning", "info"]) f[u] = (y, M = {}) => g(y, { ...M, type: u });
262
- return f.promise = async (u, y, M = {}) => {
263
- const k = g(y.loading, { ...M, type: "info", duration: 0 });
382
+ const s = e.current.getSnapshot(), m = s.slice(0, Math.max(0, s.length - 4));
383
+ for (const M of m)
384
+ clearTimeout(o.current.get(M.id)), o.current.delete(M.id);
385
+ return e.current.publish([...s.slice(-4), { id: w, message: l, type: x, dismissible: u.dismissible !== !1 }]), b > 0 && o.current.set(w, setTimeout(() => g(w), b)), w;
386
+ }, [g]), h = F(() => {
387
+ const l = (d, u) => p(d, u);
388
+ for (const d of ["success", "error", "warning", "info"]) l[d] = (u, x = {}) => p(u, { ...x, type: d });
389
+ return l.promise = async (d, u, x = {}) => {
390
+ const w = p(u.loading, { ...x, type: "info", duration: 0 });
264
391
  try {
265
- const d = await (typeof u == "function" ? u() : u);
266
- k != null && i(k);
267
- const m = typeof y.success == "function" ? y.success(d) : y.success;
268
- return m && g(m, { ...M, type: "success" }), d;
269
- } catch (d) {
270
- k != null && i(k);
271
- const m = typeof y.error == "function" ? y.error(d) : y.error;
272
- throw m && g(m, { ...M, type: "error" }), d;
392
+ const b = await (typeof d == "function" ? d() : d);
393
+ w != null && g(w);
394
+ const s = typeof u.success == "function" ? u.success(b) : u.success;
395
+ return s && p(s, { ...x, type: "success" }), b;
396
+ } catch (b) {
397
+ w != null && g(w);
398
+ const s = typeof u.error == "function" ? u.error(b) : u.error;
399
+ throw s && p(s, { ...x, type: "error" }), b;
273
400
  }
274
- }, f.dismiss = i, f.clear = () => {
275
- for (const u of t.current.values()) clearTimeout(u);
276
- t.current.clear(), e.current.publish([]);
277
- }, f;
278
- }, [g, i]);
279
- return Q(() => () => {
280
- for (const f of t.current.values()) clearTimeout(f);
281
- t.current.clear();
282
- }, []), { toast: p, dismissToast: i };
401
+ }, l.dismiss = g, l.clear = () => {
402
+ for (const d of o.current.values()) clearTimeout(d);
403
+ o.current.clear(), e.current.publish([]);
404
+ }, l;
405
+ }, [p, g]);
406
+ return H(() => {
407
+ const l = () => {
408
+ for (const u of o.current.values()) clearTimeout(u);
409
+ o.current.clear();
410
+ }, d = t?.addCleanup(l);
411
+ return () => {
412
+ d?.(), l();
413
+ };
414
+ }, [t]), { toast: h, dismissToast: g };
283
415
  }
284
- function An(e, n, r) {
285
- const t = l(/* @__PURE__ */ new Map()), i = l(0), g = w(() => {
416
+ function Gn(e, n, t, r) {
417
+ const o = r.loadingTasks, g = r.loadingSequence, p = K(() => {
286
418
  if (!n.current) return;
287
- const d = [...t.current.values()], m = { visible: d.length > 0, text: d.at(-1)?.text ?? null, count: d.length }, a = e.current.getSnapshot();
288
- (a.visible !== m.visible || a.text !== m.text || a.count !== m.count) && e.current.publish(m);
289
- }, []), p = w((d, m) => {
290
- if (!n.current || d !== "global" && r.current !== d) return null;
291
- const a = ++i.current;
292
- return t.current.set(a, { owner: d, text: m }), g(), a;
293
- }, [g]), f = w((d, m) => {
294
- if (m != null)
295
- t.current.get(m)?.owner === d && t.current.delete(m);
419
+ const b = [...o.current.values()], s = { visible: b.length > 0, text: b.at(-1)?.text ?? null, count: b.length }, m = e.current.getSnapshot();
420
+ (m.visible !== s.visible || m.text !== s.text || m.count !== s.count) && e.current.publish(s);
421
+ }, []), h = K((b, s) => {
422
+ if (!n.current || b !== "global" && t.current !== b) return null;
423
+ const m = ++g.current;
424
+ return o.current.set(m, { owner: b, text: s }), p(), m;
425
+ }, [p]), l = K((b, s) => {
426
+ if (s != null)
427
+ o.current.get(s)?.owner === b && o.current.delete(s);
296
428
  else
297
- for (const [a, P] of t.current) P.owner === d && t.current.delete(a);
298
- g();
299
- }, [g]), u = w((d, m) => {
300
- d ? (f("global"), p("global", m)) : f("global");
301
- }, [p, f]), y = w((d, m, a) => {
302
- m ? (f(d), p(d, a)) : f(d);
303
- }, [p, f]);
304
- return { loadingApi: K(() => ({ setLoading: u, setScreenLoading: y, begin: p, end: f }), [u, y, p, f]), refreshLoading: g, loadingTasks: t, setLoading: u };
429
+ for (const [m, M] of o.current) M.owner === b && o.current.delete(m);
430
+ p();
431
+ }, [p]), d = K((b, s) => {
432
+ b ? (l("global"), h("global", s)) : l("global");
433
+ }, [h, l]), u = K((b, s, m) => {
434
+ s ? (l(b), h(b, m)) : l(b);
435
+ }, [h, l]);
436
+ return { loadingApi: F(() => ({ setLoading: d, setScreenLoading: u, begin: h, end: l }), [d, u, h, l]), refreshLoading: p, loadingTasks: o, setLoading: d };
305
437
  }
306
- const Hn = be.memo(function({ store: n, translate: r }) {
307
- const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
308
- return /* @__PURE__ */ s(Tn, { loading: t, translate: r });
309
- }), _n = be.memo(function({ store: n, dismiss: r }) {
310
- const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
311
- return /* @__PURE__ */ s(Pn, { items: t, dismiss: r });
312
- }), Wn = be.memo(function({ store: n, routeKey: r, ...t }) {
313
- const i = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
314
- return /* @__PURE__ */ s(Cn, { ...t, override: i[r] });
315
- }), Un = be.memo(function({ route: n, screen: r, navigation: t, focused: i, resultEvent: g, setFooter: p, loadingApi: f, loadingStore: u, bodyClassName: y, notifyError: M, registerDirtyGuard: k, pageMotion: d, lazyFallback: m }) {
316
- const a = r.component, P = l(null), N = l(!1);
317
- He(() => {
318
- const x = i && !N.current;
319
- if (N.current = i, !x || !d?.enabled || !P.current?.animate) return;
320
- const B = d.direction === "back" ? -100 : 100;
321
- P.current.style.zIndex = "2";
322
- const $ = P.current.animate([
323
- { opacity: 1, transform: `translate3d(${B}%,0,0)` },
438
+ const St = fe.memo(function({ store: n, translate: t }) {
439
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
440
+ return /* @__PURE__ */ i(Kn, { loading: r, translate: t });
441
+ }), Ct = fe.memo(function({ store: n, dismiss: t }) {
442
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
443
+ return /* @__PURE__ */ i(Hn, { items: r, dismiss: t });
444
+ }), Et = fe.memo(function({ store: n, layoutStore: t, routeKey: r, ...o }) {
445
+ const g = () => n.getSnapshot()[r], p = Ee(n.subscribe, g, g), h = ke(t, jn, ze);
446
+ return /* @__PURE__ */ i(Dn, { ...o, options: h, override: p });
447
+ }), Mt = fe.memo(function({ route: n, screen: t, navigation: r, focused: o, resultEvent: g, setFooter: p, loadingApi: h, loadingStore: l, bodyClassName: d, notifyError: u, registerDirtyGuard: x, pageMotion: w, lazyFallback: b }) {
448
+ const s = t.component, m = k(null), M = k(!1);
449
+ Ie(() => {
450
+ const O = o && !M.current;
451
+ if (M.current = o, !O || !w?.enabled || !m.current?.animate) return;
452
+ const P = w.direction === "back" ? -100 : 100;
453
+ m.current.style.zIndex = "2";
454
+ const L = m.current.animate([
455
+ { opacity: 1, transform: `translate3d(${P}%,0,0)` },
324
456
  { opacity: 1, transform: "translate3d(0,0,0)" }
325
- ], { duration: d.duration, easing: "cubic-bezier(.22,1,.36,1)" });
457
+ ], { duration: w.duration, easing: "cubic-bezier(.22,1,.36,1)" });
326
458
  return () => {
327
- $.cancel(), P.current && (P.current.style.zIndex = "");
459
+ L.cancel(), m.current && (m.current.style.zIndex = "");
328
460
  };
329
- }, [i, d?.enabled, d?.direction, d?.duration, d?.distance]);
330
- const D = K(() => ({ isFocused: i, resultEvent: g, routeKey: n.key, setFooter: p }), [i, g, n.key, p]), L = K(() => ({
331
- setLoading: (x, B) => f.setScreenLoading(n.key, x, B),
332
- showLoading: (x) => f.begin(n.key, x),
333
- hideLoading: (x) => f.end(n.key, x)
334
- }), [f, n.key]), G = K(() => ({ routeKey: n.key, registerDirtyGuard: k }), [n.key, k]);
335
- return /* @__PURE__ */ s(on.Provider, { value: n, children: /* @__PURE__ */ s(tn.Provider, { value: G, children: /* @__PURE__ */ s(je.Provider, { value: D, children: /* @__PURE__ */ s(Me.Provider, { value: L, children: /* @__PURE__ */ s(Ue.Provider, { value: u, children: /* @__PURE__ */ s("div", { ref: P, hidden: !i, inert: !i, "data-modal-route-key": n.key, tabIndex: -1, className: `pmn-body ${i && d?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${d.direction}` : ""} ${y ?? ""}`, style: i && d?.enabled ? { "--pmn-page-duration": `${d.duration}ms`, "--pmn-page-distance": `${d.distance}px` } : void 0, children: /* @__PURE__ */ s(Mn, { route: n, onError: M, children: /* @__PURE__ */ s(bn, { fallback: m ?? /* @__PURE__ */ s("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ s(a, { route: n, navigation: t }) }) }) }) }) }) }) }) });
461
+ }, [o, w?.enabled, w?.direction, w?.duration, w?.distance]);
462
+ const I = F(() => ({ isFocused: o, resultEvent: g, routeKey: n.key, setFooter: p }), [o, g, n.key, p]), j = F(() => ({
463
+ setLoading: (O, P) => h.setScreenLoading(n.key, O, P),
464
+ showLoading: (O) => h.begin(n.key, O),
465
+ hideLoading: (O) => h.end(n.key, O)
466
+ }), [h, n.key]), q = F(() => ({ routeKey: n.key, registerDirtyGuard: x }), [n.key, x]);
467
+ return /* @__PURE__ */ i(sn.Provider, { value: n, children: /* @__PURE__ */ i(bn.Provider, { value: q, children: /* @__PURE__ */ i(Ve.Provider, { value: I, children: /* @__PURE__ */ i(De.Provider, { value: j, children: /* @__PURE__ */ i(an.Provider, { value: l, children: /* @__PURE__ */ i("div", { ref: m, hidden: !o, inert: !o, "data-modal-route-key": n.key, tabIndex: -1, className: `pmn-body ${o && w?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${w.direction}` : ""} ${d ?? ""}`, style: o && w?.enabled ? { "--pmn-page-duration": `${w.duration}ms`, "--pmn-page-distance": `${w.distance}px` } : void 0, children: /* @__PURE__ */ i(Cn, { route: n, onError: u, children: /* @__PURE__ */ i(Ln, { fallback: b ?? /* @__PURE__ */ i("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ i(s, { route: n, navigation: r }) }) }) }) }) }) }) }) });
336
468
  });
337
- function Yn({ config: e, initialScreen: n, params: r, options: t, translate: i, onRequestClose: g, onOpened: p, registerLoading: f, notifyError: u, error: y, clearError: M, registerDirtyGuard: k, canNavigate: d, exiting: m = !1 }) {
338
- const [a, P] = qn(Ke, null, () => Sn(n ?? e.initialRoute, r)), N = l(null);
339
- N.current || (N.current = kn({ canGoBack: a.length > 1, stack: a, currentRoute: a.at(-1) }));
340
- const D = l(null), L = l(null), G = l(null);
341
- D.current || (D.current = Te({ visible: !1, text: null, count: 0 })), L.current || (L.current = Te({})), G.current || (G.current = Te([]));
342
- const x = l(!0), B = l(0), { toast: $, dismissToast: H } = Nn(G, x);
343
- Q(() => (x.current = !0, () => {
344
- x.current = !1, B.current++;
345
- }), []);
346
- const [T, v] = pe({}), j = l(/* @__PURE__ */ new Map()), O = l(null), F = l(null), U = l(null), J = l(null), E = l(null), _ = l(!1), q = l(!1), re = l(/* @__PURE__ */ new Map()), X = l(0), ge = w((o, S, z) => {
347
- for (const [I, ae] of re.current)
348
- o.includes(ae.key) && (re.current.delete(I), ae.resolve({ status: S, ...S === "returned" ? { value: z } : {} }));
349
- }, []), V = l(a);
350
- V.current = a;
351
- const le = l(d);
352
- le.current = d;
353
- const ye = l(!1), b = l(0), C = a.at(-1), W = C.key, ue = l({ key: W, depth: a.length }), he = ue.current, we = he.key !== W, Ie = a.length < he.depth ? "back" : "forward";
354
- we && (ue.current = { key: W, depth: a.length });
355
- const Pe = Math.min(1e3, Math.max(0, Number(t.pageAnimationDuration ?? 360) || 0)), de = { distance: Math.min(300, Math.max(0, Number(t.pageAnimationDistance ?? 96) || 0)), enabled: t.pageAnimation !== !1 && t.animation !== !1 && Pe > 0 && we, direction: Ie, duration: Pe }, Ne = l(W);
356
- Ne.current = W;
357
- const { loadingApi: ke, refreshLoading: Ae, loadingTasks: Le, setLoading: Se } = An(D, x, Ne), c = e.screens, h = D, A = l(f);
358
- A.current = f, Q(() => (A.current?.({ setLoading: Se }), () => A.current?.(null)), [Se]);
359
- const R = w((o, S) => {
360
- if (!x.current) return;
361
- const z = L.current.getSnapshot();
362
- if (S === null) {
363
- if (!(o in z)) return;
364
- const I = { ...z };
365
- delete I[o], L.current.publish(I);
469
+ function Rt({ runtime: e, config: n, initialScreen: t, params: r, translate: o, onRequestClose: g, onOpened: p, registerLoading: h, notifyError: l, error: d, clearError: u, registerDirtyGuard: x, canNavigate: w, exiting: b = !1 }) {
470
+ const s = ke(e.stores.layout, lt, ze), [m, M] = Qn(Xe, e.stores.navigation.getSnapshot().stack), { navigation: I, loading: j, footer: q, toast: O } = e.refs, P = e.alive, L = k(0), { toast: Y, dismissToast: T } = Wn(O, P, e);
471
+ H(() => () => {
472
+ L.current++;
473
+ }, []);
474
+ const [$, Q] = xe({}), X = k(/* @__PURE__ */ new Map()), ne = k(null), oe = k(null), be = k(null), z = k(null), _ = k(null), le = k(!1), W = k(!1), ue = e.pageRequests, ie = k(0), C = K((c, E, D) => {
475
+ for (const [G, me] of ue.current)
476
+ c.includes(me.key) && (ue.current.delete(G), me.resolve({ status: E, ...E === "returned" ? { value: D } : {} }));
477
+ }, []), R = k(m);
478
+ R.current = m;
479
+ const de = k(w);
480
+ de.current = w;
481
+ const ge = k(!1), te = k(0), A = m.at(-1), y = A.key, U = k({ key: y, depth: m.length }), ve = U.current, we = ve.key !== y, Be = m.length < ve.depth ? "back" : "forward";
482
+ we && (U.current = { key: y, depth: m.length });
483
+ const Ye = Math.min(1e3, Math.max(0, Number(s.pageAnimationDuration ?? 360) || 0)), cn = Math.min(300, Math.max(0, Number(s.pageAnimationDistance ?? 96) || 0)), Re = F(() => ({ distance: cn, enabled: s.pageAnimation !== !1 && s.animation !== !1 && Ye > 0 && we, direction: Be, duration: Ye }), [cn, s.pageAnimation, s.animation, Ye, we, Be]), ln = k(y);
484
+ ln.current = y;
485
+ const { loadingApi: Qe, refreshLoading: un, loadingTasks: Ze, setLoading: Fe } = Gn(j, P, ln, e), Se = n.screens, Me = j, je = k(h);
486
+ je.current = h, H(() => (je.current?.({ setLoading: Fe }), () => je.current?.(null)), [Fe]);
487
+ const En = K((c, E) => {
488
+ if (!P.current) return;
489
+ const D = q.current.getSnapshot();
490
+ if (E === null) {
491
+ if (!(c in D)) return;
492
+ const G = { ...D };
493
+ delete G[c], q.current.publish(G);
366
494
  return;
367
495
  }
368
- z[o] !== S && L.current.publish({ ...z, [o]: S });
369
- }, []), ee = w(() => {
496
+ D[c] !== E && q.current.publish({ ...D, [c]: E });
497
+ }, []), dn = K(() => {
370
498
  if (typeof document > "u") return;
371
- const o = document.activeElement;
372
- if (!(o instanceof HTMLElement) || !O.current?.contains(o)) return;
373
- const S = o.closest("[data-modal-route-key]");
374
- S && j.current.set(S.dataset.modalRouteKey, o), O.current.focus({ preventScroll: !0 });
375
- }, []), Z = w((o) => {
376
- if (!Object.prototype.hasOwnProperty.call(c, o)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${o}`);
377
- }, [c]), ne = w((o, S) => {
499
+ const c = document.activeElement;
500
+ if (!(c instanceof HTMLElement) || !ne.current?.contains(c)) return;
501
+ const E = c.closest("[data-modal-route-key]");
502
+ E && X.current.set(E.dataset.modalRouteKey, c), ne.current.focus({ preventScroll: !0 });
503
+ }, []), mn = K((c) => {
504
+ if (!Object.prototype.hasOwnProperty.call(Se, c)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${c}`);
505
+ }, [Se]), a = K((c, E) => {
378
506
  try {
379
- Promise.resolve(t[o]?.(S)).catch((z) => u(z, { phase: o }));
380
- } catch (z) {
381
- u(z, { phase: o });
507
+ Promise.resolve(s[c]?.(E)).catch((D) => l(D, { phase: c }));
508
+ } catch (D) {
509
+ l(D, { phase: c });
382
510
  }
383
- }, [t, u]), te = w(async (o, S, z, I) => {
384
- if (!x.current || q.current) return !1;
385
- const ae = B.current, Y = V.current, se = Y.at(-1);
386
- if (o !== "BACK" && Z(S), o === "BACK" && Y.length <= 1) return !1;
387
- const dn = o === "NAVIGATE" ? Y.findIndex((Oe) => Oe.name === S) : -1, Qe = o === "RESET" ? Y : o === "BACK" || o === "REPLACE" ? [se] : dn >= 0 ? Y.slice(dn + 1) : [];
388
- q.current = !0;
511
+ }, [s, l]), f = K(async (c, E, D, G) => {
512
+ if (!P.current || W.current) return !1;
513
+ const me = L.current, Z = R.current, pe = Z.at(-1);
514
+ if (c !== "BACK" && mn(E), c === "BACK" && Z.length <= 1) return !1;
515
+ const Mn = c === "NAVIGATE" ? Z.findIndex((We) => We.name === E) : -1, pn = c === "RESET" ? Z : c === "BACK" || c === "REPLACE" ? [pe] : Mn >= 0 ? Z.slice(Mn + 1) : [];
516
+ W.current = !0;
389
517
  try {
390
- if (Qe.length && le.current && !await le.current(Qe.map((Je) => Je.key), {
518
+ if (pn.length && de.current && !await de.current(pn.map((fn) => fn.key), {
391
519
  reason: "navigation",
392
- action: o,
393
- from: se,
394
- to: o === "BACK" ? Y.at(-2)?.name : S
395
- }) || !x.current || ae !== B.current || V.current.at(-1)?.key !== se.key) return !1;
396
- if (o === "BACK" && I !== void 0) {
397
- const Ce = Y.at(-2);
398
- v((Je) => ({ ...Je, [Ce.key]: { id: ++b.current, data: I } }));
520
+ action: c,
521
+ from: pe,
522
+ to: c === "BACK" ? Z.at(-2)?.name : E
523
+ }) || !P.current || me !== L.current || R.current.at(-1)?.key !== pe.key) return !1;
524
+ if (c === "BACK" && G !== void 0) {
525
+ const $e = Z.at(-2);
526
+ Q((fn) => ({ ...fn, [$e.key]: { id: ++te.current, data: G } }));
399
527
  }
400
- o === "RESET" && v({}), ge(Qe.map((Ce) => Ce.key), o === "BACK" ? "returned" : "removed", I);
401
- const Oe = [...F.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((Ce) => Ce.dataset.modalRouteKey === se.key);
402
- U.current = Oe?.cloneNode(!0) ?? null, ee();
403
- const mn = { type: o, name: S, params: z };
404
- return V.current = Ke(V.current, mn), P(mn), !0;
405
- } catch (Oe) {
406
- return x.current && u(Oe, { phase: "navigationGuard", action: o }), !1;
528
+ c === "RESET" && Q({}), C(pn.map(($e) => $e.key), c === "BACK" ? "returned" : "removed", G);
529
+ const We = [...oe.current?.querySelectorAll("[data-modal-route-key]") ?? []].find(($e) => $e.dataset.modalRouteKey === pe.key);
530
+ be.current = We?.cloneNode(!0) ?? null, dn();
531
+ const Yn = { type: c, name: E, params: D };
532
+ return R.current = Xe(R.current, Yn), M({ type: "COMMIT", stack: R.current }), !0;
533
+ } catch (We) {
534
+ return P.current && l(We, { phase: "navigationGuard", action: c }), !1;
407
535
  } finally {
408
- q.current = !1;
536
+ W.current = !1;
409
537
  }
410
- }, [Z, ee, u, ge]), Be = w((o, S) => te("NAVIGATE", o, S), [te]), me = w(async (o, S) => {
411
- if (!x.current) return { status: "cancelled" };
412
- if (V.current, !await te("NAVIGATE", o, S) || !x.current) return { status: "cancelled" };
413
- const I = V.current.at(-1);
414
- return !I || I.name !== o ? { status: "cancelled" } : new Promise((ae) => {
415
- const Y = ++X.current;
416
- re.current.set(Y, { key: I.key, resolve: ae });
538
+ }, [mn, dn, l, C]), S = K((c, E) => f("NAVIGATE", c, E), [f]), v = K(async (c, E) => {
539
+ if (!P.current) return { status: "cancelled" };
540
+ if (R.current, !await f("NAVIGATE", c, E) || !P.current) return { status: "cancelled" };
541
+ const G = R.current.at(-1);
542
+ return !G || G.name !== c ? { status: "cancelled" } : new Promise((me) => {
543
+ const Z = ++ie.current;
544
+ ue.current.set(Z, { key: G.key, resolve: me });
417
545
  });
418
- }, [te]), ve = w((o, S) => te("REPLACE", o, S), [te]), qe = w((o, S) => te("RESET", o, S), [te]), Ee = w((o) => {
419
- if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setParams expects an object");
420
- if (!x.current) return;
421
- const S = { type: "SET_PARAMS", params: o };
422
- V.current = Ke(V.current, S), P(S);
423
- }, []), Re = w((o) => {
424
- if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
425
- if (!x.current) return;
426
- const S = { type: "SET_OPTIONS", options: o };
427
- V.current = Ke(V.current, S), P(S);
428
- }, []), an = w((o) => te("BACK", null, void 0, o), [te]), ze = w((o, S) => !x.current || h.current.getSnapshot().visible && t.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : g(o, S, { route: C, stack: a }), [t.lockCloseWhileLoading, g, C, a]), sn = l(ze);
429
- sn.current = ze;
430
- const cn = w((o) => sn.current("api", o), []), Ve = K(() => ({ navigate: Be, navigateAsync: me, replace: ve, reset: qe, setParams: Ee, setOptions: Re, goBack: an, close: cn, setLoading: Se }), [Be, me, ve, qe, Ee, Re, an, cn, Se]), ln = K(() => ({ canGoBack: a.length > 1, stack: a, currentRoute: C }), [a]);
431
- He(() => N.current.publish(ln), [ln]);
432
- const Ze = l(null);
433
- Ze.current || (Ze.current = Object.defineProperties({}, {
434
- canGoBack: { enumerable: !0, get: () => N.current.getSnapshot().canGoBack },
435
- stack: { enumerable: !0, get: () => N.current.getSnapshot().stack },
436
- currentRoute: { enumerable: !0, get: () => N.current.getSnapshot().currentRoute }
546
+ }, [f]), B = K((c, E) => f("REPLACE", c, E), [f]), N = K((c, E) => f("RESET", c, E), [f]), J = K((c) => {
547
+ if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] setParams expects an object");
548
+ if (!P.current) return;
549
+ const E = { type: "SET_PARAMS", params: c };
550
+ R.current = Xe(R.current, E), M({ type: "COMMIT", stack: R.current });
551
+ }, []), ce = K((c) => {
552
+ if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
553
+ if (!P.current) return;
554
+ const E = { type: "SET_OPTIONS", options: c };
555
+ R.current = Xe(R.current, E), M({ type: "COMMIT", stack: R.current });
556
+ }, []), ee = K((c) => f("BACK", null, void 0, c), [f]), he = K((c, E) => !P.current || Me.current.getSnapshot().visible && s.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : g(c, E, { route: A, stack: m }), [s.lockCloseWhileLoading, g, A, m]), qe = k(he);
557
+ qe.current = he;
558
+ const ae = K((c) => qe.current("api", c), []), Le = F(() => ({ navigate: S, navigateAsync: v, replace: B, reset: N, setParams: J, setOptions: ce, goBack: ee, close: ae, setLoading: Fe }), [S, v, B, N, J, ce, ee, ae, Fe]), He = F(() => ({ canGoBack: m.length > 1, stack: m, currentRoute: A }), [m]);
559
+ Ie(() => I.current.publish(He), [He]);
560
+ const ye = k(null);
561
+ ye.current || (ye.current = Object.defineProperties({}, {
562
+ canGoBack: { enumerable: !0, get: () => I.current.getSnapshot().canGoBack },
563
+ stack: { enumerable: !0, get: () => I.current.getSnapshot().stack },
564
+ currentRoute: { enumerable: !0, get: () => I.current.getSnapshot().currentRoute }
437
565
  }));
438
- const De = K(() => Object.assign(Ze.current, Ve), [Ve]);
439
- He(() => {
440
- const o = U.current;
441
- if (U.current = null, J.current?.cancel?.(), J.current = null, F.current?.querySelectorAll("[data-pmn-outgoing]").forEach((se) => se.remove()), !we || !de.enabled || !o || !F.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
442
- const S = F.current;
443
- o.removeAttribute("hidden"), o.removeAttribute("tabindex"), o.setAttribute("aria-hidden", "true"), o.setAttribute("inert", ""), o.dataset.pmnOutgoing = "true", o.querySelectorAll("[id]").forEach((se) => se.removeAttribute("id")), o.querySelectorAll("[autofocus]").forEach((se) => se.removeAttribute("autofocus")), o.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;background:var(--pmn-body);", S.appendChild(o);
444
- const z = de.direction === "back" ? 1 : -1, I = [...S.querySelectorAll("[data-modal-route-key]")].find((se) => se.dataset.modalRouteKey === W);
445
- I && (I.style.zIndex = "2");
446
- const ae = () => {
447
- o.remove(), I && (I.style.zIndex = ""), J.current === Y && (J.current = null);
566
+ const re = F(() => Object.assign(ye.current, Le), [Le]);
567
+ Ie(() => {
568
+ const c = be.current;
569
+ if (be.current = null, z.current?.cancel?.(), z.current = null, oe.current?.querySelectorAll("[data-pmn-outgoing]").forEach((pe) => pe.remove()), !we || !Re.enabled || !c || !oe.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
570
+ const E = oe.current;
571
+ c.removeAttribute("hidden"), c.removeAttribute("tabindex"), c.setAttribute("aria-hidden", "true"), c.setAttribute("inert", ""), c.dataset.pmnOutgoing = "true", c.querySelectorAll("[id]").forEach((pe) => pe.removeAttribute("id")), c.querySelectorAll("[autofocus]").forEach((pe) => pe.removeAttribute("autofocus")), c.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;background:var(--pmn-body);", E.appendChild(c);
572
+ const D = Re.direction === "back" ? 1 : -1, G = [...E.querySelectorAll("[data-modal-route-key]")].find((pe) => pe.dataset.modalRouteKey === y);
573
+ G && (G.style.zIndex = "2");
574
+ const me = () => {
575
+ c.remove(), G && (G.style.zIndex = ""), z.current === Z && (z.current = null);
448
576
  };
449
- let Y;
450
- if (o.animate)
451
- Y = o.animate([
577
+ let Z;
578
+ if (c.animate)
579
+ Z = c.animate([
452
580
  { opacity: 1, transform: "translate3d(0,0,0)" },
453
- { opacity: 1, transform: `translate3d(${z * 100}%,0,0)` }
454
- ], { duration: de.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), Y.addEventListener("finish", ae, { once: !0 }), Y.addEventListener("cancel", ae, { once: !0 }), J.current = Y;
581
+ { opacity: 1, transform: `translate3d(${D * 100}%,0,0)` }
582
+ ], { duration: Re.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), Z.addEventListener("finish", me, { once: !0 }), Z.addEventListener("cancel", me, { once: !0 }), z.current = Z;
455
583
  else {
456
- o.classList.add("pmn-page-exit", `pmn-page-exit-${de.direction}`), o.style.setProperty("--pmn-page-duration", `${de.duration}ms`), o.style.setProperty("--pmn-page-distance", "100%");
457
- const se = setTimeout(ae, de.duration + 40);
458
- Y = { cancel: () => {
459
- clearTimeout(se), ae();
460
- } }, J.current = Y;
584
+ c.classList.add("pmn-page-exit", `pmn-page-exit-${Re.direction}`), c.style.setProperty("--pmn-page-duration", `${Re.duration}ms`), c.style.setProperty("--pmn-page-distance", "100%");
585
+ const pe = setTimeout(me, Re.duration + 40);
586
+ Z = { cancel: () => {
587
+ clearTimeout(pe), me();
588
+ } }, z.current = Z;
461
589
  }
462
590
  return () => {
463
- Y?.cancel?.(), o.remove();
591
+ Z?.cancel?.(), c.remove();
464
592
  };
465
- }, [W]), He(() => {
466
- _.current = !1;
467
- const o = [...O.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((I) => I.dataset.modalRouteKey === W);
468
- if (!o) return;
469
- const S = j.current.get(W);
470
- (S?.isConnected && o.contains(S) && !S.matches(":disabled") && !S.closest("[inert], [hidden]") ? S : o).focus({ preventScroll: !0 });
471
- }, [W]), Q(() => {
472
- let o = !1;
473
- for (const [z, I] of Le.current)
474
- I.owner !== "global" && I.owner !== W && (Le.current.delete(z), o = !0);
475
- o && Ae();
476
- const S = new Set(a.map((z) => z.key));
477
- v((z) => {
478
- const I = Object.keys(z).filter((Y) => !S.has(Y));
479
- if (!I.length) return z;
480
- const ae = { ...z };
481
- return I.forEach((Y) => delete ae[Y]), ae;
593
+ }, [y]), Ie(() => {
594
+ le.current = !1;
595
+ const c = [...ne.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((G) => G.dataset.modalRouteKey === y);
596
+ if (!c) return;
597
+ const E = X.current.get(y);
598
+ (E?.isConnected && c.contains(E) && !E.matches(":disabled") && !E.closest("[inert], [hidden]") ? E : c).focus({ preventScroll: !0 });
599
+ }, [y]), H(() => {
600
+ let c = !1;
601
+ for (const [D, G] of Ze.current)
602
+ G.owner !== "global" && G.owner !== y && (Ze.current.delete(D), c = !0);
603
+ c && un();
604
+ const E = new Set(m.map((D) => D.key));
605
+ Q((D) => {
606
+ const G = Object.keys(D).filter((Z) => !E.has(Z));
607
+ if (!G.length) return D;
608
+ const me = { ...D };
609
+ return G.forEach((Z) => delete me[Z]), me;
482
610
  });
483
- for (const z of j.current.keys()) S.has(z) || j.current.delete(z);
484
- }, [W, a, Ae]), Q(() => {
485
- if (E.current?.key !== W) {
486
- if (E.current) {
487
- const o = { from: E.current, to: C, stack: a };
488
- ne("onBlur", { route: E.current, ...o }), ne("onNavigate", o), ne("onRouteChange", o);
611
+ for (const D of X.current.keys()) E.has(D) || X.current.delete(D);
612
+ }, [y, m, un]), H(() => {
613
+ if (_.current?.key !== y) {
614
+ if (_.current) {
615
+ const c = { from: _.current, to: A, stack: m };
616
+ a("onBlur", { route: _.current, ...c }), a("onNavigate", c), a("onRouteChange", c);
489
617
  }
490
- ne("onFocus", { route: C, stack: a }), E.current = C;
618
+ a("onFocus", { route: A, stack: m }), _.current = A;
491
619
  }
492
- }, [C, W, a, ne]), Q(() => () => {
493
- Le.current.clear(), j.current.clear();
494
- for (const o of re.current.values()) o.resolve({ status: "dismissed" });
495
- re.current.clear();
496
- }, []), Q(() => {
497
- ye.current || (ye.current = !0, p?.({ route: C, stack: a }));
620
+ }, [A, y, m, a]), H(() => () => {
621
+ Ze.current.clear(), X.current.clear();
622
+ for (const c of ue.current.values()) c.resolve({ status: "dismissed" });
623
+ ue.current.clear();
624
+ }, []), H(() => {
625
+ ge.current || (ge.current = !0, p?.({ route: A, stack: m }));
498
626
  }, []);
499
- const Bn = K(() => $n(a, c, t.maxCachedScreens), [a, c, t.maxCachedScreens]), un = K(() => ({ ...c[C.name], ...C.options ?? {} }), [c, C.name, C.options]);
500
- return /* @__PURE__ */ s(rn.Provider, { value: $, children: /* @__PURE__ */ s(wn.Provider, { value: G.current, children: /* @__PURE__ */ s(xn.Provider, { value: L.current, children: /* @__PURE__ */ s(vn.Provider, { value: De, children: /* @__PURE__ */ s(_e.Provider, { value: Ve, children: /* @__PURE__ */ s(We.Provider, { value: N.current, children: /* @__PURE__ */ s(Me.Provider, { value: ke, children: /* @__PURE__ */ ce(En, { dialogRef: O, options: t, requestClose: ze, exiting: m, children: [
501
- /* @__PURE__ */ s(Rn, { options: t, screen: un, route: C, navigation: De, requestClose: ze, translate: i, canGoBack: a.length > 1 }),
502
- /* @__PURE__ */ s("main", { ref: F, className: "pmn-main", children: Bn.map((o) => /* @__PURE__ */ s(
503
- Un,
627
+ const Pe = F(() => et(m, Se, s.maxCachedScreens), [m, Se, s.maxCachedScreens]), Ae = F(() => ({ ...Se[A.name], ...A.options ?? {} }), [Se, A.name, A.options]), Vn = e.refs.header;
628
+ return /* @__PURE__ */ i(tn.Provider, { value: Vn.current, children: /* @__PURE__ */ i(vn.Provider, { value: Y, children: /* @__PURE__ */ i(Bn.Provider, { value: O.current, children: /* @__PURE__ */ i(zn.Provider, { value: q.current, children: /* @__PURE__ */ i(Nn.Provider, { value: re, children: /* @__PURE__ */ i(rn.Provider, { value: Le, children: /* @__PURE__ */ i(on.Provider, { value: I.current, children: /* @__PURE__ */ i(De.Provider, { value: Qe, children: /* @__PURE__ */ Ce($n, { store: e.stores.layout, screenOptions: Ae.modalOptions, dialogRef: ne, requestClose: he, exiting: b, children: [
629
+ /* @__PURE__ */ i(In, { store: e.stores.layout, screen: Ae, route: A, navigation: re, requestClose: he, translate: o, canGoBack: m.length > 1 }),
630
+ /* @__PURE__ */ i("main", { ref: oe, className: "pmn-main", children: Pe.map((c) => /* @__PURE__ */ i(
631
+ Mt,
504
632
  {
505
- route: o,
506
- screen: c[o.name],
507
- navigation: De,
508
- focused: o.key === W,
509
- resultEvent: T[o.key] ?? null,
510
- bodyClassName: t.bodyClassName,
511
- setFooter: R,
512
- loadingApi: ke,
513
- loadingStore: D.current,
514
- notifyError: u,
515
- registerDirtyGuard: k,
516
- pageMotion: de,
517
- lazyFallback: t.lazyFallback
633
+ route: c,
634
+ screen: Se[c.name],
635
+ navigation: re,
636
+ focused: c.key === y,
637
+ resultEvent: $[c.key] ?? null,
638
+ bodyClassName: s.bodyClassName,
639
+ setFooter: En,
640
+ loadingApi: Qe,
641
+ loadingStore: j.current,
642
+ notifyError: l,
643
+ registerDirtyGuard: x,
644
+ pageMotion: c.key === y ? Re : null,
645
+ lazyFallback: s.lazyFallback
518
646
  },
519
- o.key
647
+ c.key
520
648
  )) }),
521
- /* @__PURE__ */ s(
522
- Wn,
649
+ /* @__PURE__ */ i(
650
+ Et,
523
651
  {
524
- store: L.current,
525
- routeKey: W,
526
- screen: un,
527
- options: t,
528
- route: C,
529
- navigation: De,
530
- requestClose: ze,
531
- translate: i,
532
- onError: u,
533
- loadingApi: ke
652
+ store: q.current,
653
+ routeKey: y,
654
+ screen: Ae,
655
+ layoutStore: e.stores.layout,
656
+ route: A,
657
+ navigation: re,
658
+ requestClose: he,
659
+ translate: o,
660
+ onError: l,
661
+ loadingApi: Qe
534
662
  },
535
- W
663
+ y
536
664
  ),
537
- /* @__PURE__ */ s(Hn, { store: D.current, translate: i }),
538
- /* @__PURE__ */ s(_n, { store: G.current, dismiss: H }),
539
- y && /* @__PURE__ */ ce("div", { className: "pmn-error", role: "alert", children: [
540
- /* @__PURE__ */ s("span", { children: y.message || String(y) }),
541
- /* @__PURE__ */ s("button", { type: "button", onClick: M, "aria-label": "Dismiss error", children: "×" })
665
+ /* @__PURE__ */ i(St, { store: j.current, translate: o }),
666
+ /* @__PURE__ */ i(Ct, { store: O.current, dismiss: T }),
667
+ d && /* @__PURE__ */ Ce("div", { className: "pmn-error", role: "alert", children: [
668
+ /* @__PURE__ */ i("span", { children: d.message || String(d) }),
669
+ /* @__PURE__ */ i("button", { type: "button", onClick: u, "aria-label": "Dismiss error", children: "×" })
542
670
  ] })
543
- ] }) }) }) }) }) }) }) });
671
+ ] }) }) }) }) }) }) }) }) });
544
672
  }
545
- const Vn = be.memo(function({ store: n, route: r, ...t }) {
546
- const i = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
547
- return /* @__PURE__ */ s(Cn, { ...t, route: r, override: i[r.key] });
548
- }), Zn = be.memo(function({ store: n, translate: r }) {
549
- const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
550
- return /* @__PURE__ */ s(Tn, { loading: t, translate: r });
551
- }), Qn = be.memo(function({ store: n, dismiss: r }) {
552
- const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
553
- return /* @__PURE__ */ s(Pn, { items: t, dismiss: r });
554
- });
555
- function Jn({ config: e, initialScreen: n, params: r, options: t, translate: i, onRequestClose: g, onOpened: p, registerLoading: f, notifyError: u, error: y, clearError: M, registerDirtyGuard: k, exiting: d = !1 }) {
556
- const m = n ?? e.initialRoute ?? Object.keys(e.screens)[0], [a, P] = pe(() => ({ key: "single", name: m, params: r ?? {}, options: {} })), N = l(a);
557
- N.current = a;
558
- const D = e.screens[m], L = l(!0), G = l(null), x = l(null), B = l(null), $ = l(null), H = l(null);
559
- x.current || (x.current = kn({ canGoBack: !1, stack: [a], currentRoute: a })), B.current || (B.current = Te({})), $.current || ($.current = Te({ visible: !1, text: null, count: 0 })), H.current || (H.current = Te([]));
560
- const T = l("single"), { loadingApi: v, setLoading: j } = An($, L, T), { toast: O, dismissToast: F } = Nn(H, L), U = w((b, C) => {
561
- const W = B.current, ue = W.getSnapshot();
562
- if (C === null) {
563
- if (ue[b] !== void 0) {
564
- const he = { ...ue };
565
- delete he[b], W.publish(he);
566
- }
567
- } else ue[b] !== C && W.publish({ ...ue, [b]: C });
568
- }, []), J = w((b = "api", C) => g(b, C), [g]), E = w(() => Promise.resolve(!1), []), _ = K(() => ({
569
- navigate: E,
570
- navigateAsync: async () => ({ status: "cancelled" }),
571
- replace: E,
572
- reset: E,
573
- goBack: E,
574
- popToTop: E,
575
- popTo: E,
576
- setParams: (b) => (P((C) => ({ ...C, params: { ...C.params, ...typeof b == "function" ? b(C.params) : b } })), !0),
577
- setOptions: (b) => (P((C) => ({ ...C, options: { ...C.options, ...b } })), !0),
578
- close: J,
579
- setLoading: j,
580
- canGoBack: !1,
581
- stack: [a],
582
- currentRoute: a
583
- }), [J, a, j, E]), q = l(_);
584
- q.current = _;
585
- const re = K(() => ({
586
- navigate: (...b) => q.current.navigate(...b),
587
- navigateAsync: (...b) => q.current.navigateAsync(...b),
588
- replace: (...b) => q.current.replace(...b),
589
- reset: (...b) => q.current.reset(...b),
590
- goBack: (...b) => q.current.goBack(...b),
591
- popToTop: (...b) => q.current.popToTop(...b),
592
- popTo: (...b) => q.current.popTo(...b),
593
- setParams: (...b) => q.current.setParams(...b),
594
- setOptions: (...b) => q.current.setOptions(...b),
595
- close: (...b) => q.current.close(...b),
596
- setLoading: (...b) => q.current.setLoading(...b)
597
- }), []), X = K(() => ({
598
- setLoading: (b, C) => v.setScreenLoading("single", b, C),
599
- showLoading: (b) => v.begin("single", b),
600
- hideLoading: (b) => v.end("single", b)
601
- }), [v]), ge = K(() => ({ isFocused: !0, resultEvent: null, routeKey: "single", setFooter: U }), [U]), V = K(() => ({ routeKey: "single", registerDirtyGuard: k }), [k]);
602
- Q(() => {
603
- x.current.publish({ canGoBack: !1, stack: [a], currentRoute: a });
604
- }, [a]), Q(() => (L.current = !0, f?.({ setLoading: j }), p?.({ route: N.current, stack: [N.current] }), () => {
605
- L.current = !1;
606
- }), []);
607
- const le = { ...D, ...a.options }, ye = D.component;
608
- return /* @__PURE__ */ s(rn.Provider, { value: O, children: /* @__PURE__ */ s(wn.Provider, { value: H.current, children: /* @__PURE__ */ s(xn.Provider, { value: B.current, children: /* @__PURE__ */ s(vn.Provider, { value: _, children: /* @__PURE__ */ s(_e.Provider, { value: re, children: /* @__PURE__ */ s(We.Provider, { value: x.current, children: /* @__PURE__ */ s(Me.Provider, { value: v, children: /* @__PURE__ */ ce(En, { dialogRef: G, options: t, requestClose: J, exiting: d, children: [
609
- /* @__PURE__ */ s(Rn, { options: t, screen: le, route: a, navigation: _, requestClose: J, translate: i, canGoBack: !1 }),
610
- /* @__PURE__ */ s("main", { className: "pmn-main", children: /* @__PURE__ */ s(on.Provider, { value: a, children: /* @__PURE__ */ s(tn.Provider, { value: V, children: /* @__PURE__ */ s(je.Provider, { value: ge, children: /* @__PURE__ */ s(Me.Provider, { value: X, children: /* @__PURE__ */ s(Ue.Provider, { value: $.current, children: /* @__PURE__ */ s("div", { className: `pmn-body ${t.bodyClassName ?? ""}`, "data-modal-route-key": "single", tabIndex: -1, children: /* @__PURE__ */ s(Mn, { route: a, onError: u, children: /* @__PURE__ */ s(bn, { fallback: t.lazyFallback ?? /* @__PURE__ */ s("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ s(ye, { route: a, navigation: _ }) }) }) }) }) }) }) }) }) }),
611
- /* @__PURE__ */ s(Vn, { store: B.current, route: a, screen: le, options: t, navigation: _, requestClose: J, translate: i, onError: u, loadingApi: v }),
612
- /* @__PURE__ */ s(Zn, { store: $.current, translate: i }),
613
- /* @__PURE__ */ s(Qn, { store: H.current, dismiss: F }),
614
- y && /* @__PURE__ */ ce("div", { className: "pmn-error", role: "alert", children: [
615
- /* @__PURE__ */ s("span", { children: y.message || String(y) }),
616
- /* @__PURE__ */ s("button", { type: "button", onClick: M, children: "×" })
617
- ] })
618
- ] }) }) }) }) }) }) }) });
673
+ const ar = (e) => e, sr = (e) => ({ definitionLoader: e }), Je = /* @__PURE__ */ new WeakMap();
674
+ function nn(e) {
675
+ if (!Je.has(e)) {
676
+ const n = Promise.resolve().then(e).catch((t) => {
677
+ throw Je.delete(e), t;
678
+ });
679
+ Je.set(e, n);
680
+ }
681
+ return Je.get(e);
619
682
  }
620
- const Xn = ".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}@keyframes pmn-page-forward-in{0%{opacity:.18;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:.18;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}.pmn-page-enter{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.2,.8,.2,1);animation-fill-mode:both;will-change:transform,opacity}.pmn-page-forward{animation-name:pmn-page-forward-in}.pmn-page-back{animation-name:pmn-page-back-in}@media(prefers-reduced-motion:reduce){.pmn-page-enter{animation:none!important;will-change:auto}}.pmn-main{position:relative;isolation:isolate}.pmn-page-exit{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}.pmn-page-exit-forward{animation-name:pmn-page-forward-out}.pmn-page-exit-back{animation-name:pmn-page-back-out}@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}.pmn-main>.pmn-body{position:relative;width:100%;flex:1 0 100%;background:var(--pmn-body)}.pmn-page-forward,.pmn-page-back{z-index:2}@keyframes pmn-page-forward-in{0%{opacity:1;transform:translate3d(100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:1;transform:translate3d(-100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-forward-out{to{opacity:1;transform:translate3d(-100%,0,0)}}@keyframes pmn-page-back-out{to{opacity:1;transform:translate3d(100%,0,0)}}.pmn-lazy-loading{display:flex;min-height:80px;align-items:center;justify-content:center;color:var(--pmn-muted);font-size:14px}.pmn-place-top .pmn-dialog{max-height:min(calc(100dvh - var(--pmn-top-offset, var(--pmn-gap)) - var(--pmn-gap)),var(--pmn-max-height,100dvh))}.pmn-dialog.pmn-has-custom-background{isolation:isolate;--pmn-body:transparent}.pmn-custom-background-layer{position:absolute;inset:0;z-index:0;pointer-events:none}.pmn-dialog.pmn-has-custom-background>:not(.pmn-custom-background-layer){position:relative;z-index:1}.pmn-dialog.pmn-has-custom-background .pmn-main>.pmn-body{background:transparent}", gn = "react-modal-navigation-styles", en = /* @__PURE__ */ new WeakMap();
621
- function et() {
622
- zn(() => {
623
- if (typeof document > "u") return;
624
- const e = document;
625
- let n = en.get(e);
626
- if (!n) {
627
- let r = e.getElementById(gn);
628
- const t = !r;
629
- r || (r = e.createElement("style"), r.id = gn, r.setAttribute("data-react-modal-navigation", ""), r.textContent = Xn, e.head.appendChild(r)), n = { element: r, owned: t, count: 0 }, en.set(e, n);
683
+ async function _n(e, n) {
684
+ let t = typeof e == "string" ? n?.[e] : e;
685
+ if (t?.definitionLoader) {
686
+ const r = await nn(t.definitionLoader);
687
+ t = r.default ?? r;
688
+ }
689
+ if (!t || !(t.component || t.loader || t.screens)) throw new Error(`[react-modal-navigation] Unknown or invalid modal: ${typeof e == "string" ? e : "inline"}`);
690
+ return t;
691
+ }
692
+ async function Pt(e, n, t) {
693
+ const r = await _n(e, n), o = r.screens ? r.screens[t ?? r.initialRoute ?? Object.keys(r.screens)[0]] : r;
694
+ if (!o) throw new Error("[react-modal-navigation] Unknown preload screen");
695
+ return o.loader && await nn(o.loader), r;
696
+ }
697
+ function Tt(e) {
698
+ return function(t) {
699
+ const [r, o] = xe(() => fe.lazy(() => nn(e)));
700
+ return /* @__PURE__ */ i(Cn, { route: t.route, onRetry: () => o(() => fe.lazy(() => nn(e))), children: /* @__PURE__ */ i(r, { ...t }) });
701
+ };
702
+ }
703
+ function Ot(e, n) {
704
+ const t = e.config.singlePage || Object.keys(e.config.screens).length === 1, r = t ? [{ key: "single", name: e.screen, params: e.params ?? {}, options: {} }] : Fn(e.screen, e.params), o = Oe({});
705
+ o.set = (s, m) => {
706
+ const M = o.getSnapshot();
707
+ if (m == null && !(s in M) || Object.is(M[s], m)) return;
708
+ const I = { ...M };
709
+ m == null ? delete I[s] : I[s] = m, o.publish(I);
710
+ };
711
+ const g = {
712
+ layout: Oe(n),
713
+ navigation: Oe({ canGoBack: !1, stack: r, currentRoute: r[0] }),
714
+ header: o,
715
+ footer: Oe({}),
716
+ loading: Oe({ visible: !1, text: null, count: 0 }),
717
+ toast: Oe([])
718
+ }, p = Object.fromEntries(Object.entries(g).map(([s, m]) => [s, { current: m }])), h = { current: !0 }, l = /* @__PURE__ */ new Set(), d = { current: /* @__PURE__ */ new Map() }, u = { current: /* @__PURE__ */ new Map() }, x = { current: 0 }, w = (s) => h.current ? (l.add(s), () => l.delete(s)) : (s(), () => {
719
+ }), b = () => {
720
+ if (h.current) {
721
+ h.current = !1;
722
+ for (const s of l)
723
+ try {
724
+ s();
725
+ } catch (m) {
726
+ console.error(m);
727
+ }
728
+ l.clear(), d.current.clear();
729
+ for (const s of u.current.values()) s.resolve({ status: "dismissed" });
730
+ u.current.clear(), Object.values(g).forEach((s) => s.destroy());
630
731
  }
631
- return n.count += 1, () => {
632
- n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), en.delete(e));
633
- };
634
- }, []);
732
+ };
733
+ return { id: e.id, single: t, stores: g, refs: p, alive: h, loadingTasks: d, loadingSequence: x, pageRequests: u, addCleanup: w, destroy: b };
635
734
  }
636
- function Ge(e, n, r) {
735
+ function _e(e, n, t) {
637
736
  if (typeof e == "string") {
638
737
  if (!e.trim()) throw new TypeError("[react-modal-navigation] modal name must not be empty");
639
- return { name: e, params: n ?? {}, options: r ?? {} };
738
+ return { name: e, params: n ?? {}, options: t ?? {} };
640
739
  }
641
740
  if (e === null || typeof e != "object" || Array.isArray(e))
642
741
  throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
643
- const { name: t, screen: i, params: g = {}, options: p = {}, ...f } = e;
644
- if (typeof t != "string" || !t.trim())
742
+ if (e.component || e.loader || e.screens || e.definitionLoader) {
743
+ const { params: l, options: d, screen: u, ...x } = e;
744
+ return { name: x, params: n ?? l ?? {}, options: { ...d, ...t }, screen: u };
745
+ }
746
+ const { name: r, screen: o, params: g = {}, options: p = {}, ...h } = e;
747
+ if (typeof r != "string" || !r.trim())
645
748
  throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
646
749
  if (p === null || typeof p != "object" || Array.isArray(p))
647
750
  throw new TypeError("[react-modal-navigation] open config options must be an object");
648
- if (i !== void 0 && (typeof i != "string" || !i.trim()))
751
+ if (o !== void 0 && (typeof o != "string" || !o.trim()))
649
752
  throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
650
- return { name: t, ...i === void 0 ? {} : { screen: i }, params: g, options: { ...f, ...p } };
753
+ return { name: r, ...o === void 0 ? {} : { screen: o }, params: g, options: { ...h, ...p } };
651
754
  }
652
- function nt() {
755
+ function Lt() {
653
756
  const e = /* @__PURE__ */ new Map();
654
757
  return {
655
758
  wait(n) {
656
- return new Promise((r) => {
657
- const t = setTimeout(() => {
658
- e.delete(t), r();
759
+ return n <= 0 ? Promise.resolve() : new Promise((t) => {
760
+ const r = setTimeout(() => {
761
+ e.delete(r), t();
659
762
  }, Math.max(0, n));
660
- e.set(t, r);
763
+ e.set(r, t);
661
764
  });
662
765
  },
663
766
  cancelAll() {
664
- for (const [n, r] of e)
665
- clearTimeout(n), r();
767
+ for (const [n, t] of e)
768
+ clearTimeout(n), t();
666
769
  e.clear();
667
770
  },
668
771
  pendingCount: () => e.size
669
772
  };
670
773
  }
671
- const tt = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, rt = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
672
- function pt({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: t, theme: i, translate: g = rt, onError: p, confirmDiscard: f }) {
673
- et();
674
- const [u, y] = pe(null), [M, k] = pe(null), [d, m] = pe(0), a = l(null), P = l(/* @__PURE__ */ new Map()), N = l([]), D = l(null), L = l(null), G = l(0), x = l(null), B = l(!1), $ = l(0), H = l(null), T = l(/* @__PURE__ */ new Map()), [v, j] = pe(!1), O = l(f);
675
- O.current = f;
676
- const F = w((c, h) => (T.current.set(c, h), () => {
677
- T.current.get(c) === h && T.current.delete(c);
678
- }), []), U = w(async (c) => {
679
- for (const h of T.current.values()) {
680
- if (!h.dirty) continue;
681
- if ((h.onBeforeDiscard ? await h.onBeforeDiscard(c) : O.current ? await O.current(c) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(h.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
774
+ const At = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 };
775
+ function Nt(e, n) {
776
+ let t = e;
777
+ const r = /* @__PURE__ */ new Set(), { confirmDiscard: o, onError: g } = t, p = Oe({ isOpen: !1, activeName: null, isFullscreen: !1, queueSize: 0, error: null }), h = Oe({ active: null, options: null, exiting: !1, error: null, translate: t.translate });
778
+ let l = null;
779
+ const d = (a) => {
780
+ l = a, Me();
781
+ };
782
+ let u = null;
783
+ const x = (a) => {
784
+ u = a, Me();
785
+ };
786
+ let w = 0;
787
+ const b = (a) => {
788
+ w = a, Me();
789
+ }, s = { current: null }, m = { current: /* @__PURE__ */ new Map() }, M = { current: [] }, I = { current: null }, j = { current: null }, q = { current: 0 }, O = { current: null }, P = { current: !1 }, L = { current: 0 }, Y = { current: null }, T = { current: /* @__PURE__ */ new Map() };
790
+ let $ = !1;
791
+ const Q = (a) => {
792
+ $ = a, Me();
793
+ }, X = { current: o }, ne = ((a, f) => (T.current.set(a, f), () => {
794
+ T.current.get(a) === f && T.current.delete(a);
795
+ })), oe = (async (a) => {
796
+ for (const f of T.current.values()) {
797
+ if (!f.dirty) continue;
798
+ if ((f.onBeforeDiscard ? await f.onBeforeDiscard(a) : X.current ? await X.current(a) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(f.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
682
799
  }
683
800
  return !0;
684
- }, []), J = w(async (c, h) => {
685
- for (const A of c) {
686
- const R = T.current.get(A);
687
- if (!R?.dirty) continue;
688
- if ((R.onBeforeDiscard ? await R.onBeforeDiscard(h) : O.current ? await O.current(h) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(R.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
801
+ }), be = (async (a, f) => {
802
+ for (const S of a) {
803
+ const v = T.current.get(S);
804
+ if (!v?.dirty) continue;
805
+ if ((v.onBeforeDiscard ? await v.onBeforeDiscard(f) : X.current ? await X.current(f) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(v.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
689
806
  }
690
807
  return !0;
691
- }, []), E = l(!0), _ = l(null);
692
- _.current || (_.current = nt());
693
- const q = l(null), re = l(p);
694
- re.current = p;
695
- const X = w((c, h) => {
696
- E.current && k(c);
808
+ }), z = { current: !0 }, _ = { current: null };
809
+ _.current || (_.current = Lt());
810
+ const le = { current: g }, W = ((a, f) => {
811
+ z.current && x(a);
697
812
  try {
698
- re.current ? re.current(c, h) : console.error("[react-modal-navigation]", c);
699
- } catch (A) {
700
- console.error("[react-modal-navigation] onError failed", A);
813
+ le.current ? le.current(a, f) : console.error("[react-modal-navigation]", a);
814
+ } catch (S) {
815
+ console.error("[react-modal-navigation] onError failed", S);
701
816
  }
702
- }, []), ge = w((c, h) => {
703
- const A = P.current.get(c);
704
- P.current.delete(c), A?.(h);
705
- }, []), V = w((c) => ({ ...tt, ...r, ...i !== void 0 ? { theme: i } : {}, ...t !== void 0 ? { backgroundColor: t } : {}, ...c.config.modalOptions, ...c.overrides }), [r, i, t]), le = u ? V(u) : null, ye = l(null);
706
- ye.current = le, q.current = le;
707
- const b = w(async (c = "api", h, A = {}) => {
708
- const R = a.current;
709
- if (!R || x.current || B.current) return !1;
710
- x.current = R.id, B.current = !0;
711
- const ee = q.current ?? V(R), Z = { ...A, reason: c, result: h, name: R.name };
817
+ }), ue = ((a, f) => {
818
+ const S = m.current.get(a);
819
+ m.current.delete(a);
820
+ for (const v of S ?? []) v(f);
821
+ }), ie = ((a) => ({ ...At, ...t.defaultOptions, ...t.theme !== void 0 ? { theme: t.theme } : {}, ...t.backgroundColor !== void 0 ? { backgroundColor: t.backgroundColor } : {}, ...a.config.modalOptions, ...a.overrides, runtimeLayout: a.runtimeLayout })), C = (async (a = "api", f, S = {}) => {
822
+ const v = s.current;
823
+ if (!v || O.current || P.current) return !1;
824
+ const B = L.current;
825
+ O.current = v.id, P.current = !0;
826
+ const N = ie(v), J = { ...S, reason: a, result: f, name: v.name };
712
827
  try {
713
- if (!await U(Z) || await ee.onBeforeClose?.(Z) === !1 || a.current?.id !== R.id || !E.current) return !1;
714
- j(!0);
715
- const ne = ee.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(ee.animationDuration ?? 220) || 0);
716
- if (await _.current.wait(Math.min(ne, 1e3)), !E.current || a.current?.id !== R.id) return !1;
717
- a.current = null, H.current = null, y(null), j(!1), T.current.clear(), ge(R.id, A.confirmed || h !== void 0 ? { status: "confirmed", value: h, reason: c } : { status: "dismissed", reason: c });
828
+ if (!await oe(J) || B !== L.current || s.current?.id !== v.id || await N.onBeforeClose?.(J) === !1 || s.current?.id !== v.id || !z.current) return !1;
829
+ Q(!0);
830
+ const ce = N.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(N.animationDuration ?? 220) || 0);
831
+ if (await _.current.wait(Math.min(ce, 1e3)), !z.current || s.current?.id !== v.id) return !1;
832
+ v.runtime.destroy(), s.current = null, Y.current = null, $ = !1, d(null), T.current.clear(), ue(v.id, S.confirmed || f !== void 0 ? { status: "confirmed", value: f, reason: a } : { status: "dismissed", reason: a });
718
833
  try {
719
- await ee.onClose?.(Z);
720
- } catch (te) {
721
- X(te, { phase: "onClose", name: R.name });
834
+ (S.confirmed || f !== void 0) && await N.onConfirmed?.(f), await N.onClose?.(J), await N.onClosed?.(J);
835
+ } catch (ee) {
836
+ B === L.current && W(ee, { phase: "onClose", name: v.name });
722
837
  }
723
838
  return !0;
724
- } catch (ne) {
725
- return X(ne, { phase: "onBeforeClose", name: R.name }), !1;
839
+ } catch (ce) {
840
+ return B === L.current && s.current?.id === v.id && W(ce, { phase: "onBeforeClose", name: v.name }), !1;
726
841
  } finally {
727
- x.current === R.id && (x.current = null), B.current = !1, !a.current && E.current && queueMicrotask(() => L.current?.());
842
+ O.current === v.id && (O.current = null), B === L.current && (P.current = !1), !s.current && z.current && queueMicrotask(() => j.current?.());
728
843
  }
729
- }, [V, X, ge, U]), C = w(async (c, h = {}, A = {}, R, ee) => {
730
- const Z = e?.[c], ne = Z?.component && !Z.screens ? { ...Z, singlePage: !0, initialRoute: "__single__", screens: { __single__: { component: Z.component, title: Z.title, ...Z.screenOptions ?? {} } } } : Z;
731
- if (!ne) throw new Error(`[react-modal-navigation] Unknown modal: ${c}`);
732
- const te = ee ?? ne.initialRoute ?? Object.keys(ne.screens ?? {})[0];
733
- if (!ne.screens?.[te]) throw new Error(`[react-modal-navigation] Unknown initial screen '${te}' in modal '${c}'`);
734
- if (!E.current || B.current || x.current) return null;
735
- B.current = !0;
736
- const Be = $.current;
844
+ }), R = (async (a, f = {}, S = {}, v, B) => {
845
+ if (!z.current || P.current || O.current) return null;
846
+ P.current = !0;
847
+ const N = L.current;
737
848
  try {
738
- const me = a.current;
739
- if (me) {
740
- const qe = q.current ?? V(me), Ee = { reason: "replace", name: me.name, nextName: c };
849
+ const J = await _n(a, t.registry);
850
+ if (!z.current || N !== L.current) return null;
851
+ const ce = (re) => re.loader && !re.component ? { ...re, component: n(re.loader) } : re, ee = J.screens ? { ...J, screens: Object.fromEntries(Object.entries(J.screens).map(([re, Pe]) => [re, ce(Pe)])) } : ce(J);
852
+ a = typeof a == "string" ? a : J.name ?? "inline";
853
+ const he = ee?.component && !ee.screens ? { ...ee, singlePage: !0, initialRoute: "__single__", screens: { __single__: { component: ee.component, title: ee.title, ...J.screenOptions ?? {} } } } : ee;
854
+ if (!he) throw new Error(`[react-modal-navigation] Unknown modal: ${a}`);
855
+ const qe = B ?? he.initialRoute ?? Object.keys(he.screens ?? {})[0];
856
+ if (!he.screens?.[qe]) throw new Error(`[react-modal-navigation] Unknown initial screen '${qe}' in modal '${a}'`);
857
+ const ae = s.current, Le = S.instanceKey ?? he.modalOptions?.instanceKey, He = S.duplicateStrategy ?? he.modalOptions?.duplicateStrategy;
858
+ if (ae && Le != null && ae.instanceKey === Le) {
859
+ if (He === "ignore") return null;
860
+ if (He === "reuse") {
861
+ if (v) {
862
+ const re = m.current.get(ae.id) ?? [];
863
+ re.push(v), m.current.set(ae.id, re);
864
+ }
865
+ return ae.id;
866
+ }
867
+ }
868
+ if (ae) {
869
+ const re = ie(ae), Pe = { reason: "replace", name: ae.name, nextName: a };
741
870
  try {
742
- if (!await U(Ee) || await qe.onBeforeClose?.(Ee) === !1) return null;
743
- } catch (Re) {
744
- return X(Re, { phase: "onBeforeClose", name: me.name }), null;
871
+ if (!await oe(Pe) || N !== L.current || s.current?.id !== ae.id || await re.onBeforeClose?.(Pe) === !1) return null;
872
+ } catch (Ae) {
873
+ return N === L.current && s.current?.id === ae.id && W(Ae, { phase: "onBeforeClose", name: ae.name }), null;
745
874
  }
746
- if (!E.current || Be !== $.current || a.current?.id !== me.id) return null;
747
- a.current = null, H.current = null, y(null), T.current.clear(), ge(me.id, { status: "replaced", reason: "replace" });
875
+ if (!z.current || N !== L.current || s.current?.id !== ae.id) return null;
876
+ ae.runtime.destroy(), s.current = null, Y.current = null, d(null), T.current.clear(), ue(ae.id, { status: "replaced", reason: "replace" });
748
877
  try {
749
- await qe.onClose?.(Ee);
750
- } catch (Re) {
751
- X(Re, { phase: "onClose", name: me.name });
878
+ await re.onClose?.(Pe), await re.onClosed?.(Pe);
879
+ } catch (Ae) {
880
+ N === L.current && W(Ae, { phase: "onClose", name: ae.name });
752
881
  }
753
- if (!E.current || Be !== $.current) return null;
882
+ if (!z.current || N !== L.current) return null;
754
883
  }
755
- const ve = { id: ++G.current, name: c, screen: te, params: h, config: ne, overrides: A };
756
- return a.current = ve, H.current = null, R && P.current.set(ve.id, R), k(null), y(ve), ve.id;
884
+ const ye = { id: ++q.current, name: a, screen: qe, params: f, config: he, overrides: S, instanceKey: Le };
885
+ return ye.runtime = Ot(ye, ie(ye)), ye.runtime.bindings = je(ye.id), s.current = ye, Y.current = null, v && m.current.set(ye.id, [v]), u = null, d(ye), ye.id;
757
886
  } finally {
758
- B.current = !1;
887
+ N === L.current && (P.current = !1), !s.current && z.current && queueMicrotask(() => j.current?.());
759
888
  }
760
- }, [e, V, X, ge, U]);
761
- D.current = C;
762
- const W = w(async () => {
763
- if (!E.current || a.current || B.current || x.current) return;
764
- const c = N.current.shift();
765
- if (c) {
766
- m(N.current.length);
889
+ });
890
+ I.current = R;
891
+ const de = (async () => {
892
+ if (!z.current || s.current || P.current || O.current) return;
893
+ const a = M.current.shift();
894
+ if (a) {
895
+ r.add(a), b(M.current.length);
767
896
  try {
768
- const h = await D.current(c.args.name, c.args.params, c.args.options, c.resolveResult, c.args.screen);
769
- h === null ? (c.resolveResult?.({ status: "dismissed", reason: "blocked" }), c.resolveId?.(null), queueMicrotask(() => L.current?.())) : c.resolveId?.(h);
770
- } catch (h) {
771
- c.reject?.(h), queueMicrotask(() => L.current?.());
897
+ const f = await I.current(a.args.name, a.args.params, a.args.options, a.resolveResult, a.args.screen);
898
+ f === null ? (a.resolveResult?.({ status: "dismissed", reason: "blocked" }), a.resolveId?.(null), queueMicrotask(() => j.current?.())) : a.resolveId?.(f);
899
+ } catch (f) {
900
+ a.reject?.(f), queueMicrotask(() => j.current?.());
901
+ } finally {
902
+ r.delete(a);
772
903
  }
773
904
  }
774
- }, []);
775
- L.current = W;
776
- const ue = w((c, h, A) => {
777
- const R = Ge(c, h, A);
778
- return e?.[R.name] ? new Promise((ee, Z) => {
779
- N.current.push({ args: R, resolveId: ee, reject: Z }), m(N.current.length), queueMicrotask(() => L.current?.());
780
- }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${R.name}`));
781
- }, [e]), he = w((c, h, A) => {
782
- const R = Ge(c, h, A);
783
- return e?.[R.name] ? new Promise((ee, Z) => {
784
- N.current.push({ args: R, resolveResult: ee, reject: Z }), m(N.current.length), queueMicrotask(() => L.current?.());
785
- }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${R.name}`));
786
- }, [e]), we = w((c) => {
787
- if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] update expects an options object");
788
- const h = a.current;
789
- if (!h || B.current) return !1;
790
- const A = { ...h, overrides: { ...h.overrides, ...c } };
791
- return a.current = A, y(A), q.current = V(A), !0;
792
- }, [V]), Ie = w((c = "queue-cleared") => {
793
- const h = N.current.splice(0);
794
- m(0);
795
- for (const A of h)
796
- A.resolveId?.(null), A.resolveResult?.({ status: "dismissed", reason: c });
797
- return h.length;
798
- }, []), Pe = w((c, h, A) => {
799
- const R = Ge(c, h, A);
800
- return C(R.name, R.params, R.options, void 0, R.screen);
801
- }, [C]), Ye = w((c, h, A) => {
802
- const R = Ge(c, h, A);
803
- return new Promise((ee, Z) => {
804
- C(R.name, R.params, R.options, ee, R.screen).then((ne) => {
805
- ne === null && ee({ status: "dismissed", reason: "blocked" });
806
- }, Z);
905
+ });
906
+ j.current = de;
907
+ const ge = ((a, f, S) => {
908
+ if (!z.current) return Promise.resolve(null);
909
+ const v = _e(a, f, S);
910
+ return typeof v.name == "string" && !t.registry?.[v.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${v.name}`)) : new Promise((B, N) => {
911
+ M.current.push({ args: v, resolveId: B, reject: N }), b(M.current.length), queueMicrotask(() => j.current?.());
807
912
  });
808
- }, [C]), de = w((c) => b("api", c), [b]), Ne = w((c = "api") => b(c), [b]), ke = w((c) => b("confirm", c, { confirmed: !0 }), [b]), Ae = w((c, h) => H.current?.setLoading(c, h), []), Le = K(() => ({ open: Pe, openAsync: Ye, enqueue: ue, enqueueAsync: he, update: we, clearQueue: Ie, close: de, dismiss: Ne, confirm: ke, setLoading: Ae, queueSize: d, isOpen: !!u, activeName: u?.name ?? null, error: M, clearError: () => k(null) }), [Pe, Ye, ue, he, we, Ie, de, Ne, ke, Ae, u, M, d]);
809
- Q(() => (E.current = !0, () => {
810
- E.current = !1, _.current.cancelAll(), $.current += 1, a.current = null;
811
- for (const h of P.current.values()) h({ status: "dismissed", reason: "unmount" });
812
- P.current.clear(), T.current.clear();
813
- const c = N.current.splice(0);
814
- for (const h of c)
815
- h.resolveId?.(null), h.resolveResult?.({ status: "dismissed", reason: "unmount" });
816
- }), []);
817
- const Se = u?.config.singlePage || u && Object.keys(u.config.screens ?? {}).length === 1 ? Jn : Yn;
818
- return /* @__PURE__ */ ce(yn.Provider, { value: Le, children: [
819
- n,
820
- u && /* @__PURE__ */ s(
821
- Se,
822
- {
823
- config: u.config,
824
- initialScreen: u.screen,
825
- params: u.params,
826
- options: le,
827
- translate: g,
828
- notifyError: X,
829
- error: M,
830
- clearError: () => k(null),
831
- registerLoading: (c) => {
832
- H.current = c;
833
- },
834
- registerDirtyGuard: F,
835
- canNavigate: J,
836
- exiting: v,
837
- onRequestClose: b,
838
- onOpened: (c) => {
839
- try {
840
- const h = ye.current?.onOpen?.(c);
841
- Promise.resolve(h).catch((A) => X(A, { phase: "onOpen" }));
842
- } catch (h) {
843
- X(h, { phase: "onOpen" });
844
- }
913
+ }), te = ((a, f, S) => {
914
+ if (!z.current) return Promise.resolve({ status: "dismissed", reason: "unmount" });
915
+ const v = _e(a, f, S);
916
+ return typeof v.name == "string" && !t.registry?.[v.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${v.name}`)) : new Promise((B, N) => {
917
+ M.current.push({ args: v, resolveResult: B, reject: N }), b(M.current.length), queueMicrotask(() => j.current?.());
918
+ });
919
+ }), A = ((a) => {
920
+ if (!a || typeof a != "object" || Array.isArray(a)) throw new TypeError("[react-modal-navigation] update expects an options object");
921
+ const f = s.current;
922
+ return !f || P.current ? !1 : (Object.keys(a).every((S) => Object.is(ie(f)[S], a[S])) || (f.overrides = { ...f.overrides, ...a }, f.runtimeLayout = { ...f.runtimeLayout, ...a }, Me()), !0);
923
+ }), y = ((a, f) => Pt(a, t.registry, f)), U = ((a) => A({ fullscreen: !!a })), ve = (() => U(!(s.current && ie(s.current).fullscreen))), we = ((a = "queue-cleared") => {
924
+ const f = M.current.splice(0);
925
+ b(0);
926
+ for (const S of f)
927
+ S.resolveId?.(null), S.resolveResult?.({ status: "dismissed", reason: a });
928
+ return f.length;
929
+ }), Fe = { open: ((a, f, S) => {
930
+ const v = _e(a, f, S);
931
+ return R(v.name, v.params, v.options, void 0, v.screen);
932
+ }), openInstance: (async (a, f, S) => {
933
+ const v = _e(a, f, S);
934
+ let B;
935
+ const N = new Promise((ee) => {
936
+ B = ee;
937
+ }), J = await R(v.name, v.params, v.options, B, v.screen);
938
+ J === null && B({ status: "dismissed", reason: "blocked" });
939
+ const ce = () => J !== null && s.current?.id === J;
940
+ return { id: J, result: N, isActive: ce, setOptions: (ee) => ce() && A(ee), setFullscreen: (ee) => ce() && A({ fullscreen: !!ee }), close: (ee) => ce() ? C("api", ee) : Promise.resolve(!1), confirm: (ee) => ce() ? C("confirm", ee, { confirmed: !0 }) : Promise.resolve(!1) };
941
+ }), openAsync: ((a, f, S) => {
942
+ const v = _e(a, f, S);
943
+ return new Promise((B, N) => {
944
+ R(v.name, v.params, v.options, B, v.screen).then((J) => {
945
+ J === null && B({ status: "dismissed", reason: "blocked" });
946
+ }, N);
947
+ });
948
+ }), enqueue: ge, enqueueAsync: te, update: A, setOptions: A, preload: y, setFullscreen: U, toggleFullscreen: ve, clearQueue: we, close: ((a) => C("api", a)), dismiss: ((a = "api") => C(a)), confirm: ((a) => C("confirm", a, { confirmed: !0 })), setLoading: ((a, f) => Y.current?.setLoading(a, f)), clearError: () => x(null) }, Se = (a, f) => Object.keys(a).length === Object.keys(f).length && Object.keys(a).every((S) => Object.is(a[S], f[S]));
949
+ function Me() {
950
+ const a = l ? ie(l) : null, f = h.getSnapshot();
951
+ l && !Se(a, l.runtime.stores.layout.getSnapshot()) && l.runtime.stores.layout.publish(a);
952
+ const S = l ? f.active === l ? f.options : a : null, v = { isOpen: !!l, activeName: l?.name ?? null, isFullscreen: !!a?.fullscreen, queueSize: w, error: u }, B = { active: l, options: S, exiting: $, error: u, translate: t.translate };
953
+ Se(v, p.getSnapshot()) || p.publish(v), Se(B, f) || h.publish(B);
954
+ }
955
+ const je = (a) => ({
956
+ registerLoading: (f) => {
957
+ s.current?.id === a && (Y.current = f);
958
+ },
959
+ registerDirtyGuard: (f, S) => s.current?.id === a ? ne(f, S) : () => {
960
+ },
961
+ canNavigate: (f, S) => s.current?.id === a ? be(f, S) : Promise.resolve(!1),
962
+ onRequestClose: (...f) => s.current?.id === a ? C(...f) : Promise.resolve(!1),
963
+ onOpened: (f) => {
964
+ if (s.current?.id !== a) return;
965
+ const S = ie(s.current), v = (B, N) => {
966
+ s.current?.id === a && W(B, { phase: N });
967
+ };
968
+ for (const B of ["onOpen", "onOpened"])
969
+ try {
970
+ Promise.resolve(S[B]?.(f)).catch((N) => v(N, B));
971
+ } catch (N) {
972
+ v(N, B);
845
973
  }
846
- },
847
- u.id
848
- )
849
- ] });
974
+ }
975
+ });
976
+ return { commands: Fe, statusStore: p, hostStore: h, bindInstance: je, configure: (a) => {
977
+ t = a, X.current = a.confirmDiscard, le.current = a.onError, Me();
978
+ }, mount: () => {
979
+ z.current = !0;
980
+ }, destroy: () => {
981
+ z.current = !1, L.current += 1, _.current.cancelAll(), s.current?.runtime.destroy(), s.current = null, Y.current = null, O.current = null, P.current = !1;
982
+ for (const a of m.current.keys()) ue(a, { status: "dismissed", reason: "unmount" });
983
+ m.current.clear(), T.current.clear(), l = null, $ = !1, u = null;
984
+ for (const a of r)
985
+ a.resolveId?.(null), a.resolveResult?.({ status: "dismissed", reason: "unmount" });
986
+ r.clear(), we("unmount"), Me();
987
+ }, reportError: W };
988
+ }
989
+ const zt = fe.memo(function({ Screen: n, route: t, navigation: r }) {
990
+ return /* @__PURE__ */ i(n, { route: t, navigation: r });
991
+ }), Bt = fe.memo(function({ store: n, layoutStore: t, route: r, ...o }) {
992
+ const g = () => n.getSnapshot()[r.key], p = Ee(n.subscribe, g, g), h = ke(t, jn, ze);
993
+ return /* @__PURE__ */ i(Dn, { ...o, options: h, route: r, override: p });
994
+ }), Ft = fe.memo(function({ store: n, translate: t }) {
995
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
996
+ return /* @__PURE__ */ i(Kn, { loading: r, translate: t });
997
+ }), jt = fe.memo(function({ store: n, dismiss: t }) {
998
+ const r = Ee(n.subscribe, n.getSnapshot, n.getSnapshot);
999
+ return /* @__PURE__ */ i(Hn, { items: r, dismiss: t });
1000
+ });
1001
+ function qt({ runtime: e, config: n, initialScreen: t, params: r, translate: o, onRequestClose: g, onOpened: p, registerLoading: h, notifyError: l, error: d, clearError: u, registerDirtyGuard: x, exiting: w = !1 }) {
1002
+ const b = ke(e.stores.layout, ut, ze), s = t ?? n.initialRoute ?? Object.keys(n.screens)[0], [m, M] = xe(() => e.stores.navigation.getSnapshot().currentRoute), I = k(m);
1003
+ I.current = m;
1004
+ const j = n.screens[s], q = e.alive, O = k(null), { navigation: P, footer: L, loading: Y, toast: T } = e.refs, $ = k("single"), { loadingApi: Q, setLoading: X } = Gn(Y, q, $, e), { toast: ne, dismissToast: oe } = Wn(T, q, e), be = K((y, U) => {
1005
+ const ve = L.current, we = ve.getSnapshot();
1006
+ if (U === null) {
1007
+ if (we[y] !== void 0) {
1008
+ const Be = { ...we };
1009
+ delete Be[y], ve.publish(Be);
1010
+ }
1011
+ } else we[y] !== U && ve.publish({ ...we, [y]: U });
1012
+ }, []), z = K((y = "api", U) => !q.current || Y.current.getSnapshot().visible && e.stores.layout.getSnapshot().lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : g(y, U), [g, e]), _ = K(() => Promise.resolve(!1), []), le = F(() => ({
1013
+ navigate: _,
1014
+ navigateAsync: async () => ({ status: "cancelled" }),
1015
+ replace: _,
1016
+ reset: _,
1017
+ goBack: _,
1018
+ popToTop: _,
1019
+ popTo: _,
1020
+ setParams: (y) => q.current ? (M((U) => ({ ...U, params: { ...U.params, ...typeof y == "function" ? y(U.params) : y } })), !0) : !1,
1021
+ setOptions: (y) => q.current ? (M((U) => ({ ...U, options: { ...U.options, ...y } })), !0) : !1,
1022
+ close: z,
1023
+ setLoading: X,
1024
+ canGoBack: !1,
1025
+ stack: [m],
1026
+ currentRoute: m
1027
+ }), [z, m, X, _]), W = k(le);
1028
+ W.current = le;
1029
+ const ue = F(() => ({
1030
+ navigate: (...y) => W.current.navigate(...y),
1031
+ navigateAsync: (...y) => W.current.navigateAsync(...y),
1032
+ replace: (...y) => W.current.replace(...y),
1033
+ reset: (...y) => W.current.reset(...y),
1034
+ goBack: (...y) => W.current.goBack(...y),
1035
+ popToTop: (...y) => W.current.popToTop(...y),
1036
+ popTo: (...y) => W.current.popTo(...y),
1037
+ setParams: (...y) => W.current.setParams(...y),
1038
+ setOptions: (...y) => W.current.setOptions(...y),
1039
+ close: (...y) => W.current.close(...y),
1040
+ setLoading: (...y) => W.current.setLoading(...y)
1041
+ }), []), ie = F(() => ({
1042
+ setLoading: (y, U) => Q.setScreenLoading("single", y, U),
1043
+ showLoading: (y) => Q.begin("single", y),
1044
+ hideLoading: (y) => Q.end("single", y)
1045
+ }), [Q]), C = F(() => ({ isFocused: !0, resultEvent: null, routeKey: "single", setFooter: be }), [be]), R = F(() => ({ routeKey: "single", registerDirtyGuard: x }), [x]);
1046
+ H(() => {
1047
+ P.current.publish({ canGoBack: !1, stack: [m], currentRoute: m });
1048
+ }, [m]);
1049
+ const de = k(!1);
1050
+ H(() => (h?.({ setLoading: X }), de.current || (de.current = !0, p?.({ route: I.current, stack: [I.current] })), () => {
1051
+ h?.(null);
1052
+ }), []);
1053
+ const ge = F(() => ({ ...j, ...m.options }), [j, m.options]), te = j.component, A = e.refs.header;
1054
+ return /* @__PURE__ */ i(tn.Provider, { value: A.current, children: /* @__PURE__ */ i(vn.Provider, { value: ne, children: /* @__PURE__ */ i(Bn.Provider, { value: T.current, children: /* @__PURE__ */ i(zn.Provider, { value: L.current, children: /* @__PURE__ */ i(Nn.Provider, { value: le, children: /* @__PURE__ */ i(rn.Provider, { value: ue, children: /* @__PURE__ */ i(on.Provider, { value: P.current, children: /* @__PURE__ */ i(De.Provider, { value: Q, children: /* @__PURE__ */ Ce($n, { store: e.stores.layout, screenOptions: ge.modalOptions, dialogRef: O, requestClose: z, exiting: w, children: [
1055
+ /* @__PURE__ */ i(In, { store: e.stores.layout, screen: ge, route: m, navigation: le, requestClose: z, translate: o, canGoBack: !1 }),
1056
+ /* @__PURE__ */ i("main", { className: "pmn-main", children: /* @__PURE__ */ i(sn.Provider, { value: m, children: /* @__PURE__ */ i(bn.Provider, { value: R, children: /* @__PURE__ */ i(Ve.Provider, { value: C, children: /* @__PURE__ */ i(De.Provider, { value: ie, children: /* @__PURE__ */ i(an.Provider, { value: Y.current, children: /* @__PURE__ */ i("div", { className: `pmn-body ${b.bodyClassName ?? ""}`, "data-modal-route-key": "single", tabIndex: -1, children: /* @__PURE__ */ i(Cn, { route: m, onError: l, children: /* @__PURE__ */ i(Ln, { fallback: b.lazyFallback ?? /* @__PURE__ */ i("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ i(zt, { Screen: te, route: m, navigation: le }) }) }) }) }) }) }) }) }) }),
1057
+ /* @__PURE__ */ i(Bt, { store: L.current, route: m, screen: ge, layoutStore: e.stores.layout, navigation: le, requestClose: z, translate: o, onError: l, loadingApi: Q }),
1058
+ /* @__PURE__ */ i(Ft, { store: Y.current, translate: o }),
1059
+ /* @__PURE__ */ i(jt, { store: T.current, dismiss: oe }),
1060
+ d && /* @__PURE__ */ Ce("div", { className: "pmn-error", role: "alert", children: [
1061
+ /* @__PURE__ */ i("span", { children: d.message || String(d) }),
1062
+ /* @__PURE__ */ i("button", { type: "button", onClick: u, children: "×" })
1063
+ ] })
1064
+ ] }) }) }) }) }) }) }) }) });
1065
+ }
1066
+ const $t = Ue(Rt), It = Ue(qt), Dt = Ue(function({ manager: n }) {
1067
+ const { active: t, options: r, exiting: o, error: g, translate: p } = Ee(n.hostStore.subscribe, n.hostStore.getSnapshot, n.hostStore.getSnapshot), h = t?.id, l = t?.runtime.bindings, d = F(() => (x, w) => {
1068
+ t?.runtime.alive.current && n.hostStore.getSnapshot().active?.id === h && n.reportError(x, w);
1069
+ }, [n, t, h]);
1070
+ if (!t) return null;
1071
+ const u = t.config.singlePage || Object.keys(t.config.screens ?? {}).length === 1 ? It : $t;
1072
+ return /* @__PURE__ */ i(kn.Provider, { value: t.runtime, children: /* @__PURE__ */ i(u, { runtime: t.runtime, config: t.config, initialScreen: t.screen, params: t.params, options: r, translate: p, notifyError: d, error: g, clearError: n.commands.clearError, exiting: o, ...l }, h) });
1073
+ }), Kt = ".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}@keyframes pmn-page-forward-in{0%{opacity:.18;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:.18;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}.pmn-page-enter{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.2,.8,.2,1);animation-fill-mode:both;will-change:transform,opacity}.pmn-page-forward{animation-name:pmn-page-forward-in}.pmn-page-back{animation-name:pmn-page-back-in}@media(prefers-reduced-motion:reduce){.pmn-page-enter{animation:none!important;will-change:auto}}.pmn-main{position:relative;isolation:isolate}.pmn-page-exit{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}.pmn-page-exit-forward{animation-name:pmn-page-forward-out}.pmn-page-exit-back{animation-name:pmn-page-back-out}@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}.pmn-main>.pmn-body{position:relative;width:100%;flex:1 0 100%;background:var(--pmn-body)}.pmn-page-forward,.pmn-page-back{z-index:2}@keyframes pmn-page-forward-in{0%{opacity:1;transform:translate3d(100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:1;transform:translate3d(-100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-forward-out{to{opacity:1;transform:translate3d(-100%,0,0)}}@keyframes pmn-page-back-out{to{opacity:1;transform:translate3d(100%,0,0)}}.pmn-lazy-loading{display:flex;min-height:80px;align-items:center;justify-content:center;color:var(--pmn-muted);font-size:14px}.pmn-place-top .pmn-dialog{max-height:min(calc(100dvh - var(--pmn-top-offset, var(--pmn-gap)) - var(--pmn-gap)),var(--pmn-max-height,100dvh))}.pmn-dialog.pmn-has-custom-background{isolation:isolate;--pmn-body:transparent}.pmn-custom-background-layer{position:absolute;inset:0;z-index:0;pointer-events:none}.pmn-dialog.pmn-has-custom-background>:not(.pmn-custom-background-layer){position:relative;z-index:1}.pmn-dialog.pmn-has-custom-background .pmn-main>.pmn-body{background:transparent}.pmn-overlay.pmn-fullscreen{padding:0!important;align-items:stretch;justify-content:stretch}.pmn-overlay.pmn-fullscreen .pmn-dialog{width:100%;max-width:100%;height:100%;max-height:100%;border-radius:0!important}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:100%;max-height:100%}.pmn-place-center .pmn-dialog{max-height:100%}.pmn-dialog{max-width:min(100%,var(--pmn-drag-width,var(--pmn-max-width,var(--pmn-width))));max-height:min(100%,var(--pmn-max-height,100dvh))}.pmn-dialog .pmn-resize-handle{position:absolute;z-index:5;top:0;bottom:0;width:10px;cursor:ew-resize;touch-action:none;-webkit-user-select:none;user-select:none}.pmn-resize-left{right:0}.pmn-resize-right{left:0}.pmn-resize-handle:hover,.pmn-resize-handle:focus-visible{background:var(--pmn-border)}@media(max-width:640px){.pmn-mobile-fullscreen .pmn-resize-handle{display:none}}.pmn-dialog{max-width:min(100%,var(--pmn-max-width,100%),var(--pmn-drag-width,var(--pmn-width)))}.pmn-overlay.pmn-fullscreen .pmn-dialog{max-width:100%}", Tn = "react-modal-navigation-styles", hn = /* @__PURE__ */ new WeakMap();
1074
+ function Ht() {
1075
+ Zn(() => {
1076
+ if (typeof document > "u") return;
1077
+ const e = document;
1078
+ let n = hn.get(e);
1079
+ if (!n) {
1080
+ let t = e.getElementById(Tn);
1081
+ const r = !t;
1082
+ t || (t = e.createElement("style"), t.id = Tn, t.setAttribute("data-react-modal-navigation", ""), t.textContent = Kt, e.head.appendChild(t)), n = { element: t, owned: r, count: 0 }, hn.set(e, n);
1083
+ }
1084
+ return n.count += 1, () => {
1085
+ n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), hn.delete(e));
1086
+ };
1087
+ }, []);
1088
+ }
1089
+ const Wt = Object.freeze({}), Gt = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
1090
+ function ir({ children: e, registry: n, defaultOptions: t = Wt, backgroundColor: r, theme: o, translate: g = Gt, onError: p, confirmDiscard: h }) {
1091
+ Ht();
1092
+ const l = { registry: n, defaultOptions: t, backgroundColor: r, theme: o, translate: g, onError: p, confirmDiscard: h }, [d] = xe(() => Nt(l, Tt));
1093
+ return Ie(() => (d.mount(), d.destroy), [d]), Ie(() => {
1094
+ d.configure(l);
1095
+ }, [d, n, t, r, o, g, p, h]), /* @__PURE__ */ i(wn.Provider, { value: d.commands, children: /* @__PURE__ */ i(xn.Provider, { value: d.statusStore, children: /* @__PURE__ */ Ce(An.Provider, { value: d.commands, children: [
1096
+ e,
1097
+ /* @__PURE__ */ i(Dt, { manager: d })
1098
+ ] }) }) });
850
1099
  }
851
- const ot = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), at = () => () => {
852
- }, hn = () => ot;
853
- function ft() {
854
- const e = oe(yn), n = oe(_e), r = oe(We), t = fe(r?.subscribe ?? at, r?.getSnapshot ?? hn, r?.getSnapshot ?? hn);
855
- if (!e) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
856
- const i = K(() => {
857
- const g = () => {
858
- if (!n) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
859
- return n;
1100
+ const _t = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), On = () => () => {
1101
+ }, en = () => _t;
1102
+ function cr({ subscribe: e = !0 } = {}) {
1103
+ const n = V(An), t = V(xn), r = Ee(e && t?.subscribe || On, e && t?.getSnapshot || en, e && t?.getSnapshot || en), o = F(() => n ? e ? { ...n, ...r } : n : null, [n, r, e]), g = V(rn), p = V(on), h = Ee(e && p?.subscribe || On, e && p?.getSnapshot || en, e && p?.getSnapshot || en);
1104
+ if (!o) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
1105
+ const l = F(() => {
1106
+ const d = () => {
1107
+ if (!g) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
1108
+ return g;
860
1109
  };
861
1110
  return {
862
- navigate: (...p) => g().navigate(...p),
863
- replace: (...p) => g().replace(...p),
864
- reset: (...p) => g().reset(...p),
865
- setParams: (...p) => g().setParams(...p),
866
- setOptions: (...p) => g().setOptions(...p),
867
- goBack: (...p) => g().goBack(...p),
868
- close: (...p) => g().close(...p),
869
- setLoading: (...p) => g().setLoading(...p),
870
- canGoBack: t.canGoBack,
871
- stack: t.stack,
872
- currentRoute: t.currentRoute
1111
+ navigateAsync: (...u) => d().navigateAsync(...u),
1112
+ navigate: (...u) => d().navigate(...u),
1113
+ replace: (...u) => d().replace(...u),
1114
+ reset: (...u) => d().reset(...u),
1115
+ setParams: (...u) => d().setParams(...u),
1116
+ setOptions: (...u) => d().setOptions(...u),
1117
+ goBack: (...u) => d().goBack(...u),
1118
+ close: (...u) => d().close(...u),
1119
+ setLoading: (...u) => d().setLoading(...u),
1120
+ ...e ? { canGoBack: h.canGoBack, stack: h.stack, currentRoute: h.currentRoute } : {}
873
1121
  };
874
- }, [n, t]);
875
- return K(() => ({ ...e, modal: e, navigation: i }), [e, i]);
1122
+ }, [g, h, e]);
1123
+ return F(() => ({ ...o, modal: o, navigation: l }), [o, l]);
876
1124
  }
877
- function st() {
878
- const e = oe(_e);
1125
+ function Ut() {
1126
+ const e = V(rn);
879
1127
  if (!e) throw new Error("useModalNavigationCommands requires an active modal screen");
880
1128
  return e;
881
1129
  }
882
- function it() {
883
- const e = oe(We);
884
- if (!e) throw new Error("useModalNavigationState requires an active modal screen");
885
- return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
1130
+ function Vt(e, n) {
1131
+ const t = V(on);
1132
+ if (!t) throw new Error("useModalNavigationState requires an active modal screen");
1133
+ return ke(t, e, n);
886
1134
  }
887
- function gt() {
888
- const e = st(), n = it();
889
- return K(() => ({ ...e, ...n }), [e, n]);
1135
+ function lr() {
1136
+ const e = Ut(), n = Vt();
1137
+ return F(() => ({ ...e, ...n }), [e, n]);
890
1138
  }
891
- function Ln() {
892
- const e = oe(je);
1139
+ function Un() {
1140
+ const e = V(Ve);
893
1141
  if (!e) throw new Error("useIsFocused must be called inside a modal screen");
894
1142
  return e.isFocused;
895
1143
  }
896
- function ht(e) {
897
- const n = Ln();
898
- Q(() => {
1144
+ function ur(e) {
1145
+ const n = Un();
1146
+ H(() => {
899
1147
  if (n)
900
1148
  return e();
901
1149
  }, [n, e]);
902
1150
  }
903
- function bt(e) {
904
- const n = oe(je);
1151
+ function dr(e) {
1152
+ const n = V(Ve);
905
1153
  if (!n) throw new Error("useNavigationResult requires an active modal screen");
906
- const r = l(e), t = l(null);
907
- Q(() => {
908
- r.current = e;
909
- }, [e]), Q(() => {
910
- !n.isFocused || !n.resultEvent || t.current !== n.resultEvent.id && (t.current = n.resultEvent.id, r.current(n.resultEvent.data));
1154
+ const t = k(e), r = k(null);
1155
+ H(() => {
1156
+ t.current = e;
1157
+ }, [e]), H(() => {
1158
+ !n.isFocused || !n.resultEvent || r.current !== n.resultEvent.id && (r.current = n.resultEvent.id, t.current(n.resultEvent.data));
911
1159
  }, [n.isFocused, n.resultEvent]);
912
1160
  }
913
- function yt(e = {}) {
914
- const n = oe(je);
1161
+ function mr(e = {}) {
1162
+ const n = V(Ve);
915
1163
  if (!n) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
916
- const { setFooter: r, routeKey: t } = n, i = l(e);
917
- i.current = e;
918
- const g = K(() => (...T) => i.current.done?.(...T), []), p = K(() => (...T) => (i.current.cancel ?? i.current.cancle)?.(...T), []), f = K(() => (...T) => i.current.renderFooter?.(...T), []), u = typeof e.done == "function", y = typeof (e.cancel ?? e.cancle) == "function", M = typeof e.renderFooter == "function", { showFooter: k, showFooterBorder: d, doneDisabled: m, doneText: a, cancelText: P, loadingText: N, footerClassName: D } = e, L = l({ source: null, normalized: void 0 }), G = Array.isArray(e.actions) ? e.actions : null, x = L.current.source;
919
- G === x || G && x && G.length === x.length && G.every((T, v) => {
920
- const j = x[v];
921
- return [.../* @__PURE__ */ new Set([...Object.keys(T), ...Object.keys(j)])].every((F) => F === "onClick" || Object.is(T[F], j[F]));
922
- }) || (L.current = {
923
- source: G?.map((T) => ({ ...T })) ?? null,
924
- normalized: G?.map((T, v) => ({
1164
+ const { setFooter: t, routeKey: r } = n, o = k(e);
1165
+ o.current = e;
1166
+ const g = F(() => (...T) => o.current.done?.(...T), []), p = F(() => (...T) => (o.current.cancel ?? o.current.cancle)?.(...T), []), h = F(() => (...T) => o.current.renderFooter?.(...T), []), l = typeof e.done == "function", d = typeof (e.cancel ?? e.cancle) == "function", u = typeof e.renderFooter == "function", { showFooter: x, showFooterBorder: w, doneDisabled: b, doneText: s, cancelText: m, loadingText: M, footerClassName: I } = e, j = k({ source: null, normalized: void 0 }), q = Array.isArray(e.actions) ? e.actions : null, O = j.current.source;
1167
+ q === O || q && O && q.length === O.length && q.every((T, $) => {
1168
+ const Q = O[$];
1169
+ return [.../* @__PURE__ */ new Set([...Object.keys(T), ...Object.keys(Q)])].every((ne) => ne === "onClick" || Object.is(T[ne], Q[ne]));
1170
+ }) || (j.current = {
1171
+ source: q?.map((T) => ({ ...T })) ?? null,
1172
+ normalized: q?.map((T, $) => ({
925
1173
  ...T,
926
- onClick: (...j) => (i.current.actions?.find((F) => F.key === T.key) ?? i.current.actions?.[v])?.onClick?.(...j)
1174
+ onClick: (...Q) => (o.current.actions?.find((ne) => ne.key === T.key) ?? o.current.actions?.[$])?.onClick?.(...Q)
927
1175
  }))
928
1176
  });
929
- const $ = L.current.normalized, H = K(() => ({
930
- showFooter: k,
931
- showFooterBorder: d,
932
- doneDisabled: m,
933
- doneText: a,
934
- cancelText: P,
935
- loadingText: N,
936
- footerClassName: D,
937
- ...$ !== void 0 ? { actions: $ } : {},
938
- ...u ? { done: g } : {},
939
- ...y ? { cancel: p } : {},
940
- ...M ? { renderFooter: f } : {}
941
- }), [k, d, m, a, P, N, D, $, u, y, M, g, p, f]);
942
- Q(() => {
943
- r(t, H);
944
- }, [t, r, H]), Q(() => () => r(t, null), [t, r]);
1177
+ const L = j.current.normalized, Y = F(() => ({
1178
+ showFooter: x,
1179
+ showFooterBorder: w,
1180
+ doneDisabled: b,
1181
+ doneText: s,
1182
+ cancelText: m,
1183
+ loadingText: M,
1184
+ footerClassName: I,
1185
+ ...L !== void 0 ? { actions: L } : {},
1186
+ ...l ? { done: g } : {},
1187
+ ...d ? { cancel: p } : {},
1188
+ ...u ? { renderFooter: h } : {}
1189
+ }), [x, w, b, s, m, M, I, L, l, d, u, g, p, h]);
1190
+ H(() => {
1191
+ t(r, Y);
1192
+ }, [r, t, Y]), H(() => () => t(r, null), [r, t]);
945
1193
  }
946
- function ct() {
947
- const e = oe(Me), n = oe(Ue);
1194
+ const Yt = (e) => e.visible;
1195
+ function Qt() {
1196
+ const e = V(De), n = V(an);
948
1197
  if (!e || !n) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
949
- const r = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
950
- return K(() => ({ ...e, isLoading: r.visible }), [e, r.visible]);
1198
+ const t = ke(n, Yt);
1199
+ return F(() => ({ ...e, isLoading: t }), [e, t]);
951
1200
  }
952
- function vt() {
953
- const e = oe(Me);
1201
+ function pr() {
1202
+ const e = V(De);
954
1203
  if (!e) throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");
955
1204
  return e;
956
1205
  }
957
- function xt() {
958
- const e = oe(Ue);
959
- if (!e) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
960
- return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
1206
+ function fr(e, n) {
1207
+ const t = V(an);
1208
+ if (!t) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
1209
+ return ke(t, e, n);
961
1210
  }
962
- function wt() {
963
- const e = ct(), n = Ln(), r = l(!0), t = l(!1), [i, g] = pe(!1), [p, f] = pe(null), u = l(e);
964
- return u.current = e, Q(() => (r.current = !0, () => {
965
- r.current = !1;
966
- }), []), { run: w(async (M, k = {}) => {
967
- if (t.current) return { status: "busy" };
968
- if (typeof M != "function") throw new TypeError("[react-modal-navigation] run requires a function");
969
- t.current = !0, r.current && (g(!0), f(null));
970
- const d = u.current.showLoading(k.loadingText);
1211
+ function gr() {
1212
+ const e = Qt(), n = Un(), t = k(!0), r = k(!1), [o, g] = xe(!1), [p, h] = xe(null), l = k(e);
1213
+ return l.current = e, H(() => (t.current = !0, () => {
1214
+ t.current = !1;
1215
+ }), []), { run: K(async (u, x = {}) => {
1216
+ if (r.current) return { status: "busy" };
1217
+ if (typeof u != "function") throw new TypeError("[react-modal-navigation] run requires a function");
1218
+ r.current = !0, t.current && (g(!0), h(null));
1219
+ const w = l.current.showLoading(x.loadingText);
971
1220
  try {
972
- const m = await M();
973
- return r.current && await k.onSuccess?.(m), { status: "success", value: m };
974
- } catch (m) {
975
- if (r.current) {
976
- f(m);
1221
+ const b = await u();
1222
+ return t.current && await x.onSuccess?.(b), { status: "success", value: b };
1223
+ } catch (b) {
1224
+ if (t.current) {
1225
+ h(b);
977
1226
  try {
978
- await k.onError?.(m);
979
- } catch (a) {
980
- console.error("[react-modal-navigation] onError failed", a);
1227
+ await x.onError?.(b);
1228
+ } catch (s) {
1229
+ console.error("[react-modal-navigation] onError failed", s);
981
1230
  }
982
1231
  }
983
- if (k.throwOnError) throw m;
984
- return { status: "error", error: m };
1232
+ if (x.throwOnError) throw b;
1233
+ return { status: "error", error: b };
985
1234
  } finally {
986
- d != null && u.current.hideLoading(d), t.current = !1, r.current && g(!1);
1235
+ w != null && l.current.hideLoading(w), r.current = !1, t.current && g(!1);
987
1236
  }
988
- }, []), pending: i, error: p, clearError: () => f(null), isFocused: n };
1237
+ }, []), pending: o, error: p, clearError: () => h(null), isFocused: n };
989
1238
  }
990
- function kt(e, n = {}) {
991
- const r = oe(tn);
992
- if (!r) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
993
- const t = l({ dirty: e, ...n });
994
- t.current = { dirty: e, ...n };
995
- const { routeKey: i, registerDirtyGuard: g } = r;
996
- Q(() => g(i, {
1239
+ function hr(e, n = {}) {
1240
+ const t = V(bn);
1241
+ if (!t) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
1242
+ const r = k({ dirty: e, ...n });
1243
+ r.current = { dirty: e, ...n };
1244
+ const { routeKey: o, registerDirtyGuard: g } = t;
1245
+ H(() => g(o, {
997
1246
  get dirty() {
998
- return !!t.current.dirty;
1247
+ return !!r.current.dirty;
999
1248
  },
1000
1249
  get message() {
1001
- return t.current.message;
1250
+ return r.current.message;
1002
1251
  },
1003
1252
  get onBeforeDiscard() {
1004
- return t.current.onBeforeDiscard;
1253
+ return r.current.onBeforeDiscard;
1005
1254
  }
1006
- }), [i, g]);
1255
+ }), [o, g]);
1007
1256
  }
1008
- const St = () => {
1009
- const e = oe(rn);
1257
+ const yr = () => {
1258
+ const e = V(vn);
1010
1259
  if (!e) throw new Error("[react-modal-navigation] useToast requires an active modal");
1011
1260
  return e;
1012
1261
  };
1013
- function lt() {
1014
- const e = oe(on);
1262
+ function Zt() {
1263
+ const e = V(sn);
1015
1264
  if (!e) throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");
1016
1265
  return e;
1017
1266
  }
1018
- function Et() {
1019
- return lt().params;
1267
+ function br() {
1268
+ return Zt().params;
1269
+ }
1270
+ function Xt() {
1271
+ const e = V(wn);
1272
+ if (!e) throw new Error("[react-modal-navigation] ModalProvider required");
1273
+ return e;
1274
+ }
1275
+ const Jt = (e) => e;
1276
+ function er(e = Jt, n = Object.is) {
1277
+ const t = V(xn);
1278
+ if (!t) throw new Error("[react-modal-navigation] ModalProvider required");
1279
+ return ke(t, e, n);
1280
+ }
1281
+ const nr = (e) => e.isFullscreen;
1282
+ function vr() {
1283
+ const { setFullscreen: e, toggleFullscreen: n } = Xt();
1284
+ return { isFullscreen: er(nr), setFullscreen: e, toggleFullscreen: n };
1285
+ }
1286
+ function wr(e = {}) {
1287
+ const n = V(tn), t = V(sn);
1288
+ if (!n || !t) throw new Error("[react-modal-navigation] useModalHeader requires a modal screen");
1289
+ const r = k(e);
1290
+ r.current = e, H(() => {
1291
+ n.set(t.key, r.current);
1292
+ }), H(() => () => n.set(t.key, null), [n, t.key]);
1293
+ }
1294
+ function xr(e, n) {
1295
+ const t = V(kn);
1296
+ if (!t) throw new Error("[react-modal-navigation] useModalLayout requires an active modal");
1297
+ return ke(t.stores.layout, e, n);
1020
1298
  }
1021
1299
  export {
1022
- Yn as ModalNavigator,
1023
- pt as ModalProvider,
1024
- ht as useFocusEffect,
1025
- Ln as useIsFocused,
1026
- ft as useModal,
1027
- yt as useModalFooter,
1028
- ct as useModalLoading,
1029
- vt as useModalLoadingCommands,
1030
- xt as useModalLoadingState,
1031
- gt as useModalNavigation,
1032
- st as useModalNavigationCommands,
1033
- it as useModalNavigationState,
1034
- Et as useModalParams,
1035
- lt as useModalRoute,
1036
- wt as useModalTask,
1037
- kt as useModalUnsavedChanges,
1038
- bt as useNavigationResult,
1039
- St as useToast
1300
+ Rt as ModalNavigator,
1301
+ ir as ModalProvider,
1302
+ ar as defineModal,
1303
+ sr as lazyModal,
1304
+ ze as shallowEqual,
1305
+ ur as useFocusEffect,
1306
+ Un as useIsFocused,
1307
+ cr as useModal,
1308
+ Xt as useModalCommands,
1309
+ mr as useModalFooter,
1310
+ vr as useModalFullscreen,
1311
+ wr as useModalHeader,
1312
+ xr as useModalLayout,
1313
+ Qt as useModalLoading,
1314
+ pr as useModalLoadingCommands,
1315
+ fr as useModalLoadingState,
1316
+ lr as useModalNavigation,
1317
+ Ut as useModalNavigationCommands,
1318
+ Vt as useModalNavigationState,
1319
+ br as useModalParams,
1320
+ Zt as useModalRoute,
1321
+ er as useModalStatus,
1322
+ gr as useModalTask,
1323
+ hr as useModalUnsavedChanges,
1324
+ dr as useNavigationResult,
1325
+ yr as useToast
1040
1326
  };