@24city/web-console 0.3.10 → 0.3.12

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.
@@ -1,210 +0,0 @@
1
- import { jsx as t, jsxs as c, Fragment as H } from "react/jsx-runtime";
2
- import { useState as z, useEffect as $ } from "react";
3
- import { Layout as g, Button as v, Typography as O, Space as F, Nav as S } from "@douyinfe/semi-ui";
4
- import { IconSidebar as T } from "@douyinfe/semi-icons";
5
- import { useLocation as Q, useNavigate as Y, Outlet as q } from "react-router";
6
- import { h as D, B as J, o as V, e as X, W as Z, b as ee } from "./wallet-badge-COpdEDYI.js";
7
- import { u as P, b as te, a as ne } from "./context-CaVim6ZO.js";
8
- import { u as ae } from "./use-media-query-DvyinWNg.js";
9
- import { a as oe } from "./scale-smFifpMm.js";
10
- const se = "_layout_1vz0g_6", le = "_header_1vz0g_13", re = "_headerLeft_1vz0g_34", ce = "_logo_1vz0g_43", ie = "_logoMark_1vz0g_58", de = "_logoText_1vz0g_65", ue = "_modules_1vz0g_75", me = "_module_1vz0g_75", _e = "_moduleText_1vz0g_123", pe = "_moduleIcon_1vz0g_143", he = "_moduleInk_1vz0g_147", ge = "_headerRight_1vz0g_167", ve = "_walletSlot_1vz0g_172", fe = "_body_1vz0g_180", ye = "_sider_1vz0g_186", ke = "_siderInner_1vz0g_200", Ne = "_panel_1vz0g_207", ze = "_expandButton_1vz0g_244", be = "_menu_1vz0g_260", Ie = "_menuGroup_1vz0g_271", we = "_menuGroupPlain_1vz0g_280", xe = "_menuGroupTitle_1vz0g_285", Ce = "_menuList_1vz0g_296", Me = "_collapseButton_1vz0g_419", Be = "_mask_1vz0g_440", Le = "_content_1vz0g_449", Ge = "_contentCentered_1vz0g_455", Se = "_contentInner_1vz0g_467", Te = "_letterMark_1vz0g_520", e = {
11
- layout: se,
12
- header: le,
13
- headerLeft: re,
14
- logo: ce,
15
- logoMark: ie,
16
- logoText: de,
17
- modules: ue,
18
- module: me,
19
- moduleText: _e,
20
- moduleIcon: pe,
21
- moduleInk: he,
22
- headerRight: ge,
23
- walletSlot: ve,
24
- body: fe,
25
- sider: ye,
26
- siderInner: ke,
27
- panel: Ne,
28
- expandButton: ze,
29
- menu: be,
30
- menuGroup: Ie,
31
- menuGroupPlain: we,
32
- menuGroupTitle: xe,
33
- menuList: Ce,
34
- collapseButton: Me,
35
- mask: Be,
36
- content: Le,
37
- contentCentered: Ge,
38
- contentInner: Se,
39
- letterMark: Te
40
- }, $e = (a, l) => a === l || a.startsWith(`${l}/`), Pe = (a, l) => a.flatMap((o) => o.items).find((o) => new URL(o.to, "http://console.local").pathname === l), Re = (a, l) => {
41
- var o;
42
- return (o = [...a].map((r) => ({ module: r, path: new URL(r.to, "http://console.local").pathname })).filter(({ path: r }) => $e(l, r)).sort((r, u) => u.path.length - r.path.length)[0]) == null ? void 0 : o.module;
43
- }, Ue = () => {
44
- const [a, l] = z(!1);
45
- return $(() => {
46
- const o = () => l(window.scrollY > 0);
47
- return o(), window.addEventListener("scroll", o, { passive: !0 }), () => window.removeEventListener("scroll", o);
48
- }, []), a;
49
- }, Ae = ({ size: a = 30, className: l }) => {
50
- const o = P(), r = (u) => l ? `${u} ${l}` : u;
51
- return o.markUrl ? /* @__PURE__ */ t(
52
- "span",
53
- {
54
- className: r(e.logoMark),
55
- style: { width: a, height: a, backgroundImage: `url("${o.markUrl}")` },
56
- "aria-hidden": "true"
57
- }
58
- ) : /* @__PURE__ */ t("span", { className: r(e.letterMark), style: { width: a, height: a }, "aria-hidden": "true", children: Array.from(o.mark).slice(0, 2).join("") });
59
- }, qe = ({
60
- modules: a = [],
61
- activeModuleKey: l,
62
- moduleTarget: o,
63
- sidebar: r = [],
64
- selectedKey: u,
65
- renderItemLabel: b,
66
- headerRight: R,
67
- menuLabel: U = "工作台菜单",
68
- children: A,
69
- extra: E
70
- }) => {
71
- var G;
72
- const { config: I } = te(), w = P(), f = Q(), y = Y(), x = I.routes.app, p = D(x, J(ne())), C = V(x, f.pathname), h = C ? [] : r ?? [], M = h.length > 0, K = l ?? ((G = Re(a, f.pathname)) == null ? void 0 : G.key), m = Pe([...h, p], f.pathname), B = u ?? (m == null ? void 0 : m.key), i = ae(oe("desktop")), W = Ue(), [_, k] = z(!i), [N, d] = z(!1), j = new Map([...h, p].flatMap((n) => n.items.map((s) => [s.key, s])));
73
- $(() => {
74
- k(!i), d(!1);
75
- }, [i]);
76
- const L = (n) => {
77
- const s = j.get(n);
78
- s && y(s.to), d(!1);
79
- };
80
- return /* @__PURE__ */ c(g, { className: e.layout, children: [
81
- /* @__PURE__ */ c(g.Header, { className: e.header, "data-scrolled": W ? "true" : "false", children: [
82
- /* @__PURE__ */ c("div", { className: e.headerLeft, children: [
83
- /* @__PURE__ */ c(
84
- v,
85
- {
86
- theme: "borderless",
87
- type: "tertiary",
88
- className: e.logo,
89
- "aria-label": `${w.shortName} 首页`,
90
- onClick: () => y(I.routes.publicHome),
91
- children: [
92
- /* @__PURE__ */ t(Ae, {}),
93
- /* @__PURE__ */ t(O.Text, { className: e.logoText, children: w.shortName })
94
- ]
95
- }
96
- ),
97
- a.length ? /* @__PURE__ */ t("div", { className: e.modules, role: "navigation", "aria-label": "产品模块", children: a.map((n) => /* @__PURE__ */ c(
98
- v,
99
- {
100
- theme: "borderless",
101
- type: "tertiary",
102
- className: e.module,
103
- "aria-current": K === n.key ? "page" : void 0,
104
- onClick: () => y(o ? o(n) : n.to),
105
- children: [
106
- /* @__PURE__ */ c("span", { className: e.moduleText, children: [
107
- n.icon ? /* @__PURE__ */ t("span", { className: e.moduleIcon, children: /* @__PURE__ */ t(n.icon, {}) }) : null,
108
- n.label
109
- ] }),
110
- /* @__PURE__ */ t("span", { className: e.moduleInk, "aria-hidden": "true" })
111
- ]
112
- },
113
- n.key
114
- )) }) : null
115
- ] }),
116
- /* @__PURE__ */ t(F, { spacing: 10, className: e.headerRight, children: R ?? /* @__PURE__ */ c(H, { children: [
117
- /* @__PURE__ */ t(X, {}),
118
- /* @__PURE__ */ t("span", { className: e.walletSlot, children: /* @__PURE__ */ t(Z, {}) }),
119
- /* @__PURE__ */ t(ee, { personal: p, selectedKey: m && p.items.includes(m) ? m.key : void 0, onOpen: L })
120
- ] }) })
121
- ] }),
122
- /* @__PURE__ */ c(g, { className: e.body, children: [
123
- M ? /* @__PURE__ */ t("aside", { className: e.sider, "data-collapsed": _ ? "true" : "false", children: /* @__PURE__ */ c(
124
- "div",
125
- {
126
- className: e.siderInner,
127
- "data-collapsed": _ ? "true" : "false",
128
- "data-peek": N ? "true" : "false",
129
- onMouseEnter: () => {
130
- _ && i && d(!0);
131
- },
132
- onMouseLeave: () => {
133
- i && d(!1);
134
- },
135
- children: [
136
- _ ? /* @__PURE__ */ t(
137
- v,
138
- {
139
- theme: "light",
140
- type: "tertiary",
141
- className: e.expandButton,
142
- icon: /* @__PURE__ */ t(T, { "aria-hidden": "true" }),
143
- "aria-label": "展开侧边栏",
144
- "aria-expanded": N,
145
- onClick: () => {
146
- i ? (k(!1), d(!1)) : d((n) => !n);
147
- }
148
- }
149
- ) : null,
150
- /* @__PURE__ */ c("div", { className: e.panel, children: [
151
- /* @__PURE__ */ t("nav", { className: e.menu, "aria-label": U, children: h.map((n) => /* @__PURE__ */ c(
152
- "div",
153
- {
154
- className: n.label ? e.menuGroup : `${e.menuGroup} ${e.menuGroupPlain}`,
155
- role: "group",
156
- "aria-label": n.label || void 0,
157
- children: [
158
- n.label ? /* @__PURE__ */ t("div", { className: e.menuGroupTitle, children: n.label }) : null,
159
- /* @__PURE__ */ t(
160
- S,
161
- {
162
- mode: "vertical",
163
- className: e.menuList,
164
- selectedKeys: B ? [B] : [],
165
- onSelect: ({ itemKey: s }) => L(String(s)),
166
- children: n.items.map((s) => /* @__PURE__ */ t(
167
- S.Item,
168
- {
169
- itemKey: s.key,
170
- icon: s.icon ? /* @__PURE__ */ t(s.icon, {}) : void 0,
171
- text: b ? b(s) : s.label
172
- },
173
- s.key
174
- ))
175
- }
176
- )
177
- ]
178
- },
179
- n.key
180
- )) }),
181
- i ? /* @__PURE__ */ t(
182
- v,
183
- {
184
- theme: "borderless",
185
- type: "tertiary",
186
- className: e.collapseButton,
187
- icon: /* @__PURE__ */ t(T, { "aria-hidden": "true" }),
188
- onClick: () => {
189
- k((n) => !n), d(!1);
190
- },
191
- children: _ ? "固定侧边栏" : "收起侧边栏"
192
- }
193
- ) : null
194
- ] })
195
- ]
196
- }
197
- ) }) : null,
198
- N && !i && M ? /* @__PURE__ */ t("div", { className: e.mask, "aria-hidden": "true", onClick: () => d(!1) }) : null,
199
- /* @__PURE__ */ t(g.Content, { className: C ? `${e.content} ${e.contentCentered}` : e.content, children: /* @__PURE__ */ t("div", { className: e.contentInner, children: A ?? /* @__PURE__ */ t(q, {}) }) })
200
- ] }),
201
- E
202
- ] });
203
- };
204
- export {
205
- Ae as B,
206
- qe as C,
207
- Pe as a,
208
- Re as f,
209
- $e as i
210
- };
@@ -1,378 +0,0 @@
1
- import { sanitizeInternalReturnPath as I } from "@24city/web-runtime/core/internal-path";
2
- import { createContext as _, useSyncExternalStore as x, useContext as F } from "react";
3
- import { summarizeCustomerError as z } from "@24city/web-runtime/error-summary";
4
- const C = (t) => t.includes("\\") || [...t].some((e) => {
5
- const o = e.charCodeAt(0);
6
- return o <= 31 || o === 127;
7
- }), at = (t) => !C(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
- })(), it = (t, e) => !C(t) && I(t, e) === t, M = (t, e) => !t || C(t) ? e : I(t, e), O = (t) => typeof t == "object" && t !== null && !Array.isArray(t), l = (t, e) => {
15
- const o = e.data;
16
- if (!O(o) || o.code !== 0 || !("data" in o))
17
- throw new Error(`接口 ${t} 返回了无效响应`);
18
- return o.data;
19
- }, u = (t, e, o) => {
20
- if (!O(t)) throw new Error(`接口 ${e} 字段 ${o} 无效`);
21
- return t;
22
- }, s = (t, e, o) => {
23
- const r = t[e];
24
- if (typeof r != "string" || !r.trim())
25
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
26
- return r;
27
- }, f = (t, e, o) => {
28
- const r = t[e];
29
- if (typeof r != "number" || !Number.isSafeInteger(r) || r < 0)
30
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
31
- return r;
32
- }, g = "/account", c = `${g}/session`, $ = `${g}/logout`, i = `${g}/spaces`, T = `${i}/switch`, E = `${g}/profile`, h = `${g}/wallet`, P = `${g}/entitlements`, p = `${g}/subscription`, a = `${g}/plans`, y = `${g}/shown-prompts`, A = (t, e, o) => {
33
- const r = t[e];
34
- if (r !== null && typeof r != "string")
35
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
36
- return r;
37
- }, S = (t, e, o) => {
38
- const r = t[e];
39
- if (r != null) {
40
- if (typeof r != "string")
41
- throw new Error(`接口 ${o} 字段 ${e} 无效`);
42
- return r;
43
- }
44
- }, W = (t, e, o) => {
45
- const r = t[e];
46
- return r === null ? {} : u(r, o, e);
47
- }, q = (t) => {
48
- const e = u(t, $, "data"), o = S(e, "endSessionUrl", $);
49
- if (!o) return null;
50
- try {
51
- return new URL(o).protocol === "https:" ? o : null;
52
- } catch {
53
- return null;
54
- }
55
- }, D = (t) => {
56
- const e = u(t, c, "data");
57
- if (e.purpose !== "user") throw new Error("产品用户 Web 只接受 user Purpose 会话");
58
- return {
59
- globalUserId: s(e, "globalUserId", c),
60
- localUserId: f(e, "localUserId", c),
61
- activeSpaceId: s(e, "activeSpaceId", c),
62
- authorityId: f(e, "authorityId", c),
63
- orgId: f(e, "orgId", c),
64
- purpose: "user",
65
- csrfToken: s(e, "csrfToken", c),
66
- issuedAt: s(e, "issuedAt", c),
67
- lastSeenAt: s(e, "lastSeenAt", c),
68
- absoluteExpiresAt: s(e, "absoluteExpiresAt", c),
69
- lastCentralVerifiedAt: s(e, "lastCentralVerifiedAt", c),
70
- accountCenterUrl: s(e, "accountCenterUrl", c)
71
- };
72
- }, U = (t, e, o) => {
73
- const r = u(t, e, o);
74
- return {
75
- id: s(r, "id", e),
76
- entitlementCode: s(r, "entitlementCode", e),
77
- status: S(r, "status", e),
78
- startsAt: s(r, "startsAt", e),
79
- expiresAt: A(r, "expiresAt", e),
80
- metadata: W(r, "metadata", e)
81
- };
82
- }, k = (t, e) => {
83
- const o = u(t, i, `spaces[${e}]`), r = u(o.entitlementSummary, i, "entitlementSummary"), n = r.codes, d = o.entitlements;
84
- if (!Array.isArray(n) || n.some((b) => typeof b != "string"))
85
- throw new Error(`接口 ${i} 字段 entitlementSummary.codes 无效`);
86
- if (!Array.isArray(d))
87
- throw new Error(`接口 ${i} 字段 entitlements 无效`);
88
- return {
89
- id: s(o, "id", i),
90
- name: s(o, "name", i),
91
- slug: s(o, "slug", i),
92
- type: s(o, "type", i),
93
- role: s(o, "role", i),
94
- status: s(o, "status", i),
95
- membershipStatus: s(o, "membershipStatus", i),
96
- entitlementSummary: {
97
- activeCount: f(r, "activeCount", i),
98
- codes: [...n]
99
- },
100
- entitlements: d.map(
101
- (b, m) => U(b, i, `entitlements[${m}]`)
102
- )
103
- };
104
- }, B = (t) => {
105
- const e = u(t, i, "data"), o = s(e, "activeSpaceId", i);
106
- if (!Array.isArray(e.spaces)) throw new Error(`接口 ${i} 字段 spaces 无效`);
107
- const r = e.spaces.map(k);
108
- if (!r.some((n) => n.id === o))
109
- throw new Error(`接口 ${i} 的当前空间不在可用空间列表中`);
110
- return { activeSpaceId: o, spaces: r };
111
- }, H = (t) => {
112
- const e = u(t, E, "data");
113
- return { nickName: (S(e, "nickName", E) ?? "").trim() };
114
- }, V = (t) => {
115
- const e = u(t, h, "data"), o = (r) => {
116
- const n = e[r];
117
- if (typeof n != "number" || !Number.isSafeInteger(n))
118
- throw new Error(`接口 ${h} 字段 ${r} 无效`);
119
- return n;
120
- };
121
- return {
122
- spaceId: s(e, "spaceId", h),
123
- globalUserId: s(e, "globalUserId", h),
124
- productCode: s(e, "productCode", h),
125
- availablePoints: o("availablePoints"),
126
- reservedPoints: o("reservedPoints"),
127
- globalAvailablePoints: o("globalAvailablePoints"),
128
- globalReservedPoints: o("globalReservedPoints"),
129
- productAvailablePoints: o("productAvailablePoints"),
130
- productReservedPoints: o("productReservedPoints"),
131
- walletAvailablePoints: o("walletAvailablePoints"),
132
- walletReservedPoints: o("walletReservedPoints"),
133
- walletVersion: f(e, "walletVersion", h)
134
- };
135
- }, j = (t) => {
136
- if (t === null) return null;
137
- const e = u(t, p, "data"), o = e.tier;
138
- if (typeof o != "number" || !Number.isSafeInteger(o))
139
- throw new Error(`接口 ${p} 字段 tier 无效`);
140
- if (typeof e.isDefault != "boolean")
141
- throw new Error(`接口 ${p} 字段 isDefault 无效`);
142
- return {
143
- subscriptionId: A(e, "subscriptionId", p),
144
- planCode: s(e, "planCode", p),
145
- planName: (S(e, "planName", p) ?? "").trim(),
146
- tier: o,
147
- isDefault: e.isDefault,
148
- spaceType: S(e, "spaceType", p) ?? "",
149
- currentPeriodEnd: A(e, "currentPeriodEnd", p)
150
- };
151
- }, G = /* @__PURE__ */ new Set(["month", "year", "one_time"]), K = (t, e) => {
152
- const o = u(t, a, e), r = s(o, "billingPeriod", a);
153
- if (!G.has(r)) throw new Error(`接口 ${a} 字段 ${e}.billingPeriod 无效`);
154
- return {
155
- code: s(o, "code", a),
156
- amountCents: f(o, "amountCents", a),
157
- currency: s(o, "currency", a),
158
- billingPeriod: r,
159
- durationDays: f(o, "durationDays", a),
160
- pointCycles: f(o, "pointCycles", a)
161
- };
162
- }, X = (t, e) => {
163
- const o = u(t, a, e), r = o.limit;
164
- if (r != null && (typeof r != "number" || !Number.isSafeInteger(r) || r < 0))
165
- throw new Error(`接口 ${a} 字段 ${e}.limit 无效`);
166
- const n = Array.isArray(o.discounts) ? o.discounts.filter((d) => typeof d == "string") : [];
167
- return {
168
- key: S(o, "key", a) ?? "",
169
- name: s(o, "name", a),
170
- description: S(o, "description", a) ?? "",
171
- limit: typeof r == "number" ? r : null,
172
- discounts: n
173
- };
174
- }, Y = (t, e) => {
175
- const o = `data[${e}]`, r = u(t, a, o), n = s(r, "spaceType", a);
176
- if (n !== "personal" && n !== "team") throw new Error(`接口 ${a} 字段 ${o}.spaceType 无效`);
177
- if (typeof r.tier != "number" || !Number.isSafeInteger(r.tier)) throw new Error(`接口 ${a} 字段 ${o}.tier 无效`);
178
- if (typeof r.isDefault != "boolean") throw new Error(`接口 ${a} 字段 ${o}.isDefault 无效`);
179
- if (!Array.isArray(r.prices)) throw new Error(`接口 ${a} 字段 ${o}.prices 无效`);
180
- const d = Array.isArray(r.benefits) ? r.benefits : [], b = Array.isArray(r.otherProducts) ? r.otherProducts.filter((m) => typeof m == "string" && m.trim() !== "").map((m) => m.trim()) : [];
181
- return {
182
- code: s(r, "code", a),
183
- name: s(r, "name", a).trim(),
184
- spaceType: n,
185
- tier: r.tier,
186
- isDefault: r.isDefault,
187
- includedSeats: f(r, "includedSeats", a),
188
- monthlyPoints: f(r, "monthlyPoints", a),
189
- prices: r.prices.map((m, N) => K(m, `${o}.prices[${N}]`)),
190
- benefits: d.map((m, N) => X(m, `${o}.benefits[${N}]`)),
191
- otherProducts: b
192
- };
193
- }, L = (t, e) => {
194
- const o = u(t, y, "data")[e];
195
- if (!Array.isArray(o) || o.some((r) => typeof r != "string"))
196
- throw new Error(`接口 ${y} 字段 ${e} 无效`);
197
- return [...o];
198
- }, J = (t) => {
199
- if (!Array.isArray(t)) throw new Error(`接口 ${a} 字段 data 无效`);
200
- return t.map(Y);
201
- }, ct = (t, e) => {
202
- const o = e === "/" ? "" : e;
203
- return {
204
- startLogin(r, n) {
205
- const d = M(r, n);
206
- return `${o}${g}/startLogin?returnPath=${encodeURIComponent(d)}`;
207
- },
208
- async getSession() {
209
- return D(l(c, await t.get(c)));
210
- },
211
- async getSpaces() {
212
- return B(l(i, await t.get(i)));
213
- },
214
- async switchSpace(r) {
215
- const n = l(T, await t.post(T, { globalSpaceId: r }));
216
- return D(n);
217
- },
218
- async getProfile() {
219
- return H(l(E, await t.get(E)));
220
- },
221
- async getWallet() {
222
- return V(l(h, await t.get(h)));
223
- },
224
- async getEntitlements() {
225
- const r = l(P, await t.get(P));
226
- if (!Array.isArray(r)) throw new Error(`接口 ${P} 字段 data 无效`);
227
- return r.map((n, d) => U(n, P, `entitlements[${d}]`));
228
- },
229
- async getSubscription() {
230
- return j(l(p, await t.get(p)));
231
- },
232
- async getPlans() {
233
- return J(l(a, await t.get(a)));
234
- },
235
- async logout() {
236
- const r = l($, await t.post($));
237
- return { endSessionUrl: q(r) };
238
- },
239
- async getShownPrompts(r) {
240
- const n = await t.get(y, { params: { keys: r.join(",") } });
241
- return L(l(y, n), "shown");
242
- },
243
- async claimShownPrompts(r) {
244
- const n = await t.post(y, { keys: [...r] });
245
- return L(l(y, n), "claimed");
246
- }
247
- };
248
- }, ut = async (t) => {
249
- let e = await t.getSession();
250
- const o = await t.getSpaces();
251
- if (o.activeSpaceId !== e.activeSpaceId && (e = await t.getSession()), o.activeSpaceId !== e.activeSpaceId)
252
- throw new Error("产品会话与统一空间上下文不一致");
253
- return { session: e, spaces: o.spaces };
254
- }, lt = (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"), dt = (t) => t.toLocaleString("zh-CN", { maximumFractionDigits: 0 }), mt = (t) => t > 0 && t < 0.01 ? "<0.01" : t.toLocaleString("zh-CN", { maximumFractionDigits: 2 }), pt = (t) => t ? `¥${(t / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "暂无", ft = (t) => {
255
- if (t === void 0 || t <= 0) return "";
256
- const e = Math.floor(t / 60), o = Math.floor(t % 60);
257
- return `${e}:${String(o).padStart(2, "0")}`;
258
- }, gt = (t) => {
259
- if (t === void 0 || t <= 0) return "暂无";
260
- const e = Math.floor(t / 3600), o = Math.floor(t % 3600 / 60), r = t % 60;
261
- return e > 0 ? `${e}小时${o}分` : o > 0 ? `${o}分${r}秒` : `${r}秒`;
262
- }, wt = (t) => {
263
- const e = new Date(t);
264
- return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "short", timeStyle: "short" }).format(e);
265
- }, ht = (t) => {
266
- if (!t) return "长期有效";
267
- const e = new Date(t);
268
- return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "medium" }).format(e);
269
- }, Q = () => ({
270
- session: null,
271
- spaces: [],
272
- bootstrapped: !1,
273
- serviceUnavailable: !1
274
- }), St = () => {
275
- let t = Q();
276
- const e = /* @__PURE__ */ new Set(), o = (r) => {
277
- t = r, e.forEach((n) => n());
278
- };
279
- return {
280
- subscribe(r) {
281
- return e.add(r), () => e.delete(r);
282
- },
283
- getState: () => t,
284
- getCsrfToken: () => {
285
- var r;
286
- return ((r = t.session) == null ? void 0 : r.csrfToken) ?? null;
287
- },
288
- setContext(r) {
289
- o({ session: r.session, spaces: [...r.spaces], bootstrapped: !0, serviceUnavailable: !1 });
290
- },
291
- setBootstrapping() {
292
- o({ ...t, bootstrapped: !1, serviceUnavailable: !1 });
293
- },
294
- clear(r = {}) {
295
- o({ session: null, spaces: [], bootstrapped: !0, serviceUnavailable: r.unavailable ?? !1 });
296
- }
297
- };
298
- }, R = _(null), yt = R.Provider, Z = () => {
299
- const t = F(R);
300
- if (!t) throw new Error("AuthStoreProvider 尚未初始化");
301
- return t;
302
- }, bt = () => {
303
- const t = Z();
304
- return x(t.subscribe, t.getState, t.getState);
305
- }, Pt = (t) => t instanceof Error && t.message.trim() ? t.message : "请稍后重试;如问题持续,请联系管理员。", $t = (t, e) => z(t).status === e, v = "24city.console.logout-at", tt = 15e3;
306
- let w = null;
307
- const et = () => {
308
- try {
309
- return Number(window.localStorage.getItem(v) ?? Number.NaN);
310
- } catch {
311
- return Number.NaN;
312
- }
313
- };
314
- function Et(t = Date.now()) {
315
- try {
316
- window.localStorage.setItem(v, String(t));
317
- } catch {
318
- }
319
- }
320
- function rt() {
321
- try {
322
- window.localStorage.removeItem(v);
323
- } catch {
324
- }
325
- }
326
- function Nt() {
327
- w = "leaving";
328
- }
329
- function At() {
330
- return w === "leaving";
331
- }
332
- function It(t = Date.now()) {
333
- if (w === "leaving") return !1;
334
- const e = t - et();
335
- return e >= 0 && e < tt && (w = "logged-out"), w === "logged-out";
336
- }
337
- function Ct() {
338
- return w === "logged-out";
339
- }
340
- function vt() {
341
- w === "logged-out" && (w = null);
342
- }
343
- function Tt() {
344
- w = null, rt();
345
- }
346
- export {
347
- yt as A,
348
- s as B,
349
- M as C,
350
- Pt as D,
351
- l as E,
352
- Et as a,
353
- St as b,
354
- ct as c,
355
- Ct as d,
356
- Tt as e,
357
- ut as f,
358
- Z as g,
359
- mt as h,
360
- At as i,
361
- ft as j,
362
- ht as k,
363
- Nt as l,
364
- wt as m,
365
- It as n,
366
- gt as o,
367
- lt as p,
368
- dt as q,
369
- vt as r,
370
- pt as s,
371
- $t as t,
372
- bt as u,
373
- it as v,
374
- rt as w,
375
- at as x,
376
- f as y,
377
- u as z
378
- };