@xopcai/xopc 0.0.446 → 0.0.448

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 (274) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/src/draft-stream-lifecycle.d.ts +2 -3
  3. package/dist/extensions/telegram/src/plugin.d.ts +0 -1
  4. package/dist/extensions/telegram/src/plugin.js +0 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/{activity-store-Ddf-02Rf.js → activity-store-Tn5McYcg.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dcu4ggpV.js → agent-avatar-dicebear-BX5HhrTI.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-avatar-display-CarpM_qc.js → agent-avatar-display-C7Dx9nt1.js} +2 -2
  9. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-B4GynTfH.js → agent-defaults-settings-panel-AAJsxEjB.js} +1 -1
  10. package/dist/gateway/static/root/assets/{agent-plugin-dialog-BWQ_Diyv.js → agent-plugin-dialog-BhtzU8qr.js} +1 -1
  11. package/dist/gateway/static/root/assets/{agents-DKaImiga.js → agents-CbGYb9WI.js} +3 -3
  12. package/dist/gateway/static/root/assets/{agents-admin-api-BwoePPTG.js → agents-admin-api-CShyoj9I.js} +1 -1
  13. package/dist/gateway/static/root/assets/{api-MJxs2HLk.js → api-B3M6ifoo.js} +1 -1
  14. package/dist/gateway/static/root/assets/{api-Cc72Y3ct.js → api-BET9vZ1l.js} +1 -1
  15. package/dist/gateway/static/root/assets/{app-management-settings-panel-Cy6szt9g.js → app-management-settings-panel-BxOShFPO.js} +1 -1
  16. package/dist/gateway/static/root/assets/{appearance-settings-Dy75gAe7.js → appearance-settings-L450QlMW.js} +1 -1
  17. package/dist/gateway/static/root/assets/{apps-page-DlwW9ClN.js → apps-page-BNhpN8RA.js} +1 -1
  18. package/dist/gateway/static/root/assets/{archive-plugin-_5jgYMZC.js → archive-plugin-BCXEOal7.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automation-api-DrxC4rCG.js → automation-api-B3Jnoa2G.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automation-result-state-Ba_q8_Jj.js → automation-result-state-BHAKc5QI.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automation-run-list-DuyMQwtf.js → automation-run-list-De7gini_.js} +1 -1
  22. package/dist/gateway/static/root/assets/automation-task-card-Clf0fe_n.js +3 -0
  23. package/dist/gateway/static/root/assets/{automations-page-D-Sl7Dhr.js → automations-page-CJ1rfmZd.js} +1 -1
  24. package/dist/gateway/static/root/assets/automations-workspace-CHFTlLiA.js +9 -0
  25. package/dist/gateway/static/root/assets/{binary-plugins-BYHCUreq.js → binary-plugins-B7tuUWzS.js} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-DI_JHx-P.js → block-editor-D-YHASZr.js} +55 -55
  27. package/dist/gateway/static/root/assets/{browser-settings-page-DXBM5lpK.js → browser-settings-page-DdMMia7Y.js} +1 -1
  28. package/dist/gateway/static/root/assets/capabilities-Cxh3nYa6.js +1 -0
  29. package/dist/gateway/static/root/assets/{capabilities-CUHCbQ5N.js → capabilities-YfkMBZCb.js} +1 -1
  30. package/dist/gateway/static/root/assets/{capabilities-page-RJnyR_V9.js → capabilities-page-DosENGaK.js} +2 -2
  31. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CxSrK6bJ.js → capabilities-settings-panel-qZ3S06yZ.js} +1 -1
  32. package/dist/gateway/static/root/assets/{channels-CBXmRfVR.js → channels-BBgyZnHB.js} +1 -1
  33. package/dist/gateway/static/root/assets/{chat-agents-api-D6sJpLeT.js → chat-agents-api-CgasFAm4.js} +1 -1
  34. package/dist/gateway/static/root/assets/{chat-chart-block-B2U7epTQ.js → chat-chart-block-Cgks7rH3.js} +1 -1
  35. package/dist/gateway/static/root/assets/chat-page-CCwdk6yE.js +71 -0
  36. package/dist/gateway/static/root/assets/{chat-terminal-dock-XNPvQhNw.js → chat-terminal-dock-CbP1mS4v.js} +1 -1
  37. package/dist/gateway/static/root/assets/{command-palette-api-DbL0oPXq.js → command-palette-api-Bku_h283.js} +1 -1
  38. package/dist/gateway/static/root/assets/{composer-payload-handoff-CaxZicbL.js → composer-payload-handoff-CrTYMPL_.js} +1 -1
  39. package/dist/gateway/static/root/assets/{computer-settings-page-Velpw46s.js → computer-settings-page-zvWUPPAr.js} +1 -1
  40. package/dist/gateway/static/root/assets/{connected-providers-grid-Y79g354a.js → connected-providers-grid-w3htbAyh.js} +1 -1
  41. package/dist/gateway/static/root/assets/{connection-usage-guide-BaDoesqn.js → connection-usage-guide-DL2T6cSN.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connector-service-page-C5mVM3zg.js → connector-service-page-a0gQC-nc.js} +1 -1
  43. package/dist/gateway/static/root/assets/{connectors-api-Cgiy3Dyn.js → connectors-api-DNVUmf9M.js} +1 -1
  44. package/dist/gateway/static/root/assets/{connectors-page-DDSTfe3M.js → connectors-page-CPGlpvoB.js} +1 -1
  45. package/dist/gateway/static/root/assets/constants-DpkUgykJ.js +1 -0
  46. package/dist/gateway/static/root/assets/date-picker-E0cqnNlR.js +1 -0
  47. package/dist/gateway/static/root/assets/date-time-picker-CrC_VKpw.js +1 -0
  48. package/dist/gateway/static/root/assets/{desktop-pet-D1buh7JC.js → desktop-pet-D1MkNl5F.js} +1 -1
  49. package/dist/gateway/static/root/assets/{desktop-pet-narrative-C8zQtMcw.js → desktop-pet-narrative-B7I1II0Z.js} +1 -1
  50. package/dist/gateway/static/root/assets/{desktop-pet-settings-CVs5timB.js → desktop-pet-settings-BA6u5Md-.js} +1 -1
  51. package/dist/gateway/static/root/assets/{dev-view-store-rdp0Stsh.js → dev-view-store-DnqJb6NS.js} +1 -1
  52. package/dist/gateway/static/root/assets/{device-pairing-wizard-ZX1oup6S.js → device-pairing-wizard-Ba3d606o.js} +1 -1
  53. package/dist/gateway/static/root/assets/{directory-picker-path-field-BN57kiUt.js → directory-picker-path-field-lcps-hsZ.js} +1 -1
  54. package/dist/gateway/static/root/assets/{discussion-annotation-sync-BG-sbtYu.js → discussion-annotation-sync-BmvCn1Xn.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-debug-page-DuuOhNRp.js → extension-debug-page-DED5LHxs.js} +1 -1
  56. package/dist/gateway/static/root/assets/{extension-iframe-host-DzzKhhvD.js → extension-iframe-host-B0oIml1X.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-marketplace-api-5BBPFsmU.js → extension-marketplace-api-BrLsjJLA.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-page-DDmRVcIm.js → extension-page-Ber9sWpz.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-provider-CFzHYMV0.js → extension-provider-dpOtxmuc.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-settings-page-DGAD52bm.js → extension-settings-page-BSG-nJ_7.js} +1 -1
  61. package/dist/gateway/static/root/assets/{file-preview-surface-DgG6OJyj.js → file-preview-surface-B3nLuoQO.js} +1 -1
  62. package/dist/gateway/static/root/assets/{gateway-config-swr-D0yocd87.js → gateway-config-swr-CtZy1Qw0.js} +1 -1
  63. package/dist/gateway/static/root/assets/{gateway-realtime-DpNC3Y7U.js → gateway-realtime-CG65gHUY.js} +1 -1
  64. package/dist/gateway/static/root/assets/gateway-realtime-store-Vl3uKAHV.js +1 -0
  65. package/dist/gateway/static/root/assets/{gateway-restart-C_8Z4DRU.js → gateway-restart-Cr5xtfZU.js} +1 -1
  66. package/dist/gateway/static/root/assets/{gateway-settings-CGlpz-Ft.js → gateway-settings-BwMwdwXh.js} +1 -1
  67. package/dist/gateway/static/root/assets/{gateway-startup-retry-BPSM56sw.js → gateway-startup-retry-DztAHGru.js} +1 -1
  68. package/dist/gateway/static/root/assets/{global-defaults-api-BFsm77dC.js → global-defaults-api-yHc-ZfjU.js} +1 -1
  69. package/dist/gateway/static/root/assets/home-page-DGsDrtlA.js +3 -0
  70. package/dist/gateway/static/root/assets/{image-generation-api-wJi7zpES.js → image-generation-api-D5eo_stq.js} +1 -1
  71. package/dist/gateway/static/root/assets/{imports-page-iddP3PVx.js → imports-page-CLbpRE5i.js} +1 -1
  72. package/dist/gateway/static/root/assets/index-D1EDrkUo.css +1 -0
  73. package/dist/gateway/static/root/assets/index-Dw5NFmnZ.js +11 -0
  74. package/dist/gateway/static/root/assets/install-connector-dialog-B-v1FT3P.js +1 -0
  75. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Cxdd0r3Z.js → keyboard-shortcuts-settings-BLBASsCP.js} +1 -1
  76. package/dist/gateway/static/root/assets/linkify-it-BkqEorO0.js +1 -0
  77. package/dist/gateway/static/root/assets/{local-app-workbench-page-jfkZZHHd.js → local-app-workbench-page-u0lVT4rD.js} +1 -1
  78. package/dist/gateway/static/root/assets/{local-apps-page-BwWuY0x2.js → local-apps-page-Db93n4Zy.js} +1 -1
  79. package/dist/gateway/static/root/assets/{local-session-drafts-cTAkoNSf.js → local-session-drafts-C6oPrCYY.js} +1 -1
  80. package/dist/gateway/static/root/assets/{locale-store-DJYUYPdV.js → locale-store-CQcW9_qA.js} +1 -1
  81. package/dist/gateway/static/root/assets/logs-page-Dtoheh2t.js +2 -0
  82. package/dist/gateway/static/root/assets/{management-api-CmBUdfsn.js → management-api-Dh2r5GrQ.js} +1 -1
  83. package/dist/gateway/static/root/assets/{management-settings-CYn1EOVo.js → management-settings-Fj25fafb.js} +1 -1
  84. package/dist/gateway/static/root/assets/{markdown-view-DrcA6Cfr.js → markdown-view-CkihBz06.js} +1 -1
  85. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-C5D5oueS.js → mcp-conversation-setup-page-jh3dwNfg.js} +1 -1
  86. package/dist/gateway/static/root/assets/{media-plugins-CQZ0Jh_x.js → media-plugins-BUapXtQZ.js} +1 -1
  87. package/dist/gateway/static/root/assets/messages-orB1BMgI.js +3 -0
  88. package/dist/gateway/static/root/assets/{model-selector-CbKl8YPf.js → model-selector-DYxgKUju.js} +1 -1
  89. package/dist/gateway/static/root/assets/{models-hub-cache-CwxnL3rY.js → models-hub-cache-D2cdb8nZ.js} +1 -1
  90. package/dist/gateway/static/root/assets/{note-detail-panel-uQO4kymH.js → note-detail-panel-Bw5VDFPV.js} +3 -3
  91. package/dist/gateway/static/root/assets/note-image-lightbox-C6aTUp-c.js +1 -0
  92. package/dist/gateway/static/root/assets/{notes-api-DoCb3QlH.js → notes-api-BhRyWe3S.js} +1 -1
  93. package/dist/gateway/static/root/assets/{notes-page-DOl7cqLg.js → notes-page-BmmeGUUy.js} +1 -1
  94. package/dist/gateway/static/root/assets/{oauth-api-3b_QtYeo.js → oauth-api-D5iBtOid.js} +1 -1
  95. package/dist/gateway/static/root/assets/{oauth-provider-connect-D1JQ4FBf.js → oauth-provider-connect-CmHsHynu.js} +1 -1
  96. package/dist/gateway/static/root/assets/{page-context-capture-button-CVIVl1MQ.js → page-context-capture-button-CQoRZ1b-.js} +1 -1
  97. package/dist/gateway/static/root/assets/{page-context-draft-Ky5J09qv.js → page-context-draft-aApa5ApP.js} +1 -1
  98. package/dist/gateway/static/root/assets/page-header-store-B2Ahfm0W.js +1 -0
  99. package/dist/gateway/static/root/assets/{personal-avatar-Dh4qjZYy.js → personal-avatar-Dp5LHjk3.js} +1 -1
  100. package/dist/gateway/static/root/assets/{personal-page-edoGNvVa.js → personal-page-gdKGnAPi.js} +1 -1
  101. package/dist/gateway/static/root/assets/{personal-settings-panel-BtTwDaw0.js → personal-settings-panel-CtJL6qIN.js} +1 -1
  102. package/dist/gateway/static/root/assets/{phone-dependencies-card-B6rA2lO_.js → phone-dependencies-card-BBk6k0t0.js} +1 -1
  103. package/dist/gateway/static/root/assets/{phone-model-connection-xqaXDOVF.js → phone-model-connection-QJt8SAb7.js} +1 -1
  104. package/dist/gateway/static/root/assets/{phone-model-picker-yuGXKCM9.js → phone-model-picker-CRxUxJNZ.js} +1 -1
  105. package/dist/gateway/static/root/assets/{phone-settings-page-DhjuPpF4.js → phone-settings-page-Df64khPY.js} +1 -1
  106. package/dist/gateway/static/root/assets/{phone-workspace-store-2xQhZsJr.js → phone-workspace-store-DAuPd2ie.js} +1 -1
  107. package/dist/gateway/static/root/assets/{plugin-details-dialog-CIS3SUKM.js → plugin-details-dialog-Bcer4RC3.js} +1 -1
  108. package/dist/gateway/static/root/assets/{preference-select-fields-BAZSKhoi.js → preference-select-fields-DdV7q9Bd.js} +1 -1
  109. package/dist/gateway/static/root/assets/{product-automation-feedback-Bh37tBpR.js → product-automation-feedback-uKndNxpU.js} +1 -1
  110. package/dist/gateway/static/root/assets/{product-open-page-BXcS7lCW.js → product-open-page-A7lyoXVv.js} +1 -1
  111. package/dist/gateway/static/root/assets/{product-preview-content-BNultFGN.js → product-preview-content-BrdvkWOg.js} +1 -1
  112. package/dist/gateway/static/root/assets/product-preview-modal-BxHKejcX.js +2 -0
  113. package/dist/gateway/static/root/assets/project-detail-page-BedOnA0G.js +7 -0
  114. package/dist/gateway/static/root/assets/{project-understanding-CrYVzB8i.js → project-understanding-BVhSoQHu.js} +1 -1
  115. package/dist/gateway/static/root/assets/{projects-page-nEhOaONB.js → projects-page-DSPoyFda.js} +1 -1
  116. package/dist/gateway/static/root/assets/{providers-api-MimHCxo_.js → providers-api-B47s6_9Q.js} +1 -1
  117. package/dist/gateway/static/root/assets/{recording-upload-BUe8jmx8.js → recording-upload-B-IHTsVC.js} +1 -1
  118. package/dist/gateway/static/root/assets/{registry-api-CkrGCW-C.js → registry-api-Bo8YiUE0.js} +1 -1
  119. package/dist/gateway/static/root/assets/{remote-access-hub-QqFEiO0m.js → remote-access-hub-BRf9znLV.js} +1 -1
  120. package/dist/gateway/static/root/assets/{resource-unavailable-CSc5SeHy.js → resource-unavailable-CAljzZx8.js} +1 -1
  121. package/dist/gateway/static/root/assets/route-preload-cpv-TDla.js +2 -0
  122. package/dist/gateway/static/root/assets/{runtime-tools-api-BzLDrYX8.js → runtime-tools-api-C28pB9__.js} +1 -1
  123. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DST1lBFY.js → runtime-tools-settings-panel-XYeadnhL.js} +1 -1
  124. package/dist/gateway/static/root/assets/{service-recommendation-list-DezuXPLs.js → service-recommendation-list-C6ydoBSU.js} +1 -1
  125. package/dist/gateway/static/root/assets/{session-api-QnBTnXGH.js → session-api-D7FWdG43.js} +1 -1
  126. package/dist/gateway/static/root/assets/{session-manager-b2zxVzZI.js → session-manager-7qKSmROh.js} +1 -1
  127. package/dist/gateway/static/root/assets/{sessions-page-uarYA2Xw.js → sessions-page-CyYkCsfy.js} +1 -1
  128. package/dist/gateway/static/root/assets/settings-advanced-gate-B3rOBkm_.js +1 -0
  129. package/dist/gateway/static/root/assets/{settings-advanced-section-Crhl0mQp.js → settings-advanced-section-3HwfHbqz.js} +1 -1
  130. package/dist/gateway/static/root/assets/{settings-mode-store-CrM7SFWJ.js → settings-mode-store-BVvIXZlg.js} +1 -1
  131. package/dist/gateway/static/root/assets/{settings-page-BrogpvEd.js → settings-page-DLmsK1x2.js} +1 -1
  132. package/dist/gateway/static/root/assets/{settings-page-header-DPKy790x.js → settings-page-header-CheboxIM.js} +1 -1
  133. package/dist/gateway/static/root/assets/{settings-page-layout-8kCWtU5m.js → settings-page-layout-CPFMZaLF.js} +1 -1
  134. package/dist/gateway/static/root/assets/{setup-interaction-page-BVnMLwC-.js → setup-interaction-page-BbCzYq9S.js} +1 -1
  135. package/dist/gateway/static/root/assets/{setup-status-panel--Fb7FwVG.js → setup-status-panel-DUNgVqtz.js} +1 -1
  136. package/dist/gateway/static/root/assets/{share-link-dialog-C45dGG9y.js → share-link-dialog-0P9ghttc.js} +1 -1
  137. package/dist/gateway/static/root/assets/{share-preview-page-ConV6wRP.js → share-preview-page-OOKslNfX.js} +1 -1
  138. package/dist/gateway/static/root/assets/{shares-api-BsDhQwd3.js → shares-api-iiw4F-ra.js} +1 -1
  139. package/dist/gateway/static/root/assets/{shares-settings-DJz0p2PL.js → shares-settings-DUB9Ek8Q.js} +1 -1
  140. package/dist/gateway/static/root/assets/skill-api-CLtIjE8K.js +1 -0
  141. package/dist/gateway/static/root/assets/{skill-list-api-DWCkzC6W.js → skill-list-api-DY0rRlUk.js} +1 -1
  142. package/dist/gateway/static/root/assets/{skill-reload-api-C2jfZi01.js → skill-reload-api-DJC8uWLu.js} +1 -1
  143. package/dist/gateway/static/root/assets/skills-page-CQYf7s9f.js +2 -0
  144. package/dist/gateway/static/root/assets/{system-settings-panel-BiswiIqg.js → system-settings-panel-DdBmyc93.js} +1 -1
  145. package/dist/gateway/static/root/assets/task-detail-page-BskTta5G.js +3 -0
  146. package/dist/gateway/static/root/assets/task-input-card-5BDu71NL.js +1 -0
  147. package/dist/gateway/static/root/assets/{tasks-D_xuHn6V.js → tasks-BTLabOMp.js} +1 -1
  148. package/dist/gateway/static/root/assets/{terminal-panel-store-qS6f2G-H.js → terminal-panel-store-B1EVdx4L.js} +1 -1
  149. package/dist/gateway/static/root/assets/{theme-store-Docer0tD.js → theme-store-BTkYFJOE.js} +1 -1
  150. package/dist/gateway/static/root/assets/time-picker-C1PXAXZF.js +1 -0
  151. package/dist/gateway/static/root/assets/tool-friendly-title-YQmN1S2k.js +2 -0
  152. package/dist/gateway/static/root/assets/{tracing-settings-page-DiXHv8C3.js → tracing-settings-page-h-gbBAtl.js} +1 -1
  153. package/dist/gateway/static/root/assets/{tunnel-api-UYBm3Hqd.js → tunnel-api-BDoegsWD.js} +1 -1
  154. package/dist/gateway/static/root/assets/{understanding-activity-store-CK6cQ0iJ.js → understanding-activity-store-DyFJDqHy.js} +1 -1
  155. package/dist/gateway/static/root/assets/{understanding-refresh-store-DVNqbtHk.js → understanding-refresh-store-C0SRcgyd.js} +1 -1
  156. package/dist/gateway/static/root/assets/{usage-page-DmA7kQI2.js → usage-page-CbJsT3zT.js} +1 -1
  157. package/dist/gateway/static/root/assets/{use-autosave-D1tFBLQO.js → use-autosave-CB2B4NMO.js} +1 -1
  158. package/dist/gateway/static/root/assets/{use-composer-attachments-CwJslPRU.js → use-composer-attachments-DBsGBWDR.js} +1 -1
  159. package/dist/gateway/static/root/assets/{use-file-preview-expanded-CK1OJENF.js → use-file-preview-expanded-RpLp7VdL.js} +3 -3
  160. package/dist/gateway/static/root/assets/{use-personal-profile-CpsJdlEs.js → use-personal-profile-r0OuOlBJ.js} +1 -1
  161. package/dist/gateway/static/root/assets/{use-workspace-tree-CW9hcMwg.js → use-workspace-tree-BGco62Ny.js} +1 -1
  162. package/dist/gateway/static/root/assets/{user-model-page-BlYKXzCa.js → user-model-page-BudrJ73l.js} +1 -1
  163. package/dist/gateway/static/root/assets/{voice-api-key-field-DD9V94Y7.js → voice-api-key-field-C8wd8ijq.js} +1 -1
  164. package/dist/gateway/static/root/assets/{voice-config-api-Cr6IkfV2.js → voice-config-api-yBcUSvvn.js} +1 -1
  165. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-hsEdKDO6.js → voice-input-shortcut-events-TAmJNcsN.js} +1 -1
  166. package/dist/gateway/static/root/assets/{voice-transcribe-api-DKain9tL.js → voice-transcribe-api-By2znMrG.js} +1 -1
  167. package/dist/gateway/static/root/assets/{work-discovery-overlay-yYdAqtrO.js → work-discovery-overlay-DsyYo1p0.js} +1 -1
  168. package/dist/gateway/static/root/assets/{work-discovery-page-8hTykUqr.js → work-discovery-page-BJ9VN5Zd.js} +1 -1
  169. package/dist/gateway/static/root/assets/{working-directory-picker-modal-CXPSsy2J.js → working-directory-picker-modal-CFj-ZOJE.js} +1 -1
  170. package/dist/gateway/static/root/assets/{workspace-api-DNSoGsW8.js → workspace-api-CD2aXy2n.js} +2 -2
  171. package/dist/gateway/static/root/assets/workspace-editor-agent-store-2Lt7rQfw.js +1 -0
  172. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BVYsAXwp.js → workspace-file-preview-dialog-B23lE7H0.js} +1 -1
  173. package/dist/gateway/static/root/assets/{workspace-open-location-menu-DN7E_-eH.js → workspace-open-location-menu-CJUf755Q.js} +1 -1
  174. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CGs77iKb.js → xopc-cloud-account-card-DN4DdOWZ.js} +1 -1
  175. package/dist/gateway/static/root/index.html +88 -86
  176. package/dist/package.js +1 -1
  177. package/dist/packages/gateway-contract/src/home.js +21 -0
  178. package/dist/packages/gateway-contract/src/task-research-result.js +1 -0
  179. package/dist/packages/gateway-contract/src/tasks.js +10 -2
  180. package/dist/src/agent/agent-manager.d.ts +0 -1
  181. package/dist/src/agent/agent-manager.js +0 -3
  182. package/dist/src/agent/embedded/run-for-session.js +3 -6
  183. package/dist/src/agent/embedded/session-runner.js +1 -1
  184. package/dist/src/agent/mcp/native-mcp.d.ts +2 -0
  185. package/dist/src/agent/mcp/native-mcp.js +5 -0
  186. package/dist/src/agent/mcp/transport.d.ts +2 -1
  187. package/dist/src/agent/mcp/transport.js +21 -6
  188. package/dist/src/agent/orchestration/turn-recovery.js +7 -3
  189. package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.d.ts +1 -0
  190. package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js +56 -30
  191. package/dist/src/agent/skills/marketplace/search.js +2 -2
  192. package/dist/src/agent/tools/task-result-tool.js +6 -1
  193. package/dist/src/channels/pairing/paths.d.ts +1 -1
  194. package/dist/src/channels/pairing/paths.js +1 -1
  195. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  196. package/dist/src/config/paths.d.ts +1 -1
  197. package/dist/src/config/paths.js +1 -1
  198. package/dist/src/extensions/agent-plugins/refresh-runtime-access.d.ts +7 -2
  199. package/dist/src/extensions/agent-plugins/refresh-runtime-access.js +36 -25
  200. package/dist/src/extensions/agent-plugins/setup.d.ts +1 -1
  201. package/dist/src/extensions/agent-plugins/setup.js +2 -2
  202. package/dist/src/extensions/loader.d.ts +0 -1
  203. package/dist/src/extensions/loader.js +3 -38
  204. package/dist/src/extensions/typed-event-bus.d.ts +0 -1
  205. package/dist/src/extensions/typed-event-bus.js +0 -1
  206. package/dist/src/gateway/hono/routes/tasks.js +49 -22
  207. package/dist/src/personal-agent/reply-composer.js +6 -2
  208. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  209. package/dist/src/storage/sqlite/schema.js +7 -7
  210. package/dist/src/storage/sqlite/schema.sql +1 -1
  211. package/dist/src/storage/sqlite/upgrades/271_task_criterion_unverified.sql +21 -0
  212. package/dist/src/tasks/attention-governor.d.ts +2 -0
  213. package/dist/src/tasks/attention-governor.js +8 -3
  214. package/dist/src/tasks/home-query-service.d.ts +3 -0
  215. package/dist/src/tasks/home-query-service.js +187 -41
  216. package/dist/src/tasks/index.js +2 -2
  217. package/dist/src/tasks/task-application-service.js +2 -2
  218. package/dist/src/tasks/task-context-assembler.js +1 -1
  219. package/dist/src/tasks/task-contract-planner.js +6 -4
  220. package/dist/src/tasks/task-criterion-review-repository.d.ts +3 -12
  221. package/dist/src/tasks/task-criterion-review-repository.js +3 -2
  222. package/dist/src/tasks/task-final-reply.d.ts +2 -0
  223. package/dist/src/tasks/task-final-reply.js +11 -0
  224. package/dist/src/tasks/task-repository.d.ts +1 -0
  225. package/dist/src/tasks/task-repository.js +1 -0
  226. package/dist/src/tasks/task-research-repair.d.ts +1 -0
  227. package/dist/src/tasks/task-research-repair.js +4 -1
  228. package/dist/src/tasks/task-research-result.d.ts +1 -0
  229. package/dist/src/tasks/task-research-result.js +35 -1
  230. package/dist/src/tasks/task-result-delivery-repository.js +10 -5
  231. package/dist/src/tasks/task-result-delivery-service.js +2 -2
  232. package/dist/src/tasks/task-run-coordinator.js +7 -5
  233. package/dist/src/voice/tts/index.js +1 -1
  234. package/dist/src/voice/tts/speak-core.js +1 -1
  235. package/package.json +2 -3
  236. package/dist/extensions/feishu/src/auth/paths.d.ts +0 -2
  237. package/dist/extensions/feishu/src/auth/paths.js +0 -16
  238. package/dist/extensions/feishu/src/state/thread-bindings.d.ts +0 -19
  239. package/dist/extensions/feishu/src/state/thread-bindings.js +0 -44
  240. package/dist/extensions/feishu/src/subagent-hooks.d.ts +0 -12
  241. package/dist/extensions/feishu/src/subagent-hooks.js +0 -50
  242. package/dist/extensions/feishu/src/tools/docx/docx-batch-insert.d.ts +0 -11
  243. package/dist/extensions/feishu/src/tools/docx/docx-batch-insert.js +0 -93
  244. package/dist/extensions/feishu/src/tools/docx/docx-color-text.d.ts +0 -15
  245. package/dist/extensions/feishu/src/tools/docx/docx-color-text.js +0 -73
  246. package/dist/extensions/feishu/src/tools/docx/docx-table-ops.d.ts +0 -20
  247. package/dist/extensions/feishu/src/tools/docx/docx-table-ops.js +0 -171
  248. package/dist/extensions/feishu/src/tools/docx/docx-types.d.ts +0 -34
  249. package/dist/extensions/feishu/src/tools/docx/docx-types.js +0 -1
  250. package/dist/gateway/static/root/assets/automation-task-card-D4Ojt-Q4.js +0 -3
  251. package/dist/gateway/static/root/assets/automations-workspace-ND9J7xtt.js +0 -9
  252. package/dist/gateway/static/root/assets/capabilities-C_mZ4wUq.js +0 -1
  253. package/dist/gateway/static/root/assets/chat-page-U5hc4rIa.js +0 -72
  254. package/dist/gateway/static/root/assets/constants-CsVXarqA.js +0 -1
  255. package/dist/gateway/static/root/assets/date-picker-BCxU-AEv.js +0 -1
  256. package/dist/gateway/static/root/assets/gateway-realtime-store-BQELP9Or.js +0 -1
  257. package/dist/gateway/static/root/assets/home-page-UXS36f7M.js +0 -2
  258. package/dist/gateway/static/root/assets/index-D0p4v0SG.js +0 -11
  259. package/dist/gateway/static/root/assets/index-Uxz0OdzD.css +0 -1
  260. package/dist/gateway/static/root/assets/install-connector-dialog-DSIVSJRz.js +0 -1
  261. package/dist/gateway/static/root/assets/logs-page-CuxC8O1E.js +0 -2
  262. package/dist/gateway/static/root/assets/messages-DziUGfxF.js +0 -3
  263. package/dist/gateway/static/root/assets/note-image-lightbox-CaO_VuWl.js +0 -1
  264. package/dist/gateway/static/root/assets/page-header-store-Jt0XBQxm.js +0 -1
  265. package/dist/gateway/static/root/assets/product-preview-modal-BTlUoG48.js +0 -2
  266. package/dist/gateway/static/root/assets/project-detail-page-DNvQzRnU.js +0 -7
  267. package/dist/gateway/static/root/assets/route-preload-BTPpGwjV.js +0 -2
  268. package/dist/gateway/static/root/assets/settings-advanced-gate-Bq6eQ3It.js +0 -1
  269. package/dist/gateway/static/root/assets/skill-api-BrM5Ctxg.js +0 -1
  270. package/dist/gateway/static/root/assets/skills-page-DbAc1Y4C.js +0 -2
  271. package/dist/gateway/static/root/assets/task-detail-page-R0_AM-IE.js +0 -3
  272. package/dist/gateway/static/root/assets/task-result-evidence-C1AEUu9S.js +0 -1
  273. package/dist/gateway/static/root/assets/tool-friendly-title-DEGpbye4.js +0 -1
  274. package/dist/gateway/static/root/assets/workspace-editor-agent-store-ENv6zDBq.js +0 -1
