@24city/web-console 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -2
  4. package/dist/account/account-api.d.ts +24 -0
  5. package/dist/account/account-center-links.d.ts +35 -0
  6. package/dist/account/account-center-page.d.ts +7 -0
  7. package/dist/account/account-center-ui.d.ts +19 -0
  8. package/dist/account/account-menu.d.ts +23 -0
  9. package/dist/account/auth-provider.d.ts +6 -0
  10. package/dist/account/auth-store.d.ts +25 -0
  11. package/dist/account/benefit-copy.d.ts +15 -0
  12. package/dist/account/customization.d.ts +62 -0
  13. package/dist/account/index.d.ts +34 -0
  14. package/dist/account/index.js +87 -0
  15. package/dist/account/login-page.d.ts +6 -0
  16. package/dist/account/logout-signal.d.ts +13 -0
  17. package/dist/account/personal-nav.d.ts +29 -0
  18. package/dist/account/plan-benefits.d.ts +16 -0
  19. package/dist/account/plan-cards.d.ts +10 -0
  20. package/dist/account/plan-display.d.ts +44 -0
  21. package/dist/account/plan-panel.d.ts +16 -0
  22. package/dist/account/points-section.d.ts +8 -0
  23. package/dist/account/profile-section.d.ts +9 -0
  24. package/dist/account/quota-pill.d.ts +10 -0
  25. package/dist/account/quota.d.ts +12 -0
  26. package/dist/account/route-guard.d.ts +5 -0
  27. package/dist/account/session-sync.d.ts +1 -0
  28. package/dist/account/space-label.d.ts +10 -0
  29. package/dist/account/subscription-section.d.ts +11 -0
  30. package/dist/account/team-promo.d.ts +9 -0
  31. package/dist/account/types.d.ts +120 -0
  32. package/dist/account/upgrade-entry.d.ts +6 -0
  33. package/dist/account/upgrade-modal.d.ts +14 -0
  34. package/dist/account/use-account-center.d.ts +27 -0
  35. package/dist/account/use-logout.d.ts +13 -0
  36. package/dist/account/use-membership.d.ts +48 -0
  37. package/dist/account/use-plan-catalog.d.ts +2 -0
  38. package/dist/account/use-space-switch.d.ts +8 -0
  39. package/dist/account/wallet-badge.d.ts +2 -0
  40. package/dist/assets/coin-BhUDKCPy.webp +0 -0
  41. package/dist/assets/crown-D5kKk5rW.webp +0 -0
  42. package/dist/assets/diamond-BuDSsnw-.webp +0 -0
  43. package/dist/assets/engine-hero-BaSSoV-3.webp +0 -0
  44. package/dist/assets/member-gem-DTY0gTzl.webp +0 -0
  45. package/dist/assets/team-BeZ_oZcL.webp +0 -0
  46. package/dist/assets/upgrade-crown-Ci1IFoXi.webp +0 -0
  47. package/dist/chunks/auth-provider-CqiyTeOt.js +62 -0
  48. package/dist/chunks/console-layout-CcUiJPf0.js +198 -0
  49. package/dist/chunks/context-CaVim6ZO.js +13 -0
  50. package/dist/chunks/error-boundary-BgTZsJA_.js +35 -0
  51. package/dist/chunks/http-B3mTs9KZ.js +8 -0
  52. package/dist/chunks/link-button-giJEcTmG.js +42 -0
  53. package/dist/chunks/logout-signal-CiD_zY5M.js +365 -0
  54. package/dist/chunks/page-BhfOrziX.js +89 -0
  55. package/dist/chunks/stale-build-D4N21gap.js +57 -0
  56. package/dist/chunks/text-link-7A--UEc3.js +54 -0
  57. package/dist/chunks/upgrade-modal-BbsM2VE2.js +667 -0
  58. package/dist/chunks/use-media-query-DvyinWNg.js +12 -0
  59. package/dist/chunks/wallet-badge-D7AFqTLx.js +565 -0
  60. package/dist/index.d.ts +6 -0
  61. package/dist/index.js +159 -0
  62. package/dist/layout/console-layout.d.ts +35 -0
  63. package/dist/layout/console-nav.d.ts +30 -0
  64. package/dist/layout/index.d.ts +2 -0
  65. package/dist/layout/index.js +8 -0
  66. package/dist/page/error-boundary.d.ts +20 -0
  67. package/dist/page/index.d.ts +7 -0
  68. package/dist/page/index.js +21 -0
  69. package/dist/page/link-button.d.ts +29 -0
  70. package/dist/page/not-found-page.d.ts +1 -0
  71. package/dist/page/page.d.ts +34 -0
  72. package/dist/page/startup-error.d.ts +2 -0
  73. package/dist/page/status-result.d.ts +17 -0
  74. package/dist/page/text-link.d.ts +22 -0
  75. package/dist/runtime/context.d.ts +19 -0
  76. package/dist/runtime/error-summary.d.ts +5 -0
  77. package/dist/runtime/format.d.ts +10 -0
  78. package/dist/runtime/http.d.ts +11 -0
  79. package/dist/runtime/index.d.ts +11 -0
  80. package/dist/runtime/index.js +41 -0
  81. package/dist/runtime/internal-path.d.ts +4 -0
  82. package/dist/runtime/providers.d.ts +16 -0
  83. package/dist/runtime/query-keys.d.ts +6 -0
  84. package/dist/runtime/response.d.ts +6 -0
  85. package/dist/runtime/runtime-config.d.ts +19 -0
  86. package/dist/runtime/stale-build.d.ts +11 -0
  87. package/dist/runtime/use-media-query.d.ts +2 -0
  88. package/dist/semi.d.ts +10 -0
  89. package/dist/semi.js +12 -0
  90. package/dist/styles.css +3192 -0
  91. package/dist/testing/fixtures.d.ts +15 -0
  92. package/dist/testing/fixtures.js +142 -0
  93. package/dist/testing/guard.d.ts +32 -0
  94. package/dist/testing/guard.js +61 -0
  95. package/dist/testing/jsdom.d.ts +2 -0
  96. package/dist/testing/jsdom.js +116 -0
  97. package/dist/theme/index.d.ts +24 -0
  98. package/dist/theme/index.js +51 -0
  99. package/dist/theme/palette.d.ts +6 -0
  100. package/package.json +98 -3
