react-modal-navigation 1.1.1 → 1.1.3

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,104 +1,104 @@
1
- import { jsx as m, jsxs as ae } from "react/jsx-runtime";
2
- import qe, { createContext as he, useRef as u, useState as W, useEffect as O, useReducer as Ae, useCallback as d, useMemo as V, useLayoutEffect as De, useInsertionEffect as $e, useContext as ee } from "react";
3
- import { createPortal as Oe } from "react-dom";
4
- const Te = he(null), Re = he(null), be = he(null), Me = he(null), Be = he(null);
5
- let je = 0;
6
- const Ee = (e, n) => ({ key: `modal-route-${++je}`, name: e, params: n ?? {} }), Pe = (e, n) => [Ee(e, n)];
7
- function Ie(e, n) {
1
+ import { jsx as f, jsxs as re } from "react/jsx-runtime";
2
+ import De, { createContext as pe, useRef as d, useState as Q, useEffect as j, useReducer as $e, useCallback as p, useMemo as V, useLayoutEffect as Oe, useInsertionEffect as je, useContext as Z } from "react";
3
+ import { createPortal as Ie } from "react-dom";
4
+ const Pe = pe(null), Ce = pe(null), xe = pe(null), Se = pe(null), Fe = pe(null);
5
+ let He = 0;
6
+ const Me = (e, n) => ({ key: `modal-route-${++He}`, name: e, params: n ?? {} }), qe = (e, n) => [Me(e, n)];
7
+ function Ge(e, n) {
8
8
  switch (n.type) {
9
9
  case "RESET":
10
- return Pe(n.name, n.params);
10
+ return qe(n.name, n.params);
11
11
  case "NAVIGATE": {
12
- const r = e.findIndex((s) => s.name === n.name);
13
- return r < 0 ? [...e, Ee(n.name, n.params)] : e.slice(0, r + 1).map((s, c) => c === r ? { ...s, params: n.params ?? {} } : s);
12
+ const r = e.findIndex((a) => a.name === n.name);
13
+ return r < 0 ? [...e, Me(n.name, n.params)] : e.slice(0, r + 1).map((a, s) => s === r ? { ...a, params: n.params ?? {} } : a);
14
14
  }
15
15
  case "SET_PARAMS":
16
- return e.map((r, s) => s === e.length - 1 ? { ...r, params: { ...r.params ?? {}, ...n.params ?? {} } } : r);
16
+ return e.map((r, a) => a === e.length - 1 ? { ...r, params: { ...r.params ?? {}, ...n.params ?? {} } } : r);
17
17
  case "BACK":
18
18
  return e.length > 1 ? e.slice(0, -1) : e;
19
19
  case "REPLACE":
20
- return e.length ? [...e.slice(0, -1), Ee(n.name, n.params)] : e;
20
+ return e.length ? [...e.slice(0, -1), Me(n.name, n.params)] : e;
21
21
  default:
22
22
  return e;
23
23
  }
24
24
  }
25
- const Se = () => {
25
+ const Ne = () => {
26
26
  if (typeof document > "u") return "light";
27
27
  const e = document.documentElement, n = document.body;
28
28
  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";
29
29
  };
30
- let fe = 0;
31
- const oe = [];
32
- let we = null;
33
- function He() {
34
- if (fe++, fe === 1) {
35
- const n = document.documentElement, r = document.body, s = { html: n.style.overflow, body: r.style.overflow, padding: r.style.paddingRight, width: r.style.getPropertyValue("--modal-scrollbar-width") }, c = Math.max(0, window.innerWidth - n.clientWidth), g = parseFloat(getComputedStyle(r).paddingRight) || 0;
36
- c && (r.style.paddingRight = `${g + c}px`), r.style.setProperty("--modal-scrollbar-width", `${c}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", we = () => {
37
- n.style.overflow = s.html, r.style.overflow = s.body, r.style.paddingRight = s.padding, s.width ? r.style.setProperty("--modal-scrollbar-width", s.width) : r.style.removeProperty("--modal-scrollbar-width");
30
+ let me = 0;
31
+ const te = [];
32
+ let Ee = null;
33
+ function ze() {
34
+ if (me++, me === 1) {
35
+ const n = document.documentElement, r = document.body, a = { html: n.style.overflow, body: r.style.overflow, padding: r.style.paddingRight, width: r.style.getPropertyValue("--modal-scrollbar-width") }, s = Math.max(0, window.innerWidth - n.clientWidth), x = parseFloat(getComputedStyle(r).paddingRight) || 0;
36
+ s && (r.style.paddingRight = `${x + s}px`), r.style.setProperty("--modal-scrollbar-width", `${s}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", Ee = () => {
37
+ n.style.overflow = a.html, r.style.overflow = a.body, r.style.paddingRight = a.padding, a.width ? r.style.setProperty("--modal-scrollbar-width", a.width) : r.style.removeProperty("--modal-scrollbar-width");
38
38
  };
39
39
  }
40
40
  let e = !1;
41
41
  return () => {
42
- e || (e = !0, fe = Math.max(0, fe - 1), fe || (we?.(), we = null));
42
+ e || (e = !0, me = Math.max(0, me - 1), me || (Ee?.(), Ee = null));
43
43
  };
44
44
  }
45
- const Ge = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', ze = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
46
- function Ke({ dialogRef: e, options: n, requestClose: r, children: s, exiting: c = !1 }) {
47
- const g = u(null), v = u(null), w = u(r);
45
+ const Ke = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', Ue = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
46
+ function We({ dialogRef: e, options: n, requestClose: r, children: a, exiting: s = !1 }) {
47
+ const x = d(null), y = d(null), w = d(r);
48
48
  w.current = r;
49
- const f = u(n.closeOnEsc);
50
- f.current = n.closeOnEsc;
51
- const [N, E] = W(Se), y = n.theme === "light" || n.theme === "dark" ? n.theme : N;
52
- O(() => {
49
+ const m = d(n.closeOnEsc);
50
+ m.current = n.closeOnEsc;
51
+ const [R, k] = Q(Ne), v = n.theme === "light" || n.theme === "dark" ? n.theme : R;
52
+ j(() => {
53
53
  if (n.theme === "light" || n.theme === "dark") return;
54
- const P = () => E(Se()), K = new MutationObserver(P);
55
- for (const T of [document.documentElement, document.body]) K.observe(T, { attributes: !0, attributeFilter: ["class", "data-theme"] });
56
- const k = window.matchMedia?.("(prefers-color-scheme: dark)");
57
- return k?.addEventListener?.("change", P), P(), () => {
58
- K.disconnect(), k?.removeEventListener?.("change", P);
54
+ const T = () => k(Ne()), H = new MutationObserver(T);
55
+ for (const C of [document.documentElement, document.body]) H.observe(C, { attributes: !0, attributeFilter: ["class", "data-theme"] });
56
+ const Y = window.matchMedia?.("(prefers-color-scheme: dark)");
57
+ return Y?.addEventListener?.("change", T), T(), () => {
58
+ H.disconnect(), Y?.removeEventListener?.("change", T);
59
59
  };
60
- }, [n.theme]), O(() => {
61
- v.current = document.activeElement;
62
- const P = He(), K = g.current;
63
- oe.push(K), e.current?.focus({ preventScroll: !0 });
64
- const k = (C) => {
65
- const x = e.current;
66
- if (!x || oe.at(-1) !== K) return;
67
- if (C.key === "Escape" && f.current !== !1) {
68
- C.preventDefault(), w.current("escape");
60
+ }, [n.theme]), j(() => {
61
+ y.current = document.activeElement;
62
+ const T = ze(), H = x.current;
63
+ te.push(H), e.current?.focus({ preventScroll: !0 });
64
+ const Y = (g) => {
65
+ const E = e.current;
66
+ if (!E || te.at(-1) !== H) return;
67
+ if (g.key === "Escape" && m.current !== !1) {
68
+ g.preventDefault(), w.current("escape");
69
69
  return;
70
70
  }
71
- if (C.key !== "Tab") return;
72
- const B = [...x.querySelectorAll(Ge)].filter(ze);
73
- if (!B.length) {
74
- C.preventDefault(), x.focus();
71
+ if (g.key !== "Tab") return;
72
+ const F = [...E.querySelectorAll(Ke)].filter(Ue);
73
+ if (!F.length) {
74
+ g.preventDefault(), E.focus();
75
75
  return;
76
76
  }
77
- const G = B[0], S = B.at(-1);
78
- x.contains(document.activeElement) ? C.shiftKey && (document.activeElement === G || document.activeElement === x) ? (C.preventDefault(), S.focus()) : !C.shiftKey && (document.activeElement === S || document.activeElement === x) && (C.preventDefault(), G.focus()) : (C.preventDefault(), (C.shiftKey ? S : G).focus());
79
- }, T = (C) => {
80
- oe.at(-1) === K && e.current && !e.current.contains(C.target) && e.current.focus({ preventScroll: !0 });
77
+ const G = F[0], N = F.at(-1);
78
+ E.contains(document.activeElement) ? g.shiftKey && (document.activeElement === G || document.activeElement === E) ? (g.preventDefault(), N.focus()) : !g.shiftKey && (document.activeElement === N || document.activeElement === E) && (g.preventDefault(), G.focus()) : (g.preventDefault(), (g.shiftKey ? N : G).focus());
79
+ }, C = (g) => {
80
+ te.at(-1) === H && e.current && !e.current.contains(g.target) && e.current.focus({ preventScroll: !0 });
81
81
  };
82
- return document.addEventListener("keydown", k), document.addEventListener("focusin", T), () => {
83
- document.removeEventListener("keydown", k), document.removeEventListener("focusin", T);
84
- const C = oe.at(-1) === K, x = oe.indexOf(K);
85
- if (x !== -1 && oe.splice(x, 1), P(), C) {
86
- const B = v.current;
87
- B?.isConnected && !B.closest("[inert], [hidden]") ? B.focus?.({ preventScroll: !0 }) : oe.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
82
+ return document.addEventListener("keydown", Y), document.addEventListener("focusin", C), () => {
83
+ document.removeEventListener("keydown", Y), document.removeEventListener("focusin", C);
84
+ const g = te.at(-1) === H, E = te.indexOf(H);
85
+ if (E !== -1 && te.splice(E, 1), T(), g) {
86
+ const F = y.current;
87
+ F?.isConnected && !F.closest("[inert], [hidden]") ? F.focus?.({ preventScroll: !0 }) : te.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
88
88
  }
89
89
  };
90
90
  }, [e]);
91
- const p = n.backgroundColor ?? n.backgroudColor, h = typeof p == "string" ? p : p?.[y], b = typeof h == "string" && /^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(h.trim()) ? h : null, D = { sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }, F = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", q = (P) => typeof P == "number" ? `${P}px` : P, A = q(n.width ?? D[n.size] ?? 460), R = q(n.height), j = q(n.maxHeight), M = q(n.maxWidth), I = Number(n.viewportGap ?? 5), H = Number.isFinite(I) ? Math.max(0, I) : 5, z = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
92
- return Oe(/* @__PURE__ */ m(
91
+ const L = n.backgroundColor ?? n.backgroudColor, l = typeof L == "string" ? L : L?.[v], h = typeof l == "string" && /^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(l.trim()) ? l : null, I = { sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }, B = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", q = (T) => typeof T == "number" ? `${T}px` : T, A = q(n.width ?? I[n.size] ?? 460), D = q(n.height), M = q(n.maxHeight), P = q(n.maxWidth), $ = Number(n.viewportGap ?? 5), K = Number.isFinite($) ? Math.max(0, $) : 5, O = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
92
+ return Ie(/* @__PURE__ */ f(
93
93
  "div",
94
94
  {
95
- ref: g,
96
- className: `pmn-overlay ${c ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${F} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
97
- style: { padding: H, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
98
- onMouseDown: (P) => {
99
- P.target === P.currentTarget && n.closeOnOverlay === !0 && w.current("overlay");
95
+ ref: x,
96
+ className: `pmn-overlay ${s ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${B} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
97
+ style: { padding: K, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
98
+ onMouseDown: (T) => {
99
+ T.target === T.currentTarget && n.closeOnOverlay === !0 && w.current("overlay");
100
100
  },
101
- children: /* @__PURE__ */ m(
101
+ children: /* @__PURE__ */ f(
102
102
  "section",
103
103
  {
104
104
  ref: e,
@@ -106,62 +106,62 @@ function Ke({ dialogRef: e, options: n, requestClose: r, children: s, exiting: c
106
106
  role: "dialog",
107
107
  "aria-modal": "true",
108
108
  "aria-label": n.ariaLabel ?? "Dialog",
109
- "data-modal-theme": y,
110
- className: `pmn-dialog ${y === "dark" ? "dark" : ""} ${!b && h ? h : ""} ${n.className ?? ""}`,
111
- style: { "--pmn-width": A, "--pmn-gap": `${H}px`, ...R !== void 0 ? { "--pmn-height": R } : {}, ...j !== void 0 ? { "--pmn-max-height": j } : {}, ...M !== void 0 ? { "--pmn-max-width": M } : {}, borderRadius: z, ...b ? { backgroundColor: b } : {} },
112
- children: s
109
+ "data-modal-theme": v,
110
+ className: `pmn-dialog ${v === "dark" ? "dark" : ""} ${!h && l ? l : ""} ${n.className ?? ""}`,
111
+ style: { "--pmn-width": A, "--pmn-gap": `${K}px`, ...D !== void 0 ? { "--pmn-height": D } : {}, ...M !== void 0 ? { "--pmn-max-height": M } : {}, ...P !== void 0 ? { "--pmn-max-width": P } : {}, borderRadius: O, ...h ? { backgroundColor: h } : {} },
112
+ children: a
113
113
  }
114
114
  )
115
115
  }
116
116
  ), document.body);
117
117
  }
118
- function Le({ back: e }) {
119
- return /* @__PURE__ */ m("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ m("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ m("path", { d: "M18 6 6 18M6 6l12 12" }) });
118
+ function Te({ back: e }) {
119
+ return /* @__PURE__ */ f("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ f("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ f("path", { d: "M18 6 6 18M6 6l12 12" }) });
120
120
  }
121
- function Ue({ options: e, screen: n, route: r, navigation: s, requestClose: c, translate: g }) {
121
+ function Ye({ options: e, screen: n, route: r, navigation: a, requestClose: s, translate: x }) {
122
122
  if (e.showHeader === !1) return null;
123
- const v = g ?? ((p) => p), w = n.showTitle ?? e.showTitle ?? !0, f = typeof n.title == "function" ? n.title({ t: v, route: r, navigation: s }) : n.title ?? r.name, N = { route: r, navigation: s, close: c, canGoBack: s.canGoBack, title: f, t: v }, E = n.renderHeader ?? e.renderHeader;
124
- if (E) return E(N);
125
- const y = n.renderHeaderRight ?? e.renderHeaderRight;
126
- return /* @__PURE__ */ ae("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
127
- e.showBackButton !== !1 && s.canGoBack && /* @__PURE__ */ m("button", { type: "button", className: "pmn-icon-button", "aria-label": v("modal.back"), onClick: () => s.goBack(), children: /* @__PURE__ */ m(Le, { back: !0 }) }),
128
- w ? /* @__PURE__ */ m("h2", { children: f }) : /* @__PURE__ */ m("div", { className: "pmn-header-spacer" }),
129
- y?.(N),
130
- e.showCloseButton !== !1 && /* @__PURE__ */ m("button", { type: "button", className: "pmn-icon-button", "aria-label": v("modal.close"), onClick: () => c("header"), children: /* @__PURE__ */ m(Le, {}) })
123
+ const y = x ?? ((L) => L), w = n.showTitle ?? e.showTitle ?? !0, m = typeof n.title == "function" ? n.title({ t: y, route: r, navigation: a }) : n.title ?? r.name, R = { route: r, navigation: a, close: s, canGoBack: a.canGoBack, title: m, t: y }, k = n.renderHeader ?? e.renderHeader;
124
+ if (k) return k(R);
125
+ const v = n.renderHeaderRight ?? e.renderHeaderRight;
126
+ return /* @__PURE__ */ re("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
127
+ e.showBackButton !== !1 && a.canGoBack && /* @__PURE__ */ f("button", { type: "button", className: "pmn-icon-button", "aria-label": y("modal.back"), onClick: () => a.goBack(), children: /* @__PURE__ */ f(Te, { back: !0 }) }),
128
+ w ? /* @__PURE__ */ f("h2", { children: m }) : /* @__PURE__ */ f("div", { className: "pmn-header-spacer" }),
129
+ v?.(R),
130
+ e.showCloseButton !== !1 && /* @__PURE__ */ f("button", { type: "button", className: "pmn-icon-button", "aria-label": y("modal.close"), onClick: () => s("header"), children: /* @__PURE__ */ f(Te, {}) })
131
131
  ] });
132
132
  }
133
- function We({ screen: e, options: n, override: r, route: s, navigation: c, requestClose: g, translate: v, onError: w }) {
134
- const [f, N] = W(!1), E = v ?? ((M) => M), y = { ...n, ...e, ...r }, { showFooter: p, renderFooter: h, done: b, cancel: D, cancle: F } = y, q = D ?? F, A = { route: s, navigation: c, close: g, t: E };
135
- if (p === !1) return null;
136
- const R = `pmn-footer ${y.showFooterBorder ? "pmn-border-top" : ""} ${y.footerClassName ?? ""}`;
137
- if (typeof h == "function") return /* @__PURE__ */ m("footer", { className: R, children: h({ ...A, pending: f }) });
138
- if (typeof b != "function" && typeof q != "function") return null;
139
- const j = async (M) => {
140
- if (!(f || typeof M != "function")) {
141
- N(!0);
133
+ function Qe({ screen: e, options: n, override: r, route: a, navigation: s, requestClose: x, translate: y, onError: w }) {
134
+ const [m, R] = Q(!1), k = y ?? ((P) => P), v = { ...n, ...e, ...r }, { showFooter: L, renderFooter: l, done: h, cancel: I, cancle: B } = v, q = I ?? B, A = { route: a, navigation: s, close: x, t: k };
135
+ if (L === !1) return null;
136
+ const D = `pmn-footer ${v.showFooterBorder ? "pmn-border-top" : ""} ${v.footerClassName ?? ""}`;
137
+ if (typeof l == "function") return /* @__PURE__ */ f("footer", { className: D, children: l({ ...A, pending: m }) });
138
+ if (typeof h != "function" && typeof q != "function") return null;
139
+ const M = async (P) => {
140
+ if (!(m || typeof P != "function")) {
141
+ R(!0);
142
142
  try {
143
- await M(A);
144
- } catch (I) {
145
- w?.(I, { phase: "footer", route: s });
143
+ await P(A);
144
+ } catch ($) {
145
+ w?.($, { phase: "footer", route: a });
146
146
  } finally {
147
- N(!1);
147
+ R(!1);
148
148
  }
149
149
  }
150
150
  };
151
- return /* @__PURE__ */ ae("footer", { className: R, children: [
152
- typeof q == "function" && /* @__PURE__ */ m("button", { type: "button", disabled: f, onClick: () => j(q), className: "pmn-button pmn-button-secondary", children: y.cancelText ?? E("modal.cancel") }),
153
- typeof b == "function" && /* @__PURE__ */ m("button", { type: "button", disabled: f || y.doneDisabled === !0, onClick: () => j(b), className: "pmn-button pmn-button-primary", children: f ? y.loadingText ?? E("modal.processing") : y.doneText ?? E("modal.done") })
151
+ return /* @__PURE__ */ re("footer", { className: D, children: [
152
+ typeof q == "function" && /* @__PURE__ */ f("button", { type: "button", disabled: m, onClick: () => M(q), className: "pmn-button pmn-button-secondary", children: v.cancelText ?? k("modal.cancel") }),
153
+ typeof h == "function" && /* @__PURE__ */ f("button", { type: "button", disabled: m || v.doneDisabled === !0, onClick: () => M(h), className: "pmn-button pmn-button-primary", children: m ? v.loadingText ?? k("modal.processing") : v.doneText ?? k("modal.done") })
154
154
  ] });
155
155
  }
156
- function Ye({ loading: e, translate: n }) {
156
+ function Ve({ loading: e, translate: n }) {
157
157
  if (!e.visible) return null;
158
- const s = (n ?? ((g) => g))("modal.loading"), c = e.text ?? (s === "modal.loading" ? "加载中..." : s);
159
- return /* @__PURE__ */ m("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ ae("div", { className: "pmn-loading-card", children: [
160
- /* @__PURE__ */ m("span", { className: "pmn-spinner", "aria-hidden": "true" }),
161
- /* @__PURE__ */ m("span", { children: c })
158
+ const a = (n ?? ((x) => x))("modal.loading"), s = e.text ?? (a === "modal.loading" ? "加载中..." : a);
159
+ return /* @__PURE__ */ f("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ re("div", { className: "pmn-loading-card", children: [
160
+ /* @__PURE__ */ f("span", { className: "pmn-spinner", "aria-hidden": "true" }),
161
+ /* @__PURE__ */ f("span", { children: s })
162
162
  ] }) });
163
163
  }
164
- class Qe extends qe.Component {
164
+ class _e extends De.Component {
165
165
  state = { error: null };
166
166
  static getDerivedStateFromError(n) {
167
167
  return { error: n };
@@ -173,340 +173,344 @@ class Qe extends qe.Component {
173
173
  n.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
174
174
  }
175
175
  render() {
176
- return this.state.error ? /* @__PURE__ */ ae("div", { role: "alert", className: "pmn-error-screen", children: [
177
- /* @__PURE__ */ m("strong", { children: "页面加载失败" }),
178
- /* @__PURE__ */ m("p", { children: this.state.error.message }),
179
- /* @__PURE__ */ m("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => this.setState({ error: null }), children: "重试" })
176
+ return this.state.error ? /* @__PURE__ */ re("div", { role: "alert", className: "pmn-error-screen", children: [
177
+ /* @__PURE__ */ f("strong", { children: "页面加载失败" }),
178
+ /* @__PURE__ */ f("p", { children: this.state.error.message }),
179
+ /* @__PURE__ */ f("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => this.setState({ error: null }), children: "重试" })
180
180
  ] }) : this.props.children;
181
181
  }
182
182
  }
183
- function Ve({ route: e, screen: n, navigation: r, focused: s, resultEvent: c, setFooter: g, loadingApi: v, bodyClassName: w, notifyError: f, registerDirtyGuard: N }) {
184
- const E = n.component, y = V(() => ({ isFocused: s, resultEvent: c, routeKey: e.key, setFooter: g }), [s, c, e.key, g]), p = V(() => ({
185
- isLoading: s && v.isLoading,
186
- setLoading: (h, b) => v.setScreenLoading(e.key, h, b),
187
- showLoading: (h) => v.begin(e.key, h),
188
- hideLoading: (h) => v.end(e.key, h)
189
- }), [s, v, e.key]);
190
- return /* @__PURE__ */ m(Be.Provider, { value: { routeKey: e.key, registerDirtyGuard: N }, children: /* @__PURE__ */ m(be.Provider, { value: y, children: /* @__PURE__ */ m(Me.Provider, { value: p, children: /* @__PURE__ */ m("div", { hidden: !s, inert: !s, "data-modal-route-key": e.key, tabIndex: -1, className: `pmn-body ${w ?? ""}`, children: /* @__PURE__ */ m(Qe, { route: e, onError: f, children: /* @__PURE__ */ m(E, { route: e, navigation: r }) }) }) }) }) });
183
+ function Je({ route: e, screen: n, navigation: r, focused: a, resultEvent: s, setFooter: x, loadingApi: y, bodyClassName: w, notifyError: m, registerDirtyGuard: R }) {
184
+ const k = n.component, v = V(() => ({ isFocused: a, resultEvent: s, routeKey: e.key, setFooter: x }), [a, s, e.key, x]), L = V(() => ({
185
+ isLoading: a && y.isLoading,
186
+ setLoading: (l, h) => y.setScreenLoading(e.key, l, h),
187
+ showLoading: (l) => y.begin(e.key, l),
188
+ hideLoading: (l) => y.end(e.key, l)
189
+ }), [a, y, e.key]);
190
+ return /* @__PURE__ */ f(Fe.Provider, { value: { routeKey: e.key, registerDirtyGuard: R }, children: /* @__PURE__ */ f(xe.Provider, { value: v, children: /* @__PURE__ */ f(Se.Provider, { value: L, children: /* @__PURE__ */ f("div", { hidden: !a, inert: !a, "data-modal-route-key": e.key, tabIndex: -1, className: `pmn-body ${w ?? ""}`, children: /* @__PURE__ */ f(_e, { route: e, onError: m, children: /* @__PURE__ */ f(k, { route: e, navigation: r }) }) }) }) }) });
191
191
  }
192
- function _e({ config: e, params: n, options: r, translate: s, onRequestClose: c, onOpened: g, registerLoading: v, notifyError: w, error: f, clearError: N, registerDirtyGuard: E, exiting: y = !1 }) {
193
- const [p, h] = Ae(Ie, null, () => Pe(e.initialRoute, n)), [b, D] = W({}), [F, q] = W({}), [, A] = W(0), R = u(/* @__PURE__ */ new Map()), j = u(0), M = u(/* @__PURE__ */ new Map()), I = u(null), H = u(null), z = u(!1), P = u(!1), K = u(0), k = p.at(-1), T = k.key, C = u(T);
194
- C.current = T;
195
- const x = e.screens, B = d(() => A((t) => t + 1), []), G = d((t, o) => {
196
- if (t !== "global" && C.current !== t) return null;
197
- const l = ++j.current;
198
- return R.current.set(l, { owner: t, text: o }), B(), l;
199
- }, [B]), S = d((t, o) => {
200
- if (o != null)
201
- R.current.get(o)?.owner === t && R.current.delete(o);
192
+ function Xe({ config: e, initialScreen: n, params: r, options: a, translate: s, onRequestClose: x, onOpened: y, registerLoading: w, notifyError: m, error: R, clearError: k, registerDirtyGuard: v, exiting: L = !1 }) {
193
+ const [l, h] = $e(Ge, null, () => qe(n ?? e.initialRoute, r)), [I, B] = Q({}), [q, A] = Q({}), [, D] = Q(0), M = d(/* @__PURE__ */ new Map()), P = d(0), $ = d(/* @__PURE__ */ new Map()), K = d(null), O = d(null), T = d(!1), H = d(!1), Y = d(0), C = l.at(-1), g = C.key, E = d(g);
194
+ E.current = g;
195
+ const F = e.screens, G = p(() => D((t) => t + 1), []), N = p((t, i) => {
196
+ if (t !== "global" && E.current !== t) return null;
197
+ const u = ++P.current;
198
+ return M.current.set(u, { owner: t, text: i }), G(), u;
199
+ }, [G]), U = p((t, i) => {
200
+ if (i != null)
201
+ M.current.get(i)?.owner === t && M.current.delete(i);
202
202
  else
203
- for (const [l, L] of R.current) L.owner === t && R.current.delete(l);
204
- B();
205
- }, [B]), U = d((t, o) => {
206
- t ? (S("global"), G("global", o)) : S("global");
207
- }, [G, S]), Y = d((t, o, l) => {
208
- o ? (S(t), G(t, l)) : S(t);
209
- }, [G, S]), ne = [...R.current.values()], J = { visible: ne.length > 0, text: ne.at(-1)?.text ?? null, count: ne.length }, Q = u(J);
210
- Q.current = J;
211
- const X = V(() => ({ isLoading: J.visible, setLoading: U, setScreenLoading: Y, begin: G, end: S }), [J.visible, U, Y, G, S]), ie = u(v);
212
- ie.current = v, O(() => (ie.current?.({ setLoading: U }), () => ie.current?.(null)), [U]);
213
- const ge = d((t, o) => q((l) => {
214
- if (o === null) {
215
- if (!(t in l)) return l;
216
- const L = { ...l };
217
- return delete L[t], L;
203
+ for (const [u, S] of M.current) S.owner === t && M.current.delete(u);
204
+ G();
205
+ }, [G]), z = p((t, i) => {
206
+ t ? (U("global"), N("global", i)) : U("global");
207
+ }, [N, U]), oe = p((t, i, u) => {
208
+ i ? (U(t), N(t, u)) : U(t);
209
+ }, [N, U]), ae = [...M.current.values()], W = { visible: ae.length > 0, text: ae.at(-1)?.text ?? null, count: ae.length }, J = d(W);
210
+ J.current = W;
211
+ const fe = V(() => ({ isLoading: W.visible, setLoading: z, setScreenLoading: oe, begin: N, end: U }), [W.visible, z, oe, N, U]), se = d(w);
212
+ se.current = w, j(() => (se.current?.({ setLoading: z }), () => se.current?.(null)), [z]);
213
+ const he = p((t, i) => A((u) => {
214
+ if (i === null) {
215
+ if (!(t in u)) return u;
216
+ const S = { ...u };
217
+ return delete S[t], S;
218
218
  }
219
- return l[t] === o ? l : { ...l, [t]: o };
220
- }), []), te = d(() => {
219
+ return u[t] === i ? u : { ...u, [t]: i };
220
+ }), []), ee = p(() => {
221
221
  const t = document.activeElement;
222
- if (!(t instanceof HTMLElement) || !I.current?.contains(t)) return;
223
- const o = t.closest("[data-modal-route-key]");
224
- o && M.current.set(o.dataset.modalRouteKey, t), I.current.focus({ preventScroll: !0 });
225
- }, []), ce = d((t) => {
226
- if (!Object.prototype.hasOwnProperty.call(x, t)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${t}`);
227
- }, [x]), Z = d((t, o) => {
222
+ if (!(t instanceof HTMLElement) || !K.current?.contains(t)) return;
223
+ const i = t.closest("[data-modal-route-key]");
224
+ i && $.current.set(i.dataset.modalRouteKey, t), K.current.focus({ preventScroll: !0 });
225
+ }, []), ie = p((t) => {
226
+ if (!Object.prototype.hasOwnProperty.call(F, t)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${t}`);
227
+ }, [F]), X = p((t, i) => {
228
228
  try {
229
- Promise.resolve(r[t]?.(o)).catch((l) => w(l, { phase: t }));
230
- } catch (l) {
231
- w(l, { phase: t });
229
+ Promise.resolve(a[t]?.(i)).catch((u) => m(u, { phase: t }));
230
+ } catch (u) {
231
+ m(u, { phase: t });
232
232
  }
233
- }, [r, w]), _ = d((t, o, l) => {
234
- ce(o), te(), h({ type: t, name: o, params: l });
235
- }, [ce, te]), le = d((t, o) => _("NAVIGATE", t, o), [_]), ue = d((t, o) => _("REPLACE", t, o), [_]), de = d((t, o) => {
236
- D({}), _("RESET", t, o);
237
- }, [_]), me = d((t) => {
233
+ }, [a, m]), _ = p((t, i, u) => {
234
+ ie(i), ee(), h({ type: t, name: i, params: u });
235
+ }, [ie, ee]), ce = p((t, i) => _("NAVIGATE", t, i), [_]), le = p((t, i) => _("REPLACE", t, i), [_]), ue = p((t, i) => {
236
+ B({}), _("RESET", t, i);
237
+ }, [_]), de = p((t) => {
238
238
  if (!t || typeof t != "object" || Array.isArray(t)) throw new TypeError("[react-modal-navigation] setParams expects an object");
239
239
  h({ type: "SET_PARAMS", params: t });
240
- }, []), pe = d((t) => {
241
- if (p.length <= 1 || z.current) return !1;
242
- if (z.current = !0, t !== void 0) {
243
- const o = p.at(-2);
244
- D((l) => ({ ...l, [o.key]: { id: ++K.current, data: t } }));
240
+ }, []), ge = p((t) => {
241
+ if (l.length <= 1 || T.current) return !1;
242
+ if (T.current = !0, t !== void 0) {
243
+ const i = l.at(-2);
244
+ B((u) => ({ ...u, [i.key]: { id: ++Y.current, data: t } }));
245
245
  }
246
- return te(), h({ type: "BACK" }), !0;
247
- }, [p, te]), re = d((t, o) => Q.current.visible && r.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : c(t, o, { route: k, stack: p }), [r.lockCloseWhileLoading, c, k, p]), a = d((t) => re("api", t), [re]), i = V(() => ({ navigate: le, replace: ue, reset: de, setParams: me, goBack: pe, close: a, setLoading: U, canGoBack: p.length > 1, stack: p, currentRoute: k }), [le, ue, de, me, pe, a, U, p, k]);
248
- return De(() => {
249
- z.current = !1;
250
- const t = [...I.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((L) => L.dataset.modalRouteKey === T);
246
+ return ee(), h({ type: "BACK" }), !0;
247
+ }, [l, ee]), o = p((t, i) => J.current.visible && a.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : x(t, i, { route: C, stack: l }), [a.lockCloseWhileLoading, x, C, l]), c = p((t) => o("api", t), [o]), b = V(() => ({ navigate: ce, replace: le, reset: ue, setParams: de, goBack: ge, close: c, setLoading: z, canGoBack: l.length > 1, stack: l, currentRoute: C }), [ce, le, ue, de, ge, c, z, l, C]);
248
+ return Oe(() => {
249
+ T.current = !1;
250
+ const t = [...K.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((S) => S.dataset.modalRouteKey === g);
251
251
  if (!t) return;
252
- const o = M.current.get(T);
253
- (o?.isConnected && t.contains(o) && !o.matches(":disabled") && !o.closest("[inert], [hidden]") ? o : t).focus({ preventScroll: !0 });
254
- }, [T]), O(() => {
252
+ const i = $.current.get(g);
253
+ (i?.isConnected && t.contains(i) && !i.matches(":disabled") && !i.closest("[inert], [hidden]") ? i : t).focus({ preventScroll: !0 });
254
+ }, [g]), j(() => {
255
255
  let t = !1;
256
- for (const [l, L] of R.current)
257
- L.owner !== "global" && L.owner !== T && (R.current.delete(l), t = !0);
258
- t && B();
259
- const o = new Set(p.map((l) => l.key));
260
- for (const l of M.current.keys()) o.has(l) || M.current.delete(l);
261
- }, [T, p, B]), O(() => {
262
- if (H.current?.key !== T) {
263
- if (H.current) {
264
- const t = { from: H.current, to: k, stack: p };
265
- Z("onBlur", { route: H.current, ...t }), Z("onNavigate", t), Z("onRouteChange", t);
256
+ for (const [u, S] of M.current)
257
+ S.owner !== "global" && S.owner !== g && (M.current.delete(u), t = !0);
258
+ t && G();
259
+ const i = new Set(l.map((u) => u.key));
260
+ for (const u of $.current.keys()) i.has(u) || $.current.delete(u);
261
+ }, [g, l, G]), j(() => {
262
+ if (O.current?.key !== g) {
263
+ if (O.current) {
264
+ const t = { from: O.current, to: C, stack: l };
265
+ X("onBlur", { route: O.current, ...t }), X("onNavigate", t), X("onRouteChange", t);
266
266
  }
267
- Z("onFocus", { route: k, stack: p }), H.current = k;
267
+ X("onFocus", { route: C, stack: l }), O.current = C;
268
268
  }
269
- }, [k, T, p, Z]), O(() => () => {
270
- R.current.clear(), M.current.clear();
271
- }, []), O(() => {
272
- P.current || (P.current = !0, g?.({ route: k, stack: p }));
273
- }, []), /* @__PURE__ */ m(Re.Provider, { value: i, children: /* @__PURE__ */ m(Me.Provider, { value: X, children: /* @__PURE__ */ ae(Ke, { dialogRef: I, options: r, requestClose: re, exiting: y, children: [
274
- /* @__PURE__ */ m(Ue, { options: r, screen: x[k.name], route: k, navigation: i, requestClose: re, translate: s }),
275
- /* @__PURE__ */ m("main", { className: "pmn-main", children: p.map((t) => /* @__PURE__ */ m(
276
- Ve,
269
+ }, [C, g, l, X]), j(() => () => {
270
+ M.current.clear(), $.current.clear();
271
+ }, []), j(() => {
272
+ H.current || (H.current = !0, y?.({ route: C, stack: l }));
273
+ }, []), /* @__PURE__ */ f(Ce.Provider, { value: b, children: /* @__PURE__ */ f(Se.Provider, { value: fe, children: /* @__PURE__ */ re(We, { dialogRef: K, options: a, requestClose: o, exiting: L, children: [
274
+ /* @__PURE__ */ f(Ye, { options: a, screen: F[C.name], route: C, navigation: b, requestClose: o, translate: s }),
275
+ /* @__PURE__ */ f("main", { className: "pmn-main", children: l.map((t) => /* @__PURE__ */ f(
276
+ Je,
277
277
  {
278
278
  route: t,
279
- screen: x[t.name],
280
- navigation: i,
281
- focused: t.key === T,
282
- resultEvent: b[t.key] ?? null,
283
- bodyClassName: r.bodyClassName,
284
- setFooter: ge,
285
- loadingApi: X,
286
- notifyError: w,
287
- registerDirtyGuard: E
279
+ screen: F[t.name],
280
+ navigation: b,
281
+ focused: t.key === g,
282
+ resultEvent: I[t.key] ?? null,
283
+ bodyClassName: a.bodyClassName,
284
+ setFooter: he,
285
+ loadingApi: fe,
286
+ notifyError: m,
287
+ registerDirtyGuard: v
288
288
  },
289
289
  t.key
290
290
  )) }),
291
- /* @__PURE__ */ m(
292
- We,
291
+ /* @__PURE__ */ f(
292
+ Qe,
293
293
  {
294
- screen: x[k.name],
295
- options: r,
296
- override: F[T],
297
- route: k,
298
- navigation: i,
299
- requestClose: re,
294
+ screen: F[C.name],
295
+ options: a,
296
+ override: q[g],
297
+ route: C,
298
+ navigation: b,
299
+ requestClose: o,
300
300
  translate: s,
301
- onError: w
301
+ onError: m
302
302
  },
303
- T
303
+ g
304
304
  ),
305
- /* @__PURE__ */ m(Ye, { loading: J, translate: s }),
306
- f && /* @__PURE__ */ ae("div", { className: "pmn-error", role: "alert", children: [
307
- /* @__PURE__ */ m("span", { children: f.message || String(f) }),
308
- /* @__PURE__ */ m("button", { type: "button", onClick: N, "aria-label": "Dismiss error", children: "×" })
305
+ /* @__PURE__ */ f(Ve, { loading: W, translate: s }),
306
+ R && /* @__PURE__ */ re("div", { className: "pmn-error", role: "alert", children: [
307
+ /* @__PURE__ */ f("span", { children: R.message || String(R) }),
308
+ /* @__PURE__ */ f("button", { type: "button", onClick: k, "aria-label": "Dismiss error", children: "×" })
309
309
  ] })
310
310
  ] }) }) });
311
311
  }
312
- const Je = ".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:var(--pmn-overlay-card);-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px)}.pmn-loading-card{display:flex;flex-direction:column;align-items:center;gap:12px;max-width:85%;padding:20px 28px;border-radius:12px;background:var(--pmn-surface);box-shadow:0 10px 20px #00000026}.pmn-spinner{width:36px;height:36px;border:3px solid #2563eb;border-top-color:transparent;border-radius:50%;animation:pmn-spin 1s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}.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}}", Ne = "react-modal-navigation-styles", ke = /* @__PURE__ */ new WeakMap();
313
- function Xe() {
314
- $e(() => {
312
+ const Ze = ".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:var(--pmn-overlay-card);-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px)}.pmn-loading-card{display:flex;flex-direction:column;align-items:center;gap:12px;max-width:85%;padding:20px 28px;border-radius:12px;background:var(--pmn-surface);box-shadow:0 10px 20px #00000026}.pmn-spinner{width:36px;height:36px;border:3px solid #2563eb;border-top-color:transparent;border-radius:50%;animation:pmn-spin 1s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}.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}}", Be = "react-modal-navigation-styles", Re = /* @__PURE__ */ new WeakMap();
313
+ function en() {
314
+ je(() => {
315
315
  if (typeof document > "u") return;
316
316
  const e = document;
317
- let n = ke.get(e);
317
+ let n = Re.get(e);
318
318
  if (!n) {
319
- let r = e.getElementById(Ne);
320
- const s = !r;
321
- r || (r = e.createElement("style"), r.id = Ne, r.setAttribute("data-react-modal-navigation", ""), r.textContent = Je, e.head.appendChild(r)), n = { element: r, owned: s, count: 0 }, ke.set(e, n);
319
+ let r = e.getElementById(Be);
320
+ const a = !r;
321
+ r || (r = e.createElement("style"), r.id = Be, r.setAttribute("data-react-modal-navigation", ""), r.textContent = Ze, e.head.appendChild(r)), n = { element: r, owned: a, count: 0 }, Re.set(e, n);
322
322
  }
323
323
  return n.count += 1, () => {
324
- n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), ke.delete(e));
324
+ n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), Re.delete(e));
325
325
  };
326
326
  }, []);
327
327
  }
328
- function ye(e, n, r) {
328
+ function ve(e, n, r) {
329
329
  if (typeof e == "string") {
330
330
  if (!e.trim()) throw new TypeError("[react-modal-navigation] modal name must not be empty");
331
331
  return { name: e, params: n ?? {}, options: r ?? {} };
332
332
  }
333
333
  if (e === null || typeof e != "object" || Array.isArray(e))
334
334
  throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
335
- const { name: s, params: c = {}, options: g = {}, ...v } = e;
336
- if (typeof s != "string" || !s.trim())
335
+ const { name: a, screen: s, params: x = {}, options: y = {}, ...w } = e;
336
+ if (typeof a != "string" || !a.trim())
337
337
  throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
338
- if (g === null || typeof g != "object" || Array.isArray(g))
338
+ if (y === null || typeof y != "object" || Array.isArray(y))
339
339
  throw new TypeError("[react-modal-navigation] open config options must be an object");
340
- return { name: s, params: c, options: { ...v, ...g } };
340
+ if (s !== void 0 && (typeof s != "string" || !s.trim()))
341
+ throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
342
+ return { name: a, ...s === void 0 ? {} : { screen: s }, params: x, options: { ...w, ...y } };
341
343
  }
342
- const Ze = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, en = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
343
- function an({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: s, theme: c, translate: g = en, onError: v, confirmDiscard: w }) {
344
- Xe();
345
- const [f, N] = W(null), [E, y] = W(null), [p, h] = W(0), b = u(null), D = u(/* @__PURE__ */ new Map()), F = u([]), q = u(null), A = u(null), R = u(0), j = u(null), M = u(!1), I = u(0), H = u(null), z = u(/* @__PURE__ */ new Map()), [P, K] = W(!1), k = u(w);
346
- k.current = w;
347
- const T = d((a, i) => (z.current.set(a, i), () => {
348
- z.current.get(a) === i && z.current.delete(a);
349
- }), []), C = d(async (a) => {
350
- for (const i of z.current.values()) {
351
- if (!i.dirty) continue;
352
- if ((i.onBeforeDiscard ? await i.onBeforeDiscard(a) : k.current ? await k.current(a) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(i.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
344
+ const nn = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, tn = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
345
+ function cn({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: a, theme: s, translate: x = tn, onError: y, confirmDiscard: w }) {
346
+ en();
347
+ const [m, R] = Q(null), [k, v] = Q(null), [L, l] = Q(0), h = d(null), I = d(/* @__PURE__ */ new Map()), B = d([]), q = d(null), A = d(null), D = d(0), M = d(null), P = d(!1), $ = d(0), K = d(null), O = d(/* @__PURE__ */ new Map()), [T, H] = Q(!1), Y = d(w);
348
+ Y.current = w;
349
+ const C = p((o, c) => (O.current.set(o, c), () => {
350
+ O.current.get(o) === c && O.current.delete(o);
351
+ }), []), g = p(async (o) => {
352
+ for (const c of O.current.values()) {
353
+ if (!c.dirty) continue;
354
+ if ((c.onBeforeDiscard ? await c.onBeforeDiscard(o) : Y.current ? await Y.current(o) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(c.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
353
355
  }
354
356
  return !0;
355
- }, []), x = u(!0), B = u(null), G = u(v);
356
- G.current = v;
357
- const S = d((a, i) => {
358
- x.current && y(a);
357
+ }, []), E = d(!0), F = d(null), G = d(y);
358
+ G.current = y;
359
+ const N = p((o, c) => {
360
+ E.current && v(o);
359
361
  try {
360
- G.current ? G.current(a, i) : console.error("[react-modal-navigation]", a);
361
- } catch (t) {
362
- console.error("[react-modal-navigation] onError failed", t);
362
+ G.current ? G.current(o, c) : console.error("[react-modal-navigation]", o);
363
+ } catch (b) {
364
+ console.error("[react-modal-navigation] onError failed", b);
363
365
  }
364
- }, []), U = d((a, i) => {
365
- const t = D.current.get(a);
366
- D.current.delete(a), t?.(i);
367
- }, []), Y = d((a) => ({ ...Ze, ...r, ...c !== void 0 ? { theme: c } : {}, ...s !== void 0 ? { backgroundColor: s } : {}, ...a.config.modalOptions, ...a.overrides }), [r, c, s]), ne = f ? Y(f) : null, J = u(null);
368
- J.current = ne, B.current = ne;
369
- const Q = d(async (a = "api", i, t = {}) => {
370
- const o = b.current;
371
- if (!o || j.current || M.current) return !1;
372
- j.current = o.id, M.current = !0;
373
- const l = B.current ?? Y(o), L = { ...t, reason: a, result: i, name: o.name };
366
+ }, []), U = p((o, c) => {
367
+ const b = I.current.get(o);
368
+ I.current.delete(o), b?.(c);
369
+ }, []), z = p((o) => ({ ...nn, ...r, ...s !== void 0 ? { theme: s } : {}, ...a !== void 0 ? { backgroundColor: a } : {}, ...o.config.modalOptions, ...o.overrides }), [r, s, a]), oe = m ? z(m) : null, ae = d(null);
370
+ ae.current = oe, F.current = oe;
371
+ const W = p(async (o = "api", c, b = {}) => {
372
+ const t = h.current;
373
+ if (!t || M.current || P.current) return !1;
374
+ M.current = t.id, P.current = !0;
375
+ const i = F.current ?? z(t), u = { ...b, reason: o, result: c, name: t.name };
374
376
  try {
375
- if (!await C(L) || await l.onBeforeClose?.(L) === !1 || b.current?.id !== o.id || !x.current || (K(!0), await new Promise(($) => {
376
- const se = l.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(l.animationDuration ?? 220) || 0);
377
- setTimeout($, Math.min(se, 1e3));
378
- }), !x.current || b.current?.id !== o.id)) return !1;
379
- b.current = null, H.current = null, N(null), K(!1), z.current.clear(), U(o.id, t.confirmed || i !== void 0 ? { status: "confirmed", value: i, reason: a } : { status: "dismissed", reason: a });
377
+ if (!await g(u) || await i.onBeforeClose?.(u) === !1 || h.current?.id !== t.id || !E.current || (H(!0), await new Promise((S) => {
378
+ const ye = i.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(i.animationDuration ?? 220) || 0);
379
+ setTimeout(S, Math.min(ye, 1e3));
380
+ }), !E.current || h.current?.id !== t.id)) return !1;
381
+ h.current = null, K.current = null, R(null), H(!1), O.current.clear(), U(t.id, b.confirmed || c !== void 0 ? { status: "confirmed", value: c, reason: o } : { status: "dismissed", reason: o });
380
382
  try {
381
- await l.onClose?.(L);
382
- } catch ($) {
383
- S($, { phase: "onClose", name: o.name });
383
+ await i.onClose?.(u);
384
+ } catch (S) {
385
+ N(S, { phase: "onClose", name: t.name });
384
386
  }
385
387
  return !0;
386
- } catch ($) {
387
- return S($, { phase: "onBeforeClose", name: o.name }), !1;
388
+ } catch (S) {
389
+ return N(S, { phase: "onBeforeClose", name: t.name }), !1;
388
390
  } finally {
389
- j.current === o.id && (j.current = null), M.current = !1, !b.current && x.current && queueMicrotask(() => A.current?.());
391
+ M.current === t.id && (M.current = null), P.current = !1, !h.current && E.current && queueMicrotask(() => A.current?.());
390
392
  }
391
- }, [Y, S, U, C]), X = d(async (a, i = {}, t = {}, o) => {
392
- const l = e?.[a];
393
- if (!l) throw new Error(`[react-modal-navigation] Unknown modal: ${a}`);
394
- if (!l.screens?.[l.initialRoute]) throw new Error(`[react-modal-navigation] Missing initial screen '${l.initialRoute}' in '${a}'`);
395
- if (!x.current || M.current || j.current) return null;
396
- M.current = !0;
397
- const L = I.current;
393
+ }, [z, N, U, g]), J = p(async (o, c = {}, b = {}, t, i) => {
394
+ const u = e?.[o];
395
+ if (!u) throw new Error(`[react-modal-navigation] Unknown modal: ${o}`);
396
+ const S = i ?? u.initialRoute;
397
+ if (!u.screens?.[S]) throw new Error(`[react-modal-navigation] Unknown initial screen '${S}' in modal '${o}'`);
398
+ if (!E.current || P.current || M.current) return null;
399
+ P.current = !0;
400
+ const ye = $.current;
398
401
  try {
399
- const $ = b.current;
400
- if ($) {
401
- const Ce = B.current ?? Y($), ve = { reason: "replace", name: $.name, nextName: a };
402
+ const ne = h.current;
403
+ if (ne) {
404
+ const Le = F.current ?? z(ne), we = { reason: "replace", name: ne.name, nextName: o };
402
405
  try {
403
- if (!await C(ve) || await Ce.onBeforeClose?.(ve) === !1) return null;
404
- } catch (xe) {
405
- return S(xe, { phase: "onBeforeClose", name: $.name }), null;
406
+ if (!await g(we) || await Le.onBeforeClose?.(we) === !1) return null;
407
+ } catch (ke) {
408
+ return N(ke, { phase: "onBeforeClose", name: ne.name }), null;
406
409
  }
407
- if (!x.current || L !== I.current || b.current?.id !== $.id) return null;
408
- b.current = null, H.current = null, N(null), z.current.clear(), U($.id, { status: "replaced", reason: "replace" });
410
+ if (!E.current || ye !== $.current || h.current?.id !== ne.id) return null;
411
+ h.current = null, K.current = null, R(null), O.current.clear(), U(ne.id, { status: "replaced", reason: "replace" });
409
412
  try {
410
- await Ce.onClose?.(ve);
411
- } catch (xe) {
412
- S(xe, { phase: "onClose", name: $.name });
413
+ await Le.onClose?.(we);
414
+ } catch (ke) {
415
+ N(ke, { phase: "onClose", name: ne.name });
413
416
  }
414
- if (!x.current || L !== I.current) return null;
417
+ if (!E.current || ye !== $.current) return null;
415
418
  }
416
- const se = { id: ++R.current, name: a, params: i, config: l, overrides: t };
417
- return b.current = se, H.current = null, o && D.current.set(se.id, o), y(null), N(se), se.id;
419
+ const be = { id: ++D.current, name: o, screen: S, params: c, config: u, overrides: b };
420
+ return h.current = be, K.current = null, t && I.current.set(be.id, t), v(null), R(be), be.id;
418
421
  } finally {
419
- M.current = !1;
422
+ P.current = !1;
420
423
  }
421
- }, [e, Y, S, U, C]);
422
- q.current = X;
423
- const ie = d(async () => {
424
- if (!x.current || b.current || M.current || j.current) return;
425
- const a = F.current.shift();
426
- if (a) {
427
- h(F.current.length);
424
+ }, [e, z, N, U, g]);
425
+ q.current = J;
426
+ const fe = p(async () => {
427
+ if (!E.current || h.current || P.current || M.current) return;
428
+ const o = B.current.shift();
429
+ if (o) {
430
+ l(B.current.length);
428
431
  try {
429
- const i = await q.current(a.args.name, a.args.params, a.args.options, a.resolveResult);
430
- i === null ? (a.resolveResult?.({ status: "dismissed", reason: "blocked" }), a.resolveId?.(null), queueMicrotask(() => A.current?.())) : a.resolveId?.(i);
431
- } catch (i) {
432
- a.reject?.(i), queueMicrotask(() => A.current?.());
432
+ const c = await q.current(o.args.name, o.args.params, o.args.options, o.resolveResult, o.args.screen);
433
+ c === null ? (o.resolveResult?.({ status: "dismissed", reason: "blocked" }), o.resolveId?.(null), queueMicrotask(() => A.current?.())) : o.resolveId?.(c);
434
+ } catch (c) {
435
+ o.reject?.(c), queueMicrotask(() => A.current?.());
433
436
  }
434
437
  }
435
438
  }, []);
436
- A.current = ie;
437
- const ge = d((a, i, t) => {
438
- const o = ye(a, i, t);
439
- return e?.[o.name] ? new Promise((l, L) => {
440
- F.current.push({ args: o, resolveId: l, reject: L }), h(F.current.length), queueMicrotask(() => A.current?.());
441
- }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${o.name}`));
442
- }, [e]), te = d((a, i, t) => {
443
- const o = ye(a, i, t);
444
- return e?.[o.name] ? new Promise((l, L) => {
445
- F.current.push({ args: o, resolveResult: l, reject: L }), h(F.current.length), queueMicrotask(() => A.current?.());
446
- }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${o.name}`));
447
- }, [e]), ce = d((a) => {
448
- if (!a || typeof a != "object" || Array.isArray(a)) throw new TypeError("[react-modal-navigation] update expects an options object");
449
- const i = b.current;
450
- if (!i || M.current) return !1;
451
- const t = { ...i, overrides: { ...i.overrides, ...a } };
452
- return b.current = t, N(t), B.current = Y(t), !0;
453
- }, [Y]), Z = d((a = "queue-cleared") => {
454
- const i = F.current.splice(0);
455
- h(0);
456
- for (const t of i)
457
- t.resolveId?.(null), t.resolveResult?.({ status: "dismissed", reason: a });
458
- return i.length;
459
- }, []), _ = d((a, i, t) => {
460
- const o = ye(a, i, t);
461
- return X(o.name, o.params, o.options);
462
- }, [X]), le = d((a, i, t) => {
463
- const o = ye(a, i, t);
464
- return new Promise((l, L) => {
465
- X(o.name, o.params, o.options, l).then(($) => {
466
- $ === null && l({ status: "dismissed", reason: "blocked" });
467
- }, L);
439
+ A.current = fe;
440
+ const se = p((o, c, b) => {
441
+ const t = ve(o, c, b);
442
+ return e?.[t.name] ? new Promise((i, u) => {
443
+ B.current.push({ args: t, resolveId: i, reject: u }), l(B.current.length), queueMicrotask(() => A.current?.());
444
+ }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${t.name}`));
445
+ }, [e]), he = p((o, c, b) => {
446
+ const t = ve(o, c, b);
447
+ return e?.[t.name] ? new Promise((i, u) => {
448
+ B.current.push({ args: t, resolveResult: i, reject: u }), l(B.current.length), queueMicrotask(() => A.current?.());
449
+ }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${t.name}`));
450
+ }, [e]), ee = p((o) => {
451
+ if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] update expects an options object");
452
+ const c = h.current;
453
+ if (!c || P.current) return !1;
454
+ const b = { ...c, overrides: { ...c.overrides, ...o } };
455
+ return h.current = b, R(b), F.current = z(b), !0;
456
+ }, [z]), ie = p((o = "queue-cleared") => {
457
+ const c = B.current.splice(0);
458
+ l(0);
459
+ for (const b of c)
460
+ b.resolveId?.(null), b.resolveResult?.({ status: "dismissed", reason: o });
461
+ return c.length;
462
+ }, []), X = p((o, c, b) => {
463
+ const t = ve(o, c, b);
464
+ return J(t.name, t.params, t.options, void 0, t.screen);
465
+ }, [J]), _ = p((o, c, b) => {
466
+ const t = ve(o, c, b);
467
+ return new Promise((i, u) => {
468
+ J(t.name, t.params, t.options, i, t.screen).then((S) => {
469
+ S === null && i({ status: "dismissed", reason: "blocked" });
470
+ }, u);
468
471
  });
469
- }, [X]), ue = d((a) => Q("api", a), [Q]), de = d((a = "api") => Q(a), [Q]), me = d((a) => Q("confirm", a, { confirmed: !0 }), [Q]), pe = d((a, i) => H.current?.setLoading(a, i), []), re = V(() => ({ open: _, openAsync: le, enqueue: ge, enqueueAsync: te, update: ce, clearQueue: Z, close: ue, dismiss: de, confirm: me, setLoading: pe, queueSize: p, isOpen: !!f, activeName: f?.name ?? null, error: E, clearError: () => y(null) }), [_, le, ge, te, ce, Z, ue, de, me, pe, f, E, p]);
470
- return O(() => (x.current = !0, () => {
471
- x.current = !1, I.current += 1, b.current = null;
472
- for (const i of D.current.values()) i({ status: "dismissed", reason: "unmount" });
473
- D.current.clear(), z.current.clear();
474
- const a = F.current.splice(0);
475
- for (const i of a)
476
- i.resolveId?.(null), i.resolveResult?.({ status: "dismissed", reason: "unmount" });
477
- }), []), /* @__PURE__ */ ae(Te.Provider, { value: re, children: [
472
+ }, [J]), ce = p((o) => W("api", o), [W]), le = p((o = "api") => W(o), [W]), ue = p((o) => W("confirm", o, { confirmed: !0 }), [W]), de = p((o, c) => K.current?.setLoading(o, c), []), ge = V(() => ({ open: X, openAsync: _, enqueue: se, enqueueAsync: he, update: ee, clearQueue: ie, close: ce, dismiss: le, confirm: ue, setLoading: de, queueSize: L, isOpen: !!m, activeName: m?.name ?? null, error: k, clearError: () => v(null) }), [X, _, se, he, ee, ie, ce, le, ue, de, m, k, L]);
473
+ return j(() => (E.current = !0, () => {
474
+ E.current = !1, $.current += 1, h.current = null;
475
+ for (const c of I.current.values()) c({ status: "dismissed", reason: "unmount" });
476
+ I.current.clear(), O.current.clear();
477
+ const o = B.current.splice(0);
478
+ for (const c of o)
479
+ c.resolveId?.(null), c.resolveResult?.({ status: "dismissed", reason: "unmount" });
480
+ }), []), /* @__PURE__ */ re(Pe.Provider, { value: ge, children: [
478
481
  n,
479
- f && /* @__PURE__ */ m(
480
- _e,
482
+ m && /* @__PURE__ */ f(
483
+ Xe,
481
484
  {
482
- config: f.config,
483
- params: f.params,
484
- options: ne,
485
- translate: g,
486
- notifyError: S,
487
- error: E,
488
- clearError: () => y(null),
489
- registerLoading: (a) => {
490
- H.current = a;
485
+ config: m.config,
486
+ initialScreen: m.screen,
487
+ params: m.params,
488
+ options: oe,
489
+ translate: x,
490
+ notifyError: N,
491
+ error: k,
492
+ clearError: () => v(null),
493
+ registerLoading: (o) => {
494
+ K.current = o;
491
495
  },
492
- registerDirtyGuard: T,
493
- exiting: P,
494
- onRequestClose: Q,
495
- onOpened: (a) => {
496
+ registerDirtyGuard: C,
497
+ exiting: T,
498
+ onRequestClose: W,
499
+ onOpened: (o) => {
496
500
  try {
497
- const i = J.current?.onOpen?.(a);
498
- Promise.resolve(i).catch((t) => S(t, { phase: "onOpen" }));
499
- } catch (i) {
500
- S(i, { phase: "onOpen" });
501
+ const c = ae.current?.onOpen?.(o);
502
+ Promise.resolve(c).catch((b) => N(b, { phase: "onOpen" }));
503
+ } catch (c) {
504
+ N(c, { phase: "onOpen" });
501
505
  }
502
506
  }
503
507
  },
504
- f.id
508
+ m.id
505
509
  )
506
510
  ] });
507
511
  }
508
- function sn() {
509
- const e = ee(Te), n = ee(Re);
512
+ function ln() {
513
+ const e = Z(Pe), n = Z(Ce);
510
514
  if (!e) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
511
515
  return V(() => {
512
516
  const r = () => {
@@ -514,12 +518,12 @@ function sn() {
514
518
  return n;
515
519
  };
516
520
  return { ...e, modal: e, navigation: {
517
- navigate: (...c) => r().navigate(...c),
518
- replace: (...c) => r().replace(...c),
519
- reset: (...c) => r().reset(...c),
520
- setParams: (...c) => r().setParams(...c),
521
- goBack: (...c) => r().goBack(...c),
522
- close: (...c) => r().close(...c),
521
+ navigate: (...s) => r().navigate(...s),
522
+ replace: (...s) => r().replace(...s),
523
+ reset: (...s) => r().reset(...s),
524
+ setParams: (...s) => r().setParams(...s),
525
+ goBack: (...s) => r().goBack(...s),
526
+ close: (...s) => r().close(...s),
523
527
  get canGoBack() {
524
528
  return n?.canGoBack ?? !1;
525
529
  },
@@ -532,115 +536,115 @@ function sn() {
532
536
  } };
533
537
  }, [e, n]);
534
538
  }
535
- function cn() {
536
- const e = ee(Re);
539
+ function un() {
540
+ const e = Z(Ce);
537
541
  if (!e) throw new Error("useModalNavigation requires an active modal screen");
538
542
  return e;
539
543
  }
540
- function Fe() {
541
- const e = ee(be);
544
+ function Ae() {
545
+ const e = Z(xe);
542
546
  if (!e) throw new Error("useIsFocused must be called inside a modal screen");
543
547
  return e.isFocused;
544
548
  }
545
- function ln(e) {
546
- const n = Fe();
547
- O(() => {
549
+ function dn(e) {
550
+ const n = Ae();
551
+ j(() => {
548
552
  if (n)
549
553
  return e();
550
554
  }, [n, e]);
551
555
  }
552
- function un(e) {
553
- const n = ee(be);
556
+ function mn(e) {
557
+ const n = Z(xe);
554
558
  if (!n) throw new Error("useNavigationResult requires an active modal screen");
555
- const r = u(e), s = u(null);
556
- O(() => {
559
+ const r = d(e), a = d(null);
560
+ j(() => {
557
561
  r.current = e;
558
- }, [e]), O(() => {
559
- !n.isFocused || !n.resultEvent || s.current !== n.resultEvent.id && (s.current = n.resultEvent.id, r.current(n.resultEvent.data));
562
+ }, [e]), j(() => {
563
+ !n.isFocused || !n.resultEvent || a.current !== n.resultEvent.id && (a.current = n.resultEvent.id, r.current(n.resultEvent.data));
560
564
  }, [n.isFocused, n.resultEvent]);
561
565
  }
562
- function dn(e = {}) {
563
- const n = ee(be);
566
+ function pn(e = {}) {
567
+ const n = Z(xe);
564
568
  if (!n) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
565
- const { setFooter: r, routeKey: s } = n, c = u(e);
566
- c.current = e;
567
- const g = V(() => (...R) => c.current.done?.(...R), []), v = V(() => (...R) => (c.current.cancel ?? c.current.cancle)?.(...R), []), w = V(() => (...R) => c.current.renderFooter?.(...R), []), f = typeof e.done == "function", N = typeof (e.cancel ?? e.cancle) == "function", E = typeof e.renderFooter == "function", { showFooter: y, showFooterBorder: p, doneDisabled: h, doneText: b, cancelText: D, loadingText: F, footerClassName: q } = e, A = V(() => ({
568
- showFooter: y,
569
- showFooterBorder: p,
570
- doneDisabled: h,
571
- doneText: b,
572
- cancelText: D,
573
- loadingText: F,
569
+ const { setFooter: r, routeKey: a } = n, s = d(e);
570
+ s.current = e;
571
+ const x = V(() => (...D) => s.current.done?.(...D), []), y = V(() => (...D) => (s.current.cancel ?? s.current.cancle)?.(...D), []), w = V(() => (...D) => s.current.renderFooter?.(...D), []), m = typeof e.done == "function", R = typeof (e.cancel ?? e.cancle) == "function", k = typeof e.renderFooter == "function", { showFooter: v, showFooterBorder: L, doneDisabled: l, doneText: h, cancelText: I, loadingText: B, footerClassName: q } = e, A = V(() => ({
572
+ showFooter: v,
573
+ showFooterBorder: L,
574
+ doneDisabled: l,
575
+ doneText: h,
576
+ cancelText: I,
577
+ loadingText: B,
574
578
  footerClassName: q,
575
- ...f ? { done: g } : {},
576
- ...N ? { cancel: v } : {},
577
- ...E ? { renderFooter: w } : {}
578
- }), [y, p, h, b, D, F, q, f, N, E, g, v, w]);
579
- O(() => {
580
- r(s, A);
581
- }, [s, r, A]), O(() => () => r(s, null), [s, r]);
579
+ ...m ? { done: x } : {},
580
+ ...R ? { cancel: y } : {},
581
+ ...k ? { renderFooter: w } : {}
582
+ }), [v, L, l, h, I, B, q, m, R, k, x, y, w]);
583
+ j(() => {
584
+ r(a, A);
585
+ }, [a, r, A]), j(() => () => r(a, null), [a, r]);
582
586
  }
583
- function nn() {
584
- const e = ee(Me);
587
+ function rn() {
588
+ const e = Z(Se);
585
589
  if (!e) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
586
590
  return e;
587
591
  }
588
- function mn() {
589
- const e = nn(), n = Fe(), r = u(!0), s = u(!1), [c, g] = W(!1), [v, w] = W(null), f = u(e);
590
- return f.current = e, O(() => (r.current = !0, () => {
592
+ function fn() {
593
+ const e = rn(), n = Ae(), r = d(!0), a = d(!1), [s, x] = Q(!1), [y, w] = Q(null), m = d(e);
594
+ return m.current = e, j(() => (r.current = !0, () => {
591
595
  r.current = !1;
592
- }), []), { run: d(async (E, y = {}) => {
593
- if (s.current) return { status: "busy" };
594
- if (typeof E != "function") throw new TypeError("[react-modal-navigation] run requires a function");
595
- s.current = !0, r.current && (g(!0), w(null));
596
- const p = f.current.showLoading(y.loadingText);
596
+ }), []), { run: p(async (k, v = {}) => {
597
+ if (a.current) return { status: "busy" };
598
+ if (typeof k != "function") throw new TypeError("[react-modal-navigation] run requires a function");
599
+ a.current = !0, r.current && (x(!0), w(null));
600
+ const L = m.current.showLoading(v.loadingText);
597
601
  try {
598
- const h = await E();
599
- return r.current && await y.onSuccess?.(h), { status: "success", value: h };
600
- } catch (h) {
602
+ const l = await k();
603
+ return r.current && await v.onSuccess?.(l), { status: "success", value: l };
604
+ } catch (l) {
601
605
  if (r.current) {
602
- w(h);
606
+ w(l);
603
607
  try {
604
- await y.onError?.(h);
605
- } catch (b) {
606
- console.error("[react-modal-navigation] onError failed", b);
608
+ await v.onError?.(l);
609
+ } catch (h) {
610
+ console.error("[react-modal-navigation] onError failed", h);
607
611
  }
608
612
  }
609
- if (y.throwOnError) throw h;
610
- return { status: "error", error: h };
613
+ if (v.throwOnError) throw l;
614
+ return { status: "error", error: l };
611
615
  } finally {
612
- p != null && f.current.hideLoading(p), s.current = !1, r.current && g(!1);
616
+ L != null && m.current.hideLoading(L), a.current = !1, r.current && x(!1);
613
617
  }
614
- }, []), pending: c, error: v, clearError: () => w(null), isFocused: n };
618
+ }, []), pending: s, error: y, clearError: () => w(null), isFocused: n };
615
619
  }
616
- function pn(e, n = {}) {
617
- const r = ee(Be);
620
+ function hn(e, n = {}) {
621
+ const r = Z(Fe);
618
622
  if (!r) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
619
- const s = u({ dirty: e, ...n });
620
- s.current = { dirty: e, ...n };
621
- const { routeKey: c, registerDirtyGuard: g } = r;
622
- O(() => g(c, {
623
+ const a = d({ dirty: e, ...n });
624
+ a.current = { dirty: e, ...n };
625
+ const { routeKey: s, registerDirtyGuard: x } = r;
626
+ j(() => x(s, {
623
627
  get dirty() {
624
- return !!s.current.dirty;
628
+ return !!a.current.dirty;
625
629
  },
626
630
  get message() {
627
- return s.current.message;
631
+ return a.current.message;
628
632
  },
629
633
  get onBeforeDiscard() {
630
- return s.current.onBeforeDiscard;
634
+ return a.current.onBeforeDiscard;
631
635
  }
632
- }), [c, g]);
636
+ }), [s, x]);
633
637
  }
634
638
  export {
635
- _e as ModalNavigator,
636
- an as ModalProvider,
637
- ln as useFocusEffect,
638
- Fe as useIsFocused,
639
- sn as useModal,
640
- dn as useModalFooter,
641
- nn as useModalLoading,
642
- cn as useModalNavigation,
643
- mn as useModalTask,
644
- pn as useModalUnsavedChanges,
645
- un as useNavigationResult
639
+ Xe as ModalNavigator,
640
+ cn as ModalProvider,
641
+ dn as useFocusEffect,
642
+ Ae as useIsFocused,
643
+ ln as useModal,
644
+ pn as useModalFooter,
645
+ rn as useModalLoading,
646
+ un as useModalNavigation,
647
+ fn as useModalTask,
648
+ hn as useModalUnsavedChanges,
649
+ mn as useNavigationResult
646
650
  };