@xopcai/xopc 0.0.431 → 0.0.433

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 (186) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-WqnVruhY.js → activity-store-BpYGrRXw.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CSiO9c2F.js → agent-avatar-dicebear-DTgOSv6G.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-display-D-yds6wG.js → agent-avatar-display-BUH7ljEo.js} +2 -2
  6. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-_UT9C7bg.js → agent-defaults-settings-panel-B_FAikHA.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DVzYXsAy.js → agent-plugin-dialog-DPabZaSE.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agents-Ds7K3D7T.js → agents-BAPYP1Ka.js} +3 -3
  9. package/dist/gateway/static/root/assets/{agents-admin-api-Bgv4lJ9Y.js → agents-admin-api-CXCAHNPj.js} +1 -1
  10. package/dist/gateway/static/root/assets/{api-Dv6Cn-Rs.js → api-DMbimMEi.js} +1 -1
  11. package/dist/gateway/static/root/assets/{api-C-9J9ghT.js → api-oIK4hYkJ.js} +1 -1
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-BXJrrjH5.js → app-management-settings-panel-BZ3Fy8ZR.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-oYjAVulT.js → appearance-settings-DsRTj1by.js} +1 -1
  14. package/dist/gateway/static/root/assets/{apps-page-D95yzj-f.js → apps-page-D-n71lO1.js} +1 -1
  15. package/dist/gateway/static/root/assets/{archive-plugin-DBPu3xCJ.js → archive-plugin-Bg1VTieK.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automation-api-DAou8Kji.js → automation-api-CLPsgcQN.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automation-result-state-CA7LV098.js → automation-result-state-CKVnR4KG.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automation-task-card-DIjI_Y1X.js → automation-task-card-D27Mw66U.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automations-page-BQwSCkmd.js → automations-page-DGNTJ8lN.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automations-workspace-BUFTTjBq.js → automations-workspace-DWDWy-SG.js} +2 -2
  21. package/dist/gateway/static/root/assets/{binary-plugins-D25P9ZxQ.js → binary-plugins-CuwSdCG5.js} +1 -1
  22. package/dist/gateway/static/root/assets/{block-editor-BI105p1U.js → block-editor-Dtl2BG3t.js} +1 -1
  23. package/dist/gateway/static/root/assets/{browser-automation-inputs-DhDRvWQE.js → browser-automation-inputs-uGK086ag.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-automations-page-CCPi1Bvy.js → browser-automations-page-Da_edNNS.js} +1 -1
  25. package/dist/gateway/static/root/assets/{browser-control-api-BN4F-bM1.js → browser-control-api-k3OOX3bS.js} +1 -1
  26. package/dist/gateway/static/root/assets/{browser-settings-page-BZXUZpjp.js → browser-settings-page-C1bSw-Jq.js} +1 -1
  27. package/dist/gateway/static/root/assets/{capabilities-LC-yEQYo.js → capabilities-CoeuLRt6.js} +1 -1
  28. package/dist/gateway/static/root/assets/{capabilities-u2z_KFRt.js → capabilities-DlHPLld_.js} +1 -1
  29. package/dist/gateway/static/root/assets/{capabilities-page-B8UgQ4dD.js → capabilities-page-IcwojmJK.js} +2 -2
  30. package/dist/gateway/static/root/assets/{capabilities-settings-panel-Bxn8HtEO.js → capabilities-settings-panel-CtY-bGIi.js} +1 -1
  31. package/dist/gateway/static/root/assets/{channels-9Uaa-IN0.js → channels-Cn1MWBL_.js} +1 -1
  32. package/dist/gateway/static/root/assets/{chat-agents-api-Cffxfzi1.js → chat-agents-api-BB0biwc7.js} +1 -1
  33. package/dist/gateway/static/root/assets/{chat-chart-block-Bbk0b3TV.js → chat-chart-block-QSvjx4w6.js} +1 -1
  34. package/dist/gateway/static/root/assets/{chat-page-e-xCsrdS.js → chat-page-CwP4OMdW.js} +16 -16
  35. package/dist/gateway/static/root/assets/{chat-terminal-dock-CQMuG-Bz.js → chat-terminal-dock-Cd51G9eG.js} +1 -1
  36. package/dist/gateway/static/root/assets/{command-palette-api-BRxfFgGA.js → command-palette-api-CEG10uE-.js} +1 -1
  37. package/dist/gateway/static/root/assets/{composer-payload-handoff-_9L2A5AZ.js → composer-payload-handoff-Bogdq9Hy.js} +1 -1
  38. package/dist/gateway/static/root/assets/{computer-settings-page-BIHbjBVt.js → computer-settings-page-DyAlOzqY.js} +1 -1
  39. package/dist/gateway/static/root/assets/{connected-providers-grid-B7ktDgqt.js → connected-providers-grid-D0lXg22c.js} +1 -1
  40. package/dist/gateway/static/root/assets/{connector-service-page-BVMEg8n-.js → connector-service-page-k2rjyjrp.js} +1 -1
  41. package/dist/gateway/static/root/assets/{connectors-api-B07yoCzk.js → connectors-api-DtvB9Cjm.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connectors-page-hPKaJUWY.js → connectors-page-DI_Q0CKz.js} +1 -1
  43. package/dist/gateway/static/root/assets/{date-picker-BvEnSGZK.js → date-picker-CAankdQw.js} +1 -1
  44. package/dist/gateway/static/root/assets/{desktop-pet-C1z9YDEg.js → desktop-pet-DjM73fir.js} +1 -1
  45. package/dist/gateway/static/root/assets/{desktop-pet-settings-CbbVb8GY.js → desktop-pet-settings-Rmh-GxHl.js} +1 -1
  46. package/dist/gateway/static/root/assets/{dev-view-store-38EmUIEC.js → dev-view-store-BgW2Riyk.js} +1 -1
  47. package/dist/gateway/static/root/assets/{device-pairing-wizard-Wb1EKiXA.js → device-pairing-wizard-UdzSpNa5.js} +1 -1
  48. package/dist/gateway/static/root/assets/{directory-picker-path-field-BvKDrKc4.js → directory-picker-path-field-Rkw3f7lG.js} +1 -1
  49. package/dist/gateway/static/root/assets/{discussion-annotation-sync-BfVzIwe2.js → discussion-annotation-sync-Dudoj_Fz.js} +1 -1
  50. package/dist/gateway/static/root/assets/{extension-debug-page-CB9Lu3Sq.js → extension-debug-page-DxIGAO23.js} +1 -1
  51. package/dist/gateway/static/root/assets/{extension-iframe-host-BzjrVAUR.js → extension-iframe-host-63KpX6IP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{extension-marketplace-api-DigziAgd.js → extension-marketplace-api-yXNUkQDA.js} +1 -1
  53. package/dist/gateway/static/root/assets/{extension-page-DUa9MeaZ.js → extension-page-C811A_Ww.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-provider-301x0rh-.js → extension-provider-C4jLFIgh.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-settings-page-CP9ciZUI.js → extension-settings-page-WJSw5MT0.js} +1 -1
  56. package/dist/gateway/static/root/assets/{file-preview-surface-BaMGmCbw.js → file-preview-surface-zE9AcaHM.js} +1 -1
  57. package/dist/gateway/static/root/assets/{gateway-config-swr-BD4Bf8uu.js → gateway-config-swr-D6cc6W6E.js} +1 -1
  58. package/dist/gateway/static/root/assets/{gateway-realtime-CSd9VB7Z.js → gateway-realtime-BSRNLciy.js} +1 -1
  59. package/dist/gateway/static/root/assets/gateway-realtime-store-BFeFfApQ.js +1 -0
  60. package/dist/gateway/static/root/assets/{gateway-restart-CIUCTKYR.js → gateway-restart-Unun5hRL.js} +1 -1
  61. package/dist/gateway/static/root/assets/{gateway-settings-CCqF1uZv.js → gateway-settings-DP-DV-e5.js} +1 -1
  62. package/dist/gateway/static/root/assets/{gateway-startup-retry-BsU5k8oi.js → gateway-startup-retry-C8g666Ja.js} +1 -1
  63. package/dist/gateway/static/root/assets/{global-defaults-api-asOZQeM8.js → global-defaults-api-BObi-1ww.js} +1 -1
  64. package/dist/gateway/static/root/assets/{home-page-Bb_RC1O9.js → home-page-CIcs7Mzy.js} +2 -2
  65. package/dist/gateway/static/root/assets/{image-generation-api-CdwYgzhU.js → image-generation-api-C2SqYNyD.js} +1 -1
  66. package/dist/gateway/static/root/assets/{imports-page-CVnoGUyp.js → imports-page-C8ezUkOJ.js} +1 -1
  67. package/dist/gateway/static/root/assets/{index-BmUSsdwn.js → index-D1_PUrJf.js} +5 -5
  68. package/dist/gateway/static/root/assets/{install-connector-dialog-DXVOHMhS.js → install-connector-dialog-Cn4nRSyt.js} +1 -1
  69. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BCl90SrD.js → keyboard-shortcuts-settings-BRaY4-wA.js} +1 -1
  70. package/dist/gateway/static/root/assets/{local-app-workbench-page-CcJc9xLJ.js → local-app-workbench-page-BZtVcjF3.js} +1 -1
  71. package/dist/gateway/static/root/assets/{local-apps-page-CdAKoWfg.js → local-apps-page-MqP4EnJm.js} +1 -1
  72. package/dist/gateway/static/root/assets/{local-session-drafts-nRGeybku.js → local-session-drafts-DTq9776a.js} +1 -1
  73. package/dist/gateway/static/root/assets/{locale-store-B7y-RVe8.js → locale-store-B6OrWgY1.js} +1 -1
  74. package/dist/gateway/static/root/assets/{logs-page-McbSQwJI.js → logs-page-hkHBjblX.js} +1 -1
  75. package/dist/gateway/static/root/assets/{management-settings-BIR0BwNV.js → management-settings-DoX4eTM3.js} +1 -1
  76. package/dist/gateway/static/root/assets/{markdown-view-DFHa8rUg.js → markdown-view-DrhYZSmg.js} +1 -1
  77. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-Dwx4TuIr.js → mcp-conversation-setup-page-BEp5E6TD.js} +1 -1
  78. package/dist/gateway/static/root/assets/{media-plugins-BzzLV7wW.js → media-plugins-D987i9Gc.js} +1 -1
  79. package/dist/gateway/static/root/assets/messages-jwdBhfL9.js +3 -0
  80. package/dist/gateway/static/root/assets/{model-selector-YsCHu1Gn.js → model-selector-DXm4NS1_.js} +1 -1
  81. package/dist/gateway/static/root/assets/{models-hub-cache-BUapaPTN.js → models-hub-cache-BLcha5rx.js} +1 -1
  82. package/dist/gateway/static/root/assets/{note-detail-panel-CJ-dPovd.js → note-detail-panel-Cl851ivY.js} +3 -3
  83. package/dist/gateway/static/root/assets/note-image-lightbox-DGYRJS03.js +1 -0
  84. package/dist/gateway/static/root/assets/{notes-api-ulup1oFS.js → notes-api-Ddsf7FVg.js} +1 -1
  85. package/dist/gateway/static/root/assets/{notes-page-BaFNplIr.js → notes-page-DSwA1MU1.js} +1 -1
  86. package/dist/gateway/static/root/assets/{oauth-api-DINa08-z.js → oauth-api-CMmu4DzH.js} +1 -1
  87. package/dist/gateway/static/root/assets/{oauth-provider-connect-C0PVEHC2.js → oauth-provider-connect-BkhnftBq.js} +1 -1
  88. package/dist/gateway/static/root/assets/{page-context-capture-button-CGfR0dsc.js → page-context-capture-button-urhQBRaN.js} +1 -1
  89. package/dist/gateway/static/root/assets/{page-context-draft-DhRNxc0v.js → page-context-draft-BuNUerth.js} +1 -1
  90. package/dist/gateway/static/root/assets/page-header-store-CEn_kPsn.js +1 -0
  91. package/dist/gateway/static/root/assets/{personal-avatar-DiVFO2Aw.js → personal-avatar-B49ueeZO.js} +1 -1
  92. package/dist/gateway/static/root/assets/{personal-page-Cvd-v9kT.js → personal-page-f05ceuFn.js} +1 -1
  93. package/dist/gateway/static/root/assets/{personal-settings-panel-Ds4ntiqu.js → personal-settings-panel-DLQxzPYr.js} +1 -1
  94. package/dist/gateway/static/root/assets/{phone-dependencies-card-B3R6L5Qu.js → phone-dependencies-card-DjmC1Z5j.js} +1 -1
  95. package/dist/gateway/static/root/assets/{phone-model-connection-BieYnAJ5.js → phone-model-connection-BRjHSgYn.js} +1 -1
  96. package/dist/gateway/static/root/assets/{phone-model-picker-Bkex4Sre.js → phone-model-picker-DgIiWLhR.js} +1 -1
  97. package/dist/gateway/static/root/assets/{phone-settings-page-D8PuvEuJ.js → phone-settings-page-DCZGCL_z.js} +1 -1
  98. package/dist/gateway/static/root/assets/{phone-workspace-store-Cmes9gQ4.js → phone-workspace-store-DbqktZbO.js} +1 -1
  99. package/dist/gateway/static/root/assets/{plugin-details-dialog-DblFhnuC.js → plugin-details-dialog-D4tGKip4.js} +1 -1
  100. package/dist/gateway/static/root/assets/{preference-select-fields-D2-QfMN5.js → preference-select-fields-BZWqG7pu.js} +1 -1
  101. package/dist/gateway/static/root/assets/{product-automation-feedback-BzY3z8zu.js → product-automation-feedback-DDQUsag7.js} +1 -1
  102. package/dist/gateway/static/root/assets/{product-open-page-BKw6H0Mn.js → product-open-page-BkRP_HmA.js} +1 -1
  103. package/dist/gateway/static/root/assets/{product-preview-content-VcvxaO2S.js → product-preview-content-o2Y3VNE7.js} +1 -1
  104. package/dist/gateway/static/root/assets/{product-preview-modal-Ym6bomTW.js → product-preview-modal-7Ohx-7OR.js} +2 -2
  105. package/dist/gateway/static/root/assets/{project-detail-page-CFbXWvcd.js → project-detail-page-B2RsSHya.js} +1 -1
  106. package/dist/gateway/static/root/assets/{project-understanding-CrSkrJnM.js → project-understanding-BIMouiYX.js} +1 -1
  107. package/dist/gateway/static/root/assets/{projects-page-Cp91_KzA.js → projects-page-C9R5u3tF.js} +1 -1
  108. package/dist/gateway/static/root/assets/{providers-api-CBSC3jdu.js → providers-api-BOCkRZ7X.js} +1 -1
  109. package/dist/gateway/static/root/assets/{recording-upload-DBHAGKZj.js → recording-upload-C6muEHEO.js} +1 -1
  110. package/dist/gateway/static/root/assets/{registry-api-QZEjziDq.js → registry-api-Bl2guMRg.js} +1 -1
  111. package/dist/gateway/static/root/assets/{remote-access-hub-BdXxFQfH.js → remote-access-hub-BceSMbCs.js} +1 -1
  112. package/dist/gateway/static/root/assets/{resource-unavailable-BTNhcOHF.js → resource-unavailable-CUNbPkdj.js} +1 -1
  113. package/dist/gateway/static/root/assets/{route-preload-C-VRKwB1.js → route-preload-C1BKDjnu.js} +2 -2
  114. package/dist/gateway/static/root/assets/{runtime-tools-api-BDTUD8Rj.js → runtime-tools-api-LopLjgvu.js} +1 -1
  115. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CYEzIrDf.js → runtime-tools-settings-panel-9HIPerDP.js} +1 -1
  116. package/dist/gateway/static/root/assets/{service-recommendation-list-CfeYH6lK.js → service-recommendation-list-CoMI6MB1.js} +1 -1
  117. package/dist/gateway/static/root/assets/{session-api-DVXLCZX2.js → session-api-Bfmlmn9F.js} +1 -1
  118. package/dist/gateway/static/root/assets/session-manager-X4UHOjjO.js +25 -0
  119. package/dist/gateway/static/root/assets/{sessions-page-C2CH-55n.js → sessions-page-BT0GdXdS.js} +1 -1
  120. package/dist/gateway/static/root/assets/settings-advanced-gate-Dk9c-Z5e.js +1 -0
  121. package/dist/gateway/static/root/assets/{settings-advanced-section-BmrbHgQa.js → settings-advanced-section-CEorDLUp.js} +1 -1
  122. package/dist/gateway/static/root/assets/{settings-mode-store-Bk_hzwPK.js → settings-mode-store-C2LZqBES.js} +1 -1
  123. package/dist/gateway/static/root/assets/{settings-page-B6vrcc6f.js → settings-page-C_Np_6qZ.js} +1 -1
  124. package/dist/gateway/static/root/assets/{settings-page-header-BLKI3_9N.js → settings-page-header-BAN34UQi.js} +1 -1
  125. package/dist/gateway/static/root/assets/{settings-page-layout-BqBVrkC9.js → settings-page-layout-B5TVFBV2.js} +1 -1
  126. package/dist/gateway/static/root/assets/{setup-interaction-page-BDPte58u.js → setup-interaction-page-BYvTJW3_.js} +1 -1
  127. package/dist/gateway/static/root/assets/{setup-status-panel-DEefuWo3.js → setup-status-panel-UY2dH-sK.js} +1 -1
  128. package/dist/gateway/static/root/assets/{share-link-dialog-C2LyeNzj.js → share-link-dialog-BMcXyzr2.js} +1 -1
  129. package/dist/gateway/static/root/assets/{share-preview-page-BFwEr7Ws.js → share-preview-page-UQ6eUM2_.js} +1 -1
  130. package/dist/gateway/static/root/assets/{shares-api-CTFkLQxq.js → shares-api-DOeDN6Tm.js} +1 -1
  131. package/dist/gateway/static/root/assets/{shares-settings-CpK3yhtc.js → shares-settings-W8XhuAoL.js} +1 -1
  132. package/dist/gateway/static/root/assets/{skill-api-DpicfA6o.js → skill-api-Do_c0d9n.js} +1 -1
  133. package/dist/gateway/static/root/assets/{skill-list-api-B8fegRLZ.js → skill-list-api-DpHaXI2l.js} +1 -1
  134. package/dist/gateway/static/root/assets/{skill-reload-api-VmC8ySUy.js → skill-reload-api-DDRd9IJ2.js} +1 -1
  135. package/dist/gateway/static/root/assets/{skills-page-BIWXS6Ki.js → skills-page-CaeJVKhO.js} +1 -1
  136. package/dist/gateway/static/root/assets/{system-settings-panel-BmoA92oX.js → system-settings-panel-DYWlWPJL.js} +1 -1
  137. package/dist/gateway/static/root/assets/{task-detail-page-CC3Rzqq9.js → task-detail-page-De0qD7xw.js} +1 -1
  138. package/dist/gateway/static/root/assets/{task-result-evidence-BV-6hBVU.js → task-result-evidence-CICR5K1t.js} +1 -1
  139. package/dist/gateway/static/root/assets/{terminal-panel-store-BGdKE9hU.js → terminal-panel-store-BbWUcQe7.js} +1 -1
  140. package/dist/gateway/static/root/assets/{theme-store-Dvv79Wb2.js → theme-store-TkG5mo0p.js} +1 -1
  141. package/dist/gateway/static/root/assets/{tracing-settings-page-B4uA4Pnz.js → tracing-settings-page-CYXEy4EG.js} +1 -1
  142. package/dist/gateway/static/root/assets/{tunnel-api-BurZtvqx.js → tunnel-api-DquDm6U2.js} +1 -1
  143. package/dist/gateway/static/root/assets/{understanding-activity-store-C1cLL8zq.js → understanding-activity-store-Ot3wZ3oQ.js} +1 -1
  144. package/dist/gateway/static/root/assets/{understanding-refresh-store-C3Lr_pjY.js → understanding-refresh-store-C5KYFMaC.js} +1 -1
  145. package/dist/gateway/static/root/assets/{usage-page-C91ZzLm9.js → usage-page-1xFO4smo.js} +1 -1
  146. package/dist/gateway/static/root/assets/{use-autosave-zkzRuUtx.js → use-autosave-HL8XRNR8.js} +1 -1
  147. package/dist/gateway/static/root/assets/{use-composer-attachments-CoiQAgjo.js → use-composer-attachments-XRlQBdNF.js} +1 -1
  148. package/dist/gateway/static/root/assets/{use-file-preview-expanded-DFzy6iVy.js → use-file-preview-expanded-CW956CXS.js} +2 -2
  149. package/dist/gateway/static/root/assets/{use-personal-profile-BB10h9ED.js → use-personal-profile-202s6tJt.js} +1 -1
  150. package/dist/gateway/static/root/assets/{use-workspace-tree-sF5DcONt.js → use-workspace-tree-CjydkmH1.js} +1 -1
  151. package/dist/gateway/static/root/assets/{user-model-page-WFnD5utO.js → user-model-page-OGPXx3pe.js} +1 -1
  152. package/dist/gateway/static/root/assets/{voice-api-key-field-Bqa4PeZx.js → voice-api-key-field-CxFu4MEA.js} +1 -1
  153. package/dist/gateway/static/root/assets/{voice-config-api-LNO2xXHk.js → voice-config-api-MHe5Pn-A.js} +1 -1
  154. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-AzfhxBX7.js → voice-input-shortcut-events-B9xc1oK8.js} +1 -1
  155. package/dist/gateway/static/root/assets/{voice-transcribe-api-Cb8i6dLb.js → voice-transcribe-api-CVEcB6Pe.js} +1 -1
  156. package/dist/gateway/static/root/assets/{work-discovery-overlay-CdQUiV-a.js → work-discovery-overlay-C-JoAg2D.js} +1 -1
  157. package/dist/gateway/static/root/assets/{work-discovery-page-HcUloXxf.js → work-discovery-page-B5Kx29Ru.js} +1 -1
  158. package/dist/gateway/static/root/assets/{working-directory-picker-modal-Dv1HUipe.js → working-directory-picker-modal-DGp9cNzH.js} +1 -1
  159. package/dist/gateway/static/root/assets/{workspace-api-Am2ee4R6.js → workspace-api-HBXn8pL9.js} +2 -2
  160. package/dist/gateway/static/root/assets/workspace-editor-agent-store-msZa42fU.js +1 -0
  161. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-z5Q00v92.js → workspace-file-preview-dialog-3cpwSG2w.js} +1 -1
  162. package/dist/gateway/static/root/assets/{workspace-open-location-menu-4ONYaGy0.js → workspace-open-location-menu-D0VOFvuP.js} +1 -1
  163. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DimGN59n.js → xopc-cloud-account-card-BkdW2p3v.js} +1 -1
  164. package/dist/gateway/static/root/index.html +78 -78
  165. package/dist/package.js +1 -1
  166. package/dist/src/gateway/global-defaults-admin.js +1 -1
  167. package/dist/src/gateway/service.js +4 -4
  168. package/dist/src/home-intelligence/host.js +2 -2
  169. package/dist/src/phone/adb-driver.js +2 -2
  170. package/dist/src/phone/model-adapter.d.ts +2 -0
  171. package/dist/src/phone/model-adapter.js +10 -3
  172. package/dist/src/phone/reliability.js +24 -2
  173. package/dist/src/phone/runtime.js +6 -1
  174. package/dist/src/phone/ui-dump-binary.d.ts +1 -1
  175. package/dist/src/phone/ui-dump-binary.js +1 -1
  176. package/dist/src/session/client-history.d.ts +2 -0
  177. package/dist/src/session/client-history.js +3 -0
  178. package/dist/src/session/compact-history.js +1 -0
  179. package/package.json +1 -1
  180. package/dist/gateway/static/root/assets/gateway-realtime-store-Bxkv62qs.js +0 -1
  181. package/dist/gateway/static/root/assets/messages-DYDkJvXj.js +0 -3
  182. package/dist/gateway/static/root/assets/note-image-lightbox-ClPkeHe5.js +0 -1
  183. package/dist/gateway/static/root/assets/page-header-store-CoKMiYoi.js +0 -1
  184. package/dist/gateway/static/root/assets/session-manager-DjRWxXJG.js +0 -23
  185. package/dist/gateway/static/root/assets/settings-advanced-gate-BMHe9uwy.js +0 -1
  186. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CqHcVFhS.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,l as o,o as s,p as c}from"./locale-store-B7y-RVe8.js";import{a as l,n as u,o as d,r as f,s as p,t as m}from"./dist-BGTk37IG.js";import{t as h}from"./createLucideIcon-DPHK1VkS.js";import{t as g}from"./markdown-view-DFHa8rUg.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./cn-0WouolD0.js";import{r as y,t as b}from"./chat-chart-block-Bbk0b3TV.js";var x=h(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),S=n(),C=e(t(),1),w=r(),T=(0,C.createContext)(null);function E(){let e=(0,S.c)(1),t=(0,C.useContext)(T);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:D},e[0]=t):t=e[0],t}return t}function D(){}function O(e){let t=(0,S.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[a,o]=(0,C.useState)(null),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{o({src:e,alt:t})},t[0]=s):s=t[0];let c=s,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h={openImage:c},t[1]=h):h=t[1];let g=h,y=a!==null,b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{e||o(null)},t[2]=b):b=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,w.jsx)(l,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=x):x=t[3];let E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(E=v(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=E):E=t[4];let D=a?.alt||`Image preview`,O;t[5]===D?O=t[6]:(O=(0,w.jsx)(p,{className:`sr-only`,children:D}),t[5]=D,t[6]=O);let k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,w.jsx)(_,{className:`size-5`,"aria-hidden":!0}),t[7]=k):k=t[7];let A;t[8]===i?A=t[9]:(A=(0,w.jsx)(u,{asChild:!0,children:(0,w.jsx)(`button`,{type:`button`,"aria-label":i,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:k})}),t[8]=i,t[9]=A);let j;t[10]===a?j=t[11]:(j=a?(0,w.jsx)(`img`,{src:a.src,alt:a.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=a,t[11]=j);let M;t[12]!==A||t[13]!==j||t[14]!==O?(M=(0,w.jsxs)(d,{children:[x,(0,w.jsxs)(f,{className:E,"aria-describedby":void 0,children:[O,A,j]})]}),t[12]=A,t[13]=j,t[14]=O,t[15]=M):M=t[15];let N;t[16]!==M||t[17]!==y?(N=(0,w.jsx)(m,{open:y,onOpenChange:b,children:M}),t[16]=M,t[17]=y,t[18]=N):N=t[18];let P;return t[19]!==n||t[20]!==N?(P=(0,w.jsxs)(T.Provider,{value:g,children:[n,N]}),t[19]=n,t[20]=N,t[21]=P):P=t[21],P}var k=`xopc-attachment`,A=/^xopc-attachment:\/\/notes\/([^/]+)\/([^/?#]+)$/i,j=/^\/api\/notes\/([^/]+)\/media\/([^/?#]+)$/i;function M(e,t){return`${k}://notes/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function N(e,t){let n=e.trim();if(!n)return null;let r=n.split(`?`)[0],i=r.match(A),a=r.match(j),o=i??a;if(!o)return null;let s=decodeURIComponent(o[1]),c=decodeURIComponent(o[2]);return t&&s!==t?null:{noteId:s,attachmentId:c}}function P(e,t){return`/api/notes/${encodeURIComponent(e)}/media/${encodeURIComponent(t)}`}var F=new Map,I=``;function L(e,t,n){return`${n}:${e}:${t}`}function R(){let e=o.getState().conversationId??``;if(e!==I){for(let e of F.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);F.clear(),I=e}}async function ee(e,t){R();let n=L(e,t,o.getState().conversationId??``),r=F.get(n);return r||(r={blob:(async()=>{let n=await i(a(P(e,t)));if(n.status===401&&o.getState().onUnauthorized(),!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()})(),objectUrl:null,refCount:0},F.set(n,r)),r.blob}async function z(e,t){R();let n=L(e,t,o.getState().conversationId??``),r=F.get(n);if(r||(r={blob:ee(e,t),objectUrl:null,refCount:0},F.set(n,r)),!r.objectUrl){let e=await r.blob;r.objectUrl=URL.createObjectURL(e)}return r.refCount+=1,r.objectUrl}function B(e,t){R();let n=L(e,t,o.getState().conversationId??``),r=F.get(n);r&&(r.refCount=Math.max(0,r.refCount-1),r.refCount===0&&r.objectUrl&&(URL.revokeObjectURL(r.objectUrl),r.objectUrl=null,F.delete(n)))}var V={noteId:null,attachmentId:null,playing:!1,currentTime:0,duration:0,loading:!1},H=null,U=null,W=null,G=null;function K(){return H||(H=new Audio,H.addEventListener(`timeupdate`,()=>{J.setState({currentTime:H.currentTime})}),H.addEventListener(`loadedmetadata`,()=>{let e=H.duration;Number.isFinite(e)&&J.setState({duration:e})}),H.addEventListener(`ended`,()=>{J.setState({playing:!1,currentTime:0}),H.currentTime=0}),H.addEventListener(`pause`,()=>{J.setState({playing:!1})}),H.addEventListener(`play`,()=>{J.setState({playing:!0})})),H}function q(){W&&G&&B(W,G),U=null,W=null,G=null}var J=c()((e,t)=>({...V,play:async(n,r,i)=>{let a=K(),o=t();if(o.noteId===n&&o.attachmentId===r&&U){a.play();return}a.pause(),q(),e({noteId:n,attachmentId:r,playing:!1,currentTime:0,duration:i??0,loading:!0});try{let t=await z(n,r);U=t,W=n,G=r,a.src=t,await a.play(),window.dispatchEvent(new CustomEvent(`xopc-voice-playback-start`,{detail:{id:`note:${n}:${r}`}})),e({loading:!1})}catch{e({loading:!1,playing:!1}),q()}},pause:()=>{K().pause()},toggle:(e,n,r)=>{let i=t();i.noteId===e&&i.attachmentId===n&&i.playing?t().pause():t().play(e,n,r)},seek:t=>{let n=K();n.currentTime=t,e({currentTime:t})},reset:()=>{K().pause(),K().src=``,q(),e(V)}}));function Y(e,t){return M(e,t)}function te(e){if(e<60)return`Voice · ${e}s`;let t=Math.floor(e/60),n=e%60;return`Voice · ${t}:${String(n).padStart(2,`0`)}`}async function ne(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:`HTTP ${e.status}`}async function X(e,t,n){let r=new Headers;n&&r.set(`Idempotency-Key`,n);let i=await fetch(e,{method:`POST`,headers:r,body:t});if(i.status===401&&o.getState().onUnauthorized(),!i.ok)throw Error(await ne(i));return i.json()}function re(e){let t=(0,S.c)(39),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({src:s,expectedNoteId:r,alt:c,className:n,onClick:i,onLoadFailed:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?``:c,u;t[8]!==r||t[9]!==s?(u=N(s,r),t[8]=r,t[9]=s,t[10]=u):u=t[10];let d=u,[f,p]=(0,C.useState)(d?null:s),[m,h]=(0,C.useState)(!1),g,_;if(t[11]!==a||t[12]!==d||t[13]!==s?(g=()=>{if(h(!1),!d){p(s);return}let e=!1;return p(null),z(d.noteId,d.attachmentId).then(t=>{e||p(t)}).catch(()=>{e||(h(!0),a?.())}),()=>{e=!0,B(d.noteId,d.attachmentId)}},_=[s,d,a],t[11]=a,t[12]=d,t[13]=s,t[14]=g,t[15]=_):(g=t[14],_=t[15]),(0,C.useEffect)(g,_),m){let e;t[16]===n?e=t[17]:(e=v(`flex items-center justify-center bg-surface-hover text-fg-muted`,n),t[16]=n,t[17]=e);let r=!l,i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,w.jsx)(x,{className:`size-5`}),t[18]=i):i=t[18];let a;return t[19]!==e||t[20]!==r?(a=(0,w.jsx)(`div`,{className:e,"aria-hidden":r,children:i}),t[19]=e,t[20]=r,t[21]=a):a=t[21],a}if(!f){let e;t[22]===n?e=t[23]:(e=v(`animate-pulse bg-surface-hover`,n),t[22]=n,t[23]=e);let r=!l,i;return t[24]!==e||t[25]!==r?(i=(0,w.jsx)(`div`,{className:e,"aria-hidden":r}),t[24]=e,t[25]=r,t[26]=i):i=t[26],i}let y;t[27]!==f||t[28]!==i?(y=i?()=>i(f):void 0,t[27]=f,t[28]=i,t[29]=y):y=t[29];let b;t[30]===a?b=t[31]:(b=()=>{h(!0),a?.()},t[30]=a,t[31]=b);let T;return t[32]!==l||t[33]!==n||t[34]!==f||t[35]!==o||t[36]!==y||t[37]!==b?(T=(0,w.jsx)(`img`,{...o,src:f,alt:l,className:n,onClick:y,onError:b}),t[32]=l,t[33]=n,t[34]=f,t[35]=o,t[36]=y,t[37]=b,t[38]=T):T=t[38],T}function ie(e){return e.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^)\s]+)/gi,`/api/notes/$1/media/$2`)}function ae(e,t){let n=[];return e.querySelectorAll(`.markdown-body img`).forEach(e=>{let r=N(e.getAttribute(`src`)??``,t);if(!r)return;let i=!1;z(r.noteId,r.attachmentId).then(t=>{i||(e.src=t)}).catch(()=>{e.classList.add(`note-media-load-failed`)}),n.push(()=>{i=!0,B(r.noteId,r.attachmentId)})}),e.querySelectorAll(`.markdown-body a`).forEach(e=>{let r=N(e.getAttribute(`href`)??``,t);if(!r)return;let i=document.createElement(`audio`);i.controls=!0,i.className=`note-media-audio mt-2 w-full max-w-md`,e.replaceWith(i);let a=!1;z(r.noteId,r.attachmentId).then(e=>{a||(i.src=e)}).catch(()=>{i.remove()}),n.push(()=>{a=!0,B(r.noteId,r.attachmentId)})}),()=>{for(let e of n)e()}}function oe(e){let t=(0,S.c)(21),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({content:n,noteId:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(0,C.useRef)(null),o;t[4]!==i.codeCopy||t[5]!==i.streaming?(o=e=>(0,w.jsx)(b,{source:e.source,incomplete:!e.closed,streaming:i.streaming??!1,copy:i.codeCopy??!0}),t[4]=i.codeCopy,t[5]=i.streaming,t[6]=o):o=t[6];let s=o,c;t[7]===r?c=t[8]:(c=()=>{let e=a.current;if(e)return ae(e,r)},t[7]=r,t[8]=c);let l;t[9]!==n||t[10]!==r?(l=[n,r],t[9]=n,t[10]=r,t[11]=l):l=t[11],(0,C.useLayoutEffect)(c,l);let u;t[12]===n?u=t[13]:(u=ie(n),t[12]=n,t[13]=u);let d;t[14]===i.className?d=t[15]:(d=[`markdown-note`,i.className].filter(Boolean),t[14]=i.className,t[15]=d);let f=d.join(` `),p;return t[16]!==s||t[17]!==i||t[18]!==u||t[19]!==f?(p=(0,w.jsx)(`div`,{ref:a,children:(0,w.jsx)(y,{children:(0,w.jsx)(g,{content:u,mermaidActions:!0,...i,renderChart:s,className:f})})}),t[16]=s,t[17]=i,t[18]=u,t[19]=f,t[20]=p):p=t[20],p}async function se(){return s(a(`/api/notes/project-summaries`))}async function ce(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.kind&&t.set(`kind`,e.kind),e.tag&&t.set(`tag`,e.tag),e.projectId&&t.set(`projectId`,e.projectId),e.unassigned&&t.set(`unassigned`,`true`),e.agentEdited&&t.set(`agentEdited`,`true`),e.pinned!==void 0&&t.set(`pinned`,String(e.pinned)),e.search&&t.set(`search`,e.search),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset)),e.sortBy&&t.set(`sortBy`,e.sortBy),e.sortOrder&&t.set(`sortOrder`,e.sortOrder);let n=t.toString();return s(a(`/api/notes${n?`?${n}`:``}`))}async function le(e,t=`web`){return(await s(a(`/api/notes/quick-capture`),{method:`POST`,body:JSON.stringify({text:e,channel:t})})).note}async function ue(e,t){return(await s(a(`/api/notes`),{method:`POST`,...t?{headers:{"Idempotency-Key":t}}:{},body:JSON.stringify({markdown:e.markdown,title:e.title,kind:e.kind,tags:e.tags,projectId:e.projectId,pinned:e.pinned,channel:e.channel??`web`})})).note}async function de(e){let t=await i(a(`/api/notes/${encodeURIComponent(e)}`));if(t.status===404)return null;let n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.note??null}async function Z(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).note}async function fe(e){await s(a(`/api/notes/${encodeURIComponent(e)}`),{method:`DELETE`})}async function pe(e){return s(a(`/api/notes/${encodeURIComponent(e)}/shares`))}async function me(e,t){return s(a(`/api/notes/${encodeURIComponent(e)}/shares`),{method:`POST`,body:JSON.stringify(t)})}async function he(e,t,n){await s(a(`/api/notes/${encodeURIComponent(e)}/shares/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})}async function ge(e){return(await s(a(`/api/notes/${encodeURIComponent(e)}/hosted-publications`))).payload.publications}async function _e(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/hosted-publications`),{method:`POST`,body:JSON.stringify(t)})).payload}async function ve(e,t,n){return(await s(a(`/api/notes/${encodeURIComponent(e)}/hosted-publications/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})).payload}async function ye(e){return s(a(`/api/notes/${encodeURIComponent(e)}/catalyze`),{method:`POST`})}async function be(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/catalysis-feedback`),{method:`POST`,body:JSON.stringify({feedback:t})})).note}async function xe(e,t={}){return s(a(`/api/notes/${encodeURIComponent(e)}/chat`),{method:`POST`,body:JSON.stringify(t)})}async function Se(e){return(await s(a(`/api/notes/${encodeURIComponent(e)}/threads`))).items}async function Ce(e){return s(a(`/api/notes/${encodeURIComponent(e)}/context-status`))}async function we(e){return s(a(`/api/notes/${encodeURIComponent(e)}/context-rebuild`),{method:`POST`})}async function Te(e,t,n){return(await s(a(`/api/notes/${encodeURIComponent(e)}/append`),{method:`POST`,body:JSON.stringify({content:t,heading:n})})).note}async function Q(e,t={}){return(await s(a(`/api/notes/task`),{method:`POST`,body:JSON.stringify({title:e,channel:`web`,priority:t.priority,sourceConversationId:t.sourceConversationId||void 0,sourceNoteId:t.sourceNoteId||void 0})})).note}async function Ee(e,t,n){let r=new FormData;return r.append(`file`,t),(await X(a(`/api/notes/${encodeURIComponent(e)}/media`),r,n)).attachment}async function $(e,t){let n=new FormData;return n.append(`file`,e),t?.markdown&&n.append(`markdown`,t.markdown),n.append(`channel`,t?.channel??`web`),t?.kind&&n.append(`kind`,t.kind),t?.duration!==void 0&&n.append(`duration`,String(t.duration)),(await X(a(`/api/notes`),n)).note}async function De(e,t=`web`){let n=await $(e,{channel:t}),r=n.attachments?.find(e=>e.type===`image`)??n.attachments?.[0];if(!r)return n;let i=`![${r.fileName}](${Y(n.id,r.id)})`;return n.markdown!==i&&(n=await Z(n.id,{markdown:i})),n}async function Oe(e,t,n=`web`){let r=await $(e,{channel:n,kind:`voice`,duration:t}),i=r.attachments?.find(e=>e.type===`audio`)??r.attachments?.[0];if(!i)return r;let a=`[${te(t)}](${Y(r.id,i.id)})`;return r.markdown!==a&&(r=await Z(r.id,{markdown:a,kind:`voice`})),r}async function ke(e){return(await s(a(`/api/notes/${encodeURIComponent(e)}/history`))).entries}async function Ae(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/history/${t}`))).snapshot}async function je(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/history/restore`),{method:`POST`,body:JSON.stringify({timestamp:t})})).note}export{Y as A,ve as C,Ee as D,Z as E,E as F,x as I,M,N,oe as O,O as P,be as S,je as T,xe as _,me as a,Oe as b,de as c,ge as d,ke as f,ce as g,Se as h,ue as i,J as j,re as k,Ce as l,pe as m,ye as n,Q as o,se as p,_e as r,fe as s,Te as t,Ae as u,le as v,he as w,we as x,De as y};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,l as o,o as s,p as c}from"./locale-store-B6OrWgY1.js";import{a as l,n as u,o as d,r as f,s as p,t as m}from"./dist-BGTk37IG.js";import{t as h}from"./createLucideIcon-DPHK1VkS.js";import{t as g}from"./markdown-view-DrhYZSmg.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./cn-0WouolD0.js";import{r as y,t as b}from"./chat-chart-block-QSvjx4w6.js";var x=h(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),S=n(),C=e(t(),1),w=r(),T=(0,C.createContext)(null);function E(){let e=(0,S.c)(1),t=(0,C.useContext)(T);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={openImage:D},e[0]=t):t=e[0],t}return t}function D(){}function O(e){let t=(0,S.c)(22),{children:n,closeLabel:r}=e,i=r===void 0?`Close`:r,[a,o]=(0,C.useState)(null),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{o({src:e,alt:t})},t[0]=s):s=t[0];let c=s,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h={openImage:c},t[1]=h):h=t[1];let g=h,y=a!==null,b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{e||o(null)},t[2]=b):b=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,w.jsx)(l,{className:`fixed inset-0 z-[70] bg-scrim/90 backdrop-blur-sm`}),t[3]=x):x=t[3];let E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(E=v(`fixed inset-0 z-[71] flex items-center justify-center p-4 outline-none`,`data-[state=open]:animate-in data-[state=closed]:animate-out`),t[4]=E):E=t[4];let D=a?.alt||`Image preview`,O;t[5]===D?O=t[6]:(O=(0,w.jsx)(p,{className:`sr-only`,children:D}),t[5]=D,t[6]=O);let k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,w.jsx)(_,{className:`size-5`,"aria-hidden":!0}),t[7]=k):k=t[7];let A;t[8]===i?A=t[9]:(A=(0,w.jsx)(u,{asChild:!0,children:(0,w.jsx)(`button`,{type:`button`,"aria-label":i,className:`absolute right-4 top-4 z-10 rounded-lg bg-surface-panel/80 p-2 text-fg-muted backdrop-blur transition-colors hover:bg-surface-hover hover:text-fg`,children:k})}),t[8]=i,t[9]=A);let j;t[10]===a?j=t[11]:(j=a?(0,w.jsx)(`img`,{src:a.src,alt:a.alt??``,className:`max-h-[min(90vh,900px)] max-w-[min(95vw,1200px)] rounded-lg object-contain shadow-lg`}):null,t[10]=a,t[11]=j);let M;t[12]!==A||t[13]!==j||t[14]!==O?(M=(0,w.jsxs)(d,{children:[x,(0,w.jsxs)(f,{className:E,"aria-describedby":void 0,children:[O,A,j]})]}),t[12]=A,t[13]=j,t[14]=O,t[15]=M):M=t[15];let N;t[16]!==M||t[17]!==y?(N=(0,w.jsx)(m,{open:y,onOpenChange:b,children:M}),t[16]=M,t[17]=y,t[18]=N):N=t[18];let P;return t[19]!==n||t[20]!==N?(P=(0,w.jsxs)(T.Provider,{value:g,children:[n,N]}),t[19]=n,t[20]=N,t[21]=P):P=t[21],P}var k=`xopc-attachment`,A=/^xopc-attachment:\/\/notes\/([^/]+)\/([^/?#]+)$/i,j=/^\/api\/notes\/([^/]+)\/media\/([^/?#]+)$/i;function M(e,t){return`${k}://notes/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function N(e,t){let n=e.trim();if(!n)return null;let r=n.split(`?`)[0],i=r.match(A),a=r.match(j),o=i??a;if(!o)return null;let s=decodeURIComponent(o[1]),c=decodeURIComponent(o[2]);return t&&s!==t?null:{noteId:s,attachmentId:c}}function P(e,t){return`/api/notes/${encodeURIComponent(e)}/media/${encodeURIComponent(t)}`}var F=new Map,I=``;function L(e,t,n){return`${n}:${e}:${t}`}function R(){let e=o.getState().conversationId??``;if(e!==I){for(let e of F.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);F.clear(),I=e}}async function ee(e,t){R();let n=L(e,t,o.getState().conversationId??``),r=F.get(n);return r||(r={blob:(async()=>{let n=await i(a(P(e,t)));if(n.status===401&&o.getState().onUnauthorized(),!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()})(),objectUrl:null,refCount:0},F.set(n,r)),r.blob}async function z(e,t){R();let n=L(e,t,o.getState().conversationId??``),r=F.get(n);if(r||(r={blob:ee(e,t),objectUrl:null,refCount:0},F.set(n,r)),!r.objectUrl){let e=await r.blob;r.objectUrl=URL.createObjectURL(e)}return r.refCount+=1,r.objectUrl}function B(e,t){R();let n=L(e,t,o.getState().conversationId??``),r=F.get(n);r&&(r.refCount=Math.max(0,r.refCount-1),r.refCount===0&&r.objectUrl&&(URL.revokeObjectURL(r.objectUrl),r.objectUrl=null,F.delete(n)))}var V={noteId:null,attachmentId:null,playing:!1,currentTime:0,duration:0,loading:!1},H=null,U=null,W=null,G=null;function K(){return H||(H=new Audio,H.addEventListener(`timeupdate`,()=>{J.setState({currentTime:H.currentTime})}),H.addEventListener(`loadedmetadata`,()=>{let e=H.duration;Number.isFinite(e)&&J.setState({duration:e})}),H.addEventListener(`ended`,()=>{J.setState({playing:!1,currentTime:0}),H.currentTime=0}),H.addEventListener(`pause`,()=>{J.setState({playing:!1})}),H.addEventListener(`play`,()=>{J.setState({playing:!0})})),H}function q(){W&&G&&B(W,G),U=null,W=null,G=null}var J=c()((e,t)=>({...V,play:async(n,r,i)=>{let a=K(),o=t();if(o.noteId===n&&o.attachmentId===r&&U){a.play();return}a.pause(),q(),e({noteId:n,attachmentId:r,playing:!1,currentTime:0,duration:i??0,loading:!0});try{let t=await z(n,r);U=t,W=n,G=r,a.src=t,await a.play(),window.dispatchEvent(new CustomEvent(`xopc-voice-playback-start`,{detail:{id:`note:${n}:${r}`}})),e({loading:!1})}catch{e({loading:!1,playing:!1}),q()}},pause:()=>{K().pause()},toggle:(e,n,r)=>{let i=t();i.noteId===e&&i.attachmentId===n&&i.playing?t().pause():t().play(e,n,r)},seek:t=>{let n=K();n.currentTime=t,e({currentTime:t})},reset:()=>{K().pause(),K().src=``,q(),e(V)}}));function Y(e,t){return M(e,t)}function te(e){if(e<60)return`Voice · ${e}s`;let t=Math.floor(e/60),n=e%60;return`Voice · ${t}:${String(n).padStart(2,`0`)}`}async function ne(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:`HTTP ${e.status}`}async function X(e,t,n){let r=new Headers;n&&r.set(`Idempotency-Key`,n);let i=await fetch(e,{method:`POST`,headers:r,body:t});if(i.status===401&&o.getState().onUnauthorized(),!i.ok)throw Error(await ne(i));return i.json()}function re(e){let t=(0,S.c)(39),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({src:s,expectedNoteId:r,alt:c,className:n,onClick:i,onLoadFailed:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?``:c,u;t[8]!==r||t[9]!==s?(u=N(s,r),t[8]=r,t[9]=s,t[10]=u):u=t[10];let d=u,[f,p]=(0,C.useState)(d?null:s),[m,h]=(0,C.useState)(!1),g,_;if(t[11]!==a||t[12]!==d||t[13]!==s?(g=()=>{if(h(!1),!d){p(s);return}let e=!1;return p(null),z(d.noteId,d.attachmentId).then(t=>{e||p(t)}).catch(()=>{e||(h(!0),a?.())}),()=>{e=!0,B(d.noteId,d.attachmentId)}},_=[s,d,a],t[11]=a,t[12]=d,t[13]=s,t[14]=g,t[15]=_):(g=t[14],_=t[15]),(0,C.useEffect)(g,_),m){let e;t[16]===n?e=t[17]:(e=v(`flex items-center justify-center bg-surface-hover text-fg-muted`,n),t[16]=n,t[17]=e);let r=!l,i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,w.jsx)(x,{className:`size-5`}),t[18]=i):i=t[18];let a;return t[19]!==e||t[20]!==r?(a=(0,w.jsx)(`div`,{className:e,"aria-hidden":r,children:i}),t[19]=e,t[20]=r,t[21]=a):a=t[21],a}if(!f){let e;t[22]===n?e=t[23]:(e=v(`animate-pulse bg-surface-hover`,n),t[22]=n,t[23]=e);let r=!l,i;return t[24]!==e||t[25]!==r?(i=(0,w.jsx)(`div`,{className:e,"aria-hidden":r}),t[24]=e,t[25]=r,t[26]=i):i=t[26],i}let y;t[27]!==f||t[28]!==i?(y=i?()=>i(f):void 0,t[27]=f,t[28]=i,t[29]=y):y=t[29];let b;t[30]===a?b=t[31]:(b=()=>{h(!0),a?.()},t[30]=a,t[31]=b);let T;return t[32]!==l||t[33]!==n||t[34]!==f||t[35]!==o||t[36]!==y||t[37]!==b?(T=(0,w.jsx)(`img`,{...o,src:f,alt:l,className:n,onClick:y,onError:b}),t[32]=l,t[33]=n,t[34]=f,t[35]=o,t[36]=y,t[37]=b,t[38]=T):T=t[38],T}function ie(e){return e.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^)\s]+)/gi,`/api/notes/$1/media/$2`)}function ae(e,t){let n=[];return e.querySelectorAll(`.markdown-body img`).forEach(e=>{let r=N(e.getAttribute(`src`)??``,t);if(!r)return;let i=!1;z(r.noteId,r.attachmentId).then(t=>{i||(e.src=t)}).catch(()=>{e.classList.add(`note-media-load-failed`)}),n.push(()=>{i=!0,B(r.noteId,r.attachmentId)})}),e.querySelectorAll(`.markdown-body a`).forEach(e=>{let r=N(e.getAttribute(`href`)??``,t);if(!r)return;let i=document.createElement(`audio`);i.controls=!0,i.className=`note-media-audio mt-2 w-full max-w-md`,e.replaceWith(i);let a=!1;z(r.noteId,r.attachmentId).then(e=>{a||(i.src=e)}).catch(()=>{i.remove()}),n.push(()=>{a=!0,B(r.noteId,r.attachmentId)})}),()=>{for(let e of n)e()}}function oe(e){let t=(0,S.c)(21),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({content:n,noteId:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(0,C.useRef)(null),o;t[4]!==i.codeCopy||t[5]!==i.streaming?(o=e=>(0,w.jsx)(b,{source:e.source,incomplete:!e.closed,streaming:i.streaming??!1,copy:i.codeCopy??!0}),t[4]=i.codeCopy,t[5]=i.streaming,t[6]=o):o=t[6];let s=o,c;t[7]===r?c=t[8]:(c=()=>{let e=a.current;if(e)return ae(e,r)},t[7]=r,t[8]=c);let l;t[9]!==n||t[10]!==r?(l=[n,r],t[9]=n,t[10]=r,t[11]=l):l=t[11],(0,C.useLayoutEffect)(c,l);let u;t[12]===n?u=t[13]:(u=ie(n),t[12]=n,t[13]=u);let d;t[14]===i.className?d=t[15]:(d=[`markdown-note`,i.className].filter(Boolean),t[14]=i.className,t[15]=d);let f=d.join(` `),p;return t[16]!==s||t[17]!==i||t[18]!==u||t[19]!==f?(p=(0,w.jsx)(`div`,{ref:a,children:(0,w.jsx)(y,{children:(0,w.jsx)(g,{content:u,mermaidActions:!0,...i,renderChart:s,className:f})})}),t[16]=s,t[17]=i,t[18]=u,t[19]=f,t[20]=p):p=t[20],p}async function se(){return s(a(`/api/notes/project-summaries`))}async function ce(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.kind&&t.set(`kind`,e.kind),e.tag&&t.set(`tag`,e.tag),e.projectId&&t.set(`projectId`,e.projectId),e.unassigned&&t.set(`unassigned`,`true`),e.agentEdited&&t.set(`agentEdited`,`true`),e.pinned!==void 0&&t.set(`pinned`,String(e.pinned)),e.search&&t.set(`search`,e.search),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset)),e.sortBy&&t.set(`sortBy`,e.sortBy),e.sortOrder&&t.set(`sortOrder`,e.sortOrder);let n=t.toString();return s(a(`/api/notes${n?`?${n}`:``}`))}async function le(e,t=`web`){return(await s(a(`/api/notes/quick-capture`),{method:`POST`,body:JSON.stringify({text:e,channel:t})})).note}async function ue(e,t){return(await s(a(`/api/notes`),{method:`POST`,...t?{headers:{"Idempotency-Key":t}}:{},body:JSON.stringify({markdown:e.markdown,title:e.title,kind:e.kind,tags:e.tags,projectId:e.projectId,pinned:e.pinned,channel:e.channel??`web`})})).note}async function de(e){let t=await i(a(`/api/notes/${encodeURIComponent(e)}`));if(t.status===404)return null;let n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.note??null}async function Z(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).note}async function fe(e){await s(a(`/api/notes/${encodeURIComponent(e)}`),{method:`DELETE`})}async function pe(e){return s(a(`/api/notes/${encodeURIComponent(e)}/shares`))}async function me(e,t){return s(a(`/api/notes/${encodeURIComponent(e)}/shares`),{method:`POST`,body:JSON.stringify(t)})}async function he(e,t,n){await s(a(`/api/notes/${encodeURIComponent(e)}/shares/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})}async function ge(e){return(await s(a(`/api/notes/${encodeURIComponent(e)}/hosted-publications`))).payload.publications}async function _e(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/hosted-publications`),{method:`POST`,body:JSON.stringify(t)})).payload}async function ve(e,t,n){return(await s(a(`/api/notes/${encodeURIComponent(e)}/hosted-publications/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})).payload}async function ye(e){return s(a(`/api/notes/${encodeURIComponent(e)}/catalyze`),{method:`POST`})}async function be(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/catalysis-feedback`),{method:`POST`,body:JSON.stringify({feedback:t})})).note}async function xe(e,t={}){return s(a(`/api/notes/${encodeURIComponent(e)}/chat`),{method:`POST`,body:JSON.stringify(t)})}async function Se(e){return(await s(a(`/api/notes/${encodeURIComponent(e)}/threads`))).items}async function Ce(e){return s(a(`/api/notes/${encodeURIComponent(e)}/context-status`))}async function we(e){return s(a(`/api/notes/${encodeURIComponent(e)}/context-rebuild`),{method:`POST`})}async function Te(e,t,n){return(await s(a(`/api/notes/${encodeURIComponent(e)}/append`),{method:`POST`,body:JSON.stringify({content:t,heading:n})})).note}async function Q(e,t={}){return(await s(a(`/api/notes/task`),{method:`POST`,body:JSON.stringify({title:e,channel:`web`,priority:t.priority,sourceConversationId:t.sourceConversationId||void 0,sourceNoteId:t.sourceNoteId||void 0})})).note}async function Ee(e,t,n){let r=new FormData;return r.append(`file`,t),(await X(a(`/api/notes/${encodeURIComponent(e)}/media`),r,n)).attachment}async function $(e,t){let n=new FormData;return n.append(`file`,e),t?.markdown&&n.append(`markdown`,t.markdown),n.append(`channel`,t?.channel??`web`),t?.kind&&n.append(`kind`,t.kind),t?.duration!==void 0&&n.append(`duration`,String(t.duration)),(await X(a(`/api/notes`),n)).note}async function De(e,t=`web`){let n=await $(e,{channel:t}),r=n.attachments?.find(e=>e.type===`image`)??n.attachments?.[0];if(!r)return n;let i=`![${r.fileName}](${Y(n.id,r.id)})`;return n.markdown!==i&&(n=await Z(n.id,{markdown:i})),n}async function Oe(e,t,n=`web`){let r=await $(e,{channel:n,kind:`voice`,duration:t}),i=r.attachments?.find(e=>e.type===`audio`)??r.attachments?.[0];if(!i)return r;let a=`[${te(t)}](${Y(r.id,i.id)})`;return r.markdown!==a&&(r=await Z(r.id,{markdown:a,kind:`voice`})),r}async function ke(e){return(await s(a(`/api/notes/${encodeURIComponent(e)}/history`))).entries}async function Ae(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/history/${t}`))).snapshot}async function je(e,t){return(await s(a(`/api/notes/${encodeURIComponent(e)}/history/restore`),{method:`POST`,body:JSON.stringify({timestamp:t})})).note}export{Y as A,ve as C,Ee as D,Z as E,E as F,x as I,M,N,oe as O,O as P,be as S,je as T,xe as _,me as a,Oe as b,de as c,ge as d,ke as f,ce as g,Se as h,ue as i,J as j,re as k,Ce as l,pe as m,ye as n,Q as o,se as p,_e as r,fe as s,Te as t,Ae as u,le as v,he as w,we as x,De as y};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,l as a,m as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as c,l,n as u}from"./locale-store-B7y-RVe8.js";import{t as d}from"./messages-DYDkJvXj.js";import{t as f}from"./archive-Dz0hferG.js";import{C as p,T as m,c as h,s as g,u as _}from"./discussion-annotation-sync-BfVzIwe2.js";import{t as v}from"./arrow-left-D880xG-P.js";import{t as y}from"./arrow-right-DSSvoX71.js";import{t as ee}from"./arrow-up-D5ZtR1QT.js";import{f as b}from"./product-automation-feedback-BzY3z8zu.js";import{t as x}from"./calendar-days-hw_Y-g-s.js";import{t as te}from"./chevron-down-ccbiQQz_.js";import{t as ne}from"./popover-select-CEMWIrtY.js";import{t as re}from"./ellipsis-0k4rZLoy.js";import{t as ie}from"./file-text-D12HbeVy.js";import{t as ae}from"./folder-CN-pC3XL.js";import{A as S,D as C,E as w,_ as T,g as E,i as D,p as oe,s as se}from"./notes-api-ulup1oFS.js";import{b as ce,l as O,n as k,r as le,t as ue,v as A,y as de}from"./recording-upload-DBHAGKZj.js";import{t as fe}from"./loader-circle-CifKLtgG.js";import{z as pe}from"./markdown-view-DFHa8rUg.js";import{t as me}from"./mic-CuUb7zc-.js";import{t as he}from"./paperclip-f1HujQY1.js";import{t as ge}from"./plus-Q2yW6OE7.js";import{t as _e}from"./search-DA7gz22f.js";import{t as ve}from"./sparkles-DHlfQFAF.js";import{t as ye}from"./star-BUWJqJ5c.js";import{t as be}from"./trash-2-DusmjVPV.js";import{t as xe}from"./upload-rrb46c3c.js";import{t as j}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-BI5TyibZ.js";import{i as Se}from"./vendor-swr-CdRzEUwF.js";import{r as Ce}from"./app-chrome-BeB4KgOf.js";import{t as we}from"./page-header-store-CoKMiYoi.js";import{t as Te}from"./sliding-tab-list-DuQyViqe.js";import{n as Ee}from"./index.module-Cd9ENXfk.js";import{t as De}from"./confirm-dialog-D7dQJytv.js";import{l as Oe,m as ke,o as Ae,r as je,t as Me}from"./dist-ZrL34Ps4.js";import{i as Ne,t as P}from"./note-detail-panel-CJ-dPovd.js";var F=n(),I=e(t(),1),L=r();function R({projectId:e}){let t=u(e=>e.language)===`zh`,n=s(),r=(0,I.useRef)(null),i=(0,I.useRef)(null),[a,o]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[d,f]=(0,I.useState)(null);async function p(){let t=i.current;if(!(!t||a!==null)){o(0),l(null);try{let r=await _();if(r.consentAcknowledgedAt==null){f(r.consentPolicyVersion);return}let a=await ue(t.file,t.requestId),s=await h({clientRequestId:t.requestId,contextProjectId:e,source:`web`,consentPolicyVersion:r.consentPolicyVersion});t.discussionId=s.discussion.id,await O({...a,serverDiscussionId:s.discussion.id,projectId:e}),s.discussion.audioAttachmentId||await k(a,s.discussion.id,o),await le(t.requestId),i.current=null,n(`/notes/${encodeURIComponent(s.note.id)}`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(null)}}}return(0,L.jsxs)(`div`,{className:`inline-flex flex-wrap items-center gap-2 text-xs`,children:[(0,L.jsx)(`input`,{ref:r,hidden:!0,type:`file`,accept:`audio/*,.m4a,.wav,.mp3,.webm,.ogg`,onChange:e=>{let n=e.target.files?.[0];if(e.target.value=``,n){if(!n.size||n.size>1073741824){l(t?`音频须为 1 字节至 1 GiB`:`Audio must be between 1 byte and 1 GiB`);return}i.current={file:n,requestId:crypto.randomUUID()},p()}}}),(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md p-2 hover:bg-surface-hover`,disabled:a!==null,onClick:()=>c&&i.current?void p():r.current?.click(),children:[(0,L.jsx)(xe,{className:`size-3.5`}),a===null?c&&i.current?t?`重试导入`:`Retry import`:t?`导入录音`:`Import recording`:`${a}%`]}),d===null?null:(0,L.jsxs)(`span`,{children:[t?`请确认你有权上传此录音,并允许配置的语音服务处理。`:`Confirm permission to upload this recording and process it with your configured speech service.`,(0,L.jsx)(`button`,{type:`button`,className:`p-2 text-accent`,onClick:()=>void g(d).then(()=>(f(null),p())).catch(e=>l(String(e))),children:t?`确认导入`:`Confirm import`})]}),c?(0,L.jsx)(`span`,{role:`alert`,className:`text-danger`,children:c}):null]})}async function Pe(e){e.note??=await D({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await C(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${S(t,e.id)})`);e.note=await w(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,l as a,m as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{f as c,l,n as u}from"./locale-store-B6OrWgY1.js";import{t as d}from"./messages-jwdBhfL9.js";import{t as f}from"./archive-Dz0hferG.js";import{C as p,T as m,c as h,s as g,u as _}from"./discussion-annotation-sync-Dudoj_Fz.js";import{t as v}from"./arrow-left-D880xG-P.js";import{t as y}from"./arrow-right-DSSvoX71.js";import{t as ee}from"./arrow-up-D5ZtR1QT.js";import{f as b}from"./product-automation-feedback-DDQUsag7.js";import{t as x}from"./calendar-days-hw_Y-g-s.js";import{t as te}from"./chevron-down-ccbiQQz_.js";import{t as ne}from"./popover-select-CEMWIrtY.js";import{t as re}from"./ellipsis-0k4rZLoy.js";import{t as ie}from"./file-text-D12HbeVy.js";import{t as ae}from"./folder-CN-pC3XL.js";import{A as S,D as C,E as w,_ as T,g as E,i as D,p as oe,s as se}from"./notes-api-Ddsf7FVg.js";import{b as ce,l as O,n as k,r as le,t as ue,v as A,y as de}from"./recording-upload-C6muEHEO.js";import{t as fe}from"./loader-circle-CifKLtgG.js";import{z as pe}from"./markdown-view-DrhYZSmg.js";import{t as me}from"./mic-CuUb7zc-.js";import{t as he}from"./paperclip-f1HujQY1.js";import{t as ge}from"./plus-Q2yW6OE7.js";import{t as _e}from"./search-DA7gz22f.js";import{t as ve}from"./sparkles-DHlfQFAF.js";import{t as ye}from"./star-BUWJqJ5c.js";import{t as be}from"./trash-2-DusmjVPV.js";import{t as xe}from"./upload-rrb46c3c.js";import{t as j}from"./x-B_N4OPjy.js";import{t as M}from"./cn-0WouolD0.js";import{t as N}from"./skeleton-BI5TyibZ.js";import{i as Se}from"./vendor-swr-CdRzEUwF.js";import{r as Ce}from"./app-chrome-BeB4KgOf.js";import{t as we}from"./page-header-store-CEn_kPsn.js";import{t as Te}from"./sliding-tab-list-DuQyViqe.js";import{n as Ee}from"./index.module-Cd9ENXfk.js";import{t as De}from"./confirm-dialog-D7dQJytv.js";import{l as Oe,m as ke,o as Ae,r as je,t as Me}from"./dist-ZrL34Ps4.js";import{i as Ne,t as P}from"./note-detail-panel-Cl851ivY.js";var F=n(),I=e(t(),1),L=r();function R({projectId:e}){let t=u(e=>e.language)===`zh`,n=s(),r=(0,I.useRef)(null),i=(0,I.useRef)(null),[a,o]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[d,f]=(0,I.useState)(null);async function p(){let t=i.current;if(!(!t||a!==null)){o(0),l(null);try{let r=await _();if(r.consentAcknowledgedAt==null){f(r.consentPolicyVersion);return}let a=await ue(t.file,t.requestId),s=await h({clientRequestId:t.requestId,contextProjectId:e,source:`web`,consentPolicyVersion:r.consentPolicyVersion});t.discussionId=s.discussion.id,await O({...a,serverDiscussionId:s.discussion.id,projectId:e}),s.discussion.audioAttachmentId||await k(a,s.discussion.id,o),await le(t.requestId),i.current=null,n(`/notes/${encodeURIComponent(s.note.id)}`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{o(null)}}}return(0,L.jsxs)(`div`,{className:`inline-flex flex-wrap items-center gap-2 text-xs`,children:[(0,L.jsx)(`input`,{ref:r,hidden:!0,type:`file`,accept:`audio/*,.m4a,.wav,.mp3,.webm,.ogg`,onChange:e=>{let n=e.target.files?.[0];if(e.target.value=``,n){if(!n.size||n.size>1073741824){l(t?`音频须为 1 字节至 1 GiB`:`Audio must be between 1 byte and 1 GiB`);return}i.current={file:n,requestId:crypto.randomUUID()},p()}}}),(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md p-2 hover:bg-surface-hover`,disabled:a!==null,onClick:()=>c&&i.current?void p():r.current?.click(),children:[(0,L.jsx)(xe,{className:`size-3.5`}),a===null?c&&i.current?t?`重试导入`:`Retry import`:t?`导入录音`:`Import recording`:`${a}%`]}),d===null?null:(0,L.jsxs)(`span`,{children:[t?`请确认你有权上传此录音,并允许配置的语音服务处理。`:`Confirm permission to upload this recording and process it with your configured speech service.`,(0,L.jsx)(`button`,{type:`button`,className:`p-2 text-accent`,onClick:()=>void g(d).then(()=>(f(null),p())).catch(e=>l(String(e))),children:t?`确认导入`:`Confirm import`})]}),c?(0,L.jsx)(`span`,{role:`alert`,className:`text-danger`,children:c}):null]})}async function Pe(e){e.note??=await D({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await C(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${S(t,e.id)})`);e.note=await w(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
2
2
 
3
3
  `)}`})}return{noteId:t,conversationId:(await T(t,{projectId:e.projectId})).conversationId}}function Fe(e,t,n){let r=new URLSearchParams({draft:n.replace(`{{id}}`,t),autoSend:`1`});return`/chat/${encodeURIComponent(e)}?${r}`}var z={meeting:b,requirements:ie,research:A,weekly:x};function Ie({projects:e,projectId:t,onProjectChange:n,onCreated:r,labels:i,projectsLoading:a,projectsError:o}){let c=i.home,l=s(),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)([]),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(null),[re,ie]=(0,I.useState)(``),S=(0,I.useRef)(null),C=(0,I.useRef)(!1),w=(0,I.useRef)(null),T=(0,I.useRef)(null),E=v||!!S.current,D=f?c.templateOptions[f]:null,oe=!!(u.trim()||g.length);async function se(){if(!(C.current||!oe&&!S.current)){C.current=!0,y(!0),x(null),S.current??={requestId:crypto.randomUUID(),title:u.trim().split(`
4
4
  `)[0]?.slice(0,80)||D?.label||i.titlePlaceholder,markdown:`## ${c.requestHeading}\n\n${D?`${D.prompt}\n`:``}${u.trim()}`,projectId:t||void 0,files:[...g],attachments:[],materialHeading:c.materialsHeading};try{let e=await Pe(S.current);r(),l(Fe(e.conversationId,e.noteId,c.agentPrompt))}catch(e){S.current.note&&r(),x(e instanceof Error?e.message:i.quickCaptureFailedHint)}finally{C.current=!1,y(!1)}}}function ce(){S.current=null,x(null),d(``),_([]),p(null),h(!1),T.current?.focus()}return(0,L.jsxs)(`section`,{"aria-label":c.askLabel,children:[(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),se()},className:`relative rounded-xl border border-edge bg-surface-panel p-4 focus-within:border-accent/60 sm:p-5`,children:[(0,L.jsxs)(`fieldset`,{disabled:E,className:`min-w-0`,children:[(0,L.jsxs)(`label`,{htmlFor:`notes-home-prompt`,className:`flex items-center gap-2 text-xs font-medium text-accent-fg`,children:[(0,L.jsx)(ve,{className:`size-4`,"aria-hidden":!0}),c.askLabel]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:c.agentResultHint}),D?(0,L.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft px-3 py-2 text-xs leading-5 text-accent-fg`,children:[(0,L.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`span`,{className:`font-medium`,children:[D.label,` · `]}),D.prompt.split(`
@@ -1 +1 @@
1
- import{a as e,i as t}from"./locale-store-B7y-RVe8.js";import{n}from"./electron-env-DHOGevH3.js";function r(){if(!n())return;let e=window.location.hash.startsWith(`#/`)?window.location.hash.slice(1):`/`;return e.length<=2048?e:`/`}async function i(i){let a=await e(t(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:i,client:n()?`desktop`:`web`,returnPath:r()})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${a.status}`)}return(await a.json()).payload}async function a(n){let r=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}/status`));if(!r.ok)throw Error(`OAuth status: ${r.status}`);return(await r.json()).payload}async function o(n,r){let i=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}/code`),{method:`POST`,body:JSON.stringify({code:r})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${i.status}`)}}async function s(n){let r=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}/cancel`),{method:`POST`});if(!r.ok)throw Error(`Cancel OAuth failed: ${r.status}`)}async function c(n){let r=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}`),{method:`DELETE`});if(!r.ok)throw Error(`Cleanup session failed: ${r.status}`)}async function l(n){let r=await e(t(`/api/auth/oauth/${encodeURIComponent(n)}`),{method:`DELETE`});if(!r.ok)throw Error(`Revoke OAuth failed: ${r.status}`)}export{i as a,l as i,c as n,o,a as r,s as t};
1
+ import{a as e,i as t}from"./locale-store-B6OrWgY1.js";import{n}from"./electron-env-DHOGevH3.js";function r(){if(!n())return;let e=window.location.hash.startsWith(`#/`)?window.location.hash.slice(1):`/`;return e.length<=2048?e:`/`}async function i(i){let a=await e(t(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:i,client:n()?`desktop`:`web`,returnPath:r()})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${a.status}`)}return(await a.json()).payload}async function a(n){let r=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}/status`));if(!r.ok)throw Error(`OAuth status: ${r.status}`);return(await r.json()).payload}async function o(n,r){let i=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}/code`),{method:`POST`,body:JSON.stringify({code:r})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${i.status}`)}}async function s(n){let r=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}/cancel`),{method:`POST`});if(!r.ok)throw Error(`Cancel OAuth failed: ${r.status}`)}async function c(n){let r=await e(t(`/api/auth/oauth-async/${encodeURIComponent(n)}`),{method:`DELETE`});if(!r.ok)throw Error(`Cleanup session failed: ${r.status}`)}async function l(n){let r=await e(t(`/api/auth/oauth/${encodeURIComponent(n)}`),{method:`DELETE`});if(!r.ok)throw Error(`Revoke OAuth failed: ${r.status}`)}export{i as a,l as i,c as n,o,a as r,s as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-B7y-RVe8.js";import{t as i}from"./circle-check-C23XjkUj.js";import{t as a}from"./cloud-C4-yfnnk.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{a as s}from"./vendor-swr-CdRzEUwF.js";import{t as c}from"./button-Cc4hUNTt.js";import{n as l}from"./electron-env-DHOGevH3.js";import{i as u}from"./models-hub-cache-BUapaPTN.js";import{a as d,n as f,r as p}from"./oauth-api-DINa08-z.js";var m=e(t(),1),h=`xopc-onboarding-model-setup-dismissed`,g=`/api/models/cloud-onboarding`,_=n();function v({providerId:e,displayName:t,connected:n,onConnected:h}){let v=r(e=>e.language),{mutate:y}=s(),b=v===`zh`,[x,S]=(0,m.useState)(`idle`),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(null),D=(0,m.useRef)(!1),O=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{D.current=!0,O.current?.close(),O.current=null},[]);let k=async()=>{D.current=!1,w(null),E(null),S(`waiting`);let t=l();t||(O.current?.close(),O.current=window.open(`about:blank`,`xopc-oauth`),O.current&&(O.current.opener=null));let n=null,r=null;try{for(n=(await d(e)).sessionId;!D.current;){if(await new Promise(e=>window.setTimeout(e,1e3)),D.current)return;let i=await p(n);if(i.authUrl&&i.authUrl!==r)if(r=i.authUrl,E(i.authUrl),t){let e=await window.electronAPI?.shell?.openExternalUrl(i.authUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else O.current&&!O.current.closed&&O.current.location.replace(i.authUrl);if(i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){e===`xopc-cloud`&&await y(g),await u(),O.current?.close(),O.current=null,S(`connected`),h?.();return}}}catch(e){O.current?.close(),O.current=null,D.current||(S(`idle`),w(e instanceof Error?e.message:b?`连接失败`:`Connection failed`))}finally{n&&f(n).catch(()=>{})}},A=n||x===`connected`;return(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge bg-surface-inset p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,_.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-surface-active text-fg-muted`,children:(0,_.jsx)(a,{className:`size-5`,"aria-hidden":!0})}),(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),A?(0,_.jsx)(i,{className:`size-4 text-emerald-500`,"aria-label":b?`已连接`:`Connected`}):null]}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x===`waiting`?b?`请在浏览器中完成 OAuth 授权。`:`Complete OAuth authorization in your browser.`:A?b?`已通过 OAuth 连接。`:`Connected with OAuth.`:b?`使用 OAuth 连接,无需 API Key。`:`Connect with OAuth. No API key is required.`}),x===`waiting`&&T?(0,_.jsx)(`a`,{className:`mt-1 inline-flex text-sm text-accent hover:underline`,href:T,target:`_blank`,rel:`noreferrer`,children:b?`打开授权页面`:`Open authorization page`}):null,C?(0,_.jsx)(`p`,{className:`mt-1 text-sm text-danger`,children:C}):null]})]}),(0,_.jsxs)(c,{type:`button`,variant:A?`secondary`:`primary`,disabled:x===`waiting`,onClick:()=>void k(),children:[x===`waiting`?(0,_.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,x===`waiting`?b?`等待授权…`:`Waiting…`:A?b?`重新授权`:`Reauthorize`:b?`授权`:`Authorize`]})]})}export{g as n,h as r,v as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-B6OrWgY1.js";import{t as i}from"./circle-check-C23XjkUj.js";import{t as a}from"./cloud-C4-yfnnk.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{a as s}from"./vendor-swr-CdRzEUwF.js";import{t as c}from"./button-Cc4hUNTt.js";import{n as l}from"./electron-env-DHOGevH3.js";import{i as u}from"./models-hub-cache-BLcha5rx.js";import{a as d,n as f,r as p}from"./oauth-api-CMmu4DzH.js";var m=e(t(),1),h=`xopc-onboarding-model-setup-dismissed`,g=`/api/models/cloud-onboarding`,_=n();function v({providerId:e,displayName:t,connected:n,onConnected:h}){let v=r(e=>e.language),{mutate:y}=s(),b=v===`zh`,[x,S]=(0,m.useState)(`idle`),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(null),D=(0,m.useRef)(!1),O=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{D.current=!0,O.current?.close(),O.current=null},[]);let k=async()=>{D.current=!1,w(null),E(null),S(`waiting`);let t=l();t||(O.current?.close(),O.current=window.open(`about:blank`,`xopc-oauth`),O.current&&(O.current.opener=null));let n=null,r=null;try{for(n=(await d(e)).sessionId;!D.current;){if(await new Promise(e=>window.setTimeout(e,1e3)),D.current)return;let i=await p(n);if(i.authUrl&&i.authUrl!==r)if(r=i.authUrl,E(i.authUrl),t){let e=await window.electronAPI?.shell?.openExternalUrl(i.authUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else O.current&&!O.current.closed&&O.current.location.replace(i.authUrl);if(i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){e===`xopc-cloud`&&await y(g),await u(),O.current?.close(),O.current=null,S(`connected`),h?.();return}}}catch(e){O.current?.close(),O.current=null,D.current||(S(`idle`),w(e instanceof Error?e.message:b?`连接失败`:`Connection failed`))}finally{n&&f(n).catch(()=>{})}},A=n||x===`connected`;return(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge bg-surface-inset p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,_.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-surface-active text-fg-muted`,children:(0,_.jsx)(a,{className:`size-5`,"aria-hidden":!0})}),(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t}),A?(0,_.jsx)(i,{className:`size-4 text-emerald-500`,"aria-label":b?`已连接`:`Connected`}):null]}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x===`waiting`?b?`请在浏览器中完成 OAuth 授权。`:`Complete OAuth authorization in your browser.`:A?b?`已通过 OAuth 连接。`:`Connected with OAuth.`:b?`使用 OAuth 连接,无需 API Key。`:`Connect with OAuth. No API key is required.`}),x===`waiting`&&T?(0,_.jsx)(`a`,{className:`mt-1 inline-flex text-sm text-accent hover:underline`,href:T,target:`_blank`,rel:`noreferrer`,children:b?`打开授权页面`:`Open authorization page`}):null,C?(0,_.jsx)(`p`,{className:`mt-1 text-sm text-danger`,children:C}):null]})]}),(0,_.jsxs)(c,{type:`button`,variant:A?`secondary`:`primary`,disabled:x===`waiting`,onClick:()=>void k(),children:[x===`waiting`?(0,_.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,x===`waiting`?b?`等待授权…`:`Waiting…`:A?b?`重新授权`:`Reauthorize`:b?`授权`:`Authorize`]})]})}export{g as n,h as r,v as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{l as r,u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{l as a,n as o}from"./locale-store-B7y-RVe8.js";import{t as s}from"./messages-DYDkJvXj.js";import{t as c}from"./file-text-D12HbeVy.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./session-manager-DjRWxXJG.js";import{t as d}from"./capabilities-LC-yEQYo.js";import{n as f,t as p}from"./page-context-draft-DhRNxc0v.js";var m=e(t(),1),h=n();function g({resource:e,selection:t,label:n,disabled:g=!1}){let _=s(o(e=>e.language)).chat.pageContext,v=i(),y=r().key,[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),w=(0,m.useRef)(!1),T=(0,m.useRef)(0),E=a(e=>e.baseUrl),D=a(e=>e.conversationId);(0,m.useEffect)(()=>(w.current=!1,x(!1),C(!1),()=>{T.current+=1}),[y,e.kind,e.id,e.revision,t?.text,t?.draft,g,E,D]);async function O(){if(g||w.current)return;w.current=!0,x(!0),C(!1);let n=T.current,r=()=>T.current===n&&a.getState().baseUrl===E&&a.getState().conversationId===D;try{let n=f.capture({title:``,text:``,resourceRefs:[e],selection:t}),i=await d(`xopc.context.resolve`,n.envelope);if(!r())return;let a=i.resources[0];if(i.resources.length!==1||JSON.stringify(i.snapshot)!==JSON.stringify(n.envelope)||a.reference.kind!==e.kind||a.reference.id!==e.id||a.reference.revision!==e.revision)throw Error(`Context mismatch`);n.title=a.title,n.preview=a.text,n.truncated=a.truncated;let o=await new u().createSession();if(!r())return;if(!f.put(p(E,D,o.key),n))throw Error(`Context draft limit reached`);v(`/chat/${encodeURIComponent(o.key)}`)}catch{r()&&C(!0)}finally{T.current===n&&(w.current=!1,x(!1))}}return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,h.jsxs)(`button`,{type:`button`,disabled:g||b,onClick:()=>void O(),"aria-busy":b,title:g?_.unavailable:n??_.capture,className:`inline-flex min-h-9 items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[b?(0,h.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,h.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n??_.capture]}),S?(0,h.jsx)(`p`,{role:`alert`,className:`max-w-72 text-xs text-danger`,children:_.unavailable}):null]})}export{g as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{l as r,u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{l as a,n as o}from"./locale-store-B6OrWgY1.js";import{t as s}from"./messages-jwdBhfL9.js";import{t as c}from"./file-text-D12HbeVy.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./session-manager-X4UHOjjO.js";import{t as d}from"./capabilities-CoeuLRt6.js";import{n as f,t as p}from"./page-context-draft-BuNUerth.js";var m=e(t(),1),h=n();function g({resource:e,selection:t,label:n,disabled:g=!1}){let _=s(o(e=>e.language)).chat.pageContext,v=i(),y=r().key,[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),w=(0,m.useRef)(!1),T=(0,m.useRef)(0),E=a(e=>e.baseUrl),D=a(e=>e.conversationId);(0,m.useEffect)(()=>(w.current=!1,x(!1),C(!1),()=>{T.current+=1}),[y,e.kind,e.id,e.revision,t?.text,t?.draft,g,E,D]);async function O(){if(g||w.current)return;w.current=!0,x(!0),C(!1);let n=T.current,r=()=>T.current===n&&a.getState().baseUrl===E&&a.getState().conversationId===D;try{let n=f.capture({title:``,text:``,resourceRefs:[e],selection:t}),i=await d(`xopc.context.resolve`,n.envelope);if(!r())return;let a=i.resources[0];if(i.resources.length!==1||JSON.stringify(i.snapshot)!==JSON.stringify(n.envelope)||a.reference.kind!==e.kind||a.reference.id!==e.id||a.reference.revision!==e.revision)throw Error(`Context mismatch`);n.title=a.title,n.preview=a.text,n.truncated=a.truncated;let o=await new u().createSession();if(!r())return;if(!f.put(p(E,D,o.key),n))throw Error(`Context draft limit reached`);v(`/chat/${encodeURIComponent(o.key)}`)}catch{r()&&C(!0)}finally{T.current===n&&(w.current=!1,x(!1))}}return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,h.jsxs)(`button`,{type:`button`,disabled:g||b,onClick:()=>void O(),"aria-busy":b,title:g?_.unavailable:n??_.capture,className:`inline-flex min-h-9 items-center gap-1.5 rounded-lg border border-edge px-2.5 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[b?(0,h.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,h.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),n??_.capture]}),S?(0,h.jsx)(`p`,{role:`alert`,className:`max-w-72 text-xs text-danger`,children:_.unavailable}):null]})}export{g as t};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-B7y-RVe8.js";import{_ as t}from"./local-session-drafts-nRGeybku.js";function n(){let n=crypto.randomUUID(),r=crypto.randomUUID(),i=0,a=e(()=>({drafts:{}}));return{store:a,capture(e){return{envelope:t({version:1,clientInstanceId:n,tabId:r,sequence:++i,surface:`web`,capturedAt:Date.now(),resourceRefs:e.resourceRefs,selection:e.selection}),title:e.title,preview:e.text.slice(0,16e3),truncated:e.text.length>16e3}},put(e,t){let n=a.getState().drafts;return n[e]||Object.keys(n).length>=20?!1:(a.setState({drafts:{...n,[e]:structuredClone(t)}}),!0)},remove(e,t){let n=a.getState().drafts;if(n[e]!==t)return;let r={...n};delete r[e],a.setState({drafts:r})}}}var r=n();function i(e,t,n){return JSON.stringify([e,t??null,n])}export{r as n,i as t};
1
+ import{p as e}from"./locale-store-B6OrWgY1.js";import{_ as t}from"./local-session-drafts-DTq9776a.js";function n(){let n=crypto.randomUUID(),r=crypto.randomUUID(),i=0,a=e(()=>({drafts:{}}));return{store:a,capture(e){return{envelope:t({version:1,clientInstanceId:n,tabId:r,sequence:++i,surface:`web`,capturedAt:Date.now(),resourceRefs:e.resourceRefs,selection:e.selection}),title:e.title,preview:e.text.slice(0,16e3),truncated:e.text.length>16e3}},put(e,t){let n=a.getState().drafts;return n[e]||Object.keys(n).length>=20?!1:(a.setState({drafts:{...n,[e]:structuredClone(t)}}),!0)},remove(e,t){let n=a.getState().drafts;if(n[e]!==t)return;let r={...n};delete r[e],a.setState({drafts:r})}}}var r=n();function i(e,t,n){return JSON.stringify([e,t??null,n])}export{r as n,i as t};
@@ -0,0 +1 @@
1
+ import{p as e}from"./locale-store-B6OrWgY1.js";var t={startExtra:null,main:null,end:null},n=e(e=>({...t,setPageHeader:t=>e(t),clearPageHeader:()=>e(t)}));export{n as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./createLucideIcon-DPHK1VkS.js";import{t as r}from"./loopi-CNtmi9FU.js";import{t as i}from"./agent-avatar-display-D-yds6wG.js";var a=n(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),o=e(),s=t(),c={loopi:`idle`,"loopi-curious":`curious`,"loopi-care":`care`};function l(e){let t=(0,o.c)(8),{appearance:n,agentId:a,className:l}=e,u=l===void 0?``:l;if(n===`custom`&&a){let e;return t[0]!==a||t[1]!==u?(e=(0,s.jsx)(i,{agentId:a,avatar:`xopc:custom`,className:u}),t[0]=a,t[1]=u,t[2]=e):e=t[2],e}let d=n===`custom`?`idle`:c[n],f=`personal-avatar-motion inline-flex items-center justify-center ${u}`,p;t[3]===d?p=t[4]:(p=(0,s.jsx)(r,{variant:`avatar`,mood:d,className:`size-full`}),t[3]=d,t[4]=p);let m;return t[5]!==f||t[6]!==p?(m=(0,s.jsx)(`span`,{className:f,"aria-hidden":`true`,children:p}),t[5]=f,t[6]=p,t[7]=m):m=t[7],m}export{a as n,l as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./createLucideIcon-DPHK1VkS.js";import{t as r}from"./loopi-CNtmi9FU.js";import{t as i}from"./agent-avatar-display-BUH7ljEo.js";var a=n(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),o=e(),s=t(),c={loopi:`idle`,"loopi-curious":`curious`,"loopi-care":`care`};function l(e){let t=(0,o.c)(8),{appearance:n,agentId:a,className:l}=e,u=l===void 0?``:l;if(n===`custom`&&a){let e;return t[0]!==a||t[1]!==u?(e=(0,s.jsx)(i,{agentId:a,avatar:`xopc:custom`,className:u}),t[0]=a,t[1]=u,t[2]=e):e=t[2],e}let d=n===`custom`?`idle`:c[n],f=`personal-avatar-motion inline-flex items-center justify-center ${u}`,p;t[3]===d?p=t[4]:(p=(0,s.jsx)(r,{variant:`avatar`,mood:d,className:`size-full`}),t[3]=d,t[4]=p);let m;return t[5]!==f||t[6]!==p?(m=(0,s.jsx)(`span`,{className:f,"aria-hidden":`true`,children:p}),t[5]=f,t[6]=p,t[7]=m):m=t[7],m}export{a as n,l as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as a,n as o,o as s}from"./locale-store-B7y-RVe8.js";import{t as c}from"./messages-DYDkJvXj.js";import{t as l,v as u}from"./chat-page-e-xCsrdS.js";import{t as d}from"./arrow-left-D880xG-P.js";import{t as f}from"./arrow-right-DSSvoX71.js";import{t as p}from"./arrow-up-right-T72JbQ1Q.js";import{t as m}from"./check-DUBLcKHA.js";import{t as h}from"./popover-select-CEMWIrtY.js";import{t as g}from"./list-todo-CTVRto8O.js";import{F as _}from"./markdown-view-DFHa8rUg.js";import{n as v,s as y,t as b}from"./install-connector-dialog-DXVOHMhS.js";import{n as x,t as S}from"./personal-avatar-DiVFO2Aw.js";import{t as C}from"./play-kxZvpBg8.js";import{t as w}from"./settings-2-D-csvaET.js";import{t as ee}from"./square-DMK_fB-3.js";import{t as T}from"./upload-rrb46c3c.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./skeleton-BI5TyibZ.js";import{l as te}from"./voice-transcribe-api-Cb8i6dLb.js";import{T as O,d as k,t as A}from"./session-manager-DjRWxXJG.js";import{a as j,i as M,o as N,r as P,s as F,t as ne}from"./dist-GJ8-1PAx.js";import{a as re,r as ie}from"./connectors-api-B07yoCzk.js";import{n as ae}from"./voice-call-context-BM2A4bLz.js";import{t as oe}from"./page-header-store-CoKMiYoi.js";import{s as I}from"./agent-avatar-display-D-yds6wG.js";import{l as L,n as se,t as ce}from"./voice-config-api-LNO2xXHk.js";import{t as R}from"./date-formatters-DukWSVwc.js";var z=n(),B=e(t(),1),V=r(),H=[`intro`,`identity`,`voice`,`connections`],le=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function U(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function W(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await s(a(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),I(e)}function ue({modelsAvailable:e,onCreated:t}){let n=o(e=>e.language)===`zh`,r=o(e=>e.language),[l,u]=(0,B.useState)(`intro`),[p,h]=(0,B.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[g,_]=(0,B.useState)(!1),[x,w]=(0,B.useState)(!1),[ee,E]=(0,B.useState)(null),[O,k]=(0,B.useState)(null),[A,j]=(0,B.useState)(null),[M,N]=(0,B.useState)(null),[P,F]=(0,B.useState)(!0),[ne,ae]=(0,B.useState)([]),[oe,I]=(0,B.useState)(null),R=(0,B.useRef)(null),z=(0,B.useRef)(null),[ue,de]=(0,B.useState)([]),[G,fe]=(0,B.useState)(!0),[pe,K]=(0,B.useState)([]),[q,J]=(0,B.useState)(null);(0,B.useEffect)(()=>{let e=!1;return s(a(`/api/personal-agent/onboarding`)).then(t=>{e||(u(t.payload.step),h(t.payload.draft))}).catch(t=>{e||E(t instanceof Error?t.message:String(t))}).finally(()=>{e||_(!0)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!g)return;let e=window.setTimeout(()=>{s(a(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:l,draft:p})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[p,g,l]),(0,B.useEffect)(()=>{let e=!1;return ce().then(t=>{e||(t.tts&&t.enabled?N({provider:t.tts.provider,model:t.tts.model,enabled:!0}):F(!1))}).catch(()=>{e||F(!1)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!M?.enabled)return;let e=!1;return se(M.provider,M.model,`realtime`).then(t=>{e||ae(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||F(!1)}),()=>{e=!0}},[M]),(0,B.useEffect)(()=>{if(l!==`connections`)return;let e=!1;return fe(!0),Promise.allSettled([ie({page:1,pageSize:24,verification:`verified`}),re()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];de(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&K(n.value),fe(!1)}}),()=>{e=!0}},[l]),(0,B.useEffect)(()=>()=>{z.current?.abort(),R.current?.close()},[]),(0,B.useEffect)(()=>()=>{A&&URL.revokeObjectURL(A)},[A]);let me=async(e,t=p)=>{await s(a(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),u(e)},Y=async e=>{E(null);let t=H[Math.max(0,Math.min(H.length-1,H.indexOf(l)+e))];try{await me(t)}catch(e){E(e instanceof Error?e.message:String(e))}},he=async(n=!1)=>{if(!(!e||x)){w(!0),E(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:p,r=e.voice&&M?.enabled&&ne.some(t=>t.id===e.voice)?{provider:M.provider,model:M.model,voice:e.voice}:void 0,i=(await s(a(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,o=!1;if(!n&&O)try{await W(i.agentId,O),i=(await s(a(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`})})).payload}catch{o=!0}t(i,o)}catch(e){E(e instanceof Error?e.message:String(e))}finally{w(!1)}}},X=(0,B.useCallback)(async e=>{z.current?.abort(),R.current?.close();let t=new AbortController;z.current=t,I(e),E(null);try{let n=new te;R.current=n,await n.start();let r=await L(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>I(null))}catch(e){t.signal.aborted||E(e instanceof Error?e.message:String(e)),I(null)}},[]);if(!g)return(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,V.jsx)(D,{className:`h-10 w-2/3`}),(0,V.jsx)(D,{className:`h-64 w-full rounded-2xl`}),(0,V.jsx)(D,{className:`h-12 w-full rounded-xl`})]});let Z=H.indexOf(l),ge={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[l];return(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,V.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[Z>0?(0,V.jsxs)(`button`,{type:`button`,disabled:x,onClick:()=>void Y(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,V.jsx)(d,{className:`size-4`}),n?`上一步`:`Back`]}):(0,V.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,V.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,V.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":Z+1,"aria-valuemin":1,"aria-valuemax":H.length,children:H.map((e,t)=>(0,V.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=Z?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,V.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,V.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,V.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,V.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:A?(0,V.jsx)(`img`,{src:A,alt:``,className:`size-14 rounded-xl object-cover`}):(0,V.jsx)(S,{appearance:p.appearance,className:`size-14`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,V.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:p.displayName||`Ada`})]})]}),(0,V.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${Z+1} 步 · 共 ${H.length} 步`:`Step ${Z+1} of ${H.length}`}),(0,V.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:ge}),l===`intro`&&(0,V.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,V.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,V.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),l===`identity`&&(0,V.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,V.jsx)(`input`,{value:p.displayName,maxLength:60,onChange:e=>h(t=>({...t,displayName:e.target.value})),onBlur:()=>h(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[le.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":!O&&p.appearance===e.id,onClick:()=>{k(null),j(null),h(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!O&&p.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,V.jsx)(S,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,V.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${O?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,V.jsx)(T,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,V.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){E(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}k(t),j(URL.createObjectURL(t))}}})]})]}),(0,V.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),l===`voice`&&(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),P?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(D,{className:`h-20 rounded-xl`}),(0,V.jsx)(D,{className:`h-20 rounded-xl`})]}):M?.enabled&&ne.length>0?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-pressed":!p.voice,onClick:()=>h(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${p.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),ne.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${p.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":p.voice===e.id,onClick:()=>h(t=>({...t,voice:e.id})),children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void X(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,V.jsx)(C,{className:`size-4 ${oe===e.id?`text-accent`:``}`})})]},e.id))]}):(0,V.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,V.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),l===`connections`&&(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),G?(0,V.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,V.jsx)(D,{className:`h-18 rounded-xl`}),(0,V.jsx)(D,{className:`h-18 rounded-xl`})]}):(0,V.jsx)(`div`,{className:`mt-5 space-y-2`,children:ue.length?ue.map(e=>{let t=U(pe.find(t=>t.connectorId===e.id));return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,V.jsx)(v,{connector:e,size:`sm`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,V.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,V.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,V.jsx)(m,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,V.jsx)(`button`,{type:`button`,onClick:()=>J(y(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,V.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,V.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,V.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),ee&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:ee})]},l)}),(0,V.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,V.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[l===`intro`&&(0,V.jsx)(`button`,{type:`button`,disabled:!e||x,onClick:()=>void he(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),l===`voice`&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>{let e={...p,voice:null};h(e),E(null),me(`connections`,e).catch(e=>E(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,V.jsxs)(`button`,{type:`button`,disabled:x||l===`connections`&&!e,onClick:()=>l===`connections`?void he():void Y(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[x?n?`正在创建…`:`Creating…`:l===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!x&&(0,V.jsx)(f,{className:`size-4`})]})]})]})}),q&&(0,V.jsx)(b,{draft:q,onChange:J,onClose:()=>J(null),t:c(r).connectorsSettings,onInstalled:async()=>{K(await re()),J(null)}})]})}function de({record:e,zh:t,onSelectVoice:n,onGreetingChange:r}){let[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!0),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)([]),[g,_]=(0,B.useState)(e.voicePreference?.voice??``),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(null),[S,w]=(0,B.useState)(null),T=(0,B.useRef)(null),E=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await ce();if(e||(o(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};f(n);let r=await se(n.provider,n.model,`realtime`);e||m(r)}catch(t){e||x(t instanceof Error?t.message:String(t))}finally{e||c(!1)}})(),()=>{e=!0}},[]),(0,B.useEffect)(()=>()=>{E.current?.abort(),T.current?.close()},[]);let O=()=>{E.current?.abort(),E.current=null,T.current?.close(),T.current=null,w(null)},k=async e=>{if(S!==null){O();return}O(),x(null);let n=new AbortController;E.current=n,w(e);try{let t=new te;T.current=t,await t.start();let r=await L(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{E.current===n&&(w(null),E.current=null,T.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;x(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}E.current===n&&O()}},A=async e=>{if(v||e===g)return;O();let t=g;_(e),u(``),y(!0),x(null);try{await n(e&&d?{provider:d.provider,model:d.model,voice:e}:null)||_(t)}catch(e){_(t),x(e instanceof Error?e.message:String(e))}finally{y(!1)}},j=p.find(e=>e.id===g),M=t?`默认声音`:`Default voice`,N=j?.name||(g?t?`当前音色不可用`:`Current voice unavailable`:M),P=l.trim().toLocaleLowerCase(),F=p.filter(e=>!P||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(P)).map(e=>({value:e.id,label:e.name}));return(0,V.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),s?(0,V.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,V.jsx)(D,{className:`h-10 w-full`})}):d&&p.length?(0,V.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(h,{value:g,selectedLabel:N,options:F,placeholder:M,emptyLabel:M,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:v,onChange:e=>void A(e),searchPlaceholder:p.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:l,onSearchChange:u,statusMessage:P&&!F.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,V.jsxs)(`button`,{type:`button`,disabled:v||!!(g&&!j),onClick:()=>void k(g),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:S===null?t?`试听${N}`:`Preview ${N}`:t?`停止试听`:`Stop preview`,"aria-label":S===null?t?`试听${N}`:`Preview ${N}`:t?`停止试听`:`Stop preview`,children:[S===null?(0,V.jsx)(C,{className:`size-4`,"aria-hidden":!0}):(0,V.jsx)(ee,{className:`size-4 text-accent`,"aria-hidden":!0}),S===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:j?.description||j?.style||(g?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,V.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,V.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),r&&a&&(0,V.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`连接时打招呼`:`Greet me when connected`,(0,V.jsx)(`input`,{type:`checkbox`,checked:e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:v,onChange:e=>{let t=e.target.checked;y(!0),r(t).catch(e=>x(String(e))).finally(()=>y(!1))}})]}),b&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:b})]})}var G=new A;function fe({conversationId:e,zh:t,onSaved:n}){let r=O(t=>t.sessions[e]),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(``);(0,B.useEffect)(()=>{let t=!0;return G.loadSessionAgentConfig(e).then(n=>{t&&k(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function d(t,i){O.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{k(e,await G.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await G.loadSessionAgentConfig(e).catch(()=>null);throw n&&k(e,n),t}finally{O.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,V.jsx)(D,{className:`h-9 w-full`}):(0,V.jsx)(u,{chat:c(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:d,onThinkingChange:e=>d(r?.model??``,e)}),o&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var pe=5;function K(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function q(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function J(e){let t=(0,z.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=q(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,s;t[3]===n.id?s=t[4]:(s=_(`/personal`,n.id),t[3]=n.id,t[4]=s);let c=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,l;t[5]===c?l=t[6]:(l=(0,V.jsx)(`span`,{className:c,"aria-hidden":!0}),t[5]=c,t[6]=l);let u;t[7]===n.title?u=t[8]:(u=K(n.title),t[7]=n.title,t[8]=u);let d;t[9]===u?d=t[10]:(d=(0,V.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:u}),t[9]=u,t[10]=d);let f;t[11]===o.label?f=t[12]:(f=(0,V.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=f);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,V.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=R(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let v;t[17]===g?v=t[18]:(v=(0,V.jsx)(`span`,{children:g}),t[17]=g,t[18]=v);let y;t[19]!==v||t[20]!==f?(y=(0,V.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[f,m,v]}),t[19]=v,t[20]=f,t[21]=y):y=t[21];let b;t[22]!==y||t[23]!==d?(b=(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,y]}),t[22]=y,t[23]=d,t[24]=b):b=t[24];let x;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,V.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=x):x=t[25];let S;return t[26]!==b||t[27]!==s||t[28]!==l?(S=(0,V.jsxs)(i,{to:s,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[l,b,x]}),t[26]=b,t[27]=s,t[28]=l,t[29]=S):S=t[29],S}var me=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function Y(){let e=ae(),t=(0,B.useRef)(e);t.current=e;let n=o(e=>e.language)===`zh`,r=oe(e=>e.setPageHeader),i=oe(e=>e.clearPageHeader),[c,u]=(0,B.useState)(null),d=(0,B.useRef)(null),f=(0,B.useRef)(Promise.resolve()),[p,m]=(0,B.useState)([]),[h,_]=(0,B.useState)(!0),[v,y]=(0,B.useState)(0),[b,C]=(0,B.useState)(null),[ee,te]=(0,B.useState)(!1),[O,k]=(0,B.useState)(`loopi`),[A,re]=(0,B.useState)(!1),ie=(0,B.useRef)(null),L=(0,B.useRef)(null),se=(0,B.useRef)(null),[ce,R]=(0,B.useState)(``),[z,H]=(0,B.useState)(!1),[le,U]=(0,B.useState)(!1),[W,G]=(0,B.useState)(!1),[K,q]=(0,B.useState)(null),[Y,he]=(0,B.useState)(!1),[X,Z]=(0,B.useState)(!1),[ge,_e]=(0,B.useState)(!1),[Q,ve]=(0,B.useState)(0),$=(0,B.useRef)(0),ye=(0,B.useCallback)(()=>{G(!1),U(!1),H(!0)},[]),be=(0,B.useCallback)(()=>{G(!1),U(!1),H(e=>!e)},[]),xe=(0,B.useCallback)(async()=>{try{let[e,t]=await Promise.all([s(a(`/api/personal-agent`)),s(a(`/api/personal-agent/models`))]);d.current=e.payload,u(e.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),m(t.payload),e.payload&&(R(e.payload.displayName),k(e.payload.appearance))}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(!1)}},[]);(0,B.useEffect)(()=>{xe()},[xe]);let Se=(0,B.useCallback)(e=>{y(e=>e+1),C(null);let t=f.current.then(async()=>{let t=d.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.voicePreference)&&(!e.voiceCallPreferences||JSON.stringify(e.voiceCallPreferences)===JSON.stringify(t.voiceCallPreferences)))return!0;try{let o=await s(a(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,...e.voicePreference===void 0?{}:{voicePreference:i},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return d.current=o.payload,u(o.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:o.payload})),!0}catch(e){return C(e instanceof Error?e.message:String(e)),!1}}).finally(()=>y(e=>e-1));return f.current=t,t},[]),Ce=(0,B.useCallback)(async()=>{let e=++$.current;G(!0),q(null),he(!1),Z(!1),_e(!1),ve(0);try{let t=await s(a(`/api/personal-agent/activity?limit=${pe}&offset=0`));if(e!==$.current)return;q(t.payload),ve(t.payload.items.length)}catch{e===$.current&&he(!0)}},[]),we=(0,B.useCallback)(async()=>{if(!K||X||Q>=K.total)return;let e=$.current;Z(!0),_e(!1);try{let t=await s(a(`/api/personal-agent/activity?limit=${pe}&offset=${Q}`));if(e!==$.current)return;q(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),ve(e=>e+t.payload.items.length)}catch{e===$.current&&_e(!0)}finally{e===$.current&&Z(!1)}},[K,Q,X]);(0,B.useEffect)(()=>{if(!W||!K||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=$.current;try{let t=await s(a(`/api/personal-agent/activity?limit=${Math.max(pe,Math.min(100,Q))}&offset=0`));if(e!==$.current)return;q(t.payload),ve(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[K,Q,X,W]);let Te=async e=>{if(!c||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){C(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){C(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}re(!0),C(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await s(a(`/api/agents/${encodeURIComponent(c.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),I(c.agentId),k(`custom`),U(!1),await Se({appearance:`custom`})}catch(e){C(e instanceof Error?e.message:String(e))}finally{re(!1)}};(0,B.useLayoutEffect)(()=>{let a=c?.state===`ready`,o=a?c.appearance:O,s=a?c.displayName:`Ada`;return r({startExtra:null,main:(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[a?(0,V.jsx)(`button`,{ref:se,type:`button`,onClick:be,"aria-expanded":z,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${s}的资料`:`Edit ${s}'s profile`,title:n?`资料`:`Profile`,children:(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,V.jsx)(S,{appearance:o,agentId:c?.agentId,className:`size-8`})})}):(0,V.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,V.jsx)(S,{appearance:o,agentId:c?.agentId,className:`size-8`})}),(0,V.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:s})]}),end:a?(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{c?.state===`ready`&&t.current.open({conversationId:c.conversationId,name:c.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,V.jsx)(x,{className:`size-5`})}),(0,V.jsxs)(N,{open:W,onOpenChange:e=>{e?Ce():G(!1)},children:[(0,V.jsx)(F,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-pressed":W,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,V.jsx)(g,{className:`size-5`})})}),(0,V.jsx)(j,{children:(0,V.jsxs)(M,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(22rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl focus:outline-none`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:K?n?`最近更新 · 共 ${K.total} 项`:`Recently updated · ${K.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,V.jsx)(P,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,V.jsx)(E,{className:`size-4`})})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!K&&!Y&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(D,{className:`h-18 rounded-2xl`}),(0,V.jsx)(D,{className:`h-18 rounded-2xl`}),(0,V.jsx)(D,{className:`h-18 rounded-2xl`})]}),Y&&(0,V.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void Ce(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),K?.items.length===0&&(0,V.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,V.jsx)(g,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,V.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),K&&K.items.length>0&&(0,V.jsx)(`div`,{className:`space-y-2`,children:K.items.map(e=>(0,V.jsx)(J,{item:e,zh:n},e.id))}),K&&Q<K.total&&(0,V.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>void we(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),ge&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,V.jsx)(`button`,{ref:L,type:`button`,onClick:be,"aria-expanded":z,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`编辑资料`:`Edit profile`,children:(0,V.jsx)(w,{className:`size-5`})})]}):null}),()=>i()},[K,Y,Q,X,ge,O,i,we,Ce,c,r,W,z,be,e.active,n]);function Ee(){return c?(0,V.jsxs)(N,{open:z,onOpenChange:e=>{H(e),e||U(!1)},children:[(0,V.jsx)(ne,{virtualRef:L}),(0,V.jsx)(j,{children:(0,V.jsxs)(M,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(L.current?.contains(e.target)||se.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex w-[min(22rem,calc(100vw-1rem))] flex-col rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,V.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-4 pt-4 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>U(e=>!e),"aria-expanded":le,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,V.jsx)(S,{appearance:O,agentId:c.agentId,className:`size-16`})}),(0,V.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:ce,onChange:e=>R(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(R(t),Se({displayName:t})):R(d.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=d.current?.displayName??``,R(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-2 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),v>0&&(0,V.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,V.jsxs)(`div`,{className:`space-y-4 px-4 py-4`,children:[b&&(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:b}),le&&(0,V.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[me.map(e=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{k(e.id),U(!1),Se({appearance:e.id})},"aria-pressed":O===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${O===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,V.jsx)(S,{appearance:e.id,className:`size-8`})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,V.jsx)(`input`,{ref:ie,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&Te(t),e.currentTarget.value=``}}),(0,V.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>ie.current?.click(),"aria-pressed":O===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${O===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:O===`custom`?(0,V.jsx)(S,{appearance:`custom`,agentId:c.agentId,className:`size-8`}):(0,V.jsx)(T,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:A?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,V.jsx)(de,{onGreetingChange:e=>Se({voiceCallPreferences:{openingGreetingEnabled:e}}),record:c,zh:n,onSelectVoice:e=>Se({voicePreference:e})}),(0,V.jsx)(`div`,{className:`border-t border-edge pt-4`,children:(0,V.jsx)(fe,{conversationId:c.conversationId,zh:n,onSaved:async()=>{let e=await s(a(`/api/personal-agent`));e.ok&&e.payload&&(d.current=e.payload,u(e.payload))}})})]})]})})]}):null}return h?(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,V.jsx)(D,{className:`h-20 w-20 rounded-full`}),(0,V.jsx)(D,{className:`h-9 w-72`}),(0,V.jsx)(D,{className:`h-44 w-full rounded-2xl`})]}):c?.state===`ready`?(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ee&&(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,V.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{te(!1),ye()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(l,{embedded:!0,personal:!0,personalWelcome:{name:c.displayName,addressAs:c.userCallName??void 0,avatar:(0,V.jsx)(S,{appearance:c.appearance,agentId:c.agentId,className:`size-14`}),opening:n?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`},conversationId:c.conversationId})})}),Ee()]}):(0,V.jsx)(ue,{modelsAvailable:p.length>0,onCreated:(e,t)=>{d.current=e,u(e),R(e.displayName),te(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{Y as PersonalPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as a,n as o,o as s}from"./locale-store-B6OrWgY1.js";import{t as c}from"./messages-jwdBhfL9.js";import{t as l,v as u}from"./chat-page-CwP4OMdW.js";import{t as d}from"./arrow-left-D880xG-P.js";import{t as f}from"./arrow-right-DSSvoX71.js";import{t as p}from"./arrow-up-right-T72JbQ1Q.js";import{t as m}from"./check-DUBLcKHA.js";import{t as h}from"./popover-select-CEMWIrtY.js";import{t as g}from"./list-todo-CTVRto8O.js";import{F as _}from"./markdown-view-DrhYZSmg.js";import{n as v,s as y,t as b}from"./install-connector-dialog-Cn4nRSyt.js";import{n as x,t as S}from"./personal-avatar-B49ueeZO.js";import{t as C}from"./play-kxZvpBg8.js";import{t as w}from"./settings-2-D-csvaET.js";import{t as ee}from"./square-DMK_fB-3.js";import{t as T}from"./upload-rrb46c3c.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./skeleton-BI5TyibZ.js";import{l as te}from"./voice-transcribe-api-CVEcB6Pe.js";import{T as O,d as k,t as A}from"./session-manager-X4UHOjjO.js";import{a as j,i as M,o as N,r as P,s as F,t as ne}from"./dist-GJ8-1PAx.js";import{a as re,r as ie}from"./connectors-api-DtvB9Cjm.js";import{n as ae}from"./voice-call-context-BM2A4bLz.js";import{t as oe}from"./page-header-store-CEn_kPsn.js";import{s as I}from"./agent-avatar-display-BUH7ljEo.js";import{l as L,n as se,t as ce}from"./voice-config-api-MHe5Pn-A.js";import{t as R}from"./date-formatters-DukWSVwc.js";var z=n(),B=e(t(),1),V=r(),H=[`intro`,`identity`,`voice`,`connections`],le=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function U(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function W(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await s(a(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),I(e)}function ue({modelsAvailable:e,onCreated:t}){let n=o(e=>e.language)===`zh`,r=o(e=>e.language),[l,u]=(0,B.useState)(`intro`),[p,h]=(0,B.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[g,_]=(0,B.useState)(!1),[x,w]=(0,B.useState)(!1),[ee,E]=(0,B.useState)(null),[O,k]=(0,B.useState)(null),[A,j]=(0,B.useState)(null),[M,N]=(0,B.useState)(null),[P,F]=(0,B.useState)(!0),[ne,ae]=(0,B.useState)([]),[oe,I]=(0,B.useState)(null),R=(0,B.useRef)(null),z=(0,B.useRef)(null),[ue,de]=(0,B.useState)([]),[G,fe]=(0,B.useState)(!0),[pe,K]=(0,B.useState)([]),[q,J]=(0,B.useState)(null);(0,B.useEffect)(()=>{let e=!1;return s(a(`/api/personal-agent/onboarding`)).then(t=>{e||(u(t.payload.step),h(t.payload.draft))}).catch(t=>{e||E(t instanceof Error?t.message:String(t))}).finally(()=>{e||_(!0)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!g)return;let e=window.setTimeout(()=>{s(a(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:l,draft:p})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[p,g,l]),(0,B.useEffect)(()=>{let e=!1;return ce().then(t=>{e||(t.tts&&t.enabled?N({provider:t.tts.provider,model:t.tts.model,enabled:!0}):F(!1))}).catch(()=>{e||F(!1)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!M?.enabled)return;let e=!1;return se(M.provider,M.model,`realtime`).then(t=>{e||ae(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||F(!1)}),()=>{e=!0}},[M]),(0,B.useEffect)(()=>{if(l!==`connections`)return;let e=!1;return fe(!0),Promise.allSettled([ie({page:1,pageSize:24,verification:`verified`}),re()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];de(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&K(n.value),fe(!1)}}),()=>{e=!0}},[l]),(0,B.useEffect)(()=>()=>{z.current?.abort(),R.current?.close()},[]),(0,B.useEffect)(()=>()=>{A&&URL.revokeObjectURL(A)},[A]);let me=async(e,t=p)=>{await s(a(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),u(e)},Y=async e=>{E(null);let t=H[Math.max(0,Math.min(H.length-1,H.indexOf(l)+e))];try{await me(t)}catch(e){E(e instanceof Error?e.message:String(e))}},he=async(n=!1)=>{if(!(!e||x)){w(!0),E(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:p,r=e.voice&&M?.enabled&&ne.some(t=>t.id===e.voice)?{provider:M.provider,model:M.model,voice:e.voice}:void 0,i=(await s(a(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,o=!1;if(!n&&O)try{await W(i.agentId,O),i=(await s(a(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`})})).payload}catch{o=!0}t(i,o)}catch(e){E(e instanceof Error?e.message:String(e))}finally{w(!1)}}},X=(0,B.useCallback)(async e=>{z.current?.abort(),R.current?.close();let t=new AbortController;z.current=t,I(e),E(null);try{let n=new te;R.current=n,await n.start();let r=await L(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>I(null))}catch(e){t.signal.aborted||E(e instanceof Error?e.message:String(e)),I(null)}},[]);if(!g)return(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,V.jsx)(D,{className:`h-10 w-2/3`}),(0,V.jsx)(D,{className:`h-64 w-full rounded-2xl`}),(0,V.jsx)(D,{className:`h-12 w-full rounded-xl`})]});let Z=H.indexOf(l),ge={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[l];return(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,V.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[Z>0?(0,V.jsxs)(`button`,{type:`button`,disabled:x,onClick:()=>void Y(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,V.jsx)(d,{className:`size-4`}),n?`上一步`:`Back`]}):(0,V.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,V.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,V.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":Z+1,"aria-valuemin":1,"aria-valuemax":H.length,children:H.map((e,t)=>(0,V.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=Z?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,V.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,V.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,V.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,V.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:A?(0,V.jsx)(`img`,{src:A,alt:``,className:`size-14 rounded-xl object-cover`}):(0,V.jsx)(S,{appearance:p.appearance,className:`size-14`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,V.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:p.displayName||`Ada`})]})]}),(0,V.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${Z+1} 步 · 共 ${H.length} 步`:`Step ${Z+1} of ${H.length}`}),(0,V.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:ge}),l===`intro`&&(0,V.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,V.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,V.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),l===`identity`&&(0,V.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,V.jsx)(`input`,{value:p.displayName,maxLength:60,onChange:e=>h(t=>({...t,displayName:e.target.value})),onBlur:()=>h(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[le.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":!O&&p.appearance===e.id,onClick:()=>{k(null),j(null),h(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!O&&p.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,V.jsx)(S,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,V.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${O?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,V.jsx)(T,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,V.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){E(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}k(t),j(URL.createObjectURL(t))}}})]})]}),(0,V.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),l===`voice`&&(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),P?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(D,{className:`h-20 rounded-xl`}),(0,V.jsx)(D,{className:`h-20 rounded-xl`})]}):M?.enabled&&ne.length>0?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-pressed":!p.voice,onClick:()=>h(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${p.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),ne.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${p.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":p.voice===e.id,onClick:()=>h(t=>({...t,voice:e.id})),children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void X(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,V.jsx)(C,{className:`size-4 ${oe===e.id?`text-accent`:``}`})})]},e.id))]}):(0,V.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,V.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),l===`connections`&&(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),G?(0,V.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,V.jsx)(D,{className:`h-18 rounded-xl`}),(0,V.jsx)(D,{className:`h-18 rounded-xl`})]}):(0,V.jsx)(`div`,{className:`mt-5 space-y-2`,children:ue.length?ue.map(e=>{let t=U(pe.find(t=>t.connectorId===e.id));return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,V.jsx)(v,{connector:e,size:`sm`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,V.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,V.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,V.jsx)(m,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,V.jsx)(`button`,{type:`button`,onClick:()=>J(y(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,V.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,V.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,V.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),ee&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:ee})]},l)}),(0,V.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,V.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[l===`intro`&&(0,V.jsx)(`button`,{type:`button`,disabled:!e||x,onClick:()=>void he(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),l===`voice`&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>{let e={...p,voice:null};h(e),E(null),me(`connections`,e).catch(e=>E(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,V.jsxs)(`button`,{type:`button`,disabled:x||l===`connections`&&!e,onClick:()=>l===`connections`?void he():void Y(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[x?n?`正在创建…`:`Creating…`:l===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!x&&(0,V.jsx)(f,{className:`size-4`})]})]})]})}),q&&(0,V.jsx)(b,{draft:q,onChange:J,onClose:()=>J(null),t:c(r).connectorsSettings,onInstalled:async()=>{K(await re()),J(null)}})]})}function de({record:e,zh:t,onSelectVoice:n,onGreetingChange:r}){let[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!0),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)([]),[g,_]=(0,B.useState)(e.voicePreference?.voice??``),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(null),[S,w]=(0,B.useState)(null),T=(0,B.useRef)(null),E=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await ce();if(e||(o(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};f(n);let r=await se(n.provider,n.model,`realtime`);e||m(r)}catch(t){e||x(t instanceof Error?t.message:String(t))}finally{e||c(!1)}})(),()=>{e=!0}},[]),(0,B.useEffect)(()=>()=>{E.current?.abort(),T.current?.close()},[]);let O=()=>{E.current?.abort(),E.current=null,T.current?.close(),T.current=null,w(null)},k=async e=>{if(S!==null){O();return}O(),x(null);let n=new AbortController;E.current=n,w(e);try{let t=new te;T.current=t,await t.start();let r=await L(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{E.current===n&&(w(null),E.current=null,T.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;x(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}E.current===n&&O()}},A=async e=>{if(v||e===g)return;O();let t=g;_(e),u(``),y(!0),x(null);try{await n(e&&d?{provider:d.provider,model:d.model,voice:e}:null)||_(t)}catch(e){_(t),x(e instanceof Error?e.message:String(e))}finally{y(!1)}},j=p.find(e=>e.id===g),M=t?`默认声音`:`Default voice`,N=j?.name||(g?t?`当前音色不可用`:`Current voice unavailable`:M),P=l.trim().toLocaleLowerCase(),F=p.filter(e=>!P||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(P)).map(e=>({value:e.id,label:e.name}));return(0,V.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),s?(0,V.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,V.jsx)(D,{className:`h-10 w-full`})}):d&&p.length?(0,V.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(h,{value:g,selectedLabel:N,options:F,placeholder:M,emptyLabel:M,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:v,onChange:e=>void A(e),searchPlaceholder:p.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:l,onSearchChange:u,statusMessage:P&&!F.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,V.jsxs)(`button`,{type:`button`,disabled:v||!!(g&&!j),onClick:()=>void k(g),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:S===null?t?`试听${N}`:`Preview ${N}`:t?`停止试听`:`Stop preview`,"aria-label":S===null?t?`试听${N}`:`Preview ${N}`:t?`停止试听`:`Stop preview`,children:[S===null?(0,V.jsx)(C,{className:`size-4`,"aria-hidden":!0}):(0,V.jsx)(ee,{className:`size-4 text-accent`,"aria-hidden":!0}),S===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:j?.description||j?.style||(g?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,V.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,V.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),r&&a&&(0,V.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`连接时打招呼`:`Greet me when connected`,(0,V.jsx)(`input`,{type:`checkbox`,checked:e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:v,onChange:e=>{let t=e.target.checked;y(!0),r(t).catch(e=>x(String(e))).finally(()=>y(!1))}})]}),b&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:b})]})}var G=new A;function fe({conversationId:e,zh:t,onSaved:n}){let r=O(t=>t.sessions[e]),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(``);(0,B.useEffect)(()=>{let t=!0;return G.loadSessionAgentConfig(e).then(n=>{t&&k(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function d(t,i){O.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{k(e,await G.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await G.loadSessionAgentConfig(e).catch(()=>null);throw n&&k(e,n),t}finally{O.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,V.jsx)(D,{className:`h-9 w-full`}):(0,V.jsx)(u,{chat:c(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:d,onThinkingChange:e=>d(r?.model??``,e)}),o&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var pe=5;function K(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function q(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function J(e){let t=(0,z.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=q(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,s;t[3]===n.id?s=t[4]:(s=_(`/personal`,n.id),t[3]=n.id,t[4]=s);let c=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,l;t[5]===c?l=t[6]:(l=(0,V.jsx)(`span`,{className:c,"aria-hidden":!0}),t[5]=c,t[6]=l);let u;t[7]===n.title?u=t[8]:(u=K(n.title),t[7]=n.title,t[8]=u);let d;t[9]===u?d=t[10]:(d=(0,V.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:u}),t[9]=u,t[10]=d);let f;t[11]===o.label?f=t[12]:(f=(0,V.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=f);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,V.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=R(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let v;t[17]===g?v=t[18]:(v=(0,V.jsx)(`span`,{children:g}),t[17]=g,t[18]=v);let y;t[19]!==v||t[20]!==f?(y=(0,V.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[f,m,v]}),t[19]=v,t[20]=f,t[21]=y):y=t[21];let b;t[22]!==y||t[23]!==d?(b=(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,y]}),t[22]=y,t[23]=d,t[24]=b):b=t[24];let x;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,V.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=x):x=t[25];let S;return t[26]!==b||t[27]!==s||t[28]!==l?(S=(0,V.jsxs)(i,{to:s,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[l,b,x]}),t[26]=b,t[27]=s,t[28]=l,t[29]=S):S=t[29],S}var me=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function Y(){let e=ae(),t=(0,B.useRef)(e);t.current=e;let n=o(e=>e.language)===`zh`,r=oe(e=>e.setPageHeader),i=oe(e=>e.clearPageHeader),[c,u]=(0,B.useState)(null),d=(0,B.useRef)(null),f=(0,B.useRef)(Promise.resolve()),[p,m]=(0,B.useState)([]),[h,_]=(0,B.useState)(!0),[v,y]=(0,B.useState)(0),[b,C]=(0,B.useState)(null),[ee,te]=(0,B.useState)(!1),[O,k]=(0,B.useState)(`loopi`),[A,re]=(0,B.useState)(!1),ie=(0,B.useRef)(null),L=(0,B.useRef)(null),se=(0,B.useRef)(null),[ce,R]=(0,B.useState)(``),[z,H]=(0,B.useState)(!1),[le,U]=(0,B.useState)(!1),[W,G]=(0,B.useState)(!1),[K,q]=(0,B.useState)(null),[Y,he]=(0,B.useState)(!1),[X,Z]=(0,B.useState)(!1),[ge,_e]=(0,B.useState)(!1),[Q,ve]=(0,B.useState)(0),$=(0,B.useRef)(0),ye=(0,B.useCallback)(()=>{G(!1),U(!1),H(!0)},[]),be=(0,B.useCallback)(()=>{G(!1),U(!1),H(e=>!e)},[]),xe=(0,B.useCallback)(async()=>{try{let[e,t]=await Promise.all([s(a(`/api/personal-agent`)),s(a(`/api/personal-agent/models`))]);d.current=e.payload,u(e.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),m(t.payload),e.payload&&(R(e.payload.displayName),k(e.payload.appearance))}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(!1)}},[]);(0,B.useEffect)(()=>{xe()},[xe]);let Se=(0,B.useCallback)(e=>{y(e=>e+1),C(null);let t=f.current.then(async()=>{let t=d.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.voicePreference)&&(!e.voiceCallPreferences||JSON.stringify(e.voiceCallPreferences)===JSON.stringify(t.voiceCallPreferences)))return!0;try{let o=await s(a(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,...e.voicePreference===void 0?{}:{voicePreference:i},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return d.current=o.payload,u(o.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:o.payload})),!0}catch(e){return C(e instanceof Error?e.message:String(e)),!1}}).finally(()=>y(e=>e-1));return f.current=t,t},[]),Ce=(0,B.useCallback)(async()=>{let e=++$.current;G(!0),q(null),he(!1),Z(!1),_e(!1),ve(0);try{let t=await s(a(`/api/personal-agent/activity?limit=${pe}&offset=0`));if(e!==$.current)return;q(t.payload),ve(t.payload.items.length)}catch{e===$.current&&he(!0)}},[]),we=(0,B.useCallback)(async()=>{if(!K||X||Q>=K.total)return;let e=$.current;Z(!0),_e(!1);try{let t=await s(a(`/api/personal-agent/activity?limit=${pe}&offset=${Q}`));if(e!==$.current)return;q(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),ve(e=>e+t.payload.items.length)}catch{e===$.current&&_e(!0)}finally{e===$.current&&Z(!1)}},[K,Q,X]);(0,B.useEffect)(()=>{if(!W||!K||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=$.current;try{let t=await s(a(`/api/personal-agent/activity?limit=${Math.max(pe,Math.min(100,Q))}&offset=0`));if(e!==$.current)return;q(t.payload),ve(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[K,Q,X,W]);let Te=async e=>{if(!c||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){C(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){C(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}re(!0),C(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await s(a(`/api/agents/${encodeURIComponent(c.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),I(c.agentId),k(`custom`),U(!1),await Se({appearance:`custom`})}catch(e){C(e instanceof Error?e.message:String(e))}finally{re(!1)}};(0,B.useLayoutEffect)(()=>{let a=c?.state===`ready`,o=a?c.appearance:O,s=a?c.displayName:`Ada`;return r({startExtra:null,main:(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[a?(0,V.jsx)(`button`,{ref:se,type:`button`,onClick:be,"aria-expanded":z,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${s}的资料`:`Edit ${s}'s profile`,title:n?`资料`:`Profile`,children:(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,V.jsx)(S,{appearance:o,agentId:c?.agentId,className:`size-8`})})}):(0,V.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,V.jsx)(S,{appearance:o,agentId:c?.agentId,className:`size-8`})}),(0,V.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:s})]}),end:a?(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{c?.state===`ready`&&t.current.open({conversationId:c.conversationId,name:c.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,V.jsx)(x,{className:`size-5`})}),(0,V.jsxs)(N,{open:W,onOpenChange:e=>{e?Ce():G(!1)},children:[(0,V.jsx)(F,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-pressed":W,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,V.jsx)(g,{className:`size-5`})})}),(0,V.jsx)(j,{children:(0,V.jsxs)(M,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(22rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl focus:outline-none`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:K?n?`最近更新 · 共 ${K.total} 项`:`Recently updated · ${K.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,V.jsx)(P,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,V.jsx)(E,{className:`size-4`})})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!K&&!Y&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(D,{className:`h-18 rounded-2xl`}),(0,V.jsx)(D,{className:`h-18 rounded-2xl`}),(0,V.jsx)(D,{className:`h-18 rounded-2xl`})]}),Y&&(0,V.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void Ce(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),K?.items.length===0&&(0,V.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,V.jsx)(g,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,V.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),K&&K.items.length>0&&(0,V.jsx)(`div`,{className:`space-y-2`,children:K.items.map(e=>(0,V.jsx)(J,{item:e,zh:n},e.id))}),K&&Q<K.total&&(0,V.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>void we(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),ge&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,V.jsx)(`button`,{ref:L,type:`button`,onClick:be,"aria-expanded":z,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`编辑资料`:`Edit profile`,children:(0,V.jsx)(w,{className:`size-5`})})]}):null}),()=>i()},[K,Y,Q,X,ge,O,i,we,Ce,c,r,W,z,be,e.active,n]);function Ee(){return c?(0,V.jsxs)(N,{open:z,onOpenChange:e=>{H(e),e||U(!1)},children:[(0,V.jsx)(ne,{virtualRef:L}),(0,V.jsx)(j,{children:(0,V.jsxs)(M,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(L.current?.contains(e.target)||se.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex w-[min(22rem,calc(100vw-1rem))] flex-col rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,V.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-4 pt-4 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>U(e=>!e),"aria-expanded":le,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,V.jsx)(S,{appearance:O,agentId:c.agentId,className:`size-16`})}),(0,V.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:ce,onChange:e=>R(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(R(t),Se({displayName:t})):R(d.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=d.current?.displayName??``,R(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-2 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),v>0&&(0,V.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,V.jsxs)(`div`,{className:`space-y-4 px-4 py-4`,children:[b&&(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:b}),le&&(0,V.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[me.map(e=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{k(e.id),U(!1),Se({appearance:e.id})},"aria-pressed":O===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${O===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,V.jsx)(S,{appearance:e.id,className:`size-8`})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,V.jsx)(`input`,{ref:ie,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&Te(t),e.currentTarget.value=``}}),(0,V.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>ie.current?.click(),"aria-pressed":O===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${O===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:O===`custom`?(0,V.jsx)(S,{appearance:`custom`,agentId:c.agentId,className:`size-8`}):(0,V.jsx)(T,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:A?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,V.jsx)(de,{onGreetingChange:e=>Se({voiceCallPreferences:{openingGreetingEnabled:e}}),record:c,zh:n,onSelectVoice:e=>Se({voicePreference:e})}),(0,V.jsx)(`div`,{className:`border-t border-edge pt-4`,children:(0,V.jsx)(fe,{conversationId:c.conversationId,zh:n,onSaved:async()=>{let e=await s(a(`/api/personal-agent`));e.ok&&e.payload&&(d.current=e.payload,u(e.payload))}})})]})]})})]}):null}return h?(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,V.jsx)(D,{className:`h-20 w-20 rounded-full`}),(0,V.jsx)(D,{className:`h-9 w-72`}),(0,V.jsx)(D,{className:`h-44 w-full rounded-2xl`})]}):c?.state===`ready`?(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ee&&(0,V.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,V.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{te(!1),ye()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(l,{embedded:!0,personal:!0,personalWelcome:{name:c.displayName,addressAs:c.userCallName??void 0,avatar:(0,V.jsx)(S,{appearance:c.appearance,agentId:c.agentId,className:`size-14`}),opening:n?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`},conversationId:c.conversationId})})}),Ee()]}):(0,V.jsx)(ue,{modelsAvailable:p.length>0,onCreated:(e,t)=>{d.current=e,u(e),R(e.displayName),te(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{Y as PersonalPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,n as a,o}from"./locale-store-B7y-RVe8.js";import{t as s}from"./popover-select-CEMWIrtY.js";import{t as c}from"./skeleton-BI5TyibZ.js";import{t as l}from"./personal-proactivity-DaRnbB1f.js";import{t as u}from"./use-personal-profile-BB10h9ED.js";import{n as d,t as f}from"./settings-page-header-BLKI3_9N.js";import"./settings-page-layout-BqBVrkC9.js";var p=n(),m=e(t(),1),h=r();function g(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var _=g();function v({zh:e}){let[t,n]=(0,m.useState)(),[r,a]=(0,m.useState)(``),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(``),g=f.trim().toLowerCase().replaceAll(`_`,` `),v=[...new Set([..._,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(g)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,m.useEffect)(()=>{let e=!0;return o(i(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(l.parse(t.payload))}).catch(t=>{e&&a(String(t))}),()=>{e=!1}},[]);async function y(e){if(!(!t||u)){d(!0),a(``);try{let r=await o(i(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(l.parse(r.payload))}catch(e){a(String(e));let t=await o(i(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(l.parse(t.payload))}finally{d(!1)}}}return(0,h.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,h.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,h.jsx)(c,{className:`h-9 w-full`}):t&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:u,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void y({mode:e})}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰开始`:`Quiet from`,(0,h.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void y({quietStart:Number(e)})})]}),(0,h.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰结束`:`Quiet until`,(0,h.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void y({quietEnd:Number(e)})})]})]}),(0,h.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,h.jsx)(s,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:v,disabled:u,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:f,onSearchChange:p,statusMessage:v.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{p(``),e!==t.timezone&&y({timezone:e})}})]}),(0,h.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,h.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}function y(){let e=(0,p.c)(8),{displayName:t}=u(),n=a(b)===`zh`,r=n?`设置 ${t} 主动联系你的方式和免打扰时段。`:`Manage proactive messages from ${t} and quiet hours.`,i;e[0]!==t||e[1]!==r?(i=(0,h.jsx)(f,{title:t,subtitle:r}),e[0]=t,e[1]=r,e[2]=i):i=e[2];let o;e[3]===n?o=e[4]:(o=(0,h.jsx)(v,{zh:n}),e[3]=n,e[4]=o);let s;return e[5]!==i||e[6]!==o?(s=(0,h.jsxs)(d,{children:[i,o]}),e[5]=i,e[6]=o,e[7]=s):s=e[7],s}function b(e){return e.language}export{y as PersonalSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,n as a,o}from"./locale-store-B6OrWgY1.js";import{t as s}from"./popover-select-CEMWIrtY.js";import{t as c}from"./skeleton-BI5TyibZ.js";import{t as l}from"./personal-proactivity-DaRnbB1f.js";import{t as u}from"./use-personal-profile-202s6tJt.js";import{n as d,t as f}from"./settings-page-header-BAN34UQi.js";import"./settings-page-layout-B5TVFBV2.js";var p=n(),m=e(t(),1),h=r();function g(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var _=g();function v({zh:e}){let[t,n]=(0,m.useState)(),[r,a]=(0,m.useState)(``),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(``),g=f.trim().toLowerCase().replaceAll(`_`,` `),v=[...new Set([..._,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(g)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,m.useEffect)(()=>{let e=!0;return o(i(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(l.parse(t.payload))}).catch(t=>{e&&a(String(t))}),()=>{e=!1}},[]);async function y(e){if(!(!t||u)){d(!0),a(``);try{let r=await o(i(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(l.parse(r.payload))}catch(e){a(String(e));let t=await o(i(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(l.parse(t.payload))}finally{d(!1)}}}return(0,h.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,h.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,h.jsx)(c,{className:`h-9 w-full`}):t&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:u,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void y({mode:e})}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰开始`:`Quiet from`,(0,h.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void y({quietStart:Number(e)})})]}),(0,h.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`免打扰结束`:`Quiet until`,(0,h.jsx)(s,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:u,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void y({quietEnd:Number(e)})})]})]}),(0,h.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,h.jsx)(s,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:v,disabled:u,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:f,onSearchChange:p,statusMessage:v.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{p(``),e!==t.timezone&&y({timezone:e})}})]}),(0,h.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,h.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}function y(){let e=(0,p.c)(8),{displayName:t}=u(),n=a(b)===`zh`,r=n?`设置 ${t} 主动联系你的方式和免打扰时段。`:`Manage proactive messages from ${t} and quiet hours.`,i;e[0]!==t||e[1]!==r?(i=(0,h.jsx)(f,{title:t,subtitle:r}),e[0]=t,e[1]=r,e[2]=i):i=e[2];let o;e[3]===n?o=e[4]:(o=(0,h.jsx)(v,{zh:n}),e[3]=n,e[4]=o);let s;return e[5]!==i||e[6]!==o?(s=(0,h.jsxs)(d,{children:[i,o]}),e[5]=i,e[6]=o,e[7]=s):s=e[7],s}function b(e){return e.language}export{y as PersonalSettingsPanel};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{i as r,n as i,o as a}from"./locale-store-B7y-RVe8.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{t as l}from"./refresh-cw-BRlGaq2w.js";import{t as u}from"./wrench-DFb4r8bH.js";import{t as d}from"./skeleton-BI5TyibZ.js";import{i as f}from"./vendor-swr-CdRzEUwF.js";import{t as p}from"./button-Cc4hUNTt.js";import{a as m}from"./runtime-tools-api-BDTUD8Rj.js";var h=e(t(),1),g=()=>r(`/api/runtime-tools/phone-dependencies`);async function _(){return(await a(g())).payload}async function v(e){await a(r(`/api/runtime-tools/phone-dependencies/adb/path`),{method:`POST`,body:JSON.stringify({path:e})})}async function y(e,t,n,r){return m({path:`/api/runtime-tools/phone-dependencies/${e}/${t}/stream`,body:r?{path:r}:{},onProgress:n})}var b=n();function x({cloudOnly:e=!1,onChanged:t,expanded:n=!0,onExpandedChange:r}){let a=i(e=>e.language)===`zh`,[m,x]=(0,h.useState)(),[S,C]=(0,h.useState)(!1),[w,T]=(0,h.useState)({adb:``,scrcpy:``}),[E,D]=(0,h.useState)(),[O,k]=(0,h.useState)(``),[A,j]=(0,h.useState)(!1),{data:M,error:N,mutate:P}=f(g(),_,{refreshInterval:m?2500:0}),F=a?{ready:`已就绪`,absent:`未安装`,corrupted:`需要修复`,unsupported:`当前平台需自行安装`,installing:`安装中`}:{ready:`Ready`,absent:`Not installed`,corrupted:`Needs repair`,unsupported:`Use an existing installation`,installing:`Installing`},I=a?{download:`下载中`,verify:`校验文件`,extract:`解压文件`,install:`安装中`,probe:`验证版本`,complete:`安装完成`}:{download:`Downloading`,verify:`Verifying files`,extract:`Extracting`,install:`Installing`,probe:`Checking version`,complete:`Installed`};async function L(e,n){x(e),j(!1),k(``),D(void 0);try{n===`detect`?await v(``):n===`existing`&&e===`adb`?await v(w.adb.trim()):await y(e,n===`existing`?`import`:n,D,n===`existing`?w.scrcpy.trim():void 0),await P(),t?.(),k(a?`依赖已就绪。`:`Dependency is ready.`)}catch(e){j(!0),k(e instanceof Error?e.message:String(e))}finally{x(void 0),D(void 0)}}let R=M?.statuses.filter(t=>!e||t.kind!==`adb`),z=!!(R?.length&&R.every(e=>e.state===`ready`));return(0,b.jsxs)(`details`,{open:n,onToggle:e=>{e.currentTarget.open!==n&&r?.(e.currentTarget.open)},className:`group rounded-2xl border border-edge bg-surface-panel`,"aria-label":a?`手机依赖状态`:`Phone dependencies`,children:[(0,b.jsxs)(`summary`,{className:`flex min-h-16 cursor-pointer list-none items-center gap-3 p-5 [&::-webkit-details-marker]:hidden`,children:[(0,b.jsx)(u,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,b.jsx)(`h2`,{className:`text-sm font-semibold`,children:a?`连接组件`:`Connection components`}),(0,b.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 text-xs ${N?`text-danger`:`text-fg-muted`}`,children:[z&&(0,b.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),N?a?`检测失败`:`Check failed`:M?z?a?`已就绪`:`Ready`:a?`需要配置`:`Setup needed`:a?`检测中`:`Checking`]}),(0,b.jsx)(o,{className:`size-4 shrink-0 text-fg-muted group-open:rotate-180`,"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle p-4 sm:p-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a?`安装在 Gateway 电脑上,无需全局安装。`:`Installed on your Gateway computer. No global installation needed.`}),(0,b.jsx)(p,{variant:`ghost`,"aria-label":a?`刷新手机依赖状态`:`Refresh phone dependencies`,disabled:!!m,onClick:()=>void P(),children:(0,b.jsx)(l,{className:`size-4`,"aria-hidden":!0})})]}),M?.installationEnabled===!1?(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a?`托管安装已禁用,可在运行环境中启用;已有 ADB 仍可使用。`:`Managed installation is disabled. Enable it in Runtime Tools, or use an existing ADB installation.`}):null,e?(0,b.jsxs)(`div`,{className:`space-y-2 text-xs text-fg-muted`,children:[(0,b.jsx)(`p`,{children:a?`阿里云连接无需本机 ADB;实时视频、持续触控和中文输入需要 scrcpy server。`:`Alibaba Cloud connections need no local ADB. Live video, continuous touch and Unicode input require scrcpy server.`}),(0,b.jsx)(`button`,{className:`text-accent-fg hover:underline`,"aria-expanded":S,onClick:()=>C(e=>!e),children:S?a?`收起本机连接依赖`:`Hide local connection dependencies`:a?`连接本机手机?查看 ADB 依赖`:`Connecting a local phone? Show ADB dependencies`})]}):null,N?(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:a?`无法读取依赖状态,请刷新重试。`:`Could not load dependency status. Refresh to retry.`}):M?M.statuses.filter(t=>!e||S||t.kind!==`adb`).map(e=>(0,b.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium`,children:e.kind===`adb`?`ADB · Android Platform Tools`:`scrcpy server`}),(0,b.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[F[e.state],e.version?` · ${e.version}`:` · ${a?`托管版本`:`Managed version`} ${e.requestedVersion}`,e.source===`system`?a?` · 使用已有安装`:` · Existing installation`:e.source===`custom`?a?` · 自定义路径`:` · Custom path`:``]})]}),(0,b.jsxs)(p,{disabled:!!m||e.state===`installing`||!e.canInstall,variant:e.state===`ready`?`secondary`:`primary`,onClick:()=>void L(e.kind,e.state===`corrupted`||e.state===`ready`&&e.source===`managed`?`repair`:`install`),children:[(0,b.jsx)(c,{className:`size-4`,"aria-hidden":!0}),m===e.kind||e.state===`installing`?a?`处理中…`:`Working…`:e.state===`ready`&&e.source!==`managed`?a?`安装托管副本`:`Install managed copy`:e.state===`ready`||e.state===`corrupted`?a?`修复托管安装`:`Repair managed copy`:a?`安装`:`Install`]})]}),(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.kind===`adb`?a?`仅连接本机 USB 手机或模拟器时需要;云手机无需安装。`:`Required for local USB phones and emulators. Cloud phones do not need it.`:a?`用于实时画面、跟手操作和中文输入;缺失时仍可查看截图并手动输入。`:`Required for live video, continuous touch and Unicode input. Snapshots and manual typing remain available without it.`}),(0,b.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer py-1`,children:e.kind===`adb`?a?`使用已有 ADB`:`Use existing ADB`:a?`导入已有 scrcpy server`:`Import existing scrcpy server`}),e.path?(0,b.jsxs)(`p`,{className:`mt-2 break-all`,children:[a?`当前文件:`:`Current file: `,e.path]}):null,(0,b.jsxs)(`label`,{className:`mt-3 block space-y-2`,children:[(0,b.jsx)(`span`,{children:e.kind===`adb`?a?`Gateway 上的 ADB 可执行文件绝对路径`:`Absolute ADB executable path on Gateway`:a?`Gateway 上的 scrcpy server 文件绝对路径`:`Absolute scrcpy server file path on Gateway`}),(0,b.jsx)(`input`,{"aria-label":e.kind===`adb`?a?`已有 ADB 路径`:`Existing ADB path`:a?`已有 scrcpy server 路径`:`Existing scrcpy server path`,value:w[e.kind],disabled:!!m,onChange:t=>T(n=>({...n,[e.kind]:t.target.value})),className:`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`})]}),(0,b.jsx)(`p`,{className:`mt-2`,children:e.kind===`scrcpy`?a?`只接受固定版本 ${e.requestedVersion},校验通过后复制到托管目录。`:`Only pinned version ${e.requestedVersion} is accepted and copied into managed storage after verification.`:a?`验证版本后保存路径;不会替换此文件或重启 ADB 服务。`:`Checks the version and saves the path without replacing files or restarting ADB.`}),(0,b.jsx)(p,{className:`mt-3`,disabled:!!m||!w[e.kind].trim(),onClick:()=>void L(e.kind,`existing`),children:a?`验证并使用`:`Verify and use`}),e.kind===`adb`?(0,b.jsx)(p,{variant:`ghost`,className:`ml-2 mt-3`,disabled:!!m,onClick:()=>void L(`adb`,`detect`),children:a?`恢复自动检测`:`Use automatic detection`}):null]})]},e.kind)):(0,b.jsx)(d,{className:`h-28 rounded-xl`}),(0,b.jsx)(`div`,{className:`min-h-5 text-xs`,"aria-live":`polite`,children:E?(0,b.jsxs)(`p`,{role:`status`,className:`text-fg-muted`,children:[I[E.phase]??E.phase,E.downloadedBytes&&E.totalBytes?` · ${Math.min(100,Math.round(E.downloadedBytes/E.totalBytes*100))}%`:``]}):O?(0,b.jsx)(`p`,{role:A?`alert`:`status`,className:A?`text-danger`:`text-fg-muted`,children:O}):null}),(0,b.jsx)(`a`,{href:`#/settings/runtimes`,className:`text-xs text-accent-fg hover:underline`,children:a?`管理下载代理与离线包`:`Manage download proxy and offline packages`})]})]})}export{x as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{i as r,n as i,o as a}from"./locale-store-B6OrWgY1.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{t as l}from"./refresh-cw-BRlGaq2w.js";import{t as u}from"./wrench-DFb4r8bH.js";import{t as d}from"./skeleton-BI5TyibZ.js";import{i as f}from"./vendor-swr-CdRzEUwF.js";import{t as p}from"./button-Cc4hUNTt.js";import{a as m}from"./runtime-tools-api-LopLjgvu.js";var h=e(t(),1),g=()=>r(`/api/runtime-tools/phone-dependencies`);async function _(){return(await a(g())).payload}async function v(e){await a(r(`/api/runtime-tools/phone-dependencies/adb/path`),{method:`POST`,body:JSON.stringify({path:e})})}async function y(e,t,n,r){return m({path:`/api/runtime-tools/phone-dependencies/${e}/${t}/stream`,body:r?{path:r}:{},onProgress:n})}var b=n();function x({cloudOnly:e=!1,onChanged:t,expanded:n=!0,onExpandedChange:r}){let a=i(e=>e.language)===`zh`,[m,x]=(0,h.useState)(),[S,C]=(0,h.useState)(!1),[w,T]=(0,h.useState)({adb:``,scrcpy:``}),[E,D]=(0,h.useState)(),[O,k]=(0,h.useState)(``),[A,j]=(0,h.useState)(!1),{data:M,error:N,mutate:P}=f(g(),_,{refreshInterval:m?2500:0}),F=a?{ready:`已就绪`,absent:`未安装`,corrupted:`需要修复`,unsupported:`当前平台需自行安装`,installing:`安装中`}:{ready:`Ready`,absent:`Not installed`,corrupted:`Needs repair`,unsupported:`Use an existing installation`,installing:`Installing`},I=a?{download:`下载中`,verify:`校验文件`,extract:`解压文件`,install:`安装中`,probe:`验证版本`,complete:`安装完成`}:{download:`Downloading`,verify:`Verifying files`,extract:`Extracting`,install:`Installing`,probe:`Checking version`,complete:`Installed`};async function L(e,n){x(e),j(!1),k(``),D(void 0);try{n===`detect`?await v(``):n===`existing`&&e===`adb`?await v(w.adb.trim()):await y(e,n===`existing`?`import`:n,D,n===`existing`?w.scrcpy.trim():void 0),await P(),t?.(),k(a?`依赖已就绪。`:`Dependency is ready.`)}catch(e){j(!0),k(e instanceof Error?e.message:String(e))}finally{x(void 0),D(void 0)}}let R=M?.statuses.filter(t=>!e||t.kind!==`adb`),z=!!(R?.length&&R.every(e=>e.state===`ready`));return(0,b.jsxs)(`details`,{open:n,onToggle:e=>{e.currentTarget.open!==n&&r?.(e.currentTarget.open)},className:`group rounded-2xl border border-edge bg-surface-panel`,"aria-label":a?`手机依赖状态`:`Phone dependencies`,children:[(0,b.jsxs)(`summary`,{className:`flex min-h-16 cursor-pointer list-none items-center gap-3 p-5 [&::-webkit-details-marker]:hidden`,children:[(0,b.jsx)(u,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,b.jsx)(`h2`,{className:`text-sm font-semibold`,children:a?`连接组件`:`Connection components`}),(0,b.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 text-xs ${N?`text-danger`:`text-fg-muted`}`,children:[z&&(0,b.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),N?a?`检测失败`:`Check failed`:M?z?a?`已就绪`:`Ready`:a?`需要配置`:`Setup needed`:a?`检测中`:`Checking`]}),(0,b.jsx)(o,{className:`size-4 shrink-0 text-fg-muted group-open:rotate-180`,"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle p-4 sm:p-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a?`安装在 Gateway 电脑上,无需全局安装。`:`Installed on your Gateway computer. No global installation needed.`}),(0,b.jsx)(p,{variant:`ghost`,"aria-label":a?`刷新手机依赖状态`:`Refresh phone dependencies`,disabled:!!m,onClick:()=>void P(),children:(0,b.jsx)(l,{className:`size-4`,"aria-hidden":!0})})]}),M?.installationEnabled===!1?(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a?`托管安装已禁用,可在运行环境中启用;已有 ADB 仍可使用。`:`Managed installation is disabled. Enable it in Runtime Tools, or use an existing ADB installation.`}):null,e?(0,b.jsxs)(`div`,{className:`space-y-2 text-xs text-fg-muted`,children:[(0,b.jsx)(`p`,{children:a?`阿里云连接无需本机 ADB;实时视频、持续触控和中文输入需要 scrcpy server。`:`Alibaba Cloud connections need no local ADB. Live video, continuous touch and Unicode input require scrcpy server.`}),(0,b.jsx)(`button`,{className:`text-accent-fg hover:underline`,"aria-expanded":S,onClick:()=>C(e=>!e),children:S?a?`收起本机连接依赖`:`Hide local connection dependencies`:a?`连接本机手机?查看 ADB 依赖`:`Connecting a local phone? Show ADB dependencies`})]}):null,N?(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:a?`无法读取依赖状态,请刷新重试。`:`Could not load dependency status. Refresh to retry.`}):M?M.statuses.filter(t=>!e||S||t.kind!==`adb`).map(e=>(0,b.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium`,children:e.kind===`adb`?`ADB · Android Platform Tools`:`scrcpy server`}),(0,b.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[F[e.state],e.version?` · ${e.version}`:` · ${a?`托管版本`:`Managed version`} ${e.requestedVersion}`,e.source===`system`?a?` · 使用已有安装`:` · Existing installation`:e.source===`custom`?a?` · 自定义路径`:` · Custom path`:``]})]}),(0,b.jsxs)(p,{disabled:!!m||e.state===`installing`||!e.canInstall,variant:e.state===`ready`?`secondary`:`primary`,onClick:()=>void L(e.kind,e.state===`corrupted`||e.state===`ready`&&e.source===`managed`?`repair`:`install`),children:[(0,b.jsx)(c,{className:`size-4`,"aria-hidden":!0}),m===e.kind||e.state===`installing`?a?`处理中…`:`Working…`:e.state===`ready`&&e.source!==`managed`?a?`安装托管副本`:`Install managed copy`:e.state===`ready`||e.state===`corrupted`?a?`修复托管安装`:`Repair managed copy`:a?`安装`:`Install`]})]}),(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.kind===`adb`?a?`仅连接本机 USB 手机或模拟器时需要;云手机无需安装。`:`Required for local USB phones and emulators. Cloud phones do not need it.`:a?`用于实时画面、跟手操作和中文输入;缺失时仍可查看截图并手动输入。`:`Required for live video, continuous touch and Unicode input. Snapshots and manual typing remain available without it.`}),(0,b.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer py-1`,children:e.kind===`adb`?a?`使用已有 ADB`:`Use existing ADB`:a?`导入已有 scrcpy server`:`Import existing scrcpy server`}),e.path?(0,b.jsxs)(`p`,{className:`mt-2 break-all`,children:[a?`当前文件:`:`Current file: `,e.path]}):null,(0,b.jsxs)(`label`,{className:`mt-3 block space-y-2`,children:[(0,b.jsx)(`span`,{children:e.kind===`adb`?a?`Gateway 上的 ADB 可执行文件绝对路径`:`Absolute ADB executable path on Gateway`:a?`Gateway 上的 scrcpy server 文件绝对路径`:`Absolute scrcpy server file path on Gateway`}),(0,b.jsx)(`input`,{"aria-label":e.kind===`adb`?a?`已有 ADB 路径`:`Existing ADB path`:a?`已有 scrcpy server 路径`:`Existing scrcpy server path`,value:w[e.kind],disabled:!!m,onChange:t=>T(n=>({...n,[e.kind]:t.target.value})),className:`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`})]}),(0,b.jsx)(`p`,{className:`mt-2`,children:e.kind===`scrcpy`?a?`只接受固定版本 ${e.requestedVersion},校验通过后复制到托管目录。`:`Only pinned version ${e.requestedVersion} is accepted and copied into managed storage after verification.`:a?`验证版本后保存路径;不会替换此文件或重启 ADB 服务。`:`Checks the version and saves the path without replacing files or restarting ADB.`}),(0,b.jsx)(p,{className:`mt-3`,disabled:!!m||!w[e.kind].trim(),onClick:()=>void L(e.kind,`existing`),children:a?`验证并使用`:`Verify and use`}),e.kind===`adb`?(0,b.jsx)(p,{variant:`ghost`,className:`ml-2 mt-3`,disabled:!!m,onClick:()=>void L(`adb`,`detect`),children:a?`恢复自动检测`:`Use automatic detection`}):null]})]},e.kind)):(0,b.jsx)(d,{className:`h-28 rounded-xl`}),(0,b.jsx)(`div`,{className:`min-h-5 text-xs`,"aria-live":`polite`,children:E?(0,b.jsxs)(`p`,{role:`status`,className:`text-fg-muted`,children:[I[E.phase]??E.phase,E.downloadedBytes&&E.totalBytes?` · ${Math.min(100,Math.round(E.downloadedBytes/E.totalBytes*100))}%`:``]}):O?(0,b.jsx)(`p`,{role:A?`alert`:`status`,className:A?`text-danger`:`text-fg-muted`,children:O}):null}),(0,b.jsx)(`a`,{href:`#/settings/runtimes`,className:`text-xs text-accent-fg hover:underline`,children:a?`管理下载代理与离线包`:`Manage download proxy and offline packages`})]})]})}export{x as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-BGTk37IG.js";import{t as f}from"./arrow-left-D880xG-P.js";import{t as p}from"./refresh-cw-BRlGaq2w.js";import{t as m}from"./x-B_N4OPjy.js";import{t as h}from"./skeleton-BI5TyibZ.js";import{i as g}from"./vendor-swr-CdRzEUwF.js";import{t as _}from"./button-Cc4hUNTt.js";import{t as v}from"./open-capability-settings-Cvb65hQB.js";import{n as y}from"./providers-api-CBSC3jdu.js";import{t as b}from"./mobile-pair-qr-CuIbmw5x.js";import{a as x,c as S,n as C,o as w}from"./phone-model-picker-Bkex4Sre.js";var T=n(),E=e(t(),1),D=r();function ee({zh:e,onAdded:t}){let[n,r]=(0,E.useState)(e?`阿里云手机`:`Alibaba Cloud Phone`),[i,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(),[c,l]=(0,E.useState)(),[u,d]=(0,E.useState)(!1),[f,p]=(0,E.useState)(!1),[m,h]=(0,E.useState)(``),g=(0,E.useRef)(void 0),v=(0,E.useRef)(!0),y=()=>{let e=g.current;g.current=void 0,l(void 0),e&&S(`/cloud/aliyun/tests/${e}`,void 0,`DELETE`).catch(()=>{})};(0,E.useEffect)(()=>(v.current=!0,()=>{v.current=!1,g.current&&S(`/cloud/aliyun/tests/${g.current}`,void 0,`DELETE`).catch(()=>{})}),[]);let b=async()=>{if(o){y(),p(!0),h(``);try{if(o.size>16384)throw Error(e?`私钥文件不能超过 16 KB`:`Private key must be at most 16 KB`);let t=await S(`/cloud/aliyun/test`,{endpoint:i.trim(),privateKey:await o.text()});if(!v.current){S(`/cloud/aliyun/tests/${t.token}`,void 0,`DELETE`).catch(()=>{});return}g.current=t.token,l(t)}catch(e){v.current&&h(String(e instanceof Error?e.message:e))}finally{v.current&&p(!1)}}},x=async()=>{if(c){p(!0),h(``);try{await S(`/cloud/aliyun/add`,{token:c.token,name:n.trim(),makeDefault:u}),g.current=void 0,t()}catch(e){v.current&&h(String(e instanceof Error?e.message:e))}finally{v.current&&p(!1)}}},C=`mt-2 w-full rounded-xl border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`;return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e?`在阿里云控制台绑定密钥对并创建 ADB 连接,复制公网或 Gateway 可访问的内网地址。无需云账号 AccessKey。`:`Bind a key pair and create an ADB connection in the Alibaba console. Use an address reachable from the Gateway. No cloud account AccessKey is needed.`}),(0,D.jsxs)(`label`,{className:`block text-sm`,children:[e?`手机名称`:`Phone name`,(0,D.jsx)(`input`,{className:C,value:n,maxLength:100,disabled:f,onChange:e=>r(e.target.value)})]}),(0,D.jsxs)(`label`,{className:`block text-sm`,children:[e?`ADB 地址`:`ADB address`,(0,D.jsx)(`input`,{className:C,placeholder:`203.0.113.10:10001`,value:i,disabled:f,autoComplete:`off`,onChange:e=>{y(),a(e.target.value)}})]}),(0,D.jsxs)(`label`,{className:`block text-sm`,children:[e?`私钥文件(adbkey)`:`Private key file (adbkey)`,(0,D.jsx)(`input`,{className:C,type:`file`,disabled:f,onChange:e=>{y(),s(e.target.files?.[0])}})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`私钥仅提交到当前 Gateway,添加后保存在 Gateway 凭据目录,不会替换电脑现有 ADB 密钥。`:`The key is sent only to this Gateway and saved in its credentials directory after adding. Existing host ADB keys stay unchanged.`}),(0,D.jsx)(_,{disabled:f||!i.trim()||!o,onClick:()=>void b(),children:f?e?`处理中…`:`Working…`:e?`测试连接`:`Test connection`}),m&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:m}),c&&(0,D.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,D.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[e?`连接成功`:`Connected`,` · `,c.model,` · Android `,c.androidVersion]}),(0,D.jsx)(`img`,{src:c.screenshot,alt:e?`云手机当前画面`:`Current cloud phone screen`,className:`mx-auto max-h-64 rounded-lg object-contain`}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`添加后可在聊天中使用实时视频、接管操作和交还 Agent;视频不可用时使用截图。测试结果有效期为 10 分钟。默认只允许系统设置,添加后可在「管理」中调整。`:`After adding, use live video, takeover and Agent handback in chat, with snapshots when video is unavailable. Test expires after 10 minutes. Settings is the initial allowed app; adjust it in Manage.`}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:u,disabled:f,onChange:e=>d(e.target.checked)}),e?`设为默认手机`:`Set as default phone`]}),(0,D.jsx)(_,{variant:`primary`,disabled:f||!n.trim()||c.expiresAt<=Date.now(),onClick:()=>void x(),children:e?`添加手机`:`Add phone`})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`移除连接只删除 xopc 的连接与私钥,不会销毁云手机,也不会关闭阿里云侧的 ADB 端口。`:`Removing a connection deletes its xopc credentials. It does not destroy the cloud phone or close its cloud ADB endpoint.`})]})}var O=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm`,k=new Set([`connected`,`timeout`,`error`,`cancelled`]);function A({zh:e,onSelect:t}){let[n,r]=(0,E.useState)(`qr`),[i,a]=(0,E.useState)(),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(``),[f,p]=(0,E.useState)(``),[m,v]=(0,E.useState)(``),[y,x]=(0,E.useState)(!1),[C,w]=(0,E.useState)(``),[T,ee]=(0,E.useState)(Date.now()),A=(0,E.useRef)(void 0),j=(0,E.useRef)(0),M=(0,E.useRef)(t);M.current=t;let N=g(`phone-wireless-discovery`,()=>S(`/wireless/discovery`),{refreshInterval:4e3}),P=()=>{j.current++;let e=A.current;A.current=void 0,e&&S(`/wireless/pairings/${e}`,void 0,`DELETE`).catch(()=>{})},F=async e=>{P();let t=j.current;x(!0),w(``),a(void 0),s(``);try{if(e===`connect`){let e=await S(`/wireless/connect`,{host:c,port:Number(f)});j.current===t&&M.current(e)}else{let n=await S(`/wireless/pairings`,e===`qr`?{method:`qr`}:{method:`code`,host:c,pairingPort:Number(u),code:m,...f?{connectPort:Number(f)}:{}});if(j.current!==t){S(`/wireless/pairings/${n.id}`,void 0,`DELETE`).catch(()=>{});return}A.current=n.id,a(n),v(``)}}catch(e){j.current===t&&w(e instanceof Error?e.message:String(e))}finally{j.current===t&&x(!1)}};(0,E.useEffect)(()=>(n===`qr`&&F(`qr`),P),[n]),(0,E.useEffect)(()=>{let t=!0;return s(``),i?.qrPayload&&b(i.qrPayload).then(e=>{t&&s(e)}).catch(()=>{t&&w(e?`二维码生成失败,请重试`:`Unable to render QR code`)}),()=>{t=!1}},[i?.qrPayload,e]),(0,E.useEffect)(()=>{if(!i||k.has(i.status))return;let e=!0,t,n=async()=>{try{let r=await S(`/wireless/pairings/${i.id}`);if(!e)return;if(a(r),ee(Date.now()),r.status===`connected`&&r.device){M.current(r.device);return}k.has(r.status)||(t=setTimeout(()=>{n()},1e3))}catch(r){if(!e)return;w(r instanceof Error?r.message:String(r)),Date.now()<i.expiresAt+5e3?t=setTimeout(()=>{n()},2e3):a(e=>e&&{...e,status:`timeout`,qrPayload:void 0})}};return t=setTimeout(()=>{n()},1e3),()=>{e=!1,clearTimeout(t)}},[i?.id,i?.status]);let I=e?{waiting:`等待扫码`,pairing:`正在配对`,paired:`已配对,正在查找连接地址`,connecting:`正在连接`,connected:`已连接`,timeout:`操作超时`,error:`配对失败`,cancelled:`已取消`}:{waiting:`Waiting for scan`,pairing:`Pairing`,paired:`Paired · Finding connection address`,connecting:`Connecting`,connected:`Connected`,timeout:`Timed out`,error:`Pairing failed`,cancelled:`Cancelled`},L=y||!!(i&&!k.has(i.status));return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-inset p-3 text-sm`,children:e?`手机须与 Gateway 所在电脑处于同一局域网。仅浏览器与手机同网还不够。支持 Android 11 及以上。`:`Android 11+. The phone and Gateway host must share a local network.`}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":e?`无线连接方式`:`Wireless connection method`,children:[[`qr`,e?`扫码配对`:`QR pairing`],[`code`,e?`配对码`:`Pairing code`],[`connect`,e?`连接已配对设备`:`Already paired`]].map(([e,t])=>(0,D.jsx)(_,{"aria-pressed":n===e,onClick:()=>{P(),x(!1),a(void 0),w(``),s(``),r(e)},children:t},e))}),(0,D.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5 text-sm text-fg-muted`,children:[(0,D.jsx)(`li`,{children:e?`打开手机「设置 → 开发者选项 → 无线调试」。`:`Open Settings → Developer options → Wireless debugging.`}),(0,D.jsx)(`li`,{children:n===`qr`?e?`选择「使用二维码配对设备」,扫描下方二维码。`:`Choose Pair device with QR code and scan below.`:n===`code`?e?`选择「使用配对码配对设备」,填写显示的地址和六位配对码。`:`Choose Pair device with pairing code and enter its address and six-digit code.`:e?`填写无线调试首页显示的 IP 地址与连接端口。`:`Enter the IP and port shown on the main Wireless debugging screen.`})]}),N.isLoading&&(0,D.jsx)(h,{className:`h-12 w-full`}),(N.error||N.data?.mdns===!1)&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:e?`自动发现不可用。可使用配对码并手动填写连接端口。请检查 Gateway 的 ADB、网络及防火墙。`:`Discovery unavailable. Use a pairing code and enter the connection port manually. Check Gateway ADB, network and firewall.`}),n===`qr`?(0,D.jsxs)(`div`,{className:`space-y-3 text-center`,children:[o?(0,D.jsx)(`img`,{src:o,alt:e?`无线调试配对二维码`:`Wireless debugging pairing QR code`,className:`mx-auto size-60 rounded-lg bg-white`}):i&&!k.has(i.status)?(0,D.jsx)(h,{className:`mx-auto size-60`}):null,i&&(0,D.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[I[i.status],k.has(i.status)?``:` · ${Math.max(0,Math.ceil((i.expiresAt-T)/1e3))}s`]}),(0,D.jsx)(_,{disabled:y,onClick:()=>{F(`qr`)},children:e?`重新生成`:`Regenerate`})]}):(0,D.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),F(n)},children:[N.data?.services.filter(e=>e.kind===(n===`code`?`pairing`:`connect`)).map(e=>(0,D.jsxs)(_,{type:`button`,disabled:L,onClick:()=>{if(l(e.host),n===`code`){d(String(e.port));let t=N.data?.services.find(t=>t.kind===`connect`&&t.host===e.host);p(t?String(t.port):``)}else p(String(e.port))},children:[e.host,`:`,e.port]},`${e.name}:${e.port}`)),(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`手机 IP 地址`:`Phone IP address`,(0,D.jsx)(`input`,{className:O,value:c,onChange:e=>l(e.target.value.trim()),required:!0,disabled:L,placeholder:`192.168.1.10`})]}),n===`code`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`配对端口`:`Pairing port`,(0,D.jsx)(`input`,{className:O,type:`number`,min:1,max:65535,value:u,onChange:e=>d(e.target.value),required:!0,disabled:L})]}),(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`六位配对码`:`Six-digit pairing code`,(0,D.jsx)(`input`,{className:O,inputMode:`numeric`,autoComplete:`off`,pattern:`[0-9]{6}`,maxLength:6,value:m,onChange:e=>v(e.target.value),required:!0,disabled:L})]})]}),(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`连接端口`:`Connection port`,(0,D.jsx)(`input`,{className:O,type:`number`,min:1,max:65535,value:f,onChange:e=>p(e.target.value),required:n===`connect`,disabled:L,placeholder:e?`留空自动发现`:`Auto-discover if empty`})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`连接端口在无线调试首页显示,与配对端口不同,会随设备状态变化。`:`The connection port is on the main Wireless debugging screen. It differs from the pairing port and can change.`}),i&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm`,children:I[i.status]}),(0,D.jsx)(_,{type:`submit`,disabled:L,children:e?n===`code`?`配对并连接`:`连接`:n===`code`?`Pair and connect`:`Connect`})]}),i?.errorCode&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:i.errorCode===`PHONE_CONNECT_TIMEOUT`?e?`已配对,但未能连接。切换「连接已配对设备」并填写当前连接端口,无需重新配对。`:`Paired but not connected. Use Already paired with the current connection port.`:e?`未完成配对。请检查手机配对页面、网络和配对码后重试。`:`Pairing incomplete. Check the phone pairing screen, network and code, then retry.`}),L&&(0,D.jsx)(_,{onClick:()=>{P(),x(!1),a(void 0),s(``)},children:e?`取消配对`:`Cancel pairing`}),C&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:C})]})}var j=[{id:`wireless`,available:!0,name:[`无线连接 Android 手机`,`Wireless Android phone`],description:[`Android 11+,扫码或输入配对码,无需数据线。`,`Android 11+ · Pair with a QR code or pairing code.`]},{id:`local-adb`,available:!0,name:[`Gateway 电脑上的手机 / 模拟器`,`Phone or emulator on the Gateway host`],description:[`通过 USB 或已配对的无线 ADB 连接。`,`Connect over USB or previously paired wireless ADB.`]},{id:`remote-connector`,available:!1,name:[`通过本地连接器连接`,`Local connector`],description:[`Gateway 在服务器上,手机连接在你的电脑上。`,`Connect a phone on your computer to a remote Gateway.`]},{id:`aliyun`,available:!0,name:[`阿里云手机`,`Alibaba Cloud Phone`],description:[`填写 ADB 地址并上传私钥,连接已有云手机。`,`Connect an existing cloud phone with its ADB address and private key.`]},{id:`tencent`,available:!1,name:[`腾讯云手机`,`Tencent Cloud Phone`],description:[`连接云账号,选择地域和已有实例。`,`Connect an account, then choose a region and existing instance.`]}];function M(e){let t=(0,T.c)(48),{zh:n,onClose:r,onSelect:i,onAdded:v,initialMethod:y}=e,[b,S]=(0,E.useState)(y),C;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(C={refreshInterval:3e3},t[0]=C):C=t[0];let w=g(b===`local-adb`?`phone-devices`:null,x,C),O;t[1]===b?O=t[2]:(O=j.find(e=>e.id===b),t[1]=b,t[2]=O);let k=O,M=+!n,N;t[3]===n?N=t[4]:(N=n?{device:`已连接,可添加`,unauthorized:`等待手机授权:解锁手机,点击「允许 USB 调试」`,offline:`设备离线:重新连接数据线或无线调试`,recovery:`恢复模式:请先启动 Android 系统`,sideload:`请退出刷机模式并启动 Android 系统`}:{device:`Connected · Ready to add`,unauthorized:`Unlock the phone and allow USB debugging`,offline:`Offline · Reconnect USB or wireless debugging`,recovery:`Boot Android before connecting`,sideload:`Exit sideload mode and boot Android`},t[3]=n,t[4]=N);let P=N,F;t[5]===w.data?.discovery?F=t[6]:(F=w.data?.discovery??[],t[5]=w.data?.discovery,t[6]=F);let I=F,L;t[7]===r?L=t[8]:(L=e=>{e||r()},t[7]=r,t[8]=L);let R;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,D.jsx)(a,{className:`fixed inset-0 z-[80] bg-black/40`}),t[9]=R):R=t[9];let z;t[10]!==b||t[11]!==n?(z=b&&(0,D.jsx)(_,{variant:`ghost`,"aria-label":n?`返回连接方式`:`Back to connection methods`,onClick:()=>S(void 0),children:(0,D.jsx)(f,{className:`size-4`})}),t[10]=b,t[11]=n,t[12]=z):z=t[12];let B=n?`添加手机`:`Add phone`,V;t[13]===B?V=t[14]:(V=(0,D.jsx)(u,{className:`text-base font-semibold`,children:B}),t[13]=B,t[14]=V);let H=k?k.name[M]:n?`选择手机连接在哪里。手机模型在添加设备后独立配置。`:`Choose where the phone connects. Phone models are configured separately.`,U;t[15]===H?U=t[16]:(U=(0,D.jsx)(o,{className:`mt-1 text-sm text-fg-muted`,children:H}),t[15]=H,t[16]=U);let W;t[17]!==U||t[18]!==V?(W=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[V,U]}),t[17]=U,t[18]=V,t[19]=W):W=t[19];let G=n?`关闭添加手机`:`Close add phone`,K;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,D.jsx)(m,{className:`size-4`}),t[20]=K):K=t[20];let q;t[21]===G?q=t[22]:(q=(0,D.jsx)(s,{asChild:!0,children:(0,D.jsx)(_,{variant:`ghost`,"aria-label":G,children:K})}),t[21]=G,t[22]=q);let J;t[23]!==W||t[24]!==q||t[25]!==z?(J=(0,D.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge p-5`,children:[z,W,q]}),t[23]=W,t[24]=q,t[25]=z,t[26]=J):J=t[26];let Y;t[27]!==w||t[28]!==I||t[29]!==M||t[30]!==b||t[31]!==v||t[32]!==r||t[33]!==i||t[34]!==P||t[35]!==n?(Y=b?b===`aliyun`?(0,D.jsx)(ee,{zh:n,onAdded:()=>{v?.(),r()}}):b===`wireless`?(0,D.jsx)(A,{zh:n,onSelect:i}):b===`local-adb`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-inset p-3 text-sm`,children:n?`连接位置:Gateway 所在电脑。若 Gateway 在服务器上,浏览器无法访问你电脑的 USB 手机。`:`Connection location: the Gateway host. A remote Gateway cannot access your browser computer’s USB phone.`}),(0,D.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-sm text-fg-muted`,children:[(0,D.jsx)(`li`,{children:n?`手机开启开发者选项和 USB 调试;模拟器直接启动即可。`:`Enable developer options and USB debugging, or start an emulator.`}),(0,D.jsx)(`li`,{children:n?`用数据线连接 Gateway 电脑,在手机上允许 USB 调试。`:`Connect to the Gateway host with a data cable, then allow USB debugging on the phone.`}),(0,D.jsx)(`li`,{children:n?`等待下方显示设备,选择后确认名称和应用范围。`:`Select a discovered device below, then confirm its name and app access.`})]}),(0,D.jsxs)(`details`,{className:`text-sm`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:n?`使用无线连接或安装连接工具`:`Wireless connection or connection tools`}),(0,D.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:n?`可返回连接方式,选择「无线连接 Android 手机」进行扫码或配对码配对。ADB 可在手机控制页的「手机依赖状态」中手动安装,或使用 Gateway 电脑上已有的 Platform Tools;无需安装完整 Android Studio。`:`Choose Wireless Android phone to pair with a QR code or pairing code. Install ADB from Phone dependencies or use existing Platform Tools on the Gateway host.`}),(0,D.jsx)(`a`,{href:`https://developer.android.com/tools/adb`,target:`_blank`,rel:`noopener noreferrer`,className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,children:n?`查看 Android 官方连接指引`:`Android connection guide`})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`发现的设备`:`Discovered devices`}),(0,D.jsxs)(_,{disabled:w.isValidating,onClick:()=>{w.mutate()},children:[(0,D.jsx)(p,{className:`size-4`}),n?`刷新`:`Refresh`]})]}),!w.data&&!w.error?(0,D.jsx)(h,{className:`h-24 w-full rounded-xl`}):null,(w.error||w.data?.diagnostic)&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[n?`无法检测设备,请检查 Gateway 电脑的 ADB 安装与连接。`:`Unable to detect devices. Check ADB on the Gateway host.`,(0,D.jsx)(`span`,{className:`mt-1 block break-all text-xs`,children:w.data?.diagnostic??String(w.error)})]}),I.map(e=>{let t=w.data?.devices.some(t=>t.serial===e.serial);return(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge p-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium`,children:e.name}),(0,D.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:e.serial}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:P[e.state]??e.state})]}),(0,D.jsx)(_,{disabled:t||e.state!==`device`,onClick:()=>i(e),children:t?n?`已添加`:`Added`:n?`选择设备`:`Choose device`})]},e.serial)}),w.data&&!I.length&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:n?`尚未发现设备。请检查数据线、手机调试授权,或启动模拟器。`:`No devices found. Check the cable and debugging authorization, or start an emulator.`})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`此接入方式暂未支持`:`This connection method is not available yet`}),(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b===`remote-connector`?n?`后续可通过本地连接器将电脑上的手机接入远程 Gateway。当前请将手机连接到 Gateway 所在电脑。`:`A future local connector will connect your phone to a remote Gateway. For now, connect it to the Gateway host.`:n?`云手机适配器接入后,可配置云账号、选择地域和已有实例,再验证连接并添加。当前尚不能连接云实例,不会要求填写云密钥。`:`Once the cloud adapter is available, connect an account, select a region and existing instance, then verify and add it. Cloud connections are not supported yet.`}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`添加已有实例与购买、创建、销毁实例分开处理。`:`Adding existing instances is separate from purchasing, creating or destroying them.`})]}):j.map(e=>(0,D.jsxs)(`button`,{className:`block min-h-20 w-full rounded-xl border border-edge bg-surface-base p-4 text-left hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent`,onClick:()=>S(e.id),children:[(0,D.jsxs)(`span`,{className:`flex flex-wrap items-center justify-between gap-2 text-sm font-medium`,children:[e.name[M],!e.available&&(0,D.jsx)(`span`,{className:`text-xs font-normal text-fg-muted`,children:n?`暂未支持`:`Not available yet`})]}),(0,D.jsx)(`span`,{className:`mt-2 block text-xs text-fg-muted`,children:e.description[M]})]},e.id)),t[27]=w,t[28]=I,t[29]=M,t[30]=b,t[31]=v,t[32]=r,t[33]=i,t[34]=P,t[35]=n,t[36]=Y):Y=t[36];let X;t[37]===Y?X=t[38]:(X=(0,D.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-5`,children:Y}),t[37]=Y,t[38]=X);let te=n?`取消`:`Cancel`,Z;t[39]===te?Z=t[40]:(Z=(0,D.jsx)(`footer`,{className:`flex shrink-0 justify-end border-t border-edge p-4`,children:(0,D.jsx)(s,{asChild:!0,children:(0,D.jsx)(_,{children:te})})}),t[39]=te,t[40]=Z);let Q;t[41]!==J||t[42]!==X||t[43]!==Z?(Q=(0,D.jsxs)(c,{children:[R,(0,D.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-[81] flex h-[min(42rem,90dvh)] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay text-fg`,children:[J,X,Z]})]}),t[41]=J,t[42]=X,t[43]=Z,t[44]=Q):Q=t[44];let $;return t[45]!==Q||t[46]!==L?($=(0,D.jsx)(d,{open:!0,onOpenChange:L,children:Q}),t[45]=Q,t[46]=L,t[47]=$):$=t[47],$}function N({value:e,zh:t,disabled:n,onSave:r,onSelect:a}){let o=g(`phone-models`,w),s=g(`phone-provider-meta`,y),[c,l]=(0,E.useState)(e),[u,d]=(0,E.useState)(!1),[f,p]=(0,E.useState)(``),[m,h]=(0,E.useState)(!1);(0,E.useEffect)(()=>{l(e)},[e]);let b=o.data?.models.find(e=>e.id===c),x=c.split(`/`)[0],S=s.data?.find(e=>e.id===x)?.name??x,T=!c||!!b?.configured,ee=async()=>{if(!(u||!T)){d(!0),p(``),h(!1);try{await r(c),h(!0)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start`,children:[(0,D.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,D.jsx)(C,{value:c,onChange:e=>{l(e),a?.(e),h(!1),p(``)},zh:t,disabled:n||u})}),(0,D.jsx)(_,{variant:c===e?`secondary`:`primary`,disabled:n||u||!o.data||!T||c===e,onClick:()=>{ee()},children:u?t?`保存中…`:`Saving…`:t?`保存`:`Save`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[c&&o.data?(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:b?`${S} · ${b.configured?t?`凭据就绪`:`Credentials ready`:t?`请先配置凭据`:`Configure credentials first`}`:t?`当前模型不可用,请重新选择。`:`This model is unavailable. Choose another model.`}):null,(0,D.jsx)(i,{to:`/settings/capabilities/models?returnTo=%2Fsettings%2Fphone-use&purpose=phone`,onClick:e=>{!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&(e.preventDefault(),v(`chat`,`services`,`phone`))},className:`inline-flex min-h-8 items-center text-xs text-accent-fg hover:underline`,children:t?`管理模型`:`Manage models`})]}),f&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f}),m&&(0,D.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`手机模型已保存,请返回手机连接测试实际操作。`:`Phone model saved. Test it from the phone connection.`})]})}export{M as n,N as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-BGTk37IG.js";import{t as f}from"./arrow-left-D880xG-P.js";import{t as p}from"./refresh-cw-BRlGaq2w.js";import{t as m}from"./x-B_N4OPjy.js";import{t as h}from"./skeleton-BI5TyibZ.js";import{i as g}from"./vendor-swr-CdRzEUwF.js";import{t as _}from"./button-Cc4hUNTt.js";import{t as v}from"./open-capability-settings-Cvb65hQB.js";import{n as y}from"./providers-api-BOCkRZ7X.js";import{t as b}from"./mobile-pair-qr-CuIbmw5x.js";import{a as x,c as S,n as C,o as w}from"./phone-model-picker-DgIiWLhR.js";var T=n(),E=e(t(),1),D=r();function ee({zh:e,onAdded:t}){let[n,r]=(0,E.useState)(e?`阿里云手机`:`Alibaba Cloud Phone`),[i,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(),[c,l]=(0,E.useState)(),[u,d]=(0,E.useState)(!1),[f,p]=(0,E.useState)(!1),[m,h]=(0,E.useState)(``),g=(0,E.useRef)(void 0),v=(0,E.useRef)(!0),y=()=>{let e=g.current;g.current=void 0,l(void 0),e&&S(`/cloud/aliyun/tests/${e}`,void 0,`DELETE`).catch(()=>{})};(0,E.useEffect)(()=>(v.current=!0,()=>{v.current=!1,g.current&&S(`/cloud/aliyun/tests/${g.current}`,void 0,`DELETE`).catch(()=>{})}),[]);let b=async()=>{if(o){y(),p(!0),h(``);try{if(o.size>16384)throw Error(e?`私钥文件不能超过 16 KB`:`Private key must be at most 16 KB`);let t=await S(`/cloud/aliyun/test`,{endpoint:i.trim(),privateKey:await o.text()});if(!v.current){S(`/cloud/aliyun/tests/${t.token}`,void 0,`DELETE`).catch(()=>{});return}g.current=t.token,l(t)}catch(e){v.current&&h(String(e instanceof Error?e.message:e))}finally{v.current&&p(!1)}}},x=async()=>{if(c){p(!0),h(``);try{await S(`/cloud/aliyun/add`,{token:c.token,name:n.trim(),makeDefault:u}),g.current=void 0,t()}catch(e){v.current&&h(String(e instanceof Error?e.message:e))}finally{v.current&&p(!1)}}},C=`mt-2 w-full rounded-xl border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`;return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e?`在阿里云控制台绑定密钥对并创建 ADB 连接,复制公网或 Gateway 可访问的内网地址。无需云账号 AccessKey。`:`Bind a key pair and create an ADB connection in the Alibaba console. Use an address reachable from the Gateway. No cloud account AccessKey is needed.`}),(0,D.jsxs)(`label`,{className:`block text-sm`,children:[e?`手机名称`:`Phone name`,(0,D.jsx)(`input`,{className:C,value:n,maxLength:100,disabled:f,onChange:e=>r(e.target.value)})]}),(0,D.jsxs)(`label`,{className:`block text-sm`,children:[e?`ADB 地址`:`ADB address`,(0,D.jsx)(`input`,{className:C,placeholder:`203.0.113.10:10001`,value:i,disabled:f,autoComplete:`off`,onChange:e=>{y(),a(e.target.value)}})]}),(0,D.jsxs)(`label`,{className:`block text-sm`,children:[e?`私钥文件(adbkey)`:`Private key file (adbkey)`,(0,D.jsx)(`input`,{className:C,type:`file`,disabled:f,onChange:e=>{y(),s(e.target.files?.[0])}})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`私钥仅提交到当前 Gateway,添加后保存在 Gateway 凭据目录,不会替换电脑现有 ADB 密钥。`:`The key is sent only to this Gateway and saved in its credentials directory after adding. Existing host ADB keys stay unchanged.`}),(0,D.jsx)(_,{disabled:f||!i.trim()||!o,onClick:()=>void b(),children:f?e?`处理中…`:`Working…`:e?`测试连接`:`Test connection`}),m&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:m}),c&&(0,D.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,D.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[e?`连接成功`:`Connected`,` · `,c.model,` · Android `,c.androidVersion]}),(0,D.jsx)(`img`,{src:c.screenshot,alt:e?`云手机当前画面`:`Current cloud phone screen`,className:`mx-auto max-h-64 rounded-lg object-contain`}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`添加后可在聊天中使用实时视频、接管操作和交还 Agent;视频不可用时使用截图。测试结果有效期为 10 分钟。默认只允许系统设置,添加后可在「管理」中调整。`:`After adding, use live video, takeover and Agent handback in chat, with snapshots when video is unavailable. Test expires after 10 minutes. Settings is the initial allowed app; adjust it in Manage.`}),(0,D.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:u,disabled:f,onChange:e=>d(e.target.checked)}),e?`设为默认手机`:`Set as default phone`]}),(0,D.jsx)(_,{variant:`primary`,disabled:f||!n.trim()||c.expiresAt<=Date.now(),onClick:()=>void x(),children:e?`添加手机`:`Add phone`})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`移除连接只删除 xopc 的连接与私钥,不会销毁云手机,也不会关闭阿里云侧的 ADB 端口。`:`Removing a connection deletes its xopc credentials. It does not destroy the cloud phone or close its cloud ADB endpoint.`})]})}var O=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm`,k=new Set([`connected`,`timeout`,`error`,`cancelled`]);function A({zh:e,onSelect:t}){let[n,r]=(0,E.useState)(`qr`),[i,a]=(0,E.useState)(),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(``),[f,p]=(0,E.useState)(``),[m,v]=(0,E.useState)(``),[y,x]=(0,E.useState)(!1),[C,w]=(0,E.useState)(``),[T,ee]=(0,E.useState)(Date.now()),A=(0,E.useRef)(void 0),j=(0,E.useRef)(0),M=(0,E.useRef)(t);M.current=t;let N=g(`phone-wireless-discovery`,()=>S(`/wireless/discovery`),{refreshInterval:4e3}),P=()=>{j.current++;let e=A.current;A.current=void 0,e&&S(`/wireless/pairings/${e}`,void 0,`DELETE`).catch(()=>{})},F=async e=>{P();let t=j.current;x(!0),w(``),a(void 0),s(``);try{if(e===`connect`){let e=await S(`/wireless/connect`,{host:c,port:Number(f)});j.current===t&&M.current(e)}else{let n=await S(`/wireless/pairings`,e===`qr`?{method:`qr`}:{method:`code`,host:c,pairingPort:Number(u),code:m,...f?{connectPort:Number(f)}:{}});if(j.current!==t){S(`/wireless/pairings/${n.id}`,void 0,`DELETE`).catch(()=>{});return}A.current=n.id,a(n),v(``)}}catch(e){j.current===t&&w(e instanceof Error?e.message:String(e))}finally{j.current===t&&x(!1)}};(0,E.useEffect)(()=>(n===`qr`&&F(`qr`),P),[n]),(0,E.useEffect)(()=>{let t=!0;return s(``),i?.qrPayload&&b(i.qrPayload).then(e=>{t&&s(e)}).catch(()=>{t&&w(e?`二维码生成失败,请重试`:`Unable to render QR code`)}),()=>{t=!1}},[i?.qrPayload,e]),(0,E.useEffect)(()=>{if(!i||k.has(i.status))return;let e=!0,t,n=async()=>{try{let r=await S(`/wireless/pairings/${i.id}`);if(!e)return;if(a(r),ee(Date.now()),r.status===`connected`&&r.device){M.current(r.device);return}k.has(r.status)||(t=setTimeout(()=>{n()},1e3))}catch(r){if(!e)return;w(r instanceof Error?r.message:String(r)),Date.now()<i.expiresAt+5e3?t=setTimeout(()=>{n()},2e3):a(e=>e&&{...e,status:`timeout`,qrPayload:void 0})}};return t=setTimeout(()=>{n()},1e3),()=>{e=!1,clearTimeout(t)}},[i?.id,i?.status]);let I=e?{waiting:`等待扫码`,pairing:`正在配对`,paired:`已配对,正在查找连接地址`,connecting:`正在连接`,connected:`已连接`,timeout:`操作超时`,error:`配对失败`,cancelled:`已取消`}:{waiting:`Waiting for scan`,pairing:`Pairing`,paired:`Paired · Finding connection address`,connecting:`Connecting`,connected:`Connected`,timeout:`Timed out`,error:`Pairing failed`,cancelled:`Cancelled`},L=y||!!(i&&!k.has(i.status));return(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-inset p-3 text-sm`,children:e?`手机须与 Gateway 所在电脑处于同一局域网。仅浏览器与手机同网还不够。支持 Android 11 及以上。`:`Android 11+. The phone and Gateway host must share a local network.`}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":e?`无线连接方式`:`Wireless connection method`,children:[[`qr`,e?`扫码配对`:`QR pairing`],[`code`,e?`配对码`:`Pairing code`],[`connect`,e?`连接已配对设备`:`Already paired`]].map(([e,t])=>(0,D.jsx)(_,{"aria-pressed":n===e,onClick:()=>{P(),x(!1),a(void 0),w(``),s(``),r(e)},children:t},e))}),(0,D.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5 text-sm text-fg-muted`,children:[(0,D.jsx)(`li`,{children:e?`打开手机「设置 → 开发者选项 → 无线调试」。`:`Open Settings → Developer options → Wireless debugging.`}),(0,D.jsx)(`li`,{children:n===`qr`?e?`选择「使用二维码配对设备」,扫描下方二维码。`:`Choose Pair device with QR code and scan below.`:n===`code`?e?`选择「使用配对码配对设备」,填写显示的地址和六位配对码。`:`Choose Pair device with pairing code and enter its address and six-digit code.`:e?`填写无线调试首页显示的 IP 地址与连接端口。`:`Enter the IP and port shown on the main Wireless debugging screen.`})]}),N.isLoading&&(0,D.jsx)(h,{className:`h-12 w-full`}),(N.error||N.data?.mdns===!1)&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:e?`自动发现不可用。可使用配对码并手动填写连接端口。请检查 Gateway 的 ADB、网络及防火墙。`:`Discovery unavailable. Use a pairing code and enter the connection port manually. Check Gateway ADB, network and firewall.`}),n===`qr`?(0,D.jsxs)(`div`,{className:`space-y-3 text-center`,children:[o?(0,D.jsx)(`img`,{src:o,alt:e?`无线调试配对二维码`:`Wireless debugging pairing QR code`,className:`mx-auto size-60 rounded-lg bg-white`}):i&&!k.has(i.status)?(0,D.jsx)(h,{className:`mx-auto size-60`}):null,i&&(0,D.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[I[i.status],k.has(i.status)?``:` · ${Math.max(0,Math.ceil((i.expiresAt-T)/1e3))}s`]}),(0,D.jsx)(_,{disabled:y,onClick:()=>{F(`qr`)},children:e?`重新生成`:`Regenerate`})]}):(0,D.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),F(n)},children:[N.data?.services.filter(e=>e.kind===(n===`code`?`pairing`:`connect`)).map(e=>(0,D.jsxs)(_,{type:`button`,disabled:L,onClick:()=>{if(l(e.host),n===`code`){d(String(e.port));let t=N.data?.services.find(t=>t.kind===`connect`&&t.host===e.host);p(t?String(t.port):``)}else p(String(e.port))},children:[e.host,`:`,e.port]},`${e.name}:${e.port}`)),(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`手机 IP 地址`:`Phone IP address`,(0,D.jsx)(`input`,{className:O,value:c,onChange:e=>l(e.target.value.trim()),required:!0,disabled:L,placeholder:`192.168.1.10`})]}),n===`code`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`配对端口`:`Pairing port`,(0,D.jsx)(`input`,{className:O,type:`number`,min:1,max:65535,value:u,onChange:e=>d(e.target.value),required:!0,disabled:L})]}),(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`六位配对码`:`Six-digit pairing code`,(0,D.jsx)(`input`,{className:O,inputMode:`numeric`,autoComplete:`off`,pattern:`[0-9]{6}`,maxLength:6,value:m,onChange:e=>v(e.target.value),required:!0,disabled:L})]})]}),(0,D.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[e?`连接端口`:`Connection port`,(0,D.jsx)(`input`,{className:O,type:`number`,min:1,max:65535,value:f,onChange:e=>p(e.target.value),required:n===`connect`,disabled:L,placeholder:e?`留空自动发现`:`Auto-discover if empty`})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`连接端口在无线调试首页显示,与配对端口不同,会随设备状态变化。`:`The connection port is on the main Wireless debugging screen. It differs from the pairing port and can change.`}),i&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm`,children:I[i.status]}),(0,D.jsx)(_,{type:`submit`,disabled:L,children:e?n===`code`?`配对并连接`:`连接`:n===`code`?`Pair and connect`:`Connect`})]}),i?.errorCode&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:i.errorCode===`PHONE_CONNECT_TIMEOUT`?e?`已配对,但未能连接。切换「连接已配对设备」并填写当前连接端口,无需重新配对。`:`Paired but not connected. Use Already paired with the current connection port.`:e?`未完成配对。请检查手机配对页面、网络和配对码后重试。`:`Pairing incomplete. Check the phone pairing screen, network and code, then retry.`}),L&&(0,D.jsx)(_,{onClick:()=>{P(),x(!1),a(void 0),s(``)},children:e?`取消配对`:`Cancel pairing`}),C&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:C})]})}var j=[{id:`wireless`,available:!0,name:[`无线连接 Android 手机`,`Wireless Android phone`],description:[`Android 11+,扫码或输入配对码,无需数据线。`,`Android 11+ · Pair with a QR code or pairing code.`]},{id:`local-adb`,available:!0,name:[`Gateway 电脑上的手机 / 模拟器`,`Phone or emulator on the Gateway host`],description:[`通过 USB 或已配对的无线 ADB 连接。`,`Connect over USB or previously paired wireless ADB.`]},{id:`remote-connector`,available:!1,name:[`通过本地连接器连接`,`Local connector`],description:[`Gateway 在服务器上,手机连接在你的电脑上。`,`Connect a phone on your computer to a remote Gateway.`]},{id:`aliyun`,available:!0,name:[`阿里云手机`,`Alibaba Cloud Phone`],description:[`填写 ADB 地址并上传私钥,连接已有云手机。`,`Connect an existing cloud phone with its ADB address and private key.`]},{id:`tencent`,available:!1,name:[`腾讯云手机`,`Tencent Cloud Phone`],description:[`连接云账号,选择地域和已有实例。`,`Connect an account, then choose a region and existing instance.`]}];function M(e){let t=(0,T.c)(48),{zh:n,onClose:r,onSelect:i,onAdded:v,initialMethod:y}=e,[b,S]=(0,E.useState)(y),C;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(C={refreshInterval:3e3},t[0]=C):C=t[0];let w=g(b===`local-adb`?`phone-devices`:null,x,C),O;t[1]===b?O=t[2]:(O=j.find(e=>e.id===b),t[1]=b,t[2]=O);let k=O,M=+!n,N;t[3]===n?N=t[4]:(N=n?{device:`已连接,可添加`,unauthorized:`等待手机授权:解锁手机,点击「允许 USB 调试」`,offline:`设备离线:重新连接数据线或无线调试`,recovery:`恢复模式:请先启动 Android 系统`,sideload:`请退出刷机模式并启动 Android 系统`}:{device:`Connected · Ready to add`,unauthorized:`Unlock the phone and allow USB debugging`,offline:`Offline · Reconnect USB or wireless debugging`,recovery:`Boot Android before connecting`,sideload:`Exit sideload mode and boot Android`},t[3]=n,t[4]=N);let P=N,F;t[5]===w.data?.discovery?F=t[6]:(F=w.data?.discovery??[],t[5]=w.data?.discovery,t[6]=F);let I=F,L;t[7]===r?L=t[8]:(L=e=>{e||r()},t[7]=r,t[8]=L);let R;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,D.jsx)(a,{className:`fixed inset-0 z-[80] bg-black/40`}),t[9]=R):R=t[9];let z;t[10]!==b||t[11]!==n?(z=b&&(0,D.jsx)(_,{variant:`ghost`,"aria-label":n?`返回连接方式`:`Back to connection methods`,onClick:()=>S(void 0),children:(0,D.jsx)(f,{className:`size-4`})}),t[10]=b,t[11]=n,t[12]=z):z=t[12];let B=n?`添加手机`:`Add phone`,V;t[13]===B?V=t[14]:(V=(0,D.jsx)(u,{className:`text-base font-semibold`,children:B}),t[13]=B,t[14]=V);let H=k?k.name[M]:n?`选择手机连接在哪里。手机模型在添加设备后独立配置。`:`Choose where the phone connects. Phone models are configured separately.`,U;t[15]===H?U=t[16]:(U=(0,D.jsx)(o,{className:`mt-1 text-sm text-fg-muted`,children:H}),t[15]=H,t[16]=U);let W;t[17]!==U||t[18]!==V?(W=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[V,U]}),t[17]=U,t[18]=V,t[19]=W):W=t[19];let G=n?`关闭添加手机`:`Close add phone`,K;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,D.jsx)(m,{className:`size-4`}),t[20]=K):K=t[20];let q;t[21]===G?q=t[22]:(q=(0,D.jsx)(s,{asChild:!0,children:(0,D.jsx)(_,{variant:`ghost`,"aria-label":G,children:K})}),t[21]=G,t[22]=q);let J;t[23]!==W||t[24]!==q||t[25]!==z?(J=(0,D.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge p-5`,children:[z,W,q]}),t[23]=W,t[24]=q,t[25]=z,t[26]=J):J=t[26];let Y;t[27]!==w||t[28]!==I||t[29]!==M||t[30]!==b||t[31]!==v||t[32]!==r||t[33]!==i||t[34]!==P||t[35]!==n?(Y=b?b===`aliyun`?(0,D.jsx)(ee,{zh:n,onAdded:()=>{v?.(),r()}}):b===`wireless`?(0,D.jsx)(A,{zh:n,onSelect:i}):b===`local-adb`?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-inset p-3 text-sm`,children:n?`连接位置:Gateway 所在电脑。若 Gateway 在服务器上,浏览器无法访问你电脑的 USB 手机。`:`Connection location: the Gateway host. A remote Gateway cannot access your browser computer’s USB phone.`}),(0,D.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-sm text-fg-muted`,children:[(0,D.jsx)(`li`,{children:n?`手机开启开发者选项和 USB 调试;模拟器直接启动即可。`:`Enable developer options and USB debugging, or start an emulator.`}),(0,D.jsx)(`li`,{children:n?`用数据线连接 Gateway 电脑,在手机上允许 USB 调试。`:`Connect to the Gateway host with a data cable, then allow USB debugging on the phone.`}),(0,D.jsx)(`li`,{children:n?`等待下方显示设备,选择后确认名称和应用范围。`:`Select a discovered device below, then confirm its name and app access.`})]}),(0,D.jsxs)(`details`,{className:`text-sm`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:n?`使用无线连接或安装连接工具`:`Wireless connection or connection tools`}),(0,D.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:n?`可返回连接方式,选择「无线连接 Android 手机」进行扫码或配对码配对。ADB 可在手机控制页的「手机依赖状态」中手动安装,或使用 Gateway 电脑上已有的 Platform Tools;无需安装完整 Android Studio。`:`Choose Wireless Android phone to pair with a QR code or pairing code. Install ADB from Phone dependencies or use existing Platform Tools on the Gateway host.`}),(0,D.jsx)(`a`,{href:`https://developer.android.com/tools/adb`,target:`_blank`,rel:`noopener noreferrer`,className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,children:n?`查看 Android 官方连接指引`:`Android connection guide`})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`发现的设备`:`Discovered devices`}),(0,D.jsxs)(_,{disabled:w.isValidating,onClick:()=>{w.mutate()},children:[(0,D.jsx)(p,{className:`size-4`}),n?`刷新`:`Refresh`]})]}),!w.data&&!w.error?(0,D.jsx)(h,{className:`h-24 w-full rounded-xl`}):null,(w.error||w.data?.diagnostic)&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[n?`无法检测设备,请检查 Gateway 电脑的 ADB 安装与连接。`:`Unable to detect devices. Check ADB on the Gateway host.`,(0,D.jsx)(`span`,{className:`mt-1 block break-all text-xs`,children:w.data?.diagnostic??String(w.error)})]}),I.map(e=>{let t=w.data?.devices.some(t=>t.serial===e.serial);return(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge p-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium`,children:e.name}),(0,D.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:e.serial}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:P[e.state]??e.state})]}),(0,D.jsx)(_,{disabled:t||e.state!==`device`,onClick:()=>i(e),children:t?n?`已添加`:`Added`:n?`选择设备`:`Choose device`})]},e.serial)}),w.data&&!I.length&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:n?`尚未发现设备。请检查数据线、手机调试授权,或启动模拟器。`:`No devices found. Check the cable and debugging authorization, or start an emulator.`})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-medium`,children:n?`此接入方式暂未支持`:`This connection method is not available yet`}),(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b===`remote-connector`?n?`后续可通过本地连接器将电脑上的手机接入远程 Gateway。当前请将手机连接到 Gateway 所在电脑。`:`A future local connector will connect your phone to a remote Gateway. For now, connect it to the Gateway host.`:n?`云手机适配器接入后,可配置云账号、选择地域和已有实例,再验证连接并添加。当前尚不能连接云实例,不会要求填写云密钥。`:`Once the cloud adapter is available, connect an account, select a region and existing instance, then verify and add it. Cloud connections are not supported yet.`}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`添加已有实例与购买、创建、销毁实例分开处理。`:`Adding existing instances is separate from purchasing, creating or destroying them.`})]}):j.map(e=>(0,D.jsxs)(`button`,{className:`block min-h-20 w-full rounded-xl border border-edge bg-surface-base p-4 text-left hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent`,onClick:()=>S(e.id),children:[(0,D.jsxs)(`span`,{className:`flex flex-wrap items-center justify-between gap-2 text-sm font-medium`,children:[e.name[M],!e.available&&(0,D.jsx)(`span`,{className:`text-xs font-normal text-fg-muted`,children:n?`暂未支持`:`Not available yet`})]}),(0,D.jsx)(`span`,{className:`mt-2 block text-xs text-fg-muted`,children:e.description[M]})]},e.id)),t[27]=w,t[28]=I,t[29]=M,t[30]=b,t[31]=v,t[32]=r,t[33]=i,t[34]=P,t[35]=n,t[36]=Y):Y=t[36];let X;t[37]===Y?X=t[38]:(X=(0,D.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-5`,children:Y}),t[37]=Y,t[38]=X);let te=n?`取消`:`Cancel`,Z;t[39]===te?Z=t[40]:(Z=(0,D.jsx)(`footer`,{className:`flex shrink-0 justify-end border-t border-edge p-4`,children:(0,D.jsx)(s,{asChild:!0,children:(0,D.jsx)(_,{children:te})})}),t[39]=te,t[40]=Z);let Q;t[41]!==J||t[42]!==X||t[43]!==Z?(Q=(0,D.jsxs)(c,{children:[R,(0,D.jsxs)(l,{className:`fixed left-1/2 top-1/2 z-[81] flex h-[min(42rem,90dvh)] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay text-fg`,children:[J,X,Z]})]}),t[41]=J,t[42]=X,t[43]=Z,t[44]=Q):Q=t[44];let $;return t[45]!==Q||t[46]!==L?($=(0,D.jsx)(d,{open:!0,onOpenChange:L,children:Q}),t[45]=Q,t[46]=L,t[47]=$):$=t[47],$}function N({value:e,zh:t,disabled:n,onSave:r,onSelect:a}){let o=g(`phone-models`,w),s=g(`phone-provider-meta`,y),[c,l]=(0,E.useState)(e),[u,d]=(0,E.useState)(!1),[f,p]=(0,E.useState)(``),[m,h]=(0,E.useState)(!1);(0,E.useEffect)(()=>{l(e)},[e]);let b=o.data?.models.find(e=>e.id===c),x=c.split(`/`)[0],S=s.data?.find(e=>e.id===x)?.name??x,T=!c||!!b?.configured,ee=async()=>{if(!(u||!T)){d(!0),p(``),h(!1);try{await r(c),h(!0)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start`,children:[(0,D.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,D.jsx)(C,{value:c,onChange:e=>{l(e),a?.(e),h(!1),p(``)},zh:t,disabled:n||u})}),(0,D.jsx)(_,{variant:c===e?`secondary`:`primary`,disabled:n||u||!o.data||!T||c===e,onClick:()=>{ee()},children:u?t?`保存中…`:`Saving…`:t?`保存`:`Save`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[c&&o.data?(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:b?`${S} · ${b.configured?t?`凭据就绪`:`Credentials ready`:t?`请先配置凭据`:`Configure credentials first`}`:t?`当前模型不可用,请重新选择。`:`This model is unavailable. Choose another model.`}):null,(0,D.jsx)(i,{to:`/settings/capabilities/models?returnTo=%2Fsettings%2Fphone-use&purpose=phone`,onClick:e=>{!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&(e.preventDefault(),v(`chat`,`services`,`phone`))},className:`inline-flex min-h-8 items-center text-xs text-accent-fg hover:underline`,children:t?`管理模型`:`Manage models`})]}),f&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f}),m&&(0,D.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`手机模型已保存,请返回手机连接测试实际操作。`:`Phone model saved. Test it from the phone connection.`})]})}export{M as n,N as t};