@xopcai/xopc 0.0.414 → 0.0.416

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 (359) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +4 -1
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +4 -1
  3. package/dist/browser-ext/dist/assets/{page-context-MuzjMBlJ.js → page-context-CVvmTWZb.js} +33 -9
  4. package/dist/browser-ext/dist/background.js +39 -10
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +22 -3
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/telegram/xopc.extension.json +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-ClobpdW3.js → agent-avatar-dicebear-CufU7cqe.js} +1 -1
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DHDAcss8.js +1 -0
  11. package/dist/gateway/static/root/assets/agents-BV3dAoa0.js +77 -0
  12. package/dist/gateway/static/root/assets/{agents-admin-api-CeBkHnl8.js → agents-admin-api-B1p-ghg9.js} +1 -1
  13. package/dist/gateway/static/root/assets/{app-management-settings-panel-CLunLNGp.js → app-management-settings-panel-D4-n1uBg.js} +1 -1
  14. package/dist/gateway/static/root/assets/{appearance-settings-DBEgoE9g.js → appearance-settings-Cgn4eNsX.js} +1 -1
  15. package/dist/gateway/static/root/assets/apps-page-BOYzD7Zz.js +1 -0
  16. package/dist/gateway/static/root/assets/{archive-plugin-JElK4Goq.js → archive-plugin-B4btCsiV.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automations-page-CZ0UqwyU.js → automations-page-yb1EL_3N.js} +1 -1
  18. package/dist/gateway/static/root/assets/automations-workspace-J7LJ4RuV.js +8 -0
  19. package/dist/gateway/static/root/assets/{binary-plugins-CXFawow6.js → binary-plugins-DQT9e258.js} +1 -1
  20. package/dist/gateway/static/root/assets/{block-editor-BoduwSYI.js → block-editor-B50rU9tL.js} +30 -30
  21. package/dist/gateway/static/root/assets/{browser-automation-inputs-D1pDgMJu.js → browser-automation-inputs-D6AccXaA.js} +1 -1
  22. package/dist/gateway/static/root/assets/browser-automations-page-BiQz6lJA.js +3 -0
  23. package/dist/gateway/static/root/assets/browser-settings-page-W9kuxBbE.js +3 -0
  24. package/dist/gateway/static/root/assets/{capabilities-Bpeh6E22.js → capabilities-BlxF36t-.js} +1 -1
  25. package/dist/gateway/static/root/assets/capabilities-page-iXe87MdG.js +2 -0
  26. package/dist/gateway/static/root/assets/capabilities-settings-panel-CRLSXe7Z.js +8 -0
  27. package/dist/gateway/static/root/assets/{capability-header-actions-BasrAWA0.js → capability-header-actions-BMnbzHms.js} +1 -1
  28. package/dist/gateway/static/root/assets/channels-CrRJkOKX.js +1 -0
  29. package/dist/gateway/static/root/assets/{chat-terminal-dock-CwQbzcZ_.js → chat-terminal-dock-Bd3af4gL.js} +2 -2
  30. package/dist/gateway/static/root/assets/{computer-settings-page-DNWeJKfF.js → computer-settings-page-DXfqy7xh.js} +1 -1
  31. package/dist/gateway/static/root/assets/{connector-service-page-CxHgC5RM.js → connector-service-page-B-cw0CPU.js} +1 -1
  32. package/dist/gateway/static/root/assets/connectors-page-DbFxc0Fd.js +1 -0
  33. package/dist/gateway/static/root/assets/{date-picker-CXxLbLJb.js → date-picker-CqzXevH6.js} +1 -1
  34. package/dist/gateway/static/root/assets/{dependency-picker-DVuWMrSj.js → dependency-picker-pgT4Gyaf.js} +1 -1
  35. package/dist/gateway/static/root/assets/{desktop-pet-settings-BDlg9g4s.js → desktop-pet-settings-Dy_-i2L8.js} +1 -1
  36. package/dist/gateway/static/root/assets/{desktop-pet-KbVLtAlO.js → desktop-pet-zICeqw9c.js} +1 -1
  37. package/dist/gateway/static/root/assets/device-pairing-wizard-ByGbxqkg.js +1 -0
  38. package/dist/gateway/static/root/assets/{directory-picker-path-field-a7xEodzo.js → directory-picker-path-field-C-aQ7qoM.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-debug-page-CHelH5u_.js → extension-debug-page-2NwpYkS5.js} +1 -1
  40. package/dist/gateway/static/root/assets/{extension-page-CrVHmS9-.js → extension-page-y9J0z7_Q.js} +1 -1
  41. package/dist/gateway/static/root/assets/{extension-settings-page-CiMybi0r.js → extension-settings-page-BtowusUh.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-DF_HV6NP.js → gateway-config-swr-fQKBHBi1.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-realtime-C52ghnBK.js +1 -0
  44. package/dist/gateway/static/root/assets/gateway-realtime-store-Bx9KCID-.js +1 -0
  45. package/dist/gateway/static/root/assets/gateway-settings-BYSKzUMR.js +1 -0
  46. package/dist/gateway/static/root/assets/{gateway-startup-retry-B91CBTzO.js → gateway-startup-retry-Cfwxof4k.js} +1 -1
  47. package/dist/gateway/static/root/assets/highlight-code-Cz6eeDH5.js +1 -0
  48. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-8ACAVktj.js → highlighted-body-KQOG7T2V-BiAa8HKC.js} +1 -1
  49. package/dist/gateway/static/root/assets/home-page-Cd1BjYHj.js +2 -0
  50. package/dist/gateway/static/root/assets/{image-generation-api-CVBaWmrV.js → image-generation-api-gBFro48x.js} +1 -1
  51. package/dist/gateway/static/root/assets/{imports-page-C5IP3e6d.js → imports-page-BZQpXgjj.js} +1 -1
  52. package/dist/gateway/static/root/assets/index-Cy16gQST.css +1 -0
  53. package/dist/gateway/static/root/assets/index-DRyGCING.js +710 -0
  54. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BhU6VYvd.js → keyboard-shortcuts-settings-CYunR34k.js} +1 -1
  55. package/dist/gateway/static/root/assets/local-app-workbench-page-B_Ac1lly.js +1 -0
  56. package/dist/gateway/static/root/assets/{local-apps-page-DcP1Bdlk.js → local-apps-page-w-J5bY02.js} +1 -1
  57. package/dist/gateway/static/root/assets/{local-session-drafts-DvmwiLUx.js → local-session-drafts-iGX_6O0O.js} +1 -1
  58. package/dist/gateway/static/root/assets/{locale-store-JogcXC4J.js → locale-store-B7s2Hb35.js} +1 -1
  59. package/dist/gateway/static/root/assets/logs-page-Dnjvvx2i.js +2 -0
  60. package/dist/gateway/static/root/assets/management-settings-w1EDwgLW.js +1 -0
  61. package/dist/gateway/static/root/assets/{media-plugins-BnPpcJ2J.js → media-plugins-CIx1koXw.js} +1 -1
  62. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DISkHmEC.js +1 -0
  63. package/dist/gateway/static/root/assets/{messages-RzwPiQNL.js → messages-BYq0cPbn.js} +2 -2
  64. package/dist/gateway/static/root/assets/note-detail-panel-CNkxMTFU.js +5 -0
  65. package/dist/gateway/static/root/assets/note-image-lightbox-D5GH2wuC.js +1 -0
  66. package/dist/gateway/static/root/assets/notes-page-DZgKqFBG.js +8 -0
  67. package/dist/gateway/static/root/assets/page-context-capture-button-DusR2Itk.js +1 -0
  68. package/dist/gateway/static/root/assets/personal-page-CR5JFkQ9.js +1 -0
  69. package/dist/gateway/static/root/assets/personal-settings-panel-B7undvlr.js +1 -0
  70. package/dist/gateway/static/root/assets/phone-model-picker-fWDltRUJ.js +1 -0
  71. package/dist/gateway/static/root/assets/phone-settings-page-CsOirAiy.js +1 -0
  72. package/dist/gateway/static/root/assets/plugin-details-dialog-BOBVIB3j.js +1 -0
  73. package/dist/gateway/static/root/assets/{preview-open-alternatives-FGqN-mQx.js → preview-open-alternatives-CMxjsKSw.js} +1 -1
  74. package/dist/gateway/static/root/assets/{product-open-page-CwnHLfdL.js → product-open-page-CrlyJx5M.js} +1 -1
  75. package/dist/gateway/static/root/assets/{product-preview-content-BD6k5hF9.js → product-preview-content-B-Jhzi7W.js} +1 -1
  76. package/dist/gateway/static/root/assets/project-detail-page-DoYUbtcI.js +7 -0
  77. package/dist/gateway/static/root/assets/projects-page-xGQd9oAZ.js +1 -0
  78. package/dist/gateway/static/root/assets/refresh-cw-BRlGaq2w.js +1 -0
  79. package/dist/gateway/static/root/assets/{registry-api-BGqSwITi.js → registry-api-BcfoLEna.js} +1 -1
  80. package/dist/gateway/static/root/assets/remote-access-hub-Gs0Xkws9.js +1 -0
  81. package/dist/gateway/static/root/assets/{runtime-tools-api-CSm5SpnR.js → runtime-tools-api-DesqGCnE.js} +1 -1
  82. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Bwg7U7TR.js +1 -0
  83. package/dist/gateway/static/root/assets/{schema-form-DoVn5jJK.js → schema-form-ByzTNR_C.js} +1 -1
  84. package/dist/gateway/static/root/assets/{session-api-DTxZyMta.js → session-api-DdQnMwkl.js} +1 -1
  85. package/dist/gateway/static/root/assets/{session-manager-B2HDomj4.js → session-manager-B_h0jlLb.js} +1 -1
  86. package/dist/gateway/static/root/assets/sessions-page-XzK1ftbR.js +1 -0
  87. package/dist/gateway/static/root/assets/settings-advanced-gate-D_8Mvnog.js +1 -0
  88. package/dist/gateway/static/root/assets/{settings-form-section-Ce8vVv-9.js → settings-form-section-Brgd8IOV.js} +1 -1
  89. package/dist/gateway/static/root/assets/{settings-page-DP2w3ejC.js → settings-page-B6Mv02eg.js} +1 -1
  90. package/dist/gateway/static/root/assets/settings-page-header-BWyxJKOG.js +1 -0
  91. package/dist/gateway/static/root/assets/{settings-page-layout-B20AfmFG.js → settings-page-layout-DLHcS-0T.js} +1 -1
  92. package/dist/gateway/static/root/assets/setup-status-panel-DSCj5yis.js +1 -0
  93. package/dist/gateway/static/root/assets/{share-preview-page-DV4dKrmG.js → share-preview-page-DF8Of0aZ.js} +1 -1
  94. package/dist/gateway/static/root/assets/shares-settings-DXNPe4Tl.js +1 -0
  95. package/dist/gateway/static/root/assets/{skill-api-DTdejInH.js → skill-api-CKCDCHLq.js} +1 -1
  96. package/dist/gateway/static/root/assets/skill-reload-api-BH0WF6Br.js +1 -0
  97. package/dist/gateway/static/root/assets/skills-page-DFWMVRW4.js +2 -0
  98. package/dist/gateway/static/root/assets/system-settings-panel-DB-ttubV.js +1 -0
  99. package/dist/gateway/static/root/assets/task-detail-page-BJY7c8wb.js +2 -0
  100. package/dist/gateway/static/root/assets/{task-result-evidence-DIGSC4qF.js → task-result-evidence-B-vt1BgK.js} +1 -1
  101. package/dist/gateway/static/root/assets/{tracing-settings-page-BaU8frtc.js → tracing-settings-page-Dt51Z_ws.js} +1 -1
  102. package/dist/gateway/static/root/assets/{tunnel-api-BCcOUsqu.js → tunnel-api-Dok3t7Qe.js} +1 -1
  103. package/dist/gateway/static/root/assets/usage-page-lJym5G7F.js +1 -0
  104. package/dist/gateway/static/root/assets/{use-autosave-C1X47WVb.js → use-autosave-D4EMIB-V.js} +1 -1
  105. package/dist/gateway/static/root/assets/user-model-page-BXdNkITp.js +2 -0
  106. package/dist/gateway/static/root/assets/{voice-api-key-field-Bk4DQMTw.js → voice-api-key-field-CO3KuanA.js} +1 -1
  107. package/dist/gateway/static/root/assets/{voice-config-api-D7xsWrdh.js → voice-config-api-BkUlN7GH.js} +1 -1
  108. package/dist/gateway/static/root/assets/{work-discovery-overlay-B7_NmTB5.js → work-discovery-overlay-BJRtgQM3.js} +1 -1
  109. package/dist/gateway/static/root/assets/wrench-DFb4r8bH.js +1 -0
  110. package/dist/gateway/static/root/assets/xopc-cloud-account-card-CS-_GxHV.js +1 -0
  111. package/dist/gateway/static/root/browser-setup-test.html +5 -0
  112. package/dist/gateway/static/root/browser-setup-test.js +7 -0
  113. package/dist/gateway/static/root/index.html +17 -14
  114. package/dist/package.js +1 -1
  115. package/dist/packages/gateway-contract/src/browser-setup.js +6 -0
  116. package/dist/packages/gateway-contract/src/index.js +4 -0
  117. package/dist/packages/gateway-contract/src/phone-setup.js +6 -0
  118. package/dist/packages/realtime-client/src/index.js +1 -0
  119. package/dist/packages/realtime-protocol/src/index.js +1 -0
  120. package/dist/src/agent/agent-manager.d.ts +4 -0
  121. package/dist/src/agent/agent-manager.js +12 -1
  122. package/dist/src/agent/coding/workspace-revision.js +1 -1
  123. package/dist/src/agent/commands/command-registry.js +1 -1
  124. package/dist/src/agent/embedded/tool-search-extension.js +14 -1
  125. package/dist/src/agent/memory/context-recovery.d.ts +1 -1
  126. package/dist/src/agent/service.d.ts +1 -0
  127. package/dist/src/agent/service.js +5 -0
  128. package/dist/src/agent/service.types.d.ts +2 -0
  129. package/dist/src/agent/skills/installer.js +3 -3
  130. package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
  131. package/dist/src/agent/tool-manuals/phone.js +4 -2
  132. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +2 -0
  133. package/dist/src/agent/tool-manuals/xopc-configuration.js +25 -0
  134. package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +2 -0
  135. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +6 -2
  136. package/dist/src/agent/tools/factory.d.ts +3 -0
  137. package/dist/src/agent/tools/factory.js +11 -1
  138. package/dist/src/agent/tools/personal-task-tool.d.ts +1 -1
  139. package/dist/src/agent/tools/personal-task-tool.js +23 -21
  140. package/dist/src/agent/tools/phone-use-tool.d.ts +1 -0
  141. package/dist/src/agent/tools/phone-use-tool.js +29 -1
  142. package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -1
  143. package/dist/src/agent/tools/tool-manual-tool.js +3 -1
  144. package/dist/src/agent/tools/toolExposure.js +3 -0
  145. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  146. package/dist/src/agent/tools/xopc-use-tool.js +40 -2
  147. package/dist/src/backup/archive.js +2 -1
  148. package/dist/src/browser/drivers/browser-driver.d.ts +2 -2
  149. package/dist/src/browser/drivers/extension-driver.d.ts +2 -2
  150. package/dist/src/browser/drivers/extension-driver.js +6 -3
  151. package/dist/src/browser/providers/browser-ext-install.js +3 -2
  152. package/dist/src/browser/runtime/browser-runtime.d.ts +4 -1
  153. package/dist/src/browser/runtime/browser-runtime.js +29 -17
  154. package/dist/src/browser/setup/repository.d.ts +5 -0
  155. package/dist/src/browser/setup/repository.js +42 -0
  156. package/dist/src/browser/setup/service.d.ts +152 -0
  157. package/dist/src/browser/setup/service.js +404 -0
  158. package/dist/src/browser/setup/types.d.ts +38 -0
  159. package/dist/src/browser/setup/types.js +1 -0
  160. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  161. package/dist/src/cli/commands/extension-marketplace.js +3 -3
  162. package/dist/src/cli/commands/extension-pack.js +1 -1
  163. package/dist/src/cli/commands/extension.js +2 -2
  164. package/dist/src/config/schema.d.ts +2 -0
  165. package/dist/src/extensions/install.js +1 -1
  166. package/dist/src/extensions/update.js +1 -1
  167. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  168. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  169. package/dist/src/gateway/hono/routes/browser-setup.d.ts +3 -0
  170. package/dist/src/gateway/hono/routes/browser-setup.js +114 -0
  171. package/dist/src/gateway/hono/routes/browser.d.ts +2 -1
  172. package/dist/src/gateway/hono/routes/browser.js +1 -1
  173. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  174. package/dist/src/gateway/hono/routes/phone-dependencies.js +1 -1
  175. package/dist/src/gateway/hono/routes/phone-setup.d.ts +7 -0
  176. package/dist/src/gateway/hono/routes/phone-setup.js +162 -0
  177. package/dist/src/gateway/hono/routes/phone.js +11 -7
  178. package/dist/src/gateway/hono/routes/public-gateway.js +2 -0
  179. package/dist/src/gateway/provider-model-setup.js +1 -1
  180. package/dist/src/gateway/service/config-coordinator.d.ts +2 -0
  181. package/dist/src/gateway/service/config-coordinator.js +1 -1
  182. package/dist/src/gateway/service/session-input-coordinator.js +1 -1
  183. package/dist/src/gateway/service.d.ts +5 -0
  184. package/dist/src/gateway/service.js +52 -7
  185. package/dist/src/gateway/xopc-cloud-capability-setup.js +7 -1
  186. package/dist/src/home-intelligence/host.js +2 -2
  187. package/dist/src/infra/unhandled-rejections.js +2 -2
  188. package/dist/src/infra/update-runner.js +1 -1
  189. package/dist/src/personal-agent/prompts.js +1 -1
  190. package/dist/src/phone/adb-driver.d.ts +8 -2
  191. package/dist/src/phone/adb-driver.js +124 -54
  192. package/dist/src/phone/cloud-adb.js +8 -0
  193. package/dist/src/phone/cloud-scrcpy.d.ts +3 -1
  194. package/dist/src/phone/cloud-scrcpy.js +17 -3
  195. package/dist/src/phone/contracts.d.ts +85 -0
  196. package/dist/src/phone/contracts.js +31 -5
  197. package/dist/src/phone/model-adapter.d.ts +141 -2
  198. package/dist/src/phone/model-adapter.js +176 -24
  199. package/dist/src/phone/numeric-entry.d.ts +31 -0
  200. package/dist/src/phone/numeric-entry.js +126 -0
  201. package/dist/src/phone/planning.d.ts +27 -0
  202. package/dist/src/phone/planning.js +79 -0
  203. package/dist/src/phone/recovery.d.ts +37 -0
  204. package/dist/src/phone/recovery.js +81 -0
  205. package/dist/src/phone/reliability.d.ts +7 -0
  206. package/dist/src/phone/reliability.js +66 -0
  207. package/dist/src/phone/repository.d.ts +1 -0
  208. package/dist/src/phone/repository.js +3 -0
  209. package/dist/src/phone/runtime.d.ts +8 -0
  210. package/dist/src/phone/runtime.js +387 -41
  211. package/dist/src/phone/scrcpy-text.d.ts +11 -0
  212. package/dist/src/phone/scrcpy-text.js +72 -0
  213. package/dist/src/phone/scrcpy.d.ts +5 -1
  214. package/dist/src/phone/scrcpy.js +48 -3
  215. package/dist/src/phone/semantic-controls.d.ts +13 -0
  216. package/dist/src/phone/semantic-controls.js +76 -0
  217. package/dist/src/phone/setup/service.d.ts +148 -0
  218. package/dist/src/phone/setup/service.js +251 -0
  219. package/dist/src/providers/presentation.js +2 -2
  220. package/dist/src/providers/xopc-cloud-model-source.js +6 -2
  221. package/dist/src/realtime/runtime.js +1 -1
  222. package/dist/src/storage/sqlite/connection.js +2 -2
  223. package/dist/src/storage/sqlite/offline-access.js +13 -7
  224. package/dist/src/storage/sqlite/schema-errors.d.ts +12 -0
  225. package/dist/src/storage/sqlite/schema-errors.js +21 -3
  226. package/dist/src/storage/sqlite/schema-upgrade.d.ts +4 -0
  227. package/dist/src/storage/sqlite/schema-upgrade.js +78 -0
  228. package/dist/src/storage/sqlite/schema.d.ts +4 -3
  229. package/dist/src/storage/sqlite/schema.js +14 -8
  230. package/dist/src/storage/sqlite/schema.sql +10 -0
  231. package/dist/src/storage/sqlite/upgrades/203_remove_retired_proactive_contracts.sql +70 -0
  232. package/dist/src/storage/sqlite/upgrades/204_home_intelligence.sql +78 -0
  233. package/dist/src/storage/sqlite/upgrades/205_agent_catalog.sql +66 -0
  234. package/dist/src/storage/sqlite/upgrades/206_home_advice_strategy_version.sql +2 -0
  235. package/dist/src/storage/sqlite/upgrades/207_user_model_policy_contract.sql +121 -0
  236. package/dist/src/storage/sqlite/upgrades/208_automation_management.sql +2 -0
  237. package/dist/src/storage/sqlite/upgrades/209_automation_event_hub.sql +48 -0
  238. package/dist/src/storage/sqlite/upgrades/210_remove_legacy_automation_timeout.sql +14 -0
  239. package/dist/src/storage/sqlite/upgrades/211_automation_result_deliveries.sql +16 -0
  240. package/dist/src/storage/sqlite/upgrades/212_automation_delivery_policy.sql +30 -0
  241. package/dist/src/storage/sqlite/upgrades/213_automation_reliability_contract.sql +188 -0
  242. package/dist/src/storage/sqlite/upgrades/214_ai_usage_ledger.sql +41 -0
  243. package/dist/src/storage/sqlite/upgrades/215_scene_execution_adapters.sql +6 -0
  244. package/dist/src/storage/sqlite/upgrades/216_remove_scene_model_usage.sql +1 -0
  245. package/dist/src/storage/sqlite/upgrades/217_remove_legacy_memory_tables.sql +4 -0
  246. package/dist/src/storage/sqlite/upgrades/218_core_relation_indexes.sql +26 -0
  247. package/dist/src/storage/sqlite/upgrades/219_json_contracts.sql +123 -0
  248. package/dist/src/storage/sqlite/upgrades/220_normalize_timestamps.sql +339 -0
  249. package/dist/src/storage/sqlite/upgrades/221_ai_usage_retention_index.sql +2 -0
  250. package/dist/src/storage/sqlite/upgrades/222_session_config_authority.sql +13 -0
  251. package/dist/src/storage/sqlite/upgrades/223_session_creation_receipts.sql +59 -0
  252. package/dist/src/storage/sqlite/upgrades/224_task_origin_links.sql +8 -0
  253. package/dist/src/storage/sqlite/upgrades/225_task_collaboration.sql +32 -0
  254. package/dist/src/storage/sqlite/upgrades/226_task_main_updates.sql +9 -0
  255. package/dist/src/storage/sqlite/upgrades/227_task_main_update_decisions.sql +8 -0
  256. package/dist/src/storage/sqlite/upgrades/228_task_main_agent_links.sql +14 -0
  257. package/dist/src/storage/sqlite/upgrades/229_task_criterion_reviews.sql +12 -0
  258. package/dist/src/storage/sqlite/upgrades/230_personal_agent_onboarding.sql +8 -0
  259. package/dist/src/storage/sqlite/upgrades/231_task_result_deliveries.sql +32 -0
  260. package/dist/src/storage/sqlite/upgrades/232_personal_requests.sql +28 -0
  261. package/dist/src/storage/sqlite/upgrades/233_observability_usage_links.sql +3 -0
  262. package/dist/src/storage/sqlite/upgrades/234_task_result_reply.sql +14 -0
  263. package/dist/src/storage/sqlite/upgrades/235_personal_conversation_priority.sql +3 -0
  264. package/dist/src/storage/sqlite/upgrades/236_personal_proactivity.sql +53 -0
  265. package/dist/src/storage/sqlite/upgrades/237_personal_strategy_versions.sql +18 -0
  266. package/dist/src/storage/sqlite/upgrades/238_browser_record_replay.sql +45 -0
  267. package/dist/src/storage/sqlite/upgrades/239_clarification_notifications.sql +26 -0
  268. package/dist/src/storage/sqlite/upgrades/240_device_settings.sql +5 -0
  269. package/dist/src/storage/sqlite/upgrades/241_device_grant_audit.sql +13 -0
  270. package/dist/src/storage/sqlite/upgrades/242_cloud_usage_receipts.sql +5 -0
  271. package/dist/src/storage/sqlite/upgrades/243_voice_opening_greetings.sql +12 -0
  272. package/dist/src/storage/sqlite/upgrades/244_device_request_proofs.sql +8 -0
  273. package/dist/src/storage/sqlite/upgrades/245_memory_learning.sql +125 -0
  274. package/dist/src/storage/sqlite/upgrades/246_personal_session_thinking.sql +22 -0
  275. package/dist/src/storage/sqlite/upgrades/247_agent_selection_records.sql +32 -0
  276. package/dist/src/storage/sqlite/upgrades/248_next_turn_suggestions.sql +20 -0
  277. package/dist/src/storage/sqlite/upgrades/249_task_allocations.sql +17 -0
  278. package/dist/src/storage/sqlite/upgrades/250_research_checkpoints.sql +15 -0
  279. package/dist/src/storage/sqlite/upgrades/251_personal_result_reads.sql +40 -0
  280. package/dist/src/storage/sqlite/upgrades/252_task_work_revisions.sql +15 -0
  281. package/dist/src/storage/sqlite/upgrades/253_discussion_processing_recovery.sql +20 -0
  282. package/dist/src/storage/sqlite/upgrades/254_discussion_annotations.sql +17 -0
  283. package/dist/src/storage/sqlite/upgrades/255_discussion_chapter_progress.sql +10 -0
  284. package/dist/src/storage/sqlite/upgrades/256_task_main_update_retries.sql +21 -0
  285. package/dist/src/storage/sqlite/upgrades/257_session_composer_history.sql +11 -0
  286. package/dist/src/storage/sqlite/upgrades/258_task_phase_changes.sql +20 -0
  287. package/dist/src/storage/sqlite/upgrades/259_personal_default_style.sql +10 -0
  288. package/dist/src/storage/sqlite/upgrades/260_browser_setup.sql +9 -0
  289. package/dist/src/storage/sqlite/windows-database-owners.js +33 -28
  290. package/dist/src/tasks/capabilities/relations.d.ts +2 -2
  291. package/dist/src/tui/clipboard-image.js +1 -1
  292. package/dist/src/tui/tui.js +1 -1
  293. package/dist/src/utils/index.js +1 -1
  294. package/dist/src/utils/logger/index.js +1 -1
  295. package/dist/src/utils/logger.js +1 -1
  296. package/dist/src/work-discovery/probe.js +1 -1
  297. package/package.json +3 -3
  298. package/skills/tools/configure-xopc/SKILL.md +47 -0
  299. package/skills/tools/configure-xopc/references/browser/acceptance.md +31 -0
  300. package/skills/tools/configure-xopc/references/browser/chrome-extension.md +19 -0
  301. package/skills/tools/configure-xopc/references/browser/overview.md +22 -0
  302. package/skills/tools/configure-xopc/references/browser/permissions.md +25 -0
  303. package/skills/tools/configure-xopc/references/browser/troubleshooting.md +24 -0
  304. package/skills/tools/configure-xopc/references/phone/acceptance.md +25 -0
  305. package/skills/tools/configure-xopc/references/phone/aliyun.md +29 -0
  306. package/skills/tools/configure-xopc/references/phone/dependencies.md +18 -0
  307. package/skills/tools/configure-xopc/references/phone/local.md +19 -0
  308. package/skills/tools/configure-xopc/references/phone/models.md +18 -0
  309. package/skills/tools/configure-xopc/references/phone/overview.md +30 -0
  310. package/skills/tools/configure-xopc/references/phone/troubleshooting.md +24 -0
  311. package/skills/tools/configure-xopc/references/scene-index.md +12 -0
  312. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-mf0jgEPE.js +0 -1
  313. package/dist/gateway/static/root/assets/agents-CKhZ4UYQ.js +0 -77
  314. package/dist/gateway/static/root/assets/apps-page-BZ_MaQJf.js +0 -1
  315. package/dist/gateway/static/root/assets/automations-workspace-CHUDHNVL.js +0 -8
  316. package/dist/gateway/static/root/assets/browser-automations-page-DStDm9y1.js +0 -3
  317. package/dist/gateway/static/root/assets/browser-settings-page-6I4oetKt.js +0 -3
  318. package/dist/gateway/static/root/assets/capabilities-page-C-EecWbS.js +0 -2
  319. package/dist/gateway/static/root/assets/capabilities-settings-panel-BQoCPk3x.js +0 -8
  320. package/dist/gateway/static/root/assets/channels-BKf_-Mdt.js +0 -1
  321. package/dist/gateway/static/root/assets/connectors-page-CUBg8spT.js +0 -1
  322. package/dist/gateway/static/root/assets/device-pairing-wizard-PmP_vGem.js +0 -1
  323. package/dist/gateway/static/root/assets/gateway-realtime-DMAzNlm-.js +0 -1
  324. package/dist/gateway/static/root/assets/gateway-realtime-store-CoIgC1Al.js +0 -1
  325. package/dist/gateway/static/root/assets/gateway-settings-DnrQ28E2.js +0 -1
  326. package/dist/gateway/static/root/assets/highlight-code-AMjU04kR.js +0 -1
  327. package/dist/gateway/static/root/assets/home-page-pTwVME-g.js +0 -2
  328. package/dist/gateway/static/root/assets/index-BLL0wKRZ.css +0 -1
  329. package/dist/gateway/static/root/assets/index-ygkHNYyo.js +0 -710
  330. package/dist/gateway/static/root/assets/local-app-workbench-page-Cwl6EvuX.js +0 -1
  331. package/dist/gateway/static/root/assets/logs-page-CS3hcTOq.js +0 -2
  332. package/dist/gateway/static/root/assets/management-settings-DC-Y_-GP.js +0 -1
  333. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-vckgHpON.js +0 -1
  334. package/dist/gateway/static/root/assets/note-detail-panel-C7u4dxEk.js +0 -5
  335. package/dist/gateway/static/root/assets/note-image-lightbox-jvqYtySx.js +0 -1
  336. package/dist/gateway/static/root/assets/notes-page-Bs7F5Hpf.js +0 -8
  337. package/dist/gateway/static/root/assets/page-context-capture-button-DO_yhXS1.js +0 -1
  338. package/dist/gateway/static/root/assets/personal-page-BexL2-PQ.js +0 -1
  339. package/dist/gateway/static/root/assets/personal-settings-panel-BKA4fbYH.js +0 -1
  340. package/dist/gateway/static/root/assets/phone-dependencies-card-ChFtdFhA.js +0 -1
  341. package/dist/gateway/static/root/assets/phone-model-picker-CZoIAQ1j.js +0 -1
  342. package/dist/gateway/static/root/assets/phone-settings-page-DRyK0nHH.js +0 -1
  343. package/dist/gateway/static/root/assets/plugin-details-dialog-B-N61jJH.js +0 -1
  344. package/dist/gateway/static/root/assets/project-detail-page-DtKmFBml.js +0 -7
  345. package/dist/gateway/static/root/assets/projects-page-CFZIz9mc.js +0 -1
  346. package/dist/gateway/static/root/assets/remote-access-hub-CWEc7W0m.js +0 -1
  347. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-q_oswAdV.js +0 -1
  348. package/dist/gateway/static/root/assets/sessions-page-BuPqNxpd.js +0 -1
  349. package/dist/gateway/static/root/assets/settings-advanced-gate-QTVDCGJG.js +0 -1
  350. package/dist/gateway/static/root/assets/settings-page-header-CYpuTXUW.js +0 -1
  351. package/dist/gateway/static/root/assets/setup-status-panel-ZmlE8jIE.js +0 -1
  352. package/dist/gateway/static/root/assets/shares-settings-CtNxWqW-.js +0 -1
  353. package/dist/gateway/static/root/assets/skill-reload-api-Egaf8PqZ.js +0 -1
  354. package/dist/gateway/static/root/assets/skills-page-C6FKxf4J.js +0 -2
  355. package/dist/gateway/static/root/assets/system-settings-panel-Baxkhov7.js +0 -1
  356. package/dist/gateway/static/root/assets/task-detail-page-C77-rpkt.js +0 -2
  357. package/dist/gateway/static/root/assets/usage-page-BFeIbpbi.js +0 -1
  358. package/dist/gateway/static/root/assets/user-model-page-u8zY5jea.js +0 -2
  359. package/dist/gateway/static/root/assets/xopc-cloud-account-card-CJ_akAvc.js +0 -1
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a,u as o}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as s}from"./check-DUBLcKHA.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{i as u,n as d}from"./locale-store-JogcXC4J.js";import{a as f}from"./local-apps-yys1VChX.js";import{a as p,i as m}from"./vendor-swr-BIWyz7Rc.js";import{t as h}from"./button-aIC072nz.js";import{t as g}from"./skeleton-BI5TyibZ.js";import{$u as _,Ar as te,Bc as v,Bl as y,Cl as ne,Dr as b,Er as x,Fc as S,Fl as re,Fr as ie,Ic as C,Ir as ae,Jd as oe,Lc as se,Lr as ce,Mr as le,Or as ue,Pa as de,Pl as fe,Pr as pe,Rc as me,Rr as he,Tr as ge,Uu as _e,Vc as ve,Vl as ye,ad as be,bd as w,eu as xe,il as Se,io as Ce,kr as we,mu as T,qc as Te,rl as Ee,vl as De,wd as E,zc as Oe}from"./index-ygkHNYyo.js";import{r as ke}from"./date-formatters-DukWSVwc.js";import{n as Ae,t as je}from"./tab-completion-input-CxtEp0aP.js";import{t as Me}from"./page-context-capture-button-DO_yhXS1.js";var D=e(t(),1);function Ne(e){return e.replace(/^(?:例如\s*[::]?|for example\s*[::]?|e\.g\.\s*)/i,``).replace(/…$/,``).trim()}var Pe=`build-xopc-local-app`;function O(e){return(e.routing?.agentId??e.agentId??``).trim().toLowerCase()}function Fe(e){return e.find(e=>O(e)===`coder`)??null}function Ie(e,t){let n=new URLSearchParams({skill:Pe}),r=t?.trim();return r&&n.set(`draft`,r),`/chat/${encodeURIComponent(e)}?${n.toString()}`}var Le=n(),k=r();function Re(e){let t=(0,Le.c)(36),{scenarios:n,results:r,runningTarget:i,zh:a,onRunAll:o,onRunScenario:s,onAskCoder:c}=e;if(!n.length)return null;let u=a?`产品场景`:`Product scenarios`,d;t[0]===u?d=t[1]:(d=(0,k.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:u}),t[0]=u,t[1]=d);let f=a?`${n.length} 个关键用户路径`:`${n.length} critical user journey${n.length===1?``:`s`}`,p;t[2]===f?p=t[3]:(p=(0,k.jsx)(`p`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:f}),t[2]=f,t[3]=p);let m;t[4]!==d||t[5]!==p?(m=(0,k.jsxs)(`div`,{children:[d,p]}),t[4]=d,t[5]=p,t[6]=m):m=t[6];let g=i!==null,_;t[7]===i?_=t[8]:(_=i===`all`?(0,k.jsx)(l,{className:`size-3 animate-spin`}):(0,k.jsx)(re,{className:`size-3`}),t[7]=i,t[8]=_);let te=a?`全部重跑`:`Run all`,v;t[9]!==o||t[10]!==g||t[11]!==_||t[12]!==te?(v=(0,k.jsxs)(h,{variant:`ghost`,className:`h-7 rounded-lg px-2 text-[11px]`,onClick:o,disabled:g,children:[_,te]}),t[9]=o,t[10]=g,t[11]=_,t[12]=te,t[13]=v):v=t[13];let y;t[14]!==m||t[15]!==v?(y=(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[m,v]}),t[14]=m,t[15]=v,t[16]=y):y=t[16];let ne=a?`产品场景验收结果`:`Product scenario acceptance results`,b;if(t[17]!==c||t[18]!==s||t[19]!==r||t[20]!==i||t[21]!==n||t[22]!==a){let e;t[24]!==c||t[25]!==s||t[26]!==r||t[27]!==i||t[28]!==a?(e=e=>{let t=r[e.id],n=i===`all`||i===e.id?`running`:t?.status??`pending`;return(0,k.jsx)(`li`,{className:`py-2.5 first:pt-1`,children:(0,k.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,k.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:n===`running`?(0,k.jsx)(l,{className:`size-3.5 animate-spin text-accent`}):n===`passed`?(0,k.jsx)(ee,{className:`size-3.5 text-success`}):n===`failed`?(0,k.jsx)(E,{className:`size-3.5 text-danger`}):(0,k.jsx)(w,{className:`size-3.5 text-fg-subtle`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-[11px] font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`mt-0.5 text-[10px] text-fg-subtle`,children:a?`${e.stepCount} 个步骤`:`${e.stepCount} step${e.stepCount===1?``:`s`}`})]}),(0,k.jsx)(h,{variant:`ghost`,className:`size-7 shrink-0 rounded-lg p-0`,onClick:()=>s(e.id),disabled:i!==null,"aria-label":a?`重跑${e.name}`:`Rerun ${e.name}`,title:a?`单独重跑`:`Rerun scenario`,children:(0,k.jsx)(re,{className:`size-3`})})]}),n===`running`?(0,k.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`正在隔离预览中执行…`:`Running in an isolated preview…`}):t?.status===`failed`?(0,k.jsxs)(`div`,{className:`mt-1.5`,children:[(0,k.jsx)(`p`,{className:`text-[11px] leading-4 text-danger`,children:t.message}),(0,k.jsxs)(h,{variant:`ghost`,className:`mt-1 h-7 rounded-lg px-2 text-[11px] text-danger hover:text-danger`,onClick:()=>c(e,t),children:[(0,k.jsx)(T,{className:`size-3`}),a?`让 Coder 修复`:`Ask Coder to fix`]})]}):t?.status===`passed`?(0,k.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`场景已通过`:`Scenario passed`}):(0,k.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`等待运行`:`Waiting to run`})]})]})},e.id)},t[24]=c,t[25]=s,t[26]=r,t[27]=i,t[28]=a,t[29]=e):e=t[29],b=n.map(e),t[17]=c,t[18]=s,t[19]=r,t[20]=i,t[21]=n,t[22]=a,t[23]=b}else b=t[23];let x;t[30]!==ne||t[31]!==b?(x=(0,k.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,"aria-label":ne,children:b}),t[30]=ne,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==y||t[34]!==x?(S=(0,k.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[y,x]}),t[33]=y,t[34]=x,t[35]=S):S=t[35],S}var ze=`allow-scripts allow-forms`;function Be(e,t){return ke(e,t)}function Ve(e,t,n){return!!(t&&n&&e.sourceHash===t&&e.status===n.status&&e.interactiveCount===n.interactiveCount&&JSON.stringify(e.checks)===JSON.stringify(n.checks))}function A(){let{appId:e}=i(),t=e===`new`,n=d(e=>e.language)===`zh`,r=d(e=>e.language),w=o(),{mutate:E}=p(),ke=Ce(e=>e.setPageHeader),Pe=Ce(e=>e.clearPageHeader),{data:O,isLoading:Le,error:A,mutate:He}=m(!t&&e?[`local-app`,e]:null,()=>we(e)),{data:j,isLoading:Ue,mutate:We}=m(!t&&e?[`local-app-validation`,e]:null,()=>he(e)),[Ge,Ke]=(0,D.useState)(``),[qe,Je]=(0,D.useState)(``),[M,N]=(0,D.useState)(!1),[Ye,P]=(0,D.useState)(null),[Xe,Ze]=(0,D.useState)(!1),[Qe,$e]=(0,D.useState)(!1),[et,tt]=(0,D.useState)(0),[nt,rt]=(0,D.useState)(``),[F,it]=(0,D.useState)(!1),[I,at]=(0,D.useState)(!1),[L,R]=(0,D.useState)(`booting`),[z,ot]=(0,D.useState)(null),[B,st]=(0,D.useState)(null),[V,ct]=(0,D.useState)({}),[H,lt]=(0,D.useState)(`all`),[U,W]=(0,D.useState)(0),[ut,dt]=(0,D.useState)(0),[ft,pt]=(0,D.useState)(null),[G,mt]=(0,D.useState)(null),[ht,gt]=(0,D.useState)([]),[_t,vt]=(0,D.useState)(!1),yt=(0,D.useRef)(new Set),K=(0,D.useRef)(null),bt=(0,D.useRef)(null),xt=(0,D.useRef)(null),q=(0,D.useRef)(null),J=(0,D.useRef)(``),Y=j?.acceptanceScenarios??[],X=(0,D.useMemo)(()=>{if(!Y.length)return null;let e=Y.map(e=>V[e.id]).filter(e=>!!e);return e.length===Y.length?{status:e.some(e=>e.status===`failed`)?`failed`:`passed`,scenarioCount:Y.length,scenarios:e}:null},[Y,V]),Z=(0,D.useMemo)(()=>{if(!B)return null;if(!j?.acceptanceScenarioCount)return B;if(!X)return null;let e=X.scenarios.find(e=>e.status===`failed`),t={id:`criteria`,status:X.status,message:e?`${e.name}: ${e.message}`:`${X.scenarioCount} product scenario(s) passed`},n=[...B.checks,t];return{status:n.some(e=>e.status===`failed`)?`failed`:`passed`,checks:n,interactiveCount:B.interactiveCount}},[B,X,j?.acceptanceScenarioCount]),St=(0,D.useCallback)(async(e,t)=>{let n=Fe(await de(e.projectId));if(!n){w(`/chat/new?${new URLSearchParams({projectId:e.projectId,...t?{draft:t}:{}})}`,{state:{agentId:`coder`,forceNewChat:!0}});return}yt.current.add(n.key),w(Ie(n.key,t))},[w]),Ct=(0,D.useCallback)(async(e=!0)=>{if(!O)return null;at(!0);try{let t=await he(O.id);return await We(t,{revalidate:!1}),e&&(q.current=t.sourceHash??null,lt(`all`),W(0),tt(e=>e+1)),t}catch(e){return P(e instanceof Error?e.message:String(e)),null}finally{at(!1)}},[O,We]);(0,D.useEffect)(()=>{if(!O)return;let e=!1;de(O.projectId).then(t=>{e||(yt.current=new Set(t.filter(e=>(e.routing?.agentId??e.agentId)?.toLowerCase()===`coder`).map(e=>e.key)))}).catch(()=>{});let t=e=>{let t=e.detail?.key;!t||!yt.current.has(t)||(K.current!==null&&window.clearTimeout(K.current),K.current=window.setTimeout(()=>{K.current=null,Ct(!0)},750))};return window.addEventListener(`session-transcript-updated`,t),()=>{e=!0,window.removeEventListener(`session-transcript-updated`,t),K.current!==null&&window.clearTimeout(K.current)}},[O,Ct]),(0,D.useEffect)(()=>{gt(O?.acceptanceRuns??[])},[O?.acceptanceRuns]),(0,D.useEffect)(()=>{q.current=null},[O?.id]),(0,D.useEffect)(()=>{!j?.sourceHash||q.current===j.sourceHash||(q.current=j.sourceHash,lt(`all`),W(0),tt(e=>e+1))},[O?.id,j?.sourceHash]),(0,D.useLayoutEffect)(()=>{if(!O)return;R(`booting`),ot(null),st(null),mt(null),vt(!1),J.current=``;let e=window.setTimeout(()=>R(e=>e===`failed`?e:`timeout`),7e3),t=bt.current?b(bt.current,t=>{let n=f(t);if(n){if(n.type===`ready`){R(e=>e===`failed`?e:`healthy`);return}if(n.type===`acceptance`){window.clearTimeout(e),st(n.detail),mt(q.current);return}n.type!==`criteria`&&(window.clearTimeout(e),ot(n.detail),R(`failed`))}}):()=>{};return()=>{window.clearTimeout(e),t()}},[O,et]),(0,D.useLayoutEffect)(()=>{if(!O||j?.status!==`healthy`||!Y.length){pt(null);return}let e=H===`all`?Y[U]:Y.find(e=>e.id===H),t=e?[e]:[];if(!t.length)return;pt(H),ct(e=>{if(H===`all`&&U===0)return{};let t={...e};return delete t[H],t});let r=!1,i=e=>{ct(n=>{let r={...n};for(let n of t)r[n.id]={id:n.id,name:n.name,status:`failed`,message:e,failureKind:`runner`};return r}),pt(null)},a=window.setTimeout(()=>i(r?n?`场景在 10 秒内未完成。`:`Scenario did not finish within 10 seconds.`:n?`验收执行器未能连接,请重新验收。`:`The acceptance runner did not connect. Run acceptance again.`),1e4),o=xt.current?b(xt.current,e=>{let t=f(e);t&&(t.type===`ready`?r=!0:t.type===`criteria`?(window.clearTimeout(a),ct(e=>{let n={...e};for(let e of t.detail.scenarios)(n[e.id]?.status!==`failed`||e.status===`failed`)&&(n[e.id]=e);return n}),H===`all`&&U+1<Y.length?(W(e=>e+1),dt(e=>e+1)):pt(null)):t.type===`error`&&(window.clearTimeout(a),i(ge(t.detail))))}):()=>{};return()=>{window.clearTimeout(a),o()}},[Y,O,ut,H,U,et,j?.status,n]),(0,D.useEffect)(()=>{if(!O||!Z||!G||G!==j?.sourceHash)return;let e=`${O.id}:${G}:${JSON.stringify(Z)}`;J.current!==e&&(J.current=e,vt(!0),pe(O.id,G,Z).then(t=>{J.current===e&&gt(e=>[t,...e.filter(e=>e.id!==t.id)].toSorted((e,t)=>t.createdAt-e.createdAt).slice(0,20))}).catch(t=>{J.current===e&&(J.current=``,vt(!1),P(t instanceof Error?t.message:String(t)))}).finally(()=>{J.current===e&&vt(!1)}))},[Z,G,O,j?.sourceHash]);let Q=(0,D.useCallback)(async e=>{if(O){it(!0),P(null);try{await St(O,e)}catch(e){P(e instanceof Error?e.message:String(e)),it(!1)}}},[O,St]);(0,D.useLayoutEffect)(()=>(ke({startExtra:(0,k.jsx)(a,{to:`/local-apps`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`返回应用工坊`:`Back to App Studio`,children:(0,k.jsx)(oe,{className:`size-4`})}),main:(0,k.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:O?.name||(n?`创建应用`:`Create app`)}),end:O?(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(Me,{resource:{kind:`local_app`,id:O.id,revision:j?.sourceHash??``},disabled:M||F||I||!j?.sourceHash}),(0,k.jsx)(h,{asChild:!0,variant:`ghost`,className:`h-9`,children:(0,k.jsxs)(a,{to:`/projects/${encodeURIComponent(O.projectId)}`,children:[(0,k.jsx)(_,{className:`size-4`}),`Project`]})}),(0,k.jsxs)(h,{className:`h-9`,onClick:()=>void Q(),disabled:F,children:[F?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(T,{className:`size-4`}),n?`继续开发`:`Continue building`]})]}):null}),()=>Pe()),[O,M,F,I,j?.sourceHash,Pe,Q,ke,n]);async function wt(e){e.preventDefault(),N(!0),P(null);try{let e=await ue({name:Ge,idea:qe});await E(`local-apps-list`);let t=n?`请基于 APP_BRIEF.md 完成这个本地应用的首版。先检查现有草稿,再实现最小可用版本并运行校验;完成后告诉我可以如何预览。`:`Build the first usable version of this local app from APP_BRIEF.md. Inspect the existing draft, implement the smallest useful version, run validation, and tell me how to preview it.`;try{await St(e,t)}catch{w(`/local-apps/${encodeURIComponent(e.id)}`,{replace:!0})}}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Tt(){if(O){N(!0),P(null);try{await He(await le(O.id),{revalidate:!1}),await We(),await Promise.all([E(`local-apps-list`),E(`gateway-extensions-list`)]),Ze(!1)}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Et(e){N(!0),P(null);try{return await He(await e(),{revalidate:!1}),await We(),await Promise.all([E(`local-apps-list`),E(`gateway-extensions-list`)]),!0}catch(e){return P(e instanceof Error?e.message:String(e)),!1}finally{N(!1)}}async function Dt(e){O&&await Et(()=>ae(O.id,e))}async function Ot(e){O&&await Et(()=>ie(O.id,e))}async function kt(){O&&await Et(()=>ce(O.id))&&$e(!1)}async function At(e){if(!(!O||!e.length)){P(null);try{await Q((await te(O.id,{sourceHash:j?.sourceHash,locale:n?`zh`:`en`,diagnostics:e})).prompt)}catch(e){P(e instanceof Error?e.message:String(e))}}}function jt(){At([...j?.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],...z?[{phase:`runtime`,code:z.kind,message:ge(z)}]:[],...Z?.checks.filter(e=>e.status===`failed`&&e.id!==`criteria`).map(e=>({phase:`acceptance`,code:e.id,message:e.message}))??[],...Object.values(V).filter(e=>e.status===`failed`).map(e=>({phase:e.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${e.message}`})),...L===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:`Preview did not report ready within 7 seconds.`}]:[]])}function Mt(){lt(`all`),W(0),dt(e=>e+1)}function Nt(e){lt(e),W(0),dt(e=>e+1)}function Pt(e,t){At([{phase:t.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${t.message}`}])}let Ft=ht.findIndex(e=>Ve(e,G,Z)),$=Ft>=0?ht[Ft]:null,It=Ft>=0?ht[Ft+1]??null:ht[0]??null,Lt=x(Z),Rt=It?It.checks.filter(e=>e.status===`failed`).map(e=>e.message):[],zt=j?.status===`failed`||L===`failed`||L===`timeout`||Z?.status===`failed`||Object.values(V).some(e=>e.status===`failed`),Bt=Rt.filter(e=>!Lt.includes(e)).length;async function Vt(){let e=await Ct(!1);if(e?.status===`healthy`&&e.sourceHash!==G){q.current=e.sourceHash??null,W(0),tt(e=>e+1);return}e?.status===`healthy`&&L===`healthy`&&Z?.status===`passed`&&$&&$.sourceHash===e.sourceHash&&Ze(!0)}return t?(0,k.jsx)(`div`,{className:`flex min-h-0 flex-1 bg-surface-panel p-3 sm:p-5 xl:p-6`,children:(0,k.jsxs)(`div`,{className:`grid w-full min-w-0 overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-surface lg:grid-cols-[minmax(280px,0.8fr)_minmax(0,1.5fr)]`,children:[(0,k.jsxs)(`form`,{onSubmit:wt,className:`flex flex-col border-b border-edge-subtle p-5 lg:border-b-0 lg:border-r`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-accent`,children:[(0,k.jsx)(De,{className:`size-4`}),n?`告诉 Coder 你的想法`:`Tell Coder your idea`]}),(0,k.jsx)(`h2`,{className:`mt-4 text-xl font-semibold tracking-tight text-fg`,children:n?`你想创建什么?`:`What do you want to create?`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`我们会建立一个 Coder Project,并把应用上下文和开发 Skill 带入对话。`:`We will create a Coder Project and carry the app context and development skill into chat.`}),(0,k.jsxs)(`label`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:[n?`应用名称`:`App name`,(0,k.jsx)(je,{value:Ge,onChange:e=>Ke(e.target.value),suggestion:Ne(n?`例如:阅读清单`:`e.g. Reading list`),onAcceptSuggestion:Ke,required:!0,className:`mt-2 w-full rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:阅读清单`:`e.g. Reading list`})]}),(0,k.jsxs)(`label`,{className:`mt-4 text-xs font-medium text-fg-muted`,children:[n?`描述你的想法`:`Describe your idea`,(0,k.jsx)(Ae,{value:qe,onChange:e=>Je(e.target.value),suggestion:Ne(n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`),onAcceptSuggestion:Je,required:!0,rows:7,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`})]}),Ye?(0,k.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:Ye}):null,(0,k.jsxs)(h,{type:`submit`,variant:`primary`,className:`mt-5 h-10`,disabled:M||!Ge.trim()||!qe.trim(),children:[M?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(T,{className:`size-4`}),n?`进入 Coder 对话`:`Continue with Coder`]})]}),(0,k.jsx)(`div`,{className:`hidden min-h-[620px] place-items-center bg-surface-panel p-8 lg:grid`,children:(0,k.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,k.jsx)(`div`,{className:`mx-auto flex size-16 items-center justify-center rounded-2xl border border-edge bg-surface-base text-accent shadow-surface`,children:(0,k.jsx)(xe,{className:`size-7`})}),(0,k.jsx)(`h3`,{className:`mt-5 text-base font-semibold text-fg`,children:n?`创建后,这里就是实时预览`:`Your live preview appears here`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`你可以先体验草稿,再决定是否把它添加到左侧导航。`:`Try the draft first, then decide whether to add it to the sidebar.`})]})})]})}):Le?(0,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_260px]`,children:[(0,k.jsx)(g,{className:`rounded-xl`}),(0,k.jsx)(g,{className:`rounded-xl`}),(0,k.jsx)(g,{className:`rounded-xl`})]}):A||!O?(0,k.jsx)(`div`,{className:`m-6 rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,children:A instanceof Error?A.message:n?`找不到应用`:`App not found`}):(0,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_300px]`,children:[(0,k.jsxs)(`aside`,{className:`min-h-0 min-w-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.12em] text-accent`,children:[(0,k.jsx)(De,{className:`size-4`}),n?`创作对话`:`Build conversation`]}),(0,k.jsx)(`div`,{className:`mt-4 min-w-0 rounded-xl bg-surface-panel p-3 text-sm leading-6 text-fg [overflow-wrap:anywhere]`,children:O.idea}),(0,k.jsxs)(`div`,{className:`mt-4 rounded-xl bg-accent-soft p-3`,children:[(0,k.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-accent-fg`,children:[(0,k.jsx)(ee,{className:`size-4`}),n?`草稿已准备好`:`Draft is ready`]}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`继续迭代会进入对应 Project,由 Coder 读取应用上下文和专属 skill。`:`Continue in the Project where Coder has the app context and dedicated skill.`})]}),(0,k.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),Q(nt)},children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`local-app-change-request`,children:n?`下一步想改什么?`:`What should change next?`}),(0,k.jsx)(Ae,{id:`local-app-change-request`,value:nt,onChange:e=>rt(e.target.value),suggestion:Ne(n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`),onAcceptSuggestion:rt,rows:4,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`}),(0,k.jsxs)(h,{type:`submit`,className:`mt-2 w-full`,disabled:F||!nt.trim(),children:[F?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(T,{className:`size-4`}),n?`让 Coder 修改`:`Ask Coder to update`]})]}),(0,k.jsxs)(h,{variant:`ghost`,className:`mt-2 w-full`,onClick:()=>void Q(),disabled:F,children:[(0,k.jsx)(_,{className:`size-4`}),n?`打开已有开发对话`:`Open development chat`]})]}),(0,k.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,k.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-edge-subtle px-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,k.jsx)(`span`,{className:`size-2 rounded-full ${j?.status===`failed`||L===`failed`||L===`timeout`||Z?.status===`failed`?`bg-danger`:j?.status===`healthy`&&L===`healthy`&&Z?.status===`passed`&&$?.sourceHash===j.sourceHash&&!_t?`bg-success`:`bg-fg-subtle`}`}),L===`failed`||L===`timeout`?n?`预览运行异常`:`Preview runtime issue`:j?.status===`failed`||Z?.status===`failed`?n?`自动验收未通过`:`Acceptance needs attention`:L===`booting`||!Z?n?`自动验收中`:`Running acceptance`:_t||$?.sourceHash!==j?.sourceHash?n?`正在保存验收快照`:`Saving acceptance snapshot`:n?`草稿已通过验收`:`Draft accepted`]}),(0,k.jsxs)(h,{variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Ct(!0),disabled:I,children:[I?(0,k.jsx)(l,{className:`size-3.5 animate-spin`}):(0,k.jsx)(re,{className:`size-3.5`}),n?`重新验收`:`Run again`]})]}),(0,k.jsx)(`iframe`,{ref:bt,title:`${O.name} preview`,src:u(O.draftPreviewUrl),sandbox:ze,className:`min-h-0 w-full flex-1 bg-white`,onError:()=>{ot({kind:`script_error`,message:`Preview document failed to load`}),R(`failed`)}},et),j?.status===`healthy`&&j.acceptanceScenarioCount>0?(0,k.jsx)(`iframe`,{ref:xt,title:`${O.name} acceptance runner`,src:`${u(O.draftPreviewUrl)}?xopcAcceptance=1&xopcScenario=${encodeURIComponent(H===`all`?Y[U]?.id??``:H)}`,sandbox:ze,"aria-hidden":`true`,tabIndex:-1,className:`pointer-events-none fixed left-[-200vw] top-0 h-[720px] w-[1024px] opacity-0`},`criteria-${et}-${ut}-${U}`):null]}),(0,k.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n?`发布状态`:`Release status`}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O.installationState===`not_installed`?n?`尚未安装`:`Not installed`:O.enabled?n?`版本 ${O.activeVersion} 正在使用`:`Version ${O.activeVersion} is active`:n?`已禁用,版本仍保留`:`Disabled, release retained`})]}),(0,k.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full ${O.enabled?`bg-success`:`bg-fg-subtle`}`,"aria-hidden":!0})]}),(0,k.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 text-xs`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`当前草稿`:`Draft`}),(0,k.jsxs)(`dd`,{className:`mt-1 font-medium text-fg`,children:[`v`,O.draftVersion]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`已安装`:`Installed`}),(0,k.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:O.activeVersion?`v${O.activeVersion}`:`—`})]})]}),(0,k.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,k.jsx)(be,{className:`size-4 text-accent`}),n?`草稿检查`:`Draft checks`]}),Ue||I?(0,k.jsx)(l,{className:`size-3.5 animate-spin text-fg-muted`}):j?.status===`healthy`?(0,k.jsx)(ee,{className:`size-4 text-success`}):(0,k.jsx)(Ee,{className:`size-4 text-danger`})]}),j?(0,k.jsxs)(`div`,{className:`mt-2`,children:[(0,k.jsx)(`p`,{className:`text-xs leading-5 ${j.status===`healthy`?`text-fg-muted`:`text-danger`}`,children:j.status===`healthy`?j.hasDraftChanges?n?`${j.changedFileCount} 个文件有改动,可以安装新版本。`:`${j.changedFileCount} changed files are ready for a new release.`:n?`草稿与当前安装版本一致。`:`Draft matches the installed release.`:j.issues[0]?.message}),j.changedFiles.length?(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:j.changedFiles.slice(0,4).map(e=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,k.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,j.changedFileCount>4?(0,k.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-subtle`,children:n?`还有 ${j.changedFileCount-4} 个文件`:`${j.changedFileCount-4} more files`}):null,(0,k.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,k.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,k.jsx)(`span`,{className:`size-2 rounded-full ${L===`healthy`?`bg-success`:L===`booting`?`bg-fg-subtle`:`bg-danger`}`}),n?`预览运行`:`Preview runtime`]}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 ${L===`failed`||L===`timeout`?`text-danger`:`text-fg-muted`}`,children:z?ge(z):L===`healthy`?n?`已成功启动,未发现未捕获异常。`:`Started successfully with no uncaught errors.`:L===`timeout`?n?`7 秒内未完成启动,可能出现白屏或阻塞。`:`Did not finish booting within 7 seconds.`:n?`正在等待应用启动。`:`Waiting for the app to start.`})]}),(0,k.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,k.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,k.jsx)(`span`,{className:`size-2 rounded-full ${Z?.status===`passed`?`bg-success`:Z?.status===`failed`?`bg-danger`:`bg-fg-subtle`}`}),n?`自动验收`:`Automatic acceptance`]}),Z?(0,k.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:Z.checks.map(e=>(0,k.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4 ${e.status===`failed`?`text-danger`:`text-fg-muted`}`,children:[(0,k.jsx)(`span`,{className:`mt-1 size-1.5 shrink-0 rounded-full ${e.status===`failed`?`bg-danger`:e.status===`passed`?`bg-success`:`bg-fg-subtle`}`}),(0,k.jsx)(`span`,{children:e.message})]},e.id))}):(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:j?.acceptanceScenarioCount?n?`正在检查页面基础质量和 ${j.acceptanceScenarioCount} 个产品场景。`:`Checking page quality and ${j.acceptanceScenarioCount} product scenario(s).`:n?`正在检查页面内容和基础交互。`:`Checking rendered content and basic interaction.`}),_t?(0,k.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,k.jsx)(l,{className:`size-3 animate-spin`}),n?`正在保存当前源码对应的验收快照…`:`Saving the acceptance snapshot for this source…`]}):$?(0,k.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-fg-muted`,children:It?n?`相比上次:已修复 ${Bt} 项,仍有 ${Lt.length} 项。`:`Since the previous run: ${Bt} fixed, ${Lt.length} remaining.`:n?`首个验收快照已保存。`:`First acceptance snapshot saved.`}):null,(0,k.jsx)(Re,{scenarios:Y,results:V,runningTarget:ft,zh:n,onRunAll:Mt,onRunScenario:Nt,onAskCoder:Pt})]}),zt?(0,k.jsxs)(h,{className:`mt-3 w-full`,onClick:jt,disabled:F,children:[(0,k.jsx)(T,{className:`size-4`}),n?`让 Coder 修复`:`Ask Coder to fix`]}):null]}):(0,k.jsx)(g,{className:`mt-2 h-12 rounded-lg`})]}),(0,k.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,k.jsx)(ne,{className:`size-4 text-accent`}),n?`权限`:`Permissions`]}),(0,k.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(j?.permissions??O.permissions).map(e=>(0,k.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] text-fg-muted`,children:e},e))})]}),(0,k.jsx)(h,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void Vt(),disabled:M||Ue||I||_t||j?.status===`failed`||L!==`healthy`||Z?.status!==`passed`||!$||$.sourceHash!==j?.sourceHash||O.installationState===`installed`&&j?.hasDraftChanges===!1,children:O.installationState===`installed`?n?`安装当前更新`:`Install current update`:n?`添加到左侧导航`:`Add to sidebar`}),O.installationState===`installed`?(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,k.jsxs)(h,{className:`min-w-0 flex-1`,onClick:()=>void Dt(!O.enabled),disabled:M,children:[O.enabled?(0,k.jsx)(ye,{className:`size-4`}):(0,k.jsx)(y,{className:`size-4`}),O.enabled?n?`禁用`:`Disable`:n?`启用`:`Enable`]}),(0,k.jsx)(h,{variant:`ghost`,className:`text-danger hover:text-danger`,onClick:()=>$e(!0),disabled:M,"aria-label":n?`卸载应用`:`Uninstall app`,children:(0,k.jsx)(Se,{className:`size-4`})})]}):null,(0,k.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4`,children:[(0,k.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,k.jsx)(_e,{className:`size-4`}),n?`版本历史`:`Release history`]}),O.releases.length?(0,k.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,children:O.releases.map(e=>(0,k.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2.5`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[`v`,e.version,e.isActive?(0,k.jsx)(`span`,{className:`rounded-full bg-success-soft px-1.5 py-0.5 text-[10px] text-success`,children:n?`当前`:`Active`}):null]}),(0,k.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-fg-subtle`,children:Be(e.createdAt,r)})]}),e.isActive?null:(0,k.jsxs)(h,{variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>void Ot(e.id),disabled:M,children:[(0,k.jsx)(fe,{className:`size-3.5`}),n?`恢复`:`Restore`]})]},e.id))}):(0,k.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n?`安装首个版本后,可以从这里恢复。`:`Install the first version to enable recovery.`})]}),Ye?(0,k.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-danger`,role:`alert`,children:Ye}):null]}),(0,k.jsx)(S,{open:Xe,onOpenChange:Ze,children:(0,k.jsxs)(v,{children:[(0,k.jsx)(Oe,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,k.jsxs)(se,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(560px,calc(100vh-32px))] w-[min(520px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-2xl focus:outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(ve,{className:`text-base font-semibold text-fg`,children:n?`确认安装到 XOPC`:`Confirm installation`}),(0,k.jsx)(me,{className:`mt-1 text-sm text-fg-muted`,children:n?`当前草稿会成为左侧导航中的可用版本。`:`The current draft will become the version available in the sidebar.`})]}),(0,k.jsx)(C,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,k.jsx)(Te,{className:`size-4`})})]}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,k.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:O.name}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O.extensionId})]}),(0,k.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`本次迭代`:`This iteration`}),(0,k.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-3 text-xs`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`文件变化`:`Changed files`}),(0,k.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:j?.changedFileCount??0})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`自动验收`:`Acceptance`}),(0,k.jsxs)(`dd`,{className:`mt-1 flex items-center gap-1.5 font-medium text-success`,children:[(0,k.jsx)(ee,{className:`size-3.5`}),n?`已通过并保存`:`Passed and saved`]})]})]}),j?.changedFiles.length?(0,k.jsx)(`ul`,{className:`mt-3 space-y-1`,children:j.changedFiles.slice(0,5).map(e=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,k.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,(0,k.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`请求权限`:`Requested permissions`}),(0,k.jsx)(`ul`,{className:`mt-2 space-y-2`,children:(j?.permissions??O.permissions).map(e=>(0,k.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,k.jsx)(s,{className:`size-4 text-success`}),e,O.installationState===`installed`&&j?.permissionDelta.added.includes(e)?(0,k.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-[10px] text-warning`,children:n?`新增`:`New`}):null]},e))}),O.installationState===`installed`&&j?.permissionDelta.added.length?(0,k.jsx)(`p`,{className:`mt-4 rounded-xl bg-warning-soft p-3 text-xs leading-5 text-warning`,children:n?`此更新增加了权限,请确认这些能力符合你的修改意图。`:`This update adds permissions. Confirm they match the change you requested.`}):null,(0,k.jsx)(`p`,{className:`mt-5 rounded-xl bg-accent-soft p-3 text-xs leading-5 text-accent-fg`,children:n?`Phase 1 应用只能使用界面主题和本地存储,不能访问网络或运行系统命令。`:`Phase 1 apps can use theme and local storage only. They cannot access the network or run system commands.`})]}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,k.jsx)(C,{asChild:!0,children:(0,k.jsx)(h,{children:n?`取消`:`Cancel`})}),(0,k.jsxs)(h,{variant:`primary`,onClick:()=>void Tt(),disabled:M,children:[M?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(c,{className:`size-4`}),n?`确认安装`:`Install`]})]})]})]})}),(0,k.jsx)(S,{open:Qe,onOpenChange:$e,children:(0,k.jsxs)(v,{children:[(0,k.jsx)(Oe,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,k.jsxs)(se,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(420px,calc(100vh-32px))] w-[min(500px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-2xl focus:outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(ve,{className:`text-base font-semibold text-fg`,children:n?`卸载当前应用?`:`Uninstall this app?`}),(0,k.jsx)(me,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:n?`应用会从侧栏移除,但 Project、源码、版本历史和本地数据都会保留。`:`The app leaves the sidebar, while its Project, source, release history, and local data remain.`})]}),(0,k.jsx)(C,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,k.jsx)(Te,{className:`size-4`})})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,k.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-4`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:O.name}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`之后可从任意保留版本重新安装。`:`You can reinstall any retained release later.`})]})}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,k.jsx)(C,{asChild:!0,children:(0,k.jsx)(h,{children:n?`取消`:`Cancel`})}),(0,k.jsxs)(h,{variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger`,onClick:()=>void kt(),disabled:M,children:[M?(0,k.jsx)(l,{className:`size-4 animate-spin`}):(0,k.jsx)(Se,{className:`size-4`}),n?`卸载但保留 Project`:`Uninstall and keep Project`]})]})]})]})})]})}export{A as LocalAppWorkbenchPage};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{n as o,r as s}from"./popover-select-DGKUpVsz.js";import{t as c}from"./download-Dk-ZjtO6.js";import{t as l}from"./messages-RzwPiQNL.js";import{t as u}from"./cn-0WouolD0.js";import{i as d,l as f,n as p,o as m}from"./locale-store-JogcXC4J.js";import{u as h}from"./session-api-DTxZyMta.js";import{t as g}from"./copy-to-clipboard-HOJ79TWv.js";import{t as _}from"./button-aIC072nz.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{a as y}from"./gateway-realtime-DMAzNlm-.js";import{a as b,i as x,o as S,s as C}from"./dist-C3DSFZCi.js";import{i as w,o as T,s as E}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as D,t as O}from"./sliding-indicator-hwz0sx3h.js";import{Ao as k,Bc as A,Fc as j,Fl as M,Gt as N,Ic as P,Lc as F,Oo as I,Sd as L,Vc as R,Xu as z,Zu as B,cl as V,id as H,kl as ee,qc as te,ta as U,wu as W,zc as G}from"./index-ygkHNYyo.js";import{n as K}from"./settings-page-header-CYpuTXUW.js";import"./settings-page-layout-B20AfmFG.js";var q=e(t(),1),J=n();function Y(e){let t=new URLSearchParams;if(!e)return``;e.level?.length&&t.set(`level`,e.level.join(`,`)),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.q&&t.set(`q`,e.q),e.module&&t.set(`module`,e.module),e.requestId&&t.set(`requestId`,e.requestId),e.conversationId&&t.set(`conversationId`,e.conversationId),e.transcriptId&&t.set(`transcriptId`,e.transcriptId),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return n?`?${n}`:``}async function X(e){return m(d(`/api/logs${Y(e)}`))}async function Z(){return(await m(d(`/api/logs/files`))).files??[]}async function Q(){return(await m(d(`/api/logs/modules`))).modules??[]}async function ne(){let e=await m(d(`/api/logs/stats`));return{byLevel:e.byLevel??{},runtime:e.runtime}}async function re(){return(await m(d(`/api/logs/dir`))).dir??``}async function ie(){return(await m(d(`/api/logs/level`))).level??`info`}async function ae(e,t){return m(d(`/api/logs/level`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({level:e,...t==null?{}:{duration:String(t)}})})}async function oe(e){let t=new URLSearchParams;e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit!=null&&t.set(`limit`,String(e.limit));let n=t.toString();return(await m(d(`/api/logs/errors/summary${n?`?${n}`:``}`))).items??[]}var se=500,ce=class{_callbacks;_cleanup;constructor(e){this._callbacks=e}connect(e,t){this.disconnect();let n=new Set(e?.length?e:[`trace`,`debug`,`info`,`warn`,`error`,`fatal`]);this._cleanup=y(`logs`,{onEvent:e=>{if(e.event!==`log.entry`||!e.data||typeof e.data!=`object`)return;let r=e.data;!n.has(r.level)||t&&r.module!==t||this._callbacks.onEntry(r)},onGap:()=>this._callbacks.onError(`Live log replay gap; refresh the log query`)}),this._callbacks.onConnected()}disconnect(){this._cleanup?.(),this._cleanup=void 0}};function le(e,t){let n=`${t.timestamp}-${t.requestId??``}-${t.message}`;return[t,...e.filter(e=>`${e.timestamp}-${e.requestId??``}-${e.message}`!==n)].slice(0,se)}var ue=[`trace`,`debug`,`info`,`warn`,`error`,`fatal`];function de(e){let t=new Date(String(e.timestamp)).getTime();return Number.isFinite(t)?t:0}function fe(e){return e.toSorted((e,t)=>de(t)-de(e))}var pe=new Set(ue),me=[`error`,`fatal`],he=[`warn`,`error`,`fatal`],ge=[`info`,`warn`,`error`,`fatal`];function _e(e){if(!e)return new Set;let t=new Set;for(let n of e.split(`,`)){let e=n.trim();pe.has(e)&&t.add(e)}return t}function ve(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ye(e,t){return e.size===t.length?t.every(t=>e.has(t)):!1}function be(e){return e.size===0?`all`:ye(e,me)?`errors`:ye(e,he)?`warnPlus`:ye(e,ge)?`infoPlus`:e.size===ue.length&&ue.every(t=>e.has(t))?`verbose`:`custom`}function xe(e){let t=be(e);return t===`custom`?`other`:t}function Se(e){switch(e){case`all`:return new Set;case`errors`:return new Set(me);case`warnPlus`:return new Set(he);case`infoPlus`:return new Set(ge);case`verbose`:return new Set(ue)}}function Ce(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function we(e){return String(e.module||e.service||e.extension||`—`)}function Te(e){if(typeof e.message==`string`&&e.message)return e.message;try{return JSON.stringify(e)}catch{return``}}function Ee(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{return e}}function De(e){try{return new Date(e).toLocaleString()}catch{return e}}function Oe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ke(e){let t=e.trim();return t.length<=10?t:`${t.slice(0,8)}…`}function Ae(e){return String(e).toLowerCase()}function je(e){let t=e.phase??e.meta?.phase;return typeof t==`string`&&t.trim()?t:`—`}function Me(e){return`${e.timestamp}-${e.requestId??``}-${e.message}`}function Ne(e){let t=e.err??e.meta?.err;if(!t||typeof t!=`object`)return null;let n=t;return{name:typeof n.name==`string`?n.name:void 0,message:typeof n.message==`string`?n.message:void 0,stack:typeof n.stack==`string`?n.stack:void 0}}function Pe(e,t){if(t.selectedLevels.size>0&&!t.selectedLevels.has(e.level)||t.moduleFilter&&we(e)!==t.moduleFilter||t.requestIdFilter&&e.requestId!==t.requestIdFilter||t.transcriptIdFilter&&e.transcriptId!==t.transcriptIdFilter&&e.conversationId!==t.transcriptIdFilter)return!1;if(t.dateFrom){let n=new Date(t.dateFrom).getTime(),r=new Date(String(e.timestamp)).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&r<n)return!1}if(t.dateTo){let n=new Date(t.dateTo).getTime(),r=new Date(String(e.timestamp)).getTime();if(Number.isFinite(n)&&Number.isFinite(r)&&r>n)return!1}if(t.debouncedSearch){let n=t.debouncedSearch.toLowerCase();if(![e.message,we(e),je(e),e.requestId,e.conversationId,e.transcriptId,Ne(e)?.message,Ne(e)?.stack].filter(Boolean).map(String).join(` `).toLowerCase().includes(n))return!1}return!0}function Fe(e,t){let n=[];for(let r of ue){let i=e[r]??0;i>0&&n.push(`${t[r]} ${i}`)}return n.join(` · `)}function Ie(e,t){switch(t.type){case`setSearchInput`:return e.searchInput===t.value?e:{...e,searchInput:t.value};case`setDebouncedSearch`:return e.debouncedSearch===t.value?e:{...e,debouncedSearch:t.value};case`setLevels`:return ve(e.selectedLevels,t.value)?e:{...e,selectedLevels:t.value};case`toggleLevel`:{let n=new Set(e.selectedLevels);return n.has(t.level)?n.delete(t.level):n.add(t.level),{...e,selectedLevels:n}}case`setModule`:return e.moduleFilter===t.value?e:{...e,moduleFilter:t.value};case`setRequestIdFilter`:return e.requestIdFilter===t.value?e:{...e,requestIdFilter:t.value};case`setTranscriptIdFilter`:return e.transcriptIdFilter===t.value?e:{...e,transcriptIdFilter:t.value};case`setDateFrom`:return e.dateFrom===t.value?e:{...e,dateFrom:t.value};case`setDateTo`:return e.dateTo===t.value?e:{...e,dateTo:t.value};case`setAutoRefresh`:return e.autoRefresh===t.value?e:{...e,autoRefresh:t.value};case`syncFromUrl`:{let n=t.payload;return e.searchInput===n.searchInput&&e.debouncedSearch===n.debouncedSearch&&ve(e.selectedLevels,n.selectedLevels)&&e.moduleFilter===n.moduleFilter&&e.requestIdFilter===n.requestIdFilter&&e.transcriptIdFilter===n.transcriptIdFilter&&e.dateFrom===n.dateFrom&&e.dateTo===n.dateTo&&e.autoRefresh===n.autoRefresh?e:{...e,...n}}case`clearAll`:return{searchInput:``,debouncedSearch:``,selectedLevels:new Set,moduleFilter:``,requestIdFilter:``,transcriptIdFilter:``,dateFrom:``,dateTo:``,autoRefresh:e.autoRefresh}}}var Le={logs:[],loading:!1,error:null,hasMore:!1,modules:[],files:[],stats:null,logDir:null};function Re(e,t){switch(t.type){case`queryStart`:return{...e,loading:!0,error:null,logs:[]};case`querySuccess`:return{...e,loading:!1,logs:fe(t.logs),hasMore:t.hasMore};case`queryError`:return t.resetLogs?{...e,loading:!1,error:t.message,logs:[],hasMore:!1}:{...e,loading:!1,error:t.message};case`appendSuccess`:return{...e,loading:!1,logs:fe([...e.logs,...t.logs]),hasMore:t.hasMore};case`metaSuccess`:return{...e,modules:t.modules,stats:t.stats,files:t.files};case`filesSuccess`:return{...e,files:t.files,logDir:t.logDir};case`filesClear`:return{...e,files:[]};case`liveTick`:return{...e,logs:fe(t.logs),hasMore:t.hasMore,stats:t.stats};case`appendLiveEntry`:return{...e,logs:fe(le(e.logs,t.entry))};case`updateStats`:return{...e,stats:t.stats};case`refreshAllSuccess`:return{...e,loading:!1,logs:fe(t.logs),hasMore:t.hasMore,stats:t.stats,files:t.files}}}function ze(e){let t=l(e).logs,n=f(e=>e.conversationId),r=!!n,[a,o]=i(),s=(0,q.useRef)(a),[c,u]=(0,q.useReducer)(Ie,void 0,()=>{let e=s.current,t=e.get(`q`)??``;return{searchInput:t,debouncedSearch:t.trim(),selectedLevels:_e(e.get(`level`)),moduleFilter:e.get(`module`)??``,requestIdFilter:e.get(`requestId`)??``,transcriptIdFilter:e.get(`transcriptId`)??``,dateFrom:e.get(`from`)??``,dateTo:e.get(`to`)??``,autoRefresh:e.get(`live`)===`1`}}),[d,p]=(0,q.useReducer)(Re,Le),[m,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)([]),[T,E]=(0,q.useState)(!1),{searchInput:D,debouncedSearch:O,selectedLevels:k,moduleFilter:A,requestIdFilter:j,transcriptIdFilter:M,dateFrom:N,dateTo:P,autoRefresh:F}=c,{logs:I,loading:L,error:R,hasMore:z,modules:B,files:V,stats:H,logDir:ee}=d,te=(0,q.useCallback)(e=>u({type:`setSearchInput`,value:e}),[]),U=(0,q.useCallback)(e=>u({type:`setLevels`,value:e}),[]),W=(0,q.useCallback)(e=>u({type:`setModule`,value:e}),[]),G=(0,q.useCallback)(e=>u({type:`setRequestIdFilter`,value:e}),[]),K=(0,q.useCallback)(e=>u({type:`setTranscriptIdFilter`,value:e}),[]),J=(0,q.useCallback)(e=>u({type:`setDateFrom`,value:e}),[]),Y=(0,q.useCallback)(e=>u({type:`setDateTo`,value:e}),[]),ie=(0,q.useCallback)(e=>u({type:`setAutoRefresh`,value:e}),[]),ae=(0,q.useMemo)(()=>xe(k),[k]),se=e=>{if(e===`other`){b(!0);return}u({type:`setLevels`,value:Se(e)})},le=O.length>0||k.size>0||!!A||!!j||!!M||!!N||!!P,ue=+(O.length>0)+ +(k.size>0)+ +!!A+ +!!j+ +!!M+(N||P?1:0);(0,q.useEffect)(()=>{let e=setTimeout(()=>u({type:`setDebouncedSearch`,value:D.trim()}),300);return()=>clearTimeout(e)},[D]),(0,q.useEffect)(()=>{let e=a.get(`q`)??``;u({type:`syncFromUrl`,payload:{searchInput:e,debouncedSearch:e.trim(),selectedLevels:_e(a.get(`level`)),moduleFilter:a.get(`module`)??``,requestIdFilter:a.get(`requestId`)??``,transcriptIdFilter:a.get(`transcriptId`)??``,dateFrom:a.get(`from`)??``,dateTo:a.get(`to`)??``,autoRefresh:a.get(`live`)===`1`}})},[a]),(0,q.useEffect)(()=>{let e=new URLSearchParams(a),t=O.trim();t?e.set(`q`,t):e.delete(`q`),k.size>0?e.set(`level`,Array.from(k).sort().join(`,`)):e.delete(`level`),A?e.set(`module`,A):e.delete(`module`),j?e.set(`requestId`,j):e.delete(`requestId`),M?e.set(`transcriptId`,M):e.delete(`transcriptId`),N?e.set(`from`,N):e.delete(`from`),P?e.set(`to`,P):e.delete(`to`),F?e.set(`live`,`1`):e.delete(`live`),e.toString()!==a.toString()&&o(e,{replace:!0})},[F,N,P,O,A,j,M,a,k,o]);let de=(0,q.useMemo)(()=>({q:O||void 0,level:k.size>0?Array.from(k):void 0,module:A||void 0,requestId:j||void 0,transcriptId:M||void 0,from:N||void 0,to:P||void 0,limit:50}),[O,k,A,j,M,N,P]),fe=(0,q.useMemo)(()=>({debouncedSearch:O,selectedLevels:k,moduleFilter:A,requestIdFilter:j,transcriptIdFilter:M,dateFrom:N,dateTo:P}),[O,k,A,j,M,N,P]),pe=(0,q.useRef)(fe);return pe.current=fe,(0,q.useEffect)(()=>{if(!r)return;let e=!1;return E(!0),oe({from:N||void 0,to:P||void 0,limit:12}).then(t=>{e||w(t)}).catch(()=>{e||w([])}).finally(()=>{e||E(!1)}),()=>{e=!0}},[r,N,P]),(0,q.useEffect)(()=>{if(!r)return;let e=!1;return p({type:`queryStart`}),(async()=>{try{let t=await X({...de,offset:0});if(e)return;p({type:`querySuccess`,logs:t.logs,hasMore:t.logs.length===50})}catch(n){e||p({type:`queryError`,message:n instanceof Error?n.message:t.loadError,resetLogs:!0})}})(),()=>{e=!0}},[r,de,t.loadError]),(0,q.useEffect)(()=>{if(!r)return;let e=!1;return(async()=>{try{let[t,n,r]=await Promise.all([Q(),ne(),Z()]);e||p({type:`metaSuccess`,modules:t,stats:n,files:r})}catch{}})(),()=>{e=!0}},[r]),(0,q.useEffect)(()=>{if(!r||!_)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([Z(),re()]);e||p({type:`filesSuccess`,files:t,logDir:n})}catch{e||p({type:`filesClear`})}})(),()=>{e=!0}},[r,_]),(0,q.useEffect)(()=>{if(!F||!r)return;let e=new ce({onConnected:()=>{},onEntry:e=>{Pe(e,pe.current)&&p({type:`appendLiveEntry`,entry:e})},onError:()=>{}});e.connect(k.size>0?Array.from(k):void 0,A||void 0);let t=window.setInterval(()=>{ne().then(e=>{p({type:`updateStats`,stats:e})}).catch(()=>{})},3e4);return()=>{e.disconnect(),clearInterval(t)}},[F,r,n,k,A]),(0,q.useEffect)(()=>{if(!x)return;let e=window.setTimeout(()=>S(null),2e3);return()=>clearTimeout(e)},[x]),{L:t,hasToken:r,logs:I,loading:L,error:R,hasMore:z,searchInput:D,setSearchInput:te,selectedLevels:k,setSelectedLevels:U,moduleFilter:A,setModuleFilter:W,requestIdFilter:j,transcriptIdFilter:M,dateFrom:N,setDateFrom:J,dateTo:P,setDateTo:Y,modules:B,files:V,stats:H,selectedLog:m,setSelectedLog:g,filesOpen:_,setFilesOpen:v,filtersOpen:y,setFiltersOpen:b,logDir:ee,autoRefresh:F,setAutoRefresh:ie,copiedDetail:x,setCopiedDetail:S,hasActiveFilters:le,activeFilterCount:ue,clearFilters:()=>u({type:`clearAll`}),toggleDialogLevel:e=>u({type:`toggleLevel`,level:e}),handleLoadMore:()=>{L||!z||(async()=>{p({type:`queryStart`});try{let e=await X({...de,offset:I.length});p({type:`appendSuccess`,logs:e.logs,hasMore:e.logs.length===50})}catch(e){p({type:`queryError`,message:e instanceof Error?e.message:t.loadError})}})()},refreshAll:()=>{(async()=>{p({type:`queryStart`});try{let e=await X({...de,offset:0}),[t,n]=await Promise.all([ne(),Z()]);p({type:`refreshAllSuccess`,logs:e.logs,hasMore:e.logs.length===50,stats:t,files:n})}catch(e){p({type:`queryError`,message:e instanceof Error?e.message:t.loadError})}})()},levelSegment:ae,handleLevelSegment:se,filterByRequestId:(0,q.useCallback)(e=>{g(null),G(e)},[G]),filterByTranscriptId:(0,q.useCallback)(e=>{g(null),K(e)},[K]),filterByErrorSummary:(0,q.useCallback)(e=>{u({type:`setSearchInput`,value:e.errName}),u({type:`setDebouncedSearch`,value:e.errName}),e.module&&u({type:`setModule`,value:e.module}),u({type:`setLevels`,value:Se(`errors`)})},[]),openChatForSession:(0,q.useCallback)(e=>{let t=e.conversationId?.trim();if(t){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:t}}));return}let n=e.transcriptId?.trim();n&&h({transcriptId:n}).then(e=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e.conversationId}}))}).catch(()=>{})},[]),errorSummary:C,errorSummaryLoading:T}}var $=r();function Be(e){let t=(0,J.c)(36),{L:n,items:r,loading:i,onSelectItem:o}=e,[s,c]=(0,q.useState)(!1);if(!i&&r.length===0)return null;let l;t[0]===r?l=t[1]:(l=r.reduce(He,0),t[0]=r,t[1]=l);let d=l,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>c(Ve),t[2]=f):f=t[2];let p;t[3]===n.errorSummaryTitle?p=t[4]:(p=(0,$.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-fg`,children:n.errorSummaryTitle}),t[3]=n.errorSummaryTitle,t[4]=p);let m;t[5]===n.errorSummaryHint?m=t[6]:(m=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:n.errorSummaryHint}),t[5]=n.errorSummaryHint,t[6]=m);let h;t[7]!==p||t[8]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==r.length||t[11]!==i||t[12]!==d?(g=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(v,{className:`h-5 w-8 rounded-md`}),(0,$.jsx)(v,{className:`h-5 w-10 rounded-md`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs tabular-nums text-red-600 dark:text-red-400`,children:r.length}),(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-2 py-0.5 text-xs tabular-nums text-fg-muted`,children:[`×`,d]})]}),t[10]=r.length,t[11]=i,t[12]=d,t[13]=g):g=t[13];let _=s&&`rotate-180`,y;t[14]===_?y=t[15]:(y=u(`size-4 text-fg-muted transition-transform duration-150 ease-out motion-reduce:transition-none`,_),t[14]=_,t[15]=y);let b;t[16]===y?b=t[17]:(b=(0,$.jsx)(a,{className:y,strokeWidth:1.75,"aria-hidden":!0}),t[16]=y,t[17]=b);let x;t[18]!==g||t[19]!==b?(x=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[g,b]}),t[18]=g,t[19]=b,t[20]=x):x=t[20];let S;t[21]!==s||t[22]!==x||t[23]!==h?(S=(0,$.jsxs)(`button`,{type:`button`,onClick:f,"aria-expanded":s,className:`flex w-full items-start justify-between gap-3 px-4 py-4 text-left transition-colors hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset sm:px-5`,children:[h,x]}),t[21]=s,t[22]=x,t[23]=h,t[24]=S):S=t[24];let C;t[25]!==n.module||t[26]!==n.phase||t[27]!==n.time||t[28]!==s||t[29]!==r||t[30]!==i||t[31]!==o?(C=s&&!i&&r.length>0?(0,$.jsx)(`ul`,{className:`mx-1 mb-1 flex flex-col gap-1 rounded-lg bg-surface-base/45 p-1 [&>li]:rounded-lg`,children:r.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o?.(e),className:u(`flex w-full flex-col gap-1 px-4 py-2.5 text-left transition-colors hover:bg-surface-hover`,o&&`cursor-pointer`),children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.errName}),(0,$.jsxs)(`span`,{className:`shrink-0 rounded-md bg-red-500/10 px-2 py-0.5 text-xs tabular-nums text-red-600 dark:text-red-400`,children:[`×`,e.count]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[e.phase?(0,$.jsxs)(`span`,{children:[n.phase,`: `,e.phase]}):null,e.module?(0,$.jsxs)(`span`,{children:[n.module,`: `,e.module]}):null,(0,$.jsxs)(`span`,{children:[n.time,`: `,Ee(e.lastSeen)]})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.sampleMessage})]})},e.key))}):null,t[25]=n.module,t[26]=n.phase,t[27]=n.time,t[28]=s,t[29]=r,t[30]=i,t[31]=o,t[32]=C):C=t[32];let w;return t[33]!==S||t[34]!==C?(w=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl bg-surface-hover/20`,children:[S,C]}),t[33]=S,t[34]=C,t[35]=w):w=t[35],w}function Ve(e){return!e}function He(e,t){return e+t.count}function Ue(e){let t=(0,J.c)(75),{log:n,labels:r,onFilterByRequestId:i,onFilterByTranscriptId:a,onOpenChat:o}=e,s=n.level??`info`,c=typeof n.requestId==`string`?n.requestId:``,l=typeof n.conversationId==`string`?n.conversationId:``,d=typeof n.transcriptId==`string`?n.transcriptId:``,f;t[0]===n?f=t[1]:(f=je(n),t[0]=n,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=Ne(n),t[2]=n,t[3]=m);let h=m,g=s===`error`||s===`fatal`,v;t[4]===r.message?v=t[5]:(v=(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.message}),t[4]=r.message,t[5]=v);let y=g&&`border-red-500/40`,b;t[6]===y?b=t[7]:(b=u(`mt-2 whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,y),t[6]=y,t[7]=b);let x=n.message||`—`,S;t[8]!==b||t[9]!==x?(S=(0,$.jsx)(`pre`,{className:b,children:x}),t[8]=b,t[9]=x,t[10]=S):S=t[10];let C;t[11]!==v||t[12]!==S?(C=(0,$.jsxs)(`div`,{children:[v,S]}),t[11]=v,t[12]=S,t[13]=C):C=t[13];let w;t[14]!==h||t[15]!==r.stackTrace?(w=h?.stack?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.stackTrace}),h.name?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:h.name}):null,(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words border border-red-500/30 bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-red-500/30`,children:h.stack})]}):null,t[14]=h,t[15]=r.stackTrace,t[16]=w):w=t[16];let T;t[17]===r.time?T=t[18]:(T=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.time}),t[17]=r.time,t[18]=T);let E;t[19]===n.timestamp?E=t[20]:(E=(0,$.jsx)(`code`,{className:`break-all text-fg`,children:n.timestamp}),t[19]=n.timestamp,t[20]=E);let D;t[21]===r.level?D=t[22]:(D=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.level}),t[21]=r.level,t[22]=D);let O=g&&`font-medium text-red-600 dark:text-red-400`,k;t[23]===O?k=t[24]:(k=u(`text-fg`,O),t[23]=O,t[24]=k);let A;t[25]===s?A=t[26]:(A=Ae(s),t[25]=s,t[26]=A);let j;t[27]!==k||t[28]!==A?(j=(0,$.jsx)(`span`,{className:k,children:A}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;t[30]===r.module?M=t[31]:(M=(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.module}),t[30]=r.module,t[31]=M);let N;t[32]===n?N=t[33]:(N=we(n),t[32]=n,t[33]=N);let P;t[34]===N?P=t[35]:(P=(0,$.jsx)(`code`,{className:`break-all text-fg`,children:N}),t[34]=N,t[35]=P);let F;t[36]!==r.phase||t[37]!==p?(F=p===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.phase}),(0,$.jsx)(`code`,{className:`break-all text-fg`,children:p})]}),t[36]=r.phase,t[37]=p,t[38]=F):F=t[38];let I;t[39]!==r.filterByRequestId||t[40]!==r.requestId||t[41]!==i||t[42]!==c?(I=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.requestId}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:c}),i?(0,$.jsx)(_,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>i(c),children:r.filterByRequestId}):null]})]}):null,t[39]=r.filterByRequestId,t[40]=r.requestId,t[41]=i,t[42]=c,t[43]=I):I=t[43];let L;t[44]!==r.conversationId||t[45]!==r.openChat||t[46]!==o||t[47]!==l?(L=l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.conversationId}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:l}),o?(0,$.jsx)(_,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>o({conversationId:l}),children:r.openChat}):null]})]}):null,t[44]=r.conversationId,t[45]=r.openChat,t[46]=o,t[47]=l,t[48]=L):L=t[48];let R;t[49]!==r.filterByTranscriptId||t[50]!==r.openChat||t[51]!==r.transcriptId||t[52]!==a||t[53]!==o||t[54]!==d?(R=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-sans text-fg-muted`,children:r.transcriptId}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`break-all text-fg`,children:d}),a?(0,$.jsx)(_,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>a(d),children:r.filterByTranscriptId}):null,o?(0,$.jsx)(_,{type:`button`,variant:`secondary`,className:`h-7 px-2 text-[11px]`,onClick:()=>o({transcriptId:d}),children:r.openChat}):null]})]}):null,t[49]=r.filterByTranscriptId,t[50]=r.openChat,t[51]=r.transcriptId,t[52]=a,t[53]=o,t[54]=d,t[55]=R):R=t[55];let z;t[56]!==T||t[57]!==E||t[58]!==D||t[59]!==j||t[60]!==M||t[61]!==P||t[62]!==F||t[63]!==I||t[64]!==L||t[65]!==R?(z=(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-2 text-xs`,children:[T,E,D,j,M,P,F,I,L,R]}),t[56]=T,t[57]=E,t[58]=D,t[59]=j,t[60]=M,t[61]=P,t[62]=F,t[63]=I,t[64]=L,t[65]=R,t[66]=z):z=t[66];let B;t[67]!==r.metadata||t[68]!==n.meta?(B=n.meta&&Object.keys(n.meta).length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs font-sans font-medium text-fg-muted`,children:r.metadata}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words border border-edge bg-surface-base p-3 text-xs leading-relaxed text-fg dark:border-edge`,children:JSON.stringify(n.meta,null,2)})]}):null,t[67]=r.metadata,t[68]=n.meta,t[69]=B):B=t[69];let V;return t[70]!==z||t[71]!==B||t[72]!==C||t[73]!==w?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[C,w,z,B]}),t[70]=z,t[71]=B,t[72]=C,t[73]=w,t[74]=V):V=t[74],V}function We(e){let t=(0,J.c)(50),{L:n,log:r,onClose:i,copiedDetail:a,onCopiedMessage:o,onCopiedJson:s,onFilterByRequestId:c,onFilterByTranscriptId:l,onOpenChat:d}=e,f=r!==null,p;t[0]===i?p=t[1]:(p=e=>!e&&i(),t[0]=i,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(G,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),t[2]=m):m=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,w,`dark:border-edge`),t[3]=h):h=t[3];let v;t[4]===n.details?v=t[5]:(v=(0,$.jsx)(R,{className:`text-base font-semibold tracking-tight text-fg`,children:n.details}),t[4]=n.details,t[5]=v);let y;t[6]!==n.copied||t[7]!==n.copyJson||t[8]!==n.copyMessage||t[9]!==a||t[10]!==r||t[11]!==s||t[12]!==o?(y=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{g(typeof r.message==`string`?r.message:``).then(e=>{e&&o()})},children:[(0,$.jsx)(L,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:a===`message`?n.copied:n.copyMessage})]}),(0,$.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-9 shrink-0 gap-1 px-2 text-xs`,onClick:()=>{g(JSON.stringify(r,null,2)).then(e=>{e&&s()})},children:[(0,$.jsx)(L,{className:`size-3.5 shrink-0`,strokeWidth:1.75}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:a===`json`?n.copied:n.copyJson})]})]}):null,t[6]=n.copied,t[7]=n.copyJson,t[8]=n.copyMessage,t[9]=a,t[10]=r,t[11]=s,t[12]=o,t[13]=y):y=t[13];let b;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[14]=b):b=t[14];let x;t[15]===n.close?x=t[16]:(x=(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:b})}),t[15]=n.close,t[16]=x);let S;t[17]!==y||t[18]!==x?(S=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[y,x]}),t[17]=y,t[18]=x,t[19]=S):S=t[19];let C;t[20]!==v||t[21]!==S?(C=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[v,S]}),t[20]=v,t[21]=S,t[22]=C):C=t[22];let E;t[23]!==n.conversationId||t[24]!==n.filterByRequestId||t[25]!==n.filterByTranscriptId||t[26]!==n.level||t[27]!==n.message||t[28]!==n.metadata||t[29]!==n.module||t[30]!==n.openChat||t[31]!==n.phase||t[32]!==n.requestId||t[33]!==n.stackTrace||t[34]!==n.time||t[35]!==n.transcriptId||t[36]!==r||t[37]!==c||t[38]!==l||t[39]!==d?(E=r?(0,$.jsx)(Ue,{log:r,labels:{time:n.time,level:n.level,module:n.module,message:n.message,metadata:n.metadata,requestId:n.requestId,conversationId:n.conversationId,transcriptId:n.transcriptId,phase:n.phase,stackTrace:n.stackTrace,filterByRequestId:n.filterByRequestId,filterByTranscriptId:n.filterByTranscriptId,openChat:n.openChat},onFilterByRequestId:c,onFilterByTranscriptId:l,onOpenChat:d}):null,t[23]=n.conversationId,t[24]=n.filterByRequestId,t[25]=n.filterByTranscriptId,t[26]=n.level,t[27]=n.message,t[28]=n.metadata,t[29]=n.module,t[30]=n.openChat,t[31]=n.phase,t[32]=n.requestId,t[33]=n.stackTrace,t[34]=n.time,t[35]=n.transcriptId,t[36]=r,t[37]=c,t[38]=l,t[39]=d,t[40]=E):E=t[40];let D;t[41]===E?D=t[42]:(D=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 font-mono text-sm leading-relaxed`,children:E}),t[41]=E,t[42]=D);let O;t[43]!==C||t[44]!==D?(O=(0,$.jsxs)(A,{children:[m,(0,$.jsxs)(F,{className:h,"aria-describedby":void 0,children:[C,D]})]}),t[43]=C,t[44]=D,t[45]=O):O=t[45];let k;return t[46]!==f||t[47]!==O||t[48]!==p?(k=(0,$.jsx)(j,{open:f,onOpenChange:p,children:O}),t[46]=f,t[47]=O,t[48]=p,t[49]=k):k=t[49],k}function Ge(e){let t=(0,J.c)(25),{L:n,open:r,onOpenChange:i,files:a,logDir:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(G,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),t[0]=s):s=t[0];let c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=u(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(32rem,85vh)] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,w,`dark:border-edge`),t[1]=c):c=t[1];let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(B,{className:`size-4 text-fg-muted`,strokeWidth:1.75}),t[2]=l):l=t[2];let d;t[3]===n.logFiles?d=t[4]:(d=(0,$.jsxs)(R,{className:`flex items-center gap-2 text-base font-semibold tracking-tight text-fg`,children:[l,n.logFiles]}),t[3]=n.logFiles,t[4]=d);let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[5]=f):f=t[5];let p;t[6]===n.close?p=t[7]:(p=(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:f})}),t[6]=n.close,t[7]=p);let m;t[8]!==d||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[d,p]}),t[8]=d,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==n.filesEmpty||t[12]!==a?(h=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:a.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.filesEmpty}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:a.map(Ke)})}),t[11]=n.filesEmpty,t[12]=a,t[13]=h):h=t[13];let g;t[14]!==n.logDir||t[15]!==o?(g=o?(0,$.jsxs)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-2 text-xs text-fg-subtle dark:border-edge`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[n.logDir,`: `]}),(0,$.jsx)(`code`,{className:`break-all text-fg-subtle`,children:o})]}):null,t[14]=n.logDir,t[15]=o,t[16]=g):g=t[16];let v;t[17]!==m||t[18]!==h||t[19]!==g?(v=(0,$.jsxs)(A,{children:[s,(0,$.jsxs)(F,{className:c,children:[m,h,g]})]}),t[17]=m,t[18]=h,t[19]=g,t[20]=v):v=t[20];let y;return t[21]!==i||t[22]!==r||t[23]!==v?(y=(0,$.jsx)(j,{open:r,onOpenChange:i,children:v}),t[21]=i,t[22]=r,t[23]=v,t[24]=y):y=t[24],y}function Ke(e){return(0,$.jsxs)(`li`,{className:`flex flex-col gap-1 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 dark:border-edge`,children:[(0,$.jsx)(`span`,{className:`break-all font-mono text-xs text-fg`,children:e.name}),(0,$.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:Oe(e.size)}),(0,$.jsx)(`span`,{children:De(e.modified)})]})]},e.name)}function qe(e){let t=(0,J.c)(68),{L:n,open:r,onOpenChange:i,dateFrom:a,onDateFromChange:o,dateTo:s,onDateToChange:c,selectedLevels:l,onToggleLevel:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(G,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,T)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=u(`xopc-dialog-content fixed left-1/2 top-1/2 flex max-h-[min(32rem,90vh)] w-[min(100%-2rem,22rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,w,`dark:border-edge`),t[1]=p):p=t[1];let m;t[2]===n.filtersDialogTitle?m=t[3]:(m=(0,$.jsx)(R,{className:`text-base font-semibold tracking-tight text-fg`,children:n.filtersDialogTitle}),t[2]=n.filtersDialogTitle,t[3]=m);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[4]=h):h=t[4];let g;t[5]===n.close?g=t[6]:(g=(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":n.close,children:h})}),t[5]=n.close,t[6]=g);let v;t[7]!==m||t[8]!==g?(v=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[m,g]}),t[7]=m,t[8]=g,t[9]=v):v=t[9];let y;t[10]===n.filtersDialogDesc?y=t[11]:(y=(0,$.jsx)(`div`,{id:`log-filters-desc`,className:`sr-only`,children:n.filtersDialogDesc}),t[10]=n.filtersDialogDesc,t[11]=y);let b;t[12]===n.timeRange?b=t[13]:(b=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.timeRange}),t[12]=n.timeRange,t[13]=b);let x;t[14]===n.from?x=t[15]:(x=(0,$.jsx)(`label`,{htmlFor:`log-from-d`,className:`mb-1 block text-xs text-fg-muted`,children:n.from}),t[14]=n.from,t[15]=x);let S;t[16]===o?S=t[17]:(S=e=>o(e.target.value),t[16]=o,t[17]=S);let C;t[18]!==a||t[19]!==S?(C=(0,$.jsx)(`input`,{id:`log-from-d`,type:`datetime-local`,value:a,onChange:S,className:`w-full rounded-xl border border-edge bg-surface-base p-2 text-sm text-fg dark:border-edge`}),t[18]=a,t[19]=S,t[20]=C):C=t[20];let E;t[21]!==C||t[22]!==x?(E=(0,$.jsxs)(`div`,{children:[x,C]}),t[21]=C,t[22]=x,t[23]=E):E=t[23];let D;t[24]===n.to?D=t[25]:(D=(0,$.jsx)(`label`,{htmlFor:`log-to-d`,className:`mb-1 block text-xs text-fg-muted`,children:n.to}),t[24]=n.to,t[25]=D);let O;t[26]===c?O=t[27]:(O=e=>c(e.target.value),t[26]=c,t[27]=O);let k;t[28]!==s||t[29]!==O?(k=(0,$.jsx)(`input`,{id:`log-to-d`,type:`datetime-local`,value:s,onChange:O,className:`w-full rounded-xl border border-edge bg-surface-base p-2 text-sm text-fg dark:border-edge`}),t[28]=s,t[29]=O,t[30]=k):k=t[30];let M;t[31]!==D||t[32]!==k?(M=(0,$.jsxs)(`div`,{children:[D,k]}),t[31]=D,t[32]=k,t[33]=M):M=t[33];let N;t[34]!==E||t[35]!==M?(N=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[E,M]}),t[34]=E,t[35]=M,t[36]=N):N=t[36];let I;t[37]===n.levelCustom?I=t[38]:(I=(0,$.jsx)(`p`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:n.levelCustom}),t[37]=n.levelCustom,t[38]=I);let L;t[39]===n.levelCustomHint?L=t[40]:(L=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:n.levelCustomHint}),t[39]=n.levelCustomHint,t[40]=L);let z=n.level,B;t[41]!==n.levelNames||t[42]!==d||t[43]!==l?(B=ue.map(e=>(0,$.jsx)(`button`,{type:`button`,className:u(`rounded-full border px-3 py-1.5 text-xs font-medium capitalize transition-[color,background-color,border-color] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,l.has(e)?`border-edge bg-surface-active text-fg dark:border-edge`:`border-edge-subtle bg-surface-base text-fg-muted hover:bg-surface-hover dark:border-edge`),onClick:()=>d(e),children:n.levelNames[e]},e)),t[41]=n.levelNames,t[42]=d,t[43]=l,t[44]=B):B=t[44];let V;t[45]!==n.level||t[46]!==B?(V=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,role:`group`,"aria-label":z,children:B}),t[45]=n.level,t[46]=B,t[47]=V):V=t[47];let H;t[48]!==N||t[49]!==I||t[50]!==L||t[51]!==V||t[52]!==b?(H=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[b,N,I,L,V]}),t[48]=N,t[49]=I,t[50]=L,t[51]=V,t[52]=b,t[53]=H):H=t[53];let ee;t[54]===i?ee=t[55]:(ee=()=>i(!1),t[54]=i,t[55]=ee);let U;t[56]!==n.filtersDone||t[57]!==ee?(U=(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,$.jsx)(_,{type:`button`,className:`w-full rounded-xl`,onClick:ee,children:n.filtersDone})}),t[56]=n.filtersDone,t[57]=ee,t[58]=U):U=t[58];let W;t[59]!==H||t[60]!==U||t[61]!==v||t[62]!==y?(W=(0,$.jsxs)(A,{children:[f,(0,$.jsxs)(F,{className:p,"aria-describedby":`log-filters-desc`,children:[v,y,H,U]})]}),t[59]=H,t[60]=U,t[61]=v,t[62]=y,t[63]=W):W=t[63];let K;return t[64]!==i||t[65]!==r||t[66]!==W?(K=(0,$.jsx)(j,{open:r,onOpenChange:i,children:W}),t[64]=i,t[65]=r,t[66]=W,t[67]=K):K=t[67],K}var Je=`touch-target relative z-[2] box-border flex h-6 flex-1 cursor-pointer items-center justify-center gap-1 rounded-pill border-0 bg-transparent px-2 py-0 text-center text-xs font-medium leading-none outline-none transition-[color,background-color,box-shadow] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`;function Ye(e){let t=(0,J.c)(18),{value:n,onChange:r,options:i,"aria-label":a,className:o,buttonClassName:s}=e,c=(0,q.useRef)(null),l=D(c,`button`,`button[aria-pressed="true"]`,1),d;t[0]===o?d=t[1]:(d=u(N,`relative isolate flex w-full max-w-full flex-row items-center`,o),t[0]=o,t[1]=d);let f;t[2]===l?f=t[3]:(f=(0,$.jsx)(O,{bounds:l,className:`rounded-pill bg-surface-panel shadow-sm dark:ring-1 dark:ring-edge-strong/40`}),t[2]=l,t[3]=f);let p;if(t[4]!==s||t[5]!==r||t[6]!==i||t[7]!==n){let e;t[9]!==s||t[10]!==r||t[11]!==n?(e=e=>{let t=e.icon,i=n===e.value;return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":i,title:e.title??e.label,onClick:()=>r(e.value),className:u(Je,i?`text-fg`:`text-fg-subtle`,s),children:[t?(0,$.jsx)(t,{className:`block size-3 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate leading-none`,children:e.label})]},e.value)},t[9]=s,t[10]=r,t[11]=n,t[12]=e):e=t[12],p=i.map(e),t[4]=s,t[5]=r,t[6]=i,t[7]=n,t[8]=p}else p=t[8];let m;return t[13]!==a||t[14]!==d||t[15]!==f||t[16]!==p?(m=(0,$.jsxs)(`div`,{ref:c,className:d,role:`group`,"aria-label":a,children:[f,p]}),t[13]=a,t[14]=d,t[15]=f,t[16]=p,t[17]=m):m=t[17],m}function Xe(e){let t=(0,J.c)(76),{L:n,levelSegment:r,onLevelSegment:i,searchInput:a,onSearchInputChange:c,moduleFilter:l,onModuleFilterChange:d,modules:f,onOpenFilters:p,activeFilterCount:m,hasActiveFilters:h,onClearFilters:g,autoRefresh:v}=e,y=n.filters,b;t[0]===n.presetAll?b=t[1]:(b={value:`all`,label:n.presetAll},t[0]=n.presetAll,t[1]=b);let x;t[2]===n.presetErrors?x=t[3]:(x={value:`errors`,label:n.presetErrors},t[2]=n.presetErrors,t[3]=x);let S;t[4]===n.presetWarnPlus?S=t[5]:(S={value:`warnPlus`,label:n.presetWarnPlus},t[4]=n.presetWarnPlus,t[5]=S);let C;t[6]===n.presetInfoPlus?C=t[7]:(C={value:`infoPlus`,label:n.presetInfoPlus},t[6]=n.presetInfoPlus,t[7]=C);let w;t[8]===n.presetVerbose?w=t[9]:(w={value:`verbose`,label:n.presetVerbose},t[8]=n.presetVerbose,t[9]=w);let T;t[10]===n.presetOther?T=t[11]:(T={value:`other`,label:n.presetOther},t[10]=n.presetOther,t[11]=T);let E;t[12]!==b||t[13]!==x||t[14]!==S||t[15]!==C||t[16]!==w||t[17]!==T?(E=[b,x,S,C,w,T],t[12]=b,t[13]=x,t[14]=S,t[15]=C,t[16]=w,t[17]=T,t[18]=E):E=t[18];let D;t[19]!==n.levelPresetAria||t[20]!==r||t[21]!==i||t[22]!==E?(D=(0,$.jsx)(`div`,{className:`overflow-x-auto pb-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:(0,$.jsx)(`div`,{className:`min-w-[min(100%,36rem)]`,children:(0,$.jsx)(Ye,{"aria-label":n.levelPresetAria,value:r,onChange:i,options:E,buttonClassName:`h-8 px-1.5 text-[11px] sm:px-2 sm:text-xs`})})}),t[19]=n.levelPresetAria,t[20]=r,t[21]=i,t[22]=E,t[23]=D):D=t[23];let O;t[24]===n.searchPlaceholder?O=t[25]:(O=(0,$.jsx)(`span`,{className:`sr-only`,children:n.searchPlaceholder}),t[24]=n.searchPlaceholder,t[25]=O);let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(ee,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[26]=A):A=t[26];let j;t[27]===c?j=t[28]:(j=e=>c(e.target.value),t[27]=c,t[28]=j);let M=n.searchPlaceholder,N;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(N=u(`h-10 w-full rounded-md border border-edge bg-surface-panel py-0 pl-10 pr-3 text-sm leading-5 text-fg placeholder:text-fg-subtle dark:border-edge`,I),t[29]=N):N=t[29];let P;t[30]!==n.searchPlaceholder||t[31]!==a||t[32]!==j?(P=(0,$.jsx)(`input`,{type:`search`,value:a,onChange:j,placeholder:M,autoComplete:`off`,spellCheck:!1,className:N}),t[30]=n.searchPlaceholder,t[31]=a,t[32]=j,t[33]=P):P=t[33];let F;t[34]!==O||t[35]!==P?(F=(0,$.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:min-w-[12rem]`,children:[O,A,P]}),t[34]=O,t[35]=P,t[36]=F):F=t[36];let L;t[37]===d?L=t[38]:(L=e=>d(e.target.value),t[37]=d,t[38]=L);let R=n.module,z=n.module,B;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(B=u(k,`h-10 w-full min-w-0 rounded-md py-0`),t[39]=B):B=t[39];let V;t[40]===n.allModules?V=t[41]:(V=(0,$.jsx)(s,{value:``,children:n.allModules}),t[40]=n.allModules,t[41]=V);let H;t[42]===f?H=t[43]:(H=f.map(Ze),t[42]=f,t[43]=H);let U;t[44]!==n.module||t[45]!==l||t[46]!==L||t[47]!==V||t[48]!==H?(U=(0,$.jsxs)(o,{id:`log-module`,value:l,onChange:L,"aria-label":R,title:z,className:B,children:[V,H]}),t[44]=n.module,t[45]=l,t[46]=L,t[47]=V,t[48]=H,t[49]=U):U=t[49];let G;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(W,{className:`size-4`,strokeWidth:1.75}),t[50]=G):G=t[50];let K;t[51]===m?K=t[52]:(K=m>0?(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 text-xs tabular-nums text-fg-muted`,children:m}):null,t[51]=m,t[52]=K);let q;t[53]!==n.filtersMore||t[54]!==p||t[55]!==K?(q=(0,$.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-10 min-h-[44px] gap-2 rounded-md sm:min-h-10`,onClick:p,children:[G,n.filtersMore,K]}),t[53]=n.filtersMore,t[54]=p,t[55]=K,t[56]=q):q=t[56];let Y;t[57]!==n.clear||t[58]!==h||t[59]!==g?(Y=h?(0,$.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-10 min-h-[44px] gap-1 sm:min-h-10`,onClick:g,children:[(0,$.jsx)(te,{className:`size-4`,strokeWidth:1.75}),n.clear]}):null,t[57]=n.clear,t[58]=h,t[59]=g,t[60]=Y):Y=t[60];let X;t[61]!==q||t[62]!==Y?(X=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[q,Y]}),t[61]=q,t[62]=Y,t[63]=X):X=t[63];let Z;t[64]!==F||t[65]!==U||t[66]!==X?(Z=(0,$.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[minmax(16rem,1fr)_minmax(12rem,16rem)_auto] lg:items-center`,children:[F,U,X]}),t[64]=F,t[65]=U,t[66]=X,t[67]=Z):Z=t[67];let Q;t[68]!==n.liveHint||t[69]!==v?(Q=v?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:n.liveHint}):null,t[68]=n.liveHint,t[69]=v,t[70]=Q):Q=t[70];let ne;return t[71]!==n.filters||t[72]!==Z||t[73]!==Q||t[74]!==D?(ne=(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":y,children:[D,Z,Q]}),t[71]=n.filters,t[72]=Z,t[73]=Q,t[74]=D,t[75]=ne):ne=t[75],ne}function Ze(e){return(0,$.jsx)(s,{value:e,children:e},e)}function Qe(e){let t=(0,J.c)(20),{L:n,logs:r,loading:i,hasMore:o,onSelectLog:s,onLoadMore:c,onRefreshAll:l,onFilterByRequestId:d}=e,f;t[0]!==i||t[1]!==r.length?(f=i&&r.length===0?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-hover/20`,"aria-busy":`true`,children:Array.from({length:8}).map($e)}):null,t[0]=i,t[1]=r.length,t[2]=f):f=t[2];let p;t[3]!==n||t[4]!==i||t[5]!==r.length||t[6]!==l?(p=!i&&r.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-xl bg-surface-hover/20 py-16 text-center`,children:[(0,$.jsx)(H,{className:`size-12 text-fg-subtle`,strokeWidth:1.5,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n.noLogs}),(0,$.jsx)(`p`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:n.noLogsDescription}),(0,$.jsxs)(_,{type:`button`,variant:`secondary`,className:`mt-4 gap-2`,onClick:l,children:[(0,$.jsx)(M,{className:`size-4`,strokeWidth:1.75}),n.refresh]})]}):null,t[3]=n,t[4]=i,t[5]=r.length,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==n||t[9]!==o||t[10]!==i||t[11]!==r||t[12]!==d||t[13]!==c||t[14]!==s?(m=r.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:[Ce(n.showingCount,{count:String(r.length)}),o?(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[` · `,n.moreAvailable]}):null]}),(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-hover/20 p-1 text-sm leading-6`,children:[(0,$.jsxs)(`div`,{className:`hidden items-center gap-3 px-3 py-2 text-xs font-medium text-fg-subtle md:flex`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`w-[5.25rem] shrink-0`,children:n.time}),(0,$.jsx)(`span`,{className:`w-[4.5rem] shrink-0`,children:n.level}),(0,$.jsx)(`span`,{className:`w-[4.5rem] shrink-0 sm:w-[5.25rem]`,children:n.requestId}),(0,$.jsx)(`span`,{className:`hidden max-w-[6rem] shrink-0 xl:block`,children:n.phase}),(0,$.jsx)(`span`,{className:`hidden max-w-[7rem] shrink-0 lg:block`,children:n.module}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:n.message})]}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r.map(e=>{let t=e.level??`info`,r=typeof e.requestId==`string`?e.requestId.trim():``,i=je(e),a=t===`error`||t===`fatal`;return(0,$.jsx)(`li`,{className:`rounded-lg bg-surface-base/45`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:u(`flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,a&&`bg-red-500/5`),children:[(0,$.jsx)(`span`,{className:`w-[4.75rem] shrink-0 font-mono text-xs tabular-nums text-fg-subtle sm:w-[5.25rem] sm:text-sm`,children:Ee(e.timestamp)}),(0,$.jsx)(`span`,{className:u(`w-[4.5rem] shrink-0 truncate`,a?`font-medium text-red-600 dark:text-red-400`:`text-fg-muted`),title:t,children:Ae(t)}),(0,$.jsx)(`span`,{className:`hidden w-[4.5rem] shrink-0 truncate font-mono sm:block sm:w-[5.25rem]`,children:r?d?(0,$.jsx)(`span`,{role:`link`,tabIndex:0,className:`cursor-pointer text-accent hover:underline`,title:`${n.requestId}: ${r}`,onClick:e=>{e.stopPropagation(),d(r)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),d(r))},children:ke(r)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,title:`${n.requestId}: ${r}`,children:ke(r)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,children:`—`})}),(0,$.jsx)(`span`,{className:`hidden max-w-[6rem] shrink-0 truncate text-fg-subtle xl:inline`,title:i===`—`?void 0:i,children:i===`—`?`—`:i}),(0,$.jsx)(`span`,{className:`hidden max-w-[7rem] shrink-0 truncate text-fg-muted lg:inline`,title:we(e),children:we(e)}),(0,$.jsx)(`span`,{className:u(`min-w-0 flex-1 truncate`,`text-fg`),children:Te(e)})]})},Me(e))})})]}),o?(0,$.jsx)(`div`,{className:`flex justify-center pt-1`,children:(0,$.jsxs)(_,{type:`button`,variant:`secondary`,className:`gap-2`,disabled:i,onClick:c,children:[i?(0,$.jsx)(M,{className:`size-4 animate-spin motion-reduce:animate-none`,strokeWidth:1.75}):(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75}),n.loadMore]})}):null]}):null,t[8]=n,t[9]=o,t[10]=i,t[11]=r,t[12]=d,t[13]=c,t[14]=s,t[15]=m):m=t[15];let h;return t[16]!==f||t[17]!==p||t[18]!==m?(h=(0,$.jsxs)($.Fragment,{children:[f,p,m]}),t[16]=f,t[17]=p,t[18]=m,t[19]=h):h=t[19],h}function $e(e,t){return(0,$.jsxs)(`div`,{className:`flex gap-3 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`h-4 w-16 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 w-12 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 w-20 shrink-0 bg-surface-hover motion-reduce:animate-none animate-pulse`}),(0,$.jsx)(`div`,{className:`h-4 min-w-0 flex-1 bg-surface-hover motion-reduce:animate-none animate-pulse`})]},t)}function et(e){let t=(0,J.c)(8),{L:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(V,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=r):r=t[0];let i;t[1]===n.title?i=t[2]:(i=(0,$.jsx)(`h1`,{className:`text-base font-semibold tracking-tight text-fg`,children:n.title}),t[1]=n.title,t[2]=i);let a;t[3]===n.needToken?a=t[4]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.needToken}),t[3]=n.needToken,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,$.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-10 sm:px-5 xl:px-6`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[r,(0,$.jsxs)(`div`,{children:[i,a]})]})}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function tt(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function nt(e){let t=[`timestamp`,`level`,`module`,`phase`,`requestId`,`transcriptId`,`message`],n=e.map(e=>{let t=String(e.module||``),n=String(e.phase??e.meta?.phase??``);return[e.timestamp,e.level,t,n,e.requestId??``,e.transcriptId??``,e.message??``].map(e=>tt(String(e))).join(`,`)});return[t.join(`,`),...n].join(`
2
- `)}function rt(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}function it(e,t){let n=new Date().toISOString().replace(/[:.]/g,`-`);if(t===`json`){rt(JSON.stringify(e,null,2),`xopc-logs-${n}.json`,`application/json`);return}rt(nt(e),`xopc-logs-${n}.csv`,`text/csv;charset=utf-8`)}function at(e){let t=(0,J.c)(32),{L:n,logs:r,disabled:i}=e,a=i||r.length===0,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(c,{className:`size-4`,strokeWidth:1.75}),t[0]=o):o=t[0];let s;t[1]===n.exportLogs?s=t[2]:(s=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:n.exportLogs}),t[1]=n.exportLogs,t[2]=s);let l;t[3]!==n.exportLogs||t[4]!==a||t[5]!==s?(l=(0,$.jsx)(C,{asChild:!0,children:(0,$.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-9 gap-2 whitespace-nowrap px-3 text-xs`,disabled:a,title:n.exportLogs,children:[o,s]})}),t[3]=n.exportLogs,t[4]=a,t[5]=s,t[6]=l):l=t[6];let d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=u(`w-52 rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover outline-none`,E,`dark:border-edge`),t[7]=d):d=t[7];let f;t[8]===n.exportLogs?f=t[9]:(f=(0,$.jsx)(`p`,{className:`px-2 py-1 text-xs font-medium text-fg`,children:n.exportLogs}),t[8]=n.exportLogs,t[9]=f);let p;t[10]===n.exportHint?p=t[11]:(p=(0,$.jsx)(`p`,{className:`px-2 pb-2 text-xs leading-5 text-fg-muted`,children:n.exportHint}),t[10]=n.exportHint,t[11]=p);let m;t[12]===r?m=t[13]:(m=()=>it(r,`json`),t[12]=r,t[13]=m);let h;t[14]!==n.exportJson||t[15]!==m?(h=(0,$.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 justify-start px-2 text-xs`,onClick:m,children:n.exportJson}),t[14]=n.exportJson,t[15]=m,t[16]=h):h=t[16];let g;t[17]===r?g=t[18]:(g=()=>it(r,`csv`),t[17]=r,t[18]=g);let v;t[19]!==n.exportCsv||t[20]!==g?(v=(0,$.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 justify-start px-2 text-xs`,onClick:g,children:n.exportCsv}),t[19]=n.exportCsv,t[20]=g,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==h?(y=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[h,v]}),t[22]=v,t[23]=h,t[24]=y):y=t[24];let w;t[25]!==y||t[26]!==f||t[27]!==p?(w=(0,$.jsx)(b,{children:(0,$.jsxs)(x,{side:`bottom`,align:`end`,sideOffset:6,className:d,children:[f,p,y]})}),t[25]=y,t[26]=f,t[27]=p,t[28]=w):w=t[28];let T;return t[29]!==w||t[30]!==l?(T=(0,$.jsxs)(S,{children:[l,w]}),t[29]=w,t[30]=l,t[31]=T):T=t[31],T}function ot(e){let t=(0,J.c)(38),{L:n}=e,[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(`info`),[s,c]=(0,q.useState)(!1),[l,d]=(0,q.useState)(null),f,p;t[0]!==n.logLevelLoadError||t[1]!==r?(f=()=>{if(!r)return;let e=!1;return ie().then(t=>{e||o(t)}).catch(t=>{e||d(t instanceof Error?t.message:n.logLevelLoadError)}),()=>{e=!0}},p=[r,n.logLevelLoadError],t[0]=n.logLevelLoadError,t[1]=r,t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,q.useEffect)(f,p);let m;t[4]===n.logLevelSaveError?m=t[5]:(m=e=>{c(!0),d(null),ae(e).then(e=>{o(e.current),i(!1)}).catch(e=>{d(e instanceof Error?e.message:n.logLevelSaveError)}).finally(()=>c(!1))},t[4]=n.logLevelSaveError,t[5]=m);let h=m,g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(z,{className:`size-4`,strokeWidth:1.75}),t[6]=g):g=t[6];let v;t[7]===n.logLevelTitle?v=t[8]:(v=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:n.logLevelTitle}),t[7]=n.logLevelTitle,t[8]=v);let y;t[9]===a?y=t[10]:(y=(0,$.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:a}),t[9]=a,t[10]=y);let w;t[11]!==n.logLevelTitle||t[12]!==v||t[13]!==y?(w=(0,$.jsx)(C,{asChild:!0,children:(0,$.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-9 gap-2 whitespace-nowrap px-3 text-xs`,title:n.logLevelTitle,children:[g,v,y]})}),t[11]=n.logLevelTitle,t[12]=v,t[13]=y,t[14]=w):w=t[14];let T;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(T=u(`w-56 rounded-xl border border-edge bg-surface-overlay p-3 shadow-popover outline-none`,E,`dark:border-edge`),t[15]=T):T=t[15];let D;t[16]===n.logLevelTitle?D=t[17]:(D=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.logLevelTitle}),t[16]=n.logLevelTitle,t[17]=D);let O;t[18]===n.logLevelHint?O=t[19]:(O=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.logLevelHint}),t[18]=n.logLevelHint,t[19]=O);let k;t[20]!==n.levelNames||t[21]!==h||t[22]!==a||t[23]!==s?(k=ue.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>h(e),className:u(`flex w-full items-center justify-between rounded-md px-2 py-1.5 text-left text-xs transition-colors`,a===e?`bg-accent/10 font-medium text-accent`:`text-fg hover:bg-surface-hover`),children:[(0,$.jsx)(`span`,{children:n.levelNames[e]}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] uppercase text-fg-subtle`,children:e})]})},e)),t[20]=n.levelNames,t[21]=h,t[22]=a,t[23]=s,t[24]=k):k=t[24];let A;t[25]===k?A=t[26]:(A=(0,$.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1`,children:k}),t[25]=k,t[26]=A);let j;t[27]===l?j=t[28]:(j=l?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:l}):null,t[27]=l,t[28]=j);let M;t[29]!==O||t[30]!==A||t[31]!==j||t[32]!==D?(M=(0,$.jsx)(b,{children:(0,$.jsxs)(x,{side:`bottom`,align:`end`,sideOffset:6,className:T,children:[D,O,A,j]})}),t[29]=O,t[30]=A,t[31]=j,t[32]=D,t[33]=M):M=t[33];let N;return t[34]!==r||t[35]!==M||t[36]!==w?(N=(0,$.jsxs)(S,{open:r,onOpenChange:i,children:[w,M]}),t[34]=r,t[35]=M,t[36]=w,t[37]=N):N=t[37],N}function st(e){let t=(0,J.c)(49),{L:n,autoRefresh:r,onAutoRefreshChange:i,fileCount:a,onOpenFiles:o,loading:s,onRefreshAll:c,logs:l}=e,u;t[0]===n.title?u=t[1]:(u=(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-lg`,children:n.title}),t[0]=n.title,t[1]=u);let d;t[2]===n.subtitle?d=t[3]:(d=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-fg-muted sm:mt-1`,children:n.subtitle}),t[2]=n.subtitle,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p=r?`live`:`paused`,m;t[7]===i?m=t[8]:(m=e=>i(e===`live`),t[7]=i,t[8]=m);let h;t[9]===n.refreshManual?h=t[10]:(h={value:`paused`,label:n.refreshManual},t[9]=n.refreshManual,t[10]=h);let g;t[11]===n.refreshLive?g=t[12]:(g={value:`live`,label:n.refreshLive},t[11]=n.refreshLive,t[12]=g);let v;t[13]!==h||t[14]!==g?(v=[h,g],t[13]=h,t[14]=g,t[15]=v):v=t[15];let y;t[16]!==n.refreshModeAria||t[17]!==p||t[18]!==m||t[19]!==v?(y=(0,$.jsx)(`div`,{className:`w-full sm:w-52`,children:(0,$.jsx)(Ye,{"aria-label":n.refreshModeAria,value:p,onChange:m,options:v,buttonClassName:`h-8`})}),t[16]=n.refreshModeAria,t[17]=p,t[18]=m,t[19]=v,t[20]=y):y=t[20];let b;t[21]===n?b=t[22]:(b=(0,$.jsx)(ot,{L:n}),t[21]=n,t[22]=b);let x;t[23]!==n||t[24]!==s||t[25]!==l?(x=(0,$.jsx)(at,{L:n,logs:l,disabled:s}),t[23]=n,t[24]=s,t[25]=l,t[26]=x):x=t[26];let S;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(B,{className:`size-4`,strokeWidth:1.75}),t[27]=S):S=t[27];let C;t[28]===a?C=t[29]:(C=a>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-1.5 text-xs text-fg-muted`,children:a}):null,t[28]=a,t[29]=C);let w;t[30]!==n.logFiles||t[31]!==o||t[32]!==C?(w=(0,$.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,title:n.logFiles,"aria-label":n.logFiles,onClick:o,children:[S,C]}),t[30]=n.logFiles,t[31]=o,t[32]=C,t[33]=w):w=t[33];let T;t[34]!==n.refresh||t[35]!==s||t[36]!==c?(T=(0,$.jsx)(U,{className:`h-9 min-h-[44px] min-w-[44px] px-2 sm:min-h-9 sm:min-w-0`,loading:s,label:n.refresh,onClick:c}),t[34]=n.refresh,t[35]=s,t[36]=c,t[37]=T):T=t[37];let E;t[38]!==b||t[39]!==x||t[40]!==w||t[41]!==T?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-1 sm:self-center`,children:[b,x,w,T]}),t[38]=b,t[39]=x,t[40]=w,t[41]=T,t[42]=E):E=t[42];let D;t[43]!==E||t[44]!==y?(D=(0,$.jsxs)(`div`,{className:`flex w-full shrink-0 flex-col gap-2 rounded-xl bg-surface-hover/20 p-2 sm:flex-row sm:items-center sm:justify-between`,children:[y,E]}),t[43]=E,t[44]=y,t[45]=D):D=t[45];let O;return t[46]!==D||t[47]!==f?(O=(0,$.jsxs)(`header`,{className:`flex flex-col gap-4`,children:[f,D]}),t[46]=D,t[47]=f,t[48]=O):O=t[48],O}function ct(e){let t=(0,J.c)(33),{L:n,stats:r}=e,i;t[0]===r.byLevel?i=t[1]:(i=r.byLevel??{},t[0]=r.byLevel,t[1]=i);let a;t[2]!==n.levelNames||t[3]!==i?(a=Fe(i,n.levelNames),t[2]=n.levelNames,t[3]=i,t[4]=a):a=t[4];let o=a,s=r.runtime?.errorsLast24h;if(!o&&s==null)return null;let c;t[5]===n.statsRegion?c=t[6]:(c=(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.statsRegion}),t[5]=n.statsRegion,t[6]=c);let l;t[7]===o?l=t[8]:(l=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mx-1.5 text-fg-subtle`,children:`·`}),(0,$.jsx)(`span`,{className:`tabular-nums`,children:o})]}):null,t[7]=o,t[8]=l);let d;t[9]!==n.runtimeErrors||t[10]!==s?(d=s!=null&&s>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mx-1.5 text-fg-subtle`,children:`·`}),(0,$.jsxs)(`span`,{className:`tabular-nums text-red-600 dark:text-red-400`,children:[n.runtimeErrors,` `,s]})]}):null,t[9]=n.runtimeErrors,t[10]=s,t[11]=d):d=t[11];let f;t[12]!==c||t[13]!==l||t[14]!==d?(f=(0,$.jsx)(C,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded-lg border border-transparent px-1 py-0.5 text-left text-xs leading-5 text-fg-subtle transition-colors duration-150 ease-out hover:border-edge-subtle hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel dark:hover:border-edge`,children:[c,l,d]})}),t[12]=c,t[13]=l,t[14]=d,t[15]=f):f=t[15];let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=u(`w-[min(calc(100vw-2rem),20rem)] rounded-xl border border-edge bg-surface-overlay p-3 shadow-popover outline-none`,E,`dark:border-edge`),t[16]=p):p=t[16];let m;t[17]===n.statsDetailTitle?m=t[18]:(m=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.statsDetailTitle}),t[17]=n.statsDetailTitle,t[18]=m);let h;t[19]===n.statsHint?h=t[20]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.statsHint}),t[19]=n.statsHint,t[20]=h);let g;t[21]!==n.levelNames||t[22]!==r.byLevel?(g=ue.map(e=>{let t=r.byLevel?.[e]??0;return t===0?null:(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs dark:border-edge`,children:[(0,$.jsx)(`span`,{className:`font-medium capitalize text-fg`,children:n.levelNames[e]}),(0,$.jsx)(`span`,{className:`tabular-nums text-fg-muted`,children:t})]},e)}),t[21]=n.levelNames,t[22]=r.byLevel,t[23]=g):g=t[23];let _;t[24]===g?_=t[25]:(_=(0,$.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1.5`,children:g}),t[24]=g,t[25]=_);let v;t[26]!==_||t[27]!==m||t[28]!==h?(v=(0,$.jsx)(b,{children:(0,$.jsxs)(x,{side:`bottom`,align:`start`,sideOffset:6,className:p,children:[m,h,_]})}),t[26]=_,t[27]=m,t[28]=h,t[29]=v):v=t[29];let y;return t[30]!==v||t[31]!==f?(y=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(S,{children:[f,v]})}),t[30]=v,t[31]=f,t[32]=y):y=t[32],y}function lt(){let e=(0,J.c)(89),{L:t,hasToken:n,logs:r,loading:i,error:a,hasMore:o,searchInput:s,setSearchInput:c,selectedLevels:l,moduleFilter:u,setModuleFilter:d,dateFrom:f,setDateFrom:m,dateTo:h,setDateTo:g,modules:_,files:v,stats:y,selectedLog:b,setSelectedLog:x,filesOpen:S,setFilesOpen:C,filtersOpen:w,setFiltersOpen:T,logDir:E,autoRefresh:D,setAutoRefresh:O,copiedDetail:k,setCopiedDetail:A,hasActiveFilters:j,activeFilterCount:M,clearFilters:N,toggleDialogLevel:P,handleLoadMore:F,refreshAll:I,levelSegment:L,handleLevelSegment:R,filterByRequestId:z,filterByTranscriptId:B,filterByErrorSummary:V,openChatForSession:H,errorSummary:ee,errorSummaryLoading:te}=ze(p(ut));if(!n){let n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(et,{L:t}),e[0]=t,e[1]=n),n}let U;e[2]===C?U=e[3]:(U=()=>C(!0),e[2]=C,e[3]=U);let W;e[4]!==t||e[5]!==D||e[6]!==v.length||e[7]!==i||e[8]!==r||e[9]!==I||e[10]!==O||e[11]!==U?(W=(0,$.jsx)(st,{L:t,autoRefresh:D,onAutoRefreshChange:O,fileCount:v.length,onOpenFiles:U,loading:i,onRefreshAll:I,logs:r}),e[4]=t,e[5]=D,e[6]=v.length,e[7]=i,e[8]=r,e[9]=I,e[10]=O,e[11]=U,e[12]=W):W=e[12];let G;e[13]===a?G=e[14]:(G=a?(0,$.jsx)(`div`,{className:`rounded-xl bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:a}):null,e[13]=a,e[14]=G);let q;e[15]!==t||e[16]!==y?(q=y?(0,$.jsx)(ct,{L:t,stats:y}):null,e[15]=t,e[16]=y,e[17]=q):q=e[17];let Y;e[18]!==t||e[19]!==ee||e[20]!==te||e[21]!==V?(Y=(0,$.jsx)(Be,{L:t,items:ee,loading:te,onSelectItem:V}),e[18]=t,e[19]=ee,e[20]=te,e[21]=V,e[22]=Y):Y=e[22];let X;e[23]===T?X=e[24]:(X=()=>T(!0),e[23]=T,e[24]=X);let Z;e[25]!==t||e[26]!==M||e[27]!==D||e[28]!==N||e[29]!==R||e[30]!==j||e[31]!==L||e[32]!==u||e[33]!==_||e[34]!==s||e[35]!==d||e[36]!==c||e[37]!==X?(Z=(0,$.jsx)(Xe,{L:t,levelSegment:L,onLevelSegment:R,searchInput:s,onSearchInputChange:c,moduleFilter:u,onModuleFilterChange:d,modules:_,onOpenFilters:X,activeFilterCount:M,hasActiveFilters:j,onClearFilters:N,autoRefresh:D}),e[25]=t,e[26]=M,e[27]=D,e[28]=N,e[29]=R,e[30]=j,e[31]=L,e[32]=u,e[33]=_,e[34]=s,e[35]=d,e[36]=c,e[37]=X,e[38]=Z):Z=e[38];let Q;e[39]!==t||e[40]!==z||e[41]!==F||e[42]!==o||e[43]!==i||e[44]!==r||e[45]!==I||e[46]!==x?(Q=(0,$.jsx)(Qe,{L:t,logs:r,loading:i,hasMore:o,onSelectLog:x,onLoadMore:F,onRefreshAll:I,onFilterByRequestId:z}),e[39]=t,e[40]=z,e[41]=F,e[42]=o,e[43]=i,e[44]=r,e[45]=I,e[46]=x,e[47]=Q):Q=e[47];let ne;e[48]!==t||e[49]!==f||e[50]!==h||e[51]!==w||e[52]!==l||e[53]!==m||e[54]!==g||e[55]!==T||e[56]!==P?(ne=(0,$.jsx)(qe,{L:t,open:w,onOpenChange:T,dateFrom:f,onDateFromChange:m,dateTo:h,onDateToChange:g,selectedLevels:l,onToggleLevel:P}),e[48]=t,e[49]=f,e[50]=h,e[51]=w,e[52]=l,e[53]=m,e[54]=g,e[55]=T,e[56]=P,e[57]=ne):ne=e[57];let re;e[58]===x?re=e[59]:(re=()=>x(null),e[58]=x,e[59]=re);let ie,ae;e[60]===A?(ie=e[61],ae=e[62]):(ie=()=>A(`message`),ae=()=>A(`json`),e[60]=A,e[61]=ie,e[62]=ae);let oe;e[63]!==t||e[64]!==k||e[65]!==z||e[66]!==B||e[67]!==H||e[68]!==b||e[69]!==ie||e[70]!==ae||e[71]!==re?(oe=(0,$.jsx)(We,{L:t,log:b,onClose:re,copiedDetail:k,onCopiedMessage:ie,onCopiedJson:ae,onFilterByRequestId:z,onFilterByTranscriptId:B,onOpenChat:H}),e[63]=t,e[64]=k,e[65]=z,e[66]=B,e[67]=H,e[68]=b,e[69]=ie,e[70]=ae,e[71]=re,e[72]=oe):oe=e[72];let se;e[73]!==t||e[74]!==v||e[75]!==S||e[76]!==E||e[77]!==C?(se=(0,$.jsx)(Ge,{L:t,open:S,onOpenChange:C,files:v,logDir:E}),e[73]=t,e[74]=v,e[75]=S,e[76]=E,e[77]=C,e[78]=se):se=e[78];let ce;return e[79]!==W||e[80]!==oe||e[81]!==se||e[82]!==G||e[83]!==q||e[84]!==Y||e[85]!==Z||e[86]!==Q||e[87]!==ne?(ce=(0,$.jsxs)(K,{gap:`gap-6`,children:[W,G,q,Y,Z,Q,ne,oe,se]}),e[79]=W,e[80]=oe,e[81]=se,e[82]=G,e[83]=q,e[84]=Y,e[85]=Z,e[86]=Q,e[87]=ne,e[88]=ce):ce=e[88],ce}function ut(e){return e.language}export{lt as LogsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./popover-select-DGKUpVsz.js";import{t as o}from"./messages-RzwPiQNL.js";import{t as s}from"./cn-0WouolD0.js";import{a as c,i as l,n as u}from"./locale-store-JogcXC4J.js";import{s as d}from"./session-api-DTxZyMta.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./button-aIC072nz.js";import{t as m}from"./skeleton-BI5TyibZ.js";import{i as h,o as g}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Bc as _,Fc as v,Hl as y,Ic as b,Lc as x,Md as S,Nu as C,Qd as w,Sl as ee,Vc as T,bn as E,cu as D,jd as O,kl as k,na as te,qc as ne,ta as A,vo as j,wa as M,yl as N,zc as re}from"./index-ygkHNYyo.js";import{n as P,t as F}from"./settings-page-header-CYpuTXUW.js";import{t as I}from"./settings-page-layout-B20AfmFG.js";import{t as L}from"./device-pairing-wizard-PmP_vGem.js";var R=n(),z=e(t(),1),B=r();async function V(e=`GET`,t,n){let r=await c(l(`/api/endpoint-tools/target-authorizations`+(n?`/`+encodeURIComponent(n):``)),{method:e,...t?{body:JSON.stringify(t)}:{}});if(!r.ok)throw Error(r.status===403?`owner`:`unavailable`);return(await r.json()).payload}function ie({devices:e,zh:t}){let n=f(`device-single-call-grants`,()=>V(),{refreshInterval:5e3,shouldRetryOnError:!1}),r=f(n.error?null:`device-grant-conversations`,()=>d({limit:100}),{shouldRetryOnError:!1}),[i,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(``),[h,g]=(0,z.useState)(`weather`),[_,v]=(0,z.useState)(`approximate`),[y,b]=(0,z.useState)(`restaurant`),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(!1);if(n.error)return null;let ee=e.flatMap(e=>e.endpoints.map(t=>({...t,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))),T=ee.find(e=>e.endpointId===l)?.tools.find(e=>e.descriptor.name.endsWith(`.device.get_location`))?.descriptor.name,E=async()=>{if(!(!T||!i||!s)){S(!0),w(!1);try{await V(`POST`,{conversationId:i,requestorPrincipalId:s,targetEndpointId:l,toolName:T,arguments:{purpose:h,precision:_,...h===`nearby`?{category:y}:{}}}),await n.mutate()}catch{w(!0)}finally{S(!1)}}};return(0,B.jsxs)(`section`,{className:`mb-5 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,B.jsx)(`h3`,{className:`font-semibold text-fg`,children:t?`跨设备单次授权`:`Single-call device authorization`}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t?`为指定会话和来源设备授权一次定位查询,60 秒后失效。目标设备仍需确认;授权后请在来源设备继续请求。`:`Authorize one location query for a conversation and source device. Expires in 60 seconds; target-device consent is still required. Continue the request from the source device.`}),n.isLoading||r.isLoading?(0,B.jsx)(m,{className:`mt-3 h-28`}):(0,B.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,B.jsx)(a,{value:i,onChange:o,placeholder:t?`选择会话`:`Conversation`,ariaLabel:t?`会话`:`Conversation`,options:(r.data?.items??[]).map(e=>({value:e.key,label:e.name||e.key}))}),(0,B.jsx)(a,{value:s,onChange:c,placeholder:t?`消息来源设备`:`Source device`,ariaLabel:t?`消息来源设备`:`Source device`,options:e.filter(e=>e.endpoints.length>0).map(e=>({value:e.id,label:e.displayName+` · `+e.platform+` · `+e.id.slice(-8)}))}),(0,B.jsx)(a,{value:l,onChange:u,placeholder:t?`使用哪台设备的位置`:`Location device`,ariaLabel:t?`目标设备`:`Target device`,options:ee.filter(e=>e.tools.some(e=>e.descriptor.name.endsWith(`.device.get_location`))).map(e=>({value:e.endpointId,label:e.label}))}),(0,B.jsx)(a,{placeholder:t?`用途`:`Purpose`,value:h,onChange:e=>g(e),ariaLabel:t?`用途`:`Purpose`,options:[{value:`weather`,label:t?`查询天气`:`Weather`},{value:`nearby`,label:t?`附近地点`:`Nearby places`}],allowEmpty:!1}),(0,B.jsx)(a,{placeholder:t?`精度`:`Precision`,value:_,onChange:e=>v(e),ariaLabel:t?`精度`:`Precision`,options:[{value:`approximate`,label:t?`大致位置`:`Approximate`},{value:`precise`,label:t?`精确位置`:`Precise`}],allowEmpty:!1}),h===`nearby`?(0,B.jsx)(a,{placeholder:t?`地点类型`:`Category`,value:y,onChange:b,ariaLabel:t?`附近地点类型`:`Place category`,options:[`restaurant`,`cafe`,`pharmacy`,`park`].map((e,n)=>({value:e,label:t?[`餐厅`,`咖啡馆`,`药店`,`公园`][n]:e})),allowEmpty:!1}):null,(0,B.jsx)(p,{variant:`primary`,disabled:x||!i||!s||!T,onClick:()=>void E(),children:t?`允许一次`:`Allow once`})]}),C?(0,B.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-fg-muted`,children:t?`授权失败,请检查设备连接后重试。`:`Authorization failed. Check the device connection.`}):null,(0,B.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.data?.map(r=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm text-fg-muted`,children:[(0,B.jsxs)(`span`,{children:[e.find(e=>e.endpoints.some(e=>e.endpointId===r.targetEndpointId))?.displayName??(t?`设备`:`Device`),` · `,r.state===`running`?t?`执行中`:`Running`:t?`等待本次调用`:`Awaiting one call`]}),(0,B.jsx)(p,{disabled:x,onClick:()=>{S(!0),V(`DELETE`,void 0,r.id).then(()=>n.mutate()).catch(()=>w(!0)).finally(()=>S(!1))},children:t?`撤销`:`Revoke`})]},r.id))})]})}var H=720*60*60*1e3;function U(e){let t=[e.access,e.principal].filter(e=>e!==null);return t.length>0&&t.every(e=>e.revokedAt!==void 0)}function W(e){return U(e)?`revoked`:e.endpoints.length>0?`online`:`offline`}function ae(e){return new Set(e.endpoints.flatMap(e=>e.tools.map(({descriptor:e})=>e.name))).size}function oe(e,t=Date.now()){return W(e)===`offline`?(e.lastSeenAt??e.createdAt)<t-H:!1}function se(e,t,n=Date.now()){let r=t.query.trim().toLocaleLowerCase();return e.filter(e=>{let i=W(e),a=t.status===`all`||(t.status===`active`?i!==`revoked`:t.status===`stale`?oe(e,n):i===t.status),o=!t.platform||e.platform===t.platform,s=!r||[e.displayName,e.id,e.kind,e.platform].some(e=>e.toLocaleLowerCase().includes(r));return a&&o&&s})}function ce(e){return e.length>8?e.slice(-8):e}function le(e){let t=(0,R.c)(61),{device:n,busy:r,onClose:i,onRevoke:a,onRename:c}=e,l=u(ue),d;t[0]===l?d=t[1]:(d=o(l),t[0]=l,t[1]=d);let f=d.endpointToolsSettings,m=l===`zh`?`zh-CN`:`en`,y;t[2]===m?y=t[3]:(y=new Intl.DateTimeFormat(m,{dateStyle:`medium`,timeStyle:`short`}),t[2]=m,t[3]=y);let S=y,C;t[4]===n?C=t[5]:(C=n?W(n):`offline`,t[4]=n,t[5]=C);let w=C,E=n!==null,D;t[6]===i?D=t[7]:(D=e=>!e&&i(),t[6]=i,t[7]=D);let O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,B.jsx)(re,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim`,g)}),t[8]=O):O=t[8];let k;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(k=s(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,h),t[9]=k):k=t[9];let te=n?.displayName??f.deviceDetails,A;t[10]===te?A=t[11]:(A=(0,B.jsx)(T,{className:`truncate text-base font-semibold text-fg`,children:te}),t[10]=te,t[11]=A);let j;t[12]===n?j=t[13]:(j=n?(0,B.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[n.kind,` · `,n.platform,` · `,ce(n.id)]}):null,t[12]=n,t[13]=j);let M;t[14]!==A||t[15]!==j?(M=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[A,j]}),t[14]=A,t[15]=j,t[16]=M):M=t[16];let N;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,B.jsx)(ne,{className:`size-5`,"aria-hidden":!0}),t[17]=N):N=t[17];let P;t[18]===f.close?P=t[19]:(P=(0,B.jsx)(b,{asChild:!0,children:(0,B.jsx)(p,{variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":f.close,children:N})}),t[18]=f.close,t[19]=P);let F;t[20]!==M||t[21]!==P?(F=(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[M,P]}),t[20]=M,t[21]=P,t[22]=F):F=t[22];let I;t[23]!==f.accessActive||t[24]!==f.accessRevoked||t[25]!==f.accessTitle||t[26]!==f.createdAt||t[27]!==f.endpointCount||t[28]!==f.endpointsTitle||t[29]!==f.identityId||t[30]!==f.identityTitle||t[31]!==f.lastSeen||t[32]!==f.never||t[33]!==f.noAccessIdentity||t[34]!==f.noOnlineEndpoints||t[35]!==f.noPermissions||t[36]!==f.permissions||t[37]!==f.status||t[38]!==f.statusLabel||t[39]!==f.toolCount||t[40]!==n||t[41]!==S||t[42]!==l||t[43]!==c||t[44]!==w?(I=n?(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4`,children:[n.principal&&w!==`revoked`&&c?(0,B.jsx)(de,{device:n,zh:l===`zh`,onRename:c},`${n.id}:${n.settingsRevision??0}`):null,(0,B.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 rounded-xl bg-surface-hover/40 p-4`,children:[(0,B.jsx)(G,{label:f.statusLabel,value:f.status[w]}),(0,B.jsx)(G,{label:f.lastSeen,value:n.lastSeenAt?S.format(n.lastSeenAt):f.never}),(0,B.jsx)(G,{label:f.endpointCount,value:String(n.endpoints.length)}),(0,B.jsx)(G,{label:f.toolCount,value:String(ae(n))})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:f.accessTitle}),(0,B.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs text-fg-muted`,children:n.access?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{children:n.access.revokedAt?f.accessRevoked:f.accessActive}),(0,B.jsx)(`p`,{className:`mt-1`,children:n.access.requestProofVersion===1?l===`zh`?`设备请求签名已启用`:`Device request signing enabled`:l===`zh`?`请求签名未启用,设备不可用`:`Request signing is missing; device unavailable`}),(0,B.jsxs)(`p`,{className:`mt-1 break-words`,children:[f.permissions,`: `,n.access.scopes.join(`, `)||f.noPermissions]})]}):(0,B.jsx)(`p`,{children:f.noAccessIdentity})})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:f.endpointsTitle}),(0,B.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[n.endpoints.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.noOnlineEndpoints}):null,n.endpoints.map(e=>(0,B.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,B.jsx)(`p`,{className:`min-w-0 break-all text-xs font-medium text-fg`,children:e.endpointId}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[f.status[e.availability],` · v`,e.appVersion]})]}),(0,B.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.tools.map(e=>{let{descriptor:t}=e;return(0,B.jsxs)(`div`,{className:`rounded-lg bg-surface-hover/50 px-3 py-2`,children:[(0,B.jsx)(`p`,{className:`break-all text-xs font-medium text-fg`,children:t.title}),(0,B.jsxs)(`p`,{className:`mt-0.5 break-words text-xs text-fg-subtle`,children:[t.requiresForeground?l===`zh`?`需要设备在前台 · `:`Requires foreground · `:``,t.confirmation===`always`?l===`zh`?`每次确认`:`Confirm each time`:l===`zh`?`按已授权范围调用`:`Uses the authorized scope`]})]},t.name)})})]},e.connectionId))]})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:f.identityTitle}),n.principal&&w!==`revoked`&&c?(0,B.jsx)(de,{device:n,zh:l===`zh`,onRename:c},`${n.id}:${n.settingsRevision??0}`):null,(0,B.jsxs)(`dl`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs`,children:[(0,B.jsx)(G,{label:f.identityId,value:n.id,breakAll:!0}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(G,{label:f.createdAt,value:S.format(n.createdAt)})})]})]})]}):null,t[23]=f.accessActive,t[24]=f.accessRevoked,t[25]=f.accessTitle,t[26]=f.createdAt,t[27]=f.endpointCount,t[28]=f.endpointsTitle,t[29]=f.identityId,t[30]=f.identityTitle,t[31]=f.lastSeen,t[32]=f.never,t[33]=f.noAccessIdentity,t[34]=f.noOnlineEndpoints,t[35]=f.noPermissions,t[36]=f.permissions,t[37]=f.status,t[38]=f.statusLabel,t[39]=f.toolCount,t[40]=n,t[41]=S,t[42]=l,t[43]=c,t[44]=w,t[45]=I):I=t[45];let L;t[46]!==r||t[47]!==f.removeDevice||t[48]!==f.revoking||t[49]!==n||t[50]!==a||t[51]!==w?(L=n&&w!==`revoked`?(0,B.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,B.jsxs)(p,{variant:`secondary`,className:`w-full text-danger`,disabled:r,onClick:()=>a(n),children:[(0,B.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),r?f.revoking:f.removeDevice]})}):null,t[46]=r,t[47]=f.removeDevice,t[48]=f.revoking,t[49]=n,t[50]=a,t[51]=w,t[52]=L):L=t[52];let z;t[53]!==F||t[54]!==I||t[55]!==L?(z=(0,B.jsxs)(_,{children:[O,(0,B.jsxs)(x,{className:k,"aria-describedby":void 0,children:[F,I,L]})]}),t[53]=F,t[54]=I,t[55]=L,t[56]=z):z=t[56];let V;return t[57]!==z||t[58]!==E||t[59]!==D?(V=(0,B.jsx)(v,{open:E,onOpenChange:D,children:z}),t[57]=z,t[58]=E,t[59]=D,t[60]=V):V=t[60],V}function ue(e){return e.language}function G(e){let t=(0,R.c)(10),{label:n,value:r,breakAll:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,B.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let c=a&&`break-all font-mono text-xs`,l;t[2]===c?l=t[3]:(l=s(`mt-1 text-sm text-fg`,c),t[2]=c,t[3]=l);let u;t[4]!==l||t[5]!==r?(u=(0,B.jsx)(`dd`,{className:l,children:r}),t[4]=l,t[5]=r,t[6]=u):u=t[6];let d;return t[7]!==o||t[8]!==u?(d=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[o,u]}),t[7]=o,t[8]=u,t[9]=d):d=t[9],d}function de({device:e,zh:t,onRename:n}){let[r,i]=(0,z.useState)(e.displayName),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(!1);return(0,B.jsxs)(`form`,{className:`space-y-2`,onSubmit:async t=>{if(t.preventDefault(),!(a||!r.trim())){o(!0),c(!1);try{await n(e,r.trim())}catch{c(!0)}finally{o(!1)}}},children:[(0,B.jsxs)(`label`,{className:`block text-sm text-fg`,children:[t?`设备名称`:`Device name`,(0,B.jsx)(`input`,{value:r,maxLength:80,onChange:e=>i(e.target.value),className:`mt-2 h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-fg`})]}),(0,B.jsx)(p,{type:`submit`,variant:`secondary`,disabled:a||!r.trim()||r.trim()===e.displayName,children:a?t?`保存中…`:`Saving…`:t?`保存名称`:`Save name`}),s?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`保存失败,请刷新设备信息后重试。`:`Unable to save. Refresh device information and retry.`}):null]})}function fe(e){let t=(0,R.c)(19),{onPaired:n}=e,[r,a]=i(),s=u(me),c;t[0]===s?c=t[1]:(c=o(s),t[0]=s,t[1]=c);let l=c.endpointToolsSettings.deviceAccess,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={open:!1},t[2]=d):d=t[2];let[f,m]=(0,z.useState)(d),h,g;t[3]!==r||t[4]!==a?(h=()=>{let e=r.get(`startDevicePairing`);e!==`mobile`&&e!==`browser`||(m({open:!0,target:e}),a(pe,{replace:!0}))},g=[r,a],t[3]=r,t[4]=a,t[5]=h,t[6]=g):(h=t[5],g=t[6]),(0,z.useEffect)(h,g);let _,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>m({open:!0}),v=(0,B.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[7]=_,t[8]=v):(_=t[7],v=t[8]);let b;t[9]===l.addDevice?b=t[10]:(b=(0,B.jsxs)(p,{variant:`primary`,onClick:_,children:[v,l.addDevice]}),t[9]=l.addDevice,t[10]=b);let x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>m(t=>({...t,open:e})),t[11]=x):x=t[11];let S;t[12]!==f.open||t[13]!==f.target||t[14]!==n?(S=(0,B.jsx)(L,{open:f.open,onOpenChange:x,onPaired:n,targetKind:f.target}),t[12]=f.open,t[13]=f.target,t[14]=n,t[15]=S):S=t[15];let C;return t[16]!==b||t[17]!==S?(C=(0,B.jsxs)(B.Fragment,{children:[b,S]}),t[16]=b,t[17]=S,t[18]=C):C=t[18],C}function pe(e){let t=new URLSearchParams(e);return t.delete(`startDevicePairing`),t}function me(e){return e.language}async function K(e){let t=await e.json().catch(()=>null);if(!e.ok||t?.payload===void 0)throw Error(t?.error?.message??`Endpoint management request failed: ${e.status}`);return t.payload}function he(){return l(`/api/endpoint-tools/devices`)}function ge(e){let t=new URLSearchParams({page:String(e.page),pageSize:String(e.pageSize)});return e.query.trim()&&t.set(`query`,e.query.trim()),e.principalId&&t.set(`principalId`,e.principalId),e.status&&t.set(`status`,e.status),e.effect&&t.set(`effect`,e.effect),l(`/api/endpoint-tools/invocations?${t}`)}async function _e(){return K(await c(he()))}async function ve(e){let t=Array.from({length:Math.ceil(e.length/100)},(t,n)=>e.slice(n*100,(n+1)*100));await Promise.all(t.map(async e=>{await K(await c(l(`/api/endpoint-tools/devices/revoke`),{method:`POST`,body:JSON.stringify({ids:e})}))}))}async function ye(e){return K(await c(ge(e)))}async function be(e,t,n){await K(await c(l(`/api/endpoint-tools/devices/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({nickname:t,expectedRevision:n})}))}var xe=5e3,q=20,Se=20;function Ce(e){return e===`online`||e===`succeeded`?`bg-success-soft text-success`:e===`running`?`bg-accent-soft text-accent-fg`:e===`failed`||e===`revoked`?`bg-danger-soft text-danger`:`bg-surface-hover text-fg-muted`}function we(e){let t=(0,R.c)(5),{status:n,label:r}=e,i;t[0]===n?i=t[1]:(i=s(`rounded-full px-2 py-0.5 text-xs font-medium`,Ce(n)),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,B.jsx)(`span`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Te(){let e=u(e=>e.language),t=o(e).endpointToolsSettings,[n,r]=i(),c=n.get(`view`)===`activity`?`activity`:`devices`,[l,d]=(0,z.useState)(null),[m,h]=(0,z.useState)([]),[g,_]=(0,z.useState)(!1),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(``),[T,ne]=(0,z.useState)(`active`),[re,L]=(0,z.useState)(``),[R,V]=(0,z.useState)(1),[H,U]=(0,z.useState)(()=>new Set),[ue,G]=(0,z.useState)(``),[de]=M(ue,250),[pe,me]=(0,z.useState)(``),[K,Ce]=(0,z.useState)(``),[Te,Ee]=(0,z.useState)(``),[De,J]=(0,z.useState)(1),Oe={page:De,pageSize:Se,query:de,principalId:pe,status:K,effect:Te},Y=f(he(),_e,{refreshInterval:xe}),X=f(c===`activity`?ge(Oe):null,()=>ye(Oe),{refreshInterval:xe,keepPreviousData:!0}),ke=(0,z.useMemo)(()=>new Intl.DateTimeFormat(e===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),[e]);if(Y.isLoading&&!Y.data)return(0,B.jsx)(P,{children:(0,B.jsx)(E,{sections:2})});let Z=Y.data??[],Ae=X.data?.items??[],je=Z.filter(e=>W(e)===`online`).length,Me=Z.filter(e=>W(e)!==`revoked`).length,Ne=Z.filter(e=>oe(e)).length,Pe=[...new Set(Z.map(e=>e.platform))].toSorted(),Q=se(Z,{query:b,status:T,platform:re}),Fe=Math.max(1,Math.ceil(Q.length/q)),$=Math.min(R,Fe),Ie=Q.slice(($-1)*q,$*q),Le=Ie.reduce((e,t)=>(W(t)!==`revoked`&&e.push(t.id),e),[]),Re=Le.length>0&&Le.every(e=>H.has(e)),ze=e=>{r(t=>{let n=new URLSearchParams(t);return e===`devices`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})},Be=async()=>{await Promise.all([Y.mutate(),c===`activity`?X.mutate():Promise.resolve()])},Ve=async()=>{if(!(m.length===0||g)){_(!0),y(!1);try{await ve(m.map(e=>e.id)),h([]),U(new Set),await Y.mutate()}catch{y(!0)}finally{_(!1)}}},He=e=>{e(),V(1),U(new Set)};return(0,B.jsxs)(P,{children:[(0,B.jsx)(F,{title:t.title,subtitle:t.subtitle,actions:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(A,{className:`size-9 shrink-0 p-0`,label:t.refresh,onClick:Be}),(0,B.jsx)(fe,{onPaired:()=>void Y.mutate()})]})}),Y.error||X.error?(0,B.jsx)(`div`,{className:`rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger`,children:t.loadError}):null,(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{label:t.activeDevices,value:Me,filter:`active`},{label:t.onlineDevices,value:je,filter:`online`},{label:t.staleDevices,value:Ne,filter:`stale`}].map(({label:e,value:t,filter:n})=>(0,B.jsxs)(`button`,{type:`button`,className:s(`touch-target rounded-xl px-4 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,T===n?`bg-surface-active`:`bg-surface-hover/20 hover:bg-surface-hover/50`),"aria-pressed":T===n,onClick:()=>{He(()=>ne(n)),ze(`devices`)},children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e}),(0,B.jsx)(`span`,{className:`mt-1 block text-2xl font-semibold text-fg`,children:t})]},n))}),(0,B.jsx)(j,{items:[{id:`devices`,label:t.devicesTab,icon:D,count:Me},{id:`activity`,label:t.activityTab,icon:w,count:X.data?.total}],activeTab:c,onChange:ze,ariaLabel:t.viewsAria,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`}),(0,B.jsxs)(I,{id:`devices`,activeTab:c,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.devicesTitle,hint:t.devicesHint,children:[(0,B.jsx)(ie,{devices:Z,zh:e===`zh`}),(0,B.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-[minmax(0,1fr)_11rem_11rem]`,children:[(0,B.jsxs)(`label`,{className:`relative block`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:t.searchDevices}),(0,B.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,B.jsx)(`input`,{type:`search`,"aria-label":t.searchDevices,value:b,placeholder:t.searchDevices,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>He(()=>x(e.target.value))})]}),(0,B.jsx)(a,{value:T,options:[{value:`active`,label:t.filterActive},{value:`online`,label:t.status.online},{value:`offline`,label:t.status.offline},{value:`stale`,label:t.filterStale},{value:`revoked`,label:t.status.revoked},{value:`all`,label:t.filterAll}],placeholder:t.statusLabel,allowEmpty:!1,ariaLabel:t.statusLabel,onChange:e=>He(()=>ne(e))}),(0,B.jsx)(a,{value:re,options:Pe.map(e=>({value:e,label:e})),placeholder:t.allPlatforms,emptyLabel:t.allPlatforms,ariaLabel:t.platformLabel,onChange:e=>He(()=>L(e))})]}),H.size>0?(0,B.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-3 py-2`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-accent-fg`,children:t.selectedCount.replace(`{{count}}`,String(H.size))}),(0,B.jsxs)(p,{variant:`secondary`,className:`text-danger`,onClick:()=>{y(!1),h(Z.filter(e=>H.has(e.id)))},children:[(0,B.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t.removeSelected]})]}):null,Z.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noDevices}):Q.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingDevices}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-edge-subtle px-1`,children:(0,B.jsxs)(`label`,{className:s(`touch-target flex items-center gap-2 text-xs text-fg-muted`,Le.length>0?`cursor-pointer`:`cursor-not-allowed opacity-50`),children:[(0,B.jsx)(`input`,{type:`checkbox`,"aria-label":t.selectPage,checked:Re,disabled:Le.length===0,className:`size-4 accent-accent`,onChange:e=>{U(t=>{let n=new Set(t);for(let t of Le)e.target.checked?n.add(t):n.delete(t);return n})}}),t.selectPage]})}),(0,B.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:Ie.map(e=>{let n=W(e),r=e.kind===`mobile`?N:C;return(0,B.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`label`,{className:s(`touch-target flex size-10 shrink-0 items-center justify-center`,n===`revoked`?`cursor-not-allowed opacity-40`:`cursor-pointer`),children:(0,B.jsx)(`input`,{type:`checkbox`,checked:H.has(e.id),disabled:n===`revoked`,"aria-label":t.selectDevice.replace(`{{name}}`,e.displayName),className:`size-4 accent-accent`,onChange:t=>{U(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}})}),(0,B.jsxs)(`button`,{type:`button`,className:`touch-target flex min-w-0 flex-1 items-center gap-3 py-3 text-left hover:bg-surface-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>d(e),children:[(0,B.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-inset text-fg-muted`,children:(0,B.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),(0,B.jsx)(we,{status:n,label:t.status[n]})]}),(0,B.jsxs)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:[e.platform,` · `,ce(e.id),` · `,t.lastSeen,`: `,e.lastSeenAt?ke.format(e.lastSeenAt):t.never]})]}),(0,B.jsx)(`span`,{className:`hidden shrink-0 text-right text-xs text-fg-muted sm:block`,children:t.endpointSummary.replace(`{{endpoints}}`,String(e.endpoints.length)).replace(`{{tools}}`,String(ae(e)))}),(0,B.jsx)(O,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})]},e.id)})}),(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String(($-1)*q+1)).replace(`{{to}}`,String(Math.min($*q,Q.length))).replace(`{{total}}`,String(Q.length))}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(p,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:$<=1,onClick:()=>V(e=>Math.max(1,e-1)),children:(0,B.jsx)(S,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(p,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:$>=Fe,onClick:()=>V(e=>Math.min(Fe,e+1)),children:(0,B.jsx)(O,{className:`size-4`,"aria-hidden":!0})})]})]})]})]}),(0,B.jsxs)(I,{id:`activity`,activeTab:c,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.callsTitle,hint:t.callsHint,children:[(0,B.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,B.jsxs)(`label`,{className:`relative block sm:col-span-2 lg:col-span-1`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:t.searchActivity}),(0,B.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,B.jsx)(`input`,{type:`search`,"aria-label":t.searchActivity,value:ue,placeholder:t.searchActivity,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>{G(e.target.value),J(1)}})]}),(0,B.jsx)(a,{value:pe,options:Z.map(e=>({value:e.id,label:`${e.displayName} · ${ce(e.id)}`})),placeholder:t.allDevices,emptyLabel:t.allDevices,ariaLabel:t.deviceLabel,onChange:e=>{me(e),J(1)}}),(0,B.jsx)(a,{value:K,options:[{value:`running`,label:t.status.running},{value:`succeeded`,label:t.status.succeeded},{value:`failed`,label:t.status.failed}],placeholder:t.allStatuses,emptyLabel:t.allStatuses,ariaLabel:t.statusLabel,onChange:e=>{Ce(e),J(1)}}),(0,B.jsx)(a,{value:Te,options:[{value:`read`,label:t.effects.read},{value:`write`,label:t.effects.write},{value:`destructive`,label:t.effects.destructive}],placeholder:t.allEffects,emptyLabel:t.allEffects,ariaLabel:t.effectLabel,onChange:e=>{Ee(e),J(1)}})]}),X.isLoading&&!X.data?(0,B.jsx)(E,{sections:1}):null,Ae.length===0&&!X.isLoading?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingCalls}):null,(0,B.jsx)(`div`,{className:`space-y-2`,children:Ae.map(e=>(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`break-all text-sm font-medium text-fg`,children:e.toolName}),(0,B.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[ke.format(e.startedAt),` · `,t.effects[e.effect],` · `,e.endpointId]}),e.errorMessage?(0,B.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e.errorMessage}):null]}),(0,B.jsx)(we,{status:e.status,label:t.status[e.status]})]},e.id))}),X.data&&X.data.total>0?(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((X.data.page-1)*X.data.pageSize+1)).replace(`{{to}}`,String(Math.min(X.data.page*X.data.pageSize,X.data.total))).replace(`{{total}}`,String(X.data.total))}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(p,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:X.data.page<=1,onClick:()=>J(e=>Math.max(1,e-1)),children:(0,B.jsx)(S,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(p,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:X.data.page>=X.data.totalPages,onClick:()=>J(e=>Math.min(X.data.totalPages,e+1)),children:(0,B.jsx)(O,{className:`size-4`,"aria-hidden":!0})})]})]}):null]}),(0,B.jsx)(le,{device:l,busy:g,onRename:async(e,t)=>{await be(e.id,t,e.settingsRevision??0),d((await Y.mutate())?.find(t=>t.id===e.id)??null)},onClose:()=>d(null),onRevoke:e=>{d(null),y(!1),h([e])}}),(0,B.jsx)(te,{open:m.length>0,title:m.length>1?t.removeManyTitle:t.removeTitle,description:`${m.length>1?t.removeManyDescription.replace(`{{count}}`,String(m.length)):t.removeDescription.replace(`{{name}}`,m[0]?.displayName??``)}${v?`\n\n${t.revokeError}`:``}`,confirmLabel:g?t.revoking:t.removeDevice,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void Ve(),onCancel:()=>{g||h([])}})]})}export{Te as EndpointToolsManagementSettings};
@@ -1 +0,0 @@
1
- import{Ls as e}from"./index-ygkHNYyo.js";export{e as Mermaid};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-BoduwSYI.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-ygkHNYyo.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-DBLcMg5B.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-JogcXC4J.js","assets/messages-RzwPiQNL.js","assets/dist-CI_fqRk-.js","assets/floating-ui.dom-B7uQOZZW.js","assets/chunk-KS7C4IRE-BvcCCgTW.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/app-window-DXFNqt_0.js","assets/check-DUBLcKHA.js","assets/chevron-down-ccbiQQz_.js","assets/popover-select-DGKUpVsz.js","assets/dist-C3DSFZCi.js","assets/skeleton-BI5TyibZ.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/circle-check-C23XjkUj.js","assets/copy-Dv6d4Dvw.js","assets/download-Dk-ZjtO6.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-CABVeTq0.js","assets/file-image-CDUPkZvG.js","assets/folder-open-CyzJ19I9.js","assets/globe-DSSGFWFn.js","assets/loader-circle-CifKLtgG.js","assets/session-manager-B2HDomj4.js","assets/schemas-CObaziC7.js","assets/gateway-realtime-DMAzNlm-.js","assets/gateway-realtime-store-CoIgC1Al.js","assets/local-session-drafts-DvmwiLUx.js","assets/session-api-DTxZyMta.js","assets/gateway-startup-retry-B91CBTzO.js","assets/personal-proactivity-BJcZ3Yhi.js","assets/constants-DeXt1mV-.js","assets/tool-activity-BtJkgjFf.js","assets/registry-api-BGqSwITi.js","assets/attachment-utils-core-BIOUBrpT.js","assets/agents-admin-api-CeBkHnl8.js","assets/gateway-config-swr-DF_HV6NP.js","assets/capabilities-Bpeh6E22.js","assets/local-apps-yys1VChX.js","assets/tasks-TVRjEggr.js","assets/specialists-4bkS5rZ4.js","assets/product-delivery-BqNm-8S5.js","assets/files-Bw4SBGdM.js","assets/button-aIC072nz.js","assets/sliding-indicator-hwz0sx3h.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/electron-env-Dit0bHgy.js","assets/index-BLL0wKRZ.css","assets/vendor-codemirror-Qdcjid65.js","assets/with-selector-aYPsXwdl.js","assets/note-image-lightbox-jvqYtySx.js","assets/block-editor-Cvy3D_4T.css","assets/markdown-editor-phTQ0mox.js","assets/languages-byq_L2Ae.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{l as a,t as o,u as s}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as c}from"./check-DUBLcKHA.js";import{t as l}from"./chevron-down-ccbiQQz_.js";import{n as u,r as d}from"./popover-select-DGKUpVsz.js";import{t as f}from"./circle-check-C23XjkUj.js";import{t as p}from"./copy-Dv6d4Dvw.js";import{t as m}from"./download-Dk-ZjtO6.js";import{t as h}from"./ellipsis-0k4rZLoy.js";import{t as g}from"./external-link-DjqjBmc3.js";import{t as _}from"./eye-CABVeTq0.js";import{t as v}from"./loader-circle-CifKLtgG.js";import{t as y}from"./messages-RzwPiQNL.js";import{t as b}from"./cn-0WouolD0.js";import{f as x,i as S,l as C,n as w,o as T,p as E}from"./locale-store-JogcXC4J.js";import{t as D}from"./session-manager-B2HDomj4.js";import{t as O}from"./copy-to-clipboard-HOJ79TWv.js";import{i as k}from"./vendor-swr-BIWyz7Rc.js";import{t as A}from"./button-aIC072nz.js";import{t as j}from"./skeleton-BI5TyibZ.js";import{a as M,i as N,o as P,s as F}from"./dist-C3DSFZCi.js";import{$t as I,Ai as L,Bc as R,Br as z,Ci as ee,Di as te,Fc as ne,Fl as re,Ha as B,Hr as ie,Ic as ae,Jd as V,Lc as H,Ms as oe,No as se,Ns as ce,Ot as le,Ou as ue,Qn as U,Qt as de,Rc as fe,So as pe,Sr as me,Uu as W,Vc as he,Vr as ge,Wl as _e,Yd as ve,Yl as G,Zn as ye,_d as be,_r as xe,a as Se,aa as Ce,ar as K,br as q,c as J,ca as Y,cn as we,cr as X,d as Te,dn as Ee,dr as De,en as Oe,er as ke,gl as Ae,gr as je,hr as Me,hu as Ne,i as Pe,id as Fe,il as Ie,io as Le,ir as Re,ji as ze,kc as Be,kl as Ve,la as He,ln as Z,lr as Ue,ml as We,na as Ge,nn as Ke,nr as qe,o as Je,oa as Ye,ol as Xe,or as Ze,qc as Qe,rr as $e,s as et,sa as tt,sl as nt,tn as rt,tr as it,u as at,ua as ot,un as st,vl as ct,vr as lt,wi as ut,wl as dt,yr as ft,zc as pt,zr as mt}from"./index-ygkHNYyo.js";import"./note-image-lightbox-jvqYtySx.js";import{t as ht}from"./page-context-capture-button-DO_yhXS1.js";var Q=e(t(),1),gt=n(),$=r(),_t=6e4,vt=36e5,yt=864e5;function bt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function xt(e,t,n){let r=t-e;if(r<_t)return n.justNow;if(r<vt){let e=Math.floor(r/_t);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=bt(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(e>=i-yt)return n.yesterday+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(r<7*yt){let e=Math.floor(r/yt);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(n.locale,{month:`short`,day:`numeric`})}function St(e,t,n){let r=bt(t);if(e>=r)return n.today;if(e>=r-yt)return n.yesterday;let i=new Date(e),a=new Date(t);return i.getFullYear()===a.getFullYear()?i.toLocaleDateString(n.locale,{month:`long`,day:`numeric`}):i.toLocaleDateString(n.locale,{year:`numeric`,month:`long`,day:`numeric`})}function Ct(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function wt(e){let t=(0,gt.c)(45),{title:n,description:r,prompt:i,coverage:a,className:o,variant:c}=e,l=c===void 0?`card`:c,u=w(Dt),d=y(u).automations.suggestions,p=y(u).automations,m=s(),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=h):h=t[0];let{data:g}=k(a?`automation-suggestion-coverage`:null,Et,h),_=a?g?.automations.find(e=>et(e,a)):void 0,v=_?Se(_,p):[];if(l===`titleAction`){if(_){let e;t[1]===o?e=t[2]:(e=b(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,o),t[1]=o,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(f,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let r;return t[4]===m?r=t[5]:(r=()=>m(`/automations`),t[4]=m,t[5]=r),(0,$.jsxs)(`section`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:d.coveredTitle}),(0,$.jsx)(A,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:d.manage})]})}let e;t[6]===o?e=t[7]:(e=b(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,o),t[6]=o,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(ue,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let s;t[9]!==r||t[10]!==n?(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:r,children:n}),t[9]=r,t[10]=n,t[11]=s):s=t[11];let c;t[12]!==m||t[13]!==i?(c=()=>{m(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[12]=m,t[13]=i,t[14]=c):c=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,$.jsxs)(`section`,{className:e,children:[a,s,(0,$.jsxs)(A,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[l,d.setup]})]})}if(_){let e;t[16]===o?e=t[17]:(e=b(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,o),t[16]=o,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let r;t[19]===m?r=t[20]:(r=()=>m(`/automations`),t[19]=m,t[20]=r);let i;return t[21]!==d||t[22]!==r?(i=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsx)(A,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:r,children:d.manage})}),t[21]=d,t[22]=r,t[23]=i):i=t[23],(0,$.jsxs)(`section`,{className:e,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:d.coveredTitle}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:Je(d.coveredDescription,{name:_.name})})]})]}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:p.explain.whyCovered}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:v.map(Tt)})]}),i]})}let x;t[24]===o?x=t[25]:(x=b(`rounded-lg bg-surface-panel p-3 shadow-surface`,o),t[24]=o,t[25]=x);let S;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(ue,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=S):S=t[26];let C;t[27]===n?C=t[28]:(C=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=C);let T;t[29]===r?T=t[30]:(T=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=T);let E;t[31]!==C||t[32]!==T?(E=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[S,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,T]})]}),t[31]=C,t[32]=T,t[33]=E):E=t[33];let D;t[34]!==m||t[35]!==i?(D=()=>{m(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[34]=m,t[35]=i,t[36]=D):D=t[36];let O;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0}),t[37]=O):O=t[37];let j;t[38]!==d.create||t[39]!==D?(j=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(A,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:D,children:[O,d.create]})}),t[38]=d.create,t[39]=D,t[40]=j):j=t[40];let M;return t[41]!==j||t[42]!==x||t[43]!==E?(M=(0,$.jsxs)(`section`,{className:x,children:[E,j]}),t[41]=j,t[42]=x,t[43]=E,t[44]=M):M=t[44],M}function Tt(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function Et(){return J.list()}function Dt(e){return e.language}function Ot(e){let t=(0,gt.c)(93),{detail:n,template:r,onTemplate:i,zh:a,busy:o,processing:s,pageText:c,editing:l,onOrganize:f,onRegenerate:p,onPersonalNotes:g,noteActions:_}=e,[v,y]=(0,Q.useState)(!1),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{y(!1),e()},t[0]=b):b=t[0];let x=b,C=`/api/discussions/${encodeURIComponent(n.discussion.id)}`,w=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,T=a?`更多笔记操作`:`More note actions`,E;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(h,{className:`size-5`,"aria-hidden":!0}),t[1]=E):E=t[1];let D;t[2]===T?D=t[3]:(D=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":T,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:E})}),t[2]=T,t[3]=D);let O=a?`笔记工具`:`Note tools`,k;t[4]!==g||t[5]!==a?(k=g?(0,$.jsxs)(A,{className:`min-h-11 w-full justify-start`,onClick:()=>x(g),children:[(0,$.jsx)(Ae,{className:`size-4`}),a?`添加我的补充`:`Add my notes`]}):null,t[4]=g,t[5]=a,t[6]=k):k=t[6];let j;t[7]!==_||t[8]!==a?(j=_?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(A,{className:`min-h-11 w-full justify-start`,disabled:_.busy,onClick:()=>x(_.onAnalyze),children:[(0,$.jsx)(ct,{className:`size-4`}),a?`进一步分析`:`Analyze this note`]}),(0,$.jsxs)(A,{className:`min-h-11 w-full justify-start`,disabled:_.busy,onClick:()=>x(_.onChat),children:[(0,$.jsx)(Ne,{className:`size-4`}),a?`就这篇笔记提问`:`Ask about this note`]})]}):null,t[7]=_,t[8]=a,t[9]=j):j=t[9];let I=a?`整理笔记`:`Organize notes`,L;t[10]===I?L=t[11]:(L=(0,$.jsx)(`p`,{className:`px-2 text-xs text-fg-muted`,children:I}),t[10]=I,t[11]=L);let R=a?`纪要模板`:`Summary template`,z;t[12]===i?z=t[13]:(z=e=>i(e.target.value),t[12]=i,t[13]=z);let ee=a?`通用会议`:`General`,te;t[14]===ee?te=t[15]:(te=(0,$.jsx)(d,{value:`general`,children:ee}),t[14]=ee,t[15]=te);let ne=a?`项目例会`:`Project`,B;t[16]===ne?B=t[17]:(B=(0,$.jsx)(d,{value:`project`,children:ne}),t[16]=ne,t[17]=B);let ie=a?`需求评审`:`Review`,ae;t[18]===ie?ae=t[19]:(ae=(0,$.jsx)(d,{value:`review`,children:ie}),t[18]=ie,t[19]=ae);let V=a?`客户访谈`:`Interview`,H;t[20]===V?H=t[21]:(H=(0,$.jsx)(d,{value:`interview`,children:V}),t[20]=V,t[21]=H);let oe;t[22]!==R||t[23]!==z||t[24]!==te||t[25]!==B||t[26]!==ae||t[27]!==H||t[28]!==r?(oe=(0,$.jsxs)(u,{value:r,"aria-label":R,onChange:z,children:[te,B,ae,H]}),t[22]=R,t[23]=z,t[24]=te,t[25]=B,t[26]=ae,t[27]=H,t[28]=r,t[29]=oe):oe=t[29];let se=o||s||!n.discussion.canonicalTranscript,ce;t[30]===f?ce=t[31]:(ce=()=>x(f),t[30]=f,t[31]=ce);let le;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(re,{className:`size-4`}),t[32]=le):le=t[32];let ue=a?`重新整理纪要`:`Regenerate summary`,U;t[33]!==se||t[34]!==ce||t[35]!==ue?(U=(0,$.jsxs)(A,{className:`min-h-11 w-full justify-start`,disabled:se,onClick:ce,children:[le,ue]}),t[33]=se,t[34]=ce,t[35]=ue,t[36]=U):U=t[36];let de;t[37]!==w||t[38]!==o||t[39]!==n.discussion.status||t[40]!==p||t[41]!==s||t[42]!==a?(de=w&&[`completed`,`needs_attention`].includes(n.discussion.status)?(0,$.jsx)(A,{className:`min-h-11 w-full justify-start`,disabled:o||s,onClick:()=>x(p),children:a?`从原音重新生成`:`Regenerate from audio`}):null,t[37]=w,t[38]=o,t[39]=n.discussion.status,t[40]=p,t[41]=s,t[42]=a,t[43]=de):de=t[43];let fe;t[44]!==oe||t[45]!==U||t[46]!==de||t[47]!==L?(fe=(0,$.jsxs)(`div`,{className:`space-y-2 py-3`,children:[L,oe,U,de]}),t[44]=oe,t[45]=U,t[46]=de,t[47]=L,t[48]=fe):fe=t[48];let pe=a?`导出与分享`:`Export and share`,me;t[49]===pe?me=t[50]:(me=(0,$.jsx)(`p`,{className:`px-2 text-xs text-fg-muted`,children:pe}),t[49]=pe,t[50]=me);let W;t[51]!==w||t[52]!==C||t[53]!==a?(W=w?(0,$.jsxs)(`a`,{className:`flex min-h-11 items-center gap-2 rounded-lg px-2 text-sm hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,href:S(`${C}/audio`),download:!0,children:[(0,$.jsx)(m,{className:`size-4`}),a?`下载录音`:`Download recording`]}):null,t[51]=w,t[52]=C,t[53]=a,t[54]=W):W=t[54];let he;t[55]!==_||t[56]!==a?(he=_?(0,$.jsx)(A,{className:`min-h-11 w-full justify-start`,disabled:_.busy,onClick:()=>x(_.onShare),children:a?`分享笔记`:`Share note`}):null,t[55]=_,t[56]=a,t[57]=he):he=t[57];let ge;t[58]===C?ge=t[59]:(ge=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`md`,`txt`,`srt`].map(e=>(0,$.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-lg px-3 text-sm text-accent-fg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,href:S(`${C}/export?format=${e}`),download:!0,children:e.toUpperCase()},e))}),t[58]=C,t[59]=ge);let _e=n.note.id,ve=String(n.note.remoteVersion??1),G;t[60]!==n.note.id||t[61]!==ve?(G={kind:`note`,id:_e,revision:ve},t[60]=n.note.id,t[61]=ve,t[62]=G):G=t[62];let ye;t[63]===c?ye=t[64]:(ye={text:c,draft:!1},t[63]=c,t[64]=ye);let be=a?`带到新对话`:`Use in a new chat`,xe=o||s||l||!c||c.length>16e3,Se;t[65]!==G||t[66]!==ye||t[67]!==be||t[68]!==xe?(Se=(0,$.jsx)(ht,{resource:G,selection:ye,label:be,disabled:xe}),t[65]=G,t[66]=ye,t[67]=be,t[68]=xe,t[69]=Se):Se=t[69];let Ce=c.length>16e3?a?`内容较长,请先筛选部分原文。`:`Filter the transcript to share a smaller selection.`:a?`分享当前显示的文字,不包含原音。`:`Shares displayed text, without audio.`,K;t[70]===Ce?K=t[71]:(K=(0,$.jsx)(`p`,{className:`px-2 text-xs leading-5 text-fg-muted`,children:Ce}),t[70]=Ce,t[71]=K);let q;t[72]!==me||t[73]!==W||t[74]!==he||t[75]!==ge||t[76]!==Se||t[77]!==K?(q=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle py-3`,children:[me,W,he,ge,Se,K]}),t[72]=me,t[73]=W,t[74]=he,t[75]=ge,t[76]=Se,t[77]=K,t[78]=q):q=t[78];let J;t[79]!==_||t[80]!==a?(J=_?(0,$.jsxs)(`div`,{className:`space-y-1 border-t border-edge-subtle pt-2`,children:[(0,$.jsx)(A,{className:`min-h-11 w-full justify-start`,onClick:()=>x(_.onHistory),children:a?`版本历史`:`Version history`}),(0,$.jsx)(A,{className:`min-h-11 w-full justify-start text-danger`,disabled:_.busy,onClick:()=>x(_.onDelete),children:a?`删除笔记`:`Delete note`})]}):null,t[79]=_,t[80]=a,t[81]=J):J=t[81];let Y;t[82]!==fe||t[83]!==q||t[84]!==J||t[85]!==O||t[86]!==k||t[87]!==j?(Y=(0,$.jsx)(M,{children:(0,$.jsxs)(N,{align:`end`,sideOffset:6,collisionPadding:12,"aria-label":O,className:`z-[140] max-h-[min(38rem,var(--radix-popover-content-available-height,85dvh))] w-[min(20rem,calc(100vw-2rem))] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-3 text-fg shadow-elevated`,children:[k,j,fe,q,J]})}),t[82]=fe,t[83]=q,t[84]=J,t[85]=O,t[86]=k,t[87]=j,t[88]=Y):Y=t[88];let we;return t[89]!==v||t[90]!==D||t[91]!==Y?(we=(0,$.jsxs)(P,{open:v,onOpenChange:y,children:[D,Y]}),t[89]=v,t[90]=D,t[91]=Y,t[92]=we):we=t[92],we}var kt=e=>`${Math.floor(e/6e4)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function At({id:e,query:t,zh:n,refreshKey:r,sourceKey:i,active:a,tab:o,onEvidence:s,onPlay:c}){let[l,u]=(0,Q.useState)(),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(0),[v,y]=(0,Q.useState)(),[b,x]=(0,Q.useState)(),[C,w]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!a||t)return;let e=window.setInterval(()=>D(e=>e+1),3e3);return()=>window.clearInterval(e)},[a,t]),(0,Q.useEffect)(()=>{x(void 0)},[e,t]),(0,Q.useEffect)(()=>{let n=++_.current,r=new AbortController;f(!0),g(!1),m(``);let a=window.setTimeout(()=>{T(S(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}`),{signal:r.signal}).then(e=>{_.current===n&&(u(e),y(i),w(t))}).catch(e=>{_.current===n&&!r.signal.aborted&&m(String(e))}).finally(()=>{_.current===n&&f(!1)})},t?200:0);return()=>{_.current++,r.abort(),window.clearTimeout(a)}},[e,t,r,i,E]);async function O(){if(!l||h)return;let r=_.current;g(!0);try{let n=await T(S(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}&offset=${l.hits.length}&version=${l.version}`));r===_.current&&u({...n,hits:[...l.hits,...n.hits]})}catch(e){r===_.current&&m(n?`内容已变化,请重新搜索。${String(e)}`:`Content changed; search again. ${String(e)}`)}finally{g(!1)}}function k(e){x(e),(!e.provisional||e.kind===`chapter`)&&e.transcriptRevision!==void 0&&e.segments.length&&s({transcriptRevision:e.transcriptRevision,stale:e.stale,audioAvailable:l?.coverage.audioAvailable??!1,timingVerified:e.segments.some(e=>e.playback.length>0),segments:e.segments})}let M=e=>e.kind===`chapter`?n?`章节`:`Chapter`:e.kind===`annotation`?n?`我的标记`:`My mark`:e.kind===`analysis`?n?`分析`:`Analysis`:n?`原文`:`Transcript`,N=e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-xl bg-surface-inset p-4`,children:[(0,$.jsxs)(`button`,{className:`text-left text-sm text-accent-fg`,onClick:()=>k(e),children:[e.startedAtMs===void 0?``:`${kt(e.startedAtMs)}${e.endedAtMs===void 0?``:`–${kt(e.endedAtMs)}`} · `,e.title||M(e)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm`,children:e.kind===`chapter`&&!t&&e.text.length>300?`${e.text.slice(0,300)}…`:e.text}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[M(e),e.provisional?n?` · 阶段性结果`:` · Partial result`:``,e.stale?n?` · 原文已更新,保留旧版依据`:` · Earlier transcript revision`:``,e.kind===`chapter`?` · ${e.highlightCount??0} ${n?`个重点`:`marks`} · ${e.actionCount??0} ${n?`个候选行动`:`candidate actions`}`:``]}),e.kind!==`chapter`||t||b?.id===e.id?e.segments.map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[kt(e.startedAtMs),` · `,e.text.length>500?`${e.text.slice(0,500)}…`:e.text]},`${e.sequence}:${e.startedAtMs}`)):null,e.playback.slice(0,3).map((e,t)=>(0,$.jsxs)(A,{onClick:()=>c(e.startedAtMs,e.endedAtMs),children:[n?`回听上下文`:`Play context`,` `,kt(e.startedAtMs),`–`,kt(e.endedAtMs)]},t)),e.segments.length?(0,$.jsx)(A,{onClick:()=>k(e),children:n?`查看对应原文`:`View transcript`}):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`暂无可核实的原文定位`:`No verified transcript reference`})]},e.id);return(0,$.jsxs)(`section`,{"aria-label":n?`长录音回顾`:`Recording review`,className:`flex flex-col gap-3`,children:[p?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p}),(0,$.jsx)(A,{onClick:()=>D(e=>e+1),children:n?`刷新结果`:`Refresh results`})]}):null,d&&(!l||v!==i||C!==t)?(0,$.jsx)(j,{className:`h-20 w-full`}):null,l&&v===i&&(!t||C===t)?(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`搜索结果 · ${l.total}`:`Search results · ${l.total}`}),(0,$.jsx)(A,{onClick:()=>D(e=>e+1),children:n?`刷新结果`:`Refresh results`}),(0,$.jsx)(`div`,{"aria-label":n?`命中位置`:`Match positions`,className:`relative my-3 h-5 rounded bg-surface-inset`,children:l.hits.filter(e=>e.startedAtMs!==void 0).map(e=>(0,$.jsx)(`button`,{className:`absolute top-0 h-5 w-1.5 rounded bg-accent`,style:{left:`${Math.min(99,100*e.startedAtMs/Math.max(1,l.coverage.durationMs))}%`},"aria-label":`${kt(e.startedAtMs)} ${e.title||M(e)}`,onClick:()=>k(e)},e.id))}),l.total?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`未找到关键词;尚未转写的内容无法搜索。`:`No matches. Untranscribed audio is not searchable yet.`}),l.hits.map(N)]}):(0,$.jsxs)($.Fragment,{children:[o===`summary`&&l.chapters.length?(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-inset px-4`,children:[(0,$.jsxs)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-sm font-medium focus-visible:ring-2 focus-visible:ring-accent`,children:[n?`章节目录`:`Chapters`,` · `,l.chapters.length]}),(0,$.jsx)(`div`,{className:`space-y-3 pb-4`,children:l.chapters.map(N)})]}):null,l.hits.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`本轮已完成转写(阶段性)`:`Available transcription from this run`}),l.hits.map(N)]}):null]}),l.hasMore?(0,$.jsx)(A,{disabled:h,onClick:()=>void O(),children:n?`加载更多结果`:`More results`}):null,(0,$.jsxs)(`details`,{className:`rounded-lg text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 focus-visible:ring-2 focus-visible:ring-accent`,children:n?`处理范围`:`Processing coverage`}),(0,$.jsxs)(`div`,{role:`status`,className:`space-y-2 pb-3 leading-5`,children:[(0,$.jsxs)(`p`,{children:[n?`原音`:`Audio`,` · `,l.coverage.audioAvailable?n?`已保存,可回听`:`Saved, ready to play`:n?`尚不可用`:`Unavailable`]}),(0,$.jsxs)(`p`,{children:[n?`本轮转写已处理`:`Processed this run`,` `,kt(l.coverage.processedMs),` / `,kt(l.coverage.durationMs),` · `,n?`连续处理至`:`Continuous through`,` `,kt(l.coverage.continuousThroughMs)]}),(0,$.jsxs)(`p`,{children:[n?`分析覆盖`:`Analysis coverage`,` · `,l.coverage.analysisRanges.length?l.coverage.analysisRanges.map(e=>`${kt(e.startedAtMs)}–${kt(e.endedAtMs)}`).join(`、`):n?`暂无本版已完成章节`:`No completed chapters for this revision`,l.coverage.analysisStale?n?`;已发布分析基于旧版原文`:`; published analysis uses an earlier transcript`:``,` · `,l.coverage.complete?n?`本轮处理完成`:`Run complete`:n?`阶段性内容,其余仍待处理`:`Partial content; remaining work pending`]})]})]}),b?.provisional?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`以上是本轮已保存的阶段性原文;正式发布后才能校对和标记具体段落。`:`Saved partial text; segment editing and highlighting become available after publication.`}):null]}):null]})}function jt({recordingId:e,discussionId:t,zh:n,onEvidence:r,onPlay:i}){let{data:a=[],mutate:o}=k(`/api/discussions/${t}/annotations`,e=>T(S(e))),[s,c]=(0,Q.useState)([]),[l,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),_=(0,Q.useCallback)(async()=>{c(await Oe(e))},[e]),v=(0,Q.useCallback)(async()=>{try{await de(e,t),await _(),await o()}catch(e){await o(),g(e instanceof Error?e.message:String(e))}},[e,t,_,o]);(0,Q.useEffect)(()=>{_().catch(e=>g(String(e))),v();let e=()=>{_().catch(e=>g(String(e)))};window.addEventListener(`discussion-annotations-changed`,e),window.addEventListener(`online`,v);let t=window.setInterval(()=>{navigator.onLine&&v()},15e3);return()=>{window.removeEventListener(`discussion-annotations-changed`,e),window.removeEventListener(`online`,v),window.clearInterval(t)}},[_,v]);let y=new Map(a.map(e=>[e.annotation.id,{...e,localState:`synced`}]));for(let e of s)if(e.state!==`synced`||!y.has(e.annotation.id)){let t=y.get(e.annotation.id);y.set(e.annotation.id,{annotation:e.annotation,state:t?.state??`pending`,playback:t?.playback??[],evidence:t?.evidence,localState:e.state})}let b=async(t,n=s.find(e=>e.annotation.id===t.id)?.nonce??null)=>{try{await Ke(e,{...t,updatedAt:Date.now()},n),m(null),g(``),await _(),v()}catch(e){g(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n?`我的标记`:`My highlights`,children:[h?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[h,(0,$.jsx)(A,{onClick:()=>void v(),children:n?`重试同步`:`Retry sync`})]}):null,y.size?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`录音时标重点,或在原文中标记整段。标记先保存在本机。`:`Highlight while recording or mark a transcript segment. Highlights save locally first.`}),[...y.values()].sort((e,t)=>e.annotation.anchor.capturedAt-t.annotation.anchor.capturedAt).filter(e=>!e.annotation.deleted||e.localState===`conflict`).map(e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.annotation.kind===`highlight`?n?`重点`:`Highlight`:e.annotation.kind===`question`?n?`问题`:`Question`:n?`我的补充`:`My note`,` · `,new Date(e.annotation.anchor.capturedAt).toLocaleString(),` · `,e.localState===`synced`?n?`已同步`:`Synced`:e.localState===`conflict`?n?`同步冲突,保留了本机修改`:`Conflict; local edits retained`:n?`本机已保存,待同步`:`Saved locally; sync pending`]}),e.evidence?.segments.map(e=>(0,$.jsx)(`blockquote`,{className:`text-sm`,children:e.text},e.sequence)),e.positionMs===void 0?null:(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n?`标记位置`:`Marked position`,` · `,Math.floor(e.positionMs/6e4),`:`,String(Math.floor(e.positionMs/1e3)%60).padStart(2,`0`)]}),e.annotation.text?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm`,children:[n?`我的说明:`:`My context: `,e.annotation.text]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(A,{disabled:!e.evidence,onClick:()=>e.evidence&&r(e.evidence),children:n?`查看原文`:`View transcript`}),e.playback.map((e,t)=>(0,$.jsxs)(A,{onClick:()=>i(e),children:[n?`回听`:`Play`,` `,Math.floor(e.startedAtMs/6e4),`:`,String(Math.floor(e.startedAtMs/1e3)%60).padStart(2,`0`)]},t)),(0,$.jsx)(A,{onClick:()=>{f(s.find(t=>t.annotation.id===e.annotation.id)?.nonce??null),m({...e.annotation,revision:a.find(t=>t.annotation.id===e.annotation.id)?.annotation.revision??e.annotation.revision})},children:e.localState===`conflict`?n?`合并修改`:`Merge changes`:n?`添加说明/类型`:`Edit context/type`}),(0,$.jsx)(A,{onClick:()=>void b({...e.annotation,deleted:!0}),children:n?`移除标记`:`Remove`})]}),e.state===`located`&&!e.evidence?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原文尚未生成,可先回听原音。`:`Transcript for this position is pending; audio is usable.`}):null,e.state===`unavailable`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原音未保存、已删除或时间尚无法核实;保留原始标记,不自动移动。`:`Audio at this position is missing, deleted or unverified. The original anchor has been retained.`}):e.state===`pending`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`等待原音/原文完成定位`:`Awaiting audio/transcript positioning`}):null,e.localState===`conflict`?(0,$.jsx)(A,{onClick:()=>{let t=s.find(t=>t.annotation.id===e.annotation.id),n=a.find(t=>t.annotation.id===e.annotation.id);t&&n&&I(t,n.annotation).then(_)},children:n?`使用服务端版本`:`Use server version`}):null]},e.annotation.id)),p?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":n?`编辑标记`:`Edit highlight`,className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(u,{value:p.kind,"aria-label":n?`标记类型`:`Highlight type`,onChange:e=>m({...p,kind:e.target.value}),children:[(0,$.jsx)(d,{value:`highlight`,children:n?`重点`:`Highlight`}),(0,$.jsx)(d,{value:`question`,children:n?`问题`:`Question`}),(0,$.jsx)(d,{value:`note`,children:n?`补充`:`Context`})]}),(0,$.jsx)(`textarea`,{"aria-label":n?`我的说明`:`My context`,maxLength:4e3,value:p.text,onChange:e=>m({...p,text:e.target.value}),className:`my-2 min-h-24 w-full rounded border border-edge bg-surface-inset p-2`}),(0,$.jsx)(A,{onClick:()=>void b(p,l),children:n?`保存到本机并同步`:`Save locally and sync`}),(0,$.jsx)(A,{onClick:()=>m(null),children:n?`取消`:`Cancel`})]}):null]})}var Mt={tab:`summary`,query:``,page:1,positionMs:0},Nt=E((e,t)=>({notes:{},update:(n,r)=>{let i={...Ft(n,t().notes[n]),...r};e(e=>({notes:{...e.notes,[n]:i}}));try{localStorage.setItem(`discussion-review:${n}`,JSON.stringify(i))}catch{}}})),Pt=new Map;function Ft(e,t){if(t)return t;if(Pt.has(e))return Pt.get(e);let n=Mt;try{let t=JSON.parse(localStorage.getItem(`discussion-review:${e}`)??`null`);t&&[`summary`,`transcript`,`marks`].includes(t.tab)&&typeof t.query==`string`&&Number.isSafeInteger(t.page)&&t.page>0&&t.page<=1e4&&Number.isFinite(t.positionMs)&&t.positionMs>=0&&(n={...Mt,...t})}catch{}return Pt.set(e,n),n}function It(e){let t=(0,gt.c)(51),{initial:n,zh:r,busy:i,onClose:a,onSave:o}=e,[s,c]=(0,Q.useState)(n),l;t[0]!==i||t[1]!==a?(l=e=>{!e&&!i&&a()},t[0]=i,t[1]=a,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(pt,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[3]=u):u=t[3];let d=r?`编辑纪要内容`:`Edit meeting content`,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`header`,{className:`border-b border-edge p-4`,children:(0,$.jsx)(he,{children:d})}),t[4]=d,t[5]=f);let p=r?`人工修改会保留,重新整理不会覆盖。已创建任务保持不变。`:`Your changes survive regeneration. Existing tasks remain unchanged.`,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[6]=p,t[7]=m);let h=r?`内容`:`Content`,g;t[8]===s?g=t[9]:(g=e=>c({...s,text:e.target.value}),t[8]=s,t[9]=g);let _;t[10]!==s.text||t[11]!==g?(_=(0,$.jsx)(`textarea`,{className:`mt-1 min-h-32 w-full rounded border border-edge bg-transparent p-2`,value:s.text,onChange:g}),t[10]=s.text,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==h||t[14]!==_?(v=(0,$.jsxs)(`label`,{className:`block text-sm`,children:[h,_]}),t[13]=h,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==s||t[17]!==r?(y=s.kind===`actionItems`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`负责人原话`:`Owner as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.owner??``,onChange:e=>c({...s,owner:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`期限原话`:`Date as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.dueDate??``,onChange:e=>c({...s,dueDate:e.target.value})})]})]}):null,t[16]=s,t[17]=r,t[18]=y):y=t[18];let b;t[19]!==s||t[20]!==r?(b=s.kind===`summary`?null:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!s.ignored,onChange:e=>c({...s,ignored:e.target.checked})}),r?`忽略此项`:`Ignore this item`]}),t[19]=s,t[20]=r,t[21]=b):b=t[21];let x;t[22]!==v||t[23]!==y||t[24]!==b||t[25]!==m?(x=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[m,v,y,b]}),t[22]=v,t[23]=y,t[24]=b,t[25]=m,t[26]=x):x=t[26];let S=r?`取消`:`Cancel`,C;t[27]!==i||t[28]!==a||t[29]!==S?(C=(0,$.jsx)(A,{disabled:i,onClick:a,children:S}),t[27]=i,t[28]=a,t[29]=S,t[30]=C):C=t[30];let w;t[31]!==i||t[32]!==s.text?(w=i||!s.text.trim(),t[31]=i,t[32]=s.text,t[33]=w):w=t[33];let T;t[34]!==s||t[35]!==o?(T=()=>void o(s),t[34]=s,t[35]=o,t[36]=T):T=t[36];let E=r?`保存修改`:`Save changes`,D;t[37]!==w||t[38]!==T||t[39]!==E?(D=(0,$.jsx)(A,{variant:`primary`,disabled:w,onClick:T,children:E}),t[37]=w,t[38]=T,t[39]=E,t[40]=D):D=t[40];let O;t[41]!==C||t[42]!==D?(O=(0,$.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge p-3`,children:[C,D]}),t[41]=C,t[42]=D,t[43]=O):O=t[43];let k;t[44]!==x||t[45]!==O||t[46]!==f?(k=(0,$.jsxs)(R,{children:[u,(0,$.jsxs)(H,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(32rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[f,x,O]})]}),t[44]=x,t[45]=O,t[46]=f,t[47]=k):k=t[47];let j;return t[48]!==l||t[49]!==k?(j=(0,$.jsx)(ne,{open:!0,onOpenChange:l,children:k}),t[48]=l,t[49]=k,t[50]=j):j=t[50],j}function Lt(e,t,n){if(t===`summary`){let r=e.organization;if(!r)return``;let i=r.organization;if(!i)return``;let a=e=>e.filter(e=>n.showIgnored||!e.ignored);return JSON.stringify({discussionId:e.discussion.id,view:t,revision:r.revision,transcriptRevision:r.transcriptRevision,summary:i.summary,decisions:a(i.decisions),actionItems:a(i.actionItems),risks:a(i.risks),openQuestions:a(i.openQuestions),chapters:i.chapters},null,2)}let r=n.query.toLocaleLowerCase(),i=e.transcript.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(r)||e.speakerLabel?.toLocaleLowerCase().includes(r)).slice(0,n.page*50);return i.length?JSON.stringify({discussionId:e.discussion.id,view:t,revision:e.transcript.revision,scope:`loaded filtered segments only`,segments:i.map(e=>({sequence:e.sequence,startedAtMs:e.startedAtMs,speaker:e.speakerLabel,text:e.displayText??e.rawText??``}))},null,2):``}var Rt=e=>`${String(Math.floor(e/6e4)).padStart(2,`0`)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function zt({noteId:e,onPersonalNotes:t,noteActions:n}){let r=a(),i=w(e=>e.language)===`zh`,{data:s,mutate:l,isLoading:u}=k([`note-discussion-document`,e],()=>we(e),{refreshInterval:e=>e&&([`recording`,`stopping`,`sealing`,`organizing`].includes(e.discussion.status)||e.recordingJob?.state===`queued`||e.recordingJob?.state===`running`)?3e3:0}),d=s?.discussion.id,f=`/api/discussions/${encodeURIComponent(d??``)}`,{data:p=[],mutate:m}=k(d?`${f}/actions`:null,e=>T(S(e)),{refreshInterval:1e4}),h=Nt(t=>Ft(e,t.notes[e])),g=Nt(e=>e.update),_=h.tab,v=t=>g(e,{tab:t}),y=h.query,b=t=>g(e,{query:t}),[x,C]=(0,Q.useState)(!1),E=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{x&&E.current?.focus()},[x]);let[D,O]=(0,Q.useState)(`general`),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[z,ee]=(0,Q.useState)(!1),[te,re]=(0,Q.useState)([]),[ie,ae]=(0,Q.useState)(null),[V,oe]=(0,Q.useState)(!1),se=h.page,ce=t=>g(e,{page:t}),le=(0,Q.useRef)(null),[ue,U]=(0,Q.useState)([]),fe=(0,Q.useRef)(0),pe=(0,Q.useRef)(0),me=(0,Q.useRef)(s?.transcript.revision);me.current=s?.transcript.revision;let W=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),[,ve]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{l(),m()};return window.addEventListener(`discussion-updated`,e),window.addEventListener(`discussion-segment-updated`,e),()=>{window.removeEventListener(`discussion-updated`,e),window.removeEventListener(`discussion-segment-updated`,e)}},[l,m]),(0,Q.useEffect)(()=>{s?.discussion.template&&O(s.discussion.template)},[s?.discussion.template]);async function G(e){if(!V){oe(!0),ae(null);try{await e(),await l(),await m()}catch(e){ae(e instanceof Error?e.message:String(e))}finally{oe(!1)}}}function ye(e,t){W.current&&(le.current=t??null,W.current.readyState===0?(ge.current=e/1e3,W.current.load()):(W.current.currentTime=e/1e3,W.current.play().catch(()=>void 0)))}function be(e){let t=e.stale||e.transcriptRevision!==me.current;N({...e,stale:t}),t||U(e.segments.map(e=>e.sequence))}async function xe(e,t,n=!1){if(!s)return;let r=fe.current,i=++pe.current;await G(async()=>{let a=await T(S(`${f}/evidence?revision=${t??s.organization?.transcriptRevision??s.transcript.revision}&segments=${e.join(`,`)}`));if(!(r!==fe.current||i!==pe.current)&&(be(a),n&&a.segments[0]?.playback[0])){let e=a.segments[0].playback[0];ye(e.startedAtMs,e.endedAtMs)}})}async function Se(e){s&&await G(async()=>{await Ke(s.discussion.clientRequestId,rt({type:`transcript`,capturedAt:Date.now(),transcriptRevision:s.transcript.revision,segmentIds:[e.sequence]})),v(`marks`),de(s.discussion.clientRequestId,s.discussion.id).catch(e=>ae(String(e)))})}(0,Q.useEffect)(()=>(fe.current++,N(null),U([]),F(null),L(null),re([]),ae(null),le.current=null,()=>{fe.current++}),[e]),(0,Q.useEffect)(()=>{let t=s?.discussion.audioSha256??s?.discussion.audioAttachmentId;if(!t)return;let n=Ft(e,Nt.getState().notes[e]);n.source&&n.source!==t?(fe.current++,N(null),U([]),W.current?.pause(),g(e,{positionMs:0,source:t}),ge.current=0,le.current=null):g(e,{source:t})},[e,s?.discussion.audioSha256,s?.discussion.audioAttachmentId,g]),(0,Q.useEffect)(()=>{s?.discussion.audioDeletedAt&&(W.current?.pause(),ge.current=null,le.current=null,N(e=>e?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:null))},[s?.discussion.audioDeletedAt]),(0,Q.useEffect)(()=>{h.tab===`transcript`&&h.anchor!==void 0&&h.anchorRevision===s?.transcript.revision&&window.setTimeout(()=>document.getElementById(`discussion-segment-${h.anchor}`)?.scrollIntoView?.({block:`center`}),0)},[h.tab,h.anchor,h.anchorRevision,s?.transcript.revision]),(0,Q.useEffect)(()=>{U([]),N(e=>e&&e.transcriptRevision!==s?.transcript.revision?{...e,stale:!0}:e)},[s?.transcript.revision]);let Ce=(e,t,n)=>t.some(e=>z||!e.ignored)?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-fg`,children:e}),t.filter(e=>z||!e.ignored).map(e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`flex-1 whitespace-pre-wrap`,children:[e.text,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?`有后续变更`:`Later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:V,onClick:()=>L({kind:n,itemId:e.id,text:e.text,ignored:e.ignored}),children:i?`编辑`:`Edit`}),e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:V,className:`shrink-0 text-accent-fg`,onClick:()=>void xe(e.evidenceSegmentIds,e.evidenceRevision),children:i?`原话`:`Source`}):(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无定位`:`No source timing`})]},e.id))]}):null;if(u)return(0,$.jsx)(j,{className:`h-48 w-full`});if(!s)return null;let{discussion:K,transcript:q,organization:J}=s,Y=J?.organization,X=[`stopping`,`sealing`,`organizing`].includes(K.status),Te=[`recording`,`completed`,`needs_attention`].includes(K.status),De=q.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(y.toLocaleLowerCase())||e.speakerLabel?.toLocaleLowerCase().includes(y.toLocaleLowerCase())),Oe=_===`marks`||y.trim()?``:Lt(s,_,{query:y,page:se,showIgnored:z});return(0,$.jsxs)(`section`,{className:`relative flex h-full min-h-0 w-full flex-col text-fg`,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),C(!0))},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 px-5 pb-3 pt-5 sm:px-7`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-xl font-semibold leading-snug tracking-tight`,children:!s.note.title||/^Discussion · \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(s.note.title)?i?`语音笔记`:`Voice note`:s.note.title}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[i?`录音`:`Recording`,` · `,Rt(K.durationMs??0)]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":i?`搜索此 Note`:`Search this Note`,"aria-expanded":x||!!y,onClick:()=>{C(e=>!e),x&&b(``)},className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(Ve,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(Ot,{noteActions:n,detail:s,template:D,onTemplate:O,zh:i,busy:V,processing:X,pageText:Oe,editing:!!I||!!P,onPersonalNotes:t,onOrganize:()=>void G(()=>T(S(`${f}/organize`),{method:`POST`,body:JSON.stringify({template:D})})),onRegenerate:()=>void G(()=>Z(K.id,`from_audio`))})]}),(0,$.jsx)(B,{as:`nav`,"aria-label":i?`笔记内容`:`Note content`,className:`mx-5 mb-2 flex shrink-0 gap-1 rounded-xl bg-surface-inset p-1 sm:mx-7`,indicatorClassName:`rounded-lg bg-surface-panel shadow-sm`,children:[`summary`,`transcript`,`marks`].map(e=>(0,$.jsx)(`button`,{"aria-pressed":_===e,className:`min-h-11 min-w-0 flex-1 rounded-lg px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${_===e?`bg-surface-panel font-medium text-fg shadow-sm`:`text-fg-muted hover:text-fg`}`,onClick:()=>v(e),children:e===`summary`?i?`概览`:`Overview`:e===`marks`?i?`标记`:`Highlights`:i?`原文`:`Transcript`},e))}),ie?(0,$.jsxs)(`details`,{role:`alert`,className:`px-4 py-2 text-sm text-danger`,children:[(0,$.jsx)(`summary`,{children:i?`操作未完成,可以稍后重试`:`Action incomplete. Try again later`}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs text-fg-muted`,children:ie})]}):null,x||y?(0,$.jsxs)(`label`,{className:`mx-5 mb-2 flex shrink-0 items-center gap-2 rounded-xl bg-surface-inset px-3 sm:mx-7`,children:[(0,$.jsx)(Ve,{className:`size-4 text-fg-muted`}),(0,$.jsx)(`input`,{ref:E,"aria-label":i?`搜索此 Note`:`Search this Note`,className:`min-h-11 min-w-0 w-full bg-transparent text-sm outline-none`,maxLength:200,placeholder:i?`搜索这篇笔记`:`Search this note`,value:y,onChange:e=>{b(e.target.value),ce(1)}}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i?`关闭搜索`:`Close search`,onClick:()=>{b(``),C(!1)},children:(0,$.jsx)(Qe,{className:`size-4`})})]}):null,(0,$.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-5 pb-6 pt-1 sm:px-7`,children:[K.status!==`recording`||s.recordingJob?(0,$.jsx)(st,{context:`note`,input:Ee(s),zh:i,busy:V,onRetry:e=>void G(()=>e===`analyze`?T(S(`${f}/organize`),{method:`POST`,body:JSON.stringify({template:D})}):Z(K.id,e===`regenerate`?`from_audio`:`resume`))}):null,(0,$.jsx)(`div`,{hidden:!!y.trim(),children:_===`marks`?(0,$.jsx)(jt,{recordingId:K.clientRequestId,discussionId:K.id,zh:i,onEvidence:be,onPlay:e=>ye(e.startedAtMs,e.endedAtMs)},K.id):_===`summary`?Y?(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:i?`摘要`:`Summary`}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":i?`编辑概要`:`Edit overview`,title:i?`编辑概要`:`Edit overview`,disabled:V||X,onClick:()=>L({kind:`summary`,itemId:`summary`,text:Y.summary}),children:(0,$.jsx)(Ae,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7`,children:Y.summary}),Y.summaryEditedByUser?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`已由你编辑`:`Edited by you`}):null,Y.summaryEvidenceSegmentIds?.length?Array.from({length:Math.ceil(Y.summaryEvidenceSegmentIds.length/100)},(e,t)=>(0,$.jsxs)(A,{onClick:()=>void xe(Y.summaryEvidenceSegmentIds.slice(t*100,(t+1)*100)),children:[i?`查看原话`:`View source`,Y.summaryEvidenceSegmentIds.length>100?` · ${t+1}`:``]},t)):null,Y.keyPointEvidence?.length?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{children:i?`重点结论`:`Key points`}),Y.keyPointEvidence.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1`,children:e.text}),(0,$.jsx)(A,{onClick:()=>void xe(e.evidenceSegmentIds,e.evidenceRevision),children:i?`原话`:`Source`})]},e.id))]}):Y.keyPoints.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:i?`重点结论`:`Key points`}),(0,$.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-[15px] leading-7`,children:Y.keyPoints.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}:${e}`))})]}):null,[...Y.decisions,...Y.actionItems,...Y.risks,...Y.openQuestions].some(e=>e.ignored)?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:z,onChange:e=>ee(e.target.checked)}),i?`显示已忽略项`:`Show ignored items`]}):null,te.length?(0,$.jsx)(A,{disabled:V,onClick:()=>void G(async()=>{for(let e of te)await T(S(`${f}/actions/${encodeURIComponent(e)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:J.revision})});re([])}),children:i?`加入所选 ${te.length} 项任务`:`Add ${te.length} selected tasks`}):null,Ce(i?`已决定事项`:`Decisions`,Y.decisions,`decisions`),Y.actionItems.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:i?`下一步行动`:`Next actions`}),Y.actionItems.filter(e=>z||!e.ignored).map(e=>{let t=p.find(t=>t.actionId===e.id);return(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge-subtle p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!t&&!e.ignored&&(!(e.supersededBy||e.disputedBy)||e.reviewedChangeId===(e.supersededBy??e.disputedBy))?(0,$.jsx)(`input`,{type:`checkbox`,"aria-label":`${i?`选择行动`:`Select action`}: ${e.title}`,className:`ui-checkbox`,checked:te.includes(e.id),onChange:t=>re(t.target.checked?[...te,e.id]:te.filter(t=>t!==e.id))}):null,(0,$.jsxs)(`p`,{className:`flex-1 text-sm font-medium`,children:[e.title,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?`有后续变更,请复核`:`Review later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:i?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:V||X,onClick:()=>L({kind:`actionItems`,itemId:e.id,text:e.title,owner:e.owner,dueDate:e.dueDate,ignored:e.ignored}),children:i?`编辑`:`Edit`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e.owner??(i?`负责人未明确`:`Owner unspecified`),` · `,e.dueDate??(i?`期限未明确`:`Date unspecified`)]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-xs`,children:[e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:V,className:`text-accent-fg`,onClick:()=>void xe(e.evidenceSegmentIds,e.evidenceRevision),children:i?`查看原话`:`Source`}):null,t?t.deleted?(0,$.jsx)(`span`,{children:i?`关联任务已删除`:`Linked task deleted`}):(0,$.jsx)(o,{className:`text-accent-fg`,to:Be(`${r.pathname}${r.search}`,t.taskId),children:t.resolution===`done`?i?`已完成 · 查看任务`:`Done · View task`:i?`查看任务 / 交给助手`:`View task / Delegate`}):e.ignored?null:(0,$.jsx)(A,{disabled:V||!!(e.supersededBy||e.disputedBy)&&e.reviewedChangeId!==(e.supersededBy??e.disputedBy),onClick:()=>void G(()=>T(S(`${f}/actions/${encodeURIComponent(e.id)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:J.revision})})),children:i?`加入我的任务`:`Add to my tasks`})]})]},e.id)})]}):null,Ce(i?`风险`:`Risks`,Y.risks,`risks`),Ce(i?`尚未确定`:`Open questions`,Y.openQuestions,`openQuestions`),Y.changes?.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:i?`前后变更`:`Changes during the meeting`}),Y.changes.map(e=>{let t=[...Y.decisions,...Y.actionItems,...Y.risks,...Y.openQuestions],n=t.find(t=>t.id===e.fromId),r=t.find(t=>t.id===e.toId);return!n||!r?null:(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.relation===`supersedes`?i?`后续撤销或替代`:`Later superseded`:i?`存在冲突,尚未明确解决`:`Unresolved conflict`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void xe(n.evidenceSegmentIds,n.evidenceRevision),children:`title`in n?n.title:n.text}),(0,$.jsx)(`span`,{children:`↓`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void xe(r.evidenceSegmentIds,r.evidenceRevision),children:`title`in r?r.title:r.text})]},`${e.fromId}:${e.toId}`)})]}):null]}):(0,$.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4 py-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:q.text?i?`录音摘录`:`From your recording`:i?`笔记正在整理`:`Preparing your note`}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7 ${q.text?`text-fg`:`text-fg-muted`}`,children:q.text?q.text.slice(0,400)+(q.text.length>400?`…`:``):i?`文字整理完成后,重点和行动会出现在这里。`:`Highlights and actions will appear as processing completes.`}),q.text?(0,$.jsx)(A,{className:`min-h-11`,onClick:()=>v(`transcript`),children:i?`查看原文`:`Read transcript`}):null]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[De.slice(0,se*50).map(e=>(0,$.jsxs)(`article`,{id:`discussion-segment-${e.sequence}`,className:`rounded-md border p-3 ${ue.includes(e.sequence)||h.anchor===e.sequence&&h.anchorRevision===q.revision?`border-accent`:`border-edge-subtle`}`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 text-xs text-fg-muted`,children:[(0,$.jsxs)(`button`,{className:`inline-flex items-center gap-1 text-accent-fg`,disabled:!K.audioAttachmentId||!!K.audioDeletedAt,onClick:()=>void xe([e.sequence],q.revision,!0),children:[(0,$.jsx)(_e,{className:`size-3`}),Rt(e.startedAtMs)]}),e.status===`confirmed`?(0,$.jsx)(`button`,{onClick:()=>void Se(e),children:i?`标记此段`:`Highlight segment`}):null,(0,$.jsx)(`span`,{children:e.speakerLabel??(i?`未区分说话人`:`Speaker unknown`)}),Te&&e.status===`confirmed`?(0,$.jsx)(`button`,{className:`ml-auto`,onClick:()=>F({segment:e,text:e.displayText??e.rawText??``,speaker:e.speakerLabel??``}),children:i?`校对`:`Edit`}):null]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6`,children:e.displayText??e.rawText??(i?`等待转写`:`Awaiting transcription`)})]},e.sequence)),De.length>se*50?(0,$.jsx)(A,{onClick:()=>ce(se+1),children:i?`加载更多`:`More`}):null]})}),(0,$.jsx)(`div`,{children:(0,$.jsx)(At,{id:K.id,query:y.trim(),zh:i,sourceKey:`${K.audioSha256}:${K.audioDeletedAt}`,active:X||K.status===`recording`,tab:_,refreshKey:`${K.updatedAt}:${q.revision}:${J?.revision}`,onEvidence:be,onPlay:ye},K.id)})]}),K.audioAttachmentId&&!K.audioDeletedAt?(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(`audio`,{ref:W,controls:!0,preload:`metadata`,className:`h-10 w-full`,src:S(`${f}/audio`),onTimeUpdate:()=>{let t=(W.current?.currentTime??0)*1e3;ve(t),g(e,{positionMs:t}),le.current!==null&&t>=le.current&&(W.current?.pause(),le.current=null)},onLoadedMetadata:()=>{ge.current!==null&&W.current?(W.current.currentTime=ge.current,ge.current=null,W.current.play().catch(()=>void 0)):W.current&&(W.current.currentTime=h.positionMs/1e3)},onError:()=>ae(i?`录音暂不可播放`:`Recording unavailable`)})}):null,M?(0,$.jsxs)(`aside`,{"aria-label":i?`原话证据`:`Source evidence`,className:`absolute inset-y-0 right-0 z-10 flex w-[min(26rem,100%)] flex-col border-l border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,$.jsxs)(`h3`,{children:[i?`原话证据`:`Source evidence`,` · v`,M.transcriptRevision]}),(0,$.jsx)(`button`,{"aria-label":i?`关闭`:`Close`,onClick:()=>N(null),children:(0,$.jsx)(Qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`按整段定位,不代表词句级时间。`:`Segment timing; not word-level alignment.`}),M.stale?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`原文已更新,以下保留当时版本的依据。`:`Transcript updated; showing the original evidence revision.`}):null,!M.audioAvailable||!M.timingVerified?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`原文仍可查看;原音不可用或时间定位待核实。`:`Text remains available; audio is missing or timing is unverified.`}):null,M.segments.map(t=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Rt(t.startedAtMs),`–`,Rt(t.endedAtMs),` · `,t.speakerLabel??(i?`说话人未明确`:`Unknown speaker`)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-7`,children:t.text}),t.playback.map((e,t)=>(0,$.jsxs)(A,{onClick:()=>ye(e.startedAtMs,e.endedAtMs),children:[i?`播放原话`:`Play source`,` `,Rt(e.startedAtMs),`–`,Rt(e.endedAtMs)]},t)),M.stale?null:(0,$.jsx)(A,{onClick:()=>{b(``),ce(Math.max(se,Math.ceil((q.segments.findIndex(e=>e.sequence===t.sequence)+1)/50))),v(`transcript`),U([t.sequence]),N(null),g(e,{anchor:t.sequence,anchorRevision:q.revision}),window.setTimeout(()=>document.getElementById(`discussion-segment-${t.sequence}`)?.scrollIntoView?.({block:`center`}),0)},children:i?`定位原文`:`Locate transcript`})]},t.sequence))]})]}):null,I&&J?(0,$.jsx)(It,{initial:I,zh:i,busy:V,onClose:()=>L(null),onSave:e=>G(async()=>{await T(S(`${f}/summary`),{method:`PATCH`,body:JSON.stringify({...e,expectedRevision:J.revision})}),L(null)})},`${I.kind}:${I.itemId}:${J.revision}`):null,P?(0,$.jsx)(ne,{open:!0,onOpenChange:e=>{e||F(null)},children:(0,$.jsxs)(R,{children:[(0,$.jsx)(pt,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(H,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(28rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge p-4`,children:[(0,$.jsx)(he,{children:i?`校对逐字稿`:`Edit transcript`}),(0,$.jsx)(`button`,{"aria-label":i?`关闭校对`:`Close editor`,onClick:()=>F(null),children:(0,$.jsx)(Qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[(0,$.jsxs)(`label`,{className:`block text-xs`,children:[i?`本段说话人`:`Speaker for this segment`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:P.speaker,onChange:e=>F({...P,speaker:e.target.value})})]}),P.segment.speakerLabel?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!P.applyToSpeakerGroup,onChange:e=>F({...P,applyToSpeakerGroup:e.target.checked})}),i?`同时更名所有同标签片段;输入已有标签可合并说话人`:`Rename all segments with this label; use an existing label to merge speakers`]}):null,(0,$.jsx)(`textarea`,{className:`min-h-32 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:P.text,onChange:e=>F({...P,text:e.target.value})})]}),(0,$.jsx)(`footer`,{className:`border-t border-edge p-3`,children:(0,$.jsxs)(A,{variant:`primary`,disabled:V||!P.text.trim(),onClick:()=>void G(async()=>{await T(S(`${f}/segments/${P.segment.sequence}`),{method:`PATCH`,body:JSON.stringify({displayText:P.text,speakerLabel:P.speaker,expectedRevision:P.segment.revision,applyToSpeakerGroup:P.applyToSpeakerGroup,expectedTranscriptRevision:q.revision})}),F(null)}),children:[(0,$.jsx)(c,{className:`size-4`}),i?`保存修订`:`Save revision`]})})]})]})}):null]})}var Bt={edit:G,ai_edit:ct,sync:re,restore:ve};function Vt(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function Ht({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=w(e=>e.language),o=y(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:x(a)},{data:c}=k(e?[`note-history`,e]:null,()=>Ze(e)),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),h=(0,Q.useCallback)(async t=>{u(!0),m(null);try{await ft(e,t),f(null),i()}catch{m(o.restoreFailed)}finally{u(!1)}},[e,o.restoreSuccess,o.restoreFailed,i]),g=Date.now();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(W,{className:`size-4`,"aria-hidden":!0}),o.history]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(Qe,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p?(0,$.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:p}):null,c?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>{let r=Bt[e.trigger]??G,i=t===e.timestamp,a=d===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:b(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:Vt(e.trigger,o)}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:xt(e.timestamp,g,s)})]}),e.snippet&&(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:o.restoreConfirm}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),h(e.timestamp)},disabled:l,className:`shrink-0 rounded-lg bg-accent px-3 py-1 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:opacity-50`,children:l?`...`:o.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),f(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:o.restore})})]},e.timestamp)})}):(0,$.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:o.historyEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:o.historyEmptyDescription})]})]})]})}function Ut({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:a,openingChat:o,onOpenChat:c,onOpenNewChat:l}){let u=y(w(e=>e.language)).notes,d=s(),f=t?.aiDeep?.catalysis,p=f?.report??null,[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),{data:v,mutate:x,isLoading:S}=k(e?[`note-agent-context-status`,e]:null,()=>$e(e),{revalidateOnFocus:!1}),C=(0,Q.useCallback)(async()=>{if(!g){_(!0),h(null);try{await x(()=>Me(e),{revalidate:!1})}catch(e){h(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{_(!1)}}},[g,x,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),T=(0,Q.useCallback)(async t=>{try{await je(e,t)}catch{}},[e]);return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ct,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":u.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(V,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),v?(0,$.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:S||g,className:`rounded-md px-1.5 py-0.5 text-[11px] font-medium text-accent transition-colors hover:bg-accent/10 disabled:cursor-not-allowed disabled:opacity-50`,children:g?u.processing:u.contextRebuild}),(0,$.jsx)(`span`,{className:b(`rounded-full px-2 py-0.5 text-[11px] font-medium`,v.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:v.status===`partial`?`bg-amber-500/10 text-amber-600 dark:text-amber-300`:`bg-red-500/10 text-red-600 dark:text-red-300`),children:v.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:u.contextStatusDetail.replace(`{{attachments}}`,String(v.attachments.length)).replace(`{{tokens}}`,String(v.tokenEstimate??0))}),m?(0,$.jsx)(`p`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:m}):null,v.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:v.attachments.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:p?u.recatalyze:u.catalyzeAction}),p?(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:p.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:p.targetUsers.slice(0,5).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.keyQuestions.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.mvpPath.slice(0,3).map((e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.risks.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.nextActions.slice(0,4).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,$.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(p.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void T(`helpful`),className:b(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,$.jsx)(Xe,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void T(`not_helpful`),className:b(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,f?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,$.jsx)(nt,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:u.noCatalysisReportHint}),(0,$.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Ne,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:c,disabled:o,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:o?u.openingChat:u.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:o,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),a.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:a.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:u.noThreads})]})]})]})}var Wt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function Gt({open:e,onOpenChange:t,note:n}){let r=w(e=>e.language)===`zh`,i=r?Yt:Xt,{data:a,mutate:o}=k(e?[`note-shares`,n.id]:null,()=>X(n.id)),s=k(e?`hosted-share-auth-status`:null,te),l=s.data===!0,f=k(e&&l?`hosted-publication-capabilities`:null,ut),m=f.data?.publishing.allowed===!0,h=k(e&&l?[`hosted-note-publications`,n.id]:null,()=>K(n.id)),[_,y]=(0,Q.useState)(new Set),[b,x]=(0,Q.useState)(`86400000`),[S,C]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,j]=(0,Q.useState)(`hosted`),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),[I,z]=(0,Q.useState)(null),[re,B]=(0,Q.useState)(!1),[ie,V]=(0,Q.useState)(null),oe=(0,Q.useMemo)(()=>{let e=new Set;return n.markdown.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^\s)]+)/gi,(t,r,i)=>{try{decodeURIComponent(r)===n.id&&e.add(decodeURIComponent(i))}catch{}return t}),(n.attachments??[]).filter(t=>e.has(t.id))},[n.attachments,n.id,n.markdown]);(0,Q.useEffect)(()=>{e&&(y(new Set(oe.map(e=>e.id))),z(null),B(!1),V(null))},[e,oe]);let se=async()=>{N(!0),V(null);try{let e={expectedNoteVersion:n.updatedAt,attachmentIds:[..._],ttlMs:Number(b),maxViews:S.trim()?Number(S):null,description:T.trim()||void 0};D===`hosted`?(z((await U(n.id,e)).shareUrl),await h.mutate()):(z((await ke(n.id,e)).payload.shareUrl),await o())}catch(e){V(e instanceof Error?e.message:String(e))}finally{N(!1)}},ce=async(e,t)=>{F(e.id),V(null);try{t===`refresh`?await xe(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[..._]}):await L(e.id),await h.mutate()}catch(e){V(e instanceof Error?e.message:String(e))}finally{F(null)}},ue=async(e,t)=>{F(e.id),V(null);try{t===`refresh`?await lt(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[..._]}):t===`extend`?await ee(e.id,864e5):await ze(e.id),await o()}catch(e){V(e instanceof Error?e.message:String(e))}finally{F(null)}},de=async e=>{V(null);try{if(!await O(e)){B(!1),V(i.copyFailed);return}B(!0),window.setTimeout(()=>B(!1),1500)}catch{B(!1),V(i.copyFailed)}};return(0,$.jsx)(ne,{open:e,onOpenChange:t,children:(0,$.jsxs)(R,{children:[(0,$.jsx)(pt,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(H,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(he,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,$.jsx)(dt,{className:`size-4`}),i.title]}),(0,$.jsx)(fe,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,$.jsx)(Qe,{className:`size-4`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-inset p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),oe.length>0?(0,$.jsxs)(`section`,{className:`mt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:oe.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:_.has(e.id),onChange:()=>y(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),className:`accent-accent`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Jt(e.size)})]},e.id))})]}):null,(0,$.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.delivery,(0,$.jsxs)(u,{value:D,onChange:e=>j(e.target.value),children:[(0,$.jsx)(d,{value:`hosted`,children:i.deliveryHosted}),(0,$.jsx)(d,{value:`local`,children:i.deliveryLocal})]})]}),D===`hosted`&&s.data===!1?(0,$.jsx)(`div`,{className:`sm:col-span-2`,children:(0,$.jsx)(le,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:()=>void s.mutate(!0,{revalidate:!1})})}):null,D===`hosted`&&l&&f.data&&!m?(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning sm:col-span-2`,children:i.hostedDisabled}):null,(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,$.jsx)(u,{value:b,onChange:e=>x(e.target.value),children:Wt.map(e=>(0,$.jsx)(d,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,$.jsx)(`input`,{type:`number`,min:1,max:1e3,value:S,onChange:e=>C(e.target.value),placeholder:i.unlimited,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]})]}),I?(0,$.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{readOnly:!0,value:I,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,$.jsxs)(A,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void de(I),children:[re?(0,$.jsx)(c,{className:`size-4`}):(0,$.jsx)(p,{className:`size-4`}),re?i.copied:i.copy]}),(0,$.jsxs)(A,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(I,`_blank`,`noopener,noreferrer`),children:[(0,$.jsx)(g,{className:`size-4`}),i.open]})]})}):null,ie?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:ie}):null,(a?.items.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,$.jsx)(qt,{share:e,busy:P===e.id,t:i,onCopy:de,onAction:ue},e.id))})]}):null,(h.data?.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.hostedLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:h.data.map(e=>(0,$.jsx)(Kt,{publication:e,stale:e.source?.version!==String(n.updatedAt),busy:P===e.id,publishingAllowed:m,t:i,onCopy:de,onAction:ce},e.id))})]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsx)(A,{type:`button`,variant:`ghost`,children:i.close})}),(0,$.jsxs)(A,{type:`button`,onClick:()=>void se(),disabled:M||D===`hosted`&&(!l||!m),children:[M?(0,$.jsx)(v,{className:`size-4 animate-spin`}):(0,$.jsx)(dt,{className:`size-4`}),M?i.creating:i.create]})]})]})]})})}function Kt(e){let t=(0,gt.c)(64),{publication:n,stale:r,busy:i,publishingAllowed:a,t:o,onCopy:s,onAction:c}=e,l=n.revoked||n.expired,u=l&&`opacity-60`,d;t[0]===u?d=t[1]:(d=b(`rounded-lg border border-edge-subtle p-3`,u),t[0]=u,t[1]=d);let f=r&&!l?o.stale:l?o.inactive:o.active,m;t[2]===f?m=t[3]:(m=(0,$.jsx)(`span`,{children:f}),t[2]=f,t[3]=m);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`span`,{children:`·`}),t[4]=h):h=t[4];let _=n.maxViews===null?``:` / ${n.maxViews}`,y;t[5]!==n.viewCount||t[6]!==o.views||t[7]!==_?(y=(0,$.jsxs)(`span`,{children:[o.views,` `,n.viewCount,_]}),t[5]=n.viewCount,t[6]=o.views,t[7]=_,t[8]=y):y=t[8];let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{children:`·`}),t[9]=x):x=t[9];let S;t[10]!==n.revision||t[11]!==o.revision?(S=(0,$.jsxs)(`span`,{children:[o.revision,` `,n.revision]}),t[10]=n.revision,t[11]=o.revision,t[12]=S):S=t[12];let C;t[13]!==m||t[14]!==y||t[15]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[m,h,y,x,S]}),t[13]=m,t[14]=y,t[15]=S,t[16]=C):C=t[16];let w;t[17]===n.shareUrl?w=t[18]:(w=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[17]=n.shareUrl,t[18]=w);let T;t[19]!==C||t[20]!==w?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[19]=C,t[20]=w,t[21]=T):T=t[21];let E;t[22]===i?E=t[23]:(E=i?(0,$.jsx)(v,{className:`size-4 animate-spin text-fg-muted`}):null,t[22]=i,t[23]=E);let D;t[24]!==T||t[25]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O=!a,k;t[27]!==s||t[28]!==n.shareUrl?(k=()=>void s(n.shareUrl),t[27]=s,t[28]=n.shareUrl,t[29]=k):k=t[29];let j;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(p,{className:`size-3.5`}),t[30]=j):j=t[30];let M;t[31]!==o.copy||t[32]!==O||t[33]!==k?(M=(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:O,onClick:k,children:[j,o.copy]}),t[31]=o.copy,t[32]=O,t[33]=k,t[34]=M):M=t[34];let N=!a,P;t[35]===n.shareUrl?P=t[36]:(P=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=P);let F;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(g,{className:`size-3.5`}),t[37]=F):F=t[37];let I;t[38]!==o.open||t[39]!==N||t[40]!==P?(I=(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:N,onClick:P,children:[F,o.open]}),t[38]=o.open,t[39]=N,t[40]=P,t[41]=I):I=t[41];let L;t[42]!==i||t[43]!==l||t[44]!==c||t[45]!==n||t[46]!==a||t[47]!==r||t[48]!==o.refresh?(L=r&&!l?(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i||!a,onClick:()=>void c(n,`refresh`),children:[(0,$.jsx)(re,{className:`size-3.5`}),o.refresh]}):null,t[42]=i,t[43]=l,t[44]=c,t[45]=n,t[46]=a,t[47]=r,t[48]=o.refresh,t[49]=L):L=t[49];let R;t[50]!==i||t[51]!==c||t[52]!==n||t[53]!==o.revoke?(R=n.revoked?null:(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i,onClick:()=>void c(n,`revoke`),children:[(0,$.jsx)(Ie,{className:`size-3.5`}),o.revoke]}),t[50]=i,t[51]=c,t[52]=n,t[53]=o.revoke,t[54]=R):R=t[54];let z;t[55]!==M||t[56]!==I||t[57]!==L||t[58]!==R?(z=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[M,I,L,R]}),t[55]=M,t[56]=I,t[57]=L,t[58]=R,t[59]=z):z=t[59];let ee;return t[60]!==D||t[61]!==d||t[62]!==z?(ee=(0,$.jsxs)(`div`,{className:d,children:[D,z]}),t[60]=D,t[61]=d,t[62]=z,t[63]=ee):ee=t[63],ee}function qt(e){let t=(0,gt.c)(68),{share:n,busy:r,t:i,onCopy:a,onAction:o}=e,s=n.revoked||n.expired,c=s&&`opacity-60`,l;t[0]===c?l=t[1]:(l=b(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let u=n.stale&&!s?i.stale:s?i.inactive:i.active,d;t[2]===u?d=t[3]:(d=(0,$.jsx)(`span`,{children:u}),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{children:`·`}),t[4]=f):f=t[4];let m=n.maxViews===null?``:` / ${n.maxViews}`,h;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==m?(h=(0,$.jsxs)(`span`,{children:[i.views,` `,n.viewCount,m]}),t[5]=n.viewCount,t[6]=i.views,t[7]=m,t[8]=h):h=t[8];let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{children:`·`}),t[9]=_):_=t[9];let y;t[10]===n.expiresAt?y=t[11]:(y=new Date(n.expiresAt).toLocaleDateString(),t[10]=n.expiresAt,t[11]=y);let x;t[12]===y?x=t[13]:(x=(0,$.jsx)(`span`,{children:y}),t[12]=y,t[13]=x);let S;t[14]!==x||t[15]!==d||t[16]!==h?(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[d,f,h,_,x]}),t[14]=x,t[15]=d,t[16]=h,t[17]=S):S=t[17];let C;t[18]===n.shareUrl?C=t[19]:(C=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=C);let w;t[20]!==S||t[21]!==C?(w=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[20]=S,t[21]=C,t[22]=w):w=t[22];let T;t[23]===r?T=t[24]:(T=r?(0,$.jsx)(v,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=T);let E;t[25]!==w||t[26]!==T?(E=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,T]}),t[25]=w,t[26]=T,t[27]=E):E=t[27];let D;t[28]!==a||t[29]!==n.shareUrl?(D=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=D):D=t[30];let O;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(p,{className:`size-3.5`}),t[31]=O):O=t[31];let k;t[32]!==i.copy||t[33]!==D?(k=(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:D,children:[O,i.copy]}),t[32]=i.copy,t[33]=D,t[34]=k):k=t[34];let j;t[35]===n.shareUrl?j=t[36]:(j=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=j);let M;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(g,{className:`size-3.5`}),t[37]=M):M=t[37];let N;t[38]!==i.open||t[39]!==j?(N=(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:j,children:[M,i.open]}),t[38]=i.open,t[39]=j,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(P=n.stale&&!s?(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,$.jsx)(re,{className:`size-3.5`}),i.refresh]}):null,t[41]=r,t[42]=s,t[43]=o,t[44]=n,t[45]=i.refresh,t[46]=P):P=t[46];let F;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(F=s?null:(0,$.jsx)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`extend`),children:i.extend}),t[47]=r,t[48]=s,t[49]=o,t[50]=n,t[51]=i.extend,t[52]=F):F=t[52];let I;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(I=n.revoked?null:(0,$.jsxs)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,$.jsx)(Ie,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=I):I=t[57];let L;t[58]!==k||t[59]!==N||t[60]!==P||t[61]!==F||t[62]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[k,N,P,F,I]}),t[58]=k,t[59]=N,t[60]=P,t[61]=F,t[62]=I,t[63]=L):L=t[63];let R;return t[64]!==E||t[65]!==l||t[66]!==L?(R=(0,$.jsxs)(`div`,{className:l,children:[E,L]}),t[64]=E,t[65]=l,t[66]=L,t[67]=R):R=t[67],R}function Jt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Yt={title:`分享笔记`,description:`创建一个无需登录即可查看的只读快照。`,close:`关闭`,untitled:`无标题笔记`,empty:`空笔记`,privateExcluded:`不会分享标签、AI 元数据、项目、讨论、历史版本或未引用附件。`,attachments:`包含的附件`,expires:`有效期`,maxViews:`最多查看次数`,unlimited:`不限`,publicDescription:`公开说明(可选)`,create:`创建分享链接`,creating:`创建中…`,copy:`复制`,copied:`已复制`,open:`打开`,activeLinks:`这条笔记的分享`,copyFailed:`无法复制到剪贴板,请手动选择链接并复制。`,delivery:`发布方式`,deliveryHosted:`平台托管(外网稳定访问)`,deliveryLocal:`本机直连(需要隧道或公网部署)`,hostedLinks:`平台托管发布`,revision:`版本`,hostedDisabled:`管理员已暂停你的公网分享能力。已有托管链接当前不可访问,但仍可撤销。`,stale:`旧版本`,inactive:`已失效`,active:`有效`,views:`查看`,refresh:`更新快照`,extend:`延长 24 小时`,revoke:`撤销`},Xt={title:`Share Note`,description:`Create a read-only snapshot that opens without sign-in.`,close:`Close`,untitled:`Untitled Note`,empty:`Empty Note`,privateExcluded:`Tags, AI metadata, projects, discussions, history, and unreferenced attachments are excluded.`,attachments:`Included attachments`,expires:`Expires`,maxViews:`Maximum views`,unlimited:`Unlimited`,publicDescription:`Public description (optional)`,create:`Create share link`,creating:`Creating…`,copy:`Copy`,copied:`Copied`,open:`Open`,activeLinks:`Shares for this Note`,copyFailed:`Could not copy to the clipboard. Select the link and copy it manually.`,delivery:`Publishing method`,deliveryHosted:`Hosted platform (stable public access)`,deliveryLocal:`Direct from this device (requires public access)`,hostedLinks:`Hosted publications`,revision:`Revision`,hostedDisabled:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but can still be revoked.`,stale:`Older version`,inactive:`Inactive`,active:`Active`,views:`Views`,refresh:`Update snapshot`,extend:`Extend 24 hours`,revoke:`Revoke`};function Zt(e){let t=(0,gt.c)(18),{input:n,labels:r,showLabel:i}=e,a=i===void 0?!0:i,o;t[0]===n?o=t[1]:(o=n(),t[0]=n,t[1]=o);let s=o.source.id,c;t[2]===s?c=t[3]:(c=e=>e.source?.type===`note`&&e.source.id===s&&e.status!==`idle`,t[2]=s,t[3]=c);let l=z(c),u;t[4]===s?u=t[5]:(u=e=>e.source?.type===`note`&&e.source.id===s&&e.status===`preparing`,t[4]=s,t[5]=u);let d=z(u),f=z(Qt),p;t[6]!==n||t[7]!==r||t[8]!==d||t[9]!==a?(p=(0,$.jsx)(mt,{input:n,labels:r,disabled:d,showLabel:a}),t[6]=n,t[7]=r,t[8]=d,t[9]=a,t[10]=p):p=t[10];let m;t[11]!==l||t[12]!==r||t[13]!==f?(m=l?(0,$.jsx)(`button`,{type:`button`,onClick:f,title:r.stop,"aria-label":r.stop,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0})}):null,t[11]=l,t[12]=r,t[13]=f,t[14]=m):m=t[14];let h;return t[15]!==p||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function Qt(e){return e.stop}function $t(e,t){let n=ge(t.replace(/^\s*(`{3,}|~{3,})[^\n]*$/gm,``).replace(/xopc-attachment:\/\/[^\s)]+/g,``).replace(/^(\s*[-*+]\s+)\[[ xX]\]\s*/gm,`$1`)),r=ge(e);return!r||n.split(`
3
- `)[0]===r?n:[r,n].filter(Boolean).join(`
4
-
5
- `)}var en=()=>i(()=>import(`./block-editor-BoduwSYI.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62])),tn=()=>i(()=>import(`./markdown-editor-phTQ0mox.js`),__vite__mapDeps([63,1,59,5,64,3])),nn=(0,Q.lazy)(()=>en().then(e=>({default:e.BlockEditor}))),rn=(0,Q.lazy)(()=>tn().then(e=>({default:e.MarkdownEditor})));function an(){let e=(0,gt.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function on(e){let t=(0,gt.c)(29),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:Fe},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:be},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:_},t[4]=i.preview,t[5]=s);let u;t[6]!==a||t[7]!==o||t[8]!==s?(u=[a,o,s],t[6]=a,t[7]=o,t[8]=s,t[9]=u):u=t[9];let d=u,f;t[10]!==n||t[11]!==d?(f=d.find(e=>e.id===n)??d[0],t[10]=n,t[11]=d,t[12]=f):f=t[12];let p=f,m=p.Icon,h=sn,g;t[13]===m?g=t[14]:(g=(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[13]=m,t[14]=g);let v;t[15]===p.label?v=t[16]:(v=(0,$.jsx)(`span`,{children:p.label}),t[15]=p.label,t[16]=v);let y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(l,{className:`size-3 text-fg-subtle`,"aria-hidden":!0}),t[17]=y):y=t[17];let b;t[18]!==p.label||t[19]!==g||t[20]!==v?(b=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":p.label,className:`inline-flex h-8 items-center gap-1.5 rounded-lg border border-edge px-2.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[g,v,y]})}),t[18]=p.label,t[19]=g,t[20]=v,t[21]=b):b=t[21];let x;t[22]!==n||t[23]!==d||t[24]!==r?(x=(0,$.jsx)(tt,{children:(0,$.jsx)(Ce,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:d.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(Ye,{onSelect:()=>r(t),onPointerMove:()=>h(t),onFocus:()=>h(t),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(a,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i}),n===t?(0,$.jsx)(c,{className:`size-4 text-accent`,"aria-hidden":!0}):null]},t)})})}),t[22]=n,t[23]=d,t[24]=r,t[25]=x):x=t[25];let S;return t[26]!==x||t[27]!==b?(S=(0,$.jsxs)(Y,{modal:!1,children:[b,x]}),t[26]=x,t[27]=b,t[28]=S):S=t[28],S}function sn(e){e===`wysiwyg`&&en(),e===`source`&&tn()}function cn(e){let t=(0,gt.c)(16),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:s,onOpenSearch:c,autoFocus:l,initialMode:u,onAutoFocusConsumed:d}=e,f=a===void 0?!0:a,p=s===void 0?!0:s,m=l===void 0?!1:l,h=w(ln),g;t[0]===h?g=t[1]:(g=y(h),t[0]=h,t[1]=g);let _=g.notes.lightboxClose,v;t[2]!==m||t[3]!==o||t[4]!==p||t[5]!==u||t[6]!==n||t[7]!==d||t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==f?(v=(0,$.jsx)(un,{noteId:n,onBack:r,onSaved:i,showBackButton:f,backButtonClassName:o,clearHeaderOnCleanup:p,onOpenSearch:c,autoFocus:m,initialMode:u,onAutoFocusConsumed:d}),t[2]=m,t[3]=o,t[4]=p,t[5]=u,t[6]=n,t[7]=d,t[8]=r,t[9]=c,t[10]=i,t[11]=f,t[12]=v):v=t[12];let b;return t[13]!==_||t[14]!==v?(b=(0,$.jsx)(oe,{closeLabel:_,children:v}),t[13]=_,t[14]=v,t[15]=b):b=t[15],b}function ln(e){return e.language}function un({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:a=!0,onOpenSearch:o,autoFocus:l=!1,initialMode:u=`wysiwyg`,onAutoFocusConsumed:d}){let f=w(e=>e.language),p=y(f).notes,m=y(f).chat.pageContext,g=y(f).automations.suggestions,{data:_}=k([`note-discussion-document`,e],()=>we(e)),[v,x]=(0,Q.useState)(!0),S=s(),T=pe(e=>e.resolved)===`dark`,{openImage:E}=ce(),[O,A]=(0,Q.useState)(u),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(null),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(``),[ee,te]=(0,Q.useState)(360),[ne,re]=(0,Q.useState)(!1),[B,ae]=(0,Q.useState)(!1),[H,oe]=(0,Q.useState)(!1),le=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{le.current+=1},[e]);let[ue,U]=(0,Q.useState)(null),[de,fe]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(null),[_e,ve]=(0,Q.useState)(!1),[G,be]=(0,Q.useState)(!1),xe=(0,Q.useRef)(!1),Se=(0,Q.useRef)(!1),K=(0,Q.useRef)(null),J=(0,Q.useRef)(null),X=(0,Q.useRef)(null),Ee=(0,Q.useRef)(null),Oe=(0,Q.useRef)(null),ke=(0,Q.useRef)(null),Ae=(0,Q.useRef)(null),je=(0,Q.useRef)(null),Me=(0,Q.useRef)(null),ze=Le(e=>e.setPageHeader),Be=Le(e=>e.clearPageHeader),{data:Z,mutate:We,error:Ke}=k(e?[`note-detail`,e]:null,()=>qe(e)),{data:Je=[],mutate:Xe}=k(e?[`note-threads`,e]:null,()=>Ue(e),{revalidateOnFocus:!1}),Ze=N!==null,Qe=(0,Q.useCallback)(e=>{U(`${p.refreshFailed}: ${e instanceof Error?e.message:p.quickCaptureFailedHint}`)},[p.quickCaptureFailedHint,p.refreshFailed]);(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&We().catch(Qe)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[We,e,Qe]),(0,Q.useEffect)(()=>{xe.current=!1,R(``),P(null),M(null),Se.current=!1,Me.current=null},[e]),(0,Q.useEffect)(()=>{!Z||xe.current||(R(Z.title??``),xe.current=!0)},[Z]),(0,Q.useEffect)(()=>{if(!l||!Z||Ze||Me.current===e)return;let t=window.requestAnimationFrame(()=>{je.current?.focus(),d?.()});return Me.current=e,()=>window.cancelAnimationFrame(t)},[l,Ze,Z,e,d]);let $e=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,et=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":p.back,className:b(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,se,i),children:(0,$.jsx)(V,{className:`size-4`,"aria-hidden":!0})}):null,[i,p.back,t,r]),nt=(0,Q.useCallback)(()=>{let t=z.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),rt=(0,Q.useCallback)(e=>{e!==`preview`&&nt(),A(e)},[nt]),st=(0,Q.useCallback)(t=>{nt(),R(t),e&&(Ee.current=t,J.current&&clearTimeout(J.current),J.current=setTimeout(async()=>{let t=Ee.current;if(Ee.current=null,t!==null){I(!0);try{await q(e,{title:t}),await We(),n?.()}catch{}finally{I(!1)}}},600))},[nt,e,We,n]),lt=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:b(`flex min-w-0 items-center gap-2`,se),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:L||$e||void 0,children:L||$e}),F?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:p.saving}):null]}),[p.saving,F,$e,L]),ut=(0,Q.useCallback)(async(t=!1)=>{oe(!0),U(null);try{let n=await De(e,{forceNew:t});await We(),await Xe(),S(`/chat/${encodeURIComponent(n.conversationId)}`)}catch(e){U(`${p.chatOpenFailedTitle}: ${e instanceof Error?e.message:p.chatOpenFailedMessage}`)}finally{oe(!1)}},[We,Xe,S,e,p.chatOpenFailedMessage,p.chatOpenFailedTitle]),ft=(0,Q.useCallback)(async()=>{ae(!0),U(null);try{await ye(e),await We()}catch(e){U(`${p.catalysisFailed}: ${e instanceof Error?e.message:p.chatOpenFailedMessage}`)}finally{ae(!1)}},[We,e]),pt=(0,Q.useCallback)(()=>{M(j===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!B&&ft()},[j,B,ft,Z?.aiDeep?.catalysis?.report]),mt=(0,Q.useCallback)(()=>{let t=N?N.markdown??``:X.current??Z?.markdown??``,n=N?N.title??``:L,r=$t(n,t);return{source:{type:`note`,id:e,title:n||p.titlePlaceholder},text:r,language:ie(r,f)}},[f,p.titlePlaceholder,Z?.markdown,e,N,L]),ht=(0,Q.useCallback)(async()=>{K.current&&clearTimeout(K.current),J.current&&clearTimeout(J.current),K.current=null,J.current=null;let t=X.current,r=Ee.current;X.current=null,Ee.current=null;let i={};if(t!==null&&(i.markdown=t),r!==null&&(i.title=r),Object.keys(i).length===0)return Z??null;I(!0);try{let t=await q(e,i);return await We(t,{revalidate:!1}),n?.(),t}catch(e){return X.current===null&&(X.current=t),Ee.current===null&&(Ee.current=r),U(`${p.saveFailed}: ${e instanceof Error?e.message:p.saveFailedHint}`),null}finally{I(!1)}},[We,p.saveFailed,p.saveFailedHint,Z,e,n]),gt=(0,Q.useCallback)(async()=>{if(!Z||H||F)return;oe(!0),U(null);let e=C.getState(),t=++le.current,n=()=>le.current===t&&C.getState().baseUrl===e.baseUrl&&C.getState().conversationId===e.conversationId;try{let t=window.getSelection(),r=t?.anchorNode&&t.focusNode&&Oe.current?.contains(t.anchorNode)&&Oe.current.contains(t.focusNode)?t.toString():``,i=await ht();if(!i||!n())return;if(X.current!==null||Ee.current!==null)throw Error(m.unavailable);let a=Te.capture({title:i.title||i.id,text:i.markdown,resourceRefs:[{kind:`note`,id:i.id,revision:String(i.remoteVersion??1)}],selection:r?{text:r,draft:!1}:void 0}),o=await new D().createSession();if(!n())return;if(X.current!==null||Ee.current!==null)throw Error(m.unavailable);let s=at(e.baseUrl,e.conversationId,o.key);if(!Te.put(s,a))throw Error(m.unavailable);S(`/chat/${encodeURIComponent(o.key)}`)}catch{n()&&U(m.unavailable)}finally{le.current===t&&oe(!1)}},[Z,H,F,ht,S,m.unavailable]),_t=(0,Q.useCallback)(async()=>{U(null);let e=await ht();e&&(ge(e),fe(!0))},[ht]),vt=(0,Q.useCallback)(async()=>{if(!(G||F)){ve(!1),be(!0),U(null),nt(),K.current&&clearTimeout(K.current),J.current&&clearTimeout(J.current),K.current=null,J.current=null,X.current=null,Ee.current=null;try{await it(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){U(`${p.deleteFailed}: ${e instanceof Error?e.message:p.quickCaptureFailedHint}`)}finally{be(!1)}}},[G,p.deleteFailed,p.quickCaptureFailedHint,e,t,n,F,nt]),yt=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:b(`flex min-w-0 items-center gap-1 sm:gap-2`,se),children:[o?(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":p.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(Zt,{input:mt,showLabel:!1,labels:{read:p.readAloud,preparing:p.readAloudPreparing,pause:p.readAloudPause,resume:p.readAloudResume,retry:p.readAloudRetry,stop:p.readAloudStop}}),(0,$.jsxs)(`button`,{type:`button`,onClick:pt,disabled:B,"aria-label":p.catalysisSectionTitle,className:b(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50`,j===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:B?p.catalyzing:p.catalyzeButton})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ut(!1),"aria-label":p.openChatButton,disabled:H,className:b(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,$.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:H?p.openingChat:p.openChatButton})]}),(0,$.jsx)(on,{mode:O,onModeChange:rt,labels:{edit:p.modeEdit,source:p.modeSource,preview:p.modePreview}}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void gt(),disabled:H||F||!Z||!!N,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(Fe,{className:`size-3.5`,"aria-hidden":!0}),m.capture]}),(0,$.jsxs)(Y,{modal:!1,children:[(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":p.noteActions,title:p.noteActions,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(tt,{children:(0,$.jsxs)(Ce,{align:`end`,sideOffset:6,className:`z-50 min-w-40 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(Ye,{onSelect:()=>void _t(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(dt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),f===`zh`?`分享`:`Share`]}),(0,$.jsxs)(Ye,{onSelect:()=>M(j===`history`?null:`history`),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(W,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:p.history}),j===`history`?(0,$.jsx)(c,{className:`size-4 text-accent`,"aria-hidden":!0}):null]}),(0,$.jsx)(He,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(Ye,{disabled:G||F,onSelect:()=>ve(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(Ie,{className:`size-4`,"aria-hidden":!0}),p.delete]})]})})]})]}),[B,pt,ut,gt,m.capture,Z,N,O,p.history,p.modeEdit,p.modePreview,p.modeSource,H,j,o,p.searchDialogTitle,p.readAloud,p.readAloudPause,p.readAloudPreparing,p.readAloudResume,p.readAloudRetry,p.readAloudStop,rt,mt,_t,G,F,f,p.delete,ve]);(0,Q.useLayoutEffect)(()=>(ze({startExtra:et,main:Z&&!(_&&v)?lt:null,end:Z&&!(_&&v)?yt:null}),()=>{a&&Be()}),[a,Be,yt,lt,et,_,v,Z,ze]);let bt=(0,Q.useCallback)(t=>{e&&(nt(),X.current=t,K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let t=X.current;if(X.current=null,t!==null){I(!0),U(null);try{await q(e,{markdown:t}),await We(),n?.()}catch(e){U(`${p.saveFailed}: ${e instanceof Error?e.message:p.saveFailedHint}`)}finally{I(!1)}}},600))},[nt,e,We,p.saveFailed,p.saveFailedHint,n]),xt=(0,Q.useCallback)(t=>{Re(e,t.timestamp).then(e=>{e&&(nt(),P(e))})},[e,nt]),St=(0,Q.useCallback)(()=>{nt(),M(null),P(null)},[nt]),Ct=(0,Q.useCallback)(()=>{nt(),M(null),P(null),We().catch(Qe),n?.()},[We,n,Qe,nt]);if((0,Q.useEffect)(()=>()=>{K.current&&clearTimeout(K.current),J.current&&clearTimeout(J.current);let t=X.current,n=Ee.current;X.current=null,Ee.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&q(e,r).catch(()=>void 0)},[e]),Z===void 0)return Ke?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:p.home.loadFailed}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void We().catch(Qe),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:p.home.retry}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:p.back})]}):(0,$.jsx)(an,{});if(Z===null)return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:p.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p.notFoundDescription}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:p.back})]});let Tt=Ze?N.title??``:L,Et=Ze?N.markdown??``:X.current??Z.markdown??``,Dt=new Date(Z.createdAt).getTime(),Ot=Number.isFinite(Dt)&&Date.now()-Dt<3600*1e3?(0,$.jsx)(wt,{title:g.noteCreatedTitle,description:g.noteCreatedDescription,prompt:g.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-0 min-w-0 w-full max-w-[60rem] flex-1 flex-col`,children:[ue?(0,$.jsx)(`p`,{className:`mb-3 shrink-0 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:ue}):null,(0,$.jsx)(Pe,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(Pe,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),_&&!v?(0,$.jsx)(`button`,{className:`mb-2 inline-flex min-h-11 shrink-0 items-center self-start rounded-lg px-2 text-sm text-accent-fg focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>x(!0),children:f===`zh`?`← 返回录音笔记`:`← Back to recording`}):null,(0,$.jsxs)(`div`,{ref:Oe,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[_&&v?(0,$.jsx)(zt,{noteId:e,noteActions:{onAnalyze:pt,onChat:()=>{ut(!1)},onShare:()=>{_t()},onHistory:()=>M(j===`history`?null:`history`),onDelete:()=>ve(!0),busy:G||F||B||H},onPersonalNotes:()=>{x(!1),window.setTimeout(()=>je.current?.focus(),0)}}):null,(0,$.jsx)(`div`,{className:_&&v?`hidden`:`min-h-0 min-w-0 flex-1`,children:Ze?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,children:[Tt&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Tt}),Et?(0,$.jsx)(me,{noteId:e,content:Et,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:p.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[O===`wysiwyg`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:je,type:`text`,value:L,onChange:e=>st(e.target.value),onCompositionStart:()=>{Se.current=!0},onCompositionEnd:()=>{Se.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!Se.current&&!t.isComposing&&(e.preventDefault(),(Oe.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:p.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ot]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(an,{}),children:(0,$.jsx)(nn,{initialContent:Z.markdown??``,onChange:bt,noteId:e},`wysiwyg-${e}`)})})]}),O===`source`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:je,type:`text`,value:L,onChange:e=>st(e.target.value),placeholder:p.titlePlaceholder,className:`min-w-0 flex-1 border-none bg-transparent text-2xl font-bold text-fg placeholder:text-fg-muted/40 focus:outline-none`}),Ot]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(an,{}),children:(0,$.jsx)(rn,{initialContent:Z.markdown??``,onChange:bt,isDark:T},`source-${e}`)})})]}),O===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&E(t.currentSrc||t.src,t.alt)},children:[L&&!Z.markdown.trimStart().startsWith(`# ${L.trim()}\n`)&&Z.markdown.trim()!==`# ${L.trim()}`&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:L}),Z.markdown?(0,$.jsx)(me,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:p.emptyPreview})]})]})})]})]}),(0,$.jsx)(`div`,{ref:ke,className:b(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!ne&&`transition-[width] duration-300 ease-in-out`),style:{width:j?ee:0},children:(0,$.jsxs)(`div`,{ref:Ae,className:`flex min-h-0 flex-1 flex-col`,style:{width:ee},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),re(!0);let n=e.clientX,r=ee,i=e.pointerId,a=0,o=ee,s=ee,c=()=>{a=0,s=o,j&&ke.current?.style.setProperty(`width`,`${s}px`),Ae.current?.style.setProperty(`width`,`${s}px`)},l=e=>{let t=r-(e.clientX-n);o=Math.max(280,Math.min(600,Math.round(t))),a===0&&(a=window.requestAnimationFrame(c))},u=()=>{a!==0&&(window.cancelAnimationFrame(a),c());try{t.releasePointerCapture(i)}catch{}re(!1),te(s),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u)},className:b(`absolute left-0 top-0 z-10 h-full w-2 -translate-x-1/2 cursor-col-resize`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,ne&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:j===`history`?(0,$.jsx)(Ht,{noteId:e,activeTimestamp:N?.timestamp??null,onSelect:xt,onClose:St,onRestored:Ct}):j===`breakdown`?(0,$.jsx)(Ut,{noteId:e,note:Z??null,catalyzing:B,onCatalyze:ft,onClose:()=>M(null),noteThreads:Je,openingChat:H,onOpenChat:()=>ut(!1),onOpenNewChat:()=>ut(!0)}):null})]})})]}),he?(0,$.jsx)(Gt,{open:de,onOpenChange:fe,note:he}):null,(0,$.jsx)(Ge,{open:_e,title:p.deleteConfirmTitle,description:p.deleteConfirmDescription.replace(`{{title}}`,Z.title||p.titlePlaceholder),confirmLabel:p.deleteConfirmLabel,cancelLabel:p.deleteCancelLabel,destructive:!0,onConfirm:()=>void vt(),onCancel:()=>ve(!1)})]})}export{xt as i,Ct as n,St as r,cn as t};
@@ -1 +0,0 @@
1
- import"./index-ygkHNYyo.js";