@xopcai/xopc 0.0.463 → 0.0.464

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 (238) hide show
  1. package/dist/browser-ext/dist/sidepanel.js +5 -0
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/{activity-store-CQHh48Zf.js → activity-store-B9heFbtJ.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CAz-Ke6Q.js → agent-avatar-dicebear-nzhB7Xjk.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-avatar-display-loBdGw_i.js → agent-avatar-display-DBzgoHMD.js} +2 -2
  7. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-By2Q-6JS.js → agent-defaults-settings-panel-BJrNV93g.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-plugin-dialog-C_rlXuEe.js → agent-plugin-dialog-DLbTHALG.js} +1 -1
  9. package/dist/gateway/static/root/assets/agents-C2xG8f56.js +77 -0
  10. package/dist/gateway/static/root/assets/{agents-admin-api-D0N09mqJ.js → agents-admin-api-CqQbYIiY.js} +1 -1
  11. package/dist/gateway/static/root/assets/{api-B1J5ajiP.js → api-8tNOT72p.js} +1 -1
  12. package/dist/gateway/static/root/assets/{api-B4FJ51EC.js → api-BGodd--L.js} +1 -1
  13. package/dist/gateway/static/root/assets/{app-management-settings-panel-BHlUDZOG.js → app-management-settings-panel-Q7apF7KE.js} +1 -1
  14. package/dist/gateway/static/root/assets/{appearance-settings-Du5JLyV1.js → appearance-settings-ClVZeUmo.js} +1 -1
  15. package/dist/gateway/static/root/assets/{apps-page-D1qzENN_.js → apps-page-BsJJwpKj.js} +1 -1
  16. package/dist/gateway/static/root/assets/{archive-plugin-BAvglLfu.js → archive-plugin-Bl_M0WJp.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automation-api-DxBmyzp0.js → automation-api-BOnIc_vw.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automation-result-state-CAsqgMNR.js → automation-result-state-BwDSJs05.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automation-run-list-BmYeWB_N.js → automation-run-list-CqlIq4BG.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automation-task-card-CJbIHRxN.js → automation-task-card-D3WXVKRs.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automations-page-HYFnPiNG.js → automations-page-Bimqx5Pc.js} +1 -1
  22. package/dist/gateway/static/root/assets/automations-workspace-2SOvmw-f.js +9 -0
  23. package/dist/gateway/static/root/assets/{binary-plugins-D2bFqG6K.js → binary-plugins-DDNKe1Io.js} +1 -1
  24. package/dist/gateway/static/root/assets/{block-editor-DrZyRQQ0.js → block-editor-BQ3amsRP.js} +5 -5
  25. package/dist/gateway/static/root/assets/{browser-settings-page-CGcgZOWh.js → browser-settings-page-CHf1_RVl.js} +1 -1
  26. package/dist/gateway/static/root/assets/{capabilities-hSb-qEgL.js → capabilities-C5oWMC-Z.js} +1 -1
  27. package/dist/gateway/static/root/assets/{capabilities-Dr-vvMez.js → capabilities-Cj8vl1ZY.js} +1 -1
  28. package/dist/gateway/static/root/assets/capabilities-page-rTjkjo71.js +2 -0
  29. package/dist/gateway/static/root/assets/{capabilities-settings-panel-B08mjrGB.js → capabilities-settings-panel-k5CcwhXN.js} +1 -1
  30. package/dist/gateway/static/root/assets/{channels-B--IHNs4.js → channels-DvB2fwPI.js} +1 -1
  31. package/dist/gateway/static/root/assets/chat-agents-api-C3JChTsh.js +1 -0
  32. package/dist/gateway/static/root/assets/{chat-chart-block-ClCZyIi0.js → chat-chart-block-DrtmYOIo.js} +1 -1
  33. package/dist/gateway/static/root/assets/{chat-page-CalELOKj.js → chat-page-qnsMsF_s.js} +29 -29
  34. package/dist/gateway/static/root/assets/{chat-terminal-dock-eneTvxV3.js → chat-terminal-dock-B0D220I-.js} +1 -1
  35. package/dist/gateway/static/root/assets/{command-palette-api-CP0F6sIm.js → command-palette-api-CkJ6_Yf3.js} +1 -1
  36. package/dist/gateway/static/root/assets/composer-handoff-params-GKGdXjMZ.js +1 -0
  37. package/dist/gateway/static/root/assets/{composer-model-config-control-DAagrRx_.js → composer-model-config-control-DQCOWHzJ.js} +1 -1
  38. package/dist/gateway/static/root/assets/{composer-notifications-CqV6Xj-H.js → composer-notifications-D__OU_xx.js} +1 -1
  39. package/dist/gateway/static/root/assets/{composer-payload-handoff-Dc43dgSg.js → composer-payload-handoff-BBTbJ1bO.js} +1 -1
  40. package/dist/gateway/static/root/assets/{computer-settings-page-f-vcEpeF.js → computer-settings-page-DGRUCkOt.js} +1 -1
  41. package/dist/gateway/static/root/assets/{connected-providers-grid-CZ-FXxaW.js → connected-providers-grid-BoDipD2g.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connection-usage-guide-Cibh2lrV.js → connection-usage-guide-B1VUqibv.js} +1 -1
  43. package/dist/gateway/static/root/assets/{connector-service-page-Btz68iy8.js → connector-service-page-bwQ1PekA.js} +1 -1
  44. package/dist/gateway/static/root/assets/{connectors-api-CTuVWwBf.js → connectors-api-BvYGL65q.js} +1 -1
  45. package/dist/gateway/static/root/assets/{connectors-page-B9mpz_Rt.js → connectors-page-BX6Jt6w5.js} +1 -1
  46. package/dist/gateway/static/root/assets/{date-picker-XnE3iFhG.js → date-picker-ClRDaNBJ.js} +1 -1
  47. package/dist/gateway/static/root/assets/{date-time-picker-VGKm0HVn.js → date-time-picker-CA6H47M6.js} +1 -1
  48. package/dist/gateway/static/root/assets/{desktop-pet-CBm3DySQ.js → desktop-pet-Bi8Hgf-x.js} +1 -1
  49. package/dist/gateway/static/root/assets/{desktop-pet-settings-6O77QXGo.js → desktop-pet-settings-CQ6qE8lf.js} +1 -1
  50. package/dist/gateway/static/root/assets/{dev-view-store-B8fGILny.js → dev-view-store-UCqQeWa2.js} +1 -1
  51. package/dist/gateway/static/root/assets/{device-pairing-wizard-qtUvtdDT.js → device-pairing-wizard-gC-XZxt2.js} +1 -1
  52. package/dist/gateway/static/root/assets/{directory-picker-path-field-ByDqf5fE.js → directory-picker-path-field-Y8snl5Xl.js} +1 -1
  53. package/dist/gateway/static/root/assets/{extension-authoritative-grants-BfL8dMBf.js → extension-authoritative-grants-D2abOXTl.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-debug-page-Bn_5xu_M.js → extension-debug-page-OOlRCInL.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-iframe-host-Vs6USa0c.js → extension-iframe-host-D_WXBf6a.js} +1 -1
  56. package/dist/gateway/static/root/assets/{extension-marketplace-api-BIzkukYp.js → extension-marketplace-api-Bmtm6-L1.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-message-router-GIekDj_w.js → extension-message-router-xqjjSxcp.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-page-C_3bIjSB.js → extension-page-bpQnyNz-.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-provider-D-LolObs.js → extension-provider-l7SvHEK1.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-settings-page-BV51dk16.js → extension-settings-page-DKAJE4h9.js} +1 -1
  61. package/dist/gateway/static/root/assets/{file-preview-surface-i5UOFnQF.js → file-preview-surface-B-r2ZnCV.js} +1 -1
  62. package/dist/gateway/static/root/assets/{gateway-config-swr-1Rk0LeEM.js → gateway-config-swr-DOwezeL2.js} +1 -1
  63. package/dist/gateway/static/root/assets/{gateway-realtime-DIs1pjkQ.js → gateway-realtime-Br7dErHY.js} +1 -1
  64. package/dist/gateway/static/root/assets/gateway-realtime-store-OaEqjNTb.js +1 -0
  65. package/dist/gateway/static/root/assets/{gateway-restart-DTmlcJps.js → gateway-restart-B3Xro3qd.js} +1 -1
  66. package/dist/gateway/static/root/assets/{gateway-settings-ClcCloqQ.js → gateway-settings-DCnP-HPj.js} +1 -1
  67. package/dist/gateway/static/root/assets/{gateway-startup-retry-D6WPS0RW.js → gateway-startup-retry-vteSIhYI.js} +1 -1
  68. package/dist/gateway/static/root/assets/{global-defaults-api-BpDMnJe7.js → global-defaults-api-Bpje9rVk.js} +1 -1
  69. package/dist/gateway/static/root/assets/grip-horizontal-CqVA8V1e.js +1 -0
  70. package/dist/gateway/static/root/assets/home-page-CNEgNWEQ.js +8 -0
  71. package/dist/gateway/static/root/assets/{image-generation-api-sbtx4NiC.js → image-generation-api-BvpAa3Lj.js} +1 -1
  72. package/dist/gateway/static/root/assets/{imports-page-CBlaxUhl.js → imports-page-Dx5T5pqw.js} +1 -1
  73. package/dist/gateway/static/root/assets/index-BGA-G-Bp.css +1 -0
  74. package/dist/gateway/static/root/assets/index-pmlYYCCU.js +11 -0
  75. package/dist/gateway/static/root/assets/{install-connector-dialog-DxSv1wS2.js → install-connector-dialog-Cb4ufypG.js} +1 -1
  76. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CnAV96nr.js → keyboard-shortcuts-settings-BEuXrnv0.js} +1 -1
  77. package/dist/gateway/static/root/assets/{local-app-workbench-page-CfnixDO3.js → local-app-workbench-page-CPFIbEbv.js} +1 -1
  78. package/dist/gateway/static/root/assets/{local-apps-page-BI3Be5qo.js → local-apps-page-DxHcRSxc.js} +1 -1
  79. package/dist/gateway/static/root/assets/local-session-drafts-Cmc-GCVa.js +4 -0
  80. package/dist/gateway/static/root/assets/{locale-store-Dy1EByeG.js → locale-store-tI9VX7dp.js} +1 -1
  81. package/dist/gateway/static/root/assets/{logs-page-CMW34T31.js → logs-page-BcibwftP.js} +1 -1
  82. package/dist/gateway/static/root/assets/{management-api-B5w5DdXH.js → management-api-C9tFjLcE.js} +1 -1
  83. package/dist/gateway/static/root/assets/{management-settings-DfcMIqbQ.js → management-settings-DbnAlXoB.js} +1 -1
  84. package/dist/gateway/static/root/assets/{markdown-view-CNJaAdNN.js → markdown-view-CSpQhSka.js} +1 -1
  85. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-DCIEL5bA.js → mcp-conversation-setup-page-DedbjJbF.js} +1 -1
  86. package/dist/gateway/static/root/assets/{media-plugins-DGhWjPIU.js → media-plugins-BYnP_orq.js} +1 -1
  87. package/dist/gateway/static/root/assets/{messages-BAnhwALN.js → messages-e5MhDONm.js} +2 -2
  88. package/dist/gateway/static/root/assets/{model-selector-C-CqPBao.js → model-selector-B4oTiJI6.js} +1 -1
  89. package/dist/gateway/static/root/assets/{models-hub-cache-Bgh3Gfgl.js → models-hub-cache-DpEClnsE.js} +1 -1
  90. package/dist/gateway/static/root/assets/{note-detail-panel-DsXb1qjW.js → note-detail-panel-D8asMfBm.js} +3 -3
  91. package/dist/gateway/static/root/assets/note-image-lightbox-DcDw5kp4.js +1 -0
  92. package/dist/gateway/static/root/assets/{notes-api-BOIM9Q_D.js → notes-api-pVC1amyp.js} +1 -1
  93. package/dist/gateway/static/root/assets/{notes-page-BTpiOw67.js → notes-page-CG1_6PLz.js} +1 -1
  94. package/dist/gateway/static/root/assets/{oauth-api-B560CHeD.js → oauth-api-BsVPwufr.js} +1 -1
  95. package/dist/gateway/static/root/assets/{oauth-provider-connect-D63M8Iv7.js → oauth-provider-connect-Bu20kmPq.js} +1 -1
  96. package/dist/gateway/static/root/assets/{page-context-capture-button-B_Vdo2Ai.js → page-context-capture-button-CDsnNXjS.js} +1 -1
  97. package/dist/gateway/static/root/assets/{page-context-draft-Cr5GqS2D.js → page-context-draft-D6tu8c_9.js} +1 -1
  98. package/dist/gateway/static/root/assets/page-header-store-DeaRqZgV.js +1 -0
  99. package/dist/gateway/static/root/assets/panels-top-left-BKvp2Dag.js +1 -0
  100. package/dist/gateway/static/root/assets/{personal-avatar-BMRVyTrE.js → personal-avatar-BboNc6e2.js} +1 -1
  101. package/dist/gateway/static/root/assets/{personal-page-I3IGVSJh.js → personal-page-gMRmLCWG.js} +1 -1
  102. package/dist/gateway/static/root/assets/{personal-profile-settings-C4CxmQLQ.js → personal-profile-settings-Cd4QyseL.js} +1 -1
  103. package/dist/gateway/static/root/assets/{personal-settings-panel-CnxI2TL0.js → personal-settings-panel-CtBY_Uk1.js} +1 -1
  104. package/dist/gateway/static/root/assets/{phone-dependencies-card-flTci8mm.js → phone-dependencies-card-BgH1LluB.js} +1 -1
  105. package/dist/gateway/static/root/assets/{phone-model-connection-Vi_Swyv6.js → phone-model-connection-DkdKU5Kv.js} +1 -1
  106. package/dist/gateway/static/root/assets/{phone-model-picker-BOv3mb_F.js → phone-model-picker-0g1z4RPL.js} +1 -1
  107. package/dist/gateway/static/root/assets/{phone-settings-page-vD0bTcHj.js → phone-settings-page-DlIUajBY.js} +1 -1
  108. package/dist/gateway/static/root/assets/{phone-workspace-store-Ltrevdsx.js → phone-workspace-store-DW2sZtkh.js} +1 -1
  109. package/dist/gateway/static/root/assets/{plugin-details-dialog-F08k_k2u.js → plugin-details-dialog-9KUkZk_t.js} +1 -1
  110. package/dist/gateway/static/root/assets/{preference-select-fields-D1pZekPs.js → preference-select-fields-DH5QZhIc.js} +1 -1
  111. package/dist/gateway/static/root/assets/{product-automation-feedback-CGso8wGv.js → product-automation-feedback-a1thJ0M9.js} +1 -1
  112. package/dist/gateway/static/root/assets/{product-open-page-BO8lUvw3.js → product-open-page-DCzQh7tr.js} +1 -1
  113. package/dist/gateway/static/root/assets/{product-preview-content-Dgtb4LF7.js → product-preview-content-C5TLcagj.js} +1 -1
  114. package/dist/gateway/static/root/assets/{product-preview-modal-C35EWUps.js → product-preview-modal-D9f-7kcI.js} +2 -2
  115. package/dist/gateway/static/root/assets/{project-detail-page-Dy46uSEt.js → project-detail-page-C4Z2HTRZ.js} +2 -2
  116. package/dist/gateway/static/root/assets/{project-understanding-Cg8WbBNB.js → project-understanding-CoPBvlqf.js} +1 -1
  117. package/dist/gateway/static/root/assets/{projects-page-C6Pt6OdT.js → projects-page-k1v8Fry8.js} +1 -1
  118. package/dist/gateway/static/root/assets/{providers-api-Nytkkop9.js → providers-api-BSJZyO8n.js} +1 -1
  119. package/dist/gateway/static/root/assets/{recording-upload-CFX7CANT.js → recording-upload-CExCePtr.js} +1 -1
  120. package/dist/gateway/static/root/assets/{registry-api-DuDIthjL.js → registry-api-CqcJj60w.js} +1 -1
  121. package/dist/gateway/static/root/assets/{remote-access-hub-DePwafOK.js → remote-access-hub-BLFkNl1y.js} +1 -1
  122. package/dist/gateway/static/root/assets/{resource-unavailable-BRKhKJA0.js → resource-unavailable-B_BXTQa7.js} +1 -1
  123. package/dist/gateway/static/root/assets/{right-workspace-store-HPw7Gw0n.js → right-workspace-store-OceFhUjM.js} +1 -1
  124. package/dist/gateway/static/root/assets/route-preload-5iwjWERk.js +2 -0
  125. package/dist/gateway/static/root/assets/{routine-panel-KH1VaEdC.js → routine-panel-BsE9o9uu.js} +2 -2
  126. package/dist/gateway/static/root/assets/{runtime-tools-api-Dd8a07eo.js → runtime-tools-api-aAZChVm4.js} +1 -1
  127. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CvHQoqHu.js → runtime-tools-settings-panel-Bn9HTrK5.js} +1 -1
  128. package/dist/gateway/static/root/assets/{service-recommendation-list-BmRtbJz2.js → service-recommendation-list-BNIVRGDf.js} +1 -1
  129. package/dist/gateway/static/root/assets/{session-api-BFiIYodK.js → session-api-DdW7Wix2.js} +1 -1
  130. package/dist/gateway/static/root/assets/session-channel-icon-DUJbB-Km.js +1 -0
  131. package/dist/gateway/static/root/assets/{session-identity-label-D5SAi0Uh.js → session-identity-label-DjhlQ6LU.js} +1 -1
  132. package/dist/gateway/static/root/assets/session-manager-XgtApqIh.js +25 -0
  133. package/dist/gateway/static/root/assets/sessions-page-CfhKeUkZ.js +1 -0
  134. package/dist/gateway/static/root/assets/settings-advanced-gate-BBG8dTIY.js +1 -0
  135. package/dist/gateway/static/root/assets/{settings-advanced-section-B-H1gYOs.js → settings-advanced-section-BOoJfJuB.js} +1 -1
  136. package/dist/gateway/static/root/assets/{settings-mode-store-YH60sibB.js → settings-mode-store-BMh_BQ9a.js} +1 -1
  137. package/dist/gateway/static/root/assets/{settings-page-C39lKVRv.js → settings-page-DNiRlM5x.js} +1 -1
  138. package/dist/gateway/static/root/assets/{settings-page-header-DEZZ8D0S.js → settings-page-header-Bfu4cuQd.js} +1 -1
  139. package/dist/gateway/static/root/assets/{settings-page-layout-De2j64Lo.js → settings-page-layout-BnZa1qHH.js} +1 -1
  140. package/dist/gateway/static/root/assets/{setup-interaction-page-Dh6BPwv0.js → setup-interaction-page-CVlrVNrm.js} +1 -1
  141. package/dist/gateway/static/root/assets/{setup-status-panel-DGAAczL-.js → setup-status-panel-FFyDODEx.js} +1 -1
  142. package/dist/gateway/static/root/assets/{share-link-dialog-C1t_HB6f.js → share-link-dialog-Cv-eDEw_.js} +1 -1
  143. package/dist/gateway/static/root/assets/{share-preview-page-Cqy-7-rd.js → share-preview-page-BctH6eFs.js} +1 -1
  144. package/dist/gateway/static/root/assets/{shares-api-Dm07CnXw.js → shares-api-cLTEcQLE.js} +1 -1
  145. package/dist/gateway/static/root/assets/shares-settings-DcetAN8K.js +1 -0
  146. package/dist/gateway/static/root/assets/{skill-api-BV8oFqeE.js → skill-api-CgEZJoy9.js} +1 -1
  147. package/dist/gateway/static/root/assets/{skill-list-api-1o_YRCu9.js → skill-list-api-BWVr2PL5.js} +1 -1
  148. package/dist/gateway/static/root/assets/{skill-reload-api-fGsO9Y86.js → skill-reload-api-BLhHNvaK.js} +1 -1
  149. package/dist/gateway/static/root/assets/{skills-page-DReUQ4Ug.js → skills-page-DIjcAvA0.js} +1 -1
  150. package/dist/gateway/static/root/assets/sliding-segmented-DagP0myu.js +1 -0
  151. package/dist/gateway/static/root/assets/{system-settings-panel-CUI6QHEP.js → system-settings-panel-C7LAPaN_.js} +1 -1
  152. package/dist/gateway/static/root/assets/{task-detail-page-D1dNWTnP.js → task-detail-page-DmNEMg-l.js} +1 -1
  153. package/dist/gateway/static/root/assets/{task-result-evidence-CW_tN93T.js → task-result-evidence-BsBn3n_l.js} +1 -1
  154. package/dist/gateway/static/root/assets/{terminal-panel-store-Du53Upr2.js → terminal-panel-store-DJbLuUku.js} +1 -1
  155. package/dist/gateway/static/root/assets/{theme-store-BaWep_o7.js → theme-store-QGcjV6pN.js} +1 -1
  156. package/dist/gateway/static/root/assets/{tracing-settings-page-CnciBMVH.js → tracing-settings-page-BKCiPwYL.js} +1 -1
  157. package/dist/gateway/static/root/assets/{tunnel-api-Iz7JCBt3.js → tunnel-api-S7J5Lpzt.js} +1 -1
  158. package/dist/gateway/static/root/assets/{understanding-activity-store-BFc8PamJ.js → understanding-activity-store-BNVhtJkn.js} +1 -1
  159. package/dist/gateway/static/root/assets/{understanding-refresh-store-CdEfR40A.js → understanding-refresh-store-Cf0DUO_C.js} +1 -1
  160. package/dist/gateway/static/root/assets/undo-2-6IMTwK4M.js +1 -0
  161. package/dist/gateway/static/root/assets/{unlink-BEuthaaq.js → unlink-NsCMuCT1.js} +1 -1
  162. package/dist/gateway/static/root/assets/{usage-page-DL2fmeOh.js → usage-page-D-AqzjIx.js} +1 -1
  163. package/dist/gateway/static/root/assets/{use-autosave-N_SjHXTw.js → use-autosave-CqZbhhCc.js} +1 -1
  164. package/dist/gateway/static/root/assets/use-composer-attachments-BfLhIb2_.js +2 -0
  165. package/dist/gateway/static/root/assets/{use-file-preview-expanded-D0IBFhM9.js → use-file-preview-expanded-DufxDues.js} +3 -3
  166. package/dist/gateway/static/root/assets/{use-personal-profile-C1vqD9yV.js → use-personal-profile-RnjxZnLa.js} +1 -1
  167. package/dist/gateway/static/root/assets/{use-realtime-voice-B5IsKrRW.js → use-realtime-voice-w3aHR2dr.js} +1 -1
  168. package/dist/gateway/static/root/assets/{use-workspace-tree-7X2ydgS8.js → use-workspace-tree-2Ck-ql5c.js} +1 -1
  169. package/dist/gateway/static/root/assets/{user-model-page-D2FHjLi7.js → user-model-page-CdB9qH57.js} +1 -1
  170. package/dist/gateway/static/root/assets/{voice-api-key-field-B_GApUQP.js → voice-api-key-field-C4rhpgco.js} +1 -1
  171. package/dist/gateway/static/root/assets/{voice-config-api-DhJ3l8fk.js → voice-config-api-7AHN-ns6.js} +1 -1
  172. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-CEeFBhp3.js → voice-input-shortcut-events-BbRrj833.js} +1 -1
  173. package/dist/gateway/static/root/assets/{voice-settings-57pwZeKD.js → voice-settings-wamtp0lg.js} +1 -1
  174. package/dist/gateway/static/root/assets/{work-discovery-overlay-BJ15p4rH.js → work-discovery-overlay-fVofN7aP.js} +1 -1
  175. package/dist/gateway/static/root/assets/{work-discovery-page-8XciWNs5.js → work-discovery-page-DcQG5GWy.js} +1 -1
  176. package/dist/gateway/static/root/assets/{working-directory-picker-modal-BGZduAXV.js → working-directory-picker-modal-D8Stwszr.js} +1 -1
  177. package/dist/gateway/static/root/assets/{workspace-api-Dd_UDfeo.js → workspace-api-D3iuTdNK.js} +2 -2
  178. package/dist/gateway/static/root/assets/workspace-editor-agent-store-C-J7vr2o.js +1 -0
  179. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-Clj9hMj5.js → workspace-file-preview-dialog-BXbL5Y1h.js} +1 -1
  180. package/dist/gateway/static/root/assets/{workspace-open-location-menu-CvZxU9de.js → workspace-open-location-menu-1gFO_BdL.js} +1 -1
  181. package/dist/gateway/static/root/assets/{workspace-preview-store-imhtuEIP.js → workspace-preview-store-adwmi4nx.js} +1 -1
  182. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Q_jezTUy.js → xopc-cloud-account-card-DhGh4rm7.js} +1 -1
  183. package/dist/gateway/static/root/index.html +97 -93
  184. package/dist/package.js +1 -1
  185. package/dist/packages/gateway-contract/src/session-input-command.js +5 -0
  186. package/dist/src/agent/prompt/response-language.js +9 -1
  187. package/dist/src/agent/prompt/service-prompt-builder.js +3 -0
  188. package/dist/src/cli/commands/gateway/lifecycle.js +2 -2
  189. package/dist/src/cli/commands/update.js +1 -1
  190. package/dist/src/config/schema.d.ts +1 -1
  191. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
  192. package/dist/src/gateway/hono/middleware/auth.js +1 -1
  193. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  194. package/dist/src/gateway/hono/routes/desktop-host.js +1 -1
  195. package/dist/src/gateway/hono/routes/home.js +1 -1
  196. package/dist/src/gateway/hono/routes/imports.js +1 -1
  197. package/dist/src/gateway/hono/routes/personal-agent.js +3 -3
  198. package/dist/src/gateway/hono/routes/update.js +2 -2
  199. package/dist/src/gateway/index.js +1 -1
  200. package/dist/src/gateway/run-loop.js +2 -2
  201. package/dist/src/gateway/service/agent-runner.js +1 -1
  202. package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
  203. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  204. package/dist/src/gateway/service.js +11 -11
  205. package/dist/src/home-intelligence/host.js +5 -5
  206. package/dist/src/i18n/response-language.d.ts +1 -1
  207. package/dist/src/infra/gateway-processes.js +1 -1
  208. package/dist/src/infra/update-restart.js +2 -2
  209. package/dist/src/infra/update-runner.js +2 -2
  210. package/dist/src/infra/update-startup.js +1 -1
  211. package/dist/src/notifications/service.js +2 -2
  212. package/dist/src/phone/stream-gateway.js +1 -1
  213. package/dist/src/storage/sqlite/session-creation-repository.js +6 -1
  214. package/dist/src/user-context/config.d.ts +1 -1
  215. package/package.json +2 -2
  216. package/dist/extensions/demo-memory/src/index.d.ts +0 -6
  217. package/dist/extensions/demo-memory/src/index.js +0 -146
  218. package/dist/extensions/demo-memory/xopc.extension.json +0 -15
  219. package/dist/gateway/static/root/assets/agents-DC0lHtl5.js +0 -77
  220. package/dist/gateway/static/root/assets/automations-workspace-JCQ1IXFk.js +0 -9
  221. package/dist/gateway/static/root/assets/capabilities-page-kPv2dOzf.js +0 -2
  222. package/dist/gateway/static/root/assets/chat-agents-api-CjlzCSmC.js +0 -1
  223. package/dist/gateway/static/root/assets/gateway-realtime-store-sx7B8kdC.js +0 -1
  224. package/dist/gateway/static/root/assets/home-page-DefKShSW.js +0 -8
  225. package/dist/gateway/static/root/assets/index-CChzK_5b.css +0 -1
  226. package/dist/gateway/static/root/assets/index-DUo6H0PC.js +0 -11
  227. package/dist/gateway/static/root/assets/local-session-drafts-BIBHRkpM.js +0 -4
  228. package/dist/gateway/static/root/assets/note-image-lightbox-D6mvMSKr.js +0 -1
  229. package/dist/gateway/static/root/assets/page-header-store-Bm8oxpFR.js +0 -1
  230. package/dist/gateway/static/root/assets/route-preload-ChTaYgpA.js +0 -2
  231. package/dist/gateway/static/root/assets/session-channel-icon-BzkFo-Ci.js +0 -1
  232. package/dist/gateway/static/root/assets/session-manager-63NaXb1s.js +0 -25
  233. package/dist/gateway/static/root/assets/sessions-page-DQEq_VJS.js +0 -1
  234. package/dist/gateway/static/root/assets/settings-advanced-gate-Cvx7DnU8.js +0 -1
  235. package/dist/gateway/static/root/assets/shares-settings-BDr50uTV.js +0 -1
  236. package/dist/gateway/static/root/assets/sliding-segmented-CgQ3BFdb.js +0 -1
  237. package/dist/gateway/static/root/assets/use-composer-attachments-Xn6eUus2.js +0 -2
  238. package/dist/gateway/static/root/assets/workspace-editor-agent-store-DVPJcbuE.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,p as i,r as a}from"./locale-store-Dy1EByeG.js";import{a as o,r as s}from"./voice-CDlC6XMH.js";import{t as c}from"./session-manager-63NaXb1s.js";import{t as l}from"./middleware-Pd0e8Igk.js";import{t as u}from"./composer-notifications-CqV6Xj-H.js";var d=e(t(),1),ee=i()(l(e=>({captions:!0,microphoneId:``,setCaptions:t=>e({captions:t}),setMicrophoneId:t=>e({microphoneId:t})}),{name:`xopc-voice-preferences`}));function te(){let e=ee.getState().microphoneId;return{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...e?{deviceId:{exact:e}}:{}}}function ne(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=(e,n)=>{o||(o=!0,clearTimeout(l),t.removeEventListener(`abort`,c),e===void 0?i(n):a(e))},c=()=>s(t.reason??new DOMException(`Cancelled`,`AbortError`)),l=setTimeout(()=>s(new DOMException(`Voice startup timed out`,`TimeoutError`)),n);e.then(e=>{o?r?.(e):s(void 0,e)},e=>s(e)),t.addEventListener(`abort`,c,{once:!0}),t.aborted&&c()})}function re(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var f=32,p=1481592883,ie=3,ae=1,oe=2,m=1,h=64*1024,g=new TextEncoder,_=new TextDecoder(`utf-8`,{fatal:!0});function se(e){let t=g.encode(e.id);if(!t.length||t.length>160||!Number.isInteger(e.connectionEpoch)||e.connectionEpoch<1||e.connectionEpoch>4294967295||!Number.isInteger(e.seq)||e.seq<1||e.seq>4294967295||!Number.isFinite(e.timestampMs)||e.timestampMs<0||e.durationMs!==20||e.flags<0||e.flags>3||!e.audio.length||e.audio.length%2||f+t.length+e.audio.length>h)throw Error(`Invalid voice media frame`);let n=new Uint8Array(f+t.length+e.audio.length),r=new DataView(n.buffer);return r.setUint32(0,p),r.setUint8(4,ie),r.setUint8(5,e.kind),r.setUint8(6,m),r.setUint8(7,e.flags),r.setUint32(8,e.connectionEpoch),r.setUint32(12,e.seq),r.setFloat64(16,e.timestampMs),r.setUint16(24,e.durationMs),r.setUint16(26,t.length),r.setUint32(28,e.audio.length),n.set(t,f),n.set(e.audio,f+t.length),n}function ce(e,t){if(e.length<=f||e.length>h)throw Error(`Invalid voice media frame`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint8(5),i=n.getUint32(8),a=n.getUint32(12),o=n.getFloat64(16),s=n.getUint16(24),c=n.getUint16(26),l=n.getUint32(28),u=f+c,d=n.getUint8(7);if(n.getUint32(0)!==p||n.getUint8(4)!==ie||r!==t||n.getUint8(6)!==m||d>3||!i||!a||!Number.isFinite(o)||o<0||s!==20||!c||c>160||!l||l%2||u+l!==e.length)throw Error(`Invalid voice media header`);return{kind:r,connectionEpoch:i,id:_.decode(e.subarray(f,u)),seq:a,timestampMs:o,durationMs:s,flags:d,audio:e.slice(u)}}function le(e){let t=ce(e,oe);return{connectionEpoch:t.connectionEpoch,responseId:t.id,seq:t.seq,mediaTimestampMs:t.timestampMs,durationMs:t.durationMs,audio:t.audio}}function ue(e){return se({kind:ae,connectionEpoch:e.connectionEpoch,id:e.utteranceId,seq:e.audioSeq,timestampMs:e.capturedAtMonotonicMs,durationMs:e.durationMs,flags:!!e.start|(e.end?2:0),audio:e.audio})}var de=class{session;eventSeq=0;audioSeq=0;ready=!1;closed=!1;cancelled=new Set;constructor(e){this.session=e}event(e){if(this.closed)throw Error(`Voice session closed`);if(e.sessionId!==this.session.sessionId||e.seq!==this.eventSeq+1)throw Error(`Invalid voice event sequence`);if(this.eventSeq=e.seq,e.type===`session.ready`){if(this.ready||e.payload.connectionEpoch!==this.session.connectionEpoch||e.payload.purpose!==this.session.purpose||e.payload.inputMode!==this.session.inputMode||e.payload.inputFormat.sampleRate!==this.session.inputFormat.sampleRate||e.payload.mode!==this.session.mode||e.payload.route.engine!==this.session.route.engine)throw Error(`Voice session mismatch`);this.ready=!0}e.type===`response.cancelled`&&this.cancel(e.payload.responseId),e.type===`session.closed`&&(this.ready=!1,this.closed=!0)}audio(e){if(!this.ready||e.connectionEpoch!==this.session.connectionEpoch||e.seq!==this.audioSeq+1)throw Error(`Invalid voice audio sequence`);return this.audioSeq=e.seq,!this.cancelled.has(e.responseId)}cancel(e){if(!this.cancelled.has(e)){if(this.cancelled.size>=1e4)throw Error(`Voice response limit exceeded`);this.cancelled.add(e)}}};function v(e,t){return{protocolVersion:3,messageId:crypto.randomUUID(),type:e,sentAt:Date.now(),payload:t}}function y(e){let t=new URL(n(e));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}var fe=class e{socket;session;timingMetrics;receive;heartbeatId;inputRemainder=new Uint8Array;utteranceId=crypto.randomUUID();inputSeq=0;constructor(e,t,n=[]){this.socket=e,this.session=t,this.timingMetrics=n,this.receive=new de(t)}static async preflight(e){return e.purpose===`conversation`&&e.conversationId&&await new c().materialize(e.conversationId,`voice`),(await r(n(`/api/voice/realtime/preflight`),{method:`POST`,signal:e.signal,body:JSON.stringify({purpose:e.purpose,mode:e.mode,naturalBackend:e.naturalBackend,testHiggsVoice:e.testHiggsVoice,conversationId:e.conversationId,supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})})).timingMetrics??[]}static async connect(t){t.signal?.throwIfAborted();let i=await r(n(`/api/voice/realtime/sessions`),{method:`POST`,signal:t.signal,body:JSON.stringify({purpose:t.purpose,...t.language?{language:t.language}:{},...t.purpose===`conversation`&&t.mode!==`natural`&&t.logicalCallId?{openingGreeting:{logicalCallId:t.logicalCallId,initiation:t.recovery?`recovery`:`user`,supportsOutputReady:!0}}:{},...t.mode?{mode:t.mode}:{},...t.naturalBackend?{naturalBackend:t.naturalBackend}:{},...t.testHiggsVoice?{testHiggsVoice:t.testHiggsVoice}:{},...t.conversationId?{conversationId:t.conversationId}:{},supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})}),a=s.parse(i.payload);t.signal?.throwIfAborted();let c=new WebSocket(y(a.websocketPath));c.binaryType=`arraybuffer`;let l=new e(c,a,t.timingMetrics);return await new Promise((e,n)=>{let r=!1,i,s=e=>{r||(r=!0,i!==void 0&&window.clearTimeout(i),c.close(),n(e))};i=window.setTimeout(()=>s(Error(`Realtime voice connection timed out`)),15e3);let u=()=>{r?c.close():s(Error(`Realtime voice connection cancelled`))};if(t.signal?.addEventListener(`abort`,u,{once:!0}),c.addEventListener(`close`,()=>t.signal?.removeEventListener(`abort`,u),{once:!0}),t.signal?.aborted){u();return}c.onerror=()=>s(Error(`Realtime voice connection failed`)),c.onclose=e=>{r?t.onClose?.(e.reason):s(Error(e.reason||`Realtime voice connection closed`))},c.onopen=()=>{c.send(JSON.stringify(v(`session.start`,{sessionId:a.sessionId,ticket:a.ticket})))},c.onmessage=n=>{if(typeof n.data!=`string`){try{let e=le(new Uint8Array(n.data));l.receive.audio(e)&&t.onAudio?.(e.audio.slice().buffer,e.responseId)}catch{c.close(4400,`Invalid voice audio frame`)}return}try{let c=o(JSON.parse(n.data));if(l.receive.event(c),t.onEvent(c),c.type===`session.ready`&&!r){if(c.payload.connectionEpoch!==a.connectionEpoch||c.payload.mode!==a.mode)throw Error(`Voice session mismatch`);r=!0,window.clearTimeout(i),l.startHeartbeat(c.payload.heartbeatIntervalMs),e()}else c.type===`session.error`&&!c.payload.recoverable&&s(Error(c.payload.message))}catch(e){r?c.close(4400,`Invalid voice protocol frame`):s(e instanceof Error?e:Error(String(e)))}}}),l}outputReady(){this.session.openingGreeting?.accepted&&this.sendControl(`session.output_ready`,{connectionEpoch:this.session.connectionEpoch})}sendAudio(e){if(!e.byteLength||this.socket.readyState!==WebSocket.OPEN)return;let t=new Uint8Array(e),n=new Uint8Array(this.inputRemainder.byteLength+t.byteLength);n.set(this.inputRemainder),n.set(t,this.inputRemainder.byteLength);let r=0;for(;r+640<=n.byteLength;){let e=ue({connectionEpoch:this.session.connectionEpoch,utteranceId:this.utteranceId,audioSeq:++this.inputSeq,capturedAtMonotonicMs:performance.now(),durationMs:20,...this.inputSeq===1?{start:!0}:{},audio:n.slice(r,r+640)});this.socket.send(e.buffer),r+=640}this.inputRemainder=n.slice(r)}reportMetric(e,t,n){t===`speech_end_to_audio_scheduled`&&!this.timingMetrics.includes(t)||this.sendControl(`session.metric`,{responseId:e,metric:t,durationMs:Math.min(6e5,Math.max(0,n))})}setInputMuted(e){this.sendControl(`input.mute`,{muted:e}),this.inputRemainder=new Uint8Array,e||(this.utteranceId=crypto.randomUUID(),this.inputSeq=0)}commit(){this.sendControl(`input.commit`,{})}cancelResponse(e){this.sendControl(`response.stop_playback`,{responseId:e})}cancelTask(e){this.sendControl(`task.cancel`,{taskId:e})}acknowledgeAudio(e,t){this.sendControl(`response.audio.played`,{responseId:e,playedDurationMs:Math.floor(t/48)})}stop(e=`user_finished`){this.stopHeartbeat(),this.socket.readyState===WebSocket.OPEN?this.sendControl(`session.stop`,{reason:e}):this.socket.close()}sendControl(e,t){this.socket.readyState===WebSocket.OPEN&&(e===`response.stop_playback`&&`responseId`in t&&this.receive.cancel(t.responseId),this.socket.send(JSON.stringify(v(e,t))))}startHeartbeat(e){this.stopHeartbeat(),this.heartbeatId=window.setInterval(()=>this.sendControl(`session.ping`,{}),e),this.socket.addEventListener(`close`,()=>this.stopHeartbeat(),{once:!0})}stopHeartbeat(){this.heartbeatId!==void 0&&(window.clearInterval(this.heartbeatId),this.heartbeatId=void 0)}},b=1.7,pe=class{context=new AudioContext({sampleRate:24e3,latencyHint:`interactive`});output=this.context.createGain();ringbackOutput=this.context.createGain();limiter=this.context.createDynamicsCompressor();sources=new Set;ringbackSources=new Map;ringbackDelay=null;ringbackInterval=null;ringbackActive=!1;nextStartTime=0;hasStartedAudio=!1;confirmedSpeech=!1;tentativeDuckTimer;constructor(){this.output.gain.value=b,this.limiter.threshold.value=-6,this.limiter.knee.value=6,this.limiter.ratio.value=12,this.limiter.attack.value=.003,this.limiter.release.value=.12,this.output.connect(this.limiter),this.limiter.connect(this.context.destination),this.ringbackOutput.gain.value=0,this.ringbackOutput.connect(this.context.destination)}async start(){await this.context.resume()}get hasPendingAudio(){return this.sources.size>0}startRingback(){this.stopRingback(),this.context.state!==`closed`&&(this.ringbackActive=!0,this.ringbackDelay=setTimeout(()=>{this.ringbackDelay=null,!(!this.ringbackActive||this.context.state!==`running`)&&(this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setValueAtTime(.14,this.context.currentTime),this.playRingbackPulse(),this.ringbackInterval=setInterval(()=>this.playRingbackPulse(),3e3))},500))}playRingbackPulse(){if(!this.ringbackActive||this.context.state!==`running`)return;let e=this.context.currentTime;for(let[t,n]of[392,494].entries()){let r=e+t*.4,i=this.context.createOscillator(),a=this.context.createGain();i.type=`sine`,i.frequency.value=n,a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.5,r+.04),a.gain.setValueAtTime(.5,r+.18),a.gain.linearRampToValueAtTime(0,r+.28),i.connect(a),a.connect(this.ringbackOutput),this.ringbackSources.set(i,a),i.onended=()=>{this.ringbackSources.delete(i),i.disconnect(),a.disconnect()},i.start(r),i.stop(r+.29)}}stopRingback(){if(this.ringbackActive=!1,this.ringbackDelay!==null&&clearTimeout(this.ringbackDelay),this.ringbackInterval!==null&&clearInterval(this.ringbackInterval),this.ringbackDelay=null,this.ringbackInterval=null,this.context.state!==`closed`){this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setTargetAtTime(0,this.context.currentTime,.025);for(let[e,t]of this.ringbackSources){t.gain.cancelScheduledValues(this.context.currentTime),t.gain.setTargetAtTime(0,this.context.currentTime,.02);try{e.stop(this.context.currentTime+.12)}catch{}}}}enqueue(e,t,n=24e3){if(e.byteLength<2||this.context.state===`closed`)return;let r=new DataView(e),i=new Float32Array(Math.floor(e.byteLength/2));for(let e=0;e<i.length;e+=1)i[e]=r.getInt16(e*2,!0)/32768;let a=this.context.createBuffer(1,i.length,n);a.copyToChannel(i,0);let o=this.context.createBufferSource();o.buffer=a,o.connect(this.output);let s=this.hasStartedAudio?.015:.02,c=Math.max(this.context.currentTime+s,this.nextStartTime);return o.start(c),this.hasStartedAudio=!0,this.nextStartTime=c+a.duration,this.sources.add(o),o.onended=()=>{this.sources.delete(o)&&(o.disconnect(),t())},Math.max(0,c-this.context.currentTime)*1e3}duck(e){clearTimeout(this.tentativeDuckTimer),this.tentativeDuckTimer=void 0,this.confirmedSpeech=e,this.setOutputGain(e?.15:1)}duckForVoiceOnset(){this.confirmedSpeech||this.tentativeDuckTimer!==void 0||!this.hasPendingAudio||(this.setOutputGain(.55),this.tentativeDuckTimer=setTimeout(()=>{this.tentativeDuckTimer=void 0,this.setOutputGain(1)},280))}setOutputGain(e){this.context.state!==`closed`&&(this.output.gain.cancelScheduledValues(this.context.currentTime),this.output.gain.setTargetAtTime(b*e,this.context.currentTime,.015))}clear(){for(let e of this.sources){e.onended=null;try{e.stop()}catch{}e.disconnect()}this.sources.clear(),this.nextStartTime=this.context.currentTime,this.hasStartedAudio=!1,this.duck(!1)}async close(){this.stopRingback(),this.clear(),this.output.disconnect(),this.ringbackOutput.disconnect(),this.limiter.disconnect(),this.context.state!==`closed`&&await this.context.close();for(let[e,t]of this.ringbackSources)e.onended=null,e.disconnect(),t.disconnect();this.ringbackSources.clear()}},x=`/assets/pcm-capture-worklet-CpXsv44v.js`,S=16e3;function C(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.min(1,Math.sqrt(t/e.length))}function w(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function me(e,t,n=S){if(t===n)return e;let r=Math.max(1,Math.round(e.length*n/t)),i=new Float32Array(r),a=t/n;for(let t=0;t<r;t+=1){let n=t*a,r=Math.min(e.length-1,Math.floor(n)),o=Math.min(e.length-1,r+1),s=n-r;i[t]=e[r]*(1-s)+e[o]*s}return i}function he(e,t=S){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n+=1)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t+=1){let n=Math.max(-1,Math.min(1,e[t]));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function T(e){let t=new ArrayBuffer(e.length*2),n=new DataView(t);for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,r<0?r*32768:r*32767,!0)}return t}var ge=class{sourceRate;targetRate;pending=new Float32Array;position=0;constructor(e,t=S){if(this.sourceRate=e,this.targetRate=t,e<=0||t<=0)throw Error(`PCM sample rates must be positive`)}push(e){if(e.length===0)return new ArrayBuffer(0);let t=new Float32Array(this.pending.length+e.length);t.set(this.pending),t.set(e,this.pending.length);let n=this.sourceRate/this.targetRate,r=[];for(;this.position+1<t.length;){let e=Math.floor(this.position),i=this.position-e;r.push(t[e]*(1-i)+t[e+1]*i),this.position+=n}let i=Math.min(t.length-1,Math.floor(this.position));return this.pending=t.slice(i),this.position-=i,T(Float32Array.from(r))}flush(){if(this.pending.length===0)return new ArrayBuffer(0);let e=this.pending[Math.min(this.pending.length-1,Math.floor(this.position))];return this.pending=new Float32Array,this.position=0,T(Float32Array.of(e))}},_e=`xopc-pcm-capture`,E=1e3,D=1e4,ve=class e{context;source;node;mutedOutput;options;sampleRate;paused=!1;accepting=!0;processorFailed=!1;stopPromise;flushResolve;constructor(e,t,n,r,i){this.context=e,this.source=t,this.node=n,this.mutedOutput=r,this.options=i,this.sampleRate=e.sampleRate,this.node.port.onmessage=e=>{if(e.data.type===`flushed`){this.flushResolve?.();return}if(!this.accepting||this.paused)return;let t=new Float32Array(e.data.buffer);if(this.options.onSamples(t),this.options.onAudioLevel){let e=C(t);this.options.onAudioLevel({level:e,speaking:e>=(this.options.speechThreshold??.015)})}},this.node.onprocessorerror=()=>{this.processorFailed=!0,this.flushResolve?.()}}static async start(t,n){if(typeof AudioWorkletNode>`u`)throw Error(`PCM audio recording is not supported in this browser`);let r=new AudioContext,i,a,o=new Promise((e,t)=>{a=setTimeout(()=>{t(new DOMException(`PCM audio capture startup timed out`,`TimeoutError`))},D)});try{await Promise.race([r.audioWorklet.addModule(x),o]);let a=r.createMediaStreamSource(t),s=n.frameDurationMs===void 0?void 0:Math.round(r.sampleRate*n.frameDurationMs/1e3),c=new AudioWorkletNode(r,_e,{processorOptions:{frameSamples:s}}),l=r.createGain();return l.gain.value=0,i=new e(r,a,c,l,n),a.connect(c),c.connect(l),l.connect(r.destination),await Promise.race([r.resume(),o]),i}catch(e){throw i?i.cancel():r.close().catch(()=>void 0),e}finally{clearTimeout(a)}}pause(){this.paused=!0}resume(){this.paused=!1}stop(){return this.stopPromise??=this.finish(),this.stopPromise}cancel(){this.accepting&&(this.accepting=!1,this.flushResolve?.(),this.flushResolve=void 0,this.disconnect(),this.context.close().catch(()=>void 0))}async finish(){this.accepting&&(this.processorFailed||await this.flushWorklet(),this.flushResolve=void 0,this.accepting&&(this.accepting=!1,this.disconnect(),await this.context.close().catch(()=>void 0)))}flushWorklet(){return new Promise(e=>{let t=!1,n=()=>{t||(t=!0,globalThis.clearTimeout(r),e())},r=globalThis.setTimeout(n,E);this.flushResolve=n;try{this.node.port.postMessage(`flush`)}catch{n()}})}disconnect(){this.node.port.onmessage=null,this.node.onprocessorerror=null,this.source.disconnect(),this.node.disconnect(),this.mutedOutput.disconnect()}},ye=class e{capture;chunks;stopped=!1;constructor(e,t){this.capture=e,this.chunks=t}static async start(t,n={}){let r=[],i=await ve.start(t,{...n,onSamples:e=>r.push(e)});return new e(i,r)}async stop(){if(this.stopped)return new Blob([],{type:`audio/wav`});this.stopped=!0,await this.capture.stop();let e=me(w(this.chunks),this.capture.sampleRate);return new Blob([he(e)],{type:`audio/wav`})}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.chunks.length=0)}};function O(e){return e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)||e.includes(`mp3`)?`mp3`:e.includes(`wav`)?`wav`:`webm`}async function k(e,t,i,a){let o=e.type||t||`audio/webm`,s=e.type?e:new Blob([e],{type:o}),c=new FormData;c.append(`audio`,s,`recording.${O(o)}`),a&&c.append(`expectedProvider`,a);let l=await r(n(`/api/voice/transcriptions`),{method:`POST`,body:c,...i?{signal:i}:{}});if(!l.payload)throw Error(`Missing transcription payload`);return l.payload}async function be(e){let t=await r(n(`/api/status`),{signal:e});if(!t.voice?.dictation)throw Error(`Missing dictation status`);return t.voice.dictation}function A(){}typeof window<`u`&&(window.addEventListener(`voice-config-changed`,A),window.addEventListener(`config-reload`,A));var j=null;function xe(e){return j&&j!==e?!1:(j=e,!0)}function M(e){j===e&&(j=null)}function Se(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function Ce(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function we(e){return e===`requesting`||e===`connecting`||e===`starting`}async function Te(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function Ee(e){return e instanceof DOMException||e instanceof Error?e.name:``}function De(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=Ee(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function Oe(e){let{disabled:t,chat:i,onTranscript:o}=e,[s,c]=(0,d.useState)(`idle`),[l,ee]=(0,d.useState)(!1),f=(0,d.useRef)(null),p=(0,d.useRef)(null),ie=(0,d.useRef)(void 0),[ae,oe]=(0,d.useState)(0),[m,h]=(0,d.useState)(0),[g,_]=(0,d.useState)(``),[se,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(``),[de,v]=(0,d.useState)([]),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`idle`),[C,w]=(0,d.useState)(null),[me,he]=(0,d.useState)(!1),T=(0,d.useRef)(!1),[_e,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(null),[A,j]=(0,d.useState)(!1),[Oe,ke]=(0,d.useState)(null),N=(0,d.useRef)(void 0),P=(0,d.useRef)(null),[Ae,je]=(0,d.useState)(`dictation`),Me=(0,d.useRef)(Symbol(`voice-capture`)),F=(0,d.useRef)(`idle`),I=(0,d.useRef)(0),L=(0,d.useRef)(null),Ne=(0,d.useRef)(null),R=(0,d.useRef)(null),Pe=(0,d.useRef)(void 0),Fe=(0,d.useRef)(void 0),Ie=(0,d.useRef)(void 0),z=(0,d.useRef)(null),Le=(0,d.useRef)(null),Re=(0,d.useRef)(null),B=(0,d.useRef)(new Map),V=(0,d.useRef)(!1),ze=(0,d.useRef)(()=>{}),Be=(0,d.useRef)(new Map),H=(0,d.useRef)(null),U=(0,d.useRef)(new Set),[Ve,He]=(0,d.useState)([]),Ue=(0,d.useRef)(!1),W=(0,d.useRef)(null),We=(0,d.useRef)(!1),G=(0,d.useRef)(new Set),Ge=(0,d.useRef)(0),Ke=(0,d.useRef)(6e5),qe=(0,d.useRef)(null),K=(0,d.useRef)(null),Je=(0,d.useRef)(o);Je.current=o;let Ye=(0,d.useRef)(e.onTestAudioPlayed);Ye.current=e.onTestAudioPlayed;let q=(0,d.useCallback)(e=>{F.current=e,c(e)},[]),J=(0,d.useCallback)(()=>{qe.current!=null&&(clearInterval(qe.current),qe.current=null)},[]),Y=(0,d.useCallback)(()=>{Le.current?.getTracks().forEach(e=>e.stop()),Le.current=null},[]),X=(0,d.useCallback)(()=>{M(Me.current),I.current+=1,P.current?.abort(),P.current=null,J(),K.current!==null&&clearTimeout(K.current),K.current=null,z.current?.stopRingback(),Y(),f.current?.cancel(),f.current=null,p.current=null,ie.current=void 0,ee(!1),L.current?.cancel(),L.current=null,Ne.current=null,R.current=null;let e=z.current;z.current=null,e?.close(),Re.current=null,oe(0),h(0),_(``),ce(``),ue(``),S(`idle`),w(null),v([]),b(null),W.current=null,G.current.clear(),T.current=!1,he(!1),j(!1),Be.current.clear(),B.current.clear(),V.current=!1,H.current=null,U.current.clear(),He([])},[Y,J]),Z=(0,d.useCallback)(()=>{X(),q(`idle`)},[X,q]),Xe=(0,d.useCallback)(()=>{R.current?.stop(`user_finished`),Z(),E(null),O(null),ke(null)},[Z]),Q=(0,d.useCallback)(async e=>{if(V.current)return;V.current=!0;let t=I.current,a=e??[...B.current.values()].join(` `).trim();if(Y(),J(),L.current?.cancel(),L.current=null,q(`transcribing`),!a){u(`warning`,i.voiceTranscribeEmpty),Z();return}let o=a;try{let e=await r(n(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:a}),signal:AbortSignal.any([P.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(o=e.payload.text)}catch{if(t!==I.current)return;u(`warning`,i.voiceRefinementFailed)}t===I.current&&(Je.current(o),Z())},[Z,i.voiceRefinementFailed,i.voiceTranscribeEmpty,Y,J,q]),Ze=(0,d.useCallback)(async()=>{if(V.current)return;V.current=!0;let e=I.current;J(),q(`transcribing`);try{let t=f.current;if(!p.current&&t){let n=await t.stop();if(e!==I.current)return;p.current=n}if(f.current=null,Y(),e!==I.current)return;let n=p.current;if(!n)throw Error(i.voiceTranscribeEmpty);let r=await k(n,n.type,AbortSignal.any([P.current.signal,AbortSignal.timeout(9e4)]),ie.current);if(e!==I.current)return;V.current=!1,await Q(r.text.trim())}catch(t){if(e!==I.current)return;Y(),V.current=!1,E(t instanceof Error?t.message:i.voiceTranscribeFailed),O(`session`),q(`error`)}},[Q,i.voiceTranscribeEmpty,i.voiceTranscribeFailed,Y,J,q]),Qe=(0,d.useCallback)(e=>{ke(e);let t=F.current;if(!(t===`idle`||t===`error`||V.current)){if(!N.current){if(t===`transcribing`&&e===`input_committed`){Q();return}J(),Y(),L.current?.cancel(),L.current=null,R.current=null,E(i.voiceTranscribeFailed),q(`error`);return}Z()}},[Q,Z,i.voiceTranscribeFailed,Y,J,q]),$e=(0,d.useCallback)(()=>{J(),qe.current=setInterval(()=>{let e=Re.current;if(e===null)return;let t=performance.now()-e;if(oe(Math.max(0,t/1e3)),t>=Ke.current&&F.current===`recording`){if(!N.current){ze.current();return}ke(`session_limit`),R.current?.stop(`user_finished`),Z()}},200)},[Z,J]),$=(0,d.useCallback)(async(e,n,r,o,s=!1,c)=>{if(t||F.current!==`idle`||e===`conversation`&&!r&&!c)return;if(!xe(Me.current)){E(i.callCaptureBusy),e===`dictation`&&u(`error`,i.callCaptureBusy);return}N.current=r;let l=new AbortController;P.current=l,E(null),O(null),ke(null);let d=++I.current,p=()=>d===I.current;je(e),w(e===`conversation`?`preparing`:null),(!s||!Pe.current)&&(Pe.current=crypto.randomUUID()),Fe.current=n,Ie.current=o,ue(``),q(`connecting`);let ae=performance.now(),m=(e,t,n)=>ne(e,l.signal,t,n),g=`permission`;try{if(e===`conversation`){g=`recorder`;let e=new pe;if(z.current=e,await m(e.start(),1e4),!p()){e.close();return}}g=`session`;let t=e===`dictation`?await m(be(l.signal),2e4):null;if(!p())return;if(t?.mode===`unavailable`){let e=Error(i.voiceSttNotConfigured);throw Object.assign(e,{body:{error:{code:`PROVIDER_UNAVAILABLE`}}}),e}let d=t?.mode===`recorded`,ne=e===`conversation`?{mode:n,...o?{naturalBackend:o}:{},...c?{testHiggsVoice:c}:{},conversationId:r}:{},ae=d?[]:await m(fe.preflight({purpose:e,...ne,signal:l.signal}),2e4),se=!1;if(!p())return;g=`permission`;let le=window.electronAPI?.system,de=await m(Te(),5e3);if(!p()||!we(F.current))return;if(le&&de!==`granted`){q(`requesting`);let e=await m(le.requestMicrophone(),6e4);if(!p())return;let t=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||t)throw Error(`Microphone permission denied`)}else!le&&de!==`granted`&&q(`requesting`);if(!p()||!we(F.current))return;q(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),g=`media`;let y=await m(navigator.mediaDevices.getUserMedia({audio:te()}),15e3,e=>e.getTracks().forEach(e=>e.stop()));if(!p()||!we(F.current)){y.getTracks().forEach(e=>e.stop());return}if(Le.current=y,d){g=`recorder`;let e=await m(ye.start(y,{onAudioLevel:({level:e})=>{p()&&h(Math.min(1,e*8))}}),15e3,e=>e.cancel());if(!p()){e.cancel();return}f.current=e,ie.current=t.provider,ee(!0),Ke.current=6e5,Re.current=performance.now(),oe(0),q(`recording`),$e();return}e===`conversation`&&(w(`dialing`),z.current?.startRingback(),K.current=setTimeout(()=>{p()&&(z.current?.stopRingback(),w(`slow`),K.current=null)},12e3)),g=`session`,q(`connecting`),B.current.clear();let x=await m(fe.connect({timingMetrics:ae,logicalCallId:Pe.current,recovery:s,language:a(),purpose:e,signal:l.signal,...ne,onEvent:t=>{if(p()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!re(Be.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&_(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();_(``),ce(n),n&&e===`dictation`&&(B.current.set(t.payload.utteranceId,n),[...B.current.values()].join(` `).length>=2e4&&F.current===`recording`&&ze.current(),ce([...B.current.values()].join(` `)))}if(t.type===`input.speech_started`&&!T.current&&R.current?.session.bargeIn&&H.current&&We.current&&(G.current.size<32&&G.current.add(t.payload.utteranceId),z.current?.duck(!0)),t.type===`input.speech_stopped`&&(W.current=performance.now(),G.current.delete(t.payload.utteranceId)&&G.current.size===0&&z.current?.duck(!1)),t.type===`response.created`){if(H.current){H.current!==t.payload.responseId&&R.current?.cancelResponse(t.payload.responseId);return}H.current=t.payload.responseId,G.current.clear(),z.current?.duck(!1),Ue.current=!1,We.current=!1,Ge.current=0,ue(``),U.current.size||(v([]),b(null)),S(`thinking`)}if(t.type===`task.created`&&(U.current.add(t.payload.taskId),He([...U.current])),t.type===`task.activity`&&U.current.has(t.payload.taskId)){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};v(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&(U.current.delete(t.payload.taskId),He([...U.current]),U.current.size||v([])),t.type===`response.clarification`&&b(t.payload),t.type===`response.text.delta`&&H.current===t.payload.responseId&&(S(`speaking`),ue(e=>e+t.payload.delta)),t.type===`response.audio.started`&&H.current===t.payload.responseId&&S(`speaking`),t.type===`response.done`&&H.current===t.payload.responseId&&(Ue.current=!0,z.current?.hasPendingAudio||(H.current=null,S(`idle`))),t.type===`response.cancelled`&&H.current===t.payload.responseId&&(G.current.clear(),H.current=null,S(`idle`),z.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&u(`warning`,i.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&u(`warning`,i.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let n=t.payload.code===`PROVIDER_UNAVAILABLE`,r=t.payload.code===`CONTEXT_CHANGED`?i.voiceContextChanged:n?i.voiceSttNotConfigured:t.payload.message;E(r),O(`session`),j(n),e===`dictation`&&u(`error`,r,void 0,n?{href:`/settings/capabilities/models?configure=transcription`}:void 0),R.current?.stop(`surface_closed`),e===`conversation`?X():(J(),Y(),L.current?.cancel(),L.current=null,R.current=null),q(`error`)}}},onAudio:(e,t)=>{if(!p())return;let n=H.current;if(!n||t!==n)return;let r=!We.current,i=W.current;r&&(We.current=!0,W.current!==null&&R.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-W.current),W.current=null);let a=z.current?.enqueue(e,()=>{H.current===n&&(Ge.current+=e.byteLength,R.current?.acknowledgeAudio(n,Ge.current),c&&!se&&new Int16Array(e).some(e=>Math.abs(e)>96)&&(se=!0,Ye.current?.()),Ue.current&&!z.current?.hasPendingAudio&&(H.current=null,S(`idle`)))});r&&i!==null&&a!==void 0&&R.current?.reportMetric(n,`speech_end_to_audio_scheduled`,performance.now()-i+a)},onClose:e=>{p()&&Qe(e)}}),2e4,e=>e.stop(`surface_closed`));if(!p()){x.stop(`surface_closed`);return}z.current?.stopRingback(),K.current!==null&&clearTimeout(K.current),K.current=null,R.current=x,Ke.current=x.session.limits.maxSessionMs,g=`recorder`,q(`starting`);let C,me=[],he=e===`conversation`&&y.getAudioTracks()[0]?.getSettings?.().echoCancellation===!0,_e=.005,D=0,k=0,A=!1,xe=0,M=await m(ve.start(y,{frameDurationMs:20,onSamples:e=>{if(!p()||T.current)return;if(!C){me.push(e);return}let t=(Ne.current??C).push(e);t&&x.sendAudio(t)},onAudioLevel:({level:e})=>{if(p()){if(T.current){D=k=0,A=!1;return}if(xe++%2==0&&h(Math.min(1,e*8)),!(!he||!x.session.bargeIn)){if(!H.current||!We.current||!z.current?.hasPendingAudio){e<.02&&(_e+=(e-_e)*.05),D=k=0,A=!1;return}e>=Math.max(.022,_e*3)?(k=0,!A&&++D>=3&&(A=!0,z.current.duckForVoiceOnset())):(D=0,++k>=6&&(A=!1))}}}}),15e3,e=>e.cancel());if(!p()||!we(F.current)){M.cancel(),x.stop(`surface_closed`),y.getTracks().forEach(e=>e.stop());return}if(L.current=M,e===`conversation`&&(await m(z.current.start(),1e4),!p()))return;x.outputReady(),C=new ge(M.sampleRate,x.session.inputFormat.sampleRate),Ne.current=C;for(let e of me)x.sendAudio(C.push(e));Re.current=performance.now(),oe(0),q(`recording`),w(null),$e()}catch(t){if(!p())return;let n=De(g,t);console.error(`[chat:voice] realtime capture start failed`,{stage:g,durationMs:Math.round(performance.now()-ae),kind:n,errorName:Ee(t),errorMessage:t instanceof Error?t.message:String(t)}),R.current?.stop(`surface_closed`),X(),q(n===`session`?`error`:`idle`);let r=n===`session`&&Se(t),a=Ee(t)===`TimeoutError`?g===`session`?i.voiceConnectionTimeout:i.voiceMicrophoneTimeout:n===`permission`?i.voiceMicDenied:n===`device`?i.voiceMicUnavailable:n===`recorder`?i.voiceRecorderFailed:r?i.voiceSttNotConfigured:t instanceof Error?t.message:i.voiceSttNotConfigured;E(a),O(n),j(r),e===`dictation`&&u(`error`,a,void 0,r?{href:`/settings/capabilities/models?configure=transcription`}:void 0)}},[t,Qe,i,X,$e,Y,J,q]),et=(0,d.useCallback)(()=>{if(N.current)return;if(f.current||p.current){Ze();return}if(F.current===`error`&&B.current.size){Q();return}if(F.current!==`recording`)return;q(`transcribing`),J(),Y();let e=L.current,t=I.current;L.current=null,e?.stop().then(()=>{if(t!==I.current)return;let e=Ne.current?.flush();e&&R.current?.sendAudio(e),R.current?.commit()}).catch(()=>{t===I.current&&(u(`error`,i.voiceTranscribeFailed),R.current?.stop(`surface_closed`),X(),q(`error`))})},[Q,Ze,i.voiceTranscribeFailed,X,Y,J,q]);ze.current=et,(0,d.useEffect)(()=>()=>{M(Me.current),I.current+=1,P.current?.abort(),f.current?.cancel(),p.current=null,L.current?.cancel(),R.current?.stop(`surface_closed`),z.current?.close(),K.current!==null&&clearTimeout(K.current),Y(),J()},[Y,J]);let tt=(0,d.useCallback)(()=>{if(F.current===`error`){if(p.current){Ze();return}X(),q(`idle`),$(Ae,Fe.current,N.current,Ie.current,!0)}},[$,Ze,Ae,X,q]),nt=(0,d.useCallback)(()=>$(`dictation`),[$]),rt=(0,d.useCallback)((e,t,n)=>$(`conversation`,t,e,n),[$]),it=(0,d.useCallback)(e=>$(`conversation`,`natural`,void 0,void 0,!1,e),[$]),at=(0,d.useCallback)(()=>{let e=performance.now(),t=H.current;z.current?.clear(),G.current.clear(),H.current=null,S(`idle`),t&&(R.current?.reportMetric(t,`local_stop`,performance.now()-e),R.current?.cancelResponse(t))},[]),ot=(0,d.useCallback)(()=>{let e=!T.current;T.current=e,e&&(G.current.clear(),z.current?.duck(!1)),Le.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=L.current,n=R.current;t&&n&&(Ne.current=new ge(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),_(``),h(0),z.current?.duck(!1),he(e)},[]);return{phase:s,voiceActive:s!==`idle`,recordedDictation:l,elapsedLabel:Ce(ae),audioLevel:m,partialTranscript:g,finalTranscript:se,responseText:le,activeTaskIds:Ve,cancelTask:e=>{U.current.has(e)&&R.current?.cancelTask(e)},activities:de,clarification:y,dismissClarification:e=>b(t=>t?.requestId===e?null:t),responsePhase:x,callConnectionStage:C,muted:me,error:_e,failureKind:D,settingsRequired:A,endedReason:Oe,mode:Ae,startVoiceInput:nt,startVoiceConversation:rt,startHiggsTest:it,interruptResponse:at,toggleMute:ot,cancelVoiceInput:Xe,confirmVoiceInput:et,retryVoiceInput:tt}}export{ve as a,he as c,fe as d,ee as f,be as i,me as l,xe as n,ge as o,te as p,M as r,C as s,Oe as t,pe as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,p as i,r as a}from"./locale-store-tI9VX7dp.js";import{a as o,r as s}from"./voice-CDlC6XMH.js";import{t as c}from"./session-manager-XgtApqIh.js";import{t as l}from"./middleware-Pd0e8Igk.js";import{t as u}from"./composer-notifications-D__OU_xx.js";var d=e(t(),1),ee=i()(l(e=>({captions:!0,microphoneId:``,setCaptions:t=>e({captions:t}),setMicrophoneId:t=>e({microphoneId:t})}),{name:`xopc-voice-preferences`}));function te(){let e=ee.getState().microphoneId;return{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...e?{deviceId:{exact:e}}:{}}}function ne(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=(e,n)=>{o||(o=!0,clearTimeout(l),t.removeEventListener(`abort`,c),e===void 0?i(n):a(e))},c=()=>s(t.reason??new DOMException(`Cancelled`,`AbortError`)),l=setTimeout(()=>s(new DOMException(`Voice startup timed out`,`TimeoutError`)),n);e.then(e=>{o?r?.(e):s(void 0,e)},e=>s(e)),t.addEventListener(`abort`,c,{once:!0}),t.aborted&&c()})}function re(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var f=32,p=1481592883,ie=3,ae=1,oe=2,m=1,h=64*1024,g=new TextEncoder,_=new TextDecoder(`utf-8`,{fatal:!0});function se(e){let t=g.encode(e.id);if(!t.length||t.length>160||!Number.isInteger(e.connectionEpoch)||e.connectionEpoch<1||e.connectionEpoch>4294967295||!Number.isInteger(e.seq)||e.seq<1||e.seq>4294967295||!Number.isFinite(e.timestampMs)||e.timestampMs<0||e.durationMs!==20||e.flags<0||e.flags>3||!e.audio.length||e.audio.length%2||f+t.length+e.audio.length>h)throw Error(`Invalid voice media frame`);let n=new Uint8Array(f+t.length+e.audio.length),r=new DataView(n.buffer);return r.setUint32(0,p),r.setUint8(4,ie),r.setUint8(5,e.kind),r.setUint8(6,m),r.setUint8(7,e.flags),r.setUint32(8,e.connectionEpoch),r.setUint32(12,e.seq),r.setFloat64(16,e.timestampMs),r.setUint16(24,e.durationMs),r.setUint16(26,t.length),r.setUint32(28,e.audio.length),n.set(t,f),n.set(e.audio,f+t.length),n}function ce(e,t){if(e.length<=f||e.length>h)throw Error(`Invalid voice media frame`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint8(5),i=n.getUint32(8),a=n.getUint32(12),o=n.getFloat64(16),s=n.getUint16(24),c=n.getUint16(26),l=n.getUint32(28),u=f+c,d=n.getUint8(7);if(n.getUint32(0)!==p||n.getUint8(4)!==ie||r!==t||n.getUint8(6)!==m||d>3||!i||!a||!Number.isFinite(o)||o<0||s!==20||!c||c>160||!l||l%2||u+l!==e.length)throw Error(`Invalid voice media header`);return{kind:r,connectionEpoch:i,id:_.decode(e.subarray(f,u)),seq:a,timestampMs:o,durationMs:s,flags:d,audio:e.slice(u)}}function le(e){let t=ce(e,oe);return{connectionEpoch:t.connectionEpoch,responseId:t.id,seq:t.seq,mediaTimestampMs:t.timestampMs,durationMs:t.durationMs,audio:t.audio}}function ue(e){return se({kind:ae,connectionEpoch:e.connectionEpoch,id:e.utteranceId,seq:e.audioSeq,timestampMs:e.capturedAtMonotonicMs,durationMs:e.durationMs,flags:!!e.start|(e.end?2:0),audio:e.audio})}var de=class{session;eventSeq=0;audioSeq=0;ready=!1;closed=!1;cancelled=new Set;constructor(e){this.session=e}event(e){if(this.closed)throw Error(`Voice session closed`);if(e.sessionId!==this.session.sessionId||e.seq!==this.eventSeq+1)throw Error(`Invalid voice event sequence`);if(this.eventSeq=e.seq,e.type===`session.ready`){if(this.ready||e.payload.connectionEpoch!==this.session.connectionEpoch||e.payload.purpose!==this.session.purpose||e.payload.inputMode!==this.session.inputMode||e.payload.inputFormat.sampleRate!==this.session.inputFormat.sampleRate||e.payload.mode!==this.session.mode||e.payload.route.engine!==this.session.route.engine)throw Error(`Voice session mismatch`);this.ready=!0}e.type===`response.cancelled`&&this.cancel(e.payload.responseId),e.type===`session.closed`&&(this.ready=!1,this.closed=!0)}audio(e){if(!this.ready||e.connectionEpoch!==this.session.connectionEpoch||e.seq!==this.audioSeq+1)throw Error(`Invalid voice audio sequence`);return this.audioSeq=e.seq,!this.cancelled.has(e.responseId)}cancel(e){if(!this.cancelled.has(e)){if(this.cancelled.size>=1e4)throw Error(`Voice response limit exceeded`);this.cancelled.add(e)}}};function v(e,t){return{protocolVersion:3,messageId:crypto.randomUUID(),type:e,sentAt:Date.now(),payload:t}}function y(e){let t=new URL(n(e));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}var fe=class e{socket;session;timingMetrics;receive;heartbeatId;inputRemainder=new Uint8Array;utteranceId=crypto.randomUUID();inputSeq=0;constructor(e,t,n=[]){this.socket=e,this.session=t,this.timingMetrics=n,this.receive=new de(t)}static async preflight(e){return e.purpose===`conversation`&&e.conversationId&&await new c().materialize(e.conversationId,`voice`),(await r(n(`/api/voice/realtime/preflight`),{method:`POST`,signal:e.signal,body:JSON.stringify({purpose:e.purpose,mode:e.mode,naturalBackend:e.naturalBackend,testHiggsVoice:e.testHiggsVoice,conversationId:e.conversationId,supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})})).timingMetrics??[]}static async connect(t){t.signal?.throwIfAborted();let i=await r(n(`/api/voice/realtime/sessions`),{method:`POST`,signal:t.signal,body:JSON.stringify({purpose:t.purpose,...t.language?{language:t.language}:{},...t.purpose===`conversation`&&t.mode!==`natural`&&t.logicalCallId?{openingGreeting:{logicalCallId:t.logicalCallId,initiation:t.recovery?`recovery`:`user`,supportsOutputReady:!0}}:{},...t.mode?{mode:t.mode}:{},...t.naturalBackend?{naturalBackend:t.naturalBackend}:{},...t.testHiggsVoice?{testHiggsVoice:t.testHiggsVoice}:{},...t.conversationId?{conversationId:t.conversationId}:{},supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})}),a=s.parse(i.payload);t.signal?.throwIfAborted();let c=new WebSocket(y(a.websocketPath));c.binaryType=`arraybuffer`;let l=new e(c,a,t.timingMetrics);return await new Promise((e,n)=>{let r=!1,i,s=e=>{r||(r=!0,i!==void 0&&window.clearTimeout(i),c.close(),n(e))};i=window.setTimeout(()=>s(Error(`Realtime voice connection timed out`)),15e3);let u=()=>{r?c.close():s(Error(`Realtime voice connection cancelled`))};if(t.signal?.addEventListener(`abort`,u,{once:!0}),c.addEventListener(`close`,()=>t.signal?.removeEventListener(`abort`,u),{once:!0}),t.signal?.aborted){u();return}c.onerror=()=>s(Error(`Realtime voice connection failed`)),c.onclose=e=>{r?t.onClose?.(e.reason):s(Error(e.reason||`Realtime voice connection closed`))},c.onopen=()=>{c.send(JSON.stringify(v(`session.start`,{sessionId:a.sessionId,ticket:a.ticket})))},c.onmessage=n=>{if(typeof n.data!=`string`){try{let e=le(new Uint8Array(n.data));l.receive.audio(e)&&t.onAudio?.(e.audio.slice().buffer,e.responseId)}catch{c.close(4400,`Invalid voice audio frame`)}return}try{let c=o(JSON.parse(n.data));if(l.receive.event(c),t.onEvent(c),c.type===`session.ready`&&!r){if(c.payload.connectionEpoch!==a.connectionEpoch||c.payload.mode!==a.mode)throw Error(`Voice session mismatch`);r=!0,window.clearTimeout(i),l.startHeartbeat(c.payload.heartbeatIntervalMs),e()}else c.type===`session.error`&&!c.payload.recoverable&&s(Error(c.payload.message))}catch(e){r?c.close(4400,`Invalid voice protocol frame`):s(e instanceof Error?e:Error(String(e)))}}}),l}outputReady(){this.session.openingGreeting?.accepted&&this.sendControl(`session.output_ready`,{connectionEpoch:this.session.connectionEpoch})}sendAudio(e){if(!e.byteLength||this.socket.readyState!==WebSocket.OPEN)return;let t=new Uint8Array(e),n=new Uint8Array(this.inputRemainder.byteLength+t.byteLength);n.set(this.inputRemainder),n.set(t,this.inputRemainder.byteLength);let r=0;for(;r+640<=n.byteLength;){let e=ue({connectionEpoch:this.session.connectionEpoch,utteranceId:this.utteranceId,audioSeq:++this.inputSeq,capturedAtMonotonicMs:performance.now(),durationMs:20,...this.inputSeq===1?{start:!0}:{},audio:n.slice(r,r+640)});this.socket.send(e.buffer),r+=640}this.inputRemainder=n.slice(r)}reportMetric(e,t,n){t===`speech_end_to_audio_scheduled`&&!this.timingMetrics.includes(t)||this.sendControl(`session.metric`,{responseId:e,metric:t,durationMs:Math.min(6e5,Math.max(0,n))})}setInputMuted(e){this.sendControl(`input.mute`,{muted:e}),this.inputRemainder=new Uint8Array,e||(this.utteranceId=crypto.randomUUID(),this.inputSeq=0)}commit(){this.sendControl(`input.commit`,{})}cancelResponse(e){this.sendControl(`response.stop_playback`,{responseId:e})}cancelTask(e){this.sendControl(`task.cancel`,{taskId:e})}acknowledgeAudio(e,t){this.sendControl(`response.audio.played`,{responseId:e,playedDurationMs:Math.floor(t/48)})}stop(e=`user_finished`){this.stopHeartbeat(),this.socket.readyState===WebSocket.OPEN?this.sendControl(`session.stop`,{reason:e}):this.socket.close()}sendControl(e,t){this.socket.readyState===WebSocket.OPEN&&(e===`response.stop_playback`&&`responseId`in t&&this.receive.cancel(t.responseId),this.socket.send(JSON.stringify(v(e,t))))}startHeartbeat(e){this.stopHeartbeat(),this.heartbeatId=window.setInterval(()=>this.sendControl(`session.ping`,{}),e),this.socket.addEventListener(`close`,()=>this.stopHeartbeat(),{once:!0})}stopHeartbeat(){this.heartbeatId!==void 0&&(window.clearInterval(this.heartbeatId),this.heartbeatId=void 0)}},b=1.7,pe=class{context=new AudioContext({sampleRate:24e3,latencyHint:`interactive`});output=this.context.createGain();ringbackOutput=this.context.createGain();limiter=this.context.createDynamicsCompressor();sources=new Set;ringbackSources=new Map;ringbackDelay=null;ringbackInterval=null;ringbackActive=!1;nextStartTime=0;hasStartedAudio=!1;confirmedSpeech=!1;tentativeDuckTimer;constructor(){this.output.gain.value=b,this.limiter.threshold.value=-6,this.limiter.knee.value=6,this.limiter.ratio.value=12,this.limiter.attack.value=.003,this.limiter.release.value=.12,this.output.connect(this.limiter),this.limiter.connect(this.context.destination),this.ringbackOutput.gain.value=0,this.ringbackOutput.connect(this.context.destination)}async start(){await this.context.resume()}get hasPendingAudio(){return this.sources.size>0}startRingback(){this.stopRingback(),this.context.state!==`closed`&&(this.ringbackActive=!0,this.ringbackDelay=setTimeout(()=>{this.ringbackDelay=null,!(!this.ringbackActive||this.context.state!==`running`)&&(this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setValueAtTime(.14,this.context.currentTime),this.playRingbackPulse(),this.ringbackInterval=setInterval(()=>this.playRingbackPulse(),3e3))},500))}playRingbackPulse(){if(!this.ringbackActive||this.context.state!==`running`)return;let e=this.context.currentTime;for(let[t,n]of[392,494].entries()){let r=e+t*.4,i=this.context.createOscillator(),a=this.context.createGain();i.type=`sine`,i.frequency.value=n,a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.5,r+.04),a.gain.setValueAtTime(.5,r+.18),a.gain.linearRampToValueAtTime(0,r+.28),i.connect(a),a.connect(this.ringbackOutput),this.ringbackSources.set(i,a),i.onended=()=>{this.ringbackSources.delete(i),i.disconnect(),a.disconnect()},i.start(r),i.stop(r+.29)}}stopRingback(){if(this.ringbackActive=!1,this.ringbackDelay!==null&&clearTimeout(this.ringbackDelay),this.ringbackInterval!==null&&clearInterval(this.ringbackInterval),this.ringbackDelay=null,this.ringbackInterval=null,this.context.state!==`closed`){this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setTargetAtTime(0,this.context.currentTime,.025);for(let[e,t]of this.ringbackSources){t.gain.cancelScheduledValues(this.context.currentTime),t.gain.setTargetAtTime(0,this.context.currentTime,.02);try{e.stop(this.context.currentTime+.12)}catch{}}}}enqueue(e,t,n=24e3){if(e.byteLength<2||this.context.state===`closed`)return;let r=new DataView(e),i=new Float32Array(Math.floor(e.byteLength/2));for(let e=0;e<i.length;e+=1)i[e]=r.getInt16(e*2,!0)/32768;let a=this.context.createBuffer(1,i.length,n);a.copyToChannel(i,0);let o=this.context.createBufferSource();o.buffer=a,o.connect(this.output);let s=this.hasStartedAudio?.015:.02,c=Math.max(this.context.currentTime+s,this.nextStartTime);return o.start(c),this.hasStartedAudio=!0,this.nextStartTime=c+a.duration,this.sources.add(o),o.onended=()=>{this.sources.delete(o)&&(o.disconnect(),t())},Math.max(0,c-this.context.currentTime)*1e3}duck(e){clearTimeout(this.tentativeDuckTimer),this.tentativeDuckTimer=void 0,this.confirmedSpeech=e,this.setOutputGain(e?.15:1)}duckForVoiceOnset(){this.confirmedSpeech||this.tentativeDuckTimer!==void 0||!this.hasPendingAudio||(this.setOutputGain(.55),this.tentativeDuckTimer=setTimeout(()=>{this.tentativeDuckTimer=void 0,this.setOutputGain(1)},280))}setOutputGain(e){this.context.state!==`closed`&&(this.output.gain.cancelScheduledValues(this.context.currentTime),this.output.gain.setTargetAtTime(b*e,this.context.currentTime,.015))}clear(){for(let e of this.sources){e.onended=null;try{e.stop()}catch{}e.disconnect()}this.sources.clear(),this.nextStartTime=this.context.currentTime,this.hasStartedAudio=!1,this.duck(!1)}async close(){this.stopRingback(),this.clear(),this.output.disconnect(),this.ringbackOutput.disconnect(),this.limiter.disconnect(),this.context.state!==`closed`&&await this.context.close();for(let[e,t]of this.ringbackSources)e.onended=null,e.disconnect(),t.disconnect();this.ringbackSources.clear()}},x=`/assets/pcm-capture-worklet-CpXsv44v.js`,S=16e3;function C(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.min(1,Math.sqrt(t/e.length))}function w(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function me(e,t,n=S){if(t===n)return e;let r=Math.max(1,Math.round(e.length*n/t)),i=new Float32Array(r),a=t/n;for(let t=0;t<r;t+=1){let n=t*a,r=Math.min(e.length-1,Math.floor(n)),o=Math.min(e.length-1,r+1),s=n-r;i[t]=e[r]*(1-s)+e[o]*s}return i}function he(e,t=S){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n+=1)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t+=1){let n=Math.max(-1,Math.min(1,e[t]));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function T(e){let t=new ArrayBuffer(e.length*2),n=new DataView(t);for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,r<0?r*32768:r*32767,!0)}return t}var ge=class{sourceRate;targetRate;pending=new Float32Array;position=0;constructor(e,t=S){if(this.sourceRate=e,this.targetRate=t,e<=0||t<=0)throw Error(`PCM sample rates must be positive`)}push(e){if(e.length===0)return new ArrayBuffer(0);let t=new Float32Array(this.pending.length+e.length);t.set(this.pending),t.set(e,this.pending.length);let n=this.sourceRate/this.targetRate,r=[];for(;this.position+1<t.length;){let e=Math.floor(this.position),i=this.position-e;r.push(t[e]*(1-i)+t[e+1]*i),this.position+=n}let i=Math.min(t.length-1,Math.floor(this.position));return this.pending=t.slice(i),this.position-=i,T(Float32Array.from(r))}flush(){if(this.pending.length===0)return new ArrayBuffer(0);let e=this.pending[Math.min(this.pending.length-1,Math.floor(this.position))];return this.pending=new Float32Array,this.position=0,T(Float32Array.of(e))}},_e=`xopc-pcm-capture`,E=1e3,D=1e4,ve=class e{context;source;node;mutedOutput;options;sampleRate;paused=!1;accepting=!0;processorFailed=!1;stopPromise;flushResolve;constructor(e,t,n,r,i){this.context=e,this.source=t,this.node=n,this.mutedOutput=r,this.options=i,this.sampleRate=e.sampleRate,this.node.port.onmessage=e=>{if(e.data.type===`flushed`){this.flushResolve?.();return}if(!this.accepting||this.paused)return;let t=new Float32Array(e.data.buffer);if(this.options.onSamples(t),this.options.onAudioLevel){let e=C(t);this.options.onAudioLevel({level:e,speaking:e>=(this.options.speechThreshold??.015)})}},this.node.onprocessorerror=()=>{this.processorFailed=!0,this.flushResolve?.()}}static async start(t,n){if(typeof AudioWorkletNode>`u`)throw Error(`PCM audio recording is not supported in this browser`);let r=new AudioContext,i,a,o=new Promise((e,t)=>{a=setTimeout(()=>{t(new DOMException(`PCM audio capture startup timed out`,`TimeoutError`))},D)});try{await Promise.race([r.audioWorklet.addModule(x),o]);let a=r.createMediaStreamSource(t),s=n.frameDurationMs===void 0?void 0:Math.round(r.sampleRate*n.frameDurationMs/1e3),c=new AudioWorkletNode(r,_e,{processorOptions:{frameSamples:s}}),l=r.createGain();return l.gain.value=0,i=new e(r,a,c,l,n),a.connect(c),c.connect(l),l.connect(r.destination),await Promise.race([r.resume(),o]),i}catch(e){throw i?i.cancel():r.close().catch(()=>void 0),e}finally{clearTimeout(a)}}pause(){this.paused=!0}resume(){this.paused=!1}stop(){return this.stopPromise??=this.finish(),this.stopPromise}cancel(){this.accepting&&(this.accepting=!1,this.flushResolve?.(),this.flushResolve=void 0,this.disconnect(),this.context.close().catch(()=>void 0))}async finish(){this.accepting&&(this.processorFailed||await this.flushWorklet(),this.flushResolve=void 0,this.accepting&&(this.accepting=!1,this.disconnect(),await this.context.close().catch(()=>void 0)))}flushWorklet(){return new Promise(e=>{let t=!1,n=()=>{t||(t=!0,globalThis.clearTimeout(r),e())},r=globalThis.setTimeout(n,E);this.flushResolve=n;try{this.node.port.postMessage(`flush`)}catch{n()}})}disconnect(){this.node.port.onmessage=null,this.node.onprocessorerror=null,this.source.disconnect(),this.node.disconnect(),this.mutedOutput.disconnect()}},ye=class e{capture;chunks;stopped=!1;constructor(e,t){this.capture=e,this.chunks=t}static async start(t,n={}){let r=[],i=await ve.start(t,{...n,onSamples:e=>r.push(e)});return new e(i,r)}async stop(){if(this.stopped)return new Blob([],{type:`audio/wav`});this.stopped=!0,await this.capture.stop();let e=me(w(this.chunks),this.capture.sampleRate);return new Blob([he(e)],{type:`audio/wav`})}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.chunks.length=0)}};function O(e){return e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)||e.includes(`mp3`)?`mp3`:e.includes(`wav`)?`wav`:`webm`}async function k(e,t,i,a){let o=e.type||t||`audio/webm`,s=e.type?e:new Blob([e],{type:o}),c=new FormData;c.append(`audio`,s,`recording.${O(o)}`),a&&c.append(`expectedProvider`,a);let l=await r(n(`/api/voice/transcriptions`),{method:`POST`,body:c,...i?{signal:i}:{}});if(!l.payload)throw Error(`Missing transcription payload`);return l.payload}async function be(e){let t=await r(n(`/api/status`),{signal:e});if(!t.voice?.dictation)throw Error(`Missing dictation status`);return t.voice.dictation}function A(){}typeof window<`u`&&(window.addEventListener(`voice-config-changed`,A),window.addEventListener(`config-reload`,A));var j=null;function xe(e){return j&&j!==e?!1:(j=e,!0)}function M(e){j===e&&(j=null)}function Se(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function Ce(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function we(e){return e===`requesting`||e===`connecting`||e===`starting`}async function Te(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function Ee(e){return e instanceof DOMException||e instanceof Error?e.name:``}function De(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=Ee(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function Oe(e){let{disabled:t,chat:i,onTranscript:o}=e,[s,c]=(0,d.useState)(`idle`),[l,ee]=(0,d.useState)(!1),f=(0,d.useRef)(null),p=(0,d.useRef)(null),ie=(0,d.useRef)(void 0),[ae,oe]=(0,d.useState)(0),[m,h]=(0,d.useState)(0),[g,_]=(0,d.useState)(``),[se,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(``),[de,v]=(0,d.useState)([]),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`idle`),[C,w]=(0,d.useState)(null),[me,he]=(0,d.useState)(!1),T=(0,d.useRef)(!1),[_e,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(null),[A,j]=(0,d.useState)(!1),[Oe,ke]=(0,d.useState)(null),N=(0,d.useRef)(void 0),P=(0,d.useRef)(null),[Ae,je]=(0,d.useState)(`dictation`),Me=(0,d.useRef)(Symbol(`voice-capture`)),F=(0,d.useRef)(`idle`),I=(0,d.useRef)(0),L=(0,d.useRef)(null),Ne=(0,d.useRef)(null),R=(0,d.useRef)(null),Pe=(0,d.useRef)(void 0),Fe=(0,d.useRef)(void 0),Ie=(0,d.useRef)(void 0),z=(0,d.useRef)(null),Le=(0,d.useRef)(null),Re=(0,d.useRef)(null),B=(0,d.useRef)(new Map),V=(0,d.useRef)(!1),ze=(0,d.useRef)(()=>{}),Be=(0,d.useRef)(new Map),H=(0,d.useRef)(null),U=(0,d.useRef)(new Set),[Ve,He]=(0,d.useState)([]),Ue=(0,d.useRef)(!1),W=(0,d.useRef)(null),We=(0,d.useRef)(!1),G=(0,d.useRef)(new Set),Ge=(0,d.useRef)(0),Ke=(0,d.useRef)(6e5),qe=(0,d.useRef)(null),K=(0,d.useRef)(null),Je=(0,d.useRef)(o);Je.current=o;let Ye=(0,d.useRef)(e.onTestAudioPlayed);Ye.current=e.onTestAudioPlayed;let q=(0,d.useCallback)(e=>{F.current=e,c(e)},[]),J=(0,d.useCallback)(()=>{qe.current!=null&&(clearInterval(qe.current),qe.current=null)},[]),Y=(0,d.useCallback)(()=>{Le.current?.getTracks().forEach(e=>e.stop()),Le.current=null},[]),X=(0,d.useCallback)(()=>{M(Me.current),I.current+=1,P.current?.abort(),P.current=null,J(),K.current!==null&&clearTimeout(K.current),K.current=null,z.current?.stopRingback(),Y(),f.current?.cancel(),f.current=null,p.current=null,ie.current=void 0,ee(!1),L.current?.cancel(),L.current=null,Ne.current=null,R.current=null;let e=z.current;z.current=null,e?.close(),Re.current=null,oe(0),h(0),_(``),ce(``),ue(``),S(`idle`),w(null),v([]),b(null),W.current=null,G.current.clear(),T.current=!1,he(!1),j(!1),Be.current.clear(),B.current.clear(),V.current=!1,H.current=null,U.current.clear(),He([])},[Y,J]),Z=(0,d.useCallback)(()=>{X(),q(`idle`)},[X,q]),Xe=(0,d.useCallback)(()=>{R.current?.stop(`user_finished`),Z(),E(null),O(null),ke(null)},[Z]),Q=(0,d.useCallback)(async e=>{if(V.current)return;V.current=!0;let t=I.current,a=e??[...B.current.values()].join(` `).trim();if(Y(),J(),L.current?.cancel(),L.current=null,q(`transcribing`),!a){u(`warning`,i.voiceTranscribeEmpty),Z();return}let o=a;try{let e=await r(n(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:a}),signal:AbortSignal.any([P.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(o=e.payload.text)}catch{if(t!==I.current)return;u(`warning`,i.voiceRefinementFailed)}t===I.current&&(Je.current(o),Z())},[Z,i.voiceRefinementFailed,i.voiceTranscribeEmpty,Y,J,q]),Ze=(0,d.useCallback)(async()=>{if(V.current)return;V.current=!0;let e=I.current;J(),q(`transcribing`);try{let t=f.current;if(!p.current&&t){let n=await t.stop();if(e!==I.current)return;p.current=n}if(f.current=null,Y(),e!==I.current)return;let n=p.current;if(!n)throw Error(i.voiceTranscribeEmpty);let r=await k(n,n.type,AbortSignal.any([P.current.signal,AbortSignal.timeout(9e4)]),ie.current);if(e!==I.current)return;V.current=!1,await Q(r.text.trim())}catch(t){if(e!==I.current)return;Y(),V.current=!1,E(t instanceof Error?t.message:i.voiceTranscribeFailed),O(`session`),q(`error`)}},[Q,i.voiceTranscribeEmpty,i.voiceTranscribeFailed,Y,J,q]),Qe=(0,d.useCallback)(e=>{ke(e);let t=F.current;if(!(t===`idle`||t===`error`||V.current)){if(!N.current){if(t===`transcribing`&&e===`input_committed`){Q();return}J(),Y(),L.current?.cancel(),L.current=null,R.current=null,E(i.voiceTranscribeFailed),q(`error`);return}Z()}},[Q,Z,i.voiceTranscribeFailed,Y,J,q]),$e=(0,d.useCallback)(()=>{J(),qe.current=setInterval(()=>{let e=Re.current;if(e===null)return;let t=performance.now()-e;if(oe(Math.max(0,t/1e3)),t>=Ke.current&&F.current===`recording`){if(!N.current){ze.current();return}ke(`session_limit`),R.current?.stop(`user_finished`),Z()}},200)},[Z,J]),$=(0,d.useCallback)(async(e,n,r,o,s=!1,c)=>{if(t||F.current!==`idle`||e===`conversation`&&!r&&!c)return;if(!xe(Me.current)){E(i.callCaptureBusy),e===`dictation`&&u(`error`,i.callCaptureBusy);return}N.current=r;let l=new AbortController;P.current=l,E(null),O(null),ke(null);let d=++I.current,p=()=>d===I.current;je(e),w(e===`conversation`?`preparing`:null),(!s||!Pe.current)&&(Pe.current=crypto.randomUUID()),Fe.current=n,Ie.current=o,ue(``),q(`connecting`);let ae=performance.now(),m=(e,t,n)=>ne(e,l.signal,t,n),g=`permission`;try{if(e===`conversation`){g=`recorder`;let e=new pe;if(z.current=e,await m(e.start(),1e4),!p()){e.close();return}}g=`session`;let t=e===`dictation`?await m(be(l.signal),2e4):null;if(!p())return;if(t?.mode===`unavailable`){let e=Error(i.voiceSttNotConfigured);throw Object.assign(e,{body:{error:{code:`PROVIDER_UNAVAILABLE`}}}),e}let d=t?.mode===`recorded`,ne=e===`conversation`?{mode:n,...o?{naturalBackend:o}:{},...c?{testHiggsVoice:c}:{},conversationId:r}:{},ae=d?[]:await m(fe.preflight({purpose:e,...ne,signal:l.signal}),2e4),se=!1;if(!p())return;g=`permission`;let le=window.electronAPI?.system,de=await m(Te(),5e3);if(!p()||!we(F.current))return;if(le&&de!==`granted`){q(`requesting`);let e=await m(le.requestMicrophone(),6e4);if(!p())return;let t=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||t)throw Error(`Microphone permission denied`)}else!le&&de!==`granted`&&q(`requesting`);if(!p()||!we(F.current))return;q(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),g=`media`;let y=await m(navigator.mediaDevices.getUserMedia({audio:te()}),15e3,e=>e.getTracks().forEach(e=>e.stop()));if(!p()||!we(F.current)){y.getTracks().forEach(e=>e.stop());return}if(Le.current=y,d){g=`recorder`;let e=await m(ye.start(y,{onAudioLevel:({level:e})=>{p()&&h(Math.min(1,e*8))}}),15e3,e=>e.cancel());if(!p()){e.cancel();return}f.current=e,ie.current=t.provider,ee(!0),Ke.current=6e5,Re.current=performance.now(),oe(0),q(`recording`),$e();return}e===`conversation`&&(w(`dialing`),z.current?.startRingback(),K.current=setTimeout(()=>{p()&&(z.current?.stopRingback(),w(`slow`),K.current=null)},12e3)),g=`session`,q(`connecting`),B.current.clear();let x=await m(fe.connect({timingMetrics:ae,logicalCallId:Pe.current,recovery:s,language:a(),purpose:e,signal:l.signal,...ne,onEvent:t=>{if(p()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!re(Be.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&_(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();_(``),ce(n),n&&e===`dictation`&&(B.current.set(t.payload.utteranceId,n),[...B.current.values()].join(` `).length>=2e4&&F.current===`recording`&&ze.current(),ce([...B.current.values()].join(` `)))}if(t.type===`input.speech_started`&&!T.current&&R.current?.session.bargeIn&&H.current&&We.current&&(G.current.size<32&&G.current.add(t.payload.utteranceId),z.current?.duck(!0)),t.type===`input.speech_stopped`&&(W.current=performance.now(),G.current.delete(t.payload.utteranceId)&&G.current.size===0&&z.current?.duck(!1)),t.type===`response.created`){if(H.current){H.current!==t.payload.responseId&&R.current?.cancelResponse(t.payload.responseId);return}H.current=t.payload.responseId,G.current.clear(),z.current?.duck(!1),Ue.current=!1,We.current=!1,Ge.current=0,ue(``),U.current.size||(v([]),b(null)),S(`thinking`)}if(t.type===`task.created`&&(U.current.add(t.payload.taskId),He([...U.current])),t.type===`task.activity`&&U.current.has(t.payload.taskId)){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};v(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&(U.current.delete(t.payload.taskId),He([...U.current]),U.current.size||v([])),t.type===`response.clarification`&&b(t.payload),t.type===`response.text.delta`&&H.current===t.payload.responseId&&(S(`speaking`),ue(e=>e+t.payload.delta)),t.type===`response.audio.started`&&H.current===t.payload.responseId&&S(`speaking`),t.type===`response.done`&&H.current===t.payload.responseId&&(Ue.current=!0,z.current?.hasPendingAudio||(H.current=null,S(`idle`))),t.type===`response.cancelled`&&H.current===t.payload.responseId&&(G.current.clear(),H.current=null,S(`idle`),z.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&u(`warning`,i.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&u(`warning`,i.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let n=t.payload.code===`PROVIDER_UNAVAILABLE`,r=t.payload.code===`CONTEXT_CHANGED`?i.voiceContextChanged:n?i.voiceSttNotConfigured:t.payload.message;E(r),O(`session`),j(n),e===`dictation`&&u(`error`,r,void 0,n?{href:`/settings/capabilities/models?configure=transcription`}:void 0),R.current?.stop(`surface_closed`),e===`conversation`?X():(J(),Y(),L.current?.cancel(),L.current=null,R.current=null),q(`error`)}}},onAudio:(e,t)=>{if(!p())return;let n=H.current;if(!n||t!==n)return;let r=!We.current,i=W.current;r&&(We.current=!0,W.current!==null&&R.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-W.current),W.current=null);let a=z.current?.enqueue(e,()=>{H.current===n&&(Ge.current+=e.byteLength,R.current?.acknowledgeAudio(n,Ge.current),c&&!se&&new Int16Array(e).some(e=>Math.abs(e)>96)&&(se=!0,Ye.current?.()),Ue.current&&!z.current?.hasPendingAudio&&(H.current=null,S(`idle`)))});r&&i!==null&&a!==void 0&&R.current?.reportMetric(n,`speech_end_to_audio_scheduled`,performance.now()-i+a)},onClose:e=>{p()&&Qe(e)}}),2e4,e=>e.stop(`surface_closed`));if(!p()){x.stop(`surface_closed`);return}z.current?.stopRingback(),K.current!==null&&clearTimeout(K.current),K.current=null,R.current=x,Ke.current=x.session.limits.maxSessionMs,g=`recorder`,q(`starting`);let C,me=[],he=e===`conversation`&&y.getAudioTracks()[0]?.getSettings?.().echoCancellation===!0,_e=.005,D=0,k=0,A=!1,xe=0,M=await m(ve.start(y,{frameDurationMs:20,onSamples:e=>{if(!p()||T.current)return;if(!C){me.push(e);return}let t=(Ne.current??C).push(e);t&&x.sendAudio(t)},onAudioLevel:({level:e})=>{if(p()){if(T.current){D=k=0,A=!1;return}if(xe++%2==0&&h(Math.min(1,e*8)),!(!he||!x.session.bargeIn)){if(!H.current||!We.current||!z.current?.hasPendingAudio){e<.02&&(_e+=(e-_e)*.05),D=k=0,A=!1;return}e>=Math.max(.022,_e*3)?(k=0,!A&&++D>=3&&(A=!0,z.current.duckForVoiceOnset())):(D=0,++k>=6&&(A=!1))}}}}),15e3,e=>e.cancel());if(!p()||!we(F.current)){M.cancel(),x.stop(`surface_closed`),y.getTracks().forEach(e=>e.stop());return}if(L.current=M,e===`conversation`&&(await m(z.current.start(),1e4),!p()))return;x.outputReady(),C=new ge(M.sampleRate,x.session.inputFormat.sampleRate),Ne.current=C;for(let e of me)x.sendAudio(C.push(e));Re.current=performance.now(),oe(0),q(`recording`),w(null),$e()}catch(t){if(!p())return;let n=De(g,t);console.error(`[chat:voice] realtime capture start failed`,{stage:g,durationMs:Math.round(performance.now()-ae),kind:n,errorName:Ee(t),errorMessage:t instanceof Error?t.message:String(t)}),R.current?.stop(`surface_closed`),X(),q(n===`session`?`error`:`idle`);let r=n===`session`&&Se(t),a=Ee(t)===`TimeoutError`?g===`session`?i.voiceConnectionTimeout:i.voiceMicrophoneTimeout:n===`permission`?i.voiceMicDenied:n===`device`?i.voiceMicUnavailable:n===`recorder`?i.voiceRecorderFailed:r?i.voiceSttNotConfigured:t instanceof Error?t.message:i.voiceSttNotConfigured;E(a),O(n),j(r),e===`dictation`&&u(`error`,a,void 0,r?{href:`/settings/capabilities/models?configure=transcription`}:void 0)}},[t,Qe,i,X,$e,Y,J,q]),et=(0,d.useCallback)(()=>{if(N.current)return;if(f.current||p.current){Ze();return}if(F.current===`error`&&B.current.size){Q();return}if(F.current!==`recording`)return;q(`transcribing`),J(),Y();let e=L.current,t=I.current;L.current=null,e?.stop().then(()=>{if(t!==I.current)return;let e=Ne.current?.flush();e&&R.current?.sendAudio(e),R.current?.commit()}).catch(()=>{t===I.current&&(u(`error`,i.voiceTranscribeFailed),R.current?.stop(`surface_closed`),X(),q(`error`))})},[Q,Ze,i.voiceTranscribeFailed,X,Y,J,q]);ze.current=et,(0,d.useEffect)(()=>()=>{M(Me.current),I.current+=1,P.current?.abort(),f.current?.cancel(),p.current=null,L.current?.cancel(),R.current?.stop(`surface_closed`),z.current?.close(),K.current!==null&&clearTimeout(K.current),Y(),J()},[Y,J]);let tt=(0,d.useCallback)(()=>{if(F.current===`error`){if(p.current){Ze();return}X(),q(`idle`),$(Ae,Fe.current,N.current,Ie.current,!0)}},[$,Ze,Ae,X,q]),nt=(0,d.useCallback)(()=>$(`dictation`),[$]),rt=(0,d.useCallback)((e,t,n)=>$(`conversation`,t,e,n),[$]),it=(0,d.useCallback)(e=>$(`conversation`,`natural`,void 0,void 0,!1,e),[$]),at=(0,d.useCallback)(()=>{let e=performance.now(),t=H.current;z.current?.clear(),G.current.clear(),H.current=null,S(`idle`),t&&(R.current?.reportMetric(t,`local_stop`,performance.now()-e),R.current?.cancelResponse(t))},[]),ot=(0,d.useCallback)(()=>{let e=!T.current;T.current=e,e&&(G.current.clear(),z.current?.duck(!1)),Le.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=L.current,n=R.current;t&&n&&(Ne.current=new ge(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),_(``),h(0),z.current?.duck(!1),he(e)},[]);return{phase:s,voiceActive:s!==`idle`,recordedDictation:l,elapsedLabel:Ce(ae),audioLevel:m,partialTranscript:g,finalTranscript:se,responseText:le,activeTaskIds:Ve,cancelTask:e=>{U.current.has(e)&&R.current?.cancelTask(e)},activities:de,clarification:y,dismissClarification:e=>b(t=>t?.requestId===e?null:t),responsePhase:x,callConnectionStage:C,muted:me,error:_e,failureKind:D,settingsRequired:A,endedReason:Oe,mode:Ae,startVoiceInput:nt,startVoiceConversation:rt,startHiggsTest:it,interruptResponse:at,toggleMute:ot,cancelVoiceInput:Xe,confirmVoiceInput:et,retryVoiceInput:tt}}export{ve as a,he as c,fe as d,ee as f,be as i,me as l,xe as n,ge as o,te as p,M as r,C as s,Oe as t,pe as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-Dd_UDfeo.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-D3iuTdNK.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,m as a,t as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as s,n as c,o as l}from"./locale-store-Dy1EByeG.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-CY7CS_D3.js";import{n as v,t as y}from"./earth-C9Z4bTTG.js";import{t as b}from"./bot-DjLkhyZL.js";import{C as x,S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,m as ee,n as N,o as te,p as P,r as F,s as I,t as L,v as R,w as z,x as B,y as ne}from"./understanding-refresh-store-CdEfR40A.js";import{t as re}from"./briefcase-business-BsoCaI_t.js";import{t as ie}from"./calendar-days-hw_Y-g-s.js";import{t as ae}from"./check-DUBLcKHA.js";import{t as oe}from"./chevron-down-ccbiQQz_.js";import{t as V}from"./chevron-right-BweFrslA.js";import{n as H,r as U,t as W}from"./popover-select-CLsphyzA.js";import{t as se}from"./circle-alert-BEjgurr2.js";import{t as G}from"./circle-check-C23XjkUj.js";import{t as ce}from"./clock-3-DnrAnuyZ.js";import{t as le}from"./database-CjjeZfRG.js";import{t as ue}from"./download-Dk-ZjtO6.js";import{t as de}from"./ellipsis-0k4rZLoy.js";import{m as K,p as q,t as J}from"./understanding-activity-store-BFc8PamJ.js";import{t as fe}from"./folder-open-CyzJ19I9.js";import{t as pe}from"./git-branch-Dh9uxTot.js";import{t as me}from"./list-todo-CTVRto8O.js";import{t as he}from"./loader-circle-CifKLtgG.js";import{t as ge}from"./lock-keyhole-DEK5kH0u.js";import{t as _e}from"./message-circle-Badhj-4D.js";import{t as ve}from"./pencil-DmIY3Oa-.js";import{t as ye}from"./plus-Q2yW6OE7.js";import{t as be}from"./refresh-cw-BRlGaq2w.js";import{t as xe}from"./search-DA7gz22f.js";import{t as Se}from"./shield-check-BU58siTV.js";import{t as Ce}from"./sliders-horizontal-DqsYor6I.js";import{t as we}from"./sparkles-DHlfQFAF.js";import{t as Te}from"./sticky-note-fzP7NAJq.js";import{t as Ee}from"./trash-2-DusmjVPV.js";import{t as De}from"./upload-rrb46c3c.js";import{t as Oe}from"./user-round-C9jxPhMR.js";import{t as ke}from"./x-B_N4OPjy.js";import{t as Ae}from"./cn-0WouolD0.js";import{t as je}from"./skeleton-DzdOeGYz.js";import{i as Me}from"./vendor-swr-CdRzEUwF.js";import{t as Y}from"./button-Cc4hUNTt.js";import{r as Ne}from"./app-chrome-BeB4KgOf.js";import{t as Pe}from"./page-tabs-oeTY7z3_.js";import{t as Fe}from"./page-header-store-Bm8oxpFR.js";import{t as Ie}from"./loopi-CNtmi9FU.js";import{t as Le}from"./sliding-tab-list-CmcrqRzN.js";import{l as Re,m as ze,o as Be,r as Ve,t as He}from"./dist-ZrL34Ps4.js";import{t as Ue}from"./date-picker-XnE3iFhG.js";var X=e(t(),1),Z=n(),Q=r();function We(e){let t=(0,Z.c)(15),{sourceId:n,disabled:r}=e,i=r!==void 0&&r,a=c(qe)===`zh`,{sources:o,starting:s,start:l}=L(),u;t[0]!==n||t[1]!==o?(u=n?o.filter(e=>e.grantId===n):o,t[0]=n,t[1]=o,t[2]=u):u=t[2];let d=u,f;t[3]===d?f=t[4]:(f=d.some(Ke),t[3]=d,t[4]=f);let p=f,m=n&&d.some(Ge),h=p?a?`更新中`:`Updating`:m?a?`重试`:`Retry`:n?a?`更新理解`:`Update understanding`:a?`更新全部`:`Update all`,g=i||s||p,_;t[5]!==n||t[6]!==l?(_=()=>void l(n),t[5]=n,t[6]=l,t[7]=_):_=t[7];let v;t[8]===p?v=t[9]:(v=p?(0,Q.jsx)(he,{className:`size-3.5 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(be,{className:`size-3.5`}),t[8]=p,t[9]=v);let y;return t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==v?(y=(0,Q.jsxs)(Y,{variant:`ghost`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs`,disabled:g,onClick:_,children:[v,h]}),t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y):y=t[14],y}function Ge(e){return e.status===`failed`||e.status===`partial`||e.status===`canceled`}function Ke(e){return e.status===`queued`||e.status===`running`}function qe(e){return e.language}function Je(e){let t=(0,Z.c)(22),{sourceId:n,lastCollectedAt:r}=e,i=c(Ye),a=i===`zh`,o;t[0]===n?o=t[1]:(o=e=>e.sources.find(e=>e.grantId===n),t[0]=n,t[1]=o);let s=L(o);if(!s){let e;t[2]!==i||t[3]!==r||t[4]!==a?(e=r?`${a?`上次更新:`:`Last updated: `}${new Date(r).toLocaleString(i)}`:a?`尚未分析`:`Not analyzed yet`,t[2]=i,t[3]=r,t[4]=a,t[5]=e):e=t[5];let n;return t[6]===e?n=t[7]:(n=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e}),t[6]=e,t[7]=n),n}let l;t[8]===a?l=t[9]:(l=a?{queued:`等待更新`,waiting_desktop:`等待桌面端读取资料`,reading:`正在读取资料`,analyzing:`正在更新理解`}:{queued:`Queued`,waiting_desktop:`Waiting for desktop collection`,reading:`Reading source`,analyzing:`Updating understanding`},t[8]=a,t[9]=l);let u=l,d=s.status===`running`||s.status===`queued`,f=s.status===`failed`||s.status===`partial`||s.status===`canceled`,p=s.metadata.added,m=d?u[s.metadata.phase??`queued`]??u.queued:f?a?`更新未完成,可重试`:`Update incomplete; retry available`:p===0?a?`更新完成,暂无新增理解`:`Updated; no new understanding`:p===void 0?a?`更新完成`:`Updated`:a?`更新完成,新增 ${p} 条`:`Updated; ${p} added`,h;t[10]===m?h=t[11]:(h=(0,Q.jsx)(`p`,{children:m}),t[10]=m,t[11]=h);let g;t[12]!==i||t[13]!==s.completedAt?(g=s.completedAt?(0,Q.jsx)(`p`,{children:new Date(s.completedAt).toLocaleString(i)}):null,t[12]=i,t[13]=s.completedAt,t[14]=g):g=t[14];let _;t[15]!==f||t[16]!==s.errorMessage?(_=f&&s.errorMessage?(0,Q.jsx)(`p`,{className:`text-danger`,children:s.errorMessage}):null,t[15]=f,t[16]=s.errorMessage,t[17]=_):_=t[17];let v;return t[18]!==h||t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,"aria-live":`polite`,children:[h,g,_]}),t[18]=h,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Ye(e){return e.language}function Xe(e){let t=(0,Z.c)(87),{language:n,busy:r,statement:i,scope:a,onEdit:o,onDelete:s,onScopeChange:c}=e,[l,d]=(0,X.useState)(!1),[v,x]=(0,X.useState)(!1),S=n===`zh`,{data:C,isLoading:w,error:T}=Me(v?`memory-scope-options`:null,Ze),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E={type:`global`},t[0]=E):E=t[0];let D=S?`所有协作`:`All work`,O=S?`任何助手和对话都可按需使用`:`Available when relevant across all work`,k;t[1]!==D||t[2]!==O?(k={value:E,icon:y,title:D,detail:O},t[1]=D,t[2]=O,t[3]=k):k=t[3];let A;if(t[4]!==a||t[5]!==C?.agents||t[6]!==C?.projects||t[7]!==k||t[8]!==S){let e;t[10]===S?e=t[11]:(e=e=>({value:{type:`agent`,id:e.id},icon:b,title:S?`仅助手:${e.name||e.id}`:`Assistant: ${e.name||e.id}`,detail:S?`不会分享给其他助手`:`Not shared with other assistants`}),t[10]=S,t[11]=e);let n;if(t[12]===S?n=t[13]:(n=e=>({value:{type:`project`,id:e.id},icon:y,title:S?`仅项目:${e.name}`:`Project: ${e.name}`,detail:S?`仅在此项目中按需使用`:`Available only in this project`}),t[12]=S,t[13]=n),A=[k,...(C?.agents??[]).map(e),...(C?.projects??[]).map(n)],a&&!A.some(e=>e.value.type===a.type&&e.value.id===a.id)){let e=S?`保留现有范围`:`Keep existing scope`,n;t[14]===S?n=t[15]:(n=S?{global:`所有协作`,agent:`指定助手`,workspace:`指定工作区`,project:`指定项目`,session:`指定会话`}:{global:`All work`,agent:`Assigned assistant`,workspace:`Assigned workspace`,project:`Assigned project`,session:`Assigned conversation`},t[14]=S,t[15]=n);let r=n[a.type],i;t[16]!==a||t[17]!==e||t[18]!==r?(i={value:a,icon:b,title:e,detail:r},t[16]=a,t[17]=e,t[18]=r,t[19]=i):i=t[19],A.push(i)}t[4]=a,t[5]=C?.agents,t[6]=C?.projects,t[7]=k,t[8]=S,t[9]=A}else A=t[9];let j=S?`修改或删除这条内容`:`Edit or delete this item`,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),t[20]=M):M=t[20];let ee;t[21]!==r||t[22]!==j?(ee=(0,Q.jsx)(ze,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-11 shrink-0 p-0`,disabled:r,"aria-label":j,children:M})}),t[21]=r,t[22]=j,t[23]=ee):ee=t[23];let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(ve,{className:`size-4`,"aria-hidden":`true`}),t[24]=N):N=t[24];let te=S?`修改`:`Edit`,P;t[25]!==r||t[26]!==o||t[27]!==te?(P=(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:o,children:[N,te]}),t[25]=r,t[26]=o,t[27]=te,t[28]=P):P=t[28];let F;t[29]!==r||t[30]!==c||t[31]!==a||t[32]!==S?(F=a&&c?(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:()=>x(!0),children:[(0,Q.jsx)(Ce,{className:`size-4`,"aria-hidden":`true`}),S?`作用范围`:`Where it applies`]}):null,t[29]=r,t[30]=c,t[31]=a,t[32]=S,t[33]=F):F=t[33];let I,L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>d(!0),L=(0,Q.jsx)(Ee,{className:`size-4`,"aria-hidden":`true`}),t[34]=I,t[35]=L):(I=t[34],L=t[35]);let R=S?`删除`:`Delete`,z;t[36]!==r||t[37]!==R?(z=(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:I,children:[L,R]}),t[36]=r,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==P||t[40]!==F||t[41]!==z?(B=(0,Q.jsx)(Be,{children:(0,Q.jsxs)(He,{align:`end`,sideOffset:4,className:`z-[100] min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[P,F,z]})}),t[39]=P,t[40]=F,t[41]=z,t[42]=B):B=t[42];let ne;t[43]!==B||t[44]!==ee?(ne=(0,Q.jsxs)(Re,{modal:!1,children:[ee,B]}),t[43]=B,t[44]=ee,t[45]=ne):ne=t[45];let re;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(u,{className:`fixed inset-0 z-[110] bg-scrim`}),t[46]=re):re=t[46];let ie=S?`删除这条内容?`:`Delete this item?`,ae;t[47]===ie?ae=t[48]:(ae=(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:ie}),t[47]=ie,t[48]=ae);let oe=S?`删除后将不再使用这条记忆,原始对话和文件会保留。`:`This memory will no longer be used. Original conversations and files are kept.`,V;t[49]===oe?V=t[50]:(V=(0,Q.jsx)(f,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:oe}),t[49]=oe,t[50]=V);let H;t[51]!==ae||t[52]!==V?(H=(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[ae,V]}),t[51]=ae,t[52]=V,t[53]=H):H=t[53];let U;t[54]===i?U=t[55]:(U=(0,Q.jsx)(`p`,{className:`min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words px-5 py-4 text-sm leading-6 text-fg`,children:i}),t[54]=i,t[55]=U);let W=S?`取消`:`Cancel`,se;t[56]===W?se=t[57]:(se=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,children:W})}),t[56]=W,t[57]=se);let G;t[58]===s?G=t[59]:(G=()=>{d(!1),s()},t[58]=s,t[59]=G);let ce=S?`删除`:`Delete`,le;t[60]!==r||t[61]!==G||t[62]!==ce?(le=(0,Q.jsx)(Y,{disabled:r,onClick:G,children:ce}),t[60]=r,t[61]=G,t[62]=ce,t[63]=le):le=t[63];let ue;t[64]!==se||t[65]!==le?(ue=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3`,children:[se,le]}),t[64]=se,t[65]=le,t[66]=ue):ue=t[66];let K;t[67]!==H||t[68]!==U||t[69]!==ue?(K=(0,Q.jsxs)(m,{children:[re,(0,Q.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(22rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[H,U,ue]})]}),t[67]=H,t[68]=U,t[69]=ue,t[70]=K):K=t[70];let q;t[71]!==l||t[72]!==ne||t[73]!==K?(q=(0,Q.jsxs)(_,{open:l,onOpenChange:d,children:[ne,K]}),t[71]=l,t[72]=ne,t[73]=K,t[74]=q):q=t[74];let J;t[75]!==r||t[76]!==A||t[77]!==c||t[78]!==a||t[79]!==T||t[80]!==w||t[81]!==v||t[82]!==S?(J=a&&c?(0,Q.jsx)(_,{open:v,onOpenChange:x,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`fixed inset-0 z-[110] bg-scrim`}),(0,Q.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(25rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:S?`这条记忆在哪里生效?`:`Where should this memory apply?`}),(0,Q.jsx)(f,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S?`选择明确的助手或项目。工作区和会话范围也可在对应聊天中设置。`:`Choose an assistant or project. Workspace and conversation scopes can also be set in the corresponding chat.`})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-4`,children:[w?(0,Q.jsx)(je,{className:`h-20 w-full rounded-xl`}):null,T?(0,Q.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm text-fg-muted`,children:S?`无法载入范围,请重试;现有范围未改变。`:`Could not load scopes. Your existing scope is unchanged.`}):null,A.map(e=>{let{value:t,icon:n,title:i,detail:o}=e,s=a.type===t.type&&(a.id??``)===(t.id??``);return(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full items-center gap-3 rounded-xl px-4 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${s?`bg-surface-active`:`hover:bg-surface-hover`}`,disabled:r,onClick:()=>{x(!1),c(t)},children:[(0,Q.jsx)(n,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:o})]}),s?(0,Q.jsx)(`span`,{className:`text-xs font-medium text-accent-fg`,children:S?`当前`:`Current`}):null]},`${t.type}:${t.id??``}`)})]}),(0,Q.jsx)(`footer`,{className:`flex shrink-0 justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,children:S?`取消`:`Cancel`})})})]})]})}):null,t[75]=r,t[76]=A,t[77]=c,t[78]=a,t[79]=T,t[80]=w,t[81]=v,t[82]=S,t[83]=J):J=t[83];let fe;return t[84]!==q||t[85]!==J?(fe=(0,Q.jsxs)(Q.Fragment,{children:[q,J]}),t[84]=q,t[85]=J,t[86]=fe):fe=t[86],fe}async function Ze(){let[e,t]=await Promise.all([l(s(`/api/agents`)),l(s(`/api/projects`))]);return{agents:e.payload?.agents??[],projects:t.items??[]}}function Qe(e,t){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}).format(e):null}function $e(e,t,n=new Date){let r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r);i.setDate(r.getDate()-1);let a=new Map;for(let n of[...e].sort((e,t)=>t.recordedAt-e.recordedAt)){let e=n.recordedAt>=r.getTime()?t===`zh`?`今天`:`Today`:n.recordedAt>=i.getTime()?t===`zh`?`昨天`:`Yesterday`:Qe(n.recordedAt,t)??(t===`zh`?`更早`:`Earlier`),o=a.get(e)??[];o.push(n),a.set(e,o)}return[...a].map(([e,t])=>({label:e,items:t}))}function et(e,t){return(t===`zh`?{user_explicit:`你告诉我的`,user_observed:`从协作中观察到`,system_inferred:`xopc 的推测`,external_untrusted:`来自连接的信息`}:{user_explicit:`You told me`,user_observed:`Observed while working together`,system_inferred:`Inferred by xopc`,external_untrusted:`From connected information`})[e.authority]}function tt(e,t){if(e.validTo){let n=Qe(e.validTo,t);return t===`zh`?`适用至 ${n}`:`Applies until ${n}`}return(t===`zh`?{stable:`相对稳定`,slow:`会随时间复核`,dynamic:`近期状态`,event:`特定阶段`}:{stable:`Relatively stable`,slow:`Reviewed over time`,dynamic:`Current context`,event:`Specific period`})[e.volatility]}function nt(e,t){return e.authority===`user_explicit`?null:e.confidence>=.85?t===`zh`?`把握较高`:`High confidence`:e.confidence>=.65?t===`zh`?`把握中等`:`Medium confidence`:t===`zh`?`证据较少`:`Limited evidence`}function rt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function it(e){let t=(0,Z.c)(25),{item:n,language:r,busy:i,editing:a,draft:o,onDraftChange:s,onEdit:c,onCancel:l,onDelete:u,onCorrect:d,onScopeChange:f}=e,p=(0,X.useId)(),[m,h]=(0,X.useState)(!1),g=r===`zh`,_;t[0]!==n||t[1]!==r?(_=nt(n,r),t[0]=n,t[1]=r,t[2]=_):_=t[2];let v=_,y;t[3]===n.sources?y=t[4]:(y=new Set(n.sources?.map(ot).filter(Boolean)),t[3]=n.sources,t[4]=y);let b;t[5]===y?b=t[6]:(b=[...y],t[5]=y,t[6]=b);let x=b,S=g?`修改`:`Edit`,C;return t[7]!==i||t[8]!==v||t[9]!==o||t[10]!==S||t[11]!==a||t[12]!==m||t[13]!==p||t[14]!==n||t[15]!==r||t[16]!==l||t[17]!==d||t[18]!==u||t[19]!==s||t[20]!==c||t[21]!==f||t[22]!==x||t[23]!==g?(C=(0,Q.jsx)(`article`,{className:`border-t border-edge-subtle px-4 py-3 first:border-t-0 sm:px-5 [content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:a?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:p,children:g?`修改这条理解`:`Edit this understanding`}),(0,Q.jsx)(`textarea`,{id:p,value:o,disabled:i,onChange:e=>s(e.target.value),className:`mt-2 min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-base leading-7 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(Y,{variant:`ghost`,disabled:i,onClick:l,children:g?`取消`:`Cancel`}),(0,Q.jsx)(Y,{variant:`primary`,disabled:!o.trim()||i,onClick:d,children:i?g?`保存中…`:`Saving…`:g?`保存修改`:`Save changes`})]})]}):(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 sm:flex sm:gap-4`,children:[(0,Q.jsxs)(`div`,{className:`contents min-w-0 flex-1 pt-1.5 sm:block`,children:[(0,Q.jsx)(`p`,{className:`col-span-2 whitespace-pre-wrap break-words text-base leading-7 text-fg`,children:!m&&n.statement.length>240?`${n.statement.slice(0,240)}…`:n.statement}),n.statement.length>240?(0,Q.jsx)(`button`,{type:`button`,"aria-expanded":m,onClick:()=>h(!m),className:`col-span-2 mt-1 min-h-11 rounded-md text-left text-sm text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m?g?`收起全文`:`Show less`:g?`展开全文`:`Read more`}):null,(0,Q.jsxs)(`div`,{className:`col-start-1 mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:et(n,r)}),n.usable===!1?(0,Q.jsx)(`span`,{children:g?`暂不使用`:`Not in use`}):null,n.validTo?(0,Q.jsx)(`span`,{children:tt(n,r)}):null,n.authority!==`user_explicit`&&n.confidence<.65?(0,Q.jsx)(`span`,{children:v}):null,(0,Q.jsxs)(`details`,{className:`open:basis-full`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-11 w-fit cursor-pointer items-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:g?`查看来源`:`Sources`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:g?`来源与使用方式`:`Sources & use`})]}),(0,Q.jsxs)(`div`,{className:`my-2 space-y-1 border-l-2 border-edge pl-3 text-sm leading-6`,children:[(0,Q.jsx)(`p`,{children:n.usable===!1?g?`目前不会用于回答。`:`Currently not used in responses.`:g?`回答相关问题时,xopc 会参考这条信息。`:`xopc can refer to this when answering related questions.`}),(0,Q.jsxs)(`p`,{children:[g?`适用范围:`:`Applies to: `,rt(n.scope,r)]}),n.validTo?(0,Q.jsx)(`p`,{children:tt(n,r)}):null,v?(0,Q.jsxs)(`p`,{children:[g?`确定程度:`:`Confidence: `,v]}):null,(0,Q.jsxs)(`p`,{children:[g?`最近记录:`:`Last noted: `,Qe(n.observedAt,r)]}),x.length?x.map(at):(0,Q.jsx)(`p`,{children:g?`暂无更详细的来源记录`:`No further source details available`})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,Q.jsx)(Y,{variant:`ghost`,className:`min-h-11 min-w-11 px-2`,disabled:i,onClick:c,children:S}),(0,Q.jsx)(Xe,{language:r,busy:i,statement:n.statement,scope:n.scope,onEdit:c,onDelete:u,onScopeChange:f})]})]})}),t[7]=i,t[8]=v,t[9]=o,t[10]=S,t[11]=a,t[12]=m,t[13]=p,t[14]=n,t[15]=r,t[16]=l,t[17]=d,t[18]=u,t[19]=s,t[20]=c,t[21]=f,t[22]=x,t[23]=g,t[24]=C):C=t[24],C}function at(e){return(0,Q.jsx)(`p`,{className:`break-words`,children:e},e)}function ot(e){return e.label}var st={zh:{eyebrow:`全局用户理解`,title:`xopc 如何形成对你的理解`,subtitle:`这里汇总跨项目、跨对话形成的认识,并说明它们来自哪些渠道。项目事实不会混入你的个人画像。`,channels:`理解渠道`,channelHint:`查看来源及其最近更新。`,noChannels:`尚未通过任何渠道形成可展示的全局理解。`,activeCount:`{{count}} 条已在使用`,pendingCount:`{{count}} 条暂不使用`,noUnderstanding:`暂无来自此渠道的全局理解`,pending:`最近更新`,pendingHint:`自动整理并按需使用,你可以随时修改或删除。`,nothingPending:`尚未形成全局理解。`,showAll:`查看全部 {{count}} 条`,showLess:`收起`,done:`完成`,updating:`正在从已授权渠道更新理解;你可以先查看已有内容。`,sourceKinds:{user:`你明确告诉我的`,conversation:`对话与协作`,connector:`连接的服务`,work_folder:`工作目录`,local_source:`本机来源`,inference:`综合整理`}},en:{eyebrow:`Global user understanding`,title:`How xopc forms its understanding of you`,subtitle:`This brings together understanding formed across projects and conversations, with the channel behind each item. Project facts stay out of your personal portrait.`,channels:`Understanding channels`,channelHint:`View sources and their latest updates.`,noChannels:`No channel has formed displayable global understanding yet.`,activeCount:`{{count}} in use`,pendingCount:`{{count}} not in use`,noUnderstanding:`No usable global understanding has formed from this channel yet`,pending:`Recent updates`,pendingHint:`Organized automatically and used when relevant. Edit or delete anytime.`,nothingPending:`No understanding has formed yet.`,showAll:`View all {{count}}`,showLess:`Show less`,done:`Done`,updating:`Updating from authorized channels. You can review existing understanding now.`,sourceKinds:{user:`You told me`,conversation:`Conversations and work`,connector:`Connected services`,work_folder:`Work folders`,local_source:`On-device sources`,inference:`Synthesized understanding`}}},ct={"local-recent-files":{en:`Recent files`,zh:`最近文件`},"chromium-bookmarks":{en:`Recent bookmarks`,zh:`最近书签`},"apple-notes":{en:`Apple Notes`,zh:`Apple 备忘录`},"apple-mail":{en:`Apple Mail`,zh:`Apple 邮件`},"apple-calendar":{en:`Apple Calendar`,zh:`Apple 日历`},"apple-reminders":{en:`Apple Reminders`,zh:`Apple 提醒事项`},"windows-recent-documents":{en:`Recent documents`,zh:`最近文档`},"linux-recent-documents":{en:`Recent documents`,zh:`最近文档`}},lt={user:Oe,conversation:_e,connector:le,work_folder:fe,local_source:K,inference:le},ut={files:fe,recent_documents:K,calendar:ie,tasks:me,notes:Te,mail:q,messages:_e,code_activity:pe};function $(e){let t=e.authority===`user_explicit`?`user`:e.authority===`user_observed`?`conversation`:e.authority===`external_untrusted`?`connector`:`inference`;return{id:t,kind:t,observedAt:e.observedAt}}function dt(e,t){return e.kind===`local_source`&&e.label?ct[e.label]?.[t]??e.label:e.kind===`work_folder`&&e.label?t===`zh`?`工作目录 · ${e.label}`:`Work folder · ${e.label}`:e.label?e.label:st[t].sourceKinds[e.kind]}function ft(e){return`${e.kind}:${e.adapterId}:${e.displayName}`}function pt(e){let t=(0,Z.c)(91),{assertions:n,configuredSources:r,activityRunning:i,language:a,busy:o,error:s,onReviewAssertion:c,onCompleted:l}=e,u=st[a],[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(``),_;t[0]===n?_=t[1]:(_=n.filter(bt),t[0]=n,t[1]=_);let v=_,y;t[2]===v?y=t[3]:(y=[...v].sort(yt),t[2]=v,t[3]=y);let b=y,x;if(t[4]!==r||t[5]!==v||t[6]!==a){let e=new Map;for(let t of r){let n=t.kind===`local_source`?ct[t.adapterId]?.[a]??t.displayName:t.displayName,r=ft(t);e.set(r,{key:r,grantId:t.id,kind:t.kind,category:t.category,label:t.kind===`work_folder`?a===`zh`?`工作目录 · ${n}`:`Work folder · ${n}`:n,assertions:[],lastObservedAt:t.lastCollectedAt})}for(let t of v)for(let n of t.sources?.length?t.sources:[$(t)]){let r=dt(n,a),i=[...e.values()].find(e=>e.kind===n.kind&&e.label===r),o=i?.key??`${n.kind}:${r}`,s=i??e.get(o)??{key:o,kind:n.kind,category:n.category,label:r,assertions:[],lastObservedAt:n.observedAt};s.assertions.some(e=>e.id===t.id)||s.assertions.push(t),s.lastObservedAt=Math.max(s.lastObservedAt??0,n.observedAt),e.set(o,s)}x=[...e.values()].sort(vt),t[4]=r,t[5]=v,t[6]=a,t[7]=x}else x=t[7];let S=x,C;t[8]===c?C=t[9]:(C=async(e,t,n)=>{await c(e,t,n)&&m(null)},t[8]=c,t[9]=C);let w=C,T,E,D,O,k,A,j,M,ee;if(t[10]!==i||t[11]!==o||t[12]!==h||t[13]!==p||t[14]!==a||t[15]!==b||t[16]!==w||t[17]!==d||t[18]!==u.eyebrow||t[19]!==u.nothingPending||t[20]!==u.pending||t[21]!==u.pendingHint||t[22]!==u.showAll||t[23]!==u.showLess||t[24]!==u.subtitle||t[25]!==u.title||t[26]!==u.updating){let e=d?b:b.slice(0,5);T=`mx-auto w-full max-w-[42rem] pb-2`,E=`polite`;let n;t[36]===u.eyebrow?n=t[37]:(n=(0,Q.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-accent-fg`,children:u.eyebrow}),t[36]=u.eyebrow,t[37]=n);let r;t[38]===u.title?r=t[39]:(r=(0,Q.jsx)(`h2`,{className:`mt-3 text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:u.title}),t[38]=u.title,t[39]=r);let s;t[40]===u.subtitle?s=t[41]:(s=(0,Q.jsx)(`p`,{className:`mx-auto mt-3 max-w-[38rem] text-sm leading-6 text-fg-muted`,children:u.subtitle}),t[40]=u.subtitle,t[41]=s),t[42]!==n||t[43]!==r||t[44]!==s?(D=(0,Q.jsxs)(`div`,{className:`text-center`,children:[n,r,s]}),t[42]=n,t[43]=r,t[44]=s,t[45]=D):D=t[45],t[46]!==i||t[47]!==u.updating?(O=i?(0,Q.jsxs)(`div`,{className:`mt-6 flex items-center gap-3 rounded-xl border border-accent/20 bg-accent-soft/55 px-4 py-3 text-sm text-accent-fg`,children:[(0,Q.jsx)(he,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`}),(0,Q.jsx)(`p`,{children:u.updating})]}):null,t[46]=i,t[47]=u.updating,t[48]=O):O=t[48],k=`mt-8`,A=`understanding-updates-title`;let c=b.length?` · ${b.length}`:``;t[49]!==u.pending||t[50]!==c?(j=(0,Q.jsxs)(`h3`,{id:`understanding-updates-title`,className:`text-sm font-semibold text-fg`,children:[u.pending,c]}),t[49]=u.pending,t[50]=c,t[51]=j):j=t[51],t[52]===u.pendingHint?M=t[53]:(M=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.pendingHint}),t[52]=u.pendingHint,t[53]=M),ee=b.length?(0,Q.jsxs)(`div`,{className:`mt-3`,children:[$e(e,a).map(e=>{let{label:t,items:n}=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`border-b border-edge-subtle px-4 pb-2 pt-3 text-xs font-medium text-fg-muted`,children:t}),(0,Q.jsx)(`div`,{children:n.map(e=>(0,Q.jsx)(it,{item:e,language:a,busy:o,editing:p===e.id,draft:h,onDraftChange:g,onEdit:()=>{m(e.id),g(e.statement)},onCancel:()=>m(null),onCorrect:()=>void w(e,`edited`,h.trim()),onDelete:()=>void w(e,`deleted`)},e.id))})]},t)}),b.length>5?(0,Q.jsxs)(`button`,{type:`button`,className:`mx-auto flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>f(_t),children:[d?u.showLess:u.showAll.replace(`{{count}}`,String(b.length)),(0,Q.jsx)(oe,{className:Ae(`size-3.5 transition-transform`,d&&`rotate-180`)})]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-3 rounded-xl border border-edge bg-surface-base/55 p-4`,children:[(0,Q.jsx)(G,{className:`mt-0.5 size-5 shrink-0 text-success`}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:u.nothingPending})]}),t[10]=i,t[11]=o,t[12]=h,t[13]=p,t[14]=a,t[15]=b,t[16]=w,t[17]=d,t[18]=u.eyebrow,t[19]=u.nothingPending,t[20]=u.pending,t[21]=u.pendingHint,t[22]=u.showAll,t[23]=u.showLess,t[24]=u.subtitle,t[25]=u.title,t[26]=u.updating,t[27]=T,t[28]=E,t[29]=D,t[30]=O,t[31]=k,t[32]=A,t[33]=j,t[34]=M,t[35]=ee}else T=t[27],E=t[28],D=t[29],O=t[30],k=t[31],A=t[32],j=t[33],M=t[34],ee=t[35];let N;t[54]!==k||t[55]!==A||t[56]!==j||t[57]!==M||t[58]!==ee?(N=(0,Q.jsxs)(`section`,{className:k,"aria-labelledby":A,children:[j,M,ee]}),t[54]=k,t[55]=A,t[56]=j,t[57]=M,t[58]=ee,t[59]=N):N=t[59];let te;t[60]!==S.length||t[61]!==u.channels?(te=(0,Q.jsxs)(`summary`,{className:`w-fit cursor-pointer rounded-md py-2 text-sm font-medium text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u.channels,` · `,S.length]}),t[60]=S.length,t[61]=u.channels,t[62]=te):te=t[62];let P;t[63]===u.channelHint?P=t[64]:(P=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.channelHint}),t[63]=u.channelHint,t[64]=P);let F;t[65]!==S||t[66]!==u.activeCount||t[67]!==u.noChannels||t[68]!==u.noUnderstanding||t[69]!==u.pendingCount?(F=S.length?(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let t=e.category?ut[e.category]??lt[e.kind]:lt[e.kind],n=e.assertions.filter(gt).length,r=e.assertions.filter(ht).length;return(0,Q.jsxs)(`article`,{className:`rounded-xl border border-edge bg-surface-base/55 px-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),e.grantId?(0,Q.jsx)(Je,{sourceId:e.grantId,lastCollectedAt:e.lastObservedAt}):null,e.assertions.length?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?u.activeCount.replace(`{{count}}`,String(n)):``,r?u.pendingCount.replace(`{{count}}`,String(r)):``].filter(Boolean).join(` · `)}):(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.noUnderstanding})]}),e.grantId?(0,Q.jsx)(We,{sourceId:e.grantId}):null]}),e.assertions.length?(0,Q.jsx)(`ul`,{className:`ml-12 mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,children:e.assertions.slice(0,5).map(mt)}):null]},e.key)})}):(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl border border-edge bg-surface-base/55 p-4 text-sm text-fg-muted`,children:u.noChannels}),t[65]=S,t[66]=u.activeCount,t[67]=u.noChannels,t[68]=u.noUnderstanding,t[69]=u.pendingCount,t[70]=F):F=t[70];let I;t[71]!==te||t[72]!==P||t[73]!==F?(I=(0,Q.jsxs)(`details`,{className:`mt-6 border-t border-edge pt-4`,children:[te,P,F]}),t[71]=te,t[72]=P,t[73]=F,t[74]=I):I=t[74];let L;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(ae,{className:`size-4`}),t[75]=L):L=t[75];let R;t[76]!==o||t[77]!==l||t[78]!==u.done?(R=(0,Q.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,Q.jsxs)(Y,{variant:`primary`,disabled:o,onClick:l,children:[L,u.done]})}),t[76]=o,t[77]=l,t[78]=u.done,t[79]=R):R=t[79];let z;t[80]===s?z=t[81]:(z=s?(0,Q.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:s}):null,t[80]=s,t[81]=z);let B;return t[82]!==T||t[83]!==E||t[84]!==D||t[85]!==O||t[86]!==N||t[87]!==I||t[88]!==R||t[89]!==z?(B=(0,Q.jsxs)(`section`,{className:T,"aria-live":E,children:[D,O,N,I,R,z]}),t[82]=T,t[83]=E,t[84]=D,t[85]=O,t[86]=N,t[87]=I,t[88]=R,t[89]=z,t[90]=B):B=t[90],B}function mt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent/60`}),(0,Q.jsx)(`span`,{children:e.statement})]},e.id)}function ht(e){return!e.usable}function gt(e){return e.usable}function _t(e){return!e}function vt(e,t){return t.assertions.length-e.assertions.length||(t.lastObservedAt??0)-(e.lastObservedAt??0)}function yt(e,t){return t.recordedAt-e.recordedAt}function bt(e){return e.scope.type===`global`&&e.status!==`archived`&&e.status!==`rejected`}function xt(){let{pathname:e,search:t}=i(),n=c(e=>e.language),r=J(),[a,o]=(0,X.useState)(!1),[s,l]=(0,X.useState)(null),v=e===`/user-model`,{data:y,mutate:b}=Me(v?`/api/user-model`:null,M),x=L(e=>e.error),S=L(e=>e.sources.some(e=>e.status===`running`||e.status===`queued`)),C=n===`zh`;if((0,X.useEffect)(()=>{v&&new URLSearchParams(t).get(`workDiscovery`)===`review`&&J.getState().setDrawerOpen(!0)},[v,t]),(0,X.useEffect)(()=>{v&&r.status!==`running`&&b()},[b,v,r.directoryRun?.id,r.status]),!v)return null;let T=r.status===`running`||S,E=async(e,t,n)=>{o(!0),l(null);try{return t===`edited`&&n?await N(e.id,n):t===`deleted`&&await w(e.id),await b(),!0}catch(e){return l(e instanceof Error?e.message:String(e)),!1}finally{o(!1)}},D=e=>{if(!e&&y&&r.status!==`running`){r.finish();return}r.setDrawerOpen(e)};return(0,Q.jsxs)(_,{open:r.drawerOpen,onOpenChange:D,children:[(0,Q.jsx)(d,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:Ae(`relative size-8 rounded-xl p-0`,Ne),title:C?`查看 xopc 对你的理解`:`Review what xopc understands`,"aria-label":C?`查看 xopc 对你的理解`:`Review what xopc understands`,children:T?(0,Q.jsx)(he,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(we,{className:`size-4 text-accent-fg`})})}),(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`fixed inset-0 z-[60] bg-scrim backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:backdrop-blur-none`}),(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] flex items-center justify-center p-3 sm:p-6`,children:(0,Q.jsxs)(h,{className:`xopc-understanding-center pointer-events-auto flex h-[min(42rem,calc(100dvh-1.5rem))] w-[min(44rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float outline-none sm:h-[min(42rem,calc(100dvh-3rem))] sm:w-[min(44rem,calc(100vw-3rem))]`,children:[(0,Q.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-edge-subtle px-5 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(g,{className:`text-sm font-semibold text-fg`,children:T?C?`正在更新用户理解`:`Updating user understanding`:C?`用户理解`:`User understanding`}),(0,Q.jsx)(f,{className:`mt-0.5 text-xs text-fg-muted`,children:T?C?`关闭窗口也会在后台继续`:`You can close this window; work continues in the background`:C?`自动更新,可随时修改或删除`:`Updated automatically. Edit or delete anytime`})]}),(0,Q.jsx)(We,{disabled:!y?.sources?.length}),(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 rounded-xl p-0`,"aria-label":C?`关闭`:`Close`,children:(0,Q.jsx)(ke,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-7 sm:px-9 sm:py-9`,children:y?(0,Q.jsx)(pt,{assertions:y.assertions,configuredSources:y.sources??[],activityRunning:T,language:n,busy:a,error:s??x??null,onReviewAssertion:E,onCompleted:()=>{D(!1)}}):(0,Q.jsxs)(`section`,{className:`space-y-4`,"aria-label":C?`正在加载用户理解`:`Loading user understanding`,children:[(0,Q.jsx)(je,{className:`h-8 w-2/3`}),(0,Q.jsx)(je,{className:`h-32 w-full`}),(0,Q.jsx)(je,{className:`h-32 w-full`})]})})]})})]})]})}function St(e){let t=(0,Z.c)(34),{language:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:15e3},t[0]=r):r=t[0];let{data:i,error:a,isLoading:o}=Me(`memory-learning-status`,Nt,r);if(o){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(je,{className:`h-14 w-full rounded-xl`}),t[1]=e):e=t[1],e}if(a||!i?.jobs||!i?.coverage)return null;let s;t[2]===i.jobs?s=t[3]:(s=i.jobs.filter(Mt).reduce(jt,0),t[2]=i.jobs,t[3]=s);let c=s,l;t[4]===i.coverage?l=t[5]:(l=i.coverage.filter(At).reduce(kt,0),t[4]=i.coverage,t[5]=l);let u=l,d;t[6]===i.coverage?d=t[7]:(d=i.coverage.filter(Ot).reduce(Dt,0),t[6]=i.coverage,t[7]=d);let f=d,p;t[8]===i.jobs?p=t[9]:(p=i.jobs.filter(Et).reduce(Tt,0),t[8]=i.jobs,t[9]=p);let m=p,h;t[10]===i.jobs?h=t[11]:(h=i.jobs.filter(wt).reduce(Ct,0),t[10]=i.jobs,t[11]=h);let g=h,_=n===`zh`?`资料 ${f} 条 · 已生效记忆 ${u} 条`:`${f} sources · ${u} active memories`,v;t[12]!==n||t[13]!==c?(v=c>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${c} 项处理中`:`${c} processing`}):null,t[12]=n,t[13]=c,t[14]=v):v=t[14];let y=n===`zh`?`计数说明`:`About these counts`,b;t[15]===y?b=t[16]:(b=(0,Q.jsx)(`summary`,{className:`w-fit cursor-pointer rounded focus-visible:outline-accent`,children:y}),t[15]=y,t[16]=b);let x=n===`zh`?`仅统计已启用且有依据的工作记忆;管理列表包含其他状态。“关于你”单独计数。`:`Work memories must be active and supported. Management lists include other states. About you is counted separately.`,S;t[17]===x?S=t[18]:(S=(0,Q.jsx)(`p`,{className:`mt-1 leading-5`,children:x}),t[17]=x,t[18]=S);let C;t[19]!==b||t[20]!==S?(C=(0,Q.jsxs)(`details`,{className:`mt-1 text-xs`,children:[b,S]}),t[19]=b,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==m||t[23]!==n?(w=m>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${m} 项处理失败`:`${m} failed jobs`}):null,t[22]=m,t[23]=n,t[24]=w):w=t[24];let T;t[25]!==n||t[26]!==g?(T=g>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${g} 项等待配置本地模型`:`${g} jobs require a local model`}):null,t[25]=n,t[26]=g,t[27]=T):T=t[27];let E;return t[28]!==C||t[29]!==w||t[30]!==T||t[31]!==_||t[32]!==v?(E=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-4 py-3 text-sm text-fg-muted`,role:`status`,children:[_,v,C,w,T]}),t[28]=C,t[29]=w,t[30]=T,t[31]=_,t[32]=v,t[33]=E):E=t[33],E}function Ct(e,t){return e+t.count}function wt(e){return e.errorCode===`local_model_required`}function Tt(e,t){return e+t.count}function Et(e){return e.state===`failed`}function Dt(e,t){return e+t.count}function Ot(e){return e.recordClass===`source_index`}function kt(e,t){return e+t.count}function At(e){return e.recordClass===`memory`&&e.status===`active`&&e.verification===`supported`}function jt(e,t){return e+t.count}function Mt(e){return[`queued`,`running`,`retry_wait`].includes(e.state)}function Nt(){return l(s(`/api/memory-learning/status`))}function Pt(e){let t=(0,Z.c)(12),{id:n,language:r}=e,i;t[0]===n?i=t[1]:(i=()=>l(s(`/api/knowledge-memory/${encodeURIComponent(n)}/evidence`)),t[0]=n,t[1]=i);let{data:a,error:o,isLoading:c}=Me(`knowledge-evidence:${n}`,i);if(c){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(je,{className:`mt-3 h-10 w-full rounded-lg`}),t[2]=e):e=t[2],e}if(o){let e=r===`zh`?`此条证据目前不可用于回答,请检查来源授权、有效期和读取范围。`:`Evidence is currently unavailable. Check source authorization, validity and read scope.`,n;return t[3]===e?n=t[4]:(n=(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:e}),t[3]=e,t[4]=n),n}if(!Array.isArray(a?.evidence)||!a.evidence.length)return null;let u;if(t[5]!==a.evidence||t[6]!==r){let e;t[8]===r?e=t[9]:(e=(e,t)=>(0,Q.jsxs)(`p`,{children:[r===`zh`?`证据`:`Evidence`,` · `,e.sourceType===`conversation`?r===`zh`?`对话`:`Conversation`:e.sourceType===`runtime`?r===`zh`?`执行记录`:`Execution receipt`:r===`zh`?`授权资料`:`Authorized source`,` · `,new Date(e.observedAt).toLocaleDateString(r),e.excerpt?(0,Q.jsx)(`span`,{className:`mt-1 block whitespace-pre-wrap break-words`,children:e.excerpt}):null]},t),t[8]=r,t[9]=e),u=a.evidence.map(e),t[5]=a.evidence,t[6]=r,t[7]=u}else u=t[7];let d;return t[10]===u?d=t[11]:(d=(0,Q.jsx)(`div`,{className:`mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:u}),t[10]=u,t[11]=d),d}function Ft(e){let t=e.get(`tab`);return t===`understanding`&&e.get(`section`)===`work`?`work`:t===`understanding`||t===`work`||t===`privacy`?t:`overview`}var It={en:{pageTitle:`About you`,overview:`Overview`,understanding:`What xopc knows`,privacy:`Data & privacy`,knowledge:`Work memory`,editProfile:`Edit basics`,callName:`What should xopc call you?`,callNamePlaceholder:`For example: Alex, Joyce, or Dr. Chen`,role:`Your role`,rolePlaceholder:`For example: founder, designer, or engineer`,pronouns:`Pronouns (optional)`,pronounsPlaceholder:`For example: she/her, he/him, they/them`,timezone:`Timezone`,timezoneSearch:`Search timezones…`,timezoneNoMatch:`No matching timezone`,locale:`Language / locale`,useDeviceTimezone:`Use this device`,notProvided:`Not provided`,editProfileHint:`These are facts you provide directly. They remain separate from xopc’s observations and inferences.`,saveProfile:`Save`,saving:`Saving…`,explicit:`You told me`,explicitHint:`Facts and preferences you stated directly`,learned:`Learned together`,learnedHint:`Patterns formed from our work`,allUnderstanding:`All understanding`,understandingFilterHint:`Filter this view by how each item was formed.`,importantNow:`What matters now`,prioritySourceGoal:`From a goal you confirmed`,prioritySourceWork:`From your current work`,editPriority:`Edit focus`,addPriority:`Set current focus`,priorityTitle:`Current focus`,priorityTitlePlaceholder:`What matters most right now?`,priorityOutcome:`What a good outcome looks like`,priorityOutcomePlaceholder:`Describe the result you want…`,priorityUntil:`Focus through`,savePriority:`Save focus`,endPriority:`End focus`,endingPriority:`Ending…`,priorityHint:`This is used to keep xopc aligned with what deserves attention now.`,otherGoals:`Other active outcomes`,howWeWork:`How we work together`,noRules:`No collaboration preferences yet.`,seeAll:`See all`,workMemory:`What I remember from the work`,items:`items`,refresh:`Refresh`,refreshing:`Refreshing…`,refreshComplete:`Refreshed`,refreshFailed:`Refresh failed`,aboutYouTitle:`What xopc remembers about you`,aboutYouHint:`Review your background, preferences, and habits. Edit anything that no longer fits.`,identity:`Who you are`,preferences:`Preferences and working rhythm`,relationships:`People and relationships`,currentState:`Current context`,insights:`My current read`,emptyGroup:`No usable personal understanding yet. Ongoing preferences will build through collaboration; project facts and progress are in Work memory.`,correct:`Correct`,save:`Save correction`,cancel:`Cancel`,correctionPlaceholder:`Write the accurate version…`,searchPlaceholder:`Search work memory…`,allMemory:`All work memory`,memoryFilterHint:`Filter by memory type`,memoryLibraryHint:`Only distilled facts, decisions, lessons, commitments, and open questions appear here. Source records stay with their connector.`,noKnowledge:`No work memory has formed yet.`,noKnowledgeMatch:`No work memory matches this search.`,showMore:`Show more`,expand:`Show details`,collapse:`Hide details`,disable:`Disable`,disabled:`Not in use`,enable:`Enable`,loadFailed:`Could not load your understanding.`,tryAgain:`Try again`,actionFailed:`The change could not be saved. Please try again.`},zh:{pageTitle:`关于你`,overview:`总览`,understanding:`对我的了解`,privacy:`数据与隐私`,knowledge:`工作记忆`,editProfile:`编辑基本信息`,callName:`希望 xopc 如何称呼你?`,callNamePlaceholder:`例如:Mic、Joyce、张老师`,role:`你的角色`,rolePlaceholder:`例如:创业者、产品设计师、工程师`,pronouns:`代词(可选)`,pronounsPlaceholder:`例如:she/her、he/him、they/them`,timezone:`时区`,timezoneSearch:`搜索时区…`,timezoneNoMatch:`没有匹配的时区`,locale:`语言 / 地区`,useDeviceTimezone:`使用本机时区`,notProvided:`未填写`,editProfileHint:`这些是由你直接提供的事实,与 xopc 的观察和推断分开维护。`,saveProfile:`保存`,saving:`正在保存…`,explicit:`你告诉我的`,explicitHint:`你明确表达的事实与偏好`,learned:`协作中学到的`,learnedHint:`从实际协作中形成的认识`,allUnderstanding:`全部来源`,understandingFilterHint:`按内容来源筛选这份理解。`,importantNow:`你最近在关注什么`,prioritySourceGoal:`来自你确认的当前目标`,prioritySourceWork:`来自当前工作上下文`,editPriority:`编辑`,addPriority:`设置当前关注`,priorityTitle:`当前关注`,priorityTitlePlaceholder:`现在最重要的是什么?`,priorityOutcome:`期待结果`,priorityOutcomePlaceholder:`描述你希望达成的结果…`,priorityUntil:`关注至`,savePriority:`保存关注`,endPriority:`结束关注`,endingPriority:`正在结束…`,priorityHint:`这项内容会帮助 xopc 在协作中优先关注当前最重要的事情。`,otherGoals:`其他进行中的目标`,howWeWork:`我们怎样协作`,noRules:`还没有形成协作偏好。`,seeAll:`查看全部`,workMemory:`我在工作中记住的`,items:`条`,refresh:`刷新`,refreshing:`正在刷新…`,refreshComplete:`已刷新`,refreshFailed:`刷新失败`,aboutYouTitle:`xopc 记住的你`,aboutYouHint:`在这里查看你的背景、偏好和习惯。有不准确或已经变化的内容,可以直接修改。`,identity:`你的背景与能力`,preferences:`偏好与习惯`,relationships:`重要的人与关系`,currentState:`最近的状态`,insights:`其他观察`,emptyGroup:`还没有记住关于你的信息。你可以在聊天中告诉 xopc 你的背景或偏好,例如「回答时先给结论」。`,correct:`修正`,save:`保存修正`,cancel:`取消`,correctionPlaceholder:`写下更准确的说法…`,searchPlaceholder:`搜索工作记忆…`,allMemory:`全部工作记忆`,memoryFilterHint:`按记忆类型筛选`,memoryLibraryHint:`这里只显示提炼后的事实、决定、经验、承诺和待解问题;邮件、日历与文档原文保留在对应来源中。`,noKnowledge:`还没有形成工作记忆。`,noKnowledgeMatch:`没有符合搜索条件的工作记忆。`,showMore:`显示更多`,expand:`查看详情`,collapse:`收起详情`,disable:`停用`,disabled:`已停用`,enable:`启用`,loadFailed:`无法载入对你的理解。`,tryAgain:`重试`,actionFailed:`修改没有保存,请重试。`}},Lt=new Set([`identity.call_name`,`identity.role`,`identity.pronouns`,`preference.timezone`,`preference.locale`]),Rt=[`work_thread`,`project_fact`,`workspace_fact`,`decision`,`task_lesson`,`commitment`,`open_question`,`episode`,`note`],zt=`UTC.Africa/Cairo.Africa/Johannesburg.America/Chicago.America/Denver.America/Los_Angeles.America/Mexico_City.America/New_York.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Kolkata.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Berlin.Europe/London.Europe/Madrid.Europe/Paris.Europe/Rome.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function Bt(){try{let e=Intl.supportedValuesOf(`timeZone`);return[...new Set([`UTC`,...e])]}catch{return[...zt]}}var Vt=Bt();function Ht(e){return e.map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.includes(`/`)?e.split(`/`)[0]:`UTC`}))}function Ut(e,t,n=!1){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,...n?{timeStyle:`short`}:{}}).format(e):null}function Wt(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Gt(e){return{callName:Wt(e.profile.callName)??``,role:Wt(e.profile.role)??``,pronouns:Wt(e.profile.pronouns)??``,timezone:Wt(e.profile.timezone)??``,locale:Wt(e.profile.locale)??``}}function Kt(e,t){return{"zh-CN":{en:`Simplified Chinese`,zh:`简体中文`},"zh-TW":{en:`Traditional Chinese`,zh:`繁体中文`},"en-US":{en:`English (US)`,zh:`英语(美国)`},"en-GB":{en:`English (UK)`,zh:`英语(英国)`},"ja-JP":{en:`Japanese`,zh:`日语`}}[e]?.[t]??e}function qt(e,t){let n=Ut(e,t);return t===`zh`?`当前安排至 ${n}`:`Current plan through ${n}`}function Jt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Yt(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function Xt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function Zt(e,t){return(t===`zh`?{work_thread:`工作主线`,project_fact:`项目事实`,workspace_fact:`工作区事实`,decision:`已经决定`,task_lesson:`工作经验`,commitment:`承诺与约定`,open_question:`待解问题`,episode:`重要经历`,note:`其他记录`}:{work_thread:`Work threads`,project_fact:`Project facts`,workspace_fact:`Workspace facts`,decision:`Decisions`,task_lesson:`Lessons`,commitment:`Commitments`,open_question:`Open questions`,episode:`Episodes`,note:`Notes`})[e]}function Qt(e,t,n){if(e)return e.targetType===`goal`?t.find(t=>t.id===e.targetId)?.title:/^[0-9a-f]{8}-[0-9a-f-]{20,}$/i.test(e.targetId)?(n===`zh`?{project:`当前项目`,task:`当前任务`,assertion:`一项待处理的理解`,topic:`当前主题`}:{project:`Current project`,task:`Current task`,assertion:`An understanding to address`,topic:`Current topic`})[e.targetType]:e.targetId}function $t(e){let t=(0,Z.c)(16),{title:n,hint:r,action:i,children:a,className:o}=e,s=o===void 0?``:o,c;t[0]===n?c=t[1]:(c=(0,Q.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=r?(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:r}):null,t[2]=r,t[3]=l);let u;t[4]!==c||t[5]!==l?(u=(0,Q.jsxs)(`div`,{children:[c,l]}),t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==u?(d=(0,Q.jsxs)(`header`,{className:`flex items-end justify-between gap-4 px-1 pb-3`,children:[u,i]}),t[7]=i,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:a}),t[10]=a,t[11]=f);let p;return t[12]!==s||t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`section`,{className:s,children:[d,f]}),t[12]=s,t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function en(e){let t=(0,Z.c)(7),{icon:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`p`,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-5 text-sm text-fg-muted`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function tn({open:e,profile:t,language:n,saving:r,onOpenChange:i,onSave:a}){let o=It[n],[s,c]=(0,X.useState)(t),[l,d]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&(c(t),d(``))},[e,t]);let v=e=>{e.preventDefault(),a({callName:s.callName.trim(),role:s.role.trim(),pronouns:s.pronouns.trim(),timezone:s.timezone.trim(),locale:s.locale.trim()})},y=(e,t,n)=>(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Q.jsx)(`input`,{value:s[e],onChange:t=>c(n=>({...n,[e]:t.target.value})),placeholder:n,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),b=[`zh-CN`,`zh-TW`,`en-US`,`en-GB`,`ja-JP`];s.locale&&!b.includes(s.locale)&&b.push(s.locale);let x=I(),S=(0,X.useMemo)(()=>[...new Set([...Vt,x,s.timezone].filter(Boolean))].sort(),[x,s.timezone]),C=l.trim().toLocaleLowerCase(),w=(0,X.useMemo)(()=>Ht(S.filter(e=>!C||e.toLocaleLowerCase().includes(C)||e.replaceAll(`_`,` `).toLocaleLowerCase().includes(C))),[S,C]);return(0,Q.jsx)(_,{open:e,onOpenChange:i,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsx)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(40rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:v,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:o.editProfile}),(0,Q.jsx)(f,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.editProfileHint})]}),(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o.cancel,children:(0,Q.jsx)(ke,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[y(`callName`,o.callName,o.callNamePlaceholder),y(`role`,o.role,o.rolePlaceholder),y(`pronouns`,o.pronouns,o.pronounsPlaceholder),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.locale}),(0,Q.jsxs)(H,{value:s.locale,onChange:e=>c(t=>({...t,locale:e.target.value})),children:[(0,Q.jsx)(U,{value:``,children:o.notProvided}),b.map(e=>(0,Q.jsx)(U,{value:e,children:Kt(e,n)},e))]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.timezone}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{value:s.timezone,options:w,placeholder:I(),emptyLabel:o.notProvided,ariaLabel:o.timezone,selectedLabel:s.timezone||o.notProvided,searchPlaceholder:o.timezoneSearch,searchValue:l,onSearchChange:d,statusMessage:w.length?void 0:o.timezoneNoMatch,triggerClassName:`min-w-0 flex-1 rounded-xl bg-surface-base`,onChange:e=>{c(t=>({...t,timezone:e})),d(``)}}),(0,Q.jsx)(Y,{className:`shrink-0 whitespace-nowrap`,onClick:()=>c(e=>({...e,timezone:x})),children:o.useDeviceTimezone})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{disabled:r,children:o.cancel})}),(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,disabled:r,children:[r?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,r?o.saving:o.saveProfile]})]})]})})]})})}function nn(e){let t=(0,Z.c)(94),{open:n,priority:r,title:i,outcome:a,language:o,saving:s,onOpenChange:c,onSave:l,onEnd:d}=e,v=It[o],[y,b]=(0,X.useState)(i),[x,S]=(0,X.useState)(a??``),C=r?.validTo??Date.now()+6048e5,w;t[0]===C?w=t[1]:(w=Jt(C),t[0]=C,t[1]=w);let T=w,[E,D]=(0,X.useState)(T),O,k;t[2]!==T||t[3]!==n||t[4]!==a||t[5]!==i?(O=()=>{n&&(b(i),S(a??``),D(T))},k=[T,n,a,i],t[2]=T,t[3]=n,t[4]=a,t[5]=i,t[6]=O,t[7]=k):(O=t[6],k=t[7]),(0,X.useEffect)(O,k);let A;t[8]!==x||t[9]!==y||t[10]!==E||t[11]!==l||t[12]!==r?.targetType?(A=e=>{e.preventDefault(),l({title:y.trim(),...r?.targetType===`goal`?{desiredOutcome:x.trim()}:{},validTo:Yt(E)})},t[8]=x,t[9]=y,t[10]=E,t[11]=l,t[12]=r?.targetType,t[13]=A):A=t[13];let j=A,M;t[14]!==x||t[15]!==y||t[16]!==E||t[17]!==r?.targetType?(M=y.trim()&&E&&(r?.targetType!==`goal`||x.trim()),t[14]=x,t[15]=y,t[16]=E,t[17]=r?.targetType,t[18]=M):M=t[18];let ee=!!M,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[19]=N):N=t[19];let te=r?v.editPriority:v.addPriority,P;t[20]===te?P=t[21]:(P=(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:te}),t[20]=te,t[21]=P);let F;t[22]===v.priorityHint?F=t[23]:(F=(0,Q.jsx)(f,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.priorityHint}),t[22]=v.priorityHint,t[23]=F);let I;t[24]!==F||t[25]!==P?(I=(0,Q.jsxs)(`div`,{children:[P,F]}),t[24]=F,t[25]=P,t[26]=I):I=t[26];let L;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(ke,{className:`size-4`}),t[27]=L):L=t[27];let R;t[28]===v.cancel?R=t[29]:(R=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":v.cancel,children:L})}),t[28]=v.cancel,t[29]=R);let z;t[30]!==I||t[31]!==R?(z=(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[I,R]}),t[30]=I,t[31]=R,t[32]=z):z=t[32];let B;t[33]===v.priorityTitle?B=t[34]:(B=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityTitle}),t[33]=v.priorityTitle,t[34]=B);let ne;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>b(e.target.value),t[35]=ne):ne=t[35];let re;t[36]!==y||t[37]!==v.priorityTitlePlaceholder?(re=(0,Q.jsx)(`input`,{autoFocus:!0,value:y,onChange:ne,placeholder:v.priorityTitlePlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[36]=y,t[37]=v.priorityTitlePlaceholder,t[38]=re):re=t[38];let ie;t[39]!==B||t[40]!==re?(ie=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[B,re]}),t[39]=B,t[40]=re,t[41]=ie):ie=t[41];let ae;t[42]!==x||t[43]!==r?.targetType||t[44]!==v.priorityOutcome||t[45]!==v.priorityOutcomePlaceholder?(ae=r?.targetType===`goal`?(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityOutcome}),(0,Q.jsx)(`textarea`,{value:x,onChange:e=>S(e.target.value),placeholder:v.priorityOutcomePlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}):null,t[42]=x,t[43]=r?.targetType,t[44]=v.priorityOutcome,t[45]=v.priorityOutcomePlaceholder,t[46]=ae):ae=t[46];let oe;t[47]===v.priorityUntil?oe=t[48]:(oe=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityUntil}),t[47]=v.priorityUntil,t[48]=oe);let V;t[49]===r?.validFrom?V=t[50]:(V=r?.validFrom??Date.now(),t[49]=r?.validFrom,t[50]=V);let H;t[51]===V?H=t[52]:(H=Jt(V),t[51]=V,t[52]=H);let U;t[53]!==E||t[54]!==v.priorityUntil||t[55]!==H?(U=(0,Q.jsx)(Ue,{min:H,value:E,onChange:D,ariaLabel:v.priorityUntil,className:`rounded-xl border border-edge bg-surface-base hover:border-edge-strong hover:bg-surface-base`}),t[53]=E,t[54]=v.priorityUntil,t[55]=H,t[56]=U):U=t[56];let W;t[57]!==oe||t[58]!==U?(W=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[oe,U]}),t[57]=oe,t[58]=U,t[59]=W):W=t[59];let se;t[60]!==ie||t[61]!==ae||t[62]!==W?(se=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5 sm:p-6`,children:[ie,ae,W]}),t[60]=ie,t[61]=ae,t[62]=W,t[63]=se):se=t[63];let G;t[64]!==d||t[65]!==r||t[66]!==s||t[67]!==v.endPriority||t[68]!==v.endingPriority?(G=r&&d?(0,Q.jsxs)(Y,{variant:`ghost`,className:`text-danger hover:text-danger`,disabled:s,onClick:d,children:[s?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,s?v.endingPriority:v.endPriority]}):(0,Q.jsx)(`span`,{}),t[64]=d,t[65]=r,t[66]=s,t[67]=v.endPriority,t[68]=v.endingPriority,t[69]=G):G=t[69];let ce;t[70]!==s||t[71]!==v.cancel?(ce=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{disabled:s,children:v.cancel})}),t[70]=s,t[71]=v.cancel,t[72]=ce):ce=t[72];let le=!ee||s,ue;t[73]===s?ue=t[74]:(ue=s?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,t[73]=s,t[74]=ue);let de;t[75]!==v.savePriority||t[76]!==le||t[77]!==ue?(de=(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,disabled:le,children:[ue,v.savePriority]}),t[75]=v.savePriority,t[76]=le,t[77]=ue,t[78]=de):de=t[78];let K;t[79]!==ce||t[80]!==de?(K=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[ce,de]}),t[79]=ce,t[80]=de,t[81]=K):K=t[81];let q;t[82]!==G||t[83]!==K?(q=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[G,K]}),t[82]=G,t[83]=K,t[84]=q):q=t[84];let J;t[85]!==j||t[86]!==z||t[87]!==se||t[88]!==q?(J=(0,Q.jsxs)(m,{children:[N,(0,Q.jsx)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:j,children:[z,se,q]})})]}),t[85]=j,t[86]=z,t[87]=se,t[88]=q,t[89]=J):J=t[89];let fe;return t[90]!==c||t[91]!==n||t[92]!==J?(fe=(0,Q.jsx)(_,{open:n,onOpenChange:c,children:J}),t[90]=c,t[91]=n,t[92]=J,t[93]=fe):fe=t[93],fe}function rn(e){let t=(0,Z.c)(16),{rule:n,language:r,busy:i,onToggle:a}=e,o=It[r],s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l;t[3]!==n.status||t[4]!==o.disabled?(l=n.status===`disabled`?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.disabled}):null,t[3]=n.status,t[4]=o.disabled,t[5]=l):l=t[5];let u=n.status===`active`?o.disable:o.enable,d;t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,Q.jsx)(Y,{variant:`ghost`,className:`h-8`,disabled:i,onClick:a,children:u}),t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==l||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,c,f]}),t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function an(e){let t=(0,Z.c)(15),{suggestion:n,language:r,busy:i,onConfirm:a}=e,o=r===`zh`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(we,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l=o?`根据你已确认的模式生成;确认前不会生效`:`Suggested from a pattern you confirmed; inactive until you approve`,u;t[3]===l?u=t[4]:(u=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:l}),t[3]=l,t[4]=u);let d;t[5]!==c||t[6]!==u?(d=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c,u]}),t[5]=c,t[6]=u,t[7]=d):d=t[7];let f=i?o?`启用中…`:`Enabling…`:o?`确认启用`:`Approve`,p;t[8]!==i||t[9]!==a||t[10]!==f?(p=(0,Q.jsx)(Y,{variant:`secondary`,className:`h-8 shrink-0`,disabled:i,onClick:a,children:f}),t[8]=i,t[9]=a,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14],m}function on(e){let t=(0,Z.c)(27),{item:n,language:r,busy:i,expanded:a,onToggle:o,editing:s,draft:c,onDraftChange:l,onEdit:u,onCancel:d,onReview:f,onDelete:p,onScopeChange:m}=e,h=It[r],g=n.updatedAt??n.createdAt,_;t[0]!==r||t[1]!==g?(_=Ut(g,r),t[0]=r,t[1]=g,t[2]=_):_=t[2];let y=_,b;t[3]!==n.claimMode||t[4]!==n.content?(b=n.content.length>96||n.content.includes(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,m as a,t as o}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as s,n as c,o as l}from"./locale-store-tI9VX7dp.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-CY7CS_D3.js";import{n as v,t as y}from"./earth-C9Z4bTTG.js";import{t as b}from"./bot-DjLkhyZL.js";import{C as x,S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,m as ee,n as N,o as te,p as P,r as F,s as I,t as L,v as R,w as z,x as B,y as ne}from"./understanding-refresh-store-Cf0DUO_C.js";import{t as re}from"./briefcase-business-BsoCaI_t.js";import{t as ie}from"./calendar-days-hw_Y-g-s.js";import{t as ae}from"./check-DUBLcKHA.js";import{t as oe}from"./chevron-down-ccbiQQz_.js";import{t as V}from"./chevron-right-BweFrslA.js";import{n as H,r as U,t as W}from"./popover-select-CLsphyzA.js";import{t as se}from"./circle-alert-BEjgurr2.js";import{t as G}from"./circle-check-C23XjkUj.js";import{t as ce}from"./clock-3-DnrAnuyZ.js";import{t as le}from"./database-CjjeZfRG.js";import{t as ue}from"./download-Dk-ZjtO6.js";import{t as de}from"./ellipsis-0k4rZLoy.js";import{m as K,p as q,t as J}from"./understanding-activity-store-BNVhtJkn.js";import{t as fe}from"./folder-open-CyzJ19I9.js";import{t as pe}from"./git-branch-Dh9uxTot.js";import{t as me}from"./list-todo-CTVRto8O.js";import{t as he}from"./loader-circle-CifKLtgG.js";import{t as ge}from"./lock-keyhole-DEK5kH0u.js";import{t as _e}from"./message-circle-Badhj-4D.js";import{t as ve}from"./pencil-DmIY3Oa-.js";import{t as ye}from"./plus-Q2yW6OE7.js";import{t as be}from"./refresh-cw-BRlGaq2w.js";import{t as xe}from"./search-DA7gz22f.js";import{t as Se}from"./shield-check-BU58siTV.js";import{t as Ce}from"./sliders-horizontal-DqsYor6I.js";import{t as we}from"./sparkles-DHlfQFAF.js";import{t as Te}from"./sticky-note-fzP7NAJq.js";import{t as Ee}from"./trash-2-DusmjVPV.js";import{t as De}from"./upload-rrb46c3c.js";import{t as Oe}from"./user-round-C9jxPhMR.js";import{t as ke}from"./x-B_N4OPjy.js";import{t as Ae}from"./cn-0WouolD0.js";import{t as je}from"./skeleton-DzdOeGYz.js";import{i as Me}from"./vendor-swr-CdRzEUwF.js";import{t as Y}from"./button-Cc4hUNTt.js";import{r as Ne}from"./app-chrome-BeB4KgOf.js";import{t as Pe}from"./page-tabs-oeTY7z3_.js";import{t as Fe}from"./page-header-store-DeaRqZgV.js";import{t as Ie}from"./loopi-CNtmi9FU.js";import{t as Le}from"./sliding-tab-list-CmcrqRzN.js";import{l as Re,m as ze,o as Be,r as Ve,t as He}from"./dist-ZrL34Ps4.js";import{t as Ue}from"./date-picker-ClRDaNBJ.js";var X=e(t(),1),Z=n(),Q=r();function We(e){let t=(0,Z.c)(15),{sourceId:n,disabled:r}=e,i=r!==void 0&&r,a=c(qe)===`zh`,{sources:o,starting:s,start:l}=L(),u;t[0]!==n||t[1]!==o?(u=n?o.filter(e=>e.grantId===n):o,t[0]=n,t[1]=o,t[2]=u):u=t[2];let d=u,f;t[3]===d?f=t[4]:(f=d.some(Ke),t[3]=d,t[4]=f);let p=f,m=n&&d.some(Ge),h=p?a?`更新中`:`Updating`:m?a?`重试`:`Retry`:n?a?`更新理解`:`Update understanding`:a?`更新全部`:`Update all`,g=i||s||p,_;t[5]!==n||t[6]!==l?(_=()=>void l(n),t[5]=n,t[6]=l,t[7]=_):_=t[7];let v;t[8]===p?v=t[9]:(v=p?(0,Q.jsx)(he,{className:`size-3.5 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(be,{className:`size-3.5`}),t[8]=p,t[9]=v);let y;return t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==v?(y=(0,Q.jsxs)(Y,{variant:`ghost`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs`,disabled:g,onClick:_,children:[v,h]}),t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y):y=t[14],y}function Ge(e){return e.status===`failed`||e.status===`partial`||e.status===`canceled`}function Ke(e){return e.status===`queued`||e.status===`running`}function qe(e){return e.language}function Je(e){let t=(0,Z.c)(22),{sourceId:n,lastCollectedAt:r}=e,i=c(Ye),a=i===`zh`,o;t[0]===n?o=t[1]:(o=e=>e.sources.find(e=>e.grantId===n),t[0]=n,t[1]=o);let s=L(o);if(!s){let e;t[2]!==i||t[3]!==r||t[4]!==a?(e=r?`${a?`上次更新:`:`Last updated: `}${new Date(r).toLocaleString(i)}`:a?`尚未分析`:`Not analyzed yet`,t[2]=i,t[3]=r,t[4]=a,t[5]=e):e=t[5];let n;return t[6]===e?n=t[7]:(n=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e}),t[6]=e,t[7]=n),n}let l;t[8]===a?l=t[9]:(l=a?{queued:`等待更新`,waiting_desktop:`等待桌面端读取资料`,reading:`正在读取资料`,analyzing:`正在更新理解`}:{queued:`Queued`,waiting_desktop:`Waiting for desktop collection`,reading:`Reading source`,analyzing:`Updating understanding`},t[8]=a,t[9]=l);let u=l,d=s.status===`running`||s.status===`queued`,f=s.status===`failed`||s.status===`partial`||s.status===`canceled`,p=s.metadata.added,m=d?u[s.metadata.phase??`queued`]??u.queued:f?a?`更新未完成,可重试`:`Update incomplete; retry available`:p===0?a?`更新完成,暂无新增理解`:`Updated; no new understanding`:p===void 0?a?`更新完成`:`Updated`:a?`更新完成,新增 ${p} 条`:`Updated; ${p} added`,h;t[10]===m?h=t[11]:(h=(0,Q.jsx)(`p`,{children:m}),t[10]=m,t[11]=h);let g;t[12]!==i||t[13]!==s.completedAt?(g=s.completedAt?(0,Q.jsx)(`p`,{children:new Date(s.completedAt).toLocaleString(i)}):null,t[12]=i,t[13]=s.completedAt,t[14]=g):g=t[14];let _;t[15]!==f||t[16]!==s.errorMessage?(_=f&&s.errorMessage?(0,Q.jsx)(`p`,{className:`text-danger`,children:s.errorMessage}):null,t[15]=f,t[16]=s.errorMessage,t[17]=_):_=t[17];let v;return t[18]!==h||t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,"aria-live":`polite`,children:[h,g,_]}),t[18]=h,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Ye(e){return e.language}function Xe(e){let t=(0,Z.c)(87),{language:n,busy:r,statement:i,scope:a,onEdit:o,onDelete:s,onScopeChange:c}=e,[l,d]=(0,X.useState)(!1),[v,x]=(0,X.useState)(!1),S=n===`zh`,{data:C,isLoading:w,error:T}=Me(v?`memory-scope-options`:null,Ze),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E={type:`global`},t[0]=E):E=t[0];let D=S?`所有协作`:`All work`,O=S?`任何助手和对话都可按需使用`:`Available when relevant across all work`,k;t[1]!==D||t[2]!==O?(k={value:E,icon:y,title:D,detail:O},t[1]=D,t[2]=O,t[3]=k):k=t[3];let A;if(t[4]!==a||t[5]!==C?.agents||t[6]!==C?.projects||t[7]!==k||t[8]!==S){let e;t[10]===S?e=t[11]:(e=e=>({value:{type:`agent`,id:e.id},icon:b,title:S?`仅助手:${e.name||e.id}`:`Assistant: ${e.name||e.id}`,detail:S?`不会分享给其他助手`:`Not shared with other assistants`}),t[10]=S,t[11]=e);let n;if(t[12]===S?n=t[13]:(n=e=>({value:{type:`project`,id:e.id},icon:y,title:S?`仅项目:${e.name}`:`Project: ${e.name}`,detail:S?`仅在此项目中按需使用`:`Available only in this project`}),t[12]=S,t[13]=n),A=[k,...(C?.agents??[]).map(e),...(C?.projects??[]).map(n)],a&&!A.some(e=>e.value.type===a.type&&e.value.id===a.id)){let e=S?`保留现有范围`:`Keep existing scope`,n;t[14]===S?n=t[15]:(n=S?{global:`所有协作`,agent:`指定助手`,workspace:`指定工作区`,project:`指定项目`,session:`指定会话`}:{global:`All work`,agent:`Assigned assistant`,workspace:`Assigned workspace`,project:`Assigned project`,session:`Assigned conversation`},t[14]=S,t[15]=n);let r=n[a.type],i;t[16]!==a||t[17]!==e||t[18]!==r?(i={value:a,icon:b,title:e,detail:r},t[16]=a,t[17]=e,t[18]=r,t[19]=i):i=t[19],A.push(i)}t[4]=a,t[5]=C?.agents,t[6]=C?.projects,t[7]=k,t[8]=S,t[9]=A}else A=t[9];let j=S?`修改或删除这条内容`:`Edit or delete this item`,M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),t[20]=M):M=t[20];let ee;t[21]!==r||t[22]!==j?(ee=(0,Q.jsx)(ze,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-11 shrink-0 p-0`,disabled:r,"aria-label":j,children:M})}),t[21]=r,t[22]=j,t[23]=ee):ee=t[23];let N;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(ve,{className:`size-4`,"aria-hidden":`true`}),t[24]=N):N=t[24];let te=S?`修改`:`Edit`,P;t[25]!==r||t[26]!==o||t[27]!==te?(P=(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:o,children:[N,te]}),t[25]=r,t[26]=o,t[27]=te,t[28]=P):P=t[28];let F;t[29]!==r||t[30]!==c||t[31]!==a||t[32]!==S?(F=a&&c?(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:()=>x(!0),children:[(0,Q.jsx)(Ce,{className:`size-4`,"aria-hidden":`true`}),S?`作用范围`:`Where it applies`]}):null,t[29]=r,t[30]=c,t[31]=a,t[32]=S,t[33]=F):F=t[33];let I,L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>d(!0),L=(0,Q.jsx)(Ee,{className:`size-4`,"aria-hidden":`true`}),t[34]=I,t[35]=L):(I=t[34],L=t[35]);let R=S?`删除`:`Delete`,z;t[36]!==r||t[37]!==R?(z=(0,Q.jsxs)(Ve,{className:`flex min-h-11 cursor-pointer items-center gap-2 rounded-lg px-3 text-sm text-fg outline-none focus:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,disabled:r,onSelect:I,children:[L,R]}),t[36]=r,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==P||t[40]!==F||t[41]!==z?(B=(0,Q.jsx)(Be,{children:(0,Q.jsxs)(He,{align:`end`,sideOffset:4,className:`z-[100] min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[P,F,z]})}),t[39]=P,t[40]=F,t[41]=z,t[42]=B):B=t[42];let ne;t[43]!==B||t[44]!==ee?(ne=(0,Q.jsxs)(Re,{modal:!1,children:[ee,B]}),t[43]=B,t[44]=ee,t[45]=ne):ne=t[45];let re;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(u,{className:`fixed inset-0 z-[110] bg-scrim`}),t[46]=re):re=t[46];let ie=S?`删除这条内容?`:`Delete this item?`,ae;t[47]===ie?ae=t[48]:(ae=(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:ie}),t[47]=ie,t[48]=ae);let oe=S?`删除后将不再使用这条记忆,原始对话和文件会保留。`:`This memory will no longer be used. Original conversations and files are kept.`,V;t[49]===oe?V=t[50]:(V=(0,Q.jsx)(f,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:oe}),t[49]=oe,t[50]=V);let H;t[51]!==ae||t[52]!==V?(H=(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[ae,V]}),t[51]=ae,t[52]=V,t[53]=H):H=t[53];let U;t[54]===i?U=t[55]:(U=(0,Q.jsx)(`p`,{className:`min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words px-5 py-4 text-sm leading-6 text-fg`,children:i}),t[54]=i,t[55]=U);let W=S?`取消`:`Cancel`,se;t[56]===W?se=t[57]:(se=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,children:W})}),t[56]=W,t[57]=se);let G;t[58]===s?G=t[59]:(G=()=>{d(!1),s()},t[58]=s,t[59]=G);let ce=S?`删除`:`Delete`,le;t[60]!==r||t[61]!==G||t[62]!==ce?(le=(0,Q.jsx)(Y,{disabled:r,onClick:G,children:ce}),t[60]=r,t[61]=G,t[62]=ce,t[63]=le):le=t[63];let ue;t[64]!==se||t[65]!==le?(ue=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3`,children:[se,le]}),t[64]=se,t[65]=le,t[66]=ue):ue=t[66];let K;t[67]!==H||t[68]!==U||t[69]!==ue?(K=(0,Q.jsxs)(m,{children:[re,(0,Q.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(22rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[H,U,ue]})]}),t[67]=H,t[68]=U,t[69]=ue,t[70]=K):K=t[70];let q;t[71]!==l||t[72]!==ne||t[73]!==K?(q=(0,Q.jsxs)(_,{open:l,onOpenChange:d,children:[ne,K]}),t[71]=l,t[72]=ne,t[73]=K,t[74]=q):q=t[74];let J;t[75]!==r||t[76]!==A||t[77]!==c||t[78]!==a||t[79]!==T||t[80]!==w||t[81]!==v||t[82]!==S?(J=a&&c?(0,Q.jsx)(_,{open:v,onOpenChange:x,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`fixed inset-0 z-[110] bg-scrim`}),(0,Q.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[120] flex h-[min(25rem,calc(100dvh-2rem))] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,Q.jsxs)(`header`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:S?`这条记忆在哪里生效?`:`Where should this memory apply?`}),(0,Q.jsx)(f,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:S?`选择明确的助手或项目。工作区和会话范围也可在对应聊天中设置。`:`Choose an assistant or project. Workspace and conversation scopes can also be set in the corresponding chat.`})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-4`,children:[w?(0,Q.jsx)(je,{className:`h-20 w-full rounded-xl`}):null,T?(0,Q.jsx)(`p`,{role:`status`,className:`px-4 py-2 text-sm text-fg-muted`,children:S?`无法载入范围,请重试;现有范围未改变。`:`Could not load scopes. Your existing scope is unchanged.`}):null,A.map(e=>{let{value:t,icon:n,title:i,detail:o}=e,s=a.type===t.type&&(a.id??``)===(t.id??``);return(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full items-center gap-3 rounded-xl px-4 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${s?`bg-surface-active`:`hover:bg-surface-hover`}`,disabled:r,onClick:()=>{x(!1),c(t)},children:[(0,Q.jsx)(n,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:o})]}),s?(0,Q.jsx)(`span`,{className:`text-xs font-medium text-accent-fg`,children:S?`当前`:`Current`}):null]},`${t.type}:${t.id??``}`)})]}),(0,Q.jsx)(`footer`,{className:`flex shrink-0 justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,children:S?`取消`:`Cancel`})})})]})]})}):null,t[75]=r,t[76]=A,t[77]=c,t[78]=a,t[79]=T,t[80]=w,t[81]=v,t[82]=S,t[83]=J):J=t[83];let fe;return t[84]!==q||t[85]!==J?(fe=(0,Q.jsxs)(Q.Fragment,{children:[q,J]}),t[84]=q,t[85]=J,t[86]=fe):fe=t[86],fe}async function Ze(){let[e,t]=await Promise.all([l(s(`/api/agents`)),l(s(`/api/projects`))]);return{agents:e.payload?.agents??[],projects:t.items??[]}}function Qe(e,t){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}).format(e):null}function $e(e,t,n=new Date){let r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r);i.setDate(r.getDate()-1);let a=new Map;for(let n of[...e].sort((e,t)=>t.recordedAt-e.recordedAt)){let e=n.recordedAt>=r.getTime()?t===`zh`?`今天`:`Today`:n.recordedAt>=i.getTime()?t===`zh`?`昨天`:`Yesterday`:Qe(n.recordedAt,t)??(t===`zh`?`更早`:`Earlier`),o=a.get(e)??[];o.push(n),a.set(e,o)}return[...a].map(([e,t])=>({label:e,items:t}))}function et(e,t){return(t===`zh`?{user_explicit:`你告诉我的`,user_observed:`从协作中观察到`,system_inferred:`xopc 的推测`,external_untrusted:`来自连接的信息`}:{user_explicit:`You told me`,user_observed:`Observed while working together`,system_inferred:`Inferred by xopc`,external_untrusted:`From connected information`})[e.authority]}function tt(e,t){if(e.validTo){let n=Qe(e.validTo,t);return t===`zh`?`适用至 ${n}`:`Applies until ${n}`}return(t===`zh`?{stable:`相对稳定`,slow:`会随时间复核`,dynamic:`近期状态`,event:`特定阶段`}:{stable:`Relatively stable`,slow:`Reviewed over time`,dynamic:`Current context`,event:`Specific period`})[e.volatility]}function nt(e,t){return e.authority===`user_explicit`?null:e.confidence>=.85?t===`zh`?`把握较高`:`High confidence`:e.confidence>=.65?t===`zh`?`把握中等`:`Medium confidence`:t===`zh`?`证据较少`:`Limited evidence`}function rt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function it(e){let t=(0,Z.c)(25),{item:n,language:r,busy:i,editing:a,draft:o,onDraftChange:s,onEdit:c,onCancel:l,onDelete:u,onCorrect:d,onScopeChange:f}=e,p=(0,X.useId)(),[m,h]=(0,X.useState)(!1),g=r===`zh`,_;t[0]!==n||t[1]!==r?(_=nt(n,r),t[0]=n,t[1]=r,t[2]=_):_=t[2];let v=_,y;t[3]===n.sources?y=t[4]:(y=new Set(n.sources?.map(ot).filter(Boolean)),t[3]=n.sources,t[4]=y);let b;t[5]===y?b=t[6]:(b=[...y],t[5]=y,t[6]=b);let x=b,S=g?`修改`:`Edit`,C;return t[7]!==i||t[8]!==v||t[9]!==o||t[10]!==S||t[11]!==a||t[12]!==m||t[13]!==p||t[14]!==n||t[15]!==r||t[16]!==l||t[17]!==d||t[18]!==u||t[19]!==s||t[20]!==c||t[21]!==f||t[22]!==x||t[23]!==g?(C=(0,Q.jsx)(`article`,{className:`border-t border-edge-subtle px-4 py-3 first:border-t-0 sm:px-5 [content-visibility:auto] [contain-intrinsic-size:auto_100px]`,children:a?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:p,children:g?`修改这条理解`:`Edit this understanding`}),(0,Q.jsx)(`textarea`,{id:p,value:o,disabled:i,onChange:e=>s(e.target.value),className:`mt-2 min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-base leading-7 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(Y,{variant:`ghost`,disabled:i,onClick:l,children:g?`取消`:`Cancel`}),(0,Q.jsx)(Y,{variant:`primary`,disabled:!o.trim()||i,onClick:d,children:i?g?`保存中…`:`Saving…`:g?`保存修改`:`Save changes`})]})]}):(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 sm:flex sm:gap-4`,children:[(0,Q.jsxs)(`div`,{className:`contents min-w-0 flex-1 pt-1.5 sm:block`,children:[(0,Q.jsx)(`p`,{className:`col-span-2 whitespace-pre-wrap break-words text-base leading-7 text-fg`,children:!m&&n.statement.length>240?`${n.statement.slice(0,240)}…`:n.statement}),n.statement.length>240?(0,Q.jsx)(`button`,{type:`button`,"aria-expanded":m,onClick:()=>h(!m),className:`col-span-2 mt-1 min-h-11 rounded-md text-left text-sm text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m?g?`收起全文`:`Show less`:g?`展开全文`:`Read more`}):null,(0,Q.jsxs)(`div`,{className:`col-start-1 mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:et(n,r)}),n.usable===!1?(0,Q.jsx)(`span`,{children:g?`暂不使用`:`Not in use`}):null,n.validTo?(0,Q.jsx)(`span`,{children:tt(n,r)}):null,n.authority!==`user_explicit`&&n.confidence<.65?(0,Q.jsx)(`span`,{children:v}):null,(0,Q.jsxs)(`details`,{className:`open:basis-full`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-11 w-fit cursor-pointer items-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:g?`查看来源`:`Sources`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:g?`来源与使用方式`:`Sources & use`})]}),(0,Q.jsxs)(`div`,{className:`my-2 space-y-1 border-l-2 border-edge pl-3 text-sm leading-6`,children:[(0,Q.jsx)(`p`,{children:n.usable===!1?g?`目前不会用于回答。`:`Currently not used in responses.`:g?`回答相关问题时,xopc 会参考这条信息。`:`xopc can refer to this when answering related questions.`}),(0,Q.jsxs)(`p`,{children:[g?`适用范围:`:`Applies to: `,rt(n.scope,r)]}),n.validTo?(0,Q.jsx)(`p`,{children:tt(n,r)}):null,v?(0,Q.jsxs)(`p`,{children:[g?`确定程度:`:`Confidence: `,v]}):null,(0,Q.jsxs)(`p`,{children:[g?`最近记录:`:`Last noted: `,Qe(n.observedAt,r)]}),x.length?x.map(at):(0,Q.jsx)(`p`,{children:g?`暂无更详细的来源记录`:`No further source details available`})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,Q.jsx)(Y,{variant:`ghost`,className:`min-h-11 min-w-11 px-2`,disabled:i,onClick:c,children:S}),(0,Q.jsx)(Xe,{language:r,busy:i,statement:n.statement,scope:n.scope,onEdit:c,onDelete:u,onScopeChange:f})]})]})}),t[7]=i,t[8]=v,t[9]=o,t[10]=S,t[11]=a,t[12]=m,t[13]=p,t[14]=n,t[15]=r,t[16]=l,t[17]=d,t[18]=u,t[19]=s,t[20]=c,t[21]=f,t[22]=x,t[23]=g,t[24]=C):C=t[24],C}function at(e){return(0,Q.jsx)(`p`,{className:`break-words`,children:e},e)}function ot(e){return e.label}var st={zh:{eyebrow:`全局用户理解`,title:`xopc 如何形成对你的理解`,subtitle:`这里汇总跨项目、跨对话形成的认识,并说明它们来自哪些渠道。项目事实不会混入你的个人画像。`,channels:`理解渠道`,channelHint:`查看来源及其最近更新。`,noChannels:`尚未通过任何渠道形成可展示的全局理解。`,activeCount:`{{count}} 条已在使用`,pendingCount:`{{count}} 条暂不使用`,noUnderstanding:`暂无来自此渠道的全局理解`,pending:`最近更新`,pendingHint:`自动整理并按需使用,你可以随时修改或删除。`,nothingPending:`尚未形成全局理解。`,showAll:`查看全部 {{count}} 条`,showLess:`收起`,done:`完成`,updating:`正在从已授权渠道更新理解;你可以先查看已有内容。`,sourceKinds:{user:`你明确告诉我的`,conversation:`对话与协作`,connector:`连接的服务`,work_folder:`工作目录`,local_source:`本机来源`,inference:`综合整理`}},en:{eyebrow:`Global user understanding`,title:`How xopc forms its understanding of you`,subtitle:`This brings together understanding formed across projects and conversations, with the channel behind each item. Project facts stay out of your personal portrait.`,channels:`Understanding channels`,channelHint:`View sources and their latest updates.`,noChannels:`No channel has formed displayable global understanding yet.`,activeCount:`{{count}} in use`,pendingCount:`{{count}} not in use`,noUnderstanding:`No usable global understanding has formed from this channel yet`,pending:`Recent updates`,pendingHint:`Organized automatically and used when relevant. Edit or delete anytime.`,nothingPending:`No understanding has formed yet.`,showAll:`View all {{count}}`,showLess:`Show less`,done:`Done`,updating:`Updating from authorized channels. You can review existing understanding now.`,sourceKinds:{user:`You told me`,conversation:`Conversations and work`,connector:`Connected services`,work_folder:`Work folders`,local_source:`On-device sources`,inference:`Synthesized understanding`}}},ct={"local-recent-files":{en:`Recent files`,zh:`最近文件`},"chromium-bookmarks":{en:`Recent bookmarks`,zh:`最近书签`},"apple-notes":{en:`Apple Notes`,zh:`Apple 备忘录`},"apple-mail":{en:`Apple Mail`,zh:`Apple 邮件`},"apple-calendar":{en:`Apple Calendar`,zh:`Apple 日历`},"apple-reminders":{en:`Apple Reminders`,zh:`Apple 提醒事项`},"windows-recent-documents":{en:`Recent documents`,zh:`最近文档`},"linux-recent-documents":{en:`Recent documents`,zh:`最近文档`}},lt={user:Oe,conversation:_e,connector:le,work_folder:fe,local_source:K,inference:le},ut={files:fe,recent_documents:K,calendar:ie,tasks:me,notes:Te,mail:q,messages:_e,code_activity:pe};function $(e){let t=e.authority===`user_explicit`?`user`:e.authority===`user_observed`?`conversation`:e.authority===`external_untrusted`?`connector`:`inference`;return{id:t,kind:t,observedAt:e.observedAt}}function dt(e,t){return e.kind===`local_source`&&e.label?ct[e.label]?.[t]??e.label:e.kind===`work_folder`&&e.label?t===`zh`?`工作目录 · ${e.label}`:`Work folder · ${e.label}`:e.label?e.label:st[t].sourceKinds[e.kind]}function ft(e){return`${e.kind}:${e.adapterId}:${e.displayName}`}function pt(e){let t=(0,Z.c)(91),{assertions:n,configuredSources:r,activityRunning:i,language:a,busy:o,error:s,onReviewAssertion:c,onCompleted:l}=e,u=st[a],[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(``),_;t[0]===n?_=t[1]:(_=n.filter(bt),t[0]=n,t[1]=_);let v=_,y;t[2]===v?y=t[3]:(y=[...v].sort(yt),t[2]=v,t[3]=y);let b=y,x;if(t[4]!==r||t[5]!==v||t[6]!==a){let e=new Map;for(let t of r){let n=t.kind===`local_source`?ct[t.adapterId]?.[a]??t.displayName:t.displayName,r=ft(t);e.set(r,{key:r,grantId:t.id,kind:t.kind,category:t.category,label:t.kind===`work_folder`?a===`zh`?`工作目录 · ${n}`:`Work folder · ${n}`:n,assertions:[],lastObservedAt:t.lastCollectedAt})}for(let t of v)for(let n of t.sources?.length?t.sources:[$(t)]){let r=dt(n,a),i=[...e.values()].find(e=>e.kind===n.kind&&e.label===r),o=i?.key??`${n.kind}:${r}`,s=i??e.get(o)??{key:o,kind:n.kind,category:n.category,label:r,assertions:[],lastObservedAt:n.observedAt};s.assertions.some(e=>e.id===t.id)||s.assertions.push(t),s.lastObservedAt=Math.max(s.lastObservedAt??0,n.observedAt),e.set(o,s)}x=[...e.values()].sort(vt),t[4]=r,t[5]=v,t[6]=a,t[7]=x}else x=t[7];let S=x,C;t[8]===c?C=t[9]:(C=async(e,t,n)=>{await c(e,t,n)&&m(null)},t[8]=c,t[9]=C);let w=C,T,E,D,O,k,A,j,M,ee;if(t[10]!==i||t[11]!==o||t[12]!==h||t[13]!==p||t[14]!==a||t[15]!==b||t[16]!==w||t[17]!==d||t[18]!==u.eyebrow||t[19]!==u.nothingPending||t[20]!==u.pending||t[21]!==u.pendingHint||t[22]!==u.showAll||t[23]!==u.showLess||t[24]!==u.subtitle||t[25]!==u.title||t[26]!==u.updating){let e=d?b:b.slice(0,5);T=`mx-auto w-full max-w-[42rem] pb-2`,E=`polite`;let n;t[36]===u.eyebrow?n=t[37]:(n=(0,Q.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-accent-fg`,children:u.eyebrow}),t[36]=u.eyebrow,t[37]=n);let r;t[38]===u.title?r=t[39]:(r=(0,Q.jsx)(`h2`,{className:`mt-3 text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:u.title}),t[38]=u.title,t[39]=r);let s;t[40]===u.subtitle?s=t[41]:(s=(0,Q.jsx)(`p`,{className:`mx-auto mt-3 max-w-[38rem] text-sm leading-6 text-fg-muted`,children:u.subtitle}),t[40]=u.subtitle,t[41]=s),t[42]!==n||t[43]!==r||t[44]!==s?(D=(0,Q.jsxs)(`div`,{className:`text-center`,children:[n,r,s]}),t[42]=n,t[43]=r,t[44]=s,t[45]=D):D=t[45],t[46]!==i||t[47]!==u.updating?(O=i?(0,Q.jsxs)(`div`,{className:`mt-6 flex items-center gap-3 rounded-xl border border-accent/20 bg-accent-soft/55 px-4 py-3 text-sm text-accent-fg`,children:[(0,Q.jsx)(he,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`}),(0,Q.jsx)(`p`,{children:u.updating})]}):null,t[46]=i,t[47]=u.updating,t[48]=O):O=t[48],k=`mt-8`,A=`understanding-updates-title`;let c=b.length?` · ${b.length}`:``;t[49]!==u.pending||t[50]!==c?(j=(0,Q.jsxs)(`h3`,{id:`understanding-updates-title`,className:`text-sm font-semibold text-fg`,children:[u.pending,c]}),t[49]=u.pending,t[50]=c,t[51]=j):j=t[51],t[52]===u.pendingHint?M=t[53]:(M=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.pendingHint}),t[52]=u.pendingHint,t[53]=M),ee=b.length?(0,Q.jsxs)(`div`,{className:`mt-3`,children:[$e(e,a).map(e=>{let{label:t,items:n}=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`border-b border-edge-subtle px-4 pb-2 pt-3 text-xs font-medium text-fg-muted`,children:t}),(0,Q.jsx)(`div`,{children:n.map(e=>(0,Q.jsx)(it,{item:e,language:a,busy:o,editing:p===e.id,draft:h,onDraftChange:g,onEdit:()=>{m(e.id),g(e.statement)},onCancel:()=>m(null),onCorrect:()=>void w(e,`edited`,h.trim()),onDelete:()=>void w(e,`deleted`)},e.id))})]},t)}),b.length>5?(0,Q.jsxs)(`button`,{type:`button`,className:`mx-auto flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>f(_t),children:[d?u.showLess:u.showAll.replace(`{{count}}`,String(b.length)),(0,Q.jsx)(oe,{className:Ae(`size-3.5 transition-transform`,d&&`rotate-180`)})]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-3 flex items-start gap-3 rounded-xl border border-edge bg-surface-base/55 p-4`,children:[(0,Q.jsx)(G,{className:`mt-0.5 size-5 shrink-0 text-success`}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:u.nothingPending})]}),t[10]=i,t[11]=o,t[12]=h,t[13]=p,t[14]=a,t[15]=b,t[16]=w,t[17]=d,t[18]=u.eyebrow,t[19]=u.nothingPending,t[20]=u.pending,t[21]=u.pendingHint,t[22]=u.showAll,t[23]=u.showLess,t[24]=u.subtitle,t[25]=u.title,t[26]=u.updating,t[27]=T,t[28]=E,t[29]=D,t[30]=O,t[31]=k,t[32]=A,t[33]=j,t[34]=M,t[35]=ee}else T=t[27],E=t[28],D=t[29],O=t[30],k=t[31],A=t[32],j=t[33],M=t[34],ee=t[35];let N;t[54]!==k||t[55]!==A||t[56]!==j||t[57]!==M||t[58]!==ee?(N=(0,Q.jsxs)(`section`,{className:k,"aria-labelledby":A,children:[j,M,ee]}),t[54]=k,t[55]=A,t[56]=j,t[57]=M,t[58]=ee,t[59]=N):N=t[59];let te;t[60]!==S.length||t[61]!==u.channels?(te=(0,Q.jsxs)(`summary`,{className:`w-fit cursor-pointer rounded-md py-2 text-sm font-medium text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u.channels,` · `,S.length]}),t[60]=S.length,t[61]=u.channels,t[62]=te):te=t[62];let P;t[63]===u.channelHint?P=t[64]:(P=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.channelHint}),t[63]=u.channelHint,t[64]=P);let F;t[65]!==S||t[66]!==u.activeCount||t[67]!==u.noChannels||t[68]!==u.noUnderstanding||t[69]!==u.pendingCount?(F=S.length?(0,Q.jsx)(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let t=e.category?ut[e.category]??lt[e.kind]:lt[e.kind],n=e.assertions.filter(gt).length,r=e.assertions.filter(ht).length;return(0,Q.jsxs)(`article`,{className:`rounded-xl border border-edge bg-surface-base/55 px-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),e.grantId?(0,Q.jsx)(Je,{sourceId:e.grantId,lastCollectedAt:e.lastObservedAt}):null,e.assertions.length?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?u.activeCount.replace(`{{count}}`,String(n)):``,r?u.pendingCount.replace(`{{count}}`,String(r)):``].filter(Boolean).join(` · `)}):(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.noUnderstanding})]}),e.grantId?(0,Q.jsx)(We,{sourceId:e.grantId}):null]}),e.assertions.length?(0,Q.jsx)(`ul`,{className:`ml-12 mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,children:e.assertions.slice(0,5).map(mt)}):null]},e.key)})}):(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl border border-edge bg-surface-base/55 p-4 text-sm text-fg-muted`,children:u.noChannels}),t[65]=S,t[66]=u.activeCount,t[67]=u.noChannels,t[68]=u.noUnderstanding,t[69]=u.pendingCount,t[70]=F):F=t[70];let I;t[71]!==te||t[72]!==P||t[73]!==F?(I=(0,Q.jsxs)(`details`,{className:`mt-6 border-t border-edge pt-4`,children:[te,P,F]}),t[71]=te,t[72]=P,t[73]=F,t[74]=I):I=t[74];let L;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(ae,{className:`size-4`}),t[75]=L):L=t[75];let R;t[76]!==o||t[77]!==l||t[78]!==u.done?(R=(0,Q.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,Q.jsxs)(Y,{variant:`primary`,disabled:o,onClick:l,children:[L,u.done]})}),t[76]=o,t[77]=l,t[78]=u.done,t[79]=R):R=t[79];let z;t[80]===s?z=t[81]:(z=s?(0,Q.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:s}):null,t[80]=s,t[81]=z);let B;return t[82]!==T||t[83]!==E||t[84]!==D||t[85]!==O||t[86]!==N||t[87]!==I||t[88]!==R||t[89]!==z?(B=(0,Q.jsxs)(`section`,{className:T,"aria-live":E,children:[D,O,N,I,R,z]}),t[82]=T,t[83]=E,t[84]=D,t[85]=O,t[86]=N,t[87]=I,t[88]=R,t[89]=z,t[90]=B):B=t[90],B}function mt(e){return(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-2 size-1 shrink-0 rounded-full bg-accent/60`}),(0,Q.jsx)(`span`,{children:e.statement})]},e.id)}function ht(e){return!e.usable}function gt(e){return e.usable}function _t(e){return!e}function vt(e,t){return t.assertions.length-e.assertions.length||(t.lastObservedAt??0)-(e.lastObservedAt??0)}function yt(e,t){return t.recordedAt-e.recordedAt}function bt(e){return e.scope.type===`global`&&e.status!==`archived`&&e.status!==`rejected`}function xt(){let{pathname:e,search:t}=i(),n=c(e=>e.language),r=J(),[a,o]=(0,X.useState)(!1),[s,l]=(0,X.useState)(null),v=e===`/user-model`,{data:y,mutate:b}=Me(v?`/api/user-model`:null,M),x=L(e=>e.error),S=L(e=>e.sources.some(e=>e.status===`running`||e.status===`queued`)),C=n===`zh`;if((0,X.useEffect)(()=>{v&&new URLSearchParams(t).get(`workDiscovery`)===`review`&&J.getState().setDrawerOpen(!0)},[v,t]),(0,X.useEffect)(()=>{v&&r.status!==`running`&&b()},[b,v,r.directoryRun?.id,r.status]),!v)return null;let T=r.status===`running`||S,E=async(e,t,n)=>{o(!0),l(null);try{return t===`edited`&&n?await N(e.id,n):t===`deleted`&&await w(e.id),await b(),!0}catch(e){return l(e instanceof Error?e.message:String(e)),!1}finally{o(!1)}},D=e=>{if(!e&&y&&r.status!==`running`){r.finish();return}r.setDrawerOpen(e)};return(0,Q.jsxs)(_,{open:r.drawerOpen,onOpenChange:D,children:[(0,Q.jsx)(d,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:Ae(`relative size-8 rounded-xl p-0`,Ne),title:C?`查看 xopc 对你的理解`:`Review what xopc understands`,"aria-label":C?`查看 xopc 对你的理解`:`Review what xopc understands`,children:T?(0,Q.jsx)(he,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,Q.jsx)(we,{className:`size-4 text-accent-fg`})})}),(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`fixed inset-0 z-[60] bg-scrim backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:backdrop-blur-none`}),(0,Q.jsx)(`div`,{className:`pointer-events-none fixed inset-0 z-[61] flex items-center justify-center p-3 sm:p-6`,children:(0,Q.jsxs)(h,{className:`xopc-understanding-center pointer-events-auto flex h-[min(42rem,calc(100dvh-1.5rem))] w-[min(44rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float outline-none sm:h-[min(42rem,calc(100dvh-3rem))] sm:w-[min(44rem,calc(100vw-3rem))]`,children:[(0,Q.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-edge-subtle px-5 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(g,{className:`text-sm font-semibold text-fg`,children:T?C?`正在更新用户理解`:`Updating user understanding`:C?`用户理解`:`User understanding`}),(0,Q.jsx)(f,{className:`mt-0.5 text-xs text-fg-muted`,children:T?C?`关闭窗口也会在后台继续`:`You can close this window; work continues in the background`:C?`自动更新,可随时修改或删除`:`Updated automatically. Edit or delete anytime`})]}),(0,Q.jsx)(We,{disabled:!y?.sources?.length}),(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 rounded-xl p-0`,"aria-label":C?`关闭`:`Close`,children:(0,Q.jsx)(ke,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-7 sm:px-9 sm:py-9`,children:y?(0,Q.jsx)(pt,{assertions:y.assertions,configuredSources:y.sources??[],activityRunning:T,language:n,busy:a,error:s??x??null,onReviewAssertion:E,onCompleted:()=>{D(!1)}}):(0,Q.jsxs)(`section`,{className:`space-y-4`,"aria-label":C?`正在加载用户理解`:`Loading user understanding`,children:[(0,Q.jsx)(je,{className:`h-8 w-2/3`}),(0,Q.jsx)(je,{className:`h-32 w-full`}),(0,Q.jsx)(je,{className:`h-32 w-full`})]})})]})})]})]})}function St(e){let t=(0,Z.c)(34),{language:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:15e3},t[0]=r):r=t[0];let{data:i,error:a,isLoading:o}=Me(`memory-learning-status`,Nt,r);if(o){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(je,{className:`h-14 w-full rounded-xl`}),t[1]=e):e=t[1],e}if(a||!i?.jobs||!i?.coverage)return null;let s;t[2]===i.jobs?s=t[3]:(s=i.jobs.filter(Mt).reduce(jt,0),t[2]=i.jobs,t[3]=s);let c=s,l;t[4]===i.coverage?l=t[5]:(l=i.coverage.filter(At).reduce(kt,0),t[4]=i.coverage,t[5]=l);let u=l,d;t[6]===i.coverage?d=t[7]:(d=i.coverage.filter(Ot).reduce(Dt,0),t[6]=i.coverage,t[7]=d);let f=d,p;t[8]===i.jobs?p=t[9]:(p=i.jobs.filter(Et).reduce(Tt,0),t[8]=i.jobs,t[9]=p);let m=p,h;t[10]===i.jobs?h=t[11]:(h=i.jobs.filter(wt).reduce(Ct,0),t[10]=i.jobs,t[11]=h);let g=h,_=n===`zh`?`资料 ${f} 条 · 已生效记忆 ${u} 条`:`${f} sources · ${u} active memories`,v;t[12]!==n||t[13]!==c?(v=c>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${c} 项处理中`:`${c} processing`}):null,t[12]=n,t[13]=c,t[14]=v):v=t[14];let y=n===`zh`?`计数说明`:`About these counts`,b;t[15]===y?b=t[16]:(b=(0,Q.jsx)(`summary`,{className:`w-fit cursor-pointer rounded focus-visible:outline-accent`,children:y}),t[15]=y,t[16]=b);let x=n===`zh`?`仅统计已启用且有依据的工作记忆;管理列表包含其他状态。“关于你”单独计数。`:`Work memories must be active and supported. Management lists include other states. About you is counted separately.`,S;t[17]===x?S=t[18]:(S=(0,Q.jsx)(`p`,{className:`mt-1 leading-5`,children:x}),t[17]=x,t[18]=S);let C;t[19]!==b||t[20]!==S?(C=(0,Q.jsxs)(`details`,{className:`mt-1 text-xs`,children:[b,S]}),t[19]=b,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==m||t[23]!==n?(w=m>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${m} 项处理失败`:`${m} failed jobs`}):null,t[22]=m,t[23]=n,t[24]=w):w=t[24];let T;t[25]!==n||t[26]!==g?(T=g>0?(0,Q.jsx)(`span`,{className:`ml-2`,children:n===`zh`?`${g} 项等待配置本地模型`:`${g} jobs require a local model`}):null,t[25]=n,t[26]=g,t[27]=T):T=t[27];let E;return t[28]!==C||t[29]!==w||t[30]!==T||t[31]!==_||t[32]!==v?(E=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-4 py-3 text-sm text-fg-muted`,role:`status`,children:[_,v,C,w,T]}),t[28]=C,t[29]=w,t[30]=T,t[31]=_,t[32]=v,t[33]=E):E=t[33],E}function Ct(e,t){return e+t.count}function wt(e){return e.errorCode===`local_model_required`}function Tt(e,t){return e+t.count}function Et(e){return e.state===`failed`}function Dt(e,t){return e+t.count}function Ot(e){return e.recordClass===`source_index`}function kt(e,t){return e+t.count}function At(e){return e.recordClass===`memory`&&e.status===`active`&&e.verification===`supported`}function jt(e,t){return e+t.count}function Mt(e){return[`queued`,`running`,`retry_wait`].includes(e.state)}function Nt(){return l(s(`/api/memory-learning/status`))}function Pt(e){let t=(0,Z.c)(12),{id:n,language:r}=e,i;t[0]===n?i=t[1]:(i=()=>l(s(`/api/knowledge-memory/${encodeURIComponent(n)}/evidence`)),t[0]=n,t[1]=i);let{data:a,error:o,isLoading:c}=Me(`knowledge-evidence:${n}`,i);if(c){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(je,{className:`mt-3 h-10 w-full rounded-lg`}),t[2]=e):e=t[2],e}if(o){let e=r===`zh`?`此条证据目前不可用于回答,请检查来源授权、有效期和读取范围。`:`Evidence is currently unavailable. Check source authorization, validity and read scope.`,n;return t[3]===e?n=t[4]:(n=(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:e}),t[3]=e,t[4]=n),n}if(!Array.isArray(a?.evidence)||!a.evidence.length)return null;let u;if(t[5]!==a.evidence||t[6]!==r){let e;t[8]===r?e=t[9]:(e=(e,t)=>(0,Q.jsxs)(`p`,{children:[r===`zh`?`证据`:`Evidence`,` · `,e.sourceType===`conversation`?r===`zh`?`对话`:`Conversation`:e.sourceType===`runtime`?r===`zh`?`执行记录`:`Execution receipt`:r===`zh`?`授权资料`:`Authorized source`,` · `,new Date(e.observedAt).toLocaleDateString(r),e.excerpt?(0,Q.jsx)(`span`,{className:`mt-1 block whitespace-pre-wrap break-words`,children:e.excerpt}):null]},t),t[8]=r,t[9]=e),u=a.evidence.map(e),t[5]=a.evidence,t[6]=r,t[7]=u}else u=t[7];let d;return t[10]===u?d=t[11]:(d=(0,Q.jsx)(`div`,{className:`mt-3 space-y-2 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:u}),t[10]=u,t[11]=d),d}function Ft(e){let t=e.get(`tab`);return t===`understanding`&&e.get(`section`)===`work`?`work`:t===`understanding`||t===`work`||t===`privacy`?t:`overview`}var It={en:{pageTitle:`About you`,overview:`Overview`,understanding:`What xopc knows`,privacy:`Data & privacy`,knowledge:`Work memory`,editProfile:`Edit basics`,callName:`What should xopc call you?`,callNamePlaceholder:`For example: Alex, Joyce, or Dr. Chen`,role:`Your role`,rolePlaceholder:`For example: founder, designer, or engineer`,pronouns:`Pronouns (optional)`,pronounsPlaceholder:`For example: she/her, he/him, they/them`,timezone:`Timezone`,timezoneSearch:`Search timezones…`,timezoneNoMatch:`No matching timezone`,locale:`Language / locale`,useDeviceTimezone:`Use this device`,notProvided:`Not provided`,editProfileHint:`These are facts you provide directly. They remain separate from xopc’s observations and inferences.`,saveProfile:`Save`,saving:`Saving…`,explicit:`You told me`,explicitHint:`Facts and preferences you stated directly`,learned:`Learned together`,learnedHint:`Patterns formed from our work`,allUnderstanding:`All understanding`,understandingFilterHint:`Filter this view by how each item was formed.`,importantNow:`What matters now`,prioritySourceGoal:`From a goal you confirmed`,prioritySourceWork:`From your current work`,editPriority:`Edit focus`,addPriority:`Set current focus`,priorityTitle:`Current focus`,priorityTitlePlaceholder:`What matters most right now?`,priorityOutcome:`What a good outcome looks like`,priorityOutcomePlaceholder:`Describe the result you want…`,priorityUntil:`Focus through`,savePriority:`Save focus`,endPriority:`End focus`,endingPriority:`Ending…`,priorityHint:`This is used to keep xopc aligned with what deserves attention now.`,otherGoals:`Other active outcomes`,howWeWork:`How we work together`,noRules:`No collaboration preferences yet.`,seeAll:`See all`,workMemory:`What I remember from the work`,items:`items`,refresh:`Refresh`,refreshing:`Refreshing…`,refreshComplete:`Refreshed`,refreshFailed:`Refresh failed`,aboutYouTitle:`What xopc remembers about you`,aboutYouHint:`Review your background, preferences, and habits. Edit anything that no longer fits.`,identity:`Who you are`,preferences:`Preferences and working rhythm`,relationships:`People and relationships`,currentState:`Current context`,insights:`My current read`,emptyGroup:`No usable personal understanding yet. Ongoing preferences will build through collaboration; project facts and progress are in Work memory.`,correct:`Correct`,save:`Save correction`,cancel:`Cancel`,correctionPlaceholder:`Write the accurate version…`,searchPlaceholder:`Search work memory…`,allMemory:`All work memory`,memoryFilterHint:`Filter by memory type`,memoryLibraryHint:`Only distilled facts, decisions, lessons, commitments, and open questions appear here. Source records stay with their connector.`,noKnowledge:`No work memory has formed yet.`,noKnowledgeMatch:`No work memory matches this search.`,showMore:`Show more`,expand:`Show details`,collapse:`Hide details`,disable:`Disable`,disabled:`Not in use`,enable:`Enable`,loadFailed:`Could not load your understanding.`,tryAgain:`Try again`,actionFailed:`The change could not be saved. Please try again.`},zh:{pageTitle:`关于你`,overview:`总览`,understanding:`对我的了解`,privacy:`数据与隐私`,knowledge:`工作记忆`,editProfile:`编辑基本信息`,callName:`希望 xopc 如何称呼你?`,callNamePlaceholder:`例如:Mic、Joyce、张老师`,role:`你的角色`,rolePlaceholder:`例如:创业者、产品设计师、工程师`,pronouns:`代词(可选)`,pronounsPlaceholder:`例如:she/her、he/him、they/them`,timezone:`时区`,timezoneSearch:`搜索时区…`,timezoneNoMatch:`没有匹配的时区`,locale:`语言 / 地区`,useDeviceTimezone:`使用本机时区`,notProvided:`未填写`,editProfileHint:`这些是由你直接提供的事实,与 xopc 的观察和推断分开维护。`,saveProfile:`保存`,saving:`正在保存…`,explicit:`你告诉我的`,explicitHint:`你明确表达的事实与偏好`,learned:`协作中学到的`,learnedHint:`从实际协作中形成的认识`,allUnderstanding:`全部来源`,understandingFilterHint:`按内容来源筛选这份理解。`,importantNow:`你最近在关注什么`,prioritySourceGoal:`来自你确认的当前目标`,prioritySourceWork:`来自当前工作上下文`,editPriority:`编辑`,addPriority:`设置当前关注`,priorityTitle:`当前关注`,priorityTitlePlaceholder:`现在最重要的是什么?`,priorityOutcome:`期待结果`,priorityOutcomePlaceholder:`描述你希望达成的结果…`,priorityUntil:`关注至`,savePriority:`保存关注`,endPriority:`结束关注`,endingPriority:`正在结束…`,priorityHint:`这项内容会帮助 xopc 在协作中优先关注当前最重要的事情。`,otherGoals:`其他进行中的目标`,howWeWork:`我们怎样协作`,noRules:`还没有形成协作偏好。`,seeAll:`查看全部`,workMemory:`我在工作中记住的`,items:`条`,refresh:`刷新`,refreshing:`正在刷新…`,refreshComplete:`已刷新`,refreshFailed:`刷新失败`,aboutYouTitle:`xopc 记住的你`,aboutYouHint:`在这里查看你的背景、偏好和习惯。有不准确或已经变化的内容,可以直接修改。`,identity:`你的背景与能力`,preferences:`偏好与习惯`,relationships:`重要的人与关系`,currentState:`最近的状态`,insights:`其他观察`,emptyGroup:`还没有记住关于你的信息。你可以在聊天中告诉 xopc 你的背景或偏好,例如「回答时先给结论」。`,correct:`修正`,save:`保存修正`,cancel:`取消`,correctionPlaceholder:`写下更准确的说法…`,searchPlaceholder:`搜索工作记忆…`,allMemory:`全部工作记忆`,memoryFilterHint:`按记忆类型筛选`,memoryLibraryHint:`这里只显示提炼后的事实、决定、经验、承诺和待解问题;邮件、日历与文档原文保留在对应来源中。`,noKnowledge:`还没有形成工作记忆。`,noKnowledgeMatch:`没有符合搜索条件的工作记忆。`,showMore:`显示更多`,expand:`查看详情`,collapse:`收起详情`,disable:`停用`,disabled:`已停用`,enable:`启用`,loadFailed:`无法载入对你的理解。`,tryAgain:`重试`,actionFailed:`修改没有保存,请重试。`}},Lt=new Set([`identity.call_name`,`identity.role`,`identity.pronouns`,`preference.timezone`,`preference.locale`]),Rt=[`work_thread`,`project_fact`,`workspace_fact`,`decision`,`task_lesson`,`commitment`,`open_question`,`episode`,`note`],zt=`UTC.Africa/Cairo.Africa/Johannesburg.America/Chicago.America/Denver.America/Los_Angeles.America/Mexico_City.America/New_York.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Kolkata.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Berlin.Europe/London.Europe/Madrid.Europe/Paris.Europe/Rome.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function Bt(){try{let e=Intl.supportedValuesOf(`timeZone`);return[...new Set([`UTC`,...e])]}catch{return[...zt]}}var Vt=Bt();function Ht(e){return e.map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.includes(`/`)?e.split(`/`)[0]:`UTC`}))}function Ut(e,t,n=!1){return e?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,...n?{timeStyle:`short`}:{}}).format(e):null}function Wt(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Gt(e){return{callName:Wt(e.profile.callName)??``,role:Wt(e.profile.role)??``,pronouns:Wt(e.profile.pronouns)??``,timezone:Wt(e.profile.timezone)??``,locale:Wt(e.profile.locale)??``}}function Kt(e,t){return{"zh-CN":{en:`Simplified Chinese`,zh:`简体中文`},"zh-TW":{en:`Traditional Chinese`,zh:`繁体中文`},"en-US":{en:`English (US)`,zh:`英语(美国)`},"en-GB":{en:`English (UK)`,zh:`英语(英国)`},"ja-JP":{en:`Japanese`,zh:`日语`}}[e]?.[t]??e}function qt(e,t){let n=Ut(e,t);return t===`zh`?`当前安排至 ${n}`:`Current plan through ${n}`}function Jt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Yt(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function Xt(e,t){return(t===`zh`?{global:`所有协作`,agent:`当前智能体`,workspace:`当前工作区`,project:`当前项目`,session:`当前会话`}:{global:`All work`,agent:`This agent`,workspace:`This workspace`,project:`This project`,session:`This conversation`})[e.type]}function Zt(e,t){return(t===`zh`?{work_thread:`工作主线`,project_fact:`项目事实`,workspace_fact:`工作区事实`,decision:`已经决定`,task_lesson:`工作经验`,commitment:`承诺与约定`,open_question:`待解问题`,episode:`重要经历`,note:`其他记录`}:{work_thread:`Work threads`,project_fact:`Project facts`,workspace_fact:`Workspace facts`,decision:`Decisions`,task_lesson:`Lessons`,commitment:`Commitments`,open_question:`Open questions`,episode:`Episodes`,note:`Notes`})[e]}function Qt(e,t,n){if(e)return e.targetType===`goal`?t.find(t=>t.id===e.targetId)?.title:/^[0-9a-f]{8}-[0-9a-f-]{20,}$/i.test(e.targetId)?(n===`zh`?{project:`当前项目`,task:`当前任务`,assertion:`一项待处理的理解`,topic:`当前主题`}:{project:`Current project`,task:`Current task`,assertion:`An understanding to address`,topic:`Current topic`})[e.targetType]:e.targetId}function $t(e){let t=(0,Z.c)(16),{title:n,hint:r,action:i,children:a,className:o}=e,s=o===void 0?``:o,c;t[0]===n?c=t[1]:(c=(0,Q.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=r?(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:r}):null,t[2]=r,t[3]=l);let u;t[4]!==c||t[5]!==l?(u=(0,Q.jsxs)(`div`,{children:[c,l]}),t[4]=c,t[5]=l,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==u?(d=(0,Q.jsxs)(`header`,{className:`flex items-end justify-between gap-4 px-1 pb-3`,children:[u,i]}),t[7]=i,t[8]=u,t[9]=d):d=t[9];let f;t[10]===a?f=t[11]:(f=(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:a}),t[10]=a,t[11]=f);let p;return t[12]!==s||t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`section`,{className:s,children:[d,f]}),t[12]=s,t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function en(e){let t=(0,Z.c)(7),{icon:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`span`,{className:`text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Q.jsx)(`p`,{children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-5 text-sm text-fg-muted`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function tn({open:e,profile:t,language:n,saving:r,onOpenChange:i,onSave:a}){let o=It[n],[s,c]=(0,X.useState)(t),[l,d]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&(c(t),d(``))},[e,t]);let v=e=>{e.preventDefault(),a({callName:s.callName.trim(),role:s.role.trim(),pronouns:s.pronouns.trim(),timezone:s.timezone.trim(),locale:s.locale.trim()})},y=(e,t,n)=>(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Q.jsx)(`input`,{value:s[e],onChange:t=>c(n=>({...n,[e]:t.target.value})),placeholder:n,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),b=[`zh-CN`,`zh-TW`,`en-US`,`en-GB`,`ja-JP`];s.locale&&!b.includes(s.locale)&&b.push(s.locale);let x=I(),S=(0,X.useMemo)(()=>[...new Set([...Vt,x,s.timezone].filter(Boolean))].sort(),[x,s.timezone]),C=l.trim().toLocaleLowerCase(),w=(0,X.useMemo)(()=>Ht(S.filter(e=>!C||e.toLocaleLowerCase().includes(C)||e.replaceAll(`_`,` `).toLocaleLowerCase().includes(C))),[S,C]);return(0,Q.jsx)(_,{open:e,onOpenChange:i,children:(0,Q.jsxs)(m,{children:[(0,Q.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsx)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(40rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:v,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:o.editProfile}),(0,Q.jsx)(f,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.editProfileHint})]}),(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o.cancel,children:(0,Q.jsx)(ke,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5 sm:p-6`,children:(0,Q.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[y(`callName`,o.callName,o.callNamePlaceholder),y(`role`,o.role,o.rolePlaceholder),y(`pronouns`,o.pronouns,o.pronounsPlaceholder),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.locale}),(0,Q.jsxs)(H,{value:s.locale,onChange:e=>c(t=>({...t,locale:e.target.value})),children:[(0,Q.jsx)(U,{value:``,children:o.notProvided}),b.map(e=>(0,Q.jsx)(U,{value:e,children:Kt(e,n)},e))]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:col-span-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:o.timezone}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{value:s.timezone,options:w,placeholder:I(),emptyLabel:o.notProvided,ariaLabel:o.timezone,selectedLabel:s.timezone||o.notProvided,searchPlaceholder:o.timezoneSearch,searchValue:l,onSearchChange:d,statusMessage:w.length?void 0:o.timezoneNoMatch,triggerClassName:`min-w-0 flex-1 rounded-xl bg-surface-base`,onChange:e=>{c(t=>({...t,timezone:e})),d(``)}}),(0,Q.jsx)(Y,{className:`shrink-0 whitespace-nowrap`,onClick:()=>c(e=>({...e,timezone:x})),children:o.useDeviceTimezone})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{disabled:r,children:o.cancel})}),(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,disabled:r,children:[r?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,r?o.saving:o.saveProfile]})]})]})})]})})}function nn(e){let t=(0,Z.c)(94),{open:n,priority:r,title:i,outcome:a,language:o,saving:s,onOpenChange:c,onSave:l,onEnd:d}=e,v=It[o],[y,b]=(0,X.useState)(i),[x,S]=(0,X.useState)(a??``),C=r?.validTo??Date.now()+6048e5,w;t[0]===C?w=t[1]:(w=Jt(C),t[0]=C,t[1]=w);let T=w,[E,D]=(0,X.useState)(T),O,k;t[2]!==T||t[3]!==n||t[4]!==a||t[5]!==i?(O=()=>{n&&(b(i),S(a??``),D(T))},k=[T,n,a,i],t[2]=T,t[3]=n,t[4]=a,t[5]=i,t[6]=O,t[7]=k):(O=t[6],k=t[7]),(0,X.useEffect)(O,k);let A;t[8]!==x||t[9]!==y||t[10]!==E||t[11]!==l||t[12]!==r?.targetType?(A=e=>{e.preventDefault(),l({title:y.trim(),...r?.targetType===`goal`?{desiredOutcome:x.trim()}:{},validTo:Yt(E)})},t[8]=x,t[9]=y,t[10]=E,t[11]=l,t[12]=r?.targetType,t[13]=A):A=t[13];let j=A,M;t[14]!==x||t[15]!==y||t[16]!==E||t[17]!==r?.targetType?(M=y.trim()&&E&&(r?.targetType!==`goal`||x.trim()),t[14]=x,t[15]=y,t[16]=E,t[17]=r?.targetType,t[18]=M):M=t[18];let ee=!!M,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[19]=N):N=t[19];let te=r?v.editPriority:v.addPriority,P;t[20]===te?P=t[21]:(P=(0,Q.jsx)(g,{className:`font-semibold text-fg`,children:te}),t[20]=te,t[21]=P);let F;t[22]===v.priorityHint?F=t[23]:(F=(0,Q.jsx)(f,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.priorityHint}),t[22]=v.priorityHint,t[23]=F);let I;t[24]!==F||t[25]!==P?(I=(0,Q.jsxs)(`div`,{children:[P,F]}),t[24]=F,t[25]=P,t[26]=I):I=t[26];let L;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(ke,{className:`size-4`}),t[27]=L):L=t[27];let R;t[28]===v.cancel?R=t[29]:(R=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":v.cancel,children:L})}),t[28]=v.cancel,t[29]=R);let z;t[30]!==I||t[31]!==R?(z=(0,Q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4 sm:px-6`,children:[I,R]}),t[30]=I,t[31]=R,t[32]=z):z=t[32];let B;t[33]===v.priorityTitle?B=t[34]:(B=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityTitle}),t[33]=v.priorityTitle,t[34]=B);let ne;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>b(e.target.value),t[35]=ne):ne=t[35];let re;t[36]!==y||t[37]!==v.priorityTitlePlaceholder?(re=(0,Q.jsx)(`input`,{autoFocus:!0,value:y,onChange:ne,placeholder:v.priorityTitlePlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base px-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[36]=y,t[37]=v.priorityTitlePlaceholder,t[38]=re):re=t[38];let ie;t[39]!==B||t[40]!==re?(ie=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[B,re]}),t[39]=B,t[40]=re,t[41]=ie):ie=t[41];let ae;t[42]!==x||t[43]!==r?.targetType||t[44]!==v.priorityOutcome||t[45]!==v.priorityOutcomePlaceholder?(ae=r?.targetType===`goal`?(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityOutcome}),(0,Q.jsx)(`textarea`,{value:x,onChange:e=>S(e.target.value),placeholder:v.priorityOutcomePlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}):null,t[42]=x,t[43]=r?.targetType,t[44]=v.priorityOutcome,t[45]=v.priorityOutcomePlaceholder,t[46]=ae):ae=t[46];let oe;t[47]===v.priorityUntil?oe=t[48]:(oe=(0,Q.jsx)(`span`,{className:`font-medium text-fg`,children:v.priorityUntil}),t[47]=v.priorityUntil,t[48]=oe);let V;t[49]===r?.validFrom?V=t[50]:(V=r?.validFrom??Date.now(),t[49]=r?.validFrom,t[50]=V);let H;t[51]===V?H=t[52]:(H=Jt(V),t[51]=V,t[52]=H);let U;t[53]!==E||t[54]!==v.priorityUntil||t[55]!==H?(U=(0,Q.jsx)(Ue,{min:H,value:E,onChange:D,ariaLabel:v.priorityUntil,className:`rounded-xl border border-edge bg-surface-base hover:border-edge-strong hover:bg-surface-base`}),t[53]=E,t[54]=v.priorityUntil,t[55]=H,t[56]=U):U=t[56];let W;t[57]!==oe||t[58]!==U?(W=(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[oe,U]}),t[57]=oe,t[58]=U,t[59]=W):W=t[59];let se;t[60]!==ie||t[61]!==ae||t[62]!==W?(se=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5 sm:p-6`,children:[ie,ae,W]}),t[60]=ie,t[61]=ae,t[62]=W,t[63]=se):se=t[63];let G;t[64]!==d||t[65]!==r||t[66]!==s||t[67]!==v.endPriority||t[68]!==v.endingPriority?(G=r&&d?(0,Q.jsxs)(Y,{variant:`ghost`,className:`text-danger hover:text-danger`,disabled:s,onClick:d,children:[s?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,s?v.endingPriority:v.endPriority]}):(0,Q.jsx)(`span`,{}),t[64]=d,t[65]=r,t[66]=s,t[67]=v.endPriority,t[68]=v.endingPriority,t[69]=G):G=t[69];let ce;t[70]!==s||t[71]!==v.cancel?(ce=(0,Q.jsx)(p,{asChild:!0,children:(0,Q.jsx)(Y,{disabled:s,children:v.cancel})}),t[70]=s,t[71]=v.cancel,t[72]=ce):ce=t[72];let le=!ee||s,ue;t[73]===s?ue=t[74]:(ue=s?(0,Q.jsx)(he,{className:`size-4 animate-spin`}):null,t[73]=s,t[74]=ue);let de;t[75]!==v.savePriority||t[76]!==le||t[77]!==ue?(de=(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,disabled:le,children:[ue,v.savePriority]}),t[75]=v.savePriority,t[76]=le,t[77]=ue,t[78]=de):de=t[78];let K;t[79]!==ce||t[80]!==de?(K=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[ce,de]}),t[79]=ce,t[80]=de,t[81]=K):K=t[81];let q;t[82]!==G||t[83]!==K?(q=(0,Q.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-5 py-3 sm:px-6`,children:[G,K]}),t[82]=G,t[83]=K,t[84]=q):q=t[84];let J;t[85]!==j||t[86]!==z||t[87]!==se||t[88]!==q?(J=(0,Q.jsxs)(m,{children:[N,(0,Q.jsx)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:(0,Q.jsxs)(`form`,{className:`flex h-full min-h-0 flex-col overflow-hidden [border-radius:inherit]`,onSubmit:j,children:[z,se,q]})})]}),t[85]=j,t[86]=z,t[87]=se,t[88]=q,t[89]=J):J=t[89];let fe;return t[90]!==c||t[91]!==n||t[92]!==J?(fe=(0,Q.jsx)(_,{open:n,onOpenChange:c,children:J}),t[90]=c,t[91]=n,t[92]=J,t[93]=fe):fe=t[93],fe}function rn(e){let t=(0,Z.c)(16),{rule:n,language:r,busy:i,onToggle:a}=e,o=It[r],s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l;t[3]!==n.status||t[4]!==o.disabled?(l=n.status===`disabled`?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.disabled}):null,t[3]=n.status,t[4]=o.disabled,t[5]=l):l=t[5];let u=n.status===`active`?o.disable:o.enable,d;t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,Q.jsx)(Y,{variant:`ghost`,className:`h-8`,disabled:i,onClick:a,children:u}),t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9];let f;t[10]!==l||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,c,f]}),t[13]=c,t[14]=f,t[15]=p):p=t[15],p}function an(e){let t=(0,Z.c)(15),{suggestion:n,language:r,busy:i,onConfirm:a}=e,o=r===`zh`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(we,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),t[0]=s):s=t[0];let c;t[1]===n.statement?c=t[2]:(c=(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),t[1]=n.statement,t[2]=c);let l=o?`根据你已确认的模式生成;确认前不会生效`:`Suggested from a pattern you confirmed; inactive until you approve`,u;t[3]===l?u=t[4]:(u=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:l}),t[3]=l,t[4]=u);let d;t[5]!==c||t[6]!==u?(d=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c,u]}),t[5]=c,t[6]=u,t[7]=d):d=t[7];let f=i?o?`启用中…`:`Enabling…`:o?`确认启用`:`Approve`,p;t[8]!==i||t[9]!==a||t[10]!==f?(p=(0,Q.jsx)(Y,{variant:`secondary`,className:`h-8 shrink-0`,disabled:i,onClick:a,children:f}),t[8]=i,t[9]=a,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-t border-edge-subtle px-5 py-3 first:border-t-0`,children:[s,d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14],m}function on(e){let t=(0,Z.c)(27),{item:n,language:r,busy:i,expanded:a,onToggle:o,editing:s,draft:c,onDraftChange:l,onEdit:u,onCancel:d,onReview:f,onDelete:p,onScopeChange:m}=e,h=It[r],g=n.updatedAt??n.createdAt,_;t[0]!==r||t[1]!==g?(_=Ut(g,r),t[0]=r,t[1]=g,t[2]=_):_=t[2];let y=_,b;t[3]!==n.claimMode||t[4]!==n.content?(b=n.content.length>96||n.content.includes(`
2
2
  `)||!!n.claimMode,t[3]=n.claimMode,t[4]=n.content,t[5]=b):b=t[5];let x=b,S;return t[6]!==i||t[7]!==x||t[8]!==y||t[9]!==c||t[10]!==s||t[11]!==a||t[12]!==n.claimMode||t[13]!==n.content||t[14]!==n.id||t[15]!==n.scope||t[16]!==n.verification||t[17]!==r||t[18]!==d||t[19]!==p||t[20]!==l||t[21]!==u||t[22]!==f||t[23]!==m||t[24]!==o||t[25]!==h?(S=(0,Q.jsx)(`article`,{className:`group border-t border-edge-subtle px-5 py-4 first:border-t-0 sm:px-6`,children:s?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`textarea`,{"aria-label":h.correctionPlaceholder,disabled:i,value:c,onChange:e=>l(e.target.value),className:`min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(Y,{variant:`ghost`,className:`h-8`,onClick:d,children:h.cancel}),(0,Q.jsx)(Y,{variant:`primary`,className:`h-8`,disabled:!c.trim()||i,onClick:()=>f(`edit_and_approve`,c.trim()),children:h.save})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(v,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-base leading-7 text-fg ${a?``:`line-clamp-2`}`,children:n.content}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`span`,{children:Xt(n.scope,r)}),n.claimMode===`reported`?(0,Q.jsx)(`span`,{children:r===`zh`?`来源报告`:`Source report`}):null,n.verification===`tentative`?(0,Q.jsx)(`span`,{children:r===`zh`?`证据待补充`:`Evidence pending`}):null,y?(0,Q.jsx)(`span`,{children:y}):null]}),a?(0,Q.jsx)(Pt,{id:n.id,language:r}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[x?(0,Q.jsx)(Y,{variant:`ghost`,className:`size-11 p-0`,"aria-expanded":a,"aria-label":a?h.collapse:h.expand,onClick:o,children:(0,Q.jsx)(oe,{className:`size-3.5 transition-transform ${a?`rotate-180`:``}`})}):null,(0,Q.jsx)(Xe,{language:r,busy:i,statement:n.content,scope:n.scope,onScopeChange:m,onEdit:u,onDelete:p})]})]})}),t[6]=i,t[7]=x,t[8]=y,t[9]=c,t[10]=s,t[11]=a,t[12]=n.claimMode,t[13]=n.content,t[14]=n.id,t[15]=n.scope,t[16]=n.verification,t[17]=r,t[18]=d,t[19]=p,t[20]=l,t[21]=u,t[22]=f,t[23]=m,t[24]=o,t[25]=h,t[26]=S):S=t[26],S}function sn(){let e=c(e=>e.language),t=It[e],n=Fe(e=>e.setPageHeader),r=Fe(e=>e.clearPageHeader),[i,s]=a(),{data:l,error:u,isLoading:d,isValidating:f,mutate:p}=Me(`/api/user-model`,M),m=Ft(i),[h,g]=(0,X.useState)(),[_,v]=(0,X.useState)(),[y,b]=(0,X.useState)(``),[I,L]=(0,X.useState)(),[oe,W]=(0,X.useState)(``),[G,de]=(0,X.useState)(``),[K,q]=(0,X.useState)(24),[J,fe]=(0,X.useState)(),[pe,me]=(0,X.useState)(!1),[_e,Ce]=(0,X.useState)(!1),Te=i.get(`source`),Ee=Te===`explicit`||Te===`learned`?Te:`all`,Ae=i.get(`search`)??``,Ne=i.get(`category`)??`all`,[Re,ze]=(0,X.useState)(`all`),[Be,Ve]=(0,X.useState)(`idle`),He=(0,X.useRef)(void 0),Ue=e=>{if(e===m)return;let t=document.getElementById(`app-main-content`);typeof t?.scrollTo==`function`&&t.scrollTo({top:0,behavior:`auto`}),s(t=>{let n=new URLSearchParams(t);return n.delete(`section`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n})},Z=(e,t,n=!1)=>{s(n=>{let r=new URLSearchParams(n);return!t||t===`all`?r.delete(e):r.set(e,t),r},{replace:n})},We=(0,X.useCallback)(async()=>{if(!(Be===`refreshing`||f)){He.current&&window.clearTimeout(He.current),Ve(`refreshing`),v(void 0),b(t.refreshing);try{await p(),Ve(`success`),b(t.refreshComplete)}catch{Ve(`error`),b(``),v(t.refreshFailed)}finally{He.current=window.setTimeout(()=>Ve(`idle`),1600)}}},[f,p,Be,t]);(0,X.useEffect)(()=>()=>{He.current&&window.clearTimeout(He.current)},[]);let Ge=f||Be===`refreshing`,Ke=Ge?t.refreshing:Be===`success`?t.refreshComplete:Be===`error`?t.refreshFailed:t.refresh;(0,X.useEffect)(()=>(n({startExtra:null,main:(0,Q.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:t.pageTitle}),end:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(xt,{}),(0,Q.jsx)(Y,{variant:`secondary`,className:`size-9 p-0 ${Be===`success`?`text-success`:Be===`error`?`text-danger`:``}`,disabled:Ge,"aria-label":Ke,title:Ke,onClick:()=>void We(),children:Ge?(0,Q.jsx)(he,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}):Be===`success`?(0,Q.jsx)(ae,{className:`size-4`,"aria-hidden":`true`}):Be===`error`?(0,Q.jsx)(se,{className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":`true`})})]})}),r),[r,Ge,Be,Ke,We,n,t]);let qe=async(n,r)=>{g(n),v(void 0),b(``);try{await r(),await p(),b(e===`zh`?`已更新`:`Updated`)}catch{v(t.actionFailed)}finally{g(void 0)}},Je=e=>{qe(e.id,async()=>{await N(e.id,oe.trim()),L(void 0),W(``)})},Ye=async e=>{g(`profile`),v(void 0),b(``);try{await R(e),await p(),me(!1)}catch{v(t.actionFailed)}finally{g(void 0)}},Xe=async(n,r)=>{g(`priority:${n.id}`),v(void 0),b(``);try{await C(n.id,r),await p(),Ce(!1),b(e===`zh`?`当前关注已更新`:`Current focus updated`)}catch{v(t.actionFailed)}finally{g(void 0)}},Ze=async n=>{g(`priority:create`),v(void 0),b(``);try{await F(n),await p(),Ce(!1),b(e===`zh`?`当前关注已设置`:`Current focus set`)}catch{v(t.actionFailed)}finally{g(void 0)}},Qe=async n=>{g(`priority:${n.id}`),v(void 0),b(``);try{await C(n.id,{status:`completed`}),await p(),Ce(!1),b(e===`zh`?`当前关注已结束`:`Current focus ended`)}catch{v(t.actionFailed)}finally{g(void 0)}};if(d)return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-7xl space-y-5 px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`,children:[(0,Q.jsx)(je,{className:`h-10 w-72 rounded-xl`}),(0,Q.jsx)(je,{className:`h-72 rounded-xl`}),(0,Q.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-2`,children:[(0,Q.jsx)(je,{className:`h-80 rounded-xl`}),(0,Q.jsx)(je,{className:`h-80 rounded-xl`})]})]});if(u||!l)return(0,Q.jsxs)(`div`,{className:`mx-auto flex min-h-72 max-w-xl flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(z,{className:`size-6 text-fg-subtle`}),(0,Q.jsx)(`p`,{className:`text-sm text-danger`,children:t.loadFailed}),(0,Q.jsx)(Y,{onClick:()=>void p(),children:t.tryAgain})]});let $e=l.assertions.filter(e=>e.usable&&!Lt.has(e.predicate)).sort((e,t)=>{let n=e.declaredImportance??e.inferredImportance;return(t.declaredImportance??t.inferredImportance)-n||t.recordedAt-e.recordedAt}),et=l.assertions.filter(e=>[`candidate`,`needs_review`,`conflicted`].includes(e.status)).sort((e,t)=>t.recordedAt-e.recordedAt),tt=Gt(l),nt=tt.callName||(e===`zh`?`你`:`You`),rt=[{key:`identity`,title:t.identity,icon:Oe,kinds:[`identity`,`capability`]},{key:`preferences`,title:t.preferences,icon:x,kinds:[`preference`,`value`,`routine`]},{key:`relationships`,title:t.relationships,icon:S,kinds:[`relationship`]},{key:`current`,title:t.currentState,icon:ce,kinds:[`current_state`]},{key:`insights`,title:t.insights,icon:we,kinds:[`derived_insight`]}],at=rt.find(e=>e.key===Ne),ot=$e.filter(e=>(!at||at.kinds.includes(e.kind))&&(!Ae.trim()||e.statement.toLocaleLowerCase().includes(Ae.trim().toLocaleLowerCase()))),st=ot.filter(e=>e.authority===`user_explicit`).length,ct=ot.length-st,lt=ot.filter(e=>Ee===`explicit`?e.authority===`user_explicit`:Ee!==`learned`||e.authority!==`user_explicit`),ut=l.priorities.filter(e=>e.status===`active`&&e.validTo>Date.now()),$=ut.find(e=>e.rank===`primary`)??ut[0],dt=Qt($,l.goals,e),ft=$?.targetType===`goal`?l.goals.find(e=>e.id===$.targetId):void 0,pt=l.goals.filter(e=>e.status===`active`||e.status===`paused`).filter(e=>$?.targetType!==`goal`||e.id!==$.targetId),mt=l.rules.filter(e=>e.status!==`archived`),ht=l.ruleSuggestions??[],gt=l.knowledge.filter(e=>e.status!==`archived`&&e.status!==`rejected`),_t=G.trim().toLocaleLowerCase(),vt=gt.filter(e=>Re===`all`||e.kind===Re),yt=vt.filter(t=>!_t||t.content.toLocaleLowerCase().includes(_t)||Zt(t.kind,e).toLocaleLowerCase().includes(_t)),bt=rt.map(e=>({...e,items:lt.filter(t=>e.kinds.includes(t.kind))})).filter(e=>e.items.length>0),Ct=rt.map(e=>({...e,items:$e.filter(t=>e.kinds.includes(t.kind))})).filter(e=>e.items.length>0),wt=Rt.map(e=>({kind:e,count:gt.filter(t=>t.kind===e).length})).filter(e=>e.count>0),Tt=wt.slice(0,4),Et=Tt.length===1?`grid-cols-1`:`sm:grid-cols-2`,Dt=yt.slice(0,K),Ot=Rt.map(e=>({kind:e,items:Dt.filter(t=>t.kind===e),totalCount:yt.filter(t=>t.kind===e).length})).filter(e=>e.items.length>0),kt=[{id:`all`,label:t.allUnderstanding,count:ot.length},{id:`explicit`,label:t.explicit,count:st},{id:`learned`,label:t.learned,count:ct}],At=(e=`all`)=>{s(t=>{let n=new URLSearchParams(t);return n.set(`tab`,`understanding`),n.delete(`section`),n.delete(`source`),n.delete(`search`),e===`all`?n.delete(`category`):n.set(`category`,e),n})},jt=e=>{ze(e),de(``),q(24),Ue(`work`)},Mt=t=>(0,Q.jsx)(it,{item:t,language:e,busy:!!h,editing:I===t.id,draft:I===t.id?oe:``,onDraftChange:W,onEdit:()=>{L(t.id),W(t.statement)},onCancel:()=>{L(void 0),W(``)},onDelete:()=>void qe(t.id,()=>w(t.id)),onCorrect:()=>Je(t),onScopeChange:e=>void qe(t.id,()=>O(t.id,e,t.version))},t.id);return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-6 px-4 pb-4 pt-3 sm:space-y-8 sm:px-6 sm:pb-7 lg:px-8 lg:pb-10 lg:pt-4`,children:[(0,Q.jsx)(`div`,{className:`hidden px-1 sm:block`,children:(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:e===`zh`?`让 xopc 按你的习惯与你协作。记错了,随时改。`:`Help xopc work your way. You can correct what it remembers at any time.`})}),(0,Q.jsx)(Pe,{items:[{id:`overview`,label:t.overview,icon:we},{id:`understanding`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`记住的你`:`Memories`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.understanding})]}),icon:Oe,count:$e.length},{id:`work`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`工作记忆`:`Work`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.knowledge})]}),title:t.knowledge,icon:re,count:gt.length},{id:`privacy`,label:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`隐私`:`Privacy`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.privacy})]}),icon:Se}],activeTab:m,onChange:Ue,ariaLabel:t.pageTitle,tabIdPrefix:`understanding-tab`,panelIdPrefix:`understanding-panel`,className:`w-full max-w-full gap-1 rounded-full bg-surface-panel p-1 shadow-surface sm:w-fit`,buttonClassName:`min-h-11 min-w-0 flex-1 justify-center whitespace-nowrap rounded-full px-2 py-2 sm:min-h-9 sm:flex-none sm:px-3.5 [&_svg]:hidden sm:[&_svg]:block`,countClassName:`hidden sm:inline-flex`,selectedClassName:`bg-surface-active text-fg`,unselectedClassName:`text-fg-muted hover:bg-surface-hover hover:text-fg`}),(0,Q.jsx)(`p`,{role:`status`,className:`sr-only`,children:y}),_?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-3 rounded-xl border border-danger bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,Q.jsx)(`span`,{children:_}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(void 0),"aria-label":t.cancel,children:(0,Q.jsx)(ke,{className:`size-4`})})]}):null,m===`overview`?(0,Q.jsxs)(`div`,{id:`understanding-panel-overview`,role:`tabpanel`,"aria-labelledby":`understanding-tab-overview`,className:`grid grid-cols-1 items-start gap-6 sm:gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,24rem)]`,children:[(0,Q.jsx)(`section`,{"data-testid":`overview-hero`,className:`min-w-0 lg:col-start-1 lg:row-start-1`,children:(0,Q.jsxs)(`div`,{className:`min-w-0 px-1 sm:py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:flex-wrap sm:gap-5`,children:[(0,Q.jsx)(Ie,{className:`size-16 sm:size-20`,mood:_?`care`:Ge||h?`work`:`listen`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight text-fg sm:text-3xl`,children:nt}),(0,Q.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg-muted`,children:tt.role||(e===`zh`?`从你的背景和偏好开始了解你`:`Your background and preferences, in one place`)})]}),(0,Q.jsxs)(Y,{variant:`ghost`,className:`size-11 shrink-0 px-0 sm:h-9 sm:w-auto sm:px-3`,onClick:()=>me(!0),children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:t.editProfile})]})]}),(0,Q.jsx)(`dl`,{className:`mt-6 hidden gap-x-8 gap-y-5 sm:grid sm:grid-cols-3`,children:[{icon:B,label:t.locale,value:tt.locale?Kt(tt.locale,e):``},{icon:T,label:t.timezone,value:tt.timezone},{icon:Oe,label:t.pronouns,value:tt.pronouns}].filter(({value:e})=>e).map(({icon:e,label:t,value:n})=>(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`dt`,{className:`flex items-center gap-1.5 text-xs text-fg-subtle`,children:[(0,Q.jsx)(e,{className:`size-3.5`,"aria-hidden":`true`}),t]}),(0,Q.jsx)(`dd`,{className:`mt-1.5 truncate text-sm font-medium text-fg`,children:n})]},t))})]})}),et.length?(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-accent-soft/70 shadow-surface lg:col-span-2`,"aria-label":e===`zh`?`需要你确认`:`Needs your review`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-panel text-accent-fg`,children:(0,Q.jsx)(we,{className:`size-4`,"aria-hidden":`true`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e===`zh`?`这条理解准确吗?`:`Needs your review`}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e===`zh`?`xopc 还不确定,想请你确认。`:`xopc is unsure and would like your confirmation.`})]})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 text-xs font-medium tabular-nums text-accent-fg`,children:et.length})]}),(0,Q.jsxs)(`div`,{className:`border-t border-accent/10 bg-surface-panel px-5 py-4 sm:flex sm:items-center sm:gap-4 sm:px-6`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-sm leading-6 text-fg`,children:et[0].statement}),(0,Q.jsxs)(`div`,{className:`mt-3 flex shrink-0 gap-2 sm:mt-0`,children:[(0,Q.jsx)(Y,{variant:`ghost`,className:`min-h-11 flex-1 sm:flex-none`,disabled:h===et[0].id,onClick:()=>void qe(et[0].id,()=>P(et[0].id,`rejected`)),children:e===`zh`?`不是`:`No`}),(0,Q.jsx)(Y,{variant:`primary`,className:`min-h-11 flex-1 sm:flex-none`,disabled:h===et[0].id,onClick:()=>void qe(et[0].id,()=>P(et[0].id,`active`)),children:e===`zh`?`是的`:`That’s right`})]})]})]}):null,(0,Q.jsxs)(`section`,{"aria-label":t.aboutYouTitle,className:`space-y-3 sm:space-y-4 lg:col-span-2`,children:[(0,Q.jsxs)(`header`,{className:`flex items-start justify-between gap-3 px-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e===`zh`?t.aboutYouTitle:`What xopc knows about me`}),(0,Q.jsxs)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`记错了,随时改。`:`You can correct anything.`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:e===`zh`?`这些内容会帮助 xopc 更好地回应你。推测会单独标注。`:`These details help shape xopc’s responses. Inferences are labeled.`})]})]}),(0,Q.jsx)(Y,{variant:`ghost`,className:`min-h-11 shrink-0`,onClick:()=>At(),children:t.seeAll})]}),Ct.length?(0,Q.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:Ct.map(({key:t,title:n,icon:r,items:i})=>(0,Q.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl bg-surface-panel`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between gap-3 px-5 pb-2 pt-4`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,Q.jsx)(r,{className:`size-4`,"aria-hidden":`true`}),n]}),(0,Q.jsxs)(Y,{variant:`ghost`,className:`min-h-11 shrink-0 px-2 text-fg-muted`,"aria-label":`${n}: ${i.length}`,onClick:()=>At(t),children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`${i.length} 条`:i.length}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:e===`zh`?`查看全部 ${i.length} 条`:`View all ${i.length}`}),(0,Q.jsx)(V,{className:`size-4`,"aria-hidden":`true`})]})]}),i.slice(0,2).map(Mt)]},t))}):(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel px-5 py-6`,children:[(0,Q.jsx)(`p`,{className:`max-w-xl text-sm leading-7 text-fg-muted`,children:t.emptyGroup}),(0,Q.jsx)(Y,{variant:`secondary`,className:`mt-4`,onClick:()=>me(!0),children:t.editProfile})]})]}),(0,Q.jsxs)(`aside`,{"data-testid":`priority-panel`,className:`flex min-h-0 flex-col rounded-[1.4rem] bg-surface-panel p-5 shadow-surface sm:p-6 lg:col-start-2 lg:row-start-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.importantNow}),$?(0,Q.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Q.jsx)(re,{className:`size-3.5`,"aria-hidden":`true`}),$.targetType===`goal`?t.prioritySourceGoal:t.prioritySourceWork]}):null]}),$&&dt?(0,Q.jsxs)(Y,{variant:`ghost`,className:`h-8 shrink-0 px-2.5`,onClick:()=>Ce(!0),children:[(0,Q.jsx)(ve,{className:`size-3.5`,"aria-hidden":`true`}),t.editPriority]}):null]}),dt?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`mt-3 text-lg font-semibold leading-7 tracking-tight text-fg`,children:dt}),ft?.desiredOutcome?(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:ft.desiredOutcome}):null,$?(0,Q.jsxs)(`p`,{className:`mt-auto flex items-center gap-1.5 pt-4 text-xs text-fg-subtle`,children:[(0,Q.jsx)(ie,{className:`size-3.5`,"aria-hidden":`true`}),qt($.validTo,e)]}):null]}):(0,Q.jsxs)(`div`,{className:`mt-2 space-y-4 text-sm leading-6 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:e===`zh`?`告诉 xopc 当前最重要的事,让协作更贴近你的目标。`:`Tell xopc what matters most so it can keep your goals in mind.`}),(0,Q.jsxs)(Y,{variant:`primary`,onClick:()=>Ce(!0),children:[(0,Q.jsx)(ye,{className:`size-4`,"aria-hidden":`true`}),t.addPriority]})]}),pt.length?(0,Q.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.otherGoals}),(0,Q.jsx)(`div`,{className:`mt-2 space-y-2`,children:pt.slice(0,3).map(e=>(0,Q.jsx)(`p`,{className:`text-sm text-fg`,children:e.title},e.id))})]}):null]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-6 sm:gap-8 lg:col-span-2 lg:grid-cols-2`,children:[(0,Q.jsx)($t,{title:t.howWeWork,className:`min-w-0`,children:mt.length||ht.length?(0,Q.jsxs)(Q.Fragment,{children:[mt.slice(0,3).map(t=>(0,Q.jsx)(rn,{rule:t,language:e,busy:h===t.id,onToggle:()=>void qe(t.id,()=>A(t.id,t.status===`active`?`disabled`:`active`))},t.id)),ht.slice(0,2).map(t=>(0,Q.jsx)(an,{suggestion:t,language:e,busy:h===t.id,onConfirm:()=>void qe(t.id,()=>j(t))},t.id))]}):(0,Q.jsx)(en,{icon:(0,Q.jsx)(S,{className:`size-5`}),children:t.noRules})}),(0,Q.jsx)($t,{title:t.workMemory,className:`min-w-0`,action:(0,Q.jsx)(Y,{variant:`ghost`,className:`h-8 shrink-0`,onClick:()=>jt(`all`),children:t.seeAll}),children:wt.length?(0,Q.jsx)(`div`,{"data-testid":`memory-summary-grid`,className:`grid gap-3 bg-surface-base ${Et}`,children:Tt.map(({kind:n,count:r})=>(0,Q.jsxs)(`button`,{type:`button`,className:`group flex min-h-28 cursor-pointer items-start justify-between rounded-2xl bg-surface-panel px-5 py-5 text-left transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>jt(n),"aria-label":`${Zt(n,e)}: ${r}`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`block text-xs font-medium text-fg-muted`,children:[Zt(n,e),` · `,r,` `,t.items]}),(0,Q.jsx)(`span`,{className:`mt-2 block line-clamp-3 break-words text-sm leading-6 text-fg`,children:gt.find(e=>e.kind===n)?.content})]}),(0,Q.jsx)(V,{className:`mt-1 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted motion-reduce:transform-none`,"aria-hidden":`true`})]},n))}):(0,Q.jsx)(en,{icon:(0,Q.jsx)(le,{className:`size-5`}),children:t.noKnowledge})})]})]}):null,m===`understanding`?(0,Q.jsxs)(`div`,{id:`understanding-panel-understanding`,role:`tabpanel`,"aria-labelledby":`understanding-tab-understanding`,className:`mx-auto max-w-3xl space-y-7`,children:[(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(z,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:t.aboutYouTitle}),(0,Q.jsxs)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?`你的偏好与背景,都可以在这里修改。`:`Review and edit your preferences here.`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.aboutYouHint})]})]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 grid grid-cols-[minmax(0,1fr)_7rem] gap-2 sm:flex sm:gap-3`,children:[(0,Q.jsxs)(`label`,{className:`relative block min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:e===`zh`?`搜索关于你的信息`:`Search what xopc knows`}),(0,Q.jsx)(xe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`search`,value:Ae,onChange:e=>Z(`search`,e.target.value,!0),placeholder:e===`zh`?`搜索记忆`:`Search memories`,className:`min-h-11 w-full rounded-xl border border-edge bg-surface-panel pl-10 pr-3 text-base text-fg placeholder:text-fg-muted sm:text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,Q.jsxs)(H,{"aria-label":e===`zh`?`内容分类`:`Category`,value:rt.some(e=>e.key===Ne)?Ne:`all`,onChange:e=>Z(`category`,e.target.value),triggerClassName:`min-h-11 w-full text-base sm:w-48 sm:text-sm`,children:[(0,Q.jsx)(U,{value:`all`,children:e===`zh`?`全部`:`All`}),rt.map(t=>(0,Q.jsx)(U,{value:t.key,children:e===`zh`?{identity:`背景`,preferences:`偏好`,relationships:`关系`,current:`近况`,insights:`观察`}[t.key]:{identity:`Profile`,preferences:`Habits`,relationships:`People`,current:`Now`,insights:`Notes`}[t.key]},t.key))]})]}),(0,Q.jsx)(Le,{className:`mt-3 flex flex-wrap gap-2`,role:`group`,"aria-label":t.understandingFilterHint,indicatorClassName:`rounded-full bg-surface-active`,children:kt.map(t=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Ee===t.id,className:`touch-target inline-flex min-h-11 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Ee===t.id?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>Z(`source`,t.id),children:[(0,Q.jsx)(`span`,{className:`sm:hidden`,children:e===`zh`?{all:`全部`,explicit:`你说过的`,learned:`协作中发现`}[t.id]:{all:`All`,explicit:`You said`,learned:`Observed`}[t.id]}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:t.label}),(0,Q.jsx)(`span`,{className:`hidden tabular-nums text-fg-muted sm:inline`,children:t.count})]},t.id))})]}),bt.length?bt.map(({key:e,title:t,icon:n,items:r})=>(0,Q.jsx)($t,{title:t,action:(0,Q.jsx)(n,{className:`size-4 text-fg-subtle`,"aria-hidden":`true`}),children:(0,Q.jsx)(`div`,{children:r.map(Mt)})},e)):(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel`,children:[(0,Q.jsx)(en,{icon:(0,Q.jsx)(z,{className:`size-5`}),children:$e.length?e===`zh`?`没有找到符合条件的内容,试试其他关键词或清除筛选。`:`No matching details. Try another search or clear the filters.`:t.emptyGroup}),$e.length?(0,Q.jsx)(Y,{variant:`ghost`,className:`mb-4 ml-4`,onClick:()=>At(),children:e===`zh`?`清除筛选`:`Clear filters`}):null]})]}):null,m===`work`?(0,Q.jsxs)(`div`,{id:`understanding-panel-work`,role:`tabpanel`,"aria-labelledby":`understanding-tab-work`,className:`space-y-8`,children:[(0,Q.jsx)(St,{language:e}),(0,Q.jsxs)(`div`,{className:`px-1 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:Re===`all`?t.allMemory:Zt(Re,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:[vt.length,` `,t.items,` · `,e===`zh`?`当前筛选的工作资料记录数,包含未启用或待核验项;不同于顶部已启用且有依据的记忆数。`:`Work records matching this filter, including inactive or unverified items; separate from active, supported memories above.`,` · `,t.memoryLibraryHint]})]}),(0,Q.jsxs)(`label`,{className:`relative block sm:w-80`,children:[(0,Q.jsx)(xe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:t.searchPlaceholder}),(0,Q.jsx)(`input`,{type:`search`,value:G,onChange:e=>{de(e.target.value),q(24)},placeholder:t.searchPlaceholder,className:`h-10 w-full rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none transition placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]})]}),(0,Q.jsxs)(Le,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":t.memoryFilterHint,indicatorClassName:`rounded-full bg-surface-active`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Re===`all`,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Re===`all`?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>ze(`all`),children:[t.allMemory,(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:gt.length})]}),wt.map(({kind:t,count:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":Re===t,className:`touch-target inline-flex min-h-9 cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${Re===t?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`}`,onClick:()=>ze(t),children:[Zt(t,e),(0,Q.jsx)(`span`,{className:`tabular-nums text-fg-subtle`,children:n})]},t))]})]}),yt.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`space-y-8`,children:Ot.map(({kind:t,items:n,totalCount:r})=>(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-surface-panel`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between px-5 pb-1 pt-4 sm:px-6`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Zt(t,e)}),(0,Q.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:r})]}),(0,Q.jsx)(`div`,{children:n.map(t=>(0,Q.jsx)(on,{item:t,language:e,busy:!!h,expanded:J===t.id,onToggle:()=>fe(e=>e===t.id?void 0:t.id),editing:I===`knowledge:${t.id}`,draft:oe,onDraftChange:W,onEdit:()=>{L(`knowledge:${t.id}`),W(t.content)},onCancel:()=>{L(void 0),W(``)},onDelete:()=>void qe(t.id,()=>te(t.id)),onScopeChange:e=>void qe(t.id,()=>ee(t,e)),onReview:(e,n)=>void qe(t.id,async()=>{await D(t,e,n),L(void 0),W(``)})},t.id))})]},t))}),yt.length>K?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(Y,{onClick:()=>q(e=>e+24),children:t.showMore})}):null]}):(0,Q.jsx)(`div`,{className:`rounded-2xl bg-surface-panel`,children:(0,Q.jsx)(en,{icon:(0,Q.jsx)(xe,{className:`size-5`}),children:G.trim()?t.noKnowledgeMatch:t.noKnowledge})})]}):null,m===`privacy`?(0,Q.jsxs)(`div`,{id:`understanding-panel-privacy`,role:`tabpanel`,"aria-labelledby":`understanding-tab-privacy`,className:`space-y-8`,children:[(0,Q.jsx)(`div`,{className:`px-1 pt-1`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Se,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-fg`,children:e===`zh`?`你的信息,由你掌控`:`Your information, under your control`}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:e===`zh`?`决定 xopc 可以记住什么、从哪里了解你,以及如何迁移你的数据。`:`Decide what xopc can remember, where it learns from, and how your data moves.`})]})]})}),(0,Q.jsx)($t,{title:e===`zh`?`记忆与使用`:`Memory & use`,children:(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle`,children:[[{key:`memory`,icon:z,title:e===`zh`?`长期记忆`:`Long-term memory`,detail:e===`zh`?`记住长期有用的信息,减少重复说明。`:`Remember useful information so you do not have to repeat yourself.`,enabled:l.settings.memoryEnabled},{key:`references`,icon:we,title:e===`zh`?`回答中的记忆引用`:`Memory references in answers`,detail:e===`zh`?`当个人信息影响回答时,显示本次参考内容。`:`Show what personal context was referenced when it shapes an answer.`,enabled:l.settings.showMemoryReferences}].map(({key:e,icon:t,title:n,detail:r,enabled:i})=>(0,Q.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":i,disabled:!!h,className:`flex min-h-20 w-full items-center gap-4 px-5 py-4 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent disabled:opacity-60 sm:px-6`,onClick:()=>void qe(`setting:${e}`,()=>k(e===`memory`?{memoryEnabled:!i}:{showMemoryReferences:!i})),children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(t,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:r})]}),(0,Q.jsx)(`span`,{className:`relative h-6 w-11 shrink-0 rounded-full transition-colors ${i?`bg-accent`:`bg-surface-active`}`,"aria-hidden":`true`,children:(0,Q.jsx)(`span`,{className:`absolute top-0.5 size-5 rounded-full bg-white shadow-sm transition-transform ${i?`translate-x-5`:`translate-x-0.5`}`})})]},e)),(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center gap-4 px-5 py-4 sm:px-6`,children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(ge,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`敏感信息`:`Sensitive information`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`控制健康、财务等信息是否可以保存。`:`Control whether health, financial, and similar information can be saved.`})]}),(0,Q.jsxs)(H,{"aria-label":e===`zh`?`敏感信息策略`:`Sensitive information policy`,value:l.settings.sensitiveWritePolicy,disabled:!!h,onChange:e=>void qe(`setting:sensitive`,()=>k({sensitiveWritePolicy:e.target.value})),children:[(0,Q.jsx)(U,{value:`confirm`,children:e===`zh`?`先询问`:`Ask first`}),(0,Q.jsx)(U,{value:`deny`,children:e===`zh`?`不保存`:`Never save`}),(0,Q.jsx)(U,{value:`allow`,children:e===`zh`?`允许`:`Allow`})]})]})]})}),(0,Q.jsx)($t,{title:e===`zh`?`数据管理`:`Data management`,children:(0,Q.jsxs)(`div`,{className:`divide-y divide-edge-subtle`,children:[(0,Q.jsxs)(o,{to:`/settings/imports`,className:`flex min-h-20 items-center gap-4 px-5 py-4 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent sm:px-6`,children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(De,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`从其他 AI 导入`:`Import from another AI`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`导入前预览新增、重复和冲突内容。`:`Preview new, duplicate, and conflicting items before import.`})]}),(0,Q.jsx)(V,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`})]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:!!h,className:`flex min-h-20 w-full items-center gap-4 px-5 py-4 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent disabled:opacity-60 sm:px-6`,onClick:()=>void qe(`export`,E),children:[(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base text-fg-muted`,children:(0,Q.jsx)(ue,{className:`size-4.5`,"aria-hidden":`true`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e===`zh`?`下载我的记忆`:`Download my memory`}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e===`zh`?`导出为可阅读、可迁移的数据包。`:`Export a readable, portable archive.`})]}),(0,Q.jsx)(V,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`})]})]})}),(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel px-5 py-5 sm:px-6`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e===`zh`?`纠正与忘记`:`Correct and forget`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e===`zh`?`在“记忆”中打开任意一条内容的菜单,即可修改、调整作用范围或彻底删除。`:`Open any item in Memory to edit it, change where it applies, or delete it permanently.`}),(0,Q.jsx)(Y,{variant:`ghost`,className:`mt-3`,onClick:()=>{Ue(`understanding`)},children:e===`zh`?`管理记忆`:`Manage memory`})]})]}):null,(0,Q.jsx)(tn,{open:pe,profile:tt,language:e,saving:h===`profile`,onOpenChange:me,onSave:e=>void Ye(e)}),(0,Q.jsx)(nn,{open:_e,priority:$,title:dt??``,outcome:ft?.desiredOutcome,language:e,saving:h===($?`priority:${$.id}`:`priority:create`),onOpenChange:Ce,onSave:e=>$?void Xe($,e):void Ze(e),onEnd:$?()=>void Qe($):void 0})]})}export{sn as UserModelPage};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./secret-input-DsjfQmDn.js";import{t as i}from"./cn-0WouolD0.js";import{m as a}from"./voice-config-api-DhJ3l8fk.js";var o=t();e();var s=n();function c(e){let t=(0,o.c)(15),{kind:n,providerId:c,fieldId:u,value:d,onChange:f,labels:p,placeholder:m,className:h}=e,g=m===void 0?`sk-...`:m,_;t[0]!==n||t[1]!==c?(_=()=>a({kind:n,provider:c}).then(l),t[0]=n,t[1]=c,t[2]=_):_=t[2];let v=_,y;t[3]===h?y=t[4]:(y=i(`flex min-w-0 flex-col gap-1.5`,h),t[3]=h,t[4]=y);let b;t[5]!==u||t[6]!==p||t[7]!==f||t[8]!==g||t[9]!==v||t[10]!==d?(b=(0,s.jsx)(r,{id:u,value:d,onChange:f,placeholder:g,labels:p,reveal:v,loadFailedLabel:p.loadFailed,maskedHelp:p.maskedHelp,notInConfigFile:p.notInConfigFile,inputClassName:`text-xs`}),t[5]=u,t[6]=p,t[7]=f,t[8]=g,t[9]=v,t[10]=d,t[11]=b):b=t[11];let x;return t[12]!==y||t[13]!==b?(x=(0,s.jsx)(`div`,{className:y,children:b}),t[12]=y,t[13]=b,t[14]=x):x=t[14],x}function l(e){return e.apiKey??null}export{c as t};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./secret-input-DsjfQmDn.js";import{t as i}from"./cn-0WouolD0.js";import{m as a}from"./voice-config-api-7AHN-ns6.js";var o=t();e();var s=n();function c(e){let t=(0,o.c)(15),{kind:n,providerId:c,fieldId:u,value:d,onChange:f,labels:p,placeholder:m,className:h}=e,g=m===void 0?`sk-...`:m,_;t[0]!==n||t[1]!==c?(_=()=>a({kind:n,provider:c}).then(l),t[0]=n,t[1]=c,t[2]=_):_=t[2];let v=_,y;t[3]===h?y=t[4]:(y=i(`flex min-w-0 flex-col gap-1.5`,h),t[3]=h,t[4]=y);let b;t[5]!==u||t[6]!==p||t[7]!==f||t[8]!==g||t[9]!==v||t[10]!==d?(b=(0,s.jsx)(r,{id:u,value:d,onChange:f,placeholder:g,labels:p,reveal:v,loadFailedLabel:p.loadFailed,maskedHelp:p.maskedHelp,notInConfigFile:p.notInConfigFile,inputClassName:`text-xs`}),t[5]=u,t[6]=p,t[7]=f,t[8]=g,t[9]=v,t[10]=d,t[11]=b):b=t[11];let x;return t[12]!==y||t[13]!==b?(x=(0,s.jsx)(`div`,{className:y,children:b}),t[12]=y,t[13]=b,t[14]=x):x=t[14],x}function l(e){return e.apiKey??null}export{c as t};