react-modal-navigation 1.1.5 → 1.1.7

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,106 +1,140 @@
1
- import { jsx as u, jsxs as ie } from "react/jsx-runtime";
2
- import He, { createContext as ye, useRef as m, useState as X, useEffect as z, useReducer as Ge, useCallback as p, useMemo as ne, useLayoutEffect as Ke, useInsertionEffect as Ue, useContext as re } from "react";
3
- import { createPortal as We } from "react-dom";
4
- const Ae = ye(null), Le = ye(null), Me = ye(null), Pe = ye(null), De = ye(null), je = ye(null);
5
- let Ye = 0;
6
- const Ne = (e, n) => ({ key: `modal-route-${++Ye}`, name: e, params: n ?? {} }), $e = (e, n) => [Ne(e, n)];
7
- function _e(e, n) {
1
+ import { jsx as h, jsxs as me } from "react/jsx-runtime";
2
+ import Ne, { createContext as ee, useRef as m, useState as ie, useEffect as H, useCallback as v, useMemo as K, useSyncExternalStore as be, useReducer as ln, useLayoutEffect as Qe, useInsertionEffect as un, useContext as Q } from "react";
3
+ import { createPortal as dn } from "react-dom";
4
+ const nn = ee(null), mn = ee(null), je = ee(null), Fe = ee(null), tn = ee(null), rn = ee(null), Ue = ee(null), We = ee(null), Ye = ee(null), pn = ee(null), fn = ee(null), on = ee(null);
5
+ function hn(e) {
6
+ let n = e;
7
+ const r = /* @__PURE__ */ new Set();
8
+ return {
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 c of [...r]) c();
15
+ }
16
+ },
17
+ listenerCount: () => r.size
18
+ };
19
+ }
20
+ function ze(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 c of [...r]) c();
30
+ }
31
+ },
32
+ listenerCount: () => r.size
33
+ };
34
+ }
35
+ let gn = 0;
36
+ const He = (e, n) => ({ key: `modal-route-${++gn}`, name: e, params: n ?? {} }), an = (e, n) => [He(e, n)];
37
+ function qe(e, n) {
8
38
  switch (n.type) {
9
39
  case "RESET":
10
- return $e(n.name, n.params);
40
+ return an(n.name, n.params);
11
41
  case "NAVIGATE": {
12
- const r = e.findIndex((o) => o.name === n.name);
13
- return r < 0 ? [...e, Ne(n.name, n.params)] : e.slice(0, r + 1).map((o, s) => s === r ? { ...o, params: n.params ?? {} } : o);
42
+ const r = e.findIndex((t) => t.name === n.name);
43
+ return r < 0 ? [...e, He(n.name, n.params)] : e.slice(0, r + 1).map((t, c) => c === r ? { ...t, params: n.params ?? {} } : t);
14
44
  }
15
45
  case "SET_OPTIONS":
16
- return e.map((r, o) => o === e.length - 1 ? { ...r, options: { ...r.options ?? {}, ...n.options ?? {} } } : r);
46
+ return e.map((r, t) => t === e.length - 1 ? { ...r, options: { ...r.options ?? {}, ...n.options ?? {} } } : r);
17
47
  case "SET_PARAMS":
18
- return e.map((r, o) => o === e.length - 1 ? { ...r, params: { ...r.params ?? {}, ...n.params ?? {} } } : r);
48
+ return e.map((r, t) => t === e.length - 1 ? { ...r, params: { ...r.params ?? {}, ...n.params ?? {} } } : r);
19
49
  case "BACK":
20
50
  return e.length > 1 ? e.slice(0, -1) : e;
21
51
  case "REPLACE":
22
- return e.length ? [...e.slice(0, -1), Ne(n.name, n.params)] : e;
52
+ return e.length ? [...e.slice(0, -1), He(n.name, n.params)] : e;
23
53
  default:
24
54
  return e;
25
55
  }
26
56
  }
27
- const Fe = () => {
57
+ function bn(e, n, r = 1 / 0) {
58
+ const t = r === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(r) || 0)), c = e.slice(0, -1).filter((l) => n[l.name]?.keepAlive !== !1), f = new Set((t === 0 ? [] : c.slice(-t)).map((l) => l.key));
59
+ return e.filter((l, u) => u === e.length - 1 || f.has(l.key));
60
+ }
61
+ const Je = () => {
28
62
  if (typeof document > "u") return "light";
29
63
  const e = document.documentElement, n = document.body;
30
64
  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";
31
65
  };
32
- let we = 0;
33
- const me = [];
34
- let Ce = null;
35
- function Qe() {
36
- if (we++, we === 1) {
37
- const n = document.documentElement, r = document.body, o = { 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), b = parseFloat(getComputedStyle(r).paddingRight) || 0;
38
- s && (r.style.paddingRight = `${b + s}px`), r.style.setProperty("--modal-scrollbar-width", `${s}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", Ce = () => {
39
- n.style.overflow = o.html, r.style.overflow = o.body, r.style.paddingRight = o.padding, o.width ? r.style.setProperty("--modal-scrollbar-width", o.width) : r.style.removeProperty("--modal-scrollbar-width");
66
+ let Te = 0;
67
+ const ge = [];
68
+ let Ke = null;
69
+ function yn() {
70
+ if (Te++, Te === 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") }, c = Math.max(0, window.innerWidth - n.clientWidth), f = parseFloat(getComputedStyle(r).paddingRight) || 0;
72
+ c && (r.style.paddingRight = `${f + c}px`), r.style.setProperty("--modal-scrollbar-width", `${c}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", Ke = () => {
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");
40
74
  };
41
75
  }
42
76
  let e = !1;
43
77
  return () => {
44
- e || (e = !0, we = Math.max(0, we - 1), we || (Ce?.(), Ce = null));
78
+ e || (e = !0, Te = Math.max(0, Te - 1), Te || (Ke?.(), Ke = null));
45
79
  };
46
80
  }
