@capyclaw/offline-ddr0 0.0.0-stage → 1.9.1

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 (300) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +441 -2
  3. package/client/client.js +603 -0
  4. package/cordis.patch.yml +13 -0
  5. package/docs/STORAGE-MIGRATION.md +136 -0
  6. package/lib/atomic.mjs +40 -0
  7. package/lib/http-cache.mjs +42 -0
  8. package/lib/inbox.mjs +64 -0
  9. package/lib/media.mjs +242 -0
  10. package/lib/migrate-json.mjs +101 -0
  11. package/lib/mirror-index.mjs +105 -0
  12. package/lib/mirror.mjs +123 -0
  13. package/lib/proxy.mjs +188 -0
  14. package/lib/remote.mjs +158 -0
  15. package/lib/render.mjs +93 -0
  16. package/lib/repository.mjs +71 -0
  17. package/lib/store.mjs +610 -0
  18. package/lib/surface.mjs +74 -0
  19. package/lib/sync-ui.mjs +108 -0
  20. package/lib/sync.mjs +433 -0
  21. package/lib/wire.mjs +211 -0
  22. package/lib/workstore-repository.mjs +316 -0
  23. package/lib/workstore.mjs +348 -0
  24. package/mirror/files/00001.html +2045 -0
  25. package/mirror/files/00002.json +1 -0
  26. package/mirror/files/00003.json +1 -0
  27. package/mirror/files/00004.json +1 -0
  28. package/mirror/files/00005.json +1 -0
  29. package/mirror/files/00006.json +1 -0
  30. package/mirror/files/00007.json +1 -0
  31. package/mirror/files/00008.json +1 -0
  32. package/mirror/files/00009.json +1 -0
  33. package/mirror/files/00010.json +1 -0
  34. package/mirror/files/00011.json +1 -0
  35. package/mirror/files/00012.json +1 -0
  36. package/mirror/files/00013.json +1 -0
  37. package/mirror/files/00014.json +1 -0
  38. package/mirror/files/00015.json +1 -0
  39. package/mirror/files/00016.json +1 -0
  40. package/mirror/files/00017.json +1 -0
  41. package/mirror/files/00018.json +1 -0
  42. package/mirror/files/00019.json +1 -0
  43. package/mirror/files/00020.json +1 -0
  44. package/mirror/files/00021.json +1 -0
  45. package/mirror/files/00022.json +1 -0
  46. package/mirror/files/00023.js +205 -0
  47. package/mirror/files/00024.json +1 -0
  48. package/mirror/files/00025.json +1 -0
  49. package/mirror/files/00026.json +1 -0
  50. package/mirror/files/00027.js +51 -0
  51. package/mirror/files/00028.json +1 -0
  52. package/mirror/files/00029.json +1 -0
  53. package/mirror/files/00030.json +1 -0
  54. package/mirror/files/00031.json +1 -0
  55. package/mirror/files/00032.json +1 -0
  56. package/mirror/files/00033.json +1 -0
  57. package/mirror/files/00034.json +1 -0
  58. package/mirror/files/00035.json +1 -0
  59. package/mirror/files/00036.json +1 -0
  60. package/mirror/files/00037.json +1 -0
  61. package/mirror/files/00038.json +1 -0
  62. package/mirror/files/00039.json +1 -0
  63. package/mirror/files/00040.js +2311 -0
  64. package/mirror/files/00041.json +1 -0
  65. package/mirror/files/00042.json +1 -0
  66. package/mirror/files/00043.json +1 -0
  67. package/mirror/files/00044.json +1 -0
  68. package/mirror/files/00045.js +575 -0
  69. package/mirror/files/00046.json +1 -0
  70. package/mirror/files/00047.js +575 -0
  71. package/mirror/files/00048.js +575 -0
  72. package/mirror/files/00049.json +1 -0
  73. package/mirror/files/00050.json +1 -0
  74. package/mirror/files/00051.json +1 -0
  75. package/mirror/files/00052.json +1 -0
  76. package/mirror/files/00053.js +575 -0
  77. package/mirror/files/00054.json +1 -0
  78. package/mirror/files/00055.json +1 -0
  79. package/mirror/files/00056.js +575 -0
  80. package/mirror/files/00057.json +1 -0
  81. package/mirror/files/00058.json +1 -0
  82. package/mirror/files/00059.js +360 -0
  83. package/mirror/files/00060.json +1 -0
  84. package/mirror/files/00061.json +1 -0
  85. package/mirror/files/00062.json +1 -0
  86. package/mirror/files/00063.json +1 -0
  87. package/mirror/files/00064.json +1 -0
  88. package/mirror/files/00065.js +144 -0
  89. package/mirror/files/00066.js +7 -0
  90. package/mirror/files/00067.json +1 -0
  91. package/mirror/files/00068.json +1 -0
  92. package/mirror/files/00069.json +1 -0
  93. package/mirror/files/00070.json +1 -0
  94. package/mirror/files/00071.json +1 -0
  95. package/mirror/files/00072.json +1 -0
  96. package/mirror/files/00073.js +1 -0
  97. package/mirror/files/00074.json +1 -0
  98. package/mirror/files/00075.json +1 -0
  99. package/mirror/files/00076.json +1 -0
  100. package/mirror/files/00077.js +45 -0
  101. package/mirror/files/00078.js +1348 -0
  102. package/mirror/files/00079.json +1 -0
  103. package/mirror/files/00080.json +1 -0
  104. package/mirror/files/00081.js +1 -0
  105. package/mirror/files/00082.json +1 -0
  106. package/mirror/files/00083.json +1 -0
  107. package/mirror/files/00084.js +7 -0
  108. package/mirror/files/00085.json +1 -0
  109. package/mirror/files/00086.json +1 -0
  110. package/mirror/files/00087.js +7 -0
  111. package/mirror/files/00088.json +1 -0
  112. package/mirror/files/00089.json +1 -0
  113. package/mirror/files/00090.js +7 -0
  114. package/mirror/files/00091.json +1 -0
  115. package/mirror/files/00092.json +1 -0
  116. package/mirror/files/00093.js +102 -0
  117. package/mirror/files/00094.json +1 -0
  118. package/mirror/files/00095.json +1 -0
  119. package/mirror/files/00096.json +1 -0
  120. package/mirror/files/00097.json +1 -0
  121. package/mirror/files/00098.json +1 -0
  122. package/mirror/files/00099.json +1 -0
  123. package/mirror/files/00100.json +1 -0
  124. package/mirror/files/00101.js +102 -0
  125. package/mirror/files/00102.json +1 -0
  126. package/mirror/files/00103.json +1 -0
  127. package/mirror/files/00104.json +1 -0
  128. package/mirror/files/00105.json +1 -0
  129. package/mirror/files/00106.json +1 -0
  130. package/mirror/files/00107.js +110 -0
  131. package/mirror/files/00108.json +1 -0
  132. package/mirror/files/00109.json +1 -0
  133. package/mirror/files/00110.json +1 -0
  134. package/mirror/files/00111.json +1 -0
  135. package/mirror/files/00112.json +1 -0
  136. package/mirror/files/00113.json +1 -0
  137. package/mirror/files/00114.json +1 -0
  138. package/mirror/files/00115.json +1 -0
  139. package/mirror/files/00116.json +1 -0
  140. package/mirror/files/00117.json +1 -0
  141. package/mirror/files/00118.json +1 -0
  142. package/mirror/files/00119.json +1 -0
  143. package/mirror/files/00120.json +1 -0
  144. package/mirror/files/00121.json +1 -0
  145. package/mirror/files/00122.json +1 -0
  146. package/mirror/files/00123.json +1 -0
  147. package/mirror/files/00124.json +1 -0
  148. package/mirror/files/00125.json +1 -0
  149. package/mirror/files/00126.json +1 -0
  150. package/mirror/files/00127.json +1 -0
  151. package/mirror/files/00128.json +1 -0
  152. package/mirror/files/00129.json +1 -0
  153. package/mirror/files/00130.json +1 -0
  154. package/mirror/files/00131.json +1 -0
  155. package/mirror/files/00132.js +110 -0
  156. package/mirror/files/00133.json +1 -0
  157. package/mirror/files/00134.json +1 -0
  158. package/mirror/files/00135.json +1 -0
  159. package/mirror/files/00136.json +1 -0
  160. package/mirror/files/00137.js +26 -0
  161. package/mirror/files/00138.json +1 -0
  162. package/mirror/files/00139.json +1 -0
  163. package/mirror/files/00140.json +1 -0
  164. package/mirror/files/00141.json +1 -0
  165. package/mirror/files/00142.json +1 -0
  166. package/mirror/files/00143.json +1 -0
  167. package/mirror/files/00144.js +26 -0
  168. package/mirror/files/00145.json +1 -0
  169. package/mirror/files/00146.json +1 -0
  170. package/mirror/files/00147.js +29 -0
  171. package/mirror/files/00148.json +1 -0
  172. package/mirror/files/00149.json +1 -0
  173. package/mirror/files/00150.js +23 -0
  174. package/mirror/files/00151.json +1 -0
  175. package/mirror/files/00152.json +1 -0
  176. package/mirror/files/00153.js +719 -0
  177. package/mirror/files/00154.js +9575 -0
  178. package/mirror/files/00155.js +108 -0
  179. package/mirror/files/00156.js +379 -0
  180. package/mirror/files/00157.js +48 -0
  181. package/mirror/files/00158.json +16 -0
  182. package/mirror/manifest.json +1582 -0
  183. package/node_modules/@capyclaw/asset-service/README.md +48 -0
  184. package/node_modules/@capyclaw/asset-service/cordis.patch.yml +4 -0
  185. package/node_modules/@capyclaw/asset-service/dsh-suite.json +29 -0
  186. package/node_modules/@capyclaw/asset-service/lib/host.mjs +14 -0
  187. package/node_modules/@capyclaw/asset-service/package.json +59 -0
  188. package/node_modules/@capyclaw/asset-service/src/index.mjs +310 -0
  189. package/node_modules/@capyclaw/foundation/README.md +51 -0
  190. package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
  191. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +88 -0
  192. package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
  193. package/node_modules/@capyclaw/foundation/abi/index.mjs +50 -0
  194. package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
  195. package/node_modules/@capyclaw/foundation/abi/loader.mjs +352 -0
  196. package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
  197. package/node_modules/@capyclaw/foundation/abi/spec.mjs +258 -0
  198. package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
  199. package/node_modules/@capyclaw/foundation/abi/version.mjs +140 -0
  200. package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
  201. package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
  202. package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
  203. package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
  204. package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
  205. package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
  206. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +72 -0
  207. package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
  208. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
  209. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -0
  210. package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
  211. package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
  212. package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
  213. package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
  214. package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
  215. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +38 -0
  216. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +88 -0
  217. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +54 -0
  218. package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +187 -0
  219. package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
  220. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +195 -0
  221. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -0
  222. package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
  223. package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
  224. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +198 -0
  225. package/node_modules/@capyclaw/foundation/package.json +53 -0
  226. package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
  227. package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
  228. package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
  229. package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
  230. package/node_modules/@capyclaw/plugin-kit/package.json +71 -0
  231. package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
  232. package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
  233. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +132 -0
  234. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
  235. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +60 -0
  236. package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
  237. package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
  238. package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
  239. package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
  240. package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
  241. package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
  242. package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
  243. package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
  244. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
  245. package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
  246. package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
  247. package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
  248. package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
  249. package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
  250. package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
  251. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
  252. package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
  253. package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
  254. package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
  255. package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
  256. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +664 -0
  257. package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
  258. package/node_modules/@capyclaw/service-host/README.md +86 -0
  259. package/node_modules/@capyclaw/service-host/cordis.patch.yml +4 -0
  260. package/node_modules/@capyclaw/service-host/dsh-suite.json +29 -0
  261. package/node_modules/@capyclaw/service-host/lib/host.mjs +22 -0
  262. package/node_modules/@capyclaw/service-host/package.json +60 -0
  263. package/node_modules/@capyclaw/service-host/src/index.mjs +570 -0
  264. package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
  265. package/node_modules/@capyclaw/suite-kit/README.md +289 -0
  266. package/node_modules/@capyclaw/suite-kit/bin/dsh-domain.mjs +98 -0
  267. package/node_modules/@capyclaw/suite-kit/bin/dsh-suite.mjs +174 -0
  268. package/node_modules/@capyclaw/suite-kit/client/embed.js +35 -0
  269. package/node_modules/@capyclaw/suite-kit/domain.schema.json +129 -0
  270. package/node_modules/@capyclaw/suite-kit/package.json +58 -0
  271. package/node_modules/@capyclaw/suite-kit/src/activation-registry.mjs +184 -0
  272. package/node_modules/@capyclaw/suite-kit/src/artifacts.mjs +131 -0
  273. package/node_modules/@capyclaw/suite-kit/src/capability.mjs +181 -0
  274. package/node_modules/@capyclaw/suite-kit/src/compose.mjs +201 -0
  275. package/node_modules/@capyclaw/suite-kit/src/domain.mjs +138 -0
  276. package/node_modules/@capyclaw/suite-kit/src/embed.mjs +81 -0
  277. package/node_modules/@capyclaw/suite-kit/src/host.mjs +230 -0
  278. package/node_modules/@capyclaw/suite-kit/src/index.mjs +24 -0
  279. package/node_modules/@capyclaw/suite-kit/src/manifest.mjs +263 -0
  280. package/node_modules/@capyclaw/suite-kit/src/orchestration.mjs +100 -0
  281. package/node_modules/@capyclaw/suite-kit/src/profile.mjs +584 -0
  282. package/node_modules/@capyclaw/suite-kit/src/surface.mjs +28 -0
  283. package/node_modules/@capyclaw/suite-kit/suite.schema.json +128 -0
  284. package/node_modules/@capyclaw/work-store/README.md +83 -0
  285. package/node_modules/@capyclaw/work-store/STANDARD.md +263 -0
  286. package/node_modules/@capyclaw/work-store/cordis.patch.yml +3 -0
  287. package/node_modules/@capyclaw/work-store/dsh-suite.json +33 -0
  288. package/node_modules/@capyclaw/work-store/icon.svg +7 -0
  289. package/node_modules/@capyclaw/work-store/lib/host.mjs +21 -0
  290. package/node_modules/@capyclaw/work-store/package.json +68 -0
  291. package/node_modules/@capyclaw/work-store/src/backend.mjs +90 -0
  292. package/node_modules/@capyclaw/work-store/src/db.mjs +199 -0
  293. package/node_modules/@capyclaw/work-store/src/envelope.mjs +132 -0
  294. package/node_modules/@capyclaw/work-store/src/index.mjs +571 -0
  295. package/node_modules/@capyclaw/work-store/src/interop.mjs +70 -0
  296. package/node_modules/@capyclaw/work-store/src/refs.mjs +99 -0
  297. package/node_modules/@capyclaw/work-store/src/routes.mjs +135 -0
  298. package/package.json +82 -4
  299. package/plugin.mjs +644 -0
  300. package/static/index.html +2068 -0
@@ -0,0 +1,2068 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN" data-theme="light">
3
+ <head>
4
+ <!-- offline-8223 injection(打包器 D 相管理)-->
5
+ <script>
6
+ /* 离线镜像子路径适配(打包器生成;子路径 = /offline-ddr0):
7
+ 1. __DDR0_API_OVERRIDE 命中接口域探测第一层 → 全部 apiUrl 带前缀;
8
+ 2. history.pushState/replaceState 补前缀 → SPA 路由不逃逸子路径。
9
+ /api/ 与本子路径自身不重复加前缀。 */
10
+ (function () {
11
+ var SUB = '/offline-ddr0';
12
+ try { window.__DDR0_API_OVERRIDE = SUB; } catch (e) { }
13
+ function sub(u) {
14
+ if (typeof u !== 'string' || u.charAt(0) !== '/') return u;
15
+ if (u === SUB || u.indexOf(SUB + '/') === 0) return u;
16
+ if (u.indexOf('/api/') === 0) return u;
17
+ return SUB + u;
18
+ }
19
+ try {
20
+ var ps = history.pushState.bind(history);
21
+ history.pushState = function (s, t, u) { return ps(s, t, sub(u)); };
22
+ var rs = history.replaceState.bind(history);
23
+ history.replaceState = function (s, t, u) { return rs(s, t, sub(u)); };
24
+ } catch (e) { }
25
+ })();
26
+ </script>
27
+ <meta charset="UTF-8">
28
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-content">
29
+ <meta name="theme-color" content="#E0E5EC">
30
+ <title>Site</title>
31
+ <script>
32
+ /* 站点实例身份(2026-10-27 命名治理):前端零品牌字面量。真源 =
33
+ 后端 app/settings.py::SiteConfig(.env 的 SITE_* 三行),经
34
+ /config.json site 块下发;本脚本先以主机名首段做同步占位
35
+ (ddr0.com → ddr0,同步供 <title> 与首帧使用),config 落定后
36
+ 由后置脚本校正为实例数据。存储键派生消费面 = theme.ts(主题
37
+ localStorage)/ chat-history-cache.ts(IndexedDB)/ community-view.ts
38
+ (sessionStorage)。 */
39
+ var __hostSlug = (location.hostname.replace(/^www\./, '').split('.')[0] || 'site');
40
+ window.__SITE__ = { slug: __hostSlug, name: '', domain: '' };
41
+ document.title = __hostSlug;
42
+ /* 启动里程碑打点:各阶段调 __fwMark(k),随 interact boot-probe 的
43
+ marks 字段上报(data/boot-probes.jsonl)——「拿到 HTML 后慢在哪
44
+ 一段」的直读面。必须在最先执行的脚本里定义。 */
45
+ window.__fwBootMarks = [];
46
+ window.__fwMark = function (k) {
47
+ try {
48
+ window.__fwBootMarks.push({ k: String(k).slice(0, 24), t: Math.round(performance.now()) });
49
+ } catch (e) { /* 打点失败不碍业务 */ }
50
+ };
51
+ window.__fwMark('html-head');
52
+ </script>
53
+ <!-- 首帧主题预置(2026-10-20 引入;2026-11-13 主题本地化改版):主题 =
54
+ 设备/浏览器本地偏好,localStorage <SITE_SLUG>_theme(键名由实例
55
+ 数据派生,2026-10-27 命名治理);这里在 CSS/首绘前同步把
56
+ <html data-theme> 定到本机上次选择的值,避免「先白后黑」。
57
+ localStorage 是同步 API,首绘前可读;本脚本先于 /config.json
58
+ 落定执行,故按「*_theme 后缀」匹配而不依赖 slug 已知。旧版服务端
59
+ 主题时代(m283 前)落下的 <slug>_theme cookie 在本机做一次性回退:
60
+ 读到即迁移写进 localStorage 并清掉 cookie——老设备深色偏好无缝保留。
61
+ 运行期唯一写点仍是 runtime/shared/theme.ts;本脚本只做首帧预置。 -->
62
+ <script>
63
+ (function () {
64
+ var m = null, migrated = false;
65
+ try {
66
+ /* 精确键优先(本机 slug 已知);config 落定前 slug 可能被
67
+ 校正,故再按 *_theme 后缀全量扫描兜底 */
68
+ var exact = window.__SITE__.slug + '_theme';
69
+ var v = localStorage.getItem(exact);
70
+ if (v === 'light' || v === 'dark') { m = v; }
71
+ if (!m) {
72
+ for (var i = 0; i < localStorage.length; i++) {
73
+ var k = localStorage.key(i);
74
+ if (k && /[a-z0-9_-]+_theme$/i.test(k)) {
75
+ var v2 = localStorage.getItem(k);
76
+ if (v2 === 'light' || v2 === 'dark') { m = v2; }
77
+ break;
78
+ }
79
+ }
80
+ }
81
+ } catch (e) { /* localStorage 被禁:退化为默认浅色 */ }
82
+ if (!m) {
83
+ /* 旧服务端主题时代的一次性回退迁移:cookie 里还有 <slug>_theme
84
+ 就收编进 localStorage 并清掉(服务端已不再读写下发) */
85
+ try {
86
+ var cm = document.cookie.match(/(?:^|;\s*)([a-z0-9_-]+_theme)=(light|dark)(?:;|$)/i);
87
+ if (cm) {
88
+ m = cm[2];
89
+ migrated = cm[1];
90
+ localStorage.setItem(window.__SITE__.slug + '_theme', m);
91
+ }
92
+ } catch (e) { /* ignore */ }
93
+ }
94
+ var dark = m === 'dark';
95
+ var root = document.documentElement;
96
+ root.setAttribute('data-theme', dark ? 'dark' : 'light');
97
+ root.style.colorScheme = dark ? 'dark' : 'light';
98
+ /* 在 118KB 内联 CSS 解析完之前先给画布上底色:浏览器默认白底会
99
+ 在慢网/大 CSS 下露出一下,这是「闪白」的剩余来源。 */
100
+ root.style.backgroundColor = dark ? '#1A1A1A' : '#E0E5EC';
101
+ if (dark) {
102
+ var meta = document.querySelector('meta[name="theme-color"]');
103
+ if (meta) meta.setAttribute('content', '#1A1A1A');
104
+ }
105
+ if (migrated) {
106
+ /* 旧 cookie 已收编进 localStorage:按捕获到的真实 cookie 名
107
+ 清掉(Max-Age=0;服务端 slug 与主机名占位可能不同段),
108
+ 防止长期残留(值从此以 localStorage 为唯一真源) */
109
+ try {
110
+ var secure = location.protocol === 'https:' ? '; Secure' : '';
111
+ document.cookie = migrated + '=; Path=/; Max-Age=0; SameSite=Lax' + secure;
112
+ } catch (e) { /* ignore */ }
113
+ }
114
+ window.__fwMark && window.__fwMark('theme-boot');
115
+ })();
116
+ </script>
117
+ <!-- 引导幕布首帧主题响应:让 loading screen 在大 CSS 加载前就跟随 data-theme,
118
+ 消除「闪白」(#fwBootGate 的 var(--neu-bg) fallback 是浅色)。 -->
119
+ <style>
120
+ [data-theme="dark"] #fwBootGate { background: #1A1A1A; }
121
+ /* 引导幕布整页骨架(2026-11-07):Shell 直抄——侧栏 + 主区横幅/卡格,
122
+ 几何真源 = app-shell.css / feature-hero.css / my.css。自包含:
123
+ 先于主 CSS 绘制,var() 全带主题内 fallback,token 到位后接管;
124
+ 选择器锚死 #fwBootGate 子树。为「最轻首屏」本块压缩排版(注释单行)。 */
125
+ #fwBootGate .fw-boot-shell{width:100%;height:100%;display:flex;align-items:stretch;flex-direction:column}
126
+ @media (min-width:960px){#fwBootGate .fw-boot-shell{flex-direction:row}}
127
+ /* 窄屏顶栏(同 .sb-topbar);宽屏侧栏常驻(同 .app-sidebar 224px) */
128
+ #fwBootGate .fw-sk-topbar{display:flex;flex:0 0 auto;align-items:center;justify-content:space-between;gap:10px;height:48px;padding:0 10px 0 14px;background:var(--neu-bg,#E0E5EC);border-bottom:var(--neu-line,1px solid rgba(198,207,220,.45))}
129
+ #fwBootGate .fw-sk-menu{position:relative;display:block;width:18px;height:2px;border-radius:1px;background:var(--stripe,rgba(163,177,198,.5))}
130
+ #fwBootGate .fw-sk-menu::before,#fwBootGate .fw-sk-menu::after{content:'';position:absolute;left:0;display:block;width:18px;height:2px;border-radius:1px;background:var(--stripe,rgba(163,177,198,.5))}
131
+ #fwBootGate .fw-sk-menu::before{top:-6px}
132
+ #fwBootGate .fw-sk-menu::after{top:6px}
133
+ #fwBootGate .fw-sk-sb{display:none;flex:0 0 auto;flex-direction:column;width:224px;box-sizing:border-box;padding:14px 12px 10px;background:var(--neu-bg,#E0E5EC);border-right:var(--neu-line,1px solid rgba(198,207,220,.45));overflow:hidden}
134
+ @media (min-width:960px){#fwBootGate .fw-sk-sb{display:flex}#fwBootGate .fw-sk-topbar{display:none}}
135
+ #fwBootGate .fw-sk-sb-head{display:flex;align-items:center;gap:8px;padding:6px 8px}
136
+ #fwBootGate .fw-sk-avatar{flex:0 0 auto;width:38px;height:38px;border-radius:12px;background:var(--neu-bg,#E0E5EC);box-shadow:var(--neu-raise-xs,3px 3px 7px rgba(163,177,198,.7),-3px -3px 7px rgba(255,255,255,.85))}
137
+ #fwBootGate .fw-sk-sb-id{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:5px}
138
+ #fwBootGate .fw-sk-pill{flex:0 0 auto;margin-left:auto;display:inline-flex;padding:7px 10px;border-radius:999px;background:var(--neu-bg,#E0E5EC);box-shadow:var(--neu-raise-xs,3px 3px 7px rgba(163,177,198,.7),-3px -3px 7px rgba(255,255,255,.85))}
139
+ /* 搜索/选中 = 凹陷(inset 底 + 压凹阴影,同输入槽语言) */
140
+ #fwBootGate .fw-sk-search{display:flex;align-items:center;height:40px;margin-top:10px;padding:0 14px;border-radius:16px;background:var(--neu-inset,#D1D9E6);box-shadow:var(--neu-press-xs,inset 2px 2px 4px rgba(163,177,198,.7),inset -2px -2px 4px rgba(255,255,255,.85))}
141
+ /* 侧栏行(同 .sb-item 40px/圆角12/图标22);底部行 38px + 分隔线 */
142
+ #fwBootGate .fw-sk-sb-item{display:flex;align-items:center;gap:10px;min-height:40px;padding:8px 10px;border-radius:12px}
143
+ #fwBootGate .fw-sk-sb-item.is-active{background:var(--neu-inset,#D1D9E6);box-shadow:var(--neu-press-xs,inset 2px 2px 4px rgba(163,177,198,.7),inset -2px -2px 4px rgba(255,255,255,.85))}
144
+ #fwBootGate .fw-sk-ico{flex:0 0 auto;width:22px;height:22px;border-radius:7px;background:var(--stripe,rgba(163,177,198,.24))}
145
+ #fwBootGate .fw-sk-sec{margin:14px 10px 4px}
146
+ #fwBootGate .fw-sk-sb-bottom{flex:0 0 auto;margin-top:auto;padding-top:8px;border-top:var(--neu-line,1px solid rgba(198,207,220,.45))}
147
+ #fwBootGate .fw-sk-sb-bottom .fw-sk-sb-item{min-height:38px}
148
+ /* 主区(同 .app-view-* 留白 12px 10px) */
149
+ #fwBootGate .fw-sk-main{flex:1 1 auto;min-width:0;box-sizing:border-box;padding:12px 10px;display:flex;flex-direction:column;overflow:hidden}
150
+ /* 精选横幅(同 .feat-hero 198px/圆角24/图标34/CTA 760px 内),仅 /feature/* 出现 */
151
+ #fwBootGate .fw-sk-hero{position:relative;flex:0 0 auto;margin:0 0 12px;min-height:198px;box-sizing:border-box;padding:20px 22px 30px;border-radius:24px;background:var(--neu-bg,#E0E5EC);box-shadow:var(--neu-raise-xs,3px 3px 7px rgba(163,177,198,.7),-3px -3px 7px rgba(255,255,255,.85));overflow:hidden;display:flex;flex-direction:column;justify-content:flex-end;gap:9px}
152
+ #fwBootGate .fw-sk-hero .fw-sk-title{height:24px}
153
+ #fwBootGate .fw-sk-hero .fw-sk-desc{height:11px}
154
+ #fwBootGate .fw-sk-hrow{display:flex;align-items:center;gap:10px;margin-top:6px;min-width:0;max-width:760px}
155
+ #fwBootGate .fw-sk-hicon{flex:0 0 auto;width:34px;height:34px;border-radius:10px;background:var(--neu-inset,#D1D9E6);box-shadow:var(--neu-press-xs,inset 2px 2px 4px rgba(163,177,198,.7),inset -2px -2px 4px rgba(255,255,255,.85))}
156
+ #fwBootGate .fw-sk-hinfo{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:5px}
157
+ #fwBootGate .fw-sk-cta{flex:0 0 auto;margin-left:auto;width:64px;height:30px;border-radius:999px;background:var(--neu-bg,#E0E5EC);box-shadow:var(--neu-raise-xs,3px 3px 7px rgba(163,177,198,.7),-3px -3px 7px rgba(255,255,255,.85))}
158
+ #fwBootGate .fw-sk-dots{position:absolute;left:0;right:0;bottom:7px;display:flex;justify-content:center;align-items:center;gap:2px}
159
+ #fwBootGate .fw-sk-dots i{width:6px;height:6px;border-radius:999px;background:var(--stripe,rgba(163,177,198,.24))}
160
+ #fwBootGate .fw-sk-dots i.on{width:16px;background:var(--sk-stripe-2,rgba(163,177,198,.45))}
161
+ /* 卡格(同 .favorites-grid:gap 8px,断点 1100/1600) */
162
+ #fwBootGate .fw-sk-grid{flex:1 1 auto;display:grid;grid-template-columns:minmax(0,1fr);gap:8px;align-content:start;overflow:hidden}
163
+ @media (min-width:1100px){#fwBootGate .fw-sk-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
164
+ @media (min-width:1600px){#fwBootGate .fw-sk-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
165
+ /* 卡(同 .fav-icon 紧凑档 56px/封面40/星星右缘) */
166
+ #fwBootGate .fw-sk-card{position:relative;overflow:hidden;display:flex;align-items:center;gap:10px;padding:8px 10px;min-height:56px;border-radius:var(--neu-radius-sub,16px);background:var(--neu-bg,#E0E5EC);box-shadow:var(--neu-raise-xs,3px 3px 7px rgba(163,177,198,.7),-3px -3px 7px rgba(255,255,255,.85))}
167
+ #fwBootGate .fw-sk-cover{flex:0 0 auto;width:40px;height:40px;border-radius:12px;background:var(--neu-bg,#E0E5EC);box-shadow:var(--neu-raise-sm,5px 5px 10px rgba(163,177,198,.7),-5px -5px 10px rgba(255,255,255,.85))}
168
+ #fwBootGate .fw-sk-info{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:7px;padding-right:22px}
169
+ #fwBootGate .fw-sk-line{display:block;height:12px;border-radius:999px;background:var(--stripe,rgba(163,177,198,.24))}
170
+ #fwBootGate .fw-sk-line.fw-sk-sub{height:8px}
171
+ #fwBootGate .fw-sk-line.fw-sk-d{height:10px}
172
+ #fwBootGate .fw-sk-star{position:absolute;right:10px;top:50%;transform:translateY(-50%);width:16px;height:16px;border-radius:50%;background:var(--stripe,rgba(163,177,198,.24))}
173
+ /* 扫光:全高全幅覆盖整卡(2026-11-07 用户裁定「整个卡片区域都扫
174
+ 一遍」;此前的窄带内缩是对边缘光晕的过度矫正——光晕真凶是淡出
175
+ 叠印,已撤)。transform 横扫 = 合成器层;全体块同一时序。
176
+ 放行 = 当帧直摘,无叠印窗口。
177
+ 2026-11-07 又试径向椭圆光斑(为消右上角楔形亮尖),用户裁定
178
+ 撤回,回退本线性版;楔尖问题如再议需换路数(mask 已实测会被
179
+ 合成器忽略,不可用)。 */
180
+ #fwBootGate .fw-sk-card::after,#fwBootGate .fw-sk-hero::after{content:'';position:absolute;top:0;bottom:0;left:0;width:45%;transform:translateX(-120%) skewX(-18deg);background:linear-gradient(90deg,rgba(255,255,255,0),var(--sk-sheen,rgba(255,255,255,.55)),rgba(255,255,255,0));animation:fw-sk-sweep 1.6s ease-in-out infinite}
181
+ @keyframes fw-sk-sweep{to{transform:translateX(320%) skewX(-18deg)}}
182
+ @media (prefers-reduced-motion:reduce){#fwBootGate .fw-sk-card::after,#fwBootGate .fw-sk-hero::after{animation:none;opacity:0}}
183
+ #fwBootGate .fw-sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
184
+ /* 交叉渐变放行(2026-11-07 用户裁定「骨架渐渐消失 + 内容渐渐浮现」):
185
+ armed 先置真(点击即时生效),幕布 opacity 1→0 与真实界面
186
+ (.app-layout)opacity 0→1 同步对跑——中点各 50%,读作内容浮现
187
+ 而非此前单向淡出的亮内容渗漏叠印(那版一日即撤)。降动效双侧免动画。 */
188
+ #fwBootGate{transition:opacity .24s ease}
189
+ #fwBootGate.fw-boot-lift{opacity:0}
190
+ body.fw-boot-reveal .app-layout{animation:fw-boot-reveal .28s ease-out both}
191
+ @keyframes fw-boot-reveal{from{opacity:0}}
192
+ @media (prefers-reduced-motion:reduce){
193
+ #fwBootGate{transition:none}
194
+ body.fw-boot-reveal .app-layout{animation:none}
195
+ }
196
+ /* 暗色首帧兜底(token 到位后由真源接管) */
197
+ [data-theme="dark"] #fwBootGate .fw-sk-card,[data-theme="dark"] #fwBootGate .fw-sk-hero{background:var(--neu-bg,#1A1A1A);box-shadow:var(--neu-raise-xs,3px 3px 7px rgba(0,0,0,.55),-3px -3px 7px rgba(255,255,255,.07))}
198
+ [data-theme="dark"] #fwBootGate .fw-sk-cover{background:var(--neu-bg,#1A1A1A);box-shadow:var(--neu-raise-sm,5px 5px 10px rgba(0,0,0,.55),-5px -5px 10px rgba(255,255,255,.07))}
199
+ [data-theme="dark"] #fwBootGate .fw-sk-avatar,[data-theme="dark"] #fwBootGate .fw-sk-pill,[data-theme="dark"] #fwBootGate .fw-sk-cta{background:var(--neu-bg,#1A1A1A);box-shadow:var(--neu-raise-xs,3px 3px 7px rgba(0,0,0,.55),-3px -3px 7px rgba(255,255,255,.07))}
200
+ [data-theme="dark"] #fwBootGate .fw-sk-search,[data-theme="dark"] #fwBootGate .fw-sk-hicon,[data-theme="dark"] #fwBootGate .fw-sk-sb-item.is-active{background:var(--neu-inset,#131313);box-shadow:var(--neu-press-xs,inset 2px 2px 4px rgba(0,0,0,.55),inset -2px -2px 4px rgba(255,255,255,.07))}
201
+ [data-theme="dark"] #fwBootGate .fw-sk-line,[data-theme="dark"] #fwBootGate .fw-sk-star,[data-theme="dark"] #fwBootGate .fw-sk-ico,[data-theme="dark"] #fwBootGate .fw-sk-dots i{background:var(--stripe,rgba(255,255,255,.09))}
202
+ [data-theme="dark"] #fwBootGate .fw-sk-menu,[data-theme="dark"] #fwBootGate .fw-sk-menu::before,[data-theme="dark"] #fwBootGate .fw-sk-menu::after,[data-theme="dark"] #fwBootGate .fw-sk-dots i.on{background:var(--sk-stripe-2,rgba(255,255,255,.2))}
203
+ [data-theme="dark"] #fwBootGate .fw-sk-card::after,[data-theme="dark"] #fwBootGate .fw-sk-hero::after{--sk-sheen:rgba(255,255,255,.08)}
204
+ </style>
205
+
206
+
207
+ </head>
208
+ <body>
209
+ <!-- 应用挂载点 -->
210
+ <div id="app">
211
+ <!-- 引导幕布(2026-11-07 二次裁定整页化):加载态 = Shell 整页骨架
212
+ (侧边栏 + 主区精选横幅 + 收藏卡网格)+ 扫光,构形与几何见 head
213
+ 内「引导幕布整页骨架」样式块;全部静态直出(不靠 JS 生成——
214
+ 首绘先于一切脚本执行),这里只放 DOM。 -->
215
+ <div id="fwBootGate" aria-busy="true" style="position:fixed;inset:0;z-index:2147483647;display:flex;background:var(--neu-bg,#E0E5EC);pointer-events:none;">
216
+ <div class="fw-boot-shell" aria-hidden="true">
217
+ <div class="fw-sk-topbar"><span class="fw-sk-line" style="width:88px;height:14px"></span><span class="fw-sk-menu"></span></div>
218
+ <aside class="fw-sk-sb">
219
+ <div class="fw-sk-sb-head">
220
+ <span class="fw-sk-avatar"></span>
221
+ <span class="fw-sk-sb-id"><span class="fw-sk-line" style="width:56px"></span><span class="fw-sk-line fw-sk-sub" style="width:38px"></span></span>
222
+ <span class="fw-sk-pill"><span class="fw-sk-line" style="width:34px;height:9px"></span></span>
223
+ </div>
224
+ <div class="fw-sk-search"><span class="fw-sk-line" style="width:45%"></span></div>
225
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:52px"></span></div>
226
+ <div class="fw-sk-sec"><span class="fw-sk-line" style="width:30px;height:9px"></span></div>
227
+ <div class="fw-sk-sb-item is-active"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:64px"></span></div>
228
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:48px"></span></div>
229
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:42px"></span></div>
230
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:56px"></span></div>
231
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:44px"></span></div>
232
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:50px"></span></div>
233
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:40px"></span></div>
234
+ <div class="fw-sk-sb-bottom">
235
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:64px"></span></div>
236
+ <div class="fw-sk-sb-item"><span class="fw-sk-ico"></span><span class="fw-sk-line" style="width:44px"></span></div>
237
+ </div>
238
+ </aside>
239
+ <main class="fw-sk-main">
240
+ <div class="fw-sk-hero" id="fwSkHero">
241
+ <span class="fw-sk-line" style="width:64px;height:9px"></span>
242
+ <span class="fw-sk-line fw-sk-title" style="width:46%"></span>
243
+ <span class="fw-sk-line fw-sk-desc" style="width:30%"></span>
244
+ <div class="fw-sk-hrow">
245
+ <span class="fw-sk-hicon"></span>
246
+ <span class="fw-sk-hinfo"><span class="fw-sk-line" style="width:64px;height:10px"></span><span class="fw-sk-line fw-sk-sub" style="width:110px"></span></span>
247
+ <span class="fw-sk-cta"></span>
248
+ </div>
249
+ <div class="fw-sk-dots"><i class="on"></i><i></i><i></i><i></i><i></i></div>
250
+ </div>
251
+ <div class="fw-sk-grid">
252
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:62%"></div><div class="fw-sk-line fw-sk-d" style="width:88%"></div></div><span class="fw-sk-star"></span></div>
253
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:45%"></div><div class="fw-sk-line fw-sk-d" style="width:70%"></div></div><span class="fw-sk-star"></span></div>
254
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:58%"></div><div class="fw-sk-line fw-sk-d" style="width:80%"></div></div><span class="fw-sk-star"></span></div>
255
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:38%"></div><div class="fw-sk-line fw-sk-d" style="width:64%"></div></div><span class="fw-sk-star"></span></div>
256
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:66%"></div><div class="fw-sk-line fw-sk-d" style="width:92%"></div></div><span class="fw-sk-star"></span></div>
257
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:50%"></div><div class="fw-sk-line fw-sk-d" style="width:74%"></div></div><span class="fw-sk-star"></span></div>
258
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:42%"></div><div class="fw-sk-line fw-sk-d" style="width:60%"></div></div><span class="fw-sk-star"></span></div>
259
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:60%"></div><div class="fw-sk-line fw-sk-d" style="width:84%"></div></div><span class="fw-sk-star"></span></div>
260
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:36%"></div><div class="fw-sk-line fw-sk-d" style="width:52%"></div></div><span class="fw-sk-star"></span></div>
261
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:54%"></div><div class="fw-sk-line fw-sk-d" style="width:78%"></div></div><span class="fw-sk-star"></span></div>
262
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:48%"></div><div class="fw-sk-line fw-sk-d" style="width:68%"></div></div><span class="fw-sk-star"></span></div>
263
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:64%"></div><div class="fw-sk-line fw-sk-d" style="width:90%"></div></div><span class="fw-sk-star"></span></div>
264
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:57%"></div><div class="fw-sk-line fw-sk-d" style="width:82%"></div></div><span class="fw-sk-star"></span></div>
265
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:41%"></div><div class="fw-sk-line fw-sk-d" style="width:66%"></div></div><span class="fw-sk-star"></span></div>
266
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:63%"></div><div class="fw-sk-line fw-sk-d" style="width:76%"></div></div><span class="fw-sk-star"></span></div>
267
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:47%"></div><div class="fw-sk-line fw-sk-d" style="width:58%"></div></div><span class="fw-sk-star"></span></div>
268
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:55%"></div><div class="fw-sk-line fw-sk-d" style="width:86%"></div></div><span class="fw-sk-star"></span></div>
269
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:39%"></div><div class="fw-sk-line fw-sk-d" style="width:62%"></div></div><span class="fw-sk-star"></span></div>
270
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:61%"></div><div class="fw-sk-line fw-sk-d" style="width:72%"></div></div><span class="fw-sk-star"></span></div>
271
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:43%"></div><div class="fw-sk-line fw-sk-d" style="width:56%"></div></div><span class="fw-sk-star"></span></div>
272
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:59%"></div><div class="fw-sk-line fw-sk-d" style="width:94%"></div></div><span class="fw-sk-star"></span></div>
273
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:51%"></div><div class="fw-sk-line fw-sk-d" style="width:78%"></div></div><span class="fw-sk-star"></span></div>
274
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:37%"></div><div class="fw-sk-line fw-sk-d" style="width:64%"></div></div><span class="fw-sk-star"></span></div>
275
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:65%"></div><div class="fw-sk-line fw-sk-d" style="width:70%"></div></div><span class="fw-sk-star"></span></div>
276
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:57%"></div><div class="fw-sk-line fw-sk-d" style="width:82%"></div></div><span class="fw-sk-star"></span></div>
277
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:41%"></div><div class="fw-sk-line fw-sk-d" style="width:66%"></div></div><span class="fw-sk-star"></span></div>
278
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:63%"></div><div class="fw-sk-line fw-sk-d" style="width:76%"></div></div><span class="fw-sk-star"></span></div>
279
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:47%"></div><div class="fw-sk-line fw-sk-d" style="width:58%"></div></div><span class="fw-sk-star"></span></div>
280
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:55%"></div><div class="fw-sk-line fw-sk-d" style="width:86%"></div></div><span class="fw-sk-star"></span></div>
281
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:39%"></div><div class="fw-sk-line fw-sk-d" style="width:62%"></div></div><span class="fw-sk-star"></span></div>
282
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:61%"></div><div class="fw-sk-line fw-sk-d" style="width:72%"></div></div><span class="fw-sk-star"></span></div>
283
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:43%"></div><div class="fw-sk-line fw-sk-d" style="width:56%"></div></div><span class="fw-sk-star"></span></div>
284
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:59%"></div><div class="fw-sk-line fw-sk-d" style="width:94%"></div></div><span class="fw-sk-star"></span></div>
285
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:51%"></div><div class="fw-sk-line fw-sk-d" style="width:78%"></div></div><span class="fw-sk-star"></span></div>
286
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:37%"></div><div class="fw-sk-line fw-sk-d" style="width:64%"></div></div><span class="fw-sk-star"></span></div>
287
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:65%"></div><div class="fw-sk-line fw-sk-d" style="width:70%"></div></div><span class="fw-sk-star"></span></div>
288
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:46%"></div><div class="fw-sk-line fw-sk-d" style="width:74%"></div></div><span class="fw-sk-star"></span></div>
289
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:58%"></div><div class="fw-sk-line fw-sk-d" style="width:84%"></div></div><span class="fw-sk-star"></span></div>
290
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:40%"></div><div class="fw-sk-line fw-sk-d" style="width:60%"></div></div><span class="fw-sk-star"></span></div>
291
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:62%"></div><div class="fw-sk-line fw-sk-d" style="width:88%"></div></div><span class="fw-sk-star"></span></div>
292
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:49%"></div><div class="fw-sk-line fw-sk-d" style="width:68%"></div></div><span class="fw-sk-star"></span></div>
293
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:36%"></div><div class="fw-sk-line fw-sk-d" style="width:52%"></div></div><span class="fw-sk-star"></span></div>
294
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:54%"></div><div class="fw-sk-line fw-sk-d" style="width:80%"></div></div><span class="fw-sk-star"></span></div>
295
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:44%"></div><div class="fw-sk-line fw-sk-d" style="width:62%"></div></div><span class="fw-sk-star"></span></div>
296
+ <div class="fw-sk-card"><div class="fw-sk-cover"></div><div class="fw-sk-info"><div class="fw-sk-line" style="width:60%"></div><div class="fw-sk-line fw-sk-d" style="width:78%"></div></div><span class="fw-sk-star"></span></div>
297
+ </div>
298
+ </main>
299
+ </div>
300
+ <span class="fw-sr-only">正在加载...</span>
301
+ </div>
302
+ <script>
303
+ /* 路由对齐(同步、首绘前执行):精选横幅只在 /feature/* 分区视图
304
+ 出现(真源 = boot.ts feat-hero-host 宿主 + feature-views.ts 填充);
305
+ 其余首屏路径(/ /favorites /my)无横幅,骨架同步摘除避免形态错位。 */
306
+ (function () {
307
+ try {
308
+ if (!/^\/feature\//.test(location.pathname)) {
309
+ var h = document.getElementById('fwSkHero');
310
+ if (h) h.style.display = 'none';
311
+ }
312
+ } catch (e) { /* 路径异常不碍骨架 */ }
313
+ })();
314
+ </script>
315
+ </div>
316
+
317
+ <style rel="stylesheet" crossorigin>.ip-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:20000;background:#000000eb;display:flex;align-items:center;justify-content:center;cursor:zoom-out;-webkit-tap-highlight-color:transparent;touch-action:none}.ip-stage{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;cursor:default;touch-action:none}.ip-img-wrap{position:relative;max-width:100%;max-height:100%;cursor:grab}.ip-img-wrap:active{cursor:grabbing}.ip-img{display:block;max-width:100%;max-height:100%;transform-origin:0 0;user-select:none;-webkit-user-select:none;pointer-events:auto;-webkit-user-drag:none}.ip-close{position:absolute;top:calc(12px + env(safe-area-inset-top,0px));right:12px;width:44px;height:44px;border-radius:50%;border:none;background:#00000080;color:#fff;font-size:1.5rem;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:2;font-family:-apple-system,BlinkMacSystemFont,sans-serif}.ip-close:active{background:#000000b3}.ip-title{position:absolute;left:0;right:0;bottom:calc(16px + env(safe-area-inset-bottom,0px));text-align:center;color:#ffffffeb;font-size:.88rem;font-family:-apple-system,BlinkMacSystemFont,sans-serif;pointer-events:none;text-shadow:0 1px 3px rgba(0,0,0,.5)}.ip-counter{margin-left:8px;color:#ffffffa6;font-variant-numeric:tabular-nums}.ip-nav{position:absolute;top:50%;transform:translateY(-50%);width:44px;height:64px;border:none;background:#00000059;color:#fff;font-size:1.6rem;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:2;font-family:-apple-system,BlinkMacSystemFont,sans-serif;-webkit-tap-highlight-color:transparent}.ip-nav:active{background:#0000008c}.ip-nav-prev{left:12px;border-radius:8px}.ip-nav-next{right:12px;border-radius:8px}.ip-error{display:flex;align-items:center;justify-content:center;min-height:120px;padding:24px;color:#ffffffbf;font-size:14px}.pv-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:4000;background:var(--neu-bg);display:flex;flex-direction:column}.pv-scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y;display:flex;flex-direction:column}.pv-scroll:focus{outline:none}.pv-body{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}.pv-head{position:sticky;top:0;z-index:100;padding-top:env(safe-area-inset-top,0px);background:var(--neu-bg);border-bottom:1px solid var(--border-soft, #edf2f7)}.pv-close{margin-left:auto}.pv-actions{flex:none;display:inline-flex;align-items:center;gap:4px}.pv-actions:empty{display:none}.pv-action-btn{min-height:28px;padding:4px 14px;background:transparent;color:var(--primary);border:1px solid var(--primary);border-radius:14px;font-size:.78rem;font-weight:600;line-height:1;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:background-color .15s,color .15s}.pv-action-btn:hover,.pv-action-btn:active{background:var(--primary-tint)}.pv-action-btn:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.pv-action-btn-primary{background:var(--primary);color:#fff}.pv-action-btn-primary:hover{background:var(--primary-2)}.pv-action-btn-primary:active{background:#2f6da6}.pv-action-btn-primary:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.pv-action-icon-btn{width:36px;height:36px;min-height:36px;padding:0;border:0;border-radius:50%;background:var(--primary);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:background .15s ease;flex:none}.pv-action-icon-btn:hover{background:var(--primary-2)}.pv-action-icon-btn:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.pv-action-icon-btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round}.pv-action-icon-btn-text{font-size:1.4rem;line-height:1}.pv-overlay.pv-dock-right{position:absolute;top:0;right:0;bottom:0;left:auto;width:360px;max-width:86%;border-left:1px solid var(--border-soft, #edf2f7);box-shadow:-10px 0 28px #0f141e38}@keyframes pvDockIn{0%{transform:translate(32px);opacity:.3}to{transform:translate(0);opacity:1}}@keyframes pvDockOut{0%{transform:translate(0);opacity:1}to{transform:translate(36px);opacity:0}}.pv-dock-enter{animation:pvDockIn var(--motion-dur-med, .22s) var(--motion-ease-out, ease-out)}.pv-dock-exit{pointer-events:none;animation:pvDockOut var(--motion-dur-med, .22s) var(--motion-ease-in, ease-in) forwards}.xv-body>.pv-overlay{top:var(--wv-chrome-top, 0px)}.pv-title{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:flex;align-items:center;justify-content:center;max-width:calc(100% - 96px);height:44px;margin:0;font-size:1rem;font-weight:600;line-height:1.2;color:var(--text-1, #2d3748);text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.skv-body{padding:18px 22px calc(40px + env(safe-area-inset-bottom,0px));background:linear-gradient(180deg,var(--neu-bg) 0%,var(--neu-bg) 220px);min-height:100%;box-sizing:border-box}.skv-md{max-width:680px;margin:0 auto;color:var(--text-1);font-size:15px;line-height:1.75;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Segoe UI,Microsoft YaHei,sans-serif;word-wrap:break-word}.skv-md ::selection{background:var(--tint-soak)}.skv-md video.md-video{max-width:100%;border-radius:10px;background:#000}.skv-md audio.md-audio{width:100%;height:40px}.skv-md h1,.skv-md h2,.skv-md h3,.skv-md h4,.skv-md h5,.skv-md h6{margin:1.5em 0 .65em;font-weight:700;line-height:1.35;color:var(--text-1)}.skv-md h1{font-size:1.65em;padding-bottom:.35em;border-bottom:2px solid transparent;border-image:linear-gradient(90deg,var(--primary),var(--primary-tint)) 1}.skv-md h2{font-size:1.35em;padding-left:.55em;position:relative}.skv-md h2:before{content:"";position:absolute;left:0;top:.18em;bottom:.18em;width:4px;border-radius:2px;background:linear-gradient(180deg,var(--primary),var(--primary-2))}.skv-md h3{font-size:1.18em;color:var(--primary)}.skv-md h4{font-size:1.05em;color:var(--text-1)}.skv-md h5{font-size:.95em;color:var(--text-1)}.skv-md h6{font-size:.9em;color:var(--text-3);font-weight:600}.skv-md h1:first-child,.skv-md h2:first-child,.skv-md h3:first-child{margin-top:0}.skv-md p{margin:.85em 0}.skv-md ul,.skv-md ol{margin:.85em 0;padding-left:1.6em}.skv-md li{margin:.35em 0}.skv-md li::marker{color:var(--primary);font-weight:600}.skv-md li>ul,.skv-md li>ol{margin:.2em 0}.skv-md li input[type=checkbox]{margin-right:.45em;accent-color:var(--primary)}.skv-md code{padding:.15em .45em;margin:0;font-size:.88em;background:var(--primary-tint);color:var(--primary);border-radius:5px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,monospace}.skv-md pre{margin:1em 0;padding:14px 16px;overflow-x:auto;background:var(--stripe);border-radius:10px;line-height:1.55;box-shadow:0 1px 3px #0f172a1f}.skv-md pre code{padding:0;background:transparent;color:var(--text-1);border-radius:0;font-size:.85rem}.skv-md .md-table-wrap{margin:1em 0;overflow-x:auto;font-size:.92em;border:1px solid var(--primary-tint);border-radius:10px}.skv-md .md-table-wrap table{margin:0;width:100%;border-collapse:separate;border-spacing:0}.skv-md th,.skv-md td{padding:8px 13px;text-align:left;border-bottom:1px solid var(--hairline)}.skv-md th{background:linear-gradient(180deg,var(--stripe),var(--stripe));color:var(--primary);font-weight:600;white-space:nowrap}.skv-md tr:last-child td{border-bottom:0}.skv-md tbody tr:nth-child(2n) td{background:var(--stripe)}.skv-md blockquote{margin:1em 0;padding:.55em 1em;color:var(--text-1);border-left:4px solid var(--primary);background:var(--neu-bg);border-radius:0 8px 8px 0}.skv-md blockquote>:first-child{margin-top:0}.skv-md blockquote>:last-child{margin-bottom:0}.skv-md a{color:var(--primary);text-decoration:none;font-weight:500;border-bottom:1px solid var(--tint-edge);transition:color .15s,border-color .15s}.skv-md a:hover{color:var(--primary-2);border-bottom-color:var(--primary-2)}.skv-md hr{margin:1.6em 0;border:0;height:2px;border-radius:1px;background:linear-gradient(90deg,transparent,var(--primary-tint) 20%,var(--primary-tint) 80%,transparent)}.skv-md img{max-width:100%;height:auto;border-radius:8px;box-shadow:0 1px 4px #0f172a1a}.skv-md strong{font-weight:600;color:var(--text-1)}.skv-md del{color:var(--text-3)}.skv-md kbd{padding:.1em .4em;font-size:.85em;color:var(--primary);background:var(--neu-inset);border:1px solid var(--primary-tint);border-bottom-width:2px;border-radius:5px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.xv-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:transparent;z-index:4000}.xv-body{position:absolute;top:0;right:0;bottom:0;left:0;isolation:isolate;--wv-chrome-top: calc(env(safe-area-inset-top, 0px) + 64px) }.xv-controls{position:absolute;top:calc(env(safe-area-inset-top,0px) + 10px);right:10px;z-index:2;display:flex;gap:8px;pointer-events:none}.xv-close{pointer-events:auto;flex:none;width:44px;height:44px;min-width:44px;min-height:44px;max-width:44px;max-height:44px;aspect-ratio:1 / 1;padding:0;margin:0;border:none;border-radius:50%;-webkit-border-radius:50%;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-sizing:border-box;background:#1e283261;backdrop-filter:saturate(180%) blur(8px);-webkit-backdrop-filter:saturate(180%) blur(8px);color:#fff;font-size:1.4rem;line-height:1;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}.xv-close:active{background:#1e283299}.xv-loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;background:var(--neu-bg);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;color:var(--text-2, #4a5568);font-size:.9rem}.xv-spinner{width:28px;height:28px;border:3px solid var(--border-soft, #edf2f7);border-top-color:var(--primary);border-radius:50%;animation:xvSpin .8s linear infinite}@keyframes xvSpin{to{transform:rotate(360deg)}}@keyframes xvLoadingFade{0%{opacity:1}to{opacity:0}}.xv-loading-out{pointer-events:none;animation:xvLoadingFade var(--motion-dur-med) var(--motion-ease-in) forwards}@keyframes xvShellFadeIn{0%{opacity:0}to{opacity:1}}.xv-shell-enter-fade{animation:xvShellFadeIn var(--motion-dur-med) var(--motion-ease-out)}@keyframes xvShellRise{0%{transform:translateY(var(--motion-enter-y))}to{transform:translateY(0)}}@keyframes xvShellDrop{0%{transform:translateY(0)}to{transform:translateY(var(--motion-exit-y))}}.xv-shell-enter{animation:xvShellRise var(--motion-dur-slow) var(--motion-ease-out)}.xv-shell-closing{pointer-events:none;animation:xvShellDrop var(--motion-dur-med) var(--motion-ease-in) forwards}.xv-overlay,.xv-overlay *{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}.xv-overlay input,.xv-overlay textarea,.xv-overlay [contenteditable]:not([contenteditable=false]){-webkit-user-select:text;user-select:text}.xv-error{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:24px;text-align:center;background:var(--neu-bg);color:var(--text-2, #5D6673)}.xv-error-glyph{width:52px;height:52px;display:flex;align-items:center;justify-content:center;border-radius:50%;box-shadow:inset 0 0 0 3px currentColor;font-size:1.6rem;font-weight:700;opacity:.45}.xv-error-title{font-size:1.05rem;font-weight:600;color:var(--text-1, #3D4852)}.xv-error-sub{font-size:.85rem;word-break:break-word;max-width:34em}.xv-error-hint{font-size:.75rem;opacity:.55;margin-top:6px}body.app-shell-mode{overflow:hidden;overscroll-behavior:none;background-color:var(--neu-bg)}body.app-shell-mode .app-canvas{max-width:none}.app-layout{position:relative;display:flex;width:100%;height:100vh;height:100dvh;box-sizing:border-box;padding-top:env(safe-area-inset-top,0px);padding-bottom:0;overflow:hidden;touch-action:pan-y}.app-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}.app-shell{position:relative;flex:1 1 auto;min-height:0;overflow:hidden;touch-action:pan-y}.app-sidebar{position:absolute;top:0;bottom:0;left:0;z-index:30;display:flex;flex-direction:column;width:min(80vw,272px);box-sizing:border-box;padding:14px 12px calc(10px + env(safe-area-inset-bottom,0px));background:var(--neu-bg);border-right:var(--neu-line);transform:translate(-102%);transition:transform var(--motion-dur-med, .24s) var(--motion-ease-out, ease-out);overflow:hidden}.app-layout.sb-open .app-sidebar{transform:none;box-shadow:var(--neu-pop-shadow)}.app-sidebar.sb-dragging{transition:none}.sb-scrim{position:absolute;top:0;right:0;bottom:0;left:0;z-index:20;background:transparent;pointer-events:none;touch-action:none}.app-layout.sb-open .sb-scrim{pointer-events:auto}.sb-topbar{display:none;flex:0 0 auto;align-items:center;justify-content:space-between;gap:10px;height:48px;padding:0 10px 0 14px;background:var(--neu-bg);border-bottom:var(--neu-line)}.sb-topbar-title{min-width:0;font-size:1.05rem;font-weight:800;color:var(--text-1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sb-menu-btn{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;padding:0;border:none;border-radius:50%;background:transparent;box-shadow:none;color:var(--text-2);line-height:1;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:background-color .15s ease}.sb-menu-btn:active{background:var(--border-soft, #edf2f7)}.sb-menu-btn:focus-visible{outline:2px solid var(--primary, #3182ce);outline-offset:2px}.sb-menu-icon,.sb-menu-icon:before,.sb-menu-icon:after{display:block;width:18px;height:2px;border-radius:1px;background:currentColor}.sb-menu-icon{position:relative}.sb-menu-icon:before,.sb-menu-icon:after{content:"";position:absolute;left:0}.sb-menu-icon:before{top:-6px}.sb-menu-icon:after{top:6px}@media (max-width: 959.98px){.sb-topbar{display:flex}}.sb-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}.sb-head{display:flex;align-items:center;gap:8px}.sb-head .sb-brand{flex:1 1 auto;min-width:0}.sb-brand{display:flex;align-items:center;gap:10px;padding:6px 8px;border-radius:14px;color:inherit;text-decoration:none}.sb-points{flex:0 0 auto;margin-left:auto;display:inline-flex;align-items:center;gap:5px;min-height:0;padding:5px 10px;border:none;border-radius:var(--neu-radius-pill);background:var(--neu-bg);box-shadow:var(--neu-raise-xs);color:var(--ok);font:inherit;font-size:12px;font-weight:800;line-height:1.2;white-space:nowrap;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:box-shadow .15s ease}.sb-points[hidden]{display:none}.sb-points-link{text-decoration:none;color:var(--ok)}.sb-points-link:hover{filter:brightness(1.08)}.sb-points:active{box-shadow:var(--neu-press-xs)}.sb-avatar{flex:0 0 auto;display:flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:12px;background:var(--neu-bg);box-shadow:var(--neu-raise-xs);overflow:hidden;font-size:20px}.sb-avatar img{width:100%;height:100%;object-fit:cover}.sb-avatar .avatar{background:transparent}.sb-brand-text{display:flex;flex-direction:column;min-width:0}.sb-name{font-size:15px;font-weight:800;color:var(--text-1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sb-sub{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sb-search{display:flex;align-items:center;gap:8px;width:100%;margin-top:10px;color:var(--text-3)}.sb-search .sb-search-input{flex:1 1 auto;min-width:0;padding:0 14px!important;font-size:16px!important}.sb-search.sb-search-off{opacity:.55}.sb-search.sb-search-off .sb-search-input{cursor:not-allowed}.sb-nav{display:flex;flex-direction:column;gap:2px;margin-top:12px}.sb-sec-label{margin:14px 10px 4px;font-size:11px;font-weight:700;letter-spacing:.08em;color:var(--text-muted)}.sb-feats{display:flex;flex-direction:column;gap:2px}.sb-item{display:flex;align-items:center;gap:10px;width:100%;min-height:40px;padding:8px 10px;border:none;border-radius:12px;background:transparent;color:var(--text-2);font-size:14px;font-weight:600;text-align:left;text-decoration:none;cursor:pointer;transition:box-shadow .15s ease,background-color .15s ease}.sb-item:hover{background:var(--primary-tint)}.sb-item.active{background:var(--neu-inset);box-shadow:var(--neu-press-xs);color:var(--text-1)}.sb-ico{flex:0 0 auto;width:22px;font-size:17px;line-height:1;text-align:center}.sb-label{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sb-bottom{flex:0 0 auto;margin-top:8px;padding-top:8px;border-top:var(--neu-line)}.sb-bottom .sb-item{min-height:38px}@media (min-width: 960px){.app-sidebar{position:static;flex:0 0 auto;width:224px;transform:none;transition:none;box-shadow:none}.app-layout.sb-open .app-sidebar{transform:none;box-shadow:none}.sb-scrim{display:none!important}}.app-shell .app-view{display:none;box-sizing:border-box;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;height:100%;width:100%;touch-action:pan-y}.app-shell .app-view-active{display:block}.app-shell .app-view{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}.app-shell .app-view input,.app-shell .app-view textarea,.app-shell .app-view [contenteditable=true]{-webkit-user-select:text;user-select:text;-webkit-touch-callout:default}.app-view.shell-prewarm .item-card{content-visibility:visible}.app-shell .app-view>.container{width:100%;max-width:860px;margin:0 auto;box-sizing:border-box}.app-shell .app-view-my{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;background:var(--neu-bg);color:var(--text-1);padding:12px 10px;-webkit-tap-highlight-color:transparent}.app-shell .app-view-my h1{text-align:center;margin:0 0 10px;font-size:1.2rem}.app-shell .app-view-my h2{font-size:1.05rem;margin:18px 0 10px;color:var(--text-1)}.app-shell .app-view-my .card{background:var(--neu-bg);border-radius:10px;box-shadow:0 1px 4px #00000014;padding:14px}.app-shell .app-view-my .empty{text-align:center;color:var(--text-muted);padding:26px 0;font-size:.92rem}.app-shell .app-view-favorites,.app-shell .app-view-feature{font-family:-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,Arial,sans-serif;background:var(--neu-bg);color:var(--text-1);padding:12px 10px calc(12px + env(safe-area-inset-bottom,0px));-webkit-tap-highlight-color:transparent}.lf-status{flex:1 0 auto;min-height:0;display:flex;align-items:center;justify-content:center;padding:24px;text-align:center;color:var(--text-muted);font-size:15px;line-height:1.6}.lf-status-error{color:var(--danger)}.lf-status-area{min-height:var(--status-area-height, 260px)}.lf-status-section{flex:none;min-height:96px;padding:18px}.lf-status-inline{flex:none;padding:18px 0;font-size:.85rem}:root{--primary: #6C63FF;--primary-2: #5A50E8;--canvas-w: 100%;--text-1: #3D4852;--text-2: #5D6673;--text-3: #8A94A6;--text-muted: #97A3B5;--border: #DCE3EC;--border-soft: #E4EAF1;--neu-bg: #E0E5EC;--neu-inset: #D1D9E6;--neu-sh-dark: rgba(163, 177, 198, .7);--neu-sh-light: rgba(255, 255, 255, .85);--neu-raise: 9px 9px 18px var(--neu-sh-dark), -9px -9px 18px var(--neu-sh-light);--neu-raise-sm: 5px 5px 10px var(--neu-sh-dark), -5px -5px 10px var(--neu-sh-light);--neu-raise-xs: 3px 3px 7px var(--neu-sh-dark), -3px -3px 7px var(--neu-sh-light);--neu-press: inset 5px 5px 12px var(--neu-sh-dark), inset -5px -5px 12px var(--neu-sh-light);--neu-press-sm: inset 3px 3px 6px var(--neu-sh-dark), inset -3px -3px 6px var(--neu-sh-light);--neu-press-xs: inset 2px 2px 4px var(--neu-sh-dark), inset -2px -2px 4px var(--neu-sh-light);--neu-pop-shadow: 0 8px 24px rgba(100, 112, 130, .35), 0 2px 6px rgba(100, 112, 130, .2);--neu-radius-card: 24px;--neu-radius-sub: 16px;--neu-radius-pill: 999px;--neu-accent-grad: linear-gradient(145deg, #7B73FF, var(--primary-2));--neu-overlay-bg: var(--neu-bg);--neu-line: 1px solid rgba(198, 207, 220, .45);--neu-float-bg: var(--neu-bg);--danger: #E53E3E;--danger-tint: rgba(197, 48, 48, .08);--ok: #38A169;--ok-tint: rgba(56, 161, 105, .25);--qr-dark: #5C4033;--primary-tint: rgba(92, 64, 51, .1);--tint-soak: rgba(92, 64, 51, .25);--tint-edge: rgba(92, 64, 51, .42);--tint-focus: rgba(92, 64, 51, .38);--hairline: rgba(163, 177, 198, .4);--stripe: rgba(163, 177, 198, .18);--pin-wash: rgba(209, 217, 230, .4);--canvas-hi: rgba(255, 255, 255, .55);--canvas-lo: rgba(163, 177, 198, .38)}:root[data-theme=dark]{color-scheme:dark;--primary: #C89E6E;--primary-2: #E2C29B;--text-1: #F2F2F2;--text-2: #C9C9C9;--text-3: #999999;--text-muted: #6E6E6E;--border: #3A3A3A;--border-soft: #303030;--neu-bg: #1A1A1A;--neu-inset: #131313;--neu-sh-dark: rgba(0, 0, 0, .55);--neu-sh-light: rgba(255, 255, 255, .07);--neu-pop-shadow: 0 8px 24px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);--neu-line: 1px solid rgba(255, 255, 255, .12);--neu-accent-grad: var(--neu-bg);--neu-raise: 9px 9px 18px var(--neu-sh-dark), -9px -9px 18px var(--neu-sh-light);--neu-raise-sm: 5px 5px 10px var(--neu-sh-dark), -5px -5px 10px var(--neu-sh-light);--neu-raise-xs: 3px 3px 7px var(--neu-sh-dark), -3px -3px 7px var(--neu-sh-light);--neu-press: inset 5px 5px 12px var(--neu-sh-dark), inset -5px -5px 12px var(--neu-sh-light);--neu-press-sm: inset 3px 3px 6px var(--neu-sh-dark), inset -3px -3px 6px var(--neu-sh-light);--neu-press-xs: inset 2px 2px 4px var(--neu-sh-dark), inset -2px -2px 4px var(--neu-sh-light);--neu-overlay-bg: var(--neu-bg);--neu-float-bg: var(--neu-bg);--danger: #F0715F;--danger-tint: rgba(240, 113, 95, .16);--ok: #6FBF8E;--ok-tint: rgba(111, 191, 142, .3);--qr-dark: #C89E6E;--primary-tint: rgba(200, 158, 110, .16);--tint-soak: rgba(200, 158, 110, .32);--tint-edge: rgba(200, 158, 110, .55);--tint-focus: rgba(200, 158, 110, .5);--hairline: rgba(255, 255, 255, .12);--stripe: rgba(255, 255, 255, .06);--pin-wash: rgba(255, 255, 255, .07);--canvas-hi: rgba(255, 255, 255, .05);--canvas-lo: rgba(0, 0, 0, .4)}@keyframes themeVtOut{0%{opacity:1}to{opacity:0}}@keyframes themeVtIn{0%{opacity:0}to{opacity:1}}:root.theme-vt::view-transition-old(root){animation:themeVtOut .45s cubic-bezier(.4,0,.6,1) forwards}:root.theme-vt::view-transition-new(root){animation:themeVtIn .45s cubic-bezier(.4,0,.6,1) forwards}:root{--motion-dur-med: .24s;--motion-dur-slow: .28s;--motion-dur-page: .36s;--motion-ease-out: cubic-bezier(.2, .8, .2, 1);--motion-ease-standard: cubic-bezier(.4, 0, .2, 1);--motion-ease-in: cubic-bezier(.4, 0, 1, 1);--motion-enter-y: 12px;--motion-exit-y: 10px}*{box-sizing:border-box}*{-webkit-tap-highlight-color:transparent}html,body{-webkit-text-size-adjust:100%;text-size-adjust:100%;margin:0;padding:0!important;min-height:100vh;min-height:100dvh;background:radial-gradient(1100px 560px at 15% -8%,var(--canvas-hi),transparent 62%),radial-gradient(900px 520px at 108% 108%,var(--canvas-lo),transparent 60%),var(--neu-bg);color:inherit;touch-action:manipulation}.app-canvas,.app-root{width:100%;max-width:var(--canvas-w);margin:0 auto;min-height:100vh;min-height:100dvh;background:radial-gradient(1100px 560px at 15% -8%,var(--canvas-hi),transparent 62%),radial-gradient(900px 520px at 108% 108%,var(--canvas-lo),transparent 60%),var(--neu-bg);position:relative;padding-top:env(safe-area-inset-top,0px);padding-right:env(safe-area-inset-right,0px);padding-left:env(safe-area-inset-left,0px);overflow-x:hidden}button,[role=button]{min-height:44px;padding-top:0;padding-bottom:0}button,[role=button],a{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}button:focus-visible{outline:2px solid var(--primary);outline-offset:2px}button:disabled,[aria-disabled=true]{opacity:.55;cursor:not-allowed}input,select,textarea,[contenteditable=true]{font-size:16px;line-height:1.4}input[type=checkbox],input[type=radio]{min-width:22px;min-height:22px}input:not([type=checkbox]):not([type=radio]),select,textarea{min-height:44px}input:focus-visible,select:focus-visible,textarea:focus-visible,[contenteditable=true]:focus-visible{outline:2px solid var(--primary);outline-offset:1px}@media (prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}}@view-transition{navigation: auto;}::view-transition-old(root){animation:vtContainerOut var(--motion-dur-page) var(--motion-ease-standard) forwards}::view-transition-new(root){animation:vtContainerIn var(--motion-dur-page) var(--motion-ease-standard) forwards}@keyframes vtContainerOut{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(calc(var(--motion-enter-y) * -1))}}@keyframes vtContainerIn{0%{opacity:0;transform:translateY(var(--motion-enter-y))}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion: reduce){::view-transition-old(root),::view-transition-new(root),::view-transition-group(root){animation-duration:.001ms!important}}@keyframes shellEnter{0%{opacity:0;transform:translateY(var(--motion-enter-y))}to{opacity:1;transform:translateY(0)}}@keyframes shellExit{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(var(--motion-exit-y))}}.shell-enter{animation:shellEnter var(--motion-dur-slow) var(--motion-ease-out)}.shell-closing{pointer-events:none;animation:shellExit var(--motion-dur-med) var(--motion-ease-in) forwards}.lf-chrome-back,.lf-chrome-close{flex:none;width:44px;height:44px;border:none;background:transparent;border-radius:50%;line-height:1;color:var(--text-2, #4a5568);cursor:pointer;display:inline-flex;align-items:center;justify-content:center}.lf-chrome-titlebar{position:relative;display:flex;align-items:center;gap:8px;padding:2px}.lf-chrome-back{font-size:1.5rem}.lf-chrome-close{font-size:1.4rem}.lf-chrome-back:active,.lf-chrome-close:active{background:var(--border-soft, #edf2f7)}.ms-confirm-overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:4100;background:#00000080;display:none;align-items:center;justify-content:center;padding:16px}.ms-confirm-overlay.active{display:flex}.ms-confirm{background:var(--neu-bg);border-radius:14px;width:100%;max-width:420px;max-height:80%;overflow:hidden;display:flex;flex-direction:column;box-shadow:0 20px 60px #00000059}.ms-confirm-title{padding:16px 18px 4px;font-size:1.05rem;font-weight:700;color:var(--text-1)}.ms-confirm-title:empty{display:none}.ms-confirm-message{padding:6px 18px 16px;font-size:.95rem;color:var(--text-2);line-height:1.5;overflow-y:auto;-webkit-overflow-scrolling:touch}.ms-confirm-actions{display:flex;gap:8px;padding:0 14px 14px;justify-content:flex-end;flex-wrap:wrap}.ms-confirm-actions button{flex:1 1 0;min-width:96px;min-height:44px;padding:0 14px;border-radius:10px;border:1px solid transparent;font-size:.95rem;font-weight:600;cursor:pointer;background:var(--border-soft);color:var(--text-1)}.ms-confirm-actions button.ms-confirm-cancel:focus-visible,.ms-confirm-actions button.ms-confirm-ok:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.ms-confirm-actions button.ms-confirm-ok{background:var(--primary);color:#fff}.ms-confirm-actions button.ms-confirm-ok.danger{background:var(--danger)}.ms-inline-notice{margin:10px 12px 12px;padding:10px 12px;border-left:3px solid var(--danger);border-radius:6px;background:var(--danger-tint);color:var(--danger);font-size:.9rem;line-height:1.45;cursor:pointer}.ms-inline-notice.warn{border-left-color:var(--text-muted);background:var(--neu-inset);color:var(--text-1)}html.ms-locked,html.ms-locked body{overflow:hidden!important;touch-action:none}.ps-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:4500;pointer-events:none}.ps-panel{display:flex;align-items:center;gap:8px;width:min(560px,calc(100% - 24px));margin:calc(60px + env(safe-area-inset-top,0px)) auto 0;pointer-events:auto;animation:ps-panel-in .15s ease-out}@keyframes ps-panel-in{0%{transform:translateY(-8px);opacity:0}to{transform:translateY(0);opacity:1}}.ps-overlay,.ps-overlay *{-webkit-tap-highlight-color:transparent}.ps-input{flex:1;width:100%;min-width:0;box-sizing:border-box;-moz-appearance:none;appearance:none;-webkit-appearance:none;font-family:inherit}.ps-cancel{flex:none;font-size:.88rem;cursor:pointer;font-family:inherit}.panel-scope,.panel-scope *{box-sizing:border-box}.panel-scope{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;background:var(--neu-bg);margin:0;color:var(--text-1);-webkit-tap-highlight-color:transparent}.panel-scope .container{margin:0 auto;padding:4px 10px 12px}.panel-scope .status-region{min-height:22px;margin:0 4px 12px;padding:4px 10px;font-size:.85rem;color:var(--text-2);text-align:center;border-radius:6px}.panel-scope .status-region.error{color:var(--danger);background:var(--danger-tint)}.panel-scope .status-region.warn{color:#d48806;background:#fffbe6}.panel-scope .status-region.success{color:#389e0d;background:#f6ffed}.panel-scope .status-region:empty{display:none}.panel-scope .card{padding:14px;margin-bottom:10px}.panel-scope .badge{display:inline-block;font-size:.7rem;padding:1px 8px;border-radius:10px;margin-left:6px;vertical-align:1px}.panel-scope .badge-locked{background:var(--neu-inset);color:var(--text-muted)}.panel-scope .badge-self{background:var(--border-soft);color:var(--text-3)}.panel-scope .role-chip{font-size:.72rem;padding:2px 10px;border-radius:12px;background:var(--primary-tint);color:var(--primary)}.panel-scope .empty{text-align:center;color:var(--text-muted);padding:26px 0;font-size:.92rem}.panel-scope .form-row{margin-bottom:12px}.panel-scope .form-row>label{display:block;font-size:.85rem;font-weight:600;color:var(--text-2);margin-bottom:6px}.panel-scope .form-row input[type=text],.panel-scope .form-row input[type=password]{width:100%;min-height:44px;padding:10px 12px;font-size:16px;color:var(--text-1, #2d3748);outline:none}.panel-scope .form-row select{width:100%;min-height:44px;padding:10px 36px 10px 12px;font-size:16px;color:var(--text-1, #2d3748);outline:none}.panel-scope .rd-hint{margin:14px 0 2px;padding:10px 12px;font-size:.78rem;line-height:1.55;color:var(--text-3);background:var(--neu-inset);border:none;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-press-sm)}.panel-scope .adm-form-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:16px}.panel-scope .perm-scope{font-size:.78rem;min-height:32px;padding:2px 6px}.panel-scope .permission-list{display:grid;gap:7px;max-height:52vh;overflow:auto}.panel-scope .modal-actions{display:flex;gap:8px;margin-top:14px}.panel-scope .modal-actions button{flex:1;min-height:44px;font-size:.85rem}.panel-scope .item-card.admin-card{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto auto;gap:3px 12px;min-height:0;padding:10px 12px}.panel-scope .admin-card .item-cover-wrap{width:48px;height:48px;flex:none;grid-row:1 / 3;grid-column:1;align-self:center;border-radius:50%;overflow:hidden;border:none;background:var(--primary-tint)}.panel-scope .admin-card .admin-avatar-inner{width:100%;height:100%;object-fit:cover;display:flex;align-items:center;justify-content:center;font-size:1.25rem;font-weight:600;color:var(--primary);background:var(--primary-tint)}.panel-scope .admin-card .admin-avatar-inner.avatar-emoji{font-size:1.75rem}.panel-scope .admin-card .admin-cover-char.role-char{background:linear-gradient(135deg,var(--ok),var(--primary))}.panel-scope .admin-card .admin-cover-char{font-size:1.25rem}.panel-scope .admin-card .item-info{grid-row:1;grid-column:2;align-self:end;min-width:0}.panel-scope .admin-card .item-info-top{display:flex;align-items:center;min-width:0}.panel-scope .admin-card .item-card-footer{grid-row:2;grid-column:2;display:flex;align-items:center;gap:8px;padding:0;margin:0;border-top:none;flex:none}.panel-scope .admin-card .admin-foot-meta{flex:1;min-width:0;align-self:center;font-size:.82rem;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.panel-scope .admin-card .role-chip{flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.panel-scope .admin-card .admin-foot-roles{display:flex;align-items:center;gap:4px;flex:none}.panel-scope .role-chip-more{background:var(--neu-inset);color:var(--text-muted)}.panel-scope .admin-card .item-menu-trigger{width:22px;height:22px;min-height:22px;font-size:1rem}.panel-scope .admin-cover-char{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:700;color:#fff;background:linear-gradient(135deg,var(--primary),var(--primary-2))}.panel-scope .admin-cover-char.role-char{background:linear-gradient(135deg,var(--ok),var(--primary))}.panel-scope .admin-foot-meta{flex:1;min-width:0;align-self:center;font-size:.78rem;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.panel-scope .admin-perm-card{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;margin-bottom:8px;background:var(--neu-bg);border:none;border-left:3px solid transparent;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-raise-xs);cursor:pointer;transition:box-shadow .15s ease}.panel-scope .admin-perm-card:hover{background:var(--neu-inset)}.panel-scope .admin-perm-card:active{box-shadow:var(--neu-press-xs)}.panel-scope .admin-perm-card:has(input:checked){border-left-color:var(--primary)}.panel-scope .admin-perm-card .apc-main{display:flex;align-items:center;gap:8px;min-width:0;flex:1}.panel-scope .admin-perm-card .apc-main input{width:18px;height:18px;flex:none}.panel-scope .admin-perm-card .apc-text{min-width:0}.panel-scope .admin-perm-card .apc-text small{display:block;color:var(--text-muted);font-size:.7rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.skv-body .rd-hint{color:var(--text-muted);font-size:.8rem}.skv-body .rd-meta-edit{display:flex;flex-direction:column;gap:6px;margin:0 0 10px}.skv-body .rd-meta-name,.skv-body .rd-meta-desc{width:100%;box-sizing:border-box;padding:6px 10px;font:inherit;color:var(--text-1)}.skv-body .rd-meta-name{font-size:1.15rem;font-weight:700}.skv-body .rd-meta-desc{font-size:.9rem;resize:vertical}.mcp-binding-editor{display:flex;flex-direction:column;gap:12px;margin:0 0 10px}.mcp-binding-editor .mcp-section{display:flex;flex-direction:column;gap:4px}.mcp-binding-editor .mcp-section-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.mcp-binding-editor .mcp-bind-row{display:flex;align-items:center;gap:6px;padding:6px 8px;border:none;border-radius:var(--neu-radius-sub);background:var(--neu-bg);box-shadow:var(--neu-raise-xs);margin-top:4px}.mcp-binding-editor .mcp-bind-text{flex:1 1 auto;min-width:0;line-height:1.5;overflow-wrap:anywhere}.mcp-binding-editor .mcp-bind-row code{font-size:.78rem;color:var(--text-muted)}.mcp-binding-editor .mcp-bind-head{display:block}.mcp-binding-editor .mcp-bind-desc{display:block;min-width:0;overflow-wrap:anywhere}.mcp-binding-editor .mcp-bind-desc p{margin:.15em 0}.mcp-binding-editor .mcp-bind-desc>:first-child{margin-top:2px}.mcp-binding-editor .mcp-bind-desc>:last-child{margin-bottom:0}.mcp-binding-editor .rd-ref-jump{background:none;border:none;padding:0;margin:0;font:inherit;cursor:pointer}.mcp-binding-editor .rd-ref-jump:hover code,.mcp-binding-editor .rd-ref-jump:focus-visible code{text-decoration:underline;text-decoration-style:dashed;text-underline-offset:3px}.skv-body .rd-desc-md{min-width:0;overflow-wrap:anywhere}.skv-body .rd-desc-md>:first-child{margin-top:0}.skv-body .rd-desc-md>:last-child{margin-bottom:0}.mcp-binding-editor .mcp-bind-ver{width:4.5em;padding:2px 6px;font-size:.78rem}.mcp-binding-editor .mcp-bind-add{display:flex;align-items:center;gap:6px;min-width:0;margin-top:4px}.mcp-binding-editor .mcp-bind-ref{flex:1 1 auto;min-width:0;max-width:18em;box-sizing:border-box;padding:4px 7px;font-size:.8rem}.mcp-binding-editor .link-btn{font-size:.8rem;align-self:flex-start}.skv-body .rd-meta-line{margin:0 0 8px}.skv-body .rd-meta-btn{background:none;border:none;padding:0;font:inherit;font-weight:700;color:var(--primary);cursor:pointer;text-align:left;line-height:1.4}.skv-body .rd-meta-btn:hover{text-decoration:underline}.skv-body .rd-meta-btn .rd-meta-go{font-weight:400;margin-left:2px;font-size:.9em;opacity:.7}.skv-body h1.rd-tool-work-link{cursor:pointer}.skv-body h1.rd-tool-work-link:hover{text-decoration:underline;text-decoration-style:dashed;text-underline-offset:4px}.skv-body .rd-tool-work-row{font-weight:400}.skv-body .rd-perm.rd-perm-inherit{opacity:.72}.skv-body .rd-perm .rd-perm-children .rd-perm.rd-perm-inherit{opacity:1}.skv-body .rd-inherit-badge{flex:none;padding:1px 7px;border-radius:999px;font-size:.65rem;line-height:1.6;color:var(--text-muted);background:var(--neu-inset)}.skv-body .rd-filter-table{border:none;border-radius:var(--neu-radius-sub);background:var(--neu-bg);box-shadow:var(--neu-raise-xs);overflow:hidden;margin:4px 0 10px}.skv-body .rd-filter-row{display:grid;grid-template-columns:1fr 1fr 2fr auto;border-bottom:1px solid var(--border-soft, #edf2f7)}.skv-body .rd-filter-row:last-child{border-bottom:none}.skv-body .rd-filter-head{background:none;font-weight:600;font-size:.8rem;color:var(--text-1)}.skv-body .rd-filter-head span{padding:7px 10px}.skv-body .rd-filter-row select,.skv-body .rd-filter-row input[type=text],.skv-body .rd-filter-row input[type=date],.skv-body .rd-filter-row input[type=number]{box-sizing:border-box;min-width:0;margin:6px 8px;padding:4px 8px;font:inherit;font-size:.85rem;color:var(--text-1)}.skv-body .rd-filter-row .rd-filter-del{margin:6px 8px;padding:0 6px;align-self:center;background:none;border:none;color:var(--text-muted);font:inherit;font-size:1rem;line-height:1.4;cursor:pointer}.skv-body .rd-filter-row .rd-filter-del:hover{color:var(--danger, #d33)}.skv-body .rd-filter-row .rd-filter-del:disabled{cursor:default;opacity:.4}.skv-body .rd-filter-tools{display:flex;flex-wrap:wrap;align-items:center;gap:10px 16px;font-size:.85rem;color:var(--text-1);margin:0 0 10px}.skv-body .rd-filter-tools label{display:inline-flex;align-items:center;gap:6px}.skv-body .rd-filter-tools select,.skv-body .rd-filter-tools input[type=number]{padding:3px 8px;font:inherit;font-size:.85rem;color:var(--text-1)}.skv-body .rd-filter-tools input[type=number]{width:88px}.skv-body .rd-filter-tools .rd-filter-add{padding:3px 10px;font:inherit;font-size:.85rem;cursor:pointer;color:var(--primary);background:var(--neu-bg);border:none;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-raise-xs)}.skv-body .rd-filter-tools .rd-filter-add:active{box-shadow:var(--neu-press-xs);background:var(--neu-inset)}.skv-body .rd-filter-tools .rd-filter-hint{font-size:.75rem;color:var(--text-muted)}.skv-body .rd-list{list-style:none;padding:0;margin:0}.skv-body .rd-cat{font-weight:600;font-size:.85rem;color:var(--text-1);list-style:none;padding:8px 0 2px}.skv-body h1 .rd-open-profile{background:none;border:none;padding:0;font:inherit;color:var(--primary);cursor:pointer;text-align:left}.skv-body h1 .rd-open-profile:hover{text-decoration:underline}.skv-body .rd-perms{list-style:none;padding:0;margin:0 0 4px}.skv-body .rd-perm{display:flex;align-items:center;gap:8px;padding:7px 0;border-bottom:1px solid var(--border-soft)}.skv-body .rd-perm.rd-perm-parent{flex-wrap:wrap}.skv-body .rd-perm .rd-perm-head{display:flex;align-items:center;gap:4px;flex:0 1 auto;min-width:0}.skv-body .rd-perm .rd-perm-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:0 1 auto;min-width:0}.skv-body .rd-perm input{width:18px;height:18px;flex:none}.skv-body.adm-detail .rd-perm input[type=checkbox],.skv-body.adm-detail .rd-perm input[type=radio]{accent-color:auto}.skv-body.adm-detail .rd-perm input[type=checkbox]{-webkit-appearance:none;-moz-appearance:none;appearance:none;box-sizing:border-box;margin:0;padding:0;width:22px;height:22px;min-width:22px;min-height:22px;border:2px solid var(--text-muted);border-radius:50%;background:var(--neu-inset)}.skv-body.adm-detail .rd-perm input[type=checkbox]:checked{border-color:var(--primary);background:radial-gradient(circle,#fff 0 4px,var(--primary) 5px)}.skv-body .rd-perm-name{background:none;border:none;padding:0;font:inherit;font-size:.92rem;color:var(--primary);cursor:pointer;text-align:left}.skv-body .rd-perm-name:hover{text-decoration:underline}.skv-body .rd-perm-key{flex:1;min-width:0;color:var(--text-muted);font-size:.72rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.skv-body .rd-perm .perm-scope{margin-left:auto;font-size:.78rem;min-height:30px;padding:2px 6px;flex:none}.skv-body .rd-perm-toggle{background:none;border:none;padding:0;font-size:.72rem;color:var(--primary);cursor:pointer;flex:none;line-height:1.4}.skv-body .rd-perm-toggle:hover{text-decoration:underline}.skv-body .rd-perm-toggle .rd-perm-count{font-size:.68rem;margin-left:1px}.skv-body .rd-perm .rd-perm-children{flex:1 100%;margin:0 0 2px 26px;padding:0;border-left:2px solid var(--border-soft)}.skv-body .rd-perm .rd-perm-children .rd-perm-sub{padding:5px 0 5px 12px;border-bottom:1px dashed var(--border-soft)}.skv-body .rd-perm .rd-perm-children .rd-perm-sub:last-child{border-bottom:none}.skv-body .rd-perm .rd-perm-children .rd-perm-sub .rd-perm-name{font-size:.85rem}.panel-scope .role-chip-locked{background:var(--neu-inset);color:var(--text-muted)}.skv-body.adm-detail .skv-md{max-width:none;margin:0}.perm-class-picker{margin:0 0 14px;padding:10px 12px;border:none;border-radius:var(--neu-radius-sub);background:var(--neu-bg);box-shadow:var(--neu-raise-xs)}.perm-class-picker .pcp-title{margin:0 0 8px;font-size:.78rem;color:var(--text-muted)}.perm-class-picker .pcp-options{display:flex;flex-wrap:wrap;gap:8px}.perm-class-picker .pcp-option{border:none;border-radius:var(--neu-radius-sub);background:var(--neu-bg);box-shadow:var(--neu-raise-xs);padding:6px 12px;font-size:.82rem;cursor:pointer}.perm-class-picker .pcp-option:hover:not(:disabled){color:var(--primary);filter:brightness(1.04)}.perm-class-picker .pcp-option:active:not(:disabled){box-shadow:var(--neu-press-xs)}.perm-class-picker .pcp-option.selected{background:var(--neu-accent-grad);color:var(--text-1);font-weight:600}.perm-class-picker .pcp-option:disabled{opacity:.55;cursor:not-allowed}.panel-scope.adm-sublist{background:transparent;padding:16px 14px 24px}.panel-scope .adm-sublist-count{margin:0 0 10px;font-size:.8rem;color:var(--text-muted)}.auth-card{background:var(--neu-bg);border-radius:12px;box-shadow:0 4px 20px #00000014;padding:32px 28px;width:340px;max-width:calc(100vw - 32px)}.auth-card h1{font-size:22px;text-align:center;margin-bottom:20px}.auth-card label{display:block;font-size:13px;color:var(--text-2);margin:14px 0 6px}.auth-card input{width:100%;min-height:44px;padding:10px 12px;border:1px solid #d9d9d9;border-radius:6px;font-size:16px;background:var(--neu-inset);color:inherit}.auth-card input:focus{outline:none;border-color:var(--primary)}.auth-card input:focus-visible{outline:2px solid var(--primary);outline-offset:1px}.auth-card button[type=submit]{width:100%;min-height:44px;margin-top:22px;padding:0 16px;border:none;border-radius:6px;background:var(--primary);color:#fff;font-size:15px;font-weight:600;cursor:pointer}.auth-card button[type=submit]:disabled{background:#9cc3e8;cursor:not-allowed}.auth-card button[type=submit]:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.auth-msg{min-height:20px;margin-top:12px;font-size:13px;text-align:center;color:var(--danger)}.auth-msg.success{color:var(--ok)}.auth-msg:empty{display:none}.auth-captcha{min-height:20px;margin-top:8px;font-size:12px;text-align:center;color:var(--text-muted)}.auth-captcha.error{color:var(--danger)}.auth-captcha:empty{display:none}.auth-fallback{margin-top:12px;padding:10px 12px;background:#fff7e6;border:1px solid #ffe7ba;border-radius:6px;font-size:13px;color:#874d00;text-align:center}.auth-fallback a{display:inline-block;margin-top:6px;padding:8px 16px;background:var(--primary);color:#fff;text-decoration:none;border-radius:6px;font-weight:600;min-height:36px}.auth-fallback a:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.auth-switch{margin-top:16px;font-size:13px;text-align:center;color:var(--text-3)}.auth-switch a{display:inline-flex;align-items:center;min-height:44px;padding:0 6px;color:var(--primary);text-decoration:none}.auth-switch a:focus-visible{outline:2px solid var(--primary);outline-offset:2px;border-radius:4px}.pv-body .auth-card{margin:40px auto}.auth-code-row{display:flex;align-items:stretch;gap:8px;margin-bottom:14px}.auth-code-row input{flex:1 1 auto;min-width:0}.auth-code-btn{flex:0 0 auto;width:auto;min-width:88px;margin:0;padding:0 14px;font-size:13px;white-space:nowrap;background:transparent;color:var(--primary);border:1px solid var(--border-1);border-radius:8px;cursor:pointer;min-height:44px}.auth-code-btn:disabled{color:var(--text-3);cursor:not-allowed}.feat-hero-host{width:100%}.feat-hero-host[hidden]{display:none}.feat-hero{position:relative;margin:0 0 12px;border-radius:var(--neu-radius-card);background:var(--neu-bg);box-shadow:var(--neu-raise-xs);overflow:hidden;-webkit-tap-highlight-color:transparent;touch-action:pan-y;-webkit-user-select:none;user-select:none}.feat-hero-viewport{overflow:hidden}.feat-hero-track{display:flex;width:100%;will-change:transform;transform:translateZ(0)}.feat-hero-slide{position:relative;flex:0 0 100%;min-width:100%;box-sizing:border-box;min-height:198px;padding:20px 22px 30px;display:flex;flex-direction:column;justify-content:flex-end;cursor:grab;isolation:isolate;outline:none}.feat-hero.is-dragging,.feat-hero.is-dragging .feat-hero-slide{cursor:grabbing}.feat-hero-slide:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;background:radial-gradient(115% 135% at 100% 0%,var(--primary-tint),transparent 58%)}.feat-hero-slide:focus-visible{outline:2px solid var(--primary);outline-offset:-2px;border-radius:var(--neu-radius-card)}.feat-hero-media{position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;overflow:hidden;pointer-events:none}.feat-hero-media img{width:100%;height:100%;object-fit:cover;display:block}.feat-hero-veil{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;background:linear-gradient(to top,var(--neu-bg) 4%,transparent 62%),linear-gradient(100deg,var(--neu-bg) 30%,transparent 76%)}.feat-hero-body{position:relative;display:flex;flex-direction:column;min-width:0;max-width:760px}.feat-hero-ghost{position:absolute;top:4px;right:10px;z-index:0;font-size:72px;line-height:1;opacity:.16;pointer-events:none;-webkit-user-select:none;user-select:none;transform:rotate(-6deg)}.feat-hero-label{font-size:10px;font-weight:700;letter-spacing:.14em;text-transform:uppercase;color:var(--primary)}.feat-hero-title{margin:5px 0 0;font-size:1.3rem;font-weight:700;line-height:1.22;color:var(--text-1);word-break:break-word;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.feat-hero-desc{margin:6px 0 0;max-width:46ch;font-size:.82rem;line-height:1.5;color:var(--text-2);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.feat-hero-row{display:flex;align-items:center;gap:10px;margin-top:12px;min-width:0}.feat-hero-icon{flex:0 0 auto;width:34px;height:34px;border-radius:10px;background:var(--neu-inset);box-shadow:var(--neu-press-xs);display:grid;place-items:center;overflow:hidden;font-size:17px;line-height:1}.feat-hero-icon img{width:100%;height:100%;object-fit:cover;display:block}.feat-hero-icon .avatar{background:transparent}.feat-hero-info{flex:1 1 auto;min-width:0}.feat-hero-name,.feat-hero-meta{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.feat-hero-name{font-size:.78rem;font-weight:600;color:var(--text-1)}.feat-hero-meta{margin-top:1px;font-size:.7rem;color:var(--text-3)}.feat-hero-cta{flex:0 0 auto;padding:6px 16px;border-radius:var(--neu-radius-pill);background:var(--neu-bg);box-shadow:var(--neu-raise-xs);color:var(--primary);font-size:.76rem;font-weight:700;-webkit-tap-highlight-color:transparent}.feat-hero-slide:active .feat-hero-cta{box-shadow:var(--neu-press-xs)}.feat-hero-dots{position:absolute;left:0;right:0;bottom:7px;z-index:3;display:flex;justify-content:center;align-items:center;gap:2px;pointer-events:none}.feat-hero-dot{position:relative;width:18px;height:18px;min-width:0;min-height:0;padding:0;border:none;background:none;display:grid;place-items:center;cursor:pointer;pointer-events:auto;-webkit-tap-highlight-color:transparent}.feat-hero-dot:before{content:"";display:block;width:6px;height:6px;border-radius:var(--neu-radius-pill);background:var(--text-muted);opacity:.45;transition:opacity .25s ease}.feat-hero-dot:after{content:"";position:absolute;top:50%;left:50%;width:16px;height:6px;margin:-3px 0 0 -8px;border-radius:var(--neu-radius-pill);background:var(--primary);opacity:0;transform:scaleX(0);transition:transform .25s ease,opacity .25s ease;pointer-events:none}.feat-hero-dot.active:before{opacity:0}.feat-hero-dot.active:after{opacity:1;transform:scaleX(1)}.feat-hero-dot:focus-visible{outline:2px solid var(--primary);outline-offset:0;border-radius:var(--neu-radius-pill)}@media (max-width: 700px){.feat-hero-media{opacity:.62}.feat-hero-veil{background:linear-gradient(to bottom,var(--neu-bg) 2%,transparent 44%),linear-gradient(to top,var(--neu-bg) 4%,transparent 58%),linear-gradient(100deg,var(--neu-bg) 32%,transparent 84%)}}@media (min-width: 900px){.feat-hero-title{font-size:1.5rem}.feat-hero-ghost{font-size:104px;top:8px;right:26px;opacity:.18}}@media (max-width: 480px){.feat-hero-slide{min-height:166px;padding:16px 14px 26px}.feat-hero-title{font-size:1.12rem}.feat-hero-desc{font-size:.78rem}.feat-hero-cta{padding:6px 13px}}@media (prefers-reduced-motion: reduce){.feat-hero-track{transition:none}}.link-btn{min-height:44px;padding:0 14px;cursor:pointer;font-size:.85rem;display:inline-flex;align-items:center;justify-content:center}.link-btn:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.agent-proxy-field{margin-bottom:10px}.agent-proxy-field label{display:block;font-size:.78rem;color:var(--text-3);margin-bottom:4px}.agent-proxy-field input,.agent-proxy-field textarea{width:100%;box-sizing:border-box;font:inherit;color:var(--text-1);padding:9px 10px;outline:none}.agent-proxy-field textarea{resize:vertical;min-height:88px}.set-card{padding:14px 12px 12px;margin-bottom:12px}.set-card:last-child{margin-bottom:0}.set-card-head{display:flex;align-items:center;gap:10px;margin-bottom:10px}.set-card-ico{flex:none;width:32px;height:32px;border-radius:10px;font-size:1rem;line-height:1;display:flex;align-items:center;justify-content:center}.set-card-title{font-size:.9rem;font-weight:700;color:var(--text-1, #2d3748);line-height:1.25}.set-card-hint{margin-top:2px;font-size:.72rem;color:var(--text-3, #718096);line-height:1.35}.set-card .agent-proxy-field{margin-bottom:8px}.set-card .agent-proxy-field input,.set-card .agent-proxy-field select{min-height:44px}.set-card select{width:100%;box-sizing:border-box;min-height:44px;padding:9px 34px 9px 10px;font:inherit;font-size:16px;color:var(--text-1, #2d3748);outline:none}.items-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:0}.inf-scroll-sentinel{grid-column:1 / -1}.inf-scroll-end{text-align:center;color:var(--text-muted);font-size:.78rem;padding:18px 0}.inf-scroll-sentinel [data-inf-retry]{cursor:pointer}.item-card{background:var(--neu-bg);cursor:pointer;display:flex;flex-direction:row;flex-wrap:wrap;align-items:stretch;padding:12px;gap:8px 12px;min-height:120px;-webkit-tap-highlight-color:transparent;position:relative;border-left:3px solid transparent;border-bottom:1px solid var(--hairline);content-visibility:auto;contain-intrinsic-size:auto 122px}.card-badges{position:absolute;top:8px;right:8px;z-index:2;display:flex;flex-direction:column;align-items:flex-end;gap:4px}.card-badge{background:#5a67d84d;color:#fff;font-size:.7rem;padding:2px 8px;border-radius:4px;line-height:1.4;white-space:nowrap}.card-badge-pinned{background:#dd6b204d}.card-badge-approved{background:#16a34a4d}.card-badge-pending{background:#5a67d84d}.card-badge-hidden{background:#7180964d}.card-badge-locked{background:#c530304d}.card-badge-banned{background:#dc50504d}.card-badge-recycled{background:#2d37484d}.card-badge-forked{background:#ca8a044d}.card-badge-delivery-adopted{background:#2a7a7c4d}.card-badge-delivery-published{background:#2767494d}.card-badge-visible-to{background:#0284c74d}.item-cover-wrap{flex:none;width:96px;height:96px;border:2px solid var(--primary, #667eea);border-radius:10px;overflow:hidden;background:var(--neu-bg);display:flex;align-items:center;justify-content:center}.item-cover-wrap.no-image-placeholder{background:var(--neu-inset);border-color:var(--border);border-style:dashed;color:var(--text-muted)}.item-cover{width:100%;height:100%;object-fit:cover;display:block}.item-cover-placeholder{font-size:42px;line-height:1;-webkit-user-select:none;user-select:none}.item-info{flex:1;min-width:0;display:flex;flex-direction:column;justify-content:space-between;gap:4px}.item-info-top{min-height:0}.item-name{font-size:1rem;font-weight:600;color:var(--primary, #667eea);line-height:1.3;margin-bottom:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.item-name:hover{text-decoration:underline}.item-id-badge{font-size:.72rem;font-weight:400;color:var(--text-muted);margin-left:6px}.item-excerpt{font-size:.82rem;color:var(--text-3);line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin-bottom:2px}.item-card-footer{flex:1 0 100%;display:flex;align-items:center;gap:8px;font-size:.75rem;color:var(--text-3);margin-top:0;cursor:default}.item-author{display:flex;align-items:center;gap:4px;min-width:0}.item-author .avatar{width:18px;height:18px;font-size:.7rem;flex:none;border-radius:6px;box-shadow:var(--neu-press-xs)}.item-author a{color:var(--text-1);text-decoration:none;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:140px}.item-author a:hover{color:var(--primary-2)}.item-favorite-star{flex:0 0 auto;padding:0;margin:0 4px;min-height:0;background:none;border:none;cursor:pointer;color:var(--text-muted);transition:color .2s ease,transform .2s ease;display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;line-height:1;align-self:center}.item-favorite-star svg{width:16px;height:16px;display:block}.item-favorite-star:hover{color:#fbbf24;transform:scale(1.15)}.item-favorite-star.favorited{color:#fbbf24}.item-favorite-star:active{transform:scale(.95)}.item-stats{margin-left:auto;display:flex;gap:12px;color:var(--text-3);flex:none}.item-stat{display:inline-flex;align-items:center;gap:3px;font-variant-numeric:tabular-nums}.item-stat svg{width:13px;height:13px;fill:currentColor}.item-stat em{font-style:normal}.item-stat.link{cursor:pointer}.item-stat.link:hover{color:var(--primary, #667eea)}.item-menu{flex:none;position:relative;margin-left:4px}.item-menu-trigger{width:22px;height:22px;min-height:22px;border:none;background:transparent;color:var(--text-muted);font-size:1rem;line-height:1;cursor:pointer;border-radius:50%;padding:0;display:flex;align-items:center;justify-content:center;letter-spacing:1px;transition:background .15s,color .15s}.item-menu-trigger:hover{background:var(--neu-inset);color:var(--primary, #667eea)}.item-menu-popup{display:none;position:absolute;top:calc(100% + 4px);bottom:auto;right:0;width:max-content;min-width:72px;background:var(--neu-bg);border:1px solid var(--border-soft);border-radius:8px;padding:4px 0;z-index:20}.item-menu-popup.open-up{top:auto;bottom:calc(100% + 4px)}.item-menu-popup.open{display:block}.item-card.menu-open{content-visibility:visible;transform:none!important;transition:none!important}.item-admin-actions{display:flex;flex-direction:column}.item-admin-actions button{width:100%;text-align:left;padding:8px 14px;font-size:.85rem;border:none;background:transparent;color:var(--text-1);cursor:pointer;border-radius:0;min-height:36px}.item-admin-actions button:hover{background:var(--neu-bg)}.item-admin-actions button.btn-danger{color:var(--danger)}.item-admin-actions button.btn-danger:hover{background:var(--danger-tint)}.item-tags{display:flex;gap:4px;flex-wrap:wrap}.items-grid .empty,.items-grid .loading{text-align:center;color:var(--text-3);padding:40px 20px;grid-column:1 / -1}.item-card{background:var(--neu-bg)!important;border:none!important;border-radius:var(--neu-radius-sub)!important;box-shadow:var(--neu-raise-sm)!important;transition:transform .15s ease}.item-card:active{box-shadow:var(--neu-press-sm)!important;transform:scale(.99);background:var(--neu-bg)!important}.giv{background:var(--neu-bg);color:var(--text-1);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.giv-img{width:100%;min-height:180px;max-height:420px;background:var(--neu-inset);color:var(--text-muted);font-size:14px;display:flex;align-items:center;justify-content:center;overflow:hidden}.giv-img.giv-emoji{font-size:72px;line-height:1;color:var(--text-3)}.giv-img img{width:100%;height:100%;max-height:420px;object-fit:contain;display:block}.giv-img.pending{color:var(--text-3);font-size:15px}.giv-imgwrap{position:relative}.giv-play{position:absolute;left:12px;bottom:12px;width:52px;height:52px;border-radius:50%;background:#00000080;display:flex;align-items:center;justify-content:center;pointer-events:none;transition:background .15s}.giv-imgwrap:active .giv-play{background:#000000b8}.giv-play svg{width:26px;height:26px;fill:#fff}.giv-baracts{display:flex;align-items:center;gap:2px;flex:none}.giv-bact{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-width:38px;padding:2px;border:none;background:transparent;color:var(--text-1);cursor:pointer;-webkit-tap-highlight-color:transparent;transition:color .18s}.giv-bact:hover{color:var(--text-1)}.giv-bact svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:fill .18s;flex:none}.giv-bact.active svg{fill:currentColor}.giv-bact.giv-like.active{color:var(--danger)}.giv-bact.giv-fav.active{color:#d69e2e}.giv-bact .giv-count{font-size:10px;font-weight:600;line-height:1.2;color:var(--text-muted)}.giv-bact.active .giv-count{color:currentColor}.giv-bact .giv-count:empty{display:none}.giv-body{padding:14px 16px}.giv-name{font-size:20px;font-weight:700;line-height:1.3;overflow-wrap:anywhere}.giv-ctime-btn{border:none;background:transparent;padding:0;font:inherit;font-family:inherit;color:var(--primary);cursor:pointer;-webkit-tap-highlight-color:transparent;transition:color .15s}.giv-ctime-btn:active{color:var(--primary-2)}.giv-id-badge{font-size:12px;font-weight:400;color:var(--text-muted);margin-left:8px}.giv-chips{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0;align-items:center}.giv-forked-line{margin:-4px 0 8px}.giv-forked-from{border:none;background:transparent;padding:0;font:inherit;font-family:inherit;font-size:12px;color:#805ad5;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:color .15s}.giv-forked-from:active{color:#553c9a}.giv-desc{font-size:15px;line-height:1.75;word-break:break-word;word-wrap:break-word;color:var(--text-1);margin:8px 0;font-family:-apple-system,BlinkMacSystemFont,PingFang SC,Segoe UI,Microsoft YaHei,sans-serif}.giv-desc-empty{min-height:20px}.giv-desc-placeholder{color:var(--text-muted);font-size:14px}.giv-outline{padding:10px 8px 20px}.giv-outline-item{position:relative;display:block;width:100%;text-align:left;border:0;background:none;min-height:40px;padding:9px 14px;border-radius:10px;font:inherit;font-size:14.5px;color:var(--text-1);cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-tap-highlight-color:transparent;transition:background .15s,color .15s}.giv-outline-item:hover{background:var(--primary-tint)}.giv-outline-item:active{opacity:.75}.giv-outline-item[data-level="1"]{font-weight:600}.giv-outline-item[data-level="3"],.giv-outline-item[data-level="4"]{font-size:13.5px;color:var(--text-1)}.giv-outline-sep{height:1px;margin:6px 10px;background:var(--hairline)}.giv-outline-item.cur{background:var(--primary-tint);color:var(--primary);font-weight:600}.giv-outline-item.cur:before{content:"";position:absolute;left:4px;top:50%;width:3px;height:16px;transform:translateY(-50%);border-radius:2px;background:var(--primary)}.giv-mdtoc{margin:10px 0 14px;padding:10px 12px 8px;border:1px solid var(--primary-tint);border-radius:12px;background:var(--neu-bg)}.giv-mdtoc-title{font-size:12.5px;font-weight:600;color:var(--primary);letter-spacing:.08em;margin:0 0 4px}.giv-mdtoc .giv-mdtoc-item{display:block;width:100%;text-align:left;border:0;background:none;padding:7px 12px;border-radius:8px;font:inherit;font-size:14px;color:var(--text-1);cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-tap-highlight-color:transparent;transition:background .15s}.giv-mdtoc .giv-mdtoc-item:hover{background:var(--primary-tint)}.giv-mdtoc .giv-mdtoc-item:active{opacity:.75}.giv-desc ::selection{background:var(--tint-soak)}.giv-desc h1,.giv-desc h2,.giv-desc h3,.giv-desc h4,.giv-desc h5,.giv-desc h6{margin:1.5em 0 .65em;font-weight:700;line-height:1.35;color:var(--text-1)}.giv-desc h1{font-size:1.65em;padding-bottom:.35em;border-bottom:2px solid transparent;border-image:linear-gradient(90deg,var(--primary),var(--primary-tint)) 1}.giv-desc h2{font-size:1.35em;padding-left:.55em;position:relative}.giv-desc h2:before{content:"";position:absolute;left:0;top:.18em;bottom:.18em;width:4px;border-radius:2px;background:linear-gradient(180deg,var(--primary),var(--primary-2))}.giv-desc h3{font-size:1.18em;color:var(--primary)}.giv-desc h4{font-size:1.05em;color:var(--text-1)}.giv-desc h5{font-size:.95em;color:var(--text-1)}.giv-desc h6{font-size:.9em;color:var(--text-3);font-weight:600}.giv-desc h1:first-child,.giv-desc h2:first-child,.giv-desc h3:first-child{margin-top:0}.giv-desc p{margin:.85em 0}.giv-desc ul,.giv-desc ol{margin:.85em 0;padding-left:1.6em}.giv-desc li{margin:.35em 0}.giv-desc li::marker{color:var(--primary);font-weight:600}.giv-desc li>ul,.giv-desc li>ol{margin:.2em 0}.giv-desc li input[type=checkbox]{margin-right:.45em;accent-color:var(--primary)}.giv-desc code{padding:.15em .45em;margin:0;font-size:.88em;background:var(--primary-tint);color:var(--primary);border-radius:5px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,monospace}.giv-desc pre{margin:1em 0;padding:14px 16px;overflow-x:auto;background:#1e2a3a;border-radius:10px;line-height:1.55;box-shadow:0 1px 3px #0f172a1f}.giv-desc pre code{padding:0;background:transparent;color:#dbe7f5;border-radius:0;font-size:.85rem}.giv-desc .md-table-wrap{margin:1em 0;overflow-x:auto;font-size:.92em;border:1px solid var(--border-soft);border-radius:10px}.giv-desc .md-table-wrap table{margin:0;width:100%;border-collapse:separate;border-spacing:0}.giv-desc th,.giv-desc td{padding:8px 13px;text-align:left;border-bottom:1px solid var(--hairline)}.giv-desc th{background:var(--stripe);color:var(--primary);font-weight:600;white-space:nowrap}.giv-desc tr:last-child td{border-bottom:0}.giv-desc tbody tr:nth-child(2n) td{background:var(--stripe)}.giv-desc blockquote{margin:1em 0;padding:.55em 1em;color:var(--text-1);border-left:4px solid var(--primary);background:var(--neu-bg);border-radius:0 8px 8px 0}.giv-desc blockquote>:first-child{margin-top:0}.giv-desc blockquote>:last-child{margin-bottom:0}.giv-desc a{color:var(--primary);text-decoration:none;font-weight:500;border-bottom:1px solid var(--tint-edge);transition:color .15s,border-color .15s}.giv-desc a:hover{color:var(--primary-2);border-bottom-color:var(--primary-2)}.giv-desc hr{margin:1.6em 0;border:0;height:2px;border-radius:1px;background:linear-gradient(90deg,transparent,var(--primary-tint) 20%,var(--primary-tint) 80%,transparent)}.giv-desc img{max-width:100%;height:auto;border-radius:8px;box-shadow:0 1px 4px #0f172a1a}.giv-desc .giv-mgrid{display:grid;gap:6px;margin:1em 0}.giv-desc .giv-mgrid-1{grid-template-columns:1fr}.giv-desc .giv-mgrid-2{grid-template-columns:1fr 1fr}.giv-desc .giv-mgrid-3{grid-template-columns:1fr 1fr 1fr}.giv-desc .giv-mgrid-1>img{max-width:100%;max-height:420px;justify-self:center;cursor:zoom-in}.giv-desc .giv-mgrid-2>img,.giv-desc .giv-mgrid-3>img{width:100%;aspect-ratio:1/1;object-fit:cover;cursor:zoom-in}.giv-desc .giv-mgrid-1>video{width:100%;max-height:420px;background:#000;display:block;border-radius:12px}.giv-desc audio.md-audio{width:100%;height:40px;margin:4px 0;display:block}.giv-desc strong{font-weight:600;color:var(--text-1)}.giv-desc del{color:var(--text-3)}.giv-desc kbd{padding:.1em .4em;font-size:.85em;color:var(--primary);background:var(--neu-bg);border:1px solid var(--primary-tint);border-bottom-width:2px;border-radius:5px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.giv-ctime{margin-top:10px;font-size:12px;color:var(--text-muted)}.giv-topauthor{display:flex;align-items:center;gap:8px;min-width:0;max-width:62%;text-decoration:none;flex:none;-webkit-tap-highlight-color:transparent}.giv-topauthor .avatar{width:30px;height:30px;font-size:15px;border-radius:9px;box-shadow:var(--neu-press-xs)}.giv-topauthor .avatar.avatar-emoji{font-size:19px}.giv-panel-empty{padding:26px 16px;text-align:center;color:var(--text-muted);font-size:14px}.giv-panel-section{padding:14px 16px 4px}.giv-panel-title{font-size:13px;font-weight:700;color:var(--text-1);margin-bottom:8px}.giv-entry{background:var(--neu-bg);border:1px solid var(--border-soft);border-radius:8px;padding:6px 10px;margin-bottom:6px;font-family:inherit;-webkit-tap-highlight-color:transparent}.giv-entry-strip{display:flex;align-items:center;gap:6px;height:22px;overflow:hidden;white-space:nowrap}.giv-entry.clickable-strip .giv-entry-strip{cursor:pointer}.giv-entry.clickable-strip .giv-entry-strip:active{opacity:.7}.giv-entry.clickable-card{cursor:pointer}.giv-entry.clickable-card:active{background:var(--neu-inset)}.giv-entry-menu{flex:none;position:relative;margin-left:4px}.giv-entry-menu-trigger{width:22px;height:22px;min-height:22px;border:none;background:transparent;color:var(--text-muted);font-size:1rem;line-height:1;cursor:pointer;border-radius:50%;padding:0;display:flex;align-items:center;justify-content:center;letter-spacing:1px;transition:background .15s,color .15s}.giv-entry-menu-popup{display:none;position:absolute;top:calc(100% + 4px);bottom:auto;right:0;width:max-content;min-width:72px;background:var(--neu-bg);border:1px solid var(--border);border-radius:8px;box-shadow:0 6px 20px #0000001f;padding:4px 0;z-index:20}.giv-entry-menu-popup.open-up{top:auto;bottom:calc(100% + 4px)}.giv-entry-menu-popup.open{display:block}.giv-entry.menu-open{z-index:30}.giv-entry-menu-item{display:block;width:100%;text-align:left;border:none;background:transparent;color:var(--text-1);font-size:13px;padding:8px 14px;cursor:pointer;font-family:inherit;-webkit-tap-highlight-color:transparent;white-space:nowrap}.giv-entry-menu-item:active{background:var(--neu-inset)}.giv-vlist{display:flex;flex-direction:column}.giv-vlist .giv-vcard{border-radius:0;border-left:none;border-right:none;border-bottom:none;border-top:1px solid var(--hairline)}.giv-vlist .giv-vcard:first-child{border-top:none}.giv-vlist .giv-vcard:last-child{border-bottom:1px solid var(--hairline)}.giv-vcard{display:flex;align-items:stretch;gap:10px;background:var(--neu-bg);border:1px solid var(--border);border-radius:10px;padding:10px 12px;font-family:inherit;-webkit-tap-highlight-color:transparent}.giv-vcard.clickable-card{cursor:pointer}.giv-vcard-avatar{flex:none;width:48px;height:48px;display:flex;align-items:center;justify-content:center;background:var(--primary-tint);border-radius:10px}.giv-vcard-avatar.cur{background:var(--ok-tint)}.giv-vbadge{font-size:13px;font-weight:700;color:var(--primary)}.giv-vcard-avatar.cur .giv-vbadge{color:var(--ok)}.giv-vcard-main{flex:1;min-width:0;display:flex;flex-direction:column;justify-content:space-between;gap:5px}.giv-vcard-row{display:flex;align-items:center;gap:8px;min-width:0}.giv-vcard-title{flex:1;min-width:0;font-size:14px;font-weight:600;color:var(--text-1);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.giv-vcard-title.none{color:var(--text-muted);font-weight:400}.giv-vcard-time{flex:none;font-size:11px;color:var(--text-muted)}.giv-vcard-detail{flex:1;min-width:0;font-size:12px;color:var(--text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.giv-vcard-detail.none{color:var(--text-muted)}.giv-vcard .giv-entry-menu{margin-left:auto}.giv-vcard-muted .giv-vcard-avatar{background:var(--neu-inset)}.giv-vcard-muted .giv-vcard-avatar .giv-vbadge{color:var(--text-muted)}.giv-vcard-muted .giv-vcard-title,.giv-vcard-muted .giv-vcard-detail{opacity:.55}.giv-vcard-note{flex:none;font-size:11px;color:var(--text-muted)}.giv-panel-section.flush{padding:0}.giv-desc-more{padding:14px 24px;text-align:center;color:var(--text-muted);font-size:13px;cursor:pointer;-webkit-user-select:none;user-select:none}@keyframes givContentIn{0%{opacity:0}to{opacity:1}}.giv-content-enter{animation:givContentIn var(--motion-dur-med,.24s) var(--motion-ease-out,ease-out)}.pv-actions .giv-baracts{gap:0;margin-right:-4px}.pv-actions .giv-bact{flex-direction:row;align-items:center;gap:4px;min-width:auto;height:42px;padding:6px 5px}.pv-actions .giv-bact svg{width:22px;height:22px}.pv-actions .giv-bact .giv-count{font-size:11px;line-height:1}.pv-actions .item-menu{display:flex;align-items:center;margin-left:1px}.pv-actions .item-menu-trigger{width:28px;height:42px;min-height:42px;font-size:1.3rem;color:var(--text-1);border-radius:8px}.wcg-body{padding:12px}.wcg-desc{font-size:.82rem;color:var(--text-3);line-height:1.6;margin-bottom:8px}.wcg-list{border:1px solid var(--border);border-radius:8px;overflow:hidden;margin-bottom:10px;background:var(--neu-bg)}.wcg-row{display:flex;align-items:center;gap:8px;padding:8px 10px;border-top:1px solid var(--hairline);font-size:.88rem;color:var(--text-1)}.wcg-row:first-child{border-top:none}.wcg-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wcg-ref{color:var(--text-muted);font-size:.75rem}.wcg-mode{flex-shrink:0;font-size:.7rem;padding:2px 6px;border-radius:6px;background:var(--primary-tint);color:var(--primary)}.wcg-rm{border:none;background:none;color:var(--danger);font-size:.8rem;padding:4px 6px;cursor:pointer;font-family:inherit;-webkit-tap-highlight-color:transparent}.wcg-rm:disabled{color:var(--text-muted);cursor:default}.wcg-add{display:flex;gap:8px}.wcg-input{flex:1;min-width:0;border:1px solid var(--border);border-radius:8px;padding:8px 10px;font-size:.88rem;font-family:inherit}.wcg-btns{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px}.wcg-btn{border:none;border-radius:8px;padding:9px 8px;font-size:.85rem;color:#fff;background:var(--primary);cursor:pointer;font-family:inherit;-webkit-tap-highlight-color:transparent}.wcg-btn:disabled{opacity:.6;cursor:default}.wcg-btn.btn-view{background:#b7791f}.wcg-btn.btn-coown{background:var(--primary)}.wcg-btn.btn-govern{background:var(--ok)}.wcg-btn.btn-gift{background:var(--danger)}.giv-media .giv-media-holder{width:100%}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}.item-card.conv-card{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto auto;gap:3px 12px;min-height:0;padding:10px 12px}.conv-card .item-cover-wrap.conv-avatar{width:48px;height:48px;grid-row:1 / 3;align-self:center;border-radius:50%;border:none;background:var(--primary-tint);overflow:hidden}.conv-card .conv-avatar-link{display:block;width:100%;height:100%;text-decoration:none;-webkit-tap-highlight-color:transparent}.conv-card .conv-avatar-link:active{opacity:.7}.conv-card .conv-avatar-inner{width:100%;height:100%;object-fit:cover;display:flex;align-items:center;justify-content:center;font-size:1.25rem;font-weight:600;color:var(--primary);background:var(--primary-tint)}.conv-card .conv-avatar-inner.avatar-emoji{font-size:1.75rem}.conv-card .item-info{grid-row:1;grid-column:2;padding-right:56px}.conv-card .item-info-top{display:flex;align-items:center;min-width:0}.conv-card .item-info-top .item-name{flex:0 1 auto;min-width:0}.conv-card .conv-name{color:var(--text-1)}.conv-card .msg-pin-tag{flex:none;font-size:.66rem;color:var(--primary);border:1px solid var(--primary);border-radius:4px;padding:0 4px;line-height:1.4;margin-left:8px}.conv-card .conv-agent-dot{display:inline-block;flex:none;width:8px;height:8px;border-radius:50%;margin-left:6px;background:var(--text-muted)}.conv-card .conv-agent-dot[data-state=online]{background:var(--ok)}.conv-card .conv-agent-dot[data-state=offline]{background:var(--danger);box-shadow:0 0 0 2px #e53e3e40}.conv-card .conv-footer{grid-row:2;grid-column:2;display:flex;align-items:center;gap:8px;padding-top:0;margin-top:0;border-top:none}.conv-card .conv-footer-content{flex:1;min-width:0;display:flex;align-items:center;gap:8px}.conv-card .conv-preview{flex:1;min-width:0;font-size:.82rem;color:var(--text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.conv-card .conv-preview.conv-preview-empty{color:var(--text-muted);font-style:italic}.conv-card .conv-footer-right{flex:none;display:flex;align-items:center;gap:8px}.conv-card .conv-time{position:absolute;top:10px;right:12px;flex:none;font-size:.72rem;color:var(--text-muted);white-space:nowrap}.conv-card .item-menu-trigger{width:22px;height:22px;min-height:22px;font-size:1rem}.conv-card.conv-card-pinned{background:var(--pin-wash)}.conv-card.conv-card-pinned:hover{background:var(--hairline)}h1{text-align:center;margin:0 0 10px;font-size:1.2rem}h2{font-size:1.05rem;margin:18px 0 10px;color:var(--text-1)}.card{background:var(--neu-bg);border-radius:10px;box-shadow:0 1px 4px #00000014;padding:12px}.empty{text-align:center;color:var(--text-muted);padding:26px 0;font-size:.92rem}.login-tip{text-align:center;padding:60px 0;color:var(--text-2)}.login-tip a{color:var(--primary);text-decoration:none}.guest-landing{max-width:560px;margin:0 auto}.guest-card{cursor:default}.guest-actions{display:flex;gap:10px;margin-top:10px;flex-wrap:wrap}.guest-actions .guest-login,.guest-actions .guest-register{font-size:.85rem;text-decoration:none;color:var(--text-1)}.guest-actions .guest-login{color:var(--primary)}.profile-card{margin-bottom:10px}.acc-title{font-size:.85rem;color:var(--text-1);font-weight:600;margin-bottom:8px;display:flex;align-items:center;justify-content:space-between;gap:8px}.acc-title-text{min-width:0;display:inline-block}.acc-cover .acc-emoji{font-size:2.2rem;line-height:1}.acc-action:active{transform:scale(.94)}.logout-bar{display:flex;align-items:center;justify-content:center;width:100%;min-height:44px;margin-bottom:10px;padding:12px 14px;border:none;cursor:pointer;font:inherit;font-size:.88rem;font-weight:600;color:var(--danger);-webkit-tap-highlight-color:transparent;transition:background-color .15s}.logout-bar:hover,.logout-bar:active{background:var(--danger-tint)}.logout-bar:focus-visible{outline:2px solid var(--danger);outline-offset:2px}.fav-name,.qe-label,.acc-name{font-size:.72rem;color:var(--text-1);line-height:1.3;text-align:center;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-all}.fav-name{margin-top:4px}.qe-label{margin-top:6px;max-width:100%}.acc-name{margin-top:4px}.acc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(68px,1fr));gap:12px 10px}.acc-icon{text-align:center}.acc-cover{display:flex;align-items:center;justify-content:center;width:100%;aspect-ratio:1 / 1;border-radius:14px;overflow:hidden;background:linear-gradient(135deg,var(--neu-bg),var(--primary-tint));box-shadow:0 1px 3px #1e3c6e1f;cursor:pointer}.acc-cover:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.emoji-fs-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:4100;display:none;overflow:hidden;background:#1f2430;touch-action:none;overscroll-behavior:contain;user-select:none;-webkit-user-select:none;cursor:grab}.emoji-fs-overlay.active{display:block}.emoji-fs-board{position:absolute;left:0;top:0;transform-origin:0 0;background:var(--neu-bg);border-radius:14px;box-shadow:0 12px 40px #00000059;display:grid;grid-template-columns:repeat(32,44px);grid-auto-rows:44px;gap:4px;padding:6px;will-change:transform;touch-action:none}.emoji-picker-cell{width:44px;height:44px;font-size:1.55rem;line-height:1;background:var(--neu-bg);border:none;border-radius:10px;cursor:pointer;display:flex;align-items:center;justify-content:center}.emoji-picker-cell:hover,.emoji-picker-cell:active{background:var(--neu-inset)}.api-token-desc{font-size:.82rem;color:var(--text-3);margin-bottom:10px}.settings-window{padding:16px 14px 24px}.settings-inline{display:flex;align-items:center;gap:8px}.settings-inline input{flex:1;min-width:0}.settings-inline .link-btn{flex:0 0 auto}.settings-check{display:inline-flex;align-items:center;gap:6px;cursor:pointer}.settings-check input{flex:0 0 auto;width:auto}.set-feat-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.set-feat-btn{display:flex;align-items:center;gap:8px;min-height:44px;padding:8px 10px;border:none;border-radius:10px;background:var(--neu-bg);box-shadow:var(--neu-raise-xs);font-size:.85rem;font-weight:600;color:var(--text-1);cursor:pointer;text-align:left;-webkit-tap-highlight-color:transparent;transition:box-shadow .15s ease,transform .15s ease}.set-feat-btn:active{box-shadow:var(--neu-press-sm);transform:scale(.99)}.set-feat-ico{flex:none;font-size:1.1rem;line-height:1}.set-feat-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.settings-avatar{flex:0 0 auto;line-height:0}.settings-avatar .avatar{width:52px;height:52px;border-radius:12px}.settings-avatar-row .set-push{margin-left:auto}.settings-row-btn{display:flex;justify-content:flex-end;margin-bottom:12px}.set-card .settings-row-btn{margin-bottom:0}.set-card .settings-row-btn .link-btn{flex:1}.api-token-result{display:flex;align-items:center;gap:8px;margin-top:10px}.api-token-result[hidden]{display:none}.api-token-window{padding:16px 14px 24px}.api-token-result input{flex:1;min-width:0;font-family:monospace;font-size:.82rem;padding:8px 10px;border:1px solid var(--border-soft, #edf2f7);border-radius:8px;background:var(--neu-inset);color:var(--text-1);outline:none}.api-token-result input:focus{border-color:var(--primary)}.my-window-subtitle{text-align:center;color:var(--text-muted);font-size:.78rem;padding:4px 0 10px}.fav-icon{cursor:pointer;text-align:left;position:relative;z-index:1}.fav-icon:has(.item-menu-popup.open){z-index:1000}.fav-icon .item-menu-popup{z-index:100}.fav-cover .item-menu{display:none}.fav-cover{position:relative;flex:0 0 auto;width:52px;height:52px}.favorites-grid .fav-cover{width:40px;height:40px;border-radius:12px!important}.favorites-grid .fav-ph.fav-emoji{font-size:1.4rem}.fav-cover img{width:100%;height:100%;object-fit:cover;display:block;border-radius:14px}.fav-ph{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;font-size:1.1rem;font-weight:700;color:var(--text-muted)}.fav-ph.fav-emoji{font-size:1.7rem;font-weight:400;line-height:1}.fav-cover .item-menu{position:absolute;bottom:4px;right:4px;margin:0;z-index:2}.fav-cover .item-menu-trigger{background:#ffffffe6;box-shadow:0 1px 3px #00000026}.fav-cover .item-menu-trigger:hover{background:var(--neu-inset);color:var(--text-1)}.btn-danger{background:var(--danger-tint);color:var(--danger)}.btn-danger:hover{background:var(--danger-tint)}.quick-entries{margin-bottom:10px}.qe-title{font-size:.85rem;color:var(--text-1);font-weight:600;margin-bottom:8px}.qe-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;margin-top:4px}.qe-grid:empty{display:none}.qe-grid>a{text-decoration:none;color:inherit}.qe-grid .fav-icon{width:100%}.fav-icon{position:relative}.mcpx-body{padding:12px}.mcpx-desc{font-size:.82rem;color:var(--text-3);line-height:1.6;margin-bottom:6px}.mcpx-status{font-size:.82rem;color:var(--text-3);margin:6px 0;min-height:1.2em;word-break:break-all}.mcpx-status.error{color:var(--danger);font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap}.mcpx-status.ok{color:var(--ok)}.mcpx-retry{margin:0 0 8px}.mcpx-retry[hidden]{display:none}.mcpx-tree{background:var(--neu-bg);border:1px solid var(--border);border-radius:10px;padding:8px}.mcpx-node{margin-left:0}.mcpx-children{display:none;margin-left:12px;border-left:1px solid var(--hairline);padding-left:6px}.mcpx-node.open>.mcpx-children{display:block}.mcpx-row{display:flex;align-items:baseline;gap:6px;padding:3px 4px;border-radius:6px}.mcpx-branch{cursor:pointer}.mcpx-caret{width:12px;color:var(--text-muted);flex:none;transition:transform .12s}.mcpx-node.open>.mcpx-row .mcpx-caret{transform:rotate(90deg)}.mcpx-badge{flex:none;font-size:11px;padding:0 7px;border-radius:10px;border:1px solid var(--border);color:var(--text-3)}.mcpx-badge.tools{color:var(--primary);border-color:#90cdf4}.mcpx-badge.resources{color:#276749;border-color:#9ae6b4}.mcpx-badge.prompts{color:#c05621;border-color:#f6ad55}.mcpx-name{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12.5px;overflow-wrap:anywhere}.mcpx-name.mcpx-dim{color:var(--text-3);font-family:inherit}.mcpx-leaf-desc{color:var(--text-3);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1 1 auto}.mcpx-count{color:var(--text-3);font-size:12px;margin-left:auto;flex:none}.mcpx-detail-host{display:none;margin-left:-38px}.mcpx-node.open>.mcpx-detail-host{display:block}.mcpx-detail{margin:2px 0 6px;background:var(--neu-inset);border:1px solid var(--border);border-radius:6px;padding:8px 10px;font-size:12.5px}.mcpx-kv{color:var(--text-1);margin:2px 0;overflow-wrap:anywhere}.mcpx-detail code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#276749;font-size:12px;overflow-wrap:anywhere}.mcpx-detail pre,.mcpm-result pre{background:#1a202c;color:#e2e8f0;border-radius:6px;padding:6px;overflow:auto;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;max-height:320px;margin:6px 0 0}.mcpx-schema-line{white-space:pre-wrap}.mcpx-schema-line.req{color:#63b3ed}.mcpx-detail .mcpm-form{margin-top:6px;border-top:1px dashed var(--hairline);padding-top:6px}.mcpx-detail .mcpm-form-row{margin:4px 0}.mcpx-detail .mcpm-kv{margin:2px 0}.mcpx-detail .mcpm-run{margin-top:6px}.mcpx-token{margin-top:14px;border-top:1px solid var(--hairline);padding-top:4px}.mcpx-token-title{font-size:.82rem;font-weight:600;color:var(--text-1);padding:8px 2px 0}.mcpx-token .api-token-window{padding:10px 2px 0}.mcpm-body{padding:12px}.mcpm-detail-desc{font-size:.82rem;color:var(--text-3);line-height:1.6;margin:0 0 4px}.mcpm-detail-sec{font-size:.8rem;font-weight:600;color:var(--text-1);margin:14px 0 8px}.mcpm-kv{color:var(--text-1);font-size:12.5px;margin:4px 0;overflow-wrap:anywhere}.mcpm-form-row{display:flex;flex-direction:column;gap:4px;margin:8px 0}.mcpm-form-row label{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;color:var(--text-1);word-break:break-all}.mcpm-form-row label .mcpm-form-typ{color:#c05621;font-size:11px}.mcpm-form-row input[type=text],.mcpm-form-row input[type=number],.mcpm-form-row select,.mcpm-form-row textarea{width:100%;min-width:0;box-sizing:border-box;background:var(--neu-inset);color:var(--text-1);border:1px solid var(--border);border-radius:6px;padding:7px 9px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;outline:none}.mcpm-form-row input:focus,.mcpm-form-row textarea:focus,.mcpm-form-row select:focus{border-color:var(--primary)}.mcpm-form-row textarea{min-height:56px;resize:vertical}.mcpm-form-row input[type=checkbox]{width:auto}.mcpm-form-hint{color:var(--text-3);font-size:11px}.mcpm-run{min-height:32px;margin-top:8px;padding:7px 18px;background:var(--primary);color:#fff;border:none;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;-webkit-tap-highlight-color:transparent}.mcpm-run:hover{background:var(--primary-2)}.mcpm-run:disabled{opacity:.5;cursor:not-allowed}.mcpm-result{margin-top:8px}.mcpm-result .ok{color:var(--ok);font-size:12px;margin-bottom:4px}.mcpm-result .err{color:var(--danger);font-size:12px;margin-bottom:4px;word-break:break-all}.mcpm-result pre{white-space:pre-wrap;word-break:break-all}.fav-view-host{width:100%}.favorites-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;background:transparent}.favorites-grid:empty{display:none}.favorites-grid .fav-icon{display:flex;align-items:center;gap:10px;padding:8px 10px;min-height:56px;background:var(--neu-bg);border-radius:var(--neu-radius-sub);box-shadow:var(--neu-raise-xs);-webkit-tap-highlight-color:transparent;touch-action:manipulation;transition:box-shadow .15s ease,transform .15s ease}.favorites-grid .fav-icon:active{box-shadow:var(--neu-press-sm);transform:scale(.995)}.favorites-grid .fav-icon:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}@media (min-width: 1100px){.favorites-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width: 1600px){.favorites-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}.favorites-grid .fav-name{margin-top:0;text-align:left;display:block;-webkit-line-clamp:1;font-size:.92rem;font-weight:700;color:var(--text-1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fav-row-info{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}.fav-row-top{display:flex;align-items:baseline;gap:8px;min-width:0}.fav-row-top .fav-name{flex:0 1 auto;min-width:0}.fav-row-time{flex:0 0 auto;margin-left:auto;font-size:.7rem;color:var(--text-muted);white-space:nowrap}.fav-star-icon{position:absolute;right:10px;top:50%;transform:translateY(-50%);margin:0;padding:0;min-height:0;background:none;border:none;cursor:pointer;color:var(--text-muted);transition:color .2s ease,transform .2s ease;display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;line-height:1}.fav-star-icon svg{width:16px;height:16px;display:block}.fav-star-icon:hover{color:#fbbf24;transform:translateY(-50%) scale(1.15)}.fav-star-icon.favorited{color:#fbbf24}.fav-star-icon:active{transform:translateY(-50%) scale(.95)}.fav-star-icon[aria-disabled=true]{cursor:default;opacity:.5}.fav-star-icon[aria-disabled=true]:hover,.fav-star-icon[aria-disabled=true]:active{color:var(--text-muted);transform:translateY(-50%)}.fav-row-desc{font-size:.8rem;color:var(--text-3);line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:root{--primary: #5C4033;--primary-2: #3E2A20;--text-1: #5C4033;--text-2: #7A5C47;--text-3: #9C7E68;--text-muted: #B5987F;--border: #DCE3EC;--border-soft: #E4EAF1;--neu-bg: #E0E5EC;--neu-inset: #D1D9E6;--neu-sh-dark: rgba(163, 177, 198, .7);--neu-sh-light: rgba(255, 255, 255, .85);--neu-raise: 9px 9px 18px var(--neu-sh-dark), -9px -9px 18px var(--neu-sh-light);--neu-raise-sm: 5px 5px 10px var(--neu-sh-dark), -5px -5px 10px var(--neu-sh-light);--neu-raise-xs: 3px 3px 7px var(--neu-sh-dark), -3px -3px 7px var(--neu-sh-light);--neu-press: inset 5px 5px 12px var(--neu-sh-dark), inset -5px -5px 12px var(--neu-sh-light);--neu-press-sm: inset 3px 3px 6px var(--neu-sh-dark), inset -3px -3px 6px var(--neu-sh-light);--neu-press-xs: inset 2px 2px 4px var(--neu-sh-dark), inset -2px -2px 4px var(--neu-sh-light);--neu-pop-shadow: 0 8px 24px rgba(100, 112, 130, .35), 0 2px 6px rgba(100, 112, 130, .2);--neu-radius-card: 24px;--neu-radius-sub: 16px;--neu-radius-pill: 999px;--neu-accent-grad: var(--neu-bg);--neu-overlay-bg: var(--neu-bg);--neu-line: 1px solid rgba(198, 207, 220, .45);--canvas-w: 100%;--danger: #E53E3E;--danger-tint: rgba(197, 48, 48, .08);--ok: #38A169;--ok-tint: rgba(56, 161, 105, .25);--qr-dark: #5C4033;--primary-tint: rgba(92, 64, 51, .1);--tint-soak: rgba(92, 64, 51, .25);--tint-edge: rgba(92, 64, 51, .42);--tint-focus: rgba(92, 64, 51, .38);--hairline: rgba(163, 177, 198, .4);--stripe: rgba(163, 177, 198, .18);--pin-wash: rgba(209, 217, 230, .4);--canvas-hi: rgba(255, 255, 255, .55);--canvas-lo: rgba(163, 177, 198, .38);--neu-float-bg: var(--neu-bg)}:root[data-theme=dark]{color-scheme:dark;--primary: #C89E6E;--primary-2: #E2C29B;--text-1: #F2F2F2;--text-2: #C9C9C9;--text-3: #999999;--text-muted: #6E6E6E;--border: #3A3A3A;--border-soft: #303030;--neu-bg: #1A1A1A;--neu-inset: #131313;--neu-sh-dark: rgba(0, 0, 0, .55);--neu-sh-light: rgba(255, 255, 255, .07);--neu-raise: 9px 9px 18px var(--neu-sh-dark), -9px -9px 18px var(--neu-sh-light);--neu-raise-sm: 5px 5px 10px var(--neu-sh-dark), -5px -5px 10px var(--neu-sh-light);--neu-raise-xs: 3px 3px 7px var(--neu-sh-dark), -3px -3px 7px var(--neu-sh-light);--neu-press: inset 5px 5px 12px var(--neu-sh-dark), inset -5px -5px 12px var(--neu-sh-light);--neu-press-sm: inset 3px 3px 6px var(--neu-sh-dark), inset -3px -3px 6px var(--neu-sh-light);--neu-press-xs: inset 2px 2px 4px var(--neu-sh-dark), inset -2px -2px 4px var(--neu-sh-light);--neu-pop-shadow: 0 8px 24px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);--neu-accent-grad: var(--neu-bg);--neu-overlay-bg: var(--neu-bg);--neu-line: 1px solid rgba(255, 255, 255, .12);--neu-float-bg: var(--neu-bg);--danger: #F0715F;--danger-tint: rgba(240, 113, 95, .16);--ok: #6FBF8E;--ok-tint: rgba(111, 191, 142, .3);--primary-tint: rgba(200, 158, 110, .16);--tint-soak: rgba(200, 158, 110, .32);--qr-dark: #C89E6E;--tint-edge: rgba(200, 158, 110, .55);--tint-focus: rgba(200, 158, 110, .5);--hairline: rgba(255, 255, 255, .12);--stripe: rgba(255, 255, 255, .06);--pin-wash: rgba(255, 255, 255, .07);--canvas-hi: rgba(255, 255, 255, .05);--canvas-lo: rgba(0, 0, 0, .4)}.pv-overlay{background:var(--neu-overlay-bg)!important}.pv-head,.pv-scroll,.pv-body,.panel-scope,.gct,.gfp,.giv,.skv-body{background:transparent!important}.pv-head{border-bottom:var(--neu-line)!important}.item-menu-popup,.gfp-admin-popup{background:var(--neu-bg)!important;border:none!important;border-radius:var(--neu-radius-sub)!important;box-shadow:var(--neu-pop-shadow)!important;padding:8px!important;min-width:120px!important}.item-admin-actions{gap:6px;padding:0!important;display:flex;flex-direction:column}.item-admin-actions button,.gfp-admin-popup button{background:var(--neu-bg)!important;color:var(--text-1)!important;border:none!important;border-radius:10px!important;box-shadow:var(--neu-raise-xs)!important;font-weight:600!important;text-align:center!important;padding:10px 14px!important;transition:box-shadow .15s ease}.item-admin-actions button:hover,.gfp-admin-popup button:hover{background:var(--neu-bg)!important}.item-admin-actions button:active,.gfp-admin-popup button:active{box-shadow:var(--neu-press-xs)!important}.item-admin-actions button.btn-danger,.gfp-admin-popup button.danger{color:var(--danger)!important}.card,.gfp-head,.set-card{background:var(--neu-bg)!important;border:none!important;border-radius:var(--neu-radius-card)!important;box-shadow:var(--neu-raise)!important}.link-btn,.auth-card button[type=submit],.auth-fallback a{background:var(--neu-accent-grad)!important;color:var(--text-1)!important;border:none!important;border-radius:var(--neu-radius-sub)!important;box-shadow:4px 4px 10px var(--neu-sh-dark),-4px -4px 10px var(--neu-sh-light);font-weight:700;transition:filter .18s ease,box-shadow .18s ease,transform .18s ease}.link-btn:hover,.auth-card button[type=submit]:hover,.auth-fallback a:hover{background:var(--neu-accent-grad)!important;filter:brightness(1.07)}.link-btn:active,.auth-card button[type=submit]:active,.auth-fallback a:active{transform:scale(.97);box-shadow:var(--neu-press-sm)}.auth-card .auth-code-btn{background:var(--neu-bg)!important;color:var(--text-2)!important;border:1px solid var(--border-1)!important;border-radius:var(--neu-radius-sub)!important;box-shadow:var(--neu-raise-xs);font-weight:700}.auth-card .auth-code-btn:hover{filter:brightness(1.03)}.auth-card .auth-code-btn:active{box-shadow:var(--neu-press-xs)}.neu-btn{background:var(--neu-bg)!important;color:var(--text-1)!important;border:none!important;border-radius:10px!important;box-shadow:var(--neu-raise-xs)!important;font-weight:600;transition:box-shadow .15s ease}.neu-btn:active{box-shadow:var(--neu-press-xs)!important}input:not([type=checkbox]):not([type=radio]):not([type=range]):not(.cib-input),select,textarea{background:var(--neu-inset)!important;border:none!important;border-radius:var(--neu-radius-sub)!important;box-shadow:var(--neu-press-sm)!important;color:var(--text-1);caret-color:var(--primary);transition:box-shadow .18s ease}input:not([type=checkbox]):not([type=radio]):focus,select:focus,textarea:focus{outline:none;box-shadow:var(--neu-press),0 0 0 2.5px var(--tint-focus)!important}input::placeholder,textarea::placeholder{color:var(--text-muted)}select{-moz-appearance:none;appearance:none;-webkit-appearance:none}.ps-input,.wlw-search-input{padding:0 14px!important;font-size:16px!important}.ps-input::placeholder,.wlw-search-input::placeholder{color:var(--text-3)!important}.giv-chip{background:transparent!important;color:var(--text-2)!important;box-shadow:var(--neu-raise-xs)!important;font-weight:600!important}.giv-chip.giv-script-link{color:var(--primary)!important}.giv-chip.giv-script-link:active{color:var(--primary-2)!important}.item-card .giv-chip{box-shadow:2px 2px 5px var(--neu-sh-dark),-2px -2px 5px var(--neu-sh-light)!important}body{background:radial-gradient(1100px 560px at 15% -8%,var(--canvas-hi),transparent 62%),radial-gradient(900px 520px at 108% 108%,var(--canvas-lo),transparent 60%),var(--neu-bg)!important;color:var(--text-1)!important}a{color:var(--primary)}a:hover{color:var(--primary-2)}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--neu-inset);border-radius:var(--neu-radius-pill);box-shadow:var(--neu-press-xs)}:focus-visible{outline:3px solid var(--primary);outline-offset:2px;border-radius:8px}.card,.app-shell .app-view-my .card{padding:16px 14px}.app-shell .app-view-my .empty{color:var(--text-3)}h1{text-align:center;color:var(--text-1);font-weight:800;letter-spacing:-.01em}h2{color:var(--text-1);font-weight:700}.acc-title{color:var(--text-2)}.empty,.login-tip{color:var(--text-3)}.login-tip a{color:var(--primary)}.acc-title{font-weight:700;letter-spacing:.02em}.acc-cover,.fav-cover{background:var(--neu-bg)!important;border-radius:18px!important;box-shadow:var(--neu-raise-sm);border:none;transition:box-shadow .18s ease,transform .18s ease;overflow:hidden}.acc-cover:active,.fav-cover:active{transform:scale(.95);box-shadow:var(--neu-press-sm)}.acc-name,.fav-name{color:var(--text-2);font-weight:600}.fav-edit-btn{background:var(--neu-bg);color:var(--primary);border:none;border-radius:12px;box-shadow:var(--neu-raise-xs);font-weight:700;padding:4px 14px;min-height:34px}.fav-edit-btn:hover{color:var(--primary-2)}.fav-edit-btn:active{box-shadow:var(--neu-press-xs);background:var(--neu-inset)}.logout-bar{background:var(--neu-bg)!important;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-press-sm);border:none;font-weight:700}.logout-bar:hover{background:var(--neu-bg);filter:none}.logout-bar:active{box-shadow:var(--neu-press)}.settings-window{background:transparent}.set-card-ico{background:var(--neu-inset)!important;border:none;box-shadow:var(--neu-press-xs)}.emoji-picker-cell{background:var(--neu-bg);border-radius:10px;box-shadow:var(--neu-raise-xs)}.emoji-picker-cell:hover{background:var(--neu-bg);filter:none}.emoji-picker-cell:active{box-shadow:var(--neu-press-xs)}.mcpm-form-row label{color:var(--text-2)}.mcpx-tree,.mcpx-detail{background:var(--neu-inset)!important;border:none!important;box-shadow:var(--neu-press-sm)!important;border-radius:var(--neu-radius-sub)!important}.mcpx-branch:hover{background:var(--primary-tint)}.mcpx-children{border-left:1.5px solid var(--hairline)}.wlw-grid .lf-status-section{width:100%;box-sizing:border-box;margin:0 auto;padding:20px 16px;background:var(--neu-inset);border-radius:var(--neu-radius-sub);box-shadow:var(--neu-press-sm);color:var(--text-3);text-align:center}.items-grid{background:transparent!important;box-shadow:none!important;border-radius:0!important;padding:10px 0!important;display:flex;flex-direction:column;gap:10px}.items-grid .item-card:first-child{border-radius:var(--neu-radius-sub)!important}.items-grid .item-card{box-shadow:var(--neu-raise-xs)!important}.items-grid .item-card:active{box-shadow:var(--neu-press-sm)!important}.items-grid .inf-scroll-end{background:transparent!important;box-shadow:none!important;color:var(--text-muted)!important;padding:16px 0 8px!important}.item-cover-wrap{border:none;border-radius:14px;box-shadow:var(--neu-raise-xs);background:var(--neu-bg)}.item-cover-wrap img{border-radius:14px}.item-cover-wrap.no-image-placeholder{background:var(--neu-inset);box-shadow:var(--neu-press-xs);border:none}.item-name{color:var(--text-1);font-weight:700}.item-card-footer{color:var(--text-3)}.card-badge{border-radius:var(--neu-radius-pill)}.card-badge-pending{background:color-mix(in srgb,var(--primary) 30%,transparent)}.ps-panel{background:transparent!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;border:none!important;box-shadow:none!important;border-radius:0!important;padding:0!important}.ps-cancel{flex:none;height:36px!important;padding:0 12px!important;border:none!important;border-radius:10px!important;background:var(--neu-bg)!important;box-shadow:var(--neu-raise-xs)!important;color:var(--text-1)!important}.ps-cancel:active{box-shadow:var(--neu-press-xs)!important;color:var(--text-2)!important}.conv-avatar{border-radius:16px;box-shadow:var(--neu-raise-xs)}.auth-card{background:var(--neu-bg)!important;border-radius:var(--neu-radius-card)!important;box-shadow:var(--neu-raise)!important;padding:34px 28px!important}.auth-card h1{font-weight:800;letter-spacing:-.01em}.auth-card label{color:var(--text-2);font-weight:600}.auth-card input{background:var(--neu-inset);border:none;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-press-sm)}.auth-card input:focus{border-color:transparent}.auth-card button[type=submit]:disabled{background:var(--neu-inset);color:var(--text-muted);filter:none}.auth-card .auth-code-btn:disabled{background:var(--neu-inset)!important;color:var(--text-muted)!important;box-shadow:var(--neu-press-xs);filter:none}.auth-msg{color:var(--danger)}.auth-captcha{color:var(--text-3)}.auth-fallback{background:var(--neu-inset);border:none;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-press-xs);color:var(--text-2)}.auth-switch{color:var(--text-3)}.auth-switch a{color:var(--primary);font-weight:700}.ms-confirm{border-radius:var(--neu-radius-card);box-shadow:var(--neu-pop-shadow)}.ms-confirm-actions button{background:var(--neu-bg);border:none;box-shadow:var(--neu-raise-xs);border-radius:14px}.ms-confirm-actions button.ms-confirm-ok{background:var(--neu-accent-grad);color:#fff;box-shadow:4px 4px 10px var(--neu-sh-dark),-4px -4px 10px var(--neu-sh-light)}.pv-head{background:var(--neu-float-bg)!important;border-bottom:none!important;box-shadow:0 1px 0 var(--hairline),0 2px 10px #a3b1c633!important}.pv-close{color:var(--text-2)}.pv-close:active{background:var(--neu-inset)}.app-view,.app-view-my{background:transparent!important;border:none!important;box-shadow:none!important}.app-shell .app-view>.container{background:transparent}.app-canvas,.app-root{background:transparent!important}.giv-img{background:var(--neu-inset);color:var(--text-muted)}.giv-img.giv-emoji,.giv-img.pending{color:var(--text-3)}.giv-bact{color:var(--text-2)}.giv-bact .giv-count{color:var(--text-muted)}.giv{color:var(--text-1)}.giv-id-badge,.giv-ctime{color:var(--text-muted)}.giv-ctime-btn,.giv-forked-from{color:var(--primary)}.giv-forked-from:active{color:var(--primary-2)}.giv-desc{color:var(--text-1)}.giv-desc-placeholder{color:var(--text-muted)}.giv-outline-item{color:var(--text-1)}.giv-outline-item[data-level="3"],.giv-outline-item[data-level="4"]{color:var(--text-2)}.giv-outline-sep{background:var(--hairline)}.giv-outline-item.cur{background:var(--neu-inset);color:var(--primary)}.giv-outline-item.cur:before{background:var(--primary)}.giv-mdtoc{background:var(--neu-inset);border:none;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-press-sm)}.giv-mdtoc-title{color:var(--text-2)}.giv-mdtoc .giv-mdtoc-item,.skv-md{color:var(--text-1)}.giv-desc ::selection,.skv-md ::selection{background:var(--tint-soak)}.giv-desc h1,.giv-desc h2,.giv-desc h3,.giv-desc h4,.giv-desc h5,.giv-desc h6,.skv-md h1,.skv-md h2,.skv-md h3,.skv-md h4,.skv-md h5,.skv-md h6{color:var(--text-1)}.giv-desc h3,.skv-md h3{color:var(--primary)}.giv-desc h5,.skv-md h5{color:var(--text-2)}.giv-desc h6,.skv-md h6{color:var(--text-3)}.giv-desc h1,.skv-md h1{border-image:linear-gradient(90deg,var(--primary),var(--primary-tint)) 1}.giv-desc h2:before,.skv-md h2:before{background:linear-gradient(180deg,var(--primary),var(--primary-2))}.giv-desc li::marker,.skv-md li::marker{color:var(--primary)}.giv-desc li input[type=checkbox],.skv-md li input[type=checkbox]{accent-color:var(--primary)}.giv-desc code,.skv-md code{background:var(--primary-tint);color:var(--primary-2)}.giv-desc pre,.skv-md pre{background:var(--stripe);box-shadow:none}.giv-desc pre code,.skv-md pre code{color:var(--text-1)}.giv-desc th,.giv-desc td,.skv-md th,.skv-md td{border-bottom-color:var(--hairline)}.giv-desc th,.skv-md th{background:var(--stripe);color:var(--text-2)}.giv-desc tbody tr:nth-child(2n) td,.skv-md tbody tr:nth-child(2n) td{background:var(--stripe)}.giv-desc blockquote,.skv-md blockquote{background:var(--stripe);border-left-color:var(--tint-edge);color:var(--text-2)}.giv-desc a,.skv-md a{color:var(--primary);border-bottom-color:var(--tint-edge)}.giv-desc a:hover,.skv-md a:hover{color:var(--primary-2);border-bottom-color:var(--primary-2)}.giv-desc hr,.skv-md hr{background:linear-gradient(90deg,transparent,var(--hairline) 20%,var(--hairline) 80%,transparent)}.giv-desc kbd,.skv-md kbd{background:var(--neu-inset);border-color:var(--hairline);color:var(--primary)}.giv-desc strong,.skv-md strong{color:var(--text-1)}.giv-desc del,.skv-md del{color:var(--text-3)}.giv-panel-empty{color:var(--text-muted)}.giv-panel-title{color:var(--text-2)}.giv-entry{background:var(--neu-bg);border:none;border-radius:10px;box-shadow:var(--neu-raise-xs)}.giv-entry.clickable-card:active{background:var(--neu-inset);box-shadow:var(--neu-press-xs)}.giv-entry-menu-trigger:hover{background:var(--neu-inset);color:var(--primary)}.giv-entry-menu-item{color:var(--text-1)}.giv-entry-menu-popup{background:var(--neu-bg);border:none;border-radius:var(--neu-radius-sub);box-shadow:var(--neu-pop-shadow)}.giv-vcard{background:var(--neu-bg);border:none;border-radius:12px;box-shadow:var(--neu-raise-xs)}.giv-vcard.clickable-card:active{background:var(--neu-inset)}.giv-vlist .giv-vcard{border-top-color:var(--hairline);box-shadow:none}.giv-vcard-avatar{background:var(--neu-inset)}.giv-vbadge{color:var(--primary)}.giv-vcard-title{color:var(--text-1)}.giv-vcard-title.none,.giv-vcard-time,.giv-vcard-detail.none{color:var(--text-muted)}.giv-vcard-detail{color:var(--text-3)}.avatar{display:inline-flex;align-items:center;justify-content:center;flex:none;line-height:1;background:var(--neu-inset);color:var(--primary)}::selection{background:var(--tint-soak)}.gct{color:var(--text-1)!important}.gct-msgs{padding:16px 14px 22px!important}.gct-msg.user .gct-bubble{background:var(--neu-bg)!important;color:var(--text-1)!important;border-radius:20px 20px 7px!important;box-shadow:5px 5px 11px var(--neu-sh-dark),-5px -5px 11px var(--neu-sh-light)!important}.gct-msg.peer .gct-bubble{background:var(--neu-bg)!important;color:var(--text-1)!important;border-radius:20px 20px 20px 7px!important;box-shadow:5px 5px 11px var(--neu-sh-dark),-5px -5px 11px var(--neu-sh-light)!important}.gct-bubble.error{background:var(--danger-tint)!important;color:var(--danger)!important;box-shadow:var(--neu-raise-xs)!important}.gct-md code{background:var(--primary-tint)!important;color:var(--primary-2)!important}.gct-md pre{background:var(--stripe)!important;border-radius:12px!important}.gct-md a{color:var(--primary)!important}.gct-md blockquote{border-left-color:var(--tint-edge)!important}.gct-md mark{background:#ffe9a8!important}.gct-md th,.gct-md td{border-color:var(--hairline)!important}.gct-md th{background:var(--stripe)!important}.gct-md hr{border-top-color:var(--hairline)!important}.gct-md video.md-video{max-width:100%;border-radius:12px!important;background:#000}.gct-md audio.md-audio{width:100%;height:40px}.gct-time-divider .gct-time-text{background:var(--neu-inset)!important;color:var(--text-3)!important;border-radius:var(--neu-radius-pill)!important;box-shadow:var(--neu-press-xs)!important}.gct-welcome{color:var(--text-3)!important}.cib{background:var(--neu-bg)!important;border-top:none!important;box-shadow:-1px -1px 2px var(--neu-sh-light) inset,10px 10px 24px var(--neu-sh-dark)}.cib-input{background:var(--neu-inset)!important;border:none!important;border-radius:18px!important;box-shadow:var(--neu-press-sm)!important;color:var(--text-1)!important;caret-color:var(--primary)!important}.cib-input:focus{box-shadow:var(--neu-press),0 0 0 2.5px var(--tint-focus)!important}.cib-plus{background:var(--neu-bg)!important;border:none!important;border-radius:15px!important;box-shadow:var(--neu-raise-xs)!important;color:var(--primary)!important;font-weight:700!important}.cib-plus:active{box-shadow:var(--neu-press-xs)!important}.cib-guest{color:var(--text-3)!important}.gfp{background:transparent!important;color:var(--text-1)!important}.gfp-head{padding:18px 16px!important}.gfp-name{color:var(--text-1)!important;font-weight:800!important}.gfp-name-real,.gfp-uname,.gfp-since,.gfp-views{color:var(--text-3)!important}.gfp-tag-role{background:var(--neu-bg)!important;color:var(--text-2)!important;box-shadow:var(--neu-raise-xs)!important;font-weight:700!important}.gfp-tag-role.is-admin{background:var(--neu-accent-grad)!important;color:#fff!important;box-shadow:4px 4px 10px var(--neu-sh-dark),-4px -4px 10px var(--neu-sh-light)!important}.gfp-actions .gfp-btn{border-radius:15px!important}.gfp-actions .gfp-admin-wrap .gfp-btn{background:var(--neu-bg)!important;color:var(--text-2)!important;border:none!important;box-shadow:var(--neu-raise-xs)!important}.gfp-section{color:var(--text-1)!important;font-weight:700!important}.gfp-section .gfp-count{color:var(--text-muted)!important}.gfp .items-grid{margin-top:4px}.item-card .item-info,.item-card .item-info-top,.item-card .item-tags,.item-card .item-card-footer{background:transparent!important}.conv-name{color:var(--text-1)!important;font-weight:700!important}.conv-preview,.conv-preview-empty{color:var(--text-3)!important}.conv-time{color:var(--text-muted)!important}.conv-card-pinned{background:var(--pin-wash)!important}.conv-agent-dot[data-state=online]{box-shadow:0 0 0 2px var(--ok-tint)!important}.app-canvas,.app-root{padding-bottom:0!important}.app-shell .app-view-my{overflow:hidden!important;padding:0!important}.app-shell .app-view-my>.container{padding:12px 10px!important;height:100%!important;overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;box-sizing:border-box}.app-shell .app-view-my>.container:after{content:""!important;display:block!important;height:calc(16px + env(safe-area-inset-bottom,0px))!important;background:transparent!important;box-shadow:none!important;border:none!important;pointer-events:none!important}@media (prefers-reduced-motion: reduce){.card,.acc-cover,.fav-cover,.item-card,.link-btn,.gct-bubble,.cib-input{transition:none!important}}:root[data-theme=dark] .gct-md mark,:root[data-theme=dark] .giv-desc mark,:root[data-theme=dark] .skv-md mark,:root[data-theme=dark] mark{background:#ffe9a838!important;color:var(--text-1)!important}:root[data-theme=dark] .panel-scope .role-chip{background:#5a67d829;color:#a8b2f2;border-color:#5a67d861}:root[data-theme=dark] .panel-scope .role-chip-more,:root[data-theme=dark] .panel-scope .role-chip-locked,:root[data-theme=dark] .panel-scope .badge-locked{background:#ffffff12;border-color:#ffffff29}:root[data-theme=dark] .panel-scope .badge-locked{color:var(--text-3)}.fw-busy{opacity:.6;pointer-events:none;will-change:opacity;transform:translateZ(0)}.wd-anchor{position:fixed;width:0;height:0;z-index:4050;pointer-events:none}.wd-pop{position:absolute;left:0;top:4px;bottom:auto;width:max-content;max-width:320px;background:#14141c38;-webkit-backdrop-filter:blur(20px) saturate(1.9);backdrop-filter:blur(20px) saturate(1.9);color:#ffffffe6;border:1px solid rgba(255,255,255,.18);box-shadow:0 8px 24px #00000040;border-radius:14px;padding:12px 14px;font-family:system-ui,-apple-system,PingFang SC,Microsoft YaHei,sans-serif;font-size:14px;line-height:1.6;text-align:left;pointer-events:none;z-index:4050}.wd-pop[hidden]{display:none}.wd-pop.open-up{top:auto;bottom:4px}.wd-head{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}.wd-word{font-size:17px;font-weight:700;color:#fff}.wd-ph{color:#ffffffa6;font-size:13px}.wd-via{display:inline-block;margin-top:5px;font-size:12px;background:#ffffff24;color:#ffd66e;border-radius:4px;padding:2px 7px}.wd-tags{margin-top:5px}.wd-tags i{display:inline-block;font-style:normal;font-size:11px;background:#ffffff24;color:#9ec1ff;border-radius:4px;padding:1px 6px;margin:2px 4px 0 0}.wd-tr{margin-top:7px;font-size:14px;line-height:1.65}.wd-notfound,.wd-loading,.wd-err{color:#ffffffa6;font-size:13px;margin-top:4px}.wd-task-meta{margin-top:6px;font-size:12px;color:#ffd66e}.wd-err{color:#ff8a7a}.wd-token{display:inline-block;margin:0 2px;padding:.08em .45em;border-radius:var(--neu-radius-pill, 999px);background:var(--neu-bg, #E0E5EC);box-shadow:var(--neu-raise-xs, 3px 3px 7px rgba(163, 177, 198, .7), -3px -3px 7px rgba(255, 255, 255, .85));color:var(--text-1, #5C4033);font-weight:600;line-height:1.35;cursor:pointer;-webkit-tap-highlight-color:transparent}.wd-token:active{background:var(--neu-inset, #D1D9E6);box-shadow:var(--neu-press-xs, inset 2px 2px 4px rgba(163, 177, 198, .7), inset -2px -2px 4px rgba(255, 255, 255, .85))}</style>
318
+ <!-- 15s 强制放行保险丝 -->
319
+ <script>
320
+ (function () {
321
+ setTimeout(function () {
322
+ if (window.Interact && typeof Interact.forceArm === 'function') {
323
+ Interact.forceArm();
324
+ } else {
325
+ var g = document.getElementById('fwBootGate');
326
+ if (g && g.parentNode) g.parentNode.removeChild(g);
327
+ }
328
+ (window.__fwBeacon || function () {})(
329
+ 'res', 'boot gate 15s 强制放行(交互层未就绪)', '');
330
+ }, 15000);
331
+ })();
332
+ </script>
333
+
334
+ <!-- 旧加载药丸的 fw-boot-pulse 脉冲样式已随骨架化退役(2026-11-07):
335
+ 加载特效改为 head 内骨架屏样式块的 fw-sk-sweep 扫光。 -->
336
+
337
+ <!-- 错误信标 -->
338
+ <script>
339
+ (function () {
340
+ var q = [], sent = 0;
341
+ function push(k, m, s) {
342
+ if (q.length >= 10) return;
343
+ q.push({ k: k, m: String(m == null ? '' : m).slice(0, 400),
344
+ s: String(s || '').slice(0, 300), u: location.pathname.slice(0, 200) });
345
+ }
346
+ function flush() {
347
+ if (!q.length || sent >= 3) return;
348
+ sent++;
349
+ var body = JSON.stringify({ items: q.splice(0, q.length) });
350
+ try {
351
+ // 前缀读当值的 __apiBaseUrl:flush 在错误后 800ms,分离部署
352
+ // 下前置探测(本页更靠后的脚本)通常已落定;未落定则按同源
353
+ // 兜底,该条遥测丢失可接受
354
+ fetch((window.__apiBaseUrl || '') + '/api/client-errors', { method: 'POST', keepalive: true,
355
+ headers: { 'Content-Type': 'application/json',
356
+ 'X-Requested-With': 'XMLHttpRequest' },
357
+ body: body }).catch(function () {});
358
+ } catch (e) {}
359
+ }
360
+ var prevErr = window.onerror;
361
+ window.onerror = function (m, s, l, c) {
362
+ if (typeof prevErr === 'function') { try { prevErr.apply(this, arguments); } catch (e) {} }
363
+ push('js', m, (s || '') + ':' + (l || 0) + ':' + (c || 0));
364
+ setTimeout(flush, 800);
365
+ return false;
366
+ };
367
+ window.addEventListener('unhandledrejection', function (e) {
368
+ var r = e.reason;
369
+ push('rej', (r && (r.stack || r.message)) || r, '');
370
+ setTimeout(flush, 800);
371
+ });
372
+ window.__fwBeacon = push;
373
+ })();
374
+ </script>
375
+
376
+ <!-- CSRF fetch 包装器 + 接口域统一收口 -->
377
+ <script>
378
+ (function () {
379
+ const origFetch = window.fetch;
380
+ window.fetch = function (input, init) {
381
+ // 2026-10-18 跨域分离部署统一收口(单点修好全部相对请求):
382
+ // (a) 相对 /api/ 请求补 __apiBaseUrl 前缀(已前缀成 API 域的
383
+ // 绝对 URL 不动——判断 origin 仍是页面源才算未前缀);
384
+ // (b) /api/ 请求默认 credentials:'include'(跨源 fetch 默认
385
+ // 不带 cookie;同源 include 行为不变;调用方显式设置优先);
386
+ // (c) /api/ 写请求补 X-Requested-With(后端 CSRF 闸②,与来源
387
+ // 域无关)。安全面释放由后端 CORS 白名单 + COOKIE_SAMESITE
388
+ // 承接(Origin 写闸放行 CORS_ORIGINS 清单)。
389
+ // 基址用 document.baseURI/location.href 而非 location.origin:
390
+ // file:// 页面的 location.origin 是字符串 "null",不能当 URL
391
+ // 基址(new URL(any, "null") 恒抛 Invalid URL,会让 file://
392
+ // 单文件客户端的所有请求在收口处直接失败)。
393
+ const baseHref = document.baseURI || location.href;
394
+ const url = new URL(typeof input === 'string' ? input : input.url,
395
+ baseHref);
396
+ let apiOrigin = location.origin;
397
+ try {
398
+ if (window.__apiBaseUrl) {
399
+ apiOrigin = new URL(window.__apiBaseUrl, baseHref).origin;
400
+ }
401
+ } catch (e) { /* 配置非法 → 按同源兜底 */ }
402
+ const isApi = url.pathname === '/api/' || url.pathname.startsWith('/api/');
403
+ if (isApi && url.origin === location.origin
404
+ && apiOrigin !== location.origin
405
+ && (typeof input === 'string' || input instanceof URL)) {
406
+ // 仅重写字符串/URL 形态(Request 对象重建有 body 消费风险,
407
+ // 维持原样走同源语义——仓内 /api 调用均为字符串 URL)
408
+ input = apiOrigin + url.pathname + url.search + url.hash;
409
+ }
410
+ if (isApi) {
411
+ init = Object.assign({}, init);
412
+ if (!init.credentials) init.credentials = 'include';
413
+ if (url.origin === location.origin || url.origin === apiOrigin) {
414
+ const headers = new Headers(init.headers
415
+ || (typeof input !== 'string' && input.headers) || {});
416
+ if (!headers.has('X-Requested-With')) {
417
+ headers.set('X-Requested-With', 'XMLHttpRequest');
418
+ }
419
+ init.headers = headers;
420
+ }
421
+ }
422
+ return origFetch.call(this, input, init);
423
+ };
424
+ })();
425
+ </script>
426
+
427
+ <!-- 接口域前置探测(2026-10-18 接口层改造 + 2026-10-31 单文件跨域增强):
428
+ 前端不关心后端在哪。三层兜底:
429
+ 1. 预注入全局变量(window.__DDR0_API_OVERRIDE,file:// / Electron 用)
430
+ 2. URL query 参数(?api=https://ddr0.com,直接打开/分享链接用)
431
+ 3. 相对 /config.json(同域/反向代理部署,既有行为零漂移)
432
+ 第一/二层只确定「后端在哪」,站点身份(品牌名等)仍要向后端要:
433
+ 命中后并行拉 <base>/config.json 的 site 块,否则跨域外壳会一直显示
434
+ 主机名占位(file:// 下就是字面量 site = 用户看到的「旧名称」)。
435
+ 先于一切模块求值;site-utils 的 api()/apiUrl() 等 __apiReady 落定
436
+ 后才发首个请求,auth.ts 等早序模块的启动请求不会以相对路径打错域。 -->
437
+ <script>
438
+ (function () {
439
+ var resolveReady;
440
+ window.__apiReady = new Promise(function (r) { resolveReady = r; });
441
+ window.__apiBaseUrl = '';
442
+
443
+ /* 站点实例身份校正(真源 = 后端 settings.site):首帧的主机名
444
+ 占位升级为实例数据;跨域时也从 <base>/config.json 取。 */
445
+ function applyConfig(cfg) {
446
+ if (cfg && typeof cfg.apiBaseUrl === 'string') {
447
+ window.__apiBaseUrl = cfg.apiBaseUrl.replace(/\/+$/, '');
448
+ }
449
+ if (cfg && cfg.site && typeof cfg.site === 'object') {
450
+ window.__SITE__ = {
451
+ slug: String(cfg.site.slug
452
+ || (window.__SITE__ && window.__SITE__.slug)
453
+ || 'site'),
454
+ name: String(cfg.site.name || ''),
455
+ domain: String(cfg.site.domain || '')
456
+ };
457
+ if (window.__SITE__.name) document.title = window.__SITE__.name;
458
+ }
459
+ }
460
+
461
+ /* 探测请求必须有上限:链路卡住时 fetch 可以挂几十秒,而全站
462
+ 首个 API 请求都在等 __apiReady——不设超时 = 整页一直白屏。 */
463
+ function probeFetch(url) {
464
+ var ctrl = typeof AbortController === 'function'
465
+ ? new AbortController() : null;
466
+ var timer = ctrl ? setTimeout(function () { ctrl.abort(); }, 3000) : null;
467
+ return fetch(url, { credentials: 'same-origin', signal: ctrl ? ctrl.signal : undefined })
468
+ .then(function (res) { return res.ok ? res.json() : null; })
469
+ .catch(function () { return null; })
470
+ .then(function (cfg) {
471
+ if (timer) clearTimeout(timer);
472
+ return cfg;
473
+ });
474
+ }
475
+
476
+ /* 第一层:预注入全局变量(Electron preload / 自定义壳可在此脚本前设置)。
477
+ 站点身份取后端域,取不到也不阻塞启动。 */
478
+ if (typeof window.__DDR0_API_OVERRIDE === 'string' && window.__DDR0_API_OVERRIDE) {
479
+ window.__apiBaseUrl = window.__DDR0_API_OVERRIDE.replace(/\/+$/, '');
480
+ resolveReady(window.__apiBaseUrl);
481
+ probeFetch(window.__apiBaseUrl + '/config.json').then(applyConfig);
482
+ return;
483
+ }
484
+
485
+ /* 第二层:URL query 参数 ?api=https://... */
486
+ try {
487
+ var params = new URLSearchParams(location.search);
488
+ var qApi = params.get('api');
489
+ if (qApi && typeof qApi === 'string' && qApi.trim()) {
490
+ window.__apiBaseUrl = qApi.trim().replace(/\/+$/, '');
491
+ resolveReady(window.__apiBaseUrl);
492
+ probeFetch(window.__apiBaseUrl + '/config.json').then(applyConfig);
493
+ return;
494
+ }
495
+ } catch (e) { /* URLSearchParams 不可用时跳过 */ }
496
+
497
+ /* 第三层:相对 /config.json(同域部署,或托管层提供) */
498
+ probeFetch('/config.json').then(function (cfg) {
499
+ window.__fwMark && window.__fwMark('cfg-done');
500
+ applyConfig(cfg);
501
+ resolveReady(window.__apiBaseUrl);
502
+ });
503
+ })();
504
+ </script>
505
+
506
+ <!-- 首屏并行预取(2026-10-20):bootstrap 与收藏第一页在 head 就发起,
507
+ 与 HTML 下载 / 主模块解析并行;boot.ts / my-favorites.ts 只 await
508
+ 结果,不再等模块求值完才发请求。必须放在 fetch 收口器与接口域
509
+ 探测之后(复用前缀/凭据/CSRF 头)。fav 只在本视图路径预取,
510
+ 其余页面不发无用请求。 -->
511
+ <script>
512
+ (function () {
513
+ function getJSON(url) {
514
+ // Safari ITP 等场景下会话 cookie 可能被拒,认证实际靠
515
+ // mobile-shell 写入 sessionStorage 的 token;head 预取早于
516
+ // mobile-shell 装载,必须自己补同一个 X-Session-Token,
517
+ // 否则 bootstrap 会以游客返回(主题/权限都错,随后被
518
+ // /api/auth/me 纠正 = 先浅后深的闪一下)。
519
+ // 存储键 = <slug>.sessionToken.v1(mobile-shell 单源);按后缀
520
+ // 匹配 + 旧键兜底,读错键 = 预取 403 → 白跑一次请求。
521
+ var headers = { 'X-Requested-With': 'XMLHttpRequest' };
522
+ try {
523
+ var token = '';
524
+ for (var i = 0; i < sessionStorage.length; i++) {
525
+ var k = sessionStorage.key(i);
526
+ if (k && /\.sessionToken\.v1$/.test(k)) {
527
+ token = sessionStorage.getItem(k) || '';
528
+ break;
529
+ }
530
+ }
531
+ if (!token) token = sessionStorage.getItem('session_token') || '';
532
+ if (token) headers['X-Session-Token'] = token;
533
+ } catch (e) { /* sessionStorage 被禁:仍走 cookie */ }
534
+ /* 4s 上限:预取挂在弱网上时 boot 不能无限期等它;超时
535
+ 交给 boot.ts 的现场请求重试(两条独立连接)。 */
536
+ var ctrl = typeof AbortController === 'function'
537
+ ? new AbortController() : null;
538
+ var timer = ctrl ? setTimeout(function () { ctrl.abort(); }, 4000) : null;
539
+ return fetch(url, { credentials: 'include', headers: headers,
540
+ signal: ctrl ? ctrl.signal : undefined })
541
+ .then(function (res) { return res.ok ? res.json() : null; })
542
+ .catch(function () { return null; })
543
+ .then(function (data) {
544
+ if (timer) clearTimeout(timer);
545
+ return data;
546
+ });
547
+ }
548
+ var path = location.pathname;
549
+ // favorites 预取只对持会话 cookie 的访客有价值(2026-10-28 请求
550
+ // 效率审计:匿名装载白发 403,每次硬装载 -1 请求);收藏接口
551
+ // 需登录,无 session_token 必 403。
552
+ var hasSession = document.cookie.indexOf('session_token=') !== -1;
553
+ window.__fwBootPrefetch = {
554
+ bootstrap: window.__apiReady.then(function () {
555
+ window.__fwMark && window.__fwMark('prefetch-start');
556
+ return getJSON('/api/bootstrap');
557
+ }),
558
+ favorites: (hasSession && (path === '/' || path === '/favorites'))
559
+ ? window.__apiReady.then(function () {
560
+ return getJSON('/api/my/favorites?limit=30&offset=0');
561
+ })
562
+ : null
563
+ };
564
+ })();
565
+ </script>
566
+
567
+ <!-- Motion 降级存根 -->
568
+ <script>
569
+ window.Motion = window.Motion || {
570
+ reduced: function () { return true; },
571
+ afterTransition: function (el, opts, cb) {
572
+ if (typeof opts === 'function') { cb = opts; }
573
+ var t = setTimeout(cb, 0);
574
+ return function () { clearTimeout(t); };
575
+ },
576
+ afterAnimation: function (el, opts, cb) {
577
+ if (typeof opts === 'function') { cb = opts; }
578
+ var t = setTimeout(cb, 0);
579
+ return function () { clearTimeout(t); };
580
+ },
581
+ nextPaint: function (cb) { setTimeout(cb, 0); },
582
+ };
583
+ </script>
584
+
585
+ <!-- Vendor 库(UMD 格式,必须前置加载) -->
586
+ <!-- 注意:Vite 不会自动处理这些,需要配置为 external 或手动复制 -->
587
+
588
+ <!-- 主入口(Vite 会处理这个引用) -->
589
+
590
+ <!-- Vendor 库(构建后 inline) -->
591
+ <script>/* sha256.min.js */
592
+ /**
593
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
594
+ *
595
+ * @version 1.0.0
596
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
597
+ * @copyright Chen, Yi-Cyuan 2014-2026
598
+ * @license MIT
599
+ */
600
+ !function(t,h){"object"==typeof exports&&"undefined"!=typeof module?module.exports=h():"function"==typeof define&&define.amd?define(h):(t="undefined"!=typeof globalThis?globalThis:t||self).sha256=h()}(this,function(){"use strict";var t="undefined"!=typeof ArrayBuffer,h=function(h){if("string"===typeof h)return[h,!0];if(Array.isArray(h))return[h,!1];if(t&&h){if(h.constructor===ArrayBuffer)return[new Uint8Array(h),!1];if(ArrayBuffer.isView(h))return[h,!1]}throw new Error("input is invalid type")},i="0123456789abcdef".split(""),s=[-2147483648,8388608,32768,128],e=[24,16,8,0],r=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=["hex","array","digest","arrayBuffer"],o=[],a=function(t,h){return function(i){return new c(h,!0).update(i)[t]()}},f=function(t){var h=a("hex",t);h.create=function(){return new c(t)},h.update=function(t){return h.create().update(t)};for(var i=0;i<n.length;++i){var s=n[i];h[s]=a(s,t)}return h},u=function(t,h){return function(i,s){return new y(i,h,!0).update(s)[t]()}},l=function(t){var h=u("hex",t);h.create=function(h){return new y(h,t)},h.update=function(t,i){return h.create(t).update(i)};for(var i=0;i<n.length;++i){var s=n[i];h[s]=u(s,t)}return h};function c(t,h){h?(o[0]=o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0,this.blocks=o):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function y(t,i,s){var e,r=h(t);if(t=r[0],r[1]){var n,o=[],a=t.length,f=0;for(e=0;e<a;++e)(n=t.charCodeAt(e))<128?o[f++]=n:n<2048?(o[f++]=192|n>>>6,o[f++]=128|63&n):n<55296||n>=57344?(o[f++]=224|n>>>12,o[f++]=128|n>>>6&63,o[f++]=128|63&n):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++e)),o[f++]=240|n>>>18,o[f++]=128|n>>>12&63,o[f++]=128|n>>>6&63,o[f++]=128|63&n);t=o}t.length>64&&(t=new c(i,!0).update(t).array());var u=[],l=[];for(e=0;e<64;++e){var y=t[e]||0;u[e]=92^y,l[e]=54^y}c.call(this,i,s),this.update(l),this.oKeyPad=u,this.inner=!0,this.sharedMemory=s}c.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var i=h(t);t=i[0];for(var s,r,n=i[1],o=0,a=t.length,f=this.blocks;o<a;){if(this.hashed&&(this.hashed=!1,f[0]=this.block,this.block=f[16]=f[1]=f[2]=f[3]=f[4]=f[5]=f[6]=f[7]=f[8]=f[9]=f[10]=f[11]=f[12]=f[13]=f[14]=f[15]=0),n)for(r=this.start;o<a&&r<64;++o)(s=t.charCodeAt(o))<128?f[r>>>2]|=s<<e[3&r++]:s<2048?(f[r>>>2]|=(192|s>>>6)<<e[3&r++],f[r>>>2]|=(128|63&s)<<e[3&r++]):s<55296||s>=57344?(f[r>>>2]|=(224|s>>>12)<<e[3&r++],f[r>>>2]|=(128|s>>>6&63)<<e[3&r++],f[r>>>2]|=(128|63&s)<<e[3&r++]):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++o)),f[r>>>2]|=(240|s>>>18)<<e[3&r++],f[r>>>2]|=(128|s>>>12&63)<<e[3&r++],f[r>>>2]|=(128|s>>>6&63)<<e[3&r++],f[r>>>2]|=(128|63&s)<<e[3&r++]);else for(r=this.start;o<a&&r<64;++o)f[r>>>2]|=t[o]<<e[3&r++];this.lastByteIndex=r,this.bytes+=r-this.start,r>=64?(this.block=f[16],this.start=r-64,this.hash(),this.hashed=!0):this.start=r}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},c.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,h=this.lastByteIndex;t[16]=this.block,t[h>>>2]|=s[3&h],this.block=t[16],h>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},c.prototype.hash=function(){var t,h,i,s,e,n,o,a,f,u=this.h0,l=this.h1,c=this.h2,y=this.h3,p=this.h4,d=this.h5,b=this.h6,v=this.h7,w=this.blocks;for(t=16;t<64;++t)h=((e=w[t-15])>>>7|e<<25)^(e>>>18|e<<14)^e>>>3,i=((e=w[t-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10,w[t]=w[t-16]+h+w[t-7]+i|0;for(f=l&c,t=0;t<64;t+=4)this.first?(this.is224?(n=300032,v=(e=w[0]-1413257819)-150054599|0,y=e+24177077|0):(n=704751109,v=(e=w[0]-210244248)-1521486534|0,y=e+143694565|0),this.first=!1):(h=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=(n=u&l)^u&c^f,v=y+(e=v+(i=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(p&d^~p&b)+r[t]+w[t])|0,y=e+(h+s)|0),h=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),s=(o=y&u)^y&l^n,b=c+(e=b+(i=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7))+(v&p^~v&d)+r[t+1]+w[t+1])|0,h=((c=e+(h+s)|0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),s=(a=c&y)^c&u^o,d=l+(e=d+(i=(b>>>6|b<<26)^(b>>>11|b<<21)^(b>>>25|b<<7))+(b&v^~b&p)+r[t+2]+w[t+2])|0,h=((l=e+(h+s)|0)>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),s=(f=l&c)^l&y^a,p=u+(e=p+(i=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(d&b^~d&v)+r[t+3]+w[t+3])|0,u=e+(h+s)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+u|0,this.h1=this.h1+l|0,this.h2=this.h2+c|0,this.h3=this.h3+y|0,this.h4=this.h4+p|0,this.h5=this.h5+d|0,this.h6=this.h6+b|0,this.h7=this.h7+v|0},c.prototype.hex=function(){this.finalize();var t=this.h0,h=this.h1,s=this.h2,e=this.h3,r=this.h4,n=this.h5,o=this.h6,a=this.h7,f=i[t>>>28&15]+i[t>>>24&15]+i[t>>>20&15]+i[t>>>16&15]+i[t>>>12&15]+i[t>>>8&15]+i[t>>>4&15]+i[15&t]+i[h>>>28&15]+i[h>>>24&15]+i[h>>>20&15]+i[h>>>16&15]+i[h>>>12&15]+i[h>>>8&15]+i[h>>>4&15]+i[15&h]+i[s>>>28&15]+i[s>>>24&15]+i[s>>>20&15]+i[s>>>16&15]+i[s>>>12&15]+i[s>>>8&15]+i[s>>>4&15]+i[15&s]+i[e>>>28&15]+i[e>>>24&15]+i[e>>>20&15]+i[e>>>16&15]+i[e>>>12&15]+i[e>>>8&15]+i[e>>>4&15]+i[15&e]+i[r>>>28&15]+i[r>>>24&15]+i[r>>>20&15]+i[r>>>16&15]+i[r>>>12&15]+i[r>>>8&15]+i[r>>>4&15]+i[15&r]+i[n>>>28&15]+i[n>>>24&15]+i[n>>>20&15]+i[n>>>16&15]+i[n>>>12&15]+i[n>>>8&15]+i[n>>>4&15]+i[15&n]+i[o>>>28&15]+i[o>>>24&15]+i[o>>>20&15]+i[o>>>16&15]+i[o>>>12&15]+i[o>>>8&15]+i[o>>>4&15]+i[15&o];return this.is224||(f+=i[a>>>28&15]+i[a>>>24&15]+i[a>>>20&15]+i[a>>>16&15]+i[a>>>12&15]+i[a>>>8&15]+i[a>>>4&15]+i[15&a]),f},c.prototype.toString=c.prototype.hex,c.prototype.digest=function(){this.finalize();var t=this.h0,h=this.h1,i=this.h2,s=this.h3,e=this.h4,r=this.h5,n=this.h6,o=this.h7,a=[t>>>24&255,t>>>16&255,t>>>8&255,255&t,h>>>24&255,h>>>16&255,h>>>8&255,255&h,i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s,e>>>24&255,e>>>16&255,e>>>8&255,255&e,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n];return this.is224||a.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o),a},c.prototype.array=c.prototype.digest,c.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),h=new DataView(t);return h.setUint32(0,this.h0),h.setUint32(4,this.h1),h.setUint32(8,this.h2),h.setUint32(12,this.h3),h.setUint32(16,this.h4),h.setUint32(20,this.h5),h.setUint32(24,this.h6),this.is224||h.setUint32(28,this.h7),t},y.prototype=new c,y.prototype.finalize=function(){if(c.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();c.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),c.prototype.finalize.call(this)}};var p=f(),d=f(!0);p.sha256=p,p.sha224=d,p.hmac=l(),d.hmac=l(!0);const b="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:void 0;return b&&(b.sha224=d),p});
601
+
602
+ </script>
603
+ <script>/* marked.min.js */
604
+ /**
605
+ * marked v12.0.2 - a markdown parser
606
+ * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
607
+ * https://github.com/markedjs/marked
608
+ */
609
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).marked={})}(this,(function(e){"use strict";function t(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function n(t){e.defaults=t}e.defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};const s=/[&<>"']/,r=new RegExp(s.source,"g"),i=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,l=new RegExp(i.source,"g"),o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=e=>o[e];function c(e,t){if(t){if(s.test(e))return e.replace(r,a)}else if(i.test(e))return e.replace(l,a);return e}const h=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function p(e){return e.replace(h,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const u=/(^|[^\[])\^/g;function k(e,t){let n="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let r="string"==typeof t?t:t.source;return r=r.replace(u,"$1"),n=n.replace(e,r),s},getRegex:()=>new RegExp(n,t)};return s}function g(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const f={exec:()=>null};function d(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let s=!1,r=t;for(;--r>=0&&"\\"===n[r];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function x(e,t,n){const s=e.length;if(0===s)return"";let r=0;for(;r<s;){const i=e.charAt(s-r-1);if(i!==t||n){if(i===t||!n)break;r++}else r++}return e.slice(0,s-r)}function b(e,t,n,s){const r=t.href,i=t.title?c(t.title):null,l=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:n,href:r,title:i,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,e}return{type:"image",raw:n,href:r,title:i,text:c(l)}}class w{options;rules;lexer;constructor(t){this.options=t||e.defaults}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:x(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const s=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=x(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,"\n $1");e=x(e.replace(/^ *>[ \t]?/gm,""),"\n");const n=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");const i=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let l="",o="",a=!1;for(;e;){let n=!1;if(!(t=i.exec(e)))break;if(this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,o=s.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,o=s.slice(h),h+=t[1].length);let p=!1;if(!s&&/^ *$/.test(c)&&(l+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const a=e.split("\n",1)[0];if(c=a,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),r.test(c))break;if(i.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=h||!c.trim())o+="\n"+c.slice(h);else{if(p)break;if(s.search(/[^ ]/)>=4)break;if(r.test(s))break;if(i.test(s))break;if(n.test(s))break;o+="\n"+c}p||c.trim()||(p=!0),l+=a+"\n",e=e.substring(a.length+1),s=c.slice(h)}}r.loose||(a?r.loose=!0:/\n *\n *$/.test(l)&&(a=!0));let u,k=null;this.options.gfm&&(k=/^\[[ xX]\] /.exec(o),k&&(u="[ ] "!==k[0],o=o.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:l,task:!!k,checked:u,loose:!1,text:o,tokens:[]}),r.raw+=l}r.items[r.items.length-1].raw=l.trimEnd(),r.items[r.items.length-1].text=o.trimEnd(),r.raw=r.raw.trimEnd();for(let e=0;e<r.items.length;e++)if(this.lexer.state.top=!1,r.items[e].tokens=this.lexer.blockTokens(r.items[e].text,[]),!r.loose){const t=r.items[e].tokens.filter((e=>"space"===e.type)),n=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));r.loose=n}if(r.loose)for(let e=0;e<r.items.length;e++)r.items[e].loose=!0;return r}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const n=d(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),r=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?i.align.push("right"):/^ *:-+: *$/.test(e)?i.align.push("center"):/^ *:-+ *$/.test(e)?i.align.push("left"):i.align.push(null);for(const e of n)i.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of r)i.rows.push(d(e,i.header.length).map((e=>({text:e,tokens:this.lexer.inline(e)}))));return i}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:c(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=x(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),b(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:s?s.replace(this.rules.inline.anyPunctuation,"$1"):s},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return b(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const n=[...s[0]].length-1;let r,i,l=n,o=0;const a="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+n);null!=(s=a.exec(t));){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(i=[...r].length,s[3]||s[4]){l+=i;continue}if((s[5]||s[6])&&n%3&&!((n+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);const t=[...s[0]][0].length,a=e.slice(0,n+s.index+t+i);if(Math.min(n,i)%2){const e=a.slice(1,-1);return{type:"em",raw:a,text:e,tokens:this.lexer.inlineTokens(e)}}const c=a.slice(2,-2);return{type:"strong",raw:a,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return n&&s&&(e=e.substring(1,e.length-1)),e=c(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=c(t[1]),n="mailto:"+e):(e=c(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=c(t[0]),n="mailto:"+e;else{let s;do{s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(s!==t[0]);e=c(t[0]),n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:c(t[0]),{type:"text",raw:t[0],text:e}}}}const m=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,y=/(?:[*+-]|\d{1,9}[.)])/,$=k(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,y).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),z=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,T=/(?!\s*\])(?:\\.|[^\[\]\\])+/,R=k(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",T).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_=k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,y).getRegex(),A="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",S=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,I=k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",S).replace("tag",A).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),E=k(z).replace("hr",m).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A).getRegex(),q={blockquote:k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",E).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:R,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:m,html:I,lheading:$,list:_,newline:/^(?: *(?:\n|$))+/,paragraph:E,table:f,text:/^[^\n]+/},Z=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",m).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A).getRegex(),L={...q,table:Z,paragraph:k(z).replace("hr",m).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Z).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A).getRegex()},P={...q,html:k("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",S).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:f,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(z).replace("hr",m).replace("heading"," *#{1,6} *[^\n]").replace("lheading",$).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Q=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,v=/^( {2,}|\\)\n(?!\s*$)/,B="\\p{P}\\p{S}",C=k(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,B).getRegex(),M=k(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,B).getRegex(),O=k("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,B).getRegex(),D=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,B).getRegex(),j=k(/\\([punct])/,"gu").replace(/punct/g,B).getRegex(),H=k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),U=k(S).replace("(?:--\x3e|$)","--\x3e").getRegex(),X=k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",U).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),F=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,N=k(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",F).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),G=k(/^!?\[(label)\]\[(ref)\]/).replace("label",F).replace("ref",T).getRegex(),J=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",T).getRegex(),K={_backpedal:f,anyPunctuation:j,autolink:H,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:v,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:f,emStrongLDelim:M,emStrongRDelimAst:O,emStrongRDelimUnd:D,escape:Q,link:N,nolink:J,punctuation:C,reflink:G,reflinkSearch:k("reflink|nolink(?!\\()","g").replace("reflink",G).replace("nolink",J).getRegex(),tag:X,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:f},V={...K,link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",F).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",F).getRegex()},W={...K,escape:k(Q).replace("])","~|])").getRegex(),url:k(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Y={...W,br:k(v).replace("{2,}","*").getRegex(),text:k(W.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ee={normal:q,gfm:L,pedantic:P},te={normal:K,gfm:W,breaks:Y,pedantic:V};class ne{tokens;options;state;tokenizer;inlineQueue;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||e.defaults,this.options.tokenizer=this.options.tokenizer||new w,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:ee.normal,inline:te.normal};this.options.pedantic?(n.block=ee.pedantic,n.inline=te.pedantic):this.options.gfm&&(n.block=ee.gfm,this.options.breaks?n.inline=te.breaks:n.inline=te.gfm),this.tokenizer.rules=n}static get rules(){return{block:ee,inline:te}}static lex(e,t){return new ne(t).lex(e)}static lexInline(e,t){return new ne(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){let n,s,r,i;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,n)=>t+" ".repeat(n.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(n):(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(s.raw+="\n"+n.raw,s.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(r=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r)))s=t[t.length-1],i&&"paragraph"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n),i=r.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s,r,i,l,o,a=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(a));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(a));)a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(a));)a=a.slice(0,i.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(l||(o=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,a,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(r=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(r))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),l=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class se{options;constructor(t){this.options=t||e.defaults}code(e,t,n){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+c(s)+'">'+(n?e:c(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:c(e,!0))+"</code></pre>\n"}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,n){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}list(e,t,n){const s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+s+">\n"}listitem(e,t,n){return`<li>${e}</li>\n`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>\n`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){const s=g(e);if(null===s)return n;let r='<a href="'+(e=s)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>",r}image(e,t,n){const s=g(e);if(null===s)return n;let r=`<img src="${e=s}" alt="${n}"`;return t&&(r+=` title="${t}"`),r+=">",r}text(e){return e}}class re{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class ie{options;renderer;textRenderer;constructor(t){this.options=t||e.defaults,this.options.renderer=this.options.renderer||new se,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new re}static parse(e,t){return new ie(t).parse(e)}static parseInline(e,t){return new ie(t).parseInline(e)}parse(e,t=!0){let n="";for(let s=0;s<e.length;s++){const r=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const e=r,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){n+=t||"";continue}}switch(r.type){case"space":continue;case"hr":n+=this.renderer.hr();continue;case"heading":{const e=r;n+=this.renderer.heading(this.parseInline(e.tokens),e.depth,p(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=r;n+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=r;let t="",s="";for(let t=0;t<e.header.length;t++)s+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(s);let i="";for(let t=0;t<e.rows.length;t++){const n=e.rows[t];s="";for(let t=0;t<n.length;t++)s+=this.renderer.tablecell(this.parseInline(n[t].tokens),{header:!1,align:e.align[t]});i+=this.renderer.tablerow(s)}n+=this.renderer.table(t,i);continue}case"blockquote":{const e=r,t=this.parse(e.tokens);n+=this.renderer.blockquote(t);continue}case"list":{const e=r,t=e.ordered,s=e.start,i=e.loose;let l="";for(let t=0;t<e.items.length;t++){const n=e.items[t],s=n.checked,r=n.task;let o="";if(n.task){const e=this.renderer.checkbox(!!s);i?n.tokens.length>0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):o+=e+" "}o+=this.parse(n.tokens,i),l+=this.renderer.listitem(o,r,!!s)}n+=this.renderer.list(l,t,s);continue}case"html":{const e=r;n+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=r;n+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let i=r,l=i.tokens?this.parseInline(i.tokens):i.text;for(;s+1<e.length&&"text"===e[s+1].type;)i=e[++s],l+="\n"+(i.tokens?this.parseInline(i.tokens):i.text);n+=t?this.renderer.paragraph(l):l;continue}default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let s=0;s<e.length;s++){const r=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}switch(r.type){case"escape":{const e=r;n+=t.text(e.text);break}case"html":{const e=r;n+=t.html(e.text);break}case"link":{const e=r;n+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=r;n+=t.image(e.href,e.title,e.text);break}case"strong":{const e=r;n+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=r;n+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=r;n+=t.codespan(e.text);break}case"br":n+=t.br();break;case"del":{const e=r;n+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=r;n+=t.text(e.text);break}default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}}class le{options;constructor(t){this.options=t||e.defaults}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}class oe{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(ne.lex,ie.parse);parseInline=this.#e(ne.lexInline,ie.parseInline);Parser=ie;Renderer=se;TextRenderer=re;Lexer=ne;Tokenizer=w;Hooks=le;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(const s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{const e=s;for(const s of e.header)n=n.concat(this.walkTokens(s.tokens,t));for(const s of e.rows)for(const e of s)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=s;n=n.concat(this.walkTokens(e.items,t));break}default:{const e=s;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((s=>{const r=e[s].flat(1/0);n=n.concat(this.walkTokens(r,t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=n.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new se(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if("options"===n)continue;const s=n,r=e.renderer[s],i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new w(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const s=n,r=e.tokenizer[s],i=t[s];t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new le;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if("options"===n)continue;const s=n,r=e.hooks[s],i=t[s];le.passThroughHooks.has(n)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then((e=>i.call(t,e)));const n=r.call(t,e);return i.call(t,n)}:t[s]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(s.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ne.lex(e,t??this.defaults)}parser(e,t){return ie.parse(e,t??this.defaults)}#e(e,t){return(n,s)=>{const r={...s},i={...this.defaults,...r};!0===this.defaults.async&&!1===r.async&&(i.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),i.async=!0);const l=this.#t(!!i.silent,!!i.async);if(null==n)return l(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i),i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then((t=>e(t,i))).then((e=>i.hooks?i.hooks.processAllTokens(e):e)).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>t(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(l);try{i.hooks&&(n=i.hooks.preprocess(n));let s=e(n,i);i.hooks&&(s=i.hooks.processAllTokens(s)),i.walkTokens&&this.walkTokens(s,i.walkTokens);let r=t(s,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return l(e)}}}#t(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+c(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}}const ae=new oe;function ce(e,t){return ae.parse(e,t)}ce.options=ce.setOptions=function(e){return ae.setOptions(e),ce.defaults=ae.defaults,n(ce.defaults),ce},ce.getDefaults=t,ce.defaults=e.defaults,ce.use=function(...e){return ae.use(...e),ce.defaults=ae.defaults,n(ce.defaults),ce},ce.walkTokens=function(e,t){return ae.walkTokens(e,t)},ce.parseInline=ae.parseInline,ce.Parser=ie,ce.parser=ie.parse,ce.Renderer=se,ce.TextRenderer=re,ce.Lexer=ne,ce.lexer=ne.lex,ce.Tokenizer=w,ce.Hooks=le,ce.parse=ce;const he=ce.options,pe=ce.setOptions,ue=ce.use,ke=ce.walkTokens,ge=ce.parseInline,fe=ce,de=ie.parse,xe=ne.lex;e.Hooks=le,e.Lexer=ne,e.Marked=oe,e.Parser=ie,e.Renderer=se,e.TextRenderer=re,e.Tokenizer=w,e.getDefaults=t,e.lexer=xe,e.marked=ce,e.options=he,e.parse=fe,e.parseInline=ge,e.parser=de,e.setOptions=pe,e.use=ue,e.walkTokens=ke}));
610
+
611
+ </script>
612
+ <script>/* purify.min.js */
613
+ /*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */
614
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;i||(i=function(e){return e}),a||(a=function(e){return e}),c||(c=function(e,t,n){return e.apply(t,n)}),s||(s=function(e,t){return new e(...t)});const u=R(Array.prototype.forEach),m=R(Array.prototype.lastIndexOf),p=R(Array.prototype.pop),f=R(Array.prototype.push),d=R(Array.prototype.splice),h=R(String.prototype.toLowerCase),g=R(String.prototype.toString),T=R(String.prototype.match),y=R(String.prototype.replace),E=R(String.prototype.indexOf),A=R(String.prototype.trim),_=R(Object.prototype.hasOwnProperty),S=R(RegExp.prototype.test),b=(N=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return s(N,t)});var N;function R(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return c(e,t,o)}}function w(e,o){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h;t&&t(e,null);let i=o.length;for(;i--;){let t=o[i];if("string"==typeof t){const e=r(t);e!==t&&(n(o)||(o[i]=e),t=e)}e[t]=!0}return e}function O(e){for(let t=0;t<e.length;t++){_(e,t)||(e[t]=null)}return e}function D(t){const n=l(null);for(const[o,r]of e(t)){_(t,o)&&(Array.isArray(r)?n[o]=O(r):r&&"object"==typeof r&&r.constructor===Object?n[o]=D(r):n[o]=r)}return n}function v(e,t){for(;null!==e;){const n=r(e,t);if(n){if(n.get)return R(n.get);if("function"==typeof n.value)return R(n.value)}e=o(e)}return function(){return null}}const L=i(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),C=i(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),x=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),I=i(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),M=i(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),k=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),U=i(["#text"]),z=i(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),P=i(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),H=i(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),F=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),B=a(/\{\{[\w\W]*|[\w\W]*\}\}/gm),W=a(/<%[\w\W]*|[\w\W]*%>/gm),G=a(/\$\{[\w\W]*/gm),Y=a(/^data-[\-\w.\u00B7-\uFFFF]+$/),j=a(/^aria-[\-\w]+$/),X=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),q=a(/^(?:\w+script|data):/i),$=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),K=a(/^html$/i),V=a(/^[a-z][.\w]*(-[.\w]+)+$/i);var Z=Object.freeze({__proto__:null,ARIA_ATTR:j,ATTR_WHITESPACE:$,CUSTOM_ELEMENT:V,DATA_ATTR:Y,DOCTYPE_NAME:K,ERB_EXPR:W,IS_ALLOWED_URI:X,IS_SCRIPT_OR_DATA:q,MUSTACHE_EXPR:B,TMPLIT_EXPR:G});const J=1,Q=3,ee=7,te=8,ne=9,oe=function(){return"undefined"==typeof window?null:window};var re=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:oe();const o=e=>t(e);if(o.version="3.2.6",o.removed=[],!n||!n.document||n.document.nodeType!==ne||!n.Element)return o.isSupported=!1,o;let{document:r}=n;const a=r,c=a.currentScript,{DocumentFragment:s,HTMLTemplateElement:N,Node:R,Element:O,NodeFilter:B,NamedNodeMap:W=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:G,DOMParser:Y,trustedTypes:j}=n,q=O.prototype,$=v(q,"cloneNode"),V=v(q,"remove"),re=v(q,"nextSibling"),ie=v(q,"childNodes"),ae=v(q,"parentNode");if("function"==typeof N){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let le,ce="";const{implementation:se,createNodeIterator:ue,createDocumentFragment:me,getElementsByTagName:pe}=r,{importNode:fe}=a;let de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};o.isSupported="function"==typeof e&&"function"==typeof ae&&se&&void 0!==se.createHTMLDocument;const{MUSTACHE_EXPR:he,ERB_EXPR:ge,TMPLIT_EXPR:Te,DATA_ATTR:ye,ARIA_ATTR:Ee,IS_SCRIPT_OR_DATA:Ae,ATTR_WHITESPACE:_e,CUSTOM_ELEMENT:Se}=Z;let{IS_ALLOWED_URI:be}=Z,Ne=null;const Re=w({},[...L,...C,...x,...M,...U]);let we=null;const Oe=w({},[...z,...P,...H,...F]);let De=Object.seal(l(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ve=null,Le=null,Ce=!0,xe=!0,Ie=!1,Me=!0,ke=!1,Ue=!0,ze=!1,Pe=!1,He=!1,Fe=!1,Be=!1,We=!1,Ge=!0,Ye=!1,je=!0,Xe=!1,qe={},$e=null;const Ke=w({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ve=null;const Ze=w({},["audio","video","img","source","image","track"]);let Je=null;const Qe=w({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let ot=nt,rt=!1,it=null;const at=w({},[et,tt,nt],g);let lt=w({},["mi","mo","mn","ms","mtext"]),ct=w({},["annotation-xml"]);const st=w({},["title","style","font","a","script"]);let ut=null;const mt=["application/xhtml+xml","text/html"];let pt=null,ft=null;const dt=r.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ft||ft!==e){if(e&&"object"==typeof e||(e={}),e=D(e),ut=-1===mt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,pt="application/xhtml+xml"===ut?g:h,Ne=_(e,"ALLOWED_TAGS")?w({},e.ALLOWED_TAGS,pt):Re,we=_(e,"ALLOWED_ATTR")?w({},e.ALLOWED_ATTR,pt):Oe,it=_(e,"ALLOWED_NAMESPACES")?w({},e.ALLOWED_NAMESPACES,g):at,Je=_(e,"ADD_URI_SAFE_ATTR")?w(D(Qe),e.ADD_URI_SAFE_ATTR,pt):Qe,Ve=_(e,"ADD_DATA_URI_TAGS")?w(D(Ze),e.ADD_DATA_URI_TAGS,pt):Ze,$e=_(e,"FORBID_CONTENTS")?w({},e.FORBID_CONTENTS,pt):Ke,ve=_(e,"FORBID_TAGS")?w({},e.FORBID_TAGS,pt):D({}),Le=_(e,"FORBID_ATTR")?w({},e.FORBID_ATTR,pt):D({}),qe=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,Ce=!1!==e.ALLOW_ARIA_ATTR,xe=!1!==e.ALLOW_DATA_ATTR,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Me=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ke=e.SAFE_FOR_TEMPLATES||!1,Ue=!1!==e.SAFE_FOR_XML,ze=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,Be=e.RETURN_DOM_FRAGMENT||!1,We=e.RETURN_TRUSTED_TYPE||!1,He=e.FORCE_BODY||!1,Ge=!1!==e.SANITIZE_DOM,Ye=e.SANITIZE_NAMED_PROPS||!1,je=!1!==e.KEEP_CONTENT,Xe=e.IN_PLACE||!1,be=e.ALLOWED_URI_REGEXP||X,ot=e.NAMESPACE||nt,lt=e.MATHML_TEXT_INTEGRATION_POINTS||lt,ct=e.HTML_INTEGRATION_POINTS||ct,De=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(De.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(De.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(De.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ke&&(xe=!1),Be&&(Fe=!0),qe&&(Ne=w({},U),we=[],!0===qe.html&&(w(Ne,L),w(we,z)),!0===qe.svg&&(w(Ne,C),w(we,P),w(we,F)),!0===qe.svgFilters&&(w(Ne,x),w(we,P),w(we,F)),!0===qe.mathMl&&(w(Ne,M),w(we,H),w(we,F))),e.ADD_TAGS&&(Ne===Re&&(Ne=D(Ne)),w(Ne,e.ADD_TAGS,pt)),e.ADD_ATTR&&(we===Oe&&(we=D(we)),w(we,e.ADD_ATTR,pt)),e.ADD_URI_SAFE_ATTR&&w(Je,e.ADD_URI_SAFE_ATTR,pt),e.FORBID_CONTENTS&&($e===Ke&&($e=D($e)),w($e,e.FORBID_CONTENTS,pt)),je&&(Ne["#text"]=!0),ze&&w(Ne,["html","head","body"]),Ne.table&&(w(Ne,["tbody"]),delete ve.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw b('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');le=e.TRUSTED_TYPES_POLICY,ce=le.createHTML("")}else void 0===le&&(le=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(j,c)),null!==le&&"string"==typeof ce&&(ce=le.createHTML(""));i&&i(e),ft=e}},Tt=w({},[...C,...x,...I]),yt=w({},[...M,...k]),Et=function(e){f(o.removed,{element:e});try{ae(e).removeChild(e)}catch(t){V(e)}},At=function(e,t){try{f(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Fe||Be)try{Et(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},_t=function(e){let t=null,n=null;if(He)e="<remove></remove>"+e;else{const t=T(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ut&&ot===nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=le?le.createHTML(e):e;if(ot===nt)try{t=(new Y).parseFromString(o,ut)}catch(e){}if(!t||!t.documentElement){t=se.createDocument(ot,"template",null);try{t.documentElement.innerHTML=rt?ce:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),ot===nt?pe.call(t,ze?"html":"body")[0]:ze?t.documentElement:i},St=function(e){return ue.call(e.ownerDocument||e,e,B.SHOW_ELEMENT|B.SHOW_COMMENT|B.SHOW_TEXT|B.SHOW_PROCESSING_INSTRUCTION|B.SHOW_CDATA_SECTION,null)},bt=function(e){return e instanceof G&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof W)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Nt=function(e){return"function"==typeof R&&e instanceof R};function Rt(e,t,n){u(e,(e=>{e.call(o,t,n,ft)}))}const wt=function(e){let t=null;if(Rt(de.beforeSanitizeElements,e,null),bt(e))return Et(e),!0;const n=pt(e.nodeName);if(Rt(de.uponSanitizeElement,e,{tagName:n,allowedTags:Ne}),Ue&&e.hasChildNodes()&&!Nt(e.firstElementChild)&&S(/<[/\w!]/g,e.innerHTML)&&S(/<[/\w!]/g,e.textContent))return Et(e),!0;if(e.nodeType===ee)return Et(e),!0;if(Ue&&e.nodeType===te&&S(/<[/\w]/g,e.data))return Et(e),!0;if(!Ne[n]||ve[n]){if(!ve[n]&&Dt(n)){if(De.tagNameCheck instanceof RegExp&&S(De.tagNameCheck,n))return!1;if(De.tagNameCheck instanceof Function&&De.tagNameCheck(n))return!1}if(je&&!$e[n]){const t=ae(e)||e.parentNode,n=ie(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o){const r=$(n[o],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,re(e))}}}return Et(e),!0}return e instanceof O&&!function(e){let t=ae(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=h(e.tagName),o=h(t.tagName);return!!it[e.namespaceURI]&&(e.namespaceURI===tt?t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===o||lt[o]):Boolean(Tt[n]):e.namespaceURI===et?t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&ct[o]:Boolean(yt[n]):e.namespaceURI===nt?!(t.namespaceURI===tt&&!ct[o])&&!(t.namespaceURI===et&&!lt[o])&&!yt[n]&&(st[n]||!Tt[n]):!("application/xhtml+xml"!==ut||!it[e.namespaceURI]))}(e)?(Et(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!S(/<\/no(script|embed|frames)/i,e.innerHTML)?(ke&&e.nodeType===Q&&(t=e.textContent,u([he,ge,Te],(e=>{t=y(t,e," ")})),e.textContent!==t&&(f(o.removed,{element:e.cloneNode()}),e.textContent=t)),Rt(de.afterSanitizeElements,e,null),!1):(Et(e),!0)},Ot=function(e,t,n){if(Ge&&("id"===t||"name"===t)&&(n in r||n in dt))return!1;if(xe&&!Le[t]&&S(ye,t));else if(Ce&&S(Ee,t));else if(!we[t]||Le[t]){if(!(Dt(e)&&(De.tagNameCheck instanceof RegExp&&S(De.tagNameCheck,e)||De.tagNameCheck instanceof Function&&De.tagNameCheck(e))&&(De.attributeNameCheck instanceof RegExp&&S(De.attributeNameCheck,t)||De.attributeNameCheck instanceof Function&&De.attributeNameCheck(t))||"is"===t&&De.allowCustomizedBuiltInElements&&(De.tagNameCheck instanceof RegExp&&S(De.tagNameCheck,n)||De.tagNameCheck instanceof Function&&De.tagNameCheck(n))))return!1}else if(Je[t]);else if(S(be,y(n,_e,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==E(n,"data:")||!Ve[e]){if(Ie&&!S(Ae,y(n,_e,"")));else if(n)return!1}else;return!0},Dt=function(e){return"annotation-xml"!==e&&T(e,Se)},vt=function(e){Rt(de.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||bt(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we,forceKeepAttr:void 0};let r=t.length;for(;r--;){const i=t[r],{name:a,namespaceURI:l,value:c}=i,s=pt(a),m=c;let f="value"===a?m:A(m);if(n.attrName=s,n.attrValue=f,n.keepAttr=!0,n.forceKeepAttr=void 0,Rt(de.uponSanitizeAttribute,e,n),f=n.attrValue,!Ye||"id"!==s&&"name"!==s||(At(a,e),f="user-content-"+f),Ue&&S(/((--!?|])>)|<\/(style|title)/i,f)){At(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){At(a,e);continue}if(!Me&&S(/\/>/i,f)){At(a,e);continue}ke&&u([he,ge,Te],(e=>{f=y(f,e," ")}));const d=pt(e.nodeName);if(Ot(d,s,f)){if(le&&"object"==typeof j&&"function"==typeof j.getAttributeType)if(l);else switch(j.getAttributeType(d,s)){case"TrustedHTML":f=le.createHTML(f);break;case"TrustedScriptURL":f=le.createScriptURL(f)}if(f!==m)try{l?e.setAttributeNS(l,a,f):e.setAttribute(a,f),bt(e)?Et(e):p(o.removed)}catch(t){At(a,e)}}else At(a,e)}Rt(de.afterSanitizeAttributes,e,null)},Lt=function e(t){let n=null;const o=St(t);for(Rt(de.beforeSanitizeShadowDOM,t,null);n=o.nextNode();)Rt(de.uponSanitizeShadowNode,n,null),wt(n),vt(n),n.content instanceof s&&e(n.content);Rt(de.afterSanitizeShadowDOM,t,null)};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,i=null,l=null;if(rt=!e,rt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Nt(e)){if("function"!=typeof e.toString)throw b("toString is not a function");if("string"!=typeof(e=e.toString()))throw b("dirty is not a string, aborting")}if(!o.isSupported)return e;if(Pe||gt(t),o.removed=[],"string"==typeof e&&(Xe=!1),Xe){if(e.nodeName){const t=pt(e.nodeName);if(!Ne[t]||ve[t])throw b("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof R)n=_t("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),r.nodeType===J&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r);else{if(!Fe&&!ke&&!ze&&-1===e.indexOf("<"))return le&&We?le.createHTML(e):e;if(n=_t(e),!n)return Fe?null:We?ce:""}n&&He&&Et(n.firstChild);const c=St(Xe?e:n);for(;i=c.nextNode();)wt(i),vt(i),i.content instanceof s&&Lt(i.content);if(Xe)return e;if(Fe){if(Be)for(l=me.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(we.shadowroot||we.shadowrootmode)&&(l=fe.call(a,l,!0)),l}let m=ze?n.outerHTML:n.innerHTML;return ze&&Ne["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&S(K,n.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+m),ke&&u([he,ge,Te],(e=>{m=y(m,e," ")})),le&&We?le.createHTML(m):m},o.setConfig=function(){gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Pe=!0},o.clearConfig=function(){ft=null,Pe=!1},o.isValidAttribute=function(e,t,n){ft||gt({});const o=pt(e),r=pt(t);return Ot(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&f(de[e],t)},o.removeHook=function(e,t){if(void 0!==t){const n=m(de[e],t);return-1===n?void 0:d(de[e],n,1)[0]}return p(de[e])},o.removeHooks=function(e){de[e]=[]},o.removeAllHooks=function(){de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},o}();return re}));
615
+ //# sourceMappingURL=purify.min.js.map
616
+
617
+ </script>
618
+ <!-- 运行时脚本(构建后 inline) -->
619
+ <script>/* runtime/content/work-bridge.js */
620
+ /* ============================================================
621
+ * work-bridge.js —— 作品沙箱 WorkBridge(2026-09-20 作品沙箱裁定)
622
+ * ------------------------------------------------------------
623
+ * 作品代码的影响面结构性局限在作品范围内:WorkView 舞台不再主文档
624
+ * execWorkCode,改为 opaque origin 沙箱 iframe(sandbox 无
625
+ * allow-same-origin:同源 cookie / storage / 主文档 DOM / 平台 API /
626
+ * window.open / 顶层导航一律被浏览器封死)。作品对后端的唯一通道 =
627
+ * 本文件提供的 postMessage 桥:
628
+ *
629
+ * 父侧(平台,可信):createSession —— 白名单校验(清单单一真源 =
630
+ * services/work_bridge.py::compat_allow_rules,经 manifest 下发,
631
+ * 此处禁手抄第二份)+ 同源请求凭据 + 工作凭据(X-Work-Token,
632
+ * 服务端钉版 work/user)。**token 永不进 iframe**。
633
+ * iframe 侧(作品,不可信):bootstrapDocument 生成的引导文档 ——
634
+ * fetch/XHR 兼容代理(白名单外显式拒绝)、localStorage 与 sessionStorage
635
+ * 假面(会话内存实现)、ctx/Work/WorkCaps 装配(作品侧契约面零变化)、
636
+ * 就绪探测与 Escape 中继。
637
+ *
638
+ * 协议(每次启动随机 channel id,父侧验 event.source + channel):
639
+ * iframe→parent {type:'op',op,id,payload} / {type:'ready'|'hold'|
640
+ * 'settled'|'loaded'|'error'|'esc'|'destroyed', ...} / {type:'navigating'}
641
+ * (自导航开始,2026-09-24:父侧据此作废旧文档时代的 ready/settled
642
+ * ——门作品 mount 里先 ctx.ready() 再 location.replace 的旧补救不再
643
+ * 提前揭盖)/ {type:'ui',action}
644
+ * (ui = 声明式 UI 动作,2026-09-22:免 channel,验 source +
645
+ * manifest ui_actions 枚举;执行在容器 onUiAction 回调)
646
+ * (loaded = 装载完成探测,2026-10-12 用户裁定「探测到加载完成再
647
+ * 揭开」:mount 完成 ∧ 桥在途往返归零 ∧ 媒体首帧 ∧ 字体就绪,桥侧
648
+ * 信号聚合后单发一次;父侧就绪门与 settled 合取消费)
649
+ * parent→iframe {type:'reply',id,...} / {type:'bounds',w,h} /
650
+ * {type:'destroy'} / {type:'fw:theme',mode:'light'|'dark'}
651
+ * (主题下发,2026-09-22:免 channel——门作品自导航后 iframe 内是
652
+ * 应用自己的页,同 ui 分支信任锚 = event.source 舞台钉;主题非秘密
653
+ * (主站 <html data-theme> 公开属性),只答 light|dark 两值)
654
+ * iframe→parent {type:'theme-query'}(免 channel:任意时刻问当前主题,
655
+ * 父侧回 fw:theme——应用页装载晚于父侧推送时的补拉口)
656
+ * iframe→parent {type:'fw:app-ready'}(免 channel,2026-09-24:应用页
657
+ * 首帧真正渲染完成后上报(非 load 事件——load 只代表资源到位);
658
+ * 信任锚同 ui/theme-query = event.source 舞台钉。容器就绪门对自导航
659
+ * 应用据此精确揭盖;未上报的应用回落 load≥2 + 沉淀窗)
660
+ * iframe→parent {type:'fw:app-failed', message}(免 channel,2026-09-24
661
+ * 统一失败卡:服务端标准失败页自报「应用页失败」——自导航落进死地址
662
+ * 时 work_failure.html 上报,容器据此立即换上统一错误态 .xv-error,
663
+ * 不等 CAP/沉淀窗慢慢揭出失败页本体;信任锚同 fw:app-ready)
664
+ *
665
+ * 幂等单例(window.X = window.X || IIFE 纪律);bundle 装载顺序:
666
+ * 本文件先于 work-view.js(BUNDLES 单一真源 app/static_bundles.py)。
667
+ * 细则 = docs/work-sandbox.md;静态钉版 = tests/checks/check_work_sandbox.py。
668
+ * ============================================================ */
669
+ window.WorkBridge = window.WorkBridge || (function () {
670
+ 'use strict';
671
+
672
+ /* 沙箱能力位:无 allow-same-origin(opaque origin 是整条边界的地基)、
673
+ 无 allow-popups / allow-top-navigation / allow-forms。 */
674
+ var SANDBOX_TOKEN = 'allow-scripts allow-pointer-lock allow-downloads';
675
+
676
+ /* ---------- 引导文档构建(父侧调用) ---------- */
677
+
678
+ /* JSON 内嵌防 <\/script> 逃逸:序列化后把 < 转义为 \u003c。 */
679
+ function _j(safe) {
680
+ return JSON.stringify(safe).replace(/</g, '\\u003c');
681
+ }
682
+
683
+ /* 引导文档内联样式:舞台铺满 + 交互封口(与容器级 user-select:none
684
+ 同口径;input/textarea/contenteditable 例外放行)。选择/长按封口
685
+ 挂整文档级(2026-10-13 用户裁定:屏蔽长按复制选中)——作品内容
686
+ 不必然落在 .wb-stage 子树(可直挂 body),舞台级口径会漏。
687
+ user-select 与 touch-callout 都是**非继承属性**,iOS WebKit 对
688
+ auto 向上解析在 srcdoc 沙箱内不可靠(实测 html,body 级压不住
689
+ 长按选中),星选择子逐元素钉死 + !important 防 legacy 文档自带
690
+ CSS 级联回去(作品刻意要可选中 = 自己的 !important 后到胜出,
691
+ 逃生口保留;editable 及其后代放行照旧)。 */
692
+ var BOOT_CSS = 'html,body{margin:0;padding:0;width:100%;height:100%;'
693
+ + 'overflow:hidden;background:transparent;}'
694
+ + 'html,body{user-select:none !important;'
695
+ + '-webkit-user-select:none !important;}'
696
+ + '*{user-select:none !important;'
697
+ + '-webkit-user-select:none !important;'
698
+ + '-webkit-touch-callout:none !important;}'
699
+ + 'input,textarea,[contenteditable],[contenteditable] *'
700
+ + '{user-select:text !important;-webkit-user-select:text !important;}'
701
+ + '.wb-stage{position:absolute;inset:0;overflow:hidden;'
702
+ + 'display:flex;align-items:stretch;justify-content:stretch;}';
703
+
704
+ function bootstrapDocument(opts) {
705
+ var cfg = { channel: opts.channel, origin: opts.origin,
706
+ work: { id: opts.workId, ref: opts.workRef || '' },
707
+ version: opts.version || 0,
708
+ viewDoc: opts.viewDoc || '' };
709
+ var codes = { caps: opts.capsCode || null,
710
+ entry: opts.entryCode || '' };
711
+ return '<!doctype html><html><head><meta charset="utf-8">'
712
+ + '<meta name="referrer" content="no-referrer">'
713
+ + '<style>' + BOOT_CSS + '</style></head>'
714
+ + '<body><div id="stage" class="wb-stage"></div><script>'
715
+ + 'window.__CFG=' + _j(cfg) + ';window.__CODES=' + _j(codes) + ';\n'
716
+ + '(' + bootstrapMain.toString() + ')();\n'
717
+ + '<\/script></body></html>';
718
+ }
719
+
720
+ /* ---------- iframe 侧引导程序(字符串化注入,零闭包引用) ----------
721
+ 结构性约束:本函数体内不得引用模块作用域(toString 后脱离原闭包),
722
+ 全部依赖 window.__CFG / window.__CODES 注入。 */
723
+ function bootstrapMain() {
724
+ 'use strict';
725
+ var CFG = window.__CFG;
726
+ var CODES = window.__CODES;
727
+ var CH = CFG.channel;
728
+ var seq = 1;
729
+ var pending = Object.create(null);
730
+ var def = null;
731
+ var defDone = false;
732
+ var settledSent = false;
733
+ var destroyed = false;
734
+
735
+ /* ---------- 装载完成探测(2026-10-12 用户裁定「探测到加载完成再
736
+ 揭开」):盲等固定窗换真信号聚合——mount 完成 ∧ 桥在途往返
737
+ (fetch/XHR 兼容代理)归零 ∧ 舞台媒体首帧解码(img/video,含
738
+ new Image() 预载)∧ 字体就绪,全落定上报 loaded(父侧就绪门
739
+ 消费:settled ∧ loaded ∧ 短确认窗揭开)。信号面外(纯定时器
740
+ 换画、声明 hold 后的续载)探测不到,确认窗/CAP 兜底照旧;
741
+ 权威声明通道 ctx.ready()/hold() 语义不变。 */
742
+ var mountDone = false;
743
+ var loadDoneSent = false;
744
+ var loadPending = 0;
745
+ function loadTick() {
746
+ if (destroyed || loadDoneSent || !mountDone || !settledSent) return;
747
+ if (loadPending <= 0) {
748
+ loadDoneSent = true;
749
+ post({ type: 'loaded' });
750
+ }
751
+ }
752
+ function trackLoad() { loadPending++; }
753
+ function untrackLoad() {
754
+ loadPending--;
755
+ if (loadPending <= 0) { loadPending = 0; loadTick(); }
756
+ }
757
+ /* 媒体首帧就绪追踪:img = load/error;video = loadeddata/error;
758
+ 各带兜底超时(坏 URL 不至于把揭开拖到 CAP)。 */
759
+ function trackMedia(el) {
760
+ if (destroyed || !el || el.nodeType !== 1) return;
761
+ var tag = el.tagName;
762
+ if (tag === 'IMG') {
763
+ if (el.complete && el.naturalWidth > 0) return;
764
+ } else if (tag === 'VIDEO') {
765
+ if (el.readyState >= 2) return;
766
+ } else {
767
+ return;
768
+ }
769
+ var done = false;
770
+ function finish() {
771
+ if (done) return;
772
+ done = true;
773
+ el.removeEventListener('load', finish);
774
+ el.removeEventListener('loadeddata', finish);
775
+ el.removeEventListener('error', finish);
776
+ untrackLoad();
777
+ }
778
+ trackLoad();
779
+ el.addEventListener(tag === 'IMG' ? 'load' : 'loadeddata', finish);
780
+ el.addEventListener('error', finish);
781
+ setTimeout(finish, 4000);
782
+ }
783
+
784
+ function post(msg) {
785
+ msg.channel = CH;
786
+ try { parent.postMessage(msg, '*'); } catch (e) { /* 父已离场 */ }
787
+ }
788
+ function call(op, payload) {
789
+ trackLoad();
790
+ return new Promise(function (resolve) {
791
+ var id = seq++;
792
+ pending[id] = function (rep) { untrackLoad(); resolve(rep); };
793
+ post({ type: 'op', op: op, id: id, payload: payload || {} });
794
+ });
795
+ }
796
+
797
+ /* ---------- 协议下行 ---------- */
798
+ window.addEventListener('message', function (ev) {
799
+ var d = ev.data;
800
+ if (!d || d.channel !== CH) return;
801
+ if (d.type === 'reply') {
802
+ var f = pending[d.id];
803
+ if (f) { delete pending[d.id]; f(d); }
804
+ return;
805
+ }
806
+ if (d.type === 'bounds' && ctx) {
807
+ ctx.bounds = { w: d.w, h: d.h };
808
+ for (var i = 0; i < _emitBounds.length; i++) {
809
+ try { _emitBounds[i](ctx.bounds); } catch (e) { /* 观察者失败不打断 */ }
810
+ }
811
+ } else if (d.type === 'destroy') {
812
+ doDestroy();
813
+ }
814
+ });
815
+
816
+ function fail(message) {
817
+ post({ type: 'error', message: String(message || '作品装载失败') });
818
+ }
819
+ window.addEventListener('error', function (e) {
820
+ fail((e && e.message) || '作品运行错误');
821
+ });
822
+ window.addEventListener('unhandledrejection', function (e) {
823
+ var r = e && e.reason;
824
+ fail((r && (r.message || String(r))) || '未处理的 Promise 拒绝');
825
+ });
826
+
827
+ /* ---------- 原生右键/长按菜单屏蔽(2026-10-13 用户裁定):
828
+ 容器内默认零原生 contextmenu(桌面右键菜单与 Android 长按菜单
829
+ 同源事件)。捕获相注册(先于作品监听)且只 preventDefault、
830
+ 不 stopPropagation——作品自实现右键(自身 contextmenu 监听
831
+ 自绘菜单)不受任何影响。 */
832
+ document.addEventListener('contextmenu', function (e) {
833
+ e.preventDefault();
834
+ }, true);
835
+
836
+ /* ---------- 封口透传:嵌套 srcdoc 文档(2026-10-13 补口)。
837
+ 「容器」语义 = 舞台内平台渲染的一切文档层——legacy 兼容包装层
838
+ (legacy_stage_compat 机械包装,1563 版本行存量)与作品自建
839
+ 子文档都是引导文档之内的**第二个文档**:嵌套 iframe 为独立
840
+ opaque origin,contentDocument 跨源不可访问,事后注入不可能;
841
+ 唯一可靠单点 = srcdoc 赋值时刻把同款封口(CSS + contextmenu
842
+ 捕获拦截)拼进文档头。属性 setter 与 setAttribute 双路径包装
843
+ (与 fetch/XHR/Image 补丁同一既有模式)。已知边界:src/blob
844
+ URL 形嵌套文档无赋值钩,透传不到(如实降级)。 */
845
+ var SEAL_CSS = 'html,body{user-select:none !important;'
846
+ + '-webkit-user-select:none !important;}'
847
+ + '*{user-select:none !important;'
848
+ + '-webkit-user-select:none !important;'
849
+ + '-webkit-touch-callout:none !important;}'
850
+ + 'input,textarea,[contenteditable],[contenteditable] *'
851
+ + '{user-select:text !important;'
852
+ + '-webkit-user-select:text !important;}';
853
+ function sealNestedDoc(html) {
854
+ var seal = '<style>' + SEAL_CSS + '</style>'
855
+ + '<script>(function(){'
856
+ + 'document.addEventListener("contextmenu",'
857
+ + 'function(e){e.preventDefault();},true);})();'
858
+ + '<\/script>';
859
+ var s = String(html);
860
+ var m = /<head[^>]*>/i.exec(s);
861
+ if (m) {
862
+ var at = m.index + m[0].length;
863
+ return s.slice(0, at) + seal + s.slice(at);
864
+ }
865
+ return seal + s;
866
+ }
867
+ try {
868
+ var frameProto = HTMLIFrameElement.prototype;
869
+ var srcdocDesc = Object.getOwnPropertyDescriptor(
870
+ frameProto, 'srcdoc');
871
+ if (srcdocDesc && srcdocDesc.set) {
872
+ Object.defineProperty(frameProto, 'srcdoc', {
873
+ configurable: true, enumerable: srcdocDesc.enumerable,
874
+ get: function () { return srcdocDesc.get.call(this); },
875
+ set: function (v) {
876
+ srcdocDesc.set.call(this, sealNestedDoc(v));
877
+ },
878
+ });
879
+ }
880
+ } catch (e) { /* 原型不可补丁的极端环境:属性路径降级 */ }
881
+ try {
882
+ var origSetAttr = Element.prototype.setAttribute;
883
+ Element.prototype.setAttribute = function (name, value) {
884
+ if (this.tagName === 'IFRAME'
885
+ && String(name).toLowerCase() === 'srcdoc') {
886
+ value = sealNestedDoc(value);
887
+ }
888
+ return origSetAttr.call(this, name, value);
889
+ };
890
+ } catch (e) { /* 同上:setAttribute 路径降级 */ }
891
+
892
+ /* ---------- URL 解析:相对路径对平台 origin 解析(srcdoc 的
893
+ baseURI 是 about:srcdoc,相对端点必须显式锚定) ---------- */
894
+ function resolveUrl(u) {
895
+ try { return new URL(String(u), CFG.origin + '/'); } catch (e) { return null; }
896
+ }
897
+ function normalizeHeaders(h) {
898
+ var out = {};
899
+ if (!h) return out;
900
+ if (typeof Headers !== 'undefined' && h instanceof Headers) {
901
+ h.forEach(function (v, k) { out[k] = v; });
902
+ return out;
903
+ }
904
+ for (var k in h) {
905
+ if (Object.prototype.hasOwnProperty.call(h, k)) out[k] = String(h[k]);
906
+ }
907
+ return out;
908
+ }
909
+
910
+ /* ---------- fetch 兼容代理:白名单外父侧显式拒绝(fetch reject),
911
+ 响应重建为标准 Response(文本体;流式/二进制体不支持) ---------- */
912
+ window.fetch = function (input, init) {
913
+ init = init || {};
914
+ var url, method = String(init.method || 'GET').toUpperCase();
915
+ var headers = normalizeHeaders(init.headers);
916
+ var body = init.body;
917
+ if (input && typeof input === 'object' && input.url) {
918
+ url = String(input.url);
919
+ method = String(init.method || input.method || 'GET').toUpperCase();
920
+ headers = normalizeHeaders(init.headers || input.headers);
921
+ if (body === undefined && input.body !== undefined) body = input.body;
922
+ } else {
923
+ url = String(input);
924
+ }
925
+ var u = resolveUrl(url);
926
+ if (!u) return Promise.reject(new TypeError('fetch: URL 非法'));
927
+ if (u.origin !== CFG.origin) {
928
+ return Promise.reject(new TypeError(
929
+ 'work-bridge: 仅允许同源端点(' + u.origin + ')'));
930
+ }
931
+ if (body && typeof body !== 'string') {
932
+ return Promise.reject(new TypeError(
933
+ 'work-bridge: 请求体仅支持文本/JSON(' + (body && body.constructor && body.constructor.name) + ' 不支持)'));
934
+ }
935
+ return call('fetch', { method: method, path: u.pathname + u.search,
936
+ headers: headers, body: body || '' })
937
+ .then(function (rep) {
938
+ if (rep.err) throw new TypeError(rep.err);
939
+ var hd = new Headers();
940
+ var rh = rep.headers || {};
941
+ Object.keys(rh).forEach(function (k) { hd.set(k, rh[k]); });
942
+ return new Response(rep.text == null ? '' : rep.text,
943
+ { status: rep.status || 0, statusText: rep.statusText || '',
944
+ headers: hd });
945
+ });
946
+ };
947
+
948
+ /* ---------- XMLHttpRequest 兼容代理(子集:open/setRequestHeader/
949
+ send/status/responseText/onload·onerror·onreadystatechange/
950
+ addEventListener;responseXML/同步阻塞/进度事件不支持) ---------- */
951
+ function BridgeXHR() {
952
+ this.readyState = 0;
953
+ this._hdrs = {};
954
+ this._listeners = Object.create(null);
955
+ }
956
+ BridgeXHR.prototype.open = function (m, u) {
957
+ this._method = String(m || 'GET').toUpperCase();
958
+ this._url = String(u || '');
959
+ };
960
+ BridgeXHR.prototype.setRequestHeader = function (k, v) {
961
+ this._hdrs[String(k)] = String(v);
962
+ };
963
+ BridgeXHR.prototype.abort = function () { /* 桥通道不支持中途取消 */ };
964
+ BridgeXHR.prototype.getAllResponseHeaders = function () {
965
+ return this._rheaders || '';
966
+ };
967
+ BridgeXHR.prototype.getResponseHeader = function (k) {
968
+ var h = this._hmap || {};
969
+ return h[String(k).toLowerCase()] != null
970
+ ? h[String(k).toLowerCase()] : null;
971
+ };
972
+ BridgeXHR.prototype.addEventListener = function (t, fn) {
973
+ (this._listeners[t] = this._listeners[t] || []).push(fn);
974
+ };
975
+ BridgeXHR.prototype.removeEventListener = function (t, fn) {
976
+ var l = this._listeners[t] || [];
977
+ var i = l.indexOf(fn);
978
+ if (i !== -1) l.splice(i, 1);
979
+ };
980
+ BridgeXHR.prototype._fire = function (t, ev) {
981
+ var self = this;
982
+ (this._listeners[t] || []).forEach(function (fn) {
983
+ try { fn(ev || { target: self }); } catch (e) { /* 观察者失败不打断 */ }
984
+ });
985
+ var direct = this['on' + t];
986
+ if (typeof direct === 'function') {
987
+ try { direct(ev || { target: self }); } catch (e) { /* 同上 */ }
988
+ }
989
+ };
990
+ BridgeXHR.prototype.send = function (body) {
991
+ var self = this;
992
+ var u = resolveUrl(this._url);
993
+ if (!u || u.origin !== CFG.origin) {
994
+ setTimeout(function () {
995
+ self.status = 0;
996
+ self.readyState = 4;
997
+ self._fire('error');
998
+ self._fire('loadend');
999
+ }, 0);
1000
+ return;
1001
+ }
1002
+ call('fetch', { method: this._method, path: u.pathname + u.search,
1003
+ headers: this._hdrs, body: body == null ? '' : String(body) })
1004
+ .then(function (rep) {
1005
+ if (rep.err) {
1006
+ self.status = 0;
1007
+ self.readyState = 4;
1008
+ self._fire('readystatechange');
1009
+ self._fire('error');
1010
+ self._fire('loadend');
1011
+ return;
1012
+ }
1013
+ self.status = rep.status || 0;
1014
+ self.statusText = rep.statusText || '';
1015
+ self.responseText = rep.text == null ? '' : rep.text;
1016
+ self.response = self.responseText;
1017
+ self.responseURL = u.href;
1018
+ self._hmap = {};
1019
+ var lines = [];
1020
+ var rh = rep.headers || {};
1021
+ Object.keys(rh).forEach(function (k) {
1022
+ self._hmap[k.toLowerCase()] = rh[k];
1023
+ lines.push(k + ': ' + rh[k]);
1024
+ });
1025
+ self._rheaders = lines.join('\r\n');
1026
+ self.readyState = 4;
1027
+ self._fire('readystatechange');
1028
+ self._fire('load');
1029
+ self._fire('loadend');
1030
+ });
1031
+ };
1032
+ window.XMLHttpRequest = BridgeXHR;
1033
+
1034
+ /* ---------- 媒体装载追踪面 ----------
1035
+ ① new Image() 预载(canvas 游戏主流形态:解码完成才画首帧):
1036
+ 构造器包一层登记(返回原生实例,原型链不变)。
1037
+ ② 舞台内挂载的 img/video(MutationObserver,含整子树挂入):
1038
+ 首帧解码计入在途装载。字体(document.fonts.ready)同理,带
1039
+ 2.5s 兜底(字体 URL 停滞不把揭开拖到 CAP)。 */
1040
+ var _NativeImage = window.Image;
1041
+ function PatchedImage(w, h) {
1042
+ var el = (w === undefined)
1043
+ ? new _NativeImage() : new _NativeImage(w, h);
1044
+ trackMedia(el);
1045
+ return el;
1046
+ }
1047
+ PatchedImage.prototype = _NativeImage.prototype;
1048
+ window.Image = PatchedImage;
1049
+
1050
+ var _stage = null;
1051
+ function armStageMediaObserver() {
1052
+ if (!_stage) return;
1053
+ new MutationObserver(function (muts) {
1054
+ for (var i = 0; i < muts.length; i++) {
1055
+ var add = muts[i].addedNodes;
1056
+ for (var j = 0; j < add.length; j++) {
1057
+ var n = add[j];
1058
+ if (n.nodeType !== 1) continue;
1059
+ if (n.tagName === 'IMG' || n.tagName === 'VIDEO') {
1060
+ trackMedia(n);
1061
+ }
1062
+ if (n.querySelectorAll) {
1063
+ var inner = n.querySelectorAll('img, video');
1064
+ for (var k = 0; k < inner.length; k++) {
1065
+ trackMedia(inner[k]);
1066
+ }
1067
+ }
1068
+ }
1069
+ }
1070
+ }).observe(_stage, { childList: true, subtree: true });
1071
+ }
1072
+ if (document.fonts && document.fonts.ready
1073
+ && document.fonts.ready.then) {
1074
+ var _fontDone = false;
1075
+ function _fontSettle() {
1076
+ if (_fontDone) return;
1077
+ _fontDone = true;
1078
+ untrackLoad();
1079
+ }
1080
+ trackLoad();
1081
+ document.fonts.ready.then(_fontSettle, _fontSettle);
1082
+ setTimeout(_fontSettle, 2500);
1083
+ }
1084
+
1085
+ /* ---------- localStorage 假面:仅限本次沙箱会话的内存状态 ---------- */
1086
+ var _ls = {};
1087
+ var lsFake = {
1088
+ getItem: function (k) {
1089
+ k = String(k);
1090
+ return Object.prototype.hasOwnProperty.call(_ls, k) ? _ls[k] : null;
1091
+ },
1092
+ setItem: function (k, v) { _ls[String(k)] = String(v); },
1093
+ removeItem: function (k) { delete _ls[String(k)]; },
1094
+ clear: function () { _ls = {}; },
1095
+ key: function (i) {
1096
+ var ks = Object.keys(_ls);
1097
+ return i >= 0 && i < ks.length ? ks[i] : null;
1098
+ },
1099
+ };
1100
+ Object.defineProperty(lsFake, 'length', {
1101
+ get: function () { return Object.keys(_ls).length; },
1102
+ });
1103
+ try {
1104
+ Object.defineProperty(window, 'localStorage',
1105
+ { value: lsFake, writable: false, configurable: false });
1106
+ } catch (e) { /* 原生属性不可覆写的极端环境:裸访问仍会抛,如实降级 */ }
1107
+
1108
+ /* ---------- sessionStorage 假面:内存实现(opaque origin 原生
1109
+ 访问直接抛 SecurityError;设备绑定数据本就为平台裁定所禁) ---------- */
1110
+ var _ss = {};
1111
+ var ssFake = {
1112
+ getItem: function (k) {
1113
+ k = String(k);
1114
+ return Object.prototype.hasOwnProperty.call(_ss, k) ? _ss[k] : null;
1115
+ },
1116
+ setItem: function (k, v) { _ss[String(k)] = String(v); },
1117
+ removeItem: function (k) { delete _ss[String(k)]; },
1118
+ clear: function () { _ss = {}; },
1119
+ key: function (i) {
1120
+ var ks = Object.keys(_ss);
1121
+ return i >= 0 && i < ks.length ? ks[i] : null;
1122
+ },
1123
+ };
1124
+ Object.defineProperty(ssFake, 'length', {
1125
+ get: function () { return Object.keys(_ss).length; },
1126
+ });
1127
+ try {
1128
+ Object.defineProperty(window, 'sessionStorage',
1129
+ { value: ssFake, writable: false, configurable: false });
1130
+ } catch (e) { /* 同上 */ }
1131
+
1132
+ /* ---------- 平台注入面:Work.register / WorkCaps 登记表 / ctx ----------
1133
+ 语义与 work-view.js 主文档时代逐位同构(登记表每次启动全新实例——
1134
+ 全新 iframe window 天然保证;provide 保留首个只在单次启动内生效)。 */
1135
+ var factories = Object.create(null);
1136
+ window.WorkCaps = {
1137
+ provide: function (name, factory) {
1138
+ if (!name || typeof factory !== 'function') {
1139
+ if (window.console && console.warn) {
1140
+ console.warn('[WorkCaps] provide 需要 (name, factory):', name);
1141
+ }
1142
+ return;
1143
+ }
1144
+ if (factories[name]) {
1145
+ if (window.console && console.warn) {
1146
+ console.warn('[WorkCaps] 能力件重复登记(保留首个):', name);
1147
+ }
1148
+ return;
1149
+ }
1150
+ factories[name] = factory;
1151
+ },
1152
+ mount: function (names, c) {
1153
+ var list = Array.isArray(names)
1154
+ ? names : String(names || '').split(/[\s,]+/);
1155
+ var caps = {};
1156
+ list.forEach(function (raw) {
1157
+ var name = String(raw || '').trim();
1158
+ if (!name) return;
1159
+ var factory = factories[name];
1160
+ if (!factory) {
1161
+ if (window.console && console.warn) {
1162
+ console.warn('[WorkCaps] 未登记的能力(跳过):', name);
1163
+ }
1164
+ return;
1165
+ }
1166
+ try {
1167
+ caps[name] = factory(c || {});
1168
+ } catch (e) {
1169
+ if (window.console && console.error) {
1170
+ console.error('[WorkCaps] 能力件装配失败:', name, e);
1171
+ }
1172
+ }
1173
+ });
1174
+ return Object.freeze(caps);
1175
+ },
1176
+ available: function () { return Object.keys(factories); },
1177
+ };
1178
+
1179
+ window.Work = {
1180
+ register: function (d) {
1181
+ if (defDone) {
1182
+ if (window.console && console.warn) {
1183
+ console.warn('[work-bridge] Work.register 重复调用(已取首个声明)');
1184
+ }
1185
+ return;
1186
+ }
1187
+ defDone = true;
1188
+ def = d;
1189
+ },
1190
+ };
1191
+
1192
+ var stage = document.getElementById('stage');
1193
+ var ctx = null;
1194
+ var _emitBounds = [];
1195
+
1196
+ function stageShowsContent() {
1197
+ var nodes = stage.querySelectorAll('canvas, img, video');
1198
+ for (var i = 0; i < nodes.length; i++) {
1199
+ var r = nodes[i].getBoundingClientRect();
1200
+ if (r.width > 0 && r.height > 0) return true;
1201
+ }
1202
+ var els = stage.querySelectorAll('*');
1203
+ var scanned = 0;
1204
+ for (var j = 0; j < els.length && scanned < 500; j++) {
1205
+ var el = els[j];
1206
+ var cs;
1207
+ try { cs = getComputedStyle(el); } catch (e) { continue; }
1208
+ scanned++;
1209
+ if (cs.display === 'none' || cs.visibility === 'hidden') continue;
1210
+ var bg = cs.backgroundColor;
1211
+ var hasBg = (bg && bg !== 'transparent'
1212
+ && !/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0\s*\)$/.test(bg))
1213
+ || (cs.backgroundImage && cs.backgroundImage !== 'none');
1214
+ if (!hasBg) continue;
1215
+ var r2 = el.getBoundingClientRect();
1216
+ if (r2.width > 0 && r2.height > 0) return true;
1217
+ }
1218
+ return false;
1219
+ }
1220
+ function startSettleProbe() {
1221
+ var started = Date.now();
1222
+ (function tick() {
1223
+ if (settledSent || destroyed) return;
1224
+ if (stageShowsContent()) {
1225
+ settledSent = true;
1226
+ post({ type: 'settled' });
1227
+ loadTick(); // 可见 ∧ 零在途 ∧ mount 完 → loaded
1228
+ return;
1229
+ }
1230
+ if (Date.now() - started < 6000) {
1231
+ window.requestAnimationFrame(tick);
1232
+ }
1233
+ })();
1234
+ }
1235
+
1236
+ function exec(code, tag) {
1237
+ new Function(String(code) + '\n//# sourceURL=wb-' + tag)();
1238
+ }
1239
+ function launch() {
1240
+ if (!defDone || !def || typeof def.mount !== 'function') {
1241
+ fail('作品未声明 Work.register({ mount })——通用容器无从装载');
1242
+ return;
1243
+ }
1244
+ // mount 前自测一次舞台尺寸(父侧开壳早期的 bounds 消息可能早于
1245
+ // 本文档监听器注册而丢失,不能只依赖父侧推送)
1246
+ var r = stage.getBoundingClientRect();
1247
+ ctx.bounds = { w: Math.round(r.width), h: Math.round(r.height) };
1248
+ _stage = stage;
1249
+ armStageMediaObserver();
1250
+ try {
1251
+ var ret = def.mount(ctx);
1252
+ /* async mount 的 promise 完成 = 装载信号之一(同步 mount 经
1253
+ Promise.resolve 下一微任务落定);异步拒绝如实报失败卡,
1254
+ 不留静默白壳。 */
1255
+ Promise.resolve(ret).then(function () {
1256
+ mountDone = true;
1257
+ loadTick();
1258
+ }, function (e) {
1259
+ fail('作品 mount 失败(异步):'
1260
+ + ((e && e.message) || e));
1261
+ });
1262
+ } catch (e) {
1263
+ fail('作品 mount 失败:' + ((e && e.message) || e));
1264
+ return;
1265
+ }
1266
+ startSettleProbe();
1267
+ }
1268
+ function run() {
1269
+ try {
1270
+ if (CODES.caps) exec(CODES.caps, 'caps');
1271
+ if (CODES.entry) exec(CODES.entry, 'entry');
1272
+ } catch (e) {
1273
+ fail('作品代码执行失败:' + ((e && e.message) || e));
1274
+ return;
1275
+ }
1276
+ launch();
1277
+ }
1278
+
1279
+ ctx = {
1280
+ stage: stage,
1281
+ version: CFG.version,
1282
+ work: { id: CFG.work.id, ref: CFG.work.ref },
1283
+ bounds: { w: 0, h: 0 },
1284
+ onBounds: function (fn) {
1285
+ if (typeof fn !== 'function') return;
1286
+ _emitBounds.push(fn);
1287
+ /* 注册即补发(2026-09-27 game_forge 空白画布事故锚):开壳期
1288
+ 父侧三路 bounds 推送(srcdoc 即时 / ResizeObserver 首回调 /
1289
+ iframe load)全部早于 mount——回调注册时推送已流逝,除非
1290
+ 舞台此后真的 resize 否则永不再来。mount
1291
+ 前引导文档已自测舞台尺寸写入 ctx.bounds(launch 自测),
1292
+ 注册时尺寸已知 = 立即同步补发一次(对齐「注册时已算过会
1293
+ 立即补发」的历史合同)。 */
1294
+ if (ctx.bounds && (ctx.bounds.w > 0 || ctx.bounds.h > 0)) {
1295
+ try { fn(ctx.bounds); } catch (e) { /* 观察者失败不打断 */ }
1296
+ }
1297
+ },
1298
+ caps: function (names) {
1299
+ return window.WorkCaps.mount(names, ctx);
1300
+ },
1301
+ viewDoc: CFG.viewDoc || '',
1302
+ ready: function () { post({ type: 'ready' }); },
1303
+ hold: function () { post({ type: 'hold' }); },
1304
+ };
1305
+ ctx._emit = _emitBounds;
1306
+ run();
1307
+
1308
+ function doDestroy() {
1309
+ if (destroyed) return;
1310
+ destroyed = true;
1311
+ if (def && typeof def.destroy === 'function') {
1312
+ try { def.destroy(ctx); } catch (e) { /* 收尾尽力而为 */ }
1313
+ }
1314
+ post({ type: 'destroyed' });
1315
+ }
1316
+
1317
+ /* Escape 中继:作品界面内按键(焦点在 iframe)也要能关容器。 */
1318
+ window.addEventListener('keydown', function (e) {
1319
+ if (e.key === 'Escape') post({ type: 'esc' });
1320
+ }, true);
1321
+
1322
+ /* 自导航信号(2026-09-24 闪屏事故锚):门作品 mount 里
1323
+ ctx.ready() 后 location.replace(...) 自导航到应用页——旧文档
1324
+ 的 ready/settled 描述的是即将消亡的引导文档,不描述换页后的
1325
+ 应用页,父侧若据此揭盖就是「白屏换页期放行」(WORKS-2522
1326
+ 实测 reveal@167ms / 应用页 load@611ms)。三重钩:
1327
+ ① location.replace/assign 原型补丁——导航发生**前**从活文档
1328
+ 同步上报(iOS WebKit 对 unload 期 postMessage 常整条丢弃,
1329
+ 这是唯一 iOS 必达的钩;href 赋值是不可补丁的 unforgeable
1330
+ 属性,靠②③兜);
1331
+ ② beforeunload / ③ pagehide(Chromium/桌面 WebKit 可靠)。
1332
+ 父侧幂等只消费语义。 */
1333
+ function postNavigating() { post({ type: 'navigating' }); }
1334
+ window.addEventListener('beforeunload', postNavigating);
1335
+ window.addEventListener('pagehide', postNavigating);
1336
+ try {
1337
+ var lp = Object.getPrototypeOf(window.location);
1338
+ ['replace', 'assign'].forEach(function (m) {
1339
+ var orig = lp[m];
1340
+ if (typeof orig !== 'function') return;
1341
+ Object.defineProperty(lp, m, {
1342
+ writable: true, configurable: true,
1343
+ value: function (u) {
1344
+ postNavigating();
1345
+ return orig.call(window.location, u);
1346
+ },
1347
+ });
1348
+ });
1349
+ } catch (e) { /* 原型不可补丁的极端:退回事件钩 */ }
1350
+ }
1351
+
1352
+ /* ---------- 父侧桥会话(平台可信代码) ---------- */
1353
+
1354
+ function createSession(opts) {
1355
+ var iframe = opts.iframe;
1356
+ var channel = opts.channel;
1357
+ var auth = opts.auth || null;
1358
+ var cb = opts.callbacks || {};
1359
+ var workId = opts.workId || (auth && auth.work_id) || 0;
1360
+ var workVersion = opts.version > 0 ? opts.version : (auth && auth.version);
1361
+ var token = auth ? (auth.token || null) : null;
1362
+ var allow = ((auth && auth.allow) || []).map(function (r) {
1363
+ return { m: r.m || [], re: new RegExp(r.re) };
1364
+ });
1365
+ /* UI 动作面(2026-09-22 用户裁定):枚举钳制后的声明清单由
1366
+ manifest 下发(唯一真源 = services/work_bridge.py,禁手抄),
1367
+ 动作执行在容器回调 onUiAction。 */
1368
+ var uiActions = (auth && auth.ui_actions) || [];
1369
+ var pending = Object.create(null);
1370
+ var closed = false;
1371
+ var drainUntil = 0; // destroy 排空窗:收 destroy 后短暂保留 op 面
1372
+
1373
+ function reply(id, payload) {
1374
+ if ((!iframe.contentWindow)
1375
+ || (closed && Date.now() >= drainUntil)) return;
1376
+ var msg = { channel: channel, type: 'reply', id: id };
1377
+ for (var k in payload) msg[k] = payload[k];
1378
+ try { iframe.contentWindow.postMessage(msg, '*'); } catch (e) { /* 幂等 */ }
1379
+ }
1380
+ function allowed(method, path) {
1381
+ for (var i = 0; i < allow.length; i++) {
1382
+ if (allow[i].m.indexOf(method) !== -1 && allow[i].re.test(path)) {
1383
+ return true;
1384
+ }
1385
+ }
1386
+ return false;
1387
+ }
1388
+
1389
+ /* 兼容 fetch 转发:白名单内放行,凭据不离开父页。 */
1390
+ function doFetch(d) {
1391
+ var p = d.payload || {};
1392
+ var method = String(p.method || 'GET').toUpperCase();
1393
+ var path = String(p.path || '/');
1394
+ if (!allowed(method, path)) {
1395
+ reply(d.id, { err: 'work-bridge: 端点不在作品能力面('
1396
+ + method + ' ' + path + ')' });
1397
+ return;
1398
+ }
1399
+ var headers = {};
1400
+ var ct = p.headers
1401
+ && (p.headers['content-type'] || p.headers['Content-Type']);
1402
+ if (ct) headers['Content-Type'] = ct;
1403
+ var init = { method: method, credentials: 'same-origin',
1404
+ headers: headers };
1405
+ if (method !== 'GET' && method !== 'HEAD' && p.body) {
1406
+ init.body = String(p.body);
1407
+ }
1408
+ if (token && allow.length) headers['X-Work-Token'] = token;
1409
+ fetch(path, init).then(function (res) {
1410
+ return res.text().then(function (text) {
1411
+ var hs = {};
1412
+ var v = res.headers.get('content-type');
1413
+ if (v) hs['content-type'] = v;
1414
+ reply(d.id, { status: res.status, statusText: res.statusText,
1415
+ headers: hs, text: text });
1416
+ });
1417
+ }).catch(function (err) {
1418
+ reply(d.id, { err: '网络失败:' + ((err && err.message) || err) });
1419
+ });
1420
+ }
1421
+
1422
+ function onOp(d) {
1423
+ var op = d.op;
1424
+ if (op === 'fetch') { doFetch(d); return; }
1425
+ reply(d.id, { err: 'work-bridge: 未知操作 ' + op });
1426
+ }
1427
+
1428
+ /* UI 动作(声明 ∧ 枚举,manifest 下发):免 channel——门作品
1429
+ 自导航后 iframe 内是应用自己的页、拿不到引导文档 channel id;
1430
+ 信任锚 = 下面的 event.source 舞台钉 + 服务端枚举钳制 + 动作
1431
+ 在平台层各自过权限闸。 */
1432
+ function onUi(d) {
1433
+ var action = d && d.action;
1434
+ if (!action || uiActions.indexOf(action) === -1) return;
1435
+ /* 载荷随动作透传(open_work 携 ref/version,父侧各自钳制;
1436
+ 旧消费方只取首参不受影响) */
1437
+ if (cb.onUiAction) cb.onUiAction(action, d);
1438
+ }
1439
+
1440
+ /* 主题面(2026-09-22):主站 <html data-theme> 公开属性经桥下发给
1441
+ 作品/应用页——沙箱 opaque origin 封死了一切读父文档的路,主题
1442
+ 跟随只能靠 postMessage。读侧优先 Theme 运行时(唯一真源),
1443
+ 缺(装载序/独立页)回落 <html> 属性;钳制两值,坏值按浅色。 */
1444
+ function currentThemeMode() {
1445
+ var m = (window.Theme && typeof window.Theme.current === 'function')
1446
+ ? window.Theme.current()
1447
+ : (document.documentElement.getAttribute('data-theme') || 'light');
1448
+ return m === 'dark' ? 'dark' : 'light';
1449
+ }
1450
+ function postTheme() {
1451
+ if (closed || !iframe.contentWindow) return;
1452
+ try {
1453
+ iframe.contentWindow.postMessage(
1454
+ { type: 'fw:theme', mode: currentThemeMode() }, '*');
1455
+ } catch (e) { /* iframe 已离场,幂等 */ }
1456
+ }
1457
+
1458
+ function onMessage(ev) {
1459
+ if (closed && Date.now() >= drainUntil) return;
1460
+ if (ev.source !== iframe.contentWindow) return;
1461
+ var d = ev.data;
1462
+ if (!d) return;
1463
+ if (d.type === 'ui') { onUi(d); return; }
1464
+ if (d.type === 'theme-query') { postTheme(); return; }
1465
+ if (d.type === 'fw:work-context-query') {
1466
+ if (closed || !d || typeof d !== 'object' || Array.isArray(d)
1467
+ || typeof d.request_id !== 'string'
1468
+ || !/^[A-Za-z0-9_-]{1,128}$/.test(d.request_id)
1469
+ || !Number.isSafeInteger(workId) || workId <= 0
1470
+ || !Number.isSafeInteger(workVersion) || workVersion <= 0) return;
1471
+ try {
1472
+ iframe.contentWindow.postMessage({
1473
+ type: 'fw:work-context', request_id: d.request_id,
1474
+ ref: 'WORKS-' + workId, version: workVersion,
1475
+ }, '*');
1476
+ } catch (e) { /* iframe 已离场,幂等 */ }
1477
+ return;
1478
+ }
1479
+ /* 应用就绪契约(2026-09-24):自导航后的应用页首帧渲染完成上报
1480
+ ——免 channel(应用页拿不到引导文档 channel id),信任锚同
1481
+ ui/theme-query = event.source 舞台钉。 */
1482
+ if (d.type === 'fw:app-ready') {
1483
+ if (cb.onAppReady) cb.onAppReady();
1484
+ return;
1485
+ }
1486
+ /* 应用失败契约(2026-09-24 统一失败卡):服务端标准失败页自报
1487
+ 失败——同 fw:app-ready 免通道 + event.source 舞台钉。 */
1488
+ if (d.type === 'fw:app-failed') {
1489
+ if (cb.onAppFailed) cb.onAppFailed(d.message);
1490
+ return;
1491
+ }
1492
+ if (d.channel !== channel) return;
1493
+ if (d.type === 'op') { onOp(d); return; }
1494
+ if (d.type === 'ready' && cb.onReady) cb.onReady();
1495
+ else if (d.type === 'hold' && cb.onHold) cb.onHold();
1496
+ else if (d.type === 'settled' && cb.onSettled) cb.onSettled();
1497
+ else if (d.type === 'loaded' && cb.onLoaded) cb.onLoaded();
1498
+ else if (d.type === 'navigating' && cb.onNavigating) cb.onNavigating();
1499
+ else if (d.type === 'error' && cb.onError) cb.onError(d.message);
1500
+ else if (d.type === 'esc' && cb.onEscape) cb.onEscape();
1501
+ else if (d.type === 'destroyed' && cb.onDestroyed) cb.onDestroyed();
1502
+ }
1503
+ window.addEventListener('message', onMessage);
1504
+
1505
+ return {
1506
+ postBounds: function (w, h) {
1507
+ if (closed || !iframe.contentWindow) return;
1508
+ try {
1509
+ iframe.contentWindow.postMessage(
1510
+ { channel: channel, type: 'bounds', w: w, h: h }, '*');
1511
+ } catch (e) { /* 幂等 */ }
1512
+ },
1513
+ /* 主题下发:容器在会话建立 / iframe 每次装载(含门作品自导航后
1514
+ 的应用页)/ 主站 theme-changed 时推送当前模式。 */
1515
+ postTheme: postTheme,
1516
+ /* 子层关闭回推(2026-09-27 合集复刻配套):经桥 open_work 打开
1517
+ 的子作品层关闭时通知宿主沙箱(fw:child-closed)——宿主据此
1518
+ 广播 exit 跟随信号与 onChildClose 回调。 */
1519
+ postChildClosed: function () {
1520
+ if (closed || !iframe.contentWindow) return;
1521
+ try {
1522
+ iframe.contentWindow.postMessage(
1523
+ { type: 'fw:child-closed' }, '*');
1524
+ } catch (e) { /* iframe 已离场,幂等 */ }
1525
+ },
1526
+ destroy: function () {
1527
+ if (closed) return;
1528
+ closed = true;
1529
+ /* destroy 排空窗(2026-09-27):destroy 消息
1530
+ * 派发后引导程序还要跑 def.destroy——在途请求(经桥
1531
+ * fetch)在其内;父侧若同步摘监听,这些 op 全部落聋。排空窗内
1532
+ * op/reply 照常服务;iframe 本体仍按 200ms 兜底摘除,窗只是
1533
+ * 消费已派发的尾包,不延长生命周期。 */
1534
+ drainUntil = Date.now() + 2200;
1535
+ try {
1536
+ iframe.contentWindow.postMessage(
1537
+ { channel: channel, type: 'destroy' }, '*');
1538
+ } catch (e) { /* iframe 已离场 */ }
1539
+ setTimeout(function () {
1540
+ window.removeEventListener('message', onMessage);
1541
+ drainUntil = 0;
1542
+ }, 2200);
1543
+ },
1544
+ };
1545
+ }
1546
+
1547
+ return {
1548
+ __installed: true,
1549
+ SANDBOX_TOKEN: SANDBOX_TOKEN,
1550
+ bootstrapDocument: bootstrapDocument,
1551
+ createSession: createSession,
1552
+ };
1553
+ })();
1554
+
1555
+ </script>
1556
+ <script type="module">function Lt(){const e=navigator.userAgent;return/^((?!chrome|android).)*safari/i.test(e)}function Tn(){if(!Lt())return null;const e=navigator.userAgent.match(/Version\/(\d+)/);return e?parseInt(e[1],10):null}function An(){return/iPhone|iPad|iPod/.test(navigator.userAgent)&&Lt()}let We=null,rt=null;async function Ln(){return We!==null?We:rt||(rt=new Promise(e=>{if(!window.indexedDB){console.warn("[Safari Fix] IndexedDB API not available"),We=!1,e(!1);return}try{const t=`__${window.__SITE__&&window.__SITE__.slug||"site"}_idb_test__`,n=indexedDB.open(t,1),i=setTimeout(()=>{console.warn("[Safari Fix] IndexedDB open timeout"),We=!1,e(!1)},2e3);n.onerror=()=>{clearTimeout(i),console.warn("[Safari Fix] IndexedDB open failed:",n.error),We=!1,e(!1)},n.onsuccess=()=>{clearTimeout(i);try{n.result.close(),indexedDB.deleteDatabase(t),We=!0,e(!0)}catch(o){console.warn("[Safari Fix] IndexedDB test cleanup failed:",o),We=!1,e(!1)}},n.onupgradeneeded=o=>{const s=o.target.result;s.objectStoreNames.contains("test")||s.createObjectStore("test")}}catch(t){console.warn("[Safari Fix] IndexedDB test exception:",t),We=!1,e(!1)}}),rt)}function In(){We=null,rt=null}typeof window<"u"&&(window.SafariIndexedDBFix={isSafari:Lt,getSafariVersion:Tn,isMobileSafari:An,checkIndexedDBAvailability:Ln,resetIndexedDBCheck:In});window.__perf_utils__=window.__perf_utils__||function(){function e(a,d){let p=null;return function(...w){p!==null&&clearTimeout(p),p=window.setTimeout(()=>{a.apply(this,w),p=null},d)}}function t(a,d){let p=0,w=null;return function(...y){const f=Date.now(),m=d-(f-p);m<=0?(w!==null&&(clearTimeout(w),w=null),p=f,a.apply(this,y)):w===null&&(w=window.setTimeout(()=>{p=Date.now(),w=null,a.apply(this,y)},m))}}function n(a){const d=requestAnimationFrame(a);return()=>cancelAnimationFrame(d)}function i(a,d){if("requestIdleCallback"in window){const p=requestIdleCallback(a,d);return()=>cancelIdleCallback(p)}else{const p=setTimeout(()=>a({didTimeout:!1,timeRemaining:()=>50}),1);return()=>clearTimeout(p)}}class o{constructor(){this.readQueue=[],this.writeQueue=[],this.scheduled=!1}read(d){this.readQueue.push(d),this.schedule()}write(d){this.writeQueue.push(d),this.schedule()}schedule(){this.scheduled||(this.scheduled=!0,requestAnimationFrame(()=>{this.flush()}))}flush(){const d=this.readQueue.slice();this.readQueue.length=0,d.forEach(w=>w());const p=this.writeQueue.slice();this.writeQueue.length=0,p.forEach(w=>w()),this.scheduled=!1}}const s=new o;function l(a,d,p){const w={event_type:"performance",metric:a,value:d,timestamp:new Date().toISOString(),page:p||window.location.pathname,user_agent:navigator.userAgent};postBootProbe(w)}function r(){const a=new PerformanceObserver(f=>{for(const m of f.getEntries())m.name==="first-contentful-paint"&&l("FCP",m.startTime)});try{a.observe({type:"paint",buffered:!0})}catch{}const d=new PerformanceObserver(f=>{const m=f.getEntries(),E=m[m.length-1];l("LCP",E.renderTime||E.loadTime)});try{d.observe({type:"largest-contentful-paint",buffered:!0})}catch{}const p=new PerformanceObserver(f=>{for(const m of f.getEntries()){const E=m;l("FID",E.processingStart-E.startTime)}});try{p.observe({type:"first-input",buffered:!0})}catch{}let w=0;const y=new PerformanceObserver(f=>{for(const m of f.getEntries()){const E=m;E.hadRecentInput||(w+=E.value)}});try{y.observe({type:"layout-shift",buffered:!0})}catch{}window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&l("CLS",w)},{once:!0}),"PerformanceObserver"in window&&i(()=>{const f=performance.getEntriesByType("navigation")[0];if(f){const m=f.domInteractive-f.fetchStart;l("TTI",m)}})}function c(a,d,p=!0){const w=performance.now(),y=d(),f=performance.now()-w;return p&&l(`fn.${a}`,f),y}async function u(a,d,p=!0){const w=performance.now(),y=await d(),f=performance.now()-w;return p&&l(`fn.${a}`,f),y}return{debounce:e,throttle:t,raf:n,idle:i,domBatch:s,reportPerformance:l,observeWebVitals:r,measure:c,measureAsync:u}}();window.LayerManager=window.LayerManager||function(){if(window.LayerManager&&window.LayerManager.__installed)return window.LayerManager;const e={STD:4100},t=[".pv-overlay",".xv-overlay",".ms-confirm-overlay",".ps-overlay",".ip-overlay"];function n(r){typeof r!="string"||!r||t.indexOf(r)<0&&t.push(r)}function i(r){const c=[];for(let u=0;u<t.length;u++){let a;try{a=document.querySelectorAll(t[u])}catch{continue}for(let d=0;d<a.length;d++){const p=a[d];c.indexOf(p)>=0||(c.push(p),r(p))}}}function o(r,c){c=c||{};let u=0;return i(function(a){if(a===r)return;const d=window.getComputedStyle(a);if(!c.includeHidden&&d.display==="none")return;const p=parseInt(d.zIndex,10)||0;p>u&&(u=p)}),u}function s(r,c){if(!r)return;c=c||{};const u=c.baseline||0,a=c.offset||0,d=o(r,c);(c.ge?d>=u:d>u)?r.style.zIndex=String(d+a):r.style.removeProperty("z-index")}function l(r){if(!r||r.nodeType!==1||typeof r.matches!="function")return!1;for(let c=0;c<t.length;c++)try{if(r.matches(t[c]))return!0}catch{}return!1}return{__installed:!0,LEVELS:e,register:n,topZ:o,raise:s,matches:l}}();window.FW_CONTRACTS=window.FW_CONTRACTS||function(){const e=window;return e.FW_CONTRACTS&&e.FW_CONTRACTS.__installed?e.FW_CONTRACTS:(e.__fwHistory||(e.__fwHistoryLayers=[],e.__fwHistory={push:function(t){e.__fwHistoryLayers.push(t)},pop:function(t){const n=e.__fwHistoryLayers,i=n.lastIndexOf(t);i>=0&&n.splice(i,1)},top:function(){const t=e.__fwHistoryLayers;return t.length?t[t.length-1]:null}}),Object.freeze({__installed:!0,KEYBOARD_OPEN_CLASS:"keyboard-open",KEYBOARD_EVENT:"ms:keyboard",ROUTE_CHANGE_EVENT:"app-shell:routechange",HISTORY_OVERLAY_KEY:"__fwOverlay",HISTORY_PV_KEY:"pv",HISTORY_STD_MODAL_LAYER:"std-modal",HISTORY_PV_LAYER:"pv",HISTORY_EXTSITE_KEY:"xv",HISTORY_EXTSITE_LAYER:"extsite"}))}();window.Motion=function(){if(window.Motion&&window.Motion.__installed)return window.Motion;function e(){return!!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}function t(r,c,u,a){let d=a,p={};typeof u=="function"?d=u:u&&(p=u);let w=!1;const y=setTimeout(m,p.timeout||400);function f(S){S.target===r&&(c==="transitionend"&&"property"in p&&p.property&&S.propertyName!==p.property||m())}function m(){w||(w=!0,clearTimeout(y),r.removeEventListener(c,f),typeof d=="function"&&d())}function E(){w||(w=!0,clearTimeout(y),r.removeEventListener(c,f))}return r.addEventListener(c,f),E}function n(r,c,u){return t(r,"transitionend",c,u)}function i(r,c,u){return t(r,"animationend",c,u)}function o(r,c){c=c||{};const u=c.cls||"shell-enter";if(e())return r.classList.remove(u),function(){r.classList.remove(u)};r.classList.add(u);let a=!1;const d=function(){a=!0};r.addEventListener("animationstart",d,!0);let p=!1;function w(){if(!p){if(p=!0,r.removeEventListener("animationstart",d,!0),a||!r.isConnected){r.classList.remove(u);return}l(function(){r.classList.remove(u)})}}const y=i(r,{timeout:c.timeout||450},w);return function(){if(p){r.classList.remove(u);return}p=!0,r.removeEventListener("animationstart",d,!0),y(),r.classList.remove(u)}}function s(r,c){c=c||{};const u=c.cls||"shell-closing";if(e()||c.immediate)return r.classList.remove(u),typeof c.done=="function"&&c.done(),function(){};r.classList.add(u);let a=!1;const d=i(r,{timeout:c.timeout||400},function(){a=!0,r.classList.remove(u),typeof c.done=="function"&&c.done()});return function(){if(a){r.classList.remove(u);return}a=!0,d(),r.classList.remove(u)}}function l(r){window.requestAnimationFrame(function(){window.requestAnimationFrame(function(){r()})})}return{__installed:!0,reduced:e,afterTransition:n,afterAnimation:i,playEnter:o,playExit:s,nextPaint:l}}();(function(e){if(e.StatusTpl&&e.StatusTpl.__installed)return;const t="lf-status",n="lf-status-error",i="正在加载...";function o(u){const a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return String(u??"").replace(/[&<>"']/g,d=>a[d]||"")}function s(u){return u==null||u===""?i:String(u)}function l(u,a){return t+(u==="error"?" "+n:"")+" lf-status-"+(a==="section"||a==="inline"?a:"area")}const r=new WeakMap;function c(u,a){if(!u||u.disabled||r.has(u))return null;const d={disabled:u.disabled,aria:u.getAttribute("aria-busy"),nodes:Array.prototype.slice.call(u.childNodes)};return r.set(u,d),u.disabled=!0,u.setAttribute("aria-busy","true"),a!=null&&(u.textContent=a),function(){r.get(u)===d&&(r.delete(u),u.disabled=d.disabled,d.aria==null?u.removeAttribute("aria-busy"):u.setAttribute("aria-busy",d.aria),a!=null&&u.replaceChildren&&u.replaceChildren.apply(u,d.nodes))}}e.StatusTpl={__installed:!0,text:i,busy:c,placeholder:function(u,a,d){return'<div class="'+l(a,d)+'" role="status">'+o(s(u))+"</div>"},loading:function(u,a){return e.StatusTpl.placeholder(u,null,a)},empty:function(u,a){return e.StatusTpl.placeholder(u||"暂无数据",null,a)},error:function(u,a){return e.StatusTpl.placeholder(u,"error",a)},fill:function(u,a,d,p){return u&&(u.className=l(d,p),u.setAttribute("role","status"),u.textContent=s(a),u)}}})(window);(function(){if(window.Interact&&window.Interact.__installed)return;var e=!1,t=0,n=null,i=null,o=null,s="fw-busy",l="加载失败,请重试",r=2e4,c=15e3;function u(){return document.getElementById("fwBootGate")}var a=[];document.addEventListener("click",function(U){if(U.isTrusted&&a.length&&!re(U.target)){for(var le=Date.now(),_e=null,K=0;K<a.length;K++){var X=a[K];if(!(X.saw||le>X.until)){var ae=U.target;ae&&(ae===X.el||ae.closest&&ae.closest(G)===X.ctl)&&(_e||(_e=[]),_e.push(X))}}if(_e){for(var pe=0;pe<a.length;pe++){var me=a[pe];if(!(me.saw||le>me.until)){var ge=U.target;ge&&(ge===me.el||ge.closest&&ge.closest(G)===me.ctl)&&(me.saw=!0)}}U.preventDefault&&U.preventDefault(),U.stopPropagation&&U.stopPropagation(),U.stopImmediatePropagation&&U.stopImmediatePropagation();return}}if(!(e&&t===0)){U&&U.preventDefault&&U.preventDefault(),U&&U.stopPropagation&&U.stopPropagation(),n={target:U&&U.target||null,at:Date.now()};var ke=u();ke&&(ke.classList.add("fw-boot-nudge"),setTimeout(function(){ke.classList.remove("fw-boot-nudge")},400))}},!0);function d(){var U=n;if(n=null,!(!U||Date.now()-U.at>c)){var le=U.target;if(le&&le.isConnected===!0&&typeof le.click=="function")try{le.click()}catch{}}}var p=document.readyState!=="loading",w=!1,y=!1;function f(){if(!e){e=!0,h.arm=Math.round(performance.now()),h.armWall=Date.now(),setTimeout(M,x+200);var U=u();if(U&&U.parentNode){var le=!1;try{le=!!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}catch{}le?U.parentNode.removeChild(U):(document.body.classList.add("fw-boot-reveal"),U.classList.add("fw-boot-lift"),setTimeout(function(){var _e=u();_e&&_e.parentNode&&_e.parentNode.removeChild(_e)},300))}d()}}function m(){e||!p||!w||!y||!S||setTimeout(f,0)}function E(){y||(y=!0,h.late||(h.late=Math.round(performance.now())),m())}window.addEventListener("fw:late-done",E),function(){var le=Date.now(),_e=setInterval(function(){window.__fwLateDone?(clearInterval(_e),E()):(e||Date.now()-le>2e4)&&clearInterval(_e)},300)}();var S=!1,L=1e4;function O(){S||(S=!0,m())}window.__fwContentReady===!0?S=!0:(window.addEventListener("fw:first-content",O,!0),setTimeout(O,L));function I(){f()}function v(){t++;var U=!1;return function(){U||(U=!0,t>0&&t--,d())}}document.addEventListener("auth:ready",function(){w=!0,h.auth||(h.auth=Math.round(performance.now())),m()},!0),p?m():document.addEventListener("DOMContentLoaded",function(){p=!0,h.dcl||(h.dcl=Math.round(performance.now())),m()}),window.addEventListener("pageshow",function(U){U&&U.persisted&&I()}),window.addEventListener("pageswap",function(U){if(U&&U.viewTransition&&typeof U.viewTransition.skipTransition=="function")try{U.viewTransition.skipTransition()}catch{}}),window.addEventListener("pagereveal",function(U){if(U&&U.viewTransition&&typeof U.viewTransition.skipTransition=="function")try{U.viewTransition.skipTransition()}catch{}});var h={dcl:0,auth:0,arm:0,late:0,clicks:[],sent:!1},x=8e3,T=20,_=[],g=[],B=16,A=12,k=!1;function P(){return e&&h.arm&&Date.now()-h.armWall<=x}window.addEventListener("popstate",function(U){if(!(!P()||_.length>=B)){var le="";try{le=U.state&&typeof U.state=="object"?U.state.kind||U.state.appShell||"obj":String(U.state)}catch{le="?"}_.push({t:Math.round(performance.now()),s:String(le).slice(0,30)})}},!0);function j(U,le){if(!(!P()||g.length>=A)){var _e="";try{_e=(new Error().stack||"").split(`
1557
+ `).slice(1,8).join(" < ").replace(/\s+/g," ").slice(0,140)}catch{}g.push({t:Math.round(performance.now()),k:U,im:le&&le.immediate?1:0,tag:_e})}}function Z(){if(!k){var U=window.PlainView;if(!(!U||typeof U.close!="function")){k=!0;var le=U.close;if(U.close=function(K,X){return j("c",X),le.apply(this,arguments)},typeof U.closeAll=="function"){var _e=U.closeAll;U.closeAll=function(){return j("a",null),_e.apply(this,arguments)}}}}}function N(U){if(!U||!U.tagName)return"?";var le=U.tagName.toLowerCase();return U.id?le+="#"+String(U.id).slice(0,40):U.className&&typeof U.className=="string"&&(le+="."+U.className.trim().split(/\s+/).slice(0,3).join(".")),le.slice(0,120)}function ee(U,le){if(!(!e||!h.arm)&&!(Date.now()-h.armWall>x)&&!(h.clicks.length>=T*2)){var _e={t:Math.round(performance.now()),sel:N(U.target),cap:le==="cap"?1:0,bub:le==="bub"?1:0,prev:U.defaultPrevented?1:0,out:-1};h.clicks.push(_e),le==="bub"&&setTimeout(function(){try{_e.out=document.querySelectorAll(".pv-overlay, .ps-overlay, .ms-inline-notice").length}catch{_e.out=-2}},500)}}document.addEventListener("click",function(U){ee(U,"cap")},!0),document.addEventListener("click",function(U){ee(U,"bub")},!1);var ie=[],W=[],q=16;function F(U){try{var le=U.querySelector(".pv-title");return(le&&le.textContent||"").trim().slice(0,60)}catch{return""}}(function(){var le=setInterval(function(){if(e){if(Z(),Date.now()-h.armWall>x){clearInterval(le);return}try{for(var _e=document.querySelectorAll(".pv-overlay"),K=[],X=0;X<_e.length;X++){var ae=1;try{ae=parseFloat(getComputedStyle(_e[X]).opacity)}catch{}K.push({el:_e[X],title:F(_e[X]),hidden:!!_e[X].hidden,op:isNaN(ae)?1:ae})}if(ie.length<q){for(var pe=0;pe<K.length;pe++){for(var me=!1,ge=0;ge<W.length;ge++)if(W[ge].el===K[pe].el){me=!0;break}me||ie.push({t:Math.round(performance.now()),k:"+",title:K[pe].title,op:Math.round(K[pe].op*100)/100})}for(var ke=0;ke<W.length;ke++){for(var Te=!0,Le=0;Le<K.length;Le++)if(K[Le].el===W[ke].el){Te=!1;break}if(Te)ie.push({t:Math.round(performance.now()),k:"-",title:W[ke].title});else{for(var Me=null,Pe=0;Pe<K.length;Pe++)if(K[Pe].el===W[ke].el){Me=K[Pe];break}Me&&!Me.hidden&&W[ke].op>=.95&&Me.op<.95&&ie.push({t:Math.round(performance.now()),k:"op",title:Me.title,op:Math.round(Me.op*100)/100})}}}W=K}catch{}}},200)})();function M(){if(!h.sent&&h.clicks.length){h.sent=!0;var U;try{U=JSON.stringify({v:1,path:location.pathname,dcl:h.dcl,auth:h.auth,arm:h.arm,late:h.late,clicks:h.clicks,layers:ie,pops:_,closes:g,marks:(window.__fwBootMarks||[]).slice(0,24)})}catch{return}try{postBootProbe(U)}catch{}}}var G='button, a[href], [role="button"], summary, .item-card, .fav-icon, .clickable-card, [data-card-action], [onclick]';function re(U){return U&&U.nodeType===3&&(U=U.parentElement),!!(U&&U.closest&&(U.closest("input, textarea, select, option, label")||U.isContentEditable))}var ce=".pv-overlay, .ps-overlay, .ms-inline-notice, .xv-overlay",H=400,te={},oe=0,ve=[],Se=0,se=40,Ae=null;function xe(){Ae||(Ae=setTimeout(function(){Ae=null,be()},2e4))}function be(){if(ve.length){var U=ve.splice(0,ve.length);try{postBootProbe({v:1,path:location.pathname,silent:U,ackn:Se})}catch{}}}window.addEventListener("pagehide",be),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&be()}),document.addEventListener("click",function(U){if(!(!e||t>0)){var le=U.target;if((!le||le.nodeType===3)&&(le=le?le.parentElement:null),!(!le||le.nodeType!==1||re(le))&&!(le.closest&&le.closest(".ms-inline-notice"))){var _e=le.closest?le.closest(G):null;if(_e&&!te[U.timeStamp]){if(te[U.timeStamp]=1,++oe>500&&(te={},oe=0),_e.dataset&&_e.dataset.fwAck==="1"){delete _e.dataset.fwAck;return}Se++;var K=!1,X=location.href,ae=document.activeElement,pe=null,me=null,ge=/(?:^|\s)(?:(?:pv|ps|xv)-overlay|ms-(?:confirm-overlay|inline-notice))(?:\s|$)/;try{pe=new MutationObserver(function(ke){for(var Te=0;Te<ke.length;Te++){var Le=ke[Te];if(Le.type==="attributes"){var Me=Le.target;if(Me&&Me.nodeType===1&&Me.matches&&(Me.matches(ce)||ge.test(String(Le.oldValue||"")))){K=!0;return}continue}var Pe=Le.addedNodes,De,qe;for(De=0;De<Pe.length;De++)if(qe=Pe[De],qe.nodeType===1&&qe.matches&&qe.matches(ce)){K=!0;return}for(Pe=Le.removedNodes,De=0;De<Pe.length;De++)if(qe=Pe[De],qe.nodeType===1&&qe.matches&&qe.matches(ce)){K=!0;return}}}),pe.observe(document.body,{childList:!0,attributes:!0,attributeFilter:["class"],subtree:!0,attributeOldValue:!0}),me=new MutationObserver(function(){K=!0}),me.observe(_e,{childList:!0,characterData:!0,subtree:!0,attributes:!0})}catch{}setTimeout(function(){try{pe&&pe.disconnect(),me&&me.disconnect()}catch{}if(!(K||U.defaultPrevented)){try{if(location.href!==X||document.activeElement!==ae&&_e.contains(document.activeElement))return}catch{}ve.length<se&&ve.push({t:Math.round(performance.now()),sel:N(_e)}),xe()}},H)}}}},!0);var b=11,R=700,D=800,J=4,V=null,$=!1;function ne(U){return U&&U.closest?U.closest(G):null}function C(U){for(var le=U;le&&le.nodeType===1;le=le.parentElement){if(le.hidden)return!0;var _e=null;try{_e=getComputedStyle(le)}catch{_e=null}if(_e&&(_e.display==="none"||_e.visibility==="hidden"))return!0}return!1}function z(U){var le={t:Math.round(performance.now()),sel:N(U),cap:0,bub:0,prev:0,out:-3};h.clicks.length<T*2&&h.clicks.push(le);try{M()}catch{}ve.length<se&&ve.push({t:le.t,sel:"[tap] "+le.sel}),xe()}document.addEventListener("touchstart",function(U){var le=U.touches&&U.touches[0];if(le){if(U.touches.length>1){V=null,$=!0;return}if(re(U.target)||re(document.elementFromPoint(le.clientX,le.clientY))){V=null;return}V={x:le.clientX,y:le.clientY,t:Date.now()},$=!1}},!0),document.addEventListener("touchmove",function(U){if(!(!V||$)){var le=U.touches&&U.touches[0];le&&(Math.abs(le.clientX-V.x)>b||Math.abs(le.clientY-V.y)>b)&&($=!0)}},!0),document.addEventListener("touchcancel",function(){V=null,$=!0},!0),document.addEventListener("touchend",function(U){if(!V||$){V=null;return}var le=U.changedTouches&&U.changedTouches[0];if(!le||U.changedTouches.length>1){V=null;return}var _e=Math.abs(le.clientX-V.x)<=b&&Math.abs(le.clientY-V.y)<=b,K=Date.now()-V.t;if(V=null,!(!_e||K>R)){var X=U.target;if(!X||!X.isConnected||C(X)){U.cancelable&&U.preventDefault&&U.preventDefault();return}var ae=document.elementFromPoint(le.clientX,le.clientY);if(!(!ae||ae.nodeType!==1)&&!(ae.closest&&ae.closest(".ms-inline-notice"))&&!(re(U.target)||re(ae))){var pe=ne(ae);if(pe){U.cancelable&&U.preventDefault&&U.preventDefault();for(var me=Date.now();a.length&&(a[0].saw||me>a[0].until);)a.shift();a.length>=J&&a.shift();var ge={el:ae,ctl:pe,until:me+D,saw:!1};if(a.push(ge),!e||t>0){n={target:ae,at:Date.now()};var ke=u();ke&&(ke.classList.add("fw-boot-nudge"),setTimeout(function(){ke.classList.remove("fw-boot-nudge")},400))}else try{var Te=pe||ae;Te.__fwInteractSyntheticClick=!0,Te!==ae&&(ae.__fwInteractSyntheticClick=!0),Te.click()}catch{}finally{try{delete ae.__fwInteractSyntheticClick}catch{}try{Te!==ae&&delete Te.__fwInteractSyntheticClick}catch{}}setTimeout(function(){ge.saw||z(ae)},D+30)}}}},!0);var Y={title:function(U){return U&&U.title||"正在加载..."},mode:"layer",render:function(U,le){U.innerHTML=window.StatusTpl?window.StatusTpl.loading(le&&le.label):""},onClose:function(){i&&(i.cancelled=!0),o=null}};function ue(){if(!window.AppWindows||typeof window.AppWindows.define!="function")return!1;try{window.AppWindows.define("fwPendingShell",Y)}catch{}return!0}function he(){return!!(o&&o.alive&&o.body&&o.body.isConnected)}function Ee(){var U=o;if(i=null,o=null,U&&U.alive&&(U.alive=!1,U.overlay&&window.PlainView&&typeof PlainView.close=="function"))try{PlainView.close(U.overlay,{immediate:!0})}catch{}}function Q(U){if(ue(),i&&he())return i.jobs++,o.body&&window.StatusTpl&&window.StatusTpl.fill(o.body,U),i;i={cancelled:!1,jobs:1},o=null;var le=null;try{le=window.AppWindows&&typeof AppWindows.open=="function"?AppWindows.open("fwPendingShell",{label:U}):null}catch{le=null}return le&&le.body&&(o={body:le.body,overlay:le.body.closest&&le.body.closest(".pv-overlay")||null,alive:!0}),i}function de(U){!U||U!==i||(U.jobs--,U.jobs<=0&&Ee())}function fe(U,le){!U||!U.classList||(le?(U.classList.add(s),U.setAttribute("aria-busy","true")):(U.classList.remove(s),U.removeAttribute("aria-busy")))}function ye(U){if(window.StatusNotify&&typeof StatusNotify.error=="function"){StatusNotify.error(U);return}window.MobileShell&&typeof MobileShell.notify=="function"&&MobileShell.notify(U,{type:"error"})}function we(U,le){return new Promise(function(_e,K){var X=!1,ae=null,pe=null;function me(ke,Te){X||(X=!0,ae&&clearInterval(ae),pe&&clearTimeout(pe),ke(Te))}function ge(){if(!X){var ke;try{ke=U()}catch(Te){me(K,Te);return}if(ke&&typeof ke.then=="function"){ke.then(function(Te){me(_e,Te??!0)},function(Te){me(K,Te||new Error("wait rejected"))});return}ke&&me(_e,ke)}}typeof window.__fwWhenLate=="function"&&window.__fwWhenLate(function(){setTimeout(function(){ge(),X||me(K,new Error("capability missing after late"))},0)}),ae=setInterval(ge,120),pe=setTimeout(function(){me(K,new Error("interact wait timeout"))},le||r),ge()})}function Ce(U){if(navigator.vibrate&&U&&!U.skipVibrate)try{navigator.vibrate(10)}catch{}if(U=U||{},typeof U.open!="function")return!1;var le=U.wait||function(){return!0},_e=null;try{_e=le()}catch{_e=null}if(_e&&typeof _e.then!="function"){try{U.open(_e)}catch{ye(typeof U.fail=="string"&&U.fail||l)}return!0}var K=U.busy||null;if(K&&K.classList&&K.classList.contains(s))return!0;fe(K,!0);var X=typeof U.label=="string"&&U.label||void 0,ae=U.pending===!1?null:Q(X);return we(le,U.timeoutMs).then(function(pe){fe(K,!1);var me=!!(ae&&ae.cancelled);if(de(ae),!me)try{U.open(pe)}catch{ye(typeof U.fail=="string"&&U.fail||l)}},function(){fe(K,!1);var pe=typeof U.fail=="string"&&U.fail||l,me=!!(ae&&ae.cancelled),ge=!ae||ae===i;de(ae),!me&&ge&&ye(pe)}),!0}window.Interact={__installed:!0,arm:m,forceArm:I,hold:v,isArmed:function(){return e},whenReady:we,launch:Ce}})();window.LayerFrame=window.LayerFrame||function(){if(window.LayerFrame&&window.LayerFrame.__installed)return window.LayerFrame;const e=window.Motion,t=window.FW_CONTRACTS,n=[];function i(){return window.innerHeight||document.documentElement.clientHeight||0}function o(S){for(let L=0;L<n.length;L++)if(n[L].el===S)return n[L];return null}function s(S,L){if(!S)return null;L=L||{};var O=L.top||"0px";S.style.top=O,S.style.bottom="auto";var I=i()+"px";S.style.height=O==="0px"?I:"calc("+I+" - "+O+")",S.classList.add("lf-lock");var v=o(S);return v||(v={el:S,pad:null,padBase:"0px",top:"0px"},n.push(v)),v.top=O,L.pad&&(v.pad=L.pad,v.padBase=null),v}function l(S){if(S){for(var L=n.length-1;L>=0;L--)n[L].el===S&&n.splice(L,1);S.classList.remove("lf-lock"),S.style.removeProperty("height"),S.style.removeProperty("top"),S.style.removeProperty("bottom")}}function r(){for(var S=n.length-1;S>=0;S--)n[S].el.isConnected||n.splice(S,1)}function c(){return!!(document.documentElement&&t&&document.documentElement.classList.contains(t.KEYBOARD_OPEN_CLASS))}var u=null;function a(){u&&clearTimeout(u),u=setTimeout(function(){if(u=null,!c()){r();for(var S=0;S<n.length;S++){var L=i()+"px",O=n[S].top||"0px";n[S].el.style.height=O==="0px"?L:"calc("+L+" - "+O+")"}}},150)}window.addEventListener("resize",a),window.addEventListener("orientationchange",a);function d(S,L){r();for(var O=L||null,I=0;I<n.length;I++){var v=n[I];if(v.pad){var h=v.el,x=h.getClientRects().length>0,T=x&&O&&O!==document.body&&!h.contains(O);if(!x||T||!S){v.pad.style.removeProperty("padding-bottom");continue}if(v.padBase==null)try{v.padBase=window.getComputedStyle(v.pad).paddingBottom||"0px"}catch{v.padBase="0px"}v.pad.style.paddingBottom=v.padBase==="0px"?S+"px":"calc("+v.padBase+" + "+S+"px)"}}}var p=null;function w(){var S=document.createElement("div");return S.className="pv-overlay",S.setAttribute("role","dialog"),S.setAttribute("aria-modal","true"),S.innerHTML='<div class="pv-scroll" tabindex="-1"><div class="pv-head">'+window.LayerChrome.titleBarHtml({classes:{bar:"pv-titlebar",back:"pv-back",title:"pv-title",close:"pv-close"}})+'</div><div class="pv-body lf-pad"></div></div>',S}function y(S){S=S||{},p||(p=w());var L=p.cloneNode(!0),O=function(_){return L.querySelector(_)},I=O(".pv-back");if(S.backAriaLabel&&I.setAttribute("aria-label",S.backAriaLabel),O(".pv-title").textContent=S.title||"",Array.isArray(S.actions)&&S.actions.length){var v=document.createElement("div");v.className="pv-actions";for(var h=0;h<S.actions.length;h++){var x=S.actions[h];x!=null&&(typeof x=="string"?v.insertAdjacentHTML("beforeend",x):x instanceof Node&&v.appendChild(x))}O(".pv-titlebar").insertBefore(v,O(".pv-close"))}var T=O(".pv-body");return S.placeholder&&(T.innerHTML=window.StatusTpl.loading()),{overlay:L,scroll:O(".pv-scroll"),head:O(".pv-head"),body:T,titleEl:O(".pv-title"),backBtn:I,closeBtn:O(".pv-close")}}function f(S,L){var O=!1,I=function(){O||!S.isConnected||L(S)};return e&&typeof e.nextPaint=="function"?e.nextPaint(I):setTimeout(I,0),function(){O=!0}}function m(S){for(var L=0,O=window.innerHeight,I=S.getBoundingClientRect(),v=S.parentElement;v&&v.nodeType===1;){var h=getComputedStyle(v).overflowY;if(h==="auto"||h==="scroll"||h==="hidden"){var x=v.getBoundingClientRect();x.top>L&&(L=x.top),x.bottom<O&&(O=x.bottom);for(var T=0;T<v.children.length;T++){var _=v.children[T];if(getComputedStyle(_).position==="sticky"){var g=_.getBoundingClientRect();g.height>0&&g.top<=x.top+1&&g.bottom>L&&g.left<I.right&&g.right>I.left&&(L=Math.max(L,g.bottom))}}}v=v.parentElement}return{top:L,bottom:O}}function E(S,L){if(!(!S||!L)){S.style.visibility="hidden",S.style.display="block";var O=S.offsetHeight;S.style.visibility="",S.style.display="";var I=L.getBoundingClientRect(),v=4,h=8,x=m(L),T=x.bottom-I.bottom-v-h,_=I.top-x.top-v-h,g;O<=T?g=!1:O<=_?g=!0:g=_>T,S.classList.toggle("open-up",g)}}return{__installed:!0,lock:s,unlock:l,applyKeyboardInset:d,cloneFull:y,deferFill:f,placePopup:E}}();(function(){if(window.MobileShell&&window.MobileShell.__installed)return;const e=document.documentElement,t=document.body,n=window.FW_CONTRACTS,i=350,o=40;let s=0,l=0,r=0;["gesturestart","gesturechange","gestureend"].forEach(function(K){document.addEventListener(K,function(X){X.preventDefault()},{passive:!1})}),document.addEventListener("touchend",function(K){if(K.changedTouches.length!==1){s=0;return}const X=Date.now(),ae=K.changedTouches[0],pe=X-s<=i&&Math.abs(ae.clientX-l)<=o&&Math.abs(ae.clientY-r)<=o;s=X,l=ae.clientX,r=ae.clientY,pe&&!L(K.target)&&K.preventDefault()},{passive:!1});const c=120,u=80;let a=null,d=!1,p=null,w=null,y=null,f=null,m=null,E=0;function S(){const K=window.visualViewport;return K&&typeof K.height=="number"?K.height:window.innerHeight||e.clientHeight}function L(K){if(!K||K===document.body)return!1;const X=K,ae=X.tagName;if(!ae)return!1;const pe=ae.toUpperCase();if(pe==="TEXTAREA"||pe==="SELECT")return!0;if(pe==="INPUT"){const ge=(X.type||"text").toLowerCase();return!(ge==="button"||ge==="submit"||ge==="reset"||ge==="file"||ge==="checkbox"||ge==="radio"||ge==="color"||ge==="range"||ge==="hidden"||ge==="image")}return!!X.isContentEditable}function O(){let K=S();const X=window.innerHeight||e.clientHeight||K;K=Math.max(160,Math.min(K,X));const ae=K!==y;if(ae)try{e.style.setProperty("--visual-viewport-height",K+"px")}catch{}return y=K,ae}let I=!1,v=null,h=null;const x=".ms-confirm-overlay";function T(){let K,X,ae,pe;if(d){const me=y;if(typeof me!="number")return;const ge=window.innerHeight||e.clientHeight||me,ke=window.visualViewport,Te=ke&&typeof ke.offsetTop=="number"?ke.offsetTop:0,Le=Math.max(0,Math.min(Te,Math.max(0,ge-me))),Me=Math.max(0,ge-me);if(I&&Le===h&&Me===v)return;const Pe=document.activeElement;for(window.LayerFrame&&typeof LayerFrame.applyKeyboardInset=="function"&&LayerFrame.applyKeyboardInset(Me,Pe),K=document.querySelectorAll(x),X=0;X<K.length;X++)ae=K[X],!ae.classList.contains("lf-lock")&&ae.classList.contains("active")&&(Pe&&Pe!==document.body&&!ae.contains(Pe)||(ae.style.top=Le+"px",pe=ae.firstElementChild,pe&&!ae.classList.contains("ms-confirm-overlay")&&(pe.style.height=me+"px")));I=!0,h=Le,v=Me}else if(I){for(window.LayerFrame&&typeof LayerFrame.applyKeyboardInset=="function"&&LayerFrame.applyKeyboardInset(0,null),K=document.querySelectorAll(x),X=0;X<K.length;X++)K[X].classList.contains("lf-lock")||(K[X].style.top="",pe=K[X].firstElementChild,pe&&(pe.style.height=""));I=!1,h=null,v=null}}function _(){if(d||ve.length>0)return;const K=w;try{window.scrollTo(0,K||0)}catch{}O()}const g=60;function B(){m=null;const K=O();j(),(d||p)&&(E=K?0:E+1,(d||p||E<g)&&(m=requestAnimationFrame(B)))}function A(){E=0,m==null&&typeof requestAnimationFrame=="function"&&(m=requestAnimationFrame(B))}function k(){p&&!p.isConnected&&(p=null)}function P(){const K=document.activeElement;if(!K)return!0;const X=K.tagName;return X&&X.toUpperCase()==="IFRAME"?!1:!L(K)}function j(){k();const K=S();a==null&&(a=K),!d&&K>a&&(a=K);const X=Math.max(0,a-K);!d&&X>=c&&p&&L(p)?(d=!0,w==null&&(w=window.scrollY||window.pageYOffset||0),e.classList.add(n.KEYBOARD_OPEN_CLASS),Z(!0,X)):d&&(X<=u||P())&&(d=!1,a=Math.max(a,K),e.classList.remove(n.KEYBOARD_OPEN_CLASS),Z(!1,0),setTimeout(_,80),setTimeout(_,300));try{const ae=(d?X:0)+"px";ae!==f&&(f=ae,e.style.setProperty("--keyboard-inset",ae))}catch{}T()}function Z(K,X){try{document.dispatchEvent(new CustomEvent(n.KEYBOARD_EVENT,{detail:{open:K,inset:X}}))}catch{}}function N(K,X){if(!(!K||typeof K.scrollIntoView!="function"))try{K.scrollIntoView({block:"nearest",inline:"nearest",behavior:X||"auto"})}catch{try{K.scrollIntoView()}catch{}}}let ee=null;function ie(K,X){K&&(ee&&clearTimeout(ee),ee=window.setTimeout(function(){ee=null,!(p!==K||!L(K))&&N(K,"auto")},X))}function W(K){const X=K&&K.target;if(!L(X)){p=null,setTimeout(j,80);return}p=X,w=window.scrollY||window.pageYOffset||0,j(),A(),ie(X,120)}function q(){p=null,setTimeout(j,120)}function F(){const K=y;O(),j(),A(),p&&d&&K!=null&&y!==null&&y<K&&ie(p,250)}let M=0,G=null,re="";function ce(){try{M===0&&(G={position:t.style.position,top:t.style.top,left:t.style.left,right:t.style.right,width:t.style.width,overflow:t.style.overflow,paddingRight:t.style.paddingRight,scrollY:window.scrollY||window.pageYOffset||0},re=e.style.overflow,t.style.position="fixed",t.style.top="-"+G.scrollY+"px",t.style.left="0",t.style.right="0",t.style.width="100%",t.style.overflow="hidden",e.style.overflow="hidden",e.classList.add("ms-locked")),M+=1}catch{}}function H(){try{if(M===0||(M-=1,M>0))return;if(!G){M=0;return}const K=G.scrollY||0;t.style.position=G.position||"",t.style.top=G.top||"",t.style.left=G.left||"",t.style.right=G.right||"",t.style.width=G.width||"",t.style.overflow=G.overflow||"",t.style.paddingRight=G.paddingRight||"",e.style.overflow=re||"",e.classList.remove("ms-locked"),G=null,requestAnimationFrame(function(){try{window.scrollTo(0,K)}catch{}})}catch{}}const te=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])',"iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])'].join(",");function oe(K){if(!K)return[];const X=K.querySelectorAll(te),ae=[];for(let pe=0;pe<X.length;pe++){const me=X[pe];me.offsetWidth===0&&me.offsetHeight===0&&me.getClientRects().length===0||me.getAttribute("aria-hidden")!=="true"&&(me.disabled||ae.push(me))}return ae}const ve=[];function Se(K,X){e.classList.add("modal-open");const ae=t.querySelector(".app-canvas, .app-root, main, #content, .app-content"),pe=[];ae&&ae!==X&&!ae.contains(X)&&pe.push(ae);try{for(let me=0;me<pe.length;me++){const ge=pe[me];"inert"in ge?ge.inert=!0:ge.setAttribute("aria-hidden","true")}}catch{}return function(){try{for(let ge=0;ge<pe.length;ge++){const ke=pe[ge];"inert"in ke?ke.inert=!1:ke.removeAttribute("aria-hidden")}}catch{}}}function se(K,X){if(!K)return null;X=X||{};const ae=document.activeElement,pe=X.opener||ae;K.getAttribute("role")||K.setAttribute("role","dialog"),K.getAttribute("aria-modal")||K.setAttribute("aria-modal","true"),X.labelledBy&&!K.getAttribute("aria-labelledby")&&K.setAttribute("aria-labelledby",X.labelledBy),K.setAttribute("aria-hidden","false"),p=null,ce();const me=Se(!0,K);K.classList.add("active"),K.__msPrevFocus=ae,O(),j(),setTimeout(function(){try{if(X.initialFocus===!1){const Pe=document.activeElement;if(Pe&&Pe!==document.body&&K.contains(Pe))return;K.hasAttribute("tabindex")||K.setAttribute("tabindex","-1"),K.focus({preventScroll:!0});return}const Te=K.getAttribute("aria-labelledby"),Le=Te?document.getElementById(Te):K.querySelector("h1,h2,h3,h4");Le&&!Le.hasAttribute("tabindex")&&Le.setAttribute("tabindex","-1");const Me=oe(K)[0]||Le||K;Me&&typeof Me.focus=="function"&&Me.focus({preventScroll:!0})}catch{}},30);const ge={overlay:K,opener:pe,onClose:typeof X.onClose=="function"?X.onClose:null,releaseInert:me,prevFocus:ae};ve.push(ge),A();const ke=K;return ke.__msKeyBound||(ke.__msKeyBound=!0,K.addEventListener("keydown",function(Te){if(!K.classList.contains("active"))return;if(Te.key==="Escape"){Te.preventDefault(),Ae(K);return}if(Te.key!=="Tab")return;const Le=oe(K);if(Le.length===0){Te.preventDefault();return}const Me=Le[0],Pe=Le[Le.length-1],De=document.activeElement;Te.shiftKey?(De===Me||!K.contains(De))&&(Te.preventDefault(),Pe.focus()):De===Pe&&(Te.preventDefault(),Me.focus())})),ge}function Ae(K){if(!K||!K.classList.contains("active"))return;let X=null;for(let pe=ve.length-1;pe>=0;pe--)if(ve[pe].overlay===K){X=ve.splice(pe,1)[0];break}K.classList.remove("active"),K.setAttribute("aria-hidden","true");try{X&&X.releaseInert&&X.releaseInert()}catch{}const ae=X&&X.opener||X&&X.prevFocus;if(ae&&typeof ae.focus=="function"&&document.contains(ae))try{ae.focus({preventScroll:!0})}catch{}if(X&&X.onClose)try{X.onClose()}catch{}H(),ve.length===0&&e.classList.remove("modal-open")}function xe(){return ve.length>0}let be=null,b=null;function R(){be&&document.contains(be)||(be=document.createElement("div"),be.className="ms-confirm-overlay",be.setAttribute("role","dialog"),be.setAttribute("aria-modal","true"),be.setAttribute("aria-hidden","true"),be.innerHTML='<div class="ms-confirm" role="document"><div class="ms-confirm-title" id="msConfirmTitle"></div><div class="ms-confirm-message" id="msConfirmMessage"></div><div class="ms-confirm-actions"><button type="button" class="ms-confirm-cancel" id="msConfirmCancel">取消</button><button type="button" class="ms-confirm-ok" id="msConfirmOk">确定</button></div></div>',document.body.appendChild(be),b={overlay:be,title:be.querySelector("#msConfirmTitle"),message:be.querySelector("#msConfirmMessage"),cancel:be.querySelector("#msConfirmCancel"),ok:be.querySelector("#msConfirmOk")},be.addEventListener("click",function(K){K.target===be&&J(!1)}))}let D=null;function J(K){if(!D)return;const X=D;if(D=null,X.escHandler)try{document.removeEventListener("keydown",X.escHandler,!0)}catch{}try{be&&Ae(be)}catch{}try{be&&be.style.removeProperty("z-index")}catch{}X.resolve(K)}function V(){if(!be)return;if(window.LayerManager){LayerManager.raise(be,{baseline:LayerManager.LEVELS.STD,offset:25,ge:!0});return}let K=0;const X=document.querySelectorAll(".pv-overlay");for(let ae=0;ae<X.length;ae++){const pe=X[ae];if(pe===be)continue;const me=window.getComputedStyle(pe);if(me.display==="none")continue;const ge=parseInt(me.zIndex,10)||0;ge>K&&(K=ge)}K>=4100?be.style.zIndex=String(K+25):be.style.removeProperty("z-index")}function $(K,X){if(X=X||{},typeof Promise>"u")return{then:function(me){return me(!0),this}};if(R(),D)try{J(!1)}catch{}b.title.textContent=X.title||"",b.title.style.display=X.title?"":"none",b.message.textContent=String(K??"");const ae=X.confirmText||"确定",pe=X.cancelText||"取消";return b.ok.textContent=ae,b.cancel.textContent=pe,b.ok.classList.toggle("danger",!!X.danger),b.ok.onclick=function(){J(!0)},b.cancel.onclick=function(){J(!1)},be.setAttribute("aria-labelledby","msConfirmMessage"),new Promise(function(me){D={resolve:me},D.escHandler=function(ge){ge.key==="Escape"&&(ge.preventDefault(),ge.stopPropagation(),J(!1))},document.addEventListener("keydown",D.escHandler,!0),V(),se(be,{labelledBy:"msConfirmMessage"})})}let ne=null,C=0,z="",Y=0;const ue=8e3;function he(K){const X=K||ne;X&&(C&&(window.clearTimeout(C),C=0),X.parentNode&&X.parentNode.removeChild(X),X===ne&&(ne=null))}function Ee(){const K=document.querySelectorAll(".pv-overlay");for(let pe=K.length-1;pe>=0;pe--){const me=K[pe];if(!me.isConnected||window.getComputedStyle(me).display==="none")continue;const ge=me.querySelector(".pv-scroll");if(ge)return{host:ge,before:ge.querySelector(".pv-body")}}const X=document.querySelector(".app-view-active");if(X){const me=X.querySelector(".container")||X;return{host:me,before:me.firstChild}}const ae=document.getElementById("app");return ae?{host:ae,before:ae.firstChild}:document.body?{host:document.body,before:document.body.firstChild}:null}function Q(K,X){if(X=X||{},typeof document>"u"||!document.body)return;const ae=X.type||"info";if(ae!=="error"&&ae!=="warn")return;const pe=String(K??"");if(!pe)return;const me=Ee();if(!me)return;const ge=ae+"\0"+pe;if(ge===z&&Date.now()-Y<ue)return;z=ge,Y=Date.now(),he();const ke=document.createElement("div");ke.className="ms-inline-notice "+ae,ke.setAttribute("role","alert"),ke.textContent=pe,ke.title="点击关闭",me.before&&me.before.parentNode===me.host?me.host.insertBefore(ke,me.before):me.host.appendChild(ke),ne=ke,ke.addEventListener("click",function(){he(ke)}),C=window.setTimeout(function(){he(ke)},X.duration||6e3)}function de(K){if(K)try{K.focus({preventScroll:!1}),ie(K,80)}catch{}}function fe(){document.addEventListener("focusin",W,!0),document.addEventListener("focusout",q,!0),window.visualViewport&&typeof window.visualViewport.addEventListener=="function"?(window.visualViewport.addEventListener("resize",F),window.visualViewport.addEventListener("scroll",F)):window.addEventListener("resize",F),window.addEventListener("orientationchange",function(){a=null,setTimeout(function(){O(),j()},200)}),document.addEventListener(window.FW_CONTRACTS&&window.FW_CONTRACTS.ROUTE_CHANGE_EVENT||"app-shell:routechange",function(){he()}),O()}fe();const ye=(window.__SITE__&&window.__SITE__.slug||"site")+".sessionToken.v1";let we=function(){try{return sessionStorage.getItem(ye)||""}catch{return""}}();const Ce="X-Session-Token";function U(){try{we?sessionStorage.setItem(ye,we):sessionStorage.removeItem(ye)}catch{}}function le(K){we=typeof K=="string"?K:"",U()}function _e(){le("")}if(!window.__fetchWrappedForSessionToken){const K=window.fetch&&window.fetch.bind(window);window.fetch=function(X,ae){if(!K||!we)return K(X,ae);ae=ae||{};const pe=new Headers;try{ae.headers instanceof Headers?ae.headers.forEach(function(me,ge){pe.append(ge,me)}):Array.isArray(ae.headers)?ae.headers.forEach(function(me){me&&me.length>=2&&pe.append(me[0],me[1])}):ae.headers&&typeof ae.headers=="object"&&Object.keys(ae.headers).forEach(function(me){pe.append(me,ae.headers[me])})}catch{}return pe.has(Ce)||pe.set(Ce,we),ae.headers=pe,K(X,ae)},window.__fetchWrappedForSessionToken=!0}window.MobileShell={__installed:!0,lockScroll:ce,unlockScroll:H,openOverlay:se,closeOverlay:Ae,isOpen:xe,confirm:$,notify:Q,focusField:de,setSessionToken:le,clearSessionToken:_e,getSessionToken:function(){return we}}})();(function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};e.escapeHtml=function(i){return String(i??"").replace(/[&<>"']/g,o=>t[o]??o)}})(window);(function(){function e(a){a=a||{};var d=window.__effectiveRole(a);return Object.assign({},a,{role:a.role||"guest",roles:a.roles||[],username:a.username||"",avatar_url:a.avatar_url||"",can_usermgmt:!!a.can_usermgmt,effectiveRole:d})}window.__onAuthReady=window.__onAuthReady||function(a){if(window.__me){a(window.__me);return}document.addEventListener("auth:ready",function d(p){document.removeEventListener("auth:ready",d),a(p.detail)})},window.__effectiveRole=window.__effectiveRole||function(a){return a?a.role:"guest"},window.__isManager=window.__isManager||function(a){var d=window.__gate;if(d&&typeof d.is_manager=="boolean")return d.is_manager;var p=a||window.__me,w=p&&(p.effectiveRole||p.role)||"guest";return w==="admin"||w==="root"},window.__logout=window.__logout||function(){var a=window.MobileShell&&typeof window.MobileShell.getSessionToken=="function"?window.MobileShell.getSessionToken():"";window.MobileShell&&typeof window.MobileShell.clearSessionToken=="function"&&window.MobileShell.clearSessionToken();var d={};return a&&(d["X-Session-Token"]=a),s("/api/auth/logout",{method:"POST",headers:d}).then(function(){window.ChatHistoryCache&&window.ChatHistoryCache.clearAll(),location.reload()}).catch(function(p){console.error("logout 失败:",p),location.reload()})},window.__requireLogin=window.__requireLogin||function(a){var d=window.__me;return d&&d.role!=="guest"?!0:(window.MobileShell&&window.MobileShell.confirm&&window.MobileShell.confirm(a?"登录后才能"+a:"请先登录",{title:"需要登录",confirmText:"去登录",cancelText:"取消"}).then(function(p){p&&(location.href="/login")}),!1)};var t={viewer_caps:[],is_manager:!1,card_actions:{},ui_actions:{},entries:{}},n={};function i(a,d){n[a]||(n[a]=!0,window.MobileShell&&typeof window.MobileShell.notify=="function"&&window.MobileShell.notify(d,{type:"warn",duration:4e3}))}function o(a,d,p){return a().catch(function(w){if(d<=1)throw w;return new Promise(function(y){setTimeout(y,p)}).then(function(){return o(a,d-1,p*2)})})}function s(a,d){var p=window.__apiReady||Promise.resolve("");return p.then(function(){var w=window.apiUrl?window.apiUrl(a):a,y=typeof AbortController=="function"?new AbortController:null,f=y?setTimeout(function(){y.abort()},8e3):null,m=Object.assign({credentials:"include"},d||{});return y&&!m.signal&&(m.signal=y.signal),fetch(w,m).then(function(E){return f&&clearTimeout(f),E},function(E){throw f&&clearTimeout(f),E})})}function l(){return o(function(){return s("/api/auth/me",{cache:"no-store"}).then(function(a){if(a.status===401)return{role:"guest",username:""};if(!a.ok)throw new Error("me http "+a.status);return a.json()})},3,800).catch(function(){return window.__me?(i("identity","身份信息加载失败,暂用本地身份"),window.__me):{role:"guest",username:""}})}function r(){return o(function(){return s("/api/gate",{cache:"no-store"}).then(function(a){if(!a.ok)throw new Error("gate http "+a.status);return a.json()})},3,800).catch(function(){return window.__gate?(i("gate","权限信息加载失败,暂用本地权限"),window.__gate):t})}var c=!1;document.addEventListener("api:unauthorized",function(){c||(c=!0,i("unauthorized","登录状态已失效,请重新登录"),setTimeout(function(){c=!1},3e4),u())});function u(){return Promise.all([l(),r()]).then(function(a){var d=a[0],p=a[1];window.__gate=p;var w=e(d);window.__me=w,w&&w.role&&w.role!=="guest"&&s("/api/auth/reissue-cookie",{cache:"no-store"}).catch(function(){});try{document.dispatchEvent(new CustomEvent("auth:ready",{detail:w}))}catch{}return w})}(function(){var d=window.__fwBootPrefetch&&window.__fwBootPrefetch.bootstrap;if(!d){u();return}d.then(function(p){if(p&&p.me&&p.gate){window.__gate=p.gate;var w=e(p.me);window.__me=w,document.dispatchEvent(new CustomEvent("auth:ready",{detail:w})),w&&w.role&&w.role!=="guest"&&s("/api/auth/reissue-cookie",{cache:"no-store"}).catch(function(){})}else u()}).catch(function(){u()})})(),window.__refreshAuth=u})();(function(e){e.avatarHtml=function(d,p,w){let y,f,m;return d&&typeof d=="object"&&!Array.isArray(d)?(y=d.avatar_url,f=d.username,m=p||"avatar"):(y=d,f=p,m=w||"avatar"),y&&typeof y=="string"&&y.indexOf("emoji:")===0?`<span class="${m} avatar-emoji">${escapeHtml(y.slice(6))}</span>`:`<span class="${m}">${escapeHtml((f||"?").trim().charAt(0)||"?")}</span>`},e.showAvatarZoom=function(d,p){e.ImagePreview?e.ImagePreview.open(d,{alt:p||""}):e.open(d,"_blank","noopener")};const t=15e3,n=600,i=new Map,o=e.__apiReady||Promise.resolve("");e.apiReady=o,e.apiUrl=e.apiUrl||function(d){return(e.__apiBaseUrl||"")+d};function s(a){const d=new Error("网络连接失败,请检查网络后重试");return d.status=0,d.retryable=!0,d.cause=a,d}function l(a,d){const p=!e.__me||e.__me.role==="guest";return a===401?"登录状态已失效,请重新登录":a===403?p?/community\.read/.test(d)?"登录后可浏览内容":"登录后即可使用":"当前账号没有该权限":a===429?"操作过于频繁,请稍后再试":d}e.api=async function(d,p){p=Object.assign({},p);const w=typeof FormData<"u"&&p.body instanceof FormData?{}:{"Content-Type":"application/json"};p.headers=Object.assign(w,p.headers);const y=String(p.method||"GET").toUpperCase(),f=p.signal||null;delete p.signal;const m=y==="GET"||y==="HEAD"?2:1;let E=null;const S=e.apiUrl(d);await o;const L=(y==="GET"||y==="HEAD")&&!f,O=y+" "+S+" "+(typeof p.body=="string"?p.body:"");if(L){const v=i.get(O);if(v)return v}const I=async function(){for(let v=0;v<m;v++)try{return await r(S,p,y,f)}catch(h){if(E=h,v+1>=m||!h.retryable)throw h;await new Promise(function(x){setTimeout(x,n)})}throw E}();return L&&(i.set(O,I),I.then(function(){i.delete(O)},function(){i.delete(O)})),I};async function r(a,d,p,w){const y=typeof AbortSignal.timeout=="function"?AbortSignal.timeout(t):null;let f=null;w&&y&&typeof AbortSignal.any=="function"?f=AbortSignal.any([w,y]):w?f=w:y&&(f=y);const m=Object.assign({},d,{method:p});f&&(m.signal=f),m.credentials="include";let E;try{E=await fetch(a,m)}catch(L){if(L&&L.name==="AbortError"&&w&&w.aborted)throw L;if(L&&L.name==="AbortError"&&y){const O=new Error("网络请求超时,请稍后重试");throw O.status=0,O.retryable=!0,O}throw s(L)}let S=null;try{S=await E.json()}catch{}if(!E.ok){const L=S&&(S.detail||S.message)||"",O=L||(E.status===422?"请求参数错误":E.status>=500?"服务暂时不可用,请稍后重试":"请求失败"),I=new Error(l(E.status,O));if(I.status=E.status,I.detail=L,I.retryable=E.status>=500||E.status===429,E.status===401&&e.__me&&e.__me.role!=="guest")try{document.dispatchEvent(new CustomEvent("api:unauthorized"))}catch{}throw I}return S}e.__fwApiFetch=e.api,e.apiFn=function(){return typeof e.api=="function"?e.api:e.__fwApiFetch},e.execWorkCode=function(d,p){try{new Function(String(d||"")+(p?`
1558
+ //# sourceURL=`+p:""))()}catch(w){throw setTimeout(function(){throw w},0),new Error("作品脚本执行失败:"+(w&&w.message?w.message:w))}},e.execWorkScript=function(d){return fetch(d,{credentials:"include"}).then(function(p){if(!p.ok)throw new Error("作品脚本加载失败(HTTP "+p.status+")");return p.text()}).then(function(p){e.execWorkCode(p,d)})},e.fmtTime=function(d){return d?String(d).replace("T"," ").slice(0,16):""},e.fmtFullTime=function(d){const p=String(d||"").match(/^(\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}:\d{2})/);return p?p[1]+" "+p[2]:String(d||"")},e.fmtListTime=function(d){if(!d)return"";const p=new Date(d);if(isNaN(p.getTime()))return"";const w=new Date;if(p.toDateString()===w.toDateString())return p.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1});const f=new Date(w);return f.setDate(w.getDate()-1),p.toDateString()===f.toDateString()?"昨天":p.getMonth()+1+"月"+p.getDate()+"日"};const c={};e.ensureStylesheet=function(d){if(c[d])return c[d];const w=(e.CDN_ENABLED&&e.CDN_DOMAIN?e.CDN_DOMAIN:"")+d+(e.__STATIC_V?"?v="+encodeURIComponent(e.__STATIC_V):""),y=new URL(w,location.href).href;return Array.prototype.some.call(document.querySelectorAll('head link[rel="stylesheet"]'),m=>m.href===y)?(c[d]=Promise.resolve(),c[d]):(c[d]=new Promise(m=>{const E=document.createElement("link");E.rel="stylesheet",E.href=w,E.onload=m,E.onerror=m,document.head.appendChild(E)}),c[d])};const u={};e.ensureScript=e.ensureScript||function(d,p){const w=!!(p&&p.force),f=(e.CDN_ENABLED&&e.CDN_DOMAIN?e.CDN_DOMAIN:"")+d+(e.__STATIC_V?"?v="+encodeURIComponent(e.__STATIC_V):"");if(!w){if(u[d])return u[d];const m=new URL(f,location.href).href;if(Array.prototype.some.call(document.querySelectorAll("script[src]"),S=>S.src===m))return u[d]=Promise.resolve(),u[d]}return u[d]=new Promise((m,E)=>{const S=document.createElement("script");if(w){const L=document.querySelector('script[src^="'+d+'"]');S.src=L?L.src:f}else S.src=f;S.onload=m,S.onerror=()=>{delete u[d],E(new Error("脚本加载失败:"+d))},document.head.appendChild(S)}),u[d]},e.onDomReady=e.onDomReady||function(d){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()}})(window);(function(e){e.postBootProbe=e.postBootProbe||function(n){try{fetch(e.apiUrl("/api/boot-probe"),{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:typeof n=="string"?n:JSON.stringify(n)}).catch(function(){})}catch{}},e.lookupRefItem=e.lookupRefItem||function(n){var i=typeof e.apiFn=="function"?e.apiFn():e.api;if(typeof i!="function")return Promise.resolve(null);var o=String(n||"").trim();return o?i("/api/refs/lookup?ref="+encodeURIComponent(o)).then(function(s){return s&&s.item||null}):Promise.resolve(null)},e.injectOwnedStyle=e.injectOwnedStyle||function(n,i){if(document.head.querySelector('style[data-rg-style="'+n+'"]'))return;const o=document.createElement("style");o.textContent=i,o.setAttribute("data-rg-owned","1"),o.setAttribute("data-rg-style",n),document.head.appendChild(o)}})(window);(function(e){if(e.Caps&&e.Caps.__installed)return;function t(o){const s=e.__gate,l=s&&Array.isArray(s.viewer_caps)?s.viewer_caps:null;return l?l.indexOf(o)!==-1:!0}function n(){const o=e.__me;return!o||o.role==="guest"}function i(){if(!t("community.read"))throw new Error("登录后可浏览内容")}e.Caps={__installed:!0,has:t,isGuest:n,requireCommunityRead:i}})(window);(function(e){var t="fwGateKeys::v2",n=3e5,i=["ui","card","entries","caps"];function o(){return{ui:{},card:{},entries:{},caps:{}}}function s(){if(!e.GateKeys){e.GateKeys=o();return}for(var a=e.GateKeys,d=0;d<i.length;d++){var p=i[d];(!a[p]||typeof a[p]!="object")&&(a[p]={})}}function l(a){if(!a||typeof a!="object")return!1;s();for(var d=!1,p=e.GateKeys,w=0;w<i.length;w++){var y=i[w],f=a[y];if(!(!f||typeof f!="object"))for(var m in f)Object.prototype.hasOwnProperty.call(f,m)&&(p[y][m]=f[m],d=!0)}return d}function r(){try{var a=e.sessionStorage.getItem(t);if(!a)return null;var d=JSON.parse(a);return!d||typeof d.t!="number"||!d.keys||Date.now()-d.t>=n?(e.sessionStorage.removeItem(t),null):d.keys}catch{return null}}function c(a){try{e.sessionStorage.setItem(t,JSON.stringify({t:Date.now(),keys:a}))}catch{}}s();var u=r();if(u&&l(u)){console.info("[GateKeys] 会话缓存命中(5min TTL)");return}e.api("/api/gate-keys").then(function(a){if(!a||!l(a.keys))throw new Error("GateKeys 响应缺 keys 字段");c(a.keys),console.info("[GateKeys] 运行时加载完成")}).catch(function(a){console.error("[GateKeys] 加载失败,权限入口按无权限降级:",a)})})(window);(function(){function e(l){if(l==null)return null;if(typeof l=="number"&&Number.isFinite(l))return{kind:"id",id:l};const r=String(l);if(/^-?\d+$/.test(r)){const u=parseInt(r,10);if(Number.isFinite(u))return{kind:"id",id:u}}const c=r.trim();return c?{kind:"username",key:c}:null}const t=new Map;function n(l){if(t.has(l))return t.get(l);const r=fetch((window.apiUrl?window.apiUrl("/api/u/by-username/"):"/api/u/by-username/")+encodeURIComponent(l),{headers:{Accept:"application/json"},credentials:"include"}).then(function(c){return c.ok?c.json():null}).then(function(c){return c&&c.status==="ok"&&c.user&&Number.isFinite(c.user.id)?c.user.id:null}).catch(function(){return null}).then(function(c){return c==null?t.delete(l):t.set(l,Promise.resolve(c)),c});return t.set(l,r),r}function i(l){const r=e(l);return r==null?Promise.resolve(null):r.kind==="id"?Promise.resolve(r.id):n(r.key)}function o(l,r){if(l==null||l==="")return;const c=e(l);if(c==null)return;c.kind==="id"?u(c.id):n(c.key).then(u);function u(a){if(a==null){window.MobileShell&&window.MobileShell.notify("未找到该用户(可能已注销或网络异常)",{type:"error"});return}const d=window.ProfileOrchestrator.planOpen({userId:a,opts:r});window.Orchestrator.execute(d,{openProfile:function(p,w){if(window.ProfileView){window.ProfileView.open({userId:p},w);return}window.LateGate&&window.LateGate.ensure&&window.LateGate.ensure("ProfileView").then(function(y){y&&y.open({userId:p},w)}).catch(function(){})},notify:function(p){window.MobileShell&&window.MobileShell.notify(p,{type:"error"})}})}}window.openUserProfile=o,window.resolveUserId=i;function s(){return window.MyView&&window.MyView._internals&&typeof MyView._internals.getUser=="function"?MyView._internals.getUser()||{role:"guest",username:""}:{role:"guest",username:""}}window.currentUser=s,window.resolveUsername=n})();window.Theme=window.Theme||function(){var e=["light","dark"],t="light";function n(){return(window.__SITE__&&window.__SITE__.slug||"site")+"_theme"}function i(f){return f!==null&&e.indexOf(f)>=0}function o(){var f=document.documentElement.getAttribute("data-theme");return i(f)?f:t}function s(f){i(f)||(f=t);var m=document.documentElement,E=o(),S=function(){o()!==f&&m.setAttribute("data-theme",f),a();try{document.dispatchEvent(new CustomEvent("theme-changed",{detail:{mode:f,previous:E}}))}catch{}};return E!==f?u(m,S):S(),f}var l="theme-vt",r=1e3,c=0;function u(f,m){var E=window.Motion&&window.Motion.reduced&&window.Motion.reduced();if(E||!document.startViewTransition){m();return}var S=++c,L=function(){S===c&&f.classList.remove(l)},O=function(){L()};f.classList.add(l);var I;try{I=document.startViewTransition(m)}catch{O(),m();return}I.finished.then(O,O),setTimeout(O,r)}function a(){var f=document.querySelector('meta[name="theme-color"]');f||(f=document.createElement("meta"),f.setAttribute("name","theme-color"),(document.head||document.documentElement).appendChild(f));try{var m=getComputedStyle(document.documentElement).getPropertyValue("--neu-bg");m&&f.setAttribute("content",m.trim())}catch{}}function d(f){if(!i(f))return Promise.reject(new Error("未知主题:"+f));try{return localStorage.setItem(n(),f),Promise.resolve()}catch(m){return Promise.reject(new Error("主题未能保存到本机:"+(m.message||m)))}}function p(){return(window.__SITE__&&window.__SITE__.slug||"site")+"_theme_follow_ext"}function w(){try{return localStorage.getItem(p())==="1"}catch{return!1}}function y(f){try{localStorage.setItem(p(),f?"1":"0")}catch{}return f}return{current:o,apply:s,persist:d,followExt:w,setFollowExt:y}}();window.ThemeSync=window.ThemeSync||function(){var e=1e4,t=null;async function n(){if(!(!window.Theme||!window.Theme.followExt||!window.Theme.followExt())){var s;try{var l=await window.api("/api/theme/sync");s=l&&(l.mode==="light"||l.mode==="dark")?l.mode:null}catch{return}!s||s===t||(t=s,window.Theme.current()!==s&&(window.Theme.apply(s),window.Theme.persist(s).catch(function(){})))}}var i=void 0;function o(){i||(i=window.setInterval(function(){window.Theme&&window.Theme.followExt&&window.Theme.followExt()?n():t=null},e))}return{refresh:n,start:o}}();window.ThemeSync.start();(function(e){if(e.StatusNotify&&e.StatusNotify.__installed)return;function t(o,s){const l=document.getElementById("statusRegion");l&&(l.textContent=o||"",l.classList.remove("error","warn","success"),s==="error"?l.classList.add("error"):s==="warn"?l.classList.add("warn"):s==="success"&&l.classList.add("success"))}function n(o,s){t(o,s);const l=e.MobileShell;l&&l.notify&&l.notify(o,{type:s})}function i(o,s){const l=e.MobileShell;l&&l.notify&&l.notify(o,{type:s})}e.StatusNotify={__installed:!0,error:function(o){i(o,"error")},warn:function(o){n(o,"warn")},ok:function(o){n(o,"success")},info:function(o){n(o,"info")},clear:function(){t("","")}}})(window);window.ImagePreview=window.ImagePreview||function(){const e="ip-overlay";let t=null;function n(I){return Math.max(1,Math.min(8,I))}function i(){!t||!t.img||(t.img.style.transform="translate("+t.tx+"px,"+t.ty+"px) scale("+t.s+")")}function o(){t&&(t.s=1,t.tx=0,t.ty=0,i())}function s(I,v,h){if(!t)return;const x=n(t.s*h);if(x===t.s)return;const T=x/t.s;t.tx=I-(I-t.tx)*T,t.ty=v-(v-t.ty)*T,t.s=x,i()}let l=0;function r(I){if(!t)return;const v=Date.now();if(v-l<300){if(I.preventDefault(),I.stopPropagation(),t.s>1.05)o();else{const h=t.imgWrap.getBoundingClientRect();s(h.width/2,h.height/2,2)}l=0}else l=v}function c(I){if(!t)return;I.preventDefault();const v=t.imgWrap.getBoundingClientRect(),h=I.deltaY<0?1.15:1/1.15;s(I.clientX-v.left,I.clientY-v.top,h)}const u=new Map;let a=null,d=null;function p(I){if(t)if(u.set(I.pointerId,{x:I.clientX,y:I.clientY}),u.size===2){const v=Array.from(u.values());a={d:Math.hypot(v[0].x-v[1].x,v[0].y-v[1].y),s:t.s,cx:(v[0].x+v[1].x)/2,cy:(v[0].y+v[1].y)/2},d=null}else u.size===1&&t.s>1.05&&(d={x:I.clientX,y:I.clientY,tx:t.tx,ty:t.ty},a=null)}function w(I){if(t&&u.has(I.pointerId))if(u.set(I.pointerId,{x:I.clientX,y:I.clientY}),u.size===2&&a){const v=Array.from(u.values()),h=Math.hypot(v[0].x-v[1].x,v[0].y-v[1].y),x=t.imgWrap.getBoundingClientRect();s(a.cx-x.left,a.cy-x.top,h/a.d*(a.s/t.s))}else u.size===1&&d&&(t.tx=d.tx+(I.clientX-d.x),t.ty=d.ty+(I.clientY-d.y),i())}function y(I){u.delete(I.pointerId),u.size<2&&(a=null),u.size===0&&(d=null)}function f(I){if(t){if(I.key==="Escape"){I.stopPropagation(),I.preventDefault(),S();return}t.images&&t.images.length>1&&(I.key==="ArrowLeft"?(I.preventDefault(),O(t.images,(t.index-1+t.images.length)%t.images.length)):I.key==="ArrowRight"&&(I.preventDefault(),O(t.images,(t.index+1)%t.images.length)))}}function m(I){t&&I.target===t.overlay&&S()}function E(I,v){if(!I)return;const h=v||{};O([{src:I,alt:h.alt,title:h.title}],0)}function S(){t&&(document.removeEventListener("keydown",f,!0),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),t.overlay&&t.overlay.parentNode&&t.overlay.parentNode.removeChild(t.overlay),u.clear(),a=null,d=null,t=null)}function L(){return!!t}function O(I,v){t&&S();const h=I[v],x=document.createElement("div");x.className=e;const T=document.createElement("div");T.className="ip-stage";const _=document.createElement("div");_.className="ip-img-wrap";const g=document.createElement("img");g.className="ip-img",g.src=h.src,g.alt=h.alt||"",g.draggable=!1,_.appendChild(g),g.addEventListener("error",function(){const A=document.createElement("div");A.className="ip-error",A.textContent="图片加载失败",g.replaceWith(A)}),T.appendChild(_),x.appendChild(T);const B=document.createElement("button");if(B.type="button",B.className="ip-close",B.setAttribute("aria-label","关闭"),B.textContent="×",B.addEventListener("click",function(A){A.stopPropagation(),S()}),x.appendChild(B),h.title||h.alt||I.length>1){const A=document.createElement("div");A.className="ip-title";const k=h.title||h.alt||"";if(k&&(A.textContent=k),I.length>1){const P=document.createElement("span");P.className="ip-counter",P.textContent=v+1+" / "+I.length,A.appendChild(P)}x.appendChild(A)}if(I.length>1){const A=document.createElement("button");A.type="button",A.className="ip-nav ip-nav-prev",A.setAttribute("aria-label","上一张"),A.textContent="‹",A.addEventListener("click",function(P){P.stopPropagation(),O(I,(v-1+I.length)%I.length)}),x.appendChild(A);const k=document.createElement("button");k.type="button",k.className="ip-nav ip-nav-next",k.setAttribute("aria-label","下一张"),k.textContent="›",k.addEventListener("click",function(P){P.stopPropagation(),O(I,(v+1)%I.length)}),x.appendChild(k)}x.addEventListener("click",m),_.addEventListener("click",r),_.addEventListener("wheel",c,{passive:!1}),_.addEventListener("pointerdown",p),window.addEventListener("pointermove",w),window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),document.addEventListener("keydown",f,!0),document.body.appendChild(x),window.LayerFrame&&(LayerFrame.lock(x),g.style.maxHeight=Math.max(120,x.clientHeight-80)+"px"),t={images:I,index:v,overlay:x,img:g,imgWrap:_,s:1,tx:0,ty:0}}return{open:E,close:S,isOpen:L,__installed:!0}}();window.ImageRender=function(){const e=/^((?:\/api\/cos\/image|\/static\/uploads)\/)([0-9a-f]{64})\.([a-z0-9]+)(\?.*)?$/i;function t(c,u){if(!c||typeof c!="string")return"";const a=e.exec(c);if(!a)return"";const d=a[1],p=a[2],w=a[4]||"";return`${d}${p}.${u}.webp${w}`}function n(c,u){return`<div class="${escapeHtml(c)} empty">${escapeHtml(u||"无图片")}</div>`}function i(c){const u=c&&(c.thumb_url||t(c.image_url,"thumb")||c.image_url)||"";return u&&u.startsWith("/")?(window.__apiBaseUrl||"")+u:u}function o(c,u){u=u||{};const a=u.cls||"item-poster",d=u.w||200,p=u.h||267,w=u.fallback||"无图片",y=u.alt!=null?u.alt:c&&c.name||"",f=i(c);if(!f)return n(a,w);const m=c&&c.image_url||"",E=f===m?"orig":"thumb";return`<img src="${escapeHtml(f)}" class="${escapeHtml(a)}" width="${d}" height="${p}" alt="${escapeHtml(y)}" loading="lazy" decoding="async" data-step="${E}" data-orig="${escapeHtml(m)}" data-cls="${escapeHtml(a)}" data-fbk="${escapeHtml(w)}">`}function s(c,u){u=u||{};const a=u.cls||"giv-img";u.w,u.h;const d=u.fallback||"无图片",p=u.alt!=null?u.alt:c&&c.name||"";let w=c&&(t(c.image_url,"medium")||c.image_url)||"";if(w&&w.startsWith("/")&&(w=(window.__apiBaseUrl||"")+w),!w)return`<div class="${escapeHtml(a)} empty">${escapeHtml(d)}</div>`;let y=c&&c.image_url||"";y&&y.startsWith("/")&&(y=(window.__apiBaseUrl||"")+y);const f=w===y?"orig":"medium";return`<div class="${escapeHtml(a)}"><img src="${escapeHtml(w)}" alt="${escapeHtml(p)}" title="点击查看原图" loading="lazy" decoding="async" data-step="${f}" data-orig="${escapeHtml(y)}" data-cls="${escapeHtml(a)}" data-fbk="${escapeHtml(d)}" data-wrap="1"></div>`}function l(c,u){if(typeof c=="string")return`<div class="${escapeHtml(c)} empty">${escapeHtml(u||"无图片")}</div>`;const a=c||{};return n(a.cls||"item-poster",a.fallback||"无图片")}function r(c){const u=c.target;if(!(!u||u.tagName!=="IMG"||u.dataset.fbk===void 0)){if((u.dataset.step==="thumb"||u.dataset.step==="medium")&&u.dataset.orig){u.dataset.step="orig",u.src=u.dataset.orig;return}u.dataset.wrap==="1"&&u.parentElement?u.parentElement.outerHTML=l(u.dataset.cls,u.dataset.fbk):u.outerHTML=l(u.dataset.cls,u.dataset.fbk)}}return document.addEventListener("error",r,!0),{card:o,detail:s,deriveVariantUrl:t,coverUrl:i}}();window.Fmt=function(){function e(n){return n=Number(n)||0,n>=1e4?(n/1e4).toFixed(1).replace(/\.0$/,"")+"万":String(n)}function t(n){return n=Number(n)||0,n<=0?"":e(n)}return{count:t,formatNumber:e}}();function Xt(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}function Jt(e){return typeof e=="string"}function Mn(e){return typeof e=="boolean"}function yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Pn(e){return Array.isArray(e)}function $e(e,t){return yt(e)&&t in e}function Nn(e,t){return $e(e,t)&&Xt(e[t])}function Rn(e,t){return $e(e,t)&&Jt(e[t])}function On(e){if(!yt(e)||!Nn(e,"id")||!Rn(e,"username"))return!1;const t=["nickname","display_name","avatar","avatar_url","bio","role","role_class","email","api_token","created_at","updated_at","last_seen_at","banned_until","muted_until"];for(const o of t)if($e(e,o)&&e[o]!==null&&e[o]!==void 0&&!Jt(e[o]))return!1;const n=["view_count","work_count","follower_count","following_count"];for(const o of n)if($e(e,o)&&e[o]!==null&&e[o]!==void 0&&!Xt(e[o]))return!1;const i=["is_agent","agent","is_banned","is_muted","is_active","is_verified"];for(const o of i)if($e(e,o)&&e[o]!==null&&e[o]!==void 0&&!Mn(e[o]))return!1;return!($e(e,"permissions")&&e.permissions!==null&&e.permissions!==void 0&&!Pn(e.permissions)||$e(e,"agent_config")&&e.agent_config!==null&&e.agent_config!==void 0&&!yt(e.agent_config)||$e(e,"settings")&&e.settings!==null&&e.settings!==void 0&&!yt(e.settings))}window.TypeGuards={isUser:On};class Hn{constructor(t){const n=(s,l)=>t(s,l),i=async s=>({data:await s}),o=s=>s?"?"+new URLSearchParams(s).toString():"";this.client={get:(s,l)=>i(n(s.includes("?")?s:s+o(l),{method:"GET"})),post:(s,l)=>i(n(s,{method:"POST",body:l!=null?JSON.stringify(l):void 0})),put:(s,l)=>i(n(s,{method:"PUT",body:l!=null?JSON.stringify(l):void 0})),delete:s=>i(n(s,{method:"DELETE"}))}}async openSession(t){return(await this.client.post("/api/sessions",{work_ref:t})).data}async getSession(t){return(await this.client.get(`/api/sessions/${t}`)).data}async getSessionMessages(t,n){try{const i=n?"?"+new URLSearchParams(n).toString():"",o=await this.client.get(`/api/sessions/${t}/messages${i}`);return o.data?(o.data.items&&Array.isArray(o.data.items)&&(o.data.items=o.data.items.filter(s=>s&&typeof s.id=="number"&&typeof s.content=="string")),o.data):{items:[]}}catch(i){throw console.error("TypedApi.getSessionMessages: Failed",t,n,i),i}}async sendSessionMessage(t,n){try{const i=await this.client.post(`/api/sessions/${t}/messages`,n);if(!i.data)throw new Error("发送失败:无响应数据");return i.data}catch(i){throw console.error("TypedApi.sendSessionMessage: Failed",t,i),i}}async getSessionFormConfig(t){try{return(await this.client.get(`/api/sessions/${t}/form-config`)).data||{configured:!1,form:null}}catch(n){return console.error("TypedApi.getSessionFormConfig: Failed",t,n),{configured:!1,form:null}}}async getSessionAgentStatus(t){try{return(await this.client.get(`/api/sessions/${t}/agent-status`)).data||{configured:!1,online:!1}}catch(n){return console.error("TypedApi.getSessionAgentStatus: Failed",t,n),{configured:!1,online:!1}}}async getUserProfile(t,n){try{const i=n?"?"+new URLSearchParams(n).toString():"",o=await this.client.get(`/api/u/${encodeURIComponent(t)}${i}`);if(!o.data)throw new Error("无法获取用户资料");return o.data.user&&window.TypeGuards&&(window.TypeGuards.isUser(o.data.user)||console.warn("TypedApi.getUserProfile: Invalid user data",o.data.user)),o.data}catch(i){throw console.error("TypedApi.getUserProfile: Failed",t,i),i}}async recordProfileView(t){try{await this.client.post(`/api/u/${encodeURIComponent(t)}/view`)}catch(n){console.debug("TypedApi.recordProfileView: Failed",t,n)}}async updateMyProfile(t){try{const n=await this.client.post("/api/my/profile",t);if(!n.data)throw new Error("更新资料失败:无响应数据");return window.TypeGuards&&!window.TypeGuards.isUser(n.data)&&console.warn("TypedApi.updateMyProfile: Invalid user data",n.data),n.data}catch(n){throw console.error("TypedApi.updateMyProfile: Failed",n),n}}async changePassword(t,n){try{await this.client.post("/api/my/password",{old_password:t,new_password:n})}catch(i){throw console.error("TypedApi.changePassword: Failed",i),i}}async unblockUser(t){try{await this.client.delete(`/api/blocks/${encodeURIComponent(t)}`)}catch(n){throw console.error("TypedApi.unblockUser: Failed",t,n),n}}async banUser(t,n){try{await this.client.post(`/api/admin/users/${encodeURIComponent(t)}/ban`,{duration_hours:n})}catch(i){throw console.error("TypedApi.banUser: Failed",t,i),i}}async unbanUser(t){try{await this.client.post(`/api/admin/users/${encodeURIComponent(t)}/unban`)}catch(n){throw console.error("TypedApi.unbanUser: Failed",t,n),n}}async muteUser(t,n){try{await this.client.post(`/api/admin/users/${encodeURIComponent(t)}/mute`,{duration_hours:n})}catch(i){throw console.error("TypedApi.muteUser: Failed",t,i),i}}async unmuteUser(t){try{await this.client.post(`/api/admin/users/${encodeURIComponent(t)}/unmute`)}catch(n){throw console.error("TypedApi.unmuteUser: Failed",t,n),n}}async deleteUser(t){try{await this.client.delete(`/api/admin/users/${encodeURIComponent(t)}`)}catch(n){throw console.error("TypedApi.deleteUser: Failed",t,n),n}}async get(t,n){try{return await this.client.get(t,n)}catch(i){return console.error("TypedApi.get: Request failed",t,i),{error:String(i)}}}async getFavorites(t){let n="/api/my/favorites";if(t&&(t.limit!=null||t.offset!=null)){const o=new URLSearchParams;t.limit!=null&&o.set("limit",String(t.limit)),t.offset!=null&&o.set("offset",String(t.offset)),n+="?"+o.toString()}return(await this.client.get(n)).data||{items:[]}}async reorderFavorites(t){await this.client.post("/api/my/favorites/reorder",{orders:t})}async toggleFavorite(t,n){await this.client.post(`/api/reactions/${t}/${n}/favorite`)}async post(t,n){try{return await this.client.post(t,n)}catch(i){return console.error("TypedApi.post: Request failed",t,i),{error:String(i)}}}async put(t,n){try{return await this.client.put(t,n)}catch(i){return console.error("TypedApi.put: Request failed",t,i),{error:String(i)}}}async delete(t){try{return await this.client.delete(t)}catch(n){return console.error("TypedApi.delete: Request failed",t,n),{error:String(n)}}}}const Bn=new Hn(window.api);window.TypedApi=Bn;window.WORK_STATUS=Object.freeze({HIDDEN:0,PENDING:1,APPROVED:3});window.WorkStatus=Object.freeze({isNonPublic:function(e){return e!=null&&e.status!=null&&e.status!==WORK_STATUS.APPROVED}});window.WORK_CARD_BADGES=Object.freeze([{key:"pinned",label:"置顶",when:function(e){return!!e.is_pinned}},{key:"banned",label:"封禁",when:function(e){return!!e.ban_hidden}},{key:"approved",label:"已发布",when:function(e){return e.status===window.WORK_STATUS.APPROVED}},{key:"pending",label:"待审核",when:function(e){return e.status===window.WORK_STATUS.PENDING}},{key:"hidden",label:"隐藏",when:function(e){return e.status===window.WORK_STATUS.HIDDEN}},{key:"locked",label:"已锁定",when:function(e){return!!e.is_locked}},{key:"visible-to",labels:function(e){return(Array.isArray(e.visible_to)?e.visible_to:[]).filter(function(t){return t&&t.id!=null}).map(function(t){return(t.username||"U"+t.id)+" 可见"})}},{key:"forked",labels:function(e){const t=(e.forked_from_ref||"").trim();return t?["拷贝自 "+t]:[]}},{key:"delivery-adopted",label:"已采纳",when:function(e){return!!e.delivery_adopted}},{key:"delivery-published",label:"副本已发布",when:function(e){return!!e.delivery_published}},{key:"recycled",label:"回收",when:function(e){return!!e.deleted}}]);window.workCardBadges=function(e){const t=[];return e&&WORK_CARD_BADGES.forEach(function(n){if(typeof n.labels=="function"){n.labels(e).forEach(function(i){t.push({key:n.key,label:i})});return}typeof n.when=="function"&&n.when(e)&&t.push({key:n.key,label:n.label})}),t};(function(e){if(e.WorkActionRegistry&&e.WorkActionRegistry.__installed)return;function t(v){return e.escapeHtml(v)}function n(v){return e.ItemCard?ItemCard.apiResourceOf(v):v}function i(v,h,x,T){h=h||{};const _=e.__isManager(h),g=!!(v&&(v.author_id!=null&&h.id!=null&&v.author_id===h.id||h.username&&v.author===h.username||v.co_owned===!0));return{item:v,user:h,itemType:T,allowModeration:!!x,isAdmin:_,isOwn:g,isLevel1:g,hasCap:function(A){return l(A,h.viewer_caps)},hasStatus:!!(v&&v.status!=null),isLocked:!!(v&&v.is_locked)}}function o(){return e.__me||{role:"guest",username:""}}function s(v){return e.__isManager(v||o())}function l(v,h){return(Array.isArray(h)?h:Array.isArray(o().viewer_caps)?o().viewer_caps:[]).indexOf(v)>=0}function r(v){if(!v)return!1;const h=o();return!!(v.author_id!=null&&h.id!=null&&v.author_id===h.id||h.username&&v.author===h.username||v.co_owned===!0)}function c(v,h){const x=typeof v.listView=="function"?v.listView():v.listView;x&&typeof x.removeItem=="function"?x.removeItem(h.itemType+":"+String(h.id)):v.reload&&v.reload(h)}function u(v,h,x){if(typeof v.reload=="function"){v.reload(h);return}c(v,h)}function a(v,h,x){x=x||{};const T=e.WorkActions&&typeof WorkActions.resolveLooseRef=="function"?WorkActions.resolveLooseRef(v,h):{itemType:null,id:v};v=T.itemType===null?"works":T.itemType,h=T.id;const _=function(g){Interact.launch({wait:function(){return e.ItemEditView||(e.LateGate&&e.LateGate.ensure?e.LateGate.ensure("ItemEditView"):null)},open:function(B){B.open({itemType:v,item:g,title:"修改作品",onSaved:x.onSaved})},fail:"编辑器加载失败,请刷新页面重试"})};if(x.item){_(x.item);return}typeof e.api=="function"&&e.api("/api/"+n(v)+"/"+encodeURIComponent(h)).then(function(g){_(g?g.item||g:null)}).catch(function(g){StatusNotify.error(g&&g.message||"加载作品失败")})}const d=[{key:"hide",permission:"work.status_own",handler:"toggleHide",label:v=>v.status===WORK_STATUS.PENDING?"撤回审核":"隐藏",dataAttrs:()=>({next:String(WORK_STATUS.HIDDEN)}),invoke:(v,h,x)=>{e.toggleHide&&e.toggleHide(v,h,x.getAttribute("data-next")||String(WORK_STATUS.HIDDEN))},visible:(v,h)=>h.hasStatus&&(v.status===WORK_STATUS.APPROVED||v.status===WORK_STATUS.PENDING),freezeOnLock:!0,spec:v=>({check:v.check,confirm:h=>h.extra===String(WORK_STATUS.HIDDEN)?{text:v.page==="my"?"作品将回到你的私人仓库(隐藏状态),公开列表不再展示,确定?":"内容将回到私人仓库(隐藏状态),公开列表不再展示,确定?",title:"隐藏作品",confirmText:"隐藏"}:null,api:h=>[`/api/works/${h.itemType}/${h.id}/review`,{body:{status:WORK_STATUS.HIDDEN}}],ok:h=>"已回到私人仓库(隐藏)",onSuccess:(h,x)=>{u(v,h)}})},{key:"submitReview",permission:"work.status_own",handler:"submitReviewItem",label:"提交审核",invoke:(v,h)=>{e.submitReviewItem&&e.submitReviewItem(v,h)},visible:(v,h)=>h.hasStatus&&v.status===WORK_STATUS.HIDDEN&&!v.deleted&&h.isLevel1,freezeOnLock:!0,spec:v=>({check:v.check,confirm:{text:"提交后作品进入待审核状态,审核通过才会公开上架,确定提交?",title:"提交审核",confirmText:"提交"},api:h=>[`/api/works/${h.itemType}/${h.id}/review`,{body:{status:WORK_STATUS.PENDING}}],ok:"已提交审核",fail:"提交失败",onSuccess:(h,x)=>{u(v,h)}})},{key:"republish",permission:"work.review",handler:"republishItem",label:"上架",invoke:(v,h)=>{e.republishItem&&e.republishItem(v,h)},visible:v=>WorkStatus.isNonPublic(v)&&!v.deleted,freezeOnLock:!0,spec:v=>({check:v.check,api:h=>[`/api/works/${h.itemType}/${h.id}/review`,{body:{status:WORK_STATUS.APPROVED}}],ok:"已上架",fail:"上架失败",onSuccess:(h,x)=>{u(v,h)}})},{key:"restore",permission:"work.delete_all",handler:"restoreItem",label:"恢复",invoke:(v,h)=>{e.restoreItem&&e.restoreItem(v,h)},visible:(v,h)=>!!(v&&v.deleted),freezeOnLock:!1,spec:v=>({check:v.check,api:h=>[`/api/works/${h.itemType}/${h.id}/restore`,{body:{}}],ok:"已恢复并上架",fail:"恢复失败",onSuccess:h=>{c(v,h)}})},{key:"transfer",permission:"work.transfer_own",handler:"workCoGovern",label:"共同治理",invoke:(v,h)=>{Interact.launch({wait:function(){return e.workCoGovern||null},open:function(x){x(v,h)},fail:"共同治理加载失败,请重试"})},visible:(v,h)=>h.hasStatus&&!v.deleted,freezeOnLock:!1},{key:"edit",permission:"work.update_all",handler:"editItem",label:"编辑",invoke:(v,h)=>{e.editItem&&e.editItem(v,h)},defaultOpen:(v,h)=>{a(v,h,{})},visible:(v,h)=>!0,freezeOnLock:!0},{key:"fork",permission:"work.publish_own",handler:"forkItem",label:"拷贝",invoke:(v,h,x)=>{e.forkItem&&e.forkItem(v,h)},visible:(v,h)=>!!(e.ItemCard&&typeof ItemCard.canFork=="function"&&ItemCard.canFork(v,h.itemType)),freezeOnLock:!1,spec:v=>({confirm:{text:"拷贝后会在你的作品里生成一个隐藏状态副本(可在「我的」编辑上架)。",title:"拷贝作品",confirmText:"拷贝"},api:h=>{const x=v.lookup?v.lookup(h.itemType,h.id):null;return[`/api/works/${encodeURIComponent(x&&x.ref||"")}/fork`,{body:{}}]},ok:"已拷贝到我的作品(隐藏,可在「我的」中编辑上架)",fail:"拷贝失败"})},{key:"pin",permission:"work:pin",handler:"pinItem",label:v=>v.is_pinned?"取消置顶":"置顶",dataAttrs:v=>({next:v.is_pinned?"false":"true"}),invoke:(v,h,x)=>{e.pinItem&&e.pinItem(v,h,x.getAttribute("data-next")==="true")},visible:(v,h)=>h.hasStatus,freezeOnLock:!0,spec:v=>({api:h=>[`/api/works/${h.itemType}/${h.id}/pin`,{body:{pinned:!!h.extra}}],ok:h=>h.extra?"已置顶":"已取消置顶",reload:v.reload})},{key:"lock",permission:"work:lock",handler:"lockItem",label:v=>v.is_locked?"解锁":"锁定",dataAttrs:v=>({next:v.is_locked?"false":"true"}),invoke:(v,h,x)=>{e.lockItem&&e.lockItem(v,h,x.getAttribute("data-next")==="true")},visible:(v,h)=>h.hasStatus,freezeOnLock:!1,spec:v=>({confirm:h=>h.extra?{text:"锁定后任何人都不能删除、迭代或下架该作品(含其下评论),解锁前一律冻结,确定锁定?",title:"锁定作品",confirmText:"锁定"}:null,api:h=>[`/api/works/${h.itemType}/${h.id}/lock`,{body:{locked:!!h.extra}}],ok:h=>h.extra?"已锁定":"已解锁",reload:v.reload})},{key:"del",permission:"work.delete_all",handler:"deleteItem",label:"删除",css:"btn-danger",invoke:(v,h)=>{e.deleteItem&&e.deleteItem(v,h)},visible:function(v,h){return!0},freezeOnLock:!0,spec:v=>v.page==="my"?{confirm:{text:"确定删除这件上架内容?其下评论会一并删除,不可恢复。",title:"删除上架",confirmText:"删除",danger:!0},api:h=>[`/api/${n(h.itemType)}/${h.id}`,{method:"DELETE"}],ok:"已删除上架",onSuccess:h=>{c(v,h)}}:{check:v.check,confirm:{text:"确定删除?",title:"删除",danger:!0},api:h=>[`/api/${n(h.itemType)}/${h.id}`,{method:"DELETE"}],ok:"已删除",fail:"删除失败",reload:v.reload}}],p={};d.forEach(function(v){p[v.key]=v});const w={};function y(v,h){v&&(w[v]=h&&typeof h=="object"?h:null)}const f={};function m(v){if(!v||typeof v.getAttribute!="function")return;const h=v.getAttribute("data-next");if(h!=null)return h==="true"?!0:h==="false"?!1:h}function E(v,h,x,T){return typeof v.spec!="function"||!e.WorkActions||typeof WorkActions.createWorkAction!="function"?!1:(f[v.key]||(f[v.key]=WorkActions.createWorkAction(v.spec({}))),f[v.key](h,x,m(T)),!0)}function S(v,h){const T=(e.__gate||{}).card_actions||{},_=h.isOwn?"own":"all",g={};return d.forEach(function(B){const A=T[B.key];!A||typeof A!="object"||A[_]!==!0||h.isLocked&&B.freezeOnLock||typeof B.visible=="function"&&B.visible(v,h)&&(g[B.key]=!0)}),g}function L(v,h,x){x=x||{};const T=[];return d.forEach(function(_){if(!x[_.key]||typeof _.renderIf=="function"&&!_.renderIf(v))return;const g=typeof _.label=="function"?_.label(v):_.label,B=typeof _.css=="function"?_.css(v):_.css||"";let A="";if(typeof _.dataAttrs=="function"){const P=_.dataAttrs(v)||{};Object.keys(P).forEach(function(j){P[j]!=null&&(A+=" data-"+j+'="'+t(P[j])+'"')})}const k=B?' class="'+B+'"':"";T.push("<button"+k+' data-card-action="'+_.key+'"'+A+">"+t(g)+"</button>")}),T.length?ItemCard.menuHtml(T):""}function O(v,h,x,T,_){const g=v&&p[v];if(g){if(_){const B=w[_];if(B&&typeof B[g.handler]=="function"){B[g.handler](h,x,T);return}if(E(g,h,x,T))return;if(typeof g.defaultOpen=="function"){g.defaultOpen(h,x,T,_);return}}typeof g.invoke=="function"&&g.invoke(h,x,T)}}function I(v){const h={};return d.forEach(function(x){typeof x.spec=="function"&&(!e.WorkActions||typeof WorkActions.createWorkAction!="function"||(h[x.handler]=WorkActions.createWorkAction(x.spec(v))))}),h}e.WorkActionRegistry={__installed:!0,REGISTRY:d,WORK_ACTION_REGISTRY:d,buildViewerCtx:i,resolveActions:S,renderActions:L,dispatch:O,buildPageWorkActions:I,registerSurfaceActions:y,openItemEditor:a,me:o,isManagerRole:s,hasViewerCap:l,isItemAuthor:r}})(window);(function(){if(window.MutationBatch&&window.MutationBatch.__installed)return;function e(t,n){if(document.querySelectorAll(t).forEach(n),typeof MutationObserver!="function")return;let i=[],o=!1;const s=()=>{o=!1;const r=i;i=[];for(const c of r)c.isConnected&&(c.classList&&c.classList.contains(t.slice(1))&&n(c),c.querySelectorAll&&c.querySelectorAll(t).forEach(n))};new MutationObserver(r=>{for(const c of r)for(const u of c.addedNodes||[])!u||u.nodeType!==1||i.push(u);i.length&&!o&&(o=!0,requestAnimationFrame(s))}).observe(document.body||document.documentElement,{childList:!0,subtree:!0})}window.MutationBatch={__installed:!0,observeInserted:e}})();window.ViewCounter=function(){const e=["works"];function t(l){return window.Fmt.formatNumber(l)}function n(l,r,c){if(!l||l.id==null)return;const u=r||l.item_type||"",a=String(Number(l.id)),d=Array.isArray(c)?c:["likes"];document.querySelectorAll(".item-stats").forEach(function(p){const w=p.closest(".item-card");(p.dataset.itemType||w&&w.dataset.itemType)!==u||String(Number(p.dataset.id))!==a||d.forEach(function(f){const m=p.querySelector('[data-stat="'+f+'"]');m&&f==="likes"&&(m.textContent=t(l.like_count))})})}const i=2e3,o={};function s(l,r){if(!l||l.id==null)return Promise.resolve();const c=e.indexOf(r)>=0?r:e.indexOf(l.item_type)>=0?l.item_type:"";if(!c||typeof window.api!="function")return Promise.resolve();const u=c+":"+l.id,a=Date.now();return o[u]&&a-o[u]<i?Promise.resolve():(o[u]=a,Object.keys(o).length>200&&(Object.keys(o).forEach(function(d){delete o[d]}),o[u]=a),window.api("/api/"+encodeURIComponent(c)+"/"+encodeURIComponent(l.id)+"/view",{method:"POST"}).then(function(d){if(!d||typeof d.view_count!="number")return;l.view_count=d.view_count;const p=document.getElementById("givViewCount");p&&(p.textContent=t(d.view_count))}).catch(function(){}))}return{record:s,updateStats:n,formatCount:t}}();window.ItemCard=function(){const e='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>';function t(M){return ViewCounter.formatCount(M)}function n(M){try{return fmtTime(M)}catch{return""}}function i(M){return!M||!M.length?"":'<div class="item-menu"><button class="item-menu-trigger" type="button" aria-label="更多操作" title="更多操作">⋮</button><div class="item-menu-popup"><div class="item-admin-actions">'+M.join("")+"</div></div></div>"}function o(M,G){G=G||{};const re=G.itemType||"works",ce=!!G.showStats,H=G.actions||{},te=q(re),oe=W(M.id),ve=l(M,re),Se=E(M,ve),se=s(M,G),Ae=M&&M.brief||"",xe=Ae?'<div class="item-excerpt">'+q(Ae)+"</div>":"",be=I(M),b=v(M,re),R=ce?'<div class="item-stats" data-item-type="'+q(re)+'" data-id="'+W(M.id)+'"><span class="item-stat" title="点赞数">'+e+'<em data-stat="likes">'+q(t(M.like_count))+"</em></span></div>":"",D=h(M,re,H),J=ve?" kind-"+ve:"",V=window.workCardBadges(M).map(function(ne){return'<span class="card-badge card-badge-'+ne.key+'">'+q(ne.label)+"</span>"}).join(""),$=V?'<div class="card-badges">'+V+"</div>":"";return'<div class="item-card'+J+'" data-item-type="'+te+'" data-item-id="'+oe+(G&&G.surface?'" data-action-surface="'+q(G.surface):"")+'">'+$+se+'<div class="item-info"><div class="item-info-top"><div class="item-name">'+q(M.name||"")+r(M)+"</div>"+xe+'<div class="item-tags">'+Se+'</div></div></div><div class="item-card-footer">'+be+b+R+D+"</div></div>"}function s(M,G){let re=M&&(M.thumb_url||window.ImageRender&&ImageRender.deriveVariantUrl(M.image_url,"thumb")||M.image_url)||"";re&&re.startsWith("/")&&(re=(window.__apiBaseUrl||"")+re);const ce=!!re;if(ce&&window.ImageRender)return'<div class="item-cover-wrap">'+ImageRender.card(M,{cls:"item-cover",w:96,h:96,alt:M.name,fallback:G.coverPlaceholder||"无图片"})+"</div>";if(ce)return'<div class="item-cover-wrap"><img class="item-cover" src="'+q(re)+'" alt="'+q(M.name||"")+'" loading="lazy" decoding="async"></div>';const H=G.coverPlaceholder||M&&M.emoji||"无图片";return'<div class="item-cover-wrap no-image-placeholder">'+(/[\u{1F300}-\u{1FAFF}]|[\u{2600}-\u{27BF}]/u.test(H)?'<span class="item-cover-placeholder">'+q(H)+"</span>":q(H))+"</div>"}function l(M,G){return window.ChipRenderer&&typeof ChipRenderer.effectiveKind=="function"?ChipRenderer.effectiveKind(M,G):(M&&M.item_type||G)==="works"?"works":""}function r(M){if(!M)return"";const G=y(M),re=G>=1?"_V"+G:"";return M.ref?'<span class="item-id-badge">'+q(String(M.ref))+re+"</span>":M.id==null?"":'<span class="item-id-badge">#'+W(M.id)+re+"</span>"}const c=new Map,u=new Map,a=30*1e3;function d(M,G){return String(M||"works")+":"+String(G)}function p(M,G){const re=d(M,G),ce=u.get(re);if(ce&&Date.now()-ce.t<a)return ce.p;u.delete(re);const H=typeof window.apiFn=="function"?window.apiFn:()=>window.api,te=(typeof H()=="function"?H()("/api/works/"+encodeURIComponent(M)+"/"+encodeURIComponent(String(G))+"/versions"):Promise.reject(new Error("api 未就绪"))).then(oe=>Array.isArray(oe)?oe:oe&&oe.versions||[]).catch(()=>(u.delete(re),null));return u.set(re,{p:te,t:Date.now()}),te}function w(M,G,re){const ce=Number(re&&re.latest_version)||0;if(ce<1)return 0;const H=c.get(d(M,G));if(H!=null&&H>=1)return H;const te=Number(re&&re.default_version)||0;return te>=1&&te<=ce?te:ce}function y(M){const G=Number(M&&M.latest_version)||0;if(G<1)return 0;const re=Number(M&&M.default_version)||0;return re>=1&&re<=G?re:G}function f(M,G,re){const ce=Number(re&&re.latest_version)||0;if(ce<1)return Promise.resolve(null);const H=w(M,G,re);return H<1||c.get(d(M,G))==null&&H>=ce?Promise.resolve(null):p(M,G).then(oe=>{const ve=(oe||[]).find(Se=>Number(Se&&Se.version)===Number(H));return ve&&ve.code_url||null})}function m(M,G){const re=c.get(d(M,G));return re??null}function E(M,G){return window.ChipRenderer&&typeof ChipRenderer.buildWorkLabelChips=="function"?ChipRenderer.renderChips(ChipRenderer.buildWorkLabelChips(M,{kind:G,userLimit:3})):""}function S(M,G){return!1}function L(M){return M?M.author_id!=null?M.author_id:M.author_username?M.author_username:M.author||"":""}function O(M){return M&&M.author||""}function I(M){const G=M.author||"",re=n(M.updated_at||M.last_published_at||M.created_at),ce=O(M),H=window.avatarHtml&&typeof window.avatarHtml=="function"?window.avatarHtml({avatar_url:M.author_avatar||"",username:ce}):"";let te;if(G){const ve=L(M);te=H+'<a href="/u/'+encodeURIComponent(ve)+'" data-u="'+q(String(ve))+'">'+q(ce)+"</a>"}else te=H+"匿名";return'<div class="item-author" title="'+q(G?ce:"匿名")+" · "+q(re)+'">'+te+"</div>"}function v(M,G){const re=!!(M&&M.is_favorited),ce=re?"item-favorite-star favorited":"item-favorite-star",H=re?"取消收藏":"收藏";return'<button type="button" class="'+ce+'" data-action="toggle-favorite" data-item-type="'+q(G)+'" data-item-id="'+W(M.id)+'" title="'+H+'" aria-label="'+H+'"><svg viewBox="0 0 24 24" fill="'+(re?"currentColor":"none")+'" stroke="currentColor" stroke-width="2"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></button>'}function h(M,G,re,ce){return window.WorkActionRegistry?WorkActionRegistry.renderActions(M,G,re):""}const x=new Set;function T(M,G){LayerFrame.placePopup(M,G),M.classList.add("open"),x.add(M);const re=M.closest(".item-card");re&&re.classList.add("menu-open")}function _(M){M.classList.remove("open"),x.delete(M);const G=M.closest(".item-card");G&&G.classList.remove("menu-open")}function g(){x.size&&x.forEach(M=>{if(!M.isConnected){x.delete(M);return}_(M)})}function B(){if(window.__itemCardMenuBound)return;window.__itemCardMenuBound=!0;let M=null,G=0,re=0,ce=null,H=null,te=0;const oe=500,ve=10;function Se(){M&&(clearTimeout(M),M=null),ce=null,H=null}function se(xe){xe?document.documentElement.dataset.fwLongPress="1":delete document.documentElement.dataset.fwLongPress}document.addEventListener("click",xe=>{if(Date.now()<te){te=0,xe.stopPropagation(),xe.preventDefault();return}const be=xe.target;if(!be||!be.closest)return;const b=be.closest(".item-favorite-star");if(b){xe.preventDefault(),xe.stopPropagation();const V=b.getAttribute("data-item-type"),$=b.getAttribute("data-item-id");if(V&&$&&window.TypedApi){const ne=b.classList.contains("favorited"),C=function(z){b.classList.toggle("favorited",z);const Y=z?"取消收藏":"收藏";b.setAttribute("title",Y),b.setAttribute("aria-label",Y);const ue=b.querySelector("svg");ue&&ue.setAttribute("fill",z?"currentColor":"none")};C(!ne),window.TypedApi.toggleFavorite(V,Number($)).then(()=>{window.StatusNotify&&window.StatusNotify.ok(ne?"已取消收藏":"已收藏")}).catch(z=>{C(ne),window.StatusNotify&&window.StatusNotify.error(z.message||"操作失败")})}return}const R=be.closest("[data-u]");if(R){xe.preventDefault(),xe.stopPropagation(),window.openUserProfile&&window.openUserProfile(R.getAttribute("data-u"));return}const D=be.closest(".item-menu-trigger");if(D){xe.stopPropagation(),xe.preventDefault();const V=D.closest(".item-menu"),$=V&&V.querySelector(".item-menu-popup");document.querySelectorAll(".item-menu-popup.open").forEach(ne=>{ne!==$&&_(ne)}),$&&($.classList.contains("open")?_($):T($,D));return}const J=be.closest("[data-card-action]");if(J){xe.stopPropagation(),xe.preventDefault(),g();const V=J.closest(".item-card")||J.closest("[data-item-type][data-item-id]");if(!V)return;const $=J.getAttribute("data-card-action");$&&window.WorkActionRegistry&&WorkActionRegistry.dispatch($,V.getAttribute("data-item-type")||"works",V.getAttribute("data-item-id"),J,V.getAttribute("data-action-surface")||void 0);return}be.closest(".item-menu-popup")||g()},!0);const Ae=".item-menu-trigger, .item-menu-popup, [data-card-action], [data-u], a, button, input, textarea, select";document.addEventListener("pointerdown",xe=>{if(xe.pointerType==="mouse"&&xe.button!==0||xe.pointerType==="touch"||xe.pointerType==="pen")return;const be=xe.target;if(!be||!be.closest||be.closest(Ae))return;const b=be.closest(".item-card"),R=b?null:be.closest(".fav-icon");if(!b&&!(R&&R.closest(".fav-view-host")))return;const D=b||R;if(!D)return;const J=D.querySelector(".item-menu"),V=J&&J.querySelector(".item-menu-popup");if(!J||!V)return;let $=J.querySelector(".item-menu-trigger");(!$||!$.getClientRects().length)&&($=D.querySelector(".fav-cover")),$&&(G=xe.clientX,re=xe.clientY,ce=D,H=null,se(!1),M&&clearTimeout(M),M=window.setTimeout(()=>{M=null,ce===D&&(se(!0),H={popup:V,trigger:$,root:D})},oe))},!0),document.addEventListener("pointermove",xe=>{if(!ce)return;Math.hypot(xe.clientX-G,xe.clientY-re)>ve&&Se()},!0),document.addEventListener("pointerup",()=>{const xe=H,be=!!xe&&xe.root===ce;se(!1),ce=null,H=null,be&&(te=Date.now()+450,window.setTimeout(()=>{g(),T(xe.popup,xe.trigger)},0))},!0),document.addEventListener("pointercancel",()=>{se(!1),Se()},!0),window.addEventListener("scroll",function(){Se(),g()},{capture:!0,passive:!0}),window.addEventListener("resize",g)}const A=["works"];function k(M,G){return G==="works"}function P(M,G){return G==="works"}function j(M,G){if(!M||!M.ref)return!1;const re=window.WorkActionRegistry&&typeof WorkActionRegistry.me=="function"?WorkActionRegistry.me():null;return!re||re.role==="guest"||M.status!==WORK_STATUS.APPROVED?!1:P(M,G)}function Z(M){return A.indexOf(M)>=0}function N(M){return Z(M)?M:"works"}function ee(M){return M&&M.item_type||"works"}function ie(M){return M}function W(M){const G=Number(M);return Number.isFinite(G)?String(G):"0"}const q=window.escapeHtml;function F(M,G){G=G||{};const re=G.itemType||M&&M.item_type||"works",ce=G.user||{},H=!!G.allowModeration;M&&(M.author_id!=null&&ce.id!=null&&M.author_id===ce.id||ce.username&&(M.author,ce.username)),M&&M.status!=null;const te=window.WorkActionRegistry?WorkActionRegistry.buildViewerCtx(M,ce,H,re):null;return{actions:te?WorkActionRegistry.resolveActions(M,te):{}}}return B(),{html:o,render:o,menuHtml:i,resolve:F,isContentType:Z,normalizeType:N,isForkable:P,canFork:j,isAiEditable:k,itemTypeOf:ee,apiResourceOf:ie,authorLinkTarget:L,authorDisplayName:O,shouldHideUnapprovedImage:S,COMMENTABLE_TYPES:A,selectedVersions:c,fetchVersions:p,effectiveVersion:w,displayVersion:y,versionCodeUrl:f,peekSelectedVersion:m}}();(function(e){if(e.WorkActions&&e.WorkActions.__installed)return;function t(c,u,a){return ItemCard.isContentType(String(c))?{itemType:String(c),id:u,extra:a}:{itemType:"works",id:c,extra:u}}function n(c,u){return ItemCard.isContentType(String(c))?{itemType:c,id:u}:{itemType:null,id:c}}function i(c){StatusNotify.error(c)}function o(c){e.StatusNotify&&typeof StatusNotify.ok=="function"&&StatusNotify.ok(c)}async function s(c,u){if(!c)return!0;const a=e.prompt(c.text,typeof c.value=="function"?c.value(u):c.value);if(a===null)return!1;if(u.input=a.trim(),typeof c.validate=="function"){const d=c.validate(u);if(d)return i(d),!1}return!0}async function l(c,u){if(!c)return!0;let a=typeof c=="function"?c(u):c;return a==null||a===!1||(typeof a=="string"&&(a={text:a}),!e.MobileShell||typeof e.MobileShell.confirm!="function")?!0:e.MobileShell.confirm(a.text,{title:a.title,confirmText:a.confirmText,danger:!!a.danger})}function r(c){return async function(u,a,d){const p=Object.assign(t(u,a,d),{input:""});if(!(typeof c.check=="function"&&!c.check(p))&&await s(c.prompt,p)&&await l(c.confirm,p))try{const w=typeof c.api=="function"?c.api(p):c.api,y=Array.isArray(w)?w[0]:w,f=Array.isArray(w)?Object.assign({},w[1]):{};f.method=f.method||"POST",f.body&&typeof f.body=="object"&&!(f.body instanceof FormData)&&(f.body=JSON.stringify(f.body));const m=await api(y,f);o(typeof c.ok=="function"?c.ok(p):c.ok||"操作成功"),typeof c.onSuccess=="function"&&c.onSuccess(p,m),typeof c.reload=="function"&&c.reload(p)}catch(w){const y=typeof c.fail=="function"?c.fail(w,p):c.fail;i(w&&w.message||y||"网络错误")}}}e.WorkActions={__installed:!0,normalizeWorkArgs:t,resolveLooseRef:n,createWorkAction:r}})(window);window.ConversationCard=function(){const e=window.escapeHtml;function t(y){return String(y||"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/(\*\*|__|\*|_|~~|==)/g,"").replace(/^\s*>\s?/gm,"").replace(/^\s*\|[-: |]+\|\s*$/gm,"").replace(/\|/g," ").replace(/\s+/g," ").trim()}function n(y){const f=String(y||"").trim();if(!y||f[0]!=="{")return null;try{const m=JSON.parse(f);if(!m||typeof m!="object"||typeof m.type!="string")return null;const E=m.title||m.name||m.ref||(m.type==="option"&&m.clarify?"需求确认":"")||"";return"[卡片] "+(E?String(E):m.type)}catch{return null}}function i(y){if(!y.last_message)return"";const f=y.last_from_me?"你:":"",m=n(y.last_message);return f+(m!==null?m:t(y.last_message))}function o(y,f){const m=y.target_avatar||"",E=y.target_id,S='<a href="/u/'+encodeURIComponent(E)+'" class="conv-avatar-link" data-u="'+e(String(E))+'" aria-label="查看 '+e(f)+' 的主页">',L="</a>";let O="";if(typeof window.avatarHtml=="function")O=window.avatarHtml(m,f,"conv-avatar-inner");else if(m&&typeof m=="string"&&m.indexOf("emoji:")===0)O='<span class="conv-avatar-inner avatar-emoji">'+e(m.slice(6))+"</span>";else if(m&&typeof m=="string"){const I=m.charAt(0)==="/"?(window.__apiBaseUrl||"")+m:m;O='<img class="conv-avatar-inner" src="'+e(I)+'" alt="" decoding="async" loading="lazy">'}else O='<span class="conv-avatar-inner">'+e((f||"?").trim().charAt(0)||"?")+"</span>";return'<div class="item-cover-wrap conv-avatar">'+S+O+L+"</div>"}function s(y,f){const m=[],E=y.pinned?"取消置顶":"置顶";return m.push('<button data-conv-action="pin">'+e(E)+"</button>"),m.push('<button class="btn-danger" data-conv-action="delete">删除</button>'),ItemCard.menuHtml(m)}function l(y,f){const m=y.target_username||"",E=y.pinned?" conv-card-pinned":"",S=o(y,m),L=y.pinned?'<span class="msg-pin-tag">置顶</span>':"",O=y.agent_proxy_configured?'<span class="conv-agent-dot" data-state="unknown" data-agent-status-id="'+e(String(y.target_id))+'"></span>':"",I='<div class="item-info-top"><div class="item-name conv-name">'+e(m)+"</div>"+O+L+"</div>",v=i(y),h=v?'<span class="conv-preview'+(y.last_message?"":" conv-preview-empty")+'">'+e(v)+"</span>":'<span class="conv-preview conv-preview-empty">还没有聊天记录,点进来打个招呼吧</span>',x='<span class="conv-time">'+e(fmtListTime(y.last_time))+"</span>",T=s(y),_='<div class="conv-footer-content">'+h+'<div class="conv-footer-right">'+x+"</div></div>";return'<div class="item-card conv-card'+E+'" data-target-id="'+y.target_id+'" data-session-id="'+y.session_id+'" role="button" tabindex="0" aria-label="和 '+e(m)+' 聊天">'+S+'<div class="item-info">'+I+'</div><div class="item-card-footer conv-footer">'+_+T+"</div></div>"}let r=!1;function c(y,f,m){if(!m.closest||!m.closest(".pv-overlay"))return!1;const E=window.MessagesView;if(!E)return!1;const L=E[y==="pin"?"togglePin":y==="delete"?"confirmDeleteConversation":y];return typeof L!="function"?!1:(L(f),!0)}function u(){r||(r=!0,document.addEventListener("click",y=>{const f=y.target;if(!f||!f.closest)return;const m=f.closest(".conv-avatar-link[data-u]");if(m){y.preventDefault(),y.stopPropagation(),window.openUserProfile&&window.openUserProfile(m.getAttribute("data-u"));return}const E=f.closest("[data-conv-action]");if(E){y.stopPropagation(),y.preventDefault();const S=E.closest(".item-menu-popup");if(S){S.classList.remove("open");const v=S.closest(".item-card");v&&v.classList.remove("menu-open")}const L=E.closest(".conv-card"),O=L&&L.getAttribute("data-session-id");if(!O)return;const I=E.getAttribute("data-conv-action");return!I||L&&c(I,Number(O),L),void 0}if(!f.closest(".item-menu-trigger, .item-menu-popup")){const S=f.closest(".conv-card");if(S){const L=S.getAttribute("data-session-id");if(!L)return;c("openConversation",Number(L),S)}}},!0))}u();let a=null;function d(y){if(typeof api!="function")return;const f=y.getAttribute("data-agent-status-id");f&&api("/api/sessions/"+f+"/agent-status").then(m=>{if(y.isConnected){if(!m||!m.configured){y.hidden=!0;return}y.setAttribute("data-state",m.online?"online":"offline"),y.title=m.online?"代理在线":"代理离线"}}).catch(()=>{})}function p(y){if(typeof IntersectionObserver!="function"){d(y);return}a||(a=new IntersectionObserver(f=>{f.forEach(m=>{m.isIntersecting&&(a.unobserve(m.target),d(m.target))})},{rootMargin:"200px"})),a.observe(y)}function w(){window.MutationBatch.observeInserted(".conv-agent-dot",p)}return w(),{html:l}}();window.WindowKit=function(){function e(t){t=t||{};var n=t.opener||(window.PlainView&&typeof window.PlainView.open=="function"?window.PlainView.open:null);if(!n)return null;var i=typeof t.onClose=="function"?t.onClose:null,o=n({title:t.title,onClose:i,actions:t.actions,fill:t.fill,host:t.host,dock:t.dock||null});return o?{body:o}:null}return{open:e}}();window.AppWindows=function(){var e={};function t(c,u){if(!c||!u||typeof u.render!="function")throw new Error("AppWindows.define: id 与 def.render 必填("+c+")");e[c]=u}function n(c){return!!e[c]}function i(c,u,a,d){var p=c[u];return typeof p=="function"?p(a,d):p}function o(c,u){var a=c[u];return typeof a=="function"?a:null}function s(c,u){if(!(!Array.isArray(u)||!u.length)){var a=c&&c.closest&&c.closest(".pv-overlay"),d=a&&a.querySelector(".pv-titlebar");if(d){var p=d.querySelector(".pv-actions");p?p.textContent="":(p=document.createElement("div"),p.className="pv-actions",d.insertBefore(p,d.querySelector(".pv-close"))),u.forEach(function(w){w instanceof Node&&p.appendChild(w)})}}}function l(c,u){u=u||{};var a=e[c];if(!a||!window.PlainView||typeof PlainView.open!="function"||!window.WindowKit||typeof WindowKit.open!="function"||a.mode!=="layer"&&typeof PlainView.isOpen=="function"&&PlainView.isOpen())return null;var d=null,p={title:i(a,"title",u,null)||"",actions:i(a,"actions",u,null),onClose:o(a,"onClose")?function(){return a.onClose(u,d)}:null,fill:a.fill?function(y){a.render(y,u,d)}:null,host:u&&u.host||null,dock:u&&u.dock||null};a.mode==="layer"&&window.ViewNavigation&&typeof ViewNavigation.push=="function"&&(p.opener=ViewNavigation.push);var w=WindowKit.open(p);return w?(d={id:c,body:w.body},a.fill||a.render(w.body,u,d),d):null}function r(c,u,a){a=a||{};var d=e[c];if(!d||!u)return!1;u.innerHTML="",d.render(u,a,null);var p=i(d,"actions",a,null);return Array.isArray(p)&&p.length&&s(u,p),!0}return{define:t,open:l,renderInto:r,has:n,mountActions:s}}();window.MediaPlayer=window.MediaPlayer||function(){function e(){injectOwnedStyle("mediaplayer",`
1559
+ /* ---------- 视频播放器(fwm-vid;铬件恒深色) ---------- */
1560
+ /* 圆角恒 0(直边)——与详情顶图 .giv-img 全宽直边同一观感,不另起圆角语言 */
1561
+ .fwm-vid{position:relative;width:100%;background:#000;border-radius:0;overflow:hidden;line-height:0;touch-action:pan-y;}
1562
+ /* 内联高度上限对齐详情图 420px 档(vh 字面量被弹层高度闸禁止;全屏态用
1563
+ 百分比——相对全屏元素本身,无需视口单位) */
1564
+ .fwm-vid video{width:100%;max-height:480px;display:block;background:#000;}
1565
+ .fwm-vid:fullscreen{border-radius:0;display:flex;align-items:center;justify-content:center;width:100%;height:100%;}
1566
+ .fwm-vid:fullscreen video{max-height:100%;max-width:100%;width:auto;height:auto;flex:none;}
1567
+ .fwm-vid:-webkit-full-screen{border-radius:0;}
1568
+ /* 中央播放键(暂停/结尾时显示) */
1569
+ .fwm-center{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;}
1570
+ .fwm-bigplay{pointer-events:auto;width:64px;height:64px;border:none;border-radius:50%;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:opacity .18s,transform .18s;}
1571
+ .fwm-bigplay svg{width:30px;height:30px;fill:#fff;margin-left:3px;}
1572
+ .fwm-bigplay.fwm-hidden{opacity:0;transform:scale(.8);pointer-events:none;}
1573
+ /* 双击 seek 反馈气泡 */
1574
+ .fwm-seekhint{position:absolute;top:50%;transform:translateY(-50%);padding:8px 14px;border-radius:18px;background:rgba(0,0,0,.55);color:#fff;font-size:14px;font-weight:600;opacity:0;transition:opacity .18s;pointer-events:none;}
1575
+ .fwm-seekhint-l{left:12%;}.fwm-seekhint-r{right:12%;}
1576
+ .fwm-seekhint.fwm-show{opacity:1;}
1577
+ /* 底部控制条 */
1578
+ .fwm-bar{position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;gap:8px;padding:6px 10px calc(6px + env(safe-area-inset-bottom,0px));background:linear-gradient(transparent,rgba(0,0,0,.65));opacity:1;transition:opacity .2s;}
1579
+ .fwm-bar.fwm-hidden{opacity:0;pointer-events:none;}
1580
+ .fwm-btn{flex:none;width:34px;height:34px;border:none;background:transparent;display:flex;align-items:center;justify-content:center;cursor:pointer;-webkit-tap-highlight-color:transparent;padding:0;}
1581
+ .fwm-btn svg{width:21px;height:21px;fill:#fff;}
1582
+ .fwm-time{flex:none;color:#fff;font-size:12px;font-variant-numeric:tabular-nums;min-width:34px;text-align:center;}
1583
+ .fwm-prog{flex:1;min-width:60px;height:26px;margin:0;-webkit-appearance:none;appearance:none;background:transparent;cursor:pointer;}
1584
+ .fwm-prog::-webkit-slider-runnable-track{height:3px;border-radius:2px;background:rgba(255,255,255,.35);}
1585
+ .fwm-prog::-webkit-slider-thumb{-webkit-appearance:none;width:13px;height:13px;border-radius:50%;background:#fff;margin-top:-5px;box-shadow:0 0 4px rgba(0,0,0,.5);}
1586
+ .fwm-prog::-moz-range-track{height:3px;border-radius:2px;background:rgba(255,255,255,.35);}
1587
+ .fwm-prog::-moz-range-thumb{width:13px;height:13px;border:none;border-radius:50%;background:#fff;}
1588
+ /* 加载圈 */
1589
+ .fwm-spin{position:absolute;left:50%;top:50%;width:36px;height:36px;margin:-18px 0 0 -18px;border-radius:50%;border:3px solid rgba(255,255,255,.3);border-top-color:#fff;animation:fwmrot .8s linear infinite;display:none;pointer-events:none;}
1590
+ .fwm-vid.fwm-loading .fwm-spin{display:block;}
1591
+ @keyframes fwmrot{to{transform:rotate(360deg);}}
1592
+ /* ---------- 音频卡(fwm-aud;直边同视频播放器,与详情顶图观感一致) ---------- */
1593
+ .fwm-aud{display:flex;align-items:center;gap:12px;width:100%;box-sizing:border-box;padding:14px 16px;border-radius:0;background:var(--neu-inset,#D1D9E6);box-shadow:var(--neu-press-sm);}
1594
+ .fwm-aud-play{flex:none;width:52px;height:52px;border:none;border-radius:50%;background:var(--primary,#5C4033);display:flex;align-items:center;justify-content:center;cursor:pointer;-webkit-tap-highlight-color:transparent;}
1595
+ .fwm-aud-play svg{width:24px;height:24px;fill:#fff;}
1596
+ .fwm-aud-main{flex:1;min-width:0;}
1597
+ .fwm-aud-name{font-size:14px;font-weight:600;color:var(--text-1,#5C4033);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:6px;}
1598
+ .fwm-aud-row{display:flex;align-items:center;gap:8px;}
1599
+ .fwm-aud .fwm-time{color:var(--text-3,#9C7E68);min-width:30px;}
1600
+ .fwm-aud .fwm-prog::-webkit-slider-runnable-track{background:var(--neu-sh-dark,rgba(163,177,198,.5));}
1601
+ .fwm-aud .fwm-prog::-webkit-slider-thumb{background:var(--primary,#5C4033);box-shadow:none;}
1602
+ .fwm-aud .fwm-prog::-moz-range-track{background:var(--neu-sh-dark,rgba(163,177,198,.5));}
1603
+ .fwm-aud .fwm-prog::-moz-range-thumb{background:var(--primary,#5C4033);}
1604
+ /* 媒体加载失败占位(视频黑底白字 / 音频卡名字行追加),源 404、被删、
1605
+ COS 抖动时用户能区分「加载慢」与「已损坏」,不再面对黑箱或点了没反应 */
1606
+ .fwm-err{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:rgba(255,255,255,.75);font-size:14px;line-height:1.4;padding:0 16px;box-sizing:border-box;}
1607
+ `)}var t={play:'<svg viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>',pause:'<svg viewBox="0 0 24 24"><path d="M6 5h4v14H6zM14 5h4v14h-4z"/></svg>',volume:'<svg viewBox="0 0 24 24"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4z"/></svg>',muted:'<svg viewBox="0 0 24 24"><path d="M3 9v6h4l5 5V4L7 9H3zm18.2 3 2.1-2.1-1.4-1.4-2.1 2.1-2.1-2.1-1.4 1.4 2.1 2.1-2.1 2.1 1.4 1.4 2.1-2.1 2.1 2.1 1.4-1.4-2.1-2.1z"/></svg>',full:'<svg viewBox="0 0 24 24"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>',replay:'<svg viewBox="0 0 24 24"><path d="M12 5V1L7 6l5 5V7a5 5 0 1 1-5 5H5a7 7 0 1 0 7-7z"/></svg>'};function n(r){(!isFinite(r)||r<0)&&(r=0),r=Math.floor(r);var c=Math.floor(r/3600),u=Math.floor(r%3600/60),a=r%60,d=c?String(u).padStart(2,"0"):String(u);return(c?c+":":"")+d+":"+String(a).padStart(2,"0")}var i=window.escapeHtml;function o(r,c){var u=document.createElement("div");u.className="fwm-vid",u.innerHTML='<video preload="auto" playsinline webkit-playsinline x5-playsinline></video><div class="fwm-spin"></div><div class="fwm-center"><button type="button" class="fwm-bigplay" aria-label="播放">'+t.play+'</button><span class="fwm-seekhint fwm-seekhint-l">-10s</span><span class="fwm-seekhint fwm-seekhint-r">+10s</span></div><div class="fwm-bar"><button type="button" class="fwm-btn fwm-play" aria-label="播放/暂停">'+t.play+'</button><span class="fwm-time fwm-cur">0:00</span><input type="range" class="fwm-prog" min="0" max="1000" step="1" value="0" aria-label="进度"><span class="fwm-time fwm-dur">0:00</span><button type="button" class="fwm-btn fwm-mute" aria-label="静音">'+t.volume+'</button><button type="button" class="fwm-btn fwm-full" aria-label="全屏">'+t.full+"</button></div>",r.appendChild(u);var a=u.querySelector("video"),d=u.querySelector(".fwm-bar"),p=u.querySelector(".fwm-bigplay"),w=u.querySelector(".fwm-play"),y=u.querySelector(".fwm-mute"),f=u.querySelector(".fwm-full"),m=u.querySelector(".fwm-cur"),E=u.querySelector(".fwm-dur"),S=u.querySelector(".fwm-prog"),L=u.querySelector(".fwm-seekhint-l"),O=u.querySelector(".fwm-seekhint-r");a.src=(c.url.charAt(0)==="/"&&window.__apiBaseUrl||"")+c.url,c.duration>0&&(E.textContent=n(c.duration));var I=!1,v=null;function h(){var k=a.paused||a.ended;p.innerHTML=a.ended?t.replay:t.play,p.classList.toggle("fwm-hidden",!k),w.innerHTML=k?t.play:t.pause}function x(){d.classList.remove("fwm-hidden"),v&&(clearTimeout(v),v=null),a.paused||(v=setTimeout(function(){d.classList.add("fwm-hidden")},2600))}function T(){if(a.paused||a.ended){var k=a.play();k&&k.catch&&k.catch(function(){})}else a.pause()}function _(k){if(isFinite(a.duration)){var P=Math.min(Math.max(0,a.currentTime+k),a.duration);a.currentTime=P;var j=k<0?L:O;j.classList.add("fwm-show"),setTimeout(function(){j.classList.remove("fwm-show")},420)}}function g(){const k=document;if(document.fullscreenElement||k.webkitFullscreenElement){(document.exitFullscreen||k.webkitExitFullscreen).call(document);return}u.requestFullscreen?u.requestFullscreen().then(function(){try{screen.orientation&&screen.orientation.lock&&screen.orientation.lock("landscape").catch(function(){})}catch{}}).catch(function(){B()}):B()}function B(){const k=a;k.webkitEnterFullscreen&&k.webkitEnterFullscreen()}a.addEventListener("play",function(){h(),x()}),a.addEventListener("pause",function(){h(),x()}),a.addEventListener("ended",function(){h(),x()}),a.addEventListener("waiting",function(){u.classList.add("fwm-loading")}),a.addEventListener("playing",function(){u.classList.remove("fwm-loading")}),a.addEventListener("canplay",function(){u.classList.remove("fwm-loading")}),a.addEventListener("loadedmetadata",function(){E.textContent=n(a.duration);try{a.currentTime===0&&(a.currentTime=.001)}catch{}}),a.addEventListener("timeupdate",function(){I||!isFinite(a.duration)||a.duration<=0||(S.value=String(Math.round(a.currentTime/a.duration*1e3)),m.textContent=n(a.currentTime))}),a.addEventListener("error",function(){if(u.classList.remove("fwm-loading"),d.classList.add("fwm-hidden"),p.classList.add("fwm-hidden"),!u.querySelector(".fwm-err")){var k=document.createElement("div");k.className="fwm-err",k.textContent="媒体加载失败",u.appendChild(k)}}),S.addEventListener("input",function(){if(I=!0,isFinite(a.duration)&&a.duration>0){var k=Number(S.value)/1e3*a.duration;m.textContent=n(k)}}),S.addEventListener("change",function(){isFinite(a.duration)&&a.duration>0&&(a.currentTime=Number(S.value)/1e3*a.duration),I=!1,x()}),w.addEventListener("click",function(k){k.stopPropagation(),T()}),p.addEventListener("click",function(k){k.stopPropagation(),T()}),y.addEventListener("click",function(k){k.stopPropagation(),a.muted=!a.muted,y.innerHTML=a.muted?t.muted:t.volume}),f.addEventListener("click",function(k){k.stopPropagation(),g()});var A={t:0,x:0};return u.addEventListener("click",function(k){if(k.target.closest(".fwm-bar")||k.target.closest(".fwm-bigplay"))return;var P=Date.now();const j=k.pointerType;if(j==="mouse"||j===void 0&&k.detail>1){k.detail===1&&T();return}if(P-A.t<300&&Math.abs(k.clientX-A.x)<60){A.t=0;var Z=u.getBoundingClientRect(),N=(k.clientX-Z.left)/Z.width;N<.4?_(-10):N>.6?_(10):T();return}A={t:P,x:k.clientX},d.classList.contains("fwm-hidden")?x():(d.classList.add("fwm-hidden"),v&&(clearTimeout(v),v=null))}),u.addEventListener("dblclick",function(k){if(k.target.closest(".fwm-bar")||k.target.closest(".fwm-bigplay"))return;const P=k.pointerType;P!=="mouse"&&P!==void 0||g()}),h(),x(),function(){v&&clearTimeout(v);try{a.pause()}catch{}a.removeAttribute("src");try{a.load()}catch{}u.remove()}}function s(r,c){var u=document.createElement("div");u.className="fwm-aud",u.innerHTML='<button type="button" class="fwm-aud-play" aria-label="播放/暂停">'+t.play+'</button><div class="fwm-aud-main"><div class="fwm-aud-name">'+i(c.name||"音频")+'</div><div class="fwm-aud-row"><span class="fwm-time fwm-cur">0:00</span><input type="range" class="fwm-prog" min="0" max="1000" step="1" value="0" aria-label="进度"><span class="fwm-time fwm-dur">'+(c.duration>0?n(c.duration):"--:--")+"</span></div></div>",r.appendChild(u);var a=new Audio((c.url.charAt(0)==="/"&&window.__apiBaseUrl||"")+c.url);a.preload="auto",u.appendChild(a);var d=u.querySelector(".fwm-aud-play"),p=u.querySelector(".fwm-cur"),w=u.querySelector(".fwm-dur"),y=u.querySelector(".fwm-prog"),f=!1;function m(){d.innerHTML=a.paused?t.play:t.pause}return a.addEventListener("play",m),a.addEventListener("pause",m),a.addEventListener("ended",m),a.addEventListener("loadedmetadata",function(){w.textContent=n(a.duration)}),a.addEventListener("error",function(){var E=u.querySelector(".fwm-aud-name");E&&!E.dataset.fwmErr&&(E.dataset.fwmErr="1",E.textContent=(c.name||"音频")+"(加载失败)")}),a.addEventListener("timeupdate",function(){f||!isFinite(a.duration)||a.duration<=0||(y.value=String(Math.round(a.currentTime/a.duration*1e3)),p.textContent=n(a.currentTime))}),y.addEventListener("input",function(){f=!0,isFinite(a.duration)&&a.duration>0&&(p.textContent=n(Number(y.value)/1e3*a.duration))}),y.addEventListener("change",function(){isFinite(a.duration)&&a.duration>0&&(a.currentTime=Number(y.value)/1e3*a.duration),f=!1}),d.addEventListener("click",function(){if(a.paused){var E=a.play();E&&E.catch&&E.catch(function(){m()})}else a.pause()}),m(),function(){try{a.pause()}catch{}a.src="",u.remove()}}function l(r,c){if(e(),!r||!c||!c.url)return function(){};try{return c.kind==="audio"?s(r,c):o(r,c)}catch{return function(){}}}return{mount:l}}();(function(){if(window.ChatForm&&window.ChatForm.__installed)return;function e(){injectOwnedStyle("chat-form",`
1608
+ .cff-body{padding:16px 14px 24px;display:flex;flex-direction:column;gap:12px;}
1609
+ .cff-desc{font-size:.82rem;color:var(--text-3,#718096);line-height:1.5;}
1610
+ .cff-body .set-card{margin:0;}
1611
+ .cff-body .set-card-title .cff-req{color:var(--danger,#e23e3e);margin-left:2px;}
1612
+ .cff-body .agent-proxy-field{margin:0;}
1613
+ .cff-actions{display:flex;gap:10px;}
1614
+ .cff-actions .link-btn,.cff-actions .cff-reset{flex:1;}
1615
+ .cff-reset{min-height:44px;padding:0 14px;font:inherit;font-size:.85rem;cursor:pointer;-webkit-tap-highlight-color:transparent;}
1616
+ .cff-up{display:flex;flex-direction:column;gap:8px;}
1617
+ .cff-up-btn{display:flex;align-items:center;gap:8px;min-height:44px;padding:0 12px;border:none;border-radius:var(--neu-radius-sub);background:var(--neu-inset);box-shadow:var(--neu-press-sm);color:var(--text-2,#4a5568);font:inherit;font-size:.85rem;cursor:pointer;width:100%;box-sizing:border-box;}
1618
+ .cff-up-btn[aria-busy="true"]{opacity:.6;pointer-events:none;}
1619
+ .cff-up-done{display:flex;align-items:center;gap:10px;padding:8px 10px;border:none;border-radius:10px;background:var(--neu-bg);box-shadow:var(--neu-raise-xs);}
1620
+ .cff-up-done img{flex:none;width:52px;height:52px;object-fit:cover;border-radius:8px;}
1621
+ .cff-up-ref{font-size:.8rem;color:var(--text-1,#2d3748);font-weight:600;word-break:break-all;}
1622
+ .cff-up-meta{font-size:.72rem;color:var(--text-3,#718096);margin-top:2px;}
1623
+ .cff-up-rm{margin-left:auto;flex:none;border:none;background:none;color:var(--danger,#e23e3e);font-size:1rem;cursor:pointer;padding:6px;}`)}function t(i){return!i&&i!==0?"":i<1024?i+" B":i<1024*1024?(i/1024).toFixed(1)+" KB":(i/(1024*1024)).toFixed(1)+" MB"}AppWindows.define("chatForm",{title:function(i){return i.form&&i.form.name||"表单提交"},mode:"layer",fill:!0,render:function(i,o){e();const s=o.form||{fields:[]},l=o.sid,r=o.onSubmit;i.className="cff-body",i.innerHTML="";const c={},u={},a=Array.isArray(s.fields)?s.fields:[];if(s.description){const m=document.createElement("div");m.className="cff-desc",m.textContent=s.description,i.appendChild(m)}const d={};function p(m,E){const S=document.createElement("div");S.className="set-card",S.innerHTML='<div class="set-card-head"><div><div class="set-card-title">'+escapeHtml(m.label||m.key)+(m.required?'<span class="cff-req">*</span>':"")+"</div>"+(m.hint?'<div class="set-card-hint">'+escapeHtml(m.hint)+"</div>":"")+"</div></div>",S.appendChild(E),i.appendChild(S)}a.forEach(function(m){const E=document.createElement("div");if(E.className="agent-proxy-field",m.type==="text"||m.type==="number"){const x=document.createElement("input");x.type=m.type==="number"?"number":"text",x.setAttribute("data-key",m.key),x.autocomplete="off",m.placeholder&&(x.placeholder=m.placeholder),x.setAttribute("aria-label",m.label||m.key),x.addEventListener("input",function(){c[m.key]=x.value}),E.appendChild(x),d[m.key]=x,p(m,E);return}if(m.type==="select"){const x=document.createElement("select");x.setAttribute("data-key",m.key),x.setAttribute("aria-label",m.label||m.key),x.appendChild(new Option(m.placeholder||"","")),(m.options||[]).forEach(function(T){x.appendChild(new Option(T,T))}),x.addEventListener("change",function(){c[m.key]=x.value}),E.appendChild(x),d[m.key]=x,p(m,E);return}if(m.type==="textarea"){const x=document.createElement("textarea");x.rows=5,x.setAttribute("data-key",m.key),m.placeholder&&(x.placeholder=m.placeholder),x.setAttribute("aria-label",m.label||m.key),x.addEventListener("input",function(){c[m.key]=x.value}),E.appendChild(x),d[m.key]=x,p(m,E);return}const L=(window.__gate&&window.__gate.viewer_caps||[]).indexOf("work.publish_own")>=0,O=document.createElement("div");O.className="cff-up",O.setAttribute("data-key",m.key);const I=document.createElement("button");if(I.type="button",I.className="cff-up-btn",I.textContent="📎 上传"+(m.label||m.key),!L){I.disabled=!0,I.textContent="📎 上传"+(m.label||m.key)+"(需「发布作品」能力)",I.title="附件以作品承载:上传附件需要「发布作品」能力,当前账号未开通",O.appendChild(I),d[m.key]=I,E.appendChild(O),p(m,E);return}const v=document.createElement("input");v.type="file",v.style.display="none",m.accept&&(v.accept=m.accept),I.addEventListener("click",function(){v.click()}),v.addEventListener("change",async function(){const x=v.files&&v.files[0];if(v.value="",!!x){I.setAttribute("aria-busy","true"),I.textContent="上传中…";try{const T=new FormData;T.append("file",x,x.name);const _=await window.api("/api/sessions/"+l+"/attachments",{method:"POST",body:T});if(!_||!_.ref)throw new Error("上传失败");c[m.key]=_.ref,u[m.key]={url:_.url,name:_.name||"",size:_.size||0},h(_)}catch(T){window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify(T&&T.message||"上传失败",{type:"error"})}finally{I.removeAttribute("aria-busy"),I.textContent="📎 重新上传",I.style.display=c[m.key]?"none":""}}});function h(x){let T=O.querySelector(".cff-up-done");T||(T=document.createElement("div"),T.className="cff-up-done",O.appendChild(T)),T.innerHTML=(x.is_image?'<img src="'+escapeHtml(x.url&&x.url.charAt(0)==="/"?(window.__apiBaseUrl||"")+x.url:x.url)+'" alt="">':'<span class="set-card-ico">📄</span>')+'<div><div class="cff-up-ref">'+escapeHtml(x.ref)+'</div><div class="cff-up-meta">'+escapeHtml(x.name||"")+(x.size?" · "+t(x.size):"")+'</div></div><button type="button" class="cff-up-rm" title="移除">✕</button>',T.querySelector(".cff-up-rm").addEventListener("click",function(){delete c[m.key],delete u[m.key],T.remove(),I.style.display=""})}O.appendChild(I),O.appendChild(v),d[m.key]=I,E.appendChild(O),p(m,E)});const w=document.createElement("div");w.className="cff-actions";const y=document.createElement("button");y.type="button",y.className="link-btn cff-submit",y.textContent="提交";const f=document.createElement("button");f.type="button",f.className="neu-btn cff-reset",f.textContent="重置",w.appendChild(y),w.appendChild(f),i.appendChild(w),f.addEventListener("click",function(){Object.keys(c).forEach(function(m){delete c[m]}),a.forEach(function(m){const E=d[m.key];E&&(m.type==="select"||m.type!=="file")&&(E.value="")}),i.querySelectorAll(".cff-up-done").forEach(function(m){m.remove()}),i.querySelectorAll(".cff-up-btn").forEach(function(m){m.style.display=""})}),y.addEventListener("click",function(){for(const L of a){const O=(c[L.key]||"").trim();if(L.required&&!O){window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify("请填写「"+(L.label||L.key)+"」",{type:"error"});const I=d[L.key];I&&typeof I.focus=="function"&&I.focus();return}if(L.type==="number"&&O&&!/^-?\d+(\.\d+)?$/.test(O)){window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify("「"+(L.label||L.key)+"」需为数字",{type:"error"}),d[L.key].focus();return}}const m=a.map(function(L){const O={key:L.key,label:L.label||L.key,value:(c[L.key]||"").trim()};return L.type==="file"&&O.value&&u[L.key]&&(O.url=u[L.key].url,O.name=u[L.key].name,O.size=u[L.key].size),O}),E=JSON.stringify({type:"form_submit",form:{ref:s.ref||"",version:s.version||0,name:s.name||""},entries:m});if(E.length>8e3){window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify("表单内容过长,请精简后提交",{type:"error"});return}const S="📋 表单提交"+(s.name?":"+s.name:"");if(typeof r=="function")try{r(E,S)}catch{}if(window.PlainView){const L=i.closest&&i.closest(".pv-overlay");L&&PlainView.close(L)}})}});function n(i,o,s){return AppWindows.open("chatForm",{sid:i,form:o,onSubmit:s})}window.ChatForm={__installed:!0,open:n}})();class Dn{constructor(){this.root=null,this.scrollEl=null,this.messagesEl=null,this.titleEl=null,this.activeOverlay=null,this.followOverlay=null,this.agentDotEl=null,this.typingEl=null,this.agentConfigured=null,this.ctx=null,this.inputBar=null,this.resolvingSession=null,this.historyPromise=null,this.sendChain=Promise.resolve(),this.pendingBubbles=[],this.lastMsgId=0,this.renderedIds=new Set,this.oldestRenderedId=Number.MAX_SAFE_INTEGER,this.lastDividerTs=0,this.pollTimer=null,this.adaptivePoller=null,this.agentStatusTimer=null,this.typingTimer=null,this.formCfg=null,this.formCfgPromise=null,this.historyMap=new Map,this.persistTimer=0,this.INSTANT_PAINT_LIMIT=120,this.PERSIST_DEBOUNCE_MS=600,this.DIVIDER_GAP_MS=5*60*1e3,this.TYPING_TIMEOUT_MS=180*1e3}async ensureSessionId(){if(!this.ctx)throw new Error("会话已关闭");if(this.ctx.sessionId!=null&&this.ctx.sessionId!=="")return Number(this.ctx.sessionId);const t=(this.ctx.workRef||"").trim();if(!t)throw new Error("缺少通讯入口(work_ref)");return this.resolvingSession||(this.resolvingSession=window.TypedApi.openSession(t).then(n=>{const i=n&&n.session&&n.session.session_id;if(!i)throw new Error("该作品不是可用的通讯地址");return this.ctx&&(this.ctx.sessionId=i),Number(i)}).finally(()=>{this.resolvingSession=null})),this.resolvingSession}cleanup(){this.pollTimer&&(clearTimeout(this.pollTimer),this.pollTimer=null),this.agentStatusTimer&&(clearTimeout(this.agentStatusTimer),this.agentStatusTimer=null),this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.persistTimer&&(clearTimeout(this.persistTimer),this.persistTimer=0),this.adaptivePoller&&(this.adaptivePoller.stop(),this.adaptivePoller=null),this.inputBar&&(this.inputBar.destroy(),this.inputBar=null),this.root=null,this.scrollEl=null,this.messagesEl=null,this.titleEl=null,this.activeOverlay=null,this.followOverlay=null,this.agentDotEl=null,this.typingEl=null,this.ctx=null,this.agentConfigured=null,this.pendingBubbles.length=0,this.renderedIds.clear(),this.historyMap.clear(),this.lastMsgId=0,this.oldestRenderedId=Number.MAX_SAFE_INTEGER,this.lastDividerTs=0,this.resolvingSession=null,this.historyPromise=null,this.sendChain=Promise.resolve(),this.formCfg=null,this.formCfgPromise=null}peerDisplayName(){return this.ctx?this.ctx.realName!=null&&this.ctx.realName!==""?this.ctx.realName:this.ctx.username!=null&&this.ctx.username!==""?this.ctx.username:"":""}myUserId(){const t=window.__me;return t&&typeof t.id=="number"&&isFinite(t.id)?t.id:null}historyArray(){return Array.from(this.historyMap.values()).sort((t,n)=>t.id-n.id)}scrollToBottom(){this.scrollEl&&(this.scrollEl.scrollTop=this.scrollEl.scrollHeight)}}class Vn{constructor(t){this.state=t}schedulePersist(){this.state.persistTimer||(this.state.persistTimer=window.setTimeout(()=>{this.state.persistTimer=0,this.persistHistoryNow()},this.state.PERSIST_DEBOUNCE_MS))}persistHistoryNow(){if(this.state.persistTimer&&(clearTimeout(this.state.persistTimer),this.state.persistTimer=0),!this.state.ctx||this.state.historyMap.size===0||!window.ChatHistoryCache)return;const t=this.state.myUserId(),n=Number(this.state.ctx.sessionId);t==null||!isFinite(n)||window.ChatHistoryCache.save(t,n,this.state.historyArray())}trackHistory(t){if(!(!t||t.length===0)){for(const n of t)n&&typeof n.id=="number"&&isFinite(n.id)&&this.state.historyMap.set(n.id,n);this.schedulePersist()}}async readSnapshot(t){if(!window.ChatHistoryCache)return[];const n=this.state.myUserId(),i=Number(t.sessionId);if(n==null||!isFinite(i))return[];try{const o=new Promise(r=>{window.setTimeout(()=>{r([])},150)}),s=window.ChatHistoryCache.load(n,i),l=await Promise.race([s,o]);return Array.isArray(l)?l:[]}catch{return[]}}}function Fn(e){if(!e)return"";const t=new Date(e);if(isNaN(t.getTime()))return"";const n=t.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}),i=new Date;return t.toDateString()===i.toDateString()?n:t.getMonth()+1+"月"+t.getDate()+"日 "+n}function Qt(e){const t=document.createElement("div");t.className="gct-time-divider";const n=document.createElement("span");return n.className="gct-time-text",n.textContent=Fn(e),t.appendChild(n),t}class Wn{constructor(t,n){this.state=t,this.onAction=n}insertTimeDividerIfNeeded(t){if(!t||!this.state.messagesEl)return;const n=new Date(t).getTime();isNaN(n)||this.state.lastDividerTs!==0&&n-this.state.lastDividerTs<this.state.DIVIDER_GAP_MS||(this.state.messagesEl.appendChild(Qt(t)),this.state.lastDividerTs=n)}fillBubbleText(t,n){if(window.Md&&typeof window.Md.render=="function"){window.Md.render(t,n);return}t.textContent=n||""}addBubble(t,n,i,o,s){const l=this.state.messagesEl;if(!l)return null;const r=s||l,c=r.querySelector(".gct-welcome");if(c&&c.remove(),i!=null){if(this.state.renderedIds.has(i))return l.querySelector(`[data-msg-id="${CSS.escape(String(i))}"]`);const p=l.querySelector(`[data-msg-id="${CSS.escape(String(i))}"]`);if(p)return this.state.renderedIds.add(i),p}const u=document.createElement("div");u.className="gct-msg "+t,i!=null&&(u.dataset.msgId=String(i));const a=document.createElement("div");a.className="gct-bubble";const d=document.createElement("div");return d.className="gct-text",this.fillBubbleText(d,n),a.appendChild(d),u.appendChild(a),i!=null&&this.appendBubbleActions(u,n,o),r.appendChild(u),s||this.state.scrollToBottom(),i!=null&&i>this.state.lastMsgId&&(this.state.lastMsgId=i),i!=null&&(this.state.renderedIds.add(i),i<this.state.oldestRenderedId&&(this.state.oldestRenderedId=i)),a}appendBubbleActions(t,n,i){const o=document.createElement("div");o.className="gct-actions";const s=[["edit","编辑"],["quote","引用"],["resend","重发"],["copy","复制"]];for(const[l,r]of s){const c=document.createElement("button");c.type="button",c.className="gct-act",c.dataset.act=l,c.textContent=r,c.addEventListener("click",()=>{this.onAction(l,n,i,c)}),o.appendChild(c)}t.appendChild(o)}addPendingBubble(t){const n=document.createElement("div");n.className="gct-msg user gct-pending";const i=document.createElement("div");i.className="gct-bubble";const o=document.createElement("div");o.className="gct-text",this.fillBubbleText(o,t),i.appendChild(o),n.appendChild(i);const s=document.createElement("div");return s.className="gct-send-state",s.textContent="发送中...",n.appendChild(s),this.state.messagesEl&&(this.state.messagesEl.appendChild(n),this.state.scrollToBottom()),this.state.pendingBubbles.push(n),n}markPendingFailed(t,n,i,o){t.classList.remove("gct-pending"),t.classList.add("gct-failed");const s=t.querySelector(".gct-send-state");s&&(s.textContent="发送失败,点击重试"),t.addEventListener("click",function l(){t.removeEventListener("click",l),t.classList.remove("gct-failed"),t.classList.add("gct-pending"),s&&(s.textContent="重新发送..."),o()})}reattachPending(){if(this.state.messagesEl){for(const t of this.state.pendingBubbles)t.parentNode!==this.state.messagesEl&&this.state.messagesEl.appendChild(t);this.state.scrollToBottom()}}showTypingIndicator(){const t=this.state.messagesEl;if(!(!t||this.state.agentConfigured!==!0)){if(this.state.typingEl&&this.state.typingEl.isConnected)t.appendChild(this.state.typingEl);else{const n=document.createElement("div");n.className="gct-msg peer gct-typing",n.setAttribute("aria-label","对方正在输入");const i=document.createElement("div");i.className="gct-bubble";for(let o=0;o<3;o++){const s=document.createElement("span");s.className="gct-typing-dot",s.setAttribute("aria-hidden","true"),i.appendChild(s)}n.appendChild(i),t.appendChild(n),this.state.typingEl=n}this.state.scrollToBottom(),this.state.typingTimer&&clearTimeout(this.state.typingTimer),this.state.typingTimer=window.setTimeout(()=>{this.state.typingTimer=null,this.hideTypingIndicator()},this.state.TYPING_TIMEOUT_MS)}}hideTypingIndicator(){this.state.typingTimer&&(clearTimeout(this.state.typingTimer),this.state.typingTimer=null),this.state.typingEl&&(this.state.typingEl.remove(),this.state.typingEl=null)}appendFileChip(t,n){let i={};try{i=JSON.parse(n.attachment_meta||"{}")||{}}catch{}const o=Number(i.size)||0,s=document.createElement("button");s.type="button",s.className="gct-file";const l=document.createElement("span");l.className="gct-file-name",l.textContent="📄 "+String(i.name||"附件");const r=document.createElement("span");r.className="gct-file-size",r.textContent=o?o<1024*1024?Math.max(1,Math.round(o/1024))+" KB":(o/(1024*1024)).toFixed(1)+" MB":"",s.appendChild(l),r.textContent&&s.appendChild(r),s.title="下载附件",s.addEventListener("click",function(){window.open(n.attachment_url,"_blank")}),t.appendChild(s)}refreshBubble(t){const n=this.state.messagesEl;if(!n||t.id==null)return;const i=t.content||"";for(const o of Array.from(n.querySelectorAll(`[data-msg-id="${CSS.escape(String(t.id))}"]`))){const s=o,l=s.querySelector(".gct-text");l&&this.fillBubbleText(l,i);const r=s.querySelector(".gct-bubble");r&&t.attachment_url&&!s.querySelector(".gct-file")&&this.appendFileChip(r,t);const c=s.querySelector(".gct-actions");c&&c.remove(),this.appendBubbleActions(s,i,t)}}}class qn{constructor(t,n,i,o){this.state=t,this.renderer=n,this.renderItem=i,this.focusInput=o}sendBlockedMessage(){return this.state.ctx?this.state.ctx.friendId==null||this.state.ctx.friendId===""?"会话连接中,请稍候再发送":null:"会话已关闭"}async send(t){const n=this.sendBlockedMessage();if(n){MobileShell.notify(n,{type:"info"});return}return this.state.adaptivePoller&&this.state.adaptivePoller.onActivity(),this.state.inputBar&&this.state.inputBar.clear(),this.sendPlain(t,null,null,null)}async resendContent(t,n,i){const o=this.sendBlockedMessage();if(o){MobileShell.notify(o,{type:"info"});return}return this.sendPlain(t,null,i,n)}sendPlain(t,n,i,o){const s=this.state.ctx,l=n||this.renderer.addPendingBubble(i||t),r=async()=>{if(!this.state.messagesEl||this.state.ctx!==s){l.remove();return}try{const u={content:t};o&&(o.attachment_url&&(u.attachment_url=o.attachment_url),o.kind&&(u.kind=o.kind),o.attachment_meta&&(u.attachment_meta=o.attachment_meta));const a=await this.state.ensureSessionId(),d=await window.TypedApi.sendSessionMessage(a,u);if(!this.state.messagesEl)return;const p=this.state.pendingBubbles.indexOf(l);p>=0&&this.state.pendingBubbles.splice(p,1),l.remove(),d&&d.item&&(this.renderItem(d.item),this.renderer.showTypingIndicator())}catch(u){if(!this.state.messagesEl||this.state.ctx!==s)return;this.renderer.markPendingFailed(l,t,o,()=>{this.sendPlain(t,l,i,o)}),MobileShell.notify(u.message,{type:"error"})}finally{this.focusInput()}},c=this.state.sendChain.then(r,r);return this.state.sendChain=c.catch(()=>{}),c}}window.ChatView=window.ChatView||function(){function e(){injectOwnedStyle("chatview",`
1624
+ .gct{background:#f3f4f6;color:#1f2937;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;}
1625
+ .pv-title.gct-title-link{cursor:pointer;}
1626
+ .pv-title.gct-title-link:active{opacity:.6;}
1627
+ /* 标题旁代理信号灯(配色与外接站点在线/离线角标同源):仅在对方配了代理时出现。 */
1628
+ .gct-agent-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-left:6px;vertical-align:middle;}
1629
+ .gct-agent-dot[data-state="online"]{background:var(--ok);}
1630
+ .gct-agent-dot[data-state="offline"]{background:var(--danger);box-shadow:0 0 0 2px rgba(229,62,62,.25);}
1631
+ .gct-msgs{padding:12px 10px;display:flex;flex-direction:column;gap:10px;}
1632
+ .gct-welcome{text-align:center;color:#9ca3af;font-size:14px;line-height:1.8;padding:40px 20px;}
1633
+ /* 消息行两侧不展示头像(2026-08 起),气泡直接占满可用宽度,最大化内容展示。
1634
+ 行内纵向排布(气泡 + 气泡下动作行):user 行右对齐、peer 行左对齐。 */
1635
+ .gct-msg{display:flex;flex-direction:column;align-items:flex-start;max-width:100%;}
1636
+ .gct-msg.user{align-items:flex-end;}
1637
+ .gct-bubble{max-width:100%;padding:10px 14px;border-radius:16px;font-size:15px;line-height:1.55;word-break:break-word;white-space:pre-wrap;}
1638
+ .gct-msg.user .gct-bubble{background:#667eea;color:#fff;border-bottom-right-radius:6px;}
1639
+ .gct-msg.peer .gct-bubble{background:var(--neu-bg);color:#1f2937;border-bottom-left-radius:6px;box-shadow:0 1px 2px rgba(0,0,0,.06);}
1640
+ .gct-bubble.error{background:#fef2f2;color:#b91c1c;}
1641
+ /* 乐观发送反馈(pending 气泡):发送中半透明 + 状态行;失败转红底可点按重发,
1642
+ 内容随气泡留存(微信式),不再只靠一条浮动提示告知发送失败。 */
1643
+ .gct-msg.user.gct-pending .gct-bubble{opacity:.6;}
1644
+ .gct-send-state{font-size:11px;line-height:1.4;margin-top:4px;opacity:.8;text-align:right;}
1645
+ .gct-msg.gct-failed .gct-bubble{background:#fef2f2;color:#b91c1c;cursor:pointer;border-bottom-right-radius:6px;}
1646
+ .gct-msg.gct-failed .gct-send-state{color:#b91c1c;font-weight:600;}
1647
+ /* 气泡动作行(2026-10-11):每个已落库气泡(不分自己/对方)下方挂
1648
+ 「编辑 / 引用 / 重发 / 复制」四钮(.gct-act),全部纯客户端行为;
1649
+ 乐观气泡(pending/failed)不带——失败重发沿用气泡本身的点按重试,
1650
+ 不与动作行叠两套交互。 */
1651
+ .gct-actions{display:flex;flex-wrap:wrap;gap:2px;margin-top:3px;}
1652
+ .gct-act{border:none;background:transparent;padding:8px 9px;border-radius:8px;color:#9ca3af;font-size:11px;line-height:1.2;font-family:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation;}
1653
+ .gct-act:hover{color:#4b5563;background:rgba(0,0,0,.05);}
1654
+ .gct-act:active{background:rgba(0,0,0,.08);color:#374151;}
1655
+ /* 气泡内 Markdown 排版(fillBubbleText 渲染后挂 .gct-md):紧凑段落 + 基础 code/列表/引用样式。
1656
+ 气泡默认 white-space:pre-wrap 对 marked 输出的标签间换行会多出空白行,这里改回 normal。 */
1657
+ .gct-md{white-space:normal;}
1658
+ .gct-md>:first-child{margin-top:0;}
1659
+ .gct-md>:last-child{margin-bottom:0;}
1660
+ .gct-md p{margin:0 0 6px;}
1661
+ .gct-md h1,.gct-md h2,.gct-md h3,.gct-md h4,.gct-md h5,.gct-md h6{margin:8px 0 4px;font-size:1.05em;line-height:1.4;}
1662
+ .gct-md ul,.gct-md ol{margin:4px 0;padding-left:20px;}
1663
+ .gct-md li{margin:2px 0;}
1664
+ .gct-md code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.88em;background:rgba(0,0,0,.08);padding:1px 5px;border-radius:4px;word-break:break-all;}
1665
+ .gct-md pre{background:rgba(0,0,0,.06);border-radius:8px;padding:8px 10px;margin:6px 0;overflow-x:auto;}
1666
+ .gct-md pre code{background:none;padding:0;}
1667
+ .gct-msg.user .gct-md code{background:rgba(255,255,255,.22);}
1668
+ .gct-msg.user .gct-md pre{background:rgba(0,0,0,.18);}
1669
+ .gct-md blockquote{margin:4px 0;padding:2px 10px;border-left:3px solid rgba(0,0,0,.18);opacity:.85;}
1670
+ .gct-msg.user .gct-md blockquote{border-left-color:rgba(255,255,255,.5);}
1671
+ .gct-md a{color:var(--primary);text-decoration:underline;word-break:break-all;}
1672
+ .gct-msg.user .gct-md a{color:#fff;}
1673
+ /* 聊天入口零媒体(2026-10-12 用户裁定:聊天窗口不直接出现图片/附件):
1674
+ md.js render() 把 img/video/audio 展平为替代文本,气泡内无媒体元素 */
1675
+ .gct-md hr{border:none;border-top:1px solid rgba(0,0,0,.12);margin:8px 0;}
1676
+ /* 表格:gfm 解析 + 窄屏横向滚动(气泡宽度有限,宽表不挤压断行) */
1677
+ .gct-md table{display:block;max-width:100%;overflow-x:auto;border-collapse:collapse;margin:6px 0;font-size:.9em;}
1678
+ .gct-md th,.gct-md td{border:1px solid rgba(0,0,0,.14);padding:3px 8px;text-align:left;}
1679
+ .gct-md th{background:rgba(0,0,0,.05);}
1680
+ /* ==高亮== 扩展(md.js 唯一引擎) */
1681
+ .gct-md mark{background:#fde68a;color:inherit;padding:0 2px;border-radius:3px;}
1682
+ /* 任务列表 checkbox 只读(md.js 统一 disabled) */
1683
+ .gct-md li input[type="checkbox"]{margin-right:6px;}
1684
+ /* 微信式会话时间分隔条:消息之间间隔超过 5 分钟、或进入会话后第一条消息之前,
1685
+ 在消息流中插入一条居中的时间戳;单个气泡内不再显示时间。 */
1686
+ .gct-time-divider{display:flex;justify-content:center;margin:8px 0 4px;}
1687
+ .gct-time-divider .gct-time-text{background:rgba(120,120,120,.18);color:#4b5563;font-size:11px;line-height:1.5;padding:2px 10px;border-radius:10px;}
1688
+ /* 文件 chip(附件统一呈现,图片/文件同形):气泡内按钮块——名称 + 大小,点按经闸读端点下载 */
1689
+ .gct-file{display:flex;align-items:center;gap:8px;width:100%;box-sizing:border-box;margin-top:6px;padding:9px 12px;border:1px solid rgba(15,23,42,.14);border-radius:10px;background:rgba(255,255,255,.65);color:#1f2937;font:inherit;font-size:.85rem;cursor:pointer;text-align:left;-webkit-tap-highlight-color:transparent;}
1690
+ .gct-msg.user .gct-file{background:rgba(255,255,255,.22);border-color:rgba(255,255,255,.4);color:#fff;}
1691
+ .gct-file:active{opacity:.6;}
1692
+ .gct-file-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
1693
+ .gct-file-size{flex:none;font-size:.72rem;opacity:.75;}
1694
+ /* 正在输入指示器(typing indicator):peer 侧三点气泡,消息发送成功后
1695
+ (后端开始调度智能体自动回复)挂到消息流末尾,第一条对方消息到达即撤。
1696
+ 仅对方配置了代理的会话显示。 */
1697
+ .gct-msg.gct-typing .gct-bubble{display:flex;align-items:center;gap:4px;padding:12px 14px;}
1698
+ .gct-typing-dot{width:7px;height:7px;border-radius:50%;background:#9ca3af;animation:gctTypingBlink 1.2s infinite ease-in-out;}
1699
+ .gct-typing-dot:nth-child(2){animation-delay:.15s;}
1700
+ .gct-typing-dot:nth-child(3){animation-delay:.3s;}
1701
+ @keyframes gctTypingBlink{0%,60%,100%{opacity:.3;transform:translateY(0);}30%{opacity:1;transform:translateY(-3px);}}
1702
+ @media (prefers-reduced-motion: reduce){.gct-typing-dot{animation:none;opacity:.6;}}`)}function t(){const n=new Dn,i=new Vn(n),o=new Wn(n,r),s=new qn(n,o,a,j);function l(){return WorkActionRegistry.me()}function r(W,q,F,M){const G=String(q??"");if(W==="edit"||W==="quote"){const re=n.inputBar;if(!re||!re.input)return;const ce=re.input;let H;if(W==="edit"?H=G:H=G.split(`
1703
+ `).map(oe=>"> "+oe).join(`
1704
+ `)+`
1705
+
1706
+ `+(ce.value||""),ce.maxLength>0&&H.length>ce.maxLength){MobileShell.notify("单条消息最长 10000 字",{type:"info"});return}ce.value=H,ce.dispatchEvent(new Event("input",{bubbles:!0})),j();try{ce.setSelectionRange(H.length,H.length)}catch{}M&&(M.dataset.fwAck="1");return}if(W==="resend"){const re=F?String(F.content==null?"":F.content):G,ce=G||(F&&F.attachment_url?"📎 附件":"");M&&(M.dataset.fwAck="1"),s.resendContent(re,F,ce);return}W==="copy"&&(M&&(M.dataset.fwAck="1"),c(G))}async function c(W){try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(W);else{const q=document.createElement("textarea");q.value=W,q.setAttribute("readonly",""),q.style.cssText="position:fixed;top:0;left:0;opacity:0;",document.body.appendChild(q),q.select(),document.execCommand("copy"),q.remove()}MobileShell.notify("已复制",{type:"success"})}catch{MobileShell.notify("复制失败,请手动选择复制",{type:"error"})}}async function u(){if(n.historyPromise)return n.historyPromise;const W=n.ctx,q=n.messagesEl;if(!(!W||!q))return q.innerHTML=StatusTpl.loading(),n.historyPromise=async function(){const F=n.ensureSessionId().then(function(ce){return window.TypedApi.getSessionMessages(ce,{after_id:0})}),M=await i.readSnapshot(W);if(!n.messagesEl||!n.scrollEl||n.ctx!==W)return;let G=!1;if(M.length>0){for(const H of M)n.historyMap.set(H.id,H);const ce=M.slice(-n.INSTANT_PAINT_LIMIT);n.messagesEl.innerHTML="";for(const H of ce)a(H,{fromCache:!0});o.reattachPending(),G=!0}const re=M.length>n.INSTANT_PAINT_LIMIT;try{const ce=await F;if(!n.messagesEl||!n.scrollEl||n.ctx!==W)return;const H=Array.isArray(ce.items)?ce.items:[];G||(n.messagesEl.innerHTML=H.length?"":'<div class="gct-welcome">还没有聊天记录,打个招呼吧 👋</div>');for(const te of H)a(te);if(o.reattachPending(),i.trackHistory(H),i.persistHistoryNow(),H.length>=50||re){const te=n.oldestRenderedId!==Number.MAX_SAFE_INTEGER?n.oldestRenderedId:H[0].id;try{m(W,te)}catch(oe){console.warn("[chatview] bindHistoryPager failed:",oe)}}}catch(ce){if(!n.messagesEl||!n.scrollEl||n.ctx!==W)return;if(G){if(re&&n.oldestRenderedId!==Number.MAX_SAFE_INTEGER)try{m(W,n.oldestRenderedId)}catch(te){console.warn("[chatview] bindHistoryPager failed:",te)}return}n.messagesEl.innerHTML=StatusTpl.error(ce&&ce.message||"加载失败","area");const H=n.messagesEl.firstElementChild;if(H){H.setAttribute("role","button"),H.setAttribute("tabindex","0");const te=function(oe){oe.type==="keydown"&&oe.key!=="Enter"&&oe.key!==" "||(oe.preventDefault(),H.removeEventListener("click",te),H.removeEventListener("keydown",te),u())};H.addEventListener("click",te),H.addEventListener("keydown",te)}o.reattachPending()}finally{n.historyPromise=null}}(),n.historyPromise}function a(W,q){const F=!!(q&&q.fromCache);if(!F&&W.id!=null&&n.renderedIds.has(W.id)){const M=n.historyMap.get(W.id),G=!M||M.content!==W.content||(M.attachment_url||"")!==(W.attachment_url||"");i.trackHistory([W]),G&&o.refreshBubble(W);return}W.from_me||o.hideTypingIndicator(),o.insertTimeDividerIfNeeded(W.created_at||""),d(W,null),!F&&i.trackHistory([W])}function d(W,q){const F=o.addBubble(W.from_me?"user":"peer",W.content||"",W.id,W,q);return W.attachment_url&&F&&F.classList.contains("gct-bubble")&&!F.querySelector(".gct-file")&&o.appendFileChip(F,W),F&&F.classList.contains("gct-msg")?F:F&&F.closest(".gct-msg")||null}let p=null,w=null;function y(W){W.__batchFirst&&(w=null);const q=new Date(W.created_at||"").getTime(),F=w===null||q-w>=n.DIVIDER_GAP_MS;isNaN(q)||(w=q);const M=d(W,document.createElement("div")),G=document.createDocumentFragment();return M&&(F&&G.appendChild(Qt(W.created_at||"")),G.appendChild(M)),G}async function f(W,q,F){const M={items:[],has_more:!1},G=n.myUserId();if(G==null||!window.ChatHistoryCache||!(F>0))return M;let re=[];try{re=await window.ChatHistoryCache.load(G,W)}catch{return M}const ce=re.filter(function(oe){return oe.id<q}).sort(function(oe,ve){return ve.id-oe.id}).slice(0,F).reverse(),H=ce.length?ce[0].id:0,te=ce.length>0&&re.some(function(oe){return oe.id<H});return{items:ce,has_more:te}}function m(W,q){p||!n.messagesEl||!n.scrollEl||(p=InfiniteScroll.bind({container:n.messagesEl,direction:"up",root:n.scrollEl,initial:!1,pageSize:50,initialOffset:q,extractId:F=>String(F.id),fetchPage:async F=>{const M=await n.ensureSessionId();let G=[],re=!1;try{const ce=await window.TypedApi.getSessionMessages(M,{before_id:F,limit:50});G=ce&&ce.items||[],re=!!(ce&&ce.has_more)}catch{}if(G.length<50){const ce=G.length?Math.min(G[0].id,F):F,H=await f(M,ce,50-G.length);H.items.length&&(G=G.concat(H.items)),re=re||H.has_more}return G.length&&(G[0].__batchFirst=!0),i.trackHistory(G),i.schedulePersist(),{items:G,has_more:re,next_offset:G.length?G[0].id:F}},renderItem:y,onError:function(){}}))}async function E(){try{const W=await n.ensureSessionId(),q=await window.TypedApi.getSessionMessages(W,{after_id:n.lastMsgId});for(const F of q.items)a(F)}catch{}}function S(){document.hidden||E()}function L(){if(O(),typeof AdaptivePoller<"u")try{n.adaptivePoller=new AdaptivePoller({priority:"high",requestKey:"chat:"+(n.ctx.sessionId||n.ctx.friendId),onPoll:async()=>{if(document.hidden)return{items:[]};const W=await n.ensureSessionId();return await window.TypedApi.getSessionMessages(W,{after_id:n.lastMsgId})},onMessage:W=>{for(const q of W)a(q)},onError:W=>{console.debug("[chatview] Poll error:",W)}}),n.adaptivePoller.start(),document.addEventListener("visibilitychange",S);return}catch(W){console.debug("[chatview] AdaptivePoller failed, fallback to fixed interval:",W)}document.addEventListener("visibilitychange",S),n.pollTimer=setInterval(()=>{document.hidden||E()},3e3)}function O(){n.adaptivePoller&&(n.adaptivePoller.stop(),n.adaptivePoller=null),n.pollTimer&&(clearInterval(n.pollTimer),n.pollTimer=null),document.removeEventListener("visibilitychange",S)}function I(){const W=!!(n.formCfg&&n.formCfg.configured&&n.formCfg.form);n.inputBar&&n.inputBar.setPlus(W)}function v(){const W=n.ctx.friendId;n.formCfgPromise=n.ensureSessionId().then(function(q){return window.TypedApi.getSessionFormConfig(q)}).then(function(q){!n.ctx||String(n.ctx.friendId)!==String(W)||(n.formCfg=q||{configured:!1,form:null},I())}).catch(function(){I()})}function h(){const W=n.formCfg;W&&W.configured&&W.form&&window.ChatForm&&n.ensureSessionId().then(function(q){ChatForm.open(q,W.form,function(F,M){s.sendPlain(String(F),null,M==null?null:String(M),null)})}).catch(function(){})}function x(W){const q=ChatFrame.create();if(n.root=q.root,q.root.classList.add("gct"),q.scrollEl.classList.add("gct-msgs"),q.scrollEl.setAttribute("role","log"),q.scrollEl.setAttribute("aria-live","polite"),q.scrollEl.setAttribute("aria-label","聊天记录"),n.messagesEl=q.scrollEl,n.scrollEl=q.scrollEl,W.appendChild(q.root),l().role==="guest")n.inputBar=InputBar.create({guestHtml:'<a href="/login">登录</a> 后开始聊天'}),n.messagesEl.innerHTML='<div class="gct-welcome">登录后查看聊天记录</div>';else if(n.inputBar=InputBar.create({maxLength:1e4,ariaLabel:"消息内容",limitMessage:"单条消息最长 10000 字",onSend:F=>s.send(F),plus:!0,plusLabel:"表单",onPlus:function(){h()}}),n.inputBar.input){const F=n.inputBar.input;F.addEventListener("input",function(){n.adaptivePoller&&n.adaptivePoller.onActivity()}),F.addEventListener("focus",function(){n.adaptivePoller&&n.adaptivePoller.onActivity()})}q.mountBottom(n.inputBar.root),n.messagesEl.addEventListener("click",F=>{const M=F.target;M&&M.closest("a, button, input, textarea")||n.inputBar&&n.inputBar.input&&document.activeElement===n.inputBar.input&&n.inputBar.blur()})}function T(){if(O(),A(),i.persistHistoryNow(),p){try{p.destroy()}catch{}p=null}w=null,n.cleanup()}function _(W){if(n.agentConfigured=!!(W&&W.configured),!(!n.titleEl||!n.titleEl.parentNode)){if(!W||!W.configured){n.agentDotEl&&(n.agentDotEl.remove(),n.agentDotEl=null);return}n.agentDotEl||(n.agentDotEl=document.createElement("span"),n.agentDotEl.className="gct-agent-dot",n.agentDotEl.setAttribute("aria-hidden","true")),n.agentDotEl.setAttribute("data-state",W.online?"online":"offline"),n.agentDotEl.title=W.online?"代理在线":"代理离线",n.titleEl.appendChild(n.agentDotEl)}}async function g(){if(!n.ctx||n.ctx.friendId==null||n.ctx.friendId===""||l().role==="guest")return;const W=n.ctx.friendId;try{const q=await n.ensureSessionId(),F=await window.TypedApi.getSessionAgentStatus(q);if(!n.ctx||String(n.ctx.friendId)!==String(W))return;_(F)}catch{}}function B(){n.agentDotEl||g(),A(),n.agentStatusTimer=setInterval(()=>{document.hidden||g()},15e3)}function A(){n.agentStatusTimer&&(clearInterval(n.agentStatusTimer),n.agentStatusTimer=null)}function k(){if(!n.ctx||n.ctx.friendId==null||n.ctx.friendId==="")return;const W=n.root&&n.root.closest?n.root.closest(".pv-overlay"):null;n.titleEl=W&&W.querySelector(".pv-title"),n.titleEl&&(n.titleEl.classList.add("gct-title-link"),n.titleEl.setAttribute("role","button"),n.titleEl.tabIndex=0,n.titleEl.setAttribute("aria-label","查看 "+(n.peerDisplayName()||"对方")+" 的主页"),n.titleEl.addEventListener("click",()=>ie(void 0)),n.titleEl.addEventListener("keydown",q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),ie(void 0))})),P(),B(),n.formCfgPromise||v()}function P(){if(!window.LayerChrome||typeof LayerChrome.attachSwipeLeft!="function")return;const W=n.root&&n.root.closest?n.root.closest(".pv-overlay"):null;W&&LayerChrome.attachSwipeLeft(W,{isActive(){return!n.followOverlay},onDragStart(){ie({suppressEnter:!0,onOpened(q){q&&(n.followOverlay=q)}})},getFollowEl(){return n.followOverlay&&n.followOverlay.isConnected?n.followOverlay:null},onCommit(q){q&&n.followOverlay===q&&(n.followOverlay=null)},onAbort(q){n.followOverlay===q&&(n.followOverlay=null),q&&q.isConnected&&window.PlainView&&PlainView.close(q,{immediate:!0})}})}function j(){n.inputBar&&n.inputBar.focus()}let Z=!1;function N(){if(Z||!n.ctx||!n.messagesEl||l().role==="guest"||n.ctx.friendId==null||n.ctx.friendId==="")return;Z=!0;const W=n.root&&n.root.closest?n.root.closest(".pv-overlay"):null,q=W?W.querySelector(".pv-title"):null;q&&n.peerDisplayName()&&(q.textContent=n.peerDisplayName()),k(),u(),L()}function ee(W){if(e(),n.ctx=W||{},n.ctx.sessionId&&!n.ctx.friendId){const q=Number(n.ctx.sessionId);isFinite(q)&&q>0&&window.TypedApi.getSession(q).then(F=>{F&&F.session&&n.ctx&&(n.ctx.friendId=F.session.target_id,n.ctx.username=F.session.target_username||"",n.ctx.realName=F.session.target_username||"",N())}).catch(F=>{console.warn("[chatview] 获取会话信息失败:",F),n.messagesEl&&!Z&&(n.messagesEl.innerHTML=StatusTpl.error("会话信息加载失败,请关闭后重试","area"))})}AppWindows.define("chat",{title:n.peerDisplayName()||"聊天",mode:"layer",onClose:T,render:function(q){n.activeOverlay=q.closest(".pv-overlay"),x(q),N()}}),AppWindows.open("chat",{context:W})}function ie(W){!n.ctx||!n.ctx.friendId||(typeof window.openUserProfile=="function"?window.openUserProfile(n.ctx.friendId,W):window.ProfileView?window.ProfileView.open({userId:Number(n.ctx.friendId)},W):window.LateGate&&window.LateGate.ensure&&window.LateGate.ensure("ProfileView").then(function(q){q&&q.open({userId:Number(n.ctx.friendId)},W)}).catch(function(){}))}return{open:ee}}return{open:function(n){t().open(n)}}}();(function(){if(window.MessagesView&&window.MessagesView.__installed)return;let e=null;function t(r){window.MobileShell.notify(r&&r.message||"网络错误",{type:"error"})}function n(r){return(e?e.getItems():[]).find(function(u){return Number(u.session_id)===r})||{}}function i(r){const c=n(r);if(!c||!c.session_id){console.warn("[messages-view] 会话数据未找到,sessionId:",r),Interact.launch({wait:function(){return window.ChatView||(window.LateGate&&window.LateGate.ensure?window.LateGate.ensure("ChatView"):null)},open:function(u){u.open({sessionId:r})},fail:"聊天窗口加载失败,请重试"});return}Interact.launch({wait:function(){return window.ChatView||(window.LateGate&&window.LateGate.ensure?window.LateGate.ensure("ChatView"):null)},open:function(u){u.open({sessionId:r,friendId:c.target_id!=null?c.target_id:void 0,username:c.target_username||"",realName:c.target_username||""})},fail:"聊天窗口加载失败,请重试"})}async function o(r){const c=n(r);try{await window.api("/api/sessions/"+r+"/pin",{method:c.pinned?"DELETE":"POST"}),window.MobileShell.notify(c.pinned?"已取消置顶":"已置顶",{type:"success"}),e&&e.reload()}catch(u){t(u)}}async function s(r){const u=n(r).target_username||"";if(await window.MobileShell.confirm("确定删除与「"+u+"」的会话?聊天记录将被清空",{title:"删除会话",confirmText:"删除",danger:!0}))try{await window.api("/api/sessions/"+r,{method:"DELETE"}),window.MobileShell.notify("已删除会话",{type:"success"}),e&&e.removeItem("conv:"+String(r))}catch(d){t(d)}}function l(){!window.AppWindows||typeof AppWindows.define!="function"||(AppWindows.define("messagesEntrance",{title:"消息",mode:"layer",onClose:function(){e&&(e.destroy(),e=null)},render:function(r){const c=r.closest(".pv-scroll")||r,u=document.createElement("div");u.className="items-grid",r.appendChild(u),e=ListView.bind({name:"messages-view",container:u,viewRoot:c,pageSize:20,pollInterval:1e4,computeSignature:function(a){return JSON.stringify((a||[]).map(function(d){return[d.type,d.session_id,d.target_id,d.pinned,d.last_message_id,d.last_time,d.target_username]}))},extractId:function(a){return"conv:"+a.session_id},fetchPage:async function(a,d,p){const w=window.currentUser?window.currentUser():null;if(!w||w.role==="guest")return{items:[],total:1,has_more:!1};const y="/api/messages/conversations?limit="+encodeURIComponent(d)+"&offset="+encodeURIComponent(a)+(p?"&q="+encodeURIComponent(p):"");return window.api(y)},renderItem:function(a){return window.ConversationCard?ConversationCard.html(a):""},emptyText:"暂无消息"})}}),AppWindows.open("messagesEntrance"))}window.MessagesView={open:l,openConversation:i,togglePin:o,confirmDeleteConversation:s,__installed:!0}})();window.WorkView=window.WorkView||function(){if(window.WorkView&&window.WorkView.__installed)return window.WorkView;const e=window.FW_CONTRACTS,t=window.Motion,n="作品无法运行";function i(){return'<div class="xv-loading"><div class="xv-spinner"></div><div>'+escapeHtml(window.StatusTpl.text)+"</div></div>"}const o=window.__fwHistory;function s(){const H={};return H[e.HISTORY_EXTSITE_KEY]=1,H}const l={overlay:null,session:null,onClose:null,escHandler:null,historyPushed:!1,booted:!1,loadingExitCancel:null,currentKey:null,parked:null,bridgeChild:!1};let r=0;function c(){return!!l.overlay}function u(){return r>0}function a(){return!!l.session}window.addEventListener("popstate",function(H){const te=H;setTimeout(function(){if(!(te&&te.__fwPopHandled===e.HISTORY_PV_LAYER)){if(r>0){r--;return}c()&&o.top()===e.HISTORY_EXTSITE_LAYER&&(l.historyPushed=!1,j())}},0)});function d(H,te){if(te>0)return"/api/works/works/"+H.id+"/version/"+te+"/js";if(H.code_url)return H.code_url;if(H.code_url==="")return"";const oe=H.default_version||H.latest_version||0;return oe?"/api/works/works/"+H.id+"/version/"+oe+"/js":""}function p(H,te){const oe=H.caps_suite&&H.caps_suite.url||null;if(!oe)return null;const ve=te>0?te:H.default_version||H.latest_version||0;return ve>0?"/api/caps/"+H.id+"/"+ve+".js?k="+ve:oe}function w(H,te){return fetch((window.apiUrl?window.apiUrl("/api/work-bridge/"):"/api/work-bridge/")+H+"/session",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:te||0})}).then(function(oe){return oe.ok?oe.json():null}).catch(function(){return null})}const y=180,f=501,m=1100,E=4066,S=11508,L=5e3,O=1e4,I=1e3,v=4e3,h=2e4,x=6e4;function T(){const H=l.overlay;if(!H||l.booted)return;l.booted=!0,H.classList.remove("xv-booting");const te=H.querySelector(".xv-loading");te&&(l.loadingExitCancel=t.playExit(te,{cls:"xv-loading-out",timeout:360,done:function(){l.loadingExitCancel=null,te.parentNode&&te.parentNode.removeChild(te)}}))}function _(H){let te=-1,oe=-1;const ve=Date.now(),Se=H._gateToken=(H._gateToken||0)+1;let se=!1;function Ae(){se||(se=!0,window.requestAnimationFrame(function(){se=!1,xe()}))}function xe(){if(Se!==H._gateToken||l.booted||!l.overlay)return;const b=H||{},R=Date.now();if(b.ready){if(oe<0)oe=R;else if(R-oe>=f){T();return}}else oe=-1;if(!b.holding&&b.settled&&b.loaded){if(te<0)te=R;else if(R-te>=y){T();return}}if(b.navigating&&b.appReady){T();return}if(b.loads>=2&&R-b.lastLoadAt>=m){T();return}const D=b.navigating?b.navigatingAt:b.lastLoadAt||ve;if(R-D>(b.navigating?S:E)){T();return}Ae()}Ae();const be=setInterval(function(){if(Se!==H._gateToken||l.booted||!l.overlay){clearInterval(be);return}xe()},500)}function g(H,te,oe){const ve=document.createElement("div");ve.className="work-stage",ve.setAttribute("data-rg-owned","1"),ve.style.cssText="position:absolute;inset:0;overflow:hidden;",ve.setAttribute("data-swipe-ignore","");const Se=document.createElement("iframe");Se.setAttribute("sandbox",window.WorkBridge?window.WorkBridge.SANDBOX_TOKEN:"allow-scripts"),Se.setAttribute("allowfullscreen",""),Se.setAttribute("title",te.ref||"WORKS-"+te.id),Se.style.cssText="position:absolute;inset:0;width:100%;height:100%;border:0;display:block;background:transparent;",ve.appendChild(Se),H.appendChild(ve);const se={def:null,ctx:null,stage:ve,frame:Se,bridge:null,ready:!1,holding:!1,settled:!1,loaded:!1,destroyed:!1,loads:0,lastLoadAt:0,navigating:!1,navigatingAt:0,appReady:!1,panelOpen:!1,panelEl:null,removeStage:()=>{}},Ae="wb-"+Date.now().toString(36)+"-"+Math.random().toString(36).slice(2);Se.id="wb-"+Ae,Se.name=Se.id;const xe=p(te,oe),be=te.view&&te.view.decorator||"";let b=null;function R(){if(!se.destroyed&&(se.navigating=!0,se.navigatingAt=Date.now(),se.ready=!1,se.settled=!1,se.loaded=!1,se.holding=!1,l.booted)){const Q=l.overlay;let de=Q&&Q.querySelector(".xv-loading");if(!de&&Q){const fe=Q.querySelector(".xv-body");fe&&(fe.insertAdjacentHTML("afterbegin",i()),de=fe.querySelector(".xv-loading"))}de&&(l.loadingExitCancel&&(l.loadingExitCancel(),l.loadingExitCancel=null),l.booted=!1,Q.classList.add("xv-booting"),_(se))}}function D(Q){b=window.WorkBridge?window.WorkBridge.createSession({iframe:Se,channel:Ae,workId:te.id,version:oe>0?oe:te.default_version||te.latest_version||0,auth:Q===void 0?null:Q,callbacks:{onReady:function(){se.ready=!0},onHold:function(){se.holding=!0},onSettled:function(){se.settled=!0},onLoaded:function(){se.loaded=!0},onNavigating:R,onAppReady:function(){se.appReady=!0},onAppFailed:function(de){se.destroyed||ie(H,n,String(de||"应用页报告加载失败"))},onUiAction:function(de,fe){de==="open_work_search"?F(se):de==="open_work"?q(se,fe):de==="goto_http_entry"&&W(se)},onError:function(de){se.destroyed||ie(H,n,String(de||""))},onEscape:function(){if(se.panelOpen){M(se);return}ee()},onDestroyed:function(){se.removeStage()}}}):null,se.bridge=b,se.httpEntry=String(Q&&Q.http_entry||""),J()}function J(){se.destroyed||!b||b.postTheme()}se._themePush=J,document.addEventListener&&document.addEventListener("theme-changed",se._themePush);function V(){if(!se.destroyed){if(se.destroyed=!0,se._cbLto){try{se._cbLto.disconnect()}catch{}se._cbLto=null}if(se._cbBeat&&(clearInterval(se._cbBeat),se._cbBeat=null),se._ro){try{se._ro.disconnect()}catch{}se._ro=null}else window.removeEventListener&&se._emitBounds&&window.removeEventListener("resize",se._emitBounds);document.removeEventListener&&se._themePush&&document.removeEventListener("theme-changed",se._themePush),b&&b.destroy(),setTimeout(function(){se.frame&&se.frame.parentNode&&se.frame.parentNode.removeChild(se.frame),se.stage&&se.stage.parentNode&&se.stage.parentNode.removeChild(se.stage)},1500)}}se.removeStage=V;function $(Q){se.destroyed||(l.session===se?ie(H,n,Q):l.parked&&l.parked.session===se&&A())}if(se._cbBlockedTotal=0,typeof PerformanceObserver=="function")try{se._cbLto=new PerformanceObserver(function(Q){if(se.destroyed)return;const de=Q.getEntries();let fe=0;for(let ye=0;ye<de.length;ye++){const we=de[ye];let Ce=we.name==="cross-origin-descendant";const U=we.attribution||[];for(let le=0;Ce===!1&&le<U.length;le++)U[le].containerType==="iframe"&&(U[le].containerId===Se.id||U[le].containerName===Se.name)&&(Ce=!0);Ce&&(fe+=we.duration)}fe<=0||(se._cbBlockedTotal+=fe,(fe>=L||se._cbBlockedTotal>=O)&&$("作品运行占用过高,容器已自动停止其运行以保护页面"))}),se._cbLto.observe({entryTypes:["longtask"]})}catch{}let ne=Date.now();const C=[];se._cbBeat=setInterval(function(){if(se.destroyed)return;const Q=Date.now(),de=Q-ne-I;if(ne=Q,!document.hidden&&!(de<v)){for(C.push(Q);C.length&&Q-C[0]>x;)C.shift();(de>=h||C.length>=2)&&$("页面发生卡顿,容器已停止作品运行以保护页面")}},I);function z(){if(!b||se.destroyed)return;const Q=ve.getBoundingClientRect();b.postBounds(Math.round(Q.width),Math.round(Q.height))}se._emitBounds=z;function Y(Q,de,fe,ye){if(!se.destroyed){if(!window.WorkBridge){ie(H,n,"WorkBridge 运行时未就绪(内联 work-bridge.js 未执行,请重建 frontend)");return}D(fe),Se.srcdoc=window.WorkBridge.bootstrapDocument({channel:Ae,origin:window.location.origin,workId:te.id,workRef:te.ref||"",version:oe||te.default_version||0,capsCode:Q,entryCode:de,viewDoc:ye||""}),window.ResizeObserver?(se._ro=new ResizeObserver(z),se._ro.observe(ve)):window.addEventListener&&window.addEventListener("resize",z),Se.addEventListener("load",function(){se.loads+=1,se.lastLoadAt=Date.now(),se.loads>=2&&!se.navigating&&R(),z(),J()}),z(),_(se)}}const ue=be?"/api/works/works/"+te.id+"/version/"+(oe>0?oe:te.default_version||te.latest_version||0)+"/decorator.js":d(te,oe);if(!ue)return ie(H,n,"该作品没有可装载的入口代码(缺 code_url)"),se;const he=xe?fetch(window.apiUrl?window.apiUrl(xe):xe,{credentials:"include"}).then(function(Q){if(!Q.ok&&oe>0)return null;if(!Q.ok)throw new Error("caps "+Q.status);return Q.text()}):Promise.resolve(null),Ee=be?fetch((window.apiUrl?window.apiUrl("/api/works/works/"):"/api/works/works/")+te.id+"/description-md?v="+(oe>0?oe:te.default_version||te.latest_version||0),{credentials:"include"}).then(function(Q){if(!Q.ok)throw new Error("viewdoc "+Q.status);return Q.json()}).then(function(Q){return Q&&Q.view_source||""}):Promise.resolve("");return Promise.all([he,w(te.id,oe||0),fetch(window.apiUrl?window.apiUrl(ue):ue,{credentials:"include"}).then(function(Q){if(!Q.ok)throw new Error("code "+Q.status);return Q.text()}).then(function(Q){if(!String(Q||"").trim())throw new Error("code empty");return Q}),Ee]).then(function(Q){se.destroyed||Y(Q[0],Q[2],Q[1],Q[3])}).catch(function(Q){window.ResourceGuard&&!l.claimed&&window.ResourceGuard.discardPending();const de=String(Q&&Q.message||Q||"");let fe;de==="code empty"?fe="该作品没有可装载的入口代码(版本行为空)":de.indexOf("code ")===0?fe="入口代码加载失败(HTTP "+de.slice(5)+")":de.indexOf("viewdoc ")===0?fe="装饰器数据源加载失败(HTTP "+de.slice(8)+")":de.indexOf("caps ")===0?fe="能力套件加载失败(HTTP "+de.slice(5)+")":fe="装载失败:"+de,ie(H,n,fe)}),se}function B(H){if(H){if(M(H),H.bridge&&!H.destroyed){H.bridge.destroy(),setTimeout(H.removeStage,200);return}H.removeStage()}}function A(){if(!l.parked)return;const H=l.parked.overlay;l.parked.guard&&window.ResourceGuard&&window.ResourceGuard.end(l.parked.guard),B(l.parked.session),l.parked=null,H.parentNode&&H.parentNode.removeChild(H)}function k(){const H=l.overlay,te=l.onClose,oe=l.currentKey,ve=l.session;l.overlay=null,l.session=null,l.onClose=null,l.currentKey=null,l.escHandler&&(document.removeEventListener("keydown",l.escHandler,!0),l.escHandler=null),A(),H.classList.remove("xv-overlay"),H.classList.add("xv-parked"),window.LayerFrame&&LayerFrame.unlock(H),H.style.cssText="position:fixed; inset:0; transform:translateX(-100000px); pointer-events:none;",H.setAttribute("aria-hidden","true");try{H.inert=!0}catch{}if(l.parked={key:oe,overlay:H,guard:l.guard,session:ve},l.guard=null,typeof te=="function")try{te()}catch{}}function P(H){const te=l.parked;l.parked=null;const oe=te.overlay;l.guard=te.guard||null,oe.classList.remove("xv-parked"),oe.classList.add("xv-overlay"),oe.style.cssText="",oe.removeAttribute("aria-hidden");try{oe.inert=!1}catch{}t.playEnter(oe,{cls:"xv-shell-enter",timeout:450});const ve=window.LayerManager?LayerManager.topZ(oe):0;ve>0&&(oe.style.zIndex=String(ve+1)),window.LayerFrame&&LayerFrame.lock(oe),l.overlay=oe,l.session=te.session||null,l.currentKey=te.key,l.onClose=typeof H.onClose=="function"?H.onClose:null,G();try{history.pushState(s(),""),l.historyPushed=!0,o.push(e.HISTORY_EXTSITE_LAYER)}catch{l.historyPushed=!1}}function j(){if(l.bridgeChild){N(!0),l.parked&&P({});return}N()}function Z(H,te,oe){if(B(oe),typeof te=="function")try{te()}catch{}H.className="xv-teardown";const ve=H.querySelector(".xv-body");ve&&(ve.className="xv-teardown-body"),H.style.cssText="position:fixed;inset:0;transform:translateX(-100000px);pointer-events:none;",H.setAttribute("aria-hidden","true");try{H.inert=!0}catch{}setTimeout(function(){H.parentNode&&H.parentNode.removeChild(H)},1500)}function N(H){const te=l.overlay,oe=l.onClose,ve=l.session;te&&(l.session=null),l.overlay=null,l.onClose=null,l.bridgeChild=!1,l.guard&&window.ResourceGuard&&window.ResourceGuard.end(l.guard),l.guard=null,l.escHandler&&(document.removeEventListener("keydown",l.escHandler,!0),l.escHandler=null),te&&t.playExit(te,{cls:"xv-shell-closing",timeout:400,immediate:H,done:function(){Z(te,oe,ve)}})}function ee(){if(c()){if(M(l.session),l.historyPushed){r=1,l.historyPushed=!1,o.pop(e.HISTORY_EXTSITE_LAYER);try{history.go(-1)}catch{}}j()}}function ie(H,te,oe){B(l.session),l.session=null,H.innerHTML='<div class="xv-error"><div class="xv-error-glyph">!</div><div class="xv-error-title"></div><div class="xv-error-sub"></div><div class="xv-error-hint">点右上角 × 或按 ESC 退出</div></div>',H.querySelector(".xv-error-title").textContent=te,H.querySelector(".xv-error-sub").textContent=oe,T()}function W(H){if(!H||H.destroyed)return;const te=String(H&&H.httpEntry||"").trim();if(!te)return;let oe;try{oe=new URL(te)}catch{return}oe.protocol==="http:"&&window.location.assign(oe.href)}function q(H,te){if(!H||H.destroyed)return;const oe=String(te&&te.ref||"").toUpperCase(),ve=Math.max(0,Math.min(999999,Number(te&&te.version||0)||0));if(!/^WORKS-[0-9]+$/.test(oe))return;const Se=typeof window.apiFn=="function"?window.apiFn:function(){return window.api};typeof Se()=="function"&&lookupRefItem(oe).then(function(se){return se?Se()("/api/works/"+encodeURIComponent(se.id)).then(function(Ae){return Ae&&Ae.item?Ae.item:null}).catch(function(){return null}):null}).catch(function(){return null}).then(function(se){if(!se||H.destroyed)return;if(typeof(window.ViewLaunch&&typeof window.ViewLaunch.pickImageClick=="function"?window.ViewLaunch.pickImageClick(se,"works",{}):void 0)=="function"){WorkView.open({item:se,version:ve,bridgeChild:!0,onClose:function(){if(H.bridge&&H.bridge.postChildClosed)try{H.bridge.postChildClosed()}catch{}}});return}window.ItemCard&&ItemCard.selectedVersions&&ve>0&&ItemCard.selectedVersions.set("works:"+se.id,ve),window.LateGate&&window.LateGate.run&&window.LateGate.run("ItemView",function(xe){xe.open(ve?{itemType:"works",item:se,version:ve}:{itemType:"works",item:se})})})}function F(H){if(!H||H.destroyed||H.panelOpen||!window.AdminPanels||typeof AdminPanels.openWorkSearch!="function"||!window.PlainView)return;const te=H.stage&&H.stage.closest(".xv-body"),oe=te&&typeof AdminPanels.workSearchShouldDock=="function"&&AdminPanels.workSearchShouldDock()?"right":null;H.panelOpen=!0;let ve=!1;const Se=AdminPanels.openWorkSearch({host:oe?te:null,dock:oe,onClose:function(){ve&&H.stage&&(H.stage.style.right="0px"),H.panelOpen=!1,H.panelEl=null}});if(!Se){H.panelOpen=!1;return}if(H.panelEl=Se.body&&Se.body.closest(".pv-overlay")||null,H.panelEl&&H.panelEl.classList.contains("pv-dock-right")&&H.stage){const se=H.panelEl.getBoundingClientRect().width;se>0&&(H.stage.style.right=se+"px",ve=!0)}}function M(H){var oe;if(!H||!H.panelOpen)return;H.panelOpen=!1;const te=H.panelEl||(H.stage?(oe=H.stage.closest(".xv-body"))==null?void 0:oe.querySelector(".pv-overlay"):null);H.panelEl=null,te&&te.isConnected&&window.PlainView&&typeof PlainView.close=="function"&&PlainView.close(te)}function G(){l.escHandler=function(H){if(H.key!=="Escape"||document.querySelector(".ip-overlay, .ms-confirm-overlay.active")||!c())return;const te=l.session;if(te&&te.panelOpen){M(te),H.preventDefault(),H.stopPropagation();return}H.preventDefault(),H.stopPropagation(),ee()},document.addEventListener("keydown",l.escHandler,!0)}function re(H){const te=H.item||null;if(!te)return;const oe=String(te.ref||"WORKS-"+te.id||"").toUpperCase();if(!oe)return;const ve=oe+"@V"+(H.version||0);if(!c()&&l.parked&&l.parked.key===ve){P(H);return}c()&&l.currentKey===ve&&!(l.overlay&&l.overlay.querySelector(".xv-error"))||ce(H)}function ce(H){H=H||{};const te=H.item||null;if(!te)return;const oe=String(te.ref||"WORKS-"+te.id||"").toUpperCase();if(!oe)return;const ve=oe+"@V"+(H.version||0);A();let Se=!1;if(c())if(H.bridgeChild&&l.booted&&a()&&l.currentKey){k();try{history.replaceState(s(),"")}catch{}Se=!0}else{if(l.historyPushed&&history.state&&history.state[e.HISTORY_EXTSITE_KEY]===1){try{history.replaceState(s(),"")}catch{}Se=!0}else if(l.historyPushed){r+=1,l.historyPushed=!1,o.pop(e.HISTORY_EXTSITE_LAYER);try{history.go(-1)}catch{}}N(!0)}const se=document.createElement("div");se.className="xv-overlay xv-booting";const Ae=window.LayerManager?LayerManager.topZ(se):0;Ae>0&&(se.style.zIndex=String(Ae+1)),se.setAttribute("role","dialog"),se.setAttribute("aria-modal","true"),se.innerHTML='<div class="xv-body">'+i()+'</div><div class="xv-controls">'+LayerChrome.controlsHtml({classes:{close:"xv-close"}})+"</div>";const xe=se.querySelector(".xv-body");if(se.querySelector(".xv-close").addEventListener("click",function(){const b=l.session;if(b&&b.panelOpen){M(b);return}ee()}),G(),l.guard=window.ResourceGuard?window.ResourceGuard.begin():null,document.body.appendChild(se),window.LayerFrame&&LayerFrame.lock(se),l.overlay=se,l.onClose=typeof H.onClose=="function"?H.onClose:null,l.currentKey=ve,l.booted=!1,l.bridgeChild=!!H.bridgeChild,!Se)try{history.pushState(s(),""),l.historyPushed=!0,o.push(e.HISTORY_EXTSITE_LAYER)}catch{l.historyPushed=!1}t.playEnter(se,{cls:"xv-shell-enter-fade",timeout:450});const be=p(te,H.version||0);if(be){const b=document.createElement("link");b.rel="prefetch",b.href=be,b.as="script",document.head.appendChild(b)}l.session=g(xe,te,H.version||0)}return{__installed:!0,open:re,close:ee,isOpen:c,isHistoryPopPending:u,dispose:A}}();window.ViewLaunch=function(){function e(i){const o=window;return o[i]?o[i]:o.LateGate&&o.LateGate.ensure?o.LateGate.ensure(i):null}function t(i,o){const s=i.launch;if(!s||typeof s.type!="string")return{handled:!1};switch(s.type){case"runtime":return{handled:!0,click:function(){Interact.launch({wait:function(){return e("WorkView")},open:function(l){l.open({item:i,version:o&&o.version||0})},fail:"作品容器加载失败,请重试"})}};case"external":return s.url?{handled:!0,click:function(){window.open(s.url,"_blank","noopener")}}:{handled:!0};case"chat":return{handled:!0,click:function(){Interact.launch({wait:function(){return e("ChatView")},open:function(l){l.open({friendId:Number(s.peer_id||0),workRef:s.work_ref||""})},fail:"聊天窗口加载失败,请重试"})}};case"list":return{handled:!0,click:function(){Interact.launch({wait:function(){return window.WorklistView||null},open:function(){window.WorklistView.openWorklist(i.id)},fail:"列表加载失败,请重试"})}};case"messages":return{handled:!0,click:function(){Interact.launch({wait:function(){return e("MessagesView")},open:function(l){l.open()},fail:"消息列表加载失败,请重试"})}};case"inline":case"document":return{handled:!0};default:return{handled:!1}}}function n(i,o,s){if(s=s||{},!!i&&o==="works"){const l=t(i,s);if(l.handled)return l.click;const r=i.view;if(!r)return;const c=r.kind;if(c==="link"&&r.url)return function(){window.open(r.url,"_blank","noopener")};if(c==="chatwindow"&&r.source){const u="WORKS-"+i.id;return function(){Interact.launch({wait:function(){return e("ChatView")},open:function(a){a.open({friendId:Number(r.source),workRef:u})},fail:"聊天窗口加载失败,请重试"})}}return c==="worklist"&&r.source?function(){Interact.launch({wait:function(){return window.WorklistView||null},open:function(){window.WorklistView.openWorklist(i.id)},fail:"列表加载失败,请重试"})}:c==="messages"?function(){Interact.launch({wait:function(){return e("MessagesView")},open:function(u){u.open()},fail:"消息列表加载失败,请重试"})}:c==="media"||c==="graph"?void 0:r.decorator?function(){Interact.launch({wait:function(){return e("WorkView")},open:function(u){u.open({item:i,version:s&&s.version||0})},fail:"作品容器加载失败,请重试"})}:c==="code"?function(){Interact.launch({wait:function(){return e("WorkView")},open:function(u){u.open({item:i,version:s&&s.version||0})},fail:"作品容器加载失败,请重试"})}:void 0}}return{pickImageClick:n}}();window.Orchestrator=function(){function e(t,n){if(!t)throw new Error("[Orchestrator] execute called without a plan");if(!t.ok){if(t.message&&n&&typeof n.notify=="function")try{n.notify(t.message,t.level||"error")}catch{}return}if(!n||typeof n!="object")throw new Error("[Orchestrator] execute needs an io object");const i=t.operations||[];for(let o=0;o<i.length;o++){const s=i[o];if(!s||!s.type)continue;const l=n[s.type];if(typeof l!="function"){if(s.optional)continue;throw new Error("[Orchestrator] missing required io."+s.type+" handler for plan operation")}try{l.apply(null,s.args||[])}catch(r){console.error("[Orchestrator] op",s.type,"failed:",r)}}}return{execute:e}}();const Un=60*1e3,$n=64;window.WorkItemCache=window.WorkItemCache||function(){const e=new Map;function t(l,r){const c=Number(r);return!l||!Number.isFinite(c)?null:l+":"+c}function n(l,r){const c=t(l,r);if(!c)return null;const u=e.get(c);return u?Date.now()-u.savedAt>Un?(e.delete(c),null):(e.delete(c),e.set(c,u),u.item):null}function i(l,r){if(!l||l.id==null)return;const c=r||l.item_type||"works",u=t(c,l.id);if(u)for(e.delete(u),e.set(u,{item:l,savedAt:Date.now()});e.size>$n;){const a=e.keys().next();if(a.done)break;e.delete(a.value)}}function o(l,r){const c=t(l,r);c&&e.delete(c)}function s(){e.clear()}return{get:n,put:i,delete:o,clear:s,size:function(){return e.size}}}();window.ItemViewOrchestrator=function(){const e="recordView",t="openView",n="launch";function i(k,P,j,Z){return typeof(window.ViewLaunch&&typeof window.ViewLaunch.pickImageClick=="function"?window.ViewLaunch.pickImageClick(k,P,{version:j||0}):void 0)!="function"?!1:Z?!0:P==="works"&&!k.description}function o(k){if(!k||!k.item||!k.itemType)return{ok:!1,reason:"missing_data"};if(window.ItemCard&&typeof window.ItemCard.isContentType=="function"&&!window.ItemCard.isContentType(k.itemType))return{ok:!1,reason:"unsupported_type",itemType:k.itemType,message:"暂不支持的类型",level:"error"};const P=[{type:e,args:[k.item,k.itemType]},{type:t,args:[k]}],j=()=>window.ViewLaunch&&typeof window.ViewLaunch.pickImageClick=="function"?window.ViewLaunch.pickImageClick(k.item,k.itemType,{version:k.version||0}):void 0;if(i(k.item,k.itemType,k.version||0,!!k.directPlay))return{ok:!0,operations:[{type:e,args:[k.item,k.itemType]},{type:n,args:[j()]}]};if(k.autoPlay){const Z=j();if(typeof Z=="function")return{ok:!0,operations:[{type:e,args:[k.item,k.itemType]},{type:n,args:[Z]}]}}return{ok:!0,operations:P}}function s(k,P){return window.Orchestrator.execute(k,P)}function l(k,P){if(P=P||{},!k)return!1;const j=window.ItemCard&&typeof ItemCard.normalizeType=="function"?ItemCard.normalizeType(k.item_type||P.itemType||"works"):k.item_type||P.itemType||"works";a(k,j);const Z=Number(P.version)||0;if(Z>0&&window.ItemCard&&ItemCard.selectedVersions)try{ItemCard.selectedVersions.set(j+":"+String(k.id),Z)}catch{}const N=P.notify||function(ie){window.StatusNotify&&typeof StatusNotify.error=="function"&&StatusNotify.error(ie)},ee=o({item:k,itemType:j,viewer:P.viewer||(window.currentUser?window.currentUser():null),hideUnapprovedImage:P.hideUnapprovedImage!==void 0?P.hideUnapprovedImage:!!(window.ItemCard&&ItemCard.shouldHideUnapprovedImage&&ItemCard.shouldHideUnapprovedImage(k,P.viewer)),autoPlay:!!P.autoPlay,directPlay:!!P.directPlay,version:Z,openVersions:!!P.openVersions});return s(ee,g({notify:N})),!0}async function r(k,P,j){j=j||{};const Z=String(k||"").trim().toUpperCase();if(!/^WORKS-[0-9]+$/.test(Z))return!1;const N=j.notify||function(G){window.StatusNotify&&typeof StatusNotify.error=="function"&&StatusNotify.error(G)};if(!window.api||!window.ItemCard)return N("作品打开失败,请重试"),!1;let ee=null;const ie=await lookupRefItem(Z).catch(()=>null);if(ee=ie&&ie.item_type||null,!ee)return N("作品不存在或不可见"),!1;let W=null;try{W=await d(ee,Number(Z.slice(6)))}catch{W=null}if(!W)return N("作品不存在或不可见"),!1;let q=Number(P)||0;const F=q,M=Number(W.latest_version)||0;return q===0&&(q=Number(W.default_version)||M),q<1||M>=1&&q>M?(N(Z+"_V"+F+":版本不存在"+(M>=1?"(最新 V"+M+")":"")),!1):l(W,Object.assign({},j,{itemType:ee,version:q}))}const c=Object.create(null);function u(k,P){return window.WorkItemCache?window.WorkItemCache.get(k,P):null}function a(k,P){window.WorkItemCache&&window.WorkItemCache.put(k,P)}function d(k,P){const j=k+":"+P,Z=c[j];if(Z)return Z;const N=async function(){const ee=ItemCard.apiResourceOf(k),ie=await window.api("/api/"+ee+"/"+P),W=ie&&ie.item?ie.item:null;return W&&a(W,k),W}();return c[j]=N,N.catch(function(){}).then(function(){delete c[j]}),N}function p(k,P){if(k&&typeof k.notify=="function"){k.notify(P);return}window.StatusNotify&&typeof StatusNotify.error=="function"&&StatusNotify.error(P)}async function w(k,P,j){j=j||{};const Z=Number(P);if(!Number.isFinite(Z)||!window.api||!window.ItemCard)return p(j,"作品打开失败,请重试"),!1;const N=u(k,Z);if(N)return l(N,Object.assign({},j,{itemType:k}));const ee=I(k,Z);if(ee)return l(ee,Object.assign({},j,{itemType:k}));const ie=L,W={key:k+":"+Z,shell:null};L=W,W.shell=E({item:{name:j.title||""},itemType:k},W),O(),ie&&h(ie.shell);const q=function(F){return h(W.shell),p(j,F),!1};try{const F=await d(k,Z);if(L!==W||(L=null,W.shell&&!W.shell.alive))return!1;if(!F)return q("作品不存在或已隐藏");const M=i(F,k,Number(j.version)||0,!!j.directPlay);M&&(h(W.shell),await x());const G=l(F,Object.assign({},j,{itemType:k}));return M||h(W.shell),G}catch(F){return L!==W?!1:(L=null,q(F&&F.message||"作品打开失败,请重试"))}}function y(k,P){const j=Number(P);if(!Number.isFinite(j)||!window.api||!window.ItemCard)return Promise.resolve(null);const Z=u(k,j);return Z?Promise.resolve(Z):d(k,j).catch(function(){return null})}let f=null;function m(k){return k&&k.item&&k.item.name||""}function E(k,P){if(!A()||!window.AppWindows||typeof AppWindows.open!="function"||!window.StatusTpl)return null;try{const j={item:k.item};P&&(j.waitToken=P);const Z=AppWindows.open("itemDetailShell",j);if(Z&&Z.body)return{body:Z.body,overlay:Z.body.closest&&Z.body.closest(".pv-overlay")||null,alive:!0}}catch{}return null}function S(k,P){k.shell=E(P)}let L=null;function O(){const k=f;k&&(f=null,h(k.shell))}function I(k,P){const j=f,Z=j&&j.ctx&&j.ctx.item||null;return!Z||Z.id==null||Number(Z.id)!==P?null:(window.ItemCard&&typeof ItemCard.normalizeType=="function"?ItemCard.normalizeType(Z.item_type||j.ctx.itemType||"works"):Z.item_type||"works")===k?Z:null}function v(k,P){const j=k&&k.overlay&&k.overlay.querySelector?k.overlay.querySelector(".pv-title"):null;j&&(j.textContent=m(P))}function h(k){!k||!k.alive||(k.alive=!1,k.overlay&&window.PlainView&&typeof PlainView.close=="function"&&PlainView.close(k.overlay,{immediate:!0}))}function x(){return new Promise(function(k){var P=!1,j=function(){P||(P=!0,window.removeEventListener("popstate",Z,!0),setTimeout(k,60))},Z=function(){setTimeout(j,30)};window.addEventListener("popstate",Z,{once:!0,capture:!0}),setTimeout(j,600)})}function T(){const k=f;window.LateGate.run("ItemView",function(P){f===k&&(f=null,!(k.shell&&!k.shell.alive)&&(P.open(k.ctx),h(k.shell)))},function(){f===k&&(h(k.shell),f=null,window.StatusNotify&&typeof StatusNotify.error=="function"&&StatusNotify.error("详情加载失败,请重试"))})}function _(k){const P=L;if(L=null,window.ItemView&&typeof window.ItemView.open=="function"){window.ItemView.open(k),P&&h(P.shell);return}if(f&&f.shell&&f.shell.alive){f.ctx=k,v(f.shell,k),P&&h(P.shell);return}f={ctx:k,shell:null},S(f,k),P&&h(P.shell),T()}function g(k){return k=k||{},{recordView:k.recordView||function(P,j){window.ViewCounter&&typeof ViewCounter.record=="function"&&ViewCounter.record(P,j)},openView:k.openView||_,launch:k.launch||function(P){P()},notify:k.notify||function(){}}}var B={title:function(k){return m(k)},mode:"layer",render:function(k){k.innerHTML=window.StatusTpl.loading()},onClose:function(k){const P=k&&k.waitToken;if(P){P.shell&&(P.shell.alive=!1);return}f&&f.shell&&(f.shell.alive=!1)}};function A(){if(!window.AppWindows||typeof window.AppWindows.define!="function")return!1;try{window.AppWindows.define("itemDetailShell",B)}catch{}return!0}return window.AppWindows&&typeof window.AppWindows.define=="function"&&A(),{planOpen:o,execute:s,openItem:l,resolveAndOpen:w,prefetchWork:y,openPinnedWork:r,standardIo:g}}();window.ProfileOrchestrator=function(){const e="openProfile";function t(i){const o=i&&i.userId;return o==null||o===""?{ok:!1,reason:"missing_data"}:{ok:!0,operations:[{type:e,args:[o,i.opts]}]}}function n(i,o){return window.Orchestrator.execute(i,o)}return{planOpen:t,execute:n}}();(function(){if(window.InfiniteScroll&&window.InfiniteScroll.__installed)return;const e=15,t=600;function n(i){const o=i.extractId||function(h){return h&&h.id!=null?String(h.id):null},s=i.mode==="stream",l=i.direction==="up",r={container:i.container,sentinel:null,root:i.root||null,pageSize:i.pageSize||e,initialOffset:Number(i.initialOffset)>0?Number(i.initialOffset):0,offset:Number(i.initialOffset)>0?Number(i.initialOffset):0,loading:!1,hasMore:!0,total:null,streamMode:s,up:l,paused:!1,seenIds:new Set,nodes:new Map,seq:0,observer:null,scrollHandler:null,destroyed:!1,streamAppended:0,fetchPage:i.fetchPage,renderItem:i.renderItem,extractId:o,emptyText:i.emptyText||"暂无数据",errorText:i.errorText||"加载失败",onError:i.onError||function(){},onLoaded:i.onLoaded||function(){},onReset:i.onReset||function(){},initialWindowLoading:!!i.initialWindowLoading,lastRefreshSignature:null};if(i.sentinel)r.sentinel=i.sentinel;else{const h=document.createElement("div");h.className="inf-scroll-sentinel",h.style.minHeight="1px",l?r.container.insertBefore(h,r.container.firstChild):r.container.appendChild(h),r.sentinel=h}r.sentinel.dataset.infScrollSentinel="1",r.sentinel.addEventListener("click",function(h){h.target&&h.target.closest&&h.target.closest("[data-inf-retry]")&&d()});function c(h){const x=document.createElement("template");return x.innerHTML=String(h).trim(),x.content.firstElementChild}function u(){if(s){r.sentinel.innerHTML=!r.hasMore&&r.streamAppended===0?StatusTpl.empty(r.emptyText,"section"):"";return}if(r.up){r.sentinel.innerHTML="";return}r.hasMore?r.sentinel.innerHTML="":r.total!==null&&r.offset>0?r.sentinel.innerHTML=`<div class="inf-scroll-end">共 ${r.total} 条,已加载完毕</div>`:r.sentinel.innerHTML=StatusTpl.empty(r.emptyText,"section")}function a(h){return{isStale:function(){return h!==r.seq||r.destroyed}}}async function d(){if(r.destroyed||r.loading||!r.hasMore)return;r.loading=!0;const h=++r.seq,x=r.offset===0;if(x&&!r.initialWindowLoading){const T=r.root||r.container.closest(".pv-scroll, .cfr-scroll, .app-view"),_=T?T.getBoundingClientRect().bottom:window.innerHeight,g=Math.max(96,_-r.sentinel.getBoundingClientRect().top);r.sentinel.style.setProperty("--status-area-height",g+"px")}(!x||!r.initialWindowLoading)&&(r.sentinel.innerHTML=StatusTpl.loading(null,x?"area":"inline"));try{const T=await r.fetchPage(r.offset,r.pageSize,a(h));if(h!==r.seq||r.destroyed)return;const _=Array.isArray(T)?T:T.items||[],g=[];if(s)for(const A of _)g.push(A);else for(const A of _){const k=r.extractId(A);if(k==null){g.push(A);continue}const P=String(k);r.seenIds.has(P)||(r.seenIds.add(P),g.push(A))}s||(!Array.isArray(T)&&typeof T.total=="number"?r.total=T.total:r.total===null&&(r.total=r.offset+_.length+(_.length>=r.pageSize?1:0)));let B;if(!Array.isArray(T)&&typeof T.has_more=="boolean"?B=T.has_more:B=_.length>=r.pageSize,!s&&r.total!=null&&(r.seenIds.size>=r.total||r.offset+_.length>=r.total)&&(B=!1),_.length>0&&g.length===0&&(B=!1),_.length===0&&(B=!1),s){const A=g.map(k=>String(r.renderItem(k))).join("");A&&r.sentinel.insertAdjacentHTML("beforebegin",A),r.streamAppended+=g.length}else{const A=[],k=[];for(const P of g){const j=r.renderItem(P);if(j instanceof Element)A.push(j),k.push(j.outerHTML);else if(j instanceof DocumentFragment)A.push(j),k.push("");else{const Z=String(j);k.push(Z),A.push(c(Z))}}if(l){const P=r.root||document.scrollingElement,j=P?P.scrollTop:0,Z=P?P.scrollHeight:0,N=r.sentinel.nextSibling;for(const ee of A)ee&&r.container.insertBefore(ee,N);P&&P.scrollHeight!==Z&&(P.scrollTop=j+(P.scrollHeight-Z))}else for(const P of A)P&&r.sentinel.insertAdjacentElement("beforebegin",P);for(let P=0;P<g.length;P++){const j=r.extractId(g[P]);j==null||!(A[P]instanceof Element)||r.nodes.set(String(j),{el:A[P],html:k[P]})}}!Array.isArray(T)&&typeof T.next_offset=="number"?r.offset=T.next_offset:r.offset+=_.length,r.hasMore=B,u(),r.initialWindowLoading=!1,r.onLoaded({offset:r.offset,total:r.total,hasMore:B,appended:g.length})}catch(T){if(h!==r.seq)return;r.initialWindowLoading=!1;const _=Number(T&&T.status||0),g=_===401||_===403,B=T&&T.message||r.errorText;r.sentinel.innerHTML=StatusTpl.error(g?B:B+"(点按重试)",r.offset===0?"area":"inline");const A=r.sentinel.firstElementChild;A&&!g&&(A.setAttribute("data-inf-retry","1"),A.setAttribute("role","button"),A.setAttribute("tabindex","0"),A.setAttribute("aria-label","加载失败,点击或按 Enter 重试"),A.addEventListener("keydown",k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d())})),r.onError(T)}finally{h===r.seq&&(r.loading=!1)}}if(typeof IntersectionObserver<"u"){const h={rootMargin:"600px 0px"};r.root&&(h.root=r.root),r.observer=new IntersectionObserver(x=>{for(const T of x)T.isIntersecting&&d()},h),r.observer.observe(r.sentinel)}else L(!0);function p(h){if(r.destroyed)return!1;const x=String(h),T=r.nodes.get(x);return T?(T.el.remove(),r.nodes.delete(x),r.seenIds.delete(x),r.offset>0&&(r.offset-=1),r.total!=null&&(r.total=Math.max(0,r.total-1)),u(),!0):!1}function w(h,x){if(r.destroyed)return!1;const T=String(h),_=r.nodes.get(T);if(!_)return!1;const g=r.renderItem(x),B=g instanceof Element?g.outerHTML:String(g);if(B===_.html)return!0;const A=g instanceof Element?g:c(B);return A?(_.el.replaceWith(A),r.nodes.set(T,{el:A,html:B}),!0):!1}function y(h){if(r.destroyed||s)return!1;const x=r.extractId(h);if(x==null)return!1;const T=String(x);if(r.seenIds.has(T))return!1;const _=r.renderItem(h),g=_ instanceof Element?_:c(String(_));return g?(r.sentinel.insertAdjacentElement("beforebegin",g),r.seenIds.add(T),r.nodes.set(T,{el:g,html:g.outerHTML}),r.offset+=1,r.total!=null&&(r.total+=1),u(),!0):!1}async function f(h,x){if(r.destroyed||r.loading||s||l)return;if(h===void 0&&r.offset===0&&r.nodes.size===0){r.hasMore=!0,await d();return}r.seq++,r.loading=!0;const T=r.seq;try{const _=Math.max(r.offset,r.pageSize),g=h===void 0?await r.fetchPage(0,_,a(T)):h;if(T!==r.seq||r.destroyed)return;const B=Array.isArray(g)?g:g.items||[];if(x!=null&&x===r.lastRefreshSignature){r.offset=B.length,!Array.isArray(g)&&typeof g.total=="number"&&(r.total=g.total),r.loading=!1;return}x!=null&&(r.lastRefreshSignature=x),m(B),r.offset=B.length,!Array.isArray(g)&&typeof g.total=="number"&&(r.total=g.total);let A;!Array.isArray(g)&&typeof g.has_more=="boolean"?A=g.has_more:A=B.length>=_,r.total!=null&&r.offset>=r.total&&(A=!1),r.hasMore=A,u(),r.onLoaded({offset:r.offset,total:r.total,hasMore:A,appended:0})}catch(_){if(T!==r.seq)return;r.onError(_)}finally{T===r.seq&&(r.loading=!1)}}function m(h){const x=[],T=new Map;for(const P of h){const j=r.extractId(P);if(j==null)continue;const Z=String(j);x.push(Z),T.set(Z,P)}const _=new Set(x);for(const[P,j]of Array.from(r.nodes))_.has(P)||(j.el.remove(),r.nodes.delete(P));const g=new Set,B=[];for(const P of x){const j=r.renderItem(T.get(P)),Z=j instanceof Element?j.outerHTML:String(j);let N=r.nodes.get(P);if(!(N&&N.html===Z)){const ee=c(Z);if(!ee)continue;N&&N.el.remove(),N={el:ee,html:Z},r.nodes.set(P,N)}g.add(N.el),B.push(N.el)}Array.from(r.container.children).forEach(P=>{P!==r.sentinel&&!g.has(P)&&P.remove()});const A=Array.from(r.container.children).filter(P=>P!==r.sentinel);let k=A.length===B.length;if(k){for(let P=0;P<B.length;P++)if(A[P]!==B[P]){k=!1;break}}if(!k)for(const P of B)r.container.insertBefore(P,r.sentinel);r.seenIds=_}function E(){r.seq++,r.offset=r.initialOffset||0,r.hasMore=!0,r.loading=!1,r.total=null,r.lastRefreshSignature=null,r.streamAppended=0,r.seenIds=new Set,r.nodes=new Map;const h=r.sentinel;for(;r.container.firstChild;)r.container.removeChild(r.container.firstChild);return l?r.container.insertBefore(h,r.container.firstChild):r.container.appendChild(h),h.innerHTML="",r.onReset(),d()}function S(){r.destroyed=!0,r.observer&&r.observer.disconnect(),r.scrollHandler&&((r.root||window).removeEventListener("scroll",r.scrollHandler),r.scrollHandler=null)}function L(h){if(r.scrollHandler){h&&r.scrollHandler();return}r.scrollHandler=()=>{if(r.destroyed||r.paused)return;const T=r.root;if(T){const _=r.sentinel.getBoundingClientRect(),g=T.getBoundingClientRect();l?g.top-_.top<t&&d():_.top-g.bottom<t&&d()}else{const _=r.sentinel.getBoundingClientRect();l?_.top<t&&d():_.top-window.innerHeight<t&&d()}},(r.root||window).addEventListener("scroll",r.scrollHandler,{passive:!0}),h&&r.scrollHandler()}function O(){r.destroyed||r.paused||(r.paused=!0,r.observer&&r.observer.disconnect(),r.scrollHandler&&(r.root||window).removeEventListener("scroll",r.scrollHandler))}function I(){if(!r.destroyed&&r.paused)if(r.paused=!1,r.observer){const h={rootMargin:"600px 0px"};r.root&&(h.root=r.root),r.observer=new IntersectionObserver(x=>{for(const T of x)T.isIntersecting&&d()},h),r.sentinel&&r.observer.observe(r.sentinel)}else typeof IntersectionObserver>"u"&&(r.scrollHandler?(r.root||window).addEventListener("scroll",r.scrollHandler,{passive:!0}):L(!1))}const v={loadNext:d,reset:E,destroy:S,pause:O,resume:I,removeItem:p,updateItem:w,appendItem:y,refreshSilent:f,get total(){return r.total},get offset(){return r.offset},get hasMore(){return r.hasMore},get loading(){return r.loading},get isEmpty(){return r.nodes.size===0&&r.offset===(r.initialOffset||0)}};return i.initial!==!1&&d(),v}window.InfiniteScroll={__installed:!0,bind:n}})();window.ListView=function(){const t=[];let n=!1;function i(){n||(n=!0,document.addEventListener("visibilitychange",()=>{if(document.hidden)return;const s=Date.now();t.forEach(l=>{try{if(!l.isMounted()||s-l.lastFetchAt<6e4||!l.isExposed())return;l.reload()}catch{}})}))}function o(s){const{name:l,container:r,pageSize:c=15,fetchPage:u,renderItem:a,extractId:d,emptyText:p="暂无数据",searchInput:w=null,searchBindEvents:y=!0,debounceMs:f=350,loadingEl:m=null,initialWindowLoading:E=!1,onInitialLoading:S=null,emptyHintEl:L=null,viewRoot:O=null,inShell:I=!1,pollInterval:v=0,computeSignature:h=null,isExposed:x=null,onCardClick:T=null,onLoadError:_=null,onEmpty:g=null,onLoaded:B=null,onMount:A=null,onActivate:k=null,onDeactivate:P=null,onWarmup:j=null,actions:Z={}}=s;let N=null,ee=!1,ie=null,W=null,q="",F="",M=null,G=!1,re=[],ce=!1;const H={name:l,lastFetchAt:0,isMounted:()=>G,isExposed:x||(()=>I&&window.AppShell?window.AppShell.activeView===l:!!(r&&document.contains(r))),reload:oe};t.push(H),i();function te(){return w?(w.value||"").trim():""}function oe(){if(F=te(),N&&typeof N.refreshSilent=="function")return N.refreshSilent();!N&&window.InfiniteScroll&&D()}function ve(Q){if(!(!G&&!N)&&!(Date.now()-H.lastFetchAt<Math.max(0,Q||0)))return oe()}function Se(){F=te(),re=[],ce=!1,N&&typeof N.reset=="function"?N.reset():!N&&window.InfiniteScroll&&D()}function se(Q){if(re=re.filter(de=>String(d(de))!==String(Q)),!N||typeof N.removeItem!="function"||!N.removeItem(Q)){oe();return}N.isEmpty&&R(!0)}function Ae(Q,de){const fe=re.findIndex(ye=>String(d(ye))===String(Q));fe>=0&&(re[fe]=de),(!N||typeof N.updateItem!="function"||!N.updateItem(Q,de))&&oe()}function xe(){M&&(clearTimeout(M),M=null),Se()}function be(){M&&clearTimeout(M),M=setTimeout(()=>{M=null,Se()},f)}function b(){!w||!y||w.__listViewBound||(w.__listViewBound=!0,w.addEventListener("input",be),w.addEventListener("keydown",Q=>{Q.key==="Enter"&&(Q.preventDefault(),xe())}))}function R(Q){L&&(L.hidden=!Q),Q&&g&&g()}function D(){if(ee||!r||!window.InfiniteScroll||!u)return;const Q=async(fe,ye,we)=>{const Ce=await u(fe,ye,F,we);if(H.lastFetchAt=Date.now(),we&&typeof we.isStale=="function"&&we.isStale())return Ce;const U=Ce&&Ce.items||[];if(fe===0&&(re=[]),re=re.concat(U),U.length&&(ce=!0),h&&fe===0){const le=h(U);le!==q&&(q=le)}return Ce};N=window.InfiniteScroll.bind({container:r,root:O,pageSize:c,extractId:d,fetchPage:Q,renderItem:a,emptyText:p,initialWindowLoading:E,onLoaded:({total:fe,offset:ye,appended:we})=>{m&&(m.hidden=!0),typeof S=="function"&&S(!1),R(fe!=null&&ye===0&&fe===0),r&&r.removeAttribute("aria-busy"),typeof B=="function"&&B({total:fe,offset:ye,appended:we})},onError:fe=>{m&&(m.hidden=!0),typeof S=="function"&&!ce&&S(!0,fe),_&&_(fe)}}),ee=!0;let de=!1;if(x)try{de=!!x()}catch{}else I&&window.AppShell&&(de=window.AppShell.activeView===l);I&&!de&&typeof N.pause=="function"&&N.pause()}function J(){if(N)try{typeof N.pause=="function"?N.pause():typeof N.destroy=="function"&&N.destroy()}catch{}}function V(){if(N)try{typeof N.resume=="function"?N.resume():typeof N.reset=="function"&&N.reset()}catch{}}function $(){!r||!T||r.__listViewClickBound||(r.__listViewClickBound=!0,r.addEventListener("click",Q=>{if(Q.target.closest&&Q.target.closest(".item-menu-trigger, .item-admin-actions"))return;const de=Q.target.closest&&Q.target.closest(".item-card");if(!de||!r.contains(de))return;const fe=de.getAttribute("data-item-type")||"works",ye=de.getAttribute("data-item-id");let we=null;if(ye!=null){const Ce=Number(ye);Number.isFinite(Ce)&&(we=re.find(U=>U&&(U.item_type||"works")===fe&&Number(U.id)===Ce)||null)}we?T(we,Q):window.ItemViewOrchestrator&&typeof window.ItemViewOrchestrator.resolveAndOpen=="function"&&window.ItemViewOrchestrator.resolveAndOpen(fe,ye,{notify:function(Ce){window.StatusNotify&&StatusNotify.error(Ce)}})}))}function ne(){if(!(!v||!h)){if(C(),typeof AdaptivePoller<"u")try{W=new AdaptivePoller({onPoll:async()=>{if(document.hidden)return{items:[]};const Q=F,de=N?Math.max(N.offset||0,c):c,fe=await u(0,de,Q);return H.lastFetchAt=Date.now(),Q!==F?{items:[]}:fe},onMessage:Q=>{re=Q.slice(),Q.length&&(ce=!0);const de=h(Q);if(de!==q){if(N&&N.loading)return;q=de,N&&typeof N.refreshSilent=="function"?N.refreshSilent({items:Q,total:Q.length,has_more:!1},de):oe()}}}),W.start();return}catch(Q){console.debug("[ListView] AdaptivePoller failed, fallback to fixed interval:",Q)}ie=setInterval(async()=>{if(!document.hidden)try{const Q=F,de=N?Math.max(N.offset||0,c):c,fe=await u(0,de,Q);if(H.lastFetchAt=Date.now(),Q!==F)return;const ye=fe&&fe.items||[];re=ye.slice(),ye.length&&(ce=!0);const we=h(ye);if(we!==q){if(N&&N.loading)return;q=we,N&&typeof N.refreshSilent=="function"?N.refreshSilent(fe,we):oe()}}catch{}},v)}}function C(){W&&(W.stop(),W=null),ie&&(clearInterval(ie),ie=null)}function z(){if(G){V();return}G=!0,b(),D(),$(),A&&A()}function Y(){V(),ne(),k&&k()}function ue(){J(),C(),P&&P()}function he(){b(),D(),j&&j()}const Ee={name:l,actions:Z,reload:oe,reloadIfStale:ve,resetForQuery:Se,removeItem:se,updateItem:Ae,pause:J,resume:V,destroy:function(){C();const Q=t.indexOf(H);Q>=0&&t.splice(Q,1),N&&typeof N.destroy=="function"&&N.destroy(),N=null,ee=!1,G=!1},get scroller(){return N},get mounted(){return G},get lastFetchAt(){return H.lastFetchAt},get query(){return F},getItems:()=>re.slice()};if(I&&window.AppShell&&window.AppShell.registerView){const Q={name:l,actions:Z,mount:z,activate:Y,deactivate:ue,warmup:he};window.AppShell.registerView(l,Q),window.onDomReady(z)}else{let Q=function(){z(),Y()};window.onDomReady(Q),Z&&Object.keys(Z).length&&Object.assign(window,Z)}return Ee}return{bind:o,_boundViews:t}}();window.WorkListWindow=function(){function e(){injectOwnedStyle("work-list-window",`
1707
+ .wlw{display:flex;flex-direction:column;min-height:0;}
1708
+ .wlw-win{padding:0 10px;}
1709
+ .wlw-search{padding:10px 0 0;}
1710
+ .wlw-search-input{width:100%;box-sizing:border-box;font-family:inherit;appearance:none;-webkit-appearance:none;}
1711
+ .wlw-count{text-align:center;color:var(--text-muted);font-size:0.78rem;padding:4px 0 10px;}`)}const t=()=>window.currentUser();function n(a){const d=document.createElement("button");return d.type="button",d.className="pv-action-icon-btn",d.setAttribute("aria-label","搜索"),d.setAttribute("title","搜索"),d.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="10.8" cy="10.8" r="6.3"></circle><path d="m16 16 5 5"></path></svg>',d.addEventListener("click",function(){a.open()}),d}function i(a){StatusNotify.error(a)}function o(a){const d=window.ItemViewOrchestrator;if(!d||typeof d.openItem!="function"){i("详情组件未加载,请稍候重试");return}d.openItem(a,{notify:i})}function s(a,d){const p=ItemCard.normalizeType(a.item_type),w=ItemCard.resolve(a,{itemType:p,user:t(),allowModeration:!!(d&&d.allowModeration)});return ItemCard.html(a,{itemType:p,cover:!0,showStats:!0,...w})}function l(a){const d=ItemCard.normalizeType(a.item_type);return a&&a.id!=null?d+":"+String(a.id):null}function r(a){return typeof a=="number"&&a>0?"共 "+a+" 件":""}function c(a){e();const d=document.createElement("div");d.className="wlw"+(a.rootClass?" "+a.rootClass:"");let p=a.searchInput||null;if(!p&&a.search!==!1){const E=document.createElement("div");E.className="wlw-search",p=document.createElement("input"),p.type="text",p.className="wlw-search-input",p.placeholder=a.searchPlaceholder||"搜索作品",p.setAttribute("enterkeyhint","search"),p.autocomplete="off",p.autocorrect="off",p.autocapitalize="off",p.spellcheck=!1,E.appendChild(p),d.appendChild(E)}const w=document.createElement("div");w.className="items-grid wlw-grid",d.appendChild(w);const y=document.createElement("div");y.className="wlw-count my-window-subtitle",d.appendChild(y);const f=a.countLabel||r,m=ListView.bind({name:a.name,container:w,pageSize:a.pageSize||15,fetchPage:a.fetchPage,renderItem:a.renderItem||function(E){return s(E,a)},extractId:a.extractId||l,emptyText:a.emptyText||"暂无数据",searchInput:p,debounceMs:a.debounceMs,emptyHintEl:null,initialWindowLoading:!!a.initialWindowLoading,onInitialLoading:a.onInitialLoading||null,viewRoot:a.viewRoot!==void 0?a.viewRoot:null,inShell:!!a.inShell,isExposed:a.isExposed||null,actions:a.actions||{},onCardClick:a.onCardClick||function(E){o(E)},onLoaded:function(E){y.textContent=f(E&&typeof E.total=="number"?E.total:null),typeof a.onLoaded=="function"&&a.onLoaded(E)},onEmpty:function(){y.textContent=f(0),typeof a.onEmpty=="function"&&a.onEmpty()},onLoadError:a.onLoadError||function(E){console.warn("[work-list-window] 加载失败:",E&&E.message||E)}});return{root:d,input:p,grid:w,countEl:y,list:m,reload:function(){return m.reload()},resetForQuery:function(){return m.resetForQuery()},pause:function(){m.pause()},resume:function(){m.resume()},destroy:function(){m.destroy(),d.innerHTML=""},getItems:function(){return m.getItems()}}}function u(a){const d={list:null,uid:void 0,ps:null,searchBtn:null};function p(){d.ps||!window.PullSearch||(d.ps=PullSearch.bind({placeholder:a.list&&a.list.searchPlaceholder||"搜索作品"}),d.searchBtn=n(d.ps))}return AppWindows.define(a.id,{title:a.title,mode:a.mode||"window",actions:function(){return a.list&&a.list.search==="pull"&&p(),d.searchBtn?[d.searchBtn]:[]},fill:!0,onClose:function(){d.list&&d.list.pause(),typeof a.onClose=="function"&&a.onClose()},render:function(w){if(d.list){const f=w.querySelector(".lf-status");f&&f.remove()}else{const f={...a.list};f.rootClass=(f.rootClass?f.rootClass+" ":"")+"wlw-win",a.list&&a.list.search==="pull"&&(p(),d.ps&&(f.searchInput=d.ps.input));const m=f.onInitialLoading;f.initialWindowLoading=!0,f.onInitialLoading=function(E,S){const L=w.querySelector(".lf-status");L&&L.remove(),typeof m=="function"&&m(E,S)},d.list=c(f),typeof a.onCreate=="function"&&a.onCreate(d.list)}w.appendChild(d.list.root);const y=typeof a.identity=="function"?a.identity():null;d.uid!==void 0&&y!==null&&y!==d.uid&&d.list.reload(),d.uid=y,d.list.resume()}}),{open:function(){return AppWindows.open(a.id)},list:function(){return d.list},destroy:function(){d.list&&(d.list.destroy(),d.list=null),d.ps&&(d.ps.destroy(),d.ps=null),d.searchBtn=null,d.uid=void 0}}}return{createList:c,defineWindow:u}}();(function(){if(window.LateGate&&window.LateGate.__installed)return;function e(){return window}function t(i){return Promise.resolve(e()[i]||null)}function n(i){if(typeof i=="function"){i();return}StatusNotify.error(i)}window.LateGate={__installed:!0,ensure:t,run:function(i,o,s){return window[i]?(o(window[i]),!0):window.__fwWhenLate?(window.__fwWhenLate(function(){window[i]?o(window[i]):n(s||"功能加载失败,请刷新页面重试")}),!1):(n(s||"功能加载失败,请刷新页面重试"),!1)}}})();(function(){const e=`
1712
+ .giv-chip{font-size:12px;line-height:14px;height:22px;min-height:0;max-height:22px;background:var(--neu-bg);color:var(--text-1);border:0;border-radius:999px;padding:4px 12px;margin:0;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;vertical-align:middle;font-family:inherit;font-weight:400;transform:none;}
1713
+ .giv-chip.giv-script-link{background:var(--neu-bg);color:#3182ce;padding:4px 12px;text-decoration:none;cursor:pointer;appearance:none;-webkit-appearance:none;}
1714
+ .giv-chip.giv-script-link:active{color:var(--primary);transform:none;}
1715
+ .item-card .giv-chip{font-size:.68rem;line-height:1.2;height:18px;min-height:0;max-height:18px;padding:1px 6px;border-radius:999px;}
1716
+ .item-card .giv-chip.giv-script-link{height:18px;min-height:0;max-height:18px;padding:1px 6px;background:var(--neu-bg);color:#3182ce;}
1717
+ .giv-chip.giv-system-label{color:#fff;font-weight:600;}
1718
+ /* kind 徽章背景色原派生自 WorkKinds 注册表 color 位(app/services/kinds.py),
1719
+ 注册表已随 kind 清退 / work-kinds.js 删除退役(2026-10-08,恒空无派生)。
1720
+ 下面一行是派生标签(类目)的颜色,不是 kind,保留静态。 */
1721
+ .giv-chip.giv-system-label.kind-category{background:#718096;}
1722
+ `;function t(){typeof document>"u"||injectOwnedStyle("chip-renderer",e)}const n=window.escapeHtml;function i(d){if(!d||typeof d!="object")return"";const p=[];for(const w of Object.keys(d)){const y=d[w];y==null||y===!1||p.push(y===""||y===!0?" "+w:" "+w+'="'+n(y)+'"')}return p.join("")}function o(d){if(!d||!d.text)return"";const p=d.tag||"span",w=!!d.action||p==="a"||p==="button",y=["giv-chip"];w&&y.push("giv-script-link"),d.className&&y.push(d.className);const f=i(d.attrs),m=y.filter(Boolean).join(" ");return p==="a"?'<a class="'+m+'"'+f+">"+n(d.text)+"</a>":p==="button"?'<button type="button" class="'+m+'"'+f+">"+n(d.text)+"</button>":'<span class="'+m+'"'+f+">"+n(d.text)+"</span>"}function s(d){if(!d||!d.length)return"";let p="";for(const w of d){const y=o(w);y&&(p+=y)}return p}const l={svg:"SVG",pixel:"像素",icon:"图标",model:"模型",sound_effect:"声效",music:"音乐",voice:"语音"};function r(d,p){return d&&d.kind?d.kind:""}function c(d,p){d=d||{},p=p||{};const w=[],y=new Set,f=(L,O)=>(L=String(L||"").trim(),!L||y.has(L)?!1:(y.add(L),w.push({tag:"span",text:L,className:O||""}),!0));l[d.category]&&f(l[d.category],"giv-system-label kind-category");const m=Number.isInteger(p.userLimit)&&p.userLimit>=0?p.userLimit:1/0;let E=0;const S=String(d.tags||"").split(/[,,]/);for(const L of S){const O=String(L||"").trim();!O||/^fork:/.test(O)||O==="deckdraft"||E>=m||f(O,"")&&(E+=1)}if(Array.isArray(d.system_tags))for(const L of d.system_tags)f(L,"");return w}function u(d,p){p=p||{};const w=p.kind||r(d,p.itemType)||"",y=c(d,{kind:w,itemType:p.itemType});return p.showHiddenChip&&WorkStatus.isNonPublic(d)&&y.push({tag:"span",text:"已隐藏"}),y}const a={render:o,renderChips:s,effectiveKind:r,buildWorkLabelChips:c,buildItemChips:u};typeof window<"u"&&(window.ChipRenderer=a),t()})();window.LayerChrome=window.LayerChrome||function(){const e=window.Motion;if(window.LayerChrome&&window.LayerChrome.__installed)return window.LayerChrome;function t(f){return String(f??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function n(f){f=f||{};const m=f.classes||{};if(!m.bar||!m.back||!m.title||!m.close)throw new Error("LayerChrome.titleBarHtml: classes.{bar,back,title,close} 必填");return'<div class="'+t(m.bar)+' lf-chrome-titlebar"><button type="button" class="'+t(m.back)+' lf-chrome-back" aria-label="'+t(f.backAriaLabel||"返回")+'">‹</button><h3 class="'+t(m.title)+'"></h3>'+(f.actionsHtml||"")+'<button type="button" class="'+t(m.close)+' lf-chrome-close" aria-label="关闭" title="关闭">×</button></div>'}function i(f){f=f||{};const m=f.classes||{};if(!m.close)throw new Error("LayerChrome.controlsHtml: classes.close 必填");return(m.back?'<button type="button" class="'+t(m.back)+'" aria-label="'+t(f.backAriaLabel||"返回")+'">‹</button>':"")+'<button type="button" class="'+t(m.close)+'" aria-label="关闭" title="关闭">×</button>'}const o=.35,s=.4;function l(f){return!!(f&&f.closest&&f.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'))}function r(f,m){let E=f;for(;E&&E!==m&&E!==document.body;){if(E.nodeType===1&&E.scrollWidth>E.clientWidth+1){const S=window.getComputedStyle(E).overflowX;if(S==="auto"||S==="scroll"||S==="overlay")return!0}E=E.parentNode}return!1}function c(f){return!!(f&&f.closest&&f.closest("[data-swipe-ignore]"))}const u=8;function a(f,m,E){const S=window.getSelection?window.getSelection():null;if(!S||S.rangeCount===0||S.isCollapsed)return!1;let L=S.anchorNode;if(!L||(L.nodeType!==1&&(L=L.parentNode),!L||!E.contains(L)))return!1;for(let O=0;O<S.rangeCount;O++){const I=S.getRangeAt(O).getClientRects();for(let v=0;v<I.length;v++){const h=I[v];if(!(h.width<=0&&h.height<=0)&&f>=h.left-u&&f<=h.right+u&&m>=h.top-u&&m<=h.bottom+u)return!0}}return!1}function d(f,m,E){m=m||{};let S=0,L=0,O=!1,I=!1,v=0,h=0,x=0,T=1,_=null;function g(){return typeof m.isActive=="function"?!!m.isActive():!0}function B(F){f.style.transform="translateX("+F+"px)"}const A=E===-1&&typeof m.getFollowEl=="function";function k(){if(!A)return null;try{return m.getFollowEl()||null}catch{return null}}function P(F){O||I||g()&&F.isPrimary&&(F.pointerType==="mouse"&&F.button!==0||l(F.target)||c(F.target)||r(F.target,f)||a(F.clientX,F.clientY,f)||(S=F.clientX,L=F.clientY,v=S,h=Date.now(),x=0,O=!0,_=F.pointerId))}function j(F){if(!O&&!I||F.pointerId!==_)return;if(O&&c(F.target)){O=!1;return}const M=F.clientX-S,G=F.clientY-L;if(!I){if(G>8&&Math.abs(G)>Math.abs(M)){O=!1;return}if(E*M<-8){O=!1;return}if(!(E*M>10&&Math.abs(M)>Math.abs(G)))return;if(a(S,L,f)){O=!1;return}I=!0,O=!1,T=f.clientWidth||window.innerWidth||1,A||(f.style.transition="none",f.style.willChange="transform");try{f.setPointerCapture(F.pointerId)}catch{}if(A&&typeof m.onDragStart=="function")try{m.onDragStart()}catch{}}F.cancelable&&F.preventDefault();const re=E>0?Math.max(0,M):Math.min(0,M),ce=k();A?ce&&(ce.style.transform="translateX("+(T+re)+"px)"):B(re);const H=Date.now(),te=H-h;te>0&&(x=(F.clientX-v)/te),v=F.clientX,h=H}function Z(){if(e.reduced()){f.style.transition="",f.style.transform="";return}f.style.transition="transform var(--motion-dur-med) var(--motion-ease-out)",B(0);const F=function(){f.style.transition="",f.style.transform=""};e.afterTransition(f,{timeout:320},F)}function N(F,M,G){if(e.reduced()){F.style.transition="",F.style.transform=M?"translateX("+M+"px)":"",G&&G();return}F.style.transition="transform var(--motion-dur-med) var(--motion-ease-out)",F.style.transform="translateX("+M+"px)",e.afterTransition(F,{timeout:320},function(){F.style.transition="",M||(F.style.transform=""),G&&G()})}function ee(F){const M=k();if(f.style.willChange="",I=!1,O=!1,_=null,F){if(A){M?N(M,0,function(){typeof m.onCommit=="function"&&m.onCommit(M)}):typeof m.onCommit=="function"&&m.onCommit(null);return}m.snapBackOnCommit&&Z(),typeof m.onCommit=="function"&&m.onCommit(null);return}if(A){M?N(M,T,function(){typeof m.onAbort=="function"&&m.onAbort(M)}):typeof m.onAbort=="function"&&m.onAbort(null);return}Z()}function ie(F){if(F.pointerId!==_)return;if(!I){O=!1,_=null;return}const M=v-S;ee(E*M>T*o||E*x>s)}function W(F){_!==null&&F.pointerId!==_||(I?ee(!1):(O=!1,_=null))}function q(F){I&&F.cancelable&&F.preventDefault()}return f.addEventListener("pointerdown",P),f.addEventListener("pointermove",j,{passive:!1}),f.addEventListener("pointerup",ie),f.addEventListener("pointercancel",W),f.addEventListener("touchmove",q,{passive:!1}),function(){f.removeEventListener("pointerdown",P),f.removeEventListener("pointermove",j),f.removeEventListener("pointerup",ie),f.removeEventListener("pointercancel",W),f.removeEventListener("touchmove",q)}}function p(f,m){return d(f,m,1)}function w(f,m){return d(f,Object.assign({},m,{snapBackOnCommit:!0}),-1)}function y(f,m){f.style.pointerEvents="none",f.style.willChange="transform",f.style.transition="transform var(--motion-dur-slow) var(--motion-ease-out)",f.style.transform="translateX(100%)",e.afterTransition(f,{property:"transform",timeout:340},function(){typeof m=="function"&&m()})}return{__installed:!0,titleBarHtml:n,controlsHtml:i,attachSwipeBack:p,attachSwipeLeft:w,slideOut:y,isHScrollTarget:r}}();(function(){if(window.ViewNavigation&&window.ViewNavigation.__installed)return;var e=[];function t(i){if(i=i||{},!window.PlainView||typeof window.PlainView.open!="function")throw new Error("ViewNavigation requires PlainView");var o={onClose:i.onClose},s={...i,onClose:function(){var r=e.indexOf(o);r>=0&&e.splice(r,1),typeof o.onClose=="function"&&o.onClose()}};e.push(o);try{return window.PlainView.open(s)}catch(r){var l=e.indexOf(o);throw l>=0&&e.splice(l,1),r}}var n={__installed:!0,push:t,open:t,get depth(){return e.length}};Object.defineProperty(n,"depth",{enumerable:!0,configurable:!1}),window.ViewNavigation=n})();(function(){if(window.PlainView&&window.PlainView.__installed)return;var e=window.FW_CONTRACTS,t=window.Motion;const n=window.__fwHistory;function i(){var y={};return y[e.HISTORY_PV_KEY]=1,y}var o=[],s=0,l=0;function r(y){if(l>0){l--,y.__fwPopHandled=e.HISTORY_PV_LAYER;return}if(o.length!==0&&n.top()!==e.HISTORY_STD_MODAL_LAYER&&n.top()!==e.HISTORY_EXTSITE_LAYER&&!(window.WorkView&&typeof window.WorkView.isHistoryPopPending=="function"&&window.WorkView.isHistoryPopPending()))if(y.__fwPopHandled=e.HISTORY_PV_LAYER,s=Math.max(0,s-1),a(o[o.length-1].overlay,{}),o.length>0&&s===0)try{history.pushState(i(),""),s=1}catch{}else o.length===0&&n.pop(e.HISTORY_PV_LAYER)}window.addEventListener("popstate",r);function c(y){for(var f=0;f<o.length;f++)if(o[f].overlay===y)return f;return-1}function u(y){if(y.detachSwipe)try{y.detachSwipe()}catch{}var f=document.activeElement;if(f&&f!==document.body&&y.overlay.contains(f)){var m=f;if(m&&typeof m.blur=="function")try{m.blur()}catch{}}if(typeof y.onClose=="function")try{y.onClose()}catch{}if(window.LayerFrame)try{LayerFrame.unlock(y.overlay)}catch{}y.overlay.parentNode&&y.overlay.parentNode.removeChild(y.overlay),document.removeEventListener("keydown",y.escHandler,!0)}function a(y,f){f=f||{};var m=y?c(y):o.length-1;if(!(m<0)){var E=o.splice(m,1)[0];if(o.length===0&&s>0){l=s,s=0,n.pop(e.HISTORY_PV_LAYER);try{history.go(-l)}catch{}}if(t.reduced()){u(E);return}if(f.immediate){u(E);return}if(f.slide){LayerChrome.slideOut(E.overlay,function(){u(E)});return}t.playExit(E.overlay,{timeout:400,cls:E.exitCls||void 0,done:function(){u(E)}})}}function d(){if(o.length===0){if(s>0){l=s;const y=s;s=0,n.pop(e.HISTORY_PV_LAYER);try{history.go(-y)}catch{}}return}for(;o.length;)a(o[0].overlay,{})}function p(y){y=y||{};var f=o.length===0,m=y.dock==="right",E=y.host&&y.host.nodeType===1?y.host:document.body,S=E!==document.body,L=LayerFrame.cloneFull({title:y.title||"",backAriaLabel:f?"关闭":"返回上一级",actions:y.actions,placeholder:typeof y.fill=="function"}),O=L.overlay;m&&O.classList.add("pv-dock-right"),m||LayerFrame.lock(O,{pad:L.body,top:S?"var(--wv-chrome-top, 0px)":void 0});var I=LayerManager.topZ(O);I>0&&(O.style.zIndex=String(I+1));var v=L.body;t.playEnter(O,{timeout:450,cls:m?"pv-dock-enter":void 0});var h={overlay:O,onClose:typeof y.onClose=="function"?y.onClose:null,escHandler:null,exitCls:m?"pv-dock-exit":null};h.escHandler=function(T){T.key==="Escape"&&(document.querySelector(".ip-overlay, .ms-confirm-overlay.active")||window.WorkView&&window.WorkView.isOpen()||o[o.length-1]===h&&(T.preventDefault(),a(O)))},document.addEventListener("keydown",h.escHandler,!0);var x=O.querySelector(".pv-back");if(x&&x.addEventListener("click",function(){f?d():a(O,{})}),O.querySelector(".pv-close").addEventListener("click",d),O.addEventListener("wheel",function(_){if(!(Math.abs(_.deltaX)<=Math.abs(_.deltaY))){var g=window.LayerChrome&&typeof LayerChrome.isHScrollTarget=="function"&&LayerChrome.isHScrollTarget(_.target,O);g||_.cancelable&&_.preventDefault()}},{passive:!1}),E.appendChild(O),o.push(h),h.detachSwipe=LayerChrome.attachSwipeBack(O,{isActive:function(){return o.length>0&&o[o.length-1].overlay===O},onCommit:function(){a(O,{slide:!0})}}),o.length===1&&s===0)try{history.pushState(i(),""),s=1,n.push(e.HISTORY_PV_LAYER)}catch{}try{O.querySelector(".pv-scroll").focus({preventScroll:!0})}catch{}return typeof y.fill=="function"&&LayerFrame.deferFill(v,y.fill),v}var w={__installed:!0,open:p,close:a,closeAll:d,closeTop:function(){o.length&&a(o[o.length-1].overlay,{})},isOpen:function(){return o.length>0},isHistoryPopPending:function(){return l>0},get depth(){return o.length}};Object.defineProperty(w,"depth",{enumerable:!0,configurable:!1}),window.PlainView=w})();window.ResourceGuard=window.ResourceGuard||function(){var e=[],t=[],n=!1,i={AudioContext:window.AudioContext,webkitAudioContext:window.webkitAudioContext,Audio:window.Audio,play:typeof HTMLMediaElement<"u"?HTMLMediaElement.prototype.play:null};function o(N){function ee(){for(var ie=Function.prototype.bind.apply(N,[null].concat(Array.prototype.slice.call(arguments))),W=new ie,q=0;q<e.length;q++)e[q].ctxs.push(W);return W}return ee.prototype=N.prototype,ee}function s(){if(!n){if(n=!0,i.AudioContext&&(window.AudioContext=o(i.AudioContext)),i.webkitAudioContext&&(window.webkitAudioContext=o(i.webkitAudioContext)),i.Audio){var N=i.Audio,ee=function(){for(var ie=Function.prototype.bind.apply(N,[null].concat(Array.prototype.slice.call(arguments))),W=new ie,q=0;q<e.length;q++)e[q].media.push(W);return W};ee.prototype=N.prototype,window.Audio=ee}i.play&&(HTMLMediaElement.prototype.play=function(){for(var ie=0;ie<e.length;ie++)e[ie].media.push(this);return i.play.apply(this,arguments)})}}function l(){if(n){n=!1;try{window.AudioContext=i.AudioContext}catch{}try{window.webkitAudioContext=i.webkitAudioContext}catch{}try{window.Audio=i.Audio}catch{}if(i.play)try{HTMLMediaElement.prototype.play=i.play}catch{}}}function r(N){var ee;for(ee=0;ee<N.ctxs.length;ee++){var ie=N.ctxs[ee];try{if(ie&&ie.state!=="closed"){try{ie.suspend()}catch{}try{ie.close()}catch{}}}catch{}}for(ee=0;ee<N.media.length;ee++){var W=N.media[ee];try{W.pause()}catch{}try{W.currentTime=0}catch{}try{W.parentNode&&W.parentNode.removeChild(W)}catch{}}N.ctxs=[],N.media=[];var q=e.indexOf(N);q>=0&&e.splice(q,1),e.length===0&&l()}var c=/^(mgMp|mg-loader|mgCurtain|pv-)/;function u(N){if(!(!N||N.tagName!=="CANVAS"))for(var ee=["webgl2","webgl","experimental-webgl"],ie=0;ie<ee.length;ie++){var W=null;try{W=N.getContext(ee[ie])}catch{}if(W){try{var q=W.getExtension("WEBGL_lose_context");q&&q.loseContext()}catch{}return}}}var a=/^(itemcard-kind-colors|chip-renderer-css)$/;function d(N){if(N.nodeType!==1)return!0;var ee=N,ie=ee.tagName;return!!(ie!=="STYLE"&&!(ie==="LINK"&&(ee.rel==="stylesheet"||ee.rel==="preload"))||ee.hasAttribute&&ee.hasAttribute("data-rg-owned")||ee.id&&a.test(ee.id)||ee.hasAttribute&&(ee.hasAttribute("data-mg-css")||ee.hasAttribute("data-mg-lb-css")||ee.hasAttribute("data-mg-v2-css")))}function p(N){if(!(typeof MutationObserver>"u")){N._styleCensus=new window.Set(w());var ee=[],ie=new MutationObserver(function(W){for(var q=0;q<W.length;q++)for(var F=W[q].addedNodes,M=0;M<F.length;M++){var G=F[M];d(G)||ee.push(G)}});ie.observe(document.head||document.documentElement,{childList:!0}),N._headObserver=ie,N._headEscaped=ee}}function w(){for(var N=[],ee=new window.Set,ie=[document.documentElement,document.head,document.body],W=0;W<ie.length;W++)q(ie[W]);return N;function q(F){if(!(!F||ee.has(F))){ee.add(F);for(var M=F.children||[],G=0;G<M.length;G++){var re=M[G];re.nodeType===1&&(d(re)||N.push(re),q(re))}}}}function y(N){N._headObserver&&(N._headObserver.disconnect(),N._headObserver=null);var ee=N._headEscaped;if(ee){for(var ie=0;ie<ee.length;ie++){var W=ee[ie];W.parentNode&&W.parentNode.removeChild(W)}N._headEscaped=null}if(N._styleCensus){for(var q=w(),F=0;F<q.length;F++){var M=q[F];N._styleCensus.has(M)||M.parentNode&&M.parentNode.removeChild(M)}N._styleCensus=null}}var f=["--visual-viewport-height","--keyboard-inset"];function m(){var N=document.body,ee=document.documentElement;return!N||!ee||!N.style||!ee.style?null:{bodyCss:N.style.cssText,bodyClass:N.className,rootCss:ee.style.cssText,rootClass:ee.className,adopted:typeof document=="object"&&document&&"adoptedStyleSheets"in document?Array.prototype.slice.call(document.adoptedStyleSheets||[]):null}}function E(N){for(var ee={},ie=String(N||"").split(";"),W=0;W<ie.length;W++){var q=ie[W],F=q.indexOf(":");if(!(F<0)){var M=q.slice(0,F).trim();M&&(ee[M]=q.slice(F+1).trim())}}return ee}function S(N){for(var ee={},ie=String(N||"").split(/\s+/),W=0;W<ie.length;W++)ie[W]&&(ee[ie[W]]=!0);return ee}function L(N,ee){return Object.prototype.hasOwnProperty.call(N,ee)}function O(N,ee,ie){if(!(!N||!N.style)){for(var W=S(ie),q=String(N.className||"").split(/\s+/),F=[],M=0;M<q.length;M++)q[M]&&W[q[M]]&&F.push(q[M]);N.className=F.join(" ");var G=E(ee),re=E(N.style.cssText),ce,H=!1;for(ce in re)if(L(re,ce)&&(!L(G,ce)||re[ce]!==G[ce])){H=!0;break}if(H){var te="";for(ce in re)L(re,ce)&&L(G,ce)&&(te+=(te?"; ":"")+ce+": "+G[ce]);N.style.cssText=te}}}function I(N){if(!(!N||!document.body||!document.documentElement)){for(var ee={},ie=0;ie<f.length;ie++){var W=f[ie];ee[W]=document.documentElement.style.getPropertyValue(W)}O(document.body,N.bodyCss,N.bodyClass),O(document.documentElement,N.rootCss,N.rootClass);for(var q in ee)ee[q]&&document.documentElement.style.setProperty(q,ee[q]);if(N.adopted)try{document.adoptedStyleSheets=N.adopted}catch{}}}function v(N){if(!(typeof MutationObserver>"u")){N._domCensus=new window.Set(x());var ee=[],ie=new MutationObserver(function(W){for(var q=0;q<W.length;q++)for(var F=W[q].addedNodes,M=0;M<F.length;M++){var G=F[M];G.nodeType===1&&(h(G)||ee.push(G))}});ie.observe(document.body,{childList:!0}),N._domObserver=ie,N._domEscaped=ee}}function h(N){return!!(N.id&&c.test(N.id)||window.LayerManager&&window.LayerManager.matches(N)||N.classList&&N.classList.contains("mg-loader")||N.classList&&(N.classList.contains("mg-shell")||N.classList.contains("pv-overlay")))}function x(){var N=[],ee=document.body;if(!ee||!ee.children)return N;for(var ie=ee.children,W=0;W<ie.length;W++){var q=ie[W];q.nodeType===1&&(h(q)||N.push(q))}return N}function T(N){N._domObserver&&(N._domObserver.disconnect(),N._domObserver=null);var ee=N._domEscaped;if(ee){for(var ie=0;ie<ee.length;ie++){var W=ee[ie];u(W),W.parentNode&&W.parentNode.removeChild(W)}N._domEscaped=null}if(N._domCensus){for(var q=x(),F=0;F<q.length;F++){var M=q[F];N._domCensus.has(M)||(u(M),M.parentNode&&M.parentNode.removeChild(M))}N._domCensus=null}}function _(){var N={ctxs:[],media:[]};return s(),e.push(N),v(N),p(N),N._hostStyle=m(),N}function g(){if(t.length!==0)for(var N=t.splice(0,t.length),ee=0;ee<N.length;ee++)j(N[ee],{restoreHost:!1})}function B(){return g(),_()}function A(){g();var N=_();return t.push(N),N}function k(){return t.pop()||null}function P(){var N=t.pop()||null;return N&&j(N,{restoreHost:!0}),N}function j(N,ee){N&&(ee=ee||{},r(N),T(N),y(N),N._hostStyle&&ee.restoreHost!==!1&&I(N._hostStyle),N._hostStyle=null)}function Z(N){j(N,{restoreHost:!0})}return{begin:B,end:Z,armEarly:A,claimPending:k,discardPending:P}}();(function(){if(window.WorklistView&&window.WorklistView.__installed)return;const e={};function t(i,o){if(!i){console.error("worklist-view: 缺少 workId");return}e[i]||(e[i]=n(i,o||"作品列表")),e[i].open()}function n(i,o){const s="worklist-"+i;return window.WorkListWindow.defineWindow({id:s,title:o,mode:"layer",identity:function(){const l=window.currentUser();return l&&l.id!=null?l.id:null},list:{name:s,pageSize:50,search:"pull",searchPlaceholder:"搜索作品(编号 / 标题)",rootClass:"panel-scope",fetchPage:async function(l,r,c){const u="/api/worklist/"+i+"?offset="+l+"&limit="+r+(c?"&q="+encodeURIComponent(c):""),a=await window.api(u);return a&&Array.isArray(a.items)?a:{items:[],total:0,has_more:!1}},renderItem:function(l){return window.WorkAdminCard.html(l)},emptyText:"这里还没有可展示的作品",countLabel:function(l){return typeof l=="number"&&l>0?"共 "+l+" 件":""}}})}window.WorklistView={openWorklist:t,__installed:!0}})();window.Md=function(){const e=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,t={color:!0,"background-color":!0},n=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d\s,.%]+\s*\)|[a-z]{3,32})$/i,i=/\.(mp4|webm|mov|m4v|ogv)(?:[?#].*)?$/i,o=/\.(mp3|m4a|aac|wav|ogg|oga|flac|opus)(?:[?#].*)?$/i;function s(_){return String(_).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function l(){return{name:"md-highlight",level:"inline",start(_){return _.indexOf("==")},tokenizer(_){const g=/^==(?=\S)([\s\S]*?\S)==/.exec(_);if(g)return{type:"md-highlight",raw:g[0],tokens:this.lexer.inlineTokens(g[1])}},renderer(_){return"<mark>"+this.parser.parseInline(_.tokens)+"</mark>"}}}function r(){return{link(_,g,B){const A=typeof B=="string"?B:"";if(typeof _!="string"||!/^https?:\/\//i.test(_))return A;let k=_;try{k=encodeURI(_).replace(/%25/g,"%")}catch{return A}return'<a href="'+s(k)+'" target="_blank" rel="noopener noreferrer"'+(g?' title="'+s(g)+'"':"")+">"+A+"</a>"},image(_,g,B){const A=typeof B=="string"?B:"",k=typeof _=="string"?_:"",P=k&&k.charAt(0)==="/"?(window.__apiBaseUrl||"")+k:k;if(P&&i.test(P))return'<video class="md-video" controls preload="metadata" src="'+s(P)+'"'+(A?' aria-label="'+s(A)+'"':"")+"></video>";if(P&&o.test(P))return'<audio class="md-audio" controls preload="metadata" src="'+s(P)+'"'+(A?' aria-label="'+s(A)+'"':"")+"></audio>";let j=P;try{j=encodeURI(k)}catch{return A}return j?'<img src="'+s(j)+'" alt="'+s(A)+'"'+(g?' title="'+s(g)+'"':"")+">":A}}}const c={")":"(","】":"【","》":"《","」":"「","』":"『","〉":"〈","〕":"〔","]":"[","}":"{","”":"“","’":"‘"},u={"。":!0,",":!0,"、":!0,";":!0,":":!0,"?":!0,"!":!0,"…":!0,"~":!0};Object.keys(c).forEach(_=>{u[_]=!0});function a(_,g){let B=0;for(let A=0;A<_.length;A++)_.charAt(A)===g&&B++;return B}function d(_){let g=_.length;for(;g>0;){const B=_.charAt(g-1);if(!u[B])break;const A=c[B];if(A){const k=_.slice(0,g-1);if(a(k,A)>a(k,B))break}g--}return _.slice(0,g)}function p(_){const g=String(_.raw||""),B=d(g);if(B.length===g.length)return _;const A=g.slice(B.length);_.raw=B,typeof _.text=="string"&&_.text.endsWith(A)&&(_.text=_.text.slice(0,-A.length)),typeof _.href=="string"&&_.href.endsWith(A)&&(_.href=_.href.slice(0,-A.length));const k=_.tokens&&_.tokens[0];return k&&(typeof k.raw=="string"&&k.raw.endsWith(A)&&(k.raw=k.raw.slice(0,-A.length)),typeof k.text=="string"&&k.text.endsWith(A)&&(k.text=k.text.slice(0,-A.length))),_}function w(){const _=window.marked,g=_&&_.Tokenizer&&_.Tokenizer.prototype.url;return typeof g!="function"?null:{url(B){const A=g.call(this,B);return A&&p(A)}}}let y=null;function f(){if(y)return y;const _=window.marked&&window.marked.Marked;if(!_)throw new Error("marked.Marked unavailable");y=new _({gfm:!0,breaks:!1});const g=w(),B={extensions:[l()],renderer:r()};return g&&(B.tokenizer=g),y.use(B),y}function m(_){return window.marked.Lexer.lex(_==null?"":String(_),Object.assign({},f().defaults))}function E(_){return window.marked.Parser.parse(_,Object.assign({},f().defaults))}function S(_){return f().parse(_==null?"":String(_))}function L(_){const g=window.DOMPurify;if(!g)throw new Error("DOMPurify 未装载(懒 vendor 包未执行)");return g.sanitize(_,{ADD_ATTR:["style"],ALLOWED_URI_REGEXP:e})}function O(_){const g=_.getAttribute("style");if(!g)return;const B=[];g.split(";").forEach(A=>{const k=A.indexOf(":");if(k<0)return;const P=A.slice(0,k).trim().toLowerCase(),j=A.slice(k+1).trim();t[P]&&n.test(j)&&B.push(P+":"+j)}),B.length?_.setAttribute("style",B.join(";")+";"):_.removeAttribute("style")}function I(_){Array.prototype.forEach.call(_.querySelectorAll("pre code.language-json"),g=>{try{const B=JSON.parse(g.textContent);g.textContent=JSON.stringify(B,null,2)}catch{}})}function v(_){Array.prototype.forEach.call(_.querySelectorAll("table"),g=>{const B=g.parentElement;if(!B||B.classList.contains("md-table-wrap")||B.closest("table"))return;const A=document.createElement("div");A.className="md-table-wrap",B.insertBefore(A,g),A.appendChild(g)})}function h(_){I(_),v(_),Array.prototype.forEach.call(_.querySelectorAll("[style]"),O),Array.prototype.forEach.call(_.querySelectorAll("img"),g=>{g.setAttribute("loading","lazy"),g.setAttribute("decoding","async")}),Array.prototype.forEach.call(_.querySelectorAll("a[href]"),g=>{g.setAttribute("target","_blank"),g.setAttribute("rel","noopener noreferrer")}),Array.prototype.forEach.call(_.querySelectorAll("video"),g=>{g.setAttribute("playsinline",""),g.setAttribute("preload","metadata")}),Array.prototype.forEach.call(_.querySelectorAll('input[type="checkbox"]'),g=>{g.disabled=!0})}function x(_){Array.prototype.forEach.call(_.querySelectorAll("img,video,audio"),g=>{const B=g.getAttribute("alt")||g.getAttribute("aria-label")||"";g.replaceWith(document.createTextNode(B))})}function T(_,g){const B=g==null?"":String(g);try{const A=L(S(B)),k=document.createElement("div");for(k.innerHTML=A,x(k),h(k),_.innerHTML="";k.firstChild;)_.appendChild(k.firstChild);_.classList.add("gct-md")}catch{_.textContent=B}}return{parse:S,sanitize:L,lex:m,parseTokens:E,enhance:h,render:T}}();window.AuthCaptcha=window.AuthCaptcha||function(){var e=4e3,t=null,n=null,i=null,o=!1,s="idle";function l(w,y){n&&(n.textContent=w||"",n.classList.toggle("error",!!y),n.style.display=w?"":"none")}function r(w){return new Promise(function(y,f){var m=w.salt,E=w.challenge,S=Number(w.maxnumber)||0,L=0;function O(){for(var I=Math.min(L+e,S);L<I;L++)if(window.sha256&&window.sha256(m+L)===E){y(L);return}if(L>=S){f(new Error(" PoW 求解失败"));return}setTimeout(O,0)}O()})}function c(w,y){return btoa(JSON.stringify({algorithm:w.algorithm,challenge:w.challenge,number:y,salt:w.salt,signature:w.signature}))}function u(){o||!t||(o=!0,s="solving",t.value="",l("人机验证中…"),fetch("/api/auth/captcha-challenge",{cache:"no-store"}).then(function(w){if(!w.ok)throw new Error("挑战获取失败("+w.status+")");return w.json()}).then(function(w){return r(w).then(function(y){return c(w,y)})}).then(function(w){if(!t||!t.isConnected){s="idle";return}t.value=w,s="ready",l("")}).catch(function(){if(t&&!t.isConnected){s="idle";return}s="error",l("人机验证失败,点击重试",!0)}).then(function(){o=!1}))}function a(){var w=document.getElementById("authForm");t=document.getElementById("altchaPayload"),n=document.getElementById("authCaptchaStatus"),!(!w||!t||!n)&&(w!==i&&(i=w,n.style.cursor="pointer",n.addEventListener("click",function(){s==="error"&&u()})),u())}function d(){return t&&t.value||""}function p(w){var y=Date.now()+(w||3e4);return new Promise(function(f,m){(function E(){var S=d();if(s==="ready"&&S){f(S);return}if(s==="error"){m(new Error("人机验证未完成"));return}if(Date.now()>y){m(new Error("人机验证超时"));return}setTimeout(E,100)})()})}return{mount:a,restart:u,whenReady:p,payload:d,state:function(){return s}}}();window.AuthForm=window.AuthForm||function(){function e(t){t=t||{};const n=t.mode||"login",i=["login","register-email","reset-password"].indexOf(n)>=0?n:"login",o=i==="register-email"||i==="reset-password",s=t.next||"/",l=typeof t.onSuccess=="function"?t.onSuccess:function(x){location.href=x},r=document.getElementById("authForm"),c=document.getElementById("authMsg"),u=document.getElementById("submitBtn"),a=document.getElementById("username"),d=document.getElementById("password"),p=document.getElementById("passwordConfirm"),w=document.getElementById("emailAddr"),y=document.getElementById("emailCode"),f=document.getElementById("emailCodeBtn");if(!r||!c||!u||r.__authBound)return;r.__authBound=!0;function m(x,T){c.textContent=x||"",c.classList.toggle("success",T==="success"),c.classList.toggle("error",T==="error")}let E=0,S=null;function L(){S&&(clearInterval(S),S=null),E=0,f&&(f.disabled=!1,f.textContent="获取验证码")}function O(){E=60,f&&(f.disabled=!0),S=setInterval(function(){E-=1,f&&(f.textContent=E>0?`重发(${E}s)`:"获取验证码"),E<=0&&L()},1e3)}async function I(){if(!w||!w.value.trim()){m("请先填写邮箱","error"),w&&w.focus();return}const x=window.AuthCaptcha;let T=x?x.payload():"";if(x&&!T)if(x.state()==="solving"){m("人机验证进行中,请稍候…","error"),f&&(f.disabled=!0);try{T=await x.whenReady()}catch{m("人机验证未完成,请点击状态行重试","error");return}finally{f&&(f.disabled=!1)}if(!r||!r.isConnected)return}else{m("人机验证未完成,请点击状态行重试","error");return}f&&(f.disabled=!0);try{const _=window.apiUrl?window.apiUrl("/api/auth/email-code"):"/api/auth/email-code",g=await fetch(_,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({email:w.value.trim(),purpose:i==="reset-password"?"reset":"register",altcha:T})});let B=null;try{B=await g.json()}catch{throw new Error("服务暂时不可用,请稍后重试")}if(!g.ok||B.status==="error")throw new Error(B.message||B.detail||"验证码发送失败");m("验证码已发送,请查收邮件(含垃圾箱)","success"),O()}catch(_){m(_.message||"验证码发送失败","error"),f&&(f.disabled=!1)}finally{const _=window.AuthCaptcha;_&&typeof _.restart=="function"&&_.restart()}}f&&f.addEventListener("click",function(x){x.preventDefault(),I()});async function v(){let x=!1;const T=a?a.value.trim():"",_=d?d.value:"",g=w?w.value.trim():"",B=y?y.value.trim():"";if(o){if(!g||!B){m("请填写邮箱和验证码","error");return}if(i==="register-email"||i==="reset-password"){if(!_){m("请填写密码","error");return}if(_.length<6){m("密码至少 6 位","error");return}if(p&&p.value!==_){m("两次输入的密码不一致","error"),p.select();return}}}else if(!T||!_){m("请填写用户名和密码","error");return}const A=window.AuthCaptcha;let k=A?A.payload():"";if(A&&!k)if(A.state()==="solving"){m("人机验证进行中,请稍候…","error"),u&&(u.disabled=!0);try{k=await A.whenReady()}catch{m("人机验证未完成,请点击状态行重试","error");return}finally{u&&(u.disabled=!1)}if(!r||!r.isConnected)return}else{m("人机验证未完成,请点击状态行重试","error");return}u.disabled=!0,m("");const P=document.getElementById("authFallback");P&&(P.hidden=!0,P.innerHTML="");let j=!1;try{const Z=i==="register-email"?"register-email":i==="reset-password"?"reset-password":"login",N=window.apiUrl?window.apiUrl(`/api/auth/${Z}`):`/api/auth/${Z}`,ie=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"include",body:JSON.stringify(o?i==="reset-password"?{email:g,code:B,new_password:_,altcha:k}:{email:g,code:B,password:_,altcha:k}:{username:T,password:_,altcha:k})});let W=null;try{W=await ie.json()}catch{throw new Error("服务暂时不可用,请稍后重试")}if(!ie.ok||W.status==="error")throw j=i==="login"&&ie.headers.get("X-Auth-Error-Code")==="invalid_credentials",new Error(W.message||W.detail||"操作失败");if(i==="reset-password"){m("密码重置成功,请使用新密码登录","success"),setTimeout(()=>{window.AuthPanel&&typeof window.AuthPanel.switchMode=="function"&&window.AuthPanel.switchMode("login")},1500);return}W.session_token&&window.MobileShell&&typeof window.MobileShell.setSessionToken=="function"&&window.MobileShell.setSessionToken(W.session_token);const q=ie.headers.get("x-cookie-secure")==="1",F=location.protocol==="https:",M=await fetch(window.apiUrl?window.apiUrl("/api/auth/me"):"/api/auth/me",{cache:"no-store",credentials:"include"}),G=M.ok?await M.json():null,re=M.headers.get("x-cookie-persisted")==="1",ce=W.username||T;if(!M.ok||!G||G.role==="guest"||G.username!==ce){if(q&&!F)throw new Error("登录响应 cookie 被标记为 Secure,但当前是 http://,浏览器拒存。请把 .env 的 COOKIE_SECURE 改为 0 / 留空,或部署 HTTPS 后用 https:// 访问。");const ve=/^https?:$/.test(location.protocol)&&/^[\d.]+$/.test(location.hostname)?" 当前是裸 IP HTTP 站点,如果浏览器还拒带,试试切到 https + 域名访问。":"";throw re?new Error("登录凭证校验失败。请用浏览器开发者工具 -> Network 查看 /api/auth/login 与 /api/auth/me 的 Response 头,如有疑问把内容发给运维。"):new Error("登录成功,但会话校验仍未通过 -- 浏览器没把 session 带回服务端。"+ve)}m(i.indexOf("login")===0?"登录成功,正在跳转...":"注册成功,正在跳转...","success");const H=String(s||"").replace(/\\/g,"/");let te=/^\/(?!\/)/.test(H)?H:"/";if(te==="/")try{const oe=new URL(document.referrer);oe.origin===location.origin&&oe.pathname.indexOf("/login")!==0&&oe.pathname.indexOf("/register")!==0&&(te=oe.pathname+oe.search)}catch{}x=!0,setTimeout(()=>l(te),400)}catch(Z){const ee=Z.message;if(m(ee,"error"),j){const W=document.getElementById("authFallback");W&&(W.hidden=!1,W.innerHTML='忘记密码了?<br><a href="#" data-auth-switch="reset-password">通过邮箱验证码重置</a>')}const ie=window.AuthCaptcha;ie&&typeof ie.restart=="function"&&ie.restart()}finally{!x&&u&&(u.disabled=!1)}}r.addEventListener("submit",function(x){x.preventDefault(),v()});const h=window.AuthCaptcha;h&&typeof h.mount=="function"&&h.mount()}return{init:e}}();window.SkillView=window.SkillView||function(){let e=null;function t(s,l){const r=document.createElement(s);return l&&(r.className=l),r}function n(){e=null}function i(s){e&&(e.body.innerHTML=StatusTpl.error(s))}function o(s){if(s=s||{},s.content==null||!window.PlainView)return;n();const l=t("div","skv-body");l.innerHTML=StatusTpl.loading(),e={body:l},PlainView.open({title:s.name||"技能",onClose:n}).appendChild(l);function r(c){if(!e)return;if(!window.Md||typeof Md.parse!="function"||typeof Md.sanitize!="function")throw new Error("Markdown 引擎未加载");const u=Md.sanitize(Md.parse(c));e.body.innerHTML="";const a=t("div","skv-md");a.innerHTML=u,window.Md&&typeof Md.enhance=="function"&&Md.enhance(a),e.body.appendChild(a)}if(s.content!=null){try{r(String(s.content))}catch(c){const u=c&&typeof c=="object"&&"message"in c?String(c.message):"内容渲染失败";i(u)}return}}return{open:o,__installed:!0}}();(function(e){if(e.workCoGovern)return;function t(a){e.StatusNotify&&typeof StatusNotify.ok=="function"&&StatusNotify.ok(a)}function n(a){StatusNotify.error(a)}function i(a){return"/api/works/"+encodeURIComponent(a.itemType)+"/"+encodeURIComponent(a.id)+"/visible-to"}function o(a){return"/api/works/"+encodeURIComponent(a.itemType)+"/"+encodeURIComponent(a.id)+"/transfer"}var s=[{mode:"view",label:"对方仅可见",css:"btn-view",ok:"已设为对方仅可见",confirm:{text:"对方将能查看该作品(含隐藏作品与代码),但不能编辑或处置。",title:"对方仅可见",confirmText:"仅可见"}},{mode:"govern",label:"治理转让",css:"btn-govern",ok:"已治理转让(作品仍在你名下,双方共同管理)",confirm:{text:"作品仍挂你名下,对方将与你共同管理(可见/读码/编辑/处置)。",title:"治理转让",confirmText:"治理转让"}},{mode:"co-own",label:"代理转让",css:"btn-coown",ok:"已代理转让(作品挂对方名下,双方共同管理)",confirm:{text:"作品将改挂对方名下,你保留共同管理权(可见/读码/编辑/处置)。",title:"代理转让",confirmText:"代理转让"}},{mode:"gift",label:"完全转让",css:"btn-gift",ok:"已完全转让(作品已完全归对方所有)",confirm:{text:"作品将完全归对方所有,你将失去对该作品的全部权限(隐藏作品对你即刻不可见),确定?",title:"完全转让",confirmText:"完全转让",danger:!0}}];function l(a){return a==="view"?"仅可见":"共同管理"}function r(a){const d=escapeHtml(a.username||"");return'<div class="wcg-row"><span class="wcg-name">'+(d?d+" ":"")+'<span class="wcg-ref">U'+escapeHtml(String(a.id))+'</span></span><span class="wcg-mode mode-'+escapeHtml(String(a.level||"govern"))+'">'+escapeHtml(l(a.level))+'</span><button class="wcg-rm" type="button" data-uid="'+escapeHtml(String(a.id))+'">移除</button></div>'}function c(a,d){!a||!a.isConnected||(a.innerHTML=d&&d.length?d.map(r).join(""):'<div class="wcg-row">暂无共同治理授权,作品仅你自己可见</div>')}function u(a,d){const p=a.body.querySelector("[data-role=list]");return e.api(i(d)).then(function(w){return c(p,w&&w.visible_to||[]),w})}AppWindows.define("workCoGovern",{title:"共同治理",mode:"layer",render:function(a,d,p){a.className="wcg-body",a.innerHTML='<div class="wcg-desc">把作品开放给指定用户:对方仅可见(可见/读码)、治理(挂你名下双方共同管理)、代理(挂对方名下双方共同管理)或完全转让(作品归对方,你完全退出)。</div><div class="wcg-list" data-role="list">'+StatusTpl.loading(null,"section")+'</div><div class="wcg-add"><input class="wcg-input" data-role="input" type="text" placeholder="用户名 / U 编号 / 数字 id" /></div><div class="wcg-btns" data-role="btns">'+s.map(function(m){return'<button class="wcg-btn '+m.css+'" type="button" data-mode="'+m.mode+'">'+m.label+"</button>"}).join("")+"</div>";const w=a.querySelector("[data-role=input]"),y=a.querySelector("[data-role=btns]");function f(m){const E=(w.value||"").trim();if(!E){n("请填写用户名或 U 编号");return}if(y.dataset.busy==="1")return;const S=s.find(function(O){return O.mode===m}),L=function(){y.dataset.busy="1",Array.prototype.forEach.call(y.querySelectorAll(".wcg-btn"),function(O){O.disabled=!0}),e.api(o(d),{method:"POST",body:JSON.stringify({username:E,mode:m})}).then(function(O){w.value="",c(p.body.querySelector("[data-role=list]"),O&&O.visible_to||[]),t(O&&O.message||S.ok)}).catch(function(O){n(O&&O.message||S.label+"失败")}).then(function(){y.dataset.busy="0",Array.prototype.forEach.call(y.querySelectorAll(".wcg-btn"),function(O){O.disabled=!1})})};S.confirm&&e.MobileShell&&typeof e.MobileShell.confirm=="function"?e.MobileShell.confirm(S.confirm.text,{title:S.confirm.title,confirmText:S.confirm.confirmText,danger:!!S.confirm.danger}).then(function(O){O&&L()}):L()}return y.addEventListener("click",function(m){const E=m.target.closest&&m.target.closest(".wcg-btn");E&&f(E.getAttribute("data-mode"))}),w.addEventListener("keydown",function(m){m.key==="Enter"&&(m.preventDefault(),f("view"))}),a.addEventListener("click",function(m){const E=m.target.closest&&m.target.closest(".wcg-rm");if(!E||E.disabled)return;const S=E.getAttribute("data-uid");S&&(E.disabled=!0,e.api(i(d),{method:"DELETE",body:JSON.stringify({user:S})}).then(function(L){c(p.body.querySelector("[data-role=list]"),L&&L.visible_to||[]),t("已移除")}).catch(function(L){E.disabled=!1,n(L&&L.message||"移除失败")}))}),u(p,d).catch(function(m){const E=p.body.querySelector("[data-role=list]");E&&E.isConnected&&(E.innerHTML=StatusTpl.error(m&&m.message||"名单加载失败","section")),n(m&&m.message||"名单加载失败")})}}),e.workCoGovern=function(a,d){return AppWindows.open("workCoGovern",{itemType:a,id:d})}})(window);window.ChatFrame=function(){function e(){injectOwnedStyle("chat-frame",`
1723
+ .cfr{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;}
1724
+ .cfr-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;overflow-anchor:auto;touch-action:pan-y;}`)}function t(){e();const n=document.createElement("div");n.className="cfr";const i=document.createElement("div");return i.className="cfr-scroll",n.appendChild(i),{root:n,scrollEl:i,mountBottom:function(o){o&&n.appendChild(o)}}}return{create:t}}();window.InputBar=function(){function e(){injectOwnedStyle("input-bar",`
1725
+ .cib{position:relative;z-index:2;flex:none;display:flex;flex-direction:column;background:var(--neu-bg);border-top:1px solid var(--hairline);}
1726
+ .cib-row{display:flex;gap:8px;padding:12px 12px calc(12px + env(safe-area-inset-bottom, 0px));align-items:flex-end;}
1727
+ .cib-input{flex:1;min-width:0;min-height:44px;max-height:132px;padding:10px 14px;border:1px solid var(--border-soft);border-radius:10px;font-size:16px;line-height:1.4;font-family:inherit;resize:none;outline:none;background:var(--neu-inset);}
1728
+ .cib-input:focus{border-color:#667eea;background:var(--neu-bg);}
1729
+ .cib-guest{flex:1;text-align:center;color:var(--text-3);font-size:14px;padding:10px 0;}
1730
+ .cib-guest a{color:var(--primary);}
1731
+ /* 「+」按钮(作品引用等选择器入口):视觉配方 = emoji 切换按钮 .cep-btn,
1732
+ 尺寸/描边/圆角一致,输入行内成组 */
1733
+ .cib-plus{flex:none;width:44px;height:44px;padding:0;border:1px solid var(--border-soft);border-radius:10px;background:var(--neu-bg);color:#4b5563;font-family:inherit;font-size:26px;line-height:1;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation;}
1734
+ .cib-plus:hover{border-color:#c7d2fe;background:#eef2ff;}
1735
+ .cib-plus:focus-visible{outline:2px solid #667eea;outline-offset:2px;}`)}function t(i){i.style.height="auto",i.style.height=Math.min(i.scrollHeight,132)+"px"}function n(i){i=i||{},e();const o=document.createElement("div");o.className="cib";const s=document.createElement("div");if(s.className="cib-row",o.appendChild(s),i.guestHtml)return s.innerHTML='<div class="cib-guest">'+i.guestHtml+"</div>",{root:o,input:null,focus:function(){},blur:function(){},clear:function(){},setPlus:function(){},destroy:function(){}};const l=i.maxLength>0?i.maxLength:1e3;i.limitMessage;const r=typeof i.onSend=="function"?i.onSend:null,c=typeof i.canSend=="function"?i.canSend:null,u=document.createElement("textarea");u.className="cib-input",u.rows=1,u.maxLength=l,u.placeholder=i.placeholder||"",u.setAttribute("aria-label",i.ariaLabel||"输入内容"),u.autocomplete="off",u.autocorrect="off",u.autocapitalize="off",u.spellcheck=!1,u.setAttribute("enterkeyhint","send"),s.appendChild(u);let a=null;if(i.plus){const p=document.createElement("button");p.type="button",p.className="cib-plus",p.textContent="+",p.setAttribute("aria-label",i.plusLabel||"引用作品"),p.hidden=!0,typeof i.onPlus=="function"&&p.addEventListener("click",function(){i.onPlus()}),s.appendChild(p),a=p}function d(p){a&&(a.hidden=!p)}return u.addEventListener("input",function(){t(u)}),u.addEventListener("compositionend",function(){t(u)}),u.addEventListener("keydown",p=>{if(p.key==="Enter"&&!p.shiftKey&&!p.isComposing){p.preventDefault();const w=u.value.trim();(w||c&&c())&&r&&r(w)}}),{root:o,input:u,focus:function(){try{u.focus({preventScroll:!0})}catch{u.focus()}},blur:function(){u.blur()},clear:function(){u.value="",t(u)},setPlus:d,destroy:function(){}}}return{create:n}}();class zn{constructor(){this.pending=new Map}async fetch(t,n){if(this.pending.has(t))return this.pending.get(t);const i=n().finally(()=>{this.pending.delete(t)});return this.pending.set(t,i),i}clear(){this.pending.clear()}}var Ge;let jn=(Ge=class{constructor(t){this.intervals=[3e3,5e3,1e4,3e4,6e4],this.idleThresholds=[6e4,3e5,9e5,18e5],this.currentLevel=0,this.lastMessageTime=Date.now(),this.timer=null,this.stopped=!1,this.paused=!1,this.pushMode=!1,this.pushListener=null,this.lastPushTime=0,this.pushTimeout=6e4,this.consecutiveFailures=0,this.backoffMultiplier=1,this.stats={totalPolls:0,successfulPolls:0,failedPolls:0,messagesReceived:0,pushReceived:0,totalIdleTime:0,totalActiveTime:0,lastPollTime:0,averageInterval:0,requestsMerged:0},this.visibilityListener=null,this.options={onPoll:t.onPoll,onMessage:t.onMessage||(()=>{}),onError:t.onError||(()=>{}),priority:t.priority||"normal",minInterval:t.minInterval||3e3,maxInterval:t.maxInterval||6e4,pushEvent:t.pushEvent||"",requestKey:t.requestKey||"default"},this.options.priority==="high"?(this.intervals=[2e3,3e3,5e3,1e4,3e4],this.idleThresholds=[3e4,18e4,6e5,12e5]):this.options.priority==="low"&&(this.intervals=[5e3,1e4,2e4,6e4,12e4],this.idleThresholds=[12e4,6e5,18e5,36e5]),this.intervals=this.intervals.map(n=>Math.max(this.options.minInterval,Math.min(n,this.options.maxInterval)))}start(){this.stopped=!1,this.paused=!1,this.currentLevel=0,this.lastMessageTime=Date.now(),this.consecutiveFailures=0,this.backoffMultiplier=1,this.setupVisibilityListener(),this.options.pushEvent&&this.setupPushListener(),this.schedule()}stop(){this.stopped=!0,this.paused=!1,this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.cleanupVisibilityListener(),this.cleanupPushListener()}pause(){this.paused=!0,this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}resume(){this.stopped||(this.paused=!1,this.schedule(0))}setupPushListener(){this.options.pushEvent&&(this.pushListener=t=>{this.lastPushTime=Date.now(),this.stats.pushReceived++,this.onActivity(),this.pushMode||(this.pushMode=!0,console.debug("[AdaptivePoller] 推送模式启用,轮询降为兜底"))},window.addEventListener(this.options.pushEvent,this.pushListener))}cleanupPushListener(){this.pushListener&&this.options.pushEvent&&(window.removeEventListener(this.options.pushEvent,this.pushListener),this.pushListener=null)}setupVisibilityListener(){this.visibilityListener=()=>{document.hidden?this.pause():this.resume()},document.addEventListener("visibilitychange",this.visibilityListener)}cleanupVisibilityListener(){this.visibilityListener&&(document.removeEventListener("visibilitychange",this.visibilityListener),this.visibilityListener=null)}schedule(t){if(this.stopped||this.paused)return;let n;if(t!==void 0)n=t;else{if(this.pushMode)if(Date.now()-this.lastPushTime>this.pushTimeout)this.pushMode=!1,console.debug("[AdaptivePoller] 推送超时,恢复正常轮询");else{n=3e4,this.timer=window.setTimeout(()=>{this.poll()},n);return}n=this.intervals[this.currentLevel],this.consecutiveFailures>=3&&(this.backoffMultiplier=Math.min(Math.pow(2,this.consecutiveFailures-2),this.options.maxInterval/n),n=Math.min(n*this.backoffMultiplier,this.options.maxInterval))}this.timer=window.setTimeout(()=>{this.poll()},n),this.stats.averageInterval=(this.stats.averageInterval*this.stats.totalPolls+n)/(this.stats.totalPolls+1)}async poll(){if(!(this.stopped||this.paused)){this.stats.totalPolls++,this.stats.lastPollTime=Date.now();try{const t=await Ge.pool.fetch(this.options.requestKey,()=>this.options.onPoll());this.consecutiveFailures=0,this.backoffMultiplier=1,this.stats.successfulPolls++;const n=t&&t.items||[];n.length>0?(this.stats.messagesReceived+=n.length,this.currentLevel=0,this.lastMessageTime=Date.now(),this.options.onMessage&&this.options.onMessage(n)):this.adjustInterval()}catch(t){this.consecutiveFailures++,this.stats.failedPolls++,this.pushMode&&(this.pushMode=!1,console.debug("[AdaptivePoller] 轮询失败,退出推送模式")),this.options.onError&&this.options.onError(t)}this.schedule()}}adjustInterval(){const t=Date.now()-this.lastMessageTime;let n=0;for(let i=0;i<this.idleThresholds.length;i++)t>this.idleThresholds[i]&&(n=i+1);n>this.currentLevel&&n<this.intervals.length&&(this.currentLevel=n,n>0&&(this.stats.totalIdleTime+=Date.now()-this.lastMessageTime))}onActivity(){const t=this.currentLevel>0;this.currentLevel=0,this.lastMessageTime=Date.now(),t&&(this.stats.totalActiveTime+=Date.now()-this.stats.lastPollTime),this.timer!==null&&(clearTimeout(this.timer),this.timer=null),!this.stopped&&!this.paused&&this.schedule(0)}getCurrentInterval(){if(this.pushMode)return 3e4;let t=this.intervals[this.currentLevel];return this.consecutiveFailures>=3&&(t=Math.min(t*this.backoffMultiplier,this.options.maxInterval)),t}isPushMode(){return this.pushMode}getStats(){return{...this.stats}}resetStats(){this.stats={totalPolls:0,successfulPolls:0,failedPolls:0,messagesReceived:0,pushReceived:0,totalIdleTime:0,totalActiveTime:0,lastPollTime:0,averageInterval:0,requestsMerged:0}}},Ge.pool=new zn,Ge);typeof window<"u"&&(window.AdaptivePoller=jn);function Kn(){return(window.__SITE__&&window.__SITE__.slug||"site")+"_chat_history_v2"}const Gn=1,Ve="history",qt=500,Yn=800,Xn=8;function Jn(e){if(!e||typeof e.id!="number"||!isFinite(e.id))return null;const t={id:e.id,content:typeof e.content=="string"?e.content:""};return typeof e.session_id=="number"&&(t.session_id=e.session_id),typeof e.sender_id=="number"&&(t.sender_id=e.sender_id),typeof e.origin=="string"&&(t.origin=e.origin),typeof e.from_me=="boolean"&&(t.from_me=e.from_me),typeof e.created_at=="string"&&(t.created_at=e.created_at),typeof e.attachment_url=="string"&&e.attachment_url&&(t.attachment_url=e.attachment_url),typeof e.attachment_meta=="string"&&e.attachment_meta&&(t.attachment_meta=e.attachment_meta),typeof e.kind=="string"&&e.kind&&(t.kind=e.kind),t}function Ut(e){const t=new Map;for(const n of e){const i=Jn(n);i&&t.set(i.id,i)}return Array.from(t.values()).sort(function(n,i){return n.id-i.id})}class Qn{constructor(){this.memory=new Map,this.memoryUpdatedAt=new Map,this.db=null,this.dbInit=null,this.dbBroken=!1,this.writeChains=new Map,this.writesSincePrune=0}key(t,n){return t+":s"+n}peek(t,n){if(!isFinite(t)||!isFinite(n))return[];const i=this.memory.get(this.key(t,n));return i?i.slice():[]}async load(t,n){if(!isFinite(t)||!isFinite(n))return[];const i=this.key(t,n),o=this.memory.get(i);if(o)return o.slice();const s=await this.openDB();if(!s)return[];try{const l=await new Promise(function(u,a){const p=s.transaction([Ve],"readonly").objectStore(Ve).get(i);p.onsuccess=function(){u(p.result||null)},p.onerror=function(){a(p.error)}});if(!l||!Array.isArray(l.messages))return[];const r=typeof l.updatedAt=="number"?l.updatedAt:0,c=Ut(l.messages);return this.memory.set(i,c),this.memoryUpdatedAt.set(i,r),c.slice()}catch{return[]}}save(t,n,i){if(!isFinite(t)||!isFinite(n)||!Array.isArray(i)||i.length===0)return;const o=this.key(t,n),s=Ut(i);if(s.length===0)return;const l=s.slice(-5e3),r=Date.now();this.memory.set(o,l),this.memoryUpdatedAt.set(o,r);const c={key:o,userId:t,sessionId:n,updatedAt:r,messages:l},a=(this.writeChains.get(o)||Promise.resolve()).then(()=>this.writeRecord(c)).catch(function(){});this.writeChains.set(o,a)}clear(t,n){const i=this.key(t,n);this.memory.delete(i),this.memoryUpdatedAt.delete(i);const o=this.db;o&&this.deleteRecord(o,i)}clearAll(){this.memory.clear(),this.memoryUpdatedAt.clear();const t=this.db;if(t)try{t.transaction([Ve],"readwrite").objectStore(Ve).clear()}catch{}}async getStats(){const t=await this.openDB();if(!t){let n=0;for(const i of this.memory.values())n+=i.length;return{conversations:this.memory.size,messages:n,bytes:0,storage:"memory-only"}}try{const n=await this.getAllRecords(t);let i=0,o=0;for(const s of n)i+=s.messages.length,o+=JSON.stringify(s).length*2;return{conversations:n.length,messages:i,bytes:o,storage:"indexeddb"}}catch{return{conversations:0,messages:0,bytes:0,storage:"indexeddb"}}}openDB(){return this.db?Promise.resolve(this.db):this.dbBroken?Promise.resolve(null):this.dbInit?this.dbInit:(this.dbInit=new Promise(t=>{if(typeof indexedDB>"u"){this.dbBroken=!0,t(null);return}let n=!1;const i=s=>{n||(n=!0,clearTimeout(o),s?(this.db=s,t(s)):(this.dbBroken=!0,t(null)))},o=window.setTimeout(function(){i(null)},Yn);try{const s=indexedDB.open(Kn(),Gn);s.onupgradeneeded=function(l){const r=l.target.result;r.objectStoreNames.contains(Ve)||r.createObjectStore(Ve,{keyPath:"key"}).createIndex("updatedAt","updatedAt",{unique:!1})},s.onsuccess=function(){const l=s.result;l.onversionchange=(function(){try{l.close()}catch{}this.db=null,this.dbInit=null,this.dbBroken=!1}).bind(this),i(l)},s.onerror=function(){i(null)},s.onblocked=function(){i(null)}}catch{i(null)}}),this.dbInit)}async writeRecord(t){const n=await this.openDB();n&&(await new Promise(function(i,o){const l=n.transaction([Ve],"readwrite").objectStore(Ve).put(t);l.onsuccess=function(){i()},l.onerror=function(){o(l.error)}}),this.writesSincePrune++,this.writesSincePrune>=Xn&&(this.writesSincePrune=0,await this.pruneConversations(n)))}async deleteRecord(t,n){try{await new Promise(function(i,o){const l=t.transaction([Ve],"readwrite").objectStore(Ve).delete(n);l.onsuccess=function(){i()},l.onerror=function(){o(l.error)}})}catch{}}getAllRecords(t){return new Promise(function(n,i){const s=t.transaction([Ve],"readonly").objectStore(Ve).getAll();s.onsuccess=function(){n(s.result||[])},s.onerror=function(){i(s.error)}})}async pruneConversations(t){try{const n=await this.getAllRecords(t);if(n.length<=qt)return;n.sort(function(o,s){return o.updatedAt-s.updatedAt});const i=n.length-qt;for(let o=0;o<i;o++)await this.deleteRecord(t,n[o].key)}catch{}}}typeof window<"u"&&(window.ChatHistoryCache=new Qn);window.RelationEntry=function(){const e=window.escapeHtml;function t(o,s){return" data-"+o+'="'+e(String(s))+'"'}function n(o){let s="";if(Array.isArray(o)&&o.length){let l="";o.forEach(r=>{if(!r||!r.action)return;let c="";const u=r.data||{};Object.keys(u).forEach(d=>{c+=t(d,u[d])});const a=r.html||e(String(r.label||""));l+='<button type="button" class="giv-entry-menu-item" data-entry-action="'+e(String(r.action))+'"'+c+">"+a+"</button>"}),s='<span class="giv-entry-menu"><button type="button" class="giv-entry-menu-trigger" aria-label="更多操作">⋮</button><div class="giv-entry-menu-popup">'+l+"</div></span>"}return s}function i(o){o=o||{};const s=["giv-entry","giv-vcard"];o.extraClass&&s.push(o.extraClass),o.clickable==="card"?s.push("clickable-card"):o.clickable==="strip"&&s.push("clickable-strip");let l="";const r=o.dataAttrs||{};Object.keys(r).forEach(S=>{l+=t(S,r[S])});const c="giv-vcard-avatar"+(o.badgeCur?" cur":""),u=e(String(o.badge||"")),a="giv-vcard-title"+(o.titleNone?" none":""),d=o.titleNone?"(无标题)":e(String(o.title||"")),p=o.title?' title="'+e(String(o.title))+'"':"",w="giv-vcard-detail"+(o.detailNone?" none":""),y=o.detailNone?"(无详细说明)":e(String(o.detail||"")),f=typeof window.fmtListTime=="function"&&o.time?window.fmtListTime(o.time):"",m=o.timeFull?' title="'+e(String(o.timeFull))+'"':"",E=n(Array.isArray(o.menuItems)?o.menuItems:[]);return'<div class="'+s.join(" ")+'"'+l+'><div class="'+c+'"><span class="giv-vbadge">'+u+'</span></div><div class="giv-vcard-main"><div class="giv-vcard-row"><span class="'+a+'"'+p+">"+d+'</span><span class="giv-vcard-time"'+m+">"+e(f)+'</span></div><div class="giv-vcard-row"><span class="'+w+'">'+y+"</span>"+(o.note?'<span class="giv-vcard-note">'+e(String(o.note))+"</span>":"")+E+"</div></div></div>"}return{cardHtml:i}}();window.RelationPanel=function(){const e=window.escapeHtml,t=new Set;function n(c,u){LayerFrame.placePopup(c,u),c.classList.add("open"),t.add(c);const a=c.closest(".giv-entry");a&&a.classList.add("menu-open")}function i(c){c.classList.remove("open"),t.delete(c);const u=c.closest(".giv-entry");u&&u.classList.remove("menu-open")}function o(c){t.size&&t.forEach(u=>{if(!u.isConnected){t.delete(u);return}c&&c!==document&&!c.contains(u)||i(u)})}let s=!1;function l(){if(s)return;s=!0;const c=()=>o(document);window.addEventListener("scroll",c,{capture:!0,passive:!0}),window.addEventListener("resize",c)}function r(c){c=c||{};let u=null;const a={body:null,state:null,rerender:null};function d(f){f=f||{};let m="";f.headerHtml&&(m+=f.headerHtml),(Array.isArray(f.sections)?f.sections:[]).forEach(S=>{if(!S)return;const L="giv-panel-section"+(S.extraClass?" "+S.extraClass:"");m+='<div class="'+L+'">',S.title&&(m+='<div class="giv-panel-title">'+e(String(S.title))+"</div>"),m+=S.entriesHtml||"",m+="</div>"}),f.footerHtml&&(m+=f.footerHtml),u.innerHTML=m,p(),typeof c.afterRender=="function"&&c.afterRender(u,a)}function p(){u.__relationBound||(u.__relationBound=!0,u.addEventListener("click",function(f){const m=f.target;if(!m||!m.closest)return;const E=m.closest(".giv-entry-menu-trigger");if(E){f.preventDefault(),f.stopPropagation();const O=E.closest(".giv-entry-menu"),I=O&&O.querySelector(".giv-entry-menu-popup");o(u),I&&!I.classList.contains("open")&&n(I,E);return}const S=m.closest("[data-entry-action]");if(S){f.preventDefault(),f.stopPropagation();const O=S.getAttribute("data-entry-action");o(u),O&&c.actions&&typeof c.actions[O]=="function"&&c.actions[O](S,a);return}if(m.closest(".giv-entry-menu-popup"))return;const L=m.closest(".giv-entry");if(L){o(u);const O=L.classList.contains("clickable-card")?"card":L.classList.contains("clickable-strip")?"strip":"",I=m.closest(".giv-entry-strip")?"strip":"row";O&&(O==="card"||I==="strip")&&typeof c.onEntryClick=="function"&&c.onEntryClick(L,I);return}o(u)},!0))}a.rerender=function(f){document.contains(u)&&(f!==void 0&&(a.state=f),d(a.state))};async function w(){u.innerHTML=StatusTpl.loading();try{const f=await c.fetch(a);if(!document.contains(u))return;a.state=f,d(f)}catch(f){if(!document.contains(u))return;const m=f&&f.message?String(f.message):"网络错误";u.innerHTML='<div class="giv-panel-empty">'+e(c.errorText||"加载失败")+":"+e(m)+'<br><button type="button" class="neu-btn" data-retry style="margin-top:10px;">重试</button></div>';const E=u.querySelector("[data-retry]");E&&E.addEventListener("click",function S(){E.removeEventListener("click",S),w()}),typeof c.afterError=="function"&&c.afterError(u,a,f)}}AppWindows.define("relation",{title:c.title,mode:"layer",onClose(){typeof c.onClose=="function"&&c.onClose()},render:function(f){u=f,a.body=f}});const y=AppWindows.open("relation");y&&(u=y.body,a.body=u,p(),l(),w())}return{open:r}}();(function(){if(window.AuthPanel&&window.AuthPanel.__installed)return;var e=null,t=!1;function n(l){var r=l==="login",c=l==="register-email"||l==="reset-password",u={login:"登录","register-email":"邮箱注册","reset-password":"找回密码"};return'<div class="auth-card"><h1>'+u[l]+'</h1><form id="authForm" method="POST" novalidate autocomplete="on">'+(c?"":'<label for="username">用户名或邮箱</label><input type="text" id="username" name="username" maxlength="255" placeholder="用户名 或 邮箱地址" autocomplete="username" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="next" required>')+(c?'<label for="emailAddr">邮箱</label><input type="email" id="emailAddr" name="email" maxlength="255" placeholder="name@example.com" autocomplete="email" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="next" required><label for="emailCode">验证码</label><div class="auth-code-row"><input type="text" id="emailCode" name="code" maxlength="6" placeholder="6 位数字" inputmode="numeric" autocomplete="one-time-code" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="go" required><button type="button" class="auth-code-btn" id="emailCodeBtn">获取验证码</button></div>':"")+(c&&l==="register-email"?'<label for="password">设置密码</label><input type="password" id="password" name="password" placeholder="至少 6 位" autocomplete="new-password" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="next" required><label for="passwordConfirm">确认密码</label><input type="password" id="passwordConfirm" name="password_confirm" placeholder="再输入一遍密码" autocomplete="new-password" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="go" required>':c&&l==="reset-password"?'<label for="password">新密码</label><input type="password" id="password" name="password" placeholder="至少 6 位" autocomplete="new-password" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="next" required><label for="passwordConfirm">确认新密码</label><input type="password" id="passwordConfirm" name="password_confirm" placeholder="再输入一遍密码" autocomplete="new-password" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="go" required>':"")+(c?"":'<label for="password">密码</label><input type="password" id="password" name="password" placeholder="'+(r?"请输入密码":"至少 6 位")+'" autocomplete="'+(r?"current-password":"new-password")+'" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="'+(r?"go":"next")+'" required>')+'<button type="submit" id="submitBtn">'+(r?"登录":l==="reset-password"?"重置密码":"注册并登录")+'</button><input type="hidden" name="altcha" id="altchaPayload"><div class="auth-captcha" id="authCaptchaStatus" role="status" aria-live="polite"></div><div class="auth-msg" id="authMsg" role="status" aria-live="polite"></div><div class="auth-fallback" id="authFallback" hidden></div></form><div class="auth-switch">'+(l==="login"?'还没有账号?<a href="/register" data-auth-switch="register-email">去注册</a>':l==="reset-password"?'想起密码了?<a href="/login" data-auth-switch="login">去登录</a>':'已有账号?<a href="/login" data-auth-switch="login">去登录</a>')+"</div></div>"}function i(l,r){if(window.AuthForm){var c=!!(r&&r.redirectOnSuccess);AuthForm.init({mode:l,next:r&&r.next||"/",onSuccess:c?function(u){try{PlainView.closeAll()}catch{}location.href=u||"/"}:function(){try{PlainView.closeAll()}catch{}location.reload()}})}}function o(l,r){if(!t){t=!0;var c={login:"登录","register-email":"邮箱注册","reset-password":"找回密码"};AppWindows.define("auth",{title:c[l]||"登录",mode:"layer",fill:!0,render:function(a){e=a,a.innerHTML=n(l);var d=window.__fwWhenLate?new Promise(p=>{window.__fwWhenLate(()=>p())}):Promise.resolve();d.then(function(){if(!a.isConnected){t=!1;return}i(l,r),t=!1})}});var u=AppWindows.open("auth");u||(t=!1,window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify("弹层打开失败",{type:"error"}))}}function s(l){if(!e||!e.isConnected){o(l);return}e.innerHTML=n(l),i(l)}document.addEventListener("click",function(l){if(!l.defaultPrevented&&!(typeof l.button=="number"&&l.button!==0)&&!(l.metaKey||l.ctrlKey||l.shiftKey||l.altKey)){var r=l.target&&l.target.closest?l.target.closest("a"):null;if(r){var c=r.getAttribute("data-auth-switch");if(c==="login"||c==="register-email"||c==="reset-password"){l.preventDefault(),s(c);return}var u=r.getAttribute("href")||"";u==="/login"||u.indexOf("/login?")===0?(l.preventDefault(),o("login")):(u==="/register"||u.indexOf("/register?")===0)&&(l.preventDefault(),o("register-email"))}}}),window.AuthPanel={__installed:!0,open:o,switchMode:s}})();(function(){if(window.AuthDeepLink&&window.AuthDeepLink.__installed)return;function e(n){return n==="/login"?"login":n==="/register"?"register-email":null}function t(n){if(!n)return null;var i=n.replace(/\\/g,"/").replace(/[\u0000-\u001f\u007f]/g,"");return i.charAt(0)!=="/"||i.charAt(1)==="/"?null:i}window.AuthDeepLink={__installed:!0,authDeepLinkMode:e,sanitizeNext:t}})();(function(){if(window.AppShell&&window.AppShell.__installed)return;var e=window.FW_CONTRACTS,t={},n=null,i={},o={"/":"favorites","/my":"my","/favorites":"favorites"},s={my:"/my",favorites:"/favorites"};function l(C){return document.querySelector('[data-app-view="'+C+'"]')}function r(){return document.querySelector(".app-shell")}function c(C){return C.indexOf("feature-")===0}function u(C){return s.hasOwnProperty(C)||c(C)}function a(C){return s.hasOwnProperty(C)?s[C]:c(C)?"/feature/"+C.slice(8):""}var d=[];function p(C,z){if(!C||!u(C)){console.warn("AppShell: unknown view name:",C);return}var Y=l(C);if(!Y){d.push([C,z||{}]);return}var ue=t[C];t[C]=Object.assign({name:C,node:Y,mount:function(){},activate:function(){},deactivate:function(){},warmup:function(){},actions:{},__mounted:ue?!!ue.__mounted:!1},z||{});var he=t[C].actions||{};Object.keys(he).forEach(g),h(location.pathname||"/")===C&&(n===null?L(C,location.pathname,{setTitle:!0}):n!==C&&console.warn("AppShell: late view registered while another view active",C))}function w(C){var z=t[C];z&&(z.node.classList.add("app-view-active"),z.node.setAttribute("aria-hidden","false"))}function y(C){var z=t[C];z&&(z.node.classList.remove("app-view-active"),z.node.setAttribute("aria-hidden","true"))}function f(C,z){var Y=t[C];if(Y){var ue=!Y.__mounted;if(ue){Y.__mounted=!0;try{Y.mount()}catch(Ee){console.error("AppShell mount("+C+"):",Ee)}}w(C);try{Y.activate(z||a(C))}catch(Ee){console.error("AppShell activate("+C+"):",Ee)}var he=i[C];if(typeof he=="number"&&Y.node)try{Y.node.scrollTop=he}catch{}}}function m(C){var z=t[C];if(!(!z||!z.__mounted)){if(z.node)try{i[C]=z.node.scrollTop||0}catch{}try{z.deactivate()}catch(Y){console.error("AppShell deactivate("+C+"):",Y)}y(C)}}var E=!1;function S(C){if(!E){E=!0;var z=function(){E=!1,Object.keys(t).forEach(function(Y){if(Y!==C){var ue=t[Y];if(!(!ue||ue.__mounted))try{ue.__mounted=!0,ue.mount(),typeof ue.warmup=="function"&&ue.warmup()}catch(he){ue.__mounted=!1,console.error("AppShell warmup("+Y+"):",he)}}})};window.requestIdleCallback?window.requestIdleCallback(z,{timeout:1200}):setTimeout(z,250)}}function L(C,z,Y){if(Y=Y||{},!!t[C]&&n!==C){if(M(n),n&&t[n]&&t[n].node){try{i[n]=t[n].node.scrollTop||0}catch{}m(n)}n=C,f(C,z);var ue=t[C].node.getAttribute("data-app-view-title"),he=window.__SITE__&&(window.__SITE__.name||window.__SITE__.slug)||"";(ue&&(!document.title||document.title===he)||ue&&Y.setTitle!==!1)&&(document.title=ue),k(C),P(C),F(C);try{document.dispatchEvent(new CustomEvent(e.ROUTE_CHANGE_EVENT,{detail:{view:C,path:z||a(C)}}))}catch{}S(C)}}function O(){try{if(window.PlainView&&typeof window.PlainView.isHistoryPopPending=="function"&&window.PlainView.isHistoryPopPending()||window.WorkView&&typeof window.WorkView.isHistoryPopPending=="function"&&window.WorkView.isHistoryPopPending())return!0}catch{}return!1}function I(C,z){if(C){if(O()){var Y=!1,ue=function(){if(!Y){Y=!0;try{window.removeEventListener("popstate",ue)}catch{}v(C,z)}};window.addEventListener("popstate",ue),setTimeout(ue,120);return}v(C,z)}}function v(C,z){z=z||{};var Y=h(C);if(!Y){window.location.href=C;return}if(!l(Y)){window.location.href=C;return}if(location.pathname!==C)try{z.replace?history.replaceState({appShell:Y,path:C},"",C):history.pushState({appShell:Y,path:C},"",C)}catch{}n!==Y&&L(Y,C,z)}function h(C){if(o[C])return o[C];var z=/^\/feature\/([A-Za-z0-9_-]+)$/.exec(C);if(z){var Y="feature-"+z[1].toLowerCase();return l(Y)?Y:null}return null}function x(C){var z=location.pathname||"/",Y=h(z);Y&&n!==Y&&L(Y,z,{setTitle:!0})}window.addEventListener("popstate",x);var T=window;function _(C,z){var Y=n&&t[n];if(Y&&Y.actions&&typeof Y.actions[C]=="function")try{return Y.actions[C].apply(null,z||[])}catch(he){console.error(he)}var ue=typeof T[C]=="function"&&T[C].__appShellDispatch!==C?T[C]:null;if(ue)try{return ue.apply(null,z||[])}catch(he){console.error(he)}}function g(C){if(C&&!(T[C]&&T[C].__appShellDispatch===C)){var z=function(){return _(C,Array.prototype.slice.call(arguments))};try{z.__appShellDispatch=C}catch{}T[C]=z}}function B(C){return!!h(C)}function A(){return document.getElementById("appSidebar")}function k(C){var z=A();z&&z.querySelectorAll("[data-sb-nav]").forEach(function(Y){var ue=Y.getAttribute("data-sb-nav")===C;Y.classList.toggle("active",ue),Y.tagName==="A"&&Y.setAttribute("aria-current",ue?"page":"false")})}function P(C){var z=document.getElementById("sbTopbarTitle");if(z){var Y=C?t[C]:null;z.textContent=Y&&Y.node.getAttribute("data-app-view-title")||""}}function j(){var C=document.getElementById("sbName"),z=document.getElementById("sbAvatar"),Y=window.__me;C&&(C.textContent=Y&&(Y.nickname||Array.isArray(Y.roles)&&Y.roles[0]||Y.username)||"我的"),z&&typeof window.avatarHtml=="function"&&(z.innerHTML=Y&&Y.avatar_url?window.avatarHtml({avatar_url:Y.avatar_url,username:Y&&Y.username||""}):"")}function Z(){var C=document.getElementById("sbFeats");if(!C)return;const z=C;z.innerHTML="";var Y=window.__gate||{},ue=Array.isArray(window.MY_FEATURES)?window.MY_FEATURES:[];ue.forEach(function(he){if(he.sidebar!==!1){var Ee=!1;if(he.entry?Ee=(Y.entries||{})[he.entry]===!0:he.uiAction&&(Ee=(Y.ui_actions||{})[he.uiAction]===!0),!!Ee){var Q=document.createElement(he.href?"a":"button");Q.className="sb-item",Q.title=he.label,he.viewId&&Q.setAttribute("data-sb-nav","feature-"+he.viewId),he.href?Q.href=he.href:Q.type="button",Q.innerHTML='<span class="sb-ico" aria-hidden="true"></span><span class="sb-label"></span>';var de=Q.querySelector(".sb-ico"),fe=Q.querySelector(".sb-label");de&&(de.textContent=he.icon),fe&&(fe.textContent=he.label),Q.addEventListener("click",function(ye){const we=ye;ye.defaultPrevented||we.metaKey||we.ctrlKey||we.shiftKey||we.altKey||we.button!==0||he.open&&he.open()!==!1&&he.href&&ye.preventDefault()}),z.appendChild(Q)}}})}function N(){var C=document.getElementById("sbThemeIcon");C&&(C.textContent=window.Theme&&Theme.current()==="dark"?"🌙":"☀️");var z=document.querySelector("#sbTheme .sb-label");z&&(z.textContent=window.Theme&&Theme.current()==="dark"?"浅色模式":"深色模式")}var ee=null,ie=null,W=300;function q(C){if(!(!ee||!n)){var z=t[n];if(!(!z||!z.node||!z.node.hasAttribute("data-sb-search"))){var Y=(ee.value||"").trim();ie!==null&&(clearTimeout(ie),ie=null);var ue=function(){try{z.node.dispatchEvent(new CustomEvent("sb:search",{detail:{query:Y}}))}catch{}};C||!Y?ue():ie=window.setTimeout(function(){ie=null,ue()},W)}}}function F(C){if(ee){var z=C?t[C]:null,Y=z&&z.node&&z.node.getAttribute("data-app-view-title")||"",ue=!!(z&&z.node&&z.node.hasAttribute("data-sb-search"));ee.disabled=!ue;var he=ee.closest(".sb-search");he&&he.classList.toggle("sb-search-off",!ue),ee.placeholder=ue?"在「"+Y+"」内搜索":"此页无搜索"}}function M(C){if(ee){ie!==null&&(clearTimeout(ie),ie=null);var z=C?t[C]:null;if(z&&z.node&&(ee.value||"").trim()&&z.node.hasAttribute("data-sb-search"))try{z.node.dispatchEvent(new CustomEvent("sb:search",{detail:{query:""}}))}catch{}ee.value=""}}var G=window.matchMedia("(max-width: 959.98px)"),re=Math.tan(30*Math.PI/180),ce=8,H=20;function te(){return G.matches}function oe(C){var z=document.querySelector(".app-layout");z&&z.classList.toggle("sb-open",C)}function ve(){var C=document.querySelector(".app-layout");return!!(C&&C.classList.contains("sb-open"))}function Se(C){if(!C)return!1;if(C.isContentEditable)return!0;var z=(C.tagName||"").toUpperCase();return z==="INPUT"||z==="SELECT"||z==="TEXTAREA"}function se(){return!!document.querySelector(".pv-overlay:not([hidden]), .ps-overlay:not([hidden])")}function Ae(C){for(var z=C;z&&z!==document.body;){if(z.nodeType===1){var Y=z;if(Y.classList&&Y.classList.contains("app-layout"))break;if(Y.scrollWidth>Y.clientWidth+1){var ue=window.getComputedStyle(Y).overflowX;if(ue==="auto"||ue==="scroll"||ue==="overlay")return!0}}z=z.parentNode}return!1}function xe(){var C=document.getElementById("appSidebar");if(!C)return;const z=C;var Y=0,ue=0,he=0,Ee=0,Q=0,de=0,fe=!1;function ye(X){z.classList.add("sb-dragging"),z.style.transform="translateX("+X.toFixed(1)+"px)"}function we(){z.classList.remove("sb-dragging"),z.style.transform=""}function Ce(X,ae,pe,me,ge){if(!(Y||!te()||se())){var ke=me;if(!(!ke||Se(ke)||Ae(ke))){var Te=ke.closest(".app-layout");if(Te){if(ue=X,he=ae,Ee=pe,de=X,Q=z.getBoundingClientRect().width||1,fe=!Te.classList.contains("sb-open"),fe&&ge&&X>H){Y=0;return}Y=fe||ke.closest("#sbScrim")?1:0}}}}function U(X,ae){if(!Y)return!1;var pe=X-ue,me=ae-he;if(Y===1){var ge=Math.abs(pe),ke=Math.abs(me);if(document.documentElement.dataset.fwLongPress==="1"||document.querySelector(".item-menu-popup.open"))return Y=0,!1;if(Math.max(ge,ke)<ce)return!1;if(fe){if(pe<=0)return Y=0,!1;if(ke<=ge*re)Y=2;else return Y=0,!1}else if(ge>=ke)Y=pe>0?2:3;else{if(ke>ge*1.3)return Y=0,!1;Y=pe>0?2:3}}return de=X,ye(Y===2?Math.min(0,-Q+Math.max(0,pe)):Math.min(0,Math.max(-Q,pe))),!0}function le(X,ae){var pe=Y;if(Y=0,!(!pe||pe===1)){var me=X-ue,ge=Math.max(1,ae-Ee),ke=Math.abs(me)/ge>.3,Te=pe===2?me>Q*.3||ke&&me>0:me<-Q*.3||ke&&me<0;we(),oe(pe===2?Te:!Te)}}function _e(){Y&&(Y=0,we())}document.addEventListener("touchstart",function(X){if(X.touches.length!==1){_e();return}var ae=X.touches[0];Ce(ae.clientX,ae.clientY,X.timeStamp,X.target,!1)},{passive:!0}),document.addEventListener("touchmove",function(X){if(Y){if(X.touches.length!==1){_e();return}var ae=X.touches[0];U(ae.clientX,ae.clientY)&&X.preventDefault()}},{passive:!1}),document.addEventListener("touchend",function(X){if(Y){var ae=X.changedTouches&&X.changedTouches[0];le(ae?ae.clientX:de,X.timeStamp)}},{passive:!0}),document.addEventListener("touchcancel",_e,{passive:!0}),document.addEventListener("pointerdown",function(X){X.pointerType&&X.pointerType!=="mouse"||Ce(X.clientX,X.clientY,X.timeStamp,X.target,!0)},{passive:!0}),document.addEventListener("pointermove",function(X){X.pointerType&&X.pointerType!=="mouse"||U(X.clientX,X.clientY)},{passive:!0}),document.addEventListener("pointerup",function(X){X.pointerType&&X.pointerType!=="mouse"||Y&&le(X.clientX,X.timeStamp)},{passive:!0}),document.addEventListener("pointercancel",function(X){X.pointerType&&X.pointerType!=="mouse"||_e()},{passive:!0});var K=function(){G.matches||(Y=0,we(),oe(!1))};typeof G.addEventListener=="function"?G.addEventListener("change",K):typeof G.addListener=="function"&&G.addListener(K)}function be(){var C=document.getElementById("appSidebar");if(!C||C.__sbBound)return;const z=C;z.__sbBound=!0,z.addEventListener("click",function(ye){if(!(ye.defaultPrevented||ye.metaKey||ye.ctrlKey||ye.shiftKey||ye.altKey||ye.button!==0)){var we=ye.target,Ce=we&&typeof we.closest=="function"?we.closest("[data-sb-nav]"):null;if(!(!Ce||!z.contains(Ce))){ye.preventDefault();var U=Ce.getAttribute("data-sb-nav")||"",le=a(U);le&&(U!==n&&I(le),te()&&oe(!1))}}});var Y=document.getElementById("sbSearchInput");ee=Y,Y&&(Y.addEventListener("input",function(){q(!1)}),Y.addEventListener("keydown",function(ye){ye.key==="Enter"&&q(!0)}),Y.addEventListener("blur",function(){Y.value.trim()&&q(!0)}));var ue=document.getElementById("sbTheme");ue&&ue.addEventListener("click",function(){window.MyProfile&&typeof window.MyProfile.toggleAppearance=="function"&&window.MyProfile.toggleAppearance()});var he=3742,Ee=function(){window.ItemViewOrchestrator&&typeof ItemViewOrchestrator.prefetchWork=="function"&&ItemViewOrchestrator.prefetchWork("works",he)},Q=document.querySelector(".sb-about");Q&&(Q.addEventListener("pointerenter",Ee,{passive:!0}),Q.addEventListener("pointerdown",Ee,{passive:!0}),Q.addEventListener("focus",Ee),Q.addEventListener("click",function(){te()&&oe(!1);try{ItemViewOrchestrator.resolveAndOpen("works",he,{title:"关于",viewer:window.currentUser(),notify:function(ye){window.StatusNotify&&StatusNotify.error(ye)}})}catch(ye){console.error("打开关于页面失败:",ye),window.StatusNotify&&StatusNotify.error("暂时无法打开关于页面")}}));var de=document.getElementById("sbScrim");de&&de.addEventListener("click",function(){oe(!1)});var fe=document.getElementById("sbMenuBtn");fe&&fe.addEventListener("click",function(){oe(!ve())}),document.addEventListener("keydown",function(ye){ye.key==="Escape"&&ve()&&oe(!1)}),xe(),document.addEventListener("theme-changed",N),document.addEventListener("auth:ready",function(){j(),Z()}),j(),N(),Z(),k(n),P(n),F(n)}var b={__installed:!0,currentUser:function(){return window.__me||null},registerView:p,navigate:I,dispatchAction:_,defineGlobalAction:g,pathToViewName:h,isShellPath:B,activateView:function(C){var z=s[C]||"/";L(C,z,{setTitle:!0})},get activeView(){return n},get views(){return t},warmup:S};window.AppShell=b,b.init=R;function R(){var C=r();if(C){if(d.length){var z=d;d=[];for(var Y=0;Y<z.length;Y++)p(z[Y][0],z[Y][1])}Array.prototype.map.call(C.querySelectorAll("[data-app-view]"),function(Q){return Q.getAttribute("data-app-view")});var ue=C.getAttribute("data-app-initial")||"favorites",he=location.pathname||"/",Ee=h(he)||ue;b.__shellReady=!0,b.__shellInitialView=Ee;try{document.body.classList.add("app-shell-mode")}catch{}ne(C),be(),L(Ee,he,{setTitle:!0}),window.Interact&&typeof Interact.arm=="function"&&Interact.arm()}}var D=!1,J=0;function V(){if(!document.hidden){var C=Date.now();document.querySelectorAll(".app-view").forEach(function(z){z.getAttribute("aria-hidden")==="true"&&z.querySelector(".item-card")&&(C-(z.__lastPrewarmAt||0)<8e3||(z.__lastPrewarmAt=C,z.classList.add("shell-prewarm"),requestAnimationFrame(function(){requestAnimationFrame(function(){z.classList.remove("shell-prewarm")})})))})}}function $(){if(!D){D=!0;var C=window.requestIdleCallback;C?C(function(){D=!1,V()},{timeout:2e3}):setTimeout(function(){D=!1,V()},400)}}function ne(C){if(!(!C||C.__prewarmBound)){C.__prewarmBound=!0;var z=new MutationObserver(function(ue){for(var he=0;he<ue.length;he++)if(ue[he].addedNodes&&ue[he].addedNodes.length){clearTimeout(J),J=setTimeout($,600);break}});z.observe(C,{childList:!0,subtree:!0}),document.addEventListener("visibilitychange",function(){document.hidden||$()});var Y=window.FW_CONTRACTS&&FW_CONTRACTS.ROUTE_CHANGE_EVENT||"app-shell:routechange";document.addEventListener(Y,$),$()}}window.onDomReady(R)})();window.PullSearch=window.PullSearch||function(){var e=64,t=[];function n(i){var o=i.scrollEl,s=i.placeholder||"搜索",l=typeof i.onQuery=="function"?i.onQuery:null;o||(o=null);var r=document.createElement("div");r.className="ps-overlay",r.hidden=!0,r.innerHTML='<div class="ps-panel"><input type="text" class="ps-input" placeholder="'+s.replace(/"/g,"&quot;")+'" enterkeyhint="search" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><button type="button" class="ps-cancel">取消</button></div>',document.body.appendChild(r);var c=r.querySelector(".ps-input"),u=r.querySelector(".ps-cancel"),a=!1,d=!1;function p(){return(c.value||"").trim()}function w(){l&&l(p())}function y(){d||a||(a=!0,r.hidden=!1,c.focus())}function f(){d||!a||(a=!1,c.blur(),r.hidden=!0)}function m(){c.value&&(c.value="",c.dispatchEvent(new Event("input",{bubbles:!0}))),w(),f()}c.addEventListener("input",w),c.addEventListener("keydown",function(T){T.key==="Escape"&&(T.preventDefault(),m())}),c.addEventListener("blur",function(){!d&&!p()&&f()}),u.addEventListener("mousedown",function(T){T.preventDefault()}),u.addEventListener("touchstart",function(T){T.preventDefault(),m()},{passive:!1}),u.addEventListener("click",m);var E=!1,S=0,L=0;function O(T){E=!!o&&!a&&T.isPrimary!==!1&&o.scrollTop<=0,S=T.clientY,L=T.clientX}function I(T){if(!(!E||a)){var _=T.clientY-S,g=T.clientX-L;_>=e&&_>Math.abs(g)&&(E=!1,y())}}function v(){E=!1}var h={onEnd:v,onPointerDown:O,onPointerMove:I,detachScroll:null};o&&(o.addEventListener("pointerdown",O,{passive:!0}),o.addEventListener("pointermove",I,{passive:!0}),h.detachScroll=function(){o.removeEventListener("pointerdown",O),o.removeEventListener("pointermove",I)});function x(){if(!d){d=!0,v(),f(),h.detachScroll&&h.detachScroll(),r.parentNode&&r.parentNode.removeChild(r);for(var T=t.length-1;T>=0;T--)if(t[T]===h){t.splice(T,1);break}}}return t.push(h),{input:c,open:y,close:f,get opened(){return a},destroy:x}}return document.addEventListener("pointerup",function(){for(var i=0;i<t.length;i++)t[i].onEnd()},{passive:!0}),document.addEventListener("pointercancel",function(){for(var i=0;i<t.length;i++)t[i].onEnd()},{passive:!0}),{bind:n}}();(function(){if(window.MyFavorites&&window.MyFavorites.__installed)return;let e=!1,t=null,n=[];function i(S){return ItemCard.normalizeType?ItemCard.normalizeType(S):S==="game"?"work":S||"work"}const o=window.escapeHtml;function s(S){return i(S.item_type)+":"+Number(S.id)}function l(S){return window.ImageRender&&typeof ImageRender.coverUrl=="function"?ImageRender.coverUrl(S):S.thumb_url||S.image_url||""}function r(S){const L=i(S.item_type),O=s(S),I=S.name||"未命名",v=S.emoji||S.emoji;return window.MyFavorites.renderCard({name:I,ref:S.ref||"",desc:S.brief||"",is_favorited:!0,image:l(S),emoji:v,attrs:' data-key="'+o(O)+'" data-item-type="'+L+'" data-item-id="'+Number(S.id)+'" data-type="'+L+'" data-id="'+Number(S.id)+'"'})}function c(S,L){MyFavorites.setStarState(S,L)}async function u(S,L){const O=i(S.item_type),I=L.classList.contains("favorited");c(L,!I);try{await TypedApi.toggleFavorite(O,Number(S.id)),I?(n=n.filter(v=>!(i(v.item_type)===O&&Number(v.id)===Number(S.id))),t&&t.removeItem(s(S)),window.StatusNotify&&StatusNotify.ok("已取消收藏")):window.StatusNotify&&StatusNotify.ok("已收藏")}catch(v){c(L,I),window.StatusNotify&&StatusNotify.error(v.message||"操作失败")}}function a(S){if(!S)return;const L=i(S.item_type);window.ItemViewOrchestrator&&typeof ItemViewOrchestrator.openItem=="function"&&ItemViewOrchestrator.openItem(S,{itemType:L,viewer:window.currentUser(),autoPlay:!0,notify:O=>{window.StatusNotify&&StatusNotify.error(O)}})}function d(S){if(!S||!t)return null;const L=S.getAttribute("data-item-type")||S.getAttribute("data-type"),O=S.getAttribute("data-item-id")||S.getAttribute("data-id");return L==null||O==null?null:t.getItems().find(v=>i(v.item_type)===L&&Number(v.id)===Number(O))||null}function p(){const S=document.getElementById("favoritesViewGrid");!S||S.dataset.favBound==="1"||(S.dataset.favBound="1",S.addEventListener("click",function(L){if(L.button)return;const O=L.target,I=O.closest&&O.closest(".fav-star-icon");if(I&&S.contains(I)){L.stopPropagation(),L.preventDefault();const x=I.closest(".fav-icon"),T=d(x);T&&u(T,I);return}const v=O.closest&&O.closest(".fav-icon");if(!v||!S.contains(v))return;const h=d(v);h&&(L.stopPropagation(),L.preventDefault(),a(h))}),S.addEventListener("keydown",function(L){if(L.key!=="Enter"&&L.key!==" "&&L.key!=="Spacebar")return;const O=L.target;if(!O||!O.classList||!O.classList.contains("fav-icon"))return;L.preventDefault();const I=d(O);I&&a(I)}))}async function w(S,L,O){if(window.__fwMark&&window.__fwMark("fav-start"),window.__me===void 0&&await new Promise(T=>{const _=setTimeout(T,3e3);window.__onAuthReady(()=>{clearTimeout(_),T()})}),window.__me&&window.__me.role==="guest")return{items:[],total:0,has_more:!1};const I=(O||"").trim().toLowerCase();if(I){const T=await TypedApi.getFavorites(),_=T&&Array.isArray(T.items)?T.items:[];window.__fwMark&&window.__fwMark("fav-done"),n=_;const g=_.filter(function(A){return((A.name||"")+" "+(A.brief||"")+" "+(A.author_name||A.author||A.author_username||"")).toLowerCase().indexOf(I)!==-1}),B=g.slice(S,S+L);return{items:B,total:g.length,has_more:S+B.length<g.length}}let v=null;if(S===0){const T=window.__fwBootPrefetch,_=T&&T.favorites;_&&(T.favorites=null,v=await _)}v||(v=await TypedApi.getFavorites({limit:L,offset:S}));const h=v&&Array.isArray(v.items)?v.items:[];window.__fwMark&&window.__fwMark("fav-done"),n=S===0?h:n.concat(h);const x=typeof v.total=="number"?v.total:h.length;return{items:h,total:x,has_more:typeof v.has_more=="boolean"?v.has_more:S+h.length<x}}let y=!1;function f(){y||(y=!0,window.__fwContentReady=!0,window.dispatchEvent(new Event("fw:first-content")),window.__fwMark&&window.__fwMark("first-content"))}function m(){if(t)return;const S=document.getElementById("favoritesViewGrid");if(!S)return;const L=e&&document.querySelector('[data-app-view="favorites"]')||null;t=ListView.bind({name:"favorites",container:S,viewRoot:L,searchInput:document.getElementById("sbSearchInput"),searchBindEvents:!1,loadingEl:document.getElementById("favViewSkeleton"),initialWindowLoading:!0,pageSize:30,fetchPage:async function(O,I,v){try{return await w(O,I,v)}finally{f()}},renderItem:r,extractId:s,emptyText:"还没有收藏,去「功能」分区逛逛吧",inShell:e,onMount:p})}function E(){if(e=!!(window.AppShell&&window.AppShell.__installed),!e)return;const S=document.querySelector('[data-app-view="favorites"]');S&&(m(),S.addEventListener("sb:search",function(){t&&t.resetForQuery()}),window.AppShell.registerView("favorites",{mount:function(){},activate:function(){t&&t.reloadIfStale(30*1e3)},deactivate:function(){}}))}window.onDomReady(function(){if(document.querySelector(".app-shell")||document.getElementById("favoritesViewGrid")){E();return}var S=!1;function L(){S||(S=!0,E())}window.addEventListener("spa:shell-dom",L,{once:!0}),setTimeout(L,8e3)}),window.MyFavorites={__installed:!0}})();(function(){if(window.MyFavorites&&window.MyFavorites.renderCard)return;function e(o){return window.escapeHtml(o==null?"":String(o))}function t(o,s){if(o.image){const l=o.image.charAt(0)==="/"?(window.__apiBaseUrl||"")+o.image:o.image;return'<img src="'+e(l)+'" alt="" loading="lazy" decoding="async" draggable="false">'}return o.emoji?'<span class="fav-ph fav-emoji" aria-hidden="true">'+e(o.emoji)+"</span>":'<span class="fav-ph" aria-hidden="true">'+e(s.slice(0,1))+"</span>"}function n(o){const s=o.name||"未命名",l=o.key?' data-key="'+e(o.key)+'"':"";let r="";if(o.is_favorited!==void 0){const a=!!o.starDisabled,d="fav-star-icon"+(o.is_favorited?" favorited":"")+(a?" is-disabled":""),p=a?"仅作品支持收藏":o.is_favorited?"取消收藏":"收藏";r='<button type="button" class="'+d+'" '+(a?'aria-disabled="true" ':"")+'data-action="toggle-favorite" title="'+p+'" aria-label="'+p+'"><svg viewBox="0 0 24 24" fill="'+(o.is_favorited?"currentColor":"none")+'" stroke="currentColor" stroke-width="2"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></button>'}else o.meta&&(r='<span class="fav-row-time">'+e(o.meta)+"</span>");const c=[o.ref,o.desc].filter(function(a){return!!a}).join(" · "),u=c?'<div class="fav-row-desc">'+e(c)+"</div>":"";return'<div class="fav-icon" title="'+e(o.title||s)+'" role="button" tabindex="0" aria-label="'+e(o.ariaLabel||"打开 "+s)+'"'+l+(o.attrs||"")+'><div class="fav-cover">'+t(o,s)+'</div><div class="fav-row-info"><div class="fav-row-top"><span class="'+e(o.nameClass||"fav-name")+'">'+e(s)+"</span>"+r+"</div>"+u+"</div></div>"}function i(o,s){o.classList.toggle("favorited",s);const l=s?"取消收藏":"收藏";o.setAttribute("title",l),o.setAttribute("aria-label",l);const r=o.querySelector("svg");r&&r.setAttribute("fill",s?"currentColor":"none")}window.MyFavorites.renderCard=n,window.MyFavorites.setStarState=i})();(function(){if(window.AdminCard&&window.AdminCard.__installed)return;function e(i){return ItemCard.menuHtml(i||[])}function t(i){return'<div class="item-card admin-card'+(i.className?" "+i.className:"")+'"'+(i.attrs||"")+">"+(i.coverHtml||"")+'<div class="item-info"><div class="item-info-top"><div class="item-name">'+(i.nameHtml||"")+'</div></div></div><div class="item-card-footer"><div class="admin-foot-meta">'+(i.footMetaHtml||"")+"</div>"+(i.footChipsHtml||"")+(i.footCountHtml||"")+e(i.menuItems||[])+"</div></div>"}function n(){document.querySelectorAll(".item-menu-popup.open, .item-menu-popup.open-up").forEach(function(i){i.classList.remove("open","open-up")}),document.querySelectorAll(".item-card.menu-open").forEach(function(i){i.classList.remove("menu-open")})}window.AdminCard={__installed:!0,html:t,closePopups:n}})();(function(){if(window.WorkAdminCard&&window.WorkAdminCard.__installed)return;function e(s){let l=s.thumb_url||s.image_url||"";return l&&l.startsWith("/")&&(l=(window.__apiBaseUrl||"")+l),l?'<div class="item-cover-wrap"><img class="admin-avatar-inner" src="'+escapeHtml(l)+'" alt="" loading="lazy"></div>':'<div class="item-cover-wrap">'+window.avatarHtml(s.emoji?"emoji:"+s.emoji:"",s.name,"admin-avatar-inner")+"</div>"}const t={approved:!0,"visible-to":!0,forked:!0,"delivery-adopted":!0,"delivery-published":!0,recycled:!0};function n(s){return(window.workCardBadges?window.workCardBadges(s):[]).filter(l=>!t[l.key]).map(l=>l.label).join(" · ")}function i(s){return[String(s.ref||(s.id!=null?"WORKS-"+s.id:"")),(s.brief||"").trim()].filter(Boolean).join(" · ")}function o(s){const l=n(s);return AdminCard.html({attrs:' data-item-type="'+escapeHtml(s.item_type||"works")+'" data-item-id="'+s.id+'"',coverHtml:e(s),nameHtml:escapeHtml(s.name||"WORKS-"+s.id),footMetaHtml:escapeHtml(i(s)),footCountHtml:escapeHtml([l,s.author||"",fmtTime(s.updated_at)].filter(Boolean).join(" · "))})}window.WorkAdminCard={__installed:!0,html:o}})();(function(){if(window.MyHistory&&window.MyHistory.__installed)return;function e(r){return ItemCard.normalizeType(r)}const t=r=>StatusNotify.error(r),n=()=>window.currentUser();let i=[];async function o(r,c,u){const a=await window.api("/api/my/browse-history?limit="+c+"&offset="+r+(u?"&q="+encodeURIComponent(u):""));return a&&Array.isArray(a.items)?a:{items:[],total:0,has_more:!1}}const s=WorkListWindow.defineWindow({id:"browseHistory",title:"浏览记录",identity:function(){const r=n();return r&&r.id!=null?r.id:null},list:{name:"browseHistory",pageSize:20,search:"pull",searchPlaceholder:"搜索浏览记录(编号 / 标题)",rootClass:"panel-scope",fetchPage:o,renderItem:function(r){return WorkAdminCard.html(r)},emptyText:"最近三天还没有浏览记录",countLabel:function(r){return typeof r=="number"&&r>0?"共 "+r+" 条记录(最近三天)":""},onLoaded:function(){i=s.list&&s.list()?s.list().getItems():i},onCardClick:function(r){l(r.item_type||"works",r.id)}}});async function l(r,c){const u=WorkActions.normalizeWorkArgs(r,c);r=u.itemType,c=u.id;const a=e(r);let d=i.find(function(w){return w&&e(w.item_type)===a&&Number(w.id)===Number(c)});if(!d&&window.WorkItemCache&&(d=window.WorkItemCache.get(a,c)),!d)try{const w=await window.api("/api/my/browse-history?limit=100");d=(w&&Array.isArray(w.items)?w.items:[]).find(function(f){return f&&e(f.item_type)===a&&Number(f.id)===Number(c)})}catch{}if(!d)return window.ItemViewOrchestrator&&typeof ItemViewOrchestrator.resolveAndOpen=="function"?ItemViewOrchestrator.resolveAndOpen(a,c,{viewer:n(),notify:t}):(t("该内容已失效或已隐藏"),!1);const p=window.ItemViewOrchestrator;return!p||typeof p.openItem!="function"?(t("详情组件未加载,请稍候重试"),!1):(p.openItem(d,{itemType:a,viewer:n(),notify:t}),!0)}window.MyHistory={__installed:!0,openBrowseHistoryItem:l}})();(function(){if(window.MY_FEATURES&&window.MY_FEATURES.__installed)return;function e(n){window.AppShell.navigate("/feature/"+n)}function t(n,i,o){return Interact.launch({wait:function(){var s=n();return s&&i?s:null},open:function(s){i(s)},fail:o})}window.MY_FEATURES=[{id:"qeAgent",icon:"🤖",label:"智能体",desc:"对话与自动化能力,按权限开放",entry:"agent",viewId:"agent",href:"/feature/agent",open:function(){e("agent")}},{id:"qeGame",icon:"🎮",label:"游戏",desc:"可玩作品合集",entry:"game",viewId:"game",href:"/feature/game",open:function(){e("game")}},{id:"qePPT",icon:"📊",label:"PPT",desc:"演示文稿类作品",entry:"ppt",viewId:"ppt",href:"/feature/ppt",open:function(){e("ppt")}},{id:"qeWord",icon:"📄",label:"WORD",desc:"文档类作品",entry:"word",viewId:"word",href:"/feature/word",open:function(){e("word")}},{id:"qeExcel",icon:"📈",label:"EXCEL",desc:"表格类作品",entry:"excel",viewId:"excel",href:"/feature/excel",open:function(){e("excel")}},{id:"qeDraw",icon:"🎨",label:"绘画",desc:"绘画与图像类作品",entry:"draw",viewId:"draw",href:"/feature/draw",open:function(){e("draw")}},{id:"qeSkill",icon:"⚡",label:"技能",desc:"可复用的技能与工具",entry:"skill",viewId:"skill",href:"/feature/skill",open:function(){e("skill")}},{id:"qeDesktopApp",icon:"💻",label:"桌面应用",desc:"桌面应用入口",entry:"desktop_app",viewId:"desktop_app",href:"/feature/desktop_app",open:function(){e("desktop_app")}},{id:"qeHistory",icon:"🕘",label:"浏览记录",desc:"最近浏览过的作品",entry:"history",viewId:"history",href:"/feature/history",sidebar:!1,settingsEntry:!0,open:function(){e("history")}},{id:"qeWorkSearch",icon:"🔍",label:"作品检索",desc:"按标题 / 编号检索作品",entry:"work_search",viewId:"work_search",href:"/feature/work_search",sidebar:!1,settingsEntry:!0,open:function(){e("work_search")}},{id:"qeMcpBrowser",icon:"🌳",label:"MCP 浏览器",desc:"浏览 MCP 工具与资源",entry:"mcp_browser",sidebar:!1,settingsEntry:!0,open:function(){return t(function(){return window.MyMcpBrowser},function(){AppWindows.open("mcpBrowser")},"MCP 浏览器加载失败,请重试")}},{id:"qeMyRole",icon:"🪪",label:"我的角色",desc:"查看自己的角色与权限",entry:"my_role",viewId:"my_role",href:"/feature/my_role",sidebar:!1,settingsEntry:!0,open:function(){e("my_role")}},{id:"qeUsers",icon:"👥",label:"用户管理",desc:"账号管理",entry:"users",viewId:"users",href:"/feature/users",sidebar:!1,settingsEntry:!0,open:function(){e("users")}},{id:"qeRoles",icon:"🎭",label:"角色管理",desc:"角色与权限配置",entry:"roles",viewId:"roles",href:"/feature/roles",sidebar:!1,settingsEntry:!0,open:function(){e("roles")}},{id:"qeLevels",icon:"🏆",label:"等级管理",desc:"等级与晋升配置",entry:"levels",viewId:"levels",href:"/feature/levels",sidebar:!1,settingsEntry:!0,open:function(){e("levels")}},{id:"qeNewUser",icon:"🧭",label:"新用户管理",desc:"新用户默认角色类",entry:"newuser",viewId:"newuser",href:"/feature/newuser",sidebar:!1,settingsEntry:!0,open:function(){e("newuser")}},{id:"qeProxyService",icon:"🛰️",label:"系统代理服务 配置",desc:"系统代理服务配置",entry:"proxy_service",viewId:"proxy_service",href:"/feature/proxy_service",sidebar:!1,settingsEntry:!0,open:function(){e("proxy_service")}}],new URLSearchParams(location.search).get("entry")==="work_search"&&window.addEventListener("spa:ready",function(){window.AppShell.navigate("/feature/work_search")},{once:!0}),window.MY_FEATURES.__installed=!0})();function Je(e){return encodeURIComponent(e)}function It(e){if(!e)return"";try{return fmtListTime(e)}catch{return""}}function et(e,t,n){const i=e.slice(t,t+n);return{items:i,total:e.length,has_more:t+i.length<e.length}}function gt(e,t,n){const i=(t||"").trim().toLowerCase();return i?e.filter(function(o){const s=n(o);return((s.name||"")+" "+(s.desc||"")).toLowerCase().indexOf(i)!==-1}):e}function Mt(e){if(window.ImageRender&&typeof ImageRender.coverUrl=="function"){const n=ImageRender.coverUrl(e);if(typeof n=="string")return n}let t=e&&(e.thumb_url||e.image_url)||"";return t&&t.startsWith("/")&&(t=(window.__apiBaseUrl||"")+t),t}function Pt(e){return(e&&e.item_type?String(e.item_type):"works")+":"+Number(e&&e.id)}function Nt(e){if(!e)return;const t=ItemCard.normalizeType?ItemCard.normalizeType(e.item_type||"works"):e.item_type||"works";ItemViewOrchestrator.openItem(e,{itemType:t,viewer:window.currentUser(),notify:function(n){window.StatusNotify&&StatusNotify.error(n)}})}function Zn(e){const t=e&&e.item_type||"works";return ItemCard.normalizeType?ItemCard.normalizeType(t):t}function $t(e,t){MyFavorites.setStarState(e,t)}async function ei(e,t){const n=Zn(e),i=Number(e&&e.id);if(!i)return;const o=t.classList.contains("favorited");$t(t,!o);try{await TypedApi.toggleFavorite(n,i),e.is_favorited=!o,window.StatusNotify&&StatusNotify.ok(o?"已取消收藏":"已收藏")}catch(s){$t(t,o),window.StatusNotify&&StatusNotify.error(s.message||"操作失败")}}function Zt(e){const t=window.__gate;if(t&&t.entries&&t.entries[e]!==!0)throw new Error("没有权限访问该界面")}const ti={entry:"history",emptyText:"最近三天还没有浏览记录",pageSize:30,fetchPage:async function(e,t,n){const i=await window.api("/api/my/browse-history?limit="+t+"&offset="+e+(n?"&q="+Je(n):""));return{items:i&&Array.isArray(i.items)?i.items:[],total:Number(i&&i.total)||0,has_more:!!(i&&i.has_more)}},toCard:function(e){return{key:"history:"+Pt(e),name:e.name||"未命名",ref:e.ref||"",desc:e.brief||"",meta:It(e.viewed_at||e.updated_at||e.created_at),is_favorited:!!e.is_favorited,image:Mt(e),emoji:e.emoji}},open:Nt},ni={entry:"work_search",emptyText:"没有匹配的作品",pageSize:30,fetchPage:async function(e,t,n){Caps.requireCommunityRead();const i=await window.api("/api/community/search?limit="+t+"&offset="+e+(n?"&q="+Je(n):""));return{items:i&&Array.isArray(i.items)?i.items:[],total:Number(i&&i.total)||0,has_more:!!(i&&i.has_more)}},toCard:function(e){return{key:"search:"+Pt(e),name:e.name||"未命名",ref:e.ref||"",desc:e.brief||"",meta:It(e.updated_at||e.published_at||e.created_at),is_favorited:!!e.is_favorited,image:Mt(e),emoji:e.emoji}},open:Nt},ii={entry:"users",emptyText:"没有匹配的用户",pageSize:30,fetchPage:async function(e,t,n){const i=await window.api("/api/admin/users"+(n?"?q="+Je(n):"")),o=i&&Array.isArray(i.items)?i.items:[];return et(o,e,t)},toCard:function(e){const t=[e.role].concat((e.custom_roles||[]).map(function(n){return n.name||""})).filter(function(n){return!!n});return{key:"user:"+e.id,name:e.username||"U"+e.id,desc:t.join(" · "),is_favorited:!1,starDisabled:!0,image:e.avatar_url||"",emoji:"👤"}},open:function(e){AdminPanels.openUserDetail(Number(e.id),String(e.username||""))}},en={entry:"roles",emptyText:"还没有角色",pageSize:30,fetchPage:async function(e,t,n){const i=await window.api("/api/admin/roles"),o=gt(i&&Array.isArray(i.items)?i.items:[],n,en.toCard);return et(o,e,t)},toCard:function(e){const t=Number(e.member_count)||0;return{key:"role:"+e.id,name:e.name||"未命名角色",desc:(e.description||"等级类 "+(e.role_class||"user"))+(t?" · "+t+" 人":""),is_favorited:!1,starDisabled:!0,emoji:e.avatar||"🎭"}},open:function(e){const t=function(){window.AdminRolesPanel&&window.AdminRolesPanel.openDetail(e,{})};typeof window.__bootAdminUsers=="function"?(window.__bootAdminUsers(),t()):window.LateGate&&window.LateGate.ensure&&window.LateGate.ensure("__bootAdminUsers").then(function(n){typeof n=="function"&&n(),t()}).catch(function(){})}},tn={entry:"levels",emptyText:"等级链为空",pageSize:30,fetchPage:async function(e,t,n){const i=await window.api("/api/admin/role-classes"),o=(i&&Array.isArray(i.items)?i.items:[]).filter(function(l){return l.active}),s=gt(o,n,tn.toCard);return et(s,e,t)},toCard:function(e){const t=Number(e.member_count)||0;return{key:"level:"+e.name,name:"等级 "+e.level,desc:"权限键 "+(Number(e.key_count)||0)+" 项 · 角色行 "+(Number(e.role_count)||0)+" 个"+(t?" · "+t+" 人挂载":""),is_favorited:!1,starDisabled:!0,emoji:e.avatar||"🏆"}},open:function(){AdminPanels.openLevels()}},nn={entry:"newuser",emptyText:"没有可配置的角色类",pageSize:30,fetchPage:async function(e,t,n){const o=await window.api("/api/admin/newuser-config")||{},s=[{kind:"guest",name:"游客默认角色类",desc:String(o.guest_class||"—"),meta:"现生效",emoji:"🧭"},{kind:"register",name:"注册默认角色类",desc:String(o.register_class||"—"),meta:"仅新注册",emoji:"🌱"}];(Array.isArray(o.classes)?o.classes:[]).forEach(function(c){s.push({kind:"class",name:"等级 "+c.level+" · "+c.name,desc:"档位 "+(c.grade||"—")+" · "+(Number(c.key_count)||0)+" 个权限键",meta:"",emoji:c.avatar||"🏅"})});const r=gt(s,n,nn.toCard);return et(r,e,t)},toCard:function(e){return{key:"newuser:"+e.kind+":"+e.name,name:e.name,desc:e.desc+(e.meta?" · "+e.meta:""),is_favorited:!1,starDisabled:!0,emoji:e.emoji}},open:function(){AdminPanels.openNewUser()}},rn={entry:"my_role",emptyText:"当前账号未持有角色",pageSize:30,fetchPage:async function(e,t,n){const i=await window.api("/api/admin/roles"),o=((window.__me||{}).roles||[]).map(function(l){return String(l)}),s=gt((i&&Array.isArray(i.items)?i.items:[]).filter(function(l){return o.indexOf(String(l.name))!==-1}),n,rn.toCard);return et(s,e,t)},toCard:function(e){const t=Number(e.member_count)||0;return{key:"myrole:"+e.name,name:e.name||"未命名角色",desc:(e.description||"等级类 "+(e.role_class||"user"))+(t?" · "+t+" 人":""),is_favorited:!1,starDisabled:!0,emoji:e.avatar||"🪪"}},open:function(){AdminPanels.openMyRole()}},ri={entry:"proxy_service",emptyText:"没有可选的代理账号",pageSize:30,fetchPage:async function(e,t,n){const i=await window.api("/api/proxy-service/users"+(n?"?q="+Je(n):"")),o=await window.api("/api/proxy-service/config").catch(function(){return null}),s=o&&o.account||null,l=[];return l.push({__current:!0,id:0,user_id:s?s.user_id:0,username:s?String(s.username||""):"未设置",avatar_url:s?s.avatar_url:""}),s&&l.push({__clear:!0,id:0,username:"清除当前代理",avatar_url:""}),(i&&Array.isArray(i.items)?i.items:[]).forEach(function(r){l.push(r)}),et(l,e,t)},toCard:function(e){const t=e;return t.__clear?{key:"proxy:clear",name:"清除当前代理",desc:"点按后全站代理会话入口随之收起",is_favorited:!1,starDisabled:!0,emoji:"🧹"}:t.__current?{key:"proxy:current",name:"当前代理 · "+(t.username||"未设置"),desc:"全站代理会话账号;点开该账号主页",is_favorited:!1,starDisabled:!0,image:t.avatar_url||"",emoji:"🛰️"}:{key:"proxy:"+t.id,name:t.username||"U"+t.id,desc:"点按设为全站代理账号(立即生效)",is_favorited:!1,starDisabled:!0,image:t.avatar_url||"",emoji:"👤"}},open:async function(e){const t=e;if(t.__current){t.user_id&&typeof window.openUserProfile=="function"&&window.openUserProfile(t.user_id);return}const n=!!t.__clear;if(!(!window.MobileShell||typeof window.MobileShell.confirm!="function"||!await window.MobileShell.confirm(n?"确定清除当前代理账号?":"把「"+(t.username||"U"+t.user_id)+"」设为全站代理账号?")))try{await window.api("/api/proxy-service/config",{method:"POST",body:JSON.stringify({user_id:n?null:t.id})}),window.StatusNotify&&StatusNotify.ok(n?"已清除代理账号":"已设置为代理账号"),window.MY_FEATURES&&typeof window.MY_FEATURES.__refreshView=="function"&&window.MY_FEATURES.__refreshView("proxy_service")}catch(o){window.StatusNotify&&StatusNotify.error(o.message||"操作失败")}}};function Ue(e){return{entry:e,emptyText:"还没有相关作品",pageSize:30,hero:!0,fetchPage:async function(t,n,i){Zt(e),Caps.requireCommunityRead();const o=await window.api("/api/community/category/"+Je(e)+"?limit="+n+"&offset="+t+(i?"&q="+Je(i):""));return{items:o&&Array.isArray(o.items)?o.items:[],total:Number(o&&o.total)||0,has_more:!!(o&&o.has_more)}},toCard:function(t){return{key:Pt(t),name:t.name||"未命名",ref:t.ref||"",desc:t.brief||"",meta:It(t.updated_at||t.published_at||t.created_at),is_favorited:!!t.is_favorited,image:Mt(t),emoji:t.emoji}},open:Nt}}const oi={history:ti,work_search:ni,users:ii,roles:en,levels:tn,newuser:nn,my_role:rn,proxy_service:ri,agent:Ue("agent"),game:Ue("game"),ppt:Ue("ppt"),word:Ue("word"),excel:Ue("excel"),draw:Ue("draw"),skill:Ue("skill"),desktop_app:Ue("desktop_app")},ai=5e3,xt=6,zt=.25,si=.4,li=24,ci=140,ui=.35,di=.45,jt=240,fi=460,pi="cubic-bezier(.25, 1, .5, 1)",mi=350,Kt=["本期精选","编辑推荐","值得一试","冷门佳作","人气上升"],st=new WeakMap;function Ne(e,t,n){const i=document.createElement(e);return i.className=t,n!==void 0&&(i.textContent=n),i}function Rt(){try{return!!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)}catch{return!1}}function Xe(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function hi(e){return document.hidden?!1:e.root.offsetParent!==null}function Fe(e){e.timer!==null&&(window.clearInterval(e.timer),e.timer=null)}function Qe(e){Fe(e),!(e.count<=1||Rt())&&(e.hovered||e.focused||e.gesture||(e.timer=window.setInterval(function(){hi(e)&&Ke(e,e.index+1,!0)},ai)))}function on(e){return e.looped?((e.index-1)%e.count+e.count)%e.count:e.index}function wi(e,t){return e.looped?t+1:t}function ze(e){return e.width>0?e.width:1}function an(e){const t=getComputedStyle(e.track).transform;if(!t||t==="none")return-e.index*ze(e);try{return new DOMMatrixReadOnly(t).m41}catch{const i=t.replace(/^matrix3d?\(|\)$/g,"").split(","),o=parseFloat(i.length===16?i[12]:i[4]);return isNaN(o)?-e.index*ze(e):o}}function yi(e,t){e.settleTimer!==null&&window.clearTimeout(e.settleTimer),e.settleTimer=window.setTimeout(function(){e.settleTimer=null,Ht(e)},t+80)}function Ot(e,t,n,i){const o=e.track;if(n&&!Rt()){const s=Math.min(1,Math.abs(i||0)/Math.max(1,ze(e))),l=Math.round(jt+(fi-jt)*s);o.style.transition="transform "+l+"ms "+pi,yi(e,l)}else o.style.transition="none",e.settleTimer!==null&&(window.clearTimeout(e.settleTimer),e.settleTimer=null);o.style.transform="translate3d("+t.toFixed(2)+"px, 0, 0)"}function sn(e){const t=on(e);for(let n=0;n<e.dots.length;n++){const i=n===t,o=e.dots[n];o.classList.toggle("active",i),o.setAttribute("aria-current",i?"true":"false")}for(let n=0;n<e.slides.length;n++){const i=n===t;e.slides[n].setAttribute("aria-hidden",i?"false":"true"),e.slides[n].tabIndex=i?0:-1}}function Ht(e){e.settleTimer!==null&&(window.clearTimeout(e.settleTimer),e.settleTimer=null),e.looped&&(e.index===0?e.index=e.count:e.index===e.count+1&&(e.index=1)),Ot(e,-e.index*ze(e),!1),sn(e),e.gesture||Qe(e)}function Ke(e,t,n){if(!e.count)return;const i=e.looped?e.count+1:e.count-1,o=Math.max(0,Math.min(i,Math.round(t))),s=an(e);e.index=o,Ot(e,-o*ze(e),n,-o*ze(e)-s),sn(e),(!n||Rt())&&Ht(e)}function Gt(e,t){const n=Math.max(1,t*di);return n*e/(e+n/Math.max(.01,ui))}function Ct(e,t,n,i){const o=Ne("div","feat-hero-slide");if(o.setAttribute("role","group"),o.setAttribute("aria-roledescription","幻灯片"),o.setAttribute("aria-label",t+1+" / "+n+":"+e.name),o.setAttribute("tabindex",i?"-1":"0"),o.setAttribute("data-key",e.key),i&&(o.setAttribute("aria-hidden","true"),o.setAttribute("data-clone","1")),e.image){const p=Ne("div","feat-hero-media");p.setAttribute("aria-hidden","true");const w=document.createElement("img");w.alt="",w.setAttribute("loading","lazy"),w.setAttribute("decoding","async"),w.setAttribute("draggable","false"),w.src=e.image,w.addEventListener("error",function(){p.parentNode&&p.parentNode.removeChild(p)}),p.appendChild(w),o.appendChild(p)}const s=Ne("div","feat-hero-veil");if(s.setAttribute("aria-hidden","true"),o.appendChild(s),!e.image&&e.emoji){const p=Ne("div","feat-hero-ghost",e.emoji);p.setAttribute("aria-hidden","true"),o.appendChild(p)}const l=Ne("div","feat-hero-body"),r=e.label||Kt[t%Kt.length];l.appendChild(Ne("div","feat-hero-label",r)),l.appendChild(Ne("h3","feat-hero-title",e.name||"未命名")),e.desc&&l.appendChild(Ne("p","feat-hero-desc",e.desc));const c=Ne("div","feat-hero-row"),u=Ne("div","feat-hero-icon");if(u.setAttribute("aria-hidden","true"),e.byline||e.authorAvatar){const p=window.avatarHtml&&typeof window.avatarHtml=="function"?window.avatarHtml({avatar_url:e.authorAvatar||"",username:e.byline||""}):"";p?u.innerHTML=p:u.textContent=(e.byline||"作").slice(0,1)}else if(e.image){const p=document.createElement("img");p.alt="",p.setAttribute("loading","lazy"),p.setAttribute("decoding","async"),p.setAttribute("draggable","false"),p.src=e.image,u.appendChild(p)}else e.emoji?u.textContent=e.emoji:u.textContent=(e.name||"作").slice(0,1);c.appendChild(u);const a=Ne("div","feat-hero-info");a.appendChild(Ne("div","feat-hero-name",e.byline||e.name||""));const d=[e.meta,e.ref].filter(function(p){return!!p}).join(" · ");return d&&a.appendChild(Ne("div","feat-hero-meta",d)),c.appendChild(a),c.appendChild(Ne("span","feat-hero-cta","查看")),l.appendChild(c),o.appendChild(l),o}function vi(e){const t=e.viewport;function n(p,w){const y=Xe();for(p.samples.push({x:w,t:y});p.samples.length>2&&y-p.samples[0].t>100;)p.samples.shift();p.samples.length>8&&p.samples.shift()}function i(p){if(p.samples.length<2)return 0;const w=p.samples[0],y=p.samples[p.samples.length-1],f=y.t-w.t;return f<=0?0:(y.x-w.x)/f}function o(p){const w=ze(e),y=e.looped?-(e.count+1)*w:-(e.count-1)*w;let f=p.baseOffset+p.dx;f>0?f=Gt(f,w):f<y&&(f=y-Gt(y-f,w)),e.track.style.transition="none",e.track.style.transform="translate3d("+f.toFixed(2)+"px, 0, 0)"}function s(p){p.frame||(p.frame=window.requestAnimationFrame(function(){const w=e.gesture;w&&(w.frame=0,w.axis==="x"&&o(w))}))}t.addEventListener("pointerdown",function(p){if(!p.isPrimary||p.pointerType==="mouse"&&p.button!==0||e.gesture)return;Fe(e);const w={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,baseOffset:an(e),dx:0,axis:null,samples:[{x:p.clientX,t:Xe()}],frame:0,captured:!1};e.gesture=w,e.settleTimer!==null&&(window.clearTimeout(e.settleTimer),e.settleTimer=null),e.track.style.transition="none",e.track.style.transform="translate3d("+w.baseOffset.toFixed(2)+"px, 0, 0)"}),t.addEventListener("pointermove",function(p){const w=e.gesture;if(!w||w.pointerId!==p.pointerId)return;const y=p.clientX-w.startX,f=p.clientY-w.startY;if(!w.axis){if(Math.abs(y)<xt&&Math.abs(f)<xt)return;if(Math.abs(f)>=Math.abs(y)){w.axis="y";return}if(w.axis="x",e.root.classList.add("is-dragging"),!w.captured){w.captured=!0;try{t.setPointerCapture(p.pointerId)}catch{}}}w.axis==="x"&&(w.dx=y,n(w,p.clientX),s(w))});function l(p,w){const y=e.gesture;if(!(!y||y.pointerId!==p.pointerId)){if(e.gesture=null,y.frame&&(window.cancelAnimationFrame(y.frame),y.frame=0),e.root.classList.remove("is-dragging"),y.axis==="x"&&!w){const f=ze(e),m=i(y),E=y.dx+m*ci,S=Math.abs(m)>si&&Math.abs(y.dx)>li&&(m<0?y.dx<0:y.dx>0);let L=e.index;E<-f*zt||S&&m<0?L=e.index+1:(E>f*zt||S&&m>0)&&(L=e.index-1),Ke(e,L,!0),Math.abs(y.dx)>xt&&(e.suppressClickUntil=Xe()+mi);return}Ke(e,e.index,!0)}}function r(p){l(p,!1)}function c(p){l(p,!0)}let u=0;function a(p){if(e.gesture)return;const w=Math.abs(p.deltaX)>Math.abs(p.deltaY)?p.deltaX:0;if(!w||Math.abs(w)<8)return;p.preventDefault();const y=Xe();y-u<420||(u=y,Fe(e),Ke(e,e.index+(w>0?1:-1),!0))}function d(p){p.preventDefault()}e.root.addEventListener("dragstart",d),t.addEventListener("pointerup",r),t.addEventListener("pointercancel",c),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",c),t.addEventListener("wheel",a,{passive:!1}),e.teardown.push(function(){e.root.removeEventListener("dragstart",d),t.removeEventListener("pointerup",r),t.removeEventListener("pointercancel",c),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",c),t.removeEventListener("wheel",a)})}function gi(e){function t(n){if(Xe()<e.suppressClickUntil||!n)return;const i=n;let o=typeof i.closest=="function"?i.closest(".feat-hero-slide"):null;if(o||(o=e.slides[on(e)]||null),!o)return;const s=o.getAttribute("data-key");s&&e.onOpen(s)}e.root.addEventListener("click",function(n){Xe()>=e.suppressClickUntil||(e.suppressClickUntil=0,n.preventDefault(),n.stopPropagation())},!0),e.track.addEventListener("click",function(n){t(n.target)}),e.track.addEventListener("keydown",function(n){const i=n.target;if(!!(i&&typeof i.closest=="function"&&i.closest(".feat-hero-slide"))&&(n.key==="ArrowLeft"||n.key==="ArrowRight")){n.preventDefault(),e.focused=!0,Fe(e),Ke(e,e.index+(n.key==="ArrowRight"?1:-1),!0);return}n.key!=="Enter"&&n.key!==" "&&n.key!=="Spacebar"||(n.preventDefault(),t(n.target))}),e.root.addEventListener("mouseenter",function(){e.hovered=!0,Fe(e)}),e.root.addEventListener("mouseleave",function(){e.hovered=!1,Qe(e)}),e.root.addEventListener("focusin",function(n){const i=n.target;let o=!1;try{o=!!(i&&i.matches&&i.matches(":focus-visible"))}catch{o=!1}o&&(e.focused=!0,Fe(e))}),e.root.addEventListener("focusout",function(){e.focused=!1,Qe(e)})}function bi(e,t){return function(n){n.stopPropagation(),Fe(e),Ke(e,wi(e,t),!0)}}function _i(e){const t=st.get(e);if(t){Fe(t),t.settleTimer!==null&&(window.clearTimeout(t.settleTimer),t.settleTimer=null),t.resizeObs&&(t.resizeObs.disconnect(),t.resizeObs=null);for(let n=0;n<t.teardown.length;n++)t.teardown[n]();t.teardown.length=0}st.delete(e),e.textContent=""}function Si(e){function t(){const n=e.viewport.clientWidth;!n||n===e.width||(e.width=n,Ot(e,-e.index*n,!1))}typeof ResizeObserver<"u"?(e.resizeObs=new ResizeObserver(t),e.resizeObs.observe(e.viewport)):(e.onWindowResize=t,window.addEventListener("resize",t),e.teardown.push(function(){e.onWindowResize&&(window.removeEventListener("resize",e.onWindowResize),e.onWindowResize=null)}))}function ki(e,t,n){_i(e);const i=t.filter(function(a){return!!a&&!!a.key});if(!i.length||typeof n!="function"){e.hidden=!0;return}const o=Ne("div","feat-hero");o.setAttribute("role","region"),o.setAttribute("aria-roledescription","轮播"),o.setAttribute("aria-label","精选推荐");const s=Ne("div","feat-hero-viewport"),l=Ne("div","feat-hero-track"),r=[],c=i.length>1;c&&l.appendChild(Ct(i[i.length-1],i.length-1,i.length,!0));for(let a=0;a<i.length;a++){const d=Ct(i[a],a,i.length);r.push(d),l.appendChild(d)}c&&l.appendChild(Ct(i[0],0,i.length,!0)),s.appendChild(l),o.appendChild(s);const u={root:o,viewport:s,track:l,dots:[],slides:r,count:i.length,index:c?1:0,looped:c,width:0,timer:null,settleTimer:null,onOpen:n,suppressClickUntil:0,gesture:null,hovered:!1,focused:!1,resizeObs:null,onWindowResize:null,teardown:[]};if(i.length>1){const a=Ne("div","feat-hero-dots");for(let d=0;d<i.length;d++){const p=document.createElement("button");p.type="button",p.className="feat-hero-dot"+(d===0?" active":""),p.setAttribute("aria-label","第 "+(d+1)+" 张,共 "+i.length+" 张"),p.setAttribute("aria-current",d===0?"true":"false"),p.addEventListener("click",bi(u,d)),u.dots.push(p),a.appendChild(p)}o.appendChild(a)}e.hidden=!1,e.appendChild(o),st.set(e,u),u.width=s.clientWidth||0,Si(u),vi(u),gi(u),u.track.addEventListener("transitionend",function(a){a.target!==u.track||a.propertyName!=="transform"||Ht(u)}),Ke(u,u.index,!1),Qe(u)}function Ei(e,t){const n=st.get(e);e.hidden=t,n&&(t?(n.hovered=!1,n.focused=!1,Fe(n)):Qe(n))}document.addEventListener("visibilitychange",function(){document.querySelectorAll(".feat-hero-host").forEach(function(e){const t=st.get(e);!t||e.hidden||(document.hidden?Fe(t):Qe(t))})});(function(){if(window.MY_FEATURES&&window.MY_FEATURES.__featureViewsInstalled)return;const e={};let t=!1;function n(){t||(t=!0,window.__fwContentReady=!0,window.dispatchEvent(new Event("fw:first-content")),window.__fwMark&&window.__fwMark("first-content"))}const i={};window.MY_FEATURES&&(window.MY_FEATURES.__refreshView=function(l){const r=i[l];r&&r()});function o(l,r){if(e[l])return;const c=document.querySelector('[data-app-view="feature-'+l+'"]'),u=document.getElementById("featureGrid-"+l);if(!c||!u)return;const a=c,d=u;e[l]=!0;const p="feature-"+l;let w=null;const y=document.getElementById("featureHero-"+l),f=r.heroSize||5,m={};let E=!1;function S(){if(E||!y||!r.hero||!w)return;const I=w.getItems();if(!I.length)return;const h=I.map(function(T,_){const g=r.toCard(T);return{item:T,card:g,order:_,image:g.image?1:0}}).filter(function(T){return!!T.card.key}).sort(function(T,_){return _.image-T.image||T.order-_.order}).slice(0,f);if(!h.length)return;E=!0;const x=h.map(function(T){const _=String(T.card.key||"");return m[_]=T.item,{key:_,name:T.card.name,desc:T.card.desc||"",byline:String(T.item.author_name||T.item.author||""),authorAvatar:String(T.item.author_avatar||""),meta:T.card.meta||"",ref:String(T.item.ref||""),image:T.card.image||"",emoji:T.card.emoji||""}});ki(y,x,function(T){const _=m[T];_!=null&&r.open(_)})}function L(){d.dataset.featBound!=="1"&&(d.dataset.featBound="1",d.addEventListener("click",function(I){if(I.button)return;const v=I.target,h=v.closest&&v.closest(".fav-star-icon");if(h&&d.contains(h)){if(I.preventDefault(),I.stopPropagation(),h.getAttribute("aria-disabled")==="true"){window.StatusNotify&&StatusNotify.info("仅作品支持收藏");return}const g=h.closest(".fav-icon"),B=g&&g.getAttribute("data-key");if(B!=null&&w){const A=w.getItems().find(function(k){const P=r.toCard(k);return String(P.key||"")===B});A!=null&&ei(A,h)}return}if(v.closest&&v.closest(".item-menu, .item-menu-trigger, .item-menu-popup"))return;const x=v.closest&&v.closest(".fav-icon");if(!x||!d.contains(x))return;I.preventDefault(),I.stopPropagation();const T=x.getAttribute("data-key");if(T==null||!w)return;const _=w.getItems().find(function(g){const B=r.toCard(g);return String(B.key||"")===T});_!=null&&r.open(_)}),d.addEventListener("keydown",function(I){if(I.key!=="Enter"&&I.key!==" "&&I.key!=="Spacebar")return;const v=I.target;if(!v||!v.classList||!v.classList.contains("fav-icon"))return;I.preventDefault();const h=v.getAttribute("data-key");if(h==null||!w)return;const x=w.getItems().find(function(T){const _=r.toCard(T);return String(_.key||"")===h});x!=null&&r.open(x)}))}function O(){w||(i[l]=function(){w&&w.reload()},w=ListView.bind({name:p,container:d,viewRoot:a,searchInput:document.getElementById("sbSearchInput"),searchBindEvents:!1,pageSize:r.pageSize,fetchPage:async function(I,v,h){try{return Zt(r.entry),await r.fetchPage(I,v,h)}finally{n()}},renderItem:function(I){return window.MyFavorites.renderCard(r.toCard(I))},extractId:function(I){return String(r.toCard(I).key||"")},emptyText:r.emptyText,inShell:!0,onMount:L,onLoaded:function(){S()},onLoadError:function(I){console.warn("[feature-views] "+p+" 加载失败:",I&&I.message||I)}}),a.addEventListener("sb:search",function(I){const v=I.detail,h=v&&v.query?String(v.query):"";y&&Ei(y,!!h.trim()),w&&w.resetForQuery()}),window.AppShell.registerView(p,{mount:function(){},activate:function(){w&&w.reloadIfStale(30*1e3)},deactivate:function(){}}))}window.AppShell.registerView(p,{mount:function(){},activate:function(){if(!w){O();return}w.reloadIfStale(30*1e3)},deactivate:function(){}})}function s(){if(!window.AppShell||!window.AppShell.__installed)return;(Array.isArray(window.MY_FEATURES)?window.MY_FEATURES:[]).forEach(function(r){if(!r||!r.viewId)return;const c=String(r.viewId),u=oi[c];u&&o(c,u)})}window.onDomReady(function(){if(document.querySelector(".app-shell")){s();return}let l=!1;function r(){l||(l=!0,s())}window.addEventListener("spa:shell-dom",r,{once:!0}),setTimeout(r,8e3)}),window.MY_FEATURES&&(window.MY_FEATURES.__featureViewsInstalled=!0)})();(function(){if(window.MyProfile&&window.MyProfile.__installed)return;const e=b=>{window.StatusNotify&&StatusNotify.error(b)},t=b=>{window.StatusNotify&&StatusNotify.ok(b)};let n="",i="";async function o(){await MobileShell.confirm("确定退出登录?",{title:"退出登录",confirmText:"退出",danger:!0})&&(window.__logout?window.__logout():fetch(window.apiUrl?window.apiUrl("/api/auth/logout"):"/api/auth/logout",{method:"POST"}).then(function(){location.reload()}).catch(function(){MobileShell.notify("退出失败,请检查网络后重试",{type:"error"})}))}function s(){const b=function(){const R=document.createElement("div");return R.className="settings-window",R.innerHTML='<section class="set-card"><div class="set-card-head"><span class="set-card-ico" aria-hidden="true">✏️</span><div><div class="set-card-title">昵称</div><div class="set-card-hint">留空 = 对外展示用户名</div></div></div><div class="settings-inline"><input type="text" id="setNicknameInput" maxlength="20" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" aria-label="昵称"></div></section><section class="set-card"><div class="set-card-head"><span class="set-card-ico" aria-hidden="true">🖼️</span><div><div class="set-card-title">头像</div><div class="set-card-hint">从 emoji 画布挑一个设为头像(点选即保存)</div></div></div><div class="settings-inline settings-avatar-row"><span class="settings-avatar" id="setAvatarPreview"></span><button class="link-btn set-push" id="setAvatarBtn" type="button">更换头像</button></div></section><section class="set-card"><div class="set-card-head"><span class="set-card-ico" aria-hidden="true">🔒</span><div><div class="set-card-title">修改密码</div><div class="set-card-hint">至少 6 位;留空 = 不改;更新后其他设备会被踢下线</div></div></div><div class="agent-proxy-field"><label for="setOldPwd">当前密码</label><input type="password" id="setOldPwd" autocomplete="current-password" aria-label="当前密码"></div><div class="agent-proxy-field"><label for="setNewPwd">新密码</label><input type="password" id="setNewPwd" autocomplete="new-password" aria-label="新密码"></div></section><section class="set-card"><div class="set-card-head"><span class="set-card-ico" aria-hidden="true">📧</span><div><div class="set-card-title">邮箱</div><div class="set-card-hint" id="setEmailHint">绑定后可用邮箱找回密码</div></div></div><div class="agent-proxy-field"><label for="setEmailInput">新邮箱</label><input type="email" id="setEmailInput" maxlength="255" autocomplete="email" autocapitalize="off" autocorrect="off" spellcheck="false" aria-label="新邮箱"></div><div class="auth-code-row"><input type="text" id="setEmailCode" maxlength="6" inputmode="numeric" placeholder="6 位验证码" autocomplete="one-time-code" aria-label="邮箱验证码"><button class="link-btn" id="setEmailSendBtn" type="button">获取验证码</button><button class="link-btn" id="setEmailBindBtn" type="button">绑定</button></div></section><section class="set-card"><div class="set-card-head"><span class="set-card-ico" aria-hidden="true">🌗</span><div><div class="set-card-title">外观跟随</div><div class="set-card-hint">开启后本机界面跟随外部程序(桌面工具等)的黑白模式切换(信标 10s 轮询,即刻生效;关闭 = 恢复本机手动偏好)</div></div></div><div class="settings-inline"><label class="settings-check"><input type="checkbox" id="setThemeFollowExt" aria-label="跟随外部程序主题"> 跟随外部程序主题</label></div></section><section class="set-card"><div class="set-card-hint">点保存后,以上全部修改一次保存并生效(头像在画布里点选时已即时保存)</div><div class="settings-row-btn"><button class="link-btn" id="setSaveAllBtn" type="button">保存</button></div></section><section class="set-card"><div class="set-card-head"><span class="set-card-ico" aria-hidden="true">🧰</span><div><div class="set-card-title">功能</div><div class="set-card-hint">管理与工具入口(2026-11-07 起「我的功能」网格只留内容面,这批入口收敛至此)</div></div></div><div class="set-feat-grid" id="setFeatGrid"></div></section>',R};AppWindows.define("settings",{title:"设置",render:function(R){R.appendChild(b()),r(R)}}),AppWindows.open("settings")}function l(b){b.innerHTML="",(Array.isArray(window.MY_FEATURES)?window.MY_FEATURES:[]).forEach(function(J){if(!J||!J.settingsEntry||!y(J))return;const V=document.createElement("button");V.type="button",V.className="set-feat-btn",V.setAttribute("aria-label",String(J.label||"")),V.innerHTML='<span class="set-feat-ico" aria-hidden="true">'+window.escapeHtml(J.icon||"🧩")+'</span><span class="set-feat-label">'+window.escapeHtml(J.label||"")+"</span>",V.addEventListener("click",function(){window.PlainView&&typeof PlainView.close=="function"&&PlainView.close(),J.open?J.open():J.href&&window.location.assign(J.href)}),b.appendChild(V)});const D=b.closest(".set-card");D&&(D.hidden=b.children.length===0)}function r(b){const R=Q=>b.querySelector("#"+Q),D=R("setNicknameInput");D&&(D.value=window.__me&&window.__me.nickname||"");const J=R("setAvatarPreview");J&&(J.innerHTML=avatarHtml({avatar_url:i,username:n}));const V=R("setAvatarBtn");V&&V.addEventListener("click",()=>se());const $=R("setFeatGrid");$&&l($);const ne=R("setThemeFollowExt");ne&&(ne.checked=!!(window.Theme&&window.Theme.followExt&&window.Theme.followExt()),ne.addEventListener("change",()=>{window.Theme.setFollowExt(ne.checked)&&window.ThemeSync&&window.ThemeSync.refresh()}));const C=R("setEmailHint");if(C&&window.__me){const Q=window.__me&&window.__me.email||"";C.textContent=Q?`当前:${Q}(填写新邮箱可换绑)`:"绑定后可用邮箱找回密码"}const z=R("setEmailSendBtn");let Y=0,ue=null;z&&z.addEventListener("click",async()=>{const Q=R("setEmailInput"),de=Q?Q.value.trim():"";if(!de){e("请先填写新邮箱");return}const fe=z;fe.disabled=!0;try{const ye=window.apiUrl?window.apiUrl("/api/auth/email-code"):"/api/auth/email-code",we=await fetch(ye,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({email:de,purpose:"bind"})});let Ce=null;try{Ce=await we.json()}catch{}if(!we.ok||Ce&&Ce.status==="error")throw new Error(Ce&&(Ce.message||Ce.detail)||"发送失败");t("验证码已发送,请查收邮件(含垃圾箱)"),Y=60,ue=setInterval(()=>{Y-=1,fe.textContent=Y>0?`重发(${Y}s)`:"获取验证码",Y<=0&&ue&&(clearInterval(ue),ue=null,fe.disabled=!1)},1e3)}catch(ye){e(ye.message||"发送失败"),fe.disabled=!1}});const he=R("setEmailBindBtn");he&&he.addEventListener("click",async()=>{const Q=R("setEmailInput"),de=R("setEmailCode"),fe=Q?Q.value.trim():"",ye=de?de.value.trim():"";if(!fe||!ye){e("请填写新邮箱和验证码");return}const we=he;we.disabled=!0;try{const Ce=window.apiUrl?window.apiUrl("/api/auth/me/email"):"/api/auth/me/email",U=await fetch(Ce,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({email:fe,code:ye})});let le=null;try{le=await U.json()}catch{}if(!U.ok||le&&le.status==="error")throw new Error(le&&(le.message||le.detail)||"绑定失败");window.__me&&(window.__me.email=fe),C&&(C.textContent=`当前:${fe}(填写新邮箱可换绑)`),Q&&(Q.value=""),de&&(de.value=""),t("邮箱已绑定")}catch(Ce){e(Ce.message||"绑定失败")}finally{we.disabled=!1}});const Ee=R("setSaveAllBtn");Ee&&Ee.addEventListener("click",async()=>{const Q=StatusTpl.busy(Ee,"保存中…");if(!Q)return;const de=[];try{try{const we=await window.TypedApi.updateMyProfile({nickname:D?D.value:void 0});window.__me&&D&&(window.__me.nickname=we.nickname||"")}catch(we){de.push("资料:"+(we.message||"保存失败"))}const fe=R("setOldPwd"),ye=R("setNewPwd");if(fe&&ye&&(fe.value||ye.value))if(!ye.value)de.push("密码:请填写新密码");else if(ye.value.length<6)de.push("密码:新密码至少 6 位");else if(!fe.value)de.push("密码:请填写当前密码");else try{await window.TypedApi.changePassword(fe.value,ye.value),fe.value="",ye.value=""}catch(we){de.push("密码:"+(we.message||"修改失败"))}de.length?e("部分保存失败:"+de.join(";")):t("已保存,全部修改已生效")}finally{Q()}})}const c=b=>b==="dark"?"黑夜":"浅色";let u=!1;function a(){if(!window.Theme||u)return;const b=Theme.current(),R=b==="dark"?"light":"dark";u=!0,Theme.apply(R);const D=function(){u=!1};Theme.persist(R).then(function(){t("外观已切换为"+c(R)+"模式"),D()}).catch(function(J){Theme.apply(b),e("外观保存失败:"+(J.message||"未知错误")),D()})}function d(){const b=document.querySelector("#accAppearance .acc-emoji");b&&(b.textContent=window.Theme&&Theme.current()==="dark"?"🌙":"☀️")}document.addEventListener("theme-changed",d);function p(){const b=(R,D)=>{const J=document.getElementById(R);!J||J.__bound||(J.__bound=!0,J.addEventListener("click",D))};b("accAppearance",a),b("accLogout",o)}function w(b){const R=document.getElementById("profileRoleName");R&&(R.textContent=b.nickname||(b.roles||[])[0]||b.username||"")}function y(b){const R=window.__gate||{};return b.entry?(R.entries||{})[b.entry]===!0:b.uiAction?(R.ui_actions||{})[b.uiAction]===!0:!1}function f(){const b=document.getElementById("quickEntries"),R=document.getElementById("qeGrid");if(!b||!R)return;R.innerHTML="";const D=Array.isArray(window.MY_FEATURES)?window.MY_FEATURES:[],J=window.MyFavorites&&window.MyFavorites.renderCard;let V=0;D.forEach(function($){if($.settingsEntry||!y($)||typeof J!="function")return;const ne=document.createElement($.href?"a":"div");ne.id=$.id,ne.innerHTML=J({name:$.label,desc:$.desc||"",emoji:$.icon,nameClass:"fav-name qe-label",key:$.id,attrs:' data-feature-id="'+window.escapeHtml($.id)+'"',ariaLabel:$.label}),$.href&&(ne.href=$.href),ne.addEventListener("click",function(C){$.open&&$.open()!==!1&&$.href&&C.preventDefault()}),ne.addEventListener("keydown",function(C){C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),$.open&&$.open())}),R.appendChild(ne),V++}),b.hidden=V===0}window.LayerManager&&window.LayerManager.register(".emoji-fs-overlay");const m=32,O=m*44+(m-1)*4+6*2,I=window.FW_CONTRACTS&&window.FW_CONTRACTS.HISTORY_OVERLAY_KEY||"__fwOverlay",v=window.FW_CONTRACTS&&window.FW_CONTRACTS.HISTORY_STD_MODAL_LAYER||"std-modal",h=window.__fwHistory;let x=null,T=!1,_=0,g={x:0,y:0,k:1},B=1,A=4,k=null,P=!1,j=!1;const Z=new Map;function N(b,R,D){return D<=R?(R-D)/2:Math.min(0,Math.max(R-D,b))}function ee(b){return Math.min(A,Math.max(B,b))}function ie(){const b=x&&x.__board;if(!b)return;const R=O*g.k;g.x=N(g.x,x.clientWidth,R),g.y=N(g.y,x.clientHeight,R),b.style.transform="translate("+g.x+"px,"+g.y+"px) scale("+g.k+")"}function W(){const b=window.innerWidth||0,R=window.innerHeight||0;B=Math.max(.02,Math.min(b,R)/O),A=B*4,g.k=ee(Math.max(.02,Math.max(b,R)/O)),g.x=(b-O*g.k)/2,g.y=(R-O*g.k)/2,ie()}function q(){const b=Array.from(Z.values()),R=b[0],D=b[1];return{mx:(R.x+D.x)/2,my:(R.y+D.y)/2,d:Math.hypot(R.x-D.x,R.y-D.y)||1}}function F(b){if(x){if(b.pointerType==="mouse"&&b.preventDefault(),Z.set(b.pointerId,{x:b.clientX,y:b.clientY}),Z.size===1)k={type:"pan",x0:b.clientX,y0:b.clientY,ox:g.x,oy:g.y},P=!1;else if(Z.size===2){const R=q();k={type:"pinch",d0:R.d,k0:g.k,cx:(R.mx-g.x)/g.k,cy:(R.my-g.y)/g.k},P=!0}}}function M(b){if(!(!k||!Z.has(b.pointerId))){if(Z.set(b.pointerId,{x:b.clientX,y:b.clientY}),k.type==="pan"&&Z.size===1){const R=b.clientX-k.x0,D=b.clientY-k.y0;Math.abs(R)+Math.abs(D)>4&&(P=!0),g.x=k.ox+R,g.y=k.oy+D,ie()}else if(k.type==="pinch"&&Z.size>=2){const R=q(),D=ee(k.k0*R.d/k.d0);g.k=D,g.x=R.mx-k.cx*D,g.y=R.my-k.cy*D,ie()}}}function G(b){if(Z.has(b.pointerId))if(Z.delete(b.pointerId),Z.size===1){const R=Array.from(Z.values())[0];k={type:"pan",x0:R.x,y0:R.y,ox:g.x,oy:g.y},P=!0}else Z.size===0&&(k=null)}function re(b){if(!x)return;b.preventDefault();const R=ee(g.k*(b.deltaY<0?1.15:1/1.15)),D=(b.clientX-g.x)/g.k,J=(b.clientY-g.y)/g.k;g.k=R,g.x=b.clientX-D*R,g.y=b.clientY-J*R,ie()}function ce(b){P&&(b.stopPropagation(),b.preventDefault(),P=!1)}function H(b){b.target===x&&!P&&Se(!0)}function te(){try{const b=Object.assign({},history.state||{});return b[I]=v,history.pushState(b,""),h&&h.push(v),!0}catch{return!1}}function oe(){if(_>0){_--;return}x&&Se(!1)}function ve(){x&&Se(!0)}function Se(b){const R=x;if(R){if(x=null,T){if(h)try{h.pop(v)}catch{}try{window.removeEventListener("popstate",oe)}catch{}if(b!==!1){_++;try{history.go(-1)}catch{_=Math.max(0,_-1)}}}T=!1,k=null,Z.clear();try{MobileShell.closeOverlay(R)}catch{}R.remove()}}function se(){const b=window.__EMOJI_AVATAR_POOL||[];if(!b.length||!window.MobileShell)return;x&&Se(!1);const R=document.createElement("div");R.className="emoji-fs-overlay",R.setAttribute("aria-label","选择 emoji 头像");const D=document.createElement("div");if(D.className="emoji-fs-board",b.forEach(J=>{const V=document.createElement("button");V.type="button",V.className="emoji-picker-cell",V.textContent=J,V.setAttribute("aria-label","设为头像 "+J),V.addEventListener("click",()=>{Se(!0),Ae(J)}),D.appendChild(V)}),R.appendChild(D),R.__board=D,R.addEventListener("pointerdown",F),R.addEventListener("wheel",re,{passive:!1}),R.addEventListener("click",ce,!0),R.addEventListener("click",H),R.addEventListener("contextmenu",J=>J.preventDefault()),j||(j=!0,window.addEventListener("pointermove",M),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G)),x=R,T=!1,document.body.appendChild(R),window.LayerFrame&&LayerFrame.lock(R),window.LayerManager){const J=window.LayerManager.LEVELS&&window.LayerManager.LEVELS.STD||4100;window.LayerManager.raise(R,{baseline:J,offset:1})}if(MobileShell.openOverlay(R,{onClose:ve}),T=te(),T)try{window.addEventListener("popstate",oe)}catch{}W()}async function Ae(b){try{i=(await window.TypedApi.updateMyProfile({avatar:b})).avatar_url||i,window.__me&&(window.__me.avatar_url=i);const D=document.getElementById("profileAvatar");D&&(D.innerHTML=avatarHtml({avatar_url:i,username:n},"acc-emoji"));const J=document.getElementById("setAvatarPreview");J&&(J.innerHTML=avatarHtml({avatar_url:i,username:n})),t("头像已更新")}catch(R){e(R.message||"保存失败")}}function xe(b){if(!b||b.role==="guest"){be();return}n=b.username||"",i=b.avatar_url||"";const R=b.nickname||(b.roles||[])[0]||b.username,D=document.getElementById("profileAvatar");D&&(D.innerHTML=avatarHtml({avatar_url:b.avatar_url,username:R},"acc-emoji"),D.title="打开设置",D.setAttribute("aria-label","打开设置")),w(b),D&&!D.__bound&&(D.__bound=!0,D.addEventListener("click",s),D.addEventListener("keydown",J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),s())})),p(),d(),f()}function be(){["profileAvatar","profileRoleName"].forEach(R=>{const D=document.getElementById(R);D&&(D.textContent="")}),f()}window.MyProfile={__installed:!0,render:xe,clear:be,toggleAppearance:a}})();(function(){let e={role:"guest",username:""},t=!1;const n={getUser:()=>e};window.AppShell&&window.AppShell.__installed;async function i(r){e=r||{role:"guest",username:""};const c=document.getElementById("guestTip"),u=document.getElementById("main"),a=document.getElementById("myTitle"),d=r&&Array.isArray(r.roles)&&r.roles[0]||"";if(a&&(a.textContent=d||"我的"),!r||r.role==="guest"){c&&(c.style.display=""),u&&(u.style.display="none"),window.MyProfile&&MyProfile.clear();return}c&&(c.style.display="none"),u&&(u.style.display=""),window.MyProfile&&MyProfile.render(r)}function o(){t||(t=!0,window.__me&&i(window.__me),document.addEventListener("auth:ready",function(r){i(r.detail)}))}function s(){window.MyProfile&&MyProfile.clear()}const l={name:"my",mount(){o()},activate(){},deactivate(){e&&e.role==="guest"&&s()}};window.onDomReady(function(){!!(window.AppShell&&window.AppShell.__installed)?window.AppShell.registerView("my",l):(l.mount(),l.activate())}),window.MyView={_internals:n}})();(function(e){e.McpRpc&&e.McpRpc.__installed||(e.McpRpc={__installed:!0,create:function(){let n=0,i="";async function o(l,r,c){const u={id:++n,jsonrpc:"2.0",method:l};r&&(u.params=r);const a=await fetch("/api/my/mcp-browser/rpc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:i,rpc:u})}),d=await a.json().catch(()=>({}));if((a.status===404||d.upstream_status===404)&&i&&!c)return i="",o(l,r,!0);if(!a.ok)throw new Error(d.error||d.detail||"HTTP "+a.status);d.session_id&&(i=d.session_id);const p=d.body||{};if(p.error)throw new Error(p.error.message?p.error.message+" (code "+p.error.code+")":JSON.stringify(p.error));if(d.upstream_status)throw new Error("上游返回 HTTP "+d.upstream_status+":"+(d.error||""));return p.result}async function s(l){const r=[];let c;do{const a=await o(l,c===void 0?{}:{cursor:c}),d=l.split("/")[0];Array.isArray(a&&a[d])&&r.push(...a[d]),c=a&&a.nextCursor}while(c);return r}return{rpc:o,resetSession:function(){i=""},session:function(){return i},listAll:s}}})})(window);window.McpToolForm=window.McpToolForm||function(){function e(i){const o={},s=[];return i.querySelectorAll("[data-pname]").forEach(l=>{const r=l.dataset.pname;if(l.dataset.enum){l.value!==""&&(o[r]=l.value);return}if(l.type==="checkbox"){o[r]=l.checked;return}const c=l.value.trim();if(c===""){l.dataset.required&&s.push(r+" 为必填");return}if(l.dataset.json){try{o[r]=JSON.parse(c)}catch(u){s.push(r+" 不是合法 JSON: "+u.message)}return}if(l.type==="number"){const u=Number(c);if(Number.isNaN(u)){s.push(r+" 不是数字");return}o[r]=u;return}o[r]=c}),{args:o,errors:s}}function t(i,o,s){const l=Array.isArray(o.type)?o.type[0]:o.type;let r;return Array.isArray(o.enum)?(r=document.createElement("select"),r.appendChild(new Option("","")),o.enum.forEach(c=>r.appendChild(new Option(String(c),String(c)))),r.dataset.enum="1"):l==="object"||l==="array"?(r=document.createElement("textarea"),r.placeholder=l==="array"?"[ ... ] JSON 数组":"{ ... } JSON 对象",r.dataset.json=l):(r=document.createElement("input"),r.type=l==="boolean"?"checkbox":l==="number"||l==="integer"?"number":"text",l==="integer"&&(r.step="1")),r.dataset.pname=i,r.dataset.ptype=l||"string",s&&(r.dataset.required="1"),r}function n(i,o,s){s=s||"mcpm";function l(w,y,f){const m=document.createElement(w);return y&&(m.className=y),f!=null&&(m.textContent=f),m}const r=l("div",s+"-form"),c=i.inputSchema||{},u=new Set(c.required||[]),a=Object.entries(c.properties||{});a.length||r.appendChild(l("div",s+"-kv","该工具无参数,可直接执行。")),a.forEach(([w,y])=>{const f=l("div",s+"-form-row"),m=l("label",null,w+(u.has(w)?" *":"")),E=Array.isArray(y.type)?y.type.join("|"):y.type||(y.enum?"enum":"any");m.appendChild(l("span",s==="mcpm"?"mcpm-form-typ":"typ"," ("+E+")"));const S=t(w,y,u.has(w));f.appendChild(m),f.appendChild(S),r.appendChild(f);const L=Array.isArray(y.enum)?"枚举: "+y.enum.join(" | "):"";(L||y.description)&&r.appendChild(l("div",s+"-form-hint",L+(L&&y.description?";":"")+(y.description||"")))});const d=l("button",s+"-run","执行");d.type="button",r.appendChild(d);const p=l("div",s+"-result");return p.setAttribute("aria-live","polite"),r.appendChild(p),d.addEventListener("click",async()=>{const w=window.StatusTpl.busy(d,"执行中…");if(w)try{const{args:y,errors:f}=e(r);if(p.textContent="",f.length){p.appendChild(l("div","err",f.join(";")));return}const m=await o("tools/call",{name:i.name,arguments:y});p.appendChild(l("div",m.isError?"err":"ok",m.isError?"执行返回错误:":"执行成功:"));const E=(m.content||[]).filter(S=>S.type==="text").map(S=>S.text).join(`
1736
+ `);p.appendChild(l("pre",null,E||JSON.stringify(m,null,2)))}catch(y){p.appendChild(l("div","err","调用失败:"+y.message))}finally{w()}}),r}return{collectArgs:e,build:n}}();(function(){if(window.MyMcpBrowser&&window.MyMcpBrowser.__installed)return;const{rpc:e,resetSession:t,session:n,listAll:i}=window.McpRpc.create();let o=!1;function s(g){const B={jsonrpc:"2.0",method:g};return fetch(window.apiUrl?window.apiUrl("/api/my/mcp-browser/rpc"):"/api/my/mcp-browser/rpc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:n(),rpc:B})}).catch(()=>{})}async function l(g,B,A){if(!o){o=!0,t(),r(g,"正在连接站内 MCP 服务…",""),B.children.length||B.classList.add("hidden"),A.classList.add("hidden");try{const k=await e("initialize",{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"mcp-browser",version:"1.0.0"}});await s("notifications/initialized"),r(g,"已连接:"+(k.serverInfo?k.serverInfo.name+" v"+(k.serverInfo.version||"?"):"未知服务端")+",正在读取路由清单…","");const[P,j,Z]=await Promise.all([i("tools/list").catch(ee=>(r(g,"tools 读取失败:"+ee.message,"error"),null)),i("resources/list").catch(()=>null),i("prompts/list").catch(()=>null)]);E(g,B,A,k,P,j,Z);const N=[];P&&N.push(P.length+" 个工具"),j&&N.push(j.length+" 个资源"),Z&&N.push(Z.length+" 个提示词"),r(g,"连接成功:"+N.join(","),"ok")}catch(k){r(g,"连接失败:"+k.message,"error"),A.classList.remove("hidden")}finally{o=!1}}}function r(g,B,A){g.textContent=B||"",g.className="mcpx-status"+(A?" "+A:"")}function c(g,B,A){const k=document.createElement(g);return B&&(k.className=B),A!==void 0&&(k.textContent=A),k}function u(g,B,A,k){const P=c("div","mcpx-node"),j=c("div","mcpx-row mcpx-branch");j.appendChild(c("span","mcpx-caret","▸")),B?j.appendChild(c("span","mcpx-badge "+B,g)):j.appendChild(c("span","mcpx-name mcpx-dim",g)),j.appendChild(c("span","mcpx-count",A+" 项")),P.appendChild(j);const Z=c("div","mcpx-children");return k.forEach(N=>Z.appendChild(N)),P.appendChild(Z),j.addEventListener("click",()=>P.classList.toggle("open")),P}function a(g,B,A){const k=c("div","mcpx-node"),P=c("div","mcpx-row mcpx-branch");P.appendChild(c("span","mcpx-caret","▸")),P.appendChild(c("span","mcpx-name",g)),B&&P.appendChild(c("span","mcpx-leaf-desc",B)),k.appendChild(P);const j=c("div","mcpx-detail-host");return j.appendChild(A),k.appendChild(j),P.addEventListener("click",()=>k.classList.toggle("open")),k}function d(g,B){const A=[];if(!g||typeof g!="object")return A;const k=g.properties||{},P=new Set(g.required||[]);for(const[j,Z]of Object.entries(k)){const N=Array.isArray(Z.type)?Z.type.join("|"):Z.type||(Z.enum?"enum":"any");if(A.push(B+j+(P.has(j)?" *":"")+" : "+N),Z.description&&A.push(B+" // "+Z.description),Z.enum&&A.push(B+" // 枚举: "+Z.enum.join(" | ")),Z.items&&(Z.items.type||Z.items.description||Z.items.enum)){const ee=Z.items.type||(Z.items.enum?"enum":"any");A.push(B+" [] "+ee+(Z.items.description?" // "+Z.items.description:"")),Z.items.enum&&A.push(B+" // 枚举: "+Z.items.enum.join(" | "))}}return!A.length&&g.description&&A.push(B+"// "+g.description),A}function p(g){const B=c("div","mcpx-detail"),A=d(g,"");if(A.length){const k=c("pre");A.forEach(P=>{k.appendChild(c("span",P.includes(" *")?"mcpx-schema-line req":"mcpx-schema-line",P)),k.appendChild(document.createTextNode(`
1737
+ `))}),B.appendChild(c("div","mcpx-kv","输入参数(* = 必填):")),B.appendChild(k)}else B.appendChild(c("div","mcpx-kv","无输入参数"));return B}function w(g){return McpToolForm.build(g,e,"mcpm")}function y(g){const B=p(g.inputSchema);if(g.description){const A=c("div","mcpx-detail");A.appendChild(c("span","mcpx-kv",g.description)),B.insertBefore(A,B.firstChild)}return B.appendChild(w(g)),a(g.name,"",B)}function f(g){const B=c("div","mcpx-detail");return B.appendChild(c("div","mcpx-kv","URI: ")),B.appendChild(c("code",null,g.uri||"?")),g.mimeType&&B.appendChild(c("div","mcpx-kv","MIME 类型: "+g.mimeType)),g.description&&B.appendChild(c("div","mcpx-kv",g.description)),a(g.name||g.uri,g.description||"",B)}function m(g){const B=c("div","mcpx-detail");g.description&&B.appendChild(c("div","mcpx-kv",g.description));const A=g.arguments||[];if(A.length){const k=c("pre");A.forEach(P=>{k.appendChild(c("span","mcpx-schema-line"+(P.required?" req":""),P.name+(P.required?" *":"")+" : "+(P.description||""))),k.appendChild(document.createTextNode(`
1738
+ `))}),B.appendChild(c("div","mcpx-kv","参数(* = 必填):")),B.appendChild(k)}else B.appendChild(c("div","mcpx-kv","无参数"));return a(g.name,g.description||"",B)}function E(g,B,A,k,P,j,Z){B.textContent="";const N=u(k.serverInfo&&k.serverInfo.name||"MCP Server",null,[P,j,Z].filter(Array.isArray).reduce((ie,W)=>ie+W.length,0),[]),ee=N.querySelector(":scope > .mcpx-children");if(P){const ie=u("工具 tools","tools",P.length,P.map(y));ie.classList.add("open"),ee.appendChild(ie)}j&&ee.appendChild(u("资源 resources","resources",j.length,j.map(f))),Z&&ee.appendChild(u("提示词 prompts","prompts",Z.length,Z.map(m))),N.classList.add("open"),B.appendChild(N),B.classList.remove("hidden")}let S=!1;function L(g){const B=g.querySelector("#apiTokenBtn");B.textContent="生成 Token",B.__hasToken=!1,B.addEventListener("click",O),g.querySelector("#apiTokenCopyBtn").addEventListener("click",I);const A=()=>window.api?window.api("/api/auth/me").then(k=>{S=!!(k&&k.has_api_token),B.textContent=S?"重置 Token":"生成 Token",B.__hasToken=S}).catch(()=>{}):Promise.resolve();return A(),A}async function O(){const g=document.getElementById("apiTokenBtn");if(!(!g||g.__busy)&&!(g.__hasToken&&!await MobileShell.confirm("重置后旧 Token 立即失效,确定重置?",{title:"重置 Token",confirmText:"重置",danger:!0}))){g.__busy=!0;try{const B=await window.api("/api/auth/api-token",{method:"POST"}),A=B&&B.api_token;if(!A)throw new Error("生成失败,请稍后再试");S=!0;const k=document.getElementById("apiTokenValue");k&&(k.value=A);const P=document.getElementById("apiTokenResult");P&&(P.hidden=!1);const j=document.getElementById("apiTokenDesc");j&&(j.textContent="已生成(仅显示一次,请妥善保存)"),g.textContent="重置 Token",g.__hasToken=!0,window.StatusNotify&&StatusNotify.ok("Token 已生成,请立即复制保存")}catch(B){window.StatusNotify&&StatusNotify.error(B.message||"网络错误")}finally{g.__busy=!1}}}async function I(){const g=document.getElementById("apiTokenValue");if(!(!g||!g.value))try{navigator.clipboard&&navigator.clipboard.writeText?await navigator.clipboard.writeText(g.value):(g.select(),document.execCommand("copy")),window.StatusNotify&&StatusNotify.ok("已复制")}catch{window.StatusNotify&&StatusNotify.error("复制失败,请手动选择复制")}}let v=null,h=null,x=null,T=function(){};AppWindows.define("mcpBrowser",{title:"MCP 浏览器",fill:!0,render:function(g){g.className="mcpx-body",g.innerHTML='<div class="mcpx-desc">以你的账号身份浏览站内 MCP 服务的工具 / 资源 / 提示词路由树,可直接填参试用;能调用哪些工具由你的账号权限决定。</div><div class="mcpx-status"></div><button class="mcpx-retry link-btn" type="button" hidden>重新连接</button><div class="mcpx-tree hidden"></div><div class="mcpx-token"><div class="mcpx-token-title">接入凭证(API Token)</div><div class="api-token-window"><div class="api-token-desc" id="apiTokenDesc">用于外部 AI 工具 / MCP 接入,权限等同你的账号</div><div><button class="link-btn" id="apiTokenBtn" type="button"></button></div><div class="api-token-result" id="apiTokenResult" hidden><input type="text" id="apiTokenValue" readonly autocomplete="off" spellcheck="false" aria-label="API Token(仅本次显示)"><button class="fav-edit-btn" id="apiTokenCopyBtn" type="button">复制</button></div></div></div>',v=g.querySelector(".mcpx-status"),h=g.querySelector(".mcpx-tree"),x=g.querySelector(".mcpx-retry"),x.addEventListener("click",()=>l(v,h,x)),T=L(g),l(v,h,x).then(T)}});function _(){return AppWindows.open("mcpBrowser")}window.MyMcpBrowser={__installed:!0,open:_}})();(function(){if(window.McpCallForm&&window.McpCallForm.__installed)return;const{rpc:e}=window.McpRpc.create();function t(i){return McpToolForm.build(i,e,"mcpm")}AppWindows.define("mcpToolDetail",{title:function(i){return i.tool.name},mode:"layer",fill:!0,render:function(i,o){i.className="mcpm-body",i.innerHTML="";const s=o.tool;if(s.description){const r=document.createElement("div");r.className="mcpm-detail-desc",r.textContent=s.description,i.appendChild(r)}const l=document.createElement("div");l.className="mcpm-detail-sec",l.textContent="参数与执行(* = 必填)",i.appendChild(l),i.appendChild(t(s))}});function n(i){return AppWindows.open("mcpToolDetail",{tool:i})}window.McpCallForm={__installed:!0,buildCallForm:t,openToolDetail:n}})();(function(){if(window.AdminPanels&&window.AdminPanels.__installed)return;function e(f){if(typeof f.boot=="function")try{f.boot()}catch(m){console.error("[admin-panels] 面板启动失败",m)}}function t(){return typeof window.__bootAdminUsers=="function"?Promise.resolve():window.LateGate&&typeof window.LateGate.ensure=="function"?window.LateGate.ensure("__bootAdminUsers").then(function(){}):Promise.resolve()}function n(){t().then(function(){typeof window.__bootAdminUsers=="function"&&window.__bootAdminUsers()}).catch(function(){})}function i(){t().then(function(){typeof window.__bootWorkSearch=="function"&&window.__bootWorkSearch()}).catch(function(){})}var o=null,s=!1,l=!1;function r(f,m){var E='<div id="'+f+'"><div class="lf-status">正在加载...</div></div>';return m?'<div id="'+m+'">'+E+"</div>":"<div>"+E+"</div>"}function c(f){var m=f==="roles"||f==="mcp"?"roles":f==="levels"?"levels":f==="newuser"?"newuser":"users",E;return m==="roles"?E=r("rolesBox"):m==="levels"?E=r("levelsBox"):m==="newuser"?E=r("newuserBox"):E=r("usersBox","panelUsers")+'<section id="executorUsage" hidden style="margin-top:16px;font-size:13px;line-height:1.6;"></section>','<div class="panel-scope" data-panel-mode="'+m+'"><div class="container"><div class="status-region" id="statusRegion" role="status" aria-live="polite" aria-atomic="true"></div>'+E+"</div></div>"}function u(){return'<div class="panel-scope" data-panel-mode="worksearch"><div class="container"><div id="workSearchBox"></div></div></div>'}function a(f,m){const E=m&&m.message||"打开失败";f.isConnected&&(f.innerHTML=""),window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify(E,{type:"error"})}function d(f,m){if(o!==f){o=f,AppWindows.define(f,{title:m.title,mode:"layer",actions:m.actions||[],fill:!0,onClose:m.onClose||null,render:function(S){try{S.innerHTML=m.html(),e(m)}catch(L){a(S,L)}finally{o===f&&(o=null)}}});var E=AppWindows.open(f,{host:m.host,dock:m.dock});return E||(o===f&&(o=null),window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify("弹层打开失败",{type:"error"})),E}}function p(f,m){return window.api("/api/admin/roles").then(function(E){if(!f.isConnected)return null;const L=(E&&E.items||[]).find(O=>O.name===m);if(!L)throw new Error("未找到角色「"+m+"」");return t().then(function(){return typeof window.__bootAdminUsers=="function"&&window.__bootAdminUsers(),window.AdminRolesPanel.openDetail(L,{pvBody:f})})}).then(function(E){E===!1&&f.isConnected&&(f.innerHTML="")}).catch(function(E){a(f,E)}).finally(function(){s=!1})}function w(f,m,E){return Promise.resolve().then(function(){return f.isConnected?t().then(function(){if(typeof window.__bootAdminUsers=="function"&&window.__bootAdminUsers(),!window.AdminUsersPanel||!window.AdminUsersPanel.openDetail)throw new Error("用户详情组件未就绪");return window.AdminUsersPanel.openDetail(m,E,{pvBody:f})}):null}).then(function(S){S===!1&&f.isConnected&&(f.innerHTML="")}).catch(function(S){a(f,S)}).finally(function(){l=!1})}function y(){try{return window.matchMedia("(orientation: landscape) and (min-width: 640px)").matches}catch{return!1}}window.AdminPanels={__installed:!0,workSearchShouldDock:y,openUsers:function(){d("adminUsers",{html:function(){return c("users")},title:"用户管理",boot:function(){n()},actions:['<button type="button" id="adminSearchBtn" class="pv-action-icon-btn" aria-label="搜索" title="搜索"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="10.8" cy="10.8" r="6.3"></circle><path d="m16 16 5 5"></path></svg></button>']})},openRoles:function(){d("adminRoles",{html:function(){return c("roles")},title:"角色管理",boot:function(){n()},actions:['<button type="button" id="newRoleBtn" class="pv-action-icon-btn pv-action-icon-btn-text" aria-label="新建角色" title="新建角色">+</button>']})},openLevels:function(){d("adminLevels",{html:function(){return c("levels")},title:"等级管理",boot:function(){n()},actions:['<button type="button" id="addLevelBtn" class="pv-action-icon-btn pv-action-icon-btn-text" aria-label="新增等级" title="新增等级">+</button>']})},openNewUser:function(){d("adminNewUser",{html:function(){return c("newuser")},title:"新用户管理",boot:function(){n()},actions:[]})},openWorkSearch:function(f){f=f||{};var m=f.dock;return m===void 0&&(m=f.host&&y()?"right":null),d("workSearch",{html:u,title:"作品检索",boot:function(){i()},actions:['<button type="button" id="workSearchBtn" class="pv-action-icon-btn" aria-label="搜索" title="搜索"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="10.8" cy="10.8" r="6.3"></circle><path d="m16 16 5 5"></path></svg></button>'],host:f.host,dock:m,onClose:f.onClose})},openMyRole:function(){const f=((window.__me||{}).roles||[])[0]||null;if(!f){window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify("当前账号未持有角色",{type:"error"});return}if(s)return;s=!0,AppWindows.define("myRole",{title:"我的角色",mode:"layer",fill:!0,render:function(E){p(E,f)}}),AppWindows.open("myRole")||(s=!1)},openUserDetail:function(f,m){if(!f||l)return;l=!0,AppWindows.define("userDetail",{title:"用户详情",mode:"layer",fill:!0,render:function(S){w(S,f,m)}}),AppWindows.open("userDetail")||(l=!1)}}})();class xi{constructor(){this.routes=new Map,this.currentPath="",this.registerRoutes(),this.bindEvents()}registerRoutes(){this.routes.set("/",()=>this.activateView("favorites")),this.routes.set("/favorites",()=>this.activateView("favorites")),this.routes.set("/my",()=>this.activateView("my")),this.routes.set("/login",()=>{}),this.routes.set("/register",()=>{})}bindEvents(){window.addEventListener("popstate",()=>{this.navigate(location.pathname,!1)}),document.addEventListener("click",t=>{var s;if(t.defaultPrevented||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.button!==0)return;const n=t.target.closest("a");if(!n||!n.href)return;const i=n.target;if(i&&i!=="_self"||n.hasAttribute("download")||(s=n.getAttribute("href"))!=null&&s.startsWith("#"))return;const o=new URL(n.href);o.origin===location.origin&&(o.pathname.startsWith("/api/")||o.pathname.startsWith("/static/")||this.routes.has(o.pathname)&&(t.preventDefault(),this.navigate(o.pathname)))})}navigate(t,n=!0){const i=this.routes.get(t);if(!i){console.warn("[SPARouter] Unknown route:",t);return}if(n&&t!==this.currentPath)try{history.pushState(null,"",t)}catch{}this.currentPath=t,i()}activateView(t){window.AppShell&&typeof window.AppShell.activateView=="function"?window.AppShell.activateView(t):console.error("[SPARouter] AppShell not ready, cannot activate view:",t)}}window.SPARouter=xi;(window.onDomReady||function(e){e()})(async function(){try{await window.__apiReady,window.__fwMark&&window.__fwMark("boot-begin");let o=null;try{window.__fwBootPrefetch&&(o=await window.__fwBootPrefetch.bootstrap)}catch{}o||(o=await Ai()),window.__fwMark&&window.__fwMark("boot-config"),window.__STATIC_V=o.static_v,window.__EMOJI_AVATAR_POOL=o.emoji_avatar_pool,window.CDN_ENABLED=o.cdn_enabled,window.CDN_DOMAIN=o.cdn_domain;const s=document.getElementById("app");if(s){const l=document.getElementById("fwBootGate");l&&l.parentNode&&document.body.appendChild(l),s.innerHTML=Ci(o)}window.dispatchEvent(new Event("spa:shell-dom")),window.__fwMark&&window.__fwMark("shell-dom"),window.__me||(window.__me=o.user),window.AppShell&&typeof window.AppShell.init=="function"&&window.AppShell.init(),window.__fwMark&&window.__fwMark("shell-init");var t=window.AppShell&&window.AppShell.activeView||"";t!=="favorites"&&String(t).indexOf("feature-")!==0&&(window.__fwContentReady=!0,window.dispatchEvent(new Event("fw:first-content")),window.__fwMark&&window.__fwMark("first-content")),o.user&&document.dispatchEvent(new CustomEvent("auth:ready",{detail:o.user})),await Li(),window.SPARouter?new window.SPARouter().navigate(location.pathname,!1):console.error("[SPA] SPARouter not loaded"),window.__fwMark&&window.__fwMark("router-init");var n=window.AuthDeepLink&&window.AuthDeepLink.authDeepLinkMode?window.AuthDeepLink.authDeepLinkMode(location.pathname):null;if(!o.user&&n&&window.AuthPanel){var i=null;try{i=window.AuthDeepLink&&window.AuthDeepLink.sanitizeNext?window.AuthDeepLink.sanitizeNext(new URLSearchParams(location.search).get("next")):null}catch{}window.AuthPanel.open(n,i?{next:i,redirectOnSuccess:!0}:{redirectOnSuccess:!0})}if(window.Interact)Interact.arm();else{const l=document.getElementById("fwBootGate");l&&l.remove()}window.__fwMark&&window.__fwMark("gate-removed"),window.dispatchEvent(new Event("spa:ready"))}catch(o){console.error("[SPA] Boot failed:",o);const s=document.getElementById("app");if(s){s.innerHTML='<div style="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:20px;text-align:center;"><div style="max-width:360px;padding:28px;border-radius:16px;"><h2 style="margin:0 0 12px;">启动失败</h2><p id="fwBootErrMsg" style="margin:0 0 20px;color:#666;font-size:14px;word-break:break-word;"></p><button id="fwBootRetry" type="button" style="padding:10px 22px;border:none;border-radius:10px;cursor:pointer;">重试</button></div></div>';const l=document.getElementById("fwBootErrMsg");l&&(l.textContent=o.message||String(o));const r=document.getElementById("fwBootRetry");r&&r.addEventListener("click",function(){location.reload()})}if(window.Interact&&typeof Interact.forceArm=="function")Interact.forceArm();else{const l=document.getElementById("fwBootGate");l&&l.remove()}}});function Ci(e){const t=Array.isArray(e.viewer_caps)?e.viewer_caps:[],n=Array.isArray(e.permissions)?e.permissions:[],o=(t.length>0?t:n).includes("mine.read");let s="";s+='<div class="app-layout"><aside class="app-sidebar" id="appSidebar" aria-label="主导航">',s+='<div class="sb-scroll">',s+='<div class="sb-head">';var l=window.escapeHtml?window.escapeHtml(window.__SITE__&&(window.__SITE__.name||window.__SITE__.slug)||"Site"):"Site";o?s+='<a class="sb-brand" data-sb-nav="my" href="/my" title="我的"><span class="sb-avatar" id="sbAvatar" aria-hidden="true"></span><span class="sb-brand-text"><span class="sb-name" id="sbName">我的</span><span class="sb-sub">'+l+"</span></span></a>":s+='<div class="sb-brand"><span class="sb-avatar sb-avatar-logo" aria-hidden="true">🪐</span><span class="sb-brand-text"><span class="sb-name">'+l+'</span><span class="sb-sub">游客模式</span></span></div>',s+='<a class="sb-points sb-points-link" id="sbShopLink" href="/apps/works/3899/" target="_blank" rel="noopener" title="API Key 商店:扫码购买,自动发货">🛒 <span>购买 API Key</span></a>',s+="</div>",s+='<div class="sb-search" id="sbSearch"><span class="sb-ico" aria-hidden="true">🔍</span><input class="sb-search-input" id="sbSearchInput" type="search" placeholder="搜索当前页" autocomplete="off" aria-label="搜索当前视图"></div>',s+='<nav class="sb-nav">',o?s+='<a class="sb-item" data-sb-nav="favorites" href="/favorites"><span class="sb-ico" aria-hidden="true">⭐</span><span class="sb-label">收藏</span></a>':(s+='<a class="sb-item" data-sb-nav="favorites" href="/favorites"><span class="sb-ico" aria-hidden="true">⭐</span><span class="sb-label">浏览内容</span></a>',s+='<a class="sb-item sb-login-btn" href="/login"><span class="sb-ico" aria-hidden="true">👤</span><span class="sb-label">登录</span></a>'),s+="</nav>",o&&(s+='<div class="sb-sec-label">功能</div>',s+='<div class="sb-feats" id="sbFeats"></div>'),s+="</div>";var r='<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" style="display:block;margin:0 auto" aria-hidden="true"><circle cx="12" cy="12" r="9.25"/><line x1="12" y1="11.2" x2="12" y2="16.75"/><circle cx="12" cy="7.6" r="1.15" fill="currentColor" stroke="none"/></svg>';return s+='<div class="sb-bottom"><button class="sb-item sb-theme" id="sbTheme" type="button" title="外观"><span class="sb-ico" id="sbThemeIcon" aria-hidden="true">☀️</span><span class="sb-label">深色模式</span></button><button class="sb-item sb-about" type="button" title="关于"><span class="sb-ico" aria-hidden="true">'+r+'</span><span class="sb-label">关于</span></button></div>',s+="</aside>",s+='<div class="sb-scrim" id="sbScrim" aria-hidden="true"></div>',s+='<main class="app-main">',s+='<div class="sb-topbar" id="sbTopbar"><span class="sb-topbar-title" id="sbTopbarTitle"></span><button class="sb-menu-btn" id="sbMenuBtn" type="button" aria-label="打开导航" title="打开导航"><span class="sb-menu-icon" aria-hidden="true"></span></button></div>',s+='<div class="app-shell" data-app-initial="favorites">',s+='<section class="app-view app-view-my" data-app-view="my" data-app-view-title="我的" aria-hidden="true">',s+='<div class="container">',o?(s+='<h1 id="myTitle">我的</h1>',s+='<div id="guestTip" class="login-tip card" style="display:none;">当前是游客模式,<a href="/login">登录</a> 后即可查看自己的上架。</div>',s+='<div id="main" style="display:none;">',s+='<div class="card profile-card">',s+='<div class="acc-title"><span class="acc-title-text">我的账号</span></div>',s+='<div class="acc-grid">',s+='<div class="acc-icon">',s+='<span class="acc-cover" id="profileAvatar" role="button" tabindex="0" title="打开设置" aria-label="打开设置"></span>',s+='<div class="acc-name" id="profileRoleName"></div>',s+="</div>",s+='<div class="acc-icon">',s+='<button class="acc-cover acc-action" id="accAppearance" type="button" title="外观" aria-label="外观"><span class="acc-emoji" aria-hidden="true">☀️</span></button>',s+='<div class="acc-name">外观</div>',s+="</div>",s+="</div></div>",s+='<div class="card quick-entries" id="quickEntries" hidden>',s+='<div class="qe-title">我的功能</div>',s+='<div class="favorites-grid qe-grid" id="qeGrid"></div>',s+="</div>",s+='<button class="card logout-bar" id="accLogout" type="button" title="退出登录" aria-label="退出登录">退出账号</button>',s+="</div>"):(s+='<div class="guest-landing">',s+='<div class="fav-icon guest-card">',s+='<div class="fav-cover"><span class="fav-ph fav-emoji" aria-hidden="true">👋</span></div>',s+='<div class="fav-row-info">',s+='<div class="fav-row-top"><span class="fav-name">欢迎来到游客模式</span></div>',s+='<div class="fav-row-desc">你可以自由浏览公开内容,登录后使用完整功能。</div>',s+='<div class="guest-actions"><a href="/login" class="guest-login">登录</a><a href="/register" class="guest-register">去注册</a></div>',s+="</div></div></div>"),s+="</div>",s+="</section>",s+='<section class="app-view app-view-favorites" data-app-view="favorites" data-app-view-title="'+(o?"我的收藏":"浏览内容")+'" data-sb-search="1">',s+='<div id="favoritesViewGrid" class="favorites-grid fav-view-host"></div>',s+='<div id="favViewSkeleton" class="skeleton-grid"></div>',s+="</section>",o&&Array.isArray(window.MY_FEATURES)&&window.MY_FEATURES.forEach(function(c){if(!c||!c.viewId)return;const u=String(c.viewId),a=String(c.label||"");s+='<section class="app-view app-view-feature" data-app-view="feature-'+u+'" data-app-view-title="'+window.escapeHtml(a)+'" data-sb-search="1" aria-hidden="true">',s+='<div class="feat-hero-host" id="featureHero-'+u+'" hidden></div>',s+='<div id="featureGrid-'+u+'" class="favorites-grid fav-view-host"></div>',s+="</section>"}),s+="</div></main></div>",s}function Ti(e,t){const n=typeof AbortController=="function"?new AbortController:null,i=n?setTimeout(function(){n.abort()},t):null;return fetch(e,n?{signal:n.signal}:void 0).then(function(o){if(!o.ok)throw new Error("bootstrap http "+o.status);return o.json()}).then(function(o){return i&&clearTimeout(i),o},function(o){throw i&&clearTimeout(i),o})}async function Ai(){const e=window.apiUrl?window.apiUrl("/api/bootstrap"):"/api/bootstrap";let t=null;for(let n=0;n<2;n++)try{return await Ti(e,3e3)}catch(i){t=i,n===0&&await new Promise(function(o){setTimeout(o,300)})}throw t||new Error("启动配置加载失败,请检查网络后重试")}function Li(){return new Promise(e=>{if(window.AppShell&&window.AppShell.__installed){e();return}const t=setInterval(()=>{window.AppShell&&window.AppShell.__installed&&(clearInterval(t),e())},50);setTimeout(()=>{clearInterval(t),console.warn("[SPA] AppShell wait timeout, proceeding anyway"),e()},5e3)})}(function(){if(window.ItemViewReactions&&window.ItemViewReactions.__installed)return;function e(){return window.ItemView&&window.ItemView._internals||null}function t(){const h=e(),x=h&&h.getRoot();return x?x.closest(".pv-scroll")||x:null}function n(){return WorkActionRegistry.me()}function i(h){return window.ViewCounter&&typeof ViewCounter.formatCount=="function"?ViewCounter.formatCount(h):String(Number(h)||0)}function o(h,x){const T=h.querySelector(".giv-count");T&&(T.textContent=Fmt.count(x))}function s(h,x){h.classList.toggle("active",!!x),h.setAttribute("aria-pressed",x?"true":"false")}async function l(h,x){if(h.dataset.busy||!__requireLogin(x==="like"?"点赞":"收藏"))return;const T=e(),_=T&&T.getItem(),g=T&&T.commentTargetType();if(!g||!_)return;h.dataset.busy="1";const B=h.classList.contains("active"),A=x==="like"?"like_count":"favorite_count",k=Number(_[A])||0;s(h,!B),o(h,B?Math.max(0,k-1):k+1);try{const P=await window.api(`/api/reactions/${g}/${_.id}/${x}`,{method:"POST"});s(h,P.active),o(h,P.count),_[A]=P.count,x==="like"&&window.ViewCounter&&typeof ViewCounter.updateStats=="function"&&ViewCounter.updateStats(_,(T.getCtx()||{}).itemType,["likes"])}catch(P){s(h,B),o(h,k),MobileShell.notify(P.message,{type:"error"})}finally{delete h.dataset.busy}}async function r(h,x){if(n().role==="guest")return;const T=e(),_=T&&T.getItem(),g=T&&T.commentTargetType();if(!(!g||!_))try{const B=await window.api(`/api/reactions/${g}/${_.id}/mine`);s(h,B.liked),s(x,B.favorited)}catch{}}const c=300,u=380,a=450,d=100,p=20,w=600,y=600;let f=0,m=null;function E(h,x){const T=document.createElement("div");T.className="giv-dtap",T.style.left=h+"px",T.style.top=x+"px",T.style.setProperty("--giv-dtap-r",(Math.random()*28-14).toFixed(1)+"deg");const _=["#fe2c55","#ff7aa2","#ffa940"];let g="";for(let B=0;B<6;B++)g+=`<i class="giv-dtap-spark" style="--a:${(B*60+Math.random()*30-15).toFixed(1)}deg;background:${_[B%3]}"></i>`;T.innerHTML=`
1739
+ <span class="giv-dtap-ring"></span>
1740
+ <svg class="giv-dtap-heart" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>
1741
+ ${g}`,document.body.appendChild(T),setTimeout(()=>T.remove(),1200)}function S(h,x){if(E(h,x),!__requireLogin("点赞"))return;e();const T=t(),_=T&&T.querySelector(".giv-like");if(_){if(_.classList.contains("active")){s(_,!0);return}l(_,"like")}}function L(h){return!!(h&&h.closest&&h.closest("a,button,input,textarea,[contenteditable]"))}function O(h,x,T,_,g){const B=Date.now(),A=_==="touch"?h.winTouch:h.winMouse;if(h.lastTap&&B-h.lastTap.t<A&&Math.hypot(x-h.lastTap.x,T-h.lastTap.y)<=d){h.timer&&(clearTimeout(h.timer),h.timer=null),h.lastTap=null,S(x,T);return}h.lastTap={t:B,x,y:T},h.timer&&clearTimeout(h.timer),h.timer=g?setTimeout(()=>{h.timer=null;const k=e();!k||!k.getRoot()||!k.getItem()||g()},A):null}function I(h,x,T,_){const g={lastTap:null,timer:null,winTouch:_&&_.touch||(x?c:a),winMouse:_&&_.mouse||(x?u:a)},B=A=>T?typeof T=="function"?!!T(A):!!(A&&A.closest&&A.closest(T)):!0;h.addEventListener("touchstart",A=>{if(m&&Date.now()-m.t<1e3)return;const k=A.changedTouches[0];k&&(m={id:k.identifier,x:k.clientX,y:k.clientY,t:Date.now()})},{passive:!0}),h.addEventListener("touchend",A=>{if(!m)return;let k=null;for(let j=0;j<A.changedTouches.length;j++)if(A.changedTouches[j].identifier===m.id){k=A.changedTouches[j];break}if(!k)return;const P=m;m=null,!(Math.hypot(k.clientX-P.x,k.clientY-P.y)>p)&&(Date.now()-P.t>w||L(A.target)||!B(A.target)||(f=Date.now(),O(g,k.clientX,k.clientY,"touch",x)))},{passive:!0}),h.addEventListener("touchcancel",A=>{if(m){for(let k=0;k<A.changedTouches.length;k++)if(A.changedTouches[k].identifier===m.id){m=null;break}}},{passive:!0}),h.addEventListener("click",A=>{Date.now()-f<y||L(A.target)||!B(A.target)||O(g,A.clientX,A.clientY,"mouse",x)}),h.addEventListener("dblclick",A=>{!L(A.target)&&B(A.target)&&A.preventDefault()})}function v(h){const x=e(),T=x&&x.getItem();if(!h||!T)return;const _=h.querySelector(".giv-like"),g=h.querySelector(".giv-fav");_.addEventListener("click",()=>l(_,"like")),g.addEventListener("click",()=>l(g,"favorite")),o(_,T.like_count),o(g,T.favorite_count),r(_,g)}window.ItemViewReactions={__installed:!0,bindBarActions:v,bindDoubleTapZone:I,viewCountText:i}})();(function(){if(window.ItemViewVersions&&window.ItemViewVersions.__installed)return;function e(){return window.ItemView&&window.ItemView._internals||null}function t(){const s=e();return s&&s.getItem()}function n(){const s=e();return s&&s.getCtx()}function i(s,l){if(window.SkillView)SkillView.open({content:l||"(无描述)",name:"v"+s+" 描述"});else{const r=e();r&&r.notify("查看器未加载,无法查看备注","error")}}function o(){const s=t(),l=n(),r=e();if(!s||!window.ItemCard||typeof ItemCard.fetchVersions!="function")return;const c=window.ViewLaunch&&typeof ViewLaunch.pickImageClick=="function"?ViewLaunch.pickImageClick(s,l.itemType):void 0,u=((window.__gate||{}).card_actions||{})[GateKeys.card.SET_DEFAULT],a=!!(window.WorkActionRegistry&&typeof WorkActionRegistry.isItemAuthor=="function"&&WorkActionRegistry.isItemAuthor(s)),d=!!s.is_locked,p=!!u&&typeof u=="object"&&u[a?"own":"all"]===!0&&!d,w=String(s.ref||""),y=((window.__gate||{}).card_actions||{})[GateKeys.card.COPY_FORK],f=!!y&&typeof y=="object"&&!!(y.own||y.all)&&typeof ItemCard.canFork=="function"&&ItemCard.canFork(s,l.itemType);let m=[];const E=()=>Number(ItemCard.displayVersion(s))||0,S=I=>{const v=r.getVersionSelect();if(typeof v=="function"){v(I);return}if(ItemCard.selectedVersions){const h=l.itemType+":"+String(s.id);ItemCard.selectedVersions.set(h,I)}};function L(I,v){const h=Number(I&&I.version)||0,x=[];return x.push({action:"view-note",label:"查看备注",data:{v:h}}),f&&x.push({action:"copy-fork",label:"拷贝",data:{v:h}}),h!==v&&p&&x.push({action:"set-default",label:"设置",data:{v:h}}),x}function O(){const I=E();return{sections:[{title:"",extraClass:"flush",entriesHtml:'<div class="giv-vlist">'+m.map(h=>{const x=Number(h&&h.version)||0;if(!x)return"";const T=!!(h&&h.readable===!1),_=(h&&h.description_md||"").trim(),g=_?_.split(`
1742
+ `):[];for(;g.length&&!g[0].trim();)g.shift();const B=(g.shift()||"").trim().replace(/^#+\s*/,""),A=g.join(`
1743
+ `).trim();return RelationEntry.cardHtml({badge:"v"+x,badgeCur:x===I,title:B,titleNone:!B,detail:A,detailNone:!A,time:h&&h.created_at,timeFull:window.fmtFullTime?fmtFullTime(h&&h.created_at):"",menuItems:L(h,I),dataAttrs:{v:String(x)},note:T?"不可读":"",extraClass:T?"giv-vcard-muted":"",clickable:c||T?"card":""})}).join("")+"</div>"}],footerHtml:""}}RelationPanel.open({title:"版本历史",errorText:"版本历史加载失败",fetch:async()=>{const I=await ItemCard.fetchVersions(l.itemType,s.id);return m=Array.isArray(I)?I:[],m.length?O():{sections:[],footerHtml:'<div class="giv-panel-empty">暂无版本记录</div>'}},actions:{"view-note":I=>{const v=Number(I.dataset.v)||0,h=m.find(x=>Number(x&&x.version)===v);i(v,h&&h.description_md||"")},"copy-fork":async I=>{const v=Number(I.dataset.v)||0;if(await MobileShell.confirm("拷贝后会在你的作品里生成一个隐藏状态副本(可在「我的」编辑上架)。")){try{I.disabled=!0,r.notify("正在拷贝…","info");const x=await window.api(`/api/works/${w}/fork`,{method:"POST",body:JSON.stringify({version:v})});r.notify(x&&x.name?`已拷贝为「${x.name}」(在我的作品里)`:"已拷贝到我的作品","success")}catch(x){r.notify(x&&x.message||"拷贝失败","error")}I.disabled=!1}},"set-default":async(I,v)=>{const h=Number(I.dataset.v)||0;I.disabled=!0;try{await r.applyDefaultVersion(s,h),v.rerender(O())}finally{I.disabled=!1}}},onEntryClick:I=>{const v=Number(I.dataset.v)||0;if(!v)return;const h=m.find(T=>Number(T&&T.version)===v);if(h&&h.readable===!1){r.notify("此版本内容不可读,无法运行","error");return}if(!c)return;S(v);const x=ViewLaunch.pickImageClick(s,l.itemType,{version:v});typeof x=="function"&&x()}})}window.ItemViewVersions={__installed:!0,open:o}})();if(!window.ItemView){let e=function(){return WorkActionRegistry.me()},t=function(){return WorkActionRegistry.isManagerRole()},n=function(b,R){window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify(b,{type:R||"info"})},i=function(b){return WorkActionRegistry.isItemAuthor(b)},o=function(){const b=F&&F.itemType||"";return b==="works"?b:null},s=function(b){if(!b.author)return null;const R=window.ItemCard&&ItemCard.authorLinkTarget?ItemCard.authorLinkTarget(b):b.author_id!=null?b.author_id:b.author_username||b.author,D=window.ItemCard&&ItemCard.authorDisplayName?ItemCard.authorDisplayName(b):b.author,J=document.createElement("a");return J.className="giv-topauthor",J.href="/u/"+encodeURIComponent(R),J.dataset.u=String(R),J.setAttribute("aria-label","进入 "+D+" 的主页"),J.innerHTML=avatarHtml({avatar_url:b.author_avatar||"",username:D}),J.addEventListener("click",V=>{if(V.preventDefault(),typeof window.openUserProfile=="function")window.openUserProfile(J.dataset.u);else{const $=J.dataset.u,ne=Number($),C=function(z){z.open(Number.isFinite(ne)&&String(ne)===$?ne:$)};window.ProfileView?C(window.ProfileView):window.LateGate&&window.LateGate.ensure&&window.LateGate.ensure("ProfileView").then(function(z){z&&C(z)}).catch(function(){})}}),J},l=function(b,R){if(!R||!window.WorkActionRegistry)return;const D=F&&F.itemType||R.item_type||"works",J=WorkActionRegistry.buildViewerCtx(R,e(),!1,D),V=WorkActionRegistry.renderActions(R,D,WorkActionRegistry.resolveActions(R,J));if(!V)return;b.insertAdjacentHTML("beforeend",V);const $=b.lastElementChild;$.setAttribute("data-item-type",D),$.setAttribute("data-item-id",String(R.id)),$.setAttribute("data-action-surface","itemview")},r=function(b){const R=document.createElement("div");return R.className="giv-baracts",R.innerHTML=`
1744
+ <button type="button" class="giv-bact giv-like" aria-pressed="false" aria-label="点赞" title="点赞">
1745
+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>
1746
+ <span class="giv-count"></span>
1747
+ </button>
1748
+ <button type="button" class="giv-bact giv-fav" aria-pressed="false" aria-label="收藏" title="收藏">
1749
+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>
1750
+ <span class="giv-count"></span>
1751
+ </button>
1752
+ <button type="button" class="giv-bact giv-toc" aria-label="导航" title="导航">
1753
+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 6h18M3 12h18M3 18h18"/></svg>
1754
+ </button>`,l(R,b),R},c=function(b){const R=b&&b.querySelector(".giv-toc");R&&R.addEventListener("click",()=>{const D=q&&q.querySelector(".giv-desc");D&&k(D,re)})},u=function(b){const R=b&&b.latest_version,D=typeof R=="boolean"?0:Number(R);return Number.isInteger(D)&&D>=1?D:0},a=function(b){if(window.ItemCard&&typeof ItemCard.displayVersion=="function")return ItemCard.displayVersion(b);const R=u(b);if(!R)return 0;const D=b&&b.default_version,J=typeof D=="boolean"?0:Number(D);return Number.isInteger(J)&&J>=1&&J<=R?J:R},d=function(b){const R=Number(F&&F.version)||0;if(R<1)return 0;const D=u(b);return D>=1&&R>D?0:R!==a(b)?R:0},p=function(b){const R=b&&b.ref?String(b.ref):b&&b.id!=null?"#"+String(b.id):"",D=d(b)||a(b);return R&&D?R+"_V"+D:R},w=function(b){const R=q&&q.querySelector(".giv-id-badge");R&&(R.textContent=p(b))},y=function(b){if(!window.ItemCard||typeof ItemCard.effectiveVersion!="function")return;const R=F.itemType+":"+String(b.id);ce=D=>{ItemCard.selectedVersions&&ItemCard.selectedVersions.set(R,D)}},f=function(b){return typeof F.onImageClick=="function"?F.onImageClick:window.ViewLaunch&&typeof window.ViewLaunch.pickImageClick=="function"?window.ViewLaunch.pickImageClick(b,F.itemType,{hideUnapprovedImage:!!F.hideUnapprovedImage,version:Number(F.version)||0}):null},m=function(b){return Md.sanitize(b)},E=function(b){const R=document.createElement("div");return R.innerHTML=m(b),window.Md&&typeof Md.enhance=="function"&&Md.enhance(R),R.querySelectorAll('a[href^="#"]').forEach(D=>{D.removeAttribute("target"),D.removeAttribute("rel"),D.classList.add("giv-md-anchor")}),R},S=function(b,R){const D=E(R);for(;D.firstChild;)b.appendChild(D.firstChild);I(b)},L=function(b){return b.nodeType===1&&(b.tagName==="IMG"||b.tagName==="VIDEO")},O=function(b){const R=[];for(let D=0;D<b.childNodes.length;D++){const J=b.childNodes[D];if(J.nodeType===3){if((J.textContent||"").trim())return null}else if(L(J))R.push(J);else return null}return R.length?R:null},I=function(b){Array.prototype.slice.call(b.children).forEach(J=>{if(!(!J.classList||!J.classList.contains(oe))){for(;J.firstChild;)b.insertBefore(J.firstChild,J);b.removeChild(J)}}),Array.prototype.slice.call(b.children).forEach(J=>{if(J.tagName!=="P")return;const V=O(J);V&&(V.forEach($=>b.insertBefore($,J)),b.removeChild(J))});const R=[];let D=[];Array.prototype.slice.call(b.children).forEach(J=>{J.tagName==="VIDEO"?(D.length&&(R.push(D),D=[]),R.push([J])):J.tagName==="IMG"?D.push(J):D.length&&(R.push(D),D=[])}),D.length&&R.push(D),R.forEach(J=>{const V=document.createElement("div");V.className=oe+" giv-mgrid-"+Math.min(J.length,3),b.insertBefore(V,J[0]),J.forEach($=>V.appendChild($))})},v=function(b){b.addEventListener("click",R=>{const D=R.target&&R.target.closest?R.target.closest("img"):null;if(!D||!b.contains(D)||D.closest("a"))return;const J=D.currentSrc||D.getAttribute("src")||"";!J||!(window.ImagePreview&&typeof ImagePreview.open=="function")||(R.preventDefault(),ImagePreview.open(J))})},h=function(b){return(b||"").trim().replace(/\s+/g,"-")},x=function(b,R){const D=[],J=R?R.slugs:new Map;return J.clear(),b.querySelectorAll("h1, h2, h3, h4").forEach(V=>{V.id||(V.id="giv-h-"+D.length);const $=(V.textContent||"").trim();D.push({level:Number(V.tagName.charAt(1)),text:$,id:V.id});const ne=h($);ne&&!J.has(ne)&&J.set(ne,V)}),R&&(R.entries=D),D},T=function(b,R,D){if(!D)return null;const J=R&&R.slugs.get(D);return J||Array.prototype.find.call(b.querySelectorAll("h1, h2, h3, h4"),V=>V.id===D)||null},_=function(b,R){const D=q&&q.querySelector(".cfr-scroll");if(!D||!b||!R||!R.isConnected)return;const J=12,V=()=>Math.max(0,R.getBoundingClientRect().top-D.getBoundingClientRect().top+D.scrollTop-J),$=()=>Math.max(0,D.scrollHeight-D.clientHeight);let ne=0,C=0,z=0,Y=null,ue=D.scrollTop;function he(){clearTimeout(C),C=setTimeout(fe,800)}function Ee(){!ne&&window.requestAnimationFrame&&(ne=window.requestAnimationFrame(Q))}function Q(){if(ne=0,!R.isConnected||!D.isConnected){fe();return}const we=Math.min(V(),$())-D.scrollTop;Math.abs(we)>2&&(D.scrollTop+=we,ue=D.scrollTop),he()}function de(){Math.abs(D.scrollTop-ue)>1&&fe()}function fe(){ne&&window.cancelAnimationFrame&&window.cancelAnimationFrame(ne),ne=0,clearTimeout(C),clearTimeout(z),Y&&(Y.disconnect(),Y=null),b.removeEventListener("load",Ee,!0),D.removeEventListener("scroll",de),D.removeEventListener("wheel",fe),D.removeEventListener("touchstart",fe),D.removeEventListener("keydown",fe),D.style.overflowAnchor=""}D.style.overflowAnchor="none",D.scrollTop=Math.min(V(),$()),ue=D.scrollTop,window.ResizeObserver&&(Y=new ResizeObserver(Ee),Y.observe(b)),b.addEventListener("load",Ee,!0),D.addEventListener("scroll",de,{passive:!0}),D.addEventListener("wheel",fe,{passive:!0}),D.addEventListener("touchstart",fe,{passive:!0}),D.addEventListener("keydown",fe),he(),z=setTimeout(fe,5e3)},g=function(b,R,D){let J=b.querySelector(".giv-mdtoc");if(!J){let ne=null;for(const C of b.children)if(C.tagName==="P"&&ve.test((C.textContent||"").trim())){ne=C;break}if(!ne)return;J=document.createElement("div"),J.className="giv-mdtoc",ne.replaceWith(J)}const V=document.createElement("div");V.className="giv-mdtoc-title",V.textContent="目录";const $=document.createElement("div");D.forEach(ne=>{const C=document.createElement("button");C.type="button",C.className="giv-mdtoc-item",C.style.paddingLeft=(ne.level-1)*14+14+"px",C.textContent=ne.text||"(无标题)",C.addEventListener("click",()=>Se(b,R,ne.id)),$.appendChild(C)}),J.innerHTML="",J.appendChild(V),J.appendChild($)},B=function(b){const R=re;b.addEventListener("click",D=>{const J=D.target&&D.target.closest?D.target.closest('a[href^="#"]'):null;if(!J||!b.contains(J))return;D.preventDefault();const V=(J.getAttribute("href")||"").slice(1),$=[V];try{$.push(decodeURIComponent(V))}catch{}$.slice().forEach(ne=>$.push(h(ne)));for(const ne of $)if(T(b,R,ne)){Se(b,R,ne);return}Se(b,R,h($[1]||$[0]))})},A=function(b){if(!b||!b.isConnected)return;const R=re,D=x(b,R);g(b,R,D)},k=function(b,R){if(!b||!b.isConnected)return;const D=x(b,R),J=q&&q.querySelector(".cfr-scroll"),V=new Map;let $=0;const ne=window.requestAnimationFrame?Y=>window.requestAnimationFrame(Y):Y=>setTimeout(Y,0),C=()=>{if($=0,!J||!J.isConnected)return;let Y=se;const he=J.getBoundingClientRect().top+Math.max(72,Math.min(140,J.clientHeight*.2));b.querySelectorAll("h1, h2, h3, h4").forEach(Q=>{Q.getBoundingClientRect().top<=he&&(Y=Q.id)});let Ee=null;V.forEach((Q,de)=>{const fe=de===Y;Q.classList.toggle("cur",fe),fe&&(Ee=Q)}),Ee&&typeof Ee.scrollIntoView=="function"&&Ee.scrollIntoView({block:"nearest"})},z=()=>{$||($=ne(C))};AppWindows.define("postOutline",{title:"导航",mode:"layer",render(Y){const ue=document.createElement("div");ue.className="giv-outline";const he=()=>{const Q=document.createElement("div");Q.className="giv-outline-sep",ue.appendChild(Q)},Ee=(Q,de,fe,ye)=>{const we=document.createElement("button");we.type="button",we.className="giv-outline-item",we.textContent=Q,de!=null&&V.set(de,we),ye&&(we.dataset.level=String(ye),we.style.paddingLeft=(ye-1)*14+14+"px"),we.addEventListener("click",()=>{window.PlainView&&typeof PlainView.close=="function"&&PlainView.close(),fe()}),ue.appendChild(we)};Ee("标题",se,()=>{J&&(J.scrollTop=0)},void 0),D.length&&he(),D.forEach(Q=>{Ee(Q.text||"(无标题)",Q.id,()=>Se(b,R,Q.id),Q.level)}),Y.appendChild(ue),C()},onClose(){$&&window.cancelAnimationFrame&&window.cancelAnimationFrame($),$=0,J&&J.removeEventListener("scroll",z),V.clear()}}),J&&J.addEventListener("scroll",z,{passive:!0}),AppWindows.open("postOutline")},P=function(b,R){const D=()=>{b.innerHTML="",S(b,Md.parse(R)),A(b)};if(!R||R.length<Ae||typeof Md.lex!="function"||typeof Md.parseTokens!="function"){D();return}let J;try{J=Md.lex(R)}catch{D();return}b.innerHTML="";const V=window.requestAnimationFrame?C=>window.requestAnimationFrame(C):C=>setTimeout(C,0);let $=0;const ne=()=>{if(!b.isConnected)return;const C=J.slice($,$+xe);C.links=J.links,$+=C.length,S(b,Md.parseTokens(C)),$<J.length?V(ne):A(b)};ne()},j=function(b,R,D){const J=D&&Number(D.version)>0?Number(D.version):0;if(!J&&!R.description_truncated)return;const V=F.itemType,$=re,ne=[],C=ue=>{for(;ne.length;)ne.shift()(ue!==!1)},z=document.createElement("div");z.className="giv-desc-more",b.appendChild(z);const Y=InfiniteScroll.bind({container:b,sentinel:z,root:b.closest(".cfr-scroll"),mode:"stream",pageSize:1,initialOffset:J?0:Math.max(0,Number(R.description_next_offset)||0),emptyText:"暂无描述",fetchPage:async ue=>{const he=J?"&v="+J:"",Ee=await window.api(`/api/works/${V}/${R.id}/description-md?offset=${ue}&limit=${be}`+he);return{items:Ee&&Ee.description_md?[{md:Ee.description_md}]:[],has_more:!!(Ee&&Ee.has_more),next_offset:Ee&&typeof Ee.next_offset=="number"?Ee.next_offset:ue}},renderItem:ue=>E(Md.parse(ue.md)).innerHTML,onLoaded:()=>{I(b),A(b),$&&($.done=!Y.hasMore),C(!0)},onError:()=>C(!1)});$&&($.done=!1,$.pager=Y,$.loadMoreOnce=()=>new Promise(ue=>{if(!Y.hasMore){ue(!0);return}ne.push(ue),Y.loading||Y.loadNext()}))},Z=function(b){G=b;const R=ChatFrame.create();q=R.root,q.classList.add("giv");const D=R.scrollEl,J=F.hideUnapprovedImage&&WorkStatus.isNonPublic(b),V=!!(b.view&&(b.view.kind||b.view.decorator)),$=F.itemType==="works"&&!V,ne=!b.image_url&&!!b.emoji,C=ne&&typeof f(b)!="function",z=J?'<div class="giv-img pending">审批中...</div>':$?"":ne?C?"":'<div class="giv-img giv-emoji">'+escapeHtml(b.emoji)+"</div>":ImageRender.detail(b,{cls:"giv-img",w:720,h:480,fallback:b.emoji||"无图片"}),Y=!J&&typeof f(b)=="function"?'<span class="giv-play" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg></span>':"",ue=b.media&&b.media.url?b.media:null;if(ue&&!$&&!J){const K=document.createElement("div");K.className="giv-imgwrap giv-media";const X=document.createElement("div");if(X.className="giv-media-holder",ue.kind==="picture"){const ae=document.createElement("img");ae.src=(ue.url.charAt(0)==="/"&&window.__apiBaseUrl||"")+ue.url,ae.alt=ue.name||"",ae.style.cssText="display:block;max-width:100%;max-height:480px;margin:0 auto;border-radius:12px;",X.appendChild(ae),K.appendChild(X),D.appendChild(K)}else K.appendChild(X),D.appendChild(K),H=window.MediaPlayer?MediaPlayer.mount(X,ue):null}else z&&D.insertAdjacentHTML("beforeend",'<div class="giv-imgwrap">'+z+Y+"</div>");const he=document.createElement("div");he.className="giv-body";const Ee=window.ChipRenderer?window.ChipRenderer.renderChips(window.ChipRenderer.buildItemChips(b,{kind:b.kind||"",itemType:F.itemType,showHiddenChip:!!F.showHiddenChip})):"",Q=u(b),de=b.updated_at||b.last_published_at||b.created_at?fmtTime(b.updated_at||b.last_published_at||b.created_at):"",fe=de?Q>=1?`<button type="button" class="giv-ctime-btn" title="查看版本历史">${escapeHtml(de)}</button> · `:escapeHtml(de)+" · ":"",ye=b.forked_from&&b.forked_from.ref?`<div class="giv-forked-line"><button type="button" class="giv-forked-from" title="查看原作">拷贝自 ${escapeHtml(b.forked_from.name||b.forked_from.ref)}</button></div>`:"",we=!!(b.description||"").trim();he.innerHTML=`
1755
+ <div class="giv-name">${escapeHtml(b.name)}${p(b)?`<span class="giv-id-badge">${escapeHtml(p(b))}</span>`:""}</div>
1756
+ <div class="giv-chips">${Ee}</div>
1757
+ ${ye}
1758
+ <div class="giv-desc${we?"":" giv-desc-empty"}">${we?"":'<span class="giv-desc-placeholder">暂无描述</span>'}</div>
1759
+ <div class="giv-ctime">${fe}浏览量:<span id="givViewCount">${ItemViewReactions.viewCountText(b.view_count)}</span></div>`,D.appendChild(he);const Ce=he.querySelector(".giv-desc"),U=d(b);if(Ce&&window.Md&&(we||U)){if(re={slugs:new Map,entries:[],done:!0,loadMoreOnce:null},U){Ce.classList.remove("giv-desc-empty");const K=Ce.querySelector(".giv-desc-placeholder");K&&K.remove(),j(Ce,b,{version:U})}else P(Ce,b.description),j(Ce,b,{});B(Ce),v(Ce)}ce=null,Q>=1&&y(b);const le=he.querySelector(".giv-ctime-btn");le&&le.addEventListener("click",()=>{window.ItemViewVersions&&window.ItemViewVersions.open(String(b.id))});const _e=he.querySelector(".giv-forked-from");return _e&&b.forked_from&&b.forked_from.ref&&_e.addEventListener("click",()=>{const K=String(b.forked_from.ref||"").trim().toUpperCase();K.indexOf("WORKS-")!==0||!/^\d+$/.test(K.slice(6))||lookupRefItem(K).then(X=>{if(!X){n("作品不存在或已隐藏","error");return}window.ItemViewOrchestrator&&typeof ItemViewOrchestrator.resolveAndOpen=="function"&&ItemViewOrchestrator.resolveAndOpen(X.item_type,X.id,{notify:n})}).catch(X=>n(X&&X.message||"打开失败","error"))}),q},N=function(){const b=q.querySelector(".giv-img"),R=q.querySelector(".giv-imgwrap"),D=f(G),J=$=>{try{D(G,$)}catch{}};b&&typeof D=="function"&&(b.setAttribute("role","button"),b.setAttribute("tabindex","0"),b.style.cursor="pointer",b.addEventListener("keydown",$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),J($))})),R&&!R.classList.contains("giv-media")&&ItemViewReactions.bindDoubleTapZone(R,typeof D=="function"?J:null);const V=q.querySelector(".cfr-scroll");V&&ItemViewReactions.bindDoubleTapZone(V,null,$=>!($&&$.closest&&$.closest(".giv-imgwrap"))),q.addEventListener("click",$=>{const ne=$.target.closest("a[data-u]");if(ne&&q.contains(ne)){$.preventDefault(),window.openUserProfile(ne.dataset.u);return}})},ee=function(b,R){b.innerHTML="";const D=Z(R);D.classList.add("giv-content-enter"),b.appendChild(D),A(D.querySelector(".giv-desc"));const J=b.closest(".pv-overlay"),V=J&&J.querySelector(".pv-actions .giv-baracts"),$=r(R);V&&V.parentNode&&V.parentNode.replaceChild($,V),ItemViewReactions.bindBarActions($),c($);const ne=s(R);if(ne){const C=b.closest(".pv-scroll"),z=C&&C.querySelector(".pv-titlebar .pv-back");if(z){const Y=C.querySelector(".giv-topauthor");Y&&Y.remove(),z.insertAdjacentElement("afterend",ne)}}N()},ie=function(b){b=b||{},AppWindows.define("itemDetail",{title:b.title||"",mode:"layer",actions:b.actions||null,onClose:b.onClose||null,render:function(D){typeof b.onBody=="function"&&b.onBody(D)}});const R=AppWindows.open("itemDetail");return R?R.body:null},W=function(b){const R=(b||{}).item;if(R&&WorkStatus.isNonPublic(R)){const C=((window.__gate||{}).card_actions||{})[GateKeys.card.OPEN],z=!!(window.WorkActionRegistry&&typeof WorkActionRegistry.isItemAuthor=="function"&&WorkActionRegistry.isItemAuthor(R)),Y=!!(window.WorkActionRegistry&&typeof WorkActionRegistry.hasViewerCap=="function"&&WorkActionRegistry.hasViewerCap("work:view_hidden"))||R.view_granted===!0;if(!(R.mcp_declared===!0&&!!(window.WorkActionRegistry&&typeof WorkActionRegistry.hasViewerCap=="function"&&WorkActionRegistry.hasViewerCap("account.mcp_browser")))&&!Y&&(!C||typeof C!="object"||C[z?"own":"all"]!==!0)){window.MobileShell&&window.MobileShell.notify&&window.MobileShell.notify("没有查看该作品的权限",{type:"error"});return}}if(F&&F.item&&F.itemType&&b&&b.item&&b.itemType===F.itemType&&String(b.item.id)===String(F.item.id)&&!b.version&&!b.openVersions&&window.PlainView&&typeof PlainView.isOpen=="function"&&PlainView.isOpen())return;const D=F;if(F=b||{},!F.item||!F.itemType){const C=ie({title:F.title||"详情"});C.innerHTML=StatusTpl.placeholder("缺少条目数据"),F=null;return}!F.version&&window.ItemCard&&ItemCard.selectedVersions&&ItemCard.selectedVersions.delete(F.itemType+":"+String(F.item.id)),q&&M.push({root:q,ctx:D,currentItem:G,descState:re,versionSelect:ce,mediaDestroy:H});const J=r(F.item),V=ie({title:"",actions:[J],onClose(){if(H)try{H()}catch{}if(H=null,q=null,F=null,G=null,ce=null,re&&re.pager)try{re.pager.destroy()}catch{}re=null;const C=M.pop();C&&window.PlainView&&window.PlainView.depth>0&&(q=C.root,F=C.ctx,G=C.currentItem,ce=C.versionSelect,re=C.descState!==void 0?C.descState:null,H=C.mediaDestroy!==void 0?C.mediaDestroy:null)}});V.innerHTML=StatusTpl.loading();const $=F,ne=function(){if(!(F!==$||!V.isConnected)){try{ee(V,$.item)}catch(C){try{V.innerHTML=StatusTpl.error("详情渲染失败,请重试")}catch{}try{fetch(window.apiUrl?window.apiUrl("/api/client-errors"):"/api/client-errors",{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({items:[{k:"js",m:"detail-render-fail: "+String(C&&C.message||C).slice(0,300),s:"itemview.js buildIntoBody",u:location.pathname}]})})}catch{}return}$.openVersions&&window.ItemViewVersions&&typeof window.ItemViewVersions.open=="function"&&window.ItemViewVersions.open(String($.item.id))}};window.Motion&&typeof Motion.nextPaint=="function"?Motion.nextPaint(ne):ne()},q=null,F=null;const M=[];let G=null,re=null,ce=null,H=null;async function te(b,R){if(!(!b||G!==b))try{await window.api(`/api/works/${F.itemType}/${b.id}/versions/${R}/restore`,{method:"POST"}),b.default_version=R,n(`已把 v${R} 设为默认启动版本`,"success"),window.ItemCard&&ItemCard.selectedVersions&&ItemCard.selectedVersions.delete(F.itemType+":"+String(b.id)),w(b),F&&F.listView&&typeof F.listView.reload=="function"&&F.listView.reload()}catch(D){n(D.message||"设置失败","error")}}const oe="giv-mgrid",ve=/^\[toc\]$/i;async function Se(b,R,D){if(!b||!b.isConnected)return;let J=T(b,R,D);const V=R&&typeof R.loadMoreOnce=="function"?R.loadMoreOnce:null;!J&&V&&R&&!R.done&&n(StatusTpl.text,"info");let $=0;for(;!J&&V&&R&&!R.done;){const ne=await V();if(!b.isConnected||(J=T(b,R,D),$=ne===!1?$+1:0,$>=3))return}J&&_(b,J)}const se="__top__",Ae=3e4,xe=80,be=24576;window.ItemView=window.ItemView||{open:W,_internals:{getCtx:()=>F,getRoot:()=>q,getItem:()=>G,getVersionSelect:()=>ce,notify:n,isItemAuthor:i,isManager:t,commentTargetType:o,applyDefaultVersion:te}}}window.ItemEditView=window.ItemEditView||function(){let e=null,t=null,n=null,i=null;const o="%%%WORKS-META%%%",s="%%%WORKS-DOC%%%",l="%%%WORKS-CODE%%%",r="%%%WORKS-PYTHON%%%",c="%%%WORKS-SQL%%%",u="%%%WORKS-REGEX%%%",a="%%%WORKS-DATA%%%",d=["%%%WORKS-AGENT-PROXY%%%","%%%WORKS-WORKFLOW%%%"];function p(){injectOwnedStyle("itemeditview",`
1760
+ /* root 叠在 ChatFrame 的 .cfr 上(flex 布局由 .cfr 提供),这里只给呈现样式 */
1761
+ .ged{background:var(--neu-overlay-bg,#E0E5EC);color:var(--text-1,#5C4033);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;}
1762
+ .ged-scroll{padding:16px;box-sizing:border-box;height:100%;display:flex;flex-direction:column;}
1763
+ /* fields 包裹 div 是 .ged-scroll 的唯一直接子元素:不给 flex 链它就是
1764
+ content 高的 block 壳,.ged-group 的 flex:1 在壳内不生效(2026-10-14
1765
+ 实机探针:文本框永远停在 min-height 即此故)——壳自己接力 flex 铺到文本框 */
1766
+ .ged-fields{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;}
1767
+ .ged-group{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;}
1768
+ /* 选择器带 .ged 前缀抬特异性:formkit 的 .agent-proxy-field textarea
1769
+ (min-height:88px)在 base-body.css 里,晚于本注入块解析(late 组),
1770
+ 同级特异性下后者赢——2026-10-14 实机探针量到文本框塌成 88px 小格即此故 */
1771
+ .ged .ged-group textarea{flex:1 1 auto;min-height:240px;font-size:16px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;line-height:1.5;resize:vertical;}
1772
+ /* 底部取消/发布栏:对齐聊天底栏 .cib 的结构(flex:none 钉底 + safe-area 内边距);
1773
+ 主钮 .link-btn / 次钮 .neu-btn(标准类),此处只管排布 */
1774
+ .ged-fbar{flex:none;display:flex;gap:10px;padding:12px 12px calc(12px + env(safe-area-inset-bottom, 0px));background:var(--neu-overlay-bg,#E0E5EC);border-top:var(--neu-line,1px solid rgba(198,207,220,.45));}
1775
+ .ged-fbar button{flex:1;min-height:44px;font-size:.85rem;}`)}function w(){return!!(t&&t.item)}function y(){return(e.querySelector("#gedWorks")||{}).value||""}function f(){const v=document.createElement("div");v.className="ged-scroll";const h=document.createElement("div");h.className="ged-fields",h.innerHTML=`
1776
+ <div class="ged-group agent-proxy-field">
1777
+ <label for="gedWorks">作品(.works 格式)</label>
1778
+ <textarea id="gedWorks" spellcheck="false"></textarea>
1779
+ </div>`,v.appendChild(h);const x=v.querySelector("#gedWorks");w()?m(x):x.placeholder=`${o}
1780
+ {
1781
+ "name": "作品名",
1782
+ "brief": "一句话说明(必填,48 字以内,显示在卡片描述位)",
1783
+ "tags": "标签1,标签2",
1784
+ "emoji": "🧩"
1785
+ }
1786
+
1787
+ ${s}
1788
+ 正文 Markdown(选填段,写了就必须非空)
1789
+
1790
+ ${l}
1791
+ Work.register({ mount(ctx) { … } });(选填段)
1792
+
1793
+ ${r}
1794
+ # Python 随件内容(附加代码区四选一,至多一段)
1795
+
1796
+ ${c}
1797
+ -- SQL 随件内容(四选一)
1798
+
1799
+ ${u}
1800
+ 正则表达式随件内容(四选一)
1801
+
1802
+ ${a}
1803
+ 结构化表格数据随件内容(CSV 等,四选一,最后一段)
1804
+
1805
+ ${d[0]}
1806
+ {"name": "…", "workflow_executor_url": "…", "llm_router_url": "…", "workflow_dsl": "…", "enabled": true}(代理配置声明,选填)
1807
+
1808
+ ${d[1]}
1809
+ {"v": 3, …}(平台标准工作流图声明,选填;与 WORKFLOW-SOURCE 至多其一)`;const T=document.createElement("div");T.className="ged-fbar";const _=w()?"保存":"发布";T.innerHTML=`
1810
+ <button type="button" class="neu-btn ged-cancel" id="gedCancelBtn">取消</button>
1811
+ <button type="button" class="link-btn ged-save" id="gedSaveBtn">${_}</button>`,n.scrollEl.appendChild(v),n.mountBottom(T)}function m(v){const h=S(15e3),x=h?{credentials:"include",signal:h}:{credentials:"include"},T=window.apiUrl?window.apiUrl(`/api/works/${encodeURIComponent(t.item.id)}/bundle`):`/api/works/${encodeURIComponent(t.item.id)}/bundle`;fetch(T,x).then(_=>_.text().then(g=>{if(!_.ok){let B="";try{B=(JSON.parse(g)||{}).detail||""}catch{}throw new Error(B||"读取 .works 失败")}return g})).then(_=>{v.value=_,i=_}).catch(_=>MobileShell.notify(_&&_.name==="AbortError"?"网络请求超时,请稍后重试":_.message,{type:"error"}))}function E(){e.querySelector("#gedCancelBtn").addEventListener("click",async()=>{const v=e.querySelector("#gedWorks");i!=null&&v&&v.value!==i&&(MobileShell.notify("文本有未保存的修改",{type:"info"}),!await MobileShell.confirm("放弃未保存的修改?"))||PlainView.close()}),e.querySelector("#gedSaveBtn").addEventListener("click",O)}function S(v){return typeof AbortSignal=="function"&&typeof AbortSignal.timeout=="function"?AbortSignal.timeout(v):null}async function L(v,h,x){const T=S(3e4);let _;try{_=await fetch(v,{method:h,headers:{"Content-Type":"text/plain;charset=utf-8"},body:x,...T?{signal:T}:{}})}catch(B){throw B&&B.name==="AbortError"?new Error("网络请求超时,请稍后重试"):B}let g=null;try{g=await _.json()}catch{}if(!_.ok||g&&g.status==="error")throw new Error(g&&(g.detail||g.message)||"请求失败");return g}async function O(){const v=y();if(!v.trim()){MobileShell.notify(".works 文本不能为空",{type:"error"});return}const h=e.querySelector("#gedSaveBtn"),x=StatusTpl.busy(h,w()?"保存中...":"发布中...");if(x)try{let T;w()?T=await L(`/api/works/${encodeURIComponent(t.item.id)}/bundle`,"PUT",v):T=await L("/api/works/bundle","POST",v);const _=t.onSaved;PlainView.close(),_&&_(),MobileShell.notify(w()?"已保存为新版本":"已发布到私人仓库(隐藏状态),提交审核通过后公开",{type:"success"})}catch(T){MobileShell.notify(T.message,{type:"error"})}finally{x()}}function I(v){t=v||{},p();const h=t.title||"发布作品";AppWindows.define("publish",{title:h,mode:"layer",onClose(){e=null,t=null,n=null,i=null},render:function(x){n=ChatFrame.create(),e=n.root,e.classList.add("ged"),x.appendChild(e),f(),E()}}),AppWindows.open("publish")}return{open:I}}();window.ProfileView=window.ProfileView||function(){const e=window.escapeHtml,t=15,n=[];function i(){if(!window.WorkActionRegistry)return;const a=n.length?n[n.length-1]:null;WorkActionRegistry.registerSurfaceActions("profile",a?a.surfaceActions:null)}function o(){injectOwnedStyle("profileview",`
1812
+ .gfp{display:block;background:var(--neu-bg);color:var(--text-1);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;padding:15px 16px calc(24px + env(safe-area-inset-bottom, 0px));}
1813
+ .gfp-head{display:flex;align-items:center;gap:11px;background:var(--neu-bg);border-radius:12px;padding:14px;box-shadow:0 2px 8px rgba(0,0,0,.06);}
1814
+ /* 大头像 = 精选横幅 .feat-hero-icon 同款凹槽小徽章的放大版(2026-11-07
1815
+ 用户裁定「画风统一」):基座 neu-inset 底 + 压凹阴影,这里只补圆角与
1816
+ 尺寸;点击放大查看照旧。 */
1817
+ .gfp-head .avatar{width:64px;height:64px;font-size:1.4rem;border-radius:16px;box-shadow:var(--neu-press-xs);cursor:zoom-in;}
1818
+ .gfp-info{flex:1;min-width:0;}
1819
+ .gfp-name{font-size:20px;font-weight:700;line-height:1.3;display:flex;align-items:center;gap:6px;border-radius:7px;transition:background .15s,color .15s;}
1820
+ .gfp-name-text{flex:0 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
1821
+ .gfp-name-real{font-size:13px;font-weight:400;color:var(--text-muted);margin-left:5px;}
1822
+ .gfp-uname{font-size:13px;color:var(--text-muted);margin-top:2px;}
1823
+ .gfp-since{font-size:13px;color:var(--text-muted);margin-top:4px;}
1824
+ .gfp-views{font-size:13px;color:var(--text-muted);margin-top:4px;}
1825
+ .gfp-tag-role{display:inline-flex;align-items:center;font-size:12px;font-weight:700;flex:0 0 auto;
1826
+ padding:3px 10px;border-radius:999px;background:var(--neu-bg);color:var(--text-1);letter-spacing:.5px;}
1827
+ .gfp-tag-role.is-admin{background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:#fff;}
1828
+ .gfp-actions{margin-top:12px;display:flex;gap:10px;}
1829
+ .gfp-actions .gfp-btn{flex:1;min-height:44px;border:none;border-radius:10px;font-size:15px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px;}
1830
+ .gfp-btn:disabled{opacity:.5;}
1831
+ /* 封禁/禁言状态 chip:跟在用户名后 */
1832
+ .gfp-chip{display:inline-block;font-size:11px;font-weight:700;padding:2px 8px;border-radius:999px;margin-left:6px;vertical-align:middle;flex:0 0 auto;}
1833
+ .gfp-chip-banned{background:var(--danger-tint);color:var(--danger);}
1834
+ .gfp-chip-muted{background:#fffaf0;color:#975a16;}
1835
+ /* 管理菜单「⋯」(viewer_caps = 查看者权限键,服务端仍强制校验) */
1836
+ .gfp-admin-wrap{position:relative;flex:none;width:48px;}
1837
+ .gfp-actions .gfp-admin-wrap .gfp-btn{flex:none;width:100%;background:var(--neu-bg);color:var(--text-1);border:1px solid var(--border-soft) !important;font-size:18px;letter-spacing:1px;}
1838
+ .gfp-actions .gfp-admin-wrap .gfp-btn:active{background:var(--neu-bg);}
1839
+ .gfp-admin-popup{display:none;position:absolute;top:calc(100% + 4px);right:0;width:max-content;min-width:140px;background:var(--neu-bg);border:1px solid var(--border-soft);border-radius:8px;box-shadow:0 6px 20px rgba(0,0,0,.12);padding:4px 0;z-index:30;}
1840
+ .gfp-admin-popup.open{display:block;}
1841
+ .gfp-admin-popup button{display:block;width:100%;text-align:left;padding:10px 14px;font-size:14px;border:none;background:transparent;color:var(--text-1);cursor:pointer;}
1842
+ .gfp-admin-popup button:hover{background:var(--neu-bg);}
1843
+ .gfp-admin-popup button.danger{color:var(--danger);}
1844
+ .gfp-section{margin:18px 0 10px;font-size:15px;font-weight:700;color:var(--text-1);}
1845
+ .gfp-section .gfp-count{color:var(--text-muted);font-weight:400;font-size:13px;margin-left:6px;}
1846
+ /* 加载态 = 全站统一形:哨兵「正在加载...」居中(itemcard.css .inf-scroll-*
1847
+ 全局真源)。原 .gfp 限定副本与骨架屏(.item-card.skeleton 家族)随
1848
+ 2026-09-21 加载态统一删除——骨架卡与哨兵文案曾同时可见 = 双加载指示 */`)}function s(){return WorkActionRegistry.me()}function l(a){const d=(window.__gate||{}).role_grades||{};return(a||[]).map(function(p){const w=p==="admin"||p==="root"?" is-admin":"",y=d[p]?" "+d[p]:"";return'<span class="gfp-tag-role'+w+'" title="账号角色">'+e(p+y)+"</span>"}).join("")}function r(a){if(!a)return!1;const d=Date.parse(a);return Number.isFinite(d)?d>Date.now():!0}function c(a){const d=a.item_type||"works",p=ItemCard.resolve(a,{itemType:d,user:s(),allowModeration:!1});return ItemCard.html(a,{itemType:d,cover:!0,showStats:!0,surface:"profile",...p})}function u(){let a=null,d=null,p=null,w=0,y=null,f=null,m=null,E=null;const S=window.WorkActionRegistry&&window.WorkActions?WorkActionRegistry.buildPageWorkActions({page:"profile",reload:()=>{y&&y.reload()},listView:()=>y}):{};async function L(A,k){const P=k.id;try{if(A==="ban"){const j=window.prompt("封禁时长(小时),留空或填 0 表示永久封禁:","24");if(j===null)return;const Z=parseFloat(j);await window.TypedApi.banUser(P,Number.isFinite(Z)&&Z>0?Z:null),MobileShell.notify("已封禁",{type:"success"})}else if(A==="unban")await window.TypedApi.unbanUser(P),MobileShell.notify("已解除封禁",{type:"success"});else if(A==="mute"){const j=window.prompt("禁言时长(小时),留空或填 0 表示永久禁言:","24");if(j===null)return;const Z=parseFloat(j);await window.TypedApi.muteUser(P,Number.isFinite(Z)&&Z>0?Z:null),MobileShell.notify("已禁言",{type:"success"})}else if(A==="unmute")await window.TypedApi.unmuteUser(P),MobileShell.notify("已解除禁言",{type:"success"});else if(A==="delete"){if(!await MobileShell.confirm("确定删除账号「"+(k.nickname||k.username)+"」?其作品将转让给站点根账号,评论保留。",{title:"删除账号",confirmText:"删除",danger:!0}))return;await window.TypedApi.deleteUser(P),MobileShell.notify("账号已删除",{type:"success"})}else if(A==="userDetail"){window.AdminPanels&&typeof AdminPanels.openUserDetail=="function"?AdminPanels.openUserDetail(k.id,k.username):MobileShell.notify("用户详情组件未加载",{type:"error"});return}else return;await T(void 0)}catch(j){MobileShell.notify(j&&j.message||"操作失败",{type:"error"})}}async function O(A,k){const P=await window.TypedApi.getUserProfile(f,{limit:k,offset:A}),j=P&&P.posts||[],Z=P&&typeof P.posts_total=="number"?P.posts_total:j.length,N=!!(P&&P.posts_has_more);return{items:j,total:Z,has_more:N}}function I(){y&&(y.destroy(),y=null);const A=a&&a.querySelector("#gfpListingsGrid");if(!A||!window.ListView)return;const k=m;m=null;let P=!1;y=window.ListView.bind({name:"profile_"+f,container:A,pageSize:t,fetchPage:async(j,Z)=>k&&!P&&j===0?(P=!0,k):O(j,Z),renderItem:c,extractId:j=>{const Z=j.item_type||"works";return j&&j.id!=null?Z+":"+String(j.id):null},emptyText:"TA 还没有上架内容",emptyHintEl:null,loadingEl:null,viewRoot:null,inShell:!1,onLoaded:({total:j})=>{v(typeof j=="number"?j:null)},onEmpty:()=>v(0),onCardClick:(j,Z)=>{const N=window.ItemViewOrchestrator;!N||typeof N.openItem!="function"||N.openItem(j,{viewer:s(),hideUnapprovedImage:ItemCard.shouldHideUnapprovedImage(j,s()),notify:ee=>MobileShell.notify(ee,{type:"error"})})}})}function v(A){if(!a)return;const k=a.querySelector("#gfpListingsCount");k&&(typeof A=="number"&&A>0?k.textContent="("+A+")":k.textContent="")}function h(){if(!a||!p)return;const A=p.user,k=s(),P=!!p.is_self,j=!!k.username&&!P,Z=A.nickname||A.username,N=e(Z),ee=r(A.banned_until),ie=r(A.muted_until),W=(ee?'<span class="gfp-chip gfp-chip-banned">已被封禁</span>':"")+(ie?'<span class="gfp-chip gfp-chip-muted">已被禁言</span>':""),q=(window.__gate||{}).ui_actions||{},F=!P;let M="";F&&(q[GateKeys.ui.USER_DETAIL]===!0&&(M+='<button type="button" data-admin-action="userDetail">用户详情</button>'),q[GateKeys.ui.BAN]===!0&&(M+=ee?'<button type="button" data-admin-action="unban">解除封禁</button>':'<button type="button" data-admin-action="ban">封禁</button>'),q[GateKeys.ui.MUTE]===!0&&(M+=ie?'<button type="button" data-admin-action="unmute">解除禁言</button>':'<button type="button" data-admin-action="mute">禁言</button>'),q[GateKeys.ui.DELETE_USER]===!0&&(M+='<button type="button" class="danger" data-admin-action="delete">删除账号</button>')),a.innerHTML=`
1849
+ <div class="gfp-head">
1850
+ ${avatarHtml({avatar_url:A.avatar_url,username:A.username})}
1851
+ <div class="gfp-info">
1852
+ <div class="gfp-name"><span class="gfp-name-text">${N}</span>${W}${l(A.roles)}</div>
1853
+ ${A.nickname&&A.nickname!==A.username?`<div class="gfp-uname">@${e(A.username)}</div>`:""}
1854
+ <div class="gfp-since">${A.created_at?e(A.created_at.slice(0,10))+" 加入":""}</div>
1855
+ <div class="gfp-views"><span class="gfp-views-count">${Number(A.view_count)||0}</span> 人浏览过</div>
1856
+ </div>
1857
+ </div>
1858
+ ${j&&F&&M?`
1859
+ <div class="gfp-actions">
1860
+ ${F&&M?`
1861
+ <div class="gfp-admin-wrap">
1862
+ <button type="button" class="gfp-btn gfp-admin-btn" title="管理">⋯</button>
1863
+ <div class="gfp-admin-popup">${M}</div>
1864
+ </div>`:""}
1865
+ </div>`:""}
1866
+ <div class="gfp-section">上架<span class="gfp-count" id="gfpListingsCount"></span></div>
1867
+ <div class="items-grid" id="gfpListingsGrid" aria-busy="true"></div>`;const G=a.querySelector(".gfp-head .avatar");G&&G.addEventListener("click",()=>{window.showAvatarZoom&&window.showAvatarZoom(A.avatar_url||"",Z)}),I();const re=a.querySelector(".gfp-admin-btn"),ce=a.querySelector(".gfp-admin-popup");re&&ce&&(re.addEventListener("click",H=>{H.stopPropagation(),ce.classList.toggle("open")}),ce.addEventListener("click",H=>{const te=H.target&&H.target.closest&&H.target.closest("button[data-admin-action]");te&&(ce.classList.remove("open"),L(te.dataset.adminAction,A))}))}function x(A,k){window.TypedApi.recordProfileView(A).then(P=>{if(!(k!==w||!a||!p)&&P&&P.view_count!==void 0){p.user.view_count=P.view_count;const j=a.querySelector(".gfp-views-count");j&&(j.textContent=String(P.view_count||0))}}).catch(()=>{})}async function T(A){const P=a?a.closest(".pv-scroll"):null,j=0,Z=++w;a.innerHTML=StatusTpl.loading();try{let N;if(d.userId!==void 0&&d.userId!==null&&d.userId!==""){const ie=Number(d.userId);N=Number.isFinite(ie)?ie:null}if(N==null&&d.username){if(typeof window.resolveUsername!="function")throw new Error("缺少用户名解析通道");N=await window.resolveUsername(d.username)}if(N==null||!Number.isFinite(N))throw new Error("用户不存在");f=N;const ee=await window.TypedApi.getUserProfile(N,{limit:t,offset:0});if(Z!==w||!a)return;p=ee,m={items:Array.isArray(ee.posts)?ee.posts:[],total:typeof ee.posts_total=="number"?ee.posts_total:Array.isArray(ee.posts)?ee.posts.length:0,has_more:!!ee.posts_has_more},h(),x(p.user.id,Z)}catch(N){if(Z!==w||!a)return;a.innerHTML=StatusTpl.error(N.message==="用户不存在"?"这个用户不存在":N.message)}}function _(){w++,y&&typeof y.destroy=="function"&&y.destroy(),y=null,a=null,d=null,p=null,f=null,m=null,E&&(document.removeEventListener("click",E),E=null);const A=n.indexOf(B);A>=0&&n.splice(A,1),i()}function g(A,k){d=A||{};const P=k||{};o(),E=function(j){if(!a)return;const Z=a.querySelector(".gfp-admin-popup.open");Z&&(j.target&&j.target.closest&&j.target.closest(".gfp-admin-wrap")||Z.classList.remove("open"))},document.addEventListener("click",E),n.push(B),i(),AppWindows.define("profile",{title:"主页",mode:"layer",onClose:_,render:function(j){const Z=j.closest(".pv-overlay");P.suppressEnter&&Z&&(Z.classList.remove("shell-enter"),Z.style.transition="none",Z.style.transform="translateX(100%)"),a=document.createElement("div"),a.className="gfp",j.appendChild(a);const N=d.userId!==void 0&&d.userId!==null&&d.userId!=="",ee=typeof d.username=="string"&&d.username!=="";if(N||ee?T():a.innerHTML=StatusTpl.error("缺少用户标识"),typeof P.onOpened=="function")try{P.onOpened(Z)}catch{}}}),AppWindows.open("profile",{context:d})}const B={open:g,surfaceActions:S};return B}return{open:function(a,d){u().open(a,d)}}}();let Ie=null,Ze=[],Be=[];function ln(e){Ie=e}function cn(e){Ze=e}function bt(e){Be=e}const Ye=(e,t)=>api(e,{method:"POST",body:JSON.stringify(t||{})});function Ii(e){return e.id!==Ie.me.id}function Oe(e){return((window.__gate||{}).ui_actions||{})[e]===!0}function _t(e){e.innerHTML=StatusTpl.loading()}function Mi(e,t){const n=(e||"?").trim().charAt(0).toUpperCase()||"?";return`<div class="admin-cover-char${t?" "+t:""}">${escapeHtml(n)}</div>`}function St(e,t,n,i){return typeof window.avatarHtml=="function"?`<div class="item-cover-wrap">${window.avatarHtml({avatar_url:e,username:t})}</div>`:`<div class="item-cover-wrap">${Mi(n,i)}</div>`}function Pi(e){return St(e.avatar_url||"",e.username,e.username)}function Ni(e){return St(e.avatar||"",e.name,e.name,"role-char")}function un(e){return St(e.avatar||"",String(e.level),String(e.level))}const tt=e=>AdminCard.html(e),ut=()=>AdminCard.closePopups();function nt(e){return`<div class="items-grid">${e.join("")}</div>`}const kt=()=>Ie&&Ie.role_classes||[],He=e=>{const t=kt().find(n=>n.name===e);return t?t.level:null},Ri=e=>{const t=kt().find(n=>n.name===e);return t&&t.grade?t.grade:""},Bt=e=>{const t=He(e),n=Ri(e);return!t&&!n?"?":n?`等级 ${t} · ${n}`:`等级 ${t}`};function Oi(e){const t=e.scope==="own"?" · 仅限自己":"";return`${e.name||e.key||e.permission_key||e.board}${t}`}function Hi(e){return(e.permissions||[]).filter(t=>!(t.key||t.permission_key||"").startsWith("ai."))}function dn(e){const t=He(e);return t==null?[]:(Ie.permissions||[]).filter(n=>{const i=He(n.role_class);return i!=null&&i<t})}function fn(e){return new Set(e&&e.inherit_optout||[])}function pn(e){const t=fn(e);return(e.permissions||[]).length+dn(e.role_class).filter(n=>!t.has(n.key)).length}function mn(e){const t=Hi(e),n=e.description||(t.length?t.slice(0,2).map(Oi).join(";"):"未配置权限"),i=e.is_locked?'<span class="badge badge-locked">已锁定</span>':"";return{attrs:` data-rid="${e.id}"`,coverHtml:Ni(e),nameHtml:`${escapeHtml(e.name)}${i}`,footMetaHtml:escapeHtml(n),footCountHtml:`${e.member_count} 人在用 · ${pn(e)} 项权限`}}function hn(e){const t=[];return t.push(`<button type="button" data-admin-action="relations" data-rid="${e.id}">关系</button>`),Oe("editRole")&&t.push(`<button type="button" data-admin-action="edit" data-rid="${e.id}">编辑</button>`),Oe("lockRole")&&t.push(`<button type="button" data-admin-action="lock" data-rid="${e.id}" data-next="${e.is_locked?0:1}">${e.is_locked?"解锁":"锁定"}</button>`),Oe("deleteRole")&&t.push(`<button type="button" class="btn-danger" data-admin-action="delete" data-rid="${e.id}">删除</button>`),t}const Bi={all:"所有人",own_all:"可限定范围(仅限自己 / 所有人)",none:"—"},it="AI 工具",ft="卡片按钮";let pt=null;function wn(e,t){return new Promise((n,i)=>{if(!window.LateGate){i(new Error(t));return}window.LateGate.run(e,()=>n(),()=>i(new Error(t)))})}function Di(){return window.Md&&typeof window.Md.parse=="function"?Promise.resolve():(pt||(pt=wn("Md","markdown 引擎加载失败").catch(e=>{throw pt=null,e})),pt)}function at(e,t){const n=t==null?"":String(t);!e||!n||Di().then(()=>{if(e.isConnected)try{e.innerHTML=window.Md.sanitize(window.Md.parse(n)),window.Md.enhance(e)}catch{e.textContent=n}}).catch(()=>{e.isConnected&&(e.textContent=n)})}let mt=null;function Vi(){return window.WordDict&&window.WordDict.__installed?Promise.resolve():(mt||(mt=wn("WordDict","worddict 加载失败").catch(e=>{throw mt=null,e})),mt)}async function yn(e,t){try{await Vi()}catch(n){StatusNotify.error(n.message);return}window.WordDict.openByRef(e,t)}let ht=null;async function Fi(e){if(ht===null)try{ht=(await api("/api/admin/ai_tools")).items||[]}catch{ht=[]}return ht.find(t=>t.name===e)||null}function Wi(e){const t=[e.enabled?"":"停用(不挂 MCP 面)",e.hidden?"程序专用":"",e.admin_only?"管理位形":"",e.read_only?"只读":""].filter(Boolean).join(" · "),n=Number(e.version)||0;return`
1868
+ <h2>MCP 工具 schema</h2>
1869
+ <ul>
1870
+ <li><b>工具名</b>:<code>${escapeHtml(e.name)}</code>
1871
+ ${t?`<small>(${escapeHtml(t)})</small>`:""}</li>
1872
+ ${e.ref?`<li><b>声明作品</b>:<button type="button" class="rd-tool-work-row rd-meta-btn" title="打开声明作品详情"><code>${escapeHtml(e.ref)}${n?`_V${n}`:""}</code><span class="rd-meta-go">›</span></button>(工具 = 一份带 mcp-tool 围栏的作品,键随声明派生)</li>`:""}
1873
+ <li><b>描述(LLM 可见)</b>:<br><div class="rd-desc-md" data-md-slot="desc"></div></li>
1874
+ ${e.args_schema?'<li><b>参数说明</b>:<br><div class="rd-desc-md" data-md-slot="args"></div></li>':""}
1875
+ </ul>`}function je(e,t){AppWindows.define(e,{title:t.title,mode:"layer",actions:t.actions||null,onClose:t.onClose,render:function(i){t.content&&i.appendChild(t.content)}});const n=AppWindows.open(e);return n?n.body:null}function qi(e,t){AppWindows.mountActions(e,t)}function Dt(e,t){const n=e&&e.closest&&e.closest(".pv-overlay");if(!n)return;const i=n.querySelector(".pv-titlebar");if(!i)return;i.querySelectorAll(".pv-action-btn").forEach(u=>u.remove());const o=i.querySelector(".pv-back"),s=i.querySelector(".pv-close"),l=i.querySelector(".pv-actions"),r=t.find(u=>u&&!u.classList.contains("pv-action-btn-primary")),c=t.find(u=>u&&u.classList.contains("pv-action-btn-primary"));l&&l.remove(),r&&o&&(r.style.flex="none",o.insertAdjacentElement("afterend",r)),c&&s&&(c.style.flex="none",c.style.marginLeft="auto",s.style.marginLeft="0",s.insertAdjacentElement("beforebegin",c))}function vn({currentCls:e,isDisabled:t,disabledSuffix:n,onPick:i}){const o=document.createElement("div");o.className="perm-class-picker",o.hidden=!0;const s=document.createElement("div");s.className="pcp-title",s.textContent="选择目标等级",o.appendChild(s);const l=document.createElement("div");return l.className="pcp-options",kt().forEach(r=>{const c=r.name===e,u=!c&&t&&t(r),a=document.createElement("button");a.type="button",a.className="pcp-option",a.textContent=Bt(r.name)+(c?"(当前)":u&&n||""),a.disabled=c||u,a.addEventListener("click",()=>{l.querySelectorAll(".pcp-option.selected").forEach(d=>d.classList.remove("selected")),a.classList.add("selected"),i(r.name)}),l.appendChild(a)}),o.appendChild(l),o}const wt=e=>"";function Ui(e,t){const n=e.groups.map(r=>`
1876
+ <li class="rd-cat">${escapeHtml(r.name)}</li>
1877
+ <ul class="rd-perms">${r.rows.map(c=>`
1878
+ <li class="rd-perm${c.children?" rd-perm-parent":""}" data-key="${escapeHtml(c.key)}">
1879
+ <input type="checkbox" data-permission="1" ${c.selected?"checked":""} ${e.editable?"":"disabled"}>
1880
+ <span class="rd-perm-head">
1881
+ <button type="button" class="rd-perm-name" title="${escapeHtml(c.title||"查看介绍")}">${escapeHtml(c.name)}</button>
1882
+ ${c.children?`<button type="button" class="rd-perm-toggle" aria-expanded="false" title="展开子权限">▸ <span class="rd-perm-count">${c.children.length}</span></button>`:""}
1883
+ </span>
1884
+ ${c.sub?`<small class="rd-perm-key">${escapeHtml(c.sub)}</small>`:""}
1885
+ ${c.children?`
1886
+ <ul class="rd-perms rd-perm-children" hidden>${c.children.map(u=>`
1887
+ <li class="rd-perm rd-perm-sub" data-key="${escapeHtml(u.key)}">
1888
+ <input type="checkbox" data-permission="1" ${u.selected?"checked":""} ${e.editable?"":"disabled"}>
1889
+ <button type="button" class="rd-perm-name" title="${escapeHtml(u.title||"查看介绍")}">${escapeHtml(u.name)}</button>
1890
+ ${u.sub?`<small class="rd-perm-key">${escapeHtml(u.sub)}</small>`:""}
1891
+ </li>`).join("")}</ul>`:""}
1892
+ </li>`).join("")}</ul>`).join(""),i=(e.inheritGroups||[]).map(r=>`
1893
+ <li class="rd-cat">${escapeHtml(r.name)}</li>
1894
+ <ul class="rd-perms">${r.rows.map(c=>`
1895
+ <li class="rd-perm rd-perm-inherit${c.children?" rd-perm-parent":""}" data-key="${escapeHtml(c.key)}">
1896
+ <input type="checkbox" data-inherit="1" ${c.selected?"checked":""} ${e.editable?"":"disabled"} title="取消勾选 = 豁免该继承权限(保存后生效)">
1897
+ <span class="rd-perm-head">
1898
+ <button type="button" class="rd-perm-name" title="${escapeHtml(c.title||"查看介绍")}">${escapeHtml(c.name)}</button>
1899
+ ${c.children?`<button type="button" class="rd-perm-toggle" aria-expanded="false" title="展开子权限">▸ <span class="rd-perm-count">${c.children.length}</span></button>`:""}
1900
+ </span>
1901
+ ${c.sub?`<small class="rd-perm-key">${escapeHtml(c.sub)}</small>`:""}
1902
+ <span class="rd-inherit-badge">继承</span>
1903
+ ${c.children?`
1904
+ <ul class="rd-perms rd-perm-children" hidden>${c.children.map(u=>`
1905
+ <li class="rd-perm rd-perm-sub rd-perm-inherit" data-key="${escapeHtml(u.key)}">
1906
+ <input type="checkbox" data-inherit="1" ${u.selected?"checked":""} ${e.editable?"":"disabled"} title="取消勾选 = 豁免该继承权限(保存后生效)">
1907
+ <button type="button" class="rd-perm-name" title="${escapeHtml(u.title||"查看介绍")}">${escapeHtml(u.name)}</button>
1908
+ ${u.sub?`<small class="rd-perm-key">${escapeHtml(u.sub)}</small>`:""}
1909
+ <span class="rd-inherit-badge">继承</span>
1910
+ </li>`).join("")}</ul>`:""}
1911
+ </li>`).join("")}</ul>`).join("");t.innerHTML=`
1912
+ <div class="skv-md">
1913
+ ${e.metaEdit?`
1914
+ <div class="rd-meta-edit">
1915
+ <input type="text" class="rd-meta-name" maxlength="${e.metaEdit.nameMax||50}"
1916
+ value="${escapeHtml(e.metaEdit.name||"")}"
1917
+ placeholder="${escapeHtml(e.metaEdit.namePlaceholder||"")}">
1918
+ <textarea class="rd-meta-desc" maxlength="${e.metaEdit.descMax||200}" rows="2"
1919
+ placeholder="${escapeHtml(e.metaEdit.descPlaceholder||"简介(可选)")}">${escapeHtml(e.metaEdit.description||"")}</textarea>
1920
+ </div>`:`
1921
+ <h1>${escapeHtml(e.title)}</h1>
1922
+ ${e.description?'<div class="rd-desc-md"></div>':""}`}
1923
+ ${e.metaLine?`<p class="rd-meta-line"><b>${escapeHtml(e.metaLine)}</b></p>`:""}
1924
+ ${e.filterSection?`
1925
+ <p class="rd-meta-line">
1926
+ <button type="button" class="rd-meta-btn rd-filter-entry" title="查看筛选规则">${Number(e.filterRuleCount)||0}条筛选规则<span class="rd-meta-go">›</span></button>
1927
+ </p>`:""}
1928
+ ${e.listTitle?`<h2>${escapeHtml(e.listTitle)}</h2>`:""}
1929
+ ${e.hint?`<p class="rd-hint">${escapeHtml(e.hint)}</p>`:""}
1930
+ <ul class="rd-list">${n}${i}</ul>
1931
+ </div>`,!e.metaEdit&&e.description&&at(t.querySelector(".rd-desc-md"),e.description);const o=e.groups.flatMap(r=>[...r.rows,...r.rows.flatMap(c=>c.children||[])]).concat((e.inheritGroups||[]).flatMap(r=>[...r.rows,...r.rows.flatMap(c=>c.children||[])]));t.querySelectorAll(".rd-perm-name").forEach(r=>{r.addEventListener("click",()=>{const c=o.find(u=>u.key===r.closest(".rd-perm").dataset.key);c&&c.onNameClick&&c.onNameClick()})}),t.querySelectorAll(".rd-perm-toggle").forEach(r=>{r.addEventListener("click",c=>{c.stopPropagation();const u=r.closest(".rd-perm").querySelector(".rd-perm-children");if(!u)return;const a=u.hidden;u.hidden=!a,r.setAttribute("aria-expanded",String(a)),r.firstChild.textContent=a?"▾ ":"▸ "})});const s=t.querySelector(".rd-meta-line");if(s&&e.metaLineOnClick){const r=document.createElement("button");r.type="button",r.className="rd-meta-btn",r.title="查看使用该角色的用户",r.innerHTML=`${escapeHtml(e.metaLine)}<span class="rd-meta-go">›</span>`,r.addEventListener("click",e.metaLineOnClick),s.replaceChildren(r)}const l=t.querySelector(".rd-filter-entry");l&&e.onFilterEntry&&l.addEventListener("click",e.onFilterEntry)}function $i(e,t){const n={prompts:JSON.parse(JSON.stringify(e.prompts||[])),resources:JSON.parse(JSON.stringify(e.resources||[])),proxies:JSON.parse(JSON.stringify(e.proxies||[])),forms:JSON.parse(JSON.stringify(e.forms||[]))},i=[{key:"prompts",label:"MCP 提示词"},{key:"resources",label:"MCP 资源"},{key:"proxies",label:"代理配置"},{key:"forms",label:"表单配置"}],o=document.createElement("div");o.className="mcp-binding-editor";function s(c,u){const a=u.value.trim().toUpperCase();if(a){if(n[c.key].some(d=>(d.ref||"").toUpperCase()===a)){u.select();return}n[c.key].push({ref:a}),u.value="",r()}}function l(c){const u=document.createElement("div");u.className="mcp-section";const a=document.createElement("div");if(a.className="mcp-section-head",a.innerHTML="<b>"+escapeHtml(c.label)+"("+n[c.key].length+" 条绑定)</b>",u.appendChild(a),n[c.key].forEach((d,p)=>{const w=document.createElement("div");w.className="mcp-bind-row";const y=c.key==="proxies"&&d._executor_url?' <span class="rd-hint">'+escapeHtml(d._executor_url)+(d._enabled===!1?"(停用)":"")+(d._has_dsl?"":"(无 DSL)")+"</span>":"";w.innerHTML='<span class="mcp-bind-text"><span class="mcp-bind-head"><b>'+escapeHtml(d._name||d.name||d.ref||"")+'</b> <button type="button" class="rd-ref-jump" title="打开作品详情"><code>'+escapeHtml(d.ref||"")+"</code></button>"+(d.version?' <span class="rd-hint">@v'+escapeHtml(String(d.version))+"</span>":"")+y+"</span>"+(d._description?'<span class="mcp-bind-desc"></span>':"")+"</span>",d._description&&at(w.querySelector(".mcp-bind-desc"),d._description);const f=w.querySelector(".rd-ref-jump");if(f&&(d.ref||"").trim()&&f.addEventListener("click",()=>{yn(d.ref,d.version)}),t){const m=document.createElement("input");m.type="number",m.min="1",m.value=d.version||"",m.placeholder="版本",m.title="钉住版本号(空 = 跟随作品默认版本)",m.className="mcp-bind-ver",m.addEventListener("change",()=>{const S=parseInt(m.value,10);S>0?d.version=S:delete d.version}),w.appendChild(m);const E=document.createElement("button");E.type="button",E.className="link-btn",E.textContent="✕",E.title="移除绑定",E.addEventListener("click",()=>{n[c.key].splice(p,1),r()}),w.appendChild(E)}u.appendChild(w)}),t){const d=document.createElement("div");d.className="mcp-bind-add";const p=document.createElement("input");p.type="text",p.className="mcp-bind-ref",p.placeholder="作品编号",p.title="填写作品编号,例如 WORKS-1234",p.autocomplete="off",p.addEventListener("keydown",y=>{y.key==="Enter"&&(y.preventDefault(),s(c,p))}),d.appendChild(p);const w=document.createElement("button");w.type="button",w.className="link-btn",w.textContent="添加",w.addEventListener("click",()=>s(c,p)),d.appendChild(w),u.appendChild(d)}return u}function r(){o.innerHTML="",i.forEach(c=>o.appendChild(l(c)))}return r(),o._getValue=()=>({prompts:n.prompts.map(c=>c.version?{ref:c.ref,version:c.version}:{ref:c.ref}),resources:n.resources.map(c=>c.version?{ref:c.ref,version:c.version}:{ref:c.ref}),proxies:n.proxies.map(c=>c.version?{ref:c.ref,version:c.version}:{ref:c.ref}),forms:n.forms.map(c=>c.version?{ref:c.ref,version:c.version}:{ref:c.ref})}),o}async function gn(e){const t=Be.find(n=>n.id===e);!t||!window.RelationPanel||!window.RelationEntry||RelationPanel.open({title:`关系 · ${t.name}`,errorText:"关系加载失败",fetch:async()=>{const n=await api(`/api/admin/roles/${e}/members`),i=Array.isArray(n.items)?n.items:[];return i.length?{sections:[{title:"",extraClass:"flush",entriesHtml:`<div class="giv-vlist">${i.map(s=>RelationEntry.cardHtml({badge:`U${s.id}`,title:s.username,detail:`${s.is_admin?"管理员":"普通用户"}${s.created_at?" · 注册于 "+s.created_at.slice(0,10):""}`,time:s.created_at,timeFull:window.fmtFullTime?fmtFullTime(s.created_at):"",dataAttrs:{uid:s.id},clickable:"card"})).join("")}</div>`}],footerHtml:""}:{sections:[],footerHtml:'<div class="giv-panel-empty">暂无关系</div>'}},onEntryClick:n=>{const i=Number(n.dataset.uid);i&&typeof window.openUserProfile=="function"&&window.openUserProfile(i)}})}let lt=null;async function dt(){const e=document.getElementById("rolesBox");e&&_t(e);try{const t=await api("/api/admin/roles");bt(t.items||[]),e&&bn(),lt&&lt()}catch(t){if(!e)return;e.innerHTML="",StatusNotify.error(t.message)}}function bn(){const e=document.getElementById("rolesBox");if(e){if(!Be.length){e.innerHTML='<div class="card empty">还没有角色,点右上「新建角色」创建</div>';return}e.innerHTML=nt(Be.map(t=>tt(Object.assign(mn(t),{menuItems:hn(t)}))))}}function zi(e,t){const n=e?new Map(e.map(i=>[i.key||i.permission_key,i])):new Map;return(Ie.permissions||[]).filter(i=>i.role_class===t).map(i=>{const o=n.get(i.key)||{},s=i.scope==="own_all"?`
1932
+ <select class="perm-scope" aria-label="${escapeHtml(i.name)}的权限范围">
1933
+ <option value="own" ${o.scope!=="all"?"selected":""}>仅限自己</option>
1934
+ <option value="all" ${o.scope==="all"?"selected":""}>所有人</option>
1935
+ </select>`:"";return`<label class="admin-perm-card" data-key="${escapeHtml(i.key)}">
1936
+ <span class="apc-main">
1937
+ <input type="checkbox" data-permission="1" ${o.key?"checked":""}>
1938
+ <span class="apc-text">${escapeHtml(i.name)}<small>${i.no?escapeHtml(i.no)+" · ":""}${escapeHtml(i.key)}</small></span>
1939
+ </span>${s}</label>`}).join("")}function ji(e){const t=[];return e.querySelectorAll(".admin-perm-card").forEach(n=>{const i=n.querySelector("input[data-permission]");if(!i||!i.checked)return;const o=n.querySelector(".perm-scope");t.push({key:n.dataset.key,scope:o?o.value:"all"})}),t}function Ki(e,t){if(e.requires)return;const n=e.role_class;if(!He(n))return;let o=null;const s=document.createElement("button");s.type="button",s.className="pv-action-btn",s.textContent="变更",s.addEventListener("click",()=>{let r=t.querySelector(".perm-class-picker");r||(r=vn({currentCls:n,onPick:c=>{o=c,l.disabled=!1}}),t.insertBefore(r,t.firstChild)),r.hidden=!r.hidden,r.hidden||r.scrollIntoView({block:"nearest"})});const l=document.createElement("button");return l.type="button",l.className="pv-action-btn pv-action-btn-primary",l.textContent="保存",l.disabled=!0,l.addEventListener("click",async()=>{if(o){l.disabled=!0,s.disabled=!0;try{const r=await api("/api/admin/permission-keys/"+encodeURIComponent(e.key)+"/class",{method:"POST",body:JSON.stringify({role_class:o})});StatusNotify.ok(`权限键已变更为等级 ${He(o)||"?"}`+(r.migrated_children&&r.migrated_children.length?`(${r.migrated_children.length} 个子权限键随迁)`:"")),r.warnings&&r.warnings.length&&StatusNotify.warn(r.warnings.join(";")),e.role_class=r.role_class||o,(r.migrated_children||[]).forEach(c=>{const u=(Ie.permissions||[]).find(a=>a.key===c);u&&(u.role_class=o)}),window.PlainView.close(),ot(e,null)}catch(r){StatusNotify.error(r.message),l.disabled=!1,s.disabled=!1}}}),[s,l]}async function ot(e,t){const n=document.createElement("div");n.className="skv-body adm-detail";let i;Oe("editRole")&&(i=Ki(e,n));const o=e.requires?(Ie.permissions||[]).find(l=>l.key===e.requires):null;n.innerHTML=`
1940
+ <div class="skv-md">
1941
+ <h1>${escapeHtml(e.name)}</h1>
1942
+ <h2>权限说明</h2>
1943
+ <ul>
1944
+ ${e.role_class&&He(e.role_class)?`
1945
+ <li><b>权限等级</b>:等级 ${He(e.role_class)}</li>
1946
+ `:""}
1947
+ <li><b>权限键</b>:${e.no?`<code>${escapeHtml(e.no)}</code> · `:""}<code>${escapeHtml(e.key)}</code></li>
1948
+ ${e.description?'<li><b>权限介绍</b>:<br><div class="rd-desc-md" data-md-slot="perm-desc"></div></li>':""}
1949
+ ${e.key.startsWith("ai.")||e.key.startsWith("card.")?"":`<li><b>所属类目</b>:${escapeHtml(e.category)}</li>`}
1950
+ ${e.key.startsWith("ai.")||e.key.startsWith("card.")?"":`<li><b>范围语义</b>:${escapeHtml(Bi[e.scope]||e.scope)}</li>`}
1951
+ ${e.requires?`
1952
+ <li><b>依赖权限键</b>:${o&&o.no?`<code>${escapeHtml(o.no)}</code> · `:""}<code>${escapeHtml(e.requires)}</code>(与门:两者同时勾选才生效)</li>
1953
+ `:e.key.startsWith("ai.")?`
1954
+ <li><b>依赖权限键</b>:无(勾选即授权调用)</li>
1955
+ `:""}
1956
+ ${e.exposure?`<li><b>前端体现</b>:${escapeHtml(e.exposure)}</li>`:""}
1957
+ </ul>
1958
+ </div>`;const s=je("admPermIntro",{title:"权限介绍",actions:i,content:n});if(Array.isArray(i)&&i.length&&Dt(s,i),e.description&&at(n.querySelector('[data-md-slot="perm-desc"]'),e.description),e.key.startsWith("ai.")){const l=await Fi(e.key.slice(3));if(l&&n.isConnected&&(n.querySelector(".skv-md").insertAdjacentHTML("beforeend",Wi(l)),l.description&&at(n.querySelector('[data-md-slot="desc"]'),l.description),l.args_schema&&at(n.querySelector('[data-md-slot="args"]'),l.args_schema),l.ref)){const r=()=>yn(l.ref,l.version),c=n.querySelector(".skv-md h1");c&&(c.classList.add("rd-tool-work-link"),c.title="打开声明作品 "+l.ref+"_V"+(Number(l.version)||0),c.addEventListener("click",r));const u=n.querySelector(".rd-tool-work-row");u&&u.addEventListener("click",r)}}}function vt(e,t,n={}){const i=n.pendingCls||null,o=i?new Map:new Map((e.permissions||[]).map(_=>[_.key||_.permission_key,_.scope==="own"?"own":"all"])),s=i||e.role_class||"",l=Oe("editRole"),r=e.is_locked===!0,c=(l||s==="admin")&&!r,u=c,a=c,d=(Ie.permissions||[]).filter(_=>_.category===it||_.category===ft?!1:_.role_class===s),p=(Ie.permissions||[]).filter(_=>_.requires&&_.category===ft&&_.role_class===s),w=new Map,y=[];(Ie.permissions||[]).forEach(_=>{if(!(_.category!==it||_.role_class!==s)){if(!_.requires){y.push(_);return}w.has(_.requires)||w.set(_.requires,[]),w.get(_.requires).push(_)}}),p.forEach(_=>{w.has(_.requires)||w.set(_.requires,[]),w.get(_.requires).push(_)});const f=_=>{const g=w.get(_.key)||[];return g.length?g:null},m=d,E=[],S=new Map;m.forEach(_=>{const g=_.role_class||"?";S.has(g)||(S.set(g,[]),E.push(g)),S.get(g).push(_)}),E.sort((_,g)=>(He(_)||99)-(He(g)||99));const L=i?new Set:fn(e),O=dn(s),I=_=>({key:_.key,name:_.name,sub:wt(),selected:!L.has(_.key),onNameClick:()=>ot(_),children:void 0}),v=new Map,h=[];O.forEach(_=>{if(_.category===it&&!_.requires){h.push(_);return}v.has(_.role_class)||v.set(_.role_class,[]),v.get(_.role_class).push(_)});const x=[...v.keys()].sort((_,g)=>(He(_)||99)-(He(g)||99)).map(_=>{const g=v.get(_),B=g.filter(k=>k.category!==it&&k.category!==ft),A=new Map;return g.forEach(k=>{k.category!==it&&k.category!==ft||!k.requires||(A.has(k.requires)||A.set(k.requires,[]),A.get(k.requires).push(k))}),{name:`等级 ${He(_)||"?"} 权限(继承)`,rows:B.map(k=>{const P=A.get(k.key)||[],j=I(k);return P.length&&(j.children=P.map(I)),j})}});h.length&&x.push({name:"其他 MCP 工具(不依赖权限键)(继承)",rows:h.map(I)}),Ui({title:(e.name||"角色")+(e.is_locked?" 🔒 已锁定":"")+`(${Bt(s)})`,description:e.description,metaEdit:l&&!r?{name:(n.keepMeta&&n.keepMeta.name)??e.name,nameMax:50,namePlaceholder:"角色名称",description:(n.keepMeta&&n.keepMeta.description)??e.description,descMax:200}:null,metaLine:`${e.member_count} 人在用`,metaLineOnClick:()=>kn(e.id),filterSection:!0,filterRuleCount:e.content_filter_count||0,onFilterEntry:()=>Yi(e),inheritGroups:x,editable:u,groups:[...E.map(_=>({name:`等级 ${He(_)||"?"} 权限`,rows:S.get(_).map(g=>{const B=o.get(g.key),A=f(g);return{key:g.key,name:g.name,sub:wt(),selected:!!B,onNameClick:()=>ot(g,o.has(g.key)),children:A?A.map(k=>{const P=o.get(k.key);return{key:k.key,name:k.name,sub:wt(),selected:!!P,onNameClick:()=>ot(k,o.has(k.key))}}):null}})})),...y.length?[{name:"其他 MCP 工具(不依赖权限键)",rows:y.map(_=>{const g=o.get(_.key);return{key:_.key,name:_.name,sub:wt(),selected:!!g,onNameClick:()=>ot(_,o.has(_.key))}})}]:[]]},t);const T=t.querySelector(".skv-md");if(T){const _=$i({prompts:e.prompts||[],resources:e.resources||[],proxies:e.proxies||[],forms:e.forms||[]},a);T.insertBefore(_,T.querySelector(".rd-list"))}}async function Gi(e,t,n=null){const i=(t.querySelector(".rd-meta-name")||{}).value??e.name,o=(t.querySelector(".rd-meta-desc")||{}).value??e.description,s=[...t.querySelectorAll(".rd-perm")].filter(u=>!u.classList.contains("rd-perm-inherit")).map(u=>{const a=u.querySelector("input[data-permission]");if(!a)return null;const d=u.querySelector("select[data-scope]");return{key:u.dataset.key,checked:a.checked,scope:d?d.value:"all"}}).filter(Boolean).filter(u=>u.checked).map(u=>({key:u.key,scope:u.scope})),l=[...t.querySelectorAll(".rd-perm-inherit")].filter(u=>{const a=u.querySelector("input[data-inherit]");return a&&!a.checked}).map(u=>u.dataset.key),r=t.querySelector(".mcp-binding-editor"),c=r&&r._getValue?r._getValue():null;try{const u={name:(i||"").trim(),description:(o||"").trim(),permissions:s,inherit_optout:l};c&&(u.prompts=c.prompts,u.resources=c.resources,u.proxies=c.proxies,u.forms=c.forms),n&&(u.role_class=n);const a=await api(`/api/admin/roles/${e.id}`,{method:"PUT",body:JSON.stringify(u)}),d=e.role_class;e.name=(i||"").trim(),e.description=(o||"").trim(),e.permissions=s,a&&a.inherit_optout&&(e.inherit_optout=a.inherit_optout),a&&a.prompts&&(e.prompts=a.prompts),a&&a.resources&&(e.resources=a.resources),a&&a.proxies&&(e.proxies=a.proxies),a&&a.forms&&(e.forms=a.forms),a&&a.role_class&&(e.role_class=a.role_class);const p=a&&a.added_keys||[],w=a&&a.removed_keys||[],y=a&&a.role_class&&d&&a.role_class!==d,f=[];y&&f.push(`等级已变更为 ${Bt(a.role_class)}`),p.length&&f.push(`新增 ${p.length} 项:${p.join("、")}`),w.length&&f.push(`移除 ${w.length} 项:${w.join("、")}`),l.length&&f.push(`已豁免 ${l.length} 项继承权限`),f.length?StatusNotify.warn(`已保存;${f.join(";")}`):StatusNotify.ok("已保存"),bn(),lt&&lt(),y&&vt(e,t)}catch(u){StatusNotify.error(u.message),vt(e,t)}}async function Yi(e){if(!window.PlainView){StatusNotify.error("展示组件未加载,请刷新页面重试");return}const t=Ie&&Ie.content_filter_fields||[];if(!t.length){StatusNotify.error("筛选字段配置未下发,请刷新页面重试");return}const n=Oe("editRole")&&e.is_locked!==!0;let i={logic:"and",rules:[],cap:null};try{const f=await api(`/api/admin/roles/${e.id}/content-filter`);f&&f.spec&&(i={...i,...f.spec})}catch(f){StatusNotify.error(f.message);return}const o=f=>t.find(m=>m.key===f)||null;function s(f,m){const E=m==null?"":String(m);if(f&&f.options)return`<select class="rd-filter-val"><option value=""${E===""?" selected":""}>请选择</option>`+f.options.map(O=>`<option value="${escapeHtml(O.value)}"${O.value===E?" selected":""}>${escapeHtml(O.label)}</option>`).join("")+"</select>";const S=f&&f.value_kind==="date"?"date":f&&f.value_kind==="int"?"number":"text",L=f&&f.value_kind==="int"?' placeholder="等级数字" min="0"':' placeholder="条件"';return`<input type="${S}" class="rd-filter-val" value="${escapeHtml(E)}"${L}>`}function l(f){const m=o(f.field),E=m?m.ops:[];return`<div class="rd-filter-row rd-filter-item">
1959
+ <select class="rd-filter-col">
1960
+ <option value=""${m?"":" selected"}>请选择</option>
1961
+ ${t.map(S=>`<option value="${S.key}"${f.field===S.key?" selected":""}>${escapeHtml(S.label)}</option>`).join("")}
1962
+ </select>
1963
+ <select class="rd-filter-op">${E.length?E.map(S=>`<option value="${S.key}"${f.op===S.key?" selected":""}>${escapeHtml(S.label)}</option>`).join(""):'<option value="">请先选列</option>'}</select>
1964
+ ${s(m,f.value)}
1965
+ <button type="button" class="rd-filter-del" title="删除本行">×</button>
1966
+ </div>`}const r=document.createElement("div");r.className="skv-body adm-detail";function c(f){f.querySelector(".rd-filter-col").addEventListener("change",()=>{const m=o(f.querySelector(".rd-filter-col").value),E=m?m.ops:[];f.querySelector(".rd-filter-op").innerHTML=E.length?E.map(L=>`<option value="${L.key}">${escapeHtml(L.label)}</option>`).join(""):'<option value="">请先选列</option>';const S=document.createElement("div");S.innerHTML=s(m,""),f.querySelector(".rd-filter-val").replaceWith(S.firstElementChild)}),f.querySelector(".rd-filter-del").addEventListener("click",()=>f.remove())}function u(){const f=r.querySelector(".rd-filter-add");f&&f.addEventListener("click",()=>{const E=r.querySelector(".rd-filter-table");E.insertAdjacentHTML("beforeend",l({}));const S=E.querySelectorAll(".rd-filter-item");c(S[S.length-1])});const m=r.querySelector(".rd-filter-cap-on");m&&m.addEventListener("change",()=>{r.querySelector(".rd-filter-cap-limit").disabled=!m.checked})}function a(f){const m=Array.isArray(f.rules)?f.rules:[];r.innerHTML=`
1967
+ <div class="skv-md">
1968
+ <h1>${escapeHtml(e.name||"角色")}</h1>
1969
+ <p class="rd-hint">白名单语义:规则 = 可见条件,未命中的内容对该角色隐藏(自己的作品不受限);不配置规则 = 不限制。${m.length||f.cap?"":"当前未配置。"}</p>
1970
+ <div class="rd-filter-table">
1971
+ <div class="rd-filter-row rd-filter-head">
1972
+ <span>筛选列</span><span>判断</span><span>条件</span><span></span>
1973
+ </div>
1974
+ ${m.map(E=>l(E)).join("")}
1975
+ </div>
1976
+ <div class="rd-filter-tools">
1977
+ <button type="button" class="rd-filter-add">+ 添加规则</button>
1978
+ <label>组合方式
1979
+ <select class="rd-filter-logic">
1980
+ <option value="and"${(f.logic||"and")==="and"?" selected":""}>满足全部规则</option>
1981
+ <option value="or"${f.logic==="or"?" selected":""}>满足任一规则</option>
1982
+ </select>
1983
+ </label>
1984
+ <label>
1985
+ <input type="checkbox" class="rd-filter-cap-on"${f.cap?" checked":""}> 数量上限
1986
+ <input type="number" class="rd-filter-cap-limit" min="1" max="10000" placeholder="如 100" value="${f.cap&&f.cap.limit?escapeHtml(f.cap.limit):""}"${f.cap?"":" disabled"}>
1987
+ <span class="rd-filter-hint">按默认排序只显示最新 N 条</span>
1988
+ </label>
1989
+ </div>
1990
+ </div>`,r.querySelectorAll(".rd-filter-item").forEach(c),u()}function d(){const f=[];for(const S of r.querySelectorAll(".rd-filter-item")){const L=S.querySelector(".rd-filter-col").value,O=S.querySelector(".rd-filter-op").value,I=S.querySelector(".rd-filter-val"),v=I?String(I.value).trim():"";if(!(!L&&!O&&!v)){if(!L||!O||!v)throw new Error("存在未填完整的规则行(筛选列/判断/条件都要填)");f.push({field:L,op:O,value:v})}}const m=r.querySelector(".rd-filter-cap-on");let E=null;if(m&&m.checked){const S=parseInt(r.querySelector(".rd-filter-cap-limit").value,10);if(!Number.isFinite(S)||S<1||S>1e4)throw new Error("数量上限须为 1-10000 的整数");E={limit:S}}return{logic:r.querySelector(".rd-filter-logic").value,rules:f,cap:E}}a(i);function p(){const f=document.createElement("button");f.type="button",f.className="pv-action-btn",f.textContent="变更",f.addEventListener("click",async()=>{try{const E=await api(`/api/admin/roles/${e.id}/content-filter`);i={logic:"and",rules:[],cap:null,...E&&E.spec||{}},a(i),StatusNotify.ok("已恢复为已保存的规则")}catch(E){StatusNotify.error(E.message)}});const m=document.createElement("button");return m.type="button",m.className="pv-action-btn pv-action-btn-primary",m.textContent="保存",m.addEventListener("click",async()=>{let E;try{E=d()}catch(S){StatusNotify.warn(S.message);return}try{const S=await api(`/api/admin/roles/${e.id}/content-filter`,{method:"PUT",body:JSON.stringify(E)});i=S&&S.spec||E,e.content_filter_count=(i.rules||[]).length,StatusNotify.ok("筛选规则已保存")}catch(S){StatusNotify.error(S.message)}}),[f,m]}n||r.querySelectorAll("select, input, button").forEach(f=>f.disabled=!0);const w=n?p():[],y=je("admContentFilter",{title:"内容筛选条件",actions:w,content:r});w.length&&Dt(y,w)}async function Et(e,t){const n=Be.find(r=>r.id===e);if(!n)return!1;if(!window.PlainView)return StatusNotify.error("展示组件未加载,请刷新页面重试"),!1;const i=document.createElement("div");i.className="skv-body adm-detail";const o=Oe("editRole")&&n.is_locked!==!0;let s;if(o){let r=null;const c=document.createElement("button");c.type="button",c.className="pv-action-btn pv-action-btn-primary",c.textContent="保存",c.addEventListener("click",()=>Gi(n,i,r));const u=Ie.me&&Ie.me.role_class_level||0,a=document.createElement("button");a.type="button",a.className="pv-action-btn",a.textContent="变更",a.addEventListener("click",()=>{let d=i.querySelector(".perm-class-picker");d||(d=vn({currentCls:n.role_class||"",isDisabled:p=>(p.level||0)>u,disabledSuffix:"(高于你的等级)",onPick:p=>{var y,f;r=p;const w={name:(y=i.querySelector(".rd-meta-name"))==null?void 0:y.value,description:(f=i.querySelector(".rd-meta-desc"))==null?void 0:f.value};vt(n,i,{pendingCls:p,keepMeta:w}),i.insertBefore(d,i.firstChild),d.hidden=!1}}),i.insertBefore(d,i.firstChild)),d.hidden=!d.hidden,d.hidden||d.scrollIntoView({block:"nearest"})}),s=[a,c]}const l=t&&t.pvBody||je("admRoleDetail",{title:"角色详情",actions:s});return t&&t.pvBody&&(l.innerHTML=""),l.appendChild(i),vt(n,i),s&&Dt(l,s),!0}function Xi(e){const t=Be.find(o=>o.id===e);if(!t)return;if(t.is_locked){StatusNotify.error("角色已被锁定,不能修改权限或删除(先解锁再编辑)");return}const n=document.createElement("div");n.innerHTML=`
1991
+ <div class="form-row">
1992
+ <label for="reName">角色名称</label>
1993
+ <input type="text" id="reName" maxlength="50" value="${escapeHtml(t.name)}" placeholder="如:社区版主">
1994
+ </div>
1995
+ <div class="form-row">
1996
+ <label for="reDesc">说明(可选)</label>
1997
+ <input type="text" id="reDesc" maxlength="200" value="${escapeHtml(t.description)}" placeholder="这个角色是做什么的">
1998
+ </div>
1999
+ <div class="form-row">
2000
+ <label>权限(按项授予;作品权限可限定范围)</label>
2001
+ <div class="permission-list">${zi(t.permissions,t.role_class)}</div>
2002
+ </div>
2003
+ <div class="modal-actions">
2004
+ <button type="button" class="neu-btn cancel">取消</button>
2005
+ <button type="button" class="link-btn save" id="reSave">保存修改</button>
2006
+ </div>`,je("admRoleEditor",{title:`编辑角色:${t.name}`,content:n});const i=n.querySelector(".cancel");i&&i.addEventListener("click",()=>PlainView.close()),n.querySelector("#reSave").addEventListener("click",async()=>{const o={name:n.querySelector("#reName").value.trim(),description:n.querySelector("#reDesc").value.trim(),permissions:ji(n)};try{await api(`/api/admin/roles/${t.id}`,{method:"PUT",body:JSON.stringify(o)}),PlainView.close(),StatusNotify.ok("角色已保存"),dt()}catch(s){StatusNotify.error(s.message)}})}async function _n(e,t){const n=Be.find(o=>o.id===e),i=n?n.name:String(e);if(!(t&&!await MobileShell.confirm(`锁定后角色「${i}」将无法修改权限、无法删除,确定锁定?`,{title:"锁定角色",confirmText:"锁定",danger:!0})))try{await Ye(`/api/admin/roles/${e}/lock`,{locked:t}),StatusNotify.ok(t?`已锁定角色「${i}」`:`已解锁角色「${i}」`),dt()}catch(o){StatusNotify.error(o.message)}}async function Sn(e){const t=Be.find(o=>o.id===e),n=t?t.name:String(e);if(await MobileShell.confirm(`确定删除角色「${n}」?已分配给用户的该角色会一并移除。`,{title:"删除角色",confirmText:"删除",danger:!0}))try{await api(`/api/admin/roles/${e}`,{method:"DELETE"}),StatusNotify.ok(`已删除角色「${n}」`),dt()}catch(o){StatusNotify.error(o.message)}}function Ji(){const e=Ie.me&&Ie.me.role_class_level||0,t=kt().filter(o=>o.level<=e).sort((o,s)=>o.level-s.level),n=t.map(o=>`<option value="${escapeHtml(o.name)}">等级 ${o.level} 类角色</option>`),i=t.length?He(t[0].name):null;AppWindows.define("roleCreate",{title:`新建${i?`等级 ${i} 类角色`:"角色"}`,mode:"layer",render:function(o){o.classList.add("panel-scope"),o.innerHTML=`
2007
+ <div class="form-row">
2008
+ <label for="nrName">角色名称(2~50 字符)</label>
2009
+ <input type="text" id="nrName" maxlength="50" placeholder="如:社区版主">
2010
+ </div>
2011
+ <div class="form-row">
2012
+ <label for="nrDesc">说明(可选)</label>
2013
+ <input type="text" id="nrDesc" maxlength="200" placeholder="这个角色是做什么的">
2014
+ </div>
2015
+ <div class="form-row">
2016
+ <label for="nrType">角色类型</label>
2017
+ <select id="nrType">${n.join("")}</select>
2018
+ </div>
2019
+ <p class="rd-hint">创建后点开角色卡片可调整权限与 MCP 提示词/资源绑定
2020
+ (绑定在角色详情里填写作品编号)。</p>
2021
+ <div class="adm-form-actions">
2022
+ <button type="button" class="link-btn" data-act="cancel">取消</button>
2023
+ <button type="button" class="link-btn" data-act="create">创建</button>
2024
+ </div>`;const s=o.querySelector("#nrName"),l=c=>{o.querySelectorAll(".adm-form-actions button").forEach(u=>{u.disabled=c})},r=()=>{const c=o.closest(".pv-overlay");c&&window.PlainView&&PlainView.close(c)};o.querySelector('[data-act="cancel"]').addEventListener("click",r),o.querySelector('[data-act="create"]').addEventListener("click",async()=>{const c=s.value.trim();if(c.length<2||c.length>50){StatusNotify.error("角色名称需为 2-50 个字符");return}l(!0);try{const u=o.querySelector("#nrType").value,a=(Ie.permissions||[]).filter(d=>d.role_class===u).map(d=>({key:d.key,scope:d.scope==="own"?"own":"all"}));await Ye("/api/admin/roles",{name:c,description:o.querySelector("#nrDesc").value.trim(),permissions:a}),r(),StatusNotify.ok("角色已创建,点开卡片勾选权限"),dt()}catch(u){l(!1),StatusNotify.error(u.message)}}),s.focus()}}),AppWindows.open("roleCreate")}async function kn(e){await gn(e)}function Qi(){const e=document.getElementById("rolesBox");e&&!e.__adminActionBound&&(e.__adminActionBound=!0,e.addEventListener("click",t=>{const n=t.target&&t.target.closest&&t.target.closest("button[data-admin-action]");if(n&&e.contains(n)){ut();const o=Number(n.getAttribute("data-rid")),s=n.getAttribute("data-admin-action");s==="relations"?kn(o):s==="edit"?Xi(o):s==="lock"?_n(o,Number(n.getAttribute("data-next"))===1):s==="delete"&&Sn(o);return}const i=t.target&&t.target.closest&&t.target.closest(".item-card[data-rid]");i&&e.contains(i)&&Et(Number(i.getAttribute("data-rid")))}))}function At(e){lt=e}let Tt=0;async function ct(e){const t=++Tt,n=document.getElementById("usersBox");if(n){_t(n);try{const i=await api("/api/admin/users"+(e?`?q=${encodeURIComponent(e)}`:""));if(t!==Tt)return;cn(i.items||[]),er()}catch(i){if(t!==Tt)return;n.innerHTML="",StatusNotify.error(i.message)}}}function Zi(e){for(const t of e.querySelectorAll(".admin-foot-roles")){const n=t.closest(".item-card-footer");if(!n)continue;const i=[...t.querySelectorAll(".role-chip:not(.role-chip-more)")];i.forEach(r=>{r.style.display="",r.style.maxWidth=""});let o=t.querySelector(".role-chip-more");if(!i.length){o&&o.remove();continue}o||(o=document.createElement("span"),o.className="role-chip role-chip-more",o.textContent="…",t.appendChild(o)),o.style.display="none";let s=0;for(const r of n.children)r!==t&&(s+=r.scrollWidth||0);s+=(n.children.length-1)*8;const l=Math.max(n.clientWidth-s-2,60);if(i.forEach(r=>{r.style.maxWidth=l+"px"}),!(n.scrollWidth<=n.clientWidth)){o.style.display="";for(let r=i.length-1;r>=0&&n.scrollWidth>n.clientWidth;r--)i[r].style.display="none"}}}function er(){const e=document.getElementById("usersBox");if(!Ze.length){e.innerHTML='<div class="card empty">没有匹配的用户</div>';return}e.innerHTML=nt(Ze.map(t=>{const n=t.id===Ie.me.id,i=[t.is_locked?'<span class="badge badge-locked">已锁定</span>':"",n?'<span class="badge badge-self">我</span>':""].join(""),o=(t.custom_roles||[]).map(l=>`<span class="role-chip ${l.locked?"role-chip-locked":""}">${l.locked?"🔒 ":""}${escapeHtml(l.name)}</span>`).join(""),s=[];return Ii(t)&&(Oe("resetpwd")&&s.push(`<button type="button" data-admin-action="resetpwd" data-uid="${t.id}">重置密码</button>`),Oe("lockUser")&&s.push(`<button type="button" data-admin-action="lock" data-uid="${t.id}" data-next="${t.is_locked?0:1}">${t.is_locked?"解锁":"锁定"}</button>`),Oe("deleteUser")&&s.push(`<button type="button" class="btn-danger" data-admin-action="delete" data-uid="${t.id}">删除</button>`)),tt({attrs:` data-uid="${t.id}"`,coverHtml:Pi(t),nameHtml:`${escapeHtml(t.username)}${i}`,footChipsHtml:`<div class="admin-foot-roles">${o}</div>`,menuItems:s})})),Zi(e)}function Vt(e){return Ze.find(t=>t.id===e)||{username:String(e)}}async function tr(e,t){const n=Vt(e).username;if(!(t&&!await MobileShell.confirm(`锁定后 ${n} 将无法被删除、无法修改其角色,确定锁定?`,{title:"锁定账号",confirmText:"锁定",danger:!0})))try{await Ye(`/api/admin/users/${e}/lock`,{locked:t}),StatusNotify.ok(t?`已锁定 ${n}`:`已解锁 ${n}`),ct()}catch(i){StatusNotify.error(i.message)}}async function nr(e){const t=Vt(e).username;if(await MobileShell.confirm(`确定删除账号 ${t}?其通讯会话将被清理,发布保留为无主数据,不可恢复。`,{title:"删除账号",confirmText:"删除",danger:!0}))try{await api(`/api/admin/users/${e}`,{method:"DELETE"}),StatusNotify.ok(`已删除账号 ${t}`),ct()}catch(i){StatusNotify.error(i.message)}}function ir(e){const t=Vt(e).username,n=document.createElement("div");n.innerHTML=`
2025
+ <div class="form-row">
2026
+ <label for="rpInput">为 ${escapeHtml(t)} 设置新密码(至少 6 位)</label>
2027
+ <input type="password" id="rpInput" placeholder="新密码" autocomplete="new-password">
2028
+ </div>
2029
+ <div class="form-row" style="font-size:0.78rem;color:var(--text-muted);">重置后该用户所有登录会话立即失效。</div>
2030
+ <div class="modal-actions">
2031
+ <button type="button" class="neu-btn cancel">取消</button>
2032
+ <button type="button" class="link-btn save" id="rpSave">确定重置</button>
2033
+ </div>`,je("admResetPwd",{title:"重置密码",content:n});const i=n.querySelector(".cancel");i&&i.addEventListener("click",()=>PlainView.close()),n.querySelector("#rpSave").addEventListener("click",async()=>{const o=n.querySelector("#rpInput").value;try{await Ye(`/api/admin/users/${e}/password`,{password:o}),PlainView.close(),StatusNotify.ok(`已重置 ${t} 的密码`)}catch(s){StatusNotify.error(s.message)}})}async function En(e,t,n){let i=Ze.find(y=>y.id===e);if(!i)try{const y=t?"?q="+encodeURIComponent(t):"";cn((await api("/api/admin/users"+y)).items||[]),i=Ze.find(f=>f.id===e)}catch(y){return StatusNotify.error(y.message),!1}if(!i)return StatusNotify.error("用户不存在或已删除"),!1;if(!window.PlainView)return StatusNotify.error("展示组件未加载,请刷新页面重试"),!1;const o=Oe("assignRoles"),s=i.is_locked===!0,l=o&&!s;let r=null;const c=document.createElement("div");c.className="skv-body adm-detail";let u;if(l){const y=document.createElement("button");y.type="button",y.className="pv-action-btn pv-action-btn-primary",y.textContent="保存",y.addEventListener("click",()=>w()),u=[y]}const a=n&&n.pvBody||je("admUserDetail",{title:"用户详情",actions:u});if(n&&n.pvBody&&(a.innerHTML="",qi(a,u)),a.appendChild(c),!Be.length){const y=StatusTpl.fill(document.createElement("div"));c.appendChild(y);try{bt((await api("/api/admin/roles")).items||[])}catch(f){return y.remove(),StatusNotify.error(f.message),!1}}const d=()=>new Set((i.custom_roles||[]).map(y=>y.id)),p=()=>{const y=Ie&&Ie.me&&Ie.me.role_class_level||0,f=Be.filter(E=>Oe("assignRoles")&&(()=>{const S=He(E.role_class);return S!==null&&S<y})()),m=s?"disabled":"";c.innerHTML=`
2034
+ <div class="skv-md">
2035
+ <h1>${window.openUserProfile?`<button type="button" class="rd-open-profile" title="查看用户主页">${escapeHtml(i.username)}</button>`:escapeHtml(i.username)}</h1>
2036
+ ${i.is_locked?"<p>🔒 账号已被锁定:不能删除、不能修改角色</p>":""}
2037
+ <p>ID:${Number(i.id)}</p>
2038
+ ${i.created_at?`<p>注册于 ${escapeHtml(i.created_at.slice(0,10))}</p>`:""}
2039
+ ${r?`<p>最近活跃 ${escapeHtml(fmtTime(r.last_active_at||"")||"无记录")}</p>
2040
+ <p>访问作品 ${r.views_total} · 近30天 ${r.views_month}</p>
2041
+ <p>作品数量 ${r.work_count??0} · 作品总访问量 ${r.work_views_total??0} · 作品总点赞数 ${r.work_likes_total??0}</p>`:""}
2042
+ <ul class="rd-perms">${f.length?`
2043
+ <li class="rd-perm" data-rid="">
2044
+ <input type="radio" name="rd-role-1" data-role="1" ${d().size?"":"checked"} ${m}>
2045
+ <span class="rd-perm-name">无角色</span>
2046
+ <small class="rd-perm-key">零角色态(无任何权限键,类链继承不生效)</small>
2047
+ </li>
2048
+ ${f.map(E=>{const S=!!Ie&&E.role_class===Ie.admin_class,L=d().has(E.id)?"checked":"";return`
2049
+ <li class="rd-perm" data-rid="${E.id}">
2050
+ <input type="radio" name="rd-role-1" data-role="1"${S?' data-auto="1"':""} ${L} ${m}>
2051
+ <button type="button" class="rd-perm-name" title="查看角色详情">${escapeHtml(E.name)}</button>
2052
+ <small class="rd-perm-key">${escapeHtml(E.description||`${pn(E)} 项权限`)}</small>
2053
+ </li>`}).join("")}`:'<li class="rd-cat">无可用角色选项(操作者无对应权限键)</li>'}
2054
+ </ul>
2055
+ </div>`,c.querySelectorAll(".rd-open-profile").forEach(E=>{E.addEventListener("click",()=>openUserProfile(i.id))}),c.querySelectorAll('.rd-perm-name[title="查看角色详情"]').forEach(E=>{E.addEventListener("click",()=>{Et(Number(E.closest(".rd-perm").dataset.rid))})})};p(),api(`/api/admin/users/${i.id}/stats`).then(y=>{r=y,p()}).catch(()=>{});async function w(){const y=c.querySelector("input[data-role]:checked:not(:disabled)"),f=y?Number(y.closest(".rd-perm").dataset.rid):null;try{const m=f?[f]:[];await Ye(`/api/admin/users/${i.id}/roles`,{role_ids:m}),i.custom_roles=m.map(E=>Be.find(S=>S.id===E)).filter(Boolean).map(E=>({id:E.id,name:E.name}))}catch(m){StatusNotify.error(m.message),p();return}if(i.id===Ie.me.id&&(window.__refreshAuth&&await window.__refreshAuth(),ln(await api("/api/admin/meta").catch(()=>Ie)),!Cn("users"))){window.PlainView&&typeof PlainView.close=="function"&&PlainView.close();return}StatusNotify.ok("角色分配已保存"),p(),ct()}return!0}async function rr(){const e=document.getElementById("executorUsage");if(e)try{const t=await api("/api/admin/executor-usage"),n=t&&t.totals||null;if(!n||!n.runs)return;const i=t.names||{},o=l=>(Number(l||0)/6e4).toFixed(1);let s="";(t.by_account||[]).slice(0,12).forEach(l=>{const r=i[l.account_id]||"#"+l.account_id;s+='<tr><td style="padding:2px 6px;">'+escapeHtml(r)+'</td><td style="padding:2px 6px;">'+l.runs+"(成功 "+l.ok+')</td><td style="padding:2px 6px;">'+l.total_tokens+'</td><td style="padding:2px 6px;">'+o(l.total_ms)+"</td></tr>"}),e.innerHTML='<div style="opacity:.65;margin-bottom:4px;">执行器成本台账(近 '+t.window_days+" 天,只读快照;上游未报 token 的运行按 0 计)· 运行 "+n.runs+" · 成功 "+n.ok+" · 失败 "+n.error+" · tokens "+n.total_tokens+"(prompt "+n.prompt_tokens+" / completion "+n.completion_tokens+")· 机时 "+o(n.total_ms)+' 分钟</div><table style="width:100%;border-collapse:collapse;"><thead><tr style="opacity:.6;text-align:left;"><th style="padding:2px 6px;">席位</th><th style="padding:2px 6px;">运行</th><th style="padding:2px 6px;">tokens</th><th style="padding:2px 6px;">机时(分)</th></tr></thead><tbody>'+s+"</tbody></table>",e.hidden=!1}catch{}}function or(){const e=document.getElementById("usersBox");e&&!e.__adminActionBound&&(e.__adminActionBound=!0,e.addEventListener("click",t=>{const n=t.target&&t.target.closest&&t.target.closest("button[data-admin-action]");if(n&&e.contains(n)){ut();const o=Number(n.getAttribute("data-uid")),s=n.getAttribute("data-admin-action");s==="resetpwd"?ir(o):s==="lock"?tr(o,Number(n.getAttribute("data-next"))===1):s==="delete"&&nr(o);return}const i=t.target&&t.target.closest&&t.target.closest(".item-card[data-uid]");i&&e.contains(i)&&En(Number(i.getAttribute("data-uid")))}))}let Ft=[],Re=null;async function ar(){const e=document.getElementById("newuserBox");if(e){_t(e);try{Re=await api("/api/admin/newuser-config"),xn()}catch(t){e.innerHTML="",StatusNotify.error(t.message)}}}function sr(e){const t=((Re||{}).classes||[]).find(n=>n.name===e)||{};return t.avatar?St(t.avatar,`等级 ${t.level}`,String(t.level||"?")):`<div class="item-cover-wrap"><div class="admin-cover-char">${escapeHtml(String(t.level||"?").charAt(0))}</div></div>`}function lr(e){const t=e.key==="guest"?Re.guest_class:Re.register_class;return tt({attrs:` data-anchor="${e.key}"`,coverHtml:sr(t),nameHtml:escapeHtml(e.title),footMetaHtml:escapeHtml(e.hint),footCountHtml:cr(t),menuItems:Oe("manageNewUser")?[`<button type="button" data-admin-action="configure" data-anchor="${e.key}">配置</button>`]:[]})}function cr(e){const t=((Re||{}).classes||[]).find(n=>n.name===e);return t?`当前:等级 ${t.level}${t.grade?" · "+t.grade:""} · ${t.key_count} 项权限`:"未配置"}function xn(){const e=document.getElementById("newuserBox");if(!e||!Re)return;const t=[{key:"guest",title:"游客默认角色类",hint:"未登录访客的键面 = 该角色类键集全量;变更即时生效(≤3 秒)"},{key:"register",title:"新注册用户默认角色类",hint:"新注册账号自动挂该角色类承载行;只影响之后的注册,存量账号不迁移"}];e.innerHTML=nt(t.map(lr))}function ur(e){if(!Re||!(Re.classes||[]).length)return;if(!window.PlainView){StatusNotify.error("展示组件未加载,请刷新页面重试");return}const t=e==="guest"?{title:"游客默认角色类",current:Re.guest_class,other:Re.register_class,otherTitle:"新注册用户默认角色类"}:{title:"新注册用户默认角色类",current:Re.register_class,other:Re.guest_class,otherTitle:"游客默认角色类"},n=document.createElement("div");je("admAnchorConfig",{title:`配置 · ${t.title}`,content:n});const i=[...Re.classes].sort((s,l)=>s.level-l.level),o=document.createElement("div");o.className="panel-scope adm-sublist",o.innerHTML=`<p class="adm-sublist-count">点选等级卡即设为「${escapeHtml(t.title)}」(与「${escapeHtml(t.otherTitle)}」必须互异)</p>`+nt(i.map(s=>{const l=s.name===t.current?'<span class="badge">当前</span>':s.name===t.other?'<span class="badge">另一锚点</span>':"";return tt({attrs:` data-cls="${escapeHtml(s.name)}" data-level="${s.level}"`,coverHtml:un(s),nameHtml:`等级 ${s.level}${l}`,footMetaHtml:`权限键 ${s.key_count} 项`,footCountHtml:s.grade?`档位 ${escapeHtml(s.grade)}`:"",menuItems:[]})})),n.innerHTML="",n.appendChild(o),o.addEventListener("click",s=>{const l=s.target,r=l.closest&&l.closest(".item-card[data-cls]");if(!r||!o.contains(r))return;const c=r.getAttribute("data-cls"),u=Number(r.getAttribute("data-level"));if(c===t.current){StatusNotify.ok(`等级 ${u} 已是「${t.title}」当前配置`);return}if(c===t.other){StatusNotify.error(`与「${t.otherTitle}」必须互异`);return}dr(e,c,n)})}async function dr(e,t,n){const i=e==="guest"?{guest_class:t,register_class:Re.register_class}:{guest_class:Re.guest_class,register_class:t};try{const o=await Ye("/api/admin/newuser-config",i);Re.guest_class=o.guest_class,Re.register_class=o.register_class,(o.warnings||[]).forEach(l=>StatusNotify.warn(l)),StatusNotify.ok("已保存");const s=n.closest(".pv-overlay");s&&window.PlainView&&typeof PlainView.close=="function"&&PlainView.close(s),xn()}catch(o){StatusNotify.error(o.message)}}async function Wt(){const e=document.getElementById("levelsBox");if(e){_t(e);try{Ft=(await api("/api/admin/role-classes")).items||[],fr()}catch(t){e.innerHTML="",StatusNotify.error(t.message)}}}function fr(){const e=document.getElementById("levelsBox");if(!e)return;const t=Ft.filter(i=>i.active);if(!t.length){e.innerHTML='<div class="card empty">等级链为空(异常态,请检查 role_class_chain 表)</div>';return}const n=t.map(i=>{const o=[];return Oe("manageLevels")&&t.length>=2&&o.push(`<button type="button" class="btn-danger" data-admin-action="deleteLevel" data-cls="${escapeHtml(i.name)}" data-level="${i.level}">删除</button>`),tt({attrs:` data-lname="${escapeHtml(i.name)}" data-level="${i.level}"`,coverHtml:un(i),nameHtml:`等级 ${i.level}`,footMetaHtml:`权限键 ${i.key_count} 项 · 角色行 ${i.role_count} 个`,footCountHtml:`${i.member_count} 人挂载`,menuItems:o})});e.innerHTML=nt(n)}function pr(){const e=Ft.filter(n=>n.active).sort((n,i)=>n.level-i.level);if(!e.length)return;const t=e.map(n=>`<option value="${n.level}" ${n.level===e[e.length-1].level?"selected":""}>等级 ${n.level} 之后${n.level===e.length?"(成为最高等级)":""}</option>`);AppWindows.define("levelCreate",{title:"新增等级",mode:"layer",render:function(n){n.classList.add("panel-scope"),n.innerHTML=`
2056
+ <div class="form-row">
2057
+ <label for="nlAfter">插入位置</label>
2058
+ <select id="nlAfter">${t.join("")}</select>
2059
+ </div>
2060
+ <p class="rd-hint">新等级键集为空(权限键经角色编辑器升降级迁入);
2061
+ 更高等级的等级号整体 +1,各账号等级号随之位移(等级闸仍按链位
2062
+ 相对比较,语义不变)。</p>
2063
+ <div class="adm-form-actions">
2064
+ <button type="button" class="link-btn" data-act="cancel">取消</button>
2065
+ <button type="button" class="link-btn" data-act="create">创建</button>
2066
+ </div>`;const i=s=>{n.querySelectorAll(".adm-form-actions button").forEach(l=>{l.disabled=s})},o=()=>{const s=n.closest(".pv-overlay");s&&window.PlainView&&PlainView.close(s)};n.querySelector('[data-act="cancel"]').addEventListener("click",o),n.querySelector('[data-act="create"]').addEventListener("click",async()=>{i(!0);try{const s=await Ye("/api/admin/role-classes",{after_level:Number(n.querySelector("#nlAfter").value)});o(),StatusNotify.ok(`已在等级 ${s.level} 之后插入新等级`),(s.warnings||[]).forEach(l=>StatusNotify.warn(l)),Wt()}catch(s){i(!1),StatusNotify.error(s.message)}})}}),AppWindows.open("levelCreate")}async function mr(e,t){if(await MobileShell.confirm(`确定删除等级 ${t}?其权限键与角色行将随迁到删后占据其链位的相邻类,更高等级号整体 -1(各账号等级号随之位移,不可撤销)。`,{title:"删除等级",confirmText:"删除",danger:!0}))try{const i=await api("/api/admin/role-classes/"+encodeURIComponent(e),{method:"DELETE"});StatusNotify.ok(`已删除等级 ${i.level}(键与角色行随迁到等级 ${He(i.target)||"?"})`),(i.warnings||[]).forEach(o=>StatusNotify.warn(o)),Wt()}catch(i){StatusNotify.error(i.message)}}async function hr(e,t){if(!window.PlainView){StatusNotify.error("展示组件未加载,请刷新页面重试");return}const n=document.createElement("div");if(je("admLevelRoles",{title:`等级 ${t} 的角色`,onClose:function(){At(null)},content:n}),!Be.length){const i=StatusTpl.fill(document.createElement("div"));n.appendChild(i);try{bt((await api("/api/admin/roles")).items||[])}catch(o){i.remove(),StatusNotify.error(o.message);return}}Yt(e,n),At(function(){Yt(e,n)})}function Yt(e,t){if(!t.isConnected){At(null);return}const n=Be.filter(o=>o.role_class===e),i=document.createElement("div");i.className="panel-scope adm-sublist",i.innerHTML=n.length?`<p class="adm-sublist-count">共 ${n.length} 个角色</p>`+nt(n.map(o=>tt(Object.assign(mn(o),{menuItems:hn(o)})))):'<div class="empty">该等级下暂无角色</div>',t.innerHTML="",t.appendChild(i),i.addEventListener("click",o=>{const s=o.target&&o.target.closest&&o.target.closest("button[data-admin-action]");if(s&&i.contains(s)){ut();const r=Number(s.getAttribute("data-rid")),c=s.getAttribute("data-admin-action");c==="relations"?gn(r):c==="edit"?StatusNotify.warn("编辑功能请从角色管理面板访问"):c==="lock"?_n(r,Number(s.getAttribute("data-next"))===1):c==="delete"&&Sn(r);return}const l=o.target&&o.target.closest&&o.target.closest(".item-card[data-rid]");l&&i.contains(l)&&Et(Number(l.getAttribute("data-rid")))})}function wr(){const e=document.getElementById("newuserBox");e&&!e.__adminActionBound&&(e.__adminActionBound=!0,e.addEventListener("click",t=>{const n=t.target&&t.target.closest&&t.target.closest("button[data-admin-action]");n&&e.contains(n)&&(ut(),n.getAttribute("data-admin-action")==="configure"&&ur(n.getAttribute("data-anchor")))}))}function yr(){const e=document.getElementById("levelsBox");e&&!e.__adminActionBound&&(e.__adminActionBound=!0,e.addEventListener("click",t=>{const n=t.target&&t.target.closest&&t.target.closest("button[data-admin-action]");if(n&&e.contains(n)){ut(),n.getAttribute("data-admin-action")==="deleteLevel"&&mr(n.getAttribute("data-cls"),Number(n.getAttribute("data-level")));return}const i=t.target&&t.target.closest&&t.target.closest(".item-card[data-lname]");i&&e.contains(i)&&hr(i.getAttribute("data-lname"),Number(i.getAttribute("data-level")))}))}function Cn(e){const t=(window.__gate||{}).entries||{},n=GateKeys.entries;if(e==="roles")return t[n.ROLES]===!0;if(e==="levels")return t[n.LEVELS]===!0;if(e==="newuser")return t[n.NEWUSER]===!0;if(t[n.USERS]===!0||t[n.ROLES]===!0||Oe("assignRoles"))return!0;const i=document.getElementById("panelUsers");return i&&(i.innerHTML='<div class="card empty">没有权限访问该界面</div>'),!1}window.__bootAdminUsers=function(){const e=document.querySelector(".panel-scope[data-panel-mode]")&&document.querySelector(".panel-scope[data-panel-mode]").dataset.panelMode||"users";function t(){if(e==="users"){let o=null,s=null;const l=document.getElementById("adminSearchBtn");l&&l.addEventListener("click",()=>{Interact.launch({busy:l,wait:()=>i,open:()=>{!o&&window.PullSearch&&(o=window.PullSearch.bind({placeholder:"按用户名搜索",onQuery:r=>{s&&clearTimeout(s),s=setTimeout(()=>ct(r),350)}})),o&&o.open()},fail:"管理面板加载失败,请重试"})})}if(e==="roles"){const o=document.getElementById("newRoleBtn");o&&o.addEventListener("click",()=>{Interact.launch({busy:o,wait:()=>i,open:()=>{Ji()},fail:"管理面板加载失败,请重试"})})}if(e==="levels"){const o=document.getElementById("addLevelBtn");o&&o.addEventListener("click",()=>{Interact.launch({busy:o,wait:()=>i,open:()=>{pr()},fail:"管理面板加载失败,请重试"})})}n()}function n(){if(e==="roles"){const o=document.getElementById("newRoleBtn");o&&(o.hidden=!Oe("createRole"))}if(e==="levels"){const o=document.getElementById("addLevelBtn");o&&(o.hidden=!Oe("manageLevels"))}}or(),Qi(),wr(),yr(),t();const i=async function(){try{ln(await api("/api/admin/meta"))}catch(s){throw StatusNotify.error(s.message),s}if(!Cn(e))throw new Error("没有访问该面板的权限");e==="roles"?dt():e==="levels"?Wt():e==="newuser"?ar():(ct(),rr()),n()}();window.AdminRolesPanel={openDetail:async function(o,s){if(!o)return!1;try{await i}catch{return!1}return Be.every(l=>l.id!==o.id)&&bt([...Be,o]),Et(o.id,s)}},window.AdminUsersPanel={openDetail:async function(o,s,l){if(!o)return!1;try{await i}catch{return!1}return En(o,s,l)}}};window.__bootWorkSearch=function(){var e=document.getElementById("workSearchBox");if(!e)return;var t=window.GateKeys&&GateKeys.entries||{};if(t.WORK_SEARCH!==void 0&&((window.__gate||{}).entries||{})[t.WORK_SEARCH]!==!0){e.innerHTML='<div class="card empty">没有权限访问该界面</div>';return}const n=Object.create(null);async function i(u,a,d){Caps.requireCommunityRead();const p=await window.api("/api/community/search?limit="+a+"&offset="+u+(d?"&q="+encodeURIComponent(d):""));return p&&Array.isArray(p.items)?(p.items.forEach(w=>{n[w.id]=w}),p):{items:[],total:0,has_more:!1}}window.__fwWorkSearchPs&&window.__fwWorkSearchPs.destroy&&window.__fwWorkSearchPs.destroy(),window.__fwWorkSearchList&&window.__fwWorkSearchList.destroy&&window.__fwWorkSearchList.destroy();const o=window.PullSearch&&PullSearch.bind({placeholder:"搜索作品(标题 / 编号)"})||null;window.__fwWorkSearchPs=o;const s=document.getElementById("workSearchBtn");s&&o&&s.addEventListener("click",()=>{o.open()});const l=document.createElement("div");l.className="items-grid",e.appendChild(l);const r=()=>{const u=e.closest(".pv-body")&&e.closest(".pv-body").querySelector(".lf-status");u&&u.remove()},c=ListView.bind({name:"workSearch",container:l,pageSize:20,fetchPage:i,renderItem:WorkAdminCard.html,extractId:u=>"works:"+u.id,emptyText:"没有匹配的作品",searchInput:o?o.input:null,initialWindowLoading:!0,onInitialLoading:r,onCardClick:u=>{const a=window.ItemViewOrchestrator;if(!a||typeof a.openItem!="function"){window.StatusNotify&&StatusNotify.error("详情组件未就位");return}a.openItem(u,{notify:d=>{window.StatusNotify&&StatusNotify.error(d)}})},onLoadError:u=>{console.warn("[work_search] 加载失败:",u&&u.message||u)}});window.__fwWorkSearchList=c,c&&typeof c.load=="function"&&c.load()};window.WordDict=function(){if(window.WordDict&&window.WordDict.__installed)return window.WordDict;var e=/[A-Za-z][A-Za-z'\u2019-]*/g,t=/WORKS-[0-9]+_V[0-9]+/gi,n=/WORKS-[0-9]+_历史版本/gi,i=/mcp_(?:tool|res|prt)_[a-z][a-z0-9_]*/g,o=/\bWORKS-[0-9]+\b/g,s=".giv-desc, .gct-text, .skv-md",l="a,button,input,textarea,select,[contenteditable]",r="wd-token",c={zk:"中考",gk:"高考",cet4:"四级",cet6:"六级",ky:"考研",toefl:"托福",ielts:"雅思",gre:"GRE",ox3000:"牛津3000",ox5000:"牛津5000"},u="词典服务未启用",a=320,d=null,p=null,w=null,y=new Map,f=200;function m(V,$,ne){V.size>=f&&V.delete(V.keys().next().value),V.set($,ne)}var E=!1,S=0,L=0,O=450;function I(V){return window.escapeHtml(String(V))}function v(V){return I(V).replace(/\n/g,"<br>")}function h(){d||(w=document.createElement("span"),w.className="wd-anchor",d=document.createElement("div"),d.className="wd-pop",d.hidden=!0,p=document.createElement("div"),p.className="wd-pop-body",d.appendChild(p),w.appendChild(d),document.body.appendChild(w),window.LayerManager&&window.LayerManager.register&&window.LayerManager.register(".wd-pop"))}function x(){window.LayerFrame&&window.LayerFrame.placePopup&&window.LayerFrame.placePopup(d,w)}function T(){S++,d&&(d.hidden=!0)}function _(V,$){h();var ne=8,C=Math.max(8,window.innerWidth-a-12);return w.style.left=Math.min(Math.max(V,ne),C)+"px",w.style.top=$+"px",d.hidden=!1,p.innerHTML='<div class="wd-loading">查询中…</div>',x(),L=Date.now(),++S}function g(V){return(V||"").split("/").filter(function($){return c[$]}).map(function($){return"<i>"+c[$]+"</i>"}).join("")}function B(V){if(!V.found){p.innerHTML='<div class="wd-word">'+I(V.word)+'</div><div class="wd-notfound">'+I(V.message||"词典未收录该词")+"</div>";return}var $='<div class="wd-head"><span class="wd-word">'+I(V.matched)+"</span>"+(V.phonetic?'<span class="wd-ph">'+I(V.phonetic)+"</span>":"")+"</div>";V.via&&($+='<div class="wd-via">词形归一 · 原形 '+I(V.via)+"</div>");var ne=g(V.tag);ne&&($+='<div class="wd-tags">'+ne+"</div>"),V.translation&&($+='<div class="wd-tr">'+v(V.translation)+"</div>"),p.innerHTML=$}function A(V){var $=V.toLowerCase(),ne=y.get($);return ne||(ne=window.api("/api/dict/lookup?w="+encodeURIComponent(V)),m(y,$,ne),ne.catch(function(C){y.delete($),C&&C.message===u&&(E=!0)})),ne}function k(V,$,ne){var C=_($,ne);A(V).then(function(z){C===S&&(B(z),x())}).catch(function(z){C===S&&(p.innerHTML='<div class="wd-err">'+I(z&&z.message||"查询失败")+"</div>")})}function P(V){StatusNotify.error(V)}function j(V,$){var ne=window.ItemCard&&ItemCard.apiResourceOf?ItemCard.apiResourceOf(V):V,C=typeof window.apiFn=="function"?window.apiFn:function(){return window.api};return typeof C()!="function"?Promise.resolve(null):C()("/api/"+ne+"/"+encodeURIComponent($)).then(function(z){return z&&z.item?z.item:null}).catch(function(){return null})}function Z(V){return V.slice(6)}function N(V){return lookupRefItem(V).then(function($){return $?$.item_type:null}).catch(function(){return null})}function ee(V){var $=String(V||"").toUpperCase(),ne=$.match(/^(WORKS-[0-9]+)_V([0-9]+)$/);ne&&(window.ItemViewOrchestrator&&typeof ItemViewOrchestrator.openPinnedWork=="function"?ItemViewOrchestrator.openPinnedWork(ne[1],Number(ne[2])||0,{notify:P}):P("详情组件未加载,请稍候重试"))}function ie(V){var $=String(V||"").toUpperCase(),ne=$.match(/^(WORKS-[0-9]+)_历史版本$/);if(ne){var C=ne[1];N(C).then(function(z){if(!z){P("作品不存在或不可见");return}window.ItemViewOrchestrator&&typeof ItemViewOrchestrator.resolveAndOpen=="function"?ItemViewOrchestrator.resolveAndOpen(z,Z(C),{openVersions:!0,notify:P}):P("详情组件未加载,请稍候重试")})}}function W(V){ee(String(V||"").toUpperCase()+"_V0")}var q=new Map;function F(V,$){var ne=$&&$.item||{},C='<div class="wd-head"><span class="wd-word">'+I(V)+"</span></div>";ne.found?ne.kind==="tool"?C+='<div class="wd-tr">'+v(ne.description||"(无描述)")+'</div><div class="wd-task-meta">工具详情与试执行需「我的功能 → MCP工具」就绪</div>':C+='<div class="wd-tr">'+v(ne.description||ne.entry_name||"")+'</div><div class="wd-task-meta">'+I(ne.kind==="mcp_prompt"?"提示词":"资源")+(ne.ref?" · 绑定作品 "+I(ne.ref):" · 内联内容")+"</div>":C+='<div class="wd-notfound">未收录或不在你的可见面</div>',p.innerHTML=C}function M(V){return window.AppWindows&&window.McpCallForm&&typeof window.McpCallForm.openToolDetail=="function"?(window.McpCallForm.openToolDetail({name:V.name,description:V.description||"",inputSchema:V.inputSchema||{}}),!0):!1}function G(V){var $=V.work_type;return $?(j($,V.work_id).then(function(ne){if(!ne){P("作品不存在或不可见");return}window.ItemViewOrchestrator&&typeof ItemViewOrchestrator.openItem=="function"?ItemViewOrchestrator.openItem(ne,{itemType:$,version:Number(V.version)||0,notify:P}):P("详情组件未加载,请稍候重试")}),!0):!1}function re(V,$,ne){var C=String(V||"").toLowerCase(),z=_($,ne),Y=q.get(C);Y||(Y=window.api("/api/mcp-tools/lookup?name="+encodeURIComponent(C)),m(q,C,Y),Y.catch(function(){q.delete(C)})),Y.then(function(ue){if(z===S){var he=ue&&ue.item||{};if(he.found&&he.kind==="tool"&&M(he)){T();return}if(he.found&&he.work_id&&G(he)){T();return}F(C,ue),x()}}).catch(function(ue){z===S&&(p.innerHTML='<div class="wd-err">'+I(ue&&ue.message||"查询失败")+"</div>")})}var ce=[{re:t,act:ee,chip:"ref",enabled:function(){return!0}},{re:n,act:ie,chip:"ref",enabled:function(){return!0}},{re:o,act:W,chip:"ref",hosts:".skv-md",enabled:function(){return!0}},{re:i,act:re,chip:"mcp",enabled:function(){return!0}},{re:e,act:k,enabled:function(){return!E}}];function H(V,$){return V.hosts?!!($&&$.closest&&$.closest(V.hosts)):!0}function te(V,$){for(var ne=0;ne<ce.length;ne++){var C=ce[ne];if(C.chip&&!(C.enabled&&!C.enabled())&&H(C,$)&&new RegExp("^(?:"+C.re.source+")$","i").test(V))return C}return null}function oe(V,$){var ne=V.nodeValue;if(ne){for(var C=null,z=0;z<ce.length;z++){var Y=ce[z];if(Y.chip&&H(Y,$)){Y.re.lastIndex=0;for(var ue;ue=Y.re.exec(ne);){for(var he=ue.index,Ee=he+ue[0].length,Q=!1,de=0;C&&de<C.length;de++)if(he<C[de].end&&C[de].start<Ee){Q=!0;break}Q||(C||(C=[])).push({start:he,end:Ee,cls:Y.chip})}}}if(C){C.sort(function(U,le){return U.start-le.start});for(var fe=document.createDocumentFragment(),ye=0,we=0;we<C.length;we++){C[we].start>ye&&fe.appendChild(document.createTextNode(ne.slice(ye,C[we].start)));var Ce=document.createElement("span");Ce.className=r+" "+r+"-"+C[we].cls,Ce.textContent=ne.slice(C[we].start,C[we].end),fe.appendChild(Ce),ye=C[we].end}ye<ne.length&&fe.appendChild(document.createTextNode(ne.slice(ye))),V.parentNode.replaceChild(fe,V)}}}function ve(V){for(var $=document.createTreeWalker(V,NodeFilter.SHOW_TEXT,{acceptNode:function(z){var Y=z.parentNode;return!Y||!Y.closest||Y.closest("."+r)||Y.closest(l)?NodeFilter.FILTER_REJECT:z.nodeValue?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),ne=[];$.nextNode();)ne.push($.currentNode);for(var C=0;C<ne.length;C++)oe(ne[C],V)}function Se(V){if(V.nodeType===3){V.parentNode&&V.parentNode.closest&&V.parentNode.closest(s)&&oe(V,V.parentNode.closest(s));return}if(!(V.nodeType!==1||!V.closest||V.classList.contains(r))){if(V.closest(s)){var $=V.matches(s)?V:V.closest(s);ve($);return}for(var ne=V.querySelectorAll(s),C=0;C<ne.length;C++)ve(ne[C])}}var se=null;function Ae(){se||!window.MutationObserver||(se=new MutationObserver(function(V){se.disconnect();try{for(var $=0;$<V.length;$++)for(var ne=V[$].addedNodes,C=0;C<ne.length;C++)Se(ne[C])}finally{se.observe(document.body,{childList:!0,subtree:!0})}}),se.observe(document.body,{childList:!0,subtree:!0}))}function xe(){for(var V=document.querySelectorAll(s),$=0;$<V.length;$++)ve(V[$]);Ae()}var be=1,b=4;function R(V,$,ne){var C,z;if(document.caretRangeFromPoint){var Y=document.caretRangeFromPoint(V,$);if(!Y)return null;C=Y.startContainer,z=Y.startOffset}else if(document.caretPositionFromPoint){var ue=document.caretPositionFromPoint(V,$);if(!ue)return null;C=ue.offsetNode,z=ue.offset}else return null;if(!C||C.nodeType!==3)return null;for(var he=C.nodeValue||"",Ee=0;Ee<ce.length;Ee++){var Q=ce[Ee];if(!(Q.enabled&&!Q.enabled())&&H(Q,ne)){Q.re.lastIndex=0;for(var de;(de=Q.re.exec(he))&&!(de.index>z);)if(z<=de.index+de[0].length){var fe=document.createRange();fe.setStart(C,de.index),fe.setEnd(C,de.index+de[0].length);for(var ye=fe.getClientRects(),we=0;we<ye.length;we++)if(V>=ye[we].left-be&&V<=ye[we].right+be&&$>=ye[we].top-b&&$<=ye[we].bottom+b)return{token:de[0],rect:ye[we],actor:Q};return null}}}return null}document.addEventListener("click",function(V){d&&!d.hidden&&T();var $=V.target;if(!(!$||!$.closest||!$.closest(s))){var ne=$.closest(s);if(!$.closest(l)){var C=window.getSelection&&window.getSelection();if(!(C&&!C.isCollapsed)){var z,Y=$.closest("."+r);if(Y){var ue=te(Y.textContent||"",Y);z=ue?{token:Y.textContent,rect:Y.getBoundingClientRect(),actor:ue}:null}else z=R(V.clientX,V.clientY,ne);z&&z.actor.act(z.token,Math.min(Math.max(V.clientX,z.rect.left),z.rect.right),Math.min(Math.max(V.clientY,z.rect.top),z.rect.bottom))}}}});function D(V){Date.now()-L>O&&T()}document.addEventListener("scroll",D,{capture:!0,passive:!0}),document.addEventListener("wheel",D,{capture:!0,passive:!0}),document.addEventListener("touchmove",D,{capture:!0,passive:!0}),document.addEventListener("keydown",function(V){V.key==="Escape"&&T()}),window.addEventListener("resize",T),window.onDomReady(xe);function J(V,$){var ne=Number($)||0;ee(String(V||"").toUpperCase()+"_V"+ne)}return{__installed:!0,hide:T,openByRef:J}}();window.__fwMark&&window.__fwMark("main-start");window.__fwLateDone=!0;window.__fwMark&&window.__fwMark("main-done");window.dispatchEvent(new Event("fw:late-done"));window.__fwWhenLate=e=>{e()};</script>
2067
+ </body>
2068
+ </html>