@xopcai/xopc 0.0.269 → 0.0.270

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 (204) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DcwCSY6s.js → activity-store-D_0FmdRj.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D0NBOWC4.js → agent-avatar-dicebear-IZvEXak_.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CE3ygr3l.js +1 -0
  6. package/dist/gateway/static/root/assets/agents-DzG2qw-c.js +1 -0
  7. package/dist/gateway/static/root/assets/{api-eaPO-mdr.js → api-O3TTQ4qN.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-E3xm2teY.js → app-management-settings-panel-Cqqsbzri.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-CiZOjgls.js → appearance-settings-DaJyf32s.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-B4lX6yoT.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-D09yo_Hc.js → archive-plugin-kDPnDTJI.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-CNYb8Qru.js → attachment-load-CJ3VceKS.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DsrfW5ii.js → automations-page-JwMtU8XB.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-BiNBewg0.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-OWlaGqlY.js → binary-plugins-DzyZXLBX.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-CVND3M6r.js → block-editor-kTt3gYIJ.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-D7IzVK_J.js → browser-automation-inputs-BKohPYR4.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-CQ6cCpIv.js → browser-automations-page-ktQfFPk-.js} +2 -2
  19. package/dist/gateway/static/root/assets/browser-settings-page-Dgdt5uVL.js +8 -0
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-BpDW-R9f.js +7 -0
  21. package/dist/gateway/static/root/assets/channels-settings-DU4EQnR0.js +1 -0
  22. package/dist/gateway/static/root/assets/{channels-status-swr-D4JrgJKa.js → channels-status-swr-DrqzYmDr.js} +1 -1
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-BUjnhT7C.js → chat-terminal-dock-CIFGGLGa.js} +2 -2
  24. package/dist/gateway/static/root/assets/connectors-page-CfJqy284.js +2 -0
  25. package/dist/gateway/static/root/assets/{cron-expression-DlyRIyUn.js → cron-expression-BNwbnrEb.js} +1 -1
  26. package/dist/gateway/static/root/assets/{date-picker-CU-ij_yE.js → date-picker-DKyirU4K.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dependency-picker-Z6Nf0Wjq.js → dependency-picker-D3vNIjRI.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-C0F5Iqnc.js → desktop-pet-fQwRb_3p.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-Bj_W6HL1.js → desktop-pet-settings-DfOJ-GvT.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-debug-page-Ba09EnAn.js → extension-debug-page-Cn53jB5-.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-C88aGXJs.js → extension-page-IDpLCxpC.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-settings-page-CMyt0A32.js → extension-settings-page-B1dds2bP.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-config-swr-bjzk_4hn.js → gateway-config-swr-B7dcmP7Q.js} +1 -1
  34. package/dist/gateway/static/root/assets/gateway-settings-pp9jN0wl.js +1 -0
  35. package/dist/gateway/static/root/assets/{gateway-startup-retry-DrbIzFyB.js → gateway-startup-retry-JGhGMhVZ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{heartbeat-settings-BnrMRKaZ.js → heartbeat-settings-B8_zTyev.js} +1 -1
  37. package/dist/gateway/static/root/assets/home-page-g1KdAdLb.js +1 -0
  38. package/dist/gateway/static/root/assets/{image-generation-api-CBWU9Ner.js → image-generation-api-BJLX7Qrh.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-1zRt56Zt.css +2 -0
  40. package/dist/gateway/static/root/assets/{index-CfyyA9-g.js → index-OMnem2nr.js} +47 -47
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B8Z7kKQY.js → keyboard-shortcuts-settings-CBvMTFFx.js} +1 -1
  42. package/dist/gateway/static/root/assets/local-app-workbench-page-bj75v2ZE.js +2 -0
  43. package/dist/gateway/static/root/assets/{local-apps-page-CLSfzkRp.js → local-apps-page-APCMNDvU.js} +1 -1
  44. package/dist/gateway/static/root/assets/{locale-store-BQ2HKTWb.js → locale-store-BThkG0W5.js} +1 -1
  45. package/dist/gateway/static/root/assets/{logs-page-CWDU1AGN.js → logs-page-BX7n39zV.js} +2 -2
  46. package/dist/gateway/static/root/assets/{management-settings-CuFNgQUy.js → management-settings-CM62j8ZX.js} +1 -1
  47. package/dist/gateway/static/root/assets/{markdown-view-DIcfrLmG.js → markdown-view-BwjpJVPs.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-CSv6-xTA.js → media-plugins-C10byeaa.js} +1 -1
  49. package/dist/gateway/static/root/assets/{messages-BRjoarIr.js → messages-D0V_bgRP.js} +2 -2
  50. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-C7d_ztgp.js → mobile-pairing-wizard-BCWfwVx3.js} +1 -1
  51. package/dist/gateway/static/root/assets/note-detail-panel-koOqb0gX.js +5 -0
  52. package/dist/gateway/static/root/assets/notes-page-BH54rY3B.js +8 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-BfV-PQa5.js → page-tabs-qQ36zncF.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-DQS7NFpg.js → preview-open-alternatives-BiAJvvCo.js} +1 -1
  55. package/dist/gateway/static/root/assets/proactive-card-CcNBqHoH.js +1 -0
  56. package/dist/gateway/static/root/assets/proactive-page-C3K61jve.js +1 -0
  57. package/dist/gateway/static/root/assets/{product-open-page-BIhjZLKg.js → product-open-page-CunnDP4w.js} +1 -1
  58. package/dist/gateway/static/root/assets/project-detail-page-SL2g8MZY.js +1 -0
  59. package/dist/gateway/static/root/assets/projects-page-BtxazT5J.js +1 -0
  60. package/dist/gateway/static/root/assets/{registry-api-CwveUfe8.js → registry-api-0JSegbNl.js} +1 -1
  61. package/dist/gateway/static/root/assets/remote-access-hub-BSb7b67A.js +1 -0
  62. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DMQ0wpNg.js → runtime-tools-settings-panel-bu_mwBTr.js} +2 -2
  63. package/dist/gateway/static/root/assets/{schema-form-C91g2PRU.js → schema-form-BE0sgZyz.js} +1 -1
  64. package/dist/gateway/static/root/assets/sessions-page-ljcS2KVz.js +1 -0
  65. package/dist/gateway/static/root/assets/settings-advanced-gate-CR9Y9LQm.js +1 -0
  66. package/dist/gateway/static/root/assets/{settings-form-section-Cem6L49Y.js → settings-form-section-CBo517lV.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-afDUxqlV.js → settings-page-DBPimx93.js} +1 -1
  68. package/dist/gateway/static/root/assets/{setup-status-panel-Cc_iP_vv.js → setup-status-panel-J3AnooPW.js} +1 -1
  69. package/dist/gateway/static/root/assets/{share-preview-page-CVEVHksg.js → share-preview-page-DdV75VTe.js} +1 -1
  70. package/dist/gateway/static/root/assets/shares-settings-AAm4Iwcp.js +1 -0
  71. package/dist/gateway/static/root/assets/skill-reload-api-pRCjP5sm.js +1 -0
  72. package/dist/gateway/static/root/assets/{skills-page-CNrq1W6C.js → skills-page-Cn_-nvRo.js} +1 -1
  73. package/dist/gateway/static/root/assets/{skills-page.utils-D1wGfm22.js → skills-page.utils-CfVAc_lu.js} +1 -1
  74. package/dist/gateway/static/root/assets/{system-settings-panel-BLE8PxWE.js → system-settings-panel-B-pzalp-.js} +1 -1
  75. package/dist/gateway/static/root/assets/task-detail-page-CmrLy3PO.js +1 -0
  76. package/dist/gateway/static/root/assets/{theme-store-BejLVjIT.js → theme-store-1wryLgBQ.js} +1 -1
  77. package/dist/gateway/static/root/assets/{tunnel-api-Dur80zSQ.js → tunnel-api-Cgpnm2fL.js} +1 -1
  78. package/dist/gateway/static/root/assets/{use-autosave-DmgEA8Qb.js → use-autosave-N_lm4FdD.js} +1 -1
  79. package/dist/gateway/static/root/assets/user-model-page-u3QLDX6L.js +2 -0
  80. package/dist/gateway/static/root/assets/{voice-api-key-field-sZ0J83SF.js → voice-api-key-field-DMsyVfri.js} +1 -1
  81. package/dist/gateway/static/root/assets/{voice-config-api-BEbz3avx.js → voice-config-api-QWVmiAp3.js} +1 -1
  82. package/dist/gateway/static/root/assets/{work-discovery-overlay-BXnAlbmO.js → work-discovery-overlay-BC0vAxp1.js} +1 -1
  83. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BkwFey0a.js → workflow-run-setup-panel-Cz9jQIlP.js} +2 -2
  84. package/dist/gateway/static/root/assets/workflows-page-DA6OOK6X.js +6 -0
  85. package/dist/gateway/static/root/index.html +10 -10
  86. package/dist/package.js +1 -1
  87. package/dist/packages/gateway-contract/src/notifications.js +2 -2
  88. package/dist/packages/gateway-contract/src/proactive.js +22 -6
  89. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  90. package/dist/src/agent/tool-manuals/xopc-use.js +19 -1
  91. package/dist/src/agent/tools/factory.js +1 -0
  92. package/dist/src/agent/tools/xopc-use-tool.d.ts +3 -2
  93. package/dist/src/agent/tools/xopc-use-tool.js +48 -4
  94. package/dist/src/browser/automations/schema.d.ts +1 -1
  95. package/dist/src/browser/automations/service.d.ts +1 -1
  96. package/dist/src/cli/bin.js +2 -2
  97. package/dist/src/cli/commands/agent.js +2 -2
  98. package/dist/src/cli/commands/auth.js +1 -1
  99. package/dist/src/cli/commands/connectors.js +1 -1
  100. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  101. package/dist/src/cli/commands/extension-dev.js +1 -1
  102. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  103. package/dist/src/cli/commands/extension.js +1 -1
  104. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  105. package/dist/src/cli/commands/gateway-ssh-tunnel.js +1 -1
  106. package/dist/src/cli/commands/models.js +2 -2
  107. package/dist/src/cli/commands/onboard.js +1 -1
  108. package/dist/src/cli/commands/platform.js +1 -1
  109. package/dist/src/cli/commands/profile.js +1 -1
  110. package/dist/src/cli/commands/tunnel.js +1 -1
  111. package/dist/src/cli/commands/update.js +1 -1
  112. package/dist/src/cli/extension-cli-register.js +1 -1
  113. package/dist/src/config/index.js +1 -1
  114. package/dist/src/connectors/connected-source-ingestion.js +1 -1
  115. package/dist/src/connectors/connected-source-normalizers.js +3 -0
  116. package/dist/src/connectors/connection-recovery-service.js +1 -1
  117. package/dist/src/connectors/health.js +1 -1
  118. package/dist/src/gateway/hono/routes/capabilities.js +1 -1
  119. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  120. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  121. package/dist/src/gateway/hono/routes/proactive-control.js +31 -24
  122. package/dist/src/gateway/run-loop.js +1 -1
  123. package/dist/src/gateway/server.js +1 -1
  124. package/dist/src/gateway/service.js +10 -10
  125. package/dist/src/notifications/web-push.js +1 -1
  126. package/dist/src/proactive/actions/service.js +4 -2
  127. package/dist/src/proactive/execution/authorization.d.ts +2 -0
  128. package/dist/src/proactive/execution/authorization.js +39 -1
  129. package/dist/src/proactive/execution/context.d.ts +4 -0
  130. package/dist/src/proactive/execution/context.js +51 -5
  131. package/dist/src/proactive/execution/insight.js +3 -1
  132. package/dist/src/proactive/execution/repository.js +15 -5
  133. package/dist/src/proactive/execution/types.d.ts +2 -0
  134. package/dist/src/proactive/execution/worker.js +7 -2
  135. package/dist/src/proactive/experience.d.ts +69 -0
  136. package/dist/src/proactive/experience.js +90 -0
  137. package/dist/src/proactive/follow-ups.d.ts +123 -0
  138. package/dist/src/proactive/follow-ups.js +169 -0
  139. package/dist/src/proactive/inbox/cards.js +35 -6
  140. package/dist/src/proactive/inbox/delivery.js +4 -2
  141. package/dist/src/proactive/inbox/digest.js +2 -2
  142. package/dist/src/proactive/inbox/lifecycle.js +4 -1
  143. package/dist/src/proactive/inbox/notification-policy.js +4 -2
  144. package/dist/src/proactive/inbox/repository.js +17 -11
  145. package/dist/src/proactive/inbox/types.d.ts +2 -0
  146. package/dist/src/proactive/inbox/worker.js +1 -1
  147. package/dist/src/proactive/index.js +2 -2
  148. package/dist/src/proactive/mail-thread.d.ts +13 -0
  149. package/dist/src/proactive/mail-thread.js +54 -0
  150. package/dist/src/proactive/policy/service.d.ts +2 -4
  151. package/dist/src/proactive/policy/service.js +3 -5
  152. package/dist/src/proactive/scenarios/control.d.ts +4 -7
  153. package/dist/src/proactive/scenarios/control.js +3 -4
  154. package/dist/src/proactive/scenarios/preview.js +1 -1
  155. package/dist/src/proactive/scenarios/prompt-composer.js +2 -0
  156. package/dist/src/proactive/service.js +1 -1
  157. package/dist/src/proactive/temporal/worker.d.ts +1 -0
  158. package/dist/src/proactive/temporal/worker.js +18 -4
  159. package/dist/src/storage/sqlite/migrations/162_proactive_product.sql +7 -0
  160. package/dist/src/storage/sqlite/migrations/163_proactive_follow_ups.sql +29 -0
  161. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  162. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  163. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  164. package/dist/src/storage/sqlite/schema.js +1 -1
  165. package/dist/src/tasks/home-query-service.js +1 -1
  166. package/dist/src/tasks/index.js +4 -4
  167. package/dist/src/tui/tui-startup-resources.js +1 -1
  168. package/dist/src/voice/dashscope/streaming-stt-session.js +1 -0
  169. package/dist/src/voice/dashscope/streaming-tts-stream.d.ts +1 -0
  170. package/dist/src/voice/dashscope/streaming-tts-stream.js +8 -0
  171. package/dist/src/voice/realtime/agentBroker.js +1 -1
  172. package/dist/src/voice/realtime/agentEngine.js +1 -1
  173. package/dist/src/voice/realtime/pcm-output-gain.d.ts +2 -0
  174. package/dist/src/voice/realtime/pcm-output-gain.js +16 -0
  175. package/dist/src/voice/realtime/runtime.js +4 -2
  176. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  177. package/package.json +2 -2
  178. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-qKCezlBg.js +0 -1
  179. package/dist/gateway/static/root/assets/agents-BMhnZKhP.js +0 -1
  180. package/dist/gateway/static/root/assets/apps-page-DduJDWGY.js +0 -1
  181. package/dist/gateway/static/root/assets/automations-workspace-X7hNHCjW.js +0 -6
  182. package/dist/gateway/static/root/assets/browser-settings-page-BZ7nK_pN.js +0 -8
  183. package/dist/gateway/static/root/assets/capabilities-settings-panel-BfKvJO1C.js +0 -7
  184. package/dist/gateway/static/root/assets/channels-settings-D1UDxJuA.js +0 -1
  185. package/dist/gateway/static/root/assets/connectors-page-C2nuqs_O.js +0 -2
  186. package/dist/gateway/static/root/assets/gateway-settings-ogv8ZbvG.js +0 -1
  187. package/dist/gateway/static/root/assets/home-page-CbcJCREd.js +0 -1
  188. package/dist/gateway/static/root/assets/index-7PZ6jmhy.css +0 -2
  189. package/dist/gateway/static/root/assets/local-app-workbench-page-D5XVZnK1.js +0 -2
  190. package/dist/gateway/static/root/assets/note-detail-panel-D5JuBLyt.js +0 -5
  191. package/dist/gateway/static/root/assets/notes-page-C5-ccCi4.js +0 -8
  192. package/dist/gateway/static/root/assets/proactive-page-fHjPigmx.js +0 -1
  193. package/dist/gateway/static/root/assets/project-detail-page-6v_khvEt.js +0 -1
  194. package/dist/gateway/static/root/assets/projects-page-CCy1aK4V.js +0 -1
  195. package/dist/gateway/static/root/assets/remote-access-hub-pkqKRnch.js +0 -1
  196. package/dist/gateway/static/root/assets/sessions-page-Cr4E4cap.js +0 -1
  197. package/dist/gateway/static/root/assets/settings-advanced-gate-D1JRDRyL.js +0 -1
  198. package/dist/gateway/static/root/assets/shares-settings-BrMECMAB.js +0 -1
  199. package/dist/gateway/static/root/assets/skill-reload-api-DuqIDYjc.js +0 -1
  200. package/dist/gateway/static/root/assets/task-detail-page-m0oXUKl2.js +0 -1
  201. package/dist/gateway/static/root/assets/user-model-page-Dl10D_5q.js +0 -2
  202. package/dist/gateway/static/root/assets/workflows-page-CswgoIFU.js +0 -6
  203. package/dist/src/proactive/actions/workflow.d.ts +0 -15
  204. package/dist/src/proactive/actions/workflow.js +0 -88