@@ -0,0 +1,198 @@
1
+ import { jsx as t, jsxs as c, Fragment as O } from "react/jsx-runtime";
2
+ import { useState as N, useEffect as R } from "react";
3
+ import { Layout as f, Button as g, Typography as F, Space as Q, Nav as G } from "@douyinfe/semi-ui";
4
+ import { IconSidebar as $ } from "@douyinfe/semi-icons";
5
+ import { useLocation as Y, useNavigate as q, Outlet as D } from "react-router";
6
+ import { h as J, B as V, o as X, e as Z, W as z, b as ee } from "./wallet-badge-D7AFqTLx.js";
7
+ import { u as A, b as te, a as ne } from "./context-CaVim6ZO.js";
8
+ import { u as ae } from "./use-media-query-DvyinWNg.js";
9
+ const oe = "_layout_fwvg5_6", se = "_header_fwvg5_13", le = "_headerLeft_fwvg5_34", re = "_logo_fwvg5_42", ce = "_logoMark_fwvg5_57", ie = "_logoText_fwvg5_64", de = "_modules_fwvg5_73", ue = "_module_fwvg5_73", me = "_moduleText_fwvg5_110", _e = "_moduleIcon_fwvg5_130", he = "_moduleInk_fwvg5_134", pe = "_headerRight_fwvg5_154", fe = "_body_fwvg5_163", ge = "_sider_fwvg5_169", ve = "_siderInner_fwvg5_183", we = "_panel_fwvg5_190", ye = "_expandButton_fwvg5_227", ke = "_menu_fwvg5_243", Ne = "_menuGroup_fwvg5_254", be = "_menuGroupTitle_fwvg5_263", Ie = "_menuList_fwvg5_274", xe = "_collapseButton_fwvg5_384", Ce = "_mask_fwvg5_405", Me = "_content_fwvg5_414", Be = "_contentCentered_fwvg5_420", Le = "_contentInner_fwvg5_432", Te = "_letterMark_fwvg5_485", e = {
10
+ layout: oe,
11
+ header: se,
12
+ headerLeft: le,
13
+ logo: re,
14
+ logoMark: ce,
15
+ logoText: ie,
16
+ modules: de,
17
+ module: ue,
18
+ moduleText: me,
19
+ moduleIcon: _e,
20
+ moduleInk: he,
21
+ headerRight: pe,
22
+ body: fe,
23
+ sider: ge,
24
+ siderInner: ve,
25
+ panel: we,
26
+ expandButton: ye,
27
+ menu: ke,
28
+ menuGroup: Ne,
29
+ menuGroupTitle: be,
30
+ menuList: Ie,
31
+ collapseButton: xe,
32
+ mask: Ce,
33
+ content: Me,
34
+ contentCentered: Be,
35
+ contentInner: Le,
36
+ letterMark: Te
37
+ }, Se = (a, l) => a === l || a.startsWith(`${l}/`), Ge = (a, l) => a.flatMap((o) => o.items).find((o) => new URL(o.to, "http://console.local").pathname === l), $e = (a, l) => {
38
+ var o;
39
+ return (o = [...a].map((r) => ({ module: r, path: new URL(r.to, "http://console.local").pathname })).filter(({ path: r }) => Se(l, r)).sort((r, u) => u.path.length - r.path.length)[0]) == null ? void 0 : o.module;
40
+ }, Re = () => {
41
+ const [a, l] = N(!1);
42
+ return R(() => {
43
+ const o = () => l(window.scrollY > 0);
44
+ return o(), window.addEventListener("scroll", o, { passive: !0 }), () => window.removeEventListener("scroll", o);
45
+ }, []), a;
46
+ }, Ae = ({ size: a = 30, className: l }) => {
47
+ const o = A(), r = (u) => l ? `${u} ${l}` : u;
48
+ return o.markUrl ? /* @__PURE__ */ t(
49
+ "span",
50
+ {
51
+ className: r(e.logoMark),
52
+ style: { width: a, height: a, backgroundImage: `url("${o.markUrl}")` },
53
+ "aria-hidden": "true"
54
+ }
55
+ ) : /* @__PURE__ */ t("span", { className: r(e.letterMark), style: { width: a, height: a }, "aria-hidden": "true", children: Array.from(o.mark).slice(0, 2).join("") });
56
+ }, Fe = ({
57
+ modules: a = [],
58
+ activeModuleKey: l,
59
+ moduleTarget: o,
60
+ sidebar: r = [],
61
+ selectedKey: u,
62
+ renderItemLabel: b,
63
+ headerRight: U,
64
+ menuLabel: E = "工作台菜单",
65
+ children: K,
66
+ extra: P
67
+ }) => {
68
+ var S;
69
+ const { config: I } = te(), x = A(), v = Y(), w = q(), C = I.routes.app, h = J(C, V(ne())), M = X(C, v.pathname), p = M ? [] : r ?? [], B = p.length > 0, W = l ?? ((S = $e(a, v.pathname)) == null ? void 0 : S.key), m = Ge([...p, h], v.pathname), L = u ?? (m == null ? void 0 : m.key), i = ae("(min-width: 992px)"), j = Re(), [_, y] = N(!i), [k, d] = N(!1), H = new Map([...p, h].flatMap((n) => n.items.map((s) => [s.key, s])));
70
+ R(() => {
71
+ y(!i), d(!1);
72
+ }, [i]);
73
+ const T = (n) => {
74
+ const s = H.get(n);
75
+ s && w(s.to), d(!1);
76
+ };
77
+ return /* @__PURE__ */ c(f, { className: e.layout, children: [
78
+ /* @__PURE__ */ c(f.Header, { className: e.header, "data-scrolled": j ? "true" : "false", children: [
79
+ /* @__PURE__ */ c("div", { className: e.headerLeft, children: [
80
+ /* @__PURE__ */ c(
81
+ g,
82
+ {
83
+ theme: "borderless",
84
+ type: "tertiary",
85
+ className: e.logo,
86
+ "aria-label": `${x.shortName} 首页`,
87
+ onClick: () => w(I.routes.publicHome),
88
+ children: [
89
+ /* @__PURE__ */ t(Ae, {}),
90
+ /* @__PURE__ */ t(F.Text, { className: e.logoText, children: x.shortName })
91
+ ]
92
+ }
93
+ ),
94
+ a.length ? /* @__PURE__ */ t("div", { className: e.modules, role: "navigation", "aria-label": "产品模块", children: a.map((n) => /* @__PURE__ */ c(
95
+ g,
96
+ {
97
+ theme: "borderless",
98
+ type: "tertiary",
99
+ className: e.module,
100
+ "aria-current": W === n.key ? "page" : void 0,
101
+ onClick: () => w(o ? o(n) : n.to),
102
+ children: [
103
+ /* @__PURE__ */ c("span", { className: e.moduleText, children: [
104
+ n.icon ? /* @__PURE__ */ t("span", { className: e.moduleIcon, children: /* @__PURE__ */ t(n.icon, {}) }) : null,
105
+ n.label
106
+ ] }),
107
+ /* @__PURE__ */ t("span", { className: e.moduleInk, "aria-hidden": "true" })
108
+ ]
109
+ },
110
+ n.key
111
+ )) }) : null
112
+ ] }),
113
+ /* @__PURE__ */ t(Q, { spacing: 10, className: e.headerRight, children: U ?? /* @__PURE__ */ c(O, { children: [
114
+ /* @__PURE__ */ t(Z, {}),
115
+ /* @__PURE__ */ t(z, {}),
116
+ /* @__PURE__ */ t(ee, { personal: h, selectedKey: m && h.items.includes(m) ? m.key : void 0, onOpen: T })
117
+ ] }) })
118
+ ] }),
119
+ /* @__PURE__ */ c(f, { className: e.body, children: [
120
+ B ? /* @__PURE__ */ t("aside", { className: e.sider, "data-collapsed": _ ? "true" : "false", children: /* @__PURE__ */ c(
121
+ "div",
122
+ {
123
+ className: e.siderInner,
124
+ "data-collapsed": _ ? "true" : "false",
125
+ "data-peek": k ? "true" : "false",
126
+ onMouseEnter: () => {
127
+ _ && i && d(!0);
128
+ },
129
+ onMouseLeave: () => {
130
+ i && d(!1);
131
+ },
132
+ children: [
133
+ _ ? /* @__PURE__ */ t(
134
+ g,
135
+ {
136
+ theme: "light",
137
+ type: "tertiary",
138
+ className: e.expandButton,
139
+ icon: /* @__PURE__ */ t($, { "aria-hidden": "true" }),
140
+ "aria-label": "展开侧边栏",
141
+ "aria-expanded": k,
142
+ onClick: () => {
143
+ i ? (y(!1), d(!1)) : d((n) => !n);
144
+ }
145
+ }
146
+ ) : null,
147
+ /* @__PURE__ */ c("div", { className: e.panel, children: [
148
+ /* @__PURE__ */ t("nav", { className: e.menu, "aria-label": E, children: p.map((n) => /* @__PURE__ */ c("div", { className: e.menuGroup, role: "group", "aria-label": n.label || void 0, children: [
149
+ n.label ? /* @__PURE__ */ t("div", { className: e.menuGroupTitle, children: n.label }) : null,
150
+ /* @__PURE__ */ t(
151
+ G,
152
+ {
153
+ mode: "vertical",
154
+ className: e.menuList,
155
+ selectedKeys: L ? [L] : [],
156
+ onSelect: ({ itemKey: s }) => T(String(s)),
157
+ children: n.items.map((s) => /* @__PURE__ */ t(
158
+ G.Item,
159
+ {
160
+ itemKey: s.key,
161
+ icon: s.icon ? /* @__PURE__ */ t(s.icon, {}) : void 0,
162
+ text: b ? b(s) : s.label
163
+ },
164
+ s.key
165
+ ))
166
+ }
167
+ )
168
+ ] }, n.key)) }),
169
+ i ? /* @__PURE__ */ t(
170
+ g,
171
+ {
172
+ theme: "borderless",
173
+ type: "tertiary",
174
+ className: e.collapseButton,
175
+ icon: /* @__PURE__ */ t($, { "aria-hidden": "true" }),
176
+ onClick: () => {
177
+ y((n) => !n), d(!1);
178
+ },
179
+ children: _ ? "固定侧边栏" : "收起侧边栏"
180
+ }
181
+ ) : null
182
+ ] })
183
+ ]
184
+ }
185
+ ) }) : null,
186
+ k && !i && B ? /* @__PURE__ */ t("div", { className: e.mask, "aria-hidden": "true", onClick: () => d(!1) }) : null,
187
+ /* @__PURE__ */ t(f.Content, { className: M ? `${e.content} ${e.contentCentered}` : e.content, children: /* @__PURE__ */ t("div", { className: e.contentInner, children: K ?? /* @__PURE__ */ t(D, {}) }) })
188
+ ] }),
189
+ P
190
+ ] });
191
+ };
192
+ export {
193
+ Ae as B,
194
+ Fe as C,
195
+ Ge as a,
196
+ $e as f,
197
+ Se as i
198
+ };
@@ -0,0 +1,13 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { useContext as r, createContext as i } from "react";
3
+ const e = i(null), C = ({ runtime: o, children: t }) => /* @__PURE__ */ s(e.Provider, { value: o, children: t }), n = () => {
4
+ const o = r(e);
5
+ if (!o) throw new Error("ConsoleRuntimeProvider 尚未初始化");
6
+ return o;
7
+ }, l = () => n().config.brand, m = () => n().customization ?? {};
8
+ export {
9
+ C,
10
+ m as a,
11
+ n as b,
12
+ l as u
13
+ };
@@ -0,0 +1,35 @@
1
+ var l = Object.defineProperty;
2
+ var d = (e, t, o) => t in e ? l(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var i = (e, t, o) => d(e, typeof t != "symbol" ? t + "" : t, o);
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ import { Component as c } from "react";
6
+ import { Card as m, Button as p } from "@douyinfe/semi-ui";
7
+ import { F as n, c as f } from "./page-BhfOrziX.js";
8
+ const a = () => /* @__PURE__ */ r("div", { role: "alert", children: /* @__PURE__ */ r(
9
+ f,
10
+ {
11
+ status: "error",
12
+ title: "页面暂时无法显示",
13
+ description: "本次页面加载没有完成。您可以重新加载;如问题持续,请联系管理员。",
14
+ extra: /* @__PURE__ */ r(p, { theme: "solid", type: "primary", onClick: () => window.location.reload(), children: "重新加载" })
15
+ }
16
+ ) }), E = ({ inLayout: e = !1 }) => e ? /* @__PURE__ */ r(m, { bordered: !1, children: /* @__PURE__ */ r(a, {}) }) : /* @__PURE__ */ r(n, { children: /* @__PURE__ */ r(a, {}) });
17
+ class F extends c {
18
+ constructor() {
19
+ super(...arguments);
20
+ i(this, "state", { failed: !1 });
21
+ }
22
+ static getDerivedStateFromError() {
23
+ return { failed: !0 };
24
+ }
25
+ componentDidCatch(o, s) {
26
+ console.error("产品用户 Web 渲染失败", o, s.componentStack);
27
+ }
28
+ render() {
29
+ return this.state.failed ? /* @__PURE__ */ r(n, { children: /* @__PURE__ */ r(a, {}) }) : this.props.children;
30
+ }
31
+ }
32
+ export {
33
+ F as E,
34
+ E as R
35
+ };
@@ -0,0 +1,8 @@
1
+ import { createCustomerHttpRuntime as r } from "@24city/web-runtime/http";
2
+ const s = /* @__PURE__ */ new Set(["post", "put", "patch", "delete"]), o = () => {
3
+ const e = r();
4
+ return e.http.interceptors.request.use((t) => (t.data === void 0 && s.has((t.method ?? "get").toLowerCase()) && (t.data = {}), t)), { ...e, client: e.http };
5
+ };
6
+ export {
7
+ o as c
8
+ };
@@ -0,0 +1,42 @@
1
+ import { jsx as c, jsxs as p } from "react/jsx-runtime";
2
+ const v = "_linkButton_1i3vf_2", d = "_icon_1i3vf_15", B = "_contentReverse_1i3vf_25", n = {
3
+ linkButton: v,
4
+ icon: d,
5
+ contentReverse: B
6
+ }, $ = ({
7
+ href: r,
8
+ target: e,
9
+ rel: s,
10
+ download: a,
11
+ theme: u = "light",
12
+ type: f = "tertiary",
13
+ size: o = "default",
14
+ block: b = !1,
15
+ icon: i,
16
+ iconPosition: m = "left",
17
+ className: l,
18
+ onClick: _,
19
+ children: h,
20
+ ...k
21
+ }) => {
22
+ const t = ["semi-button", `semi-button-${f}`, `semi-button-${u}`, n.linkButton];
23
+ return o !== "default" && t.push(`semi-button-size-${o}`), b && t.push("semi-button-block"), l && t.push(l), /* @__PURE__ */ c(
24
+ "a",
25
+ {
26
+ className: t.join(" "),
27
+ href: r,
28
+ target: e,
29
+ rel: e === "_blank" ? s ?? "noreferrer" : s,
30
+ download: a,
31
+ onClick: _,
32
+ "aria-label": k["aria-label"],
33
+ children: /* @__PURE__ */ p("span", { className: m === "right" ? `semi-button-content ${n.contentReverse}` : "semi-button-content", children: [
34
+ i ? /* @__PURE__ */ c("span", { className: n.icon, children: i }) : null,
35
+ h
36
+ ] })
37
+ }
38
+ );
39
+ };
40
+ export {
41
+ $ as L
42
+ };
@@ -0,0 +1,365 @@
1
+ import { sanitizeInternalReturnPath as I } from "@24city/web-runtime/core/internal-path";
2
+ import { createContext as O, useSyncExternalStore as R, useContext as x } from "react";
3
+ import { summarizeCustomerError as _ } from "@24city/web-runtime/error-summary";
4
+ const A = (t) => t.includes("\\") || [...t].some((e) => {
5
+ const r = e.charCodeAt(0);
6
+ return r <= 31 || r === 127;
7
+ }), ot = (t) => !A(t) && t.startsWith("/") && !t.startsWith("//") && (() => {
8
+ try {
9
+ const e = new URL(t, "https://product.invalid");
10
+ return e.origin === "https://product.invalid" && I(t, e.pathname) === t;
11
+ } catch {
12
+ return !1;
13
+ }
14
+ })(), st = (t, e) => !A(t) && I(t, e) === t, F = (t, e) => !t || A(t) ? e : I(t, e), D = (t) => typeof t == "object" && t !== null && !Array.isArray(t), p = (t, e) => {
15
+ const r = e.data;
16
+ if (!D(r) || r.code !== 0 || !("data" in r))
17
+ throw new Error(`接口 ${t} 返回了无效响应`);
18
+ return r.data;
19
+ }, u = (t, e, r) => {
20
+ if (!D(t)) throw new Error(`接口 ${e} 字段 ${r} 无效`);
21
+ return t;
22
+ }, o = (t, e, r) => {
23
+ const n = t[e];
24
+ if (typeof n != "string" || !n.trim())
25
+ throw new Error(`接口 ${r} 字段 ${e} 无效`);
26
+ return n;
27
+ }, f = (t, e, r) => {
28
+ const n = t[e];
29
+ if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0)
30
+ throw new Error(`接口 ${r} 字段 ${e} 无效`);
31
+ return n;
32
+ }, w = "/account", c = `${w}/session`, P = `${w}/logout`, i = `${w}/spaces`, v = `${i}/switch`, $ = `${w}/profile`, h = `${w}/wallet`, b = `${w}/entitlements`, m = `${w}/subscription`, s = `${w}/plans`, N = (t, e, r) => {
33
+ const n = t[e];
34
+ if (n !== null && typeof n != "string")
35
+ throw new Error(`接口 ${r} 字段 ${e} 无效`);
36
+ return n;
37
+ }, S = (t, e, r) => {
38
+ const n = t[e];
39
+ if (n != null) {
40
+ if (typeof n != "string")
41
+ throw new Error(`接口 ${r} 字段 ${e} 无效`);
42
+ return n;
43
+ }
44
+ }, z = (t, e, r) => {
45
+ const n = t[e];
46
+ return n === null ? {} : u(n, r, e);
47
+ }, M = (t) => {
48
+ const e = u(t, P, "data"), r = S(e, "endSessionUrl", P);
49
+ if (!r) return null;
50
+ try {
51
+ return new URL(r).protocol === "https:" ? r : null;
52
+ } catch {
53
+ return null;
54
+ }
55
+ }, T = (t) => {
56
+ const e = u(t, c, "data");
57
+ if (e.purpose !== "user") throw new Error("产品用户 Web 只接受 user Purpose 会话");
58
+ return {
59
+ globalUserId: o(e, "globalUserId", c),
60
+ localUserId: f(e, "localUserId", c),
61
+ activeSpaceId: o(e, "activeSpaceId", c),
62
+ authorityId: f(e, "authorityId", c),
63
+ orgId: f(e, "orgId", c),
64
+ purpose: "user",
65
+ csrfToken: o(e, "csrfToken", c),
66
+ issuedAt: o(e, "issuedAt", c),
67
+ lastSeenAt: o(e, "lastSeenAt", c),
68
+ absoluteExpiresAt: o(e, "absoluteExpiresAt", c),
69
+ lastCentralVerifiedAt: o(e, "lastCentralVerifiedAt", c),
70
+ accountCenterUrl: o(e, "accountCenterUrl", c)
71
+ };
72
+ }, L = (t, e, r) => {
73
+ const n = u(t, e, r);
74
+ return {
75
+ id: o(n, "id", e),
76
+ entitlementCode: o(n, "entitlementCode", e),
77
+ status: S(n, "status", e),
78
+ startsAt: o(n, "startsAt", e),
79
+ expiresAt: N(n, "expiresAt", e),
80
+ metadata: z(n, "metadata", e)
81
+ };
82
+ }, W = (t, e) => {
83
+ const r = u(t, i, `spaces[${e}]`), n = u(r.entitlementSummary, i, "entitlementSummary"), a = n.codes, l = r.entitlements;
84
+ if (!Array.isArray(a) || a.some((y) => typeof y != "string"))
85
+ throw new Error(`接口 ${i} 字段 entitlementSummary.codes 无效`);
86
+ if (!Array.isArray(l))
87
+ throw new Error(`接口 ${i} 字段 entitlements 无效`);
88
+ return {
89
+ id: o(r, "id", i),
90
+ name: o(r, "name", i),
91
+ slug: o(r, "slug", i),
92
+ type: o(r, "type", i),
93
+ role: o(r, "role", i),
94
+ status: o(r, "status", i),
95
+ membershipStatus: o(r, "membershipStatus", i),
96
+ entitlementSummary: {
97
+ activeCount: f(n, "activeCount", i),
98
+ codes: [...a]
99
+ },
100
+ entitlements: l.map(
101
+ (y, d) => L(y, i, `entitlements[${d}]`)
102
+ )
103
+ };
104
+ }, q = (t) => {
105
+ const e = u(t, i, "data"), r = o(e, "activeSpaceId", i);
106
+ if (!Array.isArray(e.spaces)) throw new Error(`接口 ${i} 字段 spaces 无效`);
107
+ const n = e.spaces.map(W);
108
+ if (!n.some((a) => a.id === r))
109
+ throw new Error(`接口 ${i} 的当前空间不在可用空间列表中`);
110
+ return { activeSpaceId: r, spaces: n };
111
+ }, B = (t) => {
112
+ const e = u(t, $, "data");
113
+ return { nickName: (S(e, "nickName", $) ?? "").trim() };
114
+ }, V = (t) => {
115
+ const e = u(t, h, "data"), r = (n) => {
116
+ const a = e[n];
117
+ if (typeof a != "number" || !Number.isSafeInteger(a))
118
+ throw new Error(`接口 ${h} 字段 ${n} 无效`);
119
+ return a;
120
+ };
121
+ return {
122
+ spaceId: o(e, "spaceId", h),
123
+ globalUserId: o(e, "globalUserId", h),
124
+ productCode: o(e, "productCode", h),
125
+ availablePoints: r("availablePoints"),
126
+ reservedPoints: r("reservedPoints"),
127
+ globalAvailablePoints: r("globalAvailablePoints"),
128
+ globalReservedPoints: r("globalReservedPoints"),
129
+ productAvailablePoints: r("productAvailablePoints"),
130
+ productReservedPoints: r("productReservedPoints"),
131
+ walletAvailablePoints: r("walletAvailablePoints"),
132
+ walletReservedPoints: r("walletReservedPoints"),
133
+ walletVersion: f(e, "walletVersion", h)
134
+ };
135
+ }, k = (t) => {
136
+ if (t === null) return null;
137
+ const e = u(t, m, "data"), r = e.tier;
138
+ if (typeof r != "number" || !Number.isSafeInteger(r))
139
+ throw new Error(`接口 ${m} 字段 tier 无效`);
140
+ if (typeof e.isDefault != "boolean")
141
+ throw new Error(`接口 ${m} 字段 isDefault 无效`);
142
+ return {
143
+ subscriptionId: N(e, "subscriptionId", m),
144
+ planCode: o(e, "planCode", m),
145
+ planName: (S(e, "planName", m) ?? "").trim(),
146
+ tier: r,
147
+ isDefault: e.isDefault,
148
+ spaceType: S(e, "spaceType", m) ?? "",
149
+ currentPeriodEnd: N(e, "currentPeriodEnd", m)
150
+ };
151
+ }, G = /* @__PURE__ */ new Set(["month", "year", "one_time"]), H = (t, e) => {
152
+ const r = u(t, s, e), n = o(r, "billingPeriod", s);
153
+ if (!G.has(n)) throw new Error(`接口 ${s} 字段 ${e}.billingPeriod 无效`);
154
+ return {
155
+ code: o(r, "code", s),
156
+ amountCents: f(r, "amountCents", s),
157
+ currency: o(r, "currency", s),
158
+ billingPeriod: n,
159
+ durationDays: f(r, "durationDays", s),
160
+ pointCycles: f(r, "pointCycles", s)
161
+ };
162
+ }, j = (t, e) => {
163
+ const r = u(t, s, e), n = r.limit;
164
+ if (n != null && (typeof n != "number" || !Number.isSafeInteger(n) || n < 0))
165
+ throw new Error(`接口 ${s} 字段 ${e}.limit 无效`);
166
+ const a = Array.isArray(r.discounts) ? r.discounts.filter((l) => typeof l == "string") : [];
167
+ return {
168
+ key: S(r, "key", s) ?? "",
169
+ name: o(r, "name", s),
170
+ description: S(r, "description", s) ?? "",
171
+ limit: typeof n == "number" ? n : null,
172
+ discounts: a
173
+ };
174
+ }, K = (t, e) => {
175
+ const r = `data[${e}]`, n = u(t, s, r), a = o(n, "spaceType", s);
176
+ if (a !== "personal" && a !== "team") throw new Error(`接口 ${s} 字段 ${r}.spaceType 无效`);
177
+ if (typeof n.tier != "number" || !Number.isSafeInteger(n.tier)) throw new Error(`接口 ${s} 字段 ${r}.tier 无效`);
178
+ if (typeof n.isDefault != "boolean") throw new Error(`接口 ${s} 字段 ${r}.isDefault 无效`);
179
+ if (!Array.isArray(n.prices)) throw new Error(`接口 ${s} 字段 ${r}.prices 无效`);
180
+ const l = Array.isArray(n.benefits) ? n.benefits : [], y = Array.isArray(n.otherProducts) ? n.otherProducts.filter((d) => typeof d == "string" && d.trim() !== "").map((d) => d.trim()) : [];
181
+ return {
182
+ code: o(n, "code", s),
183
+ name: o(n, "name", s).trim(),
184
+ spaceType: a,
185
+ tier: n.tier,
186
+ isDefault: n.isDefault,
187
+ includedSeats: f(n, "includedSeats", s),
188
+ monthlyPoints: f(n, "monthlyPoints", s),
189
+ prices: n.prices.map((d, E) => H(d, `${r}.prices[${E}]`)),
190
+ benefits: l.map((d, E) => j(d, `${r}.benefits[${E}]`)),
191
+ otherProducts: y
192
+ };
193
+ }, X = (t) => {
194
+ if (!Array.isArray(t)) throw new Error(`接口 ${s} 字段 data 无效`);
195
+ return t.map(K);
196
+ }, at = (t, e) => {
197
+ const r = e === "/" ? "" : e;
198
+ return {
199
+ startLogin(n, a) {
200
+ const l = F(n, a);
201
+ return `${r}${w}/startLogin?returnPath=${encodeURIComponent(l)}`;
202
+ },
203
+ async getSession() {
204
+ return T(p(c, await t.get(c)));
205
+ },
206
+ async getSpaces() {
207
+ return q(p(i, await t.get(i)));
208
+ },
209
+ async switchSpace(n) {
210
+ const a = p(v, await t.post(v, { globalSpaceId: n }));
211
+ return T(a);
212
+ },
213
+ async getProfile() {
214
+ return B(p($, await t.get($)));
215
+ },
216
+ async getWallet() {
217
+ return V(p(h, await t.get(h)));
218
+ },
219
+ async getEntitlements() {
220
+ const n = p(b, await t.get(b));
221
+ if (!Array.isArray(n)) throw new Error(`接口 ${b} 字段 data 无效`);
222
+ return n.map((a, l) => L(a, b, `entitlements[${l}]`));
223
+ },
224
+ async getSubscription() {
225
+ return k(p(m, await t.get(m)));
226
+ },
227
+ async getPlans() {
228
+ return X(p(s, await t.get(s)));
229
+ },
230
+ async logout() {
231
+ const n = p(P, await t.post(P));
232
+ return { endSessionUrl: M(n) };
233
+ }
234
+ };
235
+ }, it = async (t) => {
236
+ let e = await t.getSession();
237
+ const r = await t.getSpaces();
238
+ if (r.activeSpaceId !== e.activeSpaceId && (e = await t.getSession()), r.activeSpaceId !== e.activeSpaceId)
239
+ throw new Error("产品会话与统一空间上下文不一致");
240
+ return { session: e, spaces: r.spaces };
241
+ }, ct = (t) => t == null || !Number.isFinite(t) ? "暂无" : t >= 1e8 ? `${(Math.floor(t / 1e7) / 10).toFixed(1)}亿` : t >= 1e4 ? `${(Math.floor(t / 1e3) / 10).toFixed(1)}万` : t.toLocaleString("zh-CN"), ut = (t) => t.toLocaleString("zh-CN", { maximumFractionDigits: 0 }), lt = (t) => t > 0 && t < 0.01 ? "<0.01" : t.toLocaleString("zh-CN", { maximumFractionDigits: 2 }), dt = (t) => t ? `¥${(t / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "暂无", mt = (t) => {
242
+ if (t === void 0 || t <= 0) return "";
243
+ const e = Math.floor(t / 60), r = Math.floor(t % 60);
244
+ return `${e}:${String(r).padStart(2, "0")}`;
245
+ }, ft = (t) => {
246
+ if (t === void 0 || t <= 0) return "暂无";
247
+ const e = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), n = t % 60;
248
+ return e > 0 ? `${e}小时${r}分` : r > 0 ? `${r}分${n}秒` : `${n}秒`;
249
+ }, pt = (t) => {
250
+ const e = new Date(t);
251
+ return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "short", timeStyle: "short" }).format(e);
252
+ }, gt = (t) => {
253
+ if (!t) return "长期有效";
254
+ const e = new Date(t);
255
+ return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "medium" }).format(e);
256
+ }, Y = () => ({
257
+ session: null,
258
+ spaces: [],
259
+ bootstrapped: !1,
260
+ serviceUnavailable: !1
261
+ }), wt = () => {
262
+ let t = Y();
263
+ const e = /* @__PURE__ */ new Set(), r = (n) => {
264
+ t = n, e.forEach((a) => a());
265
+ };
266
+ return {
267
+ subscribe(n) {
268
+ return e.add(n), () => e.delete(n);
269
+ },
270
+ getState: () => t,
271
+ getCsrfToken: () => {
272
+ var n;
273
+ return ((n = t.session) == null ? void 0 : n.csrfToken) ?? null;
274
+ },
275
+ setContext(n) {
276
+ r({ session: n.session, spaces: [...n.spaces], bootstrapped: !0, serviceUnavailable: !1 });
277
+ },
278
+ setBootstrapping() {
279
+ r({ ...t, bootstrapped: !1, serviceUnavailable: !1 });
280
+ },
281
+ clear(n = {}) {
282
+ r({ session: null, spaces: [], bootstrapped: !0, serviceUnavailable: n.unavailable ?? !1 });
283
+ }
284
+ };
285
+ }, U = O(null), ht = U.Provider, J = () => {
286
+ const t = x(U);
287
+ if (!t) throw new Error("AuthStoreProvider 尚未初始化");
288
+ return t;
289
+ }, St = () => {
290
+ const t = J();
291
+ return R(t.subscribe, t.getState, t.getState);
292
+ }, yt = (t) => t instanceof Error && t.message.trim() ? t.message : "请稍后重试;如问题持续,请联系管理员。", bt = (t, e) => _(t).status === e, C = "24city.console.logout-at", Q = 15e3;
293
+ let g = null;
294
+ const Z = () => {
295
+ try {
296
+ return Number(window.localStorage.getItem(C) ?? Number.NaN);
297
+ } catch {
298
+ return Number.NaN;
299
+ }
300
+ };
301
+ function Pt(t = Date.now()) {
302
+ try {
303
+ window.localStorage.setItem(C, String(t));
304
+ } catch {
305
+ }
306
+ }
307
+ function tt() {
308
+ try {
309
+ window.localStorage.removeItem(C);
310
+ } catch {
311
+ }
312
+ }
313
+ function $t() {
314
+ g = "leaving";
315
+ }
316
+ function Et() {
317
+ return g === "leaving";
318
+ }
319
+ function Nt(t = Date.now()) {
320
+ if (g === "leaving") return !1;
321
+ const e = t - Z();
322
+ return e >= 0 && e < Q && (g = "logged-out"), g === "logged-out";
323
+ }
324
+ function It() {
325
+ return g === "logged-out";
326
+ }
327
+ function At() {
328
+ g === "logged-out" && (g = null);
329
+ }
330
+ function Ct() {
331
+ g = null, tt();
332
+ }
333
+ export {
334
+ ht as A,
335
+ o as B,
336
+ F as C,
337
+ yt as D,
338
+ p as E,
339
+ Pt as a,
340
+ wt as b,
341
+ at as c,
342
+ It as d,
343
+ Ct as e,
344
+ it as f,
345
+ J as g,
346
+ lt as h,
347
+ Et as i,
348
+ mt as j,
349
+ gt as k,
350
+ $t as l,
351
+ pt as m,
352
+ Nt as n,
353
+ ft as o,
354
+ ct as p,
355
+ ut as q,
356
+ At as r,
357
+ dt as s,
358
+ bt as t,
359
+ St as u,
360
+ st as v,
361
+ tt as w,
362
+ ot as x,
363
+ f as y,
364
+ u as z
365
+ };