47
- const Ve = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', Je = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
48
- function Xe({ dialogRef: e, options: n, requestClose: r, children: o, exiting: s = !1 }) {
49
- const b = m(null), y = m(null), R = m(r);
50
- R.current = r;
51
- const f = m(n.closeOnEsc);
52
- f.current = n.closeOnEsc;
53
- const [k, S] = X(Fe), x = n.theme === "light" || n.theme === "dark" ? n.theme : k;
54
- z(() => {
81
+ const vn = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', wn = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
82
+ function xn({ dialogRef: e, options: n, requestClose: r, children: t, exiting: c = !1 }) {
83
+ const f = m(null), l = m(null), u = m(r);
84
+ u.current = r;
85
+ const d = m(n.closeOnEsc);
86
+ d.current = n.closeOnEsc;
87
+ const [y, C] = ie(Je), w = n.theme === "light" || n.theme === "dark" ? n.theme : y;
88
+ H(() => {
55
89
  if (n.theme === "light" || n.theme === "dark") return;
56
- const F = () => S(Fe()), Y = new MutationObserver(F);
57
- for (const oe of [document.documentElement, document.body]) Y.observe(oe, { attributes: !0, attributeFilter: ["class", "data-theme"] });
58
- const P = window.matchMedia?.("(prefers-color-scheme: dark)");
59
- return P?.addEventListener?.("change", F), F(), () => {
60
- Y.disconnect(), P?.removeEventListener?.("change", F);
90
+ const b = () => C(Je()), T = new MutationObserver(b);
91
+ for (const F of [document.documentElement, document.body]) T.observe(F, { attributes: !0, attributeFilter: ["class", "data-theme"] });
92
+ const j = window.matchMedia?.("(prefers-color-scheme: dark)");
93
+ return j?.addEventListener?.("change", b), b(), () => {
94
+ T.disconnect(), j?.removeEventListener?.("change", b);
61
95
  };
62
- }, [n.theme]), z(() => {
63
- y.current = document.activeElement;
64
- const F = Qe(), Y = b.current;
65
- me.push(Y), e.current?.focus({ preventScroll: !0 });
66
- const P = (E) => {
67
- const T = e.current;
68
- if (!T || me.at(-1) !== Y) return;
69
- if (E.key === "Escape" && f.current !== !1) {
70
- E.preventDefault(), R.current("escape");
96
+ }, [n.theme]), H(() => {
97
+ l.current = document.activeElement;
98
+ const b = yn(), T = f.current;
99
+ ge.push(T), e.current?.focus({ preventScroll: !0 });
100
+ const j = (N) => {
101
+ const V = e.current;
102
+ if (!V || ge.at(-1) !== T) return;
103
+ if (N.key === "Escape" && d.current !== !1) {
104
+ N.preventDefault(), u.current("escape");
71
105
  return;
72
106
  }
73
- if (E.key !== "Tab") return;
74
- const B = [...T.querySelectorAll(Ve)].filter(Je);
75
- if (!B.length) {
76
- E.preventDefault(), T.focus();
107
+ if (N.key !== "Tab") return;
108
+ const L = [...V.querySelectorAll(vn)].filter(wn);
109
+ if (!L.length) {
110
+ N.preventDefault(), V.focus();
77
111
  return;
78
112
  }
79
- const Z = B[0], j = B.at(-1);
80
- T.contains(document.activeElement) ? E.shiftKey && (document.activeElement === Z || document.activeElement === T) ? (E.preventDefault(), j.focus()) : !E.shiftKey && (document.activeElement === j || document.activeElement === T) && (E.preventDefault(), Z.focus()) : (E.preventDefault(), (E.shiftKey ? j : Z).focus());
81
- }, oe = (E) => {
82
- me.at(-1) === Y && e.current && !e.current.contains(E.target) && e.current.focus({ preventScroll: !0 });
113
+ const ne = L[0], te = L.at(-1);
114
+ V.contains(document.activeElement) ? N.shiftKey && (document.activeElement === ne || document.activeElement === V) ? (N.preventDefault(), te.focus()) : !N.shiftKey && (document.activeElement === te || document.activeElement === V) && (N.preventDefault(), ne.focus()) : (N.preventDefault(), (N.shiftKey ? te : ne).focus());
115
+ }, F = (N) => {
116
+ ge.at(-1) === T && e.current && !e.current.contains(N.target) && e.current.focus({ preventScroll: !0 });
83
117
  };
84
- return document.addEventListener("keydown", P), document.addEventListener("focusin", oe), () => {
85
- document.removeEventListener("keydown", P), document.removeEventListener("focusin", oe);
86
- const E = me.at(-1) === Y, T = me.indexOf(Y);
87
- if (T !== -1 && me.splice(T, 1), F(), E) {
88
- const B = y.current;
89
- B?.isConnected && !B.closest("[inert], [hidden]") ? B.focus?.({ preventScroll: !0 }) : me.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
118
+ return document.addEventListener("keydown", j), document.addEventListener("focusin", F), () => {
119
+ document.removeEventListener("keydown", j), document.removeEventListener("focusin", F);
120
+ const N = ge.at(-1) === T, V = ge.indexOf(T);
121
+ if (V !== -1 && ge.splice(V, 1), b(), N) {
122
+ const L = l.current;
123
+ L?.isConnected && !L.closest("[inert], [hidden]") ? L.focus?.({ preventScroll: !0 }) : ge.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
90
124
  }
91
125
  };
92
126
  }, [e]);
93
- const w = n.backgroundColor ?? n.backgroudColor, l = typeof w == "string" ? w : w?.[x], g = typeof l == "string" && /^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(l.trim()) ? l : null, O = { sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }, N = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", H = (F) => typeof F == "number" ? `${F}px` : F, C = H(n.width ?? O[n.size] ?? 460), L = H(n.height), A = H(n.maxHeight), D = H(n.maxWidth), G = Number(n.viewportGap ?? 5), U = Number.isFinite(G) ? Math.max(0, G) : 5, W = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
94
- return We(/* @__PURE__ */ u(
127
+ const g = n.backgroundColor ?? n.backgroudColor, i = typeof g == "string" ? g : g?.[w], s = typeof i == "string" && /^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(i.trim()) ? i : null, B = { sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }, R = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", A = (b) => typeof b == "number" ? `${b}px` : b, q = A(n.width ?? B[n.size] ?? 460), $ = A(n.height), E = A(n.maxHeight), z = A(n.maxWidth), U = Number(n.viewportGap ?? 5), W = Number.isFinite(U) ? Math.max(0, U) : 5, M = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
128
+ return dn(/* @__PURE__ */ h(
95
129
  "div",
96
130
  {
97
- ref: b,
98
- className: `pmn-overlay ${s ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${N} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
99
- style: { padding: U, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
100
- onMouseDown: (F) => {
101
- F.target === F.currentTarget && n.closeOnOverlay === !0 && R.current("overlay");
131
+ ref: f,
132
+ className: `pmn-overlay ${c ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${R} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
133
+ style: { padding: W, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
134
+ onMouseDown: (b) => {
135
+ b.target === b.currentTarget && n.closeOnOverlay === !0 && u.current("overlay");
102
136
  },
103
- children: /* @__PURE__ */ u(
137
+ children: /* @__PURE__ */ h(
104
138
  "section",
105
139
  {
106
140
  ref: e,
@@ -108,62 +142,80 @@ function Xe({ dialogRef: e, options: n, requestClose: r, children: o, exiting: s
108
142
  role: "dialog",
109
143
  "aria-modal": "true",
110
144
  "aria-label": n.ariaLabel ?? "Dialog",
111
- "data-modal-theme": x,
112
- className: `pmn-dialog ${x === "dark" ? "dark" : ""} ${!g && l ? l : ""} ${n.className ?? ""}`,
113
- style: { "--pmn-width": C, "--pmn-gap": `${U}px`, ...L !== void 0 ? { "--pmn-height": L } : {}, ...A !== void 0 ? { "--pmn-max-height": A } : {}, ...D !== void 0 ? { "--pmn-max-width": D } : {}, borderRadius: W, ...g ? { backgroundColor: g } : {} },
114
- children: o
145
+ "data-modal-theme": w,
146
+ className: `pmn-dialog ${w === "dark" ? "dark" : ""} ${!s && i ? i : ""} ${n.className ?? ""}`,
147
+ style: { "--pmn-width": q, "--pmn-gap": `${W}px`, ...$ !== void 0 ? { "--pmn-height": $ } : {}, ...E !== void 0 ? { "--pmn-max-height": E } : {}, ...z !== void 0 ? { "--pmn-max-width": z } : {}, borderRadius: M, ...s ? { backgroundColor: s } : {} },
148
+ children: t
115
149
  }
116
150
  )
117
151
  }
118
152
  ), document.body);
119
153
  }
120
- function qe({ back: e }) {
121
- return /* @__PURE__ */ u("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ u("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ u("path", { d: "M18 6 6 18M6 6l12 12" }) });
154
+ function Xe({ back: e }) {
155
+ return /* @__PURE__ */ h("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ h("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ h("path", { d: "M18 6 6 18M6 6l12 12" }) });
122
156
  }
123
- function Ze({ options: e, screen: n, route: r, navigation: o, requestClose: s, translate: b }) {
157
+ function kn({ options: e, screen: n, route: r, navigation: t, requestClose: c, translate: f, canGoBack: l }) {
124
158
  if (e.showHeader === !1) return null;
125
- const y = b ?? ((w) => w), R = n.showTitle ?? e.showTitle ?? !0, f = typeof n.title == "function" ? n.title({ t: y, route: r, navigation: o }) : n.title ?? r.name, k = { route: r, navigation: o, close: s, canGoBack: o.canGoBack, title: f, t: y }, S = n.renderHeader ?? e.renderHeader;
126
- if (S) return S(k);
127
- const x = n.renderHeaderRight ?? e.renderHeaderRight;
128
- return /* @__PURE__ */ ie("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
129
- e.showBackButton !== !1 && o.canGoBack && /* @__PURE__ */ u("button", { type: "button", className: "pmn-icon-button", "aria-label": y("modal.back"), onClick: () => o.goBack(), children: /* @__PURE__ */ u(qe, { back: !0 }) }),
130
- R ? /* @__PURE__ */ u("h2", { children: f }) : /* @__PURE__ */ u("div", { className: "pmn-header-spacer" }),
131
- x?.(k),
132
- e.showCloseButton !== !1 && /* @__PURE__ */ u("button", { type: "button", className: "pmn-icon-button", "aria-label": y("modal.close"), onClick: () => s("header"), children: /* @__PURE__ */ u(qe, {}) })
159
+ const u = f ?? ((i) => i), d = n.showTitle ?? e.showTitle ?? !0, y = typeof n.title == "function" ? n.title({ t: u, route: r, navigation: t }) : n.title ?? r.name, C = { route: r, navigation: t, close: c, canGoBack: l, title: y, t: u }, w = n.renderHeader ?? e.renderHeader;
160
+ if (w) return w(C);
161
+ const g = n.renderHeaderRight ?? e.renderHeaderRight;
162
+ return /* @__PURE__ */ me("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
163
+ (n.showBackButton ?? e.showBackButton) !== !1 && l && /* @__PURE__ */ h("button", { type: "button", className: "pmn-icon-button", "aria-label": u("modal.back"), onClick: () => t.goBack(), children: /* @__PURE__ */ h(Xe, { back: !0 }) }),
164
+ d ? /* @__PURE__ */ h("h2", { children: y }) : /* @__PURE__ */ h("div", { className: "pmn-header-spacer" }),
165
+ g?.(C),
166
+ e.showCloseButton !== !1 && /* @__PURE__ */ h("button", { type: "button", className: "pmn-icon-button", "aria-label": u("modal.close"), onClick: () => c("header"), children: /* @__PURE__ */ h(Xe, {}) })
133
167
  ] });
134
168
  }
135
- function en({ screen: e, options: n, override: r, route: o, navigation: s, requestClose: b, translate: y, onError: R, loadingApi: f }) {
136
- const [k, S] = X(!1), x = y ?? ((G) => G), w = { ...n, ...e, ...r }, { showFooter: l, renderFooter: g, done: O, cancel: N, cancle: H } = w, C = N ?? H, L = { route: o, navigation: s, close: b, t: x };
137
- if (l === !1) return null;
138
- const A = `pmn-footer ${w.showFooterBorder ? "pmn-border-top" : ""} ${w.footerClassName ?? ""}`;
139
- if (typeof g == "function") return /* @__PURE__ */ u("footer", { className: A, children: g({ ...L, pending: k }) });
140
- if (typeof O != "function" && typeof C != "function") return null;
141
- const D = async (G) => {
142
- if (k || typeof G != "function") return;
143
- S(!0);
144
- const U = f?.begin(o.key, w.loadingText ?? x("modal.processing"));
169
+ function En({ screen: e, options: n, override: r, route: t, navigation: c, requestClose: f, translate: l, onError: u, loadingApi: d }) {
170
+ const [y, C] = ie(null), w = m(/* @__PURE__ */ new Set()), g = m(!0);
171
+ H(() => (g.current = !0, () => {
172
+ g.current = !1;
173
+ }), []);
174
+ const i = l ?? ((b) => b), s = { ...n, ...e, ...r }, { showFooter: B, renderFooter: R, done: A, cancel: q, cancle: $ } = s, E = q ?? $, z = { route: t, navigation: c, close: f, t: i };
175
+ if (B === !1) return null;
176
+ const U = `pmn-footer ${s.showFooterBorder ? "pmn-border-top" : ""} ${s.footerClassName ?? ""}`;
177
+ if (typeof R == "function") return /* @__PURE__ */ h("footer", { className: U, children: R({ ...z, pending: w.current.size > 0 }) });
178
+ const W = Array.isArray(s.actions) ? s.actions : null;
179
+ if (!W && typeof A != "function" && typeof E != "function") return null;
180
+ const M = async (b, T, j) => {
181
+ if (w.current.has(b) || typeof T != "function") return;
182
+ w.current.add(b), C(b);
183
+ const F = d?.begin(t.key, j ?? s.loadingText ?? i("modal.processing"));
145
184
  try {
146
- await G(L);
147
- } catch (W) {
148
- R?.(W, { phase: "footer", route: o });
185
+ await T(z);
186
+ } catch (N) {
187
+ u?.(N, { phase: "footer", action: b, route: t });
149
188
  } finally {
150
- f?.end(o.key, U), S(!1);
189
+ d?.end(t.key, F), w.current.delete(b), g.current && C((N) => N === b ? null : N);
151
190
  }
152
191
  };
153
- return /* @__PURE__ */ ie("footer", { className: A, children: [
154
- typeof C == "function" && /* @__PURE__ */ u("button", { type: "button", disabled: k, onClick: () => D(C), className: "pmn-button pmn-button-secondary", children: w.cancelText ?? x("modal.cancel") }),
155
- typeof O == "function" && /* @__PURE__ */ u("button", { type: "button", disabled: k || w.doneDisabled === !0, onClick: () => D(O), className: "pmn-button pmn-button-primary", children: k ? w.loadingText ?? x("modal.processing") : w.doneText ?? x("modal.done") })
192
+ return W ? /* @__PURE__ */ h("footer", { className: U, children: W.filter((b) => !b.hidden).map((b) => {
193
+ const T = w.current.has(b.key) || b.loading === !0;
194
+ return /* @__PURE__ */ h(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ disabled: b.disabled === !0 || T,
199
+ className: `pmn-button ${b.variant === "primary" || b.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${b.variant === "danger" ? "pmn-button-danger" : ""}`,
200
+ onClick: () => M(b.key, b.onClick, b.loadingText),
201
+ children: T ? b.loadingText ?? s.loadingText ?? i("modal.processing") : b.label
202
+ },
203
+ b.key
204
+ );
205
+ }) }) : /* @__PURE__ */ me("footer", { className: U, children: [
206
+ typeof E == "function" && /* @__PURE__ */ h("button", { type: "button", disabled: y !== null, onClick: () => M("cancel", E), className: "pmn-button pmn-button-secondary", children: s.cancelText ?? i("modal.cancel") }),
207
+ typeof A == "function" && /* @__PURE__ */ h("button", { type: "button", disabled: y !== null || s.doneDisabled === !0, onClick: () => M("done", A), className: "pmn-button pmn-button-primary", children: y === "done" ? s.loadingText ?? i("modal.processing") : s.doneText ?? i("modal.done") })
156
208
  ] });
157
209
  }
158
- function nn({ loading: e, translate: n }) {
210
+ function Sn({ loading: e, translate: n }) {
159
211
  if (!e.visible) return null;
160
- const o = (n ?? ((b) => b))("modal.loading"), s = e.text ?? (o === "modal.loading" ? "加载中..." : o);
161
- return /* @__PURE__ */ u("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ ie("div", { className: "pmn-loading-content", children: [
162
- /* @__PURE__ */ u("span", { className: "pmn-spinner", "aria-hidden": "true" }),
163
- s && /* @__PURE__ */ u("span", { className: "pmn-loading-text", children: s })
212
+ const t = (n ?? ((f) => f))("modal.loading"), c = e.text ?? (t === "modal.loading" ? "加载中..." : t);
213
+ return /* @__PURE__ */ h("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ me("div", { className: "pmn-loading-content", children: [
214
+ /* @__PURE__ */ h("span", { className: "pmn-spinner", "aria-hidden": "true" }),
215
+ c && /* @__PURE__ */ h("span", { className: "pmn-loading-text", children: c })
164
216
  ] }) });
165
217
  }
166
- class tn extends He.Component {
218
+ class Cn extends Ne.Component {
167
219
  state = { error: null };
168
220
  static getDerivedStateFromError(n) {
169
221
  return { error: n };
@@ -175,516 +227,667 @@ class tn extends He.Component {
175
227
  n.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
176
228
  }
177
229
  render() {
178
- return this.state.error ? /* @__PURE__ */ ie("div", { role: "alert", className: "pmn-error-screen", children: [
179
- /* @__PURE__ */ u("strong", { children: "页面加载失败" }),
180
- /* @__PURE__ */ u("p", { children: this.state.error.message }),
181
- /* @__PURE__ */ u("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => this.setState({ error: null }), children: "重试" })
230
+ return this.state.error ? /* @__PURE__ */ me("div", { role: "alert", className: "pmn-error-screen", children: [
231
+ /* @__PURE__ */ h("strong", { children: "页面加载失败" }),
232
+ /* @__PURE__ */ h("p", { children: this.state.error.message }),
233
+ /* @__PURE__ */ h("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => this.setState({ error: null }), children: "重试" })
182
234
  ] }) : this.props.children;
183
235
  }
184
236
  }
185
- const rn = { success: "✓", error: "×", warning: "!", info: "i" };
186
- function on({ items: e, dismiss: n }) {
187
- return e.length ? /* @__PURE__ */ u("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((r) => /* @__PURE__ */ ie("div", { className: `pmn-toast pmn-toast-${r.type}`, role: r.type === "error" || r.type === "warning" ? "alert" : "status", children: [
188
- /* @__PURE__ */ u("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: rn[r.type] }),
189
- /* @__PURE__ */ u("span", { className: "pmn-toast-message", children: r.message }),
190
- r.dismissible && /* @__PURE__ */ u("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => n(r.id), children: "×" })
237
+ const Rn = { success: "✓", error: "×", warning: "!", info: "i" };
238
+ function Mn({ items: e, dismiss: n }) {
239
+ return e.length ? /* @__PURE__ */ h("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((r) => /* @__PURE__ */ me("div", { className: `pmn-toast pmn-toast-${r.type}`, role: r.type === "error" || r.type === "warning" ? "alert" : "status", children: [
240
+ /* @__PURE__ */ h("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: Rn[r.type] }),
241
+ /* @__PURE__ */ h("span", { className: "pmn-toast-message", children: r.message }),
242
+ r.dismissible && /* @__PURE__ */ h("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => n(r.id), children: "×" })
191
243
  ] }, r.id)) }) : null;
192
244
  }
193
- function an({ route: e, screen: n, navigation: r, focused: o, resultEvent: s, setFooter: b, loadingApi: y, bodyClassName: R, notifyError: f, registerDirtyGuard: k }) {
194
- const S = n.component, x = ne(() => ({ isFocused: o, resultEvent: s, routeKey: e.key, setFooter: b }), [o, s, e.key, b]), w = ne(() => ({
195
- isLoading: o && y.isLoading,
196
- setLoading: (l, g) => y.setScreenLoading(e.key, l, g),
197
- showLoading: (l) => y.begin(e.key, l),
198
- hideLoading: (l) => y.end(e.key, l)
199
- }), [o, y, e.key]);
200
- return /* @__PURE__ */ u(De.Provider, { value: { routeKey: e.key, registerDirtyGuard: k }, children: /* @__PURE__ */ u(Me.Provider, { value: x, children: /* @__PURE__ */ u(Pe.Provider, { value: w, children: /* @__PURE__ */ u("div", { hidden: !o, inert: !o, "data-modal-route-key": e.key, tabIndex: -1, className: `pmn-body ${R ?? ""}`, children: /* @__PURE__ */ u(tn, { route: e, onError: f, children: /* @__PURE__ */ u(S, { route: e, navigation: r }) }) }) }) }) });
201
- }
202
- function sn({ config: e, initialScreen: n, params: r, options: o, translate: s, onRequestClose: b, onOpened: y, registerLoading: R, notifyError: f, error: k, clearError: S, registerDirtyGuard: x, exiting: w = !1 }) {
203
- const [l, g] = Ge(_e, null, () => $e(n ?? e.initialRoute, r)), [O, N] = X([]), H = m(0), C = m(/* @__PURE__ */ new Map()), L = p((t) => {
204
- clearTimeout(C.current.get(t)), C.current.delete(t), N((i) => i.filter((d) => d.id !== t));
205
- }, []), A = p((t, i = {}) => {
206
- if (typeof t != "string" || !t.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
207
- const d = typeof i == "string" ? { type: i } : i ?? {}, V = ["success", "error", "warning", "info"].includes(d.type) ? d.type : "info", Te = ++H.current, Be = Number.isFinite(d.duration) ? Math.max(0, d.duration) : 3e3;
208
- return N((ze) => [...ze, { id: Te, message: t, type: V, dismissible: d.dismissible !== !1 }].slice(-5)), Be > 0 && C.current.set(Te, setTimeout(() => L(Te), Be)), Te;
209
- }, [L]), D = ne(() => {
210
- const t = (i, d) => A(i, d);
211
- for (const i of ["success", "error", "warning", "info"]) t[i] = (d, V = {}) => A(d, { ...V, type: i });
212
- return t.dismiss = L, t.clear = () => {
213
- for (const i of C.current.values()) clearTimeout(i);
214
- C.current.clear(), N([]);
215
- }, t;
216
- }, [A, L]);
217
- z(() => () => {
218
- for (const t of C.current.values()) clearTimeout(t);
219
- C.current.clear();
220
- }, []);
221
- const [G, U] = X({}), [W, F] = X({}), [, Y] = X(0), P = m(/* @__PURE__ */ new Map()), oe = m(0), E = m(/* @__PURE__ */ new Map()), T = m(null), B = m(null), Z = m(!1), j = m(!1), pe = m(0), M = l.at(-1), $ = M.key, be = m($);
222
- be.current = $;
223
- const _ = e.screens, J = p(() => Y((t) => t + 1), []), ae = p((t, i) => {
224
- if (t !== "global" && be.current !== t) return null;
225
- const d = ++oe.current;
226
- return P.current.set(d, { owner: t, text: i }), J(), d;
227
- }, [J]), ee = p((t, i) => {
245
+ function Tn(e, n) {
246
+ const r = m(0), t = m(/* @__PURE__ */ new Map()), c = v((u) => {
247
+ clearTimeout(t.current.get(u)), t.current.delete(u), n.current && e.current.publish(e.current.getSnapshot().filter((d) => d.id !== u));
248
+ }, []), f = v((u, d = {}) => {
249
+ if (typeof u != "string" || !u.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
250
+ const y = typeof d == "string" ? { type: d } : d ?? {}, C = ["success", "error", "warning", "info"].includes(y.type) ? y.type : "info", w = ++r.current, g = Number.isFinite(y.duration) ? Math.max(0, y.duration) : 3e3;
251
+ if (!n.current) return null;
252
+ const i = e.current.getSnapshot(), s = i.slice(0, Math.max(0, i.length - 4));
253
+ for (const B of s)
254
+ clearTimeout(t.current.get(B.id)), t.current.delete(B.id);
255
+ return e.current.publish([...i.slice(-4), { id: w, message: u, type: C, dismissible: y.dismissible !== !1 }]), g > 0 && t.current.set(w, setTimeout(() => c(w), g)), w;
256
+ }, [c]), l = K(() => {
257
+ const u = (d, y) => f(d, y);
258
+ for (const d of ["success", "error", "warning", "info"]) u[d] = (y, C = {}) => f(y, { ...C, type: d });
259
+ return u.promise = async (d, y, C = {}) => {
260
+ const w = f(y.loading, { ...C, type: "info", duration: 0 });
261
+ try {
262
+ const g = await (typeof d == "function" ? d() : d);
263
+ w != null && c(w);
264
+ const i = typeof y.success == "function" ? y.success(g) : y.success;
265
+ return i && f(i, { ...C, type: "success" }), g;
266
+ } catch (g) {
267
+ w != null && c(w);
268
+ const i = typeof y.error == "function" ? y.error(g) : y.error;
269
+ throw i && f(i, { ...C, type: "error" }), g;
270
+ }
271
+ }, u.dismiss = c, u.clear = () => {
272
+ for (const d of t.current.values()) clearTimeout(d);
273
+ t.current.clear(), e.current.publish([]);
274
+ }, u;
275
+ }, [f, c]);
276
+ return H(() => () => {
277
+ for (const u of t.current.values()) clearTimeout(u);
278
+ t.current.clear();
279
+ }, []), { toast: l, dismissToast: c };
280
+ }
281
+ function Nn(e, n, r) {
282
+ const t = m(/* @__PURE__ */ new Map()), c = m(0), f = v(() => {
283
+ if (!n.current) return;
284
+ const g = [...t.current.values()], i = { visible: g.length > 0, text: g.at(-1)?.text ?? null, count: g.length }, s = e.current.getSnapshot();
285
+ (s.visible !== i.visible || s.text !== i.text || s.count !== i.count) && e.current.publish(i);
286
+ }, []), l = v((g, i) => {
287
+ if (!n.current || g !== "global" && r.current !== g) return null;
288
+ const s = ++c.current;
289
+ return t.current.set(s, { owner: g, text: i }), f(), s;
290
+ }, [f]), u = v((g, i) => {
228
291
  if (i != null)
229
- P.current.get(i)?.owner === t && P.current.delete(i);
292
+ t.current.get(i)?.owner === g && t.current.delete(i);
230
293
  else
231
- for (const [d, V] of P.current) V.owner === t && P.current.delete(d);
232
- J();
233
- }, [J]), te = p((t, i) => {
234
- t ? (ee("global"), ae("global", i)) : ee("global");
235
- }, [ae, ee]), ve = p((t, i, d) => {
236
- i ? (ee(t), ae(t, d)) : ee(t);
237
- }, [ae, ee]), fe = [...P.current.values()], se = { visible: fe.length > 0, text: fe.at(-1)?.text ?? null, count: fe.length }, xe = m(se);
238
- xe.current = se;
239
- const he = ne(() => ({ isLoading: se.visible, setLoading: te, setScreenLoading: ve, begin: ae, end: ee }), [se.visible, te, ve, ae, ee]), ge = m(R);
240
- ge.current = R, z(() => (ge.current?.({ setLoading: te }), () => ge.current?.(null)), [te]);
241
- const ke = p((t, i) => F((d) => {
242
- if (i === null) {
243
- if (!(t in d)) return d;
244
- const V = { ...d };
245
- return delete V[t], V;
294
+ for (const [s, B] of t.current) B.owner === g && t.current.delete(s);
295
+ f();
296
+ }, [f]), d = v((g, i) => {
297
+ g ? (u("global"), l("global", i)) : u("global");
298
+ }, [l, u]), y = v((g, i, s) => {
299
+ i ? (u(g), l(g, s)) : u(g);
300
+ }, [l, u]);
301
+ return { loadingApi: K(() => ({ setLoading: d, setScreenLoading: y, begin: l, end: u }), [d, y, l, u]), refreshLoading: f, loadingTasks: t, setLoading: d };
302
+ }
303
+ const Pn = Ne.memo(function({ store: n, translate: r }) {
304
+ const t = be(n.subscribe, n.getSnapshot, n.getSnapshot);
305
+ return /* @__PURE__ */ h(Sn, { loading: t, translate: r });
306
+ }), Ln = Ne.memo(function({ store: n, dismiss: r }) {
307
+ const t = be(n.subscribe, n.getSnapshot, n.getSnapshot);
308
+ return /* @__PURE__ */ h(Mn, { items: t, dismiss: r });
309
+ }), Bn = Ne.memo(function({ store: n, routeKey: r, ...t }) {
310
+ const c = be(n.subscribe, n.getSnapshot, n.getSnapshot);
311
+ return /* @__PURE__ */ h(En, { ...t, override: c[r] });
312
+ }), An = Ne.memo(function({ route: n, screen: r, navigation: t, focused: c, resultEvent: f, setFooter: l, loadingApi: u, loadingStore: d, bodyClassName: y, notifyError: C, registerDirtyGuard: w }) {
313
+ const g = r.component, i = K(() => ({ isFocused: c, resultEvent: f, routeKey: n.key, setFooter: l }), [c, f, n.key, l]), s = K(() => ({
314
+ setLoading: (R, A) => u.setScreenLoading(n.key, R, A),
315
+ showLoading: (R) => u.begin(n.key, R),
316
+ hideLoading: (R) => u.end(n.key, R)
317
+ }), [u, n.key]), B = K(() => ({ routeKey: n.key, registerDirtyGuard: w }), [n.key, w]);
318
+ return /* @__PURE__ */ h(on.Provider, { value: n, children: /* @__PURE__ */ h(tn.Provider, { value: B, children: /* @__PURE__ */ h(je.Provider, { value: i, children: /* @__PURE__ */ h(Fe.Provider, { value: s, children: /* @__PURE__ */ h(Ye.Provider, { value: d, children: /* @__PURE__ */ h("div", { hidden: !c, inert: !c, "data-modal-route-key": n.key, tabIndex: -1, className: `pmn-body ${y ?? ""}`, children: /* @__PURE__ */ h(Cn, { route: n, onError: C, children: /* @__PURE__ */ h(g, { route: n, navigation: t }) }) }) }) }) }) }) });
319
+ });
320
+ function qn({ config: e, initialScreen: n, params: r, options: t, translate: c, onRequestClose: f, onOpened: l, registerLoading: u, notifyError: d, error: y, clearError: C, registerDirtyGuard: w, canNavigate: g, exiting: i = !1 }) {
321
+ const [s, B] = ln(qe, null, () => an(n ?? e.initialRoute, r)), R = m(null);
322
+ R.current || (R.current = hn({ canGoBack: s.length > 1, stack: s, currentRoute: s.at(-1) }));
323
+ const A = m(null), q = m(null), $ = m(null);
324
+ A.current || (A.current = ze({ visible: !1, text: null, count: 0 })), q.current || (q.current = ze({})), $.current || ($.current = ze([]));
325
+ const E = m(!0), z = m(0), { toast: U, dismissToast: W } = Tn($, E);
326
+ H(() => (E.current = !0, () => {
327
+ E.current = !1, z.current++;
328
+ }), []);
329
+ const [M, b] = ie({}), T = m(/* @__PURE__ */ new Map()), j = m(null), F = m(null), N = m(!1), V = m(!1), L = m(/* @__PURE__ */ new Map()), ne = m(0), te = v((o, x, P) => {
330
+ for (const [I, ce] of L.current)
331
+ o.includes(ce.key) && (L.current.delete(I), ce.resolve({ status: x, ...x === "returned" ? { value: P } : {} }));
332
+ }, []), O = m(s);
333
+ O.current = s;
334
+ const le = m(g);
335
+ le.current = g;
336
+ const re = m(!1), Ee = m(0), G = s.at(-1), D = G.key, ue = m(D);
337
+ ue.current = D;
338
+ const { loadingApi: Se, refreshLoading: Ce, loadingTasks: ye, setLoading: pe } = Nn(A, E, ue), oe = e.screens, Pe = A, ve = m(u);
339
+ ve.current = u, H(() => (ve.current?.({ setLoading: pe }), () => ve.current?.(null)), [pe]);
340
+ const Le = v((o, x) => {
341
+ if (!E.current) return;
342
+ const P = q.current.getSnapshot();
343
+ if (x === null) {
344
+ if (!(o in P)) return;
345
+ const I = { ...P };
346
+ delete I[o], q.current.publish(I);
347
+ return;
246
348
  }
247
- return d[t] === i ? d : { ...d, [t]: i };
248
- }), []), ce = p(() => {
249
- const t = document.activeElement;
250
- if (!(t instanceof HTMLElement) || !T.current?.contains(t)) return;
251
- const i = t.closest("[data-modal-route-key]");
252
- i && E.current.set(i.dataset.modalRouteKey, t), T.current.focus({ preventScroll: !0 });
253
- }, []), Ee = p((t) => {
254
- if (!Object.prototype.hasOwnProperty.call(_, t)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${t}`);
255
- }, [_]), a = p((t, i) => {
349
+ P[o] !== x && q.current.publish({ ...P, [o]: x });
350
+ }, []), Re = v(() => {
351
+ if (typeof document > "u") return;
352
+ const o = document.activeElement;
353
+ if (!(o instanceof HTMLElement) || !j.current?.contains(o)) return;
354
+ const x = o.closest("[data-modal-route-key]");
355
+ x && T.current.set(x.dataset.modalRouteKey, o), j.current.focus({ preventScroll: !0 });
356
+ }, []), Me = v((o) => {
357
+ if (!Object.prototype.hasOwnProperty.call(oe, o)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${o}`);
358
+ }, [oe]), de = v((o, x) => {
256
359
  try {
257
- Promise.resolve(o[t]?.(i)).catch((d) => f(d, { phase: t }));
258
- } catch (d) {
259
- f(d, { phase: t });
360
+ Promise.resolve(t[o]?.(x)).catch((P) => d(P, { phase: o }));
361
+ } catch (P) {
362
+ d(P, { phase: o });
260
363
  }
261
- }, [o, f]), c = p((t, i, d) => {
262
- Ee(i), ce(), g({ type: t, name: i, params: d });
263
- }, [Ee, ce]), v = p((t, i) => c("NAVIGATE", t, i), [c]), h = p((t, i) => c("REPLACE", t, i), [c]), I = p((t, i) => {
264
- U({}), c("RESET", t, i);
265
- }, [c]), q = p((t) => {
266
- if (!t || typeof t != "object" || Array.isArray(t)) throw new TypeError("[react-modal-navigation] setParams expects an object");
267
- g({ type: "SET_PARAMS", params: t });
268
- }, []), K = p((t) => {
269
- if (!t || typeof t != "object" || Array.isArray(t)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
270
- g({ type: "SET_OPTIONS", options: t });
271
- }, []), le = p((t) => {
272
- if (l.length <= 1 || Z.current) return !1;
273
- if (Z.current = !0, t !== void 0) {
274
- const i = l.at(-2);
275
- U((d) => ({ ...d, [i.key]: { id: ++pe.current, data: t } }));
364
+ }, [t, d]), Z = v(async (o, x, P, I) => {
365
+ if (!E.current || V.current) return !1;
366
+ const ce = z.current, X = O.current, De = X.at(-1);
367
+ if (o !== "BACK" && Me(x), o === "BACK" && X.length <= 1) return !1;
368
+ const Ve = o === "NAVIGATE" ? X.findIndex((ke) => ke.name === x) : -1, Ie = o === "RESET" ? X : o === "BACK" || o === "REPLACE" ? [De] : Ve >= 0 ? X.slice(Ve + 1) : [];
369
+ V.current = !0;
370
+ try {
371
+ if (Ie.length && le.current && !await le.current(Ie.map(($e) => $e.key), {
372
+ reason: "navigation",
373
+ action: o,
374
+ from: De,
375
+ to: o === "BACK" ? X.at(-2)?.name : x
376
+ }) || !E.current || ce !== z.current || O.current.at(-1)?.key !== De.key) return !1;
377
+ if (o === "BACK" && I !== void 0) {
378
+ const Ae = X.at(-2);
379
+ b(($e) => ({ ...$e, [Ae.key]: { id: ++Ee.current, data: I } }));
380
+ }
381
+ o === "RESET" && b({}), te(Ie.map((Ae) => Ae.key), o === "BACK" ? "returned" : "removed", I), Re();
382
+ const ke = { type: o, name: x, params: P };
383
+ return O.current = qe(O.current, ke), B(ke), !0;
384
+ } catch (ke) {
385
+ return E.current && d(ke, { phase: "navigationGuard", action: o }), !1;
386
+ } finally {
387
+ V.current = !1;
276
388
  }
277
- return ce(), g({ type: "BACK" }), !0;
278
- }, [l, ce]), Q = p((t, i) => xe.current.visible && o.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : b(t, i, { route: M, stack: l }), [o.lockCloseWhileLoading, b, M, l]), ue = p((t) => Q("api", t), [Q]), de = ne(() => ({ navigate: v, replace: h, reset: I, setParams: q, setOptions: K, goBack: le, close: ue, setLoading: te, canGoBack: l.length > 1, stack: l, currentRoute: M }), [v, h, I, q, K, le, ue, te, l, M]);
279
- return Ke(() => {
280
- Z.current = !1;
281
- const t = [...T.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((V) => V.dataset.modalRouteKey === $);
282
- if (!t) return;
283
- const i = E.current.get($);
284
- (i?.isConnected && t.contains(i) && !i.matches(":disabled") && !i.closest("[inert], [hidden]") ? i : t).focus({ preventScroll: !0 });
285
- }, [$]), z(() => {
286
- let t = !1;
287
- for (const [d, V] of P.current)
288
- V.owner !== "global" && V.owner !== $ && (P.current.delete(d), t = !0);
289
- t && J();
290
- const i = new Set(l.map((d) => d.key));
291
- for (const d of E.current.keys()) i.has(d) || E.current.delete(d);
292
- }, [$, l, J]), z(() => {
293
- if (B.current?.key !== $) {
294
- if (B.current) {
295
- const t = { from: B.current, to: M, stack: l };
296
- a("onBlur", { route: B.current, ...t }), a("onNavigate", t), a("onRouteChange", t);
389
+ }, [Me, Re, d, te]), a = v((o, x) => Z("NAVIGATE", o, x), [Z]), p = v(async (o, x) => {
390
+ if (!E.current) return { status: "cancelled" };
391
+ if (O.current, !await Z("NAVIGATE", o, x) || !E.current) return { status: "cancelled" };
392
+ const I = O.current.at(-1);
393
+ return !I || I.name !== o ? { status: "cancelled" } : new Promise((ce) => {
394
+ const X = ++ne.current;
395
+ L.current.set(X, { key: I.key, resolve: ce });
396
+ });
397
+ }, [Z]), S = v((o, x) => Z("REPLACE", o, x), [Z]), k = v((o, x) => Z("RESET", o, x), [Z]), Y = v((o) => {
398
+ if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setParams expects an object");
399
+ if (!E.current) return;
400
+ const x = { type: "SET_PARAMS", params: o };
401
+ O.current = qe(O.current, x), B(x);
402
+ }, []), _ = v((o) => {
403
+ if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
404
+ if (!E.current) return;
405
+ const x = { type: "SET_OPTIONS", options: o };
406
+ O.current = qe(O.current, x), B(x);
407
+ }, []), J = v((o) => Z("BACK", null, void 0, o), [Z]), ae = v((o, x) => !E.current || Pe.current.getSnapshot().visible && t.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : f(o, x, { route: G, stack: s }), [t.lockCloseWhileLoading, f, G, s]), se = m(ae);
408
+ se.current = ae;
409
+ const fe = v((o) => se.current("api", o), []), we = K(() => ({ navigate: a, navigateAsync: p, replace: S, reset: k, setParams: Y, setOptions: _, goBack: J, close: fe, setLoading: pe }), [a, p, S, k, Y, _, J, fe, pe]), xe = K(() => ({ canGoBack: s.length > 1, stack: s, currentRoute: G }), [s]);
410
+ Qe(() => R.current.publish(xe), [xe]);
411
+ const he = m(null);
412
+ he.current || (he.current = Object.defineProperties({}, {
413
+ canGoBack: { enumerable: !0, get: () => R.current.getSnapshot().canGoBack },
414
+ stack: { enumerable: !0, get: () => R.current.getSnapshot().stack },
415
+ currentRoute: { enumerable: !0, get: () => R.current.getSnapshot().currentRoute }
416
+ }));
417
+ const Be = K(() => Object.assign(he.current, we), [we]);
418
+ Qe(() => {
419
+ N.current = !1;
420
+ const o = [...j.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((I) => I.dataset.modalRouteKey === D);
421
+ if (!o) return;
422
+ const x = T.current.get(D);
423
+ (x?.isConnected && o.contains(x) && !x.matches(":disabled") && !x.closest("[inert], [hidden]") ? x : o).focus({ preventScroll: !0 });
424
+ }, [D]), H(() => {
425
+ let o = !1;
426
+ for (const [P, I] of ye.current)
427
+ I.owner !== "global" && I.owner !== D && (ye.current.delete(P), o = !0);
428
+ o && Ce();
429
+ const x = new Set(s.map((P) => P.key));
430
+ b((P) => {
431
+ const I = Object.keys(P).filter((X) => !x.has(X));
432
+ if (!I.length) return P;
433
+ const ce = { ...P };
434
+ return I.forEach((X) => delete ce[X]), ce;
435
+ });
436
+ for (const P of T.current.keys()) x.has(P) || T.current.delete(P);
437
+ }, [D, s, Ce]), H(() => {
438
+ if (F.current?.key !== D) {
439
+ if (F.current) {
440
+ const o = { from: F.current, to: G, stack: s };
441
+ de("onBlur", { route: F.current, ...o }), de("onNavigate", o), de("onRouteChange", o);
297
442
  }
298
- a("onFocus", { route: M, stack: l }), B.current = M;
443
+ de("onFocus", { route: G, stack: s }), F.current = G;
299
444
  }
300
- }, [M, $, l, a]), z(() => () => {
301
- P.current.clear(), E.current.clear();
302
- }, []), z(() => {
303
- j.current || (j.current = !0, y?.({ route: M, stack: l }));
304
- }, []), /* @__PURE__ */ u(je.Provider, { value: D, children: /* @__PURE__ */ u(Le.Provider, { value: de, children: /* @__PURE__ */ u(Pe.Provider, { value: he, children: /* @__PURE__ */ ie(Xe, { dialogRef: T, options: o, requestClose: Q, exiting: w, children: [
305
- /* @__PURE__ */ u(Ze, { options: o, screen: { ..._[M.name], ...M.options ?? {} }, route: M, navigation: de, requestClose: Q, translate: s }),
306
- /* @__PURE__ */ u("main", { className: "pmn-main", children: l.map((t) => /* @__PURE__ */ u(
307
- an,
445
+ }, [G, D, s, de]), H(() => () => {
446
+ ye.current.clear(), T.current.clear();
447
+ for (const o of L.current.values()) o.resolve({ status: "dismissed" });
448
+ L.current.clear();
449
+ }, []), H(() => {
450
+ re.current || (re.current = !0, l?.({ route: G, stack: s }));
451
+ }, []);
452
+ const cn = K(() => bn(s, oe, t.maxCachedScreens), [s, oe, t.maxCachedScreens]), _e = K(() => ({ ...oe[G.name], ...G.options ?? {} }), [oe, G.name, G.options]);
453
+ return /* @__PURE__ */ h(rn.Provider, { value: U, children: /* @__PURE__ */ h(fn.Provider, { value: $.current, children: /* @__PURE__ */ h(pn.Provider, { value: q.current, children: /* @__PURE__ */ h(mn.Provider, { value: Be, children: /* @__PURE__ */ h(Ue.Provider, { value: we, children: /* @__PURE__ */ h(We.Provider, { value: R.current, children: /* @__PURE__ */ h(Fe.Provider, { value: Se, children: /* @__PURE__ */ me(xn, { dialogRef: j, options: t, requestClose: ae, exiting: i, children: [
454
+ /* @__PURE__ */ h(kn, { options: t, screen: _e, route: G, navigation: Be, requestClose: ae, translate: c, canGoBack: s.length > 1 }),
455
+ /* @__PURE__ */ h("main", { className: "pmn-main", children: cn.map((o) => /* @__PURE__ */ h(
456
+ An,
308
457
  {
309
- route: t,
310
- screen: _[t.name],
311
- navigation: de,
312
- focused: t.key === $,
313
- resultEvent: G[t.key] ?? null,
314
- bodyClassName: o.bodyClassName,
315
- setFooter: ke,
316
- loadingApi: he,
317
- notifyError: f,
318
- registerDirtyGuard: x
458
+ route: o,
459
+ screen: oe[o.name],
460
+ navigation: Be,
461
+ focused: o.key === D,
462
+ resultEvent: M[o.key] ?? null,
463
+ bodyClassName: t.bodyClassName,
464
+ setFooter: Le,
465
+ loadingApi: Se,
466
+ loadingStore: A.current,
467
+ notifyError: d,
468
+ registerDirtyGuard: w
319
469
  },
320
- t.key
470
+ o.key
321
471
  )) }),
322
- /* @__PURE__ */ u(
323
- en,
472
+ /* @__PURE__ */ h(
473
+ Bn,
324
474
  {
325
- screen: { ..._[M.name], ...M.options ?? {} },
326
- options: o,
327
- override: W[$],
328
- route: M,
329
- navigation: de,
330
- requestClose: Q,
331
- translate: s,
332
- onError: f,
333
- loadingApi: he
475
+ store: q.current,
476
+ routeKey: D,
477
+ screen: _e,
478
+ options: t,
479
+ route: G,
480
+ navigation: Be,
481
+ requestClose: ae,
482
+ translate: c,
483
+ onError: d,
484
+ loadingApi: Se
334
485
  },
335
- $
486
+ D
336
487
  ),
337
- /* @__PURE__ */ u(nn, { loading: se, translate: s }),
338
- /* @__PURE__ */ u(on, { items: O, dismiss: L }),
339
- k && /* @__PURE__ */ ie("div", { className: "pmn-error", role: "alert", children: [
340
- /* @__PURE__ */ u("span", { children: k.message || String(k) }),
341
- /* @__PURE__ */ u("button", { type: "button", onClick: S, "aria-label": "Dismiss error", children: "×" })
488
+ /* @__PURE__ */ h(Pn, { store: A.current, translate: c }),
489
+ /* @__PURE__ */ h(Ln, { store: $.current, dismiss: W }),
490
+ y && /* @__PURE__ */ me("div", { className: "pmn-error", role: "alert", children: [
491
+ /* @__PURE__ */ h("span", { children: y.message || String(y) }),
492
+ /* @__PURE__ */ h("button", { type: "button", onClick: C, "aria-label": "Dismiss error", children: "×" })
342
493
  ] })
343
- ] }) }) }) });
494
+ ] }) }) }) }) }) }) }) });
344
495
  }
345
- const cn = ".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)}", Oe = "react-modal-navigation-styles", Se = /* @__PURE__ */ new WeakMap();
346
- function ln() {
347
- Ue(() => {
496
+ const On = ".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}", Ze = "react-modal-navigation-styles", Ge = /* @__PURE__ */ new WeakMap();
497
+ function jn() {
498
+ un(() => {
348
499
  if (typeof document > "u") return;
349
500
  const e = document;
350
- let n = Se.get(e);
501
+ let n = Ge.get(e);
351
502
  if (!n) {
352
- let r = e.getElementById(Oe);
353
- const o = !r;
354
- r || (r = e.createElement("style"), r.id = Oe, r.setAttribute("data-react-modal-navigation", ""), r.textContent = cn, e.head.appendChild(r)), n = { element: r, owned: o, count: 0 }, Se.set(e, n);
503
+ let r = e.getElementById(Ze);
504
+ const t = !r;
505
+ r || (r = e.createElement("style"), r.id = Ze, r.setAttribute("data-react-modal-navigation", ""), r.textContent = On, e.head.appendChild(r)), n = { element: r, owned: t, count: 0 }, Ge.set(e, n);
355
506
  }
356
507
  return n.count += 1, () => {
357
- n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), Se.delete(e));
508
+ n.count -= 1, n.count === 0 && (n.owned && n.element.remove(), Ge.delete(e));
358
509
  };
359
510
  }, []);
360
511
  }
361
- function Re(e, n, r) {
512
+ function Oe(e, n, r) {
362
513
  if (typeof e == "string") {
363
514
  if (!e.trim()) throw new TypeError("[react-modal-navigation] modal name must not be empty");
364
515
  return { name: e, params: n ?? {}, options: r ?? {} };
365
516
  }
366
517
  if (e === null || typeof e != "object" || Array.isArray(e))
367
518
  throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
368
- const { name: o, screen: s, params: b = {}, options: y = {}, ...R } = e;
369
- if (typeof o != "string" || !o.trim())
519
+ const { name: t, screen: c, params: f = {}, options: l = {}, ...u } = e;
520
+ if (typeof t != "string" || !t.trim())
370
521
  throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
371
- if (y === null || typeof y != "object" || Array.isArray(y))
522
+ if (l === null || typeof l != "object" || Array.isArray(l))
372
523
  throw new TypeError("[react-modal-navigation] open config options must be an object");
373
- if (s !== void 0 && (typeof s != "string" || !s.trim()))
524
+ if (c !== void 0 && (typeof c != "string" || !c.trim()))
374
525
  throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
375
- return { name: o, ...s === void 0 ? {} : { screen: s }, params: b, options: { ...R, ...y } };
376
- }
377
- const un = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, dn = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
378
- function gn({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: o, theme: s, translate: b = dn, onError: y, confirmDiscard: R }) {
379
- ln();
380
- const [f, k] = X(null), [S, x] = X(null), [w, l] = X(0), g = m(null), O = m(/* @__PURE__ */ new Map()), N = m([]), H = m(null), C = m(null), L = m(0), A = m(null), D = m(!1), G = m(0), U = m(null), W = m(/* @__PURE__ */ new Map()), [F, Y] = X(!1), P = m(R);
381
- P.current = R;
382
- const oe = p((a, c) => (W.current.set(a, c), () => {
383
- W.current.get(a) === c && W.current.delete(a);
384
- }), []), E = p(async (a) => {
385
- for (const c of W.current.values()) {
386
- if (!c.dirty) continue;
387
- if ((c.onBeforeDiscard ? await c.onBeforeDiscard(a) : P.current ? await P.current(a) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(c.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
526
+ return { name: t, ...c === void 0 ? {} : { screen: c }, params: f, options: { ...u, ...l } };
527
+ }
528
+ const Fn = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, Dn = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
529
+ function _n({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: t, theme: c, translate: f = Dn, onError: l, confirmDiscard: u }) {
530
+ jn();
531
+ const [d, y] = ie(null), [C, w] = ie(null), [g, i] = ie(0), s = m(null), B = m(/* @__PURE__ */ new Map()), R = m([]), A = m(null), q = m(null), $ = m(0), E = m(null), z = m(!1), U = m(0), W = m(null), M = m(/* @__PURE__ */ new Map()), [b, T] = ie(!1), j = m(u);
532
+ j.current = u;
533
+ const F = v((a, p) => (M.current.set(a, p), () => {
534
+ M.current.get(a) === p && M.current.delete(a);
535
+ }), []), N = v(async (a) => {
536
+ for (const p of M.current.values()) {
537
+ if (!p.dirty) continue;
538
+ if ((p.onBeforeDiscard ? await p.onBeforeDiscard(a) : j.current ? await j.current(a) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(p.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
388
539
  }
389
540
  return !0;
390
- }, []), T = m(!0), B = m(null), Z = m(y);
391
- Z.current = y;
392
- const j = p((a, c) => {
393
- T.current && x(a);
541
+ }, []), V = v(async (a, p) => {
542
+ for (const S of a) {
543
+ const k = M.current.get(S);
544
+ if (!k?.dirty) continue;
545
+ if ((k.onBeforeDiscard ? await k.onBeforeDiscard(p) : j.current ? await j.current(p) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(k.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
546
+ }
547
+ return !0;
548
+ }, []), L = m(!0), ne = m(null), te = m(l);
549
+ te.current = l;
550
+ const O = v((a, p) => {
551
+ L.current && w(a);
394
552
  try {
395
- Z.current ? Z.current(a, c) : console.error("[react-modal-navigation]", a);
396
- } catch (v) {
397
- console.error("[react-modal-navigation] onError failed", v);
553
+ te.current ? te.current(a, p) : console.error("[react-modal-navigation]", a);
554
+ } catch (S) {
555
+ console.error("[react-modal-navigation] onError failed", S);
398
556
  }
399
- }, []), pe = p((a, c) => {
400
- const v = O.current.get(a);
401
- O.current.delete(a), v?.(c);
402
- }, []), M = p((a) => ({ ...un, ...r, ...s !== void 0 ? { theme: s } : {}, ...o !== void 0 ? { backgroundColor: o } : {}, ...a.config.modalOptions, ...a.overrides }), [r, s, o]), $ = f ? M(f) : null, be = m(null);
403
- be.current = $, B.current = $;
404
- const _ = p(async (a = "api", c, v = {}) => {
405
- const h = g.current;
406
- if (!h || A.current || D.current) return !1;
407
- A.current = h.id, D.current = !0;
408
- const I = B.current ?? M(h), q = { ...v, reason: a, result: c, name: h.name };
557
+ }, []), le = v((a, p) => {
558
+ const S = B.current.get(a);
559
+ B.current.delete(a), S?.(p);
560
+ }, []), re = v((a) => ({ ...Fn, ...r, ...c !== void 0 ? { theme: c } : {}, ...t !== void 0 ? { backgroundColor: t } : {}, ...a.config.modalOptions, ...a.overrides }), [r, c, t]), Ee = d ? re(d) : null, G = m(null);
561
+ G.current = Ee, ne.current = Ee;
562
+ const D = v(async (a = "api", p, S = {}) => {
563
+ const k = s.current;
564
+ if (!k || E.current || z.current) return !1;
565
+ E.current = k.id, z.current = !0;
566
+ const Y = ne.current ?? re(k), _ = { ...S, reason: a, result: p, name: k.name };
409
567
  try {
410
- if (!await E(q) || await I.onBeforeClose?.(q) === !1 || g.current?.id !== h.id || !T.current || (Y(!0), await new Promise((K) => {
411
- const le = I.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(I.animationDuration ?? 220) || 0);
412
- setTimeout(K, Math.min(le, 1e3));
413
- }), !T.current || g.current?.id !== h.id)) return !1;
414
- g.current = null, U.current = null, k(null), Y(!1), W.current.clear(), pe(h.id, v.confirmed || c !== void 0 ? { status: "confirmed", value: c, reason: a } : { status: "dismissed", reason: a });
568
+ if (!await N(_) || await Y.onBeforeClose?.(_) === !1 || s.current?.id !== k.id || !L.current || (T(!0), await new Promise((J) => {
569
+ const ae = Y.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(Y.animationDuration ?? 220) || 0);
570
+ setTimeout(J, Math.min(ae, 1e3));
571
+ }), !L.current || s.current?.id !== k.id)) return !1;
572
+ s.current = null, W.current = null, y(null), T(!1), M.current.clear(), le(k.id, S.confirmed || p !== void 0 ? { status: "confirmed", value: p, reason: a } : { status: "dismissed", reason: a });
415
573
  try {
416
- await I.onClose?.(q);
417
- } catch (K) {
418
- j(K, { phase: "onClose", name: h.name });
574
+ await Y.onClose?.(_);
575
+ } catch (J) {
576
+ O(J, { phase: "onClose", name: k.name });
419
577
  }
420
578
  return !0;
421
- } catch (K) {
422
- return j(K, { phase: "onBeforeClose", name: h.name }), !1;
579
+ } catch (J) {
580
+ return O(J, { phase: "onBeforeClose", name: k.name }), !1;
423
581
  } finally {
424
- A.current === h.id && (A.current = null), D.current = !1, !g.current && T.current && queueMicrotask(() => C.current?.());
582
+ E.current === k.id && (E.current = null), z.current = !1, !s.current && L.current && queueMicrotask(() => q.current?.());
425
583
  }
426
- }, [M, j, pe, E]), J = p(async (a, c = {}, v = {}, h, I) => {
427
- const q = e?.[a];
428
- if (!q) throw new Error(`[react-modal-navigation] Unknown modal: ${a}`);
429
- const K = I ?? q.initialRoute;
430
- if (!q.screens?.[K]) throw new Error(`[react-modal-navigation] Unknown initial screen '${K}' in modal '${a}'`);
431
- if (!T.current || D.current || A.current) return null;
432
- D.current = !0;
433
- const le = G.current;
584
+ }, [re, O, le, N]), ue = v(async (a, p = {}, S = {}, k, Y) => {
585
+ const _ = e?.[a];
586
+ if (!_) throw new Error(`[react-modal-navigation] Unknown modal: ${a}`);
587
+ const J = Y ?? _.initialRoute;
588
+ if (!_.screens?.[J]) throw new Error(`[react-modal-navigation] Unknown initial screen '${J}' in modal '${a}'`);
589
+ if (!L.current || z.current || E.current) return null;
590
+ z.current = !0;
591
+ const ae = U.current;
434
592
  try {
435
- const Q = g.current;
436
- if (Q) {
437
- const de = B.current ?? M(Q), t = { reason: "replace", name: Q.name, nextName: a };
593
+ const se = s.current;
594
+ if (se) {
595
+ const we = ne.current ?? re(se), xe = { reason: "replace", name: se.name, nextName: a };
438
596
  try {
439
- if (!await E(t) || await de.onBeforeClose?.(t) === !1) return null;
440
- } catch (i) {
441
- return j(i, { phase: "onBeforeClose", name: Q.name }), null;
597
+ if (!await N(xe) || await we.onBeforeClose?.(xe) === !1) return null;
598
+ } catch (he) {
599
+ return O(he, { phase: "onBeforeClose", name: se.name }), null;
442
600
  }
443
- if (!T.current || le !== G.current || g.current?.id !== Q.id) return null;
444
- g.current = null, U.current = null, k(null), W.current.clear(), pe(Q.id, { status: "replaced", reason: "replace" });
601
+ if (!L.current || ae !== U.current || s.current?.id !== se.id) return null;
602
+ s.current = null, W.current = null, y(null), M.current.clear(), le(se.id, { status: "replaced", reason: "replace" });
445
603
  try {
446
- await de.onClose?.(t);
447
- } catch (i) {
448
- j(i, { phase: "onClose", name: Q.name });
604
+ await we.onClose?.(xe);
605
+ } catch (he) {
606
+ O(he, { phase: "onClose", name: se.name });
449
607
  }
450
- if (!T.current || le !== G.current) return null;
608
+ if (!L.current || ae !== U.current) return null;
451
609
  }
452
- const ue = { id: ++L.current, name: a, screen: K, params: c, config: q, overrides: v };
453
- return g.current = ue, U.current = null, h && O.current.set(ue.id, h), x(null), k(ue), ue.id;
610
+ const fe = { id: ++$.current, name: a, screen: J, params: p, config: _, overrides: S };
611
+ return s.current = fe, W.current = null, k && B.current.set(fe.id, k), w(null), y(fe), fe.id;
454
612
  } finally {
455
- D.current = !1;
613
+ z.current = !1;
456
614
  }
457
- }, [e, M, j, pe, E]);
458
- H.current = J;
459
- const ae = p(async () => {
460
- if (!T.current || g.current || D.current || A.current) return;
461
- const a = N.current.shift();
615
+ }, [e, re, O, le, N]);
616
+ A.current = ue;
617
+ const Se = v(async () => {
618
+ if (!L.current || s.current || z.current || E.current) return;
619
+ const a = R.current.shift();
462
620
  if (a) {
463
- l(N.current.length);
621
+ i(R.current.length);
464
622
  try {
465
- const c = await H.current(a.args.name, a.args.params, a.args.options, a.resolveResult, a.args.screen);
466
- c === null ? (a.resolveResult?.({ status: "dismissed", reason: "blocked" }), a.resolveId?.(null), queueMicrotask(() => C.current?.())) : a.resolveId?.(c);
467
- } catch (c) {
468
- a.reject?.(c), queueMicrotask(() => C.current?.());
623
+ const p = await A.current(a.args.name, a.args.params, a.args.options, a.resolveResult, a.args.screen);
624
+ p === null ? (a.resolveResult?.({ status: "dismissed", reason: "blocked" }), a.resolveId?.(null), queueMicrotask(() => q.current?.())) : a.resolveId?.(p);
625
+ } catch (p) {
626
+ a.reject?.(p), queueMicrotask(() => q.current?.());
469
627
  }
470
628
  }
471
629
  }, []);
472
- C.current = ae;
473
- const ee = p((a, c, v) => {
474
- const h = Re(a, c, v);
475
- return e?.[h.name] ? new Promise((I, q) => {
476
- N.current.push({ args: h, resolveId: I, reject: q }), l(N.current.length), queueMicrotask(() => C.current?.());
477
- }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${h.name}`));
478
- }, [e]), te = p((a, c, v) => {
479
- const h = Re(a, c, v);
480
- return e?.[h.name] ? new Promise((I, q) => {
481
- N.current.push({ args: h, resolveResult: I, reject: q }), l(N.current.length), queueMicrotask(() => C.current?.());
482
- }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${h.name}`));
483
- }, [e]), ve = p((a) => {
630
+ q.current = Se;
631
+ const Ce = v((a, p, S) => {
632
+ const k = Oe(a, p, S);
633
+ return e?.[k.name] ? new Promise((Y, _) => {
634
+ R.current.push({ args: k, resolveId: Y, reject: _ }), i(R.current.length), queueMicrotask(() => q.current?.());
635
+ }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${k.name}`));
636
+ }, [e]), ye = v((a, p, S) => {
637
+ const k = Oe(a, p, S);
638
+ return e?.[k.name] ? new Promise((Y, _) => {
639
+ R.current.push({ args: k, resolveResult: Y, reject: _ }), i(R.current.length), queueMicrotask(() => q.current?.());
640
+ }) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${k.name}`));
641
+ }, [e]), pe = v((a) => {
484
642
  if (!a || typeof a != "object" || Array.isArray(a)) throw new TypeError("[react-modal-navigation] update expects an options object");
485
- const c = g.current;
486
- if (!c || D.current) return !1;
487
- const v = { ...c, overrides: { ...c.overrides, ...a } };
488
- return g.current = v, k(v), B.current = M(v), !0;
489
- }, [M]), fe = p((a = "queue-cleared") => {
490
- const c = N.current.splice(0);
491
- l(0);
492
- for (const v of c)
493
- v.resolveId?.(null), v.resolveResult?.({ status: "dismissed", reason: a });
494
- return c.length;
495
- }, []), se = p((a, c, v) => {
496
- const h = Re(a, c, v);
497
- return J(h.name, h.params, h.options, void 0, h.screen);
498
- }, [J]), xe = p((a, c, v) => {
499
- const h = Re(a, c, v);
500
- return new Promise((I, q) => {
501
- J(h.name, h.params, h.options, I, h.screen).then((K) => {
502
- K === null && I({ status: "dismissed", reason: "blocked" });
503
- }, q);
643
+ const p = s.current;
644
+ if (!p || z.current) return !1;
645
+ const S = { ...p, overrides: { ...p.overrides, ...a } };
646
+ return s.current = S, y(S), ne.current = re(S), !0;
647
+ }, [re]), oe = v((a = "queue-cleared") => {
648
+ const p = R.current.splice(0);
649
+ i(0);
650
+ for (const S of p)
651
+ S.resolveId?.(null), S.resolveResult?.({ status: "dismissed", reason: a });
652
+ return p.length;
653
+ }, []), Pe = v((a, p, S) => {
654
+ const k = Oe(a, p, S);
655
+ return ue(k.name, k.params, k.options, void 0, k.screen);
656
+ }, [ue]), ve = v((a, p, S) => {
657
+ const k = Oe(a, p, S);
658
+ return new Promise((Y, _) => {
659
+ ue(k.name, k.params, k.options, Y, k.screen).then((J) => {
660
+ J === null && Y({ status: "dismissed", reason: "blocked" });
661
+ }, _);
504
662
  });
505
- }, [J]), he = p((a) => _("api", a), [_]), ge = p((a = "api") => _(a), [_]), ke = p((a) => _("confirm", a, { confirmed: !0 }), [_]), ce = p((a, c) => U.current?.setLoading(a, c), []), Ee = ne(() => ({ open: se, openAsync: xe, enqueue: ee, enqueueAsync: te, update: ve, clearQueue: fe, close: he, dismiss: ge, confirm: ke, setLoading: ce, queueSize: w, isOpen: !!f, activeName: f?.name ?? null, error: S, clearError: () => x(null) }), [se, xe, ee, te, ve, fe, he, ge, ke, ce, f, S, w]);
506
- return z(() => (T.current = !0, () => {
507
- T.current = !1, G.current += 1, g.current = null;
508
- for (const c of O.current.values()) c({ status: "dismissed", reason: "unmount" });
509
- O.current.clear(), W.current.clear();
510
- const a = N.current.splice(0);
511
- for (const c of a)
512
- c.resolveId?.(null), c.resolveResult?.({ status: "dismissed", reason: "unmount" });
513
- }), []), /* @__PURE__ */ ie(Ae.Provider, { value: Ee, children: [
663
+ }, [ue]), Le = v((a) => D("api", a), [D]), Re = v((a = "api") => D(a), [D]), Me = v((a) => D("confirm", a, { confirmed: !0 }), [D]), de = v((a, p) => W.current?.setLoading(a, p), []), Z = K(() => ({ open: Pe, openAsync: ve, enqueue: Ce, enqueueAsync: ye, update: pe, clearQueue: oe, close: Le, dismiss: Re, confirm: Me, setLoading: de, queueSize: g, isOpen: !!d, activeName: d?.name ?? null, error: C, clearError: () => w(null) }), [Pe, ve, Ce, ye, pe, oe, Le, Re, Me, de, d, C, g]);
664
+ return H(() => (L.current = !0, () => {
665
+ L.current = !1, U.current += 1, s.current = null;
666
+ for (const p of B.current.values()) p({ status: "dismissed", reason: "unmount" });
667
+ B.current.clear(), M.current.clear();
668
+ const a = R.current.splice(0);
669
+ for (const p of a)
670
+ p.resolveId?.(null), p.resolveResult?.({ status: "dismissed", reason: "unmount" });
671
+ }), []), /* @__PURE__ */ me(nn.Provider, { value: Z, children: [
514
672
  n,
515
- f && /* @__PURE__ */ u(
516
- sn,
673
+ d && /* @__PURE__ */ h(
674
+ qn,
517
675
  {
518
- config: f.config,
519
- initialScreen: f.screen,
520
- params: f.params,
521
- options: $,
522
- translate: b,
523
- notifyError: j,
524
- error: S,
525
- clearError: () => x(null),
676
+ config: d.config,
677
+ initialScreen: d.screen,
678
+ params: d.params,
679
+ options: Ee,
680
+ translate: f,
681
+ notifyError: O,
682
+ error: C,
683
+ clearError: () => w(null),
526
684
  registerLoading: (a) => {
527
- U.current = a;
685
+ W.current = a;
528
686
  },
529
- registerDirtyGuard: oe,
530
- exiting: F,
531
- onRequestClose: _,
687
+ registerDirtyGuard: F,
688
+ canNavigate: V,
689
+ exiting: b,
690
+ onRequestClose: D,
532
691
  onOpened: (a) => {
533
692
  try {
534
- const c = be.current?.onOpen?.(a);
535
- Promise.resolve(c).catch((v) => j(v, { phase: "onOpen" }));
536
- } catch (c) {
537
- j(c, { phase: "onOpen" });
693
+ const p = G.current?.onOpen?.(a);
694
+ Promise.resolve(p).catch((S) => O(S, { phase: "onOpen" }));
695
+ } catch (p) {
696
+ O(p, { phase: "onOpen" });
538
697
  }
539
698
  }
540
699
  },
541
- f.id
700
+ d.id
542
701
  )
543
702
  ] });
544
703
  }
545
- function yn() {
546
- const e = re(Ae), n = re(Le);
704
+ const In = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), $n = () => () => {
705
+ }, en = () => In;
706
+ function Vn() {
707
+ const e = Q(nn), n = Q(Ue), r = Q(We), t = be(r?.subscribe ?? $n, r?.getSnapshot ?? en, r?.getSnapshot ?? en);
547
708
  if (!e) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
548
- return ne(() => {
549
- const r = () => {
709
+ const c = K(() => {
710
+ const f = () => {
550
711
  if (!n) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
551
712
  return n;
552
713
  };
553
- return { ...e, modal: e, navigation: {
554
- navigate: (...s) => r().navigate(...s),
555
- replace: (...s) => r().replace(...s),
556
- reset: (...s) => r().reset(...s),
557
- setParams: (...s) => r().setParams(...s),
558
- setOptions: (...s) => r().setOptions(...s),
559
- goBack: (...s) => r().goBack(...s),
560
- close: (...s) => r().close(...s),
561
- get canGoBack() {
562
- return n?.canGoBack ?? !1;
563
- },
564
- get stack() {
565
- return n?.stack ?? [];
566
- },
567
- get currentRoute() {
568
- return n?.currentRoute ?? null;
569
- }
570
- } };
571
- }, [e, n]);
714
+ return {
715
+ navigate: (...l) => f().navigate(...l),
716
+ replace: (...l) => f().replace(...l),
717
+ reset: (...l) => f().reset(...l),
718
+ setParams: (...l) => f().setParams(...l),
719
+ setOptions: (...l) => f().setOptions(...l),
720
+ goBack: (...l) => f().goBack(...l),
721
+ close: (...l) => f().close(...l),
722
+ setLoading: (...l) => f().setLoading(...l),
723
+ canGoBack: t.canGoBack,
724
+ stack: t.stack,
725
+ currentRoute: t.currentRoute
726
+ };
727
+ }, [n, t]);
728
+ return K(() => ({ ...e, modal: e, navigation: c }), [e, c]);
572
729
  }
573
- function bn() {
574
- const e = re(Le);
575
- if (!e) throw new Error("useModalNavigation requires an active modal screen");
730
+ function zn() {
731
+ const e = Q(Ue);
732
+ if (!e) throw new Error("useModalNavigationCommands requires an active modal screen");
576
733
  return e;
577
734
  }
578
- function Ie() {
579
- const e = re(Me);
735
+ function Kn() {
736
+ const e = Q(We);
737
+ if (!e) throw new Error("useModalNavigationState requires an active modal screen");
738
+ return be(e.subscribe, e.getSnapshot, e.getSnapshot);
739
+ }
740
+ function Qn() {
741
+ const e = zn(), n = Kn();
742
+ return K(() => ({ ...e, ...n }), [e, n]);
743
+ }
744
+ function sn() {
745
+ const e = Q(je);
580
746
  if (!e) throw new Error("useIsFocused must be called inside a modal screen");
581
747
  return e.isFocused;
582
748
  }
583
- function vn(e) {
584
- const n = Ie();
585
- z(() => {
749
+ function Jn(e) {
750
+ const n = sn();
751
+ H(() => {
586
752
  if (n)
587
753
  return e();
588
754
  }, [n, e]);
589
755
  }
590
- function xn(e) {
591
- const n = re(Me);
756
+ function Xn(e) {
757
+ const n = Q(je);
592
758
  if (!n) throw new Error("useNavigationResult requires an active modal screen");
593
- const r = m(e), o = m(null);
594
- z(() => {
759
+ const r = m(e), t = m(null);
760
+ H(() => {
595
761
  r.current = e;
596
- }, [e]), z(() => {
597
- !n.isFocused || !n.resultEvent || o.current !== n.resultEvent.id && (o.current = n.resultEvent.id, r.current(n.resultEvent.data));
762
+ }, [e]), H(() => {
763
+ !n.isFocused || !n.resultEvent || t.current !== n.resultEvent.id && (t.current = n.resultEvent.id, r.current(n.resultEvent.data));
598
764
  }, [n.isFocused, n.resultEvent]);
599
765
  }
600
- function wn(e = {}) {
601
- const n = re(Me);
766
+ function Zn(e = {}) {
767
+ const n = Q(je);
602
768
  if (!n) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
603
- const { setFooter: r, routeKey: o } = n, s = m(e);
604
- s.current = e;
605
- const b = ne(() => (...L) => s.current.done?.(...L), []), y = ne(() => (...L) => (s.current.cancel ?? s.current.cancle)?.(...L), []), R = ne(() => (...L) => s.current.renderFooter?.(...L), []), f = typeof e.done == "function", k = typeof (e.cancel ?? e.cancle) == "function", S = typeof e.renderFooter == "function", { showFooter: x, showFooterBorder: w, doneDisabled: l, doneText: g, cancelText: O, loadingText: N, footerClassName: H } = e, C = ne(() => ({
606
- showFooter: x,
607
- showFooterBorder: w,
608
- doneDisabled: l,
609
- doneText: g,
610
- cancelText: O,
611
- loadingText: N,
612
- footerClassName: H,
613
- ...f ? { done: b } : {},
614
- ...k ? { cancel: y } : {},
615
- ...S ? { renderFooter: R } : {}
616
- }), [x, w, l, g, O, N, H, f, k, S, b, y, R]);
617
- z(() => {
618
- r(o, C);
619
- }, [o, r, C]), z(() => () => r(o, null), [o, r]);
620
- }
621
- function mn() {
622
- const e = re(Pe);
623
- if (!e) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
769
+ const { setFooter: r, routeKey: t } = n, c = m(e);
770
+ c.current = e;
771
+ const f = K(() => (...M) => c.current.done?.(...M), []), l = K(() => (...M) => (c.current.cancel ?? c.current.cancle)?.(...M), []), u = K(() => (...M) => c.current.renderFooter?.(...M), []), d = typeof e.done == "function", y = typeof (e.cancel ?? e.cancle) == "function", C = typeof e.renderFooter == "function", { showFooter: w, showFooterBorder: g, doneDisabled: i, doneText: s, cancelText: B, loadingText: R, footerClassName: A } = e, q = m({ source: null, normalized: void 0 }), $ = Array.isArray(e.actions) ? e.actions : null, E = q.current.source;
772
+ $ === E || $ && E && $.length === E.length && $.every((M, b) => {
773
+ const T = E[b];
774
+ return [.../* @__PURE__ */ new Set([...Object.keys(M), ...Object.keys(T)])].every((F) => F === "onClick" || Object.is(M[F], T[F]));
775
+ }) || (q.current = {
776
+ source: $?.map((M) => ({ ...M })) ?? null,
777
+ normalized: $?.map((M, b) => ({
778
+ ...M,
779
+ onClick: (...T) => (c.current.actions?.find((F) => F.key === M.key) ?? c.current.actions?.[b])?.onClick?.(...T)
780
+ }))
781
+ });
782
+ const U = q.current.normalized, W = K(() => ({
783
+ showFooter: w,
784
+ showFooterBorder: g,
785
+ doneDisabled: i,
786
+ doneText: s,
787
+ cancelText: B,
788
+ loadingText: R,
789
+ footerClassName: A,
790
+ ...U !== void 0 ? { actions: U } : {},
791
+ ...d ? { done: f } : {},
792
+ ...y ? { cancel: l } : {},
793
+ ...C ? { renderFooter: u } : {}
794
+ }), [w, g, i, s, B, R, A, U, d, y, C, f, l, u]);
795
+ H(() => {
796
+ r(t, W);
797
+ }, [t, r, W]), H(() => () => r(t, null), [t, r]);
798
+ }
799
+ function Gn() {
800
+ const e = Q(Fe), n = Q(Ye);
801
+ if (!e || !n) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
802
+ const r = be(n.subscribe, n.getSnapshot, n.getSnapshot);
803
+ return K(() => ({ ...e, isLoading: r.visible }), [e, r.visible]);
804
+ }
805
+ function et() {
806
+ const e = Q(Fe);
807
+ if (!e) throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");
624
808
  return e;
625
809
  }
626
- function kn() {
627
- const e = mn(), n = Ie(), r = m(!0), o = m(!1), [s, b] = X(!1), [y, R] = X(null), f = m(e);
628
- return f.current = e, z(() => (r.current = !0, () => {
810
+ function nt() {
811
+ const e = Q(Ye);
812
+ if (!e) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
813
+ return be(e.subscribe, e.getSnapshot, e.getSnapshot);
814
+ }
815
+ function tt() {
816
+ const e = Gn(), n = sn(), r = m(!0), t = m(!1), [c, f] = ie(!1), [l, u] = ie(null), d = m(e);
817
+ return d.current = e, H(() => (r.current = !0, () => {
629
818
  r.current = !1;
630
- }), []), { run: p(async (S, x = {}) => {
631
- if (o.current) return { status: "busy" };
632
- if (typeof S != "function") throw new TypeError("[react-modal-navigation] run requires a function");
633
- o.current = !0, r.current && (b(!0), R(null));
634
- const w = f.current.showLoading(x.loadingText);
819
+ }), []), { run: v(async (C, w = {}) => {
820
+ if (t.current) return { status: "busy" };
821
+ if (typeof C != "function") throw new TypeError("[react-modal-navigation] run requires a function");
822
+ t.current = !0, r.current && (f(!0), u(null));
823
+ const g = d.current.showLoading(w.loadingText);
635
824
  try {
636
- const l = await S();
637
- return r.current && await x.onSuccess?.(l), { status: "success", value: l };
638
- } catch (l) {
825
+ const i = await C();
826
+ return r.current && await w.onSuccess?.(i), { status: "success", value: i };
827
+ } catch (i) {
639
828
  if (r.current) {
640
- R(l);
829
+ u(i);
641
830
  try {
642
- await x.onError?.(l);
643
- } catch (g) {
644
- console.error("[react-modal-navigation] onError failed", g);
831
+ await w.onError?.(i);
832
+ } catch (s) {
833
+ console.error("[react-modal-navigation] onError failed", s);
645
834
  }
646
835
  }
647
- if (x.throwOnError) throw l;
648
- return { status: "error", error: l };
836
+ if (w.throwOnError) throw i;
837
+ return { status: "error", error: i };
649
838
  } finally {
650
- w != null && f.current.hideLoading(w), o.current = !1, r.current && b(!1);
839
+ g != null && d.current.hideLoading(g), t.current = !1, r.current && f(!1);
651
840
  }
652
- }, []), pending: s, error: y, clearError: () => R(null), isFocused: n };
841
+ }, []), pending: c, error: l, clearError: () => u(null), isFocused: n };
653
842
  }
654
- function En(e, n = {}) {
655
- const r = re(De);
843
+ function rt(e, n = {}) {
844
+ const r = Q(tn);
656
845
  if (!r) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
657
- const o = m({ dirty: e, ...n });
658
- o.current = { dirty: e, ...n };
659
- const { routeKey: s, registerDirtyGuard: b } = r;
660
- z(() => b(s, {
846
+ const t = m({ dirty: e, ...n });
847
+ t.current = { dirty: e, ...n };
848
+ const { routeKey: c, registerDirtyGuard: f } = r;
849
+ H(() => f(c, {
661
850
  get dirty() {
662
- return !!o.current.dirty;
851
+ return !!t.current.dirty;
663
852
  },
664
853
  get message() {
665
- return o.current.message;
854
+ return t.current.message;
666
855
  },
667
856
  get onBeforeDiscard() {
668
- return o.current.onBeforeDiscard;
857
+ return t.current.onBeforeDiscard;
669
858
  }
670
- }), [s, b]);
859
+ }), [c, f]);
671
860
  }
672
- const Tn = () => {
673
- const e = re(je);
861
+ const ot = () => {
862
+ const e = Q(rn);
674
863
  if (!e) throw new Error("[react-modal-navigation] useToast requires an active modal");
675
864
  return e;
676
865
  };
866
+ function Hn() {
867
+ const e = Q(on);
868
+ if (!e) throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");
869
+ return e;
870
+ }
871
+ function at() {
872
+ return Hn().params;
873
+ }
677
874
  export {
678
- sn as ModalNavigator,
679
- gn as ModalProvider,
680
- vn as useFocusEffect,
681
- Ie as useIsFocused,
682
- yn as useModal,
683
- wn as useModalFooter,
684
- mn as useModalLoading,
685
- bn as useModalNavigation,
686
- kn as useModalTask,
687
- En as useModalUnsavedChanges,
688
- xn as useNavigationResult,
689
- Tn as useToast
875
+ qn as ModalNavigator,
876
+ _n as ModalProvider,
877
+ Jn as useFocusEffect,
878
+ sn as useIsFocused,
879
+ Vn as useModal,
880
+ Zn as useModalFooter,
881
+ Gn as useModalLoading,
882
+ et as useModalLoadingCommands,
883
+ nt as useModalLoadingState,
884
+ Qn as useModalNavigation,
885
+ zn as useModalNavigationCommands,
886
+ Kn as useModalNavigationState,
887
+ at as useModalParams,
888
+ Hn as useModalRoute,
889
+ tt as useModalTask,
890
+ rt as useModalUnsavedChanges,
891
+ Xn as useNavigationResult,
892
+ ot as useToast
690
893
  };