@@ -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{d as i,p as a,t as o}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./dist-CpzYSoz7.js";import{t as ee}from"./check-DUBLcKHA.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./x-B_N4OPjy.js";import{n as v,r as y}from"./locale-store-BQ2HKTWb.js";import{a as te,i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-B11EPpor.js";import{t as S}from"./skeleton-BwbyijEw.js";import{Ec as C,Fr as ne,Ic as re,Kc as w,Ll as ie,Ml as ae,Mu as oe,Tc as se,Us as ce,Ws as le,aa as ue,ao as de,au as T,bc as fe,eu as pe,fa as me,ic as he,lc as ge,ro as _e,xl as ve,yc as ye}from"./index-CfyyA9-g.js";import{n as be,t as xe}from"./tab-completion-input-D64VNmiA.js";import{t as Se}from"./tab-completion-input.utils-BP3NH_du.js";import{a as Ce,c as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./api-eaPO-mdr.js";var E=e(t(),1),je=`build-xopc-local-app`;function Me(e){return(e.routing?.agentId??e.agentId??``).trim().toLowerCase()}function Ne(e){return e.find(e=>Me(e)===`coder`)??null}function Pe(e,t){let n=new URLSearchParams({skill:je}),r=t?.trim();return r&&n.set(`draft`,r),`/chat/${encodeURIComponent(e)}?${n.toString()}`}var D=new Set([`document`,`content`,`interaction`,`criteria`]),Fe=new Set([`passed`,`failed`,`skipped`]);function Ie(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.source!==`xopc-local-app-preview`||t.version!==1)return null;if(t.type===`ready`)return{type:`ready`,detail:{}};if(t.type===`criteria`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.scenarios)||e.scenarios.length>10)return null;let n=e.scenarios.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!t.id.trim()||t.id.length>80||typeof t.name!=`string`||!t.name.trim()||t.name.length>120||t.status!==`passed`&&t.status!==`failed`||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,name:t.name,status:t.status,message:t.message.slice(0,500),failureKind:`scenario`}});if(n.some(e=>e===null))return null;let r=typeof e.scenarioCount==`number`&&Number.isInteger(e.scenarioCount)&&e.scenarioCount>=0&&e.scenarioCount<=10?e.scenarioCount:n.length;return{type:`criteria`,detail:{status:e.status,scenarioCount:r,scenarios:n}}}if(t.type===`acceptance`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.checks))return null;let n=e.checks.slice(0,10).map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return!D.has(t.id)||!Fe.has(t.status)||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,status:t.status,message:t.message.slice(0,500)}});if(!n.length||n.some(e=>e===null))return null;let r=typeof e.interactiveCount==`number`&&Number.isFinite(e.interactiveCount)&&e.interactiveCount>=0?Math.min(Math.floor(e.interactiveCount),1e4):0;return{type:`acceptance`,detail:{status:e.status,checks:n,interactiveCount:r}}}if(t.type!==`error`||!t.detail||typeof t.detail!=`object`)return null;let n=t.detail;return n.kind!==`script_error`&&n.kind!==`unhandled_rejection`||typeof n.message!=`string`||!n.message.trim()?null:{type:`error`,detail:{kind:n.kind,message:n.message.slice(0,500),filename:typeof n.filename==`string`?n.filename.slice(0,500):void 0,line:typeof n.line==`number`?n.line:void 0,column:typeof n.column==`number`?n.column:void 0}}}function Le(e){return e?.checks.filter(e=>e.status===`failed`).map(e=>e.message)??[]}function Re(e){let t=e.filename?` (${e.filename}${e.line?`:${e.line}${e.column?`:${e.column}`:``}`:``})`:``;return`${e.message}${t}`}var O=Object.freeze({source:`xopc-local-app-host`,version:1,type:`connect`});function ze(e,t){let n=null,r=()=>{n?.close();let r=new MessageChannel;n=r.port1,n.onmessage=e=>t(e.data),n.start(),e.contentWindow?.postMessage(O,`*`,[r.port2])};return e.addEventListener(`load`,r),r(),()=>{e.removeEventListener(`load`,r),n?.close()}}var Be=n(),k=r();function Ve(e){let t=(0,Be.c)(36),{scenarios:n,results:r,runningTarget:i,zh:a,onRunAll:o,onRunScenario:s,onAskCoder:c}=e;if(!n.length)return null;let l=a?`产品场景`:`Product scenarios`,u;t[0]===l?u=t[1]:(u=(0,k.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:l}),t[0]=l,t[1]=u);let d=a?`${n.length} 个关键用户路径`:`${n.length} critical user journey${n.length===1?``:`s`}`,f;t[2]===d?f=t[3]:(f=(0,k.jsx)(`p`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,k.jsxs)(`div`,{children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let ee=i!==null,h;t[7]===i?h=t[8]:(h=i===`all`?(0,k.jsx)(g,{className:`size-3 animate-spin`}):(0,k.jsx)(fe,{className:`size-3`}),t[7]=i,t[8]=h);let _=a?`全部重跑`:`Run all`,v;t[9]!==o||t[10]!==ee||t[11]!==h||t[12]!==_?(v=(0,k.jsxs)(x,{variant:`ghost`,className:`h-7 rounded-lg px-2 text-[11px]`,onClick:o,disabled:ee,children:[h,_]}),t[9]=o,t[10]=ee,t[11]=h,t[12]=_,t[13]=v):v=t[13];let y;t[14]!==p||t[15]!==v?(y=(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[p,v]}),t[14]=p,t[15]=v,t[16]=y):y=t[16];let te=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)(g,{className:`size-3.5 animate-spin text-accent`}):n===`passed`?(0,k.jsx)(m,{className:`size-3.5 text-success`}):n===`failed`?(0,k.jsx)(T,{className:`size-3.5 text-danger`}):(0,k.jsx)(pe,{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)(x,{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)(fe,{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)(x,{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)(w,{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 S;t[30]!==te||t[31]!==b?(S=(0,k.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,"aria-label":te,children:b}),t[30]=te,t[31]=b,t[32]=S):S=t[32];let C;return t[33]!==y||t[34]!==S?(C=(0,k.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[y,S]}),t[33]=y,t[34]=S,t[35]=C):C=t[35],C}var He=`allow-scripts allow-forms`;function Ue(e,t){return ne(e,t)}function We(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}=a(),t=e===`new`,n=v(e=>e.language)===`zh`,r=v(e=>e.language),ne=i(),{mutate:T}=te(),pe=_e(e=>e.moveToFront),je=de(e=>e.setPageHeader),Me=de(e=>e.clearPageHeader),{data:D,isLoading:Fe,error:O,mutate:Be}=b(!t&&e?[`local-app`,e]:null,()=>Ee(e)),{data:A,isLoading:Ge,mutate:j}=b(!t&&e?[`local-app-validation`,e]:null,()=>Te(e)),[Ke,qe]=(0,E.useState)(``),[Je,Ye]=(0,E.useState)(``),[M,N]=(0,E.useState)(!1),[Xe,P]=(0,E.useState)(null),[Ze,Qe]=(0,E.useState)(!1),[$e,et]=(0,E.useState)(!1),[tt,nt]=(0,E.useState)(0),[rt,it]=(0,E.useState)(``),[F,at]=(0,E.useState)(!1),[ot,st]=(0,E.useState)(!1),[I,L]=(0,E.useState)(`booting`),[R,ct]=(0,E.useState)(null),[z,lt]=(0,E.useState)(null),[B,ut]=(0,E.useState)({}),[V,H]=(0,E.useState)(`all`),[U,W]=(0,E.useState)(0),[dt,ft]=(0,E.useState)(0),[pt,mt]=(0,E.useState)(null),[G,ht]=(0,E.useState)(null),[gt,_t]=(0,E.useState)([]),[vt,yt]=(0,E.useState)(!1),bt=(0,E.useRef)(new Set),K=(0,E.useRef)(null),xt=(0,E.useRef)(null),St=(0,E.useRef)(null),q=(0,E.useRef)(null),J=(0,E.useRef)(``),Y=A?.acceptanceScenarios??[],X=(0,E.useMemo)(()=>{if(!Y.length)return null;let e=Y.map(e=>B[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,B]),Z=(0,E.useMemo)(()=>{if(!z)return null;if(!A?.acceptanceScenarioCount)return z;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=[...z.checks,t];return{status:n.some(e=>e.status===`failed`)?`failed`:`passed`,checks:n,interactiveCount:z.interactiveCount}},[z,X,A?.acceptanceScenarioCount]),Ct=(0,E.useCallback)(async(e,t)=>{let n=Ne(await me(e.projectId))??await ue(e.projectId,`coder`);bt.current.add(n.key),ne(Pe(n.key,t))},[ne]),wt=(0,E.useCallback)(async(e=!0)=>{if(!D)return null;st(!0);try{let t=await Te(D.id);return await j(t,{revalidate:!1}),e&&(q.current=t.sourceHash??null,H(`all`),W(0),nt(e=>e+1)),t}catch(e){return P(e instanceof Error?e.message:String(e)),null}finally{st(!1)}},[D,j]);(0,E.useEffect)(()=>{if(!D)return;let e=!1;me(D.projectId).then(t=>{e||(bt.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||!bt.current.has(t)||(K.current!==null&&window.clearTimeout(K.current),K.current=window.setTimeout(()=>{K.current=null,wt(!0)},750))};return window.addEventListener(`session-transcript-updated`,t),()=>{e=!0,window.removeEventListener(`session-transcript-updated`,t),K.current!==null&&window.clearTimeout(K.current)}},[D,wt]),(0,E.useEffect)(()=>{_t(D?.acceptanceRuns??[])},[D?.acceptanceRuns]),(0,E.useEffect)(()=>{q.current=null},[D?.id]),(0,E.useEffect)(()=>{!A?.sourceHash||q.current||(q.current=A.sourceHash,H(`all`),W(0),nt(e=>e+1))},[A?.sourceHash]),(0,E.useLayoutEffect)(()=>{if(!D)return;L(`booting`),ct(null),lt(null),ht(null),yt(!1),J.current=``;let e=window.setTimeout(()=>L(e=>e===`failed`?e:`timeout`),7e3),t=xt.current?ze(xt.current,t=>{let n=Ie(t);if(n){if(n.type===`ready`){L(e=>e===`failed`?e:`healthy`);return}if(n.type===`acceptance`){window.clearTimeout(e),lt(n.detail),ht(q.current);return}n.type!==`criteria`&&(window.clearTimeout(e),ct(n.detail),L(`failed`))}}):()=>{};return()=>{window.clearTimeout(e),t()}},[D,tt]),(0,E.useLayoutEffect)(()=>{if(!D||A?.status!==`healthy`||!Y.length){mt(null);return}let e=V===`all`?Y[U]:Y.find(e=>e.id===V),t=e?[e]:[];if(!t.length)return;mt(V),ut(e=>{if(V===`all`&&U===0)return{};let t={...e};return delete t[V],t});let r=!1,i=e=>{ut(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}),mt(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=St.current?ze(St.current,e=>{let t=Ie(e);t&&(t.type===`ready`?r=!0:t.type===`criteria`?(window.clearTimeout(a),ut(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}),V===`all`&&U+1<Y.length?(W(e=>e+1),ft(e=>e+1)):mt(null)):t.type===`error`&&(window.clearTimeout(a),i(Re(t.detail))))}):()=>{};return()=>{window.clearTimeout(a),o()}},[Y,D,dt,V,U,tt,A?.status,n]),(0,E.useEffect)(()=>{if(!D||!Z||!G||G!==A?.sourceHash)return;let e=`${D.id}:${G}:${JSON.stringify(Z)}`;J.current!==e&&(J.current=e,yt(!0),Ce(D.id,G,Z).then(t=>{J.current===e&&_t(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=``,P(t instanceof Error?t.message:String(t)))}).finally(()=>{J.current===e&&yt(!1)}))},[Z,G,D,A?.sourceHash]);let Q=(0,E.useCallback)(async e=>{if(D){at(!0),P(null);try{await Ct(D,e)}catch(e){P(e instanceof Error?e.message:String(e)),at(!1)}}},[D,Ct]);(0,E.useLayoutEffect)(()=>(je({startExtra:(0,k.jsx)(o,{to:`/local-apps`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`返回本地应用`:`Back to local apps`,children:(0,k.jsx)(oe,{className:`size-4`})}),main:(0,k.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:D?.name||(n?`创建本地应用`:`Create local app`)}),end:D?(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-9`,children:(0,k.jsxs)(o,{to:`/projects/${encodeURIComponent(D.projectId)}`,children:[(0,k.jsx)(ae,{className:`size-4`}),`Project`]})}),(0,k.jsxs)(x,{className:`h-9`,onClick:()=>void Q(),disabled:F,children:[F?(0,k.jsx)(g,{className:`size-4 animate-spin`}):(0,k.jsx)(w,{className:`size-4`}),n?`继续开发`:`Continue building`]})]}):null}),()=>Me()),[D,F,Me,Q,je,n]);async function Tt(e){e.preventDefault(),N(!0),P(null);try{let e=await Ae({name:Ke,idea:Je});await T(`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 Ct(e,t)}catch{ne(`/local-apps/${encodeURIComponent(e.id)}`,{replace:!0})}}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Et(){if(D){N(!0),P(null);try{let e=await Oe(D.id);await Be(e,{revalidate:!1}),await j(),await Promise.all([T(`local-apps-list`),T(`gateway-extensions-list`)]),pe(`ext:${e.extensionId}:app`),Qe(!1)}catch(e){P(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Dt(e,t=!1){N(!0),P(null);try{let n=await e();return await Be(n,{revalidate:!1}),await j(),await Promise.all([T(`local-apps-list`),T(`gateway-extensions-list`)]),t&&pe(`ext:${n.extensionId}:app`),!0}catch(e){return P(e instanceof Error?e.message:String(e)),!1}finally{N(!1)}}async function Ot(e){D&&await Dt(()=>ke(D.id,e),e)}async function kt(e){D&&await Dt(()=>De(D.id,e),!0)}async function At(){D&&await Dt(()=>we(D.id))&&et(!1)}function jt(){let e=Array.from(new Set([...A?.issues.map(e=>e.message)??[],...R?[Re(R)]:[],...Z?.checks.filter(e=>e.status===`failed`&&e.id!==`criteria`).map(e=>e.message)??[],...Object.values(B).filter(e=>e.status===`failed`).map(e=>`${e.name}: ${e.failureKind===`runner`?`[验收执行器] `:``}${e.message}`),...I===`timeout`?[n?`预览在 7 秒内未完成启动,可能存在白屏或阻塞。`:`The preview did not finish booting within 7 seconds and may be blank or blocked.`]:[]]));if(!e.length)return;let t=e.map(e=>`- ${e}`).join(`
2
- `);Q(n?`请修复当前本地应用草稿的校验问题,保持扩展 ID 和已安装版本不变。先复现并判断问题来自应用行为还是验收执行器,不要通过弱化断言绕过问题。修复后运行完整校验。\n\n${t}`:`Fix the current local-app draft validation issues without changing the extension id or installed release. Reproduce first and determine whether each issue comes from app behavior or the acceptance runner; do not weaken assertions to bypass it. Run the full validation afterward.\n\n${t}`)}function Mt(){H(`all`),W(0),ft(e=>e+1)}function Nt(e){H(e),W(0),ft(e=>e+1)}function Pt(e,t){let r=t.failureKind===`runner`?n?`验收执行器`:`acceptance runner`:n?`产品场景`:`product scenario`;Q(n?`请修复本地应用的${r}问题“${e.name}”。当前失败信息:${t.message}\n\n保持扩展 ID 和场景原意不变;先复现并判断问题来自应用行为还是验收执行器,不要通过弱化断言绕过问题。修复后运行完整校验。`:`Fix the local-app ${r} issue "${e.name}". Current failure: ${t.message}\n\nPreserve the extension id and scenario intent. Reproduce first and determine whether the issue comes from app behavior or the runner; do not weaken assertions to bypass it. Run the full validation afterward.`)}let Ft=gt.findIndex(e=>We(e,G,Z)),$=Ft>=0?gt[Ft]:null,It=Ft>=0?gt[Ft+1]??null:gt[0]??null,Lt=Le(Z),Rt=It?It.checks.filter(e=>e.status===`failed`).map(e=>e.message):[],zt=A?.status===`failed`||I===`failed`||I===`timeout`||Z?.status===`failed`||Object.values(B).some(e=>e.status===`failed`),Bt=Rt.filter(e=>!Lt.includes(e)).length;async function Vt(){let e=await wt(!1);if(e?.status===`healthy`&&e.sourceHash!==G){q.current=e.sourceHash??null,W(0),nt(e=>e+1);return}e?.status===`healthy`&&I===`healthy`&&Z?.status===`passed`&&$&&$.sourceHash===e.sourceHash&&Qe(!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:`mx-auto grid w-full max-w-6xl 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:Tt,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)(he,{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)(xe,{value:Ke,onChange:e=>qe(e.target.value),suggestion:Se(n?`例如:阅读清单`:`e.g. Reading list`),onAcceptSuggestion:qe,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)(be,{value:Je,onChange:e=>Ye(e.target.value),suggestion:Se(n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`),onAcceptSuggestion:Ye,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…`})]}),Xe?(0,k.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:Xe}):null,(0,k.jsxs)(x,{type:`submit`,variant:`primary`,className:`mt-5 h-10`,disabled:M||!Ke.trim()||!Je.trim(),children:[M?(0,k.jsx)(g,{className:`size-4 animate-spin`}):(0,k.jsx)(w,{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)(re,{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.`})]})})]})}):Fe?(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)(S,{className:`rounded-xl`}),(0,k.jsx)(S,{className:`rounded-xl`}),(0,k.jsx)(S,{className:`rounded-xl`})]}):O||!D?(0,k.jsx)(`div`,{className:`m-6 rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,children:O instanceof Error?O.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 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)(he,{className:`size-4`}),n?`创作对话`:`Build conversation`]}),(0,k.jsx)(`div`,{className:`mt-4 rounded-xl bg-surface-panel p-3 text-sm leading-6 text-fg`,children:D.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)(m,{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(rt)},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)(be,{id:`local-app-change-request`,value:rt,onChange:e=>it(e.target.value),suggestion:Se(n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`),onAcceptSuggestion:it,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)(x,{type:`submit`,className:`mt-2 w-full`,disabled:F||!rt.trim(),children:[F?(0,k.jsx)(g,{className:`size-4 animate-spin`}):(0,k.jsx)(w,{className:`size-4`}),n?`让 Coder 修改`:`Ask Coder to update`]})]}),(0,k.jsxs)(x,{variant:`ghost`,className:`mt-2 w-full`,onClick:()=>void Q(),disabled:F,children:[(0,k.jsx)(ae,{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 ${A?.status===`failed`||I===`failed`||I===`timeout`||Z?.status===`failed`?`bg-danger`:A?.status===`healthy`&&I===`healthy`&&Z?.status===`passed`&&$?.sourceHash===A.sourceHash&&!vt?`bg-success`:`bg-fg-subtle`}`}),I===`failed`||I===`timeout`?n?`预览运行异常`:`Preview runtime issue`:A?.status===`failed`||Z?.status===`failed`?n?`自动验收未通过`:`Acceptance needs attention`:I===`booting`||!Z?n?`自动验收中`:`Running acceptance`:vt||$?.sourceHash!==A?.sourceHash?n?`正在保存验收快照`:`Saving acceptance snapshot`:n?`草稿已通过验收`:`Draft accepted`]}),(0,k.jsxs)(x,{variant:`ghost`,className:`h-8 px-2`,onClick:()=>void wt(!0),disabled:ot,children:[ot?(0,k.jsx)(g,{className:`size-3.5 animate-spin`}):(0,k.jsx)(fe,{className:`size-3.5`}),n?`重新验收`:`Run again`]})]}),(0,k.jsx)(`iframe`,{ref:xt,title:`${D.name} preview`,src:y(D.previewUrl),sandbox:He,className:`min-h-0 w-full flex-1 bg-white`,onError:()=>{ct({kind:`script_error`,message:`Preview document failed to load`}),L(`failed`)}},tt),A?.status===`healthy`&&A.acceptanceScenarioCount>0?(0,k.jsx)(`iframe`,{ref:St,title:`${D.name} acceptance runner`,src:`${y(D.previewUrl)}?xopcAcceptance=1&xopcScenario=${encodeURIComponent(V===`all`?Y[U]?.id??``:V)}`,sandbox:He,"aria-hidden":`true`,tabIndex:-1,className:`pointer-events-none fixed left-[-200vw] top-0 h-[720px] w-[1024px] opacity-0`},`criteria-${tt}-${dt}-${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:D.installationState===`not_installed`?n?`尚未安装`:`Not installed`:D.enabled?n?`版本 ${D.activeVersion} 正在使用`:`Version ${D.activeVersion} is active`:n?`已禁用,版本仍保留`:`Disabled, release retained`})]}),(0,k.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full ${D.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`,D.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:D.activeVersion?`v${D.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)(ie,{className:`size-4 text-accent`}),n?`草稿检查`:`Draft checks`]}),Ge||ot?(0,k.jsx)(g,{className:`size-3.5 animate-spin text-fg-muted`}):A?.status===`healthy`?(0,k.jsx)(m,{className:`size-4 text-success`}):(0,k.jsx)(ce,{className:`size-4 text-danger`})]}),A?(0,k.jsxs)(`div`,{className:`mt-2`,children:[(0,k.jsx)(`p`,{className:`text-xs leading-5 ${A.status===`healthy`?`text-fg-muted`:`text-danger`}`,children:A.status===`healthy`?A.hasDraftChanges?n?`${A.changedFileCount} 个文件有改动,可以安装新版本。`:`${A.changedFileCount} changed files are ready for a new release.`:n?`草稿与当前安装版本一致。`:`Draft matches the installed release.`:A.issues[0]?.message}),A.changedFiles.length?(0,k.jsx)(`ul`,{className:`mt-2 space-y-1`,children:A.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,A.changedFileCount>4?(0,k.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-subtle`,children:n?`还有 ${A.changedFileCount-4} 个文件`:`${A.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 ${I===`healthy`?`bg-success`:I===`booting`?`bg-fg-subtle`:`bg-danger`}`}),n?`预览运行`:`Preview runtime`]}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 ${I===`failed`||I===`timeout`?`text-danger`:`text-fg-muted`}`,children:R?Re(R):I===`healthy`?n?`已成功启动,未发现未捕获异常。`:`Started successfully with no uncaught errors.`:I===`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:A?.acceptanceScenarioCount?n?`正在检查页面基础质量和 ${A.acceptanceScenarioCount} 个产品场景。`:`Checking page quality and ${A.acceptanceScenarioCount} product scenario(s).`:n?`正在检查页面内容和基础交互。`:`Checking rendered content and basic interaction.`}),vt?(0,k.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,k.jsx)(g,{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)(Ve,{scenarios:Y,results:B,runningTarget:pt,zh:n,onRunAll:Mt,onRunScenario:Nt,onAskCoder:Pt})]}),zt?(0,k.jsxs)(x,{className:`mt-3 w-full`,onClick:jt,disabled:F,children:[(0,k.jsx)(w,{className:`size-4`}),n?`让 Coder 修复`:`Ask Coder to fix`]}):null]}):(0,k.jsx)(S,{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)(ge,{className:`size-4 text-accent`}),n?`权限`:`Permissions`]}),(0,k.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(A?.permissions??D.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)(x,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void Vt(),disabled:M||Ge||ot||vt||A?.status===`failed`||I!==`healthy`||Z?.status!==`passed`||!$||$.sourceHash!==A?.sourceHash||D.installationState===`installed`&&A?.hasDraftChanges===!1,children:D.installationState===`installed`?n?`安装当前更新`:`Install current update`:n?`添加到左侧导航`:`Add to sidebar`}),D.installationState===`installed`?(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,k.jsxs)(x,{className:`min-w-0 flex-1`,onClick:()=>void Ot(!D.enabled),disabled:M,children:[D.enabled?(0,k.jsx)(C,{className:`size-4`}):(0,k.jsx)(se,{className:`size-4`}),D.enabled?n?`禁用`:`Disable`:n?`启用`:`Enable`]}),(0,k.jsx)(x,{variant:`ghost`,className:`text-danger hover:text-danger`,onClick:()=>et(!0),disabled:M,"aria-label":n?`卸载应用`:`Uninstall app`,children:(0,k.jsx)(le,{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)(ve,{className:`size-4`}),n?`版本历史`:`Release history`]}),D.releases.length?(0,k.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,children:D.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:Ue(e.createdAt,r)})]}),e.isActive?null:(0,k.jsxs)(x,{variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>void kt(e.id),disabled:M,children:[(0,k.jsx)(ye,{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.`})]}),Xe?(0,k.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-danger`,role:`alert`,children:Xe}):null]}),(0,k.jsx)(p,{open:Ze,onOpenChange:Qe,children:(0,k.jsxs)(u,{children:[(0,k.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,k.jsxs)(d,{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-base 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)(f,{className:`text-base font-semibold text-fg`,children:n?`确认安装到 XOPC`:`Confirm installation`}),(0,k.jsx)(c,{className:`mt-1 text-sm text-fg-muted`,children:n?`当前草稿会成为左侧导航中的可用版本。`:`The current draft will become the version available in the sidebar.`})]}),(0,k.jsx)(l,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,k.jsx)(_,{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:D.name}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:D.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:A?.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)(m,{className:`size-3.5`}),n?`已通过并保存`:`Passed and saved`]})]})]}),A?.changedFiles.length?(0,k.jsx)(`ul`,{className:`mt-3 space-y-1`,children:A.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:(A?.permissions??D.permissions).map(e=>(0,k.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,k.jsx)(ee,{className:`size-4 text-success`}),e,D.installationState===`installed`&&A?.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))}),D.installationState===`installed`&&A?.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)(l,{asChild:!0,children:(0,k.jsx)(x,{children:n?`取消`:`Cancel`})}),(0,k.jsxs)(x,{variant:`primary`,onClick:()=>void Et(),disabled:M,children:[M?(0,k.jsx)(g,{className:`size-4 animate-spin`}):(0,k.jsx)(h,{className:`size-4`}),n?`确认安装`:`Install`]})]})]})]})}),(0,k.jsx)(p,{open:$e,onOpenChange:et,children:(0,k.jsxs)(u,{children:[(0,k.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,k.jsxs)(d,{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-base 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)(f,{className:`text-base font-semibold text-fg`,children:n?`卸载当前应用?`:`Uninstall this app?`}),(0,k.jsx)(c,{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)(l,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,k.jsx)(_,{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:D.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)(l,{asChild:!0,children:(0,k.jsx)(x,{children:n?`取消`:`Cancel`})}),(0,k.jsxs)(x,{variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger`,onClick:()=>void At(),disabled:M,children:[M?(0,k.jsx)(g,{className:`size-4 animate-spin`}):(0,k.jsx)(le,{className:`size-4`}),n?`卸载但保留 Project`:`Uninstall and keep Project`]})]})]})]})})]})}export{A as LocalAppWorkbenchPage};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-CVND3M6r.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-CfyyA9-g.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-BvLh9GaE.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/dist-DBS3OB8K.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-DIcfrLmG.js","assets/dist-CpzYSoz7.js","assets/chunk-KS7C4IRE-Cq1tE_3b.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/locale-store-BQ2HKTWb.js","assets/messages-BRjoarIr.js","assets/cn-JdwAhgNB.js","assets/product-delivery-CCC4FJ3Y.js","assets/schemas-BaskVM5g.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-Y68dCxuc.css","assets/dist-DLmwHyAh.js","assets/vendor-swr-BIWyz7Rc.js","assets/check-DUBLcKHA.js","assets/popover-select-CKBYnT3c.js","assets/skeleton-BwbyijEw.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/settings-shell-layer-context-DCp6ykjQ.js","assets/circle-check-C23XjkUj.js","assets/copy-Dv6d4Dvw.js","assets/external-link-DjqjBmc3.js","assets/globe-DSSGFWFn.js","assets/loader-circle-CifKLtgG.js","assets/middleware-Pd0e8Igk.js","assets/files-Be5viEFY.js","assets/tool-activity-R8V9l6nk.js","assets/button-B11EPpor.js","assets/registry-api-CwveUfe8.js","assets/gateway-startup-retry-DrbIzFyB.js","assets/config-reload-event-Bjh2zoKp.js","assets/gateway-config-swr-bjzk_4hn.js","assets/electron-env-DH5wF8X8.js","assets/activity-store-DcwCSY6s.js","assets/theme-store-BejLVjIT.js","assets/index-7PZ6jmhy.css","assets/vendor-codemirror-DFxP3B9T.js","assets/with-selector-aYPsXwdl.js","assets/block-editor-D4ZIVQbk.css","assets/markdown-editor-BhBJANcx.js","assets/code-editor-CXIH8jQw.js","assets/languages-BFe8nIOO.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{d as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./check-DUBLcKHA.js";import{n as m,r as h}from"./popover-select-CKBYnT3c.js";import{t as g}from"./circle-check-C23XjkUj.js";import{t as _}from"./copy-Dv6d4Dvw.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./loader-circle-CifKLtgG.js";import{t as b}from"./x-B_N4OPjy.js";import{t as x}from"./copy-to-clipboard-HOJ79TWv.js";import{t as S}from"./messages-BRjoarIr.js";import{d as C,n as w}from"./locale-store-BQ2HKTWb.js";import{t as T}from"./cn-JdwAhgNB.js";import{i as E}from"./vendor-swr-BIWyz7Rc.js";import{t as D}from"./button-B11EPpor.js";import{i as O}from"./theme-store-BejLVjIT.js";import{t as k}from"./skeleton-BwbyijEw.js";import{$n as A,An as j,Bn as M,Ci as N,Cn as P,Dn as F,En as I,Gi as L,Gn as R,Gs as z,Hl as ee,Hn as te,Il as B,In as ne,Jt as re,Ks as ie,Mc as ae,Mu as oe,Nn as se,Nu as V,On as ce,Pn as le,Qn as H,Sn as ue,So as U,Tn as de,Uc as fe,Un as pe,Us as me,Vl as he,Vn as ge,Wn as _e,Ws as ve,Zl as ye,Zn as be,_i as W,_n as xe,a as Se,ao as Ce,bc as G,bi as K,bn as we,c as q,ec as Te,er as Ee,gi as De,gn as Oe,hc as ke,ic as Ae,jn as je,kn as Me,l as Ne,mu as Pe,nr as Fe,o as Ie,ol as J,qc as Le,qn as Re,rr as Y,s as ze,uc as Be,vn as Ve,wi as He,xl as Ue,xn as We,yn as Ge,yt as Ke}from"./index-CfyyA9-g.js";var X=n(),Z=e(t(),1),Q=r(),qe=(0,Z.createContext)(null);function Je(){let e=(0,X.c)(1),t=(0,Z.useContext)(qe);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:Ye},e[0]=t):t=e[0],t}return t}function Ye(){}function Xe(e){let t=(0,X.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[a,s]=(0,Z.useState)(null),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(e,t)=>{s({src:e,alt:t})},t[0]=p):p=t[0];let m=p,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h={openImage:m},t[1]=h):h=t[1];let g=h,_=a!==null,v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{e||s(null)},t[2]=v):v=t[2];let y;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(o,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=y):y=t[3];let x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=T(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=x):x=t[4];let S=a?.alt||`Image preview`,C;t[5]===S?C=t[6]:(C=(0,Q.jsx)(d,{className:`sr-only`,children:S}),t[5]=S,t[6]=C);let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(b,{className:`size-5`,"aria-hidden":!0}),t[7]=w):w=t[7];let E;t[8]===i?E=t[9]:(E=(0,Q.jsx)(c,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":i,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:w})}),t[8]=i,t[9]=E);let D;t[10]===a?D=t[11]:(D=a?(0,Q.jsx)(`img`,{src:a.src,alt:a.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=a,t[11]=D);let O;t[12]!==E||t[13]!==D||t[14]!==C?(O=(0,Q.jsxs)(l,{children:[y,(0,Q.jsxs)(u,{className:x,"aria-describedby":void 0,children:[C,E,D]})]}),t[12]=E,t[13]=D,t[14]=C,t[15]=O):O=t[15];let k;t[16]!==O||t[17]!==_?(k=(0,Q.jsx)(f,{open:_,onOpenChange:v,children:O}),t[16]=O,t[17]=_,t[18]=k):k=t[18];let A;return t[19]!==n||t[20]!==k?(A=(0,Q.jsxs)(qe.Provider,{value:g,children:[n,k]}),t[19]=n,t[20]=k,t[21]=A):A=t[21],A}var $=6e4,Ze=36e5,Qe=864e5;function $e(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function et(e,t,n){let r=t-e;if(r<$)return n.justNow;if(r<Ze){let e=Math.floor(r/$);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=$e(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(e>=i-Qe)return n.yesterday+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(r<7*Qe){let e=Math.floor(r/Qe);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(n.locale,{month:`short`,day:`numeric`})}function tt(e,t,n){let r=$e(t);if(e>=r)return n.today;if(e>=r-Qe)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 nt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function rt(e){let t=(0,X.c)(45),{title:n,description:r,prompt:i,coverage:o,className:s,variant:c}=e,l=c===void 0?`card`:c,u=w(ot),d=S(u).automations.suggestions,f=S(u).automations,p=a(),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=m):m=t[0];let{data:h}=E(o?`automation-suggestion-coverage`:null,at,m),_=o?h?.automations.find(e=>q(e,o)):void 0,v=_?Ie(_,f):[];if(l===`titleAction`){if(_){let e;t[1]===s?e=t[2]:(e=T(`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`,s),t[1]=s,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(g,{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]===p?r=t[5]:(r=()=>p(`/automations`),t[4]=p,t[5]=r),(0,Q.jsxs)(`section`,{className:e,children:[n,(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:d.coveredTitle}),(0,Q.jsx)(D,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:d.manage})]})}let e;t[6]===s?e=t[7]:(e=T(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,s),t[6]=s,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(J,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let o;t[9]!==r||t[10]!==n?(o=(0,Q.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]=o):o=t[11];let c;t[12]!==p||t[13]!==i?(c=()=>{p(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[12]=p,t[13]=i,t[14]=c):c=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,Q.jsxs)(`section`,{className:e,children:[a,o,(0,Q.jsxs)(D,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[l,d.setup]})]})}if(_){let e;t[16]===s?e=t[17]:(e=T(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,s),t[16]=s,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(g,{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]===p?r=t[20]:(r=()=>p(`/automations`),t[19]=p,t[20]=r);let i;return t[21]!==d||t[22]!==r?(i=(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsx)(D,{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,Q.jsxs)(`section`,{className:e,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:d.coveredTitle}),(0,Q.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:ze(d.coveredDescription,{name:_.name})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:f.explain.whyCovered}),(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:v.map(it)})]}),i]})}let y;t[24]===s?y=t[25]:(y=T(`rounded-lg bg-surface-panel p-3 shadow-surface`,s),t[24]=s,t[25]=y);let b;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(J,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=b):b=t[26];let x;t[27]===n?x=t[28]:(x=(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=x);let C;t[29]===r?C=t[30]:(C=(0,Q.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=C);let O;t[31]!==x||t[32]!==C?(O=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[b,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,C]})]}),t[31]=x,t[32]=C,t[33]=O):O=t[33];let k;t[34]!==p||t[35]!==i?(k=()=>{p(`/automations?${new URLSearchParams({draft:i,autogenerate:`1`}).toString()}`)},t[34]=p,t[35]=i,t[36]=k):k=t[36];let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),t[37]=A):A=t[37];let j;t[38]!==d.create||t[39]!==k?(j=(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(D,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:k,children:[A,d.create]})}),t[38]=d.create,t[39]=k,t[40]=j):j=t[40];let M;return t[41]!==j||t[42]!==y||t[43]!==O?(M=(0,Q.jsxs)(`section`,{className:y,children:[O,j]}),t[41]=j,t[42]=y,t[43]=O,t[44]=M):M=t[44],M}function it(e){return(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(){return Ne.list()}function ot(e){return e.language}function st(e){let t=(0,X.c)(4),{values:n}=e;if(n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.map(ct),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Q.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:r}),t[2]=r,t[3]=i),i}function ct(e,t){return(0,Q.jsx)(`li`,{children:e},`${t}:${e}`)}function lt(e){let t=(0,X.c)(10),{noteId:n,attachmentId:r,label:i,unavailableLabel:a}=e,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),u,d;if(t[0]!==r||t[1]!==n?(u=()=>{let e=!1,t=!1;return s(null),l(!1),Fe(n,r).then(i=>{if(e=!0,t){Y(n,r);return}s(i)}).catch(()=>{t||l(!0)}),()=>{t=!0,e&&Y(n,r)}},d=[r,n],t[0]=r,t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),(0,Z.useEffect)(u,d),c){let e;return t[4]===a?e=t[5]:(e=(0,Q.jsx)(`p`,{className:`text-xs text-danger`,children:a}),t[4]=a,t[5]=e),e}if(!o){let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(k,{className:`h-10 w-full max-w-md`}),t[6]=e):e=t[6],e}let f;return t[7]!==i||t[8]!==o?(f=(0,Q.jsx)(`audio`,{controls:!0,preload:`metadata`,src:o,className:`w-full max-w-md`,"aria-label":i}),t[7]=i,t[8]=o,t[9]=f):f=t[9],f}function ut(e){let t=(0,X.c)(39),{noteId:n}=e,r=S(w(pt)).notes.discussionCapture,i,a;t[0]===n?(i=t[1],a=t[2]):(i=[`note-discussion-document`,n],a=()=>re(n),t[0]=n,t[1]=i,t[2]=a);let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[3]=o):o=t[3];let{data:s,mutate:c}=E(i,a,o),l,u;if(t[4]===c?(l=t[5],u=t[6]):(l=()=>{let e=e=>{let t=e.detail;t&&c(e=>{if(!e||e.discussion.id!==t.discussionId)return e;let n=e.transcript.segments.filter(e=>e.sequence!==t.segment.sequence).concat(t.segment).sort(ft);return{...e,discussion:{...e.discussion,transcriptRevision:t.transcriptRevision},transcript:{...e.transcript,revision:t.transcriptRevision,segments:n,text:t.text,stats:t.stats}}},{revalidate:!1})},t=()=>void c();return window.addEventListener(`discussion-segment-updated`,e),window.addEventListener(`discussion-updated`,t),()=>{window.removeEventListener(`discussion-segment-updated`,e),window.removeEventListener(`discussion-updated`,t)}},u=[c],t[4]=c,t[5]=l,t[6]=u),(0,Z.useEffect)(l,u),!s)return null;let{discussion:d,transcript:f}=s,p=s.organization?.organization,m=[`stopping`,`sealing`,`organizing`].includes(d.status),h=f.stats.uploaded+f.stats.transcribing,_=f.stats.failed>0?r.failedSegments.replace(`{{count}}`,String(f.stats.failed)):h>0?r.processingSegments.replace(`{{count}}`,String(h)):m?r.finalizing:d.status===`completed`?r.transcriptReady:null,v;t[7]!==r.actionItems||t[8]!==r.decisions||t[9]!==r.openQuestions||t[10]!==r.organization||t[11]!==r.risks||t[12]!==p?(v=p?(0,Q.jsxs)(`section`,{className:`border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-accent-fg`,children:[(0,Q.jsx)(Ae,{className:`size-4`,"aria-hidden":!0}),r.organization]}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:p.summary}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 text-sm leading-6 text-fg sm:grid-cols-2 xl:grid-cols-1`,children:[p.decisions.length>0?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium`,children:r.decisions}),(0,Q.jsx)(st,{values:p.decisions})]}):null,p.actionItems.length>0?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium`,children:r.actionItems}),(0,Q.jsx)(st,{values:p.actionItems.map(dt)})]}):null,p.risks.length>0?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium`,children:r.risks}),(0,Q.jsx)(st,{values:p.risks})]}):null,p.openQuestions.length>0?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium`,children:r.openQuestions}),(0,Q.jsx)(st,{values:p.openQuestions})]}):null]})]}):null,t[7]=r.actionItems,t[8]=r.decisions,t[9]=r.openQuestions,t[10]=r.organization,t[11]=r.risks,t[12]=p,t[13]=v):v=t[13];let y;t[14]!==r.recordingAudio||t[15]!==r.recordingUnavailable||t[16]!==d.audioAttachmentId||t[17]!==n?(y=d.audioAttachmentId?(0,Q.jsxs)(`section`,{className:`border-b border-edge-subtle px-6 py-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(fe,{className:`size-4 text-accent`,"aria-hidden":!0}),r.recordingAudio]}),(0,Q.jsx)(lt,{noteId:n,attachmentId:d.audioAttachmentId,label:r.recordingAudio,unavailableLabel:r.recordingUnavailable})]}):null,t[14]=r.recordingAudio,t[15]=r.recordingUnavailable,t[16]=d.audioAttachmentId,t[17]=n,t[18]=y):y=t[18];let b;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(fe,{className:`size-4 text-accent`,"aria-hidden":!0}),t[19]=b):b=t[19];let x=d.status===`recording`?r.draftTranscript:r.fullTranscript,C;t[20]===x?C=t[21]:(C=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[b,x]}),t[20]=x,t[21]=C);let T;t[22]===d.status?T=t[23]:(T=d.status===`needs_attention`?(0,Q.jsx)(me,{className:`size-3.5 text-danger`}):d.status===`completed`?(0,Q.jsx)(g,{className:`size-3.5 text-success`}):null,t[22]=d.status,t[23]=T);let D=d.status===`needs_attention`?d.failureMessage:_,O;t[24]!==T||t[25]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[T,D]}),t[24]=T,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==C||t[28]!==O?(k=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[C,O]}),t[27]=C,t[28]=O,t[29]=k):k=t[29];let A=f.text||r.waitingTranscript,j;t[30]===A?j=t[31]:(j=(0,Q.jsx)(`div`,{className:`mt-3 max-h-48 overflow-y-auto whitespace-pre-wrap text-sm leading-6 text-fg-muted xl:max-h-none xl:overflow-visible`,children:A}),t[30]=A,t[31]=j);let M;t[32]!==k||t[33]!==j?(M=(0,Q.jsxs)(`section`,{className:`px-6 py-4`,children:[k,j]}),t[32]=k,t[33]=j,t[34]=M):M=t[34];let N;return t[35]!==M||t[36]!==v||t[37]!==y?(N=(0,Q.jsxs)(`aside`,{className:`max-h-[45%] shrink-0 overflow-y-auto border-b border-edge-subtle xl:h-full xl:max-h-none xl:w-[clamp(20rem,34%,27rem)] xl:border-r xl:border-b-0`,children:[v,y,M]}),t[35]=M,t[36]=v,t[37]=y,t[38]=N):N=t[38],N}function dt(e){return e.title}function ft(e,t){return e.sequence-t.sequence}function pt(e){return e.language}var mt={edit:ae,ai_edit:Ae,sync:G,restore:V};function ht(e,t){return{edit:t.triggerEdit,ai_edit:t.triggerAiEdit,sync:t.triggerSync,restore:t.triggerRestore}[e]??e}function gt({noteId:e,activeTimestamp:t,onSelect:n,onClose:r,onRestored:i}){let a=w(e=>e.language),o=S(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:C(a)},{data:c}=E(e?[`note-history`,e]:null,()=>je(e)),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),h=(0,Z.useCallback)(async t=>{u(!0),m(null);try{await _e(e,t),f(null),i()}catch{m(o.restoreFailed)}finally{u(!1)}},[e,o.restoreSuccess,o.restoreFailed,i]),g=Date.now();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(Ue,{className:`size-4`,"aria-hidden":!0}),o.history]}),(0,Q.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,Q.jsx)(b,{className:`size-4`,"aria-hidden":!0})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p?(0,Q.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,Q.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>{let r=mt[e.trigger]??ae,i=t===e.timestamp,a=d===e.timestamp;return(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:T(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:ht(e.trigger,o)}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:et(e.timestamp,g,s)})]}),e.snippet&&(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,Q.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:a?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:o.restoreConfirm}),(0,Q.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,Q.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,Q.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,Q.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:o.historyEmpty}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:o.historyEmptyDescription})]})]})]})}function _t({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:o,openingChat:s,onOpenChat:c,onOpenNewChat:l}){let u=S(w(e=>e.language)).notes,d=a(),f=t?.aiDeep?.catalysis,p=f?.report??null,[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),{data:v,mutate:y,isLoading:b}=E(e?[`note-agent-context-status`,e]:null,()=>ce(e),{revalidateOnFocus:!1}),x=(0,Z.useCallback)(async()=>{if(!g){_(!0),h(null);try{await y(()=>M(e),{revalidate:!1})}catch(e){h(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{_(!1)}}},[g,y,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),C=(0,Z.useCallback)(async t=>{try{await ge(e,t)}catch{}},[e]);return(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ae,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,Q.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,Q.jsx)(oe,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,Q.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),v?(0,Q.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:b||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,Q.jsx)(`span`,{className:T(`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,Q.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,Q.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,Q.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:v.attachments.slice(0,5).map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,Q.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-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:p?u.recatalyze:u.catalyzeAction}),p?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:p.valueHypothesis})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:p.targetUsers.slice(0,5).map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.keyQuestions.slice(0,3).map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,Q.jsx)(`span`,{children:e})]},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,Q.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.mvpPath.slice(0,3).map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,Q.jsx)(`span`,{children:e})]},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.risks.slice(0,3).map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,Q.jsx)(`span`,{children:e})]},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:p.nextActions.slice(0,4).map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,Q.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(p.confidence*100)))}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void C(`helpful`),className:T(`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,Q.jsx)(z,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void C(`not_helpful`),className:T(`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,Q.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,Q.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,Q.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(Le,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:c,disabled:s,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:s?u.openingChat:u.openThread}),(0,Q.jsx)(`button`,{type:`button`,onClick:l,disabled:s,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),o.length>0?(0,Q.jsx)(`div`,{className:`space-y-2`,children:o.slice(0,5).map(e=>(0,Q.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,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,Q.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 vt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function yt({open:e,onOpenChange:t,note:n}){let r=w(e=>e.language)===`zh`,i=r?Ct:wt,{data:a,mutate:g}=E(e?[`note-shares`,n.id]:null,()=>se(n.id)),S=E(e?`hosted-share-auth-status`:null,K),C=S.data===!0,T=E(e&&C?`hosted-publication-capabilities`:null,W),O=T.data?.publishing.allowed===!0,k=E(e&&C?[`hosted-note-publications`,n.id]:null,()=>j(n.id)),[A,M]=(0,Z.useState)(new Set),[F,I]=(0,Z.useState)(`86400000`),[L,R]=(0,Z.useState)(``),[z,ee]=(0,Z.useState)(``),[B,ne]=(0,Z.useState)(`hosted`),[re,ie]=(0,Z.useState)(!1),[ae,oe]=(0,Z.useState)(null),[V,ce]=(0,Z.useState)(null),[le,H]=(0,Z.useState)(!1),[ue,U]=(0,Z.useState)(null),fe=(0,Z.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,Z.useEffect)(()=>{e&&(M(new Set(fe.map(e=>e.id))),ce(null),H(!1),U(null))},[e,fe]);let me=async()=>{ie(!0),U(null);try{let e={expectedNoteVersion:n.updatedAt,attachmentIds:[...A],ttlMs:Number(F),maxViews:L.trim()?Number(L):null,description:z.trim()||void 0};B===`hosted`?(ce((await P(n.id,e)).shareUrl),await k.mutate()):(ce((await de(n.id,e)).payload.shareUrl),await g())}catch(e){U(e instanceof Error?e.message:String(e))}finally{ie(!1)}},he=async(e,t)=>{oe(e.id),U(null);try{t===`refresh`?await te(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...A]}):await N(e.id),await k.mutate()}catch(e){U(e instanceof Error?e.message:String(e))}finally{oe(null)}},ge=async(e,t)=>{oe(e.id),U(null);try{t===`refresh`?await pe(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...A]}):t===`extend`?await De(e.id,864e5):await He(e.id),await g()}catch(e){U(e instanceof Error?e.message:String(e))}finally{oe(null)}},_e=async e=>{U(null);try{if(!await x(e)){H(!1),U(i.copyFailed);return}H(!0),window.setTimeout(()=>H(!1),1500)}catch{H(!1),U(i.copyFailed)}};return(0,Q.jsx)(f,{open:e,onOpenChange:t,children:(0,Q.jsxs)(l,{children:[(0,Q.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(u,{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-panel shadow-popover outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(d,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Q.jsx)(Be,{className:`size-4`}),i.title]}),(0,Q.jsx)(s,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,Q.jsx)(c,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,Q.jsx)(b,{className:`size-4`})})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-subtle p-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,Q.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),fe.length>0?(0,Q.jsxs)(`section`,{className:`mt-5`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,Q.jsx)(`div`,{className:`mt-2 grid gap-2`,children:fe.map(e=>(0,Q.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,Q.jsx)(`input`,{type:`checkbox`,checked:A.has(e.id),onChange:()=>M(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),className:`accent-accent`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:St(e.size)})]},e.id))})]}):null,(0,Q.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.delivery,(0,Q.jsxs)(m,{value:B,onChange:e=>ne(e.target.value),children:[(0,Q.jsx)(h,{value:`hosted`,children:i.deliveryHosted}),(0,Q.jsx)(h,{value:`local`,children:i.deliveryLocal})]})]}),B===`hosted`&&S.data===!1?(0,Q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Q.jsx)(Ke,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:()=>void S.mutate(!0,{revalidate:!1})})}):null,B===`hosted`&&C&&T.data&&!O?(0,Q.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,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,Q.jsx)(m,{value:F,onChange:e=>I(e.target.value),children:vt.map(e=>(0,Q.jsx)(h,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,Q.jsx)(`input`,{type:`number`,min:1,max:1e3,value:L,onChange:e=>R(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,Q.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,Q.jsx)(`input`,{value:z,onChange:e=>ee(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`})]})]}),V?(0,Q.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`input`,{readOnly:!0,value:V,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,Q.jsxs)(D,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void _e(V),children:[le?(0,Q.jsx)(p,{className:`size-4`}):(0,Q.jsx)(_,{className:`size-4`}),le?i.copied:i.copy]}),(0,Q.jsxs)(D,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(V,`_blank`,`noopener,noreferrer`),children:[(0,Q.jsx)(v,{className:`size-4`}),i.open]})]})}):null,ue?(0,Q.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:ue}):null,(a?.items.length??0)>0?(0,Q.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,Q.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,Q.jsx)(xt,{share:e,busy:ae===e.id,t:i,onCopy:_e,onAction:ge},e.id))})]}):null,(k.data?.length??0)>0?(0,Q.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.hostedLinks}),(0,Q.jsx)(`div`,{className:`mt-2 grid gap-2`,children:k.data.map(e=>(0,Q.jsx)(bt,{publication:e,stale:e.source?.version!==String(n.updatedAt),busy:ae===e.id,publishingAllowed:O,t:i,onCopy:_e,onAction:he},e.id))})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,Q.jsx)(c,{asChild:!0,children:(0,Q.jsx)(D,{type:`button`,variant:`ghost`,children:i.close})}),(0,Q.jsxs)(D,{type:`button`,onClick:()=>void me(),disabled:re||B===`hosted`&&(!C||!O),children:[re?(0,Q.jsx)(y,{className:`size-4 animate-spin`}):(0,Q.jsx)(Be,{className:`size-4`}),re?i.creating:i.create]})]})]})]})})}function bt(e){let t=(0,X.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=T(`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,p;t[2]===f?p=t[3]:(p=(0,Q.jsx)(`span`,{children:f}),t[2]=f,t[3]=p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`span`,{children:`·`}),t[4]=m):m=t[4];let h=n.maxViews===null?``:` / ${n.maxViews}`,g;t[5]!==n.viewCount||t[6]!==o.views||t[7]!==h?(g=(0,Q.jsxs)(`span`,{children:[o.views,` `,n.viewCount,h]}),t[5]=n.viewCount,t[6]=o.views,t[7]=h,t[8]=g):g=t[8];let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(`span`,{children:`·`}),t[9]=b):b=t[9];let x;t[10]!==n.revision||t[11]!==o.revision?(x=(0,Q.jsxs)(`span`,{children:[o.revision,` `,n.revision]}),t[10]=n.revision,t[11]=o.revision,t[12]=x):x=t[12];let S;t[13]!==p||t[14]!==g||t[15]!==x?(S=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,g,b,x]}),t[13]=p,t[14]=g,t[15]=x,t[16]=S):S=t[16];let C;t[17]===n.shareUrl?C=t[18]:(C=(0,Q.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[17]=n.shareUrl,t[18]=C);let w;t[19]!==S||t[20]!==C?(w=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[19]=S,t[20]=C,t[21]=w):w=t[21];let E;t[22]===i?E=t[23]:(E=i?(0,Q.jsx)(y,{className:`size-4 animate-spin text-fg-muted`}):null,t[22]=i,t[23]=E);let O;t[24]!==w||t[25]!==E?(O=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,E]}),t[24]=w,t[25]=E,t[26]=O):O=t[26];let k=!a,A;t[27]!==s||t[28]!==n.shareUrl?(A=()=>void s(n.shareUrl),t[27]=s,t[28]=n.shareUrl,t[29]=A):A=t[29];let j;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(_,{className:`size-3.5`}),t[30]=j):j=t[30];let M;t[31]!==o.copy||t[32]!==k||t[33]!==A?(M=(0,Q.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:k,onClick:A,children:[j,o.copy]}),t[31]=o.copy,t[32]=k,t[33]=A,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,Q.jsx)(v,{className:`size-3.5`}),t[37]=F):F=t[37];let I;t[38]!==o.open||t[39]!==N||t[40]!==P?(I=(0,Q.jsxs)(D,{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,Q.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i||!a,onClick:()=>void c(n,`refresh`),children:[(0,Q.jsx)(G,{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,Q.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i,onClick:()=>void c(n,`revoke`),children:[(0,Q.jsx)(ve,{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,Q.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]!==O||t[61]!==d||t[62]!==z?(ee=(0,Q.jsxs)(`div`,{className:d,children:[O,z]}),t[60]=O,t[61]=d,t[62]=z,t[63]=ee):ee=t[63],ee}function xt(e){let t=(0,X.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=T(`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,Q.jsx)(`span`,{children:u}),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`span`,{children:`·`}),t[4]=f):f=t[4];let p=n.maxViews===null?``:` / ${n.maxViews}`,m;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==p?(m=(0,Q.jsxs)(`span`,{children:[i.views,` `,n.viewCount,p]}),t[5]=n.viewCount,t[6]=i.views,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(`span`,{children:`·`}),t[9]=h):h=t[9];let g;t[10]===n.expiresAt?g=t[11]:(g=new Date(n.expiresAt).toLocaleDateString(),t[10]=n.expiresAt,t[11]=g);let b;t[12]===g?b=t[13]:(b=(0,Q.jsx)(`span`,{children:g}),t[12]=g,t[13]=b);let x;t[14]!==b||t[15]!==d||t[16]!==m?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[d,f,m,h,b]}),t[14]=b,t[15]=d,t[16]=m,t[17]=x):x=t[17];let S;t[18]===n.shareUrl?S=t[19]:(S=(0,Q.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=S);let C;t[20]!==x||t[21]!==S?(C=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[20]=x,t[21]=S,t[22]=C):C=t[22];let w;t[23]===r?w=t[24]:(w=r?(0,Q.jsx)(y,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=w);let E;t[25]!==C||t[26]!==w?(E=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,w]}),t[25]=C,t[26]=w,t[27]=E):E=t[27];let O;t[28]!==a||t[29]!==n.shareUrl?(O=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=O):O=t[30];let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(_,{className:`size-3.5`}),t[31]=k):k=t[31];let A;t[32]!==i.copy||t[33]!==O?(A=(0,Q.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:O,children:[k,i.copy]}),t[32]=i.copy,t[33]=O,t[34]=A):A=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,Q.jsx)(v,{className:`size-3.5`}),t[37]=M):M=t[37];let N;t[38]!==i.open||t[39]!==j?(N=(0,Q.jsxs)(D,{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,Q.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,Q.jsx)(G,{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,Q.jsx)(D,{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,Q.jsxs)(D,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,Q.jsx)(ve,{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]!==A||t[59]!==N||t[60]!==P||t[61]!==F||t[62]!==I?(L=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[A,N,P,F,I]}),t[58]=A,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,Q.jsxs)(`div`,{className:l,children:[E,L]}),t[64]=E,t[65]=l,t[66]=L,t[67]=R):R=t[67],R}function St(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Ct={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:`撤销`},wt={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 Tt(e){let t=(0,X.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=H(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=H(u),f=H(Et),p;t[6]!==n||t[7]!==r||t[8]!==d||t[9]!==a?(p=(0,Q.jsx)(be,{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,Q.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,Q.jsx)(Te,{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,Q.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 Et(e){return e.stop}function Dt(e,t){let n=A(t.replace(/^\s*(`{3,}|~{3,})[^\n]*$/gm,``).replace(/xopc-attachment:\/\/[^\s)]+/g,``).replace(/^(\s*[-*+]\s+)\[[ xX]\]\s*/gm,`$1`)),r=A(e);return!r||n.split(`
3
- `)[0]===r?n:[r,n].filter(Boolean).join(`
4
-
5
- `)}var Ot=()=>i(()=>import(`./block-editor-CVND3M6r.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])),kt=()=>i(()=>import(`./markdown-editor-BhBJANcx.js`),__vite__mapDeps([50,1,47,5,51,52,3])),At=(0,Z.lazy)(()=>Ot().then(e=>({default:e.BlockEditor}))),jt=(0,Z.lazy)(()=>kt().then(e=>({default:e.MarkdownEditor})));function Mt(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,Q.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,Q.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function Nt(e){let t=(0,X.c)(29),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:B},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:ye},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:he},t[4]=i.preview,t[5]=s);let c;t[6]!==a||t[7]!==o||t[8]!==s?(c=[a,o,s],t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9];let l=c,u;t[10]!==n||t[11]!==l?(u=l.find(e=>e.id===n)??l[0],t[10]=n,t[11]=l,t[12]=u):u=t[12];let d=u,f=d.Icon,m=Pt,h;t[13]===f?h=t[14]:(h=(0,Q.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[13]=f,t[14]=h);let g;t[15]===d.label?g=t[16]:(g=(0,Q.jsx)(`span`,{children:d.label}),t[15]=d.label,t[16]=g);let _;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Pe,{className:`size-3 text-fg-subtle`,"aria-hidden":!0}),t[17]=_):_=t[17];let v;t[18]!==d.label||t[19]!==h||t[20]!==g?(v=(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":d.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:[h,g,_]})}),t[18]=d.label,t[19]=h,t[20]=g,t[21]=v):v=t[21];let y;t[22]!==n||t[23]!==l||t[24]!==r?(y=(0,Q.jsx)(Ve,{children:(0,Q.jsx)(Oe,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,children:l.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,Q.jsxs)(xe,{onSelect:()=>r(t),onPointerMove:()=>m(t),onFocus:()=>m(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,Q.jsx)(a,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`flex-1`,children:i}),n===t?(0,Q.jsx)(p,{className:`size-4 text-accent`,"aria-hidden":!0}):null]},t)})})}),t[22]=n,t[23]=l,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==y||t[27]!==v?(b=(0,Q.jsxs)(Ge,{modal:!1,children:[v,y]}),t[26]=y,t[27]=v,t[28]=b):b=t[28],b}function Pt(e){e===`wysiwyg`&&Ot(),e===`source`&&kt()}function Ft(e){let t=(0,X.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(It),g;t[0]===h?g=t[1]:(g=S(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,Q.jsx)(Lt,{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 y;return t[13]!==_||t[14]!==v?(y=(0,Q.jsx)(Xe,{closeLabel:_,children:v}),t[13]=_,t[14]=v,t[15]=y):y=t[15],y}function It(e){return e.language}function Lt({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:o=!0,onOpenSearch:s,autoFocus:c=!1,initialMode:l=`wysiwyg`,onAutoFocusConsumed:u}){let d=w(e=>e.language),f=S(d).notes,m=S(d).automations.suggestions,h=a(),g=O(e=>e.resolved)===`dark`,{openImage:_}=Je(),[v,y]=(0,Z.useState)(l),[b,x]=(0,Z.useState)(null),[C,D]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(360),[z,te]=(0,Z.useState)(!1),[B,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(!1),[se,V]=(0,Z.useState)(null),[ce,de]=(0,Z.useState)(!1),[fe,pe]=(0,Z.useState)(null),[me,he]=(0,Z.useState)(!1),[ge,_e]=(0,Z.useState)(!1),ye=(0,Z.useRef)(!1),be=(0,Z.useRef)(!1),W=(0,Z.useRef)(null),G=(0,Z.useRef)(null),K=(0,Z.useRef)(null),q=(0,Z.useRef)(null),Te=(0,Z.useRef)(null),De=(0,Z.useRef)(null),je=(0,Z.useRef)(null),Ne=(0,Z.useRef)(null),Pe=(0,Z.useRef)(null),Fe=Ce(e=>e.setPageHeader),Ie=Ce(e=>e.clearPageHeader),{data:J,mutate:Y,error:ze}=E(e?[`note-detail`,e]:null,()=>F(e)),{data:He=[],mutate:Ke}=E(e?[`note-threads`,e]:null,()=>le(e),{revalidateOnFocus:!1}),X=C!==null,qe=(0,Z.useCallback)(e=>{V(`${f.refreshFailed}: ${e instanceof Error?e.message:f.quickCaptureFailedHint}`)},[f.quickCaptureFailedHint,f.refreshFailed]);(0,Z.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&Y().catch(qe)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[Y,e,qe]),(0,Z.useEffect)(()=>{ye.current=!1,M(``),D(null),x(null),be.current=!1,Pe.current=null},[e]),(0,Z.useEffect)(()=>{!J||ye.current||(M(J.title??``),ye.current=!0)},[J]),(0,Z.useEffect)(()=>{if(!c||!J||X||Pe.current===e)return;let t=window.requestAnimationFrame(()=>{Ne.current?.focus(),u?.()});return Pe.current=e,()=>window.cancelAnimationFrame(t)},[c,X,J,e,u]);let Ye=J?new Date(J.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,Xe=(0,Z.useMemo)(()=>r?(0,Q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":f.back,className:T(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,U,i),children:(0,Q.jsx)(oe,{className:`size-4`,"aria-hidden":!0})}):null,[i,f.back,t,r]),$=(0,Z.useCallback)(()=>{let t=H.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),Ze=(0,Z.useCallback)(e=>{e!==`preview`&&$(),y(e)},[$]),Qe=(0,Z.useCallback)(t=>{$(),M(t),e&&(q.current=t,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{let t=q.current;if(q.current=null,t!==null){A(!0);try{await R(e,{title:t}),await Y(),n?.()}catch{}finally{A(!1)}}},600))},[$,e,Y,n]),$e=(0,Z.useMemo)(()=>(0,Q.jsxs)(`div`,{className:T(`flex min-w-0 items-center gap-2`,U),children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:j||Ye||void 0,children:j||Ye}),k?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:f.saving}):null]}),[f.saving,k,Ye,j]),et=(0,Z.useCallback)(async(t=!1)=>{ae(!0),V(null);try{let n=await ne(e,{forceNew:t});await Y(),await Ke(),h(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){V(`${f.chatOpenFailedTitle}: ${e instanceof Error?e.message:f.chatOpenFailedMessage}`)}finally{ae(!1)}},[Y,Ke,h,e,f.chatOpenFailedMessage,f.chatOpenFailedTitle]),tt=(0,Z.useCallback)(async()=>{re(!0),V(null);try{await ue(e),await Y()}catch(e){V(`${f.catalysisFailed}: ${e instanceof Error?e.message:f.chatOpenFailedMessage}`)}finally{re(!1)}},[Y,e]),nt=(0,Z.useCallback)(()=>{x(b===`breakdown`?null:`breakdown`),!J?.aiDeep?.catalysis?.report&&!B&&tt()},[b,B,tt,J?.aiDeep?.catalysis?.report]),it=(0,Z.useCallback)(()=>{let t=C?C.markdown??``:K.current??J?.markdown??``,n=C?C.title??``:j,r=Dt(n,t);return{source:{type:`note`,id:e,title:n||f.titlePlaceholder},text:r,language:Ee(r,d)}},[d,f.titlePlaceholder,J?.markdown,e,C,j]),at=(0,Z.useCallback)(async()=>{W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current),W.current=null,G.current=null;let t=K.current,r=q.current;K.current=null,q.current=null;let i={};if(t!==null&&(i.markdown=t),r!==null&&(i.title=r),Object.keys(i).length===0)return J??null;A(!0);try{let t=await R(e,i);return await Y(t,{revalidate:!1}),n?.(),t}catch(e){return V(`${f.saveFailed}: ${e instanceof Error?e.message:f.saveFailedHint}`),null}finally{A(!1)}},[Y,f.saveFailed,f.saveFailedHint,J,e,n]),ot=(0,Z.useCallback)(async()=>{V(null);let e=await at();e&&(pe(e),de(!0))},[at]),st=(0,Z.useCallback)(async()=>{if(!(ge||k)){he(!1),_e(!0),V(null),$(),W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current),W.current=null,G.current=null,K.current=null,q.current=null;try{await I(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){V(`${f.deleteFailed}: ${e instanceof Error?e.message:f.quickCaptureFailedHint}`)}finally{_e(!1)}}},[ge,f.deleteFailed,f.quickCaptureFailedHint,e,t,n,k,$]),ct=(0,Z.useMemo)(()=>(0,Q.jsxs)(`div`,{className:T(`flex items-center gap-2`,U),children:[s?(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-label":f.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,Q.jsx)(ke,{className:`size-4`,"aria-hidden":!0})}):null,(0,Q.jsx)(Tt,{input:it,showLabel:!1,labels:{read:f.readAloud,preparing:f.readAloudPreparing,pause:f.readAloudPause,resume:f.readAloudResume,retry:f.readAloudRetry,stop:f.readAloudStop}}),(0,Q.jsxs)(`button`,{type:`button`,onClick:nt,disabled:B,"aria-label":f.catalysisSectionTitle,className:T(`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`,b===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,Q.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),B?f.catalyzing:f.catalyzeButton]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>et(!1),disabled:ie,className:T(`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,Q.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),ie?f.openingChat:f.openChatButton]}),(0,Q.jsx)(Nt,{mode:v,onModeChange:Ze,labels:{edit:f.modeEdit,source:f.modeSource,preview:f.modePreview}}),(0,Q.jsxs)(Ge,{modal:!1,children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":f.noteActions,title:f.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,Q.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})}),(0,Q.jsx)(Ve,{children:(0,Q.jsxs)(Oe,{align:`end`,sideOffset:6,className:`z-50 min-w-40 rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Q.jsxs)(xe,{onSelect:()=>void ot(),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,Q.jsx)(Be,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),d===`zh`?`分享`:`Share`]}),(0,Q.jsxs)(xe,{onSelect:()=>x(b===`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,Q.jsx)(Ue,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`flex-1`,children:f.history}),b===`history`?(0,Q.jsx)(p,{className:`size-4 text-accent`,"aria-hidden":!0}):null]}),(0,Q.jsx)(we,{className:`my-1 h-px bg-edge-subtle`}),(0,Q.jsxs)(xe,{disabled:ge||k,onSelect:()=>he(!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,Q.jsx)(ve,{className:`size-4`,"aria-hidden":!0}),f.delete]})]})})]})]}),[B,nt,et,v,f.history,f.modeEdit,f.modePreview,f.modeSource,ie,b,s,f.searchDialogTitle,f.readAloud,f.readAloudPause,f.readAloudPreparing,f.readAloudResume,f.readAloudRetry,f.readAloudStop,Ze,it,ot,ge,k,d,f.delete,he]);(0,Z.useLayoutEffect)(()=>(Fe({startExtra:Xe,main:J?$e:null,end:J?ct:null}),()=>{o&&Ie()}),[o,Ie,ct,$e,Xe,J,Fe]);let lt=(0,Z.useCallback)(t=>{e&&($(),K.current=t,W.current&&clearTimeout(W.current),W.current=setTimeout(async()=>{let t=K.current;if(K.current=null,t!==null){A(!0),V(null);try{await R(e,{markdown:t}),await Y(),n?.()}catch(e){V(`${f.saveFailed}: ${e instanceof Error?e.message:f.saveFailedHint}`)}finally{A(!1)}}},600))},[$,e,Y,f.saveFailed,f.saveFailedHint,n]),dt=(0,Z.useCallback)(t=>{Me(e,t.timestamp).then(e=>{e&&($(),D(e))})},[e,$]),ft=(0,Z.useCallback)(()=>{$(),x(null),D(null)},[$]),pt=(0,Z.useCallback)(()=>{$(),x(null),D(null),Y().catch(qe),n?.()},[Y,n,qe,$]);if((0,Z.useEffect)(()=>()=>{W.current&&clearTimeout(W.current),G.current&&clearTimeout(G.current);let t=K.current,n=q.current;K.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&R(e,r).catch(()=>void 0)},[e]),J===void 0)return ze?(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,role:`alert`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-danger`,children:f.home.loadFailed}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void Y().catch(qe),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:f.home.retry}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:f.back})]}):(0,Q.jsx)(Mt,{});if(J===null)return(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:f.notFoundTitle}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.notFoundDescription}),(0,Q.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:f.back})]});let mt=X?C.title??``:j,ht=X?C.markdown??``:K.current??J.markdown??``,vt=new Date(J.createdAt).getTime(),bt=Number.isFinite(vt)&&Date.now()-vt<3600*1e3?(0,Q.jsx)(rt,{title:m.noteCreatedTitle,description:m.noteCreatedDescription,prompt:m.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 gap-3 p-4 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`mx-auto flex min-h-0 min-w-0 w-full max-w-[60rem] flex-1 flex-col`,children:[se?(0,Q.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:se}):null,(0,Q.jsx)(Se,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,Q.jsx)(Se,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,Q.jsxs)(`div`,{ref:Te,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[(0,Q.jsx)(ut,{noteId:e}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:X?(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,children:[mt&&(0,Q.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:mt}),ht?(0,Q.jsx)(Re,{noteId:e,content:ht,className:`opacity-80`}):(0,Q.jsx)(`p`,{className:`italic text-fg-muted`,children:f.emptyPreview})]}):(0,Q.jsxs)(Q.Fragment,{children:[v===`wysiwyg`&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,Q.jsx)(`input`,{ref:Ne,type:`text`,value:j,onChange:e=>Qe(e.target.value),onCompositionStart:()=>{be.current=!0},onCompositionEnd:()=>{be.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!be.current&&!t.isComposing&&(e.preventDefault(),(Te.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:f.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`}),bt]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Mt,{}),children:(0,Q.jsx)(At,{initialContent:J.markdown??``,onChange:lt,noteId:e},`wysiwyg-${e}`)})})]}),v===`source`&&(0,Q.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,Q.jsx)(`input`,{ref:Ne,type:`text`,value:j,onChange:e=>Qe(e.target.value),placeholder:f.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`}),bt]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Mt,{}),children:(0,Q.jsx)(jt,{initialContent:J.markdown??``,onChange:lt,isDark:g},`source-${e}`)})})]}),v===`preview`&&(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto px-6 py-4`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&_(t.currentSrc||t.src,t.alt)},children:[j&&(0,Q.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:j}),J.markdown?(0,Q.jsx)(Re,{noteId:e,content:J.markdown,className:`[&_img]:cursor-zoom-in`}):(0,Q.jsx)(`p`,{className:`italic text-fg-muted`,children:f.emptyPreview})]})]})})]})]}),(0,Q.jsx)(`div`,{ref:De,className:T(`relative flex min-h-0 shrink-0 flex-col overflow-hidden`,!z&&`transition-[width] duration-300 ease-in-out`),style:{width:b?N:0},children:(0,Q.jsxs)(`div`,{ref:je,className:`flex min-h-0 flex-1 flex-col`,style:{width:N},children:[(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),te(!0);let n=e.clientX,r=N,i=e.pointerId,a=0,o=N,s=N,c=()=>{a=0,s=o,b&&De.current?.style.setProperty(`width`,`${s}px`),je.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{}te(!1),P(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:T(`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`,z&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:b===`history`?(0,Q.jsx)(gt,{noteId:e,activeTimestamp:C?.timestamp??null,onSelect:dt,onClose:ft,onRestored:pt}):b===`breakdown`?(0,Q.jsx)(_t,{noteId:e,note:J??null,catalyzing:B,onCatalyze:tt,onClose:()=>x(null),noteThreads:He,openingChat:ie,onOpenChat:()=>et(!1),onOpenNewChat:()=>et(!0)}):null})]})})]}),fe?(0,Q.jsx)(yt,{open:ce,onOpenChange:de,note:fe}):null,(0,Q.jsx)(L,{open:me,title:f.deleteConfirmTitle,description:f.deleteConfirmDescription.replace(`{{title}}`,J.title||f.titlePlaceholder),confirmLabel:f.deleteConfirmLabel,cancelLabel:f.deleteCancelLabel,destructive:!0,onConfirm:()=>void st(),onCancel:()=>he(!1)})]})}export{Je as a,et as i,nt as n,tt as r,Ft as t};
@@ -1,8 +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{d as i,h as a,p as o,u as s}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as c}from"./popover-select-CKBYnT3c.js";import{d as l}from"./markdown-view-DIcfrLmG.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./plus-Q2yW6OE7.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./messages-BRjoarIr.js";import{d as m,n as h,s as g}from"./locale-store-BQ2HKTWb.js";import{t as _}from"./cn-JdwAhgNB.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./skeleton-BwbyijEw.js";import{$s as b,Ai as ee,En as x,Fc as S,Fn as C,Gi as te,Gn as ne,Hl as w,Ia as re,Il as T,In as E,Kn as D,Mn as O,Mu as k,Ou as A,Pu as ie,So as ae,Su as oe,Uc as j,Ws as se,Yn as M,_n as ce,ao as le,gc as N,gl as ue,gn as de,hc as fe,hu as P,ic as pe,ju as me,kl as he,ku as F,vn as ge,wn as _e,xn as ve,yn as ye,zc as be}from"./index-CfyyA9-g.js";import{i as xe,t as I}from"./note-detail-panel-D5JuBLyt.js";var L=e(t(),1),R=n();async function Se(e){e.note??=await _e({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await D(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${M(t,e.id)})`);e.note=await ne(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
2
-
3
- `)}`})}return{noteId:t,sessionKey:(await E(t,{projectId:e.projectId})).sessionKey}}function Ce(e,t,n){let r=new URLSearchParams({draft:n.replace(`{{id}}`,t),autoSend:`1`});return`/chat/${encodeURIComponent(e)}?${r}`}var z=r(),B={meeting:A,requirements:T,research:N,weekly:P};function we({projects:e,projectId:t,onProjectChange:n,onCreated:r,labels:a,projectsLoading:o,projectsError:s}){let l=a.home,d=i(),[p,m]=(0,L.useState)(``),[h,g]=(0,L.useState)(null),[v,y]=(0,L.useState)([]),[b,ee]=(0,L.useState)(!1),[x,C]=(0,L.useState)(null),[te,ne]=(0,L.useState)(``),w=(0,L.useRef)(null),T=(0,L.useRef)(!1),E=(0,L.useRef)(null),D=(0,L.useRef)(null),O=b||!!w.current,k=h?l.templateOptions[h]:null,A=!!(p.trim()||v.length);async function ie(){if(!(T.current||!A&&!w.current)){T.current=!0,ee(!0),C(null),w.current??={requestId:crypto.randomUUID(),title:p.trim().split(`
4
- `)[0]?.slice(0,80)||k?.label||a.titlePlaceholder,markdown:`## ${l.requestHeading}\n\n${k?`${k.prompt}\n`:``}${p.trim()}`,projectId:t||void 0,files:[...v],attachments:[],materialHeading:l.materialsHeading};try{let e=await Se(w.current);r(),d(Ce(e.sessionKey,e.noteId,l.agentPrompt))}catch(e){w.current.note&&r(),C(e instanceof Error?e.message:a.quickCaptureFailedHint)}finally{T.current=!1,ee(!1)}}}function ae(){w.current=null,C(null),m(``),y([]),g(null),D.current?.focus()}return(0,z.jsxs)(`section`,{"aria-label":l.askLabel,children:[(0,z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ie()},className:`relative rounded-xl border border-edge bg-surface-panel p-4 focus-within:border-accent/60 sm:p-5`,children:[(0,z.jsxs)(`fieldset`,{disabled:O,className:`min-w-0`,children:[(0,z.jsxs)(`label`,{htmlFor:`notes-home-prompt`,className:`flex items-center gap-2 text-xs font-medium text-accent-fg`,children:[(0,z.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),l.askLabel]}),k?(0,z.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft px-3 py-2 text-xs leading-5 text-accent-fg`,children:[(0,z.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`font-medium`,children:[k.label,` · `]}),k.prompt.split(`
5
-
6
- `)[0]]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>g(null),"aria-label":a.searchClear,className:`shrink-0 rounded p-1 hover:bg-surface-hover`,children:(0,z.jsx)(f,{className:`size-3.5`})})]}):null,(0,z.jsx)(`textarea`,{ref:D,id:`notes-home-prompt`,value:p,onChange:e=>m(e.target.value),placeholder:k?k.prompt.split(`
7
-
8
- `).at(-1):l.askPlaceholder,rows:2,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),ie())},className:`mt-2 min-h-16 w-full resize-y bg-transparent py-2 text-base leading-6 text-fg outline-none placeholder:text-fg-muted sm:text-sm`}),v.length?(0,z.jsx)(`ul`,{className:`mb-3 flex flex-wrap gap-2`,children:v.map((e,t)=>(0,z.jsxs)(`li`,{className:`flex max-w-full items-center gap-2 rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:[(0,z.jsx)(S,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`${l.removeMaterial}: ${e.name}`,onClick:()=>y(e=>e.filter((e,n)=>n!==t)),className:`rounded p-1 hover:bg-surface-hover`,children:(0,z.jsx)(f,{className:`size-3`})})]},`${e.name}-${t}`))}):null,(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:pr-40`,children:[(0,z.jsx)(`div`,{className:`w-44 max-w-full`,children:(0,z.jsx)(c,{value:t,options:e.filter(e=>e.name.toLowerCase().includes(te.toLowerCase())).map(e=>({value:e.id,label:e.name})),selectedLabel:t?e.find(e=>e.id===t)?.name:l.unassigned,placeholder:l.unassigned,emptyLabel:l.unassigned,ariaLabel:l.assignProject,triggerIcon:(0,z.jsx)(he,{className:`size-4 shrink-0`,"aria-hidden":!0}),triggerClassName:`h-8 border-transparent bg-transparent px-2 text-xs text-fg-muted hover:bg-surface-hover`,onChange:n,disabled:O,loading:o,statusMessage:s?l.projectsLoadFailed:void 0,searchPlaceholder:l.projectSearch,searchValue:te,onSearchChange:ne})}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>E.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover`,children:[(0,z.jsx)(S,{className:`size-4`,"aria-hidden":!0}),l.addMaterials]}),(0,z.jsx)(`input`,{ref:E,type:`file`,multiple:!0,className:`hidden`,"aria-label":l.addMaterials,onChange:e=>{let t=Array.from(e.target.files??[]);y(e=>[...e,...t]),e.target.value=``}})]})]}),(0,z.jsx)(`div`,{className:`mt-2 flex justify-end sm:absolute sm:bottom-5 sm:right-5 sm:mt-0`,children:(0,z.jsxs)(`button`,{type:`submit`,disabled:b||!w.current&&!A,className:`inline-flex h-9 items-center gap-2 rounded-lg bg-accent px-4 text-sm font-medium text-white hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,children:[b?(0,z.jsx)(u,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(F,{className:`size-4`,"aria-hidden":!0}),b?l.creating:x?l.retry:l.agentCreate]})})]}),x?(0,z.jsxs)(`div`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-3 text-xs text-danger`,role:`alert`,children:[(0,z.jsx)(`p`,{children:x}),w.current?.note?(0,z.jsx)(`p`,{className:`mt-1`,children:l.partialFailure}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[w.current?.note?(0,z.jsx)(`button`,{type:`button`,onClick:()=>d(`/notes/${encodeURIComponent(w.current.note.id)}?edit=1`),className:`underline`,children:l.openSavedDraft}):null,(0,z.jsx)(`button`,{type:`button`,onClick:ae,className:`underline`,children:l.newRequest})]})]}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-1 gap-y-1 text-xs text-fg-muted`,children:[(0,z.jsx)(`span`,{className:`mr-1 py-2`,children:l.templates}),Object.keys(B).map(e=>{let t=B[e];return(0,z.jsxs)(`button`,{type:`button`,disabled:O,"aria-pressed":h===e,onClick:()=>{g(h===e?null:e),D.current?.focus()},className:_(`inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover disabled:opacity-50`,h===e&&`bg-accent-soft text-accent-fg`),children:[(0,z.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),l.templateOptions[e].label]},e)}),(0,z.jsxs)(`button`,{type:`button`,disabled:b,onClick:()=>re(),className:`ml-auto inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover`,children:[(0,z.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),l.recordDiscussion]})]})]})}function Te(e,t){let n=Number(e.get(`page`)??0),r=Number.isSafeInteger(n)&&n>=0?n:0,i=e.get(`view`);return{projectId:e.get(`projectId`)||void 0,unassigned:e.get(`unassigned`)===`true`||i===`unassigned`||void 0,pinned:i===`favorites`?!0:void 0,agentEdited:i===`agent`||void 0,status:i===`archived`?`archived`:void 0,search:t.trim()||void 0,sortBy:`updatedAt`,sortOrder:`desc`,limit:12,offset:r*12}}function Ee(e){let t=e.snippet?.trim()??``,n=e.title?.trim();return n&&t.startsWith(n)?t.slice(n.length).replace(/^[\s::·—-]+/,``):t}var V=`inline-flex min-h-9 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`;function H(){let e=h(e=>e.language),t=p(e).notes,n=t.home,r=g(e=>e.token),o=le(e=>e.setPageHeader),l=le(e=>e.clearPageHeader),f=i(),{pathname:S,search:re}=s(),[E,D]=a(),j=E.get(`projectId`)||``,M=E.get(`view`)||`all`,N=E.get(`unassigned`)===`true`||M===`unassigned`,P=E.get(`search`)||``,[F]=ee(P,250),[I,R]=(0,L.useState)(j),[Se,Ce]=(0,L.useState)(``),[B,H]=(0,L.useState)(null),[U,De]=(0,L.useState)(!1),[Oe,ke]=(0,L.useState)(new Set),[Ae,je]=(0,L.useState)(null),[Me,Ne]=(0,L.useState)(null),W=(0,L.useRef)(new Set),G=(0,L.useRef)(null),Pe=(0,L.useRef)(!1),Fe=(0,L.useRef)(null),Ie=Te(E,F),K=(Ie.offset??0)/12,{data:Le,error:Re,isLoading:ze,mutate:Be}=v(r?[`notes-home`,r,Ie]:null,()=>C(Ie)),{data:Ve,error:He,isLoading:q,mutate:J}=v(r?[`notes-home-projects`,r]:null,O),Y=Ve?.items??[],Ue=Y.find(e=>e.id===j)?.name??n.projectNotes,We=Le?.items??[],X=Le?.total??0,Ge=ze||P!==F,Ke=(0,L.useMemo)(()=>({justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo,locale:m(e)}),[e,t.justNow,t.minutesAgo,t.today,t.yesterday,t.daysAgo]),[qe,Je]=(0,L.useState)(()=>Date.now());(0,L.useEffect)(()=>{R(j)},[j]),(0,L.useEffect)(()=>{let e=window.setInterval(()=>Je(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let Z=(0,L.useCallback)(()=>{Be().catch(()=>void 0),J().catch(()=>void 0)},[Be,J]);(0,L.useEffect)(()=>{let e=[`note-updated`,`note-created`,`note-deleted`,`project-updated`,`project-created`,`project-deleted`];return e.forEach(e=>window.addEventListener(e,Z)),()=>e.forEach(e=>window.removeEventListener(e,Z))},[Z]);let Ye=(0,L.useCallback)((e,t=!1)=>{let n=`${S}${re}`,r=new URLSearchParams({returnTo:n});t&&r.set(`edit`,`1`),f(`/notes/${encodeURIComponent(e)}?${r}`)},[S,re,f]),Q=(0,L.useCallback)(async()=>{if(!(Pe.current||!r)){Pe.current=!0,De(!0),H(null),G.current??={key:crypto.randomUUID(),projectId:I||void 0};try{let e=await _e({markdown:``,kind:`thought`,projectId:G.current.projectId},G.current.key);G.current=null,Z(),Ye(e.id,!0)}catch(e){H(`${t.createBlankFailed}: ${e instanceof Error?e.message:t.createBlankFailedHint}`)}finally{Pe.current=!1,De(!1)}}},[I,t.createBlankFailed,t.createBlankFailedHint,Ye,Z,r]),Xe=(0,L.useCallback)(e=>{D(t=>{let n=new URLSearchParams(t);return e?n.set(`search`,e):n.delete(`search`),n.delete(`page`),n},{replace:!0})},[D]);function $(e,t=`all`){let n=new URLSearchParams;e&&n.set(`projectId`,e),t===`unassigned`?n.set(`unassigned`,`true`):t!==`all`&&n.set(`view`,t),R(e),D(n)}function Ze(e){D(t=>{let n=new URLSearchParams(t);return N&&n.set(`unassigned`,`true`),e===`all`?n.delete(`view`):n.set(`view`,e),n.delete(`page`),n})}async function Qe(e,n){if(!W.current.has(e)){W.current.add(e),ke(new Set(W.current)),H(null);try{await ne(e,{pinned:n}),Z()}catch(e){H(`${t.actionFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{W.current.delete(e),ke(new Set(W.current))}}}async function $e(){let e=Ae;if(!(!e||Me)){je(null),Ne(e.id),H(null);try{await x(e.id),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e.id}})),Z()}catch(e){H(`${t.deleteFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{Ne(null)}}}if((0,L.useLayoutEffect)(()=>{if(!r){l();return}return o({startExtra:null,main:(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold text-fg`,children:t.title}),end:(0,z.jsxs)(`div`,{className:_(`flex min-w-0 items-center gap-2`,ae),children:[(0,z.jsxs)(`label`,{className:`flex h-9 w-32 min-w-0 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-2 sm:w-48`,children:[(0,z.jsx)(fe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsx)(`input`,{ref:Fe,type:`search`,value:P,onChange:e=>Xe(e.target.value),"aria-label":t.searchDialogTitle,placeholder:t.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void Q(),disabled:U,"aria-label":n.blankNote,className:_(V,`border border-edge bg-surface-panel text-fg`),children:[U?(0,z.jsx)(u,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(d,{className:`size-4`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:n.blankNote})]})]})}),()=>l()},[l,Q,U,n.blankNote,t.searchDialogTitle,t.searchPlaceholder,t.title,P,o,Xe,r]),(0,L.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.isComposing||e.target?.closest(`input, textarea, [contenteditable="true"], [role="dialog"]`)||(e.key.toLowerCase()===`n`&&(e.preventDefault(),Q()),e.key.toLowerCase()===`f`&&(e.preventDefault(),Fe.current?.focus()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Q]),!r)return(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-sm text-fg-muted`,children:t.needToken});let et=[{id:`all`,label:n.homeNav,Icon:be},{id:`favorites`,label:n.favorites,Icon:b},{id:`unassigned`,label:n.unassigned,Icon:ue},{id:`archived`,label:t.filterArchived,Icon:ie}],tt=j?`project:${j}`:N?`unassigned`:`all`;return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,children:[(0,z.jsxs)(`aside`,{className:`hidden w-44 shrink-0 flex-col gap-1 overflow-y-auto px-3 py-6 xl:flex`,"aria-label":n.homeNav,children:[et.map(({id:e,label:t,Icon:n})=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(``,e),"aria-current":!j&&(e===`unassigned`?N:!N&&M===e)?`page`:void 0,className:_(V,`justify-start px-2 text-left text-xs`,!j&&(e===`unassigned`?N:!N&&M===e)&&`bg-surface-hover font-medium text-fg`),children:[(0,z.jsx)(n,{className:`size-4 shrink-0`,"aria-hidden":!0}),t]},e)),(0,z.jsx)(`span`,{className:`mb-1 mt-7 px-2 text-xs text-fg-muted`,children:n.projects}),q?[0,1,2].map(e=>(0,z.jsx)(y,{className:`mb-2 h-8 w-full`},e)):Y.slice(0,8).map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(e.id),"aria-current":j===e.id?`page`:void 0,className:_(V,`justify-start px-2 text-left text-xs`,j===e.id&&`bg-surface-hover font-medium text-fg`),children:[(0,z.jsx)(he,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>f(`/projects`),className:_(V,`mt-2 justify-start px-2 text-xs`),children:[n.allProjects,(0,z.jsx)(me,{className:`ml-auto size-3`,"aria-hidden":!0})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,z.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 py-7 sm:px-8 lg:px-10 lg:py-9`,children:[(0,z.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,z.jsx)(`h2`,{className:`min-w-0 break-words text-2xl font-semibold tracking-tight text-fg`,children:j?Ue:N?n.unassigned:n.homeTitle}),j?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>f(`/projects/${encodeURIComponent(j)}`),className:_(V,`text-xs`),children:[n.openProject,(0,z.jsx)(me,{className:`size-3.5`,"aria-hidden":!0})]}):null]}),B?(0,z.jsx)(`p`,{className:`mb-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:B}):null,(0,z.jsx)(we,{projects:Y,projectId:I,onProjectChange:R,onCreated:Z,labels:t,projectsLoading:q,projectsError:!!He}),He?(0,z.jsxs)(`div`,{role:`alert`,className:`mt-4 flex items-center gap-3 text-xs text-danger`,children:[(0,z.jsx)(`span`,{children:n.projectsLoadFailed}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void J().catch(()=>void 0),className:`underline`,children:n.retry})]}):null,!j&&!N&&(q||Y.length>0)?(0,z.jsxs)(`section`,{className:`mt-8`,"aria-label":n.continueProjects,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.continueProjects}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>f(`/projects`),className:`text-xs text-fg-muted hover:text-fg`,children:n.allProjects})]}),(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:q?[0,1,2].map(e=>(0,z.jsx)(y,{className:`h-28 w-full`},e)):Y.slice(0,3).map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(e.id),className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-3 text-left transition-colors sm:p-4 hover:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,z.jsx)(he,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.description?(0,z.jsx)(`p`,{className:`mt-2 hidden line-clamp-1 text-xs text-fg-muted sm:block`,children:e.description}):null,(0,z.jsxs)(`span`,{className:`mt-2 flex flex-wrap items-center justify-between gap-1 text-xs text-fg-muted sm:mt-3`,children:[(0,z.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(e.noteCount))}),(0,z.jsx)(`span`,{children:e.updatedAt?xe(e.updatedAt,qe,Ke):n.emptyProject})]})]},e.id))})]}):null,(0,z.jsxs)(`section`,{className:`mt-8 pb-6`,"aria-label":n.recentNotes,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:j?n.projectNotes:n.recentNotes}),(0,z.jsx)(`div`,{className:`w-48 max-w-full`,children:(0,z.jsx)(c,{value:tt,allowEmpty:!1,ariaLabel:n.projects,placeholder:n.allNotes,options:[{value:`all`,label:n.allNotes},{value:`unassigned`,label:n.unassigned},...Y.filter(e=>e.name.toLowerCase().includes(Se.toLowerCase())).map(e=>({value:`project:${e.id}`,label:e.name}))],selectedLabel:j?Ue:N?n.unassigned:n.allNotes,triggerClassName:`h-8 bg-surface-panel text-xs`,loading:q,searchPlaceholder:n.projectSearch,searchValue:Se,onSearchChange:Ce,onChange:e=>$(e.startsWith(`project:`)?e.slice(8):``,e===`unassigned`?e:`all`)})})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 border-b border-edge`,"aria-label":t.libraryTitle,children:[[{id:`all`,label:t.filterAll},{id:`agent`,label:n.agentEdited},{id:`favorites`,label:n.favorites},{id:`archived`,label:t.filterArchived}].map(({id:e,label:t})=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":M===e||e===`all`&&M===`unassigned`,onClick:()=>Ze(e),className:_(`border-b-2 border-transparent py-3 text-xs text-fg-muted hover:text-fg`,(M===e||e===`all`&&M===`unassigned`)&&`border-fg font-medium text-fg`),children:t},e)),(0,z.jsx)(`span`,{className:`ml-auto py-3 text-xs text-fg-muted`,children:n.sortUpdated})]}),Re?(0,z.jsxs)(`div`,{className:`py-10 text-center`,role:`alert`,children:[(0,z.jsx)(`p`,{className:`text-sm text-danger`,children:n.loadFailed}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void Be().catch(()=>void 0),className:_(V,`mt-2`),children:n.retry})]}):Ge?(0,z.jsx)(`div`,{"aria-busy":`true`,className:`divide-y divide-edge`,children:[0,1,2,3].map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,z.jsx)(y,{className:`h-10 w-8 shrink-0`}),(0,z.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,z.jsx)(y,{className:`h-4 w-2/3`}),(0,z.jsx)(y,{className:`h-3 w-1/2`})]})]},e))}):We.length===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center px-4 py-12 text-center`,children:[(0,z.jsx)(be,{className:`mb-4 size-8 text-fg-muted`,strokeWidth:1.3,"aria-hidden":!0}),(0,z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:P||M!==`all`&&M!==`unassigned`?n.noMatches:j?n.projectEmpty:n.emptyTitle}),(0,z.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:P||M!==`all`&&M!==`unassigned`?n.noMatchesHint:j?n.projectEmptyHint:n.emptyDescription})]}):(0,z.jsx)(`ul`,{className:`divide-y divide-edge`,children:We.map(e=>{let r=e.voiceAttachmentId||e.kind===`voice`?A:e.kind===`bookmark`?oe:T,i=Ee(e)||(e.coverAttachmentId?t.imageNote:t.noText);return(0,z.jsxs)(`li`,{className:`group flex min-w-0 items-center gap-3 py-4`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Ye(e.id),className:`flex min-w-0 flex-1 items-center gap-3 rounded-md text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,z.jsx)(`span`,{className:`flex h-10 w-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg-muted`,children:(0,z.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg group-hover:text-accent-fg`,children:e.title||t.titlePlaceholder}),(0,z.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-xs text-fg-muted`,children:[e.lastEditTrigger===`ai_edit`?(0,z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-accent-fg`,children:[(0,z.jsx)(pe,{className:`size-3`,"aria-hidden":!0}),n.agentEditLabel,(0,z.jsx)(`span`,{"aria-hidden":!0,children:`·`})]}):null,(0,z.jsx)(`span`,{className:`truncate`,children:i})]})]})]}),(0,z.jsx)(`span`,{className:`hidden max-w-32 truncate text-xs text-fg-muted md:block`,title:e.projects?.map(e=>e.name).join(` · `),children:e.projects?.map(e=>e.name).join(` · `)||n.unassigned}),(0,z.jsx)(`time`,{dateTime:new Date(e.updatedAt).toISOString(),className:`hidden w-24 shrink-0 text-right text-xs text-fg-muted sm:block`,children:xe(e.updatedAt,qe,Ke)}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void Qe(e.id,!e.pinned),disabled:Oe.has(e.id),"aria-label":`${e.pinned?n.unfavorite:n.favorite}: ${e.title||t.titlePlaceholder}`,"aria-pressed":!!e.pinned,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:(0,z.jsx)(b,{className:_(`size-4`,e.pinned&&`fill-current text-fg`),"aria-hidden":!0})}),(0,z.jsxs)(ye,{children:[(0,z.jsx)(ve,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,disabled:Me===e.id,"aria-label":`${t.noteActions}: ${e.title||t.titlePlaceholder}`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:Me===e.id?(0,z.jsx)(u,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(w,{className:`size-4`,"aria-hidden":!0})})}),(0,z.jsx)(ge,{children:(0,z.jsx)(de,{align:`end`,sideOffset:4,className:`z-50 min-w-36 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,z.jsxs)(ce,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft`,onSelect:()=>je(e),children:[(0,z.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t.delete]})})})]})]},e.id)})}),!Ge&&!Re&&X>0?(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 text-xs text-fg-muted`,"aria-live":`polite`,children:[(0,z.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(X))}),X>12||K>0?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":n.previousPage,disabled:K===0,className:V,onClick:()=>D(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(K-1)),t}),children:(0,z.jsx)(k,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{children:[K+1,` / `,Math.max(1,Math.ceil(X/12))]}),(0,z.jsx)(`button`,{type:`button`,"aria-label":n.nextPage,disabled:(K+1)*12>=X,className:V,onClick:()=>D(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(K+1)),t}),children:(0,z.jsx)(me,{className:`size-4`,"aria-hidden":!0})})]}):null]}):null]})]})}),(0,z.jsx)(te,{open:Ae!==null,title:t.deleteConfirmTitle,description:t.deleteConfirmDescription.replace(`{{title}}`,Ae?.title||t.titlePlaceholder),confirmLabel:t.deleteConfirmLabel,cancelLabel:t.deleteCancelLabel,destructive:!0,onConfirm:()=>void $e(),onCancel:()=>je(null)})]})}function U(){let e=(0,R.c)(12),{noteId:t}=o(),n=i(),[r]=a(),s;e[0]===r?s=e[1]:(s=l(r.get(`returnTo`),`/notes`,[`/chat`,`/projects`,`/notes`,`/tasks`]),e[0]=r,e[1]=s);let c=s,u;e[2]!==n||e[3]!==c?(u=()=>{n(c)},e[2]=n,e[3]=c,e[4]=u):u=e[4];let d=u;if(!t)return null;let f=r.get(`edit`)===`1`?`wysiwyg`:`preview`,p;e[5]===r?p=e[6]:(p=r.get(`edit`),e[5]=r,e[6]=p);let m=p===`1`,h;return e[7]!==d||e[8]!==t||e[9]!==f||e[10]!==m?(h=(0,z.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,z.jsx)(I,{noteId:t,onBack:d,initialMode:f,autoFocus:m},t)}),e[7]=d,e[8]=t,e[9]=f,e[10]=m,e[11]=h):h=e[11],h}function De(){let e=(0,R.c)(2),{noteId:t}=o(),n;return e[0]===t?n=e[1]:(n=t?(0,z.jsx)(U,{}):(0,z.jsx)(H,{}),e[0]=t,e[1]=n),n}export{De as NotesPage};
@@ -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{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o,r as s}from"./popover-select-CKBYnT3c.js";import{a as c,n as l,r as u}from"./locale-store-BQ2HKTWb.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{t as f}from"./button-B11EPpor.js";import{t as p}from"./skeleton-BwbyijEw.js";import{t as m}from"./electron-env-DH5wF8X8.js";import{Kt as h,qt as g}from"./index-CfyyA9-g.js";var _=e(t(),1),v=n(),y=e=>c(u(e)),b=(e,t,n)=>c(u(e),{method:t,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),x=r(),S=`mt-1 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`;function C(e){let t=(0,v.c)(58),{value:n,onChange:r,zh:i}=e,a;t[0]===i?a=t[1]:(a=i?{all:`所有已启用设备`,auto:`自动选择一台设备`,browser:`浏览器 / 桌面`,mobile:`手机`,telegram:`Telegram`}:{all:`All enabled devices`,auto:`Choose one device`,browser:`Browser / desktop`,mobile:`Mobile`,telegram:`Telegram`},t[0]=i,t[1]=a);let s=a,c;t[2]!==r||t[3]!==n?(c=e=>r({...n,digestEnabled:e.target.checked}),t[2]=r,t[3]=n,t[4]=c):c=t[4];let l;t[5]!==c||t[6]!==n.digestEnabled?(l=(0,x.jsx)(`input`,{type:`checkbox`,checked:n.digestEnabled,onChange:c}),t[5]=c,t[6]=n.digestEnabled,t[7]=l):l=t[7];let u=i?`将提醒合并为每日摘要`:`Combine alerts into a daily digest`,d;t[8]!==l||t[9]!==u?(d=(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f=i?`摘要时间(使用上方时区)`:`Digest time (in your selected timezone)`,p=String(n.digestHour),m;t[11]===p?m=t[12]:(m=p.padStart(2,`0`),t[11]=p,t[12]=m);let h=String(n.digestMinute),g;t[13]===h?g=t[14]:(g=h.padStart(2,`0`),t[13]=h,t[14]=g);let _=`${m}:${g}`,y;t[15]!==r||t[16]!==n?(y=e=>{let[t,i]=e.target.value.split(`:`).map(Number);r({...n,digestHour:t,digestMinute:i})},t[15]=r,t[16]=n,t[17]=y):y=t[17];let b;t[18]!==_||t[19]!==y?(b=(0,x.jsx)(`input`,{className:S,type:`time`,required:!0,value:_,onChange:y}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let C;t[21]!==b||t[22]!==f?(C=(0,x.jsxs)(`label`,{className:`block text-sm`,children:[f,b]}),t[21]=b,t[22]=f,t[23]=C):C=t[23];let T=i?`提醒渠道`:`Notification channel`,E=n.preferredChannel,D;t[24]!==r||t[25]!==n?(D=e=>r({...n,preferredChannel:e.target.value}),t[24]=r,t[25]=n,t[26]=D):D=t[26];let O;t[27]===s?O=t[28]:(O=Object.entries(s).map(w),t[27]=s,t[28]=O);let k;t[29]!==D||t[30]!==O||t[31]!==n.preferredChannel?(k=(0,x.jsx)(o,{value:E,onChange:D,children:O}),t[29]=D,t[30]=O,t[31]=n.preferredChannel,t[32]=k):k=t[32];let A;t[33]!==T||t[34]!==k?(A=(0,x.jsxs)(`label`,{className:`block text-sm`,children:[T,k]}),t[33]=T,t[34]=k,t[35]=A):A=t[35];let j=i?`自动选择优先使用最近注册的浏览器,否则选择一台手机。免打扰期间的重要提醒会合并为一份摘要。`:`Automatic selection prefers the most recently registered browser, then one mobile device. Important alerts during quiet hours are combined into one digest.`,M;t[36]===j?M=t[37]:(M=(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:j}),t[36]=j,t[37]=M);let N;t[38]!==r||t[39]!==n?(N=e=>r({...n,suppressWhileViewing:e.target.checked}),t[38]=r,t[39]=n,t[40]=N):N=t[40];let P;t[41]!==N||t[42]!==n.suppressWhileViewing?(P=(0,x.jsx)(`input`,{type:`checkbox`,checked:n.suppressWhileViewing,onChange:N}),t[41]=N,t[42]=n.suppressWhileViewing,t[43]=P):P=t[43];let F=i?`正在查看卡片时不再发送系统提醒`:`Skip system alerts while viewing cards`,I;t[44]!==P||t[45]!==F?(I=(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[P,F]}),t[44]=P,t[45]=F,t[46]=I):I=t[46];let L;t[47]!==r||t[48]!==n||t[49]!==i?(L=n.preferredChannel===`telegram`&&(0,x.jsxs)(`fieldset`,{className:`space-y-3 rounded-xl border border-edge p-3`,children:[(0,x.jsx)(`legend`,{className:`px-1 text-sm`,children:`Telegram`}),[`chatId`,`accountId`,`publicUrl`].map(e=>(0,x.jsxs)(`label`,{className:`block text-sm`,children:[e===`chatId`?i?`接收对话 ID`:`Destination chat ID`:e===`accountId`?i?`账号 ID(可选)`:`Account ID (optional)`:i?`可从外部访问的控制台 HTTPS 地址`:`Public HTTPS console URL`,(0,x.jsx)(`input`,{className:S,required:e!==`accountId`,value:n.telegram?.[e]??``,onChange:t=>r({...n,telegram:{chatId:n.telegram?.chatId??``,publicUrl:n.telegram?.publicUrl??``,...n.telegram?.accountId?{accountId:n.telegram.accountId}:{},[e]:e===`accountId`?t.target.value||void 0:t.target.value}})})]},e)),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`需要已连接 Telegram 渠道。发送通用摘要和卡片链接;链接中不要填写访问令牌。`:`Connect the Telegram channel first. Alerts contain a generic summary and a card link. Do not put access tokens in the URL.`})]}),t[47]=r,t[48]=n,t[49]=i,t[50]=L):L=t[50];let R;return t[51]!==C||t[52]!==A||t[53]!==M||t[54]!==I||t[55]!==L||t[56]!==d?(R=(0,x.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[d,C,A,M,I,L]}),t[51]=C,t[52]=A,t[53]=M,t[54]=I,t[55]=L,t[56]=d,t[57]=R):R=t[57],R}function w(e){let[t,n]=e;return(0,x.jsx)(s,{value:t,children:n},t)}function T(e){let t=(0,v.c)(63),{zh:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:3e4},t[0]=r):r=t[0];let{data:i,isLoading:a,error:o}=d(`/api/proactive/metrics`,y,r);if(a){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,x.jsx)(p,{className:`h-40 max-w-2xl rounded-2xl`}),t[1]=e):e=t[1],e}if(o){let e=String(o),n;return t[2]===e?n=t[3]:(n=(0,x.jsx)(`p`,{role:`alert`,className:`text-danger`,children:e}),t[2]=e,t[3]=n),n}let s=i?.metrics;if(!s)return null;let c;t[4]===s.feedback?c=t[5]:(c=s.feedback.find(A)?.count??0,t[4]=s.feedback,t[5]=c);let l=c,u=s.feedback.reduce(k,0),f=n?`最近 30 天`:`Last 30 days`,m;t[6]===f?m=t[7]:(m=(0,x.jsx)(`h2`,{className:`font-medium`,children:f}),t[6]=f,t[7]=m);let h=n?`卡片`:`Cards`,g;t[8]===s.cards.total?g=t[9]:(g=(0,x.jsx)(`strong`,{className:`block text-xl`,children:s.cards.total}),t[8]=s.cards.total,t[9]=g);let _;t[10]!==h||t[11]!==g?(_=(0,x.jsxs)(`p`,{children:[h,g]}),t[10]=h,t[11]=g,t[12]=_):_=t[12];let b=n?`已处理`:`Resolved`,S=s.cards.resolved??0,C;t[13]===S?C=t[14]:(C=(0,x.jsx)(`strong`,{className:`block text-xl`,children:S}),t[13]=S,t[14]=C);let w;t[15]!==C||t[16]!==b?(w=(0,x.jsxs)(`p`,{children:[b,C]}),t[15]=C,t[16]=b,t[17]=w):w=t[17];let T=n?`有用率`:`Useful feedback`,j;t[18]!==u||t[19]!==l?(j=u?`${Math.round(l/u*100)}%`:`—`,t[18]=u,t[19]=l,t[20]=j):j=t[20];let M;t[21]===j?M=t[22]:(M=(0,x.jsx)(`strong`,{className:`block text-xl`,children:j}),t[21]=j,t[22]=M);let N;t[23]!==T||t[24]!==M?(N=(0,x.jsxs)(`p`,{children:[T,M]}),t[23]=T,t[24]=M,t[25]=N):N=t[25];let P;t[26]!==w||t[27]!==N||t[28]!==_?(P=(0,x.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 text-sm`,children:[_,w,N]}),t[26]=w,t[27]=N,t[28]=_,t[29]=P):P=t[29];let F=n?`有用率仅统计已反馈卡片。费用为模型返回用量与价格表估算,不代表实际账单。投递接受不等于用户看到通知。`:`Usefulness measures submitted feedback. Cost uses reported usage and model pricing, not billing data. Provider acceptance does not prove a notification was seen.`,I;t[30]===F?I=t[31]:(I=(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:F}),t[30]=F,t[31]=I);let L=s.usage.inputTokens??`—`,R=s.usage.outputTokens??`—`,z=n?`已知成本估算`:`Known cost estimate`,B;t[32]===s.usage.estimatedCostUsd?B=t[33]:(B=s.usage.estimatedCostUsd==null?`—`:`$${s.usage.estimatedCostUsd.toFixed(4)}`,t[32]=s.usage.estimatedCostUsd,t[33]=B);let V;t[34]!==s.usage.pricedRuns||t[35]!==s.usage.totalRuns||t[36]!==L||t[37]!==R||t[38]!==z||t[39]!==B?(V=(0,x.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tokens: `,L,` / `,R,` · `,z,`: `,B,` (`,s.usage.pricedRuns,`/`,s.usage.totalRuns,`)`]}),t[34]=s.usage.pricedRuns,t[35]=s.usage.totalRuns,t[36]=L,t[37]=R,t[38]=z,t[39]=B,t[40]=V):V=t[40];let ee=n?`通知与投递记录`:`Notification and delivery counts`,H;t[41]===ee?H=t[42]:(H=(0,x.jsx)(`summary`,{className:`cursor-pointer`,children:ee}),t[41]=ee,t[42]=H);let U;if(t[43]!==s.interruptions||t[44]!==n){let e;t[46]===n?e=t[47]:(e=e=>(0,x.jsxs)(`li`,{children:[e.day,` · `,e.count,` `,n?`次提醒`:`alerts`]},e.day),t[46]=n,t[47]=e),U=s.interruptions.slice(0,7).map(e),t[43]=s.interruptions,t[44]=n,t[45]=U}else U=t[45];let W;t[48]!==s.browser||t[49]!==s.telegram?(W=[...s.browser.map(O),...s.telegram.map(D)].map(E),t[48]=s.browser,t[49]=s.telegram,t[50]=W):W=t[50];let G;t[51]!==U||t[52]!==W?(G=(0,x.jsxs)(`ul`,{className:`mt-3 space-y-1`,children:[U,W]}),t[51]=U,t[52]=W,t[53]=G):G=t[53];let K;t[54]!==H||t[55]!==G?(K=(0,x.jsxs)(`details`,{className:`text-sm`,children:[H,G]}),t[54]=H,t[55]=G,t[56]=K):K=t[56];let te;return t[57]!==P||t[58]!==I||t[59]!==V||t[60]!==K||t[61]!==m?(te=(0,x.jsxs)(`section`,{className:`max-w-2xl space-y-3 rounded-2xl border border-edge bg-surface-panel p-5`,children:[m,P,I,V,K]}),t[57]=P,t[58]=I,t[59]=V,t[60]=K,t[61]=m,t[62]=te):te=t[62],te}function E(e){return(0,x.jsxs)(`li`,{children:[e.channel,` · `,e.status,` · `,e.count]},`${e.channel}:${e.status}`)}function D(e){return{...e,channel:`Telegram`}}function O(e){return{...e,channel:`Web Push`}}function k(e,t){return e+t.count}function A(e){return e.rating===`useful`}function j({zh:e}){let[t,n]=(0,_.useState)(h),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),s=d(t?`/api/proactive/web-push/probes`:null,y,{refreshInterval:1e4});async function c(){i(!0),o(``);try{let e=localStorage.getItem(g());if(!e)throw Error(`Enable this browser first`);await b(`/api/proactive/web-push/subscriptions/${encodeURIComponent(e)}/test`,`POST`,{}),await s.mutate()}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}let l=!m()&&window.isSecureContext&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;async function u(){i(!0),o(``);try{if(t){let e=localStorage.getItem(g());e&&await b(`/api/proactive/web-push/subscriptions/${encodeURIComponent(e)}`,`DELETE`,{}),await(await(await navigator.serviceWorker.getRegistration(`/`))?.pushManager.getSubscription())?.unsubscribe(),localStorage.removeItem(g()),n(!1);return}if(await Notification.requestPermission()!==`granted`)throw Error(e?`浏览器未允许通知。`:`Browser notification permission was not granted.`);let{publicKey:r}=await b(`/api/proactive/web-push/prepare`,`POST`,{});await navigator.serviceWorker.register(`/notification-sw.js`);let i=await navigator.serviceWorker.ready,{id:a}=await b(`/api/proactive/web-push/subscriptions`,`POST`,{subscription:(await i.pushManager.getSubscription()??await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r})).toJSON(),language:e?`zh`:`en`});localStorage.setItem(g(),a),n(!0)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}return(0,x.jsxs)(`section`,{className:`max-w-2xl rounded-2xl border border-edge bg-surface-panel p-5`,children:[(0,x.jsx)(`h2`,{className:`font-medium`,children:e?`网页关闭后也接收提醒`:`Receive alerts when this page is closed`}),(0,x.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:e?`Gateway 需要保持在线。锁屏通知只显示通用提示,详情在应用内查看。`:`Keep the Gateway online. Lock-screen notifications contain a generic summary; open the app for details.`}),(0,x.jsx)(f,{className:`mt-4`,disabled:r||!l,onClick:()=>void u(),children:l?t?e?`关闭此浏览器推送`:`Disable browser push`:e?`启用此浏览器推送`:`Enable browser push`:e?`当前环境不支持 Web Push`:`Web Push is unavailable here`}),t&&(0,x.jsx)(f,{className:`ml-2 mt-4`,disabled:r,onClick:()=>void c(),children:e?`向此浏览器发送测试通知`:`Send a test to this browser`}),s.data?.probes.slice(0,3).map(t=>(0,x.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[new Date(t.createdAt).toLocaleString(),` · `,t.status===`opened`?e?`已点击打开`:`Opened`:t.status===`accepted`?e?`提供方已接受,等待点击确认`:`Provider accepted; awaiting open confirmation`:t.status,t.error&&` · ${t.error}`]},t.id)),a&&(0,x.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:a})]})}function M(e){return e?{locale:`zh`,title:`为你关注`,subtitle:`持续关注你选择的事项,在有价值的变化时交付卡片。`,cards:`动态卡片`,templates:`主动服务`,settings:`提醒设置`,levels:{off:`关闭`,quiet:`安静`,balanced:`适中`,active:`积极`},inherit:`继承全局`,save:`保存`,saved:`已保存`,level:`主动程度`,delivery:`提醒方式`,inbox:`仅展示卡片`,important:`重要变化时通知`,scope:`关注项目`,enable:`启用`,enabled:`已启用`,paused:`已暂停`,instructions:`关注偏好`,instructionsHint:`例如:只有影响对外承诺时才提醒我。`,interval:`兜底检查间隔(分钟,留空跟随程度)`,connection:`会议准备需要已连接且允许主动分析的日历来源。`,eventOnly:`此模板由业务事件触发。`,meetingWindows:`会议前 24 小时和 2 小时检查。`,quietStart:`免打扰开始(小时)`,quietEnd:`免打扰结束(小时)`,timezone:`时区`,limit:`每日通知上限`,pause:`暂停一小时`,resume:`结束暂停`,privacy:`主动程度只影响发现和提醒;自动执行权限仍由项目授权单独控制。Gateway 需要保持运行。`,empty:`暂时没有需要关注的变化。你可以先启用一个主动服务。`,all:`全部`,unread:`未读`,resolved:`已处理`,more:`下一页`,first:`返回首页`,whyNow:`为什么现在`,recommendation:`建议`,evidence:`依据`,investigated:`已检查`,read:`标为已读`,resolve:`已处理`,snooze:`一小时后`,less:`少提醒这类`,pauseTemplate:`暂停此服务`,expired:`已过期`,result:`执行结果`,retry:`重试`,close:`返回卡片列表`,runs:`检查记录`,noRuns:`还没有检查记录`,lastCheck:`上次扫描`,nextCheck:`下次扫描`,chooseProject:`选择项目`,choose:`选择`,loading:`正在处理`,kinds:{briefing:`简报`,reminder:`提醒`,risk:`风险`,recommendation:`建议`,decision:`待决定`,receipt:`执行回执`}}:{locale:`en`,title:`For you`,subtitle:`Follow the work you choose and receive useful changes as cards.`,cards:`Cards`,templates:`Proactive services`,settings:`Notifications`,levels:{off:`Off`,quiet:`Quiet`,balanced:`Balanced`,active:`Active`},inherit:`Use global level`,save:`Save`,saved:`Saved`,level:`Proactive level`,delivery:`Delivery`,inbox:`Cards only`,important:`Notify on important changes`,scope:`Project`,enable:`Enable`,enabled:`Enabled`,paused:`Paused`,instructions:`What matters to you`,instructionsHint:`For example: only alert me when an external commitment is affected.`,interval:`Fallback scan interval (minutes; blank uses level)`,connection:`Meeting preparation needs a connected calendar authorized for proactive analysis.`,eventOnly:`This template runs on business events.`,meetingWindows:`Checks 24 hours and 2 hours before meetings.`,quietStart:`Quiet hours start`,quietEnd:`Quiet hours end`,timezone:`Timezone`,limit:`Daily notification limit`,pause:`Pause for one hour`,resume:`Resume`,privacy:`Proactive level controls discovery and notifications. Action permissions remain separate in project settings. Keep the Gateway running.`,empty:`No changes need attention yet. Enable a proactive service to get started.`,all:`All`,unread:`Unread`,resolved:`Resolved`,more:`Next page`,first:`First page`,whyNow:`Why now`,recommendation:`Recommendation`,evidence:`Evidence`,investigated:`Checked`,read:`Mark read`,resolve:`Resolve`,snooze:`In one hour`,less:`Fewer alerts like this`,pauseTemplate:`Pause service`,expired:`Expired`,result:`Result`,retry:`Retry`,close:`Back to cards`,runs:`Run history`,noRuns:`No runs yet`,lastCheck:`Last scan`,nextCheck:`Next scan`,chooseProject:`Choose a project`,choose:`Choose`,loading:`Working`,kinds:{briefing:`Briefing`,reminder:`Reminder`,risk:`Risk`,recommendation:`Recommendation`,decision:`Decision`,receipt:`Receipt`}}}function N(e,t,n){if(n!==`zh`)return t;let r={meeting_preparation:[`会议准备`,`在会议前检查议程与资料,提示需要提前准备的事项。`],project_delivery_risk:[`项目交付风险`,`关注项目任务、依赖与承诺,发现可能影响交付的变化。`],automation_failure_impact:[`自动化失败影响`,`分析自动化故障的实际影响,提醒需要你处理的问题。`],blocked_work:[`工作阻塞`,`检查受阻任务及依赖,指出下一步可以推进的工作。`],discussion_follow_up:[`讨论后续`,`关注讨论中的结论与未完成事项,提示需要跟进的行动。`]}[e];return r?{title:r[0],description:r[1]}:t}function P(e,t){return t===`zh`?{approval_required:`等待确认`,executing:`正在执行`,rejected:`已拒绝`,completed:`已完成`,insight:`已生成卡片`,below_threshold:`未达到提醒标准`,succeeded:`检查完成`,succeeded_with_insight:`已生成卡片`,succeeded_no_insight:`无须提醒`,no_insight:`无须提醒`,running:`检查中`,pending:`等待检查`,retryable:`等待重试`,failed:`检查失败`,discarded:`已取消`,unchanged:`内容未变化`,routine:`常规变化`,insufficient_evidence:`证据不足`,duplicate:`重复发现`,disabled:`服务已关闭`,source_unavailable:`来源不可用`,low_value:`未达到提醒标准`,policy_changed:`设置已变化`}[e]??e.replaceAll(`_`,` `):e.replaceAll(`_`,` `)}function F({card:e,zh:t}){let n=`/api/inbox/judgments/${encodeURIComponent(e.id)}`,r=d(`${n}/workflow`,y,{refreshInterval:1e4}),[i,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``);async function l(t=!1){o(!0),c(``);try{await b(`${n}/prepare`,`POST`,{expectedRevision:e.revision,retry:t}),await r.mutate()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}if(r.isLoading)return(0,x.jsx)(p,{className:`mt-4 h-14`});let u=r.data?.workflow;return(0,x.jsxs)(`div`,{className:`mt-4 space-y-2 border-t border-edge pt-4 text-sm`,children:[u?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`p`,{children:[t?`准备清单`:`Preparation`,` · `,P(u.status,t?`zh`:`en`)]}),u.sessionKey&&(0,x.jsx)(a,{className:`text-accent`,to:`/chat/${encodeURIComponent(u.sessionKey)}`,children:t?`打开工作流与产物`:`Open workflow and artifacts`}),[`failed`,`cancelled`,`interrupted`].includes(u.status)&&(0,x.jsx)(f,{className:`ml-2`,disabled:i,onClick:()=>void l(!0),children:t?`重试工作流`:`Retry workflow`}),u.error&&(0,x.jsx)(`p`,{className:`text-danger`,children:u.error})]}):(0,x.jsx)(f,{disabled:i,onClick:()=>void l(),children:t?`运行准备清单工作流`:`Run preparation workflow`}),(s||r.error)&&(0,x.jsx)(`p`,{role:`alert`,className:`text-danger`,children:s||String(r.error)})]})}function I({card:e,copy:t,refresh:n,detail:r=!1}){let[i,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``),l=e.status!==`withdrawn`&&e.status!==`expired`&&e.status!==`resolved`;async function u(t,r){o(!0),c(``);try{await b(`/api/inbox/judgments/${encodeURIComponent(e.id)}/actions`,`POST`,{actionId:t,choice:r,expectedRevision:e.revision,idempotencyKey:crypto.randomUUID()}),n()}catch(e){c(e instanceof Error?e.message:String(e)),n()}finally{o(!1)}}return(0,x.jsxs)(`article`,{className:`rounded-2xl border border-edge bg-surface-panel p-5`,children:[(0,x.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,x.jsx)(`span`,{children:t.kinds[e.kind]??e.kind}),(0,x.jsx)(`time`,{dateTime:e.updatedAt,children:new Date(e.updatedAt).toLocaleString()})]}),(0,x.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:(0,x.jsx)(a,{to:`/proactive?item=${encodeURIComponent(e.id)}`,children:e.title})}),(0,x.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm text-fg-muted`,children:e.summary}),(0,x.jsxs)(`div`,{className:`mt-4 border-l-2 border-edge pl-3 text-sm`,children:[(0,x.jsx)(`span`,{className:`font-medium text-fg`,children:t.whyNow}),(0,x.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:e.whyNow})]}),r&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`mt-4 text-sm font-medium`,children:t.recommendation}),(0,x.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.recommendation}),(0,x.jsx)(`p`,{className:`mt-4 text-sm font-medium`,children:t.investigated}),(0,x.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.workDone})]}),e.decision&&l&&(0,x.jsxs)(`div`,{className:`mt-4`,children:[(0,x.jsx)(`p`,{className:`text-sm font-medium`,children:e.decision.question}),(0,x.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.decision.options.map(e=>(0,x.jsx)(f,{disabled:i||!l,title:e.consequence,onClick:()=>void u(`decide`,e.id),children:e.label},e.id))})]}),e.actionStatus&&(0,x.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t.result,`: `,P(e.actionStatus,t.locale)]}),typeof e.actionResult?.taskId==`string`&&(0,x.jsx)(a,{className:`mt-2 block text-sm text-accent`,to:`/tasks/${encodeURIComponent(e.actionResult.taskId)}`,children:t.result}),e.status===`withdrawn`&&(0,x.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.locale===`zh`?`来源已撤回,此卡片不再展示内容或允许操作。`:`The source was withdrawn. Content and actions are no longer available.`}),e.actionStatus===`failed`&&e.status!==`withdrawn`&&e.status!==`expired`&&(0,x.jsx)(f,{disabled:i,onClick:()=>void u(`retry`),children:t.retry}),e.actionError&&(0,x.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:e.actionError}),(0,x.jsxs)(`details`,{className:`mt-4 text-xs text-fg-muted`,children:[(0,x.jsxs)(`summary`,{className:`cursor-pointer`,children:[t.evidence,` · `,e.evidence.length]}),(0,x.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.evidence.map(e=>(0,x.jsxs)(`li`,{children:[e.route?(0,x.jsx)(a,{className:`text-accent`,to:e.route,children:e.label}):e.label,e.excerpt&&(0,x.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.excerpt})]},e.id))})]}),e.status===`withdrawn`?null:e.status===`expired`?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.expired}):e.status===`resolved`?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.resolved}):(0,x.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[e.status===`unread`&&(0,x.jsx)(f,{disabled:i,onClick:()=>void u(`read`),children:t.read}),(0,x.jsx)(f,{disabled:i,onClick:()=>void u(`resolve`),children:t.resolve}),(0,x.jsx)(f,{disabled:i,onClick:()=>void u(`snooze`),children:t.snooze}),(0,x.jsx)(f,{variant:`ghost`,disabled:i,onClick:()=>void u(`less`),children:t.less}),(0,x.jsx)(f,{variant:`ghost`,disabled:i,onClick:()=>void u(`pause`),children:t.pauseTemplate})]}),e.status!==`withdrawn`&&e.status!==`expired`&&(0,x.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,x.jsx)(f,{variant:`ghost`,disabled:i,onClick:()=>void u(`useful`),children:t.locale===`zh`?`有帮助`:`Useful`}),(0,x.jsx)(f,{variant:`ghost`,disabled:i,onClick:()=>void u(`not_useful`),children:t.locale===`zh`?`不相关`:`Not useful`})]}),!!e.relatedCardIds?.length&&(0,x.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,x.jsxs)(`summary`,{children:[t.locale===`zh`?`相关发现`:`Related findings`,` · `,e.relatedCardIds.length]}),e.relatedCardIds.map(e=>(0,x.jsx)(a,{className:`mt-2 block text-accent`,to:`/proactive?item=${encodeURIComponent(e)}`,children:t.locale===`zh`?`查看相关卡片`:`View related card`},e))]}),r&&e.preparationAvailable&&e.status!==`withdrawn`&&e.status!==`expired`&&(0,x.jsx)(F,{card:e,zh:t.locale===`zh`}),s&&(0,x.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s})]})}function L(e){let t=(0,v.c)(12),{value:n,onChange:r,zh:i}=e,{data:a,isLoading:c,error:l}=d(`/api/workflows/definitions`,y),u=i?`准备材料工作流(点击卡片后才运行)`:`Preparation workflow (runs only when clicked)`,f;t[0]!==a?.definitions||t[1]!==c||t[2]!==r||t[3]!==n||t[4]!==i?(f=c?(0,x.jsx)(p,{className:`mt-2 h-9`}):(0,x.jsxs)(o,{value:n,onChange:e=>r(e.target.value),children:[(0,x.jsx)(s,{value:``,children:i?`不关联工作流`:`No workflow`}),a?.definitions.map(R)]}),t[0]=a?.definitions,t[1]=c,t[2]=r,t[3]=n,t[4]=i,t[5]=f):f=t[5];let m;t[6]===l?m=t[7]:(m=l&&(0,x.jsx)(`span`,{className:`text-danger`,children:String(l)}),t[6]=l,t[7]=m);let h;return t[8]!==u||t[9]!==f||t[10]!==m?(h=(0,x.jsxs)(`label`,{className:`block text-sm`,children:[u,f,m]}),t[8]=u,t[9]=f,t[10]=m,t[11]=h):h=t[11],h}function R(e){return(0,x.jsx)(s,{value:e.id,children:e.title||e.name},e.id)}function z({subscriptionId:e,zh:t}){let[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(``);async function c(){r(!0),s(``);try{a(await b(`/api/proactive/subscriptions/${encodeURIComponent(e)}/preview`,`POST`,{}))}catch(e){s(e instanceof Error?e.message:String(e))}finally{r(!1)}}return(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(f,{disabled:n,onClick:()=>void c(),children:t?`只读预览已保存配置`:`Preview saved settings`}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`预览可能调用模型;不生成正式卡片或执行动作。每 5 分钟一次,每日最多 5 次。`:`May call the model. Does not create live cards or run actions. Limited to once per five minutes, five times daily.`}),n&&(0,x.jsx)(p,{className:`h-24`}),o&&(0,x.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:o}),i&&(0,x.jsxs)(`div`,{className:`rounded-lg border border-edge p-3 text-sm`,children:[(0,x.jsxs)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:[t?`预览结果`:`Preview result`,` · `,i.sourceCount,` `,t?`项依据`:`evidence items`]}),i.result.candidate?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`strong`,{children:i.result.candidate.title}),(0,x.jsx)(`p`,{children:i.result.candidate.summary}),(0,x.jsx)(`p`,{className:`mt-2 text-fg-muted`,children:i.result.candidate.whyNow})]}):(0,x.jsx)(`p`,{children:P(i.result.reason??`no_insight`,t?`zh`:`en`)})]})]})}var B=`mt-1 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`;function V({preferences:e,copy:t,refresh:n}){let[r,i]=(0,_.useState)(e),[a,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(``);async function d(i=r){c(!0),u(``);try{let{revision:a,...o}={...r,...i};await b(`/api/proactive/preferences`,`PATCH`,{...o,expectedRevision:e.revision}),u(t.saved),n()}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}}return(0,x.jsxs)(`form`,{className:`max-w-2xl space-y-5 rounded-2xl border border-edge bg-surface-panel p-5`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,x.jsxs)(`label`,{className:`block text-sm`,children:[t.level,(0,x.jsx)(o,{value:r.level,onChange:e=>i({...r,level:e.target.value}),children:Object.entries(t.levels).map(([e,t])=>(0,x.jsx)(s,{value:e,children:t},e))})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,x.jsxs)(`label`,{className:`text-sm`,children:[t.timezone,(0,x.jsx)(`input`,{required:!0,className:B,value:r.timezone,onChange:e=>i({...r,timezone:e.target.value})})]}),(0,x.jsxs)(`label`,{className:`text-sm`,children:[t.limit,(0,x.jsx)(`input`,{required:!0,type:`number`,min:0,max:30,className:B,value:r.dailyNotificationLimit,onChange:e=>i({...r,dailyNotificationLimit:Number(e.target.value)})})]}),(0,x.jsxs)(`label`,{className:`text-sm`,children:[t.quietStart,(0,x.jsx)(`input`,{required:!0,type:`number`,min:0,max:23,className:B,value:r.quietStartHour,onChange:e=>i({...r,quietStartHour:Number(e.target.value)})})]}),(0,x.jsxs)(`label`,{className:`text-sm`,children:[t.quietEnd,(0,x.jsx)(`input`,{required:!0,type:`number`,min:0,max:23,className:B,value:r.quietEndHour,onChange:e=>i({...r,quietEndHour:Number(e.target.value)})})]})]}),(0,x.jsx)(C,{value:r,onChange:i,zh:t.locale===`zh`}),(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.privacy}),(0,x.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,x.jsx)(f,{type:`submit`,variant:`primary`,disabled:a,children:t.save}),(0,x.jsx)(f,{disabled:a,onClick:()=>void d({pausedUntil:new Date(Date.now()+36e5).toISOString()}),children:t.pause}),e.pausedUntil&&(0,x.jsx)(f,{disabled:a,onClick:()=>void d({pausedUntil:null}),children:t.resume})]}),l&&(0,x.jsx)(`p`,{role:`status`,className:`text-sm`,children:l})]})}function ee({template:e,subscription:t,projects:n,copy:r,refresh:i}){let a=N(e.key,e,r.locale),[c,l]=(0,_.useState)(t?.level??`inherit`),[u,d]=(0,_.useState)(t?.delivery??`important`),[p,m]=(0,_.useState)(t?.scopeId??``),[h,g]=(0,_.useState)(t?.userInstructions??``),[v,y]=(0,_.useState)(t?.preparationWorkflowId??``),[S,C]=(0,_.useState)(t?.scanIntervalMinutes?.toString()??``),[w,T]=(0,_.useState)(t?.enabled??!0),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(``);async function A(){D(!0),k(``);let n={preparationWorkflowId:v||null,level:c===`inherit`?null:c,delivery:u,userInstructions:h,scanIntervalMinutes:S?Number(S):null,enabled:w};try{t?await b(`/api/proactive/subscriptions/${encodeURIComponent(t.id)}`,`PATCH`,{...n,expectedRevision:t.revision}):await b(`/api/proactive/subscriptions`,`POST`,{...n,scenarioKey:e.key,scopeKind:e.scopeKind,scopeId:e.scopeKind===`workspace`?`current`:p}),k(r.saved),i()}catch(e){k(e instanceof Error?e.message:String(e))}finally{D(!1)}}return(0,x.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),A()},className:`space-y-4 rounded-2xl border border-edge bg-surface-panel p-5`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h2`,{className:`font-semibold`,children:a.title}),(0,x.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.description})]}),t&&(0,x.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:t.enabled?r.enabled:r.paused})]}),e.scopeKind===`project`&&(0,x.jsxs)(`label`,{className:`block text-sm`,children:[r.scope,(0,x.jsxs)(o,{value:p,disabled:!!t,onChange:e=>m(e.target.value),children:[(0,x.jsx)(s,{value:``,children:r.chooseProject}),n.map(e=>(0,x.jsx)(s,{value:e.id,children:e.name},e.id))]})]}),(0,x.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,x.jsxs)(`label`,{className:`text-sm`,children:[r.level,(0,x.jsxs)(o,{value:c,onChange:e=>l(e.target.value),children:[(0,x.jsx)(s,{value:`inherit`,children:r.inherit}),Object.entries(r.levels).map(([e,t])=>(0,x.jsx)(s,{value:e,children:t},e))]})]}),(0,x.jsxs)(`label`,{className:`text-sm`,children:[r.delivery,(0,x.jsxs)(o,{value:u,onChange:e=>d(e.target.value),children:[(0,x.jsx)(s,{value:`important`,children:r.important}),(0,x.jsx)(s,{value:`inbox`,children:r.inbox}),(0,x.jsx)(s,{value:`digest`,children:r.locale===`zh`?`每日摘要`:`Daily digest`})]})]})]}),(0,x.jsxs)(`label`,{className:`block text-sm`,children:[r.instructions,(0,x.jsx)(`textarea`,{maxLength:12e3,rows:3,className:B,value:h,placeholder:r.instructionsHint,onChange:e=>g(e.target.value)})]}),e.scheduled&&!e.requiresCalendar&&(0,x.jsxs)(`label`,{className:`block text-sm`,children:[r.interval,(0,x.jsx)(`input`,{type:`number`,min:15,max:10080,className:B,value:S,onChange:e=>C(e.target.value)})]}),(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.requiresCalendar?`${r.connection} ${r.meetingWindows}`:e.scheduled?``:r.eventOnly}),e.calendarSource&&(0,x.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.calendarSource.status===`available`?`${r.locale===`zh`?`来源数据最近同步`:`Source data last synced`}: ${e.calendarSource.lastSyncedAt?new Date(e.calendarSource.lastSyncedAt).toLocaleString():`—`}`:r.locale===`zh`?`等待已授权的日历数据;请在连接器设置中连接日历并允许主动分析。`:`Waiting for authorized calendar data. Connect a calendar and allow proactive analysis in connector settings.`}),t?.schedule?.lastCheckedAt&&(0,x.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[r.lastCheck,`: `,new Date(t.schedule.lastCheckedAt).toLocaleString()]}),(0,x.jsx)(L,{value:v,onChange:y,zh:r.locale===`zh`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,x.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked)}),r.enable]}),(0,x.jsx)(f,{type:`submit`,variant:`primary`,disabled:E||e.scopeKind===`project`&&!p,children:r.save})]}),t&&(0,x.jsx)(z,{subscriptionId:t.id,zh:r.locale===`zh`}),t&&(0,x.jsx)(H,{subscriptionId:t.id,copy:r}),O&&(0,x.jsx)(`p`,{role:`status`,className:`text-sm`,children:O})]})}function H(e){let t=(0,v.c)(13),{subscriptionId:n,copy:r}=e,[i,a]=(0,_.useState)(!1),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:15e3},t[0]=o):o=t[0];let s=d(i?`/api/proactive/subscriptions/${encodeURIComponent(n)}/runs`:null,y,o),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>a(e.currentTarget.open),t[1]=c):c=t[1];let l;t[2]===r.runs?l=t[3]:(l=(0,x.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:r.runs}),t[2]=r.runs,t[3]=l);let u;t[4]!==r.locale||t[5]!==r.noRuns||t[6]!==s.data?.runs||t[7]!==s.error||t[8]!==s.isLoading?(u=s.isLoading?(0,x.jsx)(p,{className:`mt-3 h-20`}):s.error?(0,x.jsx)(`p`,{role:`alert`,className:`mt-3 text-danger`,children:String(s.error)}):(0,x.jsxs)(`ul`,{className:`mt-3 space-y-3`,children:[s.data?.runs.length===0&&(0,x.jsx)(`li`,{className:`text-fg-muted`,children:r.noRuns}),s.data?.runs.map(e=>(0,x.jsxs)(`li`,{children:[(0,x.jsxs)(`p`,{children:[P(e.status,r.locale),e.reason&&` · ${P(e.reason,r.locale)}`]}),(0,x.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.startedAt&&new Date(e.startedAt).toLocaleString(),e.error&&` · ${e.error}`]})]},e.id))]}),t[4]=r.locale,t[5]=r.noRuns,t[6]=s.data?.runs,t[7]=s.error,t[8]=s.isLoading,t[9]=u):u=t[9];let f;return t[10]!==l||t[11]!==u?(f=(0,x.jsxs)(`details`,{className:`border-t border-edge pt-3 text-sm`,onToggle:c,children:[l,u]}),t[10]=l,t[11]=u,t[12]=f):f=t[12],f}function U(){let e=(0,v.c)(85),t=l(re),n=t===`zh`,r;e[0]===n?r=e[1]:(r=M(n),e[0]=n,e[1]=r);let o=r,[s,c]=i(),u;e[2]===s?u=e[3]:(u=s.get(`tab`)??`cards`,e[2]=s,e[3]=u);let p=u,m;e[4]===s?m=e[5]:(m=s.get(`item`),e[4]=s,e[5]=m);let h=m,g;e[6]===s?g=e[7]:(g=s.get(`digest`),e[6]=s,e[7]=g);let S=g,C;e[8]===s?C=e[9]:(C=s.get(`probe`),e[8]=s,e[9]=C);let w=C,[E]=(0,_.useState)(ne),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(``),N=d(`/api/proactive/preferences`,y),P=d(p===`templates`?`/api/proactive/templates`:null,y),F=d(p===`templates`?`/api/proactive/subscriptions`:null,y),L=d(p===`templates`?`/api/projects?limit=200`:null,y),R;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(R={refreshInterval:15e3},e[10]=R):R=e[10];let z=d(p===`cards`&&!h&&!S?`/api/proactive/cards?status=${D}&before=${encodeURIComponent(k)}`:null,y,R),B;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(B={refreshInterval:15e3},e[11]=B):B=e[11];let H=d(S?`/api/proactive/digests/${encodeURIComponent(S)}`:null,y,B),U,ie;e[12]===w?(U=e[13],ie=e[14]):(U=()=>{w&&b(`/api/proactive/web-push/probes/${encodeURIComponent(w)}/opened`,`POST`,{}).catch(te)},ie=[w],e[12]=w,e[13]=U,e[14]=ie),(0,_.useEffect)(U,ie);let ae,oe;e[15]!==E||e[16]!==p?(ae=()=>{let e=p===`cards`,t=()=>{b(`/api/proactive/presence`,`POST`,{clientId:E,surface:`web`,active:e&&document.visibilityState===`visible`&&document.hasFocus()}).catch(K)};t();let n=window.setInterval(t,3e4);return document.addEventListener(`visibilitychange`,t),window.addEventListener(`focus`,t),window.addEventListener(`blur`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t),window.removeEventListener(`blur`,t),b(`/api/proactive/presence`,`POST`,{clientId:E,surface:`web`,active:!1}).catch(G)}},oe=[E,p],e[15]=E,e[16]=p,e[17]=ae,e[18]=oe):(ae=e[17],oe=e[18]),(0,_.useEffect)(ae,oe);let se;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(se={refreshInterval:15e3},e[19]=se):se=e[19];let q=d(h?`/api/inbox/judgments/${encodeURIComponent(h)}`:null,y,se),ce;e[20]!==z||e[21]!==q||e[22]!==H||e[23]!==F?(ce=()=>{z.mutate(),q.mutate(),H.mutate(),F.mutate()},e[20]=z,e[21]=q,e[22]=H,e[23]=F,e[24]=ce):ce=e[24];let J=ce,le;e[25]!==z||e[26]!==q?(le=()=>{let e=()=>{z.mutate(),q.mutate()};return window.addEventListener(`proactive-card-changed`,e),()=>window.removeEventListener(`proactive-card-changed`,e)},e[25]=z,e[26]=q,e[27]=le):le=e[27];let ue;e[28]!==z.mutate||e[29]!==q.mutate?(ue=[z.mutate,q.mutate],e[28]=z.mutate,e[29]=q.mutate,e[30]=ue):ue=e[30],(0,_.useEffect)(le,ue);let Y=H.error??N.error??z.error??q.error??P.error??F.error??L.error,de=H.isLoading||N.isLoading||z.isLoading||q.isLoading||P.isLoading||F.isLoading||L.isLoading,X;e[31]===o.title?X=e[32]:(X=(0,x.jsx)(`h1`,{className:`text-2xl font-semibold text-fg`,children:o.title}),e[31]=o.title,e[32]=X);let Z;e[33]===c?Z=e[34]:(Z=()=>c({tab:`settings`}),e[33]=c,e[34]=Z);let fe=N.data?o.levels[N.data.preferences.level]:`…`,Q;e[35]!==o.level||e[36]!==Z||e[37]!==fe?(Q=(0,x.jsxs)(f,{variant:`ghost`,onClick:Z,children:[o.level,`: `,fe]}),e[35]=o.level,e[36]=Z,e[37]=fe,e[38]=Q):Q=e[38];let $;e[39]!==X||e[40]!==Q?($=(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[X,Q]}),e[39]=X,e[40]=Q,e[41]=$):$=e[41];let pe;e[42]===o.subtitle?pe=e[43]:(pe=(0,x.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:o.subtitle}),e[42]=o.subtitle,e[43]=pe);let me;e[44]!==$||e[45]!==pe?(me=(0,x.jsxs)(`header`,{children:[$,pe]}),e[44]=$,e[45]=pe,e[46]=me):me=e[46];let he=o.title,ge;e[47]===Symbol.for(`react.memo_cache_sentinel`)?(ge=[`cards`,`templates`,`settings`],e[47]=ge):ge=e[47];let _e;e[48]!==o||e[49]!==h||e[50]!==c||e[51]!==p?(_e=ge.map(e=>(0,x.jsx)(f,{variant:p===e&&!h?`primary`:`ghost`,onClick:()=>c(e===`cards`?{}:{tab:e}),children:o[e]},e)),e[48]=o,e[49]=h,e[50]=c,e[51]=p,e[52]=_e):_e=e[52];let ve;e[53]!==o.title||e[54]!==_e?(ve=(0,x.jsx)(`nav`,{className:`flex gap-2`,"aria-label":he,children:_e}),e[53]=o.title,e[54]=_e,e[55]=ve):ve=e[55];let ye;e[56]!==o.retry||e[57]!==Y||e[58]!==N||e[59]!==L||e[60]!==J||e[61]!==P?(ye=Y&&(0,x.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-edge p-4 text-sm text-danger`,children:[Y instanceof Error?Y.message:String(Y),(0,x.jsx)(f,{className:`ml-3`,onClick:()=>{J(),N.mutate(),P.mutate(),L.mutate()},children:o.retry})]}),e[56]=o.retry,e[57]=Y,e[58]=N,e[59]=L,e[60]=J,e[61]=P,e[62]=ye):ye=e[62];let be;e[63]!==k||e[64]!==z.data||e[65]!==o||e[66]!==q.data||e[67]!==H.data?.cards||e[68]!==S||e[69]!==h||e[70]!==t||e[71]!==de||e[72]!==N||e[73]!==L||e[74]!==J||e[75]!==D||e[76]!==F.data?.subscriptions||e[77]!==p||e[78]!==P?(be=de?(0,x.jsx)(`div`,{"aria-busy":!0,className:`space-y-4`,children:[0,1,2].map(W)}):S?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`h2`,{className:`font-medium`,children:t===`zh`?`工作摘要`:`Work digest`}),H.data?.cards.length===0&&(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t===`zh`?`这份摘要中的事项已处理、过期或撤回。`:`Items in this digest are resolved, expired, or withdrawn.`}),H.data?.cards.map(e=>(0,x.jsx)(I,{card:e,copy:o,refresh:J},e.id))]}):h?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(a,{className:`text-sm text-accent`,to:`/proactive`,children:o.close}),q.data&&(0,x.jsx)(I,{card:q.data.card,copy:o,refresh:J,detail:!0})]}):p===`settings`&&N.data?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(V,{preferences:N.data.preferences,copy:o,refresh:()=>void N.mutate()},N.data.preferences.revision),(0,x.jsx)(j,{zh:t===`zh`}),(0,x.jsx)(T,{zh:t===`zh`})]}):p===`templates`?(0,x.jsx)(`div`,{className:`grid items-start gap-4 lg:grid-cols-2`,children:P.data?.templates.flatMap(e=>{let t=F.data?.subscriptions.filter(t=>t.scenarioKey===e.key)??[];return[...t.map(t=>(0,x.jsx)(ee,{template:e,subscription:t,projects:L.data?.items??[],copy:o,refresh:J},`${t.id}:${t.revision}`)),...t.length===0||e.scopeKind===`project`?[(0,x.jsx)(ee,{template:e,projects:(L.data?.items??[]).filter(e=>!t.some(t=>t.scopeId===e.id)),copy:o,refresh:J},`new:${e.key}`)]:[]]})}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`flex gap-2`,children:[[``,o.all],[`unread`,o.unread],[`resolved`,o.resolved]].map(e=>{let[t,n]=e;return(0,x.jsx)(f,{variant:D===t?`secondary`:`ghost`,onClick:()=>{O(t),A(``)},children:n},t)})}),z.data?.cards.length===0&&(0,x.jsxs)(`div`,{className:`rounded-2xl border border-edge p-10 text-center text-sm text-fg-muted`,children:[o.empty,(0,x.jsx)(a,{className:`mt-3 block text-accent`,to:`/proactive?tab=templates`,children:o.templates})]}),(0,x.jsx)(`div`,{className:`space-y-4`,children:z.data?.cards.map(e=>(0,x.jsx)(I,{card:e,copy:o,refresh:J},e.id))}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[k&&(0,x.jsx)(f,{onClick:()=>A(``),children:o.first}),z.data?.nextCursor&&(0,x.jsx)(f,{onClick:()=>A(z.data.nextCursor),children:o.more})]})]}),e[63]=k,e[64]=z.data,e[65]=o,e[66]=q.data,e[67]=H.data?.cards,e[68]=S,e[69]=h,e[70]=t,e[71]=de,e[72]=N,e[73]=L,e[74]=J,e[75]=D,e[76]=F.data?.subscriptions,e[77]=p,e[78]=P,e[79]=be):be=e[79];let xe;return e[80]!==me||e[81]!==ve||e[82]!==ye||e[83]!==be?(xe=(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-base`,children:(0,x.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-6 px-4 py-7 sm:px-6`,children:[me,ve,ye,be]})}),e[80]=me,e[81]=ve,e[82]=ye,e[83]=be,e[84]=xe):xe=e[84],xe}function W(e){return(0,x.jsx)(p,{className:`h-44 rounded-2xl`},e)}function G(){}function K(){}function te(){}function ne(){return crypto.randomUUID()}function re(e){return e.language}export{U as ProactivePage};