@@ -1,7 +1,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-DI_JHx-P.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-DJYUYPdV.js","assets/messages-DziUGfxF.js","assets/unlink-BEuthaaq.js","assets/createLucideIcon-DPHK1VkS.js","assets/check-DUBLcKHA.js","assets/copy-Dv6d4Dvw.js","assets/external-link-DjqjBmc3.js","assets/notes-api-DoCb3QlH.js","assets/dist-BGTk37IG.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.js","assets/download-Dk-ZjtO6.js","assets/markdown-view-DrcA6Cfr.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/file-image-CDUPkZvG.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/app-link-CdD448kS.js","assets/product-delivery-DRyD9_Xq.js","assets/schemas-CCWMleym.js","assets/local-apps-Ck6kACsY.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/xml-_d7dTN2Q.js","assets/mermaid-render-oOellPHt.js","assets/markdown-view-DG8DDkEA.css","assets/chat-chart-block-B2U7epTQ.js","assets/skeleton-DzdOeGYz.js","assets/list-todo-CTVRto8O.js","assets/loader-circle-CifKLtgG.js","assets/mic-CuUb7zc-.js","assets/pause-DuPxgSxk.js","assets/pencil-DmIY3Oa-.js","assets/play-kxZvpBg8.js","assets/vendor-swr-CdRzEUwF.js","assets/floating-ui.dom-seOukHzT.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/with-selector-xonYxPoM.js","assets/note-image-lightbox-CaO_VuWl.js","assets/block-editor-Cvy3D_4T.css","assets/markdown-editor-CjQJ-Nho.js","assets/languages-kF11aUYU.js","assets/chat-page-U5hc4rIa.js","assets/app-window-DXFNqt_0.js","assets/archive-Dz0hferG.js","assets/arrow-left-D880xG-P.js","assets/voice-call-context-CJ1ZiJWR.js","assets/arrow-up-D5ZtR1QT.js","assets/product-automation-feedback-Bh37tBpR.js","assets/activity-YogQEteU.js","assets/bot-DjLkhyZL.js","assets/circle-check-C23XjkUj.js","assets/circle-pause-CN9jYH2s.js","assets/clock-3-DnrAnuyZ.js","assets/message-square-fVE7Ghj1.js","assets/rotate-ccw-JM1TBLpp.js","assets/rotate-cw-LIg3Am9S.js","assets/sparkles-DHlfQFAF.js","assets/triangle-alert-2JXFNNKU.js","assets/volume-2-BSJhAY97.js","assets/zap-dximCGjy.js","assets/button-Cc4hUNTt.js","assets/automation-api-DrxC4rCG.js","assets/earth-C9Z4bTTG.js","assets/chevron-down-ccbiQQz_.js","assets/chevron-right-BweFrslA.js","assets/working-directory-picker-modal-CXPSsy2J.js","assets/file-archive-DanfQJNe.js","assets/interaction-BdhHBbYa.js","assets/form-field-width-DJw_jULe.js","assets/settings-form-draft-Dy10ldo8.js","assets/popover-select-CLsphyzA.js","assets/dist-GJ8-1PAx.js","assets/dist-BuHnPloF.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/circle-alert-BEjgurr2.js","assets/new-chat-navigation-B6NPQ4h4.js","assets/circle-x-DFsCKeya.js","assets/circle-BoO4YvTx.js","assets/file-tree-utils-DJs1faGv.js","assets/database-CjjeZfRG.js","assets/ellipsis-0k4rZLoy.js","assets/file-BqMS_3DT.js","assets/file-text-D12HbeVy.js","assets/folder-kanban-CpLlFI1o.js","assets/folder-open-CyzJ19I9.js","assets/folder-CN-pC3XL.js","assets/use-file-preview-expanded-CK1OJENF.js","assets/eye-CABVeTq0.js","assets/link-2-D_ZKYUW7.js","assets/message-square-plus-XP0tGdlV.js","assets/minimize-2-DtOGrlpo.js","assets/paperclip-f1HujQY1.js","assets/refresh-cw-BRlGaq2w.js","assets/save-DRDABU--.js","assets/search-DA7gz22f.js","assets/constants-CsVXarqA.js","assets/session-api-QnBTnXGH.js","assets/gateway-startup-retry-BPSM56sw.js","assets/attachment-utils-core-BIOUBrpT.js","assets/activity-store-Ddf-02Rf.js","assets/app-chrome-BeB4KgOf.js","assets/electron-env-DHOGevH3.js","assets/use-async-resource-BHFGZCY2.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/index.module-Cd9ENXfk.js","assets/workspace-api-DNSoGsW8.js","assets/files-BNL4kkSB.js","assets/dist-ZrL34Ps4.js","assets/git-branch-Dh9uxTot.js","assets/globe-DSSGFWFn.js","assets/history-DXH_9jsE.js","assets/key-round-DWbpyU2U.js","assets/laptop-CI3hBVrl.js","assets/list-checks-BbsExAoq.js","assets/messages-square-BckAJrEW.js","assets/monitor-Af5eAvF7.js","assets/install-connector-dialog-DSIVSJRz.js","assets/secret-input-Dryrns2s.js","assets/is-masked-secret-DOkL5b_X.js","assets/connectors-api-Cgiy3Dyn.js","assets/gateway-config-swr-D0yocd87.js","assets/oauth-provider-connect-D1JQ4FBf.js","assets/cloud-C4-yfnnk.js","assets/models-hub-cache-CwxnL3rY.js","assets/registry-api-CkrGCW-C.js","assets/oauth-api-3b_QtYeo.js","assets/connection-usage-guide-BaDoesqn.js","assets/connection-usage-BhdQRWgQ.js","assets/settings-2-D-csvaET.js","assets/settings-uiTATseT.js","assets/shield-check-BU58siTV.js","assets/smartphone-DSSsQFqA.js","assets/square-DMK_fB-3.js","assets/trash-2-DusmjVPV.js","assets/share-link-dialog-C45dGG9y.js","assets/copy-text-row-CpiRzq4G.js","assets/wrench-DFb4r8bH.js","assets/tasks-D_xuHn6V.js","assets/specialists-xbB3xL9e.js","assets/api-Cc72Y3ct.js","assets/session-manager-b2zxVzZI.js","assets/local-session-drafts-cTAkoNSf.js","assets/tool-activity-BtJkgjFf.js","assets/personal-proactivity-DaRnbB1f.js","assets/gateway-realtime-DpNC3Y7U.js","assets/gateway-realtime-store-BQELP9Or.js","assets/agents-admin-api-BwoePPTG.js","assets/new-session-preferences-gb411vZP.js","assets/extension-provider-CFzHYMV0.js","assets/capabilities-C_mZ4wUq.js","assets/theme-store-Docer0tD.js","assets/middleware-Pd0e8Igk.js","assets/use-composer-attachments-CwJslPRU.js","assets/chevron-left-DqFhpbvK.js","assets/capabilities-CUHCbQ5N.js","assets/file-preview-surface-DgG6OJyj.js","assets/phone-workspace-store-2xQhZsJr.js","assets/shares-api-BsDhQwd3.js","assets/skill-wire-pattern-BPpeIcCi.js","assets/chat-agents-api-D6sJpLeT.js","assets/composer-payload-handoff-CaxZicbL.js","assets/voice-transcribe-api-DKain9tL.js","assets/open-capability-settings-Cvb65hQB.js","assets/workspace-editor-agent-store-ENv6zDBq.js","assets/voice-input-shortcut-events-hsEdKDO6.js","assets/chunk-D32TOXHM-DQIy-Baq.js","assets/tool-friendly-title-DEGpbye4.js","assets/page-header-store-Jt0XBQxm.js","assets/loopi-CNtmi9FU.js","assets/loopi-C09I2mNj.css","assets/agent-avatar-display-CarpM_qc.js","assets/use-directory-picker-C4p7AgWY.js","assets/confirm-dialog-D7dQJytv.js","assets/command-palette-api-DbL0oPXq.js","assets/skill-list-api-DWCkzC6W.js","assets/skill-api-utils-C7V4JVXM.js","assets/model-selector-CbKl8YPf.js","assets/model-sort-_Tz8s_4N.js","assets/automation-task-card-D4Ojt-Q4.js","assets/calendar-clock-D-quYVPe.js","assets/message-circle-Badhj-4D.js","assets/date-picker-BCxU-AEv.js","assets/calendar-days-hw_Y-g-s.js","assets/dev-view-store-rdp0Stsh.js","assets/extension-iframe-host-DzzKhhvD.js","assets/api-MJxs2HLk.js","assets/runtime-health-D2TDFLLq.js","assets/terminal-panel-store-qS6f2G-H.js","assets/agents-app-path-ciChvpCS.js","assets/agent-display-names-Bje7vfSn.js","assets/use-media-query-ady-FgjK.js","assets/oauth-authorization-window-o6URRos4.js","assets/page-context-draft-Ky5J09qv.js","assets/management-api-CmBUdfsn.js","assets/side-chat-shortcut-BIw-1TTD.js","assets/chat-page-zQeUaawJ.css"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{l as o,t as s,u as c}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as l,i as u,l as d,n as f,o as p,p as m}from"./locale-store-DJYUYPdV.js";import{t as h}from"./messages-DziUGfxF.js";import{a as g,c as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./dist-BGTk37IG.js";import{E as w,b as T,d as E,h as D,i as O,n as k,o as A,r as j,t as M,w as N,x as P}from"./discussion-annotation-sync-BG-sbtYu.js";import{t as F}from"./arrow-left-D880xG-P.js";import{a as I,c as L,d as R,i as z,l as B,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./product-automation-feedback-Bh37tBpR.js";import{t as oe}from"./check-DUBLcKHA.js";import{t as se}from"./chevron-down-ccbiQQz_.js";import{n as ce,r as V}from"./popover-select-CLsphyzA.js";import{t as le}from"./circle-check-C23XjkUj.js";import{t as ue}from"./code-xml-DJtYhZUF.js";import{t as de}from"./copy-Dv6d4Dvw.js";import{t as fe}from"./download-Dk-ZjtO6.js";import{t as pe}from"./ellipsis-0k4rZLoy.js";import{t as me}from"./external-link-DjqjBmc3.js";import{t as H}from"./eye-CABVeTq0.js";import{t as he}from"./file-text-D12HbeVy.js";import{t as U}from"./history-DXH_9jsE.js";import{C as ge,E as _e,F as ve,O as ye,P as be,S as xe,T as Se,_ as Ce,a as we,c as Te,d as Ee,f as De,h as Oe,l as W,m as ke,n as Ae,r as je,s as Me,u as Ne,w as Pe,x as Fe}from"./notes-api-DoCb3QlH.js";import{t as Ie}from"./loader-circle-CifKLtgG.js";import{P as Le}from"./markdown-view-DrcA6Cfr.js";import{t as Re}from"./message-circle-Badhj-4D.js";import{t as ze}from"./pencil-DmIY3Oa-.js";import{t as Be}from"./play-kxZvpBg8.js";import{t as Ve}from"./refresh-cw-BRlGaq2w.js";import{t as He}from"./search-DA7gz22f.js";import{t as Ue}from"./sliders-horizontal-DqsYor6I.js";import{t as We}from"./sparkles-DHlfQFAF.js";import{t as Ge}from"./square-pen-B8FsvqNu.js";import{t as G}from"./square-DMK_fB-3.js";import{t as Ke}from"./trash-2-DusmjVPV.js";import{t as qe}from"./x-B_N4OPjy.js";import{t as K}from"./cn-0WouolD0.js";import{t as q}from"./skeleton-DzdOeGYz.js";import{t as Je}from"./session-manager-b2zxVzZI.js";import{i as Ye}from"./vendor-swr-CdRzEUwF.js";import{t as J}from"./button-Cc4hUNTt.js";import{t as Xe}from"./copy-to-clipboard-HOJ79TWv.js";import{r as Y}from"./app-chrome-BeB4KgOf.js";import{i as Ze}from"./theme-store-Docer0tD.js";import{t as Qe}from"./page-header-store-Jt0XBQxm.js";import{t as X}from"./automation-api-DrxC4rCG.js";import{t as $e}from"./confirm-dialog-D7dQJytv.js";import{b as et,d as tt,o as nt,s as rt,v as it}from"./shares-api-BsDhQwd3.js";import{l as at,m as ot,o as st,r as ct,t as lt,u as ut}from"./dist-ZrL34Ps4.js";import{t as Z}from"./oauth-provider-connect-D1JQ4FBf.js";import{n as dt,t as ft}from"./page-context-draft-Ky5J09qv.js";import"./note-image-lightbox-CaO_VuWl.js";import{t as pt}from"./page-context-capture-button-CVIVl1MQ.js";var Q=e(t(),1),mt=r(),$=i(),ht=6e4,gt=36e5,_t=864e5;function vt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function yt(e,t,n){let r=t-e;if(r<ht)return n.justNow;if(r<gt){let e=Math.floor(r/ht);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=vt(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(e>=i-_t)return n.yesterday+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(r<7*_t){let e=Math.floor(r/_t);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(n.locale,{month:`short`,day:`numeric`})}function bt(e,t,n){let r=vt(t);if(e>=r)return n.today;if(e>=r-_t)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 xt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function St(e){let t=(0,mt.c)(45),{title:n,description:r,prompt:i,coverage:a,className:o,variant:s}=e,l=s===void 0?`card`:s,u=f(Tt),d=h(u).automations.suggestions,p=h(u).automations,m=c(),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=g):g=t[0];let{data:_}=Ye(a?`automation-suggestion-coverage`:null,wt,g),v=a?_?.automations.find(e=>z(e,a)):void 0,y=v?ee(v,p):[];if(l===`titleAction`){if(v){let e;t[1]===o?e=t[2]:(e=K(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,o),t[1]=o,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(le,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let r;return t[4]===m?r=t[5]:(r=()=>m(`/automations`),t[4]=m,t[5]=r),(0,$.jsxs)(`section`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:d.coveredTitle}),(0,$.jsx)(J,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:d.manage})]})}let e;t[6]===o?e=t[7]:(e=K(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,o),t[6]=o,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(N,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let s;t[9]!==r||t[10]!==n?(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:r,children:n}),t[9]=r,t[10]=n,t[11]=s):s=t[11];let c;t[12]!==m||t[13]!==i?(c=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});m(`/automations?${e.toString()}`)},t[12]=m,t[13]=i,t[14]=c):c=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,$.jsxs)(`section`,{className:e,children:[a,s,(0,$.jsxs)(J,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[l,d.setup]})]})}if(v){let e;t[16]===o?e=t[17]:(e=K(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,o),t[16]=o,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let r;t[19]===m?r=t[20]:(r=()=>m(`/automations`),t[19]=m,t[20]=r);let i;return t[21]!==d||t[22]!==r?(i=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsx)(J,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:r,children:d.manage})}),t[21]=d,t[22]=r,t[23]=i):i=t[23],(0,$.jsxs)(`section`,{className:e,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:d.coveredTitle}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:ne(d.coveredDescription,{name:v.name})})]})]}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:p.explain.whyCovered}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.map(Ct)})]}),i]})}let b;t[24]===o?b=t[25]:(b=K(`rounded-lg bg-surface-panel p-3 shadow-surface`,o),t[24]=o,t[25]=b);let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=x):x=t[26];let S;t[27]===n?S=t[28]:(S=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=S);let C;t[29]===r?C=t[30]:(C=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=C);let w;t[31]!==S||t[32]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[x,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]})]}),t[31]=S,t[32]=C,t[33]=w):w=t[33];let T;t[34]!==m||t[35]!==i?(T=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});m(`/automations?${e.toString()}`)},t[34]=m,t[35]=i,t[36]=T):T=t[36];let E;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0}),t[37]=E):E=t[37];let D;t[38]!==d.create||t[39]!==T?(D=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(J,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:T,children:[E,d.create]})}),t[38]=d.create,t[39]=T,t[40]=D):D=t[40];let O;return t[41]!==D||t[42]!==b||t[43]!==w?(O=(0,$.jsxs)(`section`,{className:b,children:[w,D]}),t[41]=D,t[42]=b,t[43]=w,t[44]=O):O=t[44],O}function Ct(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function wt(){return X.list()}function Tt(e){return e.language}var Et=`z-[140] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 text-sm text-fg shadow-popover`,Dt=`flex min-h-11 cursor-pointer items-center gap-2 rounded-md px-3 outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`;function Ot(e){let t=(0,mt.c)(54),{detail:n,zh:r,busy:i,processing:a,pageText:o,editing:s,noteActions:c}=e,l=`/api/discussions/${encodeURIComponent(n.discussion.id)}`,d=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,f;t[0]!==n.note.id||t[1]!==c||t[2]!==r?(f=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent aria-expanded:bg-accent-soft aria-expanded:text-accent-fg aria-expanded:hover:bg-accent-soft`,"aria-expanded":c.chatOpen??!1,"aria-controls":`note-assistant-${n.note.id}`,disabled:c.busy,onClick:c.onChat,children:[(0,$.jsx)(Re,{className:`size-4`,"aria-hidden":!0}),r?`AI 对话`:`AI chat`]}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r?`分享笔记`:`Share note`,disabled:c.busy,onClick:c.onShare,children:[(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:r?`分享`:`Share`})]})]}):null,t[0]=n.note.id,t[1]=c,t[2]=r,t[3]=f):f=t[3];let p=r?`导出笔记`:`Export note`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),t[4]=m):m=t[4];let h=r?`导出`:`Export`,g;t[5]===h?g=t[6]:(g=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h}),t[5]=h,t[6]=g);let _;t[7]!==p||t[8]!==g?(_=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":p,children:[m,g]})}),t[7]=p,t[8]=g,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=[`md`,`txt`,`srt`],t[10]=v):v=t[10];let y;t[11]!==l||t[12]!==r?(y=v.map(e=>(0,$.jsx)(ct,{asChild:!0,children:(0,$.jsx)(`a`,{className:Dt,href:u(`${l}/export?format=${e}`),download:!0,children:e===`srt`?r?`字幕 · SRT`:`Subtitles · SRT`:e===`md`?`Markdown · MD`:r?`纯文本 · TXT`:`Plain text · TXT`})},e)),t[11]=l,t[12]=r,t[13]=y):y=t[13];let b;t[14]!==d||t[15]!==l||t[16]!==r?(b=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsx)(ct,{asChild:!0,children:(0,$.jsxs)(`a`,{className:Dt,href:u(`${l}/audio`),download:!0,children:[(0,$.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),r?`下载录音`:`Download recording`]})})]}):null,t[14]=d,t[15]=l,t[16]=r,t[17]=b):b=t[17];let x;t[18]!==y||t[19]!==b?(x=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,collisionPadding:12,className:Et,children:[y,b]})}),t[18]=y,t[19]=b,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==_?(S=(0,$.jsxs)(at,{children:[_,x]}),t[21]=x,t[22]=_,t[23]=S):S=t[23];let C=r?`更多笔记操作`:`More note actions`,w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(pe,{className:`size-5`,"aria-hidden":!0}),t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":C,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:w})}),t[25]=C,t[26]=T);let E;t[27]!==c||t[28]!==r?(E=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ct,{className:Dt,disabled:c.busy,onSelect:c.onAnalyze,children:[(0,$.jsx)(We,{className:`size-4`,"aria-hidden":!0}),r?`进一步分析`:`Analyze this note`]}),(0,$.jsxs)(ct,{className:Dt,onSelect:c.onHistory,children:[(0,$.jsx)(U,{className:`size-4`,"aria-hidden":!0}),r?`版本历史`:`Version history`]})]}):null,t[27]=c,t[28]=r,t[29]=E):E=t[29];let D=n.note.id,O=String(n.note.remoteVersion??1),k;t[30]!==n.note.id||t[31]!==O?(k={kind:`note`,id:D,revision:O},t[30]=n.note.id,t[31]=O,t[32]=k):k=t[32];let A;t[33]===o?A=t[34]:(A={text:o,draft:!1},t[33]=o,t[34]=A);let j=r?`带到新对话`:`Use in a new chat`,M=i||a||s||!o||o.length>16e3,N;t[35]!==k||t[36]!==A||t[37]!==j||t[38]!==M?(N=(0,$.jsx)(`div`,{children:(0,$.jsx)(pt,{presentation:`menu`,resource:k,selection:A,label:j,disabled:M})}),t[35]=k,t[36]=A,t[37]=j,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==c||t[41]!==r?(P=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(ct,{className:`${Dt} text-danger`,disabled:c.busy,onSelect:c.onDelete,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),r?`删除笔记`:`Delete note`]})]}):null,t[40]=c,t[41]=r,t[42]=P):P=t[42];let F;t[43]!==E||t[44]!==N||t[45]!==P?(F=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,collisionPadding:12,className:Et,children:[E,N,P]})}),t[43]=E,t[44]=N,t[45]=P,t[46]=F):F=t[46];let I;t[47]!==T||t[48]!==F?(I=(0,$.jsxs)(at,{children:[T,F]}),t[47]=T,t[48]=F,t[49]=I):I=t[49];let L;return t[50]!==f||t[51]!==S||t[52]!==I?(L=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[f,S,I]}),t[50]=f,t[51]=S,t[52]=I,t[53]=L):L=t[53],L}function kt(e){let t=(0,mt.c)(68),{detail:n,template:r,onTemplate:i,zh:a,busy:o,processing:s,onOrganize:c,onRegenerate:l}=e,[u,d]=(0,Q.useState)(!1),f=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),t[0]=p):p=t[0];let m=a?`整理方式`:`Summary settings`,h;t[1]===m?h=t[2]:(h=(0,$.jsx)(_,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[p,m]})}),t[1]=m,t[2]=h);let w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(g,{className:`fixed inset-0 z-[150] bg-scrim`}),t[3]=w):w=t[3];let T=a?`整理方式`:`Summary settings`,E;t[4]===T?E=t[5]:(E=(0,$.jsx)(S,{className:`font-medium`,children:T}),t[4]=T,t[5]=E);let D=a?`关闭整理设置`:`Close summary settings`,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(qe,{className:`size-4`}),t[6]=O):O=t[6];let k;t[7]===D?k=t[8]:(k=(0,$.jsx)(y,{className:`inline-flex size-11 items-center justify-center rounded-lg hover:bg-surface-hover`,"aria-label":D,children:O}),t[7]=D,t[8]=k);let A;t[9]!==E||t[10]!==k?(A=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-5 py-3`,children:[E,k]}),t[9]=E,t[10]=k,t[11]=A):A=t[11];let j=a?`根据已有原文重新整理纪要。你已手动编辑的内容会保留。`:`Reorganize the existing transcript. Your manual edits are preserved.`,M;t[12]===j?M=t[13]:(M=(0,$.jsx)(v,{className:`text-sm leading-6 text-fg-muted`,children:j}),t[12]=j,t[13]=M);let N=a?`纪要模板`:`Summary template`,P;t[14]===N?P=t[15]:(P=(0,$.jsx)(`span`,{children:N}),t[14]=N,t[15]=P);let F=a?`纪要模板`:`Summary template`,I;t[16]===i?I=t[17]:(I=e=>i(e.target.value),t[16]=i,t[17]=I);let L=a?`通用会议`:`General`,R;t[18]===L?R=t[19]:(R=(0,$.jsx)(V,{value:`general`,children:L}),t[18]=L,t[19]=R);let z=a?`项目例会`:`Project`,B;t[20]===z?B=t[21]:(B=(0,$.jsx)(V,{value:`project`,children:z}),t[20]=z,t[21]=B);let ee=a?`需求评审`:`Review`,te;t[22]===ee?te=t[23]:(te=(0,$.jsx)(V,{value:`review`,children:ee}),t[22]=ee,t[23]=te);let ne=a?`客户访谈`:`Interview`,re;t[24]===ne?re=t[25]:(re=(0,$.jsx)(V,{value:`interview`,children:ne}),t[24]=ne,t[25]=re);let ie;t[26]!==F||t[27]!==I||t[28]!==R||t[29]!==B||t[30]!==te||t[31]!==re||t[32]!==r?(ie=(0,$.jsxs)(ce,{value:r,"aria-label":F,onChange:I,children:[R,B,te,re]}),t[26]=F,t[27]=I,t[28]=R,t[29]=B,t[30]=te,t[31]=re,t[32]=r,t[33]=ie):ie=t[33];let ae;t[34]!==P||t[35]!==ie?(ae=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[P,ie]}),t[34]=P,t[35]=ie,t[36]=ae):ae=t[36];let oe;t[37]!==f||t[38]!==o||t[39]!==n.discussion.status||t[40]!==l||t[41]!==s||t[42]!==a?(oe=f&&[`completed`,`needs_attention`].includes(n.discussion.status)?(0,$.jsxs)(`details`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer text-sm text-fg-muted`,children:a?`高级选项:重新识别录音`:`Advanced: transcribe again`}),(0,$.jsx)(`p`,{className:`mb-3 text-xs leading-5 text-fg-muted`,children:a?`重新处理原音,可能耗时较长。适用于原文缺失或识别不完整。`:`Process the original recording again when text is missing or incomplete. This may take longer.`}),(0,$.jsx)(J,{disabled:o||s,onClick:()=>{d(!1),l()},children:a?`从原音重新生成`:`Regenerate from audio`})]}):null,t[37]=f,t[38]=o,t[39]=n.discussion.status,t[40]=l,t[41]=s,t[42]=a,t[43]=oe):oe=t[43];let se;t[44]!==M||t[45]!==ae||t[46]!==oe?(se=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[M,ae,oe]}),t[44]=M,t[45]=ae,t[46]=oe,t[47]=se):se=t[47];let le=a?`取消`:`Cancel`,ue;t[48]===le?ue=t[49]:(ue=(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(J,{children:le})}),t[48]=le,t[49]=ue);let de=o||s||!n.discussion.canonicalTranscript,fe;t[50]===c?fe=t[51]:(fe=()=>{d(!1),c()},t[50]=c,t[51]=fe);let pe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":!0}),t[52]=pe):pe=t[52];let me=a?`重新整理纪要`:`Regenerate summary`,H;t[53]!==de||t[54]!==fe||t[55]!==me?(H=(0,$.jsxs)(J,{variant:`primary`,disabled:de,onClick:fe,children:[pe,me]}),t[53]=de,t[54]=fe,t[55]=me,t[56]=H):H=t[56];let he;t[57]!==ue||t[58]!==H?(he=(0,$.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle p-4`,children:[ue,H]}),t[57]=ue,t[58]=H,t[59]=he):he=t[59];let U;t[60]!==A||t[61]!==se||t[62]!==he?(U=(0,$.jsxs)(b,{children:[w,(0,$.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[151] flex h-[min(28rem,90dvh)] w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg`,children:[A,se,he]})]}),t[60]=A,t[61]=se,t[62]=he,t[63]=U):U=t[63];let ge;return t[64]!==u||t[65]!==h||t[66]!==U?(ge=(0,$.jsxs)(C,{open:u,onOpenChange:d,children:[h,U]}),t[64]=u,t[65]=h,t[66]=U,t[67]=ge):ge=t[67],ge}function At(e){return JSON.stringify([e.transcript.revision,e.transcript.segments.map(e=>[e.sequence,e.revision,e.status]),e.organization?.revision])}function jt(e,t){let n=(0,mt.c)(21),[r,i]=(0,Q.useState)(),a;n[0]!==t||n[1]!==e||n[2]!==r?.noteId?(a=()=>{t&&r?.noteId!==e&&i({noteId:e,version:At(t),value:t})},n[0]=t,n[1]=e,n[2]=r?.noteId,n[3]=a):a=n[3];let o=r?.noteId,s;n[4]!==t||n[5]!==e||n[6]!==o?(s=[e,t,o],n[4]=t,n[5]=e,n[6]=o,n[7]=s):s=n[7],(0,Q.useEffect)(a,s);let c;n[8]!==t||n[9]!==e?(c=n=>{let r=n===void 0?t:n;r&&i({noteId:e,version:At(r),value:r})},n[8]=t,n[9]=e,n[10]=c):c=n[10];let l=c,u=r?.noteId===e?r:void 0,d;n[11]!==u||n[12]!==t?(d=!!t&&!!u&&u.version!==At(t),n[11]=u,n[12]=t,n[13]=d):d=n[13];let f=d,p;n[14]!==u||n[15]!==t?(p=t&&u?{...t,transcript:u.value.transcript,organization:u.value.organization}:t,n[14]=u,n[15]=t,n[16]=p):p=n[16];let m=p,h;return n[17]!==m||n[18]!==f||n[19]!==l?(h={detail:m,hasUpdates:f,publish:l},n[17]=m,n[18]=f,n[19]=l,n[20]=h):h=n[20],h}var Mt=e=>`${Math.floor(e/6e4)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function Nt({id:e,query:t,zh:n,refreshKey:r,sourceKey:i,active:a,tab:o,onEvidence:s,onPlay:c}){let[l,d]=(0,Q.useState)(),[f,m]=(0,Q.useState)(),h=(0,Q.useRef)(null),g=(0,Q.useRef)(!1),[_,v]=(0,Q.useState)(!0),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(0),[w,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(0),M=JSON.stringify([e,i,t]),N=t?``:r;(0,Q.useEffect)(()=>{if(!a||t)return;let e=window.setInterval(()=>j(e=>e+1),3e3);return()=>window.clearInterval(e)},[a,t]),(0,Q.useEffect)(()=>{D(void 0)},[e,t]),(0,Q.useEffect)(()=>{let n=++C.current,r=new AbortController;v(!0),S(!1),b(``);let i=g.current;g.current=!1;let a=window.setTimeout(()=>{p(u(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}`),{signal:r.signal}).then(e=>{if(C.current!==n)return;let r=h.current;if(!i&&r?.key===M){r.value.version!==e.version&&m(e);return}h.current={key:M,value:e},d(e),m(void 0),T(M),k(t)}).catch(e=>{C.current===n&&!r.signal.aborted&&b(String(e))}).finally(()=>{C.current===n&&v(!1)})},t?200:0);return()=>{C.current++,r.abort(),window.clearTimeout(a)}},[e,t,N,i,M,A]);function P(){g.current=!0,j(e=>e+1)}async function F(){if(!l||x)return;let r=C.current;S(!0);try{let n=await p(u(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}&offset=${l.hits.length}&version=${l.version}`));if(r===C.current){let e={...n,hits:[...l.hits,...n.hits]};h.current={key:M,value:e},d(e)}}catch(e){r===C.current&&b(n?`内容已变化,请重新搜索。${String(e)}`:`Content changed; search again. ${String(e)}`)}finally{r===C.current&&S(!1)}}function I(e){D(e),(!e.provisional||e.kind===`chapter`)&&e.transcriptRevision!==void 0&&e.segments.length&&s({transcriptRevision:e.transcriptRevision,stale:e.stale,audioAvailable:l?.coverage.audioAvailable??!1,timingVerified:e.segments.some(e=>e.playback.length>0),segments:e.segments})}let L=e=>e.kind===`chapter`?n?`章节`:`Chapter`:e.kind===`annotation`?n?`我的标记`:`My mark`:e.kind===`analysis`?n?`分析`:`Analysis`:n?`原文`:`Transcript`,R=e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-xl bg-surface-inset p-4`,children:[(0,$.jsxs)(`button`,{className:`text-left text-sm text-accent-fg`,onClick:()=>I(e),children:[e.startedAtMs===void 0?``:`${Mt(e.startedAtMs)}${e.endedAtMs===void 0?``:`–${Mt(e.endedAtMs)}`} · `,e.title||L(e)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm`,children:e.kind===`chapter`&&!t&&e.text.length>300?`${e.text.slice(0,300)}…`:e.text}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[L(e),e.provisional?n?` · 阶段性结果`:` · Partial result`:``,e.stale?n?` · 原文已更新,保留旧版依据`:` · Earlier transcript revision`:``,e.kind===`chapter`?` · ${e.highlightCount??0} ${n?`个重点`:`marks`} · ${e.actionCount??0} ${n?`个候选行动`:`candidate actions`}`:``]}),e.kind!==`chapter`||t||E?.id===e.id?e.segments.map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Mt(e.startedAtMs),` · `,e.text.length>500?`${e.text.slice(0,500)}…`:e.text]},`${e.sequence}:${e.startedAtMs}`)):null,e.playback.slice(0,3).map((e,t)=>(0,$.jsxs)(J,{onClick:()=>c(e.startedAtMs,e.endedAtMs),children:[n?`回听上下文`:`Play context`,` `,Mt(e.startedAtMs),`–`,Mt(e.endedAtMs)]},t)),e.segments.length?(0,$.jsx)(J,{onClick:()=>I(e),children:n?`查看对应原文`:`View transcript`}):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`暂无可核实的原文定位`:`No verified transcript reference`})]},e.id);return(0,$.jsxs)(`section`,{"aria-label":n?`长录音回顾`:`Recording review`,className:`flex flex-col gap-3`,children:[y?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:y}),(0,$.jsx)(J,{onClick:P,children:n?`刷新结果`:`Refresh results`})]}):null,_&&(!l||w!==M||O!==t)?(0,$.jsx)(q,{className:`h-20 w-full`}):null,l&&w===M&&(!t||O===t)?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-10 h-0`,children:f?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-edge-subtle bg-surface-overlay px-3 py-2 text-xs text-fg-muted shadow-popover`,children:[(0,$.jsx)(`span`,{role:`status`,children:n?`内容已更新,当前阅读位置已保留`:`Updates available. Your reading position is preserved.`}),(0,$.jsx)(J,{variant:`ghost`,onClick:()=>{h.current={key:M,value:f},d(f),m(void 0)},children:n?`查看最新`:`View latest`})]}):null}),t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`搜索结果 · ${l.total}`:`Search results · ${l.total}`}),(0,$.jsx)(J,{onClick:P,children:n?`刷新结果`:`Refresh results`}),(0,$.jsx)(`div`,{"aria-label":n?`命中位置`:`Match positions`,className:`relative my-3 h-5 rounded bg-surface-inset`,children:l.hits.filter(e=>e.startedAtMs!==void 0).map(e=>(0,$.jsx)(`button`,{className:`absolute top-0 h-5 w-1.5 rounded bg-accent`,style:{left:`${Math.min(99,100*e.startedAtMs/Math.max(1,l.coverage.durationMs))}%`},"aria-label":`${Mt(e.startedAtMs)} ${e.title||L(e)}`,onClick:()=>I(e)},e.id))}),l.total?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`未找到关键词;尚未转写的内容无法搜索。`:`No matches. Untranscribed audio is not searchable yet.`}),l.hits.map(R)]}):(0,$.jsxs)($.Fragment,{children:[o===`summary`&&l.chapters.length?(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-inset px-4`,children:[(0,$.jsxs)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-sm font-medium focus-visible:ring-2 focus-visible:ring-accent`,children:[n?`章节目录`:`Chapters`,` · `,l.chapters.length]}),(0,$.jsx)(`div`,{className:`space-y-3 pb-4`,children:l.chapters.map(R)})]}):null,l.hits.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`本轮已完成转写(阶段性)`:`Available transcription from this run`}),l.hits.map(R)]}):null]}),l.hasMore?(0,$.jsx)(J,{disabled:x,onClick:()=>void F(),children:n?`加载更多结果`:`More results`}):null,(0,$.jsxs)(`details`,{className:`rounded-lg text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 focus-visible:ring-2 focus-visible:ring-accent`,children:n?`处理范围`:`Processing coverage`}),(0,$.jsxs)(`div`,{role:`status`,className:`space-y-2 pb-3 leading-5`,children:[(0,$.jsxs)(`p`,{children:[n?`原音`:`Audio`,` · `,l.coverage.audioAvailable?n?`已保存,可回听`:`Saved, ready to play`:n?`尚不可用`:`Unavailable`]}),(0,$.jsxs)(`p`,{children:[n?`本轮转写已处理`:`Processed this run`,` `,Mt(l.coverage.processedMs),` / `,Mt(l.coverage.durationMs),` · `,n?`连续处理至`:`Continuous through`,` `,Mt(l.coverage.continuousThroughMs)]}),(0,$.jsxs)(`p`,{children:[n?`分析覆盖`:`Analysis coverage`,` · `,l.coverage.analysisRanges.length?l.coverage.analysisRanges.map(e=>`${Mt(e.startedAtMs)}–${Mt(e.endedAtMs)}`).join(`、`):n?`暂无本版已完成章节`:`No completed chapters for this revision`,l.coverage.analysisStale?n?`;已发布分析基于旧版原文`:`; published analysis uses an earlier transcript`:``,` · `,l.coverage.complete?n?`本轮处理完成`:`Run complete`:n?`阶段性内容,其余仍待处理`:`Partial content; remaining work pending`]})]})]}),E?.provisional?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`以上是本轮已保存的阶段性原文;正式发布后才能校对和标记具体段落。`:`Saved partial text; segment editing and highlighting become available after publication.`}):null]}):null]})}function Pt({recordingId:e,discussionId:t,zh:n,onEvidence:r,onPlay:i}){let{data:a=[],mutate:o}=Ye(`/api/discussions/${t}/annotations`,e=>p(u(e))),[s,c]=(0,Q.useState)([]),[l,d]=(0,Q.useState)(null),[f,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),_=(0,Q.useCallback)(async()=>{c(await j(e))},[e]),v=(0,Q.useCallback)(async()=>{try{await M(e,t),await _(),await o()}catch(e){await o(),g(e instanceof Error?e.message:String(e))}},[e,t,_,o]);(0,Q.useEffect)(()=>{_().catch(e=>g(String(e))),v();let e=()=>{_().catch(e=>g(String(e)))};window.addEventListener(`discussion-annotations-changed`,e),window.addEventListener(`online`,v);let t=window.setInterval(()=>{navigator.onLine&&v()},15e3);return()=>{window.removeEventListener(`discussion-annotations-changed`,e),window.removeEventListener(`online`,v),window.clearInterval(t)}},[_,v]);let y=new Map(a.map(e=>[e.annotation.id,{...e,localState:`synced`}]));for(let e of s)if(e.state!==`synced`||!y.has(e.annotation.id)){let t=y.get(e.annotation.id);y.set(e.annotation.id,{annotation:e.annotation,state:t?.state??`pending`,playback:t?.playback??[],evidence:t?.evidence,localState:e.state})}let b=async(t,n=s.find(e=>e.annotation.id===t.id)?.nonce??null)=>{try{await A(e,{...t,updatedAt:Date.now()},n),m(null),g(``),await _(),v()}catch(e){g(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n?`我的标记`:`My highlights`,children:[h?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[h,(0,$.jsx)(J,{onClick:()=>void v(),children:n?`重试同步`:`Retry sync`})]}):null,y.size?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`录音时标重点,或在原文中标记整段。标记先保存在本机。`:`Highlight while recording or mark a transcript segment. Highlights save locally first.`}),[...y.values()].sort((e,t)=>e.annotation.anchor.capturedAt-t.annotation.anchor.capturedAt).filter(e=>!e.annotation.deleted||e.localState===`conflict`).map(e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.annotation.kind===`highlight`?n?`重点`:`Highlight`:e.annotation.kind===`question`?n?`问题`:`Question`:n?`我的补充`:`My note`,` · `,new Date(e.annotation.anchor.capturedAt).toLocaleString(),` · `,e.localState===`synced`?n?`已同步`:`Synced`:e.localState===`conflict`?n?`同步冲突,保留了本机修改`:`Conflict; local edits retained`:n?`本机已保存,待同步`:`Saved locally; sync pending`]}),e.evidence?.segments.map(e=>(0,$.jsx)(`blockquote`,{className:`text-sm`,children:e.text},e.sequence)),e.positionMs===void 0?null:(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n?`标记位置`:`Marked position`,` · `,Math.floor(e.positionMs/6e4),`:`,String(Math.floor(e.positionMs/1e3)%60).padStart(2,`0`)]}),e.annotation.text?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm`,children:[n?`我的说明:`:`My context: `,e.annotation.text]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(J,{disabled:!e.evidence,onClick:()=>e.evidence&&r(e.evidence),children:n?`查看原文`:`View transcript`}),e.playback.map((e,t)=>(0,$.jsxs)(J,{onClick:()=>i(e),children:[n?`回听`:`Play`,` `,Math.floor(e.startedAtMs/6e4),`:`,String(Math.floor(e.startedAtMs/1e3)%60).padStart(2,`0`)]},t)),(0,$.jsx)(J,{onClick:()=>{d(s.find(t=>t.annotation.id===e.annotation.id)?.nonce??null),m({...e.annotation,revision:a.find(t=>t.annotation.id===e.annotation.id)?.annotation.revision??e.annotation.revision})},children:e.localState===`conflict`?n?`合并修改`:`Merge changes`:n?`添加说明/类型`:`Edit context/type`}),(0,$.jsx)(J,{onClick:()=>void b({...e.annotation,deleted:!0}),children:n?`移除标记`:`Remove`})]}),e.state===`located`&&!e.evidence?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原文尚未生成,可先回听原音。`:`Transcript for this position is pending; audio is usable.`}):null,e.state===`unavailable`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原音未保存、已删除或时间尚无法核实;保留原始标记,不自动移动。`:`Audio at this position is missing, deleted or unverified. The original anchor has been retained.`}):e.state===`pending`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`等待原音/原文完成定位`:`Awaiting audio/transcript positioning`}):null,e.localState===`conflict`?(0,$.jsx)(J,{onClick:()=>{let t=s.find(t=>t.annotation.id===e.annotation.id),n=a.find(t=>t.annotation.id===e.annotation.id);t&&n&&k(t,n.annotation).then(_)},children:n?`使用服务端版本`:`Use server version`}):null]},e.annotation.id)),f?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":n?`编辑标记`:`Edit highlight`,className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(ce,{value:f.kind,"aria-label":n?`标记类型`:`Highlight type`,onChange:e=>m({...f,kind:e.target.value}),children:[(0,$.jsx)(V,{value:`highlight`,children:n?`重点`:`Highlight`}),(0,$.jsx)(V,{value:`question`,children:n?`问题`:`Question`}),(0,$.jsx)(V,{value:`note`,children:n?`补充`:`Context`})]}),(0,$.jsx)(`textarea`,{"aria-label":n?`我的说明`:`My context`,maxLength:4e3,value:f.text,onChange:e=>m({...f,text:e.target.value}),className:`my-2 min-h-24 w-full rounded border border-edge bg-surface-inset p-2`}),(0,$.jsx)(J,{onClick:()=>void b(f,l),children:n?`保存到本机并同步`:`Save locally and sync`}),(0,$.jsx)(J,{onClick:()=>m(null),children:n?`取消`:`Cancel`})]}):null]})}var Ft={tab:`summary`,query:``,page:1,positionMs:0},It=m((e,t)=>({notes:{},update:(n,r)=>{let i={...Rt(n,t().notes[n]),...r};e(e=>({notes:{...e.notes,[n]:i}}));try{localStorage.setItem(`discussion-review:${n}`,JSON.stringify(i))}catch{}}})),Lt=new Map;function Rt(e,t){if(t)return t;if(Lt.has(e))return Lt.get(e);let n=Ft;try{let t=JSON.parse(localStorage.getItem(`discussion-review:${e}`)??`null`);t&&[`summary`,`transcript`,`marks`].includes(t.tab)&&typeof t.query==`string`&&Number.isSafeInteger(t.page)&&t.page>0&&t.page<=1e4&&Number.isFinite(t.positionMs)&&t.positionMs>=0&&(n={...Ft,...t})}catch{}return Lt.set(e,n),n}function zt(e){let t=(0,mt.c)(51),{initial:n,zh:r,busy:i,onClose:a,onSave:o}=e,[s,c]=(0,Q.useState)(n),l;t[0]!==i||t[1]!==a?(l=e=>{!e&&!i&&a()},t[0]=i,t[1]=a,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[3]=u):u=t[3];let d=r?`编辑纪要内容`:`Edit meeting content`,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`header`,{className:`border-b border-edge p-4`,children:(0,$.jsx)(S,{children:d})}),t[4]=d,t[5]=f);let p=r?`人工修改会保留,重新整理不会覆盖。已创建任务保持不变。`:`Your changes survive regeneration. Existing tasks remain unchanged.`,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[6]=p,t[7]=m);let h=r?`内容`:`Content`,_;t[8]===s?_=t[9]:(_=e=>c({...s,text:e.target.value}),t[8]=s,t[9]=_);let v;t[10]!==s.text||t[11]!==_?(v=(0,$.jsx)(`textarea`,{className:`mt-1 min-h-32 w-full rounded border border-edge bg-transparent p-2`,value:s.text,onChange:_}),t[10]=s.text,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==h||t[14]!==v?(y=(0,$.jsxs)(`label`,{className:`block text-sm`,children:[h,v]}),t[13]=h,t[14]=v,t[15]=y):y=t[15];let w;t[16]!==s||t[17]!==r?(w=s.kind===`actionItems`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`负责人原话`:`Owner as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.owner??``,onChange:e=>c({...s,owner:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`期限原话`:`Date as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.dueDate??``,onChange:e=>c({...s,dueDate:e.target.value})})]})]}):null,t[16]=s,t[17]=r,t[18]=w):w=t[18];let T;t[19]!==s||t[20]!==r?(T=s.kind===`summary`?null:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!s.ignored,onChange:e=>c({...s,ignored:e.target.checked})}),r?`忽略此项`:`Ignore this item`]}),t[19]=s,t[20]=r,t[21]=T):T=t[21];let E;t[22]!==y||t[23]!==w||t[24]!==T||t[25]!==m?(E=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[m,y,w,T]}),t[22]=y,t[23]=w,t[24]=T,t[25]=m,t[26]=E):E=t[26];let D=r?`取消`:`Cancel`,O;t[27]!==i||t[28]!==a||t[29]!==D?(O=(0,$.jsx)(J,{disabled:i,onClick:a,children:D}),t[27]=i,t[28]=a,t[29]=D,t[30]=O):O=t[30];let k;t[31]!==i||t[32]!==s.text?(k=i||!s.text.trim(),t[31]=i,t[32]=s.text,t[33]=k):k=t[33];let A;t[34]!==s||t[35]!==o?(A=()=>void o(s),t[34]=s,t[35]=o,t[36]=A):A=t[36];let j=r?`保存修改`:`Save changes`,M;t[37]!==k||t[38]!==A||t[39]!==j?(M=(0,$.jsx)(J,{variant:`primary`,disabled:k,onClick:A,children:j}),t[37]=k,t[38]=A,t[39]=j,t[40]=M):M=t[40];let N;t[41]!==O||t[42]!==M?(N=(0,$.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge p-3`,children:[O,M]}),t[41]=O,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==E||t[45]!==N||t[46]!==f?(P=(0,$.jsxs)(b,{children:[u,(0,$.jsxs)(x,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(32rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[f,E,N]})]}),t[44]=E,t[45]=N,t[46]=f,t[47]=P):P=t[47];let F;return t[48]!==l||t[49]!==P?(F=(0,$.jsx)(C,{open:!0,onOpenChange:l,children:P}),t[48]=l,t[49]=P,t[50]=F):F=t[50],F}function Bt(e,t,n){if(t===`summary`){let r=e.organization;if(!r)return``;let i=r.organization;if(!i)return``;let a=e=>e.filter(e=>n.showIgnored||!e.ignored);return JSON.stringify({discussionId:e.discussion.id,view:t,revision:r.revision,transcriptRevision:r.transcriptRevision,summary:i.summary,decisions:a(i.decisions),actionItems:a(i.actionItems),risks:a(i.risks),openQuestions:a(i.openQuestions),chapters:i.chapters},null,2)}let r=n.query.toLocaleLowerCase(),i=e.transcript.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(r)||e.speakerLabel?.toLocaleLowerCase().includes(r)).slice(0,n.page*50);return i.length?JSON.stringify({discussionId:e.discussion.id,view:t,revision:e.transcript.revision,scope:`loaded filtered segments only`,segments:i.map(e=>({sequence:e.sequence,startedAtMs:e.startedAtMs,speaker:e.speakerLabel,text:e.displayText??e.rawText??``}))},null,2):``}var Vt=e=>`${String(Math.floor(e/6e4)).padStart(2,`0`)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function Ht({noteId:e,onPersonalNotes:t,onMeetingContent:n,personalNotes:r,personalNotesActive:i=!1,noteActions:a}){let c=o(),l=f(e=>e.language)===`zh`,{data:d,mutate:m,isLoading:h}=Ye([`note-discussion-document`,e],()=>E(e),{refreshInterval:e=>e&&([`recording`,`stopping`,`sealing`,`organizing`].includes(e.discussion.status)||e.recordingJob?.state===`queued`||e.recordingJob?.state===`running`)?3e3:0}),{detail:_,hasUpdates:v,publish:y}=jt(e,d),w=_?.discussion.id,k=`/api/discussions/${encodeURIComponent(w??``)}`,{data:j=[],mutate:N}=Ye(w?`${k}/actions`:null,e=>p(u(e)),{refreshInterval:1e4}),F=It(t=>Rt(e,t.notes[e])),I=It(e=>e.update),L=F.tab,R=t=>I(e,{tab:t}),z=F.query,B=t=>I(e,{query:t}),[ee,te]=(0,Q.useState)(!1),ne=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{ee&&ne.current?.focus()},[ee]);let[re,ie]=(0,Q.useState)(`general`),ae=(0,Q.useRef)(null),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),[V,le]=(0,Q.useState)(!1),[ue,de]=(0,Q.useState)(!1),fe=(0,Q.useRef)(!1),pe=(0,Q.useRef)(null),me=(0,Q.useRef)(null),[H,he]=(0,Q.useState)(null),[U,ge]=(0,Q.useState)(null),[_e,ve]=(0,Q.useState)(null),[ye,be]=(0,Q.useState)(!1),[xe,Se]=(0,Q.useState)([]),[Ce,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)(!1),De=F.page,Oe=t=>I(e,{page:t}),W=(0,Q.useRef)(null),[ke,Ae]=(0,Q.useState)([]),je=(0,Q.useRef)(0),Me=(0,Q.useRef)(0),Ne=(0,Q.useRef)(d?.transcript.revision);Ne.current=d?.transcript.revision;let Pe=(0,Q.useRef)(null),Fe=(0,Q.useRef)(d?.discussion.audioDeletedAt);Fe.current=d?.discussion.audioDeletedAt;let Ie=(0,Q.useRef)(null),[,Re]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let t=()=>{m(),N()},n=n=>{n.detail?.noteId===e&&t()};return window.addEventListener(`note-updated`,n),window.addEventListener(`discussion-updated`,t),window.addEventListener(`discussion-segment-updated`,t),()=>{window.removeEventListener(`note-updated`,n),window.removeEventListener(`discussion-updated`,t),window.removeEventListener(`discussion-segment-updated`,t)}},[m,N,e]),(0,Q.useEffect)(()=>{_?.discussion.template&&ie(_.discussion.template)},[_?.discussion.template]);async function ze(e){if(!Te){Ee(!0),we(null);try{await e();let t=await m();y(t),await N()}catch(e){we(e instanceof Error?e.message:String(e))}finally{Ee(!1)}}}function Ve(e,t){Pe.current&&(W.current=t??null,Pe.current.readyState===0?(Ie.current=e/1e3,Pe.current.load()):(Pe.current.currentTime=e/1e3,Pe.current.play().catch(()=>void 0)))}function Ue(){if(ce.current)return;let e=me.current??(document.activeElement instanceof HTMLElement?document.activeElement:null);ce.current={element:e,triggerIndex:Array.from(ae.current?.querySelectorAll(`button`)??[]).findIndex(t=>t===e),scrollTop:ae.current?.scrollTop??0,review:F}}function We(){Me.current++,le(!1),he(null),pe.current=ce.current?.element??null,ue||(ce.current=null)}function G(){let t=ce.current;if(!t)return;let{tab:n,query:r,page:i,anchor:a,anchorRevision:o}=t.review;I(e,{tab:n,query:r,page:i,anchor:a,anchorRevision:o}),Ae([]),he(null),de(!1),fe.current=!0}(0,Q.useLayoutEffect)(()=>{if(!H&&!V&&pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null),!fe.current)return;fe.current=!1;let e=ce.current;e&&ae.current&&(ae.current.scrollTop=e.scrollTop),(e?.element?.isConnected?e.element:e&&e.triggerIndex>=0?ae.current?.querySelectorAll(`button`)[e.triggerIndex]:null)?.focus({preventScroll:!0}),ce.current=null}),(0,Q.useEffect)(()=>{(H||V)&&se.current?.focus({preventScroll:!0})},[H,V]);function Ke(e){Ue();let t=e.stale||e.transcriptRevision!==Ne.current,n=Fe.current?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:e;he({...n,stale:t}),t||Ae(e.segments.map(e=>e.sequence))}async function K(e,t,n=!1){if(!_)return;let r=je.current,i=++Me.current;Ue(),le(!0),he(null),we(null);try{let a=await p(u(`${k}/evidence?revision=${t??_.organization?.transcriptRevision??_.transcript.revision}&segments=${e.join(`,`)}`));if(r!==je.current||i!==Me.current)return;if(Ke(a),n&&!Fe.current&&a.segments[0]?.playback[0]){let e=a.segments[0].playback[0];Ve(e.startedAtMs,e.endedAtMs)}}catch(e){r===je.current&&i===Me.current&&(we(e instanceof Error?e.message:String(e)),We())}finally{i===Me.current&&le(!1)}}async function Je(e){_&&await ze(async()=>{await A(_.discussion.clientRequestId,O({type:`transcript`,capturedAt:Date.now(),transcriptRevision:_.transcript.revision,segmentIds:[e.sequence]})),R(`marks`),M(_.discussion.clientRequestId,_.discussion.id).catch(e=>we(String(e)))})}(0,Q.useEffect)(()=>(je.current++,Me.current++,ce.current=null,de(!1),le(!1),he(null),Ae([]),ge(null),ve(null),Se([]),we(null),W.current=null,()=>{je.current++}),[e]),(0,Q.useEffect)(()=>{let t=_?.discussion.audioSha256??_?.discussion.audioAttachmentId;if(!t)return;let n=Rt(e,It.getState().notes[e]);n.source&&n.source!==t?(je.current++,Me.current++,le(!1),he(null),Ae([]),Pe.current?.pause(),I(e,{positionMs:0,source:t}),Ie.current=0,W.current=null):I(e,{source:t})},[e,_?.discussion.audioSha256,_?.discussion.audioAttachmentId,I]),(0,Q.useEffect)(()=>{_?.discussion.audioDeletedAt&&(Pe.current?.pause(),Ie.current=null,W.current=null,he(e=>e?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:null))},[_?.discussion.audioDeletedAt]),(0,Q.useEffect)(()=>{F.tab===`transcript`&&F.anchor!==void 0&&F.anchorRevision===_?.transcript.revision&&window.setTimeout(()=>document.getElementById(`discussion-segment-${F.anchor}`)?.scrollIntoView?.({block:`center`}),0)},[F.tab,F.anchor,F.anchorRevision,_?.transcript.revision]),(0,Q.useEffect)(()=>{Ae([]),he(e=>e&&e.transcriptRevision!==d?.transcript.revision?{...e,stale:!0}:e)},[d?.transcript.revision]);let Xe=(e,t,n)=>t.some(e=>ye||!e.ignored)?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-fg`,children:e}),t.filter(e=>ye||!e.ignored).map(e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`flex-1 whitespace-pre-wrap`,children:[e.text,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?`有后续变更`:`Later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:Te||v,onClick:()=>ve({kind:n,itemId:e.id,text:e.text,ignored:e.ignored}),children:l?`编辑`:`Edit`}),e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:Te,className:`shrink-0 text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`原话`:`Source`}):(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?`暂无定位`:`No source timing`})]},e.id))]}):null;if(h)return(0,$.jsx)(q,{className:`h-48 w-full`});if(!_)return null;let{discussion:Y,transcript:Ze,organization:Qe}=_,X=Qe?.organization,$e=[`stopping`,`sealing`,`organizing`].includes(Y.status),et=!v&&[`recording`,`completed`,`needs_attention`].includes(Y.status),tt=Ze.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(z.toLocaleLowerCase())||e.speakerLabel?.toLocaleLowerCase().includes(z.toLocaleLowerCase())),nt=i?_.note.markdown:L===`marks`||z.trim()?``:Bt(_,L,{query:z,page:De,showIgnored:ye});return(0,$.jsxs)(`section`,{className:`@container/discussion relative flex h-full min-h-0 min-w-0 w-full flex-col text-fg`,onClickCapture:e=>{me.current=e.target instanceof Element?e.target.closest(`button`):null},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),te(!0))},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-start gap-x-3 gap-y-1 px-5 pb-2 pt-5 sm:px-7`,children:[(0,$.jsxs)(`div`,{className:`min-w-40 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-2xl font-semibold leading-snug tracking-tight`,children:!_.note.title||/^Discussion · \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(_.note.title)?l?`语音笔记`:`Voice note`:_.note.title}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[l?`录音`:`Recording`,` · `,Vt(Y.durationMs??0)]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":l?`搜索此 Note`:`Search this Note`,"aria-expanded":ee||!!z,onClick:()=>{te(e=>!e),ee&&B(``)},className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(He,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(Ot,{noteActions:a,detail:_,zh:l,busy:Te,processing:$e,pageText:nt,editing:!!_e||!!U})]}),(0,$.jsx)(`nav`,{"aria-label":l?`笔记内容`:`Note content`,className:`mx-5 mb-2 flex shrink-0 gap-6 border-b border-edge-subtle sm:mx-7`,children:[`summary`,`transcript`,`personal`].map(e=>{let r=e===`personal`?i:!i&&(e===`transcript`?L===`transcript`||L===`marks`:L===e);return(0,$.jsx)(`button`,{type:`button`,"aria-pressed":r,className:`min-h-11 border-b-2 px-1 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${r?`border-accent font-medium text-fg`:`border-transparent text-fg-muted hover:text-fg`}`,onClick:()=>{e===`personal`?(We(),t?.()):(n?.(),R(e))},children:e===`summary`?l?`纪要`:`Summary`:e===`personal`?l?`我的笔记`:`My notes`:l?`原文`:`Transcript`},e)})}),Ce?(0,$.jsxs)(`details`,{role:`alert`,className:`px-4 py-2 text-sm text-danger`,children:[(0,$.jsx)(`summary`,{children:l?`操作未完成,可以稍后重试`:`Action incomplete. Try again later`}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs text-fg-muted`,children:Ce})]}):null,!i&&(ee||z)?(0,$.jsxs)(`label`,{className:`mx-5 mb-2 flex shrink-0 items-center gap-2 rounded-xl bg-surface-inset px-3 sm:mx-7`,children:[(0,$.jsx)(He,{className:`size-4 text-fg-muted`}),(0,$.jsx)(`input`,{ref:ne,"aria-label":l?`搜索此 Note`:`Search this Note`,className:`min-h-11 min-w-0 w-full bg-transparent text-sm outline-none`,maxLength:200,placeholder:l?`搜索这篇笔记`:`Search this note`,value:z,onChange:e=>{B(e.target.value),Oe(1)}}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`关闭搜索`:`Close search`,onClick:()=>{B(``),te(!1)},children:(0,$.jsx)(qe,{className:`size-4`})})]}):null,ue?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-5 pb-2 text-xs text-fg-muted sm:px-7`,children:[(0,$.jsx)(`span`,{children:ce.current?.review.tab===`summary`?l?`正在查看结论依据`:`Viewing supporting transcript`:l?`正在查看原文依据`:`Viewing source transcript`}),(0,$.jsx)(J,{variant:`ghost`,onClick:G,children:ce.current?.review.tab===`summary`?l?`返回结论`:`Back to conclusion`:l?`返回阅读位置`:`Back to reading`})]}):null,(0,$.jsx)(`div`,{className:`relative z-10 h-0 shrink-0`,children:v?(0,$.jsx)(J,{className:`absolute right-5 top-2 border-edge bg-surface-overlay text-xs shadow-popover`,onClick:()=>y(),children:l?`内容已更新 · 查看最新`:`Updates available · View latest`}):null}),(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,$.jsxs)(`main`,{ref:ae,className:`min-h-0 min-w-0 flex-1 flex-col gap-5 overflow-y-auto px-5 pb-6 pt-1 sm:px-7 ${i||H||V?`hidden`:`flex`} ${!i&&(H||V)?`@min-[58rem]/discussion:flex`:``}`,children:[L===`summary`?(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[46rem] items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?`会议纪要`:`Meeting summary`}),(0,$.jsx)(kt,{detail:_,template:re,onTemplate:ie,zh:l,busy:Te,processing:$e,onOrganize:()=>void ze(()=>p(u(`${k}/organize`),{method:`POST`,body:JSON.stringify({template:re})})),onRegenerate:()=>void ze(()=>D(Y.id,`from_audio`))})]}):(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[46rem] gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,"aria-pressed":L===`transcript`,onClick:()=>R(`transcript`),children:l?`全部原文`:`All transcript`}),(0,$.jsx)(J,{variant:`ghost`,"aria-pressed":L===`marks`,onClick:()=>R(`marks`),children:l?`我的标记`:`My highlights`})]}),(Y.status!==`completed`||!X||Qe?.transcriptRevision!==Ze.revision)&&(Y.status!==`recording`||_.recordingJob)?(0,$.jsx)(T,{context:`note`,nextAttemptAt:_.processing?.nextAttemptAt,input:P(_),zh:l,busy:Te,onRetry:e=>void ze(()=>e===`analyze`?p(u(`${k}/organize`),{method:`POST`,body:JSON.stringify({template:re})}):D(Y.id,e===`regenerate`?`from_audio`:`resume`))}):null,(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem]`,hidden:!!z.trim(),children:L===`marks`?(0,$.jsx)(Pt,{recordingId:Y.clientRequestId,discussionId:Y.id,zh:l,onEvidence:Ke,onPlay:e=>Ve(e.startedAtMs,e.endedAtMs)},Y.id):L===`summary`?X?(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[46rem] space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:l?`摘要`:`Summary`}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`编辑概要`:`Edit overview`,title:l?`编辑概要`:`Edit overview`,disabled:Te||$e||v,onClick:()=>ve({kind:`summary`,itemId:`summary`,text:X.summary}),children:(0,$.jsx)(Ge,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7`,children:X.summary}),X.summaryEditedByUser?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`已由你编辑`:`Edited by you`}):null,X.summaryEvidenceSegmentIds?.length?Array.from({length:Math.ceil(X.summaryEvidenceSegmentIds.length/100)},(e,t)=>(0,$.jsxs)(J,{onClick:()=>void K(X.summaryEvidenceSegmentIds.slice(t*100,(t+1)*100)),children:[l?`查看原话`:`View source`,X.summaryEvidenceSegmentIds.length>100?` · ${t+1}`:``]},t)):null,X.keyPointEvidence?.length?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{children:l?`重点结论`:`Key points`}),X.keyPointEvidence.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1`,children:e.text}),(0,$.jsx)(J,{onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`原话`:`Source`})]},e.id))]}):X.keyPoints.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:l?`重点结论`:`Key points`}),(0,$.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-[15px] leading-7`,children:X.keyPoints.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}:${e}`))})]}):null,[...X.decisions,...X.actionItems,...X.risks,...X.openQuestions].some(e=>e.ignored)?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ye,onChange:e=>be(e.target.checked)}),l?`显示已忽略项`:`Show ignored items`]}):null,xe.length?(0,$.jsx)(J,{disabled:Te||v,onClick:()=>void ze(async()=>{for(let e of xe)await p(u(`${k}/actions/${encodeURIComponent(e)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Qe.revision})});Se([])}),children:l?`加入所选 ${xe.length} 项任务`:`Add ${xe.length} selected tasks`}):null,Xe(l?`已决定事项`:`Decisions`,X.decisions,`decisions`),X.actionItems.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:l?`下一步行动`:`Next actions`}),X.actionItems.filter(e=>ye||!e.ignored).map(e=>{let t=j.find(t=>t.actionId===e.id);return(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge-subtle p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!t&&!e.ignored&&(!(e.supersededBy||e.disputedBy)||e.reviewedChangeId===(e.supersededBy??e.disputedBy))?(0,$.jsx)(`input`,{type:`checkbox`,"aria-label":`${l?`选择行动`:`Select action`}: ${e.title}`,className:`ui-checkbox`,checked:xe.includes(e.id),onChange:t=>Se(t.target.checked?[...xe,e.id]:xe.filter(t=>t!==e.id))}):null,(0,$.jsxs)(`p`,{className:`flex-1 text-sm font-medium`,children:[e.title,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?`有后续变更,请复核`:`Review later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:Te||$e||v,onClick:()=>ve({kind:`actionItems`,itemId:e.id,text:e.title,owner:e.owner,dueDate:e.dueDate,ignored:e.ignored}),children:l?`编辑`:`Edit`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e.owner??(l?`负责人未明确`:`Owner unspecified`),` · `,e.dueDate??(l?`期限未明确`:`Date unspecified`)]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-xs`,children:[e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:Te,className:`text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`查看原话`:`Source`}):null,t?t.deleted?(0,$.jsx)(`span`,{children:l?`关联任务已删除`:`Linked task deleted`}):(0,$.jsx)(s,{className:`text-accent-fg`,to:Le(`${c.pathname}${c.search}`,t.taskId),children:t.resolution===`done`?l?`已完成 · 查看任务`:`Done · View task`:l?`查看任务 / 交给助手`:`View task / Delegate`}):e.ignored?null:(0,$.jsx)(J,{disabled:Te||v||!!(e.supersededBy||e.disputedBy)&&e.reviewedChangeId!==(e.supersededBy??e.disputedBy),onClick:()=>void ze(()=>p(u(`${k}/actions/${encodeURIComponent(e.id)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Qe.revision})})),children:l?`加入我的任务`:`Add to my tasks`})]})]},e.id)})]}):null,Xe(l?`风险`:`Risks`,X.risks,`risks`),Xe(l?`尚未确定`:`Open questions`,X.openQuestions,`openQuestions`),X.changes?.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:l?`前后变更`:`Changes during the meeting`}),X.changes.map(e=>{let t=[...X.decisions,...X.actionItems,...X.risks,...X.openQuestions],n=t.find(t=>t.id===e.fromId),r=t.find(t=>t.id===e.toId);return!n||!r?null:(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.relation===`supersedes`?l?`后续撤销或替代`:`Later superseded`:l?`存在冲突,尚未明确解决`:`Unresolved conflict`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(n.evidenceSegmentIds,n.evidenceRevision),children:`title`in n?n.title:n.text}),(0,$.jsx)(`span`,{children:`↓`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(r.evidenceSegmentIds,r.evidenceRevision),children:`title`in r?r.title:r.text})]},`${e.fromId}:${e.toId}`)})]}):null]}):(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[46rem] space-y-4 py-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:Ze.text?l?`录音摘录`:`From your recording`:Y.status===`needs_attention`?l?`纪要暂未生成`:`Summary unavailable`:l?`笔记正在整理`:`Preparing your note`}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7 ${Ze.text?`text-fg`:`text-fg-muted`}`,children:Ze.text?Ze.text.slice(0,400)+(Ze.text.length>400?`…`:``):l?`文字整理完成后,重点和行动会出现在这里。`:`Highlights and actions will appear as processing completes.`}),Ze.text?(0,$.jsx)(J,{className:`min-h-11`,onClick:()=>R(`transcript`),children:l?`查看原文`:`Read transcript`}):null]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[tt.slice(0,De*50).map(e=>(0,$.jsxs)(`article`,{id:`discussion-segment-${e.sequence}`,className:`rounded-md border p-3 ${ke.includes(e.sequence)||F.anchor===e.sequence&&F.anchorRevision===Ze.revision?`border-accent`:`border-edge-subtle`}`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 text-xs text-fg-muted`,children:[(0,$.jsxs)(`button`,{className:`inline-flex items-center gap-1 text-accent-fg`,disabled:!Y.audioAttachmentId||!!Y.audioDeletedAt,onClick:()=>void K([e.sequence],Ze.revision,!0),children:[(0,$.jsx)(Be,{className:`size-3`}),Vt(e.startedAtMs)]}),e.status===`confirmed`&&!v?(0,$.jsx)(`button`,{onClick:()=>void Je(e),children:l?`标记此段`:`Highlight segment`}):null,(0,$.jsx)(`span`,{children:e.speakerLabel??(l?`未区分说话人`:`Speaker unknown`)}),et&&e.status===`confirmed`?(0,$.jsx)(`button`,{className:`ml-auto`,onClick:()=>ge({segment:e,text:e.displayText??e.rawText??``,speaker:e.speakerLabel??``}),children:l?`校对`:`Edit`}):null]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6`,children:e.displayText??e.rawText??(l?`等待转写`:`Awaiting transcription`)})]},e.sequence)),tt.length>De*50?(0,$.jsx)(J,{onClick:()=>Oe(De+1),children:l?`加载更多`:`More`}):null]})}),(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem]`,children:(0,$.jsx)(Nt,{id:Y.id,query:z.trim(),zh:l,sourceKey:`${Y.audioSha256}:${Y.audioDeletedAt}`,active:$e||Y.status===`recording`,tab:L,refreshKey:`${Y.updatedAt}:${Ze.revision}:${Qe?.revision}`,onEvidence:Ke,onPlay:Ve},Y.id)})]}),(0,$.jsx)(`div`,{className:i?`min-h-0 min-w-0 flex-1 overflow-hidden`:`hidden`,children:r}),H||V?(0,$.jsxs)(`aside`,{ref:se,tabIndex:-1,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),We())},"aria-label":l?`原话证据`:`Source evidence`,className:`flex min-h-0 w-full min-w-0 flex-col border-edge bg-surface-panel outline-none @min-[58rem]/discussion:w-[22rem] @min-[58rem]/discussion:shrink-0 @min-[58rem]/discussion:border-l`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,$.jsxs)(`h3`,{children:[l?`原话证据`:`Source evidence`,` `,H?`· v${H.transcriptRevision}`:``]}),(0,$.jsx)(`button`,{"aria-label":l?`关闭`:`Close`,className:`inline-flex size-11 items-center justify-center rounded-lg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:We,children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[V?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3`,children:[(0,$.jsx)(q,{className:`h-4 w-1/3`}),(0,$.jsx)(q,{className:`h-24 w-full`})]}):null,H?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`按整段定位,不代表词句级时间。`:`Segment timing; not word-level alignment.`}),H.stale?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`原文已更新,以下保留当时版本的依据。`:`Transcript updated; showing the original evidence revision.`}):null,!H.audioAvailable||!H.timingVerified?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`原文仍可查看;原音不可用或时间定位待核实。`:`Text remains available; audio is missing or timing is unverified.`}):null,H.segments.map(t=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Vt(t.startedAtMs),`–`,Vt(t.endedAtMs),` · `,t.speakerLabel??(l?`说话人未明确`:`Unknown speaker`)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-7`,children:t.text}),t.playback.map((e,t)=>(0,$.jsxs)(J,{onClick:()=>Ve(e.startedAtMs,e.endedAtMs),children:[l?`播放原话`:`Play source`,` `,Vt(e.startedAtMs),`–`,Vt(e.endedAtMs)]},t)),!H.stale&&H.transcriptRevision===d?.transcript.revision&&H.transcriptRevision!==Ze.revision?(0,$.jsx)(J,{onClick:()=>y(),children:l?`查看最新原文`:`View latest transcript`}):null,!H.stale&&H.transcriptRevision===d?.transcript.revision&&H.transcriptRevision===Ze.revision?(0,$.jsx)(J,{onClick:()=>{B(``),Oe(Math.max(De,Math.ceil((Ze.segments.findIndex(e=>e.sequence===t.sequence)+1)/50))),R(`transcript`),Ae([t.sequence]),he(null),de(!0),I(e,{anchor:t.sequence,anchorRevision:Ze.revision}),window.setTimeout(()=>document.getElementById(`discussion-segment-${t.sequence}`)?.scrollIntoView?.({block:`center`}),0)},children:l?`定位原文`:`Locate transcript`}):null]},t.sequence))]}):null]})]}):null]}),Y.audioAttachmentId&&!Y.audioDeletedAt?(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(`audio`,{ref:Pe,controls:!0,preload:`metadata`,className:`h-10 w-full`,src:u(`${k}/audio`),onTimeUpdate:()=>{let t=(Pe.current?.currentTime??0)*1e3;Re(t),I(e,{positionMs:t}),W.current!==null&&t>=W.current&&(Pe.current?.pause(),W.current=null)},onLoadedMetadata:()=>{Ie.current!==null&&Pe.current?(Pe.current.currentTime=Ie.current,Ie.current=null,Pe.current.play().catch(()=>void 0)):Pe.current&&(Pe.current.currentTime=F.positionMs/1e3)},onError:()=>we(l?`录音暂不可播放`:`Recording unavailable`)})}):null,_e&&Qe?(0,$.jsx)(zt,{initial:_e,zh:l,busy:Te,onClose:()=>ve(null),onSave:e=>ze(async()=>{await p(u(`${k}/summary`),{method:`PATCH`,body:JSON.stringify({...e,expectedRevision:Qe.revision})}),ve(null)})},`${_e.kind}:${_e.itemId}:${Qe.revision}`):null,U?(0,$.jsx)(C,{open:!0,onOpenChange:e=>{e||ge(null)},children:(0,$.jsxs)(b,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(x,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(28rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge p-4`,children:[(0,$.jsx)(S,{children:l?`校对逐字稿`:`Edit transcript`}),(0,$.jsx)(`button`,{"aria-label":l?`关闭校对`:`Close editor`,onClick:()=>ge(null),children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[(0,$.jsxs)(`label`,{className:`block text-xs`,children:[l?`本段说话人`:`Speaker for this segment`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:U.speaker,onChange:e=>ge({...U,speaker:e.target.value})})]}),U.segment.speakerLabel?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!U.applyToSpeakerGroup,onChange:e=>ge({...U,applyToSpeakerGroup:e.target.checked})}),l?`同时更名所有同标签片段;输入已有标签可合并说话人`:`Rename all segments with this label; use an existing label to merge speakers`]}):null,(0,$.jsx)(`textarea`,{className:`min-h-32 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:U.text,onChange:e=>ge({...U,text:e.target.value})})]}),(0,$.jsx)(`footer`,{className:`border-t border-edge p-3`,children:(0,$.jsxs)(J,{variant:`primary`,disabled:Te||!U.text.trim(),onClick:()=>void ze(async()=>{await p(u(`${k}/segments/${U.segment.sequence}`),{method:`PATCH`,body:JSON.stringify({displayText:U.text,speakerLabel:U.speaker,expectedRevision:U.segment.revision,applyToSpeakerGroup:U.applyToSpeakerGroup,expectedTranscriptRevision:Ze.revision})}),ge(null)}),children:[(0,$.jsx)(oe,{className:`size-4`}),l?`保存修订`:`Save revision`]})})]})]})}):null]})}var Ut={edit:ze,ai_edit:We,sync:Ve,restore:w};function Wt(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=f(e=>e.language),o=h(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:l(a)},{data:c}=Ye(e?[`note-history`,e]:null,()=>De(e)),[u,d]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=(0,Q.useCallback)(async t=>{d(!0),_(null);try{await Se(e,t),m(null),i()}catch{_(o.restoreFailed)}finally{d(!1)}},[e,o.restoreSuccess,o.restoreFailed,i]),y=Date.now();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(U,{className:`size-4`,"aria-hidden":!0}),o.history]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(qe,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[g?(0,$.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:g}):null,c?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>{let r=Ut[e.trigger]??ze,i=t===e.timestamp,a=p===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:K(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:Wt(e.trigger,o)}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:yt(e.timestamp,y,s)})]}),e.snippet&&(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:o.restoreConfirm}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),v(e.timestamp)},disabled:u,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:u?`...`:o.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),m(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:o.restore})})]},e.timestamp)})}):(0,$.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:o.historyEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:o.historyEmptyDescription})]})]})]})}function Kt({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:a,openingChat:o,onOpenChat:s,onOpenNewChat:l}){let u=h(f(e=>e.language)).notes,d=c(),p=t?.aiDeep?.catalysis,m=p?.report??null,[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),{data:b,mutate:x,isLoading:S}=Ye(e?[`note-agent-context-status`,e]:null,()=>W(e),{revalidateOnFocus:!1}),C=(0,Q.useCallback)(async()=>{if(!v){y(!0),_(null);try{await x(()=>Fe(e),{revalidate:!1})}catch(e){_(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{y(!1)}}},[v,x,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),w=(0,Q.useCallback)(async t=>{try{await xe(e,t)}catch{}},[e]);return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(We,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":u.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(F,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),b?(0,$.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:S||v,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:v?u.processing:u.contextRebuild}),(0,$.jsx)(`span`,{className:K(`rounded-full px-2 py-0.5 text-[11px] font-medium`,b.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:b.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:b.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:u.contextStatusDetail.replace(`{{attachments}}`,String(b.attachments.length)).replace(`{{tokens}}`,String(b.tokenEstimate??0))}),g?(0,$.jsx)(`p`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:g}):null,b.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:b.attachments.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:m?u.recatalyze:u.catalyzeAction}),m?(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:m.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:m.targetUsers.slice(0,5).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.keyQuestions.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.mvpPath.slice(0,3).map((e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.risks.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.nextActions.slice(0,4).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,$.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(m.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`helpful`),className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,$.jsx)(B,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`not_helpful`),className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,$.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:u.noCatalysisReportHint}),(0,$.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Re,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:s,disabled:o,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:o?u.openingChat:u.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:o,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),a.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:a.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:u.noThreads})]})]})]})}var qt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function Jt({open:e,onOpenChange:t,note:n}){let r=f(e=>e.language)===`zh`,i=r?Qt:$t,{data:a,mutate:o}=Ye(e?[`note-shares`,n.id]:null,()=>ke(n.id)),s=Ye(e?`hosted-share-auth-status`:null,tt),c=s.data===!0,l=Ye(e&&c?`hosted-publication-capabilities`:null,rt),u=l.data?.publishing.allowed===!0,d=Ye(e&&c?[`hosted-note-publications`,n.id]:null,()=>Ee(n.id)),[p,m]=(0,Q.useState)(new Set),[h,_]=(0,Q.useState)(`86400000`),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)(`hosted`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),ee=(0,Q.useMemo)(()=>{let e=new Set;return n.markdown.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^\s)]+)/gi,(t,r,i)=>{try{decodeURIComponent(r)===n.id&&e.add(decodeURIComponent(i))}catch{}return t}),(n.attachments??[]).filter(t=>e.has(t.id))},[n.attachments,n.id,n.markdown]);(0,Q.useEffect)(()=>{e&&(m(new Set(ee.map(e=>e.id))),F(null),L(!1),B(null))},[e,ee]);let te=async()=>{j(!0),B(null);try{let e={expectedNoteVersion:n.updatedAt,attachmentIds:[...p],ttlMs:Number(h),maxViews:w.trim()?Number(w):null,description:E.trim()||void 0};if(O===`hosted`){let t=await je(n.id,e);F(t.shareUrl),await d.mutate()}else{let t=await we(n.id,e);F(t.payload.shareUrl),await o()}}catch(e){B(e instanceof Error?e.message:String(e))}finally{j(!1)}},ne=async(e,t)=>{N(e.id),B(null);try{t===`refresh`?await ge(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):await it(e.id),await d.mutate()}catch(e){B(e instanceof Error?e.message:String(e))}finally{N(null)}},re=async(e,t)=>{N(e.id),B(null);try{t===`refresh`?await Pe(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):t===`extend`?await nt(e.id,864e5):await et(e.id),await o()}catch(e){B(e instanceof Error?e.message:String(e))}finally{N(null)}},ie=async e=>{B(null);try{if(!await Xe(e)){L(!1),B(i.copyFailed);return}L(!0),window.setTimeout(()=>L(!1),1500)}catch{L(!1),B(i.copyFailed)}};return(0,$.jsx)(C,{open:e,onOpenChange:t,children:(0,$.jsxs)(b,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(x,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(S,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,$.jsx)(R,{className:`size-4`}),i.title]}),(0,$.jsx)(v,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,$.jsx)(qe,{className:`size-4`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-inset p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),ee.length>0?(0,$.jsxs)(`section`,{className:`mt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:ee.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:p.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,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Zt(e.size)})]},e.id))})]}):null,(0,$.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.delivery,(0,$.jsxs)(ce,{value:O,onChange:e=>k(e.target.value),children:[(0,$.jsx)(V,{value:`hosted`,children:i.deliveryHosted}),(0,$.jsx)(V,{value:`local`,children:i.deliveryLocal})]})]}),O===`hosted`&&s.data===!1?(0,$.jsx)(`div`,{className:`sm:col-span-2`,children:(0,$.jsx)(Z,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:()=>void s.mutate(!0,{revalidate:!1})})}):null,O===`hosted`&&c&&l.data&&!u?(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning sm:col-span-2`,children:i.hostedDisabled}):null,(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,$.jsx)(ce,{value:h,onChange:e=>_(e.target.value),children:qt.map(e=>(0,$.jsx)(V,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,$.jsx)(`input`,{type:`number`,min:1,max:1e3,value:w,onChange:e=>T(e.target.value),placeholder:i.unlimited,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,$.jsx)(`input`,{value:E,onChange:e=>D(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`})]})]}),P?(0,$.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{readOnly:!0,value:P,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,$.jsxs)(J,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void ie(P),children:[I?(0,$.jsx)(oe,{className:`size-4`}):(0,$.jsx)(de,{className:`size-4`}),I?i.copied:i.copy]}),(0,$.jsxs)(J,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(P,`_blank`,`noopener,noreferrer`),children:[(0,$.jsx)(me,{className:`size-4`}),i.open]})]})}):null,z?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:z}):null,(a?.items.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,$.jsx)(Xt,{share:e,busy:M===e.id,t:i,onCopy:ie,onAction:re},e.id))})]}):null,(d.data?.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.hostedLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:d.data.map(e=>(0,$.jsx)(Yt,{publication:e,stale:e.source?.version!==String(n.updatedAt),busy:M===e.id,publishingAllowed:u,t:i,onCopy:ie,onAction:ne},e.id))})]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,children:i.close})}),(0,$.jsxs)(J,{type:`button`,onClick:()=>void te(),disabled:A||O===`hosted`&&(!c||!u),children:[A?(0,$.jsx)(Ie,{className:`size-4 animate-spin`}):(0,$.jsx)(R,{className:`size-4`}),A?i.creating:i.create]})]})]})]})})}function Yt(e){let t=(0,mt.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=K(`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,$.jsx)(`span`,{children:f}),t[2]=f,t[3]=p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.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,$.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 _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{children:`·`}),t[9]=_):_=t[9];let v;t[10]!==n.revision||t[11]!==o.revision?(v=(0,$.jsxs)(`span`,{children:[o.revision,` `,n.revision]}),t[10]=n.revision,t[11]=o.revision,t[12]=v):v=t[12];let y;t[13]!==p||t[14]!==g||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,g,_,v]}),t[13]=p,t[14]=g,t[15]=v,t[16]=y):y=t[16];let b;t[17]===n.shareUrl?b=t[18]:(b=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[17]=n.shareUrl,t[18]=b);let x;t[19]!==y||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===i?S=t[23]:(S=i?(0,$.jsx)(Ie,{className:`size-4 animate-spin text-fg-muted`}):null,t[22]=i,t[23]=S);let C;t[24]!==x||t[25]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[x,S]}),t[24]=x,t[25]=S,t[26]=C):C=t[26];let w=!a,T;t[27]!==s||t[28]!==n.shareUrl?(T=()=>void s(n.shareUrl),t[27]=s,t[28]=n.shareUrl,t[29]=T):T=t[29];let E;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(de,{className:`size-3.5`}),t[30]=E):E=t[30];let D;t[31]!==o.copy||t[32]!==w||t[33]!==T?(D=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:w,onClick:T,children:[E,o.copy]}),t[31]=o.copy,t[32]=w,t[33]=T,t[34]=D):D=t[34];let O=!a,k;t[35]===n.shareUrl?k=t[36]:(k=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=k);let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(me,{className:`size-3.5`}),t[37]=A):A=t[37];let j;t[38]!==o.open||t[39]!==O||t[40]!==k?(j=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:O,onClick:k,children:[A,o.open]}),t[38]=o.open,t[39]=O,t[40]=k,t[41]=j):j=t[41];let M;t[42]!==i||t[43]!==l||t[44]!==c||t[45]!==n||t[46]!==a||t[47]!==r||t[48]!==o.refresh?(M=r&&!l?(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i||!a,onClick:()=>void c(n,`refresh`),children:[(0,$.jsx)(Ve,{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]=M):M=t[49];let N;t[50]!==i||t[51]!==c||t[52]!==n||t[53]!==o.revoke?(N=n.revoked?null:(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i,onClick:()=>void c(n,`revoke`),children:[(0,$.jsx)(Ke,{className:`size-3.5`}),o.revoke]}),t[50]=i,t[51]=c,t[52]=n,t[53]=o.revoke,t[54]=N):N=t[54];let P;t[55]!==D||t[56]!==j||t[57]!==M||t[58]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[D,j,M,N]}),t[55]=D,t[56]=j,t[57]=M,t[58]=N,t[59]=P):P=t[59];let F;return t[60]!==C||t[61]!==d||t[62]!==P?(F=(0,$.jsxs)(`div`,{className:d,children:[C,P]}),t[60]=C,t[61]=d,t[62]=P,t[63]=F):F=t[63],F}function Xt(e){let t=(0,mt.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=K(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let u=n.stale&&!s?i.stale:s?i.inactive:i.active,d;t[2]===u?d=t[3]:(d=(0,$.jsx)(`span`,{children:u}),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{children:`·`}),t[4]=f):f=t[4];let p=n.maxViews===null?``:` / ${n.maxViews}`,m;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==p?(m=(0,$.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,$.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 _;t[12]===g?_=t[13]:(_=(0,$.jsx)(`span`,{children:g}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==d||t[16]!==m?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[d,f,m,h,_]}),t[14]=_,t[15]=d,t[16]=m,t[17]=v):v=t[17];let y;t[18]===n.shareUrl?y=t[19]:(y=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=y);let b;t[20]!==v||t[21]!==y?(b=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,y]}),t[20]=v,t[21]=y,t[22]=b):b=t[22];let x;t[23]===r?x=t[24]:(x=r?(0,$.jsx)(Ie,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=x);let S;t[25]!==b||t[26]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,x]}),t[25]=b,t[26]=x,t[27]=S):S=t[27];let C;t[28]!==a||t[29]!==n.shareUrl?(C=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=C):C=t[30];let w;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(de,{className:`size-3.5`}),t[31]=w):w=t[31];let T;t[32]!==i.copy||t[33]!==C?(T=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:C,children:[w,i.copy]}),t[32]=i.copy,t[33]=C,t[34]=T):T=t[34];let E;t[35]===n.shareUrl?E=t[36]:(E=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=E);let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(me,{className:`size-3.5`}),t[37]=D):D=t[37];let O;t[38]!==i.open||t[39]!==E?(O=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:E,children:[D,i.open]}),t[38]=i.open,t[39]=E,t[40]=O):O=t[40];let k;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(k=n.stale&&!s?(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,$.jsx)(Ve,{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]=k):k=t[46];let A;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(A=s?null:(0,$.jsx)(J,{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]=A):A=t[52];let j;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(j=n.revoked?null:(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,$.jsx)(Ke,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=j):j=t[57];let M;t[58]!==T||t[59]!==O||t[60]!==k||t[61]!==A||t[62]!==j?(M=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[T,O,k,A,j]}),t[58]=T,t[59]=O,t[60]=k,t[61]=A,t[62]=j,t[63]=M):M=t[63];let N;return t[64]!==S||t[65]!==l||t[66]!==M?(N=(0,$.jsxs)(`div`,{className:l,children:[S,M]}),t[64]=S,t[65]=l,t[66]=M,t[67]=N):N=t[67],N}function Zt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Qt={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:`撤销`},$t={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`},en=e(n(),1);function tn({noteId:e,selection:t,zh:n,onDismiss:r,onAsk:i}){let[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(``),[f,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),[_,v]=(0,Q.useState)({left:8,top:8}),y=s||a!==null||!!l,b=t.text.length>16e3;function x(){h.current?.abort(),r(),t.restore()}(0,Q.useEffect)(()=>{o(null),c(!1),d(``),m(!1);let e=e=>{g.current?.contains(e.target)||r()},n=e=>{e.key===`Escape`&&(e.preventDefault(),r(),t.restore())},i=e=>{!g.current?.contains(e.target)&&!h.current&&!g.current?.contains(document.activeElement)&&r()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,n),window.addEventListener(`resize`,r),window.addEventListener(`scroll`,i,!0),()=>{h.current?.abort(),h.current=null,document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,r),window.removeEventListener(`scroll`,i,!0)}},[t,r]),(0,Q.useLayoutEffect)(()=>{let e=g.current?.getBoundingClientRect();if(!e)return;let n=Math.max(8,Math.min(t.rect.left,window.innerWidth-e.width-8)),r=t.rect.bottom+8,i=r+e.height<=window.innerHeight-8?r:Math.max(8,t.rect.top-e.height-8);v({left:n,top:i})},[t,y,a,l]);async function S(r){h.current?.abort();let i=new AbortController;h.current=i,c(!0),d(``),o(null),m(!1);try{let a=await p(u(`/api/notes/${encodeURIComponent(e)}/ai/edit`),{method:`POST`,signal:i.signal,body:JSON.stringify({instruction:r,markdown:t.text})});if(i.signal.aborted)return;let s=a.patch.operations.filter(e=>e.type===`replaceRange`).map(e=>e.markdown??``).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/block-editor-D-YHASZr.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-CQcW9_qA.js","assets/messages-orB1BMgI.js","assets/unlink-BEuthaaq.js","assets/createLucideIcon-DPHK1VkS.js","assets/check-DUBLcKHA.js","assets/copy-Dv6d4Dvw.js","assets/external-link-DjqjBmc3.js","assets/notes-api-BhRyWe3S.js","assets/dist-BGTk37IG.js","assets/es2015-DBLcMg5B.js","assets/dist-CxGUk8J-.js","assets/download-Dk-ZjtO6.js","assets/markdown-view-CkihBz06.js","assets/chunk-KS7C4IRE-CiwuuyV8.js","assets/preload-helper-Czpn1I53.js","assets/file-image-CDUPkZvG.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/app-link-CdD448kS.js","assets/product-delivery-DRyD9_Xq.js","assets/schemas-CCWMleym.js","assets/local-apps-Ck6kACsY.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/xml-_d7dTN2Q.js","assets/mermaid-render-oOellPHt.js","assets/markdown-view-DG8DDkEA.css","assets/chat-chart-block-Cgks7rH3.js","assets/skeleton-DzdOeGYz.js","assets/list-todo-CTVRto8O.js","assets/loader-circle-CifKLtgG.js","assets/mic-CuUb7zc-.js","assets/pause-DuPxgSxk.js","assets/pencil-DmIY3Oa-.js","assets/play-kxZvpBg8.js","assets/vendor-swr-CdRzEUwF.js","assets/floating-ui.dom-seOukHzT.js","assets/linkify-it-BkqEorO0.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/with-selector-xonYxPoM.js","assets/note-image-lightbox-C6aTUp-c.js","assets/block-editor-Cvy3D_4T.css","assets/markdown-editor-CjQJ-Nho.js","assets/languages-kF11aUYU.js","assets/chat-page-CCwdk6yE.js","assets/app-window-DXFNqt_0.js","assets/archive-Dz0hferG.js","assets/arrow-left-D880xG-P.js","assets/voice-call-context-CJ1ZiJWR.js","assets/arrow-up-D5ZtR1QT.js","assets/product-automation-feedback-uKndNxpU.js","assets/activity-YogQEteU.js","assets/bot-DjLkhyZL.js","assets/circle-check-C23XjkUj.js","assets/circle-pause-CN9jYH2s.js","assets/clock-3-DnrAnuyZ.js","assets/message-square-fVE7Ghj1.js","assets/rotate-ccw-JM1TBLpp.js","assets/rotate-cw-LIg3Am9S.js","assets/sparkles-DHlfQFAF.js","assets/triangle-alert-2JXFNNKU.js","assets/volume-2-BSJhAY97.js","assets/zap-dximCGjy.js","assets/button-Cc4hUNTt.js","assets/automation-api-B3Jnoa2G.js","assets/earth-C9Z4bTTG.js","assets/chevron-down-ccbiQQz_.js","assets/chevron-right-BweFrslA.js","assets/working-directory-picker-modal-CFj-ZOJE.js","assets/file-archive-DanfQJNe.js","assets/interaction-BdhHBbYa.js","assets/form-field-width-DJw_jULe.js","assets/settings-form-draft-Dy10ldo8.js","assets/popover-select-CLsphyzA.js","assets/dist-GJ8-1PAx.js","assets/dist-BuHnPloF.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/circle-alert-BEjgurr2.js","assets/new-chat-navigation-B6NPQ4h4.js","assets/circle-x-DFsCKeya.js","assets/circle-BoO4YvTx.js","assets/file-tree-utils-DJs1faGv.js","assets/database-CjjeZfRG.js","assets/ellipsis-0k4rZLoy.js","assets/file-BqMS_3DT.js","assets/file-text-D12HbeVy.js","assets/folder-kanban-CpLlFI1o.js","assets/folder-open-CyzJ19I9.js","assets/folder-CN-pC3XL.js","assets/use-file-preview-expanded-RpLp7VdL.js","assets/eye-CABVeTq0.js","assets/link-2-D_ZKYUW7.js","assets/message-square-plus-XP0tGdlV.js","assets/minimize-2-DtOGrlpo.js","assets/paperclip-f1HujQY1.js","assets/refresh-cw-BRlGaq2w.js","assets/save-DRDABU--.js","assets/search-DA7gz22f.js","assets/constants-DpkUgykJ.js","assets/session-api-D7FWdG43.js","assets/gateway-startup-retry-DztAHGru.js","assets/attachment-utils-core-BIOUBrpT.js","assets/activity-store-Tn5McYcg.js","assets/app-chrome-BeB4KgOf.js","assets/electron-env-DHOGevH3.js","assets/use-async-resource-BHFGZCY2.js","assets/sliding-tab-list-CmcrqRzN.js","assets/sliding-indicator-hwz0sx3h.js","assets/index.module-Cd9ENXfk.js","assets/workspace-api-CD2aXy2n.js","assets/files-BNL4kkSB.js","assets/dist-ZrL34Ps4.js","assets/git-branch-Dh9uxTot.js","assets/globe-DSSGFWFn.js","assets/history-DXH_9jsE.js","assets/key-round-DWbpyU2U.js","assets/laptop-CI3hBVrl.js","assets/list-checks-BbsExAoq.js","assets/messages-square-BckAJrEW.js","assets/monitor-Af5eAvF7.js","assets/install-connector-dialog-B-v1FT3P.js","assets/secret-input-Dryrns2s.js","assets/is-masked-secret-DOkL5b_X.js","assets/connectors-api-DNVUmf9M.js","assets/gateway-config-swr-CtZy1Qw0.js","assets/oauth-provider-connect-CmHsHynu.js","assets/cloud-C4-yfnnk.js","assets/models-hub-cache-D2cdb8nZ.js","assets/registry-api-Bo8YiUE0.js","assets/oauth-api-D5iBtOid.js","assets/connection-usage-guide-DL2T6cSN.js","assets/connection-usage-BhdQRWgQ.js","assets/settings-2-D-csvaET.js","assets/settings-uiTATseT.js","assets/shield-check-BU58siTV.js","assets/smartphone-DSSsQFqA.js","assets/square-DMK_fB-3.js","assets/trash-2-DusmjVPV.js","assets/share-link-dialog-0P9ghttc.js","assets/copy-text-row-CpiRzq4G.js","assets/wrench-DFb4r8bH.js","assets/tasks-BTLabOMp.js","assets/specialists-xbB3xL9e.js","assets/api-BET9vZ1l.js","assets/session-manager-7qKSmROh.js","assets/local-session-drafts-C6oPrCYY.js","assets/tool-activity-BtJkgjFf.js","assets/personal-proactivity-DaRnbB1f.js","assets/gateway-realtime-CG65gHUY.js","assets/gateway-realtime-store-Vl3uKAHV.js","assets/agents-admin-api-CShyoj9I.js","assets/new-session-preferences-gb411vZP.js","assets/extension-provider-dpOtxmuc.js","assets/capabilities-Cxh3nYa6.js","assets/theme-store-BTkYFJOE.js","assets/middleware-Pd0e8Igk.js","assets/use-composer-attachments-DBsGBWDR.js","assets/chevron-left-DqFhpbvK.js","assets/capabilities-YfkMBZCb.js","assets/file-preview-surface-B3nLuoQO.js","assets/phone-workspace-store-DAuPd2ie.js","assets/shares-api-iiw4F-ra.js","assets/skill-wire-pattern-BPpeIcCi.js","assets/chat-agents-api-CgasFAm4.js","assets/composer-payload-handoff-CrTYMPL_.js","assets/voice-transcribe-api-By2znMrG.js","assets/open-capability-settings-Cvb65hQB.js","assets/workspace-editor-agent-store-2Lt7rQfw.js","assets/voice-input-shortcut-events-TAmJNcsN.js","assets/chunk-D32TOXHM-DQIy-Baq.js","assets/tool-friendly-title-YQmN1S2k.js","assets/page-header-store-B2Ahfm0W.js","assets/loopi-CNtmi9FU.js","assets/loopi-C09I2mNj.css","assets/agent-avatar-display-C7Dx9nt1.js","assets/use-directory-picker-C4p7AgWY.js","assets/confirm-dialog-D7dQJytv.js","assets/command-palette-api-Bku_h283.js","assets/skill-list-api-DY0rRlUk.js","assets/skill-api-utils-C7V4JVXM.js","assets/model-selector-DYxgKUju.js","assets/model-sort-_Tz8s_4N.js","assets/automation-task-card-Clf0fe_n.js","assets/calendar-clock-D-quYVPe.js","assets/message-circle-Badhj-4D.js","assets/date-picker-E0cqnNlR.js","assets/calendar-days-hw_Y-g-s.js","assets/time-picker-C1PXAXZF.js","assets/dev-view-store-DnqJb6NS.js","assets/extension-iframe-host-B0oIml1X.js","assets/api-B3M6ifoo.js","assets/runtime-health-D2TDFLLq.js","assets/terminal-panel-store-B1EVdx4L.js","assets/agents-app-path-ciChvpCS.js","assets/agent-display-names-Bje7vfSn.js","assets/use-media-query-ady-FgjK.js","assets/oauth-authorization-window-o6URRos4.js","assets/page-context-draft-aApa5ApP.js","assets/management-api-Dh2r5GrQ.js","assets/side-chat-shortcut-BIw-1TTD.js","assets/chat-page-zQeUaawJ.css"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{l as o,t as s,u as c}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as l,i as u,l as d,n as f,o as p,p as m}from"./locale-store-CQcW9_qA.js";import{t as h}from"./messages-orB1BMgI.js";import{a as g,c as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./dist-BGTk37IG.js";import{E as w,b as T,d as E,h as D,i as O,n as k,o as A,r as j,t as M,w as N,x as P}from"./discussion-annotation-sync-BmvCn1Xn.js";import{t as F}from"./arrow-left-D880xG-P.js";import{a as I,c as L,d as R,i as z,l as B,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./product-automation-feedback-uKndNxpU.js";import{t as oe}from"./check-DUBLcKHA.js";import{t as se}from"./chevron-down-ccbiQQz_.js";import{n as ce,r as V}from"./popover-select-CLsphyzA.js";import{t as le}from"./circle-check-C23XjkUj.js";import{t as ue}from"./code-xml-DJtYhZUF.js";import{t as de}from"./copy-Dv6d4Dvw.js";import{t as fe}from"./download-Dk-ZjtO6.js";import{t as pe}from"./ellipsis-0k4rZLoy.js";import{t as me}from"./external-link-DjqjBmc3.js";import{t as H}from"./eye-CABVeTq0.js";import{t as he}from"./file-text-D12HbeVy.js";import{t as U}from"./history-DXH_9jsE.js";import{C as ge,E as _e,F as ve,O as ye,P as be,S as xe,T as Se,_ as Ce,a as we,c as Te,d as Ee,f as De,h as Oe,l as W,m as ke,n as Ae,r as je,s as Me,u as Ne,w as Pe,x as Fe}from"./notes-api-BhRyWe3S.js";import{t as Ie}from"./loader-circle-CifKLtgG.js";import{P as Le}from"./markdown-view-CkihBz06.js";import{t as Re}from"./message-circle-Badhj-4D.js";import{t as ze}from"./pencil-DmIY3Oa-.js";import{t as Be}from"./play-kxZvpBg8.js";import{t as Ve}from"./refresh-cw-BRlGaq2w.js";import{t as He}from"./search-DA7gz22f.js";import{t as Ue}from"./sliders-horizontal-DqsYor6I.js";import{t as We}from"./sparkles-DHlfQFAF.js";import{t as Ge}from"./square-pen-B8FsvqNu.js";import{t as G}from"./square-DMK_fB-3.js";import{t as Ke}from"./trash-2-DusmjVPV.js";import{t as qe}from"./x-B_N4OPjy.js";import{t as K}from"./cn-0WouolD0.js";import{t as q}from"./skeleton-DzdOeGYz.js";import{t as Je}from"./session-manager-7qKSmROh.js";import{i as Ye}from"./vendor-swr-CdRzEUwF.js";import{t as J}from"./button-Cc4hUNTt.js";import{t as Xe}from"./copy-to-clipboard-HOJ79TWv.js";import{r as Y}from"./app-chrome-BeB4KgOf.js";import{i as Ze}from"./theme-store-BTkYFJOE.js";import{t as Qe}from"./page-header-store-B2Ahfm0W.js";import{t as X}from"./automation-api-B3Jnoa2G.js";import{t as $e}from"./confirm-dialog-D7dQJytv.js";import{b as et,d as tt,o as nt,s as rt,v as it}from"./shares-api-iiw4F-ra.js";import{l as at,m as ot,o as st,r as ct,t as lt,u as ut}from"./dist-ZrL34Ps4.js";import{t as Z}from"./oauth-provider-connect-CmHsHynu.js";import{n as dt,t as ft}from"./page-context-draft-aApa5ApP.js";import"./note-image-lightbox-C6aTUp-c.js";import{t as pt}from"./page-context-capture-button-CQoRZ1b-.js";var Q=e(t(),1),mt=r(),$=i(),ht=6e4,gt=36e5,_t=864e5;function vt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function yt(e,t,n){let r=t-e;if(r<ht)return n.justNow;if(r<gt){let e=Math.floor(r/ht);return n.minutesAgo.replace(`{{n}}`,String(e))}let i=vt(t);if(e>=i)return n.today+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(e>=i-_t)return n.yesterday+` `+new Date(e).toLocaleTimeString(n.locale,{hour:`2-digit`,minute:`2-digit`});if(r<7*_t){let e=Math.floor(r/_t);return n.daysAgo.replace(`{{n}}`,String(e))}return new Date(e).toLocaleDateString(n.locale,{month:`short`,day:`numeric`})}function bt(e,t,n){let r=vt(t);if(e>=r)return n.today;if(e>=r-_t)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 xt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function St(e){let t=(0,mt.c)(45),{title:n,description:r,prompt:i,coverage:a,className:o,variant:s}=e,l=s===void 0?`card`:s,u=f(Tt),d=h(u).automations.suggestions,p=h(u).automations,m=c(),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=g):g=t[0];let{data:_}=Ye(a?`automation-suggestion-coverage`:null,wt,g),v=a?_?.automations.find(e=>z(e,a)):void 0,y=v?ee(v,p):[];if(l===`titleAction`){if(v){let e;t[1]===o?e=t[2]:(e=K(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,o),t[1]=o,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(le,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let r;return t[4]===m?r=t[5]:(r=()=>m(`/automations`),t[4]=m,t[5]=r),(0,$.jsxs)(`section`,{className:e,children:[n,(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:d.coveredTitle}),(0,$.jsx)(J,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:r,children:d.manage})]})}let e;t[6]===o?e=t[7]:(e=K(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,o),t[6]=o,t[7]=e);let a;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(N,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=a):a=t[8];let s;t[9]!==r||t[10]!==n?(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:r,children:n}),t[9]=r,t[10]=n,t[11]=s):s=t[11];let c;t[12]!==m||t[13]!==i?(c=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});m(`/automations?${e.toString()}`)},t[12]=m,t[13]=i,t[14]=c):c=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,$.jsxs)(`section`,{className:e,children:[a,s,(0,$.jsxs)(J,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:c,children:[l,d.setup]})]})}if(v){let e;t[16]===o?e=t[17]:(e=K(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,o),t[16]=o,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let r;t[19]===m?r=t[20]:(r=()=>m(`/automations`),t[19]=m,t[20]=r);let i;return t[21]!==d||t[22]!==r?(i=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsx)(J,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:r,children:d.manage})}),t[21]=d,t[22]=r,t[23]=i):i=t[23],(0,$.jsxs)(`section`,{className:e,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:d.coveredTitle}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:ne(d.coveredDescription,{name:v.name})})]})]}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:p.explain.whyCovered}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:y.map(Ct)})]}),i]})}let b;t[24]===o?b=t[25]:(b=K(`rounded-lg bg-surface-panel p-3 shadow-surface`,o),t[24]=o,t[25]=b);let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=x):x=t[26];let S;t[27]===n?S=t[28]:(S=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[27]=n,t[28]=S);let C;t[29]===r?C=t[30]:(C=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:r}),t[29]=r,t[30]=C);let w;t[31]!==S||t[32]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[x,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]})]}),t[31]=S,t[32]=C,t[33]=w):w=t[33];let T;t[34]!==m||t[35]!==i?(T=()=>{let e=new URLSearchParams({draft:i,autogenerate:`1`});m(`/automations?${e.toString()}`)},t[34]=m,t[35]=i,t[36]=T):T=t[36];let E;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0}),t[37]=E):E=t[37];let D;t[38]!==d.create||t[39]!==T?(D=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(J,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:T,children:[E,d.create]})}),t[38]=d.create,t[39]=T,t[40]=D):D=t[40];let O;return t[41]!==D||t[42]!==b||t[43]!==w?(O=(0,$.jsxs)(`section`,{className:b,children:[w,D]}),t[41]=D,t[42]=b,t[43]=w,t[44]=O):O=t[44],O}function Ct(e){return(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function wt(){return X.list()}function Tt(e){return e.language}var Et=`z-[140] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 text-sm text-fg shadow-popover`,Dt=`flex min-h-11 cursor-pointer items-center gap-2 rounded-md px-3 outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`;function Ot(e){let t=(0,mt.c)(54),{detail:n,zh:r,busy:i,processing:a,pageText:o,editing:s,noteActions:c}=e,l=`/api/discussions/${encodeURIComponent(n.discussion.id)}`,d=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,f;t[0]!==n.note.id||t[1]!==c||t[2]!==r?(f=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent aria-expanded:bg-accent-soft aria-expanded:text-accent-fg aria-expanded:hover:bg-accent-soft`,"aria-expanded":c.chatOpen??!1,"aria-controls":`note-assistant-${n.note.id}`,disabled:c.busy,onClick:c.onChat,children:[(0,$.jsx)(Re,{className:`size-4`,"aria-hidden":!0}),r?`AI 对话`:`AI chat`]}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r?`分享笔记`:`Share note`,disabled:c.busy,onClick:c.onShare,children:[(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:r?`分享`:`Share`})]})]}):null,t[0]=n.note.id,t[1]=c,t[2]=r,t[3]=f):f=t[3];let p=r?`导出笔记`:`Export note`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),t[4]=m):m=t[4];let h=r?`导出`:`Export`,g;t[5]===h?g=t[6]:(g=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h}),t[5]=h,t[6]=g);let _;t[7]!==p||t[8]!==g?(_=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":p,children:[m,g]})}),t[7]=p,t[8]=g,t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=[`md`,`txt`,`srt`],t[10]=v):v=t[10];let y;t[11]!==l||t[12]!==r?(y=v.map(e=>(0,$.jsx)(ct,{asChild:!0,children:(0,$.jsx)(`a`,{className:Dt,href:u(`${l}/export?format=${e}`),download:!0,children:e===`srt`?r?`字幕 · SRT`:`Subtitles · SRT`:e===`md`?`Markdown · MD`:r?`纯文本 · TXT`:`Plain text · TXT`})},e)),t[11]=l,t[12]=r,t[13]=y):y=t[13];let b;t[14]!==d||t[15]!==l||t[16]!==r?(b=d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsx)(ct,{asChild:!0,children:(0,$.jsxs)(`a`,{className:Dt,href:u(`${l}/audio`),download:!0,children:[(0,$.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),r?`下载录音`:`Download recording`]})})]}):null,t[14]=d,t[15]=l,t[16]=r,t[17]=b):b=t[17];let x;t[18]!==y||t[19]!==b?(x=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,collisionPadding:12,className:Et,children:[y,b]})}),t[18]=y,t[19]=b,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==_?(S=(0,$.jsxs)(at,{children:[_,x]}),t[21]=x,t[22]=_,t[23]=S):S=t[23];let C=r?`更多笔记操作`:`More note actions`,w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(pe,{className:`size-5`,"aria-hidden":!0}),t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":C,className:`inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:w})}),t[25]=C,t[26]=T);let E;t[27]!==c||t[28]!==r?(E=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ct,{className:Dt,disabled:c.busy,onSelect:c.onAnalyze,children:[(0,$.jsx)(We,{className:`size-4`,"aria-hidden":!0}),r?`进一步分析`:`Analyze this note`]}),(0,$.jsxs)(ct,{className:Dt,onSelect:c.onHistory,children:[(0,$.jsx)(U,{className:`size-4`,"aria-hidden":!0}),r?`版本历史`:`Version history`]})]}):null,t[27]=c,t[28]=r,t[29]=E):E=t[29];let D=n.note.id,O=String(n.note.remoteVersion??1),k;t[30]!==n.note.id||t[31]!==O?(k={kind:`note`,id:D,revision:O},t[30]=n.note.id,t[31]=O,t[32]=k):k=t[32];let A;t[33]===o?A=t[34]:(A={text:o,draft:!1},t[33]=o,t[34]=A);let j=r?`带到新对话`:`Use in a new chat`,M=i||a||s||!o||o.length>16e3,N;t[35]!==k||t[36]!==A||t[37]!==j||t[38]!==M?(N=(0,$.jsx)(`div`,{children:(0,$.jsx)(pt,{presentation:`menu`,resource:k,selection:A,label:j,disabled:M})}),t[35]=k,t[36]=A,t[37]=j,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==c||t[41]!==r?(P=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(ct,{className:`${Dt} text-danger`,disabled:c.busy,onSelect:c.onDelete,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),r?`删除笔记`:`Delete note`]})]}):null,t[40]=c,t[41]=r,t[42]=P):P=t[42];let F;t[43]!==E||t[44]!==N||t[45]!==P?(F=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,collisionPadding:12,className:Et,children:[E,N,P]})}),t[43]=E,t[44]=N,t[45]=P,t[46]=F):F=t[46];let I;t[47]!==T||t[48]!==F?(I=(0,$.jsxs)(at,{children:[T,F]}),t[47]=T,t[48]=F,t[49]=I):I=t[49];let L;return t[50]!==f||t[51]!==S||t[52]!==I?(L=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[f,S,I]}),t[50]=f,t[51]=S,t[52]=I,t[53]=L):L=t[53],L}function kt(e){let t=(0,mt.c)(68),{detail:n,template:r,onTemplate:i,zh:a,busy:o,processing:s,onOrganize:c,onRegenerate:l}=e,[u,d]=(0,Q.useState)(!1),f=!!n.discussion.audioAttachmentId&&!n.discussion.audioDeletedAt,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),t[0]=p):p=t[0];let m=a?`整理方式`:`Summary settings`,h;t[1]===m?h=t[2]:(h=(0,$.jsx)(_,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[p,m]})}),t[1]=m,t[2]=h);let w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(g,{className:`fixed inset-0 z-[150] bg-scrim`}),t[3]=w):w=t[3];let T=a?`整理方式`:`Summary settings`,E;t[4]===T?E=t[5]:(E=(0,$.jsx)(S,{className:`font-medium`,children:T}),t[4]=T,t[5]=E);let D=a?`关闭整理设置`:`Close summary settings`,O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(qe,{className:`size-4`}),t[6]=O):O=t[6];let k;t[7]===D?k=t[8]:(k=(0,$.jsx)(y,{className:`inline-flex size-11 items-center justify-center rounded-lg hover:bg-surface-hover`,"aria-label":D,children:O}),t[7]=D,t[8]=k);let A;t[9]!==E||t[10]!==k?(A=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-5 py-3`,children:[E,k]}),t[9]=E,t[10]=k,t[11]=A):A=t[11];let j=a?`根据已有原文重新整理纪要。你已手动编辑的内容会保留。`:`Reorganize the existing transcript. Your manual edits are preserved.`,M;t[12]===j?M=t[13]:(M=(0,$.jsx)(v,{className:`text-sm leading-6 text-fg-muted`,children:j}),t[12]=j,t[13]=M);let N=a?`纪要模板`:`Summary template`,P;t[14]===N?P=t[15]:(P=(0,$.jsx)(`span`,{children:N}),t[14]=N,t[15]=P);let F=a?`纪要模板`:`Summary template`,I;t[16]===i?I=t[17]:(I=e=>i(e.target.value),t[16]=i,t[17]=I);let L=a?`通用会议`:`General`,R;t[18]===L?R=t[19]:(R=(0,$.jsx)(V,{value:`general`,children:L}),t[18]=L,t[19]=R);let z=a?`项目例会`:`Project`,B;t[20]===z?B=t[21]:(B=(0,$.jsx)(V,{value:`project`,children:z}),t[20]=z,t[21]=B);let ee=a?`需求评审`:`Review`,te;t[22]===ee?te=t[23]:(te=(0,$.jsx)(V,{value:`review`,children:ee}),t[22]=ee,t[23]=te);let ne=a?`客户访谈`:`Interview`,re;t[24]===ne?re=t[25]:(re=(0,$.jsx)(V,{value:`interview`,children:ne}),t[24]=ne,t[25]=re);let ie;t[26]!==F||t[27]!==I||t[28]!==R||t[29]!==B||t[30]!==te||t[31]!==re||t[32]!==r?(ie=(0,$.jsxs)(ce,{value:r,"aria-label":F,onChange:I,children:[R,B,te,re]}),t[26]=F,t[27]=I,t[28]=R,t[29]=B,t[30]=te,t[31]=re,t[32]=r,t[33]=ie):ie=t[33];let ae;t[34]!==P||t[35]!==ie?(ae=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[P,ie]}),t[34]=P,t[35]=ie,t[36]=ae):ae=t[36];let oe;t[37]!==f||t[38]!==o||t[39]!==n.discussion.status||t[40]!==l||t[41]!==s||t[42]!==a?(oe=f&&[`completed`,`needs_attention`].includes(n.discussion.status)?(0,$.jsxs)(`details`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer text-sm text-fg-muted`,children:a?`高级选项:重新识别录音`:`Advanced: transcribe again`}),(0,$.jsx)(`p`,{className:`mb-3 text-xs leading-5 text-fg-muted`,children:a?`重新处理原音,可能耗时较长。适用于原文缺失或识别不完整。`:`Process the original recording again when text is missing or incomplete. This may take longer.`}),(0,$.jsx)(J,{disabled:o||s,onClick:()=>{d(!1),l()},children:a?`从原音重新生成`:`Regenerate from audio`})]}):null,t[37]=f,t[38]=o,t[39]=n.discussion.status,t[40]=l,t[41]=s,t[42]=a,t[43]=oe):oe=t[43];let se;t[44]!==M||t[45]!==ae||t[46]!==oe?(se=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[M,ae,oe]}),t[44]=M,t[45]=ae,t[46]=oe,t[47]=se):se=t[47];let le=a?`取消`:`Cancel`,ue;t[48]===le?ue=t[49]:(ue=(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(J,{children:le})}),t[48]=le,t[49]=ue);let de=o||s||!n.discussion.canonicalTranscript,fe;t[50]===c?fe=t[51]:(fe=()=>{d(!1),c()},t[50]=c,t[51]=fe);let pe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":!0}),t[52]=pe):pe=t[52];let me=a?`重新整理纪要`:`Regenerate summary`,H;t[53]!==de||t[54]!==fe||t[55]!==me?(H=(0,$.jsxs)(J,{variant:`primary`,disabled:de,onClick:fe,children:[pe,me]}),t[53]=de,t[54]=fe,t[55]=me,t[56]=H):H=t[56];let he;t[57]!==ue||t[58]!==H?(he=(0,$.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle p-4`,children:[ue,H]}),t[57]=ue,t[58]=H,t[59]=he):he=t[59];let U;t[60]!==A||t[61]!==se||t[62]!==he?(U=(0,$.jsxs)(b,{children:[w,(0,$.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[151] flex h-[min(28rem,90dvh)] w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg`,children:[A,se,he]})]}),t[60]=A,t[61]=se,t[62]=he,t[63]=U):U=t[63];let ge;return t[64]!==u||t[65]!==h||t[66]!==U?(ge=(0,$.jsxs)(C,{open:u,onOpenChange:d,children:[h,U]}),t[64]=u,t[65]=h,t[66]=U,t[67]=ge):ge=t[67],ge}function At(e){return JSON.stringify([e.transcript.revision,e.transcript.segments.map(e=>[e.sequence,e.revision,e.status]),e.organization?.revision])}function jt(e,t){let n=(0,mt.c)(21),[r,i]=(0,Q.useState)(),a;n[0]!==t||n[1]!==e||n[2]!==r?.noteId?(a=()=>{t&&r?.noteId!==e&&i({noteId:e,version:At(t),value:t})},n[0]=t,n[1]=e,n[2]=r?.noteId,n[3]=a):a=n[3];let o=r?.noteId,s;n[4]!==t||n[5]!==e||n[6]!==o?(s=[e,t,o],n[4]=t,n[5]=e,n[6]=o,n[7]=s):s=n[7],(0,Q.useEffect)(a,s);let c;n[8]!==t||n[9]!==e?(c=n=>{let r=n===void 0?t:n;r&&i({noteId:e,version:At(r),value:r})},n[8]=t,n[9]=e,n[10]=c):c=n[10];let l=c,u=r?.noteId===e?r:void 0,d;n[11]!==u||n[12]!==t?(d=!!t&&!!u&&u.version!==At(t),n[11]=u,n[12]=t,n[13]=d):d=n[13];let f=d,p;n[14]!==u||n[15]!==t?(p=t&&u?{...t,transcript:u.value.transcript,organization:u.value.organization}:t,n[14]=u,n[15]=t,n[16]=p):p=n[16];let m=p,h;return n[17]!==m||n[18]!==f||n[19]!==l?(h={detail:m,hasUpdates:f,publish:l},n[17]=m,n[18]=f,n[19]=l,n[20]=h):h=n[20],h}var Mt=e=>`${Math.floor(e/6e4)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function Nt({id:e,query:t,zh:n,refreshKey:r,sourceKey:i,active:a,tab:o,onEvidence:s,onPlay:c}){let[l,d]=(0,Q.useState)(),[f,m]=(0,Q.useState)(),h=(0,Q.useRef)(null),g=(0,Q.useRef)(!1),[_,v]=(0,Q.useState)(!0),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(0),[w,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(0),M=JSON.stringify([e,i,t]),N=t?``:r;(0,Q.useEffect)(()=>{if(!a||t)return;let e=window.setInterval(()=>j(e=>e+1),3e3);return()=>window.clearInterval(e)},[a,t]),(0,Q.useEffect)(()=>{D(void 0)},[e,t]),(0,Q.useEffect)(()=>{let n=++C.current,r=new AbortController;v(!0),S(!1),b(``);let i=g.current;g.current=!1;let a=window.setTimeout(()=>{p(u(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}`),{signal:r.signal}).then(e=>{if(C.current!==n)return;let r=h.current;if(!i&&r?.key===M){r.value.version!==e.version&&m(e);return}h.current={key:M,value:e},d(e),m(void 0),T(M),k(t)}).catch(e=>{C.current===n&&!r.signal.aborted&&b(String(e))}).finally(()=>{C.current===n&&v(!1)})},t?200:0);return()=>{C.current++,r.abort(),window.clearTimeout(a)}},[e,t,N,i,M,A]);function P(){g.current=!0,j(e=>e+1)}async function F(){if(!l||x)return;let r=C.current;S(!0);try{let n=await p(u(`/api/discussions/${encodeURIComponent(e)}/review?q=${encodeURIComponent(t)}&offset=${l.hits.length}&version=${l.version}`));if(r===C.current){let e={...n,hits:[...l.hits,...n.hits]};h.current={key:M,value:e},d(e)}}catch(e){r===C.current&&b(n?`内容已变化,请重新搜索。${String(e)}`:`Content changed; search again. ${String(e)}`)}finally{r===C.current&&S(!1)}}function I(e){D(e),(!e.provisional||e.kind===`chapter`)&&e.transcriptRevision!==void 0&&e.segments.length&&s({transcriptRevision:e.transcriptRevision,stale:e.stale,audioAvailable:l?.coverage.audioAvailable??!1,timingVerified:e.segments.some(e=>e.playback.length>0),segments:e.segments})}let L=e=>e.kind===`chapter`?n?`章节`:`Chapter`:e.kind===`annotation`?n?`我的标记`:`My mark`:e.kind===`analysis`?n?`分析`:`Analysis`:n?`原文`:`Transcript`,R=e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-xl bg-surface-inset p-4`,children:[(0,$.jsxs)(`button`,{className:`text-left text-sm text-accent-fg`,onClick:()=>I(e),children:[e.startedAtMs===void 0?``:`${Mt(e.startedAtMs)}${e.endedAtMs===void 0?``:`–${Mt(e.endedAtMs)}`} · `,e.title||L(e)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm`,children:e.kind===`chapter`&&!t&&e.text.length>300?`${e.text.slice(0,300)}…`:e.text}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[L(e),e.provisional?n?` · 阶段性结果`:` · Partial result`:``,e.stale?n?` · 原文已更新,保留旧版依据`:` · Earlier transcript revision`:``,e.kind===`chapter`?` · ${e.highlightCount??0} ${n?`个重点`:`marks`} · ${e.actionCount??0} ${n?`个候选行动`:`candidate actions`}`:``]}),e.kind!==`chapter`||t||E?.id===e.id?e.segments.map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Mt(e.startedAtMs),` · `,e.text.length>500?`${e.text.slice(0,500)}…`:e.text]},`${e.sequence}:${e.startedAtMs}`)):null,e.playback.slice(0,3).map((e,t)=>(0,$.jsxs)(J,{onClick:()=>c(e.startedAtMs,e.endedAtMs),children:[n?`回听上下文`:`Play context`,` `,Mt(e.startedAtMs),`–`,Mt(e.endedAtMs)]},t)),e.segments.length?(0,$.jsx)(J,{onClick:()=>I(e),children:n?`查看对应原文`:`View transcript`}):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`暂无可核实的原文定位`:`No verified transcript reference`})]},e.id);return(0,$.jsxs)(`section`,{"aria-label":n?`长录音回顾`:`Recording review`,className:`flex flex-col gap-3`,children:[y?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:y}),(0,$.jsx)(J,{onClick:P,children:n?`刷新结果`:`Refresh results`})]}):null,_&&(!l||w!==M||O!==t)?(0,$.jsx)(q,{className:`h-20 w-full`}):null,l&&w===M&&(!t||O===t)?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-10 h-0`,children:f?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-edge-subtle bg-surface-overlay px-3 py-2 text-xs text-fg-muted shadow-popover`,children:[(0,$.jsx)(`span`,{role:`status`,children:n?`内容已更新,当前阅读位置已保留`:`Updates available. Your reading position is preserved.`}),(0,$.jsx)(J,{variant:`ghost`,onClick:()=>{h.current={key:M,value:f},d(f),m(void 0)},children:n?`查看最新`:`View latest`})]}):null}),t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`搜索结果 · ${l.total}`:`Search results · ${l.total}`}),(0,$.jsx)(J,{onClick:P,children:n?`刷新结果`:`Refresh results`}),(0,$.jsx)(`div`,{"aria-label":n?`命中位置`:`Match positions`,className:`relative my-3 h-5 rounded bg-surface-inset`,children:l.hits.filter(e=>e.startedAtMs!==void 0).map(e=>(0,$.jsx)(`button`,{className:`absolute top-0 h-5 w-1.5 rounded bg-accent`,style:{left:`${Math.min(99,100*e.startedAtMs/Math.max(1,l.coverage.durationMs))}%`},"aria-label":`${Mt(e.startedAtMs)} ${e.title||L(e)}`,onClick:()=>I(e)},e.id))}),l.total?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`未找到关键词;尚未转写的内容无法搜索。`:`No matches. Untranscribed audio is not searchable yet.`}),l.hits.map(R)]}):(0,$.jsxs)($.Fragment,{children:[o===`summary`&&l.chapters.length?(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-inset px-4`,children:[(0,$.jsxs)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-sm font-medium focus-visible:ring-2 focus-visible:ring-accent`,children:[n?`章节目录`:`Chapters`,` · `,l.chapters.length]}),(0,$.jsx)(`div`,{className:`space-y-3 pb-4`,children:l.chapters.map(R)})]}):null,l.hits.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`本轮已完成转写(阶段性)`:`Available transcription from this run`}),l.hits.map(R)]}):null]}),l.hasMore?(0,$.jsx)(J,{disabled:x,onClick:()=>void F(),children:n?`加载更多结果`:`More results`}):null,(0,$.jsxs)(`details`,{className:`rounded-lg text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 focus-visible:ring-2 focus-visible:ring-accent`,children:n?`处理范围`:`Processing coverage`}),(0,$.jsxs)(`div`,{role:`status`,className:`space-y-2 pb-3 leading-5`,children:[(0,$.jsxs)(`p`,{children:[n?`原音`:`Audio`,` · `,l.coverage.audioAvailable?n?`已保存,可回听`:`Saved, ready to play`:n?`尚不可用`:`Unavailable`]}),(0,$.jsxs)(`p`,{children:[n?`本轮转写已处理`:`Processed this run`,` `,Mt(l.coverage.processedMs),` / `,Mt(l.coverage.durationMs),` · `,n?`连续处理至`:`Continuous through`,` `,Mt(l.coverage.continuousThroughMs)]}),(0,$.jsxs)(`p`,{children:[n?`分析覆盖`:`Analysis coverage`,` · `,l.coverage.analysisRanges.length?l.coverage.analysisRanges.map(e=>`${Mt(e.startedAtMs)}–${Mt(e.endedAtMs)}`).join(`、`):n?`暂无本版已完成章节`:`No completed chapters for this revision`,l.coverage.analysisStale?n?`;已发布分析基于旧版原文`:`; published analysis uses an earlier transcript`:``,` · `,l.coverage.complete?n?`本轮处理完成`:`Run complete`:n?`阶段性内容,其余仍待处理`:`Partial content; remaining work pending`]})]})]}),E?.provisional?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`以上是本轮已保存的阶段性原文;正式发布后才能校对和标记具体段落。`:`Saved partial text; segment editing and highlighting become available after publication.`}):null]}):null]})}function Pt({recordingId:e,discussionId:t,zh:n,onEvidence:r,onPlay:i}){let{data:a=[],mutate:o}=Ye(`/api/discussions/${t}/annotations`,e=>p(u(e))),[s,c]=(0,Q.useState)([]),[l,d]=(0,Q.useState)(null),[f,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),_=(0,Q.useCallback)(async()=>{c(await j(e))},[e]),v=(0,Q.useCallback)(async()=>{try{await M(e,t),await _(),await o()}catch(e){await o(),g(e instanceof Error?e.message:String(e))}},[e,t,_,o]);(0,Q.useEffect)(()=>{_().catch(e=>g(String(e))),v();let e=()=>{_().catch(e=>g(String(e)))};window.addEventListener(`discussion-annotations-changed`,e),window.addEventListener(`online`,v);let t=window.setInterval(()=>{navigator.onLine&&v()},15e3);return()=>{window.removeEventListener(`discussion-annotations-changed`,e),window.removeEventListener(`online`,v),window.clearInterval(t)}},[_,v]);let y=new Map(a.map(e=>[e.annotation.id,{...e,localState:`synced`}]));for(let e of s)if(e.state!==`synced`||!y.has(e.annotation.id)){let t=y.get(e.annotation.id);y.set(e.annotation.id,{annotation:e.annotation,state:t?.state??`pending`,playback:t?.playback??[],evidence:t?.evidence,localState:e.state})}let b=async(t,n=s.find(e=>e.annotation.id===t.id)?.nonce??null)=>{try{await A(e,{...t,updatedAt:Date.now()},n),m(null),g(``),await _(),v()}catch(e){g(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`section`,{className:`space-y-4`,"aria-label":n?`我的标记`:`My highlights`,children:[h?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[h,(0,$.jsx)(J,{onClick:()=>void v(),children:n?`重试同步`:`Retry sync`})]}):null,y.size?null:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`录音时标重点,或在原文中标记整段。标记先保存在本机。`:`Highlight while recording or mark a transcript segment. Highlights save locally first.`}),[...y.values()].sort((e,t)=>e.annotation.anchor.capturedAt-t.annotation.anchor.capturedAt).filter(e=>!e.annotation.deleted||e.localState===`conflict`).map(e=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.annotation.kind===`highlight`?n?`重点`:`Highlight`:e.annotation.kind===`question`?n?`问题`:`Question`:n?`我的补充`:`My note`,` · `,new Date(e.annotation.anchor.capturedAt).toLocaleString(),` · `,e.localState===`synced`?n?`已同步`:`Synced`:e.localState===`conflict`?n?`同步冲突,保留了本机修改`:`Conflict; local edits retained`:n?`本机已保存,待同步`:`Saved locally; sync pending`]}),e.evidence?.segments.map(e=>(0,$.jsx)(`blockquote`,{className:`text-sm`,children:e.text},e.sequence)),e.positionMs===void 0?null:(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n?`标记位置`:`Marked position`,` · `,Math.floor(e.positionMs/6e4),`:`,String(Math.floor(e.positionMs/1e3)%60).padStart(2,`0`)]}),e.annotation.text?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm`,children:[n?`我的说明:`:`My context: `,e.annotation.text]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(J,{disabled:!e.evidence,onClick:()=>e.evidence&&r(e.evidence),children:n?`查看原文`:`View transcript`}),e.playback.map((e,t)=>(0,$.jsxs)(J,{onClick:()=>i(e),children:[n?`回听`:`Play`,` `,Math.floor(e.startedAtMs/6e4),`:`,String(Math.floor(e.startedAtMs/1e3)%60).padStart(2,`0`)]},t)),(0,$.jsx)(J,{onClick:()=>{d(s.find(t=>t.annotation.id===e.annotation.id)?.nonce??null),m({...e.annotation,revision:a.find(t=>t.annotation.id===e.annotation.id)?.annotation.revision??e.annotation.revision})},children:e.localState===`conflict`?n?`合并修改`:`Merge changes`:n?`添加说明/类型`:`Edit context/type`}),(0,$.jsx)(J,{onClick:()=>void b({...e.annotation,deleted:!0}),children:n?`移除标记`:`Remove`})]}),e.state===`located`&&!e.evidence?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原文尚未生成,可先回听原音。`:`Transcript for this position is pending; audio is usable.`}):null,e.state===`unavailable`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`该位置原音未保存、已删除或时间尚无法核实;保留原始标记,不自动移动。`:`Audio at this position is missing, deleted or unverified. The original anchor has been retained.`}):e.state===`pending`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`等待原音/原文完成定位`:`Awaiting audio/transcript positioning`}):null,e.localState===`conflict`?(0,$.jsx)(J,{onClick:()=>{let t=s.find(t=>t.annotation.id===e.annotation.id),n=a.find(t=>t.annotation.id===e.annotation.id);t&&n&&k(t,n.annotation).then(_)},children:n?`使用服务端版本`:`Use server version`}):null]},e.annotation.id)),f?(0,$.jsxs)(`div`,{role:`dialog`,"aria-label":n?`编辑标记`:`Edit highlight`,className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(ce,{value:f.kind,"aria-label":n?`标记类型`:`Highlight type`,onChange:e=>m({...f,kind:e.target.value}),children:[(0,$.jsx)(V,{value:`highlight`,children:n?`重点`:`Highlight`}),(0,$.jsx)(V,{value:`question`,children:n?`问题`:`Question`}),(0,$.jsx)(V,{value:`note`,children:n?`补充`:`Context`})]}),(0,$.jsx)(`textarea`,{"aria-label":n?`我的说明`:`My context`,maxLength:4e3,value:f.text,onChange:e=>m({...f,text:e.target.value}),className:`my-2 min-h-24 w-full rounded border border-edge bg-surface-inset p-2`}),(0,$.jsx)(J,{onClick:()=>void b(f,l),children:n?`保存到本机并同步`:`Save locally and sync`}),(0,$.jsx)(J,{onClick:()=>m(null),children:n?`取消`:`Cancel`})]}):null]})}var Ft={tab:`summary`,query:``,page:1,positionMs:0},It=m((e,t)=>({notes:{},update:(n,r)=>{let i={...Rt(n,t().notes[n]),...r};e(e=>({notes:{...e.notes,[n]:i}}));try{localStorage.setItem(`discussion-review:${n}`,JSON.stringify(i))}catch{}}})),Lt=new Map;function Rt(e,t){if(t)return t;if(Lt.has(e))return Lt.get(e);let n=Ft;try{let t=JSON.parse(localStorage.getItem(`discussion-review:${e}`)??`null`);t&&[`summary`,`transcript`,`marks`].includes(t.tab)&&typeof t.query==`string`&&Number.isSafeInteger(t.page)&&t.page>0&&t.page<=1e4&&Number.isFinite(t.positionMs)&&t.positionMs>=0&&(n={...Ft,...t})}catch{}return Lt.set(e,n),n}function zt(e){let t=(0,mt.c)(51),{initial:n,zh:r,busy:i,onClose:a,onSave:o}=e,[s,c]=(0,Q.useState)(n),l;t[0]!==i||t[1]!==a?(l=e=>{!e&&!i&&a()},t[0]=i,t[1]=a,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[3]=u):u=t[3];let d=r?`编辑纪要内容`:`Edit meeting content`,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`header`,{className:`border-b border-edge p-4`,children:(0,$.jsx)(S,{children:d})}),t[4]=d,t[5]=f);let p=r?`人工修改会保留,重新整理不会覆盖。已创建任务保持不变。`:`Your changes survive regeneration. Existing tasks remain unchanged.`,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[6]=p,t[7]=m);let h=r?`内容`:`Content`,_;t[8]===s?_=t[9]:(_=e=>c({...s,text:e.target.value}),t[8]=s,t[9]=_);let v;t[10]!==s.text||t[11]!==_?(v=(0,$.jsx)(`textarea`,{className:`mt-1 min-h-32 w-full rounded border border-edge bg-transparent p-2`,value:s.text,onChange:_}),t[10]=s.text,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==h||t[14]!==v?(y=(0,$.jsxs)(`label`,{className:`block text-sm`,children:[h,v]}),t[13]=h,t[14]=v,t[15]=y):y=t[15];let w;t[16]!==s||t[17]!==r?(w=s.kind===`actionItems`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`负责人原话`:`Owner as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.owner??``,onChange:e=>c({...s,owner:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[r?`期限原话`:`Date as stated`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-transparent p-2`,value:s.dueDate??``,onChange:e=>c({...s,dueDate:e.target.value})})]})]}):null,t[16]=s,t[17]=r,t[18]=w):w=t[18];let T;t[19]!==s||t[20]!==r?(T=s.kind===`summary`?null:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!s.ignored,onChange:e=>c({...s,ignored:e.target.checked})}),r?`忽略此项`:`Ignore this item`]}),t[19]=s,t[20]=r,t[21]=T):T=t[21];let E;t[22]!==y||t[23]!==w||t[24]!==T||t[25]!==m?(E=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[m,y,w,T]}),t[22]=y,t[23]=w,t[24]=T,t[25]=m,t[26]=E):E=t[26];let D=r?`取消`:`Cancel`,O;t[27]!==i||t[28]!==a||t[29]!==D?(O=(0,$.jsx)(J,{disabled:i,onClick:a,children:D}),t[27]=i,t[28]=a,t[29]=D,t[30]=O):O=t[30];let k;t[31]!==i||t[32]!==s.text?(k=i||!s.text.trim(),t[31]=i,t[32]=s.text,t[33]=k):k=t[33];let A;t[34]!==s||t[35]!==o?(A=()=>void o(s),t[34]=s,t[35]=o,t[36]=A):A=t[36];let j=r?`保存修改`:`Save changes`,M;t[37]!==k||t[38]!==A||t[39]!==j?(M=(0,$.jsx)(J,{variant:`primary`,disabled:k,onClick:A,children:j}),t[37]=k,t[38]=A,t[39]=j,t[40]=M):M=t[40];let N;t[41]!==O||t[42]!==M?(N=(0,$.jsxs)(`footer`,{className:`flex justify-end gap-2 border-t border-edge p-3`,children:[O,M]}),t[41]=O,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==E||t[45]!==N||t[46]!==f?(P=(0,$.jsxs)(b,{children:[u,(0,$.jsxs)(x,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(32rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[f,E,N]})]}),t[44]=E,t[45]=N,t[46]=f,t[47]=P):P=t[47];let F;return t[48]!==l||t[49]!==P?(F=(0,$.jsx)(C,{open:!0,onOpenChange:l,children:P}),t[48]=l,t[49]=P,t[50]=F):F=t[50],F}function Bt(e,t,n){if(t===`summary`){let r=e.organization;if(!r)return``;let i=r.organization;if(!i)return``;let a=e=>e.filter(e=>n.showIgnored||!e.ignored);return JSON.stringify({discussionId:e.discussion.id,view:t,revision:r.revision,transcriptRevision:r.transcriptRevision,summary:i.summary,decisions:a(i.decisions),actionItems:a(i.actionItems),risks:a(i.risks),openQuestions:a(i.openQuestions),chapters:i.chapters},null,2)}let r=n.query.toLocaleLowerCase(),i=e.transcript.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(r)||e.speakerLabel?.toLocaleLowerCase().includes(r)).slice(0,n.page*50);return i.length?JSON.stringify({discussionId:e.discussion.id,view:t,revision:e.transcript.revision,scope:`loaded filtered segments only`,segments:i.map(e=>({sequence:e.sequence,startedAtMs:e.startedAtMs,speaker:e.speakerLabel,text:e.displayText??e.rawText??``}))},null,2):``}var Vt=e=>`${String(Math.floor(e/6e4)).padStart(2,`0`)}:${String(Math.floor(e/1e3)%60).padStart(2,`0`)}`;function Ht({noteId:e,onPersonalNotes:t,onMeetingContent:n,personalNotes:r,personalNotesActive:i=!1,noteActions:a}){let c=o(),l=f(e=>e.language)===`zh`,{data:d,mutate:m,isLoading:h}=Ye([`note-discussion-document`,e],()=>E(e),{refreshInterval:e=>e&&([`recording`,`stopping`,`sealing`,`organizing`].includes(e.discussion.status)||e.recordingJob?.state===`queued`||e.recordingJob?.state===`running`)?3e3:0}),{detail:_,hasUpdates:v,publish:y}=jt(e,d),w=_?.discussion.id,k=`/api/discussions/${encodeURIComponent(w??``)}`,{data:j=[],mutate:N}=Ye(w?`${k}/actions`:null,e=>p(u(e)),{refreshInterval:1e4}),F=It(t=>Rt(e,t.notes[e])),I=It(e=>e.update),L=F.tab,R=t=>I(e,{tab:t}),z=F.query,B=t=>I(e,{query:t}),[ee,te]=(0,Q.useState)(!1),ne=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{ee&&ne.current?.focus()},[ee]);let[re,ie]=(0,Q.useState)(`general`),ae=(0,Q.useRef)(null),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),[V,le]=(0,Q.useState)(!1),[ue,de]=(0,Q.useState)(!1),fe=(0,Q.useRef)(!1),pe=(0,Q.useRef)(null),me=(0,Q.useRef)(null),[H,he]=(0,Q.useState)(null),[U,ge]=(0,Q.useState)(null),[_e,ve]=(0,Q.useState)(null),[ye,be]=(0,Q.useState)(!1),[xe,Se]=(0,Q.useState)([]),[Ce,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)(!1),De=F.page,Oe=t=>I(e,{page:t}),W=(0,Q.useRef)(null),[ke,Ae]=(0,Q.useState)([]),je=(0,Q.useRef)(0),Me=(0,Q.useRef)(0),Ne=(0,Q.useRef)(d?.transcript.revision);Ne.current=d?.transcript.revision;let Pe=(0,Q.useRef)(null),Fe=(0,Q.useRef)(d?.discussion.audioDeletedAt);Fe.current=d?.discussion.audioDeletedAt;let Ie=(0,Q.useRef)(null),[,Re]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let t=()=>{m(),N()},n=n=>{n.detail?.noteId===e&&t()};return window.addEventListener(`note-updated`,n),window.addEventListener(`discussion-updated`,t),window.addEventListener(`discussion-segment-updated`,t),()=>{window.removeEventListener(`note-updated`,n),window.removeEventListener(`discussion-updated`,t),window.removeEventListener(`discussion-segment-updated`,t)}},[m,N,e]),(0,Q.useEffect)(()=>{_?.discussion.template&&ie(_.discussion.template)},[_?.discussion.template]);async function ze(e){if(!Te){Ee(!0),we(null);try{await e();let t=await m();y(t),await N()}catch(e){we(e instanceof Error?e.message:String(e))}finally{Ee(!1)}}}function Ve(e,t){Pe.current&&(W.current=t??null,Pe.current.readyState===0?(Ie.current=e/1e3,Pe.current.load()):(Pe.current.currentTime=e/1e3,Pe.current.play().catch(()=>void 0)))}function Ue(){if(ce.current)return;let e=me.current??(document.activeElement instanceof HTMLElement?document.activeElement:null);ce.current={element:e,triggerIndex:Array.from(ae.current?.querySelectorAll(`button`)??[]).findIndex(t=>t===e),scrollTop:ae.current?.scrollTop??0,review:F}}function We(){Me.current++,le(!1),he(null),pe.current=ce.current?.element??null,ue||(ce.current=null)}function G(){let t=ce.current;if(!t)return;let{tab:n,query:r,page:i,anchor:a,anchorRevision:o}=t.review;I(e,{tab:n,query:r,page:i,anchor:a,anchorRevision:o}),Ae([]),he(null),de(!1),fe.current=!0}(0,Q.useLayoutEffect)(()=>{if(!H&&!V&&pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null),!fe.current)return;fe.current=!1;let e=ce.current;e&&ae.current&&(ae.current.scrollTop=e.scrollTop),(e?.element?.isConnected?e.element:e&&e.triggerIndex>=0?ae.current?.querySelectorAll(`button`)[e.triggerIndex]:null)?.focus({preventScroll:!0}),ce.current=null}),(0,Q.useEffect)(()=>{(H||V)&&se.current?.focus({preventScroll:!0})},[H,V]);function Ke(e){Ue();let t=e.stale||e.transcriptRevision!==Ne.current,n=Fe.current?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:e;he({...n,stale:t}),t||Ae(e.segments.map(e=>e.sequence))}async function K(e,t,n=!1){if(!_)return;let r=je.current,i=++Me.current;Ue(),le(!0),he(null),we(null);try{let a=await p(u(`${k}/evidence?revision=${t??_.organization?.transcriptRevision??_.transcript.revision}&segments=${e.join(`,`)}`));if(r!==je.current||i!==Me.current)return;if(Ke(a),n&&!Fe.current&&a.segments[0]?.playback[0]){let e=a.segments[0].playback[0];Ve(e.startedAtMs,e.endedAtMs)}}catch(e){r===je.current&&i===Me.current&&(we(e instanceof Error?e.message:String(e)),We())}finally{i===Me.current&&le(!1)}}async function Je(e){_&&await ze(async()=>{await A(_.discussion.clientRequestId,O({type:`transcript`,capturedAt:Date.now(),transcriptRevision:_.transcript.revision,segmentIds:[e.sequence]})),R(`marks`),M(_.discussion.clientRequestId,_.discussion.id).catch(e=>we(String(e)))})}(0,Q.useEffect)(()=>(je.current++,Me.current++,ce.current=null,de(!1),le(!1),he(null),Ae([]),ge(null),ve(null),Se([]),we(null),W.current=null,()=>{je.current++}),[e]),(0,Q.useEffect)(()=>{let t=_?.discussion.audioSha256??_?.discussion.audioAttachmentId;if(!t)return;let n=Rt(e,It.getState().notes[e]);n.source&&n.source!==t?(je.current++,Me.current++,le(!1),he(null),Ae([]),Pe.current?.pause(),I(e,{positionMs:0,source:t}),Ie.current=0,W.current=null):I(e,{source:t})},[e,_?.discussion.audioSha256,_?.discussion.audioAttachmentId,I]),(0,Q.useEffect)(()=>{_?.discussion.audioDeletedAt&&(Pe.current?.pause(),Ie.current=null,W.current=null,he(e=>e?{...e,audioAvailable:!1,timingVerified:!1,segments:e.segments.map(e=>({...e,playback:[]}))}:null))},[_?.discussion.audioDeletedAt]),(0,Q.useEffect)(()=>{F.tab===`transcript`&&F.anchor!==void 0&&F.anchorRevision===_?.transcript.revision&&window.setTimeout(()=>document.getElementById(`discussion-segment-${F.anchor}`)?.scrollIntoView?.({block:`center`}),0)},[F.tab,F.anchor,F.anchorRevision,_?.transcript.revision]),(0,Q.useEffect)(()=>{Ae([]),he(e=>e&&e.transcriptRevision!==d?.transcript.revision?{...e,stale:!0}:e)},[d?.transcript.revision]);let Xe=(e,t,n)=>t.some(e=>ye||!e.ignored)?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-fg`,children:e}),t.filter(e=>ye||!e.ignored).map(e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,$.jsxs)(`p`,{className:`flex-1 whitespace-pre-wrap`,children:[e.text,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?`有后续变更`:`Later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:Te||v,onClick:()=>ve({kind:n,itemId:e.id,text:e.text,ignored:e.ignored}),children:l?`编辑`:`Edit`}),e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:Te,className:`shrink-0 text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`原话`:`Source`}):(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?`暂无定位`:`No source timing`})]},e.id))]}):null;if(h)return(0,$.jsx)(q,{className:`h-48 w-full`});if(!_)return null;let{discussion:Y,transcript:Ze,organization:Qe}=_,X=Qe?.organization,$e=[`stopping`,`sealing`,`organizing`].includes(Y.status),et=!v&&[`recording`,`completed`,`needs_attention`].includes(Y.status),tt=Ze.segments.filter(e=>(e.displayText??e.rawText??``).toLocaleLowerCase().includes(z.toLocaleLowerCase())||e.speakerLabel?.toLocaleLowerCase().includes(z.toLocaleLowerCase())),nt=i?_.note.markdown:L===`marks`||z.trim()?``:Bt(_,L,{query:z,page:De,showIgnored:ye});return(0,$.jsxs)(`section`,{className:`@container/discussion relative flex h-full min-h-0 min-w-0 w-full flex-col text-fg`,onClickCapture:e=>{me.current=e.target instanceof Element?e.target.closest(`button`):null},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),te(!0))},children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-start gap-x-3 gap-y-1 px-5 pb-2 pt-5 sm:px-7`,children:[(0,$.jsxs)(`div`,{className:`min-w-40 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-2xl font-semibold leading-snug tracking-tight`,children:!_.note.title||/^Discussion · \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(_.note.title)?l?`语音笔记`:`Voice note`:_.note.title}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[l?`录音`:`Recording`,` · `,Vt(Y.durationMs??0)]})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":l?`搜索此 Note`:`Search this Note`,"aria-expanded":ee||!!z,onClick:()=>{te(e=>!e),ee&&B(``)},className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(He,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(Ot,{noteActions:a,detail:_,zh:l,busy:Te,processing:$e,pageText:nt,editing:!!_e||!!U})]}),(0,$.jsx)(`nav`,{"aria-label":l?`笔记内容`:`Note content`,className:`mx-5 mb-2 flex shrink-0 gap-6 border-b border-edge-subtle sm:mx-7`,children:[`summary`,`transcript`,`personal`].map(e=>{let r=e===`personal`?i:!i&&(e===`transcript`?L===`transcript`||L===`marks`:L===e);return(0,$.jsx)(`button`,{type:`button`,"aria-pressed":r,className:`min-h-11 border-b-2 px-1 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${r?`border-accent font-medium text-fg`:`border-transparent text-fg-muted hover:text-fg`}`,onClick:()=>{e===`personal`?(We(),t?.()):(n?.(),R(e))},children:e===`summary`?l?`纪要`:`Summary`:e===`personal`?l?`我的笔记`:`My notes`:l?`原文`:`Transcript`},e)})}),Ce?(0,$.jsxs)(`details`,{role:`alert`,className:`px-4 py-2 text-sm text-danger`,children:[(0,$.jsx)(`summary`,{children:l?`操作未完成,可以稍后重试`:`Action incomplete. Try again later`}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs text-fg-muted`,children:Ce})]}):null,!i&&(ee||z)?(0,$.jsxs)(`label`,{className:`mx-5 mb-2 flex shrink-0 items-center gap-2 rounded-xl bg-surface-inset px-3 sm:mx-7`,children:[(0,$.jsx)(He,{className:`size-4 text-fg-muted`}),(0,$.jsx)(`input`,{ref:ne,"aria-label":l?`搜索此 Note`:`Search this Note`,className:`min-h-11 min-w-0 w-full bg-transparent text-sm outline-none`,maxLength:200,placeholder:l?`搜索这篇笔记`:`Search this note`,value:z,onChange:e=>{B(e.target.value),Oe(1)}}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`关闭搜索`:`Close search`,onClick:()=>{B(``),te(!1)},children:(0,$.jsx)(qe,{className:`size-4`})})]}):null,ue?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-5 pb-2 text-xs text-fg-muted sm:px-7`,children:[(0,$.jsx)(`span`,{children:ce.current?.review.tab===`summary`?l?`正在查看结论依据`:`Viewing supporting transcript`:l?`正在查看原文依据`:`Viewing source transcript`}),(0,$.jsx)(J,{variant:`ghost`,onClick:G,children:ce.current?.review.tab===`summary`?l?`返回结论`:`Back to conclusion`:l?`返回阅读位置`:`Back to reading`})]}):null,(0,$.jsx)(`div`,{className:`relative z-10 h-0 shrink-0`,children:v?(0,$.jsx)(J,{className:`absolute right-5 top-2 border-edge bg-surface-overlay text-xs shadow-popover`,onClick:()=>y(),children:l?`内容已更新 · 查看最新`:`Updates available · View latest`}):null}),(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,$.jsxs)(`main`,{ref:ae,className:`min-h-0 min-w-0 flex-1 flex-col gap-5 overflow-y-auto px-5 pb-6 pt-1 sm:px-7 ${i||H||V?`hidden`:`flex`} ${!i&&(H||V)?`@min-[58rem]/discussion:flex`:``}`,children:[L===`summary`?(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[46rem] items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:l?`会议纪要`:`Meeting summary`}),(0,$.jsx)(kt,{detail:_,template:re,onTemplate:ie,zh:l,busy:Te,processing:$e,onOrganize:()=>void ze(()=>p(u(`${k}/organize`),{method:`POST`,body:JSON.stringify({template:re})})),onRegenerate:()=>void ze(()=>D(Y.id,`from_audio`))})]}):(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[46rem] gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,"aria-pressed":L===`transcript`,onClick:()=>R(`transcript`),children:l?`全部原文`:`All transcript`}),(0,$.jsx)(J,{variant:`ghost`,"aria-pressed":L===`marks`,onClick:()=>R(`marks`),children:l?`我的标记`:`My highlights`})]}),(Y.status!==`completed`||!X||Qe?.transcriptRevision!==Ze.revision)&&(Y.status!==`recording`||_.recordingJob)?(0,$.jsx)(T,{context:`note`,nextAttemptAt:_.processing?.nextAttemptAt,input:P(_),zh:l,busy:Te,onRetry:e=>void ze(()=>e===`analyze`?p(u(`${k}/organize`),{method:`POST`,body:JSON.stringify({template:re})}):D(Y.id,e===`regenerate`?`from_audio`:`resume`))}):null,(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem]`,hidden:!!z.trim(),children:L===`marks`?(0,$.jsx)(Pt,{recordingId:Y.clientRequestId,discussionId:Y.id,zh:l,onEvidence:Ke,onPlay:e=>Ve(e.startedAtMs,e.endedAtMs)},Y.id):L===`summary`?X?(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[46rem] space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:l?`摘要`:`Summary`}),(0,$.jsx)(`button`,{className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l?`编辑概要`:`Edit overview`,title:l?`编辑概要`:`Edit overview`,disabled:Te||$e||v,onClick:()=>ve({kind:`summary`,itemId:`summary`,text:X.summary}),children:(0,$.jsx)(Ge,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7`,children:X.summary}),X.summaryEditedByUser?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`已由你编辑`:`Edited by you`}):null,X.summaryEvidenceSegmentIds?.length?Array.from({length:Math.ceil(X.summaryEvidenceSegmentIds.length/100)},(e,t)=>(0,$.jsxs)(J,{onClick:()=>void K(X.summaryEvidenceSegmentIds.slice(t*100,(t+1)*100)),children:[l?`查看原话`:`View source`,X.summaryEvidenceSegmentIds.length>100?` · ${t+1}`:``]},t)):null,X.keyPointEvidence?.length?(0,$.jsxs)(`section`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{children:l?`重点结论`:`Key points`}),X.keyPointEvidence.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1`,children:e.text}),(0,$.jsx)(J,{onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`原话`:`Source`})]},e.id))]}):X.keyPoints.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:l?`重点结论`:`Key points`}),(0,$.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-[15px] leading-7`,children:X.keyPoints.map((e,t)=>(0,$.jsx)(`li`,{children:e},`${t}:${e}`))})]}):null,[...X.decisions,...X.actionItems,...X.risks,...X.openQuestions].some(e=>e.ignored)?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ye,onChange:e=>be(e.target.checked)}),l?`显示已忽略项`:`Show ignored items`]}):null,xe.length?(0,$.jsx)(J,{disabled:Te||v,onClick:()=>void ze(async()=>{for(let e of xe)await p(u(`${k}/actions/${encodeURIComponent(e)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Qe.revision})});Se([])}),children:l?`加入所选 ${xe.length} 项任务`:`Add ${xe.length} selected tasks`}):null,Xe(l?`已决定事项`:`Decisions`,X.decisions,`decisions`),X.actionItems.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:l?`下一步行动`:`Next actions`}),X.actionItems.filter(e=>ye||!e.ignored).map(e=>{let t=j.find(t=>t.actionId===e.id);return(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge-subtle p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!t&&!e.ignored&&(!(e.supersededBy||e.disputedBy)||e.reviewedChangeId===(e.supersededBy??e.disputedBy))?(0,$.jsx)(`input`,{type:`checkbox`,"aria-label":`${l?`选择行动`:`Select action`}: ${e.title}`,className:`ui-checkbox`,checked:xe.includes(e.id),onChange:t=>Se(t.target.checked?[...xe,e.id]:xe.filter(t=>t!==e.id))}):null,(0,$.jsxs)(`p`,{className:`flex-1 text-sm font-medium`,children:[e.title,e.supersededBy||e.disputedBy?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?`有后续变更,请复核`:`Review later changes`}):null,e.editedByUser?(0,$.jsx)(`span`,{className:`ml-2 text-xs text-fg-muted`,children:l?e.ignored?`已忽略`:`人工编辑`:e.ignored?`Ignored`:`Edited`}):null]}),(0,$.jsx)(`button`,{className:`text-xs text-fg-muted`,disabled:Te||$e||v,onClick:()=>ve({kind:`actionItems`,itemId:e.id,text:e.title,owner:e.owner,dueDate:e.dueDate,ignored:e.ignored}),children:l?`编辑`:`Edit`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e.owner??(l?`负责人未明确`:`Owner unspecified`),` · `,e.dueDate??(l?`期限未明确`:`Date unspecified`)]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-xs`,children:[e.evidenceSegmentIds.length?(0,$.jsx)(`button`,{disabled:Te,className:`text-accent-fg`,onClick:()=>void K(e.evidenceSegmentIds,e.evidenceRevision),children:l?`查看原话`:`Source`}):null,t?t.deleted?(0,$.jsx)(`span`,{children:l?`关联任务已删除`:`Linked task deleted`}):(0,$.jsx)(s,{className:`text-accent-fg`,to:Le(`${c.pathname}${c.search}`,t.taskId),children:t.resolution===`done`?l?`已完成 · 查看任务`:`Done · View task`:l?`查看任务 / 交给助手`:`View task / Delegate`}):e.ignored?null:(0,$.jsx)(J,{disabled:Te||v||!!(e.supersededBy||e.disputedBy)&&e.reviewedChangeId!==(e.supersededBy??e.disputedBy),onClick:()=>void ze(()=>p(u(`${k}/actions/${encodeURIComponent(e.id)}/convert`),{method:`POST`,body:JSON.stringify({organizationRevision:Qe.revision})})),children:l?`加入我的任务`:`Add to my tasks`})]})]},e.id)})]}):null,Xe(l?`风险`:`Risks`,X.risks,`risks`),Xe(l?`尚未确定`:`Open questions`,X.openQuestions,`openQuestions`),X.changes?.length?(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:l?`前后变更`:`Changes during the meeting`}),X.changes.map(e=>{let t=[...X.decisions,...X.actionItems,...X.risks,...X.openQuestions],n=t.find(t=>t.id===e.fromId),r=t.find(t=>t.id===e.toId);return!n||!r?null:(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.relation===`supersedes`?l?`后续撤销或替代`:`Later superseded`:l?`存在冲突,尚未明确解决`:`Unresolved conflict`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(n.evidenceSegmentIds,n.evidenceRevision),children:`title`in n?n.title:n.text}),(0,$.jsx)(`span`,{children:`↓`}),(0,$.jsx)(`button`,{className:`block text-left text-accent-fg`,onClick:()=>void K(r.evidenceSegmentIds,r.evidenceRevision),children:`title`in r?r.title:r.text})]},`${e.fromId}:${e.toId}`)})]}):null]}):(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[46rem] space-y-4 py-3`,children:[(0,$.jsx)(`h3`,{className:`text-base font-medium`,children:Ze.text?l?`录音摘录`:`From your recording`:Y.status===`needs_attention`?l?`纪要暂未生成`:`Summary unavailable`:l?`笔记正在整理`:`Preparing your note`}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[15px] leading-7 ${Ze.text?`text-fg`:`text-fg-muted`}`,children:Ze.text?Ze.text.slice(0,400)+(Ze.text.length>400?`…`:``):l?`文字整理完成后,重点和行动会出现在这里。`:`Highlights and actions will appear as processing completes.`}),Ze.text?(0,$.jsx)(J,{className:`min-h-11`,onClick:()=>R(`transcript`),children:l?`查看原文`:`Read transcript`}):null]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[tt.slice(0,De*50).map(e=>(0,$.jsxs)(`article`,{id:`discussion-segment-${e.sequence}`,className:`rounded-md border p-3 ${ke.includes(e.sequence)||F.anchor===e.sequence&&F.anchorRevision===Ze.revision?`border-accent`:`border-edge-subtle`}`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 text-xs text-fg-muted`,children:[(0,$.jsxs)(`button`,{className:`inline-flex items-center gap-1 text-accent-fg`,disabled:!Y.audioAttachmentId||!!Y.audioDeletedAt,onClick:()=>void K([e.sequence],Ze.revision,!0),children:[(0,$.jsx)(Be,{className:`size-3`}),Vt(e.startedAtMs)]}),e.status===`confirmed`&&!v?(0,$.jsx)(`button`,{onClick:()=>void Je(e),children:l?`标记此段`:`Highlight segment`}):null,(0,$.jsx)(`span`,{children:e.speakerLabel??(l?`未区分说话人`:`Speaker unknown`)}),et&&e.status===`confirmed`?(0,$.jsx)(`button`,{className:`ml-auto`,onClick:()=>ge({segment:e,text:e.displayText??e.rawText??``,speaker:e.speakerLabel??``}),children:l?`校对`:`Edit`}):null]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6`,children:e.displayText??e.rawText??(l?`等待转写`:`Awaiting transcription`)})]},e.sequence)),tt.length>De*50?(0,$.jsx)(J,{onClick:()=>Oe(De+1),children:l?`加载更多`:`More`}):null]})}),(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[46rem]`,children:(0,$.jsx)(Nt,{id:Y.id,query:z.trim(),zh:l,sourceKey:`${Y.audioSha256}:${Y.audioDeletedAt}`,active:$e||Y.status===`recording`,tab:L,refreshKey:`${Y.updatedAt}:${Ze.revision}:${Qe?.revision}`,onEvidence:Ke,onPlay:Ve},Y.id)})]}),(0,$.jsx)(`div`,{className:i?`min-h-0 min-w-0 flex-1 overflow-hidden`:`hidden`,children:r}),H||V?(0,$.jsxs)(`aside`,{ref:se,tabIndex:-1,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),We())},"aria-label":l?`原话证据`:`Source evidence`,className:`flex min-h-0 w-full min-w-0 flex-col border-edge bg-surface-panel outline-none @min-[58rem]/discussion:w-[22rem] @min-[58rem]/discussion:shrink-0 @min-[58rem]/discussion:border-l`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,$.jsxs)(`h3`,{children:[l?`原话证据`:`Source evidence`,` `,H?`· v${H.transcriptRevision}`:``]}),(0,$.jsx)(`button`,{"aria-label":l?`关闭`:`Close`,className:`inline-flex size-11 items-center justify-center rounded-lg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:We,children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[V?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3`,children:[(0,$.jsx)(q,{className:`h-4 w-1/3`}),(0,$.jsx)(q,{className:`h-24 w-full`})]}):null,H?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`按整段定位,不代表词句级时间。`:`Segment timing; not word-level alignment.`}),H.stale?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`原文已更新,以下保留当时版本的依据。`:`Transcript updated; showing the original evidence revision.`}):null,!H.audioAvailable||!H.timingVerified?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l?`原文仍可查看;原音不可用或时间定位待核实。`:`Text remains available; audio is missing or timing is unverified.`}):null,H.segments.map(t=>(0,$.jsxs)(`article`,{className:`space-y-2 rounded border border-edge p-3`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Vt(t.startedAtMs),`–`,Vt(t.endedAtMs),` · `,t.speakerLabel??(l?`说话人未明确`:`Unknown speaker`)]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-7`,children:t.text}),t.playback.map((e,t)=>(0,$.jsxs)(J,{onClick:()=>Ve(e.startedAtMs,e.endedAtMs),children:[l?`播放原话`:`Play source`,` `,Vt(e.startedAtMs),`–`,Vt(e.endedAtMs)]},t)),!H.stale&&H.transcriptRevision===d?.transcript.revision&&H.transcriptRevision!==Ze.revision?(0,$.jsx)(J,{onClick:()=>y(),children:l?`查看最新原文`:`View latest transcript`}):null,!H.stale&&H.transcriptRevision===d?.transcript.revision&&H.transcriptRevision===Ze.revision?(0,$.jsx)(J,{onClick:()=>{B(``),Oe(Math.max(De,Math.ceil((Ze.segments.findIndex(e=>e.sequence===t.sequence)+1)/50))),R(`transcript`),Ae([t.sequence]),he(null),de(!0),I(e,{anchor:t.sequence,anchorRevision:Ze.revision}),window.setTimeout(()=>document.getElementById(`discussion-segment-${t.sequence}`)?.scrollIntoView?.({block:`center`}),0)},children:l?`定位原文`:`Locate transcript`}):null]},t.sequence))]}):null]})]}):null]}),Y.audioAttachmentId&&!Y.audioDeletedAt?(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)(`audio`,{ref:Pe,controls:!0,preload:`metadata`,className:`h-10 w-full`,src:u(`${k}/audio`),onTimeUpdate:()=>{let t=(Pe.current?.currentTime??0)*1e3;Re(t),I(e,{positionMs:t}),W.current!==null&&t>=W.current&&(Pe.current?.pause(),W.current=null)},onLoadedMetadata:()=>{Ie.current!==null&&Pe.current?(Pe.current.currentTime=Ie.current,Ie.current=null,Pe.current.play().catch(()=>void 0)):Pe.current&&(Pe.current.currentTime=F.positionMs/1e3)},onError:()=>we(l?`录音暂不可播放`:`Recording unavailable`)})}):null,_e&&Qe?(0,$.jsx)(zt,{initial:_e,zh:l,busy:Te,onClose:()=>ve(null),onSave:e=>ze(async()=>{await p(u(`${k}/summary`),{method:`PATCH`,body:JSON.stringify({...e,expectedRevision:Qe.revision})}),ve(null)})},`${_e.kind}:${_e.itemId}:${Qe.revision}`):null,U?(0,$.jsx)(C,{open:!0,onOpenChange:e=>{e||ge(null)},children:(0,$.jsxs)(b,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(x,{"aria-describedby":void 0,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(28rem,90dvh)] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between border-b border-edge p-4`,children:[(0,$.jsx)(S,{children:l?`校对逐字稿`:`Edit transcript`}),(0,$.jsx)(`button`,{"aria-label":l?`关闭校对`:`Close editor`,onClick:()=>ge(null),children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,children:[(0,$.jsxs)(`label`,{className:`block text-xs`,children:[l?`本段说话人`:`Speaker for this segment`,(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:U.speaker,onChange:e=>ge({...U,speaker:e.target.value})})]}),U.segment.speakerLabel?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!U.applyToSpeakerGroup,onChange:e=>ge({...U,applyToSpeakerGroup:e.target.checked})}),l?`同时更名所有同标签片段;输入已有标签可合并说话人`:`Rename all segments with this label; use an existing label to merge speakers`]}):null,(0,$.jsx)(`textarea`,{className:`min-h-32 w-full rounded border border-edge bg-surface-inset p-2 text-sm`,value:U.text,onChange:e=>ge({...U,text:e.target.value})})]}),(0,$.jsx)(`footer`,{className:`border-t border-edge p-3`,children:(0,$.jsxs)(J,{variant:`primary`,disabled:Te||!U.text.trim(),onClick:()=>void ze(async()=>{await p(u(`${k}/segments/${U.segment.sequence}`),{method:`PATCH`,body:JSON.stringify({displayText:U.text,speakerLabel:U.speaker,expectedRevision:U.segment.revision,applyToSpeakerGroup:U.applyToSpeakerGroup,expectedTranscriptRevision:Ze.revision})}),ge(null)}),children:[(0,$.jsx)(oe,{className:`size-4`}),l?`保存修订`:`Save revision`]})})]})]})}):null]})}var Ut={edit:ze,ai_edit:We,sync:Ve,restore:w};function Wt(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=f(e=>e.language),o=h(a).notes,s={justNow:o.justNow,minutesAgo:o.minutesAgo,today:o.today,yesterday:o.yesterday,daysAgo:o.daysAgo,locale:l(a)},{data:c}=Ye(e?[`note-history`,e]:null,()=>De(e)),[u,d]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=(0,Q.useCallback)(async t=>{d(!0),_(null);try{await Se(e,t),m(null),i()}catch{_(o.restoreFailed)}finally{d(!1)}},[e,o.restoreSuccess,o.restoreFailed,i]),y=Date.now();return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(U,{className:`size-4`,"aria-hidden":!0}),o.history]}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg p-1 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(qe,{className:`size-4`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[g?(0,$.jsx)(`p`,{className:`border-b border-danger/20 bg-danger-soft px-4 py-2 text-xs text-danger`,role:`alert`,children:g}):null,c?.length?(0,$.jsx)(`ul`,{className:`divide-y divide-edge`,children:c.map(e=>{let r=Ut[e.trigger]??ze,i=t===e.timestamp,a=p===e.timestamp;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:K(`w-full px-4 py-3 text-left transition-colors`,i?`bg-accent/10`:`hover:bg-surface-hover`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:Wt(e.trigger,o)}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:yt(e.timestamp,y,s)})]}),e.snippet&&(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted/60`,children:e.snippet})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-edge/50 px-4 py-2`,children:a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs text-fg-muted`,children:o.restoreConfirm}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),v(e.timestamp)},disabled:u,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:u?`...`:o.restore}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m(null)},className:`shrink-0 rounded-lg px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover`,children:`Cancel`})]}):(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),m(e.timestamp)},className:`rounded-lg bg-surface-hover px-3 py-1 text-xs font-medium text-fg transition-colors hover:bg-accent hover:text-on-accent`,children:o.restore})})]},e.timestamp)})}):(0,$.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:o.historyEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted/60`,children:o.historyEmptyDescription})]})]})]})}function Kt({noteId:e,note:t,catalyzing:n,onCatalyze:r,onClose:i,noteThreads:a,openingChat:o,onOpenChat:s,onOpenNewChat:l}){let u=h(f(e=>e.language)).notes,d=c(),p=t?.aiDeep?.catalysis,m=p?.report??null,[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),{data:b,mutate:x,isLoading:S}=Ye(e?[`note-agent-context-status`,e]:null,()=>W(e),{revalidateOnFocus:!1}),C=(0,Q.useCallback)(async()=>{if(!v){y(!0),_(null);try{await x(()=>Fe(e),{revalidate:!1})}catch(e){_(`${u.contextRebuildFailed}: ${e instanceof Error?e.message:u.quickCaptureFailedHint}`)}finally{y(!1)}}},[v,x,u.contextRebuildFailed,u.quickCaptureFailedHint,e]),w=(0,Q.useCallback)(async t=>{try{await xe(e,t)}catch{}},[e]);return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(We,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:u.catalysisSectionTitle})]}),(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":u.lightboxClose,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:(0,$.jsx)(F,{className:`size-4 rotate-180`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-xs leading-relaxed text-fg-muted`,children:u.catalysisSectionDescription}),b?(0,$.jsxs)(`section`,{className:`mb-4 rounded-xl bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.contextStatusTitle}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:S||v,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:v?u.processing:u.contextRebuild}),(0,$.jsx)(`span`,{className:K(`rounded-full px-2 py-0.5 text-[11px] font-medium`,b.status===`ready`?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-300`:b.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:b.status})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:u.contextStatusDetail.replace(`{{attachments}}`,String(b.attachments.length)).replace(`{{tokens}}`,String(b.tokenEstimate??0))}),g?(0,$.jsx)(`p`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:g}):null,b.attachments.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-1.5`,children:b.attachments.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg bg-surface-hover px-2 py-1.5 text-xs`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.status})]},e.attachmentId))}):null]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`w-full rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:n?u.processing:m?u.recatalyze:u.catalyzeAction}),m?(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.valueHypothesis}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg`,children:m.valueHypothesis})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.targetUsers}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:m.targetUsers.slice(0,5).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg`,children:e},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.keyQuestions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.keyQuestions.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.mvpPathLabel}),(0,$.jsx)(`ol`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.mvpPath.slice(0,3).map((e,t)=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[t+1,`.`]}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.risks}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.risks.slice(0,3).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-fg-muted`}),(0,$.jsx)(`span`,{children:e})]},e))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:u.nextActions}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm leading-relaxed text-fg`,children:m.nextActions.slice(0,4).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`rounded bg-accent/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-accent`,children:e.kind}),(0,$.jsx)(`span`,{children:e.text})]},`${e.kind}:${e.text}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:u.confidenceLabel.replace(`{{percent}}`,String(Math.round(m.confidence*100)))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`helpful`),className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackHelpfulAria,children:(0,$.jsx)(B,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void w(`not_helpful`),className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p?.feedback===`not_helpful`&&`bg-accent/10 text-accent`),"aria-label":u.feedbackNotHelpfulAria,children:(0,$.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0})})]})]})]}):(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-dashed border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:u.noCatalysisReportHint}),(0,$.jsxs)(`section`,{className:`mt-6 rounded-xl bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Re,{className:`size-4 text-accent`,"aria-hidden":!0}),u.relatedThreadsTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.relatedThreadsDescription})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:s,disabled:o,className:`rounded-lg border border-edge px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`,children:o?u.openingChat:u.openThread}),(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:o,className:`rounded-lg bg-accent px-2.5 py-1.5 text-xs font-medium text-on-accent transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50`,children:u.newThread})]})]}),a.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:a.slice(0,5).map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(`/chat/${encodeURIComponent(e.key)}`),className:`w-full rounded-lg border border-edge-subtle px-3 py-2 text-left transition-colors hover:bg-surface-hover`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.name||u.noteDiscussionFallback}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:u.messageCount.replace(`{{count}}`,String(e.messageCount??0))})]},e.key))}):(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-5 text-center text-sm text-fg-muted`,children:u.noThreads})]})]})]})}var qt=[{value:`86400000`,zh:`24 小时`,en:`24 hours`},{value:`604800000`,zh:`7 天`,en:`7 days`},{value:`2592000000`,zh:`30 天`,en:`30 days`}];function Jt({open:e,onOpenChange:t,note:n}){let r=f(e=>e.language)===`zh`,i=r?Qt:$t,{data:a,mutate:o}=Ye(e?[`note-shares`,n.id]:null,()=>ke(n.id)),s=Ye(e?`hosted-share-auth-status`:null,tt),c=s.data===!0,l=Ye(e&&c?`hosted-publication-capabilities`:null,rt),u=l.data?.publishing.allowed===!0,d=Ye(e&&c?[`hosted-note-publications`,n.id]:null,()=>Ee(n.id)),[p,m]=(0,Q.useState)(new Set),[h,_]=(0,Q.useState)(`86400000`),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)(`hosted`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),ee=(0,Q.useMemo)(()=>{let e=new Set;return n.markdown.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^\s)]+)/gi,(t,r,i)=>{try{decodeURIComponent(r)===n.id&&e.add(decodeURIComponent(i))}catch{}return t}),(n.attachments??[]).filter(t=>e.has(t.id))},[n.attachments,n.id,n.markdown]);(0,Q.useEffect)(()=>{e&&(m(new Set(ee.map(e=>e.id))),F(null),L(!1),B(null))},[e,ee]);let te=async()=>{j(!0),B(null);try{let e={expectedNoteVersion:n.updatedAt,attachmentIds:[...p],ttlMs:Number(h),maxViews:w.trim()?Number(w):null,description:E.trim()||void 0};if(O===`hosted`){let t=await je(n.id,e);F(t.shareUrl),await d.mutate()}else{let t=await we(n.id,e);F(t.payload.shareUrl),await o()}}catch(e){B(e instanceof Error?e.message:String(e))}finally{j(!1)}},ne=async(e,t)=>{N(e.id),B(null);try{t===`refresh`?await ge(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):await it(e.id),await d.mutate()}catch(e){B(e instanceof Error?e.message:String(e))}finally{N(null)}},re=async(e,t)=>{N(e.id),B(null);try{t===`refresh`?await Pe(n.id,e.id,{expectedNoteVersion:n.updatedAt,attachmentIds:[...p]}):t===`extend`?await nt(e.id,864e5):await et(e.id),await o()}catch(e){B(e instanceof Error?e.message:String(e))}finally{N(null)}},ie=async e=>{B(null);try{if(!await Xe(e)){L(!1),B(i.copyFailed);return}L(!0),window.setTimeout(()=>L(!1),1500)}catch{L(!1),B(i.copyFailed)}};return(0,$.jsx)(C,{open:e,onOpenChange:t,children:(0,$.jsxs)(b,{children:[(0,$.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(x,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(S,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,$.jsx)(R,{className:`size-4`}),i.title]}),(0,$.jsx)(v,{className:`mt-1 text-xs text-fg-muted`,children:i.description})]}),(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":i.close,children:(0,$.jsx)(qe,{className:`size-4`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-inset p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.title||i.untitled}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-4 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,children:n.markdown||i.empty}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:i.privateExcluded})]}),ee.length>0?(0,$.jsxs)(`section`,{className:`mt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.attachments}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:ee.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:p.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,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Zt(e.size)})]},e.id))})]}):null,(0,$.jsxs)(`section`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.delivery,(0,$.jsxs)(ce,{value:O,onChange:e=>k(e.target.value),children:[(0,$.jsx)(V,{value:`hosted`,children:i.deliveryHosted}),(0,$.jsx)(V,{value:`local`,children:i.deliveryLocal})]})]}),O===`hosted`&&s.data===!1?(0,$.jsx)(`div`,{className:`sm:col-span-2`,children:(0,$.jsx)(Z,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:()=>void s.mutate(!0,{revalidate:!1})})}):null,O===`hosted`&&c&&l.data&&!u?(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning sm:col-span-2`,children:i.hostedDisabled}):null,(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.expires,(0,$.jsx)(ce,{value:h,onChange:e=>_(e.target.value),children:qt.map(e=>(0,$.jsx)(V,{value:e.value,children:r?e.zh:e.en},e.value))})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[i.maxViews,(0,$.jsx)(`input`,{type:`number`,min:1,max:1e3,value:w,onChange:e=>T(e.target.value),placeholder:i.unlimited,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted sm:col-span-2`,children:[i.publicDescription,(0,$.jsx)(`input`,{value:E,onChange:e=>D(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`})]})]}),P?(0,$.jsx)(`div`,{className:`mt-5 rounded-lg border border-success/25 bg-success-soft p-3`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`input`,{readOnly:!0,value:P,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,$.jsxs)(J,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void ie(P),children:[I?(0,$.jsx)(oe,{className:`size-4`}):(0,$.jsx)(de,{className:`size-4`}),I?i.copied:i.copy]}),(0,$.jsxs)(J,{type:`button`,className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>window.open(P,`_blank`,`noopener,noreferrer`),children:[(0,$.jsx)(me,{className:`size-4`}),i.open]})]})}):null,z?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,children:z}):null,(a?.items.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.activeLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:a.items.map(e=>(0,$.jsx)(Xt,{share:e,busy:M===e.id,t:i,onCopy:ie,onAction:re},e.id))})]}):null,(d.data?.length??0)>0?(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.hostedLinks}),(0,$.jsx)(`div`,{className:`mt-2 grid gap-2`,children:d.data.map(e=>(0,$.jsx)(Yt,{publication:e,stale:e.source?.version!==String(n.updatedAt),busy:M===e.id,publishingAllowed:u,t:i,onCopy:ie,onAction:ne},e.id))})]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-3`,children:[(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,children:i.close})}),(0,$.jsxs)(J,{type:`button`,onClick:()=>void te(),disabled:A||O===`hosted`&&(!c||!u),children:[A?(0,$.jsx)(Ie,{className:`size-4 animate-spin`}):(0,$.jsx)(R,{className:`size-4`}),A?i.creating:i.create]})]})]})]})})}function Yt(e){let t=(0,mt.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=K(`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,$.jsx)(`span`,{children:f}),t[2]=f,t[3]=p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.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,$.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 _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{children:`·`}),t[9]=_):_=t[9];let v;t[10]!==n.revision||t[11]!==o.revision?(v=(0,$.jsxs)(`span`,{children:[o.revision,` `,n.revision]}),t[10]=n.revision,t[11]=o.revision,t[12]=v):v=t[12];let y;t[13]!==p||t[14]!==g||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,g,_,v]}),t[13]=p,t[14]=g,t[15]=v,t[16]=y):y=t[16];let b;t[17]===n.shareUrl?b=t[18]:(b=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[17]=n.shareUrl,t[18]=b);let x;t[19]!==y||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;t[22]===i?S=t[23]:(S=i?(0,$.jsx)(Ie,{className:`size-4 animate-spin text-fg-muted`}):null,t[22]=i,t[23]=S);let C;t[24]!==x||t[25]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[x,S]}),t[24]=x,t[25]=S,t[26]=C):C=t[26];let w=!a,T;t[27]!==s||t[28]!==n.shareUrl?(T=()=>void s(n.shareUrl),t[27]=s,t[28]=n.shareUrl,t[29]=T):T=t[29];let E;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(de,{className:`size-3.5`}),t[30]=E):E=t[30];let D;t[31]!==o.copy||t[32]!==w||t[33]!==T?(D=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:w,onClick:T,children:[E,o.copy]}),t[31]=o.copy,t[32]=w,t[33]=T,t[34]=D):D=t[34];let O=!a,k;t[35]===n.shareUrl?k=t[36]:(k=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=k);let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(me,{className:`size-3.5`}),t[37]=A):A=t[37];let j;t[38]!==o.open||t[39]!==O||t[40]!==k?(j=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:O,onClick:k,children:[A,o.open]}),t[38]=o.open,t[39]=O,t[40]=k,t[41]=j):j=t[41];let M;t[42]!==i||t[43]!==l||t[44]!==c||t[45]!==n||t[46]!==a||t[47]!==r||t[48]!==o.refresh?(M=r&&!l?(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i||!a,onClick:()=>void c(n,`refresh`),children:[(0,$.jsx)(Ve,{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]=M):M=t[49];let N;t[50]!==i||t[51]!==c||t[52]!==n||t[53]!==o.revoke?(N=n.revoked?null:(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:i,onClick:()=>void c(n,`revoke`),children:[(0,$.jsx)(Ke,{className:`size-3.5`}),o.revoke]}),t[50]=i,t[51]=c,t[52]=n,t[53]=o.revoke,t[54]=N):N=t[54];let P;t[55]!==D||t[56]!==j||t[57]!==M||t[58]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[D,j,M,N]}),t[55]=D,t[56]=j,t[57]=M,t[58]=N,t[59]=P):P=t[59];let F;return t[60]!==C||t[61]!==d||t[62]!==P?(F=(0,$.jsxs)(`div`,{className:d,children:[C,P]}),t[60]=C,t[61]=d,t[62]=P,t[63]=F):F=t[63],F}function Xt(e){let t=(0,mt.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=K(`rounded-lg border border-edge-subtle p-3`,c),t[0]=c,t[1]=l);let u=n.stale&&!s?i.stale:s?i.inactive:i.active,d;t[2]===u?d=t[3]:(d=(0,$.jsx)(`span`,{children:u}),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`span`,{children:`·`}),t[4]=f):f=t[4];let p=n.maxViews===null?``:` / ${n.maxViews}`,m;t[5]!==n.viewCount||t[6]!==i.views||t[7]!==p?(m=(0,$.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,$.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 _;t[12]===g?_=t[13]:(_=(0,$.jsx)(`span`,{children:g}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==d||t[16]!==m?(v=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[d,f,m,h,_]}),t[14]=_,t[15]=d,t[16]=m,t[17]=v):v=t[17];let y;t[18]===n.shareUrl?y=t[19]:(y=(0,$.jsx)(`div`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.shareUrl}),t[18]=n.shareUrl,t[19]=y);let b;t[20]!==v||t[21]!==y?(b=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,y]}),t[20]=v,t[21]=y,t[22]=b):b=t[22];let x;t[23]===r?x=t[24]:(x=r?(0,$.jsx)(Ie,{className:`size-4 animate-spin text-fg-muted`}):null,t[23]=r,t[24]=x);let S;t[25]!==b||t[26]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,x]}),t[25]=b,t[26]=x,t[27]=S):S=t[27];let C;t[28]!==a||t[29]!==n.shareUrl?(C=()=>void a(n.shareUrl),t[28]=a,t[29]=n.shareUrl,t[30]=C):C=t[30];let w;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(de,{className:`size-3.5`}),t[31]=w):w=t[31];let T;t[32]!==i.copy||t[33]!==C?(T=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:C,children:[w,i.copy]}),t[32]=i.copy,t[33]=C,t[34]=T):T=t[34];let E;t[35]===n.shareUrl?E=t[36]:(E=()=>window.open(n.shareUrl,`_blank`,`noopener,noreferrer`),t[35]=n.shareUrl,t[36]=E);let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(me,{className:`size-3.5`}),t[37]=D):D=t[37];let O;t[38]!==i.open||t[39]!==E?(O=(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:E,children:[D,i.open]}),t[38]=i.open,t[39]=E,t[40]=O):O=t[40];let k;t[41]!==r||t[42]!==s||t[43]!==o||t[44]!==n||t[45]!==i.refresh?(k=n.stale&&!s?(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`refresh`),children:[(0,$.jsx)(Ve,{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]=k):k=t[46];let A;t[47]!==r||t[48]!==s||t[49]!==o||t[50]!==n||t[51]!==i.extend?(A=s?null:(0,$.jsx)(J,{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]=A):A=t[52];let j;t[53]!==r||t[54]!==o||t[55]!==n||t[56]!==i.revoke?(j=n.revoked?null:(0,$.jsxs)(J,{className:`px-2 py-1 text-xs`,variant:`ghost`,disabled:r,onClick:()=>void o(n,`revoke`),children:[(0,$.jsx)(Ke,{className:`size-3.5`}),i.revoke]}),t[53]=r,t[54]=o,t[55]=n,t[56]=i.revoke,t[57]=j):j=t[57];let M;t[58]!==T||t[59]!==O||t[60]!==k||t[61]!==A||t[62]!==j?(M=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[T,O,k,A,j]}),t[58]=T,t[59]=O,t[60]=k,t[61]=A,t[62]=j,t[63]=M):M=t[63];let N;return t[64]!==S||t[65]!==l||t[66]!==M?(N=(0,$.jsxs)(`div`,{className:l,children:[S,M]}),t[64]=S,t[65]=l,t[66]=M,t[67]=N):N=t[67],N}function Zt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var Qt={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:`撤销`},$t={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`},en=e(n(),1);function tn({noteId:e,selection:t,zh:n,onDismiss:r,onAsk:i}){let[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(``),[f,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),[_,v]=(0,Q.useState)({left:8,top:8}),y=s||a!==null||!!l,b=t.text.length>16e3;function x(){h.current?.abort(),r(),t.restore()}(0,Q.useEffect)(()=>{o(null),c(!1),d(``),m(!1);let e=e=>{g.current?.contains(e.target)||r()},n=e=>{e.key===`Escape`&&(e.preventDefault(),r(),t.restore())},i=e=>{!g.current?.contains(e.target)&&!h.current&&!g.current?.contains(document.activeElement)&&r()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,n),window.addEventListener(`resize`,r),window.addEventListener(`scroll`,i,!0),()=>{h.current?.abort(),h.current=null,document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,r),window.removeEventListener(`scroll`,i,!0)}},[t,r]),(0,Q.useLayoutEffect)(()=>{let e=g.current?.getBoundingClientRect();if(!e)return;let n=Math.max(8,Math.min(t.rect.left,window.innerWidth-e.width-8)),r=t.rect.bottom+8,i=r+e.height<=window.innerHeight-8?r:Math.max(8,t.rect.top-e.height-8);v({left:n,top:i})},[t,y,a,l]);async function S(r){h.current?.abort();let i=new AbortController;h.current=i,c(!0),d(``),o(null),m(!1);try{let a=await p(u(`/api/notes/${encodeURIComponent(e)}/ai/edit`),{method:`POST`,signal:i.signal,body:JSON.stringify({instruction:r,markdown:t.text})});if(i.signal.aborted)return;let s=a.patch.operations.filter(e=>e.type===`replaceRange`).map(e=>e.markdown??``).join(`
3
3
 
4
4
  `);if(!s.trim())throw Error(n?`没有可用结果,请重试。`:`No result available. Try again.`);o(s)}catch(e){i.signal.aborted||d(e instanceof Error?e.message:String(e))}finally{i.signal.aborted||(c(!1),h.current=null)}}return(0,en.createPortal)((0,$.jsxs)(`div`,{ref:g,role:`region`,"data-note-selection-actions":!0,"aria-keyshortcuts":`Alt+Enter`,"aria-label":n?`笔记选段操作`:`Note selection actions`,className:`fixed z-[80] flex max-h-[calc(100dvh-1rem)] max-w-[calc(100vw-1rem)] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg shadow-popover ${y?`w-96`:``}`,style:_,onPointerDown:e=>{e.target.closest(`button`)&&e.preventDefault()},children:[(0,$.jsxs)(`div`,{role:`group`,"aria-label":n?`选段操作`:`Selection actions`,className:`flex shrink-0 flex-wrap items-center gap-1 p-1`,children:[(0,$.jsx)(J,{variant:`ghost`,className:`text-xs`,disabled:s||b,onClick:()=>void S(`summary`),children:n?`摘要预览`:`Summary`}),(0,$.jsx)(J,{variant:`ghost`,className:`text-xs`,disabled:s||b,onClick:()=>void S(`todo`),children:n?`提取待办`:`Extract to-dos`}),(0,$.jsx)(J,{variant:`ghost`,className:`text-xs`,disabled:s||b,onClick:()=>i(t.text),children:n?`引用提问`:`Ask about selection`}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 items-center justify-center rounded-lg hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭选段操作`:`Close selection actions`,onClick:x,children:(0,$.jsx)(qe,{className:`size-4`})})]}),b?(0,$.jsx)(`p`,{className:`px-3 pb-3 text-xs text-fg-muted`,children:n?`请选择不超过 16000 字的片段。`:`Select up to 16,000 characters.`}):null,y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto border-t border-edge-subtle p-3`,children:[(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n?`按选段生成的本地整理预览,尚未写入笔记。`:`Local preview of the selection. Your note is unchanged.`}),s?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,$.jsx)(q,{className:`h-4 w-full`}),(0,$.jsx)(q,{className:`h-4 w-2/3`})]}):null,a===null?null:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-sans text-sm leading-6`,children:a}),l?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:l}):null]}),a===null?null:(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle p-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>void Xe(a).then(e=>{m(e),e||d(n?`复制失败,请重试。`:`Copy failed. Try again.`)}),children:f?n?`已复制`:`Copied`:n?`复制结果`:`Copy`}),(0,$.jsx)(J,{variant:`primary`,onClick:()=>{t.insertAfter(a)?r():d(n?`正文已变化,请重新选择片段后再整理。`:`The note changed. Select the passage again.`)},children:n?`插入选段后`:`Insert after selection`})]})]}):null]}),document.body)}function nn(e){let t=(0,mt.c)(18),{input:n,labels:r,showLabel:i}=e,a=i===void 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=te(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=te(u),f=te(rn),p;t[6]!==n||t[7]!==r||t[8]!==d||t[9]!==a?(p=(0,$.jsx)(I,{input:n,labels:r,disabled:d,showLabel:a}),t[6]=n,t[7]=r,t[8]=d,t[9]=a,t[10]=p):p=t[10];let m;t[11]!==l||t[12]!==r||t[13]!==f?(m=l?(0,$.jsx)(`button`,{type:`button`,onClick:f,title:r.stop,"aria-label":r.stop,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(G,{className:`size-3.5`,"aria-hidden":!0})}):null,t[11]=l,t[12]=r,t[13]=f,t[14]=m):m=t[14];let h;return t[15]!==p||t[16]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function rn(e){return e.stop}function an(e,t){let n=re(t.replace(/^\s*(`{3,}|~{3,})[^\n]*$/gm,``).replace(/xopc-attachment:\/\/[^\s)]+/g,``).replace(/^(\s*[-*+]\s+)\[[ xX]\]\s*/gm,`$1`)),r=re(e);return!r||n.split(`
5
5
  `)[0]===r?n:[r,n].filter(Boolean).join(`
6
6
 
7
- `)}var on=()=>a(()=>import(`./block-editor-DI_JHx-P.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])),sn=()=>a(()=>import(`./markdown-editor-CjQJ-Nho.js`),__vite__mapDeps([45,1,2,41,46,17])),cn=(0,Q.lazy)(()=>a(()=>import(`./chat-page-U5hc4rIa.js`).then(e=>e.n).then(e=>({default:e.ChatPage})),__vite__mapDeps([47,1,2,17,16,3,4,11,12,13,6,48,49,50,51,52,53,54,55,56,57,58,9,10,14,15,18,19,20,21,22,23,24,25,26,27,28,29,30,31,7,8,32,34,59,36,38,60,61,62,63,64,65,39,66,67,68,69,70,71,72,73,74,75,76,77,78,40,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,37,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,33,121,35,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202]))),ln=(0,Q.lazy)(()=>on().then(e=>({default:e.BlockEditor}))),un=(0,Q.lazy)(()=>sn().then(e=>({default:e.MarkdownEditor})));function dn(){let e=(0,mt.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function fn(e){let t=(0,mt.c)(29),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:he},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:ue},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:H},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,p=pn,m;t[13]===f?m=t[14]:(m=(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[13]=f,t[14]=m);let h;t[15]===d.label?h=t[16]:(h=(0,$.jsx)(`span`,{children:d.label}),t[15]=d.label,t[16]=h);let g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(se,{className:`size-3 text-fg-subtle`,"aria-hidden":!0}),t[17]=g):g=t[17];let _;t[18]!==d.label||t[19]!==m||t[20]!==h?(_=(0,$.jsx)(ot,{asChild:!0,children:(0,$.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:[m,h,g]})}),t[18]=d.label,t[19]=m,t[20]=h,t[21]=_):_=t[21];let v;t[22]!==n||t[23]!==l||t[24]!==r?(v=(0,$.jsx)(st,{children:(0,$.jsx)(lt,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:l.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(ct,{onSelect:()=>r(t),onPointerMove:()=>p(t),onFocus:()=>p(t),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(a,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i}),n===t?(0,$.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}):null]},t)})})}),t[22]=n,t[23]=l,t[24]=r,t[25]=v):v=t[25];let y;return t[26]!==v||t[27]!==_?(y=(0,$.jsxs)(at,{modal:!1,children:[_,v]}),t[26]=v,t[27]=_,t[28]=y):y=t[28],y}function pn(e){e===`wysiwyg`&&on(),e===`source`&&sn()}function mn(e){let t=(0,mt.c)(16),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:s,onOpenSearch:c,autoFocus:l,initialMode:u,onAutoFocusConsumed:d}=e,p=a===void 0||a,m=s===void 0||s,g=l!==void 0&&l,_=f(hn),v;t[0]===_?v=t[1]:(v=h(_),t[0]=_,t[1]=v);let y=v.notes.lightboxClose,b;t[2]!==g||t[3]!==o||t[4]!==m||t[5]!==u||t[6]!==n||t[7]!==d||t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==p?(b=(0,$.jsx)(gn,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:o,clearHeaderOnCleanup:m,onOpenSearch:c,autoFocus:g,initialMode:u,onAutoFocusConsumed:d}),t[2]=g,t[3]=o,t[4]=m,t[5]=u,t[6]=n,t[7]=d,t[8]=r,t[9]=c,t[10]=i,t[11]=p,t[12]=b):b=t[12];let x;return t[13]!==y||t[14]!==b?(x=(0,$.jsx)(be,{closeLabel:y,children:b}),t[13]=y,t[14]=b,t[15]=x):x=t[15],x}function hn(e){return e.language}function gn({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:a=!0,onOpenSearch:o,autoFocus:s=!1,initialMode:l=`wysiwyg`,onAutoFocusConsumed:u}){let p=f(e=>e.language),m=h(p).notes,g=h(p).chat.pageContext,_=h(p).automations.suggestions,{data:v}=Ye([`note-discussion-document`,e],()=>E(e)),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(null),C=(0,Q.useCallback)(()=>S(null),[]);(0,Q.useEffect)(()=>{S(null)},[e]);let w=c(),T=Ze(e=>e.resolved)===`dark`,{openImage:D}=ve(),[O,k]=(0,Q.useState)(l);(0,Q.useEffect)(()=>{S(null)},[O,y]);let[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),[P,I]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(``),[ee,ne]=(0,Q.useState)(360),[re,ae]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[V,le]=(0,Q.useState)(!1),[ue,de]=(0,Q.useState)(!1),[fe,me]=(0,Q.useState)(null),H=(0,Q.useRef)(0),[ge,be]=(0,Q.useState)(null),xe=d(e=>e.baseUrl),Se=d(e=>e.conversationId),we=fe?.noteId===e&&fe.gatewayUrl===xe&&fe.gatewayToken===Se?fe.conversationId:null;(0,Q.useEffect)(()=>(H.current++,de(!1),me(null),le(!1),be(null),b(!0),()=>{H.current++}),[e,xe,Se]);let Ee=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{Ee.current+=1},[e]);let[De,W]=(0,Q.useState)(null),[ke,je]=(0,Q.useState)(!1),[Pe,Fe]=(0,Q.useState)(null),[Ie,Le]=(0,Q.useState)(!1),[ze,Be]=(0,Q.useState)(!1),Ve=(0,Q.useRef)(!1),Ue=(0,Q.useRef)(null),Ge=(0,Q.useRef)(null),G=(0,Q.useRef)(null),q=(0,Q.useRef)(null),J=(0,Q.useRef)(void 0),Xe=(0,Q.useRef)(null),X=(0,Q.useRef)(null),et=(0,Q.useRef)(null),tt=(0,Q.useRef)(null),nt=(0,Q.useRef)(null),rt=Qe(e=>e.setPageHeader),it=Qe(e=>e.clearPageHeader),{data:Z,mutate:pt,error:mt}=Ye(e?[`note-detail`,e]:null,()=>Te(e)),{data:ht=[],mutate:gt}=Ye(e?[`note-threads`,e]:null,()=>Oe(e),{revalidateOnFocus:!1}),_t=M!==null,vt=(0,Q.useCallback)(e=>{W(`${m.refreshFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)},[m.quickCaptureFailedHint,m.refreshFailed]);(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&pt().catch(vt)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[pt,e,vt]),(0,Q.useEffect)(()=>{B(``),N(null),j(null),Ve.current=!1,nt.current=null},[e]),(0,Q.useEffect)(()=>{!Z||P||q.current!==null||Ve.current||B(Z.title??``)},[Z,P]),(0,Q.useEffect)(()=>{if(!s||!Z||_t||nt.current===e)return;let t=window.requestAnimationFrame(()=>{tt.current?.focus(),u?.()});return nt.current=e,()=>window.cancelAnimationFrame(t)},[s,_t,Z,e,u]);let yt=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,bt=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":m.back,className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,Y,i),children:(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0})}):null,[i,m.back,t,r]),xt=(0,Q.useCallback)(()=>{let t=te.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),Ct=(0,Q.useCallback)(e=>{e!==`preview`&&xt(),k(e)},[xt]);(0,Q.useEffect)(()=>{!P&&G.current===null&&q.current===null&&(J.current=Z?.remoteVersion??1)},[e,Z?.remoteVersion,P]);let wt=(0,Q.useCallback)(async t=>{let n=J.current??Z?.remoteVersion??1,r=await _e(e,t,n);return J.current===n&&(J.current=r.remoteVersion??n+1),r},[e,Z?.remoteVersion]),Tt=(0,Q.useCallback)(t=>{xt(),B(t),e&&(q.current=t,Ge.current&&clearTimeout(Ge.current),Ge.current=setTimeout(async()=>{let e=q.current;if(q.current=null,e!==null){I(!0);try{await wt({title:e}),await pt(),n?.()}catch(t){q.current===null&&(q.current=e),W(`${m.saveFailed}: ${t instanceof Error?t.message:m.saveFailedHint}`)}finally{I(!1)}}},600))},[xt,e,pt,n,wt,m.saveFailed,m.saveFailedHint]),Et=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-2`,Y),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:z||yt||void 0,children:z||yt}),P?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:m.saving}):null]}),[m.saving,P,yt,z]),Dt=(0,Q.useCallback)(async()=>{ce(!0),W(null);try{await Ae(e),await pt()}catch(e){W(`${m.catalysisFailed}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{ce(!1)}},[pt,e]),Ot=(0,Q.useCallback)(()=>{de(!1),j(A===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!se&&Dt()},[A,se,Dt,Z?.aiDeep?.catalysis?.report]),kt=(0,Q.useCallback)(()=>{let t=M?M.markdown??``:G.current??Z?.markdown??``,n=M?M.title??``:z,r=an(n,t);return{source:{type:`note`,id:e,title:n||m.titlePlaceholder},text:r,language:L(r,p)}},[p,m.titlePlaceholder,Z?.markdown,e,M,z]),At=(0,Q.useCallback)(async()=>{Ue.current&&clearTimeout(Ue.current),Ge.current&&clearTimeout(Ge.current),Ue.current=null,Ge.current=null;let e=G.current,t=q.current;G.current=null,q.current=null;let r={};if(e!==null&&(r.markdown=e),t!==null&&(r.title=t),Object.keys(r).length===0)return Z??null;I(!0);try{let e=await wt(r);return await pt(e,{revalidate:!1}),n?.(),e}catch(n){return G.current===null&&(G.current=e),q.current===null&&(q.current=t),W(`${m.saveFailed}: ${n instanceof Error?n.message:m.saveFailedHint}`),null}finally{I(!1)}},[pt,m.saveFailed,m.saveFailedHint,Z,n,wt]),jt=(0,Q.useCallback)(async()=>P?(W(p===`zh`?`笔记正在保存,请稍后发送。`:`The note is saving. Please send again shortly.`),!1):!!await At()&&G.current===null&&q.current===null,[P,p,At]),Mt=(0,Q.useCallback)(async(t=!1)=>{if(j(null),de(!0),V||!t&&we)return;let n=++H.current;le(!0),W(null);try{if(!await jt())return;let r=await Ce(e,{forceNew:t});if(n!==H.current)return;me({noteId:e,gatewayUrl:xe,gatewayToken:Se,conversationId:r.conversationId}),await pt(),await gt()}catch(e){n===H.current&&W(`${m.chatOpenFailedTitle}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{n===H.current&&le(!1)}},[V,we,jt,pt,gt,e,xe,Se,m.chatOpenFailedMessage,m.chatOpenFailedTitle]),Nt=(0,Q.useCallback)(async e=>{if(!Z||V||P)return;le(!0),W(null);let t=d.getState(),n=++Ee.current,r=()=>Ee.current===n&&d.getState().baseUrl===t.baseUrl&&d.getState().conversationId===t.conversationId;try{let n=window.getSelection(),i=e??(n?.anchorNode&&n.focusNode&&Xe.current?.contains(n.anchorNode)&&Xe.current.contains(n.focusNode)?n.toString():``),a=await At();if(!a||!r())return;if(G.current!==null||q.current!==null)throw Error(g.unavailable);let o=dt.capture({title:a.title||a.id,text:a.markdown,resourceRefs:[{kind:`note`,id:a.id,revision:String(a.remoteVersion??1)}],selection:i?{text:i,draft:!1}:void 0}),s=await new Je().createSession();if(!r())return;if(G.current!==null||q.current!==null)throw Error(g.unavailable);let c=ft(t.baseUrl,t.conversationId,s.key);if(!dt.put(c,o))throw Error(g.unavailable);w(`/chat/${encodeURIComponent(s.key)}`)}catch{r()&&W(g.unavailable)}finally{Ee.current===n&&le(!1)}},[Z,V,P,At,w,g.unavailable]),Pt=(0,Q.useCallback)(async()=>{W(null);let e=await At();e&&(Fe(e),je(!0))},[At]),Ft=(0,Q.useCallback)(async()=>{if(!(ze||P)){Le(!1),Be(!0),W(null),xt(),Ue.current&&clearTimeout(Ue.current),Ge.current&&clearTimeout(Ge.current),Ue.current=null,Ge.current=null,G.current=null,q.current=null;try{await Me(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){W(`${m.deleteFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)}finally{Be(!1)}}},[ze,m.deleteFailed,m.quickCaptureFailedHint,e,t,n,P,xt]),It=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-1 sm:gap-2`,Y),children:[o?(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":m.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(He,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(nn,{input:kt,showLabel:!1,labels:{read:m.readAloud,preparing:m.readAloudPreparing,pause:m.readAloudPause,resume:m.readAloudResume,retry:m.readAloudRetry,stop:m.readAloudStop}}),(0,$.jsxs)(`button`,{type:`button`,onClick:Ot,disabled:se,"aria-label":m.catalysisSectionTitle,className:K(`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`,A===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:se?m.catalyzing:m.catalyzeButton})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Mt(!1),"aria-label":m.openChatButton,disabled:V,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,$.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:V?m.openingChat:m.openChatButton})]}),(0,$.jsx)(fn,{mode:O,onModeChange:Ct,labels:{edit:m.modeEdit,source:m.modeSource,preview:m.modePreview}}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Nt(),disabled:V||P||!Z||!!M,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),g.capture]}),(0,$.jsxs)(at,{modal:!1,children:[(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":m.noteActions,title:m.noteActions,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(pe,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,className:`z-50 min-w-40 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(ct,{onSelect:()=>void Pt(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(R,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),p===`zh`?`分享`:`Share`]}),(0,$.jsxs)(ct,{onSelect:()=>{de(!1),j(A===`history`?null:`history`)},className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(U,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:m.history}),A===`history`?(0,$.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}):null]}),(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(ct,{disabled:ze||P,onSelect:()=>Le(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),m.delete]})]})})]})]}),[se,Ot,Mt,Nt,g.capture,Z,M,O,m.history,m.modeEdit,m.modePreview,m.modeSource,V,A,o,m.searchDialogTitle,m.readAloud,m.readAloudPause,m.readAloudPreparing,m.readAloudResume,m.readAloudRetry,m.readAloudStop,Ct,kt,Pt,ze,P,p,m.delete,Le]);(0,Q.useLayoutEffect)(()=>(rt({startExtra:bt,main:Z&&!v?Et:null,end:Z&&!v?It:null}),()=>{a&&it()}),[a,it,It,Et,bt,v,y,Z,rt]);let Lt=(0,Q.useCallback)(t=>{e&&(xt(),G.current=t,Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(async()=>{let e=G.current;if(G.current=null,e!==null){I(!0),W(null);try{await wt({markdown:e}),await pt(),n?.()}catch(t){G.current===null&&(G.current=e),W(`${m.saveFailed}: ${t instanceof Error?t.message:m.saveFailedHint}`)}finally{I(!1)}}},600))},[xt,e,pt,m.saveFailed,m.saveFailedHint,n,wt]),Rt=(0,Q.useCallback)(t=>{Ne(e,t.timestamp).then(e=>{e&&(xt(),N(e))})},[e,xt]),zt=(0,Q.useCallback)(()=>{xt(),j(null),N(null)},[xt]),Bt=(0,Q.useCallback)(()=>{xt(),j(null),N(null),pt().catch(vt),n?.()},[pt,n,vt,xt]);if((0,Q.useEffect)(()=>()=>{Ue.current&&clearTimeout(Ue.current),Ge.current&&clearTimeout(Ge.current);let t=G.current,n=q.current;G.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&_e(e,r,J.current).catch(()=>void 0)},[e]),Z===void 0)return mt?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:m.home.loadFailed}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void pt().catch(vt),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:m.home.retry}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:m.back})]}):(0,$.jsx)(dn,{});if(Z===null)return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:m.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.notFoundDescription}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:m.back})]});let Vt=_t?M.title??``:z,Ut=_t?M.markdown??``:G.current??Z.markdown??``,Wt=new Date(Z.createdAt).getTime(),qt=Number.isFinite(Wt)&&Date.now()-Wt<3600*1e3?(0,$.jsx)(St,{title:_.noteCreatedTitle,description:_.noteCreatedDescription,prompt:_.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null,Yt=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[v?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center justify-end px-4 py-1`,children:(0,$.jsx)(fn,{mode:O,onModeChange:Ct,labels:{edit:m.modeEdit,source:m.modeSource,preview:m.modePreview}})}):null,(0,$.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1`,children:_t?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,children:[Vt&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Vt}),Ut?(0,$.jsx)(ye,{noteId:e,content:Ut,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[O===`wysiwyg`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:tt,type:`text`,value:z,onChange:e=>Tt(e.target.value),onCompositionStart:()=>{Ve.current=!0},onCompositionEnd:()=>{Ve.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!Ve.current&&!t.isComposing&&(e.preventDefault(),(Xe.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:m.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`}),qt]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(dn,{}),children:(0,$.jsx)(ln,{initialContent:Z.markdown??``,onChange:Lt,noteId:e,onTextSelection:S},`wysiwyg-${e}`)})})]}),O===`source`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:tt,type:`text`,value:z,onChange:e=>Tt(e.target.value),placeholder:m.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`}),qt]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(dn,{}),children:(0,$.jsx)(un,{initialContent:Z.markdown??``,onChange:Lt,isDark:T,onTextSelection:S},`source-${e}`)})})]}),O===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&D(t.currentSrc||t.src,t.alt)},children:[z&&!Z.markdown.trimStart().startsWith(`# ${z.trim()}\n`)&&Z.markdown.trim()!==`# ${z.trim()}`&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:z}),Z.markdown?(0,$.jsx)(ye,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]})]})})]});return(0,$.jsxs)($.Fragment,{children:[x&&!_t&&!(v&&y)&&O!==`preview`?(0,$.jsx)(tn,{noteId:e,selection:x,zh:p===`zh`,onDismiss:C,onAsk:e=>{be({id:Date.now(),text:p===`zh`?`请帮我分析或改写下面这段笔记:\n\n${e}`:`Help me analyze or rewrite this note selection:\n\n${e}`}),C(),Mt()}},`${e}:${O}`):null,(0,$.jsxs)(`div`,{className:`@container/note flex h-full min-h-0 min-w-0 gap-3 p-3 sm:p-4`,children:[(0,$.jsxs)(`div`,{className:K(`mx-auto min-h-0 min-w-0 w-full flex-1 flex-col`,ue||A?`hidden @min-[56rem]/note:flex`:`flex`,!v&&`max-w-[60rem]`),children:[De?(0,$.jsx)(`p`,{className:`mb-3 shrink-0 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:De}):null,(0,$.jsx)(ie,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(ie,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsxs)(`div`,{ref:Xe,onKeyDown:e=>{x&&e.altKey&&e.key===`Enter`&&(e.preventDefault(),document.querySelector(`[data-note-selection-actions] button:not(:disabled)`)?.focus())},className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[v?(0,$.jsx)(Ht,{personalNotes:Yt,personalNotesActive:!y,onMeetingContent:()=>b(!0),noteId:e,noteActions:{onAnalyze:Ot,chatOpen:ue,onChat:()=>{ue?de(!1):Mt(!1)},onShare:()=>{Pt()},onHistory:()=>{de(!1),j(A===`history`?null:`history`)},onDelete:()=>Le(!0),busy:ze||P||se||V},onPersonalNotes:()=>{b(!1),window.setTimeout(()=>tt.current?.focus(),0)}}):null,v?null:Yt]})]}),ue||we?(0,$.jsxs)(`aside`,{id:`note-assistant-${e}`,"aria-label":p===`zh`?`笔记 AI 对话`:`Note AI chat`,className:K(`min-h-0 min-w-0 shrink-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,ue?`flex w-full @min-[56rem]/note:w-[22rem] @min-[76rem]/note:w-[24rem]`:`hidden`),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-edge-subtle px-4 py-2`,children:[(0,$.jsx)(Re,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`flex-1 text-sm font-medium`,children:p===`zh`?`AI 对话`:`AI chat`}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-11 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":p===`zh`?`收起 AI 对话`:`Close AI chat`,onClick:()=>{de(!1),window.requestAnimationFrame(()=>document.querySelector(`[aria-controls="note-assistant-${e}"]`)?.focus({preventScroll:!0}))},children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsx)(`p`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 text-xs leading-5 text-fg-muted`,children:p===`zh`?`已关联当前笔记。可提问、改写我的笔记,也可将回答保存回笔记。`:`Linked to this note. Ask questions, edit My notes, or save an answer to the note.`}),De&&we?(0,$.jsx)(`p`,{role:`alert`,className:`shrink-0 px-4 py-2 text-xs text-danger`,children:De}):null,(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:we?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(dn,{}),children:(0,$.jsx)(cn,{embedded:!0,sourceNoteInView:!0,conversationId:we,draftSeed:ge,beforeSend:jt},`${e}:${we}`)}):V?(0,$.jsx)(dn,{}):(0,$.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:De||(p===`zh`?`对话尚未打开,请重试。`:`Chat could not be opened. Try again.`)}),(0,$.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-lg px-3 text-accent-fg hover:bg-surface-hover`,onClick:()=>void Mt(),children:p===`zh`?`重新打开`:`Try again`})]})})]}):null,(0,$.jsx)(`div`,{ref:X,className:K(`relative min-h-0 max-w-full shrink-0 flex-col overflow-hidden`,A?`flex`:`hidden`,!re&&`transition-[width] duration-300 ease-in-out`),style:{width:A?ee:0},children:(0,$.jsxs)(`div`,{ref:et,className:`flex min-h-0 flex-1 flex-col`,style:{width:ee},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),ae(!0);let n=e.clientX,r=ee,i=e.pointerId,a=0,o=ee,s=ee,c=()=>{a=0,s=o,A&&X.current?.style.setProperty(`width`,`${s}px`),et.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{}ae(!1),ne(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:K(`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`,re&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:A===`history`?(0,$.jsx)(Gt,{noteId:e,activeTimestamp:M?.timestamp??null,onSelect:Rt,onClose:zt,onRestored:Bt}):A===`breakdown`?(0,$.jsx)(Kt,{noteId:e,note:Z??null,catalyzing:se,onCatalyze:Dt,onClose:()=>j(null),noteThreads:ht,openingChat:V,onOpenChat:()=>Mt(!1),onOpenNewChat:()=>Mt(!0)}):null})]})})]}),Pe?(0,$.jsx)(Jt,{open:ke,onOpenChange:je,note:Pe}):null,(0,$.jsx)($e,{open:Ie,title:m.deleteConfirmTitle,description:m.deleteConfirmDescription.replace(`{{title}}`,Z.title||m.titlePlaceholder),confirmLabel:m.deleteConfirmLabel,cancelLabel:m.deleteCancelLabel,destructive:!0,onConfirm:()=>void Ft(),onCancel:()=>Le(!1)})]})}export{yt as i,xt as n,bt as r,mn as t};
7
+ `)}var on=()=>a(()=>import(`./block-editor-D-YHASZr.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])),sn=()=>a(()=>import(`./markdown-editor-CjQJ-Nho.js`),__vite__mapDeps([46,1,2,42,47,17])),cn=(0,Q.lazy)(()=>a(()=>import(`./chat-page-CCwdk6yE.js`).then(e=>e.n).then(e=>({default:e.ChatPage})),__vite__mapDeps([48,1,2,17,16,3,4,11,12,13,6,49,50,51,52,53,54,55,56,57,58,59,9,10,14,15,18,19,20,21,22,23,24,25,26,27,28,29,30,31,7,8,32,34,60,36,38,61,62,63,64,65,66,39,67,68,69,70,71,72,73,74,75,76,77,78,79,40,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,37,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,33,122,35,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,41,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204]))),ln=(0,Q.lazy)(()=>on().then(e=>({default:e.BlockEditor}))),un=(0,Q.lazy)(()=>sn().then(e=>({default:e.MarkdownEditor})));function dn(){let e=(0,mt.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-6 py-4`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-8 w-56 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-6 h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function fn(e){let t=(0,mt.c)(29),{mode:n,onModeChange:r,labels:i}=e,a;t[0]===i.edit?a=t[1]:(a={id:`wysiwyg`,label:i.edit,Icon:he},t[0]=i.edit,t[1]=a);let o;t[2]===i.source?o=t[3]:(o={id:`source`,label:i.source,Icon:ue},t[2]=i.source,t[3]=o);let s;t[4]===i.preview?s=t[5]:(s={id:`preview`,label:i.preview,Icon:H},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,p=pn,m;t[13]===f?m=t[14]:(m=(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[13]=f,t[14]=m);let h;t[15]===d.label?h=t[16]:(h=(0,$.jsx)(`span`,{children:d.label}),t[15]=d.label,t[16]=h);let g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(se,{className:`size-3 text-fg-subtle`,"aria-hidden":!0}),t[17]=g):g=t[17];let _;t[18]!==d.label||t[19]!==m||t[20]!==h?(_=(0,$.jsx)(ot,{asChild:!0,children:(0,$.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:[m,h,g]})}),t[18]=d.label,t[19]=m,t[20]=h,t[21]=_):_=t[21];let v;t[22]!==n||t[23]!==l||t[24]!==r?(v=(0,$.jsx)(st,{children:(0,$.jsx)(lt,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:l.map(e=>{let{id:t,label:i,Icon:a}=e;return(0,$.jsxs)(ct,{onSelect:()=>r(t),onPointerMove:()=>p(t),onFocus:()=>p(t),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(a,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:i}),n===t?(0,$.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}):null]},t)})})}),t[22]=n,t[23]=l,t[24]=r,t[25]=v):v=t[25];let y;return t[26]!==v||t[27]!==_?(y=(0,$.jsxs)(at,{modal:!1,children:[_,v]}),t[26]=v,t[27]=_,t[28]=y):y=t[28],y}function pn(e){e===`wysiwyg`&&on(),e===`source`&&sn()}function mn(e){let t=(0,mt.c)(16),{noteId:n,onBack:r,onSaved:i,showBackButton:a,backButtonClassName:o,clearHeaderOnCleanup:s,onOpenSearch:c,autoFocus:l,initialMode:u,onAutoFocusConsumed:d}=e,p=a===void 0||a,m=s===void 0||s,g=l!==void 0&&l,_=f(hn),v;t[0]===_?v=t[1]:(v=h(_),t[0]=_,t[1]=v);let y=v.notes.lightboxClose,b;t[2]!==g||t[3]!==o||t[4]!==m||t[5]!==u||t[6]!==n||t[7]!==d||t[8]!==r||t[9]!==c||t[10]!==i||t[11]!==p?(b=(0,$.jsx)(gn,{noteId:n,onBack:r,onSaved:i,showBackButton:p,backButtonClassName:o,clearHeaderOnCleanup:m,onOpenSearch:c,autoFocus:g,initialMode:u,onAutoFocusConsumed:d}),t[2]=g,t[3]=o,t[4]=m,t[5]=u,t[6]=n,t[7]=d,t[8]=r,t[9]=c,t[10]=i,t[11]=p,t[12]=b):b=t[12];let x;return t[13]!==y||t[14]!==b?(x=(0,$.jsx)(be,{closeLabel:y,children:b}),t[13]=y,t[14]=b,t[15]=x):x=t[15],x}function hn(e){return e.language}function gn({noteId:e,onBack:t,onSaved:n,showBackButton:r=!0,backButtonClassName:i,clearHeaderOnCleanup:a=!0,onOpenSearch:o,autoFocus:s=!1,initialMode:l=`wysiwyg`,onAutoFocusConsumed:u}){let p=f(e=>e.language),m=h(p).notes,g=h(p).chat.pageContext,_=h(p).automations.suggestions,{data:v}=Ye([`note-discussion-document`,e],()=>E(e)),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(null),C=(0,Q.useCallback)(()=>S(null),[]);(0,Q.useEffect)(()=>{S(null)},[e]);let w=c(),T=Ze(e=>e.resolved)===`dark`,{openImage:D}=ve(),[O,k]=(0,Q.useState)(l);(0,Q.useEffect)(()=>{S(null)},[O,y]);let[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(null),[P,I]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(``),[ee,ne]=(0,Q.useState)(360),[re,ae]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[V,le]=(0,Q.useState)(!1),[ue,de]=(0,Q.useState)(!1),[fe,me]=(0,Q.useState)(null),H=(0,Q.useRef)(0),[ge,be]=(0,Q.useState)(null),xe=d(e=>e.baseUrl),Se=d(e=>e.conversationId),we=fe?.noteId===e&&fe.gatewayUrl===xe&&fe.gatewayToken===Se?fe.conversationId:null;(0,Q.useEffect)(()=>(H.current++,de(!1),me(null),le(!1),be(null),b(!0),()=>{H.current++}),[e,xe,Se]);let Ee=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{Ee.current+=1},[e]);let[De,W]=(0,Q.useState)(null),[ke,je]=(0,Q.useState)(!1),[Pe,Fe]=(0,Q.useState)(null),[Ie,Le]=(0,Q.useState)(!1),[ze,Be]=(0,Q.useState)(!1),Ve=(0,Q.useRef)(!1),Ue=(0,Q.useRef)(null),Ge=(0,Q.useRef)(null),G=(0,Q.useRef)(null),q=(0,Q.useRef)(null),J=(0,Q.useRef)(void 0),Xe=(0,Q.useRef)(null),X=(0,Q.useRef)(null),et=(0,Q.useRef)(null),tt=(0,Q.useRef)(null),nt=(0,Q.useRef)(null),rt=Qe(e=>e.setPageHeader),it=Qe(e=>e.clearPageHeader),{data:Z,mutate:pt,error:mt}=Ye(e?[`note-detail`,e]:null,()=>Te(e)),{data:ht=[],mutate:gt}=Ye(e?[`note-threads`,e]:null,()=>Oe(e),{revalidateOnFocus:!1}),_t=M!==null,vt=(0,Q.useCallback)(e=>{W(`${m.refreshFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)},[m.quickCaptureFailedHint,m.refreshFailed]);(0,Q.useEffect)(()=>{if(!e)return;let t=t=>{t.detail?.noteId===e&&pt().catch(vt)};return window.addEventListener(`note-updated`,t),()=>window.removeEventListener(`note-updated`,t)},[pt,e,vt]),(0,Q.useEffect)(()=>{B(``),N(null),j(null),Ve.current=!1,nt.current=null},[e]),(0,Q.useEffect)(()=>{!Z||P||q.current!==null||Ve.current||B(Z.title??``)},[Z,P]),(0,Q.useEffect)(()=>{if(!s||!Z||_t||nt.current===e)return;let t=window.requestAnimationFrame(()=>{tt.current?.focus(),u?.()});return nt.current=e,()=>window.cancelAnimationFrame(t)},[s,_t,Z,e,u]);let yt=Z?new Date(Z.createdAt).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):``,bt=(0,Q.useMemo)(()=>r?(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":m.back,className:K(`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,Y,i),children:(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0})}):null,[i,m.back,t,r]),xt=(0,Q.useCallback)(()=>{let t=te.getState();t.source?.type===`note`&&t.source.id===e&&t.stop()},[e]),Ct=(0,Q.useCallback)(e=>{e!==`preview`&&xt(),k(e)},[xt]);(0,Q.useEffect)(()=>{!P&&G.current===null&&q.current===null&&(J.current=Z?.remoteVersion??1)},[e,Z?.remoteVersion,P]);let wt=(0,Q.useCallback)(async t=>{let n=J.current??Z?.remoteVersion??1,r=await _e(e,t,n);return J.current===n&&(J.current=r.remoteVersion??n+1),r},[e,Z?.remoteVersion]),Tt=(0,Q.useCallback)(t=>{xt(),B(t),e&&(q.current=t,Ge.current&&clearTimeout(Ge.current),Ge.current=setTimeout(async()=>{let e=q.current;if(q.current=null,e!==null){I(!0);try{await wt({title:e}),await pt(),n?.()}catch(t){q.current===null&&(q.current=e),W(`${m.saveFailed}: ${t instanceof Error?t.message:m.saveFailedHint}`)}finally{I(!1)}}},600))},[xt,e,pt,n,wt,m.saveFailed,m.saveFailedHint]),Et=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-2`,Y),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,title:z||yt||void 0,children:z||yt}),P?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted opacity-60`,children:m.saving}):null]}),[m.saving,P,yt,z]),Dt=(0,Q.useCallback)(async()=>{ce(!0),W(null);try{await Ae(e),await pt()}catch(e){W(`${m.catalysisFailed}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{ce(!1)}},[pt,e]),Ot=(0,Q.useCallback)(()=>{de(!1),j(A===`breakdown`?null:`breakdown`),!Z?.aiDeep?.catalysis?.report&&!se&&Dt()},[A,se,Dt,Z?.aiDeep?.catalysis?.report]),kt=(0,Q.useCallback)(()=>{let t=M?M.markdown??``:G.current??Z?.markdown??``,n=M?M.title??``:z,r=an(n,t);return{source:{type:`note`,id:e,title:n||m.titlePlaceholder},text:r,language:L(r,p)}},[p,m.titlePlaceholder,Z?.markdown,e,M,z]),At=(0,Q.useCallback)(async()=>{Ue.current&&clearTimeout(Ue.current),Ge.current&&clearTimeout(Ge.current),Ue.current=null,Ge.current=null;let e=G.current,t=q.current;G.current=null,q.current=null;let r={};if(e!==null&&(r.markdown=e),t!==null&&(r.title=t),Object.keys(r).length===0)return Z??null;I(!0);try{let e=await wt(r);return await pt(e,{revalidate:!1}),n?.(),e}catch(n){return G.current===null&&(G.current=e),q.current===null&&(q.current=t),W(`${m.saveFailed}: ${n instanceof Error?n.message:m.saveFailedHint}`),null}finally{I(!1)}},[pt,m.saveFailed,m.saveFailedHint,Z,n,wt]),jt=(0,Q.useCallback)(async()=>P?(W(p===`zh`?`笔记正在保存,请稍后发送。`:`The note is saving. Please send again shortly.`),!1):!!await At()&&G.current===null&&q.current===null,[P,p,At]),Mt=(0,Q.useCallback)(async(t=!1)=>{if(j(null),de(!0),V||!t&&we)return;let n=++H.current;le(!0),W(null);try{if(!await jt())return;let r=await Ce(e,{forceNew:t});if(n!==H.current)return;me({noteId:e,gatewayUrl:xe,gatewayToken:Se,conversationId:r.conversationId}),await pt(),await gt()}catch(e){n===H.current&&W(`${m.chatOpenFailedTitle}: ${e instanceof Error?e.message:m.chatOpenFailedMessage}`)}finally{n===H.current&&le(!1)}},[V,we,jt,pt,gt,e,xe,Se,m.chatOpenFailedMessage,m.chatOpenFailedTitle]),Nt=(0,Q.useCallback)(async e=>{if(!Z||V||P)return;le(!0),W(null);let t=d.getState(),n=++Ee.current,r=()=>Ee.current===n&&d.getState().baseUrl===t.baseUrl&&d.getState().conversationId===t.conversationId;try{let n=window.getSelection(),i=e??(n?.anchorNode&&n.focusNode&&Xe.current?.contains(n.anchorNode)&&Xe.current.contains(n.focusNode)?n.toString():``),a=await At();if(!a||!r())return;if(G.current!==null||q.current!==null)throw Error(g.unavailable);let o=dt.capture({title:a.title||a.id,text:a.markdown,resourceRefs:[{kind:`note`,id:a.id,revision:String(a.remoteVersion??1)}],selection:i?{text:i,draft:!1}:void 0}),s=await new Je().createSession();if(!r())return;if(G.current!==null||q.current!==null)throw Error(g.unavailable);let c=ft(t.baseUrl,t.conversationId,s.key);if(!dt.put(c,o))throw Error(g.unavailable);w(`/chat/${encodeURIComponent(s.key)}`)}catch{r()&&W(g.unavailable)}finally{Ee.current===n&&le(!1)}},[Z,V,P,At,w,g.unavailable]),Pt=(0,Q.useCallback)(async()=>{W(null);let e=await At();e&&(Fe(e),je(!0))},[At]),Ft=(0,Q.useCallback)(async()=>{if(!(ze||P)){Le(!1),Be(!0),W(null),xt(),Ue.current&&clearTimeout(Ue.current),Ge.current&&clearTimeout(Ge.current),Ue.current=null,Ge.current=null,G.current=null,q.current=null;try{await Me(e),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e}})),n?.(),t()}catch(e){W(`${m.deleteFailed}: ${e instanceof Error?e.message:m.quickCaptureFailedHint}`)}finally{Be(!1)}}},[ze,m.deleteFailed,m.quickCaptureFailedHint,e,t,n,P,xt]),It=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:K(`flex min-w-0 items-center gap-1 sm:gap-2`,Y),children:[o?(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":m.searchDialogTitle,className:`rounded-lg p-1.5 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(He,{className:`size-4`,"aria-hidden":!0})}):null,(0,$.jsx)(nn,{input:kt,showLabel:!1,labels:{read:m.readAloud,preparing:m.readAloudPreparing,pause:m.readAloudPause,resume:m.readAloudResume,retry:m.readAloudRetry,stop:m.readAloudStop}}),(0,$.jsxs)(`button`,{type:`button`,onClick:Ot,disabled:se,"aria-label":m.catalysisSectionTitle,className:K(`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`,A===`breakdown`?`bg-accent/10 text-accent`:`bg-accent/10 text-fg hover:bg-accent/15`),children:[(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:se?m.catalyzing:m.catalyzeButton})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Mt(!1),"aria-label":m.openChatButton,disabled:V,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,`border border-edge text-fg-muted hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50`),children:[(0,$.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:V?m.openingChat:m.openChatButton})]}),(0,$.jsx)(fn,{mode:O,onModeChange:Ct,labels:{edit:m.modeEdit,source:m.modeSource,preview:m.modePreview}}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Nt(),disabled:V||P||!Z||!!M,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),g.capture]}),(0,$.jsxs)(at,{modal:!1,children:[(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":m.noteActions,title:m.noteActions,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(pe,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{align:`end`,sideOffset:6,className:`z-50 min-w-40 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(ct,{onSelect:()=>void Pt(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(R,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),p===`zh`?`分享`:`Share`]}),(0,$.jsxs)(ct,{onSelect:()=>{de(!1),j(A===`history`?null:`history`)},className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(U,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`flex-1`,children:m.history}),A===`history`?(0,$.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}):null]}),(0,$.jsx)(ut,{className:`my-1 h-px bg-edge-subtle`}),(0,$.jsxs)(ct,{disabled:ze||P,onSelect:()=>Le(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),m.delete]})]})})]})]}),[se,Ot,Mt,Nt,g.capture,Z,M,O,m.history,m.modeEdit,m.modePreview,m.modeSource,V,A,o,m.searchDialogTitle,m.readAloud,m.readAloudPause,m.readAloudPreparing,m.readAloudResume,m.readAloudRetry,m.readAloudStop,Ct,kt,Pt,ze,P,p,m.delete,Le]);(0,Q.useLayoutEffect)(()=>(rt({startExtra:bt,main:Z&&!v?Et:null,end:Z&&!v?It:null}),()=>{a&&it()}),[a,it,It,Et,bt,v,y,Z,rt]);let Lt=(0,Q.useCallback)(t=>{e&&(xt(),G.current=t,Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(async()=>{let e=G.current;if(G.current=null,e!==null){I(!0),W(null);try{await wt({markdown:e}),await pt(),n?.()}catch(t){G.current===null&&(G.current=e),W(`${m.saveFailed}: ${t instanceof Error?t.message:m.saveFailedHint}`)}finally{I(!1)}}},600))},[xt,e,pt,m.saveFailed,m.saveFailedHint,n,wt]),Rt=(0,Q.useCallback)(t=>{Ne(e,t.timestamp).then(e=>{e&&(xt(),N(e))})},[e,xt]),zt=(0,Q.useCallback)(()=>{xt(),j(null),N(null)},[xt]),Bt=(0,Q.useCallback)(()=>{xt(),j(null),N(null),pt().catch(vt),n?.()},[pt,n,vt,xt]);if((0,Q.useEffect)(()=>()=>{Ue.current&&clearTimeout(Ue.current),Ge.current&&clearTimeout(Ge.current);let t=G.current,n=q.current;G.current=null,q.current=null;let r={};t!==null&&(r.markdown=t),n!==null&&(r.title=n),Object.keys(r).length>0&&_e(e,r,J.current).catch(()=>void 0)},[e]),Z===void 0)return mt?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:m.home.loadFailed}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void pt().catch(vt),className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-hover`,children:m.home.retry}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-fg-muted hover:text-fg`,children:m.back})]}):(0,$.jsx)(dn,{});if(Z===null)return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:m.notFoundTitle}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.notFoundDescription}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-edge px-3 py-1.5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,children:m.back})]});let Vt=_t?M.title??``:z,Ut=_t?M.markdown??``:G.current??Z.markdown??``,Wt=new Date(Z.createdAt).getTime(),qt=Number.isFinite(Wt)&&Date.now()-Wt<3600*1e3?(0,$.jsx)(St,{title:_.noteCreatedTitle,description:_.noteCreatedDescription,prompt:_.noteCreatedPrompt,coverage:{eventType:`note.created`,source:`notes`,eventPayload:{noteId:e}},variant:`titleAction`,className:`ml-3 hidden max-w-[18rem] shrink-0 md:flex`}):null,Yt=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[v?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center justify-end px-4 py-1`,children:(0,$.jsx)(fn,{mode:O,onModeChange:Ct,labels:{edit:m.modeEdit,source:m.modeSource,preview:m.modePreview}})}):null,(0,$.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1`,children:_t?(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,children:[Vt&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg/70`,children:Vt}),Ut?(0,$.jsx)(ye,{noteId:e,content:Ut,className:`opacity-80`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]}):(0,$.jsxs)($.Fragment,{children:[O===`wysiwyg`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:tt,type:`text`,value:z,onChange:e=>Tt(e.target.value),onCompositionStart:()=>{Ve.current=!0},onCompositionEnd:()=>{Ve.current=!1},onKeyDown:e=>{let t=e.nativeEvent;e.key===`Enter`&&!Ve.current&&!t.isComposing&&(e.preventDefault(),(Xe.current?.querySelector(`.ProseMirror`))?.focus())},placeholder:m.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`}),qt]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(dn,{}),children:(0,$.jsx)(ln,{initialContent:Z.markdown??``,onChange:Lt,noteId:e,onTextSelection:S},`wysiwyg-${e}`)})})]}),O===`source`&&(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start px-6 pt-4`,children:[(0,$.jsx)(`input`,{ref:tt,type:`text`,value:z,onChange:e=>Tt(e.target.value),placeholder:m.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`}),qt]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(dn,{}),children:(0,$.jsx)(un,{initialContent:Z.markdown??``,onChange:Lt,isDark:T,onTextSelection:S},`source-${e}`)})})]}),O===`preview`&&(0,$.jsxs)(`div`,{className:`h-full overflow-y-auto px-4 py-4 sm:px-6`,onClick:e=>{let t=e.target;t instanceof HTMLImageElement&&D(t.currentSrc||t.src,t.alt)},children:[z&&!Z.markdown.trimStart().startsWith(`# ${z.trim()}\n`)&&Z.markdown.trim()!==`# ${z.trim()}`&&(0,$.jsx)(`h1`,{className:`mb-4 text-2xl font-bold text-fg`,children:z}),Z.markdown?(0,$.jsx)(ye,{noteId:e,content:Z.markdown,className:`[&_img]:cursor-zoom-in`}):(0,$.jsx)(`p`,{className:`italic text-fg-muted`,children:m.emptyPreview})]})]})})]});return(0,$.jsxs)($.Fragment,{children:[x&&!_t&&!(v&&y)&&O!==`preview`?(0,$.jsx)(tn,{noteId:e,selection:x,zh:p===`zh`,onDismiss:C,onAsk:e=>{be({id:Date.now(),text:p===`zh`?`请帮我分析或改写下面这段笔记:\n\n${e}`:`Help me analyze or rewrite this note selection:\n\n${e}`}),C(),Mt()}},`${e}:${O}`):null,(0,$.jsxs)(`div`,{className:`@container/note flex h-full min-h-0 min-w-0 gap-3 p-3 sm:p-4`,children:[(0,$.jsxs)(`div`,{className:K(`mx-auto min-h-0 min-w-0 w-full flex-1 flex-col`,ue||A?`hidden @min-[56rem]/note:flex`:`flex`,!v&&`max-w-[60rem]`),children:[De?(0,$.jsx)(`p`,{className:`mb-3 shrink-0 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:De}):null,(0,$.jsx)(ie,{eventType:`note.created`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsx)(ie,{eventType:`note.updated`,source:`notes`,payloadKey:`noteId`,payloadValue:e,className:`mb-3 shrink-0`}),(0,$.jsxs)(`div`,{ref:Xe,onKeyDown:e=>{x&&e.altKey&&e.key===`Enter`&&(e.preventDefault(),document.querySelector(`[data-note-selection-actions] button:not(:disabled)`)?.focus())},className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel xl:flex-row`,children:[v?(0,$.jsx)(Ht,{personalNotes:Yt,personalNotesActive:!y,onMeetingContent:()=>b(!0),noteId:e,noteActions:{onAnalyze:Ot,chatOpen:ue,onChat:()=>{ue?de(!1):Mt(!1)},onShare:()=>{Pt()},onHistory:()=>{de(!1),j(A===`history`?null:`history`)},onDelete:()=>Le(!0),busy:ze||P||se||V},onPersonalNotes:()=>{b(!1),window.setTimeout(()=>tt.current?.focus(),0)}}):null,v?null:Yt]})]}),ue||we?(0,$.jsxs)(`aside`,{id:`note-assistant-${e}`,"aria-label":p===`zh`?`笔记 AI 对话`:`Note AI chat`,className:K(`min-h-0 min-w-0 shrink-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,ue?`flex w-full @min-[56rem]/note:w-[22rem] @min-[76rem]/note:w-[24rem]`:`hidden`),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 border-b border-edge-subtle px-4 py-2`,children:[(0,$.jsx)(Re,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`flex-1 text-sm font-medium`,children:p===`zh`?`AI 对话`:`AI chat`}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-11 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":p===`zh`?`收起 AI 对话`:`Close AI chat`,onClick:()=>{de(!1),window.requestAnimationFrame(()=>document.querySelector(`[aria-controls="note-assistant-${e}"]`)?.focus({preventScroll:!0}))},children:(0,$.jsx)(qe,{className:`size-4`})})]}),(0,$.jsx)(`p`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 text-xs leading-5 text-fg-muted`,children:p===`zh`?`已关联当前笔记。可提问、改写我的笔记,也可将回答保存回笔记。`:`Linked to this note. Ask questions, edit My notes, or save an answer to the note.`}),De&&we?(0,$.jsx)(`p`,{role:`alert`,className:`shrink-0 px-4 py-2 text-xs text-danger`,children:De}):null,(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:we?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(dn,{}),children:(0,$.jsx)(cn,{embedded:!0,sourceNoteInView:!0,conversationId:we,draftSeed:ge,beforeSend:jt},`${e}:${we}`)}):V?(0,$.jsx)(dn,{}):(0,$.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:De||(p===`zh`?`对话尚未打开,请重试。`:`Chat could not be opened. Try again.`)}),(0,$.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-lg px-3 text-accent-fg hover:bg-surface-hover`,onClick:()=>void Mt(),children:p===`zh`?`重新打开`:`Try again`})]})})]}):null,(0,$.jsx)(`div`,{ref:X,className:K(`relative min-h-0 max-w-full shrink-0 flex-col overflow-hidden`,A?`flex`:`hidden`,!re&&`transition-[width] duration-300 ease-in-out`),style:{width:A?ee:0},children:(0,$.jsxs)(`div`,{ref:et,className:`flex min-h-0 flex-1 flex-col`,style:{width:ee},children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:e=>{e.preventDefault();let t=e.currentTarget;t.setPointerCapture(e.pointerId),ae(!0);let n=e.clientX,r=ee,i=e.pointerId,a=0,o=ee,s=ee,c=()=>{a=0,s=o,A&&X.current?.style.setProperty(`width`,`${s}px`),et.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{}ae(!1),ne(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:K(`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`,re&&`before:!bg-edge/80 dark:before:!bg-edge/85`,`touch-none select-none`)}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:A===`history`?(0,$.jsx)(Gt,{noteId:e,activeTimestamp:M?.timestamp??null,onSelect:Rt,onClose:zt,onRestored:Bt}):A===`breakdown`?(0,$.jsx)(Kt,{noteId:e,note:Z??null,catalyzing:se,onCatalyze:Dt,onClose:()=>j(null),noteThreads:ht,openingChat:V,onOpenChat:()=>Mt(!1),onOpenNewChat:()=>Mt(!0)}):null})]})})]}),Pe?(0,$.jsx)(Jt,{open:ke,onOpenChange:je,note:Pe}):null,(0,$.jsx)($e,{open:Ie,title:m.deleteConfirmTitle,description:m.deleteConfirmDescription.replace(`{{title}}`,Z.title||m.titlePlaceholder),confirmLabel:m.deleteConfirmLabel,cancelLabel:m.deleteCancelLabel,destructive:!0,onConfirm:()=>void Ft(),onCancel:()=>Le(!1)})]})}export{yt as i,xt as n,bt as r,mn as t};