@24city/web-console 0.3.11 → 0.3.13

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,629 +0,0 @@
1
- import { jsx as s, jsxs as _, Fragment as ye } from "react/jsx-runtime";
2
- import { useState as D, useRef as ke, useCallback as we, useEffect as be } from "react";
3
- import { Skeleton as ie, Button as k, Toast as ge, Modal as $e, Avatar as Be, Popover as Oe, Tooltip as Me } from "@douyinfe/semi-ui";
4
- import { IconUser as U, IconCrown as De, IconGift as Ue, IconChevronRight as V, IconUserGroup as le, IconChevronUp as Fe, IconChevronDown as Re, IconTick as ze, IconMoon as Ke } from "@douyinfe/semi-icons";
5
- import { useNavigate as Z } from "react-router";
6
- import { C as We } from "./color-mode-switch-BinpVuZ0.js";
7
- import { a as ve, b as w } from "./context-CaVim6ZO.js";
8
- import { u as je } from "./color-mode-DC4KIKya.js";
9
- import { q as N, k as qe, a as Ge, t as Ne, w as Ye, l as Qe, u as L, g as Ve, f as de } from "./logout-signal-CsnJzWTz.js";
10
- import { useQueryClient as Se, useQuery as E } from "@tanstack/react-query";
11
- import { notifyCustomerSessionChanged as Ce } from "@24city/web-runtime/session-sync";
12
- const He = "_trigger_w6k09_7", Xe = "_avatarWrap_w6k09_28", Ze = "_avatar_w6k09_28", Je = "_card_w6k09_81", et = "_identity_w6k09_91", tt = "_who_w6k09_99", nt = "_nameRow_w6k09_108", at = "_name_w6k09_108", st = "_planChip_w6k09_125", ot = "_diamond_w6k09_155", ct = "_spaceToggle_w6k09_163", rt = "_spaceStatic_w6k09_164", it = "_spaceSwitchText_w6k09_185", lt = "_spaceName_w6k09_191", dt = "_spaceType_w6k09_197", ut = "_spaceList_w6k09_207", pt = "_spaceOption_w6k09_216", mt = "_spaceCheck_w6k09_238", _t = "_plan_w6k09_125", ht = "_allowance_w6k09_249", ft = "_links_w6k09_259", yt = "_link_w6k09_259", kt = "_linkIcon_w6k09_297", wt = "_linkLabel_w6k09_308", bt = "_linkArrow_w6k09_313", gt = "_appearance_w6k09_320", vt = "_divider_w6k09_330", Nt = "_logout_w6k09_336", l = {
13
- trigger: He,
14
- avatarWrap: Xe,
15
- avatar: Ze,
16
- card: Je,
17
- identity: et,
18
- who: tt,
19
- nameRow: nt,
20
- name: at,
21
- planChip: st,
22
- diamond: ot,
23
- spaceToggle: ct,
24
- spaceStatic: rt,
25
- spaceSwitchText: it,
26
- spaceName: lt,
27
- spaceType: dt,
28
- spaceList: ut,
29
- spaceOption: pt,
30
- spaceCheck: mt,
31
- plan: _t,
32
- allowance: ht,
33
- links: ft,
34
- link: yt,
35
- linkIcon: kt,
36
- linkLabel: wt,
37
- linkArrow: bt,
38
- appearance: gt,
39
- divider: vt,
40
- logout: Nt
41
- }, St = ["profile", "subscription", "points"], Ct = (e) => St.includes(e), v = (e, t) => `${e}/account/${t}`, aa = (e, t) => t === `${e}/account` || t.startsWith(`${e}/account/`), M = (e) => `account-${e}`, x = {
42
- profile: M("profile"),
43
- subscription: M("subscription"),
44
- points: M("points")
45
- }, Tt = /^[a-z][a-z0-9-]{0,31}$/, At = (e) => {
46
- const t = e.accountSections ?? [], n = /* @__PURE__ */ new Set();
47
- for (const a of t) {
48
- if (!Tt.test(a.key))
49
- throw new Error(`个人中心分区 key 不合法:${a.key}(小写字母开头,只含小写字母、数字和连字符)`);
50
- if (Ct(a.key)) throw new Error(`个人中心分区 key 与内置分区重名:${a.key}`);
51
- if (n.has(a.key)) throw new Error(`个人中心分区 key 重复:${a.key}`);
52
- n.add(a.key);
53
- }
54
- return t;
55
- }, Et = (e, t = []) => ({
56
- key: "personal",
57
- label: "个人中心",
58
- items: [
59
- { key: x.profile, label: "账号与安全", to: v(e, "profile"), icon: U },
60
- { key: x.subscription, label: "订阅与套餐", to: v(e, "subscription"), icon: De },
61
- { key: x.points, label: "积分与明细", to: v(e, "points"), icon: Ue },
62
- ...t.map(
63
- (n) => ({
64
- key: M(n.key),
65
- label: n.label,
66
- to: v(e, n.key),
67
- icon: n.icon
68
- })
69
- )
70
- ]
71
- }), xt = 1e6, J = (e) => e != null && e >= xt, sa = (e) => !!e && e.limit !== null && e.used >= e.limit, oa = (e, t) => e.limit === null ? `已有 ${e.used} ${t}` : e.limit === 0 && e.used === 0 ? "套餐未包含" : J(e.limit) ? `已有 ${e.used} ${t} · 不限` : `已用 ${e.used}/${e.limit}`, ca = (e, t) => (n) => n !== null && J(n) ? t : e(N(n ?? 0)), Te = (e, t) => e.find((n) => n.key === t), ue = (e, t) => {
72
- const n = e.findIndex((a) => a.key === t);
73
- return n === -1 ? e.length : n;
74
- }, It = (e, t) => {
75
- const n = Te(e, t.key), a = n ? n.on(t.limit) : t.limit === null ? t.name : `${t.name} ${J(t.limit) ? "不限" : N(t.limit)}`;
76
- return t.discounts.length ? `${a}(${t.discounts.join("、")})` : a;
77
- }, Lt = (e) => {
78
- if (e.length < 2) return /* @__PURE__ */ new Set();
79
- const t = new Set(e.flatMap((n) => n.benefits.filter((a) => a.limit === null).map((a) => a.key)));
80
- return new Set(
81
- [...t].filter((n) => e.every((a) => a.benefits.some((o) => o.key === n && o.limit === null)))
82
- );
83
- }, Pt = (e, t = [], n = {}) => {
84
- var m;
85
- const a = n.benefitCopy ?? [], o = Lt(t), c = [];
86
- for (const r of [...e.benefits, ...t.flatMap((d) => d.benefits)])
87
- !c.includes(r.key) && !o.has(r.key) && c.push(r.key);
88
- const i = [];
89
- for (const r of [...c].sort((d, u) => ue(a, d) - ue(a, u) || c.indexOf(d) - c.indexOf(u))) {
90
- const d = e.benefits.find((f) => f.key === r);
91
- if (d) {
92
- i.push({ text: It(a, d), included: !0 });
93
- continue;
94
- }
95
- const u = (m = Te(a, r)) == null ? void 0 : m.off;
96
- u && i.push({ text: u, included: !1 });
97
- }
98
- return i;
99
- }, H = (e) => e.planName || e.planCode, $t = (e) => e.isDefault || !e.currentPeriodEnd ? "长期有效" : `有效期至 ${qe(e.currentPeriodEnd)}`, Bt = 1440 * 60 * 1e3, Ot = (e, t = Date.now()) => {
100
- if (e.isDefault || !e.currentPeriodEnd) return null;
101
- const n = Date.parse(e.currentPeriodEnd);
102
- return Number.isFinite(n) ? Math.max(0, Math.ceil((n - t) / Bt)) : null;
103
- }, Mt = 7, Dt = { month: "/月", year: "/年", one_time: "" }, Ut = (e) => {
104
- const t = (e.amountCents / 100).toLocaleString("zh-CN", { maximumFractionDigits: 2 });
105
- return e.currency === "CNY" ? `¥${t}` : `${e.currency} ${t}`;
106
- }, ra = (e) => e ? { focusPlan: e } : void 0, ia = (e) => {
107
- if (typeof e != "object" || e === null) return;
108
- const t = e.focusPlan;
109
- return typeof t == "string" && t ? t : void 0;
110
- }, Ft = (e) => `${Ut(e)}${Dt[e.billingPeriod]}`, Rt = (e) => {
111
- const t = e.prices.filter((o) => o.amountCents > 0), n = t.filter((o) => o.billingPeriod === "month");
112
- return (n.length ? n : t).reduce((o, c) => !o || c.amountCents < o.amountCents ? c : o, null);
113
- }, zt = (e, t, n) => {
114
- const o = (e ?? []).filter(
115
- (c) => c.spaceType === t && !c.isDefault && (n === null || c.tier > n)
116
- ).map((c) => ({ plan: c, price: Rt(c) }));
117
- return o.sort(
118
- (c, i) => {
119
- var m, r;
120
- return c.plan.tier - i.plan.tier || (((m = c.price) == null ? void 0 : m.amountCents) ?? Number.MAX_SAFE_INTEGER) - (((r = i.price) == null ? void 0 : r.amountCents) ?? Number.MAX_SAFE_INTEGER);
121
- }
122
- ), o[0] ?? null;
123
- }, la = (e) => e == null ? void 0 : e.filter((t) => t.spaceType === "team" && !t.isDefault).sort((t, n) => t.tier - n.tier)[0], Kt = (e, t) => e == null ? void 0 : e.find((n) => n.code === t.planCode), Wt = (e, t = [], n = {}) => {
124
- if (!e) return ["积分按月发放", "24.city 全产品通用"];
125
- const a = [];
126
- e.monthlyPoints > 0 && a.push(`每月 ${N(e.monthlyPoints)} 积分`);
127
- for (const o of Pt(e, t, n).filter((c) => c.included).slice(0, 2)) a.push(o.text);
128
- return a.length < 2 && a.push("24.city 全产品通用"), a;
129
- }, jt = "_promo_uc5su_6", qt = "_member_uc5su_7", Gt = "_plain_uc5su_8", Yt = "_promoArt_uc5su_28", Qt = "_promoBody_uc5su_38", Vt = "_promoTitle_uc5su_44", Ht = "_promoText_uc5su_55", Xt = "_cta_uc5su_63", Zt = "_ctaButton_uc5su_69", Jt = "_ctaTag_uc5su_89", en = "_ownerOnly_uc5su_106", tn = "_memberArt_uc5su_122", nn = "_memberBody_uc5su_132", an = "_memberEyebrow_uc5su_139", sn = "_memberTitle_uc5su_145", on = "_memberMeta_uc5su_159", cn = "_memberCta_uc5su_166", rn = "_plainBody_uc5su_200", ln = "_plainText_uc5su_207", dn = "_retry_uc5su_212", un = "_loading_uc5su_216", pn = "_assets_uc5su_224", mn = "_asset_uc5su_224", _n = "_coin_uc5su_279", hn = "_assetLabel_uc5su_287", fn = "_assetValue_uc5su_291", yn = "_assetArrow_uc5su_299", kn = "_assetDivider_uc5su_312", p = {
130
- promo: jt,
131
- member: qt,
132
- plain: Gt,
133
- promoArt: Yt,
134
- promoBody: Qt,
135
- promoTitle: Vt,
136
- promoText: Ht,
137
- cta: Xt,
138
- ctaButton: Zt,
139
- ctaTag: Jt,
140
- ownerOnly: en,
141
- memberArt: tn,
142
- memberBody: nn,
143
- memberEyebrow: an,
144
- memberTitle: sn,
145
- memberMeta: on,
146
- memberCta: cn,
147
- plainBody: rn,
148
- plainText: ln,
149
- retry: dn,
150
- loading: un,
151
- assets: pn,
152
- asset: mn,
153
- coin: _n,
154
- assetLabel: hn,
155
- assetValue: fn,
156
- assetArrow: yn,
157
- assetDivider: kn
158
- }, wn = x.points, ee = x.subscription, bn = ({ membership: e, text: t, onOpen: n }) => {
159
- const { canBuy: a, offer: o } = e;
160
- return a ? /* @__PURE__ */ _("span", { className: p.cta, children: [
161
- /* @__PURE__ */ s(k, { theme: "light", type: "tertiary", block: !0, className: p.ctaButton, onClick: () => n(ee), children: t }),
162
- o != null && o.price ? /* @__PURE__ */ _("span", { className: p.ctaTag, children: [
163
- Ft(o.price),
164
- "起"
165
- ] }) : null
166
- ] }) : /* @__PURE__ */ s("span", { className: p.ownerOnly, children: "请团队所有者在统一账号中心续费" });
167
- }, W = ({
168
- membership: e,
169
- extra: t,
170
- onOpen: n
171
- }) => {
172
- const { wallet: a } = e, o = a.isPending ? "…" : a.data ? N(a.data.availablePoints) : "暂不可用";
173
- return /* @__PURE__ */ _("div", { className: p.assets, children: [
174
- /* @__PURE__ */ _(k, { theme: "borderless", type: "tertiary", className: p.asset, "aria-label": `可用积分 ${o},查看积分与明细`, onClick: () => n(wn), children: [
175
- /* @__PURE__ */ s("span", { className: p.coin, "aria-hidden": "true" }),
176
- /* @__PURE__ */ s("span", { className: p.assetLabel, children: "积分" }),
177
- /* @__PURE__ */ s("span", { className: p.assetValue, children: o }),
178
- /* @__PURE__ */ s(V, { className: p.assetArrow, "aria-hidden": "true" })
179
- ] }),
180
- t ? /* @__PURE__ */ _(ye, { children: [
181
- /* @__PURE__ */ s("span", { className: p.assetDivider, "aria-hidden": "true" }),
182
- /* @__PURE__ */ _(k, { theme: "borderless", type: "tertiary", className: p.asset, "data-tone": t.tone, onClick: t.onClick ?? (() => n(ee)), children: [
183
- /* @__PURE__ */ s("span", { className: p.assetValue, children: t.label }),
184
- /* @__PURE__ */ s(V, { className: p.assetArrow, "aria-hidden": "true" })
185
- ] })
186
- ] }) : null
187
- ] });
188
- }, gn = ({ membership: e, onOpen: t }) => {
189
- const n = ve(), { state: a, offer: o, currentPlan: c, subscription: i } = e;
190
- if (a.kind === "loading")
191
- return /* @__PURE__ */ s("div", { className: p.loading, children: /* @__PURE__ */ s(ie, { loading: !0, active: !0, placeholder: /* @__PURE__ */ s(ie.Paragraph, { rows: 3 }) }) });
192
- if (a.kind === "error")
193
- return /* @__PURE__ */ _("div", { className: p.plain, children: [
194
- /* @__PURE__ */ _("div", { className: p.plainBody, children: [
195
- /* @__PURE__ */ s("span", { className: p.plainText, children: "套餐信息暂时读不到" }),
196
- /* @__PURE__ */ s(k, { theme: "borderless", type: "tertiary", size: "small", className: p.retry, onClick: () => void i.refetch(), children: "重试" })
197
- ] }),
198
- /* @__PURE__ */ s(W, { membership: e, onOpen: t })
199
- ] });
200
- if (a.kind === "member") {
201
- const { subscription: f, daysLeft: y } = a, C = y !== null && y <= Mt, T = (c == null ? void 0 : c.monthlyPoints) ?? 0;
202
- return /* @__PURE__ */ _("div", { className: `${p.member} semi-always-light`, "data-expiring": C ? "true" : "false", children: [
203
- /* @__PURE__ */ s("span", { className: p.memberArt, "aria-hidden": "true" }),
204
- /* @__PURE__ */ _("div", { className: p.memberBody, children: [
205
- /* @__PURE__ */ _("span", { className: p.memberEyebrow, children: [
206
- "当前会员",
207
- T > 0 ? ` · 每月 ${N(T)} 积分` : ""
208
- ] }),
209
- /* @__PURE__ */ s("span", { className: p.memberTitle, children: H(f) }),
210
- /* @__PURE__ */ s("span", { className: p.memberMeta, children: $t(f) }),
211
- e.canBuy ? /* @__PURE__ */ s(k, { theme: "light", type: "tertiary", size: "small", className: p.memberCta, onClick: () => t(ee), children: C ? "立即续费" : o ? "续费或升级" : "续费" }) : null
212
- ] }),
213
- /* @__PURE__ */ s(
214
- W,
215
- {
216
- membership: e,
217
- onOpen: t,
218
- extra: y === null ? void 0 : { label: y === 0 ? "今天到期" : `剩余 ${y} 天`, tone: C ? "warning" : void 0 }
219
- }
220
- )
221
- ] });
222
- }
223
- const m = a.kind === "team-expired", r = m ? "团队版已到期" : o ? `升级${o.plan.name},畅享更多` : "开通会员畅享", d = m ? "续费后团队成员继续共用套餐和积分" : Wt(o == null ? void 0 : o.plan, e.plans.data ?? [], n).join(" · "), u = m ? 0 : (c == null ? void 0 : c.monthlyPoints) ?? 0;
224
- return /* @__PURE__ */ _("div", { className: p.promo, "data-tone": m ? "team" : "free", children: [
225
- /* @__PURE__ */ s("span", { className: p.promoArt, "aria-hidden": "true" }),
226
- /* @__PURE__ */ _("div", { className: p.promoBody, children: [
227
- /* @__PURE__ */ s("span", { className: p.promoTitle, children: r }),
228
- /* @__PURE__ */ s("span", { className: p.promoText, children: d }),
229
- /* @__PURE__ */ s(bn, { membership: e, text: m ? "续费团队版" : "立即开通会员", onOpen: t })
230
- ] }),
231
- /* @__PURE__ */ s(W, { membership: e, onOpen: t, extra: u > 0 ? { label: `免费版每月赠 ${N(u)}` } : void 0 })
232
- ] });
233
- }, vn = "个人空间", F = (e) => e.type === "team", X = (e) => e.type === "personal" ? vn : e.name || e.slug, Nn = { owner: "所有者", admin: "管理员", member: "成员" }, da = (e) => e ? Nn[e] ?? "" : "", Sn = (e) => !!(e && (e.type === "personal" || e.role === "owner")), Cn = () => {
234
- const [e, t] = D(!1), n = Se(), { accountApi: a, config: o } = w(), c = async () => {
235
- if (e) return;
236
- t(!0), Ge();
237
- let m = o.routes.publicHome;
238
- try {
239
- const { endSessionUrl: r } = await a.logout();
240
- r && (m = r);
241
- } catch (r) {
242
- if (!Ne(r, 401)) {
243
- Ye(), ge.error("退出失败,请重试"), t(!1);
244
- return;
245
- }
246
- }
247
- return Qe(), await n.cancelQueries().catch(() => {
248
- }), Ce(), window.location.assign(m), new Promise(() => {
249
- });
250
- };
251
- return { confirmLogout: () => {
252
- e || $e.confirm({
253
- title: "退出登录",
254
- content: "将同时退出 24.city 统一账号并回到首页,再次进入工作台需要重新登录。",
255
- okText: "退出登录",
256
- cancelText: "取消",
257
- okButtonProps: { type: "danger" },
258
- onOk: c
259
- });
260
- }, logout: c, pending: e };
261
- }, j = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Tn = (e) => {
262
- if (!Ne(e, 403) || !j(e) || !j(e.response)) return !1;
263
- const t = e.response.data;
264
- return j(t) && t.reason === "team_subscription_required";
265
- }, I = {
266
- profile: (e) => ["product-profile", e],
267
- wallet: (e, t) => ["product-wallet", e, t],
268
- subscription: (e, t) => ["product-subscription", e, t],
269
- plans: ["product-plans"]
270
- }, An = () => {
271
- const { accountApi: e } = w(), { session: t, spaces: n } = L(), a = (t == null ? void 0 : t.activeSpaceId) ?? "", o = (t == null ? void 0 : t.globalUserId) ?? "", c = (t == null ? void 0 : t.purpose) === "user" && !!(a && o), i = n.find((u) => u.id === a), m = E({
272
- queryKey: I.profile(o),
273
- queryFn: () => e.getProfile(),
274
- enabled: !!o,
275
- staleTime: 1 / 0
276
- }), r = E({
277
- queryKey: I.wallet(a, o),
278
- queryFn: () => e.getWallet(),
279
- enabled: c
280
- }), d = E({
281
- queryKey: I.subscription(a, o),
282
- queryFn: () => e.getSubscription(),
283
- enabled: c
284
- });
285
- return { session: t, allowed: c, activeSpace: i, activeSpaceId: a, globalUserId: o, profile: m, wallet: r, subscription: d };
286
- }, En = 5 * 6e4, xn = (e) => {
287
- const { accountApi: t } = w();
288
- return E({
289
- queryKey: I.plans,
290
- queryFn: () => t.getPlans(),
291
- enabled: e,
292
- staleTime: En
293
- });
294
- }, Ae = () => {
295
- var y;
296
- const { config: e } = w(), t = An(), { activeSpace: n, subscription: a, allowed: o } = t, c = xn(o), i = n ? F(n) : !1, m = i ? "team" : "personal";
297
- let r;
298
- !o || a.isPending ? r = { kind: "loading" } : a.isError ? r = Tn(a.error) ? { kind: "team-expired" } : { kind: "error" } : !a.data || a.data.isDefault ? r = { kind: "free", subscription: a.data ?? null } : r = { kind: "member", subscription: a.data, daysLeft: Ot(a.data) };
299
- const d = r.kind === "free" || r.kind === "member" ? ((y = r.subscription) == null ? void 0 : y.tier) ?? null : null, u = r.kind === "free" || r.kind === "member" || r.kind === "team-expired" ? zt(c.data, m, d) : null, f = (r.kind === "free" || r.kind === "member") && r.subscription ? Kt(c.data, r.subscription) : void 0;
300
- return {
301
- ...t,
302
- plans: c,
303
- state: r,
304
- offer: u,
305
- currentPlan: f,
306
- team: i,
307
- /** 个人空间是自己的;团队空间只有所有者能买(STD-BILLING-001) */
308
- canBuy: Sn(n),
309
- /** 「订阅与套餐」的站内地址 */
310
- subscriptionPath: v(e.routes.app, "subscription")
311
- };
312
- }, In = () => {
313
- const e = Se(), t = Ve(), { session: n } = L(), { accountApi: a } = w(), [o, c] = D(!1), i = ke(0), m = n == null ? void 0 : n.activeSpaceId, r = we(
314
- async (d) => {
315
- if (!d || d === m || o) return;
316
- const u = ++i.current;
317
- c(!0);
318
- try {
319
- if (await e.cancelQueries(), e.clear(), (await a.switchSpace(d)).activeSpaceId !== d) throw new Error("空间切换响应与请求不一致");
320
- const y = await de(a);
321
- if (i.current !== u) return;
322
- t.setContext(y), Ce();
323
- } catch {
324
- if (i.current !== u) return;
325
- try {
326
- const f = await de(a);
327
- e.clear(), t.setContext(f), f.session.activeSpaceId !== d && ge.error("空间切换失败,请稍后重试");
328
- } catch {
329
- e.clear(), t.clear({ unavailable: !0 });
330
- }
331
- } finally {
332
- i.current === u && c(!1);
333
- }
334
- },
335
- [a, m, t, e, o]
336
- );
337
- return { switching: o, switchSpace: r };
338
- }, q = "我的账号", Ln = 80, Pn = 200, G = ({ space: e }) => /* @__PURE__ */ _(ye, { children: [
339
- /* @__PURE__ */ s("span", { className: l.spaceName, children: X(e) }),
340
- F(e) ? /* @__PURE__ */ s("span", { className: l.spaceType, children: "团队" }) : null
341
- ] }), pe = ({ nickName: e, member: t, size: n }) => /* @__PURE__ */ s("span", { className: l.avatarWrap, "data-member": t ? "true" : "false", "data-size": n > 40 ? "large" : "small", children: /* @__PURE__ */ s(Be, { size: "small", shape: "circle", className: l.avatar, style: { width: n, height: n }, children: e ? Array.from(e)[0] : /* @__PURE__ */ s(U, { "aria-hidden": "true" }) }) }), $n = ({ state: e }) => e.kind === "member" ? /* @__PURE__ */ _("span", { className: l.planChip, "data-tone": "member", children: [
342
- /* @__PURE__ */ s("span", { className: l.diamond, "aria-hidden": "true" }),
343
- H(e.subscription)
344
- ] }) : e.kind === "free" ? /* @__PURE__ */ s("span", { className: l.planChip, "data-tone": "free", children: e.subscription ? H(e.subscription) : "未开通" }) : e.kind === "team-expired" ? /* @__PURE__ */ s("span", { className: l.planChip, "data-tone": "warning", children: "团队版已到期" }) : null, ua = ({ personal: e, selectedKey: t, onOpen: n }) => {
345
- var re;
346
- const { config: a } = w(), o = ve(), c = Z(), i = e ?? Et(a.routes.app, At(o)), m = Ae(), { profile: r, state: d } = m, { session: u, spaces: f } = L(), { confirmLogout: y, pending: C } = Cn(), { switching: T, switchSpace: Ee } = In(), { darkAvailable: xe } = je(), [R, P] = D(!1), [z, $] = D(!1), A = ke(void 0), K = ((re = r.data) == null ? void 0 : re.nickName) ?? "", B = K || (r.isPending ? "" : q), te = (u == null ? void 0 : u.activeSpaceId) ?? "", b = f.find((h) => h.id === te), ne = f.length > 1, ae = d.kind === "member", { AccountAllowance: se } = o, S = () => {
347
- A.current !== void 0 && (window.clearTimeout(A.current), A.current = void 0);
348
- };
349
- be(() => S, []);
350
- const O = () => {
351
- S(), P(!1), $(!1);
352
- }, Ie = () => {
353
- S(), A.current = window.setTimeout(() => P(!0), Ln);
354
- }, oe = () => {
355
- S(), A.current = window.setTimeout(() => {
356
- P(!1), $(!1);
357
- }, Pn);
358
- }, ce = (h) => {
359
- if (O(), n) {
360
- n(h);
361
- return;
362
- }
363
- const g = i.items.find((Pe) => Pe.key === h);
364
- g && c(g.to);
365
- }, Le = /* @__PURE__ */ _("div", { className: l.card, role: "dialog", "aria-label": "账号", onMouseEnter: S, onMouseLeave: oe, children: [
366
- /* @__PURE__ */ _("div", { className: l.identity, children: [
367
- /* @__PURE__ */ s(pe, { nickName: K, member: ae, size: 52 }),
368
- /* @__PURE__ */ _("div", { className: l.who, children: [
369
- /* @__PURE__ */ _("div", { className: l.nameRow, children: [
370
- /* @__PURE__ */ s("span", { className: l.name, title: B || q, children: B || q }),
371
- /* @__PURE__ */ s($n, { state: d })
372
- ] }),
373
- b ? ne ? /* @__PURE__ */ _(
374
- k,
375
- {
376
- theme: "borderless",
377
- type: "tertiary",
378
- size: "small",
379
- className: l.spaceToggle,
380
- "aria-expanded": z,
381
- "aria-label": `当前空间:${X(b)},切换空间`,
382
- onClick: () => $((h) => !h),
383
- children: [
384
- F(b) ? /* @__PURE__ */ s(le, { "aria-hidden": "true" }) : /* @__PURE__ */ s(U, { "aria-hidden": "true" }),
385
- /* @__PURE__ */ s(G, { space: b }),
386
- /* @__PURE__ */ s("span", { className: l.spaceSwitchText, children: "切换" }),
387
- z ? /* @__PURE__ */ s(Fe, { "aria-hidden": "true" }) : /* @__PURE__ */ s(Re, { "aria-hidden": "true" })
388
- ]
389
- }
390
- ) : /* @__PURE__ */ _("span", { className: l.spaceStatic, "aria-label": `当前空间:${X(b)}`, children: [
391
- F(b) ? /* @__PURE__ */ s(le, { "aria-hidden": "true" }) : /* @__PURE__ */ s(U, { "aria-hidden": "true" }),
392
- /* @__PURE__ */ s(G, { space: b })
393
- ] }) : null
394
- ] })
395
- ] }),
396
- ne && z ? /* @__PURE__ */ s("div", { className: l.spaceList, role: "group", "aria-label": "切换空间", children: f.map((h) => {
397
- const g = h.id === te;
398
- return /* @__PURE__ */ _(
399
- k,
400
- {
401
- theme: "borderless",
402
- type: "tertiary",
403
- block: !0,
404
- className: l.spaceOption,
405
- "aria-current": g ? "true" : void 0,
406
- disabled: T && !g,
407
- onClick: () => {
408
- g || (O(), Ee(h.id));
409
- },
410
- children: [
411
- /* @__PURE__ */ s("span", { className: l.spaceCheck, children: g ? /* @__PURE__ */ s(ze, { "aria-hidden": "true" }) : null }),
412
- /* @__PURE__ */ s(G, { space: h })
413
- ]
414
- },
415
- h.id
416
- );
417
- }) }) : null,
418
- /* @__PURE__ */ s("div", { className: l.plan, children: /* @__PURE__ */ s(gn, { membership: m, onOpen: ce }) }),
419
- se && u ? /* @__PURE__ */ s("div", { className: l.allowance, children: /* @__PURE__ */ s(se, { activeSpaceId: u.activeSpaceId, globalUserId: u.globalUserId }) }) : null,
420
- /* @__PURE__ */ s("div", { className: l.links, role: "group", "aria-label": i.label, children: i.items.map((h) => /* @__PURE__ */ _(
421
- k,
422
- {
423
- theme: "borderless",
424
- type: "tertiary",
425
- block: !0,
426
- className: l.link,
427
- "aria-current": h.key === t ? "page" : void 0,
428
- onClick: () => ce(h.key),
429
- children: [
430
- h.icon ? /* @__PURE__ */ s("span", { className: l.linkIcon, "aria-hidden": "true", children: /* @__PURE__ */ s(h.icon, {}) }) : null,
431
- /* @__PURE__ */ s("span", { className: l.linkLabel, children: h.label }),
432
- /* @__PURE__ */ s(V, { className: l.linkArrow, "aria-hidden": "true" })
433
- ]
434
- },
435
- h.key
436
- )) }),
437
- xe ? /* @__PURE__ */ _("div", { className: l.appearance, children: [
438
- /* @__PURE__ */ s("span", { className: l.linkIcon, "aria-hidden": "true", children: /* @__PURE__ */ s(Ke, {}) }),
439
- /* @__PURE__ */ s("span", { className: l.linkLabel, children: "外观" }),
440
- /* @__PURE__ */ s(We, {})
441
- ] }) : null,
442
- /* @__PURE__ */ s("div", { className: l.divider, "aria-hidden": "true" }),
443
- /* @__PURE__ */ s(
444
- k,
445
- {
446
- theme: "borderless",
447
- type: "tertiary",
448
- block: !0,
449
- className: l.logout,
450
- disabled: C,
451
- onClick: () => {
452
- O(), y();
453
- },
454
- children: "退出登录"
455
- }
456
- )
457
- ] });
458
- return /* @__PURE__ */ s(
459
- Oe,
460
- {
461
- trigger: "custom",
462
- visible: R,
463
- position: "bottomRight",
464
- showArrow: !1,
465
- spacing: 8,
466
- className: l.popover,
467
- content: Le,
468
- onClickOutSide: O,
469
- children: /* @__PURE__ */ s(
470
- k,
471
- {
472
- theme: "borderless",
473
- type: "tertiary",
474
- className: l.trigger,
475
- "aria-label": B ? `${B},账号菜单` : "账号菜单",
476
- "aria-haspopup": "dialog",
477
- "aria-expanded": R,
478
- loading: T,
479
- onMouseEnter: Ie,
480
- onMouseLeave: oe,
481
- onClick: () => {
482
- S(), P((h) => !h), R && $(!1);
483
- },
484
- children: /* @__PURE__ */ s(pe, { nickName: K, member: ae, size: 34 })
485
- }
486
- )
487
- }
488
- );
489
- }, me = 2e3, _e = 20, Bn = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `evt-${Date.now()}-${Math.random().toString(36).slice(2, 12)}`, On = (e) => {
490
- var t;
491
- return typeof e == "object" && e !== null && "response" in e ? (t = e.response) == null ? void 0 : t.status : void 0;
492
- }, Mn = (e, t = !0) => {
493
- let n = [], a, o = !1, c = t;
494
- const i = async () => {
495
- if (a && clearTimeout(a), a = void 0, o || c !== !0 || n.length === 0) return;
496
- const d = n.splice(0, _e);
497
- try {
498
- await e(d);
499
- } catch (u) {
500
- On(u) === 404 && (o = !0, n = []);
501
- }
502
- n.length > 0 && i();
503
- }, m = (d, u = {}) => {
504
- if (o || c === !1) return;
505
- const f = { eventId: Bn(), name: d, occurredAt: (/* @__PURE__ */ new Date()).toISOString() };
506
- if (u.target && (f.target = u.target), u.props && Object.keys(u.props).length > 0 && (f.props = u.props), n.push(f), n.length >= _e) {
507
- i();
508
- return;
509
- }
510
- a || (a = setTimeout(() => void i(), me));
511
- }, r = (d) => {
512
- d !== c && (c = d, d === !1 && (n = []), d === !0 && n.length > 0 && !a && (a = setTimeout(() => void i(), me)));
513
- };
514
- return typeof window < "u" && window.addEventListener("pagehide", () => void i()), { track: m, flush: i, setSignedIn: r };
515
- }, he = /* @__PURE__ */ new WeakMap(), fe = (e) => {
516
- const t = e.reportBehaviorEvents;
517
- if (!t) return;
518
- let n = he.get(e);
519
- return n || (n = Mn((a) => t.call(e, a), void 0), he.set(e, n)), n;
520
- }, Dn = () => {
521
- const { accountApi: e } = w(), { session: t, bootstrapped: n } = L(), a = n ? !!t : void 0;
522
- return be(() => {
523
- var o;
524
- (o = fe(e)) == null || o.setSignedIn(a);
525
- }, [e, a]), we((o, c) => {
526
- var i;
527
- return (i = fe(e)) == null ? void 0 : i.track(o, c);
528
- }, [e]);
529
- }, Un = /^(?:\d{2,}|[0-9a-f]{12,}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{16,})$/i, Fn = /^[A-Za-z0-9_.-]*$/, pa = (e) => (e.split("/").map((a) => Un.test(a) || !Fn.test(a) ? ":id" : a).join("/").replace(/\/+$/, "") || "/").slice(0, 128), Rn = "_upgrade_1dxl7_2", zn = "_crown_1dxl7_25", Kn = "_text_1dxl7_37", Y = {
530
- upgrade: Rn,
531
- crown: zn,
532
- text: Kn
533
- }, ma = () => {
534
- const { config: e } = w(), t = Z(), { state: n, canBuy: a } = Ae(), o = Dn();
535
- if (!a || n.kind !== "free" && n.kind !== "team-expired") return null;
536
- const c = n.kind === "team-expired" ? "续费团队版" : "开通会员";
537
- return /* @__PURE__ */ _(
538
- k,
539
- {
540
- theme: "light",
541
- type: "tertiary",
542
- className: Y.upgrade,
543
- onClick: () => {
544
- o("upgrade_entry.clicked", { target: n.kind }), t(v(e.routes.app, "subscription"));
545
- },
546
- children: [
547
- /* @__PURE__ */ s("span", { className: Y.crown, "aria-hidden": "true" }),
548
- /* @__PURE__ */ s("span", { className: Y.text, children: c })
549
- ]
550
- }
551
- );
552
- }, Wn = "_wallet_e6uma_2", jn = "_coin_e6uma_25", qn = "_value_e6uma_32", Q = {
553
- wallet: Wn,
554
- coin: jn,
555
- value: qn
556
- }, _a = () => {
557
- const { accountApi: e, config: t } = w(), { session: n } = L(), a = Z(), o = (n == null ? void 0 : n.activeSpaceId) ?? "", c = (n == null ? void 0 : n.globalUserId) ?? "", i = E({
558
- queryKey: I.wallet(o, c),
559
- queryFn: () => e.getWallet(),
560
- enabled: !!n,
561
- refetchOnWindowFocus: !0
562
- });
563
- if (!n) return null;
564
- const m = i.isPending ? "读取中" : i.data ? N(i.data.availablePoints) : "积分暂不可用";
565
- return /* @__PURE__ */ s(Me, { content: "当前空间可用积分,由统一账号中心记账", children: /* @__PURE__ */ _(
566
- k,
567
- {
568
- theme: "light",
569
- type: "tertiary",
570
- className: Q.wallet,
571
- "aria-label": i.data ? `积分 ${m}` : m,
572
- onClick: () => a(v(t.routes.app, "points")),
573
- children: [
574
- /* @__PURE__ */ s("span", { className: Q.coin, "aria-hidden": "true" }),
575
- /* @__PURE__ */ s("span", { className: Q.value, children: m })
576
- ]
577
- }
578
- ) });
579
- };
580
- export {
581
- St as A,
582
- $t as B,
583
- H as C,
584
- At as D,
585
- Mt as E,
586
- q as F,
587
- ca as G,
588
- sa as H,
589
- oa as I,
590
- X as J,
591
- da as K,
592
- Rt as L,
593
- zt as M,
594
- An as N,
595
- Cn as O,
596
- x as P,
597
- Ae as Q,
598
- xn as R,
599
- In as S,
600
- Dn as T,
601
- xt as U,
602
- _a as W,
603
- pe as a,
604
- ua as b,
605
- vn as c,
606
- gn as d,
607
- ma as e,
608
- I as f,
609
- v as g,
610
- pa as h,
611
- Et as i,
612
- Sn as j,
613
- Kt as k,
614
- Mn as l,
615
- la as m,
616
- Pt as n,
617
- Ut as o,
618
- Ft as p,
619
- aa as q,
620
- Ct as r,
621
- F as s,
622
- Tn as t,
623
- J as u,
624
- Wt as v,
625
- M as w,
626
- Ot as x,
627
- ia as y,
628
- ra as z
629
- };